@yuriai/web 0.3.2-beta.5 → 0.3.2-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentAvatar-CBL6sHJE.js → AgentAvatar-b8inwRDh.js} +1 -1
- package/dist/assets/{AssistantConversationSurface-Cp2d6O6B.js → AssistantConversationSurface-DcXXPlNA.js} +3 -3
- package/dist/assets/{AssistantSessionCard-DFrNXOAT.js → AssistantSessionCard-DX7b5oge.js} +2 -2
- package/dist/assets/{AssistantUnreadBadge-Bo73Q6BB.js → AssistantUnreadBadge-D2d4OBjo.js} +1 -1
- package/dist/assets/{AssistantView-vuLTK9d2.js → AssistantView-oeyp5moU.js} +1 -1
- package/dist/assets/{DiagramView-BjOVH-j5.js → DiagramView-zPxVoYfO.js} +1 -1
- package/dist/assets/{FadeInOnReveal-DMPdjrLF.js → FadeInOnReveal-DqqNgA5K.js} +1 -1
- package/dist/assets/{GuiPluginPage-BH4y6vow.js → GuiPluginPage-XEOZ2YIE.js} +1 -1
- package/dist/assets/{GuiPluginSurface-CGlVzvxa.js → GuiPluginSurface-BLoRfTGO.js} +1 -1
- package/dist/assets/{GuiPluginWindow-4R5kzF0A.js → GuiPluginWindow-BS0XZ8UB.js} +1 -1
- package/dist/assets/{Icon-ClBPpnUf.js → Icon-DNZA_riL.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-DEPgECiZ.js → ImageLoadingPlaceholder-xLFiotWm.js} +1 -1
- package/dist/assets/{LoadingImage-6RgbsYqE.js → LoadingImage-B1Q7emSX.js} +1 -1
- package/dist/assets/{MarkdownRenderer-CZ7klEN1.js → MarkdownRenderer-D2oCSF9S.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-Vx_EJkjx.js → MarkdownRendererImpl-CL86tRxk.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-DHO-8Jdb.js → MarkstreamRendererImpl-CbS9t0Lb.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-CGOUP3hG.js → MobileDetailNavigation-D9OZvTH7.js} +1 -1
- package/dist/assets/{MobileResizableSheet-CaVmfnq6.js → MobileResizableSheet-CJLBR89R.js} +1 -1
- package/dist/assets/{MobileShareBridge-DL7arvpR.js → MobileShareBridge-BqhP1wSW.js} +1 -1
- package/dist/assets/{MobileSurface-DjCDAZL8.js → MobileSurface-DFRJ7nyL.js} +1 -1
- package/dist/assets/{MultiRunWindow-G5K_lWwa.js → MultiRunWindow-BjmrZIN8.js} +1 -1
- package/dist/assets/{OnboardingScreen-CDzgaBUD.js → OnboardingScreen-6UdQ9pI2.js} +1 -1
- package/dist/assets/{OverlayScrollbar-B95V3IGT.js → OverlayScrollbar-BsUherue.js} +1 -1
- package/dist/assets/{RemoteAssistantSessionCard-C_QT0goG.js → RemoteAssistantSessionCard-DuhxRmG_.js} +1 -1
- package/dist/assets/{SettingsView-CuGWlw_X.js → SettingsView-CmYrql0Y.js} +1 -1
- package/dist/assets/{SettingsWindow-DIW0AQRS.js → SettingsWindow-DbAjbzAm.js} +1 -1
- package/dist/assets/{SetupTourDialog-BRrS7Dpd.js → SetupTourDialog-sMu7cJS7.js} +1 -1
- package/dist/assets/{TerminalView-FVDCLrdP.js → TerminalView-BmdJXwbs.js} +1 -1
- package/dist/assets/{ToolOutputDialog-CifgNF-1.js → ToolOutputDialog-C03nGQvh.js} +1 -1
- package/dist/assets/{VoiceSettings-DxGAZJAV.js → VoiceSettings-DV3EAW04.js} +1 -1
- package/dist/assets/{capgoAdapter-D6TPMM9f.js → capgoAdapter-SjN4JN3S.js} +1 -1
- package/dist/assets/{checkbox-CybLE-Zl.js → checkbox-BmDsqYlN.js} +1 -1
- package/dist/assets/{collapsible-D2mwqRkT.js → collapsible-CYFRNuOh.js} +1 -1
- package/dist/assets/{context-menu-Cm7xs4XO.js → context-menu-Ba6Opvzx.js} +1 -1
- package/dist/assets/{diagram-CabYt3Db.js → diagram-D0rZqQqX.js} +1 -1
- package/dist/assets/{dialog-DyvzUXG3.js → dialog-DcdiMxIb.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-D6Rpu5f_.js → fileMentionTouchSelection-BZufsE6q.js} +1 -1
- package/dist/assets/{gitApi-DlwTh9NW.js → gitApi-B74KW8UU.js} +1 -1
- package/dist/assets/{input-C6MAf06e.js → input-BSVjxHBf.js} +1 -1
- package/dist/assets/{insertionBoundaries-C-4cteSY.js → insertionBoundaries-Dt_DdXrL.js} +1 -1
- package/dist/assets/{main-CbtlQbQI.js → main-BezENVit.js} +2 -2
- package/dist/assets/{main-DDLH1X63.js → main-CN6evHsO.js} +5 -5
- package/dist/assets/{markdownHeightCache-JuN3oMi6.js → markdownHeightCache-248kmm0A.js} +1 -1
- package/dist/assets/{mcpQueries-Dd_VmvWV.js → mcpQueries-Da7X2ZE0.js} +1 -1
- package/dist/assets/{miniChat-CiNYAPRr.js → miniChat-BYxNlok6.js} +2 -2
- package/dist/assets/{mobile-CGKpsHw1.js → mobile-CVir7hmR.js} +2 -2
- package/dist/assets/{mobileBackNavigation-D3OhbamI.js → mobileBackNavigation-CbHUVgUi.js} +1 -1
- package/dist/assets/{mobileConnections-BK433R6N.js → mobileConnections-B2OHZP1-.js} +2 -2
- package/dist/assets/{multirun-Dzs8FDNn.js → multirun-BtlXFSSx.js} +1 -1
- package/dist/assets/{native-config-uc65vCw8.js → native-config-C7I5Js2W.js} +1 -1
- package/dist/assets/{navigation-DDzw_NEu.js → navigation-Bart975B.js} +1 -1
- package/dist/assets/{openRemoteProjectSession-DkJL986P.js → openRemoteProjectSession-BHawZ5DM.js} +1 -1
- package/dist/assets/{projectMeta-CsrDVoC1.js → projectMeta-548A_zjC.js} +1 -1
- package/dist/assets/{pwa-DHXIykNQ.js → pwa-BGxwZ3sK.js} +1 -1
- package/dist/assets/{queue-abort-optimistic-BsmRDwoS.js → queue-abort-optimistic-Axqv48kA.js} +1 -1
- package/dist/assets/{react-KM6tXYVe.js → react-DUWkLJW_.js} +1 -1
- package/dist/assets/{readiness-BanqgdIH.js → readiness-DpD_wUMJ.js} +2 -2
- package/dist/assets/{reference-history-DoOTboVn.js → reference-history-D7pv4xBj.js} +1 -1
- package/dist/assets/{remoteSessionReference-BJh0TdIi.js → remoteSessionReference-D4uRxFrm.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-BIhAX0oU.js → renderElectronMiniChatApp-CRP1yE3w.js} +2 -2
- package/dist/assets/{renderMobileApp-COx1KhSz.js → renderMobileApp-DDcooBwa.js} +4 -4
- package/dist/assets/{runtimeConfig-Cy1it_q_.js → runtimeConfig-CVQXB6Sk.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-DsuHDYDQ.js → runtimeEndpointReset-SUR75n8I.js} +3 -3
- package/dist/assets/{select-lbIrGcNl.js → select-DikdnuBx.js} +1 -1
- package/dist/assets/{sessionLookup-CBezXNzA.js → sessionLookup-DIImfb9J.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-G4QUbJpF.js → sortable-tabs-strip-2Mhh65oR.js} +1 -1
- package/dist/assets/{speechSettingsQueries-CoVmOYle.js → speechSettingsQueries-B3yVfEX8.js} +1 -1
- package/dist/assets/{textarea-BcfQlOYG.js → textarea-CjzOsOcb.js} +1 -1
- package/dist/assets/{tooltip-CIc7xlps.js → tooltip-o8hl4eie.js} +1 -1
- package/dist/assets/{types-B3ZWGgBY.js → types-CsZ29VjS.js} +1 -1
- package/dist/assets/{useAppFontEffects-BIdV2CzE.js → useAppFontEffects-BPTPdll8.js} +5 -5
- package/dist/assets/{useDesktopWindowControlsLayout-B-2bY2eA.js → useDesktopWindowControlsLayout-ug8tD9Vh.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-1f4VS7c7.js → useEffectiveDirectory-DP_Vb2yB.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-CoZJ4Era.js → useMobileNavigationStore-CXvADUF9.js} +4 -4
- package/dist/assets/{usePluginsStore-DRHBLsBS.js → usePluginsStore-CfZJ7xPI.js} +1 -1
- package/dist/assets/{useProjectRuntimeAPIs-b3443nPE.js → useProjectRuntimeAPIs-C47fBxo8.js} +1 -1
- package/dist/assets/{useStreamingTextThrottle-Bj4ojbIP.js → useStreamingTextThrottle-BZD-fFFZ.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,p as r,t as i,v as a,w as o}from"./runtime-auth-mjIpsk3N.js";import{c as s,f as c,i as l,n as u,o as d,r as f,s as p,t as m}from"./runtime-switch-BMjl5Y5W.js";import{n as h}from"./runtime-fetch-DKZOpfzo.js";import{$ as g,A as _,F as v,G as y,H as b,L as x,P as S,Q as C,R as w,U as T,W as E,X as D,a as O,c as k,ct as A,dt as j,f as M,it as N,j as P,k as F,l as I,lt as L,m as R,p as z,s as ee,st as B,u as V,ut as te,v as ne,z as re}from"./platform-wF65ZFgV.js";import{n as ie,t as ae}from"./runtimeAPIRegistry-C2VogTny.js";import{d as oe,h as H,m as se,r as U,v as ce}from"./desktopHosts-135cuRCE.js";import{a as W,i as le,t as ue}from"./vendor-zustand-CNn3HHhT.js";import{A as de,B as fe,C as pe,F as me,I as he,L as ge,M as _e,N as ve,R as ye,S as be,T as xe,a as Se,i as Ce,it as we,j as Te,ot as Ee,st as De,z as Oe}from"./vendor-base-ui-fom6orB6.js";import{Ct as ke,Et as Ae,Ft as je,Mt as Me,Pt as Ne,St as Pe,Tt as Fe,an as Ie,jt as Le,on as Re,wt as G,xt as ze}from"./gitApiHttp-BEMPJCIG.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as Be,r as Ve,t as He}from"./safeStorage-DTOhKN0V.js";import{Bt as Ue,Ct as We,Jt as Ge,Qt as Ke,U as qe,V as Je,Yt as Ye,Zt as Xe,gt as Ze,ht as Qe,in as $e,n as et,nn as tt,on as nt,pt as rt,sn as it,yr as at,zt as ot}from"./client-CgAFd1ew.js";import{P as st,d as ct,z as lt}from"./prompt-attachment-upload-8bssUUT3.js";import{n as ut,t as dt}from"./vendor-react-D5BntRmA.js";import{f as ft,u as pt}from"./vendor-tanstack-query-core-BSjXNgF_.js";import{n as mt,o as ht,s as gt}from"./vendor-tanstack-react-query-ChSd65dm.js";import{E as _t,H as vt,L as yt,O as bt,P as xt,V as St,c as Ct,q as wt,r as Tt,s as Et,t as Dt,y as Ot,z as kt}from"./runtime-file-resource-DnhWnndu.js";import{a as At,n as jt}from"./path-utils-jGozTg9d.js";import{h as Mt,m as Nt,r as K}from"./vendor-reactuses-core-B8s-Rcd-.js";import{o as Pt}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{a as Ft,i as It,o as Lt,r as q,s as Rt,t as zt}from"./useUIStore-CYex4rbF.js";import{o as Bt}from"./useMobileHtmlPreviewStore-DUquFMmd.js";import{n as Vt,r as Ht}from"./terminalApi-eR_918UZ.js";import{a as Ut}from"./types-B3ZWGgBY.js";import{t as Wt}from"./bootstrap-eLlfzqAI.js";/* empty css */import{U as Gt}from"./vendor-codemirror-autocomplete-C0FrlFqZ.js";import{a as Kt}from"./vendor-pierre-diffs-HJfPTtu2.js";import{a as qt,i as Jt,n as Yt,r as Xt,t as Zt}from"./i18n-OsFhnlRH.js";import{n as Qt}from"./store-Dj5cSf8B.js";import{S as $t,b as en,h as tn}from"./MobileDetailNavigation-CGOUP3hG.js";import{$a as nn,A as rn,Bn as an,C as on,Ci as J,Er as sn,F as cn,Fa as ln,Ft as un,Ga as dn,Gr as fn,H as pn,Ha as mn,Hn as hn,I as gn,In as Y,Ir as _n,Kt as vn,Lr as yn,Mr as bn,Oi as xn,Or as Sn,Pr as Cn,R as wn,Rn as X,S as Tn,Si as En,Sn as Dn,Tr as On,U as kn,Un as An,Vn as jn,W as Mn,Wa as Nn,Wi as Pn,Wn as Fn,Yi as In,Zi as Ln,Zr as Rn,at as zn,b as Bn,bt as Vn,ct as Hn,da as Un,di as Wn,eo as Gn,er as Kn,et as qn,ft as Jn,g as Yn,gi as Xn,hi as Zn,hr as Qn,in as $n,j as er,kr as tr,m as nr,mi as rr,mr as ir,mt as ar,oi as or,ot as sr,p as cr,pi as lr,pt as ur,qr as dr,qt as fr,ra as pr,st as mr,to as hr,tt as gr,ut as _r,vi as vr,vt as yr,wr as br,x as xr,xi as Sr,y as Cr,yi as wr,yt as Tr,zn as Er}from"./useMobileNavigationStore-CoZJ4Era.js";import{n as Dr}from"./useAssistantUIStore-CphyXHEY.js";import{n as Or}from"./input-store-DRTu4uZc.js";import{d as kr,h as Ar,m as jr,p as Mr}from"./remoteProjectQueries-8giIAvzL.js";import{a as Nr,c as Pr,i as Fr,l as Ir,o as Lr,s as Rr}from"./toolHelpers-iEHVHQ9p.js";import{n as zr}from"./useThemeSystem-D2YBbLma.js";import{n as Br,o as Vr}from"./vendor-framer-motion-DiGWHm7K.js";import{n as Z,t as Hr}from"./Icon-ClBPpnUf.js";import{a as Ur,i as Wr,n as Gr,o as Kr,r as qr,t as Jr}from"./dialog-DyvzUXG3.js";import{b as Yr,h as Xr,m as Zr}from"./gitApi-DlwTh9NW.js";import{$ as Qr,A as $r,At as ei,Bt as ti,Ct as ni,Dt as ri,Et as ii,F as ai,Ft as oi,Gt as si,Ht as ci,I as li,It as ui,J as di,Jt as fi,Kt as pi,L as mi,Lt as hi,M as gi,Mt as _i,N as vi,O as yi,Ot as bi,P as xi,Pt as Si,Q as Ci,Qt as wi,Rt as Ti,S as Ei,St as Di,Tt as Oi,U as ki,Ut as Ai,Vt as ji,Wt as Mi,Y as Ni,Yt as Pi,Zt as Fi,_ as Ii,_t as Li,at as Ri,b as zi,bt as Bi,c as Vi,ct as Hi,d as Ui,f as Wi,g as Gi,gt as Ki,h as qi,i as Ji,it as Yi,j as Xi,jt as Zi,k as Qi,kt as $i,l as ea,lt as ta,m as na,mt as ra,n as ia,nt as aa,ot as oa,p as sa,qt as ca,rt as la,s as ua,st as da,t as fa,tt as pa,u as ma,ut as ha,v as ga,w as _a,wt as va,x as ya,xt as ba,y as xa,z as Sa,zt as Ca}from"./useAppFontEffects-BIdV2CzE.js";import{t as wa}from"./input-C6MAf06e.js";import{i as Ta,n as Ea,r as Da,t as Oa}from"./tooltip-CIc7xlps.js";import{A as ka,C as Aa,D as ja,F as Ma,G as Na,I as Pa,J as Fa,K as Ia,O as La,Q as Ra,S as za,T as Ba,V as Va,Vt as Ha,W as Ua,Z as Wa,_ as Ga,at as Ka,c as qa,et as Ja,g as Ya,h as Xa,i as Za,it as Qa,jt as $a,m as eo,nt as to,o as no,ot as ro,p as io,q as ao,s as oo,st as so,u as co,v as lo,w as uo}from"./pwa-DHXIykNQ.js";import{t as fo}from"./YuriLogo-DNvrroBa.js";import{o as po,s as mo}from"./react-KM6tXYVe.js";import{a as ho,r as go}from"./device-C8ZHblkr.js";import{r as _o}from"./themes-BgDJcxRc.js";import{f as vo,g as yo,h as bo,p as xo}from"./scheduledTaskNavigation-Bi7sRiFW.js";import{a as So,n as Co,o as wo}from"./MarkdownRenderer-CZ7klEN1.js";import{T as To,_ as Eo,g as Do,h as Oo,w as ko}from"./insertionBoundaries-C-4cteSY.js";import{c as Ao,d as jo,i as Mo,l as No,n as Po,s as Fo,t as Io}from"./select-lbIrGcNl.js";import{a as Lo,i as Ro}from"./mobileBackNavigation-D3OhbamI.js";import{n as zo,t as Bo}from"./useEffectiveDirectory-1f4VS7c7.js";import{t as Vo}from"./ImageLoadingPlaceholder-DEPgECiZ.js";import{t as Ho}from"./LoadingImage-6RgbsYqE.js";import{_ as Uo,i as Wo,l as Go,n as Ko,s as qo,t as Jo,v as Yo}from"./vendor-dnd-kit-core-DRyd7I0I.js";import{a as Xo,n as Zo,s as Qo,t as $o}from"./vendor-dnd-kit-sortable-C8S8cyRO.js";import{n as es,r as ts}from"./textarea-BcfQlOYG.js";import{i as ns,n as rs,r as is,t as as}from"./dropdown-menu.styles-BDla58Rm.js";import{f as os,l as ss,p as cs,s as ls}from"./projectMeta-CsrDVoC1.js";import{p as us}from"./ToolOutputDialog-CifgNF-1.js";import{a as ds,i as fs}from"./sessionLookup-CBezXNzA.js";import{t as ps}from"./vendor-motion-DtmZZeEm.js";import{n as ms,t as hs}from"./useProjectRuntimeAPIs-b3443nPE.js";import{t as gs}from"./sortable-tabs-strip-G4QUbJpF.js";import{A as _s,C as vs,F as ys,G as bs,J as xs,K as Ss,M as Cs,N as ws,Q as Ts,S as Es,T as Ds,U as Os,X as ks,Y as As,_ as js,b as Ms,c as Ns,d as Ps,et as Fs,f as Is,h as Ls,j as Rs,k as zs,l as Bs,m as Vs,o as Hs,p as Us,q as Ws,u as Gs,v as Ks,w as qs,x as Js,y as Ys}from"./MobileSurface-DjCDAZL8.js";import{i as Xs,n as Zs,r as Qs,t as $s}from"./useDesktopWindowControlsLayout-B-2bY2eA.js";import{n as ec,t as tc}from"./openRemoteProjectSession-DkJL986P.js";import{n as nc}from"./useFontPreferences-DFF-uEAD.js";import{$ as rc,A as ic,At as ac,B as oc,Bt as sc,C as cc,D as lc,Et as uc,G as dc,Gt as fc,H as pc,Ht as mc,I as hc,It as gc,J as _c,Jt as vc,K as yc,Kt as bc,L as xc,Lt as Sc,M as Cc,Mt as wc,N as Tc,Nt as Ec,O as Dc,Ot as Oc,P as kc,Pt as Ac,Q as jc,R as Mc,Rt as Nc,S as Pc,Tt as Fc,U as Ic,Ut as Lc,V as Rc,Vt as zc,W as Bc,Wt as Vc,X as Hc,Xt as Uc,Y as Wc,Yt as Gc,Z as Kc,Zt as qc,_ as Jc,_t as Yc,a as Xc,b as Zc,bt as Qc,d as $c,et as el,g as tl,gt as nl,h as rl,ht as il,i as al,j as ol,jt as sl,k as cl,kt as ll,m as ul,n as dl,nt as fl,p as pl,q as ml,qt as hl,r as gl,rt as _l,tt as vl,v as yl,vt as bl,wt as xl,x as Sl,y as Cl,yt as wl,z as Tl,zt as El}from"./runtimeEndpointReset-DsuHDYDQ.js";import{t as Dl}from"./YuriWordmark-bJX68f2Y.js";import{a as Ol}from"./readiness-BanqgdIH.js";import{n as kl,t as Al}from"./relay-preview-frame-src-BPyz3nXA.js";import{t as jl}from"./AssistantUnreadBadge-Bo73Q6BB.js";import{a as Ml,i as Nl,n as Pl,r as Fl,t as Il}from"./context-menu-Cm7xs4XO.js";import{n as Ll,r as Rl,t as zl}from"./collapsible-D2mwqRkT.js";import{r as Bl,t as Vl}from"./navigation-DDzw_NEu.js";import{n as Hl,t as Ul}from"./GuiPluginPage-BH4y6vow.js";import{d as Wl,i as Gl,n as Kl,r as ql,u as Jl}from"./historyImportQueries-eR7Bj6VN.js";import{t as Yl}from"./diagram-CabYt3Db.js";import{a as Xl,i as Zl,n as Ql,o as $l,r as eu,t as tu}from"./multirun-Dzs8FDNn.js";import{a as nu,i as ru,n as iu,r as au,t as ou}from"./projectActions-50e_f9dI.js";import{t as su}from"./vendor-zumer-snapdom-yq9vlCKr.js";import{n as cu,t as lu}from"./vendor-html-to-image-BDMm2v6d.js";var Q=e(De(),1),uu=dt(),du=ut(),$=Ee();function fu(e){let t=(0,du.c)(14),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({size:i,className:n,style:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=typeof i==`number`?`${i}px`:i,s=typeof i==`number`?`${i}px`:i,c;t[5]!==a||t[6]!==o||t[7]!==s?(c={width:o,height:s,...a},t[5]=a,t[6]=o,t[7]=s,t[8]=c):c=t[8];let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`path`,{d:`M112,148a12,12,0,0,0-12,12v19L69.17,148.2A4,4,0,0,1,68,145.37V97.94a36,36,0,1,0-24,0v47.43a27.81,27.81,0,0,0,8.2,19.8L83,196H64a12,12,0,0,0,0,24h48a12,12,0,0,0,12-12V160A12,12,0,0,0,112,148ZM56,52A12,12,0,1,1,44,64,12,12,0,0,1,56,52ZM212,158.06V110.63a27.81,27.81,0,0,0-8.2-19.8L173,60h19a12,12,0,0,0,0-24H144a12,12,0,0,0-12,12V96a12,12,0,0,0,24,0V77l30.83,30.83a4,4,0,0,1,1.17,2.83v47.43a36,36,0,1,0,24,0ZM200,204a12,12,0,1,1,12-12A12,12,0,0,1,200,204Z`}),t[9]=l):l=t[9];let u;return t[10]!==n||t[11]!==r||t[12]!==c?(u=(0,$.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 256 256`,fill:`currentColor`,className:n,style:c,...r,children:l}),t[10]=n,t[11]=r,t[12]=c,t[13]=u):u=t[13],u}var pu=!1,mu=0,hu=new Set,gu=async()=>{let e=++mu;try{let t=await P(`desktop_is_window_fullscreen`);if(e!==mu||t===pu)return;pu=t===!0,hu.forEach(e=>e())}catch{}},_u=e=>v()?(hu.add(e),hu.size===1&&(window.addEventListener(`yuri:window-resized`,gu),gu()),()=>{hu.delete(e),hu.size===0&&(window.removeEventListener(`yuri:window-resized`,gu),mu++,pu=!1)}):()=>{};function vu(){return(0,Q.useSyncExternalStore)(_u,bu,yu)}function yu(){return!1}function bu(){return pu}function xu(){let e=(0,du.c)(19),{t}=Zt(),n=q(Eu),r=q(Tu),i=q(wu),a=q(Cu),o=q(Su),s=n&&r||i,c;e[0]!==n||e[1]!==r||e[2]!==i||e[3]!==a||e[4]!==o?(c=()=>{if(!r){n||a(!0),o(!i);return}a(!n)},e[0]=n,e[1]=r,e[2]=i,e[3]=a,e[4]=o,e[5]=c):c=e[5];let l=K(c),u;e[6]===t?u=e[7]:(u=t(`header.workStatusPanel.toggleAria`),e[6]=t,e[7]=u);let d;e[8]===t?d=e[9]:(d=t(`header.workStatusPanel.toggleAria`),e[8]=t,e[9]=d);let f=s?`text-foreground`:`text-muted-foreground/50`,p;e[10]===f?p=e[11]:(p=X(`app-region-no-drag size-7`,f),e[10]=f,e[11]=p);let m;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(Z,{name:`settings-2`,className:`size-4`}),e[12]=m):m=e[12];let h;return e[13]!==s||e[14]!==u||e[15]!==d||e[16]!==p||e[17]!==l?(h=(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,"data-work-status-toggle":`true`,"aria-pressed":s,"aria-label":u,title:d,onClick:l,className:p,children:m}),e[13]=s,e[14]=u,e[15]=d,e[16]=p,e[17]=l,e[18]=h):h=e[18],h}function Su(e){return e.setWorkStatusOverlayOpen}function Cu(e){return e.setWorkStatusPanelEnabled}function wu(e){return e.workStatusOverlayOpen}function Tu(e){return e.workStatusPanelFits}function Eu(e){return e.workStatusPanelEnabled}var Du=(e,t,n)=>ht({queryKey:[`desktop-host-inventory`,e],queryFn:async({signal:e})=>{let r=await U(),i=new Set(r.sshHostIds??[]);if(r.sshHostIds===void 0&&z()){let e=await $a();for(let t of e.instances)i.add(t.id)}return e.throwIfAborted(),{hosts:r.hosts.filter(e=>se(e,i)||t===`host:${e.id}`||!!(n&&H(n,oe(e)))),sshIds:i}}});function Ou(e){let t=(0,du.c)(18),{onClick:n,open:r}=e,{t:i}=Zt(),a=Q.useSyncExternalStore(s,l,l),o=q(ku),c=f(),u=m(),d=S(),{data:p}=gt({...Du(a,c,u),enabled:!o}),h=c.startsWith(`host:`)?c.slice(5):null,g=p?.hosts.find(e=>h?e.id===h:!!(u&&H(u,oe(e))));if(d&&!p?.hosts.length&&!p?.sshIds.size)return null;let _=g?ce(g.label):i(d?`desktopHostSwitcher.instance.local`:`desktopHostSwitcher.title`),v=fi({isLocal:d,isSsh:!!(g&&p?.sshIds.has(g.id)),isRelay:a.startsWith(`relay:`)}),y=Oa,b=Ta,x=Y,C=i(`header.actions.sessionMenu.servicesWithInstance`,{current:_}),w;t[0]===v?w=t[1]:(w=(0,$.jsx)(`span`,{className:`inline-flex h-full w-7 items-center justify-center`,children:(0,$.jsx)(Z,{name:v,className:`size-5`})}),t[0]=v,t[1]=w);let T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(`span`,{className:`inline-flex h-full w-3 items-center justify-center`,children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`size-2.5`})}),t[2]=T):T=t[2];let E;t[3]!==x||t[4]!==n||t[5]!==r||t[6]!==C||t[7]!==w?(E=(0,$.jsxs)(x,{variant:`ghost`,size:`sm`,className:`app-region-no-drag h-7 w-12 gap-0 self-center rounded-md border border-border/40 px-1 py-0 text-muted-foreground hover:text-foreground`,"aria-label":C,"aria-expanded":r,"aria-haspopup":`menu`,onClick:n,children:[w,T]}),t[3]=x,t[4]=n,t[5]=r,t[6]=C,t[7]=w,t[8]=E):E=t[8];let D;t[9]!==b||t[10]!==E?(D=(0,$.jsx)(b,{asChild:!0,children:E}),t[9]=b,t[10]=E,t[11]=D):D=t[11];let O;t[12]===_?O=t[13]:(O=(0,$.jsx)(Ea,{children:_}),t[12]=_,t[13]=O);let k;return t[14]!==y||t[15]!==O||t[16]!==D?(k=(0,$.jsxs)(y,{children:[D,O]}),t[14]=y,t[15]=O,t[16]=D,t[17]=k):k=t[17],k}function ku(e){return e.isSettingsDialogOpen}var Au=[{id:`finder`,label:`Finder`,appName:`Finder`},{id:`terminal`,label:`Terminal`,appName:`Terminal`},{id:`iterm2`,label:`iTerm2`,appName:`iTerm`},{id:`ghostty`,label:`Ghostty`,appName:`Ghostty`},{id:`vscode`,label:`VS Code`,appName:`Visual Studio Code`},{id:`vscode-insiders`,label:`VS Code Insiders`,appName:`Visual Studio Code - Insiders`},{id:`intellij`,label:`IntelliJ`,appName:`IntelliJ IDEA`},{id:`visual-studio`,label:`Visual Studio`,appName:`Visual Studio`},{id:`cursor`,label:`Cursor`,appName:`Cursor`},{id:`android-studio`,label:`Android Studio`,appName:`Android Studio`},{id:`pycharm`,label:`PyCharm`,appName:`PyCharm`},{id:`xcode`,label:`Xcode`,appName:`Xcode`},{id:`sublime-text`,label:`Sublime`,appName:`Sublime Text`},{id:`webstorm`,label:`WebStorm`,appName:`WebStorm`},{id:`rider`,label:`Rider`,appName:`Rider`},{id:`zed`,label:`Zed`,appName:`Zed`},{id:`wu`,label:`Wu`,appName:`Wu`},{id:`phpstorm`,label:`PhpStorm`,appName:`PhpStorm`},{id:`eclipse`,label:`Eclipse`,appName:`Eclipse`},{id:`windsurf`,label:`Windsurf`,appName:`Windsurf`},{id:`vscodium`,label:`VSCodium`,appName:`VSCodium`},{id:`rustrover`,label:`RustRover`,appName:`RustRover`},{id:`kiro`,label:`Kiro`,appName:`Kiro`},{id:`antigravity`,label:`Antigravity`,appName:`Antigravity`},{id:`trae`,label:`Trae`,appName:`Trae`}],ju=`finder`,Mu=new Set([`finder`,`terminal`]),Nu=e=>typeof window<`u`&&window.__YURI_PLATFORM__===`win32`&&e.id===`finder`?{...e,label:`Explorer`,appName:`File Explorer`}:e,Pu=e=>{if(!e)return null;let t=Au.find(t=>t.id===e)??null;return t?Nu(t):null},Fu=()=>Au.filter(e=>Mu.has(e.id)).map(e=>({...Nu(e)})),Iu=()=>{if(typeof window>`u`)return ju;let e=window.localStorage.getItem(`openInAppId`);return e&&Pu(e)?e:ju},Lu=!1,Ru=!1,zu=!1,Bu=0,Vu=null,Hu=()=>{Vu&&=(clearTimeout(Vu),null)},Uu=W()((e,t)=>({selectedAppId:Iu(),availableApps:Fu(),hasLoadedApps:!1,isCacheStale:!1,isScanning:!1,initialize:()=>{if(Lu||typeof window>`u`)return;Lu=!0;let n=(t,n=!0)=>{if(!Array.isArray(t)||t.length===0){e({availableApps:Fu(),hasLoadedApps:n});return}let r=new Set(t.map(e=>e.name)),i=new Map(t.map(e=>[e.name,e.iconDataUrl??void 0]));e({availableApps:Au.filter(e=>r.has(e.appName)||Mu.has(e.id)).map(e=>({...Nu(e),iconDataUrl:i.get(e.appName)})),hasLoadedApps:!0})},r=async i=>{if(!v()||Ru||t().hasLoadedApps&&!i)return;let a=Au.map(e=>e.appName);Hu(),i&&e({hasLoadedApps:!1}),Ru=!0,zu=!1,e({isScanning:!0});try{let{apps:t,success:o,hasCache:s,isCacheStale:c}=await ne(a,i),l=o&&!s&&t.length===0&&Bu<3;if(e({isCacheStale:s?c:!1}),n(t,o?!l:!1),o){if(l){let e=[800,1600,3200][Bu]??3200;Bu+=1,zu=!0,Vu=setTimeout(()=>{r()},e);return}Bu=0,zu=!1;return}if(Bu<3){let e=[1e3,3e3,7e3][Bu]??7e3;Bu+=1,zu=!0,Vu=setTimeout(()=>{r()},e)}}finally{Ru=!1,zu||e({isScanning:!1})}};r(),window.addEventListener(`yuri:settings-synced`,t=>{let n=t.detail,r=n&&typeof n.openInAppId==`string`&&n.openInAppId.length>0&&Pu(n.openInAppId)?n.openInAppId:null;r&&(window.localStorage.setItem(`openInAppId`,r),e({selectedAppId:r}))}),window.addEventListener(`yuri:app-ready`,()=>{r()}),window.addEventListener(`yuri:installed-apps-updated`,t=>{let r=t.detail;Array.isArray(r)&&(Bu=3,zu=!1,e({isScanning:!1,isCacheStale:!1}),n(r))}),window.__yuriAppReady&&r(),window.setTimeout(()=>{t().hasLoadedApps||r()},5e3)},loadInstalledApps:async n=>{if(Lu||t().initialize(),!v()||Ru||t().hasLoadedApps&&!n)return;let r=Au.map(e=>e.appName);Hu(),n&&e({hasLoadedApps:!1}),Ru=!0,zu=!1,e({isScanning:!0});try{let{apps:t,hasCache:i,isCacheStale:a}=await ne(r,n),o=new Set(t.map(e=>e.name)),s=new Map(t.map(e=>[e.name,e.iconDataUrl??void 0])),c=Au.filter(e=>o.has(e.appName)||Mu.has(e.id)).map(e=>({...e,iconDataUrl:s.get(e.appName)}));e({availableApps:c.length>0?c:Fu(),hasLoadedApps:c.length>0,isCacheStale:i?a:!1})}finally{Ru=!1,zu||e({isScanning:!1})}},selectApp:async t=>{Pu(t)&&(e({selectedAppId:t}),typeof window<`u`&&window.localStorage.setItem(`openInAppId`,t),await je({openInAppId:t}))}})),Wu=(e=f(),t=l())=>{let n=e.startsWith(`host:`)?e.slice(5):null;return{queryKey:[t,`ssh-editor-apps`,n],enabled:v()&&_()&&n!==null,queryFn:async({signal:e})=>{let t=await P(`desktop_ssh_editor_apps`,{hostId:n});return e.throwIfAborted(),t?{hostId:n,appIds:t.appIds}:null}}},Gu=()=>{let e=(0,du.c)(3),t=(0,Q.useSyncExternalStore)(s,f,Ku),n=(0,Q.useSyncExternalStore)(s,l,qu),r;return e[0]!==t||e[1]!==n?(r=Wu(t,n),e[0]=t,e[1]=n,e[2]=r):r=e[2],gt(r)};function Ku(){return``}function qu(){return``}var Ju=`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`,Yu=`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`,Xu=e=>({...e,fallbackIconDataUrl:e.id===`finder`&&window.__YURI_PLATFORM__!==`win32`?Ju:e.id===`terminal`?Yu:void 0}),Zu=e=>{let t=(0,du.c)(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=e,[a,o]=Q.useState(!1),s;t[0]===n?s=t[1]:(s=n.trim().slice(0,1).toUpperCase()||`?`,t[0]=n,t[1]=s);let c=s,l=r||i;if(l&&!a){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>o(!0),t[2]=e):e=t[2];let n;return t[3]===l?n=t[4]:(n=(0,$.jsx)(`img`,{src:l,alt:``,className:`h-4 w-4 rounded-sm`,onError:e}),t[3]=l,t[4]=n),n}let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=X(`h-4 w-4 rounded-sm flex items-center justify-center`,`bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground`),t[5]=u):u=t[5];let d;return t[6]===c?d=t[7]:(d=(0,$.jsx)(`span`,{className:u,children:c}),t[6]=c,t[7]=d),d},Qu=({directory:e,className:t})=>{let{t:n}=Zt(),r=Uu(e=>e.selectedAppId),i=Uu(e=>e.availableApps),a=Uu(e=>e.isCacheStale),o=Uu(e=>e.isScanning),s=Uu(e=>e.initialize),c=Uu(e=>e.loadInstalledApps),l=Uu(e=>e.selectApp),{data:u}=Gu(),d=Q.useMemo(()=>u?i.filter(e=>u.appIds.includes(e.id)):i,[i,u]);Q.useEffect(()=>{s()},[s]);let f=v()&&S(),p=Q.useMemo(()=>{let e=d.find(e=>e.id===r)??d.find(e=>e.id===`finder`)??d[0];return e?Xu(e):null},[d,r]);if(!f&&!u||!e)return null;let m=async t=>{try{let r=await y(e,t.id,t.appName,u?.hostId);!r&&!u?await E(e,t.appName):r||J.error(n(`filesView.toast.openInAppFailed`,{app:t.label}))}catch(e){J.error(n(String(e).includes(`SSH_EDITOR_CONFIG_REQUIRED`)?`openInApp.errors.sshConfigRequired`:`filesView.toast.openInAppFailed`,{app:t.label}))}},h=async e=>{await l(e.id),await m(e)},g=async()=>{await Pn(e)};return(0,$.jsxs)(`div`,{className:X(`app-region-no-drag inline-flex h-7 w-12 items-center self-center overflow-hidden rounded-md border border-border/40 px-1`,`hover:bg-interactive-hover transition-colors`,t),children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void(p?m(p):g()),className:X(`inline-flex h-full w-7 items-center justify-center typography-ui-label font-medium`,`text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`,o&&`animate-pulse`),"aria-label":p?n(`openInApp.actions.openInAria`,{app:p.label}):n(`openInApp.actions.copyPath`),children:p?(0,$.jsx)(Zu,{label:p.label,iconDataUrl:p.iconDataUrl,fallbackIconDataUrl:p.fallbackIconDataUrl}):(0,$.jsx)(Z,{name:`file-copy`,className:`h-4 w-4`})}),(0,$.jsxs)(Na,{children:[(0,$.jsx)(Ra,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:X(`inline-flex h-full w-3 items-center justify-center text-muted-foreground`,`hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`),"aria-label":n(`openInApp.actions.chooseAppAria`),children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`size-2.5`})})}),(0,$.jsxs)(Ia,{align:`end`,className:`w-56 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:()=>void g(),children:[(0,$.jsx)(Z,{name:`file-copy`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n(`openInApp.actions.copyPath`)})]}),(0,$.jsx)(Wa,{}),d.map(e=>{let t=Xu(e);return(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:()=>void h(e),children:[(0,$.jsx)(Zu,{label:e.label,iconDataUrl:e.iconDataUrl,fallbackIconDataUrl:t.fallbackIconDataUrl}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e.label}),p?.id===e.id?(0,$.jsx)(Z,{name:`check`,className:`ml-auto h-4 w-4 text-primary`}):null]},e.id)}),a?(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:()=>void c(!0),children:[(0,$.jsx)(Z,{name:`refresh`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n(`openInApp.actions.refreshApps`)})]}):null]})]})]})},$u=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],ed=[`dev`,`start`,`preview`,`serve`];async function td(e,t,n,r){if(!e)return null;let i=id(t);if(i)return{command:i.command,label:i.name||`Start Preview`,actionId:i.id};if(n){let t=ad(n);if(t){let n=await od(e,r);return{command:`${n===`npm`?`npm run`:n===`yarn`?`yarn`:n===`pnpm`?`pnpm`:n===`bun`?`bun run --shell=bun`:`npm run`} ${t}`,label:`Start (${t})`}}}if(await nd(e,r)){let e=await rd(r),t=typeof e==`number`&&Number.isFinite(e)&&e>0?e:8e3;return{command:`python3 -m http.server ${t}`,label:`Static preview`,previewUrlHint:`http://127.0.0.1:${t}/`}}return null}async function nd(e,t){let n=await sd(`${e}/index.html`,e,t);return typeof n==`string`&&n.trim().length>0}async function rd(e){if(e){let t=await kt(e).json(`/api/system/free-port`,{cache:`no-store`});if(!Number.isInteger(t.port)||t.port<1||t.port>65535)throw Error(`Invalid Host preview port`);return t.port}try{let e=await h(`/api/system/free-port`,{cache:`no-store`});if(!e.ok)return null;let t=await e.json().catch(()=>null),n=typeof t?.port==`number`?t.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function id(e){for(let t of e){let e=`${t.name} ${t.command}`.toLowerCase();if(ed.some(t=>e.includes(t)))return t}return null}function ad(e){for(let{pattern:t}of $u)for(let n of Object.keys(e))if(t.test(n))return n;return null}async function od(e,t){let n=await sd(`${e}/package.json`,e,t);if(n)try{let e=JSON.parse(n),t=typeof e.packageManager==`string`?e.packageManager.toLowerCase():``;if(t.startsWith(`bun@`))return`bun`;if(t.startsWith(`pnpm@`))return`pnpm`;if(t.startsWith(`yarn@`))return`yarn`;if(t.startsWith(`npm@`))return`npm`}catch{}for(let[n,r]of[[`bun.lock`,`bun`],[`bun.lockb`,`bun`],[`pnpm-lock.yaml`,`pnpm`],[`yarn.lock`,`yarn`],[`package-lock.json`,`npm`]]){let i=await sd(`${e}/${n}`,e,t);if(typeof i==`string`&&i.trim().length>0)return r}return`npm`}async function sd(e,t,n){if(n){let r=kt(n),i=await r.fetch(`/api/fs/read`,{query:{path:e,directory:t,optional:`true`},cache:`no-store`});if(i.status===404)return null;if(!i.ok)throw Error(`Failed to read Host preview file (${i.status})`);let a=await i.text();return r.assertCurrent(),i.headers.get(`x-yuri-file-exists`)===`false`?null:a}if(t?.trim())try{let n=new URLSearchParams({path:e,directory:t,optional:`true`}),r=await h(`/api/fs/read?${n.toString()}`,{cache:`no-store`});if(r.ok)return r.text()}catch{}let r=ae()?.files;if(r?.readFile)try{let t=await r.readFile(e,{optional:!0});return typeof t?.content==`string`?t.content:null}catch{return null}try{let t=await h(`/api/fs/read?path=${encodeURIComponent(e)}&optional=true`,{cache:`no-store`});return t.ok?t.text():null}catch{return null}}async function cd(e,t){try{let n=await sd(`${e}/package.json`,e,t);if(n==null)return null;let r=JSON.parse(n).scripts;return r&&typeof r==`object`&&!Array.isArray(r)?r:null}catch(e){if(t)throw e;return null}}var ld=e=>new Promise(t=>{window.setTimeout(t,e)}),ud=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),dd=/https?:\/\/[^\s<>'"`]+/gi,fd=`__yuri_auto_discover_preview__`,pd=15e3,md=e=>{let t=``;for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);r>=0&&r<=8||r===11||r===12||r>=14&&r<=31||r===127||(t+=e[n])}return t},hd=e=>{let t=(e||``).trim();if(!t)return null;let n=/^https?:\/\//i.test(t)?t:`http://${t}`;try{let e=new URL(n);return e.protocol!==`http:`&&e.protocol!==`https:`?null:e.toString()}catch{return null}},gd=e=>{let t=e.replace(ud,``).match(dd);if(!t||t.length===0)return null;let n=t.map(e=>e.replace(/[),.;]+$/,``)).filter(Boolean);if(n.length===0)return null;let r=[];for(let e of n)try{let t=new URL(e);t.port&&t.port.length>0&&r.push({raw:e,parsed:t})}catch{}if(r.length>0){let e=e=>{let{parsed:t}=e,n=t.hostname.toLowerCase(),r=n===`localhost`||n===`127.0.0.1`||n===`0.0.0.0`||n===`::1`,i=t.pathname||`/`,a=i.split(`/`).filter(Boolean).length,o=i===`/`||i===``,s=!!(t.search||t.hash),c=0;return r&&(c+=50),o&&(c+=30),c-=Math.min(a*5,20),s&&(c-=10),c};return r.sort((t,n)=>e(n)-e(t)),r[0]?.parsed.origin??r[0]?.raw??null}return n[0]??null},_d=e=>{let t=(0,du.c)(19),n=!!e.projectRef?.hostId,{registry:r}=jr(n&&!e.scope),i=e.projectRef?.hostId,a;t[0]!==i||t[1]!==r?(a={subscribe:e=>r&&i?r.subscribeHost(i,e):yd,snapshot:()=>r&&i?r.getHost(i):void 0},t[0]=i,t[1]=r,t[2]=a):a=t[2];let o=a;Q.useSyncExternalStore(o.subscribe,o.snapshot,o.snapshot);let s=e.directory||e.projectRef?.path||``,c;t[3]!==s||t[4]!==e.projectRef||t[5]!==e.scope||t[6]!==r||t[7]!==n?(c=e.scope?r?.hubId===e.scope.location.hubId?r.resolve(e.scope.location):e.scope:n&&r&&r.hubId===e.projectRef?.hubId?r.resolve({hubId:r.hubId,hostId:e.projectRef.hostId,directory:s}):void 0,t[3]=s,t[4]=e.projectRef,t[5]=e.scope,t[6]=r,t[7]=n,t[8]=c):c=t[8];let l=c,u;t[9]!==s||t[10]!==l||t[11]!==e.projectRef?.hostId||t[12]!==e.projectRef?.hubId||t[13]!==n?(u=l?`${l.key}:${l.connectionGeneration}`:n?JSON.stringify([e.projectRef?.hubId,e.projectRef?.hostId,s]):s,t[9]=s,t[10]=l,t[11]=e.projectRef?.hostId,t[12]=e.projectRef?.hubId,t[13]=n,t[14]=u):u=t[14];let d=u,f;return t[15]!==l||t[16]!==d||t[17]!==e?(f=(0,$.jsx)(vd,{...e,scope:l},d),t[15]=l,t[16]=d,t[17]=e,t[18]=f):f=t[18],f},vd=({projectRef:e,directory:t,className:n,compact:r=!1,allowMobile:i=!1,scope:a})=>{let{t:o}=Zt(),{terminal:s,runtime:c}=St(),l=Q.useRef(null),u=Q.useRef(!0),d=()=>{if(!u.current)throw new DOMException(`Project action scope superseded`,`AbortError`);if(e?.hostId&&(!a||a.location.hostId!==e.hostId||a.location.hubId!==e.hubId)||a&&a.location.directory!==(t||e?.path||``))throw Error(o(`remoteProjects.host-unavailable`));a&&kt(a).assertCurrent()},f=K(()=>{if(d(),!a)throw Error(o(`remoteProjects.host-unavailable`));return l.current??=Ht(a)}),p=Q.useMemo(()=>a||e?.hostId?{createSession:e=>f().createTerminalSession(e),sendInput:(e,t)=>f().sendTerminalInput(e,t),close:e=>f().closeTerminal(e)}:s,[a,e?.hostId,s,f]),{isMobile:m}=go(),h=Q.useMemo(()=>v(),[]),g=Vs(e=>e.instances),_=Vs(e=>e.load),y=q(e=>e.setBottomTerminalOpen),b=q(e=>e.setActiveMainTab),x=q(e=>e.setSettingsPage),S=q(e=>e.setSettingsDialogOpen),C=q(e=>e.setSettingsProjectsSelectedId),w=q(e=>e.openContextPreview),T=nc(e=>e.sessions),E=nc(e=>e.ensureDirectory),D=nc(e=>e.setTabLabel),O=nc(e=>e.setTabIconKey),k=nc(e=>e.setActiveTab),A=nc(e=>e.setConnecting),j=nc(e=>e.setTabSessionId),M=nc(e=>e.setTabPreviewUrl),N=nc(e=>e.projectActionRuns),P=nc(e=>e.setProjectActionRun),F=nc(e=>e.updateProjectActionRunStatus),L=nc(e=>e.removeProjectActionRun),[R,z]=Q.useState([]),[B,V]=Q.useState(null),[te,ne]=Q.useState(!1),re=Q.useRef({}),ie=Q.useRef({}),ae=Q.useRef({}),oe=Q.useRef({}),H=Q.useRef(0),se=Q.useRef(new Set),U=e?.id??null,ce=e?.path??``,W=Q.useMemo(()=>U?{id:U,path:ce,hostId:e?.hostId,hubId:e?.hubId}:null,[U,ce,e?.hostId,e?.hubId]);Q.useEffect(()=>{u.current=!0;let e=ae.current,t=oe.current;return()=>{u.current=!1,H.current+=1,Object.values(e).forEach(e=>e()),Object.values(t).forEach(e=>window.clearTimeout(e)),l.current?.dispose(),l.current=null}},[a]),Q.useEffect(()=>{!h||a||e?.hostId||_().catch(()=>void 0)},[h,_,a,e?.hostId]);let le=K(async e=>{await Bt(e)}),ue=K(async()=>{if(!W)return;let e=H.current+1;H.current=e,ne(!0);try{d();let t=await yn(W,a);if(H.current!==e)return;let n=t.actions;z(n),V(e=>e===fd||e&&n.some(t=>t.id===e)?e:null)}catch{if(H.current!==e)return}finally{H.current===e&&ne(!1)}}),de=t||W?.path||``,fe=Q.useMemo(()=>a?I(ee({...a.location,directory:de})):W?.hostId?W.hubId?I(ee({hubId:W.hubId,hostId:W.hostId,directory:de})):``:au(de),[de,W,a]),pe=Q.useMemo(()=>B?R.find(e=>e.id===B)??null:null,[R,B]),me=Q.useMemo(()=>({id:fd,name:o(`projectActions.actions.autoDiscover`),command:``,icon:`search`,autoOpenUrl:!0}),[o]),he=!m,ge=Q.useMemo(()=>he?[me,...R]:R,[R,me,he]);Q.useEffect(()=>{ue()},[ue,W,a]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;U&&(t?.projectId&&t.projectId!==U||ue())};return window.addEventListener(ou,e),()=>{window.removeEventListener(ou,e)}},[ue,U]),Q.useEffect(()=>{B&&(B===fd&&he||R.some(e=>e.id===B)||V(null))},[R,he,B]),Q.useEffect(()=>{for(let[e,t]of Object.entries(N)){if(t.directory!==fe)continue;let n=T.get(t.directory)?.tabs.find(e=>e.id===t.tabId);(!n||n.terminalSessionId!==t.sessionId)&&L(e)}},[fe,N,L,T]),Q.useEffect(()=>{for(let[e,t]of Object.entries(N)){if(t.directory!==fe)continue;let n=ie.current[e]??{lastSeenChunkId:null,openedUrl:!1,tail:``,openInPreview:!1};ie.current[e]=n;let r=ge.find(e=>e.id===t.actionId);if(!r)continue;let i=T.get(t.directory)?.tabs.find(e=>e.id===t.tabId);if(!i||!Array.isArray(i.bufferChunks)||i.bufferChunks.length===0)continue;let s=i.bufferChunks.filter(e=>n.lastSeenChunkId===null||e.id>n.lastSeenChunkId);if(s.length===0)continue;let c=s.map(e=>e.data).join(``),l=`${n.tail}${c}`,u=!n.openedUrl&&r.autoOpenUrl===!0?gd(l):null;if(n.lastSeenChunkId=s[s.length-1]?.id??n.lastSeenChunkId,n.tail=l.slice(-512),u)if(n.openedUrl=!0,n.openInPreview){let t=N[e];t&&(M(t.directory,t.tabId,u,{locked:!1,autoOpened:!1}),t.status===`waiting-for-preview`&&F(e,`running`),window.clearTimeout(oe.current[e]),delete oe.current[e],w(t.directory,u))}else a||W?.hostId?(M(t.directory,t.tabId,u,{locked:!1,autoOpened:!0}),w(t.directory,u)):(le(u),J.success(o(`projectActions.toast.openedUrlFromOutput`)));ie.current[e]=n}for(let e of Object.keys(ie.current))N[e]||(delete ie.current[e],window.clearTimeout(oe.current[e]),delete oe.current[e])},[fe,a,W?.hostId,ge,w,le,N,M,o,T,F]);let _e=K(async(e,t={})=>{if(!fe)throw Error(o(`projectActions.error.noActiveDirectory`));let n=nu(fe,e.id);E(fe);let r=nc.getState(),i=r.getDirectoryState(fe),a=re.current[n]||null,s=a?!!i?.tabs.some(e=>e.id===a):!1;(!a||!s)&&(a=r.createTab(fe),re.current[n]=a),D(fe,a,`Action: ${e.name}`),O(fe,a,e.icon||`play`),t.revealTerminal!==!1&&(k(fe,a),y(!0),b(`terminal`));let c=nc.getState().getDirectoryState(fe)?.tabs.find(e=>e.id===a);return{key:n,tabId:a,sessionId:c?.terminalSessionId??null}}),ve=K(async e=>{if(c.isVSCode||!i&&m)return;if(!fe){J.error(o(`projectActions.error.noActiveDirectoryForAction`));return}let t=nu(fe,e.id),n=N[t];if(!(n&&n.status===`running`)&&!se.current.has(t)){se.current.add(t);try{d();let t=e.id===fd?await(async()=>{let[e,t]=await Promise.all([yn({...W,id:W?.id??``,path:de},a),cd(de,a)]),n=await td(de,e.actions,t,a);if(!n)throw Error(o(`contextPanel.preview.noDevServer`));return{id:fd,name:o(`projectActions.actions.autoDiscover`),command:n.command,icon:`search`,autoOpenUrl:!0,openUrl:n.previewUrlHint||``}})():e,n=t.autoOpenUrl===!0&&(t.openUrl||``).trim().length>0;d();let{key:r,tabId:i,sessionId:s}=await _e(t,{revealTerminal:!n&&e.id!==fd}),c=s,l=!1;if(!c){A(fe,i,!0);try{let e=await p.createSession({cwd:de});d(),c=e.sessionId,l=!0,j(fe,i,c)}finally{A(fe,i,!1)}}if(!c)throw Error(o(`projectActions.error.failedToCreateTerminalSession`));l&&await ld(350),d(),t.id===fd&&(ae.current[r]?.(),A(fe,i,!0),ae.current[r]=(a?f().connectTerminalStream:Vt)(c,e=>{if(u.current){try{d()}catch{return}e.type===`data`&&typeof e.data==`string`&&e.data.length>0&&nc.getState().appendToBuffer(fe,i,e.data),e.type===`exit`&&(nc.getState().setTabLifecycle(fe,i,`exited`),nc.getState().setConnecting(fe,i,!1),nc.getState().removeProjectActionRun(r),delete ie.current[r],ae.current[r]?.(),delete ae.current[r],window.clearTimeout(oe.current[r]),delete oe.current[r])}},()=>{u.current&&nc.getState().setConnecting(fe,i,!1)},{maxRetries:60,initialRetryDelay:250,maxRetryDelay:2e3,connectionTimeout:5e3}));let m=t.autoOpenUrl===!0&&!a&&h&&(t.desktopOpenSshForward||``).trim().length>0,_=t.autoOpenUrl?hd(t.openUrl):null,v=t.autoOpenUrl&&h&&!a?ru(t.desktopOpenSshForward,g):null;P({key:r,directory:fe,actionId:t.id,tabId:i,sessionId:c,status:t.id===fd&&!_?`waiting-for-preview`:`running`}),window.clearTimeout(oe.current[r]),delete oe.current[r],t.id===fd&&!_&&(oe.current[r]=window.setTimeout(()=>{nc.getState().updateProjectActionRunStatus(r,`running`),delete oe.current[r]},pd)),v?(M(fe,i,null,{locked:!0}),le(v),J.success(o(`projectActions.toast.openedForwardedUrl`))):_?(M(fe,i,_,{locked:!0,autoOpened:!0}),w(fe,_),J.success(o(`projectActions.toast.openedActionUrl`))):n?(M(fe,i,null,{locked:!0}),J.error(o(`projectActions.error.invalidCustomUrlFormat`))):m?(M(fe,i,null,{locked:!0}),J.error(o(`projectActions.error.selectedDesktopSshForwardUnavailable`))):M(fe,i,null,{locked:!1,autoOpened:!1}),ie.current[r]={lastSeenChunkId:null,openedUrl:!!v||!!_||n,tail:``,openInPreview:t.id===fd};let y=md(t.command.trim().replace(/\r\n|\r/g,`
|
|
3
|
-
`));d(),await p.sendInput(c,`${y}\r`)}catch(e){L(t),delete ie.current[t],ae.current[t]?.(),delete ae.current[t],window.clearTimeout(oe.current[t]),delete oe.current[t],J.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`))}finally{se.current.delete(t)}}}),ye=K(async e=>{let t=nu(fe,e.id),n=N[t];if(n){F(t,`stopping`);try{await p.sendInput(n.sessionId,``)}catch(e){if(a||W?.hostId){F(t,`running`),J.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`));return}}if(await new Promise(e=>{window.setTimeout(e,1e3)}),nc.getState().getDirectoryState(n.directory)?.tabs.find(e=>e.id===n.tabId)?.terminalSessionId===n.sessionId)if(a||W?.hostId){try{d(),await p.close(n.sessionId)}catch(e){F(t,`running`),J.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`));return}j(n.directory,n.tabId,null)}else{if(typeof p.forceKill==`function`)try{await p.forceKill({sessionId:n.sessionId})}catch{}else try{await p.close(n.sessionId)}catch{}j(n.directory,n.tabId,null)}L(t),delete ie.current[t],ae.current[t]?.(),delete ae.current[t],window.clearTimeout(oe.current[t]),delete oe.current[t]}}),be=K(()=>{let e=pe??ge[0];if(!e)return;let t=nu(fe,e.id),n=N[t];if(n?.status!==`stopping`){if(n){ye(e);return}ve(e)}}),xe=K((e,t=!1)=>{if(V(e.id),!t){ve(e);return}let n=nu(fe,e.id),r=N[n];if(r?.status!==`stopping`){if(r){ye(e);return}ve(e)}}),Se=K(()=>{if(W?.id){if(a||W.hostId){J.info(o(`remoteProjects.configurationReadOnly`)),x(`remoteInstances`),S(!0);return}C(W.id),x(`projects`),S(!0)}});if(c.isVSCode||!i&&m||!W||!fe)return null;let Ce=pe??ge[0]??null;if(!Ce)return null;let we=Ce.icon||`play`,Te=Ce.id===fd?`search`:iu[we]||`play`,Ee=N[nu(fe,Ce.id)],De=Ee?.status===`stopping`,Oe=Ee?.status===`waiting-for-preview`,ke=Ee?T.get(Ee.directory)?.tabs.find(e=>e.id===Ee.tabId)?.previewUrl??null:null,Ae=!!(Ee&&ke),je=()=>{!Ee||!ke||w(Ee.directory,ke)};return r?(0,$.jsxs)(`div`,{className:`inline-flex items-center`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:te||De,className:X(`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:be,"aria-label":o(Ee?`projectActions.actions.stopNamedAria`:`projectActions.actions.runNamedAria`,{name:Ce.name}),children:De||Oe?(0,$.jsx)(Z,{name:`loader-4`,className:`h-5 w-5 animate-spin text-[var(--status-warning)]`}):Ee?(0,$.jsx)(Z,{name:`stop`,className:`h-5 w-5 text-[var(--status-warning)]`}):(0,$.jsx)(Z,{name:Te,className:`h-5 w-5`})}),Ae?(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.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:je,children:(0,$.jsx)(Z,{name:`global`,className:`h-4 w-4`})})}),(0,$.jsx)(Ea,{sideOffset:6,children:o(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(Na,{children:[(0,$.jsx)(Ra,{asChild:!0,children:(0,$.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:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-3.5 w-3.5`})})}),(0,$.jsxs)(Ia,{align:`end`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:Se,children:[(0,$.jsx)(Z,{name:`add`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`projectActions.actions.addNewAction`)})]}),(0,$.jsx)(Wa,{}),ge.map(e=>{let t=e.icon||`play`,n=e.id===fd?`search`:iu[t]||`play`,r=nu(fe,e.id),i=N[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:()=>{xe(e,!0)},children:[(0,$.jsx)(Z,{name:n,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:e.name}),o||i?.status===`waiting-for-preview`?(0,$.jsx)(Z,{name:`loader-4`,className:`ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]`}):a?(0,$.jsx)(Z,{name:`stop`,className:`ml-auto h-4 w-4 text-[var(--status-warning)]`}):null]},e.id)})]})]})]}):(0,$.jsxs)(`div`,{className:X(`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:[(0,$.jsx)(`button`,{type:`button`,onClick:be,disabled:te||De,className:X(`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":o(Ee?`projectActions.actions.stopNamedAria`:`projectActions.actions.runNamedAria`,{name:Ce.name}),children:(0,$.jsx)(`span`,{className:`inline-flex h-4 w-4 shrink-0 items-center justify-center`,children:De||Oe?(0,$.jsx)(Z,{name:`loader-4`,className:`h-4 w-4 animate-spin text-[var(--status-warning)]`}):Ee?(0,$.jsx)(Z,{name:`stop`,className:`h-4 w-4 text-[var(--status-warning)]`}):(0,$.jsx)(Z,{name:Te,className:`h-4 w-4`})})}),Ae?(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:je,className:X(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:(0,$.jsx)(Z,{name:`global`,className:`h-4 w-4`})})}),(0,$.jsx)(Ea,{sideOffset:6,children:o(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(Na,{children:[(0,$.jsx)(Ra,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:X(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:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4`})})}),(0,$.jsxs)(Ia,{align:`start`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:Se,children:[(0,$.jsx)(Z,{name:`add`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`projectActions.actions.addNewAction`)})]}),(0,$.jsx)(Wa,{}),ge.map(e=>{let t=e.icon||`play`,n=e.id===fd?`search`:iu[t]||`play`,r=nu(fe,e.id),i=N[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:()=>{xe(e,!0)},children:[(0,$.jsx)(Z,{name:n,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:e.name}),o||i?.status===`waiting-for-preview`?(0,$.jsx)(Z,{name:`loader-4`,className:`ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]`}):a?(0,$.jsx)(Z,{name:`stop`,className:`ml-auto h-4 w-4 text-[var(--status-warning)]`}):null]},e.id)})]})]})]})};function yd(){}function bd(e){return e.isOpen&&e.activeTab===e.targetTab?{open:!1,tab:e.activeTab}:{open:!0,tab:e.targetTab}}var xd=`app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors`,Sd=`app-region-no-drag inline-flex h-9 w-9 items-center justify-center gap-2 p-2 rounded-md typography-ui-label font-medium text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:text-foreground hover:bg-interactive-hover transition-colors`,Cd=Q.memo(function(e){let t=(0,du.c)(17),{visible:n,title:r,ariaLabel:i,onClick:a,className:o,Icon:s,iconClassName:c,pressed:l}=e,u=n===void 0||n,d=l!==void 0&&l;if(!u)return null;let f=o??xd,p=d&&`bg-interactive-selection text-interactive-selection-foreground`,m;t[0]!==f||t[1]!==p?(m=X(f,p),t[0]=f,t[1]=p,t[2]=m):m=t[2];let h=c??`h-[18px] w-[18px]`,g;t[3]!==s||t[4]!==h?(g=(0,$.jsx)(Z,{name:s,className:h}),t[3]=s,t[4]=h,t[5]=g):g=t[5];let _;t[6]!==i||t[7]!==a||t[8]!==d||t[9]!==m||t[10]!==g?(_=(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:a,"aria-label":i,"aria-pressed":d,className:m,children:g})}),t[6]=i,t[7]=a,t[8]=d,t[9]=m,t[10]=g,t[11]=_):_=t[11];let v;t[12]===r?v=t[13]:(v=(0,$.jsx)(Ea,{children:(0,$.jsx)(`p`,{children:r})}),t[12]=r,t[13]=v);let y;return t[14]!==_||t[15]!==v?(y=(0,$.jsxs)(Oa,{children:[_,v]}),t[14]=_,t[15]=v,t[16]=y):y=t[16],y}),wd=Q.memo(function(e){let t=(0,du.c)(42),{isMobile:n,githubAuthStatus:r,githubAccounts:i,githubAvatarUrl:a,githubLogin:o,isSwitchingGitHubAccount:s,handleGitHubAccountSwitch:c}=e,{t:l}=Zt();if(!r?.connected||n)return null;if(i.length>1){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=X(xd,`h-6 w-6 overflow-hidden rounded-full border border-border/60 bg-muted/80 p-0`),t[0]=e):e=t[0];let n;t[1]!==o||t[2]!==l?(n=o?l(`header.github.connectedWithLogin`,{login:o}):l(`header.github.connected`),t[1]=o,t[2]=l,t[3]=n):n=t[3];let r;t[4]!==a||t[5]!==o||t[6]!==l?(r=a?(0,$.jsx)(`img`,{src:a,alt:o?l(`header.github.avatarWithLogin`,{login:o}):l(`header.github.avatar`),className:`h-full w-full object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(Z,{name:`github-fill`,className:`h-3.5 w-3.5 text-foreground`}),t[4]=a,t[5]=o,t[6]=l,t[7]=r):r=t[7];let u;t[8]!==s||t[9]!==n||t[10]!==r?(u=(0,$.jsx)(Ra,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:e,title:n,disabled:s,children:r})}),t[8]=s,t[9]=n,t[10]=r,t[11]=u):u=t[11];let d;t[12]===l?d=t[13]:(d=l(`header.github.accountsTitle`),t[12]=l,t[13]=d);let f;t[14]===d?f=t[15]:(f=(0,$.jsx)(Fa,{className:`typography-ui-header font-semibold text-foreground`,children:d}),t[14]=d,t[15]=f);let p;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(Wa,{}),t[16]=p):p=t[16];let m;if(t[17]!==i||t[18]!==c||t[19]!==s||t[20]!==l){let e;t[22]!==c||t[23]!==s||t[24]!==l?(e=e=>{let t=e.user,n=!!e.current,r=e.source===`gh-cli`?l(`header.github.accountSource.cli`):l(`header.github.accountSource.oauth`);return(0,$.jsxs)(ao,{className:`gap-2`,disabled:s,onSelect:()=>{n||c(e.id)},children:[t?.avatarUrl?(0,$.jsx)(`img`,{src:t.avatarUrl,alt:t.login?l(`header.github.avatarWithLogin`,{login:t.login}):l(`header.github.avatar`),className:`h-6 w-6 rounded-full border border-border/60 bg-muted object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted`,children:(0,$.jsx)(Z,{name:`github-fill`,className:`h-3 w-3 text-muted-foreground`})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-foreground`,children:t?.name?.trim()||t?.login||`GitHub`}),t?.login?(0,$.jsxs)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:t.login}),(0,$.jsx)(`span`,{className:`mx-1 opacity-50`,children:`·`}),(0,$.jsx)(`span`,{children:r})]}):null]}),n?(0,$.jsx)(Z,{name:`check`,className:`h-4 w-4 text-primary`}):null]},e.id)},t[22]=c,t[23]=s,t[24]=l,t[25]=e):e=t[25],m=i.map(e),t[17]=i,t[18]=c,t[19]=s,t[20]=l,t[21]=m}else m=t[21];let h;t[26]!==f||t[27]!==m?(h=(0,$.jsxs)(Ia,{align:`end`,className:`w-64`,children:[f,p,m]}),t[26]=f,t[27]=m,t[28]=h):h=t[28];let g;return t[29]!==u||t[30]!==h?(g=(0,$.jsxs)(Na,{children:[u,h]}),t[29]=u,t[30]=h,t[31]=g):g=t[31],g}let u;t[32]!==o||t[33]!==l?(u=o?l(`header.github.connectedWithLogin`,{login:o}):l(`header.github.connected`),t[32]=o,t[33]=l,t[34]=u):u=t[34];let d;t[35]!==a||t[36]!==o||t[37]!==l?(d=a?(0,$.jsx)(`img`,{src:a,alt:o?l(`header.github.avatarWithLogin`,{login:o}):l(`header.github.avatar`),className:`h-full w-full object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(Z,{name:`github-fill`,className:`h-3.5 w-3.5 text-foreground`}),t[35]=a,t[36]=o,t[37]=l,t[38]=d):d=t[38];let f;return t[39]!==u||t[40]!==d?(f=(0,$.jsx)(`div`,{className:`app-region-no-drag flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80`,title:u,children:d}),t[39]=u,t[40]=d,t[41]=f):f=t[41],f}),Td=Q.memo(function(e){let t=(0,du.c)(52),{isDesktopApp:n,currentInstanceSupportsUpdate:r,isDesktopServicesOpen:i,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:o,desktopServicesTab:s,setDesktopServicesTab:c,fetchAllQuotas:l,servicesTabItems:u,quotaLastUpdated:d,quotaDisplayMode:f,quotaDisplayTabItems:p,handleDisplayModeChange:m,handleUsageRefresh:h,isQuotaLoading:g,isUsageRefreshSpinning:_,hasRateLimits:v,rateLimitGroups:y,expandedFamilies:b,toggleFamilyExpanded:x,showPredValues:S,timeFormatPreference:C,anchorRef:w}=e,{t:T}=Zt(),E=Q.useRef(!1),D;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>{E.current=e},t[0]=D):D=t[0];let O=K(D),k;t[1]!==s||t[2]!==l||t[3]!==d||t[4]!==o||t[5]!==a?(k=(e,t)=>{if(!e&&(t.reason===`trigger-hover`||t.reason===`focus-out`||E.current)){t.cancel();return}a(e),e&&(o(),s===`usage`&&d===null&&l())},t[1]=s,t[2]=l,t[3]=d,t[4]=o,t[5]=a,t[6]=k):k=t[6];let A;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(Ra,{asChild:!0,openOnHover:!1,children:(0,$.jsx)(`button`,{type:`button`,"aria-hidden":!0,tabIndex:-1,className:`pointer-events-none absolute h-px w-px overflow-hidden opacity-0`})}),t[7]=A):A=t[7];let j;t[8]!==l||t[9]!==d||t[10]!==c?(j=e=>{if(E.current)return;let t=e;c(t),t===`usage`&&d===null&&l()},t[8]=l,t[9]=d,t[10]=c,t[11]=j):j=t[11];let M;t[12]!==s||t[13]!==u||t[14]!==j?(M=(0,$.jsx)(`div`,{className:`sticky top-0 z-20 bg-[var(--surface-elevated)]/60 px-2 pt-1.5 pb-1.5 backdrop-blur-xl backdrop-saturate-150`,children:(0,$.jsx)(`div`,{className:`h-9`,children:(0,$.jsx)(gs,{items:u,activeId:s,onSelect:j,layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,activePillButtonClassName:`h-8`,className:`h-full`})})}),t[12]=s,t[13]=u,t[14]=j,t[15]=M):M=t[15];let N;t[16]!==r||t[17]!==s||t[18]!==O||t[19]!==n||t[20]!==i||t[21]!==a?(N=n&&s===`instance`?(0,$.jsxs)(`div`,{children:[r&&i?(0,$.jsx)(`div`,{className:`border-b border-[var(--interactive-border)] px-4 py-2.5`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground`,children:`Yuri`}),(0,$.jsx)(Os,{})]})}):null,(0,$.jsx)(ca,{embedded:!0,open:i&&s===`instance`,onOpenChange:Fd,onHostSwitched:()=>a(!1),onBusyChange:O})]}):null,t[16]=r,t[17]=s,t[18]=O,t[19]=n,t[20]=i,t[21]=a,t[22]=N):N=t[22];let P;t[23]!==s||t[24]!==i?(P=s===`mcp`?(0,$.jsx)(bc,{active:i&&s===`mcp`}):null,t[23]=s,t[24]=i,t[25]=P):P=t[25];let F;t[26]!==s||t[27]!==b||t[28]!==m||t[29]!==h||t[30]!==v||t[31]!==g||t[32]!==_||t[33]!==f||t[34]!==p||t[35]!==d||t[36]!==y||t[37]!==S||t[38]!==T||t[39]!==C||t[40]!==x?(F=s===`usage`?(0,$.jsxs)(`div`,{className:`overflow-x-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-[var(--interactive-border)] px-4 py-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-header font-semibold text-foreground`,children:T(`header.services.rateLimits`)}),(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Dd(d,C)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`div`,{className:`h-7 w-[10.5rem]`,children:(0,$.jsx)(gs,{items:p,activeId:f,onSelect:e=>void m(e),layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,className:`h-full`})}),(0,$.jsx)(`button`,{type:`button`,className:X(`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors`,`hover:text-foreground hover:bg-interactive-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),onClick:h,disabled:g||_,"aria-label":T(`header.services.refreshRateLimitsAria`),children:(0,$.jsx)(Z,{name:`refresh`,className:X(`h-4 w-4`,_&&`animate-spin`)})})]})]}),v?null:(0,$.jsx)(`div`,{className:`px-4 py-5 text-center`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:T(`header.services.noRateLimits`)})}),(0,$.jsx)(`div`,{className:`space-y-2 px-3 py-2.5`,children:y.map(e=>{let t=b[e.providerId]??[];return(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pb-2`,children:[(0,$.jsx)(No,{providerId:e.providerId,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:e.providerName})]}),e.entries.length===0&&(!e.modelFamilies||e.modelFamilies.length===0)?(0,$.jsx)(`div`,{children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:e.error??T(`header.services.noRateLimitsReported`)})}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[e.entries.map((t,n)=>{let[r,i]=t,a=Ac(e.entries,n),o=f===`remaining`?i.remainingPercent:i.usedPercent,s=i.disablePace?null:Ba(i.usedPercent,i.resetAt,i.windowSeconds,r),c=s?.dailyAllocationPercent==null?null:f===`remaining`?100-uo(s.elapsedRatio):uo(s.elapsedRatio),l=La(i.valueLabel,o),u=ja(i.resetAt,i.resetAfterFormatted??i.resetAtFormatted,C);return(0,$.jsxs)(Q.Fragment,{children:[a?(0,$.jsx)(`div`,{className:X(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,n>0&&`mt-5 border-t border-[var(--surface-subtle)] pt-3`),children:a}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground break-words`,children:ka(i.label??r)}),u?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:u}):null]}),(0,$.jsx)(`span`,{className:`shrink-0 whitespace-nowrap typography-ui-label tabular-nums text-foreground`,children:l===`-`?``:l})]}),(0,$.jsx)(Us,{percent:o,tonePercent:i.usedPercent,className:`h-1.5`,expectedMarkerPercent:c}),s&&S?(0,$.jsx)(Is,{paceInfo:s,compact:!0}):null]})]},`${e.providerId}-${r}`)}),e.modelFamilies&&e.modelFamilies.length>0?(0,$.jsx)(`div`,{className:`space-y-0.5`,children:e.modelFamilies.map(n=>{let r=n.familyId??`other`,i=t.includes(r);return(0,$.jsxs)(zl,{open:i,onOpenChange:()=>x(e.providerId,r),children:[(0,$.jsxs)(Rl,{className:`flex w-full items-center justify-between rounded-md px-1 py-1.5 text-left hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:n.familyLabel}),i?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`})]}),(0,$.jsx)(Ll,{children:(0,$.jsx)(`div`,{className:`space-y-2.5 pb-1 pl-1 pt-1`,children:n.models.map(t=>{let[n,r]=t,i=f===`remaining`?r.remainingPercent:r.usedPercent,a=Ba(r.usedPercent,r.resetAt,r.windowSeconds),o=a?.dailyAllocationPercent==null?null:f===`remaining`?100-uo(a.elapsedRatio):uo(a.elapsedRatio),s=La(r.valueLabel,i);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Cs(n)}),(0,$.jsx)(`span`,{className:`typography-ui-label tabular-nums text-foreground`,children:s===`-`?``:s})]}),(0,$.jsx)(Us,{percent:i,tonePercent:r.usedPercent,className:`h-1.5`,expectedMarkerPercent:o}),a&&S?(0,$.jsx)(Is,{paceInfo:a,compact:!0}):null]},`${e.providerId}-${n}`)})})})]},r)})}):null]})]},e.providerId)})})]}):null,t[26]=s,t[27]=b,t[28]=m,t[29]=h,t[30]=v,t[31]=g,t[32]=_,t[33]=f,t[34]=p,t[35]=d,t[36]=y,t[37]=S,t[38]=T,t[39]=C,t[40]=x,t[41]=F):F=t[41];let I;t[42]!==w||t[43]!==M||t[44]!==N||t[45]!==P||t[46]!==F?(I=(0,$.jsxs)(Ia,{anchor:w,align:`start`,sideOffset:6,collisionPadding:12,className:`w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto bg-[var(--surface-elevated)] p-0 [&_[role=tab]]:capitalize`,children:[M,N,P,F]}),t[42]=w,t[43]=M,t[44]=N,t[45]=P,t[46]=F,t[47]=I):I=t[47];let L;return t[48]!==i||t[49]!==k||t[50]!==I?(L=(0,$.jsxs)(Na,{open:i,onOpenChange:k,children:[A,I]}),t[48]=i,t[49]=k,t[50]=I,t[51]=L):L=t[51],L}),Ed=(e,t)=>e===t?!0:!e||!t?!1:e.totalTokens===t.totalTokens&&e.pending===t.pending&&e.percentage===t.percentage&&e.contextLimit===t.contextLimit&&(e.outputLimit??0)===(t.outputLimit??0)&&(e.normalizedOutput??0)===(t.normalizedOutput??0)&&e.thresholdLimit===t.thresholdLimit&&(e.lastMessageId??``)===(t.lastMessageId??``),Dd=(e,t)=>{if(!e)return`-`;try{return Pa(e,t,{fallback:`-`})}catch{return`-`}},Od=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+$/g,``);return r=r.replace(/\/+/g,`/`),n&&!r.startsWith(`//`)&&(r=`/${r}`),r===``?t.startsWith(`/`)?`/`:``:r},kd=e=>!e?.isOpen||!Array.isArray(e.tabs)||e.tabs.length===0?null:(e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[e.tabs.length-1])?.mode??null,Ad=e=>{let t=(0,du.c)(3),n=mn(Id),r;return t[0]!==n||t[1]!==e?(r=n?(0,$.jsx)(jd,{...e,hostId:n}):(0,$.jsx)(Pd,{...e}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r},jd=e=>{let t=(0,du.c)(11),n,r;t[0]===e?(n=t[1],r=t[2]):({hostId:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i=_t(),a=jr(!0),o=Mr(a.registry,n),s;t[3]!==n||t[4]!==a.catalog?.hosts?(s=a.catalog?.hosts.find(e=>e.id===n)?.name??n,t[3]=n,t[4]=a.catalog?.hosts,t[5]=s):s=t[5];let c=s,l=i?.registry??a.registry,u;return t[6]!==c||t[7]!==r||t[8]!==o.data||t[9]!==l?(u=(0,$.jsx)(Pd,{...r,remoteSummaries:o.data,remoteHostName:c,remoteRegistry:l}),t[6]=c,t[7]=r,t[8]=o.data,t[9]=l,t[10]=u):u=t[10],u},Md=Q.memo(e=>{let t=(0,du.c)(10),{entry:n,sessionId:r,fallback:i}=e,a;t[0]!==n.queryScope||t[1]!==r?(a=[...n.queryScope,`chat`,r,`session`],t[0]=n.queryScope,t[1]=r,t[2]=a):a=t[2];let o;t[3]===r?o=t[4]:(o=e=>e.id===r&&e.title?.trim()||null,t[3]=r,t[4]=o);let s;t[5]!==a||t[6]!==o?(s={queryKey:a,queryFn:ft,enabled:!1,staleTime:1/0,gcTime:1/0,select:o},t[5]=a,t[6]=o,t[7]=s):s=t[7];let c=gt(s,wt).data??i,l;return t[8]===c?l=t[9]:(l=(0,$.jsx)($.Fragment,{children:c}),t[8]=c,t[9]=l),l}),Nd=Q.memo(e=>{let t=(0,du.c)(39),{entry:n,sessionId:r,onClick:i,pressed:a}=e,o=n.location,s=Q.useSyncExternalStore(nt,Ke,Ke),c;t[0]===o?c=t[1]:(c=Xe(o),t[0]=o,t[1]=c);let u=c,d;t[2]!==o||t[3]!==u||t[4]!==r?(d=u?it(o,r):null,t[2]=o,t[3]=u,t[4]=r,t[5]=d):d=t[5];let f;t[6]!==s||t[7]!==d?(f={revision:s,scope:d},t[6]=s,t[7]=d,t[8]=f):f=t[8];let p=f.scope,m;t[9]!==u||t[10]!==p?(m=e=>u&&p?u.subscribe(p,e):Ld,t[9]=u,t[10]=p,t[11]=m):m=t[11];let h=m,g;t[12]!==u||t[13]!==p?(g=()=>u&&p?u.getTranscript(p):null,t[12]=u,t[13]=p,t[14]=g):g=t[14];let _=g,v=Q.useSyncExternalStore(h,_,_),y;t[15]!==n||t[16]!==o.directory?(y=ln(o.directory,l(),n),t[15]=n,t[16]=o.directory,t[17]=y):y=t[17];let b;t[18]===y?b=t[19]:(b={...y,enabled:!1,staleTime:1/0,gcTime:1/0},t[18]=y,t[19]=b);let x=gt(b,wt),S;t[20]!==o||t[21]!==r?(S=e=>e.getSessionModelSelection(r,o),t[20]=o,t[21]=r,t[22]=S):S=t[22];let C=pr(S),w;bb0:{if(!v){w=null;break bb0}for(let e=v.messageOrder.length-1;e>=0;e--){let t=v.messagesByID[v.messageOrder[e]];if(!t)continue;let n=Ue([t],e=>v.partsByMessageID[e]);if(n){w=n;break bb0}}w=null}let T=w,E=T&&`messageId`in T&&v?v.messagesByID[T.messageId]:void 0,D;if(t[23]!==T||t[24]!==E?.modelID||t[25]!==E?.providerID||t[26]!==x.data?.providers||t[27]!==C?.modelId||t[28]!==C?.providerId){let e=x.data?.providers.find(e=>e.id===(C?.providerId??E?.providerID))?.models[C?.modelId??E?.modelID??``];D=ot(T,e?.limit?.context??0,e?.limit?.output??0),t[23]=T,t[24]=E?.modelID,t[25]=E?.providerID,t[26]=x.data?.providers,t[27]=C?.modelId,t[28]=C?.providerId,t[29]=D}else D=t[29];let O=D;if(!O)return null;let k=O.contextLimit>0?Math.min(999,O.totalTokens/O.contextLimit*100):0,A=O.outputLimit??0,j;return t[30]!==i||t[31]!==a||t[32]!==k||t[33]!==A||t[34]!==O.contextLimit||t[35]!==O.pending||t[36]!==O.percentage||t[37]!==O.totalTokens?(j=(0,$.jsx)(Xs,{pending:O.pending,totalTokens:O.totalTokens,percentage:k,colorPercentage:O.percentage,contextLimit:O.contextLimit,outputLimit:A,size:`compact`,appearance:`subtle`,onClick:i,pressed:a}),t[30]=i,t[31]=a,t[32]=k,t[33]=A,t[34]=O.contextLimit,t[35]=O.pending,t[36]=O.percentage,t[37]=O.totalTokens,t[38]=j):j=t[38],j}),Pd=({onToggleLeftDrawer:e,onToggleRightDrawer:n,leftDrawerOpen:r,rightDrawerOpen:i,remoteSummaries:a,remoteHostName:o,remoteRegistry:s})=>{let{t:c}=Zt(),u=q(e=>e.setSessionSwitcherOpen),d=q(e=>e.toggleSidebar),p=q(e=>e.isSidebarOpen),g=q(e=>e.toggleBottomTerminal),_=q(e=>e.toggleContextPanel),y=q(e=>e.openContextOverview),b=q(e=>e.openContextBrowser),x=q(e=>e.closeContextPanel),C=q(e=>e.activeMainTab),T=q(e=>e.setActiveMainTab),E=q(e=>e.shortcutOverrides),D=q(e=>e.timeFormatPreference),O=Ln(e=>e.getCurrentModel),k=St(),A=cr(e=>!!e.newSessionDraft?.open),j=cr(e=>e.currentSessionId),M=mn(e=>e.activeProjectId?e.projects.find(t=>t.id===e.activeProjectId)??null:null),I=!!M?.hostId,L=dn(e=>e.remoteSession),z=M?.hostId&&L?.projectId===M.id&&L.location.hostId===M.hostId&&(!M.hubId||L.location.hubId===M.hubId)?L:null,B=I?z?.sessionId??null:j,V=I?!z?.sessionId:A,te=_r(I?``:B??``),ne=pn(I?null:B),re=mn(e=>e.projects),ie=Q.useMemo(()=>{if(!I)return ne;let e=z?.location.directory??M?.path,t=M?.hubId??s?.hubId,n=M?.hostId;if(!(!e||!t||!n||xt(re,t,n,e,a?.worktrees)?.id!==M?.id))return a?.directories.find(t=>t.directory===e)?.sessions.find(t=>t.id===B&&t.directory===e)},[I,ne,z?.location.directory,M,s?.hubId,re,a,B]),ae=Q.useMemo(()=>{if(!M)return null;let e=M.path.split(/[\\/]/).filter(Boolean);return e[e.length-1]??null},[M]),se=_s(e=>e.results),W=_s(e=>e.fetchAllQuotas),le=_s(e=>e.isLoading),ue=_s(e=>e.lastUpdated),de=_s(e=>e.displayMode),fe=_s(e=>e.showPredValues),pe=_s(e=>e.dropdownProviderIds),me=_s(e=>e.loadSettings),he=_s(e=>e.setDisplayMode),{isMobile:ge}=go(),_e=Va().data??null,ve=Ps(e=>e.setStatus),ye=Q.useRef(null),[be,xe]=Q.useState(()=>typeof window>`u`?!1:v()),Se=Q.useMemo(()=>R(),[]),Ce=be&&F()===`win32`,we=ho(),Te=vu(),Ee=Q.useMemo(()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),[]),{usesFramelessChrome:De,side:Oe}=$s(),ke=Q.useMemo(()=>{if(typeof window>`u`)return null;let e=window.__YURI_MACOS_MAJOR__;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e;if(typeof navigator>`u`)return null;let t=(navigator.userAgent||``).match(/Mac OS X (\d+)[._](\d+)/);if(!t)return null;let n=Number.parseInt(t[1],10),r=Number.parseInt(t[2],10);return Number.isNaN(n)?null:n===10?r:n},[]);(0,Q.useEffect)(()=>{typeof window>`u`||xe(v())},[]);let Ae=O(),Me=Ae&&typeof Ae.limit==`object`&&Ae.limit!==null?Ae.limit:null,Ne=Me&&typeof Me.context==`number`?Me.context:0,Pe=Me&&typeof Me.output==`number`?Me.output:0,Fe=gr(I?``:B??``,Ne,Pe),Ie=V?null:Fe,[Le,Re]=Q.useState(null),G=!B||te;(0,Q.useEffect)(()=>{if(!B){Re(e=>e===null?e:null);return}if(Ie){Re(e=>Ed(e,Ie)?e:Ie);return}G&&Re(e=>e===null?e:null)},[Ie,B,G]);let ze=q(e=>e.isSessionSwitcherOpen),Be=_e?.connected?_e.user?.avatarUrl??null:null,Ve=_e?.connected?_e.user?.login??null:null,He=_e?.accounts??[],[Ue,We]=Q.useState(!1),[Ge,Ke]=Q.useState(!1),[qe,Je]=Q.useState(!1),[Ye,Xe]=Q.useState(!1),[Ze,Qe]=Q.useState(`Local`),[$e,et]=Q.useState(!1),[tt,nt]=Q.useState(be?`instance`:`usage`),[rt,it]=Q.useState(`usage`);(0,Q.useEffect)(()=>{!be&&tt===`instance`&&nt(`usage`)},[tt,be]);let at=Q.useMemo(()=>w(),[]),ot=!at&&C===`chat`&&!!Le,st=Le&&Le.contextLimit>0?Math.min(999,Le.totalTokens/Le.contextLimit*100):0,ct=K(async()=>{if(!(typeof window>`u`||!be))try{if(S()){Qe(`Local`),et(!1);return}let e=l(),t=await U();if(l()!==e)return;let n=m(),r=f(),i=r.startsWith(`host:`)?r.slice(5):null,a=(i?t.hosts.find(e=>e.id===i):void 0)??t.hosts.find(e=>n?H(n,oe(e)):!1);if(m()!==n)return;if(et(!!n),a?.label?.trim()){Qe(ce(a.label.trim()));return}Qe(`Instance`)}catch{Qe(`Local`),et(!1)}});(0,Q.useEffect)(()=>{ct()},[be]),zs();let lt=_s(e=>e.selectedModels),ut=_s(e=>e.expandedFamilies),dt=_s(e=>e.toggleFamilyExpanded),ft=Q.useMemo(()=>{let e=[];for(let t of Fs(se)){if(!pe.includes(t.id))continue;let n=se.find(e=>e?.providerId===t.id),r=n?.usage?.windows??{},i=n?.usage?.models,a=gc(Object.entries(r),n?.usage?.accounts),o={providerId:t.id,providerName:t.name,entries:a,error:n&&!n.ok&&n.configured?n.error:void 0};if(i&&Object.keys(i).length>0){let e=lt[t.id]??[],n=e.length>0,r=ws(i,t.id),a=Rs(t.id),s=ys(a);o.modelFamilies=[];for(let t of s){let a=r.get(t.id)??[];if(a.length===0)continue;let s=n?a.filter(t=>e.includes(t)):a;if(s.length===0)continue;let c=[];for(let e of s){let t=i[e];if(t?.windows){let n=Object.entries(t.windows);n.length>0&&c.push([e,n[0][1]])}}c.length>0&&o.modelFamilies.push({familyId:t.id,familyLabel:t.label,models:c})}let l=r.get(null)??[],u=n?l.filter(t=>e.includes(t)):l;if(u.length>0){let e=[];for(let t of u){let n=i[t];if(n?.windows){let r=Object.entries(n.windows);r.length>0&&e.push([t,r[0][1]])}}e.length>0&&o.modelFamilies.push({familyId:null,familyLabel:c(`header.services.modelFamily.other`),models:e})}}(a.length>0||o.modelFamilies&&o.modelFamilies.length>0||o.error)&&e.push(o)}return e},[pe,se,lt,c]),pt=ft.length>0;Q.useEffect(()=>{me()},[me]);let mt=Q.useCallback(async e=>{he(e);try{await je({usageDisplayMode:e})}catch(e){console.warn(`Failed to update usage display mode:`,e)}},[he]),ht=Q.useCallback(()=>{if(Ye)return;Xe(!0);let e=new Promise(e=>setTimeout(e,500));Promise.all([W(),e]).finally(()=>{Xe(!1)})},[W,Ye]),gt=cr(e=>I||!B?``:e.worktreeMetadata.get(B)?.path??``),_t=Q.useMemo(()=>Od(gt||``),[gt]),vt=Q.useMemo(()=>Od((typeof ie?.directory==`string`?ie.directory:``)||``),[ie?.directory]),yt=cr(e=>e.newSessionDraft?.open?Od(e.newSessionDraft.bootstrapPendingDirectory??e.newSessionDraft.directoryOverride??``):``),bt=Q.useMemo(()=>I?z?.location.directory??M?.path??``:_t||vt||yt,[I,z?.location.directory,M?.path,yt,vt,_t]),Ct=zo(),wt=z?ee(z.location):M?.hostId&&M.hubId?ee({hubId:M.hubId,hostId:M.hostId,directory:Ct??M.path}):``,Tt=Q.useMemo(()=>I?wt:Od(Ct||bt||M?.path||``),[I,wt,M?.path,Ct,bt]),Et=q(e=>zt(e,Tt)),Dt=!!Et?.isOpen,Ot=K(()=>_(Tt)),kt=Q.useMemo(()=>{if(!B)return ae??`Yuri`;let e=ie?.title?.trim();return e&&e.length>0?e:`Untitled Session`},[ae,ie?.title,B]),At=Q.useMemo(()=>I?bt:Od(bt||M?.path||``),[I,M?.path,bt]),jt=Q.useMemo(()=>M?{id:M.id,path:M.path,hostId:M.hostId,hubId:M.hubId}:null,[M]),Mt=Q.useRef(null);Q.useEffect(()=>{!jt||!At||(Mt.current={projectRef:jt,directory:At})},[At,jt]);let Pt=Q.useMemo(()=>jt&&At?{projectRef:jt,directory:At}:Mt.current,[At,jt]),Ft=Q.useCallback(async e=>{if(!(!e||Ue)){We(!0);try{let t=k.github?await k.github.authActivate(e):await(async()=>{let t=await h(`/api/github/auth/activate`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({accountId:e})}),n=await t.json().catch(()=>null);if(!t.ok||!n)throw Error(n?.error||t.statusText);return n})();ve(t)}catch(e){console.error(`Failed to switch GitHub account:`,e)}finally{We(!1)}}},[Ue,k.github,ve]),It=Q.useCallback(()=>{if(typeof document>`u`)return;let e=document.activeElement;if(!e)return;let t=e.tagName;(t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable)&&e.blur()},[]),Lt=Q.useCallback(()=>{if(ge){It(),u(!ze);return}d()},[It,ge,ze,u,d]),Rt=Q.useCallback(()=>{I||P(`desktop_open_draft_mini_chat_window`,{directory:Od(bt||M?.path||``),projectId:M?.id??null,apiBaseUrl:m(),clientToken:t()}).catch(e=>{console.warn(`[header] failed to open draft mini chat window`,e)})},[I,M?.id,M?.path,bt]),Bt=Q.useCallback(()=>{if(!I){if(V){Rt();return}B&&P(`desktop_open_session_mini_chat_window`,{sessionId:B,directory:Od(bt||M?.path||``),apiBaseUrl:m(),clientToken:t()}).catch(e=>{console.warn(`[header] failed to open session mini chat window`,e)})}},[I,M?.path,B,Rt,V,bt]),Vt=Q.useCallback(()=>{let e=Tt;if(e){if(kd(Et)===`context`){x(e);return}y(e)}},[x,Tt,Et,y]),Ht=Q.useMemo(()=>Tt?kd(Et)===`context`:!1,[Tt,Et]),Ut=Q.useCallback(()=>{let e=Tt;if(e){if(kd(Et)===`browser`){x(e);return}b(e)}},[x,Tt,Et,b]),Wt=Q.useMemo(()=>Tt?kd(Et)===`browser`:!1,[Tt,Et]),Gt=xd,Kt=Sd,qt=Q.useMemo(()=>Ge?`services`:r?`sessions`:i?`git`:C,[C,Ge,r,i]),Jt=Q.useCallback(()=>{Ke(!1),r&&e&&e(),i&&n&&n(),!e&&ze&&u(!1)},[ze,r,e,n,i,u]),Yt=Q.useCallback(()=>{r||Ke(!1),e?.()},[r,e]),Xt=Q.useCallback(()=>{i||Ke(!1),n?.()},[n,i]),Qt=Q.useMemo(()=>be&&Ee&&!Te?`5.5rem`:we?`max(calc(0.75rem + var(--yuri-wco-left-inset, 0px)), 5.5rem)`:(!be||De)&&!at?`calc(0.75rem + var(--yuri-wco-left-inset, 0px))`:`0.75rem`,[be,Te,Ee,we,at,De]);(0,Q.useEffect)(()=>{typeof document>`u`||document.documentElement.style.setProperty(`--yuri-titlebar-left-inset`,Qt)},[Qt]);let $t=p?`0.75rem`:`var(--yuri-titlebar-left-inset, 0.75rem)`,en=p?`0px`:`calc(var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`,tn=Q.useMemo(()=>!be||!Ee||ke===null?``:ke>=26?`h-12`:ke<=15?`h-14`:``,[be,Ee,ke]),nn=Q.useMemo(()=>{if(!(be&&!De||at))return{paddingRight:Dt?`0.75rem`:`calc(0.75rem + var(--yuri-wco-right-inset, 0px))`,minHeight:`max(3rem, var(--yuri-wco-titlebar-height, 0px))`,height:`max(3rem, var(--yuri-wco-titlebar-height, 0px))`}},[be,at,Dt,De]),rn=K(e=>{if(!e||typeof document>`u`)return;let t=document.documentElement.style,n=`${e}px`;t.getPropertyValue(`--yuri-header-height`)!==n&&t.setProperty(`--yuri-header-height`,n)});Nt(ye,([e])=>{e&&rn(e.borderBoxSize[0]?.blockSize??e.target.getBoundingClientRect().height)},{box:`border-box`}),Q.useLayoutEffect(()=>{rn(ye.current?.getBoundingClientRect().height)},[rn,ge,tn]);let an=Q.useCallback(async e=>{let t=e.target;t.closest(`.app-region-no-drag`)||t.closest(`button, a, input, select, textarea`)||e.button===0&&be&&await N()},[be]),on=Q.useMemo(()=>{if(ge){let e=[{id:`chat`,label:c(`layout.mainTab.chat`),icon:`chat-thread`}];return e.push({id:`diff`,label:c(`layout.mainTab.diff`),icon:`diff`},{id:`files`,label:c(`layout.mainTab.files`),icon:`folder-6`},{id:`terminal`,label:c(`layout.mainTab.terminal`),icon:`terminal-box`},{id:`diagram`,label:c(`layout.mainTab.diagram`),icon:`file`}),e}return[]},[ge,c]),J=Q.useCallback(e=>to(Qa(e,E)),[E]);(0,Q.useEffect)(()=>{!ge&&(C===`git`||C===`terminal`||C===`diff`||C===`files`)&&T(`chat`)},[C,ge,T]);let sn=Q.useMemo(()=>{let e=[];return be&&e.push({value:`instance`,label:c(`layout.services.instance`),icon:(0,$.jsx)(Z,{name:`connection-local`,className:`h-3.5 w-3.5`})}),e.push({value:`usage`,label:c(`layout.services.usage`),icon:(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`})},{value:`mcp`,label:`MCP`,icon:(0,$.jsx)(Ts,{className:`h-3.5 w-3.5`})}),e},[be,c]),cn=Q.useMemo(()=>sn.map(e=>({id:e.value,label:e.label,icon:e.icon})),[sn]),ln=Q.useMemo(()=>[{value:`usage`,label:c(`header.services.used`)},{value:`remaining`,label:c(`header.services.remaining`)}],[c]),un=Q.useMemo(()=>ln.map(e=>({id:e.value,label:e.label})),[ln]),fn=Q.useMemo(()=>[{id:`usage`,label:c(`layout.services.usage`),icon:(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`})},{id:`mcp`,label:`MCP`,icon:(0,$.jsx)(Ts,{className:`h-3.5 w-3.5`})}],[c]);(0,Q.useEffect)(()=>{let e=e=>{if(An(e)&&!e.shiftKey&&!e.altKey){let t=parseInt(e.key,10);t>=1&&t<=on.length&&(e.preventDefault(),ge&&(It(),Jt()),T(on[t-1].id))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[It,Jt,ge,T,on]);let hn=K(e=>{nt(e),Je(!0),ct(),e===`usage`&&ue===null&&W()});(0,Q.useEffect)(()=>{let e=e=>{let t=Qa(`toggle_services_menu`,E);if(Ja(e,t)){e.preventDefault();let t=bd({isOpen:qe,activeTab:tt,targetTab:be?`instance`:`usage`});t.open?hn(t.tab):Je(!1);return}let n=Qa(`cycle_services_tab`,E);if(Ja(e,n)){e.preventDefault();let t=sn.map(e=>e.value);if(t.length===0)return;let n=t.indexOf(tt),r=t[n===-1?0:(n+1)%t.length];nt(r),Je(!0),ct(),r===`usage`&&ue===null&&W();return}let r=Qa(`open_usage`,E);if(Ja(e,r)){e.preventDefault();let t=bd({isOpen:qe,activeTab:tt,targetTab:`usage`});t.open?hn(t.tab):Je(!1);return}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[E,be,qe,tt,sn,ue,W,ct,hn]);let gn=e=>{let t=C===e.id,n=e.icon===`diff`,r=n?null:e.icon,i=e.id===`chat`,a=e=>n?(0,$.jsx)(fu,{size:e}):r?(0,$.jsx)(Z,{name:r,className:`h-${e/4} w-${e/4}`}):null,o=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>T(e.id),className:X(`relative flex h-8 items-center gap-2 px-3 rounded-lg typography-ui-label font-medium transition-colors`,t?`app-region-no-drag bg-interactive-selection text-interactive-selection-foreground shadow-none`:`app-region-no-drag text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,i&&!ge&&`min-w-[100px] justify-center`),"aria-label":e.label,"aria-selected":t,role:`tab`,children:[ge?a(20):(0,$.jsxs)($.Fragment,{children:[a(16),(0,$.jsx)(`span`,{className:`header-tab-label`,children:e.label})]}),e.badge!==void 0&&e.badge>0&&(0,$.jsx)(`span`,{className:`header-tab-badge typography-micro text-status-info font-medium`,children:e.badge})]});return(0,$.jsx)(Q.Fragment,{children:o},e.id)},Y=!I&&Se&&(V||!!B),_n=Q.useCallback(e=>{window.setTimeout(e,0)},[]),vn=Q.useCallback(e=>{hn(e)},[hn]),yn=Q.useRef(null),bn=(0,$.jsxs)(`div`,{className:`relative flex shrink-0 items-center`,children:[(0,$.jsx)(`div`,{ref:yn,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center`,children:(0,$.jsxs)(Na,{children:[(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(Ra,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`header.actions.sessionMenuAria`),className:X(Gt,`text-muted-foreground`),children:(0,$.jsx)(Z,{name:`more-2`,className:`h-[18px] w-[18px]`})})})}),(0,$.jsx)(Ea,{children:(0,$.jsx)(`p`,{children:c(`header.actions.sessionMenu`)})})]}),(0,$.jsxs)(Ia,{align:`start`,className:`min-w-[14rem]`,children:[Y?(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:()=>_n(Bt),children:[(0,$.jsx)(Z,{name:`picture-in-picture-2`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(V?`header.actions.newMiniChat`:`header.actions.openSessionMiniChat`)})]}):null,be?(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:()=>_n(()=>vn(`instance`)),children:[(0,$.jsx)(Z,{name:`stack`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:c(`header.actions.sessionMenu.servicesWithInstance`,{current:Ze})}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:J(`toggle_services_menu`)})]}):null,(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:()=>_n(()=>vn(`usage`)),children:[(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`header.actions.sessionMenu.viewUsage`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:J(`open_usage`)})]}),(0,$.jsx)(Wa,{}),(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:()=>_n(g),children:[(0,$.jsx)(Z,{name:`terminal-box`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`header.actions.toggleTerminalPanel`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:J(`toggle_terminal`)})]}),(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:()=>_n(Ut),children:[(0,$.jsx)(Z,{name:`global`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`contextPanel.browser.open`)}),Wt?(0,$.jsx)(Z,{name:`check`,className:`h-3.5 w-3.5 text-foreground`}):null]})]})]})}),(0,$.jsx)(Td,{isDesktopApp:be,currentInstanceSupportsUpdate:$e,isDesktopServicesOpen:qe,setIsDesktopServicesOpen:Je,refreshCurrentInstanceLabel:ct,desktopServicesTab:tt,setDesktopServicesTab:nt,fetchAllQuotas:W,servicesTabItems:cn,quotaLastUpdated:ue,quotaDisplayMode:de,showPredValues:fe,quotaDisplayTabItems:un,handleDisplayModeChange:mt,handleUsageRefresh:ht,isQuotaLoading:le,isUsageRefreshSpinning:Ye,hasRateLimits:pt,rateLimitGroups:ft,expandedFamilies:ut,toggleFamilyExpanded:dt,timeFormatPreference:D,anchorRef:yn})]}),xn=(0,$.jsxs)($.Fragment,{children:[!I&&!ge&&!at&&C===`chat`?(0,$.jsx)(xu,{}):null,I?null:(0,$.jsx)(Qu,{directory:At}),be&&(0,$.jsx)(Ou,{open:qe&&tt===`instance`,onClick:()=>hn(`instance`)}),(0,$.jsx)(Cd,{title:c(`header.actions.rightSidebarWithShortcut`,{shortcut:J(`toggle_right_sidebar`)}),ariaLabel:c(`contextPanel.actions.togglePanel`),pressed:Dt,onClick:Ot,className:X(`app-region-no-drag group inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary hover:bg-interactive-hover transition-colors`,Dt?`bg-interactive-selection text-interactive-selection-foreground`:`text-muted-foreground/75 hover:text-foreground`),Icon:`folder-3`,iconClassName:`size-4`}),(0,$.jsx)(wd,{isMobile:ge,githubAuthStatus:_e,githubAccounts:He,githubAvatarUrl:Be,githubLogin:Ve,isSwitchingGitHubAccount:Ue,handleGitHubAccountSwitch:Ft})]}),Sn=()=>(0,$.jsxs)(`div`,{onMouseDown:an,className:X(`app-region-drag relative flex h-12 select-none items-center pr-3`,tn),style:nn,role:`tablist`,"aria-label":c(`header.navigation.mainAria`),children:[(0,$.jsx)(`div`,{"aria-hidden":!0,className:`shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,style:{width:$t}}),(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,style:{width:en}}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[(0,$.jsxs)(`div`,{className:`app-region-no-drag mr-3 flex min-w-0 items-center gap-0.5`,children:[(0,$.jsx)(Qs,{scopeProjectId:I?M?.id:null,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`sessions.switcher.openAria`),className:`inline-flex h-8 min-w-0 max-w-full items-center rounded-md px-2.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-primary`,children:(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground`,children:V?c(`sessions.switcher.draftTitle`):I&&s&&z?.sessionId?(0,$.jsx)(Md,{entry:s.resolve(z.location),sessionId:z.sessionId,fallback:kt},ee(z.location)):kt})})}),I?(0,$.jsxs)(`span`,{"data-remote-header-host":M?.hostId,className:`inline-flex min-w-0 max-w-36 items-center gap-1 typography-meta text-muted-foreground`,title:o,children:[(0,$.jsx)(Z,{name:`computer`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:o}),s&&M?.hostId?(0,$.jsx)(Si,{registry:s,hostId:M.hostId}):null]}):null]}),on.length>0&&(0,$.jsx)(`div`,{className:`flex items-center gap-1 rounded-lg bg-[var(--surface-muted)]/50 p-1`,children:on.map(e=>gn(e))}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[bn,I&&!at&&C===`chat`&&s&&z?.sessionId?(0,$.jsx)(Nd,{entry:s.resolve(z.location),sessionId:z.sessionId,onClick:Vt,pressed:Ht},ee(z.location)):null,ot&&Le?(0,$.jsx)(Xs,{pending:Le.pending,totalTokens:Le.totalTokens,percentage:st,colorPercentage:Le.percentage,contextLimit:Le.contextLimit,outputLimit:Le.outputLimit??0,size:`compact`,appearance:`subtle`,onClick:Vt,pressed:Ht}):null,xn,(0,$.jsx)(Zs,{visible:De&&Oe===`right`&&!Dt,position:`right`})]})]})]}),Cn=()=>(0,$.jsxs)(`div`,{className:`app-region-drag relative flex items-center gap-2 px-3 py-2 select-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e?(0,$.jsx)(`button`,{type:`button`,onClick:Yt,className:X(Kt,qt===`sessions`&&`bg-interactive-selection text-interactive-selection-foreground`),"aria-label":c(r?`header.actions.closeSessionsAria`:`header.actions.openSessionsAria`),children:(0,$.jsx)(Z,{name:`layout-left`,className:`h-5 w-5`})}):ze?(0,$.jsx)(`button`,{type:`button`,onClick:()=>u(!1),className:`app-region-no-drag h-9 w-9 p-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md active:bg-interactive-active`,"aria-label":c(`header.actions.backAria`),children:(0,$.jsx)(Z,{name:`arrow-left-s`,className:`h-5 w-5`})}):(0,$.jsx)(`button`,{type:`button`,onClick:Lt,className:`app-region-no-drag h-9 w-9 p-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md active:bg-interactive-active`,"aria-label":c(`header.actions.openSessionsAria`),children:(0,$.jsx)(Z,{name:`play-list-add`,className:`h-5 w-5`})}),!e&&ze&&(0,$.jsx)(`span`,{className:`typography-ui-label font-semibold text-foreground`,children:c(`header.sessions.title`)})]}),(!ze||!!e)&&(0,$.jsxs)($.Fragment,{children:[I?(0,$.jsxs)(`span`,{"data-remote-header-host":M?.hostId,className:`inline-flex max-w-28 shrink-0 items-center gap-1 typography-meta text-muted-foreground`,title:o,children:[(0,$.jsx)(`span`,{className:`truncate`,children:o}),s&&M?.hostId?(0,$.jsx)(Si,{registry:s,hostId:M.hostId}):null]}):null,(0,$.jsx)(`div`,{className:`app-region-no-drag flex min-w-0 flex-1 items-center`,children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 overflow-x-auto overflow-y-hidden scrollbar-hidden touch-pan-x overscroll-x-contain`,children:(0,$.jsx)(`div`,{className:`flex w-max items-center gap-1 pr-1`,children:(0,$.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-[var(--surface-muted)]/50 p-0.5`,role:`tablist`,"aria-label":c(`header.navigation.mainAria`),children:on.map(e=>{let t=C===e.id,n=e.icon===`diff`,r=n?null:e.icon;return(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{ge&&(It(),Jt()),T(e.id)},"aria-label":e.label,"aria-selected":t,role:`tab`,className:X(Kt,`relative rounded-lg`,qt===e.id&&`bg-interactive-selection text-interactive-selection-foreground`),children:[n?(0,$.jsx)(fu,{className:`h-5 w-5`}):r?(0,$.jsx)(Z,{name:r,className:`h-5 w-5`}):null,e.badge!==void 0&&e.badge>0&&(0,$.jsx)(`span`,{className:`absolute -top-1 -right-1 text-[10px] font-semibold text-primary`,children:e.badge}),e.showDot&&(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 h-2 w-2 rounded-full bg-primary`,"aria-label":c(`header.changes.availableAria`)})]})}),(0,$.jsx)(Ea,{children:(0,$.jsx)(`p`,{children:e.label})})]},e.id)})})})})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(gl,{mobile:!0}),Pt&&(0,$.jsx)(_d,{projectRef:Pt.projectRef,directory:Pt.directory,compact:!0,allowMobile:!0,className:`h-9`}),(0,$.jsxs)(Na,{open:Ge,onOpenChange:t=>{t&&(r&&e&&e(),i&&n&&n()),Ke(t),t&&ue===null&&W()},children:[(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(Ra,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`header.services.viewAria`),className:X(Kt,qt===`services`&&`bg-interactive-selection text-interactive-selection-foreground`),children:(0,$.jsx)(Z,{name:`stack`,className:`h-5 w-5`})})})}),(0,$.jsx)(Ea,{children:(0,$.jsx)(`p`,{children:c(`header.services.title`)})})]}),(0,$.jsx)(Ia,{align:`end`,sideOffset:0,positionerClassName:`!fixed !bottom-0 !left-0 !right-0 !top-[var(--yuri-header-height,56px)] !transform-none`,className:`h-full w-screen max-h-none rounded-none border-0 p-0 pt-1 overflow-hidden`,children:(0,$.jsxs)(`div`,{className:`flex h-full flex-col bg-[var(--surface-elevated)]`,children:[(0,$.jsx)(`div`,{className:`sticky top-0 z-20 bg-[var(--surface-elevated)] px-2 py-px`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-0`,children:[(0,$.jsx)(`div`,{className:`h-10 min-w-0 flex-1`,children:(0,$.jsx)(gs,{items:fn,activeId:rt,onSelect:e=>{let t=e;it(t),t===`usage`&&ue===null&&W()},layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,activePillButtonClassName:`h-8`,className:`h-full`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>Ke(!1),className:`inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover`,"aria-label":c(`header.services.closeAria`),children:(0,$.jsx)(Z,{name:`close`,className:`h-5 w-5`})})]})}),rt===`mcp`&&(0,$.jsx)(bc,{active:Ge&&rt===`mcp`}),rt===`usage`&&(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto overflow-x-hidden pb-[calc(4rem+env(safe-area-inset-bottom))]`,children:[(0,$.jsx)(`div`,{className:`border-b border-[var(--interactive-border)]`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col min-w-0 gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-header font-semibold text-foreground`,children:c(`header.services.rateLimits`)}),(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Dd(ue,D)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center h-6`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>mt(`usage`),className:X(`typography-ui-label px-1 pb-0.5 transition-colors`,de===`usage`?`text-foreground border-b-2 border-[var(--primary-base)]`:`text-muted-foreground hover:text-foreground`),children:c(`header.services.used`)}),(0,$.jsx)(`span`,{className:`text-muted-foreground typography-ui-label px-0.5`,children:`·`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>mt(`remaining`),className:X(`typography-ui-label px-1 pb-0.5 transition-colors`,de===`remaining`?`text-foreground border-b-2 border-[var(--primary-base)]`:`text-muted-foreground hover:text-foreground`),children:c(`header.services.remaining`)})]}),(0,$.jsx)(`button`,{type:`button`,className:X(`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors`,`hover:text-foreground hover:bg-interactive-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),onClick:ht,disabled:le||Ye,"aria-label":c(`header.services.refreshRateLimitsAria`),children:(0,$.jsx)(Z,{name:`refresh`,className:X(`h-4 w-4`,Ye&&`animate-spin`)})})]})]})}),!pt&&(0,$.jsx)(`div`,{className:`px-4 py-6 text-center`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:c(`header.services.noRateLimits`)})}),(0,$.jsx)(`div`,{className:`py-1`,children:ft.map((e,t)=>(0,$.jsxs)(Q.Fragment,{children:[t>0?(0,$.jsx)(`div`,{className:`mx-4 my-1 border-t border-[var(--interactive-border)]`}):null,(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2`,children:[(0,$.jsx)(No,{providerId:e.providerId,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:e.providerName})]}),e.entries.length===0&&(!e.modelFamilies||e.modelFamilies.length===0)?(0,$.jsx)(`div`,{className:`px-4 pb-2`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:e.error??c(`header.services.noRateLimitsReported`)})}):(0,$.jsxs)(`div`,{className:`space-y-3 px-4 pb-2`,children:[e.entries.map(([t,n],r)=>{let i=Ac(e.entries,r),a=de===`remaining`?n.remainingPercent:n.usedPercent,o=n.disablePace?null:Ba(n.usedPercent,n.resetAt,n.windowSeconds,t),s=o?.dailyAllocationPercent==null?null:de===`remaining`?100-uo(o.elapsedRatio):uo(o.elapsedRatio),c=La(n.valueLabel,a),l=ja(n.resetAt,n.resetAfterFormatted??n.resetAtFormatted,D);return(0,$.jsxs)(Q.Fragment,{children:[i?(0,$.jsx)(`div`,{className:X(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,r>0&&`mt-5 border-t border-[var(--surface-subtle)] pt-3`),children:i}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground break-words`,children:ka(n.label??t)}),l?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:l}):null]}),(0,$.jsx)(`span`,{className:`shrink-0 whitespace-nowrap typography-ui-label text-foreground tabular-nums`,children:c===`-`?``:c})]}),(0,$.jsx)(Us,{percent:a,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:s}),o&&fe?(0,$.jsx)(Is,{paceInfo:o,compact:!0}):null]})]},`${e.providerId}-${t}`)}),e.modelFamilies&&e.modelFamilies.length>0&&(0,$.jsx)(`div`,{className:`space-y-0.5`,children:e.modelFamilies.map(t=>{let n=(ut[e.providerId]??[]).includes(t.familyId??`other`);return(0,$.jsxs)(zl,{open:n,onOpenChange:()=>dt(e.providerId,t.familyId??`other`),children:[(0,$.jsxs)(Rl,{className:`flex w-full items-center justify-between rounded-md px-1 py-1.5 text-left hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:t.familyLabel}),n?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`})]}),(0,$.jsx)(Ll,{children:(0,$.jsx)(`div`,{className:`space-y-2.5 pb-1 pl-1 pt-1`,children:t.models.map(([t,n])=>{let r=de===`remaining`?n.remainingPercent:n.usedPercent,i=Ba(n.usedPercent,n.resetAt,n.windowSeconds),a=i?.dailyAllocationPercent==null?null:de===`remaining`?100-uo(i.elapsedRatio):uo(i.elapsedRatio),o=La(n.valueLabel,r);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Cs(t)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground tabular-nums`,children:o===`-`?``:o})]}),(0,$.jsx)(Us,{percent:r,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:a}),i&&fe?(0,$.jsx)(Is,{paceInfo:i,compact:!0}):null]},`${e.providerId}-${t}`)})})})]},t.familyId??`other`)})})]})]},e.providerId))})]})]})})]}),n?(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:Xt,className:X(Kt,`relative`,qt===`git`&&`bg-interactive-selection text-interactive-selection-foreground`),"aria-label":i?`Close git sidebar`:`Open git sidebar`,children:(0,$.jsx)(Z,{name:`layout-right`,className:`h-5 w-5`})})}),(0,$.jsx)(Ea,{children:(0,$.jsx)(`p`,{children:i?`Close git sidebar`:`Open git sidebar`})})]}):null]})]})]}),wn=X(`header-safe-area relative z-10 bg-background`,Ce&&`bg-[var(--surface-background)] backdrop-blur-none`,ge&&`yuri-layout-divider-b`);return(0,$.jsx)($.Fragment,{children:(0,$.jsx)(`header`,{ref:ye,className:wn,style:{"--padding-scale":`1`},children:ge?Cn():Sn()})})};function Fd(){}function Id(e){return e.projects.find(t=>t.id===e.activeProjectId)?.hostId}function Ld(){}var Rd=180,zd=640,Bd=110,Vd=e=>{let t=(0,du.c)(44),{isOpen:n,isMobile:r,children:i}=e,{t:a}=Zt(),o=q(Hd),s=q(Ud),c=q(Wd),l=q(Gd),[u,d]=Q.useState(null),[f,p]=Q.useState(!1),m=Q.useRef(null),h=Q.useRef(0),g=Q.useRef(o||300),_=Math.min(zd,Math.max(Rd,o||300)),v,y;t[0]===n?(v=t[1],y=t[2]):(v=()=>{n||(d(null),p(!1))},y=[n],t[0]=n,t[1]=v,t[2]=y),Q.useEffect(v,y);let b,x;t[3]!==s||t[4]!==r||t[5]!==n?(b=()=>{if(r||!n||!s)return;let e=()=>{let e=m.current?.parentElement?.getBoundingClientRect().height;if(!e||e<=0)return;let t=Math.max(0,Math.round(e));d(e=>e===t?e:t)};e();let t=m.current?.parentElement;if(!t)return;let i=new ResizeObserver(e);return i.observe(t),()=>{i.disconnect()}},x=[s,r,n],t[3]=s,t[4]=r,t[5]=n,t[6]=b,t[7]=x):(b=t[6],x=t[7]),Q.useEffect(b,x);let S,C;if(t[8]!==s||t[9]!==r||t[10]!==f||t[11]!==c||t[12]!==l?(S=()=>{if(r||!f||s)return;let e=e=>{let t=h.current-e.clientY,n=Math.min(zd,Math.max(Rd,g.current+t));c(n)},t=()=>{p(!1),q.getState().bottomTerminalHeight<=Bd&&l(!1)};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t,{once:!0}),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},C=[s,r,f,c,l],t[8]=s,t[9]=r,t[10]=f,t[11]=c,t[12]=l,t[13]=S,t[14]=C):(S=t[13],C=t[14]),Q.useEffect(S,C),r)return null;let w=n?s?Math.max(0,u??_):_:0,T=n&&s,E;t[15]!==w||t[16]!==s||t[17]!==n?(E=e=>{!n||s||(p(!0),h.current=e.clientY,g.current=w,e.preventDefault())},t[15]=w,t[16]=s,t[17]=n,t[18]=E):E=t[18];let D=E,O=T?`absolute inset-x-0 bottom-0 z-40`:`relative`,k=f?`transition-none`:`transition-[height] duration-300 ease-in-out`,A=(!n||T)&&`border-t-0`,j;t[19]!==A||t[20]!==O||t[21]!==k?(j=X(`flex overflow-hidden border-t border-border bg-sidebar`,O,k,A),t[19]=A,t[20]=O,t[21]=k,t[22]=j):j=t[22];let M;t[23]!==w||t[24]!==T?(M=T?{top:0}:{height:`${w}px`,minHeight:`${w}px`,maxHeight:`${w}px`},t[23]=w,t[24]=T,t[25]=M):M=t[25];let N=!n||!s&&w===0,P;t[26]!==D||t[27]!==s||t[28]!==n||t[29]!==f||t[30]!==a?(P=n&&!s&&(0,$.jsx)(`div`,{className:X(`absolute left-0 top-0 z-20 h-[3px] w-full cursor-row-resize hover:bg-[var(--interactive-border)]/80 transition-colors`,f&&`bg-[var(--interactive-border)]`),onPointerDown:D,role:`separator`,"aria-orientation":`horizontal`,"aria-label":a(`terminalView.bottomDock.resizeAria`)}),t[26]=D,t[27]=s,t[28]=n,t[29]=f,t[30]=a,t[31]=P):P=t[31];let F=!n&&`pointer-events-none select-none opacity-0`,I;t[32]===F?I=t[33]:(I=X(`relative z-10 flex h-full min-h-0 w-full flex-col transition-opacity duration-300 ease-in-out`,F),t[32]=F,t[33]=I);let L=!n,R;t[34]!==i||t[35]!==I||t[36]!==L?(R=(0,$.jsx)(`div`,{className:I,"aria-hidden":L,children:i}),t[34]=i,t[35]=I,t[36]=L,t[37]=R):R=t[37];let z;return t[38]!==j||t[39]!==M||t[40]!==N||t[41]!==P||t[42]!==R?(z=(0,$.jsxs)(`section`,{ref:m,className:j,style:M,"aria-hidden":N,children:[P,R]}),t[38]=j,t[39]=M,t[40]=N,t[41]=P,t[42]=R,t[43]=z):z=t[43],z};function Hd(e){return e.bottomTerminalHeight}function Ud(e){return e.isBottomTerminalExpanded}function Wd(e){return e.setBottomTerminalHeight}function Gd(e){return e.setBottomTerminalOpen}var Kd=260,qd=260,Jd=500,Yd=e=>Math.min(Jd,Math.max(qd,e)),Xd=({isOpen:e,isMobile:t,children:n,className:r,topBar:i})=>{let{t:a}=Zt(),o=q(e=>e.sidebarWidth),s=q(e=>e.setSidebarWidth),[c,l]=Q.useState(!1),u=Q.useRef(0),d=Q.useRef(o||Kd),f=Q.useRef(null),p=Q.useRef(null),m=Q.useRef(null),h=Q.useRef(null),g=K(e=>{let t=m.current;t&&(t.style.width=`${e}px`,t.style.minWidth=`${e}px`,t.style.maxWidth=`${e}px`,h.current&&(h.current.style.width=`${e}px`))});if(Q.useEffect(()=>{t&&c&&l(!1)},[t,c]),Q.useEffect(()=>{c||(f.current=null,p.current=null)},[c]),t)return null;let _=Math.min(Jd,Math.max(qd,o||Kd)),v=e?_:0,y=t=>{if(e){try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}p.current=t.pointerId,l(!0),u.current=t.clientX,d.current=v,f.current=v,g(v),t.preventDefault()}},b=e=>{if(t||!c||p.current!==e.pointerId)return;let n=e.clientX-u.current,r=Yd(d.current+n);f.current!==r&&(f.current=r,g(r))},x=e=>{if(p.current!==e.pointerId||t)return;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}let n=Yd(f.current??v);p.current=null,f.current=null,l(!1),s(n)},S=c?f.current??v:v;return(0,$.jsxs)(`aside`,{ref:m,className:X(`relative flex h-full overflow-hidden yuri-layout-divider-r will-change-[width] motion-reduce:transition-none`,`bg-sidebar yuri-vibrancy-surface`,!e&&`border-r-0`,r),style:{width:`${S}px`,minWidth:`${S}px`,maxWidth:`${S}px`,overflowX:`clip`,transitionProperty:c?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!e||v===0,children:[e&&(0,$.jsx)(`div`,{className:X(`absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors`,c&&`bg-[var(--interactive-border)]`),onPointerDown:y,onPointerMove:b,onPointerUp:x,onPointerCancel:x,role:`separator`,"aria-orientation":`vertical`,"aria-label":a(`sidebar.resize.leftPanelAria`)}),(0,$.jsxs)(`div`,{ref:h,className:X(`relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,c&&`pointer-events-none`,!e&&`pointer-events-none select-none opacity-0`),style:{width:`${c?S:_}px`,overflowX:`hidden`},"aria-hidden":!e,children:[i,(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,$.jsx)(po,{children:n})})]})]})},Zd=()=>{let e=(0,du.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={height:`var(--yuri-header-height, 3rem)`},e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-drag shrink-0`,style:{width:`var(--yuri-titlebar-left-inset, 0.75rem)`}}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex shrink-0`,style:t,children:[n,(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-no-drag shrink-0`,style:{width:`calc(var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`}}),(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-drag flex-1`})]}),e[2]=r):r=e[2],r},Qd=e=>{let t=(0,du.c)(26),{className:n}=e,{t:r}=Zt(),i=q($d),a=Bs(ef).trim(),o=a.split(/\s+/).filter(Boolean),s=o.includes(`Yuri`),c=o.some(tf);if(Q.useEffect(()=>{c&&ia()},[c]),o.length===0)return null;let l;t[0]===n?l=t[1]:(l=X(`flex min-w-0 items-center overflow-hidden pb-2 pt-1`,n),t[0]=n,t[1]=l);let u=Y,d;t[2]===r?d=t[3]:(d=r(`layout.brand.editName`),t[2]=r,t[3]=d);let f;t[4]===r?f=t[5]:(f=r(`layout.brand.editName`),t[4]=r,t[5]=f);let p;t[6]===i?p=t[7]:(p=()=>i(`appearance`,`appearance.sidebar-brand`),t[6]=i,t[7]=p);let m=o.join(` `),h=a.includes(`Yuri`)?`items-center`:`items-baseline`,g;t[8]===h?g=t[9]:(g=X(`inline-flex min-w-0 gap-[0.28em] overflow-hidden whitespace-nowrap text-foreground`,h),t[8]=h,t[9]=g);let _;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(_={fontFamily:`"Syne", var(--font-sans, system-ui, sans-serif)`,fontSize:`1.0625rem`,fontWeight:700,letterSpacing:`0.08em`,lineHeight:1},t[10]=_):_=t[10];let v=a.includes(`Yuri`)?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0 self-center`,children:(0,$.jsx)(fo,{width:24,height:24,className:`size-6`})}):null,y=o.map((e,t)=>(0,$.jsx)(`span`,{"aria-hidden":`true`,className:X(`inline-flex shrink-0 items-baseline`,!s&&t>0&&`text-primary`),children:e===`Yuri`?(0,$.jsx)(Dl,{width:`2.44814cap`}):e},t)),b;t[11]!==g||t[12]!==_||t[13]!==v||t[14]!==y||t[15]!==m?(b=(0,$.jsxs)(`span`,{role:`img`,"aria-label":m,className:g,style:_,children:[v,y]}),t[11]=g,t[12]=_,t[13]=v,t[14]=y,t[15]=m,t[16]=b):b=t[16];let x;t[17]!==u||t[18]!==b||t[19]!==d||t[20]!==f||t[21]!==p?(x=(0,$.jsx)(u,{variant:`ghost`,size:`xs`,className:`app-region-no-drag min-w-0 max-w-full justify-start`,"aria-label":d,title:f,onClick:p,children:b}),t[17]=u,t[18]=b,t[19]=d,t[20]=f,t[21]=p,t[22]=x):x=t[22];let S;return t[23]!==l||t[24]!==x?(S=(0,$.jsx)(`div`,{className:l,children:x}),t[23]=l,t[24]=x,t[25]=S):S=t[25],S};function $d(e){return e.openSettingsAtItem}function ef(e){return e.sidebarBrandName}function tf(e){return e!==`Yuri`}var nf=`app-region-no-drag inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/75 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary hover:bg-interactive-hover hover:text-foreground transition-colors`,rf=()=>{let e=(0,du.c)(50),{t}=Zt(),n=mn(af),r=dn(of),i=n?.hostId&&r?.projectId===n.id&&r.location.hostId===n.hostId&&(!n.hubId||r.location.hubId===n.hubId)?r:null,a;e[0]!==n||e[1]!==i?(a=i?ee(i.location):n?.hostId&&n.hubId?ee({hubId:n.hubId,hostId:n.hostId,directory:n.path}):n?.path,e[0]=n,e[1]=i,e[2]=a):a=e[2];let o=a,s=q(sf),c=q(cf),l=q(lf),u=q(uf),d=Bs(df),f=Q.useRef(null),p=to(Qa(`toggle_sidebar`,u)),{usesFramelessChrome:m,side:h}=$s(),g;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=v(),e[3]=g):g=e[3];let _=g,y=!_||!s||!d,b;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(b=!w()&&!_&&re(),e[4]=b):b=e[4];let x=b,S=pf,C,T;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{if(typeof document>`u`)return;let e=f.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect().width;document.documentElement.style.setProperty(`--yuri-titlebar-controls-width`,`${Math.round(t)}px`)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},T=[],e[5]=C,e[6]=T):(C=e[5],T=e[6]),Q.useEffect(C,T);let E=o||void 0,D=x&&s?`${c||260}px`:void 0,O;e[7]===D?O=e[8]:(O={height:`var(--yuri-header-height, 3rem)`,paddingLeft:`var(--yuri-titlebar-left-inset, 0.75rem)`,width:D},e[7]=D,e[8]=O);let k=x&&s&&`w-full justify-between`,A;e[9]===k?A=e[10]:(A=X(`flex items-center gap-2`,k),e[9]=k,e[10]=A);let j;e[11]===s?j=e[12]:(j=x&&s?(0,$.jsx)(Qd,{className:`flex min-w-0 items-center p-0 pl-1.5`}):null,e[11]=s,e[12]=j);let M;e[13]!==m||e[14]!==h?(M=m&&h===`left`?(0,$.jsx)(Zs,{visible:!0,position:`left`}):null,e[13]=m,e[14]=h,e[15]=M):M=e[15];let N;e[16]!==t||e[17]!==m?(N=m?(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:S,"aria-label":t(`header.actions.openAppMenuAria`),className:X(nf,`shrink-0`),children:(0,$.jsx)(Z,{name:`menu-2`,className:`h-[18px] w-[18px]`})})}),(0,$.jsx)(Ea,{children:(0,$.jsx)(`p`,{children:t(`header.actions.openAppMenu`)})})]}):null,e[16]=t,e[17]=m,e[18]=N):N=e[18];let P;e[19]===y?P=e[20]:(P=y?(0,$.jsx)(pl,{}):null,e[19]=y,e[20]=P);let F=Oa,I;e[21]===t?I=e[22]:(I=t(`header.actions.openSessionsAria`),e[21]=t,e[22]=I);let L,R;e[23]===Symbol.for(`react.memo_cache_sentinel`)?(L=X(nf,`group shrink-0`),R=(0,$.jsx)(Z,{name:`layout-left-rounded`,className:`size-4 text-foreground/55 transition-colors group-hover:text-foreground group-focus-visible:text-foreground`}),e[23]=L,e[24]=R):(L=e[23],R=e[24]);let z;e[25]!==I||e[26]!==l?(z=(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:l,"aria-label":I,className:L,children:R})}),e[25]=I,e[26]=l,e[27]=z):z=e[27];let B=Ea,V=t(`header.actions.openSessionsWithShortcut`,{shortcut:p}),te;e[28]===V?te=e[29]:(te=(0,$.jsx)(`p`,{children:V}),e[28]=V,e[29]=te);let ne;e[30]!==B||e[31]!==te?(ne=(0,$.jsx)(B,{children:te}),e[30]=B,e[31]=te,e[32]=ne):ne=e[32];let ie;e[33]!==F||e[34]!==z||e[35]!==ne?(ie=(0,$.jsxs)(F,{children:[z,ne]}),e[33]=F,e[34]=z,e[35]=ne,e[36]=ie):ie=e[36];let ae;e[37]!==P||e[38]!==ie?(ae=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[P,ie]}),e[37]=P,e[38]=ie,e[39]=ae):ae=e[39];let oe;e[40]!==A||e[41]!==j||e[42]!==M||e[43]!==N||e[44]!==ae?(oe=(0,$.jsxs)(`div`,{ref:f,className:A,children:[j,M,N,ae]}),e[40]=A,e[41]=j,e[42]=M,e[43]=N,e[44]=ae,e[45]=oe):oe=e[45];let H;return e[46]!==oe||e[47]!==E||e[48]!==O?(H=(0,$.jsx)(`div`,{"data-titlebar-location":E,className:`app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2`,style:O,children:oe}),e[46]=oe,e[47]=E,e[48]=O,e[49]=H):H=e[49],H};function af(e){return e.projects.find(t=>t.id===e.activeProjectId)}function of(e){return e.remoteSession}function sf(e){return e.isSidebarOpen}function cf(e){return e.sidebarWidth}function lf(e){return e.toggleSidebar}function uf(e){return e.shortcutOverrides}function df(e){return e.sidebarBrandName.trim().length>0}function ff(e){console.warn(`[titlebar] failed to open app menu`,e)}function pf(e){let t=e.currentTarget.getBoundingClientRect();P(`desktop_show_app_menu`,{x:t.left,y:t.bottom}).catch(ff)}var mf=(e,t)=>{let n=jt(t,e);return!n||n===`.`||n===t?0:n.split(`/`).filter(Boolean).length},hf=(e,t,n=10)=>{let r=At(e);if(!r||n<1)return[];let i=new Set,a=[];for(let e of Object.values(t))if(e)for(let t of e){if(t.type!==`directory`)continue;let e=At(t.path);if(!e||i.has(e))continue;let o=mf(r,e);o<1||o>n||(i.add(e),a.push(e))}return a},gf=e=>e.some(e=>!!At(e)),_f=(e,t)=>{let n=new Set(t.map(e=>At(e)).filter(Boolean));return e.filter(e=>!n.has(e))},vf=(e,t,n)=>t.length===0?e.length===0:_f(e,t).length>0?!1:t.every(e=>n.has(At(e))),yf=So(()=>Pt(()=>import(`./ToolOutputDialog-CifgNF-1.js`).then(e=>e.n),__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]))),bf=e=>{let t=Cf(e);if(!t)return``;if(t===`/`||/^[A-Za-z]:\/$/.test(t))return t;let n=t.lastIndexOf(`/`);if(n<0)return t;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?`${r}/`:r},xf=e=>{let t=(0,du.c)(8),{label:n,iconDataUrl:r}=e,[i,a]=Q.useState(!1),o;t[0]===n?o=t[1]:(o=n.trim().slice(0,1).toUpperCase()||`?`,t[0]=n,t[1]=o);let s=o;if(r&&!i){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>a(!0),t[2]=e):e=t[2];let n;return t[3]===r?n=t[4]:(n=(0,$.jsx)(`img`,{src:r,alt:``,className:`size-4 rounded-sm`,onError:e}),t[3]=r,t[4]=n),n}let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=X(`size-4 rounded-sm flex items-center justify-center`,`bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground`),t[5]=c):c=t[5];let l;return t[6]===s?l=t[7]:(l=(0,$.jsx)(`span`,{className:c,children:s}),t[6]=s,t[7]=l),l},Sf=e=>e.slice().sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1),Cf=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+/g,`/`);n&&!r.startsWith(`//`)&&(r=`/${r}`);let i=r===`/`,a=/^[A-Za-z]:\/$/.test(r);return!i&&!a&&(r=r.replace(/\/+$/,``)),r},wf=e=>e.startsWith(`/`)||e.startsWith(`//`)||/^[A-Za-z]:\//.test(e),Tf=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,Ef=(e,t)=>{let n=Cf(t),r=Cf(e);if(!n||!r)return!1;let i=Tf(n),a=Tf(r);return a===i||a.startsWith(`${i}/`)},Df=(e,t)=>{let n=Cf(t),r=Cf(e);if(!Ef(r,n))return[];let i=r.slice(n.length).replace(/^\//,``).split(`/`),a=[],o=n;for(let e=0;e<i.length-1;e++)o=o?`${o}/${i[e]}`:i[e],a.push(o);return a},Of=(e,t)=>{if(!t)return``;let n=Cf(t);if(!e||!Ef(n,e))return n;let r=n.slice(e.length);return r.startsWith(`/`)?r.slice(1):r},kf=new Set([`node_modules`]),Af=e=>{let t=(0,du.c)(3),{status:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={open:`var(--status-info)`,modified:`var(--status-warning)`,"git-modified":`var(--status-warning)`,"git-added":`var(--status-success)`,"git-deleted":`var(--status-error)`},t[0]=r):r=t[0];let i=r[n],a;return t[1]===i?a=t[2]:(a=(0,$.jsx)(`span`,{className:`size-2 rounded-full`,style:{backgroundColor:i}}),t[1]=i,t[2]=a),a},jf=e=>{let t=(0,du.c)(11),{name:n}=e,r=Q.useRef(null),i=Q.useRef(null),[a,o]=Q.useState(!1),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=r.current,t=i.current;if(!e||!t)return;let n=()=>{o(t.scrollWidth>e.clientWidth+1)};n();let a=new ResizeObserver(n);return a.observe(e),a.observe(t),()=>{a.disconnect()}},t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=[n],t[1]=n,t[2]=c),Q.useLayoutEffect(s,c);let l;t[3]===n?l=t[4]:(l=(0,$.jsx)(`span`,{ref:i,"aria-hidden":`true`,className:`invisible absolute whitespace-nowrap`,children:n}),t[3]=n,t[4]=l);let u;t[5]!==n||t[6]!==a?(u=a?(0,$.jsxs)(`span`,{className:`open-file-name-marquee-track`,children:[(0,$.jsx)(`span`,{className:`open-file-name-marquee-item`,children:n}),(0,$.jsx)(`span`,{className:`open-file-name-marquee-item`,"aria-hidden":`true`,children:n})]}):(0,$.jsx)(`span`,{className:`block min-w-0 truncate`,children:n}),t[5]=n,t[6]=a,t[7]=u):u=t[7];let d;return t[8]!==l||t[9]!==u?(d=(0,$.jsxs)(`span`,{ref:r,className:`relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap`,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10],d},Mf=e=>kf.has(e),Nf=e=>{let t=Cf(e);return t===`node_modules`||t.endsWith(`/node_modules`)||t.includes(`/node_modules/`)},Pf=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`is a directory`)||t.includes(`eisdir`)},Ff=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`file not found`)||t.includes(`enoent`)||t.includes(`no such file`)||t.includes(`does not exist`)},If=2e5,Lf=`yuri:files:auto-save-enabled`,Rf=e=>{let t=0,n=0;for(let r=0;r<e.length;r+=1)e.charCodeAt(r)===10&&(r>0&&e.charCodeAt(r-1)===13?t+=1:n+=1);return t>n?`\r
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-C03nGQvh.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-auth-mjIpsk3N.js","assets/runtime-switch-BMjl5Y5W.js","assets/runtime-fetch-DKZOpfzo.js","assets/reasoning-projection-client-BEhVknv9.js","assets/platform-wF65ZFgV.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-base-ui-fom6orB6.js","assets/vendor-react-D5BntRmA.js","assets/vendor-tanstack-react-query-ChSd65dm.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/runtime-file-resource-DnhWnndu.js","assets/path-utils-jGozTg9d.js","assets/vendor-reactuses-core-B8s-Rcd-.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-store-BVRgEtI-.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/useUIStore-CYex4rbF.js","assets/vendor-zustand-CNn3HHhT.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/safeStorage-DTOhKN0V.js","assets/useMobileHtmlPreviewStore-DUquFMmd.js","assets/runtime-file-download-Dc459c9e.js","assets/vendor-pierre-diffs-HJfPTtu2.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/i18n-OsFhnlRH.js","assets/runtime-ead7P81A.js","assets/bootstrap-eLlfzqAI.js","assets/store-Dj5cSf8B.js","assets/tour-CMXP3Kif.js","assets/useMobileNavigationStore-CXvADUF9.js","assets/gitApiHttp-BEMPJCIG.js","assets/client-CgAFd1ew.js","assets/vendor-opencode-client-BM2r1f0o.js","assets/vendor-effect-X1Hqc7ba.js","assets/prompt-attachment-upload-8bssUUT3.js","assets/uuid-D-SDZijH.js","assets/vendor-sonner-Y-KPX915.js","assets/useAssistantUIStore-CphyXHEY.js","assets/input-store-DRTu4uZc.js","assets/remoteProjectQueries-8giIAvzL.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/toolHelpers-iEHVHQ9p.js","assets/useThemeSystem-D2YBbLma.js","assets/vendor-framer-motion-DiGWHm7K.js","assets/Icon-DNZA_riL.js","assets/dialog-DcdiMxIb.js","assets/dialog-DYOEW9DC.css","assets/tap-LkQum5bB.js","assets/themes-BgDJcxRc.js","assets/MarkdownRenderer-D2oCSF9S.js","assets/useEffectiveDirectory-DP_Vb2yB.js","assets/markdownHeightCache-248kmm0A.js","assets/dualLimitLru-D8Sphgua.js","assets/MobileWindowStack-DGLdgoGr.js","assets/mobileBackNavigation-CbHUVgUi.js","assets/agentColors-DWSbQXy2.js","assets/rasterizePng-056Poix7.js","assets/image-loading-ZB1bYt51.js","assets/image-loading-DA9JEHD8.css","assets/ImageLoadingPlaceholder-xLFiotWm.js","assets/vendor-tanstack-react-virtual-WY42p6U6.js","assets/markdownTheme-C2LJ3cJo.js","assets/markdown-worker-oBGEB9Eg.js","assets/TerminalView-BmdJXwbs.js","assets/terminalApi-eR_918UZ.js","assets/vendor-ghostty-web-DbBrwBII.js","assets/device-C8ZHblkr.js","assets/OverlayScrollbar-BsUherue.js","assets/useProjectRuntimeAPIs-C47fBxo8.js","assets/sortable-tabs-strip-2Mhh65oR.js","assets/vendor-dnd-kit-core-DRyd7I0I.js","assets/vendor-dnd-kit-accessibility-Cf9EEJvm.js","assets/vendor-dnd-kit-sortable-C8S8cyRO.js","assets/useFontPreferences-DFF-uEAD.js","assets/project-preview-BhNspxqe.js","assets/relay-preview-frame-src-BPyz3nXA.js","assets/projectActions-50e_f9dI.js","assets/DiagramView-zPxVoYfO.js","assets/diagram-D0rZqQqX.js","assets/vendor-react-drawio-DXADKcSU.js","assets/SettingsView-CmYrql0Y.js","assets/desktopHosts-135cuRCE.js","assets/desktopRelayRestore-1aUztDPU.js","assets/types-CsZ29VjS.js","assets/native-config-C7I5Js2W.js","assets/vendor-codemirror-autocomplete-C0FrlFqZ.js","assets/MobileDetailNavigation-D9OZvTH7.js","assets/MobileShareBridge-BqhP1wSW.js","assets/mobileConnections-B2OHZP1-.js","assets/AgentAvatar-b8inwRDh.js","assets/vendor-dicebear-core-CV95S5Pg.js","assets/vendor-dicebear-styles-C4OfoX7R.js","assets/gitApi-B74KW8UU.js","assets/input-BSVjxHBf.js","assets/tooltip-o8hl4eie.js","assets/pwa-BGxwZ3sK.js","assets/vendor-simplewebauthn-browser-Dwhcdg_5.js","assets/MobileResizableSheet-CJLBR89R.js","assets/select-DikdnuBx.js","assets/textarea-CjzOsOcb.js","assets/dropdown-menu.styles-BDla58Rm.js","assets/projectMeta-548A_zjC.js","assets/YuriLogo-DNvrroBa.js","assets/react-DUWkLJW_.js","assets/scheduledTaskNavigation-Bi7sRiFW.js","assets/MobileSurface-DFRJ7nyL.js","assets/vendor-codemirror-lang-angular-Cm7vBE3E.js","assets/vendor-codemirror-lang-json-DowyFczU.js","assets/vendor-codemirror-lang-markdown-npWBZIoE.js","assets/vendor-codemirror-lang-python-OPRdU26g.js","assets/vendor-codemirror-legacy-modes-DwltVFbT.js","assets/mcpQueries-Da7X2ZE0.js","assets/usePluginsStore-CfZJ7xPI.js","assets/collapsible-CYFRNuOh.js","assets/vendor-codemirror-commands-5saeUOVY.js","assets/vendor-codemirror-search-hZY-L2l8.js","assets/vendor-replit-codemirror-vim-BmQmU1lR.js","assets/vendor-codemirror-language-data-B3pLWvv-.js","assets/readiness-DpD_wUMJ.js","assets/context-menu-Ba6Opvzx.js","assets/vendor-qrcode-D7jBCyl-.js","assets/vendor-dijkstrajs-BAzPDGZM.js","assets/VoiceSettings-DV3EAW04.js","assets/useDictation-Do12BpsS.js","assets/speechSettingsQueries-B3yVfEX8.js","assets/VoiceSettings-C0HSdVvS.css","assets/GuiPluginWindow-BS0XZ8UB.js","assets/vendor-yaml-C9KlJAlj.js","assets/SettingsWindow-DbAjbzAm.js","assets/MultiRunWindow-BjmrZIN8.js","assets/multirun-BtlXFSSx.js","assets/checkbox-BmDsqYlN.js","assets/insertionBoundaries-Dt_DdXrL.js","assets/fileMentionAutocompleteState-BZJqfgae.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/vendor-fuzzysort-ukaRp9PC.js","assets/fileMentionTouchSelection-BZufsE6q.js","assets/AssistantView-oeyp5moU.js","assets/sessionLookup-DIImfb9J.js","assets/AssistantConversationSurface-DcXXPlNA.js","assets/reference-history-D7pv4xBj.js","assets/LoadingImage-B1Q7emSX.js","assets/reference-history-8C8nv-EP.css","assets/vendor-motion-DtmZZeEm.js","assets/assistant-attachment-cache-zu9sz4ex.js","assets/AssistantSessionCard-DX7b5oge.js","assets/AssistantConversationSurface-B59k-lXE.css","assets/AssistantUnreadBadge-D2d4OBjo.js","assets/navigation-Bart975B.js","assets/OnboardingScreen-6UdQ9pI2.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,p as r,t as i,v as a,w as o}from"./runtime-auth-mjIpsk3N.js";import{c as s,f as c,i as l,n as u,o as d,r as f,s as p,t as m}from"./runtime-switch-BMjl5Y5W.js";import{n as h}from"./runtime-fetch-DKZOpfzo.js";import{$ as g,A as _,F as v,G as y,H as b,L as x,P as S,Q as C,R as w,U as T,W as E,X as D,a as O,c as k,ct as A,dt as j,f as M,it as N,j as P,k as F,l as I,lt as L,m as R,p as z,s as ee,st as B,u as V,ut as te,v as ne,z as re}from"./platform-wF65ZFgV.js";import{n as ie,t as ae}from"./runtimeAPIRegistry-C2VogTny.js";import{d as oe,h as H,m as se,r as U,v as ce}from"./desktopHosts-135cuRCE.js";import{a as W,i as le,t as ue}from"./vendor-zustand-CNn3HHhT.js";import{A as de,B as fe,C as pe,F as me,I as he,L as ge,M as _e,N as ve,R as ye,S as be,T as xe,a as Se,i as Ce,it as we,j as Te,ot as Ee,st as De,z as Oe}from"./vendor-base-ui-fom6orB6.js";import{Ct as ke,Et as Ae,Ft as je,Mt as Me,Pt as Ne,St as Pe,Tt as Fe,an as Ie,jt as Le,on as Re,wt as G,xt as ze}from"./gitApiHttp-BEMPJCIG.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as Be,r as Ve,t as He}from"./safeStorage-DTOhKN0V.js";import{Bt as Ue,Ct as We,Jt as Ge,Qt as Ke,U as qe,V as Je,Yt as Ye,Zt as Xe,gt as Ze,ht as Qe,in as $e,n as et,nn as tt,on as nt,pt as rt,sn as it,yr as at,zt as ot}from"./client-CgAFd1ew.js";import{P as st,d as ct,z as lt}from"./prompt-attachment-upload-8bssUUT3.js";import{n as ut,t as dt}from"./vendor-react-D5BntRmA.js";import{f as ft,u as pt}from"./vendor-tanstack-query-core-BSjXNgF_.js";import{n as mt,o as ht,s as gt}from"./vendor-tanstack-react-query-ChSd65dm.js";import{E as _t,H as vt,L as yt,O as bt,P as xt,V as St,c as Ct,q as wt,r as Tt,s as Et,t as Dt,y as Ot,z as kt}from"./runtime-file-resource-DnhWnndu.js";import{a as At,n as jt}from"./path-utils-jGozTg9d.js";import{h as Mt,m as Nt,r as K}from"./vendor-reactuses-core-B8s-Rcd-.js";import{o as Pt}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{a as Ft,i as It,o as Lt,r as q,s as Rt,t as zt}from"./useUIStore-CYex4rbF.js";import{o as Bt}from"./useMobileHtmlPreviewStore-DUquFMmd.js";import{n as Vt,r as Ht}from"./terminalApi-eR_918UZ.js";import{a as Ut}from"./types-CsZ29VjS.js";import{t as Wt}from"./bootstrap-eLlfzqAI.js";/* empty css */import{U as Gt}from"./vendor-codemirror-autocomplete-C0FrlFqZ.js";import{a as Kt}from"./vendor-pierre-diffs-HJfPTtu2.js";import{a as qt,i as Jt,n as Yt,r as Xt,t as Zt}from"./i18n-OsFhnlRH.js";import{n as Qt}from"./store-Dj5cSf8B.js";import{S as $t,b as en,h as tn}from"./MobileDetailNavigation-D9OZvTH7.js";import{$a as nn,A as rn,Bn as an,C as on,Ci as J,Er as sn,F as cn,Fa as ln,Ft as un,Ga as dn,Gr as fn,H as pn,Ha as mn,Hn as hn,I as gn,In as Y,Ir as _n,Kt as vn,Lr as yn,Mr as bn,Oi as xn,Or as Sn,Pr as Cn,R as wn,Rn as X,S as Tn,Si as En,Sn as Dn,Tr as On,U as kn,Un as An,Vn as jn,W as Mn,Wa as Nn,Wi as Pn,Wn as Fn,Yi as In,Zi as Ln,Zr as Rn,at as zn,b as Bn,bt as Vn,ct as Hn,da as Un,di as Wn,eo as Gn,er as Kn,et as qn,ft as Jn,g as Yn,gi as Xn,hi as Zn,hr as Qn,in as $n,j as er,kr as tr,m as nr,mi as rr,mr as ir,mt as ar,oi as or,ot as sr,p as cr,pi as lr,pt as ur,qr as dr,qt as fr,ra as pr,st as mr,to as hr,tt as gr,ut as _r,vi as vr,vt as yr,wr as br,x as xr,xi as Sr,y as Cr,yi as wr,yt as Tr,zn as Er}from"./useMobileNavigationStore-CXvADUF9.js";import{n as Dr}from"./useAssistantUIStore-CphyXHEY.js";import{n as Or}from"./input-store-DRTu4uZc.js";import{d as kr,h as Ar,m as jr,p as Mr}from"./remoteProjectQueries-8giIAvzL.js";import{a as Nr,c as Pr,i as Fr,l as Ir,o as Lr,s as Rr}from"./toolHelpers-iEHVHQ9p.js";import{n as zr}from"./useThemeSystem-D2YBbLma.js";import{n as Br,o as Vr}from"./vendor-framer-motion-DiGWHm7K.js";import{n as Z,t as Hr}from"./Icon-DNZA_riL.js";import{a as Ur,i as Wr,n as Gr,o as Kr,r as qr,t as Jr}from"./dialog-DcdiMxIb.js";import{b as Yr,h as Xr,m as Zr}from"./gitApi-B74KW8UU.js";import{$ as Qr,A as $r,At as ei,Bt as ti,Ct as ni,Dt as ri,Et as ii,F as ai,Ft as oi,Gt as si,Ht as ci,I as li,It as ui,J as di,Jt as fi,Kt as pi,L as mi,Lt as hi,M as gi,Mt as _i,N as vi,O as yi,Ot as bi,P as xi,Pt as Si,Q as Ci,Qt as wi,Rt as Ti,S as Ei,St as Di,Tt as Oi,U as ki,Ut as Ai,Vt as ji,Wt as Mi,Y as Ni,Yt as Pi,Zt as Fi,_ as Ii,_t as Li,at as Ri,b as zi,bt as Bi,c as Vi,ct as Hi,d as Ui,f as Wi,g as Gi,gt as Ki,h as qi,i as Ji,it as Yi,j as Xi,jt as Zi,k as Qi,kt as $i,l as ea,lt as ta,m as na,mt as ra,n as ia,nt as aa,ot as oa,p as sa,qt as ca,rt as la,s as ua,st as da,t as fa,tt as pa,u as ma,ut as ha,v as ga,w as _a,wt as va,x as ya,xt as ba,y as xa,z as Sa,zt as Ca}from"./useAppFontEffects-BPTPdll8.js";import{t as wa}from"./input-BSVjxHBf.js";import{i as Ta,n as Ea,r as Da,t as Oa}from"./tooltip-o8hl4eie.js";import{A as ka,C as Aa,D as ja,F as Ma,G as Na,I as Pa,J as Fa,K as Ia,O as La,Q as Ra,S as za,T as Ba,V as Va,Vt as Ha,W as Ua,Z as Wa,_ as Ga,at as Ka,c as qa,et as Ja,g as Ya,h as Xa,i as Za,it as Qa,jt as $a,m as eo,nt as to,o as no,ot as ro,p as io,q as ao,s as oo,st as so,u as co,v as lo,w as uo}from"./pwa-BGxwZ3sK.js";import{t as fo}from"./YuriLogo-DNvrroBa.js";import{o as po,s as mo}from"./react-DUWkLJW_.js";import{a as ho,r as go}from"./device-C8ZHblkr.js";import{r as _o}from"./themes-BgDJcxRc.js";import{f as vo,g as yo,h as bo,p as xo}from"./scheduledTaskNavigation-Bi7sRiFW.js";import{a as So,n as Co,o as wo}from"./MarkdownRenderer-D2oCSF9S.js";import{T as To,_ as Eo,g as Do,h as Oo,w as ko}from"./insertionBoundaries-Dt_DdXrL.js";import{c as Ao,d as jo,i as Mo,l as No,n as Po,s as Fo,t as Io}from"./select-DikdnuBx.js";import{a as Lo,i as Ro}from"./mobileBackNavigation-CbHUVgUi.js";import{n as zo,t as Bo}from"./useEffectiveDirectory-DP_Vb2yB.js";import{t as Vo}from"./ImageLoadingPlaceholder-xLFiotWm.js";import{t as Ho}from"./LoadingImage-B1Q7emSX.js";import{_ as Uo,i as Wo,l as Go,n as Ko,s as qo,t as Jo,v as Yo}from"./vendor-dnd-kit-core-DRyd7I0I.js";import{a as Xo,n as Zo,s as Qo,t as $o}from"./vendor-dnd-kit-sortable-C8S8cyRO.js";import{n as es,r as ts}from"./textarea-CjzOsOcb.js";import{i as ns,n as rs,r as is,t as as}from"./dropdown-menu.styles-BDla58Rm.js";import{f as os,l as ss,p as cs,s as ls}from"./projectMeta-548A_zjC.js";import{p as us}from"./ToolOutputDialog-C03nGQvh.js";import{a as ds,i as fs}from"./sessionLookup-DIImfb9J.js";import{t as ps}from"./vendor-motion-DtmZZeEm.js";import{n as ms,t as hs}from"./useProjectRuntimeAPIs-C47fBxo8.js";import{t as gs}from"./sortable-tabs-strip-2Mhh65oR.js";import{A as _s,C as vs,F as ys,G as bs,J as xs,K as Ss,M as Cs,N as ws,Q as Ts,S as Es,T as Ds,U as Os,X as ks,Y as As,_ as js,b as Ms,c as Ns,d as Ps,et as Fs,f as Is,h as Ls,j as Rs,k as zs,l as Bs,m as Vs,o as Hs,p as Us,q as Ws,u as Gs,v as Ks,w as qs,x as Js,y as Ys}from"./MobileSurface-DFRJ7nyL.js";import{i as Xs,n as Zs,r as Qs,t as $s}from"./useDesktopWindowControlsLayout-ug8tD9Vh.js";import{n as ec,t as tc}from"./openRemoteProjectSession-BHawZ5DM.js";import{n as nc}from"./useFontPreferences-DFF-uEAD.js";import{$ as rc,A as ic,At as ac,B as oc,Bt as sc,C as cc,D as lc,Et as uc,G as dc,Gt as fc,H as pc,Ht as mc,I as hc,It as gc,J as _c,Jt as vc,K as yc,Kt as bc,L as xc,Lt as Sc,M as Cc,Mt as wc,N as Tc,Nt as Ec,O as Dc,Ot as Oc,P as kc,Pt as Ac,Q as jc,R as Mc,Rt as Nc,S as Pc,Tt as Fc,U as Ic,Ut as Lc,V as Rc,Vt as zc,W as Bc,Wt as Vc,X as Hc,Xt as Uc,Y as Wc,Yt as Gc,Z as Kc,Zt as qc,_ as Jc,_t as Yc,a as Xc,b as Zc,bt as Qc,d as $c,et as el,g as tl,gt as nl,h as rl,ht as il,i as al,j as ol,jt as sl,k as cl,kt as ll,m as ul,n as dl,nt as fl,p as pl,q as ml,qt as hl,r as gl,rt as _l,tt as vl,v as yl,vt as bl,wt as xl,x as Sl,y as Cl,yt as wl,z as Tl,zt as El}from"./runtimeEndpointReset-SUR75n8I.js";import{t as Dl}from"./YuriWordmark-bJX68f2Y.js";import{a as Ol}from"./readiness-DpD_wUMJ.js";import{n as kl,t as Al}from"./relay-preview-frame-src-BPyz3nXA.js";import{t as jl}from"./AssistantUnreadBadge-D2d4OBjo.js";import{a as Ml,i as Nl,n as Pl,r as Fl,t as Il}from"./context-menu-Ba6Opvzx.js";import{n as Ll,r as Rl,t as zl}from"./collapsible-CYFRNuOh.js";import{r as Bl,t as Vl}from"./navigation-Bart975B.js";import{n as Hl,t as Ul}from"./GuiPluginPage-XEOZ2YIE.js";import{d as Wl,i as Gl,n as Kl,r as ql,u as Jl}from"./historyImportQueries-eR7Bj6VN.js";import{t as Yl}from"./diagram-D0rZqQqX.js";import{a as Xl,i as Zl,n as Ql,o as $l,r as eu,t as tu}from"./multirun-BtlXFSSx.js";import{a as nu,i as ru,n as iu,r as au,t as ou}from"./projectActions-50e_f9dI.js";import{t as su}from"./vendor-zumer-snapdom-yq9vlCKr.js";import{n as cu,t as lu}from"./vendor-html-to-image-BDMm2v6d.js";var Q=e(De(),1),uu=dt(),du=ut(),$=Ee();function fu(e){let t=(0,du.c)(14),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({size:i,className:n,style:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=typeof i==`number`?`${i}px`:i,s=typeof i==`number`?`${i}px`:i,c;t[5]!==a||t[6]!==o||t[7]!==s?(c={width:o,height:s,...a},t[5]=a,t[6]=o,t[7]=s,t[8]=c):c=t[8];let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`path`,{d:`M112,148a12,12,0,0,0-12,12v19L69.17,148.2A4,4,0,0,1,68,145.37V97.94a36,36,0,1,0-24,0v47.43a27.81,27.81,0,0,0,8.2,19.8L83,196H64a12,12,0,0,0,0,24h48a12,12,0,0,0,12-12V160A12,12,0,0,0,112,148ZM56,52A12,12,0,1,1,44,64,12,12,0,0,1,56,52ZM212,158.06V110.63a27.81,27.81,0,0,0-8.2-19.8L173,60h19a12,12,0,0,0,0-24H144a12,12,0,0,0-12,12V96a12,12,0,0,0,24,0V77l30.83,30.83a4,4,0,0,1,1.17,2.83v47.43a36,36,0,1,0,24,0ZM200,204a12,12,0,1,1,12-12A12,12,0,0,1,200,204Z`}),t[9]=l):l=t[9];let u;return t[10]!==n||t[11]!==r||t[12]!==c?(u=(0,$.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 256 256`,fill:`currentColor`,className:n,style:c,...r,children:l}),t[10]=n,t[11]=r,t[12]=c,t[13]=u):u=t[13],u}var pu=!1,mu=0,hu=new Set,gu=async()=>{let e=++mu;try{let t=await P(`desktop_is_window_fullscreen`);if(e!==mu||t===pu)return;pu=t===!0,hu.forEach(e=>e())}catch{}},_u=e=>v()?(hu.add(e),hu.size===1&&(window.addEventListener(`yuri:window-resized`,gu),gu()),()=>{hu.delete(e),hu.size===0&&(window.removeEventListener(`yuri:window-resized`,gu),mu++,pu=!1)}):()=>{};function vu(){return(0,Q.useSyncExternalStore)(_u,bu,yu)}function yu(){return!1}function bu(){return pu}function xu(){let e=(0,du.c)(19),{t}=Zt(),n=q(Eu),r=q(Tu),i=q(wu),a=q(Cu),o=q(Su),s=n&&r||i,c;e[0]!==n||e[1]!==r||e[2]!==i||e[3]!==a||e[4]!==o?(c=()=>{if(!r){n||a(!0),o(!i);return}a(!n)},e[0]=n,e[1]=r,e[2]=i,e[3]=a,e[4]=o,e[5]=c):c=e[5];let l=K(c),u;e[6]===t?u=e[7]:(u=t(`header.workStatusPanel.toggleAria`),e[6]=t,e[7]=u);let d;e[8]===t?d=e[9]:(d=t(`header.workStatusPanel.toggleAria`),e[8]=t,e[9]=d);let f=s?`text-foreground`:`text-muted-foreground/50`,p;e[10]===f?p=e[11]:(p=X(`app-region-no-drag size-7`,f),e[10]=f,e[11]=p);let m;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(Z,{name:`settings-2`,className:`size-4`}),e[12]=m):m=e[12];let h;return e[13]!==s||e[14]!==u||e[15]!==d||e[16]!==p||e[17]!==l?(h=(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,"data-work-status-toggle":`true`,"aria-pressed":s,"aria-label":u,title:d,onClick:l,className:p,children:m}),e[13]=s,e[14]=u,e[15]=d,e[16]=p,e[17]=l,e[18]=h):h=e[18],h}function Su(e){return e.setWorkStatusOverlayOpen}function Cu(e){return e.setWorkStatusPanelEnabled}function wu(e){return e.workStatusOverlayOpen}function Tu(e){return e.workStatusPanelFits}function Eu(e){return e.workStatusPanelEnabled}var Du=(e,t,n)=>ht({queryKey:[`desktop-host-inventory`,e],queryFn:async({signal:e})=>{let r=await U(),i=new Set(r.sshHostIds??[]);if(r.sshHostIds===void 0&&z()){let e=await $a();for(let t of e.instances)i.add(t.id)}return e.throwIfAborted(),{hosts:r.hosts.filter(e=>se(e,i)||t===`host:${e.id}`||!!(n&&H(n,oe(e)))),sshIds:i}}});function Ou(e){let t=(0,du.c)(18),{onClick:n,open:r}=e,{t:i}=Zt(),a=Q.useSyncExternalStore(s,l,l),o=q(ku),c=f(),u=m(),d=S(),{data:p}=gt({...Du(a,c,u),enabled:!o}),h=c.startsWith(`host:`)?c.slice(5):null,g=p?.hosts.find(e=>h?e.id===h:!!(u&&H(u,oe(e))));if(d&&!p?.hosts.length&&!p?.sshIds.size)return null;let _=g?ce(g.label):i(d?`desktopHostSwitcher.instance.local`:`desktopHostSwitcher.title`),v=fi({isLocal:d,isSsh:!!(g&&p?.sshIds.has(g.id)),isRelay:a.startsWith(`relay:`)}),y=Oa,b=Ta,x=Y,C=i(`header.actions.sessionMenu.servicesWithInstance`,{current:_}),w;t[0]===v?w=t[1]:(w=(0,$.jsx)(`span`,{className:`inline-flex h-full w-7 items-center justify-center`,children:(0,$.jsx)(Z,{name:v,className:`size-5`})}),t[0]=v,t[1]=w);let T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(`span`,{className:`inline-flex h-full w-3 items-center justify-center`,children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`size-2.5`})}),t[2]=T):T=t[2];let E;t[3]!==x||t[4]!==n||t[5]!==r||t[6]!==C||t[7]!==w?(E=(0,$.jsxs)(x,{variant:`ghost`,size:`sm`,className:`app-region-no-drag h-7 w-12 gap-0 self-center rounded-md border border-border/40 px-1 py-0 text-muted-foreground hover:text-foreground`,"aria-label":C,"aria-expanded":r,"aria-haspopup":`menu`,onClick:n,children:[w,T]}),t[3]=x,t[4]=n,t[5]=r,t[6]=C,t[7]=w,t[8]=E):E=t[8];let D;t[9]!==b||t[10]!==E?(D=(0,$.jsx)(b,{asChild:!0,children:E}),t[9]=b,t[10]=E,t[11]=D):D=t[11];let O;t[12]===_?O=t[13]:(O=(0,$.jsx)(Ea,{children:_}),t[12]=_,t[13]=O);let k;return t[14]!==y||t[15]!==O||t[16]!==D?(k=(0,$.jsxs)(y,{children:[D,O]}),t[14]=y,t[15]=O,t[16]=D,t[17]=k):k=t[17],k}function ku(e){return e.isSettingsDialogOpen}var Au=[{id:`finder`,label:`Finder`,appName:`Finder`},{id:`terminal`,label:`Terminal`,appName:`Terminal`},{id:`iterm2`,label:`iTerm2`,appName:`iTerm`},{id:`ghostty`,label:`Ghostty`,appName:`Ghostty`},{id:`vscode`,label:`VS Code`,appName:`Visual Studio Code`},{id:`vscode-insiders`,label:`VS Code Insiders`,appName:`Visual Studio Code - Insiders`},{id:`intellij`,label:`IntelliJ`,appName:`IntelliJ IDEA`},{id:`visual-studio`,label:`Visual Studio`,appName:`Visual Studio`},{id:`cursor`,label:`Cursor`,appName:`Cursor`},{id:`android-studio`,label:`Android Studio`,appName:`Android Studio`},{id:`pycharm`,label:`PyCharm`,appName:`PyCharm`},{id:`xcode`,label:`Xcode`,appName:`Xcode`},{id:`sublime-text`,label:`Sublime`,appName:`Sublime Text`},{id:`webstorm`,label:`WebStorm`,appName:`WebStorm`},{id:`rider`,label:`Rider`,appName:`Rider`},{id:`zed`,label:`Zed`,appName:`Zed`},{id:`wu`,label:`Wu`,appName:`Wu`},{id:`phpstorm`,label:`PhpStorm`,appName:`PhpStorm`},{id:`eclipse`,label:`Eclipse`,appName:`Eclipse`},{id:`windsurf`,label:`Windsurf`,appName:`Windsurf`},{id:`vscodium`,label:`VSCodium`,appName:`VSCodium`},{id:`rustrover`,label:`RustRover`,appName:`RustRover`},{id:`kiro`,label:`Kiro`,appName:`Kiro`},{id:`antigravity`,label:`Antigravity`,appName:`Antigravity`},{id:`trae`,label:`Trae`,appName:`Trae`}],ju=`finder`,Mu=new Set([`finder`,`terminal`]),Nu=e=>typeof window<`u`&&window.__YURI_PLATFORM__===`win32`&&e.id===`finder`?{...e,label:`Explorer`,appName:`File Explorer`}:e,Pu=e=>{if(!e)return null;let t=Au.find(t=>t.id===e)??null;return t?Nu(t):null},Fu=()=>Au.filter(e=>Mu.has(e.id)).map(e=>({...Nu(e)})),Iu=()=>{if(typeof window>`u`)return ju;let e=window.localStorage.getItem(`openInAppId`);return e&&Pu(e)?e:ju},Lu=!1,Ru=!1,zu=!1,Bu=0,Vu=null,Hu=()=>{Vu&&=(clearTimeout(Vu),null)},Uu=W()((e,t)=>({selectedAppId:Iu(),availableApps:Fu(),hasLoadedApps:!1,isCacheStale:!1,isScanning:!1,initialize:()=>{if(Lu||typeof window>`u`)return;Lu=!0;let n=(t,n=!0)=>{if(!Array.isArray(t)||t.length===0){e({availableApps:Fu(),hasLoadedApps:n});return}let r=new Set(t.map(e=>e.name)),i=new Map(t.map(e=>[e.name,e.iconDataUrl??void 0]));e({availableApps:Au.filter(e=>r.has(e.appName)||Mu.has(e.id)).map(e=>({...Nu(e),iconDataUrl:i.get(e.appName)})),hasLoadedApps:!0})},r=async i=>{if(!v()||Ru||t().hasLoadedApps&&!i)return;let a=Au.map(e=>e.appName);Hu(),i&&e({hasLoadedApps:!1}),Ru=!0,zu=!1,e({isScanning:!0});try{let{apps:t,success:o,hasCache:s,isCacheStale:c}=await ne(a,i),l=o&&!s&&t.length===0&&Bu<3;if(e({isCacheStale:s?c:!1}),n(t,o?!l:!1),o){if(l){let e=[800,1600,3200][Bu]??3200;Bu+=1,zu=!0,Vu=setTimeout(()=>{r()},e);return}Bu=0,zu=!1;return}if(Bu<3){let e=[1e3,3e3,7e3][Bu]??7e3;Bu+=1,zu=!0,Vu=setTimeout(()=>{r()},e)}}finally{Ru=!1,zu||e({isScanning:!1})}};r(),window.addEventListener(`yuri:settings-synced`,t=>{let n=t.detail,r=n&&typeof n.openInAppId==`string`&&n.openInAppId.length>0&&Pu(n.openInAppId)?n.openInAppId:null;r&&(window.localStorage.setItem(`openInAppId`,r),e({selectedAppId:r}))}),window.addEventListener(`yuri:app-ready`,()=>{r()}),window.addEventListener(`yuri:installed-apps-updated`,t=>{let r=t.detail;Array.isArray(r)&&(Bu=3,zu=!1,e({isScanning:!1,isCacheStale:!1}),n(r))}),window.__yuriAppReady&&r(),window.setTimeout(()=>{t().hasLoadedApps||r()},5e3)},loadInstalledApps:async n=>{if(Lu||t().initialize(),!v()||Ru||t().hasLoadedApps&&!n)return;let r=Au.map(e=>e.appName);Hu(),n&&e({hasLoadedApps:!1}),Ru=!0,zu=!1,e({isScanning:!0});try{let{apps:t,hasCache:i,isCacheStale:a}=await ne(r,n),o=new Set(t.map(e=>e.name)),s=new Map(t.map(e=>[e.name,e.iconDataUrl??void 0])),c=Au.filter(e=>o.has(e.appName)||Mu.has(e.id)).map(e=>({...e,iconDataUrl:s.get(e.appName)}));e({availableApps:c.length>0?c:Fu(),hasLoadedApps:c.length>0,isCacheStale:i?a:!1})}finally{Ru=!1,zu||e({isScanning:!1})}},selectApp:async t=>{Pu(t)&&(e({selectedAppId:t}),typeof window<`u`&&window.localStorage.setItem(`openInAppId`,t),await je({openInAppId:t}))}})),Wu=(e=f(),t=l())=>{let n=e.startsWith(`host:`)?e.slice(5):null;return{queryKey:[t,`ssh-editor-apps`,n],enabled:v()&&_()&&n!==null,queryFn:async({signal:e})=>{let t=await P(`desktop_ssh_editor_apps`,{hostId:n});return e.throwIfAborted(),t?{hostId:n,appIds:t.appIds}:null}}},Gu=()=>{let e=(0,du.c)(3),t=(0,Q.useSyncExternalStore)(s,f,Ku),n=(0,Q.useSyncExternalStore)(s,l,qu),r;return e[0]!==t||e[1]!==n?(r=Wu(t,n),e[0]=t,e[1]=n,e[2]=r):r=e[2],gt(r)};function Ku(){return``}function qu(){return``}var Ju=`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`,Yu=`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`,Xu=e=>({...e,fallbackIconDataUrl:e.id===`finder`&&window.__YURI_PLATFORM__!==`win32`?Ju:e.id===`terminal`?Yu:void 0}),Zu=e=>{let t=(0,du.c)(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=e,[a,o]=Q.useState(!1),s;t[0]===n?s=t[1]:(s=n.trim().slice(0,1).toUpperCase()||`?`,t[0]=n,t[1]=s);let c=s,l=r||i;if(l&&!a){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>o(!0),t[2]=e):e=t[2];let n;return t[3]===l?n=t[4]:(n=(0,$.jsx)(`img`,{src:l,alt:``,className:`h-4 w-4 rounded-sm`,onError:e}),t[3]=l,t[4]=n),n}let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=X(`h-4 w-4 rounded-sm flex items-center justify-center`,`bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground`),t[5]=u):u=t[5];let d;return t[6]===c?d=t[7]:(d=(0,$.jsx)(`span`,{className:u,children:c}),t[6]=c,t[7]=d),d},Qu=({directory:e,className:t})=>{let{t:n}=Zt(),r=Uu(e=>e.selectedAppId),i=Uu(e=>e.availableApps),a=Uu(e=>e.isCacheStale),o=Uu(e=>e.isScanning),s=Uu(e=>e.initialize),c=Uu(e=>e.loadInstalledApps),l=Uu(e=>e.selectApp),{data:u}=Gu(),d=Q.useMemo(()=>u?i.filter(e=>u.appIds.includes(e.id)):i,[i,u]);Q.useEffect(()=>{s()},[s]);let f=v()&&S(),p=Q.useMemo(()=>{let e=d.find(e=>e.id===r)??d.find(e=>e.id===`finder`)??d[0];return e?Xu(e):null},[d,r]);if(!f&&!u||!e)return null;let m=async t=>{try{let r=await y(e,t.id,t.appName,u?.hostId);!r&&!u?await E(e,t.appName):r||J.error(n(`filesView.toast.openInAppFailed`,{app:t.label}))}catch(e){J.error(n(String(e).includes(`SSH_EDITOR_CONFIG_REQUIRED`)?`openInApp.errors.sshConfigRequired`:`filesView.toast.openInAppFailed`,{app:t.label}))}},h=async e=>{await l(e.id),await m(e)},g=async()=>{await Pn(e)};return(0,$.jsxs)(`div`,{className:X(`app-region-no-drag inline-flex h-7 w-12 items-center self-center overflow-hidden rounded-md border border-border/40 px-1`,`hover:bg-interactive-hover transition-colors`,t),children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void(p?m(p):g()),className:X(`inline-flex h-full w-7 items-center justify-center typography-ui-label font-medium`,`text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`,o&&`animate-pulse`),"aria-label":p?n(`openInApp.actions.openInAria`,{app:p.label}):n(`openInApp.actions.copyPath`),children:p?(0,$.jsx)(Zu,{label:p.label,iconDataUrl:p.iconDataUrl,fallbackIconDataUrl:p.fallbackIconDataUrl}):(0,$.jsx)(Z,{name:`file-copy`,className:`h-4 w-4`})}),(0,$.jsxs)(Na,{children:[(0,$.jsx)(Ra,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:X(`inline-flex h-full w-3 items-center justify-center text-muted-foreground`,`hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`),"aria-label":n(`openInApp.actions.chooseAppAria`),children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`size-2.5`})})}),(0,$.jsxs)(Ia,{align:`end`,className:`w-56 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:()=>void g(),children:[(0,$.jsx)(Z,{name:`file-copy`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n(`openInApp.actions.copyPath`)})]}),(0,$.jsx)(Wa,{}),d.map(e=>{let t=Xu(e);return(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:()=>void h(e),children:[(0,$.jsx)(Zu,{label:e.label,iconDataUrl:e.iconDataUrl,fallbackIconDataUrl:t.fallbackIconDataUrl}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e.label}),p?.id===e.id?(0,$.jsx)(Z,{name:`check`,className:`ml-auto h-4 w-4 text-primary`}):null]},e.id)}),a?(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:()=>void c(!0),children:[(0,$.jsx)(Z,{name:`refresh`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n(`openInApp.actions.refreshApps`)})]}):null]})]})]})},$u=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],ed=[`dev`,`start`,`preview`,`serve`];async function td(e,t,n,r){if(!e)return null;let i=id(t);if(i)return{command:i.command,label:i.name||`Start Preview`,actionId:i.id};if(n){let t=ad(n);if(t){let n=await od(e,r);return{command:`${n===`npm`?`npm run`:n===`yarn`?`yarn`:n===`pnpm`?`pnpm`:n===`bun`?`bun run --shell=bun`:`npm run`} ${t}`,label:`Start (${t})`}}}if(await nd(e,r)){let e=await rd(r),t=typeof e==`number`&&Number.isFinite(e)&&e>0?e:8e3;return{command:`python3 -m http.server ${t}`,label:`Static preview`,previewUrlHint:`http://127.0.0.1:${t}/`}}return null}async function nd(e,t){let n=await sd(`${e}/index.html`,e,t);return typeof n==`string`&&n.trim().length>0}async function rd(e){if(e){let t=await kt(e).json(`/api/system/free-port`,{cache:`no-store`});if(!Number.isInteger(t.port)||t.port<1||t.port>65535)throw Error(`Invalid Host preview port`);return t.port}try{let e=await h(`/api/system/free-port`,{cache:`no-store`});if(!e.ok)return null;let t=await e.json().catch(()=>null),n=typeof t?.port==`number`?t.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function id(e){for(let t of e){let e=`${t.name} ${t.command}`.toLowerCase();if(ed.some(t=>e.includes(t)))return t}return null}function ad(e){for(let{pattern:t}of $u)for(let n of Object.keys(e))if(t.test(n))return n;return null}async function od(e,t){let n=await sd(`${e}/package.json`,e,t);if(n)try{let e=JSON.parse(n),t=typeof e.packageManager==`string`?e.packageManager.toLowerCase():``;if(t.startsWith(`bun@`))return`bun`;if(t.startsWith(`pnpm@`))return`pnpm`;if(t.startsWith(`yarn@`))return`yarn`;if(t.startsWith(`npm@`))return`npm`}catch{}for(let[n,r]of[[`bun.lock`,`bun`],[`bun.lockb`,`bun`],[`pnpm-lock.yaml`,`pnpm`],[`yarn.lock`,`yarn`],[`package-lock.json`,`npm`]]){let i=await sd(`${e}/${n}`,e,t);if(typeof i==`string`&&i.trim().length>0)return r}return`npm`}async function sd(e,t,n){if(n){let r=kt(n),i=await r.fetch(`/api/fs/read`,{query:{path:e,directory:t,optional:`true`},cache:`no-store`});if(i.status===404)return null;if(!i.ok)throw Error(`Failed to read Host preview file (${i.status})`);let a=await i.text();return r.assertCurrent(),i.headers.get(`x-yuri-file-exists`)===`false`?null:a}if(t?.trim())try{let n=new URLSearchParams({path:e,directory:t,optional:`true`}),r=await h(`/api/fs/read?${n.toString()}`,{cache:`no-store`});if(r.ok)return r.text()}catch{}let r=ae()?.files;if(r?.readFile)try{let t=await r.readFile(e,{optional:!0});return typeof t?.content==`string`?t.content:null}catch{return null}try{let t=await h(`/api/fs/read?path=${encodeURIComponent(e)}&optional=true`,{cache:`no-store`});return t.ok?t.text():null}catch{return null}}async function cd(e,t){try{let n=await sd(`${e}/package.json`,e,t);if(n==null)return null;let r=JSON.parse(n).scripts;return r&&typeof r==`object`&&!Array.isArray(r)?r:null}catch(e){if(t)throw e;return null}}var ld=e=>new Promise(t=>{window.setTimeout(t,e)}),ud=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),dd=/https?:\/\/[^\s<>'"`]+/gi,fd=`__yuri_auto_discover_preview__`,pd=15e3,md=e=>{let t=``;for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);r>=0&&r<=8||r===11||r===12||r>=14&&r<=31||r===127||(t+=e[n])}return t},hd=e=>{let t=(e||``).trim();if(!t)return null;let n=/^https?:\/\//i.test(t)?t:`http://${t}`;try{let e=new URL(n);return e.protocol!==`http:`&&e.protocol!==`https:`?null:e.toString()}catch{return null}},gd=e=>{let t=e.replace(ud,``).match(dd);if(!t||t.length===0)return null;let n=t.map(e=>e.replace(/[),.;]+$/,``)).filter(Boolean);if(n.length===0)return null;let r=[];for(let e of n)try{let t=new URL(e);t.port&&t.port.length>0&&r.push({raw:e,parsed:t})}catch{}if(r.length>0){let e=e=>{let{parsed:t}=e,n=t.hostname.toLowerCase(),r=n===`localhost`||n===`127.0.0.1`||n===`0.0.0.0`||n===`::1`,i=t.pathname||`/`,a=i.split(`/`).filter(Boolean).length,o=i===`/`||i===``,s=!!(t.search||t.hash),c=0;return r&&(c+=50),o&&(c+=30),c-=Math.min(a*5,20),s&&(c-=10),c};return r.sort((t,n)=>e(n)-e(t)),r[0]?.parsed.origin??r[0]?.raw??null}return n[0]??null},_d=e=>{let t=(0,du.c)(19),n=!!e.projectRef?.hostId,{registry:r}=jr(n&&!e.scope),i=e.projectRef?.hostId,a;t[0]!==i||t[1]!==r?(a={subscribe:e=>r&&i?r.subscribeHost(i,e):yd,snapshot:()=>r&&i?r.getHost(i):void 0},t[0]=i,t[1]=r,t[2]=a):a=t[2];let o=a;Q.useSyncExternalStore(o.subscribe,o.snapshot,o.snapshot);let s=e.directory||e.projectRef?.path||``,c;t[3]!==s||t[4]!==e.projectRef||t[5]!==e.scope||t[6]!==r||t[7]!==n?(c=e.scope?r?.hubId===e.scope.location.hubId?r.resolve(e.scope.location):e.scope:n&&r&&r.hubId===e.projectRef?.hubId?r.resolve({hubId:r.hubId,hostId:e.projectRef.hostId,directory:s}):void 0,t[3]=s,t[4]=e.projectRef,t[5]=e.scope,t[6]=r,t[7]=n,t[8]=c):c=t[8];let l=c,u;t[9]!==s||t[10]!==l||t[11]!==e.projectRef?.hostId||t[12]!==e.projectRef?.hubId||t[13]!==n?(u=l?`${l.key}:${l.connectionGeneration}`:n?JSON.stringify([e.projectRef?.hubId,e.projectRef?.hostId,s]):s,t[9]=s,t[10]=l,t[11]=e.projectRef?.hostId,t[12]=e.projectRef?.hubId,t[13]=n,t[14]=u):u=t[14];let d=u,f;return t[15]!==l||t[16]!==d||t[17]!==e?(f=(0,$.jsx)(vd,{...e,scope:l},d),t[15]=l,t[16]=d,t[17]=e,t[18]=f):f=t[18],f},vd=({projectRef:e,directory:t,className:n,compact:r=!1,allowMobile:i=!1,scope:a})=>{let{t:o}=Zt(),{terminal:s,runtime:c}=St(),l=Q.useRef(null),u=Q.useRef(!0),d=()=>{if(!u.current)throw new DOMException(`Project action scope superseded`,`AbortError`);if(e?.hostId&&(!a||a.location.hostId!==e.hostId||a.location.hubId!==e.hubId)||a&&a.location.directory!==(t||e?.path||``))throw Error(o(`remoteProjects.host-unavailable`));a&&kt(a).assertCurrent()},f=K(()=>{if(d(),!a)throw Error(o(`remoteProjects.host-unavailable`));return l.current??=Ht(a)}),p=Q.useMemo(()=>a||e?.hostId?{createSession:e=>f().createTerminalSession(e),sendInput:(e,t)=>f().sendTerminalInput(e,t),close:e=>f().closeTerminal(e)}:s,[a,e?.hostId,s,f]),{isMobile:m}=go(),h=Q.useMemo(()=>v(),[]),g=Vs(e=>e.instances),_=Vs(e=>e.load),y=q(e=>e.setBottomTerminalOpen),b=q(e=>e.setActiveMainTab),x=q(e=>e.setSettingsPage),S=q(e=>e.setSettingsDialogOpen),C=q(e=>e.setSettingsProjectsSelectedId),w=q(e=>e.openContextPreview),T=nc(e=>e.sessions),E=nc(e=>e.ensureDirectory),D=nc(e=>e.setTabLabel),O=nc(e=>e.setTabIconKey),k=nc(e=>e.setActiveTab),A=nc(e=>e.setConnecting),j=nc(e=>e.setTabSessionId),M=nc(e=>e.setTabPreviewUrl),N=nc(e=>e.projectActionRuns),P=nc(e=>e.setProjectActionRun),F=nc(e=>e.updateProjectActionRunStatus),L=nc(e=>e.removeProjectActionRun),[R,z]=Q.useState([]),[B,V]=Q.useState(null),[te,ne]=Q.useState(!1),re=Q.useRef({}),ie=Q.useRef({}),ae=Q.useRef({}),oe=Q.useRef({}),H=Q.useRef(0),se=Q.useRef(new Set),U=e?.id??null,ce=e?.path??``,W=Q.useMemo(()=>U?{id:U,path:ce,hostId:e?.hostId,hubId:e?.hubId}:null,[U,ce,e?.hostId,e?.hubId]);Q.useEffect(()=>{u.current=!0;let e=ae.current,t=oe.current;return()=>{u.current=!1,H.current+=1,Object.values(e).forEach(e=>e()),Object.values(t).forEach(e=>window.clearTimeout(e)),l.current?.dispose(),l.current=null}},[a]),Q.useEffect(()=>{!h||a||e?.hostId||_().catch(()=>void 0)},[h,_,a,e?.hostId]);let le=K(async e=>{await Bt(e)}),ue=K(async()=>{if(!W)return;let e=H.current+1;H.current=e,ne(!0);try{d();let t=await yn(W,a);if(H.current!==e)return;let n=t.actions;z(n),V(e=>e===fd||e&&n.some(t=>t.id===e)?e:null)}catch{if(H.current!==e)return}finally{H.current===e&&ne(!1)}}),de=t||W?.path||``,fe=Q.useMemo(()=>a?I(ee({...a.location,directory:de})):W?.hostId?W.hubId?I(ee({hubId:W.hubId,hostId:W.hostId,directory:de})):``:au(de),[de,W,a]),pe=Q.useMemo(()=>B?R.find(e=>e.id===B)??null:null,[R,B]),me=Q.useMemo(()=>({id:fd,name:o(`projectActions.actions.autoDiscover`),command:``,icon:`search`,autoOpenUrl:!0}),[o]),he=!m,ge=Q.useMemo(()=>he?[me,...R]:R,[R,me,he]);Q.useEffect(()=>{ue()},[ue,W,a]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;U&&(t?.projectId&&t.projectId!==U||ue())};return window.addEventListener(ou,e),()=>{window.removeEventListener(ou,e)}},[ue,U]),Q.useEffect(()=>{B&&(B===fd&&he||R.some(e=>e.id===B)||V(null))},[R,he,B]),Q.useEffect(()=>{for(let[e,t]of Object.entries(N)){if(t.directory!==fe)continue;let n=T.get(t.directory)?.tabs.find(e=>e.id===t.tabId);(!n||n.terminalSessionId!==t.sessionId)&&L(e)}},[fe,N,L,T]),Q.useEffect(()=>{for(let[e,t]of Object.entries(N)){if(t.directory!==fe)continue;let n=ie.current[e]??{lastSeenChunkId:null,openedUrl:!1,tail:``,openInPreview:!1};ie.current[e]=n;let r=ge.find(e=>e.id===t.actionId);if(!r)continue;let i=T.get(t.directory)?.tabs.find(e=>e.id===t.tabId);if(!i||!Array.isArray(i.bufferChunks)||i.bufferChunks.length===0)continue;let s=i.bufferChunks.filter(e=>n.lastSeenChunkId===null||e.id>n.lastSeenChunkId);if(s.length===0)continue;let c=s.map(e=>e.data).join(``),l=`${n.tail}${c}`,u=!n.openedUrl&&r.autoOpenUrl===!0?gd(l):null;if(n.lastSeenChunkId=s[s.length-1]?.id??n.lastSeenChunkId,n.tail=l.slice(-512),u)if(n.openedUrl=!0,n.openInPreview){let t=N[e];t&&(M(t.directory,t.tabId,u,{locked:!1,autoOpened:!1}),t.status===`waiting-for-preview`&&F(e,`running`),window.clearTimeout(oe.current[e]),delete oe.current[e],w(t.directory,u))}else a||W?.hostId?(M(t.directory,t.tabId,u,{locked:!1,autoOpened:!0}),w(t.directory,u)):(le(u),J.success(o(`projectActions.toast.openedUrlFromOutput`)));ie.current[e]=n}for(let e of Object.keys(ie.current))N[e]||(delete ie.current[e],window.clearTimeout(oe.current[e]),delete oe.current[e])},[fe,a,W?.hostId,ge,w,le,N,M,o,T,F]);let _e=K(async(e,t={})=>{if(!fe)throw Error(o(`projectActions.error.noActiveDirectory`));let n=nu(fe,e.id);E(fe);let r=nc.getState(),i=r.getDirectoryState(fe),a=re.current[n]||null,s=a?!!i?.tabs.some(e=>e.id===a):!1;(!a||!s)&&(a=r.createTab(fe),re.current[n]=a),D(fe,a,`Action: ${e.name}`),O(fe,a,e.icon||`play`),t.revealTerminal!==!1&&(k(fe,a),y(!0),b(`terminal`));let c=nc.getState().getDirectoryState(fe)?.tabs.find(e=>e.id===a);return{key:n,tabId:a,sessionId:c?.terminalSessionId??null}}),ve=K(async e=>{if(c.isVSCode||!i&&m)return;if(!fe){J.error(o(`projectActions.error.noActiveDirectoryForAction`));return}let t=nu(fe,e.id),n=N[t];if(!(n&&n.status===`running`)&&!se.current.has(t)){se.current.add(t);try{d();let t=e.id===fd?await(async()=>{let[e,t]=await Promise.all([yn({...W,id:W?.id??``,path:de},a),cd(de,a)]),n=await td(de,e.actions,t,a);if(!n)throw Error(o(`contextPanel.preview.noDevServer`));return{id:fd,name:o(`projectActions.actions.autoDiscover`),command:n.command,icon:`search`,autoOpenUrl:!0,openUrl:n.previewUrlHint||``}})():e,n=t.autoOpenUrl===!0&&(t.openUrl||``).trim().length>0;d();let{key:r,tabId:i,sessionId:s}=await _e(t,{revealTerminal:!n&&e.id!==fd}),c=s,l=!1;if(!c){A(fe,i,!0);try{let e=await p.createSession({cwd:de});d(),c=e.sessionId,l=!0,j(fe,i,c)}finally{A(fe,i,!1)}}if(!c)throw Error(o(`projectActions.error.failedToCreateTerminalSession`));l&&await ld(350),d(),t.id===fd&&(ae.current[r]?.(),A(fe,i,!0),ae.current[r]=(a?f().connectTerminalStream:Vt)(c,e=>{if(u.current){try{d()}catch{return}e.type===`data`&&typeof e.data==`string`&&e.data.length>0&&nc.getState().appendToBuffer(fe,i,e.data),e.type===`exit`&&(nc.getState().setTabLifecycle(fe,i,`exited`),nc.getState().setConnecting(fe,i,!1),nc.getState().removeProjectActionRun(r),delete ie.current[r],ae.current[r]?.(),delete ae.current[r],window.clearTimeout(oe.current[r]),delete oe.current[r])}},()=>{u.current&&nc.getState().setConnecting(fe,i,!1)},{maxRetries:60,initialRetryDelay:250,maxRetryDelay:2e3,connectionTimeout:5e3}));let m=t.autoOpenUrl===!0&&!a&&h&&(t.desktopOpenSshForward||``).trim().length>0,_=t.autoOpenUrl?hd(t.openUrl):null,v=t.autoOpenUrl&&h&&!a?ru(t.desktopOpenSshForward,g):null;P({key:r,directory:fe,actionId:t.id,tabId:i,sessionId:c,status:t.id===fd&&!_?`waiting-for-preview`:`running`}),window.clearTimeout(oe.current[r]),delete oe.current[r],t.id===fd&&!_&&(oe.current[r]=window.setTimeout(()=>{nc.getState().updateProjectActionRunStatus(r,`running`),delete oe.current[r]},pd)),v?(M(fe,i,null,{locked:!0}),le(v),J.success(o(`projectActions.toast.openedForwardedUrl`))):_?(M(fe,i,_,{locked:!0,autoOpened:!0}),w(fe,_),J.success(o(`projectActions.toast.openedActionUrl`))):n?(M(fe,i,null,{locked:!0}),J.error(o(`projectActions.error.invalidCustomUrlFormat`))):m?(M(fe,i,null,{locked:!0}),J.error(o(`projectActions.error.selectedDesktopSshForwardUnavailable`))):M(fe,i,null,{locked:!1,autoOpened:!1}),ie.current[r]={lastSeenChunkId:null,openedUrl:!!v||!!_||n,tail:``,openInPreview:t.id===fd};let y=md(t.command.trim().replace(/\r\n|\r/g,`
|
|
3
|
+
`));d(),await p.sendInput(c,`${y}\r`)}catch(e){L(t),delete ie.current[t],ae.current[t]?.(),delete ae.current[t],window.clearTimeout(oe.current[t]),delete oe.current[t],J.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`))}finally{se.current.delete(t)}}}),ye=K(async e=>{let t=nu(fe,e.id),n=N[t];if(n){F(t,`stopping`);try{await p.sendInput(n.sessionId,``)}catch(e){if(a||W?.hostId){F(t,`running`),J.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`));return}}if(await new Promise(e=>{window.setTimeout(e,1e3)}),nc.getState().getDirectoryState(n.directory)?.tabs.find(e=>e.id===n.tabId)?.terminalSessionId===n.sessionId)if(a||W?.hostId){try{d(),await p.close(n.sessionId)}catch(e){F(t,`running`),J.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`));return}j(n.directory,n.tabId,null)}else{if(typeof p.forceKill==`function`)try{await p.forceKill({sessionId:n.sessionId})}catch{}else try{await p.close(n.sessionId)}catch{}j(n.directory,n.tabId,null)}L(t),delete ie.current[t],ae.current[t]?.(),delete ae.current[t],window.clearTimeout(oe.current[t]),delete oe.current[t]}}),be=K(()=>{let e=pe??ge[0];if(!e)return;let t=nu(fe,e.id),n=N[t];if(n?.status!==`stopping`){if(n){ye(e);return}ve(e)}}),xe=K((e,t=!1)=>{if(V(e.id),!t){ve(e);return}let n=nu(fe,e.id),r=N[n];if(r?.status!==`stopping`){if(r){ye(e);return}ve(e)}}),Se=K(()=>{if(W?.id){if(a||W.hostId){J.info(o(`remoteProjects.configurationReadOnly`)),x(`remoteInstances`),S(!0);return}C(W.id),x(`projects`),S(!0)}});if(c.isVSCode||!i&&m||!W||!fe)return null;let Ce=pe??ge[0]??null;if(!Ce)return null;let we=Ce.icon||`play`,Te=Ce.id===fd?`search`:iu[we]||`play`,Ee=N[nu(fe,Ce.id)],De=Ee?.status===`stopping`,Oe=Ee?.status===`waiting-for-preview`,ke=Ee?T.get(Ee.directory)?.tabs.find(e=>e.id===Ee.tabId)?.previewUrl??null:null,Ae=!!(Ee&&ke),je=()=>{!Ee||!ke||w(Ee.directory,ke)};return r?(0,$.jsxs)(`div`,{className:`inline-flex items-center`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:te||De,className:X(`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:be,"aria-label":o(Ee?`projectActions.actions.stopNamedAria`:`projectActions.actions.runNamedAria`,{name:Ce.name}),children:De||Oe?(0,$.jsx)(Z,{name:`loader-4`,className:`h-5 w-5 animate-spin text-[var(--status-warning)]`}):Ee?(0,$.jsx)(Z,{name:`stop`,className:`h-5 w-5 text-[var(--status-warning)]`}):(0,$.jsx)(Z,{name:Te,className:`h-5 w-5`})}),Ae?(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.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:je,children:(0,$.jsx)(Z,{name:`global`,className:`h-4 w-4`})})}),(0,$.jsx)(Ea,{sideOffset:6,children:o(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(Na,{children:[(0,$.jsx)(Ra,{asChild:!0,children:(0,$.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:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-3.5 w-3.5`})})}),(0,$.jsxs)(Ia,{align:`end`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:Se,children:[(0,$.jsx)(Z,{name:`add`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`projectActions.actions.addNewAction`)})]}),(0,$.jsx)(Wa,{}),ge.map(e=>{let t=e.icon||`play`,n=e.id===fd?`search`:iu[t]||`play`,r=nu(fe,e.id),i=N[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:()=>{xe(e,!0)},children:[(0,$.jsx)(Z,{name:n,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:e.name}),o||i?.status===`waiting-for-preview`?(0,$.jsx)(Z,{name:`loader-4`,className:`ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]`}):a?(0,$.jsx)(Z,{name:`stop`,className:`ml-auto h-4 w-4 text-[var(--status-warning)]`}):null]},e.id)})]})]})]}):(0,$.jsxs)(`div`,{className:X(`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:[(0,$.jsx)(`button`,{type:`button`,onClick:be,disabled:te||De,className:X(`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":o(Ee?`projectActions.actions.stopNamedAria`:`projectActions.actions.runNamedAria`,{name:Ce.name}),children:(0,$.jsx)(`span`,{className:`inline-flex h-4 w-4 shrink-0 items-center justify-center`,children:De||Oe?(0,$.jsx)(Z,{name:`loader-4`,className:`h-4 w-4 animate-spin text-[var(--status-warning)]`}):Ee?(0,$.jsx)(Z,{name:`stop`,className:`h-4 w-4 text-[var(--status-warning)]`}):(0,$.jsx)(Z,{name:Te,className:`h-4 w-4`})})}),Ae?(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:je,className:X(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:(0,$.jsx)(Z,{name:`global`,className:`h-4 w-4`})})}),(0,$.jsx)(Ea,{sideOffset:6,children:o(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(Na,{children:[(0,$.jsx)(Ra,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:X(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:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4`})})}),(0,$.jsxs)(Ia,{align:`start`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:Se,children:[(0,$.jsx)(Z,{name:`add`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`projectActions.actions.addNewAction`)})]}),(0,$.jsx)(Wa,{}),ge.map(e=>{let t=e.icon||`play`,n=e.id===fd?`search`:iu[t]||`play`,r=nu(fe,e.id),i=N[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:()=>{xe(e,!0)},children:[(0,$.jsx)(Z,{name:n,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:e.name}),o||i?.status===`waiting-for-preview`?(0,$.jsx)(Z,{name:`loader-4`,className:`ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]`}):a?(0,$.jsx)(Z,{name:`stop`,className:`ml-auto h-4 w-4 text-[var(--status-warning)]`}):null]},e.id)})]})]})]})};function yd(){}function bd(e){return e.isOpen&&e.activeTab===e.targetTab?{open:!1,tab:e.activeTab}:{open:!0,tab:e.targetTab}}var xd=`app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors`,Sd=`app-region-no-drag inline-flex h-9 w-9 items-center justify-center gap-2 p-2 rounded-md typography-ui-label font-medium text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:text-foreground hover:bg-interactive-hover transition-colors`,Cd=Q.memo(function(e){let t=(0,du.c)(17),{visible:n,title:r,ariaLabel:i,onClick:a,className:o,Icon:s,iconClassName:c,pressed:l}=e,u=n===void 0||n,d=l!==void 0&&l;if(!u)return null;let f=o??xd,p=d&&`bg-interactive-selection text-interactive-selection-foreground`,m;t[0]!==f||t[1]!==p?(m=X(f,p),t[0]=f,t[1]=p,t[2]=m):m=t[2];let h=c??`h-[18px] w-[18px]`,g;t[3]!==s||t[4]!==h?(g=(0,$.jsx)(Z,{name:s,className:h}),t[3]=s,t[4]=h,t[5]=g):g=t[5];let _;t[6]!==i||t[7]!==a||t[8]!==d||t[9]!==m||t[10]!==g?(_=(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:a,"aria-label":i,"aria-pressed":d,className:m,children:g})}),t[6]=i,t[7]=a,t[8]=d,t[9]=m,t[10]=g,t[11]=_):_=t[11];let v;t[12]===r?v=t[13]:(v=(0,$.jsx)(Ea,{children:(0,$.jsx)(`p`,{children:r})}),t[12]=r,t[13]=v);let y;return t[14]!==_||t[15]!==v?(y=(0,$.jsxs)(Oa,{children:[_,v]}),t[14]=_,t[15]=v,t[16]=y):y=t[16],y}),wd=Q.memo(function(e){let t=(0,du.c)(42),{isMobile:n,githubAuthStatus:r,githubAccounts:i,githubAvatarUrl:a,githubLogin:o,isSwitchingGitHubAccount:s,handleGitHubAccountSwitch:c}=e,{t:l}=Zt();if(!r?.connected||n)return null;if(i.length>1){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=X(xd,`h-6 w-6 overflow-hidden rounded-full border border-border/60 bg-muted/80 p-0`),t[0]=e):e=t[0];let n;t[1]!==o||t[2]!==l?(n=o?l(`header.github.connectedWithLogin`,{login:o}):l(`header.github.connected`),t[1]=o,t[2]=l,t[3]=n):n=t[3];let r;t[4]!==a||t[5]!==o||t[6]!==l?(r=a?(0,$.jsx)(`img`,{src:a,alt:o?l(`header.github.avatarWithLogin`,{login:o}):l(`header.github.avatar`),className:`h-full w-full object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(Z,{name:`github-fill`,className:`h-3.5 w-3.5 text-foreground`}),t[4]=a,t[5]=o,t[6]=l,t[7]=r):r=t[7];let u;t[8]!==s||t[9]!==n||t[10]!==r?(u=(0,$.jsx)(Ra,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:e,title:n,disabled:s,children:r})}),t[8]=s,t[9]=n,t[10]=r,t[11]=u):u=t[11];let d;t[12]===l?d=t[13]:(d=l(`header.github.accountsTitle`),t[12]=l,t[13]=d);let f;t[14]===d?f=t[15]:(f=(0,$.jsx)(Fa,{className:`typography-ui-header font-semibold text-foreground`,children:d}),t[14]=d,t[15]=f);let p;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(Wa,{}),t[16]=p):p=t[16];let m;if(t[17]!==i||t[18]!==c||t[19]!==s||t[20]!==l){let e;t[22]!==c||t[23]!==s||t[24]!==l?(e=e=>{let t=e.user,n=!!e.current,r=e.source===`gh-cli`?l(`header.github.accountSource.cli`):l(`header.github.accountSource.oauth`);return(0,$.jsxs)(ao,{className:`gap-2`,disabled:s,onSelect:()=>{n||c(e.id)},children:[t?.avatarUrl?(0,$.jsx)(`img`,{src:t.avatarUrl,alt:t.login?l(`header.github.avatarWithLogin`,{login:t.login}):l(`header.github.avatar`),className:`h-6 w-6 rounded-full border border-border/60 bg-muted object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted`,children:(0,$.jsx)(Z,{name:`github-fill`,className:`h-3 w-3 text-muted-foreground`})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-foreground`,children:t?.name?.trim()||t?.login||`GitHub`}),t?.login?(0,$.jsxs)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:t.login}),(0,$.jsx)(`span`,{className:`mx-1 opacity-50`,children:`·`}),(0,$.jsx)(`span`,{children:r})]}):null]}),n?(0,$.jsx)(Z,{name:`check`,className:`h-4 w-4 text-primary`}):null]},e.id)},t[22]=c,t[23]=s,t[24]=l,t[25]=e):e=t[25],m=i.map(e),t[17]=i,t[18]=c,t[19]=s,t[20]=l,t[21]=m}else m=t[21];let h;t[26]!==f||t[27]!==m?(h=(0,$.jsxs)(Ia,{align:`end`,className:`w-64`,children:[f,p,m]}),t[26]=f,t[27]=m,t[28]=h):h=t[28];let g;return t[29]!==u||t[30]!==h?(g=(0,$.jsxs)(Na,{children:[u,h]}),t[29]=u,t[30]=h,t[31]=g):g=t[31],g}let u;t[32]!==o||t[33]!==l?(u=o?l(`header.github.connectedWithLogin`,{login:o}):l(`header.github.connected`),t[32]=o,t[33]=l,t[34]=u):u=t[34];let d;t[35]!==a||t[36]!==o||t[37]!==l?(d=a?(0,$.jsx)(`img`,{src:a,alt:o?l(`header.github.avatarWithLogin`,{login:o}):l(`header.github.avatar`),className:`h-full w-full object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(Z,{name:`github-fill`,className:`h-3.5 w-3.5 text-foreground`}),t[35]=a,t[36]=o,t[37]=l,t[38]=d):d=t[38];let f;return t[39]!==u||t[40]!==d?(f=(0,$.jsx)(`div`,{className:`app-region-no-drag flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80`,title:u,children:d}),t[39]=u,t[40]=d,t[41]=f):f=t[41],f}),Td=Q.memo(function(e){let t=(0,du.c)(52),{isDesktopApp:n,currentInstanceSupportsUpdate:r,isDesktopServicesOpen:i,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:o,desktopServicesTab:s,setDesktopServicesTab:c,fetchAllQuotas:l,servicesTabItems:u,quotaLastUpdated:d,quotaDisplayMode:f,quotaDisplayTabItems:p,handleDisplayModeChange:m,handleUsageRefresh:h,isQuotaLoading:g,isUsageRefreshSpinning:_,hasRateLimits:v,rateLimitGroups:y,expandedFamilies:b,toggleFamilyExpanded:x,showPredValues:S,timeFormatPreference:C,anchorRef:w}=e,{t:T}=Zt(),E=Q.useRef(!1),D;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>{E.current=e},t[0]=D):D=t[0];let O=K(D),k;t[1]!==s||t[2]!==l||t[3]!==d||t[4]!==o||t[5]!==a?(k=(e,t)=>{if(!e&&(t.reason===`trigger-hover`||t.reason===`focus-out`||E.current)){t.cancel();return}a(e),e&&(o(),s===`usage`&&d===null&&l())},t[1]=s,t[2]=l,t[3]=d,t[4]=o,t[5]=a,t[6]=k):k=t[6];let A;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(Ra,{asChild:!0,openOnHover:!1,children:(0,$.jsx)(`button`,{type:`button`,"aria-hidden":!0,tabIndex:-1,className:`pointer-events-none absolute h-px w-px overflow-hidden opacity-0`})}),t[7]=A):A=t[7];let j;t[8]!==l||t[9]!==d||t[10]!==c?(j=e=>{if(E.current)return;let t=e;c(t),t===`usage`&&d===null&&l()},t[8]=l,t[9]=d,t[10]=c,t[11]=j):j=t[11];let M;t[12]!==s||t[13]!==u||t[14]!==j?(M=(0,$.jsx)(`div`,{className:`sticky top-0 z-20 bg-[var(--surface-elevated)]/60 px-2 pt-1.5 pb-1.5 backdrop-blur-xl backdrop-saturate-150`,children:(0,$.jsx)(`div`,{className:`h-9`,children:(0,$.jsx)(gs,{items:u,activeId:s,onSelect:j,layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,activePillButtonClassName:`h-8`,className:`h-full`})})}),t[12]=s,t[13]=u,t[14]=j,t[15]=M):M=t[15];let N;t[16]!==r||t[17]!==s||t[18]!==O||t[19]!==n||t[20]!==i||t[21]!==a?(N=n&&s===`instance`?(0,$.jsxs)(`div`,{children:[r&&i?(0,$.jsx)(`div`,{className:`border-b border-[var(--interactive-border)] px-4 py-2.5`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground`,children:`Yuri`}),(0,$.jsx)(Os,{})]})}):null,(0,$.jsx)(ca,{embedded:!0,open:i&&s===`instance`,onOpenChange:Fd,onHostSwitched:()=>a(!1),onBusyChange:O})]}):null,t[16]=r,t[17]=s,t[18]=O,t[19]=n,t[20]=i,t[21]=a,t[22]=N):N=t[22];let P;t[23]!==s||t[24]!==i?(P=s===`mcp`?(0,$.jsx)(bc,{active:i&&s===`mcp`}):null,t[23]=s,t[24]=i,t[25]=P):P=t[25];let F;t[26]!==s||t[27]!==b||t[28]!==m||t[29]!==h||t[30]!==v||t[31]!==g||t[32]!==_||t[33]!==f||t[34]!==p||t[35]!==d||t[36]!==y||t[37]!==S||t[38]!==T||t[39]!==C||t[40]!==x?(F=s===`usage`?(0,$.jsxs)(`div`,{className:`overflow-x-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-[var(--interactive-border)] px-4 py-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-header font-semibold text-foreground`,children:T(`header.services.rateLimits`)}),(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Dd(d,C)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`div`,{className:`h-7 w-[10.5rem]`,children:(0,$.jsx)(gs,{items:p,activeId:f,onSelect:e=>void m(e),layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,className:`h-full`})}),(0,$.jsx)(`button`,{type:`button`,className:X(`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors`,`hover:text-foreground hover:bg-interactive-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),onClick:h,disabled:g||_,"aria-label":T(`header.services.refreshRateLimitsAria`),children:(0,$.jsx)(Z,{name:`refresh`,className:X(`h-4 w-4`,_&&`animate-spin`)})})]})]}),v?null:(0,$.jsx)(`div`,{className:`px-4 py-5 text-center`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:T(`header.services.noRateLimits`)})}),(0,$.jsx)(`div`,{className:`space-y-2 px-3 py-2.5`,children:y.map(e=>{let t=b[e.providerId]??[];return(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pb-2`,children:[(0,$.jsx)(No,{providerId:e.providerId,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:e.providerName})]}),e.entries.length===0&&(!e.modelFamilies||e.modelFamilies.length===0)?(0,$.jsx)(`div`,{children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:e.error??T(`header.services.noRateLimitsReported`)})}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[e.entries.map((t,n)=>{let[r,i]=t,a=Ac(e.entries,n),o=f===`remaining`?i.remainingPercent:i.usedPercent,s=i.disablePace?null:Ba(i.usedPercent,i.resetAt,i.windowSeconds,r),c=s?.dailyAllocationPercent==null?null:f===`remaining`?100-uo(s.elapsedRatio):uo(s.elapsedRatio),l=La(i.valueLabel,o),u=ja(i.resetAt,i.resetAfterFormatted??i.resetAtFormatted,C);return(0,$.jsxs)(Q.Fragment,{children:[a?(0,$.jsx)(`div`,{className:X(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,n>0&&`mt-5 border-t border-[var(--surface-subtle)] pt-3`),children:a}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground break-words`,children:ka(i.label??r)}),u?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:u}):null]}),(0,$.jsx)(`span`,{className:`shrink-0 whitespace-nowrap typography-ui-label tabular-nums text-foreground`,children:l===`-`?``:l})]}),(0,$.jsx)(Us,{percent:o,tonePercent:i.usedPercent,className:`h-1.5`,expectedMarkerPercent:c}),s&&S?(0,$.jsx)(Is,{paceInfo:s,compact:!0}):null]})]},`${e.providerId}-${r}`)}),e.modelFamilies&&e.modelFamilies.length>0?(0,$.jsx)(`div`,{className:`space-y-0.5`,children:e.modelFamilies.map(n=>{let r=n.familyId??`other`,i=t.includes(r);return(0,$.jsxs)(zl,{open:i,onOpenChange:()=>x(e.providerId,r),children:[(0,$.jsxs)(Rl,{className:`flex w-full items-center justify-between rounded-md px-1 py-1.5 text-left hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:n.familyLabel}),i?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`})]}),(0,$.jsx)(Ll,{children:(0,$.jsx)(`div`,{className:`space-y-2.5 pb-1 pl-1 pt-1`,children:n.models.map(t=>{let[n,r]=t,i=f===`remaining`?r.remainingPercent:r.usedPercent,a=Ba(r.usedPercent,r.resetAt,r.windowSeconds),o=a?.dailyAllocationPercent==null?null:f===`remaining`?100-uo(a.elapsedRatio):uo(a.elapsedRatio),s=La(r.valueLabel,i);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Cs(n)}),(0,$.jsx)(`span`,{className:`typography-ui-label tabular-nums text-foreground`,children:s===`-`?``:s})]}),(0,$.jsx)(Us,{percent:i,tonePercent:r.usedPercent,className:`h-1.5`,expectedMarkerPercent:o}),a&&S?(0,$.jsx)(Is,{paceInfo:a,compact:!0}):null]},`${e.providerId}-${n}`)})})})]},r)})}):null]})]},e.providerId)})})]}):null,t[26]=s,t[27]=b,t[28]=m,t[29]=h,t[30]=v,t[31]=g,t[32]=_,t[33]=f,t[34]=p,t[35]=d,t[36]=y,t[37]=S,t[38]=T,t[39]=C,t[40]=x,t[41]=F):F=t[41];let I;t[42]!==w||t[43]!==M||t[44]!==N||t[45]!==P||t[46]!==F?(I=(0,$.jsxs)(Ia,{anchor:w,align:`start`,sideOffset:6,collisionPadding:12,className:`w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto bg-[var(--surface-elevated)] p-0 [&_[role=tab]]:capitalize`,children:[M,N,P,F]}),t[42]=w,t[43]=M,t[44]=N,t[45]=P,t[46]=F,t[47]=I):I=t[47];let L;return t[48]!==i||t[49]!==k||t[50]!==I?(L=(0,$.jsxs)(Na,{open:i,onOpenChange:k,children:[A,I]}),t[48]=i,t[49]=k,t[50]=I,t[51]=L):L=t[51],L}),Ed=(e,t)=>e===t?!0:!e||!t?!1:e.totalTokens===t.totalTokens&&e.pending===t.pending&&e.percentage===t.percentage&&e.contextLimit===t.contextLimit&&(e.outputLimit??0)===(t.outputLimit??0)&&(e.normalizedOutput??0)===(t.normalizedOutput??0)&&e.thresholdLimit===t.thresholdLimit&&(e.lastMessageId??``)===(t.lastMessageId??``),Dd=(e,t)=>{if(!e)return`-`;try{return Pa(e,t,{fallback:`-`})}catch{return`-`}},Od=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+$/g,``);return r=r.replace(/\/+/g,`/`),n&&!r.startsWith(`//`)&&(r=`/${r}`),r===``?t.startsWith(`/`)?`/`:``:r},kd=e=>!e?.isOpen||!Array.isArray(e.tabs)||e.tabs.length===0?null:(e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[e.tabs.length-1])?.mode??null,Ad=e=>{let t=(0,du.c)(3),n=mn(Id),r;return t[0]!==n||t[1]!==e?(r=n?(0,$.jsx)(jd,{...e,hostId:n}):(0,$.jsx)(Pd,{...e}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r},jd=e=>{let t=(0,du.c)(11),n,r;t[0]===e?(n=t[1],r=t[2]):({hostId:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i=_t(),a=jr(!0),o=Mr(a.registry,n),s;t[3]!==n||t[4]!==a.catalog?.hosts?(s=a.catalog?.hosts.find(e=>e.id===n)?.name??n,t[3]=n,t[4]=a.catalog?.hosts,t[5]=s):s=t[5];let c=s,l=i?.registry??a.registry,u;return t[6]!==c||t[7]!==r||t[8]!==o.data||t[9]!==l?(u=(0,$.jsx)(Pd,{...r,remoteSummaries:o.data,remoteHostName:c,remoteRegistry:l}),t[6]=c,t[7]=r,t[8]=o.data,t[9]=l,t[10]=u):u=t[10],u},Md=Q.memo(e=>{let t=(0,du.c)(10),{entry:n,sessionId:r,fallback:i}=e,a;t[0]!==n.queryScope||t[1]!==r?(a=[...n.queryScope,`chat`,r,`session`],t[0]=n.queryScope,t[1]=r,t[2]=a):a=t[2];let o;t[3]===r?o=t[4]:(o=e=>e.id===r&&e.title?.trim()||null,t[3]=r,t[4]=o);let s;t[5]!==a||t[6]!==o?(s={queryKey:a,queryFn:ft,enabled:!1,staleTime:1/0,gcTime:1/0,select:o},t[5]=a,t[6]=o,t[7]=s):s=t[7];let c=gt(s,wt).data??i,l;return t[8]===c?l=t[9]:(l=(0,$.jsx)($.Fragment,{children:c}),t[8]=c,t[9]=l),l}),Nd=Q.memo(e=>{let t=(0,du.c)(39),{entry:n,sessionId:r,onClick:i,pressed:a}=e,o=n.location,s=Q.useSyncExternalStore(nt,Ke,Ke),c;t[0]===o?c=t[1]:(c=Xe(o),t[0]=o,t[1]=c);let u=c,d;t[2]!==o||t[3]!==u||t[4]!==r?(d=u?it(o,r):null,t[2]=o,t[3]=u,t[4]=r,t[5]=d):d=t[5];let f;t[6]!==s||t[7]!==d?(f={revision:s,scope:d},t[6]=s,t[7]=d,t[8]=f):f=t[8];let p=f.scope,m;t[9]!==u||t[10]!==p?(m=e=>u&&p?u.subscribe(p,e):Ld,t[9]=u,t[10]=p,t[11]=m):m=t[11];let h=m,g;t[12]!==u||t[13]!==p?(g=()=>u&&p?u.getTranscript(p):null,t[12]=u,t[13]=p,t[14]=g):g=t[14];let _=g,v=Q.useSyncExternalStore(h,_,_),y;t[15]!==n||t[16]!==o.directory?(y=ln(o.directory,l(),n),t[15]=n,t[16]=o.directory,t[17]=y):y=t[17];let b;t[18]===y?b=t[19]:(b={...y,enabled:!1,staleTime:1/0,gcTime:1/0},t[18]=y,t[19]=b);let x=gt(b,wt),S;t[20]!==o||t[21]!==r?(S=e=>e.getSessionModelSelection(r,o),t[20]=o,t[21]=r,t[22]=S):S=t[22];let C=pr(S),w;bb0:{if(!v){w=null;break bb0}for(let e=v.messageOrder.length-1;e>=0;e--){let t=v.messagesByID[v.messageOrder[e]];if(!t)continue;let n=Ue([t],e=>v.partsByMessageID[e]);if(n){w=n;break bb0}}w=null}let T=w,E=T&&`messageId`in T&&v?v.messagesByID[T.messageId]:void 0,D;if(t[23]!==T||t[24]!==E?.modelID||t[25]!==E?.providerID||t[26]!==x.data?.providers||t[27]!==C?.modelId||t[28]!==C?.providerId){let e=x.data?.providers.find(e=>e.id===(C?.providerId??E?.providerID))?.models[C?.modelId??E?.modelID??``];D=ot(T,e?.limit?.context??0,e?.limit?.output??0),t[23]=T,t[24]=E?.modelID,t[25]=E?.providerID,t[26]=x.data?.providers,t[27]=C?.modelId,t[28]=C?.providerId,t[29]=D}else D=t[29];let O=D;if(!O)return null;let k=O.contextLimit>0?Math.min(999,O.totalTokens/O.contextLimit*100):0,A=O.outputLimit??0,j;return t[30]!==i||t[31]!==a||t[32]!==k||t[33]!==A||t[34]!==O.contextLimit||t[35]!==O.pending||t[36]!==O.percentage||t[37]!==O.totalTokens?(j=(0,$.jsx)(Xs,{pending:O.pending,totalTokens:O.totalTokens,percentage:k,colorPercentage:O.percentage,contextLimit:O.contextLimit,outputLimit:A,size:`compact`,appearance:`subtle`,onClick:i,pressed:a}),t[30]=i,t[31]=a,t[32]=k,t[33]=A,t[34]=O.contextLimit,t[35]=O.pending,t[36]=O.percentage,t[37]=O.totalTokens,t[38]=j):j=t[38],j}),Pd=({onToggleLeftDrawer:e,onToggleRightDrawer:n,leftDrawerOpen:r,rightDrawerOpen:i,remoteSummaries:a,remoteHostName:o,remoteRegistry:s})=>{let{t:c}=Zt(),u=q(e=>e.setSessionSwitcherOpen),d=q(e=>e.toggleSidebar),p=q(e=>e.isSidebarOpen),g=q(e=>e.toggleBottomTerminal),_=q(e=>e.toggleContextPanel),y=q(e=>e.openContextOverview),b=q(e=>e.openContextBrowser),x=q(e=>e.closeContextPanel),C=q(e=>e.activeMainTab),T=q(e=>e.setActiveMainTab),E=q(e=>e.shortcutOverrides),D=q(e=>e.timeFormatPreference),O=Ln(e=>e.getCurrentModel),k=St(),A=cr(e=>!!e.newSessionDraft?.open),j=cr(e=>e.currentSessionId),M=mn(e=>e.activeProjectId?e.projects.find(t=>t.id===e.activeProjectId)??null:null),I=!!M?.hostId,L=dn(e=>e.remoteSession),z=M?.hostId&&L?.projectId===M.id&&L.location.hostId===M.hostId&&(!M.hubId||L.location.hubId===M.hubId)?L:null,B=I?z?.sessionId??null:j,V=I?!z?.sessionId:A,te=_r(I?``:B??``),ne=pn(I?null:B),re=mn(e=>e.projects),ie=Q.useMemo(()=>{if(!I)return ne;let e=z?.location.directory??M?.path,t=M?.hubId??s?.hubId,n=M?.hostId;if(!(!e||!t||!n||xt(re,t,n,e,a?.worktrees)?.id!==M?.id))return a?.directories.find(t=>t.directory===e)?.sessions.find(t=>t.id===B&&t.directory===e)},[I,ne,z?.location.directory,M,s?.hubId,re,a,B]),ae=Q.useMemo(()=>{if(!M)return null;let e=M.path.split(/[\\/]/).filter(Boolean);return e[e.length-1]??null},[M]),se=_s(e=>e.results),W=_s(e=>e.fetchAllQuotas),le=_s(e=>e.isLoading),ue=_s(e=>e.lastUpdated),de=_s(e=>e.displayMode),fe=_s(e=>e.showPredValues),pe=_s(e=>e.dropdownProviderIds),me=_s(e=>e.loadSettings),he=_s(e=>e.setDisplayMode),{isMobile:ge}=go(),_e=Va().data??null,ve=Ps(e=>e.setStatus),ye=Q.useRef(null),[be,xe]=Q.useState(()=>typeof window>`u`?!1:v()),Se=Q.useMemo(()=>R(),[]),Ce=be&&F()===`win32`,we=ho(),Te=vu(),Ee=Q.useMemo(()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),[]),{usesFramelessChrome:De,side:Oe}=$s(),ke=Q.useMemo(()=>{if(typeof window>`u`)return null;let e=window.__YURI_MACOS_MAJOR__;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e;if(typeof navigator>`u`)return null;let t=(navigator.userAgent||``).match(/Mac OS X (\d+)[._](\d+)/);if(!t)return null;let n=Number.parseInt(t[1],10),r=Number.parseInt(t[2],10);return Number.isNaN(n)?null:n===10?r:n},[]);(0,Q.useEffect)(()=>{typeof window>`u`||xe(v())},[]);let Ae=O(),Me=Ae&&typeof Ae.limit==`object`&&Ae.limit!==null?Ae.limit:null,Ne=Me&&typeof Me.context==`number`?Me.context:0,Pe=Me&&typeof Me.output==`number`?Me.output:0,Fe=gr(I?``:B??``,Ne,Pe),Ie=V?null:Fe,[Le,Re]=Q.useState(null),G=!B||te;(0,Q.useEffect)(()=>{if(!B){Re(e=>e===null?e:null);return}if(Ie){Re(e=>Ed(e,Ie)?e:Ie);return}G&&Re(e=>e===null?e:null)},[Ie,B,G]);let ze=q(e=>e.isSessionSwitcherOpen),Be=_e?.connected?_e.user?.avatarUrl??null:null,Ve=_e?.connected?_e.user?.login??null:null,He=_e?.accounts??[],[Ue,We]=Q.useState(!1),[Ge,Ke]=Q.useState(!1),[qe,Je]=Q.useState(!1),[Ye,Xe]=Q.useState(!1),[Ze,Qe]=Q.useState(`Local`),[$e,et]=Q.useState(!1),[tt,nt]=Q.useState(be?`instance`:`usage`),[rt,it]=Q.useState(`usage`);(0,Q.useEffect)(()=>{!be&&tt===`instance`&&nt(`usage`)},[tt,be]);let at=Q.useMemo(()=>w(),[]),ot=!at&&C===`chat`&&!!Le,st=Le&&Le.contextLimit>0?Math.min(999,Le.totalTokens/Le.contextLimit*100):0,ct=K(async()=>{if(!(typeof window>`u`||!be))try{if(S()){Qe(`Local`),et(!1);return}let e=l(),t=await U();if(l()!==e)return;let n=m(),r=f(),i=r.startsWith(`host:`)?r.slice(5):null,a=(i?t.hosts.find(e=>e.id===i):void 0)??t.hosts.find(e=>n?H(n,oe(e)):!1);if(m()!==n)return;if(et(!!n),a?.label?.trim()){Qe(ce(a.label.trim()));return}Qe(`Instance`)}catch{Qe(`Local`),et(!1)}});(0,Q.useEffect)(()=>{ct()},[be]),zs();let lt=_s(e=>e.selectedModels),ut=_s(e=>e.expandedFamilies),dt=_s(e=>e.toggleFamilyExpanded),ft=Q.useMemo(()=>{let e=[];for(let t of Fs(se)){if(!pe.includes(t.id))continue;let n=se.find(e=>e?.providerId===t.id),r=n?.usage?.windows??{},i=n?.usage?.models,a=gc(Object.entries(r),n?.usage?.accounts),o={providerId:t.id,providerName:t.name,entries:a,error:n&&!n.ok&&n.configured?n.error:void 0};if(i&&Object.keys(i).length>0){let e=lt[t.id]??[],n=e.length>0,r=ws(i,t.id),a=Rs(t.id),s=ys(a);o.modelFamilies=[];for(let t of s){let a=r.get(t.id)??[];if(a.length===0)continue;let s=n?a.filter(t=>e.includes(t)):a;if(s.length===0)continue;let c=[];for(let e of s){let t=i[e];if(t?.windows){let n=Object.entries(t.windows);n.length>0&&c.push([e,n[0][1]])}}c.length>0&&o.modelFamilies.push({familyId:t.id,familyLabel:t.label,models:c})}let l=r.get(null)??[],u=n?l.filter(t=>e.includes(t)):l;if(u.length>0){let e=[];for(let t of u){let n=i[t];if(n?.windows){let r=Object.entries(n.windows);r.length>0&&e.push([t,r[0][1]])}}e.length>0&&o.modelFamilies.push({familyId:null,familyLabel:c(`header.services.modelFamily.other`),models:e})}}(a.length>0||o.modelFamilies&&o.modelFamilies.length>0||o.error)&&e.push(o)}return e},[pe,se,lt,c]),pt=ft.length>0;Q.useEffect(()=>{me()},[me]);let mt=Q.useCallback(async e=>{he(e);try{await je({usageDisplayMode:e})}catch(e){console.warn(`Failed to update usage display mode:`,e)}},[he]),ht=Q.useCallback(()=>{if(Ye)return;Xe(!0);let e=new Promise(e=>setTimeout(e,500));Promise.all([W(),e]).finally(()=>{Xe(!1)})},[W,Ye]),gt=cr(e=>I||!B?``:e.worktreeMetadata.get(B)?.path??``),_t=Q.useMemo(()=>Od(gt||``),[gt]),vt=Q.useMemo(()=>Od((typeof ie?.directory==`string`?ie.directory:``)||``),[ie?.directory]),yt=cr(e=>e.newSessionDraft?.open?Od(e.newSessionDraft.bootstrapPendingDirectory??e.newSessionDraft.directoryOverride??``):``),bt=Q.useMemo(()=>I?z?.location.directory??M?.path??``:_t||vt||yt,[I,z?.location.directory,M?.path,yt,vt,_t]),Ct=zo(),wt=z?ee(z.location):M?.hostId&&M.hubId?ee({hubId:M.hubId,hostId:M.hostId,directory:Ct??M.path}):``,Tt=Q.useMemo(()=>I?wt:Od(Ct||bt||M?.path||``),[I,wt,M?.path,Ct,bt]),Et=q(e=>zt(e,Tt)),Dt=!!Et?.isOpen,Ot=K(()=>_(Tt)),kt=Q.useMemo(()=>{if(!B)return ae??`Yuri`;let e=ie?.title?.trim();return e&&e.length>0?e:`Untitled Session`},[ae,ie?.title,B]),At=Q.useMemo(()=>I?bt:Od(bt||M?.path||``),[I,M?.path,bt]),jt=Q.useMemo(()=>M?{id:M.id,path:M.path,hostId:M.hostId,hubId:M.hubId}:null,[M]),Mt=Q.useRef(null);Q.useEffect(()=>{!jt||!At||(Mt.current={projectRef:jt,directory:At})},[At,jt]);let Pt=Q.useMemo(()=>jt&&At?{projectRef:jt,directory:At}:Mt.current,[At,jt]),Ft=Q.useCallback(async e=>{if(!(!e||Ue)){We(!0);try{let t=k.github?await k.github.authActivate(e):await(async()=>{let t=await h(`/api/github/auth/activate`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({accountId:e})}),n=await t.json().catch(()=>null);if(!t.ok||!n)throw Error(n?.error||t.statusText);return n})();ve(t)}catch(e){console.error(`Failed to switch GitHub account:`,e)}finally{We(!1)}}},[Ue,k.github,ve]),It=Q.useCallback(()=>{if(typeof document>`u`)return;let e=document.activeElement;if(!e)return;let t=e.tagName;(t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable)&&e.blur()},[]),Lt=Q.useCallback(()=>{if(ge){It(),u(!ze);return}d()},[It,ge,ze,u,d]),Rt=Q.useCallback(()=>{I||P(`desktop_open_draft_mini_chat_window`,{directory:Od(bt||M?.path||``),projectId:M?.id??null,apiBaseUrl:m(),clientToken:t()}).catch(e=>{console.warn(`[header] failed to open draft mini chat window`,e)})},[I,M?.id,M?.path,bt]),Bt=Q.useCallback(()=>{if(!I){if(V){Rt();return}B&&P(`desktop_open_session_mini_chat_window`,{sessionId:B,directory:Od(bt||M?.path||``),apiBaseUrl:m(),clientToken:t()}).catch(e=>{console.warn(`[header] failed to open session mini chat window`,e)})}},[I,M?.path,B,Rt,V,bt]),Vt=Q.useCallback(()=>{let e=Tt;if(e){if(kd(Et)===`context`){x(e);return}y(e)}},[x,Tt,Et,y]),Ht=Q.useMemo(()=>Tt?kd(Et)===`context`:!1,[Tt,Et]),Ut=Q.useCallback(()=>{let e=Tt;if(e){if(kd(Et)===`browser`){x(e);return}b(e)}},[x,Tt,Et,b]),Wt=Q.useMemo(()=>Tt?kd(Et)===`browser`:!1,[Tt,Et]),Gt=xd,Kt=Sd,qt=Q.useMemo(()=>Ge?`services`:r?`sessions`:i?`git`:C,[C,Ge,r,i]),Jt=Q.useCallback(()=>{Ke(!1),r&&e&&e(),i&&n&&n(),!e&&ze&&u(!1)},[ze,r,e,n,i,u]),Yt=Q.useCallback(()=>{r||Ke(!1),e?.()},[r,e]),Xt=Q.useCallback(()=>{i||Ke(!1),n?.()},[n,i]),Qt=Q.useMemo(()=>be&&Ee&&!Te?`5.5rem`:we?`max(calc(0.75rem + var(--yuri-wco-left-inset, 0px)), 5.5rem)`:(!be||De)&&!at?`calc(0.75rem + var(--yuri-wco-left-inset, 0px))`:`0.75rem`,[be,Te,Ee,we,at,De]);(0,Q.useEffect)(()=>{typeof document>`u`||document.documentElement.style.setProperty(`--yuri-titlebar-left-inset`,Qt)},[Qt]);let $t=p?`0.75rem`:`var(--yuri-titlebar-left-inset, 0.75rem)`,en=p?`0px`:`calc(var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`,tn=Q.useMemo(()=>!be||!Ee||ke===null?``:ke>=26?`h-12`:ke<=15?`h-14`:``,[be,Ee,ke]),nn=Q.useMemo(()=>{if(!(be&&!De||at))return{paddingRight:Dt?`0.75rem`:`calc(0.75rem + var(--yuri-wco-right-inset, 0px))`,minHeight:`max(3rem, var(--yuri-wco-titlebar-height, 0px))`,height:`max(3rem, var(--yuri-wco-titlebar-height, 0px))`}},[be,at,Dt,De]),rn=K(e=>{if(!e||typeof document>`u`)return;let t=document.documentElement.style,n=`${e}px`;t.getPropertyValue(`--yuri-header-height`)!==n&&t.setProperty(`--yuri-header-height`,n)});Nt(ye,([e])=>{e&&rn(e.borderBoxSize[0]?.blockSize??e.target.getBoundingClientRect().height)},{box:`border-box`}),Q.useLayoutEffect(()=>{rn(ye.current?.getBoundingClientRect().height)},[rn,ge,tn]);let an=Q.useCallback(async e=>{let t=e.target;t.closest(`.app-region-no-drag`)||t.closest(`button, a, input, select, textarea`)||e.button===0&&be&&await N()},[be]),on=Q.useMemo(()=>{if(ge){let e=[{id:`chat`,label:c(`layout.mainTab.chat`),icon:`chat-thread`}];return e.push({id:`diff`,label:c(`layout.mainTab.diff`),icon:`diff`},{id:`files`,label:c(`layout.mainTab.files`),icon:`folder-6`},{id:`terminal`,label:c(`layout.mainTab.terminal`),icon:`terminal-box`},{id:`diagram`,label:c(`layout.mainTab.diagram`),icon:`file`}),e}return[]},[ge,c]),J=Q.useCallback(e=>to(Qa(e,E)),[E]);(0,Q.useEffect)(()=>{!ge&&(C===`git`||C===`terminal`||C===`diff`||C===`files`)&&T(`chat`)},[C,ge,T]);let sn=Q.useMemo(()=>{let e=[];return be&&e.push({value:`instance`,label:c(`layout.services.instance`),icon:(0,$.jsx)(Z,{name:`connection-local`,className:`h-3.5 w-3.5`})}),e.push({value:`usage`,label:c(`layout.services.usage`),icon:(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`})},{value:`mcp`,label:`MCP`,icon:(0,$.jsx)(Ts,{className:`h-3.5 w-3.5`})}),e},[be,c]),cn=Q.useMemo(()=>sn.map(e=>({id:e.value,label:e.label,icon:e.icon})),[sn]),ln=Q.useMemo(()=>[{value:`usage`,label:c(`header.services.used`)},{value:`remaining`,label:c(`header.services.remaining`)}],[c]),un=Q.useMemo(()=>ln.map(e=>({id:e.value,label:e.label})),[ln]),fn=Q.useMemo(()=>[{id:`usage`,label:c(`layout.services.usage`),icon:(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`})},{id:`mcp`,label:`MCP`,icon:(0,$.jsx)(Ts,{className:`h-3.5 w-3.5`})}],[c]);(0,Q.useEffect)(()=>{let e=e=>{if(An(e)&&!e.shiftKey&&!e.altKey){let t=parseInt(e.key,10);t>=1&&t<=on.length&&(e.preventDefault(),ge&&(It(),Jt()),T(on[t-1].id))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[It,Jt,ge,T,on]);let hn=K(e=>{nt(e),Je(!0),ct(),e===`usage`&&ue===null&&W()});(0,Q.useEffect)(()=>{let e=e=>{let t=Qa(`toggle_services_menu`,E);if(Ja(e,t)){e.preventDefault();let t=bd({isOpen:qe,activeTab:tt,targetTab:be?`instance`:`usage`});t.open?hn(t.tab):Je(!1);return}let n=Qa(`cycle_services_tab`,E);if(Ja(e,n)){e.preventDefault();let t=sn.map(e=>e.value);if(t.length===0)return;let n=t.indexOf(tt),r=t[n===-1?0:(n+1)%t.length];nt(r),Je(!0),ct(),r===`usage`&&ue===null&&W();return}let r=Qa(`open_usage`,E);if(Ja(e,r)){e.preventDefault();let t=bd({isOpen:qe,activeTab:tt,targetTab:`usage`});t.open?hn(t.tab):Je(!1);return}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[E,be,qe,tt,sn,ue,W,ct,hn]);let gn=e=>{let t=C===e.id,n=e.icon===`diff`,r=n?null:e.icon,i=e.id===`chat`,a=e=>n?(0,$.jsx)(fu,{size:e}):r?(0,$.jsx)(Z,{name:r,className:`h-${e/4} w-${e/4}`}):null,o=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>T(e.id),className:X(`relative flex h-8 items-center gap-2 px-3 rounded-lg typography-ui-label font-medium transition-colors`,t?`app-region-no-drag bg-interactive-selection text-interactive-selection-foreground shadow-none`:`app-region-no-drag text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,i&&!ge&&`min-w-[100px] justify-center`),"aria-label":e.label,"aria-selected":t,role:`tab`,children:[ge?a(20):(0,$.jsxs)($.Fragment,{children:[a(16),(0,$.jsx)(`span`,{className:`header-tab-label`,children:e.label})]}),e.badge!==void 0&&e.badge>0&&(0,$.jsx)(`span`,{className:`header-tab-badge typography-micro text-status-info font-medium`,children:e.badge})]});return(0,$.jsx)(Q.Fragment,{children:o},e.id)},Y=!I&&Se&&(V||!!B),_n=Q.useCallback(e=>{window.setTimeout(e,0)},[]),vn=Q.useCallback(e=>{hn(e)},[hn]),yn=Q.useRef(null),bn=(0,$.jsxs)(`div`,{className:`relative flex shrink-0 items-center`,children:[(0,$.jsx)(`div`,{ref:yn,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center`,children:(0,$.jsxs)(Na,{children:[(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(Ra,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`header.actions.sessionMenuAria`),className:X(Gt,`text-muted-foreground`),children:(0,$.jsx)(Z,{name:`more-2`,className:`h-[18px] w-[18px]`})})})}),(0,$.jsx)(Ea,{children:(0,$.jsx)(`p`,{children:c(`header.actions.sessionMenu`)})})]}),(0,$.jsxs)(Ia,{align:`start`,className:`min-w-[14rem]`,children:[Y?(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:()=>_n(Bt),children:[(0,$.jsx)(Z,{name:`picture-in-picture-2`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(V?`header.actions.newMiniChat`:`header.actions.openSessionMiniChat`)})]}):null,be?(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:()=>_n(()=>vn(`instance`)),children:[(0,$.jsx)(Z,{name:`stack`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:c(`header.actions.sessionMenu.servicesWithInstance`,{current:Ze})}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:J(`toggle_services_menu`)})]}):null,(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:()=>_n(()=>vn(`usage`)),children:[(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`header.actions.sessionMenu.viewUsage`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:J(`open_usage`)})]}),(0,$.jsx)(Wa,{}),(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:()=>_n(g),children:[(0,$.jsx)(Z,{name:`terminal-box`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`header.actions.toggleTerminalPanel`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:J(`toggle_terminal`)})]}),(0,$.jsxs)(ao,{className:`flex items-center gap-2`,onClick:()=>_n(Ut),children:[(0,$.jsx)(Z,{name:`global`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`contextPanel.browser.open`)}),Wt?(0,$.jsx)(Z,{name:`check`,className:`h-3.5 w-3.5 text-foreground`}):null]})]})]})}),(0,$.jsx)(Td,{isDesktopApp:be,currentInstanceSupportsUpdate:$e,isDesktopServicesOpen:qe,setIsDesktopServicesOpen:Je,refreshCurrentInstanceLabel:ct,desktopServicesTab:tt,setDesktopServicesTab:nt,fetchAllQuotas:W,servicesTabItems:cn,quotaLastUpdated:ue,quotaDisplayMode:de,showPredValues:fe,quotaDisplayTabItems:un,handleDisplayModeChange:mt,handleUsageRefresh:ht,isQuotaLoading:le,isUsageRefreshSpinning:Ye,hasRateLimits:pt,rateLimitGroups:ft,expandedFamilies:ut,toggleFamilyExpanded:dt,timeFormatPreference:D,anchorRef:yn})]}),xn=(0,$.jsxs)($.Fragment,{children:[!I&&!ge&&!at&&C===`chat`?(0,$.jsx)(xu,{}):null,I?null:(0,$.jsx)(Qu,{directory:At}),be&&(0,$.jsx)(Ou,{open:qe&&tt===`instance`,onClick:()=>hn(`instance`)}),(0,$.jsx)(Cd,{title:c(`header.actions.rightSidebarWithShortcut`,{shortcut:J(`toggle_right_sidebar`)}),ariaLabel:c(`contextPanel.actions.togglePanel`),pressed:Dt,onClick:Ot,className:X(`app-region-no-drag group inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary hover:bg-interactive-hover transition-colors`,Dt?`bg-interactive-selection text-interactive-selection-foreground`:`text-muted-foreground/75 hover:text-foreground`),Icon:`folder-3`,iconClassName:`size-4`}),(0,$.jsx)(wd,{isMobile:ge,githubAuthStatus:_e,githubAccounts:He,githubAvatarUrl:Be,githubLogin:Ve,isSwitchingGitHubAccount:Ue,handleGitHubAccountSwitch:Ft})]}),Sn=()=>(0,$.jsxs)(`div`,{onMouseDown:an,className:X(`app-region-drag relative flex h-12 select-none items-center pr-3`,tn),style:nn,role:`tablist`,"aria-label":c(`header.navigation.mainAria`),children:[(0,$.jsx)(`div`,{"aria-hidden":!0,className:`shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,style:{width:$t}}),(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,style:{width:en}}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[(0,$.jsxs)(`div`,{className:`app-region-no-drag mr-3 flex min-w-0 items-center gap-0.5`,children:[(0,$.jsx)(Qs,{scopeProjectId:I?M?.id:null,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`sessions.switcher.openAria`),className:`inline-flex h-8 min-w-0 max-w-full items-center rounded-md px-2.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-primary`,children:(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground`,children:V?c(`sessions.switcher.draftTitle`):I&&s&&z?.sessionId?(0,$.jsx)(Md,{entry:s.resolve(z.location),sessionId:z.sessionId,fallback:kt},ee(z.location)):kt})})}),I?(0,$.jsxs)(`span`,{"data-remote-header-host":M?.hostId,className:`inline-flex min-w-0 max-w-36 items-center gap-1 typography-meta text-muted-foreground`,title:o,children:[(0,$.jsx)(Z,{name:`computer`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:o}),s&&M?.hostId?(0,$.jsx)(Si,{registry:s,hostId:M.hostId}):null]}):null]}),on.length>0&&(0,$.jsx)(`div`,{className:`flex items-center gap-1 rounded-lg bg-[var(--surface-muted)]/50 p-1`,children:on.map(e=>gn(e))}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[bn,I&&!at&&C===`chat`&&s&&z?.sessionId?(0,$.jsx)(Nd,{entry:s.resolve(z.location),sessionId:z.sessionId,onClick:Vt,pressed:Ht},ee(z.location)):null,ot&&Le?(0,$.jsx)(Xs,{pending:Le.pending,totalTokens:Le.totalTokens,percentage:st,colorPercentage:Le.percentage,contextLimit:Le.contextLimit,outputLimit:Le.outputLimit??0,size:`compact`,appearance:`subtle`,onClick:Vt,pressed:Ht}):null,xn,(0,$.jsx)(Zs,{visible:De&&Oe===`right`&&!Dt,position:`right`})]})]})]}),Cn=()=>(0,$.jsxs)(`div`,{className:`app-region-drag relative flex items-center gap-2 px-3 py-2 select-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e?(0,$.jsx)(`button`,{type:`button`,onClick:Yt,className:X(Kt,qt===`sessions`&&`bg-interactive-selection text-interactive-selection-foreground`),"aria-label":c(r?`header.actions.closeSessionsAria`:`header.actions.openSessionsAria`),children:(0,$.jsx)(Z,{name:`layout-left`,className:`h-5 w-5`})}):ze?(0,$.jsx)(`button`,{type:`button`,onClick:()=>u(!1),className:`app-region-no-drag h-9 w-9 p-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md active:bg-interactive-active`,"aria-label":c(`header.actions.backAria`),children:(0,$.jsx)(Z,{name:`arrow-left-s`,className:`h-5 w-5`})}):(0,$.jsx)(`button`,{type:`button`,onClick:Lt,className:`app-region-no-drag h-9 w-9 p-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md active:bg-interactive-active`,"aria-label":c(`header.actions.openSessionsAria`),children:(0,$.jsx)(Z,{name:`play-list-add`,className:`h-5 w-5`})}),!e&&ze&&(0,$.jsx)(`span`,{className:`typography-ui-label font-semibold text-foreground`,children:c(`header.sessions.title`)})]}),(!ze||!!e)&&(0,$.jsxs)($.Fragment,{children:[I?(0,$.jsxs)(`span`,{"data-remote-header-host":M?.hostId,className:`inline-flex max-w-28 shrink-0 items-center gap-1 typography-meta text-muted-foreground`,title:o,children:[(0,$.jsx)(`span`,{className:`truncate`,children:o}),s&&M?.hostId?(0,$.jsx)(Si,{registry:s,hostId:M.hostId}):null]}):null,(0,$.jsx)(`div`,{className:`app-region-no-drag flex min-w-0 flex-1 items-center`,children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 overflow-x-auto overflow-y-hidden scrollbar-hidden touch-pan-x overscroll-x-contain`,children:(0,$.jsx)(`div`,{className:`flex w-max items-center gap-1 pr-1`,children:(0,$.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-[var(--surface-muted)]/50 p-0.5`,role:`tablist`,"aria-label":c(`header.navigation.mainAria`),children:on.map(e=>{let t=C===e.id,n=e.icon===`diff`,r=n?null:e.icon;return(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{ge&&(It(),Jt()),T(e.id)},"aria-label":e.label,"aria-selected":t,role:`tab`,className:X(Kt,`relative rounded-lg`,qt===e.id&&`bg-interactive-selection text-interactive-selection-foreground`),children:[n?(0,$.jsx)(fu,{className:`h-5 w-5`}):r?(0,$.jsx)(Z,{name:r,className:`h-5 w-5`}):null,e.badge!==void 0&&e.badge>0&&(0,$.jsx)(`span`,{className:`absolute -top-1 -right-1 text-[10px] font-semibold text-primary`,children:e.badge}),e.showDot&&(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 h-2 w-2 rounded-full bg-primary`,"aria-label":c(`header.changes.availableAria`)})]})}),(0,$.jsx)(Ea,{children:(0,$.jsx)(`p`,{children:e.label})})]},e.id)})})})})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(gl,{mobile:!0}),Pt&&(0,$.jsx)(_d,{projectRef:Pt.projectRef,directory:Pt.directory,compact:!0,allowMobile:!0,className:`h-9`}),(0,$.jsxs)(Na,{open:Ge,onOpenChange:t=>{t&&(r&&e&&e(),i&&n&&n()),Ke(t),t&&ue===null&&W()},children:[(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(Ra,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`header.services.viewAria`),className:X(Kt,qt===`services`&&`bg-interactive-selection text-interactive-selection-foreground`),children:(0,$.jsx)(Z,{name:`stack`,className:`h-5 w-5`})})})}),(0,$.jsx)(Ea,{children:(0,$.jsx)(`p`,{children:c(`header.services.title`)})})]}),(0,$.jsx)(Ia,{align:`end`,sideOffset:0,positionerClassName:`!fixed !bottom-0 !left-0 !right-0 !top-[var(--yuri-header-height,56px)] !transform-none`,className:`h-full w-screen max-h-none rounded-none border-0 p-0 pt-1 overflow-hidden`,children:(0,$.jsxs)(`div`,{className:`flex h-full flex-col bg-[var(--surface-elevated)]`,children:[(0,$.jsx)(`div`,{className:`sticky top-0 z-20 bg-[var(--surface-elevated)] px-2 py-px`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-0`,children:[(0,$.jsx)(`div`,{className:`h-10 min-w-0 flex-1`,children:(0,$.jsx)(gs,{items:fn,activeId:rt,onSelect:e=>{let t=e;it(t),t===`usage`&&ue===null&&W()},layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,activePillButtonClassName:`h-8`,className:`h-full`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>Ke(!1),className:`inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover`,"aria-label":c(`header.services.closeAria`),children:(0,$.jsx)(Z,{name:`close`,className:`h-5 w-5`})})]})}),rt===`mcp`&&(0,$.jsx)(bc,{active:Ge&&rt===`mcp`}),rt===`usage`&&(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto overflow-x-hidden pb-[calc(4rem+env(safe-area-inset-bottom))]`,children:[(0,$.jsx)(`div`,{className:`border-b border-[var(--interactive-border)]`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col min-w-0 gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-header font-semibold text-foreground`,children:c(`header.services.rateLimits`)}),(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Dd(ue,D)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center h-6`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>mt(`usage`),className:X(`typography-ui-label px-1 pb-0.5 transition-colors`,de===`usage`?`text-foreground border-b-2 border-[var(--primary-base)]`:`text-muted-foreground hover:text-foreground`),children:c(`header.services.used`)}),(0,$.jsx)(`span`,{className:`text-muted-foreground typography-ui-label px-0.5`,children:`·`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>mt(`remaining`),className:X(`typography-ui-label px-1 pb-0.5 transition-colors`,de===`remaining`?`text-foreground border-b-2 border-[var(--primary-base)]`:`text-muted-foreground hover:text-foreground`),children:c(`header.services.remaining`)})]}),(0,$.jsx)(`button`,{type:`button`,className:X(`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors`,`hover:text-foreground hover:bg-interactive-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),onClick:ht,disabled:le||Ye,"aria-label":c(`header.services.refreshRateLimitsAria`),children:(0,$.jsx)(Z,{name:`refresh`,className:X(`h-4 w-4`,Ye&&`animate-spin`)})})]})]})}),!pt&&(0,$.jsx)(`div`,{className:`px-4 py-6 text-center`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:c(`header.services.noRateLimits`)})}),(0,$.jsx)(`div`,{className:`py-1`,children:ft.map((e,t)=>(0,$.jsxs)(Q.Fragment,{children:[t>0?(0,$.jsx)(`div`,{className:`mx-4 my-1 border-t border-[var(--interactive-border)]`}):null,(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2`,children:[(0,$.jsx)(No,{providerId:e.providerId,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:e.providerName})]}),e.entries.length===0&&(!e.modelFamilies||e.modelFamilies.length===0)?(0,$.jsx)(`div`,{className:`px-4 pb-2`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:e.error??c(`header.services.noRateLimitsReported`)})}):(0,$.jsxs)(`div`,{className:`space-y-3 px-4 pb-2`,children:[e.entries.map(([t,n],r)=>{let i=Ac(e.entries,r),a=de===`remaining`?n.remainingPercent:n.usedPercent,o=n.disablePace?null:Ba(n.usedPercent,n.resetAt,n.windowSeconds,t),s=o?.dailyAllocationPercent==null?null:de===`remaining`?100-uo(o.elapsedRatio):uo(o.elapsedRatio),c=La(n.valueLabel,a),l=ja(n.resetAt,n.resetAfterFormatted??n.resetAtFormatted,D);return(0,$.jsxs)(Q.Fragment,{children:[i?(0,$.jsx)(`div`,{className:X(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,r>0&&`mt-5 border-t border-[var(--surface-subtle)] pt-3`),children:i}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground break-words`,children:ka(n.label??t)}),l?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:l}):null]}),(0,$.jsx)(`span`,{className:`shrink-0 whitespace-nowrap typography-ui-label text-foreground tabular-nums`,children:c===`-`?``:c})]}),(0,$.jsx)(Us,{percent:a,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:s}),o&&fe?(0,$.jsx)(Is,{paceInfo:o,compact:!0}):null]})]},`${e.providerId}-${t}`)}),e.modelFamilies&&e.modelFamilies.length>0&&(0,$.jsx)(`div`,{className:`space-y-0.5`,children:e.modelFamilies.map(t=>{let n=(ut[e.providerId]??[]).includes(t.familyId??`other`);return(0,$.jsxs)(zl,{open:n,onOpenChange:()=>dt(e.providerId,t.familyId??`other`),children:[(0,$.jsxs)(Rl,{className:`flex w-full items-center justify-between rounded-md px-1 py-1.5 text-left hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:t.familyLabel}),n?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`})]}),(0,$.jsx)(Ll,{children:(0,$.jsx)(`div`,{className:`space-y-2.5 pb-1 pl-1 pt-1`,children:t.models.map(([t,n])=>{let r=de===`remaining`?n.remainingPercent:n.usedPercent,i=Ba(n.usedPercent,n.resetAt,n.windowSeconds),a=i?.dailyAllocationPercent==null?null:de===`remaining`?100-uo(i.elapsedRatio):uo(i.elapsedRatio),o=La(n.valueLabel,r);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Cs(t)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground tabular-nums`,children:o===`-`?``:o})]}),(0,$.jsx)(Us,{percent:r,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:a}),i&&fe?(0,$.jsx)(Is,{paceInfo:i,compact:!0}):null]},`${e.providerId}-${t}`)})})})]},t.familyId??`other`)})})]})]},e.providerId))})]})]})})]}),n?(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:Xt,className:X(Kt,`relative`,qt===`git`&&`bg-interactive-selection text-interactive-selection-foreground`),"aria-label":i?`Close git sidebar`:`Open git sidebar`,children:(0,$.jsx)(Z,{name:`layout-right`,className:`h-5 w-5`})})}),(0,$.jsx)(Ea,{children:(0,$.jsx)(`p`,{children:i?`Close git sidebar`:`Open git sidebar`})})]}):null]})]})]}),wn=X(`header-safe-area relative z-10 bg-background`,Ce&&`bg-[var(--surface-background)] backdrop-blur-none`,ge&&`yuri-layout-divider-b`);return(0,$.jsx)($.Fragment,{children:(0,$.jsx)(`header`,{ref:ye,className:wn,style:{"--padding-scale":`1`},children:ge?Cn():Sn()})})};function Fd(){}function Id(e){return e.projects.find(t=>t.id===e.activeProjectId)?.hostId}function Ld(){}var Rd=180,zd=640,Bd=110,Vd=e=>{let t=(0,du.c)(44),{isOpen:n,isMobile:r,children:i}=e,{t:a}=Zt(),o=q(Hd),s=q(Ud),c=q(Wd),l=q(Gd),[u,d]=Q.useState(null),[f,p]=Q.useState(!1),m=Q.useRef(null),h=Q.useRef(0),g=Q.useRef(o||300),_=Math.min(zd,Math.max(Rd,o||300)),v,y;t[0]===n?(v=t[1],y=t[2]):(v=()=>{n||(d(null),p(!1))},y=[n],t[0]=n,t[1]=v,t[2]=y),Q.useEffect(v,y);let b,x;t[3]!==s||t[4]!==r||t[5]!==n?(b=()=>{if(r||!n||!s)return;let e=()=>{let e=m.current?.parentElement?.getBoundingClientRect().height;if(!e||e<=0)return;let t=Math.max(0,Math.round(e));d(e=>e===t?e:t)};e();let t=m.current?.parentElement;if(!t)return;let i=new ResizeObserver(e);return i.observe(t),()=>{i.disconnect()}},x=[s,r,n],t[3]=s,t[4]=r,t[5]=n,t[6]=b,t[7]=x):(b=t[6],x=t[7]),Q.useEffect(b,x);let S,C;if(t[8]!==s||t[9]!==r||t[10]!==f||t[11]!==c||t[12]!==l?(S=()=>{if(r||!f||s)return;let e=e=>{let t=h.current-e.clientY,n=Math.min(zd,Math.max(Rd,g.current+t));c(n)},t=()=>{p(!1),q.getState().bottomTerminalHeight<=Bd&&l(!1)};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t,{once:!0}),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},C=[s,r,f,c,l],t[8]=s,t[9]=r,t[10]=f,t[11]=c,t[12]=l,t[13]=S,t[14]=C):(S=t[13],C=t[14]),Q.useEffect(S,C),r)return null;let w=n?s?Math.max(0,u??_):_:0,T=n&&s,E;t[15]!==w||t[16]!==s||t[17]!==n?(E=e=>{!n||s||(p(!0),h.current=e.clientY,g.current=w,e.preventDefault())},t[15]=w,t[16]=s,t[17]=n,t[18]=E):E=t[18];let D=E,O=T?`absolute inset-x-0 bottom-0 z-40`:`relative`,k=f?`transition-none`:`transition-[height] duration-300 ease-in-out`,A=(!n||T)&&`border-t-0`,j;t[19]!==A||t[20]!==O||t[21]!==k?(j=X(`flex overflow-hidden border-t border-border bg-sidebar`,O,k,A),t[19]=A,t[20]=O,t[21]=k,t[22]=j):j=t[22];let M;t[23]!==w||t[24]!==T?(M=T?{top:0}:{height:`${w}px`,minHeight:`${w}px`,maxHeight:`${w}px`},t[23]=w,t[24]=T,t[25]=M):M=t[25];let N=!n||!s&&w===0,P;t[26]!==D||t[27]!==s||t[28]!==n||t[29]!==f||t[30]!==a?(P=n&&!s&&(0,$.jsx)(`div`,{className:X(`absolute left-0 top-0 z-20 h-[3px] w-full cursor-row-resize hover:bg-[var(--interactive-border)]/80 transition-colors`,f&&`bg-[var(--interactive-border)]`),onPointerDown:D,role:`separator`,"aria-orientation":`horizontal`,"aria-label":a(`terminalView.bottomDock.resizeAria`)}),t[26]=D,t[27]=s,t[28]=n,t[29]=f,t[30]=a,t[31]=P):P=t[31];let F=!n&&`pointer-events-none select-none opacity-0`,I;t[32]===F?I=t[33]:(I=X(`relative z-10 flex h-full min-h-0 w-full flex-col transition-opacity duration-300 ease-in-out`,F),t[32]=F,t[33]=I);let L=!n,R;t[34]!==i||t[35]!==I||t[36]!==L?(R=(0,$.jsx)(`div`,{className:I,"aria-hidden":L,children:i}),t[34]=i,t[35]=I,t[36]=L,t[37]=R):R=t[37];let z;return t[38]!==j||t[39]!==M||t[40]!==N||t[41]!==P||t[42]!==R?(z=(0,$.jsxs)(`section`,{ref:m,className:j,style:M,"aria-hidden":N,children:[P,R]}),t[38]=j,t[39]=M,t[40]=N,t[41]=P,t[42]=R,t[43]=z):z=t[43],z};function Hd(e){return e.bottomTerminalHeight}function Ud(e){return e.isBottomTerminalExpanded}function Wd(e){return e.setBottomTerminalHeight}function Gd(e){return e.setBottomTerminalOpen}var Kd=260,qd=260,Jd=500,Yd=e=>Math.min(Jd,Math.max(qd,e)),Xd=({isOpen:e,isMobile:t,children:n,className:r,topBar:i})=>{let{t:a}=Zt(),o=q(e=>e.sidebarWidth),s=q(e=>e.setSidebarWidth),[c,l]=Q.useState(!1),u=Q.useRef(0),d=Q.useRef(o||Kd),f=Q.useRef(null),p=Q.useRef(null),m=Q.useRef(null),h=Q.useRef(null),g=K(e=>{let t=m.current;t&&(t.style.width=`${e}px`,t.style.minWidth=`${e}px`,t.style.maxWidth=`${e}px`,h.current&&(h.current.style.width=`${e}px`))});if(Q.useEffect(()=>{t&&c&&l(!1)},[t,c]),Q.useEffect(()=>{c||(f.current=null,p.current=null)},[c]),t)return null;let _=Math.min(Jd,Math.max(qd,o||Kd)),v=e?_:0,y=t=>{if(e){try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}p.current=t.pointerId,l(!0),u.current=t.clientX,d.current=v,f.current=v,g(v),t.preventDefault()}},b=e=>{if(t||!c||p.current!==e.pointerId)return;let n=e.clientX-u.current,r=Yd(d.current+n);f.current!==r&&(f.current=r,g(r))},x=e=>{if(p.current!==e.pointerId||t)return;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}let n=Yd(f.current??v);p.current=null,f.current=null,l(!1),s(n)},S=c?f.current??v:v;return(0,$.jsxs)(`aside`,{ref:m,className:X(`relative flex h-full overflow-hidden yuri-layout-divider-r will-change-[width] motion-reduce:transition-none`,`bg-sidebar yuri-vibrancy-surface`,!e&&`border-r-0`,r),style:{width:`${S}px`,minWidth:`${S}px`,maxWidth:`${S}px`,overflowX:`clip`,transitionProperty:c?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!e||v===0,children:[e&&(0,$.jsx)(`div`,{className:X(`absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors`,c&&`bg-[var(--interactive-border)]`),onPointerDown:y,onPointerMove:b,onPointerUp:x,onPointerCancel:x,role:`separator`,"aria-orientation":`vertical`,"aria-label":a(`sidebar.resize.leftPanelAria`)}),(0,$.jsxs)(`div`,{ref:h,className:X(`relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,c&&`pointer-events-none`,!e&&`pointer-events-none select-none opacity-0`),style:{width:`${c?S:_}px`,overflowX:`hidden`},"aria-hidden":!e,children:[i,(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,$.jsx)(po,{children:n})})]})]})},Zd=()=>{let e=(0,du.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={height:`var(--yuri-header-height, 3rem)`},e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-drag shrink-0`,style:{width:`var(--yuri-titlebar-left-inset, 0.75rem)`}}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex shrink-0`,style:t,children:[n,(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-no-drag shrink-0`,style:{width:`calc(var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`}}),(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-drag flex-1`})]}),e[2]=r):r=e[2],r},Qd=e=>{let t=(0,du.c)(26),{className:n}=e,{t:r}=Zt(),i=q($d),a=Bs(ef).trim(),o=a.split(/\s+/).filter(Boolean),s=o.includes(`Yuri`),c=o.some(tf);if(Q.useEffect(()=>{c&&ia()},[c]),o.length===0)return null;let l;t[0]===n?l=t[1]:(l=X(`flex min-w-0 items-center overflow-hidden pb-2 pt-1`,n),t[0]=n,t[1]=l);let u=Y,d;t[2]===r?d=t[3]:(d=r(`layout.brand.editName`),t[2]=r,t[3]=d);let f;t[4]===r?f=t[5]:(f=r(`layout.brand.editName`),t[4]=r,t[5]=f);let p;t[6]===i?p=t[7]:(p=()=>i(`appearance`,`appearance.sidebar-brand`),t[6]=i,t[7]=p);let m=o.join(` `),h=a.includes(`Yuri`)?`items-center`:`items-baseline`,g;t[8]===h?g=t[9]:(g=X(`inline-flex min-w-0 gap-[0.28em] overflow-hidden whitespace-nowrap text-foreground`,h),t[8]=h,t[9]=g);let _;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(_={fontFamily:`"Syne", var(--font-sans, system-ui, sans-serif)`,fontSize:`1.0625rem`,fontWeight:700,letterSpacing:`0.08em`,lineHeight:1},t[10]=_):_=t[10];let v=a.includes(`Yuri`)?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0 self-center`,children:(0,$.jsx)(fo,{width:24,height:24,className:`size-6`})}):null,y=o.map((e,t)=>(0,$.jsx)(`span`,{"aria-hidden":`true`,className:X(`inline-flex shrink-0 items-baseline`,!s&&t>0&&`text-primary`),children:e===`Yuri`?(0,$.jsx)(Dl,{width:`2.44814cap`}):e},t)),b;t[11]!==g||t[12]!==_||t[13]!==v||t[14]!==y||t[15]!==m?(b=(0,$.jsxs)(`span`,{role:`img`,"aria-label":m,className:g,style:_,children:[v,y]}),t[11]=g,t[12]=_,t[13]=v,t[14]=y,t[15]=m,t[16]=b):b=t[16];let x;t[17]!==u||t[18]!==b||t[19]!==d||t[20]!==f||t[21]!==p?(x=(0,$.jsx)(u,{variant:`ghost`,size:`xs`,className:`app-region-no-drag min-w-0 max-w-full justify-start`,"aria-label":d,title:f,onClick:p,children:b}),t[17]=u,t[18]=b,t[19]=d,t[20]=f,t[21]=p,t[22]=x):x=t[22];let S;return t[23]!==l||t[24]!==x?(S=(0,$.jsx)(`div`,{className:l,children:x}),t[23]=l,t[24]=x,t[25]=S):S=t[25],S};function $d(e){return e.openSettingsAtItem}function ef(e){return e.sidebarBrandName}function tf(e){return e!==`Yuri`}var nf=`app-region-no-drag inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/75 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary hover:bg-interactive-hover hover:text-foreground transition-colors`,rf=()=>{let e=(0,du.c)(50),{t}=Zt(),n=mn(af),r=dn(of),i=n?.hostId&&r?.projectId===n.id&&r.location.hostId===n.hostId&&(!n.hubId||r.location.hubId===n.hubId)?r:null,a;e[0]!==n||e[1]!==i?(a=i?ee(i.location):n?.hostId&&n.hubId?ee({hubId:n.hubId,hostId:n.hostId,directory:n.path}):n?.path,e[0]=n,e[1]=i,e[2]=a):a=e[2];let o=a,s=q(sf),c=q(cf),l=q(lf),u=q(uf),d=Bs(df),f=Q.useRef(null),p=to(Qa(`toggle_sidebar`,u)),{usesFramelessChrome:m,side:h}=$s(),g;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=v(),e[3]=g):g=e[3];let _=g,y=!_||!s||!d,b;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(b=!w()&&!_&&re(),e[4]=b):b=e[4];let x=b,S=pf,C,T;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{if(typeof document>`u`)return;let e=f.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect().width;document.documentElement.style.setProperty(`--yuri-titlebar-controls-width`,`${Math.round(t)}px`)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},T=[],e[5]=C,e[6]=T):(C=e[5],T=e[6]),Q.useEffect(C,T);let E=o||void 0,D=x&&s?`${c||260}px`:void 0,O;e[7]===D?O=e[8]:(O={height:`var(--yuri-header-height, 3rem)`,paddingLeft:`var(--yuri-titlebar-left-inset, 0.75rem)`,width:D},e[7]=D,e[8]=O);let k=x&&s&&`w-full justify-between`,A;e[9]===k?A=e[10]:(A=X(`flex items-center gap-2`,k),e[9]=k,e[10]=A);let j;e[11]===s?j=e[12]:(j=x&&s?(0,$.jsx)(Qd,{className:`flex min-w-0 items-center p-0 pl-1.5`}):null,e[11]=s,e[12]=j);let M;e[13]!==m||e[14]!==h?(M=m&&h===`left`?(0,$.jsx)(Zs,{visible:!0,position:`left`}):null,e[13]=m,e[14]=h,e[15]=M):M=e[15];let N;e[16]!==t||e[17]!==m?(N=m?(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:S,"aria-label":t(`header.actions.openAppMenuAria`),className:X(nf,`shrink-0`),children:(0,$.jsx)(Z,{name:`menu-2`,className:`h-[18px] w-[18px]`})})}),(0,$.jsx)(Ea,{children:(0,$.jsx)(`p`,{children:t(`header.actions.openAppMenu`)})})]}):null,e[16]=t,e[17]=m,e[18]=N):N=e[18];let P;e[19]===y?P=e[20]:(P=y?(0,$.jsx)(pl,{}):null,e[19]=y,e[20]=P);let F=Oa,I;e[21]===t?I=e[22]:(I=t(`header.actions.openSessionsAria`),e[21]=t,e[22]=I);let L,R;e[23]===Symbol.for(`react.memo_cache_sentinel`)?(L=X(nf,`group shrink-0`),R=(0,$.jsx)(Z,{name:`layout-left-rounded`,className:`size-4 text-foreground/55 transition-colors group-hover:text-foreground group-focus-visible:text-foreground`}),e[23]=L,e[24]=R):(L=e[23],R=e[24]);let z;e[25]!==I||e[26]!==l?(z=(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:l,"aria-label":I,className:L,children:R})}),e[25]=I,e[26]=l,e[27]=z):z=e[27];let B=Ea,V=t(`header.actions.openSessionsWithShortcut`,{shortcut:p}),te;e[28]===V?te=e[29]:(te=(0,$.jsx)(`p`,{children:V}),e[28]=V,e[29]=te);let ne;e[30]!==B||e[31]!==te?(ne=(0,$.jsx)(B,{children:te}),e[30]=B,e[31]=te,e[32]=ne):ne=e[32];let ie;e[33]!==F||e[34]!==z||e[35]!==ne?(ie=(0,$.jsxs)(F,{children:[z,ne]}),e[33]=F,e[34]=z,e[35]=ne,e[36]=ie):ie=e[36];let ae;e[37]!==P||e[38]!==ie?(ae=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[P,ie]}),e[37]=P,e[38]=ie,e[39]=ae):ae=e[39];let oe;e[40]!==A||e[41]!==j||e[42]!==M||e[43]!==N||e[44]!==ae?(oe=(0,$.jsxs)(`div`,{ref:f,className:A,children:[j,M,N,ae]}),e[40]=A,e[41]=j,e[42]=M,e[43]=N,e[44]=ae,e[45]=oe):oe=e[45];let H;return e[46]!==oe||e[47]!==E||e[48]!==O?(H=(0,$.jsx)(`div`,{"data-titlebar-location":E,className:`app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2`,style:O,children:oe}),e[46]=oe,e[47]=E,e[48]=O,e[49]=H):H=e[49],H};function af(e){return e.projects.find(t=>t.id===e.activeProjectId)}function of(e){return e.remoteSession}function sf(e){return e.isSidebarOpen}function cf(e){return e.sidebarWidth}function lf(e){return e.toggleSidebar}function uf(e){return e.shortcutOverrides}function df(e){return e.sidebarBrandName.trim().length>0}function ff(e){console.warn(`[titlebar] failed to open app menu`,e)}function pf(e){let t=e.currentTarget.getBoundingClientRect();P(`desktop_show_app_menu`,{x:t.left,y:t.bottom}).catch(ff)}var mf=(e,t)=>{let n=jt(t,e);return!n||n===`.`||n===t?0:n.split(`/`).filter(Boolean).length},hf=(e,t,n=10)=>{let r=At(e);if(!r||n<1)return[];let i=new Set,a=[];for(let e of Object.values(t))if(e)for(let t of e){if(t.type!==`directory`)continue;let e=At(t.path);if(!e||i.has(e))continue;let o=mf(r,e);o<1||o>n||(i.add(e),a.push(e))}return a},gf=e=>e.some(e=>!!At(e)),_f=(e,t)=>{let n=new Set(t.map(e=>At(e)).filter(Boolean));return e.filter(e=>!n.has(e))},vf=(e,t,n)=>t.length===0?e.length===0:_f(e,t).length>0?!1:t.every(e=>n.has(At(e))),yf=So(()=>Pt(()=>import(`./ToolOutputDialog-C03nGQvh.js`).then(e=>e.n),__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]))),bf=e=>{let t=Cf(e);if(!t)return``;if(t===`/`||/^[A-Za-z]:\/$/.test(t))return t;let n=t.lastIndexOf(`/`);if(n<0)return t;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?`${r}/`:r},xf=e=>{let t=(0,du.c)(8),{label:n,iconDataUrl:r}=e,[i,a]=Q.useState(!1),o;t[0]===n?o=t[1]:(o=n.trim().slice(0,1).toUpperCase()||`?`,t[0]=n,t[1]=o);let s=o;if(r&&!i){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>a(!0),t[2]=e):e=t[2];let n;return t[3]===r?n=t[4]:(n=(0,$.jsx)(`img`,{src:r,alt:``,className:`size-4 rounded-sm`,onError:e}),t[3]=r,t[4]=n),n}let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=X(`size-4 rounded-sm flex items-center justify-center`,`bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground`),t[5]=c):c=t[5];let l;return t[6]===s?l=t[7]:(l=(0,$.jsx)(`span`,{className:c,children:s}),t[6]=s,t[7]=l),l},Sf=e=>e.slice().sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1),Cf=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+/g,`/`);n&&!r.startsWith(`//`)&&(r=`/${r}`);let i=r===`/`,a=/^[A-Za-z]:\/$/.test(r);return!i&&!a&&(r=r.replace(/\/+$/,``)),r},wf=e=>e.startsWith(`/`)||e.startsWith(`//`)||/^[A-Za-z]:\//.test(e),Tf=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,Ef=(e,t)=>{let n=Cf(t),r=Cf(e);if(!n||!r)return!1;let i=Tf(n),a=Tf(r);return a===i||a.startsWith(`${i}/`)},Df=(e,t)=>{let n=Cf(t),r=Cf(e);if(!Ef(r,n))return[];let i=r.slice(n.length).replace(/^\//,``).split(`/`),a=[],o=n;for(let e=0;e<i.length-1;e++)o=o?`${o}/${i[e]}`:i[e],a.push(o);return a},Of=(e,t)=>{if(!t)return``;let n=Cf(t);if(!e||!Ef(n,e))return n;let r=n.slice(e.length);return r.startsWith(`/`)?r.slice(1):r},kf=new Set([`node_modules`]),Af=e=>{let t=(0,du.c)(3),{status:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={open:`var(--status-info)`,modified:`var(--status-warning)`,"git-modified":`var(--status-warning)`,"git-added":`var(--status-success)`,"git-deleted":`var(--status-error)`},t[0]=r):r=t[0];let i=r[n],a;return t[1]===i?a=t[2]:(a=(0,$.jsx)(`span`,{className:`size-2 rounded-full`,style:{backgroundColor:i}}),t[1]=i,t[2]=a),a},jf=e=>{let t=(0,du.c)(11),{name:n}=e,r=Q.useRef(null),i=Q.useRef(null),[a,o]=Q.useState(!1),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=r.current,t=i.current;if(!e||!t)return;let n=()=>{o(t.scrollWidth>e.clientWidth+1)};n();let a=new ResizeObserver(n);return a.observe(e),a.observe(t),()=>{a.disconnect()}},t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=[n],t[1]=n,t[2]=c),Q.useLayoutEffect(s,c);let l;t[3]===n?l=t[4]:(l=(0,$.jsx)(`span`,{ref:i,"aria-hidden":`true`,className:`invisible absolute whitespace-nowrap`,children:n}),t[3]=n,t[4]=l);let u;t[5]!==n||t[6]!==a?(u=a?(0,$.jsxs)(`span`,{className:`open-file-name-marquee-track`,children:[(0,$.jsx)(`span`,{className:`open-file-name-marquee-item`,children:n}),(0,$.jsx)(`span`,{className:`open-file-name-marquee-item`,"aria-hidden":`true`,children:n})]}):(0,$.jsx)(`span`,{className:`block min-w-0 truncate`,children:n}),t[5]=n,t[6]=a,t[7]=u):u=t[7];let d;return t[8]!==l||t[9]!==u?(d=(0,$.jsxs)(`span`,{ref:r,className:`relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap`,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10],d},Mf=e=>kf.has(e),Nf=e=>{let t=Cf(e);return t===`node_modules`||t.endsWith(`/node_modules`)||t.includes(`/node_modules/`)},Pf=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`is a directory`)||t.includes(`eisdir`)},Ff=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`file not found`)||t.includes(`enoent`)||t.includes(`no such file`)||t.includes(`does not exist`)},If=2e5,Lf=`yuri:files:auto-save-enabled`,Rf=e=>{let t=0,n=0;for(let r=0;r<e.length;r+=1)e.charCodeAt(r)===10&&(r>0&&e.charCodeAt(r-1)===13?t+=1:n+=1);return t>n?`\r
|
|
4
4
|
`:`
|
|
5
5
|
`},zf=e=>e.replace(/\r\n/g,`
|
|
6
6
|
`).replace(/\r/g,`
|
|
@@ -143,7 +143,7 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,p as r,t
|
|
|
143
143
|
`),n=A.map(e=>{let t=new Date(e.ts).toISOString(),n=e.details?`\n${e.details}`:``;return`[${t}] [${e.level}] ${e.message}${n}`}).join(`
|
|
144
144
|
`);Pn(`${t}${n}`).then(e=>{e.ok?J.success(a(`contextPanel.preview.console.copied`)):J.error(a(`contextPanel.preview.console.copyFailed`))})},[A,_e,e,a]),Te=Q.useCallback(()=>{let t=ie;if(!t){J.error(a(`contextPanel.preview.console.attachNoSession`));return}let n=[`Preview URL: ${e||_e||``}`,`Events: ${A.length}`,``].join(`
|
|
145
145
|
`),r=A.map(e=>{let t=new Date(e.ts).toISOString(),n=e.details?`\n${e.details}`:``;return`[${t}] [${e.level}] ${e.message}${n}`}).join(`
|
|
146
|
-
`);te({sessionKey:t,source:`preview-console`,fileLabel:e||_e||`preview`,startLine:1,endLine:Math.max(1,A.length),code:`${n}${r}`,language:`text`,text:a(`contextPanel.preview.console.attachAnnotation`)}),J.success(a(`contextPanel.preview.console.attached`))},[te,A,ie,_e,e,a]),[Ee,De]=Q.useState(`unknown`),Oe=Q.useRef(0),ke=Q.useRef(0);Q.useEffect(()=>{if(!de){De(`unknown`),Oe.current=0,ke.current=0;return}let e=!1;return Oe.current||(Oe.current=Date.now(),ke.current=0),De(`unknown`),(async()=>{let t=await(async()=>{try{let e=new URL(de,window.location.href),t=n?.location.hostId?O(n.location.hostId,`/api`).slice(0,-4):``,r=`${t&&e.pathname.startsWith(t+`/`)?e.pathname.slice(t.length):e.pathname}${e.search}`;return await i(r,{method:`GET`,credentials:`include`,cache:`no-store`,redirect:`manual`})}catch{return null}})();if(e)return;if(!t){De(`unreachable`);return}if(t.status===403||t.status===404){Hg.delete(ce),_({status:`loading`}),p();return}if(t.status!==502){De(`reachable`);return}let r=Oe.current||Date.now();if(Date.now()-r<15e3){De(`starting`),ke.current+=1;let t=ke.current,n=Math.min(2e3,250*2**Math.min(4,t));setTimeout(()=>{e||d()},n).unref?.();return}De(`unreachable`)})(),()=>{e=!0}},[n,i,ce,de,u]);let Ae=H&&g.status===`ready`&&(Ee===`unknown`||Ee===`starting`),je=H&&g.status===`ready`&&Ee===`unreachable`,Me=Q.useCallback(e=>{if(!H||g.status!==`ready`||typeof window>`u`)return;let t=e.currentTarget.contentWindow;if(t)try{let e=t.location,n=K_(_e||de);if(e.origin!==n||e.pathname.startsWith(g.proxyBasePath))return;let r=`${g.proxyBasePath}${e.pathname}${e.search}${e.hash}`;t.location.replace(r)}catch{}},[_e,H,de,g]);return(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border/40 bg-[var(--surface-background)] px-2 py-1`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1 truncate typography-micro text-muted-foreground`,title:ve||e,children:ve||e||a(`contextPanel.preview.empty`)}),(0,$.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 w-7 p-0`,onClick:()=>d(),title:a(`contextPanel.preview.actions.reload`),"aria-label":a(`contextPanel.preview.actions.reload`),disabled:!_e,children:(0,$.jsx)(Z,{name:`refresh`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 w-7 p-0`,onClick:()=>{le&&Bt(n?.location.hostId?_e:le)},title:a(`contextPanel.preview.actions.openExternal`),"aria-label":a(`contextPanel.preview.actions.openExternal`),disabled:n?.location.hostId?!_e:!le,children:(0,$.jsx)(Z,{name:`external-link`,className:`h-3.5 w-3.5`})}),H?(0,$.jsx)(Y,{type:`button`,size:`sm`,variant:M?`secondary`:`ghost`,className:`h-7 gap-1 px-2`,onClick:()=>N(e=>!e),title:a(`contextPanel.preview.inspect.toggle`),"aria-label":a(`contextPanel.preview.inspect.toggle`),disabled:!S,children:(0,$.jsx)(Z,{name:`cursor`,className:`h-3.5 w-3.5`})}):null,H?(0,$.jsxs)(Y,{type:`button`,size:`sm`,variant:w?`secondary`:`ghost`,className:`h-7 gap-1 px-2`,onClick:()=>T(e=>!e),title:a(S?`contextPanel.preview.console.open`:`contextPanel.preview.console.waiting`),"aria-label":a(S?`contextPanel.preview.console.open`:`contextPanel.preview.console.waiting`),disabled:!S&&A.length===0,children:[(0,$.jsx)(Z,{name:`terminal-box`,className:`h-3.5 w-3.5`}),Se>0?(0,$.jsx)(`span`,{className:`typography-micro text-status-error`,children:Se}):null]}):null]}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 bg-background`,children:[Ae?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground`,children:[(0,$.jsx)(`div`,{children:a(`contextPanel.preview.startingServer`)}),(0,$.jsx)(`div`,{className:`text-xs opacity-70`,children:a(`contextPanel.preview.startingServerHint`)})]}):je?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground`,children:[(0,$.jsx)(`div`,{children:a(`contextPanel.preview.upstreamUnreachable`)}),(0,$.jsx)(`div`,{className:`text-xs opacity-70`,children:a(`contextPanel.preview.upstreamUnreachableHint`)}),(0,$.jsx)(Y,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>d(),children:a(`contextPanel.preview.actions.retry`)})]}):_e&&(!H||Ee===`reachable`)?(0,$.jsxs)(`div`,{className:`relative h-full w-full`,children:[(0,$.jsx)(`iframe`,{ref:b,src:_e,title:a(`contextPanel.preview.iframeTitle`),className:`h-full w-full border-0`,style:{colorScheme:W},onLoad:Me,sandbox:H?`allow-scripts allow-same-origin allow-forms allow-popups allow-downloads`:`allow-scripts allow-forms`},`${_e}:${u}`),M&&P?(0,$.jsx)(`div`,{className:`pointer-events-none absolute rounded-sm border-2 border-[var(--interactive-focus-ring)] bg-[var(--interactive-focus-ring)]/35`,style:{left:P.bounds.x,top:P.bounds.y,width:P.bounds.width,height:P.bounds.height},children:(0,$.jsxs)(`div`,{className:`absolute -top-6 left-0 max-w-64 truncate rounded bg-[var(--surface-elevated)] px-2 py-0.5 typography-micro text-foreground shadow`,children:[P.tag,P.text?` · ${P.text}`:``]})}):null]}):ye?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-sm text-muted-foreground`,children:a(`contextPanel.preview.loading`)}):be?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 px-6 text-sm text-muted-foreground`,children:[(0,$.jsx)(`div`,{children:a(`contextPanel.preview.proxyError`)}),g.status===`error`?(0,$.jsx)(`div`,{className:`text-center text-xs opacity-70`,children:g.message}):null,(0,$.jsx)(Y,{type:`button`,size:`sm`,onClick:()=>p(),children:a(`contextPanel.preview.actions.retry`)})]}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-sm text-muted-foreground`,children:a(`contextPanel.preview.invalidUrl`)}),w?(0,$.jsxs)(`div`,{className:`absolute inset-x-3 bottom-3 z-10 max-h-[45%] overflow-hidden rounded-xl border border-border/70 bg-[var(--surface-elevated)] shadow-lg`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/50 px-3 py-2`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:a(`contextPanel.preview.console.title`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Y,{type:`button`,size:`xs`,variant:`ghost`,onClick:Te,disabled:A.length===0,children:a(`contextPanel.preview.console.attach`)}),(0,$.jsx)(Y,{type:`button`,size:`xs`,variant:`ghost`,onClick:we,disabled:A.length===0,children:a(`contextPanel.preview.console.copy`)}),(0,$.jsx)(Y,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>j([]),disabled:A.length===0,children:a(`contextPanel.preview.console.clear`)})]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1 border-b border-border/30 px-3 py-1.5`,children:[`all`,`errors`,`warnings`,`logs`].map(e=>(0,$.jsx)(Y,{type:`button`,size:`xs`,variant:E===e?`secondary`:`ghost`,onClick:()=>D(e),children:a(e===`all`?`contextPanel.preview.console.filter.all`:e===`errors`?`contextPanel.preview.console.filter.errors`:e===`warnings`?`contextPanel.preview.console.filter.warnings`:`contextPanel.preview.console.filter.logs`)},e))}),(0,$.jsx)(`div`,{className:`max-h-64 overflow-auto p-2 typography-code text-xs`,children:A.length===0?(0,$.jsx)(`div`,{className:`px-2 py-3 text-muted-foreground`,children:a(`contextPanel.preview.console.empty`)}):Ce.length===0?(0,$.jsx)(`div`,{className:`px-2 py-3 text-muted-foreground`,children:a(`contextPanel.preview.console.noFilteredEvents`)}):Ce.map(e=>(0,$.jsx)(`div`,{className:`border-b border-border/30 px-2 py-1 last:border-b-0`,children:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:X(`shrink-0 uppercase`,e.level===`error`||e.level===`runtime`||e.level===`resource`?`text-status-error`:e.level===`warn`?`text-status-warning`:`text-muted-foreground`),children:e.level}),(0,$.jsx)(`span`,{className:`min-w-0 break-words text-foreground`,children:e.message})]})},e.id))})]}):null]})]})},Z_=()=>typeof window<`u`&&!!window.__YURI_ELECTRON__,Q_=({initialUrl:e,directory:t,tabID:n})=>{let i=_t()?.entry,a=i?.fetch??h,{t:s}=Zt(),u=Q.useRef(null),d=q(e=>e.setContextPanelTabTargetPath),f=Mg(e),p=f===`about:blank`?``:f,[g,_]=Q.useState(p),[v,y]=Q.useState(p),[b,x]=Q.useState(p),[S,C]=Q.useState(()=>p?[p]:[]),[w,T]=Q.useState(()=>p?0:-1),[E,D]=Q.useReducer(e=>e+1,0),[O,A]=Q.useState(!!p),[j,M]=Q.useState(!1),[N,P]=Q.useState(null),[F,I]=Q.useState({status:`idle`}),[L,R]=Q.useState(``),z=cr(e=>e.currentSessionId),B=cr(e=>e.newSessionDraft?.open),V=dn(e=>e.remoteSession),te=i&&V&&ee(V.location)===i.key?V:null,ne=i?.location.hostId?te?.sessionId??null:z,re=i?.location.hostId?!te?.sessionId:B,ie=Zi(e=>e.addDraft),ae=Or(e=>e.addAttachedFile),oe=K(async e=>{if(!i?.location.hostId)return ae(e);let t={transportIdentity:l(),location:i.location},n=ne?lt(t,ne):st(t,`remote-new-session`);await Or.getState().addDraftLocalAttachment(n,e)}),H=i?.location.hostId?k(i.location,ne??`draft`):ne??(re?`draft`:null),se=Q.useCallback(e=>{!e||e===`about:blank`||!t||!n||d(t,n,e)},[t,n,d]),U=Q.useCallback((e,t)=>{let n=Mg(e),r=n===`about:blank`?``:n;y(r),_(r),t?.inFrame?A(!1):(x(r),A(!!r)),se(r),C(e=>{if(!r)return T(-1),[];if(t?.replaceHistory)return e;let n=w>=0?e.slice(0,w+1):[];if(n[n.length-1]===r)return T(n.length-1),n;let i=[...n,r];return T(i.length-1),i})},[w,se]),ce=Q.useRef(v);ce.current=v,Q.useEffect(()=>{let t=Ng(e,ce.current);t!==null&&U(t)},[e,U]);let W=Q.useCallback(e=>{let t=S[e];t&&(T(e),y(t),x(t),_(t),A(!0),se(t))},[S,se]),le=Q.useCallback(()=>{if(v){A(!0);try{u.current?.contentWindow?.location.reload()}catch{D()}}},[v]);Q.useEffect(()=>{if(!b){I({status:`idle`});return}let e=i?.location.hostId?`${i.key}|${i.connectionGeneration}|${Kg(b)}`:Kg(b),t=Gg(e);if(t?.previewToken)return I({status:`ready`,proxyBasePath:t.proxyBasePath,previewToken:t.previewToken,expiresAt:t.expiresAt}),()=>{i?.location.hostId&&Hg.delete(e)};t&&Hg.delete(e);let n=!1;return I({status:`loading`}),A(!0),(async()=>{try{let t=await a(`/api/preview/targets`,{method:`POST`,headers:{"Content-Type":`application/json`,...i?.location.hostId?{"x-opencode-directory":i.location.directory}:{}},credentials:`include`,body:JSON.stringify({url:b,allowExternal:!0})});if(!t.ok){let e=await t.json().catch(()=>({})),r=typeof e?.error==`string`?e.error:`HTTP ${t.status}`;n||(I({status:`error`,message:r}),A(!1));return}let r=await t.json(),o=typeof r.proxyBasePath==`string`&&G_(i,r.proxyBasePath)?W_(i,r.proxyBasePath):``,c=typeof r.previewToken==`string`?r.previewToken:``,l=typeof r.expiresAt==`number`?r.expiresAt:0;if(!G_(i,o)||!c||!Number.isFinite(l)||l<=Date.now()){n||(I({status:`error`,message:s(`contextPanel.preview.proxyError`)}),A(!1));return}if(n)return;i?.sdk(),Hg.set(e,{proxyBasePath:o,previewToken:c,expiresAt:l}),n||I({status:`ready`,proxyBasePath:o,previewToken:c,expiresAt:l})}catch(e){if(!n){let t=e instanceof Error?e.message:String(e);I({status:`error`,message:t}),A(!1)}}})(),()=>{n=!0,i?.location.hostId&&Hg.delete(e)}},[i,a,b,E,s]);let ue=b&&F.status===`ready`?`${F.proxyBasePath}|${F.previewToken||``}|${E}`:``;Q.useEffect(()=>{if(!ue){R(``);return}let e=!1;return R(``),r(m()).then(t=>{!e&&t&&R(ue)}).catch(()=>{}),()=>{e=!0}},[ue]);let de=Q.useMemo(()=>{if(L!==ue||!b||F.status!==`ready`)return``;try{let e=new URL(b),t=e.pathname||`/`,n=new URLSearchParams(e.search);n.delete(`yuri_url_token`),n.delete(`yuri_client_token`),n.set(`yuriPreview`,String(E)),n.set(`yuri_preview_token`,F.previewToken||``);let r=n.toString();return c().authenticatedAsset(W_(i,`${F.proxyBasePath}${t}${r?`?${r}`:``}${e.hash}`))}catch{return``}},[i,b,F,ue,E,L]),fe=o()&&Ic(),[pe,me]=Q.useState(``);Q.useEffect(()=>{if(!fe){me(``);return}let e=!1;return me(``),pc().then(t=>{!e&&t&&me(t)}).catch(()=>{e||me(``)}),()=>{e=!0}},[fe,ue]);let he=de?kl({relayActive:fe,gatewayOrigin:pe||null,authenticatedAssetUrl:de}):``,ge=fe&&!!de&&!pe,_e=ge?``:he||(F.status===`error`&&!fe&&!i?.location.hostId?b:``),ve=Q.useCallback(e=>{if(!e||!b||F.status!==`ready`)return``;try{let t=new URL(e,window.location.origin),n=F.proxyBasePath.endsWith(`/`)?F.proxyBasePath.slice(0,-1):F.proxyBasePath,r=K_(_e||de);if(!(t.origin===window.location.origin||r&&t.origin===r)||!t.pathname.startsWith(n))return``;let i=t.pathname.slice(n.length)||`/`,a=new URL(b).origin;return Y_(new URL(`${i}${t.search}${t.hash}`,a).toString())}catch{return``}},[_e,b,de,F]),ye=Q.useCallback(e=>{if(!e||!b||F.status!==`ready`)return``;try{let t=new URL(e,window.location.origin),n=new URL(b).origin,r=K_(_e||de);if(!(t.origin===window.location.origin||r&&t.origin===r)||n===window.location.origin)return``;let i=F.proxyBasePath.endsWith(`/`)?F.proxyBasePath.slice(0,-1):F.proxyBasePath;return t.pathname.startsWith(i)?``:Y_(new URL(`${t.pathname}${t.search}${t.hash}`,n).toString())}catch{return``}},[_e,b,de,F]),be=Q.useCallback(e=>{let t=u.current?.contentWindow;t&&q_(t,_e||de,{source:`yuri-preview-parent`,version:1,type:`set-inspect-mode`,enabled:e})},[_e,de]),xe=Q.useCallback(async e=>{let t=H;if(!t){J.error(s(`contextPanel.preview.inspect.attachNoSession`));return}let n=u.current,r=n?.contentWindow,a=n?.getBoundingClientRect(),o={width:Number.isFinite(r?.innerWidth)?r?.innerWidth??a?.width??0:a?.width??0,height:Number.isFinite(r?.innerHeight)?r?.innerHeight??a?.height??0:a?.height??0},c=n?await zg(n,e,i):null,l=!!c;c&&await oe(c),ie({sessionKey:t,source:`preview-annotation`,fileLabel:v||`browser`,startLine:1,endLine:1,code:Rg({pageUrl:v,viewport:o,devicePixelRatio:window.devicePixelRatio||1,target:e,screenshotAttached:l,intro:s(l?`contextPanel.preview.inspect.attachAnnotationWithScreenshot`:`contextPanel.preview.inspect.attachAnnotation`)}),language:`markdown`,text:``}),J.success(s(`contextPanel.preview.inspect.attached`))},[i,oe,ie,H,v,s]),Se=Q.useCallback(()=>{let e=u.current;P(null),be(!1),e&&H_(e,B_).catch(()=>{})},[be]);Q.useEffect(()=>{if(!j)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopImmediatePropagation(),M(!1),Se())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[Se,j]),Q.useEffect(()=>()=>Se(),[Se]),Q.useEffect(()=>{let e=e=>{if(e.source!==u.current?.contentWindow)return;let t=e.data;if(!(!t||t.source!==`yuri-preview-bridge`||t.version!==1)){if(t.type===`ready`){let e=typeof t.url==`string`?t.url:``,n=ve(e);n&&n!==v&&U(n,{inFrame:!0});return}if(t.type===`hover`){P(Lg(t.target)?t.target:null);return}if(t.type===`select`&&Lg(t.target)){P(null),M(!1),be(!1),xe(t.target);return}if(t.type===`navigate-preview`){let e=typeof t.url==`string`?t.url:``,n=ye(e);if(n){U(n);return}e&&U(e)}}};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[U,xe,v,ve,ye,be]);let Ce=Q.useCallback(()=>{let e=u.current;if(!(!e||!v)){if(j){M(!1),Se();return}if(de){P(null),M(!0),be(!0);return}M(!0),(async()=>{try{let t=await H_(e,z_);if(M(!1),!t||!Lg(t))return;await xe(t)}catch{M(!1),J.error(s(`contextPanel.browser.inspectUnavailable`))}})()}},[xe,Se,v,j,be,de,s]),we=Q.useCallback(()=>{try{let e=u.current?.contentWindow?.location.href||``,t=ye(e);if(t){U(t,{inFrame:!0});return}}catch{}A(!1),j&&de&&be(!0)},[U,ye,j,be,de]);return(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col bg-background`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border/40 bg-[var(--surface-background)] px-2 py-1`,children:[(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:w<=0,onClick:()=>W(w-1),children:(0,$.jsx)(Z,{name:`arrow-left`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:w<0||w>=S.length-1,onClick:()=>W(w+1),children:(0,$.jsx)(Z,{name:`arrow-right`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:!v,onClick:le,children:(0,$.jsx)(Z,{name:`refresh`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault(),U(g)},children:(0,$.jsx)(`input`,{value:g,onChange:e=>_(e.target.value),className:`h-7 w-full rounded-md border border-border/50 bg-[var(--surface-elevated)] px-2 typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]`,"aria-label":s(`contextPanel.browser.addressAria`)})}),(0,$.jsx)(Y,{type:`button`,variant:j?`secondary`:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:!v,onClick:Ce,title:s(`contextPanel.preview.inspect.toggle`),"aria-label":s(`contextPanel.preview.inspect.toggle`),children:(0,$.jsx)(Z,{name:`cursor`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:i?.location.hostId?!_e:!v,onClick:()=>void Bt(i?.location.hostId?_e:v),children:(0,$.jsx)(Z,{name:`external-link`,className:`h-3.5 w-3.5`})})]}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 bg-background`,children:[_e?(0,$.jsxs)(`div`,{className:`absolute inset-0`,children:[(0,$.jsx)(`iframe`,{ref:u,src:_e,title:s(`contextPanel.browser.empty`),className:`absolute inset-0 h-full w-full border-0 bg-background`,allow:`clipboard-read; clipboard-write; fullscreen`,allowFullScreen:!0,onLoad:we},`${n}:${E}`),j&&N?(0,$.jsx)(`div`,{className:`pointer-events-none absolute rounded-sm border-2 border-[var(--interactive-focus-ring)] bg-[var(--interactive-focus-ring)]/35`,style:{left:N.bounds.x,top:N.bounds.y,width:N.bounds.width,height:N.bounds.height},children:(0,$.jsxs)(`div`,{className:`absolute -top-6 left-0 max-w-64 truncate rounded bg-[var(--surface-elevated)] px-2 py-0.5 typography-micro text-foreground shadow`,children:[N.tag,N.text?` · ${N.text}`:``]})}):null]}):F.status===`error`&&i?.location.hostId?(0,$.jsxs)(`div`,{role:`alert`,className:`absolute inset-0 flex flex-col items-center justify-center gap-3 p-6 text-center typography-meta text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:s(`contextPanel.preview.proxyError`)}),(0,$.jsx)(`span`,{children:F.message}),(0,$.jsx)(Y,{type:`button`,size:`sm`,onClick:()=>D(),children:s(`contextPanel.preview.actions.retry`)})]}):(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-6 bg-background p-6 text-center`,children:[(0,$.jsx)(fo,{width:140,height:140,className:`opacity-20`}),(0,$.jsx)(`span`,{className:`typography-ui-header text-muted-foreground`,children:s(`contextPanel.browser.empty`)}),(0,$.jsx)(`span`,{className:`max-w-sm typography-micro text-muted-foreground`,children:s(`contextPanel.browser.emptyHint`)}),(0,$.jsx)(`span`,{className:`max-w-md typography-micro leading-relaxed text-status-warning/70`,children:s(`contextPanel.browser.trustNotice`)})]}),O||ge?(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-background/70 typography-micro text-muted-foreground`,children:s(`common.loading`)}):null]})]})},$_=({initialUrl:e,directory:t,tabID:n})=>{let{t:r}=Zt(),i=Q.useRef(null),a=q(e=>e.setContextPanelTabTargetPath),o=Mg(e),s=o===`about:blank`?``:o,c=Q.useRef(Mg(e)),[l,u]=Q.useState(s),[d,f]=Q.useState(s),[p,m]=Q.useState(!1),[h,g]=Q.useState(!0),_=Q.useRef(null),v=h,y=Q.useCallback(e=>{!e||e===`about:blank`||!t||!n||a(t,n,e)},[t,n,a]),b=cr(e=>e.currentSessionId),x=cr(e=>e.newSessionDraft?.open),S=Zi(e=>e.addDraft),C=Or(e=>e.addAttachedFile);Q.useEffect(()=>{let e=i.current;if(!e)return;let t=()=>{try{let t=e.getURL();t&&t!==`about:blank`&&(f(t),u(t),y(t))}catch{}},n=e=>{let t=e.detail;typeof t?.url==`string`&&t.url&&(f(t.url),u(t.url),y(t.url))},r=()=>{_.current&&clearTimeout(_.current),_.current=setTimeout(()=>g(!0),200)},a=()=>{_.current&&clearTimeout(_.current),g(!1),t()},o=e=>{let t=e.detail;if(t?.disposition===`new-window`||t?.disposition===`foreground-tab`||t?.disposition===`background-tab`){e.preventDefault();let n=i.current;typeof n?.loadURL==`function`&&t.url&&n.loadURL(t.url)}},s=()=>{try{e.executeJavaScript?.(V_,!0).catch(()=>{})}catch{}};e.addEventListener(`did-navigate`,n),e.addEventListener(`did-navigate-in-page`,n),e.addEventListener(`did-start-loading`,r),e.addEventListener(`did-stop-loading`,a),e.addEventListener(`new-window`,o),e.addEventListener(`dom-ready`,s);try{e.isLoading()||(g(!1),t())}catch{}return s(),()=>{_.current&&clearTimeout(_.current),e.removeEventListener(`did-navigate`,n),e.removeEventListener(`did-navigate-in-page`,n),e.removeEventListener(`did-start-loading`,r),e.removeEventListener(`did-stop-loading`,a),e.removeEventListener(`new-window`,o),e.removeEventListener(`dom-ready`,s)}},[y]),Q.useEffect(()=>{let e=setTimeout(()=>g(!1),3e4);return()=>clearTimeout(e)},[]),Q.useEffect(()=>{if(!p)return;let e=e=>{if(e.key!==`Escape`)return;e.preventDefault(),e.stopImmediatePropagation(),m(!1);let t=i.current;try{t?.executeJavaScript?.(B_).catch(()=>{})}catch{}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[p]),Q.useEffect(()=>{let e=i.current;return()=>{try{let r=e?.getURL?.();r&&r!==`about:blank`&&a(t,n,r)}catch{}try{e?.executeJavaScript?.(B_).catch(()=>{})}catch{}}},[t,n,a]);let w=Q.useCallback(e=>{let t=i.current;if(typeof t?.loadURL!=`function`)return;let n=Mg(e);try{t.loadURL(n)}catch{}},[]),T=Q.useRef(d);T.current=d,Q.useEffect(()=>{let t=Ng(e,T.current);t!==null&&(f(t),u(t),g(!0),w(t))},[e,w]);let E=Q.useCallback(()=>{let e=i.current;if(e){if(p){m(!1);try{e.executeJavaScript?.(B_).catch(()=>{})}catch{}return}m(!0),e.executeJavaScript?.(z_,!0).then(async t=>{if(m(!1),!t||!Lg(t))return;let n=b??(x?`draft`:null);if(!n){J.error(r(`contextPanel.preview.inspect.attachNoSession`));return}let i=typeof e.getWebContentsId==`function`?e.getWebContentsId():null;if(i==null)return;let a=await qt(`desktop_browser_capture_page`,{webContentsId:i}),o=await e.executeJavaScript?.(`({ width: window.innerWidth, height: window.innerHeight })`,!0).catch(()=>null),s=Number.isFinite(o?.width)?o.width:a.width,c=Number.isFinite(o?.height)?o.height:a.height,l=await Bg(a.base64,a.width,a.height,s,c,t),u=!!l;l&&await C(l),S({sessionKey:n,source:`preview-annotation`,fileLabel:d||`browser`,startLine:1,endLine:1,code:Rg({pageUrl:d,viewport:{width:s,height:c},devicePixelRatio:window.devicePixelRatio||1,target:t,screenshotAttached:u,intro:r(`contextPanel.preview.inspect.attachAnnotationWithScreenshot`)}),language:`markdown`,text:``}),J.success(r(`contextPanel.preview.inspect.attached`))}).catch(()=>m(!1))}},[C,S,b,d,p,x,r]);return(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col bg-background`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border/40 bg-[var(--surface-background)] px-2 py-1`,children:[(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>{try{i.current?.goBack?.()}catch{}},children:(0,$.jsx)(Z,{name:`arrow-left`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>{try{i.current?.goForward?.()}catch{}},children:(0,$.jsx)(Z,{name:`arrow-right`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>{try{i.current?.reload?.()}catch{}},children:(0,$.jsx)(Z,{name:`refresh`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault(),w(l)},children:(0,$.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),className:`h-7 w-full rounded-md border border-border/50 bg-[var(--surface-elevated)] px-2 typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]`,"aria-label":r(`contextPanel.browser.addressAria`)})}),(0,$.jsx)(Y,{type:`button`,variant:p?`secondary`:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:E,title:r(`contextPanel.preview.inspect.toggle`),"aria-label":r(`contextPanel.preview.inspect.toggle`),children:(0,$.jsx)(Z,{name:`cursor`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>void Bt(d),children:(0,$.jsx)(Z,{name:`external-link`,className:`h-3.5 w-3.5`})})]}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 bg-background`,children:[(0,$.jsx)(`webview`,{ref:i,src:c.current,partition:`persist:yuri-browser`,allowpopups:!0,style:{width:`100%`,height:`100%`,border:`none`}}),(!d||d===`about:blank`)&&!h?(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-6 bg-background p-6 text-center`,children:[(0,$.jsx)(fo,{width:140,height:140,className:`opacity-20`}),(0,$.jsx)(`span`,{className:`typography-ui-header text-muted-foreground`,children:r(`contextPanel.browser.empty`)})]}):null,v?(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-background/70 typography-micro text-muted-foreground`,children:r(`common.loading`)}):null]})]})},ev=e=>{let t=(0,du.c)(3),n=_t(),r;return t[0]!==n||t[1]!==e?(r=n?(0,$.jsx)(tv,{...e},n.entry.key):(0,$.jsx)(Nc,{children:(0,$.jsx)(tv,{...e})}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r},tv=e=>{let t=(0,du.c)(3),n=_t(),r;return t[0]!==n?.entry.location.hostId||t[1]!==e?(r=n?.entry.location.hostId?(0,$.jsx)(nv,{...e}):(0,$.jsx)(rv,{...e}),t[0]=n?.entry.location.hostId,t[1]=e,t[2]=r):r=t[2],r},nv=e=>{let t=(0,du.c)(5),n=_t(),r=Mr(n.registry,n.entry.location.hostId),i;t[0]===r.data?.directories?i=t[1]:(i=r.data?.directories.flatMap(iv)??[],t[0]=r.data?.directories,t[1]=i);let a=i,o;return t[2]!==e||t[3]!==a?(o=(0,$.jsx)(rv,{...e,remoteSessions:a}),t[2]=e,t[3]=a,t[4]=o):o=t[4],o},rv=({directory:e,onReservedWidthChange:t,fillAvailableSpace:n=!1,getMaxSplitWidth:r,remoteSessions:i})=>{let{t:a}=Zt(),s=_t(),c=!!s?.entry.location.hostId,l=cr(e=>e.currentSessionId),u=dn(e=>e.remoteSession),d=c?u&&ee(u.location)===s.entry.key?u.sessionId:null:l,p=zo()??``,m=e?V(e,s?.entry.location.hubId??`local`).directory:p,h=c?ee({...s.entry.location,directory:m}):E_(m),g=q(e=>zt(e,h)),_=q(e=>h?e.contextToolDiffByDirectory[h]:void 0),v=q(e=>e.closeContextPanel),y=q(e=>e.closeContextPanelTab),b=q(e=>e.openContextPanelTab),x=q(e=>e.toggleContextPanelExpanded),S=q(e=>e.setContextPanelWidth),C=q(e=>e.setActiveContextPanelTab),w=q(e=>e.reorderContextPanelTabs),T=q(e=>e.isRightSidebarOpen),E=q(e=>e.isSidebarOpen),{usesFramelessChrome:D,side:O}=$s(),k=To(e=>e.setSelectedPath),A=q(e=>e.openContextPreview),j=q(e=>e.allowPromptingSubagentSessions),{themeMode:M,setThemeMode:N,lightThemeId:P,darkThemeId:F,currentTheme:I}=zr(),L=Q.useMemo(()=>g?.tabs??[],[g?.tabs]),R=L.find(e=>e.id===g?.activeTabId)??L[L.length-1]??null,z=!!g?.isOpen,B=!!g?.expanded,te=z&&(B||n),ne=Q.useRef(null),re=Q.useRef(!0),[ie,ae]=Q.useState(!0);Nt(ne,([e])=>{if(!e||e.contentRect.width<=0)return;let t=e.contentRect.width<x_;t!==re.current&&(re.current=t,ae(t))});let oe=z&&(!R||T&&(!ie||g?.activeView!==`preview`)),H=z&&(!ie||!oe),se=D_(g?.width??y_),U=Q.useMemo(()=>{let e=[];for(let t of L){if(t.mode!==`chat`)continue;let n=F_(t.dedupeKey);n&&!e.includes(n)&&e.push(n)}return e},[L]),ce=R_(m||void 0,U,i),[W,le]=Q.useState(!1),[ue,de]=Q.useState(!1),fe=Q.useRef(0),pe=Q.useRef(se),me=Q.useRef(null),he=Q.useRef(null),ge=Q.useRef({directory:h,width:se});Q.useLayoutEffect(()=>{W||((ge.current.directory!==h||z&&!te)&&(ge.current={directory:h,width:se}),t?.(z?B?1/0:se:0))},[h,te,z,W,t,B,se]);let _e=Q.useRef(null),ve=Q.useRef(new Map),ye=Q.useRef(new Map),be=Q.useRef(!1),xe=Q.useRef(z),Se=Q.useRef(null),[Ce,we]=Q.useState({}),Te=Q.useRef(Ce);Te.current=Ce;let[Ee,De]=Q.useReducer(Eg,{activeViewKey:null,tabs:{},mountedViews:{}}),Oe=c?`react-surface`:Jh(),ke=f(),Ae=Q.useCallback(e=>{let t=Te.current,n=e(t);return n!==t&&(Te.current=n,we(n),!0)},[]),je=Q.useCallback(e=>{if(!h)return;if(q.getState().contextPanelByDirectory[h]?.tabs.find(t=>t.id===e)?.mode===`btw`){let e=d;e&&pa.getState().clear({sessionId:e,directory:m,host:c?s.entry:void 0})}De({type:`close-tab`,tabId:e});let t=Yh(h,e);Ae(e=>{if(!e[t])return e;let n={...e};return delete n[t],n}),y(h,e)},[d,m,s,c,y,Ae,h]),Me=Q.useCallback(()=>{de(!0),Se.current!==null&&window.cancelAnimationFrame(Se.current),Se.current=window.requestAnimationFrame(()=>{Se.current=null,de(!1)})},[]);Q.useEffect(()=>()=>{Se.current!==null&&window.cancelAnimationFrame(Se.current)},[]),Q.useLayoutEffect(()=>{let e=xe.current;if(xe.current=z,!z){de(!1);return}e||Me()},[z,Me]),Q.useEffect(()=>{if(!z||be.current){be.current=z;return}let e=window.requestAnimationFrame(()=>{let e=_e.current;e&&!e.contains(document.activeElement)&&e.focus({preventScroll:!0})});return be.current=!0,()=>window.cancelAnimationFrame(e)},[z]);let Ne=K(e=>{let n=_e.current;if(!n)return;let r=k_(e,n);n.style.setProperty(`--yuri-context-panel-width`,`${r}px`),t?.(r)}),Pe=K(e=>{if(!z||!h)return;try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}he.current=e.pointerId,le(!0),fe.current=e.clientX;let t=_e.current?.clientWidth||se;pe.current=t,me.current=t,B&&x(h),Ne(t),e.preventDefault()}),Fe=Q.useCallback(e=>{if(!W||he.current!==e.pointerId)return;let t=fe.current-e.clientX,n=k_(pe.current+t,_e.current);me.current!==n&&(me.current=n,Ne(n))},[Ne,W]),Ie=Q.useCallback(e=>{if(he.current!==e.pointerId||!h)return;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}let t=k_(me.current??se,_e.current);Me(),Ne(t),me.current=t,S(h,t),le(!1),he.current=null},[Ne,h,S,Me,se]);Q.useEffect(()=>{W||(me.current=null)},[W]);let Le=Q.useCallback(()=>{if(!h)return;let e=d;e&&pa.getState().cancel({sessionId:e,directory:m,host:c?s.entry:void 0}),v(h)},[d,m,s,c,v,h]),Re=K(()=>{if(!h)return;if(!te){x(h);return}let e=ge.current.width,t=D_(Math.min(e,r?.()??e));t!==se&&S(h,t),B&&x(h)}),G=Q.useCallback(e=>{if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`w`&&R&&h){e.preventDefault(),e.stopPropagation(),je(R.id);return}e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Le())},[R,je,h,Le]);Q.useEffect(()=>{if(!(!h||!R)&&R.mode===`file`&&R.targetPath){k(h,R.targetPath,{allowOutsideRoot:!0});return}},[R,h,k]);let ze=R?.mode===`chat`?R.id:null,Be=ng(ze?Ce[Yh(h,ze)]:void 0,ze?F_(R?.dedupeKey):null);Q.useEffect(()=>{if(c||!H||!h||!Be){cn(``,null);return}return cn(h,Be),()=>{cn(``,null)}},[Be,h,H,c]),Q.useEffect(()=>{if(c||!H||!h||!Be||typeof window>`u`)return;let e=()=>{if(document.visibilityState===`hidden`||!document.hasFocus()){gn(h,Be,!1);return}sn(Be),gn(h,Be,!0)};e();let t=window.setInterval(e,1e4);return window.addEventListener(`focus`,e),window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,e),()=>{window.clearInterval(t),window.removeEventListener(`focus`,e),window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,e),gn(h,Be,!1)}},[Be,h,H,c]);let Ve=Q.useCallback((e,t,n)=>bo(ye.current,e,t,h||null,n,{mode:M,lightThemeId:P,darkThemeId:F,currentTheme:I}),[I,F,h,P,M]);Q.useEffect(()=>{let e=new Set(L.map(e=>e.id));for(let t of ye.current.keys())e.has(t)||ye.current.delete(t)},[L]);let He=Q.useCallback(e=>{!h||R?.mode!==`diff`&&R?.mode!==`file-diff`||b(h,{mode:R.mode,targetPath:R.targetPath,stagedDiff:e===`staged`,diffScope:e})},[R,h,b]),Ue=Q.useCallback(()=>{if(typeof window>`u`)return;let e={themeMode:M,lightThemeId:P,darkThemeId:F,currentTheme:I};for(let t of ve.current.values()){let n=t.contentWindow;if(!n)continue;let r=n.__yuriApplyThemeSync;if(typeof r==`function`)try{r(e);continue}catch{}n.postMessage({type:`yuri:theme-sync`,payload:e},window.location.origin)}},[I,F,P,M]),We=Q.useCallback(()=>{if(typeof window>`u`)return;let e={allowPromptingSubagentSessions:j};for(let t of ve.current.values()){let n=t.contentWindow;if(!n)continue;let r=n.__yuriApplyChatSettingsSync;if(typeof r==`function`)try{r(e);continue}catch{}n.postMessage({type:`yuri:chat-settings-sync`,payload:e},window.location.origin)}},[j]),Ge=Q.useCallback(()=>{if(!(typeof window>`u`))for(let[e,t]of ve.current.entries()){let n=t.contentWindow;if(!n)continue;let r={visible:H&&ze===e},i=n.__yuriSetEmbeddedVisibility;if(typeof i==`function`)try{i(r);continue}catch{}n.postMessage({type:vo,payload:r},window.location.origin)}},[ze,H]);Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{if(e.origin!==window.location.origin||!Array.from(ve.current.values()).some(t=>t.contentWindow===e.source))return;let t=e.data;if(t?.type===`yuri:close-embedded-session-chat`){let t=Array.from(ve.current.entries()).find(([,t])=>t.contentWindow===e.source);t&&h&&je(t[0]);return}if(t?.type===`yuri:chat-settings-request`){We();return}if(t?.type===`yuri:embedded-visibility-request`){Ge();return}if(t?.type!==`yuri:cycle-theme-request`)return;let n=[`light`,`dark`,`system`],r=(n.indexOf(M)+1)%n.length;N(n[r])};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[je,h,We,Ge,N,M]),Q.useLayoutEffect(()=>{L.some(e=>e.mode===`chat`)&&(Ue(),We(),Ge())},[F,P,We,Ge,Ue,L,M]);let Ke=Q.useMemo(()=>L.map(e=>{let t=N_(e,ce,a),n=U_(t,b_),r=A_(e.targetPath,m);return{id:e.id,label:n,icon:P_(e),title:r?`${t}: ${r}`:t,closeLabel:a(`contextPanel.tab.closeTabAria`,{label:n})}}),[m,ce,a,L]),qe=R?.mode===`context`?(0,$.jsx)(Cp,{active:H}):R?.mode===`preview`?(0,$.jsx)(X_,{rawUrl:R.targetPath??``,onNavigate:e=>A(h,e)},`${h}:${s?.entry.connectionGeneration??``}:${R.id}`):(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-4 p-6 text-center`,children:[(0,$.jsxs)(`div`,{"aria-hidden":`true`,className:`flex h-18 w-24 flex-col overflow-hidden rounded-lg border border-current/35 text-muted-foreground/45`,children:[(0,$.jsx)(`div`,{className:`flex h-3.5 shrink-0 items-end border-b border-current/25 px-2`,children:(0,$.jsx)(`span`,{className:`h-1.5 w-5 rounded-t-sm bg-current/20`})}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex w-6 shrink-0 flex-col gap-1.5 border-r border-current/25 px-1.5 py-3`,children:[(0,$.jsx)(`span`,{className:`h-0.5 w-full rounded-full bg-current/40`}),(0,$.jsx)(`span`,{className:`h-0.5 w-2 rounded-full bg-current/25`}),(0,$.jsx)(`span`,{className:`h-0.5 w-full rounded-full bg-current/25`})]}),(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,$.jsx)(Z,{name:`file-text`,className:`size-7`})})]})]}),(0,$.jsx)(`p`,{className:`typography-ui-label text-muted-foreground`,children:a(`contextPanel.empty.selectFile`)})]}),Je=Q.useMemo(()=>L.filter(e=>e.mode===`chat`),[L]),Ye=Q.useMemo(()=>L.filter(e=>e.mode===`browser`),[L]),Xe=Q.useMemo(()=>L.filter(e=>e.mode===`diff`||e.mode===`file-diff`),[L]),Ze=Pg({isElectron:!c&&Z_(),relayActive:o()})?$_:Q_,Qe=H&&R?.mode===`browser`&&Ze===$_;Q.useLayoutEffect(()=>{if(!Qe)return;let e=document.documentElement;return e.setAttribute(`data-yuri-native-browser-visible`,``),()=>e.removeAttribute(`data-yuri-native-browser-visible`)},[Qe]);let $e=Q.useMemo(()=>L.some(e=>e.mode===`file`),[L]),et=R?.mode===`file`,[tt,nt]=Q.useState(null),rt=et?R.targetPath:tt?.directory===h&&L.some(e=>e.mode===`file`&&e.targetPath===tt.path)?tt.path:null;Q.useEffect(()=>{nt(e=>e?.directory===h&&e.path===rt?e:{directory:h,path:rt??null})},[h,rt]);let it=et?R?.fileNotice??null:null;Q.useEffect(()=>{let e=new Set(Je.map(e=>Yh(h,e.id)));Ae(t=>{let n=!1,r={};for(let e of Je){let i=F_(e.dedupeKey);if(!i)continue;let a=Yh(h,e.id),o=t[a];r[a]=o??eg({sessionId:i,directory:h}),n||=!o}let i=sg(t,e);return n||=i!==t,n?{...i,...r}:t});for(let t of Object.keys(Ee.tabs))(!e.has(Yh(h,t))||Ee.tabs[t]?.directory!==h)&&De({type:`close-tab`,tabId:t})},[Je,Ae,h,Ee.tabs]);let at=ze?Yh(h,ze):null,ot=ze?F_(R?.dedupeKey):null,st=at&&ot?tg(Ce[at],{sessionId:ot,directory:h}):void 0,ct=st&&at?Xh(ke,at,st.current.directory,st.current.sessionId):null;Q.useLayoutEffect(()=>{if(Oe!==`react-surface`||!z||!ze||!st||!at||!ct){Oe===`react-surface`&&De({type:`activate`,viewKey:null,now:Date.now()});return}Ae(e=>e[at]?e:{...e,[at]:st}),De({type:`touch`,tab:{tabId:ze,sessionId:st.anchor.sessionId,directory:st.anchor.directory},view:{tabId:ze,surfaceId:at,sessionId:st.current.sessionId,directory:st.current.directory,viewKey:ct},now:Date.now()})},[st,at,ze,ct,Oe,Ae,z]);let lt=Q.useCallback((e,t,n)=>{let r=Yh(h,e),i=!1;return Ae(e=>{let a=c&&s?ee({...s.entry.location,directory:V(n,s.entry.location.hubId).directory}):n,o=og(e,r,{sessionId:t,directory:a});return i=o.accepted,o.navigationBySurfaceId}),i},[Ae,h,c,s]),ut=Q.useCallback(e=>{let t=Yh(h,e);Ae(e=>{let n=e[t];if(!n)return e;let r=ig(n);return r===n?e:{...e,[t]:r}})},[Ae,h]),dt=(0,$.jsxs)(`header`,{className:X(`app-region-drag flex shrink-0 select-none items-center pl-2`,I.metadata.variant===`light`&&[`[--interactive-hover:color-mix(in_srgb,var(--surface-foreground)_6%,var(--background))]`,`[--interactive-active:color-mix(in_srgb,var(--surface-foreground)_10%,var(--background))]`]),style:{height:`calc(var(--yuri-header-height, 3rem) - 0.75rem * var(--padding-scale, 1))`,minHeight:`calc(max(3rem, var(--yuri-wco-titlebar-height, 0px)) - 0.75rem * var(--padding-scale, 1))`,paddingRight:`calc(0.75rem + var(--yuri-wco-right-inset, 0px))`,...n&&!E?{paddingLeft:`calc(var(--yuri-titlebar-left-inset, 0.75rem) + var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`}:{}},children:[(0,$.jsx)(gs,{items:Ke,activeId:R?.id??null,onSelect:e=>{h&&C(h,e)},onClose:e=>{je(e)},onReorder:(e,t)=>{h&&w(h,e,t)},layoutMode:`scrollable`,variant:`compact`,className:`app-region-no-drag h-6`}),(0,$.jsxs)(`div`,{className:`app-region-no-drag flex shrink-0 items-center gap-1 pl-1.5`,children:[z?(0,$.jsx)(Rh,{railVisible:oe}):null,(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:Re,className:`h-7 w-7 p-0`,title:a(te?`contextPanel.actions.collapsePanel`:`contextPanel.actions.expandPanel`),"aria-label":a(te?`contextPanel.actions.collapsePanel`:`contextPanel.actions.expandPanel`),"aria-pressed":te,children:(0,$.jsx)(Z,{name:te?`collapse-diagonal`:`expand-diagonal`,className:`size-4`})}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:Le,className:`h-7 w-7 p-0`,title:a(`contextPanel.actions.closePanel`),"aria-label":a(`contextPanel.actions.closePanel`),children:(0,$.jsx)(Z,{name:`close`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(Zs,{visible:z&&D&&O===`right`,position:`right`})]})]}),ft=z?{width:te?`100%`:`min(var(--yuri-context-panel-width), 100%)`,minWidth:`min(${__}px, 100%)`,maxWidth:`100%`,"--yuri-context-panel-width":`${W?me.current??se:se}px`}:{"--yuri-context-panel-width":`${W?me.current??se:se}px`,width:0,minWidth:0,maxWidth:0,opacity:0,overflow:`hidden`,visibility:`hidden`};return(0,$.jsxs)(`aside`,{ref:_e,"data-context-panel":`true`,"data-native-browser-visible":Qe?`true`:void 0,tabIndex:-1,inert:!z||void 0,className:X(`flex min-h-0 flex-col overflow-visible bg-transparent`,z&&`py-1.5 pl-1 pr-1.5`,`relative h-full flex-shrink-0`,!z&&`pointer-events-none`,W||!z||ue||t?`transition-none`:`transition-[width] duration-200 ease-in-out`),onKeyDownCapture:G,style:ft,children:[(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`div`,{className:`group/preview-resize absolute -left-1 top-0 z-50 h-full w-4 touch-none cursor-col-resize`,onPointerDown:Pe,onPointerMove:Fe,onPointerUp:Ie,onPointerCancel:Ie,role:`separator`,"aria-orientation":`vertical`,"aria-label":a(`contextPanel.actions.resizePanelAria`),"data-context-resize-handle":!0,children:(0,$.jsx)(`span`,{"aria-hidden":`true`,className:X(`pointer-events-none absolute left-[2px] top-1/2 h-14 w-[3px] -translate-y-1/2 rounded-full bg-muted-foreground/25 opacity-0 transition-opacity duration-150 group-hover/preview-resize:opacity-100`,W&&`opacity-100`)})})}),(0,$.jsx)(Ea,{side:`right`,sideOffset:4,children:a(`contextPanel.actions.resizePanel`)})]}),(0,$.jsxs)(Hl,{"data-context-panel-surface":!0,children:[dt,it===`turn-diff-outside-workspace`?(0,$.jsx)(`div`,{className:`shrink-0 border-b border-status-info/20 bg-status-info/10 px-3 py-2 typography-meta text-status-info`,children:a(`contextPanel.file.notice.turnDiffOutsideWorkspace`)}):null,(0,$.jsxs)(`div`,{ref:ne,className:X(`relative flex min-h-0 flex-1 overflow-hidden`,W&&`pointer-events-none`),"data-context-layout":ie?`single`:`split`,children:[(0,$.jsx)(`div`,{className:X(`min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,H?`flex`:`hidden`),inert:!H||void 0,"data-context-preview-content":!0,children:(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[$e&&rt?(0,$.jsx)(`div`,{className:X(`absolute inset-0`,et?`block`:`hidden`),children:(0,$.jsx)(Jf,{mode:`editor-only`,targetPath:rt,isActive:H&&et},`${h}:${rt??``}`)}):null,Oe===`legacy-iframe`&&Je.map(e=>{let t=F_(e.dedupeKey);if(!t)return null;let n=Ve(e.id,t,e.readOnly);return n?(0,$.jsx)(`iframe`,{ref:t=>{if(!t){ve.current.delete(e.id);return}ve.current.set(e.id,t)},src:n,title:a(`contextPanel.iframe.sessionChatTitle`,{sessionID:t}),className:X(`absolute inset-0 h-full w-full border-0 bg-background`,ze===e.id?`block`:`hidden`),onLoad:()=>{Ue(),We(),Ge()}},e.id):null}),Oe===`react-surface`?Object.values(Ee.mountedViews).map(e=>{let t=Ce[Yh(h,e.tabId)],n=H&&ze===e.tabId&&ct===e.viewKey;return(0,$.jsx)(Q.Activity,{name:`context-panel-session-${e.sessionId}`,mode:n?`visible`:`hidden`,children:c&&s?(0,$.jsxs)(`div`,{className:`relative h-full min-h-0`,children:[n&&t?.stack.length?(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,onClick:()=>ut(e.tabId),className:`absolute left-3 top-3 z-20 !font-normal bg-[var(--surface-background)]/95`,"aria-label":a(`chat.container.returnToParent.aria`),title:a(`chat.container.returnToParent.title`),children:[(0,$.jsx)(Z,{name:`arrow-left`,className:`h-4 w-4`}),a(`chat.container.returnToParent.label`)]}):null,(0,$.jsx)(Qi,{location:{...s.entry.location,directory:V(e.directory,s.entry.location.hubId).directory},sessionId:e.sessionId,active:n,readOnly:L.find(t=>t.id===e.tabId)?.readOnly??!0,onNavigateSession:(t,n)=>{lt(e.tabId,t,n)}})]}):(0,$.jsx)(kg,{surfaceId:e.surfaceId,sessionId:e.sessionId,directory:e.directory,active:n,canNavigateBack:n&&!!t?.stack.length,onNavigateSession:(t,n)=>lt(e.tabId,t,n),onNavigateBack:()=>ut(e.tabId),onEstimateBytes:(e,t)=>De({type:`estimate`,viewKey:e,estimatedBytes:t})})},e.viewKey)}):null,L.filter(e=>e.mode===`btw`).map(e=>{let t=H&&R?.id===e.id;return(0,$.jsx)(Q.Activity,{name:`context-panel-btw`,mode:t?`visible`:`hidden`,children:d?(0,$.jsx)(ki,{scope:{sessionId:d,directory:m,host:c?s.entry:void 0},hostRegistry:c?s.registry:void 0,active:t}):(0,$.jsx)(`p`,{className:`p-4 text-muted-foreground`,children:a(`chat.btw.sessionRequired`)})},`btw:${h}:${d}:${e.id}`)}),Ye.map(e=>(0,$.jsx)(`div`,{className:X(`absolute inset-0`,R?.id!==e.id&&`hidden`),children:(0,$.jsx)(Ze,{initialUrl:e.targetPath??``,directory:h,tabID:e.id})},`${h}:${s?.entry.connectionGeneration??``}:${e.id}`)),Xe.map(e=>{let t=e.mode===`diff`&&_?.targetPath===e.targetPath&&_.turnMessageId===e.diffTurnMessageId?_.patches:null;return(0,$.jsx)(`div`,{className:X(`absolute inset-0`,R?.id!==e.id&&`hidden`),children:(0,$.jsx)(uc,{hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!t,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:e.diffScope??(e.stagedDiff?`staged`:`working`),turnMessageId:e.diffTurnMessageId,sessionId:e.diffSessionId,directory:m,onDiffScopeChange:He,targetFilePath:e.targetPath,targetLine:e.diffTargetLine??null,toolPatches:t,navigationRequestKey:e.touchedAt,flushContent:!0,singleFileView:e.mode===`file-diff`,preloadFullFiles:e.mode===`file-diff`})},e.id)}),R?.mode!==`chat`&&R?.mode!==`btw`&&!et&&R?.mode!==`browser`&&R?.mode!==`diff`&&R?.mode!==`file-diff`?qe:null]})}),(0,$.jsx)(Up,{isOpen:oe,className:X(`!min-w-0 shrink-0 bg-transparent [--layout-chrome-divider-width:1px] [--layout-chrome-divider:color-mix(in_srgb,var(--surface-foreground)_8%,var(--background))]`,ie&&`!transition-none`,ie&&oe?`!w-full !max-w-full !border-l-0 [&>[role=separator]]:hidden`:`!max-w-[50%]`),children:oe?(0,$.jsx)(po,{children:(0,$.jsx)(zh,{isActive:oe})}):null})]})]})]})};function iv(e){return e.sessions}var av=350,ov=e=>{let t=(0,du.c)(26),{children:n,header:r,footer:i}=e,a=Q.useRef(null),o=Q.useRef(0),s=Q.useRef(0),c=Q.useRef(!1),[l,u]=Q.useState(!1),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{if(o.current<=0)return;let e=s.current>0&&o.current-s.current<av;e!==c.current&&(c.current=e,u(e))},t[0]=d):d=t[0];let f=K(d),p;t[1]===f?p=t[2]:(p=e=>{s.current=e,f()},t[1]=f,t[2]=p);let m=K(p),h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>o.current-av,t[3]=h):h=t[3];let g=K(h),_,v;t[4]===f?(_=t[5],v=t[6]):(_=()=>{o.current=a.current?.clientWidth??0,f()},v=[f],t[4]=f,t[5]=_,t[6]=v),Q.useLayoutEffect(_,v);let y;t[7]===f?y=t[8]:(y=e=>{let[t]=e;t&&(o.current=t.contentRect.width,f())},t[7]=f,t[8]=y),Nt(a,y);let b;t[9]===l?b=t[10]:(b=l?{display:`none`}:{minWidth:`min(${av}px, 100%)`},t[9]=l,t[10]=b);let x=l||void 0,S;t[11]===n?S=t[12]:(S=(0,$.jsx)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden yuri-layout-divider-t`,"data-primary-chat-content":!0,children:n}),t[11]=n,t[12]=S);let C;t[13]!==i||t[14]!==r||t[15]!==b||t[16]!==x||t[17]!==S?(C=(0,$.jsxs)(`main`,{className:`flex flex-1 min-w-0 flex-col overflow-hidden bg-background relative`,style:b,inert:x,"data-page-scroll-lock":`true`,"data-primary-chat":!0,children:[r,S,i]}),t[13]=i,t[14]=r,t[15]=b,t[16]=x,t[17]=S,t[18]=C):C=t[18];let w;t[19]!==g||t[20]!==m||t[21]!==l?(w=(0,$.jsx)(ev,{onReservedWidthChange:m,fillAvailableSpace:l,getMaxSplitWidth:g}),t[19]=g,t[20]=m,t[21]=l,t[22]=w):w=t[22];let T;return t[23]!==C||t[24]!==w?(T=(0,$.jsxs)(`div`,{ref:a,className:`relative flex flex-1 min-h-0 min-w-0 overflow-hidden`,"data-page-scroll-lock":`true`,"data-chat-area":!0,children:[C,w]}),t[23]=C,t[24]=w,t[25]=T):T=t[25],T},sv=(e,t,n)=>so(e)?Ka(e,n).map(to):t,cv=()=>{let e=(0,du.c)(34),{t}=Zt(),{isMobile:n}=go(),r=q(lv),i=q(uv),a=q(dv),o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=ro(),e[0]=o):o=e[0];let s=o,c;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=w(),e[1]=c):c=e[1];let l=c,u,d,f,p,m,h,g,_,v;if(e[2]!==r||e[3]!==n||e[4]!==i||e[5]!==a||e[6]!==t){let o=[{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:`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:[`Shift + ${s} + 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:`previous_session`,descriptionKey:`helpDialog.item.previousSession`,icon:`arrow-left`,keys:``},{id:`next_session`,descriptionKey:`helpDialog.item.nextSession`,icon:`arrow-right`,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.leaderChords`,items:[{keys:`Ctrl+X → M`,descriptionKey:`helpDialog.item.leaderOpenModel`,icon:`ai-generate-2`},{keys:`Ctrl+X → A`,descriptionKey:`helpDialog.item.leaderOpenAgent`,icon:`ai-agent`},{keys:`Ctrl+X → N`,descriptionKey:`helpDialog.item.leaderNewSession`,icon:`add`},{keys:`Ctrl+X → C`,descriptionKey:`helpDialog.item.leaderCompact`,icon:`scissors`}]},{categoryKey:`helpDialog.section.panels`,items:[{id:`toggle_right_sidebar`,descriptionKey:`helpDialog.item.toggleRightSidebar`,icon:`layout-right`,keys:``},{id:`open_right_sidebar_git`,descriptionKey:`helpDialog.item.openRightSidebarGitTab`,icon:`git-branch`,keys:``},{id:`open_right_sidebar_files`,descriptionKey:`helpDialog.item.openRightSidebarFilesTab`,icon:`layout-right`,keys:``},{id:`cycle_right_sidebar_tab`,descriptionKey:`helpDialog.item.cycleRightSidebarTab`,icon:`layout-right`,keys:``},{id:`close_context_panel_tab`,descriptionKey:`helpDialog.item.closeContextPanelTab`,icon:`close`,keys:``},{id:`toggle_terminal`,descriptionKey:`helpDialog.item.toggleTerminal`,icon:`window`,keys:``},{id:`new_terminal_tab`,descriptionKey:`helpDialog.item.newTerminalTab`,icon:`terminal-box`,keys:``},{id:`open_new_terminal`,descriptionKey:`helpDialog.item.openNewTerminal`,icon:`terminal-box`,keys:``},{id:`previous_terminal_tab`,descriptionKey:`helpDialog.item.previousTerminalTab`,icon:`arrow-left`,keys:``},{id:`next_terminal_tab`,descriptionKey:`helpDialog.item.nextTerminalTab`,icon:`arrow-right`,keys:``},{id:`toggle_bottom_panel`,descriptionKey:`helpDialog.item.toggleBottomPanel`,icon:`window`,keys:``},{id:`toggle_terminal_expanded`,descriptionKey:`helpDialog.item.toggleTerminalExpanded`,icon:`window`,keys:``}]},{categoryKey:`helpDialog.section.interface`,items:[{id:`cycle_theme`,descriptionKey:`helpDialog.item.cycleTheme`,icon:`palette`,keys:``},{id:`zoom_in`,descriptionKey:`helpDialog.item.zoomIn`,icon:`add`,keys:``},{id:`zoom_out`,descriptionKey:`helpDialog.item.zoomOut`,icon:`subtract`,keys:``},{id:`zoom_reset`,descriptionKey:`helpDialog.item.zoomReset`,icon:`restart`,keys:``},{keys:[`${s} + 1...9`],descriptionKey:`helpDialog.item.switchSession`,icon:`layout-left`},{id:`toggle_services_menu`,descriptionKey:`helpDialog.item.toggleServicesMenu`,icon:`stack`,keys:``},{id:`open_usage`,descriptionKey:`helpDialog.item.openUsage`,icon:`timer`,keys:``},{id:`cycle_services_tab`,descriptionKey:`helpDialog.item.cycleServicesTab`,icon:`stack`,keys:``},{id:`open_settings`,descriptionKey:`helpDialog.item.openSettings`,icon:`settings-3`,keys:``}]}];d=Jr,g=r,_=i,u=Gr,p=n?`default`:`picker`,m=n?`max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden`:void 0;let c;e[16]===t?c=e[17]:(c=t(`helpDialog.title`),e[16]=t,e[17]=c),e[18]===c?h=e[19]:(h=(0,$.jsx)(Ur,{className:`yuri-picker-header`,children:(0,$.jsx)(Kr,{className:`yuri-picker-title`,children:c})}),e[18]=c,e[19]=h),f=`yuri-picker-list`,v=(0,$.jsx)(`div`,{children:o.map(e=>(0,$.jsxs)(`div`,{className:`yuri-picker-section`,children:[(0,$.jsx)(`h3`,{className:`yuri-picker-section-title text-muted-foreground`,children:t(e.categoryKey)}),(0,$.jsx)(`div`,{children:e.items.filter(e=>!(l&&e.id===`toggle_prompt_navigator`)).map(e=>{let n=e.id?sv(e.id,Array.isArray(e.keys)?e.keys[0]:e.keys,a):Array.isArray(e.keys)?e.keys:e.keys.split(` / `);return(0,$.jsxs)(`div`,{className:`yuri-picker-row yuri-help-shortcut-row`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,$.jsx)(Z,{name:e.icon,className:`h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`yuri-picker-label`,children:t(e.descriptionKey)})]}),(0,$.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-1`,children:(Array.isArray(n)?n:[n]).map((e,n)=>(0,$.jsxs)(Q.Fragment,{children:[n>0&&(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground mx-1`,children:t(`helpDialog.keyCombiner.or`)}),(0,$.jsx)($i,{shortcut:e,variant:`hint`})]},`${e}-${n}`))})]},e.id||e.descriptionKey)})})]},e.categoryKey))}),e[2]=r,e[3]=n,e[4]=i,e[5]=a,e[6]=t,e[7]=u,e[8]=d,e[9]=f,e[10]=p,e[11]=m,e[12]=h,e[13]=g,e[14]=_,e[15]=v}else u=e[7],d=e[8],f=e[9],p=e[10],m=e[11],h=e[12],g=e[13],_=e[14],v=e[15];let y;e[20]!==f||e[21]!==v?(y=(0,$.jsx)(`div`,{className:f,children:v}),e[20]=f,e[21]=v,e[22]=y):y=e[22];let b;e[23]!==u||e[24]!==p||e[25]!==m||e[26]!==h||e[27]!==y?(b=(0,$.jsxs)(u,{presentation:p,className:m,children:[h,y]}),e[23]=u,e[24]=p,e[25]=m,e[26]=h,e[27]=y,e[28]=b):b=e[28];let x;return e[29]!==d||e[30]!==b||e[31]!==g||e[32]!==_?(x=(0,$.jsx)(d,{open:g,onOpenChange:_,children:b}),e[29]=d,e[30]=b,e[31]=g,e[32]=_,e[33]=x):x=e[33],x};function lv(e){return e.isHelpDialogOpen}function uv(e){return e.setHelpDialogOpen}function dv(e){return e.shortcutOverrides}var fv=()=>{let e=(0,du.c)(32),{t}=Zt(),n=q(pv),r=q(mv),i=q(hv),a;e[0]!==i||e[1]!==t?(a=async()=>{if(i){if((await Pn(i)).ok){J.success(t(`openCodeStatusDialog.toast.copiedTitle`),{description:t(`openCodeStatusDialog.toast.copiedDescription`)});return}J.error(t(`openCodeStatusDialog.toast.copyFailed`))}},e[0]=i,e[1]=t,e[2]=a):a=e[2];let o=a,s;e[3]===t?s=e[4]:(s=t(`openCodeStatusDialog.title`),e[3]=t,e[4]=s);let c;e[5]===s?c=e[6]:(c=(0,$.jsx)(Kr,{children:s}),e[5]=s,e[6]=c);let l;e[7]===t?l=e[8]:(l=t(`openCodeStatusDialog.description`),e[7]=t,e[8]=l);let u;e[9]===l?u=e[10]:(u=(0,$.jsx)(qr,{children:l}),e[9]=l,e[10]=u);let d;e[11]!==c||e[12]!==u?(d=(0,$.jsxs)(Ur,{children:[c,u]}),e[11]=c,e[12]=u,e[13]=d):d=e[13];let f;e[14]===t?f=e[15]:(f=t(`openCodeStatusDialog.actions.copy`),e[14]=t,e[15]=f);let p;e[16]!==o||e[17]!==f?(p=(0,$.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,$.jsx)(`button`,{type:`button`,onClick:o,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:f})}),e[16]=o,e[17]=f,e[18]=p):p=e[18];let m;e[19]!==i||e[20]!==t?(m=i||t(`openCodeStatusDialog.empty.noData`),e[19]=i,e[20]=t,e[21]=m):m=e[21];let h;e[22]===m?h=e[23]:(h=(0,$.jsx)(`pre`,{className:`max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap`,children:m}),e[22]=m,e[23]=h);let g;e[24]!==d||e[25]!==p||e[26]!==h?(g=(0,$.jsxs)(Gr,{className:`max-w-2xl`,children:[d,p,h]}),e[24]=d,e[25]=p,e[26]=h,e[27]=g):g=e[27];let _;return e[28]!==n||e[29]!==r||e[30]!==g?(_=(0,$.jsx)(Jr,{open:n,onOpenChange:r,children:g}),e[28]=n,e[29]=r,e[30]=g,e[31]=_):_=e[31],_};function pv(e){return e.isOpenCodeStatusDialogOpen}function mv(e){return e.setOpenCodeStatusDialogOpen}function hv(e){return e.openCodeStatusText}function gv(){let e=(0,du.c)(2),t=$t(),n;return e[0]===t?n=e[1]:(n=t?(0,$.jsx)(Yc,{className:`ml-auto`}):null,e[0]=t,e[1]=n),n}function _v(){let e=(0,du.c)(2),t=en(),n;return e[0]===t?n=e[1]:(n=t?(0,$.jsx)(Yc,{}):null,e[0]=t,e[1]=n),n}var vv=e=>{let t=(0,du.c)(12),{normalizedProjects:n,ownership:r,isSessionsLoading:i,fullCatalogSessionIds:a,fullCatalogGeneration:o,foldersMap:s,createFolder:c,addSessionToFolder:l,cleanupSessions:u,enabled:d}=e,f=d===void 0||d,p,m;t[0]!==l||t[1]!==u||t[2]!==c||t[3]!==f||t[4]!==s||t[5]!==o||t[6]!==a||t[7]!==i||t[8]!==n||t[9]!==r?(p=()=>{!f||i||n.forEach(e=>{let t=Ga(e.normalizedPath),n=r.archivedSessionsByProject.get(e.id)??[],i=s[t]??[],d=new Map(i.map(yv));n.forEach(n=>{let r=Aa(n,e.normalizedPath),i=r.toLowerCase(),a=d.get(i);a||(a=c(t,r),d.set(i,a)),a.sessionIds.includes(n.id)||l(t,a.id,n.id)}),o>0&&u(t,a)})},m=[f,n,r,i,o,a,s,c,l,u],t[0]=l,t[1]=u,t[2]=c,t[3]=f,t[4]=s,t[5]=o,t[6]=a,t[7]=i,t[8]=n,t[9]=r,t[10]=p,t[11]=m):(p=t[10],m=t[11]),Q.useEffect(p,m)};function yv(e){return[e.name.toLowerCase(),e]}var bv=e=>{let t=(0,du.c)(7),{isSessionsLoading:n,fullCatalogSessionIds:r,fullCatalogGeneration:i,normalizedProjects:a,cleanupSessions:o}=e,s,c;t[0]!==o||t[1]!==i||t[2]!==r||t[3]!==n||t[4]!==a?(s=()=>{if(n||i===0)return;let e=or.getState().foldersMap;new Set([...Object.keys(e),...a.map(xv)]).forEach(e=>{o(e,r)})},c=[o,i,r,n,a],t[0]=o,t[1]=i,t[2]=r,t[3]=n,t[4]=a,t[5]=s,t[6]=c):(s=t[5],c=t[6]),Q.useEffect(s,c)};function xv(e){return Ga(e.normalizedPath)}var Sv=Q.memo(function(e){let t=(0,du.c)(17),{normalizedProjects:n,ownership:r,enabled:i}=e;Mc();let a=wr(Cv),o=wr(wv),s=cr(Tv),c=or(Ev),l=or(Dv),u=or(Ov),d=or(kv),f;t[0]!==d||t[1]!==o||t[2]!==a||t[3]!==s||t[4]!==n?(f={normalizedProjects:n,fullCatalogSessionIds:a,fullCatalogGeneration:o,isSessionsLoading:s,cleanupSessions:d},t[0]=d,t[1]=o,t[2]=a,t[3]=s,t[4]=n,t[5]=f):f=t[5],bv(f);let p;return t[6]!==u||t[7]!==d||t[8]!==l||t[9]!==i||t[10]!==c||t[11]!==o||t[12]!==a||t[13]!==s||t[14]!==n||t[15]!==r?(p={normalizedProjects:n,ownership:r,enabled:i,fullCatalogSessionIds:a,fullCatalogGeneration:o,isSessionsLoading:s,foldersMap:c,createFolder:l,addSessionToFolder:u,cleanupSessions:d},t[6]=u,t[7]=d,t[8]=l,t[9]=i,t[10]=c,t[11]=o,t[12]=a,t[13]=s,t[14]=n,t[15]=r,t[16]=p):p=t[16],vv(p),null});function Cv(e){return e.fullCatalogSessionIds}function wv(e){return e.fullCatalogGeneration}function Tv(e){return e.isLoading}function Ev(e){return e.foldersMap}function Dv(e){return e.createFolder}function Ov(e){return e.addSessionToFolder}function kv(e){return e.cleanupSessions}var Av=new WeakMap,jv=e=>{let{normalizedProjects:t,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:a,projectRootBranches:o,lastRepoStatus:s,buildGroupedSessions:c,hasSessionSearchQuery:l,normalizedSessionSearchQuery:u,filterSessionNodesForSearch:d,buildGroupSearchText:f,foldersMap:p}=e,m=Q.useRef([]),h=Q.useMemo(()=>{let e=new Map(m.current.map(e=>[e.project.id,e])),l=t.map(t=>{let l=e.get(t.id),u=eo([...n(t.id),...r(t.id)]),d=i.get(t.normalizedPath)??[],f=a.has(t.id)?!!a.get(t.id):s,p=new Map(l?.groups.map(e=>[e.id,e])),m=c(u,t.normalizedPath,d,o.get(t.id)??null,f).map(e=>pt(p.get(e.id),e));return pt(l,{project:t,groups:m})});return l.length===m.current.length&&l.every((e,t)=>e===m.current[t])?m.current:l},[t,n,r,i,a,s,c,o]);Q.useLayoutEffect(()=>{m.current=h},[h]);let g=Q.useMemo(()=>h,[h]),_=Q.useMemo(()=>{if(!l)return Av;let e=new WeakMap,t=e=>e.reduce((e,n)=>e+1+t(n.children),0);return g.forEach(n=>{n.groups.forEach(n=>{let r=d(n.sessions,u),i=t(r),a=f(n).includes(u),o=M(n.directory??null),s=(o?p[o]??[]:[]).filter(e=>e.name.toLowerCase().includes(u)).length;e.set(n,{filteredNodes:r,matchedSessionCount:i,folderNameMatchCount:s,groupMatches:a,hasMatch:a||i>0||s>0})})}),e},[l,g,d,u,f,p]),v=Q.useMemo(()=>l?g.map(e=>({...e,groups:e.groups.filter(e=>_.get(e)?.hasMatch===!0)})).filter(e=>e.groups.length>0):g,[l,g,_]),y=l?v:g;return{projectSections:h,visibleProjectSections:g,groupSearchDataByGroup:_,searchableProjectSections:v,sectionsForRender:y,searchMatchCount:Q.useMemo(()=>l?y.reduce((e,t)=>e+t.groups.reduce((e,t)=>{let n=_.get(t);if(!n)return e;let r=n.folderNameMatchCount+ +!!n.groupMatches;return e+n.matchedSessionCount+r},0),0):0,[l,y,_])}},Mv=e=>{let t=(0,du.c)(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:a,currentSessionId:o,handleSessionSelect:s,newSessionDraftOpen:c,mobileVariant:l,openNewSessionDraft:u,setActiveMainTab:d,setSessionSwitcherOpen:f}=e,p,m;if(t[0]!==n){m=new Map,p=new Map;let e=(t,n,r,i)=>{m.has(t)||m.set(t,new Map);let a=m.get(t);i.forEach(i=>{let o=M(i.worktree?.path??i.session.directory??r??n);a.set(i.session.id,{directory:o}),p.has(t)||p.set(t,{id:i.session.id,directory:o}),i.children.length>0&&e(t,n,o,i.children)})};n.forEach(t=>{t.groups.forEach(n=>{e(t.project.id,t.project.normalizedPath,n.directory,n.sessions)})}),t[0]=n,t[1]=p,t[2]=m}else p=t[1],m=t[2];let h;t[3]!==p||t[4]!==m?(h={metaByProject:m,firstSessionByProject:p},t[3]=p,t[4]=m,t[5]=h):h=t[5];let g=h,_=Q.useRef(null),v,y;t[6]!==r||t[7]!==i||t[8]!==o||t[9]!==s||t[10]!==l||t[11]!==c||t[12]!==u||t[13]!==n||t[14]!==g||t[15]!==d||t[16]!==a||t[17]!==f?(v=()=>{if(!r||c||q.getState().isNewWorktreeDialogOpen||_.current===r)return;let e=n.find(e=>e.project.id===r);if(!e)return;_.current=r;let t=g.metaByProject.get(r);if(o&&t&&t.has(o)){a(e=>{if(e.get(r)===o)return e;let t=new Map(e);return t.set(r,o),t});return}if(o&&t)return;if(!t||t.size===0){d(`chat`),l&&f(!1),u({directoryOverride:e.project.normalizedPath});return}let p=i.get(r),m=p&&t.has(p)?p:null,h=g.firstSessionByProject.get(r)?.id??null,v=m??h;if(!v||v===o)return;let y=t.get(v)?.directory??null;s(v,y,r)},y=[r,i,o,s,c,l,u,n,g,d,f,a],t[6]=r,t[7]=i,t[8]=o,t[9]=s,t[10]=l,t[11]=c,t[12]=u,t[13]=n,t[14]=g,t[15]=d,t[16]=a,t[17]=f,t[18]=v,t[19]=y):(v=t[18],y=t[19]),Q.useLayoutEffect(v,y);let b,x;t[20]!==r||t[21]!==o||t[22]!==g||t[23]!==a?(b=()=>{if(!r||!o)return;let e=g.metaByProject.get(r);!e||!e.has(o)||a(e=>{if(e.get(r)===o)return e;let t=new Map(e);return t.set(r,o),t})},x=[r,o,g,a],t[20]=r,t[21]=o,t[22]=g,t[23]=a,t[24]=b,t[25]=x):(b=t[24],x=t[25]),Q.useEffect(b,x)},Nv=e=>{let t=bn(e=>e.orderByProject);return{getOrderedGroups:Q.useMemo(()=>(n,r)=>{let i=e.get(n),a=t[n];if(!i?.length&&!a?.length)return r;let o=new Map(r.map(e=>[e.id,e])),s=[];if(i?.forEach(e=>{let t=o.get(e);t&&(s.push(t),o.delete(e))}),r.forEach(e=>{o.has(e.id)&&s.push(e)}),!a?.length)return s;let c=new Map(a.map((e,t)=>[M(e),t])),l=s.filter(e=>e.worktree&&!e.isMain);l.sort((e,t)=>(c.get(M(e.directory))??2**53-1)-(c.get(M(t.directory))??2**53-1));let u=0;return s.map(e=>e.worktree&&!e.isMain?l[u++]:e)},[e,t])}},Pv=e=>{let t=(0,du.c)(9),{isSessionSearchOpen:n,setIsSessionSearchOpen:r,sessionSearchInputRef:i,sessionSearchContainerRef:a}=e,o,s;t[0]!==n||t[1]!==i?(o=()=>{if(!n||typeof window>`u`)return;let e=window.requestAnimationFrame(()=>{i.current?.focus(),i.current?.select()});return()=>window.cancelAnimationFrame(e)},s=[n,i],t[0]=n,t[1]=i,t[2]=o,t[3]=s):(o=t[2],s=t[3]),Q.useEffect(o,s);let c,l;t[4]!==n||t[5]!==a||t[6]!==r?(c=()=>{if(!n||typeof document>`u`)return;let e=e=>{a.current&&(a.current.contains(e.target)||r(!1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},l=[n,r,a],t[4]=n,t[5]=a,t[6]=r,t[7]=c,t[8]=l):(c=t[7],l=t[8]),Q.useEffect(c,l)},Fv=e=>{let t=(0,du.c)(42),{t:n}=Zt(),[r,i]=Q.useState(null),a=Q.useRef(null),o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>()=>{a.current&&clearTimeout(a.current)},s=[],t[0]=o,t[1]=s):(o=t[0],s=t[1]),Q.useEffect(o,s);let c;t[2]===e?c=t[3]:(c=(t,n,r)=>{let i=()=>{!e.isSessionSearchOpen&&e.sessionSearchQuery.length===0||(e.setSessionSearchQuery(``),e.setIsSessionSearchOpen(!1))};if(r&&r!==e.activeProjectId&&e.setActiveProjectIdOnly(r),n&&n!==e.currentDirectory&&e.setDirectory(n,{showOverlay:!1}),e.setActiveMainTab(`chat`)){if(e.mobileVariant&&e.setSessionSwitcherOpen(!1),t===e.currentSessionId){e.allowReselect&&e.onSessionSelected?.(t),i();return}e.setCurrentSession(t,n??null),e.onSessionSelected?.(t),i()}},t[2]=e,t[3]=c);let l=c,u;t[4]===e?u=t[5]:(u=(t,n)=>{e.setEditingId(t),e.setEditTitle(n)},t[4]=e,t[5]=u);let d=u,f;t[6]===e?f=t[7]:(f=async t=>{if(!e.editingId)return;let n=(t??e.editTitle).trim();n&&await e.updateSessionTitle(e.editingId,n),e.setEditingId(null),e.setEditTitle(``)},t[6]=e,t[7]=f);let p=f,m;t[8]===e?m=t[9]:(m=()=>{e.setEditingId(null),e.setEditTitle(``)},t[8]=e,t[9]=m);let h=m,g;t[10]!==e||t[11]!==n?(g=async t=>{let r=await e.shareSession(t.id);r&&r.share?.url?J.success(n(`sessions.sidebar.session.share.successTitle`),{description:n(`sessions.sidebar.session.share.successDescription`)}):J.error(n(`sessions.sidebar.session.share.error`))},t[10]=e,t[11]=n,t[12]=g):g=t[12];let _=g,v;t[13]===n?v=t[14]:(v=(e,t)=>{Pn(e).then(e=>{if(!e.ok){J.error(n(`sessions.sidebar.session.share.copyUrlError`));return}i(t),a.current&&clearTimeout(a.current),a.current=window.setTimeout(()=>{i(null),a.current=null},2e3)}).catch(()=>{J.error(n(`sessions.sidebar.session.share.copyUrlError`))})},t[13]=n,t[14]=v);let y=v,b;t[15]!==e||t[16]!==n?(b=async t=>{await e.unshareSession(t)?J.success(n(`sessions.sidebar.session.unshare.success`)):J.error(n(`sessions.sidebar.session.unshare.error`))},t[15]=e,t[16]=n,t[17]=b):b=t[17];let x=b,S;t[18]===e.childrenMap?S=t[19]:(S=t=>{let n=[],r=t=>{(e.childrenMap.get(t)??[]).forEach(e=>{n.push(e),r(e.id)})};return r(t),n},t[18]=e.childrenMap,t[19]=S);let C=S,w=Lv,T;t[20]!==e||t[21]!==C||t[22]!==n?(T=async(t,r,i)=>{let a=r?.archivedBucket===!0||r?.hardDelete===!0,o=i?.descendantIds??w(C(t.id),a).map(Rv);if(o.length===0){if(a){il({sessionIds:[t.id],message:n(`sessions.sidebar.session.delete.success`),undoLabel:n(`sessions.sidebar.undo`),commitFailedMessage:n(`sessions.sidebar.session.delete.error`)});return}await e.archiveSession(t.id)?nl({sessionIds:[t.id],message:n(`sessions.sidebar.session.archive.success`),undoLabel:n(`sessions.sidebar.undo`),settingsLabel:n(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:n(`sessions.sidebar.session.archive.undoFailed`)}):J.error(n(`sessions.sidebar.session.archive.error`));return}let s=[t.id,...o];if(a){il({sessionIds:s,message:s.length===1?n(`sessions.sidebar.bulkActions.deletedSingle`,{count:s.length}):n(`sessions.sidebar.bulkActions.deletedPlural`,{count:s.length}),undoLabel:n(`sessions.sidebar.undo`),commitFailedMessage:n(`sessions.sidebar.session.delete.error`)});return}let{archivedIds:c,failedIds:l}=await e.archiveSessions(s);c.length>0&&nl({sessionIds:c,message:c.length===1?n(`sessions.sidebar.bulkActions.archivedSingle`,{count:c.length}):n(`sessions.sidebar.bulkActions.archivedPlural`,{count:c.length}),undoLabel:n(`sessions.sidebar.undo`),settingsLabel:n(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:c.length===1?n(`sessions.sidebar.session.archive.undoFailed`):n(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:c.length})}),l.length>0&&J.error(l.length===1?n(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:l.length}):n(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:l.length}))},t[20]=e,t[21]=C,t[22]=n,t[23]=T):T=t[23];let E=T,D;t[24]!==e||t[25]!==C||t[26]!==E?(D=(t,n)=>{let r=n?.archivedBucket===!0||n?.hardDelete===!0,i=w(C(t.id),r).map(zv);if(!r||!e.showDeletionDialog||n?.skipConfirm===!0){E(t,n,{descendantIds:i});return}e.setDeleteSessionConfirm({session:t,descendantCount:i.length,descendantIds:i,archivedBucket:r})},t[24]=e,t[25]=C,t[26]=E,t[27]=D):D=t[27];let O=D,k;t[28]!==e||t[29]!==E?(k=async()=>{if(!e.deleteSessionConfirm)return;let{session:t,archivedBucket:n,descendantIds:r}=e.deleteSessionConfirm;e.setDeleteSessionConfirm(null),await E(t,{archivedBucket:n},{descendantIds:r})},t[28]=e,t[29]=E,t[30]=k):k=t[30];let A=k,j;return t[31]!==A||t[32]!==r||t[33]!==h||t[34]!==y||t[35]!==O||t[36]!==p||t[37]!==d||t[38]!==l||t[39]!==_||t[40]!==x?(j={copiedSessionId:r,handleSessionSelect:l,handleSessionDoubleClick:d,handleSaveEdit:p,handleCancelEdit:h,handleShareSession:_,handleCopyShareUrl:y,handleUnshareSession:x,handleDeleteSession:O,confirmDeleteSession:A},t[31]=A,t[32]=r,t[33]=h,t[34]=y,t[35]=O,t[36]=p,t[37]=d,t[38]=l,t[39]=_,t[40]=x,t[41]=j):j=t[41],j};function Iv(e){return!e.time?.archived}function Lv(e,t){return t?e:e.filter(Iv)}function Rv(e){return e.id}function zv(e){return e.id}var Bv=[`project:active:`,`project:archived:`,`pinned:active:`,`pinned:archived:`],Vv=e=>{let{isVSCode:t,safeStorage:n,keys:r,groupOrderByProject:i,activeSessionByProject:a,collapsedGroups:o,setExpandedParents:s,setCollapsedProjects:c}=e,l=Q.useRef(null),u=Q.useRef(null),[d,f]=Q.useState(!1),p=Q.useCallback(()=>{if(t)return;let e=u.current;if(u.current=null,l.current=null,!e)return;let{projects:n}=mn.getState(),r=n.map(t=>({...t,sidebarCollapsed:e.has(t.id)}));je({projects:r}).catch(()=>{})},[t]),m=Q.useCallback(e=>{typeof window>`u`||t||(u.current=e,l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>{p()},700))},[t,p]);return Q.useEffect(()=>()=>{typeof window<`u`&&l.current!==null&&window.clearTimeout(l.current),l.current=null,u.current=null},[]),Q.useEffect(()=>{try{let e=n.getItem(r.sessionExpanded);if(e){let t=JSON.parse(e);Array.isArray(t)&&s(new Set(t.filter(e=>typeof e==`string`)))}else{let e=n.getItem(r.sessionExpandedLegacy);if(e){try{let t=JSON.parse(e);if(Array.isArray(t)){let e=new Set;if(t.forEach(t=>{typeof t==`string`&&t.length!==0&&Bv.forEach(n=>e.add(`${n}${t}`))}),e.size>0){s(e);try{n.setItem(r.sessionExpanded,JSON.stringify(Array.from(e)))}catch{}}}}catch{}try{n.removeItem?.(r.sessionExpandedLegacy)}catch{}}}let t=n.getItem(r.projectCollapse);if(t){let e=JSON.parse(t);Array.isArray(e)&&c(new Set(e.filter(e=>typeof e==`string`)))}}catch{}finally{f(!0)}},[r.projectCollapse,r.sessionExpanded,r.sessionExpandedLegacy,n,c,s]),Q.useEffect(()=>{try{let e=Object.fromEntries(i.entries());n.setItem(r.groupOrder,JSON.stringify(e))}catch{}},[i,r.groupOrder,n]),Q.useEffect(()=>{try{let e=Object.fromEntries(a.entries());n.setItem(r.projectActiveSession,JSON.stringify(e))}catch{}},[a,r.projectActiveSession,n]),Q.useEffect(()=>{try{n.setItem(r.groupCollapse,JSON.stringify(Array.from(o)))}catch{}},[o,r.groupCollapse,n]),{scheduleCollapsedProjectsPersist:m,hasRestoredProjectCollapse:d}},Hv=async(e,t,n)=>{if(e.length===0)return[];let r=Math.max(1,Math.min(t,e.length)),i=Array(e.length),a=0,o=async()=>{for(;;){let t=a;if(a+=1,t>=e.length)return;i[t]=await n(e[t])}};return await Promise.all(Array.from({length:r},()=>o())),i},Uv=e=>{let{normalizedProjects:t,activeProjectId:n,gitRepoStatus:r,setProjectRepoStatus:i,setProjectRootBranches:a,enabled:o=!0}=e,{git:s}=St(),c=Eo(e=>e.ensureStatus),l=Q.useMemo(()=>o?t.filter(e=>e.id===n):[],[n,o,t]);Q.useEffect(()=>{if(!o||!s||l.length===0){if(!o)return;i(e=>e.size===0?e:new Map);return}l.forEach(e=>{c(e.normalizedPath,s)})},[l,o,s,c,i]),Q.useEffect(()=>{let e=new Map;l.forEach(t=>{e.set(t.id,r.get(t.normalizedPath)?.isGitRepo??null)}),i(t=>t.size===e.size&&[...e].every(([e,n])=>t.has(e)&&t.get(e)===n)?t:e)},[l,r,i]);let u=Q.useMemo(()=>l.map(e=>{let t=r.get(e.normalizedPath)?.branch??``;return`${e.id}:${t}`}).join(`|`),[l,r]),d=Q.useRef(new Map),f=Q.useRef(new Map);Q.useEffect(()=>{let e=!1,t=setTimeout(()=>{(async()=>{let t=new Set(l.map(e=>e.id));for(let e of d.current.keys())t.has(e)||(d.current.delete(e),f.current.delete(e));let n=Date.now(),i=l.filter(e=>{let t=r.get(e.normalizedPath);if(t?.isGitRepo===!1)return d.current.delete(e.id),f.current.delete(e.id),!1;if(t?.isGitRepo!==!0||t.branch===null)return!1;let i=t.branch.trim(),a=`${e.normalizedPath}\0${i}`,o=d.current.get(e.id);if(o===a){let t=f.current.get(e.id);return t&&(t.at=n),!1}return!(o!==void 0&&n-(f.current.get(e.id)?.at??0)<3e5)});if(i.length===0)return;let o=await Hv(i,2,async e=>{let t=r.get(e.normalizedPath)?.branch?.trim()??``,n=`${e.normalizedPath}\0${t}`,i=await os(e.normalizedPath,t?{knownBranch:t}:void 0).catch(()=>null);return{id:e.id,inputKey:n,branch:i}});if(e)return;let s=o.filter(e=>e.branch);if(s.length===0)return;let c=Date.now();a(e=>{let t=e;return s.forEach(({id:n,branch:r})=>{r&&e.get(n)!==r&&(t===e&&(t=new Map(e)),t.set(n,r))}),t}),s.forEach(({id:e,inputKey:t,branch:n})=>{d.current.set(e,t),n&&f.current.set(e,{branch:n,at:c})})})()},150);return()=>{e=!0,clearTimeout(t)}},[l,u,r,a])},Wv=e=>{let t=(0,du.c)(7),{ownership:n}=e,r;t[0]===n?r=t[1]:(r=e=>n.sessionsByProject.get(e)??[],t[0]=n,t[1]=r);let i=r,a;t[2]===n?a=t[3]:(a=e=>n.archivedSessionsByProject.get(e)??[],t[2]=n,t[3]=a);let o=a,s;return t[4]!==o||t[5]!==i?(s={getSessionsForProject:i,getArchivedSessionsForProject:o},t[4]=o,t[5]=i,t[6]=s):s=t[6],s},Gv=e=>{let t=(0,du.c)(16),{open:n,onOpenChange:r,project:i,onSave:a}=e,o;t[0]!==i?.label||t[1]!==i?.path?(o=i?.label||i?.path.split(/[\\/]/).filter(Boolean).at(-1),t[0]=i?.label,t[1]=i?.path,t[2]=o):o=t[2];let s;t[3]!==a||t[4]!==n||t[5]!==i?(s=n&&i?(0,$.jsx)(Ls,{project:i,onIdentitySave:a,compact:!0}):null,t[3]=a,t[4]=n,t[5]=i,t[6]=s):s=t[6];let c;t[7]===s?c=t[8]:(c=(0,$.jsx)(es,{outerClassName:`max-h-[min(85dvh,44rem)]`,disableHorizontal:!0,children:(0,$.jsx)(`div`,{className:`w-full p-4 sm:p-6`,children:s})}),t[7]=s,t[8]=c);let l;t[9]!==o||t[10]!==c?(l=(0,$.jsx)(Gr,{"aria-label":o,className:`yuri-settings-workspace w-full max-w-xl gap-0 overflow-hidden p-0`,children:c}),t[9]=o,t[10]=c,t[11]=l):l=t[11];let u;return t[12]!==r||t[13]!==n||t[14]!==l?(u=(0,$.jsx)(Jr,{open:n,onOpenChange:r,children:l}),t[12]=r,t[13]=n,t[14]=l,t[15]=u):u=t[15],u};function Kv(e){let t=(0,du.c)(36),{t:n}=Zt(),{hideDirectoryControls:r,isSessionSearchOpen:i,setIsSessionSearchOpen:a,sessionSearchInputRef:o,sessionSearchQuery:s,setSessionSearchQuery:c,hasSessionSearchQuery:l,searchMatchCount:u}=e;if(r||!i)return null;let d;t[0]!==l||t[1]!==u||t[2]!==n?(d=l?(0,$.jsx)(`span`,{children:n(u===1?`sessions.sidebar.header.search.matchCountSingle`:`sessions.sidebar.header.search.matchCountPlural`,{count:u})}):(0,$.jsx)(`span`,{}),t[0]=l,t[1]=u,t[2]=n,t[3]=d):d=t[3];let f;t[4]===n?f=t[5]:(f=n(`sessions.sidebar.header.search.escapeHint`),t[4]=n,t[5]=f);let p;t[6]===f?p=t[7]:(p=(0,$.jsx)(`span`,{children:f}),t[6]=f,t[7]=p);let m;t[8]!==d||t[9]!==p?(m=(0,$.jsxs)(`div`,{className:`mb-1 flex items-center justify-between px-0.5 typography-micro text-muted-foreground/80`,children:[d,p]}),t[8]=d,t[9]=p,t[10]=m):m=t[10];let h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(Z,{name:`search`,className:`pointer-events-none absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),t[11]=h):h=t[11];let g;t[12]===c?g=t[13]:(g=e=>c(e.target.value),t[12]=c,t[13]=g);let _;t[14]===n?_=t[15]:(_=n(`sessions.sidebar.header.search.placeholder`),t[14]=n,t[15]=_);let v;t[16]!==l||t[17]!==a||t[18]!==c?(v=e=>{e.key===`Escape`&&(e.stopPropagation(),l?c(``):a(!1))},t[16]=l,t[17]=a,t[18]=c,t[19]=v):v=t[19];let y;t[20]!==o||t[21]!==s||t[22]!==g||t[23]!==_||t[24]!==v?(y=(0,$.jsx)(`input`,{ref:o,value:s,onChange:g,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:v}),t[20]=o,t[21]=s,t[22]=g,t[23]=_,t[24]=v,t[25]=y):y=t[25];let b;t[26]!==s.length||t[27]!==c||t[28]!==n?(b=s.length>0?(0,$.jsx)(`button`,{type:`button`,onClick:()=>c(``),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:(0,$.jsx)(Z,{name:`close`,className:`h-3.5 w-3.5`})}):null,t[26]=s.length,t[27]=c,t[28]=n,t[29]=b):b=t[29];let x;t[30]!==y||t[31]!==b?(x=(0,$.jsxs)(`div`,{className:`relative`,children:[h,y,b]}),t[30]=y,t[31]=b,t[32]=x):x=t[32];let S;return t[33]!==x||t[34]!==m?(S=(0,$.jsx)(`div`,{className:`select-none flex-shrink-0 px-3 py-1`,children:(0,$.jsxs)(`div`,{className:`pb-1`,children:[m,x]})}),t[33]=x,t[34]=m,t[35]=S):S=t[35],S}function qv(e){let t=(0,du.c)(13),{title:n,accessory:r,isFirst:i,onToggle:a,expanded:o,className:s}=e,c=i!==void 0&&i?`pt-1 pb-1`:`pt-4 pb-1`,l;t[0]!==s||t[1]!==c?(l=X(`group/section flex w-full items-center gap-1 px-2`,c,s),t[0]=s,t[1]=c,t[2]=l):l=t[2];let u;t[3]!==o||t[4]!==a||t[5]!==n?(u=a?(0,$.jsxs)(`button`,{type:`button`,onClick:a,className:`group/toggle flex min-w-0 flex-1 items-center gap-1 rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-expanded":o,children:[(0,$.jsx)(`span`,{className:`typography-micro font-normal tracking-wide text-muted-foreground/80`,children:n}),(0,$.jsx)(Z,{name:o?`arrow-down-s`:`arrow-right-s`,className:`size-3 shrink-0 opacity-0 transition-opacity group-hover/toggle:opacity-100 group-focus-visible/toggle:opacity-100`})]}):(0,$.jsx)(`span`,{className:X(`flex min-w-0 flex-1 items-center gap-1`,`typography-micro font-normal tracking-wide text-muted-foreground/80`),children:n}),t[3]=o,t[4]=a,t[5]=n,t[6]=u):u=t[6];let d;t[7]===r?d=t[8]:(d=r?(0,$.jsx)(`div`,{className:`ml-auto -mr-2 flex shrink-0 items-center`,children:r}):null,t[7]=r,t[8]=d);let f;return t[9]!==l||t[10]!==u||t[11]!==d?(f=(0,$.jsxs)(`div`,{className:l,children:[u,d]}),t[9]=l,t[10]=u,t[11]=d,t[12]=f):f=t[12],f}function Jv(e){let t=(0,du.c)(60),{items:n,reorderEnabled:r,onSessionsReordered:i,inProgressItems:a,renderSessionNode:o,currentSessionId:s,editingId:c,openSidebarMenuKey:l,headerAccessory:u,onVisibleSessionIdsChange:d}=e,f=r!==void 0&&r,p;t[0]===a?p=t[1]:(p=a===void 0?[]:a,t[0]=a,t[1]=p);let m=p,{t:h}=Zt(),[g,_]=Q.useState(!1),v=f&&!c&&n.length>1&&!!i,y;t[2]===n?y=t[3]:(y=n.map(ny),t[2]=n,t[3]=y);let b=y,x;t[4]===b?x=t[5]:(x=new Map(b.map(ty)),t[4]=b,t[5]=x);let S=x,C=ga(ey),w,T;t[6]!==g||t[7]!==m||t[8]!==n||t[9]!==d?(w=()=>{if(g){d?.([]);return}d?.([...n.map($v),...m.map(Qv)])},T=[g,m,n,d],t[6]=g,t[7]=m,t[8]=n,t[9]=d,t[10]=w,t[11]=T):(w=t[10],T=t[11]),Q.useLayoutEffect(w,T);let E,D;t[12]!==m||t[13]!==n||t[14]!==C?(E=()=>{C&&(n.some(e=>e.node.session.id===C)||m.some(e=>e.node.session.id===C))&&_(!1)},D=[m,n,C],t[12]=m,t[13]=n,t[14]=C,t[15]=E,t[16]=D):(E=t[15],D=t[16]),Q.useLayoutEffect(E,D);let O,k,A,j;if(t[17]!==s||t[18]!==c||t[19]!==m||t[20]!==n||t[21]!==l){let e=[...n,...m].map(Zv);A=new Set,rl(e,s,A),j=new Set,rl(e,c,j),O=yl(e,l,`pinned`,!1),k=new WeakMap;let r=e=>{k.set(e,tl(e)),e.children.forEach(r)};e.forEach(r),t[17]=s,t[18]=c,t[19]=m,t[20]=n,t[21]=l,t[22]=O,t[23]=k,t[24]=A,t[25]=j}else O=t[22],k=t[23],A=t[24],j=t[25];let M;t[26]!==O||t[27]!==k||t[28]!==A||t[29]!==j?(M=e=>({subtreeContainsActive:A,subtreeContainsEditing:j,menuOpenSessionId:O,nodeStructureKey:k.get(e)??``,childRenderExtrasFor:M}),t[26]=O,t[27]=k,t[28]=A,t[29]=j,t[30]=M):M=t[30];let N;t[31]!==M||t[32]!==O||t[33]!==k||t[34]!==A||t[35]!==j?(N=e=>({subtreeContainsActive:A,subtreeContainsEditing:j,menuOpenSessionId:O,nodeStructureKey:k.get(e)??``,childRenderExtrasFor:M}),t[31]=M,t[32]=O,t[33]=k,t[34]=A,t[35]=j,t[36]=N):N=t[36];let P=N;if(n.length+m.length===0)return null;let F;t[37]!==P||t[38]!==o?(F=e=>e.map(e=>{let t=e.content??o(e.node,0,e.groupDirectory,e.projectId,!1,e.secondaryMeta,`pinned`,P(e.node));return(0,$.jsx)(Q.Fragment,{children:t},e.identity??e.node.session.id)}),t[37]=P,t[38]=o,t[39]=F):F=t[39];let I=F,L;t[40]!==m.length||t[41]!==h?(L=m.length>0?h(`directoryTree.section.pinnedInProgress`):h(`directoryTree.section.pinned`),t[40]=m.length,t[41]=h,t[42]=L):L=t[42];let R;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>_(Xv),t[43]=R):R=t[43];let z=!g,ee;t[44]!==u||t[45]!==L||t[46]!==z?(ee=(0,$.jsx)(qv,{title:L,onToggle:R,expanded:z,accessory:u}),t[44]=u,t[45]=L,t[46]=z,t[47]=ee):ee=t[47];let B;t[48]!==v||t[49]!==g||t[50]!==S||t[51]!==m||t[52]!==n||t[53]!==i||t[54]!==I||t[55]!==b?(B=g?null:(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[v?(0,$.jsx)(xc,{scopeKey:Zc,sessionIds:b,folderIdBySessionId:S,onSessionDroppedOnFolder:Yv,onSessionsReordered:(e,t)=>i?.(e,t),children:I(n)}):I(n),I(m)]}),t[48]=v,t[49]=g,t[50]=S,t[51]=m,t[52]=n,t[53]=i,t[54]=I,t[55]=b,t[56]=B):B=t[56];let V;return t[57]!==ee||t[58]!==B?(V=(0,$.jsx)(Da,{delay:0,closeDelay:150,timeout:600,children:(0,$.jsxs)(`div`,{className:`pb-1`,children:[ee,B]})}),t[57]=ee,t[58]=B,t[59]=V):V=t[59],V}function Yv(){}function Xv(e){return!e}function Zv(e){return e.node}function Qv(e){return e.node.session.id}function $v(e){return e.node.session.id}function ey(e){return e.focus?.scope===`pinned`?e.focus.sessionId:null}function ty(e){return[e,null]}function ny(e){return e.node.session.id}function ry(e){let t=(0,du.c)(41),{collapseAllProjects:n,expandAllProjects:r,buttonClassName:i,iconClassName:a}=e,{t:o}=Zt(),s;t[0]===i?s=t[1]:(s=X(`size-6 p-0 text-muted-foreground`,i),t[0]=i,t[1]=s);let c;t[2]===o?c=t[3]:(c=o(`sessions.sidebar.header.actions.sessionDisplayMode`),t[2]=o,t[3]=c);let l;t[4]===a?l=t[5]:(l=X(`h-3.5 w-3.5`,a),t[4]=a,t[5]=l);let u;t[6]===l?u=t[7]:(u=(0,$.jsx)(Z,{name:`more-2-fill`,className:l}),t[6]=l,t[7]=u);let d;t[8]!==s||t[9]!==c||t[10]!==u?(d=(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(Ra,{asChild:!0,children:(0,$.jsx)(Y,{variant:`ghost`,size:`xs`,className:s,"aria-label":c,onClick:iy,children:u})})}),t[8]=s,t[9]=c,t[10]=u,t[11]=d):d=t[11];let f;t[12]===o?f=t[13]:(f=o(`sessions.sidebar.header.displayMode.label`),t[12]=o,t[13]=f);let p;t[14]===f?p=t[15]:(p=(0,$.jsx)(Ea,{side:`bottom`,sideOffset:4,children:(0,$.jsx)(`p`,{children:f})}),t[14]=f,t[15]=p);let m;t[16]!==d||t[17]!==p?(m=(0,$.jsxs)(Oa,{children:[d,p]}),t[16]=d,t[17]=p,t[18]=m):m=t[18];let h;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(Z,{name:`contract-up-down`,className:`h-4 w-4`}),t[19]=h):h=t[19];let g;t[20]===o?g=t[21]:(g=o(`sessions.sidebar.header.displayMode.collapseAll`),t[20]=o,t[21]=g);let _;t[22]===g?_=t[23]:(_=(0,$.jsx)(`span`,{children:g}),t[22]=g,t[23]=_);let v;t[24]!==n||t[25]!==_?(v=(0,$.jsxs)(ao,{onClick:n,className:`flex items-center gap-2`,children:[h,_]}),t[24]=n,t[25]=_,t[26]=v):v=t[26];let y;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(Z,{name:`expand-up-down`,className:`h-4 w-4`}),t[27]=y):y=t[27];let b;t[28]===o?b=t[29]:(b=o(`sessions.sidebar.header.displayMode.expandAll`),t[28]=o,t[29]=b);let x;t[30]===b?x=t[31]:(x=(0,$.jsx)(`span`,{children:b}),t[30]=b,t[31]=x);let S;t[32]!==r||t[33]!==x?(S=(0,$.jsxs)(ao,{onClick:r,className:`flex items-center gap-2`,children:[y,x]}),t[32]=r,t[33]=x,t[34]=S):S=t[34];let C;t[35]!==v||t[36]!==S?(C=(0,$.jsxs)(Ia,{align:`end`,className:`min-w-[160px]`,children:[v,S]}),t[35]=v,t[36]=S,t[37]=C):C=t[37];let w;return t[38]!==C||t[39]!==m?(w=(0,$.jsxs)(Na,{children:[m,C]}),t[38]=C,t[39]=m,t[40]=w):w=t[40],w}function iy(e){e.stopPropagation()}var ay=()=>ht({queryKey:[l(),u(),`device-connections`],queryFn:async({signal:e})=>{let t=await h(`/api/client-auth/clients`,{signal:e});if(!t.ok)throw Error(`Device list unavailable`);let n=await t.json();if(!Array.isArray(n.clients))throw Error(`Invalid device list`);if(n.clients.some(e=>typeof e.connected!=`boolean`))throw Error(`Presence unavailable`);return n.clients.filter(e=>!e.revokedAt&&e.connected&&e.clientKind!==`desktop-local`&&e.id!==n.currentClientId)},staleTime:0,retry:!1});function oy(){let e=(0,du.c)(53),{t}=Zt(),{clientAuth:n}=St(),[r,i]=(0,Q.useState)(!1),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=ay(),e[0]=a):a=e[0];let o=r&&!!n,s=r?5e3:!1,c;e[1]!==o||e[2]!==s?(c={...a,enabled:o,refetchInterval:s},e[1]=o,e[2]=s,e[3]=c):c=e[3];let l=gt(c),u;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{i(!1);let e=q.getState();e.setSettingsRemoteInstancesSelectedId(null),e.setSettingsPage(`remote-instances`),q.setState({devicePairingRequested:!0}),e.setSettingsDialogOpen(!0)},e[4]=u):u=e[4];let d=K(u);if(!n)return null;let f;e[5]===t?f=e[6]:(f=t(`settings.remoteInstances.quick.title`),e[5]=t,e[6]=f);let p;e[7]===f?p=e[8]:(p=(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,className:`group size-7 rounded-md text-foreground/55 hover:bg-interactive-hover hover:text-foreground`,"aria-label":f}),e[7]=f,e[8]=p);let m;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(Z,{name:`devices-connected`,className:`size-[18px]`}),e[9]=m):m=e[9];let h;e[10]===p?h=e[11]:(h=(0,$.jsx)(Oe,{openOnHover:!0,delay:180,closeDelay:200,render:p,children:m}),e[10]=p,e[11]=h);let g;e[12]===t?g=e[13]:(g=t(`settings.remoteInstances.quick.title`),e[12]=t,e[13]=g);let _;e[14]===g?_=e[15]:(_=(0,$.jsx)(me,{className:`typography-ui-label font-medium`,children:g}),e[14]=g,e[15]=_);let v;e[16]===l.data?v=e[17]:(v=l.data&&l.data.length>0?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:l.data.length}):null,e[16]=l.data,e[17]=v);let y;e[18]!==_||e[19]!==v?(y=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pb-2 pt-4`,children:[_,v]}),e[18]=_,e[19]=v,e[20]=y):y=e[20];let b;e[21]!==l.isPending||e[22]!==t?(b=l.isPending?(0,$.jsx)(`p`,{className:`px-2 py-3 typography-meta text-muted-foreground`,children:t(`common.loading`)}):null,e[21]=l.isPending,e[22]=t,e[23]=b):b=e[23];let x;e[24]!==l.isError||e[25]!==t?(x=l.isError?(0,$.jsx)(`p`,{className:`px-2 py-3 typography-meta text-muted-foreground`,children:t(`settings.remoteInstances.quick.error`)}):null,e[24]=l.isError,e[25]=t,e[26]=x):x=e[26];let S;e[27]!==l.data?.length||e[28]!==l.isError||e[29]!==t?(S=!l.isError&&l.data?.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center px-5 pb-5 pt-6 text-center`,children:[(0,$.jsx)(Z,{name:`devices-connected`,className:`mb-4 size-16 text-muted-foreground/45`}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:t(`settings.remoteInstances.clientAuth.state.empty`)}),(0,$.jsx)(`p`,{className:`mt-2 typography-meta leading-relaxed text-muted-foreground`,children:t(`settings.remoteInstances.quick.emptyHint`)})]}):null,e[27]=l.data?.length,e[28]=l.isError,e[29]=t,e[30]=S):S=e[30];let C;e[31]!==l.data||e[32]!==t?(C=l.data?.map(e=>{let n=e.devicePlatform?.toLowerCase();return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl px-3 py-2.5`,children:[(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(Z,{name:n===`ios`?`device-ios`:n===`android`?`device-android`:`device-desktop`,className:`size-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`truncate typography-ui-label`,children:e.label}),(0,$.jsx)(`p`,{className:`mt-0.5 truncate typography-micro text-[var(--status-success)]`,children:t(`desktopHostSwitcher.status.connected`)})]})]},e.id)}),e[31]=l.data,e[32]=t,e[33]=C):C=e[33];let w;e[34]!==b||e[35]!==x||e[36]!==S||e[37]!==C?(w=(0,$.jsxs)(`div`,{className:`max-h-64 space-y-2 overflow-y-auto px-3 pb-2`,"aria-live":`polite`,children:[b,x,S,C]}),e[34]=b,e[35]=x,e[36]=S,e[37]=C,e[38]=w):w=e[38];let T;e[39]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Z,{name:`add`,className:`size-4`}),e[39]=T):T=e[39];let E;e[40]===t?E=e[41]:(E=t(`settings.remoteInstances.clientAuth.actions.addDevice`),e[40]=t,e[41]=E);let D;e[42]!==d||e[43]!==E?(D=(0,$.jsx)(`div`,{className:`px-3 pb-3 pt-1`,children:(0,$.jsxs)(Y,{variant:`secondary`,size:`sm`,className:`w-full justify-center gap-2 rounded-xl`,onClick:d,children:[T,E]})}),e[42]=d,e[43]=E,e[44]=D):D=e[44];let O;e[45]!==y||e[46]!==w||e[47]!==D?(O=(0,$.jsx)(ye,{children:(0,$.jsx)(ge,{side:`top`,align:`start`,sideOffset:10,className:`z-50`,children:(0,$.jsxs)(he,{className:`yuri-mobile-overlay-surface yuri-popup-surface w-72 max-w-[calc(100vw-24px)] origin-[var(--transform-origin)] overflow-hidden rounded-2xl outline-none transition-[opacity,transform] duration-150 data-[starting-style]:translate-y-1 data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`,children:[y,w,D]})})}),e[45]=y,e[46]=w,e[47]=D,e[48]=O):O=e[48];let k;return e[49]!==r||e[50]!==O||e[51]!==h?(k=(0,$.jsxs)(fe,{open:r,onOpenChange:i,children:[h,O]}),e[49]=r,e[50]=O,e[51]=h,e[52]=k):k=e[52],k}function sy(e){let t=(0,du.c)(11),{task:n}=e,r=n.total>0?Math.min(99,Math.floor(Math.max(0,n.completed)/n.total*100)):void 0,i=`inline-flex size-4 shrink-0 ${n.failed?`text-[var(--status-error)]`:``}`,a=`size-full -rotate-90 ${r===void 0&&!n.failed?`motion-safe:animate-spin`:``}`,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`circle`,{cx:`9`,cy:`9`,r:`7.5`,stroke:`currentColor`,strokeOpacity:`0.2`,strokeWidth:`1.5`}),t[0]=o):o=t[0];let s=100-(r??22),c;t[1]===s?c=t[2]:(c=(0,$.jsx)(`circle`,{cx:`9`,cy:`9`,r:`7.5`,pathLength:`100`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeDasharray:`100`,strokeDashoffset:s,className:`motion-safe:transition-[stroke-dashoffset] motion-safe:duration-300`}),t[1]=s,t[2]=c);let l;t[3]!==a||t[4]!==c?(l=(0,$.jsxs)(`svg`,{viewBox:`0 0 18 18`,fill:`none`,"aria-hidden":`true`,className:a,children:[o,c]}),t[3]=a,t[4]=c,t[5]=l):l=t[5];let u;return t[6]!==i||t[7]!==l||t[8]!==n.detail||t[9]!==r?(u=(0,$.jsx)(`span`,{role:`progressbar`,"aria-label":n.detail,"aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,className:i,children:l}),t[6]=i,t[7]=l,t[8]=n.detail,t[9]=r,t[10]=u):u=t[10],u}function cy({task:e}){let{t,locale:n}=Zt(),[r,i]=Q.useState(!1),a=Q.useRef(!1),o=mt({mutationFn:async t=>{try{await(t===`dismiss`?e.dismiss?.():e.resume?.())}finally{a.current=!1}},onError:(t,n)=>{n===`resume`&&e.dismiss&&i(!0)},retry:!1}),s=e=>new Intl.NumberFormat(n).format(e),c=e=>new Intl.NumberFormat(n,{minimumFractionDigits:1,maximumFractionDigits:1}).format(e/1e6),l=e.total>0?Math.min(100,Math.max(0,e.completed/e.total*100)):void 0;return(0,$.jsxs)(`div`,{className:`grid grid-cols-[1rem_minmax(0,1fr)_auto] items-center gap-x-2.5 gap-y-2 py-2.5`,"data-background-task":e.id,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:(0,$.jsx)(sy,{task:e})}),(0,$.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label`,children:e.label}),e.detail!==e.label&&(0,$.jsx)(`span`,{className:`break-words typography-micro text-muted-foreground`,children:e.detail})]}),(0,$.jsx)(`div`,{role:`progressbar`,"aria-label":e.detail,"aria-valuenow":l,"aria-valuemin":0,"aria-valuemax":100,className:`my-1.5 h-1 overflow-hidden rounded-full bg-[var(--surface-subtle)]`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full ${e.failed?`bg-[var(--status-error)]`:`bg-[var(--primary-base)]`} ${l===void 0?e.failed?`w-1/3`:`w-1/3 motion-safe:animate-pulse`:`motion-safe:transition-[width] motion-safe:duration-300`}`,style:l===void 0?void 0:{width:`${l}%`}})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 typography-micro tabular-nums text-muted-foreground`,"data-background-task-meta":!0,children:[e.bytes?(0,$.jsx)(`span`,{children:t(e.total>0?`backgroundTasks.downloaded`:`backgroundTasks.downloadedUnknownTotal`,{completed:c(e.completed),total:c(e.total)})}):e.total>0&&!e.hideCounts&&(0,$.jsx)(`span`,{"aria-label":t(`backgroundTasks.processed`,{completed:s(e.completed),total:s(e.total)}),children:`${s(e.completed)} / ${s(e.total)}`}),!!e.failures&&(0,$.jsx)(`span`,{className:`text-[var(--status-error)]`,children:t(`backgroundTasks.failedCount`,{count:s(e.failures)})})]})]}),e.failed&&e.resume&&(0,$.jsx)(Y,{size:`xs`,className:`shrink-0`,disabled:o.isPending,onClick:()=>{a.current||(a.current=!0,o.mutate(r?`dismiss`:`resume`))},children:t(r?o.isPending?`backgroundTasks.removing`:`backgroundTasks.dismiss`:o.isPending?`backgroundTasks.resuming`:`backgroundTasks.resume`)}),e.stale&&(0,$.jsx)(`p`,{className:`col-span-2 col-start-2 typography-micro text-muted-foreground`,children:t(`backgroundTasks.progressUnavailable`)}),o.isError&&(0,$.jsx)(`p`,{role:`alert`,className:`col-span-2 col-start-2 typography-micro text-[var(--status-error)]`,children:t(o.variables===`dismiss`?`backgroundTasks.dismissFailed`:o.error.message===`update_plan_changed`?`backgroundTasks.updateChanged`:o.error.message===`resume_request_missing`?`backgroundTasks.originalSelectionMissing`:`backgroundTasks.resumeFailed`)})]})}var ly=Q.memo(function(e){let t=(0,du.c)(4),{compactWithRestart:n}=e,r=n!==void 0&&n,i=Q.useSyncExternalStore(s,u,u),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=l(),t[0]=a):a=t[0];let o=`${a}:${i}`,c;return t[1]!==r||t[2]!==o?(c=(0,$.jsx)(uy,{compactWithRestart:r},o),t[1]=r,t[2]=o,t[3]=c):c=t[3],c});function uy(e){let t=(0,du.c)(126),{compactWithRestart:n}=e,{t:r,locale:i}=Zt(),[a,o]=Q.useState(!1),s=As(Dy),c=As(Ey),d=As(Ty),f=As(wy),p=As(Cy),m=As(Sy),h=As(xy),g=l(),_=u(),v=gt({...ql(g),retry:!1,refetchInterval:yy}),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y={...Uc(),retry:!1,refetchInterval:vy},t[0]=y):y=t[0];let b=gt(y),x=Ss(g,_),C;t[1]===x?C=t[2]:(C={...x,refetchInterval:_y},t[1]=x,t[2]=C);let w=gt(C),T;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(T=new Set,t[3]=T):T=t[3];let E=Q.useRef(T),D,O;t[4]!==_||t[5]!==v.data||t[6]!==v.isError||t[7]!==g?(D=()=>{if(!v.data||v.isError)return;let e=new Set(v.data.filter(gy).map(hy)),t=[...E.current].some(t=>!e.has(t));E.current=e,t&&g===l()&&_===u()&&Nn(g).catch(my)},O=[v.data,v.isError,g,_],t[4]=_,t[5]=v.data,t[6]=v.isError,t[7]=g,t[8]=D,t[9]=O):(D=t[8],O=t[9]),Q.useEffect(D,O);let k;if(t[10]!==m||t[11]!==d||t[12]!==h||t[13]!==f||t[14]!==c||t[15]!==s||t[16]!==_||t[17]!==b||t[18]!==v.data||t[19]!==v.isError||t[20]!==r||t[21]!==g||t[22]!==w||t[23]!==p){k=[];for(let e of v.data??[])if(!Wl(e)){let t=Jl(e);k.push({id:e.id,label:r(`backgroundTasks.import`),detail:r(e.state===`running`?`historyImport.phase.${t.phase}`:`historyImport.state.${e.state}`),...t,stale:v.isError,failed:e.state!==`running`,failures:e.failures,resume:()=>Gl(e.id,g,_),dismiss:()=>Kl(e.id,g,_)})}if(b.data&&b.data.phase!==`ready`){let e;t[25]===r?e=t[26]:(e=r(`backgroundTasks.index`),t[25]=r,t[26]=e);let n;t[27]===b.data.phase?n=t[28]:(n=[`partial`,`error`].includes(b.data.phase)?`backgroundTasks.indexFailed`:`backgroundTasks.indexing`,t[27]=b.data.phase,t[28]=n);let i;t[29]!==r||t[30]!==n?(i=r(n),t[29]=r,t[30]=n,t[31]=i):i=t[31];let a=b.data.completed,o=b.data.total,s=b.isError,c;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(c=[`partial`,`error`],t[32]=c):c=t[32];let l=c.includes(b.data.phase),u;t[33]!==_||t[34]!==g?(u=()=>Gc(g,_),t[33]=_,t[34]=g,t[35]=u):u=t[35];let d;t[36]!==b.data.completed||t[37]!==b.data.failed||t[38]!==b.data.total||t[39]!==b.isError||t[40]!==l||t[41]!==u||t[42]!==e||t[43]!==i?(d={id:`content-index`,label:e,detail:i,completed:a,total:o,stale:s,failed:l,failures:b.data.failed,resume:u},t[36]=b.data.completed,t[37]=b.data.failed,t[38]=b.data.total,t[39]=b.isError,t[40]=l,t[41]=u,t[42]=e,t[43]=i,t[44]=d):d=t[44],k.push(d)}if(s||d){let e;t[45]===r?e=t[46]:(e=r(`backgroundTasks.download`),t[45]=r,t[46]=e);let n=d?`backgroundTasks.downloadFailed`:`updateDialog.status.downloading`,i;t[47]!==r||t[48]!==n?(i=r(n),t[47]=r,t[48]=n,t[49]=i):i=t[49];let a=!!d,o;t[50]!==m||t[51]!==h||t[52]!==a||t[53]!==e||t[54]!==i?(o={id:`client-update`,label:e,detail:i,completed:m,total:h,stale:!1,bytes:!0,failed:a,resume:py},t[50]=m,t[51]=h,t[52]=a,t[53]=e,t[54]=i,t[55]=o):o=t[55],k.push(o)}let e=w.data?.operation;if(e&&(Ws(e)||e.status===`failed`)&&!((s||d||c&&Ws(e))&&e.version===(f??p)&&S())){let n=e.id,i;t[56]===r?i=t[57]:(i=r(`backgroundTasks.download`),t[56]=r,t[57]=i);let a=e.status===`failed`?`backgroundTasks.downloadFailed`:e.status===`installing`?`updateDialog.status.installingUpdate`:e.status===`restarting`?`updateDialog.status.serverRestarting`:e.status===`checking`?`updateDialog.status.updating`:`updateDialog.status.downloading`,o;t[58]!==r||t[59]!==a?(o=r(a),t[58]=r,t[59]=a,t[60]=o):o=t[60];let s=`${o} · ${e.version}`,c=e.progress??0,l=e.progress==null?0:100,u=e.status===`failed`,d;t[61]!==_||t[62]!==e||t[63]!==g?(d=()=>xs(e,g,_),t[61]=_,t[62]=e,t[63]=g,t[64]=d):d=t[64];let f;t[65]!==e.id||t[66]!==s||t[67]!==c||t[68]!==l||t[69]!==u||t[70]!==d||t[71]!==i||t[72]!==w.isError?(f={id:n,label:i,detail:s,completed:c,total:l,stale:w.isError,hideCounts:!0,failed:u,resume:d},t[65]=e.id,t[66]=s,t[67]=c,t[68]=l,t[69]=u,t[70]=d,t[71]=i,t[72]=w.isError,t[73]=f):f=t[73],k.push(f)}t[10]=m,t[11]=d,t[12]=h,t[13]=f,t[14]=c,t[15]=s,t[16]=_,t[17]=b,t[18]=v.data,t[19]=v.isError,t[20]=r,t[21]=g,t[22]=w,t[23]=p,t[24]=k}else k=t[24];if(!k.length&&!a)return null;let A;t[74]===i?A=t[75]:(A=e=>new Intl.NumberFormat(i).format(e),t[74]=i,t[75]=A);let j=A,M=`w-fit min-w-0 shrink text-muted-foreground/60 ${k.length?``:`invisible`}`,N=k.length?``:void 0,P=n&&c&&k.length===1?`icon`:`xs`,F;t[76]===r?F=t[77]:(F=r(`backgroundTasks.title`),t[76]=r,t[77]=F);let I;t[78]!==n||t[79]!==c||t[80]!==r||t[81]!==k[0]||t[82]!==k.length?(I=n&&c?k.length===1?k[0].label:r(`backgroundTasks.title`):void 0,t[78]=n,t[79]=c,t[80]=r,t[81]=k[0],t[82]=k.length,t[83]=I):I=t[83];let L=`max-w-full gap-2 text-[10px] font-normal text-muted-foreground/60 ${n&&c&&k.length===1?`size-7 rounded-md`:``}`,R;t[84]!==P||t[85]!==F||t[86]!==I||t[87]!==L?(R=(0,$.jsx)(Y,{variant:`ghost`,size:P,"aria-label":F,title:I,className:L}),t[84]=P,t[85]=F,t[86]=I,t[87]=L,t[88]=R):R=t[88];let z;t[89]===k?z=t[90]:(z=k.map(fy),t[89]=k,t[90]=z);let ee;t[91]!==n||t[92]!==c||t[93]!==k[0]||t[94]!==k.length?(ee=k.length===1&&!(n&&c)&&(0,$.jsx)(`span`,{className:`truncate`,children:k[0].label}),t[91]=n,t[92]=c,t[93]=k[0],t[94]=k.length,t[95]=ee):ee=t[95];let B;t[96]!==R||t[97]!==z||t[98]!==ee?(B=(0,$.jsxs)(Oe,{render:R,children:[z,ee]}),t[96]=R,t[97]=z,t[98]=ee,t[99]=B):B=t[99];let V;t[100]!==B||t[101]!==M||t[102]!==N?(V=(0,$.jsx)(`div`,{className:M,"data-sidebar-background-tasks":N,children:B}),t[100]=B,t[101]=M,t[102]=N,t[103]=V):V=t[103];let te;t[104]===r?te=t[105]:(te=r(`backgroundTasks.title`),t[104]=r,t[105]=te);let ne;t[106]===te?ne=t[107]:(ne=(0,$.jsx)(me,{className:`typography-micro font-medium text-muted-foreground`,children:te}),t[106]=te,t[107]=ne);let re;t[108]!==j||t[109]!==k.length?(re=k.length>0&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:j(k.length)}),t[108]=j,t[109]=k.length,t[110]=re):re=t[110];let ie;t[111]!==ne||t[112]!==re?(ie=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pb-1 pt-3`,children:[ne,re]}),t[111]=ne,t[112]=re,t[113]=ie):ie=t[113];let ae;t[114]!==r||t[115]!==k?(ae=k.length?k.map(dy):(0,$.jsx)(`p`,{className:`px-2 py-3 typography-meta text-muted-foreground`,children:r(`backgroundTasks.empty`)}),t[114]=r,t[115]=k,t[116]=ae):ae=t[116];let oe;t[117]===ae?oe=t[118]:(oe=(0,$.jsx)(`div`,{className:`max-h-64 divide-y-[length:var(--yuri-popup-divider-width)] divide-[var(--yuri-popup-divider)] overflow-y-auto px-3 pb-1`,"data-background-task-details":!0,children:ae}),t[117]=ae,t[118]=oe);let H;t[119]!==ie||t[120]!==oe?(H=(0,$.jsx)(ye,{children:(0,$.jsx)(ge,{side:`top`,align:`center`,sideOffset:10,className:`z-50`,children:(0,$.jsxs)(he,{initialFocus:!1,className:`yuri-mobile-overlay-surface yuri-popup-surface w-72 max-w-[calc(100vw-24px)] origin-[var(--transform-origin)] overflow-hidden rounded-2xl outline-none transition-[opacity,transform] duration-150 data-[starting-style]:translate-y-1 data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`,children:[ie,oe]})})}),t[119]=ie,t[120]=oe,t[121]=H):H=t[121];let se;return t[122]!==a||t[123]!==V||t[124]!==H?(se=(0,$.jsxs)(fe,{open:a,onOpenChange:o,children:[V,H]}),t[122]=a,t[123]=V,t[124]=H,t[125]=se):se=t[125],se}function dy(e){return(0,$.jsx)(cy,{task:e},e.id)}function fy(e){return(0,$.jsx)(sy,{task:e},e.id)}async function py(){if(await As.getState().downloadUpdate({resume:!0}),As.getState().downloadError)throw Error(As.getState().downloadError)}function my(){}function hy(e){return e.id}function gy(e){return e.state===`running`}function _y(e){return Ws(e.state.data?.operation)?2e3:e.state.error?.message!==`host_update_unsupported`&&15e3}function vy(e){return e.state.data===null?!1:e.state.data?.phase===`indexing`||e.state.data?.phase===`pending`?3e3:15e3}function yy(e){return e.state.error?.message===`history_import_unsupported`?!1:e.state.data?.some(by)?1e3:15e3}function by(e){return e.state===`running`}function xy(e){return e.progress?.total??0}function Sy(e){return e.progress?.downloaded??0}function Cy(e){return e.info?.version}function wy(e){return e.downloadVersion}function Ty(e){return e.downloadError}function Ey(e){return e.downloaded}function Dy(e){return e.downloading}var Oy=`group size-7 rounded-md text-muted-foreground/75 transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:ring-2 focus-visible:ring-primary`,ky=`size-4 text-foreground/55 transition-colors group-hover:text-foreground group-focus-visible:text-foreground`;function Ay(e){let t=(0,du.c)(32),{onOpenUpdate:n,hideDownload:r}=e,{t:i}=Zt(),a=As(Fy),o=As(Py),s=As(Ny),c=As(My),l=As(jy),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=[`update`,`restart-to-apply`],t[0]=u):u=t[0];let d;t[1]===c?d=t[2]:(d={mutationKey:u,mutationFn:()=>c(),retry:!1,networkMode:`always`},t[1]=c,t[2]=d);let f=mt(d),p=f.isPending,m=Q.useRef(!1),h;t[3]!==o||t[4]!==n||t[5]!==f||t[6]!==p?(h=()=>{if(o&&!p){if(m.current)return;m.current=!0,f.mutate();return}n()},t[3]=o,t[4]=n,t[5]=f,t[6]=p,t[7]=h):h=t[7];let g=K(h),_;t[8]!==o||t[9]!==a||t[10]!==s||t[11]!==p||t[12]!==i?(_=s||i(a?`updateDialog.status.downloading`:p?`updateDialog.status.updating`:o?`sessions.sidebar.footer.actions.restartUpdate`:`sessions.sidebar.footer.actions.update`),t[8]=o,t[9]=a,t[10]=s,t[11]=p,t[12]=i,t[13]=_):_=t[13];let v=_;if(r&&a)return null;let y=p||void 0,b;t[14]!==o||t[15]!==a||t[16]!==l||t[17]!==p||t[18]!==v?(b=o?(0,$.jsx)(Z,{name:`restart`,className:`${ky} ${p?`motion-safe:animate-spin`:``}`}):a?(0,$.jsxs)(`svg`,{viewBox:`0 0 18 18`,className:l===null?`size-4 animate-spin`:`size-4 -rotate-90`,role:`progressbar`,"aria-label":v,"aria-valuenow":l??void 0,"aria-valuemin":0,"aria-valuemax":100,children:[(0,$.jsx)(`circle`,{cx:`9`,cy:`9`,r:`7.5`,fill:`none`,stroke:`currentColor`,strokeOpacity:`0.25`,strokeWidth:`2`}),(0,$.jsx)(`circle`,{cx:`9`,cy:`9`,r:`7.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,pathLength:`100`,strokeDasharray:`100`,strokeDashoffset:100-(l===null?25:Math.max(0,Math.min(100,l))),className:`transition-[stroke-dashoffset] duration-300`})]}):(0,$.jsx)(Z,{name:`download`,className:ky}),t[14]=o,t[15]=a,t[16]=l,t[17]=p,t[18]=v,t[19]=b):b=t[19];let x;t[20]!==g||t[21]!==p||t[22]!==y||t[23]!==b||t[24]!==v?(x=(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,className:`${Oy} disabled:opacity-100`,onClick:g,disabled:p,"aria-busy":y,"aria-label":v,children:b})}),t[20]=g,t[21]=p,t[22]=y,t[23]=b,t[24]=v,t[25]=x):x=t[25];let S=a&&l!==null?` ${l}%`:``,C;t[26]!==S||t[27]!==v?(C=(0,$.jsx)(Ea,{side:`top`,sideOffset:4,children:(0,$.jsxs)(`p`,{children:[v,S]})}),t[26]=S,t[27]=v,t[28]=C):C=t[28];let w;return t[29]!==x||t[30]!==C?(w=(0,$.jsxs)(Oa,{children:[x,C]}),t[29]=x,t[30]=C,t[31]=w):w=t[31],w}function jy(e){return e.progress?.total?Math.round(e.progress.downloaded/e.progress.total*100):null}function My(e){return e.restartToUpdate}function Ny(e){return e.error}function Py(e){return e.downloaded}function Fy(e){return e.downloading}function Iy(e){let t=(0,du.c)(19),{onOpenSettings:n,onOpenShortcuts:r,onOpenUpdate:i,showRuntimeButtons:a,showUpdateButton:o}=e,s=a===void 0||a,c=o!==void 0&&o,{t:l}=Zt(),u;t[0]!==n||t[1]!==r||t[2]!==s||t[3]!==l?(u=s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,className:Oy,onClick:n,"aria-label":l(`sessions.sidebar.footer.actions.settings`),children:(0,$.jsx)(Z,{name:`settings-3`,className:ky})})}),(0,$.jsx)(Ea,{side:`top`,sideOffset:4,children:l(`sessions.sidebar.footer.actions.settings`)})]}),(0,$.jsx)(oy,{}),(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,className:Oy,onClick:r,"aria-label":l(`sessions.sidebar.footer.actions.shortcuts`),children:(0,$.jsx)(Z,{name:`question`,className:ky})})}),(0,$.jsx)(Ea,{side:`top`,sideOffset:4,children:l(`sessions.sidebar.footer.actions.shortcuts`)})]})]}):null,t[0]=n,t[1]=r,t[2]=s,t[3]=l,t[4]=u):u=t[4];let d;t[5]!==i||t[6]!==s||t[7]!==c?(d=s?(0,$.jsx)(ly,{compactWithRestart:!!(c&&i)}):null,t[5]=i,t[6]=s,t[7]=c,t[8]=d):d=t[8];let f;t[9]!==i||t[10]!==s||t[11]!==c?(f=c&&i?(0,$.jsx)(Ay,{onOpenUpdate:i,hideDownload:s}):null,t[9]=i,t[10]=s,t[11]=c,t[12]=f):f=t[12];let p;t[13]!==d||t[14]!==f?(p=(0,$.jsxs)(`div`,{className:`ml-auto flex min-w-0 items-center gap-1`,children:[d,f]}),t[13]=d,t[14]=f,t[15]=p):p=t[15];let m;return t[16]!==u||t[17]!==p?(m=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-start gap-1 px-2.5 py-2`,children:[u,p]}),t[16]=u,t[17]=p,t[18]=m):m=t[18],m}var Ly=1/3,Ry=1,zy=({containerScrollTop:e,containerClientHeight:t,containerScrollHeight:n,rowOffsetFromViewportTop:r})=>{let i=e+(r-t*Ly),a=Math.max(0,n-t);return Math.min(a,Math.max(0,i))},By=()=>typeof window>`u`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`,Vy=e=>{let t=e.closest(`.overlay-scrollbar-target`);if(t)return t;let n=e.parentElement;for(;n&&n!==document.body;){let e=window.getComputedStyle(n).overflowY;if(e===`auto`||e===`scroll`||e===`overlay`)return n;n=n.parentElement}return null},Hy=(e,t)=>{let n=Vy(e),r=t?.behavior??By();if(!n){e.scrollIntoView({block:`nearest`,inline:`nearest`,behavior:r});return}let i=e.getBoundingClientRect(),a=n.getBoundingClientRect().top+n.clientTop,o=a+n.clientHeight;if(i.top>=a&&i.bottom<=o)return;let s=zy({containerScrollTop:n.scrollTop,containerClientHeight:n.clientHeight,containerScrollHeight:n.scrollHeight,rowOffsetFromViewportTop:i.top-a});Math.abs(s-n.scrollTop)<Ry||n.scrollTo({top:s,behavior:r})},Uy={activationConstraint:{distance:8}},Wy={coordinateGetter:Xo},Gy=e=>{let t=(0,du.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(Da,{delay:0,closeDelay:150,timeout:600,children:n}),t[0]=n,t[1]=r),r};function Ky(e){let{t}=Zt(),n=new Map((e.remoteProjects??[]).map(e=>[e.id,e])),r=(e.remoteProjects??[]).map(e=>({project:{id:e.id,hostId:e.hostId,normalizedPath:e.path},groups:[]})),i=[...e.sectionsForRender,...r];if(e.projectOrderIds?.length){let t=new Map(e.projectOrderIds.map((e,t)=>[e,t]));i.sort((e,n)=>(t.get(e.project.id)??1/0)-(t.get(n.project.id)??1/0))}let a=r=>{let i=n.get(r);return i?e.hostRegistry?(0,$.jsx)(Xc,{project:i,registry:e.hostRegistry,search:e.remoteSearch,mobile:e.mobileVariant,reorderEnabled:e.projectReorderEnabled,onNavigationTargets:e.onRemoteNavigationTargets,onActivityItems:e.onRemoteActivityItems},r):(0,$.jsxs)(`div`,{className:`px-2 py-1 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`span`,{children:[i.label||i.path,` · `,i.hostId]}),(0,$.jsx)(`p`,{role:e.remoteError?`alert`:`status`,children:e.remoteError||t(kr()?`remoteProjects.state.connecting`:`remoteProjects.unsupported`)})]},r):null},o=Yo(Uo(qo,Uy),Uo(Wo,Wy)),s=e.hasSessionSearchQuery?null:(0,$.jsx)(qv,{title:t(`sessions.sidebar.projectsTitle`),isFirst:!e.hasLeadingSection,accessory:e.headerAccessory}),c=Q.useRef(null),l=Q.useRef(null);Q.useLayoutEffect(()=>{let t=e.projectRevealTarget;if(!t){l.current=null;return}if(e.mobileVariant||e.showOnlyMainWorkspace||e.hasSessionSearchQuery)return;let n=l.current;if(n?.projectId===t.projectId&&n.revision===t.revision)return;let r=c.current?.querySelector(`[data-sidebar-project-header="${CSS.escape(t.projectId)}"]`);r&&(l.current=t,Hy(r))},[e.projectRevealTarget,e.mobileVariant,e.showOnlyMainWorkspace,e.hasSessionSearchQuery,e.sectionsForRender]);let u=Q.useRef(new Map),d=Q.useRef(e.getOrderedGroups);d.current!==e.getOrderedGroups&&(d.current=e.getOrderedGroups,u.current.clear());let f=(t,n)=>{let r=u.current,i=r.get(t);if(i&&i.groups===n)return i.ordered;let a=e.getOrderedGroups(t,n);if(r.set(t,{groups:n,ordered:a}),r.size>256){let e=r.keys().next().value;e!==void 0&&r.delete(e)}return a};return e.sharedSessionsOnly?(0,$.jsx)(Gy,{children:(0,$.jsxs)(es,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:`flex-1 min-h-0`,className:X(`space-y-1 px-3 pb-1`,(e.mobileVariant,``)),children:[e.topContent,e.hasSharedSessions?null:e.hasSessionSearchQuery?e.searchEmptyState:e.emptyState]})}):e.projectSections.length===0&&r.length===0?(0,$.jsx)(Gy,{children:(0,$.jsxs)(es,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:`flex-1 min-h-0`,className:X(`space-y-1 px-3 pb-1`,(e.mobileVariant,``)),children:[e.topContent,s,e.emptyState]})}):i.length===0?(0,$.jsx)(Gy,{children:(0,$.jsx)(es,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:`flex-1 min-h-0`,className:X(`space-y-1 px-3 pb-1`,(e.mobileVariant,``)),children:e.searchEmptyState})}):(0,$.jsx)(Gy,{children:(0,$.jsxs)(es,{ref:c,useScrollShadow:!0,scrollShadowSize:96,outerClassName:`flex-1 min-h-0`,className:X(`space-y-1 px-3 pb-1 [overflow-anchor:none]`,(e.mobileVariant,``)),children:[e.topContent,e.showOnlyMainWorkspace?(0,$.jsx)(`div`,{className:`space-y-[0.6rem] py-1`,children:(()=>{let r=i.find(t=>t.project.id===e.activeProjectId)??i[0];if(!r)return e.hasSessionSearchQuery?e.searchEmptyState:e.emptyState;if(n.has(r.project.id))return a(r.project.id);let o=r.groups.find(e=>e.isMain&&e.sessions.length>0)??r.groups.find(e=>e.sessions.length>0)??r.groups.find(e=>e.isMain)??r.groups[0];if(!o)return(0,$.jsx)(`div`,{className:co,children:t(`sessions.sidebar.empty.noSessions.title`)});let s=r.groups.find(e=>e.isArchivedBucket);return[o,...s&&s.id!==o.id?[s]:[]].map(t=>{let n=`${r.project.id}:${t.id}`,i=t.id===o.id;return(0,$.jsx)(Q.Fragment,{children:e.renderGroupSessions(t,n,r.project.id,i,null,!0,c)},n)})})()}):(0,$.jsxs)($.Fragment,{children:[s,(0,$.jsxs)(Jo,{sensors:o,collisionDetection:Go,onDragEnd:t=>{if(e.isInlineEditing||e.projectSortOrder!==`manual`)return;let{active:n,over:r}=t;!r||n.id===r.id||e.reorderProjects(String(n.id),String(r.id))},children:[(0,$.jsx)($o,{items:i.map(e=>e.project.id),strategy:Qo,children:i.map(t=>{let r=t.project,i=r.id;return n.has(i)?a(i):(0,$.jsx)(qy,{project:r,orderedGroups:f(i,t.groups),isCollapsed:e.collapsedProjects.has(i),isActiveProject:i===e.activeProjectId,isRepo:!!e.projectRepoStatus.get(i),hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:e.alwaysShowActions,toggleProject:e.toggleProject,setActiveProjectIdOnly:e.setActiveProjectIdOnly,setActiveMainTab:e.setActiveMainTab,setSessionSwitcherOpen:e.setSessionSwitcherOpen,openNewSessionDraft:e.openNewSessionDraft,openNewWorktreeDialog:e.openNewWorktreeDialog,syncProjectSessions:e.syncProjectSessions,openProjectEditDialog:e.openProjectEditDialog,removeProject:e.removeProject,openSidebarMenuKey:e.openSidebarMenuKey===`project:${i}`?e.openSidebarMenuKey:null,setOpenSidebarMenuKey:e.setOpenSidebarMenuKey,projectReorderEnabled:e.projectReorderEnabled,projectSortOrder:e.projectSortOrder,isInlineEditing:e.isInlineEditing,setGroupOrderByProject:e.setGroupOrderByProject,renderGroupSessions:e.renderGroupSessions,scrollContainerRef:c,homeDirectory:e.homeDirectory,hostRegistry:e.hostRegistry},i)})}),(0,$.jsx)(Ko,{dropAnimation:null})]})]})]})})}var qy=Q.memo(function(e){let t=(0,du.c)(111),{t:n}=Zt(),{project:r,orderedGroups:i,isCollapsed:a,renderGroupSessions:o,scrollContainerRef:s,isInlineEditing:c}=e,l=r.id,u;t[0]===r.normalizedPath?u=t[1]:(u=e=>w()?void 0:e.availableWorktreesByProject.get(r.normalizedPath),t[0]=r.normalizedPath,t[1]=u);let d=cr(u),f;t[2]!==r.normalizedPath||t[3]!==d?(f=[r.normalizedPath,...(d??[]).flatMap(Jy)],t[2]=r.normalizedPath,t[3]=d,t[4]=f):f=t[4];let p=f,m;t[5]===p?m=t[6]:(m=e=>p.some(t=>e.loadingDirectories.has(t)),t[5]=p,t[6]=m);let h=wr(m),g;t[7]===p?g=t[8]:(g=e=>p.some(t=>e.refreshingDirectories.has(t)),t[7]=p,t[8]=g);let _=wr(g),v=Yo(Uo(qo,Uy)),y;t[9]===i?y=t[10]:(y=i.find(Yy)??null,t[9]=i,t[10]=y);let b=y,x;t[11]!==i||t[12]!==b?(x=b?i.filter(e=>e.id!==b.id):i,t[11]=i,t[12]=b,t[13]=x):x=t[13];let S=x,C;t[14]!==l||t[15]!==e?(C=()=>e.toggleProject(l),t[14]=l,t[15]=e,t[16]=C):C=t[16];let T=K(C),E;t[17]!==r.normalizedPath||t[18]!==l||t[19]!==e?(E=()=>{e.isActiveProject||e.setActiveProjectIdOnly(l),e.setActiveMainTab(`chat`),e.mobileVariant&&e.setSessionSwitcherOpen(!1),e.openNewSessionDraft({directoryOverride:r.normalizedPath})},t[17]=r.normalizedPath,t[18]=l,t[19]=e,t[20]=E):E=t[20];let D=K(E),O;t[21]!==l||t[22]!==e?(O=()=>{e.isActiveProject||e.setActiveProjectIdOnly(l),e.setActiveMainTab(`chat`),e.openNewWorktreeDialog()},t[21]=l,t[22]=e,t[23]=O):O=t[23];let k=K(O),A;t[24]!==l||t[25]!==e?(A=()=>e.syncProjectSessions(l),t[24]=l,t[25]=e,t[26]=A):A=t[26];let j=K(A),M;t[27]!==l||t[28]!==e?(M=()=>e.openProjectEditDialog(l),t[27]=l,t[28]=e,t[29]=M):M=t[29];let N=K(M),P;t[30]!==l||t[31]!==e?(P=()=>e.removeProject(l),t[30]=l,t[31]=e,t[32]=P):P=t[32];let F=K(P),I;t[33]!==c||t[34]!==S||t[35]!==r.normalizedPath||t[36]!==l||t[37]!==e||t[38]!==b?(I=t=>{if(c)return;let{active:n,over:i}=t;if(!i||n.id===i.id)return;let a=S.findIndex(e=>e.id===n.id),o=S.findIndex(e=>e.id===i.id);if(a===-1||o===-1||a===o)return;let s=Zo(S,a,o).map(Xy),u=b?[b.id,...s]:s,d=new Map(S.map(Zy));bn.getState().setWorktreeOrder(l,r.normalizedPath,s.flatMap(e=>{let t=d.get(e);return t?.worktree&&t.directory?[t.directory]:[]})),e.setGroupOrderByProject(e=>new Map(e).set(l,u))},t[33]=c,t[34]=S,t[35]=r.normalizedPath,t[36]=l,t[37]=e,t[38]=b,t[39]=I):I=t[39];let L=K(I),R;t[40]!==l||t[41]!==o||t[42]!==b||t[43]!==s?(R=b?o(b,`${l}:${b.id}`,l,!0,null,void 0,s):null,t[40]=l,t[41]=o,t[42]=b,t[43]=s,t[44]=R):R=t[44];let z;t[45]===S?z=t[46]:(z=S.map(Qy),t[45]=S,t[46]=z);let ee;if(t[47]!==c||t[48]!==S||t[49]!==l||t[50]!==o||t[51]!==s){let e;t[53]!==c||t[54]!==l||t[55]!==o||t[56]!==s?(e=e=>(0,$.jsx)(ol,{id:e.id,disabled:c,children:t=>o(e,`${l}:${e.id}`,l,!1,t,void 0,s)},e.id),t[53]=c,t[54]=l,t[55]=o,t[56]=s,t[57]=e):e=t[57],ee=S.map(e),t[47]=c,t[48]=S,t[49]=l,t[50]=o,t[51]=s,t[52]=ee}else ee=t[52];let B;t[58]!==z||t[59]!==ee?(B=(0,$.jsx)($o,{items:z,strategy:Qo,children:ee}),t[58]=z,t[59]=ee,t[60]=B):B=t[60];let V;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(Ko,{dropAnimation:null}),t[61]=V):V=t[61];let te;t[62]!==v||t[63]!==L||t[64]!==R||t[65]!==B?(te=(0,$.jsxs)(Jo,{sensors:v,collisionDetection:Go,onDragEnd:L,children:[R,B,V]}),t[62]=v,t[63]=L,t[64]=R,t[65]=B,t[66]=te):te=t[66];let ne=te,re=e.projectSortOrder!==`manual`,ie=r.hostId,ae=r.remoteState,oe=e.hostRegistry,H;t[67]===r.normalizedPath?H=t[68]:(H=Er(r.normalizedPath)||r.normalizedPath,t[67]=r.normalizedPath,t[68]=H);let se;t[69]!==r.normalizedPath||t[70]!==e.homeDirectory?(se=an(r.normalizedPath,e.homeDirectory),t[69]=r.normalizedPath,t[70]=e.homeDirectory,t[71]=se):se=t[71];let U=h||_,ce=e.projectReorderEnabled??!1,W=!a,le=a||void 0,ue;t[72]!==ne||t[73]!==h||t[74]!==i.length||t[75]!==n?(ue=(0,$.jsx)(`div`,{className:`space-y-0 pt-0 pb-0.5`,children:i.length>0?ne:h?(0,$.jsx)(`div`,{className:`box-border w-full py-1.5 text-left typography-ui-label font-normal text-muted-foreground/80 animate-pulse select-none`,style:{paddingLeft:lo(1)},role:`status`,"aria-live":`polite`,children:n(`sessions.sidebar.project.loadingSessions`)}):(0,$.jsx)(`div`,{className:co,children:n(`sessions.sidebar.empty.noSessions.title`)})}),t[72]=ne,t[73]=h,t[74]=i.length,t[75]=n,t[76]=ue):ue=t[76];let de;t[77]!==le||t[78]!==ue?(de=(0,$.jsx)(Ll,{"data-sidebar-collapse":!0,className:`h-[var(--collapsible-panel-height)] transition-[height] duration-200 ease-out data-[starting-style]:h-0 data-[ending-style]:h-0 data-[open]:animate-none data-[closed]:animate-none motion-reduce:transition-none`,inert:le,children:ue}),t[77]=le,t[78]=ue,t[79]=de):de=t[79];let fe;t[80]!==W||t[81]!==de?(fe=(0,$.jsx)(zl,{open:W,children:de}),t[80]=W,t[81]=de,t[82]=fe):fe=t[82];let pe;return t[83]!==a||t[84]!==F||t[85]!==D||t[86]!==k||t[87]!==N||t[88]!==j||t[89]!==T||t[90]!==r.color||t[91]!==r.hostId||t[92]!==r.icon||t[93]!==r.iconImage||t[94]!==r.remoteState||t[95]!==l||t[96]!==e.alwaysShowActions||t[97]!==e.hideDirectoryControls||t[98]!==e.hostRegistry||t[99]!==e.isActiveProject||t[100]!==e.isRepo||t[101]!==e.mobileVariant||t[102]!==e.openSidebarMenuKey||t[103]!==e.setOpenSidebarMenuKey||t[104]!==re||t[105]!==H||t[106]!==se||t[107]!==U||t[108]!==ce||t[109]!==fe?(pe=(0,$.jsx)(Cc,{id:l,disabled:re,hostId:ie,remoteState:ae,hostRegistry:oe,projectLabel:H,projectDescription:se,projectIcon:r.icon,projectColor:r.color,projectIconImage:r.iconImage,isCollapsed:a,isActiveProject:e.isActiveProject,isSessionsLoading:U,isRepo:e.isRepo,hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:e.alwaysShowActions,onToggle:T,onNewSession:D,onNewWorktreeSession:k,onSyncSessions:j,onRenameStart:N,onClose:F,showCreateButtons:!0,openSidebarMenuKey:e.openSidebarMenuKey,setOpenSidebarMenuKey:e.setOpenSidebarMenuKey,reorderEnabled:ce,children:fe}),t[83]=a,t[84]=F,t[85]=D,t[86]=k,t[87]=N,t[88]=j,t[89]=T,t[90]=r.color,t[91]=r.hostId,t[92]=r.icon,t[93]=r.iconImage,t[94]=r.remoteState,t[95]=l,t[96]=e.alwaysShowActions,t[97]=e.hideDirectoryControls,t[98]=e.hostRegistry,t[99]=e.isActiveProject,t[100]=e.isRepo,t[101]=e.mobileVariant,t[102]=e.openSidebarMenuKey,t[103]=e.setOpenSidebarMenuKey,t[104]=re,t[105]=H,t[106]=se,t[107]=U,t[108]=ce,t[109]=fe,t[110]=pe):pe=t[110],pe});function Jy(e){let t=M(e.path);return t?[t]:[]}function Yy(e){return e.isMain}function Xy(e){return e.id}function Zy(e){return[e.id,e]}function Qy(e){return e.id}function $y(e){if(typeof e!=`number`||!Number.isFinite(e))return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:`${t.toLocaleString(Yt(),{month:`short`})} ${t.getDate()}, ${t.getFullYear()}, ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function eb(e){if(e.info.role===`user`)return``;let t=typeof e.info.providerID==`string`?e.info.providerID.trim():``,n=typeof e.info.modelID==`string`?e.info.modelID.trim():``;return t&&n?`${t}/${n}`:n||t}function tb(e){let t=e.info.role===`user`?`User`:`Assistant`,n=$y(e.info.time?.created),r=eb(e),i=n&&r?`${n} (${r})`:n||r;return i?`**${t}**\n\n*${i}*`:`**${t}**`}function nb(e){return e.filter(e=>e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(``)}function rb(e){let t=tb(e),n=nb(e.parts).trim();return n?`${t}\n\n${n}`:``}function ib(e,t){let n=`#`.repeat(Math.min(t+1,6)),r=e.agent?` — ${e.agent}`:``,i=[`${n} Sub-agent: ${e.title}${r}\n\n---\n\n`+e.records.map(rb).filter(Boolean).join(`
|
|
146
|
+
`);te({sessionKey:t,source:`preview-console`,fileLabel:e||_e||`preview`,startLine:1,endLine:Math.max(1,A.length),code:`${n}${r}`,language:`text`,text:a(`contextPanel.preview.console.attachAnnotation`)}),J.success(a(`contextPanel.preview.console.attached`))},[te,A,ie,_e,e,a]),[Ee,De]=Q.useState(`unknown`),Oe=Q.useRef(0),ke=Q.useRef(0);Q.useEffect(()=>{if(!de){De(`unknown`),Oe.current=0,ke.current=0;return}let e=!1;return Oe.current||(Oe.current=Date.now(),ke.current=0),De(`unknown`),(async()=>{let t=await(async()=>{try{let e=new URL(de,window.location.href),t=n?.location.hostId?O(n.location.hostId,`/api`).slice(0,-4):``,r=`${t&&e.pathname.startsWith(t+`/`)?e.pathname.slice(t.length):e.pathname}${e.search}`;return await i(r,{method:`GET`,credentials:`include`,cache:`no-store`,redirect:`manual`})}catch{return null}})();if(e)return;if(!t){De(`unreachable`);return}if(t.status===403||t.status===404){Hg.delete(ce),_({status:`loading`}),p();return}if(t.status!==502){De(`reachable`);return}let r=Oe.current||Date.now();if(Date.now()-r<15e3){De(`starting`),ke.current+=1;let t=ke.current,n=Math.min(2e3,250*2**Math.min(4,t));setTimeout(()=>{e||d()},n).unref?.();return}De(`unreachable`)})(),()=>{e=!0}},[n,i,ce,de,u]);let Ae=H&&g.status===`ready`&&(Ee===`unknown`||Ee===`starting`),je=H&&g.status===`ready`&&Ee===`unreachable`,Me=Q.useCallback(e=>{if(!H||g.status!==`ready`||typeof window>`u`)return;let t=e.currentTarget.contentWindow;if(t)try{let e=t.location,n=K_(_e||de);if(e.origin!==n||e.pathname.startsWith(g.proxyBasePath))return;let r=`${g.proxyBasePath}${e.pathname}${e.search}${e.hash}`;t.location.replace(r)}catch{}},[_e,H,de,g]);return(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border/40 bg-[var(--surface-background)] px-2 py-1`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1 truncate typography-micro text-muted-foreground`,title:ve||e,children:ve||e||a(`contextPanel.preview.empty`)}),(0,$.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 w-7 p-0`,onClick:()=>d(),title:a(`contextPanel.preview.actions.reload`),"aria-label":a(`contextPanel.preview.actions.reload`),disabled:!_e,children:(0,$.jsx)(Z,{name:`refresh`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 w-7 p-0`,onClick:()=>{le&&Bt(n?.location.hostId?_e:le)},title:a(`contextPanel.preview.actions.openExternal`),"aria-label":a(`contextPanel.preview.actions.openExternal`),disabled:n?.location.hostId?!_e:!le,children:(0,$.jsx)(Z,{name:`external-link`,className:`h-3.5 w-3.5`})}),H?(0,$.jsx)(Y,{type:`button`,size:`sm`,variant:M?`secondary`:`ghost`,className:`h-7 gap-1 px-2`,onClick:()=>N(e=>!e),title:a(`contextPanel.preview.inspect.toggle`),"aria-label":a(`contextPanel.preview.inspect.toggle`),disabled:!S,children:(0,$.jsx)(Z,{name:`cursor`,className:`h-3.5 w-3.5`})}):null,H?(0,$.jsxs)(Y,{type:`button`,size:`sm`,variant:w?`secondary`:`ghost`,className:`h-7 gap-1 px-2`,onClick:()=>T(e=>!e),title:a(S?`contextPanel.preview.console.open`:`contextPanel.preview.console.waiting`),"aria-label":a(S?`contextPanel.preview.console.open`:`contextPanel.preview.console.waiting`),disabled:!S&&A.length===0,children:[(0,$.jsx)(Z,{name:`terminal-box`,className:`h-3.5 w-3.5`}),Se>0?(0,$.jsx)(`span`,{className:`typography-micro text-status-error`,children:Se}):null]}):null]}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 bg-background`,children:[Ae?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground`,children:[(0,$.jsx)(`div`,{children:a(`contextPanel.preview.startingServer`)}),(0,$.jsx)(`div`,{className:`text-xs opacity-70`,children:a(`contextPanel.preview.startingServerHint`)})]}):je?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground`,children:[(0,$.jsx)(`div`,{children:a(`contextPanel.preview.upstreamUnreachable`)}),(0,$.jsx)(`div`,{className:`text-xs opacity-70`,children:a(`contextPanel.preview.upstreamUnreachableHint`)}),(0,$.jsx)(Y,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>d(),children:a(`contextPanel.preview.actions.retry`)})]}):_e&&(!H||Ee===`reachable`)?(0,$.jsxs)(`div`,{className:`relative h-full w-full`,children:[(0,$.jsx)(`iframe`,{ref:b,src:_e,title:a(`contextPanel.preview.iframeTitle`),className:`h-full w-full border-0`,style:{colorScheme:W},onLoad:Me,sandbox:H?`allow-scripts allow-same-origin allow-forms allow-popups allow-downloads`:`allow-scripts allow-forms`},`${_e}:${u}`),M&&P?(0,$.jsx)(`div`,{className:`pointer-events-none absolute rounded-sm border-2 border-[var(--interactive-focus-ring)] bg-[var(--interactive-focus-ring)]/35`,style:{left:P.bounds.x,top:P.bounds.y,width:P.bounds.width,height:P.bounds.height},children:(0,$.jsxs)(`div`,{className:`absolute -top-6 left-0 max-w-64 truncate rounded bg-[var(--surface-elevated)] px-2 py-0.5 typography-micro text-foreground shadow`,children:[P.tag,P.text?` · ${P.text}`:``]})}):null]}):ye?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-sm text-muted-foreground`,children:a(`contextPanel.preview.loading`)}):be?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 px-6 text-sm text-muted-foreground`,children:[(0,$.jsx)(`div`,{children:a(`contextPanel.preview.proxyError`)}),g.status===`error`?(0,$.jsx)(`div`,{className:`text-center text-xs opacity-70`,children:g.message}):null,(0,$.jsx)(Y,{type:`button`,size:`sm`,onClick:()=>p(),children:a(`contextPanel.preview.actions.retry`)})]}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-sm text-muted-foreground`,children:a(`contextPanel.preview.invalidUrl`)}),w?(0,$.jsxs)(`div`,{className:`absolute inset-x-3 bottom-3 z-10 max-h-[45%] overflow-hidden rounded-xl border border-border/70 bg-[var(--surface-elevated)] shadow-lg`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/50 px-3 py-2`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:a(`contextPanel.preview.console.title`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Y,{type:`button`,size:`xs`,variant:`ghost`,onClick:Te,disabled:A.length===0,children:a(`contextPanel.preview.console.attach`)}),(0,$.jsx)(Y,{type:`button`,size:`xs`,variant:`ghost`,onClick:we,disabled:A.length===0,children:a(`contextPanel.preview.console.copy`)}),(0,$.jsx)(Y,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>j([]),disabled:A.length===0,children:a(`contextPanel.preview.console.clear`)})]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1 border-b border-border/30 px-3 py-1.5`,children:[`all`,`errors`,`warnings`,`logs`].map(e=>(0,$.jsx)(Y,{type:`button`,size:`xs`,variant:E===e?`secondary`:`ghost`,onClick:()=>D(e),children:a(e===`all`?`contextPanel.preview.console.filter.all`:e===`errors`?`contextPanel.preview.console.filter.errors`:e===`warnings`?`contextPanel.preview.console.filter.warnings`:`contextPanel.preview.console.filter.logs`)},e))}),(0,$.jsx)(`div`,{className:`max-h-64 overflow-auto p-2 typography-code text-xs`,children:A.length===0?(0,$.jsx)(`div`,{className:`px-2 py-3 text-muted-foreground`,children:a(`contextPanel.preview.console.empty`)}):Ce.length===0?(0,$.jsx)(`div`,{className:`px-2 py-3 text-muted-foreground`,children:a(`contextPanel.preview.console.noFilteredEvents`)}):Ce.map(e=>(0,$.jsx)(`div`,{className:`border-b border-border/30 px-2 py-1 last:border-b-0`,children:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:X(`shrink-0 uppercase`,e.level===`error`||e.level===`runtime`||e.level===`resource`?`text-status-error`:e.level===`warn`?`text-status-warning`:`text-muted-foreground`),children:e.level}),(0,$.jsx)(`span`,{className:`min-w-0 break-words text-foreground`,children:e.message})]})},e.id))})]}):null]})]})},Z_=()=>typeof window<`u`&&!!window.__YURI_ELECTRON__,Q_=({initialUrl:e,directory:t,tabID:n})=>{let i=_t()?.entry,a=i?.fetch??h,{t:s}=Zt(),u=Q.useRef(null),d=q(e=>e.setContextPanelTabTargetPath),f=Mg(e),p=f===`about:blank`?``:f,[g,_]=Q.useState(p),[v,y]=Q.useState(p),[b,x]=Q.useState(p),[S,C]=Q.useState(()=>p?[p]:[]),[w,T]=Q.useState(()=>p?0:-1),[E,D]=Q.useReducer(e=>e+1,0),[O,A]=Q.useState(!!p),[j,M]=Q.useState(!1),[N,P]=Q.useState(null),[F,I]=Q.useState({status:`idle`}),[L,R]=Q.useState(``),z=cr(e=>e.currentSessionId),B=cr(e=>e.newSessionDraft?.open),V=dn(e=>e.remoteSession),te=i&&V&&ee(V.location)===i.key?V:null,ne=i?.location.hostId?te?.sessionId??null:z,re=i?.location.hostId?!te?.sessionId:B,ie=Zi(e=>e.addDraft),ae=Or(e=>e.addAttachedFile),oe=K(async e=>{if(!i?.location.hostId)return ae(e);let t={transportIdentity:l(),location:i.location},n=ne?lt(t,ne):st(t,`remote-new-session`);await Or.getState().addDraftLocalAttachment(n,e)}),H=i?.location.hostId?k(i.location,ne??`draft`):ne??(re?`draft`:null),se=Q.useCallback(e=>{!e||e===`about:blank`||!t||!n||d(t,n,e)},[t,n,d]),U=Q.useCallback((e,t)=>{let n=Mg(e),r=n===`about:blank`?``:n;y(r),_(r),t?.inFrame?A(!1):(x(r),A(!!r)),se(r),C(e=>{if(!r)return T(-1),[];if(t?.replaceHistory)return e;let n=w>=0?e.slice(0,w+1):[];if(n[n.length-1]===r)return T(n.length-1),n;let i=[...n,r];return T(i.length-1),i})},[w,se]),ce=Q.useRef(v);ce.current=v,Q.useEffect(()=>{let t=Ng(e,ce.current);t!==null&&U(t)},[e,U]);let W=Q.useCallback(e=>{let t=S[e];t&&(T(e),y(t),x(t),_(t),A(!0),se(t))},[S,se]),le=Q.useCallback(()=>{if(v){A(!0);try{u.current?.contentWindow?.location.reload()}catch{D()}}},[v]);Q.useEffect(()=>{if(!b){I({status:`idle`});return}let e=i?.location.hostId?`${i.key}|${i.connectionGeneration}|${Kg(b)}`:Kg(b),t=Gg(e);if(t?.previewToken)return I({status:`ready`,proxyBasePath:t.proxyBasePath,previewToken:t.previewToken,expiresAt:t.expiresAt}),()=>{i?.location.hostId&&Hg.delete(e)};t&&Hg.delete(e);let n=!1;return I({status:`loading`}),A(!0),(async()=>{try{let t=await a(`/api/preview/targets`,{method:`POST`,headers:{"Content-Type":`application/json`,...i?.location.hostId?{"x-opencode-directory":i.location.directory}:{}},credentials:`include`,body:JSON.stringify({url:b,allowExternal:!0})});if(!t.ok){let e=await t.json().catch(()=>({})),r=typeof e?.error==`string`?e.error:`HTTP ${t.status}`;n||(I({status:`error`,message:r}),A(!1));return}let r=await t.json(),o=typeof r.proxyBasePath==`string`&&G_(i,r.proxyBasePath)?W_(i,r.proxyBasePath):``,c=typeof r.previewToken==`string`?r.previewToken:``,l=typeof r.expiresAt==`number`?r.expiresAt:0;if(!G_(i,o)||!c||!Number.isFinite(l)||l<=Date.now()){n||(I({status:`error`,message:s(`contextPanel.preview.proxyError`)}),A(!1));return}if(n)return;i?.sdk(),Hg.set(e,{proxyBasePath:o,previewToken:c,expiresAt:l}),n||I({status:`ready`,proxyBasePath:o,previewToken:c,expiresAt:l})}catch(e){if(!n){let t=e instanceof Error?e.message:String(e);I({status:`error`,message:t}),A(!1)}}})(),()=>{n=!0,i?.location.hostId&&Hg.delete(e)}},[i,a,b,E,s]);let ue=b&&F.status===`ready`?`${F.proxyBasePath}|${F.previewToken||``}|${E}`:``;Q.useEffect(()=>{if(!ue){R(``);return}let e=!1;return R(``),r(m()).then(t=>{!e&&t&&R(ue)}).catch(()=>{}),()=>{e=!0}},[ue]);let de=Q.useMemo(()=>{if(L!==ue||!b||F.status!==`ready`)return``;try{let e=new URL(b),t=e.pathname||`/`,n=new URLSearchParams(e.search);n.delete(`yuri_url_token`),n.delete(`yuri_client_token`),n.set(`yuriPreview`,String(E)),n.set(`yuri_preview_token`,F.previewToken||``);let r=n.toString();return c().authenticatedAsset(W_(i,`${F.proxyBasePath}${t}${r?`?${r}`:``}${e.hash}`))}catch{return``}},[i,b,F,ue,E,L]),fe=o()&&Ic(),[pe,me]=Q.useState(``);Q.useEffect(()=>{if(!fe){me(``);return}let e=!1;return me(``),pc().then(t=>{!e&&t&&me(t)}).catch(()=>{e||me(``)}),()=>{e=!0}},[fe,ue]);let he=de?kl({relayActive:fe,gatewayOrigin:pe||null,authenticatedAssetUrl:de}):``,ge=fe&&!!de&&!pe,_e=ge?``:he||(F.status===`error`&&!fe&&!i?.location.hostId?b:``),ve=Q.useCallback(e=>{if(!e||!b||F.status!==`ready`)return``;try{let t=new URL(e,window.location.origin),n=F.proxyBasePath.endsWith(`/`)?F.proxyBasePath.slice(0,-1):F.proxyBasePath,r=K_(_e||de);if(!(t.origin===window.location.origin||r&&t.origin===r)||!t.pathname.startsWith(n))return``;let i=t.pathname.slice(n.length)||`/`,a=new URL(b).origin;return Y_(new URL(`${i}${t.search}${t.hash}`,a).toString())}catch{return``}},[_e,b,de,F]),ye=Q.useCallback(e=>{if(!e||!b||F.status!==`ready`)return``;try{let t=new URL(e,window.location.origin),n=new URL(b).origin,r=K_(_e||de);if(!(t.origin===window.location.origin||r&&t.origin===r)||n===window.location.origin)return``;let i=F.proxyBasePath.endsWith(`/`)?F.proxyBasePath.slice(0,-1):F.proxyBasePath;return t.pathname.startsWith(i)?``:Y_(new URL(`${t.pathname}${t.search}${t.hash}`,n).toString())}catch{return``}},[_e,b,de,F]),be=Q.useCallback(e=>{let t=u.current?.contentWindow;t&&q_(t,_e||de,{source:`yuri-preview-parent`,version:1,type:`set-inspect-mode`,enabled:e})},[_e,de]),xe=Q.useCallback(async e=>{let t=H;if(!t){J.error(s(`contextPanel.preview.inspect.attachNoSession`));return}let n=u.current,r=n?.contentWindow,a=n?.getBoundingClientRect(),o={width:Number.isFinite(r?.innerWidth)?r?.innerWidth??a?.width??0:a?.width??0,height:Number.isFinite(r?.innerHeight)?r?.innerHeight??a?.height??0:a?.height??0},c=n?await zg(n,e,i):null,l=!!c;c&&await oe(c),ie({sessionKey:t,source:`preview-annotation`,fileLabel:v||`browser`,startLine:1,endLine:1,code:Rg({pageUrl:v,viewport:o,devicePixelRatio:window.devicePixelRatio||1,target:e,screenshotAttached:l,intro:s(l?`contextPanel.preview.inspect.attachAnnotationWithScreenshot`:`contextPanel.preview.inspect.attachAnnotation`)}),language:`markdown`,text:``}),J.success(s(`contextPanel.preview.inspect.attached`))},[i,oe,ie,H,v,s]),Se=Q.useCallback(()=>{let e=u.current;P(null),be(!1),e&&H_(e,B_).catch(()=>{})},[be]);Q.useEffect(()=>{if(!j)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopImmediatePropagation(),M(!1),Se())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[Se,j]),Q.useEffect(()=>()=>Se(),[Se]),Q.useEffect(()=>{let e=e=>{if(e.source!==u.current?.contentWindow)return;let t=e.data;if(!(!t||t.source!==`yuri-preview-bridge`||t.version!==1)){if(t.type===`ready`){let e=typeof t.url==`string`?t.url:``,n=ve(e);n&&n!==v&&U(n,{inFrame:!0});return}if(t.type===`hover`){P(Lg(t.target)?t.target:null);return}if(t.type===`select`&&Lg(t.target)){P(null),M(!1),be(!1),xe(t.target);return}if(t.type===`navigate-preview`){let e=typeof t.url==`string`?t.url:``,n=ye(e);if(n){U(n);return}e&&U(e)}}};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[U,xe,v,ve,ye,be]);let Ce=Q.useCallback(()=>{let e=u.current;if(!(!e||!v)){if(j){M(!1),Se();return}if(de){P(null),M(!0),be(!0);return}M(!0),(async()=>{try{let t=await H_(e,z_);if(M(!1),!t||!Lg(t))return;await xe(t)}catch{M(!1),J.error(s(`contextPanel.browser.inspectUnavailable`))}})()}},[xe,Se,v,j,be,de,s]),we=Q.useCallback(()=>{try{let e=u.current?.contentWindow?.location.href||``,t=ye(e);if(t){U(t,{inFrame:!0});return}}catch{}A(!1),j&&de&&be(!0)},[U,ye,j,be,de]);return(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col bg-background`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border/40 bg-[var(--surface-background)] px-2 py-1`,children:[(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:w<=0,onClick:()=>W(w-1),children:(0,$.jsx)(Z,{name:`arrow-left`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:w<0||w>=S.length-1,onClick:()=>W(w+1),children:(0,$.jsx)(Z,{name:`arrow-right`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:!v,onClick:le,children:(0,$.jsx)(Z,{name:`refresh`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault(),U(g)},children:(0,$.jsx)(`input`,{value:g,onChange:e=>_(e.target.value),className:`h-7 w-full rounded-md border border-border/50 bg-[var(--surface-elevated)] px-2 typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]`,"aria-label":s(`contextPanel.browser.addressAria`)})}),(0,$.jsx)(Y,{type:`button`,variant:j?`secondary`:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:!v,onClick:Ce,title:s(`contextPanel.preview.inspect.toggle`),"aria-label":s(`contextPanel.preview.inspect.toggle`),children:(0,$.jsx)(Z,{name:`cursor`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:i?.location.hostId?!_e:!v,onClick:()=>void Bt(i?.location.hostId?_e:v),children:(0,$.jsx)(Z,{name:`external-link`,className:`h-3.5 w-3.5`})})]}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 bg-background`,children:[_e?(0,$.jsxs)(`div`,{className:`absolute inset-0`,children:[(0,$.jsx)(`iframe`,{ref:u,src:_e,title:s(`contextPanel.browser.empty`),className:`absolute inset-0 h-full w-full border-0 bg-background`,allow:`clipboard-read; clipboard-write; fullscreen`,allowFullScreen:!0,onLoad:we},`${n}:${E}`),j&&N?(0,$.jsx)(`div`,{className:`pointer-events-none absolute rounded-sm border-2 border-[var(--interactive-focus-ring)] bg-[var(--interactive-focus-ring)]/35`,style:{left:N.bounds.x,top:N.bounds.y,width:N.bounds.width,height:N.bounds.height},children:(0,$.jsxs)(`div`,{className:`absolute -top-6 left-0 max-w-64 truncate rounded bg-[var(--surface-elevated)] px-2 py-0.5 typography-micro text-foreground shadow`,children:[N.tag,N.text?` · ${N.text}`:``]})}):null]}):F.status===`error`&&i?.location.hostId?(0,$.jsxs)(`div`,{role:`alert`,className:`absolute inset-0 flex flex-col items-center justify-center gap-3 p-6 text-center typography-meta text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:s(`contextPanel.preview.proxyError`)}),(0,$.jsx)(`span`,{children:F.message}),(0,$.jsx)(Y,{type:`button`,size:`sm`,onClick:()=>D(),children:s(`contextPanel.preview.actions.retry`)})]}):(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-6 bg-background p-6 text-center`,children:[(0,$.jsx)(fo,{width:140,height:140,className:`opacity-20`}),(0,$.jsx)(`span`,{className:`typography-ui-header text-muted-foreground`,children:s(`contextPanel.browser.empty`)}),(0,$.jsx)(`span`,{className:`max-w-sm typography-micro text-muted-foreground`,children:s(`contextPanel.browser.emptyHint`)}),(0,$.jsx)(`span`,{className:`max-w-md typography-micro leading-relaxed text-status-warning/70`,children:s(`contextPanel.browser.trustNotice`)})]}),O||ge?(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-background/70 typography-micro text-muted-foreground`,children:s(`common.loading`)}):null]})]})},$_=({initialUrl:e,directory:t,tabID:n})=>{let{t:r}=Zt(),i=Q.useRef(null),a=q(e=>e.setContextPanelTabTargetPath),o=Mg(e),s=o===`about:blank`?``:o,c=Q.useRef(Mg(e)),[l,u]=Q.useState(s),[d,f]=Q.useState(s),[p,m]=Q.useState(!1),[h,g]=Q.useState(!0),_=Q.useRef(null),v=h,y=Q.useCallback(e=>{!e||e===`about:blank`||!t||!n||a(t,n,e)},[t,n,a]),b=cr(e=>e.currentSessionId),x=cr(e=>e.newSessionDraft?.open),S=Zi(e=>e.addDraft),C=Or(e=>e.addAttachedFile);Q.useEffect(()=>{let e=i.current;if(!e)return;let t=()=>{try{let t=e.getURL();t&&t!==`about:blank`&&(f(t),u(t),y(t))}catch{}},n=e=>{let t=e.detail;typeof t?.url==`string`&&t.url&&(f(t.url),u(t.url),y(t.url))},r=()=>{_.current&&clearTimeout(_.current),_.current=setTimeout(()=>g(!0),200)},a=()=>{_.current&&clearTimeout(_.current),g(!1),t()},o=e=>{let t=e.detail;if(t?.disposition===`new-window`||t?.disposition===`foreground-tab`||t?.disposition===`background-tab`){e.preventDefault();let n=i.current;typeof n?.loadURL==`function`&&t.url&&n.loadURL(t.url)}},s=()=>{try{e.executeJavaScript?.(V_,!0).catch(()=>{})}catch{}};e.addEventListener(`did-navigate`,n),e.addEventListener(`did-navigate-in-page`,n),e.addEventListener(`did-start-loading`,r),e.addEventListener(`did-stop-loading`,a),e.addEventListener(`new-window`,o),e.addEventListener(`dom-ready`,s);try{e.isLoading()||(g(!1),t())}catch{}return s(),()=>{_.current&&clearTimeout(_.current),e.removeEventListener(`did-navigate`,n),e.removeEventListener(`did-navigate-in-page`,n),e.removeEventListener(`did-start-loading`,r),e.removeEventListener(`did-stop-loading`,a),e.removeEventListener(`new-window`,o),e.removeEventListener(`dom-ready`,s)}},[y]),Q.useEffect(()=>{let e=setTimeout(()=>g(!1),3e4);return()=>clearTimeout(e)},[]),Q.useEffect(()=>{if(!p)return;let e=e=>{if(e.key!==`Escape`)return;e.preventDefault(),e.stopImmediatePropagation(),m(!1);let t=i.current;try{t?.executeJavaScript?.(B_).catch(()=>{})}catch{}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[p]),Q.useEffect(()=>{let e=i.current;return()=>{try{let r=e?.getURL?.();r&&r!==`about:blank`&&a(t,n,r)}catch{}try{e?.executeJavaScript?.(B_).catch(()=>{})}catch{}}},[t,n,a]);let w=Q.useCallback(e=>{let t=i.current;if(typeof t?.loadURL!=`function`)return;let n=Mg(e);try{t.loadURL(n)}catch{}},[]),T=Q.useRef(d);T.current=d,Q.useEffect(()=>{let t=Ng(e,T.current);t!==null&&(f(t),u(t),g(!0),w(t))},[e,w]);let E=Q.useCallback(()=>{let e=i.current;if(e){if(p){m(!1);try{e.executeJavaScript?.(B_).catch(()=>{})}catch{}return}m(!0),e.executeJavaScript?.(z_,!0).then(async t=>{if(m(!1),!t||!Lg(t))return;let n=b??(x?`draft`:null);if(!n){J.error(r(`contextPanel.preview.inspect.attachNoSession`));return}let i=typeof e.getWebContentsId==`function`?e.getWebContentsId():null;if(i==null)return;let a=await qt(`desktop_browser_capture_page`,{webContentsId:i}),o=await e.executeJavaScript?.(`({ width: window.innerWidth, height: window.innerHeight })`,!0).catch(()=>null),s=Number.isFinite(o?.width)?o.width:a.width,c=Number.isFinite(o?.height)?o.height:a.height,l=await Bg(a.base64,a.width,a.height,s,c,t),u=!!l;l&&await C(l),S({sessionKey:n,source:`preview-annotation`,fileLabel:d||`browser`,startLine:1,endLine:1,code:Rg({pageUrl:d,viewport:{width:s,height:c},devicePixelRatio:window.devicePixelRatio||1,target:t,screenshotAttached:u,intro:r(`contextPanel.preview.inspect.attachAnnotationWithScreenshot`)}),language:`markdown`,text:``}),J.success(r(`contextPanel.preview.inspect.attached`))}).catch(()=>m(!1))}},[C,S,b,d,p,x,r]);return(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col bg-background`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border/40 bg-[var(--surface-background)] px-2 py-1`,children:[(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>{try{i.current?.goBack?.()}catch{}},children:(0,$.jsx)(Z,{name:`arrow-left`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>{try{i.current?.goForward?.()}catch{}},children:(0,$.jsx)(Z,{name:`arrow-right`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>{try{i.current?.reload?.()}catch{}},children:(0,$.jsx)(Z,{name:`refresh`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault(),w(l)},children:(0,$.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),className:`h-7 w-full rounded-md border border-border/50 bg-[var(--surface-elevated)] px-2 typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]`,"aria-label":r(`contextPanel.browser.addressAria`)})}),(0,$.jsx)(Y,{type:`button`,variant:p?`secondary`:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:E,title:r(`contextPanel.preview.inspect.toggle`),"aria-label":r(`contextPanel.preview.inspect.toggle`),children:(0,$.jsx)(Z,{name:`cursor`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>void Bt(d),children:(0,$.jsx)(Z,{name:`external-link`,className:`h-3.5 w-3.5`})})]}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 bg-background`,children:[(0,$.jsx)(`webview`,{ref:i,src:c.current,partition:`persist:yuri-browser`,allowpopups:!0,style:{width:`100%`,height:`100%`,border:`none`}}),(!d||d===`about:blank`)&&!h?(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-6 bg-background p-6 text-center`,children:[(0,$.jsx)(fo,{width:140,height:140,className:`opacity-20`}),(0,$.jsx)(`span`,{className:`typography-ui-header text-muted-foreground`,children:r(`contextPanel.browser.empty`)})]}):null,v?(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-background/70 typography-micro text-muted-foreground`,children:r(`common.loading`)}):null]})]})},ev=e=>{let t=(0,du.c)(3),n=_t(),r;return t[0]!==n||t[1]!==e?(r=n?(0,$.jsx)(tv,{...e},n.entry.key):(0,$.jsx)(Nc,{children:(0,$.jsx)(tv,{...e})}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r},tv=e=>{let t=(0,du.c)(3),n=_t(),r;return t[0]!==n?.entry.location.hostId||t[1]!==e?(r=n?.entry.location.hostId?(0,$.jsx)(nv,{...e}):(0,$.jsx)(rv,{...e}),t[0]=n?.entry.location.hostId,t[1]=e,t[2]=r):r=t[2],r},nv=e=>{let t=(0,du.c)(5),n=_t(),r=Mr(n.registry,n.entry.location.hostId),i;t[0]===r.data?.directories?i=t[1]:(i=r.data?.directories.flatMap(iv)??[],t[0]=r.data?.directories,t[1]=i);let a=i,o;return t[2]!==e||t[3]!==a?(o=(0,$.jsx)(rv,{...e,remoteSessions:a}),t[2]=e,t[3]=a,t[4]=o):o=t[4],o},rv=({directory:e,onReservedWidthChange:t,fillAvailableSpace:n=!1,getMaxSplitWidth:r,remoteSessions:i})=>{let{t:a}=Zt(),s=_t(),c=!!s?.entry.location.hostId,l=cr(e=>e.currentSessionId),u=dn(e=>e.remoteSession),d=c?u&&ee(u.location)===s.entry.key?u.sessionId:null:l,p=zo()??``,m=e?V(e,s?.entry.location.hubId??`local`).directory:p,h=c?ee({...s.entry.location,directory:m}):E_(m),g=q(e=>zt(e,h)),_=q(e=>h?e.contextToolDiffByDirectory[h]:void 0),v=q(e=>e.closeContextPanel),y=q(e=>e.closeContextPanelTab),b=q(e=>e.openContextPanelTab),x=q(e=>e.toggleContextPanelExpanded),S=q(e=>e.setContextPanelWidth),C=q(e=>e.setActiveContextPanelTab),w=q(e=>e.reorderContextPanelTabs),T=q(e=>e.isRightSidebarOpen),E=q(e=>e.isSidebarOpen),{usesFramelessChrome:D,side:O}=$s(),k=To(e=>e.setSelectedPath),A=q(e=>e.openContextPreview),j=q(e=>e.allowPromptingSubagentSessions),{themeMode:M,setThemeMode:N,lightThemeId:P,darkThemeId:F,currentTheme:I}=zr(),L=Q.useMemo(()=>g?.tabs??[],[g?.tabs]),R=L.find(e=>e.id===g?.activeTabId)??L[L.length-1]??null,z=!!g?.isOpen,B=!!g?.expanded,te=z&&(B||n),ne=Q.useRef(null),re=Q.useRef(!0),[ie,ae]=Q.useState(!0);Nt(ne,([e])=>{if(!e||e.contentRect.width<=0)return;let t=e.contentRect.width<x_;t!==re.current&&(re.current=t,ae(t))});let oe=z&&(!R||T&&(!ie||g?.activeView!==`preview`)),H=z&&(!ie||!oe),se=D_(g?.width??y_),U=Q.useMemo(()=>{let e=[];for(let t of L){if(t.mode!==`chat`)continue;let n=F_(t.dedupeKey);n&&!e.includes(n)&&e.push(n)}return e},[L]),ce=R_(m||void 0,U,i),[W,le]=Q.useState(!1),[ue,de]=Q.useState(!1),fe=Q.useRef(0),pe=Q.useRef(se),me=Q.useRef(null),he=Q.useRef(null),ge=Q.useRef({directory:h,width:se});Q.useLayoutEffect(()=>{W||((ge.current.directory!==h||z&&!te)&&(ge.current={directory:h,width:se}),t?.(z?B?1/0:se:0))},[h,te,z,W,t,B,se]);let _e=Q.useRef(null),ve=Q.useRef(new Map),ye=Q.useRef(new Map),be=Q.useRef(!1),xe=Q.useRef(z),Se=Q.useRef(null),[Ce,we]=Q.useState({}),Te=Q.useRef(Ce);Te.current=Ce;let[Ee,De]=Q.useReducer(Eg,{activeViewKey:null,tabs:{},mountedViews:{}}),Oe=c?`react-surface`:Jh(),ke=f(),Ae=Q.useCallback(e=>{let t=Te.current,n=e(t);return n!==t&&(Te.current=n,we(n),!0)},[]),je=Q.useCallback(e=>{if(!h)return;if(q.getState().contextPanelByDirectory[h]?.tabs.find(t=>t.id===e)?.mode===`btw`){let e=d;e&&pa.getState().clear({sessionId:e,directory:m,host:c?s.entry:void 0})}De({type:`close-tab`,tabId:e});let t=Yh(h,e);Ae(e=>{if(!e[t])return e;let n={...e};return delete n[t],n}),y(h,e)},[d,m,s,c,y,Ae,h]),Me=Q.useCallback(()=>{de(!0),Se.current!==null&&window.cancelAnimationFrame(Se.current),Se.current=window.requestAnimationFrame(()=>{Se.current=null,de(!1)})},[]);Q.useEffect(()=>()=>{Se.current!==null&&window.cancelAnimationFrame(Se.current)},[]),Q.useLayoutEffect(()=>{let e=xe.current;if(xe.current=z,!z){de(!1);return}e||Me()},[z,Me]),Q.useEffect(()=>{if(!z||be.current){be.current=z;return}let e=window.requestAnimationFrame(()=>{let e=_e.current;e&&!e.contains(document.activeElement)&&e.focus({preventScroll:!0})});return be.current=!0,()=>window.cancelAnimationFrame(e)},[z]);let Ne=K(e=>{let n=_e.current;if(!n)return;let r=k_(e,n);n.style.setProperty(`--yuri-context-panel-width`,`${r}px`),t?.(r)}),Pe=K(e=>{if(!z||!h)return;try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}he.current=e.pointerId,le(!0),fe.current=e.clientX;let t=_e.current?.clientWidth||se;pe.current=t,me.current=t,B&&x(h),Ne(t),e.preventDefault()}),Fe=Q.useCallback(e=>{if(!W||he.current!==e.pointerId)return;let t=fe.current-e.clientX,n=k_(pe.current+t,_e.current);me.current!==n&&(me.current=n,Ne(n))},[Ne,W]),Ie=Q.useCallback(e=>{if(he.current!==e.pointerId||!h)return;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}let t=k_(me.current??se,_e.current);Me(),Ne(t),me.current=t,S(h,t),le(!1),he.current=null},[Ne,h,S,Me,se]);Q.useEffect(()=>{W||(me.current=null)},[W]);let Le=Q.useCallback(()=>{if(!h)return;let e=d;e&&pa.getState().cancel({sessionId:e,directory:m,host:c?s.entry:void 0}),v(h)},[d,m,s,c,v,h]),Re=K(()=>{if(!h)return;if(!te){x(h);return}let e=ge.current.width,t=D_(Math.min(e,r?.()??e));t!==se&&S(h,t),B&&x(h)}),G=Q.useCallback(e=>{if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`w`&&R&&h){e.preventDefault(),e.stopPropagation(),je(R.id);return}e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Le())},[R,je,h,Le]);Q.useEffect(()=>{if(!(!h||!R)&&R.mode===`file`&&R.targetPath){k(h,R.targetPath,{allowOutsideRoot:!0});return}},[R,h,k]);let ze=R?.mode===`chat`?R.id:null,Be=ng(ze?Ce[Yh(h,ze)]:void 0,ze?F_(R?.dedupeKey):null);Q.useEffect(()=>{if(c||!H||!h||!Be){cn(``,null);return}return cn(h,Be),()=>{cn(``,null)}},[Be,h,H,c]),Q.useEffect(()=>{if(c||!H||!h||!Be||typeof window>`u`)return;let e=()=>{if(document.visibilityState===`hidden`||!document.hasFocus()){gn(h,Be,!1);return}sn(Be),gn(h,Be,!0)};e();let t=window.setInterval(e,1e4);return window.addEventListener(`focus`,e),window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,e),()=>{window.clearInterval(t),window.removeEventListener(`focus`,e),window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,e),gn(h,Be,!1)}},[Be,h,H,c]);let Ve=Q.useCallback((e,t,n)=>bo(ye.current,e,t,h||null,n,{mode:M,lightThemeId:P,darkThemeId:F,currentTheme:I}),[I,F,h,P,M]);Q.useEffect(()=>{let e=new Set(L.map(e=>e.id));for(let t of ye.current.keys())e.has(t)||ye.current.delete(t)},[L]);let He=Q.useCallback(e=>{!h||R?.mode!==`diff`&&R?.mode!==`file-diff`||b(h,{mode:R.mode,targetPath:R.targetPath,stagedDiff:e===`staged`,diffScope:e})},[R,h,b]),Ue=Q.useCallback(()=>{if(typeof window>`u`)return;let e={themeMode:M,lightThemeId:P,darkThemeId:F,currentTheme:I};for(let t of ve.current.values()){let n=t.contentWindow;if(!n)continue;let r=n.__yuriApplyThemeSync;if(typeof r==`function`)try{r(e);continue}catch{}n.postMessage({type:`yuri:theme-sync`,payload:e},window.location.origin)}},[I,F,P,M]),We=Q.useCallback(()=>{if(typeof window>`u`)return;let e={allowPromptingSubagentSessions:j};for(let t of ve.current.values()){let n=t.contentWindow;if(!n)continue;let r=n.__yuriApplyChatSettingsSync;if(typeof r==`function`)try{r(e);continue}catch{}n.postMessage({type:`yuri:chat-settings-sync`,payload:e},window.location.origin)}},[j]),Ge=Q.useCallback(()=>{if(!(typeof window>`u`))for(let[e,t]of ve.current.entries()){let n=t.contentWindow;if(!n)continue;let r={visible:H&&ze===e},i=n.__yuriSetEmbeddedVisibility;if(typeof i==`function`)try{i(r);continue}catch{}n.postMessage({type:vo,payload:r},window.location.origin)}},[ze,H]);Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{if(e.origin!==window.location.origin||!Array.from(ve.current.values()).some(t=>t.contentWindow===e.source))return;let t=e.data;if(t?.type===`yuri:close-embedded-session-chat`){let t=Array.from(ve.current.entries()).find(([,t])=>t.contentWindow===e.source);t&&h&&je(t[0]);return}if(t?.type===`yuri:chat-settings-request`){We();return}if(t?.type===`yuri:embedded-visibility-request`){Ge();return}if(t?.type!==`yuri:cycle-theme-request`)return;let n=[`light`,`dark`,`system`],r=(n.indexOf(M)+1)%n.length;N(n[r])};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[je,h,We,Ge,N,M]),Q.useLayoutEffect(()=>{L.some(e=>e.mode===`chat`)&&(Ue(),We(),Ge())},[F,P,We,Ge,Ue,L,M]);let Ke=Q.useMemo(()=>L.map(e=>{let t=N_(e,ce,a),n=U_(t,b_),r=A_(e.targetPath,m);return{id:e.id,label:n,icon:P_(e),title:r?`${t}: ${r}`:t,closeLabel:a(`contextPanel.tab.closeTabAria`,{label:n})}}),[m,ce,a,L]),qe=R?.mode===`context`?(0,$.jsx)(Cp,{active:H}):R?.mode===`preview`?(0,$.jsx)(X_,{rawUrl:R.targetPath??``,onNavigate:e=>A(h,e)},`${h}:${s?.entry.connectionGeneration??``}:${R.id}`):(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-4 p-6 text-center`,children:[(0,$.jsxs)(`div`,{"aria-hidden":`true`,className:`flex h-18 w-24 flex-col overflow-hidden rounded-lg border border-current/35 text-muted-foreground/45`,children:[(0,$.jsx)(`div`,{className:`flex h-3.5 shrink-0 items-end border-b border-current/25 px-2`,children:(0,$.jsx)(`span`,{className:`h-1.5 w-5 rounded-t-sm bg-current/20`})}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex w-6 shrink-0 flex-col gap-1.5 border-r border-current/25 px-1.5 py-3`,children:[(0,$.jsx)(`span`,{className:`h-0.5 w-full rounded-full bg-current/40`}),(0,$.jsx)(`span`,{className:`h-0.5 w-2 rounded-full bg-current/25`}),(0,$.jsx)(`span`,{className:`h-0.5 w-full rounded-full bg-current/25`})]}),(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,$.jsx)(Z,{name:`file-text`,className:`size-7`})})]})]}),(0,$.jsx)(`p`,{className:`typography-ui-label text-muted-foreground`,children:a(`contextPanel.empty.selectFile`)})]}),Je=Q.useMemo(()=>L.filter(e=>e.mode===`chat`),[L]),Ye=Q.useMemo(()=>L.filter(e=>e.mode===`browser`),[L]),Xe=Q.useMemo(()=>L.filter(e=>e.mode===`diff`||e.mode===`file-diff`),[L]),Ze=Pg({isElectron:!c&&Z_(),relayActive:o()})?$_:Q_,Qe=H&&R?.mode===`browser`&&Ze===$_;Q.useLayoutEffect(()=>{if(!Qe)return;let e=document.documentElement;return e.setAttribute(`data-yuri-native-browser-visible`,``),()=>e.removeAttribute(`data-yuri-native-browser-visible`)},[Qe]);let $e=Q.useMemo(()=>L.some(e=>e.mode===`file`),[L]),et=R?.mode===`file`,[tt,nt]=Q.useState(null),rt=et?R.targetPath:tt?.directory===h&&L.some(e=>e.mode===`file`&&e.targetPath===tt.path)?tt.path:null;Q.useEffect(()=>{nt(e=>e?.directory===h&&e.path===rt?e:{directory:h,path:rt??null})},[h,rt]);let it=et?R?.fileNotice??null:null;Q.useEffect(()=>{let e=new Set(Je.map(e=>Yh(h,e.id)));Ae(t=>{let n=!1,r={};for(let e of Je){let i=F_(e.dedupeKey);if(!i)continue;let a=Yh(h,e.id),o=t[a];r[a]=o??eg({sessionId:i,directory:h}),n||=!o}let i=sg(t,e);return n||=i!==t,n?{...i,...r}:t});for(let t of Object.keys(Ee.tabs))(!e.has(Yh(h,t))||Ee.tabs[t]?.directory!==h)&&De({type:`close-tab`,tabId:t})},[Je,Ae,h,Ee.tabs]);let at=ze?Yh(h,ze):null,ot=ze?F_(R?.dedupeKey):null,st=at&&ot?tg(Ce[at],{sessionId:ot,directory:h}):void 0,ct=st&&at?Xh(ke,at,st.current.directory,st.current.sessionId):null;Q.useLayoutEffect(()=>{if(Oe!==`react-surface`||!z||!ze||!st||!at||!ct){Oe===`react-surface`&&De({type:`activate`,viewKey:null,now:Date.now()});return}Ae(e=>e[at]?e:{...e,[at]:st}),De({type:`touch`,tab:{tabId:ze,sessionId:st.anchor.sessionId,directory:st.anchor.directory},view:{tabId:ze,surfaceId:at,sessionId:st.current.sessionId,directory:st.current.directory,viewKey:ct},now:Date.now()})},[st,at,ze,ct,Oe,Ae,z]);let lt=Q.useCallback((e,t,n)=>{let r=Yh(h,e),i=!1;return Ae(e=>{let a=c&&s?ee({...s.entry.location,directory:V(n,s.entry.location.hubId).directory}):n,o=og(e,r,{sessionId:t,directory:a});return i=o.accepted,o.navigationBySurfaceId}),i},[Ae,h,c,s]),ut=Q.useCallback(e=>{let t=Yh(h,e);Ae(e=>{let n=e[t];if(!n)return e;let r=ig(n);return r===n?e:{...e,[t]:r}})},[Ae,h]),dt=(0,$.jsxs)(`header`,{className:X(`app-region-drag flex shrink-0 select-none items-center pl-2`,I.metadata.variant===`light`&&[`[--interactive-hover:color-mix(in_srgb,var(--surface-foreground)_6%,var(--background))]`,`[--interactive-active:color-mix(in_srgb,var(--surface-foreground)_10%,var(--background))]`]),style:{height:`calc(var(--yuri-header-height, 3rem) - 0.75rem * var(--padding-scale, 1))`,minHeight:`calc(max(3rem, var(--yuri-wco-titlebar-height, 0px)) - 0.75rem * var(--padding-scale, 1))`,paddingRight:`calc(0.75rem + var(--yuri-wco-right-inset, 0px))`,...n&&!E?{paddingLeft:`calc(var(--yuri-titlebar-left-inset, 0.75rem) + var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`}:{}},children:[(0,$.jsx)(gs,{items:Ke,activeId:R?.id??null,onSelect:e=>{h&&C(h,e)},onClose:e=>{je(e)},onReorder:(e,t)=>{h&&w(h,e,t)},layoutMode:`scrollable`,variant:`compact`,className:`app-region-no-drag h-6`}),(0,$.jsxs)(`div`,{className:`app-region-no-drag flex shrink-0 items-center gap-1 pl-1.5`,children:[z?(0,$.jsx)(Rh,{railVisible:oe}):null,(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:Re,className:`h-7 w-7 p-0`,title:a(te?`contextPanel.actions.collapsePanel`:`contextPanel.actions.expandPanel`),"aria-label":a(te?`contextPanel.actions.collapsePanel`:`contextPanel.actions.expandPanel`),"aria-pressed":te,children:(0,$.jsx)(Z,{name:te?`collapse-diagonal`:`expand-diagonal`,className:`size-4`})}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:Le,className:`h-7 w-7 p-0`,title:a(`contextPanel.actions.closePanel`),"aria-label":a(`contextPanel.actions.closePanel`),children:(0,$.jsx)(Z,{name:`close`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(Zs,{visible:z&&D&&O===`right`,position:`right`})]})]}),ft=z?{width:te?`100%`:`min(var(--yuri-context-panel-width), 100%)`,minWidth:`min(${__}px, 100%)`,maxWidth:`100%`,"--yuri-context-panel-width":`${W?me.current??se:se}px`}:{"--yuri-context-panel-width":`${W?me.current??se:se}px`,width:0,minWidth:0,maxWidth:0,opacity:0,overflow:`hidden`,visibility:`hidden`};return(0,$.jsxs)(`aside`,{ref:_e,"data-context-panel":`true`,"data-native-browser-visible":Qe?`true`:void 0,tabIndex:-1,inert:!z||void 0,className:X(`flex min-h-0 flex-col overflow-visible bg-transparent`,z&&`py-1.5 pl-1 pr-1.5`,`relative h-full flex-shrink-0`,!z&&`pointer-events-none`,W||!z||ue||t?`transition-none`:`transition-[width] duration-200 ease-in-out`),onKeyDownCapture:G,style:ft,children:[(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`div`,{className:`group/preview-resize absolute -left-1 top-0 z-50 h-full w-4 touch-none cursor-col-resize`,onPointerDown:Pe,onPointerMove:Fe,onPointerUp:Ie,onPointerCancel:Ie,role:`separator`,"aria-orientation":`vertical`,"aria-label":a(`contextPanel.actions.resizePanelAria`),"data-context-resize-handle":!0,children:(0,$.jsx)(`span`,{"aria-hidden":`true`,className:X(`pointer-events-none absolute left-[2px] top-1/2 h-14 w-[3px] -translate-y-1/2 rounded-full bg-muted-foreground/25 opacity-0 transition-opacity duration-150 group-hover/preview-resize:opacity-100`,W&&`opacity-100`)})})}),(0,$.jsx)(Ea,{side:`right`,sideOffset:4,children:a(`contextPanel.actions.resizePanel`)})]}),(0,$.jsxs)(Hl,{"data-context-panel-surface":!0,children:[dt,it===`turn-diff-outside-workspace`?(0,$.jsx)(`div`,{className:`shrink-0 border-b border-status-info/20 bg-status-info/10 px-3 py-2 typography-meta text-status-info`,children:a(`contextPanel.file.notice.turnDiffOutsideWorkspace`)}):null,(0,$.jsxs)(`div`,{ref:ne,className:X(`relative flex min-h-0 flex-1 overflow-hidden`,W&&`pointer-events-none`),"data-context-layout":ie?`single`:`split`,children:[(0,$.jsx)(`div`,{className:X(`min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,H?`flex`:`hidden`),inert:!H||void 0,"data-context-preview-content":!0,children:(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[$e&&rt?(0,$.jsx)(`div`,{className:X(`absolute inset-0`,et?`block`:`hidden`),children:(0,$.jsx)(Jf,{mode:`editor-only`,targetPath:rt,isActive:H&&et},`${h}:${rt??``}`)}):null,Oe===`legacy-iframe`&&Je.map(e=>{let t=F_(e.dedupeKey);if(!t)return null;let n=Ve(e.id,t,e.readOnly);return n?(0,$.jsx)(`iframe`,{ref:t=>{if(!t){ve.current.delete(e.id);return}ve.current.set(e.id,t)},src:n,title:a(`contextPanel.iframe.sessionChatTitle`,{sessionID:t}),className:X(`absolute inset-0 h-full w-full border-0 bg-background`,ze===e.id?`block`:`hidden`),onLoad:()=>{Ue(),We(),Ge()}},e.id):null}),Oe===`react-surface`?Object.values(Ee.mountedViews).map(e=>{let t=Ce[Yh(h,e.tabId)],n=H&&ze===e.tabId&&ct===e.viewKey;return(0,$.jsx)(Q.Activity,{name:`context-panel-session-${e.sessionId}`,mode:n?`visible`:`hidden`,children:c&&s?(0,$.jsxs)(`div`,{className:`relative h-full min-h-0`,children:[n&&t?.stack.length?(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,onClick:()=>ut(e.tabId),className:`absolute left-3 top-3 z-20 !font-normal bg-[var(--surface-background)]/95`,"aria-label":a(`chat.container.returnToParent.aria`),title:a(`chat.container.returnToParent.title`),children:[(0,$.jsx)(Z,{name:`arrow-left`,className:`h-4 w-4`}),a(`chat.container.returnToParent.label`)]}):null,(0,$.jsx)(Qi,{location:{...s.entry.location,directory:V(e.directory,s.entry.location.hubId).directory},sessionId:e.sessionId,active:n,readOnly:L.find(t=>t.id===e.tabId)?.readOnly??!0,onNavigateSession:(t,n)=>{lt(e.tabId,t,n)}})]}):(0,$.jsx)(kg,{surfaceId:e.surfaceId,sessionId:e.sessionId,directory:e.directory,active:n,canNavigateBack:n&&!!t?.stack.length,onNavigateSession:(t,n)=>lt(e.tabId,t,n),onNavigateBack:()=>ut(e.tabId),onEstimateBytes:(e,t)=>De({type:`estimate`,viewKey:e,estimatedBytes:t})})},e.viewKey)}):null,L.filter(e=>e.mode===`btw`).map(e=>{let t=H&&R?.id===e.id;return(0,$.jsx)(Q.Activity,{name:`context-panel-btw`,mode:t?`visible`:`hidden`,children:d?(0,$.jsx)(ki,{scope:{sessionId:d,directory:m,host:c?s.entry:void 0},hostRegistry:c?s.registry:void 0,active:t}):(0,$.jsx)(`p`,{className:`p-4 text-muted-foreground`,children:a(`chat.btw.sessionRequired`)})},`btw:${h}:${d}:${e.id}`)}),Ye.map(e=>(0,$.jsx)(`div`,{className:X(`absolute inset-0`,R?.id!==e.id&&`hidden`),children:(0,$.jsx)(Ze,{initialUrl:e.targetPath??``,directory:h,tabID:e.id})},`${h}:${s?.entry.connectionGeneration??``}:${e.id}`)),Xe.map(e=>{let t=e.mode===`diff`&&_?.targetPath===e.targetPath&&_.turnMessageId===e.diffTurnMessageId?_.patches:null;return(0,$.jsx)(`div`,{className:X(`absolute inset-0`,R?.id!==e.id&&`hidden`),children:(0,$.jsx)(uc,{hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!t,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:e.diffScope??(e.stagedDiff?`staged`:`working`),turnMessageId:e.diffTurnMessageId,sessionId:e.diffSessionId,directory:m,onDiffScopeChange:He,targetFilePath:e.targetPath,targetLine:e.diffTargetLine??null,toolPatches:t,navigationRequestKey:e.touchedAt,flushContent:!0,singleFileView:e.mode===`file-diff`,preloadFullFiles:e.mode===`file-diff`})},e.id)}),R?.mode!==`chat`&&R?.mode!==`btw`&&!et&&R?.mode!==`browser`&&R?.mode!==`diff`&&R?.mode!==`file-diff`?qe:null]})}),(0,$.jsx)(Up,{isOpen:oe,className:X(`!min-w-0 shrink-0 bg-transparent [--layout-chrome-divider-width:1px] [--layout-chrome-divider:color-mix(in_srgb,var(--surface-foreground)_8%,var(--background))]`,ie&&`!transition-none`,ie&&oe?`!w-full !max-w-full !border-l-0 [&>[role=separator]]:hidden`:`!max-w-[50%]`),children:oe?(0,$.jsx)(po,{children:(0,$.jsx)(zh,{isActive:oe})}):null})]})]})]})};function iv(e){return e.sessions}var av=350,ov=e=>{let t=(0,du.c)(26),{children:n,header:r,footer:i}=e,a=Q.useRef(null),o=Q.useRef(0),s=Q.useRef(0),c=Q.useRef(!1),[l,u]=Q.useState(!1),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{if(o.current<=0)return;let e=s.current>0&&o.current-s.current<av;e!==c.current&&(c.current=e,u(e))},t[0]=d):d=t[0];let f=K(d),p;t[1]===f?p=t[2]:(p=e=>{s.current=e,f()},t[1]=f,t[2]=p);let m=K(p),h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>o.current-av,t[3]=h):h=t[3];let g=K(h),_,v;t[4]===f?(_=t[5],v=t[6]):(_=()=>{o.current=a.current?.clientWidth??0,f()},v=[f],t[4]=f,t[5]=_,t[6]=v),Q.useLayoutEffect(_,v);let y;t[7]===f?y=t[8]:(y=e=>{let[t]=e;t&&(o.current=t.contentRect.width,f())},t[7]=f,t[8]=y),Nt(a,y);let b;t[9]===l?b=t[10]:(b=l?{display:`none`}:{minWidth:`min(${av}px, 100%)`},t[9]=l,t[10]=b);let x=l||void 0,S;t[11]===n?S=t[12]:(S=(0,$.jsx)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden yuri-layout-divider-t`,"data-primary-chat-content":!0,children:n}),t[11]=n,t[12]=S);let C;t[13]!==i||t[14]!==r||t[15]!==b||t[16]!==x||t[17]!==S?(C=(0,$.jsxs)(`main`,{className:`flex flex-1 min-w-0 flex-col overflow-hidden bg-background relative`,style:b,inert:x,"data-page-scroll-lock":`true`,"data-primary-chat":!0,children:[r,S,i]}),t[13]=i,t[14]=r,t[15]=b,t[16]=x,t[17]=S,t[18]=C):C=t[18];let w;t[19]!==g||t[20]!==m||t[21]!==l?(w=(0,$.jsx)(ev,{onReservedWidthChange:m,fillAvailableSpace:l,getMaxSplitWidth:g}),t[19]=g,t[20]=m,t[21]=l,t[22]=w):w=t[22];let T;return t[23]!==C||t[24]!==w?(T=(0,$.jsxs)(`div`,{ref:a,className:`relative flex flex-1 min-h-0 min-w-0 overflow-hidden`,"data-page-scroll-lock":`true`,"data-chat-area":!0,children:[C,w]}),t[23]=C,t[24]=w,t[25]=T):T=t[25],T},sv=(e,t,n)=>so(e)?Ka(e,n).map(to):t,cv=()=>{let e=(0,du.c)(34),{t}=Zt(),{isMobile:n}=go(),r=q(lv),i=q(uv),a=q(dv),o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=ro(),e[0]=o):o=e[0];let s=o,c;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=w(),e[1]=c):c=e[1];let l=c,u,d,f,p,m,h,g,_,v;if(e[2]!==r||e[3]!==n||e[4]!==i||e[5]!==a||e[6]!==t){let o=[{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:`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:[`Shift + ${s} + 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:`previous_session`,descriptionKey:`helpDialog.item.previousSession`,icon:`arrow-left`,keys:``},{id:`next_session`,descriptionKey:`helpDialog.item.nextSession`,icon:`arrow-right`,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.leaderChords`,items:[{keys:`Ctrl+X → M`,descriptionKey:`helpDialog.item.leaderOpenModel`,icon:`ai-generate-2`},{keys:`Ctrl+X → A`,descriptionKey:`helpDialog.item.leaderOpenAgent`,icon:`ai-agent`},{keys:`Ctrl+X → N`,descriptionKey:`helpDialog.item.leaderNewSession`,icon:`add`},{keys:`Ctrl+X → C`,descriptionKey:`helpDialog.item.leaderCompact`,icon:`scissors`}]},{categoryKey:`helpDialog.section.panels`,items:[{id:`toggle_right_sidebar`,descriptionKey:`helpDialog.item.toggleRightSidebar`,icon:`layout-right`,keys:``},{id:`open_right_sidebar_git`,descriptionKey:`helpDialog.item.openRightSidebarGitTab`,icon:`git-branch`,keys:``},{id:`open_right_sidebar_files`,descriptionKey:`helpDialog.item.openRightSidebarFilesTab`,icon:`layout-right`,keys:``},{id:`cycle_right_sidebar_tab`,descriptionKey:`helpDialog.item.cycleRightSidebarTab`,icon:`layout-right`,keys:``},{id:`close_context_panel_tab`,descriptionKey:`helpDialog.item.closeContextPanelTab`,icon:`close`,keys:``},{id:`toggle_terminal`,descriptionKey:`helpDialog.item.toggleTerminal`,icon:`window`,keys:``},{id:`new_terminal_tab`,descriptionKey:`helpDialog.item.newTerminalTab`,icon:`terminal-box`,keys:``},{id:`open_new_terminal`,descriptionKey:`helpDialog.item.openNewTerminal`,icon:`terminal-box`,keys:``},{id:`previous_terminal_tab`,descriptionKey:`helpDialog.item.previousTerminalTab`,icon:`arrow-left`,keys:``},{id:`next_terminal_tab`,descriptionKey:`helpDialog.item.nextTerminalTab`,icon:`arrow-right`,keys:``},{id:`toggle_bottom_panel`,descriptionKey:`helpDialog.item.toggleBottomPanel`,icon:`window`,keys:``},{id:`toggle_terminal_expanded`,descriptionKey:`helpDialog.item.toggleTerminalExpanded`,icon:`window`,keys:``}]},{categoryKey:`helpDialog.section.interface`,items:[{id:`cycle_theme`,descriptionKey:`helpDialog.item.cycleTheme`,icon:`palette`,keys:``},{id:`zoom_in`,descriptionKey:`helpDialog.item.zoomIn`,icon:`add`,keys:``},{id:`zoom_out`,descriptionKey:`helpDialog.item.zoomOut`,icon:`subtract`,keys:``},{id:`zoom_reset`,descriptionKey:`helpDialog.item.zoomReset`,icon:`restart`,keys:``},{keys:[`${s} + 1...9`],descriptionKey:`helpDialog.item.switchSession`,icon:`layout-left`},{id:`toggle_services_menu`,descriptionKey:`helpDialog.item.toggleServicesMenu`,icon:`stack`,keys:``},{id:`open_usage`,descriptionKey:`helpDialog.item.openUsage`,icon:`timer`,keys:``},{id:`cycle_services_tab`,descriptionKey:`helpDialog.item.cycleServicesTab`,icon:`stack`,keys:``},{id:`open_settings`,descriptionKey:`helpDialog.item.openSettings`,icon:`settings-3`,keys:``}]}];d=Jr,g=r,_=i,u=Gr,p=n?`default`:`picker`,m=n?`max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden`:void 0;let c;e[16]===t?c=e[17]:(c=t(`helpDialog.title`),e[16]=t,e[17]=c),e[18]===c?h=e[19]:(h=(0,$.jsx)(Ur,{className:`yuri-picker-header`,children:(0,$.jsx)(Kr,{className:`yuri-picker-title`,children:c})}),e[18]=c,e[19]=h),f=`yuri-picker-list`,v=(0,$.jsx)(`div`,{children:o.map(e=>(0,$.jsxs)(`div`,{className:`yuri-picker-section`,children:[(0,$.jsx)(`h3`,{className:`yuri-picker-section-title text-muted-foreground`,children:t(e.categoryKey)}),(0,$.jsx)(`div`,{children:e.items.filter(e=>!(l&&e.id===`toggle_prompt_navigator`)).map(e=>{let n=e.id?sv(e.id,Array.isArray(e.keys)?e.keys[0]:e.keys,a):Array.isArray(e.keys)?e.keys:e.keys.split(` / `);return(0,$.jsxs)(`div`,{className:`yuri-picker-row yuri-help-shortcut-row`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,$.jsx)(Z,{name:e.icon,className:`h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`yuri-picker-label`,children:t(e.descriptionKey)})]}),(0,$.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-1`,children:(Array.isArray(n)?n:[n]).map((e,n)=>(0,$.jsxs)(Q.Fragment,{children:[n>0&&(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground mx-1`,children:t(`helpDialog.keyCombiner.or`)}),(0,$.jsx)($i,{shortcut:e,variant:`hint`})]},`${e}-${n}`))})]},e.id||e.descriptionKey)})})]},e.categoryKey))}),e[2]=r,e[3]=n,e[4]=i,e[5]=a,e[6]=t,e[7]=u,e[8]=d,e[9]=f,e[10]=p,e[11]=m,e[12]=h,e[13]=g,e[14]=_,e[15]=v}else u=e[7],d=e[8],f=e[9],p=e[10],m=e[11],h=e[12],g=e[13],_=e[14],v=e[15];let y;e[20]!==f||e[21]!==v?(y=(0,$.jsx)(`div`,{className:f,children:v}),e[20]=f,e[21]=v,e[22]=y):y=e[22];let b;e[23]!==u||e[24]!==p||e[25]!==m||e[26]!==h||e[27]!==y?(b=(0,$.jsxs)(u,{presentation:p,className:m,children:[h,y]}),e[23]=u,e[24]=p,e[25]=m,e[26]=h,e[27]=y,e[28]=b):b=e[28];let x;return e[29]!==d||e[30]!==b||e[31]!==g||e[32]!==_?(x=(0,$.jsx)(d,{open:g,onOpenChange:_,children:b}),e[29]=d,e[30]=b,e[31]=g,e[32]=_,e[33]=x):x=e[33],x};function lv(e){return e.isHelpDialogOpen}function uv(e){return e.setHelpDialogOpen}function dv(e){return e.shortcutOverrides}var fv=()=>{let e=(0,du.c)(32),{t}=Zt(),n=q(pv),r=q(mv),i=q(hv),a;e[0]!==i||e[1]!==t?(a=async()=>{if(i){if((await Pn(i)).ok){J.success(t(`openCodeStatusDialog.toast.copiedTitle`),{description:t(`openCodeStatusDialog.toast.copiedDescription`)});return}J.error(t(`openCodeStatusDialog.toast.copyFailed`))}},e[0]=i,e[1]=t,e[2]=a):a=e[2];let o=a,s;e[3]===t?s=e[4]:(s=t(`openCodeStatusDialog.title`),e[3]=t,e[4]=s);let c;e[5]===s?c=e[6]:(c=(0,$.jsx)(Kr,{children:s}),e[5]=s,e[6]=c);let l;e[7]===t?l=e[8]:(l=t(`openCodeStatusDialog.description`),e[7]=t,e[8]=l);let u;e[9]===l?u=e[10]:(u=(0,$.jsx)(qr,{children:l}),e[9]=l,e[10]=u);let d;e[11]!==c||e[12]!==u?(d=(0,$.jsxs)(Ur,{children:[c,u]}),e[11]=c,e[12]=u,e[13]=d):d=e[13];let f;e[14]===t?f=e[15]:(f=t(`openCodeStatusDialog.actions.copy`),e[14]=t,e[15]=f);let p;e[16]!==o||e[17]!==f?(p=(0,$.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,$.jsx)(`button`,{type:`button`,onClick:o,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:f})}),e[16]=o,e[17]=f,e[18]=p):p=e[18];let m;e[19]!==i||e[20]!==t?(m=i||t(`openCodeStatusDialog.empty.noData`),e[19]=i,e[20]=t,e[21]=m):m=e[21];let h;e[22]===m?h=e[23]:(h=(0,$.jsx)(`pre`,{className:`max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap`,children:m}),e[22]=m,e[23]=h);let g;e[24]!==d||e[25]!==p||e[26]!==h?(g=(0,$.jsxs)(Gr,{className:`max-w-2xl`,children:[d,p,h]}),e[24]=d,e[25]=p,e[26]=h,e[27]=g):g=e[27];let _;return e[28]!==n||e[29]!==r||e[30]!==g?(_=(0,$.jsx)(Jr,{open:n,onOpenChange:r,children:g}),e[28]=n,e[29]=r,e[30]=g,e[31]=_):_=e[31],_};function pv(e){return e.isOpenCodeStatusDialogOpen}function mv(e){return e.setOpenCodeStatusDialogOpen}function hv(e){return e.openCodeStatusText}function gv(){let e=(0,du.c)(2),t=$t(),n;return e[0]===t?n=e[1]:(n=t?(0,$.jsx)(Yc,{className:`ml-auto`}):null,e[0]=t,e[1]=n),n}function _v(){let e=(0,du.c)(2),t=en(),n;return e[0]===t?n=e[1]:(n=t?(0,$.jsx)(Yc,{}):null,e[0]=t,e[1]=n),n}var vv=e=>{let t=(0,du.c)(12),{normalizedProjects:n,ownership:r,isSessionsLoading:i,fullCatalogSessionIds:a,fullCatalogGeneration:o,foldersMap:s,createFolder:c,addSessionToFolder:l,cleanupSessions:u,enabled:d}=e,f=d===void 0||d,p,m;t[0]!==l||t[1]!==u||t[2]!==c||t[3]!==f||t[4]!==s||t[5]!==o||t[6]!==a||t[7]!==i||t[8]!==n||t[9]!==r?(p=()=>{!f||i||n.forEach(e=>{let t=Ga(e.normalizedPath),n=r.archivedSessionsByProject.get(e.id)??[],i=s[t]??[],d=new Map(i.map(yv));n.forEach(n=>{let r=Aa(n,e.normalizedPath),i=r.toLowerCase(),a=d.get(i);a||(a=c(t,r),d.set(i,a)),a.sessionIds.includes(n.id)||l(t,a.id,n.id)}),o>0&&u(t,a)})},m=[f,n,r,i,o,a,s,c,l,u],t[0]=l,t[1]=u,t[2]=c,t[3]=f,t[4]=s,t[5]=o,t[6]=a,t[7]=i,t[8]=n,t[9]=r,t[10]=p,t[11]=m):(p=t[10],m=t[11]),Q.useEffect(p,m)};function yv(e){return[e.name.toLowerCase(),e]}var bv=e=>{let t=(0,du.c)(7),{isSessionsLoading:n,fullCatalogSessionIds:r,fullCatalogGeneration:i,normalizedProjects:a,cleanupSessions:o}=e,s,c;t[0]!==o||t[1]!==i||t[2]!==r||t[3]!==n||t[4]!==a?(s=()=>{if(n||i===0)return;let e=or.getState().foldersMap;new Set([...Object.keys(e),...a.map(xv)]).forEach(e=>{o(e,r)})},c=[o,i,r,n,a],t[0]=o,t[1]=i,t[2]=r,t[3]=n,t[4]=a,t[5]=s,t[6]=c):(s=t[5],c=t[6]),Q.useEffect(s,c)};function xv(e){return Ga(e.normalizedPath)}var Sv=Q.memo(function(e){let t=(0,du.c)(17),{normalizedProjects:n,ownership:r,enabled:i}=e;Mc();let a=wr(Cv),o=wr(wv),s=cr(Tv),c=or(Ev),l=or(Dv),u=or(Ov),d=or(kv),f;t[0]!==d||t[1]!==o||t[2]!==a||t[3]!==s||t[4]!==n?(f={normalizedProjects:n,fullCatalogSessionIds:a,fullCatalogGeneration:o,isSessionsLoading:s,cleanupSessions:d},t[0]=d,t[1]=o,t[2]=a,t[3]=s,t[4]=n,t[5]=f):f=t[5],bv(f);let p;return t[6]!==u||t[7]!==d||t[8]!==l||t[9]!==i||t[10]!==c||t[11]!==o||t[12]!==a||t[13]!==s||t[14]!==n||t[15]!==r?(p={normalizedProjects:n,ownership:r,enabled:i,fullCatalogSessionIds:a,fullCatalogGeneration:o,isSessionsLoading:s,foldersMap:c,createFolder:l,addSessionToFolder:u,cleanupSessions:d},t[6]=u,t[7]=d,t[8]=l,t[9]=i,t[10]=c,t[11]=o,t[12]=a,t[13]=s,t[14]=n,t[15]=r,t[16]=p):p=t[16],vv(p),null});function Cv(e){return e.fullCatalogSessionIds}function wv(e){return e.fullCatalogGeneration}function Tv(e){return e.isLoading}function Ev(e){return e.foldersMap}function Dv(e){return e.createFolder}function Ov(e){return e.addSessionToFolder}function kv(e){return e.cleanupSessions}var Av=new WeakMap,jv=e=>{let{normalizedProjects:t,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:a,projectRootBranches:o,lastRepoStatus:s,buildGroupedSessions:c,hasSessionSearchQuery:l,normalizedSessionSearchQuery:u,filterSessionNodesForSearch:d,buildGroupSearchText:f,foldersMap:p}=e,m=Q.useRef([]),h=Q.useMemo(()=>{let e=new Map(m.current.map(e=>[e.project.id,e])),l=t.map(t=>{let l=e.get(t.id),u=eo([...n(t.id),...r(t.id)]),d=i.get(t.normalizedPath)??[],f=a.has(t.id)?!!a.get(t.id):s,p=new Map(l?.groups.map(e=>[e.id,e])),m=c(u,t.normalizedPath,d,o.get(t.id)??null,f).map(e=>pt(p.get(e.id),e));return pt(l,{project:t,groups:m})});return l.length===m.current.length&&l.every((e,t)=>e===m.current[t])?m.current:l},[t,n,r,i,a,s,c,o]);Q.useLayoutEffect(()=>{m.current=h},[h]);let g=Q.useMemo(()=>h,[h]),_=Q.useMemo(()=>{if(!l)return Av;let e=new WeakMap,t=e=>e.reduce((e,n)=>e+1+t(n.children),0);return g.forEach(n=>{n.groups.forEach(n=>{let r=d(n.sessions,u),i=t(r),a=f(n).includes(u),o=M(n.directory??null),s=(o?p[o]??[]:[]).filter(e=>e.name.toLowerCase().includes(u)).length;e.set(n,{filteredNodes:r,matchedSessionCount:i,folderNameMatchCount:s,groupMatches:a,hasMatch:a||i>0||s>0})})}),e},[l,g,d,u,f,p]),v=Q.useMemo(()=>l?g.map(e=>({...e,groups:e.groups.filter(e=>_.get(e)?.hasMatch===!0)})).filter(e=>e.groups.length>0):g,[l,g,_]),y=l?v:g;return{projectSections:h,visibleProjectSections:g,groupSearchDataByGroup:_,searchableProjectSections:v,sectionsForRender:y,searchMatchCount:Q.useMemo(()=>l?y.reduce((e,t)=>e+t.groups.reduce((e,t)=>{let n=_.get(t);if(!n)return e;let r=n.folderNameMatchCount+ +!!n.groupMatches;return e+n.matchedSessionCount+r},0),0):0,[l,y,_])}},Mv=e=>{let t=(0,du.c)(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:a,currentSessionId:o,handleSessionSelect:s,newSessionDraftOpen:c,mobileVariant:l,openNewSessionDraft:u,setActiveMainTab:d,setSessionSwitcherOpen:f}=e,p,m;if(t[0]!==n){m=new Map,p=new Map;let e=(t,n,r,i)=>{m.has(t)||m.set(t,new Map);let a=m.get(t);i.forEach(i=>{let o=M(i.worktree?.path??i.session.directory??r??n);a.set(i.session.id,{directory:o}),p.has(t)||p.set(t,{id:i.session.id,directory:o}),i.children.length>0&&e(t,n,o,i.children)})};n.forEach(t=>{t.groups.forEach(n=>{e(t.project.id,t.project.normalizedPath,n.directory,n.sessions)})}),t[0]=n,t[1]=p,t[2]=m}else p=t[1],m=t[2];let h;t[3]!==p||t[4]!==m?(h={metaByProject:m,firstSessionByProject:p},t[3]=p,t[4]=m,t[5]=h):h=t[5];let g=h,_=Q.useRef(null),v,y;t[6]!==r||t[7]!==i||t[8]!==o||t[9]!==s||t[10]!==l||t[11]!==c||t[12]!==u||t[13]!==n||t[14]!==g||t[15]!==d||t[16]!==a||t[17]!==f?(v=()=>{if(!r||c||q.getState().isNewWorktreeDialogOpen||_.current===r)return;let e=n.find(e=>e.project.id===r);if(!e)return;_.current=r;let t=g.metaByProject.get(r);if(o&&t&&t.has(o)){a(e=>{if(e.get(r)===o)return e;let t=new Map(e);return t.set(r,o),t});return}if(o&&t)return;if(!t||t.size===0){d(`chat`),l&&f(!1),u({directoryOverride:e.project.normalizedPath});return}let p=i.get(r),m=p&&t.has(p)?p:null,h=g.firstSessionByProject.get(r)?.id??null,v=m??h;if(!v||v===o)return;let y=t.get(v)?.directory??null;s(v,y,r)},y=[r,i,o,s,c,l,u,n,g,d,f,a],t[6]=r,t[7]=i,t[8]=o,t[9]=s,t[10]=l,t[11]=c,t[12]=u,t[13]=n,t[14]=g,t[15]=d,t[16]=a,t[17]=f,t[18]=v,t[19]=y):(v=t[18],y=t[19]),Q.useLayoutEffect(v,y);let b,x;t[20]!==r||t[21]!==o||t[22]!==g||t[23]!==a?(b=()=>{if(!r||!o)return;let e=g.metaByProject.get(r);!e||!e.has(o)||a(e=>{if(e.get(r)===o)return e;let t=new Map(e);return t.set(r,o),t})},x=[r,o,g,a],t[20]=r,t[21]=o,t[22]=g,t[23]=a,t[24]=b,t[25]=x):(b=t[24],x=t[25]),Q.useEffect(b,x)},Nv=e=>{let t=bn(e=>e.orderByProject);return{getOrderedGroups:Q.useMemo(()=>(n,r)=>{let i=e.get(n),a=t[n];if(!i?.length&&!a?.length)return r;let o=new Map(r.map(e=>[e.id,e])),s=[];if(i?.forEach(e=>{let t=o.get(e);t&&(s.push(t),o.delete(e))}),r.forEach(e=>{o.has(e.id)&&s.push(e)}),!a?.length)return s;let c=new Map(a.map((e,t)=>[M(e),t])),l=s.filter(e=>e.worktree&&!e.isMain);l.sort((e,t)=>(c.get(M(e.directory))??2**53-1)-(c.get(M(t.directory))??2**53-1));let u=0;return s.map(e=>e.worktree&&!e.isMain?l[u++]:e)},[e,t])}},Pv=e=>{let t=(0,du.c)(9),{isSessionSearchOpen:n,setIsSessionSearchOpen:r,sessionSearchInputRef:i,sessionSearchContainerRef:a}=e,o,s;t[0]!==n||t[1]!==i?(o=()=>{if(!n||typeof window>`u`)return;let e=window.requestAnimationFrame(()=>{i.current?.focus(),i.current?.select()});return()=>window.cancelAnimationFrame(e)},s=[n,i],t[0]=n,t[1]=i,t[2]=o,t[3]=s):(o=t[2],s=t[3]),Q.useEffect(o,s);let c,l;t[4]!==n||t[5]!==a||t[6]!==r?(c=()=>{if(!n||typeof document>`u`)return;let e=e=>{a.current&&(a.current.contains(e.target)||r(!1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},l=[n,r,a],t[4]=n,t[5]=a,t[6]=r,t[7]=c,t[8]=l):(c=t[7],l=t[8]),Q.useEffect(c,l)},Fv=e=>{let t=(0,du.c)(42),{t:n}=Zt(),[r,i]=Q.useState(null),a=Q.useRef(null),o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>()=>{a.current&&clearTimeout(a.current)},s=[],t[0]=o,t[1]=s):(o=t[0],s=t[1]),Q.useEffect(o,s);let c;t[2]===e?c=t[3]:(c=(t,n,r)=>{let i=()=>{!e.isSessionSearchOpen&&e.sessionSearchQuery.length===0||(e.setSessionSearchQuery(``),e.setIsSessionSearchOpen(!1))};if(r&&r!==e.activeProjectId&&e.setActiveProjectIdOnly(r),n&&n!==e.currentDirectory&&e.setDirectory(n,{showOverlay:!1}),e.setActiveMainTab(`chat`)){if(e.mobileVariant&&e.setSessionSwitcherOpen(!1),t===e.currentSessionId){e.allowReselect&&e.onSessionSelected?.(t),i();return}e.setCurrentSession(t,n??null),e.onSessionSelected?.(t),i()}},t[2]=e,t[3]=c);let l=c,u;t[4]===e?u=t[5]:(u=(t,n)=>{e.setEditingId(t),e.setEditTitle(n)},t[4]=e,t[5]=u);let d=u,f;t[6]===e?f=t[7]:(f=async t=>{if(!e.editingId)return;let n=(t??e.editTitle).trim();n&&await e.updateSessionTitle(e.editingId,n),e.setEditingId(null),e.setEditTitle(``)},t[6]=e,t[7]=f);let p=f,m;t[8]===e?m=t[9]:(m=()=>{e.setEditingId(null),e.setEditTitle(``)},t[8]=e,t[9]=m);let h=m,g;t[10]!==e||t[11]!==n?(g=async t=>{let r=await e.shareSession(t.id);r&&r.share?.url?J.success(n(`sessions.sidebar.session.share.successTitle`),{description:n(`sessions.sidebar.session.share.successDescription`)}):J.error(n(`sessions.sidebar.session.share.error`))},t[10]=e,t[11]=n,t[12]=g):g=t[12];let _=g,v;t[13]===n?v=t[14]:(v=(e,t)=>{Pn(e).then(e=>{if(!e.ok){J.error(n(`sessions.sidebar.session.share.copyUrlError`));return}i(t),a.current&&clearTimeout(a.current),a.current=window.setTimeout(()=>{i(null),a.current=null},2e3)}).catch(()=>{J.error(n(`sessions.sidebar.session.share.copyUrlError`))})},t[13]=n,t[14]=v);let y=v,b;t[15]!==e||t[16]!==n?(b=async t=>{await e.unshareSession(t)?J.success(n(`sessions.sidebar.session.unshare.success`)):J.error(n(`sessions.sidebar.session.unshare.error`))},t[15]=e,t[16]=n,t[17]=b):b=t[17];let x=b,S;t[18]===e.childrenMap?S=t[19]:(S=t=>{let n=[],r=t=>{(e.childrenMap.get(t)??[]).forEach(e=>{n.push(e),r(e.id)})};return r(t),n},t[18]=e.childrenMap,t[19]=S);let C=S,w=Lv,T;t[20]!==e||t[21]!==C||t[22]!==n?(T=async(t,r,i)=>{let a=r?.archivedBucket===!0||r?.hardDelete===!0,o=i?.descendantIds??w(C(t.id),a).map(Rv);if(o.length===0){if(a){il({sessionIds:[t.id],message:n(`sessions.sidebar.session.delete.success`),undoLabel:n(`sessions.sidebar.undo`),commitFailedMessage:n(`sessions.sidebar.session.delete.error`)});return}await e.archiveSession(t.id)?nl({sessionIds:[t.id],message:n(`sessions.sidebar.session.archive.success`),undoLabel:n(`sessions.sidebar.undo`),settingsLabel:n(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:n(`sessions.sidebar.session.archive.undoFailed`)}):J.error(n(`sessions.sidebar.session.archive.error`));return}let s=[t.id,...o];if(a){il({sessionIds:s,message:s.length===1?n(`sessions.sidebar.bulkActions.deletedSingle`,{count:s.length}):n(`sessions.sidebar.bulkActions.deletedPlural`,{count:s.length}),undoLabel:n(`sessions.sidebar.undo`),commitFailedMessage:n(`sessions.sidebar.session.delete.error`)});return}let{archivedIds:c,failedIds:l}=await e.archiveSessions(s);c.length>0&&nl({sessionIds:c,message:c.length===1?n(`sessions.sidebar.bulkActions.archivedSingle`,{count:c.length}):n(`sessions.sidebar.bulkActions.archivedPlural`,{count:c.length}),undoLabel:n(`sessions.sidebar.undo`),settingsLabel:n(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:c.length===1?n(`sessions.sidebar.session.archive.undoFailed`):n(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:c.length})}),l.length>0&&J.error(l.length===1?n(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:l.length}):n(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:l.length}))},t[20]=e,t[21]=C,t[22]=n,t[23]=T):T=t[23];let E=T,D;t[24]!==e||t[25]!==C||t[26]!==E?(D=(t,n)=>{let r=n?.archivedBucket===!0||n?.hardDelete===!0,i=w(C(t.id),r).map(zv);if(!r||!e.showDeletionDialog||n?.skipConfirm===!0){E(t,n,{descendantIds:i});return}e.setDeleteSessionConfirm({session:t,descendantCount:i.length,descendantIds:i,archivedBucket:r})},t[24]=e,t[25]=C,t[26]=E,t[27]=D):D=t[27];let O=D,k;t[28]!==e||t[29]!==E?(k=async()=>{if(!e.deleteSessionConfirm)return;let{session:t,archivedBucket:n,descendantIds:r}=e.deleteSessionConfirm;e.setDeleteSessionConfirm(null),await E(t,{archivedBucket:n},{descendantIds:r})},t[28]=e,t[29]=E,t[30]=k):k=t[30];let A=k,j;return t[31]!==A||t[32]!==r||t[33]!==h||t[34]!==y||t[35]!==O||t[36]!==p||t[37]!==d||t[38]!==l||t[39]!==_||t[40]!==x?(j={copiedSessionId:r,handleSessionSelect:l,handleSessionDoubleClick:d,handleSaveEdit:p,handleCancelEdit:h,handleShareSession:_,handleCopyShareUrl:y,handleUnshareSession:x,handleDeleteSession:O,confirmDeleteSession:A},t[31]=A,t[32]=r,t[33]=h,t[34]=y,t[35]=O,t[36]=p,t[37]=d,t[38]=l,t[39]=_,t[40]=x,t[41]=j):j=t[41],j};function Iv(e){return!e.time?.archived}function Lv(e,t){return t?e:e.filter(Iv)}function Rv(e){return e.id}function zv(e){return e.id}var Bv=[`project:active:`,`project:archived:`,`pinned:active:`,`pinned:archived:`],Vv=e=>{let{isVSCode:t,safeStorage:n,keys:r,groupOrderByProject:i,activeSessionByProject:a,collapsedGroups:o,setExpandedParents:s,setCollapsedProjects:c}=e,l=Q.useRef(null),u=Q.useRef(null),[d,f]=Q.useState(!1),p=Q.useCallback(()=>{if(t)return;let e=u.current;if(u.current=null,l.current=null,!e)return;let{projects:n}=mn.getState(),r=n.map(t=>({...t,sidebarCollapsed:e.has(t.id)}));je({projects:r}).catch(()=>{})},[t]),m=Q.useCallback(e=>{typeof window>`u`||t||(u.current=e,l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>{p()},700))},[t,p]);return Q.useEffect(()=>()=>{typeof window<`u`&&l.current!==null&&window.clearTimeout(l.current),l.current=null,u.current=null},[]),Q.useEffect(()=>{try{let e=n.getItem(r.sessionExpanded);if(e){let t=JSON.parse(e);Array.isArray(t)&&s(new Set(t.filter(e=>typeof e==`string`)))}else{let e=n.getItem(r.sessionExpandedLegacy);if(e){try{let t=JSON.parse(e);if(Array.isArray(t)){let e=new Set;if(t.forEach(t=>{typeof t==`string`&&t.length!==0&&Bv.forEach(n=>e.add(`${n}${t}`))}),e.size>0){s(e);try{n.setItem(r.sessionExpanded,JSON.stringify(Array.from(e)))}catch{}}}}catch{}try{n.removeItem?.(r.sessionExpandedLegacy)}catch{}}}let t=n.getItem(r.projectCollapse);if(t){let e=JSON.parse(t);Array.isArray(e)&&c(new Set(e.filter(e=>typeof e==`string`)))}}catch{}finally{f(!0)}},[r.projectCollapse,r.sessionExpanded,r.sessionExpandedLegacy,n,c,s]),Q.useEffect(()=>{try{let e=Object.fromEntries(i.entries());n.setItem(r.groupOrder,JSON.stringify(e))}catch{}},[i,r.groupOrder,n]),Q.useEffect(()=>{try{let e=Object.fromEntries(a.entries());n.setItem(r.projectActiveSession,JSON.stringify(e))}catch{}},[a,r.projectActiveSession,n]),Q.useEffect(()=>{try{n.setItem(r.groupCollapse,JSON.stringify(Array.from(o)))}catch{}},[o,r.groupCollapse,n]),{scheduleCollapsedProjectsPersist:m,hasRestoredProjectCollapse:d}},Hv=async(e,t,n)=>{if(e.length===0)return[];let r=Math.max(1,Math.min(t,e.length)),i=Array(e.length),a=0,o=async()=>{for(;;){let t=a;if(a+=1,t>=e.length)return;i[t]=await n(e[t])}};return await Promise.all(Array.from({length:r},()=>o())),i},Uv=e=>{let{normalizedProjects:t,activeProjectId:n,gitRepoStatus:r,setProjectRepoStatus:i,setProjectRootBranches:a,enabled:o=!0}=e,{git:s}=St(),c=Eo(e=>e.ensureStatus),l=Q.useMemo(()=>o?t.filter(e=>e.id===n):[],[n,o,t]);Q.useEffect(()=>{if(!o||!s||l.length===0){if(!o)return;i(e=>e.size===0?e:new Map);return}l.forEach(e=>{c(e.normalizedPath,s)})},[l,o,s,c,i]),Q.useEffect(()=>{let e=new Map;l.forEach(t=>{e.set(t.id,r.get(t.normalizedPath)?.isGitRepo??null)}),i(t=>t.size===e.size&&[...e].every(([e,n])=>t.has(e)&&t.get(e)===n)?t:e)},[l,r,i]);let u=Q.useMemo(()=>l.map(e=>{let t=r.get(e.normalizedPath)?.branch??``;return`${e.id}:${t}`}).join(`|`),[l,r]),d=Q.useRef(new Map),f=Q.useRef(new Map);Q.useEffect(()=>{let e=!1,t=setTimeout(()=>{(async()=>{let t=new Set(l.map(e=>e.id));for(let e of d.current.keys())t.has(e)||(d.current.delete(e),f.current.delete(e));let n=Date.now(),i=l.filter(e=>{let t=r.get(e.normalizedPath);if(t?.isGitRepo===!1)return d.current.delete(e.id),f.current.delete(e.id),!1;if(t?.isGitRepo!==!0||t.branch===null)return!1;let i=t.branch.trim(),a=`${e.normalizedPath}\0${i}`,o=d.current.get(e.id);if(o===a){let t=f.current.get(e.id);return t&&(t.at=n),!1}return!(o!==void 0&&n-(f.current.get(e.id)?.at??0)<3e5)});if(i.length===0)return;let o=await Hv(i,2,async e=>{let t=r.get(e.normalizedPath)?.branch?.trim()??``,n=`${e.normalizedPath}\0${t}`,i=await os(e.normalizedPath,t?{knownBranch:t}:void 0).catch(()=>null);return{id:e.id,inputKey:n,branch:i}});if(e)return;let s=o.filter(e=>e.branch);if(s.length===0)return;let c=Date.now();a(e=>{let t=e;return s.forEach(({id:n,branch:r})=>{r&&e.get(n)!==r&&(t===e&&(t=new Map(e)),t.set(n,r))}),t}),s.forEach(({id:e,inputKey:t,branch:n})=>{d.current.set(e,t),n&&f.current.set(e,{branch:n,at:c})})})()},150);return()=>{e=!0,clearTimeout(t)}},[l,u,r,a])},Wv=e=>{let t=(0,du.c)(7),{ownership:n}=e,r;t[0]===n?r=t[1]:(r=e=>n.sessionsByProject.get(e)??[],t[0]=n,t[1]=r);let i=r,a;t[2]===n?a=t[3]:(a=e=>n.archivedSessionsByProject.get(e)??[],t[2]=n,t[3]=a);let o=a,s;return t[4]!==o||t[5]!==i?(s={getSessionsForProject:i,getArchivedSessionsForProject:o},t[4]=o,t[5]=i,t[6]=s):s=t[6],s},Gv=e=>{let t=(0,du.c)(16),{open:n,onOpenChange:r,project:i,onSave:a}=e,o;t[0]!==i?.label||t[1]!==i?.path?(o=i?.label||i?.path.split(/[\\/]/).filter(Boolean).at(-1),t[0]=i?.label,t[1]=i?.path,t[2]=o):o=t[2];let s;t[3]!==a||t[4]!==n||t[5]!==i?(s=n&&i?(0,$.jsx)(Ls,{project:i,onIdentitySave:a,compact:!0}):null,t[3]=a,t[4]=n,t[5]=i,t[6]=s):s=t[6];let c;t[7]===s?c=t[8]:(c=(0,$.jsx)(es,{outerClassName:`max-h-[min(85dvh,44rem)]`,disableHorizontal:!0,children:(0,$.jsx)(`div`,{className:`w-full p-4 sm:p-6`,children:s})}),t[7]=s,t[8]=c);let l;t[9]!==o||t[10]!==c?(l=(0,$.jsx)(Gr,{"aria-label":o,className:`yuri-settings-workspace w-full max-w-xl gap-0 overflow-hidden p-0`,children:c}),t[9]=o,t[10]=c,t[11]=l):l=t[11];let u;return t[12]!==r||t[13]!==n||t[14]!==l?(u=(0,$.jsx)(Jr,{open:n,onOpenChange:r,children:l}),t[12]=r,t[13]=n,t[14]=l,t[15]=u):u=t[15],u};function Kv(e){let t=(0,du.c)(36),{t:n}=Zt(),{hideDirectoryControls:r,isSessionSearchOpen:i,setIsSessionSearchOpen:a,sessionSearchInputRef:o,sessionSearchQuery:s,setSessionSearchQuery:c,hasSessionSearchQuery:l,searchMatchCount:u}=e;if(r||!i)return null;let d;t[0]!==l||t[1]!==u||t[2]!==n?(d=l?(0,$.jsx)(`span`,{children:n(u===1?`sessions.sidebar.header.search.matchCountSingle`:`sessions.sidebar.header.search.matchCountPlural`,{count:u})}):(0,$.jsx)(`span`,{}),t[0]=l,t[1]=u,t[2]=n,t[3]=d):d=t[3];let f;t[4]===n?f=t[5]:(f=n(`sessions.sidebar.header.search.escapeHint`),t[4]=n,t[5]=f);let p;t[6]===f?p=t[7]:(p=(0,$.jsx)(`span`,{children:f}),t[6]=f,t[7]=p);let m;t[8]!==d||t[9]!==p?(m=(0,$.jsxs)(`div`,{className:`mb-1 flex items-center justify-between px-0.5 typography-micro text-muted-foreground/80`,children:[d,p]}),t[8]=d,t[9]=p,t[10]=m):m=t[10];let h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(Z,{name:`search`,className:`pointer-events-none absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),t[11]=h):h=t[11];let g;t[12]===c?g=t[13]:(g=e=>c(e.target.value),t[12]=c,t[13]=g);let _;t[14]===n?_=t[15]:(_=n(`sessions.sidebar.header.search.placeholder`),t[14]=n,t[15]=_);let v;t[16]!==l||t[17]!==a||t[18]!==c?(v=e=>{e.key===`Escape`&&(e.stopPropagation(),l?c(``):a(!1))},t[16]=l,t[17]=a,t[18]=c,t[19]=v):v=t[19];let y;t[20]!==o||t[21]!==s||t[22]!==g||t[23]!==_||t[24]!==v?(y=(0,$.jsx)(`input`,{ref:o,value:s,onChange:g,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:v}),t[20]=o,t[21]=s,t[22]=g,t[23]=_,t[24]=v,t[25]=y):y=t[25];let b;t[26]!==s.length||t[27]!==c||t[28]!==n?(b=s.length>0?(0,$.jsx)(`button`,{type:`button`,onClick:()=>c(``),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:(0,$.jsx)(Z,{name:`close`,className:`h-3.5 w-3.5`})}):null,t[26]=s.length,t[27]=c,t[28]=n,t[29]=b):b=t[29];let x;t[30]!==y||t[31]!==b?(x=(0,$.jsxs)(`div`,{className:`relative`,children:[h,y,b]}),t[30]=y,t[31]=b,t[32]=x):x=t[32];let S;return t[33]!==x||t[34]!==m?(S=(0,$.jsx)(`div`,{className:`select-none flex-shrink-0 px-3 py-1`,children:(0,$.jsxs)(`div`,{className:`pb-1`,children:[m,x]})}),t[33]=x,t[34]=m,t[35]=S):S=t[35],S}function qv(e){let t=(0,du.c)(13),{title:n,accessory:r,isFirst:i,onToggle:a,expanded:o,className:s}=e,c=i!==void 0&&i?`pt-1 pb-1`:`pt-4 pb-1`,l;t[0]!==s||t[1]!==c?(l=X(`group/section flex w-full items-center gap-1 px-2`,c,s),t[0]=s,t[1]=c,t[2]=l):l=t[2];let u;t[3]!==o||t[4]!==a||t[5]!==n?(u=a?(0,$.jsxs)(`button`,{type:`button`,onClick:a,className:`group/toggle flex min-w-0 flex-1 items-center gap-1 rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-expanded":o,children:[(0,$.jsx)(`span`,{className:`typography-micro font-normal tracking-wide text-muted-foreground/80`,children:n}),(0,$.jsx)(Z,{name:o?`arrow-down-s`:`arrow-right-s`,className:`size-3 shrink-0 opacity-0 transition-opacity group-hover/toggle:opacity-100 group-focus-visible/toggle:opacity-100`})]}):(0,$.jsx)(`span`,{className:X(`flex min-w-0 flex-1 items-center gap-1`,`typography-micro font-normal tracking-wide text-muted-foreground/80`),children:n}),t[3]=o,t[4]=a,t[5]=n,t[6]=u):u=t[6];let d;t[7]===r?d=t[8]:(d=r?(0,$.jsx)(`div`,{className:`ml-auto -mr-2 flex shrink-0 items-center`,children:r}):null,t[7]=r,t[8]=d);let f;return t[9]!==l||t[10]!==u||t[11]!==d?(f=(0,$.jsxs)(`div`,{className:l,children:[u,d]}),t[9]=l,t[10]=u,t[11]=d,t[12]=f):f=t[12],f}function Jv(e){let t=(0,du.c)(60),{items:n,reorderEnabled:r,onSessionsReordered:i,inProgressItems:a,renderSessionNode:o,currentSessionId:s,editingId:c,openSidebarMenuKey:l,headerAccessory:u,onVisibleSessionIdsChange:d}=e,f=r!==void 0&&r,p;t[0]===a?p=t[1]:(p=a===void 0?[]:a,t[0]=a,t[1]=p);let m=p,{t:h}=Zt(),[g,_]=Q.useState(!1),v=f&&!c&&n.length>1&&!!i,y;t[2]===n?y=t[3]:(y=n.map(ny),t[2]=n,t[3]=y);let b=y,x;t[4]===b?x=t[5]:(x=new Map(b.map(ty)),t[4]=b,t[5]=x);let S=x,C=ga(ey),w,T;t[6]!==g||t[7]!==m||t[8]!==n||t[9]!==d?(w=()=>{if(g){d?.([]);return}d?.([...n.map($v),...m.map(Qv)])},T=[g,m,n,d],t[6]=g,t[7]=m,t[8]=n,t[9]=d,t[10]=w,t[11]=T):(w=t[10],T=t[11]),Q.useLayoutEffect(w,T);let E,D;t[12]!==m||t[13]!==n||t[14]!==C?(E=()=>{C&&(n.some(e=>e.node.session.id===C)||m.some(e=>e.node.session.id===C))&&_(!1)},D=[m,n,C],t[12]=m,t[13]=n,t[14]=C,t[15]=E,t[16]=D):(E=t[15],D=t[16]),Q.useLayoutEffect(E,D);let O,k,A,j;if(t[17]!==s||t[18]!==c||t[19]!==m||t[20]!==n||t[21]!==l){let e=[...n,...m].map(Zv);A=new Set,rl(e,s,A),j=new Set,rl(e,c,j),O=yl(e,l,`pinned`,!1),k=new WeakMap;let r=e=>{k.set(e,tl(e)),e.children.forEach(r)};e.forEach(r),t[17]=s,t[18]=c,t[19]=m,t[20]=n,t[21]=l,t[22]=O,t[23]=k,t[24]=A,t[25]=j}else O=t[22],k=t[23],A=t[24],j=t[25];let M;t[26]!==O||t[27]!==k||t[28]!==A||t[29]!==j?(M=e=>({subtreeContainsActive:A,subtreeContainsEditing:j,menuOpenSessionId:O,nodeStructureKey:k.get(e)??``,childRenderExtrasFor:M}),t[26]=O,t[27]=k,t[28]=A,t[29]=j,t[30]=M):M=t[30];let N;t[31]!==M||t[32]!==O||t[33]!==k||t[34]!==A||t[35]!==j?(N=e=>({subtreeContainsActive:A,subtreeContainsEditing:j,menuOpenSessionId:O,nodeStructureKey:k.get(e)??``,childRenderExtrasFor:M}),t[31]=M,t[32]=O,t[33]=k,t[34]=A,t[35]=j,t[36]=N):N=t[36];let P=N;if(n.length+m.length===0)return null;let F;t[37]!==P||t[38]!==o?(F=e=>e.map(e=>{let t=e.content??o(e.node,0,e.groupDirectory,e.projectId,!1,e.secondaryMeta,`pinned`,P(e.node));return(0,$.jsx)(Q.Fragment,{children:t},e.identity??e.node.session.id)}),t[37]=P,t[38]=o,t[39]=F):F=t[39];let I=F,L;t[40]!==m.length||t[41]!==h?(L=m.length>0?h(`directoryTree.section.pinnedInProgress`):h(`directoryTree.section.pinned`),t[40]=m.length,t[41]=h,t[42]=L):L=t[42];let R;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>_(Xv),t[43]=R):R=t[43];let z=!g,ee;t[44]!==u||t[45]!==L||t[46]!==z?(ee=(0,$.jsx)(qv,{title:L,onToggle:R,expanded:z,accessory:u}),t[44]=u,t[45]=L,t[46]=z,t[47]=ee):ee=t[47];let B;t[48]!==v||t[49]!==g||t[50]!==S||t[51]!==m||t[52]!==n||t[53]!==i||t[54]!==I||t[55]!==b?(B=g?null:(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[v?(0,$.jsx)(xc,{scopeKey:Zc,sessionIds:b,folderIdBySessionId:S,onSessionDroppedOnFolder:Yv,onSessionsReordered:(e,t)=>i?.(e,t),children:I(n)}):I(n),I(m)]}),t[48]=v,t[49]=g,t[50]=S,t[51]=m,t[52]=n,t[53]=i,t[54]=I,t[55]=b,t[56]=B):B=t[56];let V;return t[57]!==ee||t[58]!==B?(V=(0,$.jsx)(Da,{delay:0,closeDelay:150,timeout:600,children:(0,$.jsxs)(`div`,{className:`pb-1`,children:[ee,B]})}),t[57]=ee,t[58]=B,t[59]=V):V=t[59],V}function Yv(){}function Xv(e){return!e}function Zv(e){return e.node}function Qv(e){return e.node.session.id}function $v(e){return e.node.session.id}function ey(e){return e.focus?.scope===`pinned`?e.focus.sessionId:null}function ty(e){return[e,null]}function ny(e){return e.node.session.id}function ry(e){let t=(0,du.c)(41),{collapseAllProjects:n,expandAllProjects:r,buttonClassName:i,iconClassName:a}=e,{t:o}=Zt(),s;t[0]===i?s=t[1]:(s=X(`size-6 p-0 text-muted-foreground`,i),t[0]=i,t[1]=s);let c;t[2]===o?c=t[3]:(c=o(`sessions.sidebar.header.actions.sessionDisplayMode`),t[2]=o,t[3]=c);let l;t[4]===a?l=t[5]:(l=X(`h-3.5 w-3.5`,a),t[4]=a,t[5]=l);let u;t[6]===l?u=t[7]:(u=(0,$.jsx)(Z,{name:`more-2-fill`,className:l}),t[6]=l,t[7]=u);let d;t[8]!==s||t[9]!==c||t[10]!==u?(d=(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(Ra,{asChild:!0,children:(0,$.jsx)(Y,{variant:`ghost`,size:`xs`,className:s,"aria-label":c,onClick:iy,children:u})})}),t[8]=s,t[9]=c,t[10]=u,t[11]=d):d=t[11];let f;t[12]===o?f=t[13]:(f=o(`sessions.sidebar.header.displayMode.label`),t[12]=o,t[13]=f);let p;t[14]===f?p=t[15]:(p=(0,$.jsx)(Ea,{side:`bottom`,sideOffset:4,children:(0,$.jsx)(`p`,{children:f})}),t[14]=f,t[15]=p);let m;t[16]!==d||t[17]!==p?(m=(0,$.jsxs)(Oa,{children:[d,p]}),t[16]=d,t[17]=p,t[18]=m):m=t[18];let h;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(Z,{name:`contract-up-down`,className:`h-4 w-4`}),t[19]=h):h=t[19];let g;t[20]===o?g=t[21]:(g=o(`sessions.sidebar.header.displayMode.collapseAll`),t[20]=o,t[21]=g);let _;t[22]===g?_=t[23]:(_=(0,$.jsx)(`span`,{children:g}),t[22]=g,t[23]=_);let v;t[24]!==n||t[25]!==_?(v=(0,$.jsxs)(ao,{onClick:n,className:`flex items-center gap-2`,children:[h,_]}),t[24]=n,t[25]=_,t[26]=v):v=t[26];let y;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(Z,{name:`expand-up-down`,className:`h-4 w-4`}),t[27]=y):y=t[27];let b;t[28]===o?b=t[29]:(b=o(`sessions.sidebar.header.displayMode.expandAll`),t[28]=o,t[29]=b);let x;t[30]===b?x=t[31]:(x=(0,$.jsx)(`span`,{children:b}),t[30]=b,t[31]=x);let S;t[32]!==r||t[33]!==x?(S=(0,$.jsxs)(ao,{onClick:r,className:`flex items-center gap-2`,children:[y,x]}),t[32]=r,t[33]=x,t[34]=S):S=t[34];let C;t[35]!==v||t[36]!==S?(C=(0,$.jsxs)(Ia,{align:`end`,className:`min-w-[160px]`,children:[v,S]}),t[35]=v,t[36]=S,t[37]=C):C=t[37];let w;return t[38]!==C||t[39]!==m?(w=(0,$.jsxs)(Na,{children:[m,C]}),t[38]=C,t[39]=m,t[40]=w):w=t[40],w}function iy(e){e.stopPropagation()}var ay=()=>ht({queryKey:[l(),u(),`device-connections`],queryFn:async({signal:e})=>{let t=await h(`/api/client-auth/clients`,{signal:e});if(!t.ok)throw Error(`Device list unavailable`);let n=await t.json();if(!Array.isArray(n.clients))throw Error(`Invalid device list`);if(n.clients.some(e=>typeof e.connected!=`boolean`))throw Error(`Presence unavailable`);return n.clients.filter(e=>!e.revokedAt&&e.connected&&e.clientKind!==`desktop-local`&&e.id!==n.currentClientId)},staleTime:0,retry:!1});function oy(){let e=(0,du.c)(53),{t}=Zt(),{clientAuth:n}=St(),[r,i]=(0,Q.useState)(!1),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=ay(),e[0]=a):a=e[0];let o=r&&!!n,s=r?5e3:!1,c;e[1]!==o||e[2]!==s?(c={...a,enabled:o,refetchInterval:s},e[1]=o,e[2]=s,e[3]=c):c=e[3];let l=gt(c),u;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{i(!1);let e=q.getState();e.setSettingsRemoteInstancesSelectedId(null),e.setSettingsPage(`remote-instances`),q.setState({devicePairingRequested:!0}),e.setSettingsDialogOpen(!0)},e[4]=u):u=e[4];let d=K(u);if(!n)return null;let f;e[5]===t?f=e[6]:(f=t(`settings.remoteInstances.quick.title`),e[5]=t,e[6]=f);let p;e[7]===f?p=e[8]:(p=(0,$.jsx)(Y,{variant:`ghost`,size:`icon`,className:`group size-7 rounded-md text-foreground/55 hover:bg-interactive-hover hover:text-foreground`,"aria-label":f}),e[7]=f,e[8]=p);let m;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(Z,{name:`devices-connected`,className:`size-[18px]`}),e[9]=m):m=e[9];let h;e[10]===p?h=e[11]:(h=(0,$.jsx)(Oe,{openOnHover:!0,delay:180,closeDelay:200,render:p,children:m}),e[10]=p,e[11]=h);let g;e[12]===t?g=e[13]:(g=t(`settings.remoteInstances.quick.title`),e[12]=t,e[13]=g);let _;e[14]===g?_=e[15]:(_=(0,$.jsx)(me,{className:`typography-ui-label font-medium`,children:g}),e[14]=g,e[15]=_);let v;e[16]===l.data?v=e[17]:(v=l.data&&l.data.length>0?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:l.data.length}):null,e[16]=l.data,e[17]=v);let y;e[18]!==_||e[19]!==v?(y=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pb-2 pt-4`,children:[_,v]}),e[18]=_,e[19]=v,e[20]=y):y=e[20];let b;e[21]!==l.isPending||e[22]!==t?(b=l.isPending?(0,$.jsx)(`p`,{className:`px-2 py-3 typography-meta text-muted-foreground`,children:t(`common.loading`)}):null,e[21]=l.isPending,e[22]=t,e[23]=b):b=e[23];let x;e[24]!==l.isError||e[25]!==t?(x=l.isError?(0,$.jsx)(`p`,{className:`px-2 py-3 typography-meta text-muted-foreground`,children:t(`settings.remoteInstances.quick.error`)}):null,e[24]=l.isError,e[25]=t,e[26]=x):x=e[26];let S;e[27]!==l.data?.length||e[28]!==l.isError||e[29]!==t?(S=!l.isError&&l.data?.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center px-5 pb-5 pt-6 text-center`,children:[(0,$.jsx)(Z,{name:`devices-connected`,className:`mb-4 size-16 text-muted-foreground/45`}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:t(`settings.remoteInstances.clientAuth.state.empty`)}),(0,$.jsx)(`p`,{className:`mt-2 typography-meta leading-relaxed text-muted-foreground`,children:t(`settings.remoteInstances.quick.emptyHint`)})]}):null,e[27]=l.data?.length,e[28]=l.isError,e[29]=t,e[30]=S):S=e[30];let C;e[31]!==l.data||e[32]!==t?(C=l.data?.map(e=>{let n=e.devicePlatform?.toLowerCase();return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl px-3 py-2.5`,children:[(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(Z,{name:n===`ios`?`device-ios`:n===`android`?`device-android`:`device-desktop`,className:`size-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`truncate typography-ui-label`,children:e.label}),(0,$.jsx)(`p`,{className:`mt-0.5 truncate typography-micro text-[var(--status-success)]`,children:t(`desktopHostSwitcher.status.connected`)})]})]},e.id)}),e[31]=l.data,e[32]=t,e[33]=C):C=e[33];let w;e[34]!==b||e[35]!==x||e[36]!==S||e[37]!==C?(w=(0,$.jsxs)(`div`,{className:`max-h-64 space-y-2 overflow-y-auto px-3 pb-2`,"aria-live":`polite`,children:[b,x,S,C]}),e[34]=b,e[35]=x,e[36]=S,e[37]=C,e[38]=w):w=e[38];let T;e[39]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Z,{name:`add`,className:`size-4`}),e[39]=T):T=e[39];let E;e[40]===t?E=e[41]:(E=t(`settings.remoteInstances.clientAuth.actions.addDevice`),e[40]=t,e[41]=E);let D;e[42]!==d||e[43]!==E?(D=(0,$.jsx)(`div`,{className:`px-3 pb-3 pt-1`,children:(0,$.jsxs)(Y,{variant:`secondary`,size:`sm`,className:`w-full justify-center gap-2 rounded-xl`,onClick:d,children:[T,E]})}),e[42]=d,e[43]=E,e[44]=D):D=e[44];let O;e[45]!==y||e[46]!==w||e[47]!==D?(O=(0,$.jsx)(ye,{children:(0,$.jsx)(ge,{side:`top`,align:`start`,sideOffset:10,className:`z-50`,children:(0,$.jsxs)(he,{className:`yuri-mobile-overlay-surface yuri-popup-surface w-72 max-w-[calc(100vw-24px)] origin-[var(--transform-origin)] overflow-hidden rounded-2xl outline-none transition-[opacity,transform] duration-150 data-[starting-style]:translate-y-1 data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`,children:[y,w,D]})})}),e[45]=y,e[46]=w,e[47]=D,e[48]=O):O=e[48];let k;return e[49]!==r||e[50]!==O||e[51]!==h?(k=(0,$.jsxs)(fe,{open:r,onOpenChange:i,children:[h,O]}),e[49]=r,e[50]=O,e[51]=h,e[52]=k):k=e[52],k}function sy(e){let t=(0,du.c)(11),{task:n}=e,r=n.total>0?Math.min(99,Math.floor(Math.max(0,n.completed)/n.total*100)):void 0,i=`inline-flex size-4 shrink-0 ${n.failed?`text-[var(--status-error)]`:``}`,a=`size-full -rotate-90 ${r===void 0&&!n.failed?`motion-safe:animate-spin`:``}`,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`circle`,{cx:`9`,cy:`9`,r:`7.5`,stroke:`currentColor`,strokeOpacity:`0.2`,strokeWidth:`1.5`}),t[0]=o):o=t[0];let s=100-(r??22),c;t[1]===s?c=t[2]:(c=(0,$.jsx)(`circle`,{cx:`9`,cy:`9`,r:`7.5`,pathLength:`100`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeDasharray:`100`,strokeDashoffset:s,className:`motion-safe:transition-[stroke-dashoffset] motion-safe:duration-300`}),t[1]=s,t[2]=c);let l;t[3]!==a||t[4]!==c?(l=(0,$.jsxs)(`svg`,{viewBox:`0 0 18 18`,fill:`none`,"aria-hidden":`true`,className:a,children:[o,c]}),t[3]=a,t[4]=c,t[5]=l):l=t[5];let u;return t[6]!==i||t[7]!==l||t[8]!==n.detail||t[9]!==r?(u=(0,$.jsx)(`span`,{role:`progressbar`,"aria-label":n.detail,"aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,className:i,children:l}),t[6]=i,t[7]=l,t[8]=n.detail,t[9]=r,t[10]=u):u=t[10],u}function cy({task:e}){let{t,locale:n}=Zt(),[r,i]=Q.useState(!1),a=Q.useRef(!1),o=mt({mutationFn:async t=>{try{await(t===`dismiss`?e.dismiss?.():e.resume?.())}finally{a.current=!1}},onError:(t,n)=>{n===`resume`&&e.dismiss&&i(!0)},retry:!1}),s=e=>new Intl.NumberFormat(n).format(e),c=e=>new Intl.NumberFormat(n,{minimumFractionDigits:1,maximumFractionDigits:1}).format(e/1e6),l=e.total>0?Math.min(100,Math.max(0,e.completed/e.total*100)):void 0;return(0,$.jsxs)(`div`,{className:`grid grid-cols-[1rem_minmax(0,1fr)_auto] items-center gap-x-2.5 gap-y-2 py-2.5`,"data-background-task":e.id,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:(0,$.jsx)(sy,{task:e})}),(0,$.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label`,children:e.label}),e.detail!==e.label&&(0,$.jsx)(`span`,{className:`break-words typography-micro text-muted-foreground`,children:e.detail})]}),(0,$.jsx)(`div`,{role:`progressbar`,"aria-label":e.detail,"aria-valuenow":l,"aria-valuemin":0,"aria-valuemax":100,className:`my-1.5 h-1 overflow-hidden rounded-full bg-[var(--surface-subtle)]`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full ${e.failed?`bg-[var(--status-error)]`:`bg-[var(--primary-base)]`} ${l===void 0?e.failed?`w-1/3`:`w-1/3 motion-safe:animate-pulse`:`motion-safe:transition-[width] motion-safe:duration-300`}`,style:l===void 0?void 0:{width:`${l}%`}})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 typography-micro tabular-nums text-muted-foreground`,"data-background-task-meta":!0,children:[e.bytes?(0,$.jsx)(`span`,{children:t(e.total>0?`backgroundTasks.downloaded`:`backgroundTasks.downloadedUnknownTotal`,{completed:c(e.completed),total:c(e.total)})}):e.total>0&&!e.hideCounts&&(0,$.jsx)(`span`,{"aria-label":t(`backgroundTasks.processed`,{completed:s(e.completed),total:s(e.total)}),children:`${s(e.completed)} / ${s(e.total)}`}),!!e.failures&&(0,$.jsx)(`span`,{className:`text-[var(--status-error)]`,children:t(`backgroundTasks.failedCount`,{count:s(e.failures)})})]})]}),e.failed&&e.resume&&(0,$.jsx)(Y,{size:`xs`,className:`shrink-0`,disabled:o.isPending,onClick:()=>{a.current||(a.current=!0,o.mutate(r?`dismiss`:`resume`))},children:t(r?o.isPending?`backgroundTasks.removing`:`backgroundTasks.dismiss`:o.isPending?`backgroundTasks.resuming`:`backgroundTasks.resume`)}),e.stale&&(0,$.jsx)(`p`,{className:`col-span-2 col-start-2 typography-micro text-muted-foreground`,children:t(`backgroundTasks.progressUnavailable`)}),o.isError&&(0,$.jsx)(`p`,{role:`alert`,className:`col-span-2 col-start-2 typography-micro text-[var(--status-error)]`,children:t(o.variables===`dismiss`?`backgroundTasks.dismissFailed`:o.error.message===`update_plan_changed`?`backgroundTasks.updateChanged`:o.error.message===`resume_request_missing`?`backgroundTasks.originalSelectionMissing`:`backgroundTasks.resumeFailed`)})]})}var ly=Q.memo(function(e){let t=(0,du.c)(4),{compactWithRestart:n}=e,r=n!==void 0&&n,i=Q.useSyncExternalStore(s,u,u),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=l(),t[0]=a):a=t[0];let o=`${a}:${i}`,c;return t[1]!==r||t[2]!==o?(c=(0,$.jsx)(uy,{compactWithRestart:r},o),t[1]=r,t[2]=o,t[3]=c):c=t[3],c});function uy(e){let t=(0,du.c)(126),{compactWithRestart:n}=e,{t:r,locale:i}=Zt(),[a,o]=Q.useState(!1),s=As(Dy),c=As(Ey),d=As(Ty),f=As(wy),p=As(Cy),m=As(Sy),h=As(xy),g=l(),_=u(),v=gt({...ql(g),retry:!1,refetchInterval:yy}),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y={...Uc(),retry:!1,refetchInterval:vy},t[0]=y):y=t[0];let b=gt(y),x=Ss(g,_),C;t[1]===x?C=t[2]:(C={...x,refetchInterval:_y},t[1]=x,t[2]=C);let w=gt(C),T;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(T=new Set,t[3]=T):T=t[3];let E=Q.useRef(T),D,O;t[4]!==_||t[5]!==v.data||t[6]!==v.isError||t[7]!==g?(D=()=>{if(!v.data||v.isError)return;let e=new Set(v.data.filter(gy).map(hy)),t=[...E.current].some(t=>!e.has(t));E.current=e,t&&g===l()&&_===u()&&Nn(g).catch(my)},O=[v.data,v.isError,g,_],t[4]=_,t[5]=v.data,t[6]=v.isError,t[7]=g,t[8]=D,t[9]=O):(D=t[8],O=t[9]),Q.useEffect(D,O);let k;if(t[10]!==m||t[11]!==d||t[12]!==h||t[13]!==f||t[14]!==c||t[15]!==s||t[16]!==_||t[17]!==b||t[18]!==v.data||t[19]!==v.isError||t[20]!==r||t[21]!==g||t[22]!==w||t[23]!==p){k=[];for(let e of v.data??[])if(!Wl(e)){let t=Jl(e);k.push({id:e.id,label:r(`backgroundTasks.import`),detail:r(e.state===`running`?`historyImport.phase.${t.phase}`:`historyImport.state.${e.state}`),...t,stale:v.isError,failed:e.state!==`running`,failures:e.failures,resume:()=>Gl(e.id,g,_),dismiss:()=>Kl(e.id,g,_)})}if(b.data&&b.data.phase!==`ready`){let e;t[25]===r?e=t[26]:(e=r(`backgroundTasks.index`),t[25]=r,t[26]=e);let n;t[27]===b.data.phase?n=t[28]:(n=[`partial`,`error`].includes(b.data.phase)?`backgroundTasks.indexFailed`:`backgroundTasks.indexing`,t[27]=b.data.phase,t[28]=n);let i;t[29]!==r||t[30]!==n?(i=r(n),t[29]=r,t[30]=n,t[31]=i):i=t[31];let a=b.data.completed,o=b.data.total,s=b.isError,c;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(c=[`partial`,`error`],t[32]=c):c=t[32];let l=c.includes(b.data.phase),u;t[33]!==_||t[34]!==g?(u=()=>Gc(g,_),t[33]=_,t[34]=g,t[35]=u):u=t[35];let d;t[36]!==b.data.completed||t[37]!==b.data.failed||t[38]!==b.data.total||t[39]!==b.isError||t[40]!==l||t[41]!==u||t[42]!==e||t[43]!==i?(d={id:`content-index`,label:e,detail:i,completed:a,total:o,stale:s,failed:l,failures:b.data.failed,resume:u},t[36]=b.data.completed,t[37]=b.data.failed,t[38]=b.data.total,t[39]=b.isError,t[40]=l,t[41]=u,t[42]=e,t[43]=i,t[44]=d):d=t[44],k.push(d)}if(s||d){let e;t[45]===r?e=t[46]:(e=r(`backgroundTasks.download`),t[45]=r,t[46]=e);let n=d?`backgroundTasks.downloadFailed`:`updateDialog.status.downloading`,i;t[47]!==r||t[48]!==n?(i=r(n),t[47]=r,t[48]=n,t[49]=i):i=t[49];let a=!!d,o;t[50]!==m||t[51]!==h||t[52]!==a||t[53]!==e||t[54]!==i?(o={id:`client-update`,label:e,detail:i,completed:m,total:h,stale:!1,bytes:!0,failed:a,resume:py},t[50]=m,t[51]=h,t[52]=a,t[53]=e,t[54]=i,t[55]=o):o=t[55],k.push(o)}let e=w.data?.operation,n=w.data,i=e?.status===`failed`&&!!n&&!n.checkError&&n.update!==void 0&&n.channel===e.channel&&(n.update?.version!==e.version||n.update.kind!==e.kind);if(e&&!i&&(Ws(e)||e.status===`failed`)&&!((s||d||c&&Ws(e))&&e.version===(f??p)&&S())){let n=e.id,i;t[56]===r?i=t[57]:(i=r(`backgroundTasks.download`),t[56]=r,t[57]=i);let a=e.status===`failed`?`backgroundTasks.downloadFailed`:e.status===`installing`?`updateDialog.status.installingUpdate`:e.status===`restarting`?`updateDialog.status.serverRestarting`:e.status===`checking`?`updateDialog.status.updating`:`updateDialog.status.downloading`,o;t[58]!==r||t[59]!==a?(o=r(a),t[58]=r,t[59]=a,t[60]=o):o=t[60];let s=`${o} · ${e.version}`,c=e.progress??0,l=e.progress==null?0:100,u=e.status===`failed`,d;t[61]!==_||t[62]!==e||t[63]!==g?(d=()=>xs(e,g,_),t[61]=_,t[62]=e,t[63]=g,t[64]=d):d=t[64];let f;t[65]!==e.id||t[66]!==s||t[67]!==c||t[68]!==l||t[69]!==u||t[70]!==d||t[71]!==i||t[72]!==w.isError?(f={id:n,label:i,detail:s,completed:c,total:l,stale:w.isError,hideCounts:!0,failed:u,resume:d},t[65]=e.id,t[66]=s,t[67]=c,t[68]=l,t[69]=u,t[70]=d,t[71]=i,t[72]=w.isError,t[73]=f):f=t[73],k.push(f)}t[10]=m,t[11]=d,t[12]=h,t[13]=f,t[14]=c,t[15]=s,t[16]=_,t[17]=b,t[18]=v.data,t[19]=v.isError,t[20]=r,t[21]=g,t[22]=w,t[23]=p,t[24]=k}else k=t[24];if(!k.length&&!a)return null;let A;t[74]===i?A=t[75]:(A=e=>new Intl.NumberFormat(i).format(e),t[74]=i,t[75]=A);let j=A,M=`w-fit min-w-0 shrink text-muted-foreground/60 ${k.length?``:`invisible`}`,N=k.length?``:void 0,P=n&&c&&k.length===1?`icon`:`xs`,F;t[76]===r?F=t[77]:(F=r(`backgroundTasks.title`),t[76]=r,t[77]=F);let I;t[78]!==n||t[79]!==c||t[80]!==r||t[81]!==k[0]||t[82]!==k.length?(I=n&&c?k.length===1?k[0].label:r(`backgroundTasks.title`):void 0,t[78]=n,t[79]=c,t[80]=r,t[81]=k[0],t[82]=k.length,t[83]=I):I=t[83];let L=`max-w-full gap-2 text-[10px] font-normal text-muted-foreground/60 ${n&&c&&k.length===1?`size-7 rounded-md`:``}`,R;t[84]!==P||t[85]!==F||t[86]!==I||t[87]!==L?(R=(0,$.jsx)(Y,{variant:`ghost`,size:P,"aria-label":F,title:I,className:L}),t[84]=P,t[85]=F,t[86]=I,t[87]=L,t[88]=R):R=t[88];let z;t[89]===k?z=t[90]:(z=k.map(fy),t[89]=k,t[90]=z);let ee;t[91]!==n||t[92]!==c||t[93]!==k[0]||t[94]!==k.length?(ee=k.length===1&&!(n&&c)&&(0,$.jsx)(`span`,{className:`truncate`,children:k[0].label}),t[91]=n,t[92]=c,t[93]=k[0],t[94]=k.length,t[95]=ee):ee=t[95];let B;t[96]!==R||t[97]!==z||t[98]!==ee?(B=(0,$.jsxs)(Oe,{render:R,children:[z,ee]}),t[96]=R,t[97]=z,t[98]=ee,t[99]=B):B=t[99];let V;t[100]!==B||t[101]!==M||t[102]!==N?(V=(0,$.jsx)(`div`,{className:M,"data-sidebar-background-tasks":N,children:B}),t[100]=B,t[101]=M,t[102]=N,t[103]=V):V=t[103];let te;t[104]===r?te=t[105]:(te=r(`backgroundTasks.title`),t[104]=r,t[105]=te);let ne;t[106]===te?ne=t[107]:(ne=(0,$.jsx)(me,{className:`typography-micro font-medium text-muted-foreground`,children:te}),t[106]=te,t[107]=ne);let re;t[108]!==j||t[109]!==k.length?(re=k.length>0&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:j(k.length)}),t[108]=j,t[109]=k.length,t[110]=re):re=t[110];let ie;t[111]!==ne||t[112]!==re?(ie=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pb-1 pt-3`,children:[ne,re]}),t[111]=ne,t[112]=re,t[113]=ie):ie=t[113];let ae;t[114]!==r||t[115]!==k?(ae=k.length?k.map(dy):(0,$.jsx)(`p`,{className:`px-2 py-3 typography-meta text-muted-foreground`,children:r(`backgroundTasks.empty`)}),t[114]=r,t[115]=k,t[116]=ae):ae=t[116];let oe;t[117]===ae?oe=t[118]:(oe=(0,$.jsx)(`div`,{className:`max-h-64 divide-y-[length:var(--yuri-popup-divider-width)] divide-[var(--yuri-popup-divider)] overflow-y-auto px-3 pb-1`,"data-background-task-details":!0,children:ae}),t[117]=ae,t[118]=oe);let H;t[119]!==ie||t[120]!==oe?(H=(0,$.jsx)(ye,{children:(0,$.jsx)(ge,{side:`top`,align:`center`,sideOffset:10,className:`z-50`,children:(0,$.jsxs)(he,{initialFocus:!1,className:`yuri-mobile-overlay-surface yuri-popup-surface w-72 max-w-[calc(100vw-24px)] origin-[var(--transform-origin)] overflow-hidden rounded-2xl outline-none transition-[opacity,transform] duration-150 data-[starting-style]:translate-y-1 data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`,children:[ie,oe]})})}),t[119]=ie,t[120]=oe,t[121]=H):H=t[121];let se;return t[122]!==a||t[123]!==V||t[124]!==H?(se=(0,$.jsxs)(fe,{open:a,onOpenChange:o,children:[V,H]}),t[122]=a,t[123]=V,t[124]=H,t[125]=se):se=t[125],se}function dy(e){return(0,$.jsx)(cy,{task:e},e.id)}function fy(e){return(0,$.jsx)(sy,{task:e},e.id)}async function py(){if(await As.getState().downloadUpdate({resume:!0}),As.getState().downloadError)throw Error(As.getState().downloadError)}function my(){}function hy(e){return e.id}function gy(e){return e.state===`running`}function _y(e){return Ws(e.state.data?.operation)?2e3:e.state.error?.message!==`host_update_unsupported`&&15e3}function vy(e){return e.state.data===null?!1:e.state.data?.phase===`indexing`||e.state.data?.phase===`pending`?3e3:15e3}function yy(e){return e.state.error?.message===`history_import_unsupported`?!1:e.state.data?.some(by)?1e3:15e3}function by(e){return e.state===`running`}function xy(e){return e.progress?.total??0}function Sy(e){return e.progress?.downloaded??0}function Cy(e){return e.info?.version}function wy(e){return e.downloadVersion}function Ty(e){return e.downloadError}function Ey(e){return e.downloaded}function Dy(e){return e.downloading}var Oy=`group size-7 rounded-md text-muted-foreground/75 transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:ring-2 focus-visible:ring-primary`,ky=`size-4 text-foreground/55 transition-colors group-hover:text-foreground group-focus-visible:text-foreground`;function Ay(e){let t=(0,du.c)(32),{onOpenUpdate:n,hideDownload:r}=e,{t:i}=Zt(),a=As(Fy),o=As(Py),s=As(Ny),c=As(My),l=As(jy),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=[`update`,`restart-to-apply`],t[0]=u):u=t[0];let d;t[1]===c?d=t[2]:(d={mutationKey:u,mutationFn:()=>c(),retry:!1,networkMode:`always`},t[1]=c,t[2]=d);let f=mt(d),p=f.isPending,m=Q.useRef(!1),h;t[3]!==o||t[4]!==n||t[5]!==f||t[6]!==p?(h=()=>{if(o&&!p){if(m.current)return;m.current=!0,f.mutate();return}n()},t[3]=o,t[4]=n,t[5]=f,t[6]=p,t[7]=h):h=t[7];let g=K(h),_;t[8]!==o||t[9]!==a||t[10]!==s||t[11]!==p||t[12]!==i?(_=s||i(a?`updateDialog.status.downloading`:p?`updateDialog.status.updating`:o?`sessions.sidebar.footer.actions.restartUpdate`:`sessions.sidebar.footer.actions.update`),t[8]=o,t[9]=a,t[10]=s,t[11]=p,t[12]=i,t[13]=_):_=t[13];let v=_;if(r&&a)return null;let y=p||void 0,b;t[14]!==o||t[15]!==a||t[16]!==l||t[17]!==p||t[18]!==v?(b=o?(0,$.jsx)(Z,{name:`restart`,className:`${ky} ${p?`motion-safe:animate-spin`:``}`}):a?(0,$.jsxs)(`svg`,{viewBox:`0 0 18 18`,className:l===null?`size-4 animate-spin`:`size-4 -rotate-90`,role:`progressbar`,"aria-label":v,"aria-valuenow":l??void 0,"aria-valuemin":0,"aria-valuemax":100,children:[(0,$.jsx)(`circle`,{cx:`9`,cy:`9`,r:`7.5`,fill:`none`,stroke:`currentColor`,strokeOpacity:`0.25`,strokeWidth:`2`}),(0,$.jsx)(`circle`,{cx:`9`,cy:`9`,r:`7.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,pathLength:`100`,strokeDasharray:`100`,strokeDashoffset:100-(l===null?25:Math.max(0,Math.min(100,l))),className:`transition-[stroke-dashoffset] duration-300`})]}):(0,$.jsx)(Z,{name:`download`,className:ky}),t[14]=o,t[15]=a,t[16]=l,t[17]=p,t[18]=v,t[19]=b):b=t[19];let x;t[20]!==g||t[21]!==p||t[22]!==y||t[23]!==b||t[24]!==v?(x=(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,className:`${Oy} disabled:opacity-100`,onClick:g,disabled:p,"aria-busy":y,"aria-label":v,children:b})}),t[20]=g,t[21]=p,t[22]=y,t[23]=b,t[24]=v,t[25]=x):x=t[25];let S=a&&l!==null?` ${l}%`:``,C;t[26]!==S||t[27]!==v?(C=(0,$.jsx)(Ea,{side:`top`,sideOffset:4,children:(0,$.jsxs)(`p`,{children:[v,S]})}),t[26]=S,t[27]=v,t[28]=C):C=t[28];let w;return t[29]!==x||t[30]!==C?(w=(0,$.jsxs)(Oa,{children:[x,C]}),t[29]=x,t[30]=C,t[31]=w):w=t[31],w}function jy(e){return e.progress?.total?Math.round(e.progress.downloaded/e.progress.total*100):null}function My(e){return e.restartToUpdate}function Ny(e){return e.error}function Py(e){return e.downloaded}function Fy(e){return e.downloading}function Iy(e){let t=(0,du.c)(19),{onOpenSettings:n,onOpenShortcuts:r,onOpenUpdate:i,showRuntimeButtons:a,showUpdateButton:o}=e,s=a===void 0||a,c=o!==void 0&&o,{t:l}=Zt(),u;t[0]!==n||t[1]!==r||t[2]!==s||t[3]!==l?(u=s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,className:Oy,onClick:n,"aria-label":l(`sessions.sidebar.footer.actions.settings`),children:(0,$.jsx)(Z,{name:`settings-3`,className:ky})})}),(0,$.jsx)(Ea,{side:`top`,sideOffset:4,children:l(`sessions.sidebar.footer.actions.settings`)})]}),(0,$.jsx)(oy,{}),(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,className:Oy,onClick:r,"aria-label":l(`sessions.sidebar.footer.actions.shortcuts`),children:(0,$.jsx)(Z,{name:`question`,className:ky})})}),(0,$.jsx)(Ea,{side:`top`,sideOffset:4,children:l(`sessions.sidebar.footer.actions.shortcuts`)})]})]}):null,t[0]=n,t[1]=r,t[2]=s,t[3]=l,t[4]=u):u=t[4];let d;t[5]!==i||t[6]!==s||t[7]!==c?(d=s?(0,$.jsx)(ly,{compactWithRestart:!!(c&&i)}):null,t[5]=i,t[6]=s,t[7]=c,t[8]=d):d=t[8];let f;t[9]!==i||t[10]!==s||t[11]!==c?(f=c&&i?(0,$.jsx)(Ay,{onOpenUpdate:i,hideDownload:s}):null,t[9]=i,t[10]=s,t[11]=c,t[12]=f):f=t[12];let p;t[13]!==d||t[14]!==f?(p=(0,$.jsxs)(`div`,{className:`ml-auto flex min-w-0 items-center gap-1`,children:[d,f]}),t[13]=d,t[14]=f,t[15]=p):p=t[15];let m;return t[16]!==u||t[17]!==p?(m=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-start gap-1 px-2.5 py-2`,children:[u,p]}),t[16]=u,t[17]=p,t[18]=m):m=t[18],m}var Ly=1/3,Ry=1,zy=({containerScrollTop:e,containerClientHeight:t,containerScrollHeight:n,rowOffsetFromViewportTop:r})=>{let i=e+(r-t*Ly),a=Math.max(0,n-t);return Math.min(a,Math.max(0,i))},By=()=>typeof window>`u`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`,Vy=e=>{let t=e.closest(`.overlay-scrollbar-target`);if(t)return t;let n=e.parentElement;for(;n&&n!==document.body;){let e=window.getComputedStyle(n).overflowY;if(e===`auto`||e===`scroll`||e===`overlay`)return n;n=n.parentElement}return null},Hy=(e,t)=>{let n=Vy(e),r=t?.behavior??By();if(!n){e.scrollIntoView({block:`nearest`,inline:`nearest`,behavior:r});return}let i=e.getBoundingClientRect(),a=n.getBoundingClientRect().top+n.clientTop,o=a+n.clientHeight;if(i.top>=a&&i.bottom<=o)return;let s=zy({containerScrollTop:n.scrollTop,containerClientHeight:n.clientHeight,containerScrollHeight:n.scrollHeight,rowOffsetFromViewportTop:i.top-a});Math.abs(s-n.scrollTop)<Ry||n.scrollTo({top:s,behavior:r})},Uy={activationConstraint:{distance:8}},Wy={coordinateGetter:Xo},Gy=e=>{let t=(0,du.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(Da,{delay:0,closeDelay:150,timeout:600,children:n}),t[0]=n,t[1]=r),r};function Ky(e){let{t}=Zt(),n=new Map((e.remoteProjects??[]).map(e=>[e.id,e])),r=(e.remoteProjects??[]).map(e=>({project:{id:e.id,hostId:e.hostId,normalizedPath:e.path},groups:[]})),i=[...e.sectionsForRender,...r];if(e.projectOrderIds?.length){let t=new Map(e.projectOrderIds.map((e,t)=>[e,t]));i.sort((e,n)=>(t.get(e.project.id)??1/0)-(t.get(n.project.id)??1/0))}let a=r=>{let i=n.get(r);return i?e.hostRegistry?(0,$.jsx)(Xc,{project:i,registry:e.hostRegistry,search:e.remoteSearch,mobile:e.mobileVariant,reorderEnabled:e.projectReorderEnabled,onNavigationTargets:e.onRemoteNavigationTargets,onActivityItems:e.onRemoteActivityItems},r):(0,$.jsxs)(`div`,{className:`px-2 py-1 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`span`,{children:[i.label||i.path,` · `,i.hostId]}),(0,$.jsx)(`p`,{role:e.remoteError?`alert`:`status`,children:e.remoteError||t(kr()?`remoteProjects.state.connecting`:`remoteProjects.unsupported`)})]},r):null},o=Yo(Uo(qo,Uy),Uo(Wo,Wy)),s=e.hasSessionSearchQuery?null:(0,$.jsx)(qv,{title:t(`sessions.sidebar.projectsTitle`),isFirst:!e.hasLeadingSection,accessory:e.headerAccessory}),c=Q.useRef(null),l=Q.useRef(null);Q.useLayoutEffect(()=>{let t=e.projectRevealTarget;if(!t){l.current=null;return}if(e.mobileVariant||e.showOnlyMainWorkspace||e.hasSessionSearchQuery)return;let n=l.current;if(n?.projectId===t.projectId&&n.revision===t.revision)return;let r=c.current?.querySelector(`[data-sidebar-project-header="${CSS.escape(t.projectId)}"]`);r&&(l.current=t,Hy(r))},[e.projectRevealTarget,e.mobileVariant,e.showOnlyMainWorkspace,e.hasSessionSearchQuery,e.sectionsForRender]);let u=Q.useRef(new Map),d=Q.useRef(e.getOrderedGroups);d.current!==e.getOrderedGroups&&(d.current=e.getOrderedGroups,u.current.clear());let f=(t,n)=>{let r=u.current,i=r.get(t);if(i&&i.groups===n)return i.ordered;let a=e.getOrderedGroups(t,n);if(r.set(t,{groups:n,ordered:a}),r.size>256){let e=r.keys().next().value;e!==void 0&&r.delete(e)}return a};return e.sharedSessionsOnly?(0,$.jsx)(Gy,{children:(0,$.jsxs)(es,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:`flex-1 min-h-0`,className:X(`space-y-1 px-3 pb-1`,(e.mobileVariant,``)),children:[e.topContent,e.hasSharedSessions?null:e.hasSessionSearchQuery?e.searchEmptyState:e.emptyState]})}):e.projectSections.length===0&&r.length===0?(0,$.jsx)(Gy,{children:(0,$.jsxs)(es,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:`flex-1 min-h-0`,className:X(`space-y-1 px-3 pb-1`,(e.mobileVariant,``)),children:[e.topContent,s,e.emptyState]})}):i.length===0?(0,$.jsx)(Gy,{children:(0,$.jsx)(es,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:`flex-1 min-h-0`,className:X(`space-y-1 px-3 pb-1`,(e.mobileVariant,``)),children:e.searchEmptyState})}):(0,$.jsx)(Gy,{children:(0,$.jsxs)(es,{ref:c,useScrollShadow:!0,scrollShadowSize:96,outerClassName:`flex-1 min-h-0`,className:X(`space-y-1 px-3 pb-1 [overflow-anchor:none]`,(e.mobileVariant,``)),children:[e.topContent,e.showOnlyMainWorkspace?(0,$.jsx)(`div`,{className:`space-y-[0.6rem] py-1`,children:(()=>{let r=i.find(t=>t.project.id===e.activeProjectId)??i[0];if(!r)return e.hasSessionSearchQuery?e.searchEmptyState:e.emptyState;if(n.has(r.project.id))return a(r.project.id);let o=r.groups.find(e=>e.isMain&&e.sessions.length>0)??r.groups.find(e=>e.sessions.length>0)??r.groups.find(e=>e.isMain)??r.groups[0];if(!o)return(0,$.jsx)(`div`,{className:co,children:t(`sessions.sidebar.empty.noSessions.title`)});let s=r.groups.find(e=>e.isArchivedBucket);return[o,...s&&s.id!==o.id?[s]:[]].map(t=>{let n=`${r.project.id}:${t.id}`,i=t.id===o.id;return(0,$.jsx)(Q.Fragment,{children:e.renderGroupSessions(t,n,r.project.id,i,null,!0,c)},n)})})()}):(0,$.jsxs)($.Fragment,{children:[s,(0,$.jsxs)(Jo,{sensors:o,collisionDetection:Go,onDragEnd:t=>{if(e.isInlineEditing||e.projectSortOrder!==`manual`)return;let{active:n,over:r}=t;!r||n.id===r.id||e.reorderProjects(String(n.id),String(r.id))},children:[(0,$.jsx)($o,{items:i.map(e=>e.project.id),strategy:Qo,children:i.map(t=>{let r=t.project,i=r.id;return n.has(i)?a(i):(0,$.jsx)(qy,{project:r,orderedGroups:f(i,t.groups),isCollapsed:e.collapsedProjects.has(i),isActiveProject:i===e.activeProjectId,isRepo:!!e.projectRepoStatus.get(i),hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:e.alwaysShowActions,toggleProject:e.toggleProject,setActiveProjectIdOnly:e.setActiveProjectIdOnly,setActiveMainTab:e.setActiveMainTab,setSessionSwitcherOpen:e.setSessionSwitcherOpen,openNewSessionDraft:e.openNewSessionDraft,openNewWorktreeDialog:e.openNewWorktreeDialog,syncProjectSessions:e.syncProjectSessions,openProjectEditDialog:e.openProjectEditDialog,removeProject:e.removeProject,openSidebarMenuKey:e.openSidebarMenuKey===`project:${i}`?e.openSidebarMenuKey:null,setOpenSidebarMenuKey:e.setOpenSidebarMenuKey,projectReorderEnabled:e.projectReorderEnabled,projectSortOrder:e.projectSortOrder,isInlineEditing:e.isInlineEditing,setGroupOrderByProject:e.setGroupOrderByProject,renderGroupSessions:e.renderGroupSessions,scrollContainerRef:c,homeDirectory:e.homeDirectory,hostRegistry:e.hostRegistry},i)})}),(0,$.jsx)(Ko,{dropAnimation:null})]})]})]})})}var qy=Q.memo(function(e){let t=(0,du.c)(111),{t:n}=Zt(),{project:r,orderedGroups:i,isCollapsed:a,renderGroupSessions:o,scrollContainerRef:s,isInlineEditing:c}=e,l=r.id,u;t[0]===r.normalizedPath?u=t[1]:(u=e=>w()?void 0:e.availableWorktreesByProject.get(r.normalizedPath),t[0]=r.normalizedPath,t[1]=u);let d=cr(u),f;t[2]!==r.normalizedPath||t[3]!==d?(f=[r.normalizedPath,...(d??[]).flatMap(Jy)],t[2]=r.normalizedPath,t[3]=d,t[4]=f):f=t[4];let p=f,m;t[5]===p?m=t[6]:(m=e=>p.some(t=>e.loadingDirectories.has(t)),t[5]=p,t[6]=m);let h=wr(m),g;t[7]===p?g=t[8]:(g=e=>p.some(t=>e.refreshingDirectories.has(t)),t[7]=p,t[8]=g);let _=wr(g),v=Yo(Uo(qo,Uy)),y;t[9]===i?y=t[10]:(y=i.find(Yy)??null,t[9]=i,t[10]=y);let b=y,x;t[11]!==i||t[12]!==b?(x=b?i.filter(e=>e.id!==b.id):i,t[11]=i,t[12]=b,t[13]=x):x=t[13];let S=x,C;t[14]!==l||t[15]!==e?(C=()=>e.toggleProject(l),t[14]=l,t[15]=e,t[16]=C):C=t[16];let T=K(C),E;t[17]!==r.normalizedPath||t[18]!==l||t[19]!==e?(E=()=>{e.isActiveProject||e.setActiveProjectIdOnly(l),e.setActiveMainTab(`chat`),e.mobileVariant&&e.setSessionSwitcherOpen(!1),e.openNewSessionDraft({directoryOverride:r.normalizedPath})},t[17]=r.normalizedPath,t[18]=l,t[19]=e,t[20]=E):E=t[20];let D=K(E),O;t[21]!==l||t[22]!==e?(O=()=>{e.isActiveProject||e.setActiveProjectIdOnly(l),e.setActiveMainTab(`chat`),e.openNewWorktreeDialog()},t[21]=l,t[22]=e,t[23]=O):O=t[23];let k=K(O),A;t[24]!==l||t[25]!==e?(A=()=>e.syncProjectSessions(l),t[24]=l,t[25]=e,t[26]=A):A=t[26];let j=K(A),M;t[27]!==l||t[28]!==e?(M=()=>e.openProjectEditDialog(l),t[27]=l,t[28]=e,t[29]=M):M=t[29];let N=K(M),P;t[30]!==l||t[31]!==e?(P=()=>e.removeProject(l),t[30]=l,t[31]=e,t[32]=P):P=t[32];let F=K(P),I;t[33]!==c||t[34]!==S||t[35]!==r.normalizedPath||t[36]!==l||t[37]!==e||t[38]!==b?(I=t=>{if(c)return;let{active:n,over:i}=t;if(!i||n.id===i.id)return;let a=S.findIndex(e=>e.id===n.id),o=S.findIndex(e=>e.id===i.id);if(a===-1||o===-1||a===o)return;let s=Zo(S,a,o).map(Xy),u=b?[b.id,...s]:s,d=new Map(S.map(Zy));bn.getState().setWorktreeOrder(l,r.normalizedPath,s.flatMap(e=>{let t=d.get(e);return t?.worktree&&t.directory?[t.directory]:[]})),e.setGroupOrderByProject(e=>new Map(e).set(l,u))},t[33]=c,t[34]=S,t[35]=r.normalizedPath,t[36]=l,t[37]=e,t[38]=b,t[39]=I):I=t[39];let L=K(I),R;t[40]!==l||t[41]!==o||t[42]!==b||t[43]!==s?(R=b?o(b,`${l}:${b.id}`,l,!0,null,void 0,s):null,t[40]=l,t[41]=o,t[42]=b,t[43]=s,t[44]=R):R=t[44];let z;t[45]===S?z=t[46]:(z=S.map(Qy),t[45]=S,t[46]=z);let ee;if(t[47]!==c||t[48]!==S||t[49]!==l||t[50]!==o||t[51]!==s){let e;t[53]!==c||t[54]!==l||t[55]!==o||t[56]!==s?(e=e=>(0,$.jsx)(ol,{id:e.id,disabled:c,children:t=>o(e,`${l}:${e.id}`,l,!1,t,void 0,s)},e.id),t[53]=c,t[54]=l,t[55]=o,t[56]=s,t[57]=e):e=t[57],ee=S.map(e),t[47]=c,t[48]=S,t[49]=l,t[50]=o,t[51]=s,t[52]=ee}else ee=t[52];let B;t[58]!==z||t[59]!==ee?(B=(0,$.jsx)($o,{items:z,strategy:Qo,children:ee}),t[58]=z,t[59]=ee,t[60]=B):B=t[60];let V;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(Ko,{dropAnimation:null}),t[61]=V):V=t[61];let te;t[62]!==v||t[63]!==L||t[64]!==R||t[65]!==B?(te=(0,$.jsxs)(Jo,{sensors:v,collisionDetection:Go,onDragEnd:L,children:[R,B,V]}),t[62]=v,t[63]=L,t[64]=R,t[65]=B,t[66]=te):te=t[66];let ne=te,re=e.projectSortOrder!==`manual`,ie=r.hostId,ae=r.remoteState,oe=e.hostRegistry,H;t[67]===r.normalizedPath?H=t[68]:(H=Er(r.normalizedPath)||r.normalizedPath,t[67]=r.normalizedPath,t[68]=H);let se;t[69]!==r.normalizedPath||t[70]!==e.homeDirectory?(se=an(r.normalizedPath,e.homeDirectory),t[69]=r.normalizedPath,t[70]=e.homeDirectory,t[71]=se):se=t[71];let U=h||_,ce=e.projectReorderEnabled??!1,W=!a,le=a||void 0,ue;t[72]!==ne||t[73]!==h||t[74]!==i.length||t[75]!==n?(ue=(0,$.jsx)(`div`,{className:`space-y-0 pt-0 pb-0.5`,children:i.length>0?ne:h?(0,$.jsx)(`div`,{className:`box-border w-full py-1.5 text-left typography-ui-label font-normal text-muted-foreground/80 animate-pulse select-none`,style:{paddingLeft:lo(1)},role:`status`,"aria-live":`polite`,children:n(`sessions.sidebar.project.loadingSessions`)}):(0,$.jsx)(`div`,{className:co,children:n(`sessions.sidebar.empty.noSessions.title`)})}),t[72]=ne,t[73]=h,t[74]=i.length,t[75]=n,t[76]=ue):ue=t[76];let de;t[77]!==le||t[78]!==ue?(de=(0,$.jsx)(Ll,{"data-sidebar-collapse":!0,className:`h-[var(--collapsible-panel-height)] transition-[height] duration-200 ease-out data-[starting-style]:h-0 data-[ending-style]:h-0 data-[open]:animate-none data-[closed]:animate-none motion-reduce:transition-none`,inert:le,children:ue}),t[77]=le,t[78]=ue,t[79]=de):de=t[79];let fe;t[80]!==W||t[81]!==de?(fe=(0,$.jsx)(zl,{open:W,children:de}),t[80]=W,t[81]=de,t[82]=fe):fe=t[82];let pe;return t[83]!==a||t[84]!==F||t[85]!==D||t[86]!==k||t[87]!==N||t[88]!==j||t[89]!==T||t[90]!==r.color||t[91]!==r.hostId||t[92]!==r.icon||t[93]!==r.iconImage||t[94]!==r.remoteState||t[95]!==l||t[96]!==e.alwaysShowActions||t[97]!==e.hideDirectoryControls||t[98]!==e.hostRegistry||t[99]!==e.isActiveProject||t[100]!==e.isRepo||t[101]!==e.mobileVariant||t[102]!==e.openSidebarMenuKey||t[103]!==e.setOpenSidebarMenuKey||t[104]!==re||t[105]!==H||t[106]!==se||t[107]!==U||t[108]!==ce||t[109]!==fe?(pe=(0,$.jsx)(Cc,{id:l,disabled:re,hostId:ie,remoteState:ae,hostRegistry:oe,projectLabel:H,projectDescription:se,projectIcon:r.icon,projectColor:r.color,projectIconImage:r.iconImage,isCollapsed:a,isActiveProject:e.isActiveProject,isSessionsLoading:U,isRepo:e.isRepo,hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:e.alwaysShowActions,onToggle:T,onNewSession:D,onNewWorktreeSession:k,onSyncSessions:j,onRenameStart:N,onClose:F,showCreateButtons:!0,openSidebarMenuKey:e.openSidebarMenuKey,setOpenSidebarMenuKey:e.setOpenSidebarMenuKey,reorderEnabled:ce,children:fe}),t[83]=a,t[84]=F,t[85]=D,t[86]=k,t[87]=N,t[88]=j,t[89]=T,t[90]=r.color,t[91]=r.hostId,t[92]=r.icon,t[93]=r.iconImage,t[94]=r.remoteState,t[95]=l,t[96]=e.alwaysShowActions,t[97]=e.hideDirectoryControls,t[98]=e.hostRegistry,t[99]=e.isActiveProject,t[100]=e.isRepo,t[101]=e.mobileVariant,t[102]=e.openSidebarMenuKey,t[103]=e.setOpenSidebarMenuKey,t[104]=re,t[105]=H,t[106]=se,t[107]=U,t[108]=ce,t[109]=fe,t[110]=pe):pe=t[110],pe});function Jy(e){let t=M(e.path);return t?[t]:[]}function Yy(e){return e.isMain}function Xy(e){return e.id}function Zy(e){return[e.id,e]}function Qy(e){return e.id}function $y(e){if(typeof e!=`number`||!Number.isFinite(e))return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:`${t.toLocaleString(Yt(),{month:`short`})} ${t.getDate()}, ${t.getFullYear()}, ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function eb(e){if(e.info.role===`user`)return``;let t=typeof e.info.providerID==`string`?e.info.providerID.trim():``,n=typeof e.info.modelID==`string`?e.info.modelID.trim():``;return t&&n?`${t}/${n}`:n||t}function tb(e){let t=e.info.role===`user`?`User`:`Assistant`,n=$y(e.info.time?.created),r=eb(e),i=n&&r?`${n} (${r})`:n||r;return i?`**${t}**\n\n*${i}*`:`**${t}**`}function nb(e){return e.filter(e=>e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(``)}function rb(e){let t=tb(e),n=nb(e.parts).trim();return n?`${t}\n\n${n}`:``}function ib(e,t){let n=`#`.repeat(Math.min(t+1,6)),r=e.agent?` — ${e.agent}`:``,i=[`${n} Sub-agent: ${e.title}${r}\n\n---\n\n`+e.records.map(rb).filter(Boolean).join(`
|
|
147
147
|
|
|
148
148
|
---
|
|
149
149
|
|
|
@@ -166,4 +166,4 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,p as r,t
|
|
|
166
166
|
`+e}return r}function ob(e,t){let n=new Blob([e],{type:`text/markdown;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}async function sb(e,t){let n=await g(t,e);if(n)return n;if(!w())return null;try{let n=await ae()?.vscode?.saveMarkdown?.({fileName:t,content:e});if(!n||n.saved!==!0)return null;let r=typeof n.path==`string`?n.path.trim():``;return r.length>0?r:null}catch{return null}}async function cb(e){let t=ae()?.files;if(t?.revealPath)try{return!!(await t.revealPath(e))?.success}catch{return!1}return await C(e)?!0:E(e)}function lb(){return hn()}function ub(e){return`${(e?.trim()||`session`).normalize(`NFKC`).toLowerCase().replace(/[^\p{L}\p{N}]+/gu,`-`).replace(/^-+|-+$/g,``).slice(0,60)||`session`}-${new Date().toISOString().split(`T`)[0]}.md`}var db=(e,t)=>{if(!t)return Array.from(e);let n=[],r=new Set;for(let i of e){r.has(i)||(r.add(i),n.push(i));let e=t.get(i);if(e)for(let t of e)r.has(t)||(r.add(t),n.push(t))}return n},fb=W()((e,t)=>({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null,enable:()=>{t().enabled||e({enabled:!0})},disable:()=>{e({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null})},toggleMode:()=>{t().enabled?e({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null}):e({enabled:!0})},toggleSelected:(n,r,i)=>{let a=t(),o=new Set(a.selectedIds),s=a.scopeKey,c=a.anchorId;r!==null&&a.scopeKey!==null&&r!==a.scopeKey?(o.clear(),s=r,c=null):s===null&&r!==null&&(s=r);let l=i&&i.length>0?[n,...i]:[n];if(o.has(n)){for(let e of l)o.delete(e);c===n&&(c=null)}else{for(let e of l)o.add(e);c=n}o.size===0?e({selectedIds:o,scopeKey:null,anchorId:null}):e({selectedIds:o,scopeKey:s,anchorId:c})},setRange:(n,r,i,a,o)=>{let s=t();if(i.length===0)return;let c=n&&i.includes(n)?n:i[0],l=i.indexOf(c),u=i.indexOf(r);if(l<0||u<0)return;let[d,f]=l<=u?[l,u]:[u,l],p=db(i.slice(d,f+1),o),m=a!==null&&s.scopeKey!==null&&a!==s.scopeKey?new Set:new Set(s.selectedIds);for(let e of p)m.add(e);e({selectedIds:m,scopeKey:a??s.scopeKey,anchorId:c})},replaceAll:(t,n)=>{if(t.length===0){e({selectedIds:new Set,scopeKey:null,anchorId:null});return}e({selectedIds:new Set(t),scopeKey:n,anchorId:t[0]??null})},clear:()=>{e({selectedIds:new Set,scopeKey:null,anchorId:null})},removeMany:n=>{let r=t();if(r.selectedIds.size===0||n.length===0)return;let i=new Set(r.selectedIds);for(let e of n)i.delete(e);i.size!==r.selectedIds.size&&(i.size===0?e({selectedIds:i,scopeKey:null,anchorId:null}):e({selectedIds:i}))}})),pb=!1,mb=new Set,hb=!1;function gb(){for(let e of mb)e()}function _b(e){pb!==e&&(pb=e,gb())}function vb(e){e.key===`Shift`&&_b(!0)}function yb(e){e.key===`Shift`&&_b(!1)}function bb(){_b(!1)}function xb(){hb||typeof window>`u`||(hb=!0,window.addEventListener(`keydown`,vb),window.addEventListener(`keyup`,yb),window.addEventListener(`blur`,bb))}function Sb(e){return xb(),mb.add(e),()=>{mb.delete(e)}}function Cb(){return pb}function wb(){return!1}function Tb(){return(0,Q.useSyncExternalStore)(Sb,Cb,wb)}var Eb=!1,Db=!1,Ob=new Set;function kb(){Ob.forEach(e=>e())}function Ab(e){Eb!==e&&(Eb=e,kb())}function jb(e){return Fn()?e.key===`Meta`:e.key===`Control`}var Mb=(({setVisible:e,schedule:t=(e,t)=>setTimeout(e,t),cancel:n=e=>clearTimeout(e)})=>{let r=!1,i=null,a=()=>{i!==null&&(n(i),i=null)};return{press(){r||(r=!0,a(),i=t(()=>{i=null,r&&e(!0)},500))},release(){r=!1,a(),e(!1)}}})({setVisible:Ab});function Nb(e){jb(e)&&Mb.press()}function Pb(){Mb.release()}function Fb(e){jb(e)&&Pb()}function Ib(){document.visibilityState!==`visible`&&Pb()}function Lb(){Db||typeof window>`u`||(Db=!0,window.addEventListener(`keydown`,Nb),window.addEventListener(`keyup`,Fb),window.addEventListener(`blur`,Pb),document.addEventListener(`visibilitychange`,Ib))}function Rb(e){return Lb(),Ob.add(e),()=>Ob.delete(e)}function zb(){return Eb}function Bb(){return!1}function Vb(){return(0,Q.useSyncExternalStore)(Rb,zb,Bb)}var Hb=(e,t,n)=>{let r=e.session.title?.trim()||e.session.id;return`\n\n--- RESULT ${n+1}: ${r} ---\n${t.trim()}\n--- END RESULT ${n+1} ---`},Ub=(e,t)=>cr.getState().getWorktreeMetadata(e)?.projectDirectory??t,Wb=e=>e.type===`assistant`?Sa(e.content??[]).trim():``,Gb=async e=>{let t=e.directory??void 0,n=Qe(e.session.id,t);if(n.length===0&&e.directory){let t=await et.withDirectory(e.directory,()=>et.getSdkClient().message.list({sessionID:e.session.id,limit:50})),n=Array.isArray(t.data)?t.data:[];for(let e=n.length-1;e>=0;--e){let t=Wb(n[e]);if(t)return t}return``}for(let e=n.length-1;e>=0;--e){let r=n[e];if(r.role===`assistant`)return Sa(Ze(r.id,t)).trim()}return``};function Kb({session:e,open:t,onOpenChange:n}){let{t:r}=Zt(),i=wn(),a=wr(e=>e.activeSessions),o=wr(e=>e.archivedSessions),s=Ln(e=>e.providers),c=Ln(e=>e.currentProviderId),l=Ln(e=>e.currentModelId),u=Ln(e=>e.currentAgentName),[d,f]=Q.useState(c??``),[p,m]=Q.useState(l??``),[h,g]=Q.useState(()=>c&&l?[{providerID:c,modelID:l,instanceId:Zl()}]:[]),[_,v]=Q.useState(``),[y,b]=Q.useState(u??``),[x,S]=Q.useState([]),[C,w]=Q.useState(!1),T=Q.useMemo(()=>$l(e.title),[e.title]),E=Q.useMemo(()=>{let t=new Map;for(let e of i)t.set(e.id,e);for(let e of a)t.set(e.id,e);for(let e of o)t.set(e.id,e);return e.id&&t.set(e.id,e),Array.from(t.values())},[a,o,i,e]);Q.useEffect(()=>{if(!t||!T)return;let n=cr.getState().getDirectoryForSession(e.id),r=Ub(e.id,n),i=E.map(e=>{let t=$l(e.title);if(!t||t.groupSlug!==T.groupSlug||t.fusion||(t.runGroup??null)!==(T.runGroup??null))return null;let n=cr.getState().getDirectoryForSession(e.id)??Xn(e),i=Ub(e.id,n);return r&&i&&r!==i?null:{session:e,directory:n,projectDirectory:i}}).filter(e=>e!==null).sort((e,t)=>(e.session.time?.created??0)-(t.session.time?.created??0));S(i)},[E,t,T,e.id]);let D=s.find(e=>e.id===d)?.models.find(e=>e.id===p),O=D?.variants?Object.keys(D.variants):[],k=!!(T&&d&&p&&x.length>0&&!C),A=Q.useCallback(e=>{g([e]),f(e.providerID),m(e.modelID),v(``)},[]),j=h[0]?.displayName||h[0]?.modelID||r(`multirun.fusion.model.placeholder`);return(0,$.jsx)(Jr,{open:t,onOpenChange:n,children:(0,$.jsxs)(Gr,{className:`max-w-xl overflow-visible`,children:[(0,$.jsxs)(Ur,{children:[(0,$.jsx)(Kr,{children:r(`multirun.fusion.title`)}),(0,$.jsx)(qr,{children:r(`multirun.fusion.description`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`max-w-full`,children:(0,$.jsx)(eu,{selectedModels:h,onAdd:A,onUpdate:(e,t)=>A(t),onRemove:()=>{g([]),f(``),m(``),v(``)},maxModels:1,addButtonLabel:j,showChips:!1,addButtonClassName:`h-8 w-fit max-w-[min(28rem,calc(100vw-8rem))] justify-start rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] px-3 py-1.5`,dropdownSide:`bottom`,dropdownClassName:`w-[min(28rem,calc(100vw-8rem))]`,triggerIcon:d||p?(0,$.jsx)(jo,{modelId:p,providerId:d,className:`h-3.5 w-3.5 mr-1`}):void 0})}),O.length>0?(0,$.jsxs)(Io,{value:_||`__default__`,onValueChange:e=>v(e===`__default__`?``:e),children:[(0,$.jsxs)(Fo,{size:`lg`,className:`h-8 w-fit rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] !border-border/80 !bg-[var(--surface-subtle)] hover:!bg-[var(--interactive-hover)]/70 typography-meta font-medium text-foreground px-3 py-1.5`,children:[(0,$.jsx)(Z,{name:`brain-ai-3`,className:`h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(Ao,{children:e=>e===`__default__`?r(`multirun.modelMultiSelect.variant.default`):e})]}),(0,$.jsxs)(Po,{fitContent:!0,portalToBody:!0,children:[(0,$.jsx)(Mo,{value:`__default__`,children:r(`multirun.modelMultiSelect.variant.default`)}),O.map(e=>(0,$.jsx)(Mo,{value:e,children:e},e))]})]}):null,(0,$.jsx)(Ql,{value:y,onChange:b,portalToBody:!0,className:`h-8 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] px-3 py-1.5`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`typography-meta font-medium text-foreground`,children:r(`multirun.fusion.sources.label`,{count:x.length})}),(0,$.jsx)(`div`,{className:`max-h-56 space-y-1 overflow-auto rounded-lg border border-[var(--interactive-border)] p-1`,children:x.map(e=>{let t=$l(e.session.title);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md px-2 py-1.5 typography-meta`,children:[(0,$.jsx)(jo,{modelId:t?.modelID,providerId:t?.providerID,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.session.title||e.session.id}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>S(t=>t.filter(t=>t.session.id!==e.session.id)),className:`text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(Z,{name:`close`,className:`h-4 w-4`})})]},e.session.id)})})]}),(0,$.jsxs)(Wr,{children:[(0,$.jsx)(Y,{variant:`ghost`,onClick:()=>n(!1),children:r(`multirun.fusion.actions.cancel`)}),(0,$.jsx)(Y,{onClick:async()=>{if(!(!T||!d||!p)){w(!0);try{let e=await Promise.all(x.map(e=>Gb(e))),t=x.map((t,n)=>({source:t,text:e[n]??``})).filter(e=>e.text.trim().length>0);if(t.length===0){J.error(r(`multirun.fusion.toast.noOutputs`));return}let i=x[0]?.projectDirectory??x[0]?.directory??null,a=Xl(T.groupSlug,d,p,T.runGroup),[o,s]=await Promise.all([Yr(`session.fusion.visible`),Yr(`session.fusion.instructions`)]),c=await cr.getState().createSession(a,i,null);if(!c)throw Error(`Failed to create fusion session`);cr.getState().setCurrentSession(c.id,i),n(!1),await et.sendMessage({id:c.id,providerID:d,modelID:p,variant:_||void 0,agent:y||void 0,text:o,additionalParts:[{text:s,synthetic:!0},...t.map((e,t)=>({text:Hb(e.source,e.text,t),synthetic:!0})),{text:`
|
|
167
167
|
|
|
168
168
|
--- FUSION INPUTS END ---
|
|
169
|
-
Now write the final fused answer.`,synthetic:!0}],directory:i??et.getDirectory()})}catch(e){console.error(`[MultiRunFusion] Failed to start fusion`,e),J.error(r(`multirun.fusion.toast.failed`))}finally{w(!1)}}},disabled:!k,children:r(C?`multirun.fusion.actions.starting`:`multirun.fusion.actions.start`)})]})]})})}function qb(e){let t=(0,du.c)(13),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=[`yuri-icon`,n].filter(Boolean),t[3]=n,t[4]=i);let a=i.join(` `),o,s,c,l,u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`path`,{d:`M12 4.5v6.25M12 10.75v3.5M12 10.75H7.25A3.25 3.25 0 0 0 4 14v1.25M12 10.75h4.75A3.25 3.25 0 0 1 20 14v1.25`}),s=(0,$.jsx)(`path`,{d:`M9.25 7.25 12 4.5l2.75 2.75`}),c=(0,$.jsx)(`circle`,{cx:`4`,cy:`17.25`,r:`1.55`}),l=(0,$.jsx)(`circle`,{cx:`12`,cy:`17.25`,r:`1.55`}),u=(0,$.jsx)(`circle`,{cx:`20`,cy:`17.25`,r:`1.55`}),t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u):(o=t[5],s=t[6],c=t[7],l=t[8],u=t[9]);let d;return t[10]!==r||t[11]!==a?(d=(0,$.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:Hr,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:a,...r,children:[o,s,c,l,u]}),t[10]=r,t[11]=a,t[12]=d):d=t[12],d}var Jb=e(we(),1),Yb=null,Xb=!1,Zb=(e,t=ga.getState().focus)=>e===null?null:typeof e==`string`?t?.sessionId===e?t:qi(e):e,Qb=e=>{typeof window>`u`||(e.commitFrame!==null&&window.cancelAnimationFrame(e.commitFrame),e.paintFrame!==null&&window.cancelAnimationFrame(e.paintFrame),e.fallbackTimer!==null&&window.clearTimeout(e.fallbackTimer))},$b=()=>{Yb&&=(Qb(Yb),null)},ex=(e,t)=>{$b(),nr(!0);let n=Zb(e);if(!n)return;Xb=!0;let r;try{r=It(n.sessionId)}finally{Xb=!1}Yb={commit:t,commitFrame:null,fallbackTimer:null,focus:n,intent:r,paintFrame:null,scheduled:!1},(0,Jb.flushSync)(()=>{ga.getState().setFocus(n)}),typeof window<`u`&&(Yb.fallbackTimer=window.setTimeout(()=>{tx(n)},150))},tx=e=>{let t=Yb,n=Zb(e);if(!t||!Ii(t.focus,n)||t.scheduled)return;t.scheduled=!0,typeof window<`u`&&t.fallbackTimer!==null&&(window.clearTimeout(t.fallbackTimer),t.fallbackTimer=null);let r=()=>{Yb===t&&Ft()===t.intent&&(Yb=null,Yn(),t.commit())};if(typeof window>`u`){r();return}t.commitFrame=window.requestAnimationFrame(()=>{Yb===t&&Ft()===t.intent&&(t.paintFrame=window.requestAnimationFrame(r))})},nx=e=>{if(Yb)return;let t=ga.getState();t.setFocus(Zb(e,t.focus))};Lt(e=>{if(Xb)return;let t=Yb;if(t?.intent===e)return;t&&$b();let n=ga.getState();n.setFocus(Zb(e.sessionId,n.focus))});var rx=e=>{let t=[],n=e=>{e.children.forEach(e=>{t.push(e.session.id),n(e)})};return n(e),t},ix=Q.memo(function(e){let t=(0,du.c)(21),{pinned:n,pinLabel:r,buttonSizeClass:i,iconSizeClass:a,onPointerDown:o,onMouseDown:s,onPin:c}=e,l=n?`text-foreground`:`text-muted-foreground`,u;t[0]!==i||t[1]!==l?(u=X(`inline-flex items-center justify-center rounded-md hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,l,i),t[0]=i,t[1]=l,t[2]=u):u=t[2];let d=n?`pushpin-2-fill`:`pushpin-2`,f=!n&&`rotate-45`,p;t[3]!==a||t[4]!==f?(p=X(a,f),t[3]=a,t[4]=f,t[5]=p):p=t[5];let m;t[6]!==d||t[7]!==p?(m=(0,$.jsx)(Z,{name:d,className:p}),t[6]=d,t[7]=p,t[8]=m):m=t[8];let h;t[9]!==s||t[10]!==c||t[11]!==o||t[12]!==r||t[13]!==u||t[14]!==m?(h=(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:u,"aria-label":r,onPointerDown:o,onMouseDown:s,onClick:c,onKeyDown:_x,children:m})}),t[9]=s,t[10]=c,t[11]=o,t[12]=r,t[13]=u,t[14]=m,t[15]=h):h=t[15];let g;t[16]===r?g=t[17]:(g=(0,$.jsx)(Ea,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:r}),t[16]=r,t[17]=g);let _;return t[18]!==h||t[19]!==g?(_=(0,$.jsxs)(Oa,{children:[h,g]}),t[18]=h,t[19]=g,t[20]=_):_=t[20],_}),ax=Q.memo(function(e){let t=(0,du.c)(24),{archiveLabel:n,deleteLabel:r,deleteOnly:i,buttonSizeClass:a,iconSizeClass:o,revealClassName:s,onPointerDown:c,onMouseDown:l,onArchive:u,onDelete:d}=e,f=i!==void 0&&i,p=Tb(),m=f||p,h=m?r:n,g;t[0]!==f||t[1]!==u||t[2]!==d||t[3]!==p?(g=e=>{if(f||p||e.shiftKey){d(e);return}u(e)},t[0]=f,t[1]=u,t[2]=d,t[3]=p,t[4]=g):g=t[4];let _=g,v=m?`text-destructive hover:text-destructive hover:bg-[color-mix(in_srgb,var(--status-error)_12%,transparent)]`:`text-muted-foreground hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,y;t[5]!==a||t[6]!==s||t[7]!==v?(y=X(`inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,v,a,s),t[5]=a,t[6]=s,t[7]=v,t[8]=y):y=t[8];let b=m?`delete-bin`:`inbox-archive`,x;t[9]!==o||t[10]!==b?(x=(0,$.jsx)(Z,{name:b,className:o}),t[9]=o,t[10]=b,t[11]=x):x=t[11];let S;t[12]!==_||t[13]!==h||t[14]!==l||t[15]!==c||t[16]!==y||t[17]!==x?(S=(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:y,"aria-label":h,onPointerDown:c,onMouseDown:l,onClick:_,onKeyDown:vx,children:x})}),t[12]=_,t[13]=h,t[14]=l,t[15]=c,t[16]=y,t[17]=x,t[18]=S):S=t[18];let C;t[19]===h?C=t[20]:(C=(0,$.jsx)(Ea,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:h}),t[19]=h,t[20]=C);let w;return t[21]!==S||t[22]!==C?(w=(0,$.jsxs)(Oa,{children:[S,C]}),t[21]=S,t[22]=C,t[23]=w):w=t[23],w}),ox=Q.memo(function(e){let t=(0,du.c)(3),{number:n}=e;if(!Vb())return null;let r=Fn()?`⌘${n}`:`Ctrl+${n}`,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(bi,{"data-sidebar-shortcut-number":n,variant:`hint`,"aria-hidden":`true`,children:r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i});function sx(e){let{t:n}=Zt(),{node:r,depth:i=0,groupDirectory:a,projectId:o,archivedBucket:s=!1,pinnedSessionIds:c,expandedParents:l,hasSessionSearchQuery:u,normalizedSessionSearchQuery:d,editingId:f,setEditingId:p,editTitle:h,setEditTitle:g,handleSaveEdit:_,handleCancelEdit:v,toggleParent:y,handleSessionSelect:b,togglePinnedSession:x,handleShareSession:S,copiedSessionId:C,handleCopyShareUrl:T,handleUnshareSession:E,setOpenSidebarMenuKey:D,renamingFolderId:O,getFoldersForScope:k,getSessionFolderId:A,removeSessionFromFolder:j,addSessionToFolder:N,createFolderAndStartRename:F,handleDeleteSession:I,mobileVariant:L,alwaysShowActions:z,renderSessionNode:ee,secondaryMeta:B,renderContext:V=`project`,subtreeContainsActive:te,subtreeContainsEditing:ne,menuOpenSessionId:re,childRenderExtrasFor:ie,liveSessionById:ae,shortcutNumber:oe=null}=e,H=!!B?.projectLabel,se=!!B?.branchLabel,U=br(e=>e.displayMode),ce=Q.useMemo(()=>w(),[]),W=U===`minimal`||ce,le=Q.useMemo(()=>R(),[]),ue=Q.useContext(vt),fe=ce?`group-hover:opacity-100 group-hover:pointer-events-auto`:`group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto`,me=ce,he=V===`pinned`&&c.has(r.session.id),ge=!he&&!s&&!L,ye=`h-5 w-5`,we=`h-3.5 w-3.5`,Ee=(ge||he?1:0)+ +!!me+1,De=Ee>=3?`group-hover:pr-18 group-focus-within:pr-18`:Ee>=2?`group-hover:pr-12 group-focus-within:pr-12`:`group-hover:pr-7 group-focus-within:pr-7`,Oe=Ee>=2?`pr-12`:`pr-8`,ke=Q.useRef(!1),Ae=Q.useRef(!1),[je,Me]=Q.useState(!1),Ne=Q.useRef(f);Ne.current=f;let Pe=Q.useRef(null),[Fe,Ie]=Q.useState(h),[Le,Re]=Q.useState(f===r.session.id),G=Q.useRef(null),ze=Q.useRef(null),Be=Q.useRef(null),Ve=r.session,He=ae.get(Ve.id)??Ve,Ue=!!He.metadata?.yuri?.assistant,Ge=M(Ve.directory??null)??M(a??null),Ke=kn(Ge??void 0,{bootstrap:!1}),qe=_i(),Je=fb(e=>e.enabled),Ye=fb(Q.useMemo(()=>e=>e.selectedIds.has(Ve.id),[Ve.id])),Ze=fb(e=>e.toggleSelected),Qe=fb(e=>e.setRange),[et,tt]=Q.useState(!1),[nt,rt]=Q.useState(!0),[at,ot]=Q.useState(!1),[st,ct]=Q.useState(!1),lt=`${V}:${s?`archived`:`active`}:${Ve.id}`,ut=Tn(Q.useMemo(()=>e=>!!e.sessionMemoryState.get(on(Ve.id))?.isZombie,[Ve.id])),dt=qn(Ve.id),ft=Jn(Ve.id,Ge??void 0,{bootstrap:!1}),pt=ur(Ve.id,Ge??void 0,{bootstrap:!1}),mt=Q.useMemo(()=>({scope:V,sessionId:Ve.id,projectId:o??null}),[o,V,Ve.id]),ht=Q.useMemo(()=>Gi(mt)??``,[mt]),gt=Q.useRef(null),_t=ga(Q.useMemo(()=>e=>Ii(e.focus,mt),[mt]));Q.useLayoutEffect(()=>{if(!_t)return;let e=gt.current;e&&(L?e.scrollIntoView({block:`nearest`,inline:`nearest`}):Hy(e)),tx(mt)},[_t,L,mt]);let yt=He.title||n(`sessions.sidebar.session.untitled`),bt=fs(ds(He)),xt=He.metadata?.yuri?.titleRefresh,St=typeof xt?.lastError==`string`?xt.lastError:null,Ct=typeof xt?.failedAt==`number`?xt.failedAt:null;Q.useEffect(()=>{!St||Ct===null||console.warn(`[session-title] generation failed for ${Ve.id}: ${St}`)},[Ve.id,St,Ct]);let wt=typeof xt?.generationExpiresAt==`number`&&Number.isFinite(xt.generationExpiresAt)?xt.generationExpiresAt:0,[Tt,Et]=Q.useState(0),Dt=Q.useMemo(()=>Math.max(0,wt-Date.now()),[wt]),[,Ot,kt]=Mt(()=>Et(wt),Dt,{immediate:!1}),At=xt?.isGenerating===!0;Q.useEffect(()=>(At&&wt>Date.now()&&Ot(),kt),[At,wt,Ot,kt]);let jt=r.children.length>0||!!(He.hasChildren??Ve.hasChildren),Nt=c.has(Ve.id),Pt=lt,Ft=u?!0:l.has(Pt),It=!!He.parentID,Lt=V===`pinned`,q=tr(Ve.id),Rt=q>0&&!It,zt=In(He)||Date.now(),Bt=Ya(zt),Vt=Xa(zt),[Ht,Ut]=Q.useState(!1),Wt=Ht,Gt=Q.useMemo(()=>$l(He.title)!==null,[He.title]),[Kt,qt]=Q.useState(!1),Jt=Q.useMemo(()=>rx(r).length,[r]),Yt=K(e=>{let t=Ge??``,n=(Xe()??$e(t,Ke)).getTranscript(it(t,e)),r=Ke.getState().session.find(t=>t.id===e)?.revert?.messageID;return er({sessionID:e,messages:We(n),parts:n.partsByMessageID,revertMessageID:r}).list}),Xt=K(async e=>{let t=[],r=0;for(let i of e)try{await qe.ensureSessionRenderable(i.session.id);let e=Yt(i.session.id),a=i.session.title||n(`sessions.sidebar.session.export.untitledSubagent`),o=i.session.agent,s=await Xt(i.children);r+=s.skipped,t.push({title:a,agent:o,records:e,children:s.children})}catch{r+=rx(i).length+1}return{children:t,skipped:r}}),Qt=K(e=>{e<=0||J.warning(n(e===1?`sessions.sidebar.session.export.skippedSubtaskSingle`:`sessions.sidebar.session.export.skippedSubtaskMany`,{count:e}))}),$t=K(async e=>{if(!Ge){J.error(n(`sessions.sidebar.session.export.nothingToExport`));return}await qe.ensureSessionRenderable(Ve.id);let t=Yt(Ve.id);if(t.length===0){J.error(n(`sessions.sidebar.session.export.nothingToExport`));return}let i,a=0;if(e&&r.children.length>0){let e=await Xt(r.children);i=e.children,a=e.skipped}let o=ab(t,He.title??null,i),s=ub(He.title??null),c=await sb(o,s);if(c){J.success(n(`sessions.sidebar.session.export.success`),{action:{label:n(lb()),onClick:()=>{cb(c).then(e=>{e||J.error(n(`sessions.sidebar.session.export.failedRevealPath`))})}}}),Qt(a);return}ob(o,s),J.success(n(`sessions.sidebar.session.export.success`)),Qt(a)}),en=K(async()=>{if(r.children.length>0){rt(!0),tt(!0);return}await $t(!1)}),tn=K(()=>{Ge&&P(`desktop_open_session_mini_chat_window`,{sessionId:Ve.id,directory:Ge,apiBaseUrl:m(),clientToken:t()}).catch(e=>{console.warn(`[session-sidebar] failed to open mini chat window`,e)})});Q.useLayoutEffect(()=>{if(f!==Ve.id){Le&&Re(!1),G.current===Ve.id&&(G.current=null);return}!Le||G.current===Ve.id||(G.current=Ve.id,Ie(h),queueMicrotask(()=>Be.current?.select()))},[f,h,Ve.id,Le]);let nn=K(e=>{if(!e&&Pe.current){let{id:e,title:t}=Pe.current;Pe.current=null,Re(!0),p(e),g(t)}}),rn=K(e=>{Ut(e)}),an=K(e=>{e.preventDefault(),e.stopPropagation()}),cn=K(e=>{e.preventDefault(),e.stopPropagation()}),ln=K(e=>{e.preventDefault(),e.stopPropagation(),D(null),x(Ve.id)}),un=K(e=>{e.preventDefault(),e.stopPropagation(),D(null),I(Ve,{archivedBucket:s})}),dn=K(e=>{e.preventDefault(),e.stopPropagation(),D(null),I(Ve,{archivedBucket:s,hardDelete:!0,skipConfirm:!0})}),fn=K(e=>{e.preventDefault(),e.stopPropagation(),D(null),x(Ve.id)}),pn=K(()=>{!Ge||at||(ot(!0),(async()=>{try{await qe.refreshSessionTranscript(Ve.id,{directory:Ge}),J.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{J.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{ot(!1)}})())}),mn=K(e=>{e.preventDefault(),e.stopPropagation()}),hn=K(e=>{e.preventDefault(),e.stopPropagation()}),gn=K(e=>{e.preventDefault(),e.stopPropagation(),ue?.vscode?.executeCommand(`yuri.openSessionInEditor`,Ve.id,yt)}),_n=K(e=>{if(ke.current){ke.current=!1;return}if(Je){if(e?.preventDefault(),e?.stopPropagation(),e?.shiftKey){let e=(typeof document<`u`?Array.from(document.querySelectorAll(`[data-session-row]`)):[]).map(e=>e.getAttribute(`data-session-row`)).filter(e=>typeof e==`string`&&e.length>0),t=fb.getState().anchorId,n=new Map;n.set(Ve.id,rx(r)),Qe(t,Ve.id,e,Ge??null,n);return}Ze(Ve.id,Ge??null,rx(r));return}b(Ve.id,Ge,o,V)}),yn=K(e=>{if(e.defaultPrevented||e.target?.closest(`button, a, input, [role="menuitem"], [role="menu"]`))return;_n(e);let t=e.currentTarget.querySelector(`[data-session-title]`);t&&!L&&(t.focus({preventScroll:!0}),Ae.current=!0)}),bn=K(e=>{(e.button===2||e.button===0&&e.ctrlKey&&!Je)&&(ke.current=!0)}),xn=K(e=>{Ae.current=e.pointerType===`mouse`,L&&e.pointerType===`touch`&&Me(!0)}),Sn=K(e=>{L&&e.pointerType===`touch`&&Me(!1)}),Cn=K(e=>{e.key!==`Enter`||!Ae.current||(e.preventDefault(),e.stopPropagation(),Re(!0),p(Ve.id),g(yt))}),wn=K(e=>{if(_n(e),!Ae.current)return;let t=e.currentTarget;window.requestAnimationFrame(()=>{Ae.current=!0,t.focus({preventScroll:!0})})}),En=K(()=>{Ae.current=!1}),Dn=K(()=>{!Ft&&!st&&(ct(!0),qe.loadChildren(Ve.id,Ge).catch(()=>J.error(n(`sessions.sidebar.session.subsessions.loadFailed`))).finally(()=>ct(!1))),y(Pt)});if(f===Ve.id&&Le){let e=async()=>{v();try{await vn(Ve.id)}catch(e){console.warn(`[session-sidebar] failed to request smart title:`,e)}};return(0,$.jsx)(`div`,{className:`group relative my-0.5 flex items-center rounded-lg py-1.5 pr-2`,style:{paddingLeft:lo(i)},children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0`,children:[(0,$.jsxs)(`form`,{ref:ze,className:`flex w-full items-center gap-2`,onSubmit:e=>{e.preventDefault(),_(Fe)},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||v()},children:[(0,$.jsx)(`input`,{ref:Be,value:Fe,onChange:e=>Ie(e.target.value),className:`flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground`,autoFocus:!0,placeholder:n(`sessions.sidebar.session.menu.rename`),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`){v();return}}}),(0,$.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{e()},"aria-label":n(`sessions.sidebar.session.rename.smartTitle`),title:n(`sessions.sidebar.session.rename.smartTitle`),className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(Z,{name:`ai-generate-2`,className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`submit`,onMouseDown:e=>e.preventDefault(),"aria-label":n(`sessions.sidebar.session.rename.save`),title:n(`sessions.sidebar.session.rename.save`),className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(Z,{name:`check`,className:`size-3.5`})})]}),W?null:(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-3 text-muted-foreground/60 min-w-0 overflow-hidden leading-tight`,style:{fontSize:`calc(var(--text-ui-label) * 0.85)`},children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 overflow-hidden`,children:[jt&&!Lt&&!It?(0,$.jsx)(`span`,{className:`inline-flex items-center justify-center flex-shrink-0`,children:Ft?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-3 w-3`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-3 w-3`})}):null,(0,$.jsx)(`span`,{className:`flex-shrink-0`,children:Bt}),H?(0,$.jsx)(`span`,{className:`truncate`,children:B?.projectLabel}):null,se?(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-0.5`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`h-3 w-3 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:B?.branchLabel})]}):null]})})]})},Ve.id)}let An=dt,jn=At&&wt>Date.now()&&Tt!==wt,Mn=ft.length,Nn=pt.length>0,Pn=Nn||An||!Nn&&!An&&Rt,Fn=!z||ce,Ln=Nn?(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":n(`sessions.sidebar.session.status.questionRequired`),title:n(`sessions.sidebar.session.status.questionRequired`),children:(0,$.jsx)(Z,{name:`question`,className:`h-3.5 w-3.5 text-primary`})}):An?(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":n(`sessions.sidebar.session.status.active`),title:n(`sessions.sidebar.session.status.active`),children:(0,$.jsx)(Yc,{})}):(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":n(`sessions.sidebar.session.status.unread`),title:n(`sessions.sidebar.session.status.unread`),children:(0,$.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-[var(--status-info)]`})}),Rn=!Lt&&!It&&jt,zn=Rn&&!z&&!st,Bn=lo(Math.max(0,i-1)),Vn=Rn?(0,$.jsx)(`span`,{role:`button`,tabIndex:0,"aria-expanded":Ft,"aria-busy":st,onClick:e=>{e.stopPropagation(),e.currentTarget.blur(),Dn()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),Dn())},style:{minWidth:14,minHeight:14,left:Bn},className:X(`absolute inline-flex h-3.5 w-3.5 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`,W?`top-1/2 -translate-y-1/2`:`top-[14.5px] -translate-y-1/2`,zn?`opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto`:``),"aria-label":n(Ft?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),children:st?(0,$.jsx)(Yc,{size:12}):Ft?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-3 w-3`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-3 w-3`})}):null,Hn=ut?(0,$.jsx)(Z,{name:`error-warning`,className:`h-4 w-4 text-status-warning`}):null,Un=(0,$.jsx)(Te,{children:(0,$.jsx)(de,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(_e,{"data-slot":`dropdown-menu-content`,finalFocus:()=>!(O||Ne.current),style:{color:`var(--surface-elevated-foreground)`},className:X(rs,`yuri-session-context-menu min-w-[180px]`),children:(({Item:e,Separator:t,Sub:r,SubTrigger:i,SubContent:a})=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(e,{onClick:()=>x(Ve.id),className:`[&>svg]:mr-1`,children:[Nt?(0,$.jsx)(Z,{name:`unpin`,className:`mr-1 h-4 w-4`}):(0,$.jsx)(Z,{name:`pushpin`,className:`mr-1 h-4 w-4`}),n(Nt?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`)]}),It?null:(0,$.jsxs)(e,{onClick:()=>{q>0?sn(Ve.id):On(Ve.id,Ge||void 0).catch(()=>J.error(n(`sessions.sidebar.session.menu.markUnreadFailed`)))},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:q>0?`mail-open`:`mail`,className:`mr-1 h-4 w-4`}),n(q>0?`sessions.sidebar.session.menu.markRead`:`sessions.sidebar.session.menu.markUnread`)]}),(0,$.jsxs)(e,{onClick:()=>{Pe.current={id:Ve.id,title:yt}},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`pencil-ai`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.rename`)]}),$n()&&!He.share?(0,$.jsxs)(e,{onClick:()=>S(He),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`share-2`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.share`)]}):$n()&&He.share?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(e,{onClick:()=>{He.share?.url&&T(He.share.url,Ve.id)},className:`[&>svg]:mr-1`,children:C===Ve.id?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`check`,className:`mr-1 h-4 w-4`,style:{color:`var(--status-success)`}}),n(`sessions.sidebar.session.menu.copied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`file-copy`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.copyLink`)]})}),(0,$.jsxs)(e,{onClick:()=>E(Ve.id),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`link-unlink-m`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.unshare`)]})]}):null,(0,$.jsxs)(e,{onClick:()=>{en()},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`download`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.exportMarkdown`)]}),(0,$.jsxs)(e,{disabled:!Ge||at,onClick:()=>{pn()},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`refresh`,className:X(`mr-1 h-4 w-4`,at&&`animate-spin`)}),n(`sessions.sidebar.session.menu.refreshTranscript`)]}),Gt?(0,$.jsxs)(e,{onClick:()=>qt(!0),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(qb,{className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.runFusion`)]}):null,Ge&&!s?(()=>{let o=k(Ge),s=A(Ge,Ve.id);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(t,{}),(0,$.jsxs)(r,{children:[(0,$.jsxs)(i,{className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`folder`,className:`h-4 w-4`}),n(`sessions.sidebar.folders.moveToFolder`)]}),(0,$.jsxs)(a,{className:`min-w-[180px]`,children:[o.length===0?(0,$.jsx)(e,{disabled:!0,className:`text-muted-foreground`,children:n(`sessions.sidebar.folders.none`)}):o.map(t=>(0,$.jsxs)(e,{onClick:()=>{s===t.id?j(Ge,Ve.id):N(Ge,t.id,Ve.id)},children:[(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:t.name}),s===t.id?(0,$.jsx)(Z,{name:`check`,className:`ml-2 h-3.5 w-3.5 text-primary flex-shrink-0`}):null]},t.id)),(0,$.jsx)(t,{}),(0,$.jsxs)(e,{onClick:()=>{let e=F(Ge);e&&N(Ge,e.id,Ve.id)},children:[(0,$.jsx)(Z,{name:`add`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.folders.newFolderEllipsis`)]}),s?(0,$.jsxs)(e,{onClick:()=>{j(Ge,Ve.id)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(Z,{name:`close`,className:`mr-1 h-4 w-4 text-inherit`}),n(`sessions.sidebar.folders.removeFromFolder`)]}):null]})]})]})})():null,le?(0,$.jsxs)(e,{disabled:!Ge,onClick:tn,className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`window`,className:`mr-1 h-4 w-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:n(`sessions.sidebar.session.menu.openMiniChatWindow`)})]}):null,(0,$.jsx)(t,{}),s?null:(0,$.jsxs)(e,{className:`[&>svg]:mr-1`,onClick:()=>I(Ve,{archivedBucket:s}),children:[(0,$.jsx)(Z,{name:`inbox-archive`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.bulkActions.archive`)]}),(0,$.jsxs)(e,{className:`text-destructive/80 focus:text-destructive/80 [&>svg]:mr-1`,onClick:()=>I(Ve,{archivedBucket:s,hardDelete:!0}),children:[(0,$.jsx)(Z,{name:`delete-bin`,className:`mr-1 h-4 w-4 text-inherit`}),n(`sessions.sidebar.bulkActions.delete`)]})]}))({Item:({className:e,...t})=>(0,$.jsx)(ve,{className:X(as,e),...t}),Separator:({className:e,...t})=>(0,$.jsx)(pe,{className:X(is,e),...t}),Sub:xe,SubTrigger:({className:e,children:t,...n})=>(0,$.jsxs)(be,{className:X(ns,e),...n,children:[t,(0,$.jsx)(Z,{name:`arrow-right-s`,className:`ml-auto size-3.5`})]}),SubContent:({className:e,children:t,...n})=>(0,$.jsx)(Te,{children:(0,$.jsx)(de,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(_e,{"data-slot":`dropdown-menu-sub-content`,style:{color:`var(--surface-elevated-foreground)`},className:X(rs,`yuri-session-context-menu`,e),...n,children:t})})})})})})});return(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(hc,{sessionId:Ve.id,sessionDirectory:Ge??null,sessionTitle:yt,children:(0,$.jsxs)(Se,{open:Ht,onOpenChange:rn,onOpenChangeComplete:nn,children:[(0,$.jsxs)(Ce,{render:(0,$.jsx)(cl,{ref:gt,active:_t,selected:Ye,"data-session-row":Ve.id,"data-session-scope":Ge??``,"data-session-focus-scope":V,"data-session-focus-key":ht,"data-session-project-id":o??``,"data-session-archived":s?`1`:`0`,"data-session-depth":i,onClick:yn,className:X(_t&&!Ye&&`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,Ye&&`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,!_t&&!Ye&&`hover:bg-[color-mix(in_srgb,var(--surface-foreground)_3.5%,transparent)] dark:hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`)}),children:[Vn,(0,$.jsx)(Dc,{depth:i,children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(ic,{type:`button`,"data-session-title":!0,onPointerDown:xn,onPointerUp:Sn,onPointerCancel:Sn,onMouseDown:bn,onKeyDown:Cn,onBlur:En,onClick:wn,onDoubleClick:e=>{e.stopPropagation(),!L&&R()&&tn()},className:X(je&&`bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,z?ce?De:Oe:De),children:(0,$.jsxs)(`div`,{className:`flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:X(`block min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground`,jn&&`animate-text-shimmer`),"aria-busy":jn||void 0,children:za(yt,d)}),bt?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro tabular-nums text-muted-foreground`,children:bt}):null,Ue?(0,$.jsx)(Z,{name:`ai-agent`,className:`size-3 shrink-0 text-muted-foreground`,"aria-label":`Assistant`}):null,Mn>0?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0`,title:n(`sessions.sidebar.session.status.permissionRequired`),"aria-label":n(`sessions.sidebar.session.status.permissionRequired`),children:[(0,$.jsx)(Z,{name:`shield`,className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`leading-none`,children:Mn})]}):null,Pn?(0,$.jsx)(`span`,{className:X(`inline-flex shrink-0 items-center justify-center transition-none`,Fn?X(`group-hover:hidden group-focus-within:hidden`,Wt?`hidden`:``):Wt?`invisible`:``),children:Ln}):null,oe?(0,$.jsx)(ox,{number:oe}):null]})})}),ce?null:(0,$.jsx)(Ea,{side:`right`,align:`start`,sideOffset:8,className:`w-64 max-w-[min(16rem,calc(100vw-2rem))] px-3 py-2.5 text-left shadow-md`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-left`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1 break-words typography-ui-label font-medium text-foreground`,children:yt}),(0,$.jsx)(`div`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:Vt})]}),H?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 typography-meta text-muted-foreground`,children:[(0,$.jsx)(Z,{name:`folder-open`,className:`h-3.5 w-3.5 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:B?.projectLabel})]}):null,se?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 typography-meta text-muted-foreground`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`h-3.5 w-3.5 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:B?.branchLabel})]}):null]})})]})})}),Hn&&!L?(0,$.jsx)(`div`,{className:X(`absolute top-1/2 -translate-y-1/2 z-10`,W?`right-0`:`right-[30px]`),children:Hn}):null,(0,$.jsxs)(lc,{visible:Wt||z&&!ce,className:X(`absolute right-1 top-1/2 z-10 flex -translate-y-1/2 items-center gap-1 transition-none group-has-[[data-sidebar-shortcut-number]]:hidden`,Wt||z&&!ce?`opacity-100`:X(`opacity-0`,fe)),children:[ge?(0,$.jsx)(ix,{pinned:Nt,pinLabel:n(Nt?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`),buttonSizeClass:ye,iconSizeClass:we,onPointerDown:an,onMouseDown:cn,onPin:ln}):null,he?(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:X(`inline-flex items-center justify-center rounded-md text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,ye),"aria-label":n(`sessions.sidebar.session.actions.pinned`),onPointerDown:an,onMouseDown:cn,onClick:fn,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(Z,{name:`pushpin-2-fill`,className:we})})}),(0,$.jsx)(Ea,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:n(`sessions.sidebar.session.actions.pinned`)})]}):null,me?(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:X(`inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,ye),"aria-label":n(`sessions.sidebar.session.actions.openInEditor`),onPointerDown:mn,onMouseDown:hn,onClick:gn,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(Z,{name:`external-link`,className:we})})}),(0,$.jsx)(Ea,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:n(`sessions.sidebar.session.actions.openInEditor`)})]}):null,(0,$.jsx)(ax,{archiveLabel:n(`sessions.sidebar.bulkActions.archive`),deleteLabel:n(`sessions.sidebar.bulkActions.delete`),deleteOnly:s===!0,buttonSizeClass:ye,iconSizeClass:we,revealClassName:W&&!z&&!Wt?X(`opacity-0`,fe):`opacity-100`,onPointerDown:an,onMouseDown:cn,onArchive:un,onDelete:dn})]})]}),Un]})}),!Lt&&jt&&Ft?r.children.map(e=>{let t=ie?ie(e):{subtreeContainsActive:te,subtreeContainsEditing:ne,menuOpenSessionId:re,nodeStructureKey:``};return ee(e,i+1,Ge??a,o,s,void 0,V,t)}):null,(0,$.jsx)(Jr,{open:et,onOpenChange:tt,children:(0,$.jsxs)(Gr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,$.jsxs)(Ur,{children:[(0,$.jsx)(Kr,{children:n(`sessions.sidebar.session.export.dialog.title`)}),(0,$.jsx)(qr,{children:n(Jt===1?`sessions.sidebar.session.export.dialog.descriptionSingle`:`sessions.sidebar.session.export.dialog.descriptionMany`,{count:Jt})})]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-ui-label cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:nt,onChange:e=>rt(e.target.checked),className:`h-4 w-4 rounded border-border accent-primary`}),n(`sessions.sidebar.session.export.dialog.includeSubtasks`)]}),(0,$.jsxs)(Wr,{children:[(0,$.jsx)(Y,{type:`button`,onClick:()=>tt(!1),variant:`outline`,size:`sm`,children:n(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{type:`button`,onClick:()=>{tt(!1),$t(nt)},size:`sm`,children:n(`sessions.sidebar.session.export.dialog.confirm`)})]})]})}),Gt?(0,$.jsx)(Kb,{session:He,open:Kt,onOpenChange:qt}):null]},Ve.id)}var cx=e=>M(e.session.directory??null),lx=(e,t)=>(e?.projectLabel??null)===(t?.projectLabel??null)&&(e?.branchLabel??null)===(t?.branchLabel??null),ux=e=>{if(!e.openSidebarMenuKey)return null;let t=e.archivedBucket?`archived`:`active`,n=`${e.renderContext??`project`}:${t}:`;return e.openSidebarMenuKey.startsWith(n)?e.openSidebarMenuKey.slice(n.length):null},dx=e=>e.menuOpenSessionId??ux(e),fx=(e,t,n)=>t?n.has(e.node.session.id)?!0:Jc(e.node,t):!1,px=(e,t,n,r,i)=>{if(e.session.id!==t.session.id)return!0;let a=i(e);if(n.has(a)!==r.has(a)||e.children.length!==t.children.length)return!0;for(let a=0;a<e.children.length;a+=1)if(px(e.children[a],t.children[a],n,r,i))return!0;return!1},mx=(e,t,n,r)=>{if(e.session.id!==t.session.id)return!0;let i=e.session.id,a=n.get(i)??e.session,o=r.get(i)??t.session;if(a!==o&&Cl(a)!==Cl(o)||e.children.length!==t.children.length)return!0;for(let i=0;i<e.children.length;i+=1)if(mx(e.children[i],t.children[i],n,r))return!0;return!1},hx=(e,t)=>{if(e.hasSessionSearchQuery||t.hasSessionSearchQuery)return!1;let n=e.archivedBucket?`archived`:`active`,r=t.archivedBucket?`archived`:`active`;return px(e.node,t.node,e.expandedParents,t.expandedParents,t=>`${e.renderContext??`project`}:${n}:${t.session.id}`)||px(e.node,t.node,e.expandedParents,t.expandedParents,e=>`${t.renderContext??`project`}:${r}:${e.session.id}`)},gx=Q.memo(sx,(e,t)=>{if(e.node.session.id!==t.node.session.id||e.depth!==t.depth||e.groupDirectory!==t.groupDirectory||e.projectId!==t.projectId||e.archivedBucket!==t.archivedBucket||(e.renderContext??`project`)!==(t.renderContext??`project`)||e.mobileVariant!==t.mobileVariant||e.alwaysShowActions!==t.alwaysShowActions||e.shortcutNumber!==t.shortcutNumber||e.hasSessionSearchQuery!==t.hasSessionSearchQuery||e.normalizedSessionSearchQuery!==t.normalizedSessionSearchQuery||e.notifyOnSubtasks!==t.notifyOnSubtasks||e.nodeStructureKey!==t.nodeStructureKey||e.node.session.hasChildren!==t.node.session.hasChildren||cx(e.node)!==cx(t.node)||!lx(e.secondaryMeta,t.secondaryMeta)||e.liveSessionById!==t.liveSessionById&&mx(e.node,t.node,e.liveSessionById,t.liveSessionById)||e.pinnedSessionIds!==t.pinnedSessionIds&&px(e.node,t.node,e.pinnedSessionIds,t.pinnedSessionIds,e=>e.session.id)||e.expandedParents!==t.expandedParents&&hx(e,t)||e.currentSessionId!==t.currentSessionId&&(fx(e,e.currentSessionId,e.subtreeContainsActive)||fx(t,t.currentSessionId,t.subtreeContainsActive))||e.editingId!==t.editingId&&(fx(e,e.editingId,e.subtreeContainsEditing)||fx(t,t.editingId,t.subtreeContainsEditing))||e.editTitle!==t.editTitle&&(fx(e,e.editingId,e.subtreeContainsEditing)||fx(t,t.editingId,t.subtreeContainsEditing))||e.copiedSessionId!==t.copiedSessionId&&(Jc(e.node,e.copiedSessionId)||Jc(t.node,t.copiedSessionId)))return!1;if(e.openSidebarMenuKey!==t.openSidebarMenuKey){let n=dx(e),r=dx(t);if(Jc(e.node,n)||Jc(t.node,r))return!1}if(e.renamingFolderId!==t.renamingFolderId){let n=dx(e),r=dx(t);if(Jc(e.node,n)||Jc(t.node,r))return!1}return e.setEditingId===t.setEditingId&&e.setEditTitle===t.setEditTitle&&e.handleSaveEdit===t.handleSaveEdit&&e.handleCancelEdit===t.handleCancelEdit&&e.toggleParent===t.toggleParent&&e.handleSessionSelect===t.handleSessionSelect&&e.handleSessionDoubleClick===t.handleSessionDoubleClick&&e.togglePinnedSession===t.togglePinnedSession&&e.handleShareSession===t.handleShareSession&&e.handleCopyShareUrl===t.handleCopyShareUrl&&e.handleUnshareSession===t.handleUnshareSession&&e.setOpenSidebarMenuKey===t.setOpenSidebarMenuKey&&e.getFoldersForScope===t.getFoldersForScope&&e.getSessionFolderId===t.getSessionFolderId&&e.removeSessionFromFolder===t.removeSessionFromFolder&&e.addSessionToFolder===t.addSessionToFolder&&e.createFolderAndStartRename===t.createFolderAndStartRename&&e.handleDeleteSession===t.handleDeleteSession&&e.renderSessionNode===t.renderSessionNode});function _x(e){return e.stopPropagation()}function vx(e){return e.stopPropagation()}function yx(e){let t=(0,du.c)(71),{t:n}=Zt(),{value:r,setValue:i,showDeletionDialog:a,setShowDeletionDialog:o,onConfirm:s}=e,c,l,u,d,f,p,m,h,g,_;if(t[0]!==i||t[1]!==n||t[2]!==r){let e=n(`sessions.sidebar.session.untitled`);d=Jr,g=!!r,t[13]===i?_=t[14]:(_=e=>{e||i(null)},t[13]=i,t[14]=_),u=Gr,m=!1,h=`max-w-sm gap-5`,l=Ur;let a;t[15]!==n||t[16]!==r?.archivedBucket?(a=r?.archivedBucket?n(`sessions.sidebar.dialogs.deleteSession.title`):n(`sessions.sidebar.dialogs.archiveSession.title`),t[15]=n,t[16]=r?.archivedBucket,t[17]=a):a=t[17],t[18]===a?p=t[19]:(p=(0,$.jsx)(Kr,{children:a}),t[18]=a,t[19]=p),c=qr,f=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n(`sessions.sidebar.dialogs.deleteSession.withOneSubtask`,{sessionTitle:r.session.title||e,count:r.descendantCount}):n(`sessions.sidebar.dialogs.deleteSession.withManySubtasks`,{sessionTitle:r.session.title||e,count:r.descendantCount}):r.descendantCount===1?n(`sessions.sidebar.dialogs.archiveSession.withOneSubtask`,{sessionTitle:r.session.title||e,count:r.descendantCount}):n(`sessions.sidebar.dialogs.archiveSession.withManySubtasks`,{sessionTitle:r.session.title||e,count:r.descendantCount}):r?.archivedBucket?n(`sessions.sidebar.dialogs.deleteSession.single`,{sessionTitle:r?.session.title||e}):n(`sessions.sidebar.dialogs.archiveSession.single`,{sessionTitle:r?.session.title||e}),t[0]=i,t[1]=n,t[2]=r,t[3]=c,t[4]=l,t[5]=u,t[6]=d,t[7]=f,t[8]=p,t[9]=m,t[10]=h,t[11]=g,t[12]=_}else c=t[3],l=t[4],u=t[5],d=t[6],f=t[7],p=t[8],m=t[9],h=t[10],g=t[11],_=t[12];let v;t[20]!==c||t[21]!==f?(v=(0,$.jsx)(c,{children:f}),t[20]=c,t[21]=f,t[22]=v):v=t[22];let y;t[23]!==l||t[24]!==p||t[25]!==v?(y=(0,$.jsxs)(l,{children:[p,v]}),t[23]=l,t[24]=p,t[25]=v,t[26]=y):y=t[26];let b;t[27]!==o||t[28]!==a?(b=()=>o(!a),t[27]=o,t[28]=a,t[29]=b):b=t[29];let x=!a,S;t[30]===a?S=t[31]:(S=a?(0,$.jsx)(Z,{name:`checkbox-blank`,className:`h-4 w-4`}):(0,$.jsx)(Z,{name:`checkbox`,className:`h-4 w-4 text-primary`}),t[30]=a,t[31]=S);let C;t[32]===n?C=t[33]:(C=n(`sessions.sidebar.dialogs.neverAsk`),t[32]=n,t[33]=C);let w;t[34]!==S||t[35]!==C||t[36]!==b||t[37]!==x?(w=(0,$.jsxs)(`button`,{type:`button`,onClick:b,className:`inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":x,children:[S,C]}),t[34]=S,t[35]=C,t[36]=b,t[37]=x,t[38]=w):w=t[38];let T;t[39]===i?T=t[40]:(T=()=>i(null),t[39]=i,t[40]=T);let E;t[41]===n?E=t[42]:(E=n(`sessions.sidebar.dialogs.cancel`),t[41]=n,t[42]=E);let D;t[43]!==T||t[44]!==E?(D=(0,$.jsx)(`button`,{type:`button`,onClick:T,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:E}),t[43]=T,t[44]=E,t[45]=D):D=t[45];let O;t[46]===s?O=t[47]:(O=()=>void s(),t[46]=s,t[47]=O);let k;t[48]!==n||t[49]!==r?.archivedBucket?(k=r?.archivedBucket?n(`sessions.sidebar.bulkActions.delete`):n(`sessions.sidebar.bulkActions.archive`),t[48]=n,t[49]=r?.archivedBucket,t[50]=k):k=t[50];let A;t[51]!==O||t[52]!==k?(A=(0,$.jsx)(`button`,{type:`button`,onClick:O,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:k}),t[51]=O,t[52]=k,t[53]=A):A=t[53];let j;t[54]!==D||t[55]!==A?(j=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[D,A]}),t[54]=D,t[55]=A,t[56]=j):j=t[56];let M;t[57]!==w||t[58]!==j?(M=(0,$.jsxs)(Wr,{className:`w-full sm:items-center sm:justify-between`,children:[w,j]}),t[57]=w,t[58]=j,t[59]=M):M=t[59];let N;t[60]!==u||t[61]!==m||t[62]!==M||t[63]!==h||t[64]!==y?(N=(0,$.jsxs)(u,{showCloseButton:m,className:h,children:[y,M]}),t[60]=u,t[61]=m,t[62]=M,t[63]=h,t[64]=y,t[65]=N):N=t[65];let P;return t[66]!==d||t[67]!==N||t[68]!==g||t[69]!==_?(P=(0,$.jsx)(d,{open:g,onOpenChange:_,children:N}),t[66]=d,t[67]=N,t[68]=g,t[69]=_,t[70]=P):P=t[70],P}function bx(e){let t=(0,du.c)(57),{t:n}=Zt(),{value:r,setValue:i,showDeletionDialog:a,setShowDeletionDialog:o,onConfirm:s}=e,c=r?.archivedBucket===!0,l=r?.sessionCount??0,u;t[0]!==c||t[1]!==l||t[2]!==n?(u=n(c?l===1?`sessions.sidebar.dialogs.deleteSession.title`:`sessions.sidebar.dialogs.deleteSessions.title`:l===1?`sessions.sidebar.dialogs.archiveSession.title`:`sessions.sidebar.dialogs.archiveSessions.title`),t[0]=c,t[1]=l,t[2]=n,t[3]=u):u=t[3];let d=u,f;t[4]!==c||t[5]!==l||t[6]!==n?(f=n(c?l===1?`sessions.sidebar.dialogs.deleteSessions.singleDescription`:`sessions.sidebar.dialogs.deleteSessions.pluralDescription`:l===1?`sessions.sidebar.dialogs.archiveSessions.singleDescription`:`sessions.sidebar.dialogs.archiveSessions.pluralDescription`,{count:l}),t[4]=c,t[5]=l,t[6]=n,t[7]=f):f=t[7];let p=f,m=!!r,h;t[8]===i?h=t[9]:(h=e=>{e||i(null)},t[8]=i,t[9]=h);let g;t[10]===d?g=t[11]:(g=(0,$.jsx)(Kr,{children:d}),t[10]=d,t[11]=g);let _;t[12]===p?_=t[13]:(_=(0,$.jsx)(qr,{children:p}),t[12]=p,t[13]=_);let v;t[14]!==g||t[15]!==_?(v=(0,$.jsxs)(Ur,{children:[g,_]}),t[14]=g,t[15]=_,t[16]=v):v=t[16];let y;t[17]!==o||t[18]!==a?(y=()=>o(!a),t[17]=o,t[18]=a,t[19]=y):y=t[19];let b=!a,x;t[20]===a?x=t[21]:(x=a?(0,$.jsx)(Z,{name:`checkbox-blank`,className:`h-4 w-4`}):(0,$.jsx)(Z,{name:`checkbox`,className:`h-4 w-4 text-primary`}),t[20]=a,t[21]=x);let S;t[22]===n?S=t[23]:(S=n(`sessions.sidebar.dialogs.neverAsk`),t[22]=n,t[23]=S);let C;t[24]!==S||t[25]!==y||t[26]!==b||t[27]!==x?(C=(0,$.jsxs)(`button`,{type:`button`,onClick:y,className:`inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":b,children:[x,S]}),t[24]=S,t[25]=y,t[26]=b,t[27]=x,t[28]=C):C=t[28];let w;t[29]===i?w=t[30]:(w=()=>i(null),t[29]=i,t[30]=w);let T;t[31]===n?T=t[32]:(T=n(`sessions.sidebar.dialogs.cancel`),t[31]=n,t[32]=T);let E;t[33]!==w||t[34]!==T?(E=(0,$.jsx)(`button`,{type:`button`,onClick:w,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:T}),t[33]=w,t[34]=T,t[35]=E):E=t[35];let D;t[36]===s?D=t[37]:(D=()=>void s(),t[36]=s,t[37]=D);let O;t[38]!==c||t[39]!==n?(O=n(c?`sessions.sidebar.bulkActions.delete`:`sessions.sidebar.bulkActions.archive`),t[38]=c,t[39]=n,t[40]=O):O=t[40];let k;t[41]!==D||t[42]!==O?(k=(0,$.jsx)(`button`,{type:`button`,onClick:D,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:O}),t[41]=D,t[42]=O,t[43]=k):k=t[43];let A;t[44]!==E||t[45]!==k?(A=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[E,k]}),t[44]=E,t[45]=k,t[46]=A):A=t[46];let j;t[47]!==C||t[48]!==A?(j=(0,$.jsxs)(Wr,{className:`w-full sm:items-center sm:justify-between`,children:[C,A]}),t[47]=C,t[48]=A,t[49]=j):j=t[49];let M;t[50]!==j||t[51]!==v?(M=(0,$.jsxs)(Gr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[v,j]}),t[50]=j,t[51]=v,t[52]=M):M=t[52];let N;return t[53]!==m||t[54]!==M||t[55]!==h?(N=(0,$.jsx)(Jr,{open:m,onOpenChange:h,children:M}),t[53]=m,t[54]=M,t[55]=h,t[56]=N):N=t[56],N}function xx(e){let t=(0,du.c)(36),{t:n}=Zt(),{value:r,setValue:i,onConfirm:a}=e,o=!!r,s;t[0]===i?s=t[1]:(s=e=>{e||i(null)},t[0]=i,t[1]=s);let c;t[2]===n?c=t[3]:(c=n(`sessions.sidebar.dialogs.deleteFolder.title`),t[2]=n,t[3]=c);let l;t[4]===c?l=t[5]:(l=(0,$.jsx)(Kr,{children:c}),t[4]=c,t[5]=l);let u;t[6]!==n||t[7]!==r?(u=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?n(`sessions.sidebar.dialogs.deleteFolder.withOneSubfolder`,{folderName:r.folderName,count:r.subFolderCount}):n(`sessions.sidebar.dialogs.deleteFolder.withManySubfolders`,{folderName:r.folderName,count:r.subFolderCount}):n(`sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders`,{folderName:r.folderName}):n(`sessions.sidebar.dialogs.deleteFolder.single`,{folderName:r?.folderName??``}),t[6]=n,t[7]=r,t[8]=u):u=t[8];let d;t[9]===u?d=t[10]:(d=(0,$.jsx)(qr,{children:u}),t[9]=u,t[10]=d);let f;t[11]!==l||t[12]!==d?(f=(0,$.jsxs)(Ur,{children:[l,d]}),t[11]=l,t[12]=d,t[13]=f):f=t[13];let p;t[14]===i?p=t[15]:(p=()=>i(null),t[14]=i,t[15]=p);let m;t[16]===n?m=t[17]:(m=n(`sessions.sidebar.dialogs.cancel`),t[16]=n,t[17]=m);let h;t[18]!==p||t[19]!==m?(h=(0,$.jsx)(`button`,{type:`button`,onClick:p,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:m}),t[18]=p,t[19]=m,t[20]=h):h=t[20];let g;t[21]===n?g=t[22]:(g=n(`sessions.sidebar.bulkActions.delete`),t[21]=n,t[22]=g);let _;t[23]!==a||t[24]!==g?(_=(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:g}),t[23]=a,t[24]=g,t[25]=_):_=t[25];let v;t[26]!==_||t[27]!==h?(v=(0,$.jsxs)(Wr,{children:[h,_]}),t[26]=_,t[27]=h,t[28]=v):v=t[28];let y;t[29]!==v||t[30]!==f?(y=(0,$.jsxs)(Gr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[f,v]}),t[29]=v,t[30]=f,t[31]=y):y=t[31];let b;return t[32]!==o||t[33]!==s||t[34]!==y?(b=(0,$.jsx)(Jr,{open:o,onOpenChange:s,children:y}),t[32]=o,t[33]=s,t[34]=y,t[35]=b):b=t[35],b}var Sx=e=>{let t=(0,du.c)(46),{selectedCount:n,scopeKey:r,scopeFolders:i,archivedBucket:a,onMoveToFolder:o,onCreateFolderAndMove:s,onRemoveFromFolder:c,canRemoveFromFolder:l,onDelete:u,onDone:d}=e,{t:f}=Zt(),p=!!r&&!a,m;t[0]!==a||t[1]!==f?(m=f(a?`sessions.sidebar.bulkActions.delete`:`sessions.sidebar.bulkActions.archive`),t[0]=a,t[1]=f,t[2]=m):m=t[2];let h=m,g;t[3]!==n||t[4]!==f?(g=f(`sessions.sidebar.bulkActions.selectedCount`,{count:n}),t[3]=n,t[4]=f,t[5]=g):g=t[5];let _;t[6]===g?_=t[7]:(_=(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground whitespace-nowrap`,children:g}),t[6]=g,t[7]=_);let v;t[8]!==p||t[9]!==l||t[10]!==s||t[11]!==o||t[12]!==c||t[13]!==i||t[14]!==f?(v=p?(0,$.jsxs)(Na,{children:[(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(Ra,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":f(`sessions.sidebar.bulkActions.moveToFolder`),children:(0,$.jsx)(Z,{name:`folder`,className:`h-4 w-4`})})})}),(0,$.jsx)(Ea,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:f(`sessions.sidebar.bulkActions.moveToFolder`)})})]}),(0,$.jsxs)(Ia,{align:`end`,className:`min-w-[180px]`,children:[i.length===0?(0,$.jsx)(ao,{disabled:!0,className:`text-muted-foreground`,children:f(`sessions.sidebar.folders.none`)}):i.map(e=>(0,$.jsx)(ao,{onClick:()=>o(e.id),children:(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e.name})},e.id)),(0,$.jsx)(Wa,{}),(0,$.jsxs)(ao,{onClick:s,children:[(0,$.jsx)(Z,{name:`add`,className:`mr-1 h-4 w-4`}),f(`sessions.sidebar.folders.newFolderEllipsis`)]}),l?(0,$.jsxs)(ao,{onClick:c,className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(Z,{name:`close`,className:`mr-1 h-4 w-4 text-inherit`}),f(`sessions.sidebar.folders.removeFromFolder`)]}):null]})]}):null,t[8]=p,t[9]=l,t[10]=s,t[11]=o,t[12]=c,t[13]=i,t[14]=f,t[15]=v):v=t[15];let y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=X(`inline-flex h-7 w-7 items-center justify-center rounded-md text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`),t[16]=y):y=t[16];let b;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(Z,{name:`delete-bin`,className:`h-4 w-4`}),t[17]=b):b=t[17];let x;t[18]!==h||t[19]!==u?(x=(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:u,className:y,"aria-label":h,children:b})}),t[18]=h,t[19]=u,t[20]=x):x=t[20];let S;t[21]===h?S=t[22]:(S=(0,$.jsx)(Ea,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:h})}),t[21]=h,t[22]=S);let C;t[23]!==x||t[24]!==S?(C=(0,$.jsxs)(Oa,{children:[x,S]}),t[23]=x,t[24]=S,t[25]=C):C=t[25];let w;t[26]===f?w=t[27]:(w=f(`sessions.sidebar.header.actions.exitSelection`),t[26]=f,t[27]=w);let T;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Z,{name:`close`,className:`h-4 w-4`}),t[28]=T):T=t[28];let E;t[29]!==d||t[30]!==w?(E=(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:d,className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":w,children:T})}),t[29]=d,t[30]=w,t[31]=E):E=t[31];let D;t[32]===f?D=t[33]:(D=f(`sessions.sidebar.header.actions.exitSelection`),t[32]=f,t[33]=D);let O;t[34]===D?O=t[35]:(O=(0,$.jsx)(Ea,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:D})}),t[34]=D,t[35]=O);let k;t[36]!==E||t[37]!==O?(k=(0,$.jsxs)(Oa,{children:[E,O]}),t[36]=E,t[37]=O,t[38]=k):k=t[38];let A;t[39]!==k||t[40]!==v||t[41]!==C?(A=(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5`,children:[v,C,k]}),t[39]=k,t[40]=v,t[41]=C,t[42]=A):A=t[42];let j;return t[43]!==A||t[44]!==_?(j=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-t border-border px-2.5 py-1.5`,children:[_,A]}),t[43]=A,t[44]=_,t[45]=j):j=t[45],j},Cx=e=>{let{t}=Zt(),{isInlineEditing:n,showDeletionDialog:r,foldersMap:i,addSessionsToFolder:a,removeSessionsFromFolders:o,createFolderAndStartRename:s,archiveSessions:c,setBulkDeleteConfirm:l}=e,u=fb(e=>e.enabled),d=fb(e=>e.selectedIds.size),f=d>0,p=fb(e=>e.selectedIds),m=fb(e=>e.scopeKey),h=Q.useCallback(()=>{fb.getState().toggleMode()},[]),g=Q.useCallback(()=>{fb.getState().disable()},[]),_=Q.useMemo(()=>{if(!f||typeof document>`u`)return!1;let e=!1,t=!1;for(let n of p){let r=document.querySelectorAll(`[data-session-row="${CSS.escape(n)}"]`);for(let n of r)n.getAttribute(`data-session-archived`)===`1`?t=!0:e=!0}return t&&!e},[f,p]),v=Q.useMemo(()=>{if(m)return m;if(!f||typeof document>`u`)return null;for(let e of p){let t=document.querySelector(`[data-session-row="${CSS.escape(e)}"]`)?.getAttribute(`data-session-scope`);if(t&&t.length>0)return t}return null},[f,p,m]),y=Q.useMemo(()=>v?i[v]??[]:[],[i,v]),b=Q.useMemo(()=>{if(!v||!f)return!1;let e=i[v]??[];for(let t of e)for(let e of t.sessionIds)if(p.has(e))return!0;return!1},[i,v,f,p]),x=Q.useCallback(e=>{!v||!f||a(v,e,Array.from(p))},[a,p,v,f]),S=Q.useCallback(()=>{if(!v||!f)return;let e=s(v);e&&a(v,e.id,Array.from(p))},[a,s,p,v,f]),C=Q.useCallback(()=>{!v||!f||o(v,Array.from(p))},[o,p,v,f]),w=Q.useCallback(async()=>{let e=Array.from(p);if(e.length!==0){if(_)il({sessionIds:e,message:e.length===1?t(`sessions.sidebar.bulkActions.deletedSingle`,{count:e.length}):t(`sessions.sidebar.bulkActions.deletedPlural`,{count:e.length}),undoLabel:t(`sessions.sidebar.undo`),commitFailedMessage:e.length===1?t(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:e.length}):t(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:e.length})});else{let{archivedIds:n,failedIds:r}=await c(e);n.length>0&&nl({sessionIds:n,message:n.length===1?t(`sessions.sidebar.bulkActions.archivedSingle`,{count:n.length}):t(`sessions.sidebar.bulkActions.archivedPlural`,{count:n.length}),undoLabel:t(`sessions.sidebar.undo`),settingsLabel:t(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:n.length===1?t(`sessions.sidebar.session.archive.undoFailed`):t(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:n.length})}),r.length>0&&J.error(r.length===1?t(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):t(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}fb.getState().clear()}},[c,_,p,t]),T=Q.useCallback(()=>{if(!f)return;let e=p.size;if(!_||!r){w();return}l({sessionCount:e,archivedBucket:_})},[_,w,p,r,l,f]),E=Q.useCallback(async()=>{l(null),await w()},[w]);return Q.useEffect(()=>{if(!u)return;let e=typeof navigator<`u`&&/Macintosh|Mac OS X/.test(navigator.userAgent||``),t=t=>{if(n)return;let r=t.target;if(r&&(r.tagName===`INPUT`||r.tagName===`TEXTAREA`||r.isContentEditable))return;let i=e?t.metaKey:t.ctrlKey;if(t.key===`Escape`){t.preventDefault(),fb.getState().disable();return}if(i&&t.key===`Backspace`){t.preventDefault(),T();return}if(i&&(t.key===`a`||t.key===`A`)){let e=typeof document<`u`?Array.from(document.querySelectorAll(`[data-session-row]`)):[];if(e.length===0)return;t.preventDefault();let n=fb.getState().scopeKey??e[0]?.getAttribute(`data-session-scope`)??null,r=e.filter(e=>!n||e.getAttribute(`data-session-scope`)===n).map(e=>e.getAttribute(`data-session-row`)).filter(e=>typeof e==`string`&&e.length>0);if(r.length===0)return;fb.getState().replaceAll(r,n||null)}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[T,n,u]),{selectionModeEnabled:u,hasSelection:f,selectedIdsSize:d,bulkScopeIsArchived:_,derivedSelectionScope:v,bulkScopeFolders:y,bulkCanRemoveFromFolder:b,handleToggleSelectionMode:h,handleExitSelectionMode:g,handleBulkMoveToFolder:x,handleBulkCreateFolderAndMove:S,handleBulkRemoveFromFolder:C,handleBulkDelete:T,confirmBulkDelete:E}},wx=(e,t,n)=>{let r=[],i=new Set,a=e=>{let t=M(e??null);!t||i.has(t)||(i.add(t),r.push(t))};if(a(e),a(n?.workspaceRoot),a(n?.currentDirectory),n?.includeWorktrees!==!1)for(let e of t)a(e.path);return r},Tx=(e,t,n,r)=>{let i=e.filter(e=>e.sessionId===t);if(i.length===0)return null;if(n){let e=i.find(e=>e.projectId===n);if(e)return e}if(r){let e=i.find(e=>e.projectId===r);if(e)return e}return i[0]??null},Ex=({currentSessionId:e,focus:t,pinnedFocuses:n,projectFocuses:r,fallbackProjectId:i})=>{if(!e)return null;let a=t?.sessionId===e,o=a?t.projectId:null,s=Tx(r,e,o,i)??{scope:`project`,sessionId:e,projectId:i};return!a||t.scope===`project`?s:Tx(n,e,o,i)??s};function Dx(e,t,n=null){if(!e||e.scope!==`project`||!e.sessionId)return null;if(e.projectId){let n=t.find(t=>t.sessionId===e.sessionId&&t.projectId===e.projectId);if(n)return n}if(n){let r=t.find(t=>t.sessionId===e.sessionId&&t.projectId===n);if(r)return r}return t.find(t=>t.sessionId===e.sessionId)??null}var Ox=`yuri.sessions.projectCollapse`,kx=`yuri.sessions.groupOrder`,Ax=`yuri.sessions.groupCollapse`,jx=`yuri.sessions.activeSessionByProject`,Mx=`yuri.sessions.expandedParents.v2`,Nx=`yuri.sessions.expandedParents`,Px=at(Be()),Fx=e=>{try{let t=Px.getItem(e);if(!t)return new Set;let n=JSON.parse(t);return new Set(Array.isArray(n)?n.filter(e=>typeof e==`string`):[])}catch{return new Set}},Ix=e=>{try{let t=Px.getItem(e);if(!t)return new Map;let n=JSON.parse(t),r=new Map;return!n||typeof n!=`object`||Array.isArray(n)||Object.entries(n).forEach(([e,t])=>{typeof t==`string`&&t.length>0&&r.set(e,t)}),r}catch{return new Map}},Lx=e=>{try{let t=Px.getItem(e);if(!t)return new Map;let n=JSON.parse(t),r=new Map;return!n||typeof n!=`object`||Array.isArray(n)||Object.entries(n).forEach(([e,t])=>{Array.isArray(t)&&r.set(e,t.filter(e=>typeof e==`string`))}),r}catch{return new Map}},Rx=(e,t,n)=>{let r=new Set;for(let t of e){let e=M(t.path)?.toLowerCase();e&&r.add(e)}if(n?.includeWorktrees===!1)return r;for(let e of t.values())for(let t of e){let e=M(t.path)?.toLowerCase();e&&r.add(e)}return r},zx=(e,t,n)=>{if(e.time?.archived)return!0;let r=M(Xn(e))?.toLowerCase();return r?t.size===0?n?.allowEmptyDirectorySet??!0:t.has(r):n?.allowUnknownDirectory??!0},Bx=new Set,Vx=[],Hx={},Ux=(e,t)=>{let n=Q.useRef(e);return n.current=e,Q.useMemo(()=>(...e)=>n.current(...e),[t])},Wx=Q.memo(function(e){let t=(0,du.c)(3),{onOpenChange:n}=e,r=As(ue(Kx)),i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(bs,{open:!0,onOpenChange:n,...r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}),Gx=Q.memo(function({mobileVariant:e=!1,onSessionSelected:t,allowReselect:n=!1,hideDirectoryControls:r=!1,showOnlyMainWorkspace:i=!1,isVisible:a=!0}){let{t:o}=Zt(),[c,l]=Q.useState(!1),[u,d]=Q.useState(!1),[f,m]=Q.useState(``),h=Q.useRef(null),g=Q.useRef(null),[_,y]=Q.useState(null),[b,x]=Q.useState(``),[S,C]=Q.useState(null),[T,E]=Q.useState(new Set),D=Q.useMemo(()=>Px,[]),[O,k]=Q.useState(new Set),[A,j]=Q.useState(new Map),[N,P]=Q.useState(new Map),F=q(e=>e.isNewWorktreeDialogOpen),I=q(e=>e.setNewWorktreeDialogOpen),[L,R]=Q.useState(null),[z,ee]=Q.useState(null),[B,V]=Q.useState(``),[te,ne]=Q.useState(null),[re,ie]=Q.useState(null),[ae,oe]=Q.useState(null),H=Sr(),se=En(),[U,ce]=Q.useState(()=>Fx(Ax)),[W,le]=Q.useState(()=>Lx(kx)),[ue,de]=Q.useState(()=>Ix(jx)),fe=Q.useRef(null);Q.useEffect(()=>s(e=>{p(e)&&(fe.current=null,ce(Fx(Ax)),le(Lx(kx)),de(Ix(jx)),k(Fx(Ox)),E(Fx(Mx)))}),[]);let[pe,me]=Q.useState(new Map),he=Q.useRef(0),ge=Pe(e=>e.homeDirectory),_e=Pe(e=>e.currentDirectory),ve=Pe(e=>e.setDirectory),ye=mn(e=>e.projects),be=Q.useMemo(()=>ye.filter(e=>!e.hostId),[ye]),xe=Q.useMemo(()=>ye.filter(e=>e.hostId).map(Ar),[ye]),[Se,Ce]=Q.useState(()=>new Map),we=K((e,t)=>{Ce(n=>{if(!t.length&&!n.has(e))return n;let r=new Map(n);return t.length?r.set(e,t):r.delete(e),r})}),Te=kc(a),[Ee,De]=Q.useState(new Map),Oe=K((e,t)=>{De(n=>JSON.stringify(n.get(e))===JSON.stringify(t)?n:new Map(n).set(e,t))}),ke=mn(e=>e.activeProjectId),Ae=mn(e=>e.removeProject),je=mn(e=>e.setActiveProjectIdOnly),Me=mn(e=>e.updateProjectMeta),Ne=mn(e=>e.reorderProjectsById),Fe=q(e=>e.setActiveMainTab),Ie=q(e=>e.activeMainTab),Le=tn(),Re=q(e=>e.setSettingsDialogOpen),G=q(e=>e.toggleHelpDialog),ze=q(e=>e.setSessionSwitcherOpen),Be=q(e=>e.setScheduledTasksDialogOpen),Ve=q(e=>e.notifyOnSubtasks),He=q(e=>e.showDeletionDialog),Ue=q(e=>e.setShowDeletionDialog),We=ko(f,120),Ge=Q.useMemo(()=>We.trim().toLowerCase(),[We]),Ke=Ge.length>0,qe=As(e=>e.available&&(e.runtimeType===`desktop`||e.runtimeType===`web`)),Je=or(e=>e.collapsedFolderIds),Ye=or(e=>e.foldersMap),Xe=or(e=>e.sessionOrderByScope),Ze=or(e=>e.sessionOrderActivityByScope),Qe=or(e=>e.getFoldersForScope),$e=or(e=>e.createFolder),et=or(e=>e.renameFolder),tt=or(e=>e.deleteFolder),nt=or(e=>e.addSessionToFolder),rt=or(e=>e.addSessionsToFolder),it=or(e=>e.removeSessionFromFolder),at=or(e=>e.removeSessionsFromFolders),ot=or(e=>e.toggleFolderCollapse),st=or(e=>e.getSessionFolderId),ct=or(e=>e.reorderSessions);Pv({isSessionSearchOpen:a&&u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchContainerRef:h});let lt=Q.useMemo(()=>new Map,[]),ut=wn({enabled:a,includeChildren:!0}),dt=xl({enabled:a}),ft=Fc({enabled:a}),pt=Sn(e=>a?e.index.session.unseenCount:Hx),mt=Q.useMemo(()=>w(),[]),ht=wr(e=>e.status),gt=wr(e=>e.activeSessions),_t=wr(e=>e.archivedSessions),vt=wr(e=>e.loadingDirectories.size>0||e.refreshingDirectories.size>0),bt=wr(e=>e.archivedLoadingDirectories),xt=Q.useDeferredValue(gt),St=Q.useDeferredValue(_t),Ct=cr(e=>e.currentSessionId),wt=dn(e=>e.remoteSession!==null)?null:Ct,Tt=ga(e=>e.focus),Et=Q.useSyncExternalStore(Lt,Ft,Ft),Dt=cr(e=>!!e.newSessionDraft?.open),Ot=cr(e=>e.newSessionDraft?.open&&!e.currentSessionId?e.newSessionDraft.selectedProjectId??null:null),kt=Q.useMemo(()=>!e&&Ie===`chat`&&Ot&&Et.sessionId===null?{projectId:Ot,revision:Et.revision}:null,[e,Ie,Ot,Et]),At=cr(e=>e.setCurrentSession),jt=cr(e=>e.updateSessionTitle),Mt=cr(e=>e.shareSession),Nt=cr(e=>e.unshareSession),Pt=cr(e=>e.worktreeMetadata),Rt=cr(e=>e.availableWorktreesByProject),zt=cr(e=>e.openNewSessionDraft),Bt=K(t=>{let n=xe.find(e=>e.id===(t?.selectedProjectId??mn.getState().activeProjectId));if(n){tc(n,e).catch(e=>J.error(e instanceof Error?e.message:String(e)));return}dn.getState().clearRemoteSession(),zt(t),mt&&window.dispatchEvent(new CustomEvent(`yuri:navigate`,{detail:{view:`chat`}}))}),Vt=Q.useMemo(()=>Rx(be,Rt,{includeWorktrees:!mt}),[Rt,mt,be]),Ht=Q.useMemo(()=>{let e=new Map(ut.map(e=>[e.id,e])),t=xt.map(t=>{let n=e.get(t.id);return n?lr(n,t):t}),n=new Set(t.map(e=>e.id));return ut.forEach(e=>{n.has(e.id)||t.push(e)}),t.filter(e=>zx(e,Vt,{allowUnknownDirectory:!mt,allowEmptyDirectorySet:!mt}))},[xt,mt,Vt,ut]),Ut=Q.useMemo(()=>ut.map(e=>{let t=M(e.directory??null)??``;return`${e.id}:${e.title??``}:${+!!e.time?.archived}:${t}`}).join(`|`),[ut]),Wt=Q.useRef(ut);Q.useEffect(()=>{Wt.current=ut},[Ut,ut]);let Gt=Q.useMemo(()=>new Map(ut.map(e=>[e.id,e])),[ut]);Q.useEffect(()=>{let e=null,t=yt(t=>{t.type===`scheduled-task-ran`&&(e&&clearTimeout(e),e=setTimeout(()=>{let e=mn.getState().projects.find(e=>e.id===t.projectId),n=M(e?.path??null);if(!n)return;let r=[n];(cr.getState().availableWorktreesByProject.get(n)??[]).forEach(e=>{let t=M(e.path);t&&r.push(t)}),Zn(r,Wt.current)},500))});return()=>{e&&clearTimeout(e),t()}},[]);let Kt=Q.useMemo(()=>v(),[]),qt=Bs(e=>e.sidebarBrandName.trim().length>0),{isTablet:Jt,isDesktop:Yt}=go(),Xt=e||Jt,{buildGroupSearchText:Qt,filterSessionNodesForSearch:$t,buildGroupedSessions:en}=Tc({homeDirectory:ge,worktreeMetadata:Pt,pinnedSessionIds:H,gitBranches:lt,isVSCode:mt}),{scheduleCollapsedProjectsPersist:nn,hasRestoredProjectCollapse:rn}=Vv({isVSCode:mt,safeStorage:D,keys:{sessionExpanded:Mx,sessionExpandedLegacy:Nx,projectCollapse:Ox,groupOrder:kx,projectActiveSession:jx,groupCollapse:Ax},groupOrderByProject:W,activeSessionByProject:ue,collapsedGroups:U,setExpandedParents:E,setCollapsedProjects:k}),an=Q.useMemo(()=>[...Ht].sort((e,t)=>io(e,t,H)),[Ht,H]),on=Q.useMemo(()=>{let e=new Map;return an.forEach(t=>{let n=t.parentID;if(!n)return;let r=e.get(n)??[];r.push(t),e.set(n,r)}),e.forEach(e=>e.sort((e,t)=>io(e,t,H))),e},[an,H]),sn=(0,$.jsxs)(`div`,{className:`py-6 text-center text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold`,children:o(`sessions.sidebar.empty.noSessions.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1`,children:o(`sessions.sidebar.empty.noSessions.description`)})]}),cn=Q.useMemo(()=>be.find(e=>e.id===S)??null,[be,S]),ln=Q.useCallback(e=>{S&&Me(S,{label:e.label,icon:e.icon,color:e.color,iconBackground:e.iconBackground,defaultModel:e.defaultModel??null})},[S,Me]),un=Q.useCallback(()=>{I(!0)},[I]),fn=Q.useCallback((t,n)=>{if(Fe(`chat`),e&&ze(!1),!n?.remote){if(n?.sessionId){At(n.sessionId,t);return}zt({directoryOverride:t,preserveDirectoryOverride:!0})}},[e,zt,Fe,At,ze]),pn=K(()=>{let e=As.getState();if(e.available&&e.info){l(!0);return}e.checkForUpdates().then(()=>{let{available:e,error:t}=As.getState();if(t){J.error(o(`sessions.sidebar.updateCheck.errorTitle`),{description:t});return}if(!e){J.success(o(`sessions.sidebar.updateCheck.latestVersion`));return}l(!0)})}),hn=Q.useCallback(()=>{e&&ze(!1),Re(!0)},[e,ze,Re]),gn=K(()=>{let t=xe.find(e=>e.id===mn.getState().activeProjectId);if(t){tc(t,e).catch(e=>J.error(e instanceof Error?e.message:String(e)));return}dn.getState().clearRemoteSession(),Fe(`chat`),zt(),e&&ze(!1)}),_n=Q.useCallback(()=>{if(!e){Fe(`schedule`);return}Be(!0),ze(!1)},[e,Fe,Be,ze]),vn=Q.useCallback(()=>{Dr(),e&&ze(!1)},[e,ze]),yn=cr(e=>e.archiveSession),bn=cr(e=>e.archiveSessions),{copiedSessionId:xn,handleSessionSelect:Cn,handleSessionDoubleClick:Tn,handleSaveEdit:Dn,handleCancelEdit:On,handleShareSession:kn,handleCopyShareUrl:An,handleUnshareSession:jn,handleDeleteSession:Mn,confirmDeleteSession:Nn}=Fv({activeProjectId:ke,currentDirectory:_e,currentSessionId:wt,mobileVariant:e,allowReselect:n,onSessionSelected:t,isSessionSearchOpen:u,sessionSearchQuery:f,setSessionSearchQuery:m,setIsSessionSearchOpen:d,setActiveProjectIdOnly:je,setDirectory:ve,setActiveMainTab:Fe,setSessionSwitcherOpen:ze,setCurrentSession:At,updateSessionTitle:jt,shareSession:Mt,unshareSession:Nt,archiveSession:yn,archiveSessions:bn,childrenMap:on,showDeletionDialog:He,setDeleteSessionConfirm:ne,deleteSessionConfirm:te,setEditingId:y,setEditTitle:x,editingId:_,editTitle:b}),Pn=Q.useCallback((e,t,n,r=`project`)=>{dn.getState().clearRemoteSession();let i={sessionId:e,scope:r,projectId:n??null};if(e===wt){It(e),nx(i),Cn(e,t,n);return}ex(i,()=>Cn(e,t,n))},[Cn,wt]);Q.useEffect(()=>()=>{$b()},[]);let Fn=Q.useCallback(()=>{if(!re)return;let{scopeKey:e,folderId:t}=re;ie(null),tt(e,t)},[re,tt]);Q.useEffect(()=>{if(!wt)return;let e=Ht.find(e=>e.id===wt)?.parentID;if(!e)return;let t=[`project:active:${e}`,`project:archived:${e}`,`recent:active:${e}`,`recent:archived:${e}`];E(e=>{if(t.every(t=>e.has(t)))return e;let n=new Set(e);t.forEach(e=>n.add(e));try{D.setItem(Mx,JSON.stringify(Array.from(n)))}catch{}return n})},[wt,Ht,D]);let Ln=Q.useCallback(e=>{E(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{D.setItem(Mx,JSON.stringify(Array.from(n)))}catch{}return n})},[D]),Rn=Q.useCallback((e,t)=>{if(!e)return null;t&&Je.has(t)&&ot(t);let n=$e(e,o(`sessions.sidebar.folder.newFolderName`),t);return ee(n.id),V(n.name),n},[Je,ot,$e,o]),zn=K(Pn),Bn=K(Tn),Vn=K(Dn),Hn=K(On),Un=K(kn),Gn=K(An),qn=K(jn),Jn=K(Mn),Yn=K(Rn),Qn=K((e,t,n,r)=>{let i=Qc(),a=Math.max(i,n)+7;if(P(e=>{let r=Math.max(i,e.get(t)??i,n),a=new Map(e);return a.set(t,r+7),a}),e.isArchivedBucket||a<r)return;let o=M(e.directory??null);if(!o)return;let s=wr.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&Wn(o)}),$n=K(e=>{P(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})}),er=K(e=>{P(t=>{let n=!1,r=new Map(t),i=`${e}:`;for(let e of r.keys())e.startsWith(i)&&(r.delete(e),n=!0);return n?r:t})}),tr=Q.useMemo(()=>e=>{let t=be.find(t=>t.id===e),n=M(t?.path??null);if(!n)return[];let r=[n];return mt||(Rt.get(n)??[]).forEach(e=>{let t=M(e.path);t&&r.push(t)}),r},[Rt,mt,be]),nr=K(e=>{let t=tr(e);if(t.length===0)return;let n=wr.getState().loadedDirectories,r=t.filter(e=>!n.has(e));r.length!==0&&Zn(r,Wt.current)}),ir=K(e=>{let t=be.find(t=>t.id===e);t&&(async()=>{let e=[];if(!mt)try{e=(await ls({id:t.id,path:t.path})).worktrees}catch(n){console.warn(`[SessionSidebar] Worktree refresh before session sync failed:`,n);let r=M(t.path);e=r?cr.getState().availableWorktreesByProject.get(r)??[]:[]}let n=wx(t.path,e,{currentDirectory:_e,workspaceRoot:t.path,includeWorktrees:!mt});n.length!==0&&await vr(n,Wt.current)})()});Q.useEffect(()=>{if(!rn)return;let e=wr.getState(),t=be.flatMap(t=>O.has(t.id)?[]:tr(t.id).filter(t=>!e.loadedDirectories.has(t)&&!e.loadingDirectories.has(t)&&!e.refreshingDirectories.has(t)));t.length>0&&Zn(t,Wt.current)},[O,tr,rn,be]);let ar=K(()=>{he.current=Date.now()+150,P(new Map),k(()=>{let e=new Set(be.map(e=>e.id));try{D.setItem(Ox,JSON.stringify(Array.from(e)))}catch{}return mt||nn(e),e})}),sr=K(()=>{he.current=Date.now()+150,P(new Map),k(()=>{let e=new Set;try{D.setItem(Ox,JSON.stringify([]))}catch{}return mt||nn(e),e});let e=wr.getState().loadedDirectories,t=be.flatMap(t=>tr(t.id).filter(t=>!e.has(t)));t.length>0&&Zn(t,Wt.current)}),ur=K(e=>{he.current=Date.now()+150,er(e),k(t=>{let n=new Set(t);n.has(e)?(n.delete(e),queueMicrotask(()=>nr(e))):n.add(e);try{D.setItem(Ox,JSON.stringify(Array.from(n)))}catch{}return mt||nn(n),n})}),dr=K(e=>{he.current=Date.now()+150,nr(e),k(t=>{if(!t.has(e))return t;let n=new Set(t);n.delete(e);try{D.setItem(Ox,JSON.stringify(Array.from(n)))}catch{}return mt||nn(n),n})}),fr=Q.useMemo(()=>be.map(e=>({...e,normalizedPath:M(e.path)})).filter(e=>!!e.normalizedPath),[be]),pr=Q.useMemo(()=>new Map(fr.map(e=>[e.id,Er(e.normalizedPath)||e.normalizedPath])),[fr]),mr=Q.useMemo(()=>fr.map(e=>e.normalizedPath),[fr]),hr=Q.useMemo(()=>{let e=new Set(fr.map(e=>e.normalizedPath));if(!mt)for(let t of Rt.values())for(let n of t){let t=M(n.path);t&&e.add(t)}return[...e].sort()},[Rt,mt,fr]),gr=Q.useRef(null);Q.useEffect(()=>{let e=new Set(hr),t=gr.current;if(gr.current=e,!t)return;let n=hr.filter(e=>!t.has(e));if(n.length===0)return;let r=wr.getState().loadedDirectories,i=M(_e),a=fr.find(e=>e.id===ke)??fr.find(e=>e.normalizedPath===i)??null,o=new Set;i&&o.add(i),a?.normalizedPath&&(o.add(a.normalizedPath),mt||(Rt.get(a.normalizedPath)??[]).forEach(e=>{let t=M(e.path);t&&o.add(t)}));let s=n.filter(e=>o.has(e)&&!r.has(e));s.length!==0&&Zn(s,Wt.current)},[ke,Rt,_e,mt,fr,hr]);let _r=Oo(a?mr:Vx);Uv({normalizedProjects:fr,activeProjectId:ke,gitRepoStatus:_r,setProjectRepoStatus:j,setProjectRootBranches:me,enabled:a});let yr=Q.useMemo(()=>Ns(Ht,fr,Rt,mt,St),[St,Rt,mt,fr,Ht]),{getSessionsForProject:xr,getArchivedSessionsForProject:Cr}=Wv({ownership:yr}),Tr=vt||ht===`idle`||ht===`loading`,Or=Q.useRef(!1);ke&&A.has(ke)&&(Or.current=!!A.get(ke));let kr=br(e=>e.projectSortOrder),jr=Q.useMemo(()=>$c(fr,kr),[fr,kr]),{projectSections:Mr,groupSearchDataByGroup:Nr,sectionsForRender:Pr,searchMatchCount:Fr}=jv({normalizedProjects:jr,getSessionsForProject:xr,getArchivedSessionsForProject:Cr,availableWorktreesByProject:Rt,projectRepoStatus:A,projectRootBranches:pe,lastRepoStatus:Or.current,buildGroupedSessions:en,hasSessionSearchQuery:Ke,normalizedSessionSearchQuery:Ge,filterSessionNodesForSearch:$t,buildGroupSearchText:Qt,foldersMap:Ye}),Ir=(0,$.jsxs)(`div`,{className:`py-6 text-center text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold`,children:o(`sessions.sidebar.empty.noMatches.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1`,children:o(`sessions.sidebar.empty.noMatches.description`)})]});Mv({projectSections:Mr,activeProjectId:ke,activeSessionByProject:ue,setActiveSessionByProject:de,currentSessionId:wt,handleSessionSelect:Cn,newSessionDraftOpen:Dt,mobileVariant:e,openNewSessionDraft:zt,setActiveMainTab:Fe,setSessionSwitcherOpen:ze});let{getOrderedGroups:Lr}=Nv(W),Rr=Q.useRef(!1);Q.useEffect(()=>{if(Rr.current||Mr.length===0)return;let e=Mr.flatMap(e=>e.groups.filter(e=>e.isArchivedBucket).map(t=>`${e.project.id}:${t.id}`));e.length>0&&ce(t=>new Set([...t,...e])),Rr.current=!0},[Mr]);let zr=Q.useMemo(()=>{let e=new Map,t=new Map;return Mr.forEach(n=>{let r=Er(n.project.normalizedPath)||n.project.normalizedPath;n.groups.forEach(i=>{let a=i.branch&&i.branch!==`HEAD`&&i.branch!==r?i.branch:null,o={projectLabel:r,branchLabel:a},s=r=>{r.forEach(r=>{let a=n.project.normalizedPath.length;a<(t.get(r.session.id)??-1)||(e.set(r.session.id,{node:r,projectId:n.project.id,groupDirectory:i.directory,secondaryMeta:o}),t.set(r.session.id,a),r.children.length>0&&s(r.children))})};s(i.sessions)})}),e},[Mr]);Q.useLayoutEffect(()=>{if(!wt){nx(null);return}let e=ga.getState().focus;if(e?.sessionId===wt){e.scope===`project`&&!e.projectId&&nx({...e,projectId:zr.get(wt)?.projectId??null});return}nx({scope:`project`,sessionId:wt,projectId:zr.get(wt)?.projectId??null})},[wt,zr]);let Br=Q.useMemo(()=>mt?[]:Sl(Ht,H,Xe[Zc]),[mt,H,Ht,Xe]),Vr=K((e,t)=>{_||ct(Zc,Br.map(e=>e.id),e,t,{}).catch(()=>J.error(o(`sessions.order.saveFailed`)))}),Hr=Q.useMemo(()=>Ke?[]:Pc(Ht,H,ft,pt),[Ke,H,ft,Ht,pt]),{pinnedItems:Ur,inProgressItems:Wr}=Q.useMemo(()=>{let e=e=>{let t=zr.get(e.id),n=M(e.directory??null),r={session:e,children:[],worktree:Pt.get(e.id)??null};if(Ke&&$t([r],Ge).length===0)return null;let i=yr.bySessionId.get(e.id),a=i?jr.find(e=>e.id===i.projectId):void 0,o=a?Er(a.normalizedPath)||a.normalizedPath:t?.secondaryMeta?.projectLabel??null,s=cc({projectLabel:o,owner:i,sessionWorktree:Pt.get(e.id)??null,worktrees:a?Rt.get(a.normalizedPath)??[]:[],projectRootBranch:i?pe.get(i.projectId)??(a?_r.get(a.normalizedPath)?.branch:null)??null:null,isVSCode:mt})??t?.secondaryMeta??null;return{node:r,projectId:i?.projectId??t?.projectId??null,groupDirectory:i?.scopeDirectory??t?.groupDirectory??n,secondaryMeta:s}},t=t=>t.map(e).filter(e=>e!==null);return{pinnedItems:mt?[]:t(Br),inProgressItems:t(Hr)}},[Rt,$t,_r,Ke,Hr,mt,Ge,Br,pe,yr,zr,jr,Pt]),Gr=Q.useMemo(()=>[...Wr,...xe.flatMap(e=>Se.get(e.id)??[])].sort((e,t)=>In(t.node.session)-In(e.node.session)),[Wr,xe,Se]),Kr=Q.useMemo(()=>Pr.map(e=>({...e,groups:e.groups.filter(e=>!e.isArchivedBucket)})),[Pr]),qr=Q.useMemo(()=>{let e=Ke?Kr.map(e=>({...e,groups:e.groups.map(e=>({...e,sessions:Nr.get(e)?.filteredNodes??[]}))})):Kr;if(!i)return e;let t=e.find(e=>e.project.id===ke)??e[0];if(!t)return[];let n=t.groups.find(e=>e.isMain&&e.sessions.length>0)??t.groups.find(e=>e.sessions.length>0)??t.groups.find(e=>e.isMain)??t.groups[0];return n?[{...t,groups:[n]}]:[]},[ke,Nr,Ke,Kr,i]),Jr=Q.useMemo(()=>bl({sections:qr,foldersMap:Ye,getOrderedGroups:Lr,pinnedSessionIds:H,sessionOrderByScope:Xe,sessionOrderActivityByScope:Ze}),[Ye,Lr,qr,H,Ze,Xe]),Yr=Q.useMemo(()=>wl({targets:Jr,collapsedProjectIds:O,collapsedGroupKeys:U,collapsedFolderIds:Je,visibleSessionCountByGroup:N,defaultVisibleSessionCount:Qc(),hasSessionSearchQuery:Ke,alwaysVisibleSessionIds:dt}),[dt,Je,U,O,Ke,Jr,N]),Xr=Q.useMemo(()=>Ke?[]:[...Ur,...Gr].map((e,t)=>{let n=e.node.session;return{scope:`pinned`,sessionId:n.id,projectId:e.projectId,directory:M(Xn(n))??e.groupDirectory??null,visibleIndex:t}}),[Ke,Gr,Ur]),[Zr,Qr]=Q.useState(null),$r=Q.useCallback(e=>{Qr(t=>t&&t.length===e.length&&t.every((t,n)=>t===e[n])?t:[...e])},[]),ei=Q.useMemo(()=>{if(!Zr)return Xr;let e=new Set(Zr);return Xr.filter(t=>e.has(t.sessionId))},[Xr,Zr]),ti=Q.useMemo(()=>!a&&fe.current?fe.current:{pinned:ei,project:Yr},[a,ei,Yr]);Q.useLayoutEffect(()=>{a&&(fe.current=ti)},[a,ti]);let ni=Q.useMemo(()=>e?[]:ua({pinnedTargets:ti.pinned,projectTargets:ye.flatMap(e=>e.hostId?Ee.get(e.id)??[]:ti.project.filter(t=>t.projectId===e.id))}),[e,ti,ye,Ee]),ri=Q.useCallback(t=>{let n=xe.find(e=>e.id===t.projectId);if(n&&Te.registry){let r=Se.get(n.id)?.find(e=>e.identity===t.sessionId);ec(n,Te.registry,r?.remoteSessionId??t.sessionId,t.directory??n.path,e);return}Fe(`chat`),ze(!1),t.scope===`project`&&t.projectId&&je(t.projectId),Pn(t.sessionId,t.directory,t.projectId,t.scope)},[Pn,Fe,je,ze,xe,Te.registry,Se,e]);Q.useLayoutEffect(()=>ea({targets:ni,activate:ri}),[ri,ni]);let ii=Q.useMemo(()=>{let e=new Map;return ni.forEach(t=>{let n=Gi({scope:t.scope,sessionId:t.sessionId,projectId:t.projectId});n&&e.set(n,Vi(ni,t)??0)}),e},[ni]),ai=Q.useMemo(()=>{if(!wt||Ke)return[];let e=[],t=(n,r)=>{if(n.session.id===wt){e.push({scope:`pinned`,sessionId:wt,projectId:r});return}n.children.forEach(e=>t(e,r))};return Ur.forEach(e=>t(e.node,e.projectId)),Wr.forEach(e=>t(e.node,e.projectId)),e},[wt,Ke,Wr,Ur]),oi=Q.useMemo(()=>{if(!wt)return[];let e=[],t=(n,r)=>{if(n.session.id===wt){e.push({scope:`project`,sessionId:wt,projectId:r});return}n.children.forEach(e=>t(e,r))};return Mr.forEach(e=>{e.groups.forEach(n=>{n.sessions.forEach(n=>t(n,e.project.id))})}),e},[wt,Mr]);Q.useLayoutEffect(()=>na({pinned:ti.pinned,project:ti.project}),[ti]),Q.useLayoutEffect(()=>{!a||Tr||nx(Ex({currentSessionId:wt,focus:Tt,pinnedFocuses:ai,projectFocuses:oi,fallbackProjectId:wt?zr.get(wt)?.projectId??null:null}))},[wt,a,Tr,oi,ai,Tt,zr]);let si=Q.useMemo(()=>{let e=Tt?.sessionId?zr.get(Tt.sessionId)?.projectId??null:null;return Dx(Tt,Jr,e)},[Jr,Tt,zr]),ci=Q.useRef(null),li=Q.useRef(null);Q.useEffect(()=>{li.current&&li.current!==wt&&(li.current=null)},[wt]),Q.useLayoutEffect(()=>{if(!si?.projectId)return;let e=si.sessionId,t=Et.sessionId===e;if(!(!t&&wt!==e)){if(t){if(ci.current===Et.revision)return;ci.current=Et.revision,li.current=e}else{if(li.current===e)return;li.current=e}if(dr(si.projectId),si.groupKey&&ce(e=>{if(!e.has(si.groupKey))return e;let t=new Set(e);return t.delete(si.groupKey),t}),si.folderAncestorIds?.forEach(e=>{let t=or.getState();t.collapsedFolderIds.has(e)&&t.toggleFolderCollapse(e)}),si.groupKey&&si.visibleIndex!==void 0){let e=si.visibleIndex+1;P(t=>{if((t.get(si.groupKey)??0)>=e)return t;let n=new Map(t);return n.set(si.groupKey,e),n})}}},[wt,si,Et]);let ui=Ux((t,n=0,r,i,a=!1,o,s=`project`,c)=>(0,$.jsx)(gx,{node:t,depth:n,groupDirectory:r,projectId:i,archivedBucket:a,currentSessionId:wt,pinnedSessionIds:H,expandedParents:T,hasSessionSearchQuery:Ke,normalizedSessionSearchQuery:Ge,notifyOnSubtasks:Ve,editingId:_,setEditingId:y,editTitle:b,setEditTitle:x,handleSaveEdit:Vn,handleCancelEdit:Hn,toggleParent:Ln,handleSessionSelect:zn,handleSessionDoubleClick:Bn,togglePinnedSession:se,handleShareSession:Un,copiedSessionId:xn,handleCopyShareUrl:Gn,handleUnshareSession:qn,openSidebarMenuKey:L,setOpenSidebarMenuKey:R,renamingFolderId:z,getFoldersForScope:Qe,getSessionFolderId:st,removeSessionFromFolder:it,addSessionToFolder:nt,createFolderAndStartRename:Yn,handleDeleteSession:Jn,mobileVariant:e,alwaysShowActions:Xt,renderSessionNode:ui,secondaryMeta:o,renderContext:s,subtreeContainsActive:c?.subtreeContainsActive??Bx,subtreeContainsEditing:c?.subtreeContainsEditing??Bx,menuOpenSessionId:c?.menuOpenSessionId??null,nodeStructureKey:c?.nodeStructureKey??``,childRenderExtrasFor:c?.childRenderExtrasFor,liveSessionById:Gt,shortcutNumber:ii.get(Gi({scope:s,sessionId:t.session.id,projectId:i??null})??``)??null},`${s}:${i??``}:${t.session.id}`),JSON.stringify([...ii])),di=Q.useCallback(e=>{$n(e),ce(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[$n]),fi=Q.useCallback(e=>{let t=tr(e);if(t.length===0)return;let n=wr.getState(),r=t.filter(e=>!n.archivedLoadedDirectories.has(e));r.length>0&&rr(r)},[tr]),pi=K((e,t,n,r,i)=>{let a=e.folderScopeKey??M(e.directory??null);a&&ct(a,t,n,r,i).catch(()=>J.error(o(`sessions.order.saveFailed`)))}),mi=K((e,t,n)=>{e.isArchivedBucket&&U.has(t)&&n&&fi(n),di(t)}),hi=Q.useMemo(()=>(t,n,r,i,a,o,s)=>(0,$.jsx)(ul,{group:t,groupKey:n,isArchivedLoading:!!(t.isArchivedBucket&&r&&tr(r).some(e=>bt.has(e))),projectId:r,projectLabel:r?pr.get(r)??null:null,hideGroupLabel:i,compactBodyPadding:o,hasSessionSearchQuery:Ke,normalizedSessionSearchQuery:Ge,groupSearchDataByGroup:Nr,visibleSessionCount:N.get(n),collapsedGroups:U,collapsedFolderIds:Je,toggleFolderCollapse:ot,renameFolder:et,deleteFolder:tt,showDeletionDialog:He,setDeleteFolderConfirm:ie,renderSessionNode:ui,projectRepoStatus:A,lastRepoStatus:Or.current,showMoreGroupSessions:Qn,resetGroupSessionLimit:$n,mobileVariant:e,alwaysShowActions:Xt,activeProjectId:ke,setActiveProjectIdOnly:je,setActiveMainTab:Fe,setSessionSwitcherOpen:ze,openNewSessionDraft:Bt,addSessionToFolder:nt,createFolderAndStartRename:Yn,renamingFolderId:z,renameFolderDraft:B,setRenameFolderDraft:V,setRenamingFolderId:ee,pinnedSessionIds:H,expandedParents:T,sessionOrderByScope:Xe,sessionOrderActivityByScope:Ze,onReorderSessions:pi,currentSessionId:wt,shortcutTargetSessionId:si?.groupKey===n?si.sessionId:null,shortcutTargetVisibleIndex:si?.groupKey===n?si.visibleIndex??null:null,editingId:_,editTitle:b,openSidebarMenuKey:L,liveSessionById:Gt,alwaysVisibleSessionIds:dt,onToggleCollapsedGroup:mi,dragHandleProps:a,scrollContainerRef:s}),[Ke,Ge,Nr,pr,bt,tr,N,U,Je,ot,et,tt,He,ui,A,Qn,$n,e,Xt,ke,je,Fe,ze,Bt,nt,Yn,z,B,H,T,Xe,Ze,pi,wt,si,_,b,L,Gt,dt,mi]),gi=r?null:(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(ry,{collapseAllProjects:ar,expandAllProjects:sr}),(0,$.jsx)(Y,{variant:`ghost`,size:`xs`,className:`size-6 p-0 text-muted-foreground`,"aria-label":o(`sessions.sidebar.header.actions.addProject`),title:o(`sessions.sidebar.header.actions.addProject`),onClick:Kn.requestDirectoryDialog,children:(0,$.jsx)(Z,{name:`add`,className:`size-4`})})]}),_i=Kt&&qt&&!mt&&!Ke?(0,$.jsx)(`div`,{className:`shrink-0 px-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(Qd,{className:`min-w-0 flex-1`}),(0,$.jsx)(pl,{className:`ml-auto shrink-0`})]})}):null,vi=!mt&&!Ke,yi=vi&&Yt&&!e,bi=!Ke&&(Ur.length>0||Gr.length>0),xi=(0,$.jsxs)(`div`,{className:`space-y-0.5 py-1`,children:[(0,$.jsxs)(Y,{variant:`ghost`,size:`sm`,className:X(`w-full justify-start px-2 font-normal`,e&&`h-11`),onClick:gn,children:[(0,$.jsx)(Z,{name:`chat-new`,className:`size-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`sessions.sidebar.header.actions.newSession`)})]}),(0,$.jsxs)(Y,{variant:`ghost`,size:`sm`,className:X(`w-full justify-start px-2 font-normal`,Ie===`schedule`&&`bg-interactive-selection text-interactive-selection-foreground`,e&&`h-11`),onClick:_n,children:[(0,$.jsx)(Z,{name:`time`,className:`size-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`sessions.sidebar.header.actions.scheduledTasks`)}),a?(0,$.jsx)(gv,{}):null]}),Le.data?.supported&&Le.data?.enabled?(0,$.jsxs)(Y,{variant:`ghost`,size:`sm`,className:X(`w-full justify-start px-2 font-normal`,Ie===`assistant`&&`bg-interactive-selection text-interactive-selection-foreground`,e&&`h-11`),onClick:vn,children:[(0,$.jsx)(al,{className:`size-4 shrink-0 [&[data-assistant-navigation-avatar]]:scale-125`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`assistants.title`)}),(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,$.jsx)(jl,{className:`h-3.5 min-w-3.5 px-1 text-[10px]`}),a?(0,$.jsx)(_v,{}):null]})]}):null,(0,$.jsx)(gl,{sidebar:!0,mobile:e})]}),Si=vi&&!yi||bi?(0,$.jsxs)($.Fragment,{children:[vi&&!yi?(0,$.jsxs)($.Fragment,{children:[e&&qt?(0,$.jsx)(Qd,{}):null,xi]}):null,bi?(0,$.jsx)(Jv,{items:Ur,reorderEnabled:!0,onSessionsReordered:Vr,inProgressItems:Gr,renderSessionNode:ui,currentSessionId:wt,editingId:_,openSidebarMenuKey:L,onVisibleSessionIdsChange:$r}):null]}):null,Ci=!!(z||_||S),{selectionModeEnabled:wi,hasSelection:Ti,selectedIdsSize:Ei,bulkScopeIsArchived:Di,derivedSelectionScope:Oi,bulkScopeFolders:ki,bulkCanRemoveFromFolder:Ai,handleExitSelectionMode:ji,handleBulkMoveToFolder:Mi,handleBulkCreateFolderAndMove:Ni,handleBulkRemoveFromFolder:Pi,handleBulkDelete:Fi,confirmBulkDelete:Ii}=Cx({isInlineEditing:Ci,showDeletionDialog:He,foldersMap:Ye,addSessionsToFolder:rt,removeSessionsFromFolders:at,createFolderAndStartRename:Rn,archiveSessions:bn,setBulkDeleteConfirm:oe});return(0,$.jsxs)(`div`,{ref:h,className:X(`yuri-session-sidebar relative flex h-full flex-col text-foreground overflow-x-hidden`,e?``:`bg-transparent`),children:[(0,$.jsx)(Kv,{hideDirectoryControls:r,isSessionSearchOpen:u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchQuery:f,setSessionSearchQuery:m,hasSessionSearchQuery:Ke,searchMatchCount:Fr}),_i,yi?(0,$.jsx)(`div`,{className:`shrink-0 px-3`,children:xi}):null,a?(0,$.jsx)(Ky,{remoteProjects:xe,hostRegistry:Te.registry,projectOrderIds:$c(ye,kr).map(e=>e.id),onRemoteActivityItems:we,remoteSearch:f,remoteError:Te.catalog.error?.message,onRemoteNavigationTargets:Oe,topContent:Si,hasLeadingSection:Si!==null&&(Ur.length>0||Wr.length>0),headerAccessory:gi,sectionsForRender:Kr,projectSections:Mr,activeProjectId:ke,projectRevealTarget:kt,showOnlyMainWorkspace:i,hasSessionSearchQuery:Ke,emptyState:sn,searchEmptyState:Ir,renderGroupSessions:hi,homeDirectory:ge,collapsedProjects:O,hideDirectoryControls:r,projectRepoStatus:A,mobileVariant:e,alwaysShowActions:Xt,toggleProject:ur,setActiveProjectIdOnly:je,setActiveMainTab:Fe,setSessionSwitcherOpen:ze,openNewSessionDraft:Bt,openNewWorktreeDialog:un,syncProjectSessions:ir,openProjectEditDialog:C,removeProject:Ae,projectReorderEnabled:kr===`manual`,reorderProjects:Ne,projectSortOrder:kr,getOrderedGroups:Lr,setGroupOrderByProject:le,openSidebarMenuKey:L,setOpenSidebarMenuKey:R,isInlineEditing:Ci}):null,wi&&Ti?(0,$.jsx)(Sx,{selectedCount:Ei,scopeKey:Oi,scopeFolders:ki,archivedBucket:Di,onMoveToFolder:Mi,onCreateFolderAndMove:Ni,onRemoveFromFolder:Pi,canRemoveFromFolder:Ai,onDelete:Fi,onDone:ji}):null,(0,$.jsx)(Sv,{normalizedProjects:fr,ownership:yr,enabled:a}),(0,$.jsx)(Iy,{onOpenSettings:hn,onOpenShortcuts:G,onOpenUpdate:pn,showRuntimeButtons:!mt,showUpdateButton:qe}),c?(0,$.jsx)(Wx,{onOpenChange:l}):null,cn?(0,$.jsx)(Gv,{open:!0,onOpenChange:e=>{e||C(null)},project:cn,onSave:ln}):null,F?(0,$.jsx)(aa,{open:!0,onOpenChange:I,onWorktreeCreated:fn}):null,(0,$.jsx)(Wc,{}),(0,$.jsx)(Hs,{}),(0,$.jsx)(yx,{value:te,setValue:ne,showDeletionDialog:He,setShowDeletionDialog:Ue,onConfirm:Nn}),(0,$.jsx)(xx,{value:re,setValue:ie,onConfirm:Fn}),(0,$.jsx)(bx,{value:ae,setValue:oe,showDeletionDialog:He,setShowDeletionDialog:Ue,onConfirm:Ii})]})});function Kx(e){return{info:e.info,downloading:e.downloading,downloaded:e.downloaded,progress:e.progress,error:e.error,runtimeType:e.runtimeType,onDownload:e.downloadUpdate,onRestart:e.restartToUpdate}}var qx=e=>e?(0,$.jsx)(`span`,{className:`text-foreground/80 dark:text-foreground/70`,children:e}):void 0,Jx=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.replace(/\/+$/,``)},Yx=()=>{let{t:e}=Zt(),[t,n]=Q.useState(!1),[r,i]=Q.useState(),[a,o]=Q.useState(null),[s,c]=Q.useState([]),[l,u]=Q.useState(!1),[d,f]=Q.useState(!1),[p,m]=Q.useState(!1),[h,g]=Q.useState(!1),[_,v]=Q.useState(new Set),y=cr(e=>e.getWorktreeMetadata),b=cr(e=>e.newSessionDraft),x=cr(e=>e.setNewSessionDraftTarget),S=cr(e=>e.setDraftBootstrapPendingDirectory),C=un,w=cr(e=>e.archiveSessions),T=q(e=>e.showDeletionDialog),E=q(e=>e.setShowDeletionDialog),D=Pe(e=>e.currentDirectory),O=Pe(e=>e.homeDirectory),k=mn(e=>e.projects),A=mn(e=>e.activeProjectId),{isMobile:j,isTablet:M,hasTouchInput:N}=go(),P=j||M||N,F=Q.useMemo(()=>Jx((A?k.find(e=>e.id===A)??null:null)?.path??D),[A,D,k]),I=Q.useCallback(e=>{let t=Jx(e.projectDirectory)||F;return{id:(k.find(e=>Jx(e.path)===t)??null)?.id??`path:${t}`,path:t}},[F,k]),L=h&&_.size>0,R=Q.useMemo(()=>{let e=a?.worktree;return e&&typeof e.branch==`string`&&e.branch.trim().length>0?!0:s.length>0&&s.every(({metadata:e})=>typeof e.branch==`string`&&e.branch.trim().length>0)},[a?.worktree,s]),z=a?.mode===`worktree`,ee=z,B=p||!z||!R,V=p||!z,te=Q.useCallback(e=>{o({sessions:e.sessions,dateLabel:e.dateLabel,mode:e.mode??`session`,worktree:e.worktree??null})},[]),ne=Q.useCallback(()=>{o(null),c([]),u(!1),f(!1),m(!1),g(!1),v(new Set)},[]),re=Q.useCallback(t=>{if(t.sessions.length===0)return;let n=t.sessions.map(e=>e.id);il({sessionIds:n,message:n.length===1?e(`sessions.sidebar.session.delete.success`):e(`sessions.sidebar.bulkActions.deletedPlural`,{count:n.length}),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:n.length===1?e(`sessions.sidebar.session.delete.error`):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:n.length})})},[e]);Q.useEffect(()=>Kn.onDeleteRequest(e=>{if(!T&&(e.mode??`session`)===`session`){re(e);return}te(e)}),[te,T,re]),Q.useEffect(()=>Kn.onDirectoryRequest(({origin:e})=>{i(e),n(!0)}),[]),Q.useEffect(()=>{if(!a){c([]),u(!1),f(!1),g(!1),v(new Set);return}let e=a.sessions.map(e=>{let t=y(e.id);return t?{session:e,metadata:t}:null}).filter(e=>!!e);c(e),u(!1),g(!1),v(new Set);let t=new Map;if(a.worktree?.path&&t.set(Jx(a.worktree.path),a.worktree),e.forEach(({metadata:e})=>{e.path&&t.set(Jx(e.path),e)}),t.size===0){g(!0);return}let n=!1;return(async()=>{let e=new Map,r=new Set;await Promise.all(Array.from(t.entries()).map(async([t,n])=>{try{let i=await cs(n.path);e.set(t,i),i?.isDirty&&r.add(t)}catch{n.status&&(e.set(t,n.status),n.status.isDirty&&r.add(t))}})).catch(e=>{console.warn(`Failed to inspect worktree status before deletion:`,e)}),!n&&(v(r),g(!0),o(t=>{if(!t?.worktree?.path)return t;let n=Jx(t.worktree.path),r=e.get(n);if(!r)return t;let i=t.worktree.status;return i?.isDirty===r.isDirty&&i?.ahead===r.ahead&&i?.behind===r.behind&&i?.upstream===r.upstream?t:{...t,worktree:{...t.worktree,status:r}}}),c(t=>t.map(t=>{let n=Jx(t.metadata.path),r=e.get(n);return r?{session:t.session,metadata:{...t.metadata,status:r}}:t})))})(),()=>{n=!0}},[a,y]),Q.useEffect(()=>{R||u(!1)},[R]);let ie=Q.useCallback(async(t,n)=>{let r=l&&R,i=I(t),a=Jx(t.path),o=Jx(i.path);try{await ss(i,t,{deleteRemoteBranch:r,deleteLocalBranch:n});let e=Jx(b?.directoryOverride);return b?.open&&a&&e===a&&o&&(S(null),x({projectId:i.id,directoryOverride:o},{force:!0})),Jx(D)===a&&o&&Pe.getState().setDirectory(o,{showOverlay:!1}),!0}catch(t){return J.error(e(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:qx(t instanceof Error?t.message:e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),!1}},[R,D,l,I,b?.directoryOverride,b?.open,S,x,e]),ae=Q.useCallback((t,n)=>{let r=l&&R;(async()=>{if(!await ie(t,n))return;let i=e(r?`sessions.sidebar.sessionDialogs.worktree.removedWithRemote`:`sessions.sidebar.sessionDialogs.worktree.removed`);J.success(e(`sessions.sidebar.sessionDialogs.worktree.removedTitle`),{description:qx(i)})})()},[R,l,ie,e]),oe=Q.useCallback(async()=>{if(a){m(!0);try{let t=ee&&d;if(a.sessions.length===0&&z&&a.worktree){ae(a.worktree,t),ne();return}if(a.sessions.length===1){let t=a.sessions[0];if(z){if(!await C(t.id)){J.error(e(`sessions.sidebar.session.archive.error`)),m(!1);return}nl({sessionIds:[t.id],message:e(`sessions.sidebar.session.archive.success`),undoLabel:e(`sessions.sidebar.undo`),settingsLabel:e(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:e(`sessions.sidebar.session.archive.undoFailed`)})}else il({sessionIds:[t.id],message:e(`sessions.sidebar.session.delete.success`),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:e(`sessions.sidebar.session.delete.error`)})}else{let n=a.sessions.map(e=>e.id),r=[],i=[];if(z){let e=await w(n);r=e.archivedIds,i=e.failedIds}else il({sessionIds:n,message:n.length===1?e(`sessions.sidebar.bulkActions.deletedSingle`,{count:n.length}):e(`sessions.sidebar.bulkActions.deletedPlural`,{count:n.length}),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:n.length===1?e(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:n.length}):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:n.length})}),r=n,i=[];if(z&&a.worktree&&i.length===0&&ae(a.worktree,t),z&&r.length>0&&nl({sessionIds:r,message:r.length===1?e(`sessions.sidebar.bulkActions.archivedSingle`,{count:r.length}):e(`sessions.sidebar.bulkActions.archivedPlural`,{count:r.length}),undoLabel:e(`sessions.sidebar.undo`),settingsLabel:e(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:r.length===1?e(`sessions.sidebar.session.archive.undoFailed`):e(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:r.length})}),i.length>0&&(J.error(z?i.length===1?e(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):e(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}):i.length===1?e(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:i.length}):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:i.length}),{description:qx(e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),r.length===0)){m(!1);return}}z&&a.sessions.length===1&&a.worktree&&ae(a.worktree,t),ne()}finally{m(!1)}}},[a,d,C,w,ne,ee,z,ae,e]),H=a?.worktree??s[0]?.metadata??null,se=a?a.mode===`worktree`?a.sessions.length===0?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked`):a.sessions.length===1?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked`,{count:a.sessions.length}):e(`sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked`,{count:a.sessions.length}):a.sessions.length===1?a.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate`,{dateLabel:a.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionOne`):a.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate`,{count:a.sessions.length,dateLabel:a.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionMany`,{count:a.sessions.length}):``,U=a?(0,$.jsxs)(`div`,{className:X(z?`space-y-3`:`space-y-2`),children:[a.sessions.length>0&&(0,$.jsxs)(`div`,{className:X(z?`rounded-lg bg-muted/30 p-3`:`space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3`),children:[z&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:a.sessions.length===1?e(`sessions.sidebar.sessionDialogs.linkedSessionSingle`):e(`sessions.sidebar.sessionDialogs.linkedSessionPlural`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:a.sessions.length})]}),(0,$.jsxs)(`ul`,{className:X(z?`mt-2 space-y-1`:`space-y-0.5`),children:[a.sessions.slice(0,5).map(t=>(0,$.jsxs)(`li`,{className:X(z?`flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground`:`typography-micro text-muted-foreground/80`),children:[(0,$.jsx)(`span`,{className:X(!z&&`hidden`),children:`•`}),(0,$.jsx)(`span`,{className:`truncate`,children:t.title||e(`sessions.sidebar.session.untitled`)})]},t.id)),a.sessions.length>5&&(0,$.jsx)(`li`,{className:X(z?`px-2.5 py-1 text-xs text-muted-foreground/70`:`typography-micro text-muted-foreground/70`),children:e(`sessions.sidebar.dialogs.sessionList.more`,{count:a.sessions.length-5})})]})]}),z?(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg bg-muted/30 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:e(`sessions.sidebar.sessionDialogs.worktree.label`)}),H?.label?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:H.label}):null]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/80 break-all`,children:H?an(H.path,O):e(`sessions.sidebar.sessionDialogs.worktree.pathUnavailable`)}),L&&(0,$.jsx)(`p`,{className:`typography-micro text-status-warning`,children:e(`sessions.sidebar.sessionDialogs.worktree.uncommittedWarning`)})]}):(0,$.jsx)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/60 p-3`,children:(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/80`,children:e(`sessions.sidebar.sessionDialogs.delete.note`)})})]}):null,ce=z?R?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{B||u(e=>!e)},disabled:B,className:X(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,B?`cursor-not-allowed opacity-60`:`hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),children:[l?(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}):(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}),e(`sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch`)]}):(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:e(`sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable`)}):null,W=z?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{V||f(e=>!e)},disabled:V,className:X(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,V?`cursor-not-allowed opacity-60`:`hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),children:[d?(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}):(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}),e(`sessions.sidebar.sessionDialogs.actions.deleteLocalBranch`)]}):null,le=z?(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[W,ce]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{variant:`ghost`,onClick:ne,disabled:p,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{variant:`destructive`,onClick:oe,disabled:p,children:e(p?`sessions.sidebar.sessionDialogs.actions.deleting`:`sessions.sidebar.sessionDialogs.actions.deleteWorktree`)})]})]}):(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>E(!T),className:`inline-flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":!T,children:[T?(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}):(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}),e(`sessions.sidebar.dialogs.neverAsk`)]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{variant:`ghost`,onClick:ne,disabled:p,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{variant:`destructive`,onClick:oe,disabled:p,children:p?e(`sessions.sidebar.sessionDialogs.actions.deleting`):a?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`)})]})]}),ue=z?e(`sessions.sidebar.sessionDialogs.actions.deleteWorktree`):a?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`);return(0,$.jsxs)($.Fragment,{children:[P?(0,$.jsx)(Ua,{open:!!a,onClose:()=>{p||ne()},title:ue,footer:(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:le}),children:(0,$.jsxs)(`div`,{className:`space-y-2 pb-2`,children:[se&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/80`,children:se}),U]})}):(0,$.jsx)(Jr,{open:!!a,onOpenChange:e=>{if(!e){if(p)return;ne()}},children:(0,$.jsxs)(Gr,{className:X(z?`max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3`:`max-w-[min(520px,100vw-2rem)] space-y-2 pb-2`),children:[(0,$.jsxs)(Ur,{children:[(0,$.jsxs)(Kr,{className:X(z&&`flex items-center gap-2`),children:[z&&(0,$.jsx)(Z,{name:`delete-bin`,className:`h-5 w-5`}),ue]}),se&&(0,$.jsx)(qr,{children:se})]}),(0,$.jsx)(`div`,{className:X(z&&`flex-1 min-h-0 overflow-y-auto space-y-2`),children:U}),(0,$.jsx)(Wr,{className:`mt-2 gap-2 pt-1 pb-1`,children:le})]})}),(0,$.jsx)(Kc,{open:t,onOpenChange:n,origin:r})]})},Xx=Q.createContext(null),Zx=e=>{let t=(0,du.c)(3),{children:n,value:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(Xx.Provider,{value:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},Qx=So(()=>Pt(()=>import(`./TerminalView-FVDCLrdP.js`).then(e=>({default:e.TerminalView})),__vite__mapDeps([79,1,4,2,5,3,6,7,8,9,21,22,23,20,24,25,18,80,43,44,45,46,47,13,10,12,11,14,15,16,17,19,48,81,37,38,39,40,41,42,49,50,51,52,53,54,55,56,57,58,60,82,66,83,84,85,86,87,88,89,90,91,92]))),$x=So(()=>Pt(()=>import(`./DiagramView-BjOVH-j5.js`).then(e=>({default:e.DiagramView})),__vite__mapDeps([93,1,3,2,9,11,12,13,4,5,6,7,8,10,14,15,16,17,18,19,20,21,22,23,24,25,49,37,38,39,40,41,60,42,43,44,45,46,47,48,50,51,52,53,54,55,56,57,66,84,80,94,95]))),eS=So(()=>Pt(()=>import(`./SettingsView-CuGWlw_X.js`).then(e=>e.n).then(e=>({default:e.SettingsView})),__vite__mapDeps([96,1,2,3,4,5,6,7,8,97,98,22,9,43,23,20,24,44,45,46,47,13,10,12,11,14,15,16,17,18,19,21,25,48,99,100,101,49,37,38,39,40,41,102,42,50,51,52,53,54,55,56,57,60,103,104,105,71,106,107,68,58,59,61,62,72,108,109,110,111,112,113,69,114,82,115,83,116,117,86,87,88,76,118,119,120,65,66,67,70,27,28,29,30,31,32,33,34,35,36,85,121,122,123,124,125,126,78,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143]))),tS=So(()=>Pt(()=>import(`./SettingsWindow-DIW0AQRS.js`).then(e=>({default:e.SettingsWindow})),__vite__mapDeps([144,1,9,10,37,6,2,3,7,8,38,23,20,39,40,22,18,41,42,5,4,43,24,44,45,46,47,13,12,11,14,15,16,17,19,21,25,48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,60,103,104,105,71,106,107,68,58,59,61,62,72,108,109,110,111,112,113,69,114,82,115,83,116,117,86,87,88,76,118,119,120,65,66,67,70,27,28,29,30,31,32,33,34,35,36,85,121,122,123,124,125,126,78,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143]))),nS=So(()=>Pt(()=>import(`./MultiRunWindow-G5K_lWwa.js`).then(e=>({default:e.MultiRunWindow})),__vite__mapDeps([145,1,9,10,37,6,2,3,7,8,38,23,20,39,40,22,18,41,42,5,4,43,24,44,45,46,47,13,12,11,14,15,16,17,19,21,25,48,49,50,51,52,53,54,55,56,57,60,146,108,147,109,110,82,148,149,150,151,105,71,106,107,68,58,59,152,115,83,117,114,113,69,86,87,88,76,129]))),rS=So(()=>Pt(()=>import(`./AssistantView-vuLTK9d2.js`).then(e=>e.n).then(e=>({default:e.AssistantView})),__vite__mapDeps([153,1,2,3,6,7,8,9,10,11,12,15,16,17,21,5,22,23,20,24,25,18,49,37,38,39,40,41,102,4,13,14,19,42,43,44,45,46,47,48,50,51,52,53,54,55,56,57,60,103,104,105,71,106,107,68,58,59,61,62,72,82,154,155,149,150,151,120,65,66,67,156,64,113,69,139,157,75,73,74,115,83,158,152,159,160,161,162,163,135,116]))),iS=()=>{let e=q(e=>e.isSidebarOpen),t=q(e=>e.isRightSidebarOpen),n=q(e=>e.isBottomTerminalOpen),r=q(e=>e.setRightSidebarOpen),i=q(e=>e.setBottomTerminalOpen),a=q(e=>e.activeMainTab),o=q(e=>e.setIsMobile),s=q(e=>e.isSessionSwitcherOpen),c=q(e=>e.isSettingsDialogOpen),l=q(e=>e.setSettingsDialogOpen),u=q(e=>e.isMultiRunLauncherOpen),d=q(e=>e.setMultiRunLauncherOpen),{isMobile:f,isTablet:p}=go(),m=Q.useRef(!1),h=Q.useRef(!1),[g,_]=Q.useState(!1),[v,y]=Q.useState(!1),[b,x]=Q.useState(!1),[S,C]=Q.useState(!1),w=Q.useCallback(e=>{_(e),q.getState().setSessionSwitcherOpen(e)},[]),T=Q.useRef(!1),E=Q.useRef(typeof window>`u`?0:window.innerWidth),D=Br(-E.current),O=(0,Q.useRef)(0),k=Br(E.current),A=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{f&&(O.current=window.innerWidth,A.current=window.innerWidth)},[f]),(0,Q.useEffect)(()=>{if(!f){x(!1);return}g&&x(!0),Vr(D,g?0:-O.current,{type:`spring`,stiffness:400,damping:35,mass:.8})},[g,f,D]),(0,Q.useEffect)(()=>{if(!f){C(!1);return}T.current=v,v&&C(!0),Vr(k,v?0:A.current,{type:`spring`,stiffness:400,damping:35,mass:.8})},[f,v,k]),(0,Q.useEffect)(()=>{if(f)return D.on(`change`,e=>{let t=O.current||E.current,n=g||e>-t+.5;x(e=>e===n?e:n)})},[f,D,g]),(0,Q.useEffect)(()=>{if(f)return k.on(`change`,e=>{let t=A.current||E.current,n=v||e<t-.5;C(e=>e===n?e:n)})},[f,v,k]),(0,Q.useEffect)(()=>{f&&!s&&g&&w(!1)},[s,f,g,w]),(0,Q.useEffect)(()=>{if(!f){h.current=!1;return}h.current||(h.current=!0,w(!1),y(!1),q.getState().isRightSidebarOpen&&r(!1))},[f,w,r]),(0,Q.useEffect)(()=>{if(!f||a!==`chat`||g||v||c)return;let e=!1,t,n=r=>{t=window.setTimeout(()=>{if(e)return;let t=cr.getState(),r=q.getState();if(!(r.activeMainTab!==`chat`||r.isSettingsDialogOpen||t.currentSessionId||t.newSessionDraft?.open)){if(t.isLoading){n(250);return}t.openNewSessionDraft()}},r)};return n(500),()=>{e=!0,t!==void 0&&window.clearTimeout(t)}},[a,f,c,g,v]),(0,Q.useEffect)(()=>{!f||!c||(w(!1),y(!1),t&&r(!1))},[f,c,t,w,r]),Q.useEffect(()=>{q.getState().isMobile!==f&&o(f)},[f,o]),Q.useEffect(()=>{if(typeof window>`u`)return;let e,t=()=>{e===void 0&&(e=window.requestAnimationFrame(()=>{e=void 0,q.getState().updateProportionalSidebarWidths()}))};return window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t),e!==void 0&&window.cancelAnimationFrame(e)}},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e,t=()=>{let e=q.getState(),t=window.innerHeight;!f&&!p&&(t<640?e.isBottomTerminalOpen&&(i(!1),m.current=!0):t>=700&&m.current&&(i(!0),m.current=!1))},n=()=>{e===void 0&&(e=window.requestAnimationFrame(()=>{e=void 0,t()}))};return t(),window.addEventListener(`resize`,n),()=>{window.removeEventListener(`resize`,n),e!==void 0&&window.cancelAnimationFrame(e)}},[f,p,i]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=q.subscribe((e,t)=>{let n=window.innerHeight>=700;e.isBottomTerminalOpen!==t.isBottomTerminalOpen&&n&&(m.current=!1)});return()=>{e()}},[f,p,i]);let j=Q.useCallback(()=>{g&&w(!1),y(!v)},[g,v,w]),M=Q.useMemo(()=>{switch(a){case`git`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(lh,{isActive:!v})});case`diff`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(uc,{})});case`terminal`:return n?null:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Qx,{})});case`files`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Jf,{})});case`diagram`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)($x,{})});default:return null}},[a,n,v]),N=a===`schedule`,P=a===`assistant`,F=a===`plugin`,I=N||P||F,L=a===`chat`,R=!I&&!c;return(0,$.jsx)(qc,{children:(0,$.jsxs)(`div`,{"data-page-scroll-lock":`true`,className:X(`main-content-safe-area`,f?`flex h-[100dvh] flex-col`:`relative flex h-[100dvh]`,`bg-background`),children:[(0,$.jsx)(El,{}),(0,$.jsx)(cv,{}),(0,$.jsx)(fv,{}),(0,$.jsx)(Yx,{}),(0,$.jsx)(hl,{}),f?(0,$.jsxs)(Zx,{value:{leftDrawerOpen:g,rightDrawerOpen:v,toggleLeftDrawer:()=>{let e=!g;v&&y(!1),w(e)},toggleRightDrawer:j,leftDrawerX:D,rightDrawerX:k,leftDrawerWidth:O,rightDrawerWidth:A,setMobileLeftDrawerOpen:w,setRightSidebarOpen:y},children:[!c&&!I&&(0,$.jsx)(Ad,{onToggleLeftDrawer:()=>{let e=!g;v&&y(!1),w(e)},onToggleRightDrawer:()=>{j()},leftDrawerOpen:g,rightDrawerOpen:v}),(0,$.jsx)(`div`,{"data-page-scroll-lock":`true`,className:X(`flex flex-1 overflow-hidden relative`,c&&`hidden`),children:(0,$.jsxs)(`main`,{className:`w-full h-full overflow-hidden bg-background relative`,"data-page-scroll-lock":`true`,children:[N&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(po,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Hc,{})})})}),P&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(po,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(rS,{})})})}),R&&(0,$.jsx)(`div`,{className:X(`absolute inset-0`,!L&&`invisible`),children:(0,$.jsx)(Nc,{children:(0,$.jsx)(po,{children:(0,$.jsx)(Ec,{})})})}),R&&M&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Nc,{children:(0,$.jsx)(po,{children:M})})}),u&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(po,{children:(0,$.jsx)(tu,{onCreated:()=>d(!1),onCancel:()=>d(!1)})})}),(0,$.jsx)(ps.div,{className:X(`absolute inset-0 z-20 bg-sidebar`,!b&&`pointer-events-none invisible`),"data-page-scroll-lock":`true`,style:{x:D},"aria-hidden":!g,children:(0,$.jsx)(po,{children:(0,$.jsx)(Gx,{mobileVariant:!0,isVisible:b})})}),S&&(0,$.jsx)(ps.div,{className:`absolute inset-0 z-20 bg-sidebar`,"data-page-scroll-lock":`true`,style:{x:k},"aria-hidden":!v,children:(0,$.jsx)(po,{children:(0,$.jsx)(Nc,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(lh,{isActive:v})})})})})]})}),c&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,style:{paddingTop:`var(--yuri-safe-area-top, 0px)`},children:(0,$.jsx)(po,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(eS,{onClose:()=>l(!1)})})})}),(0,$.jsx)(po,{children:(0,$.jsx)(_l,{})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(rf,{}),(0,$.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:[(0,$.jsx)(Xd,{isOpen:e,isMobile:f,className:`border-border/50`,topBar:(0,$.jsx)(Zd,{}),children:(0,$.jsx)(Gx,{isVisible:e})}),(0,$.jsx)(`div`,{className:`relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:I?(0,$.jsx)(`main`,{className:`flex-1 overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(po,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:F?(0,$.jsx)(Ul,{}):P?(0,$.jsx)(rS,{}):(0,$.jsx)(Hc,{})})})}):(0,$.jsx)(Nc,{children:(0,$.jsxs)(ov,{header:(0,$.jsx)(Ad,{}),footer:(0,$.jsx)(Vd,{isOpen:n,isMobile:f,children:n?(0,$.jsx)(po,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Qx,{})})}):null}),children:[R&&(0,$.jsx)(`div`,{className:X(`absolute inset-0`,!L&&`invisible`),children:(0,$.jsx)(po,{children:(0,$.jsx)(Ec,{})})}),R&&M&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(po,{children:M})})]})})})]}),(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(tS,{open:c,onOpenChange:l})}),(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(nS,{open:u,onOpenChange:d})})]})]})})},aS=9e4,oS=15e3,sS=3e5,cS=[2e3,5e3],lS=6e4,uS=12e4,dS=3e5,fS=4,pS=432e5,mS=`yuri.github-pr-status`,hS=e=>e===`closed`||e===`merged`,gS=e=>{let t=e?.checks;return t?t.state===`pending`||t.pending>0:!1},_S=(e,t,n)=>`${e}::${t}`,vS=new Map,yS=new Map,bS=new Set,xS=new Map,SS=2,CS=0,wS=[],TS=()=>CS<SS?(CS+=1,Promise.resolve()):new Promise(e=>{wS.push(e)}),ES=()=>{let e=wS.shift();if(e){e();return}CS=Math.max(0,CS-1)},DS=()=>({status:null,isLoading:!1,error:null,isInitialStatusResolved:!1,lastRefreshAt:0,lastDiscoveryPollAt:0,watchers:0,params:null,identity:null,resolvedRemoteName:null}),OS=e=>e?.params?.directory&&e.params.branch?{directory:e.params.directory,branch:e.params.branch,remoteName:e.params.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null}:!e?.identity?.directory||!e.identity.branch?null:e.identity,kS=e=>{let t=OS(e);return!t?.directory||!t.branch?null:`${t.directory}::${t.branch}`},AS=(e,t)=>Object.entries(e).filter(([,e])=>kS(e)===t).map(([e])=>e),jS=(e,t)=>{let n=t.remoteName??e.params?.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null;return{...e,params:e.params?{...e.params,...t,remoteName:n}:{...t,remoteName:n},identity:{directory:t.directory,branch:t.branch,remoteName:n}}},MS=e=>!e?.params?.canShow||!e.params.github?.prStatus?null:{...e.params,remoteName:e.params.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null},NS=(e,t,n)=>{let r=AS(e,t),i=r.map(t=>MS(e[t])).filter(e=>!!e);if(i.length===0)return null;let a=MS(e[n]);if(a&&kS(e[n])===t)return a;let o=r.map(t=>e[t]).find(e=>!!(e?.resolvedRemoteName&&MS(e)));return o?MS(o):i.find(e=>!!e.remoteName)||(i[0]??null)},PS=e=>({status:e.status,isInitialStatusResolved:e.isInitialStatusResolved,lastRefreshAt:e.lastRefreshAt,lastDiscoveryPollAt:e.lastDiscoveryPollAt,identity:OS(e),resolvedRemoteName:e.resolvedRemoteName??e.status?.resolvedRemoteName??null}),FS=e=>({...DS(),status:e?.status??null,isInitialStatusResolved:e?.isInitialStatusResolved??!1,lastRefreshAt:e?.lastRefreshAt??0,lastDiscoveryPollAt:e?.lastDiscoveryPollAt??0,identity:e?.identity??null,resolvedRemoteName:e?.resolvedRemoteName??e?.status?.resolvedRemoteName??null}),IS=W()(le((e,t)=>({entries:{},activeRequestCount:0,totalRequestCount:0,ensureEntry:t=>{e(e=>e.entries[t]?e:{entries:{...e.entries,[t]:DS()}})},setParams:(t,n)=>{e(e=>{let r=e.entries[t]??DS();return{entries:{...e.entries,[t]:jS(r,n)}}})},startWatching:n=>{if(e(e=>{let t=e.entries[n]??DS();return{entries:{...e.entries,[n]:{...t,watchers:t.watchers+1}}}}),vS.has(n))return;let r=e=>{let r=window.setTimeout(()=>{if(typeof document<`u`&&document.visibilityState!==`visible`)return;let e=t().entries[n];!e||e.watchers<=0||e.status?.pr||t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0})},e),i=yS.get(n)??[];i.push(r),yS.set(n,i)};t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0}),cS.forEach(e=>r(e));let i=window.setInterval(()=>{if(typeof document<`u`&&document.visibilityState!==`visible`)return;let r=t().entries[n];if(!(!r||r.watchers<=0)){if(!r.status?.pr){let i=Date.now();if(i-r.lastDiscoveryPollAt<sS)return;e(e=>{let t=e.entries[n];return t?{entries:{...e.entries,[n]:{...t,lastDiscoveryPollAt:i}}}:e}),t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0});return}hS(r.status?.pr?.state)||Date.now()-r.lastRefreshAt<(gS(r.status)?lS:r.status?.checks&&r.status.checks.state!==`pending`?dS:uS)||t().refresh(n,{force:!0,onlyExistingPr:!0,silent:!0,markInitialResolved:!0})}},oS);vS.set(n,i)},stopWatching:n=>{e(e=>{let t=e.entries[n];if(!t)return e;let r=Math.max(0,t.watchers-1);return{entries:{...e.entries,[n]:{...t,watchers:r}}}});let r=t().entries[n];if(r&&r.watchers>0)return;let i=vS.get(n);typeof i==`number`&&window.clearInterval(i),vS.delete(n);let a=yS.get(n);a&&a.length>0&&a.forEach(e=>{window.clearTimeout(e)}),yS.delete(n)},refresh:async(n,r)=>{let i=t(),a=i.entries[n],o=kS(a);if(!a||!o)return;let s=AS(i.entries,o),c=s.some(e=>!!i.entries[e]?.status?.pr);if(r?.onlyExistingPr&&!c)return;let l=xS.get(o)??0;if(!r?.force&&Date.now()-l<aS||bS.has(o))return;let u=NS(i.entries,o,n);if(u){if(bS.add(o),xS.set(o,Date.now()),e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,lastRefreshAt:Date.now(),isLoading:!r?.silent||n.isLoading,error:null})}),{entries:t}}),u.githubAuthChecked&&u.githubConnected===!1){e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,status:{connected:!1},error:null,isLoading:r?.silent?n.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||n.isInitialStatusResolved})}),{entries:t}}),bS.delete(o);return}if(!u.github?.prStatus){e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,status:null,error:`GitHub runtime API unavailable`,isLoading:r?.silent?n.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||n.isInitialStatusResolved})}),{entries:t}}),bS.delete(o);return}try{e(e=>({...e,activeRequestCount:e.activeRequestCount+1,totalRequestCount:e.totalRequestCount+1})),await TS();let t;try{t=await u.github.prStatus(u.directory,u.branch,u.remoteName??void 0,{force:r?.force})}finally{ES()}e(e=>{let n={...e.entries};return s.forEach(e=>{let i=n[e];if(!i)return;let a=i.status?.pr,o=t.pr,s=o&&a&&o.number===a.number&&(!o.body||!o.body.trim())&&typeof a.body==`string`&&a.body.trim().length>0&&o&&a?.body?{...t,pr:{...o,body:a.body}}:t,c=s.resolvedRemoteName??i.resolvedRemoteName??u.remoteName??null,l=OS(i)??{directory:u.directory,branch:u.branch,remoteName:u.remoteName??null};n[e]={...i,status:s,error:null,isLoading:r?.silent?i.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||i.isInitialStatusResolved,resolvedRemoteName:c,identity:{...l,remoteName:c??l.remoteName??null}}}),{entries:n}})}catch(t){let n=t instanceof Error?t.message:String(t);e(e=>{let t={...e.entries};return s.forEach(e=>{let i=t[e];i&&(t[e]={...i,error:n||`Failed to load PR status`,isLoading:r?.silent?i.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||i.isInitialStatusResolved})}),{entries:t}})}finally{bS.delete(o),e(e=>({...e,activeRequestCount:Math.max(0,e.activeRequestCount-1)}))}}},refreshTargets:async(e,n)=>{await Hv(Array.from(new Set(e.map(e=>{let t=e.directory.trim(),n=e.branch.trim();return!t||!n?null:_S(t,n,e.remoteName??null)}).filter(e=>!!e))),fS,e=>t().refresh(e,n))},updateStatus:(t,n)=>{e(e=>{let r=e.entries[t]??DS();return{entries:{...e.entries,[t]:{...r,status:n(r.status)}}}})}}),{name:mS,storage:He(),partialize:e=>({entries:Object.fromEntries(Object.entries(e.entries).filter(([,e])=>{let t=OS(e);if(!t?.directory||!t.branch)return!1;let n=Math.max(e.lastRefreshAt,e.lastDiscoveryPollAt);return n===0||Date.now()-n<pS}).map(([e,t])=>[e,PS(t)]))}),merge:(e,t)=>{let n=e?.entries??{};return{...t,entries:Object.fromEntries(Object.entries(n).map(([e,t])=>[e,FS(t)]))}}})),LS=e=>{if(e<1e3)return`${Math.round(e)}ms`;let t=e/1e3;return t<60?`${t.toFixed(1)}s`:`${Math.floor(t/60)}m ${Math.round(t%60)}s`},RS=e=>{let t=(0,du.c)(8),{label:n,value:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={backgroundColor:`color-mix(in srgb, var(--surface-muted) 55%, transparent)`},t[0]=i):i=t[0];let a;t[1]===n?a=t[2]:(a=(0,$.jsx)(`div`,{className:`typography-meta text-[var(--surface-muted-foreground)]`,children:n}),t[1]=n,t[2]=a);let o;t[3]===r?o=t[4]:(o=(0,$.jsx)(`div`,{className:`typography-markdown font-semibold text-[var(--surface-foreground)]`,children:r}),t[3]=r,t[4]=o);let s;return t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`div`,{className:`rounded-md p-2`,style:i,children:[a,o]}),t[5]=a,t[6]=o,t[7]=s):s=t[7],s},zS=e=>{let t=(0,du.c)(43),{title:n,snapshot:r,emptyLabel:i}=e,{t:a}=Zt(),o;if(t[0]!==i||t[1]!==r.durationMs||t[2]!==r.entries||t[3]!==r.lastUpdatedAt||t[4]!==r.startedAt||t[5]!==a||t[6]!==n){let e=r.entries.slice(0,12),s;t[8]===r.entries?s=t[9]:(s=r.entries.reduce(VS,0),t[8]=r.entries,t[9]=s);let c=s,l;t[10]===n?l=t[11]:(l=(0,$.jsx)(`div`,{className:`typography-ui-label font-semibold text-[var(--surface-foreground)]`,children:n}),t[10]=n,t[11]=l);let u;t[12]!==r.durationMs||t[13]!==r.startedAt||t[14]!==a?(u=r.startedAt?LS(r.durationMs):a(`memoryDebugPanel.common.idle`),t[12]=r.durationMs,t[13]=r.startedAt,t[14]=a,t[15]=u):u=t[15];let d;t[16]===u?d=t[17]:(d=(0,$.jsx)(`div`,{className:`typography-meta text-[var(--surface-muted-foreground)]`,children:u}),t[16]=u,t[17]=d);let f;t[18]!==l||t[19]!==d?(f=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[l,d]}),t[18]=l,t[19]=d,t[20]=f):f=t[20];let p;t[21]===a?p=t[22]:(p=a(`memoryDebugPanel.metric.metrics`),t[21]=a,t[22]=p);let m;t[23]!==r.entries.length||t[24]!==p?(m=(0,$.jsx)(RS,{label:p,value:r.entries.length}),t[23]=r.entries.length,t[24]=p,t[25]=m):m=t[25];let h;t[26]===a?h=t[27]:(h=a(`memoryDebugPanel.metric.samples`),t[26]=a,t[27]=h);let g;t[28]!==h||t[29]!==c?(g=(0,$.jsx)(RS,{label:h,value:c}),t[28]=h,t[29]=c,t[30]=g):g=t[30];let _;t[31]===a?_=t[32]:(_=a(`memoryDebugPanel.metric.lastUpdate`),t[31]=a,t[32]=_);let v;t[33]!==r.lastUpdatedAt||t[34]!==a?(v=r.lastUpdatedAt?a(`memoryDebugPanel.common.live`):a(`memoryDebugPanel.common.notAvailable`),t[33]=r.lastUpdatedAt,t[34]=a,t[35]=v):v=t[35];let y;t[36]!==_||t[37]!==v?(y=(0,$.jsx)(RS,{label:_,value:v}),t[36]=_,t[37]=v,t[38]=y):y=t[38];let b;t[39]!==g||t[40]!==y||t[41]!==m?(b=(0,$.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[m,g,y]}),t[39]=g,t[40]=y,t[41]=m,t[42]=b):b=t[42],o=(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0`,children:[f,b,e.length===0?(0,$.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}):(0,$.jsx)(es,{outerClassName:`max-h-64`,className:`pr-1`,children:(0,$.jsx)(`div`,{className:`space-y-1`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`rounded-md border border-[var(--interactive-border)] p-2`,style:{backgroundColor:`color-mix(in srgb, var(--surface-elevated) 88%, transparent)`},children:[(0,$.jsx)(`div`,{className:`typography-meta font-medium text-[var(--surface-foreground)] break-all`,children:e.metric}),(0,$.jsxs)(`div`,{className:`mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]`,children:[(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.countValue`,{value:e.count})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.avgValue`,{value:e.avg})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.maxValue`,{value:e.max})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.totalValue`,{value:e.total})})]})]},e.metric))})})]}),t[0]=i,t[1]=r.durationMs,t[2]=r.entries,t[3]=r.lastUpdatedAt,t[4]=r.startedAt,t[5]=a,t[6]=n,t[7]=o}else o=t[7];return o},BS=e=>{let t=(0,du.c)(104),{onClose:n}=e,{t:r}=Zt(),[i,a]=Q.useState(`memory`),[o,s]=Q.useState(`idle`),c=cr(HS),l=Tn(US),u=Tr(),d=Vn(),[f,p]=Q.useState(WS),m,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>nt(()=>{p(Ke())}),h=[],t[0]=m,t[1]=h):(m=t[0],h=t[1]),Q.useEffect(m,h);let g;if(t[2]!==d||t[3]!==u){bb0:{let e=Xe(),t={};if(!e){g=t;break bb0}let n=e.getCacheBudget?.(),r=n?n.listCanonical().map(GS):u.map(e=>({directory:d,sessionID:e.id}));for(let n of r){if(d&&n.directory!==d)continue;let r=e.getTranscript(it(n.directory,n.sessionID));t[n.sessionID]=r.messageOrder.map(e=>r.messagesByID[e]).filter(KS)}g=t}t[2]=d,t[3]=u,t[4]=g}else g=t[4];let _=g,v=IS(qS),[y,b]=Q.useState(JS),[x,S]=Q.useState(YS),C;t[5]===y.entries?C=t[6]:(C=new Map,y.entries.forEach(e=>{C.set(e.metric,e.count)}),t[5]=y.entries,t[6]=C);let w;t[7]===C?w=t[8]:(w=C.get(`ui.message_list.render`)??0,t[7]=C,t[8]=w);let T;t[9]===C?T=t[10]:(T=C.get(`ui.message_list.render.streaming`)??0,t[9]=C,t[10]=T);let E;t[11]===C?E=t[12]:(E=C.get(`ui.chat_message.render`)??0,t[11]=C,t[12]=E);let D;t[13]===C?D=t[14]:(D=C.get(`ui.chat_message.render.streaming`)??0,t[13]=C,t[14]=D);let O;t[15]===C?O=t[16]:(O=C.get(`ui.chat_message.render.static_during_stream`)??0,t[15]=C,t[16]=O);let k;t[17]===C?k=t[18]:(k=C.get(`ui.chat_message.render.static_outside_active_turn_during_stream`)??0,t[17]=C,t[18]=k);let A;t[19]!==w||t[20]!==T||t[21]!==E||t[22]!==D||t[23]!==O||t[24]!==k?(A={messageListRender:w,messageListRenderStreaming:T,chatMessageRender:E,chatMessageRenderStreaming:D,chatMessageRenderStaticDuringStream:O,chatMessageRenderStaticOutsideActiveTurnDuringStream:k},t[19]=w,t[20]=T,t[21]=E,t[22]=D,t[23]=O,t[24]=k,t[25]=A):A=t[25];let j=A,M,N;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{let e=()=>{b(ke()),S(G())};e();let t=window.setInterval(e,500);return()=>window.clearInterval(t)},N=[],t[26]=M,t[27]=N):(M=t[26],N=t[27]),Q.useEffect(M,N);let P,F;t[28]===o?(P=t[29],F=t[30]):(P=()=>{if(o===`idle`)return;let e=window.setTimeout(()=>{s(`idle`)},1500);return()=>window.clearTimeout(e)},F=[o],t[28]=o,t[29]=P,t[30]=F),Q.useEffect(P,F);let I=0,L=0,R=0;for(let e of Object.keys(_)){let t=_[e]??[];L+=t.length;for(let e of t)e.role===`user`?R+=1:e.role===`assistant`&&(I+=1)}let z;t[31]!==I||t[32]!==L||t[33]!==R?(z={assistant:I,total:L,user:R},t[31]=I,t[32]=L,t[33]=R,t[34]=z):z=t[34];let ee=z,B;if(t[35]!==c||t[36]!==_||t[37]!==l||t[38]!==u||t[39]!==r){let e;t[41]!==c||t[42]!==_||t[43]!==l||t[44]!==r?(e=e=>{let t=_[e.id]??[],n=0,i=0;for(let e of t)e.role===`user`?i+=1:e.role===`assistant`&&(n+=1);let a=l.get(e.id);return{id:e.id,title:e.title||r(`memoryDebugPanel.common.untitled`),assistantMessageCount:n,messageCount:t.length,userMessageCount:i,isStreaming:a?.isStreaming||!1,isZombie:a?.isZombie||!1,backgroundCount:a?.backgroundMessageCount||0,lastAccessed:a?.lastAccessedAt||0,isCurrent:e.id===c}},t[41]=c,t[42]=_,t[43]=l,t[44]=r,t[45]=e):e=t[45],B=u.map(e).sort(XS),t[35]=c,t[36]=_,t[37]=l,t[38]=u,t[39]=r,t[40]=B}else B=t[40];let V=B,te;t[46]===_?te=t[47]:(te=Object.keys(_),t[46]=_,t[47]=te);let ne=te.length,re;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(re=async()=>{try{let e={generatedAt:new Date().toISOString(),ui:ke(),vscode:G()};await navigator.clipboard.writeText(JSON.stringify(e,null,2)),s(`copied`)}catch{s(`error`)}},t[48]=re):re=t[48];let ie=re,ae;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ae={backgroundColor:`color-mix(in srgb, var(--surface-background) 94%, transparent)`},t[49]=ae):ae=t[49];let oe;t[50]===i?oe=t[51]:(oe=i===`memory`?(0,$.jsx)(Z,{name:`database-2`,className:`h-4 w-4 text-[var(--surface-foreground)]`}):(0,$.jsx)(Z,{name:`bar-chart-box`,className:`h-4 w-4 text-[var(--surface-foreground)]`}),t[50]=i,t[51]=oe);let H;t[52]===r?H=t[53]:(H=r(`memoryDebugPanel.title`),t[52]=r,t[53]=H);let se;t[54]===H?se=t[55]:(se=(0,$.jsx)(`h3`,{className:`typography-ui-label font-semibold text-[var(--surface-foreground)]`,children:H}),t[54]=H,t[55]=se);let U;t[56]!==oe||t[57]!==se?(U=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[oe,se]}),t[56]=oe,t[57]=se,t[58]=U):U=t[58];let ce;t[59]===i?ce=t[60]:(ce=i===`streaming`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,onClick:ie,children:(0,$.jsx)(Z,{name:`file-copy`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,onClick:()=>{Fe(),b(ke()),S(G())},children:(0,$.jsx)(Z,{name:`refresh`,className:`h-3.5 w-3.5`})})]}):null,t[59]=i,t[60]=ce);let W;t[61]===n?W=t[62]:(W=n?(0,$.jsx)(Y,{size:`icon`,variant:`ghost`,className:`h-6 w-6`,onClick:n,children:(0,$.jsx)(Z,{name:`close`,className:`h-4 w-4`})}):null,t[61]=n,t[62]=W);let le;t[63]!==ce||t[64]!==W?(le=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[ce,W]}),t[63]=ce,t[64]=W,t[65]=le):le=t[65];let ue;t[66]!==U||t[67]!==le?(ue=(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[U,le]}),t[66]=U,t[67]=le,t[68]=ue):ue=t[68];let de;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(de={backgroundColor:`color-mix(in srgb, var(--surface-muted) 55%, transparent)`},t[69]=de):de=t[69];let fe=i===`memory`?`secondary`:`ghost`,pe;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(pe=()=>a(`memory`),t[70]=pe):pe=t[70];let me;t[71]===r?me=t[72]:(me=r(`memoryDebugPanel.tabs.memory`),t[71]=r,t[72]=me);let he;t[73]!==fe||t[74]!==me?(he=(0,$.jsx)(Y,{size:`sm`,variant:fe,className:`flex-1`,onClick:pe,children:me}),t[73]=fe,t[74]=me,t[75]=he):he=t[75];let ge=i===`streaming`?`secondary`:`ghost`,_e;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(_e=()=>a(`streaming`),t[76]=_e):_e=t[76];let ve;t[77]===r?ve=t[78]:(ve=r(`memoryDebugPanel.tabs.streaming`),t[77]=r,t[78]=ve);let ye;t[79]!==ge||t[80]!==ve?(ye=(0,$.jsx)(Y,{size:`sm`,variant:ge,className:`flex-1`,onClick:_e,children:ve}),t[79]=ge,t[80]=ve,t[81]=ye):ye=t[81];let be;t[82]!==he||t[83]!==ye?(be=(0,$.jsxs)(`div`,{className:`mb-3 flex gap-1 rounded-md p-1`,style:de,children:[he,ye]}),t[82]=he,t[83]=ye,t[84]=be):be=t[84];let xe;t[85]!==i||t[86]!==ne||t[87]!==o||t[88]!==c||t[89]!==_||t[90]!==ee||t[91]!==l||t[92]!==V||t[93]!==u||t[94]!==j||t[95]!==y||t[96]!==r||t[97]!==v||t[98]!==x?(xe=i===`memory`?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 typography-meta`,children:[(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.totalMessages`),value:ee.total}),(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.cachedSessions`),value:`${ne} / ${$r.MAX_SESSIONS}`}),(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.userMessages`),value:ee.user}),(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.assistantMessages`),value:ee.assistant})]}),(0,$.jsxs)(`div`,{className:`typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.viewportWindow`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.messagesValue`,{count:Xi()})})]}),(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.zombieTimeout`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.minutesValue`,{count:$r.ZOMBIE_TIMEOUT/1e3/60})})]}),(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.githubTotalRequests`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:v})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-[var(--interactive-border)] pt-2`,children:[(0,$.jsx)(`div`,{className:`mb-1 typography-meta font-semibold text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.section.sessionsInMemory`)}),(0,$.jsx)(es,{outerClassName:`max-h-48`,className:`space-y-1 pr-1`,children:V.map(e=>(0,$.jsxs)(`div`,{className:`typography-meta flex items-center justify-between rounded p-1.5`,style:{backgroundColor:e.isCurrent?`color-mix(in srgb, var(--interactive-selection) 22%, transparent)`:`color-mix(in srgb, var(--surface-muted) 35%, transparent)`},children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-[var(--surface-foreground)]`,children:e.title}),e.isStreaming?(0,$.jsx)(Z,{name:`pulse`,className:`h-3 w-3 animate-pulse text-[var(--status-info)]`}):null,e.isZombie?(0,$.jsx)(`span`,{className:`text-[var(--status-warning)]`,children:`!`}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.roleMsgsValue`,{assistant:e.assistantMessageCount,user:e.userMessageCount})}),(0,$.jsx)(`span`,{className:`font-mono text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.msgsValue`,{count:e.messageCount})}),e.backgroundCount>0?(0,$.jsxs)(`span`,{className:`text-[var(--status-info)]`,children:[`+`,e.backgroundCount]}):null]})]},e.id))})]}),(0,$.jsx)(`div`,{className:`flex gap-2 border-t border-[var(--interactive-border)] pt-2`,children:(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(Y,{size:`sm`,variant:`outline`,className:`typography-meta`,onClick:()=>{u.map(ZS),Object.keys(_),V.map(QS),Object.fromEntries(l)},children:r(`memoryDebugPanel.actions.logState`)})}),(0,$.jsx)(Ea,{side:`top`,children:r(`memoryDebugPanel.tooltip.logCurrentState`)})]})})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.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:[(0,$.jsx)(`span`,{children:r(o===`copied`?`memoryDebugPanel.streaming.copy.copied`:o===`error`?`memoryDebugPanel.streaming.copy.failed`:`memoryDebugPanel.streaming.copy.hint`)}),(0,$.jsx)(Y,{size:`xs`,variant:`outline`,onClick:ie,children:r(`memoryDebugPanel.actions.copyJson`)})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.uiMetrics`),value:y.entries.length}),(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.vscodeMetrics`),value:x.entries.length}),(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.messageListRenders`),value:j.messageListRender}),(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.messageListStreamRenders`),value:j.messageListRenderStreaming}),(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.chatMessageRenders`),value:j.chatMessageRender}),(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.chatMessageStreamRenders`),value:j.chatMessageRenderStreaming}),(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.chatMessageStaticDuringStream`),value:j.chatMessageRenderStaticDuringStream}),(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn`),value:j.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),(0,$.jsx)(zS,{title:r(`memoryDebugPanel.section.uiStreamingMetrics`),snapshot:y,emptyLabel:r(`memoryDebugPanel.section.noUiSamples`)}),x.entries.length>0?(0,$.jsx)(zS,{title:r(`memoryDebugPanel.section.vscodeBridgeMetrics`),snapshot:x,emptyLabel:r(`memoryDebugPanel.section.noVscodeSamples`)}):null]}),t[85]=i,t[86]=ne,t[87]=o,t[88]=c,t[89]=_,t[90]=ee,t[91]=l,t[92]=V,t[93]=u,t[94]=j,t[95]=y,t[96]=r,t[97]=v,t[98]=x,t[99]=xe):xe=t[99];let Se;return t[100]!==ue||t[101]!==be||t[102]!==xe?(Se=(0,$.jsxs)(mo,{className:`fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area`,style:ae,children:[ue,be,xe]}),t[100]=ue,t[101]=be,t[102]=xe,t[103]=Se):Se=t[103],Se};function VS(e,t){return e+t.count}function HS(e){return e.currentSessionId}function US(e){return e.sessionMemoryState}function WS(){return Ke()}function GS(e){return e.scope}function KS(e){return!!e}function qS(e){return e.totalRequestCount}function JS(){return ke()}function YS(){return G()}function XS(e,t){return t.lastAccessed-e.lastAccessed}function ZS(e){return{id:e.id,title:e.title}}function QS(e){return{id:e.id,title:e.title,total:e.messageCount,user:e.userMessageCount,assistant:e.assistantMessageCount}}var $S=()=>{let{isMobile:e,closeActiveContextPanelTab:t}=q.getState();if(e)return;let n=Bo();n&&t(n)||R()&&P(`desktop_close_current_window`).catch(e=>{console.warn(`[menu-actions] failed to close current window`,e)})},eC=()=>{if(typeof document>`u`)return``;let e=document.activeElement;if(e instanceof HTMLTextAreaElement)return e.value.slice(e.selectionStart??0,e.selectionEnd??0);if(e instanceof HTMLInputElement){let t=e.type?.toLowerCase()??`text`;if([`text`,`search`,`url`,`tel`,`password`].includes(t))return e.value.slice(e.selectionStart??0,e.selectionEnd??0)}return e instanceof HTMLElement&&e.isContentEditable?e.ownerDocument.defaultView?.getSelection?.()?.toString()??``:``},tC=async()=>{let e=eC()||window.getSelection()?.toString()||``;if(!e.trim())return!1;try{if(typeof navigator<`u`&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}return document.execCommand(`copy`)},nC=`yuri:menu-action`,rC=`yuri:check-for-updates`,iC=e=>typeof e?.listen==`function`?`bridge`:`dom`,aC=e=>{let t=cr(e=>e.openNewSessionDraft),n=q(e=>e.toggleCommandPalette),r=q(e=>e.setCommandPaletteOpen),i=q(e=>e.toggleHelpDialog),a=q(e=>e.toggleSidebar),o=q(e=>e.setSessionSwitcherOpen),s=q(e=>e.setActiveMainTab),c=q(e=>e.setSettingsDialogOpen),l=q(e=>e.setSettingsPage),u=q(e=>e.setAboutDialogOpen),d=q(e=>e.toggleContextPanel),f=q(e=>e.setRightSidebarOpen),p=q(e=>e.setRightSidebarTab),m=q(e=>e.toggleBottomTerminal),h=q(e=>e.setBottomTerminalExpanded),g=As(e=>e.checkForUpdates),{setThemeMode:_}=zr(),{t:v}=Zt(),y=Q.useRef(!1),b=typeof window>`u`?null:window.__YURI_DESKTOP__,x=iC(b),S=Q.useCallback(()=>{y.current||(y.current=!0,g().then(()=>{let{available:e,error:t}=As.getState();if(t){J.error(v(`sessions.sidebar.updateCheck.errorTitle`),{description:t});return}e||J.success(v(`sessions.sidebar.updateCheck.latestVersion`))}).finally(()=>{y.current=!1}))},[g,v]),C=Q.useCallback(()=>{Kn.requestDirectoryDialog()},[]),w=Q.useCallback(e=>{sa(e,cr.getState().currentSessionId,e=>{s(`chat`),o(!1),cr.getState().setCurrentSession(e.sessionId,e.directory)})},[s,o]),T=Q.useCallback(e=>{let{activeProjectId:t,projects:n,setActiveProject:r}=mn.getState();if(n.length===0)return;let i=n.findIndex(e=>e.id===t),a=e>0?0:n.length-1;i>=0&&(a=(i+e+n.length)%n.length);let o=n[a];o&&r(o.id)},[]),E=Q.useCallback(g=>{switch(g){case`about`:u(!0);break;case`settings`:c(!0);break;case`switch-instance`:l(`remote-instances`),c(!0);break;case`command-palette`:n();break;case`quick-open`:r(!0);break;case`new-session`:s(`chat`),o(!1),t();break;case`new-worktree-session`:s(`chat`),o(!1),ha();break;case`change-workspace`:C();break;case`close-tab-or-window`:$S();break;case`toggle-right-sidebar`:{let e=Bo();e&&d(e);break}case`open-right-sidebar-git`:{let e=Bo();e&&q.getState().openContextPanel(e),f(!0),p(`git`);break}case`open-right-sidebar-files`:{let e=Bo();e&&q.getState().openContextPanel(e),f(!0),p(`files`);break}case`toggle-terminal`:m();break;case`toggle-terminal-expanded`:h(!q.getState().isBottomTerminalExpanded);break;case`copy`:{let e=new Event(`yuri:copy`,{cancelable:!0});window.dispatchEvent(e)&&tC();break}case`theme-light`:_(`light`);break;case`theme-dark`:_(`dark`);break;case`theme-system`:_(`system`);break;case`toggle-sidebar`:a();break;case`toggle-memory-debug`:e?.();break;case`zoom-in`:Ui();break;case`zoom-out`:Wi();break;case`zoom-reset`:ma();break;case`go-back`:Pe.getState().goBack();break;case`go-forward`:Pe.getState().goForward();break;case`previous-session`:w(-1);break;case`next-session`:w(1);break;case`previous-project`:T(-1);break;case`next-project`:T(1);break;case`help-dialog`:i();break;case`download-logs`:xa().catch(()=>{J.error(`Failed to collect OpenCode status`)})}},[C,T,w,e,t,u,s,o,r,c,l,h,f,p,_,m,n,i,d,a]);Q.useEffect(()=>{if(x!==`dom`)return;let e=e=>{let t=e.detail;t&&E(t)},t=()=>{S()};return window.addEventListener(nC,e),window.addEventListener(rC,t),()=>{window.removeEventListener(nC,e),window.removeEventListener(rC,t)}},[E,S,x]),Q.useEffect(()=>{if(x!==`bridge`)return;let e=b?.listen;if(typeof e!=`function`)return;let t=null,n=null;return e(`yuri:menu-action`,e=>{let t=e?.payload;typeof t==`string`&&E(t)}).then(e=>{t=e}).catch(()=>{}),e(`yuri:check-for-updates`,S).then(e=>{n=e}).catch(()=>{}),()=>{(async()=>{try{let e=t?.();e instanceof Promise&&await e}catch{}try{let e=n?.();e instanceof Promise&&await e}catch{}})()}},[b,E,S,x])},oC=(e,t)=>e<t?-1:+(e>t),sC=e=>JSON.stringify([...e.entries()].map(([e,t])=>[e,[...new Set(t)].sort(oC)]).sort(([e],[t])=>oC(e,t)));async function cC({targets:e,isReady:t,fetchStatus:n,applySnapshot:r,concurrency:i=2,isDisposed:a=()=>!1}){if(!t()||a())return;let o=[...e.entries()],s=0,c=Math.min(Math.max(1,i),o.length),l=async()=>{for(;s<o.length&&t()&&!a();){let e=o[s];if(s+=1,!e)return;let[t,i]=e,c=await n(t);c===null||a()||r(t,c,i)}};await Promise.all(Array.from({length:c},()=>l()))}var lC=`yuri:tray-action`,uC=3e4,dC=120,fC=20,pC=()=>{if(typeof window>`u`)return!1;let e=window.__YURI_PLATFORM__;return e===`darwin`||e===`win32`},mC=e=>{let t=typeof e.permission==`string`?e.permission:`Permission`,n=Array.isArray(e.patterns)?e.patterns.find(e=>typeof e==`string`&&e.trim()):``;return n?`${t}: ${n}`:t},hC=e=>{let t=Array.isArray(e.questions)?e.questions[0]:void 0;return t?.header||t?.question||`Question`},gC=e=>In(e),_C=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t},vC=(e,t,n,r)=>{if(!e)return``;let i=_n(t,n,e),a=_C(i?i.path:e),o=Cn(e),s=o&&r.get(o)||``;if(!s){for(let[e,t]of Eo.getState().directories)if(Cn(e)===o){s=t.status?.current??``;break}}if(!s)for(let e of n.values()){let t=e.find(e=>Cn(e.path)===o);if(t?.branch){s=t.branch;break}}return s?`${a} · ${s}`:a},yC=()=>{let{results:e,dropdownProviderIds:t,displayMode:n}=_s.getState(),r=n===`remaining`?`remaining`:`usage`;if(!t.length)return{mode:r,groups:[]};let i=new Map(e.map(e=>[e?.providerId,e])),a=[];for(let n of Fs(e)){if(!t.includes(n.id))continue;let e=i.get(n.id);if(!e||e.configured!==!0)continue;let o=[];for(let[t,n]of Object.entries(e.usage?.windows??{})){let e=r===`remaining`?n.remainingPercent:n.usedPercent;o.push({label:ka(n.label??t),value:La(n.valueLabel,e)})}let s=!e.ok&&e.error?e.error:o.length===0?`No rate limits reported`:null;a.push({provider:n.name,rows:o,status:s})}return{mode:r,groups:a}},bC=async()=>{try{if(S())return`Local Yuri`;let e=window.__YURI_LOCAL_ORIGIN__||window.location.origin,t=m();if(t&&H(t,e))return`Local Yuri`;let n=(await U()).hosts.find(e=>t?H(t,oe(e)):!1);return n?.label?.trim()?ce(n.label.trim()):`Instance`}catch{return``}},xC=()=>{let e=new Map,t=new Map,n=[],r=new Map,i;try{i=rt()}catch{return{statusById:e,branchByDirectory:t,approvals:n,titleById:r}}for(let[a,o]of i.children.entries()){let i=o.getState(),s=typeof i.vcs?.branch==`string`?i.vcs.branch:typeof i.vcs?.branch?.current==`string`?i.vcs.branch.current:``;s&&t.set(Cn(a)??a,s);for(let e of i.session)!e?.id||!e.title||r.set(e.id,e.title);for(let[t,n]of Object.entries(i.session_status??{})){let r=n?.type,i=r===`busy`?`busy`:r===`retry`?`retry`:`idle`,a=e.get(t);(!a||a===`idle`)&&e.set(t,i)}for(let[e,t]of Object.entries(i.permission??{}))for(let r of t??[]){if(!r?.id)continue;let t=r.sessionID||e;n.push({kind:`permission`,id:r.id,sessionId:t,sessionTitle:``,label:mC(r),directory:a})}for(let[e,t]of Object.entries(i.question??{}))for(let r of t??[]){if(!r?.id)continue;let t=r.sessionID||e;n.push({kind:`question`,id:r.id,sessionId:t,sessionTitle:``,label:hC(r),directory:a})}}return{statusById:e,branchByDirectory:t,approvals:n,titleById:r}},SC=()=>{let e=wr.getState().activeSessions,t=new Set;e.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>gC(t)-gC(e)).slice(0,fC).forEach(e=>{let n=Xn(e);n&&t.add(n)});let n=new Map;for(let r of e){if(!r?.id)continue;let e=Xn(r);if(!e||!t.has(e))continue;let i=n.get(e)??[];i.push(r.id),n.set(e,i)}return n},CC=e=>{let t=xC(),n=Sn.getState().index.session,r=wr.getState().activeSessions,i=new Map(t.titleById),a=new Map;for(let e of r)if(e?.id&&(e.title&&i.set(e.id,e.title),e.parentID)){let t=a.get(e.parentID)??[];t.push(e.id),a.set(e.parentID,t)}let o=e=>{let t=[],n=[...a.get(e)??[]],r=new Set;for(;n.length;){let e=n.pop();r.has(e)||(r.add(e),t.push(e),n.push(...a.get(e)??[]))}return t},s=Qn.getState().statusById,c=e=>{let n=t.statusById.get(e);return n&&n!==`idle`?n:s.get(e)?.status??n??`idle`},l=e=>{let t=e.map(e=>c(e));return t.includes(`busy`)?`busy`:t.includes(`retry`)?`retry`:`idle`},u=mn.getState().projects,d=cr.getState().availableWorktreesByProject,f=r.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>gC(t)-gC(e)).slice(0,fC).map(e=>{let r=[e.id,...o(e.id)],i=Xn(e)??``;return{id:e.id,title:e.title||`Untitled session`,status:l(r),branch:i?t.branchByDirectory.get(i)??``:``,unseen:n.unseenCount[e.id]??0,hasError:n.unseenHasError[e.id]??!1,directory:i,subtitle:vC(i,u,d,t.branchByDirectory)}}),p=t.approvals.map(e=>({...e,sessionTitle:i.get(e.sessionId)||``})),m=q.getState(),h=0;if(m.dockBadgeEnabled)for(let e of r)!e?.id||e.parentID||(n.unseenCount[e.id]??0)>0&&(h+=1);return{sessions:f,approvals:p,instanceName:e,usage:yC(),dockBadgeCount:h}},wC=()=>{Q.useEffect(()=>{if(!pC()||!R())return;let e=!1,t=``,n=null,r=``,i=()=>{if(e)return;let n=CC(r),i=JSON.stringify(n);i!==t&&(t=i,P(`desktop_tray_update`,n))};bC().then(t=>{e||(r=t,i())});let a=null,o=``,s=()=>{let e=Ln.getState();return e.isConnected&&e.connectionPhase===`connected`},c=()=>{if(a)return a;let t=SC();return o=sC(t),a=cC({targets:t,isReady:s,concurrency:2,isDisposed:()=>e,fetchStatus:async()=>{try{let e=await et.getSdkClient().session.active();if(!e||typeof e!=`object`||Array.isArray(e))return null;let t={};for(let[n,r]of Object.entries(e))r?.type===`running`&&(t[n]={type:`busy`});return t}catch{return null}},applySnapshot:(e,t,n)=>{ir(e,t,[...n])}}).finally(()=>{a=null;let t=SC();!e&&s()&&sC(t)!==o&&c()}),a},l=()=>{e||n!==null||(n=window.setTimeout(()=>{n=null,i()},dC))},u=new Map,d=()=>{if(e)return;let t;try{t=rt()}catch{return}let n=new Set;for(let[e,r]of t.children.entries())n.add(e),u.has(e)||u.set(e,r.subscribe(()=>l()));for(let[e,t]of u)n.has(e)||(t(),u.delete(e))},f=null;try{f=rt().subscribeRegistry(()=>{d(),l()})}catch{}d();let p=Sn.subscribe(()=>l()),m=wr.subscribe(()=>{l(),s()&&sC(SC())!==o&&c()}),h=mn.subscribe(()=>l()),g=cr.subscribe(()=>l()),_=Eo.subscribe(()=>l()),v=q.subscribe(()=>l()),y=Qn.subscribe(()=>l()),b=s(),x=Ln.subscribe(()=>{let e=s();e&&!b&&c(),b=e});b&&c();let S=_s.subscribe(()=>l());_s.getState().loadSettings().then(()=>{if(e)return;let{dropdownProviderIds:t,results:n}=_s.getState();t.length>0&&t.some(e=>!n.some(t=>t?.providerId===e))&&_s.getState().fetchAllQuotas()});let C=window.setInterval(()=>{let e=_s.getState();e.autoRefresh&&e.dropdownProviderIds.length>0&&e.fetchAllQuotas()},Math.max(3e4,_s.getState().refreshIntervalMs||6e4)),w=window.setInterval(()=>{d(),i()},uC);return i(),()=>{e=!0,n!==null&&window.clearTimeout(n),window.clearInterval(w),window.clearInterval(C),p(),m(),h(),g(),_(),v(),y(),x(),S(),f?.();for(let e of u.values())e();u.clear()}},[]),Q.useEffect(()=>{if(!pC()||typeof window>`u`)return;let e=window.__YURI_DESKTOP__?.listen;if(typeof e!=`function`)return;let t=e=>{e.type===`respond-permission`&&fr(e.sessionId,e.id,e.response).catch(()=>{J.error(`Failed to respond to permission request`)})},n=null;return e(lC,e=>{let n=e?.payload;!n||typeof n!=`object`||typeof n.type!=`string`||t(n)}).then(e=>{n=e}).catch(()=>{}),()=>{try{let e=n?.();e instanceof Promise&&e.catch(()=>{})}catch{}}},[])},TC=`/api/notifications/stream`,EC=()=>typeof document>`u`||document.visibilityState===`visible`&&document.hasFocus(),DC=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=t.properties&&typeof t.properties==`object`?t.properties:null;return t.type!==`yuri: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,requireHidden:n.requireHidden===!0||n.requireHidden!==!1&&void 0}},OC=e=>{let t=(0,du.c)(3),n=e?.enabled??!0,r,i;t[0]===n?(r=t[1],i=t[2]):(r=()=>{if(!n||v()||!re()||typeof window>`u`||typeof EventSource>`u`)return;let e=new EventSource(c().sse(TC));return e.onmessage=kC,()=>{e.close()}},i=[n],t[0]=n,t[1]=r,t[2]=i),Q.useEffect(r,i)};function kC(e){let t;try{t=JSON.parse(e.data)}catch{return}let n=q.getState();if(!n.nativeNotificationsEnabled)return;let r=DC(t);r&&((r.requireHidden??n.notificationMode!==`always`)&&EC()||ae()?.notifications?.notifyAgentCompletion(r))}var AC=`pwa-install-toast-shown`,jC=`pwa-install-toast-dismissed`,MC=()=>{let e=(0,du.c)(6),{browserTab:t}=Gs(),{t:n}=Zt(),r=Q.useRef(n),i,a;e[0]===n?(i=e[1],a=e[2]):(i=()=>{r.current=n},a=[n],e[0]=n,e[1]=i,e[2]=a),Q.useEffect(i,a);let o,s;e[3]===t?(o=e[4],s=e[5]):(o=()=>{if(typeof window>`u`||!re()||!t)return;let e=null,n=null,i=()=>{n!==null&&(J.dismiss(n),n=null)},a=async()=>{if(!e)return;let t=e;e=null,i(),await t.prompt();let{outcome:n}=await t.userChoice;n===`accepted`&&J.success(r.current(`pwa.installPrompt.started`))},o=t=>{let o=t;if(typeof o.prompt!=`function`)return;o.preventDefault(),e=o;let s=Be(),c=Ve();fc({dismissed:s.getItem(jC),sessionShown:c.getItem(AC),hasActiveToast:n!==null})&&(c.setItem(AC,`true`),n=J.info(r.current(`pwa.installPrompt.description`),{duration:1/0,action:{label:r.current(`pwa.installPrompt.action`),onClick:()=>{a()}},cancel:{label:r.current(`pwa.installPrompt.dismiss`),onClick:()=>{Be().setItem(jC,`true`),i()}}}))},s=()=>{e=null,i(),J.success(r.current(`pwa.installPrompt.installed`))};return window.addEventListener(`beforeinstallprompt`,o),window.addEventListener(`appinstalled`,s),()=>{i(),window.removeEventListener(`beforeinstallprompt`,o),window.removeEventListener(`appinstalled`,s)}},s=[t],e[3]=t,e[4]=o,e[5]=s),Q.useEffect(o,s)},NC=0;function PC(e){let t=typeof e?.sessionId==`string`?e.sessionId.trim():``;if(!t)return;let n=++NC,r=typeof e?.directory==`string`&&e.directory.trim().length>0?e.directory.trim():null;if(q.getState().setActiveMainTab(`chat`),e.hostId||e.hubId||e.instanceId){if(!e.hostId||!e.hubId||!r)return;Pt(async()=>{let{applyRemoteProjectRoute:e}=await import(`./navigation-DDzw_NEu.js`).then(e=>e.n);return{applyRemoteProjectRoute:e}},__vite__mapDeps([164,1,3,2,13,4,5,6,7,8,9,10,12,11,14,15,16,17,18,19,20,42,22,43,23,24,44,45,46,47,21,25,48,49,37,38,39,40,41,50,51,52,53,54,55,56,57])).then(({applyRemoteProjectRoute:i})=>{if(n===NC)return i({sessionId:t,directory:r,hostId:e.hostId,hubId:e.hubId,...e.instanceId?{instanceId:e.instanceId}:{},isNewSession:!1},()=>n===NC)}).catch(()=>console.warn(`[remote-session] Notification navigation failed`));return}cr.getState().setCurrentSession(t,r)}var FC=({open:e,onOpenChange:t})=>{let{t:n}=Zt(),[r,i]=Q.useState(null),[a,o]=Q.useState(null);Q.useEffect(()=>{e&&(async()=>{try{let e=await h(`/api/system/info`);if(e.ok){let t=await e.json();if(typeof t.yuriVersion==`string`&&t.yuriVersion.trim()){i(t.yuriVersion);return}}}catch{}i(await Jt())})()},[e]),Q.useEffect(()=>{if(!e)return;let t=!1;return(async()=>{try{let e=await h(`/api/opencode/upgrade-status`,{headers:{Accept:`application/json`}});if(!e.ok)return;let n=await e.json().catch(()=>null),r=typeof n?.currentVersion==`string`?n.currentVersion.trim():``;!t&&r&&o(r)}catch{}})(),()=>{t=!0}},[e]);let s=r;return(0,$.jsx)(Jr,{open:e,onOpenChange:t,children:(0,$.jsx)(Gr,{className:`max-w-xs p-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[(0,$.jsx)(fo,{width:48,height:48}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Yuri`}),(0,$.jsxs)(`div`,{className:`space-y-0.5 typography-meta text-muted-foreground`,children:[s&&(0,$.jsx)(`p`,{children:n(`aboutDialog.yuriVersionLabel`,{version:s})}),a&&(0,$.jsx)(`p`,{children:n(`aboutDialog.openCodeVersionLabel`,{version:a})})]})]}),(0,$.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,$.jsxs)(`a`,{href:`https://github.com/yee94/yuri`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors`,children:[(0,$.jsx)(Z,{name:`github-fill`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`GitHub`})]})}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/60`,children:n(`aboutDialog.footerNote`)})]})})})},IC=(e,t)=>{let n=e.get(t);return typeof n==`string`&&n.trim()||null},LC=(e,t)=>{let n=e instanceof Error?e.message:t;return/oauth state required/i.test(n)?`Authorization session expired or was cleared during reload. Return to Yuri and click Authorize again.`:n},RC=()=>{let e=ks(e=>e.completeAuth),[t,n]=Q.useState(`working`),[r,i]=Q.useState(`Completing MCP authorization...`);return Q.useEffect(()=>{if(typeof window>`u`){n(`error`),i(`Browser context unavailable.`);return}let t=new URLSearchParams(window.location.search),r=IC(t,`code`),a=qs(t),o=Ds(t),s=IC(t,`error`),c=IC(t,`error_description`);if(s){o&&h(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`error`),i(c??s);return}(async()=>{try{if(!r)throw Error(`Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into Yuri manually.`);let t=a;if(!t&&o){let e=await h(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`);if(e.ok){let n=await e.json().catch(()=>null);n?.name?.trim()&&(t={name:n.name.trim(),directory:typeof n.directory==`string`&&n.directory.trim()?n.directory.trim():null})}}if(!t?.name)throw Error(`Authorization session details were not available. Start authorization again from MCP Settings or paste the returned code into Yuri manually.`);await e(t.name,r,t.directory),o&&await h(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`success`),i(`Authorization completed. You can close this tab and return to Yuri.`)}catch(e){o&&await h(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`error`),i(LC(e,`Failed to complete MCP authorization.`))}})()},[e]),(0,$.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-background px-6 py-12 text-foreground`,children:(0,$.jsxs)(`div`,{className:`w-full max-w-xl rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-8 shadow-sm dark:shadow-none`,children:[(0,$.jsxs)(`div`,{className:`space-y-3 text-center`,children:[(0,$.jsx)(`div`,{className:t===`error`?`text-[var(--status-error)]`:t===`success`?`text-[var(--status-success)]`:`text-[var(--status-info)]`,children:(0,$.jsx)(`h1`,{className:`typography-hero font-semibold`,children:t===`working`?`Completing Authorization`:t===`success`?`Authorization Complete`:`Authorization Failed`})}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:r})]}),t!==`working`&&(0,$.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,$.jsx)(Y,{type:`button`,onClick:()=>{typeof window>`u`||window.location.replace(`/`)},children:`Return to Yuri`})})]})})},zC=()=>{let e=wr(e=>e.startupSyncProgress.active),t=wr(e=>e.startupSyncProgress.phase),n=wr(e=>e.startupSyncProgress.completed),r=wr(e=>e.startupSyncProgress.total),{locale:i,t:a}=Zt(),[o,s]=Q.useState(!0),c=Wt(i).startingApi;Q.useEffect(()=>{let e=!1,t=async()=>{try{let t=await(await h(`/health`,{signal:AbortSignal.timeout(4e3)})).json().catch(()=>null);if(e)return;let n=t?.openCodeStarting===!0||t?.isOpenCodeReady!==!0&&!t?.lastOpenCodeError;s(n)}catch{e||s(!0)}};t();let n=window.setInterval(()=>{t()},750);return()=>{e=!0,window.clearInterval(n)}},[]);let l=r>0?Math.round(n/r*100):0,u=t===`restoring`?a(`common.loading`):a(`sessions.startupSync.progress`,{completed:n,total:r});return Q.useLayoutEffect(()=>{let t=document.getElementById(`startup-session-progress`),i=document.getElementById(`startup-session-progress-track`),s=document.getElementById(`startup-session-progress-fill`),d=document.getElementById(`startup-session-progress-text`);if(!(!t||!i||!s||!d)){if(e){t.hidden=!1,s.style.width=`${l}%`,i.setAttribute(`aria-label`,a(`sessions.startupSync.title`)),i.setAttribute(`aria-valuemax`,String(Math.max(r,1))),i.setAttribute(`aria-valuenow`,String(n)),i.setAttribute(`aria-valuetext`,u),d.textContent=u;return}if(o){t.hidden=!1,s.style.width=`30%`,i.setAttribute(`aria-label`,c),i.setAttribute(`aria-valuetext`,c),d.textContent=c;return}t.hidden=!0}},[e,n,o,l,u,c,a,r]),null},BC=(e,t,n,r=350)=>n?Math.max(0,r-Math.max(0,t-e)):null;function VC(e){let t=(0,du.c)(21),{transition:n,ready:r}=e,{t:i}=Zt(),a=Ha(!0),[o,s]=Q.useState(0),c=n.epoch>o,l=a||c,u,d;if(t[0]!==c||t[1]!==a||t[2]!==r||t[3]!==n.epoch||t[4]!==n.startedAt?(u=()=>{if(!c||a)return;let e=BC(n.startedAt,Date.now(),r);if(e===null)return;let t=window.setTimeout(()=>{s(e=>Math.max(e,n.epoch))},e);return()=>window.clearTimeout(t)},d=[c,a,r,n.epoch,n.startedAt],t[0]=c,t[1]=a,t[2]=r,t[3]=n.epoch,t[4]=n.startedAt,t[5]=u,t[6]=d):(u=t[5],d=t[6]),Q.useEffect(u,d),!l)return null;let f;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 opacity-70`,"aria-hidden":`true`,children:[(0,$.jsx)(`div`,{className:`absolute left-1/2 top-1/2 size-[28rem] -translate-x-1/2 -translate-y-1/2 rounded-full border border-[var(--interactive-border)]/40`}),(0,$.jsx)(`div`,{className:`absolute left-1/2 top-1/2 size-72 -translate-x-1/2 -translate-y-1/2 rounded-full bg-[var(--interactive-selection)]/10 blur-3xl`})]}),t[7]=f):f=t[7];let p;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`div`,{className:`mb-7 flex size-28 items-center justify-center rounded-[2rem] border border-[var(--interactive-border)]/60 bg-[var(--surface-elevated)]/75 shadow-2xl shadow-background/40`,children:(0,$.jsx)(fo,{width:76,height:76,isAnimated:!0})}),t[8]=p):p=t[8];let m;t[9]===i?m=t[10]:(m=i(`desktopHostSwitcher.transition.title`),t[9]=i,t[10]=m);let h;t[11]===m?h=t[12]:(h=(0,$.jsx)(`h1`,{className:`typography-title text-foreground`,children:m}),t[11]=m,t[12]=h);let g;t[13]===i?g=t[14]:(g=i(`desktopHostSwitcher.transition.description`),t[13]=i,t[14]=g);let _;t[15]===g?_=t[16]:(_=(0,$.jsx)(`p`,{className:`mt-2 typography-body text-muted-foreground`,children:g}),t[15]=g,t[16]=_);let v;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`div`,{className:`mt-7 h-1 w-28 overflow-hidden rounded-full bg-[var(--surface-muted)]`,"aria-hidden":`true`,children:(0,$.jsx)(`div`,{className:`h-full w-1/2 animate-pulse rounded-full bg-[var(--status-info)] motion-reduce:animate-none`})}),t[17]=v):v=t[17];let y;return t[18]!==h||t[19]!==_?(y=(0,$.jsxs)(`div`,{className:`fixed inset-0 z-[9998] flex items-center justify-center overflow-hidden bg-background/95 px-6 backdrop-blur-xl`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:[f,(0,$.jsxs)(`div`,{className:`relative flex max-w-md animate-in flex-col items-center text-center fade-in zoom-in-95 duration-300 motion-reduce:animate-none`,children:[p,h,_,v]})]}),t[18]=h,t[19]=_,t[20]=y):y=t[20],y}var HC=So(()=>Pt(()=>import(`./OnboardingScreen-CDzgaBUD.js`).then(e=>({default:e.OnboardingScreen})),__vite__mapDeps([165,1,4,2,5,3,6,7,8,97,9,43,22,23,20,24,44,45,46,47,13,10,12,11,14,15,16,17,18,19,21,25,48,37,38,39,40,41,42,49,50,51,52,53,54,55,56,57,60,61,62,109,118,58]))),UC=36e5,WC=12e5,GC=()=>{let e=(0,du.c)(3),t=q(QC),n=q($C),r;return e[0]!==t||e[1]!==n?(r=(0,$.jsx)(FC,{open:t,onOpenChange:n}),e[0]=t,e[1]=n,e[2]=r):r=e[2],r},KC=e=>{let t=(0,du.c)(21),{onRetry:n,isRetrying:r}=e,{t:i}=Zt(),a;t[0]===i?a=t[1]:(a=i(`startup.initRecovery.title`),t[0]=i,t[1]=a);let o;t[2]===a?o=t[3]:(o=(0,$.jsx)(`h1`,{className:`typography-title text-foreground`,children:a}),t[2]=a,t[3]=o);let s;t[4]===i?s=t[5]:(s=i(`startup.initRecovery.description`),t[4]=i,t[5]=s);let c;t[6]===s?c=t[7]:(c=(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:s}),t[6]=s,t[7]=c);let l;t[8]!==o||t[9]!==c?(l=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o,c]}),t[8]=o,t[9]=c,t[10]=l):l=t[10];let u;t[11]!==r||t[12]!==i?(u=i(r?`startup.initRecovery.retrying`:`startup.initRecovery.retry`),t[11]=r,t[12]=i,t[13]=u):u=t[13];let d;t[14]!==r||t[15]!==n||t[16]!==u?(d=(0,$.jsx)(Y,{type:`button`,onClick:n,disabled:r,children:u}),t[14]=r,t[15]=n,t[16]=u,t[17]=d):d=t[17];let f;return t[18]!==l||t[19]!==d?(f=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center bg-background px-6 text-foreground`,children:(0,$.jsxs)(`div`,{className:`flex max-w-md flex-col items-center gap-4 text-center`,children:[l,d]})}),t[18]=l,t[19]=d,t[20]=f):f=t[20],f},qC=e=>e?e.replace(/\\/g,`/`).replace(/\/+$/g,``):``,JC=()=>{if(typeof window>`u`||!yo())return null;let e=new URLSearchParams(window.location.search),t=e.get(`sessionId`),n=typeof t==`string`?t.trim():``;if(!n)return null;let r=e.get(`directory`);return{sessionId:n,directory:typeof r==`string`&&r.trim().length>0?r.trim():null,readOnly:e.get(`readOnly`)===`1`||e.get(`readOnly`)===`true`}},YC=()=>typeof window>`u`?!1:window.location.pathname===vs,XC=e=>{let t=(0,du.c)(22),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=e,a=Pe(ew),o=cr(tw),s=cr(nw),c=_i(),l=Q.useRef(null),u;t[0]===n.directory?u=t[1]:(u=qC(n.directory),t[0]=n.directory,t[1]=u);let d=u,f;t[2]===a?f=t[3]:(f=qC(a),t[2]=a,t[3]=f);let p=f,m,h;if(t[4]!==p||t[5]!==o||t[6]!==n.directory||t[7]!==n.sessionId||t[8]!==d||t[9]!==r||t[10]!==s||t[11]!==c?(m=()=>{if(r||d&&p!==d)return;let e=`${d}\n${n.sessionId}`;l.current===e&&o||(l.current=e,s(n.sessionId,n.directory),c.ensureSessionRenderable(n.sessionId,!0))},h=[p,o,n.directory,n.sessionId,d,r,s,c],t[4]=p,t[5]=o,t[6]=n.directory,t[7]=n.sessionId,t[8]=d,t[9]=r,t[10]=s,t[11]=c,t[12]=m,t[13]=h):(m=t[12],h=t[13]),Q.useEffect(m,h),d&&p!==d)return null;let g;t[14]===i?g=t[15]:(g=(0,$.jsx)(Ji,{embeddedBackgroundWorkEnabled:i}),t[14]=i,t[15]=g);let _;t[16]===n.readOnly?_=t[17]:(_=(0,$.jsx)(Ec,{readOnly:n.readOnly}),t[16]=n.readOnly,t[17]=_);let v;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(ui,{}),t[18]=v):v=t[18];let y;return t[19]!==g||t[20]!==_?(y=(0,$.jsxs)($.Fragment,{children:[g,_,v]}),t[19]=g,t[20]=_,t[21]=y):y=t[21],y};function ZC({apis:e}){Q.useEffect(()=>{Je(`App:mounted`),qe()},[]),Q.useEffect(()=>xn(),[]);let t=Ln(e=>e.initializeApp),n=Ln(e=>e.isInitialized),r=Ln(e=>e.isConnected),i=cr(e=>e.error),a=cr(e=>e.clearError),o=cr(e=>!(e.newSessionDraft?.open&&e.currentSessionId===null)),c=Pe(e=>e.currentDirectory),l=Pe(e=>e.setDirectory),u=Pe(e=>e.isSwitchingDirectory),[f,p]=Q.useState(!1),m=Ps(e=>e.refreshStatus),[h,g]=Q.useState(()=>e.runtime.isVSCode),[_,y]=Q.useState(!1),[C,w]=Q.useState(!1),[T,E]=Q.useState(0),[O,k]=Q.useState(0),[M,N]=Q.useState({epoch:0,startedAt:0}),[F,I]=Q.useState(!1),R=Q.useRef(!1),z=q(e=>e.wideChatLayoutEnabled),ee=q(e=>e.mobileKeyboardMode),V=Q.useMemo(()=>v(),[]),ne=wr(e=>e.hasCachedSessionIndex),re=wr(e=>e.hasHydratedSessionIndex),[ae,oe]=Q.useState(()=>A()),[H,se]=Q.useState(()=>{let e=L();return e===null?null:te({isDesktopShell:!0,bootOutcome:e})}),U=Q.useRef(!1),ce=Q.useMemo(()=>JC(),[]),W=!ce||_,le=Q.useMemo(()=>YC(),[]);Q.useEffect(()=>(Ae(f),()=>{Ae(!1)}),[f]),Q.useEffect(()=>{Rt(ee)},[ee]),Q.useEffect(()=>{g(e.runtime.isVSCode)},[e.runtime.isVSCode]),Q.useEffect(()=>{let e=Pi(e=>{d(e)&&(V&&N(e=>({epoch:e.epoch+1,startedAt:Date.now()})),dl(e),k(e=>e+1),w(!1),E(e=>e+1))}),t=s(t=>e.schedule(t));return()=>{t(),e.cancel()}},[V]),Q.useEffect(()=>(document.documentElement.classList.toggle(`wide-chat-layout`,z),()=>{document.documentElement.classList.remove(`wide-chat-layout`)}),[z]),Q.useEffect(()=>(ie(e),()=>ie(null)),[e]),Q.useEffect(()=>{if(ce)return;let t=!1;return hr().then(()=>{t||m(e.github,{force:!0})}),()=>{t=!0}},[e.github,ce,m]),fa();let ue=ae===`valid`,de=H?.screen===`main`,[fe,pe]=Q.useState(!1);Q.useEffect(()=>{if(!W||!B({isDesktopShell:V,isInitialized:V&&de?ne||n&&re:n,bootOutcomeKnown:ue,bootViewIsMain:de}))return;let e,t=setTimeout(()=>{let t=document.getElementById(`initial-loading`);t?(t.classList.add(`fade-out`),e=setTimeout(()=>{t.remove(),pe(!0)},300)):pe(!0)},150);return()=>{clearTimeout(t),e&&clearTimeout(e)}},[W,V,n,ue,de,ne,re]),Q.useEffect(()=>{if(!V||ae!==`malformed`)return;let e=document.getElementById(`initial-loading`);e&&(e.textContent=`Desktop startup failed — please restart the app.`)},[V,ae]),Q.useEffect(()=>{if(!W||V)return;let e,t=setTimeout(()=>{let t=document.getElementById(`initial-loading`);t&&!n&&(t.classList.add(`fade-out`),e=setTimeout(()=>{t.remove()},300))},5e3);return()=>{clearTimeout(t),e&&clearTimeout(e)}},[W,V,n]),Q.useEffect(()=>{if(!W||h)return;let e=!1;return hr().then(()=>{if(!e)return t()}),()=>{e=!0}},[W,t,h]),Q.useEffect(()=>{if(!W||h||n)return;let e=!0,t,r=0,i=1e3,a=async()=>{if(!e)return;if(r>=10){w(!0);return}let n=Ln.getState();if(n.isInitialized){w(!1);return}if(r+=1,await hr(),!e)return;await n.initializeApp();let o=Ln.getState();if(!e)return;if(o.isInitialized){w(!1);return}if(r>=10){w(!0);return}let s=Math.min(i*2**(r-1),16e3);t=setTimeout(a,s)};return t=setTimeout(a,i),()=>{e=!1,t&&clearTimeout(t)}},[W,T,n,h]),Q.useEffect(()=>{W&&n&&w(!1)},[W,n]),Q.useEffect(()=>{if(!W||!C)return;let e=document.getElementById(`initial-loading`);if(e){e.classList.add(`fade-out`);let t=setTimeout(()=>{e.remove()},300);return()=>clearTimeout(t)}},[W,C]),Ti({enabled:W&&!h,source:`startupRecovery`}),Q.useEffect(()=>{u||h||r&&et.setDirectory(c)},[c,u,r,h]),Q.useEffect(()=>{if(!ce||typeof window>`u`)return;let e=e=>{let t=e?.visible===!0;y(t)},t=t=>{if(t.origin!==window.location.origin)return;let n=t.data;n?.type===`yuri:embedded-visibility`&&e(n.payload)},n=window;return n.__yuriSetEmbeddedVisibility=e,window.addEventListener(`message`,t),window.parent&&window.parent!==window&&window.parent.postMessage({type:xo},window.location.origin),()=>{window.removeEventListener(`message`,t),n.__yuriSetEmbeddedVisibility===e&&delete n.__yuriSetEmbeddedVisibility}},[ce]),Q.useEffect(()=>{!ce?.directory||h||c!==ce.directory&&l(ce.directory,{showOverlay:!1})},[c,ce,h,l]),Q.useEffect(()=>{if(!ce||typeof window>`u`)return;let e=e=>{e.storageArea===window.localStorage&&e.key===`ui-store`&&q.persist.rehydrate()};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}},[ce]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;PC(t??{})},t=e=>{let t=e.detail?.assistantID;typeof t==`string`&&t.trim()&&Dr(t.trim())},n=e=>{let t=e.detail,n=t?.projectID,r=t?.taskID;n&&r&&Pt(async()=>{let{openScheduledTask:e}=await import(`./scheduledTaskNavigation-Bi7sRiFW.js`).then(e=>e.n);return{openScheduledTask:e}},__vite__mapDeps([120,1,21,5,3,2,6,7,8,22,9,23,20,24,25,18])).then(({openScheduledTask:e})=>e(n,r))};return window.addEventListener(`yuri:open-session`,e),window.addEventListener(`yuri:open-assistant`,t),window.addEventListener(`yuri:open-scheduled-task`,n),()=>{window.removeEventListener(`yuri:open-session`,e),window.removeEventListener(`yuri:open-assistant`,t),window.removeEventListener(`yuri:open-scheduled-task`,n)}},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=()=>{let e=Pe.getState().currentDirectory,{activeProjectId:t,projects:n}=mn.getState(),r=n.find(e=>e.id===t)??null;P(`desktop_open_draft_mini_chat_window`,{directory:e||r?.path||``,projectId:r?.id??null})};return window.addEventListener(`yuri:open-mini-chat`,e),()=>window.removeEventListener(`yuri:open-mini-chat`,e)},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=()=>{if(dn.getState().remoteSession)return;let e=cr.getState().currentSessionId;e&&sn(e)};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=0,t=t=>{let n=++e,r=t.detail,i=typeof r?.directory==`string`&&r.directory.trim().length>0?r.directory.trim():null,a=typeof r?.projectId==`string`&&r.projectId.trim().length>0?r.projectId.trim():null,o=typeof r?.initialPrompt==`string`&&r.initialPrompt.trim().length>0?r.initialPrompt.trim():void 0;q.getState().setActiveMainTab(`chat`),q.getState().setSessionSwitcherOpen(!1);let s=mn.getState(),c=s.projects.find(e=>e.id===(a??(i?null:s.activeProjectId)));if(r?.hostId){let t=dn.getState().remoteSession,c=s.activeProjectId;Vl({sessionId:null,isNewSession:!0,hostId:r.hostId,hubId:r.hubId,directory:i,projectId:a},()=>n===e&&dn.getState().remoteSession===t&&mn.getState().activeProjectId===c).then(async e=>{if(!e)return;let t=dn.getState().remoteSession;o&&t&&await Bl(t.location,o)}).catch(e=>J.error(e instanceof Error?e.message:String(e)));return}if(c?.hostId&&c.hubId){let e={hubId:c.hubId,hostId:c.hostId,directory:c.path};s.setActiveProjectIdOnly(c.id),dn.getState().openRemoteSession(c,e,null),o&&Bl(e,o).catch(e=>J.error(e instanceof Error?e.message:String(e)));return}dn.getState().clearRemoteSession(),cr.getState().openNewSessionDraft({selectedProjectId:a,directoryOverride:i,preserveDirectoryOverride:!!i,ensureProjectForDirectory:!!i,initialPrompt:o})};return window.addEventListener(`yuri:open-draft-session`,t),()=>{e+=1,window.removeEventListener(`yuri:open-draft-session`,t)}},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail,n=typeof t?.projectPath==`string`?t.projectPath.trim():``;if(!n)return;let r=mn.getState(),i=r.projects.find(e=>!e.hostId&&e.path===n);i?r.setActiveProject(i.id):r.addProject(n)};return window.addEventListener(`yuri:open-project`,e),()=>window.removeEventListener(`yuri:open-project`,e)},[]),Q.useEffect(()=>{typeof window>`u`||!W||!n||u||U.current||(U.current=!0,window.__yuriAppReady=!0,window.dispatchEvent(new Event(`yuri:app-ready`)))},[W,n,u]),Ei({enabled:W}),OC({enabled:W}),MC(),ya(),vl(),aC(K(()=>{p(e=>!e)})),Q.useEffect(()=>{x()&&Ut().then(async e=>{e&&await b(e)}).catch(console.warn)},[]),Q.useEffect(()=>{if(!n||!x()||R.current)return;R.current=!0;let e=!1,t=null,r=null;As.getState().subscribeDesktopUpdateEvents().then(t=>{if(e){t();return}r=t});let i=()=>{let e=As.getState();e.checking||e.checkForUpdates()},a=n=>{t=window.setTimeout(()=>{e||(document.visibilityState===`visible`&&i(),a(UC))},n)},o=()=>{if(e||document.visibilityState!==`visible`)return;let t=As.getState().lastChecked;t!=null&&Date.now()-t<WC||i()};return a(0),window.addEventListener(`focus`,o),()=>{e=!0,t!==null&&window.clearTimeout(t),window.removeEventListener(`focus`,o),r&&r()}},[n]),wC(),Q.useEffect(()=>{if(ce)return;let e=e=>{An(e)&&e.shiftKey&&!e.altKey&&(e.code===`KeyD`||e.key.toLowerCase()===`d`)&&(e.preventDefault(),p(e=>!e))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[ce]),Q.useEffect(()=>{ce||i&&setTimeout(()=>a(),5e3)},[a,ce,i]),Q.useEffect(()=>{if(!V||ae!==`not-injected`)return;let e=!1,t=0,n=()=>{if(e)return;t++;let r=A();if(r!==`not-injected`){if(e=!0,oe(r),r===`valid`){let e=L();e&&se(te({isDesktopShell:!0,bootOutcome:e}))}return}let i=Math.min(200*1.1**t,2e3);if(t>=50){let e=document.getElementById(`initial-loading`);e&&!e.textContent?.includes(`taking longer`)&&(e.textContent=`Desktop startup is taking longer than expected...`)}window.setTimeout(n,i)};return window.setTimeout(n,200),()=>{e=!0}},[V,ae]);let me=K(async()=>{if(j({isDesktopShell:v(),isDesktopLocalOriginActive:S()})){await D();return}window.location.reload()}),he=K(async()=>{if(!F){w(!1),I(!0);try{await hr(),await Ln.getState().initializeApp()}finally{I(!1)}Ln.getState().isInitialized||E(e=>e+1)}}),ge=e=>{if(e.screen===`recovery`)return e.variant};if(V&&H&&H.screen!==`main`){if(H.screen===`chooser`)return(0,$.jsx)(po,{children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-transparent`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-full`}),children:(0,$.jsx)(HC,{mode:`first-launch`,onCliAvailable:me,onChooseRemote:()=>{}})})})});let e=ge(H),t=H.screen===`recovery`&&`url`in H?H.url:void 0;return(0,$.jsx)(po,{children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-transparent`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-full`}),children:(0,$.jsx)(HC,{mode:`recovery`,recoveryVariant:e,recoveryHostUrl:t,recoveryHostLabel:void 0,onCliAvailable:me})})})})}if(ce)return Gn(),(0,$.jsx)(po,{children:(0,$.jsx)(rn,{sdk:et.getSdkClient(),directory:c||``,bootstrapDirectory:o,children:(0,$.jsx)(hi,{apis:e,children:(0,$.jsx)(Da,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-background`,children:(0,$.jsx)(XC,{embeddedSessionChat:ce,isVSCodeRuntime:h,embeddedBackgroundWorkEnabled:W})})})})},O)});if(le)return(0,$.jsx)(po,{children:(0,$.jsx)(RC,{})});if(C&&!n&&!h&&!ce)return(0,$.jsx)(po,{children:(0,$.jsx)(KC,{onRetry:()=>{he()},isRetrying:F})});let _e=!n&&!V;return(0,$.jsx)(po,{children:(0,$.jsx)(rn,{sdk:et.getSdkClient(),directory:c||``,bootstrapDirectory:o,children:(0,$.jsx)(hi,{apis:e,children:(0,$.jsx)(fl,{ready:fe&&n&&W,children:(0,$.jsx)($p,{children:(0,$.jsx)(Da,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:V?`h-full text-foreground bg-transparent`:`h-full text-foreground bg-background`,children:[(0,$.jsx)(Ji,{embeddedBackgroundWorkEnabled:W}),(0,$.jsx)(el,{}),(0,$.jsx)(Sc,{}),(0,$.jsx)(Vc,{}),(0,$.jsx)(iS,{}),V&&(0,$.jsx)(VC,{transition:M,ready:n&&r}),(0,$.jsx)(zC,{}),(0,$.jsx)(ui,{}),!_e&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(mc,{}),(0,$.jsx)(Lc,{}),(0,$.jsx)(vc,{}),(0,$.jsx)(GC,{}),f&&(0,$.jsx)(BS,{onClose:()=>p(!1)})]})]})})})})})},O)})}function QC(e){return e.isAboutDialogOpen}function $C(e){return e.setAboutDialogOpen}function ew(e){return e.currentDirectory}function tw(e){return e.currentSessionId}function nw(e){return e.setCurrentSession}if(typeof window<`u`&&!window.__YURI_REFRESH_DEBUG_INSTALLED__){window.__YURI_REFRESH_DEBUG_INSTALLED__=!0;let e=performance.getEntriesByType(`navigation`)[0];console.warn(`[refresh-debug] renderer-entry`,{navigationType:e?.type??`unknown`,protocol:window.location.protocol}),window.addEventListener(`beforeunload`,()=>{console.warn(`[refresh-debug] beforeunload`,{visibilityState:document.visibilityState})}),window.addEventListener(`pagehide`,e=>{console.warn(`[refresh-debug] pagehide`,{persisted:e.persisted})})}var rw=typeof window<`u`&&window.__YURI_RUNTIME_APIS__||(()=>{throw Error(`Runtime APIs not provided for legacy UI entrypoint.`)})();wo(),Qt(),v()&&nn(),Fi({runtimeKey:f(),initializeAppearance:Me,syncSettings:Ne,applyDirectory:wi,startWatchers:()=>{ci(),ji(),ti()},onError:(e,t)=>{console.error(e===`appearance`?`[main] appearance init failed:`:`[main] settings init failed:`,t)}});var iw=document.getElementById(`root`);if(!iw)throw Error(`Root element not found`);(0,uu.createRoot)(iw).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(Ca,{children:(0,$.jsx)(Xt,{children:(0,$.jsx)(Ai,{children:(0,$.jsx)(Mi,{children:(0,$.jsx)(si,{children:(0,$.jsx)(pi,{children:(0,$.jsx)(ZC,{apis:rw})})})})})})})}));
|
|
169
|
+
Now write the final fused answer.`,synthetic:!0}],directory:i??et.getDirectory()})}catch(e){console.error(`[MultiRunFusion] Failed to start fusion`,e),J.error(r(`multirun.fusion.toast.failed`))}finally{w(!1)}}},disabled:!k,children:r(C?`multirun.fusion.actions.starting`:`multirun.fusion.actions.start`)})]})]})})}function qb(e){let t=(0,du.c)(13),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=[`yuri-icon`,n].filter(Boolean),t[3]=n,t[4]=i);let a=i.join(` `),o,s,c,l,u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`path`,{d:`M12 4.5v6.25M12 10.75v3.5M12 10.75H7.25A3.25 3.25 0 0 0 4 14v1.25M12 10.75h4.75A3.25 3.25 0 0 1 20 14v1.25`}),s=(0,$.jsx)(`path`,{d:`M9.25 7.25 12 4.5l2.75 2.75`}),c=(0,$.jsx)(`circle`,{cx:`4`,cy:`17.25`,r:`1.55`}),l=(0,$.jsx)(`circle`,{cx:`12`,cy:`17.25`,r:`1.55`}),u=(0,$.jsx)(`circle`,{cx:`20`,cy:`17.25`,r:`1.55`}),t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u):(o=t[5],s=t[6],c=t[7],l=t[8],u=t[9]);let d;return t[10]!==r||t[11]!==a?(d=(0,$.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:Hr,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:a,...r,children:[o,s,c,l,u]}),t[10]=r,t[11]=a,t[12]=d):d=t[12],d}var Jb=e(we(),1),Yb=null,Xb=!1,Zb=(e,t=ga.getState().focus)=>e===null?null:typeof e==`string`?t?.sessionId===e?t:qi(e):e,Qb=e=>{typeof window>`u`||(e.commitFrame!==null&&window.cancelAnimationFrame(e.commitFrame),e.paintFrame!==null&&window.cancelAnimationFrame(e.paintFrame),e.fallbackTimer!==null&&window.clearTimeout(e.fallbackTimer))},$b=()=>{Yb&&=(Qb(Yb),null)},ex=(e,t)=>{$b(),nr(!0);let n=Zb(e);if(!n)return;Xb=!0;let r;try{r=It(n.sessionId)}finally{Xb=!1}Yb={commit:t,commitFrame:null,fallbackTimer:null,focus:n,intent:r,paintFrame:null,scheduled:!1},(0,Jb.flushSync)(()=>{ga.getState().setFocus(n)}),typeof window<`u`&&(Yb.fallbackTimer=window.setTimeout(()=>{tx(n)},150))},tx=e=>{let t=Yb,n=Zb(e);if(!t||!Ii(t.focus,n)||t.scheduled)return;t.scheduled=!0,typeof window<`u`&&t.fallbackTimer!==null&&(window.clearTimeout(t.fallbackTimer),t.fallbackTimer=null);let r=()=>{Yb===t&&Ft()===t.intent&&(Yb=null,Yn(),t.commit())};if(typeof window>`u`){r();return}t.commitFrame=window.requestAnimationFrame(()=>{Yb===t&&Ft()===t.intent&&(t.paintFrame=window.requestAnimationFrame(r))})},nx=e=>{if(Yb)return;let t=ga.getState();t.setFocus(Zb(e,t.focus))};Lt(e=>{if(Xb)return;let t=Yb;if(t?.intent===e)return;t&&$b();let n=ga.getState();n.setFocus(Zb(e.sessionId,n.focus))});var rx=e=>{let t=[],n=e=>{e.children.forEach(e=>{t.push(e.session.id),n(e)})};return n(e),t},ix=Q.memo(function(e){let t=(0,du.c)(21),{pinned:n,pinLabel:r,buttonSizeClass:i,iconSizeClass:a,onPointerDown:o,onMouseDown:s,onPin:c}=e,l=n?`text-foreground`:`text-muted-foreground`,u;t[0]!==i||t[1]!==l?(u=X(`inline-flex items-center justify-center rounded-md hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,l,i),t[0]=i,t[1]=l,t[2]=u):u=t[2];let d=n?`pushpin-2-fill`:`pushpin-2`,f=!n&&`rotate-45`,p;t[3]!==a||t[4]!==f?(p=X(a,f),t[3]=a,t[4]=f,t[5]=p):p=t[5];let m;t[6]!==d||t[7]!==p?(m=(0,$.jsx)(Z,{name:d,className:p}),t[6]=d,t[7]=p,t[8]=m):m=t[8];let h;t[9]!==s||t[10]!==c||t[11]!==o||t[12]!==r||t[13]!==u||t[14]!==m?(h=(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:u,"aria-label":r,onPointerDown:o,onMouseDown:s,onClick:c,onKeyDown:_x,children:m})}),t[9]=s,t[10]=c,t[11]=o,t[12]=r,t[13]=u,t[14]=m,t[15]=h):h=t[15];let g;t[16]===r?g=t[17]:(g=(0,$.jsx)(Ea,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:r}),t[16]=r,t[17]=g);let _;return t[18]!==h||t[19]!==g?(_=(0,$.jsxs)(Oa,{children:[h,g]}),t[18]=h,t[19]=g,t[20]=_):_=t[20],_}),ax=Q.memo(function(e){let t=(0,du.c)(24),{archiveLabel:n,deleteLabel:r,deleteOnly:i,buttonSizeClass:a,iconSizeClass:o,revealClassName:s,onPointerDown:c,onMouseDown:l,onArchive:u,onDelete:d}=e,f=i!==void 0&&i,p=Tb(),m=f||p,h=m?r:n,g;t[0]!==f||t[1]!==u||t[2]!==d||t[3]!==p?(g=e=>{if(f||p||e.shiftKey){d(e);return}u(e)},t[0]=f,t[1]=u,t[2]=d,t[3]=p,t[4]=g):g=t[4];let _=g,v=m?`text-destructive hover:text-destructive hover:bg-[color-mix(in_srgb,var(--status-error)_12%,transparent)]`:`text-muted-foreground hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,y;t[5]!==a||t[6]!==s||t[7]!==v?(y=X(`inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,v,a,s),t[5]=a,t[6]=s,t[7]=v,t[8]=y):y=t[8];let b=m?`delete-bin`:`inbox-archive`,x;t[9]!==o||t[10]!==b?(x=(0,$.jsx)(Z,{name:b,className:o}),t[9]=o,t[10]=b,t[11]=x):x=t[11];let S;t[12]!==_||t[13]!==h||t[14]!==l||t[15]!==c||t[16]!==y||t[17]!==x?(S=(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:y,"aria-label":h,onPointerDown:c,onMouseDown:l,onClick:_,onKeyDown:vx,children:x})}),t[12]=_,t[13]=h,t[14]=l,t[15]=c,t[16]=y,t[17]=x,t[18]=S):S=t[18];let C;t[19]===h?C=t[20]:(C=(0,$.jsx)(Ea,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:h}),t[19]=h,t[20]=C);let w;return t[21]!==S||t[22]!==C?(w=(0,$.jsxs)(Oa,{children:[S,C]}),t[21]=S,t[22]=C,t[23]=w):w=t[23],w}),ox=Q.memo(function(e){let t=(0,du.c)(3),{number:n}=e;if(!Vb())return null;let r=Fn()?`⌘${n}`:`Ctrl+${n}`,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(bi,{"data-sidebar-shortcut-number":n,variant:`hint`,"aria-hidden":`true`,children:r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i});function sx(e){let{t:n}=Zt(),{node:r,depth:i=0,groupDirectory:a,projectId:o,archivedBucket:s=!1,pinnedSessionIds:c,expandedParents:l,hasSessionSearchQuery:u,normalizedSessionSearchQuery:d,editingId:f,setEditingId:p,editTitle:h,setEditTitle:g,handleSaveEdit:_,handleCancelEdit:v,toggleParent:y,handleSessionSelect:b,togglePinnedSession:x,handleShareSession:S,copiedSessionId:C,handleCopyShareUrl:T,handleUnshareSession:E,setOpenSidebarMenuKey:D,renamingFolderId:O,getFoldersForScope:k,getSessionFolderId:A,removeSessionFromFolder:j,addSessionToFolder:N,createFolderAndStartRename:F,handleDeleteSession:I,mobileVariant:L,alwaysShowActions:z,renderSessionNode:ee,secondaryMeta:B,renderContext:V=`project`,subtreeContainsActive:te,subtreeContainsEditing:ne,menuOpenSessionId:re,childRenderExtrasFor:ie,liveSessionById:ae,shortcutNumber:oe=null}=e,H=!!B?.projectLabel,se=!!B?.branchLabel,U=br(e=>e.displayMode),ce=Q.useMemo(()=>w(),[]),W=U===`minimal`||ce,le=Q.useMemo(()=>R(),[]),ue=Q.useContext(vt),fe=ce?`group-hover:opacity-100 group-hover:pointer-events-auto`:`group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto`,me=ce,he=V===`pinned`&&c.has(r.session.id),ge=!he&&!s&&!L,ye=`h-5 w-5`,we=`h-3.5 w-3.5`,Ee=(ge||he?1:0)+ +!!me+1,De=Ee>=3?`group-hover:pr-18 group-focus-within:pr-18`:Ee>=2?`group-hover:pr-12 group-focus-within:pr-12`:`group-hover:pr-7 group-focus-within:pr-7`,Oe=Ee>=2?`pr-12`:`pr-8`,ke=Q.useRef(!1),Ae=Q.useRef(!1),[je,Me]=Q.useState(!1),Ne=Q.useRef(f);Ne.current=f;let Pe=Q.useRef(null),[Fe,Ie]=Q.useState(h),[Le,Re]=Q.useState(f===r.session.id),G=Q.useRef(null),ze=Q.useRef(null),Be=Q.useRef(null),Ve=r.session,He=ae.get(Ve.id)??Ve,Ue=!!He.metadata?.yuri?.assistant,Ge=M(Ve.directory??null)??M(a??null),Ke=kn(Ge??void 0,{bootstrap:!1}),qe=_i(),Je=fb(e=>e.enabled),Ye=fb(Q.useMemo(()=>e=>e.selectedIds.has(Ve.id),[Ve.id])),Ze=fb(e=>e.toggleSelected),Qe=fb(e=>e.setRange),[et,tt]=Q.useState(!1),[nt,rt]=Q.useState(!0),[at,ot]=Q.useState(!1),[st,ct]=Q.useState(!1),lt=`${V}:${s?`archived`:`active`}:${Ve.id}`,ut=Tn(Q.useMemo(()=>e=>!!e.sessionMemoryState.get(on(Ve.id))?.isZombie,[Ve.id])),dt=qn(Ve.id),ft=Jn(Ve.id,Ge??void 0,{bootstrap:!1}),pt=ur(Ve.id,Ge??void 0,{bootstrap:!1}),mt=Q.useMemo(()=>({scope:V,sessionId:Ve.id,projectId:o??null}),[o,V,Ve.id]),ht=Q.useMemo(()=>Gi(mt)??``,[mt]),gt=Q.useRef(null),_t=ga(Q.useMemo(()=>e=>Ii(e.focus,mt),[mt]));Q.useLayoutEffect(()=>{if(!_t)return;let e=gt.current;e&&(L?e.scrollIntoView({block:`nearest`,inline:`nearest`}):Hy(e)),tx(mt)},[_t,L,mt]);let yt=He.title||n(`sessions.sidebar.session.untitled`),bt=fs(ds(He)),xt=He.metadata?.yuri?.titleRefresh,St=typeof xt?.lastError==`string`?xt.lastError:null,Ct=typeof xt?.failedAt==`number`?xt.failedAt:null;Q.useEffect(()=>{!St||Ct===null||console.warn(`[session-title] generation failed for ${Ve.id}: ${St}`)},[Ve.id,St,Ct]);let wt=typeof xt?.generationExpiresAt==`number`&&Number.isFinite(xt.generationExpiresAt)?xt.generationExpiresAt:0,[Tt,Et]=Q.useState(0),Dt=Q.useMemo(()=>Math.max(0,wt-Date.now()),[wt]),[,Ot,kt]=Mt(()=>Et(wt),Dt,{immediate:!1}),At=xt?.isGenerating===!0;Q.useEffect(()=>(At&&wt>Date.now()&&Ot(),kt),[At,wt,Ot,kt]);let jt=r.children.length>0||!!(He.hasChildren??Ve.hasChildren),Nt=c.has(Ve.id),Pt=lt,Ft=u?!0:l.has(Pt),It=!!He.parentID,Lt=V===`pinned`,q=tr(Ve.id),Rt=q>0&&!It,zt=In(He)||Date.now(),Bt=Ya(zt),Vt=Xa(zt),[Ht,Ut]=Q.useState(!1),Wt=Ht,Gt=Q.useMemo(()=>$l(He.title)!==null,[He.title]),[Kt,qt]=Q.useState(!1),Jt=Q.useMemo(()=>rx(r).length,[r]),Yt=K(e=>{let t=Ge??``,n=(Xe()??$e(t,Ke)).getTranscript(it(t,e)),r=Ke.getState().session.find(t=>t.id===e)?.revert?.messageID;return er({sessionID:e,messages:We(n),parts:n.partsByMessageID,revertMessageID:r}).list}),Xt=K(async e=>{let t=[],r=0;for(let i of e)try{await qe.ensureSessionRenderable(i.session.id);let e=Yt(i.session.id),a=i.session.title||n(`sessions.sidebar.session.export.untitledSubagent`),o=i.session.agent,s=await Xt(i.children);r+=s.skipped,t.push({title:a,agent:o,records:e,children:s.children})}catch{r+=rx(i).length+1}return{children:t,skipped:r}}),Qt=K(e=>{e<=0||J.warning(n(e===1?`sessions.sidebar.session.export.skippedSubtaskSingle`:`sessions.sidebar.session.export.skippedSubtaskMany`,{count:e}))}),$t=K(async e=>{if(!Ge){J.error(n(`sessions.sidebar.session.export.nothingToExport`));return}await qe.ensureSessionRenderable(Ve.id);let t=Yt(Ve.id);if(t.length===0){J.error(n(`sessions.sidebar.session.export.nothingToExport`));return}let i,a=0;if(e&&r.children.length>0){let e=await Xt(r.children);i=e.children,a=e.skipped}let o=ab(t,He.title??null,i),s=ub(He.title??null),c=await sb(o,s);if(c){J.success(n(`sessions.sidebar.session.export.success`),{action:{label:n(lb()),onClick:()=>{cb(c).then(e=>{e||J.error(n(`sessions.sidebar.session.export.failedRevealPath`))})}}}),Qt(a);return}ob(o,s),J.success(n(`sessions.sidebar.session.export.success`)),Qt(a)}),en=K(async()=>{if(r.children.length>0){rt(!0),tt(!0);return}await $t(!1)}),tn=K(()=>{Ge&&P(`desktop_open_session_mini_chat_window`,{sessionId:Ve.id,directory:Ge,apiBaseUrl:m(),clientToken:t()}).catch(e=>{console.warn(`[session-sidebar] failed to open mini chat window`,e)})});Q.useLayoutEffect(()=>{if(f!==Ve.id){Le&&Re(!1),G.current===Ve.id&&(G.current=null);return}!Le||G.current===Ve.id||(G.current=Ve.id,Ie(h),queueMicrotask(()=>Be.current?.select()))},[f,h,Ve.id,Le]);let nn=K(e=>{if(!e&&Pe.current){let{id:e,title:t}=Pe.current;Pe.current=null,Re(!0),p(e),g(t)}}),rn=K(e=>{Ut(e)}),an=K(e=>{e.preventDefault(),e.stopPropagation()}),cn=K(e=>{e.preventDefault(),e.stopPropagation()}),ln=K(e=>{e.preventDefault(),e.stopPropagation(),D(null),x(Ve.id)}),un=K(e=>{e.preventDefault(),e.stopPropagation(),D(null),I(Ve,{archivedBucket:s})}),dn=K(e=>{e.preventDefault(),e.stopPropagation(),D(null),I(Ve,{archivedBucket:s,hardDelete:!0,skipConfirm:!0})}),fn=K(e=>{e.preventDefault(),e.stopPropagation(),D(null),x(Ve.id)}),pn=K(()=>{!Ge||at||(ot(!0),(async()=>{try{await qe.refreshSessionTranscript(Ve.id,{directory:Ge}),J.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{J.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{ot(!1)}})())}),mn=K(e=>{e.preventDefault(),e.stopPropagation()}),hn=K(e=>{e.preventDefault(),e.stopPropagation()}),gn=K(e=>{e.preventDefault(),e.stopPropagation(),ue?.vscode?.executeCommand(`yuri.openSessionInEditor`,Ve.id,yt)}),_n=K(e=>{if(ke.current){ke.current=!1;return}if(Je){if(e?.preventDefault(),e?.stopPropagation(),e?.shiftKey){let e=(typeof document<`u`?Array.from(document.querySelectorAll(`[data-session-row]`)):[]).map(e=>e.getAttribute(`data-session-row`)).filter(e=>typeof e==`string`&&e.length>0),t=fb.getState().anchorId,n=new Map;n.set(Ve.id,rx(r)),Qe(t,Ve.id,e,Ge??null,n);return}Ze(Ve.id,Ge??null,rx(r));return}b(Ve.id,Ge,o,V)}),yn=K(e=>{if(e.defaultPrevented||e.target?.closest(`button, a, input, [role="menuitem"], [role="menu"]`))return;_n(e);let t=e.currentTarget.querySelector(`[data-session-title]`);t&&!L&&(t.focus({preventScroll:!0}),Ae.current=!0)}),bn=K(e=>{(e.button===2||e.button===0&&e.ctrlKey&&!Je)&&(ke.current=!0)}),xn=K(e=>{Ae.current=e.pointerType===`mouse`,L&&e.pointerType===`touch`&&Me(!0)}),Sn=K(e=>{L&&e.pointerType===`touch`&&Me(!1)}),Cn=K(e=>{e.key!==`Enter`||!Ae.current||(e.preventDefault(),e.stopPropagation(),Re(!0),p(Ve.id),g(yt))}),wn=K(e=>{if(_n(e),!Ae.current)return;let t=e.currentTarget;window.requestAnimationFrame(()=>{Ae.current=!0,t.focus({preventScroll:!0})})}),En=K(()=>{Ae.current=!1}),Dn=K(()=>{!Ft&&!st&&(ct(!0),qe.loadChildren(Ve.id,Ge).catch(()=>J.error(n(`sessions.sidebar.session.subsessions.loadFailed`))).finally(()=>ct(!1))),y(Pt)});if(f===Ve.id&&Le){let e=async()=>{v();try{await vn(Ve.id)}catch(e){console.warn(`[session-sidebar] failed to request smart title:`,e)}};return(0,$.jsx)(`div`,{className:`group relative my-0.5 flex items-center rounded-lg py-1.5 pr-2`,style:{paddingLeft:lo(i)},children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0`,children:[(0,$.jsxs)(`form`,{ref:ze,className:`flex w-full items-center gap-2`,onSubmit:e=>{e.preventDefault(),_(Fe)},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||v()},children:[(0,$.jsx)(`input`,{ref:Be,value:Fe,onChange:e=>Ie(e.target.value),className:`flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground`,autoFocus:!0,placeholder:n(`sessions.sidebar.session.menu.rename`),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`){v();return}}}),(0,$.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{e()},"aria-label":n(`sessions.sidebar.session.rename.smartTitle`),title:n(`sessions.sidebar.session.rename.smartTitle`),className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(Z,{name:`ai-generate-2`,className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`submit`,onMouseDown:e=>e.preventDefault(),"aria-label":n(`sessions.sidebar.session.rename.save`),title:n(`sessions.sidebar.session.rename.save`),className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(Z,{name:`check`,className:`size-3.5`})})]}),W?null:(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-3 text-muted-foreground/60 min-w-0 overflow-hidden leading-tight`,style:{fontSize:`calc(var(--text-ui-label) * 0.85)`},children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 overflow-hidden`,children:[jt&&!Lt&&!It?(0,$.jsx)(`span`,{className:`inline-flex items-center justify-center flex-shrink-0`,children:Ft?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-3 w-3`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-3 w-3`})}):null,(0,$.jsx)(`span`,{className:`flex-shrink-0`,children:Bt}),H?(0,$.jsx)(`span`,{className:`truncate`,children:B?.projectLabel}):null,se?(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-0.5`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`h-3 w-3 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:B?.branchLabel})]}):null]})})]})},Ve.id)}let An=dt,jn=At&&wt>Date.now()&&Tt!==wt,Mn=ft.length,Nn=pt.length>0,Pn=Nn||An||!Nn&&!An&&Rt,Fn=!z||ce,Ln=Nn?(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":n(`sessions.sidebar.session.status.questionRequired`),title:n(`sessions.sidebar.session.status.questionRequired`),children:(0,$.jsx)(Z,{name:`question`,className:`h-3.5 w-3.5 text-primary`})}):An?(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":n(`sessions.sidebar.session.status.active`),title:n(`sessions.sidebar.session.status.active`),children:(0,$.jsx)(Yc,{})}):(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":n(`sessions.sidebar.session.status.unread`),title:n(`sessions.sidebar.session.status.unread`),children:(0,$.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-[var(--status-info)]`})}),Rn=!Lt&&!It&&jt,zn=Rn&&!z&&!st,Bn=lo(Math.max(0,i-1)),Vn=Rn?(0,$.jsx)(`span`,{role:`button`,tabIndex:0,"aria-expanded":Ft,"aria-busy":st,onClick:e=>{e.stopPropagation(),e.currentTarget.blur(),Dn()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),Dn())},style:{minWidth:14,minHeight:14,left:Bn},className:X(`absolute inline-flex h-3.5 w-3.5 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`,W?`top-1/2 -translate-y-1/2`:`top-[14.5px] -translate-y-1/2`,zn?`opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto`:``),"aria-label":n(Ft?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),children:st?(0,$.jsx)(Yc,{size:12}):Ft?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-3 w-3`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-3 w-3`})}):null,Hn=ut?(0,$.jsx)(Z,{name:`error-warning`,className:`h-4 w-4 text-status-warning`}):null,Un=(0,$.jsx)(Te,{children:(0,$.jsx)(de,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(_e,{"data-slot":`dropdown-menu-content`,finalFocus:()=>!(O||Ne.current),style:{color:`var(--surface-elevated-foreground)`},className:X(rs,`yuri-session-context-menu min-w-[180px]`),children:(({Item:e,Separator:t,Sub:r,SubTrigger:i,SubContent:a})=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(e,{onClick:()=>x(Ve.id),className:`[&>svg]:mr-1`,children:[Nt?(0,$.jsx)(Z,{name:`unpin`,className:`mr-1 h-4 w-4`}):(0,$.jsx)(Z,{name:`pushpin`,className:`mr-1 h-4 w-4`}),n(Nt?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`)]}),It?null:(0,$.jsxs)(e,{onClick:()=>{q>0?sn(Ve.id):On(Ve.id,Ge||void 0).catch(()=>J.error(n(`sessions.sidebar.session.menu.markUnreadFailed`)))},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:q>0?`mail-open`:`mail`,className:`mr-1 h-4 w-4`}),n(q>0?`sessions.sidebar.session.menu.markRead`:`sessions.sidebar.session.menu.markUnread`)]}),(0,$.jsxs)(e,{onClick:()=>{Pe.current={id:Ve.id,title:yt}},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`pencil-ai`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.rename`)]}),$n()&&!He.share?(0,$.jsxs)(e,{onClick:()=>S(He),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`share-2`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.share`)]}):$n()&&He.share?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(e,{onClick:()=>{He.share?.url&&T(He.share.url,Ve.id)},className:`[&>svg]:mr-1`,children:C===Ve.id?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`check`,className:`mr-1 h-4 w-4`,style:{color:`var(--status-success)`}}),n(`sessions.sidebar.session.menu.copied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`file-copy`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.copyLink`)]})}),(0,$.jsxs)(e,{onClick:()=>E(Ve.id),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`link-unlink-m`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.unshare`)]})]}):null,(0,$.jsxs)(e,{onClick:()=>{en()},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`download`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.exportMarkdown`)]}),(0,$.jsxs)(e,{disabled:!Ge||at,onClick:()=>{pn()},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`refresh`,className:X(`mr-1 h-4 w-4`,at&&`animate-spin`)}),n(`sessions.sidebar.session.menu.refreshTranscript`)]}),Gt?(0,$.jsxs)(e,{onClick:()=>qt(!0),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(qb,{className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.runFusion`)]}):null,Ge&&!s?(()=>{let o=k(Ge),s=A(Ge,Ve.id);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(t,{}),(0,$.jsxs)(r,{children:[(0,$.jsxs)(i,{className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`folder`,className:`h-4 w-4`}),n(`sessions.sidebar.folders.moveToFolder`)]}),(0,$.jsxs)(a,{className:`min-w-[180px]`,children:[o.length===0?(0,$.jsx)(e,{disabled:!0,className:`text-muted-foreground`,children:n(`sessions.sidebar.folders.none`)}):o.map(t=>(0,$.jsxs)(e,{onClick:()=>{s===t.id?j(Ge,Ve.id):N(Ge,t.id,Ve.id)},children:[(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:t.name}),s===t.id?(0,$.jsx)(Z,{name:`check`,className:`ml-2 h-3.5 w-3.5 text-primary flex-shrink-0`}):null]},t.id)),(0,$.jsx)(t,{}),(0,$.jsxs)(e,{onClick:()=>{let e=F(Ge);e&&N(Ge,e.id,Ve.id)},children:[(0,$.jsx)(Z,{name:`add`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.folders.newFolderEllipsis`)]}),s?(0,$.jsxs)(e,{onClick:()=>{j(Ge,Ve.id)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(Z,{name:`close`,className:`mr-1 h-4 w-4 text-inherit`}),n(`sessions.sidebar.folders.removeFromFolder`)]}):null]})]})]})})():null,le?(0,$.jsxs)(e,{disabled:!Ge,onClick:tn,className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`window`,className:`mr-1 h-4 w-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:n(`sessions.sidebar.session.menu.openMiniChatWindow`)})]}):null,(0,$.jsx)(t,{}),s?null:(0,$.jsxs)(e,{className:`[&>svg]:mr-1`,onClick:()=>I(Ve,{archivedBucket:s}),children:[(0,$.jsx)(Z,{name:`inbox-archive`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.bulkActions.archive`)]}),(0,$.jsxs)(e,{className:`text-destructive/80 focus:text-destructive/80 [&>svg]:mr-1`,onClick:()=>I(Ve,{archivedBucket:s,hardDelete:!0}),children:[(0,$.jsx)(Z,{name:`delete-bin`,className:`mr-1 h-4 w-4 text-inherit`}),n(`sessions.sidebar.bulkActions.delete`)]})]}))({Item:({className:e,...t})=>(0,$.jsx)(ve,{className:X(as,e),...t}),Separator:({className:e,...t})=>(0,$.jsx)(pe,{className:X(is,e),...t}),Sub:xe,SubTrigger:({className:e,children:t,...n})=>(0,$.jsxs)(be,{className:X(ns,e),...n,children:[t,(0,$.jsx)(Z,{name:`arrow-right-s`,className:`ml-auto size-3.5`})]}),SubContent:({className:e,children:t,...n})=>(0,$.jsx)(Te,{children:(0,$.jsx)(de,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(_e,{"data-slot":`dropdown-menu-sub-content`,style:{color:`var(--surface-elevated-foreground)`},className:X(rs,`yuri-session-context-menu`,e),...n,children:t})})})})})})});return(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(hc,{sessionId:Ve.id,sessionDirectory:Ge??null,sessionTitle:yt,children:(0,$.jsxs)(Se,{open:Ht,onOpenChange:rn,onOpenChangeComplete:nn,children:[(0,$.jsxs)(Ce,{render:(0,$.jsx)(cl,{ref:gt,active:_t,selected:Ye,"data-session-row":Ve.id,"data-session-scope":Ge??``,"data-session-focus-scope":V,"data-session-focus-key":ht,"data-session-project-id":o??``,"data-session-archived":s?`1`:`0`,"data-session-depth":i,onClick:yn,className:X(_t&&!Ye&&`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,Ye&&`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,!_t&&!Ye&&`hover:bg-[color-mix(in_srgb,var(--surface-foreground)_3.5%,transparent)] dark:hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`)}),children:[Vn,(0,$.jsx)(Dc,{depth:i,children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(ic,{type:`button`,"data-session-title":!0,onPointerDown:xn,onPointerUp:Sn,onPointerCancel:Sn,onMouseDown:bn,onKeyDown:Cn,onBlur:En,onClick:wn,onDoubleClick:e=>{e.stopPropagation(),!L&&R()&&tn()},className:X(je&&`bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,z?ce?De:Oe:De),children:(0,$.jsxs)(`div`,{className:`flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:X(`block min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground`,jn&&`animate-text-shimmer`),"aria-busy":jn||void 0,children:za(yt,d)}),bt?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro tabular-nums text-muted-foreground`,children:bt}):null,Ue?(0,$.jsx)(Z,{name:`ai-agent`,className:`size-3 shrink-0 text-muted-foreground`,"aria-label":`Assistant`}):null,Mn>0?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0`,title:n(`sessions.sidebar.session.status.permissionRequired`),"aria-label":n(`sessions.sidebar.session.status.permissionRequired`),children:[(0,$.jsx)(Z,{name:`shield`,className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`leading-none`,children:Mn})]}):null,Pn?(0,$.jsx)(`span`,{className:X(`inline-flex shrink-0 items-center justify-center transition-none`,Fn?X(`group-hover:hidden group-focus-within:hidden`,Wt?`hidden`:``):Wt?`invisible`:``),children:Ln}):null,oe?(0,$.jsx)(ox,{number:oe}):null]})})}),ce?null:(0,$.jsx)(Ea,{side:`right`,align:`start`,sideOffset:8,className:`w-64 max-w-[min(16rem,calc(100vw-2rem))] px-3 py-2.5 text-left shadow-md`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-left`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1 break-words typography-ui-label font-medium text-foreground`,children:yt}),(0,$.jsx)(`div`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:Vt})]}),H?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 typography-meta text-muted-foreground`,children:[(0,$.jsx)(Z,{name:`folder-open`,className:`h-3.5 w-3.5 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:B?.projectLabel})]}):null,se?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 typography-meta text-muted-foreground`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`h-3.5 w-3.5 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:B?.branchLabel})]}):null]})})]})})}),Hn&&!L?(0,$.jsx)(`div`,{className:X(`absolute top-1/2 -translate-y-1/2 z-10`,W?`right-0`:`right-[30px]`),children:Hn}):null,(0,$.jsxs)(lc,{visible:Wt||z&&!ce,className:X(`absolute right-1 top-1/2 z-10 flex -translate-y-1/2 items-center gap-1 transition-none group-has-[[data-sidebar-shortcut-number]]:hidden`,Wt||z&&!ce?`opacity-100`:X(`opacity-0`,fe)),children:[ge?(0,$.jsx)(ix,{pinned:Nt,pinLabel:n(Nt?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`),buttonSizeClass:ye,iconSizeClass:we,onPointerDown:an,onMouseDown:cn,onPin:ln}):null,he?(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:X(`inline-flex items-center justify-center rounded-md text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,ye),"aria-label":n(`sessions.sidebar.session.actions.pinned`),onPointerDown:an,onMouseDown:cn,onClick:fn,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(Z,{name:`pushpin-2-fill`,className:we})})}),(0,$.jsx)(Ea,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:n(`sessions.sidebar.session.actions.pinned`)})]}):null,me?(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:X(`inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,ye),"aria-label":n(`sessions.sidebar.session.actions.openInEditor`),onPointerDown:mn,onMouseDown:hn,onClick:gn,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(Z,{name:`external-link`,className:we})})}),(0,$.jsx)(Ea,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:n(`sessions.sidebar.session.actions.openInEditor`)})]}):null,(0,$.jsx)(ax,{archiveLabel:n(`sessions.sidebar.bulkActions.archive`),deleteLabel:n(`sessions.sidebar.bulkActions.delete`),deleteOnly:s===!0,buttonSizeClass:ye,iconSizeClass:we,revealClassName:W&&!z&&!Wt?X(`opacity-0`,fe):`opacity-100`,onPointerDown:an,onMouseDown:cn,onArchive:un,onDelete:dn})]})]}),Un]})}),!Lt&&jt&&Ft?r.children.map(e=>{let t=ie?ie(e):{subtreeContainsActive:te,subtreeContainsEditing:ne,menuOpenSessionId:re,nodeStructureKey:``};return ee(e,i+1,Ge??a,o,s,void 0,V,t)}):null,(0,$.jsx)(Jr,{open:et,onOpenChange:tt,children:(0,$.jsxs)(Gr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,$.jsxs)(Ur,{children:[(0,$.jsx)(Kr,{children:n(`sessions.sidebar.session.export.dialog.title`)}),(0,$.jsx)(qr,{children:n(Jt===1?`sessions.sidebar.session.export.dialog.descriptionSingle`:`sessions.sidebar.session.export.dialog.descriptionMany`,{count:Jt})})]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-ui-label cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:nt,onChange:e=>rt(e.target.checked),className:`h-4 w-4 rounded border-border accent-primary`}),n(`sessions.sidebar.session.export.dialog.includeSubtasks`)]}),(0,$.jsxs)(Wr,{children:[(0,$.jsx)(Y,{type:`button`,onClick:()=>tt(!1),variant:`outline`,size:`sm`,children:n(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{type:`button`,onClick:()=>{tt(!1),$t(nt)},size:`sm`,children:n(`sessions.sidebar.session.export.dialog.confirm`)})]})]})}),Gt?(0,$.jsx)(Kb,{session:He,open:Kt,onOpenChange:qt}):null]},Ve.id)}var cx=e=>M(e.session.directory??null),lx=(e,t)=>(e?.projectLabel??null)===(t?.projectLabel??null)&&(e?.branchLabel??null)===(t?.branchLabel??null),ux=e=>{if(!e.openSidebarMenuKey)return null;let t=e.archivedBucket?`archived`:`active`,n=`${e.renderContext??`project`}:${t}:`;return e.openSidebarMenuKey.startsWith(n)?e.openSidebarMenuKey.slice(n.length):null},dx=e=>e.menuOpenSessionId??ux(e),fx=(e,t,n)=>t?n.has(e.node.session.id)?!0:Jc(e.node,t):!1,px=(e,t,n,r,i)=>{if(e.session.id!==t.session.id)return!0;let a=i(e);if(n.has(a)!==r.has(a)||e.children.length!==t.children.length)return!0;for(let a=0;a<e.children.length;a+=1)if(px(e.children[a],t.children[a],n,r,i))return!0;return!1},mx=(e,t,n,r)=>{if(e.session.id!==t.session.id)return!0;let i=e.session.id,a=n.get(i)??e.session,o=r.get(i)??t.session;if(a!==o&&Cl(a)!==Cl(o)||e.children.length!==t.children.length)return!0;for(let i=0;i<e.children.length;i+=1)if(mx(e.children[i],t.children[i],n,r))return!0;return!1},hx=(e,t)=>{if(e.hasSessionSearchQuery||t.hasSessionSearchQuery)return!1;let n=e.archivedBucket?`archived`:`active`,r=t.archivedBucket?`archived`:`active`;return px(e.node,t.node,e.expandedParents,t.expandedParents,t=>`${e.renderContext??`project`}:${n}:${t.session.id}`)||px(e.node,t.node,e.expandedParents,t.expandedParents,e=>`${t.renderContext??`project`}:${r}:${e.session.id}`)},gx=Q.memo(sx,(e,t)=>{if(e.node.session.id!==t.node.session.id||e.depth!==t.depth||e.groupDirectory!==t.groupDirectory||e.projectId!==t.projectId||e.archivedBucket!==t.archivedBucket||(e.renderContext??`project`)!==(t.renderContext??`project`)||e.mobileVariant!==t.mobileVariant||e.alwaysShowActions!==t.alwaysShowActions||e.shortcutNumber!==t.shortcutNumber||e.hasSessionSearchQuery!==t.hasSessionSearchQuery||e.normalizedSessionSearchQuery!==t.normalizedSessionSearchQuery||e.notifyOnSubtasks!==t.notifyOnSubtasks||e.nodeStructureKey!==t.nodeStructureKey||e.node.session.hasChildren!==t.node.session.hasChildren||cx(e.node)!==cx(t.node)||!lx(e.secondaryMeta,t.secondaryMeta)||e.liveSessionById!==t.liveSessionById&&mx(e.node,t.node,e.liveSessionById,t.liveSessionById)||e.pinnedSessionIds!==t.pinnedSessionIds&&px(e.node,t.node,e.pinnedSessionIds,t.pinnedSessionIds,e=>e.session.id)||e.expandedParents!==t.expandedParents&&hx(e,t)||e.currentSessionId!==t.currentSessionId&&(fx(e,e.currentSessionId,e.subtreeContainsActive)||fx(t,t.currentSessionId,t.subtreeContainsActive))||e.editingId!==t.editingId&&(fx(e,e.editingId,e.subtreeContainsEditing)||fx(t,t.editingId,t.subtreeContainsEditing))||e.editTitle!==t.editTitle&&(fx(e,e.editingId,e.subtreeContainsEditing)||fx(t,t.editingId,t.subtreeContainsEditing))||e.copiedSessionId!==t.copiedSessionId&&(Jc(e.node,e.copiedSessionId)||Jc(t.node,t.copiedSessionId)))return!1;if(e.openSidebarMenuKey!==t.openSidebarMenuKey){let n=dx(e),r=dx(t);if(Jc(e.node,n)||Jc(t.node,r))return!1}if(e.renamingFolderId!==t.renamingFolderId){let n=dx(e),r=dx(t);if(Jc(e.node,n)||Jc(t.node,r))return!1}return e.setEditingId===t.setEditingId&&e.setEditTitle===t.setEditTitle&&e.handleSaveEdit===t.handleSaveEdit&&e.handleCancelEdit===t.handleCancelEdit&&e.toggleParent===t.toggleParent&&e.handleSessionSelect===t.handleSessionSelect&&e.handleSessionDoubleClick===t.handleSessionDoubleClick&&e.togglePinnedSession===t.togglePinnedSession&&e.handleShareSession===t.handleShareSession&&e.handleCopyShareUrl===t.handleCopyShareUrl&&e.handleUnshareSession===t.handleUnshareSession&&e.setOpenSidebarMenuKey===t.setOpenSidebarMenuKey&&e.getFoldersForScope===t.getFoldersForScope&&e.getSessionFolderId===t.getSessionFolderId&&e.removeSessionFromFolder===t.removeSessionFromFolder&&e.addSessionToFolder===t.addSessionToFolder&&e.createFolderAndStartRename===t.createFolderAndStartRename&&e.handleDeleteSession===t.handleDeleteSession&&e.renderSessionNode===t.renderSessionNode});function _x(e){return e.stopPropagation()}function vx(e){return e.stopPropagation()}function yx(e){let t=(0,du.c)(71),{t:n}=Zt(),{value:r,setValue:i,showDeletionDialog:a,setShowDeletionDialog:o,onConfirm:s}=e,c,l,u,d,f,p,m,h,g,_;if(t[0]!==i||t[1]!==n||t[2]!==r){let e=n(`sessions.sidebar.session.untitled`);d=Jr,g=!!r,t[13]===i?_=t[14]:(_=e=>{e||i(null)},t[13]=i,t[14]=_),u=Gr,m=!1,h=`max-w-sm gap-5`,l=Ur;let a;t[15]!==n||t[16]!==r?.archivedBucket?(a=r?.archivedBucket?n(`sessions.sidebar.dialogs.deleteSession.title`):n(`sessions.sidebar.dialogs.archiveSession.title`),t[15]=n,t[16]=r?.archivedBucket,t[17]=a):a=t[17],t[18]===a?p=t[19]:(p=(0,$.jsx)(Kr,{children:a}),t[18]=a,t[19]=p),c=qr,f=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n(`sessions.sidebar.dialogs.deleteSession.withOneSubtask`,{sessionTitle:r.session.title||e,count:r.descendantCount}):n(`sessions.sidebar.dialogs.deleteSession.withManySubtasks`,{sessionTitle:r.session.title||e,count:r.descendantCount}):r.descendantCount===1?n(`sessions.sidebar.dialogs.archiveSession.withOneSubtask`,{sessionTitle:r.session.title||e,count:r.descendantCount}):n(`sessions.sidebar.dialogs.archiveSession.withManySubtasks`,{sessionTitle:r.session.title||e,count:r.descendantCount}):r?.archivedBucket?n(`sessions.sidebar.dialogs.deleteSession.single`,{sessionTitle:r?.session.title||e}):n(`sessions.sidebar.dialogs.archiveSession.single`,{sessionTitle:r?.session.title||e}),t[0]=i,t[1]=n,t[2]=r,t[3]=c,t[4]=l,t[5]=u,t[6]=d,t[7]=f,t[8]=p,t[9]=m,t[10]=h,t[11]=g,t[12]=_}else c=t[3],l=t[4],u=t[5],d=t[6],f=t[7],p=t[8],m=t[9],h=t[10],g=t[11],_=t[12];let v;t[20]!==c||t[21]!==f?(v=(0,$.jsx)(c,{children:f}),t[20]=c,t[21]=f,t[22]=v):v=t[22];let y;t[23]!==l||t[24]!==p||t[25]!==v?(y=(0,$.jsxs)(l,{children:[p,v]}),t[23]=l,t[24]=p,t[25]=v,t[26]=y):y=t[26];let b;t[27]!==o||t[28]!==a?(b=()=>o(!a),t[27]=o,t[28]=a,t[29]=b):b=t[29];let x=!a,S;t[30]===a?S=t[31]:(S=a?(0,$.jsx)(Z,{name:`checkbox-blank`,className:`h-4 w-4`}):(0,$.jsx)(Z,{name:`checkbox`,className:`h-4 w-4 text-primary`}),t[30]=a,t[31]=S);let C;t[32]===n?C=t[33]:(C=n(`sessions.sidebar.dialogs.neverAsk`),t[32]=n,t[33]=C);let w;t[34]!==S||t[35]!==C||t[36]!==b||t[37]!==x?(w=(0,$.jsxs)(`button`,{type:`button`,onClick:b,className:`inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":x,children:[S,C]}),t[34]=S,t[35]=C,t[36]=b,t[37]=x,t[38]=w):w=t[38];let T;t[39]===i?T=t[40]:(T=()=>i(null),t[39]=i,t[40]=T);let E;t[41]===n?E=t[42]:(E=n(`sessions.sidebar.dialogs.cancel`),t[41]=n,t[42]=E);let D;t[43]!==T||t[44]!==E?(D=(0,$.jsx)(`button`,{type:`button`,onClick:T,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:E}),t[43]=T,t[44]=E,t[45]=D):D=t[45];let O;t[46]===s?O=t[47]:(O=()=>void s(),t[46]=s,t[47]=O);let k;t[48]!==n||t[49]!==r?.archivedBucket?(k=r?.archivedBucket?n(`sessions.sidebar.bulkActions.delete`):n(`sessions.sidebar.bulkActions.archive`),t[48]=n,t[49]=r?.archivedBucket,t[50]=k):k=t[50];let A;t[51]!==O||t[52]!==k?(A=(0,$.jsx)(`button`,{type:`button`,onClick:O,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:k}),t[51]=O,t[52]=k,t[53]=A):A=t[53];let j;t[54]!==D||t[55]!==A?(j=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[D,A]}),t[54]=D,t[55]=A,t[56]=j):j=t[56];let M;t[57]!==w||t[58]!==j?(M=(0,$.jsxs)(Wr,{className:`w-full sm:items-center sm:justify-between`,children:[w,j]}),t[57]=w,t[58]=j,t[59]=M):M=t[59];let N;t[60]!==u||t[61]!==m||t[62]!==M||t[63]!==h||t[64]!==y?(N=(0,$.jsxs)(u,{showCloseButton:m,className:h,children:[y,M]}),t[60]=u,t[61]=m,t[62]=M,t[63]=h,t[64]=y,t[65]=N):N=t[65];let P;return t[66]!==d||t[67]!==N||t[68]!==g||t[69]!==_?(P=(0,$.jsx)(d,{open:g,onOpenChange:_,children:N}),t[66]=d,t[67]=N,t[68]=g,t[69]=_,t[70]=P):P=t[70],P}function bx(e){let t=(0,du.c)(57),{t:n}=Zt(),{value:r,setValue:i,showDeletionDialog:a,setShowDeletionDialog:o,onConfirm:s}=e,c=r?.archivedBucket===!0,l=r?.sessionCount??0,u;t[0]!==c||t[1]!==l||t[2]!==n?(u=n(c?l===1?`sessions.sidebar.dialogs.deleteSession.title`:`sessions.sidebar.dialogs.deleteSessions.title`:l===1?`sessions.sidebar.dialogs.archiveSession.title`:`sessions.sidebar.dialogs.archiveSessions.title`),t[0]=c,t[1]=l,t[2]=n,t[3]=u):u=t[3];let d=u,f;t[4]!==c||t[5]!==l||t[6]!==n?(f=n(c?l===1?`sessions.sidebar.dialogs.deleteSessions.singleDescription`:`sessions.sidebar.dialogs.deleteSessions.pluralDescription`:l===1?`sessions.sidebar.dialogs.archiveSessions.singleDescription`:`sessions.sidebar.dialogs.archiveSessions.pluralDescription`,{count:l}),t[4]=c,t[5]=l,t[6]=n,t[7]=f):f=t[7];let p=f,m=!!r,h;t[8]===i?h=t[9]:(h=e=>{e||i(null)},t[8]=i,t[9]=h);let g;t[10]===d?g=t[11]:(g=(0,$.jsx)(Kr,{children:d}),t[10]=d,t[11]=g);let _;t[12]===p?_=t[13]:(_=(0,$.jsx)(qr,{children:p}),t[12]=p,t[13]=_);let v;t[14]!==g||t[15]!==_?(v=(0,$.jsxs)(Ur,{children:[g,_]}),t[14]=g,t[15]=_,t[16]=v):v=t[16];let y;t[17]!==o||t[18]!==a?(y=()=>o(!a),t[17]=o,t[18]=a,t[19]=y):y=t[19];let b=!a,x;t[20]===a?x=t[21]:(x=a?(0,$.jsx)(Z,{name:`checkbox-blank`,className:`h-4 w-4`}):(0,$.jsx)(Z,{name:`checkbox`,className:`h-4 w-4 text-primary`}),t[20]=a,t[21]=x);let S;t[22]===n?S=t[23]:(S=n(`sessions.sidebar.dialogs.neverAsk`),t[22]=n,t[23]=S);let C;t[24]!==S||t[25]!==y||t[26]!==b||t[27]!==x?(C=(0,$.jsxs)(`button`,{type:`button`,onClick:y,className:`inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":b,children:[x,S]}),t[24]=S,t[25]=y,t[26]=b,t[27]=x,t[28]=C):C=t[28];let w;t[29]===i?w=t[30]:(w=()=>i(null),t[29]=i,t[30]=w);let T;t[31]===n?T=t[32]:(T=n(`sessions.sidebar.dialogs.cancel`),t[31]=n,t[32]=T);let E;t[33]!==w||t[34]!==T?(E=(0,$.jsx)(`button`,{type:`button`,onClick:w,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:T}),t[33]=w,t[34]=T,t[35]=E):E=t[35];let D;t[36]===s?D=t[37]:(D=()=>void s(),t[36]=s,t[37]=D);let O;t[38]!==c||t[39]!==n?(O=n(c?`sessions.sidebar.bulkActions.delete`:`sessions.sidebar.bulkActions.archive`),t[38]=c,t[39]=n,t[40]=O):O=t[40];let k;t[41]!==D||t[42]!==O?(k=(0,$.jsx)(`button`,{type:`button`,onClick:D,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:O}),t[41]=D,t[42]=O,t[43]=k):k=t[43];let A;t[44]!==E||t[45]!==k?(A=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[E,k]}),t[44]=E,t[45]=k,t[46]=A):A=t[46];let j;t[47]!==C||t[48]!==A?(j=(0,$.jsxs)(Wr,{className:`w-full sm:items-center sm:justify-between`,children:[C,A]}),t[47]=C,t[48]=A,t[49]=j):j=t[49];let M;t[50]!==j||t[51]!==v?(M=(0,$.jsxs)(Gr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[v,j]}),t[50]=j,t[51]=v,t[52]=M):M=t[52];let N;return t[53]!==m||t[54]!==M||t[55]!==h?(N=(0,$.jsx)(Jr,{open:m,onOpenChange:h,children:M}),t[53]=m,t[54]=M,t[55]=h,t[56]=N):N=t[56],N}function xx(e){let t=(0,du.c)(36),{t:n}=Zt(),{value:r,setValue:i,onConfirm:a}=e,o=!!r,s;t[0]===i?s=t[1]:(s=e=>{e||i(null)},t[0]=i,t[1]=s);let c;t[2]===n?c=t[3]:(c=n(`sessions.sidebar.dialogs.deleteFolder.title`),t[2]=n,t[3]=c);let l;t[4]===c?l=t[5]:(l=(0,$.jsx)(Kr,{children:c}),t[4]=c,t[5]=l);let u;t[6]!==n||t[7]!==r?(u=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?n(`sessions.sidebar.dialogs.deleteFolder.withOneSubfolder`,{folderName:r.folderName,count:r.subFolderCount}):n(`sessions.sidebar.dialogs.deleteFolder.withManySubfolders`,{folderName:r.folderName,count:r.subFolderCount}):n(`sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders`,{folderName:r.folderName}):n(`sessions.sidebar.dialogs.deleteFolder.single`,{folderName:r?.folderName??``}),t[6]=n,t[7]=r,t[8]=u):u=t[8];let d;t[9]===u?d=t[10]:(d=(0,$.jsx)(qr,{children:u}),t[9]=u,t[10]=d);let f;t[11]!==l||t[12]!==d?(f=(0,$.jsxs)(Ur,{children:[l,d]}),t[11]=l,t[12]=d,t[13]=f):f=t[13];let p;t[14]===i?p=t[15]:(p=()=>i(null),t[14]=i,t[15]=p);let m;t[16]===n?m=t[17]:(m=n(`sessions.sidebar.dialogs.cancel`),t[16]=n,t[17]=m);let h;t[18]!==p||t[19]!==m?(h=(0,$.jsx)(`button`,{type:`button`,onClick:p,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:m}),t[18]=p,t[19]=m,t[20]=h):h=t[20];let g;t[21]===n?g=t[22]:(g=n(`sessions.sidebar.bulkActions.delete`),t[21]=n,t[22]=g);let _;t[23]!==a||t[24]!==g?(_=(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:g}),t[23]=a,t[24]=g,t[25]=_):_=t[25];let v;t[26]!==_||t[27]!==h?(v=(0,$.jsxs)(Wr,{children:[h,_]}),t[26]=_,t[27]=h,t[28]=v):v=t[28];let y;t[29]!==v||t[30]!==f?(y=(0,$.jsxs)(Gr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[f,v]}),t[29]=v,t[30]=f,t[31]=y):y=t[31];let b;return t[32]!==o||t[33]!==s||t[34]!==y?(b=(0,$.jsx)(Jr,{open:o,onOpenChange:s,children:y}),t[32]=o,t[33]=s,t[34]=y,t[35]=b):b=t[35],b}var Sx=e=>{let t=(0,du.c)(46),{selectedCount:n,scopeKey:r,scopeFolders:i,archivedBucket:a,onMoveToFolder:o,onCreateFolderAndMove:s,onRemoveFromFolder:c,canRemoveFromFolder:l,onDelete:u,onDone:d}=e,{t:f}=Zt(),p=!!r&&!a,m;t[0]!==a||t[1]!==f?(m=f(a?`sessions.sidebar.bulkActions.delete`:`sessions.sidebar.bulkActions.archive`),t[0]=a,t[1]=f,t[2]=m):m=t[2];let h=m,g;t[3]!==n||t[4]!==f?(g=f(`sessions.sidebar.bulkActions.selectedCount`,{count:n}),t[3]=n,t[4]=f,t[5]=g):g=t[5];let _;t[6]===g?_=t[7]:(_=(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground whitespace-nowrap`,children:g}),t[6]=g,t[7]=_);let v;t[8]!==p||t[9]!==l||t[10]!==s||t[11]!==o||t[12]!==c||t[13]!==i||t[14]!==f?(v=p?(0,$.jsxs)(Na,{children:[(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(Ra,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":f(`sessions.sidebar.bulkActions.moveToFolder`),children:(0,$.jsx)(Z,{name:`folder`,className:`h-4 w-4`})})})}),(0,$.jsx)(Ea,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:f(`sessions.sidebar.bulkActions.moveToFolder`)})})]}),(0,$.jsxs)(Ia,{align:`end`,className:`min-w-[180px]`,children:[i.length===0?(0,$.jsx)(ao,{disabled:!0,className:`text-muted-foreground`,children:f(`sessions.sidebar.folders.none`)}):i.map(e=>(0,$.jsx)(ao,{onClick:()=>o(e.id),children:(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e.name})},e.id)),(0,$.jsx)(Wa,{}),(0,$.jsxs)(ao,{onClick:s,children:[(0,$.jsx)(Z,{name:`add`,className:`mr-1 h-4 w-4`}),f(`sessions.sidebar.folders.newFolderEllipsis`)]}),l?(0,$.jsxs)(ao,{onClick:c,className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(Z,{name:`close`,className:`mr-1 h-4 w-4 text-inherit`}),f(`sessions.sidebar.folders.removeFromFolder`)]}):null]})]}):null,t[8]=p,t[9]=l,t[10]=s,t[11]=o,t[12]=c,t[13]=i,t[14]=f,t[15]=v):v=t[15];let y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=X(`inline-flex h-7 w-7 items-center justify-center rounded-md text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`),t[16]=y):y=t[16];let b;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(Z,{name:`delete-bin`,className:`h-4 w-4`}),t[17]=b):b=t[17];let x;t[18]!==h||t[19]!==u?(x=(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:u,className:y,"aria-label":h,children:b})}),t[18]=h,t[19]=u,t[20]=x):x=t[20];let S;t[21]===h?S=t[22]:(S=(0,$.jsx)(Ea,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:h})}),t[21]=h,t[22]=S);let C;t[23]!==x||t[24]!==S?(C=(0,$.jsxs)(Oa,{children:[x,S]}),t[23]=x,t[24]=S,t[25]=C):C=t[25];let w;t[26]===f?w=t[27]:(w=f(`sessions.sidebar.header.actions.exitSelection`),t[26]=f,t[27]=w);let T;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Z,{name:`close`,className:`h-4 w-4`}),t[28]=T):T=t[28];let E;t[29]!==d||t[30]!==w?(E=(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:d,className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":w,children:T})}),t[29]=d,t[30]=w,t[31]=E):E=t[31];let D;t[32]===f?D=t[33]:(D=f(`sessions.sidebar.header.actions.exitSelection`),t[32]=f,t[33]=D);let O;t[34]===D?O=t[35]:(O=(0,$.jsx)(Ea,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:D})}),t[34]=D,t[35]=O);let k;t[36]!==E||t[37]!==O?(k=(0,$.jsxs)(Oa,{children:[E,O]}),t[36]=E,t[37]=O,t[38]=k):k=t[38];let A;t[39]!==k||t[40]!==v||t[41]!==C?(A=(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5`,children:[v,C,k]}),t[39]=k,t[40]=v,t[41]=C,t[42]=A):A=t[42];let j;return t[43]!==A||t[44]!==_?(j=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-t border-border px-2.5 py-1.5`,children:[_,A]}),t[43]=A,t[44]=_,t[45]=j):j=t[45],j},Cx=e=>{let{t}=Zt(),{isInlineEditing:n,showDeletionDialog:r,foldersMap:i,addSessionsToFolder:a,removeSessionsFromFolders:o,createFolderAndStartRename:s,archiveSessions:c,setBulkDeleteConfirm:l}=e,u=fb(e=>e.enabled),d=fb(e=>e.selectedIds.size),f=d>0,p=fb(e=>e.selectedIds),m=fb(e=>e.scopeKey),h=Q.useCallback(()=>{fb.getState().toggleMode()},[]),g=Q.useCallback(()=>{fb.getState().disable()},[]),_=Q.useMemo(()=>{if(!f||typeof document>`u`)return!1;let e=!1,t=!1;for(let n of p){let r=document.querySelectorAll(`[data-session-row="${CSS.escape(n)}"]`);for(let n of r)n.getAttribute(`data-session-archived`)===`1`?t=!0:e=!0}return t&&!e},[f,p]),v=Q.useMemo(()=>{if(m)return m;if(!f||typeof document>`u`)return null;for(let e of p){let t=document.querySelector(`[data-session-row="${CSS.escape(e)}"]`)?.getAttribute(`data-session-scope`);if(t&&t.length>0)return t}return null},[f,p,m]),y=Q.useMemo(()=>v?i[v]??[]:[],[i,v]),b=Q.useMemo(()=>{if(!v||!f)return!1;let e=i[v]??[];for(let t of e)for(let e of t.sessionIds)if(p.has(e))return!0;return!1},[i,v,f,p]),x=Q.useCallback(e=>{!v||!f||a(v,e,Array.from(p))},[a,p,v,f]),S=Q.useCallback(()=>{if(!v||!f)return;let e=s(v);e&&a(v,e.id,Array.from(p))},[a,s,p,v,f]),C=Q.useCallback(()=>{!v||!f||o(v,Array.from(p))},[o,p,v,f]),w=Q.useCallback(async()=>{let e=Array.from(p);if(e.length!==0){if(_)il({sessionIds:e,message:e.length===1?t(`sessions.sidebar.bulkActions.deletedSingle`,{count:e.length}):t(`sessions.sidebar.bulkActions.deletedPlural`,{count:e.length}),undoLabel:t(`sessions.sidebar.undo`),commitFailedMessage:e.length===1?t(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:e.length}):t(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:e.length})});else{let{archivedIds:n,failedIds:r}=await c(e);n.length>0&&nl({sessionIds:n,message:n.length===1?t(`sessions.sidebar.bulkActions.archivedSingle`,{count:n.length}):t(`sessions.sidebar.bulkActions.archivedPlural`,{count:n.length}),undoLabel:t(`sessions.sidebar.undo`),settingsLabel:t(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:n.length===1?t(`sessions.sidebar.session.archive.undoFailed`):t(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:n.length})}),r.length>0&&J.error(r.length===1?t(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):t(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}fb.getState().clear()}},[c,_,p,t]),T=Q.useCallback(()=>{if(!f)return;let e=p.size;if(!_||!r){w();return}l({sessionCount:e,archivedBucket:_})},[_,w,p,r,l,f]),E=Q.useCallback(async()=>{l(null),await w()},[w]);return Q.useEffect(()=>{if(!u)return;let e=typeof navigator<`u`&&/Macintosh|Mac OS X/.test(navigator.userAgent||``),t=t=>{if(n)return;let r=t.target;if(r&&(r.tagName===`INPUT`||r.tagName===`TEXTAREA`||r.isContentEditable))return;let i=e?t.metaKey:t.ctrlKey;if(t.key===`Escape`){t.preventDefault(),fb.getState().disable();return}if(i&&t.key===`Backspace`){t.preventDefault(),T();return}if(i&&(t.key===`a`||t.key===`A`)){let e=typeof document<`u`?Array.from(document.querySelectorAll(`[data-session-row]`)):[];if(e.length===0)return;t.preventDefault();let n=fb.getState().scopeKey??e[0]?.getAttribute(`data-session-scope`)??null,r=e.filter(e=>!n||e.getAttribute(`data-session-scope`)===n).map(e=>e.getAttribute(`data-session-row`)).filter(e=>typeof e==`string`&&e.length>0);if(r.length===0)return;fb.getState().replaceAll(r,n||null)}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[T,n,u]),{selectionModeEnabled:u,hasSelection:f,selectedIdsSize:d,bulkScopeIsArchived:_,derivedSelectionScope:v,bulkScopeFolders:y,bulkCanRemoveFromFolder:b,handleToggleSelectionMode:h,handleExitSelectionMode:g,handleBulkMoveToFolder:x,handleBulkCreateFolderAndMove:S,handleBulkRemoveFromFolder:C,handleBulkDelete:T,confirmBulkDelete:E}},wx=(e,t,n)=>{let r=[],i=new Set,a=e=>{let t=M(e??null);!t||i.has(t)||(i.add(t),r.push(t))};if(a(e),a(n?.workspaceRoot),a(n?.currentDirectory),n?.includeWorktrees!==!1)for(let e of t)a(e.path);return r},Tx=(e,t,n,r)=>{let i=e.filter(e=>e.sessionId===t);if(i.length===0)return null;if(n){let e=i.find(e=>e.projectId===n);if(e)return e}if(r){let e=i.find(e=>e.projectId===r);if(e)return e}return i[0]??null},Ex=({currentSessionId:e,focus:t,pinnedFocuses:n,projectFocuses:r,fallbackProjectId:i})=>{if(!e)return null;let a=t?.sessionId===e,o=a?t.projectId:null,s=Tx(r,e,o,i)??{scope:`project`,sessionId:e,projectId:i};return!a||t.scope===`project`?s:Tx(n,e,o,i)??s};function Dx(e,t,n=null){if(!e||e.scope!==`project`||!e.sessionId)return null;if(e.projectId){let n=t.find(t=>t.sessionId===e.sessionId&&t.projectId===e.projectId);if(n)return n}if(n){let r=t.find(t=>t.sessionId===e.sessionId&&t.projectId===n);if(r)return r}return t.find(t=>t.sessionId===e.sessionId)??null}var Ox=`yuri.sessions.projectCollapse`,kx=`yuri.sessions.groupOrder`,Ax=`yuri.sessions.groupCollapse`,jx=`yuri.sessions.activeSessionByProject`,Mx=`yuri.sessions.expandedParents.v2`,Nx=`yuri.sessions.expandedParents`,Px=at(Be()),Fx=e=>{try{let t=Px.getItem(e);if(!t)return new Set;let n=JSON.parse(t);return new Set(Array.isArray(n)?n.filter(e=>typeof e==`string`):[])}catch{return new Set}},Ix=e=>{try{let t=Px.getItem(e);if(!t)return new Map;let n=JSON.parse(t),r=new Map;return!n||typeof n!=`object`||Array.isArray(n)||Object.entries(n).forEach(([e,t])=>{typeof t==`string`&&t.length>0&&r.set(e,t)}),r}catch{return new Map}},Lx=e=>{try{let t=Px.getItem(e);if(!t)return new Map;let n=JSON.parse(t),r=new Map;return!n||typeof n!=`object`||Array.isArray(n)||Object.entries(n).forEach(([e,t])=>{Array.isArray(t)&&r.set(e,t.filter(e=>typeof e==`string`))}),r}catch{return new Map}},Rx=(e,t,n)=>{let r=new Set;for(let t of e){let e=M(t.path)?.toLowerCase();e&&r.add(e)}if(n?.includeWorktrees===!1)return r;for(let e of t.values())for(let t of e){let e=M(t.path)?.toLowerCase();e&&r.add(e)}return r},zx=(e,t,n)=>{if(e.time?.archived)return!0;let r=M(Xn(e))?.toLowerCase();return r?t.size===0?n?.allowEmptyDirectorySet??!0:t.has(r):n?.allowUnknownDirectory??!0},Bx=new Set,Vx=[],Hx={},Ux=(e,t)=>{let n=Q.useRef(e);return n.current=e,Q.useMemo(()=>(...e)=>n.current(...e),[t])},Wx=Q.memo(function(e){let t=(0,du.c)(3),{onOpenChange:n}=e,r=As(ue(Kx)),i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(bs,{open:!0,onOpenChange:n,...r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}),Gx=Q.memo(function({mobileVariant:e=!1,onSessionSelected:t,allowReselect:n=!1,hideDirectoryControls:r=!1,showOnlyMainWorkspace:i=!1,isVisible:a=!0}){let{t:o}=Zt(),[c,l]=Q.useState(!1),[u,d]=Q.useState(!1),[f,m]=Q.useState(``),h=Q.useRef(null),g=Q.useRef(null),[_,y]=Q.useState(null),[b,x]=Q.useState(``),[S,C]=Q.useState(null),[T,E]=Q.useState(new Set),D=Q.useMemo(()=>Px,[]),[O,k]=Q.useState(new Set),[A,j]=Q.useState(new Map),[N,P]=Q.useState(new Map),F=q(e=>e.isNewWorktreeDialogOpen),I=q(e=>e.setNewWorktreeDialogOpen),[L,R]=Q.useState(null),[z,ee]=Q.useState(null),[B,V]=Q.useState(``),[te,ne]=Q.useState(null),[re,ie]=Q.useState(null),[ae,oe]=Q.useState(null),H=Sr(),se=En(),[U,ce]=Q.useState(()=>Fx(Ax)),[W,le]=Q.useState(()=>Lx(kx)),[ue,de]=Q.useState(()=>Ix(jx)),fe=Q.useRef(null);Q.useEffect(()=>s(e=>{p(e)&&(fe.current=null,ce(Fx(Ax)),le(Lx(kx)),de(Ix(jx)),k(Fx(Ox)),E(Fx(Mx)))}),[]);let[pe,me]=Q.useState(new Map),he=Q.useRef(0),ge=Pe(e=>e.homeDirectory),_e=Pe(e=>e.currentDirectory),ve=Pe(e=>e.setDirectory),ye=mn(e=>e.projects),be=Q.useMemo(()=>ye.filter(e=>!e.hostId),[ye]),xe=Q.useMemo(()=>ye.filter(e=>e.hostId).map(Ar),[ye]),[Se,Ce]=Q.useState(()=>new Map),we=K((e,t)=>{Ce(n=>{if(!t.length&&!n.has(e))return n;let r=new Map(n);return t.length?r.set(e,t):r.delete(e),r})}),Te=kc(a),[Ee,De]=Q.useState(new Map),Oe=K((e,t)=>{De(n=>JSON.stringify(n.get(e))===JSON.stringify(t)?n:new Map(n).set(e,t))}),ke=mn(e=>e.activeProjectId),Ae=mn(e=>e.removeProject),je=mn(e=>e.setActiveProjectIdOnly),Me=mn(e=>e.updateProjectMeta),Ne=mn(e=>e.reorderProjectsById),Fe=q(e=>e.setActiveMainTab),Ie=q(e=>e.activeMainTab),Le=tn(),Re=q(e=>e.setSettingsDialogOpen),G=q(e=>e.toggleHelpDialog),ze=q(e=>e.setSessionSwitcherOpen),Be=q(e=>e.setScheduledTasksDialogOpen),Ve=q(e=>e.notifyOnSubtasks),He=q(e=>e.showDeletionDialog),Ue=q(e=>e.setShowDeletionDialog),We=ko(f,120),Ge=Q.useMemo(()=>We.trim().toLowerCase(),[We]),Ke=Ge.length>0,qe=As(e=>e.available&&(e.runtimeType===`desktop`||e.runtimeType===`web`)),Je=or(e=>e.collapsedFolderIds),Ye=or(e=>e.foldersMap),Xe=or(e=>e.sessionOrderByScope),Ze=or(e=>e.sessionOrderActivityByScope),Qe=or(e=>e.getFoldersForScope),$e=or(e=>e.createFolder),et=or(e=>e.renameFolder),tt=or(e=>e.deleteFolder),nt=or(e=>e.addSessionToFolder),rt=or(e=>e.addSessionsToFolder),it=or(e=>e.removeSessionFromFolder),at=or(e=>e.removeSessionsFromFolders),ot=or(e=>e.toggleFolderCollapse),st=or(e=>e.getSessionFolderId),ct=or(e=>e.reorderSessions);Pv({isSessionSearchOpen:a&&u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchContainerRef:h});let lt=Q.useMemo(()=>new Map,[]),ut=wn({enabled:a,includeChildren:!0}),dt=xl({enabled:a}),ft=Fc({enabled:a}),pt=Sn(e=>a?e.index.session.unseenCount:Hx),mt=Q.useMemo(()=>w(),[]),ht=wr(e=>e.status),gt=wr(e=>e.activeSessions),_t=wr(e=>e.archivedSessions),vt=wr(e=>e.loadingDirectories.size>0||e.refreshingDirectories.size>0),bt=wr(e=>e.archivedLoadingDirectories),xt=Q.useDeferredValue(gt),St=Q.useDeferredValue(_t),Ct=cr(e=>e.currentSessionId),wt=dn(e=>e.remoteSession!==null)?null:Ct,Tt=ga(e=>e.focus),Et=Q.useSyncExternalStore(Lt,Ft,Ft),Dt=cr(e=>!!e.newSessionDraft?.open),Ot=cr(e=>e.newSessionDraft?.open&&!e.currentSessionId?e.newSessionDraft.selectedProjectId??null:null),kt=Q.useMemo(()=>!e&&Ie===`chat`&&Ot&&Et.sessionId===null?{projectId:Ot,revision:Et.revision}:null,[e,Ie,Ot,Et]),At=cr(e=>e.setCurrentSession),jt=cr(e=>e.updateSessionTitle),Mt=cr(e=>e.shareSession),Nt=cr(e=>e.unshareSession),Pt=cr(e=>e.worktreeMetadata),Rt=cr(e=>e.availableWorktreesByProject),zt=cr(e=>e.openNewSessionDraft),Bt=K(t=>{let n=xe.find(e=>e.id===(t?.selectedProjectId??mn.getState().activeProjectId));if(n){tc(n,e).catch(e=>J.error(e instanceof Error?e.message:String(e)));return}dn.getState().clearRemoteSession(),zt(t),mt&&window.dispatchEvent(new CustomEvent(`yuri:navigate`,{detail:{view:`chat`}}))}),Vt=Q.useMemo(()=>Rx(be,Rt,{includeWorktrees:!mt}),[Rt,mt,be]),Ht=Q.useMemo(()=>{let e=new Map(ut.map(e=>[e.id,e])),t=xt.map(t=>{let n=e.get(t.id);return n?lr(n,t):t}),n=new Set(t.map(e=>e.id));return ut.forEach(e=>{n.has(e.id)||t.push(e)}),t.filter(e=>zx(e,Vt,{allowUnknownDirectory:!mt,allowEmptyDirectorySet:!mt}))},[xt,mt,Vt,ut]),Ut=Q.useMemo(()=>ut.map(e=>{let t=M(e.directory??null)??``;return`${e.id}:${e.title??``}:${+!!e.time?.archived}:${t}`}).join(`|`),[ut]),Wt=Q.useRef(ut);Q.useEffect(()=>{Wt.current=ut},[Ut,ut]);let Gt=Q.useMemo(()=>new Map(ut.map(e=>[e.id,e])),[ut]);Q.useEffect(()=>{let e=null,t=yt(t=>{t.type===`scheduled-task-ran`&&(e&&clearTimeout(e),e=setTimeout(()=>{let e=mn.getState().projects.find(e=>e.id===t.projectId),n=M(e?.path??null);if(!n)return;let r=[n];(cr.getState().availableWorktreesByProject.get(n)??[]).forEach(e=>{let t=M(e.path);t&&r.push(t)}),Zn(r,Wt.current)},500))});return()=>{e&&clearTimeout(e),t()}},[]);let Kt=Q.useMemo(()=>v(),[]),qt=Bs(e=>e.sidebarBrandName.trim().length>0),{isTablet:Jt,isDesktop:Yt}=go(),Xt=e||Jt,{buildGroupSearchText:Qt,filterSessionNodesForSearch:$t,buildGroupedSessions:en}=Tc({homeDirectory:ge,worktreeMetadata:Pt,pinnedSessionIds:H,gitBranches:lt,isVSCode:mt}),{scheduleCollapsedProjectsPersist:nn,hasRestoredProjectCollapse:rn}=Vv({isVSCode:mt,safeStorage:D,keys:{sessionExpanded:Mx,sessionExpandedLegacy:Nx,projectCollapse:Ox,groupOrder:kx,projectActiveSession:jx,groupCollapse:Ax},groupOrderByProject:W,activeSessionByProject:ue,collapsedGroups:U,setExpandedParents:E,setCollapsedProjects:k}),an=Q.useMemo(()=>[...Ht].sort((e,t)=>io(e,t,H)),[Ht,H]),on=Q.useMemo(()=>{let e=new Map;return an.forEach(t=>{let n=t.parentID;if(!n)return;let r=e.get(n)??[];r.push(t),e.set(n,r)}),e.forEach(e=>e.sort((e,t)=>io(e,t,H))),e},[an,H]),sn=(0,$.jsxs)(`div`,{className:`py-6 text-center text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold`,children:o(`sessions.sidebar.empty.noSessions.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1`,children:o(`sessions.sidebar.empty.noSessions.description`)})]}),cn=Q.useMemo(()=>be.find(e=>e.id===S)??null,[be,S]),ln=Q.useCallback(e=>{S&&Me(S,{label:e.label,icon:e.icon,color:e.color,iconBackground:e.iconBackground,defaultModel:e.defaultModel??null})},[S,Me]),un=Q.useCallback(()=>{I(!0)},[I]),fn=Q.useCallback((t,n)=>{if(Fe(`chat`),e&&ze(!1),!n?.remote){if(n?.sessionId){At(n.sessionId,t);return}zt({directoryOverride:t,preserveDirectoryOverride:!0})}},[e,zt,Fe,At,ze]),pn=K(()=>{let e=As.getState();if(e.available&&e.info){l(!0);return}e.checkForUpdates().then(()=>{let{available:e,error:t}=As.getState();if(t){J.error(o(`sessions.sidebar.updateCheck.errorTitle`),{description:t});return}if(!e){J.success(o(`sessions.sidebar.updateCheck.latestVersion`));return}l(!0)})}),hn=Q.useCallback(()=>{e&&ze(!1),Re(!0)},[e,ze,Re]),gn=K(()=>{let t=xe.find(e=>e.id===mn.getState().activeProjectId);if(t){tc(t,e).catch(e=>J.error(e instanceof Error?e.message:String(e)));return}dn.getState().clearRemoteSession(),Fe(`chat`),zt(),e&&ze(!1)}),_n=Q.useCallback(()=>{if(!e){Fe(`schedule`);return}Be(!0),ze(!1)},[e,Fe,Be,ze]),vn=Q.useCallback(()=>{Dr(),e&&ze(!1)},[e,ze]),yn=cr(e=>e.archiveSession),bn=cr(e=>e.archiveSessions),{copiedSessionId:xn,handleSessionSelect:Cn,handleSessionDoubleClick:Tn,handleSaveEdit:Dn,handleCancelEdit:On,handleShareSession:kn,handleCopyShareUrl:An,handleUnshareSession:jn,handleDeleteSession:Mn,confirmDeleteSession:Nn}=Fv({activeProjectId:ke,currentDirectory:_e,currentSessionId:wt,mobileVariant:e,allowReselect:n,onSessionSelected:t,isSessionSearchOpen:u,sessionSearchQuery:f,setSessionSearchQuery:m,setIsSessionSearchOpen:d,setActiveProjectIdOnly:je,setDirectory:ve,setActiveMainTab:Fe,setSessionSwitcherOpen:ze,setCurrentSession:At,updateSessionTitle:jt,shareSession:Mt,unshareSession:Nt,archiveSession:yn,archiveSessions:bn,childrenMap:on,showDeletionDialog:He,setDeleteSessionConfirm:ne,deleteSessionConfirm:te,setEditingId:y,setEditTitle:x,editingId:_,editTitle:b}),Pn=Q.useCallback((e,t,n,r=`project`)=>{dn.getState().clearRemoteSession();let i={sessionId:e,scope:r,projectId:n??null};if(e===wt){It(e),nx(i),Cn(e,t,n);return}ex(i,()=>Cn(e,t,n))},[Cn,wt]);Q.useEffect(()=>()=>{$b()},[]);let Fn=Q.useCallback(()=>{if(!re)return;let{scopeKey:e,folderId:t}=re;ie(null),tt(e,t)},[re,tt]);Q.useEffect(()=>{if(!wt)return;let e=Ht.find(e=>e.id===wt)?.parentID;if(!e)return;let t=[`project:active:${e}`,`project:archived:${e}`,`recent:active:${e}`,`recent:archived:${e}`];E(e=>{if(t.every(t=>e.has(t)))return e;let n=new Set(e);t.forEach(e=>n.add(e));try{D.setItem(Mx,JSON.stringify(Array.from(n)))}catch{}return n})},[wt,Ht,D]);let Ln=Q.useCallback(e=>{E(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{D.setItem(Mx,JSON.stringify(Array.from(n)))}catch{}return n})},[D]),Rn=Q.useCallback((e,t)=>{if(!e)return null;t&&Je.has(t)&&ot(t);let n=$e(e,o(`sessions.sidebar.folder.newFolderName`),t);return ee(n.id),V(n.name),n},[Je,ot,$e,o]),zn=K(Pn),Bn=K(Tn),Vn=K(Dn),Hn=K(On),Un=K(kn),Gn=K(An),qn=K(jn),Jn=K(Mn),Yn=K(Rn),Qn=K((e,t,n,r)=>{let i=Qc(),a=Math.max(i,n)+7;if(P(e=>{let r=Math.max(i,e.get(t)??i,n),a=new Map(e);return a.set(t,r+7),a}),e.isArchivedBucket||a<r)return;let o=M(e.directory??null);if(!o)return;let s=wr.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&Wn(o)}),$n=K(e=>{P(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})}),er=K(e=>{P(t=>{let n=!1,r=new Map(t),i=`${e}:`;for(let e of r.keys())e.startsWith(i)&&(r.delete(e),n=!0);return n?r:t})}),tr=Q.useMemo(()=>e=>{let t=be.find(t=>t.id===e),n=M(t?.path??null);if(!n)return[];let r=[n];return mt||(Rt.get(n)??[]).forEach(e=>{let t=M(e.path);t&&r.push(t)}),r},[Rt,mt,be]),nr=K(e=>{let t=tr(e);if(t.length===0)return;let n=wr.getState().loadedDirectories,r=t.filter(e=>!n.has(e));r.length!==0&&Zn(r,Wt.current)}),ir=K(e=>{let t=be.find(t=>t.id===e);t&&(async()=>{let e=[];if(!mt)try{e=(await ls({id:t.id,path:t.path})).worktrees}catch(n){console.warn(`[SessionSidebar] Worktree refresh before session sync failed:`,n);let r=M(t.path);e=r?cr.getState().availableWorktreesByProject.get(r)??[]:[]}let n=wx(t.path,e,{currentDirectory:_e,workspaceRoot:t.path,includeWorktrees:!mt});n.length!==0&&await vr(n,Wt.current)})()});Q.useEffect(()=>{if(!rn)return;let e=wr.getState(),t=be.flatMap(t=>O.has(t.id)?[]:tr(t.id).filter(t=>!e.loadedDirectories.has(t)&&!e.loadingDirectories.has(t)&&!e.refreshingDirectories.has(t)));t.length>0&&Zn(t,Wt.current)},[O,tr,rn,be]);let ar=K(()=>{he.current=Date.now()+150,P(new Map),k(()=>{let e=new Set(be.map(e=>e.id));try{D.setItem(Ox,JSON.stringify(Array.from(e)))}catch{}return mt||nn(e),e})}),sr=K(()=>{he.current=Date.now()+150,P(new Map),k(()=>{let e=new Set;try{D.setItem(Ox,JSON.stringify([]))}catch{}return mt||nn(e),e});let e=wr.getState().loadedDirectories,t=be.flatMap(t=>tr(t.id).filter(t=>!e.has(t)));t.length>0&&Zn(t,Wt.current)}),ur=K(e=>{he.current=Date.now()+150,er(e),k(t=>{let n=new Set(t);n.has(e)?(n.delete(e),queueMicrotask(()=>nr(e))):n.add(e);try{D.setItem(Ox,JSON.stringify(Array.from(n)))}catch{}return mt||nn(n),n})}),dr=K(e=>{he.current=Date.now()+150,nr(e),k(t=>{if(!t.has(e))return t;let n=new Set(t);n.delete(e);try{D.setItem(Ox,JSON.stringify(Array.from(n)))}catch{}return mt||nn(n),n})}),fr=Q.useMemo(()=>be.map(e=>({...e,normalizedPath:M(e.path)})).filter(e=>!!e.normalizedPath),[be]),pr=Q.useMemo(()=>new Map(fr.map(e=>[e.id,Er(e.normalizedPath)||e.normalizedPath])),[fr]),mr=Q.useMemo(()=>fr.map(e=>e.normalizedPath),[fr]),hr=Q.useMemo(()=>{let e=new Set(fr.map(e=>e.normalizedPath));if(!mt)for(let t of Rt.values())for(let n of t){let t=M(n.path);t&&e.add(t)}return[...e].sort()},[Rt,mt,fr]),gr=Q.useRef(null);Q.useEffect(()=>{let e=new Set(hr),t=gr.current;if(gr.current=e,!t)return;let n=hr.filter(e=>!t.has(e));if(n.length===0)return;let r=wr.getState().loadedDirectories,i=M(_e),a=fr.find(e=>e.id===ke)??fr.find(e=>e.normalizedPath===i)??null,o=new Set;i&&o.add(i),a?.normalizedPath&&(o.add(a.normalizedPath),mt||(Rt.get(a.normalizedPath)??[]).forEach(e=>{let t=M(e.path);t&&o.add(t)}));let s=n.filter(e=>o.has(e)&&!r.has(e));s.length!==0&&Zn(s,Wt.current)},[ke,Rt,_e,mt,fr,hr]);let _r=Oo(a?mr:Vx);Uv({normalizedProjects:fr,activeProjectId:ke,gitRepoStatus:_r,setProjectRepoStatus:j,setProjectRootBranches:me,enabled:a});let yr=Q.useMemo(()=>Ns(Ht,fr,Rt,mt,St),[St,Rt,mt,fr,Ht]),{getSessionsForProject:xr,getArchivedSessionsForProject:Cr}=Wv({ownership:yr}),Tr=vt||ht===`idle`||ht===`loading`,Or=Q.useRef(!1);ke&&A.has(ke)&&(Or.current=!!A.get(ke));let kr=br(e=>e.projectSortOrder),jr=Q.useMemo(()=>$c(fr,kr),[fr,kr]),{projectSections:Mr,groupSearchDataByGroup:Nr,sectionsForRender:Pr,searchMatchCount:Fr}=jv({normalizedProjects:jr,getSessionsForProject:xr,getArchivedSessionsForProject:Cr,availableWorktreesByProject:Rt,projectRepoStatus:A,projectRootBranches:pe,lastRepoStatus:Or.current,buildGroupedSessions:en,hasSessionSearchQuery:Ke,normalizedSessionSearchQuery:Ge,filterSessionNodesForSearch:$t,buildGroupSearchText:Qt,foldersMap:Ye}),Ir=(0,$.jsxs)(`div`,{className:`py-6 text-center text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold`,children:o(`sessions.sidebar.empty.noMatches.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1`,children:o(`sessions.sidebar.empty.noMatches.description`)})]});Mv({projectSections:Mr,activeProjectId:ke,activeSessionByProject:ue,setActiveSessionByProject:de,currentSessionId:wt,handleSessionSelect:Cn,newSessionDraftOpen:Dt,mobileVariant:e,openNewSessionDraft:zt,setActiveMainTab:Fe,setSessionSwitcherOpen:ze});let{getOrderedGroups:Lr}=Nv(W),Rr=Q.useRef(!1);Q.useEffect(()=>{if(Rr.current||Mr.length===0)return;let e=Mr.flatMap(e=>e.groups.filter(e=>e.isArchivedBucket).map(t=>`${e.project.id}:${t.id}`));e.length>0&&ce(t=>new Set([...t,...e])),Rr.current=!0},[Mr]);let zr=Q.useMemo(()=>{let e=new Map,t=new Map;return Mr.forEach(n=>{let r=Er(n.project.normalizedPath)||n.project.normalizedPath;n.groups.forEach(i=>{let a=i.branch&&i.branch!==`HEAD`&&i.branch!==r?i.branch:null,o={projectLabel:r,branchLabel:a},s=r=>{r.forEach(r=>{let a=n.project.normalizedPath.length;a<(t.get(r.session.id)??-1)||(e.set(r.session.id,{node:r,projectId:n.project.id,groupDirectory:i.directory,secondaryMeta:o}),t.set(r.session.id,a),r.children.length>0&&s(r.children))})};s(i.sessions)})}),e},[Mr]);Q.useLayoutEffect(()=>{if(!wt){nx(null);return}let e=ga.getState().focus;if(e?.sessionId===wt){e.scope===`project`&&!e.projectId&&nx({...e,projectId:zr.get(wt)?.projectId??null});return}nx({scope:`project`,sessionId:wt,projectId:zr.get(wt)?.projectId??null})},[wt,zr]);let Br=Q.useMemo(()=>mt?[]:Sl(Ht,H,Xe[Zc]),[mt,H,Ht,Xe]),Vr=K((e,t)=>{_||ct(Zc,Br.map(e=>e.id),e,t,{}).catch(()=>J.error(o(`sessions.order.saveFailed`)))}),Hr=Q.useMemo(()=>Ke?[]:Pc(Ht,H,ft,pt),[Ke,H,ft,Ht,pt]),{pinnedItems:Ur,inProgressItems:Wr}=Q.useMemo(()=>{let e=e=>{let t=zr.get(e.id),n=M(e.directory??null),r={session:e,children:[],worktree:Pt.get(e.id)??null};if(Ke&&$t([r],Ge).length===0)return null;let i=yr.bySessionId.get(e.id),a=i?jr.find(e=>e.id===i.projectId):void 0,o=a?Er(a.normalizedPath)||a.normalizedPath:t?.secondaryMeta?.projectLabel??null,s=cc({projectLabel:o,owner:i,sessionWorktree:Pt.get(e.id)??null,worktrees:a?Rt.get(a.normalizedPath)??[]:[],projectRootBranch:i?pe.get(i.projectId)??(a?_r.get(a.normalizedPath)?.branch:null)??null:null,isVSCode:mt})??t?.secondaryMeta??null;return{node:r,projectId:i?.projectId??t?.projectId??null,groupDirectory:i?.scopeDirectory??t?.groupDirectory??n,secondaryMeta:s}},t=t=>t.map(e).filter(e=>e!==null);return{pinnedItems:mt?[]:t(Br),inProgressItems:t(Hr)}},[Rt,$t,_r,Ke,Hr,mt,Ge,Br,pe,yr,zr,jr,Pt]),Gr=Q.useMemo(()=>[...Wr,...xe.flatMap(e=>Se.get(e.id)??[])].sort((e,t)=>In(t.node.session)-In(e.node.session)),[Wr,xe,Se]),Kr=Q.useMemo(()=>Pr.map(e=>({...e,groups:e.groups.filter(e=>!e.isArchivedBucket)})),[Pr]),qr=Q.useMemo(()=>{let e=Ke?Kr.map(e=>({...e,groups:e.groups.map(e=>({...e,sessions:Nr.get(e)?.filteredNodes??[]}))})):Kr;if(!i)return e;let t=e.find(e=>e.project.id===ke)??e[0];if(!t)return[];let n=t.groups.find(e=>e.isMain&&e.sessions.length>0)??t.groups.find(e=>e.sessions.length>0)??t.groups.find(e=>e.isMain)??t.groups[0];return n?[{...t,groups:[n]}]:[]},[ke,Nr,Ke,Kr,i]),Jr=Q.useMemo(()=>bl({sections:qr,foldersMap:Ye,getOrderedGroups:Lr,pinnedSessionIds:H,sessionOrderByScope:Xe,sessionOrderActivityByScope:Ze}),[Ye,Lr,qr,H,Ze,Xe]),Yr=Q.useMemo(()=>wl({targets:Jr,collapsedProjectIds:O,collapsedGroupKeys:U,collapsedFolderIds:Je,visibleSessionCountByGroup:N,defaultVisibleSessionCount:Qc(),hasSessionSearchQuery:Ke,alwaysVisibleSessionIds:dt}),[dt,Je,U,O,Ke,Jr,N]),Xr=Q.useMemo(()=>Ke?[]:[...Ur,...Gr].map((e,t)=>{let n=e.node.session;return{scope:`pinned`,sessionId:n.id,projectId:e.projectId,directory:M(Xn(n))??e.groupDirectory??null,visibleIndex:t}}),[Ke,Gr,Ur]),[Zr,Qr]=Q.useState(null),$r=Q.useCallback(e=>{Qr(t=>t&&t.length===e.length&&t.every((t,n)=>t===e[n])?t:[...e])},[]),ei=Q.useMemo(()=>{if(!Zr)return Xr;let e=new Set(Zr);return Xr.filter(t=>e.has(t.sessionId))},[Xr,Zr]),ti=Q.useMemo(()=>!a&&fe.current?fe.current:{pinned:ei,project:Yr},[a,ei,Yr]);Q.useLayoutEffect(()=>{a&&(fe.current=ti)},[a,ti]);let ni=Q.useMemo(()=>e?[]:ua({pinnedTargets:ti.pinned,projectTargets:ye.flatMap(e=>e.hostId?Ee.get(e.id)??[]:ti.project.filter(t=>t.projectId===e.id))}),[e,ti,ye,Ee]),ri=Q.useCallback(t=>{let n=xe.find(e=>e.id===t.projectId);if(n&&Te.registry){let r=Se.get(n.id)?.find(e=>e.identity===t.sessionId);ec(n,Te.registry,r?.remoteSessionId??t.sessionId,t.directory??n.path,e);return}Fe(`chat`),ze(!1),t.scope===`project`&&t.projectId&&je(t.projectId),Pn(t.sessionId,t.directory,t.projectId,t.scope)},[Pn,Fe,je,ze,xe,Te.registry,Se,e]);Q.useLayoutEffect(()=>ea({targets:ni,activate:ri}),[ri,ni]);let ii=Q.useMemo(()=>{let e=new Map;return ni.forEach(t=>{let n=Gi({scope:t.scope,sessionId:t.sessionId,projectId:t.projectId});n&&e.set(n,Vi(ni,t)??0)}),e},[ni]),ai=Q.useMemo(()=>{if(!wt||Ke)return[];let e=[],t=(n,r)=>{if(n.session.id===wt){e.push({scope:`pinned`,sessionId:wt,projectId:r});return}n.children.forEach(e=>t(e,r))};return Ur.forEach(e=>t(e.node,e.projectId)),Wr.forEach(e=>t(e.node,e.projectId)),e},[wt,Ke,Wr,Ur]),oi=Q.useMemo(()=>{if(!wt)return[];let e=[],t=(n,r)=>{if(n.session.id===wt){e.push({scope:`project`,sessionId:wt,projectId:r});return}n.children.forEach(e=>t(e,r))};return Mr.forEach(e=>{e.groups.forEach(n=>{n.sessions.forEach(n=>t(n,e.project.id))})}),e},[wt,Mr]);Q.useLayoutEffect(()=>na({pinned:ti.pinned,project:ti.project}),[ti]),Q.useLayoutEffect(()=>{!a||Tr||nx(Ex({currentSessionId:wt,focus:Tt,pinnedFocuses:ai,projectFocuses:oi,fallbackProjectId:wt?zr.get(wt)?.projectId??null:null}))},[wt,a,Tr,oi,ai,Tt,zr]);let si=Q.useMemo(()=>{let e=Tt?.sessionId?zr.get(Tt.sessionId)?.projectId??null:null;return Dx(Tt,Jr,e)},[Jr,Tt,zr]),ci=Q.useRef(null),li=Q.useRef(null);Q.useEffect(()=>{li.current&&li.current!==wt&&(li.current=null)},[wt]),Q.useLayoutEffect(()=>{if(!si?.projectId)return;let e=si.sessionId,t=Et.sessionId===e;if(!(!t&&wt!==e)){if(t){if(ci.current===Et.revision)return;ci.current=Et.revision,li.current=e}else{if(li.current===e)return;li.current=e}if(dr(si.projectId),si.groupKey&&ce(e=>{if(!e.has(si.groupKey))return e;let t=new Set(e);return t.delete(si.groupKey),t}),si.folderAncestorIds?.forEach(e=>{let t=or.getState();t.collapsedFolderIds.has(e)&&t.toggleFolderCollapse(e)}),si.groupKey&&si.visibleIndex!==void 0){let e=si.visibleIndex+1;P(t=>{if((t.get(si.groupKey)??0)>=e)return t;let n=new Map(t);return n.set(si.groupKey,e),n})}}},[wt,si,Et]);let ui=Ux((t,n=0,r,i,a=!1,o,s=`project`,c)=>(0,$.jsx)(gx,{node:t,depth:n,groupDirectory:r,projectId:i,archivedBucket:a,currentSessionId:wt,pinnedSessionIds:H,expandedParents:T,hasSessionSearchQuery:Ke,normalizedSessionSearchQuery:Ge,notifyOnSubtasks:Ve,editingId:_,setEditingId:y,editTitle:b,setEditTitle:x,handleSaveEdit:Vn,handleCancelEdit:Hn,toggleParent:Ln,handleSessionSelect:zn,handleSessionDoubleClick:Bn,togglePinnedSession:se,handleShareSession:Un,copiedSessionId:xn,handleCopyShareUrl:Gn,handleUnshareSession:qn,openSidebarMenuKey:L,setOpenSidebarMenuKey:R,renamingFolderId:z,getFoldersForScope:Qe,getSessionFolderId:st,removeSessionFromFolder:it,addSessionToFolder:nt,createFolderAndStartRename:Yn,handleDeleteSession:Jn,mobileVariant:e,alwaysShowActions:Xt,renderSessionNode:ui,secondaryMeta:o,renderContext:s,subtreeContainsActive:c?.subtreeContainsActive??Bx,subtreeContainsEditing:c?.subtreeContainsEditing??Bx,menuOpenSessionId:c?.menuOpenSessionId??null,nodeStructureKey:c?.nodeStructureKey??``,childRenderExtrasFor:c?.childRenderExtrasFor,liveSessionById:Gt,shortcutNumber:ii.get(Gi({scope:s,sessionId:t.session.id,projectId:i??null})??``)??null},`${s}:${i??``}:${t.session.id}`),JSON.stringify([...ii])),di=Q.useCallback(e=>{$n(e),ce(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[$n]),fi=Q.useCallback(e=>{let t=tr(e);if(t.length===0)return;let n=wr.getState(),r=t.filter(e=>!n.archivedLoadedDirectories.has(e));r.length>0&&rr(r)},[tr]),pi=K((e,t,n,r,i)=>{let a=e.folderScopeKey??M(e.directory??null);a&&ct(a,t,n,r,i).catch(()=>J.error(o(`sessions.order.saveFailed`)))}),mi=K((e,t,n)=>{e.isArchivedBucket&&U.has(t)&&n&&fi(n),di(t)}),hi=Q.useMemo(()=>(t,n,r,i,a,o,s)=>(0,$.jsx)(ul,{group:t,groupKey:n,isArchivedLoading:!!(t.isArchivedBucket&&r&&tr(r).some(e=>bt.has(e))),projectId:r,projectLabel:r?pr.get(r)??null:null,hideGroupLabel:i,compactBodyPadding:o,hasSessionSearchQuery:Ke,normalizedSessionSearchQuery:Ge,groupSearchDataByGroup:Nr,visibleSessionCount:N.get(n),collapsedGroups:U,collapsedFolderIds:Je,toggleFolderCollapse:ot,renameFolder:et,deleteFolder:tt,showDeletionDialog:He,setDeleteFolderConfirm:ie,renderSessionNode:ui,projectRepoStatus:A,lastRepoStatus:Or.current,showMoreGroupSessions:Qn,resetGroupSessionLimit:$n,mobileVariant:e,alwaysShowActions:Xt,activeProjectId:ke,setActiveProjectIdOnly:je,setActiveMainTab:Fe,setSessionSwitcherOpen:ze,openNewSessionDraft:Bt,addSessionToFolder:nt,createFolderAndStartRename:Yn,renamingFolderId:z,renameFolderDraft:B,setRenameFolderDraft:V,setRenamingFolderId:ee,pinnedSessionIds:H,expandedParents:T,sessionOrderByScope:Xe,sessionOrderActivityByScope:Ze,onReorderSessions:pi,currentSessionId:wt,shortcutTargetSessionId:si?.groupKey===n?si.sessionId:null,shortcutTargetVisibleIndex:si?.groupKey===n?si.visibleIndex??null:null,editingId:_,editTitle:b,openSidebarMenuKey:L,liveSessionById:Gt,alwaysVisibleSessionIds:dt,onToggleCollapsedGroup:mi,dragHandleProps:a,scrollContainerRef:s}),[Ke,Ge,Nr,pr,bt,tr,N,U,Je,ot,et,tt,He,ui,A,Qn,$n,e,Xt,ke,je,Fe,ze,Bt,nt,Yn,z,B,H,T,Xe,Ze,pi,wt,si,_,b,L,Gt,dt,mi]),gi=r?null:(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(ry,{collapseAllProjects:ar,expandAllProjects:sr}),(0,$.jsx)(Y,{variant:`ghost`,size:`xs`,className:`size-6 p-0 text-muted-foreground`,"aria-label":o(`sessions.sidebar.header.actions.addProject`),title:o(`sessions.sidebar.header.actions.addProject`),onClick:Kn.requestDirectoryDialog,children:(0,$.jsx)(Z,{name:`add`,className:`size-4`})})]}),_i=Kt&&qt&&!mt&&!Ke?(0,$.jsx)(`div`,{className:`shrink-0 px-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(Qd,{className:`min-w-0 flex-1`}),(0,$.jsx)(pl,{className:`ml-auto shrink-0`})]})}):null,vi=!mt&&!Ke,yi=vi&&Yt&&!e,bi=!Ke&&(Ur.length>0||Gr.length>0),xi=(0,$.jsxs)(`div`,{className:`space-y-0.5 py-1`,children:[(0,$.jsxs)(Y,{variant:`ghost`,size:`sm`,className:X(`w-full justify-start px-2 font-normal`,e&&`h-11`),onClick:gn,children:[(0,$.jsx)(Z,{name:`chat-new`,className:`size-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`sessions.sidebar.header.actions.newSession`)})]}),(0,$.jsxs)(Y,{variant:`ghost`,size:`sm`,className:X(`w-full justify-start px-2 font-normal`,Ie===`schedule`&&`bg-interactive-selection text-interactive-selection-foreground`,e&&`h-11`),onClick:_n,children:[(0,$.jsx)(Z,{name:`time`,className:`size-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`sessions.sidebar.header.actions.scheduledTasks`)}),a?(0,$.jsx)(gv,{}):null]}),Le.data?.supported&&Le.data?.enabled?(0,$.jsxs)(Y,{variant:`ghost`,size:`sm`,className:X(`w-full justify-start px-2 font-normal`,Ie===`assistant`&&`bg-interactive-selection text-interactive-selection-foreground`,e&&`h-11`),onClick:vn,children:[(0,$.jsx)(al,{className:`size-4 shrink-0 [&[data-assistant-navigation-avatar]]:scale-125`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`assistants.title`)}),(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,$.jsx)(jl,{className:`h-3.5 min-w-3.5 px-1 text-[10px]`}),a?(0,$.jsx)(_v,{}):null]})]}):null,(0,$.jsx)(gl,{sidebar:!0,mobile:e})]}),Si=vi&&!yi||bi?(0,$.jsxs)($.Fragment,{children:[vi&&!yi?(0,$.jsxs)($.Fragment,{children:[e&&qt?(0,$.jsx)(Qd,{}):null,xi]}):null,bi?(0,$.jsx)(Jv,{items:Ur,reorderEnabled:!0,onSessionsReordered:Vr,inProgressItems:Gr,renderSessionNode:ui,currentSessionId:wt,editingId:_,openSidebarMenuKey:L,onVisibleSessionIdsChange:$r}):null]}):null,Ci=!!(z||_||S),{selectionModeEnabled:wi,hasSelection:Ti,selectedIdsSize:Ei,bulkScopeIsArchived:Di,derivedSelectionScope:Oi,bulkScopeFolders:ki,bulkCanRemoveFromFolder:Ai,handleExitSelectionMode:ji,handleBulkMoveToFolder:Mi,handleBulkCreateFolderAndMove:Ni,handleBulkRemoveFromFolder:Pi,handleBulkDelete:Fi,confirmBulkDelete:Ii}=Cx({isInlineEditing:Ci,showDeletionDialog:He,foldersMap:Ye,addSessionsToFolder:rt,removeSessionsFromFolders:at,createFolderAndStartRename:Rn,archiveSessions:bn,setBulkDeleteConfirm:oe});return(0,$.jsxs)(`div`,{ref:h,className:X(`yuri-session-sidebar relative flex h-full flex-col text-foreground overflow-x-hidden`,e?``:`bg-transparent`),children:[(0,$.jsx)(Kv,{hideDirectoryControls:r,isSessionSearchOpen:u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchQuery:f,setSessionSearchQuery:m,hasSessionSearchQuery:Ke,searchMatchCount:Fr}),_i,yi?(0,$.jsx)(`div`,{className:`shrink-0 px-3`,children:xi}):null,a?(0,$.jsx)(Ky,{remoteProjects:xe,hostRegistry:Te.registry,projectOrderIds:$c(ye,kr).map(e=>e.id),onRemoteActivityItems:we,remoteSearch:f,remoteError:Te.catalog.error?.message,onRemoteNavigationTargets:Oe,topContent:Si,hasLeadingSection:Si!==null&&(Ur.length>0||Wr.length>0),headerAccessory:gi,sectionsForRender:Kr,projectSections:Mr,activeProjectId:ke,projectRevealTarget:kt,showOnlyMainWorkspace:i,hasSessionSearchQuery:Ke,emptyState:sn,searchEmptyState:Ir,renderGroupSessions:hi,homeDirectory:ge,collapsedProjects:O,hideDirectoryControls:r,projectRepoStatus:A,mobileVariant:e,alwaysShowActions:Xt,toggleProject:ur,setActiveProjectIdOnly:je,setActiveMainTab:Fe,setSessionSwitcherOpen:ze,openNewSessionDraft:Bt,openNewWorktreeDialog:un,syncProjectSessions:ir,openProjectEditDialog:C,removeProject:Ae,projectReorderEnabled:kr===`manual`,reorderProjects:Ne,projectSortOrder:kr,getOrderedGroups:Lr,setGroupOrderByProject:le,openSidebarMenuKey:L,setOpenSidebarMenuKey:R,isInlineEditing:Ci}):null,wi&&Ti?(0,$.jsx)(Sx,{selectedCount:Ei,scopeKey:Oi,scopeFolders:ki,archivedBucket:Di,onMoveToFolder:Mi,onCreateFolderAndMove:Ni,onRemoveFromFolder:Pi,canRemoveFromFolder:Ai,onDelete:Fi,onDone:ji}):null,(0,$.jsx)(Sv,{normalizedProjects:fr,ownership:yr,enabled:a}),(0,$.jsx)(Iy,{onOpenSettings:hn,onOpenShortcuts:G,onOpenUpdate:pn,showRuntimeButtons:!mt,showUpdateButton:qe}),c?(0,$.jsx)(Wx,{onOpenChange:l}):null,cn?(0,$.jsx)(Gv,{open:!0,onOpenChange:e=>{e||C(null)},project:cn,onSave:ln}):null,F?(0,$.jsx)(aa,{open:!0,onOpenChange:I,onWorktreeCreated:fn}):null,(0,$.jsx)(Wc,{}),(0,$.jsx)(Hs,{}),(0,$.jsx)(yx,{value:te,setValue:ne,showDeletionDialog:He,setShowDeletionDialog:Ue,onConfirm:Nn}),(0,$.jsx)(xx,{value:re,setValue:ie,onConfirm:Fn}),(0,$.jsx)(bx,{value:ae,setValue:oe,showDeletionDialog:He,setShowDeletionDialog:Ue,onConfirm:Ii})]})});function Kx(e){return{info:e.info,downloading:e.downloading,downloaded:e.downloaded,progress:e.progress,error:e.error,runtimeType:e.runtimeType,onDownload:e.downloadUpdate,onRestart:e.restartToUpdate}}var qx=e=>e?(0,$.jsx)(`span`,{className:`text-foreground/80 dark:text-foreground/70`,children:e}):void 0,Jx=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.replace(/\/+$/,``)},Yx=()=>{let{t:e}=Zt(),[t,n]=Q.useState(!1),[r,i]=Q.useState(),[a,o]=Q.useState(null),[s,c]=Q.useState([]),[l,u]=Q.useState(!1),[d,f]=Q.useState(!1),[p,m]=Q.useState(!1),[h,g]=Q.useState(!1),[_,v]=Q.useState(new Set),y=cr(e=>e.getWorktreeMetadata),b=cr(e=>e.newSessionDraft),x=cr(e=>e.setNewSessionDraftTarget),S=cr(e=>e.setDraftBootstrapPendingDirectory),C=un,w=cr(e=>e.archiveSessions),T=q(e=>e.showDeletionDialog),E=q(e=>e.setShowDeletionDialog),D=Pe(e=>e.currentDirectory),O=Pe(e=>e.homeDirectory),k=mn(e=>e.projects),A=mn(e=>e.activeProjectId),{isMobile:j,isTablet:M,hasTouchInput:N}=go(),P=j||M||N,F=Q.useMemo(()=>Jx((A?k.find(e=>e.id===A)??null:null)?.path??D),[A,D,k]),I=Q.useCallback(e=>{let t=Jx(e.projectDirectory)||F;return{id:(k.find(e=>Jx(e.path)===t)??null)?.id??`path:${t}`,path:t}},[F,k]),L=h&&_.size>0,R=Q.useMemo(()=>{let e=a?.worktree;return e&&typeof e.branch==`string`&&e.branch.trim().length>0?!0:s.length>0&&s.every(({metadata:e})=>typeof e.branch==`string`&&e.branch.trim().length>0)},[a?.worktree,s]),z=a?.mode===`worktree`,ee=z,B=p||!z||!R,V=p||!z,te=Q.useCallback(e=>{o({sessions:e.sessions,dateLabel:e.dateLabel,mode:e.mode??`session`,worktree:e.worktree??null})},[]),ne=Q.useCallback(()=>{o(null),c([]),u(!1),f(!1),m(!1),g(!1),v(new Set)},[]),re=Q.useCallback(t=>{if(t.sessions.length===0)return;let n=t.sessions.map(e=>e.id);il({sessionIds:n,message:n.length===1?e(`sessions.sidebar.session.delete.success`):e(`sessions.sidebar.bulkActions.deletedPlural`,{count:n.length}),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:n.length===1?e(`sessions.sidebar.session.delete.error`):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:n.length})})},[e]);Q.useEffect(()=>Kn.onDeleteRequest(e=>{if(!T&&(e.mode??`session`)===`session`){re(e);return}te(e)}),[te,T,re]),Q.useEffect(()=>Kn.onDirectoryRequest(({origin:e})=>{i(e),n(!0)}),[]),Q.useEffect(()=>{if(!a){c([]),u(!1),f(!1),g(!1),v(new Set);return}let e=a.sessions.map(e=>{let t=y(e.id);return t?{session:e,metadata:t}:null}).filter(e=>!!e);c(e),u(!1),g(!1),v(new Set);let t=new Map;if(a.worktree?.path&&t.set(Jx(a.worktree.path),a.worktree),e.forEach(({metadata:e})=>{e.path&&t.set(Jx(e.path),e)}),t.size===0){g(!0);return}let n=!1;return(async()=>{let e=new Map,r=new Set;await Promise.all(Array.from(t.entries()).map(async([t,n])=>{try{let i=await cs(n.path);e.set(t,i),i?.isDirty&&r.add(t)}catch{n.status&&(e.set(t,n.status),n.status.isDirty&&r.add(t))}})).catch(e=>{console.warn(`Failed to inspect worktree status before deletion:`,e)}),!n&&(v(r),g(!0),o(t=>{if(!t?.worktree?.path)return t;let n=Jx(t.worktree.path),r=e.get(n);if(!r)return t;let i=t.worktree.status;return i?.isDirty===r.isDirty&&i?.ahead===r.ahead&&i?.behind===r.behind&&i?.upstream===r.upstream?t:{...t,worktree:{...t.worktree,status:r}}}),c(t=>t.map(t=>{let n=Jx(t.metadata.path),r=e.get(n);return r?{session:t.session,metadata:{...t.metadata,status:r}}:t})))})(),()=>{n=!0}},[a,y]),Q.useEffect(()=>{R||u(!1)},[R]);let ie=Q.useCallback(async(t,n)=>{let r=l&&R,i=I(t),a=Jx(t.path),o=Jx(i.path);try{await ss(i,t,{deleteRemoteBranch:r,deleteLocalBranch:n});let e=Jx(b?.directoryOverride);return b?.open&&a&&e===a&&o&&(S(null),x({projectId:i.id,directoryOverride:o},{force:!0})),Jx(D)===a&&o&&Pe.getState().setDirectory(o,{showOverlay:!1}),!0}catch(t){return J.error(e(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:qx(t instanceof Error?t.message:e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),!1}},[R,D,l,I,b?.directoryOverride,b?.open,S,x,e]),ae=Q.useCallback((t,n)=>{let r=l&&R;(async()=>{if(!await ie(t,n))return;let i=e(r?`sessions.sidebar.sessionDialogs.worktree.removedWithRemote`:`sessions.sidebar.sessionDialogs.worktree.removed`);J.success(e(`sessions.sidebar.sessionDialogs.worktree.removedTitle`),{description:qx(i)})})()},[R,l,ie,e]),oe=Q.useCallback(async()=>{if(a){m(!0);try{let t=ee&&d;if(a.sessions.length===0&&z&&a.worktree){ae(a.worktree,t),ne();return}if(a.sessions.length===1){let t=a.sessions[0];if(z){if(!await C(t.id)){J.error(e(`sessions.sidebar.session.archive.error`)),m(!1);return}nl({sessionIds:[t.id],message:e(`sessions.sidebar.session.archive.success`),undoLabel:e(`sessions.sidebar.undo`),settingsLabel:e(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:e(`sessions.sidebar.session.archive.undoFailed`)})}else il({sessionIds:[t.id],message:e(`sessions.sidebar.session.delete.success`),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:e(`sessions.sidebar.session.delete.error`)})}else{let n=a.sessions.map(e=>e.id),r=[],i=[];if(z){let e=await w(n);r=e.archivedIds,i=e.failedIds}else il({sessionIds:n,message:n.length===1?e(`sessions.sidebar.bulkActions.deletedSingle`,{count:n.length}):e(`sessions.sidebar.bulkActions.deletedPlural`,{count:n.length}),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:n.length===1?e(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:n.length}):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:n.length})}),r=n,i=[];if(z&&a.worktree&&i.length===0&&ae(a.worktree,t),z&&r.length>0&&nl({sessionIds:r,message:r.length===1?e(`sessions.sidebar.bulkActions.archivedSingle`,{count:r.length}):e(`sessions.sidebar.bulkActions.archivedPlural`,{count:r.length}),undoLabel:e(`sessions.sidebar.undo`),settingsLabel:e(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:r.length===1?e(`sessions.sidebar.session.archive.undoFailed`):e(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:r.length})}),i.length>0&&(J.error(z?i.length===1?e(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):e(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}):i.length===1?e(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:i.length}):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:i.length}),{description:qx(e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),r.length===0)){m(!1);return}}z&&a.sessions.length===1&&a.worktree&&ae(a.worktree,t),ne()}finally{m(!1)}}},[a,d,C,w,ne,ee,z,ae,e]),H=a?.worktree??s[0]?.metadata??null,se=a?a.mode===`worktree`?a.sessions.length===0?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked`):a.sessions.length===1?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked`,{count:a.sessions.length}):e(`sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked`,{count:a.sessions.length}):a.sessions.length===1?a.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate`,{dateLabel:a.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionOne`):a.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate`,{count:a.sessions.length,dateLabel:a.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionMany`,{count:a.sessions.length}):``,U=a?(0,$.jsxs)(`div`,{className:X(z?`space-y-3`:`space-y-2`),children:[a.sessions.length>0&&(0,$.jsxs)(`div`,{className:X(z?`rounded-lg bg-muted/30 p-3`:`space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3`),children:[z&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:a.sessions.length===1?e(`sessions.sidebar.sessionDialogs.linkedSessionSingle`):e(`sessions.sidebar.sessionDialogs.linkedSessionPlural`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:a.sessions.length})]}),(0,$.jsxs)(`ul`,{className:X(z?`mt-2 space-y-1`:`space-y-0.5`),children:[a.sessions.slice(0,5).map(t=>(0,$.jsxs)(`li`,{className:X(z?`flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground`:`typography-micro text-muted-foreground/80`),children:[(0,$.jsx)(`span`,{className:X(!z&&`hidden`),children:`•`}),(0,$.jsx)(`span`,{className:`truncate`,children:t.title||e(`sessions.sidebar.session.untitled`)})]},t.id)),a.sessions.length>5&&(0,$.jsx)(`li`,{className:X(z?`px-2.5 py-1 text-xs text-muted-foreground/70`:`typography-micro text-muted-foreground/70`),children:e(`sessions.sidebar.dialogs.sessionList.more`,{count:a.sessions.length-5})})]})]}),z?(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg bg-muted/30 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:e(`sessions.sidebar.sessionDialogs.worktree.label`)}),H?.label?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:H.label}):null]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/80 break-all`,children:H?an(H.path,O):e(`sessions.sidebar.sessionDialogs.worktree.pathUnavailable`)}),L&&(0,$.jsx)(`p`,{className:`typography-micro text-status-warning`,children:e(`sessions.sidebar.sessionDialogs.worktree.uncommittedWarning`)})]}):(0,$.jsx)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/60 p-3`,children:(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/80`,children:e(`sessions.sidebar.sessionDialogs.delete.note`)})})]}):null,ce=z?R?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{B||u(e=>!e)},disabled:B,className:X(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,B?`cursor-not-allowed opacity-60`:`hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),children:[l?(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}):(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}),e(`sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch`)]}):(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:e(`sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable`)}):null,W=z?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{V||f(e=>!e)},disabled:V,className:X(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,V?`cursor-not-allowed opacity-60`:`hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),children:[d?(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}):(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}),e(`sessions.sidebar.sessionDialogs.actions.deleteLocalBranch`)]}):null,le=z?(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[W,ce]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{variant:`ghost`,onClick:ne,disabled:p,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{variant:`destructive`,onClick:oe,disabled:p,children:e(p?`sessions.sidebar.sessionDialogs.actions.deleting`:`sessions.sidebar.sessionDialogs.actions.deleteWorktree`)})]})]}):(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>E(!T),className:`inline-flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":!T,children:[T?(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}):(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}),e(`sessions.sidebar.dialogs.neverAsk`)]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{variant:`ghost`,onClick:ne,disabled:p,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{variant:`destructive`,onClick:oe,disabled:p,children:p?e(`sessions.sidebar.sessionDialogs.actions.deleting`):a?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`)})]})]}),ue=z?e(`sessions.sidebar.sessionDialogs.actions.deleteWorktree`):a?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`);return(0,$.jsxs)($.Fragment,{children:[P?(0,$.jsx)(Ua,{open:!!a,onClose:()=>{p||ne()},title:ue,footer:(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:le}),children:(0,$.jsxs)(`div`,{className:`space-y-2 pb-2`,children:[se&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/80`,children:se}),U]})}):(0,$.jsx)(Jr,{open:!!a,onOpenChange:e=>{if(!e){if(p)return;ne()}},children:(0,$.jsxs)(Gr,{className:X(z?`max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3`:`max-w-[min(520px,100vw-2rem)] space-y-2 pb-2`),children:[(0,$.jsxs)(Ur,{children:[(0,$.jsxs)(Kr,{className:X(z&&`flex items-center gap-2`),children:[z&&(0,$.jsx)(Z,{name:`delete-bin`,className:`h-5 w-5`}),ue]}),se&&(0,$.jsx)(qr,{children:se})]}),(0,$.jsx)(`div`,{className:X(z&&`flex-1 min-h-0 overflow-y-auto space-y-2`),children:U}),(0,$.jsx)(Wr,{className:`mt-2 gap-2 pt-1 pb-1`,children:le})]})}),(0,$.jsx)(Kc,{open:t,onOpenChange:n,origin:r})]})},Xx=Q.createContext(null),Zx=e=>{let t=(0,du.c)(3),{children:n,value:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(Xx.Provider,{value:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},Qx=So(()=>Pt(()=>import(`./TerminalView-BmdJXwbs.js`).then(e=>({default:e.TerminalView})),__vite__mapDeps([79,1,4,2,5,3,6,7,8,9,21,22,23,20,24,25,18,80,43,44,45,46,47,13,10,12,11,14,15,16,17,19,48,81,37,38,39,40,41,42,49,50,51,52,53,54,55,56,57,58,60,82,66,83,84,85,86,87,88,89,90,91,92]))),$x=So(()=>Pt(()=>import(`./DiagramView-zPxVoYfO.js`).then(e=>({default:e.DiagramView})),__vite__mapDeps([93,1,3,2,9,11,12,13,4,5,6,7,8,10,14,15,16,17,18,19,20,21,22,23,24,25,49,37,38,39,40,41,60,42,43,44,45,46,47,48,50,51,52,53,54,55,56,57,66,84,80,94,95]))),eS=So(()=>Pt(()=>import(`./SettingsView-CmYrql0Y.js`).then(e=>e.n).then(e=>({default:e.SettingsView})),__vite__mapDeps([96,1,2,3,4,5,6,7,8,97,98,22,9,43,23,20,24,44,45,46,47,13,10,12,11,14,15,16,17,18,19,21,25,48,99,100,101,49,37,38,39,40,41,102,42,50,51,52,53,54,55,56,57,60,103,104,105,71,106,107,68,58,59,61,62,72,108,109,110,111,112,113,69,114,82,115,83,116,117,86,87,88,76,118,119,120,65,66,67,70,27,28,29,30,31,32,33,34,35,36,85,121,122,123,124,125,126,78,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143]))),tS=So(()=>Pt(()=>import(`./SettingsWindow-DbAjbzAm.js`).then(e=>({default:e.SettingsWindow})),__vite__mapDeps([144,1,9,10,37,6,2,3,7,8,38,23,20,39,40,22,18,41,42,5,4,43,24,44,45,46,47,13,12,11,14,15,16,17,19,21,25,48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,60,103,104,105,71,106,107,68,58,59,61,62,72,108,109,110,111,112,113,69,114,82,115,83,116,117,86,87,88,76,118,119,120,65,66,67,70,27,28,29,30,31,32,33,34,35,36,85,121,122,123,124,125,126,78,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143]))),nS=So(()=>Pt(()=>import(`./MultiRunWindow-BjmrZIN8.js`).then(e=>({default:e.MultiRunWindow})),__vite__mapDeps([145,1,9,10,37,6,2,3,7,8,38,23,20,39,40,22,18,41,42,5,4,43,24,44,45,46,47,13,12,11,14,15,16,17,19,21,25,48,49,50,51,52,53,54,55,56,57,60,146,108,147,109,110,82,148,149,150,151,105,71,106,107,68,58,59,152,115,83,117,114,113,69,86,87,88,76,129]))),rS=So(()=>Pt(()=>import(`./AssistantView-oeyp5moU.js`).then(e=>e.n).then(e=>({default:e.AssistantView})),__vite__mapDeps([153,1,2,3,6,7,8,9,10,11,12,15,16,17,21,5,22,23,20,24,25,18,49,37,38,39,40,41,102,4,13,14,19,42,43,44,45,46,47,48,50,51,52,53,54,55,56,57,60,103,104,105,71,106,107,68,58,59,61,62,72,82,154,155,149,150,151,120,65,66,67,156,64,113,69,139,157,75,73,74,115,83,158,152,159,160,161,162,163,135,116]))),iS=()=>{let e=q(e=>e.isSidebarOpen),t=q(e=>e.isRightSidebarOpen),n=q(e=>e.isBottomTerminalOpen),r=q(e=>e.setRightSidebarOpen),i=q(e=>e.setBottomTerminalOpen),a=q(e=>e.activeMainTab),o=q(e=>e.setIsMobile),s=q(e=>e.isSessionSwitcherOpen),c=q(e=>e.isSettingsDialogOpen),l=q(e=>e.setSettingsDialogOpen),u=q(e=>e.isMultiRunLauncherOpen),d=q(e=>e.setMultiRunLauncherOpen),{isMobile:f,isTablet:p}=go(),m=Q.useRef(!1),h=Q.useRef(!1),[g,_]=Q.useState(!1),[v,y]=Q.useState(!1),[b,x]=Q.useState(!1),[S,C]=Q.useState(!1),w=Q.useCallback(e=>{_(e),q.getState().setSessionSwitcherOpen(e)},[]),T=Q.useRef(!1),E=Q.useRef(typeof window>`u`?0:window.innerWidth),D=Br(-E.current),O=(0,Q.useRef)(0),k=Br(E.current),A=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{f&&(O.current=window.innerWidth,A.current=window.innerWidth)},[f]),(0,Q.useEffect)(()=>{if(!f){x(!1);return}g&&x(!0),Vr(D,g?0:-O.current,{type:`spring`,stiffness:400,damping:35,mass:.8})},[g,f,D]),(0,Q.useEffect)(()=>{if(!f){C(!1);return}T.current=v,v&&C(!0),Vr(k,v?0:A.current,{type:`spring`,stiffness:400,damping:35,mass:.8})},[f,v,k]),(0,Q.useEffect)(()=>{if(f)return D.on(`change`,e=>{let t=O.current||E.current,n=g||e>-t+.5;x(e=>e===n?e:n)})},[f,D,g]),(0,Q.useEffect)(()=>{if(f)return k.on(`change`,e=>{let t=A.current||E.current,n=v||e<t-.5;C(e=>e===n?e:n)})},[f,v,k]),(0,Q.useEffect)(()=>{f&&!s&&g&&w(!1)},[s,f,g,w]),(0,Q.useEffect)(()=>{if(!f){h.current=!1;return}h.current||(h.current=!0,w(!1),y(!1),q.getState().isRightSidebarOpen&&r(!1))},[f,w,r]),(0,Q.useEffect)(()=>{if(!f||a!==`chat`||g||v||c)return;let e=!1,t,n=r=>{t=window.setTimeout(()=>{if(e)return;let t=cr.getState(),r=q.getState();if(!(r.activeMainTab!==`chat`||r.isSettingsDialogOpen||t.currentSessionId||t.newSessionDraft?.open)){if(t.isLoading){n(250);return}t.openNewSessionDraft()}},r)};return n(500),()=>{e=!0,t!==void 0&&window.clearTimeout(t)}},[a,f,c,g,v]),(0,Q.useEffect)(()=>{!f||!c||(w(!1),y(!1),t&&r(!1))},[f,c,t,w,r]),Q.useEffect(()=>{q.getState().isMobile!==f&&o(f)},[f,o]),Q.useEffect(()=>{if(typeof window>`u`)return;let e,t=()=>{e===void 0&&(e=window.requestAnimationFrame(()=>{e=void 0,q.getState().updateProportionalSidebarWidths()}))};return window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t),e!==void 0&&window.cancelAnimationFrame(e)}},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e,t=()=>{let e=q.getState(),t=window.innerHeight;!f&&!p&&(t<640?e.isBottomTerminalOpen&&(i(!1),m.current=!0):t>=700&&m.current&&(i(!0),m.current=!1))},n=()=>{e===void 0&&(e=window.requestAnimationFrame(()=>{e=void 0,t()}))};return t(),window.addEventListener(`resize`,n),()=>{window.removeEventListener(`resize`,n),e!==void 0&&window.cancelAnimationFrame(e)}},[f,p,i]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=q.subscribe((e,t)=>{let n=window.innerHeight>=700;e.isBottomTerminalOpen!==t.isBottomTerminalOpen&&n&&(m.current=!1)});return()=>{e()}},[f,p,i]);let j=Q.useCallback(()=>{g&&w(!1),y(!v)},[g,v,w]),M=Q.useMemo(()=>{switch(a){case`git`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(lh,{isActive:!v})});case`diff`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(uc,{})});case`terminal`:return n?null:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Qx,{})});case`files`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Jf,{})});case`diagram`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)($x,{})});default:return null}},[a,n,v]),N=a===`schedule`,P=a===`assistant`,F=a===`plugin`,I=N||P||F,L=a===`chat`,R=!I&&!c;return(0,$.jsx)(qc,{children:(0,$.jsxs)(`div`,{"data-page-scroll-lock":`true`,className:X(`main-content-safe-area`,f?`flex h-[100dvh] flex-col`:`relative flex h-[100dvh]`,`bg-background`),children:[(0,$.jsx)(El,{}),(0,$.jsx)(cv,{}),(0,$.jsx)(fv,{}),(0,$.jsx)(Yx,{}),(0,$.jsx)(hl,{}),f?(0,$.jsxs)(Zx,{value:{leftDrawerOpen:g,rightDrawerOpen:v,toggleLeftDrawer:()=>{let e=!g;v&&y(!1),w(e)},toggleRightDrawer:j,leftDrawerX:D,rightDrawerX:k,leftDrawerWidth:O,rightDrawerWidth:A,setMobileLeftDrawerOpen:w,setRightSidebarOpen:y},children:[!c&&!I&&(0,$.jsx)(Ad,{onToggleLeftDrawer:()=>{let e=!g;v&&y(!1),w(e)},onToggleRightDrawer:()=>{j()},leftDrawerOpen:g,rightDrawerOpen:v}),(0,$.jsx)(`div`,{"data-page-scroll-lock":`true`,className:X(`flex flex-1 overflow-hidden relative`,c&&`hidden`),children:(0,$.jsxs)(`main`,{className:`w-full h-full overflow-hidden bg-background relative`,"data-page-scroll-lock":`true`,children:[N&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(po,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Hc,{})})})}),P&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(po,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(rS,{})})})}),R&&(0,$.jsx)(`div`,{className:X(`absolute inset-0`,!L&&`invisible`),children:(0,$.jsx)(Nc,{children:(0,$.jsx)(po,{children:(0,$.jsx)(Ec,{})})})}),R&&M&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Nc,{children:(0,$.jsx)(po,{children:M})})}),u&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(po,{children:(0,$.jsx)(tu,{onCreated:()=>d(!1),onCancel:()=>d(!1)})})}),(0,$.jsx)(ps.div,{className:X(`absolute inset-0 z-20 bg-sidebar`,!b&&`pointer-events-none invisible`),"data-page-scroll-lock":`true`,style:{x:D},"aria-hidden":!g,children:(0,$.jsx)(po,{children:(0,$.jsx)(Gx,{mobileVariant:!0,isVisible:b})})}),S&&(0,$.jsx)(ps.div,{className:`absolute inset-0 z-20 bg-sidebar`,"data-page-scroll-lock":`true`,style:{x:k},"aria-hidden":!v,children:(0,$.jsx)(po,{children:(0,$.jsx)(Nc,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(lh,{isActive:v})})})})})]})}),c&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,style:{paddingTop:`var(--yuri-safe-area-top, 0px)`},children:(0,$.jsx)(po,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(eS,{onClose:()=>l(!1)})})})}),(0,$.jsx)(po,{children:(0,$.jsx)(_l,{})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(rf,{}),(0,$.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:[(0,$.jsx)(Xd,{isOpen:e,isMobile:f,className:`border-border/50`,topBar:(0,$.jsx)(Zd,{}),children:(0,$.jsx)(Gx,{isVisible:e})}),(0,$.jsx)(`div`,{className:`relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:I?(0,$.jsx)(`main`,{className:`flex-1 overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(po,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:F?(0,$.jsx)(Ul,{}):P?(0,$.jsx)(rS,{}):(0,$.jsx)(Hc,{})})})}):(0,$.jsx)(Nc,{children:(0,$.jsxs)(ov,{header:(0,$.jsx)(Ad,{}),footer:(0,$.jsx)(Vd,{isOpen:n,isMobile:f,children:n?(0,$.jsx)(po,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Qx,{})})}):null}),children:[R&&(0,$.jsx)(`div`,{className:X(`absolute inset-0`,!L&&`invisible`),children:(0,$.jsx)(po,{children:(0,$.jsx)(Ec,{})})}),R&&M&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(po,{children:M})})]})})})]}),(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(tS,{open:c,onOpenChange:l})}),(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(nS,{open:u,onOpenChange:d})})]})]})})},aS=9e4,oS=15e3,sS=3e5,cS=[2e3,5e3],lS=6e4,uS=12e4,dS=3e5,fS=4,pS=432e5,mS=`yuri.github-pr-status`,hS=e=>e===`closed`||e===`merged`,gS=e=>{let t=e?.checks;return t?t.state===`pending`||t.pending>0:!1},_S=(e,t,n)=>`${e}::${t}`,vS=new Map,yS=new Map,bS=new Set,xS=new Map,SS=2,CS=0,wS=[],TS=()=>CS<SS?(CS+=1,Promise.resolve()):new Promise(e=>{wS.push(e)}),ES=()=>{let e=wS.shift();if(e){e();return}CS=Math.max(0,CS-1)},DS=()=>({status:null,isLoading:!1,error:null,isInitialStatusResolved:!1,lastRefreshAt:0,lastDiscoveryPollAt:0,watchers:0,params:null,identity:null,resolvedRemoteName:null}),OS=e=>e?.params?.directory&&e.params.branch?{directory:e.params.directory,branch:e.params.branch,remoteName:e.params.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null}:!e?.identity?.directory||!e.identity.branch?null:e.identity,kS=e=>{let t=OS(e);return!t?.directory||!t.branch?null:`${t.directory}::${t.branch}`},AS=(e,t)=>Object.entries(e).filter(([,e])=>kS(e)===t).map(([e])=>e),jS=(e,t)=>{let n=t.remoteName??e.params?.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null;return{...e,params:e.params?{...e.params,...t,remoteName:n}:{...t,remoteName:n},identity:{directory:t.directory,branch:t.branch,remoteName:n}}},MS=e=>!e?.params?.canShow||!e.params.github?.prStatus?null:{...e.params,remoteName:e.params.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null},NS=(e,t,n)=>{let r=AS(e,t),i=r.map(t=>MS(e[t])).filter(e=>!!e);if(i.length===0)return null;let a=MS(e[n]);if(a&&kS(e[n])===t)return a;let o=r.map(t=>e[t]).find(e=>!!(e?.resolvedRemoteName&&MS(e)));return o?MS(o):i.find(e=>!!e.remoteName)||(i[0]??null)},PS=e=>({status:e.status,isInitialStatusResolved:e.isInitialStatusResolved,lastRefreshAt:e.lastRefreshAt,lastDiscoveryPollAt:e.lastDiscoveryPollAt,identity:OS(e),resolvedRemoteName:e.resolvedRemoteName??e.status?.resolvedRemoteName??null}),FS=e=>({...DS(),status:e?.status??null,isInitialStatusResolved:e?.isInitialStatusResolved??!1,lastRefreshAt:e?.lastRefreshAt??0,lastDiscoveryPollAt:e?.lastDiscoveryPollAt??0,identity:e?.identity??null,resolvedRemoteName:e?.resolvedRemoteName??e?.status?.resolvedRemoteName??null}),IS=W()(le((e,t)=>({entries:{},activeRequestCount:0,totalRequestCount:0,ensureEntry:t=>{e(e=>e.entries[t]?e:{entries:{...e.entries,[t]:DS()}})},setParams:(t,n)=>{e(e=>{let r=e.entries[t]??DS();return{entries:{...e.entries,[t]:jS(r,n)}}})},startWatching:n=>{if(e(e=>{let t=e.entries[n]??DS();return{entries:{...e.entries,[n]:{...t,watchers:t.watchers+1}}}}),vS.has(n))return;let r=e=>{let r=window.setTimeout(()=>{if(typeof document<`u`&&document.visibilityState!==`visible`)return;let e=t().entries[n];!e||e.watchers<=0||e.status?.pr||t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0})},e),i=yS.get(n)??[];i.push(r),yS.set(n,i)};t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0}),cS.forEach(e=>r(e));let i=window.setInterval(()=>{if(typeof document<`u`&&document.visibilityState!==`visible`)return;let r=t().entries[n];if(!(!r||r.watchers<=0)){if(!r.status?.pr){let i=Date.now();if(i-r.lastDiscoveryPollAt<sS)return;e(e=>{let t=e.entries[n];return t?{entries:{...e.entries,[n]:{...t,lastDiscoveryPollAt:i}}}:e}),t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0});return}hS(r.status?.pr?.state)||Date.now()-r.lastRefreshAt<(gS(r.status)?lS:r.status?.checks&&r.status.checks.state!==`pending`?dS:uS)||t().refresh(n,{force:!0,onlyExistingPr:!0,silent:!0,markInitialResolved:!0})}},oS);vS.set(n,i)},stopWatching:n=>{e(e=>{let t=e.entries[n];if(!t)return e;let r=Math.max(0,t.watchers-1);return{entries:{...e.entries,[n]:{...t,watchers:r}}}});let r=t().entries[n];if(r&&r.watchers>0)return;let i=vS.get(n);typeof i==`number`&&window.clearInterval(i),vS.delete(n);let a=yS.get(n);a&&a.length>0&&a.forEach(e=>{window.clearTimeout(e)}),yS.delete(n)},refresh:async(n,r)=>{let i=t(),a=i.entries[n],o=kS(a);if(!a||!o)return;let s=AS(i.entries,o),c=s.some(e=>!!i.entries[e]?.status?.pr);if(r?.onlyExistingPr&&!c)return;let l=xS.get(o)??0;if(!r?.force&&Date.now()-l<aS||bS.has(o))return;let u=NS(i.entries,o,n);if(u){if(bS.add(o),xS.set(o,Date.now()),e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,lastRefreshAt:Date.now(),isLoading:!r?.silent||n.isLoading,error:null})}),{entries:t}}),u.githubAuthChecked&&u.githubConnected===!1){e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,status:{connected:!1},error:null,isLoading:r?.silent?n.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||n.isInitialStatusResolved})}),{entries:t}}),bS.delete(o);return}if(!u.github?.prStatus){e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,status:null,error:`GitHub runtime API unavailable`,isLoading:r?.silent?n.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||n.isInitialStatusResolved})}),{entries:t}}),bS.delete(o);return}try{e(e=>({...e,activeRequestCount:e.activeRequestCount+1,totalRequestCount:e.totalRequestCount+1})),await TS();let t;try{t=await u.github.prStatus(u.directory,u.branch,u.remoteName??void 0,{force:r?.force})}finally{ES()}e(e=>{let n={...e.entries};return s.forEach(e=>{let i=n[e];if(!i)return;let a=i.status?.pr,o=t.pr,s=o&&a&&o.number===a.number&&(!o.body||!o.body.trim())&&typeof a.body==`string`&&a.body.trim().length>0&&o&&a?.body?{...t,pr:{...o,body:a.body}}:t,c=s.resolvedRemoteName??i.resolvedRemoteName??u.remoteName??null,l=OS(i)??{directory:u.directory,branch:u.branch,remoteName:u.remoteName??null};n[e]={...i,status:s,error:null,isLoading:r?.silent?i.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||i.isInitialStatusResolved,resolvedRemoteName:c,identity:{...l,remoteName:c??l.remoteName??null}}}),{entries:n}})}catch(t){let n=t instanceof Error?t.message:String(t);e(e=>{let t={...e.entries};return s.forEach(e=>{let i=t[e];i&&(t[e]={...i,error:n||`Failed to load PR status`,isLoading:r?.silent?i.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||i.isInitialStatusResolved})}),{entries:t}})}finally{bS.delete(o),e(e=>({...e,activeRequestCount:Math.max(0,e.activeRequestCount-1)}))}}},refreshTargets:async(e,n)=>{await Hv(Array.from(new Set(e.map(e=>{let t=e.directory.trim(),n=e.branch.trim();return!t||!n?null:_S(t,n,e.remoteName??null)}).filter(e=>!!e))),fS,e=>t().refresh(e,n))},updateStatus:(t,n)=>{e(e=>{let r=e.entries[t]??DS();return{entries:{...e.entries,[t]:{...r,status:n(r.status)}}}})}}),{name:mS,storage:He(),partialize:e=>({entries:Object.fromEntries(Object.entries(e.entries).filter(([,e])=>{let t=OS(e);if(!t?.directory||!t.branch)return!1;let n=Math.max(e.lastRefreshAt,e.lastDiscoveryPollAt);return n===0||Date.now()-n<pS}).map(([e,t])=>[e,PS(t)]))}),merge:(e,t)=>{let n=e?.entries??{};return{...t,entries:Object.fromEntries(Object.entries(n).map(([e,t])=>[e,FS(t)]))}}})),LS=e=>{if(e<1e3)return`${Math.round(e)}ms`;let t=e/1e3;return t<60?`${t.toFixed(1)}s`:`${Math.floor(t/60)}m ${Math.round(t%60)}s`},RS=e=>{let t=(0,du.c)(8),{label:n,value:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={backgroundColor:`color-mix(in srgb, var(--surface-muted) 55%, transparent)`},t[0]=i):i=t[0];let a;t[1]===n?a=t[2]:(a=(0,$.jsx)(`div`,{className:`typography-meta text-[var(--surface-muted-foreground)]`,children:n}),t[1]=n,t[2]=a);let o;t[3]===r?o=t[4]:(o=(0,$.jsx)(`div`,{className:`typography-markdown font-semibold text-[var(--surface-foreground)]`,children:r}),t[3]=r,t[4]=o);let s;return t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`div`,{className:`rounded-md p-2`,style:i,children:[a,o]}),t[5]=a,t[6]=o,t[7]=s):s=t[7],s},zS=e=>{let t=(0,du.c)(43),{title:n,snapshot:r,emptyLabel:i}=e,{t:a}=Zt(),o;if(t[0]!==i||t[1]!==r.durationMs||t[2]!==r.entries||t[3]!==r.lastUpdatedAt||t[4]!==r.startedAt||t[5]!==a||t[6]!==n){let e=r.entries.slice(0,12),s;t[8]===r.entries?s=t[9]:(s=r.entries.reduce(VS,0),t[8]=r.entries,t[9]=s);let c=s,l;t[10]===n?l=t[11]:(l=(0,$.jsx)(`div`,{className:`typography-ui-label font-semibold text-[var(--surface-foreground)]`,children:n}),t[10]=n,t[11]=l);let u;t[12]!==r.durationMs||t[13]!==r.startedAt||t[14]!==a?(u=r.startedAt?LS(r.durationMs):a(`memoryDebugPanel.common.idle`),t[12]=r.durationMs,t[13]=r.startedAt,t[14]=a,t[15]=u):u=t[15];let d;t[16]===u?d=t[17]:(d=(0,$.jsx)(`div`,{className:`typography-meta text-[var(--surface-muted-foreground)]`,children:u}),t[16]=u,t[17]=d);let f;t[18]!==l||t[19]!==d?(f=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[l,d]}),t[18]=l,t[19]=d,t[20]=f):f=t[20];let p;t[21]===a?p=t[22]:(p=a(`memoryDebugPanel.metric.metrics`),t[21]=a,t[22]=p);let m;t[23]!==r.entries.length||t[24]!==p?(m=(0,$.jsx)(RS,{label:p,value:r.entries.length}),t[23]=r.entries.length,t[24]=p,t[25]=m):m=t[25];let h;t[26]===a?h=t[27]:(h=a(`memoryDebugPanel.metric.samples`),t[26]=a,t[27]=h);let g;t[28]!==h||t[29]!==c?(g=(0,$.jsx)(RS,{label:h,value:c}),t[28]=h,t[29]=c,t[30]=g):g=t[30];let _;t[31]===a?_=t[32]:(_=a(`memoryDebugPanel.metric.lastUpdate`),t[31]=a,t[32]=_);let v;t[33]!==r.lastUpdatedAt||t[34]!==a?(v=r.lastUpdatedAt?a(`memoryDebugPanel.common.live`):a(`memoryDebugPanel.common.notAvailable`),t[33]=r.lastUpdatedAt,t[34]=a,t[35]=v):v=t[35];let y;t[36]!==_||t[37]!==v?(y=(0,$.jsx)(RS,{label:_,value:v}),t[36]=_,t[37]=v,t[38]=y):y=t[38];let b;t[39]!==g||t[40]!==y||t[41]!==m?(b=(0,$.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[m,g,y]}),t[39]=g,t[40]=y,t[41]=m,t[42]=b):b=t[42],o=(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0`,children:[f,b,e.length===0?(0,$.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}):(0,$.jsx)(es,{outerClassName:`max-h-64`,className:`pr-1`,children:(0,$.jsx)(`div`,{className:`space-y-1`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`rounded-md border border-[var(--interactive-border)] p-2`,style:{backgroundColor:`color-mix(in srgb, var(--surface-elevated) 88%, transparent)`},children:[(0,$.jsx)(`div`,{className:`typography-meta font-medium text-[var(--surface-foreground)] break-all`,children:e.metric}),(0,$.jsxs)(`div`,{className:`mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]`,children:[(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.countValue`,{value:e.count})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.avgValue`,{value:e.avg})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.maxValue`,{value:e.max})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.totalValue`,{value:e.total})})]})]},e.metric))})})]}),t[0]=i,t[1]=r.durationMs,t[2]=r.entries,t[3]=r.lastUpdatedAt,t[4]=r.startedAt,t[5]=a,t[6]=n,t[7]=o}else o=t[7];return o},BS=e=>{let t=(0,du.c)(104),{onClose:n}=e,{t:r}=Zt(),[i,a]=Q.useState(`memory`),[o,s]=Q.useState(`idle`),c=cr(HS),l=Tn(US),u=Tr(),d=Vn(),[f,p]=Q.useState(WS),m,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>nt(()=>{p(Ke())}),h=[],t[0]=m,t[1]=h):(m=t[0],h=t[1]),Q.useEffect(m,h);let g;if(t[2]!==d||t[3]!==u){bb0:{let e=Xe(),t={};if(!e){g=t;break bb0}let n=e.getCacheBudget?.(),r=n?n.listCanonical().map(GS):u.map(e=>({directory:d,sessionID:e.id}));for(let n of r){if(d&&n.directory!==d)continue;let r=e.getTranscript(it(n.directory,n.sessionID));t[n.sessionID]=r.messageOrder.map(e=>r.messagesByID[e]).filter(KS)}g=t}t[2]=d,t[3]=u,t[4]=g}else g=t[4];let _=g,v=IS(qS),[y,b]=Q.useState(JS),[x,S]=Q.useState(YS),C;t[5]===y.entries?C=t[6]:(C=new Map,y.entries.forEach(e=>{C.set(e.metric,e.count)}),t[5]=y.entries,t[6]=C);let w;t[7]===C?w=t[8]:(w=C.get(`ui.message_list.render`)??0,t[7]=C,t[8]=w);let T;t[9]===C?T=t[10]:(T=C.get(`ui.message_list.render.streaming`)??0,t[9]=C,t[10]=T);let E;t[11]===C?E=t[12]:(E=C.get(`ui.chat_message.render`)??0,t[11]=C,t[12]=E);let D;t[13]===C?D=t[14]:(D=C.get(`ui.chat_message.render.streaming`)??0,t[13]=C,t[14]=D);let O;t[15]===C?O=t[16]:(O=C.get(`ui.chat_message.render.static_during_stream`)??0,t[15]=C,t[16]=O);let k;t[17]===C?k=t[18]:(k=C.get(`ui.chat_message.render.static_outside_active_turn_during_stream`)??0,t[17]=C,t[18]=k);let A;t[19]!==w||t[20]!==T||t[21]!==E||t[22]!==D||t[23]!==O||t[24]!==k?(A={messageListRender:w,messageListRenderStreaming:T,chatMessageRender:E,chatMessageRenderStreaming:D,chatMessageRenderStaticDuringStream:O,chatMessageRenderStaticOutsideActiveTurnDuringStream:k},t[19]=w,t[20]=T,t[21]=E,t[22]=D,t[23]=O,t[24]=k,t[25]=A):A=t[25];let j=A,M,N;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{let e=()=>{b(ke()),S(G())};e();let t=window.setInterval(e,500);return()=>window.clearInterval(t)},N=[],t[26]=M,t[27]=N):(M=t[26],N=t[27]),Q.useEffect(M,N);let P,F;t[28]===o?(P=t[29],F=t[30]):(P=()=>{if(o===`idle`)return;let e=window.setTimeout(()=>{s(`idle`)},1500);return()=>window.clearTimeout(e)},F=[o],t[28]=o,t[29]=P,t[30]=F),Q.useEffect(P,F);let I=0,L=0,R=0;for(let e of Object.keys(_)){let t=_[e]??[];L+=t.length;for(let e of t)e.role===`user`?R+=1:e.role===`assistant`&&(I+=1)}let z;t[31]!==I||t[32]!==L||t[33]!==R?(z={assistant:I,total:L,user:R},t[31]=I,t[32]=L,t[33]=R,t[34]=z):z=t[34];let ee=z,B;if(t[35]!==c||t[36]!==_||t[37]!==l||t[38]!==u||t[39]!==r){let e;t[41]!==c||t[42]!==_||t[43]!==l||t[44]!==r?(e=e=>{let t=_[e.id]??[],n=0,i=0;for(let e of t)e.role===`user`?i+=1:e.role===`assistant`&&(n+=1);let a=l.get(e.id);return{id:e.id,title:e.title||r(`memoryDebugPanel.common.untitled`),assistantMessageCount:n,messageCount:t.length,userMessageCount:i,isStreaming:a?.isStreaming||!1,isZombie:a?.isZombie||!1,backgroundCount:a?.backgroundMessageCount||0,lastAccessed:a?.lastAccessedAt||0,isCurrent:e.id===c}},t[41]=c,t[42]=_,t[43]=l,t[44]=r,t[45]=e):e=t[45],B=u.map(e).sort(XS),t[35]=c,t[36]=_,t[37]=l,t[38]=u,t[39]=r,t[40]=B}else B=t[40];let V=B,te;t[46]===_?te=t[47]:(te=Object.keys(_),t[46]=_,t[47]=te);let ne=te.length,re;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(re=async()=>{try{let e={generatedAt:new Date().toISOString(),ui:ke(),vscode:G()};await navigator.clipboard.writeText(JSON.stringify(e,null,2)),s(`copied`)}catch{s(`error`)}},t[48]=re):re=t[48];let ie=re,ae;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ae={backgroundColor:`color-mix(in srgb, var(--surface-background) 94%, transparent)`},t[49]=ae):ae=t[49];let oe;t[50]===i?oe=t[51]:(oe=i===`memory`?(0,$.jsx)(Z,{name:`database-2`,className:`h-4 w-4 text-[var(--surface-foreground)]`}):(0,$.jsx)(Z,{name:`bar-chart-box`,className:`h-4 w-4 text-[var(--surface-foreground)]`}),t[50]=i,t[51]=oe);let H;t[52]===r?H=t[53]:(H=r(`memoryDebugPanel.title`),t[52]=r,t[53]=H);let se;t[54]===H?se=t[55]:(se=(0,$.jsx)(`h3`,{className:`typography-ui-label font-semibold text-[var(--surface-foreground)]`,children:H}),t[54]=H,t[55]=se);let U;t[56]!==oe||t[57]!==se?(U=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[oe,se]}),t[56]=oe,t[57]=se,t[58]=U):U=t[58];let ce;t[59]===i?ce=t[60]:(ce=i===`streaming`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,onClick:ie,children:(0,$.jsx)(Z,{name:`file-copy`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,onClick:()=>{Fe(),b(ke()),S(G())},children:(0,$.jsx)(Z,{name:`refresh`,className:`h-3.5 w-3.5`})})]}):null,t[59]=i,t[60]=ce);let W;t[61]===n?W=t[62]:(W=n?(0,$.jsx)(Y,{size:`icon`,variant:`ghost`,className:`h-6 w-6`,onClick:n,children:(0,$.jsx)(Z,{name:`close`,className:`h-4 w-4`})}):null,t[61]=n,t[62]=W);let le;t[63]!==ce||t[64]!==W?(le=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[ce,W]}),t[63]=ce,t[64]=W,t[65]=le):le=t[65];let ue;t[66]!==U||t[67]!==le?(ue=(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[U,le]}),t[66]=U,t[67]=le,t[68]=ue):ue=t[68];let de;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(de={backgroundColor:`color-mix(in srgb, var(--surface-muted) 55%, transparent)`},t[69]=de):de=t[69];let fe=i===`memory`?`secondary`:`ghost`,pe;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(pe=()=>a(`memory`),t[70]=pe):pe=t[70];let me;t[71]===r?me=t[72]:(me=r(`memoryDebugPanel.tabs.memory`),t[71]=r,t[72]=me);let he;t[73]!==fe||t[74]!==me?(he=(0,$.jsx)(Y,{size:`sm`,variant:fe,className:`flex-1`,onClick:pe,children:me}),t[73]=fe,t[74]=me,t[75]=he):he=t[75];let ge=i===`streaming`?`secondary`:`ghost`,_e;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(_e=()=>a(`streaming`),t[76]=_e):_e=t[76];let ve;t[77]===r?ve=t[78]:(ve=r(`memoryDebugPanel.tabs.streaming`),t[77]=r,t[78]=ve);let ye;t[79]!==ge||t[80]!==ve?(ye=(0,$.jsx)(Y,{size:`sm`,variant:ge,className:`flex-1`,onClick:_e,children:ve}),t[79]=ge,t[80]=ve,t[81]=ye):ye=t[81];let be;t[82]!==he||t[83]!==ye?(be=(0,$.jsxs)(`div`,{className:`mb-3 flex gap-1 rounded-md p-1`,style:de,children:[he,ye]}),t[82]=he,t[83]=ye,t[84]=be):be=t[84];let xe;t[85]!==i||t[86]!==ne||t[87]!==o||t[88]!==c||t[89]!==_||t[90]!==ee||t[91]!==l||t[92]!==V||t[93]!==u||t[94]!==j||t[95]!==y||t[96]!==r||t[97]!==v||t[98]!==x?(xe=i===`memory`?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 typography-meta`,children:[(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.totalMessages`),value:ee.total}),(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.cachedSessions`),value:`${ne} / ${$r.MAX_SESSIONS}`}),(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.userMessages`),value:ee.user}),(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.assistantMessages`),value:ee.assistant})]}),(0,$.jsxs)(`div`,{className:`typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.viewportWindow`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.messagesValue`,{count:Xi()})})]}),(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.zombieTimeout`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.minutesValue`,{count:$r.ZOMBIE_TIMEOUT/1e3/60})})]}),(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.githubTotalRequests`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:v})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-[var(--interactive-border)] pt-2`,children:[(0,$.jsx)(`div`,{className:`mb-1 typography-meta font-semibold text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.section.sessionsInMemory`)}),(0,$.jsx)(es,{outerClassName:`max-h-48`,className:`space-y-1 pr-1`,children:V.map(e=>(0,$.jsxs)(`div`,{className:`typography-meta flex items-center justify-between rounded p-1.5`,style:{backgroundColor:e.isCurrent?`color-mix(in srgb, var(--interactive-selection) 22%, transparent)`:`color-mix(in srgb, var(--surface-muted) 35%, transparent)`},children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-[var(--surface-foreground)]`,children:e.title}),e.isStreaming?(0,$.jsx)(Z,{name:`pulse`,className:`h-3 w-3 animate-pulse text-[var(--status-info)]`}):null,e.isZombie?(0,$.jsx)(`span`,{className:`text-[var(--status-warning)]`,children:`!`}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.roleMsgsValue`,{assistant:e.assistantMessageCount,user:e.userMessageCount})}),(0,$.jsx)(`span`,{className:`font-mono text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.msgsValue`,{count:e.messageCount})}),e.backgroundCount>0?(0,$.jsxs)(`span`,{className:`text-[var(--status-info)]`,children:[`+`,e.backgroundCount]}):null]})]},e.id))})]}),(0,$.jsx)(`div`,{className:`flex gap-2 border-t border-[var(--interactive-border)] pt-2`,children:(0,$.jsxs)(Oa,{children:[(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(Y,{size:`sm`,variant:`outline`,className:`typography-meta`,onClick:()=>{u.map(ZS),Object.keys(_),V.map(QS),Object.fromEntries(l)},children:r(`memoryDebugPanel.actions.logState`)})}),(0,$.jsx)(Ea,{side:`top`,children:r(`memoryDebugPanel.tooltip.logCurrentState`)})]})})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.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:[(0,$.jsx)(`span`,{children:r(o===`copied`?`memoryDebugPanel.streaming.copy.copied`:o===`error`?`memoryDebugPanel.streaming.copy.failed`:`memoryDebugPanel.streaming.copy.hint`)}),(0,$.jsx)(Y,{size:`xs`,variant:`outline`,onClick:ie,children:r(`memoryDebugPanel.actions.copyJson`)})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.uiMetrics`),value:y.entries.length}),(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.vscodeMetrics`),value:x.entries.length}),(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.messageListRenders`),value:j.messageListRender}),(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.messageListStreamRenders`),value:j.messageListRenderStreaming}),(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.chatMessageRenders`),value:j.chatMessageRender}),(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.chatMessageStreamRenders`),value:j.chatMessageRenderStreaming}),(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.chatMessageStaticDuringStream`),value:j.chatMessageRenderStaticDuringStream}),(0,$.jsx)(RS,{label:r(`memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn`),value:j.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),(0,$.jsx)(zS,{title:r(`memoryDebugPanel.section.uiStreamingMetrics`),snapshot:y,emptyLabel:r(`memoryDebugPanel.section.noUiSamples`)}),x.entries.length>0?(0,$.jsx)(zS,{title:r(`memoryDebugPanel.section.vscodeBridgeMetrics`),snapshot:x,emptyLabel:r(`memoryDebugPanel.section.noVscodeSamples`)}):null]}),t[85]=i,t[86]=ne,t[87]=o,t[88]=c,t[89]=_,t[90]=ee,t[91]=l,t[92]=V,t[93]=u,t[94]=j,t[95]=y,t[96]=r,t[97]=v,t[98]=x,t[99]=xe):xe=t[99];let Se;return t[100]!==ue||t[101]!==be||t[102]!==xe?(Se=(0,$.jsxs)(mo,{className:`fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area`,style:ae,children:[ue,be,xe]}),t[100]=ue,t[101]=be,t[102]=xe,t[103]=Se):Se=t[103],Se};function VS(e,t){return e+t.count}function HS(e){return e.currentSessionId}function US(e){return e.sessionMemoryState}function WS(){return Ke()}function GS(e){return e.scope}function KS(e){return!!e}function qS(e){return e.totalRequestCount}function JS(){return ke()}function YS(){return G()}function XS(e,t){return t.lastAccessed-e.lastAccessed}function ZS(e){return{id:e.id,title:e.title}}function QS(e){return{id:e.id,title:e.title,total:e.messageCount,user:e.userMessageCount,assistant:e.assistantMessageCount}}var $S=()=>{let{isMobile:e,closeActiveContextPanelTab:t}=q.getState();if(e)return;let n=Bo();n&&t(n)||R()&&P(`desktop_close_current_window`).catch(e=>{console.warn(`[menu-actions] failed to close current window`,e)})},eC=()=>{if(typeof document>`u`)return``;let e=document.activeElement;if(e instanceof HTMLTextAreaElement)return e.value.slice(e.selectionStart??0,e.selectionEnd??0);if(e instanceof HTMLInputElement){let t=e.type?.toLowerCase()??`text`;if([`text`,`search`,`url`,`tel`,`password`].includes(t))return e.value.slice(e.selectionStart??0,e.selectionEnd??0)}return e instanceof HTMLElement&&e.isContentEditable?e.ownerDocument.defaultView?.getSelection?.()?.toString()??``:``},tC=async()=>{let e=eC()||window.getSelection()?.toString()||``;if(!e.trim())return!1;try{if(typeof navigator<`u`&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}return document.execCommand(`copy`)},nC=`yuri:menu-action`,rC=`yuri:check-for-updates`,iC=e=>typeof e?.listen==`function`?`bridge`:`dom`,aC=e=>{let t=cr(e=>e.openNewSessionDraft),n=q(e=>e.toggleCommandPalette),r=q(e=>e.setCommandPaletteOpen),i=q(e=>e.toggleHelpDialog),a=q(e=>e.toggleSidebar),o=q(e=>e.setSessionSwitcherOpen),s=q(e=>e.setActiveMainTab),c=q(e=>e.setSettingsDialogOpen),l=q(e=>e.setSettingsPage),u=q(e=>e.setAboutDialogOpen),d=q(e=>e.toggleContextPanel),f=q(e=>e.setRightSidebarOpen),p=q(e=>e.setRightSidebarTab),m=q(e=>e.toggleBottomTerminal),h=q(e=>e.setBottomTerminalExpanded),g=As(e=>e.checkForUpdates),{setThemeMode:_}=zr(),{t:v}=Zt(),y=Q.useRef(!1),b=typeof window>`u`?null:window.__YURI_DESKTOP__,x=iC(b),S=Q.useCallback(()=>{y.current||(y.current=!0,g().then(()=>{let{available:e,error:t}=As.getState();if(t){J.error(v(`sessions.sidebar.updateCheck.errorTitle`),{description:t});return}e||J.success(v(`sessions.sidebar.updateCheck.latestVersion`))}).finally(()=>{y.current=!1}))},[g,v]),C=Q.useCallback(()=>{Kn.requestDirectoryDialog()},[]),w=Q.useCallback(e=>{sa(e,cr.getState().currentSessionId,e=>{s(`chat`),o(!1),cr.getState().setCurrentSession(e.sessionId,e.directory)})},[s,o]),T=Q.useCallback(e=>{let{activeProjectId:t,projects:n,setActiveProject:r}=mn.getState();if(n.length===0)return;let i=n.findIndex(e=>e.id===t),a=e>0?0:n.length-1;i>=0&&(a=(i+e+n.length)%n.length);let o=n[a];o&&r(o.id)},[]),E=Q.useCallback(g=>{switch(g){case`about`:u(!0);break;case`settings`:c(!0);break;case`switch-instance`:l(`remote-instances`),c(!0);break;case`command-palette`:n();break;case`quick-open`:r(!0);break;case`new-session`:s(`chat`),o(!1),t();break;case`new-worktree-session`:s(`chat`),o(!1),ha();break;case`change-workspace`:C();break;case`close-tab-or-window`:$S();break;case`toggle-right-sidebar`:{let e=Bo();e&&d(e);break}case`open-right-sidebar-git`:{let e=Bo();e&&q.getState().openContextPanel(e),f(!0),p(`git`);break}case`open-right-sidebar-files`:{let e=Bo();e&&q.getState().openContextPanel(e),f(!0),p(`files`);break}case`toggle-terminal`:m();break;case`toggle-terminal-expanded`:h(!q.getState().isBottomTerminalExpanded);break;case`copy`:{let e=new Event(`yuri:copy`,{cancelable:!0});window.dispatchEvent(e)&&tC();break}case`theme-light`:_(`light`);break;case`theme-dark`:_(`dark`);break;case`theme-system`:_(`system`);break;case`toggle-sidebar`:a();break;case`toggle-memory-debug`:e?.();break;case`zoom-in`:Ui();break;case`zoom-out`:Wi();break;case`zoom-reset`:ma();break;case`go-back`:Pe.getState().goBack();break;case`go-forward`:Pe.getState().goForward();break;case`previous-session`:w(-1);break;case`next-session`:w(1);break;case`previous-project`:T(-1);break;case`next-project`:T(1);break;case`help-dialog`:i();break;case`download-logs`:xa().catch(()=>{J.error(`Failed to collect OpenCode status`)})}},[C,T,w,e,t,u,s,o,r,c,l,h,f,p,_,m,n,i,d,a]);Q.useEffect(()=>{if(x!==`dom`)return;let e=e=>{let t=e.detail;t&&E(t)},t=()=>{S()};return window.addEventListener(nC,e),window.addEventListener(rC,t),()=>{window.removeEventListener(nC,e),window.removeEventListener(rC,t)}},[E,S,x]),Q.useEffect(()=>{if(x!==`bridge`)return;let e=b?.listen;if(typeof e!=`function`)return;let t=null,n=null;return e(`yuri:menu-action`,e=>{let t=e?.payload;typeof t==`string`&&E(t)}).then(e=>{t=e}).catch(()=>{}),e(`yuri:check-for-updates`,S).then(e=>{n=e}).catch(()=>{}),()=>{(async()=>{try{let e=t?.();e instanceof Promise&&await e}catch{}try{let e=n?.();e instanceof Promise&&await e}catch{}})()}},[b,E,S,x])},oC=(e,t)=>e<t?-1:+(e>t),sC=e=>JSON.stringify([...e.entries()].map(([e,t])=>[e,[...new Set(t)].sort(oC)]).sort(([e],[t])=>oC(e,t)));async function cC({targets:e,isReady:t,fetchStatus:n,applySnapshot:r,concurrency:i=2,isDisposed:a=()=>!1}){if(!t()||a())return;let o=[...e.entries()],s=0,c=Math.min(Math.max(1,i),o.length),l=async()=>{for(;s<o.length&&t()&&!a();){let e=o[s];if(s+=1,!e)return;let[t,i]=e,c=await n(t);c===null||a()||r(t,c,i)}};await Promise.all(Array.from({length:c},()=>l()))}var lC=`yuri:tray-action`,uC=3e4,dC=120,fC=20,pC=()=>{if(typeof window>`u`)return!1;let e=window.__YURI_PLATFORM__;return e===`darwin`||e===`win32`},mC=e=>{let t=typeof e.permission==`string`?e.permission:`Permission`,n=Array.isArray(e.patterns)?e.patterns.find(e=>typeof e==`string`&&e.trim()):``;return n?`${t}: ${n}`:t},hC=e=>{let t=Array.isArray(e.questions)?e.questions[0]:void 0;return t?.header||t?.question||`Question`},gC=e=>In(e),_C=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t},vC=(e,t,n,r)=>{if(!e)return``;let i=_n(t,n,e),a=_C(i?i.path:e),o=Cn(e),s=o&&r.get(o)||``;if(!s){for(let[e,t]of Eo.getState().directories)if(Cn(e)===o){s=t.status?.current??``;break}}if(!s)for(let e of n.values()){let t=e.find(e=>Cn(e.path)===o);if(t?.branch){s=t.branch;break}}return s?`${a} · ${s}`:a},yC=()=>{let{results:e,dropdownProviderIds:t,displayMode:n}=_s.getState(),r=n===`remaining`?`remaining`:`usage`;if(!t.length)return{mode:r,groups:[]};let i=new Map(e.map(e=>[e?.providerId,e])),a=[];for(let n of Fs(e)){if(!t.includes(n.id))continue;let e=i.get(n.id);if(!e||e.configured!==!0)continue;let o=[];for(let[t,n]of Object.entries(e.usage?.windows??{})){let e=r===`remaining`?n.remainingPercent:n.usedPercent;o.push({label:ka(n.label??t),value:La(n.valueLabel,e)})}let s=!e.ok&&e.error?e.error:o.length===0?`No rate limits reported`:null;a.push({provider:n.name,rows:o,status:s})}return{mode:r,groups:a}},bC=async()=>{try{if(S())return`Local Yuri`;let e=window.__YURI_LOCAL_ORIGIN__||window.location.origin,t=m();if(t&&H(t,e))return`Local Yuri`;let n=(await U()).hosts.find(e=>t?H(t,oe(e)):!1);return n?.label?.trim()?ce(n.label.trim()):`Instance`}catch{return``}},xC=()=>{let e=new Map,t=new Map,n=[],r=new Map,i;try{i=rt()}catch{return{statusById:e,branchByDirectory:t,approvals:n,titleById:r}}for(let[a,o]of i.children.entries()){let i=o.getState(),s=typeof i.vcs?.branch==`string`?i.vcs.branch:typeof i.vcs?.branch?.current==`string`?i.vcs.branch.current:``;s&&t.set(Cn(a)??a,s);for(let e of i.session)!e?.id||!e.title||r.set(e.id,e.title);for(let[t,n]of Object.entries(i.session_status??{})){let r=n?.type,i=r===`busy`?`busy`:r===`retry`?`retry`:`idle`,a=e.get(t);(!a||a===`idle`)&&e.set(t,i)}for(let[e,t]of Object.entries(i.permission??{}))for(let r of t??[]){if(!r?.id)continue;let t=r.sessionID||e;n.push({kind:`permission`,id:r.id,sessionId:t,sessionTitle:``,label:mC(r),directory:a})}for(let[e,t]of Object.entries(i.question??{}))for(let r of t??[]){if(!r?.id)continue;let t=r.sessionID||e;n.push({kind:`question`,id:r.id,sessionId:t,sessionTitle:``,label:hC(r),directory:a})}}return{statusById:e,branchByDirectory:t,approvals:n,titleById:r}},SC=()=>{let e=wr.getState().activeSessions,t=new Set;e.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>gC(t)-gC(e)).slice(0,fC).forEach(e=>{let n=Xn(e);n&&t.add(n)});let n=new Map;for(let r of e){if(!r?.id)continue;let e=Xn(r);if(!e||!t.has(e))continue;let i=n.get(e)??[];i.push(r.id),n.set(e,i)}return n},CC=e=>{let t=xC(),n=Sn.getState().index.session,r=wr.getState().activeSessions,i=new Map(t.titleById),a=new Map;for(let e of r)if(e?.id&&(e.title&&i.set(e.id,e.title),e.parentID)){let t=a.get(e.parentID)??[];t.push(e.id),a.set(e.parentID,t)}let o=e=>{let t=[],n=[...a.get(e)??[]],r=new Set;for(;n.length;){let e=n.pop();r.has(e)||(r.add(e),t.push(e),n.push(...a.get(e)??[]))}return t},s=Qn.getState().statusById,c=e=>{let n=t.statusById.get(e);return n&&n!==`idle`?n:s.get(e)?.status??n??`idle`},l=e=>{let t=e.map(e=>c(e));return t.includes(`busy`)?`busy`:t.includes(`retry`)?`retry`:`idle`},u=mn.getState().projects,d=cr.getState().availableWorktreesByProject,f=r.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>gC(t)-gC(e)).slice(0,fC).map(e=>{let r=[e.id,...o(e.id)],i=Xn(e)??``;return{id:e.id,title:e.title||`Untitled session`,status:l(r),branch:i?t.branchByDirectory.get(i)??``:``,unseen:n.unseenCount[e.id]??0,hasError:n.unseenHasError[e.id]??!1,directory:i,subtitle:vC(i,u,d,t.branchByDirectory)}}),p=t.approvals.map(e=>({...e,sessionTitle:i.get(e.sessionId)||``})),m=q.getState(),h=0;if(m.dockBadgeEnabled)for(let e of r)!e?.id||e.parentID||(n.unseenCount[e.id]??0)>0&&(h+=1);return{sessions:f,approvals:p,instanceName:e,usage:yC(),dockBadgeCount:h}},wC=()=>{Q.useEffect(()=>{if(!pC()||!R())return;let e=!1,t=``,n=null,r=``,i=()=>{if(e)return;let n=CC(r),i=JSON.stringify(n);i!==t&&(t=i,P(`desktop_tray_update`,n))};bC().then(t=>{e||(r=t,i())});let a=null,o=``,s=()=>{let e=Ln.getState();return e.isConnected&&e.connectionPhase===`connected`},c=()=>{if(a)return a;let t=SC();return o=sC(t),a=cC({targets:t,isReady:s,concurrency:2,isDisposed:()=>e,fetchStatus:async()=>{try{let e=await et.getSdkClient().session.active();if(!e||typeof e!=`object`||Array.isArray(e))return null;let t={};for(let[n,r]of Object.entries(e))r?.type===`running`&&(t[n]={type:`busy`});return t}catch{return null}},applySnapshot:(e,t,n)=>{ir(e,t,[...n])}}).finally(()=>{a=null;let t=SC();!e&&s()&&sC(t)!==o&&c()}),a},l=()=>{e||n!==null||(n=window.setTimeout(()=>{n=null,i()},dC))},u=new Map,d=()=>{if(e)return;let t;try{t=rt()}catch{return}let n=new Set;for(let[e,r]of t.children.entries())n.add(e),u.has(e)||u.set(e,r.subscribe(()=>l()));for(let[e,t]of u)n.has(e)||(t(),u.delete(e))},f=null;try{f=rt().subscribeRegistry(()=>{d(),l()})}catch{}d();let p=Sn.subscribe(()=>l()),m=wr.subscribe(()=>{l(),s()&&sC(SC())!==o&&c()}),h=mn.subscribe(()=>l()),g=cr.subscribe(()=>l()),_=Eo.subscribe(()=>l()),v=q.subscribe(()=>l()),y=Qn.subscribe(()=>l()),b=s(),x=Ln.subscribe(()=>{let e=s();e&&!b&&c(),b=e});b&&c();let S=_s.subscribe(()=>l());_s.getState().loadSettings().then(()=>{if(e)return;let{dropdownProviderIds:t,results:n}=_s.getState();t.length>0&&t.some(e=>!n.some(t=>t?.providerId===e))&&_s.getState().fetchAllQuotas()});let C=window.setInterval(()=>{let e=_s.getState();e.autoRefresh&&e.dropdownProviderIds.length>0&&e.fetchAllQuotas()},Math.max(3e4,_s.getState().refreshIntervalMs||6e4)),w=window.setInterval(()=>{d(),i()},uC);return i(),()=>{e=!0,n!==null&&window.clearTimeout(n),window.clearInterval(w),window.clearInterval(C),p(),m(),h(),g(),_(),v(),y(),x(),S(),f?.();for(let e of u.values())e();u.clear()}},[]),Q.useEffect(()=>{if(!pC()||typeof window>`u`)return;let e=window.__YURI_DESKTOP__?.listen;if(typeof e!=`function`)return;let t=e=>{e.type===`respond-permission`&&fr(e.sessionId,e.id,e.response).catch(()=>{J.error(`Failed to respond to permission request`)})},n=null;return e(lC,e=>{let n=e?.payload;!n||typeof n!=`object`||typeof n.type!=`string`||t(n)}).then(e=>{n=e}).catch(()=>{}),()=>{try{let e=n?.();e instanceof Promise&&e.catch(()=>{})}catch{}}},[])},TC=`/api/notifications/stream`,EC=()=>typeof document>`u`||document.visibilityState===`visible`&&document.hasFocus(),DC=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=t.properties&&typeof t.properties==`object`?t.properties:null;return t.type!==`yuri: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,requireHidden:n.requireHidden===!0||n.requireHidden!==!1&&void 0}},OC=e=>{let t=(0,du.c)(3),n=e?.enabled??!0,r,i;t[0]===n?(r=t[1],i=t[2]):(r=()=>{if(!n||v()||!re()||typeof window>`u`||typeof EventSource>`u`)return;let e=new EventSource(c().sse(TC));return e.onmessage=kC,()=>{e.close()}},i=[n],t[0]=n,t[1]=r,t[2]=i),Q.useEffect(r,i)};function kC(e){let t;try{t=JSON.parse(e.data)}catch{return}let n=q.getState();if(!n.nativeNotificationsEnabled)return;let r=DC(t);r&&((r.requireHidden??n.notificationMode!==`always`)&&EC()||ae()?.notifications?.notifyAgentCompletion(r))}var AC=`pwa-install-toast-shown`,jC=`pwa-install-toast-dismissed`,MC=()=>{let e=(0,du.c)(6),{browserTab:t}=Gs(),{t:n}=Zt(),r=Q.useRef(n),i,a;e[0]===n?(i=e[1],a=e[2]):(i=()=>{r.current=n},a=[n],e[0]=n,e[1]=i,e[2]=a),Q.useEffect(i,a);let o,s;e[3]===t?(o=e[4],s=e[5]):(o=()=>{if(typeof window>`u`||!re()||!t)return;let e=null,n=null,i=()=>{n!==null&&(J.dismiss(n),n=null)},a=async()=>{if(!e)return;let t=e;e=null,i(),await t.prompt();let{outcome:n}=await t.userChoice;n===`accepted`&&J.success(r.current(`pwa.installPrompt.started`))},o=t=>{let o=t;if(typeof o.prompt!=`function`)return;o.preventDefault(),e=o;let s=Be(),c=Ve();fc({dismissed:s.getItem(jC),sessionShown:c.getItem(AC),hasActiveToast:n!==null})&&(c.setItem(AC,`true`),n=J.info(r.current(`pwa.installPrompt.description`),{duration:1/0,action:{label:r.current(`pwa.installPrompt.action`),onClick:()=>{a()}},cancel:{label:r.current(`pwa.installPrompt.dismiss`),onClick:()=>{Be().setItem(jC,`true`),i()}}}))},s=()=>{e=null,i(),J.success(r.current(`pwa.installPrompt.installed`))};return window.addEventListener(`beforeinstallprompt`,o),window.addEventListener(`appinstalled`,s),()=>{i(),window.removeEventListener(`beforeinstallprompt`,o),window.removeEventListener(`appinstalled`,s)}},s=[t],e[3]=t,e[4]=o,e[5]=s),Q.useEffect(o,s)},NC=0;function PC(e){let t=typeof e?.sessionId==`string`?e.sessionId.trim():``;if(!t)return;let n=++NC,r=typeof e?.directory==`string`&&e.directory.trim().length>0?e.directory.trim():null;if(q.getState().setActiveMainTab(`chat`),e.hostId||e.hubId||e.instanceId){if(!e.hostId||!e.hubId||!r)return;Pt(async()=>{let{applyRemoteProjectRoute:e}=await import(`./navigation-Bart975B.js`).then(e=>e.n);return{applyRemoteProjectRoute:e}},__vite__mapDeps([164,1,3,2,13,4,5,6,7,8,9,10,12,11,14,15,16,17,18,19,20,42,22,43,23,24,44,45,46,47,21,25,48,49,37,38,39,40,41,50,51,52,53,54,55,56,57])).then(({applyRemoteProjectRoute:i})=>{if(n===NC)return i({sessionId:t,directory:r,hostId:e.hostId,hubId:e.hubId,...e.instanceId?{instanceId:e.instanceId}:{},isNewSession:!1},()=>n===NC)}).catch(()=>console.warn(`[remote-session] Notification navigation failed`));return}cr.getState().setCurrentSession(t,r)}var FC=({open:e,onOpenChange:t})=>{let{t:n}=Zt(),[r,i]=Q.useState(null),[a,o]=Q.useState(null);Q.useEffect(()=>{e&&(async()=>{try{let e=await h(`/api/system/info`);if(e.ok){let t=await e.json();if(typeof t.yuriVersion==`string`&&t.yuriVersion.trim()){i(t.yuriVersion);return}}}catch{}i(await Jt())})()},[e]),Q.useEffect(()=>{if(!e)return;let t=!1;return(async()=>{try{let e=await h(`/api/opencode/upgrade-status`,{headers:{Accept:`application/json`}});if(!e.ok)return;let n=await e.json().catch(()=>null),r=typeof n?.currentVersion==`string`?n.currentVersion.trim():``;!t&&r&&o(r)}catch{}})(),()=>{t=!0}},[e]);let s=r;return(0,$.jsx)(Jr,{open:e,onOpenChange:t,children:(0,$.jsx)(Gr,{className:`max-w-xs p-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[(0,$.jsx)(fo,{width:48,height:48}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Yuri`}),(0,$.jsxs)(`div`,{className:`space-y-0.5 typography-meta text-muted-foreground`,children:[s&&(0,$.jsx)(`p`,{children:n(`aboutDialog.yuriVersionLabel`,{version:s})}),a&&(0,$.jsx)(`p`,{children:n(`aboutDialog.openCodeVersionLabel`,{version:a})})]})]}),(0,$.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,$.jsxs)(`a`,{href:`https://github.com/yee94/yuri`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors`,children:[(0,$.jsx)(Z,{name:`github-fill`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`GitHub`})]})}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/60`,children:n(`aboutDialog.footerNote`)})]})})})},IC=(e,t)=>{let n=e.get(t);return typeof n==`string`&&n.trim()||null},LC=(e,t)=>{let n=e instanceof Error?e.message:t;return/oauth state required/i.test(n)?`Authorization session expired or was cleared during reload. Return to Yuri and click Authorize again.`:n},RC=()=>{let e=ks(e=>e.completeAuth),[t,n]=Q.useState(`working`),[r,i]=Q.useState(`Completing MCP authorization...`);return Q.useEffect(()=>{if(typeof window>`u`){n(`error`),i(`Browser context unavailable.`);return}let t=new URLSearchParams(window.location.search),r=IC(t,`code`),a=qs(t),o=Ds(t),s=IC(t,`error`),c=IC(t,`error_description`);if(s){o&&h(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`error`),i(c??s);return}(async()=>{try{if(!r)throw Error(`Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into Yuri manually.`);let t=a;if(!t&&o){let e=await h(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`);if(e.ok){let n=await e.json().catch(()=>null);n?.name?.trim()&&(t={name:n.name.trim(),directory:typeof n.directory==`string`&&n.directory.trim()?n.directory.trim():null})}}if(!t?.name)throw Error(`Authorization session details were not available. Start authorization again from MCP Settings or paste the returned code into Yuri manually.`);await e(t.name,r,t.directory),o&&await h(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`success`),i(`Authorization completed. You can close this tab and return to Yuri.`)}catch(e){o&&await h(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`error`),i(LC(e,`Failed to complete MCP authorization.`))}})()},[e]),(0,$.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-background px-6 py-12 text-foreground`,children:(0,$.jsxs)(`div`,{className:`w-full max-w-xl rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-8 shadow-sm dark:shadow-none`,children:[(0,$.jsxs)(`div`,{className:`space-y-3 text-center`,children:[(0,$.jsx)(`div`,{className:t===`error`?`text-[var(--status-error)]`:t===`success`?`text-[var(--status-success)]`:`text-[var(--status-info)]`,children:(0,$.jsx)(`h1`,{className:`typography-hero font-semibold`,children:t===`working`?`Completing Authorization`:t===`success`?`Authorization Complete`:`Authorization Failed`})}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:r})]}),t!==`working`&&(0,$.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,$.jsx)(Y,{type:`button`,onClick:()=>{typeof window>`u`||window.location.replace(`/`)},children:`Return to Yuri`})})]})})},zC=()=>{let e=wr(e=>e.startupSyncProgress.active),t=wr(e=>e.startupSyncProgress.phase),n=wr(e=>e.startupSyncProgress.completed),r=wr(e=>e.startupSyncProgress.total),{locale:i,t:a}=Zt(),[o,s]=Q.useState(!0),c=Wt(i).startingApi;Q.useEffect(()=>{let e=!1,t=async()=>{try{let t=await(await h(`/health`,{signal:AbortSignal.timeout(4e3)})).json().catch(()=>null);if(e)return;let n=t?.openCodeStarting===!0||t?.isOpenCodeReady!==!0&&!t?.lastOpenCodeError;s(n)}catch{e||s(!0)}};t();let n=window.setInterval(()=>{t()},750);return()=>{e=!0,window.clearInterval(n)}},[]);let l=r>0?Math.round(n/r*100):0,u=t===`restoring`?a(`common.loading`):a(`sessions.startupSync.progress`,{completed:n,total:r});return Q.useLayoutEffect(()=>{let t=document.getElementById(`startup-session-progress`),i=document.getElementById(`startup-session-progress-track`),s=document.getElementById(`startup-session-progress-fill`),d=document.getElementById(`startup-session-progress-text`);if(!(!t||!i||!s||!d)){if(e){t.hidden=!1,s.style.width=`${l}%`,i.setAttribute(`aria-label`,a(`sessions.startupSync.title`)),i.setAttribute(`aria-valuemax`,String(Math.max(r,1))),i.setAttribute(`aria-valuenow`,String(n)),i.setAttribute(`aria-valuetext`,u),d.textContent=u;return}if(o){t.hidden=!1,s.style.width=`30%`,i.setAttribute(`aria-label`,c),i.setAttribute(`aria-valuetext`,c),d.textContent=c;return}t.hidden=!0}},[e,n,o,l,u,c,a,r]),null},BC=(e,t,n,r=350)=>n?Math.max(0,r-Math.max(0,t-e)):null;function VC(e){let t=(0,du.c)(21),{transition:n,ready:r}=e,{t:i}=Zt(),a=Ha(!0),[o,s]=Q.useState(0),c=n.epoch>o,l=a||c,u,d;if(t[0]!==c||t[1]!==a||t[2]!==r||t[3]!==n.epoch||t[4]!==n.startedAt?(u=()=>{if(!c||a)return;let e=BC(n.startedAt,Date.now(),r);if(e===null)return;let t=window.setTimeout(()=>{s(e=>Math.max(e,n.epoch))},e);return()=>window.clearTimeout(t)},d=[c,a,r,n.epoch,n.startedAt],t[0]=c,t[1]=a,t[2]=r,t[3]=n.epoch,t[4]=n.startedAt,t[5]=u,t[6]=d):(u=t[5],d=t[6]),Q.useEffect(u,d),!l)return null;let f;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 opacity-70`,"aria-hidden":`true`,children:[(0,$.jsx)(`div`,{className:`absolute left-1/2 top-1/2 size-[28rem] -translate-x-1/2 -translate-y-1/2 rounded-full border border-[var(--interactive-border)]/40`}),(0,$.jsx)(`div`,{className:`absolute left-1/2 top-1/2 size-72 -translate-x-1/2 -translate-y-1/2 rounded-full bg-[var(--interactive-selection)]/10 blur-3xl`})]}),t[7]=f):f=t[7];let p;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`div`,{className:`mb-7 flex size-28 items-center justify-center rounded-[2rem] border border-[var(--interactive-border)]/60 bg-[var(--surface-elevated)]/75 shadow-2xl shadow-background/40`,children:(0,$.jsx)(fo,{width:76,height:76,isAnimated:!0})}),t[8]=p):p=t[8];let m;t[9]===i?m=t[10]:(m=i(`desktopHostSwitcher.transition.title`),t[9]=i,t[10]=m);let h;t[11]===m?h=t[12]:(h=(0,$.jsx)(`h1`,{className:`typography-title text-foreground`,children:m}),t[11]=m,t[12]=h);let g;t[13]===i?g=t[14]:(g=i(`desktopHostSwitcher.transition.description`),t[13]=i,t[14]=g);let _;t[15]===g?_=t[16]:(_=(0,$.jsx)(`p`,{className:`mt-2 typography-body text-muted-foreground`,children:g}),t[15]=g,t[16]=_);let v;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`div`,{className:`mt-7 h-1 w-28 overflow-hidden rounded-full bg-[var(--surface-muted)]`,"aria-hidden":`true`,children:(0,$.jsx)(`div`,{className:`h-full w-1/2 animate-pulse rounded-full bg-[var(--status-info)] motion-reduce:animate-none`})}),t[17]=v):v=t[17];let y;return t[18]!==h||t[19]!==_?(y=(0,$.jsxs)(`div`,{className:`fixed inset-0 z-[9998] flex items-center justify-center overflow-hidden bg-background/95 px-6 backdrop-blur-xl`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:[f,(0,$.jsxs)(`div`,{className:`relative flex max-w-md animate-in flex-col items-center text-center fade-in zoom-in-95 duration-300 motion-reduce:animate-none`,children:[p,h,_,v]})]}),t[18]=h,t[19]=_,t[20]=y):y=t[20],y}var HC=So(()=>Pt(()=>import(`./OnboardingScreen-6UdQ9pI2.js`).then(e=>({default:e.OnboardingScreen})),__vite__mapDeps([165,1,4,2,5,3,6,7,8,97,9,43,22,23,20,24,44,45,46,47,13,10,12,11,14,15,16,17,18,19,21,25,48,37,38,39,40,41,42,49,50,51,52,53,54,55,56,57,60,61,62,109,118,58]))),UC=36e5,WC=12e5,GC=()=>{let e=(0,du.c)(3),t=q(QC),n=q($C),r;return e[0]!==t||e[1]!==n?(r=(0,$.jsx)(FC,{open:t,onOpenChange:n}),e[0]=t,e[1]=n,e[2]=r):r=e[2],r},KC=e=>{let t=(0,du.c)(21),{onRetry:n,isRetrying:r}=e,{t:i}=Zt(),a;t[0]===i?a=t[1]:(a=i(`startup.initRecovery.title`),t[0]=i,t[1]=a);let o;t[2]===a?o=t[3]:(o=(0,$.jsx)(`h1`,{className:`typography-title text-foreground`,children:a}),t[2]=a,t[3]=o);let s;t[4]===i?s=t[5]:(s=i(`startup.initRecovery.description`),t[4]=i,t[5]=s);let c;t[6]===s?c=t[7]:(c=(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:s}),t[6]=s,t[7]=c);let l;t[8]!==o||t[9]!==c?(l=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o,c]}),t[8]=o,t[9]=c,t[10]=l):l=t[10];let u;t[11]!==r||t[12]!==i?(u=i(r?`startup.initRecovery.retrying`:`startup.initRecovery.retry`),t[11]=r,t[12]=i,t[13]=u):u=t[13];let d;t[14]!==r||t[15]!==n||t[16]!==u?(d=(0,$.jsx)(Y,{type:`button`,onClick:n,disabled:r,children:u}),t[14]=r,t[15]=n,t[16]=u,t[17]=d):d=t[17];let f;return t[18]!==l||t[19]!==d?(f=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center bg-background px-6 text-foreground`,children:(0,$.jsxs)(`div`,{className:`flex max-w-md flex-col items-center gap-4 text-center`,children:[l,d]})}),t[18]=l,t[19]=d,t[20]=f):f=t[20],f},qC=e=>e?e.replace(/\\/g,`/`).replace(/\/+$/g,``):``,JC=()=>{if(typeof window>`u`||!yo())return null;let e=new URLSearchParams(window.location.search),t=e.get(`sessionId`),n=typeof t==`string`?t.trim():``;if(!n)return null;let r=e.get(`directory`);return{sessionId:n,directory:typeof r==`string`&&r.trim().length>0?r.trim():null,readOnly:e.get(`readOnly`)===`1`||e.get(`readOnly`)===`true`}},YC=()=>typeof window>`u`?!1:window.location.pathname===vs,XC=e=>{let t=(0,du.c)(22),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=e,a=Pe(ew),o=cr(tw),s=cr(nw),c=_i(),l=Q.useRef(null),u;t[0]===n.directory?u=t[1]:(u=qC(n.directory),t[0]=n.directory,t[1]=u);let d=u,f;t[2]===a?f=t[3]:(f=qC(a),t[2]=a,t[3]=f);let p=f,m,h;if(t[4]!==p||t[5]!==o||t[6]!==n.directory||t[7]!==n.sessionId||t[8]!==d||t[9]!==r||t[10]!==s||t[11]!==c?(m=()=>{if(r||d&&p!==d)return;let e=`${d}\n${n.sessionId}`;l.current===e&&o||(l.current=e,s(n.sessionId,n.directory),c.ensureSessionRenderable(n.sessionId,!0))},h=[p,o,n.directory,n.sessionId,d,r,s,c],t[4]=p,t[5]=o,t[6]=n.directory,t[7]=n.sessionId,t[8]=d,t[9]=r,t[10]=s,t[11]=c,t[12]=m,t[13]=h):(m=t[12],h=t[13]),Q.useEffect(m,h),d&&p!==d)return null;let g;t[14]===i?g=t[15]:(g=(0,$.jsx)(Ji,{embeddedBackgroundWorkEnabled:i}),t[14]=i,t[15]=g);let _;t[16]===n.readOnly?_=t[17]:(_=(0,$.jsx)(Ec,{readOnly:n.readOnly}),t[16]=n.readOnly,t[17]=_);let v;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(ui,{}),t[18]=v):v=t[18];let y;return t[19]!==g||t[20]!==_?(y=(0,$.jsxs)($.Fragment,{children:[g,_,v]}),t[19]=g,t[20]=_,t[21]=y):y=t[21],y};function ZC({apis:e}){Q.useEffect(()=>{Je(`App:mounted`),qe()},[]),Q.useEffect(()=>xn(),[]);let t=Ln(e=>e.initializeApp),n=Ln(e=>e.isInitialized),r=Ln(e=>e.isConnected),i=cr(e=>e.error),a=cr(e=>e.clearError),o=cr(e=>!(e.newSessionDraft?.open&&e.currentSessionId===null)),c=Pe(e=>e.currentDirectory),l=Pe(e=>e.setDirectory),u=Pe(e=>e.isSwitchingDirectory),[f,p]=Q.useState(!1),m=Ps(e=>e.refreshStatus),[h,g]=Q.useState(()=>e.runtime.isVSCode),[_,y]=Q.useState(!1),[C,w]=Q.useState(!1),[T,E]=Q.useState(0),[O,k]=Q.useState(0),[M,N]=Q.useState({epoch:0,startedAt:0}),[F,I]=Q.useState(!1),R=Q.useRef(!1),z=q(e=>e.wideChatLayoutEnabled),ee=q(e=>e.mobileKeyboardMode),V=Q.useMemo(()=>v(),[]),ne=wr(e=>e.hasCachedSessionIndex),re=wr(e=>e.hasHydratedSessionIndex),[ae,oe]=Q.useState(()=>A()),[H,se]=Q.useState(()=>{let e=L();return e===null?null:te({isDesktopShell:!0,bootOutcome:e})}),U=Q.useRef(!1),ce=Q.useMemo(()=>JC(),[]),W=!ce||_,le=Q.useMemo(()=>YC(),[]);Q.useEffect(()=>(Ae(f),()=>{Ae(!1)}),[f]),Q.useEffect(()=>{Rt(ee)},[ee]),Q.useEffect(()=>{g(e.runtime.isVSCode)},[e.runtime.isVSCode]),Q.useEffect(()=>{let e=Pi(e=>{d(e)&&(V&&N(e=>({epoch:e.epoch+1,startedAt:Date.now()})),dl(e),k(e=>e+1),w(!1),E(e=>e+1))}),t=s(t=>e.schedule(t));return()=>{t(),e.cancel()}},[V]),Q.useEffect(()=>(document.documentElement.classList.toggle(`wide-chat-layout`,z),()=>{document.documentElement.classList.remove(`wide-chat-layout`)}),[z]),Q.useEffect(()=>(ie(e),()=>ie(null)),[e]),Q.useEffect(()=>{if(ce)return;let t=!1;return hr().then(()=>{t||m(e.github,{force:!0})}),()=>{t=!0}},[e.github,ce,m]),fa();let ue=ae===`valid`,de=H?.screen===`main`,[fe,pe]=Q.useState(!1);Q.useEffect(()=>{if(!W||!B({isDesktopShell:V,isInitialized:V&&de?ne||n&&re:n,bootOutcomeKnown:ue,bootViewIsMain:de}))return;let e,t=setTimeout(()=>{let t=document.getElementById(`initial-loading`);t?(t.classList.add(`fade-out`),e=setTimeout(()=>{t.remove(),pe(!0)},300)):pe(!0)},150);return()=>{clearTimeout(t),e&&clearTimeout(e)}},[W,V,n,ue,de,ne,re]),Q.useEffect(()=>{if(!V||ae!==`malformed`)return;let e=document.getElementById(`initial-loading`);e&&(e.textContent=`Desktop startup failed — please restart the app.`)},[V,ae]),Q.useEffect(()=>{if(!W||V)return;let e,t=setTimeout(()=>{let t=document.getElementById(`initial-loading`);t&&!n&&(t.classList.add(`fade-out`),e=setTimeout(()=>{t.remove()},300))},5e3);return()=>{clearTimeout(t),e&&clearTimeout(e)}},[W,V,n]),Q.useEffect(()=>{if(!W||h)return;let e=!1;return hr().then(()=>{if(!e)return t()}),()=>{e=!0}},[W,t,h]),Q.useEffect(()=>{if(!W||h||n)return;let e=!0,t,r=0,i=1e3,a=async()=>{if(!e)return;if(r>=10){w(!0);return}let n=Ln.getState();if(n.isInitialized){w(!1);return}if(r+=1,await hr(),!e)return;await n.initializeApp();let o=Ln.getState();if(!e)return;if(o.isInitialized){w(!1);return}if(r>=10){w(!0);return}let s=Math.min(i*2**(r-1),16e3);t=setTimeout(a,s)};return t=setTimeout(a,i),()=>{e=!1,t&&clearTimeout(t)}},[W,T,n,h]),Q.useEffect(()=>{W&&n&&w(!1)},[W,n]),Q.useEffect(()=>{if(!W||!C)return;let e=document.getElementById(`initial-loading`);if(e){e.classList.add(`fade-out`);let t=setTimeout(()=>{e.remove()},300);return()=>clearTimeout(t)}},[W,C]),Ti({enabled:W&&!h,source:`startupRecovery`}),Q.useEffect(()=>{u||h||r&&et.setDirectory(c)},[c,u,r,h]),Q.useEffect(()=>{if(!ce||typeof window>`u`)return;let e=e=>{let t=e?.visible===!0;y(t)},t=t=>{if(t.origin!==window.location.origin)return;let n=t.data;n?.type===`yuri:embedded-visibility`&&e(n.payload)},n=window;return n.__yuriSetEmbeddedVisibility=e,window.addEventListener(`message`,t),window.parent&&window.parent!==window&&window.parent.postMessage({type:xo},window.location.origin),()=>{window.removeEventListener(`message`,t),n.__yuriSetEmbeddedVisibility===e&&delete n.__yuriSetEmbeddedVisibility}},[ce]),Q.useEffect(()=>{!ce?.directory||h||c!==ce.directory&&l(ce.directory,{showOverlay:!1})},[c,ce,h,l]),Q.useEffect(()=>{if(!ce||typeof window>`u`)return;let e=e=>{e.storageArea===window.localStorage&&e.key===`ui-store`&&q.persist.rehydrate()};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}},[ce]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;PC(t??{})},t=e=>{let t=e.detail?.assistantID;typeof t==`string`&&t.trim()&&Dr(t.trim())},n=e=>{let t=e.detail,n=t?.projectID,r=t?.taskID;n&&r&&Pt(async()=>{let{openScheduledTask:e}=await import(`./scheduledTaskNavigation-Bi7sRiFW.js`).then(e=>e.n);return{openScheduledTask:e}},__vite__mapDeps([120,1,21,5,3,2,6,7,8,22,9,23,20,24,25,18])).then(({openScheduledTask:e})=>e(n,r))};return window.addEventListener(`yuri:open-session`,e),window.addEventListener(`yuri:open-assistant`,t),window.addEventListener(`yuri:open-scheduled-task`,n),()=>{window.removeEventListener(`yuri:open-session`,e),window.removeEventListener(`yuri:open-assistant`,t),window.removeEventListener(`yuri:open-scheduled-task`,n)}},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=()=>{let e=Pe.getState().currentDirectory,{activeProjectId:t,projects:n}=mn.getState(),r=n.find(e=>e.id===t)??null;P(`desktop_open_draft_mini_chat_window`,{directory:e||r?.path||``,projectId:r?.id??null})};return window.addEventListener(`yuri:open-mini-chat`,e),()=>window.removeEventListener(`yuri:open-mini-chat`,e)},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=()=>{if(dn.getState().remoteSession)return;let e=cr.getState().currentSessionId;e&&sn(e)};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=0,t=t=>{let n=++e,r=t.detail,i=typeof r?.directory==`string`&&r.directory.trim().length>0?r.directory.trim():null,a=typeof r?.projectId==`string`&&r.projectId.trim().length>0?r.projectId.trim():null,o=typeof r?.initialPrompt==`string`&&r.initialPrompt.trim().length>0?r.initialPrompt.trim():void 0;q.getState().setActiveMainTab(`chat`),q.getState().setSessionSwitcherOpen(!1);let s=mn.getState(),c=s.projects.find(e=>e.id===(a??(i?null:s.activeProjectId)));if(r?.hostId){let t=dn.getState().remoteSession,c=s.activeProjectId;Vl({sessionId:null,isNewSession:!0,hostId:r.hostId,hubId:r.hubId,directory:i,projectId:a},()=>n===e&&dn.getState().remoteSession===t&&mn.getState().activeProjectId===c).then(async e=>{if(!e)return;let t=dn.getState().remoteSession;o&&t&&await Bl(t.location,o)}).catch(e=>J.error(e instanceof Error?e.message:String(e)));return}if(c?.hostId&&c.hubId){let e={hubId:c.hubId,hostId:c.hostId,directory:c.path};s.setActiveProjectIdOnly(c.id),dn.getState().openRemoteSession(c,e,null),o&&Bl(e,o).catch(e=>J.error(e instanceof Error?e.message:String(e)));return}dn.getState().clearRemoteSession(),cr.getState().openNewSessionDraft({selectedProjectId:a,directoryOverride:i,preserveDirectoryOverride:!!i,ensureProjectForDirectory:!!i,initialPrompt:o})};return window.addEventListener(`yuri:open-draft-session`,t),()=>{e+=1,window.removeEventListener(`yuri:open-draft-session`,t)}},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail,n=typeof t?.projectPath==`string`?t.projectPath.trim():``;if(!n)return;let r=mn.getState(),i=r.projects.find(e=>!e.hostId&&e.path===n);i?r.setActiveProject(i.id):r.addProject(n)};return window.addEventListener(`yuri:open-project`,e),()=>window.removeEventListener(`yuri:open-project`,e)},[]),Q.useEffect(()=>{typeof window>`u`||!W||!n||u||U.current||(U.current=!0,window.__yuriAppReady=!0,window.dispatchEvent(new Event(`yuri:app-ready`)))},[W,n,u]),Ei({enabled:W}),OC({enabled:W}),MC(),ya(),vl(),aC(K(()=>{p(e=>!e)})),Q.useEffect(()=>{x()&&Ut().then(async e=>{e&&await b(e)}).catch(console.warn)},[]),Q.useEffect(()=>{if(!n||!x()||R.current)return;R.current=!0;let e=!1,t=null,r=null;As.getState().subscribeDesktopUpdateEvents().then(t=>{if(e){t();return}r=t});let i=()=>{let e=As.getState();e.checking||e.checkForUpdates()},a=n=>{t=window.setTimeout(()=>{e||(document.visibilityState===`visible`&&i(),a(UC))},n)},o=()=>{if(e||document.visibilityState!==`visible`)return;let t=As.getState().lastChecked;t!=null&&Date.now()-t<WC||i()};return a(0),window.addEventListener(`focus`,o),()=>{e=!0,t!==null&&window.clearTimeout(t),window.removeEventListener(`focus`,o),r&&r()}},[n]),wC(),Q.useEffect(()=>{if(ce)return;let e=e=>{An(e)&&e.shiftKey&&!e.altKey&&(e.code===`KeyD`||e.key.toLowerCase()===`d`)&&(e.preventDefault(),p(e=>!e))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[ce]),Q.useEffect(()=>{ce||i&&setTimeout(()=>a(),5e3)},[a,ce,i]),Q.useEffect(()=>{if(!V||ae!==`not-injected`)return;let e=!1,t=0,n=()=>{if(e)return;t++;let r=A();if(r!==`not-injected`){if(e=!0,oe(r),r===`valid`){let e=L();e&&se(te({isDesktopShell:!0,bootOutcome:e}))}return}let i=Math.min(200*1.1**t,2e3);if(t>=50){let e=document.getElementById(`initial-loading`);e&&!e.textContent?.includes(`taking longer`)&&(e.textContent=`Desktop startup is taking longer than expected...`)}window.setTimeout(n,i)};return window.setTimeout(n,200),()=>{e=!0}},[V,ae]);let me=K(async()=>{if(j({isDesktopShell:v(),isDesktopLocalOriginActive:S()})){await D();return}window.location.reload()}),he=K(async()=>{if(!F){w(!1),I(!0);try{await hr(),await Ln.getState().initializeApp()}finally{I(!1)}Ln.getState().isInitialized||E(e=>e+1)}}),ge=e=>{if(e.screen===`recovery`)return e.variant};if(V&&H&&H.screen!==`main`){if(H.screen===`chooser`)return(0,$.jsx)(po,{children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-transparent`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-full`}),children:(0,$.jsx)(HC,{mode:`first-launch`,onCliAvailable:me,onChooseRemote:()=>{}})})})});let e=ge(H),t=H.screen===`recovery`&&`url`in H?H.url:void 0;return(0,$.jsx)(po,{children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-transparent`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-full`}),children:(0,$.jsx)(HC,{mode:`recovery`,recoveryVariant:e,recoveryHostUrl:t,recoveryHostLabel:void 0,onCliAvailable:me})})})})}if(ce)return Gn(),(0,$.jsx)(po,{children:(0,$.jsx)(rn,{sdk:et.getSdkClient(),directory:c||``,bootstrapDirectory:o,children:(0,$.jsx)(hi,{apis:e,children:(0,$.jsx)(Da,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-background`,children:(0,$.jsx)(XC,{embeddedSessionChat:ce,isVSCodeRuntime:h,embeddedBackgroundWorkEnabled:W})})})})},O)});if(le)return(0,$.jsx)(po,{children:(0,$.jsx)(RC,{})});if(C&&!n&&!h&&!ce)return(0,$.jsx)(po,{children:(0,$.jsx)(KC,{onRetry:()=>{he()},isRetrying:F})});let _e=!n&&!V;return(0,$.jsx)(po,{children:(0,$.jsx)(rn,{sdk:et.getSdkClient(),directory:c||``,bootstrapDirectory:o,children:(0,$.jsx)(hi,{apis:e,children:(0,$.jsx)(fl,{ready:fe&&n&&W,children:(0,$.jsx)($p,{children:(0,$.jsx)(Da,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:V?`h-full text-foreground bg-transparent`:`h-full text-foreground bg-background`,children:[(0,$.jsx)(Ji,{embeddedBackgroundWorkEnabled:W}),(0,$.jsx)(el,{}),(0,$.jsx)(Sc,{}),(0,$.jsx)(Vc,{}),(0,$.jsx)(iS,{}),V&&(0,$.jsx)(VC,{transition:M,ready:n&&r}),(0,$.jsx)(zC,{}),(0,$.jsx)(ui,{}),!_e&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(mc,{}),(0,$.jsx)(Lc,{}),(0,$.jsx)(vc,{}),(0,$.jsx)(GC,{}),f&&(0,$.jsx)(BS,{onClose:()=>p(!1)})]})]})})})})})},O)})}function QC(e){return e.isAboutDialogOpen}function $C(e){return e.setAboutDialogOpen}function ew(e){return e.currentDirectory}function tw(e){return e.currentSessionId}function nw(e){return e.setCurrentSession}if(typeof window<`u`&&!window.__YURI_REFRESH_DEBUG_INSTALLED__){window.__YURI_REFRESH_DEBUG_INSTALLED__=!0;let e=performance.getEntriesByType(`navigation`)[0];console.warn(`[refresh-debug] renderer-entry`,{navigationType:e?.type??`unknown`,protocol:window.location.protocol}),window.addEventListener(`beforeunload`,()=>{console.warn(`[refresh-debug] beforeunload`,{visibilityState:document.visibilityState})}),window.addEventListener(`pagehide`,e=>{console.warn(`[refresh-debug] pagehide`,{persisted:e.persisted})})}var rw=typeof window<`u`&&window.__YURI_RUNTIME_APIS__||(()=>{throw Error(`Runtime APIs not provided for legacy UI entrypoint.`)})();wo(),Qt(),v()&&nn(),Fi({runtimeKey:f(),initializeAppearance:Me,syncSettings:Ne,applyDirectory:wi,startWatchers:()=>{ci(),ji(),ti()},onError:(e,t)=>{console.error(e===`appearance`?`[main] appearance init failed:`:`[main] settings init failed:`,t)}});var iw=document.getElementById(`root`);if(!iw)throw Error(`Root element not found`);(0,uu.createRoot)(iw).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(Ca,{children:(0,$.jsx)(Xt,{children:(0,$.jsx)(Ai,{children:(0,$.jsx)(Mi,{children:(0,$.jsx)(si,{children:(0,$.jsx)(pi,{children:(0,$.jsx)(ZC,{apis:rw})})})})})})})}));
|