@yuriai/web 0.2.36-beta.7 → 0.2.36
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-D4JLZ7IL.js → AgentAvatar-0zDTBIBH.js} +1 -1
- package/dist/assets/{AssistantContactStatus-CqANenYS.js → AssistantContactStatus-CqBzrMI3.js} +3 -3
- package/dist/assets/{AssistantUnreadBadge-j-O3lnH_.js → AssistantUnreadBadge-CqMHWeGm.js} +1 -1
- package/dist/assets/{AssistantView-DXibp8Nh.js → AssistantView-DSnDwWGc.js} +1 -1
- package/dist/assets/{DiagramView-BRW8DdSg.js → DiagramView-xGg1oS8b.js} +1 -1
- package/dist/assets/{FadeInOnReveal-CY1UuS2D.js → FadeInOnReveal-C_UU65YY.js} +1 -1
- package/dist/assets/{GuiPluginSurface-BOWSgNtP.js → GuiPluginSurface-Dpiaq__1.js} +1 -1
- package/dist/assets/{GuiPluginWindow-DlnxZgDZ.js → GuiPluginWindow-B0oHkEwj.js} +1 -1
- package/dist/assets/{Icon-D7VxRqha.js → Icon-BNzwtZlI.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-ClzN4oGS.js → ImageLoadingPlaceholder-CH4TCRvH.js} +1 -1
- package/dist/assets/{LoadingImage-QfRXuKTy.js → LoadingImage-C6jr50EL.js} +1 -1
- package/dist/assets/MarkdownRenderer-BonJRvHM.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-DIvSv3Rv.js → MarkdownRendererImpl-DBaGpRQS.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-AJvljij3.js → MarkstreamRendererImpl-DcxDrUW1.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-CaO-fGvE.js → MobileDetailNavigation-DacHr77a.js} +1 -1
- package/dist/assets/{MobileResizableSheet-CNn25qxG.js → MobileResizableSheet-DZ7Kq3ZS.js} +1 -1
- package/dist/assets/MobileShareBridge-CKDkjJIK.js +4 -0
- package/dist/assets/{MobileTabPageHeader-CkuLCAUz.js → MobileTabPageHeader-CT5jeuHU.js} +1 -1
- package/dist/assets/{MultiRunWindow-PFfaS1N3.js → MultiRunWindow-GFioSTDw.js} +1 -1
- package/dist/assets/{OnboardingScreen-BmAImZZZ.js → OnboardingScreen-DAiSh2kq.js} +1 -1
- package/dist/assets/{OverlayScrollbar-dxKlRNuH.js → OverlayScrollbar-5yODT_nG.js} +1 -1
- package/dist/assets/{SettingsView-Ci7GRXnm.js → SettingsView-BoDwWc6-.js} +1 -1
- package/dist/assets/{SettingsWindow-DjqjH8zU.js → SettingsWindow-BGPVsXUi.js} +1 -1
- package/dist/assets/{SetupTourDialog-yJq3b29w.js → SetupTourDialog-CM8-QHJ3.js} +1 -1
- package/dist/assets/{TerminalView-DsqOYj1E.js → TerminalView-BnR50Mgm.js} +1 -1
- package/dist/assets/{ToolOutputDialog-CxlFIAQ4.js → ToolOutputDialog-BhD4QiRH.js} +1 -1
- package/dist/assets/{VoiceSettings-BEtahqoU.js → VoiceSettings-BeMRGXfr.js} +1 -1
- package/dist/assets/{YuriLogo-DADSHd1H.js → YuriLogo-D7QXHCf6.js} +1 -1
- package/dist/assets/{appThemeRegistry-Bz6WZldU.js → appThemeRegistry-2DEQy44q.js} +1 -1
- package/dist/assets/{button-B7w-b2yV.js → button-CPRnAdlm.js} +1 -1
- package/dist/assets/{capgoAdapter-BpF4euDL.js → capgoAdapter-Dz8eMW5Y.js} +1 -1
- package/dist/assets/{checkbox-DTPgJBK_.js → checkbox-DZkjNegP.js} +1 -1
- package/dist/assets/{collapsible-DZ4ykYM2.js → collapsible-CP7z1jKL.js} +1 -1
- package/dist/assets/{context-menu-BXHMb3Q-.js → context-menu-B8yin969.js} +1 -1
- package/dist/assets/{diagram-CldUPV-Z.js → diagram-O7VUqG75.js} +1 -1
- package/dist/assets/{dialog-gc3n4NXh.js → dialog-Dq8l3IQC.js} +1 -1
- package/dist/assets/{es-DDcXvUON.js → es-CPoqPlVn.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-CJtFYKAV.js → fileMentionTouchSelection-B-oPBD2a.js} +1 -1
- package/dist/assets/{fr-pUULu88g.js → fr-F7aQyu3-.js} +1 -1
- package/dist/assets/{gitApi-CJS823P8.js → gitApi-Dy__-dVB.js} +1 -1
- package/dist/assets/{input-B7yPcQsA.js → input-9A1m0Yjq.js} +1 -1
- package/dist/assets/{insertionBoundaries-D9Vc7ZK5.js → insertionBoundaries-DdpR3zaP.js} +1 -1
- package/dist/assets/{ja-C7MjLXCG.js → ja-BVQSzC4w.js} +1 -1
- package/dist/assets/{ko-U4JK9TxK.js → ko-DW2WaBw6.js} +1 -1
- package/dist/assets/{main-DD5kDabV.js → main-B2Bi3ueT.js} +2 -2
- package/dist/assets/{main-Da12pxuy.js → main-CpoO7VOS.js} +4 -4
- package/dist/assets/{markdownHeightCache-CLiBBW4n.js → markdownHeightCache-D0fP62uP.js} +1 -1
- package/dist/assets/{mcpQueries-JrS0Bvb3.js → mcpQueries-DcbmHgNY.js} +1 -1
- package/dist/assets/{miniChat-lRi18Hvu.js → miniChat-C52LB0Yu.js} +2 -2
- package/dist/assets/{mobile-8eKyWn8a.js → mobile-U4WSU-8R.js} +2 -2
- package/dist/assets/{mobileBackNavigation-BMaLnPn4.js → mobileBackNavigation-B-dgoPw6.js} +1 -1
- package/dist/assets/{multirun-Cui2oFM-.js → multirun-VckoCH5p.js} +1 -1
- package/dist/assets/{native-config-C8AlS30O.js → native-config-CLcCZ6JT.js} +1 -1
- package/dist/assets/{pl-Cy7NC-CJ.js → pl-BWVfAt6z.js} +1 -1
- package/dist/assets/{projectMeta-A8jJRQk7.js → projectMeta-BYNpABmO.js} +1 -1
- package/dist/assets/{pt-BR-qCU-EBEs.js → pt-BR-BifD1KYG.js} +1 -1
- package/dist/assets/{pwa-CbR9DKyA.js → pwa--whpkoe7.js} +1 -1
- package/dist/assets/{queue-abort-optimistic-B_crtkQx.js → queue-abort-optimistic-CsU9CtHa.js} +1 -1
- package/dist/assets/{readiness-BpeOajK9.js → readiness-CafO-iNt.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-DqJy20-t.js → renderElectronMiniChatApp-BOZWsCQP.js} +2 -2
- package/dist/assets/{renderMobileApp-C9OxYnMu.js → renderMobileApp-Cc6uK66H.js} +5 -5
- package/dist/assets/{runtimeConfig-7LsY--_g.js → runtimeConfig-Coh1hryT.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-NZMW9r3D.js → runtimeEndpointReset-Bwm_RwzE.js} +3 -3
- package/dist/assets/{select-WCptRb7Z.js → select-BNDVM5KL.js} +1 -1
- package/dist/assets/{sessionLookup-CxjYSDU2.js → sessionLookup-BI6ygHcL.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-DFKCoZZF.js → sortable-tabs-strip-lZ6K_9ug.js} +1 -1
- package/dist/assets/{speechSettingsQueries-4gKyXBgi.js → speechSettingsQueries-sb0ZHAri.js} +1 -1
- package/dist/assets/{store-CVmc1U19.js → store-Dvb_y7vz.js} +3 -3
- package/dist/assets/{textarea-CMVUhwQ2.js → textarea-Ds63PD7U.js} +1 -1
- package/dist/assets/{tooltip-L2xweVkb.js → tooltip-C25g1ojI.js} +1 -1
- package/dist/assets/types-DD3a5G5L.js +2 -0
- package/dist/assets/{uk-D5ulQPhM.js → uk-3_q1FN3X.js} +1 -1
- package/dist/assets/{useAppFontEffects-mxyvl0gj.js → useAppFontEffects-BBRIHYET.js} +5 -5
- package/dist/assets/{useDesktopWindowControlsLayout-ZHw0VsJh.js → useDesktopWindowControlsLayout-CTSEy8Ep.js} +1 -1
- package/dist/assets/{useDictation-DO12CgDE.js → useDictation-ozXiBIfG.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-B6ny9aem.js → useEffectiveDirectory-DO311OTB.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-DRBFwjAg.js → useMobileNavigationStore-D59MROJU.js} +7 -7
- package/dist/assets/{usePluginsStore-Bav6NFUH.js → usePluginsStore-3VJgeLvf.js} +1 -1
- package/dist/assets/{useStreamingTextThrottle-DLR8xP-j.js → useStreamingTextThrottle-C2ORuOtg.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-DdYDj9PN.js → useWorkerHighlightedLines-DaoXaYxw.js} +1 -1
- package/dist/assets/{zh-CN-C3SRM0mS.js → zh-CN-DvlJbsyJ.js} +1 -1
- package/dist/assets/{zh-TW-CZD-9AC2.js → zh-TW-B4FmXnzP.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +5 -5
- package/package.json +1 -1
- package/dist/assets/MarkdownRenderer-DjSn61IL.js +0 -2
- package/dist/assets/MobileShareBridge-D8oRgnuW.js +0 -4
- package/dist/assets/types-djs5o8aQ.js +0 -2
|
@@ -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-DBn9yahL.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-DEZ1K7qW.js";import{n as h}from"./runtime-fetch-D0YWp3FJ.js";import{A as g,B as _,E as v,G as y,J as b,L as x,M as S,Q as C,S as w,T,X as E,Y as D,Z as O,_ as k,j as A,k as j,n as M,o as N,t as P,v as F,w as I,x as L,y as R,z}from"./desktop-BAmoc_34.js";import{n as ee,t as B}from"./runtimeAPIRegistry-C2VogTny.js";import{_ as V,d as H,m as te,p as ne,r as re}from"./desktopHosts-BLU1tGSX.js";import{a as U,i as ie,t as ae}from"./vendor-zustand-vDaAPGfl.js";import{A as W,B as oe,L as G,M as se,R as ce,a as le,at as ue,d as de,f as fe,g as pe,h as me,i as he,k as ge,m as _e,ot as ve,p as ye,st as be,z as xe}from"./vendor-base-ui-CzHs0bHY.js";import{At as Se,Ct as Ce,Er as we,In as Te,Kn as Ee,Or as De,Rn as Oe,St as ke,_r as Ae,br as je,bt as Me,fn as Ne,gr as K,kr as Pe,kt as Fe,mn as Ie,wt as Le,xt as Re,yr as ze,yt as Be,zn as Ve}from"./gitApiHttp-CKrsk1tw.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{E as He,T as Ue,a as We,i as Ge,o as Ke,r as q,s as qe,t as Je,w as Ye}from"./useUIStore-B61bCFEM.js";import{A as Xe,Nt as Ze,a as Qe,ct as $e,k as et,o as tt,r as nt,t as rt}from"./bootstrap-Bi91NjXG.js";import{n as it,t as at}from"./vendor-react-DlzBev0S.js";import{l as ot}from"./vendor-tanstack-query-core-Y_YoRHtC.js";import{n as st,o as ct,s as lt}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{d as ut,u as dt}from"./fileQueries-C2Rs6TPz.js";import{r as ft,s as pt}from"./runtime-file-resource-BP4P52ry.js";import{a as mt,n as ht}from"./path-utils-jGozTg9d.js";import{o as gt}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as _t}from"./pathNormalization-ewtPqJWn.js";import{n as vt}from"./terminalApi-Bo6KWljy.js";import{a as yt}from"./types-djs5o8aQ.js";/* empty css */import{U as bt}from"./vendor-codemirror-autocomplete-C0FrlFqZ.js";import{a as xt}from"./vendor-pierre-diffs-BFiZ3IhI.js";import{a as St,h as Ct,i as wt,m as Tt,t as Et}from"./vendor-reactuses-core-DWo5Wn6R.js";import{a as Dt,c as Ot,d as kt,f as At,g as jt,h as Mt,i as Nt,l as Pt,m as Ft,o as It,p as Lt,r as J,s as Rt,t as Y}from"./button-B7w-b2yV.js";import{n as zt}from"./store-CVmc1U19.js";import{S as Bt,b as Vt,h as Ht}from"./MobileDetailNavigation-CaO-fGvE.js";import{$r as Ut,A as Wt,Bi as Gt,C as Kt,Ca as qt,Cr as Jt,Da as Yt,Ea as Xt,Ei as Zt,F as Qt,Ft as $t,Gr as en,H as tn,Hr as nn,I as rn,Kr as an,Kt as on,Lr as sn,Mn as cn,Qn as ln,Qr as un,R as dn,S as fn,Ta as pn,Tr as mn,U as hn,W as gn,Wr as _n,Xr as vn,Yr as yn,ai as bn,at as xn,b as Sn,bt as Cn,ct as wn,dr as Tn,ei as X,et as En,ft as Dn,g as On,ha as kn,ir as An,j as jn,jn as Mn,ka as Nn,kn as Pn,kr as Fn,m as In,mr as Ln,mt as Rn,or as zn,ot as Bn,p as Vn,pr as Hn,pt as Un,qr as Wn,qt as Gn,rn as Kn,rr as qn,sr as Jn,st as Yn,tr as Xn,tt as Zn,ur as Qn,ut as $n,vt as er,wi as tr,x as nr,y as rr,yt as ir}from"./useMobileNavigationStore-DRBFwjAg.js";import{n as ar}from"./useAssistantUIStore-cHle1U5H.js";import{n as or}from"./useThemeSystem-CNzUUkFn.js";import{n as sr,o as cr}from"./vendor-framer-motion-DDMKlXiP.js";import{n as Z,t as lr}from"./Icon-D7VxRqha.js";import{a as ur,i as dr,n as fr,o as pr,r as mr,t as hr}from"./dialog-gc3n4NXh.js";import{A as gr,C as _r,D as vr,O as yr,P as br,T as xr,V as Sr,a as Cr,f as wr,h as Tr,i as Er,j as Dr,k as Or,m as kr,o as Ar,p as jr,r as Mr,t as Nr,w as Pr,y as Fr}from"./gitApi-CJS823P8.js";import{$ as Ir,A as Lr,At as Rr,B as zr,Ct as Br,D as Vr,Dt as Hr,Et as Ur,Ft as Wr,H as Gr,I as Kr,It as qr,J as Jr,M as Yr,Mt as Xr,N as Zr,Nt as Qr,O as $r,Ot as ei,P as ti,Pt as ni,Rt as ri,S as ii,St as ai,Tt as oi,V as si,Z as ci,_ as li,_t as ui,at as di,b as fi,bt as pi,c as mi,ct as hi,d as gi,et as _i,f as vi,ft as yi,g as bi,h as xi,i as Si,it as Ci,j as wi,jt as Ti,k as Ei,kt as Di,l as Oi,m as ki,mt as Ai,n as ji,nt as Mi,ot as Ni,p as Pi,pt as Fi,q as Ii,rt as Li,s as Ri,st as zi,t as Bi,tt as Vi,u as Hi,v as Ui,vt as Wi,w as Gi,wt as Ki,x as qi,xt as Ji,y as Yi,yt as Xi,zt as Zi}from"./useAppFontEffects-mxyvl0gj.js";import{t as Qi}from"./input-B7yPcQsA.js";import{i as $i,n as ea,r as ta,t as na}from"./tooltip-L2xweVkb.js";import{A as ra,B as ia,Bt as aa,C as oa,D as sa,F as ca,I as la,J as ua,O as da,Q as fa,S as pa,T as ma,X as ha,Xt as ga,Y as _a,Z as va,_ as ya,c as ba,ct as xa,dt as Sa,f as Ca,g as wa,gt as Ta,h as Ea,ht as Da,i as Oa,it as ka,lt as Aa,m as ja,nt as Ma,o as Na,ot as Pa,p as Fa,s as Ia,tt as La,u as Ra,ut as za,v as Ba,w as Va,x as Ha,y as Ua}from"./pwa-CbR9DKyA.js";import{t as Wa}from"./YuriLogo-DADSHd1H.js";import{a as Ga,r as Ka}from"./device-w1ioiqv3.js";import{r as qa}from"./themes-BgDJcxRc.js";import{f as Ja,g as Ya,h as Xa,p as Za}from"./scheduledTaskNavigation-7dD6PWMD.js";import{a as Qa,i as $a}from"./sessionLookup-CxjYSDU2.js";import{D as eo,E as to,_ as no,b as ro,f as io,g as ao,h as oo,m as so,v as co,y as lo}from"./insertionBoundaries-D9Vc7ZK5.js";import{c as uo,d as fo,i as po,l as mo,n as ho,s as go,t as _o}from"./select-WCptRb7Z.js";import{n as vo,t as yo}from"./appThemeRegistry-Bz6WZldU.js";import{n as bo,o as xo}from"./MarkdownRenderer-DjSn61IL.js";import{a as So}from"./url-MRa-FtQa.js";import{a as Co,c as wo,i as To,l as Eo,o as Do,s as Oo}from"./toolHelpers-iEHVHQ9p.js";import{a as ko}from"./react-a6PrrNTm.js";import{n as Ao,t as jo}from"./useEffectiveDirectory-B6ny9aem.js";import{t as Mo}from"./ImageLoadingPlaceholder-ClzN4oGS.js";import{t as No}from"./LoadingImage-QfRXuKTy.js";import{_ as Po,i as Fo,l as Io,n as Lo,s as Ro,t as zo,v as Bo,y as Vo}from"./vendor-dnd-kit-core-DK4OoOTr.js";import{a as Ho,n as Uo,o as Wo,s as Go,t as Ko}from"./vendor-dnd-kit-sortable-Cv69eQm1.js";import{n as qo,r as Jo}from"./textarea-CMVUhwQ2.js";import{i as Yo,n as Xo,r as Zo,t as Qo}from"./dropdown-menu.styles-BDla58Rm.js";import{a as $o,f as es,i as ts,l as ns,n as rs,p as is,s as as}from"./projectMeta-A8jJRQk7.js";import{h as os}from"./useWorkerHighlightedLines-DdYDj9PN.js";import{t as ss}from"./vendor-tanstack-react-virtual-DSFNK3qc.js";import{t as cs}from"./sortable-tabs-strip-DFKCoZZF.js";import{t as ls}from"./vendor-motion-C9oiAdx-.js";import{A as us,B as ds,C as fs,D as ps,E as ms,G as hs,H as gs,K as _s,O as vs,S as ys,T as bs,U as xs,W as Ss,Y as Cs,Z as ws,a as Ts,b as Es,c as Ds,f as Os,g as ks,h as As,k as js,l as Ms,m as Ns,n as Ps,o as Fs,p as Is,q as Ls,r as Rs,s as zs,u as Bs,v as Vs,w as Hs,y as Us}from"./MobileTabPageHeader-CkuLCAUz.js";import{i as Ws,n as Gs,r as Ks,t as qs}from"./useDesktopWindowControlsLayout-ZHw0VsJh.js";import{n as Js}from"./useFontPreferences-D-AOjd9H.js";import{$ as Ys,A as Xs,C as Zs,Ct as Qs,D as $s,E as ec,G as tc,J as nc,K as rc,M as ic,N as ac,O as oc,S as sc,St as cc,T as lc,Tt as uc,W as dc,X as fc,Y as pc,Z as mc,_ as hc,_t as gc,a as _c,at as vc,b as yc,bt as bc,c as xc,ct as Sc,d as Cc,dt as wc,et as Tc,f as Ec,ft as Dc,g as Oc,gt as kc,h as Ac,ht as jc,i as Mc,it as Nc,j as Pc,l as Fc,lt as Ic,mt as Lc,n as Rc,o as zc,p as Bc,pt as Vc,q as Hc,r as Uc,rt as Wc,s as Gc,st as Kc,tt as qc,u as Jc,ut as Yc,v as Xc,vt as Zc,w as Qc,wt as $c,x as el,xt as tl,y as nl,yt as rl}from"./runtimeEndpointReset-NZMW9r3D.js";import{t as il}from"./YuriWordmark-CGDlDvEH.js";import{t as al}from"./AssistantUnreadBadge-j-O3lnH_.js";import{a as ol,i as sl,n as cl,r as ll,t as ul}from"./context-menu-BXHMb3Q-.js";import{n as dl,r as fl,t as pl}from"./collapsible-DZ4ykYM2.js";import{n as ml,r as hl}from"./readiness-BpeOajK9.js";import{a as gl,o as _l,r as vl,s as yl,t as bl}from"./projectActions-BX0cjZoq.js";import{d as xl,i as Sl,n as Cl,r as wl,u as Tl}from"./historyImportQueries-C8VK9R5_.js";import{t as El}from"./diagram-CldUPV-Z.js";import{a as Dl,i as Ol,n as kl,o as Al,r as jl,t as Ml}from"./multirun-Cui2oFM-.js";import{t as Nl}from"./vendor-zumer-snapdom-yq9vlCKr.js";import{n as Pl,t as Fl}from"./vendor-html-to-image-BDMm2v6d.js";var Q=e(be(),1),Il=at(),Ll=it(),$=ve();function Rl(e){let t=(0,Ll.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 zl=!1,Bl=0,Vl=new Set,Hl=async()=>{let e=++Bl;try{let t=await R(`desktop_is_window_fullscreen`);if(e!==Bl||t===zl)return;zl=t===!0,Vl.forEach(e=>e())}catch{}},Ul=e=>w()?(Vl.add(e),Vl.size===1&&(window.addEventListener(`yuri:window-resized`,Hl),Hl()),()=>{Vl.delete(e),Vl.size===0&&(window.removeEventListener(`yuri:window-resized`,Hl),Bl++,zl=!1)}):()=>{};function Wl(){return(0,Q.useSyncExternalStore)(Ul,Kl,Gl)}function Gl(){return!1}function Kl(){return zl}function ql(){let e=(0,Ll.c)(19),{t}=At(),n=q(Ql),r=q(Zl),i=q(Xl),a=q(Yl),o=q(Jl),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=wt(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=J(`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 Jl(e){return e.setWorkStatusOverlayOpen}function Yl(e){return e.setWorkStatusPanelEnabled}function Xl(e){return e.workStatusOverlayOpen}function Zl(e){return e.workStatusPanelFits}function Ql(e){return e.workStatusPanelEnabled}var $l=(e,t,n)=>ct({queryKey:[`desktop-host-inventory`,e],queryFn:async({signal:e})=>{let r=await re(),i=new Set(r.sshHostIds??[]);if(r.sshHostIds===void 0&&P()){let e=await aa();for(let t of e.instances)i.add(t.id)}return e.throwIfAborted(),{hosts:r.hosts.filter(e=>ne(e,i)||t===`host:${e.id}`||!!(n&&te(n,H(e)))),sshIds:i}}});function eu(e){let t=(0,Ll.c)(18),{onClick:n,open:r}=e,{t:i}=At(),a=Q.useSyncExternalStore(s,l,l),o=q(tu),c=f(),u=m(),d=L(),{data:p}=lt({...$l(a,c,u),enabled:!o}),h=c.startsWith(`host:`)?c.slice(5):null,g=p?.hosts.find(e=>h?e.id===h:!!(u&&te(u,H(e))));if(d&&!p?.hosts.length&&!p?.sshIds.size)return null;let _=g?V(g.label):i(d?`desktopHostSwitcher.instance.local`:`desktopHostSwitcher.title`),v=Wr({isLocal:d,isSsh:!!(g&&p?.sshIds.has(g.id)),isRelay:a.startsWith(`relay:`)}),y=na,b=$i,x=Y,S=i(`header.actions.sessionMenu.servicesWithInstance`,{current:_}),C;t[0]===v?C=t[1]:(C=(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]=C);let w;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=(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]=w):w=t[2];let T;t[3]!==x||t[4]!==n||t[5]!==r||t[6]!==S||t[7]!==C?(T=(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":S,"aria-expanded":r,"aria-haspopup":`menu`,onClick:n,children:[C,w]}),t[3]=x,t[4]=n,t[5]=r,t[6]=S,t[7]=C,t[8]=T):T=t[8];let E;t[9]!==b||t[10]!==T?(E=(0,$.jsx)(b,{asChild:!0,children:T}),t[9]=b,t[10]=T,t[11]=E):E=t[11];let D;t[12]===_?D=t[13]:(D=(0,$.jsx)(ea,{children:_}),t[12]=_,t[13]=D);let O;return t[14]!==y||t[15]!==D||t[16]!==E?(O=(0,$.jsxs)(y,{children:[E,D]}),t[14]=y,t[15]=D,t[16]=E,t[17]=O):O=t[17],O}function tu(e){return e.isSettingsDialogOpen}var nu=[{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`}],ru=`finder`,iu=new Set([`finder`,`terminal`]),au=e=>typeof window<`u`&&window.__YURI_PLATFORM__===`win32`&&e.id===`finder`?{...e,label:`Explorer`,appName:`File Explorer`}:e,ou=e=>{if(!e)return null;let t=nu.find(t=>t.id===e)??null;return t?au(t):null},su=()=>nu.filter(e=>iu.has(e.id)).map(e=>({...au(e)})),cu=()=>{if(typeof window>`u`)return ru;let e=window.localStorage.getItem(`openInAppId`);return e&&ou(e)?e:ru},lu=!1,uu=!1,du=!1,fu=0,pu=null,mu=()=>{pu&&=(clearTimeout(pu),null)},hu=U()((e,t)=>({selectedAppId:cu(),availableApps:su(),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:su(),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:nu.filter(e=>r.has(e.appName)||iu.has(e.id)).map(e=>({...au(e),iconDataUrl:i.get(e.appName)})),hasLoadedApps:!0})},r=async i=>{if(!w()||uu||t().hasLoadedApps&&!i)return;let a=nu.map(e=>e.appName);mu(),i&&e({hasLoadedApps:!1}),uu=!0,du=!1,e({isScanning:!0});try{let{apps:t,success:o,hasCache:s,isCacheStale:c}=await N(a,i),l=o&&!s&&t.length===0&&fu<3;if(e({isCacheStale:s?c:!1}),n(t,o?!l:!1),o){if(l){let e=[800,1600,3200][fu]??3200;fu+=1,du=!0,pu=setTimeout(()=>{r()},e);return}fu=0,du=!1;return}if(fu<3){let e=[1e3,3e3,7e3][fu]??7e3;fu+=1,du=!0,pu=setTimeout(()=>{r()},e)}}finally{uu=!1,du||e({isScanning:!1})}};r(),window.addEventListener(`yuri:settings-synced`,t=>{let n=t.detail,r=n&&typeof n.openInAppId==`string`&&n.openInAppId.length>0&&ou(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)&&(fu=3,du=!1,e({isScanning:!1,isCacheStale:!1}),n(r))}),window.__yuriAppReady&&r(),window.setTimeout(()=>{t().hasLoadedApps||r()},5e3)},loadInstalledApps:async n=>{if(lu||t().initialize(),!w()||uu||t().hasLoadedApps&&!n)return;let r=nu.map(e=>e.appName);mu(),n&&e({hasLoadedApps:!1}),uu=!0,du=!1,e({isScanning:!0});try{let{apps:t,hasCache:i,isCacheStale:a}=await N(r,n),o=new Set(t.map(e=>e.name)),s=new Map(t.map(e=>[e.name,e.iconDataUrl??void 0])),c=nu.filter(e=>o.has(e.appName)||iu.has(e.id)).map(e=>({...e,iconDataUrl:s.get(e.appName)}));e({availableApps:c.length>0?c:su(),hasLoadedApps:c.length>0,isCacheStale:i?a:!1})}finally{uu=!1,du||e({isScanning:!1})}},selectApp:async t=>{ou(t)&&(e({selectedAppId:t}),typeof window<`u`&&window.localStorage.setItem(`openInAppId`,t),await tt({openInAppId:t}))}})),gu=(e=f(),t=l())=>{let n=e.startsWith(`host:`)?e.slice(5):null;return{queryKey:[t,`ssh-editor-apps`,n],enabled:w()&&F()&&n!==null,queryFn:async({signal:e})=>{let t=await R(`desktop_ssh_editor_apps`,{hostId:n});return e.throwIfAborted(),t?{hostId:n,appIds:t.appIds}:null}}},_u=()=>{let e=(0,Ll.c)(3),t=(0,Q.useSyncExternalStore)(s,f,vu),n=(0,Q.useSyncExternalStore)(s,l,yu),r;return e[0]!==t||e[1]!==n?(r=gu(t,n),e[0]=t,e[1]=n,e[2]=r):r=e[2],lt(r)};function vu(){return``}function yu(){return``}var bu=`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`,xu=`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`,Su=e=>({...e,fallbackIconDataUrl:e.id===`finder`&&window.__YURI_PLATFORM__!==`win32`?bu:e.id===`terminal`?xu:void 0}),Cu=e=>{let t=(0,Ll.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=J(`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},wu=({directory:e,className:t})=>{let{t:n}=At(),r=hu(e=>e.selectedAppId),i=hu(e=>e.availableApps),a=hu(e=>e.isCacheStale),o=hu(e=>e.isScanning),s=hu(e=>e.initialize),c=hu(e=>e.loadInstalledApps),l=hu(e=>e.selectApp),{data:u}=_u(),d=Q.useMemo(()=>u?i.filter(e=>u.appIds.includes(e.id)):i,[i,u]);Q.useEffect(()=>{s()},[s]);let f=w()&&L(),p=Q.useMemo(()=>{let e=d.find(e=>e.id===r)??d.find(e=>e.id===`finder`)??d[0];return e?Su(e):null},[d,r]);if(!f&&!u||!e)return null;let m=async t=>{try{let r=await S(e,t.id,t.appName,u?.hostId);!r&&!u?await A(e,t.appName):r||X.error(n(`filesView.toast.openInAppFailed`,{app:t.label}))}catch(e){X.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 kt(e)};return(0,$.jsxs)(`div`,{className:J(`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:J(`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)(Cu,{label:p.label,iconDataUrl:p.iconDataUrl,fallbackIconDataUrl:p.fallbackIconDataUrl}):(0,$.jsx)(Z,{name:`file-copy`,className:`h-4 w-4`})}),(0,$.jsxs)(_a,{children:[(0,$.jsx)(Ma,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:J(`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)(ha,{align:`end`,className:`w-56 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(va,{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)(La,{}),d.map(e=>{let t=Su(e);return(0,$.jsxs)(va,{className:`flex items-center gap-2`,onClick:()=>void h(e),children:[(0,$.jsx)(Cu,{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)(va,{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]})]})]})},Tu=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Eu=[`dev`,`start`,`preview`,`serve`];async function Du(e,t,n){if(!e)return null;let r=Au(t);if(r)return{command:r.command,label:r.name||`Start Preview`,actionId:r.id};if(n){let t=ju(n);if(t){let n=await Mu(e);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 Ou(e)){let e=await ku(),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 Ou(e){let t=await Nu(`${e}/index.html`,e);return typeof t==`string`&&t.trim().length>0}async function ku(){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 Au(e){for(let t of e){let e=`${t.name} ${t.command}`.toLowerCase();if(Eu.some(t=>e.includes(t)))return t}return null}function ju(e){for(let{pattern:t}of Tu)for(let n of Object.keys(e))if(t.test(n))return n;return null}async function Mu(e){let t=await Nu(`${e}/package.json`,e);if(t)try{let e=JSON.parse(t),n=typeof e.packageManager==`string`?e.packageManager.toLowerCase():``;if(n.startsWith(`bun@`))return`bun`;if(n.startsWith(`pnpm@`))return`pnpm`;if(n.startsWith(`yarn@`))return`yarn`;if(n.startsWith(`npm@`))return`npm`}catch{}for(let[t,n]of[[`bun.lock`,`bun`],[`bun.lockb`,`bun`],[`pnpm-lock.yaml`,`pnpm`],[`yarn.lock`,`yarn`],[`package-lock.json`,`npm`]]){let r=await Nu(`${e}/${t}`,e);if(typeof r==`string`&&r.trim().length>0)return n}return`npm`}async function Nu(e,t){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 n=B()?.files;if(n?.readFile)try{let t=await n.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 Pu(e){try{let t=await Nu(`${e}/package.json`,e);if(t==null)return null;let n=JSON.parse(t).scripts;return n&&typeof n==`object`&&!Array.isArray(n)?n:null}catch{return null}}var Fu=e=>new Promise(t=>{window.setTimeout(t,e)}),Iu=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),Lu=/https?:\/\/[^\s<>'"`]+/gi,Ru=`__yuri_auto_discover_preview__`,zu=15e3,Bu=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},Vu=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}},Hu=e=>{let t=e.replace(Iu,``).match(Lu);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},Uu=({projectRef:e,directory:t,className:n,compact:r=!1,allowMobile:i=!1})=>{let{t:a}=At(),{terminal:o,runtime:s}=dt(),{isMobile:c}=Ka(),l=Q.useMemo(()=>w(),[]),u=Es(e=>e.instances),d=Es(e=>e.load),f=q(e=>e.setBottomTerminalOpen),p=q(e=>e.setActiveMainTab),m=q(e=>e.setSettingsPage),h=q(e=>e.setSettingsDialogOpen),g=q(e=>e.setSettingsProjectsSelectedId),_=q(e=>e.openContextPreview),v=Js(e=>e.sessions),y=Js(e=>e.ensureDirectory),b=Js(e=>e.setTabLabel),x=Js(e=>e.setTabIconKey),S=Js(e=>e.setActiveTab),C=Js(e=>e.setConnecting),T=Js(e=>e.setTabSessionId),E=Js(e=>e.setTabPreviewUrl),D=Js(e=>e.projectActionRuns),O=Js(e=>e.setProjectActionRun),k=Js(e=>e.updateProjectActionRunStatus),A=Js(e=>e.removeProjectActionRun),[j,M]=Q.useState([]),[N,P]=Q.useState(null),[F,I]=Q.useState(!1),L=Q.useRef({}),R=Q.useRef({}),z=Q.useRef({}),ee=Q.useRef({}),B=Q.useRef(0),V=e?.id??null,H=e?.path??``,te=Q.useMemo(()=>V?{id:V,path:H}:null,[V,H]);Q.useEffect(()=>{l&&d().catch(()=>void 0)},[l,d]);let ne=Q.useCallback(async e=>{await So(e)},[]),re=Q.useCallback(async()=>{if(!te)return;let e=B.current+1;B.current=e,I(!0);try{let t=await Ln(te);if(B.current!==e)return;let n=t.actions;M(n),P(e=>e===Ru||e&&n.some(t=>t.id===e)?e:null)}catch{if(B.current!==e)return}finally{B.current===e&&I(!1)}},[te]),U=Q.useMemo(()=>gl(t||te?.path||``),[t,te?.path]),ie=Q.useMemo(()=>N?j.find(e=>e.id===N)??null:null,[j,N]),ae=Q.useMemo(()=>({id:Ru,name:a(`projectActions.actions.autoDiscover`),command:``,icon:`search`,autoOpenUrl:!0}),[a]),W=!c,oe=Q.useMemo(()=>W?[ae,...j]:j,[j,ae,W]);Q.useEffect(()=>{re()},[re]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;V&&(t?.projectId&&t.projectId!==V||re())};return window.addEventListener(bl,e),()=>{window.removeEventListener(bl,e)}},[re,V]),Q.useEffect(()=>{N&&(N===Ru&&W||j.some(e=>e.id===N)||P(null))},[j,W,N]),Q.useEffect(()=>{for(let[e,t]of Object.entries(D)){let n=v.get(t.directory)?.tabs.find(e=>e.id===t.tabId);(!n||n.terminalSessionId!==t.sessionId)&&A(e)}},[D,A,v]),Q.useEffect(()=>{for(let[e,t]of Object.entries(D)){let n=R.current[e]??{lastSeenChunkId:null,openedUrl:!1,tail:``,openInPreview:!1};R.current[e]=n;let r=oe.find(e=>e.id===t.actionId);if(!r)continue;let i=v.get(t.directory)?.tabs.find(e=>e.id===t.tabId);if(!i||!Array.isArray(i.bufferChunks)||i.bufferChunks.length===0)continue;let o=i.bufferChunks.filter(e=>n.lastSeenChunkId===null||e.id>n.lastSeenChunkId);if(o.length===0)continue;let s=o.map(e=>e.data).join(``),c=`${n.tail}${s}`,l=!n.openedUrl&&r.autoOpenUrl===!0?Hu(c):null;if(n.lastSeenChunkId=o[o.length-1]?.id??n.lastSeenChunkId,n.tail=c.slice(-512),l)if(n.openedUrl=!0,n.openInPreview){let t=D[e];t&&(E(t.directory,t.tabId,l,{locked:!1,autoOpened:!1}),t.status===`waiting-for-preview`&&k(e,`running`),window.clearTimeout(ee.current[e]),delete ee.current[e],_(t.directory,l))}else ne(l),X.success(a(`projectActions.toast.openedUrlFromOutput`));R.current[e]=n}for(let e of Object.keys(R.current))D[e]||(delete R.current[e],window.clearTimeout(ee.current[e]),delete ee.current[e])},[oe,_,ne,D,E,a,v,k]);let G=Q.useCallback(async(e,t={})=>{if(!U)throw Error(a(`projectActions.error.noActiveDirectory`));let n=yl(U,e.id);y(U);let r=Js.getState(),i=r.getDirectoryState(U),o=L.current[n]||null,s=o?!!i?.tabs.some(e=>e.id===o):!1;(!o||!s)&&(o=r.createTab(U),L.current[n]=o),b(U,o,`Action: ${e.name}`),x(U,o,e.icon||`play`),t.revealTerminal!==!1&&(S(U,o),f(!0),p(`terminal`));let c=Js.getState().getDirectoryState(U)?.tabs.find(e=>e.id===o);return{key:n,tabId:o,sessionId:c?.terminalSessionId??null}},[y,U,p,S,f,x,b,a]),se=Q.useCallback(async e=>{if(s.isVSCode||!i&&c)return;if(!U){X.error(a(`projectActions.error.noActiveDirectoryForAction`));return}let t=yl(U,e.id),n=D[t];if(!(n&&n.status===`running`))try{let t=e.id===Ru?await(async()=>{let[e,t]=await Promise.all([Ln({id:te?.id??``,path:U}),Pu(U)]),n=await Du(U,e.actions,t);if(!n)throw Error(a(`contextPanel.preview.noDevServer`));return{id:Ru,name:a(`projectActions.actions.autoDiscover`),command:n.command,icon:`search`,autoOpenUrl:!0,openUrl:n.previewUrlHint||``}})():e,n=t.autoOpenUrl===!0&&(t.openUrl||``).trim().length>0,{key:r,tabId:i,sessionId:s}=await G(t,{revealTerminal:!n&&e.id!==Ru}),c=s,d=!1;if(!c){C(U,i,!0);try{c=(await o.createSession({cwd:U})).sessionId,d=!0,T(U,i,c)}finally{C(U,i,!1)}}if(!c)throw Error(a(`projectActions.error.failedToCreateTerminalSession`));d&&await Fu(350),t.id===Ru&&(z.current[r]?.(),C(U,i,!0),z.current[r]=vt(c,e=>{e.type===`data`&&typeof e.data==`string`&&e.data.length>0&&Js.getState().appendToBuffer(U,i,e.data),e.type===`exit`&&(Js.getState().setTabLifecycle(U,i,`exited`),Js.getState().setConnecting(U,i,!1),Js.getState().removeProjectActionRun(r),delete R.current[r],z.current[r]?.(),delete z.current[r],window.clearTimeout(ee.current[r]),delete ee.current[r])},()=>{Js.getState().setConnecting(U,i,!1)},{maxRetries:60,initialRetryDelay:250,maxRetryDelay:2e3,connectionTimeout:5e3}));let f=t.autoOpenUrl===!0&&l&&(t.desktopOpenSshForward||``).trim().length>0,p=t.autoOpenUrl?Vu(t.openUrl):null,m=t.autoOpenUrl&&l?_l(t.desktopOpenSshForward,u):null;O({key:r,directory:U,actionId:t.id,tabId:i,sessionId:c,status:t.id===Ru&&!p?`waiting-for-preview`:`running`}),window.clearTimeout(ee.current[r]),delete ee.current[r],t.id===Ru&&!p&&(ee.current[r]=window.setTimeout(()=>{Js.getState().updateProjectActionRunStatus(r,`running`),delete ee.current[r]},zu)),m?(E(U,i,null,{locked:!0}),ne(m),X.success(a(`projectActions.toast.openedForwardedUrl`))):p?(E(U,i,p,{locked:!0,autoOpened:!0}),_(U,p),X.success(a(`projectActions.toast.openedActionUrl`))):n?(E(U,i,null,{locked:!0}),X.error(a(`projectActions.error.invalidCustomUrlFormat`))):f?(E(U,i,null,{locked:!0}),X.error(a(`projectActions.error.selectedDesktopSshForwardUnavailable`))):E(U,i,null,{locked:!1,autoOpened:!1}),R.current[r]={lastSeenChunkId:null,openedUrl:!!m||!!p||n,tail:``,openInPreview:t.id===Ru};let h=Bu(t.command.trim().replace(/\r\n|\r/g,`
|
|
3
|
-
`));await o.sendInput(c,`${h}\r`)}catch(e){A(t),delete R.current[t],z.current[t]?.(),delete z.current[t],window.clearTimeout(ee.current[t]),delete ee.current[t],X.error(e instanceof Error?e.message:a(`projectActions.error.failedToRunAction`))}},[u,G,i,c,l,U,ne,_,D,s.isVSCode,A,C,O,E,T,te?.id,a,o]),ce=Q.useCallback(async e=>{let t=yl(U,e.id),n=D[t];if(n){k(t,`stopping`);try{await o.sendInput(n.sessionId,``)}catch{}if(await new Promise(e=>{window.setTimeout(e,1e3)}),Js.getState().getDirectoryState(n.directory)?.tabs.find(e=>e.id===n.tabId)?.terminalSessionId===n.sessionId){if(typeof o.forceKill==`function`)try{await o.forceKill({sessionId:n.sessionId})}catch{}else try{await o.close(n.sessionId)}catch{}T(n.directory,n.tabId,null)}A(t),delete R.current[t],z.current[t]?.(),delete z.current[t],window.clearTimeout(ee.current[t]),delete ee.current[t]}},[U,D,A,T,o,k]),le=Q.useCallback(()=>{let e=ie??oe[0];if(!e)return;let t=yl(U,e.id),n=D[t];if(n?.status!==`stopping`){if(n){ce(e);return}se(e)}},[oe,U,se,D,ie,ce]),ue=Q.useCallback((e,t=!1)=>{if(P(e.id),!t){se(e);return}let n=yl(U,e.id),r=D[n];if(r?.status!==`stopping`){if(r){ce(e);return}se(e)}},[U,se,D,ce]),de=Q.useCallback(()=>{te?.id&&(g(te.id),m(`projects`),h(!0))},[h,m,g,te?.id]);if(s.isVSCode||!i&&c||!te||!U)return null;let fe=ie??oe[0]??null;if(!fe)return null;let pe=fe.icon||`play`,me=fe.id===Ru?`search`:vl[pe]||`play`,he=D[yl(U,fe.id)],ge=he?.status===`stopping`,_e=he?.status===`waiting-for-preview`,ve=he?v.get(he.directory)?.tabs.find(e=>e.id===he.tabId)?.previewUrl??null:null,ye=!!(he&&ve),be=()=>{!he||!ve||_(he.directory,ve)};return r?(0,$.jsxs)(`div`,{className:`inline-flex items-center`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:F||ge,className:J(`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:le,"aria-label":a(he?`projectActions.actions.stopNamedAria`:`projectActions.actions.runNamedAria`,{name:fe.name}),children:ge||_e?(0,$.jsx)(Z,{name:`loader-4`,className:`h-5 w-5 animate-spin text-[var(--status-warning)]`}):he?(0,$.jsx)(Z,{name:`stop`,className:`h-5 w-5 text-[var(--status-warning)]`}):(0,$.jsx)(Z,{name:me,className:`h-5 w-5`})}),ye?(0,$.jsxs)(na,{children:[(0,$.jsx)($i,{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":a(`projectActions.actions.openPreview`),onClick:be,children:(0,$.jsx)(Z,{name:`global`,className:`h-4 w-4`})})}),(0,$.jsx)(ea,{sideOffset:6,children:a(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(_a,{children:[(0,$.jsx)(Ma,{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":a(`projectActions.actions.chooseActionAria`),children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-3.5 w-3.5`})})}),(0,$.jsxs)(ha,{align:`end`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(va,{className:`flex items-center gap-2`,onClick:de,children:[(0,$.jsx)(Z,{name:`add`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:a(`projectActions.actions.addNewAction`)})]}),(0,$.jsx)(La,{}),oe.map(e=>{let t=e.icon||`play`,n=e.id===Ru?`search`:vl[t]||`play`,r=yl(U,e.id),i=D[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(va,{className:`flex items-center gap-2`,onClick:()=>{ue(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:J(`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:le,disabled:F||ge,className:J(`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":a(he?`projectActions.actions.stopNamedAria`:`projectActions.actions.runNamedAria`,{name:fe.name}),children:(0,$.jsx)(`span`,{className:`inline-flex h-4 w-4 shrink-0 items-center justify-center`,children:ge||_e?(0,$.jsx)(Z,{name:`loader-4`,className:`h-4 w-4 animate-spin text-[var(--status-warning)]`}):he?(0,$.jsx)(Z,{name:`stop`,className:`h-4 w-4 text-[var(--status-warning)]`}):(0,$.jsx)(Z,{name:me,className:`h-4 w-4`})})}),ye?(0,$.jsxs)(na,{children:[(0,$.jsx)($i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:be,className:J(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":a(`projectActions.actions.openPreview`),children:(0,$.jsx)(Z,{name:`global`,className:`h-4 w-4`})})}),(0,$.jsx)(ea,{sideOffset:6,children:a(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(_a,{children:[(0,$.jsx)(Ma,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:J(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":a(`projectActions.actions.chooseActionAria`),children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4`})})}),(0,$.jsxs)(ha,{align:`start`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(va,{className:`flex items-center gap-2`,onClick:de,children:[(0,$.jsx)(Z,{name:`add`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:a(`projectActions.actions.addNewAction`)})]}),(0,$.jsx)(La,{}),oe.map(e=>{let t=e.icon||`play`,n=e.id===Ru?`search`:vl[t]||`play`,r=yl(U,e.id),i=D[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(va,{className:`flex items-center gap-2`,onClick:()=>{ue(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 Wu(e){return e.isOpen&&e.activeTab===e.targetTab?{open:!1,tab:e.activeTab}:{open:!0,tab:e.targetTab}}var Gu=`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`,Ku=`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`,qu=Q.memo(function(e){let t=(0,Ll.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??Gu,p=d&&`bg-interactive-selection text-interactive-selection-foreground`,m;t[0]!==f||t[1]!==p?(m=J(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)($i,{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)(na,{children:[_,v]}),t[14]=_,t[15]=v,t[16]=y):y=t[16],y}),Ju=Q.memo(function(e){let t=(0,Ll.c)(42),{isMobile:n,githubAuthStatus:r,githubAccounts:i,githubAvatarUrl:a,githubLogin:o,isSwitchingGitHubAccount:s,handleGitHubAccountSwitch:c}=e,{t:l}=At();if(!r?.connected||n)return null;if(i.length>1){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=J(Gu,`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)(Ma,{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)(La,{}),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)(va,{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)(ha,{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)(_a,{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}),Yu=Q.memo(function(e){let t=(0,Ll.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}=At(),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=wt(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)(Ma,{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)(cs,{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)(ds,{})]})}):null,(0,$.jsx)(ni,{embedded:!0,open:i&&s===`instance`,onOpenChange:td,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:Zu(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)(cs,{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:J(`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:J(`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)(mo,{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=oc(e.entries,n),o=f===`remaining`?i.remainingPercent:i.usedPercent,s=i.disablePace?null:ma(i.usedPercent,i.resetAt,i.windowSeconds,r),c=s?.dailyAllocationPercent==null?null:f===`remaining`?100-Va(s.elapsedRatio):Va(s.elapsedRatio),l=da(i.valueLabel,o),u=sa(i.resetAt,i.resetAfterFormatted??i.resetAtFormatted,C);return(0,$.jsxs)(Q.Fragment,{children:[a?(0,$.jsx)(`div`,{className:J(`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:ra(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)(Bs,{percent:o,tonePercent:i.usedPercent,className:`h-1.5`,expectedMarkerPercent:c}),s&&S?(0,$.jsx)(Ms,{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)(pl,{open:i,onOpenChange:()=>x(e.providerId,r),children:[(0,$.jsxs)(fl,{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)(dl,{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=ma(r.usedPercent,r.resetAt,r.windowSeconds),o=a?.dailyAllocationPercent==null?null:f===`remaining`?100-Va(a.elapsedRatio):Va(a.elapsedRatio),s=da(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:As(n)}),(0,$.jsx)(`span`,{className:`typography-ui-label tabular-nums text-foreground`,children:s===`-`?``:s})]}),(0,$.jsx)(Bs,{percent:i,tonePercent:r.usedPercent,className:`h-1.5`,expectedMarkerPercent:o}),a&&S?(0,$.jsx)(Ms,{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)(ha,{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)(_a,{open:i,onOpenChange:k,children:[A,I]}),t[48]=i,t[49]=k,t[50]=I,t[51]=L):L=t[51],L}),Xu=(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??``),Zu=(e,t)=>{if(!e)return`-`;try{return la(e,t,{fallback:`-`})}catch{return`-`}},Qu=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},$u=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,ed=({onToggleLeftDrawer:e,onToggleRightDrawer:n,leftDrawerOpen:r,rightDrawerOpen:i})=>{let{t:a}=At(),o=q(e=>e.setSessionSwitcherOpen),s=q(e=>e.toggleSidebar),c=q(e=>e.isSidebarOpen),u=q(e=>e.toggleBottomTerminal),d=q(e=>e.toggleContextPanel),p=q(e=>e.openContextOverview),g=q(e=>e.openContextBrowser),_=q(e=>e.closeContextPanel),v=q(e=>e.activeMainTab),b=q(e=>e.setActiveMainTab),x=q(e=>e.shortcutOverrides),S=q(e=>e.timeFormatPreference),C=Zt(e=>e.getCurrentModel),E=dt(),D=Vn(e=>!!e.newSessionDraft?.open),O=Vn(e=>e.currentSessionId),A=$n(O??``),j=tn(O),N=kn(e=>e.activeProjectId?e.projects.find(t=>t.id===e.activeProjectId)??null:null),P=Q.useMemo(()=>{if(!N)return null;let e=N.path.split(/[\\/]/).filter(Boolean);return e[e.length-1]??null},[N]),F=Is(e=>e.results),I=Is(e=>e.fetchAllQuotas),z=Is(e=>e.isLoading),ee=Is(e=>e.lastUpdated),B=Is(e=>e.displayMode),ne=Is(e=>e.showPredValues),U=Is(e=>e.dropdownProviderIds),ie=Is(e=>e.loadSettings),ae=Is(e=>e.setDisplayMode),{isMobile:W}=Ka(),oe=ia().data??null,G=Ds(e=>e.setStatus),se=Q.useRef(null),[ce,le]=Q.useState(()=>typeof window>`u`?!1:w()),ue=Q.useMemo(()=>M(),[]),de=ce&&k()===`win32`,fe=Ga(),pe=Wl(),me=Q.useMemo(()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),[]),{usesFramelessChrome:he,side:ge}=qs(),_e=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`||le(w())},[]);let ve=C(),ye=ve&&typeof ve.limit==`object`&&ve.limit!==null?ve.limit:null,be=ye&&typeof ye.context==`number`?ye.context:0,xe=ye&&typeof ye.output==`number`?ye.output:0,Se=Zn(O??``,be,xe),Ce=D?null:Se,[we,Te]=Q.useState(null),Ee=!O||A;(0,Q.useEffect)(()=>{if(!O){Te(e=>e===null?e:null);return}if(Ce){Te(e=>Xu(e,Ce)?e:Ce);return}Ee&&Te(e=>e===null?e:null)},[Ce,O,Ee]);let De=q(e=>e.isSessionSwitcherOpen),Oe=oe?.connected?oe.user?.avatarUrl??null:null,ke=oe?.connected?oe.user?.login??null:null,Ae=oe?.accounts??[],[je,Me]=Q.useState(!1),[Ne,K]=Q.useState(!1),[Pe,Fe]=Q.useState(!1),[Ie,Le]=Q.useState(!1),[Re,ze]=Q.useState(`Local`),[Be,Ve]=Q.useState(!1),[He,Ue]=Q.useState(ce?`instance`:`usage`),[We,Ge]=Q.useState(`usage`);(0,Q.useEffect)(()=>{!ce&&He===`instance`&&Ue(`usage`)},[He,ce]);let Ke=Q.useMemo(()=>T(),[]),qe=!Ke&&v===`chat`&&!!we,Ye=we&&we.contextLimit>0?Math.min(999,we.totalTokens/we.contextLimit*100):0,Xe=wt(async()=>{if(!(typeof window>`u`||!ce))try{if(L()){ze(`Local`),Ve(!1);return}let e=l(),t=await re();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?te(n,H(e)):!1);if(m()!==n)return;if(Ve(!!n),a?.label?.trim()){ze(V(a.label.trim()));return}ze(`Instance`)}catch{ze(`Local`),Ve(!1)}});(0,Q.useEffect)(()=>{Xe()},[ce]),Os();let Ze=Is(e=>e.selectedModels),Qe=Is(e=>e.expandedFamilies),$e=Is(e=>e.toggleFamilyExpanded),et=Q.useMemo(()=>{let e=[];for(let t of ws(F)){if(!U.includes(t.id))continue;let n=F.find(e=>e?.providerId===t.id),r=n?.usage?.windows??{},i=n?.usage?.models,o=Xs(Object.entries(r),n?.usage?.accounts),s={providerId:t.id,providerName:t.name,entries:o,error:n&&!n.ok&&n.configured?n.error:void 0};if(i&&Object.keys(i).length>0){let e=Ze[t.id]??[],n=e.length>0,r=ks(i,t.id),o=Ns(t.id),c=Vs(o);s.modelFamilies=[];for(let t of c){let a=r.get(t.id)??[];if(a.length===0)continue;let o=n?a.filter(t=>e.includes(t)):a;if(o.length===0)continue;let c=[];for(let e of o){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&&s.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&&s.modelFamilies.push({familyId:null,familyLabel:a(`header.services.modelFamily.other`),models:e})}}(o.length>0||s.modelFamilies&&s.modelFamilies.length>0||s.error)&&e.push(s)}return e},[U,F,Ze,a]),nt=et.length>0;Q.useEffect(()=>{ie()},[ie]);let rt=Q.useCallback(async e=>{ae(e);try{await tt({usageDisplayMode:e})}catch(e){console.warn(`Failed to update usage display mode:`,e)}},[ae]),it=Q.useCallback(()=>{if(Ie)return;Le(!0);let e=new Promise(e=>setTimeout(e,500));Promise.all([I(),e]).finally(()=>{Le(!1)})},[I,Ie]),at=Vn(e=>O?e.worktreeMetadata.get(O)?.path??``:``),ot=Q.useMemo(()=>Qu(at||``),[at]),st=Q.useMemo(()=>Qu((typeof j?.directory==`string`?j.directory:``)||``),[j?.directory]),ct=Vn(e=>e.newSessionDraft?.open?Qu(e.newSessionDraft.bootstrapPendingDirectory??e.newSessionDraft.directoryOverride??``):``),lt=Q.useMemo(()=>ot||st||ct,[ct,st,ot]),ut=Ao(),ft=Q.useMemo(()=>Qu(ut||lt||N?.path||``),[N?.path,ut,lt]),pt=q(e=>Je(e,ft)),mt=!!pt?.isOpen,ht=wt(()=>d(ft)),gt=Q.useMemo(()=>{if(!O)return P??`Yuri`;let e=j?.title?.trim();return e&&e.length>0?e:`Untitled Session`},[P,j?.title,O]),_t=Q.useMemo(()=>Qu(lt||N?.path||``),[N?.path,lt]),vt=Q.useMemo(()=>N?{id:N.id,path:N.path}:null,[N]),yt=Q.useRef(null);Q.useEffect(()=>{!vt||!_t||(yt.current={projectRef:vt,directory:_t})},[_t,vt]);let bt=Q.useMemo(()=>vt&&_t?{projectRef:vt,directory:_t}:yt.current,[_t,vt]),xt=Q.useCallback(async e=>{if(!(!e||je)){Me(!0);try{let t=E.github?await E.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})();G(t)}catch(e){console.error(`Failed to switch GitHub account:`,e)}finally{Me(!1)}}},[je,E.github,G]),St=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()},[]),Ct=Q.useCallback(()=>{if(W){St(),o(!De);return}s()},[St,W,De,o,s]),Et=Q.useCallback(()=>{R(`desktop_open_draft_mini_chat_window`,{directory:Qu(lt||N?.path||``),projectId:N?.id??null,apiBaseUrl:m(),clientToken:t()}).catch(e=>{console.warn(`[header] failed to open draft mini chat window`,e)})},[N?.id,N?.path,lt]),Dt=Q.useCallback(()=>{if(D){Et();return}O&&R(`desktop_open_session_mini_chat_window`,{sessionId:O,directory:Qu(lt||N?.path||``),apiBaseUrl:m(),clientToken:t()}).catch(e=>{console.warn(`[header] failed to open session mini chat window`,e)})},[N?.path,O,Et,D,lt]),kt=Q.useCallback(()=>{let e=ft;if(e){if($u(pt)===`context`){_(e);return}p(e)}},[_,ft,pt,p]),jt=Q.useMemo(()=>ft?$u(pt)===`context`:!1,[ft,pt]),Mt=Q.useCallback(()=>{let e=ft;if(e){if($u(pt)===`browser`){_(e);return}g(e)}},[_,ft,pt,g]),Nt=Q.useMemo(()=>ft?$u(pt)===`browser`:!1,[ft,pt]),Pt=Gu,Ft=Ku,It=Q.useMemo(()=>Ne?`services`:r?`sessions`:i?`git`:v,[v,Ne,r,i]),Lt=Q.useCallback(()=>{K(!1),r&&e&&e(),i&&n&&n(),!e&&De&&o(!1)},[De,r,e,n,i,o]),Rt=Q.useCallback(()=>{r||K(!1),e?.()},[r,e]),Y=Q.useCallback(()=>{i||K(!1),n?.()},[n,i]),zt=Q.useMemo(()=>ce&&me&&!pe?`5.5rem`:fe?`max(calc(0.75rem + var(--yuri-wco-left-inset, 0px)), 5.5rem)`:(!ce||he)&&!Ke?`calc(0.75rem + var(--yuri-wco-left-inset, 0px))`:`0.75rem`,[ce,pe,me,fe,Ke,he]);(0,Q.useEffect)(()=>{typeof document>`u`||document.documentElement.style.setProperty(`--yuri-titlebar-left-inset`,zt)},[zt]);let Bt=c?`0.75rem`:`var(--yuri-titlebar-left-inset, 0.75rem)`,Vt=c?`0px`:`calc(var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`,Ht=Q.useMemo(()=>!ce||!me||_e===null?``:_e>=26?`h-12`:_e<=15?`h-14`:``,[ce,me,_e]),Ut=Q.useMemo(()=>{if(!(ce&&!he||Ke))return{paddingRight:mt?`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))`}},[ce,Ke,mt,he]),Wt=wt(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)});Tt(se,([e])=>{e&&Wt(e.borderBoxSize[0]?.blockSize??e.target.getBoundingClientRect().height)},{box:`border-box`}),Q.useLayoutEffect(()=>{Wt(se.current?.getBoundingClientRect().height)},[Wt,W,Ht]);let Gt=Q.useCallback(async e=>{let t=e.target;t.closest(`.app-region-no-drag`)||t.closest(`button, a, input, select, textarea`)||e.button===0&&ce&&await y()},[ce]),Kt=Q.useMemo(()=>{if(W){let e=[{id:`chat`,label:a(`layout.mainTab.chat`),icon:`chat-thread`}];return e.push({id:`diff`,label:a(`layout.mainTab.diff`),icon:`diff`},{id:`files`,label:a(`layout.mainTab.files`),icon:`folder-6`},{id:`terminal`,label:a(`layout.mainTab.terminal`),icon:`terminal-box`},{id:`diagram`,label:a(`layout.mainTab.diagram`),icon:`file`}),e}return[]},[W,a]),qt=Q.useCallback(e=>Pa(xa(e,x)),[x]);(0,Q.useEffect)(()=>{!W&&(v===`git`||v===`terminal`||v===`diff`||v===`files`)&&b(`chat`)},[v,W,b]);let Jt=Q.useMemo(()=>{let e=[];return ce&&e.push({value:`instance`,label:a(`layout.services.instance`),icon:(0,$.jsx)(Z,{name:`connection-local`,className:`h-3.5 w-3.5`})}),e.push({value:`usage`,label:a(`layout.services.usage`),icon:(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`})},{value:`mcp`,label:`MCP`,icon:(0,$.jsx)(Cs,{className:`h-3.5 w-3.5`})}),e},[ce,a]),Yt=Q.useMemo(()=>Jt.map(e=>({id:e.value,label:e.label,icon:e.icon})),[Jt]),Xt=Q.useMemo(()=>[{value:`usage`,label:a(`header.services.used`)},{value:`remaining`,label:a(`header.services.remaining`)}],[a]),Qt=Q.useMemo(()=>Xt.map(e=>({id:e.value,label:e.label})),[Xt]),$t=Q.useMemo(()=>[{id:`usage`,label:a(`layout.services.usage`),icon:(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`})},{id:`mcp`,label:`MCP`,icon:(0,$.jsx)(Cs,{className:`h-3.5 w-3.5`})}],[a]);(0,Q.useEffect)(()=>{let e=e=>{if(Ot(e)&&!e.shiftKey&&!e.altKey){let t=parseInt(e.key,10);t>=1&&t<=Kt.length&&(e.preventDefault(),W&&(St(),Lt()),b(Kt[t-1].id))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[St,Lt,W,b,Kt]);let en=wt(e=>{Ue(e),Fe(!0),Xe(),e===`usage`&&ee===null&&I()});(0,Q.useEffect)(()=>{let e=e=>{let t=xa(`toggle_services_menu`,x);if(ka(e,t)){e.preventDefault();let t=Wu({isOpen:Pe,activeTab:He,targetTab:ce?`instance`:`usage`});t.open?en(t.tab):Fe(!1);return}let n=xa(`cycle_services_tab`,x);if(ka(e,n)){e.preventDefault();let t=Jt.map(e=>e.value);if(t.length===0)return;let n=t.indexOf(He),r=t[n===-1?0:(n+1)%t.length];Ue(r),Fe(!0),Xe(),r===`usage`&&ee===null&&I();return}let r=xa(`open_usage`,x);if(ka(e,r)){e.preventDefault();let t=Wu({isOpen:Pe,activeTab:He,targetTab:`usage`});t.open?en(t.tab):Fe(!1);return}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[x,ce,Pe,He,Jt,ee,I,Xe,en]);let nn=e=>{let t=v===e.id,n=e.icon===`diff`,r=n?null:e.icon,i=e.id===`chat`,a=e=>n?(0,$.jsx)(Rl,{size:e}):r?(0,$.jsx)(Z,{name:r,className:`h-${e/4} w-${e/4}`}):null,o=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>b(e.id),className:J(`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&&!W&&`min-w-[100px] justify-center`),"aria-label":e.label,"aria-selected":t,role:`tab`,children:[W?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)},rn=ue&&(D||!!O),an=Q.useCallback(e=>{window.setTimeout(e,0)},[]),on=Q.useCallback(e=>{en(e)},[en]),sn=Q.useRef(null),cn=(0,$.jsxs)(`div`,{className:`relative flex shrink-0 items-center`,children:[(0,$.jsx)(`div`,{ref:sn,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center`,children:(0,$.jsxs)(_a,{children:[(0,$.jsxs)(na,{children:[(0,$.jsx)($i,{asChild:!0,children:(0,$.jsx)(Ma,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":a(`header.actions.sessionMenuAria`),className:J(Pt,`text-muted-foreground`),children:(0,$.jsx)(Z,{name:`more-2`,className:`h-[18px] w-[18px]`})})})}),(0,$.jsx)(ea,{children:(0,$.jsx)(`p`,{children:a(`header.actions.sessionMenu`)})})]}),(0,$.jsxs)(ha,{align:`start`,className:`min-w-[14rem]`,children:[rn?(0,$.jsxs)(va,{className:`flex items-center gap-2`,onClick:()=>an(Dt),children:[(0,$.jsx)(Z,{name:`picture-in-picture-2`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:a(D?`header.actions.newMiniChat`:`header.actions.openSessionMiniChat`)})]}):null,ce?(0,$.jsxs)(va,{className:`flex items-center gap-2`,onClick:()=>an(()=>on(`instance`)),children:[(0,$.jsx)(Z,{name:`stack`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:a(`header.actions.sessionMenu.servicesWithInstance`,{current:Re})}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:qt(`toggle_services_menu`)})]}):null,(0,$.jsxs)(va,{className:`flex items-center gap-2`,onClick:()=>an(()=>on(`usage`)),children:[(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:a(`header.actions.sessionMenu.viewUsage`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:qt(`open_usage`)})]}),(0,$.jsx)(La,{}),(0,$.jsxs)(va,{className:`flex items-center gap-2`,onClick:()=>an(u),children:[(0,$.jsx)(Z,{name:`terminal-box`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:a(`header.actions.toggleTerminalPanel`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:qt(`toggle_terminal`)})]}),(0,$.jsxs)(va,{className:`flex items-center gap-2`,onClick:()=>an(Mt),children:[(0,$.jsx)(Z,{name:`global`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:a(`contextPanel.browser.open`)}),Nt?(0,$.jsx)(Z,{name:`check`,className:`h-3.5 w-3.5 text-foreground`}):null]})]})]})}),(0,$.jsx)(Yu,{isDesktopApp:ce,currentInstanceSupportsUpdate:Be,isDesktopServicesOpen:Pe,setIsDesktopServicesOpen:Fe,refreshCurrentInstanceLabel:Xe,desktopServicesTab:He,setDesktopServicesTab:Ue,fetchAllQuotas:I,servicesTabItems:Yt,quotaLastUpdated:ee,quotaDisplayMode:B,showPredValues:ne,quotaDisplayTabItems:Qt,handleDisplayModeChange:rt,handleUsageRefresh:it,isQuotaLoading:z,isUsageRefreshSpinning:Ie,hasRateLimits:nt,rateLimitGroups:et,expandedFamilies:Qe,toggleFamilyExpanded:$e,timeFormatPreference:S,anchorRef:sn})]}),ln=(0,$.jsxs)($.Fragment,{children:[!W&&!Ke&&v===`chat`?(0,$.jsx)(ql,{}):null,(0,$.jsx)(wu,{directory:_t}),ce&&(0,$.jsx)(eu,{open:Pe&&He===`instance`,onClick:()=>en(`instance`)}),(0,$.jsx)(qu,{title:a(`header.actions.rightSidebarWithShortcut`,{shortcut:qt(`toggle_right_sidebar`)}),ariaLabel:a(`contextPanel.actions.togglePanel`),pressed:mt,onClick:ht,className:J(`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`,mt?`bg-interactive-selection text-interactive-selection-foreground`:`text-muted-foreground/75 hover:text-foreground`),Icon:`folder-3`,iconClassName:`size-4`}),(0,$.jsx)(Ju,{isMobile:W,githubAuthStatus:oe,githubAccounts:Ae,githubAvatarUrl:Oe,githubLogin:ke,isSwitchingGitHubAccount:je,handleGitHubAccountSwitch:xt})]}),un=()=>(0,$.jsxs)(`div`,{onMouseDown:Gt,className:J(`app-region-drag relative flex h-12 select-none items-center pr-3`,Ht),style:Ut,role:`tablist`,"aria-label":a(`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:Bt}}),(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:Vt}}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[(0,$.jsx)(`div`,{className:`app-region-no-drag mr-3 flex min-w-0 items-center gap-0.5`,children:(0,$.jsx)(Ks,{children:(0,$.jsx)(`button`,{type:`button`,"aria-label":a(`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:D?a(`sessions.switcher.draftTitle`):gt})})})}),Kt.length>0&&(0,$.jsx)(`div`,{className:`flex items-center gap-1 rounded-lg bg-[var(--surface-muted)]/50 p-1`,children:Kt.map(e=>nn(e))}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[cn,qe&&we?(0,$.jsx)(Ws,{pending:we.pending,totalTokens:we.totalTokens,percentage:Ye,colorPercentage:we.percentage,contextLimit:we.contextLimit,outputLimit:we.outputLimit??0,size:`compact`,appearance:`subtle`,onClick:kt,pressed:jt}):null,ln,(0,$.jsx)(Gs,{visible:he&&ge===`right`&&!mt,position:`right`})]})]})]}),dn=()=>(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:Rt,className:J(Ft,It===`sessions`&&`bg-interactive-selection text-interactive-selection-foreground`),"aria-label":a(r?`header.actions.closeSessionsAria`:`header.actions.openSessionsAria`),children:(0,$.jsx)(Z,{name:`layout-left`,className:`h-5 w-5`})}):De?(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(!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":a(`header.actions.backAria`),children:(0,$.jsx)(Z,{name:`arrow-left-s`,className:`h-5 w-5`})}):(0,$.jsx)(`button`,{type:`button`,onClick:Ct,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":a(`header.actions.openSessionsAria`),children:(0,$.jsx)(Z,{name:`play-list-add`,className:`h-5 w-5`})}),!e&&De&&(0,$.jsx)(`span`,{className:`typography-ui-label font-semibold text-foreground`,children:a(`header.sessions.title`)})]}),(!De||!!e)&&(0,$.jsxs)($.Fragment,{children:[(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":a(`header.navigation.mainAria`),children:Kt.map(e=>{let t=v===e.id,n=e.icon===`diff`,r=n?null:e.icon;return(0,$.jsxs)(na,{children:[(0,$.jsx)($i,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{W&&(St(),Lt()),b(e.id)},"aria-label":e.label,"aria-selected":t,role:`tab`,className:J(Ft,`relative rounded-lg`,It===e.id&&`bg-interactive-selection text-interactive-selection-foreground`),children:[n?(0,$.jsx)(Rl,{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":a(`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)(Ps,{mobile:!0}),bt&&(0,$.jsx)(Uu,{projectRef:bt.projectRef,directory:bt.directory,compact:!0,allowMobile:!0,className:`h-9`}),(0,$.jsxs)(_a,{open:Ne,onOpenChange:t=>{t&&(r&&e&&e(),i&&n&&n()),K(t),t&&ee===null&&I()},children:[(0,$.jsxs)(na,{children:[(0,$.jsx)($i,{asChild:!0,children:(0,$.jsx)(Ma,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":a(`header.services.viewAria`),className:J(Ft,It===`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:a(`header.services.title`)})})]}),(0,$.jsx)(ha,{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)(cs,{items:$t,activeId:We,onSelect:e=>{let t=e;Ge(t),t===`usage`&&ee===null&&I()},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:()=>K(!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":a(`header.services.closeAria`),children:(0,$.jsx)(Z,{name:`close`,className:`h-5 w-5`})})]})}),We===`mcp`&&(0,$.jsx)(bc,{active:Ne&&We===`mcp`}),We===`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:a(`header.services.rateLimits`)}),(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Zu(ee,S)})]}),(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:()=>rt(`usage`),className:J(`typography-ui-label px-1 pb-0.5 transition-colors`,B===`usage`?`text-foreground border-b-2 border-[var(--primary-base)]`:`text-muted-foreground hover:text-foreground`),children:a(`header.services.used`)}),(0,$.jsx)(`span`,{className:`text-muted-foreground typography-ui-label px-0.5`,children:`·`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>rt(`remaining`),className:J(`typography-ui-label px-1 pb-0.5 transition-colors`,B===`remaining`?`text-foreground border-b-2 border-[var(--primary-base)]`:`text-muted-foreground hover:text-foreground`),children:a(`header.services.remaining`)})]}),(0,$.jsx)(`button`,{type:`button`,className:J(`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:it,disabled:z||Ie,"aria-label":a(`header.services.refreshRateLimitsAria`),children:(0,$.jsx)(Z,{name:`refresh`,className:J(`h-4 w-4`,Ie&&`animate-spin`)})})]})]})}),!nt&&(0,$.jsx)(`div`,{className:`px-4 py-6 text-center`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:a(`header.services.noRateLimits`)})}),(0,$.jsx)(`div`,{className:`py-1`,children:et.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)(mo,{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??a(`header.services.noRateLimitsReported`)})}):(0,$.jsxs)(`div`,{className:`space-y-3 px-4 pb-2`,children:[e.entries.map(([t,n],r)=>{let i=oc(e.entries,r),a=B===`remaining`?n.remainingPercent:n.usedPercent,o=n.disablePace?null:ma(n.usedPercent,n.resetAt,n.windowSeconds,t),s=o?.dailyAllocationPercent==null?null:B===`remaining`?100-Va(o.elapsedRatio):Va(o.elapsedRatio),c=da(n.valueLabel,a),l=sa(n.resetAt,n.resetAfterFormatted??n.resetAtFormatted,S);return(0,$.jsxs)(Q.Fragment,{children:[i?(0,$.jsx)(`div`,{className:J(`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:ra(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)(Bs,{percent:a,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:s}),o&&ne?(0,$.jsx)(Ms,{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=(Qe[e.providerId]??[]).includes(t.familyId??`other`);return(0,$.jsxs)(pl,{open:n,onOpenChange:()=>$e(e.providerId,t.familyId??`other`),children:[(0,$.jsxs)(fl,{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)(dl,{children:(0,$.jsx)(`div`,{className:`space-y-2.5 pb-1 pl-1 pt-1`,children:t.models.map(([t,n])=>{let r=B===`remaining`?n.remainingPercent:n.usedPercent,i=ma(n.usedPercent,n.resetAt,n.windowSeconds),a=i?.dailyAllocationPercent==null?null:B===`remaining`?100-Va(i.elapsedRatio):Va(i.elapsedRatio),o=da(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:As(t)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground tabular-nums`,children:o===`-`?``:o})]}),(0,$.jsx)(Bs,{percent:r,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:a}),i&&ne?(0,$.jsx)(Ms,{paceInfo:i,compact:!0}):null]},`${e.providerId}-${t}`)})})})]},t.familyId??`other`)})})]})]},e.providerId))})]})]})})]}),n?(0,$.jsxs)(na,{children:[(0,$.jsx)($i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:Y,className:J(Ft,`relative`,It===`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]})]})]}),fn=J(`header-safe-area relative z-10 bg-background`,de&&`bg-[var(--surface-background)] backdrop-blur-none`,W&&`yuri-layout-divider-b`);return(0,$.jsx)($.Fragment,{children:(0,$.jsx)(`header`,{ref:se,className:fn,style:{"--padding-scale":`1`},children:W?dn():un()})})};function td(){}var nd=180,rd=640,id=110,ad=e=>{let t=(0,Ll.c)(44),{isOpen:n,isMobile:r,children:i}=e,{t:a}=At(),o=q(od),s=q(sd),c=q(cd),l=q(ld),[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(rd,Math.max(nd,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(rd,Math.max(nd,g.current+t));c(n)},t=()=>{p(!1),q.getState().bottomTerminalHeight<=id&&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=J(`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:J(`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=J(`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 od(e){return e.bottomTerminalHeight}function sd(e){return e.isBottomTerminalExpanded}function cd(e){return e.setBottomTerminalHeight}function ld(e){return e.setBottomTerminalOpen}var ud=260,dd=260,fd=500,pd=e=>Math.min(fd,Math.max(dd,e)),md=({isOpen:e,isMobile:t,children:n,className:r,topBar:i})=>{let{t:a}=At(),o=q(e=>e.sidebarWidth),s=q(e=>e.setSidebarWidth),[c,l]=Q.useState(!1),u=Q.useRef(0),d=Q.useRef(o||ud),f=Q.useRef(null),p=Q.useRef(null),m=Q.useRef(null),h=Q.useRef(null),g=wt(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(fd,Math.max(dd,o||ud)),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=pd(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=pd(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:J(`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:J(`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:J(`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)(Da,{children:n})})]})]})},hd=()=>{let e=(0,Ll.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},gd=e=>{let t=(0,Ll.c)(14),{className:n}=e,r=Fs(_d).trim(),i=r.split(/\s+/).filter(Boolean),a=i.includes(`Yuri`),o=i.some(vd);if(Q.useEffect(()=>{o&&ji()},[o]),i.length===0)return null;let s;t[0]===n?s=t[1]:(s=J(`flex min-w-0 items-center overflow-hidden px-2 pb-2 pt-1`,n),t[0]=n,t[1]=s);let c=i.join(` `),l=r.includes(`Yuri`)?`items-center`:`items-baseline`,u;t[2]===l?u=t[3]:(u=J(`inline-flex min-w-0 gap-[0.28em] overflow-hidden whitespace-nowrap text-foreground`,l),t[2]=l,t[3]=u);let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d={fontFamily:`"Syne", var(--font-sans, system-ui, sans-serif)`,fontSize:`1.0625rem`,fontWeight:700,letterSpacing:`0.08em`,lineHeight:1},t[4]=d):d=t[4];let f=r.includes(`Yuri`)?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0 self-center`,children:(0,$.jsx)(Wa,{width:24,height:24})}):null,p=i.map((e,t)=>(0,$.jsx)(`span`,{"aria-hidden":`true`,className:J(`inline-flex shrink-0 items-baseline`,!a&&t>0&&`text-primary`),children:e===`Yuri`?(0,$.jsx)(il,{width:`2.44814cap`}):e},t)),m;t[5]!==c||t[6]!==u||t[7]!==d||t[8]!==f||t[9]!==p?(m=(0,$.jsxs)(`span`,{role:`img`,"aria-label":c,className:u,style:d,children:[f,p]}),t[5]=c,t[6]=u,t[7]=d,t[8]=f,t[9]=p,t[10]=m):m=t[10];let h;return t[11]!==s||t[12]!==m?(h=(0,$.jsx)(`div`,{className:s,children:m}),t[11]=s,t[12]=m,t[13]=h):h=t[13],h};function _d(e){return e.sidebarBrandName}function vd(e){return e!==`Yuri`}var yd=`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`,bd=()=>{let e=(0,Ll.c)(48),{t}=At(),n=q(xd),r=q(Sd),i=q(Cd),a=q(wd),o=Fs(Td),s=Q.useRef(null),c=Pa(xa(`toggle_sidebar`,a)),{usesFramelessChrome:l,side:u}=qs(),d;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=w(),e[0]=d):d=e[0];let f=d,p=Wl(),m=!f||p||!n||!o,h;e[1]===p?h=e[2]:(h=!T()&&(f?p:v()),e[1]=p,e[2]=h);let g=h,_=Dd,y,b;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{if(typeof document>`u`)return;let e=s.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()}},b=[],e[3]=y,e[4]=b):(y=e[3],b=e[4]),Q.useEffect(y,b);let x=g&&n?`${r||260}px`:void 0,S;e[5]===x?S=e[6]:(S={height:`var(--yuri-header-height, 3rem)`,paddingLeft:`var(--yuri-titlebar-left-inset, 0.75rem)`,width:x},e[5]=x,e[6]=S);let C=g&&n&&`w-full justify-between`,E;e[7]===C?E=e[8]:(E=J(`flex items-center gap-2`,C),e[7]=C,e[8]=E);let D;e[9]!==n||e[10]!==g?(D=g&&n?(0,$.jsx)(gd,{className:`flex min-w-0 items-center p-0 pl-1.5`}):null,e[9]=n,e[10]=g,e[11]=D):D=e[11];let O;e[12]!==l||e[13]!==u?(O=l&&u===`left`?(0,$.jsx)(Gs,{visible:!0,position:`left`}):null,e[12]=l,e[13]=u,e[14]=O):O=e[14];let k;e[15]!==t||e[16]!==l?(k=l?(0,$.jsxs)(na,{children:[(0,$.jsx)($i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:_,"aria-label":t(`header.actions.openAppMenuAria`),className:J(yd,`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[15]=t,e[16]=l,e[17]=k):k=e[17];let A;e[18]===m?A=e[19]:(A=m?(0,$.jsx)(Fc,{}):null,e[18]=m,e[19]=A);let j=na,M;e[20]===t?M=e[21]:(M=t(`header.actions.openSessionsAria`),e[20]=t,e[21]=M);let N,P;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(N=J(yd,`group shrink-0`),P=(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[22]=N,e[23]=P):(N=e[22],P=e[23]);let F;e[24]!==M||e[25]!==i?(F=(0,$.jsx)($i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:i,"aria-label":M,className:N,children:P})}),e[24]=M,e[25]=i,e[26]=F):F=e[26];let I=ea,L=t(`header.actions.openSessionsWithShortcut`,{shortcut:c}),R;e[27]===L?R=e[28]:(R=(0,$.jsx)(`p`,{children:L}),e[27]=L,e[28]=R);let z;e[29]!==I||e[30]!==R?(z=(0,$.jsx)(I,{children:R}),e[29]=I,e[30]=R,e[31]=z):z=e[31];let ee;e[32]!==j||e[33]!==F||e[34]!==z?(ee=(0,$.jsxs)(j,{children:[F,z]}),e[32]=j,e[33]=F,e[34]=z,e[35]=ee):ee=e[35];let B;e[36]!==A||e[37]!==ee?(B=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[A,ee]}),e[36]=A,e[37]=ee,e[38]=B):B=e[38];let V;e[39]!==O||e[40]!==k||e[41]!==B||e[42]!==E||e[43]!==D?(V=(0,$.jsxs)(`div`,{ref:s,className:E,children:[D,O,k,B]}),e[39]=O,e[40]=k,e[41]=B,e[42]=E,e[43]=D,e[44]=V):V=e[44];let H;return e[45]!==V||e[46]!==S?(H=(0,$.jsx)(`div`,{className:`app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2`,style:S,children:V}),e[45]=V,e[46]=S,e[47]=H):H=e[47],H};function xd(e){return e.isSidebarOpen}function Sd(e){return e.sidebarWidth}function Cd(e){return e.toggleSidebar}function wd(e){return e.shortcutOverrides}function Td(e){return e.sidebarBrandName.trim().length>0}function Ed(e){console.warn(`[titlebar] failed to open app menu`,e)}function Dd(e){let t=e.currentTarget.getBoundingClientRect();R(`desktop_show_app_menu`,{x:t.left,y:t.bottom}).catch(Ed)}function Od(e){let t=(0,Ll.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({children:n,className:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=J(`relative isolate flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl bg-background shadow-sm [--background:oklch(from_var(--surface-background)_min(1,calc(l_+_0.015))_c_h)] dark:[--background:color-mix(in_srgb,var(--surface-foreground)_4%,var(--surface-background))]`,r),t[4]=r,t[5]=a);let o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`span`,{"aria-hidden":`true`,"data-workspace-surface-ring":!0,className:`pointer-events-none absolute inset-0 z-50 rounded-[inherit] ring-1 ring-inset ring-[var(--interactive-border)]`}),t[6]=o):o=t[6];let s;return t[7]!==n||t[8]!==i||t[9]!==a?(s=(0,$.jsxs)(`section`,{...i,"data-workspace-surface":!0,className:a,children:[n,o]}),t[7]=n,t[8]=i,t[9]=a,t[10]=s):s=t[10],s}var kd=(e,t)=>{let n=ht(t,e);return!n||n===`.`||n===t?0:n.split(`/`).filter(Boolean).length},Ad=(e,t,n=10)=>{let r=mt(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=mt(t.path);if(!e||i.has(e))continue;let o=kd(r,e);o<1||o>n||(i.add(e),a.push(e))}return a},jd=e=>e.some(e=>!!mt(e)),Md=(e,t)=>{let n=new Set(t.map(e=>mt(e)).filter(Boolean));return e.filter(e=>!n.has(e))},Nd=(e,t,n)=>t.length===0?e.length===0:Md(e,t).length>0?!1:t.every(e=>n.has(mt(e))),Pd=xo(()=>gt(()=>import(`./ToolOutputDialog-CxlFIAQ4.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78]))),Fd=e=>{let t=Rd(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},Id=e=>{let t=(0,Ll.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=J(`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},Ld=e=>e.slice().sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1),Rd=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},zd=e=>e.startsWith(`/`)||e.startsWith(`//`)||/^[A-Za-z]:\//.test(e),Bd=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,Vd=(e,t)=>{let n=Rd(t),r=Rd(e);if(!n||!r)return!1;let i=Bd(n),a=Bd(r);return a===i||a.startsWith(`${i}/`)},Hd=(e,t)=>{let n=Rd(t),r=Rd(e);if(!Vd(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},Ud=(e,t)=>{if(!t)return``;let n=Rd(t);if(!e||!Vd(n,e))return n;let r=n.slice(e.length);return r.startsWith(`/`)?r.slice(1):r},Wd=new Set([`node_modules`]),Gd=e=>{let t=(0,Ll.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},Kd=e=>{let t=(0,Ll.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},qd=e=>Wd.has(e),Jd=e=>{let t=Rd(e);return t===`node_modules`||t.endsWith(`/node_modules`)||t.includes(`/node_modules/`)},Yd=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`is a directory`)||t.includes(`eisdir`)},Xd=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`)},Zd=2e5,Qd=`yuri:files:auto-save-enabled`,$d=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-BhD4QiRH.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-auth-DBn9yahL.js","assets/runtime-switch-DEZ1K7qW.js","assets/runtime-fetch-D0YWp3FJ.js","assets/desktop-BAmoc_34.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-base-ui-CzHs0bHY.js","assets/useUIStore-B61bCFEM.js","assets/vendor-zustand-vDaAPGfl.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/vendor-react-DlzBev0S.js","assets/vendor-tanstack-react-query-B-Wpqq5J.js","assets/vendor-tanstack-query-core-Y_YoRHtC.js","assets/runtime-file-resource-BP4P52ry.js","assets/queryRuntime-2dx7jbt9.js","assets/fileQueries-C2Rs6TPz.js","assets/runtime-file-store-BVRgEtI-.js","assets/path-utils-jGozTg9d.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-download-D6bwc3Kj.js","assets/platform-sEg2IOLZ.js","assets/vendor-pierre-diffs-BFiZ3IhI.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/vendor-reactuses-core-DWo5Wn6R.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button-CPRnAdlm.js","assets/bootstrap-Bi91NjXG.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/runtime-ead7P81A.js","assets/store-Dvb_y7vz.js","assets/tour-DDI0Zg7l.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useThemeSystem-CNzUUkFn.js","assets/vendor-framer-motion-DDMKlXiP.js","assets/Icon-BNzwtZlI.js","assets/dialog-Dq8l3IQC.js","assets/dialog-CTYD3Sbr.css","assets/tap-LkQum5bB.js","assets/themes-BgDJcxRc.js","assets/MobileWindowStack-DGLdgoGr.js","assets/appThemeRegistry-2DEQy44q.js","assets/useMobileNavigationStore-D59MROJU.js","assets/gitApiHttp-CKrsk1tw.js","assets/vendor-opencode-client-cQ47ywrT.js","assets/vendor-effect-X1Hqc7ba.js","assets/vendor-sonner-BEHGipm5.js","assets/useAssistantUIStore-cHle1U5H.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/agentColors-DWSbQXy2.js","assets/rasterizePng-056Poix7.js","assets/MarkdownRenderer-BonJRvHM.js","assets/useEffectiveDirectory-DO311OTB.js","assets/markdownHeightCache-D0fP62uP.js","assets/dualLimitLru-D8Sphgua.js","assets/toolHelpers-iEHVHQ9p.js","assets/image-loading-DKQOYtti.js","assets/image-loading-D9Z_BASK.css","assets/ImageLoadingPlaceholder-CH4TCRvH.js","assets/useWorkerHighlightedLines-DaoXaYxw.js","assets/markdownTheme-CHNl6tUv.js","assets/markdown-worker-oBGEB9Eg.js","assets/vendor-tanstack-react-virtual-DSFNK3qc.js","assets/mobileBackNavigation-B-dgoPw6.js","assets/touch-gestures-CErgaXZ7.js","assets/ToolOutputDialog-CbGuK5bP.css","assets/TerminalView-BnR50Mgm.js","assets/terminalApi-Bo6KWljy.js","assets/vendor-ghostty-web-DbBrwBII.js","assets/device-w1ioiqv3.js","assets/OverlayScrollbar-5yODT_nG.js","assets/sortable-tabs-strip-lZ6K_9ug.js","assets/vendor-dnd-kit-core-DK4OoOTr.js","assets/vendor-dnd-kit-accessibility-BOtnpZt5.js","assets/vendor-dnd-kit-sortable-Cv69eQm1.js","assets/useFontPreferences-D-AOjd9H.js","assets/projectActions-BX0cjZoq.js","assets/DiagramView-xGg1oS8b.js","assets/diagram-O7VUqG75.js","assets/vendor-react-drawio-Dyg1-39Q.js","assets/SettingsView-BoDwWc6-.js","assets/desktopHosts-BLU1tGSX.js","assets/desktopRelayRestore-2BIIs8mZ.js","assets/types-DD3a5G5L.js","assets/native-config-CLcCZ6JT.js","assets/vendor-codemirror-autocomplete-C0FrlFqZ.js","assets/MobileShareBridge-CKDkjJIK.js","assets/MobileDetailNavigation-DacHr77a.js","assets/AgentAvatar-0zDTBIBH.js","assets/vendor-dicebear-core-CV95S5Pg.js","assets/vendor-dicebear-styles-C4OfoX7R.js","assets/gitApi-Dy__-dVB.js","assets/input-9A1m0Yjq.js","assets/tooltip-C25g1ojI.js","assets/pwa--whpkoe7.js","assets/vendor-simplewebauthn-browser-Dwhcdg_5.js","assets/MobileResizableSheet-DZ7Kq3ZS.js","assets/select-BNDVM5KL.js","assets/textarea-Ds63PD7U.js","assets/dropdown-menu.styles-BDla58Rm.js","assets/projectMeta-BYNpABmO.js","assets/YuriLogo-D7QXHCf6.js","assets/scheduledTaskNavigation-7dD6PWMD.js","assets/url-MRa-FtQa.js","assets/react-a6PrrNTm.js","assets/MobileTabPageHeader-CT5jeuHU.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-DcbmHgNY.js","assets/usePluginsStore-3VJgeLvf.js","assets/collapsible-CP7z1jKL.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/context-menu-B8yin969.js","assets/vendor-qrcode-D7jBCyl-.js","assets/vendor-dijkstrajs-BAzPDGZM.js","assets/VoiceSettings-BeMRGXfr.js","assets/useDictation-ozXiBIfG.js","assets/speechSettingsQueries-sb0ZHAri.js","assets/VoiceSettings-C0HSdVvS.css","assets/readiness-CafO-iNt.js","assets/GuiPluginWindow-B0oHkEwj.js","assets/vendor-yaml-C9KlJAlj.js","assets/SettingsWindow-BGPVsXUi.js","assets/MultiRunWindow-GFioSTDw.js","assets/multirun-VckoCH5p.js","assets/checkbox-DZkjNegP.js","assets/insertionBoundaries-DdpR3zaP.js","assets/fileMentionAutocompleteState-BZJqfgae.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/vendor-fuzzysort-ukaRp9PC.js","assets/fileMentionTouchSelection-B-oPBD2a.js","assets/AssistantView-DSnDwWGc.js","assets/sessionLookup-BI6ygHcL.js","assets/LoadingImage-C6jr50EL.js","assets/sessionLookup-8C8nv-EP.css","assets/AssistantContactStatus-CqBzrMI3.js","assets/vendor-motion-C9oiAdx-.js","assets/assistant-attachment-cache-oatc8F4t.js","assets/AssistantUnreadBadge-CqMHWeGm.js","assets/OnboardingScreen-DAiSh2kq.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-DBn9yahL.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-DEZ1K7qW.js";import{n as h}from"./runtime-fetch-D0YWp3FJ.js";import{A as g,B as _,E as v,G as y,J as b,L as x,M as S,Q as C,S as w,T,X as E,Y as D,Z as O,_ as k,j as A,k as j,n as M,o as N,t as P,v as F,w as I,x as L,y as R,z}from"./desktop-BAmoc_34.js";import{n as ee,t as B}from"./runtimeAPIRegistry-C2VogTny.js";import{_ as V,d as H,m as te,p as ne,r as re}from"./desktopHosts-BLU1tGSX.js";import{a as U,i as ie,t as ae}from"./vendor-zustand-vDaAPGfl.js";import{A as W,B as oe,L as G,M as se,R as ce,a as le,at as ue,d as de,f as fe,g as pe,h as me,i as he,k as ge,m as _e,ot as ve,p as ye,st as be,z as xe}from"./vendor-base-ui-CzHs0bHY.js";import{At as Se,Ct as Ce,Er as we,In as Te,Kn as Ee,Or as De,Rn as Oe,St as ke,_r as Ae,br as je,bt as Me,fn as Ne,gr as K,kr as Pe,kt as Fe,mn as Ie,wt as Le,xt as Re,yr as ze,yt as Be,zn as Ve}from"./gitApiHttp-CKrsk1tw.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{E as He,T as Ue,a as We,i as Ge,o as Ke,r as q,s as qe,t as Je,w as Ye}from"./useUIStore-B61bCFEM.js";import{A as Xe,Nt as Ze,a as Qe,ct as $e,k as et,o as tt,r as nt,t as rt}from"./bootstrap-Bi91NjXG.js";import{n as it,t as at}from"./vendor-react-DlzBev0S.js";import{l as ot}from"./vendor-tanstack-query-core-Y_YoRHtC.js";import{n as st,o as ct,s as lt}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{d as ut,u as dt}from"./fileQueries-C2Rs6TPz.js";import{r as ft,s as pt}from"./runtime-file-resource-BP4P52ry.js";import{a as mt,n as ht}from"./path-utils-jGozTg9d.js";import{o as gt}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as _t}from"./pathNormalization-ewtPqJWn.js";import{n as vt}from"./terminalApi-Bo6KWljy.js";import{a as yt}from"./types-DD3a5G5L.js";/* empty css */import{U as bt}from"./vendor-codemirror-autocomplete-C0FrlFqZ.js";import{a as xt}from"./vendor-pierre-diffs-BFiZ3IhI.js";import{a as St,h as Ct,i as wt,m as Tt,t as Et}from"./vendor-reactuses-core-DWo5Wn6R.js";import{a as Dt,c as Ot,d as kt,f as At,g as jt,h as Mt,i as Nt,l as Pt,m as Ft,o as It,p as Lt,r as J,s as Rt,t as Y}from"./button-CPRnAdlm.js";import{n as zt}from"./store-Dvb_y7vz.js";import{S as Bt,b as Vt,h as Ht}from"./MobileDetailNavigation-DacHr77a.js";import{$r as Ut,A as Wt,Bi as Gt,C as Kt,Ca as qt,Cr as Jt,Da as Yt,Ea as Xt,Ei as Zt,F as Qt,Ft as $t,Gr as en,H as tn,Hr as nn,I as rn,Kr as an,Kt as on,Lr as sn,Mn as cn,Qn as ln,Qr as un,R as dn,S as fn,Ta as pn,Tr as mn,U as hn,W as gn,Wr as _n,Xr as vn,Yr as yn,ai as bn,at as xn,b as Sn,bt as Cn,ct as wn,dr as Tn,ei as X,et as En,ft as Dn,g as On,ha as kn,ir as An,j as jn,jn as Mn,ka as Nn,kn as Pn,kr as Fn,m as In,mr as Ln,mt as Rn,or as zn,ot as Bn,p as Vn,pr as Hn,pt as Un,qr as Wn,qt as Gn,rn as Kn,rr as qn,sr as Jn,st as Yn,tr as Xn,tt as Zn,ur as Qn,ut as $n,vt as er,wi as tr,x as nr,y as rr,yt as ir}from"./useMobileNavigationStore-D59MROJU.js";import{n as ar}from"./useAssistantUIStore-cHle1U5H.js";import{n as or}from"./useThemeSystem-CNzUUkFn.js";import{n as sr,o as cr}from"./vendor-framer-motion-DDMKlXiP.js";import{n as Z,t as lr}from"./Icon-BNzwtZlI.js";import{a as ur,i as dr,n as fr,o as pr,r as mr,t as hr}from"./dialog-Dq8l3IQC.js";import{A as gr,C as _r,D as vr,O as yr,P as br,T as xr,V as Sr,a as Cr,f as wr,h as Tr,i as Er,j as Dr,k as Or,m as kr,o as Ar,p as jr,r as Mr,t as Nr,w as Pr,y as Fr}from"./gitApi-Dy__-dVB.js";import{$ as Ir,A as Lr,At as Rr,B as zr,Ct as Br,D as Vr,Dt as Hr,Et as Ur,Ft as Wr,H as Gr,I as Kr,It as qr,J as Jr,M as Yr,Mt as Xr,N as Zr,Nt as Qr,O as $r,Ot as ei,P as ti,Pt as ni,Rt as ri,S as ii,St as ai,Tt as oi,V as si,Z as ci,_ as li,_t as ui,at as di,b as fi,bt as pi,c as mi,ct as hi,d as gi,et as _i,f as vi,ft as yi,g as bi,h as xi,i as Si,it as Ci,j as wi,jt as Ti,k as Ei,kt as Di,l as Oi,m as ki,mt as Ai,n as ji,nt as Mi,ot as Ni,p as Pi,pt as Fi,q as Ii,rt as Li,s as Ri,st as zi,t as Bi,tt as Vi,u as Hi,v as Ui,vt as Wi,w as Gi,wt as Ki,x as qi,xt as Ji,y as Yi,yt as Xi,zt as Zi}from"./useAppFontEffects-BBRIHYET.js";import{t as Qi}from"./input-9A1m0Yjq.js";import{i as $i,n as ea,r as ta,t as na}from"./tooltip-C25g1ojI.js";import{A as ra,B as ia,Bt as aa,C as oa,D as sa,F as ca,I as la,J as ua,O as da,Q as fa,S as pa,T as ma,X as ha,Xt as ga,Y as _a,Z as va,_ as ya,c as ba,ct as xa,dt as Sa,f as Ca,g as wa,gt as Ta,h as Ea,ht as Da,i as Oa,it as ka,lt as Aa,m as ja,nt as Ma,o as Na,ot as Pa,p as Fa,s as Ia,tt as La,u as Ra,ut as za,v as Ba,w as Va,x as Ha,y as Ua}from"./pwa--whpkoe7.js";import{t as Wa}from"./YuriLogo-D7QXHCf6.js";import{a as Ga,r as Ka}from"./device-w1ioiqv3.js";import{r as qa}from"./themes-BgDJcxRc.js";import{f as Ja,g as Ya,h as Xa,p as Za}from"./scheduledTaskNavigation-7dD6PWMD.js";import{a as Qa,i as $a}from"./sessionLookup-BI6ygHcL.js";import{D as eo,E as to,_ as no,b as ro,f as io,g as ao,h as oo,m as so,v as co,y as lo}from"./insertionBoundaries-DdpR3zaP.js";import{c as uo,d as fo,i as po,l as mo,n as ho,s as go,t as _o}from"./select-BNDVM5KL.js";import{n as vo,t as yo}from"./appThemeRegistry-2DEQy44q.js";import{n as bo,o as xo}from"./MarkdownRenderer-BonJRvHM.js";import{a as So}from"./url-MRa-FtQa.js";import{a as Co,c as wo,i as To,l as Eo,o as Do,s as Oo}from"./toolHelpers-iEHVHQ9p.js";import{a as ko}from"./react-a6PrrNTm.js";import{n as Ao,t as jo}from"./useEffectiveDirectory-DO311OTB.js";import{t as Mo}from"./ImageLoadingPlaceholder-CH4TCRvH.js";import{t as No}from"./LoadingImage-C6jr50EL.js";import{_ as Po,i as Fo,l as Io,n as Lo,s as Ro,t as zo,v as Bo,y as Vo}from"./vendor-dnd-kit-core-DK4OoOTr.js";import{a as Ho,n as Uo,o as Wo,s as Go,t as Ko}from"./vendor-dnd-kit-sortable-Cv69eQm1.js";import{n as qo,r as Jo}from"./textarea-Ds63PD7U.js";import{i as Yo,n as Xo,r as Zo,t as Qo}from"./dropdown-menu.styles-BDla58Rm.js";import{a as $o,f as es,i as ts,l as ns,n as rs,p as is,s as as}from"./projectMeta-BYNpABmO.js";import{h as os}from"./useWorkerHighlightedLines-DaoXaYxw.js";import{t as ss}from"./vendor-tanstack-react-virtual-DSFNK3qc.js";import{t as cs}from"./sortable-tabs-strip-lZ6K_9ug.js";import{t as ls}from"./vendor-motion-C9oiAdx-.js";import{A as us,B as ds,C as fs,D as ps,E as ms,G as hs,H as gs,K as _s,O as vs,S as ys,T as bs,U as xs,W as Ss,Y as Cs,Z as ws,a as Ts,b as Es,c as Ds,f as Os,g as ks,h as As,k as js,l as Ms,m as Ns,n as Ps,o as Fs,p as Is,q as Ls,r as Rs,s as zs,u as Bs,v as Vs,w as Hs,y as Us}from"./MobileTabPageHeader-CT5jeuHU.js";import{i as Ws,n as Gs,r as Ks,t as qs}from"./useDesktopWindowControlsLayout-CTSEy8Ep.js";import{n as Js}from"./useFontPreferences-D-AOjd9H.js";import{$ as Ys,A as Xs,C as Zs,Ct as Qs,D as $s,E as ec,G as tc,J as nc,K as rc,M as ic,N as ac,O as oc,S as sc,St as cc,T as lc,Tt as uc,W as dc,X as fc,Y as pc,Z as mc,_ as hc,_t as gc,a as _c,at as vc,b as yc,bt as bc,c as xc,ct as Sc,d as Cc,dt as wc,et as Tc,f as Ec,ft as Dc,g as Oc,gt as kc,h as Ac,ht as jc,i as Mc,it as Nc,j as Pc,l as Fc,lt as Ic,mt as Lc,n as Rc,o as zc,p as Bc,pt as Vc,q as Hc,r as Uc,rt as Wc,s as Gc,st as Kc,tt as qc,u as Jc,ut as Yc,v as Xc,vt as Zc,w as Qc,wt as $c,x as el,xt as tl,y as nl,yt as rl}from"./runtimeEndpointReset-Bwm_RwzE.js";import{t as il}from"./YuriWordmark-CGDlDvEH.js";import{t as al}from"./AssistantUnreadBadge-CqMHWeGm.js";import{a as ol,i as sl,n as cl,r as ll,t as ul}from"./context-menu-B8yin969.js";import{n as dl,r as fl,t as pl}from"./collapsible-CP7z1jKL.js";import{n as ml,r as hl}from"./readiness-CafO-iNt.js";import{a as gl,o as _l,r as vl,s as yl,t as bl}from"./projectActions-BX0cjZoq.js";import{d as xl,i as Sl,n as Cl,r as wl,u as Tl}from"./historyImportQueries-C8VK9R5_.js";import{t as El}from"./diagram-O7VUqG75.js";import{a as Dl,i as Ol,n as kl,o as Al,r as jl,t as Ml}from"./multirun-VckoCH5p.js";import{t as Nl}from"./vendor-zumer-snapdom-yq9vlCKr.js";import{n as Pl,t as Fl}from"./vendor-html-to-image-BDMm2v6d.js";var Q=e(be(),1),Il=at(),Ll=it(),$=ve();function Rl(e){let t=(0,Ll.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 zl=!1,Bl=0,Vl=new Set,Hl=async()=>{let e=++Bl;try{let t=await R(`desktop_is_window_fullscreen`);if(e!==Bl||t===zl)return;zl=t===!0,Vl.forEach(e=>e())}catch{}},Ul=e=>w()?(Vl.add(e),Vl.size===1&&(window.addEventListener(`yuri:window-resized`,Hl),Hl()),()=>{Vl.delete(e),Vl.size===0&&(window.removeEventListener(`yuri:window-resized`,Hl),Bl++,zl=!1)}):()=>{};function Wl(){return(0,Q.useSyncExternalStore)(Ul,Kl,Gl)}function Gl(){return!1}function Kl(){return zl}function ql(){let e=(0,Ll.c)(19),{t}=At(),n=q(Ql),r=q(Zl),i=q(Xl),a=q(Yl),o=q(Jl),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=wt(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=J(`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 Jl(e){return e.setWorkStatusOverlayOpen}function Yl(e){return e.setWorkStatusPanelEnabled}function Xl(e){return e.workStatusOverlayOpen}function Zl(e){return e.workStatusPanelFits}function Ql(e){return e.workStatusPanelEnabled}var $l=(e,t,n)=>ct({queryKey:[`desktop-host-inventory`,e],queryFn:async({signal:e})=>{let r=await re(),i=new Set(r.sshHostIds??[]);if(r.sshHostIds===void 0&&P()){let e=await aa();for(let t of e.instances)i.add(t.id)}return e.throwIfAborted(),{hosts:r.hosts.filter(e=>ne(e,i)||t===`host:${e.id}`||!!(n&&te(n,H(e)))),sshIds:i}}});function eu(e){let t=(0,Ll.c)(18),{onClick:n,open:r}=e,{t:i}=At(),a=Q.useSyncExternalStore(s,l,l),o=q(tu),c=f(),u=m(),d=L(),{data:p}=lt({...$l(a,c,u),enabled:!o}),h=c.startsWith(`host:`)?c.slice(5):null,g=p?.hosts.find(e=>h?e.id===h:!!(u&&te(u,H(e))));if(d&&!p?.hosts.length&&!p?.sshIds.size)return null;let _=g?V(g.label):i(d?`desktopHostSwitcher.instance.local`:`desktopHostSwitcher.title`),v=Wr({isLocal:d,isSsh:!!(g&&p?.sshIds.has(g.id)),isRelay:a.startsWith(`relay:`)}),y=na,b=$i,x=Y,S=i(`header.actions.sessionMenu.servicesWithInstance`,{current:_}),C;t[0]===v?C=t[1]:(C=(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]=C);let w;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=(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]=w):w=t[2];let T;t[3]!==x||t[4]!==n||t[5]!==r||t[6]!==S||t[7]!==C?(T=(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":S,"aria-expanded":r,"aria-haspopup":`menu`,onClick:n,children:[C,w]}),t[3]=x,t[4]=n,t[5]=r,t[6]=S,t[7]=C,t[8]=T):T=t[8];let E;t[9]!==b||t[10]!==T?(E=(0,$.jsx)(b,{asChild:!0,children:T}),t[9]=b,t[10]=T,t[11]=E):E=t[11];let D;t[12]===_?D=t[13]:(D=(0,$.jsx)(ea,{children:_}),t[12]=_,t[13]=D);let O;return t[14]!==y||t[15]!==D||t[16]!==E?(O=(0,$.jsxs)(y,{children:[E,D]}),t[14]=y,t[15]=D,t[16]=E,t[17]=O):O=t[17],O}function tu(e){return e.isSettingsDialogOpen}var nu=[{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`}],ru=`finder`,iu=new Set([`finder`,`terminal`]),au=e=>typeof window<`u`&&window.__YURI_PLATFORM__===`win32`&&e.id===`finder`?{...e,label:`Explorer`,appName:`File Explorer`}:e,ou=e=>{if(!e)return null;let t=nu.find(t=>t.id===e)??null;return t?au(t):null},su=()=>nu.filter(e=>iu.has(e.id)).map(e=>({...au(e)})),cu=()=>{if(typeof window>`u`)return ru;let e=window.localStorage.getItem(`openInAppId`);return e&&ou(e)?e:ru},lu=!1,uu=!1,du=!1,fu=0,pu=null,mu=()=>{pu&&=(clearTimeout(pu),null)},hu=U()((e,t)=>({selectedAppId:cu(),availableApps:su(),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:su(),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:nu.filter(e=>r.has(e.appName)||iu.has(e.id)).map(e=>({...au(e),iconDataUrl:i.get(e.appName)})),hasLoadedApps:!0})},r=async i=>{if(!w()||uu||t().hasLoadedApps&&!i)return;let a=nu.map(e=>e.appName);mu(),i&&e({hasLoadedApps:!1}),uu=!0,du=!1,e({isScanning:!0});try{let{apps:t,success:o,hasCache:s,isCacheStale:c}=await N(a,i),l=o&&!s&&t.length===0&&fu<3;if(e({isCacheStale:s?c:!1}),n(t,o?!l:!1),o){if(l){let e=[800,1600,3200][fu]??3200;fu+=1,du=!0,pu=setTimeout(()=>{r()},e);return}fu=0,du=!1;return}if(fu<3){let e=[1e3,3e3,7e3][fu]??7e3;fu+=1,du=!0,pu=setTimeout(()=>{r()},e)}}finally{uu=!1,du||e({isScanning:!1})}};r(),window.addEventListener(`yuri:settings-synced`,t=>{let n=t.detail,r=n&&typeof n.openInAppId==`string`&&n.openInAppId.length>0&&ou(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)&&(fu=3,du=!1,e({isScanning:!1,isCacheStale:!1}),n(r))}),window.__yuriAppReady&&r(),window.setTimeout(()=>{t().hasLoadedApps||r()},5e3)},loadInstalledApps:async n=>{if(lu||t().initialize(),!w()||uu||t().hasLoadedApps&&!n)return;let r=nu.map(e=>e.appName);mu(),n&&e({hasLoadedApps:!1}),uu=!0,du=!1,e({isScanning:!0});try{let{apps:t,hasCache:i,isCacheStale:a}=await N(r,n),o=new Set(t.map(e=>e.name)),s=new Map(t.map(e=>[e.name,e.iconDataUrl??void 0])),c=nu.filter(e=>o.has(e.appName)||iu.has(e.id)).map(e=>({...e,iconDataUrl:s.get(e.appName)}));e({availableApps:c.length>0?c:su(),hasLoadedApps:c.length>0,isCacheStale:i?a:!1})}finally{uu=!1,du||e({isScanning:!1})}},selectApp:async t=>{ou(t)&&(e({selectedAppId:t}),typeof window<`u`&&window.localStorage.setItem(`openInAppId`,t),await tt({openInAppId:t}))}})),gu=(e=f(),t=l())=>{let n=e.startsWith(`host:`)?e.slice(5):null;return{queryKey:[t,`ssh-editor-apps`,n],enabled:w()&&F()&&n!==null,queryFn:async({signal:e})=>{let t=await R(`desktop_ssh_editor_apps`,{hostId:n});return e.throwIfAborted(),t?{hostId:n,appIds:t.appIds}:null}}},_u=()=>{let e=(0,Ll.c)(3),t=(0,Q.useSyncExternalStore)(s,f,vu),n=(0,Q.useSyncExternalStore)(s,l,yu),r;return e[0]!==t||e[1]!==n?(r=gu(t,n),e[0]=t,e[1]=n,e[2]=r):r=e[2],lt(r)};function vu(){return``}function yu(){return``}var bu=`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`,xu=`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`,Su=e=>({...e,fallbackIconDataUrl:e.id===`finder`&&window.__YURI_PLATFORM__!==`win32`?bu:e.id===`terminal`?xu:void 0}),Cu=e=>{let t=(0,Ll.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=J(`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},wu=({directory:e,className:t})=>{let{t:n}=At(),r=hu(e=>e.selectedAppId),i=hu(e=>e.availableApps),a=hu(e=>e.isCacheStale),o=hu(e=>e.isScanning),s=hu(e=>e.initialize),c=hu(e=>e.loadInstalledApps),l=hu(e=>e.selectApp),{data:u}=_u(),d=Q.useMemo(()=>u?i.filter(e=>u.appIds.includes(e.id)):i,[i,u]);Q.useEffect(()=>{s()},[s]);let f=w()&&L(),p=Q.useMemo(()=>{let e=d.find(e=>e.id===r)??d.find(e=>e.id===`finder`)??d[0];return e?Su(e):null},[d,r]);if(!f&&!u||!e)return null;let m=async t=>{try{let r=await S(e,t.id,t.appName,u?.hostId);!r&&!u?await A(e,t.appName):r||X.error(n(`filesView.toast.openInAppFailed`,{app:t.label}))}catch(e){X.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 kt(e)};return(0,$.jsxs)(`div`,{className:J(`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:J(`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)(Cu,{label:p.label,iconDataUrl:p.iconDataUrl,fallbackIconDataUrl:p.fallbackIconDataUrl}):(0,$.jsx)(Z,{name:`file-copy`,className:`h-4 w-4`})}),(0,$.jsxs)(_a,{children:[(0,$.jsx)(Ma,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:J(`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)(ha,{align:`end`,className:`w-56 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(va,{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)(La,{}),d.map(e=>{let t=Su(e);return(0,$.jsxs)(va,{className:`flex items-center gap-2`,onClick:()=>void h(e),children:[(0,$.jsx)(Cu,{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)(va,{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]})]})]})},Tu=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Eu=[`dev`,`start`,`preview`,`serve`];async function Du(e,t,n){if(!e)return null;let r=Au(t);if(r)return{command:r.command,label:r.name||`Start Preview`,actionId:r.id};if(n){let t=ju(n);if(t){let n=await Mu(e);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 Ou(e)){let e=await ku(),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 Ou(e){let t=await Nu(`${e}/index.html`,e);return typeof t==`string`&&t.trim().length>0}async function ku(){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 Au(e){for(let t of e){let e=`${t.name} ${t.command}`.toLowerCase();if(Eu.some(t=>e.includes(t)))return t}return null}function ju(e){for(let{pattern:t}of Tu)for(let n of Object.keys(e))if(t.test(n))return n;return null}async function Mu(e){let t=await Nu(`${e}/package.json`,e);if(t)try{let e=JSON.parse(t),n=typeof e.packageManager==`string`?e.packageManager.toLowerCase():``;if(n.startsWith(`bun@`))return`bun`;if(n.startsWith(`pnpm@`))return`pnpm`;if(n.startsWith(`yarn@`))return`yarn`;if(n.startsWith(`npm@`))return`npm`}catch{}for(let[t,n]of[[`bun.lock`,`bun`],[`bun.lockb`,`bun`],[`pnpm-lock.yaml`,`pnpm`],[`yarn.lock`,`yarn`],[`package-lock.json`,`npm`]]){let r=await Nu(`${e}/${t}`,e);if(typeof r==`string`&&r.trim().length>0)return n}return`npm`}async function Nu(e,t){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 n=B()?.files;if(n?.readFile)try{let t=await n.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 Pu(e){try{let t=await Nu(`${e}/package.json`,e);if(t==null)return null;let n=JSON.parse(t).scripts;return n&&typeof n==`object`&&!Array.isArray(n)?n:null}catch{return null}}var Fu=e=>new Promise(t=>{window.setTimeout(t,e)}),Iu=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),Lu=/https?:\/\/[^\s<>'"`]+/gi,Ru=`__yuri_auto_discover_preview__`,zu=15e3,Bu=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},Vu=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}},Hu=e=>{let t=e.replace(Iu,``).match(Lu);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},Uu=({projectRef:e,directory:t,className:n,compact:r=!1,allowMobile:i=!1})=>{let{t:a}=At(),{terminal:o,runtime:s}=dt(),{isMobile:c}=Ka(),l=Q.useMemo(()=>w(),[]),u=Es(e=>e.instances),d=Es(e=>e.load),f=q(e=>e.setBottomTerminalOpen),p=q(e=>e.setActiveMainTab),m=q(e=>e.setSettingsPage),h=q(e=>e.setSettingsDialogOpen),g=q(e=>e.setSettingsProjectsSelectedId),_=q(e=>e.openContextPreview),v=Js(e=>e.sessions),y=Js(e=>e.ensureDirectory),b=Js(e=>e.setTabLabel),x=Js(e=>e.setTabIconKey),S=Js(e=>e.setActiveTab),C=Js(e=>e.setConnecting),T=Js(e=>e.setTabSessionId),E=Js(e=>e.setTabPreviewUrl),D=Js(e=>e.projectActionRuns),O=Js(e=>e.setProjectActionRun),k=Js(e=>e.updateProjectActionRunStatus),A=Js(e=>e.removeProjectActionRun),[j,M]=Q.useState([]),[N,P]=Q.useState(null),[F,I]=Q.useState(!1),L=Q.useRef({}),R=Q.useRef({}),z=Q.useRef({}),ee=Q.useRef({}),B=Q.useRef(0),V=e?.id??null,H=e?.path??``,te=Q.useMemo(()=>V?{id:V,path:H}:null,[V,H]);Q.useEffect(()=>{l&&d().catch(()=>void 0)},[l,d]);let ne=Q.useCallback(async e=>{await So(e)},[]),re=Q.useCallback(async()=>{if(!te)return;let e=B.current+1;B.current=e,I(!0);try{let t=await Ln(te);if(B.current!==e)return;let n=t.actions;M(n),P(e=>e===Ru||e&&n.some(t=>t.id===e)?e:null)}catch{if(B.current!==e)return}finally{B.current===e&&I(!1)}},[te]),U=Q.useMemo(()=>gl(t||te?.path||``),[t,te?.path]),ie=Q.useMemo(()=>N?j.find(e=>e.id===N)??null:null,[j,N]),ae=Q.useMemo(()=>({id:Ru,name:a(`projectActions.actions.autoDiscover`),command:``,icon:`search`,autoOpenUrl:!0}),[a]),W=!c,oe=Q.useMemo(()=>W?[ae,...j]:j,[j,ae,W]);Q.useEffect(()=>{re()},[re]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;V&&(t?.projectId&&t.projectId!==V||re())};return window.addEventListener(bl,e),()=>{window.removeEventListener(bl,e)}},[re,V]),Q.useEffect(()=>{N&&(N===Ru&&W||j.some(e=>e.id===N)||P(null))},[j,W,N]),Q.useEffect(()=>{for(let[e,t]of Object.entries(D)){let n=v.get(t.directory)?.tabs.find(e=>e.id===t.tabId);(!n||n.terminalSessionId!==t.sessionId)&&A(e)}},[D,A,v]),Q.useEffect(()=>{for(let[e,t]of Object.entries(D)){let n=R.current[e]??{lastSeenChunkId:null,openedUrl:!1,tail:``,openInPreview:!1};R.current[e]=n;let r=oe.find(e=>e.id===t.actionId);if(!r)continue;let i=v.get(t.directory)?.tabs.find(e=>e.id===t.tabId);if(!i||!Array.isArray(i.bufferChunks)||i.bufferChunks.length===0)continue;let o=i.bufferChunks.filter(e=>n.lastSeenChunkId===null||e.id>n.lastSeenChunkId);if(o.length===0)continue;let s=o.map(e=>e.data).join(``),c=`${n.tail}${s}`,l=!n.openedUrl&&r.autoOpenUrl===!0?Hu(c):null;if(n.lastSeenChunkId=o[o.length-1]?.id??n.lastSeenChunkId,n.tail=c.slice(-512),l)if(n.openedUrl=!0,n.openInPreview){let t=D[e];t&&(E(t.directory,t.tabId,l,{locked:!1,autoOpened:!1}),t.status===`waiting-for-preview`&&k(e,`running`),window.clearTimeout(ee.current[e]),delete ee.current[e],_(t.directory,l))}else ne(l),X.success(a(`projectActions.toast.openedUrlFromOutput`));R.current[e]=n}for(let e of Object.keys(R.current))D[e]||(delete R.current[e],window.clearTimeout(ee.current[e]),delete ee.current[e])},[oe,_,ne,D,E,a,v,k]);let G=Q.useCallback(async(e,t={})=>{if(!U)throw Error(a(`projectActions.error.noActiveDirectory`));let n=yl(U,e.id);y(U);let r=Js.getState(),i=r.getDirectoryState(U),o=L.current[n]||null,s=o?!!i?.tabs.some(e=>e.id===o):!1;(!o||!s)&&(o=r.createTab(U),L.current[n]=o),b(U,o,`Action: ${e.name}`),x(U,o,e.icon||`play`),t.revealTerminal!==!1&&(S(U,o),f(!0),p(`terminal`));let c=Js.getState().getDirectoryState(U)?.tabs.find(e=>e.id===o);return{key:n,tabId:o,sessionId:c?.terminalSessionId??null}},[y,U,p,S,f,x,b,a]),se=Q.useCallback(async e=>{if(s.isVSCode||!i&&c)return;if(!U){X.error(a(`projectActions.error.noActiveDirectoryForAction`));return}let t=yl(U,e.id),n=D[t];if(!(n&&n.status===`running`))try{let t=e.id===Ru?await(async()=>{let[e,t]=await Promise.all([Ln({id:te?.id??``,path:U}),Pu(U)]),n=await Du(U,e.actions,t);if(!n)throw Error(a(`contextPanel.preview.noDevServer`));return{id:Ru,name:a(`projectActions.actions.autoDiscover`),command:n.command,icon:`search`,autoOpenUrl:!0,openUrl:n.previewUrlHint||``}})():e,n=t.autoOpenUrl===!0&&(t.openUrl||``).trim().length>0,{key:r,tabId:i,sessionId:s}=await G(t,{revealTerminal:!n&&e.id!==Ru}),c=s,d=!1;if(!c){C(U,i,!0);try{c=(await o.createSession({cwd:U})).sessionId,d=!0,T(U,i,c)}finally{C(U,i,!1)}}if(!c)throw Error(a(`projectActions.error.failedToCreateTerminalSession`));d&&await Fu(350),t.id===Ru&&(z.current[r]?.(),C(U,i,!0),z.current[r]=vt(c,e=>{e.type===`data`&&typeof e.data==`string`&&e.data.length>0&&Js.getState().appendToBuffer(U,i,e.data),e.type===`exit`&&(Js.getState().setTabLifecycle(U,i,`exited`),Js.getState().setConnecting(U,i,!1),Js.getState().removeProjectActionRun(r),delete R.current[r],z.current[r]?.(),delete z.current[r],window.clearTimeout(ee.current[r]),delete ee.current[r])},()=>{Js.getState().setConnecting(U,i,!1)},{maxRetries:60,initialRetryDelay:250,maxRetryDelay:2e3,connectionTimeout:5e3}));let f=t.autoOpenUrl===!0&&l&&(t.desktopOpenSshForward||``).trim().length>0,p=t.autoOpenUrl?Vu(t.openUrl):null,m=t.autoOpenUrl&&l?_l(t.desktopOpenSshForward,u):null;O({key:r,directory:U,actionId:t.id,tabId:i,sessionId:c,status:t.id===Ru&&!p?`waiting-for-preview`:`running`}),window.clearTimeout(ee.current[r]),delete ee.current[r],t.id===Ru&&!p&&(ee.current[r]=window.setTimeout(()=>{Js.getState().updateProjectActionRunStatus(r,`running`),delete ee.current[r]},zu)),m?(E(U,i,null,{locked:!0}),ne(m),X.success(a(`projectActions.toast.openedForwardedUrl`))):p?(E(U,i,p,{locked:!0,autoOpened:!0}),_(U,p),X.success(a(`projectActions.toast.openedActionUrl`))):n?(E(U,i,null,{locked:!0}),X.error(a(`projectActions.error.invalidCustomUrlFormat`))):f?(E(U,i,null,{locked:!0}),X.error(a(`projectActions.error.selectedDesktopSshForwardUnavailable`))):E(U,i,null,{locked:!1,autoOpened:!1}),R.current[r]={lastSeenChunkId:null,openedUrl:!!m||!!p||n,tail:``,openInPreview:t.id===Ru};let h=Bu(t.command.trim().replace(/\r\n|\r/g,`
|
|
3
|
+
`));await o.sendInput(c,`${h}\r`)}catch(e){A(t),delete R.current[t],z.current[t]?.(),delete z.current[t],window.clearTimeout(ee.current[t]),delete ee.current[t],X.error(e instanceof Error?e.message:a(`projectActions.error.failedToRunAction`))}},[u,G,i,c,l,U,ne,_,D,s.isVSCode,A,C,O,E,T,te?.id,a,o]),ce=Q.useCallback(async e=>{let t=yl(U,e.id),n=D[t];if(n){k(t,`stopping`);try{await o.sendInput(n.sessionId,``)}catch{}if(await new Promise(e=>{window.setTimeout(e,1e3)}),Js.getState().getDirectoryState(n.directory)?.tabs.find(e=>e.id===n.tabId)?.terminalSessionId===n.sessionId){if(typeof o.forceKill==`function`)try{await o.forceKill({sessionId:n.sessionId})}catch{}else try{await o.close(n.sessionId)}catch{}T(n.directory,n.tabId,null)}A(t),delete R.current[t],z.current[t]?.(),delete z.current[t],window.clearTimeout(ee.current[t]),delete ee.current[t]}},[U,D,A,T,o,k]),le=Q.useCallback(()=>{let e=ie??oe[0];if(!e)return;let t=yl(U,e.id),n=D[t];if(n?.status!==`stopping`){if(n){ce(e);return}se(e)}},[oe,U,se,D,ie,ce]),ue=Q.useCallback((e,t=!1)=>{if(P(e.id),!t){se(e);return}let n=yl(U,e.id),r=D[n];if(r?.status!==`stopping`){if(r){ce(e);return}se(e)}},[U,se,D,ce]),de=Q.useCallback(()=>{te?.id&&(g(te.id),m(`projects`),h(!0))},[h,m,g,te?.id]);if(s.isVSCode||!i&&c||!te||!U)return null;let fe=ie??oe[0]??null;if(!fe)return null;let pe=fe.icon||`play`,me=fe.id===Ru?`search`:vl[pe]||`play`,he=D[yl(U,fe.id)],ge=he?.status===`stopping`,_e=he?.status===`waiting-for-preview`,ve=he?v.get(he.directory)?.tabs.find(e=>e.id===he.tabId)?.previewUrl??null:null,ye=!!(he&&ve),be=()=>{!he||!ve||_(he.directory,ve)};return r?(0,$.jsxs)(`div`,{className:`inline-flex items-center`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:F||ge,className:J(`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:le,"aria-label":a(he?`projectActions.actions.stopNamedAria`:`projectActions.actions.runNamedAria`,{name:fe.name}),children:ge||_e?(0,$.jsx)(Z,{name:`loader-4`,className:`h-5 w-5 animate-spin text-[var(--status-warning)]`}):he?(0,$.jsx)(Z,{name:`stop`,className:`h-5 w-5 text-[var(--status-warning)]`}):(0,$.jsx)(Z,{name:me,className:`h-5 w-5`})}),ye?(0,$.jsxs)(na,{children:[(0,$.jsx)($i,{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":a(`projectActions.actions.openPreview`),onClick:be,children:(0,$.jsx)(Z,{name:`global`,className:`h-4 w-4`})})}),(0,$.jsx)(ea,{sideOffset:6,children:a(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(_a,{children:[(0,$.jsx)(Ma,{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":a(`projectActions.actions.chooseActionAria`),children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-3.5 w-3.5`})})}),(0,$.jsxs)(ha,{align:`end`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(va,{className:`flex items-center gap-2`,onClick:de,children:[(0,$.jsx)(Z,{name:`add`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:a(`projectActions.actions.addNewAction`)})]}),(0,$.jsx)(La,{}),oe.map(e=>{let t=e.icon||`play`,n=e.id===Ru?`search`:vl[t]||`play`,r=yl(U,e.id),i=D[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(va,{className:`flex items-center gap-2`,onClick:()=>{ue(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:J(`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:le,disabled:F||ge,className:J(`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":a(he?`projectActions.actions.stopNamedAria`:`projectActions.actions.runNamedAria`,{name:fe.name}),children:(0,$.jsx)(`span`,{className:`inline-flex h-4 w-4 shrink-0 items-center justify-center`,children:ge||_e?(0,$.jsx)(Z,{name:`loader-4`,className:`h-4 w-4 animate-spin text-[var(--status-warning)]`}):he?(0,$.jsx)(Z,{name:`stop`,className:`h-4 w-4 text-[var(--status-warning)]`}):(0,$.jsx)(Z,{name:me,className:`h-4 w-4`})})}),ye?(0,$.jsxs)(na,{children:[(0,$.jsx)($i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:be,className:J(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":a(`projectActions.actions.openPreview`),children:(0,$.jsx)(Z,{name:`global`,className:`h-4 w-4`})})}),(0,$.jsx)(ea,{sideOffset:6,children:a(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(_a,{children:[(0,$.jsx)(Ma,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:J(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":a(`projectActions.actions.chooseActionAria`),children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4`})})}),(0,$.jsxs)(ha,{align:`start`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(va,{className:`flex items-center gap-2`,onClick:de,children:[(0,$.jsx)(Z,{name:`add`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:a(`projectActions.actions.addNewAction`)})]}),(0,$.jsx)(La,{}),oe.map(e=>{let t=e.icon||`play`,n=e.id===Ru?`search`:vl[t]||`play`,r=yl(U,e.id),i=D[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(va,{className:`flex items-center gap-2`,onClick:()=>{ue(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 Wu(e){return e.isOpen&&e.activeTab===e.targetTab?{open:!1,tab:e.activeTab}:{open:!0,tab:e.targetTab}}var Gu=`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`,Ku=`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`,qu=Q.memo(function(e){let t=(0,Ll.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??Gu,p=d&&`bg-interactive-selection text-interactive-selection-foreground`,m;t[0]!==f||t[1]!==p?(m=J(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)($i,{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)(na,{children:[_,v]}),t[14]=_,t[15]=v,t[16]=y):y=t[16],y}),Ju=Q.memo(function(e){let t=(0,Ll.c)(42),{isMobile:n,githubAuthStatus:r,githubAccounts:i,githubAvatarUrl:a,githubLogin:o,isSwitchingGitHubAccount:s,handleGitHubAccountSwitch:c}=e,{t:l}=At();if(!r?.connected||n)return null;if(i.length>1){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=J(Gu,`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)(Ma,{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)(La,{}),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)(va,{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)(ha,{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)(_a,{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}),Yu=Q.memo(function(e){let t=(0,Ll.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}=At(),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=wt(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)(Ma,{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)(cs,{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)(ds,{})]})}):null,(0,$.jsx)(ni,{embedded:!0,open:i&&s===`instance`,onOpenChange:td,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:Zu(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)(cs,{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:J(`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:J(`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)(mo,{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=oc(e.entries,n),o=f===`remaining`?i.remainingPercent:i.usedPercent,s=i.disablePace?null:ma(i.usedPercent,i.resetAt,i.windowSeconds,r),c=s?.dailyAllocationPercent==null?null:f===`remaining`?100-Va(s.elapsedRatio):Va(s.elapsedRatio),l=da(i.valueLabel,o),u=sa(i.resetAt,i.resetAfterFormatted??i.resetAtFormatted,C);return(0,$.jsxs)(Q.Fragment,{children:[a?(0,$.jsx)(`div`,{className:J(`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:ra(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)(Bs,{percent:o,tonePercent:i.usedPercent,className:`h-1.5`,expectedMarkerPercent:c}),s&&S?(0,$.jsx)(Ms,{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)(pl,{open:i,onOpenChange:()=>x(e.providerId,r),children:[(0,$.jsxs)(fl,{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)(dl,{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=ma(r.usedPercent,r.resetAt,r.windowSeconds),o=a?.dailyAllocationPercent==null?null:f===`remaining`?100-Va(a.elapsedRatio):Va(a.elapsedRatio),s=da(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:As(n)}),(0,$.jsx)(`span`,{className:`typography-ui-label tabular-nums text-foreground`,children:s===`-`?``:s})]}),(0,$.jsx)(Bs,{percent:i,tonePercent:r.usedPercent,className:`h-1.5`,expectedMarkerPercent:o}),a&&S?(0,$.jsx)(Ms,{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)(ha,{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)(_a,{open:i,onOpenChange:k,children:[A,I]}),t[48]=i,t[49]=k,t[50]=I,t[51]=L):L=t[51],L}),Xu=(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??``),Zu=(e,t)=>{if(!e)return`-`;try{return la(e,t,{fallback:`-`})}catch{return`-`}},Qu=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},$u=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,ed=({onToggleLeftDrawer:e,onToggleRightDrawer:n,leftDrawerOpen:r,rightDrawerOpen:i})=>{let{t:a}=At(),o=q(e=>e.setSessionSwitcherOpen),s=q(e=>e.toggleSidebar),c=q(e=>e.isSidebarOpen),u=q(e=>e.toggleBottomTerminal),d=q(e=>e.toggleContextPanel),p=q(e=>e.openContextOverview),g=q(e=>e.openContextBrowser),_=q(e=>e.closeContextPanel),v=q(e=>e.activeMainTab),b=q(e=>e.setActiveMainTab),x=q(e=>e.shortcutOverrides),S=q(e=>e.timeFormatPreference),C=Zt(e=>e.getCurrentModel),E=dt(),D=Vn(e=>!!e.newSessionDraft?.open),O=Vn(e=>e.currentSessionId),A=$n(O??``),j=tn(O),N=kn(e=>e.activeProjectId?e.projects.find(t=>t.id===e.activeProjectId)??null:null),P=Q.useMemo(()=>{if(!N)return null;let e=N.path.split(/[\\/]/).filter(Boolean);return e[e.length-1]??null},[N]),F=Is(e=>e.results),I=Is(e=>e.fetchAllQuotas),z=Is(e=>e.isLoading),ee=Is(e=>e.lastUpdated),B=Is(e=>e.displayMode),ne=Is(e=>e.showPredValues),U=Is(e=>e.dropdownProviderIds),ie=Is(e=>e.loadSettings),ae=Is(e=>e.setDisplayMode),{isMobile:W}=Ka(),oe=ia().data??null,G=Ds(e=>e.setStatus),se=Q.useRef(null),[ce,le]=Q.useState(()=>typeof window>`u`?!1:w()),ue=Q.useMemo(()=>M(),[]),de=ce&&k()===`win32`,fe=Ga(),pe=Wl(),me=Q.useMemo(()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),[]),{usesFramelessChrome:he,side:ge}=qs(),_e=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`||le(w())},[]);let ve=C(),ye=ve&&typeof ve.limit==`object`&&ve.limit!==null?ve.limit:null,be=ye&&typeof ye.context==`number`?ye.context:0,xe=ye&&typeof ye.output==`number`?ye.output:0,Se=Zn(O??``,be,xe),Ce=D?null:Se,[we,Te]=Q.useState(null),Ee=!O||A;(0,Q.useEffect)(()=>{if(!O){Te(e=>e===null?e:null);return}if(Ce){Te(e=>Xu(e,Ce)?e:Ce);return}Ee&&Te(e=>e===null?e:null)},[Ce,O,Ee]);let De=q(e=>e.isSessionSwitcherOpen),Oe=oe?.connected?oe.user?.avatarUrl??null:null,ke=oe?.connected?oe.user?.login??null:null,Ae=oe?.accounts??[],[je,Me]=Q.useState(!1),[Ne,K]=Q.useState(!1),[Pe,Fe]=Q.useState(!1),[Ie,Le]=Q.useState(!1),[Re,ze]=Q.useState(`Local`),[Be,Ve]=Q.useState(!1),[He,Ue]=Q.useState(ce?`instance`:`usage`),[We,Ge]=Q.useState(`usage`);(0,Q.useEffect)(()=>{!ce&&He===`instance`&&Ue(`usage`)},[He,ce]);let Ke=Q.useMemo(()=>T(),[]),qe=!Ke&&v===`chat`&&!!we,Ye=we&&we.contextLimit>0?Math.min(999,we.totalTokens/we.contextLimit*100):0,Xe=wt(async()=>{if(!(typeof window>`u`||!ce))try{if(L()){ze(`Local`),Ve(!1);return}let e=l(),t=await re();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?te(n,H(e)):!1);if(m()!==n)return;if(Ve(!!n),a?.label?.trim()){ze(V(a.label.trim()));return}ze(`Instance`)}catch{ze(`Local`),Ve(!1)}});(0,Q.useEffect)(()=>{Xe()},[ce]),Os();let Ze=Is(e=>e.selectedModels),Qe=Is(e=>e.expandedFamilies),$e=Is(e=>e.toggleFamilyExpanded),et=Q.useMemo(()=>{let e=[];for(let t of ws(F)){if(!U.includes(t.id))continue;let n=F.find(e=>e?.providerId===t.id),r=n?.usage?.windows??{},i=n?.usage?.models,o=Xs(Object.entries(r),n?.usage?.accounts),s={providerId:t.id,providerName:t.name,entries:o,error:n&&!n.ok&&n.configured?n.error:void 0};if(i&&Object.keys(i).length>0){let e=Ze[t.id]??[],n=e.length>0,r=ks(i,t.id),o=Ns(t.id),c=Vs(o);s.modelFamilies=[];for(let t of c){let a=r.get(t.id)??[];if(a.length===0)continue;let o=n?a.filter(t=>e.includes(t)):a;if(o.length===0)continue;let c=[];for(let e of o){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&&s.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&&s.modelFamilies.push({familyId:null,familyLabel:a(`header.services.modelFamily.other`),models:e})}}(o.length>0||s.modelFamilies&&s.modelFamilies.length>0||s.error)&&e.push(s)}return e},[U,F,Ze,a]),nt=et.length>0;Q.useEffect(()=>{ie()},[ie]);let rt=Q.useCallback(async e=>{ae(e);try{await tt({usageDisplayMode:e})}catch(e){console.warn(`Failed to update usage display mode:`,e)}},[ae]),it=Q.useCallback(()=>{if(Ie)return;Le(!0);let e=new Promise(e=>setTimeout(e,500));Promise.all([I(),e]).finally(()=>{Le(!1)})},[I,Ie]),at=Vn(e=>O?e.worktreeMetadata.get(O)?.path??``:``),ot=Q.useMemo(()=>Qu(at||``),[at]),st=Q.useMemo(()=>Qu((typeof j?.directory==`string`?j.directory:``)||``),[j?.directory]),ct=Vn(e=>e.newSessionDraft?.open?Qu(e.newSessionDraft.bootstrapPendingDirectory??e.newSessionDraft.directoryOverride??``):``),lt=Q.useMemo(()=>ot||st||ct,[ct,st,ot]),ut=Ao(),ft=Q.useMemo(()=>Qu(ut||lt||N?.path||``),[N?.path,ut,lt]),pt=q(e=>Je(e,ft)),mt=!!pt?.isOpen,ht=wt(()=>d(ft)),gt=Q.useMemo(()=>{if(!O)return P??`Yuri`;let e=j?.title?.trim();return e&&e.length>0?e:`Untitled Session`},[P,j?.title,O]),_t=Q.useMemo(()=>Qu(lt||N?.path||``),[N?.path,lt]),vt=Q.useMemo(()=>N?{id:N.id,path:N.path}:null,[N]),yt=Q.useRef(null);Q.useEffect(()=>{!vt||!_t||(yt.current={projectRef:vt,directory:_t})},[_t,vt]);let bt=Q.useMemo(()=>vt&&_t?{projectRef:vt,directory:_t}:yt.current,[_t,vt]),xt=Q.useCallback(async e=>{if(!(!e||je)){Me(!0);try{let t=E.github?await E.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})();G(t)}catch(e){console.error(`Failed to switch GitHub account:`,e)}finally{Me(!1)}}},[je,E.github,G]),St=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()},[]),Ct=Q.useCallback(()=>{if(W){St(),o(!De);return}s()},[St,W,De,o,s]),Et=Q.useCallback(()=>{R(`desktop_open_draft_mini_chat_window`,{directory:Qu(lt||N?.path||``),projectId:N?.id??null,apiBaseUrl:m(),clientToken:t()}).catch(e=>{console.warn(`[header] failed to open draft mini chat window`,e)})},[N?.id,N?.path,lt]),Dt=Q.useCallback(()=>{if(D){Et();return}O&&R(`desktop_open_session_mini_chat_window`,{sessionId:O,directory:Qu(lt||N?.path||``),apiBaseUrl:m(),clientToken:t()}).catch(e=>{console.warn(`[header] failed to open session mini chat window`,e)})},[N?.path,O,Et,D,lt]),kt=Q.useCallback(()=>{let e=ft;if(e){if($u(pt)===`context`){_(e);return}p(e)}},[_,ft,pt,p]),jt=Q.useMemo(()=>ft?$u(pt)===`context`:!1,[ft,pt]),Mt=Q.useCallback(()=>{let e=ft;if(e){if($u(pt)===`browser`){_(e);return}g(e)}},[_,ft,pt,g]),Nt=Q.useMemo(()=>ft?$u(pt)===`browser`:!1,[ft,pt]),Pt=Gu,Ft=Ku,It=Q.useMemo(()=>Ne?`services`:r?`sessions`:i?`git`:v,[v,Ne,r,i]),Lt=Q.useCallback(()=>{K(!1),r&&e&&e(),i&&n&&n(),!e&&De&&o(!1)},[De,r,e,n,i,o]),Rt=Q.useCallback(()=>{r||K(!1),e?.()},[r,e]),Y=Q.useCallback(()=>{i||K(!1),n?.()},[n,i]),zt=Q.useMemo(()=>ce&&me&&!pe?`5.5rem`:fe?`max(calc(0.75rem + var(--yuri-wco-left-inset, 0px)), 5.5rem)`:(!ce||he)&&!Ke?`calc(0.75rem + var(--yuri-wco-left-inset, 0px))`:`0.75rem`,[ce,pe,me,fe,Ke,he]);(0,Q.useEffect)(()=>{typeof document>`u`||document.documentElement.style.setProperty(`--yuri-titlebar-left-inset`,zt)},[zt]);let Bt=c?`0.75rem`:`var(--yuri-titlebar-left-inset, 0.75rem)`,Vt=c?`0px`:`calc(var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`,Ht=Q.useMemo(()=>!ce||!me||_e===null?``:_e>=26?`h-12`:_e<=15?`h-14`:``,[ce,me,_e]),Ut=Q.useMemo(()=>{if(!(ce&&!he||Ke))return{paddingRight:mt?`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))`}},[ce,Ke,mt,he]),Wt=wt(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)});Tt(se,([e])=>{e&&Wt(e.borderBoxSize[0]?.blockSize??e.target.getBoundingClientRect().height)},{box:`border-box`}),Q.useLayoutEffect(()=>{Wt(se.current?.getBoundingClientRect().height)},[Wt,W,Ht]);let Gt=Q.useCallback(async e=>{let t=e.target;t.closest(`.app-region-no-drag`)||t.closest(`button, a, input, select, textarea`)||e.button===0&&ce&&await y()},[ce]),Kt=Q.useMemo(()=>{if(W){let e=[{id:`chat`,label:a(`layout.mainTab.chat`),icon:`chat-thread`}];return e.push({id:`diff`,label:a(`layout.mainTab.diff`),icon:`diff`},{id:`files`,label:a(`layout.mainTab.files`),icon:`folder-6`},{id:`terminal`,label:a(`layout.mainTab.terminal`),icon:`terminal-box`},{id:`diagram`,label:a(`layout.mainTab.diagram`),icon:`file`}),e}return[]},[W,a]),qt=Q.useCallback(e=>Pa(xa(e,x)),[x]);(0,Q.useEffect)(()=>{!W&&(v===`git`||v===`terminal`||v===`diff`||v===`files`)&&b(`chat`)},[v,W,b]);let Jt=Q.useMemo(()=>{let e=[];return ce&&e.push({value:`instance`,label:a(`layout.services.instance`),icon:(0,$.jsx)(Z,{name:`connection-local`,className:`h-3.5 w-3.5`})}),e.push({value:`usage`,label:a(`layout.services.usage`),icon:(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`})},{value:`mcp`,label:`MCP`,icon:(0,$.jsx)(Cs,{className:`h-3.5 w-3.5`})}),e},[ce,a]),Yt=Q.useMemo(()=>Jt.map(e=>({id:e.value,label:e.label,icon:e.icon})),[Jt]),Xt=Q.useMemo(()=>[{value:`usage`,label:a(`header.services.used`)},{value:`remaining`,label:a(`header.services.remaining`)}],[a]),Qt=Q.useMemo(()=>Xt.map(e=>({id:e.value,label:e.label})),[Xt]),$t=Q.useMemo(()=>[{id:`usage`,label:a(`layout.services.usage`),icon:(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`})},{id:`mcp`,label:`MCP`,icon:(0,$.jsx)(Cs,{className:`h-3.5 w-3.5`})}],[a]);(0,Q.useEffect)(()=>{let e=e=>{if(Ot(e)&&!e.shiftKey&&!e.altKey){let t=parseInt(e.key,10);t>=1&&t<=Kt.length&&(e.preventDefault(),W&&(St(),Lt()),b(Kt[t-1].id))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[St,Lt,W,b,Kt]);let en=wt(e=>{Ue(e),Fe(!0),Xe(),e===`usage`&&ee===null&&I()});(0,Q.useEffect)(()=>{let e=e=>{let t=xa(`toggle_services_menu`,x);if(ka(e,t)){e.preventDefault();let t=Wu({isOpen:Pe,activeTab:He,targetTab:ce?`instance`:`usage`});t.open?en(t.tab):Fe(!1);return}let n=xa(`cycle_services_tab`,x);if(ka(e,n)){e.preventDefault();let t=Jt.map(e=>e.value);if(t.length===0)return;let n=t.indexOf(He),r=t[n===-1?0:(n+1)%t.length];Ue(r),Fe(!0),Xe(),r===`usage`&&ee===null&&I();return}let r=xa(`open_usage`,x);if(ka(e,r)){e.preventDefault();let t=Wu({isOpen:Pe,activeTab:He,targetTab:`usage`});t.open?en(t.tab):Fe(!1);return}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[x,ce,Pe,He,Jt,ee,I,Xe,en]);let nn=e=>{let t=v===e.id,n=e.icon===`diff`,r=n?null:e.icon,i=e.id===`chat`,a=e=>n?(0,$.jsx)(Rl,{size:e}):r?(0,$.jsx)(Z,{name:r,className:`h-${e/4} w-${e/4}`}):null,o=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>b(e.id),className:J(`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&&!W&&`min-w-[100px] justify-center`),"aria-label":e.label,"aria-selected":t,role:`tab`,children:[W?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)},rn=ue&&(D||!!O),an=Q.useCallback(e=>{window.setTimeout(e,0)},[]),on=Q.useCallback(e=>{en(e)},[en]),sn=Q.useRef(null),cn=(0,$.jsxs)(`div`,{className:`relative flex shrink-0 items-center`,children:[(0,$.jsx)(`div`,{ref:sn,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center`,children:(0,$.jsxs)(_a,{children:[(0,$.jsxs)(na,{children:[(0,$.jsx)($i,{asChild:!0,children:(0,$.jsx)(Ma,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":a(`header.actions.sessionMenuAria`),className:J(Pt,`text-muted-foreground`),children:(0,$.jsx)(Z,{name:`more-2`,className:`h-[18px] w-[18px]`})})})}),(0,$.jsx)(ea,{children:(0,$.jsx)(`p`,{children:a(`header.actions.sessionMenu`)})})]}),(0,$.jsxs)(ha,{align:`start`,className:`min-w-[14rem]`,children:[rn?(0,$.jsxs)(va,{className:`flex items-center gap-2`,onClick:()=>an(Dt),children:[(0,$.jsx)(Z,{name:`picture-in-picture-2`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:a(D?`header.actions.newMiniChat`:`header.actions.openSessionMiniChat`)})]}):null,ce?(0,$.jsxs)(va,{className:`flex items-center gap-2`,onClick:()=>an(()=>on(`instance`)),children:[(0,$.jsx)(Z,{name:`stack`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:a(`header.actions.sessionMenu.servicesWithInstance`,{current:Re})}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:qt(`toggle_services_menu`)})]}):null,(0,$.jsxs)(va,{className:`flex items-center gap-2`,onClick:()=>an(()=>on(`usage`)),children:[(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:a(`header.actions.sessionMenu.viewUsage`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:qt(`open_usage`)})]}),(0,$.jsx)(La,{}),(0,$.jsxs)(va,{className:`flex items-center gap-2`,onClick:()=>an(u),children:[(0,$.jsx)(Z,{name:`terminal-box`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:a(`header.actions.toggleTerminalPanel`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:qt(`toggle_terminal`)})]}),(0,$.jsxs)(va,{className:`flex items-center gap-2`,onClick:()=>an(Mt),children:[(0,$.jsx)(Z,{name:`global`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:a(`contextPanel.browser.open`)}),Nt?(0,$.jsx)(Z,{name:`check`,className:`h-3.5 w-3.5 text-foreground`}):null]})]})]})}),(0,$.jsx)(Yu,{isDesktopApp:ce,currentInstanceSupportsUpdate:Be,isDesktopServicesOpen:Pe,setIsDesktopServicesOpen:Fe,refreshCurrentInstanceLabel:Xe,desktopServicesTab:He,setDesktopServicesTab:Ue,fetchAllQuotas:I,servicesTabItems:Yt,quotaLastUpdated:ee,quotaDisplayMode:B,showPredValues:ne,quotaDisplayTabItems:Qt,handleDisplayModeChange:rt,handleUsageRefresh:it,isQuotaLoading:z,isUsageRefreshSpinning:Ie,hasRateLimits:nt,rateLimitGroups:et,expandedFamilies:Qe,toggleFamilyExpanded:$e,timeFormatPreference:S,anchorRef:sn})]}),ln=(0,$.jsxs)($.Fragment,{children:[!W&&!Ke&&v===`chat`?(0,$.jsx)(ql,{}):null,(0,$.jsx)(wu,{directory:_t}),ce&&(0,$.jsx)(eu,{open:Pe&&He===`instance`,onClick:()=>en(`instance`)}),(0,$.jsx)(qu,{title:a(`header.actions.rightSidebarWithShortcut`,{shortcut:qt(`toggle_right_sidebar`)}),ariaLabel:a(`contextPanel.actions.togglePanel`),pressed:mt,onClick:ht,className:J(`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`,mt?`bg-interactive-selection text-interactive-selection-foreground`:`text-muted-foreground/75 hover:text-foreground`),Icon:`folder-3`,iconClassName:`size-4`}),(0,$.jsx)(Ju,{isMobile:W,githubAuthStatus:oe,githubAccounts:Ae,githubAvatarUrl:Oe,githubLogin:ke,isSwitchingGitHubAccount:je,handleGitHubAccountSwitch:xt})]}),un=()=>(0,$.jsxs)(`div`,{onMouseDown:Gt,className:J(`app-region-drag relative flex h-12 select-none items-center pr-3`,Ht),style:Ut,role:`tablist`,"aria-label":a(`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:Bt}}),(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:Vt}}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[(0,$.jsx)(`div`,{className:`app-region-no-drag mr-3 flex min-w-0 items-center gap-0.5`,children:(0,$.jsx)(Ks,{children:(0,$.jsx)(`button`,{type:`button`,"aria-label":a(`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:D?a(`sessions.switcher.draftTitle`):gt})})})}),Kt.length>0&&(0,$.jsx)(`div`,{className:`flex items-center gap-1 rounded-lg bg-[var(--surface-muted)]/50 p-1`,children:Kt.map(e=>nn(e))}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[cn,qe&&we?(0,$.jsx)(Ws,{pending:we.pending,totalTokens:we.totalTokens,percentage:Ye,colorPercentage:we.percentage,contextLimit:we.contextLimit,outputLimit:we.outputLimit??0,size:`compact`,appearance:`subtle`,onClick:kt,pressed:jt}):null,ln,(0,$.jsx)(Gs,{visible:he&&ge===`right`&&!mt,position:`right`})]})]})]}),dn=()=>(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:Rt,className:J(Ft,It===`sessions`&&`bg-interactive-selection text-interactive-selection-foreground`),"aria-label":a(r?`header.actions.closeSessionsAria`:`header.actions.openSessionsAria`),children:(0,$.jsx)(Z,{name:`layout-left`,className:`h-5 w-5`})}):De?(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(!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":a(`header.actions.backAria`),children:(0,$.jsx)(Z,{name:`arrow-left-s`,className:`h-5 w-5`})}):(0,$.jsx)(`button`,{type:`button`,onClick:Ct,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":a(`header.actions.openSessionsAria`),children:(0,$.jsx)(Z,{name:`play-list-add`,className:`h-5 w-5`})}),!e&&De&&(0,$.jsx)(`span`,{className:`typography-ui-label font-semibold text-foreground`,children:a(`header.sessions.title`)})]}),(!De||!!e)&&(0,$.jsxs)($.Fragment,{children:[(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":a(`header.navigation.mainAria`),children:Kt.map(e=>{let t=v===e.id,n=e.icon===`diff`,r=n?null:e.icon;return(0,$.jsxs)(na,{children:[(0,$.jsx)($i,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{W&&(St(),Lt()),b(e.id)},"aria-label":e.label,"aria-selected":t,role:`tab`,className:J(Ft,`relative rounded-lg`,It===e.id&&`bg-interactive-selection text-interactive-selection-foreground`),children:[n?(0,$.jsx)(Rl,{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":a(`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)(Ps,{mobile:!0}),bt&&(0,$.jsx)(Uu,{projectRef:bt.projectRef,directory:bt.directory,compact:!0,allowMobile:!0,className:`h-9`}),(0,$.jsxs)(_a,{open:Ne,onOpenChange:t=>{t&&(r&&e&&e(),i&&n&&n()),K(t),t&&ee===null&&I()},children:[(0,$.jsxs)(na,{children:[(0,$.jsx)($i,{asChild:!0,children:(0,$.jsx)(Ma,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":a(`header.services.viewAria`),className:J(Ft,It===`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:a(`header.services.title`)})})]}),(0,$.jsx)(ha,{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)(cs,{items:$t,activeId:We,onSelect:e=>{let t=e;Ge(t),t===`usage`&&ee===null&&I()},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:()=>K(!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":a(`header.services.closeAria`),children:(0,$.jsx)(Z,{name:`close`,className:`h-5 w-5`})})]})}),We===`mcp`&&(0,$.jsx)(bc,{active:Ne&&We===`mcp`}),We===`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:a(`header.services.rateLimits`)}),(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Zu(ee,S)})]}),(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:()=>rt(`usage`),className:J(`typography-ui-label px-1 pb-0.5 transition-colors`,B===`usage`?`text-foreground border-b-2 border-[var(--primary-base)]`:`text-muted-foreground hover:text-foreground`),children:a(`header.services.used`)}),(0,$.jsx)(`span`,{className:`text-muted-foreground typography-ui-label px-0.5`,children:`·`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>rt(`remaining`),className:J(`typography-ui-label px-1 pb-0.5 transition-colors`,B===`remaining`?`text-foreground border-b-2 border-[var(--primary-base)]`:`text-muted-foreground hover:text-foreground`),children:a(`header.services.remaining`)})]}),(0,$.jsx)(`button`,{type:`button`,className:J(`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:it,disabled:z||Ie,"aria-label":a(`header.services.refreshRateLimitsAria`),children:(0,$.jsx)(Z,{name:`refresh`,className:J(`h-4 w-4`,Ie&&`animate-spin`)})})]})]})}),!nt&&(0,$.jsx)(`div`,{className:`px-4 py-6 text-center`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:a(`header.services.noRateLimits`)})}),(0,$.jsx)(`div`,{className:`py-1`,children:et.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)(mo,{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??a(`header.services.noRateLimitsReported`)})}):(0,$.jsxs)(`div`,{className:`space-y-3 px-4 pb-2`,children:[e.entries.map(([t,n],r)=>{let i=oc(e.entries,r),a=B===`remaining`?n.remainingPercent:n.usedPercent,o=n.disablePace?null:ma(n.usedPercent,n.resetAt,n.windowSeconds,t),s=o?.dailyAllocationPercent==null?null:B===`remaining`?100-Va(o.elapsedRatio):Va(o.elapsedRatio),c=da(n.valueLabel,a),l=sa(n.resetAt,n.resetAfterFormatted??n.resetAtFormatted,S);return(0,$.jsxs)(Q.Fragment,{children:[i?(0,$.jsx)(`div`,{className:J(`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:ra(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)(Bs,{percent:a,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:s}),o&&ne?(0,$.jsx)(Ms,{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=(Qe[e.providerId]??[]).includes(t.familyId??`other`);return(0,$.jsxs)(pl,{open:n,onOpenChange:()=>$e(e.providerId,t.familyId??`other`),children:[(0,$.jsxs)(fl,{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)(dl,{children:(0,$.jsx)(`div`,{className:`space-y-2.5 pb-1 pl-1 pt-1`,children:t.models.map(([t,n])=>{let r=B===`remaining`?n.remainingPercent:n.usedPercent,i=ma(n.usedPercent,n.resetAt,n.windowSeconds),a=i?.dailyAllocationPercent==null?null:B===`remaining`?100-Va(i.elapsedRatio):Va(i.elapsedRatio),o=da(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:As(t)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground tabular-nums`,children:o===`-`?``:o})]}),(0,$.jsx)(Bs,{percent:r,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:a}),i&&ne?(0,$.jsx)(Ms,{paceInfo:i,compact:!0}):null]},`${e.providerId}-${t}`)})})})]},t.familyId??`other`)})})]})]},e.providerId))})]})]})})]}),n?(0,$.jsxs)(na,{children:[(0,$.jsx)($i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:Y,className:J(Ft,`relative`,It===`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]})]})]}),fn=J(`header-safe-area relative z-10 bg-background`,de&&`bg-[var(--surface-background)] backdrop-blur-none`,W&&`yuri-layout-divider-b`);return(0,$.jsx)($.Fragment,{children:(0,$.jsx)(`header`,{ref:se,className:fn,style:{"--padding-scale":`1`},children:W?dn():un()})})};function td(){}var nd=180,rd=640,id=110,ad=e=>{let t=(0,Ll.c)(44),{isOpen:n,isMobile:r,children:i}=e,{t:a}=At(),o=q(od),s=q(sd),c=q(cd),l=q(ld),[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(rd,Math.max(nd,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(rd,Math.max(nd,g.current+t));c(n)},t=()=>{p(!1),q.getState().bottomTerminalHeight<=id&&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=J(`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:J(`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=J(`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 od(e){return e.bottomTerminalHeight}function sd(e){return e.isBottomTerminalExpanded}function cd(e){return e.setBottomTerminalHeight}function ld(e){return e.setBottomTerminalOpen}var ud=260,dd=260,fd=500,pd=e=>Math.min(fd,Math.max(dd,e)),md=({isOpen:e,isMobile:t,children:n,className:r,topBar:i})=>{let{t:a}=At(),o=q(e=>e.sidebarWidth),s=q(e=>e.setSidebarWidth),[c,l]=Q.useState(!1),u=Q.useRef(0),d=Q.useRef(o||ud),f=Q.useRef(null),p=Q.useRef(null),m=Q.useRef(null),h=Q.useRef(null),g=wt(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(fd,Math.max(dd,o||ud)),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=pd(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=pd(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:J(`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:J(`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:J(`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)(Da,{children:n})})]})]})},hd=()=>{let e=(0,Ll.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},gd=e=>{let t=(0,Ll.c)(14),{className:n}=e,r=Fs(_d).trim(),i=r.split(/\s+/).filter(Boolean),a=i.includes(`Yuri`),o=i.some(vd);if(Q.useEffect(()=>{o&&ji()},[o]),i.length===0)return null;let s;t[0]===n?s=t[1]:(s=J(`flex min-w-0 items-center overflow-hidden px-2 pb-2 pt-1`,n),t[0]=n,t[1]=s);let c=i.join(` `),l=r.includes(`Yuri`)?`items-center`:`items-baseline`,u;t[2]===l?u=t[3]:(u=J(`inline-flex min-w-0 gap-[0.28em] overflow-hidden whitespace-nowrap text-foreground`,l),t[2]=l,t[3]=u);let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d={fontFamily:`"Syne", var(--font-sans, system-ui, sans-serif)`,fontSize:`1.0625rem`,fontWeight:700,letterSpacing:`0.08em`,lineHeight:1},t[4]=d):d=t[4];let f=r.includes(`Yuri`)?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0 self-center`,children:(0,$.jsx)(Wa,{width:24,height:24})}):null,p=i.map((e,t)=>(0,$.jsx)(`span`,{"aria-hidden":`true`,className:J(`inline-flex shrink-0 items-baseline`,!a&&t>0&&`text-primary`),children:e===`Yuri`?(0,$.jsx)(il,{width:`2.44814cap`}):e},t)),m;t[5]!==c||t[6]!==u||t[7]!==d||t[8]!==f||t[9]!==p?(m=(0,$.jsxs)(`span`,{role:`img`,"aria-label":c,className:u,style:d,children:[f,p]}),t[5]=c,t[6]=u,t[7]=d,t[8]=f,t[9]=p,t[10]=m):m=t[10];let h;return t[11]!==s||t[12]!==m?(h=(0,$.jsx)(`div`,{className:s,children:m}),t[11]=s,t[12]=m,t[13]=h):h=t[13],h};function _d(e){return e.sidebarBrandName}function vd(e){return e!==`Yuri`}var yd=`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`,bd=()=>{let e=(0,Ll.c)(48),{t}=At(),n=q(xd),r=q(Sd),i=q(Cd),a=q(wd),o=Fs(Td),s=Q.useRef(null),c=Pa(xa(`toggle_sidebar`,a)),{usesFramelessChrome:l,side:u}=qs(),d;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=w(),e[0]=d):d=e[0];let f=d,p=Wl(),m=!f||p||!n||!o,h;e[1]===p?h=e[2]:(h=!T()&&(f?p:v()),e[1]=p,e[2]=h);let g=h,_=Dd,y,b;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{if(typeof document>`u`)return;let e=s.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()}},b=[],e[3]=y,e[4]=b):(y=e[3],b=e[4]),Q.useEffect(y,b);let x=g&&n?`${r||260}px`:void 0,S;e[5]===x?S=e[6]:(S={height:`var(--yuri-header-height, 3rem)`,paddingLeft:`var(--yuri-titlebar-left-inset, 0.75rem)`,width:x},e[5]=x,e[6]=S);let C=g&&n&&`w-full justify-between`,E;e[7]===C?E=e[8]:(E=J(`flex items-center gap-2`,C),e[7]=C,e[8]=E);let D;e[9]!==n||e[10]!==g?(D=g&&n?(0,$.jsx)(gd,{className:`flex min-w-0 items-center p-0 pl-1.5`}):null,e[9]=n,e[10]=g,e[11]=D):D=e[11];let O;e[12]!==l||e[13]!==u?(O=l&&u===`left`?(0,$.jsx)(Gs,{visible:!0,position:`left`}):null,e[12]=l,e[13]=u,e[14]=O):O=e[14];let k;e[15]!==t||e[16]!==l?(k=l?(0,$.jsxs)(na,{children:[(0,$.jsx)($i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:_,"aria-label":t(`header.actions.openAppMenuAria`),className:J(yd,`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[15]=t,e[16]=l,e[17]=k):k=e[17];let A;e[18]===m?A=e[19]:(A=m?(0,$.jsx)(Fc,{}):null,e[18]=m,e[19]=A);let j=na,M;e[20]===t?M=e[21]:(M=t(`header.actions.openSessionsAria`),e[20]=t,e[21]=M);let N,P;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(N=J(yd,`group shrink-0`),P=(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[22]=N,e[23]=P):(N=e[22],P=e[23]);let F;e[24]!==M||e[25]!==i?(F=(0,$.jsx)($i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:i,"aria-label":M,className:N,children:P})}),e[24]=M,e[25]=i,e[26]=F):F=e[26];let I=ea,L=t(`header.actions.openSessionsWithShortcut`,{shortcut:c}),R;e[27]===L?R=e[28]:(R=(0,$.jsx)(`p`,{children:L}),e[27]=L,e[28]=R);let z;e[29]!==I||e[30]!==R?(z=(0,$.jsx)(I,{children:R}),e[29]=I,e[30]=R,e[31]=z):z=e[31];let ee;e[32]!==j||e[33]!==F||e[34]!==z?(ee=(0,$.jsxs)(j,{children:[F,z]}),e[32]=j,e[33]=F,e[34]=z,e[35]=ee):ee=e[35];let B;e[36]!==A||e[37]!==ee?(B=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[A,ee]}),e[36]=A,e[37]=ee,e[38]=B):B=e[38];let V;e[39]!==O||e[40]!==k||e[41]!==B||e[42]!==E||e[43]!==D?(V=(0,$.jsxs)(`div`,{ref:s,className:E,children:[D,O,k,B]}),e[39]=O,e[40]=k,e[41]=B,e[42]=E,e[43]=D,e[44]=V):V=e[44];let H;return e[45]!==V||e[46]!==S?(H=(0,$.jsx)(`div`,{className:`app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2`,style:S,children:V}),e[45]=V,e[46]=S,e[47]=H):H=e[47],H};function xd(e){return e.isSidebarOpen}function Sd(e){return e.sidebarWidth}function Cd(e){return e.toggleSidebar}function wd(e){return e.shortcutOverrides}function Td(e){return e.sidebarBrandName.trim().length>0}function Ed(e){console.warn(`[titlebar] failed to open app menu`,e)}function Dd(e){let t=e.currentTarget.getBoundingClientRect();R(`desktop_show_app_menu`,{x:t.left,y:t.bottom}).catch(Ed)}function Od(e){let t=(0,Ll.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({children:n,className:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=J(`relative isolate flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl bg-background shadow-sm [--background:oklch(from_var(--surface-background)_min(1,calc(l_+_0.015))_c_h)] dark:[--background:color-mix(in_srgb,var(--surface-foreground)_4%,var(--surface-background))]`,r),t[4]=r,t[5]=a);let o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`span`,{"aria-hidden":`true`,"data-workspace-surface-ring":!0,className:`pointer-events-none absolute inset-0 z-50 rounded-[inherit] ring-1 ring-inset ring-[var(--interactive-border)]`}),t[6]=o):o=t[6];let s;return t[7]!==n||t[8]!==i||t[9]!==a?(s=(0,$.jsxs)(`section`,{...i,"data-workspace-surface":!0,className:a,children:[n,o]}),t[7]=n,t[8]=i,t[9]=a,t[10]=s):s=t[10],s}var kd=(e,t)=>{let n=ht(t,e);return!n||n===`.`||n===t?0:n.split(`/`).filter(Boolean).length},Ad=(e,t,n=10)=>{let r=mt(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=mt(t.path);if(!e||i.has(e))continue;let o=kd(r,e);o<1||o>n||(i.add(e),a.push(e))}return a},jd=e=>e.some(e=>!!mt(e)),Md=(e,t)=>{let n=new Set(t.map(e=>mt(e)).filter(Boolean));return e.filter(e=>!n.has(e))},Nd=(e,t,n)=>t.length===0?e.length===0:Md(e,t).length>0?!1:t.every(e=>n.has(mt(e))),Pd=xo(()=>gt(()=>import(`./ToolOutputDialog-BhD4QiRH.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78]))),Fd=e=>{let t=Rd(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},Id=e=>{let t=(0,Ll.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=J(`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},Ld=e=>e.slice().sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1),Rd=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},zd=e=>e.startsWith(`/`)||e.startsWith(`//`)||/^[A-Za-z]:\//.test(e),Bd=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,Vd=(e,t)=>{let n=Rd(t),r=Rd(e);if(!n||!r)return!1;let i=Bd(n),a=Bd(r);return a===i||a.startsWith(`${i}/`)},Hd=(e,t)=>{let n=Rd(t),r=Rd(e);if(!Vd(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},Ud=(e,t)=>{if(!t)return``;let n=Rd(t);if(!e||!Vd(n,e))return n;let r=n.slice(e.length);return r.startsWith(`/`)?r.slice(1):r},Wd=new Set([`node_modules`]),Gd=e=>{let t=(0,Ll.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},Kd=e=>{let t=(0,Ll.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},qd=e=>Wd.has(e),Jd=e=>{let t=Rd(e);return t===`node_modules`||t.endsWith(`/node_modules`)||t.includes(`/node_modules/`)},Yd=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`is a directory`)||t.includes(`eisdir`)},Xd=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`)},Zd=2e5,Qd=`yuri:files:auto-save-enabled`,$d=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
|
`},ef=e=>e.replace(/\r\n/g,`
|
|
6
6
|
`).replace(/\r/g,`
|
|
@@ -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 Cb(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 wb(e,t){let n=await _(t,e);if(n)return n;if(!T())return null;try{let n=await B()?.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 Tb(e){let t=B()?.files;if(t?.revealPath)try{return!!(await t.revealPath(e))?.success}catch{return!1}return await z(e)?!0:A(e)}function Eb(){return Rt()}function Db(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 Ob=(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},kb=U()((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=Ob(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}))}})),Ab=!1,jb=new Set,Mb=!1;function Nb(){for(let e of jb)e()}function Pb(e){Ab!==e&&(Ab=e,Nb())}function Fb(e){e.key===`Shift`&&Pb(!0)}function Ib(e){e.key===`Shift`&&Pb(!1)}function Lb(){Pb(!1)}function Rb(){Mb||typeof window>`u`||(Mb=!0,window.addEventListener(`keydown`,Fb),window.addEventListener(`keyup`,Ib),window.addEventListener(`blur`,Lb))}function zb(e){return Rb(),jb.add(e),()=>{jb.delete(e)}}function Bb(){return Ab}function Vb(){return!1}function Hb(){return(0,Q.useSyncExternalStore)(zb,Bb,Vb)}var Ub=!1,Wb=!1,Gb=new Set;function Kb(){Gb.forEach(e=>e())}function qb(e){Ub!==e&&(Ub=e,Kb())}function Jb(e){return Pt()?e.key===`Meta`:e.key===`Control`}var Yb=(({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:qb});function Xb(e){Jb(e)&&Yb.press()}function Zb(){Yb.release()}function Qb(e){Jb(e)&&Zb()}function $b(){document.visibilityState!==`visible`&&Zb()}function ex(){Wb||typeof window>`u`||(Wb=!0,window.addEventListener(`keydown`,Xb),window.addEventListener(`keyup`,Qb),window.addEventListener(`blur`,Zb),document.addEventListener(`visibilitychange`,$b))}function tx(e){return ex(),Gb.add(e),()=>Gb.delete(e)}function nx(){return Ub}function rx(){return!1}function ix(){return(0,Q.useSyncExternalStore)(tx,nx,rx)}var ax=(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} ---`},ox=(e,t)=>Vn.getState().getWorktreeMetadata(e)?.projectDirectory??t,sx=e=>e.type===`assistant`?Kr(e.content??[]).trim():``,cx=async e=>{let t=e.directory??void 0,n=Oe(e.session.id,t);if(n.length===0&&e.directory){let t=await Se.withDirectory(e.directory,()=>Se.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=sx(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 Kr(Ve(r.id,t)).trim()}return``};function lx({session:e,open:t,onOpenChange:n}){let{t:r}=At(),i=dn(),a=vn(e=>e.activeSessions),o=vn(e=>e.archivedSessions),s=Zt(e=>e.providers),c=Zt(e=>e.currentProviderId),l=Zt(e=>e.currentModelId),u=Zt(e=>e.currentAgentName),[d,f]=Q.useState(c??``),[p,m]=Q.useState(l??``),[h,g]=Q.useState(()=>c&&l?[{providerID:c,modelID:l,instanceId:Ol()}]:[]),[_,v]=Q.useState(``),[y,b]=Q.useState(u??``),[x,S]=Q.useState([]),[C,w]=Q.useState(!1),T=Q.useMemo(()=>Al(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=Vn.getState().getDirectoryForSession(e.id),r=ox(e.id,n),i=E.map(e=>{let t=Al(e.title);if(!t||t.groupSlug!==T.groupSlug||t.fusion||(t.runGroup??null)!==(T.runGroup??null))return null;let n=Vn.getState().getDirectoryForSession(e.id)??Wn(e),i=ox(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)(hr,{open:t,onOpenChange:n,children:(0,$.jsxs)(fr,{className:`max-w-xl overflow-visible`,children:[(0,$.jsxs)(ur,{children:[(0,$.jsx)(pr,{children:r(`multirun.fusion.title`)}),(0,$.jsx)(mr,{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)(jl,{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)(fo,{modelId:p,providerId:d,className:`h-3.5 w-3.5 mr-1`}):void 0})}),O.length>0?(0,$.jsxs)(_o,{value:_||`__default__`,onValueChange:e=>v(e===`__default__`?``:e),children:[(0,$.jsxs)(go,{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)(uo,{children:e=>e===`__default__`?r(`multirun.modelMultiSelect.variant.default`):e})]}),(0,$.jsxs)(ho,{fitContent:!0,portalToBody:!0,children:[(0,$.jsx)(po,{value:`__default__`,children:r(`multirun.modelMultiSelect.variant.default`)}),O.map(e=>(0,$.jsx)(po,{value:e,children:e},e))]})]}):null,(0,$.jsx)(kl,{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=Al(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)(fo,{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)(dr,{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=>cx(e))),t=x.map((t,n)=>({source:t,text:e[n]??``})).filter(e=>e.text.trim().length>0);if(t.length===0){X.error(r(`multirun.fusion.toast.noOutputs`));return}let i=x[0]?.projectDirectory??x[0]?.directory??null,a=Dl(T.groupSlug,d,p,T.runGroup),[o,s]=await Promise.all([Sr(`session.fusion.visible`),Sr(`session.fusion.instructions`)]),c=await Vn.getState().createSession(a,i,null);if(!c)throw Error(`Failed to create fusion session`);Vn.getState().setCurrentSession(c.id,i),n(!1),await Se.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:ax(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??Se.getDirectory()})}catch(e){console.error(`[MultiRunFusion] Failed to start fusion`,e),X.error(r(`multirun.fusion.toast.failed`))}finally{w(!1)}}},disabled:!k,children:r(C?`multirun.fusion.actions.starting`:`multirun.fusion.actions.start`)})]})]})})}function ux(e){let t=(0,Ll.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:lr,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 dx=1/3,fx=1,px=({containerScrollTop:e,containerClientHeight:t,containerScrollHeight:n,rowOffsetFromViewportTop:r})=>{let i=e+(r-t*dx),a=Math.max(0,n-t);return Math.min(a,Math.max(0,i))},mx=()=>typeof window>`u`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`,hx=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},gx=(e,t)=>{let n=hx(e),r=t?.behavior??mx();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=px({containerScrollTop:n.scrollTop,containerClientHeight:n.clientHeight,containerScrollHeight:n.scrollHeight,rowOffsetFromViewportTop:i.top-a});Math.abs(s-n.scrollTop)<fx||n.scrollTo({top:s,behavior:r})},_x=e(ue(),1),vx=null,yx=!1,bx=(e,t=Ui.getState().focus)=>e===null?null:typeof e==`string`?t?.sessionId===e?t:xi(e):e,xx=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))},Sx=()=>{vx&&=(xx(vx),null)},Cx=(e,t)=>{Sx(),In(!0);let n=bx(e);if(!n)return;yx=!0;let r;try{r=Ge(n.sessionId)}finally{yx=!1}vx={commit:t,commitFrame:null,fallbackTimer:null,focus:n,intent:r,paintFrame:null,scheduled:!1},(0,_x.flushSync)(()=>{Ui.getState().setFocus(n)}),typeof window<`u`&&(vx.fallbackTimer=window.setTimeout(()=>{wx(n)},150))},wx=e=>{let t=vx,n=bx(e);if(!t||!li(t.focus,n)||t.scheduled)return;t.scheduled=!0,typeof window<`u`&&t.fallbackTimer!==null&&(window.clearTimeout(t.fallbackTimer),t.fallbackTimer=null);let r=()=>{vx===t&&We()===t.intent&&(vx=null,On(),t.commit())};if(typeof window>`u`){r();return}t.commitFrame=window.requestAnimationFrame(()=>{vx===t&&We()===t.intent&&(t.paintFrame=window.requestAnimationFrame(r))})},Tx=e=>{if(vx)return;let t=Ui.getState();t.setFocus(bx(e,t.focus))};Ke(e=>{if(yx)return;let t=vx;if(t?.intent===e)return;t&&Sx();let n=Ui.getState();n.setFocus(bx(e.sessionId,n.focus))});var Ex=e=>{let t=[],n=e=>{e.children.forEach(e=>{t.push(e.session.id),n(e)})};return n(e),t},Dx=Q.memo(function(e){let t=(0,Ll.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=J(`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=J(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)($i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:u,"aria-label":r,onPointerDown:o,onMouseDown:s,onClick:c,onKeyDown:Bx,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)(na,{children:[h,g]}),t[18]=h,t[19]=g,t[20]=_):_=t[20],_}),Ox=Q.memo(function(e){let t=(0,Ll.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=Hb(),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=J(`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)($i,{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)(na,{children:[S,C]}),t[21]=S,t[22]=C,t[23]=w):w=t[23],w}),kx=Q.memo(function(e){let t=(0,Ll.c)(3),{number:n}=e;if(!ix())return null;let r=Pt()?`⌘${n}`:`Ctrl+${n}`,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(Wi,{"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 Ax(e){let{t:n}=At(),{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,handleSessionDoubleClick:x,togglePinnedSession:S,handleShareSession:C,copiedSessionId:w,handleCopyShareUrl:E,handleUnshareSession:D,setOpenSidebarMenuKey:O,renamingFolderId:k,getFoldersForScope:A,getSessionFolderId:j,removeSessionFromFolder:N,addSessionToFolder:P,createFolderAndStartRename:F,handleDeleteSession:I,mobileVariant:L,alwaysShowActions:z,renderSessionNode:ee,secondaryMeta:B,renderContext:V=`project`,subtreeContainsActive:H,subtreeContainsEditing:te,menuOpenSessionId:ne,childRenderExtrasFor:re,liveSessionById:U,shortcutNumber:ie=null}=e,ae=!!B?.projectLabel,ue=!!B?.branchLabel,de=Xn(e=>e.displayMode),fe=Q.useMemo(()=>T(),[]),pe=de===`minimal`||fe,me=Q.useMemo(()=>M(),[]),_e=Q.useContext(ut),ve=fe?`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`,ye=fe,be=V===`pinned`&&c.has(r.session.id),Se=!be&&!s&&!L,Ce=`h-5 w-5`,Te=`h-3.5 w-3.5`,De=(Se||be?1:0)+ +!!ye+1,Oe=De>=3?`group-hover:pr-18 group-focus-within:pr-18`:De>=2?`group-hover:pr-12 group-focus-within:pr-12`:`group-hover:pr-7 group-focus-within:pr-7`,ke=De>=2?`pr-12`:`pr-8`,Ae=Q.useRef(!1),je=Q.useRef(!1),[Me,Ne]=Q.useState(!1),K=Q.useRef(f);K.current=f;let Fe=Q.useRef(null),Ie=Q.useRef(_);Ie.current=_;let[Le,Re]=Q.useState(h),Be=Q.useRef(Le);Be.current=Le;let Ve=Q.useRef(null),He=Q.useRef(null),Ue=Q.useRef(null),We=r.session,Ge=U.get(We.id)??We,Ke=!!Ge.metadata?.yuri?.assistant,q=_t(We.directory??null)??_t(a??null),qe=hn(q??void 0,{bootstrap:!1}),Je=ai(),Ye=kb(e=>e.enabled),Xe=kb(Q.useMemo(()=>e=>e.selectedIds.has(We.id),[We.id])),Ze=kb(e=>e.toggleSelected),Qe=kb(e=>e.setRange),[$e,et]=Q.useState(!1),[tt,nt]=Q.useState(!0),[rt,it]=Q.useState(!1),[at,ot]=Q.useState(!1),st=`${V}:${s?`archived`:`active`}:${We.id}`,ct=fn(Q.useMemo(()=>e=>!!e.sessionMemoryState.get(Kt(We.id))?.isZombie,[We.id])),lt=En(We.id),dt=Dn(We.id,q??void 0,{bootstrap:!1}),ft=Un(We.id,q??void 0,{bootstrap:!1}),pt=Q.useMemo(()=>({scope:V,sessionId:We.id,projectId:o??null}),[o,V,We.id]),mt=Q.useMemo(()=>bi(pt)??``,[pt]),ht=Q.useRef(null),gt=Ui(Q.useMemo(()=>e=>li(e.focus,pt),[pt]));Q.useLayoutEffect(()=>{if(!gt)return;let e=ht.current;e&&(L?e.scrollIntoView({block:`nearest`,inline:`nearest`}):gx(e)),wx(pt)},[gt,L,pt]);let vt=Ge.title||n(`sessions.sidebar.session.untitled`),yt=$a(Qa(Ge)),bt=Ge.metadata?.yuri?.titleRefresh,xt=typeof bt?.lastError==`string`?bt.lastError:null,St=typeof bt?.failedAt==`number`?bt.failedAt:null;Q.useEffect(()=>{!xt||St===null||console.warn(`[session-title] generation failed for ${We.id}: ${xt}`)},[We.id,xt,St]);let Tt=typeof bt?.generationExpiresAt==`number`&&Number.isFinite(bt.generationExpiresAt)?bt.generationExpiresAt:0,[Dt,Ot]=Q.useState(0),kt=Q.useMemo(()=>Math.max(0,Tt-Date.now()),[Tt]),[,jt,Mt]=Ct(()=>Ot(Tt),kt,{immediate:!1}),Nt=bt?.isGenerating===!0;Q.useEffect(()=>(Nt&&Tt>Date.now()&&jt(),Mt),[Nt,Tt,jt,Mt]);let Pt=r.children.length>0||!!(Ge.hasChildren??We.hasChildren),Ft=c.has(We.id),It=st,Lt=u?!0:l.has(It),Rt=!!Ge.parentID,zt=V===`pinned`,Bt=Jn(We.id)>0&&!Rt,Vt=tr(Ge)||Date.now(),Ht=wa(Vt),Ut=Ea(Vt),[Wt,Gt]=Q.useState(!1),qt=Wt,Jt=Q.useMemo(()=>Al(Ge.title)!==null,[Ge.title]),[Yt,Xt]=Q.useState(!1),Zt=Q.useMemo(()=>Ex(r).length,[r]),Qt=wt(e=>{let t=q??``,n=(ze()??we(t,qe)).getTranscript(Pe(t,e)),r=qe.getState().session.find(t=>t.id===e)?.revert?.messageID;return jn({sessionID:e,messages:Ee(n),parts:n.partsByMessageID,revertMessageID:r}).list}),$t=wt(async e=>{let t=[],r=0;for(let i of e)try{await Je.ensureSessionRenderable(i.session.id);let e=Qt(i.session.id),a=i.session.title||n(`sessions.sidebar.session.export.untitledSubagent`),o=i.session.agent,s=await $t(i.children);r+=s.skipped,t.push({title:a,agent:o,records:e,children:s.children})}catch{r+=Ex(i).length+1}return{children:t,skipped:r}}),en=wt(e=>{e<=0||X.warning(n(e===1?`sessions.sidebar.session.export.skippedSubtaskSingle`:`sessions.sidebar.session.export.skippedSubtaskMany`,{count:e}))}),tn=wt(async e=>{if(!q){X.error(n(`sessions.sidebar.session.export.nothingToExport`));return}await Je.ensureSessionRenderable(We.id);let t=Qt(We.id);if(t.length===0){X.error(n(`sessions.sidebar.session.export.nothingToExport`));return}let i,a=0;if(e&&r.children.length>0){let e=await $t(r.children);i=e.children,a=e.skipped}let o=Sb(t,Ge.title??null,i),s=Db(Ge.title??null),c=await wb(o,s);if(c){X.success(n(`sessions.sidebar.session.export.success`),{action:{label:n(Eb()),onClick:()=>{Tb(c).then(e=>{e||X.error(n(`sessions.sidebar.session.export.failedRevealPath`))})}}}),en(a);return}Cb(o,s),X.success(n(`sessions.sidebar.session.export.success`)),en(a)}),nn=wt(async()=>{if(r.children.length>0){nt(!0),et(!0);return}await tn(!1)}),rn=wt(()=>{q&&R(`desktop_open_session_mini_chat_window`,{sessionId:We.id,directory:q,apiBaseUrl:m(),clientToken:t()}).catch(e=>{console.warn(`[session-sidebar] failed to open mini chat window`,e)})});Et(He,()=>{Ie.current(Be.current)},f===We.id),Q.useLayoutEffect(()=>{if(f!==We.id){Ve.current===We.id&&(Ve.current=null);return}Ve.current!==We.id&&(Ve.current=We.id,Re(h),queueMicrotask(()=>Ue.current?.select()))},[f,h,We.id]);let an=wt(e=>{if(!e&&Fe.current){let{id:e,title:t}=Fe.current;Fe.current=null,p(e),g(t)}}),sn=wt(e=>{Gt(e)}),cn=wt(e=>{e.preventDefault(),e.stopPropagation()}),ln=wt(e=>{e.preventDefault(),e.stopPropagation()}),un=wt(e=>{e.preventDefault(),e.stopPropagation(),O(null),S(We.id)}),dn=wt(e=>{e.preventDefault(),e.stopPropagation(),O(null),I(We,{archivedBucket:s})}),pn=wt(e=>{e.preventDefault(),e.stopPropagation(),O(null),I(We,{archivedBucket:s,hardDelete:!0,skipConfirm:!0})}),mn=wt(e=>{e.preventDefault(),e.stopPropagation(),O(null),S(We.id)}),gn=wt(()=>{!q||rt||(it(!0),(async()=>{try{await Je.refreshSessionTranscript(We.id,{directory:q}),X.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{X.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{it(!1)}})())}),_n=wt(e=>{e.preventDefault(),e.stopPropagation()}),vn=wt(e=>{e.preventDefault(),e.stopPropagation()}),yn=wt(e=>{e.preventDefault(),e.stopPropagation(),_e?.vscode?.executeCommand(`yuri.openSessionInEditor`,We.id,vt)}),bn=wt(e=>{if(Ae.current){Ae.current=!1;return}if(Ye){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=kb.getState().anchorId,n=new Map;n.set(We.id,Ex(r)),Qe(t,We.id,e,q??null,n);return}Ze(We.id,q??null,Ex(r));return}b(We.id,q,o,V)}),xn=wt(e=>{e.defaultPrevented||e.target?.closest(`button, a, input, [role="menuitem"], [role="menu"]`)||bn(e)}),Sn=wt(e=>{(e.button===2||e.button===0&&e.ctrlKey&&!Ye)&&(Ae.current=!0)}),Cn=wt(e=>{je.current=e.pointerType===`mouse`,L&&e.pointerType===`touch`&&Ne(!0)}),wn=wt(e=>{L&&e.pointerType===`touch`&&Ne(!1)}),Tn=wt(e=>{e.key!==`Enter`||!je.current||(e.preventDefault(),e.stopPropagation(),x(We.id,vt))}),On=wt(e=>{if(bn(e),!je.current)return;let t=e.currentTarget;window.requestAnimationFrame(()=>{je.current=!0,t.focus({preventScroll:!0})})}),kn=wt(()=>{je.current=!1}),An=wt(e=>{if(!je.current)return;let t=e.relatedTarget;if(t instanceof Node&&e.currentTarget.contains(t))return;let n=document.activeElement;!(n instanceof HTMLElement)||!e.currentTarget.contains(n)||(n.blur(),je.current=!1)}),Mn=wt(()=>{!Lt&&!at&&(ot(!0),Je.loadChildren(We.id,q).catch(()=>X.error(n(`sessions.sidebar.session.subsessions.loadFailed`))).finally(()=>ot(!1))),y(It)});if(f===We.id){let e=async()=>{v();try{await on(We.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:Ba(i)},children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0`,children:[(0,$.jsxs)(`form`,{ref:He,className:`flex w-full items-center gap-2`,onSubmit:e=>{e.preventDefault(),_(Le)},children:[(0,$.jsx)(`input`,{ref:Ue,value:Le,onChange:e=>Re(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`,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`,"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`})})]}),pe?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:[Pt&&!zt&&!Rt?(0,$.jsx)(`span`,{className:`inline-flex items-center justify-center flex-shrink-0`,children:Lt?(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:Ht}),ae?(0,$.jsx)(`span`,{className:`truncate`,children:B?.projectLabel}):null,ue?(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]})})]})},We.id)}let Nn=lt,Pn=Nt&&Tt>Date.now()&&Dt!==Tt,Fn=dt.length,In=ft.length>0,Ln=In||Nn||!In&&!Nn&&Bt,Rn=!z||fe,zn=In?(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`})}):Nn?(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)(rc,{})}):(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)]`})}),Bn=!zt&&!Rt&&Pt,Vn=Bn&&!z&&!at,Hn=Ba(Math.max(0,i-1)),Wn=Bn?(0,$.jsx)(`span`,{role:`button`,tabIndex:0,"aria-expanded":Lt,"aria-busy":at,onClick:e=>{e.stopPropagation(),e.currentTarget.blur(),Mn()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),Mn())},style:{minWidth:14,minHeight:14,left:Hn},className:J(`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`,pe?`top-1/2 -translate-y-1/2`:`top-[14.5px] -translate-y-1/2`,Vn?`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(Lt?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),children:at?(0,$.jsx)(rc,{size:12}):Lt?(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,Gn=ct?(0,$.jsx)(Z,{name:`error-warning`,className:`h-4 w-4 text-status-warning`}):null,qn=(0,$.jsx)(ce,{children:(0,$.jsx)(G,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(xe,{"data-slot":`dropdown-menu-content`,finalFocus:()=>!(k||K.current),style:{color:`var(--surface-elevated-foreground)`},className:J(Xo,`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:()=>{Fe.current={id:We.id,title:vt}},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`pencil-ai`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.rename`)]}),(0,$.jsxs)(e,{onClick:()=>S(We.id),className:`[&>svg]:mr-1`,children:[Ft?(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(Ft?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`)]}),Kn()&&!Ge.share?(0,$.jsxs)(e,{onClick:()=>C(Ge),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`share-2`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.share`)]}):Kn()&&Ge.share?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(e,{onClick:()=>{Ge.share?.url&&E(Ge.share.url,We.id)},className:`[&>svg]:mr-1`,children:w===We.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:()=>D(We.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:()=>{nn()},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:!q||rt,onClick:()=>{gn()},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`refresh`,className:J(`mr-1 h-4 w-4`,rt&&`animate-spin`)}),n(`sessions.sidebar.session.menu.refreshTranscript`)]}),Jt?(0,$.jsxs)(e,{onClick:()=>Xt(!0),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(ux,{className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.runFusion`)]}):null,q&&!s?(()=>{let o=A(q),s=j(q,We.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?N(q,We.id):P(q,t.id,We.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(q);e&&P(q,e.id,We.id)},children:[(0,$.jsx)(Z,{name:`add`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.folders.newFolderEllipsis`)]}),s?(0,$.jsxs)(e,{onClick:()=>{N(q,We.id)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(Z,{name:`close`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.folders.removeFromFolder`)]}):null]})]})]})})():null,me?(0,$.jsxs)(e,{disabled:!q,onClick:rn,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(We,{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(We,{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)(oe,{className:J(Qo,e),...t}),Separator:({className:e,...t})=>(0,$.jsx)(W,{className:J(Zo,e),...t}),Sub:se,SubTrigger:({className:e,children:t,...n})=>(0,$.jsxs)(ge,{className:J(Yo,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)(ce,{children:(0,$.jsx)(G,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(xe,{"data-slot":`dropdown-menu-sub-content`,style:{color:`var(--surface-elevated-foreground)`},className:J(Xo,`yuri-session-context-menu`,e),...n,children:t})})})})})})});return(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(Cc,{sessionId:We.id,sessionDirectory:q??null,sessionTitle:vt,children:(0,$.jsxs)(le,{open:Wt,onOpenChange:sn,onOpenChangeComplete:an,children:[(0,$.jsxs)(he,{render:(0,$.jsx)(`div`,{ref:ht,"data-session-row":We.id,"data-session-scope":q??``,"data-session-focus-scope":V,"data-session-focus-key":mt,"data-session-project-id":o??``,"data-session-archived":s?`1`:`0`,"data-session-depth":i,onClick:xn,onMouseLeave:An,className:J(`group relative my-0.5 flex cursor-pointer items-center rounded-lg py-1.5 pr-2`,gt&&!Xe&&`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,Xe&&`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,!gt&&!Xe&&`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:[Wn,(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,style:{paddingLeft:Ba(i)},children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:(0,$.jsxs)(na,{children:[(0,$.jsx)($i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onPointerDown:Cn,onPointerUp:wn,onPointerCancel:wn,onMouseDown:Sn,onKeyDown:Tn,onBlur:kn,onClick:On,onDoubleClick:e=>{e.stopPropagation(),x(We.id,vt)},className:J(`relative flex min-w-0 flex-1 cursor-pointer flex-col gap-0 overflow-hidden rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 text-foreground select-none has-[[data-sidebar-shortcut-number]]:!pr-0`,Me&&`bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,z?fe?Oe:ke:Oe),children:(0,$.jsxs)(`div`,{className:`flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:J(`block min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground`,Pn&&`animate-text-shimmer`),"aria-busy":Pn||void 0,children:pa(vt,d)}),yt?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro tabular-nums text-muted-foreground`,children:yt}):null,Ke?(0,$.jsx)(Z,{name:`ai-agent`,className:`size-3 shrink-0 text-muted-foreground`,"aria-label":`Assistant`}):null,Fn>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:Fn})]}):null,Ln?(0,$.jsx)(`span`,{className:J(`inline-flex shrink-0 items-center justify-center transition-none`,Rn?J(`group-hover:hidden group-focus-within:hidden`,qt?`hidden`:``):qt?`invisible`:``),children:zn}):null,ie?(0,$.jsx)(kx,{number:ie}):null]})})}),fe?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:vt}),(0,$.jsx)(`div`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:Ut})]}),ae?(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,ue?(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]})})]})})}),Gn&&!L?(0,$.jsx)(`div`,{className:J(`absolute top-1/2 -translate-y-1/2 z-10`,pe?`right-0`:`right-[30px]`),children:Gn}):null,(0,$.jsxs)(`div`,{className:J(`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`,qt||z&&!fe?`opacity-100`:J(`opacity-0`,ve)),children:[Se?(0,$.jsx)(Dx,{pinned:Ft,pinLabel:n(Ft?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`),buttonSizeClass:Ce,iconSizeClass:Te,onPointerDown:cn,onMouseDown:ln,onPin:un}):null,be?(0,$.jsxs)(na,{children:[(0,$.jsx)($i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:J(`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`,Ce),"aria-label":n(`sessions.sidebar.session.actions.pinned`),onPointerDown:cn,onMouseDown:ln,onClick:mn,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(Z,{name:`pushpin-2-fill`,className:Te})})}),(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,ye?(0,$.jsxs)(na,{children:[(0,$.jsx)($i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:J(`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`,Ce),"aria-label":n(`sessions.sidebar.session.actions.openInEditor`),onPointerDown:_n,onMouseDown:vn,onClick:yn,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(Z,{name:`external-link`,className:Te})})}),(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)(Ox,{archiveLabel:n(`sessions.sidebar.bulkActions.archive`),deleteLabel:n(`sessions.sidebar.bulkActions.delete`),deleteOnly:s===!0,buttonSizeClass:Ce,iconSizeClass:Te,revealClassName:pe&&!z&&!qt?J(`opacity-0`,ve):`opacity-100`,onPointerDown:cn,onMouseDown:ln,onArchive:dn,onDelete:pn})]})]}),qn]})}),!zt&&Pt&&Lt?r.children.map(e=>{let t=re?re(e):{subtreeContainsActive:H,subtreeContainsEditing:te,menuOpenSessionId:ne,nodeStructureKey:``};return ee(e,i+1,q??a,o,s,void 0,V,t)}):null,(0,$.jsx)(hr,{open:$e,onOpenChange:et,children:(0,$.jsxs)(fr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,$.jsxs)(ur,{children:[(0,$.jsx)(pr,{children:n(`sessions.sidebar.session.export.dialog.title`)}),(0,$.jsx)(mr,{children:n(Zt===1?`sessions.sidebar.session.export.dialog.descriptionSingle`:`sessions.sidebar.session.export.dialog.descriptionMany`,{count:Zt})})]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-ui-label cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:tt,onChange:e=>nt(e.target.checked),className:`h-4 w-4 rounded border-border accent-primary`}),n(`sessions.sidebar.session.export.dialog.includeSubtasks`)]}),(0,$.jsxs)(dr,{children:[(0,$.jsx)(Y,{type:`button`,onClick:()=>et(!1),variant:`outline`,size:`sm`,children:n(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{type:`button`,onClick:()=>{et(!1),tn(tt)},size:`sm`,children:n(`sessions.sidebar.session.export.dialog.confirm`)})]})]})}),Jt?(0,$.jsx)(lx,{session:Ge,open:Yt,onOpenChange:Xt}):null]},We.id)}var jx=e=>_t(e.session.directory??null),Mx=(e,t)=>(e?.projectLabel??null)===(t?.projectLabel??null)&&(e?.branchLabel??null)===(t?.branchLabel??null),Nx=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},Px=e=>e.menuOpenSessionId??Nx(e),Fx=(e,t,n)=>t?n.has(e.node.session.id)?!0:Kv(e.node,t):!1,Ix=(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(Ix(e.children[a],t.children[a],n,r,i))return!0;return!1},Lx=(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&&Wv(a)!==Wv(o)||e.children.length!==t.children.length)return!0;for(let i=0;i<e.children.length;i+=1)if(Lx(e.children[i],t.children[i],n,r))return!0;return!1},Rx=(e,t)=>{if(e.hasSessionSearchQuery||t.hasSessionSearchQuery)return!1;let n=e.archivedBucket?`archived`:`active`,r=t.archivedBucket?`archived`:`active`;return Ix(e.node,t.node,e.expandedParents,t.expandedParents,t=>`${e.renderContext??`project`}:${n}:${t.session.id}`)||Ix(e.node,t.node,e.expandedParents,t.expandedParents,e=>`${t.renderContext??`project`}:${r}:${e.session.id}`)},zx=Q.memo(Ax,(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||jx(e.node)!==jx(t.node)||!Mx(e.secondaryMeta,t.secondaryMeta)||e.liveSessionById!==t.liveSessionById&&Lx(e.node,t.node,e.liveSessionById,t.liveSessionById)||e.pinnedSessionIds!==t.pinnedSessionIds&&Ix(e.node,t.node,e.pinnedSessionIds,t.pinnedSessionIds,e=>e.session.id)||e.expandedParents!==t.expandedParents&&Rx(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&&(Kv(e.node,e.copiedSessionId)||Kv(t.node,t.copiedSessionId)))return!1;if(e.openSidebarMenuKey!==t.openSidebarMenuKey){let n=Px(e),r=Px(t);if(Kv(e.node,n)||Kv(t.node,r))return!1}if(e.renamingFolderId!==t.renamingFolderId){let n=Px(e),r=Px(t);if(Kv(e.node,n)||Kv(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 Bx(e){return e.stopPropagation()}function Vx(e){return e.stopPropagation()}function Hx(e){let t=(0,Ll.c)(71),{t:n}=At(),{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=hr,g=!!r,t[13]===i?_=t[14]:(_=e=>{e||i(null)},t[13]=i,t[14]=_),u=fr,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)(pr,{children:a}),t[18]=a,t[19]=p),c=mr,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)(dr,{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 Ux(e){let t=(0,Ll.c)(57),{t:n}=At(),{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)(pr,{children:d}),t[10]=d,t[11]=g);let _;t[12]===p?_=t[13]:(_=(0,$.jsx)(mr,{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)(dr,{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)(fr,{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)(hr,{open:m,onOpenChange:h,children:M}),t[53]=m,t[54]=M,t[55]=h,t[56]=N):N=t[56],N}function Wx(e){let t=(0,Ll.c)(36),{t:n}=At(),{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)(pr,{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)(mr,{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)(dr,{children:[h,_]}),t[26]=_,t[27]=h,t[28]=v):v=t[28];let y;t[29]!==v||t[30]!==f?(y=(0,$.jsxs)(fr,{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)(hr,{open:o,onOpenChange:s,children:y}),t[32]=o,t[33]=s,t[34]=y,t[35]=b):b=t[35],b}var Gx=e=>{let t=(0,Ll.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}=At(),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)(_a,{children:[(0,$.jsxs)(na,{children:[(0,$.jsx)($i,{asChild:!0,children:(0,$.jsx)(Ma,{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)(ha,{align:`end`,className:`min-w-[180px]`,children:[i.length===0?(0,$.jsx)(va,{disabled:!0,className:`text-muted-foreground`,children:f(`sessions.sidebar.folders.none`)}):i.map(e=>(0,$.jsx)(va,{onClick:()=>o(e.id),children:(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e.name})},e.id)),(0,$.jsx)(La,{}),(0,$.jsxs)(va,{onClick:s,children:[(0,$.jsx)(Z,{name:`add`,className:`mr-1 h-4 w-4`}),f(`sessions.sidebar.folders.newFolderEllipsis`)]}),l?(0,$.jsxs)(va,{onClick:c,className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(Z,{name:`close`,className:`mr-1 h-4 w-4`}),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=J(`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)($i,{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)(na,{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)($i,{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)(na,{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},Kx=e=>{let{t}=At(),{isInlineEditing:n,showDeletionDialog:r,foldersMap:i,addSessionsToFolder:a,removeSessionsFromFolders:o,createFolderAndStartRename:s,archiveSessions:c,setBulkDeleteConfirm:l}=e,u=kb(e=>e.enabled),d=kb(e=>e.selectedIds.size),f=d>0,p=kb(e=>e.selectedIds),m=kb(e=>e.scopeKey),h=Q.useCallback(()=>{kb.getState().toggleMode()},[]),g=Q.useCallback(()=>{kb.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(_)dc({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&&tc({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&&X.error(r.length===1?t(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):t(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}kb.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(),kb.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=kb.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;kb.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}},qx=(e,t,n)=>{let r=[],i=new Set,a=e=>{let t=_t(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},Jx=(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},Yx=({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=Jx(r,e,o,i)??{scope:`project`,sessionId:e,projectId:i};return!a||t.scope===`project`?s:Jx(n,e,o,i)??s};function Xx(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 Zx=`yuri.sessions.projectCollapse`,Qx=`yuri.sessions.groupOrder`,$x=`yuri.sessions.groupCollapse`,eS=`yuri.sessions.activeSessionByProject`,tS=`yuri.sessions.expandedParents.v2`,nS=`yuri.sessions.expandedParents`,rS=Ze(Ue()),iS=e=>{try{let t=rS.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}},aS=e=>{try{let t=rS.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}},oS=e=>{try{let t=rS.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}},sS=(e,t,n)=>{let r=new Set;for(let t of e){let e=_t(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=_t(t.path)?.toLowerCase();e&&r.add(e)}return r},cS=(e,t,n)=>{if(e.time?.archived)return!0;let r=_t(Wn(e))?.toLowerCase();return r?t.size===0?n?.allowEmptyDirectorySet??!0:t.has(r):n?.allowUnknownDirectory??!0},lS=new Set,uS=[],dS={},fS=e=>{let t=Q.useRef(e);return t.current=e,Q.useMemo(()=>(...e)=>t.current(...e),[])},pS=Q.memo(function(e){let t=(0,Ll.c)(3),{onOpenChange:n}=e,r=_s(ae(hS)),i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(gs,{open:!0,onOpenChange:n,...r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}),mS=Q.memo(function({mobileVariant:e=!1,onSessionSelected:t,allowReselect:n=!1,hideDirectoryControls:r=!1,showOnlyMainWorkspace:i=!1,isVisible:a=!0}){let{t:o}=At(),[c,l]=Q.useState(!1),[u,d]=Q.useState(!1),[f,m]=Q.useState(``),h=Q.useRef(null),g=Q.useRef(null),[_,v]=Q.useState(null),[y,b]=Q.useState(``),[x,S]=Q.useState(null),[C,E]=Q.useState(new Set),D=Q.useMemo(()=>rS,[]),[O,k]=Q.useState(new Set),[A,j]=Q.useState(new Map),[M,N]=Q.useState(new Map),P=q(e=>e.isNewWorktreeDialogOpen),F=q(e=>e.setNewWorktreeDialogOpen),[I,L]=Q.useState(null),[R,z]=Q.useState(null),[ee,B]=Q.useState(``),[V,H]=Q.useState(null),[te,ne]=Q.useState(null),[re,U]=Q.useState(null),ie=un(),ae=Ut(),[W,oe]=Q.useState(()=>iS($x)),[G,se]=Q.useState(()=>oS(Qx)),[ce,le]=Q.useState(()=>aS(eS));Q.useEffect(()=>s(e=>{p(e)&&(oe(iS($x)),se(oS(Qx)),le(aS(eS)),k(iS(Zx)),E(iS(tS)))}),[]);let[ue,de]=Q.useState(new Map),fe=Q.useRef(0),pe=Me(e=>e.homeDirectory),me=Me(e=>e.currentDirectory),he=Me(e=>e.setDirectory),ge=kn(e=>e.projects),_e=kn(e=>e.activeProjectId),ve=kn(e=>e.removeProject),ye=kn(e=>e.setActiveProjectIdOnly),be=kn(e=>e.updateProjectMeta),xe=kn(e=>e.reorderProjectsById),Se=q(e=>e.setActiveMainTab),Ce=q(e=>e.activeMainTab),we=Ht(),Te=q(e=>e.setSettingsDialogOpen),Ee=q(e=>e.toggleHelpDialog),De=q(e=>e.setSessionSwitcherOpen),Oe=q(e=>e.setScheduledTasksDialogOpen),ke=q(e=>e.notifyOnSubtasks),Ae=q(e=>e.showDeletionDialog),je=q(e=>e.setShowDeletionDialog),Ne=to(f,120),K=Q.useMemo(()=>Ne.trim().toLowerCase(),[Ne]),Pe=K.length>0,Fe=_s(e=>e.available&&(e.runtimeType===`desktop`||e.runtimeType===`web`)),Ie=sn(e=>e.collapsedFolderIds),Le=sn(e=>e.foldersMap),Re=sn(e=>e.sessionOrderByScope),ze=sn(e=>e.sessionOrderActivityByScope),Be=sn(e=>e.getFoldersForScope),Ve=sn(e=>e.createFolder),He=sn(e=>e.renameFolder),Ue=sn(e=>e.deleteFolder),qe=sn(e=>e.addSessionToFolder),Je=sn(e=>e.addSessionsToFolder),Ye=sn(e=>e.removeSessionFromFolder),Xe=sn(e=>e.removeSessionsFromFolders),Ze=sn(e=>e.toggleFolderCollapse),Qe=sn(e=>e.getSessionFolderId),$e=sn(e=>e.reorderSessions);bv({isSessionSearchOpen:a&&u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchContainerRef:h});let et=Q.useMemo(()=>new Map,[]),tt=dn({enabled:a,includeChildren:!0}),nt=Wc({enabled:a}),rt=Nc({enabled:a}),it=zn(e=>a?e.index.session.unseenCount:dS),at=Q.useMemo(()=>T(),[]),ot=vn(e=>e.status),st=vn(e=>e.activeSessions),ct=vn(e=>e.archivedSessions),lt=vn(e=>e.loadingDirectories.size>0||e.refreshingDirectories.size>0),ut=vn(e=>e.archivedLoadingDirectories),dt=Q.useDeferredValue(st),ft=Q.useDeferredValue(ct),pt=Vn(e=>e.currentSessionId),mt=Ui(e=>e.focus),ht=Q.useSyncExternalStore(Ke,We,We),gt=Vn(e=>!!e.newSessionDraft?.open),vt=Vn(e=>e.setCurrentSession),yt=Vn(e=>e.updateSessionTitle),bt=Vn(e=>e.shareSession),xt=Vn(e=>e.unshareSession),St=Vn(e=>e.worktreeMetadata),Ct=Vn(e=>e.availableWorktreesByProject),Tt=Vn(e=>e.openNewSessionDraft),Et=wt(e=>{Tt(e),at&&window.dispatchEvent(new CustomEvent(`yuri:navigate`,{detail:{view:`chat`}}))}),Dt=Q.useMemo(()=>sS(ge,Ct,{includeWorktrees:!at}),[Ct,at,ge]),Ot=Q.useMemo(()=>{let e=new Map(tt.map(e=>[e.id,e])),t=dt.map(t=>{let n=e.get(t.id);return n?_n(n,t):t}),n=new Set(t.map(e=>e.id));return tt.forEach(e=>{n.has(e.id)||t.push(e)}),t.filter(e=>cS(e,Dt,{allowUnknownDirectory:!at,allowEmptyDirectorySet:!at}))},[dt,at,Dt,tt]),kt=Q.useMemo(()=>tt.map(e=>{let t=_t(e.directory??null)??``;return`${e.id}:${e.title??``}:${+!!e.time?.archived}:${t}`}).join(`|`),[tt]),jt=Q.useRef(tt);Q.useEffect(()=>{jt.current=tt},[kt,tt]);let Mt=Q.useMemo(()=>new Map(tt.map(e=>[e.id,e])),[tt]);Q.useEffect(()=>{let e=null,t=Nn(t=>{t.type===`scheduled-task-ran`&&(e&&clearTimeout(e),e=setTimeout(()=>{let e=kn.getState().projects.find(e=>e.id===t.projectId),n=_t(e?.path??null);if(!n)return;let r=[n];(Vn.getState().availableWorktreesByProject.get(n)??[]).forEach(e=>{let t=_t(e.path);t&&r.push(t)}),an(r,jt.current)},500))});return()=>{e&&clearTimeout(e),t()}},[]);let Pt=Q.useMemo(()=>w(),[]),Ft=Wl(),It=Fs(e=>e.sidebarBrandName.trim().length>0),{isTablet:Lt,isDesktop:Rt}=Ka(),zt=e||Lt,{buildGroupSearchText:Bt,filterSessionNodesForSearch:Vt,buildGroupedSessions:Wt}=yv({homeDirectory:pe,worktreeMetadata:St,pinnedSessionIds:ie,gitBranches:et,isVSCode:at}),{scheduleCollapsedProjectsPersist:Gt,hasRestoredProjectCollapse:Kt}=Dv({isVSCode:at,safeStorage:D,keys:{sessionExpanded:tS,sessionExpandedLegacy:nS,projectCollapse:Zx,groupOrder:Qx,projectActiveSession:eS,groupCollapse:$x},groupOrderByProject:G,activeSessionByProject:ce,collapsedGroups:W,setExpandedParents:E,setCollapsedProjects:k}),qt=Q.useMemo(()=>[...Ot].sort((e,t)=>Fa(e,t,ie)),[Ot,ie]),Jt=Q.useMemo(()=>{let e=new Map;return qt.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)=>Fa(e,t,ie))),e},[qt,ie]),Yt=(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`)})]}),Xt=Q.useMemo(()=>ge.find(e=>e.id===x)??null,[ge,x]),Zt=Q.useCallback(e=>{x&&be(x,{label:e.label,icon:e.icon,color:e.color,iconBackground:e.iconBackground,defaultModel:e.defaultModel??null})},[x,be]),Qt=Q.useCallback(()=>{F(!0)},[F]),$t=Q.useCallback((t,n)=>{if(Se(`chat`),e&&De(!1),n?.sessionId){vt(n.sessionId,t);return}Tt({directoryOverride:t,preserveDirectoryOverride:!0})},[e,Tt,Se,vt,De]),tn=wt(()=>{let e=_s.getState();if(e.available&&e.info){l(!0);return}e.checkForUpdates().then(()=>{let{available:e,error:t}=_s.getState();if(t){X.error(o(`sessions.sidebar.updateCheck.errorTitle`),{description:t});return}if(!e){X.success(o(`sessions.sidebar.updateCheck.latestVersion`));return}l(!0)})}),rn=Q.useCallback(()=>{e&&De(!1),Te(!0)},[e,De,Te]),on=Q.useCallback(()=>{Se(`chat`),Tt(),e&&De(!1)},[e,Tt,Se,De]),cn=Q.useCallback(()=>{if(!e){Se(`schedule`);return}Oe(!0),De(!1)},[e,Se,Oe,De]),fn=Q.useCallback(()=>{ar(),e&&De(!1)},[e,De]),pn=Vn(e=>e.archiveSession),mn=Vn(e=>e.archiveSessions),{copiedSessionId:hn,handleSessionSelect:gn,handleSessionDoubleClick:bn,handleSaveEdit:xn,handleCancelEdit:Sn,handleShareSession:Cn,handleCopyShareUrl:wn,handleUnshareSession:Tn,handleDeleteSession:En,confirmDeleteSession:Dn}=xv({activeProjectId:_e,currentDirectory:me,currentSessionId:pt,mobileVariant:e,allowReselect:n,onSessionSelected:t,isSessionSearchOpen:u,sessionSearchQuery:f,setSessionSearchQuery:m,setIsSessionSearchOpen:d,setActiveProjectIdOnly:ye,setDirectory:he,setActiveMainTab:Se,setSessionSwitcherOpen:De,setCurrentSession:vt,updateSessionTitle:yt,shareSession:bt,unshareSession:xt,archiveSession:pn,archiveSessions:mn,childrenMap:Jt,showDeletionDialog:Ae,setDeleteSessionConfirm:H,deleteSessionConfirm:V,setEditingId:v,setEditTitle:b,editingId:_,editTitle:y}),On=Q.useCallback((e,t,n,r=`project`)=>{let i={sessionId:e,scope:r,projectId:n??null};if(e===pt){Ge(e),Tx(i),gn(e,t,n);return}Cx(i,()=>gn(e,t,n))},[gn,pt]);Q.useEffect(()=>()=>{Sx()},[]);let An=Q.useCallback(()=>{if(!te)return;let{scopeKey:e,folderId:t}=te;ne(null),Ue(e,t)},[te,Ue]);Q.useEffect(()=>{if(!pt)return;let e=Ot.find(e=>e.id===pt)?.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(tS,JSON.stringify(Array.from(n)))}catch{}return n})},[pt,Ot,D]);let jn=Q.useCallback(e=>{E(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{D.setItem(tS,JSON.stringify(Array.from(n)))}catch{}return n})},[D]),Mn=Q.useCallback((e,t)=>{if(!e)return null;t&&Ie.has(t)&&Ze(t);let n=Ve(e,o(`sessions.sidebar.folder.newFolderName`),t);return z(n.id),B(n.name),n},[Ie,Ze,Ve,o]),Pn=wt(On),Fn=wt(bn),In=wt(xn),Ln=wt(Sn),Rn=wt(Cn),Bn=wt(wn),Hn=wt(Tn),Un=wt(En),Gn=wt(Mn),Kn=wt((e,t,n,r)=>{let i=pc(),a=Math.max(i,n)+7;if(N(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=_t(e.directory??null);if(!o)return;let s=vn.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&nn(o)}),qn=wt(e=>{N(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})}),Jn=wt(e=>{N(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})}),Yn=Q.useMemo(()=>e=>{let t=ge.find(t=>t.id===e),n=_t(t?.path??null);if(!n)return[];let r=[n];return at||(Ct.get(n)??[]).forEach(e=>{let t=_t(e.path);t&&r.push(t)}),r},[Ct,at,ge]),Zn=wt(e=>{let t=Yn(e);if(t.length===0)return;let n=vn.getState().loadedDirectories,r=t.filter(e=>!n.has(e));r.length!==0&&an(r,jt.current)}),Qn=wt(e=>{let t=ge.find(t=>t.id===e);t&&(async()=>{let e=[];if(!at)try{e=(await as({id:t.id,path:t.path})).worktrees}catch(n){console.warn(`[SessionSidebar] Worktree refresh before session sync failed:`,n);let r=_t(t.path);e=r?Vn.getState().availableWorktreesByProject.get(r)??[]:[]}let n=qx(t.path,e,{currentDirectory:me,workspaceRoot:t.path,includeWorktrees:!at});n.length!==0&&await yn(n,jt.current)})()});Q.useEffect(()=>{if(!Kt)return;let e=vn.getState(),t=ge.flatMap(t=>O.has(t.id)?[]:Yn(t.id).filter(t=>!e.loadedDirectories.has(t)&&!e.loadingDirectories.has(t)&&!e.refreshingDirectories.has(t)));t.length>0&&an(t,jt.current)},[O,Yn,Kt,ge]);let $n=wt(()=>{fe.current=Date.now()+150,N(new Map),k(()=>{let e=new Set(ge.map(e=>e.id));try{D.setItem(Zx,JSON.stringify(Array.from(e)))}catch{}return at||Gt(e),e})}),er=wt(()=>{fe.current=Date.now()+150,N(new Map),k(()=>{let e=new Set;try{D.setItem(Zx,JSON.stringify([]))}catch{}return at||Gt(e),e});let e=vn.getState().loadedDirectories,t=ge.flatMap(t=>Yn(t.id).filter(t=>!e.has(t)));t.length>0&&an(t,jt.current)}),tr=wt(e=>{fe.current=Date.now()+150,Jn(e),k(t=>{let n=new Set(t);n.has(e)?(n.delete(e),queueMicrotask(()=>Zn(e))):n.add(e);try{D.setItem(Zx,JSON.stringify(Array.from(n)))}catch{}return at||Gt(n),n})}),nr=wt(e=>{fe.current=Date.now()+150,Zn(e),k(t=>{if(!t.has(e))return t;let n=new Set(t);n.delete(e);try{D.setItem(Zx,JSON.stringify(Array.from(n)))}catch{}return at||Gt(n),n})}),rr=Q.useMemo(()=>ge.map(e=>({...e,normalizedPath:_t(e.path)})).filter(e=>!!e.normalizedPath),[ge]),ir=Q.useMemo(()=>rr.map(e=>e.normalizedPath),[rr]),or=Q.useMemo(()=>{let e=new Set(rr.map(e=>e.normalizedPath));if(!at)for(let t of Ct.values())for(let n of t){let t=_t(n.path);t&&e.add(t)}return[...e].sort()},[Ct,at,rr]),sr=Q.useRef(null);Q.useEffect(()=>{let e=new Set(or),t=sr.current;if(sr.current=e,!t)return;let n=or.filter(e=>!t.has(e));if(n.length===0)return;let r=vn.getState().loadedDirectories,i=_t(me),a=rr.find(e=>e.id===_e)??rr.find(e=>e.normalizedPath===i)??null,o=new Set;i&&o.add(i),a?.normalizedPath&&(o.add(a.normalizedPath),at||(Ct.get(a.normalizedPath)??[]).forEach(e=>{let t=_t(e.path);t&&o.add(t)}));let s=n.filter(e=>o.has(e)&&!r.has(e));s.length!==0&&an(s,jt.current)},[_e,Ct,me,at,rr,or]);let cr=no(a?ir:uS);kv({normalizedProjects:rr,activeProjectId:_e,gitRepoStatus:cr,setProjectRepoStatus:j,setProjectRootBranches:de,enabled:a});let lr=Q.useMemo(()=>Ts(Ot,rr,Ct,at,ft),[ft,Ct,at,rr,Ot]),{getSessionsForProject:ur,getArchivedSessionsForProject:dr}=Av({ownership:lr}),fr=lt||ot===`idle`||ot===`loading`,pr=Q.useRef(!1);_e&&A.has(_e)&&(pr.current=!!A.get(_e));let mr=Xn(e=>e.projectSortOrder),hr=Q.useMemo(()=>Mc(rr,mr),[rr,mr]),{projectSections:gr,groupSearchDataByGroup:_r,sectionsForRender:vr,searchMatchCount:yr}=gv({normalizedProjects:hr,getSessionsForProject:ur,getArchivedSessionsForProject:dr,availableWorktreesByProject:Ct,projectRepoStatus:A,projectRootBranches:ue,lastRepoStatus:pr.current,buildGroupedSessions:Wt,hasSessionSearchQuery:Pe,normalizedSessionSearchQuery:K,filterSessionNodesForSearch:Vt,buildGroupSearchText:Bt,foldersMap:Le}),br=(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`)})]});_v({projectSections:gr,activeProjectId:_e,activeSessionByProject:ce,setActiveSessionByProject:le,currentSessionId:pt,handleSessionSelect:gn,newSessionDraftOpen:gt,mobileVariant:e,openNewSessionDraft:Tt,setActiveMainTab:Se,setSessionSwitcherOpen:De});let{getOrderedGroups:xr}=vv(G),Sr=Q.useRef(!1);Q.useEffect(()=>{if(Sr.current||gr.length===0)return;let e=gr.flatMap(e=>e.groups.filter(e=>e.isArchivedBucket).map(t=>`${e.project.id}:${t.id}`));e.length>0&&oe(t=>new Set([...t,...e])),Sr.current=!0},[gr]);let Cr=Q.useMemo(()=>{let e=new Map,t=new Map;return gr.forEach(n=>{let r=Nt(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},[gr]);Q.useLayoutEffect(()=>{if(!pt){Tx(null);return}let e=Ui.getState().focus;if(e?.sessionId===pt){e.scope===`project`&&!e.projectId&&Tx({...e,projectId:Cr.get(pt)?.projectId??null});return}Tx({scope:`project`,sessionId:pt,projectId:Cr.get(pt)?.projectId??null})},[pt,Cr]);let wr=Q.useMemo(()=>at?[]:zc(Ot,ie,Re[_c]),[at,ie,Ot,Re]),Tr=wt((e,t)=>{_||$e(_c,wr.map(e=>e.id),e,t,{}).catch(()=>X.error(o(`sessions.order.saveFailed`)))}),Er=Q.useMemo(()=>Pe?[]:Gc(Ot,ie,rt,it),[Pe,ie,rt,Ot,it]),{pinnedItems:Dr,inProgressItems:Or}=Q.useMemo(()=>{let e=e=>{let t=Cr.get(e.id),n=_t(e.directory??null),r={session:e,children:[],worktree:St.get(e.id)??null};if(Pe&&Vt([r],K).length===0)return null;let i=lr.bySessionId.get(e.id),a=i?hr.find(e=>e.id===i.projectId):void 0,o=a?Nt(a.normalizedPath)||a.normalizedPath:t?.secondaryMeta?.projectLabel??null,s=xc({projectLabel:o,owner:i,sessionWorktree:St.get(e.id)??null,worktrees:a?Ct.get(a.normalizedPath)??[]:[],projectRootBranch:i?ue.get(i.projectId)??(a?cr.get(a.normalizedPath)?.branch:null)??null:null,isVSCode:at})??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:at?[]:t(wr),inProgressItems:t(Er)}},[Ct,Vt,cr,Pe,Er,at,K,wr,ue,lr,Cr,hr,St]),kr=Q.useMemo(()=>vr.map(e=>({...e,groups:e.groups.filter(e=>!e.isArchivedBucket)})),[vr]),Ar=Q.useMemo(()=>{let e=Pe?kr.map(e=>({...e,groups:e.groups.map(e=>({...e,sessions:_r.get(e)?.filteredNodes??[]}))})):kr;if(!i)return e;let t=e.find(e=>e.project.id===_e)??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]}]:[]},[_e,_r,Pe,kr,i]),jr=Q.useMemo(()=>Hc({sections:Ar,foldersMap:Le,getOrderedGroups:xr,pinnedSessionIds:ie,sessionOrderByScope:Re,sessionOrderActivityByScope:ze}),[Le,xr,Ar,ie,ze,Re]),Mr=Q.useMemo(()=>nc({targets:jr,collapsedProjectIds:O,collapsedGroupKeys:W,collapsedFolderIds:Ie,visibleSessionCountByGroup:M,defaultVisibleSessionCount:pc(),hasSessionSearchQuery:Pe,alwaysVisibleSessionIds:nt}),[nt,Ie,W,O,Pe,jr,M]),Nr=Q.useMemo(()=>Pe?[]:[...Dr,...Or].map((e,t)=>{let n=e.node.session;return{scope:`pinned`,sessionId:n.id,projectId:e.projectId,directory:_t(Wn(n))??e.groupDirectory??null,visibleIndex:t}}),[Pe,Or,Dr]),[Pr,Fr]=Q.useState(null),Ir=Q.useCallback(e=>{Fr(t=>t&&t.length===e.length&&t.every((t,n)=>t===e[n])?t:[...e])},[]),Lr=Q.useMemo(()=>{if(!Pr)return Nr;let e=new Set(Pr);return Nr.filter(t=>e.has(t.sessionId))},[Nr,Pr]),Rr=Q.useMemo(()=>e?[]:Ri({pinnedTargets:Lr,projectTargets:Mr}),[e,Lr,Mr]),zr=Q.useCallback(e=>{Se(`chat`),De(!1),e.scope===`project`&&e.projectId&&ye(e.projectId),On(e.sessionId,e.directory,e.projectId,e.scope)},[On,Se,ye,De]);Q.useLayoutEffect(()=>Oi({targets:Rr,activate:zr}),[zr,Rr]);let Br=Q.useMemo(()=>{let e=new Map;return Rr.forEach(t=>{let n=bi({scope:t.scope,sessionId:t.sessionId,projectId:t.projectId});n&&e.set(n,mi(Rr,t)??0)}),e},[Rr]),Vr=Q.useMemo(()=>{if(!pt||Pe)return[];let e=[],t=(n,r)=>{if(n.session.id===pt){e.push({scope:`pinned`,sessionId:pt,projectId:r});return}n.children.forEach(e=>t(e,r))};return Dr.forEach(e=>t(e.node,e.projectId)),Or.forEach(e=>t(e.node,e.projectId)),e},[pt,Pe,Or,Dr]),Hr=Q.useMemo(()=>{if(!pt)return[];let e=[],t=(n,r)=>{if(n.session.id===pt){e.push({scope:`project`,sessionId:pt,projectId:r});return}n.children.forEach(e=>t(e,r))};return gr.forEach(e=>{e.groups.forEach(n=>{n.sessions.forEach(n=>t(n,e.project.id))})}),e},[pt,gr]);Q.useLayoutEffect(()=>ki({pinned:Lr,project:Mr}),[Lr,Mr]),Q.useLayoutEffect(()=>{fr||Tx(Yx({currentSessionId:pt,focus:mt,pinnedFocuses:Vr,projectFocuses:Hr,fallbackProjectId:pt?Cr.get(pt)?.projectId??null:null}))},[pt,fr,Hr,Vr,mt,Cr]);let Ur=Q.useMemo(()=>{let e=mt?.sessionId?Cr.get(mt.sessionId)?.projectId??null:null;return Xx(mt,jr,e)},[jr,mt,Cr]),Wr=Q.useRef(null),Gr=Q.useRef(null);Q.useEffect(()=>{Gr.current&&Gr.current!==pt&&(Gr.current=null)},[pt]),Q.useLayoutEffect(()=>{if(!Ur?.projectId)return;let e=Ur.sessionId,t=ht.sessionId===e;if(!(!t&&pt!==e)){if(t){if(Wr.current===ht.revision)return;Wr.current=ht.revision,Gr.current=e}else{if(Gr.current===e)return;Gr.current=e}if(nr(Ur.projectId),Ur.groupKey&&oe(e=>{if(!e.has(Ur.groupKey))return e;let t=new Set(e);return t.delete(Ur.groupKey),t}),Ur.folderAncestorIds?.forEach(e=>{let t=sn.getState();t.collapsedFolderIds.has(e)&&t.toggleFolderCollapse(e)}),Ur.groupKey&&Ur.visibleIndex!==void 0){let e=Ur.visibleIndex+1;N(t=>{if((t.get(Ur.groupKey)??0)>=e)return t;let n=new Map(t);return n.set(Ur.groupKey,e),n})}}},[pt,Ur,ht]);let Kr=fS((t,n=0,r,i,a=!1,o,s=`project`,c)=>(0,$.jsx)(zx,{node:t,depth:n,groupDirectory:r,projectId:i,archivedBucket:a,currentSessionId:pt,pinnedSessionIds:ie,expandedParents:C,hasSessionSearchQuery:Pe,normalizedSessionSearchQuery:K,notifyOnSubtasks:ke,editingId:_,setEditingId:v,editTitle:y,setEditTitle:b,handleSaveEdit:In,handleCancelEdit:Ln,toggleParent:jn,handleSessionSelect:Pn,handleSessionDoubleClick:Fn,togglePinnedSession:ae,handleShareSession:Rn,copiedSessionId:hn,handleCopyShareUrl:Bn,handleUnshareSession:Hn,openSidebarMenuKey:I,setOpenSidebarMenuKey:L,renamingFolderId:R,getFoldersForScope:Be,getSessionFolderId:Qe,removeSessionFromFolder:Ye,addSessionToFolder:qe,createFolderAndStartRename:Gn,handleDeleteSession:Un,mobileVariant:e,alwaysShowActions:zt,renderSessionNode:Kr,secondaryMeta:o,renderContext:s,subtreeContainsActive:c?.subtreeContainsActive??lS,subtreeContainsEditing:c?.subtreeContainsEditing??lS,menuOpenSessionId:c?.menuOpenSessionId??null,nodeStructureKey:c?.nodeStructureKey??``,childRenderExtrasFor:c?.childRenderExtrasFor,liveSessionById:Mt,shortcutNumber:Br.get(bi({scope:s,sessionId:t.session.id,projectId:i??null})??``)??null},`${s}:${i??``}:${t.session.id}`)),qr=Q.useCallback(e=>{qn(e),oe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[qn]),Jr=Q.useCallback(e=>{let t=Yn(e);if(t.length===0)return;let n=vn.getState(),r=t.filter(e=>!n.archivedLoadedDirectories.has(e));r.length>0&&en(r)},[Yn]),Yr=wt((e,t,n,r,i)=>{let a=e.folderScopeKey??_t(e.directory??null);a&&$e(a,t,n,r,i).catch(()=>X.error(o(`sessions.order.saveFailed`)))}),Xr=wt((e,t,n)=>{e.isArchivedBucket&&W.has(t)&&n&&Jr(n),qr(t)}),Zr=Q.useMemo(()=>(t,n,r,i,a,o,s)=>(0,$.jsx)(dy,{group:t,groupKey:n,isArchivedLoading:!!(t.isArchivedBucket&&r&&Yn(r).some(e=>ut.has(e))),projectId:r,hideGroupLabel:i,compactBodyPadding:o,hasSessionSearchQuery:Pe,normalizedSessionSearchQuery:K,groupSearchDataByGroup:_r,visibleSessionCount:M.get(n),collapsedGroups:W,collapsedFolderIds:Ie,toggleFolderCollapse:Ze,renameFolder:He,deleteFolder:Ue,showDeletionDialog:Ae,setDeleteFolderConfirm:ne,renderSessionNode:Kr,projectRepoStatus:A,lastRepoStatus:pr.current,showMoreGroupSessions:Kn,resetGroupSessionLimit:qn,mobileVariant:e,alwaysShowActions:zt,activeProjectId:_e,setActiveProjectIdOnly:ye,setActiveMainTab:Se,setSessionSwitcherOpen:De,openNewSessionDraft:Et,addSessionToFolder:qe,createFolderAndStartRename:Gn,renamingFolderId:R,renameFolderDraft:ee,setRenameFolderDraft:B,setRenamingFolderId:z,pinnedSessionIds:ie,expandedParents:C,sessionOrderByScope:Re,sessionOrderActivityByScope:ze,onReorderSessions:Yr,currentSessionId:pt,shortcutTargetSessionId:Ur?.groupKey===n?Ur.sessionId:null,shortcutTargetVisibleIndex:Ur?.groupKey===n?Ur.visibleIndex??null:null,editingId:_,editTitle:y,openSidebarMenuKey:I,liveSessionById:Mt,alwaysVisibleSessionIds:nt,onToggleCollapsedGroup:Xr,dragHandleProps:a,scrollContainerRef:s}),[Pe,K,_r,ut,Yn,M,W,Ie,Ze,He,Ue,Ae,Kr,A,Kn,qn,e,zt,_e,ye,Se,De,Et,qe,Gn,R,ee,ie,C,Re,ze,Yr,pt,Ur,_,y,I,Mt,nt,Xr]),Qr=r?null:(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Cy,{collapseAllProjects:$n,expandAllProjects:er}),(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:ln.requestDirectoryDialog,children:(0,$.jsx)(Z,{name:`add`,className:`size-4`})})]}),$r=Pt&&!Ft&&It&&!at&&!Pe?(0,$.jsx)(`div`,{className:`shrink-0 px-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(gd,{className:`min-w-0 flex-1`}),(0,$.jsx)(Fc,{className:`ml-auto shrink-0`})]})}):null,ei=!at&&!Pe,ti=ei&&Rt&&!Ft&&!e,ni=!Pe&&(Dr.length>0||Or.length>0),ri=(0,$.jsxs)(`div`,{className:`space-y-0.5 py-1`,children:[(0,$.jsxs)(Y,{variant:`ghost`,size:`sm`,className:J(`w-full justify-start px-2 font-normal`,e&&`h-11`),onClick:on,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:J(`w-full justify-start px-2 font-normal`,Ce===`schedule`&&`bg-interactive-selection text-interactive-selection-foreground`,e&&`h-11`),onClick:cn,children:[(0,$.jsx)(Z,{name:`time`,className:`size-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`sessions.sidebar.header.actions.scheduledTasks`)}),a?(0,$.jsx)(tv,{}):null]}),we.data?.supported&&we.data?.enabled?(0,$.jsxs)(Y,{variant:`ghost`,size:`sm`,className:J(`w-full justify-start px-2 font-normal`,Ce===`assistant`&&`bg-interactive-selection text-interactive-selection-foreground`,e&&`h-11`),onClick:fn,children:[(0,$.jsx)(Jc,{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)(al,{className:`h-3.5 min-w-3.5 bg-[oklch(from_var(--primary-base)_calc(l_*_0.78)_c_h)] px-1 text-[10px] text-[var(--color-white)] shadow-none`}),a?(0,$.jsx)(nv,{}):null]})]}):null,(0,$.jsx)(Ps,{sidebar:!0,mobile:e})]}),ii=ei&&!ti||ni?(0,$.jsxs)($.Fragment,{children:[ei&&!ti?(0,$.jsxs)($.Fragment,{children:[e&&It?(0,$.jsx)(gd,{}):null,ri]}):null,ni?(0,$.jsx)(my,{items:Dr,reorderEnabled:!0,onSessionsReordered:Tr,inProgressItems:Or,renderSessionNode:Kr,currentSessionId:pt,editingId:_,openSidebarMenuKey:I,onVisibleSessionIdsChange:Ir}):null]}):null,ai=!!(R||_||x),{selectionModeEnabled:oi,hasSelection:si,selectedIdsSize:ci,bulkScopeIsArchived:li,derivedSelectionScope:ui,bulkScopeFolders:di,bulkCanRemoveFromFolder:fi,handleExitSelectionMode:pi,handleBulkMoveToFolder:hi,handleBulkCreateFolderAndMove:gi,handleBulkRemoveFromFolder:vi,handleBulkDelete:yi,confirmBulkDelete:xi}=Kx({isInlineEditing:ai,showDeletionDialog:Ae,foldersMap:Le,addSessionsToFolder:Je,removeSessionsFromFolders:Xe,createFolderAndStartRename:Mn,archiveSessions:mn,setBulkDeleteConfirm:U});return(0,$.jsxs)(`div`,{ref:h,className:J(`yuri-session-sidebar relative flex h-full flex-col text-foreground overflow-x-hidden`,e?``:`bg-transparent`),children:[(0,$.jsx)(fy,{hideDirectoryControls:r,isSessionSearchOpen:u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchQuery:f,setSessionSearchQuery:m,hasSessionSearchQuery:Pe,searchMatchCount:yr}),$r,ti?(0,$.jsx)(`div`,{className:`shrink-0 px-3`,children:ri}):null,a?(0,$.jsx)(lb,{topContent:ii,hasLeadingSection:ii!==null&&(Dr.length>0||Or.length>0),headerAccessory:Qr,sectionsForRender:kr,projectSections:gr,activeProjectId:_e,showOnlyMainWorkspace:i,hasSessionSearchQuery:Pe,emptyState:Yt,searchEmptyState:br,renderGroupSessions:Zr,homeDirectory:pe,collapsedProjects:O,hideDirectoryControls:r,projectRepoStatus:A,mobileVariant:e,alwaysShowActions:zt,toggleProject:tr,setActiveProjectIdOnly:ye,setActiveMainTab:Se,setSessionSwitcherOpen:De,openNewSessionDraft:Et,openNewWorktreeDialog:Qt,syncProjectSessions:Qn,openProjectEditDialog:S,removeProject:ve,projectReorderEnabled:mr===`manual`,reorderProjects:xe,projectSortOrder:mr,getOrderedGroups:xr,setGroupOrderByProject:se,openSidebarMenuKey:I,setOpenSidebarMenuKey:L,isInlineEditing:ai}):null,oi&&si?(0,$.jsx)(Gx,{selectedCount:ci,scopeKey:ui,scopeFolders:di,archivedBucket:li,onMoveToFolder:hi,onCreateFolderAndMove:gi,onRemoveFromFolder:vi,canRemoveFromFolder:fi,onDelete:yi,onDone:pi}):null,(0,$.jsx)(sv,{normalizedProjects:rr,ownership:lr,enabled:a}),(0,$.jsx)(eb,{onOpenSettings:rn,onOpenShortcuts:Ee,onOpenUpdate:tn,showRuntimeButtons:!at,showUpdateButton:Fe}),c?(0,$.jsx)(pS,{onOpenChange:l}):null,Xt?(0,$.jsx)(jv,{open:!0,onOpenChange:e=>{e||S(null)},project:Xt,onSave:Zt}):null,P?(0,$.jsx)(_i,{open:!0,onOpenChange:F,onWorktreeCreated:$t}):null,(0,$.jsx)(sc,{}),(0,$.jsx)(Rs,{}),(0,$.jsx)(Hx,{value:V,setValue:H,showDeletionDialog:Ae,setShowDeletionDialog:je,onConfirm:Dn}),(0,$.jsx)(Wx,{value:te,setValue:ne,onConfirm:An}),(0,$.jsx)(Ux,{value:re,setValue:U,showDeletionDialog:Ae,setShowDeletionDialog:je,onConfirm:xi})]})});function hS(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 gS=e=>e?(0,$.jsx)(`span`,{className:`text-foreground/80 dark:text-foreground/70`,children:e}):void 0,_S=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.replace(/\/+$/,``)},vS=()=>{let{t:e}=At(),[t,n]=Q.useState(!1),[r,i]=Q.useState(null),[a,o]=Q.useState([]),[s,c]=Q.useState(!1),[l,u]=Q.useState(!1),[d,f]=Q.useState(!1),[p,m]=Q.useState(!1),[h,g]=Q.useState(new Set),_=Vn(e=>e.getWorktreeMetadata),v=Vn(e=>e.newSessionDraft),y=Vn(e=>e.setNewSessionDraftTarget),b=Vn(e=>e.setDraftBootstrapPendingDirectory),x=$t,S=Vn(e=>e.archiveSessions),C=q(e=>e.showDeletionDialog),w=q(e=>e.setShowDeletionDialog),T=Me(e=>e.currentDirectory),E=Me(e=>e.homeDirectory),D=kn(e=>e.projects),O=kn(e=>e.activeProjectId),{isMobile:k,isTablet:A,hasTouchInput:j}=Ka(),M=k||A||j,N=Q.useMemo(()=>_S((O?D.find(e=>e.id===O)??null:null)?.path??T),[O,T,D]),P=Q.useCallback(e=>{let t=_S(e.projectDirectory)||N;return{id:(D.find(e=>_S(e.path)===t)??null)?.id??`path:${t}`,path:t}},[N,D]),F=p&&h.size>0,I=Q.useMemo(()=>{let e=r?.worktree;return e&&typeof e.branch==`string`&&e.branch.trim().length>0?!0:a.length>0&&a.every(({metadata:e})=>typeof e.branch==`string`&&e.branch.trim().length>0)},[r?.worktree,a]),L=r?.mode===`worktree`,R=L,z=d||!L||!I,ee=d||!L,B=Q.useCallback(e=>{i({sessions:e.sessions,dateLabel:e.dateLabel,mode:e.mode??`session`,worktree:e.worktree??null})},[]),V=Q.useCallback(()=>{i(null),o([]),c(!1),u(!1),f(!1),m(!1),g(new Set)},[]),H=Q.useCallback(t=>{if(t.sessions.length===0)return;let n=t.sessions.map(e=>e.id);dc({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(()=>ln.onDeleteRequest(e=>{if(!C&&(e.mode??`session`)===`session`){H(e);return}B(e)}),[B,C,H]),Q.useEffect(()=>ln.onDirectoryRequest(()=>{n(!0)}),[]),Q.useEffect(()=>{if(!r){o([]),c(!1),u(!1),m(!1),g(new Set);return}let e=r.sessions.map(e=>{let t=_(e.id);return t?{session:e,metadata:t}:null}).filter(e=>!!e);o(e),c(!1),m(!1),g(new Set);let t=new Map;if(r.worktree?.path&&t.set(_S(r.worktree.path),r.worktree),e.forEach(({metadata:e})=>{e.path&&t.set(_S(e.path),e)}),t.size===0){m(!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 is(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&&(g(r),m(!0),i(t=>{if(!t?.worktree?.path)return t;let n=_S(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}}}),o(t=>t.map(t=>{let n=_S(t.metadata.path),r=e.get(n);return r?{session:t.session,metadata:{...t.metadata,status:r}}:t})))})(),()=>{n=!0}},[r,_]),Q.useEffect(()=>{I||c(!1)},[I]);let te=Q.useCallback(async(t,n)=>{let r=s&&I,i=P(t),a=_S(t.path),o=_S(i.path);try{await ns(i,t,{deleteRemoteBranch:r,deleteLocalBranch:n});let e=_S(v?.directoryOverride);return v?.open&&a&&e===a&&o&&(b(null),y({projectId:i.id,directoryOverride:o},{force:!0})),_S(T)===a&&o&&Me.getState().setDirectory(o,{showOverlay:!1}),!0}catch(t){return X.error(e(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:gS(t instanceof Error?t.message:e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),!1}},[I,T,s,P,v?.directoryOverride,v?.open,b,y,e]),ne=Q.useCallback((t,n)=>{let r=s&&I;(async()=>{if(!await te(t,n))return;let i=e(r?`sessions.sidebar.sessionDialogs.worktree.removedWithRemote`:`sessions.sidebar.sessionDialogs.worktree.removed`);X.success(e(`sessions.sidebar.sessionDialogs.worktree.removedTitle`),{description:gS(i)})})()},[I,s,te,e]),re=Q.useCallback(async()=>{if(r){f(!0);try{let t=R&&l;if(r.sessions.length===0&&L&&r.worktree){ne(r.worktree,t),V();return}if(r.sessions.length===1){let t=r.sessions[0];if(L){if(!await x(t.id)){X.error(e(`sessions.sidebar.session.archive.error`)),f(!1);return}tc({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 dc({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=r.sessions.map(e=>e.id),i=[],a=[];if(L){let e=await S(n);i=e.archivedIds,a=e.failedIds}else dc({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})}),i=n,a=[];if(L&&r.worktree&&a.length===0&&ne(r.worktree,t),L&&i.length>0&&tc({sessionIds:i,message:i.length===1?e(`sessions.sidebar.bulkActions.archivedSingle`,{count:i.length}):e(`sessions.sidebar.bulkActions.archivedPlural`,{count:i.length}),undoLabel:e(`sessions.sidebar.undo`),settingsLabel:e(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:i.length===1?e(`sessions.sidebar.session.archive.undoFailed`):e(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:i.length})}),a.length>0&&(X.error(L?a.length===1?e(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:a.length}):e(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:a.length}):a.length===1?e(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:a.length}):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:a.length}),{description:gS(e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),i.length===0)){f(!1);return}}L&&r.sessions.length===1&&r.worktree&&ne(r.worktree,t),V()}finally{f(!1)}}},[r,l,x,S,V,R,L,ne,e]),U=r?.worktree??a[0]?.metadata??null,ie=r?r.mode===`worktree`?r.sessions.length===0?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked`):r.sessions.length===1?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked`,{count:r.sessions.length}):e(`sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked`,{count:r.sessions.length}):r.sessions.length===1?r.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate`,{dateLabel:r.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionOne`):r.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate`,{count:r.sessions.length,dateLabel:r.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionMany`,{count:r.sessions.length}):``,ae=r?(0,$.jsxs)(`div`,{className:J(L?`space-y-3`:`space-y-2`),children:[r.sessions.length>0&&(0,$.jsxs)(`div`,{className:J(L?`rounded-lg bg-muted/30 p-3`:`space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3`),children:[L&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:r.sessions.length===1?e(`sessions.sidebar.sessionDialogs.linkedSessionSingle`):e(`sessions.sidebar.sessionDialogs.linkedSessionPlural`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:r.sessions.length})]}),(0,$.jsxs)(`ul`,{className:J(L?`mt-2 space-y-1`:`space-y-0.5`),children:[r.sessions.slice(0,5).map(t=>(0,$.jsxs)(`li`,{className:J(L?`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:J(!L&&`hidden`),children:`•`}),(0,$.jsx)(`span`,{className:`truncate`,children:t.title||e(`sessions.sidebar.session.untitled`)})]},t.id)),r.sessions.length>5&&(0,$.jsx)(`li`,{className:J(L?`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:r.sessions.length-5})})]})]}),L?(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`)}),U?.label?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:U.label}):null]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/80 break-all`,children:U?Dt(U.path,E):e(`sessions.sidebar.sessionDialogs.worktree.pathUnavailable`)}),F&&(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,W=L?I?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{z||c(e=>!e)},disabled:z,className:J(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,z?`cursor-not-allowed opacity-60`:`hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),children:[s?(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,oe=L?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{ee||u(e=>!e)},disabled:ee,className:J(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,ee?`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.deleteLocalBranch`)]}):null,G=L?(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:[oe,W]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{variant:`ghost`,onClick:V,disabled:d,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{variant:`destructive`,onClick:re,disabled:d,children:e(d?`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:()=>w(!C),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":!C,children:[C?(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:V,disabled:d,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{variant:`destructive`,onClick:re,disabled:d,children:d?e(`sessions.sidebar.sessionDialogs.actions.deleting`):r?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`)})]})]}),se=L?e(`sessions.sidebar.sessionDialogs.actions.deleteWorktree`):r?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`);return(0,$.jsxs)($.Fragment,{children:[M?(0,$.jsx)(ua,{open:!!r,onClose:()=>{d||V()},title:se,footer:(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:G}),children:(0,$.jsxs)(`div`,{className:`space-y-2 pb-2`,children:[ie&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/80`,children:ie}),ae]})}):(0,$.jsx)(hr,{open:!!r,onOpenChange:e=>{if(!e){if(d)return;V()}},children:(0,$.jsxs)(fr,{className:J(L?`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)(pr,{className:J(L&&`flex items-center gap-2`),children:[L&&(0,$.jsx)(Z,{name:`delete-bin`,className:`h-5 w-5`}),se]}),ie&&(0,$.jsx)(mr,{children:ie})]}),(0,$.jsx)(`div`,{className:J(L&&`flex-1 min-h-0 overflow-y-auto space-y-2`),children:ae}),(0,$.jsx)(dr,{className:`mt-2 gap-2 pt-1 pb-1`,children:G})]})}),(0,$.jsx)(Qc,{open:t,onOpenChange:n})]})};function yS(){let{host:e,snapshot:t,inventory:n,error:r,requested:i,requestLoad:a}=ko(),{t:o}=At(),s=q(e=>e.activeGuiPage),c=q(e=>e.isMobile);Q.useEffect(()=>{i||a()},[i,a]);let l=t.pages.find(e=>e.key===s),u=t.plugins.find(e=>e.id===l?.pluginId)?.revision,d;try{let e=JSON.parse(s??`null`);Array.isArray(e)&&typeof e[0]==`string`&&(d=e[0])}catch{}let f=t.plugins.some(e=>e.id===d&&e.status===`failed`)||n.some(e=>e.id===d&&e.error)||!l&&!!r;return c?null:(0,$.jsx)(`div`,{"data-gui-plugin-page":!0,className:`flex h-full min-h-0 min-w-0 flex-col py-1.5 pl-1 pr-1.5 text-foreground`,children:(0,$.jsx)(Od,{"data-gui-plugin-page-surface":!0,children:e&&l?(0,$.jsx)(Da,{fallback:(0,$.jsx)(hl,{message:o(`guiPlugins.error`)}),children:(0,$.jsx)(ml,{host:e,kind:`page`,contributionKey:l.key,revision:u})},JSON.stringify([l.key,u])):f?(0,$.jsx)(hl,{message:o(`guiPlugins.error`)}):null})})}var bS=Q.createContext(null),xS=e=>{let t=(0,Ll.c)(3),{children:n,value:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(bS.Provider,{value:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},SS=xo(()=>gt(()=>import(`./TerminalView-DsqOYj1E.js`).then(e=>({default:e.TerminalView})),__vite__mapDeps([79,1,4,2,3,5,6,7,8,9,10,11,17,12,13,14,16,80,55,56,57,37,38,39,40,15,18,19,20,81,36,41,42,43,44,54,22,58,33,34,35,59,60,61,45,47,82,65,83,84,85,86,87,88,89]))),CS=xo(()=>gt(()=>import(`./DiagramView-BRW8DdSg.js`).then(e=>({default:e.DiagramView})),__vite__mapDeps([90,1,3,2,7,8,9,10,11,13,14,17,12,16,4,58,36,5,6,37,38,39,40,41,20,42,43,44,47,65,55,56,57,15,18,19,54,22,33,34,35,59,60,61,91,92]))),wS=xo(()=>gt(()=>import(`./SettingsView-Ci7GRXnm.js`).then(e=>e.n).then(e=>({default:e.SettingsView})),__vite__mapDeps([93,1,2,3,4,5,6,94,95,9,7,55,56,57,10,11,8,37,12,16,14,38,39,40,15,17,13,18,19,20,22,96,97,98,58,33,34,35,36,41,42,43,44,99,100,54,59,60,61,47,101,62,102,103,67,45,46,48,49,63,104,105,106,107,108,109,52,110,82,111,83,112,113,85,86,87,114,115,53,23,24,25,26,27,28,29,30,31,32,64,65,66,116,68,117,84,118,119,120,121,122,123,74,124,125,126,127,128,129,130,89,76,131,132,133,134,135,136,137,138,139,140]))),TS=xo(()=>gt(()=>import(`./SettingsWindow-DjqjH8zU.js`).then(e=>({default:e.SettingsWindow})),__vite__mapDeps([141,1,7,12,36,5,2,3,6,37,4,9,10,11,8,16,14,38,39,40,41,20,42,43,44,93,94,95,55,56,57,15,17,13,18,19,22,96,97,98,58,33,34,35,99,100,54,59,60,61,47,101,62,102,103,67,45,46,48,49,63,104,105,106,107,108,109,52,110,82,111,83,112,113,85,86,87,114,115,53,23,24,25,26,27,28,29,30,31,32,64,65,66,116,68,117,84,118,119,120,121,122,123,74,124,125,126,127,128,129,130,89,76,131,132,133,134,135,136,137,138,139,140]))),ES=xo(()=>gt(()=>import(`./MultiRunWindow-PFfaS1N3.js`).then(e=>({default:e.MultiRunWindow})),__vite__mapDeps([142,1,7,12,36,5,2,3,6,37,4,9,10,11,8,16,14,38,39,40,41,20,42,43,44,47,143,55,56,57,15,17,13,18,19,33,34,35,54,22,58,59,60,61,104,144,105,106,82,145,146,147,148,101,62,102,103,67,45,46,149,111,83,113,110,109,52,85,86,87,126]))),DS=xo(()=>gt(()=>import(`./AssistantView-DXibp8Nh.js`).then(e=>e.n).then(e=>({default:e.AssistantView})),__vite__mapDeps([150,1,2,3,5,6,7,8,9,10,11,12,13,14,58,33,34,35,36,37,4,16,38,39,40,41,20,42,43,44,99,15,17,18,19,22,100,54,55,56,57,59,60,61,47,101,62,102,103,67,45,46,48,49,63,82,151,51,109,52,135,152,71,69,70,111,83,153,154,146,147,148,115,149,64,65,66,155,156,157,131,112]))),OS=()=>{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}=Ka(),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=sr(-E.current),O=(0,Q.useRef)(0),k=sr(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),cr(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),cr(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=Vn.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)(_m,{isActive:!v})});case`diff`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(vc,{})});case`terminal`:return n?null:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(SS,{})});case`files`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(uf,{})});case`diagram`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(CS,{})});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)(uc,{children:(0,$.jsxs)(`div`,{"data-page-scroll-lock":`true`,className:J(`main-content-safe-area`,f?`flex h-[100dvh] flex-col`:`relative flex h-[100dvh]`,`bg-background`),children:[(0,$.jsx)(Vc,{}),(0,$.jsx)(q_,{}),(0,$.jsx)(Z_,{}),(0,$.jsx)(vS,{}),(0,$.jsx)(tl,{}),f?(0,$.jsxs)(xS,{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)(ed,{onToggleLeftDrawer:()=>{let e=!g;v&&y(!1),w(e)},onToggleRightDrawer:()=>{j()},leftDrawerOpen:g,rightDrawerOpen:v}),(0,$.jsx)(`div`,{"data-page-scroll-lock":`true`,className:J(`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)(Da,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Zs,{})})})}),P&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Da,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(DS,{})})})}),R&&(0,$.jsx)(`div`,{className:J(`absolute inset-0`,!L&&`invisible`),children:(0,$.jsx)(Da,{children:(0,$.jsx)(Dc,{})})}),R&&M&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Da,{children:M})}),u&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(Da,{children:(0,$.jsx)(Ml,{onCreated:()=>d(!1),onCancel:()=>d(!1)})})}),(0,$.jsx)(ls.div,{className:J(`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)(Da,{children:(0,$.jsx)(mS,{mobileVariant:!0,isVisible:b})})}),S&&(0,$.jsx)(ls.div,{className:`absolute inset-0 z-20 bg-sidebar`,"data-page-scroll-lock":`true`,style:{x:k},"aria-hidden":!v,children:(0,$.jsx)(Da,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(_m,{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)(Da,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(wS,{onClose:()=>l(!1)})})})}),(0,$.jsx)(Da,{children:(0,$.jsx)(ac,{})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(bd,{}),(0,$.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:[(0,$.jsx)(md,{isOpen:e,isMobile:f,className:`border-border/50`,topBar:(0,$.jsx)(hd,{}),children:(0,$.jsx)(mS,{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)(Da,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:F?(0,$.jsx)(yS,{}):P?(0,$.jsx)(DS,{}):(0,$.jsx)(Zs,{})})})}):(0,$.jsxs)(G_,{header:(0,$.jsx)(ed,{}),footer:(0,$.jsx)(ad,{isOpen:n,isMobile:f,children:n?(0,$.jsx)(Da,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(SS,{})})}):null}),children:[R&&(0,$.jsx)(`div`,{className:J(`absolute inset-0`,!L&&`invisible`),children:(0,$.jsx)(Da,{children:(0,$.jsx)(Dc,{})})}),R&&M&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Da,{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)(ES,{open:u,onOpenChange:d})})]})]})})},kS=9e4,AS=15e3,jS=3e5,MS=[2e3,5e3],NS=6e4,PS=12e4,FS=3e5,IS=4,LS=432e5,RS=`yuri.github-pr-status`,zS=e=>e===`closed`||e===`merged`,BS=e=>{let t=e?.checks;return t?t.state===`pending`||t.pending>0:!1},VS=(e,t,n)=>`${e}::${t}`,HS=new Map,US=new Map,WS=new Set,GS=new Map,KS=2,qS=0,JS=[],YS=()=>qS<KS?(qS+=1,Promise.resolve()):new Promise(e=>{JS.push(e)}),XS=()=>{let e=JS.shift();if(e){e();return}qS=Math.max(0,qS-1)},ZS=()=>({status:null,isLoading:!1,error:null,isInitialStatusResolved:!1,lastRefreshAt:0,lastDiscoveryPollAt:0,watchers:0,params:null,identity:null,resolvedRemoteName:null}),QS=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,$S=e=>{let t=QS(e);return!t?.directory||!t.branch?null:`${t.directory}::${t.branch}`},eC=(e,t)=>Object.entries(e).filter(([,e])=>$S(e)===t).map(([e])=>e),tC=(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}}},nC=e=>!e?.params?.canShow||!e.params.github?.prStatus?null:{...e.params,remoteName:e.params.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null},rC=(e,t,n)=>{let r=eC(e,t),i=r.map(t=>nC(e[t])).filter(e=>!!e);if(i.length===0)return null;let a=nC(e[n]);if(a&&$S(e[n])===t)return a;let o=r.map(t=>e[t]).find(e=>!!(e?.resolvedRemoteName&&nC(e)));return o?nC(o):i.find(e=>!!e.remoteName)||(i[0]??null)},iC=e=>({status:e.status,isInitialStatusResolved:e.isInitialStatusResolved,lastRefreshAt:e.lastRefreshAt,lastDiscoveryPollAt:e.lastDiscoveryPollAt,identity:QS(e),resolvedRemoteName:e.resolvedRemoteName??e.status?.resolvedRemoteName??null}),aC=e=>({...ZS(),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}),oC=U()(ie((e,t)=>({entries:{},activeRequestCount:0,totalRequestCount:0,ensureEntry:t=>{e(e=>e.entries[t]?e:{entries:{...e.entries,[t]:ZS()}})},setParams:(t,n)=>{e(e=>{let r=e.entries[t]??ZS();return{entries:{...e.entries,[t]:tC(r,n)}}})},startWatching:n=>{if(e(e=>{let t=e.entries[n]??ZS();return{entries:{...e.entries,[n]:{...t,watchers:t.watchers+1}}}}),HS.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=US.get(n)??[];i.push(r),US.set(n,i)};t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0}),MS.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<jS)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}zS(r.status?.pr?.state)||Date.now()-r.lastRefreshAt<(BS(r.status)?NS:r.status?.checks&&r.status.checks.state!==`pending`?FS:PS)||t().refresh(n,{force:!0,onlyExistingPr:!0,silent:!0,markInitialResolved:!0})}},AS);HS.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=HS.get(n);typeof i==`number`&&window.clearInterval(i),HS.delete(n);let a=US.get(n);a&&a.length>0&&a.forEach(e=>{window.clearTimeout(e)}),US.delete(n)},refresh:async(n,r)=>{let i=t(),a=i.entries[n],o=$S(a);if(!a||!o)return;let s=eC(i.entries,o),c=s.some(e=>!!i.entries[e]?.status?.pr);if(r?.onlyExistingPr&&!c)return;let l=GS.get(o)??0;if(!r?.force&&Date.now()-l<kS||WS.has(o))return;let u=rC(i.entries,o,n);if(u){if(WS.add(o),GS.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}}),WS.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}}),WS.delete(o);return}try{e(e=>({...e,activeRequestCount:e.activeRequestCount+1,totalRequestCount:e.totalRequestCount+1})),await YS();let t;try{t=await u.github.prStatus(u.directory,u.branch,u.remoteName??void 0,{force:r?.force})}finally{XS()}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=QS(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{WS.delete(o),e(e=>({...e,activeRequestCount:Math.max(0,e.activeRequestCount-1)}))}}},refreshTargets:async(e,n)=>{await Ov(Array.from(new Set(e.map(e=>{let t=e.directory.trim(),n=e.branch.trim();return!t||!n?null:VS(t,n,e.remoteName??null)}).filter(e=>!!e))),IS,e=>t().refresh(e,n))},updateStatus:(t,n)=>{e(e=>{let r=e.entries[t]??ZS();return{entries:{...e.entries,[t]:{...r,status:n(r.status)}}}})}}),{name:RS,storage:Ye(),partialize:e=>({entries:Object.fromEntries(Object.entries(e.entries).filter(([,e])=>{let t=QS(e);if(!t?.directory||!t.branch)return!1;let n=Math.max(e.lastRefreshAt,e.lastDiscoveryPollAt);return n===0||Date.now()-n<LS}).map(([e,t])=>[e,iC(t)]))}),merge:(e,t)=>{let n=e?.entries??{};return{...t,entries:Object.fromEntries(Object.entries(n).map(([e,t])=>[e,aC(t)]))}}})),sC=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`},cC=e=>{let t=(0,Ll.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},lC=e=>{let t=(0,Ll.c)(43),{title:n,snapshot:r,emptyLabel:i}=e,{t:a}=At(),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(dC,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?sC(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)(cC,{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)(cC,{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)(cC,{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)(qo,{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},uC=e=>{let t=(0,Ll.c)(104),{onClose:n}=e,{t:r}=At(),[i,a]=Q.useState(`memory`),[o,s]=Q.useState(`idle`),c=Vn(fC),l=fn(pC),u=ir(),d=Cn(),[f,p]=Q.useState(mC),m,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>De(()=>{p(je())}),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=ze(),t={};if(!e){g=t;break bb0}let n=e.getCacheBudget?.(),r=n?n.listCanonical().map(hC):u.map(e=>({directory:d,sessionID:e.id}));for(let n of r){if(d&&n.directory!==d)continue;let r=e.getTranscript(Pe(n.directory,n.sessionID));t[n.sessionID]=r.messageOrder.map(e=>r.messagesByID[e]).filter(gC)}g=t}t[2]=d,t[3]=u,t[4]=g}else g=t[4];let _=g,v=oC(_C),[y,b]=Q.useState(vC),[x,S]=Q.useState(yC),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(Re()),S(ke())};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(bC),t[35]=c,t[36]=_,t[37]=l,t[38]=u,t[39]=r,t[40]=B}else B=t[40];let V=B,H;t[46]===_?H=t[47]:(H=Object.keys(_),t[46]=_,t[47]=H);let te=H.length,ne;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(ne=async()=>{try{let e={generatedAt:new Date().toISOString(),ui:Re(),vscode:ke()};await navigator.clipboard.writeText(JSON.stringify(e,null,2)),s(`copied`)}catch{s(`error`)}},t[48]=ne):ne=t[48];let re=ne,U;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(U={backgroundColor:`color-mix(in srgb, var(--surface-background) 94%, transparent)`},t[49]=U):U=t[49];let ie;t[50]===i?ie=t[51]:(ie=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]=ie);let ae;t[52]===r?ae=t[53]:(ae=r(`memoryDebugPanel.title`),t[52]=r,t[53]=ae);let W;t[54]===ae?W=t[55]:(W=(0,$.jsx)(`h3`,{className:`typography-ui-label font-semibold text-[var(--surface-foreground)]`,children:ae}),t[54]=ae,t[55]=W);let oe;t[56]!==ie||t[57]!==W?(oe=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[ie,W]}),t[56]=ie,t[57]=W,t[58]=oe):oe=t[58];let G;t[59]===i?G=t[60]:(G=i===`streaming`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,onClick:re,children:(0,$.jsx)(Z,{name:`file-copy`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,onClick:()=>{Ce(),b(Re()),S(ke())},children:(0,$.jsx)(Z,{name:`refresh`,className:`h-3.5 w-3.5`})})]}):null,t[59]=i,t[60]=G);let se;t[61]===n?se=t[62]:(se=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]=se);let ce;t[63]!==G||t[64]!==se?(ce=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[G,se]}),t[63]=G,t[64]=se,t[65]=ce):ce=t[65];let le;t[66]!==oe||t[67]!==ce?(le=(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[oe,ce]}),t[66]=oe,t[67]=ce,t[68]=le):le=t[68];let ue;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(ue={backgroundColor:`color-mix(in srgb, var(--surface-muted) 55%, transparent)`},t[69]=ue):ue=t[69];let de=i===`memory`?`secondary`:`ghost`,fe;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(fe=()=>a(`memory`),t[70]=fe):fe=t[70];let pe;t[71]===r?pe=t[72]:(pe=r(`memoryDebugPanel.tabs.memory`),t[71]=r,t[72]=pe);let me;t[73]!==de||t[74]!==pe?(me=(0,$.jsx)(Y,{size:`sm`,variant:de,className:`flex-1`,onClick:fe,children:pe}),t[73]=de,t[74]=pe,t[75]=me):me=t[75];let he=i===`streaming`?`secondary`:`ghost`,ge;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(ge=()=>a(`streaming`),t[76]=ge):ge=t[76];let _e;t[77]===r?_e=t[78]:(_e=r(`memoryDebugPanel.tabs.streaming`),t[77]=r,t[78]=_e);let ve;t[79]!==he||t[80]!==_e?(ve=(0,$.jsx)(Y,{size:`sm`,variant:he,className:`flex-1`,onClick:ge,children:_e}),t[79]=he,t[80]=_e,t[81]=ve):ve=t[81];let ye;t[82]!==me||t[83]!==ve?(ye=(0,$.jsxs)(`div`,{className:`mb-3 flex gap-1 rounded-md p-1`,style:ue,children:[me,ve]}),t[82]=me,t[83]=ve,t[84]=ye):ye=t[84];let be;t[85]!==i||t[86]!==te||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?(be=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)(cC,{label:r(`memoryDebugPanel.metric.totalMessages`),value:ee.total}),(0,$.jsx)(cC,{label:r(`memoryDebugPanel.metric.cachedSessions`),value:`${te} / ${Vr.MAX_SESSIONS}`}),(0,$.jsx)(cC,{label:r(`memoryDebugPanel.metric.userMessages`),value:ee.user}),(0,$.jsx)(cC,{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:$r()})})]}),(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:Vr.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)(qo,{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)(na,{children:[(0,$.jsx)($i,{asChild:!0,children:(0,$.jsx)(Y,{size:`sm`,variant:`outline`,className:`typography-meta`,onClick:()=>{u.map(xC),Object.keys(_),V.map(SC),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:re,children:r(`memoryDebugPanel.actions.copyJson`)})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(cC,{label:r(`memoryDebugPanel.metric.uiMetrics`),value:y.entries.length}),(0,$.jsx)(cC,{label:r(`memoryDebugPanel.metric.vscodeMetrics`),value:x.entries.length}),(0,$.jsx)(cC,{label:r(`memoryDebugPanel.metric.messageListRenders`),value:j.messageListRender}),(0,$.jsx)(cC,{label:r(`memoryDebugPanel.metric.messageListStreamRenders`),value:j.messageListRenderStreaming}),(0,$.jsx)(cC,{label:r(`memoryDebugPanel.metric.chatMessageRenders`),value:j.chatMessageRender}),(0,$.jsx)(cC,{label:r(`memoryDebugPanel.metric.chatMessageStreamRenders`),value:j.chatMessageRenderStreaming}),(0,$.jsx)(cC,{label:r(`memoryDebugPanel.metric.chatMessageStaticDuringStream`),value:j.chatMessageRenderStaticDuringStream}),(0,$.jsx)(cC,{label:r(`memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn`),value:j.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),(0,$.jsx)(lC,{title:r(`memoryDebugPanel.section.uiStreamingMetrics`),snapshot:y,emptyLabel:r(`memoryDebugPanel.section.noUiSamples`)}),x.entries.length>0?(0,$.jsx)(lC,{title:r(`memoryDebugPanel.section.vscodeBridgeMetrics`),snapshot:x,emptyLabel:r(`memoryDebugPanel.section.noVscodeSamples`)}):null]}),t[85]=i,t[86]=te,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]=be):be=t[99];let xe;return t[100]!==le||t[101]!==ye||t[102]!==be?(xe=(0,$.jsxs)(Ta,{className:`fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area`,style:U,children:[le,ye,be]}),t[100]=le,t[101]=ye,t[102]=be,t[103]=xe):xe=t[103],xe};function dC(e,t){return e+t.count}function fC(e){return e.currentSessionId}function pC(e){return e.sessionMemoryState}function mC(){return je()}function hC(e){return e.scope}function gC(e){return!!e}function _C(e){return e.totalRequestCount}function vC(){return Re()}function yC(){return ke()}function bC(e,t){return t.lastAccessed-e.lastAccessed}function xC(e){return{id:e.id,title:e.title}}function SC(e){return{id:e.id,title:e.title,total:e.messageCount,user:e.userMessageCount,assistant:e.assistantMessageCount}}var CC=()=>{let{isMobile:e,closeActiveContextPanelTab:t}=q.getState();if(e)return;let n=jo();n&&t(n)||M()&&R(`desktop_close_current_window`).catch(e=>{console.warn(`[menu-actions] failed to close current window`,e)})},wC=()=>{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=wC()||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`)},EC=`yuri:menu-action`,DC=`yuri:check-for-updates`,OC=e=>typeof e?.listen==`function`?`bridge`:`dom`,kC=e=>{let t=Vn(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=_s(e=>e.checkForUpdates),{setThemeMode:_}=or(),{t:v}=At(),y=Q.useRef(!1),b=typeof window>`u`?null:window.__YURI_DESKTOP__,x=OC(b),S=Q.useCallback(()=>{y.current||(y.current=!0,g().then(()=>{let{available:e,error:t}=_s.getState();if(t){X.error(v(`sessions.sidebar.updateCheck.errorTitle`),{description:t});return}e||X.success(v(`sessions.sidebar.updateCheck.latestVersion`))}).finally(()=>{y.current=!1}))},[g,v]),C=Q.useCallback(()=>{ln.requestDirectoryDialog()},[]),w=Q.useCallback(e=>{Pi(e,Vn.getState().currentSessionId,e=>{s(`chat`),o(!1),Vn.getState().setCurrentSession(e.sessionId,e.directory)})},[s,o]),T=Q.useCallback(e=>{let{activeProjectId:t,projects:n,setActiveProject:r}=kn.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),hi();break;case`change-workspace`:C();break;case`close-tab-or-window`:CC();break;case`toggle-right-sidebar`:{let e=jo();e&&d(e);break}case`open-right-sidebar-git`:{let e=jo();e&&q.getState().openContextPanel(e),f(!0),p(`git`);break}case`open-right-sidebar-files`:{let e=jo();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`:gi();break;case`zoom-out`:vi();break;case`zoom-reset`:Hi();break;case`go-back`:Me.getState().goBack();break;case`go-forward`:Me.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`:Yi().catch(()=>{X.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(EC,e),window.addEventListener(DC,t),()=>{window.removeEventListener(EC,e),window.removeEventListener(DC,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])},AC=(e,t)=>e<t?-1:+(e>t),jC=e=>JSON.stringify([...e.entries()].map(([e,t])=>[e,[...new Set(t)].sort(AC)]).sort(([e],[t])=>AC(e,t)));async function MC({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 NC=`yuri:tray-action`,PC=3e4,FC=120,IC=20,LC=()=>{if(typeof window>`u`)return!1;let e=window.__YURI_PLATFORM__;return e===`darwin`||e===`win32`},RC=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},zC=e=>{let t=Array.isArray(e.questions)?e.questions[0]:void 0;return t?.header||t?.question||`Question`},BC=e=>tr(e),VC=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t},HC=(e,t,n,r)=>{if(!e)return``;let i=Hn(t,n,e),a=VC(i?i.path:e),o=Tn(e),s=o&&r.get(o)||``;if(!s){for(let[e,t]of lo.getState().directories)if(Tn(e)===o){s=t.status?.current??``;break}}if(!s)for(let e of n.values()){let t=e.find(e=>Tn(e.path)===o);if(t?.branch){s=t.branch;break}}return s?`${a} · ${s}`:a},UC=()=>{let{results:e,dropdownProviderIds:t,displayMode:n}=Is.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 ws(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:ra(n.label??t),value:da(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}},WC=async()=>{try{if(L())return`Local Yuri`;let e=window.__YURI_LOCAL_ORIGIN__||window.location.origin,t=m();if(t&&te(t,e))return`Local Yuri`;let n=(await re()).hosts.find(e=>t?te(t,H(e)):!1);return n?.label?.trim()?V(n.label.trim()):`Instance`}catch{return``}},GC=()=>{let e=new Map,t=new Map,n=[],r=new Map,i;try{i=Te()}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(Tn(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:RC(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:zC(r),directory:a})}}return{statusById:e,branchByDirectory:t,approvals:n,titleById:r}},KC=()=>{let e=vn.getState().activeSessions,t=new Set;e.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>BC(t)-BC(e)).slice(0,IC).forEach(e=>{let n=Wn(e);n&&t.add(n)});let n=new Map;for(let r of e){if(!r?.id)continue;let e=Wn(r);if(!e||!t.has(e))continue;let i=n.get(e)??[];i.push(r.id),n.set(e,i)}return n},qC=e=>{let t=GC(),n=zn.getState().index.session,r=vn.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=cn.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=kn.getState().projects,d=Vn.getState().availableWorktreesByProject,f=r.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>BC(t)-BC(e)).slice(0,IC).map(e=>{let r=[e.id,...o(e.id)],i=Wn(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:HC(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:UC(),dockBadgeCount:h}},JC=()=>{Q.useEffect(()=>{if(!LC()||!M())return;let e=!1,t=``,n=null,r=``,i=()=>{if(e)return;let n=qC(r),i=JSON.stringify(n);i!==t&&(t=i,R(`desktop_tray_update`,n))};WC().then(t=>{e||(r=t,i())});let a=null,o=``,s=()=>{let e=Zt.getState();return e.isConnected&&e.connectionPhase===`connected`},c=()=>{if(a)return a;let t=KC();return o=jC(t),a=MC({targets:t,isReady:s,concurrency:2,isDisposed:()=>e,fetchStatus:async()=>{try{let e=await Se.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)=>{Mn(e,t,[...n])}}).finally(()=>{a=null;let t=KC();!e&&s()&&jC(t)!==o&&c()}),a},l=()=>{e||n!==null||(n=window.setTimeout(()=>{n=null,i()},FC))},u=new Map,d=()=>{if(e)return;let t;try{t=Te()}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=Te().subscribeRegistry(()=>{d(),l()})}catch{}d();let p=zn.subscribe(()=>l()),m=vn.subscribe(()=>{l(),s()&&jC(KC())!==o&&c()}),h=kn.subscribe(()=>l()),g=Vn.subscribe(()=>l()),_=lo.subscribe(()=>l()),v=q.subscribe(()=>l()),y=cn.subscribe(()=>l()),b=s(),x=Zt.subscribe(()=>{let e=s();e&&!b&&c(),b=e});b&&c();let S=Is.subscribe(()=>l());Is.getState().loadSettings().then(()=>{if(e)return;let{dropdownProviderIds:t,results:n}=Is.getState();t.length>0&&t.some(e=>!n.some(t=>t?.providerId===e))&&Is.getState().fetchAllQuotas()});let C=window.setInterval(()=>{let e=Is.getState();e.autoRefresh&&e.dropdownProviderIds.length>0&&e.fetchAllQuotas()},Math.max(3e4,Is.getState().refreshIntervalMs||6e4)),w=window.setInterval(()=>{d(),i()},PC);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(!LC()||typeof window>`u`)return;let e=window.__YURI_DESKTOP__?.listen;if(typeof e!=`function`)return;let t=e=>{e.type===`respond-permission`&&Gn(e.sessionId,e.id,e.response).catch(()=>{X.error(`Failed to respond to permission request`)})},n=null;return e(NC,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{}}},[])},YC=`/api/notifications/stream`,XC=()=>typeof document>`u`||document.visibilityState===`visible`&&document.hasFocus(),ZC=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}},QC=e=>{let t=(0,Ll.c)(3),n=e?.enabled??!0,r,i;t[0]===n?(r=t[1],i=t[2]):(r=()=>{if(!n||w()||!v()||typeof window>`u`||typeof EventSource>`u`)return;let e=new EventSource(c().sse(YC));return e.onmessage=$C,()=>{e.close()}},i=[n],t[0]=n,t[1]=r,t[2]=i),Q.useEffect(r,i)};function $C(e){let t;try{t=JSON.parse(e.data)}catch{return}let n=q.getState();if(!n.nativeNotificationsEnabled)return;let r=ZC(t);r&&((r.requireHidden??n.notificationMode!==`always`)&&XC()||B()?.notifications?.notifyAgentCompletion(r))}var ew=`pwa-install-toast-shown`,tw=`pwa-install-toast-dismissed`,nw=()=>{let e=(0,Ll.c)(6),{browserTab:t}=zs(),{t:n}=At(),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`||!v()||!t)return;let e=null,n=null,i=()=>{n!==null&&(X.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`&&X.success(r.current(`pwa.installPrompt.started`))},o=t=>{let o=t;if(typeof o.prompt!=`function`)return;o.preventDefault(),e=o;let s=Ue(),c=He();rl({dismissed:s.getItem(tw),sessionShown:c.getItem(ew),hasActiveToast:n!==null})&&(c.setItem(ew,`true`),n=X.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:()=>{Ue().setItem(tw,`true`),i()}}}))},s=()=>{e=null,i(),X.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)};function rw(e){let t=typeof e?.sessionId==`string`?e.sessionId.trim():``;if(!t)return;let n=typeof e?.directory==`string`&&e.directory.trim().length>0?e.directory.trim():null;q.getState().setActiveMainTab(`chat`),Vn.getState().setCurrentSession(t,n)}var iw=({open:e,onOpenChange:t})=>{let{t:n}=At(),[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 Mt())})()},[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)(hr,{open:e,onOpenChange:t,children:(0,$.jsx)(fr,{className:`max-w-xs p-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[(0,$.jsx)(Wa,{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`)})]})})})},aw=(e,t)=>{let n=e.get(t);return typeof n==`string`&&n.trim()||null},ow=(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},sw=()=>{let e=Ls(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=aw(t,`code`),a=js(t),o=us(t),s=aw(t,`error`),c=aw(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(ow(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`})})]})})},cw=()=>{let e=vn(e=>e.startupSyncProgress.active),t=vn(e=>e.startupSyncProgress.phase),n=vn(e=>e.startupSyncProgress.completed),r=vn(e=>e.startupSyncProgress.total),{locale:i,t:a}=At(),[o,s]=Q.useState(!0),c=rt(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},lw=(e,t,n,r=350)=>n?Math.max(0,r-Math.max(0,t-e)):null;function uw(e){let t=(0,Ll.c)(21),{transition:n,ready:r}=e,{t:i}=At(),a=ga(!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=lw(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)(Wa,{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 dw=xo(()=>gt(()=>import(`./OnboardingScreen-BmAImZZZ.js`).then(e=>({default:e.OnboardingScreen})),__vite__mapDeps([158,1,4,2,3,5,6,94,7,37,9,10,11,8,12,16,14,38,39,40,36,41,20,42,43,44,47,48,49,105,114,45]))),fw=36e5,pw=12e5,mw=()=>{let e=(0,Ll.c)(3),t=q(xw),n=q(Sw),r;return e[0]!==t||e[1]!==n?(r=(0,$.jsx)(iw,{open:t,onOpenChange:n}),e[0]=t,e[1]=n,e[2]=r):r=e[2],r},hw=e=>{let t=(0,Ll.c)(21),{onRetry:n,isRetrying:r}=e,{t:i}=At(),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},gw=e=>e?e.replace(/\\/g,`/`).replace(/\/+$/g,``):``,_w=()=>{if(typeof window>`u`||!Ya())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`}},vw=()=>typeof window>`u`?!1:window.location.pathname===vs,yw=e=>{let t=(0,Ll.c)(22),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=e,a=Me(Cw),o=Vn(ww),s=Vn(Tw),c=ai(),l=Q.useRef(null),u;t[0]===n.directory?u=t[1]:(u=gw(n.directory),t[0]=n.directory,t[1]=u);let d=u,f;t[2]===a?f=t[3]:(f=gw(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)(Si,{embeddedBackgroundWorkEnabled:i}),t[14]=i,t[15]=g);let _;t[16]===n.readOnly?_=t[17]:(_=(0,$.jsx)(Dc,{readOnly:n.readOnly}),t[16]=n.readOnly,t[17]=_);let v;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Br,{}),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 bw({apis:e}){Q.useEffect(()=>{Ne(`App:mounted`),Ie()},[]),Q.useEffect(()=>bn(),[]);let t=Zt(e=>e.initializeApp),n=Zt(e=>e.isInitialized),r=Zt(e=>e.isConnected),i=Vn(e=>e.error),a=Vn(e=>e.clearError),o=Vn(e=>!(e.newSessionDraft?.open&&e.currentSessionId===null)),c=Me(e=>e.currentDirectory),l=Me(e=>e.setDirectory),u=Me(e=>e.isSwitchingDirectory),[f,p]=Q.useState(!1),m=Ds(e=>e.refreshStatus),[h,g]=Q.useState(()=>e.runtime.isVSCode),[_,v]=Q.useState(!1),[y,S]=Q.useState(!1),[T,k]=Q.useState(0),[A,M]=Q.useState(0),[N,P]=Q.useState({epoch:0,startedAt:0}),[F,z]=Q.useState(!1),B=Q.useRef(!1),V=q(e=>e.wideChatLayoutEnabled),H=q(e=>e.mobileKeyboardMode),te=Q.useMemo(()=>w(),[]),ne=vn(e=>e.hasCachedSessionIndex),re=vn(e=>e.hasHydratedSessionIndex),[U,ie]=Q.useState(()=>D()),[ae,W]=Q.useState(()=>{let e=E();return e===null?null:O({isDesktopShell:!0,bootOutcome:e})}),oe=Q.useRef(!1),G=Q.useMemo(()=>_w(),[]),se=!G||_,ce=Q.useMemo(()=>vw(),[]);Q.useEffect(()=>(Le(f),()=>{Le(!1)}),[f]),Q.useEffect(()=>{qe(H)},[H]),Q.useEffect(()=>{g(e.runtime.isVSCode)},[e.runtime.isVSCode]),Q.useEffect(()=>{let e=qr(e=>{d(e)&&(te&&P(e=>({epoch:e.epoch+1,startedAt:Date.now()})),Rc(e),M(e=>e+1),S(!1),k(e=>e+1))}),t=s(t=>e.schedule(t));return()=>{t(),e.cancel()}},[te]),Q.useEffect(()=>(document.documentElement.classList.toggle(`wide-chat-layout`,V),()=>{document.documentElement.classList.remove(`wide-chat-layout`)}),[V]),Q.useEffect(()=>(ee(e),()=>ee(null)),[e]),Q.useEffect(()=>{if(G)return;let t=!1;return Yt().then(()=>{t||m(e.github,{force:!0})}),()=>{t=!0}},[e.github,G,m]),Bi();let le=U===`valid`,ue=ae?.screen===`main`,[de,fe]=Q.useState(!1);Q.useEffect(()=>{if(!se||!b({isDesktopShell:te,isInitialized:te&&ue?ne||n&&re:n,bootOutcomeKnown:le,bootViewIsMain:ue}))return;let e,t=setTimeout(()=>{let t=document.getElementById(`initial-loading`);t?(t.classList.add(`fade-out`),e=setTimeout(()=>{t.remove(),fe(!0)},300)):fe(!0)},150);return()=>{clearTimeout(t),e&&clearTimeout(e)}},[se,te,n,le,ue,ne,re]),Q.useEffect(()=>{if(!te||U!==`malformed`)return;let e=document.getElementById(`initial-loading`);e&&(e.textContent=`Desktop startup failed — please restart the app.`)},[te,U]),Q.useEffect(()=>{if(!se||te)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)}},[se,te,n]),Q.useEffect(()=>{if(!se||h)return;let e=!1;return Yt().then(()=>{if(!e)return t()}),()=>{e=!0}},[se,t,h]),Q.useEffect(()=>{if(!se||h||n)return;let e=!0,t,r=0,i=1e3,a=async()=>{if(!e)return;if(r>=10){S(!0);return}let n=Zt.getState();if(n.isInitialized){S(!1);return}if(r+=1,await Yt(),!e)return;await n.initializeApp();let o=Zt.getState();if(!e)return;if(o.isInitialized){S(!1);return}if(r>=10){S(!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)}},[se,T,n,h]),Q.useEffect(()=>{se&&n&&S(!1)},[se,n]),Q.useEffect(()=>{if(!se||!y)return;let e=document.getElementById(`initial-loading`);if(e){e.classList.add(`fade-out`);let t=setTimeout(()=>{e.remove()},300);return()=>clearTimeout(t)}},[se,y]),oi({enabled:se&&!h,source:`startupRecovery`}),Q.useEffect(()=>{u||h||r&&Se.setDirectory(c)},[c,u,r,h]),Q.useEffect(()=>{if(!G||typeof window>`u`)return;let e=e=>{let t=e?.visible===!0;v(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:Za},window.location.origin),()=>{window.removeEventListener(`message`,t),n.__yuriSetEmbeddedVisibility===e&&delete n.__yuriSetEmbeddedVisibility}},[G]),Q.useEffect(()=>{!G?.directory||h||c!==G.directory&&l(G.directory,{showOverlay:!1})},[c,G,h,l]),Q.useEffect(()=>{if(!G||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)}},[G]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;rw(t??{})},t=e=>{let t=e.detail?.assistantID;typeof t==`string`&&t.trim()&&ar(t.trim())},n=e=>{let t=e.detail,n=t?.projectID,r=t?.taskID;n&&r&>(async()=>{let{openScheduledTask:e}=await import(`./scheduledTaskNavigation-7dD6PWMD.js`).then(e=>e.n);return{openScheduledTask:e}},__vite__mapDeps([115,1,8,3,2,9,7,10,11])).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=Me.getState().currentDirectory,{activeProjectId:t,projects:n}=kn.getState(),r=n.find(e=>e.id===t)??null;R(`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=()=>{let e=Vn.getState().currentSessionId;e&&An(e)};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail,n=typeof t?.directory==`string`&&t.directory.trim().length>0?t.directory.trim():null,r=typeof t?.projectId==`string`&&t.projectId.trim().length>0?t.projectId.trim():null,i=typeof t?.initialPrompt==`string`&&t.initialPrompt.trim().length>0?t.initialPrompt.trim():void 0;q.getState().setActiveMainTab(`chat`),q.getState().setSessionSwitcherOpen(!1),Vn.getState().openNewSessionDraft({selectedProjectId:r,directoryOverride:n,preserveDirectoryOverride:!!n,ensureProjectForDirectory:!!n,initialPrompt:i})};return window.addEventListener(`yuri:open-draft-session`,e),()=>window.removeEventListener(`yuri:open-draft-session`,e)},[]),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=kn.getState(),i=r.projects.find(e=>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`||!se||!n||u||oe.current||(oe.current=!0,window.__yuriAppReady=!0,window.dispatchEvent(new Event(`yuri:app-ready`)))},[se,n,u]),ii({enabled:se}),QC({enabled:se}),nw(),qi(),Pc(),kC(wt(()=>{p(e=>!e)})),Q.useEffect(()=>{I()&&yt().then(async e=>{e&&await j(e)}).catch(console.warn)},[]),Q.useEffect(()=>{if(!n||!I()||B.current)return;B.current=!0;let e=!1,t=null,r=null;_s.getState().subscribeDesktopUpdateEvents().then(t=>{if(e){t();return}r=t});let i=()=>{let e=_s.getState();e.checking||e.checkForUpdates()},a=n=>{t=window.setTimeout(()=>{e||(document.visibilityState===`visible`&&i(),a(fw))},n)},o=()=>{if(e||document.visibilityState!==`visible`)return;let t=_s.getState().lastChecked;t!=null&&Date.now()-t<pw||i()};return a(0),window.addEventListener(`focus`,o),()=>{e=!0,t!==null&&window.clearTimeout(t),window.removeEventListener(`focus`,o),r&&r()}},[n]),JC(),Q.useEffect(()=>{if(G)return;let e=e=>{Ot(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)},[G]),Q.useEffect(()=>{G||i&&setTimeout(()=>a(),5e3)},[a,G,i]),Q.useEffect(()=>{if(!te||U!==`not-injected`)return;let e=!1,t=0,n=()=>{if(e)return;t++;let r=D();if(r!==`not-injected`){if(e=!0,ie(r),r===`valid`){let e=E();e&&W(O({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}},[te,U]);let pe=wt(async()=>{if(C({isDesktopShell:w(),isDesktopLocalOriginActive:L()})){await x();return}window.location.reload()}),me=wt(async()=>{if(!F){S(!1),z(!0);try{await Yt(),await Zt.getState().initializeApp()}finally{z(!1)}Zt.getState().isInitialized||k(e=>e+1)}}),he=e=>{if(e.screen===`recovery`)return e.variant};if(te&&ae&&ae.screen!==`main`){if(ae.screen===`chooser`)return(0,$.jsx)(Da,{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)(dw,{mode:`first-launch`,onCliAvailable:pe,onChooseRemote:()=>{}})})})});let e=he(ae),t=ae.screen===`recovery`&&`url`in ae?ae.url:void 0;return(0,$.jsx)(Da,{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)(dw,{mode:`recovery`,recoveryVariant:e,recoveryHostUrl:t,recoveryHostLabel:void 0,onCliAvailable:pe})})})})}if(G)return Xt(),(0,$.jsx)(Da,{children:(0,$.jsx)(Wt,{sdk:Se.getSdkClient(),directory:c||``,bootstrapDirectory:o,children:(0,$.jsx)(Ki,{apis:e,children:(0,$.jsx)(ta,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-background`,children:(0,$.jsx)(yw,{embeddedSessionChat:G,isVSCodeRuntime:h,embeddedBackgroundWorkEnabled:se})})})})},A)});if(ce)return(0,$.jsx)(Da,{children:(0,$.jsx)(sw,{})});if(y&&!n&&!h&&!G)return(0,$.jsx)(Da,{children:(0,$.jsx)(hw,{onRetry:()=>{me()},isRetrying:F})});let ge=!n&&!te;return(0,$.jsx)(Da,{children:(0,$.jsx)(Wt,{sdk:Se.getSdkClient(),directory:c||``,bootstrapDirectory:o,children:(0,$.jsx)(Ki,{apis:e,children:(0,$.jsx)(ic,{ready:de&&n&&se,children:(0,$.jsx)(cp,{children:(0,$.jsx)(ta,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:te?`h-full text-foreground bg-transparent`:`h-full text-foreground bg-background`,children:[(0,$.jsx)(Si,{embeddedBackgroundWorkEnabled:se}),(0,$.jsx)($s,{}),(0,$.jsx)(Zc,{}),(0,$.jsx)(OS,{}),te&&(0,$.jsx)(uw,{transition:N,ready:n&&r}),(0,$.jsx)(cw,{}),(0,$.jsx)(Br,{}),!ge&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kc,{}),(0,$.jsx)(gc,{}),(0,$.jsx)(cc,{}),(0,$.jsx)(mw,{}),f&&(0,$.jsx)(uC,{onClose:()=>p(!1)})]})]})})})})})},A)})}function xw(e){return e.isAboutDialogOpen}function Sw(e){return e.setAboutDialogOpen}function Cw(e){return e.currentDirectory}function ww(e){return e.currentSessionId}function Tw(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 Ew=typeof window<`u`&&window.__YURI_RUNTIME_APIS__||(()=>{throw Error(`Runtime APIs not provided for legacy UI entrypoint.`)})();zt(),w()&&pn(),ri({runtimeKey:f(),initializeAppearance:nt,syncSettings:Qe,applyDirectory:Zi,startWatchers:()=>{Di(),ei(),Hr()},onError:(e,t)=>{console.error(e===`appearance`?`[main] appearance init failed:`:`[main] settings init failed:`,t)}});var Dw=document.getElementById(`root`);if(!Dw)throw Error(`Root element not found`);(0,Il.createRoot)(Dw).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(Ur,{children:(0,$.jsx)(Ft,{children:(0,$.jsx)(Rr,{children:(0,$.jsx)(Ti,{children:(0,$.jsx)(Xr,{children:(0,$.jsx)(Qr,{children:(0,$.jsx)(bw,{apis:Ew})})})})})})})}));
|
|
169
|
+
Now write the final fused answer.`,synthetic:!0}],directory:i??Se.getDirectory()})}catch(e){console.error(`[MultiRunFusion] Failed to start fusion`,e),X.error(r(`multirun.fusion.toast.failed`))}finally{w(!1)}}},disabled:!k,children:r(C?`multirun.fusion.actions.starting`:`multirun.fusion.actions.start`)})]})]})})}function ux(e){let t=(0,Ll.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:lr,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 dx=1/3,fx=1,px=({containerScrollTop:e,containerClientHeight:t,containerScrollHeight:n,rowOffsetFromViewportTop:r})=>{let i=e+(r-t*dx),a=Math.max(0,n-t);return Math.min(a,Math.max(0,i))},mx=()=>typeof window>`u`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`,hx=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},gx=(e,t)=>{let n=hx(e),r=t?.behavior??mx();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=px({containerScrollTop:n.scrollTop,containerClientHeight:n.clientHeight,containerScrollHeight:n.scrollHeight,rowOffsetFromViewportTop:i.top-a});Math.abs(s-n.scrollTop)<fx||n.scrollTo({top:s,behavior:r})},_x=e(ue(),1),vx=null,yx=!1,bx=(e,t=Ui.getState().focus)=>e===null?null:typeof e==`string`?t?.sessionId===e?t:xi(e):e,xx=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))},Sx=()=>{vx&&=(xx(vx),null)},Cx=(e,t)=>{Sx(),In(!0);let n=bx(e);if(!n)return;yx=!0;let r;try{r=Ge(n.sessionId)}finally{yx=!1}vx={commit:t,commitFrame:null,fallbackTimer:null,focus:n,intent:r,paintFrame:null,scheduled:!1},(0,_x.flushSync)(()=>{Ui.getState().setFocus(n)}),typeof window<`u`&&(vx.fallbackTimer=window.setTimeout(()=>{wx(n)},150))},wx=e=>{let t=vx,n=bx(e);if(!t||!li(t.focus,n)||t.scheduled)return;t.scheduled=!0,typeof window<`u`&&t.fallbackTimer!==null&&(window.clearTimeout(t.fallbackTimer),t.fallbackTimer=null);let r=()=>{vx===t&&We()===t.intent&&(vx=null,On(),t.commit())};if(typeof window>`u`){r();return}t.commitFrame=window.requestAnimationFrame(()=>{vx===t&&We()===t.intent&&(t.paintFrame=window.requestAnimationFrame(r))})},Tx=e=>{if(vx)return;let t=Ui.getState();t.setFocus(bx(e,t.focus))};Ke(e=>{if(yx)return;let t=vx;if(t?.intent===e)return;t&&Sx();let n=Ui.getState();n.setFocus(bx(e.sessionId,n.focus))});var Ex=e=>{let t=[],n=e=>{e.children.forEach(e=>{t.push(e.session.id),n(e)})};return n(e),t},Dx=Q.memo(function(e){let t=(0,Ll.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=J(`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=J(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)($i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:u,"aria-label":r,onPointerDown:o,onMouseDown:s,onClick:c,onKeyDown:Bx,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)(na,{children:[h,g]}),t[18]=h,t[19]=g,t[20]=_):_=t[20],_}),Ox=Q.memo(function(e){let t=(0,Ll.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=Hb(),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=J(`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)($i,{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)(na,{children:[S,C]}),t[21]=S,t[22]=C,t[23]=w):w=t[23],w}),kx=Q.memo(function(e){let t=(0,Ll.c)(3),{number:n}=e;if(!ix())return null;let r=Pt()?`⌘${n}`:`Ctrl+${n}`,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(Wi,{"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 Ax(e){let{t:n}=At(),{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,handleSessionDoubleClick:x,togglePinnedSession:S,handleShareSession:C,copiedSessionId:w,handleCopyShareUrl:E,handleUnshareSession:D,setOpenSidebarMenuKey:O,renamingFolderId:k,getFoldersForScope:A,getSessionFolderId:j,removeSessionFromFolder:N,addSessionToFolder:P,createFolderAndStartRename:F,handleDeleteSession:I,mobileVariant:L,alwaysShowActions:z,renderSessionNode:ee,secondaryMeta:B,renderContext:V=`project`,subtreeContainsActive:H,subtreeContainsEditing:te,menuOpenSessionId:ne,childRenderExtrasFor:re,liveSessionById:U,shortcutNumber:ie=null}=e,ae=!!B?.projectLabel,ue=!!B?.branchLabel,de=Xn(e=>e.displayMode),fe=Q.useMemo(()=>T(),[]),pe=de===`minimal`||fe,me=Q.useMemo(()=>M(),[]),_e=Q.useContext(ut),ve=fe?`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`,ye=fe,be=V===`pinned`&&c.has(r.session.id),Se=!be&&!s&&!L,Ce=`h-5 w-5`,Te=`h-3.5 w-3.5`,De=(Se||be?1:0)+ +!!ye+1,Oe=De>=3?`group-hover:pr-18 group-focus-within:pr-18`:De>=2?`group-hover:pr-12 group-focus-within:pr-12`:`group-hover:pr-7 group-focus-within:pr-7`,ke=De>=2?`pr-12`:`pr-8`,Ae=Q.useRef(!1),je=Q.useRef(!1),[Me,Ne]=Q.useState(!1),K=Q.useRef(f);K.current=f;let Fe=Q.useRef(null),Ie=Q.useRef(_);Ie.current=_;let[Le,Re]=Q.useState(h),Be=Q.useRef(Le);Be.current=Le;let Ve=Q.useRef(null),He=Q.useRef(null),Ue=Q.useRef(null),We=r.session,Ge=U.get(We.id)??We,Ke=!!Ge.metadata?.yuri?.assistant,q=_t(We.directory??null)??_t(a??null),qe=hn(q??void 0,{bootstrap:!1}),Je=ai(),Ye=kb(e=>e.enabled),Xe=kb(Q.useMemo(()=>e=>e.selectedIds.has(We.id),[We.id])),Ze=kb(e=>e.toggleSelected),Qe=kb(e=>e.setRange),[$e,et]=Q.useState(!1),[tt,nt]=Q.useState(!0),[rt,it]=Q.useState(!1),[at,ot]=Q.useState(!1),st=`${V}:${s?`archived`:`active`}:${We.id}`,ct=fn(Q.useMemo(()=>e=>!!e.sessionMemoryState.get(Kt(We.id))?.isZombie,[We.id])),lt=En(We.id),dt=Dn(We.id,q??void 0,{bootstrap:!1}),ft=Un(We.id,q??void 0,{bootstrap:!1}),pt=Q.useMemo(()=>({scope:V,sessionId:We.id,projectId:o??null}),[o,V,We.id]),mt=Q.useMemo(()=>bi(pt)??``,[pt]),ht=Q.useRef(null),gt=Ui(Q.useMemo(()=>e=>li(e.focus,pt),[pt]));Q.useLayoutEffect(()=>{if(!gt)return;let e=ht.current;e&&(L?e.scrollIntoView({block:`nearest`,inline:`nearest`}):gx(e)),wx(pt)},[gt,L,pt]);let vt=Ge.title||n(`sessions.sidebar.session.untitled`),yt=$a(Qa(Ge)),bt=Ge.metadata?.yuri?.titleRefresh,xt=typeof bt?.lastError==`string`?bt.lastError:null,St=typeof bt?.failedAt==`number`?bt.failedAt:null;Q.useEffect(()=>{!xt||St===null||console.warn(`[session-title] generation failed for ${We.id}: ${xt}`)},[We.id,xt,St]);let Tt=typeof bt?.generationExpiresAt==`number`&&Number.isFinite(bt.generationExpiresAt)?bt.generationExpiresAt:0,[Dt,Ot]=Q.useState(0),kt=Q.useMemo(()=>Math.max(0,Tt-Date.now()),[Tt]),[,jt,Mt]=Ct(()=>Ot(Tt),kt,{immediate:!1}),Nt=bt?.isGenerating===!0;Q.useEffect(()=>(Nt&&Tt>Date.now()&&jt(),Mt),[Nt,Tt,jt,Mt]);let Pt=r.children.length>0||!!(Ge.hasChildren??We.hasChildren),Ft=c.has(We.id),It=st,Lt=u?!0:l.has(It),Rt=!!Ge.parentID,zt=V===`pinned`,Bt=Jn(We.id)>0&&!Rt,Vt=tr(Ge)||Date.now(),Ht=wa(Vt),Ut=Ea(Vt),[Wt,Gt]=Q.useState(!1),qt=Wt,Jt=Q.useMemo(()=>Al(Ge.title)!==null,[Ge.title]),[Yt,Xt]=Q.useState(!1),Zt=Q.useMemo(()=>Ex(r).length,[r]),Qt=wt(e=>{let t=q??``,n=(ze()??we(t,qe)).getTranscript(Pe(t,e)),r=qe.getState().session.find(t=>t.id===e)?.revert?.messageID;return jn({sessionID:e,messages:Ee(n),parts:n.partsByMessageID,revertMessageID:r}).list}),$t=wt(async e=>{let t=[],r=0;for(let i of e)try{await Je.ensureSessionRenderable(i.session.id);let e=Qt(i.session.id),a=i.session.title||n(`sessions.sidebar.session.export.untitledSubagent`),o=i.session.agent,s=await $t(i.children);r+=s.skipped,t.push({title:a,agent:o,records:e,children:s.children})}catch{r+=Ex(i).length+1}return{children:t,skipped:r}}),en=wt(e=>{e<=0||X.warning(n(e===1?`sessions.sidebar.session.export.skippedSubtaskSingle`:`sessions.sidebar.session.export.skippedSubtaskMany`,{count:e}))}),tn=wt(async e=>{if(!q){X.error(n(`sessions.sidebar.session.export.nothingToExport`));return}await Je.ensureSessionRenderable(We.id);let t=Qt(We.id);if(t.length===0){X.error(n(`sessions.sidebar.session.export.nothingToExport`));return}let i,a=0;if(e&&r.children.length>0){let e=await $t(r.children);i=e.children,a=e.skipped}let o=Sb(t,Ge.title??null,i),s=Db(Ge.title??null),c=await wb(o,s);if(c){X.success(n(`sessions.sidebar.session.export.success`),{action:{label:n(Eb()),onClick:()=>{Tb(c).then(e=>{e||X.error(n(`sessions.sidebar.session.export.failedRevealPath`))})}}}),en(a);return}Cb(o,s),X.success(n(`sessions.sidebar.session.export.success`)),en(a)}),nn=wt(async()=>{if(r.children.length>0){nt(!0),et(!0);return}await tn(!1)}),rn=wt(()=>{q&&R(`desktop_open_session_mini_chat_window`,{sessionId:We.id,directory:q,apiBaseUrl:m(),clientToken:t()}).catch(e=>{console.warn(`[session-sidebar] failed to open mini chat window`,e)})});Et(He,()=>{Ie.current(Be.current)},f===We.id),Q.useLayoutEffect(()=>{if(f!==We.id){Ve.current===We.id&&(Ve.current=null);return}Ve.current!==We.id&&(Ve.current=We.id,Re(h),queueMicrotask(()=>Ue.current?.select()))},[f,h,We.id]);let an=wt(e=>{if(!e&&Fe.current){let{id:e,title:t}=Fe.current;Fe.current=null,p(e),g(t)}}),sn=wt(e=>{Gt(e)}),cn=wt(e=>{e.preventDefault(),e.stopPropagation()}),ln=wt(e=>{e.preventDefault(),e.stopPropagation()}),un=wt(e=>{e.preventDefault(),e.stopPropagation(),O(null),S(We.id)}),dn=wt(e=>{e.preventDefault(),e.stopPropagation(),O(null),I(We,{archivedBucket:s})}),pn=wt(e=>{e.preventDefault(),e.stopPropagation(),O(null),I(We,{archivedBucket:s,hardDelete:!0,skipConfirm:!0})}),mn=wt(e=>{e.preventDefault(),e.stopPropagation(),O(null),S(We.id)}),gn=wt(()=>{!q||rt||(it(!0),(async()=>{try{await Je.refreshSessionTranscript(We.id,{directory:q}),X.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{X.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{it(!1)}})())}),_n=wt(e=>{e.preventDefault(),e.stopPropagation()}),vn=wt(e=>{e.preventDefault(),e.stopPropagation()}),yn=wt(e=>{e.preventDefault(),e.stopPropagation(),_e?.vscode?.executeCommand(`yuri.openSessionInEditor`,We.id,vt)}),bn=wt(e=>{if(Ae.current){Ae.current=!1;return}if(Ye){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=kb.getState().anchorId,n=new Map;n.set(We.id,Ex(r)),Qe(t,We.id,e,q??null,n);return}Ze(We.id,q??null,Ex(r));return}b(We.id,q,o,V)}),xn=wt(e=>{e.defaultPrevented||e.target?.closest(`button, a, input, [role="menuitem"], [role="menu"]`)||bn(e)}),Sn=wt(e=>{(e.button===2||e.button===0&&e.ctrlKey&&!Ye)&&(Ae.current=!0)}),Cn=wt(e=>{je.current=e.pointerType===`mouse`,L&&e.pointerType===`touch`&&Ne(!0)}),wn=wt(e=>{L&&e.pointerType===`touch`&&Ne(!1)}),Tn=wt(e=>{e.key!==`Enter`||!je.current||(e.preventDefault(),e.stopPropagation(),x(We.id,vt))}),On=wt(e=>{if(bn(e),!je.current)return;let t=e.currentTarget;window.requestAnimationFrame(()=>{je.current=!0,t.focus({preventScroll:!0})})}),kn=wt(()=>{je.current=!1}),An=wt(e=>{if(!je.current)return;let t=e.relatedTarget;if(t instanceof Node&&e.currentTarget.contains(t))return;let n=document.activeElement;!(n instanceof HTMLElement)||!e.currentTarget.contains(n)||(n.blur(),je.current=!1)}),Mn=wt(()=>{!Lt&&!at&&(ot(!0),Je.loadChildren(We.id,q).catch(()=>X.error(n(`sessions.sidebar.session.subsessions.loadFailed`))).finally(()=>ot(!1))),y(It)});if(f===We.id){let e=async()=>{v();try{await on(We.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:Ba(i)},children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0`,children:[(0,$.jsxs)(`form`,{ref:He,className:`flex w-full items-center gap-2`,onSubmit:e=>{e.preventDefault(),_(Le)},children:[(0,$.jsx)(`input`,{ref:Ue,value:Le,onChange:e=>Re(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`,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`,"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`})})]}),pe?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:[Pt&&!zt&&!Rt?(0,$.jsx)(`span`,{className:`inline-flex items-center justify-center flex-shrink-0`,children:Lt?(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:Ht}),ae?(0,$.jsx)(`span`,{className:`truncate`,children:B?.projectLabel}):null,ue?(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]})})]})},We.id)}let Nn=lt,Pn=Nt&&Tt>Date.now()&&Dt!==Tt,Fn=dt.length,In=ft.length>0,Ln=In||Nn||!In&&!Nn&&Bt,Rn=!z||fe,zn=In?(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`})}):Nn?(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)(rc,{})}):(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)]`})}),Bn=!zt&&!Rt&&Pt,Vn=Bn&&!z&&!at,Hn=Ba(Math.max(0,i-1)),Wn=Bn?(0,$.jsx)(`span`,{role:`button`,tabIndex:0,"aria-expanded":Lt,"aria-busy":at,onClick:e=>{e.stopPropagation(),e.currentTarget.blur(),Mn()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),Mn())},style:{minWidth:14,minHeight:14,left:Hn},className:J(`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`,pe?`top-1/2 -translate-y-1/2`:`top-[14.5px] -translate-y-1/2`,Vn?`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(Lt?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),children:at?(0,$.jsx)(rc,{size:12}):Lt?(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,Gn=ct?(0,$.jsx)(Z,{name:`error-warning`,className:`h-4 w-4 text-status-warning`}):null,qn=(0,$.jsx)(ce,{children:(0,$.jsx)(G,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(xe,{"data-slot":`dropdown-menu-content`,finalFocus:()=>!(k||K.current),style:{color:`var(--surface-elevated-foreground)`},className:J(Xo,`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:()=>{Fe.current={id:We.id,title:vt}},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`pencil-ai`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.rename`)]}),(0,$.jsxs)(e,{onClick:()=>S(We.id),className:`[&>svg]:mr-1`,children:[Ft?(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(Ft?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`)]}),Kn()&&!Ge.share?(0,$.jsxs)(e,{onClick:()=>C(Ge),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`share-2`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.share`)]}):Kn()&&Ge.share?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(e,{onClick:()=>{Ge.share?.url&&E(Ge.share.url,We.id)},className:`[&>svg]:mr-1`,children:w===We.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:()=>D(We.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:()=>{nn()},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:!q||rt,onClick:()=>{gn()},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`refresh`,className:J(`mr-1 h-4 w-4`,rt&&`animate-spin`)}),n(`sessions.sidebar.session.menu.refreshTranscript`)]}),Jt?(0,$.jsxs)(e,{onClick:()=>Xt(!0),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(ux,{className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.runFusion`)]}):null,q&&!s?(()=>{let o=A(q),s=j(q,We.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?N(q,We.id):P(q,t.id,We.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(q);e&&P(q,e.id,We.id)},children:[(0,$.jsx)(Z,{name:`add`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.folders.newFolderEllipsis`)]}),s?(0,$.jsxs)(e,{onClick:()=>{N(q,We.id)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(Z,{name:`close`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.folders.removeFromFolder`)]}):null]})]})]})})():null,me?(0,$.jsxs)(e,{disabled:!q,onClick:rn,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(We,{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(We,{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)(oe,{className:J(Qo,e),...t}),Separator:({className:e,...t})=>(0,$.jsx)(W,{className:J(Zo,e),...t}),Sub:se,SubTrigger:({className:e,children:t,...n})=>(0,$.jsxs)(ge,{className:J(Yo,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)(ce,{children:(0,$.jsx)(G,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(xe,{"data-slot":`dropdown-menu-sub-content`,style:{color:`var(--surface-elevated-foreground)`},className:J(Xo,`yuri-session-context-menu`,e),...n,children:t})})})})})})});return(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(Cc,{sessionId:We.id,sessionDirectory:q??null,sessionTitle:vt,children:(0,$.jsxs)(le,{open:Wt,onOpenChange:sn,onOpenChangeComplete:an,children:[(0,$.jsxs)(he,{render:(0,$.jsx)(`div`,{ref:ht,"data-session-row":We.id,"data-session-scope":q??``,"data-session-focus-scope":V,"data-session-focus-key":mt,"data-session-project-id":o??``,"data-session-archived":s?`1`:`0`,"data-session-depth":i,onClick:xn,onMouseLeave:An,className:J(`group relative my-0.5 flex cursor-pointer items-center rounded-lg py-1.5 pr-2`,gt&&!Xe&&`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,Xe&&`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,!gt&&!Xe&&`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:[Wn,(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,style:{paddingLeft:Ba(i)},children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:(0,$.jsxs)(na,{children:[(0,$.jsx)($i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onPointerDown:Cn,onPointerUp:wn,onPointerCancel:wn,onMouseDown:Sn,onKeyDown:Tn,onBlur:kn,onClick:On,onDoubleClick:e=>{e.stopPropagation(),x(We.id,vt)},className:J(`relative flex min-w-0 flex-1 cursor-pointer flex-col gap-0 overflow-hidden rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 text-foreground select-none has-[[data-sidebar-shortcut-number]]:!pr-0`,Me&&`bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,z?fe?Oe:ke:Oe),children:(0,$.jsxs)(`div`,{className:`flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:J(`block min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground`,Pn&&`animate-text-shimmer`),"aria-busy":Pn||void 0,children:pa(vt,d)}),yt?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro tabular-nums text-muted-foreground`,children:yt}):null,Ke?(0,$.jsx)(Z,{name:`ai-agent`,className:`size-3 shrink-0 text-muted-foreground`,"aria-label":`Assistant`}):null,Fn>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:Fn})]}):null,Ln?(0,$.jsx)(`span`,{className:J(`inline-flex shrink-0 items-center justify-center transition-none`,Rn?J(`group-hover:hidden group-focus-within:hidden`,qt?`hidden`:``):qt?`invisible`:``),children:zn}):null,ie?(0,$.jsx)(kx,{number:ie}):null]})})}),fe?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:vt}),(0,$.jsx)(`div`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:Ut})]}),ae?(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,ue?(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]})})]})})}),Gn&&!L?(0,$.jsx)(`div`,{className:J(`absolute top-1/2 -translate-y-1/2 z-10`,pe?`right-0`:`right-[30px]`),children:Gn}):null,(0,$.jsxs)(`div`,{className:J(`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`,qt||z&&!fe?`opacity-100`:J(`opacity-0`,ve)),children:[Se?(0,$.jsx)(Dx,{pinned:Ft,pinLabel:n(Ft?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`),buttonSizeClass:Ce,iconSizeClass:Te,onPointerDown:cn,onMouseDown:ln,onPin:un}):null,be?(0,$.jsxs)(na,{children:[(0,$.jsx)($i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:J(`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`,Ce),"aria-label":n(`sessions.sidebar.session.actions.pinned`),onPointerDown:cn,onMouseDown:ln,onClick:mn,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(Z,{name:`pushpin-2-fill`,className:Te})})}),(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,ye?(0,$.jsxs)(na,{children:[(0,$.jsx)($i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:J(`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`,Ce),"aria-label":n(`sessions.sidebar.session.actions.openInEditor`),onPointerDown:_n,onMouseDown:vn,onClick:yn,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(Z,{name:`external-link`,className:Te})})}),(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)(Ox,{archiveLabel:n(`sessions.sidebar.bulkActions.archive`),deleteLabel:n(`sessions.sidebar.bulkActions.delete`),deleteOnly:s===!0,buttonSizeClass:Ce,iconSizeClass:Te,revealClassName:pe&&!z&&!qt?J(`opacity-0`,ve):`opacity-100`,onPointerDown:cn,onMouseDown:ln,onArchive:dn,onDelete:pn})]})]}),qn]})}),!zt&&Pt&&Lt?r.children.map(e=>{let t=re?re(e):{subtreeContainsActive:H,subtreeContainsEditing:te,menuOpenSessionId:ne,nodeStructureKey:``};return ee(e,i+1,q??a,o,s,void 0,V,t)}):null,(0,$.jsx)(hr,{open:$e,onOpenChange:et,children:(0,$.jsxs)(fr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,$.jsxs)(ur,{children:[(0,$.jsx)(pr,{children:n(`sessions.sidebar.session.export.dialog.title`)}),(0,$.jsx)(mr,{children:n(Zt===1?`sessions.sidebar.session.export.dialog.descriptionSingle`:`sessions.sidebar.session.export.dialog.descriptionMany`,{count:Zt})})]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-ui-label cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:tt,onChange:e=>nt(e.target.checked),className:`h-4 w-4 rounded border-border accent-primary`}),n(`sessions.sidebar.session.export.dialog.includeSubtasks`)]}),(0,$.jsxs)(dr,{children:[(0,$.jsx)(Y,{type:`button`,onClick:()=>et(!1),variant:`outline`,size:`sm`,children:n(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{type:`button`,onClick:()=>{et(!1),tn(tt)},size:`sm`,children:n(`sessions.sidebar.session.export.dialog.confirm`)})]})]})}),Jt?(0,$.jsx)(lx,{session:Ge,open:Yt,onOpenChange:Xt}):null]},We.id)}var jx=e=>_t(e.session.directory??null),Mx=(e,t)=>(e?.projectLabel??null)===(t?.projectLabel??null)&&(e?.branchLabel??null)===(t?.branchLabel??null),Nx=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},Px=e=>e.menuOpenSessionId??Nx(e),Fx=(e,t,n)=>t?n.has(e.node.session.id)?!0:Kv(e.node,t):!1,Ix=(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(Ix(e.children[a],t.children[a],n,r,i))return!0;return!1},Lx=(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&&Wv(a)!==Wv(o)||e.children.length!==t.children.length)return!0;for(let i=0;i<e.children.length;i+=1)if(Lx(e.children[i],t.children[i],n,r))return!0;return!1},Rx=(e,t)=>{if(e.hasSessionSearchQuery||t.hasSessionSearchQuery)return!1;let n=e.archivedBucket?`archived`:`active`,r=t.archivedBucket?`archived`:`active`;return Ix(e.node,t.node,e.expandedParents,t.expandedParents,t=>`${e.renderContext??`project`}:${n}:${t.session.id}`)||Ix(e.node,t.node,e.expandedParents,t.expandedParents,e=>`${t.renderContext??`project`}:${r}:${e.session.id}`)},zx=Q.memo(Ax,(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||jx(e.node)!==jx(t.node)||!Mx(e.secondaryMeta,t.secondaryMeta)||e.liveSessionById!==t.liveSessionById&&Lx(e.node,t.node,e.liveSessionById,t.liveSessionById)||e.pinnedSessionIds!==t.pinnedSessionIds&&Ix(e.node,t.node,e.pinnedSessionIds,t.pinnedSessionIds,e=>e.session.id)||e.expandedParents!==t.expandedParents&&Rx(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&&(Kv(e.node,e.copiedSessionId)||Kv(t.node,t.copiedSessionId)))return!1;if(e.openSidebarMenuKey!==t.openSidebarMenuKey){let n=Px(e),r=Px(t);if(Kv(e.node,n)||Kv(t.node,r))return!1}if(e.renamingFolderId!==t.renamingFolderId){let n=Px(e),r=Px(t);if(Kv(e.node,n)||Kv(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 Bx(e){return e.stopPropagation()}function Vx(e){return e.stopPropagation()}function Hx(e){let t=(0,Ll.c)(71),{t:n}=At(),{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=hr,g=!!r,t[13]===i?_=t[14]:(_=e=>{e||i(null)},t[13]=i,t[14]=_),u=fr,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)(pr,{children:a}),t[18]=a,t[19]=p),c=mr,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)(dr,{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 Ux(e){let t=(0,Ll.c)(57),{t:n}=At(),{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)(pr,{children:d}),t[10]=d,t[11]=g);let _;t[12]===p?_=t[13]:(_=(0,$.jsx)(mr,{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)(dr,{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)(fr,{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)(hr,{open:m,onOpenChange:h,children:M}),t[53]=m,t[54]=M,t[55]=h,t[56]=N):N=t[56],N}function Wx(e){let t=(0,Ll.c)(36),{t:n}=At(),{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)(pr,{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)(mr,{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)(dr,{children:[h,_]}),t[26]=_,t[27]=h,t[28]=v):v=t[28];let y;t[29]!==v||t[30]!==f?(y=(0,$.jsxs)(fr,{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)(hr,{open:o,onOpenChange:s,children:y}),t[32]=o,t[33]=s,t[34]=y,t[35]=b):b=t[35],b}var Gx=e=>{let t=(0,Ll.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}=At(),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)(_a,{children:[(0,$.jsxs)(na,{children:[(0,$.jsx)($i,{asChild:!0,children:(0,$.jsx)(Ma,{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)(ha,{align:`end`,className:`min-w-[180px]`,children:[i.length===0?(0,$.jsx)(va,{disabled:!0,className:`text-muted-foreground`,children:f(`sessions.sidebar.folders.none`)}):i.map(e=>(0,$.jsx)(va,{onClick:()=>o(e.id),children:(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e.name})},e.id)),(0,$.jsx)(La,{}),(0,$.jsxs)(va,{onClick:s,children:[(0,$.jsx)(Z,{name:`add`,className:`mr-1 h-4 w-4`}),f(`sessions.sidebar.folders.newFolderEllipsis`)]}),l?(0,$.jsxs)(va,{onClick:c,className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(Z,{name:`close`,className:`mr-1 h-4 w-4`}),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=J(`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)($i,{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)(na,{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)($i,{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)(na,{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},Kx=e=>{let{t}=At(),{isInlineEditing:n,showDeletionDialog:r,foldersMap:i,addSessionsToFolder:a,removeSessionsFromFolders:o,createFolderAndStartRename:s,archiveSessions:c,setBulkDeleteConfirm:l}=e,u=kb(e=>e.enabled),d=kb(e=>e.selectedIds.size),f=d>0,p=kb(e=>e.selectedIds),m=kb(e=>e.scopeKey),h=Q.useCallback(()=>{kb.getState().toggleMode()},[]),g=Q.useCallback(()=>{kb.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(_)dc({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&&tc({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&&X.error(r.length===1?t(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):t(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}kb.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(),kb.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=kb.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;kb.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}},qx=(e,t,n)=>{let r=[],i=new Set,a=e=>{let t=_t(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},Jx=(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},Yx=({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=Jx(r,e,o,i)??{scope:`project`,sessionId:e,projectId:i};return!a||t.scope===`project`?s:Jx(n,e,o,i)??s};function Xx(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 Zx=`yuri.sessions.projectCollapse`,Qx=`yuri.sessions.groupOrder`,$x=`yuri.sessions.groupCollapse`,eS=`yuri.sessions.activeSessionByProject`,tS=`yuri.sessions.expandedParents.v2`,nS=`yuri.sessions.expandedParents`,rS=Ze(Ue()),iS=e=>{try{let t=rS.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}},aS=e=>{try{let t=rS.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}},oS=e=>{try{let t=rS.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}},sS=(e,t,n)=>{let r=new Set;for(let t of e){let e=_t(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=_t(t.path)?.toLowerCase();e&&r.add(e)}return r},cS=(e,t,n)=>{if(e.time?.archived)return!0;let r=_t(Wn(e))?.toLowerCase();return r?t.size===0?n?.allowEmptyDirectorySet??!0:t.has(r):n?.allowUnknownDirectory??!0},lS=new Set,uS=[],dS={},fS=e=>{let t=Q.useRef(e);return t.current=e,Q.useMemo(()=>(...e)=>t.current(...e),[])},pS=Q.memo(function(e){let t=(0,Ll.c)(3),{onOpenChange:n}=e,r=_s(ae(hS)),i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(gs,{open:!0,onOpenChange:n,...r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}),mS=Q.memo(function({mobileVariant:e=!1,onSessionSelected:t,allowReselect:n=!1,hideDirectoryControls:r=!1,showOnlyMainWorkspace:i=!1,isVisible:a=!0}){let{t:o}=At(),[c,l]=Q.useState(!1),[u,d]=Q.useState(!1),[f,m]=Q.useState(``),h=Q.useRef(null),g=Q.useRef(null),[_,v]=Q.useState(null),[y,b]=Q.useState(``),[x,S]=Q.useState(null),[C,E]=Q.useState(new Set),D=Q.useMemo(()=>rS,[]),[O,k]=Q.useState(new Set),[A,j]=Q.useState(new Map),[M,N]=Q.useState(new Map),P=q(e=>e.isNewWorktreeDialogOpen),F=q(e=>e.setNewWorktreeDialogOpen),[I,L]=Q.useState(null),[R,z]=Q.useState(null),[ee,B]=Q.useState(``),[V,H]=Q.useState(null),[te,ne]=Q.useState(null),[re,U]=Q.useState(null),ie=un(),ae=Ut(),[W,oe]=Q.useState(()=>iS($x)),[G,se]=Q.useState(()=>oS(Qx)),[ce,le]=Q.useState(()=>aS(eS));Q.useEffect(()=>s(e=>{p(e)&&(oe(iS($x)),se(oS(Qx)),le(aS(eS)),k(iS(Zx)),E(iS(tS)))}),[]);let[ue,de]=Q.useState(new Map),fe=Q.useRef(0),pe=Me(e=>e.homeDirectory),me=Me(e=>e.currentDirectory),he=Me(e=>e.setDirectory),ge=kn(e=>e.projects),_e=kn(e=>e.activeProjectId),ve=kn(e=>e.removeProject),ye=kn(e=>e.setActiveProjectIdOnly),be=kn(e=>e.updateProjectMeta),xe=kn(e=>e.reorderProjectsById),Se=q(e=>e.setActiveMainTab),Ce=q(e=>e.activeMainTab),we=Ht(),Te=q(e=>e.setSettingsDialogOpen),Ee=q(e=>e.toggleHelpDialog),De=q(e=>e.setSessionSwitcherOpen),Oe=q(e=>e.setScheduledTasksDialogOpen),ke=q(e=>e.notifyOnSubtasks),Ae=q(e=>e.showDeletionDialog),je=q(e=>e.setShowDeletionDialog),Ne=to(f,120),K=Q.useMemo(()=>Ne.trim().toLowerCase(),[Ne]),Pe=K.length>0,Fe=_s(e=>e.available&&(e.runtimeType===`desktop`||e.runtimeType===`web`)),Ie=sn(e=>e.collapsedFolderIds),Le=sn(e=>e.foldersMap),Re=sn(e=>e.sessionOrderByScope),ze=sn(e=>e.sessionOrderActivityByScope),Be=sn(e=>e.getFoldersForScope),Ve=sn(e=>e.createFolder),He=sn(e=>e.renameFolder),Ue=sn(e=>e.deleteFolder),qe=sn(e=>e.addSessionToFolder),Je=sn(e=>e.addSessionsToFolder),Ye=sn(e=>e.removeSessionFromFolder),Xe=sn(e=>e.removeSessionsFromFolders),Ze=sn(e=>e.toggleFolderCollapse),Qe=sn(e=>e.getSessionFolderId),$e=sn(e=>e.reorderSessions);bv({isSessionSearchOpen:a&&u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchContainerRef:h});let et=Q.useMemo(()=>new Map,[]),tt=dn({enabled:a,includeChildren:!0}),nt=Wc({enabled:a}),rt=Nc({enabled:a}),it=zn(e=>a?e.index.session.unseenCount:dS),at=Q.useMemo(()=>T(),[]),ot=vn(e=>e.status),st=vn(e=>e.activeSessions),ct=vn(e=>e.archivedSessions),lt=vn(e=>e.loadingDirectories.size>0||e.refreshingDirectories.size>0),ut=vn(e=>e.archivedLoadingDirectories),dt=Q.useDeferredValue(st),ft=Q.useDeferredValue(ct),pt=Vn(e=>e.currentSessionId),mt=Ui(e=>e.focus),ht=Q.useSyncExternalStore(Ke,We,We),gt=Vn(e=>!!e.newSessionDraft?.open),vt=Vn(e=>e.setCurrentSession),yt=Vn(e=>e.updateSessionTitle),bt=Vn(e=>e.shareSession),xt=Vn(e=>e.unshareSession),St=Vn(e=>e.worktreeMetadata),Ct=Vn(e=>e.availableWorktreesByProject),Tt=Vn(e=>e.openNewSessionDraft),Et=wt(e=>{Tt(e),at&&window.dispatchEvent(new CustomEvent(`yuri:navigate`,{detail:{view:`chat`}}))}),Dt=Q.useMemo(()=>sS(ge,Ct,{includeWorktrees:!at}),[Ct,at,ge]),Ot=Q.useMemo(()=>{let e=new Map(tt.map(e=>[e.id,e])),t=dt.map(t=>{let n=e.get(t.id);return n?_n(n,t):t}),n=new Set(t.map(e=>e.id));return tt.forEach(e=>{n.has(e.id)||t.push(e)}),t.filter(e=>cS(e,Dt,{allowUnknownDirectory:!at,allowEmptyDirectorySet:!at}))},[dt,at,Dt,tt]),kt=Q.useMemo(()=>tt.map(e=>{let t=_t(e.directory??null)??``;return`${e.id}:${e.title??``}:${+!!e.time?.archived}:${t}`}).join(`|`),[tt]),jt=Q.useRef(tt);Q.useEffect(()=>{jt.current=tt},[kt,tt]);let Mt=Q.useMemo(()=>new Map(tt.map(e=>[e.id,e])),[tt]);Q.useEffect(()=>{let e=null,t=Nn(t=>{t.type===`scheduled-task-ran`&&(e&&clearTimeout(e),e=setTimeout(()=>{let e=kn.getState().projects.find(e=>e.id===t.projectId),n=_t(e?.path??null);if(!n)return;let r=[n];(Vn.getState().availableWorktreesByProject.get(n)??[]).forEach(e=>{let t=_t(e.path);t&&r.push(t)}),an(r,jt.current)},500))});return()=>{e&&clearTimeout(e),t()}},[]);let Pt=Q.useMemo(()=>w(),[]),Ft=Wl(),It=Fs(e=>e.sidebarBrandName.trim().length>0),{isTablet:Lt,isDesktop:Rt}=Ka(),zt=e||Lt,{buildGroupSearchText:Bt,filterSessionNodesForSearch:Vt,buildGroupedSessions:Wt}=yv({homeDirectory:pe,worktreeMetadata:St,pinnedSessionIds:ie,gitBranches:et,isVSCode:at}),{scheduleCollapsedProjectsPersist:Gt,hasRestoredProjectCollapse:Kt}=Dv({isVSCode:at,safeStorage:D,keys:{sessionExpanded:tS,sessionExpandedLegacy:nS,projectCollapse:Zx,groupOrder:Qx,projectActiveSession:eS,groupCollapse:$x},groupOrderByProject:G,activeSessionByProject:ce,collapsedGroups:W,setExpandedParents:E,setCollapsedProjects:k}),qt=Q.useMemo(()=>[...Ot].sort((e,t)=>Fa(e,t,ie)),[Ot,ie]),Jt=Q.useMemo(()=>{let e=new Map;return qt.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)=>Fa(e,t,ie))),e},[qt,ie]),Yt=(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`)})]}),Xt=Q.useMemo(()=>ge.find(e=>e.id===x)??null,[ge,x]),Zt=Q.useCallback(e=>{x&&be(x,{label:e.label,icon:e.icon,color:e.color,iconBackground:e.iconBackground,defaultModel:e.defaultModel??null})},[x,be]),Qt=Q.useCallback(()=>{F(!0)},[F]),$t=Q.useCallback((t,n)=>{if(Se(`chat`),e&&De(!1),n?.sessionId){vt(n.sessionId,t);return}Tt({directoryOverride:t,preserveDirectoryOverride:!0})},[e,Tt,Se,vt,De]),tn=wt(()=>{let e=_s.getState();if(e.available&&e.info){l(!0);return}e.checkForUpdates().then(()=>{let{available:e,error:t}=_s.getState();if(t){X.error(o(`sessions.sidebar.updateCheck.errorTitle`),{description:t});return}if(!e){X.success(o(`sessions.sidebar.updateCheck.latestVersion`));return}l(!0)})}),rn=Q.useCallback(()=>{e&&De(!1),Te(!0)},[e,De,Te]),on=Q.useCallback(()=>{Se(`chat`),Tt(),e&&De(!1)},[e,Tt,Se,De]),cn=Q.useCallback(()=>{if(!e){Se(`schedule`);return}Oe(!0),De(!1)},[e,Se,Oe,De]),fn=Q.useCallback(()=>{ar(),e&&De(!1)},[e,De]),pn=Vn(e=>e.archiveSession),mn=Vn(e=>e.archiveSessions),{copiedSessionId:hn,handleSessionSelect:gn,handleSessionDoubleClick:bn,handleSaveEdit:xn,handleCancelEdit:Sn,handleShareSession:Cn,handleCopyShareUrl:wn,handleUnshareSession:Tn,handleDeleteSession:En,confirmDeleteSession:Dn}=xv({activeProjectId:_e,currentDirectory:me,currentSessionId:pt,mobileVariant:e,allowReselect:n,onSessionSelected:t,isSessionSearchOpen:u,sessionSearchQuery:f,setSessionSearchQuery:m,setIsSessionSearchOpen:d,setActiveProjectIdOnly:ye,setDirectory:he,setActiveMainTab:Se,setSessionSwitcherOpen:De,setCurrentSession:vt,updateSessionTitle:yt,shareSession:bt,unshareSession:xt,archiveSession:pn,archiveSessions:mn,childrenMap:Jt,showDeletionDialog:Ae,setDeleteSessionConfirm:H,deleteSessionConfirm:V,setEditingId:v,setEditTitle:b,editingId:_,editTitle:y}),On=Q.useCallback((e,t,n,r=`project`)=>{let i={sessionId:e,scope:r,projectId:n??null};if(e===pt){Ge(e),Tx(i),gn(e,t,n);return}Cx(i,()=>gn(e,t,n))},[gn,pt]);Q.useEffect(()=>()=>{Sx()},[]);let An=Q.useCallback(()=>{if(!te)return;let{scopeKey:e,folderId:t}=te;ne(null),Ue(e,t)},[te,Ue]);Q.useEffect(()=>{if(!pt)return;let e=Ot.find(e=>e.id===pt)?.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(tS,JSON.stringify(Array.from(n)))}catch{}return n})},[pt,Ot,D]);let jn=Q.useCallback(e=>{E(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{D.setItem(tS,JSON.stringify(Array.from(n)))}catch{}return n})},[D]),Mn=Q.useCallback((e,t)=>{if(!e)return null;t&&Ie.has(t)&&Ze(t);let n=Ve(e,o(`sessions.sidebar.folder.newFolderName`),t);return z(n.id),B(n.name),n},[Ie,Ze,Ve,o]),Pn=wt(On),Fn=wt(bn),In=wt(xn),Ln=wt(Sn),Rn=wt(Cn),Bn=wt(wn),Hn=wt(Tn),Un=wt(En),Gn=wt(Mn),Kn=wt((e,t,n,r)=>{let i=pc(),a=Math.max(i,n)+7;if(N(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=_t(e.directory??null);if(!o)return;let s=vn.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&nn(o)}),qn=wt(e=>{N(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})}),Jn=wt(e=>{N(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})}),Yn=Q.useMemo(()=>e=>{let t=ge.find(t=>t.id===e),n=_t(t?.path??null);if(!n)return[];let r=[n];return at||(Ct.get(n)??[]).forEach(e=>{let t=_t(e.path);t&&r.push(t)}),r},[Ct,at,ge]),Zn=wt(e=>{let t=Yn(e);if(t.length===0)return;let n=vn.getState().loadedDirectories,r=t.filter(e=>!n.has(e));r.length!==0&&an(r,jt.current)}),Qn=wt(e=>{let t=ge.find(t=>t.id===e);t&&(async()=>{let e=[];if(!at)try{e=(await as({id:t.id,path:t.path})).worktrees}catch(n){console.warn(`[SessionSidebar] Worktree refresh before session sync failed:`,n);let r=_t(t.path);e=r?Vn.getState().availableWorktreesByProject.get(r)??[]:[]}let n=qx(t.path,e,{currentDirectory:me,workspaceRoot:t.path,includeWorktrees:!at});n.length!==0&&await yn(n,jt.current)})()});Q.useEffect(()=>{if(!Kt)return;let e=vn.getState(),t=ge.flatMap(t=>O.has(t.id)?[]:Yn(t.id).filter(t=>!e.loadedDirectories.has(t)&&!e.loadingDirectories.has(t)&&!e.refreshingDirectories.has(t)));t.length>0&&an(t,jt.current)},[O,Yn,Kt,ge]);let $n=wt(()=>{fe.current=Date.now()+150,N(new Map),k(()=>{let e=new Set(ge.map(e=>e.id));try{D.setItem(Zx,JSON.stringify(Array.from(e)))}catch{}return at||Gt(e),e})}),er=wt(()=>{fe.current=Date.now()+150,N(new Map),k(()=>{let e=new Set;try{D.setItem(Zx,JSON.stringify([]))}catch{}return at||Gt(e),e});let e=vn.getState().loadedDirectories,t=ge.flatMap(t=>Yn(t.id).filter(t=>!e.has(t)));t.length>0&&an(t,jt.current)}),tr=wt(e=>{fe.current=Date.now()+150,Jn(e),k(t=>{let n=new Set(t);n.has(e)?(n.delete(e),queueMicrotask(()=>Zn(e))):n.add(e);try{D.setItem(Zx,JSON.stringify(Array.from(n)))}catch{}return at||Gt(n),n})}),nr=wt(e=>{fe.current=Date.now()+150,Zn(e),k(t=>{if(!t.has(e))return t;let n=new Set(t);n.delete(e);try{D.setItem(Zx,JSON.stringify(Array.from(n)))}catch{}return at||Gt(n),n})}),rr=Q.useMemo(()=>ge.map(e=>({...e,normalizedPath:_t(e.path)})).filter(e=>!!e.normalizedPath),[ge]),ir=Q.useMemo(()=>rr.map(e=>e.normalizedPath),[rr]),or=Q.useMemo(()=>{let e=new Set(rr.map(e=>e.normalizedPath));if(!at)for(let t of Ct.values())for(let n of t){let t=_t(n.path);t&&e.add(t)}return[...e].sort()},[Ct,at,rr]),sr=Q.useRef(null);Q.useEffect(()=>{let e=new Set(or),t=sr.current;if(sr.current=e,!t)return;let n=or.filter(e=>!t.has(e));if(n.length===0)return;let r=vn.getState().loadedDirectories,i=_t(me),a=rr.find(e=>e.id===_e)??rr.find(e=>e.normalizedPath===i)??null,o=new Set;i&&o.add(i),a?.normalizedPath&&(o.add(a.normalizedPath),at||(Ct.get(a.normalizedPath)??[]).forEach(e=>{let t=_t(e.path);t&&o.add(t)}));let s=n.filter(e=>o.has(e)&&!r.has(e));s.length!==0&&an(s,jt.current)},[_e,Ct,me,at,rr,or]);let cr=no(a?ir:uS);kv({normalizedProjects:rr,activeProjectId:_e,gitRepoStatus:cr,setProjectRepoStatus:j,setProjectRootBranches:de,enabled:a});let lr=Q.useMemo(()=>Ts(Ot,rr,Ct,at,ft),[ft,Ct,at,rr,Ot]),{getSessionsForProject:ur,getArchivedSessionsForProject:dr}=Av({ownership:lr}),fr=lt||ot===`idle`||ot===`loading`,pr=Q.useRef(!1);_e&&A.has(_e)&&(pr.current=!!A.get(_e));let mr=Xn(e=>e.projectSortOrder),hr=Q.useMemo(()=>Mc(rr,mr),[rr,mr]),{projectSections:gr,groupSearchDataByGroup:_r,sectionsForRender:vr,searchMatchCount:yr}=gv({normalizedProjects:hr,getSessionsForProject:ur,getArchivedSessionsForProject:dr,availableWorktreesByProject:Ct,projectRepoStatus:A,projectRootBranches:ue,lastRepoStatus:pr.current,buildGroupedSessions:Wt,hasSessionSearchQuery:Pe,normalizedSessionSearchQuery:K,filterSessionNodesForSearch:Vt,buildGroupSearchText:Bt,foldersMap:Le}),br=(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`)})]});_v({projectSections:gr,activeProjectId:_e,activeSessionByProject:ce,setActiveSessionByProject:le,currentSessionId:pt,handleSessionSelect:gn,newSessionDraftOpen:gt,mobileVariant:e,openNewSessionDraft:Tt,setActiveMainTab:Se,setSessionSwitcherOpen:De});let{getOrderedGroups:xr}=vv(G),Sr=Q.useRef(!1);Q.useEffect(()=>{if(Sr.current||gr.length===0)return;let e=gr.flatMap(e=>e.groups.filter(e=>e.isArchivedBucket).map(t=>`${e.project.id}:${t.id}`));e.length>0&&oe(t=>new Set([...t,...e])),Sr.current=!0},[gr]);let Cr=Q.useMemo(()=>{let e=new Map,t=new Map;return gr.forEach(n=>{let r=Nt(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},[gr]);Q.useLayoutEffect(()=>{if(!pt){Tx(null);return}let e=Ui.getState().focus;if(e?.sessionId===pt){e.scope===`project`&&!e.projectId&&Tx({...e,projectId:Cr.get(pt)?.projectId??null});return}Tx({scope:`project`,sessionId:pt,projectId:Cr.get(pt)?.projectId??null})},[pt,Cr]);let wr=Q.useMemo(()=>at?[]:zc(Ot,ie,Re[_c]),[at,ie,Ot,Re]),Tr=wt((e,t)=>{_||$e(_c,wr.map(e=>e.id),e,t,{}).catch(()=>X.error(o(`sessions.order.saveFailed`)))}),Er=Q.useMemo(()=>Pe?[]:Gc(Ot,ie,rt,it),[Pe,ie,rt,Ot,it]),{pinnedItems:Dr,inProgressItems:Or}=Q.useMemo(()=>{let e=e=>{let t=Cr.get(e.id),n=_t(e.directory??null),r={session:e,children:[],worktree:St.get(e.id)??null};if(Pe&&Vt([r],K).length===0)return null;let i=lr.bySessionId.get(e.id),a=i?hr.find(e=>e.id===i.projectId):void 0,o=a?Nt(a.normalizedPath)||a.normalizedPath:t?.secondaryMeta?.projectLabel??null,s=xc({projectLabel:o,owner:i,sessionWorktree:St.get(e.id)??null,worktrees:a?Ct.get(a.normalizedPath)??[]:[],projectRootBranch:i?ue.get(i.projectId)??(a?cr.get(a.normalizedPath)?.branch:null)??null:null,isVSCode:at})??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:at?[]:t(wr),inProgressItems:t(Er)}},[Ct,Vt,cr,Pe,Er,at,K,wr,ue,lr,Cr,hr,St]),kr=Q.useMemo(()=>vr.map(e=>({...e,groups:e.groups.filter(e=>!e.isArchivedBucket)})),[vr]),Ar=Q.useMemo(()=>{let e=Pe?kr.map(e=>({...e,groups:e.groups.map(e=>({...e,sessions:_r.get(e)?.filteredNodes??[]}))})):kr;if(!i)return e;let t=e.find(e=>e.project.id===_e)??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]}]:[]},[_e,_r,Pe,kr,i]),jr=Q.useMemo(()=>Hc({sections:Ar,foldersMap:Le,getOrderedGroups:xr,pinnedSessionIds:ie,sessionOrderByScope:Re,sessionOrderActivityByScope:ze}),[Le,xr,Ar,ie,ze,Re]),Mr=Q.useMemo(()=>nc({targets:jr,collapsedProjectIds:O,collapsedGroupKeys:W,collapsedFolderIds:Ie,visibleSessionCountByGroup:M,defaultVisibleSessionCount:pc(),hasSessionSearchQuery:Pe,alwaysVisibleSessionIds:nt}),[nt,Ie,W,O,Pe,jr,M]),Nr=Q.useMemo(()=>Pe?[]:[...Dr,...Or].map((e,t)=>{let n=e.node.session;return{scope:`pinned`,sessionId:n.id,projectId:e.projectId,directory:_t(Wn(n))??e.groupDirectory??null,visibleIndex:t}}),[Pe,Or,Dr]),[Pr,Fr]=Q.useState(null),Ir=Q.useCallback(e=>{Fr(t=>t&&t.length===e.length&&t.every((t,n)=>t===e[n])?t:[...e])},[]),Lr=Q.useMemo(()=>{if(!Pr)return Nr;let e=new Set(Pr);return Nr.filter(t=>e.has(t.sessionId))},[Nr,Pr]),Rr=Q.useMemo(()=>e?[]:Ri({pinnedTargets:Lr,projectTargets:Mr}),[e,Lr,Mr]),zr=Q.useCallback(e=>{Se(`chat`),De(!1),e.scope===`project`&&e.projectId&&ye(e.projectId),On(e.sessionId,e.directory,e.projectId,e.scope)},[On,Se,ye,De]);Q.useLayoutEffect(()=>Oi({targets:Rr,activate:zr}),[zr,Rr]);let Br=Q.useMemo(()=>{let e=new Map;return Rr.forEach(t=>{let n=bi({scope:t.scope,sessionId:t.sessionId,projectId:t.projectId});n&&e.set(n,mi(Rr,t)??0)}),e},[Rr]),Vr=Q.useMemo(()=>{if(!pt||Pe)return[];let e=[],t=(n,r)=>{if(n.session.id===pt){e.push({scope:`pinned`,sessionId:pt,projectId:r});return}n.children.forEach(e=>t(e,r))};return Dr.forEach(e=>t(e.node,e.projectId)),Or.forEach(e=>t(e.node,e.projectId)),e},[pt,Pe,Or,Dr]),Hr=Q.useMemo(()=>{if(!pt)return[];let e=[],t=(n,r)=>{if(n.session.id===pt){e.push({scope:`project`,sessionId:pt,projectId:r});return}n.children.forEach(e=>t(e,r))};return gr.forEach(e=>{e.groups.forEach(n=>{n.sessions.forEach(n=>t(n,e.project.id))})}),e},[pt,gr]);Q.useLayoutEffect(()=>ki({pinned:Lr,project:Mr}),[Lr,Mr]),Q.useLayoutEffect(()=>{fr||Tx(Yx({currentSessionId:pt,focus:mt,pinnedFocuses:Vr,projectFocuses:Hr,fallbackProjectId:pt?Cr.get(pt)?.projectId??null:null}))},[pt,fr,Hr,Vr,mt,Cr]);let Ur=Q.useMemo(()=>{let e=mt?.sessionId?Cr.get(mt.sessionId)?.projectId??null:null;return Xx(mt,jr,e)},[jr,mt,Cr]),Wr=Q.useRef(null),Gr=Q.useRef(null);Q.useEffect(()=>{Gr.current&&Gr.current!==pt&&(Gr.current=null)},[pt]),Q.useLayoutEffect(()=>{if(!Ur?.projectId)return;let e=Ur.sessionId,t=ht.sessionId===e;if(!(!t&&pt!==e)){if(t){if(Wr.current===ht.revision)return;Wr.current=ht.revision,Gr.current=e}else{if(Gr.current===e)return;Gr.current=e}if(nr(Ur.projectId),Ur.groupKey&&oe(e=>{if(!e.has(Ur.groupKey))return e;let t=new Set(e);return t.delete(Ur.groupKey),t}),Ur.folderAncestorIds?.forEach(e=>{let t=sn.getState();t.collapsedFolderIds.has(e)&&t.toggleFolderCollapse(e)}),Ur.groupKey&&Ur.visibleIndex!==void 0){let e=Ur.visibleIndex+1;N(t=>{if((t.get(Ur.groupKey)??0)>=e)return t;let n=new Map(t);return n.set(Ur.groupKey,e),n})}}},[pt,Ur,ht]);let Kr=fS((t,n=0,r,i,a=!1,o,s=`project`,c)=>(0,$.jsx)(zx,{node:t,depth:n,groupDirectory:r,projectId:i,archivedBucket:a,currentSessionId:pt,pinnedSessionIds:ie,expandedParents:C,hasSessionSearchQuery:Pe,normalizedSessionSearchQuery:K,notifyOnSubtasks:ke,editingId:_,setEditingId:v,editTitle:y,setEditTitle:b,handleSaveEdit:In,handleCancelEdit:Ln,toggleParent:jn,handleSessionSelect:Pn,handleSessionDoubleClick:Fn,togglePinnedSession:ae,handleShareSession:Rn,copiedSessionId:hn,handleCopyShareUrl:Bn,handleUnshareSession:Hn,openSidebarMenuKey:I,setOpenSidebarMenuKey:L,renamingFolderId:R,getFoldersForScope:Be,getSessionFolderId:Qe,removeSessionFromFolder:Ye,addSessionToFolder:qe,createFolderAndStartRename:Gn,handleDeleteSession:Un,mobileVariant:e,alwaysShowActions:zt,renderSessionNode:Kr,secondaryMeta:o,renderContext:s,subtreeContainsActive:c?.subtreeContainsActive??lS,subtreeContainsEditing:c?.subtreeContainsEditing??lS,menuOpenSessionId:c?.menuOpenSessionId??null,nodeStructureKey:c?.nodeStructureKey??``,childRenderExtrasFor:c?.childRenderExtrasFor,liveSessionById:Mt,shortcutNumber:Br.get(bi({scope:s,sessionId:t.session.id,projectId:i??null})??``)??null},`${s}:${i??``}:${t.session.id}`)),qr=Q.useCallback(e=>{qn(e),oe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[qn]),Jr=Q.useCallback(e=>{let t=Yn(e);if(t.length===0)return;let n=vn.getState(),r=t.filter(e=>!n.archivedLoadedDirectories.has(e));r.length>0&&en(r)},[Yn]),Yr=wt((e,t,n,r,i)=>{let a=e.folderScopeKey??_t(e.directory??null);a&&$e(a,t,n,r,i).catch(()=>X.error(o(`sessions.order.saveFailed`)))}),Xr=wt((e,t,n)=>{e.isArchivedBucket&&W.has(t)&&n&&Jr(n),qr(t)}),Zr=Q.useMemo(()=>(t,n,r,i,a,o,s)=>(0,$.jsx)(dy,{group:t,groupKey:n,isArchivedLoading:!!(t.isArchivedBucket&&r&&Yn(r).some(e=>ut.has(e))),projectId:r,hideGroupLabel:i,compactBodyPadding:o,hasSessionSearchQuery:Pe,normalizedSessionSearchQuery:K,groupSearchDataByGroup:_r,visibleSessionCount:M.get(n),collapsedGroups:W,collapsedFolderIds:Ie,toggleFolderCollapse:Ze,renameFolder:He,deleteFolder:Ue,showDeletionDialog:Ae,setDeleteFolderConfirm:ne,renderSessionNode:Kr,projectRepoStatus:A,lastRepoStatus:pr.current,showMoreGroupSessions:Kn,resetGroupSessionLimit:qn,mobileVariant:e,alwaysShowActions:zt,activeProjectId:_e,setActiveProjectIdOnly:ye,setActiveMainTab:Se,setSessionSwitcherOpen:De,openNewSessionDraft:Et,addSessionToFolder:qe,createFolderAndStartRename:Gn,renamingFolderId:R,renameFolderDraft:ee,setRenameFolderDraft:B,setRenamingFolderId:z,pinnedSessionIds:ie,expandedParents:C,sessionOrderByScope:Re,sessionOrderActivityByScope:ze,onReorderSessions:Yr,currentSessionId:pt,shortcutTargetSessionId:Ur?.groupKey===n?Ur.sessionId:null,shortcutTargetVisibleIndex:Ur?.groupKey===n?Ur.visibleIndex??null:null,editingId:_,editTitle:y,openSidebarMenuKey:I,liveSessionById:Mt,alwaysVisibleSessionIds:nt,onToggleCollapsedGroup:Xr,dragHandleProps:a,scrollContainerRef:s}),[Pe,K,_r,ut,Yn,M,W,Ie,Ze,He,Ue,Ae,Kr,A,Kn,qn,e,zt,_e,ye,Se,De,Et,qe,Gn,R,ee,ie,C,Re,ze,Yr,pt,Ur,_,y,I,Mt,nt,Xr]),Qr=r?null:(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Cy,{collapseAllProjects:$n,expandAllProjects:er}),(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:ln.requestDirectoryDialog,children:(0,$.jsx)(Z,{name:`add`,className:`size-4`})})]}),$r=Pt&&!Ft&&It&&!at&&!Pe?(0,$.jsx)(`div`,{className:`shrink-0 px-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(gd,{className:`min-w-0 flex-1`}),(0,$.jsx)(Fc,{className:`ml-auto shrink-0`})]})}):null,ei=!at&&!Pe,ti=ei&&Rt&&!Ft&&!e,ni=!Pe&&(Dr.length>0||Or.length>0),ri=(0,$.jsxs)(`div`,{className:`space-y-0.5 py-1`,children:[(0,$.jsxs)(Y,{variant:`ghost`,size:`sm`,className:J(`w-full justify-start px-2 font-normal`,e&&`h-11`),onClick:on,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:J(`w-full justify-start px-2 font-normal`,Ce===`schedule`&&`bg-interactive-selection text-interactive-selection-foreground`,e&&`h-11`),onClick:cn,children:[(0,$.jsx)(Z,{name:`time`,className:`size-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`sessions.sidebar.header.actions.scheduledTasks`)}),a?(0,$.jsx)(tv,{}):null]}),we.data?.supported&&we.data?.enabled?(0,$.jsxs)(Y,{variant:`ghost`,size:`sm`,className:J(`w-full justify-start px-2 font-normal`,Ce===`assistant`&&`bg-interactive-selection text-interactive-selection-foreground`,e&&`h-11`),onClick:fn,children:[(0,$.jsx)(Jc,{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)(al,{className:`h-3.5 min-w-3.5 bg-[oklch(from_var(--primary-base)_calc(l_*_0.78)_c_h)] px-1 text-[10px] text-[var(--color-white)] shadow-none`}),a?(0,$.jsx)(nv,{}):null]})]}):null,(0,$.jsx)(Ps,{sidebar:!0,mobile:e})]}),ii=ei&&!ti||ni?(0,$.jsxs)($.Fragment,{children:[ei&&!ti?(0,$.jsxs)($.Fragment,{children:[e&&It?(0,$.jsx)(gd,{}):null,ri]}):null,ni?(0,$.jsx)(my,{items:Dr,reorderEnabled:!0,onSessionsReordered:Tr,inProgressItems:Or,renderSessionNode:Kr,currentSessionId:pt,editingId:_,openSidebarMenuKey:I,onVisibleSessionIdsChange:Ir}):null]}):null,ai=!!(R||_||x),{selectionModeEnabled:oi,hasSelection:si,selectedIdsSize:ci,bulkScopeIsArchived:li,derivedSelectionScope:ui,bulkScopeFolders:di,bulkCanRemoveFromFolder:fi,handleExitSelectionMode:pi,handleBulkMoveToFolder:hi,handleBulkCreateFolderAndMove:gi,handleBulkRemoveFromFolder:vi,handleBulkDelete:yi,confirmBulkDelete:xi}=Kx({isInlineEditing:ai,showDeletionDialog:Ae,foldersMap:Le,addSessionsToFolder:Je,removeSessionsFromFolders:Xe,createFolderAndStartRename:Mn,archiveSessions:mn,setBulkDeleteConfirm:U});return(0,$.jsxs)(`div`,{ref:h,className:J(`yuri-session-sidebar relative flex h-full flex-col text-foreground overflow-x-hidden`,e?``:`bg-transparent`),children:[(0,$.jsx)(fy,{hideDirectoryControls:r,isSessionSearchOpen:u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchQuery:f,setSessionSearchQuery:m,hasSessionSearchQuery:Pe,searchMatchCount:yr}),$r,ti?(0,$.jsx)(`div`,{className:`shrink-0 px-3`,children:ri}):null,a?(0,$.jsx)(lb,{topContent:ii,hasLeadingSection:ii!==null&&(Dr.length>0||Or.length>0),headerAccessory:Qr,sectionsForRender:kr,projectSections:gr,activeProjectId:_e,showOnlyMainWorkspace:i,hasSessionSearchQuery:Pe,emptyState:Yt,searchEmptyState:br,renderGroupSessions:Zr,homeDirectory:pe,collapsedProjects:O,hideDirectoryControls:r,projectRepoStatus:A,mobileVariant:e,alwaysShowActions:zt,toggleProject:tr,setActiveProjectIdOnly:ye,setActiveMainTab:Se,setSessionSwitcherOpen:De,openNewSessionDraft:Et,openNewWorktreeDialog:Qt,syncProjectSessions:Qn,openProjectEditDialog:S,removeProject:ve,projectReorderEnabled:mr===`manual`,reorderProjects:xe,projectSortOrder:mr,getOrderedGroups:xr,setGroupOrderByProject:se,openSidebarMenuKey:I,setOpenSidebarMenuKey:L,isInlineEditing:ai}):null,oi&&si?(0,$.jsx)(Gx,{selectedCount:ci,scopeKey:ui,scopeFolders:di,archivedBucket:li,onMoveToFolder:hi,onCreateFolderAndMove:gi,onRemoveFromFolder:vi,canRemoveFromFolder:fi,onDelete:yi,onDone:pi}):null,(0,$.jsx)(sv,{normalizedProjects:rr,ownership:lr,enabled:a}),(0,$.jsx)(eb,{onOpenSettings:rn,onOpenShortcuts:Ee,onOpenUpdate:tn,showRuntimeButtons:!at,showUpdateButton:Fe}),c?(0,$.jsx)(pS,{onOpenChange:l}):null,Xt?(0,$.jsx)(jv,{open:!0,onOpenChange:e=>{e||S(null)},project:Xt,onSave:Zt}):null,P?(0,$.jsx)(_i,{open:!0,onOpenChange:F,onWorktreeCreated:$t}):null,(0,$.jsx)(sc,{}),(0,$.jsx)(Rs,{}),(0,$.jsx)(Hx,{value:V,setValue:H,showDeletionDialog:Ae,setShowDeletionDialog:je,onConfirm:Dn}),(0,$.jsx)(Wx,{value:te,setValue:ne,onConfirm:An}),(0,$.jsx)(Ux,{value:re,setValue:U,showDeletionDialog:Ae,setShowDeletionDialog:je,onConfirm:xi})]})});function hS(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 gS=e=>e?(0,$.jsx)(`span`,{className:`text-foreground/80 dark:text-foreground/70`,children:e}):void 0,_S=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.replace(/\/+$/,``)},vS=()=>{let{t:e}=At(),[t,n]=Q.useState(!1),[r,i]=Q.useState(null),[a,o]=Q.useState([]),[s,c]=Q.useState(!1),[l,u]=Q.useState(!1),[d,f]=Q.useState(!1),[p,m]=Q.useState(!1),[h,g]=Q.useState(new Set),_=Vn(e=>e.getWorktreeMetadata),v=Vn(e=>e.newSessionDraft),y=Vn(e=>e.setNewSessionDraftTarget),b=Vn(e=>e.setDraftBootstrapPendingDirectory),x=$t,S=Vn(e=>e.archiveSessions),C=q(e=>e.showDeletionDialog),w=q(e=>e.setShowDeletionDialog),T=Me(e=>e.currentDirectory),E=Me(e=>e.homeDirectory),D=kn(e=>e.projects),O=kn(e=>e.activeProjectId),{isMobile:k,isTablet:A,hasTouchInput:j}=Ka(),M=k||A||j,N=Q.useMemo(()=>_S((O?D.find(e=>e.id===O)??null:null)?.path??T),[O,T,D]),P=Q.useCallback(e=>{let t=_S(e.projectDirectory)||N;return{id:(D.find(e=>_S(e.path)===t)??null)?.id??`path:${t}`,path:t}},[N,D]),F=p&&h.size>0,I=Q.useMemo(()=>{let e=r?.worktree;return e&&typeof e.branch==`string`&&e.branch.trim().length>0?!0:a.length>0&&a.every(({metadata:e})=>typeof e.branch==`string`&&e.branch.trim().length>0)},[r?.worktree,a]),L=r?.mode===`worktree`,R=L,z=d||!L||!I,ee=d||!L,B=Q.useCallback(e=>{i({sessions:e.sessions,dateLabel:e.dateLabel,mode:e.mode??`session`,worktree:e.worktree??null})},[]),V=Q.useCallback(()=>{i(null),o([]),c(!1),u(!1),f(!1),m(!1),g(new Set)},[]),H=Q.useCallback(t=>{if(t.sessions.length===0)return;let n=t.sessions.map(e=>e.id);dc({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(()=>ln.onDeleteRequest(e=>{if(!C&&(e.mode??`session`)===`session`){H(e);return}B(e)}),[B,C,H]),Q.useEffect(()=>ln.onDirectoryRequest(()=>{n(!0)}),[]),Q.useEffect(()=>{if(!r){o([]),c(!1),u(!1),m(!1),g(new Set);return}let e=r.sessions.map(e=>{let t=_(e.id);return t?{session:e,metadata:t}:null}).filter(e=>!!e);o(e),c(!1),m(!1),g(new Set);let t=new Map;if(r.worktree?.path&&t.set(_S(r.worktree.path),r.worktree),e.forEach(({metadata:e})=>{e.path&&t.set(_S(e.path),e)}),t.size===0){m(!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 is(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&&(g(r),m(!0),i(t=>{if(!t?.worktree?.path)return t;let n=_S(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}}}),o(t=>t.map(t=>{let n=_S(t.metadata.path),r=e.get(n);return r?{session:t.session,metadata:{...t.metadata,status:r}}:t})))})(),()=>{n=!0}},[r,_]),Q.useEffect(()=>{I||c(!1)},[I]);let te=Q.useCallback(async(t,n)=>{let r=s&&I,i=P(t),a=_S(t.path),o=_S(i.path);try{await ns(i,t,{deleteRemoteBranch:r,deleteLocalBranch:n});let e=_S(v?.directoryOverride);return v?.open&&a&&e===a&&o&&(b(null),y({projectId:i.id,directoryOverride:o},{force:!0})),_S(T)===a&&o&&Me.getState().setDirectory(o,{showOverlay:!1}),!0}catch(t){return X.error(e(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:gS(t instanceof Error?t.message:e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),!1}},[I,T,s,P,v?.directoryOverride,v?.open,b,y,e]),ne=Q.useCallback((t,n)=>{let r=s&&I;(async()=>{if(!await te(t,n))return;let i=e(r?`sessions.sidebar.sessionDialogs.worktree.removedWithRemote`:`sessions.sidebar.sessionDialogs.worktree.removed`);X.success(e(`sessions.sidebar.sessionDialogs.worktree.removedTitle`),{description:gS(i)})})()},[I,s,te,e]),re=Q.useCallback(async()=>{if(r){f(!0);try{let t=R&&l;if(r.sessions.length===0&&L&&r.worktree){ne(r.worktree,t),V();return}if(r.sessions.length===1){let t=r.sessions[0];if(L){if(!await x(t.id)){X.error(e(`sessions.sidebar.session.archive.error`)),f(!1);return}tc({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 dc({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=r.sessions.map(e=>e.id),i=[],a=[];if(L){let e=await S(n);i=e.archivedIds,a=e.failedIds}else dc({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})}),i=n,a=[];if(L&&r.worktree&&a.length===0&&ne(r.worktree,t),L&&i.length>0&&tc({sessionIds:i,message:i.length===1?e(`sessions.sidebar.bulkActions.archivedSingle`,{count:i.length}):e(`sessions.sidebar.bulkActions.archivedPlural`,{count:i.length}),undoLabel:e(`sessions.sidebar.undo`),settingsLabel:e(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:i.length===1?e(`sessions.sidebar.session.archive.undoFailed`):e(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:i.length})}),a.length>0&&(X.error(L?a.length===1?e(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:a.length}):e(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:a.length}):a.length===1?e(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:a.length}):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:a.length}),{description:gS(e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),i.length===0)){f(!1);return}}L&&r.sessions.length===1&&r.worktree&&ne(r.worktree,t),V()}finally{f(!1)}}},[r,l,x,S,V,R,L,ne,e]),U=r?.worktree??a[0]?.metadata??null,ie=r?r.mode===`worktree`?r.sessions.length===0?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked`):r.sessions.length===1?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked`,{count:r.sessions.length}):e(`sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked`,{count:r.sessions.length}):r.sessions.length===1?r.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate`,{dateLabel:r.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionOne`):r.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate`,{count:r.sessions.length,dateLabel:r.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionMany`,{count:r.sessions.length}):``,ae=r?(0,$.jsxs)(`div`,{className:J(L?`space-y-3`:`space-y-2`),children:[r.sessions.length>0&&(0,$.jsxs)(`div`,{className:J(L?`rounded-lg bg-muted/30 p-3`:`space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3`),children:[L&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:r.sessions.length===1?e(`sessions.sidebar.sessionDialogs.linkedSessionSingle`):e(`sessions.sidebar.sessionDialogs.linkedSessionPlural`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:r.sessions.length})]}),(0,$.jsxs)(`ul`,{className:J(L?`mt-2 space-y-1`:`space-y-0.5`),children:[r.sessions.slice(0,5).map(t=>(0,$.jsxs)(`li`,{className:J(L?`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:J(!L&&`hidden`),children:`•`}),(0,$.jsx)(`span`,{className:`truncate`,children:t.title||e(`sessions.sidebar.session.untitled`)})]},t.id)),r.sessions.length>5&&(0,$.jsx)(`li`,{className:J(L?`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:r.sessions.length-5})})]})]}),L?(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`)}),U?.label?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:U.label}):null]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/80 break-all`,children:U?Dt(U.path,E):e(`sessions.sidebar.sessionDialogs.worktree.pathUnavailable`)}),F&&(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,W=L?I?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{z||c(e=>!e)},disabled:z,className:J(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,z?`cursor-not-allowed opacity-60`:`hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),children:[s?(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,oe=L?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{ee||u(e=>!e)},disabled:ee,className:J(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,ee?`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.deleteLocalBranch`)]}):null,G=L?(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:[oe,W]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{variant:`ghost`,onClick:V,disabled:d,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{variant:`destructive`,onClick:re,disabled:d,children:e(d?`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:()=>w(!C),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":!C,children:[C?(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:V,disabled:d,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{variant:`destructive`,onClick:re,disabled:d,children:d?e(`sessions.sidebar.sessionDialogs.actions.deleting`):r?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`)})]})]}),se=L?e(`sessions.sidebar.sessionDialogs.actions.deleteWorktree`):r?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`);return(0,$.jsxs)($.Fragment,{children:[M?(0,$.jsx)(ua,{open:!!r,onClose:()=>{d||V()},title:se,footer:(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:G}),children:(0,$.jsxs)(`div`,{className:`space-y-2 pb-2`,children:[ie&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/80`,children:ie}),ae]})}):(0,$.jsx)(hr,{open:!!r,onOpenChange:e=>{if(!e){if(d)return;V()}},children:(0,$.jsxs)(fr,{className:J(L?`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)(pr,{className:J(L&&`flex items-center gap-2`),children:[L&&(0,$.jsx)(Z,{name:`delete-bin`,className:`h-5 w-5`}),se]}),ie&&(0,$.jsx)(mr,{children:ie})]}),(0,$.jsx)(`div`,{className:J(L&&`flex-1 min-h-0 overflow-y-auto space-y-2`),children:ae}),(0,$.jsx)(dr,{className:`mt-2 gap-2 pt-1 pb-1`,children:G})]})}),(0,$.jsx)(Qc,{open:t,onOpenChange:n})]})};function yS(){let{host:e,snapshot:t,inventory:n,error:r,requested:i,requestLoad:a}=ko(),{t:o}=At(),s=q(e=>e.activeGuiPage),c=q(e=>e.isMobile);Q.useEffect(()=>{i||a()},[i,a]);let l=t.pages.find(e=>e.key===s),u=t.plugins.find(e=>e.id===l?.pluginId)?.revision,d;try{let e=JSON.parse(s??`null`);Array.isArray(e)&&typeof e[0]==`string`&&(d=e[0])}catch{}let f=t.plugins.some(e=>e.id===d&&e.status===`failed`)||n.some(e=>e.id===d&&e.error)||!l&&!!r;return c?null:(0,$.jsx)(`div`,{"data-gui-plugin-page":!0,className:`flex h-full min-h-0 min-w-0 flex-col py-1.5 pl-1 pr-1.5 text-foreground`,children:(0,$.jsx)(Od,{"data-gui-plugin-page-surface":!0,children:e&&l?(0,$.jsx)(Da,{fallback:(0,$.jsx)(hl,{message:o(`guiPlugins.error`)}),children:(0,$.jsx)(ml,{host:e,kind:`page`,contributionKey:l.key,revision:u})},JSON.stringify([l.key,u])):f?(0,$.jsx)(hl,{message:o(`guiPlugins.error`)}):null})})}var bS=Q.createContext(null),xS=e=>{let t=(0,Ll.c)(3),{children:n,value:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(bS.Provider,{value:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},SS=xo(()=>gt(()=>import(`./TerminalView-BnR50Mgm.js`).then(e=>({default:e.TerminalView})),__vite__mapDeps([79,1,4,2,3,5,6,7,8,9,10,11,17,12,13,14,16,80,55,56,57,37,38,39,40,15,18,19,20,81,36,41,42,43,44,54,22,58,33,34,35,59,60,61,45,47,82,65,83,84,85,86,87,88,89]))),CS=xo(()=>gt(()=>import(`./DiagramView-xGg1oS8b.js`).then(e=>({default:e.DiagramView})),__vite__mapDeps([90,1,3,2,7,8,9,10,11,13,14,17,12,16,4,58,36,5,6,37,38,39,40,41,20,42,43,44,47,65,55,56,57,15,18,19,54,22,33,34,35,59,60,61,91,92]))),wS=xo(()=>gt(()=>import(`./SettingsView-BoDwWc6-.js`).then(e=>e.n).then(e=>({default:e.SettingsView})),__vite__mapDeps([93,1,2,3,4,5,6,94,95,9,7,55,56,57,10,11,8,37,12,16,14,38,39,40,15,17,13,18,19,20,22,96,97,98,58,33,34,35,36,41,42,43,44,99,100,54,59,60,61,47,101,62,102,103,67,45,46,48,49,63,104,105,106,107,108,109,52,110,82,111,83,112,113,85,86,87,114,115,53,23,24,25,26,27,28,29,30,31,32,64,65,66,116,68,117,84,118,119,120,121,122,123,74,124,125,126,127,128,129,130,89,76,131,132,133,134,135,136,137,138,139,140]))),TS=xo(()=>gt(()=>import(`./SettingsWindow-BGPVsXUi.js`).then(e=>({default:e.SettingsWindow})),__vite__mapDeps([141,1,7,12,36,5,2,3,6,37,4,9,10,11,8,16,14,38,39,40,41,20,42,43,44,93,94,95,55,56,57,15,17,13,18,19,22,96,97,98,58,33,34,35,99,100,54,59,60,61,47,101,62,102,103,67,45,46,48,49,63,104,105,106,107,108,109,52,110,82,111,83,112,113,85,86,87,114,115,53,23,24,25,26,27,28,29,30,31,32,64,65,66,116,68,117,84,118,119,120,121,122,123,74,124,125,126,127,128,129,130,89,76,131,132,133,134,135,136,137,138,139,140]))),ES=xo(()=>gt(()=>import(`./MultiRunWindow-GFioSTDw.js`).then(e=>({default:e.MultiRunWindow})),__vite__mapDeps([142,1,7,12,36,5,2,3,6,37,4,9,10,11,8,16,14,38,39,40,41,20,42,43,44,47,143,55,56,57,15,17,13,18,19,33,34,35,54,22,58,59,60,61,104,144,105,106,82,145,146,147,148,101,62,102,103,67,45,46,149,111,83,113,110,109,52,85,86,87,126]))),DS=xo(()=>gt(()=>import(`./AssistantView-DSnDwWGc.js`).then(e=>e.n).then(e=>({default:e.AssistantView})),__vite__mapDeps([150,1,2,3,5,6,7,8,9,10,11,12,13,14,58,33,34,35,36,37,4,16,38,39,40,41,20,42,43,44,99,15,17,18,19,22,100,54,55,56,57,59,60,61,47,101,62,102,103,67,45,46,48,49,63,82,151,51,109,52,135,152,71,69,70,111,83,153,154,146,147,148,115,149,64,65,66,155,156,157,131,112]))),OS=()=>{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}=Ka(),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=sr(-E.current),O=(0,Q.useRef)(0),k=sr(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),cr(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),cr(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=Vn.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)(_m,{isActive:!v})});case`diff`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(vc,{})});case`terminal`:return n?null:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(SS,{})});case`files`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(uf,{})});case`diagram`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(CS,{})});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)(uc,{children:(0,$.jsxs)(`div`,{"data-page-scroll-lock":`true`,className:J(`main-content-safe-area`,f?`flex h-[100dvh] flex-col`:`relative flex h-[100dvh]`,`bg-background`),children:[(0,$.jsx)(Vc,{}),(0,$.jsx)(q_,{}),(0,$.jsx)(Z_,{}),(0,$.jsx)(vS,{}),(0,$.jsx)(tl,{}),f?(0,$.jsxs)(xS,{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)(ed,{onToggleLeftDrawer:()=>{let e=!g;v&&y(!1),w(e)},onToggleRightDrawer:()=>{j()},leftDrawerOpen:g,rightDrawerOpen:v}),(0,$.jsx)(`div`,{"data-page-scroll-lock":`true`,className:J(`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)(Da,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Zs,{})})})}),P&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Da,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(DS,{})})})}),R&&(0,$.jsx)(`div`,{className:J(`absolute inset-0`,!L&&`invisible`),children:(0,$.jsx)(Da,{children:(0,$.jsx)(Dc,{})})}),R&&M&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Da,{children:M})}),u&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(Da,{children:(0,$.jsx)(Ml,{onCreated:()=>d(!1),onCancel:()=>d(!1)})})}),(0,$.jsx)(ls.div,{className:J(`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)(Da,{children:(0,$.jsx)(mS,{mobileVariant:!0,isVisible:b})})}),S&&(0,$.jsx)(ls.div,{className:`absolute inset-0 z-20 bg-sidebar`,"data-page-scroll-lock":`true`,style:{x:k},"aria-hidden":!v,children:(0,$.jsx)(Da,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(_m,{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)(Da,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(wS,{onClose:()=>l(!1)})})})}),(0,$.jsx)(Da,{children:(0,$.jsx)(ac,{})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(bd,{}),(0,$.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:[(0,$.jsx)(md,{isOpen:e,isMobile:f,className:`border-border/50`,topBar:(0,$.jsx)(hd,{}),children:(0,$.jsx)(mS,{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)(Da,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:F?(0,$.jsx)(yS,{}):P?(0,$.jsx)(DS,{}):(0,$.jsx)(Zs,{})})})}):(0,$.jsxs)(G_,{header:(0,$.jsx)(ed,{}),footer:(0,$.jsx)(ad,{isOpen:n,isMobile:f,children:n?(0,$.jsx)(Da,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(SS,{})})}):null}),children:[R&&(0,$.jsx)(`div`,{className:J(`absolute inset-0`,!L&&`invisible`),children:(0,$.jsx)(Da,{children:(0,$.jsx)(Dc,{})})}),R&&M&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Da,{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)(ES,{open:u,onOpenChange:d})})]})]})})},kS=9e4,AS=15e3,jS=3e5,MS=[2e3,5e3],NS=6e4,PS=12e4,FS=3e5,IS=4,LS=432e5,RS=`yuri.github-pr-status`,zS=e=>e===`closed`||e===`merged`,BS=e=>{let t=e?.checks;return t?t.state===`pending`||t.pending>0:!1},VS=(e,t,n)=>`${e}::${t}`,HS=new Map,US=new Map,WS=new Set,GS=new Map,KS=2,qS=0,JS=[],YS=()=>qS<KS?(qS+=1,Promise.resolve()):new Promise(e=>{JS.push(e)}),XS=()=>{let e=JS.shift();if(e){e();return}qS=Math.max(0,qS-1)},ZS=()=>({status:null,isLoading:!1,error:null,isInitialStatusResolved:!1,lastRefreshAt:0,lastDiscoveryPollAt:0,watchers:0,params:null,identity:null,resolvedRemoteName:null}),QS=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,$S=e=>{let t=QS(e);return!t?.directory||!t.branch?null:`${t.directory}::${t.branch}`},eC=(e,t)=>Object.entries(e).filter(([,e])=>$S(e)===t).map(([e])=>e),tC=(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}}},nC=e=>!e?.params?.canShow||!e.params.github?.prStatus?null:{...e.params,remoteName:e.params.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null},rC=(e,t,n)=>{let r=eC(e,t),i=r.map(t=>nC(e[t])).filter(e=>!!e);if(i.length===0)return null;let a=nC(e[n]);if(a&&$S(e[n])===t)return a;let o=r.map(t=>e[t]).find(e=>!!(e?.resolvedRemoteName&&nC(e)));return o?nC(o):i.find(e=>!!e.remoteName)||(i[0]??null)},iC=e=>({status:e.status,isInitialStatusResolved:e.isInitialStatusResolved,lastRefreshAt:e.lastRefreshAt,lastDiscoveryPollAt:e.lastDiscoveryPollAt,identity:QS(e),resolvedRemoteName:e.resolvedRemoteName??e.status?.resolvedRemoteName??null}),aC=e=>({...ZS(),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}),oC=U()(ie((e,t)=>({entries:{},activeRequestCount:0,totalRequestCount:0,ensureEntry:t=>{e(e=>e.entries[t]?e:{entries:{...e.entries,[t]:ZS()}})},setParams:(t,n)=>{e(e=>{let r=e.entries[t]??ZS();return{entries:{...e.entries,[t]:tC(r,n)}}})},startWatching:n=>{if(e(e=>{let t=e.entries[n]??ZS();return{entries:{...e.entries,[n]:{...t,watchers:t.watchers+1}}}}),HS.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=US.get(n)??[];i.push(r),US.set(n,i)};t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0}),MS.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<jS)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}zS(r.status?.pr?.state)||Date.now()-r.lastRefreshAt<(BS(r.status)?NS:r.status?.checks&&r.status.checks.state!==`pending`?FS:PS)||t().refresh(n,{force:!0,onlyExistingPr:!0,silent:!0,markInitialResolved:!0})}},AS);HS.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=HS.get(n);typeof i==`number`&&window.clearInterval(i),HS.delete(n);let a=US.get(n);a&&a.length>0&&a.forEach(e=>{window.clearTimeout(e)}),US.delete(n)},refresh:async(n,r)=>{let i=t(),a=i.entries[n],o=$S(a);if(!a||!o)return;let s=eC(i.entries,o),c=s.some(e=>!!i.entries[e]?.status?.pr);if(r?.onlyExistingPr&&!c)return;let l=GS.get(o)??0;if(!r?.force&&Date.now()-l<kS||WS.has(o))return;let u=rC(i.entries,o,n);if(u){if(WS.add(o),GS.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}}),WS.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}}),WS.delete(o);return}try{e(e=>({...e,activeRequestCount:e.activeRequestCount+1,totalRequestCount:e.totalRequestCount+1})),await YS();let t;try{t=await u.github.prStatus(u.directory,u.branch,u.remoteName??void 0,{force:r?.force})}finally{XS()}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=QS(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{WS.delete(o),e(e=>({...e,activeRequestCount:Math.max(0,e.activeRequestCount-1)}))}}},refreshTargets:async(e,n)=>{await Ov(Array.from(new Set(e.map(e=>{let t=e.directory.trim(),n=e.branch.trim();return!t||!n?null:VS(t,n,e.remoteName??null)}).filter(e=>!!e))),IS,e=>t().refresh(e,n))},updateStatus:(t,n)=>{e(e=>{let r=e.entries[t]??ZS();return{entries:{...e.entries,[t]:{...r,status:n(r.status)}}}})}}),{name:RS,storage:Ye(),partialize:e=>({entries:Object.fromEntries(Object.entries(e.entries).filter(([,e])=>{let t=QS(e);if(!t?.directory||!t.branch)return!1;let n=Math.max(e.lastRefreshAt,e.lastDiscoveryPollAt);return n===0||Date.now()-n<LS}).map(([e,t])=>[e,iC(t)]))}),merge:(e,t)=>{let n=e?.entries??{};return{...t,entries:Object.fromEntries(Object.entries(n).map(([e,t])=>[e,aC(t)]))}}})),sC=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`},cC=e=>{let t=(0,Ll.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},lC=e=>{let t=(0,Ll.c)(43),{title:n,snapshot:r,emptyLabel:i}=e,{t:a}=At(),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(dC,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?sC(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)(cC,{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)(cC,{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)(cC,{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)(qo,{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},uC=e=>{let t=(0,Ll.c)(104),{onClose:n}=e,{t:r}=At(),[i,a]=Q.useState(`memory`),[o,s]=Q.useState(`idle`),c=Vn(fC),l=fn(pC),u=ir(),d=Cn(),[f,p]=Q.useState(mC),m,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>De(()=>{p(je())}),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=ze(),t={};if(!e){g=t;break bb0}let n=e.getCacheBudget?.(),r=n?n.listCanonical().map(hC):u.map(e=>({directory:d,sessionID:e.id}));for(let n of r){if(d&&n.directory!==d)continue;let r=e.getTranscript(Pe(n.directory,n.sessionID));t[n.sessionID]=r.messageOrder.map(e=>r.messagesByID[e]).filter(gC)}g=t}t[2]=d,t[3]=u,t[4]=g}else g=t[4];let _=g,v=oC(_C),[y,b]=Q.useState(vC),[x,S]=Q.useState(yC),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(Re()),S(ke())};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(bC),t[35]=c,t[36]=_,t[37]=l,t[38]=u,t[39]=r,t[40]=B}else B=t[40];let V=B,H;t[46]===_?H=t[47]:(H=Object.keys(_),t[46]=_,t[47]=H);let te=H.length,ne;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(ne=async()=>{try{let e={generatedAt:new Date().toISOString(),ui:Re(),vscode:ke()};await navigator.clipboard.writeText(JSON.stringify(e,null,2)),s(`copied`)}catch{s(`error`)}},t[48]=ne):ne=t[48];let re=ne,U;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(U={backgroundColor:`color-mix(in srgb, var(--surface-background) 94%, transparent)`},t[49]=U):U=t[49];let ie;t[50]===i?ie=t[51]:(ie=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]=ie);let ae;t[52]===r?ae=t[53]:(ae=r(`memoryDebugPanel.title`),t[52]=r,t[53]=ae);let W;t[54]===ae?W=t[55]:(W=(0,$.jsx)(`h3`,{className:`typography-ui-label font-semibold text-[var(--surface-foreground)]`,children:ae}),t[54]=ae,t[55]=W);let oe;t[56]!==ie||t[57]!==W?(oe=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[ie,W]}),t[56]=ie,t[57]=W,t[58]=oe):oe=t[58];let G;t[59]===i?G=t[60]:(G=i===`streaming`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,onClick:re,children:(0,$.jsx)(Z,{name:`file-copy`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,onClick:()=>{Ce(),b(Re()),S(ke())},children:(0,$.jsx)(Z,{name:`refresh`,className:`h-3.5 w-3.5`})})]}):null,t[59]=i,t[60]=G);let se;t[61]===n?se=t[62]:(se=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]=se);let ce;t[63]!==G||t[64]!==se?(ce=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[G,se]}),t[63]=G,t[64]=se,t[65]=ce):ce=t[65];let le;t[66]!==oe||t[67]!==ce?(le=(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[oe,ce]}),t[66]=oe,t[67]=ce,t[68]=le):le=t[68];let ue;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(ue={backgroundColor:`color-mix(in srgb, var(--surface-muted) 55%, transparent)`},t[69]=ue):ue=t[69];let de=i===`memory`?`secondary`:`ghost`,fe;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(fe=()=>a(`memory`),t[70]=fe):fe=t[70];let pe;t[71]===r?pe=t[72]:(pe=r(`memoryDebugPanel.tabs.memory`),t[71]=r,t[72]=pe);let me;t[73]!==de||t[74]!==pe?(me=(0,$.jsx)(Y,{size:`sm`,variant:de,className:`flex-1`,onClick:fe,children:pe}),t[73]=de,t[74]=pe,t[75]=me):me=t[75];let he=i===`streaming`?`secondary`:`ghost`,ge;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(ge=()=>a(`streaming`),t[76]=ge):ge=t[76];let _e;t[77]===r?_e=t[78]:(_e=r(`memoryDebugPanel.tabs.streaming`),t[77]=r,t[78]=_e);let ve;t[79]!==he||t[80]!==_e?(ve=(0,$.jsx)(Y,{size:`sm`,variant:he,className:`flex-1`,onClick:ge,children:_e}),t[79]=he,t[80]=_e,t[81]=ve):ve=t[81];let ye;t[82]!==me||t[83]!==ve?(ye=(0,$.jsxs)(`div`,{className:`mb-3 flex gap-1 rounded-md p-1`,style:ue,children:[me,ve]}),t[82]=me,t[83]=ve,t[84]=ye):ye=t[84];let be;t[85]!==i||t[86]!==te||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?(be=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)(cC,{label:r(`memoryDebugPanel.metric.totalMessages`),value:ee.total}),(0,$.jsx)(cC,{label:r(`memoryDebugPanel.metric.cachedSessions`),value:`${te} / ${Vr.MAX_SESSIONS}`}),(0,$.jsx)(cC,{label:r(`memoryDebugPanel.metric.userMessages`),value:ee.user}),(0,$.jsx)(cC,{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:$r()})})]}),(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:Vr.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)(qo,{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)(na,{children:[(0,$.jsx)($i,{asChild:!0,children:(0,$.jsx)(Y,{size:`sm`,variant:`outline`,className:`typography-meta`,onClick:()=>{u.map(xC),Object.keys(_),V.map(SC),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:re,children:r(`memoryDebugPanel.actions.copyJson`)})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(cC,{label:r(`memoryDebugPanel.metric.uiMetrics`),value:y.entries.length}),(0,$.jsx)(cC,{label:r(`memoryDebugPanel.metric.vscodeMetrics`),value:x.entries.length}),(0,$.jsx)(cC,{label:r(`memoryDebugPanel.metric.messageListRenders`),value:j.messageListRender}),(0,$.jsx)(cC,{label:r(`memoryDebugPanel.metric.messageListStreamRenders`),value:j.messageListRenderStreaming}),(0,$.jsx)(cC,{label:r(`memoryDebugPanel.metric.chatMessageRenders`),value:j.chatMessageRender}),(0,$.jsx)(cC,{label:r(`memoryDebugPanel.metric.chatMessageStreamRenders`),value:j.chatMessageRenderStreaming}),(0,$.jsx)(cC,{label:r(`memoryDebugPanel.metric.chatMessageStaticDuringStream`),value:j.chatMessageRenderStaticDuringStream}),(0,$.jsx)(cC,{label:r(`memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn`),value:j.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),(0,$.jsx)(lC,{title:r(`memoryDebugPanel.section.uiStreamingMetrics`),snapshot:y,emptyLabel:r(`memoryDebugPanel.section.noUiSamples`)}),x.entries.length>0?(0,$.jsx)(lC,{title:r(`memoryDebugPanel.section.vscodeBridgeMetrics`),snapshot:x,emptyLabel:r(`memoryDebugPanel.section.noVscodeSamples`)}):null]}),t[85]=i,t[86]=te,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]=be):be=t[99];let xe;return t[100]!==le||t[101]!==ye||t[102]!==be?(xe=(0,$.jsxs)(Ta,{className:`fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area`,style:U,children:[le,ye,be]}),t[100]=le,t[101]=ye,t[102]=be,t[103]=xe):xe=t[103],xe};function dC(e,t){return e+t.count}function fC(e){return e.currentSessionId}function pC(e){return e.sessionMemoryState}function mC(){return je()}function hC(e){return e.scope}function gC(e){return!!e}function _C(e){return e.totalRequestCount}function vC(){return Re()}function yC(){return ke()}function bC(e,t){return t.lastAccessed-e.lastAccessed}function xC(e){return{id:e.id,title:e.title}}function SC(e){return{id:e.id,title:e.title,total:e.messageCount,user:e.userMessageCount,assistant:e.assistantMessageCount}}var CC=()=>{let{isMobile:e,closeActiveContextPanelTab:t}=q.getState();if(e)return;let n=jo();n&&t(n)||M()&&R(`desktop_close_current_window`).catch(e=>{console.warn(`[menu-actions] failed to close current window`,e)})},wC=()=>{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=wC()||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`)},EC=`yuri:menu-action`,DC=`yuri:check-for-updates`,OC=e=>typeof e?.listen==`function`?`bridge`:`dom`,kC=e=>{let t=Vn(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=_s(e=>e.checkForUpdates),{setThemeMode:_}=or(),{t:v}=At(),y=Q.useRef(!1),b=typeof window>`u`?null:window.__YURI_DESKTOP__,x=OC(b),S=Q.useCallback(()=>{y.current||(y.current=!0,g().then(()=>{let{available:e,error:t}=_s.getState();if(t){X.error(v(`sessions.sidebar.updateCheck.errorTitle`),{description:t});return}e||X.success(v(`sessions.sidebar.updateCheck.latestVersion`))}).finally(()=>{y.current=!1}))},[g,v]),C=Q.useCallback(()=>{ln.requestDirectoryDialog()},[]),w=Q.useCallback(e=>{Pi(e,Vn.getState().currentSessionId,e=>{s(`chat`),o(!1),Vn.getState().setCurrentSession(e.sessionId,e.directory)})},[s,o]),T=Q.useCallback(e=>{let{activeProjectId:t,projects:n,setActiveProject:r}=kn.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),hi();break;case`change-workspace`:C();break;case`close-tab-or-window`:CC();break;case`toggle-right-sidebar`:{let e=jo();e&&d(e);break}case`open-right-sidebar-git`:{let e=jo();e&&q.getState().openContextPanel(e),f(!0),p(`git`);break}case`open-right-sidebar-files`:{let e=jo();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`:gi();break;case`zoom-out`:vi();break;case`zoom-reset`:Hi();break;case`go-back`:Me.getState().goBack();break;case`go-forward`:Me.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`:Yi().catch(()=>{X.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(EC,e),window.addEventListener(DC,t),()=>{window.removeEventListener(EC,e),window.removeEventListener(DC,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])},AC=(e,t)=>e<t?-1:+(e>t),jC=e=>JSON.stringify([...e.entries()].map(([e,t])=>[e,[...new Set(t)].sort(AC)]).sort(([e],[t])=>AC(e,t)));async function MC({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 NC=`yuri:tray-action`,PC=3e4,FC=120,IC=20,LC=()=>{if(typeof window>`u`)return!1;let e=window.__YURI_PLATFORM__;return e===`darwin`||e===`win32`},RC=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},zC=e=>{let t=Array.isArray(e.questions)?e.questions[0]:void 0;return t?.header||t?.question||`Question`},BC=e=>tr(e),VC=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t},HC=(e,t,n,r)=>{if(!e)return``;let i=Hn(t,n,e),a=VC(i?i.path:e),o=Tn(e),s=o&&r.get(o)||``;if(!s){for(let[e,t]of lo.getState().directories)if(Tn(e)===o){s=t.status?.current??``;break}}if(!s)for(let e of n.values()){let t=e.find(e=>Tn(e.path)===o);if(t?.branch){s=t.branch;break}}return s?`${a} · ${s}`:a},UC=()=>{let{results:e,dropdownProviderIds:t,displayMode:n}=Is.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 ws(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:ra(n.label??t),value:da(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}},WC=async()=>{try{if(L())return`Local Yuri`;let e=window.__YURI_LOCAL_ORIGIN__||window.location.origin,t=m();if(t&&te(t,e))return`Local Yuri`;let n=(await re()).hosts.find(e=>t?te(t,H(e)):!1);return n?.label?.trim()?V(n.label.trim()):`Instance`}catch{return``}},GC=()=>{let e=new Map,t=new Map,n=[],r=new Map,i;try{i=Te()}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(Tn(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:RC(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:zC(r),directory:a})}}return{statusById:e,branchByDirectory:t,approvals:n,titleById:r}},KC=()=>{let e=vn.getState().activeSessions,t=new Set;e.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>BC(t)-BC(e)).slice(0,IC).forEach(e=>{let n=Wn(e);n&&t.add(n)});let n=new Map;for(let r of e){if(!r?.id)continue;let e=Wn(r);if(!e||!t.has(e))continue;let i=n.get(e)??[];i.push(r.id),n.set(e,i)}return n},qC=e=>{let t=GC(),n=zn.getState().index.session,r=vn.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=cn.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=kn.getState().projects,d=Vn.getState().availableWorktreesByProject,f=r.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>BC(t)-BC(e)).slice(0,IC).map(e=>{let r=[e.id,...o(e.id)],i=Wn(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:HC(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:UC(),dockBadgeCount:h}},JC=()=>{Q.useEffect(()=>{if(!LC()||!M())return;let e=!1,t=``,n=null,r=``,i=()=>{if(e)return;let n=qC(r),i=JSON.stringify(n);i!==t&&(t=i,R(`desktop_tray_update`,n))};WC().then(t=>{e||(r=t,i())});let a=null,o=``,s=()=>{let e=Zt.getState();return e.isConnected&&e.connectionPhase===`connected`},c=()=>{if(a)return a;let t=KC();return o=jC(t),a=MC({targets:t,isReady:s,concurrency:2,isDisposed:()=>e,fetchStatus:async()=>{try{let e=await Se.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)=>{Mn(e,t,[...n])}}).finally(()=>{a=null;let t=KC();!e&&s()&&jC(t)!==o&&c()}),a},l=()=>{e||n!==null||(n=window.setTimeout(()=>{n=null,i()},FC))},u=new Map,d=()=>{if(e)return;let t;try{t=Te()}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=Te().subscribeRegistry(()=>{d(),l()})}catch{}d();let p=zn.subscribe(()=>l()),m=vn.subscribe(()=>{l(),s()&&jC(KC())!==o&&c()}),h=kn.subscribe(()=>l()),g=Vn.subscribe(()=>l()),_=lo.subscribe(()=>l()),v=q.subscribe(()=>l()),y=cn.subscribe(()=>l()),b=s(),x=Zt.subscribe(()=>{let e=s();e&&!b&&c(),b=e});b&&c();let S=Is.subscribe(()=>l());Is.getState().loadSettings().then(()=>{if(e)return;let{dropdownProviderIds:t,results:n}=Is.getState();t.length>0&&t.some(e=>!n.some(t=>t?.providerId===e))&&Is.getState().fetchAllQuotas()});let C=window.setInterval(()=>{let e=Is.getState();e.autoRefresh&&e.dropdownProviderIds.length>0&&e.fetchAllQuotas()},Math.max(3e4,Is.getState().refreshIntervalMs||6e4)),w=window.setInterval(()=>{d(),i()},PC);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(!LC()||typeof window>`u`)return;let e=window.__YURI_DESKTOP__?.listen;if(typeof e!=`function`)return;let t=e=>{e.type===`respond-permission`&&Gn(e.sessionId,e.id,e.response).catch(()=>{X.error(`Failed to respond to permission request`)})},n=null;return e(NC,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{}}},[])},YC=`/api/notifications/stream`,XC=()=>typeof document>`u`||document.visibilityState===`visible`&&document.hasFocus(),ZC=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}},QC=e=>{let t=(0,Ll.c)(3),n=e?.enabled??!0,r,i;t[0]===n?(r=t[1],i=t[2]):(r=()=>{if(!n||w()||!v()||typeof window>`u`||typeof EventSource>`u`)return;let e=new EventSource(c().sse(YC));return e.onmessage=$C,()=>{e.close()}},i=[n],t[0]=n,t[1]=r,t[2]=i),Q.useEffect(r,i)};function $C(e){let t;try{t=JSON.parse(e.data)}catch{return}let n=q.getState();if(!n.nativeNotificationsEnabled)return;let r=ZC(t);r&&((r.requireHidden??n.notificationMode!==`always`)&&XC()||B()?.notifications?.notifyAgentCompletion(r))}var ew=`pwa-install-toast-shown`,tw=`pwa-install-toast-dismissed`,nw=()=>{let e=(0,Ll.c)(6),{browserTab:t}=zs(),{t:n}=At(),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`||!v()||!t)return;let e=null,n=null,i=()=>{n!==null&&(X.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`&&X.success(r.current(`pwa.installPrompt.started`))},o=t=>{let o=t;if(typeof o.prompt!=`function`)return;o.preventDefault(),e=o;let s=Ue(),c=He();rl({dismissed:s.getItem(tw),sessionShown:c.getItem(ew),hasActiveToast:n!==null})&&(c.setItem(ew,`true`),n=X.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:()=>{Ue().setItem(tw,`true`),i()}}}))},s=()=>{e=null,i(),X.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)};function rw(e){let t=typeof e?.sessionId==`string`?e.sessionId.trim():``;if(!t)return;let n=typeof e?.directory==`string`&&e.directory.trim().length>0?e.directory.trim():null;q.getState().setActiveMainTab(`chat`),Vn.getState().setCurrentSession(t,n)}var iw=({open:e,onOpenChange:t})=>{let{t:n}=At(),[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 Mt())})()},[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)(hr,{open:e,onOpenChange:t,children:(0,$.jsx)(fr,{className:`max-w-xs p-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[(0,$.jsx)(Wa,{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`)})]})})})},aw=(e,t)=>{let n=e.get(t);return typeof n==`string`&&n.trim()||null},ow=(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},sw=()=>{let e=Ls(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=aw(t,`code`),a=js(t),o=us(t),s=aw(t,`error`),c=aw(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(ow(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`})})]})})},cw=()=>{let e=vn(e=>e.startupSyncProgress.active),t=vn(e=>e.startupSyncProgress.phase),n=vn(e=>e.startupSyncProgress.completed),r=vn(e=>e.startupSyncProgress.total),{locale:i,t:a}=At(),[o,s]=Q.useState(!0),c=rt(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},lw=(e,t,n,r=350)=>n?Math.max(0,r-Math.max(0,t-e)):null;function uw(e){let t=(0,Ll.c)(21),{transition:n,ready:r}=e,{t:i}=At(),a=ga(!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=lw(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)(Wa,{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 dw=xo(()=>gt(()=>import(`./OnboardingScreen-DAiSh2kq.js`).then(e=>({default:e.OnboardingScreen})),__vite__mapDeps([158,1,4,2,3,5,6,94,7,37,9,10,11,8,12,16,14,38,39,40,36,41,20,42,43,44,47,48,49,105,114,45]))),fw=36e5,pw=12e5,mw=()=>{let e=(0,Ll.c)(3),t=q(xw),n=q(Sw),r;return e[0]!==t||e[1]!==n?(r=(0,$.jsx)(iw,{open:t,onOpenChange:n}),e[0]=t,e[1]=n,e[2]=r):r=e[2],r},hw=e=>{let t=(0,Ll.c)(21),{onRetry:n,isRetrying:r}=e,{t:i}=At(),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},gw=e=>e?e.replace(/\\/g,`/`).replace(/\/+$/g,``):``,_w=()=>{if(typeof window>`u`||!Ya())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`}},vw=()=>typeof window>`u`?!1:window.location.pathname===vs,yw=e=>{let t=(0,Ll.c)(22),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=e,a=Me(Cw),o=Vn(ww),s=Vn(Tw),c=ai(),l=Q.useRef(null),u;t[0]===n.directory?u=t[1]:(u=gw(n.directory),t[0]=n.directory,t[1]=u);let d=u,f;t[2]===a?f=t[3]:(f=gw(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)(Si,{embeddedBackgroundWorkEnabled:i}),t[14]=i,t[15]=g);let _;t[16]===n.readOnly?_=t[17]:(_=(0,$.jsx)(Dc,{readOnly:n.readOnly}),t[16]=n.readOnly,t[17]=_);let v;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Br,{}),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 bw({apis:e}){Q.useEffect(()=>{Ne(`App:mounted`),Ie()},[]),Q.useEffect(()=>bn(),[]);let t=Zt(e=>e.initializeApp),n=Zt(e=>e.isInitialized),r=Zt(e=>e.isConnected),i=Vn(e=>e.error),a=Vn(e=>e.clearError),o=Vn(e=>!(e.newSessionDraft?.open&&e.currentSessionId===null)),c=Me(e=>e.currentDirectory),l=Me(e=>e.setDirectory),u=Me(e=>e.isSwitchingDirectory),[f,p]=Q.useState(!1),m=Ds(e=>e.refreshStatus),[h,g]=Q.useState(()=>e.runtime.isVSCode),[_,v]=Q.useState(!1),[y,S]=Q.useState(!1),[T,k]=Q.useState(0),[A,M]=Q.useState(0),[N,P]=Q.useState({epoch:0,startedAt:0}),[F,z]=Q.useState(!1),B=Q.useRef(!1),V=q(e=>e.wideChatLayoutEnabled),H=q(e=>e.mobileKeyboardMode),te=Q.useMemo(()=>w(),[]),ne=vn(e=>e.hasCachedSessionIndex),re=vn(e=>e.hasHydratedSessionIndex),[U,ie]=Q.useState(()=>D()),[ae,W]=Q.useState(()=>{let e=E();return e===null?null:O({isDesktopShell:!0,bootOutcome:e})}),oe=Q.useRef(!1),G=Q.useMemo(()=>_w(),[]),se=!G||_,ce=Q.useMemo(()=>vw(),[]);Q.useEffect(()=>(Le(f),()=>{Le(!1)}),[f]),Q.useEffect(()=>{qe(H)},[H]),Q.useEffect(()=>{g(e.runtime.isVSCode)},[e.runtime.isVSCode]),Q.useEffect(()=>{let e=qr(e=>{d(e)&&(te&&P(e=>({epoch:e.epoch+1,startedAt:Date.now()})),Rc(e),M(e=>e+1),S(!1),k(e=>e+1))}),t=s(t=>e.schedule(t));return()=>{t(),e.cancel()}},[te]),Q.useEffect(()=>(document.documentElement.classList.toggle(`wide-chat-layout`,V),()=>{document.documentElement.classList.remove(`wide-chat-layout`)}),[V]),Q.useEffect(()=>(ee(e),()=>ee(null)),[e]),Q.useEffect(()=>{if(G)return;let t=!1;return Yt().then(()=>{t||m(e.github,{force:!0})}),()=>{t=!0}},[e.github,G,m]),Bi();let le=U===`valid`,ue=ae?.screen===`main`,[de,fe]=Q.useState(!1);Q.useEffect(()=>{if(!se||!b({isDesktopShell:te,isInitialized:te&&ue?ne||n&&re:n,bootOutcomeKnown:le,bootViewIsMain:ue}))return;let e,t=setTimeout(()=>{let t=document.getElementById(`initial-loading`);t?(t.classList.add(`fade-out`),e=setTimeout(()=>{t.remove(),fe(!0)},300)):fe(!0)},150);return()=>{clearTimeout(t),e&&clearTimeout(e)}},[se,te,n,le,ue,ne,re]),Q.useEffect(()=>{if(!te||U!==`malformed`)return;let e=document.getElementById(`initial-loading`);e&&(e.textContent=`Desktop startup failed — please restart the app.`)},[te,U]),Q.useEffect(()=>{if(!se||te)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)}},[se,te,n]),Q.useEffect(()=>{if(!se||h)return;let e=!1;return Yt().then(()=>{if(!e)return t()}),()=>{e=!0}},[se,t,h]),Q.useEffect(()=>{if(!se||h||n)return;let e=!0,t,r=0,i=1e3,a=async()=>{if(!e)return;if(r>=10){S(!0);return}let n=Zt.getState();if(n.isInitialized){S(!1);return}if(r+=1,await Yt(),!e)return;await n.initializeApp();let o=Zt.getState();if(!e)return;if(o.isInitialized){S(!1);return}if(r>=10){S(!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)}},[se,T,n,h]),Q.useEffect(()=>{se&&n&&S(!1)},[se,n]),Q.useEffect(()=>{if(!se||!y)return;let e=document.getElementById(`initial-loading`);if(e){e.classList.add(`fade-out`);let t=setTimeout(()=>{e.remove()},300);return()=>clearTimeout(t)}},[se,y]),oi({enabled:se&&!h,source:`startupRecovery`}),Q.useEffect(()=>{u||h||r&&Se.setDirectory(c)},[c,u,r,h]),Q.useEffect(()=>{if(!G||typeof window>`u`)return;let e=e=>{let t=e?.visible===!0;v(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:Za},window.location.origin),()=>{window.removeEventListener(`message`,t),n.__yuriSetEmbeddedVisibility===e&&delete n.__yuriSetEmbeddedVisibility}},[G]),Q.useEffect(()=>{!G?.directory||h||c!==G.directory&&l(G.directory,{showOverlay:!1})},[c,G,h,l]),Q.useEffect(()=>{if(!G||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)}},[G]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;rw(t??{})},t=e=>{let t=e.detail?.assistantID;typeof t==`string`&&t.trim()&&ar(t.trim())},n=e=>{let t=e.detail,n=t?.projectID,r=t?.taskID;n&&r&>(async()=>{let{openScheduledTask:e}=await import(`./scheduledTaskNavigation-7dD6PWMD.js`).then(e=>e.n);return{openScheduledTask:e}},__vite__mapDeps([115,1,8,3,2,9,7,10,11])).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=Me.getState().currentDirectory,{activeProjectId:t,projects:n}=kn.getState(),r=n.find(e=>e.id===t)??null;R(`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=()=>{let e=Vn.getState().currentSessionId;e&&An(e)};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail,n=typeof t?.directory==`string`&&t.directory.trim().length>0?t.directory.trim():null,r=typeof t?.projectId==`string`&&t.projectId.trim().length>0?t.projectId.trim():null,i=typeof t?.initialPrompt==`string`&&t.initialPrompt.trim().length>0?t.initialPrompt.trim():void 0;q.getState().setActiveMainTab(`chat`),q.getState().setSessionSwitcherOpen(!1),Vn.getState().openNewSessionDraft({selectedProjectId:r,directoryOverride:n,preserveDirectoryOverride:!!n,ensureProjectForDirectory:!!n,initialPrompt:i})};return window.addEventListener(`yuri:open-draft-session`,e),()=>window.removeEventListener(`yuri:open-draft-session`,e)},[]),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=kn.getState(),i=r.projects.find(e=>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`||!se||!n||u||oe.current||(oe.current=!0,window.__yuriAppReady=!0,window.dispatchEvent(new Event(`yuri:app-ready`)))},[se,n,u]),ii({enabled:se}),QC({enabled:se}),nw(),qi(),Pc(),kC(wt(()=>{p(e=>!e)})),Q.useEffect(()=>{I()&&yt().then(async e=>{e&&await j(e)}).catch(console.warn)},[]),Q.useEffect(()=>{if(!n||!I()||B.current)return;B.current=!0;let e=!1,t=null,r=null;_s.getState().subscribeDesktopUpdateEvents().then(t=>{if(e){t();return}r=t});let i=()=>{let e=_s.getState();e.checking||e.checkForUpdates()},a=n=>{t=window.setTimeout(()=>{e||(document.visibilityState===`visible`&&i(),a(fw))},n)},o=()=>{if(e||document.visibilityState!==`visible`)return;let t=_s.getState().lastChecked;t!=null&&Date.now()-t<pw||i()};return a(0),window.addEventListener(`focus`,o),()=>{e=!0,t!==null&&window.clearTimeout(t),window.removeEventListener(`focus`,o),r&&r()}},[n]),JC(),Q.useEffect(()=>{if(G)return;let e=e=>{Ot(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)},[G]),Q.useEffect(()=>{G||i&&setTimeout(()=>a(),5e3)},[a,G,i]),Q.useEffect(()=>{if(!te||U!==`not-injected`)return;let e=!1,t=0,n=()=>{if(e)return;t++;let r=D();if(r!==`not-injected`){if(e=!0,ie(r),r===`valid`){let e=E();e&&W(O({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}},[te,U]);let pe=wt(async()=>{if(C({isDesktopShell:w(),isDesktopLocalOriginActive:L()})){await x();return}window.location.reload()}),me=wt(async()=>{if(!F){S(!1),z(!0);try{await Yt(),await Zt.getState().initializeApp()}finally{z(!1)}Zt.getState().isInitialized||k(e=>e+1)}}),he=e=>{if(e.screen===`recovery`)return e.variant};if(te&&ae&&ae.screen!==`main`){if(ae.screen===`chooser`)return(0,$.jsx)(Da,{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)(dw,{mode:`first-launch`,onCliAvailable:pe,onChooseRemote:()=>{}})})})});let e=he(ae),t=ae.screen===`recovery`&&`url`in ae?ae.url:void 0;return(0,$.jsx)(Da,{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)(dw,{mode:`recovery`,recoveryVariant:e,recoveryHostUrl:t,recoveryHostLabel:void 0,onCliAvailable:pe})})})})}if(G)return Xt(),(0,$.jsx)(Da,{children:(0,$.jsx)(Wt,{sdk:Se.getSdkClient(),directory:c||``,bootstrapDirectory:o,children:(0,$.jsx)(Ki,{apis:e,children:(0,$.jsx)(ta,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-background`,children:(0,$.jsx)(yw,{embeddedSessionChat:G,isVSCodeRuntime:h,embeddedBackgroundWorkEnabled:se})})})})},A)});if(ce)return(0,$.jsx)(Da,{children:(0,$.jsx)(sw,{})});if(y&&!n&&!h&&!G)return(0,$.jsx)(Da,{children:(0,$.jsx)(hw,{onRetry:()=>{me()},isRetrying:F})});let ge=!n&&!te;return(0,$.jsx)(Da,{children:(0,$.jsx)(Wt,{sdk:Se.getSdkClient(),directory:c||``,bootstrapDirectory:o,children:(0,$.jsx)(Ki,{apis:e,children:(0,$.jsx)(ic,{ready:de&&n&&se,children:(0,$.jsx)(cp,{children:(0,$.jsx)(ta,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:te?`h-full text-foreground bg-transparent`:`h-full text-foreground bg-background`,children:[(0,$.jsx)(Si,{embeddedBackgroundWorkEnabled:se}),(0,$.jsx)($s,{}),(0,$.jsx)(Zc,{}),(0,$.jsx)(OS,{}),te&&(0,$.jsx)(uw,{transition:N,ready:n&&r}),(0,$.jsx)(cw,{}),(0,$.jsx)(Br,{}),!ge&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kc,{}),(0,$.jsx)(gc,{}),(0,$.jsx)(cc,{}),(0,$.jsx)(mw,{}),f&&(0,$.jsx)(uC,{onClose:()=>p(!1)})]})]})})})})})},A)})}function xw(e){return e.isAboutDialogOpen}function Sw(e){return e.setAboutDialogOpen}function Cw(e){return e.currentDirectory}function ww(e){return e.currentSessionId}function Tw(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 Ew=typeof window<`u`&&window.__YURI_RUNTIME_APIS__||(()=>{throw Error(`Runtime APIs not provided for legacy UI entrypoint.`)})();zt(),w()&&pn(),ri({runtimeKey:f(),initializeAppearance:nt,syncSettings:Qe,applyDirectory:Zi,startWatchers:()=>{Di(),ei(),Hr()},onError:(e,t)=>{console.error(e===`appearance`?`[main] appearance init failed:`:`[main] settings init failed:`,t)}});var Dw=document.getElementById(`root`);if(!Dw)throw Error(`Root element not found`);(0,Il.createRoot)(Dw).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(Ur,{children:(0,$.jsx)(Ft,{children:(0,$.jsx)(Rr,{children:(0,$.jsx)(Ti,{children:(0,$.jsx)(Xr,{children:(0,$.jsx)(Qr,{children:(0,$.jsx)(bw,{apis:Ew})})})})})})})}));
|