@yuriai/web 0.2.29-beta.4 → 0.2.29-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/assets/{AssistantContactStatus-AG7iGeRF.js → AssistantContactStatus-B67HXRUY.js} +3 -3
  2. package/dist/assets/{AssistantUnreadBadge-BMCaH0Cc.js → AssistantUnreadBadge-Xz7kMLSv.js} +1 -1
  3. package/dist/assets/{AssistantView-C5ACV-pb.js → AssistantView-YVdgtBeh.js} +1 -1
  4. package/dist/assets/{DiagramView-DJDzscnd.js → DiagramView-DCrAY37j.js} +1 -1
  5. package/dist/assets/{GuiPluginSurface-DfLl4Gd9.js → GuiPluginSurface-u815jFNI.js} +1 -1
  6. package/dist/assets/{MarkdownRenderer-YzZqs3v5.js → MarkdownRenderer-DZXM92vp.js} +2 -2
  7. package/dist/assets/{MarkdownRendererImpl-BjjAFHTQ.js → MarkdownRendererImpl-BLzRLmeZ.js} +1 -1
  8. package/dist/assets/{MarkstreamRendererImpl-D8tam--u.js → MarkstreamRendererImpl-MqrsrtVx.js} +1 -1
  9. package/dist/assets/{MobileDetailNavigation-B-AuJG6R.js → MobileDetailNavigation-CozkWJ5y.js} +1 -1
  10. package/dist/assets/{MobileShareBridge-B8X_MEk1.js → MobileShareBridge-yWj21Mpo.js} +1 -1
  11. package/dist/assets/{MobileTabPageHeader-vvveBlBV.js → MobileTabPageHeader-BSbOGw3M.js} +1 -1
  12. package/dist/assets/{MultiRunWindow-C0dOS6fA.js → MultiRunWindow-BDh7FxgY.js} +1 -1
  13. package/dist/assets/{SettingsView-aWGqxCrZ.js → SettingsView-C1dLufb0.js} +1 -1
  14. package/dist/assets/{SettingsWindow-rX0TNPNO.js → SettingsWindow-DZFZJ8PI.js} +1 -1
  15. package/dist/assets/{TerminalView-BArR-jEl.js → TerminalView-2DhtuWTv.js} +1 -1
  16. package/dist/assets/{ToolOutputDialog-Bdwio4o_.js → ToolOutputDialog-COWWhGPD.js} +1 -1
  17. package/dist/assets/{appThemeRegistry-DOuA757r.js → appThemeRegistry-CPa7wDcf.js} +1 -1
  18. package/dist/assets/{capgoAdapter-BBnW57us.js → capgoAdapter-CQz-vZo-.js} +1 -1
  19. package/dist/assets/{gitApi-b2Mo4rXl.js → gitApi-CXkfrI_H.js} +1 -1
  20. package/dist/assets/{insertionBoundaries-BviApxnS.js → insertionBoundaries-CmxtGojv.js} +1 -1
  21. package/dist/assets/{main-Cp31rg32.js → main-CJAnB1m1.js} +4 -4
  22. package/dist/assets/{main-BchAIbLD.js → main-DuN735GT.js} +2 -2
  23. package/dist/assets/{mcpQueries-Cksi876R.js → mcpQueries-Ls770ehB.js} +1 -1
  24. package/dist/assets/{miniChat-BbuRxk9z.js → miniChat-BibI1YhA.js} +2 -2
  25. package/dist/assets/{mobile-CBiiV7GW.js → mobile-DNvOl_GU.js} +2 -2
  26. package/dist/assets/{mobileBackNavigation-BsbWBz8h.js → mobileBackNavigation-CXfKEN3p.js} +1 -1
  27. package/dist/assets/{multirun-Ce977k1P.js → multirun-CicU-KQt.js} +1 -1
  28. package/dist/assets/{native-config-5BNfonUF.js → native-config-BHa0LfdJ.js} +1 -1
  29. package/dist/assets/{projectMeta-KTYl7ter.js → projectMeta-D3GYq5jV.js} +1 -1
  30. package/dist/assets/{queue-abort-optimistic-CJmevpBJ.js → queue-abort-optimistic-DRJa-BrH.js} +1 -1
  31. package/dist/assets/{readiness-CdCOcZnK.js → readiness-lO-fOlzd.js} +1 -1
  32. package/dist/assets/{renderElectronMiniChatApp-wFpIvOFT.js → renderElectronMiniChatApp-DnzgZv3d.js} +2 -2
  33. package/dist/assets/{renderMobileApp-QJ2XwXGj.js → renderMobileApp-DLFGqfxp.js} +4 -4
  34. package/dist/assets/{runtimeConfig-IuT6iZ4x.js → runtimeConfig-Be6cMHuS.js} +1 -1
  35. package/dist/assets/{runtimeEndpointReset-DEWSVYyD.js → runtimeEndpointReset-DeWcqIyJ.js} +3 -3
  36. package/dist/assets/{sessionLookup-mvlGQJTe.js → sessionLookup-qvz-n65R.js} +1 -1
  37. package/dist/assets/{speechSettingsQueries-DEGyglgn.js → speechSettingsQueries-CsCKPsRU.js} +1 -1
  38. package/dist/assets/{types-COEinOJU.js → types-CTkS0uZU.js} +1 -1
  39. package/dist/assets/{useAppFontEffects-C__cAJlw.js → useAppFontEffects-Cs_0mUpl.js} +5 -5
  40. package/dist/assets/{useDesktopWindowControlsLayout-BYt7I5so.js → useDesktopWindowControlsLayout-avf-_JWZ.js} +1 -1
  41. package/dist/assets/{useEffectiveDirectory-CcDsvhjq.js → useEffectiveDirectory-esZ8PL08.js} +1 -1
  42. package/dist/assets/{useMobileNavigationStore-BgM0EvUr.js → useMobileNavigationStore-9lAGHZos.js} +4 -4
  43. package/dist/assets/{useWorkerHighlightedLines-ZOArIAed.js → useWorkerHighlightedLines-BxqdOw1S.js} +1 -1
  44. package/dist/index.html +5 -5
  45. package/dist/mini-chat.html +5 -5
  46. package/dist/mobile.html +5 -5
  47. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-Bdwio4o_.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-auth-DBn9yahL.js","assets/runtime-switch-DEZ1K7qW.js","assets/runtime-fetch-D0YWp3FJ.js","assets/desktop-JwYqThiw.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-base-ui-CzHs0bHY.js","assets/useUIStore-BDZCXouA.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-B2psfNaU.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/runtime-file-resource-qB_oVdE6.js","assets/queryRuntime-CTcigFdj.js","assets/fileQueries-DWj9yB2g.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-o29morT6.js","assets/platform-DFJEtBlo.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-BF2cNEuq.js","assets/store-BPYoxYhv.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-CLLDJn-P.js","assets/dialog-r7RRePv5.js","assets/dialog-CTYD3Sbr.css","assets/tap-LkQum5bB.js","assets/themes-BgDJcxRc.js","assets/MobileWindowStack-DGLdgoGr.js","assets/appThemeRegistry-DOuA757r.js","assets/useMobileNavigationStore-BgM0EvUr.js","assets/gitApiHttp-DGAlAuET.js","assets/vendor-opencode-client-cQ47ywrT.js","assets/vendor-effect-X1Hqc7ba.js","assets/persistence-Dta0OwIa.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-sonner-BEHGipm5.js","assets/useAssistantUIStore-CYyXdd5c.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/agentColors-DWSbQXy2.js","assets/rasterizePng-056Poix7.js","assets/MarkdownRenderer-YzZqs3v5.js","assets/useEffectiveDirectory-CcDsvhjq.js","assets/markdownHeightCache-D02GlOiy.js","assets/dualLimitLru-D8Sphgua.js","assets/toolHelpers-iEHVHQ9p.js","assets/image-loading-BUouaouB.js","assets/image-loading-D9Z_BASK.css","assets/ImageLoadingPlaceholder-DTWzB26a.js","assets/useWorkerHighlightedLines-ZOArIAed.js","assets/markdownTheme-CHNl6tUv.js","assets/markdown-worker-oBGEB9Eg.js","assets/vendor-tanstack-react-virtual-DSFNK3qc.js","assets/mobileBackNavigation-BsbWBz8h.js","assets/touch-gestures-CErgaXZ7.js","assets/ToolOutputDialog-CbGuK5bP.css","assets/TerminalView-BArR-jEl.js","assets/terminalApi-CPVNQ5DH.js","assets/vendor-ghostty-web-DbBrwBII.js","assets/device-DN1GigI_.js","assets/OverlayScrollbar-CzQC0JQI.js","assets/sortable-tabs-strip-Dc4Jr4ml.js","assets/vendor-dnd-kit-core-DK4OoOTr.js","assets/vendor-dnd-kit-accessibility-BOtnpZt5.js","assets/vendor-dnd-kit-sortable-Cv69eQm1.js","assets/useFontPreferences-UzjDmx4b.js","assets/projectActions-BX0cjZoq.js","assets/DiagramView-DJDzscnd.js","assets/diagram-D9-jif9d.js","assets/vendor-react-drawio-Dyg1-39Q.js","assets/SettingsView-aWGqxCrZ.js","assets/desktopHosts-CB0CTcMg.js","assets/desktopRelayRestore-C7pjf6fE.js","assets/types-COEinOJU.js","assets/native-config-5BNfonUF.js","assets/vendor-codemirror-autocomplete-C0FrlFqZ.js","assets/MobileShareBridge-B8X_MEk1.js","assets/MobileDetailNavigation-B-AuJG6R.js","assets/AgentAvatar-GVufO03R.js","assets/vendor-dicebear-core-CV95S5Pg.js","assets/vendor-dicebear-styles-C4OfoX7R.js","assets/gitApi-b2Mo4rXl.js","assets/input-DvF_mp0Y.js","assets/tooltip-BoAbDVNP.js","assets/speechSettingsQueries-DEGyglgn.js","assets/vendor-simplewebauthn-browser-Dwhcdg_5.js","assets/MobileResizableSheet-CAj4YGtu.js","assets/projectMeta-KTYl7ter.js","assets/textarea-CIhiRPB2.js","assets/dropdown-menu.styles-CX8oXdks.js","assets/YuriLogo-BZC0ckt0.js","assets/scheduledTaskNavigation-BqkeRfVc.js","assets/url-MRa-FtQa.js","assets/react-Bwr5-XPi.js","assets/MobileTabPageHeader-vvveBlBV.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-Cksi876R.js","assets/collapsible-CS5qCQRU.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-C6l4ycZG.js","assets/vendor-qrcode-D7jBCyl-.js","assets/vendor-dijkstrajs-BAzPDGZM.js","assets/readiness-CdCOcZnK.js","assets/GuiPluginWindow-CW0-Tapi.js","assets/vendor-yaml-C9KlJAlj.js","assets/SettingsView-C0HSdVvS.css","assets/SettingsWindow-rX0TNPNO.js","assets/MultiRunWindow-C0dOS6fA.js","assets/multirun-Ce977k1P.js","assets/insertionBoundaries-BviApxnS.js","assets/fileMentionAutocompleteState-BZJqfgae.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/vendor-fuzzysort-ukaRp9PC.js","assets/fileMentionTouchSelection-dpFpcetU.js","assets/AssistantView-C5ACV-pb.js","assets/sessionLookup-mvlGQJTe.js","assets/LoadingImage-B89ghYMH.js","assets/sessionLookup-8C8nv-EP.css","assets/AssistantContactStatus-AG7iGeRF.js","assets/vendor-motion-C9oiAdx-.js","assets/assistant-attachment-cache-DMw2Smc8.js","assets/AssistantUnreadBadge-BMCaH0Cc.js","assets/OnboardingScreen-BdU6Tyax.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,C as _,I as v,J as y,O as b,R as x,T as S,W as C,X as w,Y as T,Z as E,_ as D,a as O,b as k,g as A,j,k as M,q as N,t as P,v as ee,w as F,x as I,z as L}from"./desktop-JwYqThiw.js";import{n as R,t as z}from"./runtimeAPIRegistry-C2VogTny.js";import{g as B,p as V,r as H,u as te}from"./desktopHosts-CB0CTcMg.js";import{a as ne,i as re,t as U}from"./vendor-zustand-vDaAPGfl.js";import{A as ie,B as ae,L as W,M as oe,R as G,a as se,at as ce,d as le,f as ue,g as de,h as fe,i as pe,k as me,m as he,ot as ge,p as _e,st as ve,z as ye}from"./vendor-base-ui-CzHs0bHY.js";import{At as be,Ct as xe,Er as Se,In as Ce,Kn as we,Or as Te,Rn as Ee,St as De,_r as Oe,br as ke,bt as Ae,fn as je,gr as Me,kr as Ne,kt as Pe,mn as K,wt as Fe,xt as Ie,yr as Le,yt as Re,zn as ze}from"./gitApiHttp-DGAlAuET.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{C as Be,S as Ve,i as He,r as q,t as Ue,x as We}from"./useUIStore-BDZCXouA.js";import{D as Ge,O as Ke,i as qe,jt as Je,ot as Ye,r as Xe,t as Ze}from"./persistence-Dta0OwIa.js";import{n as Qe,t as $e}from"./vendor-react-DlzBev0S.js";import{c as et}from"./vendor-tanstack-query-core-BWz0ose6.js";import{n as tt,o as nt,s as rt}from"./vendor-tanstack-react-query-B2psfNaU.js";import{d as it,u as at}from"./fileQueries-DWj9yB2g.js";import{r as ot,s as st}from"./runtime-file-resource-qB_oVdE6.js";import{a as ct,n as lt}from"./path-utils-jGozTg9d.js";import{o as ut}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as dt}from"./pathNormalization-ewtPqJWn.js";import{n as ft}from"./terminalApi-CPVNQ5DH.js";import{a as pt}from"./types-COEinOJU.js";/* empty css */import{U as mt}from"./vendor-codemirror-autocomplete-C0FrlFqZ.js";import{a as ht}from"./vendor-pierre-diffs-BFiZ3IhI.js";import{a as gt,h as _t,i as vt,m as yt,t as bt}from"./vendor-reactuses-core-DWo5Wn6R.js";import{_ as xt,a as St,c as Ct,d as wt,f as Tt,g as Et,h as Dt,i as Ot,l as kt,m as At,o as jt,p as Mt,r as J,s as Nt,t as Y}from"./button-BF2cNEuq.js";import{n as Pt}from"./store-BPYoxYhv.js";import{S as Ft,b as It,h as Lt}from"./MobileDetailNavigation-B-AuJG6R.js";import{Br as Rt,C as zt,Ca as Bt,Cr as Vt,Ct as Ht,Dr as Ut,E as Wt,Ea as Gt,Fr as Kt,Ft as qt,G as Jt,Gr as Yt,Hr as Xt,Jr as Zt,K as Qt,Kt as $t,Mn as en,N as tn,P as nn,Qn as rn,Qr as X,R as an,Ri as on,S as sn,Sa as cn,Si as ln,St as un,T as dn,Ur as fn,V as pn,Wr as mn,Xr as hn,Zr as gn,_ as _n,_t as vn,ar as yn,ba as bn,cr as xn,ct as Sn,dr as Cn,dt as wn,fa as Tn,fr as En,g as Dn,gt as On,h as kn,ht as An,ir as jn,it as Mn,jn as Nn,kn as Pn,lr as Fn,lt as In,m as Ln,nr as Rn,p as zn,pt as Bn,q as Vn,qr as Hn,qt as Un,ri as Wn,rn as Gn,rt as Kn,tr as qn,ut as Jn,w as Yn,wa as Xn,wi as Zn,xr as Qn,xt as $n,y as er,z as tr}from"./useMobileNavigationStore-BgM0EvUr.js";import{n as nr}from"./useAssistantUIStore-CYyXdd5c.js";import{n as rr}from"./useThemeSystem-CNzUUkFn.js";import{n as ir,o as ar}from"./vendor-framer-motion-DDMKlXiP.js";import{n as Z,t as or}from"./Icon-CLLDJn-P.js";import{a as sr,i as cr,n as lr,o as ur,r as dr,t as fr}from"./dialog-r7RRePv5.js";import{A as pr,C as mr,D as hr,O as gr,P as _r,T as vr,V as yr,a as br,f as xr,h as Sr,i as Cr,j as wr,k as Tr,m as Er,o as Dr,p as Or,r as kr,t as Ar,w as jr,y as Mr}from"./gitApi-b2Mo4rXl.js";import{$ as Nr,A as Pr,At as Fr,B as Ir,Ct as Lr,D as Rr,Dt as zr,Et as Br,Ft as Vr,H as Hr,I as Ur,J as Wr,Lt as Gr,M as Kr,Mt as qr,N as Jr,Nt as Yr,O as Xr,Ot as Zr,P as Qr,Pt as $r,Rt as ei,S as ti,St as ni,Tt as ri,V as ii,Z as ai,_ as oi,_t as si,at as ci,b as li,bt as ui,c as di,ct as fi,d as pi,et as mi,f as hi,ft as gi,g as _i,gt as vi,h as yi,ht as bi,i as xi,it as Si,j as Ci,jt as wi,k as Ti,kt as Ei,l as Di,m as Oi,n as ki,nt as Ai,ot as ji,p as Mi,q as Ni,rt as Pi,s as Fi,st as Ii,t as Li,tt as Ri,u as zi,v as Bi,vt as Vi,w as Hi,wt as Ui,x as Wi,xt as Gi,y as Ki,yt as qi}from"./useAppFontEffects-C__cAJlw.js";import{D as Ji,E as Yi,_ as Xi,b as Zi,f as Qi,g as $i,h as ea,m as ta,v as na,y as ra}from"./insertionBoundaries-BviApxnS.js";import{t as ia}from"./input-DvF_mp0Y.js";import{i as aa,n as oa,r as sa,t as ca}from"./tooltip-BoAbDVNP.js";import{A as la,D as ua,E as da,K as fa,N as pa,O as ma,R as ha,S as ga,St as _a,T as va,_ as ya,_t as ba,b as xa,ct as Sa,d as Ca,et as wa,ft as Ta,g as Ea,gt as Da,h as Oa,ht as ka,it as Aa,j as ja,l as Ma,mt as Na,nt as Pa,p as Fa,rn as Ia,rt as La,s as Ra,st as za,tt as Ba,u as Va,ut as Ha,v as Ua,w as Wa,x as Ga,xt as Ka,y as qa,z as Ja}from"./speechSettingsQueries-DEGyglgn.js";import{t as Ya}from"./YuriLogo-BZC0ckt0.js";import{a as Xa,r as Za}from"./device-DN1GigI_.js";import{r as Qa}from"./themes-BgDJcxRc.js";import{f as $a,g as eo,h as to,p as no}from"./scheduledTaskNavigation-BqkeRfVc.js";import{a as ro,i as io}from"./sessionLookup-mvlGQJTe.js";import{E as ao,O as oo,_ as so,a as co,b as lo,f as uo,h as fo,i as po,l as mo,m as ho,n as go,p as _o,s as vo,x as yo}from"./projectMeta-KTYl7ter.js";import{n as bo,t as xo}from"./appThemeRegistry-DOuA757r.js";import{i as So,n as Co,r as wo,t as To}from"./dropdown-menu.styles-CX8oXdks.js";import{n as Eo,o as Do}from"./MarkdownRenderer-YzZqs3v5.js";import{a as Oo}from"./url-MRa-FtQa.js";import{a as ko,c as Ao,i as jo,l as Mo,o as No,s as Po}from"./toolHelpers-iEHVHQ9p.js";import{i as Fo}from"./react-Bwr5-XPi.js";import{n as Io,t as Lo}from"./useEffectiveDirectory-CcDsvhjq.js";import{t as Ro}from"./ImageLoadingPlaceholder-DTWzB26a.js";import{t as zo}from"./LoadingImage-B89ghYMH.js";import{_ as Bo,i as Vo,l as Ho,n as Uo,s as Wo,t as Go,v as Ko,y as qo}from"./vendor-dnd-kit-core-DK4OoOTr.js";import{a as Jo,n as Yo,o as Xo,s as Zo,t as Qo}from"./vendor-dnd-kit-sortable-Cv69eQm1.js";import{n as $o,r as es}from"./textarea-CIhiRPB2.js";import{h as ts}from"./useWorkerHighlightedLines-ZOArIAed.js";import{t as ns}from"./vendor-tanstack-react-virtual-DSFNK3qc.js";import{t as rs}from"./sortable-tabs-strip-Dc4Jr4ml.js";import{t as is}from"./vendor-motion-C9oiAdx-.js";import{A as as,C as os,D as ss,E as cs,O as ls,S as us,T as ds,Z as fs,a as ps,at as ms,b as hs,c as gs,dt as _s,f as vs,g as ys,h as bs,k as xs,l as Ss,lt as Cs,m as ws,n as Ts,o as Es,ot as Ds,p as Os,r as ks,s as As,st as js,u as Ms,v as Ns,w as Ps,y as Fs}from"./MobileTabPageHeader-vvveBlBV.js";import{i as Is,n as Ls,r as Rs,t as zs}from"./useDesktopWindowControlsLayout-BYt7I5so.js";import{n as Bs}from"./useFontPreferences-UzjDmx4b.js";import{$ as Vs,A as Hs,C as Us,Ct as Ws,D as Gs,E as Ks,G as qs,J as Js,K as Ys,M as Xs,N as Zs,O as Qs,S as $s,St as ec,T as tc,W as nc,X as rc,Y as ic,Z as ac,_ as oc,_t as sc,a as cc,at as lc,b as uc,bt as dc,c as fc,ct as pc,d as mc,dt as hc,et as gc,f as _c,ft as vc,g as yc,gt as bc,h as xc,ht as Sc,i as Cc,it as wc,j as Tc,l as Ec,lt as Dc,mt as Oc,n as kc,o as Ac,p as jc,pt as Mc,q as Nc,r as Pc,rt as Fc,s as Ic,st as Lc,tt as Rc,u as zc,ut as Bc,v as Vc,vt as Hc,w as Uc,x as Wc,xt as Gc,y as Kc,yt as qc}from"./runtimeEndpointReset-DEWSVYyD.js";import{t as Jc}from"./AssistantUnreadBadge-BMCaH0Cc.js";import{a as Yc,i as Xc,n as Zc,r as Qc,t as $c}from"./context-menu-C6l4ycZG.js";import{n as el,r as tl,t as nl}from"./collapsible-CS5qCQRU.js";import{n as rl,r as il}from"./readiness-CdCOcZnK.js";import{a as al,o as ol,r as sl,s as cl,t as ll}from"./projectActions-BX0cjZoq.js";import{t as ul}from"./diagram-D9-jif9d.js";import{a as dl,i as fl,n as pl,o as ml,r as hl,t as gl}from"./multirun-Ce977k1P.js";import{t as _l}from"./vendor-zumer-snapdom-yq9vlCKr.js";import{n as vl,t as yl}from"./vendor-html-to-image-BDMm2v6d.js";var Q=e(ve(),1),bl=$e(),xl=Qe(),$=ge();function Sl(e){let t=(0,xl.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 Cl=!1,wl=0,Tl=new Set,El=async()=>{let e=++wl;try{let t=await ee(`desktop_is_window_fullscreen`);if(e!==wl||t===Cl)return;Cl=t===!0,Tl.forEach(e=>e())}catch{}},Dl=e=>I()?(Tl.add(e),Tl.size===1&&(window.addEventListener(`yuri:window-resized`,El),El()),()=>{Tl.delete(e),Tl.size===0&&(window.removeEventListener(`yuri:window-resized`,El),wl++,Cl=!1)}):()=>{};function Ol(){return(0,Q.useSyncExternalStore)(Dl,Al,kl)}function kl(){return!1}function Al(){return Cl}function jl(){let e=(0,xl.c)(19),{t}=Tt(),n=q(Il),r=q(Fl),i=q(Pl),a=q(Nl),o=q(Ml),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=vt(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 Ml(e){return e.setWorkStatusOverlayOpen}function Nl(e){return e.setWorkStatusPanelEnabled}function Pl(e){return e.workStatusOverlayOpen}function Fl(e){return e.workStatusPanelFits}function Il(e){return e.workStatusPanelEnabled}var Ll=[{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`}],Rl=`finder`,zl=new Set([`finder`,`terminal`]),Bl=e=>typeof window<`u`&&window.__YURI_PLATFORM__===`win32`&&e.id===`finder`?{...e,label:`Explorer`,appName:`File Explorer`}:e,Vl=e=>{if(!e)return null;let t=Ll.find(t=>t.id===e)??null;return t?Bl(t):null},Hl=()=>Ll.filter(e=>zl.has(e.id)).map(e=>({...Bl(e)})),Ul=()=>{if(typeof window>`u`)return Rl;let e=window.localStorage.getItem(`openInAppId`);return e&&Vl(e)?e:Rl},Wl=!1,Gl=!1,Kl=!1,ql=0,Jl=null,Yl=()=>{Jl&&=(clearTimeout(Jl),null)},Xl=ne()((e,t)=>({selectedAppId:Ul(),availableApps:Hl(),hasLoadedApps:!1,isCacheStale:!1,isScanning:!1,initialize:()=>{if(Wl||typeof window>`u`)return;Wl=!0;let n=(t,n=!0)=>{if(!Array.isArray(t)||t.length===0){e({availableApps:Hl(),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:Ll.filter(e=>r.has(e.appName)||zl.has(e.id)).map(e=>({...Bl(e),iconDataUrl:i.get(e.appName)})),hasLoadedApps:!0})},r=async i=>{if(!I()||Gl||t().hasLoadedApps&&!i)return;let a=Ll.map(e=>e.appName);Yl(),i&&e({hasLoadedApps:!1}),Gl=!0,Kl=!1,e({isScanning:!0});try{let{apps:t,success:o,hasCache:s,isCacheStale:c}=await O(a,i),l=o&&!s&&t.length===0&&ql<3;if(e({isCacheStale:s?c:!1}),n(t,o?!l:!1),o){if(l){let e=[800,1600,3200][ql]??3200;ql+=1,Kl=!0,Jl=setTimeout(()=>{r()},e);return}ql=0,Kl=!1;return}if(ql<3){let e=[1e3,3e3,7e3][ql]??7e3;ql+=1,Kl=!0,Jl=setTimeout(()=>{r()},e)}}finally{Gl=!1,Kl||e({isScanning:!1})}};r(),window.addEventListener(`yuri:settings-synced`,t=>{let n=t.detail,r=n&&typeof n.openInAppId==`string`&&n.openInAppId.length>0&&Vl(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)&&(ql=3,Kl=!1,e({isScanning:!1,isCacheStale:!1}),n(r))}),window.__yuriAppReady&&r(),window.setTimeout(()=>{t().hasLoadedApps||r()},5e3)},loadInstalledApps:async n=>{if(Wl||t().initialize(),!I()||Gl||t().hasLoadedApps&&!n)return;let r=Ll.map(e=>e.appName);Yl(),n&&e({hasLoadedApps:!1}),Gl=!0,Kl=!1,e({isScanning:!0});try{let{apps:t,hasCache:i,isCacheStale:a}=await O(r,n),o=new Set(t.map(e=>e.name)),s=new Map(t.map(e=>[e.name,e.iconDataUrl??void 0])),c=Ll.filter(e=>o.has(e.appName)||zl.has(e.id)).map(e=>({...e,iconDataUrl:s.get(e.appName)}));e({availableApps:c.length>0?c:Hl(),hasLoadedApps:c.length>0,isCacheStale:i?a:!1})}finally{Gl=!1,Kl||e({isScanning:!1})}},selectApp:async t=>{Vl(t)&&(e({selectedAppId:t}),typeof window<`u`&&window.localStorage.setItem(`openInAppId`,t),await qe({openInAppId:t}))}})),Zl=(e=f(),t=l())=>{let n=e.startsWith(`host:`)?e.slice(5):null;return{queryKey:[t,`ssh-editor-apps`,n],enabled:I()&&D()&&n!==null,queryFn:async({signal:e})=>{let t=await ee(`desktop_ssh_editor_apps`,{hostId:n});return e.throwIfAborted(),t?{hostId:n,appIds:t.appIds}:null}}},Ql=()=>{let e=(0,xl.c)(3),t=(0,Q.useSyncExternalStore)(s,f,$l),n=(0,Q.useSyncExternalStore)(s,l,eu),r;return e[0]!==t||e[1]!==n?(r=Zl(t,n),e[0]=t,e[1]=n,e[2]=r):r=e[2],rt(r)};function $l(){return``}function eu(){return``}var tu=`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`,nu=`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`,ru=e=>({...e,fallbackIconDataUrl:e.id===`finder`&&window.__YURI_PLATFORM__!==`win32`?tu:e.id===`terminal`?nu:void 0}),iu=e=>{let t=(0,xl.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},au=({directory:e,className:t})=>{let{t:n}=Tt(),r=Xl(e=>e.selectedAppId),i=Xl(e=>e.availableApps),a=Xl(e=>e.isCacheStale),o=Xl(e=>e.isScanning),s=Xl(e=>e.initialize),c=Xl(e=>e.loadInstalledApps),l=Xl(e=>e.selectApp),{data:u}=Ql(),d=Q.useMemo(()=>u?i.filter(e=>u.appIds.includes(e.id)):i,[i,u]);Q.useEffect(()=>{s()},[s]);let f=I()&&k(),p=Q.useMemo(()=>{let e=d.find(e=>e.id===r)??d.find(e=>e.id===`finder`)??d[0];return e?ru(e):null},[d,r]);if(!f&&!u||!e)return null;let m=async t=>{try{let r=await j(e,t.id,t.appName,u?.hostId);!r&&!u?await g(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)},_=async()=>{await wt(e)};return(0,$.jsxs)(`div`,{className:J(`app-region-no-drag inline-flex h-7 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]`,`bg-[var(--surface-elevated)] overflow-hidden`,`border border-border/60`,t),children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void(p?m(p):_()),className:J(`inline-flex h-full items-center px-2.5 typography-ui-label font-medium`,`text-foreground hover:bg-interactive-hover transition-colors`,o&&`animate-pulse`),"aria-label":p?n(`openInApp.actions.openInAria`,{app:p.label}):n(`openInApp.actions.copyPath`),children:p?(0,$.jsx)(iu,{label:p.label,iconDataUrl:p.iconDataUrl,fallbackIconDataUrl:p.fallbackIconDataUrl}):(0,$.jsx)(Z,{name:`file-copy`,className:`h-4 w-4`})}),(0,$.jsxs)(Ba,{children:[(0,$.jsx)(Sa,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:J(`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`),"aria-label":n(`openInApp.actions.chooseAppAria`),children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4`})})}),(0,$.jsxs)(Pa,{align:`end`,className:`w-56 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(La,{className:`flex items-center gap-2`,onClick:()=>void _(),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)(za,{}),d.map(e=>{let t=ru(e);return(0,$.jsxs)(La,{className:`flex items-center gap-2`,onClick:()=>void h(e),children:[(0,$.jsx)(iu,{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)(La,{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]})]})]})},ou=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],su=[`dev`,`start`,`preview`,`serve`];async function cu(e,t,n){if(!e)return null;let r=du(t);if(r)return{command:r.command,label:r.name||`Start Preview`,actionId:r.id};if(n){let t=fu(n);if(t){let n=await pu(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 lu(e)){let e=await uu(),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 lu(e){let t=await mu(`${e}/index.html`,e);return typeof t==`string`&&t.trim().length>0}async function uu(){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 du(e){for(let t of e){let e=`${t.name} ${t.command}`.toLowerCase();if(su.some(t=>e.includes(t)))return t}return null}function fu(e){for(let{pattern:t}of ou)for(let n of Object.keys(e))if(t.test(n))return n;return null}async function pu(e){let t=await mu(`${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 mu(`${e}/${t}`,e);if(typeof r==`string`&&r.trim().length>0)return n}return`npm`}async function mu(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=z()?.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 hu(e){try{let t=await mu(`${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 gu=e=>new Promise(t=>{window.setTimeout(t,e)}),_u=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),vu=/https?:\/\/[^\s<>'"`]+/gi,yu=`__yuri_auto_discover_preview__`,bu=15e3,xu=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},Su=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}},Cu=e=>{let t=e.replace(_u,``).match(vu);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},wu=({projectRef:e,directory:t,className:n,compact:r=!1,allowMobile:i=!1})=>{let{t:a}=Tt(),{terminal:o,runtime:s}=at(),{isMobile:c}=Za(),l=Q.useMemo(()=>I(),[]),u=hs(e=>e.instances),d=hs(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=Bs(e=>e.sessions),y=Bs(e=>e.ensureDirectory),b=Bs(e=>e.setTabLabel),x=Bs(e=>e.setTabIconKey),S=Bs(e=>e.setActiveTab),C=Bs(e=>e.setConnecting),w=Bs(e=>e.setTabSessionId),T=Bs(e=>e.setTabPreviewUrl),E=Bs(e=>e.projectActionRuns),D=Bs(e=>e.setProjectActionRun),O=Bs(e=>e.updateProjectActionRunStatus),k=Bs(e=>e.removeProjectActionRun),[A,j]=Q.useState([]),[M,N]=Q.useState(null),[P,ee]=Q.useState(!1),F=Q.useRef({}),L=Q.useRef({}),R=Q.useRef({}),z=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 Oo(e)},[]),re=Q.useCallback(async()=>{if(!te)return;let e=B.current+1;B.current=e,ee(!0);try{let t=await En(te);if(B.current!==e)return;let n=t.actions;j(n),N(e=>e===yu||e&&n.some(t=>t.id===e)?e:null)}catch{if(B.current!==e)return}finally{B.current===e&&ee(!1)}},[te]),U=Q.useMemo(()=>al(t||te?.path||``),[t,te?.path]),ie=Q.useMemo(()=>M?A.find(e=>e.id===M)??null:null,[A,M]),ae=Q.useMemo(()=>({id:yu,name:a(`projectActions.actions.autoDiscover`),command:``,icon:`search`,autoOpenUrl:!0}),[a]),W=!c,oe=Q.useMemo(()=>W?[ae,...A]:A,[A,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(ll,e),()=>{window.removeEventListener(ll,e)}},[re,V]),Q.useEffect(()=>{M&&(M===yu&&W||A.some(e=>e.id===M)||N(null))},[A,W,M]),Q.useEffect(()=>{for(let[e,t]of Object.entries(E)){let n=v.get(t.directory)?.tabs.find(e=>e.id===t.tabId);(!n||n.terminalSessionId!==t.sessionId)&&k(e)}},[E,k,v]),Q.useEffect(()=>{for(let[e,t]of Object.entries(E)){let n=L.current[e]??{lastSeenChunkId:null,openedUrl:!1,tail:``,openInPreview:!1};L.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?Cu(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=E[e];t&&(T(t.directory,t.tabId,l,{locked:!1,autoOpened:!1}),t.status===`waiting-for-preview`&&O(e,`running`),window.clearTimeout(z.current[e]),delete z.current[e],_(t.directory,l))}else ne(l),X.success(a(`projectActions.toast.openedUrlFromOutput`));L.current[e]=n}for(let e of Object.keys(L.current))E[e]||(delete L.current[e],window.clearTimeout(z.current[e]),delete z.current[e])},[oe,_,ne,E,T,a,v,O]);let G=Q.useCallback(async(e,t={})=>{if(!U)throw Error(a(`projectActions.error.noActiveDirectory`));let n=cl(U,e.id);y(U);let r=Bs.getState(),i=r.getDirectoryState(U),o=F.current[n]||null,s=o?!!i?.tabs.some(e=>e.id===o):!1;(!o||!s)&&(o=r.createTab(U),F.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=Bs.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=cl(U,e.id),n=E[t];if(!(n&&n.status===`running`))try{let t=e.id===yu?await(async()=>{let[e,t]=await Promise.all([En({id:te?.id??``,path:U}),hu(U)]),n=await cu(U,e.actions,t);if(!n)throw Error(a(`contextPanel.preview.noDevServer`));return{id:yu,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!==yu}),c=s,d=!1;if(!c){C(U,i,!0);try{c=(await o.createSession({cwd:U})).sessionId,d=!0,w(U,i,c)}finally{C(U,i,!1)}}if(!c)throw Error(a(`projectActions.error.failedToCreateTerminalSession`));d&&await gu(350),t.id===yu&&(R.current[r]?.(),C(U,i,!0),R.current[r]=ft(c,e=>{e.type===`data`&&typeof e.data==`string`&&e.data.length>0&&Bs.getState().appendToBuffer(U,i,e.data),e.type===`exit`&&(Bs.getState().setTabLifecycle(U,i,`exited`),Bs.getState().setConnecting(U,i,!1),Bs.getState().removeProjectActionRun(r),delete L.current[r],R.current[r]?.(),delete R.current[r],window.clearTimeout(z.current[r]),delete z.current[r])},()=>{Bs.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?Su(t.openUrl):null,m=t.autoOpenUrl&&l?ol(t.desktopOpenSshForward,u):null;D({key:r,directory:U,actionId:t.id,tabId:i,sessionId:c,status:t.id===yu&&!p?`waiting-for-preview`:`running`}),window.clearTimeout(z.current[r]),delete z.current[r],t.id===yu&&!p&&(z.current[r]=window.setTimeout(()=>{Bs.getState().updateProjectActionRunStatus(r,`running`),delete z.current[r]},bu)),m?(T(U,i,null,{locked:!0}),ne(m),X.success(a(`projectActions.toast.openedForwardedUrl`))):p?(T(U,i,p,{locked:!0,autoOpened:!0}),_(U,p),X.success(a(`projectActions.toast.openedActionUrl`))):n?(T(U,i,null,{locked:!0}),X.error(a(`projectActions.error.invalidCustomUrlFormat`))):f?(T(U,i,null,{locked:!0}),X.error(a(`projectActions.error.selectedDesktopSshForwardUnavailable`))):T(U,i,null,{locked:!1,autoOpened:!1}),L.current[r]={lastSeenChunkId:null,openedUrl:!!m||!!p||n,tail:``,openInPreview:t.id===yu};let h=xu(t.command.trim().replace(/\r\n|\r/g,`
3
- `));await o.sendInput(c,`${h}\r`)}catch(e){k(t),delete L.current[t],R.current[t]?.(),delete R.current[t],window.clearTimeout(z.current[t]),delete z.current[t],X.error(e instanceof Error?e.message:a(`projectActions.error.failedToRunAction`))}},[u,G,i,c,l,U,ne,_,E,s.isVSCode,k,C,D,T,w,te?.id,a,o]),ce=Q.useCallback(async e=>{let t=cl(U,e.id),n=E[t];if(n){O(t,`stopping`);try{await o.sendInput(n.sessionId,``)}catch{}if(await new Promise(e=>{window.setTimeout(e,1e3)}),Bs.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{}w(n.directory,n.tabId,null)}k(t),delete L.current[t],R.current[t]?.(),delete R.current[t],window.clearTimeout(z.current[t]),delete z.current[t]}},[U,E,k,w,o,O]),le=Q.useCallback(()=>{let e=ie??oe[0];if(!e)return;let t=cl(U,e.id),n=E[t];if(n?.status!==`stopping`){if(n){ce(e);return}se(e)}},[oe,U,se,E,ie,ce]),ue=Q.useCallback((e,t=!1)=>{if(N(e.id),!t){se(e);return}let n=cl(U,e.id),r=E[n];if(r?.status!==`stopping`){if(r){ce(e);return}se(e)}},[U,se,E,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===yu?`search`:sl[pe]||`play`,he=E[cl(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:P||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)(ca,{children:[(0,$.jsx)(aa,{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)(oa,{sideOffset:6,children:a(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(Ba,{children:[(0,$.jsx)(Sa,{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)(Pa,{align:`end`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(La,{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)(za,{}),oe.map(e=>{let t=e.icon||`play`,n=e.id===yu?`search`:sl[t]||`play`,r=cl(U,e.id),i=E[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(La,{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:P||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)(ca,{children:[(0,$.jsx)(aa,{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)(oa,{sideOffset:6,children:a(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(Ba,{children:[(0,$.jsx)(Sa,{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)(Pa,{align:`start`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(La,{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)(za,{}),oe.map(e=>{let t=e.icon||`play`,n=e.id===yu?`search`:sl[t]||`play`,r=cl(U,e.id),i=E[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(La,{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 Tu(e){return e.isOpen&&e.activeTab===e.targetTab?{open:!1,tab:e.activeTab}:{open:!0,tab:e.targetTab}}var Eu=`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`,Du=`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`,Ou=Q.memo(function(e){let t=(0,xl.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??Eu,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)(aa,{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)(oa,{children:(0,$.jsx)(`p`,{children:r})}),t[12]=r,t[13]=v);let y;return t[14]!==_||t[15]!==v?(y=(0,$.jsxs)(ca,{children:[_,v]}),t[14]=_,t[15]=v,t[16]=y):y=t[16],y}),ku=Q.memo(function(e){let t=(0,xl.c)(42),{isMobile:n,githubAuthStatus:r,githubAccounts:i,githubAvatarUrl:a,githubLogin:o,isSwitchingGitHubAccount:s,handleGitHubAccountSwitch:c}=e,{t:l}=Tt();if(!r?.connected||n)return null;if(i.length>1){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=J(Eu,`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)(Sa,{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)(Aa,{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)(za,{}),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)(La,{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)(Pa,{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)(Ba,{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}),Au=Q.memo(function(e){let t=(0,xl.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}=Tt(),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=vt(D),k;t[1]!==s||t[2]!==l||t[3]!==d||t[4]!==o||t[5]!==a?(k=e=>{!e&&E.current||(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)(Sa,{asChild:!0,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)(rs,{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)(fs,{})]})}):null,(0,$.jsx)($r,{embedded:!0,open:i&&s===`instance`,onOpenChange:Iu,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)(Gc,{active:i&&s===`mcp`}):null,t[23]=s,t[24]=i,t[25]=P):P=t[25];let ee;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?(ee=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:Mu(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)(rs,{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)(ao,{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=Qs(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-ua(s.elapsedRatio):ua(s.elapsedRatio),l=ja(i.valueLabel,o),u=la(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:pa(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)(Ms,{percent:o,tonePercent:i.usedPercent,className:`h-1.5`,expectedMarkerPercent:c}),s&&S?(0,$.jsx)(Ss,{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)(nl,{open:i,onOpenChange:()=>x(e.providerId,r),children:[(0,$.jsxs)(tl,{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)(el,{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-ua(a.elapsedRatio):ua(a.elapsedRatio),s=ja(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:bs(n)}),(0,$.jsx)(`span`,{className:`typography-ui-label tabular-nums text-foreground`,children:s===`-`?``:s})]}),(0,$.jsx)(Ms,{percent:i,tonePercent:r.usedPercent,className:`h-1.5`,expectedMarkerPercent:o}),a&&S?(0,$.jsx)(Ss,{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]=ee):ee=t[41];let F;t[42]!==w||t[43]!==M||t[44]!==N||t[45]!==P||t[46]!==ee?(F=(0,$.jsxs)(Pa,{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,ee]}),t[42]=w,t[43]=M,t[44]=N,t[45]=P,t[46]=ee,t[47]=F):F=t[47];let I;return t[48]!==i||t[49]!==k||t[50]!==F?(I=(0,$.jsxs)(Ba,{open:i,onOpenChange:k,children:[A,F]}),t[48]=i,t[49]=k,t[50]=F,t[51]=I):I=t[51],I}),ju=(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??``),Mu=(e,t)=>{if(!e)return`-`;try{return Ja(e,t,{fallback:`-`})}catch{return`-`}},Nu=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},Pu=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,Fu=({onToggleLeftDrawer:e,onToggleRightDrawer:n,leftDrawerOpen:r,rightDrawerOpen:i})=>{let{t:a}=Tt(),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),y=q(e=>e.setActiveMainTab),b=q(e=>e.shortcutOverrides),x=q(e=>e.timeFormatPreference),S=Zn(e=>e.getCurrentModel),w=at(),T=zn(e=>!!e.newSessionDraft?.open),E=zn(e=>e.currentSessionId),D=Bn(E??``),O=Jt(E),j=Tn(e=>e.activeProjectId?e.projects.find(t=>t.id===e.activeProjectId)??null:null),M=Q.useMemo(()=>{if(!j)return null;let e=j.path.split(/[\\/]/).filter(Boolean);return e[e.length-1]??null},[j]),N=Os(e=>e.results),L=Os(e=>e.fetchAllQuotas),R=Os(e=>e.isLoading),z=Os(e=>e.lastUpdated),ne=Os(e=>e.displayMode),re=Os(e=>e.showPredValues),U=Os(e=>e.dropdownProviderIds),ie=Os(e=>e.loadSettings),ae=Os(e=>e.setDisplayMode),{isMobile:W}=Za(),oe=fa().data??null,G=gs(e=>e.setStatus),se=Q.useRef(null),[ce,le]=Q.useState(()=>typeof window>`u`?!1:I()),ue=Q.useMemo(()=>P(),[]),de=ce&&A()===`win32`,fe=Xa(),pe=Ol(),me=Q.useMemo(()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),[]),{usesFramelessChrome:he,side:ge}=zs(),_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(I())},[]);let ve=S(),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=Mn(E??``,be,xe),Ce=T?null:Se,[we,Te]=Q.useState(null),Ee=!E||D;(0,Q.useEffect)(()=>{if(!E){Te(e=>e===null?e:null);return}if(Ce){Te(e=>ju(e,Ce)?e:Ce);return}Ee&&Te(e=>e===null?e:null)},[Ce,E,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,Pe]=Q.useState(!1),[K,Fe]=Q.useState(!1),[Ie,Le]=Q.useState(!1),[Re,ze]=Q.useState(`Local`),[Be,Ve]=Q.useState(!1),[He,We]=Q.useState(ce?`instance`:`usage`),[Ge,Ke]=Q.useState(`usage`);(0,Q.useEffect)(()=>{!ce&&He===`instance`&&We(`usage`)},[He,ce]);let Je=Q.useMemo(()=>F(),[]),Ye=!Je&&v===`chat`&&!!we,Xe=we&&we.contextLimit>0?Math.min(999,we.totalTokens/we.contextLimit*100):0,Ze=vt(async()=>{if(!(typeof window>`u`||!ce))try{if(k()){ze(`Local`),Ve(!1);return}let e=l(),t=await H();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?V(n,te(e)):!1);if(m()!==n)return;if(Ve(!!n),a?.label?.trim()){ze(B(a.label.trim()));return}ze(`Instance`)}catch{ze(`Local`),Ve(!1)}});(0,Q.useEffect)(()=>{Ze()},[ce]),vs();let Qe=Os(e=>e.selectedModels),$e=Os(e=>e.expandedFamilies),et=Os(e=>e.toggleFamilyExpanded),tt=Q.useMemo(()=>{let e=[];for(let t of _s(N)){if(!U.includes(t.id))continue;let n=N.find(e=>e?.providerId===t.id),r=n?.usage?.windows??{},i=n?.usage?.models,o=Hs(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=Qe[t.id]??[],n=e.length>0,r=ys(i,t.id),o=ws(t.id),c=Ns(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,N,Qe,a]),nt=tt.length>0;Q.useEffect(()=>{ie()},[ie]);let rt=Q.useCallback(async e=>{ae(e);try{await qe({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([L(),e]).finally(()=>{Le(!1)})},[L,Ie]),ot=zn(e=>E?e.worktreeMetadata.get(E)?.path??``:``),st=Q.useMemo(()=>Nu(ot||``),[ot]),ct=Q.useMemo(()=>Nu((typeof O?.directory==`string`?O.directory:``)||``),[O?.directory]),lt=zn(e=>e.newSessionDraft?.open?Nu(e.newSessionDraft.bootstrapPendingDirectory??e.newSessionDraft.directoryOverride??``):``),ut=Q.useMemo(()=>st||ct||lt,[lt,ct,st]),dt=Io(),ft=Q.useMemo(()=>Nu(dt||ut||j?.path||``),[j?.path,dt,ut]),pt=q(e=>Ue(e,ft)),mt=!!pt?.isOpen,ht=vt(()=>d(ft)),gt=Q.useMemo(()=>{if(!E)return M??`Yuri`;let e=O?.title?.trim();return e&&e.length>0?e:`Untitled Session`},[M,O?.title,E]),_t=Q.useMemo(()=>Nu(ut||j?.path||``),[j?.path,ut]),yt=Q.useMemo(()=>j?{id:j.id,path:j.path}:null,[j]),bt=Q.useRef(null);Q.useEffect(()=>{!yt||!_t||(bt.current={projectRef:yt,directory:_t})},[_t,yt]);let xt=Q.useMemo(()=>yt&&_t?{projectRef:yt,directory:_t}:bt.current,[_t,yt]),St=Q.useCallback(async e=>{if(!(!e||je)){Me(!0);try{let t=w.github?await w.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,w.github,G]),wt=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()},[]),Et=Q.useCallback(()=>{if(W){wt(),o(!De);return}s()},[wt,W,De,o,s]),Dt=Q.useCallback(()=>{ee(`desktop_open_draft_mini_chat_window`,{directory:Nu(ut||j?.path||``),projectId:j?.id??null,apiBaseUrl:m(),clientToken:t()}).catch(e=>{console.warn(`[header] failed to open draft mini chat window`,e)})},[j?.id,j?.path,ut]),Ot=Q.useCallback(()=>{if(T){Dt();return}E&&ee(`desktop_open_session_mini_chat_window`,{sessionId:E,directory:Nu(ut||j?.path||``),apiBaseUrl:m(),clientToken:t()}).catch(e=>{console.warn(`[header] failed to open session mini chat window`,e)})},[j?.path,E,Dt,T,ut]),kt=Q.useCallback(()=>{let e=ft;if(e){if(Pu(pt)===`context`){_(e);return}p(e)}},[_,ft,pt,p]),At=Q.useMemo(()=>ft?Pu(pt)===`context`:!1,[ft,pt]),jt=Q.useCallback(()=>{let e=ft;if(e){if(Pu(pt)===`browser`){_(e);return}g(e)}},[_,ft,pt,g]),Mt=Q.useMemo(()=>ft?Pu(pt)===`browser`:!1,[ft,pt]),Nt=Eu,Y=Du,Pt=Q.useMemo(()=>Ne?`services`:r?`sessions`:i?`git`:v,[v,Ne,r,i]),Ft=Q.useCallback(()=>{Pe(!1),r&&e&&e(),i&&n&&n(),!e&&De&&o(!1)},[De,r,e,n,i,o]),It=Q.useCallback(()=>{r||Pe(!1),e?.()},[r,e]),Lt=Q.useCallback(()=>{i||Pe(!1),n?.()},[n,i]),Rt=Q.useMemo(()=>ce&&me&&!pe?`5.5rem`:fe?`max(calc(0.75rem + var(--yuri-wco-left-inset, 0px)), 5.5rem)`:(!ce||he)&&!Je?`calc(0.75rem + var(--yuri-wco-left-inset, 0px))`:`0.75rem`,[ce,pe,me,fe,Je,he]);(0,Q.useEffect)(()=>{typeof document>`u`||document.documentElement.style.setProperty(`--yuri-titlebar-left-inset`,Rt)},[Rt]);let zt=c?`0.75rem`:`var(--yuri-titlebar-left-inset, 0.75rem)`,Bt=c?`0px`:`calc(var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`,Vt=Q.useMemo(()=>!ce||!me||_e===null?``:_e>=26?`h-12`:_e<=15?`h-14`:``,[ce,me,_e]),Ht=Q.useMemo(()=>{if(!(ce&&!he||Je))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,Je,mt,he]),Ut=Q.useCallback(()=>{if(typeof document>`u`)return;let e=se.current?.getBoundingClientRect().height;e&&document.documentElement.style.setProperty(`--yuri-header-height`,`${e}px`)},[]);(0,Q.useEffect)(()=>{if(typeof window>`u`)return;Ut();let e=se.current;if(!e||typeof ResizeObserver>`u`)return()=>{};let t=0,n=()=>{t||=requestAnimationFrame(()=>{t=0,Ut()})},r=new ResizeObserver(n);return r.observe(e),window.addEventListener(`resize`,n),window.addEventListener(`orientationchange`,n),()=>{t&&cancelAnimationFrame(t),r.disconnect(),window.removeEventListener(`resize`,n),window.removeEventListener(`orientationchange`,n)}},[Ut]),(0,Q.useEffect)(()=>{Ut()},[Ut,W,Vt]);let Wt=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 C()},[ce]),Gt=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]),Kt=Q.useCallback(e=>Ta(Na(e,b)),[b]);(0,Q.useEffect)(()=>{!W&&(v===`git`||v===`terminal`||v===`diff`||v===`files`)&&y(`chat`)},[v,W,y]);let qt=Q.useMemo(()=>{let e=[];return ce&&e.push({value:`instance`,label:a(`layout.services.instance`),icon:(0,$.jsx)(Z,{name:`server`,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(()=>qt.map(e=>({id:e.value,label:e.label,icon:e.icon})),[qt]),Xt=Q.useMemo(()=>[{value:`usage`,label:a(`header.services.used`)},{value:`remaining`,label:a(`header.services.remaining`)}],[a]),Zt=Q.useMemo(()=>Xt.map(e=>({id:e.value,label:e.label})),[Xt]),Qt=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(Ct(e)&&!e.shiftKey&&!e.altKey){let t=parseInt(e.key,10);t>=1&&t<=Gt.length&&(e.preventDefault(),W&&(wt(),Ft()),y(Gt[t-1].id))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[wt,Ft,W,y,Gt]);let $t=vt(e=>{We(e),Fe(!0),Ze(),e===`usage`&&z===null&&L()});(0,Q.useEffect)(()=>{let e=e=>{let t=Na(`toggle_services_menu`,b);if(Ha(e,t)){e.preventDefault();let t=Tu({isOpen:K,activeTab:He,targetTab:ce?`instance`:`usage`});t.open?$t(t.tab):Fe(!1);return}let n=Na(`cycle_services_tab`,b);if(Ha(e,n)){e.preventDefault();let t=qt.map(e=>e.value);if(t.length===0)return;let n=t.indexOf(He),r=t[n===-1?0:(n+1)%t.length];We(r),Fe(!0),Ze(),r===`usage`&&z===null&&L();return}let r=Na(`open_usage`,b);if(Ha(e,r)){e.preventDefault();let t=Tu({isOpen:K,activeTab:He,targetTab:`usage`});t.open?$t(t.tab):Fe(!1);return}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[b,ce,K,He,qt,z,L,Ze,$t]);let en=e=>{let t=v===e.id,n=e.icon===`diff`,r=n?null:e.icon,i=e.id===`chat`,a=e=>n?(0,$.jsx)(Sl,{size:e}):r?(0,$.jsx)(Z,{name:r,className:`h-${e/4} w-${e/4}`}):null,o=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>y(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)},tn=ue&&(T||!!E),nn=Q.useCallback(e=>{window.setTimeout(e,0)},[]),rn=Q.useCallback(e=>{$t(e)},[$t]),X=Q.useRef(null),an=(0,$.jsxs)(`div`,{className:`relative flex shrink-0 items-center`,children:[(0,$.jsx)(`div`,{ref:X,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center`,children:(0,$.jsxs)(Ba,{children:[(0,$.jsxs)(ca,{children:[(0,$.jsx)(aa,{asChild:!0,children:(0,$.jsx)(Sa,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":a(`header.actions.sessionMenuAria`),className:J(Nt,`text-muted-foreground`),children:(0,$.jsx)(Z,{name:`more-2`,className:`h-[18px] w-[18px]`})})})}),(0,$.jsx)(oa,{children:(0,$.jsx)(`p`,{children:a(`header.actions.sessionMenu`)})})]}),(0,$.jsxs)(Pa,{align:`start`,className:`min-w-[14rem]`,children:[tn?(0,$.jsxs)(La,{className:`flex items-center gap-2`,onClick:()=>nn(Ot),children:[(0,$.jsx)(Z,{name:`picture-in-picture-2`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:a(T?`header.actions.newMiniChat`:`header.actions.openSessionMiniChat`)})]}):null,ce?(0,$.jsxs)(La,{className:`flex items-center gap-2`,onClick:()=>nn(()=>rn(`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:Kt(`toggle_services_menu`)})]}):null,(0,$.jsxs)(La,{className:`flex items-center gap-2`,onClick:()=>nn(()=>rn(`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:Kt(`open_usage`)})]}),(0,$.jsx)(za,{}),(0,$.jsxs)(La,{className:`flex items-center gap-2`,onClick:()=>nn(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:Kt(`toggle_terminal`)})]}),(0,$.jsxs)(La,{className:`flex items-center gap-2`,onClick:()=>nn(jt),children:[(0,$.jsx)(Z,{name:`global`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:a(`contextPanel.browser.open`)}),Mt?(0,$.jsx)(Z,{name:`check`,className:`h-3.5 w-3.5 text-foreground`}):null]})]})]})}),(0,$.jsx)(Au,{isDesktopApp:ce,currentInstanceSupportsUpdate:Be,isDesktopServicesOpen:K,setIsDesktopServicesOpen:Fe,refreshCurrentInstanceLabel:Ze,desktopServicesTab:He,setDesktopServicesTab:We,fetchAllQuotas:L,servicesTabItems:Yt,quotaLastUpdated:z,quotaDisplayMode:ne,showPredValues:re,quotaDisplayTabItems:Zt,handleDisplayModeChange:rt,handleUsageRefresh:it,isQuotaLoading:R,isUsageRefreshSpinning:Ie,hasRateLimits:nt,rateLimitGroups:tt,expandedFamilies:$e,toggleFamilyExpanded:et,timeFormatPreference:x,anchorRef:X})]}),on=(0,$.jsxs)($.Fragment,{children:[!W&&!Je&&v===`chat`?(0,$.jsx)(jl,{}):null,(0,$.jsx)(au,{directory:_t}),(0,$.jsx)(Ou,{title:a(`header.actions.rightSidebarWithShortcut`,{shortcut:Kt(`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)(ku,{isMobile:W,githubAuthStatus:oe,githubAccounts:Ae,githubAvatarUrl:Oe,githubLogin:ke,isSwitchingGitHubAccount:je,handleGitHubAccountSwitch:St})]}),sn=()=>(0,$.jsxs)(`div`,{onMouseDown:Wt,className:J(`app-region-drag relative flex h-12 select-none items-center pr-3`,Vt),style:Ht,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:zt}}),(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:Bt}}),(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)(Rs,{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:T?a(`sessions.switcher.draftTitle`):gt})})})}),Gt.length>0&&(0,$.jsx)(`div`,{className:`flex items-center gap-1 rounded-lg bg-[var(--surface-muted)]/50 p-1`,children:Gt.map(e=>en(e))}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[an,Ye&&we?(0,$.jsx)(Is,{pending:we.pending,totalTokens:we.totalTokens,percentage:Xe,colorPercentage:we.percentage,contextLimit:we.contextLimit,outputLimit:we.outputLimit??0,size:`compact`,appearance:`subtle`,onClick:kt,pressed:At}):null,on,(0,$.jsx)(Ls,{visible:he&&ge===`right`&&!mt,position:`right`})]})]})]}),cn=()=>(0,$.jsxs)(`div`,{className:`app-region-drag relative flex items-center gap-2 px-3 py-2 select-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e?(0,$.jsx)(`button`,{type:`button`,onClick:It,className:J(Y,Pt===`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:Et,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:Gt.map(e=>{let t=v===e.id,n=e.icon===`diff`,r=n?null:e.icon;return(0,$.jsxs)(ca,{children:[(0,$.jsx)(aa,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{W&&(wt(),Ft()),y(e.id)},"aria-label":e.label,"aria-selected":t,role:`tab`,className:J(Y,`relative rounded-lg`,Pt===e.id&&`bg-interactive-selection text-interactive-selection-foreground`),children:[n?(0,$.jsx)(Sl,{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)(oa,{children:(0,$.jsx)(`p`,{children:e.label})})]},e.id)})})})})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(Ts,{mobile:!0}),xt&&(0,$.jsx)(wu,{projectRef:xt.projectRef,directory:xt.directory,compact:!0,allowMobile:!0,className:`h-9`}),(0,$.jsxs)(Ba,{open:Ne,onOpenChange:t=>{t&&(r&&e&&e(),i&&n&&n()),Pe(t),t&&z===null&&L()},children:[(0,$.jsxs)(ca,{children:[(0,$.jsx)(aa,{asChild:!0,children:(0,$.jsx)(Sa,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":a(`header.services.viewAria`),className:J(Y,Pt===`services`&&`bg-interactive-selection text-interactive-selection-foreground`),children:(0,$.jsx)(Z,{name:`stack`,className:`h-5 w-5`})})})}),(0,$.jsx)(oa,{children:(0,$.jsx)(`p`,{children:a(`header.services.title`)})})]}),(0,$.jsx)(Pa,{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)(rs,{items:Qt,activeId:Ge,onSelect:e=>{let t=e;Ke(t),t===`usage`&&z===null&&L()},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:()=>Pe(!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`})})]})}),Ge===`mcp`&&(0,$.jsx)(Gc,{active:Ne&&Ge===`mcp`}),Ge===`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:Mu(z,x)})]}),(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`,ne===`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`,ne===`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:R||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:tt.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)(ao,{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=Qs(e.entries,r),a=ne===`remaining`?n.remainingPercent:n.usedPercent,o=n.disablePace?null:ma(n.usedPercent,n.resetAt,n.windowSeconds,t),s=o?.dailyAllocationPercent==null?null:ne===`remaining`?100-ua(o.elapsedRatio):ua(o.elapsedRatio),c=ja(n.valueLabel,a),l=la(n.resetAt,n.resetAfterFormatted??n.resetAtFormatted,x);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:pa(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)(Ms,{percent:a,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:s}),o&&re?(0,$.jsx)(Ss,{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=($e[e.providerId]??[]).includes(t.familyId??`other`);return(0,$.jsxs)(nl,{open:n,onOpenChange:()=>et(e.providerId,t.familyId??`other`),children:[(0,$.jsxs)(tl,{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)(el,{children:(0,$.jsx)(`div`,{className:`space-y-2.5 pb-1 pl-1 pt-1`,children:t.models.map(([t,n])=>{let r=ne===`remaining`?n.remainingPercent:n.usedPercent,i=ma(n.usedPercent,n.resetAt,n.windowSeconds),a=i?.dailyAllocationPercent==null?null:ne===`remaining`?100-ua(i.elapsedRatio):ua(i.elapsedRatio),o=ja(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:bs(t)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground tabular-nums`,children:o===`-`?``:o})]}),(0,$.jsx)(Ms,{percent:r,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:a}),i&&re?(0,$.jsx)(Ss,{paceInfo:i,compact:!0}):null]},`${e.providerId}-${t}`)})})})]},t.familyId??`other`)})})]})]},e.providerId))})]})]})})]}),n?(0,$.jsxs)(ca,{children:[(0,$.jsx)(aa,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:Lt,className:J(Y,`relative`,Pt===`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)(oa,{children:(0,$.jsx)(`p`,{children:i?`Close git sidebar`:`Open git sidebar`})})]}):null]})]})]}),ln=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:ln,style:{"--padding-scale":`1`},children:W?cn():sn()})})};function Iu(){}var Lu=180,Ru=640,zu=110,Bu=e=>{let t=(0,xl.c)(44),{isOpen:n,isMobile:r,children:i}=e,{t:a}=Tt(),o=q(Vu),s=q(Hu),c=q(Uu),l=q(Wu),[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(Ru,Math.max(Lu,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(Ru,Math.max(Lu,g.current+t));c(n)},t=()=>{p(!1),q.getState().bottomTerminalHeight<=zu&&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 ee=!n&&`pointer-events-none select-none opacity-0`,F;t[32]===ee?F=t[33]:(F=J(`relative z-10 flex h-full min-h-0 w-full flex-col transition-opacity duration-300 ease-in-out`,ee),t[32]=ee,t[33]=F);let I=!n,L;t[34]!==i||t[35]!==F||t[36]!==I?(L=(0,$.jsx)(`div`,{className:F,"aria-hidden":I,children:i}),t[34]=i,t[35]=F,t[36]=I,t[37]=L):L=t[37];let R;return t[38]!==j||t[39]!==M||t[40]!==N||t[41]!==P||t[42]!==L?(R=(0,$.jsxs)(`section`,{ref:m,className:j,style:M,"aria-hidden":N,children:[P,L]}),t[38]=j,t[39]=M,t[40]=N,t[41]=P,t[42]=L,t[43]=R):R=t[43],R};function Vu(e){return e.bottomTerminalHeight}function Hu(e){return e.isBottomTerminalExpanded}function Uu(e){return e.setBottomTerminalHeight}function Wu(e){return e.setBottomTerminalOpen}var Gu=260,Ku=260,qu=500,Ju=({isOpen:e,isMobile:t,children:n,className:r,topBar:i})=>{let{t:a}=Tt(),o=q(e=>e.sidebarWidth),s=q(e=>e.setSidebarWidth),[c,l]=Q.useState(!1),u=Q.useRef(0),d=Q.useRef(o||Gu),f=Q.useRef(null),p=Q.useRef(null),m=Q.useRef(null),h=Q.useCallback(e=>Math.min(qu,Math.max(Ku,e)),[]),g=Q.useCallback(e=>{let t=m.current;t&&(t.style.width=`${e}px`,t.style.minWidth=`${e}px`,t.style.maxWidth=`${e}px`,t.style.setProperty(`--yuri-left-sidebar-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(qu,Math.max(Ku,o||Gu)),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=h(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=h(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`,"--yuri-left-sidebar-width":`${c?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`,{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:`var(--yuri-left-sidebar-width)`,overflowX:`hidden`},"aria-hidden":!e,children:[i,(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,$.jsx)(Ka,{children:n})})]})]})},Yu=()=>{let e=(0,xl.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},Xu=e=>{let t=(0,xl.c)(14),{className:n}=e,r=Es(Zu).trim(),i=r.split(/\s+/).filter(Boolean),a=i.includes(`Yuri`),o=i.some(Qu);if(Q.useEffect(()=>{o&&ki()},[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)(Ya,{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)(bc,{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 Zu(e){return e.sidebarBrandName}function Qu(e){return e!==`Yuri`}var $u=`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`,ed=()=>{let e=(0,xl.c)(48),{t}=Tt(),n=q(td),r=q(nd),i=q(rd),a=q(id),o=Es(ad),s=Q.useRef(null),c=Ta(Na(`toggle_sidebar`,a)),{usesFramelessChrome:l,side:u}=zs(),d;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=I(),e[0]=d):d=e[0];let f=d,p=Ol(),m=!f||p||!n||!o,h;e[1]===p?h=e[2]:(h=!F()&&(f?p:S()),e[1]=p,e[2]=h);let g=h,_=sd,v,y;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>{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()}},y=[],e[3]=v,e[4]=y):(v=e[3],y=e[4]),Q.useEffect(v,y);let b=g&&n?`${r||260}px`:void 0,x;e[5]===b?x=e[6]:(x={height:`var(--yuri-header-height, 3rem)`,paddingLeft:`var(--yuri-titlebar-left-inset, 0.75rem)`,width:b},e[5]=b,e[6]=x);let C=g&&n&&`w-full justify-between`,w;e[7]===C?w=e[8]:(w=J(`flex items-center gap-2`,C),e[7]=C,e[8]=w);let T;e[9]!==n||e[10]!==g?(T=g&&n?(0,$.jsx)(Xu,{className:`flex min-w-0 items-center p-0 pl-1.5`}):null,e[9]=n,e[10]=g,e[11]=T):T=e[11];let E;e[12]!==l||e[13]!==u?(E=l&&u===`left`?(0,$.jsx)(Ls,{visible:!0,position:`left`}):null,e[12]=l,e[13]=u,e[14]=E):E=e[14];let D;e[15]!==t||e[16]!==l?(D=l?(0,$.jsxs)(ca,{children:[(0,$.jsx)(aa,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:_,"aria-label":t(`header.actions.openAppMenuAria`),className:J($u,`shrink-0`),children:(0,$.jsx)(Z,{name:`menu-2`,className:`h-[18px] w-[18px]`})})}),(0,$.jsx)(oa,{children:(0,$.jsx)(`p`,{children:t(`header.actions.openAppMenu`)})})]}):null,e[15]=t,e[16]=l,e[17]=D):D=e[17];let O;e[18]===m?O=e[19]:(O=m?(0,$.jsx)(Ec,{}):null,e[18]=m,e[19]=O);let k=ca,A;e[20]===t?A=e[21]:(A=t(`header.actions.openSessionsAria`),e[20]=t,e[21]=A);let j,M;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(j=J($u,`group shrink-0`),M=(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]=j,e[23]=M):(j=e[22],M=e[23]);let N;e[24]!==A||e[25]!==i?(N=(0,$.jsx)(aa,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:i,"aria-label":A,className:j,children:M})}),e[24]=A,e[25]=i,e[26]=N):N=e[26];let P=oa,ee=t(`header.actions.openSessionsWithShortcut`,{shortcut:c}),L;e[27]===ee?L=e[28]:(L=(0,$.jsx)(`p`,{children:ee}),e[27]=ee,e[28]=L);let R;e[29]!==P||e[30]!==L?(R=(0,$.jsx)(P,{children:L}),e[29]=P,e[30]=L,e[31]=R):R=e[31];let z;e[32]!==k||e[33]!==N||e[34]!==R?(z=(0,$.jsxs)(k,{children:[N,R]}),e[32]=k,e[33]=N,e[34]=R,e[35]=z):z=e[35];let B;e[36]!==O||e[37]!==z?(B=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[O,z]}),e[36]=O,e[37]=z,e[38]=B):B=e[38];let V;e[39]!==E||e[40]!==D||e[41]!==B||e[42]!==w||e[43]!==T?(V=(0,$.jsxs)(`div`,{ref:s,className:w,children:[T,E,D,B]}),e[39]=E,e[40]=D,e[41]=B,e[42]=w,e[43]=T,e[44]=V):V=e[44];let H;return e[45]!==V||e[46]!==x?(H=(0,$.jsx)(`div`,{className:`app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2`,style:x,children:V}),e[45]=V,e[46]=x,e[47]=H):H=e[47],H};function td(e){return e.isSidebarOpen}function nd(e){return e.sidebarWidth}function rd(e){return e.toggleSidebar}function id(e){return e.shortcutOverrides}function ad(e){return e.sidebarBrandName.trim().length>0}function od(e){console.warn(`[titlebar] failed to open app menu`,e)}function sd(e){let t=e.currentTarget.getBoundingClientRect();ee(`desktop_show_app_menu`,{x:t.left,y:t.bottom}).catch(od)}function cd(e){let t=(0,xl.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 ld=(e,t)=>{let n=lt(t,e);return!n||n===`.`||n===t?0:n.split(`/`).filter(Boolean).length},ud=(e,t,n=10)=>{let r=ct(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=ct(t.path);if(!e||i.has(e))continue;let o=ld(r,e);o<1||o>n||(i.add(e),a.push(e))}return a},dd=e=>e.some(e=>!!ct(e)),fd=(e,t)=>{let n=new Set(t.map(e=>ct(e)).filter(Boolean));return e.filter(e=>!n.has(e))},pd=(e,t,n)=>t.length===0?e.length===0:fd(e,t).length>0?!1:t.every(e=>n.has(ct(e))),md=Do(()=>ut(()=>import(`./ToolOutputDialog-Bdwio4o_.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]))),hd=e=>{let t=vd(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},gd=e=>{let t=(0,xl.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},_d=e=>e.slice().sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1),vd=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},yd=e=>e.startsWith(`/`)||e.startsWith(`//`)||/^[A-Za-z]:\//.test(e),bd=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,xd=(e,t)=>{let n=vd(t),r=vd(e);if(!n||!r)return!1;let i=bd(n),a=bd(r);return a===i||a.startsWith(`${i}/`)},Sd=(e,t)=>{let n=vd(t),r=vd(e);if(!xd(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},Cd=(e,t)=>{if(!t)return``;let n=vd(t);if(!e||!xd(n,e))return n;let r=n.slice(e.length);return r.startsWith(`/`)?r.slice(1):r},wd=new Set([`node_modules`]),Td=e=>{let t=(0,xl.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},Ed=e=>{let t=(0,xl.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},Dd=e=>wd.has(e),Od=e=>{let t=vd(e);return t===`node_modules`||t.endsWith(`/node_modules`)||t.includes(`/node_modules/`)},kd=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`is a directory`)||t.includes(`eisdir`)},Ad=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`)},jd=2e5,Md=`yuri:files:auto-save-enabled`,Nd=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-COWWhGPD.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-auth-DBn9yahL.js","assets/runtime-switch-DEZ1K7qW.js","assets/runtime-fetch-D0YWp3FJ.js","assets/desktop-JwYqThiw.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-base-ui-CzHs0bHY.js","assets/useUIStore-BDZCXouA.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-B2psfNaU.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/runtime-file-resource-qB_oVdE6.js","assets/queryRuntime-CTcigFdj.js","assets/fileQueries-DWj9yB2g.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-o29morT6.js","assets/platform-DFJEtBlo.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-BF2cNEuq.js","assets/store-BPYoxYhv.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-CLLDJn-P.js","assets/dialog-r7RRePv5.js","assets/dialog-CTYD3Sbr.css","assets/tap-LkQum5bB.js","assets/themes-BgDJcxRc.js","assets/MobileWindowStack-DGLdgoGr.js","assets/appThemeRegistry-CPa7wDcf.js","assets/useMobileNavigationStore-9lAGHZos.js","assets/gitApiHttp-DGAlAuET.js","assets/vendor-opencode-client-cQ47ywrT.js","assets/vendor-effect-X1Hqc7ba.js","assets/persistence-Dta0OwIa.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-sonner-BEHGipm5.js","assets/useAssistantUIStore-CYyXdd5c.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/agentColors-DWSbQXy2.js","assets/rasterizePng-056Poix7.js","assets/MarkdownRenderer-DZXM92vp.js","assets/useEffectiveDirectory-esZ8PL08.js","assets/markdownHeightCache-D02GlOiy.js","assets/dualLimitLru-D8Sphgua.js","assets/toolHelpers-iEHVHQ9p.js","assets/image-loading-BUouaouB.js","assets/image-loading-D9Z_BASK.css","assets/ImageLoadingPlaceholder-DTWzB26a.js","assets/useWorkerHighlightedLines-BxqdOw1S.js","assets/markdownTheme-CHNl6tUv.js","assets/markdown-worker-oBGEB9Eg.js","assets/vendor-tanstack-react-virtual-DSFNK3qc.js","assets/mobileBackNavigation-CXfKEN3p.js","assets/touch-gestures-CErgaXZ7.js","assets/ToolOutputDialog-CbGuK5bP.css","assets/TerminalView-2DhtuWTv.js","assets/terminalApi-CPVNQ5DH.js","assets/vendor-ghostty-web-DbBrwBII.js","assets/device-DN1GigI_.js","assets/OverlayScrollbar-CzQC0JQI.js","assets/sortable-tabs-strip-Dc4Jr4ml.js","assets/vendor-dnd-kit-core-DK4OoOTr.js","assets/vendor-dnd-kit-accessibility-BOtnpZt5.js","assets/vendor-dnd-kit-sortable-Cv69eQm1.js","assets/useFontPreferences-UzjDmx4b.js","assets/projectActions-BX0cjZoq.js","assets/DiagramView-DCrAY37j.js","assets/diagram-D9-jif9d.js","assets/vendor-react-drawio-Dyg1-39Q.js","assets/SettingsView-C1dLufb0.js","assets/desktopHosts-CB0CTcMg.js","assets/desktopRelayRestore-C7pjf6fE.js","assets/types-CTkS0uZU.js","assets/native-config-BHa0LfdJ.js","assets/vendor-codemirror-autocomplete-C0FrlFqZ.js","assets/MobileShareBridge-yWj21Mpo.js","assets/MobileDetailNavigation-CozkWJ5y.js","assets/AgentAvatar-GVufO03R.js","assets/vendor-dicebear-core-CV95S5Pg.js","assets/vendor-dicebear-styles-C4OfoX7R.js","assets/gitApi-CXkfrI_H.js","assets/input-DvF_mp0Y.js","assets/tooltip-BoAbDVNP.js","assets/speechSettingsQueries-CsCKPsRU.js","assets/vendor-simplewebauthn-browser-Dwhcdg_5.js","assets/MobileResizableSheet-CAj4YGtu.js","assets/projectMeta-D3GYq5jV.js","assets/textarea-CIhiRPB2.js","assets/dropdown-menu.styles-CX8oXdks.js","assets/YuriLogo-BZC0ckt0.js","assets/scheduledTaskNavigation-BqkeRfVc.js","assets/url-MRa-FtQa.js","assets/react-Bwr5-XPi.js","assets/MobileTabPageHeader-BSbOGw3M.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-Ls770ehB.js","assets/collapsible-CS5qCQRU.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-C6l4ycZG.js","assets/vendor-qrcode-D7jBCyl-.js","assets/vendor-dijkstrajs-BAzPDGZM.js","assets/readiness-lO-fOlzd.js","assets/GuiPluginWindow-CW0-Tapi.js","assets/vendor-yaml-C9KlJAlj.js","assets/SettingsView-C0HSdVvS.css","assets/SettingsWindow-DZFZJ8PI.js","assets/MultiRunWindow-BDh7FxgY.js","assets/multirun-CicU-KQt.js","assets/insertionBoundaries-CmxtGojv.js","assets/fileMentionAutocompleteState-BZJqfgae.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/vendor-fuzzysort-ukaRp9PC.js","assets/fileMentionTouchSelection-dpFpcetU.js","assets/AssistantView-YVdgtBeh.js","assets/sessionLookup-qvz-n65R.js","assets/LoadingImage-B89ghYMH.js","assets/sessionLookup-8C8nv-EP.css","assets/AssistantContactStatus-B67HXRUY.js","assets/vendor-motion-C9oiAdx-.js","assets/assistant-attachment-cache-DMw2Smc8.js","assets/AssistantUnreadBadge-Xz7kMLSv.js","assets/OnboardingScreen-BdU6Tyax.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,C as _,I as v,J as y,O as b,R as x,T as S,W as C,X as w,Y as T,Z as E,_ as D,a as O,b as k,g as A,j,k as M,q as N,t as P,v as ee,w as F,x as I,z as L}from"./desktop-JwYqThiw.js";import{n as R,t as z}from"./runtimeAPIRegistry-C2VogTny.js";import{g as B,p as V,r as H,u as te}from"./desktopHosts-CB0CTcMg.js";import{a as ne,i as re,t as U}from"./vendor-zustand-vDaAPGfl.js";import{A as ie,B as ae,L as W,M as oe,R as G,a as se,at as ce,d as le,f as ue,g as de,h as fe,i as pe,k as me,m as he,ot as ge,p as _e,st as ve,z as ye}from"./vendor-base-ui-CzHs0bHY.js";import{At as be,Ct as xe,Er as Se,In as Ce,Kn as we,Or as Te,Rn as Ee,St as De,_r as Oe,br as ke,bt as Ae,fn as je,gr as Me,kr as Ne,kt as Pe,mn as K,wt as Fe,xt as Ie,yr as Le,yt as Re,zn as ze}from"./gitApiHttp-DGAlAuET.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{C as Be,S as Ve,i as He,r as q,t as Ue,x as We}from"./useUIStore-BDZCXouA.js";import{D as Ge,O as Ke,i as qe,jt as Je,ot as Ye,r as Xe,t as Ze}from"./persistence-Dta0OwIa.js";import{n as Qe,t as $e}from"./vendor-react-DlzBev0S.js";import{c as et}from"./vendor-tanstack-query-core-BWz0ose6.js";import{n as tt,o as nt,s as rt}from"./vendor-tanstack-react-query-B2psfNaU.js";import{d as it,u as at}from"./fileQueries-DWj9yB2g.js";import{r as ot,s as st}from"./runtime-file-resource-qB_oVdE6.js";import{a as ct,n as lt}from"./path-utils-jGozTg9d.js";import{o as ut}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as dt}from"./pathNormalization-ewtPqJWn.js";import{n as ft}from"./terminalApi-CPVNQ5DH.js";import{a as pt}from"./types-CTkS0uZU.js";/* empty css */import{U as mt}from"./vendor-codemirror-autocomplete-C0FrlFqZ.js";import{a as ht}from"./vendor-pierre-diffs-BFiZ3IhI.js";import{a as gt,h as _t,i as vt,m as yt,t as bt}from"./vendor-reactuses-core-DWo5Wn6R.js";import{_ as xt,a as St,c as Ct,d as wt,f as Tt,g as Et,h as Dt,i as Ot,l as kt,m as At,o as jt,p as Mt,r as J,s as Nt,t as Y}from"./button-BF2cNEuq.js";import{n as Pt}from"./store-BPYoxYhv.js";import{S as Ft,b as It,h as Lt}from"./MobileDetailNavigation-CozkWJ5y.js";import{Br as Rt,C as zt,Ca as Bt,Cr as Vt,Ct as Ht,Dr as Ut,E as Wt,Ea as Gt,Fr as Kt,Ft as qt,G as Jt,Gr as Yt,Hr as Xt,Jr as Zt,K as Qt,Kt as $t,Mn as en,N as tn,P as nn,Qn as rn,Qr as X,R as an,Ri as on,S as sn,Sa as cn,Si as ln,St as un,T as dn,Ur as fn,V as pn,Wr as mn,Xr as hn,Zr as gn,_ as _n,_t as vn,ar as yn,ba as bn,cr as xn,ct as Sn,dr as Cn,dt as wn,fa as Tn,fr as En,g as Dn,gt as On,h as kn,ht as An,ir as jn,it as Mn,jn as Nn,kn as Pn,lr as Fn,lt as In,m as Ln,nr as Rn,p as zn,pt as Bn,q as Vn,qr as Hn,qt as Un,ri as Wn,rn as Gn,rt as Kn,tr as qn,ut as Jn,w as Yn,wa as Xn,wi as Zn,xr as Qn,xt as $n,y as er,z as tr}from"./useMobileNavigationStore-9lAGHZos.js";import{n as nr}from"./useAssistantUIStore-CYyXdd5c.js";import{n as rr}from"./useThemeSystem-CNzUUkFn.js";import{n as ir,o as ar}from"./vendor-framer-motion-DDMKlXiP.js";import{n as Z,t as or}from"./Icon-CLLDJn-P.js";import{a as sr,i as cr,n as lr,o as ur,r as dr,t as fr}from"./dialog-r7RRePv5.js";import{A as pr,C as mr,D as hr,O as gr,P as _r,T as vr,V as yr,a as br,f as xr,h as Sr,i as Cr,j as wr,k as Tr,m as Er,o as Dr,p as Or,r as kr,t as Ar,w as jr,y as Mr}from"./gitApi-CXkfrI_H.js";import{$ as Nr,A as Pr,At as Fr,B as Ir,Ct as Lr,D as Rr,Dt as zr,Et as Br,Ft as Vr,H as Hr,I as Ur,J as Wr,Lt as Gr,M as Kr,Mt as qr,N as Jr,Nt as Yr,O as Xr,Ot as Zr,P as Qr,Pt as $r,Rt as ei,S as ti,St as ni,Tt as ri,V as ii,Z as ai,_ as oi,_t as si,at as ci,b as li,bt as ui,c as di,ct as fi,d as pi,et as mi,f as hi,ft as gi,g as _i,gt as vi,h as yi,ht as bi,i as xi,it as Si,j as Ci,jt as wi,k as Ti,kt as Ei,l as Di,m as Oi,n as ki,nt as Ai,ot as ji,p as Mi,q as Ni,rt as Pi,s as Fi,st as Ii,t as Li,tt as Ri,u as zi,v as Bi,vt as Vi,w as Hi,wt as Ui,x as Wi,xt as Gi,y as Ki,yt as qi}from"./useAppFontEffects-Cs_0mUpl.js";import{D as Ji,E as Yi,_ as Xi,b as Zi,f as Qi,g as $i,h as ea,m as ta,v as na,y as ra}from"./insertionBoundaries-CmxtGojv.js";import{t as ia}from"./input-DvF_mp0Y.js";import{i as aa,n as oa,r as sa,t as ca}from"./tooltip-BoAbDVNP.js";import{A as la,D as ua,E as da,K as fa,N as pa,O as ma,R as ha,S as ga,St as _a,T as va,_ as ya,_t as ba,b as xa,ct as Sa,d as Ca,et as wa,ft as Ta,g as Ea,gt as Da,h as Oa,ht as ka,it as Aa,j as ja,l as Ma,mt as Na,nt as Pa,p as Fa,rn as Ia,rt as La,s as Ra,st as za,tt as Ba,u as Va,ut as Ha,v as Ua,w as Wa,x as Ga,xt as Ka,y as qa,z as Ja}from"./speechSettingsQueries-CsCKPsRU.js";import{t as Ya}from"./YuriLogo-BZC0ckt0.js";import{a as Xa,r as Za}from"./device-DN1GigI_.js";import{r as Qa}from"./themes-BgDJcxRc.js";import{f as $a,g as eo,h as to,p as no}from"./scheduledTaskNavigation-BqkeRfVc.js";import{a as ro,i as io}from"./sessionLookup-qvz-n65R.js";import{E as ao,O as oo,_ as so,a as co,b as lo,f as uo,h as fo,i as po,l as mo,m as ho,n as go,p as _o,s as vo,x as yo}from"./projectMeta-D3GYq5jV.js";import{n as bo,t as xo}from"./appThemeRegistry-CPa7wDcf.js";import{i as So,n as Co,r as wo,t as To}from"./dropdown-menu.styles-CX8oXdks.js";import{n as Eo,o as Do}from"./MarkdownRenderer-DZXM92vp.js";import{a as Oo}from"./url-MRa-FtQa.js";import{a as ko,c as Ao,i as jo,l as Mo,o as No,s as Po}from"./toolHelpers-iEHVHQ9p.js";import{i as Fo}from"./react-Bwr5-XPi.js";import{n as Io,t as Lo}from"./useEffectiveDirectory-esZ8PL08.js";import{t as Ro}from"./ImageLoadingPlaceholder-DTWzB26a.js";import{t as zo}from"./LoadingImage-B89ghYMH.js";import{_ as Bo,i as Vo,l as Ho,n as Uo,s as Wo,t as Go,v as Ko,y as qo}from"./vendor-dnd-kit-core-DK4OoOTr.js";import{a as Jo,n as Yo,o as Xo,s as Zo,t as Qo}from"./vendor-dnd-kit-sortable-Cv69eQm1.js";import{n as $o,r as es}from"./textarea-CIhiRPB2.js";import{h as ts}from"./useWorkerHighlightedLines-BxqdOw1S.js";import{t as ns}from"./vendor-tanstack-react-virtual-DSFNK3qc.js";import{t as rs}from"./sortable-tabs-strip-Dc4Jr4ml.js";import{t as is}from"./vendor-motion-C9oiAdx-.js";import{A as as,C as os,D as ss,E as cs,O as ls,S as us,T as ds,Z as fs,a as ps,at as ms,b as hs,c as gs,dt as _s,f as vs,g as ys,h as bs,k as xs,l as Ss,lt as Cs,m as ws,n as Ts,o as Es,ot as Ds,p as Os,r as ks,s as As,st as js,u as Ms,v as Ns,w as Ps,y as Fs}from"./MobileTabPageHeader-BSbOGw3M.js";import{i as Is,n as Ls,r as Rs,t as zs}from"./useDesktopWindowControlsLayout-avf-_JWZ.js";import{n as Bs}from"./useFontPreferences-UzjDmx4b.js";import{$ as Vs,A as Hs,C as Us,Ct as Ws,D as Gs,E as Ks,G as qs,J as Js,K as Ys,M as Xs,N as Zs,O as Qs,S as $s,St as ec,T as tc,W as nc,X as rc,Y as ic,Z as ac,_ as oc,_t as sc,a as cc,at as lc,b as uc,bt as dc,c as fc,ct as pc,d as mc,dt as hc,et as gc,f as _c,ft as vc,g as yc,gt as bc,h as xc,ht as Sc,i as Cc,it as wc,j as Tc,l as Ec,lt as Dc,mt as Oc,n as kc,o as Ac,p as jc,pt as Mc,q as Nc,r as Pc,rt as Fc,s as Ic,st as Lc,tt as Rc,u as zc,ut as Bc,v as Vc,vt as Hc,w as Uc,x as Wc,xt as Gc,y as Kc,yt as qc}from"./runtimeEndpointReset-DeWcqIyJ.js";import{t as Jc}from"./AssistantUnreadBadge-Xz7kMLSv.js";import{a as Yc,i as Xc,n as Zc,r as Qc,t as $c}from"./context-menu-C6l4ycZG.js";import{n as el,r as tl,t as nl}from"./collapsible-CS5qCQRU.js";import{n as rl,r as il}from"./readiness-lO-fOlzd.js";import{a as al,o as ol,r as sl,s as cl,t as ll}from"./projectActions-BX0cjZoq.js";import{t as ul}from"./diagram-D9-jif9d.js";import{a as dl,i as fl,n as pl,o as ml,r as hl,t as gl}from"./multirun-CicU-KQt.js";import{t as _l}from"./vendor-zumer-snapdom-yq9vlCKr.js";import{n as vl,t as yl}from"./vendor-html-to-image-BDMm2v6d.js";var Q=e(ve(),1),bl=$e(),xl=Qe(),$=ge();function Sl(e){let t=(0,xl.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 Cl=!1,wl=0,Tl=new Set,El=async()=>{let e=++wl;try{let t=await ee(`desktop_is_window_fullscreen`);if(e!==wl||t===Cl)return;Cl=t===!0,Tl.forEach(e=>e())}catch{}},Dl=e=>I()?(Tl.add(e),Tl.size===1&&(window.addEventListener(`yuri:window-resized`,El),El()),()=>{Tl.delete(e),Tl.size===0&&(window.removeEventListener(`yuri:window-resized`,El),wl++,Cl=!1)}):()=>{};function Ol(){return(0,Q.useSyncExternalStore)(Dl,Al,kl)}function kl(){return!1}function Al(){return Cl}function jl(){let e=(0,xl.c)(19),{t}=Tt(),n=q(Il),r=q(Fl),i=q(Pl),a=q(Nl),o=q(Ml),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=vt(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 Ml(e){return e.setWorkStatusOverlayOpen}function Nl(e){return e.setWorkStatusPanelEnabled}function Pl(e){return e.workStatusOverlayOpen}function Fl(e){return e.workStatusPanelFits}function Il(e){return e.workStatusPanelEnabled}var Ll=[{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`}],Rl=`finder`,zl=new Set([`finder`,`terminal`]),Bl=e=>typeof window<`u`&&window.__YURI_PLATFORM__===`win32`&&e.id===`finder`?{...e,label:`Explorer`,appName:`File Explorer`}:e,Vl=e=>{if(!e)return null;let t=Ll.find(t=>t.id===e)??null;return t?Bl(t):null},Hl=()=>Ll.filter(e=>zl.has(e.id)).map(e=>({...Bl(e)})),Ul=()=>{if(typeof window>`u`)return Rl;let e=window.localStorage.getItem(`openInAppId`);return e&&Vl(e)?e:Rl},Wl=!1,Gl=!1,Kl=!1,ql=0,Jl=null,Yl=()=>{Jl&&=(clearTimeout(Jl),null)},Xl=ne()((e,t)=>({selectedAppId:Ul(),availableApps:Hl(),hasLoadedApps:!1,isCacheStale:!1,isScanning:!1,initialize:()=>{if(Wl||typeof window>`u`)return;Wl=!0;let n=(t,n=!0)=>{if(!Array.isArray(t)||t.length===0){e({availableApps:Hl(),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:Ll.filter(e=>r.has(e.appName)||zl.has(e.id)).map(e=>({...Bl(e),iconDataUrl:i.get(e.appName)})),hasLoadedApps:!0})},r=async i=>{if(!I()||Gl||t().hasLoadedApps&&!i)return;let a=Ll.map(e=>e.appName);Yl(),i&&e({hasLoadedApps:!1}),Gl=!0,Kl=!1,e({isScanning:!0});try{let{apps:t,success:o,hasCache:s,isCacheStale:c}=await O(a,i),l=o&&!s&&t.length===0&&ql<3;if(e({isCacheStale:s?c:!1}),n(t,o?!l:!1),o){if(l){let e=[800,1600,3200][ql]??3200;ql+=1,Kl=!0,Jl=setTimeout(()=>{r()},e);return}ql=0,Kl=!1;return}if(ql<3){let e=[1e3,3e3,7e3][ql]??7e3;ql+=1,Kl=!0,Jl=setTimeout(()=>{r()},e)}}finally{Gl=!1,Kl||e({isScanning:!1})}};r(),window.addEventListener(`yuri:settings-synced`,t=>{let n=t.detail,r=n&&typeof n.openInAppId==`string`&&n.openInAppId.length>0&&Vl(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)&&(ql=3,Kl=!1,e({isScanning:!1,isCacheStale:!1}),n(r))}),window.__yuriAppReady&&r(),window.setTimeout(()=>{t().hasLoadedApps||r()},5e3)},loadInstalledApps:async n=>{if(Wl||t().initialize(),!I()||Gl||t().hasLoadedApps&&!n)return;let r=Ll.map(e=>e.appName);Yl(),n&&e({hasLoadedApps:!1}),Gl=!0,Kl=!1,e({isScanning:!0});try{let{apps:t,hasCache:i,isCacheStale:a}=await O(r,n),o=new Set(t.map(e=>e.name)),s=new Map(t.map(e=>[e.name,e.iconDataUrl??void 0])),c=Ll.filter(e=>o.has(e.appName)||zl.has(e.id)).map(e=>({...e,iconDataUrl:s.get(e.appName)}));e({availableApps:c.length>0?c:Hl(),hasLoadedApps:c.length>0,isCacheStale:i?a:!1})}finally{Gl=!1,Kl||e({isScanning:!1})}},selectApp:async t=>{Vl(t)&&(e({selectedAppId:t}),typeof window<`u`&&window.localStorage.setItem(`openInAppId`,t),await qe({openInAppId:t}))}})),Zl=(e=f(),t=l())=>{let n=e.startsWith(`host:`)?e.slice(5):null;return{queryKey:[t,`ssh-editor-apps`,n],enabled:I()&&D()&&n!==null,queryFn:async({signal:e})=>{let t=await ee(`desktop_ssh_editor_apps`,{hostId:n});return e.throwIfAborted(),t?{hostId:n,appIds:t.appIds}:null}}},Ql=()=>{let e=(0,xl.c)(3),t=(0,Q.useSyncExternalStore)(s,f,$l),n=(0,Q.useSyncExternalStore)(s,l,eu),r;return e[0]!==t||e[1]!==n?(r=Zl(t,n),e[0]=t,e[1]=n,e[2]=r):r=e[2],rt(r)};function $l(){return``}function eu(){return``}var tu=`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`,nu=`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`,ru=e=>({...e,fallbackIconDataUrl:e.id===`finder`&&window.__YURI_PLATFORM__!==`win32`?tu:e.id===`terminal`?nu:void 0}),iu=e=>{let t=(0,xl.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},au=({directory:e,className:t})=>{let{t:n}=Tt(),r=Xl(e=>e.selectedAppId),i=Xl(e=>e.availableApps),a=Xl(e=>e.isCacheStale),o=Xl(e=>e.isScanning),s=Xl(e=>e.initialize),c=Xl(e=>e.loadInstalledApps),l=Xl(e=>e.selectApp),{data:u}=Ql(),d=Q.useMemo(()=>u?i.filter(e=>u.appIds.includes(e.id)):i,[i,u]);Q.useEffect(()=>{s()},[s]);let f=I()&&k(),p=Q.useMemo(()=>{let e=d.find(e=>e.id===r)??d.find(e=>e.id===`finder`)??d[0];return e?ru(e):null},[d,r]);if(!f&&!u||!e)return null;let m=async t=>{try{let r=await j(e,t.id,t.appName,u?.hostId);!r&&!u?await g(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)},_=async()=>{await wt(e)};return(0,$.jsxs)(`div`,{className:J(`app-region-no-drag inline-flex h-7 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]`,`bg-[var(--surface-elevated)] overflow-hidden`,`border border-border/60`,t),children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void(p?m(p):_()),className:J(`inline-flex h-full items-center px-2.5 typography-ui-label font-medium`,`text-foreground hover:bg-interactive-hover transition-colors`,o&&`animate-pulse`),"aria-label":p?n(`openInApp.actions.openInAria`,{app:p.label}):n(`openInApp.actions.copyPath`),children:p?(0,$.jsx)(iu,{label:p.label,iconDataUrl:p.iconDataUrl,fallbackIconDataUrl:p.fallbackIconDataUrl}):(0,$.jsx)(Z,{name:`file-copy`,className:`h-4 w-4`})}),(0,$.jsxs)(Ba,{children:[(0,$.jsx)(Sa,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:J(`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`),"aria-label":n(`openInApp.actions.chooseAppAria`),children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4`})})}),(0,$.jsxs)(Pa,{align:`end`,className:`w-56 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(La,{className:`flex items-center gap-2`,onClick:()=>void _(),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)(za,{}),d.map(e=>{let t=ru(e);return(0,$.jsxs)(La,{className:`flex items-center gap-2`,onClick:()=>void h(e),children:[(0,$.jsx)(iu,{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)(La,{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]})]})]})},ou=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],su=[`dev`,`start`,`preview`,`serve`];async function cu(e,t,n){if(!e)return null;let r=du(t);if(r)return{command:r.command,label:r.name||`Start Preview`,actionId:r.id};if(n){let t=fu(n);if(t){let n=await pu(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 lu(e)){let e=await uu(),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 lu(e){let t=await mu(`${e}/index.html`,e);return typeof t==`string`&&t.trim().length>0}async function uu(){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 du(e){for(let t of e){let e=`${t.name} ${t.command}`.toLowerCase();if(su.some(t=>e.includes(t)))return t}return null}function fu(e){for(let{pattern:t}of ou)for(let n of Object.keys(e))if(t.test(n))return n;return null}async function pu(e){let t=await mu(`${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 mu(`${e}/${t}`,e);if(typeof r==`string`&&r.trim().length>0)return n}return`npm`}async function mu(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=z()?.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 hu(e){try{let t=await mu(`${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 gu=e=>new Promise(t=>{window.setTimeout(t,e)}),_u=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),vu=/https?:\/\/[^\s<>'"`]+/gi,yu=`__yuri_auto_discover_preview__`,bu=15e3,xu=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},Su=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}},Cu=e=>{let t=e.replace(_u,``).match(vu);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},wu=({projectRef:e,directory:t,className:n,compact:r=!1,allowMobile:i=!1})=>{let{t:a}=Tt(),{terminal:o,runtime:s}=at(),{isMobile:c}=Za(),l=Q.useMemo(()=>I(),[]),u=hs(e=>e.instances),d=hs(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=Bs(e=>e.sessions),y=Bs(e=>e.ensureDirectory),b=Bs(e=>e.setTabLabel),x=Bs(e=>e.setTabIconKey),S=Bs(e=>e.setActiveTab),C=Bs(e=>e.setConnecting),w=Bs(e=>e.setTabSessionId),T=Bs(e=>e.setTabPreviewUrl),E=Bs(e=>e.projectActionRuns),D=Bs(e=>e.setProjectActionRun),O=Bs(e=>e.updateProjectActionRunStatus),k=Bs(e=>e.removeProjectActionRun),[A,j]=Q.useState([]),[M,N]=Q.useState(null),[P,ee]=Q.useState(!1),F=Q.useRef({}),L=Q.useRef({}),R=Q.useRef({}),z=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 Oo(e)},[]),re=Q.useCallback(async()=>{if(!te)return;let e=B.current+1;B.current=e,ee(!0);try{let t=await En(te);if(B.current!==e)return;let n=t.actions;j(n),N(e=>e===yu||e&&n.some(t=>t.id===e)?e:null)}catch{if(B.current!==e)return}finally{B.current===e&&ee(!1)}},[te]),U=Q.useMemo(()=>al(t||te?.path||``),[t,te?.path]),ie=Q.useMemo(()=>M?A.find(e=>e.id===M)??null:null,[A,M]),ae=Q.useMemo(()=>({id:yu,name:a(`projectActions.actions.autoDiscover`),command:``,icon:`search`,autoOpenUrl:!0}),[a]),W=!c,oe=Q.useMemo(()=>W?[ae,...A]:A,[A,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(ll,e),()=>{window.removeEventListener(ll,e)}},[re,V]),Q.useEffect(()=>{M&&(M===yu&&W||A.some(e=>e.id===M)||N(null))},[A,W,M]),Q.useEffect(()=>{for(let[e,t]of Object.entries(E)){let n=v.get(t.directory)?.tabs.find(e=>e.id===t.tabId);(!n||n.terminalSessionId!==t.sessionId)&&k(e)}},[E,k,v]),Q.useEffect(()=>{for(let[e,t]of Object.entries(E)){let n=L.current[e]??{lastSeenChunkId:null,openedUrl:!1,tail:``,openInPreview:!1};L.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?Cu(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=E[e];t&&(T(t.directory,t.tabId,l,{locked:!1,autoOpened:!1}),t.status===`waiting-for-preview`&&O(e,`running`),window.clearTimeout(z.current[e]),delete z.current[e],_(t.directory,l))}else ne(l),X.success(a(`projectActions.toast.openedUrlFromOutput`));L.current[e]=n}for(let e of Object.keys(L.current))E[e]||(delete L.current[e],window.clearTimeout(z.current[e]),delete z.current[e])},[oe,_,ne,E,T,a,v,O]);let G=Q.useCallback(async(e,t={})=>{if(!U)throw Error(a(`projectActions.error.noActiveDirectory`));let n=cl(U,e.id);y(U);let r=Bs.getState(),i=r.getDirectoryState(U),o=F.current[n]||null,s=o?!!i?.tabs.some(e=>e.id===o):!1;(!o||!s)&&(o=r.createTab(U),F.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=Bs.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=cl(U,e.id),n=E[t];if(!(n&&n.status===`running`))try{let t=e.id===yu?await(async()=>{let[e,t]=await Promise.all([En({id:te?.id??``,path:U}),hu(U)]),n=await cu(U,e.actions,t);if(!n)throw Error(a(`contextPanel.preview.noDevServer`));return{id:yu,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!==yu}),c=s,d=!1;if(!c){C(U,i,!0);try{c=(await o.createSession({cwd:U})).sessionId,d=!0,w(U,i,c)}finally{C(U,i,!1)}}if(!c)throw Error(a(`projectActions.error.failedToCreateTerminalSession`));d&&await gu(350),t.id===yu&&(R.current[r]?.(),C(U,i,!0),R.current[r]=ft(c,e=>{e.type===`data`&&typeof e.data==`string`&&e.data.length>0&&Bs.getState().appendToBuffer(U,i,e.data),e.type===`exit`&&(Bs.getState().setTabLifecycle(U,i,`exited`),Bs.getState().setConnecting(U,i,!1),Bs.getState().removeProjectActionRun(r),delete L.current[r],R.current[r]?.(),delete R.current[r],window.clearTimeout(z.current[r]),delete z.current[r])},()=>{Bs.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?Su(t.openUrl):null,m=t.autoOpenUrl&&l?ol(t.desktopOpenSshForward,u):null;D({key:r,directory:U,actionId:t.id,tabId:i,sessionId:c,status:t.id===yu&&!p?`waiting-for-preview`:`running`}),window.clearTimeout(z.current[r]),delete z.current[r],t.id===yu&&!p&&(z.current[r]=window.setTimeout(()=>{Bs.getState().updateProjectActionRunStatus(r,`running`),delete z.current[r]},bu)),m?(T(U,i,null,{locked:!0}),ne(m),X.success(a(`projectActions.toast.openedForwardedUrl`))):p?(T(U,i,p,{locked:!0,autoOpened:!0}),_(U,p),X.success(a(`projectActions.toast.openedActionUrl`))):n?(T(U,i,null,{locked:!0}),X.error(a(`projectActions.error.invalidCustomUrlFormat`))):f?(T(U,i,null,{locked:!0}),X.error(a(`projectActions.error.selectedDesktopSshForwardUnavailable`))):T(U,i,null,{locked:!1,autoOpened:!1}),L.current[r]={lastSeenChunkId:null,openedUrl:!!m||!!p||n,tail:``,openInPreview:t.id===yu};let h=xu(t.command.trim().replace(/\r\n|\r/g,`
3
+ `));await o.sendInput(c,`${h}\r`)}catch(e){k(t),delete L.current[t],R.current[t]?.(),delete R.current[t],window.clearTimeout(z.current[t]),delete z.current[t],X.error(e instanceof Error?e.message:a(`projectActions.error.failedToRunAction`))}},[u,G,i,c,l,U,ne,_,E,s.isVSCode,k,C,D,T,w,te?.id,a,o]),ce=Q.useCallback(async e=>{let t=cl(U,e.id),n=E[t];if(n){O(t,`stopping`);try{await o.sendInput(n.sessionId,``)}catch{}if(await new Promise(e=>{window.setTimeout(e,1e3)}),Bs.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{}w(n.directory,n.tabId,null)}k(t),delete L.current[t],R.current[t]?.(),delete R.current[t],window.clearTimeout(z.current[t]),delete z.current[t]}},[U,E,k,w,o,O]),le=Q.useCallback(()=>{let e=ie??oe[0];if(!e)return;let t=cl(U,e.id),n=E[t];if(n?.status!==`stopping`){if(n){ce(e);return}se(e)}},[oe,U,se,E,ie,ce]),ue=Q.useCallback((e,t=!1)=>{if(N(e.id),!t){se(e);return}let n=cl(U,e.id),r=E[n];if(r?.status!==`stopping`){if(r){ce(e);return}se(e)}},[U,se,E,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===yu?`search`:sl[pe]||`play`,he=E[cl(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:P||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)(ca,{children:[(0,$.jsx)(aa,{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)(oa,{sideOffset:6,children:a(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(Ba,{children:[(0,$.jsx)(Sa,{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)(Pa,{align:`end`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(La,{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)(za,{}),oe.map(e=>{let t=e.icon||`play`,n=e.id===yu?`search`:sl[t]||`play`,r=cl(U,e.id),i=E[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(La,{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:P||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)(ca,{children:[(0,$.jsx)(aa,{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)(oa,{sideOffset:6,children:a(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(Ba,{children:[(0,$.jsx)(Sa,{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)(Pa,{align:`start`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(La,{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)(za,{}),oe.map(e=>{let t=e.icon||`play`,n=e.id===yu?`search`:sl[t]||`play`,r=cl(U,e.id),i=E[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(La,{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 Tu(e){return e.isOpen&&e.activeTab===e.targetTab?{open:!1,tab:e.activeTab}:{open:!0,tab:e.targetTab}}var Eu=`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`,Du=`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`,Ou=Q.memo(function(e){let t=(0,xl.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??Eu,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)(aa,{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)(oa,{children:(0,$.jsx)(`p`,{children:r})}),t[12]=r,t[13]=v);let y;return t[14]!==_||t[15]!==v?(y=(0,$.jsxs)(ca,{children:[_,v]}),t[14]=_,t[15]=v,t[16]=y):y=t[16],y}),ku=Q.memo(function(e){let t=(0,xl.c)(42),{isMobile:n,githubAuthStatus:r,githubAccounts:i,githubAvatarUrl:a,githubLogin:o,isSwitchingGitHubAccount:s,handleGitHubAccountSwitch:c}=e,{t:l}=Tt();if(!r?.connected||n)return null;if(i.length>1){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=J(Eu,`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)(Sa,{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)(Aa,{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)(za,{}),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)(La,{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)(Pa,{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)(Ba,{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}),Au=Q.memo(function(e){let t=(0,xl.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}=Tt(),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=vt(D),k;t[1]!==s||t[2]!==l||t[3]!==d||t[4]!==o||t[5]!==a?(k=e=>{!e&&E.current||(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)(Sa,{asChild:!0,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)(rs,{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)(fs,{})]})}):null,(0,$.jsx)($r,{embedded:!0,open:i&&s===`instance`,onOpenChange:Iu,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)(Gc,{active:i&&s===`mcp`}):null,t[23]=s,t[24]=i,t[25]=P):P=t[25];let ee;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?(ee=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:Mu(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)(rs,{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)(ao,{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=Qs(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-ua(s.elapsedRatio):ua(s.elapsedRatio),l=ja(i.valueLabel,o),u=la(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:pa(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)(Ms,{percent:o,tonePercent:i.usedPercent,className:`h-1.5`,expectedMarkerPercent:c}),s&&S?(0,$.jsx)(Ss,{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)(nl,{open:i,onOpenChange:()=>x(e.providerId,r),children:[(0,$.jsxs)(tl,{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)(el,{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-ua(a.elapsedRatio):ua(a.elapsedRatio),s=ja(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:bs(n)}),(0,$.jsx)(`span`,{className:`typography-ui-label tabular-nums text-foreground`,children:s===`-`?``:s})]}),(0,$.jsx)(Ms,{percent:i,tonePercent:r.usedPercent,className:`h-1.5`,expectedMarkerPercent:o}),a&&S?(0,$.jsx)(Ss,{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]=ee):ee=t[41];let F;t[42]!==w||t[43]!==M||t[44]!==N||t[45]!==P||t[46]!==ee?(F=(0,$.jsxs)(Pa,{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,ee]}),t[42]=w,t[43]=M,t[44]=N,t[45]=P,t[46]=ee,t[47]=F):F=t[47];let I;return t[48]!==i||t[49]!==k||t[50]!==F?(I=(0,$.jsxs)(Ba,{open:i,onOpenChange:k,children:[A,F]}),t[48]=i,t[49]=k,t[50]=F,t[51]=I):I=t[51],I}),ju=(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??``),Mu=(e,t)=>{if(!e)return`-`;try{return Ja(e,t,{fallback:`-`})}catch{return`-`}},Nu=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},Pu=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,Fu=({onToggleLeftDrawer:e,onToggleRightDrawer:n,leftDrawerOpen:r,rightDrawerOpen:i})=>{let{t:a}=Tt(),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),y=q(e=>e.setActiveMainTab),b=q(e=>e.shortcutOverrides),x=q(e=>e.timeFormatPreference),S=Zn(e=>e.getCurrentModel),w=at(),T=zn(e=>!!e.newSessionDraft?.open),E=zn(e=>e.currentSessionId),D=Bn(E??``),O=Jt(E),j=Tn(e=>e.activeProjectId?e.projects.find(t=>t.id===e.activeProjectId)??null:null),M=Q.useMemo(()=>{if(!j)return null;let e=j.path.split(/[\\/]/).filter(Boolean);return e[e.length-1]??null},[j]),N=Os(e=>e.results),L=Os(e=>e.fetchAllQuotas),R=Os(e=>e.isLoading),z=Os(e=>e.lastUpdated),ne=Os(e=>e.displayMode),re=Os(e=>e.showPredValues),U=Os(e=>e.dropdownProviderIds),ie=Os(e=>e.loadSettings),ae=Os(e=>e.setDisplayMode),{isMobile:W}=Za(),oe=fa().data??null,G=gs(e=>e.setStatus),se=Q.useRef(null),[ce,le]=Q.useState(()=>typeof window>`u`?!1:I()),ue=Q.useMemo(()=>P(),[]),de=ce&&A()===`win32`,fe=Xa(),pe=Ol(),me=Q.useMemo(()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),[]),{usesFramelessChrome:he,side:ge}=zs(),_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(I())},[]);let ve=S(),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=Mn(E??``,be,xe),Ce=T?null:Se,[we,Te]=Q.useState(null),Ee=!E||D;(0,Q.useEffect)(()=>{if(!E){Te(e=>e===null?e:null);return}if(Ce){Te(e=>ju(e,Ce)?e:Ce);return}Ee&&Te(e=>e===null?e:null)},[Ce,E,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,Pe]=Q.useState(!1),[K,Fe]=Q.useState(!1),[Ie,Le]=Q.useState(!1),[Re,ze]=Q.useState(`Local`),[Be,Ve]=Q.useState(!1),[He,We]=Q.useState(ce?`instance`:`usage`),[Ge,Ke]=Q.useState(`usage`);(0,Q.useEffect)(()=>{!ce&&He===`instance`&&We(`usage`)},[He,ce]);let Je=Q.useMemo(()=>F(),[]),Ye=!Je&&v===`chat`&&!!we,Xe=we&&we.contextLimit>0?Math.min(999,we.totalTokens/we.contextLimit*100):0,Ze=vt(async()=>{if(!(typeof window>`u`||!ce))try{if(k()){ze(`Local`),Ve(!1);return}let e=l(),t=await H();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?V(n,te(e)):!1);if(m()!==n)return;if(Ve(!!n),a?.label?.trim()){ze(B(a.label.trim()));return}ze(`Instance`)}catch{ze(`Local`),Ve(!1)}});(0,Q.useEffect)(()=>{Ze()},[ce]),vs();let Qe=Os(e=>e.selectedModels),$e=Os(e=>e.expandedFamilies),et=Os(e=>e.toggleFamilyExpanded),tt=Q.useMemo(()=>{let e=[];for(let t of _s(N)){if(!U.includes(t.id))continue;let n=N.find(e=>e?.providerId===t.id),r=n?.usage?.windows??{},i=n?.usage?.models,o=Hs(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=Qe[t.id]??[],n=e.length>0,r=ys(i,t.id),o=ws(t.id),c=Ns(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,N,Qe,a]),nt=tt.length>0;Q.useEffect(()=>{ie()},[ie]);let rt=Q.useCallback(async e=>{ae(e);try{await qe({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([L(),e]).finally(()=>{Le(!1)})},[L,Ie]),ot=zn(e=>E?e.worktreeMetadata.get(E)?.path??``:``),st=Q.useMemo(()=>Nu(ot||``),[ot]),ct=Q.useMemo(()=>Nu((typeof O?.directory==`string`?O.directory:``)||``),[O?.directory]),lt=zn(e=>e.newSessionDraft?.open?Nu(e.newSessionDraft.bootstrapPendingDirectory??e.newSessionDraft.directoryOverride??``):``),ut=Q.useMemo(()=>st||ct||lt,[lt,ct,st]),dt=Io(),ft=Q.useMemo(()=>Nu(dt||ut||j?.path||``),[j?.path,dt,ut]),pt=q(e=>Ue(e,ft)),mt=!!pt?.isOpen,ht=vt(()=>d(ft)),gt=Q.useMemo(()=>{if(!E)return M??`Yuri`;let e=O?.title?.trim();return e&&e.length>0?e:`Untitled Session`},[M,O?.title,E]),_t=Q.useMemo(()=>Nu(ut||j?.path||``),[j?.path,ut]),yt=Q.useMemo(()=>j?{id:j.id,path:j.path}:null,[j]),bt=Q.useRef(null);Q.useEffect(()=>{!yt||!_t||(bt.current={projectRef:yt,directory:_t})},[_t,yt]);let xt=Q.useMemo(()=>yt&&_t?{projectRef:yt,directory:_t}:bt.current,[_t,yt]),St=Q.useCallback(async e=>{if(!(!e||je)){Me(!0);try{let t=w.github?await w.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,w.github,G]),wt=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()},[]),Et=Q.useCallback(()=>{if(W){wt(),o(!De);return}s()},[wt,W,De,o,s]),Dt=Q.useCallback(()=>{ee(`desktop_open_draft_mini_chat_window`,{directory:Nu(ut||j?.path||``),projectId:j?.id??null,apiBaseUrl:m(),clientToken:t()}).catch(e=>{console.warn(`[header] failed to open draft mini chat window`,e)})},[j?.id,j?.path,ut]),Ot=Q.useCallback(()=>{if(T){Dt();return}E&&ee(`desktop_open_session_mini_chat_window`,{sessionId:E,directory:Nu(ut||j?.path||``),apiBaseUrl:m(),clientToken:t()}).catch(e=>{console.warn(`[header] failed to open session mini chat window`,e)})},[j?.path,E,Dt,T,ut]),kt=Q.useCallback(()=>{let e=ft;if(e){if(Pu(pt)===`context`){_(e);return}p(e)}},[_,ft,pt,p]),At=Q.useMemo(()=>ft?Pu(pt)===`context`:!1,[ft,pt]),jt=Q.useCallback(()=>{let e=ft;if(e){if(Pu(pt)===`browser`){_(e);return}g(e)}},[_,ft,pt,g]),Mt=Q.useMemo(()=>ft?Pu(pt)===`browser`:!1,[ft,pt]),Nt=Eu,Y=Du,Pt=Q.useMemo(()=>Ne?`services`:r?`sessions`:i?`git`:v,[v,Ne,r,i]),Ft=Q.useCallback(()=>{Pe(!1),r&&e&&e(),i&&n&&n(),!e&&De&&o(!1)},[De,r,e,n,i,o]),It=Q.useCallback(()=>{r||Pe(!1),e?.()},[r,e]),Lt=Q.useCallback(()=>{i||Pe(!1),n?.()},[n,i]),Rt=Q.useMemo(()=>ce&&me&&!pe?`5.5rem`:fe?`max(calc(0.75rem + var(--yuri-wco-left-inset, 0px)), 5.5rem)`:(!ce||he)&&!Je?`calc(0.75rem + var(--yuri-wco-left-inset, 0px))`:`0.75rem`,[ce,pe,me,fe,Je,he]);(0,Q.useEffect)(()=>{typeof document>`u`||document.documentElement.style.setProperty(`--yuri-titlebar-left-inset`,Rt)},[Rt]);let zt=c?`0.75rem`:`var(--yuri-titlebar-left-inset, 0.75rem)`,Bt=c?`0px`:`calc(var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`,Vt=Q.useMemo(()=>!ce||!me||_e===null?``:_e>=26?`h-12`:_e<=15?`h-14`:``,[ce,me,_e]),Ht=Q.useMemo(()=>{if(!(ce&&!he||Je))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,Je,mt,he]),Ut=Q.useCallback(()=>{if(typeof document>`u`)return;let e=se.current?.getBoundingClientRect().height;e&&document.documentElement.style.setProperty(`--yuri-header-height`,`${e}px`)},[]);(0,Q.useEffect)(()=>{if(typeof window>`u`)return;Ut();let e=se.current;if(!e||typeof ResizeObserver>`u`)return()=>{};let t=0,n=()=>{t||=requestAnimationFrame(()=>{t=0,Ut()})},r=new ResizeObserver(n);return r.observe(e),window.addEventListener(`resize`,n),window.addEventListener(`orientationchange`,n),()=>{t&&cancelAnimationFrame(t),r.disconnect(),window.removeEventListener(`resize`,n),window.removeEventListener(`orientationchange`,n)}},[Ut]),(0,Q.useEffect)(()=>{Ut()},[Ut,W,Vt]);let Wt=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 C()},[ce]),Gt=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]),Kt=Q.useCallback(e=>Ta(Na(e,b)),[b]);(0,Q.useEffect)(()=>{!W&&(v===`git`||v===`terminal`||v===`diff`||v===`files`)&&y(`chat`)},[v,W,y]);let qt=Q.useMemo(()=>{let e=[];return ce&&e.push({value:`instance`,label:a(`layout.services.instance`),icon:(0,$.jsx)(Z,{name:`server`,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(()=>qt.map(e=>({id:e.value,label:e.label,icon:e.icon})),[qt]),Xt=Q.useMemo(()=>[{value:`usage`,label:a(`header.services.used`)},{value:`remaining`,label:a(`header.services.remaining`)}],[a]),Zt=Q.useMemo(()=>Xt.map(e=>({id:e.value,label:e.label})),[Xt]),Qt=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(Ct(e)&&!e.shiftKey&&!e.altKey){let t=parseInt(e.key,10);t>=1&&t<=Gt.length&&(e.preventDefault(),W&&(wt(),Ft()),y(Gt[t-1].id))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[wt,Ft,W,y,Gt]);let $t=vt(e=>{We(e),Fe(!0),Ze(),e===`usage`&&z===null&&L()});(0,Q.useEffect)(()=>{let e=e=>{let t=Na(`toggle_services_menu`,b);if(Ha(e,t)){e.preventDefault();let t=Tu({isOpen:K,activeTab:He,targetTab:ce?`instance`:`usage`});t.open?$t(t.tab):Fe(!1);return}let n=Na(`cycle_services_tab`,b);if(Ha(e,n)){e.preventDefault();let t=qt.map(e=>e.value);if(t.length===0)return;let n=t.indexOf(He),r=t[n===-1?0:(n+1)%t.length];We(r),Fe(!0),Ze(),r===`usage`&&z===null&&L();return}let r=Na(`open_usage`,b);if(Ha(e,r)){e.preventDefault();let t=Tu({isOpen:K,activeTab:He,targetTab:`usage`});t.open?$t(t.tab):Fe(!1);return}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[b,ce,K,He,qt,z,L,Ze,$t]);let en=e=>{let t=v===e.id,n=e.icon===`diff`,r=n?null:e.icon,i=e.id===`chat`,a=e=>n?(0,$.jsx)(Sl,{size:e}):r?(0,$.jsx)(Z,{name:r,className:`h-${e/4} w-${e/4}`}):null,o=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>y(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)},tn=ue&&(T||!!E),nn=Q.useCallback(e=>{window.setTimeout(e,0)},[]),rn=Q.useCallback(e=>{$t(e)},[$t]),X=Q.useRef(null),an=(0,$.jsxs)(`div`,{className:`relative flex shrink-0 items-center`,children:[(0,$.jsx)(`div`,{ref:X,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center`,children:(0,$.jsxs)(Ba,{children:[(0,$.jsxs)(ca,{children:[(0,$.jsx)(aa,{asChild:!0,children:(0,$.jsx)(Sa,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":a(`header.actions.sessionMenuAria`),className:J(Nt,`text-muted-foreground`),children:(0,$.jsx)(Z,{name:`more-2`,className:`h-[18px] w-[18px]`})})})}),(0,$.jsx)(oa,{children:(0,$.jsx)(`p`,{children:a(`header.actions.sessionMenu`)})})]}),(0,$.jsxs)(Pa,{align:`start`,className:`min-w-[14rem]`,children:[tn?(0,$.jsxs)(La,{className:`flex items-center gap-2`,onClick:()=>nn(Ot),children:[(0,$.jsx)(Z,{name:`picture-in-picture-2`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:a(T?`header.actions.newMiniChat`:`header.actions.openSessionMiniChat`)})]}):null,ce?(0,$.jsxs)(La,{className:`flex items-center gap-2`,onClick:()=>nn(()=>rn(`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:Kt(`toggle_services_menu`)})]}):null,(0,$.jsxs)(La,{className:`flex items-center gap-2`,onClick:()=>nn(()=>rn(`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:Kt(`open_usage`)})]}),(0,$.jsx)(za,{}),(0,$.jsxs)(La,{className:`flex items-center gap-2`,onClick:()=>nn(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:Kt(`toggle_terminal`)})]}),(0,$.jsxs)(La,{className:`flex items-center gap-2`,onClick:()=>nn(jt),children:[(0,$.jsx)(Z,{name:`global`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:a(`contextPanel.browser.open`)}),Mt?(0,$.jsx)(Z,{name:`check`,className:`h-3.5 w-3.5 text-foreground`}):null]})]})]})}),(0,$.jsx)(Au,{isDesktopApp:ce,currentInstanceSupportsUpdate:Be,isDesktopServicesOpen:K,setIsDesktopServicesOpen:Fe,refreshCurrentInstanceLabel:Ze,desktopServicesTab:He,setDesktopServicesTab:We,fetchAllQuotas:L,servicesTabItems:Yt,quotaLastUpdated:z,quotaDisplayMode:ne,showPredValues:re,quotaDisplayTabItems:Zt,handleDisplayModeChange:rt,handleUsageRefresh:it,isQuotaLoading:R,isUsageRefreshSpinning:Ie,hasRateLimits:nt,rateLimitGroups:tt,expandedFamilies:$e,toggleFamilyExpanded:et,timeFormatPreference:x,anchorRef:X})]}),on=(0,$.jsxs)($.Fragment,{children:[!W&&!Je&&v===`chat`?(0,$.jsx)(jl,{}):null,(0,$.jsx)(au,{directory:_t}),(0,$.jsx)(Ou,{title:a(`header.actions.rightSidebarWithShortcut`,{shortcut:Kt(`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)(ku,{isMobile:W,githubAuthStatus:oe,githubAccounts:Ae,githubAvatarUrl:Oe,githubLogin:ke,isSwitchingGitHubAccount:je,handleGitHubAccountSwitch:St})]}),sn=()=>(0,$.jsxs)(`div`,{onMouseDown:Wt,className:J(`app-region-drag relative flex h-12 select-none items-center pr-3`,Vt),style:Ht,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:zt}}),(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:Bt}}),(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)(Rs,{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:T?a(`sessions.switcher.draftTitle`):gt})})})}),Gt.length>0&&(0,$.jsx)(`div`,{className:`flex items-center gap-1 rounded-lg bg-[var(--surface-muted)]/50 p-1`,children:Gt.map(e=>en(e))}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[an,Ye&&we?(0,$.jsx)(Is,{pending:we.pending,totalTokens:we.totalTokens,percentage:Xe,colorPercentage:we.percentage,contextLimit:we.contextLimit,outputLimit:we.outputLimit??0,size:`compact`,appearance:`subtle`,onClick:kt,pressed:At}):null,on,(0,$.jsx)(Ls,{visible:he&&ge===`right`&&!mt,position:`right`})]})]})]}),cn=()=>(0,$.jsxs)(`div`,{className:`app-region-drag relative flex items-center gap-2 px-3 py-2 select-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e?(0,$.jsx)(`button`,{type:`button`,onClick:It,className:J(Y,Pt===`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:Et,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:Gt.map(e=>{let t=v===e.id,n=e.icon===`diff`,r=n?null:e.icon;return(0,$.jsxs)(ca,{children:[(0,$.jsx)(aa,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{W&&(wt(),Ft()),y(e.id)},"aria-label":e.label,"aria-selected":t,role:`tab`,className:J(Y,`relative rounded-lg`,Pt===e.id&&`bg-interactive-selection text-interactive-selection-foreground`),children:[n?(0,$.jsx)(Sl,{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)(oa,{children:(0,$.jsx)(`p`,{children:e.label})})]},e.id)})})})})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(Ts,{mobile:!0}),xt&&(0,$.jsx)(wu,{projectRef:xt.projectRef,directory:xt.directory,compact:!0,allowMobile:!0,className:`h-9`}),(0,$.jsxs)(Ba,{open:Ne,onOpenChange:t=>{t&&(r&&e&&e(),i&&n&&n()),Pe(t),t&&z===null&&L()},children:[(0,$.jsxs)(ca,{children:[(0,$.jsx)(aa,{asChild:!0,children:(0,$.jsx)(Sa,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":a(`header.services.viewAria`),className:J(Y,Pt===`services`&&`bg-interactive-selection text-interactive-selection-foreground`),children:(0,$.jsx)(Z,{name:`stack`,className:`h-5 w-5`})})})}),(0,$.jsx)(oa,{children:(0,$.jsx)(`p`,{children:a(`header.services.title`)})})]}),(0,$.jsx)(Pa,{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)(rs,{items:Qt,activeId:Ge,onSelect:e=>{let t=e;Ke(t),t===`usage`&&z===null&&L()},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:()=>Pe(!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`})})]})}),Ge===`mcp`&&(0,$.jsx)(Gc,{active:Ne&&Ge===`mcp`}),Ge===`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:Mu(z,x)})]}),(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`,ne===`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`,ne===`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:R||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:tt.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)(ao,{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=Qs(e.entries,r),a=ne===`remaining`?n.remainingPercent:n.usedPercent,o=n.disablePace?null:ma(n.usedPercent,n.resetAt,n.windowSeconds,t),s=o?.dailyAllocationPercent==null?null:ne===`remaining`?100-ua(o.elapsedRatio):ua(o.elapsedRatio),c=ja(n.valueLabel,a),l=la(n.resetAt,n.resetAfterFormatted??n.resetAtFormatted,x);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:pa(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)(Ms,{percent:a,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:s}),o&&re?(0,$.jsx)(Ss,{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=($e[e.providerId]??[]).includes(t.familyId??`other`);return(0,$.jsxs)(nl,{open:n,onOpenChange:()=>et(e.providerId,t.familyId??`other`),children:[(0,$.jsxs)(tl,{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)(el,{children:(0,$.jsx)(`div`,{className:`space-y-2.5 pb-1 pl-1 pt-1`,children:t.models.map(([t,n])=>{let r=ne===`remaining`?n.remainingPercent:n.usedPercent,i=ma(n.usedPercent,n.resetAt,n.windowSeconds),a=i?.dailyAllocationPercent==null?null:ne===`remaining`?100-ua(i.elapsedRatio):ua(i.elapsedRatio),o=ja(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:bs(t)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground tabular-nums`,children:o===`-`?``:o})]}),(0,$.jsx)(Ms,{percent:r,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:a}),i&&re?(0,$.jsx)(Ss,{paceInfo:i,compact:!0}):null]},`${e.providerId}-${t}`)})})})]},t.familyId??`other`)})})]})]},e.providerId))})]})]})})]}),n?(0,$.jsxs)(ca,{children:[(0,$.jsx)(aa,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:Lt,className:J(Y,`relative`,Pt===`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)(oa,{children:(0,$.jsx)(`p`,{children:i?`Close git sidebar`:`Open git sidebar`})})]}):null]})]})]}),ln=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:ln,style:{"--padding-scale":`1`},children:W?cn():sn()})})};function Iu(){}var Lu=180,Ru=640,zu=110,Bu=e=>{let t=(0,xl.c)(44),{isOpen:n,isMobile:r,children:i}=e,{t:a}=Tt(),o=q(Vu),s=q(Hu),c=q(Uu),l=q(Wu),[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(Ru,Math.max(Lu,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(Ru,Math.max(Lu,g.current+t));c(n)},t=()=>{p(!1),q.getState().bottomTerminalHeight<=zu&&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 ee=!n&&`pointer-events-none select-none opacity-0`,F;t[32]===ee?F=t[33]:(F=J(`relative z-10 flex h-full min-h-0 w-full flex-col transition-opacity duration-300 ease-in-out`,ee),t[32]=ee,t[33]=F);let I=!n,L;t[34]!==i||t[35]!==F||t[36]!==I?(L=(0,$.jsx)(`div`,{className:F,"aria-hidden":I,children:i}),t[34]=i,t[35]=F,t[36]=I,t[37]=L):L=t[37];let R;return t[38]!==j||t[39]!==M||t[40]!==N||t[41]!==P||t[42]!==L?(R=(0,$.jsxs)(`section`,{ref:m,className:j,style:M,"aria-hidden":N,children:[P,L]}),t[38]=j,t[39]=M,t[40]=N,t[41]=P,t[42]=L,t[43]=R):R=t[43],R};function Vu(e){return e.bottomTerminalHeight}function Hu(e){return e.isBottomTerminalExpanded}function Uu(e){return e.setBottomTerminalHeight}function Wu(e){return e.setBottomTerminalOpen}var Gu=260,Ku=260,qu=500,Ju=({isOpen:e,isMobile:t,children:n,className:r,topBar:i})=>{let{t:a}=Tt(),o=q(e=>e.sidebarWidth),s=q(e=>e.setSidebarWidth),[c,l]=Q.useState(!1),u=Q.useRef(0),d=Q.useRef(o||Gu),f=Q.useRef(null),p=Q.useRef(null),m=Q.useRef(null),h=Q.useCallback(e=>Math.min(qu,Math.max(Ku,e)),[]),g=Q.useCallback(e=>{let t=m.current;t&&(t.style.width=`${e}px`,t.style.minWidth=`${e}px`,t.style.maxWidth=`${e}px`,t.style.setProperty(`--yuri-left-sidebar-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(qu,Math.max(Ku,o||Gu)),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=h(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=h(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`,"--yuri-left-sidebar-width":`${c?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`,{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:`var(--yuri-left-sidebar-width)`,overflowX:`hidden`},"aria-hidden":!e,children:[i,(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,$.jsx)(Ka,{children:n})})]})]})},Yu=()=>{let e=(0,xl.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},Xu=e=>{let t=(0,xl.c)(14),{className:n}=e,r=Es(Zu).trim(),i=r.split(/\s+/).filter(Boolean),a=i.includes(`Yuri`),o=i.some(Qu);if(Q.useEffect(()=>{o&&ki()},[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)(Ya,{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)(bc,{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 Zu(e){return e.sidebarBrandName}function Qu(e){return e!==`Yuri`}var $u=`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`,ed=()=>{let e=(0,xl.c)(48),{t}=Tt(),n=q(td),r=q(nd),i=q(rd),a=q(id),o=Es(ad),s=Q.useRef(null),c=Ta(Na(`toggle_sidebar`,a)),{usesFramelessChrome:l,side:u}=zs(),d;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=I(),e[0]=d):d=e[0];let f=d,p=Ol(),m=!f||p||!n||!o,h;e[1]===p?h=e[2]:(h=!F()&&(f?p:S()),e[1]=p,e[2]=h);let g=h,_=sd,v,y;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>{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()}},y=[],e[3]=v,e[4]=y):(v=e[3],y=e[4]),Q.useEffect(v,y);let b=g&&n?`${r||260}px`:void 0,x;e[5]===b?x=e[6]:(x={height:`var(--yuri-header-height, 3rem)`,paddingLeft:`var(--yuri-titlebar-left-inset, 0.75rem)`,width:b},e[5]=b,e[6]=x);let C=g&&n&&`w-full justify-between`,w;e[7]===C?w=e[8]:(w=J(`flex items-center gap-2`,C),e[7]=C,e[8]=w);let T;e[9]!==n||e[10]!==g?(T=g&&n?(0,$.jsx)(Xu,{className:`flex min-w-0 items-center p-0 pl-1.5`}):null,e[9]=n,e[10]=g,e[11]=T):T=e[11];let E;e[12]!==l||e[13]!==u?(E=l&&u===`left`?(0,$.jsx)(Ls,{visible:!0,position:`left`}):null,e[12]=l,e[13]=u,e[14]=E):E=e[14];let D;e[15]!==t||e[16]!==l?(D=l?(0,$.jsxs)(ca,{children:[(0,$.jsx)(aa,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:_,"aria-label":t(`header.actions.openAppMenuAria`),className:J($u,`shrink-0`),children:(0,$.jsx)(Z,{name:`menu-2`,className:`h-[18px] w-[18px]`})})}),(0,$.jsx)(oa,{children:(0,$.jsx)(`p`,{children:t(`header.actions.openAppMenu`)})})]}):null,e[15]=t,e[16]=l,e[17]=D):D=e[17];let O;e[18]===m?O=e[19]:(O=m?(0,$.jsx)(Ec,{}):null,e[18]=m,e[19]=O);let k=ca,A;e[20]===t?A=e[21]:(A=t(`header.actions.openSessionsAria`),e[20]=t,e[21]=A);let j,M;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(j=J($u,`group shrink-0`),M=(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]=j,e[23]=M):(j=e[22],M=e[23]);let N;e[24]!==A||e[25]!==i?(N=(0,$.jsx)(aa,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:i,"aria-label":A,className:j,children:M})}),e[24]=A,e[25]=i,e[26]=N):N=e[26];let P=oa,ee=t(`header.actions.openSessionsWithShortcut`,{shortcut:c}),L;e[27]===ee?L=e[28]:(L=(0,$.jsx)(`p`,{children:ee}),e[27]=ee,e[28]=L);let R;e[29]!==P||e[30]!==L?(R=(0,$.jsx)(P,{children:L}),e[29]=P,e[30]=L,e[31]=R):R=e[31];let z;e[32]!==k||e[33]!==N||e[34]!==R?(z=(0,$.jsxs)(k,{children:[N,R]}),e[32]=k,e[33]=N,e[34]=R,e[35]=z):z=e[35];let B;e[36]!==O||e[37]!==z?(B=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[O,z]}),e[36]=O,e[37]=z,e[38]=B):B=e[38];let V;e[39]!==E||e[40]!==D||e[41]!==B||e[42]!==w||e[43]!==T?(V=(0,$.jsxs)(`div`,{ref:s,className:w,children:[T,E,D,B]}),e[39]=E,e[40]=D,e[41]=B,e[42]=w,e[43]=T,e[44]=V):V=e[44];let H;return e[45]!==V||e[46]!==x?(H=(0,$.jsx)(`div`,{className:`app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2`,style:x,children:V}),e[45]=V,e[46]=x,e[47]=H):H=e[47],H};function td(e){return e.isSidebarOpen}function nd(e){return e.sidebarWidth}function rd(e){return e.toggleSidebar}function id(e){return e.shortcutOverrides}function ad(e){return e.sidebarBrandName.trim().length>0}function od(e){console.warn(`[titlebar] failed to open app menu`,e)}function sd(e){let t=e.currentTarget.getBoundingClientRect();ee(`desktop_show_app_menu`,{x:t.left,y:t.bottom}).catch(od)}function cd(e){let t=(0,xl.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 ld=(e,t)=>{let n=lt(t,e);return!n||n===`.`||n===t?0:n.split(`/`).filter(Boolean).length},ud=(e,t,n=10)=>{let r=ct(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=ct(t.path);if(!e||i.has(e))continue;let o=ld(r,e);o<1||o>n||(i.add(e),a.push(e))}return a},dd=e=>e.some(e=>!!ct(e)),fd=(e,t)=>{let n=new Set(t.map(e=>ct(e)).filter(Boolean));return e.filter(e=>!n.has(e))},pd=(e,t,n)=>t.length===0?e.length===0:fd(e,t).length>0?!1:t.every(e=>n.has(ct(e))),md=Do(()=>ut(()=>import(`./ToolOutputDialog-COWWhGPD.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]))),hd=e=>{let t=vd(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},gd=e=>{let t=(0,xl.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},_d=e=>e.slice().sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1),vd=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},yd=e=>e.startsWith(`/`)||e.startsWith(`//`)||/^[A-Za-z]:\//.test(e),bd=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,xd=(e,t)=>{let n=vd(t),r=vd(e);if(!n||!r)return!1;let i=bd(n),a=bd(r);return a===i||a.startsWith(`${i}/`)},Sd=(e,t)=>{let n=vd(t),r=vd(e);if(!xd(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},Cd=(e,t)=>{if(!t)return``;let n=vd(t);if(!e||!xd(n,e))return n;let r=n.slice(e.length);return r.startsWith(`/`)?r.slice(1):r},wd=new Set([`node_modules`]),Td=e=>{let t=(0,xl.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},Ed=e=>{let t=(0,xl.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},Dd=e=>wd.has(e),Od=e=>{let t=vd(e);return t===`node_modules`||t.endsWith(`/node_modules`)||t.includes(`/node_modules/`)},kd=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`is a directory`)||t.includes(`eisdir`)},Ad=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`)},jd=2e5,Md=`yuri:files:auto-save-enabled`,Nd=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
  `},Pd=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 Ry(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 zy(e,t){let n=await L(t,e);if(n)return n;if(!F())return null;try{let n=await z()?.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 By(e){let t=z()?.files;if(t?.revealPath)try{return!!(await t.revealPath(e))?.success}catch{return!1}return await x(e)?!0:g(e)}function Vy(){return Nt()}function Hy(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 Uy=(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},Wy=ne()((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=Uy(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}))}})),Gy=!1,Ky=new Set,qy=!1;function Jy(){for(let e of Ky)e()}function Yy(e){Gy!==e&&(Gy=e,Jy())}function Xy(e){e.key===`Shift`&&Yy(!0)}function Zy(e){e.key===`Shift`&&Yy(!1)}function Qy(){Yy(!1)}function $y(){qy||typeof window>`u`||(qy=!0,window.addEventListener(`keydown`,Xy),window.addEventListener(`keyup`,Zy),window.addEventListener(`blur`,Qy))}function eb(e){return $y(),Ky.add(e),()=>{Ky.delete(e)}}function tb(){return Gy}function nb(){return!1}function rb(){return(0,Q.useSyncExternalStore)(eb,tb,nb)}var ib=!1,ab=!1,ob=new Set;function sb(){ob.forEach(e=>e())}function cb(e){ib!==e&&(ib=e,sb())}function lb(e){return kt()?e.key===`Meta`:e.key===`Control`}var ub=(({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:cb});function db(e){lb(e)&&ub.press()}function fb(){ub.release()}function pb(e){lb(e)&&fb()}function mb(){document.visibilityState!==`visible`&&fb()}function hb(){ab||typeof window>`u`||(ab=!0,window.addEventListener(`keydown`,db),window.addEventListener(`keyup`,pb),window.addEventListener(`blur`,fb),document.addEventListener(`visibilitychange`,mb))}function gb(e){return hb(),ob.add(e),()=>ob.delete(e)}function _b(){return ib}function vb(){return!1}function yb(){return(0,Q.useSyncExternalStore)(gb,_b,vb)}var bb=(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} ---`},xb=(e,t)=>zn.getState().getWorktreeMetadata(e)?.projectDirectory??t,Sb=e=>e.type===`assistant`?Ur(e.content??[]).trim():``,Cb=async e=>{let t=e.directory??void 0,n=Ee(e.session.id,t);if(n.length===0&&e.directory){let t=await be.withDirectory(e.directory,()=>be.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=Sb(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 Ur(ze(r.id,t)).trim()}return``};function wb({session:e,open:t,onOpenChange:n}){let{t:r}=Tt(),i=pn(),a=Zt(e=>e.activeSessions),o=Zt(e=>e.archivedSessions),s=Zn(e=>e.providers),c=Zn(e=>e.currentProviderId),l=Zn(e=>e.currentModelId),u=Zn(e=>e.currentAgentName),[d,f]=Q.useState(c??``),[p,m]=Q.useState(l??``),[h,g]=Q.useState(()=>c&&l?[{providerID:c,modelID:l,instanceId:fl()}]:[]),[_,v]=Q.useState(``),[y,b]=Q.useState(u??``),[x,S]=Q.useState([]),[C,w]=Q.useState(!1),T=Q.useMemo(()=>ml(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=zn.getState().getDirectoryForSession(e.id),r=xb(e.id,n),i=E.map(e=>{let t=ml(e.title);if(!t||t.groupSlug!==T.groupSlug||t.fusion||(t.runGroup??null)!==(T.runGroup??null))return null;let n=zn.getState().getDirectoryForSession(e.id)??Yt(e),i=xb(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)(fr,{open:t,onOpenChange:n,children:(0,$.jsxs)(lr,{className:`max-w-xl overflow-visible`,children:[(0,$.jsxs)(sr,{children:[(0,$.jsx)(ur,{children:r(`multirun.fusion.title`)}),(0,$.jsx)(dr,{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)(hl,{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)(oo,{modelId:p,providerId:d,className:`h-3.5 w-3.5 mr-1`}):void 0})}),O.length>0?(0,$.jsxs)(ho,{value:_||`__default__`,onValueChange:e=>v(e===`__default__`?``:e),children:[(0,$.jsxs)(lo,{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)(yo,{children:e=>e===`__default__`?r(`multirun.modelMultiSelect.variant.default`):e})]}),(0,$.jsxs)(fo,{fitContent:!0,portalToBody:!0,children:[(0,$.jsx)(so,{value:`__default__`,children:r(`multirun.modelMultiSelect.variant.default`)}),O.map(e=>(0,$.jsx)(so,{value:e,children:e},e))]})]}):null,(0,$.jsx)(pl,{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=ml(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)(oo,{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)(cr,{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=>Cb(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([yr(`session.fusion.visible`),yr(`session.fusion.instructions`)]),c=await zn.getState().createSession(a,i,null);if(!c)throw Error(`Failed to create fusion session`);zn.getState().setCurrentSession(c.id,i),n(!1),await be.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:bb(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??be.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 Tb(e){let t=(0,xl.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:or,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 Eb=1/3,Db=1,Ob=({containerScrollTop:e,containerClientHeight:t,containerScrollHeight:n,rowOffsetFromViewportTop:r})=>{let i=e+(r-t*Eb),a=Math.max(0,n-t);return Math.min(a,Math.max(0,i))},kb=()=>typeof window>`u`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`,Ab=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},jb=(e,t)=>{let n=Ab(e),r=t?.behavior??kb();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=Ob({containerScrollTop:n.scrollTop,containerClientHeight:n.clientHeight,containerScrollHeight:n.scrollHeight,rowOffsetFromViewportTop:i.top-a});Math.abs(s-n.scrollTop)<Db||n.scrollTo({top:s,behavior:r})},Mb=e(ce(),1),Nb=null,Pb=!1,Fb=(e,t=Bi.getState().focus)=>e===null?null:typeof e==`string`?t?.sessionId===e?t:yi(e):e,Ib=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))},Lb=()=>{Nb&&=(Ib(Nb),null)},Rb=(e,t)=>{Lb(),_n(!0);let n=Fb(e);if(!n)return;Pb=!0;let r;try{r=Ln(n.sessionId)}finally{Pb=!1}Nb={commit:t,commitFrame:null,fallbackTimer:null,focus:n,intent:r,paintFrame:null,scheduled:!1},(0,Mb.flushSync)(()=>{Bi.getState().setFocus(n)}),typeof window<`u`&&(Nb.fallbackTimer=window.setTimeout(()=>{zb(n)},150))},zb=e=>{let t=Nb,n=Fb(e);if(!t||!oi(t.focus,n)||t.scheduled)return;t.scheduled=!0,typeof window<`u`&&t.fallbackTimer!==null&&(window.clearTimeout(t.fallbackTimer),t.fallbackTimer=null);let r=()=>{Nb===t&&kn()===t.intent&&(Nb=null,er(),t.commit())};if(typeof window>`u`){r();return}t.commitFrame=window.requestAnimationFrame(()=>{Nb===t&&kn()===t.intent&&(t.paintFrame=window.requestAnimationFrame(r))})},Bb=e=>{if(Nb)return;let t=Bi.getState();t.setFocus(Fb(e,t.focus))};Dn(e=>{if(Pb)return;let t=Nb;if(t?.intent===e)return;t&&Lb();let n=Bi.getState();n.setFocus(Fb(e.sessionId,n.focus))});var Vb=e=>{let t=[],n=e=>{e.children.forEach(e=>{t.push(e.session.id),n(e)})};return n(e),t},Hb=Q.memo(function(e){let t=(0,xl.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)(aa,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:u,"aria-label":r,onPointerDown:o,onMouseDown:s,onClick:c,onKeyDown:tx,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)(oa,{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)(ca,{children:[h,g]}),t[18]=h,t[19]=g,t[20]=_):_=t[20],_}),Ub=Q.memo(function(e){let t=(0,xl.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=rb(),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)(aa,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:y,"aria-label":h,onPointerDown:c,onMouseDown:l,onClick:_,onKeyDown:nx,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)(oa,{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)(ca,{children:[S,C]}),t[21]=S,t[22]=C,t[23]=w):w=t[23],w}),Wb=Q.memo(function(e){let t=(0,xl.c)(3),{number:n}=e;if(!yb())return null;let r=kt()?`⌘${n}`:`Ctrl+${n}`,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(Vi,{"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 Gb(e){let{t:n}=Tt(),{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:T,handleUnshareSession:E,setOpenSidebarMenuKey:D,renamingFolderId:O,getFoldersForScope:k,getSessionFolderId:A,removeSessionFromFolder:j,addSessionToFolder:M,createFolderAndStartRename:N,handleDeleteSession:I,mobileVariant:L,alwaysShowActions:R,renderSessionNode:z,secondaryMeta:B,renderContext:V=`project`,subtreeContainsActive:H,subtreeContainsEditing:te,menuOpenSessionId:ne,childRenderExtrasFor:re,liveSessionById:U,shortcutNumber:ce=null}=e,le=!!B?.projectLabel,ue=!!B?.branchLabel,de=qn(e=>e.displayMode),fe=Q.useMemo(()=>F(),[]),he=de===`minimal`||fe,ge=Q.useMemo(()=>P(),[]),_e=Q.useContext(it),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`,be=fe,xe=V===`pinned`&&c.has(r.session.id),Ce=!xe&&!s&&!L,Te=`h-5 w-5`,Ee=`h-3.5 w-3.5`,De=(Ce||xe?1:0)+ +!!be+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,Pe]=Q.useState(!1),K=Q.useRef(f);K.current=f;let Fe=Q.useRef(null),Ie=Q.useRef(_);Ie.current=_;let[Re,ze]=Q.useState(h),Be=Q.useRef(Re);Be.current=Re;let Ve=Q.useRef(null),He=Q.useRef(null),q=Q.useRef(null),Ue=r.session,We=U.get(Ue.id)??Ue,Ge=!!We.metadata?.yuri?.assistant,Ke=dt(Ue.directory??null)??dt(a??null),qe=Qt(Ke??void 0,{bootstrap:!1}),Je=ni(),Ye=Wy(e=>e.enabled),Xe=Wy(Q.useMemo(()=>e=>e.selectedIds.has(Ue.id),[Ue.id])),Ze=Wy(e=>e.toggleSelected),Qe=Wy(e=>e.setRange),[$e,et]=Q.useState(!1),[tt,nt]=Q.useState(!0),[rt,at]=Q.useState(!1),[ot,st]=Q.useState(!1),ct=`${V}:${s?`archived`:`active`}:${Ue.id}`,lt=dn(Q.useMemo(()=>e=>!!e.sessionMemoryState.get(Wt(Ue.id))?.isZombie,[Ue.id])),ut=Kn(Ue.id),ft=An(Ue.id,Ke??void 0,{bootstrap:!1}),pt=On(Ue.id,Ke??void 0,{bootstrap:!1}),mt=Q.useMemo(()=>({scope:V,sessionId:Ue.id,projectId:o??null}),[o,V,Ue.id]),ht=Q.useMemo(()=>_i(mt)??``,[mt]),gt=Q.useRef(null),yt=Bi(Q.useMemo(()=>e=>oi(e.focus,mt),[mt]));Q.useLayoutEffect(()=>{if(!yt)return;let e=gt.current;e&&(L?e.scrollIntoView({block:`nearest`,inline:`nearest`}):jb(e)),zb(mt)},[yt,L,mt]);let xt=We.title||n(`sessions.sidebar.session.untitled`),St=io(ro(We)),Ct=We.metadata?.yuri?.titleRefresh,wt=typeof Ct?.lastError==`string`?Ct.lastError:null,Et=typeof Ct?.failedAt==`number`?Ct.failedAt:null;Q.useEffect(()=>{!wt||Et===null||console.warn(`[session-title] generation failed for ${Ue.id}: ${wt}`)},[Ue.id,wt,Et]);let Dt=typeof Ct?.generationExpiresAt==`number`&&Number.isFinite(Ct.generationExpiresAt)?Ct.generationExpiresAt:0,[Ot,kt]=Q.useState(0),At=Q.useMemo(()=>Math.max(0,Dt-Date.now()),[Dt]),[,jt,Mt]=_t(()=>kt(Dt),At,{immediate:!1}),Nt=Ct?.isGenerating===!0;Q.useEffect(()=>(Nt&&Dt>Date.now()&&jt(),Mt),[Nt,Dt,jt,Mt]);let Pt=r.children.length>0||!!(We.hasChildren??Ue.hasChildren),Ft=c.has(Ue.id),It=ct,Lt=u?!0:l.has(It),Rt=!!We.parentID,zt=V===`pinned`,Bt=yn(Ue.id)>0&&!Rt,Vt=ln(We)||Date.now(),Ht=qa(Vt),Ut=Ua(Vt),[Gt,Kt]=Q.useState(!1),qt=Gt,Jt=Q.useMemo(()=>ml(We.title)!==null,[We.title]),[Yt,Xt]=Q.useState(!1),Zt=Q.useMemo(()=>Vb(r).length,[r]),en=vt(e=>{let t=Ke??``,n=(Le()??Se(t,qe)).getTranscript(Ne(t,e)),r=qe.getState().session.find(t=>t.id===e)?.revert?.messageID;return nn({sessionID:e,messages:we(n),parts:n.partsByMessageID,revertMessageID:r}).list}),tn=vt(async e=>{let t=[],r=0;for(let i of e)try{await Je.ensureSessionRenderable(i.session.id);let e=en(i.session.id),a=i.session.title||n(`sessions.sidebar.session.export.untitledSubagent`),o=i.session.agent,s=await tn(i.children);r+=s.skipped,t.push({title:a,agent:o,records:e,children:s.children})}catch{r+=Vb(i).length+1}return{children:t,skipped:r}}),rn=vt(e=>{e<=0||X.warning(n(e===1?`sessions.sidebar.session.export.skippedSubtaskSingle`:`sessions.sidebar.session.export.skippedSubtaskMany`,{count:e}))}),an=vt(async e=>{if(!Ke){X.error(n(`sessions.sidebar.session.export.nothingToExport`));return}await Je.ensureSessionRenderable(Ue.id);let t=en(Ue.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 tn(r.children);i=e.children,a=e.skipped}let o=Ly(t,We.title??null,i),s=Hy(We.title??null),c=await zy(o,s);if(c){X.success(n(`sessions.sidebar.session.export.success`),{action:{label:n(Vy()),onClick:()=>{By(c).then(e=>{e||X.error(n(`sessions.sidebar.session.export.failedRevealPath`))})}}}),rn(a);return}Ry(o,s),X.success(n(`sessions.sidebar.session.export.success`)),rn(a)}),on=vt(async()=>{if(r.children.length>0){nt(!0),et(!0);return}await an(!1)}),sn=vt(()=>{Ke&&ee(`desktop_open_session_mini_chat_window`,{sessionId:Ue.id,directory:Ke,apiBaseUrl:m(),clientToken:t()}).catch(e=>{console.warn(`[session-sidebar] failed to open mini chat window`,e)})});bt(He,()=>{Ie.current(Be.current)},f===Ue.id),Q.useLayoutEffect(()=>{if(f!==Ue.id){Ve.current===Ue.id&&(Ve.current=null);return}Ve.current!==Ue.id&&(Ve.current=Ue.id,ze(h),queueMicrotask(()=>q.current?.select()))},[f,h,Ue.id]);let cn=vt(e=>{if(!e&&Fe.current){let{id:e,title:t}=Fe.current;Fe.current=null,p(e),g(t)}}),un=vt(e=>{Kt(e)}),fn=vt(e=>{e.preventDefault(),e.stopPropagation()}),pn=vt(e=>{e.preventDefault(),e.stopPropagation()}),mn=vt(e=>{e.preventDefault(),e.stopPropagation(),D(null),S(Ue.id)}),hn=vt(e=>{e.preventDefault(),e.stopPropagation(),D(null),I(Ue,{archivedBucket:s})}),gn=vt(e=>{e.preventDefault(),e.stopPropagation(),D(null),I(Ue,{archivedBucket:s,hardDelete:!0,skipConfirm:!0})}),_n=vt(e=>{e.preventDefault(),e.stopPropagation(),D(null),S(Ue.id)}),vn=vt(()=>{!Ke||rt||(at(!0),(async()=>{try{await Je.refreshSessionTranscript(Ue.id,{directory:Ke}),X.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{X.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{at(!1)}})())}),bn=vt(e=>{e.preventDefault(),e.stopPropagation()}),xn=vt(e=>{e.preventDefault(),e.stopPropagation()}),Sn=vt(e=>{e.preventDefault(),e.stopPropagation(),_e?.vscode?.executeCommand(`yuri.openSessionInEditor`,Ue.id,xt)}),Cn=vt(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=Wy.getState().anchorId,n=new Map;n.set(Ue.id,Vb(r)),Qe(t,Ue.id,e,Ke??null,n);return}Ze(Ue.id,Ke??null,Vb(r));return}b(Ue.id,Ke,o,V)}),wn=vt(e=>{e.defaultPrevented||e.target?.closest(`button, a, input, [role="menuitem"], [role="menu"]`)||Cn(e)}),Tn=vt(e=>{(e.button===2||e.button===0&&e.ctrlKey&&!Ye)&&(Ae.current=!0)}),En=vt(e=>{je.current=e.pointerType===`mouse`,L&&e.pointerType===`touch`&&Pe(!0)}),Dn=vt(e=>{L&&e.pointerType===`touch`&&Pe(!1)}),kn=vt(e=>{e.key!==`Enter`||!je.current||(e.preventDefault(),e.stopPropagation(),x(Ue.id,xt))}),jn=vt(e=>{if(Cn(e),!je.current)return;let t=e.currentTarget;window.requestAnimationFrame(()=>{je.current=!0,t.focus({preventScroll:!0})})}),Mn=vt(()=>{je.current=!1}),Nn=vt(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)}),Pn=vt(()=>{!Lt&&!ot&&(st(!0),Je.loadChildren(Ue.id,Ke).catch(()=>X.error(n(`sessions.sidebar.session.subsessions.loadFailed`))).finally(()=>st(!1))),y(It)});if(f===Ue.id){let e=async()=>{v();try{await $t(Ue.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:Ga(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(),_(Re)},children:[(0,$.jsx)(`input`,{ref:q,value:Re,onChange:e=>ze(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`})})]}),he?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}),le?(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]})})]})},Ue.id)}let Fn=ut,In=Nt&&Dt>Date.now()&&Ot!==Dt,Ln=ft.length,Rn=pt.length>0,zn=Rn||Fn||!Rn&&!Fn&&Bt,Bn=!R||fe,Vn=Rn?(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`})}):Fn?(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)(Ys,{})}):(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)]`})}),Hn=!zt&&!Rt&&Pt,Un=Hn&&!R&&!ot,Wn=Ga(Math.max(0,i-1)),Jn=Hn?(0,$.jsx)(`span`,{role:`button`,tabIndex:0,"aria-expanded":Lt,"aria-busy":ot,onClick:e=>{e.stopPropagation(),e.currentTarget.blur(),Pn()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),Pn())},style:{minWidth:14,minHeight:14,left:Wn},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`,he?`top-1/2 -translate-y-1/2`:`top-[14.5px] -translate-y-1/2`,Un?`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:ot?(0,$.jsx)(Ys,{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,Yn=lt?(0,$.jsx)(Z,{name:`error-warning`,className:`h-4 w-4 text-status-warning`}):null,Xn=(0,$.jsx)(G,{children:(0,$.jsx)(W,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(ye,{"data-slot":`dropdown-menu-content`,finalFocus:()=>!(O||K.current),style:{color:`var(--surface-elevated-foreground)`},className:J(Co,`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:Ue.id,title:xt}},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(Ue.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`)]}),Gn()&&!We.share?(0,$.jsxs)(e,{onClick:()=>C(We),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`share-2`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.share`)]}):Gn()&&We.share?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(e,{onClick:()=>{We.share?.url&&T(We.share.url,Ue.id)},className:`[&>svg]:mr-1`,children:w===Ue.id?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`check`,className:`mr-1 h-4 w-4`,style:{color:`var(--status-success)`}}),n(`sessions.sidebar.session.menu.copied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`file-copy`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.copyLink`)]})}),(0,$.jsxs)(e,{onClick:()=>E(Ue.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:()=>{on()},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:!Ke||rt,onClick:()=>{vn()},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)(Tb,{className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.runFusion`)]}):null,Ke&&!s?(()=>{let o=k(Ke),s=A(Ke,Ue.id);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(t,{}),(0,$.jsxs)(r,{children:[(0,$.jsxs)(i,{className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`folder`,className:`h-4 w-4`}),n(`sessions.sidebar.folders.moveToFolder`)]}),(0,$.jsxs)(a,{className:`min-w-[180px]`,children:[o.length===0?(0,$.jsx)(e,{disabled:!0,className:`text-muted-foreground`,children:n(`sessions.sidebar.folders.none`)}):o.map(t=>(0,$.jsxs)(e,{onClick:()=>{s===t.id?j(Ke,Ue.id):M(Ke,t.id,Ue.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=N(Ke);e&&M(Ke,e.id,Ue.id)},children:[(0,$.jsx)(Z,{name:`add`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.folders.newFolderEllipsis`)]}),s?(0,$.jsxs)(e,{onClick:()=>{j(Ke,Ue.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,ge?(0,$.jsxs)(e,{disabled:!Ke,onClick:sn,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(Ue,{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(Ue,{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)(ae,{className:J(To,e),...t}),Separator:({className:e,...t})=>(0,$.jsx)(ie,{className:J(wo,e),...t}),Sub:oe,SubTrigger:({className:e,children:t,...n})=>(0,$.jsxs)(me,{className:J(So,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)(G,{children:(0,$.jsx)(W,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(ye,{"data-slot":`dropdown-menu-sub-content`,style:{color:`var(--surface-elevated-foreground)`},className:J(Co,`yuri-session-context-menu`,e),...n,children:t})})})})})})});return(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(mc,{sessionId:Ue.id,sessionDirectory:Ke??null,sessionTitle:xt,children:(0,$.jsxs)(se,{open:Gt,onOpenChange:un,onOpenChangeComplete:cn,children:[(0,$.jsxs)(pe,{render:(0,$.jsx)(`div`,{ref:gt,"data-session-row":Ue.id,"data-session-scope":Ke??``,"data-session-focus-scope":V,"data-session-focus-key":ht,"data-session-project-id":o??``,"data-session-archived":s?`1`:`0`,"data-session-depth":i,onClick:wn,onMouseLeave:Nn,className:J(`group relative my-0.5 flex cursor-pointer items-center rounded-lg py-1.5 pr-2`,yt&&!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)]`,!yt&&!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:[Jn,(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,style:{paddingLeft:Ga(i)},children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:(0,$.jsxs)(ca,{children:[(0,$.jsx)(aa,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onPointerDown:En,onPointerUp:Dn,onPointerCancel:Dn,onMouseDown:Tn,onKeyDown:kn,onBlur:Mn,onClick:jn,onDoubleClick:e=>{e.stopPropagation(),x(Ue.id,xt)},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)]`,R?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`,In&&`animate-text-shimmer`),"aria-busy":In||void 0,children:va(xt,d)}),St?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro tabular-nums text-muted-foreground`,children:St}):null,Ge?(0,$.jsx)(Z,{name:`ai-agent`,className:`size-3 shrink-0 text-muted-foreground`,"aria-label":`Assistant`}):null,Ln>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:Ln})]}):null,zn?(0,$.jsx)(`span`,{className:J(`inline-flex shrink-0 items-center justify-center transition-none`,Bn?J(`group-hover:hidden group-focus-within:hidden`,qt?`hidden`:``):qt?`invisible`:``),children:Vn}):null,ce?(0,$.jsx)(Wb,{number:ce}):null]})})}),fe?null:(0,$.jsx)(oa,{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:xt}),(0,$.jsx)(`div`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:Ut})]}),le?(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]})})]})})}),Yn&&!L?(0,$.jsx)(`div`,{className:J(`absolute top-1/2 -translate-y-1/2 z-10`,he?`right-0`:`right-[30px]`),children:Yn}):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||R&&!fe?`opacity-100`:J(`opacity-0`,ve)),children:[Ce?(0,$.jsx)(Hb,{pinned:Ft,pinLabel:n(Ft?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`),buttonSizeClass:Te,iconSizeClass:Ee,onPointerDown:fn,onMouseDown:pn,onPin:mn}):null,xe?(0,$.jsxs)(ca,{children:[(0,$.jsx)(aa,{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`,Te),"aria-label":n(`sessions.sidebar.session.actions.pinned`),onPointerDown:fn,onMouseDown:pn,onClick:_n,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(Z,{name:`pushpin-2-fill`,className:Ee})})}),(0,$.jsx)(oa,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:n(`sessions.sidebar.session.actions.pinned`)})]}):null,be?(0,$.jsxs)(ca,{children:[(0,$.jsx)(aa,{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`,Te),"aria-label":n(`sessions.sidebar.session.actions.openInEditor`),onPointerDown:bn,onMouseDown:xn,onClick:Sn,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(Z,{name:`external-link`,className:Ee})})}),(0,$.jsx)(oa,{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)(Ub,{archiveLabel:n(`sessions.sidebar.bulkActions.archive`),deleteLabel:n(`sessions.sidebar.bulkActions.delete`),deleteOnly:s===!0,buttonSizeClass:Te,iconSizeClass:Ee,revealClassName:he&&!R&&!qt?J(`opacity-0`,ve):`opacity-100`,onPointerDown:fn,onMouseDown:pn,onArchive:hn,onDelete:gn})]})]}),Xn]})}),!zt&&Pt&&Lt?r.children.map(e=>{let t=re?re(e):{subtreeContainsActive:H,subtreeContainsEditing:te,menuOpenSessionId:ne,nodeStructureKey:``};return z(e,i+1,Ke??a,o,s,void 0,V,t)}):null,(0,$.jsx)(fr,{open:$e,onOpenChange:et,children:(0,$.jsxs)(lr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,$.jsxs)(sr,{children:[(0,$.jsx)(ur,{children:n(`sessions.sidebar.session.export.dialog.title`)}),(0,$.jsx)(dr,{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)(cr,{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),an(tt)},size:`sm`,children:n(`sessions.sidebar.session.export.dialog.confirm`)})]})]})}),Jt?(0,$.jsx)(wb,{session:We,open:Yt,onOpenChange:Xt}):null]},Ue.id)}var Kb=e=>dt(e.session.directory??null),qb=(e,t)=>(e?.projectLabel??null)===(t?.projectLabel??null)&&(e?.branchLabel??null)===(t?.branchLabel??null),Jb=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},Yb=e=>e.menuOpenSessionId??Jb(e),Xb=(e,t,n)=>t?n.has(e.node.session.id)?!0:Ev(e.node,t):!1,Zb=(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(Zb(e.children[a],t.children[a],n,r,i))return!0;return!1},Qb=(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(Qb(e.children[i],t.children[i],n,r))return!0;return!1},$b=(e,t)=>{if(e.hasSessionSearchQuery||t.hasSessionSearchQuery)return!1;let n=e.archivedBucket?`archived`:`active`,r=t.archivedBucket?`archived`:`active`;return Zb(e.node,t.node,e.expandedParents,t.expandedParents,t=>`${e.renderContext??`project`}:${n}:${t.session.id}`)||Zb(e.node,t.node,e.expandedParents,t.expandedParents,e=>`${t.renderContext??`project`}:${r}:${e.session.id}`)},ex=Q.memo(Gb,(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||Kb(e.node)!==Kb(t.node)||!qb(e.secondaryMeta,t.secondaryMeta)||e.liveSessionById!==t.liveSessionById&&Qb(e.node,t.node,e.liveSessionById,t.liveSessionById)||e.pinnedSessionIds!==t.pinnedSessionIds&&Zb(e.node,t.node,e.pinnedSessionIds,t.pinnedSessionIds,e=>e.session.id)||e.expandedParents!==t.expandedParents&&$b(e,t)||e.currentSessionId!==t.currentSessionId&&(Xb(e,e.currentSessionId,e.subtreeContainsActive)||Xb(t,t.currentSessionId,t.subtreeContainsActive))||e.editingId!==t.editingId&&(Xb(e,e.editingId,e.subtreeContainsEditing)||Xb(t,t.editingId,t.subtreeContainsEditing))||e.editTitle!==t.editTitle&&(Xb(e,e.editingId,e.subtreeContainsEditing)||Xb(t,t.editingId,t.subtreeContainsEditing))||e.copiedSessionId!==t.copiedSessionId&&(Ev(e.node,e.copiedSessionId)||Ev(t.node,t.copiedSessionId)))return!1;if(e.openSidebarMenuKey!==t.openSidebarMenuKey){let n=Yb(e),r=Yb(t);if(Ev(e.node,n)||Ev(t.node,r))return!1}if(e.renamingFolderId!==t.renamingFolderId){let n=Yb(e),r=Yb(t);if(Ev(e.node,n)||Ev(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 tx(e){return e.stopPropagation()}function nx(e){return e.stopPropagation()}function rx(e){let t=(0,xl.c)(71),{t:n}=Tt(),{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=fr,g=!!r,t[13]===i?_=t[14]:(_=e=>{e||i(null)},t[13]=i,t[14]=_),u=lr,m=!1,h=`max-w-sm gap-5`,l=sr;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)(ur,{children:a}),t[18]=a,t[19]=p),c=dr,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)(cr,{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 ix(e){let t=(0,xl.c)(57),{t:n}=Tt(),{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)(ur,{children:d}),t[10]=d,t[11]=g);let _;t[12]===p?_=t[13]:(_=(0,$.jsx)(dr,{children:p}),t[12]=p,t[13]=_);let v;t[14]!==g||t[15]!==_?(v=(0,$.jsxs)(sr,{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)(cr,{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)(lr,{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)(fr,{open:m,onOpenChange:h,children:M}),t[53]=m,t[54]=M,t[55]=h,t[56]=N):N=t[56],N}function ax(e){let t=(0,xl.c)(36),{t:n}=Tt(),{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)(ur,{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)(dr,{children:u}),t[9]=u,t[10]=d);let f;t[11]!==l||t[12]!==d?(f=(0,$.jsxs)(sr,{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)(cr,{children:[h,_]}),t[26]=_,t[27]=h,t[28]=v):v=t[28];let y;t[29]!==v||t[30]!==f?(y=(0,$.jsxs)(lr,{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)(fr,{open:o,onOpenChange:s,children:y}),t[32]=o,t[33]=s,t[34]=y,t[35]=b):b=t[35],b}var ox=e=>{let t=(0,xl.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}=Tt(),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)(Ba,{children:[(0,$.jsxs)(ca,{children:[(0,$.jsx)(aa,{asChild:!0,children:(0,$.jsx)(Sa,{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)(oa,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:f(`sessions.sidebar.bulkActions.moveToFolder`)})})]}),(0,$.jsxs)(Pa,{align:`end`,className:`min-w-[180px]`,children:[i.length===0?(0,$.jsx)(La,{disabled:!0,className:`text-muted-foreground`,children:f(`sessions.sidebar.folders.none`)}):i.map(e=>(0,$.jsx)(La,{onClick:()=>o(e.id),children:(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e.name})},e.id)),(0,$.jsx)(za,{}),(0,$.jsxs)(La,{onClick:s,children:[(0,$.jsx)(Z,{name:`add`,className:`mr-1 h-4 w-4`}),f(`sessions.sidebar.folders.newFolderEllipsis`)]}),l?(0,$.jsxs)(La,{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)(aa,{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)(oa,{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)(ca,{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)(aa,{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)(oa,{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)(ca,{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},sx=e=>{let{t}=Tt(),{isInlineEditing:n,showDeletionDialog:r,foldersMap:i,addSessionsToFolder:a,removeSessionsFromFolders:o,createFolderAndStartRename:s,archiveSessions:c,setBulkDeleteConfirm:l}=e,u=Wy(e=>e.enabled),d=Wy(e=>e.selectedIds.size),f=d>0,p=Wy(e=>e.selectedIds),m=Wy(e=>e.scopeKey),h=Q.useCallback(()=>{Wy.getState().toggleMode()},[]),g=Q.useCallback(()=>{Wy.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(_)nc({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&&qs({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}))}Wy.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(),Wy.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=Wy.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;Wy.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}},cx=(e,t,n)=>{let r=[],i=new Set,a=e=>{let t=dt(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},lx=(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},ux=({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=lx(r,e,o,i)??{scope:`project`,sessionId:e,projectId:i};return!a||t.scope===`project`?s:lx(n,e,o,i)??s};function dx(e,t,n=null){if(!e||e.scope!==`project`||!e.sessionId)return null;if(e.projectId){let n=t.find(t=>t.sessionId===e.sessionId&&t.projectId===e.projectId);if(n)return n}if(n){let r=t.find(t=>t.sessionId===e.sessionId&&t.projectId===n);if(r)return r}return t.find(t=>t.sessionId===e.sessionId)??null}var fx=`yuri.sessions.projectCollapse`,px=`yuri.sessions.groupOrder`,mx=`yuri.sessions.groupCollapse`,hx=`yuri.sessions.activeSessionByProject`,gx=`yuri.sessions.expandedParents.v2`,_x=`yuri.sessions.expandedParents`,vx=Je(Ve()),yx=e=>{try{let t=vx.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}},bx=e=>{try{let t=vx.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}},xx=e=>{try{let t=vx.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}},Sx=(e,t,n)=>{let r=new Set;for(let t of e){let e=dt(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=dt(t.path)?.toLowerCase();e&&r.add(e)}return r},Cx=(e,t,n)=>{if(e.time?.archived)return!0;let r=dt(Yt(e))?.toLowerCase();return r?t.size===0?n?.allowEmptyDirectorySet??!0:t.has(r):n?.allowUnknownDirectory??!0},wx=new Set,Tx=[],Ex={},Dx=e=>{let t=Q.useRef(e);return t.current=e,Q.useMemo(()=>(...e)=>t.current(...e),[])},Ox=Q.memo(function(e){let t=(0,xl.c)(3),{onOpenChange:n}=e,r=Ds(U(Ax)),i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(ms,{open:!0,onOpenChange:n,...r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}),kx=Q.memo(function({mobileVariant:e=!1,onSessionSelected:t,allowReselect:n=!1,hideDirectoryControls:r=!1,showOnlyMainWorkspace:i=!1,isVisible:a=!0}){let{t:o}=Tt(),[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,w]=Q.useState(new Set),T=Q.useMemo(()=>vx,[]),[E,D]=Q.useState(new Set),[O,k]=Q.useState(new Map),[A,j]=Q.useState(new Map),M=q(e=>e.isNewWorktreeDialogOpen),N=q(e=>e.setNewWorktreeDialogOpen),[P,ee]=Q.useState(null),[L,R]=Q.useState(null),[z,B]=Q.useState(``),[V,H]=Q.useState(null),[te,ne]=Q.useState(null),[re,U]=Q.useState(null),ie=hn(),ae=gn(),[W,oe]=Q.useState(()=>yx(mx)),[G,se]=Q.useState(()=>xx(px)),[ce,le]=Q.useState(()=>bx(hx));Q.useEffect(()=>s(e=>{p(e)&&(oe(yx(mx)),se(xx(px)),le(bx(hx)),D(yx(fx)),w(yx(gx)))}),[]);let[ue,de]=Q.useState(new Map),fe=Q.useRef(0),pe=Ae(e=>e.homeDirectory),me=Ae(e=>e.currentDirectory),he=Ae(e=>e.setDirectory),ge=Tn(e=>e.projects),_e=Tn(e=>e.activeProjectId),ve=Tn(e=>e.removeProject),ye=Tn(e=>e.setActiveProjectIdOnly),be=Tn(e=>e.updateProjectMeta),xe=Tn(e=>e.reorderProjectsById),Se=q(e=>e.setActiveMainTab),Ce=q(e=>e.activeMainTab),we=Lt(),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),je=q(e=>e.showDeletionDialog),Me=q(e=>e.setShowDeletionDialog),Ne=Yi(f,120),Pe=Q.useMemo(()=>Ne.trim().toLowerCase(),[Ne]),K=Pe.length>0,Fe=Ds(e=>e.available&&(e.runtimeType===`desktop`||e.runtimeType===`web`)),Ie=Kt(e=>e.collapsedFolderIds),Le=Kt(e=>e.foldersMap),Re=Kt(e=>e.sessionOrderByScope),ze=Kt(e=>e.sessionOrderActivityByScope),Be=Kt(e=>e.getFoldersForScope),Ve=Kt(e=>e.createFolder),He=Kt(e=>e.renameFolder),Ue=Kt(e=>e.deleteFolder),We=Kt(e=>e.addSessionToFolder),Ge=Kt(e=>e.addSessionsToFolder),Ke=Kt(e=>e.removeSessionFromFolder),qe=Kt(e=>e.removeSessionsFromFolders),Je=Kt(e=>e.toggleFolderCollapse),Ye=Kt(e=>e.getSessionFolderId),Xe=Kt(e=>e.reorderSessions);ev({isSessionSearchOpen:a&&u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchContainerRef:h});let Ze=Q.useMemo(()=>new Map,[]),Qe=pn({enabled:a,includeChildren:!0}),$e=Fc({enabled:a}),et=wc({enabled:a}),tt=jn(e=>a?e.index.session.unseenCount:Ex),nt=Q.useMemo(()=>F(),[]),rt=Zt(e=>e.status),it=Zt(e=>e.activeSessions),at=Zt(e=>e.archivedSessions),ot=Zt(e=>e.loadingDirectories.size>0||e.refreshingDirectories.size>0),st=Zt(e=>e.archivedLoadingDirectories),ct=Q.useDeferredValue(it),lt=Q.useDeferredValue(at),ut=zn(e=>e.currentSessionId),ft=Bi(e=>e.focus),pt=Q.useSyncExternalStore(Dn,kn,kn),mt=zn(e=>!!e.newSessionDraft?.open),ht=zn(e=>e.setCurrentSession),gt=zn(e=>e.updateSessionTitle),_t=zn(e=>e.shareSession),yt=zn(e=>e.unshareSession),bt=zn(e=>e.worktreeMetadata),xt=zn(e=>e.availableWorktreesByProject),St=zn(e=>e.openNewSessionDraft),Ct=vt(e=>{St(e),nt&&window.dispatchEvent(new CustomEvent(`yuri:navigate`,{detail:{view:`chat`}}))}),wt=Q.useMemo(()=>Sx(ge,xt,{includeWorktrees:!nt}),[xt,nt,ge]),Et=Q.useMemo(()=>{let e=new Map(Qe.map(e=>[e.id,e])),t=ct.map(t=>{let n=e.get(t.id);return n?Xt(n,t):t}),n=new Set(t.map(e=>e.id));return Qe.forEach(e=>{n.has(e.id)||t.push(e)}),t.filter(e=>Cx(e,wt,{allowUnknownDirectory:!nt,allowEmptyDirectorySet:!nt}))},[ct,nt,wt,Qe]),Dt=Q.useMemo(()=>Qe.map(e=>{let t=dt(e.directory??null)??``;return`${e.id}:${e.title??``}:${+!!e.time?.archived}:${t}`}).join(`|`),[Qe]),kt=Q.useRef(Qe);Q.useEffect(()=>{kt.current=Qe},[Dt,Qe]);let At=Q.useMemo(()=>new Map(Qe.map(e=>[e.id,e])),[Qe]);Q.useEffect(()=>{let e=null,t=Gt(t=>{t.type===`scheduled-task-ran`&&(e&&clearTimeout(e),e=setTimeout(()=>{let e=Tn.getState().projects.find(e=>e.id===t.projectId),n=dt(e?.path??null);if(!n)return;let r=[n];(zn.getState().availableWorktreesByProject.get(n)??[]).forEach(e=>{let t=dt(e.path);t&&r.push(t)}),mn(r,kt.current)},500))});return()=>{e&&clearTimeout(e),t()}},[]);let jt=Q.useMemo(()=>I(),[]),Mt=Ol(),Nt=Es(e=>e.sidebarBrandName.trim().length>0),{isTablet:Pt}=Za(),Ft=e||Pt,{buildGroupSearchText:It,filterSessionNodesForSearch:zt,buildGroupedSessions:Bt}=$_({homeDirectory:pe,worktreeMetadata:bt,pinnedSessionIds:ie,gitBranches:Ze,isVSCode:nt}),{scheduleCollapsedProjectsPersist:Vt,hasRestoredProjectCollapse:Ht}=sv({isVSCode:nt,safeStorage:T,keys:{sessionExpanded:gx,sessionExpandedLegacy:_x,projectCollapse:fx,groupOrder:px,projectActiveSession:hx,groupCollapse:mx},groupOrderByProject:G,activeSessionByProject:ce,collapsedGroups:W,setExpandedParents:w,setCollapsedProjects:D}),Ut=Q.useMemo(()=>[...Et].sort((e,t)=>Ea(e,t,ie)),[Et,ie]),Wt=Q.useMemo(()=>{let e=new Map;return Ut.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)=>Ea(e,t,ie))),e},[Ut,ie]),qt=(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`)})]}),Jt=Q.useMemo(()=>ge.find(e=>e.id===x)??null,[ge,x]),Qt=Q.useCallback(e=>{x&&be(x,{label:e.label,icon:e.icon,color:e.color,iconBackground:e.iconBackground,defaultModel:e.defaultModel??null})},[x,be]),$t=Q.useCallback(()=>{N(!0)},[N]),en=Q.useCallback((t,n)=>{if(Se(`chat`),e&&De(!1),n?.sessionId){ht(n.sessionId,t);return}St({directoryOverride:t,preserveDirectoryOverride:!0})},[e,St,Se,ht,De]),tn=vt(()=>{let e=Ds.getState();if(e.available&&e.info){l(!0);return}e.checkForUpdates().then(()=>{let{available:e,error:t}=Ds.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)})}),nn=Q.useCallback(()=>{e&&De(!1),Te(!0)},[e,De,Te]),an=Q.useCallback(()=>{Se(`chat`),St(),e&&De(!1)},[e,St,Se,De]),on=Q.useCallback(()=>{if(!e){Se(`schedule`);return}Oe(!0),De(!1)},[e,Se,Oe,De]),sn=Q.useCallback(()=>{nr(),e&&De(!1)},[e,De]),cn=zn(e=>e.archiveSession),ln=zn(e=>e.archiveSessions),{copiedSessionId:un,handleSessionSelect:dn,handleSessionDoubleClick:_n,handleSaveEdit:vn,handleCancelEdit:yn,handleShareSession:bn,handleCopyShareUrl:xn,handleUnshareSession:Sn,handleDeleteSession:Cn,confirmDeleteSession:wn}=tv({activeProjectId:_e,currentDirectory:me,currentSessionId:ut,mobileVariant:e,allowReselect:n,onSessionSelected:t,isSessionSearchOpen:u,sessionSearchQuery:f,setSessionSearchQuery:m,setIsSessionSearchOpen:d,setActiveProjectIdOnly:ye,setDirectory:he,setActiveMainTab:Se,setSessionSwitcherOpen:De,setCurrentSession:ht,updateSessionTitle:gt,shareSession:_t,unshareSession:yt,archiveSession:cn,archiveSessions:ln,childrenMap:Wt,showDeletionDialog:je,setDeleteSessionConfirm:H,deleteSessionConfirm:V,setEditingId:v,setEditTitle:b,editingId:_,editTitle:y}),En=Q.useCallback((e,t,n,r=`project`)=>{let i={sessionId:e,scope:r,projectId:n??null};if(e===ut){Ln(e),Bb(i),dn(e,t,n);return}Rb(i,()=>dn(e,t,n))},[dn,ut]);Q.useEffect(()=>()=>{Lb()},[]);let On=Q.useCallback(()=>{if(!te)return;let{scopeKey:e,folderId:t}=te;ne(null),Ue(e,t)},[te,Ue]);Q.useEffect(()=>{if(!ut)return;let e=Et.find(e=>e.id===ut)?.parentID;if(!e)return;let t=[`project:active:${e}`,`project:archived:${e}`,`recent:active:${e}`,`recent:archived:${e}`];w(e=>{if(t.every(t=>e.has(t)))return e;let n=new Set(e);t.forEach(e=>n.add(e));try{T.setItem(gx,JSON.stringify(Array.from(n)))}catch{}return n})},[ut,Et,T]);let An=Q.useCallback(e=>{w(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{T.setItem(gx,JSON.stringify(Array.from(n)))}catch{}return n})},[T]),Mn=Q.useCallback((e,t)=>{if(!e)return null;t&&Ie.has(t)&&Je(t);let n=Ve(e,o(`sessions.sidebar.folder.newFolderName`),t);return R(n.id),B(n.name),n},[Ie,Je,Ve,o]),Nn=vt(En),Pn=vt(_n),Fn=vt(vn),In=vt(yn),Rn=vt(bn),Bn=vt(xn),Vn=vt(Sn),Un=vt(Cn),Wn=vt(Mn),Gn=vt((e,t,n,r)=>{let i=ic(),a=Math.max(i,n)+7;if(j(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=dt(e.directory??null);if(!o)return;let s=Zt.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&Rt(o)}),Kn=vt(e=>{j(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})}),Jn=vt(e=>{j(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=dt(t?.path??null);if(!n)return[];let r=[n];return nt||(xt.get(n)??[]).forEach(e=>{let t=dt(e.path);t&&r.push(t)}),r},[xt,nt,ge]),Xn=vt(e=>{let t=Yn(e);if(t.length===0)return;let n=Zt.getState().loadedDirectories,r=t.filter(e=>!n.has(e));r.length!==0&&mn(r,kt.current)}),Zn=vt(e=>{let t=ge.find(t=>t.id===e);t&&(async()=>{let e=[];if(!nt)try{e=(await vo({id:t.id,path:t.path})).worktrees}catch(n){console.warn(`[SessionSidebar] Worktree refresh before session sync failed:`,n);let r=dt(t.path);e=r?zn.getState().availableWorktreesByProject.get(r)??[]:[]}let n=cx(t.path,e,{currentDirectory:me,workspaceRoot:t.path,includeWorktrees:!nt});n.length!==0&&await Hn(n,kt.current)})()});Q.useEffect(()=>{if(!Ht)return;let e=Zt.getState(),t=ge.flatMap(t=>E.has(t.id)?[]:Yn(t.id).filter(t=>!e.loadedDirectories.has(t)&&!e.loadingDirectories.has(t)&&!e.refreshingDirectories.has(t)));t.length>0&&mn(t,kt.current)},[E,Yn,Ht,ge]);let Qn=vt(()=>{fe.current=Date.now()+150,j(new Map),D(()=>{let e=new Set(ge.map(e=>e.id));try{T.setItem(fx,JSON.stringify(Array.from(e)))}catch{}return nt||Vt(e),e})}),$n=vt(()=>{fe.current=Date.now()+150,j(new Map),D(()=>{let e=new Set;try{T.setItem(fx,JSON.stringify([]))}catch{}return nt||Vt(e),e});let e=Zt.getState().loadedDirectories,t=ge.flatMap(t=>Yn(t.id).filter(t=>!e.has(t)));t.length>0&&mn(t,kt.current)}),er=vt(e=>{fe.current=Date.now()+150,Jn(e),D(t=>{let n=new Set(t);n.has(e)?(n.delete(e),queueMicrotask(()=>Xn(e))):n.add(e);try{T.setItem(fx,JSON.stringify(Array.from(n)))}catch{}return nt||Vt(n),n})}),tr=vt(e=>{fe.current=Date.now()+150,Xn(e),D(t=>{if(!t.has(e))return t;let n=new Set(t);n.delete(e);try{T.setItem(fx,JSON.stringify(Array.from(n)))}catch{}return nt||Vt(n),n})}),rr=Q.useMemo(()=>ge.map(e=>({...e,normalizedPath:dt(e.path)})).filter(e=>!!e.normalizedPath),[ge]),ir=Q.useMemo(()=>rr.map(e=>e.normalizedPath),[rr]),ar=Q.useMemo(()=>{let e=new Set(rr.map(e=>e.normalizedPath));if(!nt)for(let t of xt.values())for(let n of t){let t=dt(n.path);t&&e.add(t)}return[...e].sort()},[xt,nt,rr]),or=Q.useRef(null);Q.useEffect(()=>{let e=new Set(ar),t=or.current;if(or.current=e,!t)return;let n=ar.filter(e=>!t.has(e));if(n.length===0)return;let r=Zt.getState().loadedDirectories,i=dt(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),nt||(xt.get(a.normalizedPath)??[]).forEach(e=>{let t=dt(e.path);t&&o.add(t)}));let s=n.filter(e=>o.has(e)&&!r.has(e));s.length!==0&&mn(s,kt.current)},[_e,xt,me,nt,rr,ar]);let sr=Xi(a?ir:Tx);lv({normalizedProjects:rr,activeProjectId:_e,gitRepoStatus:sr,setProjectRepoStatus:k,setProjectRootBranches:de,enabled:a});let cr=Q.useMemo(()=>ps(Et,rr,xt,nt,lt),[lt,xt,nt,rr,Et]),{getSessionsForProject:lr,getArchivedSessionsForProject:ur}=uv({ownership:cr}),dr=ot||rt===`idle`||rt===`loading`,fr=Q.useRef(!1);_e&&O.has(_e)&&(fr.current=!!O.get(_e));let pr=qn(e=>e.projectSortOrder),mr=Q.useMemo(()=>Cc(rr,pr),[rr,pr]),{projectSections:hr,groupSearchDataByGroup:gr,sectionsForRender:_r,searchMatchCount:vr}=X_({normalizedProjects:mr,getSessionsForProject:lr,getArchivedSessionsForProject:ur,availableWorktreesByProject:xt,projectRepoStatus:O,projectRootBranches:ue,lastRepoStatus:fr.current,buildGroupedSessions:Bt,hasSessionSearchQuery:K,normalizedSessionSearchQuery:Pe,filterSessionNodesForSearch:zt,buildGroupSearchText:It,foldersMap:Le}),yr=(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`)})]});Z_({projectSections:hr,activeProjectId:_e,activeSessionByProject:ce,setActiveSessionByProject:le,currentSessionId:ut,handleSessionSelect:dn,newSessionDraftOpen:mt,mobileVariant:e,openNewSessionDraft:St,setActiveMainTab:Se,setSessionSwitcherOpen:De});let{getOrderedGroups:br}=Q_(G),xr=Q.useRef(!1);Q.useEffect(()=>{if(xr.current||hr.length===0)return;let e=hr.flatMap(e=>e.groups.filter(e=>e.isArchivedBucket).map(t=>`${e.project.id}:${t.id}`));e.length>0&&oe(t=>new Set([...t,...e])),xr.current=!0},[hr]);let Sr=Q.useMemo(()=>{let e=new Map,t=new Map;return hr.forEach(n=>{let r=Ot(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},[hr]);Q.useLayoutEffect(()=>{if(!ut){Bb(null);return}let e=Bi.getState().focus;if(e?.sessionId===ut){e.scope===`project`&&!e.projectId&&Bb({...e,projectId:Sr.get(ut)?.projectId??null});return}Bb({scope:`project`,sessionId:ut,projectId:Sr.get(ut)?.projectId??null})},[ut,Sr]);let Cr=Q.useMemo(()=>nt?[]:Ac(Et,ie,Re[cc]),[nt,ie,Et,Re]),wr=vt((e,t)=>{_||Xe(cc,Cr.map(e=>e.id),e,t,{}).catch(()=>X.error(o(`sessions.order.saveFailed`)))}),Tr=Q.useMemo(()=>K?[]:Ic(Et,ie,et,tt),[K,ie,et,Et,tt]),{pinnedItems:Er,inProgressItems:Dr}=Q.useMemo(()=>{let e=e=>{let t=Sr.get(e.id),n=dt(e.directory??null),r={session:e,children:[],worktree:bt.get(e.id)??null};if(K&&zt([r],Pe).length===0)return null;let i=cr.bySessionId.get(e.id),a=i?mr.find(e=>e.id===i.projectId):void 0,o=a?Ot(a.normalizedPath)||a.normalizedPath:t?.secondaryMeta?.projectLabel??null,s=fc({projectLabel:o,owner:i,sessionWorktree:bt.get(e.id)??null,worktrees:a?xt.get(a.normalizedPath)??[]:[],projectRootBranch:i?ue.get(i.projectId)??(a?sr.get(a.normalizedPath)?.branch:null)??null:null,isVSCode:nt})??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:nt?[]:t(Cr),inProgressItems:t(Tr)}},[xt,zt,sr,K,Tr,nt,Pe,Cr,ue,cr,Sr,mr,bt]),Or=Q.useMemo(()=>_r.map(e=>({...e,groups:e.groups.filter(e=>!e.isArchivedBucket)})),[_r]),kr=Q.useMemo(()=>{let e=K?Or.map(e=>({...e,groups:e.groups.map(e=>({...e,sessions:gr.get(e)?.filteredNodes??[]}))})):Or;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,gr,K,Or,i]),Ar=Q.useMemo(()=>Nc({sections:kr,foldersMap:Le,getOrderedGroups:br,pinnedSessionIds:ie,sessionOrderByScope:Re,sessionOrderActivityByScope:ze}),[Le,br,kr,ie,ze,Re]),jr=Q.useMemo(()=>Js({targets:Ar,collapsedProjectIds:E,collapsedGroupKeys:W,collapsedFolderIds:Ie,visibleSessionCountByGroup:A,defaultVisibleSessionCount:ic(),hasSessionSearchQuery:K,alwaysVisibleSessionIds:$e}),[$e,Ie,W,E,K,Ar,A]),Mr=Q.useMemo(()=>K?[]:[...Er,...Dr].map((e,t)=>{let n=e.node.session;return{scope:`pinned`,sessionId:n.id,projectId:e.projectId,directory:dt(Yt(n))??e.groupDirectory??null,visibleIndex:t}}),[K,Dr,Er]),[Nr,Pr]=Q.useState(null),Fr=Q.useCallback(e=>{Pr(t=>t&&t.length===e.length&&t.every((t,n)=>t===e[n])?t:[...e])},[]),Ir=Q.useMemo(()=>{if(!Nr)return Mr;let e=new Set(Nr);return Mr.filter(t=>e.has(t.sessionId))},[Mr,Nr]),Lr=Q.useMemo(()=>e?[]:Fi({pinnedTargets:Ir,projectTargets:jr}),[e,Ir,jr]),Rr=Q.useCallback(e=>{Se(`chat`),De(!1),e.scope===`project`&&e.projectId&&ye(e.projectId),En(e.sessionId,e.directory,e.projectId,e.scope)},[En,Se,ye,De]);Q.useLayoutEffect(()=>Di({targets:Lr,activate:Rr}),[Rr,Lr]);let zr=Q.useMemo(()=>{let e=new Map;return Lr.forEach(t=>{let n=_i({scope:t.scope,sessionId:t.sessionId,projectId:t.projectId});n&&e.set(n,di(Lr,t)??0)}),e},[Lr]),Br=Q.useMemo(()=>{if(!ut||K)return[];let e=[],t=(n,r)=>{if(n.session.id===ut){e.push({scope:`pinned`,sessionId:ut,projectId:r});return}n.children.forEach(e=>t(e,r))};return Er.forEach(e=>t(e.node,e.projectId)),Dr.forEach(e=>t(e.node,e.projectId)),e},[ut,K,Dr,Er]),Vr=Q.useMemo(()=>{if(!ut)return[];let e=[],t=(n,r)=>{if(n.session.id===ut){e.push({scope:`project`,sessionId:ut,projectId:r});return}n.children.forEach(e=>t(e,r))};return hr.forEach(e=>{e.groups.forEach(n=>{n.sessions.forEach(n=>t(n,e.project.id))})}),e},[ut,hr]);Q.useLayoutEffect(()=>Oi({pinned:Ir,project:jr}),[Ir,jr]),Q.useLayoutEffect(()=>{dr||Bb(ux({currentSessionId:ut,focus:ft,pinnedFocuses:Br,projectFocuses:Vr,fallbackProjectId:ut?Sr.get(ut)?.projectId??null:null}))},[ut,dr,Vr,Br,ft,Sr]);let Hr=Q.useMemo(()=>{let e=ft?.sessionId?Sr.get(ft.sessionId)?.projectId??null:null;return dx(ft,Ar,e)},[Ar,ft,Sr]),Ur=Q.useRef(null),Wr=Q.useRef(null);Q.useEffect(()=>{Wr.current&&Wr.current!==ut&&(Wr.current=null)},[ut]),Q.useLayoutEffect(()=>{if(!Hr?.projectId)return;let e=Hr.sessionId,t=pt.sessionId===e;if(!(!t&&ut!==e)){if(t){if(Ur.current===pt.revision)return;Ur.current=pt.revision,Wr.current=e}else{if(Wr.current===e)return;Wr.current=e}if(tr(Hr.projectId),Hr.groupKey&&oe(e=>{if(!e.has(Hr.groupKey))return e;let t=new Set(e);return t.delete(Hr.groupKey),t}),Hr.folderAncestorIds?.forEach(e=>{let t=Kt.getState();t.collapsedFolderIds.has(e)&&t.toggleFolderCollapse(e)}),Hr.groupKey&&Hr.visibleIndex!==void 0){let e=Hr.visibleIndex+1;j(t=>{if((t.get(Hr.groupKey)??0)>=e)return t;let n=new Map(t);return n.set(Hr.groupKey,e),n})}}},[ut,Hr,pt]);let Gr=Dx((t,n=0,r,i,a=!1,o,s=`project`,c)=>(0,$.jsx)(ex,{node:t,depth:n,groupDirectory:r,projectId:i,archivedBucket:a,currentSessionId:ut,pinnedSessionIds:ie,expandedParents:C,hasSessionSearchQuery:K,normalizedSessionSearchQuery:Pe,notifyOnSubtasks:ke,editingId:_,setEditingId:v,editTitle:y,setEditTitle:b,handleSaveEdit:Fn,handleCancelEdit:In,toggleParent:An,handleSessionSelect:Nn,handleSessionDoubleClick:Pn,togglePinnedSession:ae,handleShareSession:Rn,copiedSessionId:un,handleCopyShareUrl:Bn,handleUnshareSession:Vn,openSidebarMenuKey:P,setOpenSidebarMenuKey:ee,renamingFolderId:L,getFoldersForScope:Be,getSessionFolderId:Ye,removeSessionFromFolder:Ke,addSessionToFolder:We,createFolderAndStartRename:Wn,handleDeleteSession:Un,mobileVariant:e,alwaysShowActions:Ft,renderSessionNode:Gr,secondaryMeta:o,renderContext:s,subtreeContainsActive:c?.subtreeContainsActive??wx,subtreeContainsEditing:c?.subtreeContainsEditing??wx,menuOpenSessionId:c?.menuOpenSessionId??null,nodeStructureKey:c?.nodeStructureKey??``,childRenderExtrasFor:c?.childRenderExtrasFor,liveSessionById:At,shortcutNumber:zr.get(_i({scope:s,sessionId:t.session.id,projectId:i??null})??``)??null},`${s}:${i??``}:${t.session.id}`)),Kr=Q.useCallback(e=>{Kn(e),oe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[Kn]),qr=Q.useCallback(e=>{let t=Yn(e);if(t.length===0)return;let n=Zt.getState(),r=t.filter(e=>!n.archivedLoadedDirectories.has(e));r.length>0&&fn(r)},[Yn]),Jr=vt((e,t,n,r,i)=>{let a=e.folderScopeKey??dt(e.directory??null);a&&Xe(a,t,n,r,i).catch(()=>X.error(o(`sessions.order.saveFailed`)))}),Yr=vt((e,t,n)=>{e.isArchivedBucket&&W.has(t)&&n&&qr(n),Kr(t)}),Xr=Q.useMemo(()=>(t,n,r,i,a,o,s)=>(0,$.jsx)(Gv,{group:t,groupKey:n,isArchivedLoading:!!(t.isArchivedBucket&&r&&Yn(r).some(e=>st.has(e))),projectId:r,hideGroupLabel:i,compactBodyPadding:o,hasSessionSearchQuery:K,normalizedSessionSearchQuery:Pe,groupSearchDataByGroup:gr,visibleSessionCount:A.get(n),collapsedGroups:W,collapsedFolderIds:Ie,toggleFolderCollapse:Je,renameFolder:He,deleteFolder:Ue,showDeletionDialog:je,setDeleteFolderConfirm:ne,renderSessionNode:Gr,projectRepoStatus:O,lastRepoStatus:fr.current,showMoreGroupSessions:Gn,resetGroupSessionLimit:Kn,mobileVariant:e,alwaysShowActions:Ft,activeProjectId:_e,setActiveProjectIdOnly:ye,setActiveMainTab:Se,setSessionSwitcherOpen:De,openNewSessionDraft:Ct,addSessionToFolder:We,createFolderAndStartRename:Wn,renamingFolderId:L,renameFolderDraft:z,setRenameFolderDraft:B,setRenamingFolderId:R,pinnedSessionIds:ie,expandedParents:C,sessionOrderByScope:Re,sessionOrderActivityByScope:ze,onReorderSessions:Jr,currentSessionId:ut,shortcutTargetSessionId:Hr?.groupKey===n?Hr.sessionId:null,shortcutTargetVisibleIndex:Hr?.groupKey===n?Hr.visibleIndex??null:null,editingId:_,editTitle:y,openSidebarMenuKey:P,liveSessionById:At,alwaysVisibleSessionIds:$e,onToggleCollapsedGroup:Yr,dragHandleProps:a,scrollContainerRef:s}),[K,Pe,gr,st,Yn,A,W,Ie,Je,He,Ue,je,Gr,O,Gn,Kn,e,Ft,_e,ye,Se,De,Ct,We,Wn,L,z,ie,C,Re,ze,Jr,ut,Hr,_,y,P,At,$e,Yr]),Zr=r?null:(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(ry,{collapseAllProjects:Qn,expandAllProjects:$n}),(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:rn.requestDirectoryDialog,children:(0,$.jsx)(Z,{name:`add`,className:`size-4`})})]}),Qr=jt&&!Mt&&Nt&&!nt&&!K?(0,$.jsx)(`div`,{className:`shrink-0 px-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(Xu,{className:`min-w-0 flex-1`}),(0,$.jsx)(Ec,{className:`ml-auto shrink-0`})]})}):null,$r=!nt&&!K,ei=!K&&(Er.length>0||Dr.length>0),ti=$r||ei?(0,$.jsxs)($.Fragment,{children:[$r?(0,$.jsxs)($.Fragment,{children:[e&&Nt?(0,$.jsx)(Xu,{}):null,(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:an,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:on,children:[(0,$.jsx)(Z,{name:`time`,className:`size-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`sessions.sidebar.header.actions.scheduledTasks`)}),a?(0,$.jsx)(F_,{}):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:sn,children:[(0,$.jsx)(zc,{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)(Jc,{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)(I_,{}):null]})]}):null,(0,$.jsx)(Ts,{sidebar:!0,mobile:e})]})]}):null,ei?(0,$.jsx)(Jv,{items:Er,reorderEnabled:!0,onSessionsReordered:wr,inProgressItems:Dr,renderSessionNode:Gr,currentSessionId:ut,editingId:_,openSidebarMenuKey:P,onVisibleSessionIdsChange:Fr}):null]}):null,ni=!!(L||_||x),{selectionModeEnabled:ri,hasSelection:ii,selectedIdsSize:ai,bulkScopeIsArchived:oi,derivedSelectionScope:si,bulkScopeFolders:ci,bulkCanRemoveFromFolder:li,handleExitSelectionMode:ui,handleBulkMoveToFolder:fi,handleBulkCreateFolderAndMove:pi,handleBulkRemoveFromFolder:hi,handleBulkDelete:gi,confirmBulkDelete:vi}=sx({isInlineEditing:ni,showDeletionDialog:je,foldersMap:Le,addSessionsToFolder:Ge,removeSessionsFromFolders:qe,createFolderAndStartRename:Mn,archiveSessions:ln,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)(Kv,{hideDirectoryControls:r,isSessionSearchOpen:u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchQuery:f,setSessionSearchQuery:m,hasSessionSearchQuery:K,searchMatchCount:vr}),Qr,a?(0,$.jsx)(wy,{topContent:ti,hasLeadingSection:ti!==null&&(Er.length>0||Dr.length>0),headerAccessory:Zr,sectionsForRender:Or,projectSections:hr,activeProjectId:_e,showOnlyMainWorkspace:i,hasSessionSearchQuery:K,emptyState:qt,searchEmptyState:yr,renderGroupSessions:Xr,homeDirectory:pe,collapsedProjects:E,hideDirectoryControls:r,projectRepoStatus:O,mobileVariant:e,alwaysShowActions:Ft,toggleProject:er,setActiveProjectIdOnly:ye,setActiveMainTab:Se,setSessionSwitcherOpen:De,openNewSessionDraft:Ct,openNewWorktreeDialog:$t,syncProjectSessions:Zn,openProjectEditDialog:S,removeProject:ve,projectReorderEnabled:pr===`manual`,reorderProjects:xe,projectSortOrder:pr,getOrderedGroups:br,setGroupOrderByProject:se,openSidebarMenuKey:P,setOpenSidebarMenuKey:ee,isInlineEditing:ni}):null,ri&&ii?(0,$.jsx)(ox,{selectedCount:ai,scopeKey:si,scopeFolders:ci,archivedBucket:oi,onMoveToFolder:fi,onCreateFolderAndMove:pi,onRemoveFromFolder:hi,canRemoveFromFolder:li,onDelete:gi,onDone:ui}):null,(0,$.jsx)(V_,{normalizedProjects:rr,ownership:cr,enabled:a}),(0,$.jsx)(hy,{onOpenSettings:nn,onOpenShortcuts:Ee,onOpenUpdate:tn,showRuntimeButtons:!nt,showUpdateButton:Fe}),c?(0,$.jsx)(Ox,{onOpenChange:l}):null,Jt?(0,$.jsx)(dv,{open:!0,onOpenChange:e=>{e||S(null)},project:Jt,onSave:Qt}):null,M?(0,$.jsx)(mi,{open:!0,onOpenChange:N,onWorktreeCreated:en}):null,(0,$.jsx)($s,{}),(0,$.jsx)(ks,{}),(0,$.jsx)(rx,{value:V,setValue:H,showDeletionDialog:je,setShowDeletionDialog:Me,onConfirm:wn}),(0,$.jsx)(ax,{value:te,setValue:ne,onConfirm:On}),(0,$.jsx)(ix,{value:re,setValue:U,showDeletionDialog:je,setShowDeletionDialog:Me,onConfirm:vi})]})});function Ax(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 jx=e=>e?(0,$.jsx)(`span`,{className:`text-foreground/80 dark:text-foreground/70`,children:e}):void 0,Mx=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.replace(/\/+$/,``)},Nx=()=>{let{t:e}=Tt(),[t,n]=Q.useState(!1),[r,i]=Q.useState(!1),[a,o]=Q.useState(null),[s,c]=Q.useState([]),[l,u]=Q.useState(!1),[d,f]=Q.useState(!1),[p,m]=Q.useState(!1),[h,g]=Q.useState(!1),[_,v]=Q.useState(new Set),y=zn(e=>e.getWorktreeMetadata),b=zn(e=>e.newSessionDraft),x=zn(e=>e.setNewSessionDraftTarget),S=zn(e=>e.setDraftBootstrapPendingDirectory),C=qt,w=zn(e=>e.archiveSessions),T=q(e=>e.showDeletionDialog),E=q(e=>e.setShowDeletionDialog),D=Ae(e=>e.currentDirectory),O=Ae(e=>e.homeDirectory),k=Ae(e=>e.isHomeReady),A=Tn(e=>e.projects),j=Tn(e=>e.activeProjectId),{isMobile:M,isTablet:N,hasTouchInput:P}=Za(),ee=M||N||P,F=Q.useMemo(()=>Mx((j?A.find(e=>e.id===j)??null:null)?.path??D),[j,D,A]),I=Q.useCallback(e=>{let t=Mx(e.projectDirectory)||F;return{id:(A.find(e=>Mx(e.path)===t)??null)?.id??`path:${t}`,path:t}},[F,A]),L=h&&_.size>0,R=Q.useMemo(()=>{let e=a?.worktree;return e&&typeof e.branch==`string`&&e.branch.trim().length>0?!0:s.length>0&&s.every(({metadata:e})=>typeof e.branch==`string`&&e.branch.trim().length>0)},[a?.worktree,s]),z=a?.mode===`worktree`,B=z,V=p||!z||!R,H=p||!z;Q.useEffect(()=>{r||!k||A.length>0||(i(!0),n(!0))},[r,k,A.length]);let te=Q.useCallback(e=>{o({sessions:e.sessions,dateLabel:e.dateLabel,mode:e.mode??`session`,worktree:e.worktree??null})},[]),ne=Q.useCallback(()=>{o(null),c([]),u(!1),f(!1),m(!1),g(!1),v(new Set)},[]),re=Q.useCallback(t=>{if(t.sessions.length===0)return;let n=t.sessions.map(e=>e.id);nc({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(()=>rn.onDeleteRequest(e=>{if(!T&&(e.mode??`session`)===`session`){re(e);return}te(e)}),[te,T,re]),Q.useEffect(()=>rn.onDirectoryRequest(()=>{n(!0)}),[]),Q.useEffect(()=>{if(!a){c([]),u(!1),f(!1),g(!1),v(new Set);return}let e=a.sessions.map(e=>{let t=y(e.id);return t?{session:e,metadata:t}:null}).filter(e=>!!e);c(e),u(!1),g(!1),v(new Set);let t=new Map;if(a.worktree?.path&&t.set(Mx(a.worktree.path),a.worktree),e.forEach(({metadata:e})=>{e.path&&t.set(Mx(e.path),e)}),t.size===0){g(!0);return}let n=!1;return(async()=>{let e=new Map,r=new Set;await Promise.all(Array.from(t.entries()).map(async([t,n])=>{try{let i=await _o(n.path);e.set(t,i),i?.isDirty&&r.add(t)}catch{n.status&&(e.set(t,n.status),n.status.isDirty&&r.add(t))}})).catch(e=>{console.warn(`Failed to inspect worktree status before deletion:`,e)}),!n&&(v(r),g(!0),o(t=>{if(!t?.worktree?.path)return t;let n=Mx(t.worktree.path),r=e.get(n);if(!r)return t;let i=t.worktree.status;return i?.isDirty===r.isDirty&&i?.ahead===r.ahead&&i?.behind===r.behind&&i?.upstream===r.upstream?t:{...t,worktree:{...t.worktree,status:r}}}),c(t=>t.map(t=>{let n=Mx(t.metadata.path),r=e.get(n);return r?{session:t.session,metadata:{...t.metadata,status:r}}:t})))})(),()=>{n=!0}},[a,y]),Q.useEffect(()=>{R||u(!1)},[R]);let U=Q.useCallback(async(t,n)=>{let r=l&&R,i=I(t),a=Mx(t.path),o=Mx(i.path);try{await mo(i,t,{deleteRemoteBranch:r,deleteLocalBranch:n});let e=Mx(b?.directoryOverride);return b?.open&&a&&e===a&&o&&(S(null),x({projectId:i.id,directoryOverride:o},{force:!0})),Mx(D)===a&&o&&Ae.getState().setDirectory(o,{showOverlay:!1}),!0}catch(t){return X.error(e(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:jx(t instanceof Error?t.message:e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),!1}},[R,D,l,I,b?.directoryOverride,b?.open,S,x,e]),ie=Q.useCallback((t,n)=>{let r=l&&R;(async()=>{if(!await U(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:jx(i)})})()},[R,l,U,e]),ae=Q.useCallback(async()=>{if(a){m(!0);try{let t=B&&d;if(a.sessions.length===0&&z&&a.worktree){ie(a.worktree,t),ne();return}if(a.sessions.length===1){let t=a.sessions[0];if(z){if(!await C(t.id)){X.error(e(`sessions.sidebar.session.archive.error`)),m(!1);return}qs({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 nc({sessionIds:[t.id],message:e(`sessions.sidebar.session.delete.success`),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:e(`sessions.sidebar.session.delete.error`)})}else{let n=a.sessions.map(e=>e.id),r=[],i=[];if(z){let e=await w(n);r=e.archivedIds,i=e.failedIds}else nc({sessionIds:n,message:n.length===1?e(`sessions.sidebar.bulkActions.deletedSingle`,{count:n.length}):e(`sessions.sidebar.bulkActions.deletedPlural`,{count:n.length}),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:n.length===1?e(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:n.length}):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:n.length})}),r=n,i=[];if(z&&a.worktree&&i.length===0&&ie(a.worktree,t),z&&r.length>0&&qs({sessionIds:r,message:r.length===1?e(`sessions.sidebar.bulkActions.archivedSingle`,{count:r.length}):e(`sessions.sidebar.bulkActions.archivedPlural`,{count:r.length}),undoLabel:e(`sessions.sidebar.undo`),settingsLabel:e(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:r.length===1?e(`sessions.sidebar.session.archive.undoFailed`):e(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:r.length})}),i.length>0&&(X.error(z?i.length===1?e(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):e(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}):i.length===1?e(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:i.length}):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:i.length}),{description:jx(e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),r.length===0)){m(!1);return}}z&&a.sessions.length===1&&a.worktree&&ie(a.worktree,t),ne()}finally{m(!1)}}},[a,d,C,w,ne,B,z,ie,e]),W=a?.worktree??s[0]?.metadata??null,oe=a?a.mode===`worktree`?a.sessions.length===0?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked`):a.sessions.length===1?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked`,{count:a.sessions.length}):e(`sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked`,{count:a.sessions.length}):a.sessions.length===1?a.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate`,{dateLabel:a.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionOne`):a.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate`,{count:a.sessions.length,dateLabel:a.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionMany`,{count:a.sessions.length}):``,G=a?(0,$.jsxs)(`div`,{className:J(z?`space-y-3`:`space-y-2`),children:[a.sessions.length>0&&(0,$.jsxs)(`div`,{className:J(z?`rounded-lg bg-muted/30 p-3`:`space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3`),children:[z&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:a.sessions.length===1?e(`sessions.sidebar.sessionDialogs.linkedSessionSingle`):e(`sessions.sidebar.sessionDialogs.linkedSessionPlural`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:a.sessions.length})]}),(0,$.jsxs)(`ul`,{className:J(z?`mt-2 space-y-1`:`space-y-0.5`),children:[a.sessions.slice(0,5).map(t=>(0,$.jsxs)(`li`,{className:J(z?`flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground`:`typography-micro text-muted-foreground/80`),children:[(0,$.jsx)(`span`,{className:J(!z&&`hidden`),children:`•`}),(0,$.jsx)(`span`,{className:`truncate`,children:t.title||e(`sessions.sidebar.session.untitled`)})]},t.id)),a.sessions.length>5&&(0,$.jsx)(`li`,{className:J(z?`px-2.5 py-1 text-xs text-muted-foreground/70`:`typography-micro text-muted-foreground/70`),children:e(`sessions.sidebar.dialogs.sessionList.more`,{count:a.sessions.length-5})})]})]}),z?(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg bg-muted/30 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:e(`sessions.sidebar.sessionDialogs.worktree.label`)}),W?.label?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:W.label}):null]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/80 break-all`,children:W?St(W.path,O):e(`sessions.sidebar.sessionDialogs.worktree.pathUnavailable`)}),L&&(0,$.jsx)(`p`,{className:`typography-micro text-status-warning`,children:e(`sessions.sidebar.sessionDialogs.worktree.uncommittedWarning`)})]}):(0,$.jsx)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/60 p-3`,children:(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/80`,children:e(`sessions.sidebar.sessionDialogs.delete.note`)})})]}):null,se=z?R?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{V||u(e=>!e)},disabled:V,className:J(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,V?`cursor-not-allowed opacity-60`:`hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),children:[l?(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}):(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}),e(`sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch`)]}):(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:e(`sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable`)}):null,ce=z?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{H||f(e=>!e)},disabled:H,className:J(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,H?`cursor-not-allowed opacity-60`:`hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),children:[d?(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}):(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}),e(`sessions.sidebar.sessionDialogs.actions.deleteLocalBranch`)]}):null,le=z?(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[ce,se]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{variant:`ghost`,onClick:ne,disabled:p,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{variant:`destructive`,onClick:ae,disabled:p,children:e(p?`sessions.sidebar.sessionDialogs.actions.deleting`:`sessions.sidebar.sessionDialogs.actions.deleteWorktree`)})]})]}):(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>E(!T),className:`inline-flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":!T,children:[T?(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}):(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}),e(`sessions.sidebar.dialogs.neverAsk`)]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{variant:`ghost`,onClick:ne,disabled:p,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{variant:`destructive`,onClick:ae,disabled:p,children:p?e(`sessions.sidebar.sessionDialogs.actions.deleting`):a?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`)})]})]}),ue=z?e(`sessions.sidebar.sessionDialogs.actions.deleteWorktree`):a?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`);return(0,$.jsxs)($.Fragment,{children:[ee?(0,$.jsx)(wa,{open:!!a,onClose:()=>{p||ne()},title:ue,footer:(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:le}),children:(0,$.jsxs)(`div`,{className:`space-y-2 pb-2`,children:[oe&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/80`,children:oe}),G]})}):(0,$.jsx)(fr,{open:!!a,onOpenChange:e=>{if(!e){if(p)return;ne()}},children:(0,$.jsxs)(lr,{className:J(z?`max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3`:`max-w-[min(520px,100vw-2rem)] space-y-2 pb-2`),children:[(0,$.jsxs)(sr,{children:[(0,$.jsxs)(ur,{className:J(z&&`flex items-center gap-2`),children:[z&&(0,$.jsx)(Z,{name:`delete-bin`,className:`h-5 w-5`}),ue]}),oe&&(0,$.jsx)(dr,{children:oe})]}),(0,$.jsx)(`div`,{className:J(z&&`flex-1 min-h-0 overflow-y-auto space-y-2`),children:G}),(0,$.jsx)(cr,{className:`mt-2 gap-2 pt-1 pb-1`,children:le})]})}),(0,$.jsx)(Uc,{open:t,onOpenChange:n})]})};function Px(){let{host:e,snapshot:t,inventory:n,error:r,requested:i,requestLoad:a}=Fo(),{t:o}=Tt(),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)(cd,{"data-gui-plugin-page-surface":!0,children:e&&l?(0,$.jsx)(Ka,{fallback:(0,$.jsx)(il,{message:o(`guiPlugins.error`)}),children:(0,$.jsx)(rl,{host:e,kind:`page`,contributionKey:l.key,revision:u})},JSON.stringify([l.key,u])):f?(0,$.jsx)(il,{message:o(`guiPlugins.error`)}):null})})}var Fx=Q.createContext(null),Ix=e=>{let t=(0,xl.c)(3),{children:n,value:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(Fx.Provider,{value:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},Lx=Do(()=>ut(()=>import(`./TerminalView-BArR-jEl.js`).then(e=>({default:e.TerminalView})),__vite__mapDeps([77,1,4,2,3,5,6,7,8,9,10,11,17,12,13,14,16,78,50,51,52,53,54,55,15,18,19,20,79,36,37,38,39,49,22,56,33,34,35,57,58,59,40,42,80,63,81,82,83,84,85,86,87]))),Rx=Do(()=>ut(()=>import(`./DiagramView-DJDzscnd.js`).then(e=>({default:e.DiagramView})),__vite__mapDeps([88,1,3,2,7,8,9,10,11,13,14,17,12,16,4,56,36,5,6,37,20,38,39,42,63,50,51,52,53,54,55,15,18,19,49,22,33,34,35,57,58,59,89,90]))),zx=Do(()=>ut(()=>import(`./SettingsView-aWGqxCrZ.js`).then(e=>e.n).then(e=>({default:e.SettingsView})),__vite__mapDeps([91,1,2,3,4,5,6,92,93,9,7,50,51,52,10,11,8,53,12,16,14,54,55,15,17,13,18,19,20,22,94,95,96,56,33,34,35,36,37,38,39,97,98,49,57,58,59,42,99,60,100,101,65,40,41,43,44,61,102,103,104,105,106,107,47,108,80,83,84,85,109,81,110,111,112,48,23,24,25,26,27,28,29,30,31,32,62,63,64,113,66,114,82,115,116,117,118,119,120,72,121,122,123,124,125,126,87,74,127,128,129,130,131,132,133]))),Bx=Do(()=>ut(()=>import(`./SettingsWindow-rX0TNPNO.js`).then(e=>({default:e.SettingsWindow})),__vite__mapDeps([134,1,7,12,36,5,2,3,6,37,9,10,11,20,38,39,91,4,92,93,50,51,52,8,53,16,14,54,55,15,17,13,18,19,22,94,95,96,56,33,34,35,97,98,49,57,58,59,42,99,60,100,101,65,40,41,43,44,61,102,103,104,105,106,107,47,108,80,83,84,85,109,81,110,111,112,48,23,24,25,26,27,28,29,30,31,32,62,63,64,113,66,114,82,115,116,117,118,119,120,72,121,122,123,124,125,126,87,74,127,128,129,130,131,132,133]))),Vx=Do(()=>ut(()=>import(`./MultiRunWindow-C0dOS6fA.js`).then(e=>({default:e.MultiRunWindow})),__vite__mapDeps([135,1,7,12,36,5,2,3,6,37,9,10,11,20,38,39,42,136,50,4,51,52,8,53,16,14,54,55,15,17,13,18,19,33,34,35,49,22,56,57,58,59,102,137,138,139,140,99,60,100,101,65,40,41,141,108,103,104,80,107,47,83,84,85,109,81,122]))),Hx=Do(()=>ut(()=>import(`./AssistantView-C5ACV-pb.js`).then(e=>e.n).then(e=>({default:e.AssistantView})),__vite__mapDeps([142,1,2,3,5,6,7,8,9,10,11,12,13,14,56,33,34,35,36,37,20,38,39,97,4,53,16,54,55,15,17,18,19,22,98,49,50,51,52,57,58,59,42,99,60,100,101,65,40,41,43,44,61,80,143,46,107,47,110,144,69,67,68,109,81,145,146,138,139,140,112,141,62,63,64,147,148,149,127]))),Ux=()=>{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}=Za(),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=ir(-E.current),O=(0,Q.useRef)(0),k=ir(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),ar(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),ar(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=zn.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)(Zp,{isActive:!v})});case`diff`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(lc,{})});case`terminal`:return n?null:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Lx,{})});case`files`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Ud,{})});case`diagram`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Rx,{})});default:return null}},[a,n,v]),N=a===`schedule`,P=a===`assistant`,ee=a===`plugin`,F=N||P||ee,I=a===`chat`,L=!F&&!c;return(0,$.jsx)(Ws,{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)(Mc,{}),(0,$.jsx)(D_,{}),(0,$.jsx)(j_,{}),(0,$.jsx)(Nx,{}),f?(0,$.jsxs)(Ix,{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&&!F&&(0,$.jsx)(Fu,{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)(Ka,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Us,{})})})}),P&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Ka,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Hx,{})})})}),L&&(0,$.jsx)(`div`,{className:J(`absolute inset-0`,!I&&`invisible`),children:(0,$.jsx)(Ka,{children:(0,$.jsx)(vc,{})})}),L&&M&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Ka,{children:M})}),u&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(Ka,{children:(0,$.jsx)(gl,{onCreated:()=>d(!1),onCancel:()=>d(!1)})})}),(0,$.jsx)(is.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)(Ka,{children:(0,$.jsx)(kx,{mobileVariant:!0,isVisible:b})})}),S&&(0,$.jsx)(is.div,{className:`absolute inset-0 z-20 bg-sidebar`,"data-page-scroll-lock":`true`,style:{x:k},"aria-hidden":!v,children:(0,$.jsx)(Ka,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Zp,{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)(Ka,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(zx,{onClose:()=>l(!1)})})})}),(0,$.jsx)(Ka,{children:(0,$.jsx)(Zs,{})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ed,{}),(0,$.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:[(0,$.jsx)(Ju,{isOpen:e,isMobile:f,className:`border-border/50`,topBar:(0,$.jsx)(Yu,{}),children:(0,$.jsx)(kx,{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:F?(0,$.jsx)(`main`,{className:`flex-1 overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(Ka,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:ee?(0,$.jsx)(Px,{}):P?(0,$.jsx)(Hx,{}):(0,$.jsx)(Us,{})})})}):(0,$.jsxs)(T_,{header:(0,$.jsx)(Fu,{}),footer:(0,$.jsx)(Bu,{isOpen:n,isMobile:f,children:n?(0,$.jsx)(Ka,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Lx,{})})}):null}),children:[L&&(0,$.jsx)(`div`,{className:J(`absolute inset-0`,!I&&`invisible`),children:(0,$.jsx)(Ka,{children:(0,$.jsx)(vc,{})})}),L&&M&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Ka,{children:M})})]})})]}),(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Bx,{open:c,onOpenChange:l})}),(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Vx,{open:u,onOpenChange:d})})]})]})})},Wx=9e4,Gx=15e3,Kx=3e5,qx=[2e3,5e3],Jx=6e4,Yx=12e4,Xx=3e5,Zx=4,Qx=432e5,$x=`yuri.github-pr-status`,eS=e=>e===`closed`||e===`merged`,tS=e=>{let t=e?.checks;return t?t.state===`pending`||t.pending>0:!1},nS=(e,t,n)=>`${e}::${t}`,rS=new Map,iS=new Map,aS=new Set,oS=new Map,sS=2,cS=0,lS=[],uS=()=>cS<sS?(cS+=1,Promise.resolve()):new Promise(e=>{lS.push(e)}),dS=()=>{let e=lS.shift();if(e){e();return}cS=Math.max(0,cS-1)},fS=()=>({status:null,isLoading:!1,error:null,isInitialStatusResolved:!1,lastRefreshAt:0,lastDiscoveryPollAt:0,watchers:0,params:null,identity:null,resolvedRemoteName:null}),pS=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,mS=e=>{let t=pS(e);return!t?.directory||!t.branch?null:`${t.directory}::${t.branch}`},hS=(e,t)=>Object.entries(e).filter(([,e])=>mS(e)===t).map(([e])=>e),gS=(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}}},_S=e=>!e?.params?.canShow||!e.params.github?.prStatus?null:{...e.params,remoteName:e.params.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null},vS=(e,t,n)=>{let r=hS(e,t),i=r.map(t=>_S(e[t])).filter(e=>!!e);if(i.length===0)return null;let a=_S(e[n]);if(a&&mS(e[n])===t)return a;let o=r.map(t=>e[t]).find(e=>!!(e?.resolvedRemoteName&&_S(e)));return o?_S(o):i.find(e=>!!e.remoteName)||(i[0]??null)},yS=e=>({status:e.status,isInitialStatusResolved:e.isInitialStatusResolved,lastRefreshAt:e.lastRefreshAt,lastDiscoveryPollAt:e.lastDiscoveryPollAt,identity:pS(e),resolvedRemoteName:e.resolvedRemoteName??e.status?.resolvedRemoteName??null}),bS=e=>({...fS(),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}),xS=ne()(re((e,t)=>({entries:{},activeRequestCount:0,totalRequestCount:0,ensureEntry:t=>{e(e=>e.entries[t]?e:{entries:{...e.entries,[t]:fS()}})},setParams:(t,n)=>{e(e=>{let r=e.entries[t]??fS();return{entries:{...e.entries,[t]:gS(r,n)}}})},startWatching:n=>{if(e(e=>{let t=e.entries[n]??fS();return{entries:{...e.entries,[n]:{...t,watchers:t.watchers+1}}}}),rS.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=iS.get(n)??[];i.push(r),iS.set(n,i)};t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0}),qx.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<Kx)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}eS(r.status?.pr?.state)||Date.now()-r.lastRefreshAt<(tS(r.status)?Jx:r.status?.checks&&r.status.checks.state!==`pending`?Xx:Yx)||t().refresh(n,{force:!0,onlyExistingPr:!0,silent:!0,markInitialResolved:!0})}},Gx);rS.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=rS.get(n);typeof i==`number`&&window.clearInterval(i),rS.delete(n);let a=iS.get(n);a&&a.length>0&&a.forEach(e=>{window.clearTimeout(e)}),iS.delete(n)},refresh:async(n,r)=>{let i=t(),a=i.entries[n],o=mS(a);if(!a||!o)return;let s=hS(i.entries,o),c=s.some(e=>!!i.entries[e]?.status?.pr);if(r?.onlyExistingPr&&!c)return;let l=oS.get(o)??0;if(!r?.force&&Date.now()-l<Wx||aS.has(o))return;let u=vS(i.entries,o,n);if(u){if(aS.add(o),oS.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}}),aS.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}}),aS.delete(o);return}try{e(e=>({...e,activeRequestCount:e.activeRequestCount+1,totalRequestCount:e.totalRequestCount+1})),await uS();let t;try{t=await u.github.prStatus(u.directory,u.branch,u.remoteName??void 0,{force:r?.force})}finally{dS()}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=pS(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{aS.delete(o),e(e=>({...e,activeRequestCount:Math.max(0,e.activeRequestCount-1)}))}}},refreshTargets:async(e,n)=>{await cv(Array.from(new Set(e.map(e=>{let t=e.directory.trim(),n=e.branch.trim();return!t||!n?null:nS(t,n,e.remoteName??null)}).filter(e=>!!e))),Zx,e=>t().refresh(e,n))},updateStatus:(t,n)=>{e(e=>{let r=e.entries[t]??fS();return{entries:{...e.entries,[t]:{...r,status:n(r.status)}}}})}}),{name:$x,storage:We(),partialize:e=>({entries:Object.fromEntries(Object.entries(e.entries).filter(([,e])=>{let t=pS(e);if(!t?.directory||!t.branch)return!1;let n=Math.max(e.lastRefreshAt,e.lastDiscoveryPollAt);return n===0||Date.now()-n<Qx}).map(([e,t])=>[e,yS(t)]))}),merge:(e,t)=>{let n=e?.entries??{};return{...t,entries:Object.fromEntries(Object.entries(n).map(([e,t])=>[e,bS(t)]))}}})),SS=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`},CS=e=>{let t=(0,xl.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},wS=e=>{let t=(0,xl.c)(43),{title:n,snapshot:r,emptyLabel:i}=e,{t:a}=Tt(),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(ES,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?SS(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)(CS,{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)(CS,{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)(CS,{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)($o,{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},TS=e=>{let t=(0,xl.c)(104),{onClose:n}=e,{t:r}=Tt(),[i,a]=Q.useState(`memory`),[o,s]=Q.useState(`idle`),c=zn(DS),l=dn(OS),u=un(),d=Ht(),[f,p]=Q.useState(kS),m,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>Te(()=>{p(ke())}),h=[],t[0]=m,t[1]=h):(m=t[0],h=t[1]),Q.useEffect(m,h);let g;if(t[2]!==d||t[3]!==u){bb0:{let e=Le(),t={};if(!e){g=t;break bb0}let n=e.getCacheBudget?.(),r=n?n.listCanonical().map(AS):u.map(e=>({directory:d,sessionID:e.id}));for(let n of r){if(d&&n.directory!==d)continue;let r=e.getTranscript(Ne(n.directory,n.sessionID));t[n.sessionID]=r.messageOrder.map(e=>r.messagesByID[e]).filter(jS)}g=t}t[2]=d,t[3]=u,t[4]=g}else g=t[4];let _=g,v=xS(MS),[y,b]=Q.useState(NS),[x,S]=Q.useState(PS),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(Ie()),S(De())};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,ee;t[28]===o?(P=t[29],ee=t[30]):(P=()=>{if(o===`idle`)return;let e=window.setTimeout(()=>{s(`idle`)},1500);return()=>window.clearTimeout(e)},ee=[o],t[28]=o,t[29]=P,t[30]=ee),Q.useEffect(P,ee);let F=0,I=0,L=0;for(let e of Object.keys(_)){let t=_[e]??[];I+=t.length;for(let e of t)e.role===`user`?L+=1:e.role===`assistant`&&(F+=1)}let R;t[31]!==F||t[32]!==I||t[33]!==L?(R={assistant:F,total:I,user:L},t[31]=F,t[32]=I,t[33]=L,t[34]=R):R=t[34];let z=R,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(FS),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:Ie(),vscode:De()};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:()=>{xe(),b(Ie()),S(De())},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]!==z||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)(CS,{label:r(`memoryDebugPanel.metric.totalMessages`),value:z.total}),(0,$.jsx)(CS,{label:r(`memoryDebugPanel.metric.cachedSessions`),value:`${te} / ${Rr.MAX_SESSIONS}`}),(0,$.jsx)(CS,{label:r(`memoryDebugPanel.metric.userMessages`),value:z.user}),(0,$.jsx)(CS,{label:r(`memoryDebugPanel.metric.assistantMessages`),value:z.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:Xr()})})]}),(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:Rr.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)($o,{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)(ca,{children:[(0,$.jsx)(aa,{asChild:!0,children:(0,$.jsx)(Y,{size:`sm`,variant:`outline`,className:`typography-meta`,onClick:()=>{u.map(IS),Object.keys(_),V.map(LS),Object.fromEntries(l)},children:r(`memoryDebugPanel.actions.logState`)})}),(0,$.jsx)(oa,{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)(CS,{label:r(`memoryDebugPanel.metric.uiMetrics`),value:y.entries.length}),(0,$.jsx)(CS,{label:r(`memoryDebugPanel.metric.vscodeMetrics`),value:x.entries.length}),(0,$.jsx)(CS,{label:r(`memoryDebugPanel.metric.messageListRenders`),value:j.messageListRender}),(0,$.jsx)(CS,{label:r(`memoryDebugPanel.metric.messageListStreamRenders`),value:j.messageListRenderStreaming}),(0,$.jsx)(CS,{label:r(`memoryDebugPanel.metric.chatMessageRenders`),value:j.chatMessageRender}),(0,$.jsx)(CS,{label:r(`memoryDebugPanel.metric.chatMessageStreamRenders`),value:j.chatMessageRenderStreaming}),(0,$.jsx)(CS,{label:r(`memoryDebugPanel.metric.chatMessageStaticDuringStream`),value:j.chatMessageRenderStaticDuringStream}),(0,$.jsx)(CS,{label:r(`memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn`),value:j.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),(0,$.jsx)(wS,{title:r(`memoryDebugPanel.section.uiStreamingMetrics`),snapshot:y,emptyLabel:r(`memoryDebugPanel.section.noUiSamples`)}),x.entries.length>0?(0,$.jsx)(wS,{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]=z,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 Se;return t[100]!==le||t[101]!==ye||t[102]!==be?(Se=(0,$.jsxs)(_a,{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]=Se):Se=t[103],Se};function ES(e,t){return e+t.count}function DS(e){return e.currentSessionId}function OS(e){return e.sessionMemoryState}function kS(){return ke()}function AS(e){return e.scope}function jS(e){return!!e}function MS(e){return e.totalRequestCount}function NS(){return Ie()}function PS(){return De()}function FS(e,t){return t.lastAccessed-e.lastAccessed}function IS(e){return{id:e.id,title:e.title}}function LS(e){return{id:e.id,title:e.title,total:e.messageCount,user:e.userMessageCount,assistant:e.assistantMessageCount}}var RS=()=>{let{isMobile:e,closeActiveContextPanelTab:t}=q.getState();if(e)return;let n=Lo();n&&t(n)||P()&&ee(`desktop_close_current_window`).catch(e=>{console.warn(`[menu-actions] failed to close current window`,e)})},zS=()=>{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()??``:``},BS=async()=>{let e=zS()||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`)},VS=`yuri:menu-action`,HS=`yuri:check-for-updates`,US=e=>typeof e?.listen==`function`?`bridge`:`dom`,WS=e=>{let t=zn(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=Ds(e=>e.checkForUpdates),{setThemeMode:_}=rr(),{t:v}=Tt(),y=Q.useRef(!1),b=typeof window>`u`?null:window.__YURI_DESKTOP__,x=US(b),S=Q.useCallback(()=>{y.current||(y.current=!0,g().then(()=>{let{available:e,error:t}=Ds.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(()=>{rn.requestDirectoryDialog()},[]),w=Q.useCallback(e=>{Mi(e,zn.getState().currentSessionId,e=>{s(`chat`),o(!1),zn.getState().setCurrentSession(e.sessionId,e.directory)})},[s,o]),T=Q.useCallback(e=>{let{activeProjectId:t,projects:n,setActiveProject:r}=Tn.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),fi();break;case`change-workspace`:C();break;case`close-tab-or-window`:RS();break;case`toggle-right-sidebar`:{let e=Lo();e&&d(e);break}case`open-right-sidebar-git`:{let e=Lo();e&&q.getState().openContextPanel(e),f(!0),p(`git`);break}case`open-right-sidebar-files`:{let e=Lo();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)&&BS();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`:pi();break;case`zoom-out`:hi();break;case`zoom-reset`:zi();break;case`go-back`:Ae.getState().goBack();break;case`go-forward`:Ae.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`:Ki().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(VS,e),window.addEventListener(HS,t),()=>{window.removeEventListener(VS,e),window.removeEventListener(HS,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])},GS=(e,t)=>e<t?-1:+(e>t),KS=e=>JSON.stringify([...e.entries()].map(([e,t])=>[e,[...new Set(t)].sort(GS)]).sort(([e],[t])=>GS(e,t)));async function qS({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 JS=`yuri:tray-action`,YS=3e4,XS=120,ZS=20,QS=()=>{if(typeof window>`u`)return!1;let e=window.__YURI_PLATFORM__;return e===`darwin`||e===`win32`},$S=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},eC=e=>{let t=Array.isArray(e.questions)?e.questions[0]:void 0;return t?.header||t?.question||`Question`},tC=e=>ln(e),nC=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t},rC=(e,t,n,r)=>{if(!e)return``;let i=Cn(t,n,e),a=nC(i?i.path:e),o=Fn(e),s=o&&r.get(o)||``;if(!s){for(let[e,t]of ra.getState().directories)if(Fn(e)===o){s=t.status?.current??``;break}}if(!s)for(let e of n.values()){let t=e.find(e=>Fn(e.path)===o);if(t?.branch){s=t.branch;break}}return s?`${a} · ${s}`:a},iC=()=>{let{results:e,dropdownProviderIds:t,displayMode:n}=Os.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 _s(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:pa(n.label??t),value:ja(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}},aC=async()=>{try{if(k())return`Local Yuri`;let e=window.__YURI_LOCAL_ORIGIN__||window.location.origin,t=m();if(t&&V(t,e))return`Local Yuri`;let n=(await H()).hosts.find(e=>t?V(t,te(e)):!1);return n?.label?.trim()?B(n.label.trim()):`Instance`}catch{return``}},oC=()=>{let e=new Map,t=new Map,n=[],r=new Map,i;try{i=Ce()}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(Fn(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:$S(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:eC(r),directory:a})}}return{statusById:e,branchByDirectory:t,approvals:n,titleById:r}},sC=()=>{let e=Zt.getState().activeSessions,t=new Set;e.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>tC(t)-tC(e)).slice(0,ZS).forEach(e=>{let n=Yt(e);n&&t.add(n)});let n=new Map;for(let r of e){if(!r?.id)continue;let e=Yt(r);if(!e||!t.has(e))continue;let i=n.get(e)??[];i.push(r.id),n.set(e,i)}return n},cC=e=>{let t=oC(),n=jn.getState().index.session,r=Zt.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=en.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=Tn.getState().projects,d=zn.getState().availableWorktreesByProject,f=r.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>tC(t)-tC(e)).slice(0,ZS).map(e=>{let r=[e.id,...o(e.id)],i=Yt(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:rC(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:iC(),dockBadgeCount:h}},lC=()=>{Q.useEffect(()=>{if(!QS()||!P())return;let e=!1,t=``,n=null,r=``,i=()=>{if(e)return;let n=cC(r),i=JSON.stringify(n);i!==t&&(t=i,ee(`desktop_tray_update`,n))};aC().then(t=>{e||(r=t,i())});let a=null,o=``,s=()=>{let e=Zn.getState();return e.isConnected&&e.connectionPhase===`connected`},c=()=>{if(a)return a;let t=sC();return o=KS(t),a=qS({targets:t,isReady:s,concurrency:2,isDisposed:()=>e,fetchStatus:async()=>{try{let e=await be.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)=>{Nn(e,t,[...n])}}).finally(()=>{a=null;let t=sC();!e&&s()&&KS(t)!==o&&c()}),a},l=()=>{e||n!==null||(n=window.setTimeout(()=>{n=null,i()},XS))},u=new Map,d=()=>{if(e)return;let t;try{t=Ce()}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=Ce().subscribeRegistry(()=>{d(),l()})}catch{}d();let p=jn.subscribe(()=>l()),m=Zt.subscribe(()=>{l(),s()&&KS(sC())!==o&&c()}),h=Tn.subscribe(()=>l()),g=zn.subscribe(()=>l()),_=ra.subscribe(()=>l()),v=q.subscribe(()=>l()),y=en.subscribe(()=>l()),b=s(),x=Zn.subscribe(()=>{let e=s();e&&!b&&c(),b=e});b&&c();let S=Os.subscribe(()=>l());Os.getState().loadSettings().then(()=>{if(e)return;let{dropdownProviderIds:t,results:n}=Os.getState();t.length>0&&t.some(e=>!n.some(t=>t?.providerId===e))&&Os.getState().fetchAllQuotas()});let C=window.setInterval(()=>{let e=Os.getState();e.autoRefresh&&e.dropdownProviderIds.length>0&&e.fetchAllQuotas()},Math.max(3e4,Os.getState().refreshIntervalMs||6e4)),w=window.setInterval(()=>{d(),i()},YS);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(!QS()||typeof window>`u`)return;let e=window.__YURI_DESKTOP__?.listen;if(typeof e!=`function`)return;let t=e=>{e.type===`respond-permission`&&Un(e.sessionId,e.id,e.response).catch(()=>{X.error(`Failed to respond to permission request`)})},n=null;return e(JS,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{}}},[])},uC=`/api/notifications/stream`,dC=()=>typeof document>`u`||document.visibilityState===`visible`&&document.hasFocus(),fC=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}},pC=e=>{let t=(0,xl.c)(3),n=e?.enabled??!0,r,i;t[0]===n?(r=t[1],i=t[2]):(r=()=>{if(!n||I()||!S()||typeof window>`u`||typeof EventSource>`u`)return;let e=new EventSource(c().sse(uC));return e.onmessage=mC,()=>{e.close()}},i=[n],t[0]=n,t[1]=r,t[2]=i),Q.useEffect(r,i)};function mC(e){let t;try{t=JSON.parse(e.data)}catch{return}let n=q.getState();if(!n.nativeNotificationsEnabled)return;let r=fC(t);r&&((r.requireHidden??n.notificationMode!==`always`)&&dC()||z()?.notifications?.notifyAgentCompletion(r))}var hC=`pwa-install-toast-shown`,gC=`pwa-install-toast-dismissed`,_C=()=>{let e=(0,xl.c)(6),{browserTab:t}=As(),{t:n}=Tt(),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`||!S()||!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=Ve(),c=Be();dc({dismissed:s.getItem(gC),sessionShown:c.getItem(hC),hasActiveToast:n!==null})&&(c.setItem(hC,`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:()=>{Ve().setItem(gC,`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 vC(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`),zn.getState().setCurrentSession(t,n)}var yC=({open:e,onOpenChange:t})=>{let{t:n}=Tt(),[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 Et())})()},[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)(fr,{open:e,onOpenChange:t,children:(0,$.jsx)(lr,{className:`max-w-xs p-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[(0,$.jsx)(Ya,{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`)})]})})})},bC=(e,t)=>{let n=e.get(t);return typeof n==`string`&&n.trim()||null},xC=(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},SC=()=>{let e=js(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=bC(t,`code`),a=xs(t),o=as(t),s=bC(t,`error`),c=bC(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(xC(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`})})]})})},CC=()=>{let e=Zt(e=>e.startupSyncProgress.active),t=Zt(e=>e.startupSyncProgress.phase),n=Zt(e=>e.startupSyncProgress.completed),r=Zt(e=>e.startupSyncProgress.total),{locale:i,t:a}=Tt(),[o,s]=Q.useState(!0),c=At(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},wC=(e,t,n,r=350)=>n?Math.max(0,r-Math.max(0,t-e)):null;function TC(e){let t=(0,xl.c)(21),{transition:n,ready:r}=e,{t:i}=Tt(),a=Ia(!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=wC(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)(Ya,{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 EC=Do(()=>ut(()=>import(`./OnboardingScreen-BdU6Tyax.js`).then(e=>({default:e.OnboardingScreen})),__vite__mapDeps([150,1,4,2,3,5,6,92,7,53,9,10,11,8,12,16,14,54,55,36,37,20,38,39,42,43,44,103,111,40]))),DC=36e5,OC=12e5,kC=()=>{let e=(0,xl.c)(3),t=q(IC),n=q(LC),r;return e[0]!==t||e[1]!==n?(r=(0,$.jsx)(yC,{open:t,onOpenChange:n}),e[0]=t,e[1]=n,e[2]=r):r=e[2],r},AC=e=>{let t=(0,xl.c)(21),{onRetry:n,isRetrying:r}=e,{t:i}=Tt(),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},jC=e=>e?e.replace(/\\/g,`/`).replace(/\/+$/g,``):``,MC=()=>{if(typeof window>`u`||!eo())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`}},NC=()=>typeof window>`u`?!1:window.location.pathname===ls,PC=e=>{let t=(0,xl.c)(22),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=e,a=Ae(RC),o=zn(zC),s=zn(BC),c=ni(),l=Q.useRef(null),u;t[0]===n.directory?u=t[1]:(u=jC(n.directory),t[0]=n.directory,t[1]=u);let d=u,f;t[2]===a?f=t[3]:(f=jC(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)(xi,{embeddedBackgroundWorkEnabled:i}),t[14]=i,t[15]=g);let _;t[16]===n.readOnly?_=t[17]:(_=(0,$.jsx)(vc,{readOnly:n.readOnly}),t[16]=n.readOnly,t[17]=_);let v;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Lr,{}),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 FC({apis:e}){Q.useEffect(()=>{je(`App:mounted`),K()},[]),Q.useEffect(()=>Wn(),[]);let t=Zn(e=>e.initializeApp),n=Zn(e=>e.isInitialized),r=Zn(e=>e.isConnected),i=zn(e=>e.error),a=zn(e=>e.clearError),o=zn(e=>!(e.newSessionDraft?.open&&e.currentSessionId===null)),c=Ae(e=>e.currentDirectory),l=Ae(e=>e.setDirectory),u=Ae(e=>e.isSwitchingDirectory),[f,p]=Q.useState(!1),m=gs(e=>e.refreshStatus),[h,g]=Q.useState(()=>e.runtime.isVSCode),[x,S]=Q.useState(!1),[C,D]=Q.useState(!1),[O,A]=Q.useState(0),[j,M]=Q.useState(0),[P,F]=Q.useState({epoch:0,startedAt:0}),[L,z]=Q.useState(!1),B=Q.useRef(!1),V=q(e=>e.wideChatLayoutEnabled),H=q(e=>e.mobileKeyboardMode),te=Q.useMemo(()=>I(),[]),ne=Zt(e=>e.hasCachedSessionIndex),re=Zt(e=>e.hasHydratedSessionIndex),[U,ie]=Q.useState(()=>y()),[ae,W]=Q.useState(()=>{let e=T();return e===null?null:w({isDesktopShell:!0,bootOutcome:e})}),oe=Q.useRef(!1),G=Q.useMemo(()=>MC(),[]),se=!G||x,ce=Q.useMemo(()=>NC(),[]);Q.useEffect(()=>(Fe(f),()=>{Fe(!1)}),[f]),Q.useEffect(()=>{He(H)},[H]),Q.useEffect(()=>{g(e.runtime.isVSCode)},[e.runtime.isVSCode]),Q.useEffect(()=>{let e=Vr(e=>{d(e)&&(te&&F(e=>({epoch:e.epoch+1,startedAt:Date.now()})),kc(e),M(e=>e+1),D(!1),A(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(()=>(R(e),()=>R(null)),[e]),Q.useEffect(()=>{if(G)return;let t=!1;return Xn().then(()=>{t||m(e.github,{force:!0})}),()=>{t=!0}},[e.github,G,m]),Li();let le=U===`valid`,ue=ae?.screen===`main`,[de,fe]=Q.useState(!1);Q.useEffect(()=>{if(!se||!N({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 Xn().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){D(!0);return}let n=Zn.getState();if(n.isInitialized){D(!1);return}if(r+=1,await Xn(),!e)return;await n.initializeApp();let o=Zn.getState();if(!e)return;if(o.isInitialized){D(!1);return}if(r>=10){D(!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,O,n,h]),Q.useEffect(()=>{se&&n&&D(!1)},[se,n]),Q.useEffect(()=>{if(!se||!C)return;let e=document.getElementById(`initial-loading`);if(e){e.classList.add(`fade-out`);let t=setTimeout(()=>{e.remove()},300);return()=>clearTimeout(t)}},[se,C]),ri({enabled:se&&!h,source:`startupRecovery`}),Q.useEffect(()=>{u||h||r&&be.setDirectory(c)},[c,u,r,h]),Q.useEffect(()=>{if(!G||typeof window>`u`)return;let e=e=>{let t=e?.visible===!0;S(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:no},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;vC(t??{})},t=e=>{let t=e.detail?.assistantID;typeof t==`string`&&t.trim()&&nr(t.trim())},n=e=>{let t=e.detail,n=t?.projectID,r=t?.taskID;n&&r&&ut(async()=>{let{openScheduledTask:e}=await import(`./scheduledTaskNavigation-BqkeRfVc.js`).then(e=>e.n);return{openScheduledTask:e}},__vite__mapDeps([112,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=Ae.getState().currentDirectory,{activeProjectId:t,projects:n}=Tn.getState(),r=n.find(e=>e.id===t)??null;ee(`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=zn.getState().currentSessionId;e&&Rn(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),zn.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=Tn.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]),ti({enabled:se}),pC({enabled:se}),_C(),Wi(),Tc(),WS(vt(()=>{p(e=>!e)})),Q.useEffect(()=>{_()&&pt().then(async e=>{e&&await b(e)}).catch(console.warn)},[]),Q.useEffect(()=>{if(!n||!_()||B.current)return;B.current=!0;let e=!1,t=null,r=null;Ds.getState().subscribeDesktopUpdateEvents().then(t=>{if(e){t();return}r=t});let i=()=>{let e=Ds.getState();e.checking||e.checkForUpdates()},a=n=>{t=window.setTimeout(()=>{e||(document.visibilityState===`visible`&&i(),a(DC))},n)},o=()=>{if(e||document.visibilityState!==`visible`)return;let t=Ds.getState().lastChecked;t!=null&&Date.now()-t<OC||i()};return a(0),window.addEventListener(`focus`,o),()=>{e=!0,t!==null&&window.clearTimeout(t),window.removeEventListener(`focus`,o),r&&r()}},[n]),lC(),Q.useEffect(()=>{if(G)return;let e=e=>{Ct(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=y();if(r!==`not-injected`){if(e=!0,ie(r),r===`valid`){let e=T();e&&W(w({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=vt(async()=>{if(E({isDesktopShell:I(),isDesktopLocalOriginActive:k()})){await v();return}window.location.reload()}),me=vt(async()=>{if(!L){D(!1),z(!0);try{await Xn(),await Zn.getState().initializeApp()}finally{z(!1)}Zn.getState().isInitialized||A(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)(Ka,{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)(EC,{mode:`first-launch`,onCliAvailable:pe,onChooseRemote:()=>{}})})})});let e=he(ae),t=ae.screen===`recovery`&&`url`in ae?ae.url:void 0;return(0,$.jsx)(Ka,{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)(EC,{mode:`recovery`,recoveryVariant:e,recoveryHostUrl:t,recoveryHostLabel:void 0,onCliAvailable:pe})})})})}if(G)return Bt(),(0,$.jsx)(Ka,{children:(0,$.jsx)(tn,{sdk:be.getSdkClient(),directory:c||``,bootstrapDirectory:o,children:(0,$.jsx)(Ui,{apis:e,children:(0,$.jsx)(sa,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-background`,children:(0,$.jsx)(PC,{embeddedSessionChat:G,isVSCodeRuntime:h,embeddedBackgroundWorkEnabled:se})})})})},j)});if(ce)return(0,$.jsx)(Ka,{children:(0,$.jsx)(SC,{})});if(C&&!n&&!h&&!G)return(0,$.jsx)(Ka,{children:(0,$.jsx)(AC,{onRetry:()=>{me()},isRetrying:L})});let ge=!n&&!te;return(0,$.jsx)(Ka,{children:(0,$.jsx)(tn,{sdk:be.getSdkClient(),directory:c||``,bootstrapDirectory:o,children:(0,$.jsx)(Ui,{apis:e,children:(0,$.jsx)(Xs,{ready:de&&n&&se,children:(0,$.jsx)(Hf,{children:(0,$.jsx)(sa,{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)(xi,{embeddedBackgroundWorkEnabled:se}),(0,$.jsx)(Gs,{}),(0,$.jsx)(qc,{}),(0,$.jsx)(Ux,{}),te&&(0,$.jsx)(TC,{transition:P,ready:n&&r}),(0,$.jsx)(CC,{}),(0,$.jsx)(Lr,{}),!ge&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(sc,{}),(0,$.jsx)(Hc,{}),(0,$.jsx)(ec,{}),(0,$.jsx)(kC,{}),f&&(0,$.jsx)(TS,{onClose:()=>p(!1)})]})]})})})})})},j)})}function IC(e){return e.isAboutDialogOpen}function LC(e){return e.setAboutDialogOpen}function RC(e){return e.currentDirectory}function zC(e){return e.currentSessionId}function BC(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 VC=typeof window<`u`&&window.__YURI_RUNTIME_APIS__||(()=>{throw Error(`Runtime APIs not provided for legacy UI entrypoint.`)})();Pt(),I()&&cn(),Gr({runtimeKey:f(),initializeAppearance:Ze,syncSettings:Xe,applyDirectory:ei,startWatchers:()=>{Ei(),Zr(),zr()},onError:(e,t)=>{console.error(e===`appearance`?`[main] appearance init failed:`:`[main] settings init failed:`,t)}});var HC=document.getElementById(`root`);if(!HC)throw Error(`Root element not found`);(0,bl.createRoot)(HC).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(Br,{children:(0,$.jsx)(Dt,{children:(0,$.jsx)(Fr,{children:(0,$.jsx)(wi,{children:(0,$.jsx)(qr,{children:(0,$.jsx)(Yr,{children:(0,$.jsx)(FC,{apis:VC})})})})})})})}));
169
+ Now write the final fused answer.`,synthetic:!0}],directory:i??be.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 Tb(e){let t=(0,xl.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:or,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 Eb=1/3,Db=1,Ob=({containerScrollTop:e,containerClientHeight:t,containerScrollHeight:n,rowOffsetFromViewportTop:r})=>{let i=e+(r-t*Eb),a=Math.max(0,n-t);return Math.min(a,Math.max(0,i))},kb=()=>typeof window>`u`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`,Ab=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},jb=(e,t)=>{let n=Ab(e),r=t?.behavior??kb();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=Ob({containerScrollTop:n.scrollTop,containerClientHeight:n.clientHeight,containerScrollHeight:n.scrollHeight,rowOffsetFromViewportTop:i.top-a});Math.abs(s-n.scrollTop)<Db||n.scrollTo({top:s,behavior:r})},Mb=e(ce(),1),Nb=null,Pb=!1,Fb=(e,t=Bi.getState().focus)=>e===null?null:typeof e==`string`?t?.sessionId===e?t:yi(e):e,Ib=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))},Lb=()=>{Nb&&=(Ib(Nb),null)},Rb=(e,t)=>{Lb(),_n(!0);let n=Fb(e);if(!n)return;Pb=!0;let r;try{r=Ln(n.sessionId)}finally{Pb=!1}Nb={commit:t,commitFrame:null,fallbackTimer:null,focus:n,intent:r,paintFrame:null,scheduled:!1},(0,Mb.flushSync)(()=>{Bi.getState().setFocus(n)}),typeof window<`u`&&(Nb.fallbackTimer=window.setTimeout(()=>{zb(n)},150))},zb=e=>{let t=Nb,n=Fb(e);if(!t||!oi(t.focus,n)||t.scheduled)return;t.scheduled=!0,typeof window<`u`&&t.fallbackTimer!==null&&(window.clearTimeout(t.fallbackTimer),t.fallbackTimer=null);let r=()=>{Nb===t&&kn()===t.intent&&(Nb=null,er(),t.commit())};if(typeof window>`u`){r();return}t.commitFrame=window.requestAnimationFrame(()=>{Nb===t&&kn()===t.intent&&(t.paintFrame=window.requestAnimationFrame(r))})},Bb=e=>{if(Nb)return;let t=Bi.getState();t.setFocus(Fb(e,t.focus))};Dn(e=>{if(Pb)return;let t=Nb;if(t?.intent===e)return;t&&Lb();let n=Bi.getState();n.setFocus(Fb(e.sessionId,n.focus))});var Vb=e=>{let t=[],n=e=>{e.children.forEach(e=>{t.push(e.session.id),n(e)})};return n(e),t},Hb=Q.memo(function(e){let t=(0,xl.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)(aa,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:u,"aria-label":r,onPointerDown:o,onMouseDown:s,onClick:c,onKeyDown:tx,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)(oa,{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)(ca,{children:[h,g]}),t[18]=h,t[19]=g,t[20]=_):_=t[20],_}),Ub=Q.memo(function(e){let t=(0,xl.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=rb(),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)(aa,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:y,"aria-label":h,onPointerDown:c,onMouseDown:l,onClick:_,onKeyDown:nx,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)(oa,{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)(ca,{children:[S,C]}),t[21]=S,t[22]=C,t[23]=w):w=t[23],w}),Wb=Q.memo(function(e){let t=(0,xl.c)(3),{number:n}=e;if(!yb())return null;let r=kt()?`⌘${n}`:`Ctrl+${n}`,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(Vi,{"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 Gb(e){let{t:n}=Tt(),{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:T,handleUnshareSession:E,setOpenSidebarMenuKey:D,renamingFolderId:O,getFoldersForScope:k,getSessionFolderId:A,removeSessionFromFolder:j,addSessionToFolder:M,createFolderAndStartRename:N,handleDeleteSession:I,mobileVariant:L,alwaysShowActions:R,renderSessionNode:z,secondaryMeta:B,renderContext:V=`project`,subtreeContainsActive:H,subtreeContainsEditing:te,menuOpenSessionId:ne,childRenderExtrasFor:re,liveSessionById:U,shortcutNumber:ce=null}=e,le=!!B?.projectLabel,ue=!!B?.branchLabel,de=qn(e=>e.displayMode),fe=Q.useMemo(()=>F(),[]),he=de===`minimal`||fe,ge=Q.useMemo(()=>P(),[]),_e=Q.useContext(it),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`,be=fe,xe=V===`pinned`&&c.has(r.session.id),Ce=!xe&&!s&&!L,Te=`h-5 w-5`,Ee=`h-3.5 w-3.5`,De=(Ce||xe?1:0)+ +!!be+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,Pe]=Q.useState(!1),K=Q.useRef(f);K.current=f;let Fe=Q.useRef(null),Ie=Q.useRef(_);Ie.current=_;let[Re,ze]=Q.useState(h),Be=Q.useRef(Re);Be.current=Re;let Ve=Q.useRef(null),He=Q.useRef(null),q=Q.useRef(null),Ue=r.session,We=U.get(Ue.id)??Ue,Ge=!!We.metadata?.yuri?.assistant,Ke=dt(Ue.directory??null)??dt(a??null),qe=Qt(Ke??void 0,{bootstrap:!1}),Je=ni(),Ye=Wy(e=>e.enabled),Xe=Wy(Q.useMemo(()=>e=>e.selectedIds.has(Ue.id),[Ue.id])),Ze=Wy(e=>e.toggleSelected),Qe=Wy(e=>e.setRange),[$e,et]=Q.useState(!1),[tt,nt]=Q.useState(!0),[rt,at]=Q.useState(!1),[ot,st]=Q.useState(!1),ct=`${V}:${s?`archived`:`active`}:${Ue.id}`,lt=dn(Q.useMemo(()=>e=>!!e.sessionMemoryState.get(Wt(Ue.id))?.isZombie,[Ue.id])),ut=Kn(Ue.id),ft=An(Ue.id,Ke??void 0,{bootstrap:!1}),pt=On(Ue.id,Ke??void 0,{bootstrap:!1}),mt=Q.useMemo(()=>({scope:V,sessionId:Ue.id,projectId:o??null}),[o,V,Ue.id]),ht=Q.useMemo(()=>_i(mt)??``,[mt]),gt=Q.useRef(null),yt=Bi(Q.useMemo(()=>e=>oi(e.focus,mt),[mt]));Q.useLayoutEffect(()=>{if(!yt)return;let e=gt.current;e&&(L?e.scrollIntoView({block:`nearest`,inline:`nearest`}):jb(e)),zb(mt)},[yt,L,mt]);let xt=We.title||n(`sessions.sidebar.session.untitled`),St=io(ro(We)),Ct=We.metadata?.yuri?.titleRefresh,wt=typeof Ct?.lastError==`string`?Ct.lastError:null,Et=typeof Ct?.failedAt==`number`?Ct.failedAt:null;Q.useEffect(()=>{!wt||Et===null||console.warn(`[session-title] generation failed for ${Ue.id}: ${wt}`)},[Ue.id,wt,Et]);let Dt=typeof Ct?.generationExpiresAt==`number`&&Number.isFinite(Ct.generationExpiresAt)?Ct.generationExpiresAt:0,[Ot,kt]=Q.useState(0),At=Q.useMemo(()=>Math.max(0,Dt-Date.now()),[Dt]),[,jt,Mt]=_t(()=>kt(Dt),At,{immediate:!1}),Nt=Ct?.isGenerating===!0;Q.useEffect(()=>(Nt&&Dt>Date.now()&&jt(),Mt),[Nt,Dt,jt,Mt]);let Pt=r.children.length>0||!!(We.hasChildren??Ue.hasChildren),Ft=c.has(Ue.id),It=ct,Lt=u?!0:l.has(It),Rt=!!We.parentID,zt=V===`pinned`,Bt=yn(Ue.id)>0&&!Rt,Vt=ln(We)||Date.now(),Ht=qa(Vt),Ut=Ua(Vt),[Gt,Kt]=Q.useState(!1),qt=Gt,Jt=Q.useMemo(()=>ml(We.title)!==null,[We.title]),[Yt,Xt]=Q.useState(!1),Zt=Q.useMemo(()=>Vb(r).length,[r]),en=vt(e=>{let t=Ke??``,n=(Le()??Se(t,qe)).getTranscript(Ne(t,e)),r=qe.getState().session.find(t=>t.id===e)?.revert?.messageID;return nn({sessionID:e,messages:we(n),parts:n.partsByMessageID,revertMessageID:r}).list}),tn=vt(async e=>{let t=[],r=0;for(let i of e)try{await Je.ensureSessionRenderable(i.session.id);let e=en(i.session.id),a=i.session.title||n(`sessions.sidebar.session.export.untitledSubagent`),o=i.session.agent,s=await tn(i.children);r+=s.skipped,t.push({title:a,agent:o,records:e,children:s.children})}catch{r+=Vb(i).length+1}return{children:t,skipped:r}}),rn=vt(e=>{e<=0||X.warning(n(e===1?`sessions.sidebar.session.export.skippedSubtaskSingle`:`sessions.sidebar.session.export.skippedSubtaskMany`,{count:e}))}),an=vt(async e=>{if(!Ke){X.error(n(`sessions.sidebar.session.export.nothingToExport`));return}await Je.ensureSessionRenderable(Ue.id);let t=en(Ue.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 tn(r.children);i=e.children,a=e.skipped}let o=Ly(t,We.title??null,i),s=Hy(We.title??null),c=await zy(o,s);if(c){X.success(n(`sessions.sidebar.session.export.success`),{action:{label:n(Vy()),onClick:()=>{By(c).then(e=>{e||X.error(n(`sessions.sidebar.session.export.failedRevealPath`))})}}}),rn(a);return}Ry(o,s),X.success(n(`sessions.sidebar.session.export.success`)),rn(a)}),on=vt(async()=>{if(r.children.length>0){nt(!0),et(!0);return}await an(!1)}),sn=vt(()=>{Ke&&ee(`desktop_open_session_mini_chat_window`,{sessionId:Ue.id,directory:Ke,apiBaseUrl:m(),clientToken:t()}).catch(e=>{console.warn(`[session-sidebar] failed to open mini chat window`,e)})});bt(He,()=>{Ie.current(Be.current)},f===Ue.id),Q.useLayoutEffect(()=>{if(f!==Ue.id){Ve.current===Ue.id&&(Ve.current=null);return}Ve.current!==Ue.id&&(Ve.current=Ue.id,ze(h),queueMicrotask(()=>q.current?.select()))},[f,h,Ue.id]);let cn=vt(e=>{if(!e&&Fe.current){let{id:e,title:t}=Fe.current;Fe.current=null,p(e),g(t)}}),un=vt(e=>{Kt(e)}),fn=vt(e=>{e.preventDefault(),e.stopPropagation()}),pn=vt(e=>{e.preventDefault(),e.stopPropagation()}),mn=vt(e=>{e.preventDefault(),e.stopPropagation(),D(null),S(Ue.id)}),hn=vt(e=>{e.preventDefault(),e.stopPropagation(),D(null),I(Ue,{archivedBucket:s})}),gn=vt(e=>{e.preventDefault(),e.stopPropagation(),D(null),I(Ue,{archivedBucket:s,hardDelete:!0,skipConfirm:!0})}),_n=vt(e=>{e.preventDefault(),e.stopPropagation(),D(null),S(Ue.id)}),vn=vt(()=>{!Ke||rt||(at(!0),(async()=>{try{await Je.refreshSessionTranscript(Ue.id,{directory:Ke}),X.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{X.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{at(!1)}})())}),bn=vt(e=>{e.preventDefault(),e.stopPropagation()}),xn=vt(e=>{e.preventDefault(),e.stopPropagation()}),Sn=vt(e=>{e.preventDefault(),e.stopPropagation(),_e?.vscode?.executeCommand(`yuri.openSessionInEditor`,Ue.id,xt)}),Cn=vt(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=Wy.getState().anchorId,n=new Map;n.set(Ue.id,Vb(r)),Qe(t,Ue.id,e,Ke??null,n);return}Ze(Ue.id,Ke??null,Vb(r));return}b(Ue.id,Ke,o,V)}),wn=vt(e=>{e.defaultPrevented||e.target?.closest(`button, a, input, [role="menuitem"], [role="menu"]`)||Cn(e)}),Tn=vt(e=>{(e.button===2||e.button===0&&e.ctrlKey&&!Ye)&&(Ae.current=!0)}),En=vt(e=>{je.current=e.pointerType===`mouse`,L&&e.pointerType===`touch`&&Pe(!0)}),Dn=vt(e=>{L&&e.pointerType===`touch`&&Pe(!1)}),kn=vt(e=>{e.key!==`Enter`||!je.current||(e.preventDefault(),e.stopPropagation(),x(Ue.id,xt))}),jn=vt(e=>{if(Cn(e),!je.current)return;let t=e.currentTarget;window.requestAnimationFrame(()=>{je.current=!0,t.focus({preventScroll:!0})})}),Mn=vt(()=>{je.current=!1}),Nn=vt(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)}),Pn=vt(()=>{!Lt&&!ot&&(st(!0),Je.loadChildren(Ue.id,Ke).catch(()=>X.error(n(`sessions.sidebar.session.subsessions.loadFailed`))).finally(()=>st(!1))),y(It)});if(f===Ue.id){let e=async()=>{v();try{await $t(Ue.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:Ga(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(),_(Re)},children:[(0,$.jsx)(`input`,{ref:q,value:Re,onChange:e=>ze(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`})})]}),he?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}),le?(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]})})]})},Ue.id)}let Fn=ut,In=Nt&&Dt>Date.now()&&Ot!==Dt,Ln=ft.length,Rn=pt.length>0,zn=Rn||Fn||!Rn&&!Fn&&Bt,Bn=!R||fe,Vn=Rn?(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`})}):Fn?(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)(Ys,{})}):(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)]`})}),Hn=!zt&&!Rt&&Pt,Un=Hn&&!R&&!ot,Wn=Ga(Math.max(0,i-1)),Jn=Hn?(0,$.jsx)(`span`,{role:`button`,tabIndex:0,"aria-expanded":Lt,"aria-busy":ot,onClick:e=>{e.stopPropagation(),e.currentTarget.blur(),Pn()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),Pn())},style:{minWidth:14,minHeight:14,left:Wn},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`,he?`top-1/2 -translate-y-1/2`:`top-[14.5px] -translate-y-1/2`,Un?`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:ot?(0,$.jsx)(Ys,{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,Yn=lt?(0,$.jsx)(Z,{name:`error-warning`,className:`h-4 w-4 text-status-warning`}):null,Xn=(0,$.jsx)(G,{children:(0,$.jsx)(W,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(ye,{"data-slot":`dropdown-menu-content`,finalFocus:()=>!(O||K.current),style:{color:`var(--surface-elevated-foreground)`},className:J(Co,`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:Ue.id,title:xt}},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(Ue.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`)]}),Gn()&&!We.share?(0,$.jsxs)(e,{onClick:()=>C(We),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`share-2`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.share`)]}):Gn()&&We.share?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(e,{onClick:()=>{We.share?.url&&T(We.share.url,Ue.id)},className:`[&>svg]:mr-1`,children:w===Ue.id?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`check`,className:`mr-1 h-4 w-4`,style:{color:`var(--status-success)`}}),n(`sessions.sidebar.session.menu.copied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`file-copy`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.copyLink`)]})}),(0,$.jsxs)(e,{onClick:()=>E(Ue.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:()=>{on()},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:!Ke||rt,onClick:()=>{vn()},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)(Tb,{className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.session.menu.runFusion`)]}):null,Ke&&!s?(()=>{let o=k(Ke),s=A(Ke,Ue.id);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(t,{}),(0,$.jsxs)(r,{children:[(0,$.jsxs)(i,{className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`folder`,className:`h-4 w-4`}),n(`sessions.sidebar.folders.moveToFolder`)]}),(0,$.jsxs)(a,{className:`min-w-[180px]`,children:[o.length===0?(0,$.jsx)(e,{disabled:!0,className:`text-muted-foreground`,children:n(`sessions.sidebar.folders.none`)}):o.map(t=>(0,$.jsxs)(e,{onClick:()=>{s===t.id?j(Ke,Ue.id):M(Ke,t.id,Ue.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=N(Ke);e&&M(Ke,e.id,Ue.id)},children:[(0,$.jsx)(Z,{name:`add`,className:`mr-1 h-4 w-4`}),n(`sessions.sidebar.folders.newFolderEllipsis`)]}),s?(0,$.jsxs)(e,{onClick:()=>{j(Ke,Ue.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,ge?(0,$.jsxs)(e,{disabled:!Ke,onClick:sn,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(Ue,{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(Ue,{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)(ae,{className:J(To,e),...t}),Separator:({className:e,...t})=>(0,$.jsx)(ie,{className:J(wo,e),...t}),Sub:oe,SubTrigger:({className:e,children:t,...n})=>(0,$.jsxs)(me,{className:J(So,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)(G,{children:(0,$.jsx)(W,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(ye,{"data-slot":`dropdown-menu-sub-content`,style:{color:`var(--surface-elevated-foreground)`},className:J(Co,`yuri-session-context-menu`,e),...n,children:t})})})})})})});return(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(mc,{sessionId:Ue.id,sessionDirectory:Ke??null,sessionTitle:xt,children:(0,$.jsxs)(se,{open:Gt,onOpenChange:un,onOpenChangeComplete:cn,children:[(0,$.jsxs)(pe,{render:(0,$.jsx)(`div`,{ref:gt,"data-session-row":Ue.id,"data-session-scope":Ke??``,"data-session-focus-scope":V,"data-session-focus-key":ht,"data-session-project-id":o??``,"data-session-archived":s?`1`:`0`,"data-session-depth":i,onClick:wn,onMouseLeave:Nn,className:J(`group relative my-0.5 flex cursor-pointer items-center rounded-lg py-1.5 pr-2`,yt&&!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)]`,!yt&&!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:[Jn,(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,style:{paddingLeft:Ga(i)},children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:(0,$.jsxs)(ca,{children:[(0,$.jsx)(aa,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onPointerDown:En,onPointerUp:Dn,onPointerCancel:Dn,onMouseDown:Tn,onKeyDown:kn,onBlur:Mn,onClick:jn,onDoubleClick:e=>{e.stopPropagation(),x(Ue.id,xt)},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)]`,R?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`,In&&`animate-text-shimmer`),"aria-busy":In||void 0,children:va(xt,d)}),St?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro tabular-nums text-muted-foreground`,children:St}):null,Ge?(0,$.jsx)(Z,{name:`ai-agent`,className:`size-3 shrink-0 text-muted-foreground`,"aria-label":`Assistant`}):null,Ln>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:Ln})]}):null,zn?(0,$.jsx)(`span`,{className:J(`inline-flex shrink-0 items-center justify-center transition-none`,Bn?J(`group-hover:hidden group-focus-within:hidden`,qt?`hidden`:``):qt?`invisible`:``),children:Vn}):null,ce?(0,$.jsx)(Wb,{number:ce}):null]})})}),fe?null:(0,$.jsx)(oa,{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:xt}),(0,$.jsx)(`div`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:Ut})]}),le?(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]})})]})})}),Yn&&!L?(0,$.jsx)(`div`,{className:J(`absolute top-1/2 -translate-y-1/2 z-10`,he?`right-0`:`right-[30px]`),children:Yn}):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||R&&!fe?`opacity-100`:J(`opacity-0`,ve)),children:[Ce?(0,$.jsx)(Hb,{pinned:Ft,pinLabel:n(Ft?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`),buttonSizeClass:Te,iconSizeClass:Ee,onPointerDown:fn,onMouseDown:pn,onPin:mn}):null,xe?(0,$.jsxs)(ca,{children:[(0,$.jsx)(aa,{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`,Te),"aria-label":n(`sessions.sidebar.session.actions.pinned`),onPointerDown:fn,onMouseDown:pn,onClick:_n,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(Z,{name:`pushpin-2-fill`,className:Ee})})}),(0,$.jsx)(oa,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:n(`sessions.sidebar.session.actions.pinned`)})]}):null,be?(0,$.jsxs)(ca,{children:[(0,$.jsx)(aa,{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`,Te),"aria-label":n(`sessions.sidebar.session.actions.openInEditor`),onPointerDown:bn,onMouseDown:xn,onClick:Sn,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(Z,{name:`external-link`,className:Ee})})}),(0,$.jsx)(oa,{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)(Ub,{archiveLabel:n(`sessions.sidebar.bulkActions.archive`),deleteLabel:n(`sessions.sidebar.bulkActions.delete`),deleteOnly:s===!0,buttonSizeClass:Te,iconSizeClass:Ee,revealClassName:he&&!R&&!qt?J(`opacity-0`,ve):`opacity-100`,onPointerDown:fn,onMouseDown:pn,onArchive:hn,onDelete:gn})]})]}),Xn]})}),!zt&&Pt&&Lt?r.children.map(e=>{let t=re?re(e):{subtreeContainsActive:H,subtreeContainsEditing:te,menuOpenSessionId:ne,nodeStructureKey:``};return z(e,i+1,Ke??a,o,s,void 0,V,t)}):null,(0,$.jsx)(fr,{open:$e,onOpenChange:et,children:(0,$.jsxs)(lr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,$.jsxs)(sr,{children:[(0,$.jsx)(ur,{children:n(`sessions.sidebar.session.export.dialog.title`)}),(0,$.jsx)(dr,{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)(cr,{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),an(tt)},size:`sm`,children:n(`sessions.sidebar.session.export.dialog.confirm`)})]})]})}),Jt?(0,$.jsx)(wb,{session:We,open:Yt,onOpenChange:Xt}):null]},Ue.id)}var Kb=e=>dt(e.session.directory??null),qb=(e,t)=>(e?.projectLabel??null)===(t?.projectLabel??null)&&(e?.branchLabel??null)===(t?.branchLabel??null),Jb=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},Yb=e=>e.menuOpenSessionId??Jb(e),Xb=(e,t,n)=>t?n.has(e.node.session.id)?!0:Ev(e.node,t):!1,Zb=(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(Zb(e.children[a],t.children[a],n,r,i))return!0;return!1},Qb=(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(Qb(e.children[i],t.children[i],n,r))return!0;return!1},$b=(e,t)=>{if(e.hasSessionSearchQuery||t.hasSessionSearchQuery)return!1;let n=e.archivedBucket?`archived`:`active`,r=t.archivedBucket?`archived`:`active`;return Zb(e.node,t.node,e.expandedParents,t.expandedParents,t=>`${e.renderContext??`project`}:${n}:${t.session.id}`)||Zb(e.node,t.node,e.expandedParents,t.expandedParents,e=>`${t.renderContext??`project`}:${r}:${e.session.id}`)},ex=Q.memo(Gb,(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||Kb(e.node)!==Kb(t.node)||!qb(e.secondaryMeta,t.secondaryMeta)||e.liveSessionById!==t.liveSessionById&&Qb(e.node,t.node,e.liveSessionById,t.liveSessionById)||e.pinnedSessionIds!==t.pinnedSessionIds&&Zb(e.node,t.node,e.pinnedSessionIds,t.pinnedSessionIds,e=>e.session.id)||e.expandedParents!==t.expandedParents&&$b(e,t)||e.currentSessionId!==t.currentSessionId&&(Xb(e,e.currentSessionId,e.subtreeContainsActive)||Xb(t,t.currentSessionId,t.subtreeContainsActive))||e.editingId!==t.editingId&&(Xb(e,e.editingId,e.subtreeContainsEditing)||Xb(t,t.editingId,t.subtreeContainsEditing))||e.editTitle!==t.editTitle&&(Xb(e,e.editingId,e.subtreeContainsEditing)||Xb(t,t.editingId,t.subtreeContainsEditing))||e.copiedSessionId!==t.copiedSessionId&&(Ev(e.node,e.copiedSessionId)||Ev(t.node,t.copiedSessionId)))return!1;if(e.openSidebarMenuKey!==t.openSidebarMenuKey){let n=Yb(e),r=Yb(t);if(Ev(e.node,n)||Ev(t.node,r))return!1}if(e.renamingFolderId!==t.renamingFolderId){let n=Yb(e),r=Yb(t);if(Ev(e.node,n)||Ev(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 tx(e){return e.stopPropagation()}function nx(e){return e.stopPropagation()}function rx(e){let t=(0,xl.c)(71),{t:n}=Tt(),{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=fr,g=!!r,t[13]===i?_=t[14]:(_=e=>{e||i(null)},t[13]=i,t[14]=_),u=lr,m=!1,h=`max-w-sm gap-5`,l=sr;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)(ur,{children:a}),t[18]=a,t[19]=p),c=dr,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)(cr,{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 ix(e){let t=(0,xl.c)(57),{t:n}=Tt(),{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)(ur,{children:d}),t[10]=d,t[11]=g);let _;t[12]===p?_=t[13]:(_=(0,$.jsx)(dr,{children:p}),t[12]=p,t[13]=_);let v;t[14]!==g||t[15]!==_?(v=(0,$.jsxs)(sr,{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)(cr,{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)(lr,{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)(fr,{open:m,onOpenChange:h,children:M}),t[53]=m,t[54]=M,t[55]=h,t[56]=N):N=t[56],N}function ax(e){let t=(0,xl.c)(36),{t:n}=Tt(),{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)(ur,{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)(dr,{children:u}),t[9]=u,t[10]=d);let f;t[11]!==l||t[12]!==d?(f=(0,$.jsxs)(sr,{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)(cr,{children:[h,_]}),t[26]=_,t[27]=h,t[28]=v):v=t[28];let y;t[29]!==v||t[30]!==f?(y=(0,$.jsxs)(lr,{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)(fr,{open:o,onOpenChange:s,children:y}),t[32]=o,t[33]=s,t[34]=y,t[35]=b):b=t[35],b}var ox=e=>{let t=(0,xl.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}=Tt(),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)(Ba,{children:[(0,$.jsxs)(ca,{children:[(0,$.jsx)(aa,{asChild:!0,children:(0,$.jsx)(Sa,{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)(oa,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:f(`sessions.sidebar.bulkActions.moveToFolder`)})})]}),(0,$.jsxs)(Pa,{align:`end`,className:`min-w-[180px]`,children:[i.length===0?(0,$.jsx)(La,{disabled:!0,className:`text-muted-foreground`,children:f(`sessions.sidebar.folders.none`)}):i.map(e=>(0,$.jsx)(La,{onClick:()=>o(e.id),children:(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e.name})},e.id)),(0,$.jsx)(za,{}),(0,$.jsxs)(La,{onClick:s,children:[(0,$.jsx)(Z,{name:`add`,className:`mr-1 h-4 w-4`}),f(`sessions.sidebar.folders.newFolderEllipsis`)]}),l?(0,$.jsxs)(La,{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)(aa,{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)(oa,{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)(ca,{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)(aa,{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)(oa,{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)(ca,{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},sx=e=>{let{t}=Tt(),{isInlineEditing:n,showDeletionDialog:r,foldersMap:i,addSessionsToFolder:a,removeSessionsFromFolders:o,createFolderAndStartRename:s,archiveSessions:c,setBulkDeleteConfirm:l}=e,u=Wy(e=>e.enabled),d=Wy(e=>e.selectedIds.size),f=d>0,p=Wy(e=>e.selectedIds),m=Wy(e=>e.scopeKey),h=Q.useCallback(()=>{Wy.getState().toggleMode()},[]),g=Q.useCallback(()=>{Wy.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(_)nc({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&&qs({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}))}Wy.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(),Wy.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=Wy.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;Wy.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}},cx=(e,t,n)=>{let r=[],i=new Set,a=e=>{let t=dt(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},lx=(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},ux=({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=lx(r,e,o,i)??{scope:`project`,sessionId:e,projectId:i};return!a||t.scope===`project`?s:lx(n,e,o,i)??s};function dx(e,t,n=null){if(!e||e.scope!==`project`||!e.sessionId)return null;if(e.projectId){let n=t.find(t=>t.sessionId===e.sessionId&&t.projectId===e.projectId);if(n)return n}if(n){let r=t.find(t=>t.sessionId===e.sessionId&&t.projectId===n);if(r)return r}return t.find(t=>t.sessionId===e.sessionId)??null}var fx=`yuri.sessions.projectCollapse`,px=`yuri.sessions.groupOrder`,mx=`yuri.sessions.groupCollapse`,hx=`yuri.sessions.activeSessionByProject`,gx=`yuri.sessions.expandedParents.v2`,_x=`yuri.sessions.expandedParents`,vx=Je(Ve()),yx=e=>{try{let t=vx.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}},bx=e=>{try{let t=vx.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}},xx=e=>{try{let t=vx.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}},Sx=(e,t,n)=>{let r=new Set;for(let t of e){let e=dt(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=dt(t.path)?.toLowerCase();e&&r.add(e)}return r},Cx=(e,t,n)=>{if(e.time?.archived)return!0;let r=dt(Yt(e))?.toLowerCase();return r?t.size===0?n?.allowEmptyDirectorySet??!0:t.has(r):n?.allowUnknownDirectory??!0},wx=new Set,Tx=[],Ex={},Dx=e=>{let t=Q.useRef(e);return t.current=e,Q.useMemo(()=>(...e)=>t.current(...e),[])},Ox=Q.memo(function(e){let t=(0,xl.c)(3),{onOpenChange:n}=e,r=Ds(U(Ax)),i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(ms,{open:!0,onOpenChange:n,...r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}),kx=Q.memo(function({mobileVariant:e=!1,onSessionSelected:t,allowReselect:n=!1,hideDirectoryControls:r=!1,showOnlyMainWorkspace:i=!1,isVisible:a=!0}){let{t:o}=Tt(),[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,w]=Q.useState(new Set),T=Q.useMemo(()=>vx,[]),[E,D]=Q.useState(new Set),[O,k]=Q.useState(new Map),[A,j]=Q.useState(new Map),M=q(e=>e.isNewWorktreeDialogOpen),N=q(e=>e.setNewWorktreeDialogOpen),[P,ee]=Q.useState(null),[L,R]=Q.useState(null),[z,B]=Q.useState(``),[V,H]=Q.useState(null),[te,ne]=Q.useState(null),[re,U]=Q.useState(null),ie=hn(),ae=gn(),[W,oe]=Q.useState(()=>yx(mx)),[G,se]=Q.useState(()=>xx(px)),[ce,le]=Q.useState(()=>bx(hx));Q.useEffect(()=>s(e=>{p(e)&&(oe(yx(mx)),se(xx(px)),le(bx(hx)),D(yx(fx)),w(yx(gx)))}),[]);let[ue,de]=Q.useState(new Map),fe=Q.useRef(0),pe=Ae(e=>e.homeDirectory),me=Ae(e=>e.currentDirectory),he=Ae(e=>e.setDirectory),ge=Tn(e=>e.projects),_e=Tn(e=>e.activeProjectId),ve=Tn(e=>e.removeProject),ye=Tn(e=>e.setActiveProjectIdOnly),be=Tn(e=>e.updateProjectMeta),xe=Tn(e=>e.reorderProjectsById),Se=q(e=>e.setActiveMainTab),Ce=q(e=>e.activeMainTab),we=Lt(),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),je=q(e=>e.showDeletionDialog),Me=q(e=>e.setShowDeletionDialog),Ne=Yi(f,120),Pe=Q.useMemo(()=>Ne.trim().toLowerCase(),[Ne]),K=Pe.length>0,Fe=Ds(e=>e.available&&(e.runtimeType===`desktop`||e.runtimeType===`web`)),Ie=Kt(e=>e.collapsedFolderIds),Le=Kt(e=>e.foldersMap),Re=Kt(e=>e.sessionOrderByScope),ze=Kt(e=>e.sessionOrderActivityByScope),Be=Kt(e=>e.getFoldersForScope),Ve=Kt(e=>e.createFolder),He=Kt(e=>e.renameFolder),Ue=Kt(e=>e.deleteFolder),We=Kt(e=>e.addSessionToFolder),Ge=Kt(e=>e.addSessionsToFolder),Ke=Kt(e=>e.removeSessionFromFolder),qe=Kt(e=>e.removeSessionsFromFolders),Je=Kt(e=>e.toggleFolderCollapse),Ye=Kt(e=>e.getSessionFolderId),Xe=Kt(e=>e.reorderSessions);ev({isSessionSearchOpen:a&&u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchContainerRef:h});let Ze=Q.useMemo(()=>new Map,[]),Qe=pn({enabled:a,includeChildren:!0}),$e=Fc({enabled:a}),et=wc({enabled:a}),tt=jn(e=>a?e.index.session.unseenCount:Ex),nt=Q.useMemo(()=>F(),[]),rt=Zt(e=>e.status),it=Zt(e=>e.activeSessions),at=Zt(e=>e.archivedSessions),ot=Zt(e=>e.loadingDirectories.size>0||e.refreshingDirectories.size>0),st=Zt(e=>e.archivedLoadingDirectories),ct=Q.useDeferredValue(it),lt=Q.useDeferredValue(at),ut=zn(e=>e.currentSessionId),ft=Bi(e=>e.focus),pt=Q.useSyncExternalStore(Dn,kn,kn),mt=zn(e=>!!e.newSessionDraft?.open),ht=zn(e=>e.setCurrentSession),gt=zn(e=>e.updateSessionTitle),_t=zn(e=>e.shareSession),yt=zn(e=>e.unshareSession),bt=zn(e=>e.worktreeMetadata),xt=zn(e=>e.availableWorktreesByProject),St=zn(e=>e.openNewSessionDraft),Ct=vt(e=>{St(e),nt&&window.dispatchEvent(new CustomEvent(`yuri:navigate`,{detail:{view:`chat`}}))}),wt=Q.useMemo(()=>Sx(ge,xt,{includeWorktrees:!nt}),[xt,nt,ge]),Et=Q.useMemo(()=>{let e=new Map(Qe.map(e=>[e.id,e])),t=ct.map(t=>{let n=e.get(t.id);return n?Xt(n,t):t}),n=new Set(t.map(e=>e.id));return Qe.forEach(e=>{n.has(e.id)||t.push(e)}),t.filter(e=>Cx(e,wt,{allowUnknownDirectory:!nt,allowEmptyDirectorySet:!nt}))},[ct,nt,wt,Qe]),Dt=Q.useMemo(()=>Qe.map(e=>{let t=dt(e.directory??null)??``;return`${e.id}:${e.title??``}:${+!!e.time?.archived}:${t}`}).join(`|`),[Qe]),kt=Q.useRef(Qe);Q.useEffect(()=>{kt.current=Qe},[Dt,Qe]);let At=Q.useMemo(()=>new Map(Qe.map(e=>[e.id,e])),[Qe]);Q.useEffect(()=>{let e=null,t=Gt(t=>{t.type===`scheduled-task-ran`&&(e&&clearTimeout(e),e=setTimeout(()=>{let e=Tn.getState().projects.find(e=>e.id===t.projectId),n=dt(e?.path??null);if(!n)return;let r=[n];(zn.getState().availableWorktreesByProject.get(n)??[]).forEach(e=>{let t=dt(e.path);t&&r.push(t)}),mn(r,kt.current)},500))});return()=>{e&&clearTimeout(e),t()}},[]);let jt=Q.useMemo(()=>I(),[]),Mt=Ol(),Nt=Es(e=>e.sidebarBrandName.trim().length>0),{isTablet:Pt}=Za(),Ft=e||Pt,{buildGroupSearchText:It,filterSessionNodesForSearch:zt,buildGroupedSessions:Bt}=$_({homeDirectory:pe,worktreeMetadata:bt,pinnedSessionIds:ie,gitBranches:Ze,isVSCode:nt}),{scheduleCollapsedProjectsPersist:Vt,hasRestoredProjectCollapse:Ht}=sv({isVSCode:nt,safeStorage:T,keys:{sessionExpanded:gx,sessionExpandedLegacy:_x,projectCollapse:fx,groupOrder:px,projectActiveSession:hx,groupCollapse:mx},groupOrderByProject:G,activeSessionByProject:ce,collapsedGroups:W,setExpandedParents:w,setCollapsedProjects:D}),Ut=Q.useMemo(()=>[...Et].sort((e,t)=>Ea(e,t,ie)),[Et,ie]),Wt=Q.useMemo(()=>{let e=new Map;return Ut.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)=>Ea(e,t,ie))),e},[Ut,ie]),qt=(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`)})]}),Jt=Q.useMemo(()=>ge.find(e=>e.id===x)??null,[ge,x]),Qt=Q.useCallback(e=>{x&&be(x,{label:e.label,icon:e.icon,color:e.color,iconBackground:e.iconBackground,defaultModel:e.defaultModel??null})},[x,be]),$t=Q.useCallback(()=>{N(!0)},[N]),en=Q.useCallback((t,n)=>{if(Se(`chat`),e&&De(!1),n?.sessionId){ht(n.sessionId,t);return}St({directoryOverride:t,preserveDirectoryOverride:!0})},[e,St,Se,ht,De]),tn=vt(()=>{let e=Ds.getState();if(e.available&&e.info){l(!0);return}e.checkForUpdates().then(()=>{let{available:e,error:t}=Ds.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)})}),nn=Q.useCallback(()=>{e&&De(!1),Te(!0)},[e,De,Te]),an=Q.useCallback(()=>{Se(`chat`),St(),e&&De(!1)},[e,St,Se,De]),on=Q.useCallback(()=>{if(!e){Se(`schedule`);return}Oe(!0),De(!1)},[e,Se,Oe,De]),sn=Q.useCallback(()=>{nr(),e&&De(!1)},[e,De]),cn=zn(e=>e.archiveSession),ln=zn(e=>e.archiveSessions),{copiedSessionId:un,handleSessionSelect:dn,handleSessionDoubleClick:_n,handleSaveEdit:vn,handleCancelEdit:yn,handleShareSession:bn,handleCopyShareUrl:xn,handleUnshareSession:Sn,handleDeleteSession:Cn,confirmDeleteSession:wn}=tv({activeProjectId:_e,currentDirectory:me,currentSessionId:ut,mobileVariant:e,allowReselect:n,onSessionSelected:t,isSessionSearchOpen:u,sessionSearchQuery:f,setSessionSearchQuery:m,setIsSessionSearchOpen:d,setActiveProjectIdOnly:ye,setDirectory:he,setActiveMainTab:Se,setSessionSwitcherOpen:De,setCurrentSession:ht,updateSessionTitle:gt,shareSession:_t,unshareSession:yt,archiveSession:cn,archiveSessions:ln,childrenMap:Wt,showDeletionDialog:je,setDeleteSessionConfirm:H,deleteSessionConfirm:V,setEditingId:v,setEditTitle:b,editingId:_,editTitle:y}),En=Q.useCallback((e,t,n,r=`project`)=>{let i={sessionId:e,scope:r,projectId:n??null};if(e===ut){Ln(e),Bb(i),dn(e,t,n);return}Rb(i,()=>dn(e,t,n))},[dn,ut]);Q.useEffect(()=>()=>{Lb()},[]);let On=Q.useCallback(()=>{if(!te)return;let{scopeKey:e,folderId:t}=te;ne(null),Ue(e,t)},[te,Ue]);Q.useEffect(()=>{if(!ut)return;let e=Et.find(e=>e.id===ut)?.parentID;if(!e)return;let t=[`project:active:${e}`,`project:archived:${e}`,`recent:active:${e}`,`recent:archived:${e}`];w(e=>{if(t.every(t=>e.has(t)))return e;let n=new Set(e);t.forEach(e=>n.add(e));try{T.setItem(gx,JSON.stringify(Array.from(n)))}catch{}return n})},[ut,Et,T]);let An=Q.useCallback(e=>{w(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{T.setItem(gx,JSON.stringify(Array.from(n)))}catch{}return n})},[T]),Mn=Q.useCallback((e,t)=>{if(!e)return null;t&&Ie.has(t)&&Je(t);let n=Ve(e,o(`sessions.sidebar.folder.newFolderName`),t);return R(n.id),B(n.name),n},[Ie,Je,Ve,o]),Nn=vt(En),Pn=vt(_n),Fn=vt(vn),In=vt(yn),Rn=vt(bn),Bn=vt(xn),Vn=vt(Sn),Un=vt(Cn),Wn=vt(Mn),Gn=vt((e,t,n,r)=>{let i=ic(),a=Math.max(i,n)+7;if(j(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=dt(e.directory??null);if(!o)return;let s=Zt.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&Rt(o)}),Kn=vt(e=>{j(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})}),Jn=vt(e=>{j(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=dt(t?.path??null);if(!n)return[];let r=[n];return nt||(xt.get(n)??[]).forEach(e=>{let t=dt(e.path);t&&r.push(t)}),r},[xt,nt,ge]),Xn=vt(e=>{let t=Yn(e);if(t.length===0)return;let n=Zt.getState().loadedDirectories,r=t.filter(e=>!n.has(e));r.length!==0&&mn(r,kt.current)}),Zn=vt(e=>{let t=ge.find(t=>t.id===e);t&&(async()=>{let e=[];if(!nt)try{e=(await vo({id:t.id,path:t.path})).worktrees}catch(n){console.warn(`[SessionSidebar] Worktree refresh before session sync failed:`,n);let r=dt(t.path);e=r?zn.getState().availableWorktreesByProject.get(r)??[]:[]}let n=cx(t.path,e,{currentDirectory:me,workspaceRoot:t.path,includeWorktrees:!nt});n.length!==0&&await Hn(n,kt.current)})()});Q.useEffect(()=>{if(!Ht)return;let e=Zt.getState(),t=ge.flatMap(t=>E.has(t.id)?[]:Yn(t.id).filter(t=>!e.loadedDirectories.has(t)&&!e.loadingDirectories.has(t)&&!e.refreshingDirectories.has(t)));t.length>0&&mn(t,kt.current)},[E,Yn,Ht,ge]);let Qn=vt(()=>{fe.current=Date.now()+150,j(new Map),D(()=>{let e=new Set(ge.map(e=>e.id));try{T.setItem(fx,JSON.stringify(Array.from(e)))}catch{}return nt||Vt(e),e})}),$n=vt(()=>{fe.current=Date.now()+150,j(new Map),D(()=>{let e=new Set;try{T.setItem(fx,JSON.stringify([]))}catch{}return nt||Vt(e),e});let e=Zt.getState().loadedDirectories,t=ge.flatMap(t=>Yn(t.id).filter(t=>!e.has(t)));t.length>0&&mn(t,kt.current)}),er=vt(e=>{fe.current=Date.now()+150,Jn(e),D(t=>{let n=new Set(t);n.has(e)?(n.delete(e),queueMicrotask(()=>Xn(e))):n.add(e);try{T.setItem(fx,JSON.stringify(Array.from(n)))}catch{}return nt||Vt(n),n})}),tr=vt(e=>{fe.current=Date.now()+150,Xn(e),D(t=>{if(!t.has(e))return t;let n=new Set(t);n.delete(e);try{T.setItem(fx,JSON.stringify(Array.from(n)))}catch{}return nt||Vt(n),n})}),rr=Q.useMemo(()=>ge.map(e=>({...e,normalizedPath:dt(e.path)})).filter(e=>!!e.normalizedPath),[ge]),ir=Q.useMemo(()=>rr.map(e=>e.normalizedPath),[rr]),ar=Q.useMemo(()=>{let e=new Set(rr.map(e=>e.normalizedPath));if(!nt)for(let t of xt.values())for(let n of t){let t=dt(n.path);t&&e.add(t)}return[...e].sort()},[xt,nt,rr]),or=Q.useRef(null);Q.useEffect(()=>{let e=new Set(ar),t=or.current;if(or.current=e,!t)return;let n=ar.filter(e=>!t.has(e));if(n.length===0)return;let r=Zt.getState().loadedDirectories,i=dt(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),nt||(xt.get(a.normalizedPath)??[]).forEach(e=>{let t=dt(e.path);t&&o.add(t)}));let s=n.filter(e=>o.has(e)&&!r.has(e));s.length!==0&&mn(s,kt.current)},[_e,xt,me,nt,rr,ar]);let sr=Xi(a?ir:Tx);lv({normalizedProjects:rr,activeProjectId:_e,gitRepoStatus:sr,setProjectRepoStatus:k,setProjectRootBranches:de,enabled:a});let cr=Q.useMemo(()=>ps(Et,rr,xt,nt,lt),[lt,xt,nt,rr,Et]),{getSessionsForProject:lr,getArchivedSessionsForProject:ur}=uv({ownership:cr}),dr=ot||rt===`idle`||rt===`loading`,fr=Q.useRef(!1);_e&&O.has(_e)&&(fr.current=!!O.get(_e));let pr=qn(e=>e.projectSortOrder),mr=Q.useMemo(()=>Cc(rr,pr),[rr,pr]),{projectSections:hr,groupSearchDataByGroup:gr,sectionsForRender:_r,searchMatchCount:vr}=X_({normalizedProjects:mr,getSessionsForProject:lr,getArchivedSessionsForProject:ur,availableWorktreesByProject:xt,projectRepoStatus:O,projectRootBranches:ue,lastRepoStatus:fr.current,buildGroupedSessions:Bt,hasSessionSearchQuery:K,normalizedSessionSearchQuery:Pe,filterSessionNodesForSearch:zt,buildGroupSearchText:It,foldersMap:Le}),yr=(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`)})]});Z_({projectSections:hr,activeProjectId:_e,activeSessionByProject:ce,setActiveSessionByProject:le,currentSessionId:ut,handleSessionSelect:dn,newSessionDraftOpen:mt,mobileVariant:e,openNewSessionDraft:St,setActiveMainTab:Se,setSessionSwitcherOpen:De});let{getOrderedGroups:br}=Q_(G),xr=Q.useRef(!1);Q.useEffect(()=>{if(xr.current||hr.length===0)return;let e=hr.flatMap(e=>e.groups.filter(e=>e.isArchivedBucket).map(t=>`${e.project.id}:${t.id}`));e.length>0&&oe(t=>new Set([...t,...e])),xr.current=!0},[hr]);let Sr=Q.useMemo(()=>{let e=new Map,t=new Map;return hr.forEach(n=>{let r=Ot(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},[hr]);Q.useLayoutEffect(()=>{if(!ut){Bb(null);return}let e=Bi.getState().focus;if(e?.sessionId===ut){e.scope===`project`&&!e.projectId&&Bb({...e,projectId:Sr.get(ut)?.projectId??null});return}Bb({scope:`project`,sessionId:ut,projectId:Sr.get(ut)?.projectId??null})},[ut,Sr]);let Cr=Q.useMemo(()=>nt?[]:Ac(Et,ie,Re[cc]),[nt,ie,Et,Re]),wr=vt((e,t)=>{_||Xe(cc,Cr.map(e=>e.id),e,t,{}).catch(()=>X.error(o(`sessions.order.saveFailed`)))}),Tr=Q.useMemo(()=>K?[]:Ic(Et,ie,et,tt),[K,ie,et,Et,tt]),{pinnedItems:Er,inProgressItems:Dr}=Q.useMemo(()=>{let e=e=>{let t=Sr.get(e.id),n=dt(e.directory??null),r={session:e,children:[],worktree:bt.get(e.id)??null};if(K&&zt([r],Pe).length===0)return null;let i=cr.bySessionId.get(e.id),a=i?mr.find(e=>e.id===i.projectId):void 0,o=a?Ot(a.normalizedPath)||a.normalizedPath:t?.secondaryMeta?.projectLabel??null,s=fc({projectLabel:o,owner:i,sessionWorktree:bt.get(e.id)??null,worktrees:a?xt.get(a.normalizedPath)??[]:[],projectRootBranch:i?ue.get(i.projectId)??(a?sr.get(a.normalizedPath)?.branch:null)??null:null,isVSCode:nt})??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:nt?[]:t(Cr),inProgressItems:t(Tr)}},[xt,zt,sr,K,Tr,nt,Pe,Cr,ue,cr,Sr,mr,bt]),Or=Q.useMemo(()=>_r.map(e=>({...e,groups:e.groups.filter(e=>!e.isArchivedBucket)})),[_r]),kr=Q.useMemo(()=>{let e=K?Or.map(e=>({...e,groups:e.groups.map(e=>({...e,sessions:gr.get(e)?.filteredNodes??[]}))})):Or;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,gr,K,Or,i]),Ar=Q.useMemo(()=>Nc({sections:kr,foldersMap:Le,getOrderedGroups:br,pinnedSessionIds:ie,sessionOrderByScope:Re,sessionOrderActivityByScope:ze}),[Le,br,kr,ie,ze,Re]),jr=Q.useMemo(()=>Js({targets:Ar,collapsedProjectIds:E,collapsedGroupKeys:W,collapsedFolderIds:Ie,visibleSessionCountByGroup:A,defaultVisibleSessionCount:ic(),hasSessionSearchQuery:K,alwaysVisibleSessionIds:$e}),[$e,Ie,W,E,K,Ar,A]),Mr=Q.useMemo(()=>K?[]:[...Er,...Dr].map((e,t)=>{let n=e.node.session;return{scope:`pinned`,sessionId:n.id,projectId:e.projectId,directory:dt(Yt(n))??e.groupDirectory??null,visibleIndex:t}}),[K,Dr,Er]),[Nr,Pr]=Q.useState(null),Fr=Q.useCallback(e=>{Pr(t=>t&&t.length===e.length&&t.every((t,n)=>t===e[n])?t:[...e])},[]),Ir=Q.useMemo(()=>{if(!Nr)return Mr;let e=new Set(Nr);return Mr.filter(t=>e.has(t.sessionId))},[Mr,Nr]),Lr=Q.useMemo(()=>e?[]:Fi({pinnedTargets:Ir,projectTargets:jr}),[e,Ir,jr]),Rr=Q.useCallback(e=>{Se(`chat`),De(!1),e.scope===`project`&&e.projectId&&ye(e.projectId),En(e.sessionId,e.directory,e.projectId,e.scope)},[En,Se,ye,De]);Q.useLayoutEffect(()=>Di({targets:Lr,activate:Rr}),[Rr,Lr]);let zr=Q.useMemo(()=>{let e=new Map;return Lr.forEach(t=>{let n=_i({scope:t.scope,sessionId:t.sessionId,projectId:t.projectId});n&&e.set(n,di(Lr,t)??0)}),e},[Lr]),Br=Q.useMemo(()=>{if(!ut||K)return[];let e=[],t=(n,r)=>{if(n.session.id===ut){e.push({scope:`pinned`,sessionId:ut,projectId:r});return}n.children.forEach(e=>t(e,r))};return Er.forEach(e=>t(e.node,e.projectId)),Dr.forEach(e=>t(e.node,e.projectId)),e},[ut,K,Dr,Er]),Vr=Q.useMemo(()=>{if(!ut)return[];let e=[],t=(n,r)=>{if(n.session.id===ut){e.push({scope:`project`,sessionId:ut,projectId:r});return}n.children.forEach(e=>t(e,r))};return hr.forEach(e=>{e.groups.forEach(n=>{n.sessions.forEach(n=>t(n,e.project.id))})}),e},[ut,hr]);Q.useLayoutEffect(()=>Oi({pinned:Ir,project:jr}),[Ir,jr]),Q.useLayoutEffect(()=>{dr||Bb(ux({currentSessionId:ut,focus:ft,pinnedFocuses:Br,projectFocuses:Vr,fallbackProjectId:ut?Sr.get(ut)?.projectId??null:null}))},[ut,dr,Vr,Br,ft,Sr]);let Hr=Q.useMemo(()=>{let e=ft?.sessionId?Sr.get(ft.sessionId)?.projectId??null:null;return dx(ft,Ar,e)},[Ar,ft,Sr]),Ur=Q.useRef(null),Wr=Q.useRef(null);Q.useEffect(()=>{Wr.current&&Wr.current!==ut&&(Wr.current=null)},[ut]),Q.useLayoutEffect(()=>{if(!Hr?.projectId)return;let e=Hr.sessionId,t=pt.sessionId===e;if(!(!t&&ut!==e)){if(t){if(Ur.current===pt.revision)return;Ur.current=pt.revision,Wr.current=e}else{if(Wr.current===e)return;Wr.current=e}if(tr(Hr.projectId),Hr.groupKey&&oe(e=>{if(!e.has(Hr.groupKey))return e;let t=new Set(e);return t.delete(Hr.groupKey),t}),Hr.folderAncestorIds?.forEach(e=>{let t=Kt.getState();t.collapsedFolderIds.has(e)&&t.toggleFolderCollapse(e)}),Hr.groupKey&&Hr.visibleIndex!==void 0){let e=Hr.visibleIndex+1;j(t=>{if((t.get(Hr.groupKey)??0)>=e)return t;let n=new Map(t);return n.set(Hr.groupKey,e),n})}}},[ut,Hr,pt]);let Gr=Dx((t,n=0,r,i,a=!1,o,s=`project`,c)=>(0,$.jsx)(ex,{node:t,depth:n,groupDirectory:r,projectId:i,archivedBucket:a,currentSessionId:ut,pinnedSessionIds:ie,expandedParents:C,hasSessionSearchQuery:K,normalizedSessionSearchQuery:Pe,notifyOnSubtasks:ke,editingId:_,setEditingId:v,editTitle:y,setEditTitle:b,handleSaveEdit:Fn,handleCancelEdit:In,toggleParent:An,handleSessionSelect:Nn,handleSessionDoubleClick:Pn,togglePinnedSession:ae,handleShareSession:Rn,copiedSessionId:un,handleCopyShareUrl:Bn,handleUnshareSession:Vn,openSidebarMenuKey:P,setOpenSidebarMenuKey:ee,renamingFolderId:L,getFoldersForScope:Be,getSessionFolderId:Ye,removeSessionFromFolder:Ke,addSessionToFolder:We,createFolderAndStartRename:Wn,handleDeleteSession:Un,mobileVariant:e,alwaysShowActions:Ft,renderSessionNode:Gr,secondaryMeta:o,renderContext:s,subtreeContainsActive:c?.subtreeContainsActive??wx,subtreeContainsEditing:c?.subtreeContainsEditing??wx,menuOpenSessionId:c?.menuOpenSessionId??null,nodeStructureKey:c?.nodeStructureKey??``,childRenderExtrasFor:c?.childRenderExtrasFor,liveSessionById:At,shortcutNumber:zr.get(_i({scope:s,sessionId:t.session.id,projectId:i??null})??``)??null},`${s}:${i??``}:${t.session.id}`)),Kr=Q.useCallback(e=>{Kn(e),oe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[Kn]),qr=Q.useCallback(e=>{let t=Yn(e);if(t.length===0)return;let n=Zt.getState(),r=t.filter(e=>!n.archivedLoadedDirectories.has(e));r.length>0&&fn(r)},[Yn]),Jr=vt((e,t,n,r,i)=>{let a=e.folderScopeKey??dt(e.directory??null);a&&Xe(a,t,n,r,i).catch(()=>X.error(o(`sessions.order.saveFailed`)))}),Yr=vt((e,t,n)=>{e.isArchivedBucket&&W.has(t)&&n&&qr(n),Kr(t)}),Xr=Q.useMemo(()=>(t,n,r,i,a,o,s)=>(0,$.jsx)(Gv,{group:t,groupKey:n,isArchivedLoading:!!(t.isArchivedBucket&&r&&Yn(r).some(e=>st.has(e))),projectId:r,hideGroupLabel:i,compactBodyPadding:o,hasSessionSearchQuery:K,normalizedSessionSearchQuery:Pe,groupSearchDataByGroup:gr,visibleSessionCount:A.get(n),collapsedGroups:W,collapsedFolderIds:Ie,toggleFolderCollapse:Je,renameFolder:He,deleteFolder:Ue,showDeletionDialog:je,setDeleteFolderConfirm:ne,renderSessionNode:Gr,projectRepoStatus:O,lastRepoStatus:fr.current,showMoreGroupSessions:Gn,resetGroupSessionLimit:Kn,mobileVariant:e,alwaysShowActions:Ft,activeProjectId:_e,setActiveProjectIdOnly:ye,setActiveMainTab:Se,setSessionSwitcherOpen:De,openNewSessionDraft:Ct,addSessionToFolder:We,createFolderAndStartRename:Wn,renamingFolderId:L,renameFolderDraft:z,setRenameFolderDraft:B,setRenamingFolderId:R,pinnedSessionIds:ie,expandedParents:C,sessionOrderByScope:Re,sessionOrderActivityByScope:ze,onReorderSessions:Jr,currentSessionId:ut,shortcutTargetSessionId:Hr?.groupKey===n?Hr.sessionId:null,shortcutTargetVisibleIndex:Hr?.groupKey===n?Hr.visibleIndex??null:null,editingId:_,editTitle:y,openSidebarMenuKey:P,liveSessionById:At,alwaysVisibleSessionIds:$e,onToggleCollapsedGroup:Yr,dragHandleProps:a,scrollContainerRef:s}),[K,Pe,gr,st,Yn,A,W,Ie,Je,He,Ue,je,Gr,O,Gn,Kn,e,Ft,_e,ye,Se,De,Ct,We,Wn,L,z,ie,C,Re,ze,Jr,ut,Hr,_,y,P,At,$e,Yr]),Zr=r?null:(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(ry,{collapseAllProjects:Qn,expandAllProjects:$n}),(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:rn.requestDirectoryDialog,children:(0,$.jsx)(Z,{name:`add`,className:`size-4`})})]}),Qr=jt&&!Mt&&Nt&&!nt&&!K?(0,$.jsx)(`div`,{className:`shrink-0 px-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(Xu,{className:`min-w-0 flex-1`}),(0,$.jsx)(Ec,{className:`ml-auto shrink-0`})]})}):null,$r=!nt&&!K,ei=!K&&(Er.length>0||Dr.length>0),ti=$r||ei?(0,$.jsxs)($.Fragment,{children:[$r?(0,$.jsxs)($.Fragment,{children:[e&&Nt?(0,$.jsx)(Xu,{}):null,(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:an,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:on,children:[(0,$.jsx)(Z,{name:`time`,className:`size-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`sessions.sidebar.header.actions.scheduledTasks`)}),a?(0,$.jsx)(F_,{}):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:sn,children:[(0,$.jsx)(zc,{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)(Jc,{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)(I_,{}):null]})]}):null,(0,$.jsx)(Ts,{sidebar:!0,mobile:e})]})]}):null,ei?(0,$.jsx)(Jv,{items:Er,reorderEnabled:!0,onSessionsReordered:wr,inProgressItems:Dr,renderSessionNode:Gr,currentSessionId:ut,editingId:_,openSidebarMenuKey:P,onVisibleSessionIdsChange:Fr}):null]}):null,ni=!!(L||_||x),{selectionModeEnabled:ri,hasSelection:ii,selectedIdsSize:ai,bulkScopeIsArchived:oi,derivedSelectionScope:si,bulkScopeFolders:ci,bulkCanRemoveFromFolder:li,handleExitSelectionMode:ui,handleBulkMoveToFolder:fi,handleBulkCreateFolderAndMove:pi,handleBulkRemoveFromFolder:hi,handleBulkDelete:gi,confirmBulkDelete:vi}=sx({isInlineEditing:ni,showDeletionDialog:je,foldersMap:Le,addSessionsToFolder:Ge,removeSessionsFromFolders:qe,createFolderAndStartRename:Mn,archiveSessions:ln,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)(Kv,{hideDirectoryControls:r,isSessionSearchOpen:u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchQuery:f,setSessionSearchQuery:m,hasSessionSearchQuery:K,searchMatchCount:vr}),Qr,a?(0,$.jsx)(wy,{topContent:ti,hasLeadingSection:ti!==null&&(Er.length>0||Dr.length>0),headerAccessory:Zr,sectionsForRender:Or,projectSections:hr,activeProjectId:_e,showOnlyMainWorkspace:i,hasSessionSearchQuery:K,emptyState:qt,searchEmptyState:yr,renderGroupSessions:Xr,homeDirectory:pe,collapsedProjects:E,hideDirectoryControls:r,projectRepoStatus:O,mobileVariant:e,alwaysShowActions:Ft,toggleProject:er,setActiveProjectIdOnly:ye,setActiveMainTab:Se,setSessionSwitcherOpen:De,openNewSessionDraft:Ct,openNewWorktreeDialog:$t,syncProjectSessions:Zn,openProjectEditDialog:S,removeProject:ve,projectReorderEnabled:pr===`manual`,reorderProjects:xe,projectSortOrder:pr,getOrderedGroups:br,setGroupOrderByProject:se,openSidebarMenuKey:P,setOpenSidebarMenuKey:ee,isInlineEditing:ni}):null,ri&&ii?(0,$.jsx)(ox,{selectedCount:ai,scopeKey:si,scopeFolders:ci,archivedBucket:oi,onMoveToFolder:fi,onCreateFolderAndMove:pi,onRemoveFromFolder:hi,canRemoveFromFolder:li,onDelete:gi,onDone:ui}):null,(0,$.jsx)(V_,{normalizedProjects:rr,ownership:cr,enabled:a}),(0,$.jsx)(hy,{onOpenSettings:nn,onOpenShortcuts:Ee,onOpenUpdate:tn,showRuntimeButtons:!nt,showUpdateButton:Fe}),c?(0,$.jsx)(Ox,{onOpenChange:l}):null,Jt?(0,$.jsx)(dv,{open:!0,onOpenChange:e=>{e||S(null)},project:Jt,onSave:Qt}):null,M?(0,$.jsx)(mi,{open:!0,onOpenChange:N,onWorktreeCreated:en}):null,(0,$.jsx)($s,{}),(0,$.jsx)(ks,{}),(0,$.jsx)(rx,{value:V,setValue:H,showDeletionDialog:je,setShowDeletionDialog:Me,onConfirm:wn}),(0,$.jsx)(ax,{value:te,setValue:ne,onConfirm:On}),(0,$.jsx)(ix,{value:re,setValue:U,showDeletionDialog:je,setShowDeletionDialog:Me,onConfirm:vi})]})});function Ax(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 jx=e=>e?(0,$.jsx)(`span`,{className:`text-foreground/80 dark:text-foreground/70`,children:e}):void 0,Mx=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.replace(/\/+$/,``)},Nx=()=>{let{t:e}=Tt(),[t,n]=Q.useState(!1),[r,i]=Q.useState(!1),[a,o]=Q.useState(null),[s,c]=Q.useState([]),[l,u]=Q.useState(!1),[d,f]=Q.useState(!1),[p,m]=Q.useState(!1),[h,g]=Q.useState(!1),[_,v]=Q.useState(new Set),y=zn(e=>e.getWorktreeMetadata),b=zn(e=>e.newSessionDraft),x=zn(e=>e.setNewSessionDraftTarget),S=zn(e=>e.setDraftBootstrapPendingDirectory),C=qt,w=zn(e=>e.archiveSessions),T=q(e=>e.showDeletionDialog),E=q(e=>e.setShowDeletionDialog),D=Ae(e=>e.currentDirectory),O=Ae(e=>e.homeDirectory),k=Ae(e=>e.isHomeReady),A=Tn(e=>e.projects),j=Tn(e=>e.activeProjectId),{isMobile:M,isTablet:N,hasTouchInput:P}=Za(),ee=M||N||P,F=Q.useMemo(()=>Mx((j?A.find(e=>e.id===j)??null:null)?.path??D),[j,D,A]),I=Q.useCallback(e=>{let t=Mx(e.projectDirectory)||F;return{id:(A.find(e=>Mx(e.path)===t)??null)?.id??`path:${t}`,path:t}},[F,A]),L=h&&_.size>0,R=Q.useMemo(()=>{let e=a?.worktree;return e&&typeof e.branch==`string`&&e.branch.trim().length>0?!0:s.length>0&&s.every(({metadata:e})=>typeof e.branch==`string`&&e.branch.trim().length>0)},[a?.worktree,s]),z=a?.mode===`worktree`,B=z,V=p||!z||!R,H=p||!z;Q.useEffect(()=>{r||!k||A.length>0||(i(!0),n(!0))},[r,k,A.length]);let te=Q.useCallback(e=>{o({sessions:e.sessions,dateLabel:e.dateLabel,mode:e.mode??`session`,worktree:e.worktree??null})},[]),ne=Q.useCallback(()=>{o(null),c([]),u(!1),f(!1),m(!1),g(!1),v(new Set)},[]),re=Q.useCallback(t=>{if(t.sessions.length===0)return;let n=t.sessions.map(e=>e.id);nc({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(()=>rn.onDeleteRequest(e=>{if(!T&&(e.mode??`session`)===`session`){re(e);return}te(e)}),[te,T,re]),Q.useEffect(()=>rn.onDirectoryRequest(()=>{n(!0)}),[]),Q.useEffect(()=>{if(!a){c([]),u(!1),f(!1),g(!1),v(new Set);return}let e=a.sessions.map(e=>{let t=y(e.id);return t?{session:e,metadata:t}:null}).filter(e=>!!e);c(e),u(!1),g(!1),v(new Set);let t=new Map;if(a.worktree?.path&&t.set(Mx(a.worktree.path),a.worktree),e.forEach(({metadata:e})=>{e.path&&t.set(Mx(e.path),e)}),t.size===0){g(!0);return}let n=!1;return(async()=>{let e=new Map,r=new Set;await Promise.all(Array.from(t.entries()).map(async([t,n])=>{try{let i=await _o(n.path);e.set(t,i),i?.isDirty&&r.add(t)}catch{n.status&&(e.set(t,n.status),n.status.isDirty&&r.add(t))}})).catch(e=>{console.warn(`Failed to inspect worktree status before deletion:`,e)}),!n&&(v(r),g(!0),o(t=>{if(!t?.worktree?.path)return t;let n=Mx(t.worktree.path),r=e.get(n);if(!r)return t;let i=t.worktree.status;return i?.isDirty===r.isDirty&&i?.ahead===r.ahead&&i?.behind===r.behind&&i?.upstream===r.upstream?t:{...t,worktree:{...t.worktree,status:r}}}),c(t=>t.map(t=>{let n=Mx(t.metadata.path),r=e.get(n);return r?{session:t.session,metadata:{...t.metadata,status:r}}:t})))})(),()=>{n=!0}},[a,y]),Q.useEffect(()=>{R||u(!1)},[R]);let U=Q.useCallback(async(t,n)=>{let r=l&&R,i=I(t),a=Mx(t.path),o=Mx(i.path);try{await mo(i,t,{deleteRemoteBranch:r,deleteLocalBranch:n});let e=Mx(b?.directoryOverride);return b?.open&&a&&e===a&&o&&(S(null),x({projectId:i.id,directoryOverride:o},{force:!0})),Mx(D)===a&&o&&Ae.getState().setDirectory(o,{showOverlay:!1}),!0}catch(t){return X.error(e(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:jx(t instanceof Error?t.message:e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),!1}},[R,D,l,I,b?.directoryOverride,b?.open,S,x,e]),ie=Q.useCallback((t,n)=>{let r=l&&R;(async()=>{if(!await U(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:jx(i)})})()},[R,l,U,e]),ae=Q.useCallback(async()=>{if(a){m(!0);try{let t=B&&d;if(a.sessions.length===0&&z&&a.worktree){ie(a.worktree,t),ne();return}if(a.sessions.length===1){let t=a.sessions[0];if(z){if(!await C(t.id)){X.error(e(`sessions.sidebar.session.archive.error`)),m(!1);return}qs({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 nc({sessionIds:[t.id],message:e(`sessions.sidebar.session.delete.success`),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:e(`sessions.sidebar.session.delete.error`)})}else{let n=a.sessions.map(e=>e.id),r=[],i=[];if(z){let e=await w(n);r=e.archivedIds,i=e.failedIds}else nc({sessionIds:n,message:n.length===1?e(`sessions.sidebar.bulkActions.deletedSingle`,{count:n.length}):e(`sessions.sidebar.bulkActions.deletedPlural`,{count:n.length}),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:n.length===1?e(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:n.length}):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:n.length})}),r=n,i=[];if(z&&a.worktree&&i.length===0&&ie(a.worktree,t),z&&r.length>0&&qs({sessionIds:r,message:r.length===1?e(`sessions.sidebar.bulkActions.archivedSingle`,{count:r.length}):e(`sessions.sidebar.bulkActions.archivedPlural`,{count:r.length}),undoLabel:e(`sessions.sidebar.undo`),settingsLabel:e(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:r.length===1?e(`sessions.sidebar.session.archive.undoFailed`):e(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:r.length})}),i.length>0&&(X.error(z?i.length===1?e(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):e(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}):i.length===1?e(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:i.length}):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:i.length}),{description:jx(e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),r.length===0)){m(!1);return}}z&&a.sessions.length===1&&a.worktree&&ie(a.worktree,t),ne()}finally{m(!1)}}},[a,d,C,w,ne,B,z,ie,e]),W=a?.worktree??s[0]?.metadata??null,oe=a?a.mode===`worktree`?a.sessions.length===0?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked`):a.sessions.length===1?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked`,{count:a.sessions.length}):e(`sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked`,{count:a.sessions.length}):a.sessions.length===1?a.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate`,{dateLabel:a.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionOne`):a.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate`,{count:a.sessions.length,dateLabel:a.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionMany`,{count:a.sessions.length}):``,G=a?(0,$.jsxs)(`div`,{className:J(z?`space-y-3`:`space-y-2`),children:[a.sessions.length>0&&(0,$.jsxs)(`div`,{className:J(z?`rounded-lg bg-muted/30 p-3`:`space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3`),children:[z&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:a.sessions.length===1?e(`sessions.sidebar.sessionDialogs.linkedSessionSingle`):e(`sessions.sidebar.sessionDialogs.linkedSessionPlural`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:a.sessions.length})]}),(0,$.jsxs)(`ul`,{className:J(z?`mt-2 space-y-1`:`space-y-0.5`),children:[a.sessions.slice(0,5).map(t=>(0,$.jsxs)(`li`,{className:J(z?`flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground`:`typography-micro text-muted-foreground/80`),children:[(0,$.jsx)(`span`,{className:J(!z&&`hidden`),children:`•`}),(0,$.jsx)(`span`,{className:`truncate`,children:t.title||e(`sessions.sidebar.session.untitled`)})]},t.id)),a.sessions.length>5&&(0,$.jsx)(`li`,{className:J(z?`px-2.5 py-1 text-xs text-muted-foreground/70`:`typography-micro text-muted-foreground/70`),children:e(`sessions.sidebar.dialogs.sessionList.more`,{count:a.sessions.length-5})})]})]}),z?(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg bg-muted/30 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:e(`sessions.sidebar.sessionDialogs.worktree.label`)}),W?.label?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:W.label}):null]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/80 break-all`,children:W?St(W.path,O):e(`sessions.sidebar.sessionDialogs.worktree.pathUnavailable`)}),L&&(0,$.jsx)(`p`,{className:`typography-micro text-status-warning`,children:e(`sessions.sidebar.sessionDialogs.worktree.uncommittedWarning`)})]}):(0,$.jsx)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/60 p-3`,children:(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/80`,children:e(`sessions.sidebar.sessionDialogs.delete.note`)})})]}):null,se=z?R?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{V||u(e=>!e)},disabled:V,className:J(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,V?`cursor-not-allowed opacity-60`:`hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),children:[l?(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}):(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}),e(`sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch`)]}):(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:e(`sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable`)}):null,ce=z?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{H||f(e=>!e)},disabled:H,className:J(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,H?`cursor-not-allowed opacity-60`:`hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),children:[d?(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}):(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}),e(`sessions.sidebar.sessionDialogs.actions.deleteLocalBranch`)]}):null,le=z?(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[ce,se]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{variant:`ghost`,onClick:ne,disabled:p,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{variant:`destructive`,onClick:ae,disabled:p,children:e(p?`sessions.sidebar.sessionDialogs.actions.deleting`:`sessions.sidebar.sessionDialogs.actions.deleteWorktree`)})]})]}):(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>E(!T),className:`inline-flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":!T,children:[T?(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}):(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}),e(`sessions.sidebar.dialogs.neverAsk`)]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{variant:`ghost`,onClick:ne,disabled:p,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Y,{variant:`destructive`,onClick:ae,disabled:p,children:p?e(`sessions.sidebar.sessionDialogs.actions.deleting`):a?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`)})]})]}),ue=z?e(`sessions.sidebar.sessionDialogs.actions.deleteWorktree`):a?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`);return(0,$.jsxs)($.Fragment,{children:[ee?(0,$.jsx)(wa,{open:!!a,onClose:()=>{p||ne()},title:ue,footer:(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:le}),children:(0,$.jsxs)(`div`,{className:`space-y-2 pb-2`,children:[oe&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/80`,children:oe}),G]})}):(0,$.jsx)(fr,{open:!!a,onOpenChange:e=>{if(!e){if(p)return;ne()}},children:(0,$.jsxs)(lr,{className:J(z?`max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3`:`max-w-[min(520px,100vw-2rem)] space-y-2 pb-2`),children:[(0,$.jsxs)(sr,{children:[(0,$.jsxs)(ur,{className:J(z&&`flex items-center gap-2`),children:[z&&(0,$.jsx)(Z,{name:`delete-bin`,className:`h-5 w-5`}),ue]}),oe&&(0,$.jsx)(dr,{children:oe})]}),(0,$.jsx)(`div`,{className:J(z&&`flex-1 min-h-0 overflow-y-auto space-y-2`),children:G}),(0,$.jsx)(cr,{className:`mt-2 gap-2 pt-1 pb-1`,children:le})]})}),(0,$.jsx)(Uc,{open:t,onOpenChange:n})]})};function Px(){let{host:e,snapshot:t,inventory:n,error:r,requested:i,requestLoad:a}=Fo(),{t:o}=Tt(),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)(cd,{"data-gui-plugin-page-surface":!0,children:e&&l?(0,$.jsx)(Ka,{fallback:(0,$.jsx)(il,{message:o(`guiPlugins.error`)}),children:(0,$.jsx)(rl,{host:e,kind:`page`,contributionKey:l.key,revision:u})},JSON.stringify([l.key,u])):f?(0,$.jsx)(il,{message:o(`guiPlugins.error`)}):null})})}var Fx=Q.createContext(null),Ix=e=>{let t=(0,xl.c)(3),{children:n,value:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(Fx.Provider,{value:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},Lx=Do(()=>ut(()=>import(`./TerminalView-2DhtuWTv.js`).then(e=>({default:e.TerminalView})),__vite__mapDeps([77,1,4,2,3,5,6,7,8,9,10,11,17,12,13,14,16,78,50,51,52,53,54,55,15,18,19,20,79,36,37,38,39,49,22,56,33,34,35,57,58,59,40,42,80,63,81,82,83,84,85,86,87]))),Rx=Do(()=>ut(()=>import(`./DiagramView-DCrAY37j.js`).then(e=>({default:e.DiagramView})),__vite__mapDeps([88,1,3,2,7,8,9,10,11,13,14,17,12,16,4,56,36,5,6,37,20,38,39,42,63,50,51,52,53,54,55,15,18,19,49,22,33,34,35,57,58,59,89,90]))),zx=Do(()=>ut(()=>import(`./SettingsView-C1dLufb0.js`).then(e=>e.n).then(e=>({default:e.SettingsView})),__vite__mapDeps([91,1,2,3,4,5,6,92,93,9,7,50,51,52,10,11,8,53,12,16,14,54,55,15,17,13,18,19,20,22,94,95,96,56,33,34,35,36,37,38,39,97,98,49,57,58,59,42,99,60,100,101,65,40,41,43,44,61,102,103,104,105,106,107,47,108,80,83,84,85,109,81,110,111,112,48,23,24,25,26,27,28,29,30,31,32,62,63,64,113,66,114,82,115,116,117,118,119,120,72,121,122,123,124,125,126,87,74,127,128,129,130,131,132,133]))),Bx=Do(()=>ut(()=>import(`./SettingsWindow-DZFZJ8PI.js`).then(e=>({default:e.SettingsWindow})),__vite__mapDeps([134,1,7,12,36,5,2,3,6,37,9,10,11,20,38,39,91,4,92,93,50,51,52,8,53,16,14,54,55,15,17,13,18,19,22,94,95,96,56,33,34,35,97,98,49,57,58,59,42,99,60,100,101,65,40,41,43,44,61,102,103,104,105,106,107,47,108,80,83,84,85,109,81,110,111,112,48,23,24,25,26,27,28,29,30,31,32,62,63,64,113,66,114,82,115,116,117,118,119,120,72,121,122,123,124,125,126,87,74,127,128,129,130,131,132,133]))),Vx=Do(()=>ut(()=>import(`./MultiRunWindow-BDh7FxgY.js`).then(e=>({default:e.MultiRunWindow})),__vite__mapDeps([135,1,7,12,36,5,2,3,6,37,9,10,11,20,38,39,42,136,50,4,51,52,8,53,16,14,54,55,15,17,13,18,19,33,34,35,49,22,56,57,58,59,102,137,138,139,140,99,60,100,101,65,40,41,141,108,103,104,80,107,47,83,84,85,109,81,122]))),Hx=Do(()=>ut(()=>import(`./AssistantView-YVdgtBeh.js`).then(e=>e.n).then(e=>({default:e.AssistantView})),__vite__mapDeps([142,1,2,3,5,6,7,8,9,10,11,12,13,14,56,33,34,35,36,37,20,38,39,97,4,53,16,54,55,15,17,18,19,22,98,49,50,51,52,57,58,59,42,99,60,100,101,65,40,41,43,44,61,80,143,46,107,47,110,144,69,67,68,109,81,145,146,138,139,140,112,141,62,63,64,147,148,149,127]))),Ux=()=>{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}=Za(),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=ir(-E.current),O=(0,Q.useRef)(0),k=ir(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),ar(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),ar(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=zn.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)(Zp,{isActive:!v})});case`diff`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(lc,{})});case`terminal`:return n?null:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Lx,{})});case`files`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Ud,{})});case`diagram`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Rx,{})});default:return null}},[a,n,v]),N=a===`schedule`,P=a===`assistant`,ee=a===`plugin`,F=N||P||ee,I=a===`chat`,L=!F&&!c;return(0,$.jsx)(Ws,{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)(Mc,{}),(0,$.jsx)(D_,{}),(0,$.jsx)(j_,{}),(0,$.jsx)(Nx,{}),f?(0,$.jsxs)(Ix,{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&&!F&&(0,$.jsx)(Fu,{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)(Ka,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Us,{})})})}),P&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Ka,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Hx,{})})})}),L&&(0,$.jsx)(`div`,{className:J(`absolute inset-0`,!I&&`invisible`),children:(0,$.jsx)(Ka,{children:(0,$.jsx)(vc,{})})}),L&&M&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Ka,{children:M})}),u&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(Ka,{children:(0,$.jsx)(gl,{onCreated:()=>d(!1),onCancel:()=>d(!1)})})}),(0,$.jsx)(is.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)(Ka,{children:(0,$.jsx)(kx,{mobileVariant:!0,isVisible:b})})}),S&&(0,$.jsx)(is.div,{className:`absolute inset-0 z-20 bg-sidebar`,"data-page-scroll-lock":`true`,style:{x:k},"aria-hidden":!v,children:(0,$.jsx)(Ka,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Zp,{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)(Ka,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(zx,{onClose:()=>l(!1)})})})}),(0,$.jsx)(Ka,{children:(0,$.jsx)(Zs,{})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ed,{}),(0,$.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:[(0,$.jsx)(Ju,{isOpen:e,isMobile:f,className:`border-border/50`,topBar:(0,$.jsx)(Yu,{}),children:(0,$.jsx)(kx,{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:F?(0,$.jsx)(`main`,{className:`flex-1 overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(Ka,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:ee?(0,$.jsx)(Px,{}):P?(0,$.jsx)(Hx,{}):(0,$.jsx)(Us,{})})})}):(0,$.jsxs)(T_,{header:(0,$.jsx)(Fu,{}),footer:(0,$.jsx)(Bu,{isOpen:n,isMobile:f,children:n?(0,$.jsx)(Ka,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Lx,{})})}):null}),children:[L&&(0,$.jsx)(`div`,{className:J(`absolute inset-0`,!I&&`invisible`),children:(0,$.jsx)(Ka,{children:(0,$.jsx)(vc,{})})}),L&&M&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Ka,{children:M})})]})})]}),(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Bx,{open:c,onOpenChange:l})}),(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Vx,{open:u,onOpenChange:d})})]})]})})},Wx=9e4,Gx=15e3,Kx=3e5,qx=[2e3,5e3],Jx=6e4,Yx=12e4,Xx=3e5,Zx=4,Qx=432e5,$x=`yuri.github-pr-status`,eS=e=>e===`closed`||e===`merged`,tS=e=>{let t=e?.checks;return t?t.state===`pending`||t.pending>0:!1},nS=(e,t,n)=>`${e}::${t}`,rS=new Map,iS=new Map,aS=new Set,oS=new Map,sS=2,cS=0,lS=[],uS=()=>cS<sS?(cS+=1,Promise.resolve()):new Promise(e=>{lS.push(e)}),dS=()=>{let e=lS.shift();if(e){e();return}cS=Math.max(0,cS-1)},fS=()=>({status:null,isLoading:!1,error:null,isInitialStatusResolved:!1,lastRefreshAt:0,lastDiscoveryPollAt:0,watchers:0,params:null,identity:null,resolvedRemoteName:null}),pS=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,mS=e=>{let t=pS(e);return!t?.directory||!t.branch?null:`${t.directory}::${t.branch}`},hS=(e,t)=>Object.entries(e).filter(([,e])=>mS(e)===t).map(([e])=>e),gS=(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}}},_S=e=>!e?.params?.canShow||!e.params.github?.prStatus?null:{...e.params,remoteName:e.params.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null},vS=(e,t,n)=>{let r=hS(e,t),i=r.map(t=>_S(e[t])).filter(e=>!!e);if(i.length===0)return null;let a=_S(e[n]);if(a&&mS(e[n])===t)return a;let o=r.map(t=>e[t]).find(e=>!!(e?.resolvedRemoteName&&_S(e)));return o?_S(o):i.find(e=>!!e.remoteName)||(i[0]??null)},yS=e=>({status:e.status,isInitialStatusResolved:e.isInitialStatusResolved,lastRefreshAt:e.lastRefreshAt,lastDiscoveryPollAt:e.lastDiscoveryPollAt,identity:pS(e),resolvedRemoteName:e.resolvedRemoteName??e.status?.resolvedRemoteName??null}),bS=e=>({...fS(),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}),xS=ne()(re((e,t)=>({entries:{},activeRequestCount:0,totalRequestCount:0,ensureEntry:t=>{e(e=>e.entries[t]?e:{entries:{...e.entries,[t]:fS()}})},setParams:(t,n)=>{e(e=>{let r=e.entries[t]??fS();return{entries:{...e.entries,[t]:gS(r,n)}}})},startWatching:n=>{if(e(e=>{let t=e.entries[n]??fS();return{entries:{...e.entries,[n]:{...t,watchers:t.watchers+1}}}}),rS.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=iS.get(n)??[];i.push(r),iS.set(n,i)};t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0}),qx.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<Kx)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}eS(r.status?.pr?.state)||Date.now()-r.lastRefreshAt<(tS(r.status)?Jx:r.status?.checks&&r.status.checks.state!==`pending`?Xx:Yx)||t().refresh(n,{force:!0,onlyExistingPr:!0,silent:!0,markInitialResolved:!0})}},Gx);rS.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=rS.get(n);typeof i==`number`&&window.clearInterval(i),rS.delete(n);let a=iS.get(n);a&&a.length>0&&a.forEach(e=>{window.clearTimeout(e)}),iS.delete(n)},refresh:async(n,r)=>{let i=t(),a=i.entries[n],o=mS(a);if(!a||!o)return;let s=hS(i.entries,o),c=s.some(e=>!!i.entries[e]?.status?.pr);if(r?.onlyExistingPr&&!c)return;let l=oS.get(o)??0;if(!r?.force&&Date.now()-l<Wx||aS.has(o))return;let u=vS(i.entries,o,n);if(u){if(aS.add(o),oS.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}}),aS.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}}),aS.delete(o);return}try{e(e=>({...e,activeRequestCount:e.activeRequestCount+1,totalRequestCount:e.totalRequestCount+1})),await uS();let t;try{t=await u.github.prStatus(u.directory,u.branch,u.remoteName??void 0,{force:r?.force})}finally{dS()}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=pS(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{aS.delete(o),e(e=>({...e,activeRequestCount:Math.max(0,e.activeRequestCount-1)}))}}},refreshTargets:async(e,n)=>{await cv(Array.from(new Set(e.map(e=>{let t=e.directory.trim(),n=e.branch.trim();return!t||!n?null:nS(t,n,e.remoteName??null)}).filter(e=>!!e))),Zx,e=>t().refresh(e,n))},updateStatus:(t,n)=>{e(e=>{let r=e.entries[t]??fS();return{entries:{...e.entries,[t]:{...r,status:n(r.status)}}}})}}),{name:$x,storage:We(),partialize:e=>({entries:Object.fromEntries(Object.entries(e.entries).filter(([,e])=>{let t=pS(e);if(!t?.directory||!t.branch)return!1;let n=Math.max(e.lastRefreshAt,e.lastDiscoveryPollAt);return n===0||Date.now()-n<Qx}).map(([e,t])=>[e,yS(t)]))}),merge:(e,t)=>{let n=e?.entries??{};return{...t,entries:Object.fromEntries(Object.entries(n).map(([e,t])=>[e,bS(t)]))}}})),SS=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`},CS=e=>{let t=(0,xl.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},wS=e=>{let t=(0,xl.c)(43),{title:n,snapshot:r,emptyLabel:i}=e,{t:a}=Tt(),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(ES,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?SS(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)(CS,{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)(CS,{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)(CS,{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)($o,{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},TS=e=>{let t=(0,xl.c)(104),{onClose:n}=e,{t:r}=Tt(),[i,a]=Q.useState(`memory`),[o,s]=Q.useState(`idle`),c=zn(DS),l=dn(OS),u=un(),d=Ht(),[f,p]=Q.useState(kS),m,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>Te(()=>{p(ke())}),h=[],t[0]=m,t[1]=h):(m=t[0],h=t[1]),Q.useEffect(m,h);let g;if(t[2]!==d||t[3]!==u){bb0:{let e=Le(),t={};if(!e){g=t;break bb0}let n=e.getCacheBudget?.(),r=n?n.listCanonical().map(AS):u.map(e=>({directory:d,sessionID:e.id}));for(let n of r){if(d&&n.directory!==d)continue;let r=e.getTranscript(Ne(n.directory,n.sessionID));t[n.sessionID]=r.messageOrder.map(e=>r.messagesByID[e]).filter(jS)}g=t}t[2]=d,t[3]=u,t[4]=g}else g=t[4];let _=g,v=xS(MS),[y,b]=Q.useState(NS),[x,S]=Q.useState(PS),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(Ie()),S(De())};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,ee;t[28]===o?(P=t[29],ee=t[30]):(P=()=>{if(o===`idle`)return;let e=window.setTimeout(()=>{s(`idle`)},1500);return()=>window.clearTimeout(e)},ee=[o],t[28]=o,t[29]=P,t[30]=ee),Q.useEffect(P,ee);let F=0,I=0,L=0;for(let e of Object.keys(_)){let t=_[e]??[];I+=t.length;for(let e of t)e.role===`user`?L+=1:e.role===`assistant`&&(F+=1)}let R;t[31]!==F||t[32]!==I||t[33]!==L?(R={assistant:F,total:I,user:L},t[31]=F,t[32]=I,t[33]=L,t[34]=R):R=t[34];let z=R,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(FS),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:Ie(),vscode:De()};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:()=>{xe(),b(Ie()),S(De())},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]!==z||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)(CS,{label:r(`memoryDebugPanel.metric.totalMessages`),value:z.total}),(0,$.jsx)(CS,{label:r(`memoryDebugPanel.metric.cachedSessions`),value:`${te} / ${Rr.MAX_SESSIONS}`}),(0,$.jsx)(CS,{label:r(`memoryDebugPanel.metric.userMessages`),value:z.user}),(0,$.jsx)(CS,{label:r(`memoryDebugPanel.metric.assistantMessages`),value:z.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:Xr()})})]}),(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:Rr.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)($o,{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)(ca,{children:[(0,$.jsx)(aa,{asChild:!0,children:(0,$.jsx)(Y,{size:`sm`,variant:`outline`,className:`typography-meta`,onClick:()=>{u.map(IS),Object.keys(_),V.map(LS),Object.fromEntries(l)},children:r(`memoryDebugPanel.actions.logState`)})}),(0,$.jsx)(oa,{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)(CS,{label:r(`memoryDebugPanel.metric.uiMetrics`),value:y.entries.length}),(0,$.jsx)(CS,{label:r(`memoryDebugPanel.metric.vscodeMetrics`),value:x.entries.length}),(0,$.jsx)(CS,{label:r(`memoryDebugPanel.metric.messageListRenders`),value:j.messageListRender}),(0,$.jsx)(CS,{label:r(`memoryDebugPanel.metric.messageListStreamRenders`),value:j.messageListRenderStreaming}),(0,$.jsx)(CS,{label:r(`memoryDebugPanel.metric.chatMessageRenders`),value:j.chatMessageRender}),(0,$.jsx)(CS,{label:r(`memoryDebugPanel.metric.chatMessageStreamRenders`),value:j.chatMessageRenderStreaming}),(0,$.jsx)(CS,{label:r(`memoryDebugPanel.metric.chatMessageStaticDuringStream`),value:j.chatMessageRenderStaticDuringStream}),(0,$.jsx)(CS,{label:r(`memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn`),value:j.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),(0,$.jsx)(wS,{title:r(`memoryDebugPanel.section.uiStreamingMetrics`),snapshot:y,emptyLabel:r(`memoryDebugPanel.section.noUiSamples`)}),x.entries.length>0?(0,$.jsx)(wS,{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]=z,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 Se;return t[100]!==le||t[101]!==ye||t[102]!==be?(Se=(0,$.jsxs)(_a,{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]=Se):Se=t[103],Se};function ES(e,t){return e+t.count}function DS(e){return e.currentSessionId}function OS(e){return e.sessionMemoryState}function kS(){return ke()}function AS(e){return e.scope}function jS(e){return!!e}function MS(e){return e.totalRequestCount}function NS(){return Ie()}function PS(){return De()}function FS(e,t){return t.lastAccessed-e.lastAccessed}function IS(e){return{id:e.id,title:e.title}}function LS(e){return{id:e.id,title:e.title,total:e.messageCount,user:e.userMessageCount,assistant:e.assistantMessageCount}}var RS=()=>{let{isMobile:e,closeActiveContextPanelTab:t}=q.getState();if(e)return;let n=Lo();n&&t(n)||P()&&ee(`desktop_close_current_window`).catch(e=>{console.warn(`[menu-actions] failed to close current window`,e)})},zS=()=>{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()??``:``},BS=async()=>{let e=zS()||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`)},VS=`yuri:menu-action`,HS=`yuri:check-for-updates`,US=e=>typeof e?.listen==`function`?`bridge`:`dom`,WS=e=>{let t=zn(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=Ds(e=>e.checkForUpdates),{setThemeMode:_}=rr(),{t:v}=Tt(),y=Q.useRef(!1),b=typeof window>`u`?null:window.__YURI_DESKTOP__,x=US(b),S=Q.useCallback(()=>{y.current||(y.current=!0,g().then(()=>{let{available:e,error:t}=Ds.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(()=>{rn.requestDirectoryDialog()},[]),w=Q.useCallback(e=>{Mi(e,zn.getState().currentSessionId,e=>{s(`chat`),o(!1),zn.getState().setCurrentSession(e.sessionId,e.directory)})},[s,o]),T=Q.useCallback(e=>{let{activeProjectId:t,projects:n,setActiveProject:r}=Tn.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),fi();break;case`change-workspace`:C();break;case`close-tab-or-window`:RS();break;case`toggle-right-sidebar`:{let e=Lo();e&&d(e);break}case`open-right-sidebar-git`:{let e=Lo();e&&q.getState().openContextPanel(e),f(!0),p(`git`);break}case`open-right-sidebar-files`:{let e=Lo();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)&&BS();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`:pi();break;case`zoom-out`:hi();break;case`zoom-reset`:zi();break;case`go-back`:Ae.getState().goBack();break;case`go-forward`:Ae.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`:Ki().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(VS,e),window.addEventListener(HS,t),()=>{window.removeEventListener(VS,e),window.removeEventListener(HS,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])},GS=(e,t)=>e<t?-1:+(e>t),KS=e=>JSON.stringify([...e.entries()].map(([e,t])=>[e,[...new Set(t)].sort(GS)]).sort(([e],[t])=>GS(e,t)));async function qS({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 JS=`yuri:tray-action`,YS=3e4,XS=120,ZS=20,QS=()=>{if(typeof window>`u`)return!1;let e=window.__YURI_PLATFORM__;return e===`darwin`||e===`win32`},$S=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},eC=e=>{let t=Array.isArray(e.questions)?e.questions[0]:void 0;return t?.header||t?.question||`Question`},tC=e=>ln(e),nC=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t},rC=(e,t,n,r)=>{if(!e)return``;let i=Cn(t,n,e),a=nC(i?i.path:e),o=Fn(e),s=o&&r.get(o)||``;if(!s){for(let[e,t]of ra.getState().directories)if(Fn(e)===o){s=t.status?.current??``;break}}if(!s)for(let e of n.values()){let t=e.find(e=>Fn(e.path)===o);if(t?.branch){s=t.branch;break}}return s?`${a} · ${s}`:a},iC=()=>{let{results:e,dropdownProviderIds:t,displayMode:n}=Os.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 _s(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:pa(n.label??t),value:ja(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}},aC=async()=>{try{if(k())return`Local Yuri`;let e=window.__YURI_LOCAL_ORIGIN__||window.location.origin,t=m();if(t&&V(t,e))return`Local Yuri`;let n=(await H()).hosts.find(e=>t?V(t,te(e)):!1);return n?.label?.trim()?B(n.label.trim()):`Instance`}catch{return``}},oC=()=>{let e=new Map,t=new Map,n=[],r=new Map,i;try{i=Ce()}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(Fn(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:$S(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:eC(r),directory:a})}}return{statusById:e,branchByDirectory:t,approvals:n,titleById:r}},sC=()=>{let e=Zt.getState().activeSessions,t=new Set;e.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>tC(t)-tC(e)).slice(0,ZS).forEach(e=>{let n=Yt(e);n&&t.add(n)});let n=new Map;for(let r of e){if(!r?.id)continue;let e=Yt(r);if(!e||!t.has(e))continue;let i=n.get(e)??[];i.push(r.id),n.set(e,i)}return n},cC=e=>{let t=oC(),n=jn.getState().index.session,r=Zt.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=en.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=Tn.getState().projects,d=zn.getState().availableWorktreesByProject,f=r.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>tC(t)-tC(e)).slice(0,ZS).map(e=>{let r=[e.id,...o(e.id)],i=Yt(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:rC(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:iC(),dockBadgeCount:h}},lC=()=>{Q.useEffect(()=>{if(!QS()||!P())return;let e=!1,t=``,n=null,r=``,i=()=>{if(e)return;let n=cC(r),i=JSON.stringify(n);i!==t&&(t=i,ee(`desktop_tray_update`,n))};aC().then(t=>{e||(r=t,i())});let a=null,o=``,s=()=>{let e=Zn.getState();return e.isConnected&&e.connectionPhase===`connected`},c=()=>{if(a)return a;let t=sC();return o=KS(t),a=qS({targets:t,isReady:s,concurrency:2,isDisposed:()=>e,fetchStatus:async()=>{try{let e=await be.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)=>{Nn(e,t,[...n])}}).finally(()=>{a=null;let t=sC();!e&&s()&&KS(t)!==o&&c()}),a},l=()=>{e||n!==null||(n=window.setTimeout(()=>{n=null,i()},XS))},u=new Map,d=()=>{if(e)return;let t;try{t=Ce()}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=Ce().subscribeRegistry(()=>{d(),l()})}catch{}d();let p=jn.subscribe(()=>l()),m=Zt.subscribe(()=>{l(),s()&&KS(sC())!==o&&c()}),h=Tn.subscribe(()=>l()),g=zn.subscribe(()=>l()),_=ra.subscribe(()=>l()),v=q.subscribe(()=>l()),y=en.subscribe(()=>l()),b=s(),x=Zn.subscribe(()=>{let e=s();e&&!b&&c(),b=e});b&&c();let S=Os.subscribe(()=>l());Os.getState().loadSettings().then(()=>{if(e)return;let{dropdownProviderIds:t,results:n}=Os.getState();t.length>0&&t.some(e=>!n.some(t=>t?.providerId===e))&&Os.getState().fetchAllQuotas()});let C=window.setInterval(()=>{let e=Os.getState();e.autoRefresh&&e.dropdownProviderIds.length>0&&e.fetchAllQuotas()},Math.max(3e4,Os.getState().refreshIntervalMs||6e4)),w=window.setInterval(()=>{d(),i()},YS);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(!QS()||typeof window>`u`)return;let e=window.__YURI_DESKTOP__?.listen;if(typeof e!=`function`)return;let t=e=>{e.type===`respond-permission`&&Un(e.sessionId,e.id,e.response).catch(()=>{X.error(`Failed to respond to permission request`)})},n=null;return e(JS,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{}}},[])},uC=`/api/notifications/stream`,dC=()=>typeof document>`u`||document.visibilityState===`visible`&&document.hasFocus(),fC=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}},pC=e=>{let t=(0,xl.c)(3),n=e?.enabled??!0,r,i;t[0]===n?(r=t[1],i=t[2]):(r=()=>{if(!n||I()||!S()||typeof window>`u`||typeof EventSource>`u`)return;let e=new EventSource(c().sse(uC));return e.onmessage=mC,()=>{e.close()}},i=[n],t[0]=n,t[1]=r,t[2]=i),Q.useEffect(r,i)};function mC(e){let t;try{t=JSON.parse(e.data)}catch{return}let n=q.getState();if(!n.nativeNotificationsEnabled)return;let r=fC(t);r&&((r.requireHidden??n.notificationMode!==`always`)&&dC()||z()?.notifications?.notifyAgentCompletion(r))}var hC=`pwa-install-toast-shown`,gC=`pwa-install-toast-dismissed`,_C=()=>{let e=(0,xl.c)(6),{browserTab:t}=As(),{t:n}=Tt(),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`||!S()||!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=Ve(),c=Be();dc({dismissed:s.getItem(gC),sessionShown:c.getItem(hC),hasActiveToast:n!==null})&&(c.setItem(hC,`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:()=>{Ve().setItem(gC,`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 vC(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`),zn.getState().setCurrentSession(t,n)}var yC=({open:e,onOpenChange:t})=>{let{t:n}=Tt(),[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 Et())})()},[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)(fr,{open:e,onOpenChange:t,children:(0,$.jsx)(lr,{className:`max-w-xs p-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[(0,$.jsx)(Ya,{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`)})]})})})},bC=(e,t)=>{let n=e.get(t);return typeof n==`string`&&n.trim()||null},xC=(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},SC=()=>{let e=js(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=bC(t,`code`),a=xs(t),o=as(t),s=bC(t,`error`),c=bC(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(xC(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`})})]})})},CC=()=>{let e=Zt(e=>e.startupSyncProgress.active),t=Zt(e=>e.startupSyncProgress.phase),n=Zt(e=>e.startupSyncProgress.completed),r=Zt(e=>e.startupSyncProgress.total),{locale:i,t:a}=Tt(),[o,s]=Q.useState(!0),c=At(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},wC=(e,t,n,r=350)=>n?Math.max(0,r-Math.max(0,t-e)):null;function TC(e){let t=(0,xl.c)(21),{transition:n,ready:r}=e,{t:i}=Tt(),a=Ia(!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=wC(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)(Ya,{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 EC=Do(()=>ut(()=>import(`./OnboardingScreen-BdU6Tyax.js`).then(e=>({default:e.OnboardingScreen})),__vite__mapDeps([150,1,4,2,3,5,6,92,7,53,9,10,11,8,12,16,14,54,55,36,37,20,38,39,42,43,44,103,111,40]))),DC=36e5,OC=12e5,kC=()=>{let e=(0,xl.c)(3),t=q(IC),n=q(LC),r;return e[0]!==t||e[1]!==n?(r=(0,$.jsx)(yC,{open:t,onOpenChange:n}),e[0]=t,e[1]=n,e[2]=r):r=e[2],r},AC=e=>{let t=(0,xl.c)(21),{onRetry:n,isRetrying:r}=e,{t:i}=Tt(),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},jC=e=>e?e.replace(/\\/g,`/`).replace(/\/+$/g,``):``,MC=()=>{if(typeof window>`u`||!eo())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`}},NC=()=>typeof window>`u`?!1:window.location.pathname===ls,PC=e=>{let t=(0,xl.c)(22),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=e,a=Ae(RC),o=zn(zC),s=zn(BC),c=ni(),l=Q.useRef(null),u;t[0]===n.directory?u=t[1]:(u=jC(n.directory),t[0]=n.directory,t[1]=u);let d=u,f;t[2]===a?f=t[3]:(f=jC(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)(xi,{embeddedBackgroundWorkEnabled:i}),t[14]=i,t[15]=g);let _;t[16]===n.readOnly?_=t[17]:(_=(0,$.jsx)(vc,{readOnly:n.readOnly}),t[16]=n.readOnly,t[17]=_);let v;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Lr,{}),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 FC({apis:e}){Q.useEffect(()=>{je(`App:mounted`),K()},[]),Q.useEffect(()=>Wn(),[]);let t=Zn(e=>e.initializeApp),n=Zn(e=>e.isInitialized),r=Zn(e=>e.isConnected),i=zn(e=>e.error),a=zn(e=>e.clearError),o=zn(e=>!(e.newSessionDraft?.open&&e.currentSessionId===null)),c=Ae(e=>e.currentDirectory),l=Ae(e=>e.setDirectory),u=Ae(e=>e.isSwitchingDirectory),[f,p]=Q.useState(!1),m=gs(e=>e.refreshStatus),[h,g]=Q.useState(()=>e.runtime.isVSCode),[x,S]=Q.useState(!1),[C,D]=Q.useState(!1),[O,A]=Q.useState(0),[j,M]=Q.useState(0),[P,F]=Q.useState({epoch:0,startedAt:0}),[L,z]=Q.useState(!1),B=Q.useRef(!1),V=q(e=>e.wideChatLayoutEnabled),H=q(e=>e.mobileKeyboardMode),te=Q.useMemo(()=>I(),[]),ne=Zt(e=>e.hasCachedSessionIndex),re=Zt(e=>e.hasHydratedSessionIndex),[U,ie]=Q.useState(()=>y()),[ae,W]=Q.useState(()=>{let e=T();return e===null?null:w({isDesktopShell:!0,bootOutcome:e})}),oe=Q.useRef(!1),G=Q.useMemo(()=>MC(),[]),se=!G||x,ce=Q.useMemo(()=>NC(),[]);Q.useEffect(()=>(Fe(f),()=>{Fe(!1)}),[f]),Q.useEffect(()=>{He(H)},[H]),Q.useEffect(()=>{g(e.runtime.isVSCode)},[e.runtime.isVSCode]),Q.useEffect(()=>{let e=Vr(e=>{d(e)&&(te&&F(e=>({epoch:e.epoch+1,startedAt:Date.now()})),kc(e),M(e=>e+1),D(!1),A(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(()=>(R(e),()=>R(null)),[e]),Q.useEffect(()=>{if(G)return;let t=!1;return Xn().then(()=>{t||m(e.github,{force:!0})}),()=>{t=!0}},[e.github,G,m]),Li();let le=U===`valid`,ue=ae?.screen===`main`,[de,fe]=Q.useState(!1);Q.useEffect(()=>{if(!se||!N({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 Xn().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){D(!0);return}let n=Zn.getState();if(n.isInitialized){D(!1);return}if(r+=1,await Xn(),!e)return;await n.initializeApp();let o=Zn.getState();if(!e)return;if(o.isInitialized){D(!1);return}if(r>=10){D(!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,O,n,h]),Q.useEffect(()=>{se&&n&&D(!1)},[se,n]),Q.useEffect(()=>{if(!se||!C)return;let e=document.getElementById(`initial-loading`);if(e){e.classList.add(`fade-out`);let t=setTimeout(()=>{e.remove()},300);return()=>clearTimeout(t)}},[se,C]),ri({enabled:se&&!h,source:`startupRecovery`}),Q.useEffect(()=>{u||h||r&&be.setDirectory(c)},[c,u,r,h]),Q.useEffect(()=>{if(!G||typeof window>`u`)return;let e=e=>{let t=e?.visible===!0;S(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:no},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;vC(t??{})},t=e=>{let t=e.detail?.assistantID;typeof t==`string`&&t.trim()&&nr(t.trim())},n=e=>{let t=e.detail,n=t?.projectID,r=t?.taskID;n&&r&&ut(async()=>{let{openScheduledTask:e}=await import(`./scheduledTaskNavigation-BqkeRfVc.js`).then(e=>e.n);return{openScheduledTask:e}},__vite__mapDeps([112,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=Ae.getState().currentDirectory,{activeProjectId:t,projects:n}=Tn.getState(),r=n.find(e=>e.id===t)??null;ee(`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=zn.getState().currentSessionId;e&&Rn(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),zn.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=Tn.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]),ti({enabled:se}),pC({enabled:se}),_C(),Wi(),Tc(),WS(vt(()=>{p(e=>!e)})),Q.useEffect(()=>{_()&&pt().then(async e=>{e&&await b(e)}).catch(console.warn)},[]),Q.useEffect(()=>{if(!n||!_()||B.current)return;B.current=!0;let e=!1,t=null,r=null;Ds.getState().subscribeDesktopUpdateEvents().then(t=>{if(e){t();return}r=t});let i=()=>{let e=Ds.getState();e.checking||e.checkForUpdates()},a=n=>{t=window.setTimeout(()=>{e||(document.visibilityState===`visible`&&i(),a(DC))},n)},o=()=>{if(e||document.visibilityState!==`visible`)return;let t=Ds.getState().lastChecked;t!=null&&Date.now()-t<OC||i()};return a(0),window.addEventListener(`focus`,o),()=>{e=!0,t!==null&&window.clearTimeout(t),window.removeEventListener(`focus`,o),r&&r()}},[n]),lC(),Q.useEffect(()=>{if(G)return;let e=e=>{Ct(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=y();if(r!==`not-injected`){if(e=!0,ie(r),r===`valid`){let e=T();e&&W(w({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=vt(async()=>{if(E({isDesktopShell:I(),isDesktopLocalOriginActive:k()})){await v();return}window.location.reload()}),me=vt(async()=>{if(!L){D(!1),z(!0);try{await Xn(),await Zn.getState().initializeApp()}finally{z(!1)}Zn.getState().isInitialized||A(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)(Ka,{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)(EC,{mode:`first-launch`,onCliAvailable:pe,onChooseRemote:()=>{}})})})});let e=he(ae),t=ae.screen===`recovery`&&`url`in ae?ae.url:void 0;return(0,$.jsx)(Ka,{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)(EC,{mode:`recovery`,recoveryVariant:e,recoveryHostUrl:t,recoveryHostLabel:void 0,onCliAvailable:pe})})})})}if(G)return Bt(),(0,$.jsx)(Ka,{children:(0,$.jsx)(tn,{sdk:be.getSdkClient(),directory:c||``,bootstrapDirectory:o,children:(0,$.jsx)(Ui,{apis:e,children:(0,$.jsx)(sa,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-background`,children:(0,$.jsx)(PC,{embeddedSessionChat:G,isVSCodeRuntime:h,embeddedBackgroundWorkEnabled:se})})})})},j)});if(ce)return(0,$.jsx)(Ka,{children:(0,$.jsx)(SC,{})});if(C&&!n&&!h&&!G)return(0,$.jsx)(Ka,{children:(0,$.jsx)(AC,{onRetry:()=>{me()},isRetrying:L})});let ge=!n&&!te;return(0,$.jsx)(Ka,{children:(0,$.jsx)(tn,{sdk:be.getSdkClient(),directory:c||``,bootstrapDirectory:o,children:(0,$.jsx)(Ui,{apis:e,children:(0,$.jsx)(Xs,{ready:de&&n&&se,children:(0,$.jsx)(Hf,{children:(0,$.jsx)(sa,{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)(xi,{embeddedBackgroundWorkEnabled:se}),(0,$.jsx)(Gs,{}),(0,$.jsx)(qc,{}),(0,$.jsx)(Ux,{}),te&&(0,$.jsx)(TC,{transition:P,ready:n&&r}),(0,$.jsx)(CC,{}),(0,$.jsx)(Lr,{}),!ge&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(sc,{}),(0,$.jsx)(Hc,{}),(0,$.jsx)(ec,{}),(0,$.jsx)(kC,{}),f&&(0,$.jsx)(TS,{onClose:()=>p(!1)})]})]})})})})})},j)})}function IC(e){return e.isAboutDialogOpen}function LC(e){return e.setAboutDialogOpen}function RC(e){return e.currentDirectory}function zC(e){return e.currentSessionId}function BC(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 VC=typeof window<`u`&&window.__YURI_RUNTIME_APIS__||(()=>{throw Error(`Runtime APIs not provided for legacy UI entrypoint.`)})();Pt(),I()&&cn(),Gr({runtimeKey:f(),initializeAppearance:Ze,syncSettings:Xe,applyDirectory:ei,startWatchers:()=>{Ei(),Zr(),zr()},onError:(e,t)=>{console.error(e===`appearance`?`[main] appearance init failed:`:`[main] settings init failed:`,t)}});var HC=document.getElementById(`root`);if(!HC)throw Error(`Root element not found`);(0,bl.createRoot)(HC).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(Br,{children:(0,$.jsx)(Dt,{children:(0,$.jsx)(Fr,{children:(0,$.jsx)(wi,{children:(0,$.jsx)(qr,{children:(0,$.jsx)(Yr,{children:(0,$.jsx)(FC,{apis:VC})})})})})})})}));