@yuriai/web 0.2.29 → 0.2.30

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 (51) hide show
  1. package/dist/assets/{AssistantContactStatus-diuJawg6.js → AssistantContactStatus-gA-rrWq5.js} +3 -3
  2. package/dist/assets/{AssistantUnreadBadge-Bm2v4QFf.js → AssistantUnreadBadge-i7n8bLaM.js} +1 -1
  3. package/dist/assets/{AssistantView-BfJ7SgWf.js → AssistantView-HxZlNZq7.js} +1 -1
  4. package/dist/assets/{DiagramView-Doy9Dw3w.js → DiagramView-BCocEvVv.js} +1 -1
  5. package/dist/assets/{GuiPluginSurface-DD2js1dF.js → GuiPluginSurface-BqFdg497.js} +1 -1
  6. package/dist/assets/{MarkdownRenderer-DlwJOAKc.js → MarkdownRenderer-D0UA-oW2.js} +2 -2
  7. package/dist/assets/{MarkdownRendererImpl-Bcew9khF.js → MarkdownRendererImpl-BzLfIM6s.js} +1 -1
  8. package/dist/assets/{MarkstreamRendererImpl-DhcURvX5.js → MarkstreamRendererImpl-BWT-THLA.js} +1 -1
  9. package/dist/assets/{MobileDetailNavigation-6ZzfZFN1.js → MobileDetailNavigation-DWx5Qg0b.js} +1 -1
  10. package/dist/assets/{MobileShareBridge-gejXx1yh.js → MobileShareBridge-DlDDFngz.js} +1 -1
  11. package/dist/assets/{MobileTabPageHeader-DkT6g7Mg.js → MobileTabPageHeader-CwJW-4fw.js} +1 -1
  12. package/dist/assets/{MultiRunWindow-CRgoeY0-.js → MultiRunWindow-IoZeDgjq.js} +1 -1
  13. package/dist/assets/{SettingsView-Ds6O5lyc.js → SettingsView-By2SUPhz.js} +1 -1
  14. package/dist/assets/{SettingsWindow-BWn1_7aJ.js → SettingsWindow-CoybS1ar.js} +1 -1
  15. package/dist/assets/{SetupTourDialog-CPIzaGRX.js → SetupTourDialog-CxsiEmUV.js} +1 -1
  16. package/dist/assets/{TerminalView-c7zh5vLz.js → TerminalView-6aWOZj9I.js} +1 -1
  17. package/dist/assets/{ToolOutputDialog-CDOXuNnT.js → ToolOutputDialog-DF9iEO7P.js} +1 -1
  18. package/dist/assets/{VoiceSettings-C4dUe9aM.js → VoiceSettings-CTXfVzZh.js} +1 -1
  19. package/dist/assets/{appThemeRegistry-yYsjzEE3.js → appThemeRegistry-BLQvL9m5.js} +1 -1
  20. package/dist/assets/{capgoAdapter-Bu3WngVl.js → capgoAdapter-CMlvFJvv.js} +1 -1
  21. package/dist/assets/{gitApi-Qflz9_C8.js → gitApi-D6P3ytSw.js} +1 -1
  22. package/dist/assets/{insertionBoundaries-BUw7PHl1.js → insertionBoundaries-DE9VLpxi.js} +1 -1
  23. package/dist/assets/{main-D-GaWYGg.js → main-D6Z501de.js} +2 -2
  24. package/dist/assets/{main-Bjl7PEcs.js → main-D8vs5_MH.js} +4 -4
  25. package/dist/assets/{mcpQueries-DHembIpw.js → mcpQueries-BXdUXuLQ.js} +1 -1
  26. package/dist/assets/{miniChat-CmBB3uQK.js → miniChat-BfApc3PU.js} +2 -2
  27. package/dist/assets/{mobile-Dc6ZV3uE.js → mobile-Dckvt7F3.js} +2 -2
  28. package/dist/assets/{mobileBackNavigation-CsrEjMEM.js → mobileBackNavigation-CoPwMqGc.js} +1 -1
  29. package/dist/assets/{multirun-ruXWPXy8.js → multirun-B5nt-Gl3.js} +1 -1
  30. package/dist/assets/{native-config-BcE2v-v8.js → native-config-ekhLUQ-p.js} +1 -1
  31. package/dist/assets/{projectMeta-aZbJXiqn.js → projectMeta-UlBCJIBo.js} +1 -1
  32. package/dist/assets/{pwa-BXcwcwBq.js → pwa-H5fgqBjr.js} +1 -1
  33. package/dist/assets/{queue-abort-optimistic-p3-XNzC5.js → queue-abort-optimistic-DfQMDPWr.js} +1 -1
  34. package/dist/assets/{readiness-CG6k1v_D.js → readiness-CZbavzQq.js} +1 -1
  35. package/dist/assets/{renderElectronMiniChatApp-DKbHyoWv.js → renderElectronMiniChatApp-BFHRuA8I.js} +2 -2
  36. package/dist/assets/{renderMobileApp-ouUhZ7cf.js → renderMobileApp-BkPcVHxL.js} +4 -4
  37. package/dist/assets/{runtimeConfig-pROQUB9G.js → runtimeConfig-CoE19dQU.js} +1 -1
  38. package/dist/assets/{runtimeEndpointReset-DPIu6oI9.js → runtimeEndpointReset-_zJtyAdg.js} +3 -3
  39. package/dist/assets/{sessionLookup-CNrni3E6.js → sessionLookup-CTnucWJc.js} +1 -1
  40. package/dist/assets/{speechSettingsQueries-Dz5sTpjO.js → speechSettingsQueries-DfG7QJBy.js} +1 -1
  41. package/dist/assets/{types-DodQbc1N.js → types-DRcBo4SK.js} +1 -1
  42. package/dist/assets/{useAppFontEffects-DtteQwrV.js → useAppFontEffects-iu-GyWPx.js} +5 -5
  43. package/dist/assets/{useDesktopWindowControlsLayout-BDhl0M6j.js → useDesktopWindowControlsLayout-CynyNP7q.js} +1 -1
  44. package/dist/assets/{useEffectiveDirectory-DcTO2pCq.js → useEffectiveDirectory-BCMjNzpx.js} +1 -1
  45. package/dist/assets/{useMobileNavigationStore-CWXCC9MY.js → useMobileNavigationStore-DYc48dNS.js} +4 -4
  46. package/dist/assets/{usePluginsStore-B6vwvN4g.js → usePluginsStore-BzZm-uao.js} +1 -1
  47. package/dist/assets/{useWorkerHighlightedLines-B9uHlxuS.js → useWorkerHighlightedLines-B4sqe9Xq.js} +1 -1
  48. package/dist/index.html +5 -5
  49. package/dist/mini-chat.html +5 -5
  50. package/dist/mobile.html +5 -5
  51. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/OnboardingScreen-CgQGvlEs.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-fetch-D0YWp3FJ.js","assets/runtime-auth-DBn9yahL.js","assets/runtime-switch-DEZ1K7qW.js","assets/desktop-JwYqThiw.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/desktopHosts-CB0CTcMg.js","assets/vendor-base-ui-CzHs0bHY.js","assets/persistence-D-rnhgr4.js","assets/vendor-zustand-vDaAPGfl.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/useUIStore-CoWJ3ROq.js","assets/vendor-react-DlzBev0S.js","assets/queryRuntime-2dx7jbt9.js","assets/vendor-tanstack-query-core-Y_YoRHtC.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/button-Cjciq1yh.js","assets/store-CKIMMlXR.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/tour-Db44qwfs.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/Icon-BQczEnxm.js","assets/dialog-rVkj8VgE.js","assets/dialog-CTYD3Sbr.css","assets/input-GVRUiwuQ.js","assets/YuriLogo-CpccdHvS.js","assets/useThemeSystem-CNzUUkFn.js","assets/SetupTourDialog-CPIzaGRX.js","assets/vendor-tanstack-react-query-B-Wpqq5J.js","assets/vendor-reactuses-core-DWo5Wn6R.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/useMobileNavigationStore-CWXCC9MY.js","assets/gitApiHttp-Ddik7PM_.js","assets/vendor-opencode-client-cQ47ywrT.js","assets/vendor-effect-X1Hqc7ba.js","assets/runtime-file-resource-BP4P52ry.js","assets/fileQueries-C2Rs6TPz.js","assets/runtime-file-store-BVRgEtI-.js","assets/path-utils-jGozTg9d.js","assets/platform-DFJEtBlo.js","assets/vendor-sonner-BEHGipm5.js","assets/useAssistantUIStore-BI_dAUjx.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/select-DeP9bukP.js","assets/device-DN1GigI_.js","assets/MobileResizableSheet-Bk3z4g6T.js","assets/vendor-framer-motion-DDMKlXiP.js","assets/MobileWindowStack-DGLdgoGr.js","assets/textarea-B4mWtnN5.js","assets/OverlayScrollbar-C9Ac564a.js","assets/MarkdownRenderer-DlwJOAKc.js","assets/useEffectiveDirectory-DcTO2pCq.js","assets/markdownHeightCache-C7UOJdkN.js","assets/dualLimitLru-D8Sphgua.js","assets/speechSettingsQueries-Dz5sTpjO.js","assets/useDictation-CwX05CAo.js","assets/YuriWordmark-hZ6K7Smk.js","assets/usePluginsStore-B6vwvN4g.js","assets/VoiceSettings-C4dUe9aM.js","assets/tooltip-BuZ86ipm.js","assets/url-MRa-FtQa.js","assets/VoiceSettings-C0HSdVvS.css","assets/SetupTourDialog-CUzqT2sw.css","assets/GuiPluginSurface-DD2js1dF.js","assets/react-Bwr5-XPi.js","assets/readiness-CG6k1v_D.js","assets/GuiPluginWindow-CIVNyw4s.js","assets/native-DsqzO52u.js","assets/native-errors-06if6eu-.js","assets/vendor-opencode-plugin-BmdTE4Te.js","assets/host-D776RHTx.js","assets/appearance--vFosLNi.js","assets/themes-BgDJcxRc.js","assets/theme-validation-BGYdrOu7.js","assets/fileReferenceParser-1HHDBUum.js","assets/vendor-solid-js-D98iXT7C.js","assets/gui-CJjEj3l4.js","assets/fileReferenceActions-CvDFcgBH.js","assets/toolHelpers-iEHVHQ9p.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,n as r,o as i,r as a,s as o}from"./runtime-switch-DEZ1K7qW.js";import{n as s}from"./runtime-fetch-D0YWp3FJ.js";import{A as c,G as l,M as u,T as d,U as f,b as p,c as m,s as h,t as g,v as _,w as v,x as y}from"./desktop-JwYqThiw.js";import{a as b,i as x,o as S}from"./vendor-zustand-vDaAPGfl.js";import{at as C,ot as w,st as T}from"./vendor-base-ui-CzHs0bHY.js";import{At as E,bt as D,sr as O}from"./gitApiHttp-Ddik7PM_.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{S as k,n as A,r as j,t as M}from"./useUIStore-CoWJ3ROq.js";import{At as N,Mt as ee,ot as P}from"./persistence-D-rnhgr4.js";import{n as F}from"./vendor-react-DlzBev0S.js";import{l as I,n as L,o as R,s as z,t as te}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{a as B,o as V}from"./queryRuntime-2dx7jbt9.js";import{l as H,u as ne}from"./fileQueries-C2Rs6TPz.js";import{o as re}from"./path-utils-jGozTg9d.js";import{o as U}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as W}from"./pathNormalization-ewtPqJWn.js";import{i as ie}from"./terminalApi-ChZhb60_.js";import{r as ae}from"./platform-DFJEtBlo.js";import{c as oe,d as G,f as K,l as se,m as ce,n as q,o as le,p as ue,s as de,t as fe,u as pe}from"./vendor-pierre-diffs-BFiZ3IhI.js";import{r as me}from"./vendor-sonner-BEHGipm5.js";import{a as he,d as ge,h as _e,i as J,o as ve}from"./vendor-reactuses-core-DWo5Wn6R.js";import{d as ye,f as be,i as xe,l as Se,p as Ce,r as Y,t as X,u as we}from"./button-Cjciq1yh.js";import{i as Te,t as Ee}from"./store-CKIMMlXR.js";import{A as De,D as Oe,E as ke,O as Ae,k as je,t as Me,v as Ne}from"./MobileDetailNavigation-6ZzfZFN1.js";import{$t as Pe,B as Fe,Br as Ie,Bt as Le,Dt as Re,Ei as ze,Et as Be,Ft as Ve,G as He,It as Ue,Jr as We,K as Ge,Kr as Ke,Nt as qe,Oa as Je,Oi as Ye,Pt as Xe,Qr as Ze,Rr as Qe,Ta as $e,Tt as et,Ur as tt,V as nt,Vr as rt,Wr as it,Xr as at,Yr as ot,Zr as st,_a as ct,an as lt,ar as ut,cr as dt,ei as ft,fr as pt,ft as mt,hr as ht,ii as gt,ja as _t,jn as vt,ni as yt,p as bt,q as xt,s as St,st as Ct,ti as wt,tn as Tt,tr as Et,ur as Dt,va as Ot,ya as kt,zi as At,zr as jt}from"./useMobileNavigationStore-CWXCC9MY.js";import{i as Mt,t as Nt}from"./useAssistantUIStore-BI_dAUjx.js";import{g as Pt}from"./fileMentionAutocompleteState-BZJqfgae.js";import{n as Ft,t as It}from"./AgentAvatar-CR6dX_XT.js";import{n as Lt,r as Rt,t as zt}from"./useThemeSystem-CNzUUkFn.js";import{i as Bt,t as Vt}from"./vendor-framer-motion-DDMKlXiP.js";import{n as Z}from"./Icon-BQczEnxm.js";import{a as Ht,i as Ut,n as Wt,o as Gt,r as Kt,t as qt}from"./dialog-rVkj8VgE.js";import{d as Jt}from"./gitApi-Qflz9_C8.js";import{C as Yt,E as Xt,It as Zt,L as Qt,Q as $t,R as en,at as tn,bt as nn,ct as rn,et as an,it as on,mt as sn,nt as cn,o as ln,ot as un,pt as dn,rt as fn,st as pn,vt as mn,xt as hn,yt as gn,z as _n}from"./useAppFontEffects-DtteQwrV.js";import{E as vn,b as yn,h as bn,k as xn,r as Sn,v as Cn,w as wn,x as Tn,y as En}from"./insertionBoundaries-BUw7PHl1.js";import{t as Dn}from"./input-GVRUiwuQ.js";import{i as On,n as kn,t as An}from"./tooltip-BuZ86ipm.js";import{$ as jn,J as Mn,X as Nn,Y as Pn,Z as Fn,_t as In,ct as Ln,et as Rn,gt as zn,ht as Bn,m as Vn,nt as Hn,ot as Un,p as Wn,vt as Gn,yt as Kn}from"./pwa-BXcwcwBq.js";import{n as qn,t as Jn}from"./YuriLogo-CpccdHvS.js";import{r as Yn}from"./device-DN1GigI_.js";import{r as Xn}from"./themes-BgDJcxRc.js";import{a as Zn,g as Qn,i as $n,r as er,s as tr,t as nr,u as rr}from"./scheduledTaskNavigation-Bp5rGr3m.js";import{C as ir,_ as ar,f as or,m as sr,n as cr,p as lr,r as ur,t as dr,u as fr,y as pr}from"./MobileResizableSheet-Bk3z4g6T.js";import{E as mr,n as hr,r as gr}from"./sessionLookup-CNrni3E6.js";import{c as _r,i as vr,n as yr,s as br,t as xr}from"./select-DeP9bukP.js";import{n as Sr,t as Cr}from"./appThemeRegistry-yYsjzEE3.js";import{o as wr}from"./MarkdownRenderer-DlwJOAKc.js";import{a as Tr,c as Er}from"./toolHelpers-iEHVHQ9p.js";import{i as Dr,n as Or,r as kr,t as Ar}from"./react-Bwr5-XPi.js";import{n as jr}from"./useEffectiveDirectory-DcTO2pCq.js";import{t as Mr}from"./LoadingImage-Ch5MyA20.js";import{_ as Nr,c as Pr,g as Fr,i as Ir,l as Lr,n as Rr,o as zr,s as Br,t as Vr,v as Hr,y as Ur}from"./vendor-dnd-kit-core-DK4OoOTr.js";import{a as Wr,o as Gr,s as Kr,t as qr}from"./vendor-dnd-kit-sortable-Cv69eQm1.js";import{t as Jr}from"./OverlayScrollbar-C9Ac564a.js";import{n as Yr,r as Xr,t as Zr}from"./textarea-B4mWtnN5.js";import{a as Qr,d as $r,f as ei,i as ti,l as ni,n as ri,p as ii,r as ai,s as oi,t as si}from"./projectMeta-aZbJXiqn.js";import{_ as ci,b as li,g as ui,n as di,v as fi,y as pi}from"./useWorkerHighlightedLines-B9uHlxuS.js";import{t as mi}from"./vendor-tanstack-react-virtual-DSFNK3qc.js";import{t as hi}from"./vendor-motion-C9oiAdx-.js";import{G as gi,M as _i,N as vi,W as yi,d as bi,j as xi,t as Si,x as Ci}from"./MobileTabPageHeader-DkT6g7Mg.js";import{n as wi}from"./YuriWordmark-hZ6K7Smk.js";import{c as Ti,l as Ei}from"./mcpQueries-DHembIpw.js";import{t as Di}from"./usePluginsStore-B6vwvN4g.js";import{n as Oi}from"./mobileBackNavigation-CsrEjMEM.js";import{i as ki,r as Ai}from"./AssistantUnreadBadge-Bm2v4QFf.js";import{a as ji,i as Mi,n as Ni,r as Pi,t as Fi}from"./context-menu-BIjCIXOg.js";import{n as Ii,r as Li,t as Ri}from"./collapsible-BzCn4-sd.js";import{a as zi,i as Bi,n as Vi,t as Hi}from"./readiness-CG6k1v_D.js";import{n as Ui,t as Wi}from"./native-errors-06if6eu-.js";import{t as Gi}from"./appearance--vFosLNi.js";import{t as Ki}from"./vendor-cron-parser-BmO80h0C.js";var Q=e(T(),1),qi=F(),$=w(),Ji=e(C(),1);function Yi(){return new Worker(fe,{type:`module`})}var Xi=[`typescript`,`javascript`,`tsx`,`jsx`,`json`,`markdown`],Zi={unified:{poolSize:1,totalASTLRUCacheSize:24,lineDiffType:`none`},split:{poolSize:2,totalASTLRUCacheSize:56,lineDiffType:`word-alt`}},Qi,$i,ea=e=>{let t=Zi[e],n=new ue({workerFactory:Yi,poolSize:t.poolSize,totalASTLRUCacheSize:t.totalASTLRUCacheSize},{theme:{light:`pierre-light`,dark:`pierre-dark`},langs:Xi,lineDiffType:t.lineDiffType,preferredHighlighter:`shiki-wasm`});return n.initialize(),n},ta=e=>{if(!(typeof window>`u`))return e===`split`?($i??=ea(`split`),$i):(Qi??=ea(`unified`),Qi)},na=e=>{let t=(0,qi.c)(7),{children:n,renderTheme:r}=e,i=ia(`unified`),a=ia(`split`),o,s;t[0]!==r||t[1]!==a||t[2]!==i?(o=()=>{i&&i.setRenderOptions({theme:r,lineDiffType:Zi.unified.lineDiffType}),a&&a.setRenderOptions({theme:r,lineDiffType:Zi.split.lineDiffType})},s=[r,a,i],t[0]=r,t[1]=a,t[2]=i,t[3]=o,t[4]=s):(o=t[3],s=t[4]),(0,Q.useEffect)(o,s);let c;return t[5]===n?c=t[6]:(c=(0,$.jsx)($.Fragment,{children:n}),t[5]=n,t[6]=c),c},ra=e=>{let t=(0,qi.c)(11),{children:n}=e,r=zt(),i,a;if(t[0]!==r?.availableThemes||t[1]!==r?.darkThemeId||t[2]!==r?.lightThemeId){let e=Xn(!1),n=Xn(!0),o=r?.lightThemeId??e.metadata.id,s=r?.darkThemeId??n.metadata.id;a=r?.availableThemes.find(e=>e.metadata.id===o)??e,i=r?.availableThemes.find(e=>e.metadata.id===s)??n,Cr(a),Cr(i),t[0]=r?.availableThemes,t[1]=r?.darkThemeId,t[2]=r?.lightThemeId,t[3]=i,t[4]=a}else i=t[3],a=t[4];let o;t[5]!==i.metadata.id||t[6]!==a.metadata.id?(o={light:a.metadata.id,dark:i.metadata.id},t[5]=i.metadata.id,t[6]=a.metadata.id,t[7]=o):o=t[7];let s=o,c;return t[8]!==n||t[9]!==s?(c=(0,$.jsx)(na,{renderTheme:s,children:n}),t[8]=n,t[9]=s,t[10]=c):c=t[10],c},ia=e=>{let t=(0,qi.c)(2),n=e===void 0?`unified`:e,r;return t[0]===n?r=t[1]:(r=ta(n),t[0]=n,t[1]=r),r},aa=(e,t)=>{if(!e||typeof e!=`object`)return!1;let n=e;return(n.role===`user`||n.role===`assistant`)&&typeof n.sessionID==`string`&&n.sessionID.length>0&&typeof n.messageID==`string`&&n.messageID.length>0&&typeof n.snippet==`string`&&typeof n.createdAt==`number`&&Number.isFinite(n.createdAt)&&t.length>0},oa=async e=>{let t=e.query.trim();if(!t)return[];let n=await(e.fetch??s)(`/api/yuri/content-search`,{query:{q:t,limit:String(e.limit??30)},signal:e.signal});if(!n.ok)throw Error(`session content search failed (${n.status})`);let r=await n.json();if(!Array.isArray(r?.hits))throw Error(`session content search returned no hits`);return r.hits.flatMap(e=>aa(e,typeof e?.directory==`string`?e.directory:``)?[e]:[])},sa=(e,t)=>{let i=e.trim(),a=t.scope,o=a?.transport??n(),s=a?.generation??r(),c=t.searchContent??oa;return R({queryKey:V.sessionContentSearch.query(i,``,s,o),enabled:i.length>0&&a!==null,queryFn:({signal:e})=>a?c({scope:a,query:i,limit:30,signal:e}):[],staleTime:0,refetchInterval:3e3,retry:1})},ca=(e=s)=>R({queryKey:[n(),`contentSearchStatus`,r()],queryFn:async({signal:t})=>{let n=await e(`/api/yuri/content-search`,{signal:t});if(n.status===404||n.status===501)return null;if(!n.ok)throw Error(`Content index unavailable (${n.status})`);let{index:r}=await n.json();if(!r||![`pending`,`indexing`,`ready`,`partial`,`error`].includes(r.phase)||![r.total,r.completed,r.failed,r.messages].every(e=>Number.isFinite(e)&&e>=0)||r.initializationRequired!==void 0&&typeof r.initializationRequired!=`boolean`||[r.indexStartedAt,r.indexCompletedAt,r.coveredSince,r.verifiedAt,r.updatedAt].some(e=>e!=null&&!Number.isFinite(e)))throw Error(`Invalid content index status`);return r},refetchInterval:3e3,staleTime:0}),la=wr(()=>U(()=>import(`./OnboardingScreen-CgQGvlEs.js`).then(e=>({default:e.OnboardingScreen})),__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])));function ua(){let e=(0,qi.c)(12),[t,n]=Q.useState(!1),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=ca(),e[0]=r):r=e[0];let i=!t,a;e[1]===i?a=e[2]:(a={...r,enabled:i,refetchOnWindowFocus:!1,refetchInterval:da},e[1]=i,e[2]=a);let o=z(a),s=o.data,c=o.isFetchedAfterMount&&!o.isError&&(s===null||s&&(s.initializationRequired===void 0||s.initializationRequired===!1&&s.updatedAt!=null)),l,u;if(e[3]===c?(l=e[4],u=e[5]):(l=()=>{c&&n(!0)},u=[c],e[3]=c,e[4]=l,e[5]=u),Q.useEffect(l,u),t||!s?.initializationRequired||s.total===0)return null;let d;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=e=>{e||n(!0)},e[6]=d):d=e[6];let f;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(f={transform:`none`,transition:`none`,opacity:1},e[7]=f):f=e[7];let p;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>n(!0),e[8]=p):p=e[8];let m;return e[9]!==s||e[10]!==o.isError?(m=(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(qt,{open:!0,onOpenChange:d,children:(0,$.jsx)(Wt,{showCloseButton:!1,className:`h-full max-w-none rounded-none border-0 p-0`,style:f,overlayClassName:`z-[9997]`,containerClassName:`z-[9997] items-stretch p-0`,children:(0,$.jsx)(la,{mode:`content-index`,indexStatus:s,indexStatusError:o.isError,onContinueInBackground:p})})})}),e[9]=s,e[10]=o.isError,e[11]=m):m=e[11],m}function da(e){let t=e.state.data;return t===null||t&&t.initializationRequired===void 0||t?.initializationRequired===!1&&t.updatedAt!=null?!1:3e3}function fa(){let e=(0,qi.c)(4);if(H())return null;let t,n;if(e[0]===Symbol.for(`react.memo_cache_sentinel`)){let r=ca().queryKey;t=ua,n=JSON.stringify(r),e[0]=t,e[1]=n}else t=e[0],n=e[1];let r;return e[2]===n?r=e[3]:(r=(0,$.jsx)(t,{},n),e[2]=n,e[3]=r),r}var pa=wr(()=>U(()=>import(`./SetupTourDialog-CPIzaGRX.js`).then(e=>({default:e.SetupTourDialog})),__vite__mapDeps([31,1,4,3,8,14,32,16,15,2,33,34,35,19,5,6,20,10,11,12,21,22,23,24,36,37,38,39,13,9,17,18,40,41,42,43,44,45,46,47,48,25,26,27,29,30,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,28,65,66,67,68])));function ma(e){let t=(0,qi.c)(29),{runtime:n,autoStart:r}=e,i;t[0]===n?i=t[1]:(i=e=>e.openedRuntime===n,t[0]=n,t[1]=i);let a=wi(i),o;t[2]===n?o=t[3]:(o=e=>e.progress[n],t[2]=n,t[3]=o);let s=wi(o),c=D(_a),l=D(ga),u=Ye(ha),[d,f]=Q.useState(!1),p,m;t[4]===n?(p=t[5],m=t[6]):(p=()=>{let e=!0;return Promise.resolve(Zt(n)).then(t=>{e&&t!==!1&&f(!0)}),()=>{e=!1}},m=[n],t[4]=n,t[5]=p,t[6]=m),Q.useEffect(p,m);let h=r&&d&&c&&u&&!s,g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(g=ut(),t[7]=g):g=t[7];let _;t[8]===h?_=t[9]:(_={...g,enabled:h},t[8]=h,t[9]=_);let v=z(_),y,b;if(t[10]!==r||t[11]!==d||t[12]!==u||t[13]!==a||t[14]!==s||t[15]!==v.data||t[16]!==v.isError||t[17]!==v.isFetchedAfterMount||t[18]!==v.isSuccess||t[19]!==c||t[20]!==n?(y=()=>{if(!r||!d||!c||!u||a||s?.dismissed)return;let e=wi.getState();if(s){e.open(n);return}!v.isSuccess||v.isError||!v.isFetchedAfterMount||(v.data.projects?.length?e.dismiss(n):e.open(n))},b=[r,d,c,u,n,a,s,v.isSuccess,v.isError,v.isFetchedAfterMount,v.data],t[10]=r,t[11]=d,t[12]=u,t[13]=a,t[14]=s,t[15]=v.data,t[16]=v.isError,t[17]=v.isFetchedAfterMount,t[18]=v.isSuccess,t[19]=c,t[20]=n,t[21]=y,t[22]=b):(y=t[21],b=t[22]),Q.useEffect(y,b),!a)return null;let x;t[23]===n?x=t[24]:(x=()=>wi.getState().dismiss(n),t[23]=n,t[24]=x);let S;return t[25]!==l||t[26]!==n||t[27]!==x?(S=(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(pa,{runtime:n,onClose:x},l)}),t[25]=l,t[26]=n,t[27]=x,t[28]=S):S=t[28],S}function ha(e){return e.isInitialized}function ga(e){return e.currentDirectory}function _a(e){return e.isHomeReady}function va(e){let i=(0,qi.c)(5),{autoStart:o}=e,s=o===void 0||o,c=H(),l=Q.useSyncExternalStore(t,a,a),u=Q.useSyncExternalStore(t,r,r);if(c)return null;let d;i[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=n(),i[0]=d):d=i[0];let f=`${l}:${u}:${d}`,p;return i[1]!==s||i[2]!==l||i[3]!==f?(p=(0,$.jsx)(ma,{runtime:l,autoStart:s},f),i[1]=s,i[2]=l,i[3]=f,i[4]=p):p=i[4],p}var ya={},ba=[],xa=(e,t)=>{if(!e)return t(`mcpDropdown.status.unknown`);switch(e.status){case`connected`:return t(`mcpDropdown.status.connected`);case`failed`:return t(`mcpDropdown.status.failed`,{error:e.error||t(`mcpDropdown.status.unknownError`)});case`needs_auth`:return t(`mcpDropdown.status.needsAuth`);case`needs_client_registration`:return t(`mcpDropdown.status.needsRegistration`,{error:e.error||``});default:return e.status}},Sa=e=>{switch(e?.status){case`connected`:return`success`;case`failed`:return`error`;case`needs_auth`:case`needs_client_registration`:return`warning`;default:return`default`}},Ca=({active:e,className:t,headerAction:n,listClassName:r,hideHeader:i=!1,mobileListDensity:a=!1})=>{let{t:o}=be(),s=D(e=>e.currentDirectory)??null,c=yi(e=>e.connect),l=yi(e=>e.disconnect),{data:u,refetch:d,isError:f,error:p}=Ei(s,{enabled:e}),{data:m}=Ti(s,{enabled:e}),h=u??ya,g=m??ba,[_,v]=Q.useState(!1),[y,b]=Q.useState(null),x=Q.useMemo(()=>{let e=new Set(Object.keys(h));for(let t of g)t?.name&&e.add(t.name);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[g,h]),S=Q.useCallback(e=>{if(e?.preventDefault(),_)return;v(!0);let t=new Promise(e=>setTimeout(e,500));Promise.all([d(),t]).finally(()=>{v(!1)})},[_,d]);return(0,$.jsxs)(`div`,{className:Y(`w-full`,t),children:[i?null:(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-2.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex items-baseline gap-2`,children:[(0,$.jsx)(`div`,{className:`typography-ui-header font-semibold text-foreground`,children:o(`mcpDropdown.title`)}),s&&(0,$.jsx)(`div`,{className:`truncate typography-micro text-muted-foreground`,children:s.split(`/`).pop()||s})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[n,(0,$.jsx)(`button`,{type:`button`,className:`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`,disabled:_,onClick:S,"aria-label":o(`mcpDropdown.actions.refreshAria`),children:(0,$.jsx)(Z,{name:`refresh`,className:Y(`h-4 w-4`,_&&`animate-spin`)})})]})]})}),(0,$.jsx)(`div`,{className:Y(`max-h-64 overflow-y-auto`,a?`space-y-1 py-3`:`px-3 py-2.5`,r),children:(0,$.jsxs)(`div`,{className:Y(!a&&x.length>0&&`rounded-xl bg-[var(--surface-muted)] p-1.5`),children:[x.map(e=>{let t=h[e]??(f&&!u&&g.some(t=>t.name===e)?{status:`failed`,error:p.message}:void 0),n=Sa(t),r=t?.status===`connected`,i=y===e,d=xa(t,o);return(0,$.jsxs)(`div`,{className:Y(`flex items-center justify-between rounded-lg hover:bg-interactive-hover/50`,a?`gap-3 px-4 py-3`:`gap-2 px-2.5 py-2`),children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsxs)(An,{children:[(0,$.jsx)(On,{asChild:!0,children:(0,$.jsx)(`span`,{className:Y(`rounded-full flex-shrink-0`,a?`h-2.5 w-2.5`:`h-2 w-2`,n===`success`&&`bg-status-success`,n===`error`&&`bg-status-error`,n===`warning`&&`bg-status-warning`,n==="default"&&`bg-muted-foreground/40`),"aria-label":d})}),(0,$.jsx)(kn,{side:`left`,children:(0,$.jsx)(`p`,{children:d})})]}),(0,$.jsx)(`span`,{className:Y(`truncate`,a?`text-[17px] leading-6 font-medium`:`typography-ui-label`),children:e})]})}),(0,$.jsx)(gi,{checked:r,disabled:i,className:`data-[checked]:bg-status-info`,onCheckedChange:async t=>{b(e);try{t?await c(e,s):await l(e,s)}finally{b(null)}}})]},e)}),x.length===0&&(0,$.jsx)(`div`,{className:`px-4 py-5 typography-ui-label text-muted-foreground text-center`,children:o(`mcpDropdown.empty.configureInConfig`)})]})})]})},wa=e=>!(e.dismissed===`true`||e.sessionShown===`true`||e.hasActiveToast),Ta=e=>!(!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),Ea=e=>{if(typeof e!=`object`||!e)return``;let t=e.version;return typeof t==`string`?t.trim():``},Da=e=>{if(!e||e.available!==!0||e.canManage===!1)return``;let t=typeof e.latestVersion==`string`?e.latestVersion:typeof e.targetVersion==`string`?e.targetVersion:``;return t?t.trim():``},Oa=e=>{let t=e.trim().replace(/^v/i,``);return t?{target:t}:null},ka=5e3,Aa={setTimeout:(e,t)=>globalThis.setTimeout(e,t),clearTimeout:e=>globalThis.clearTimeout(e)};function ja(e,t,n=Aa){if(!e)return()=>void 0;let r=n.setTimeout(()=>{t().catch(()=>void 0)},ka);return()=>n.clearTimeout(r)}var Ma=(e,t)=>({queryKey:[e,`opencode-update`,t],queryFn:async({signal:i})=>{let a=()=>e===n()&&t===r();if(!a())throw Error(`Stale OpenCode update check`);let o=await s(`/api/opencode/upgrade-status`,{headers:{Accept:`application/json`},signal:i});if(!o.ok)throw Error(`OpenCode update check failed`);let c=await o.json();if(i.aborted||!a())throw Error(`Stale OpenCode update check`);if(!c||typeof c!=`object`||Array.isArray(c))throw Error(`Invalid OpenCode update status`);return c},staleTime:3e4,refetchInterval:3e5,refetchOnWindowFocus:!0,refetchOnReconnect:!0,retry:1}),Na=`opencode-update-available`,Pa=`opencode-upgrade-progress`,Fa=`opencode-update-toast-dismissed-version`,Ia=()=>{let{t:e}=be(),i=j(e=>e.showOpenCodeUpdateNotifications),a=Q.useRef(new Set),o=Q.useRef(!1),c=Q.useSyncExternalStore(t,n,n),l=Q.useSyncExternalStore(t,r,r),u=I(),[d,f]=Q.useState(!1);Q.useEffect(()=>ja(i,async()=>{f(!0)}),[i]);let p=z({...Ma(c,l),enabled:i&&d});he(`yuri:opencode-update-available`,e=>{i&&Ea(e.detail)&&p.refetch()});let m=`${Fa}:${c}`;Q.useEffect(()=>{a.current.clear(),yt.dismiss(Na),yt.dismiss(Pa)},[c,l]),Q.useEffect(()=>{i||yt.dismiss(Na)},[i]);let h=J(async(t,i=!1)=>{if(o.current)return;o.current=!0;let a=()=>c===n()&&l===r();yt.dismiss(Na),yt.message(e(`opencodeUpdate.toast.upgrading.title`),{id:Pa,description:e(`opencodeUpdate.toast.upgrading.description`),duration:1/0,icon:(0,$.jsx)(Z,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})});try{let n=Oa(t);if(!n)throw Error(e(`opencodeUpdate.toast.failed.description`));let r=await s(`/api/opencode/upgrade`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({...n,confirmActiveTasks:i})}),o=await r.json().catch(()=>null);if(!a())return;if(o?.errorCode===`UPGRADE_ACTIVE_TASKS`){yt.error(e(`opencodeUpdate.toast.failed.title`),{id:Pa,description:o.error,duration:1/0,action:{label:e(`opencodeUpdate.toast.actions.update`),onClick:()=>{a()&&h(t,!0)}}});return}if(!r.ok||o?.success!==!0)throw Error(o?.error||r.statusText||e(`opencodeUpdate.toast.failed.description`));yt.success(e(`opencodeUpdate.toast.updated.title`),{id:Pa,description:o?.version?e(`opencodeUpdate.toast.updated.descriptionWithVersion`,{version:o.version}):e(`opencodeUpdate.toast.updated.description`),duration:1/0,icon:(0,$.jsx)(Z,{name:`check`,className:`h-4 w-4 text-[var(--status-success)]`})}),u.invalidateQueries({queryKey:[c,`opencode-update`,l]}),u.invalidateQueries({queryKey:[c,`about`,l]})}catch(n){if(!a())return;yt.error(e(`opencodeUpdate.toast.failed.title`),{id:Pa,description:n instanceof Error?n.message:e(`opencodeUpdate.toast.failed.description`),duration:1/0,action:{label:e(`opencodeUpdate.toast.actions.update`),onClick:()=>{a()&&h(t)}}})}finally{o.current=!1}});return Q.useEffect(()=>{let t=t=>{if(!j.getState().showOpenCodeUpdateNotifications){yt.dismiss(Na);return}Ta({version:t,dismissedVersion:k().getItem(m),seenVersions:a.current})&&(a.current.add(t),yt.info(e(`opencodeUpdate.toast.available.title`),{id:Na,description:e(`opencodeUpdate.toast.available.description`,{version:t}),duration:1/0,action:{label:e(`opencodeUpdate.toast.actions.update`),onClick:()=>{c===n()&&l===r()&&h(t)}},cancel:{label:e(`opencodeUpdate.toast.actions.dismiss`),onClick:()=>{k().setItem(m,t),yt.dismiss(Na)}}}))},i=Da(p.data);i?t(i):(p.data?.available===!1||p.data?.canManage===!1)&&yt.dismiss(Na)},[i,e,p.data,m,c,l,h]),null},La=`plugin-load-issue`,Ra=()=>{let e=(0,qi.c)(10),{t}=be(),n=vi(),r=mr(),i=Q.useRef(``),a;e[0]===r?a=e[1]:(a=e=>{if(Di.getState().setSelected(e),r){r.openSettings(`plugins`);return}let t=j.getState();t.setSettingsPage(`plugins`),t.setSettingsDialogOpen(!0)},e[0]=r,e[1]=a);let o=J(a),s;e[2]===n?s=e[3]:(s=n.map(za).join(``),e[2]=n,e[3]=s);let c=s,l,u;return e[4]!==n||e[5]!==o||e[6]!==c||e[7]!==t?(l=()=>{if(c===i.current)return;if(i.current=c,n.length===0){yt.dismiss(La);return}let[e]=n;yt.message(n.length===1?t(`settings.plugins.issue.toast`,{name:e.label}):t(`settings.plugins.issue.toastMany`,{count:n.length}),{id:La,action:{label:t(`settings.plugins.issue.view`),onClick:()=>o(e.id)}})},u=[n,o,c,t],e[4]=n,e[5]=o,e[6]=c,e[7]=t,e[8]=l,e[9]=u):(l=e[8],u=e[9]),Q.useEffect(l,u),null};function za(e){return`${e.id}\u0000${e.error}`}var Ba=()=>{let e=(0,qi.c)(3),[t,n]=Q.useState(Va),{isUpdating:r}=t,i,a;if(e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>kt(n),a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),Q.useEffect(i,a),!r)return null;let o;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center bg-background/90`,children:(0,$.jsx)(Jn,{width:80,height:80,isAnimated:!0})}),e[2]=o):o=e[2],o};function Va(){return Ot()}function Ha({query:e,onSelect:t}){let{host:n,snapshot:r}=Dr(),{t:i}=be(),[a,o]=Q.useState(null),s=Q.useMemo(()=>e.trim()?Pt([...r.commands],e.trim(),e=>`${e.title} ${e.description??``}`,{threshold:.4}).map(({item:e})=>e):r.commands,[r.commands,e]);if(!s.length)return null;let c=a===e?s:s.slice(0,5),l=async e=>{t();try{await n?.runCommand(e)}catch(e){yt.error(e instanceof Error?e.message:i(`guiPlugins.error`))}};return(0,$.jsxs)(on,{heading:(0,$.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,$.jsx)(`span`,{children:i(`guiPlugins.commands`)}),(0,$.jsx)(`span`,{className:`yuri-global-search-group-count`,children:s.length})]}),children:[c.map(e=>(0,$.jsxs)(un,{value:`gui-plugin:${e.key}`,className:`yuri-global-search-compact min-h-9 gap-4 rounded-lg px-3 py-2 typography-meta`,onSelect:()=>void l(e.key),children:[(0,$.jsx)(`span`,{className:`yuri-global-search-result-title min-w-0 flex-1 truncate`,children:e.title}),e.description?(0,$.jsx)(`span`,{className:`yuri-global-search-result-detail max-w-[50%] truncate text-muted-foreground`,children:e.description}):null]},e.key)),c.length<s.length?(0,$.jsx)(un,{value:`gui-plugin:show-more`,onSelect:()=>o(e),children:i(`commandPalette.group.showMore`,{count:s.length-c.length})}):null]})}var Ua=5e3,Wa=(e,t)=>{if(!e)return 1;let n=1;for(let r=0;r<e.length;r+=1)if(e.charCodeAt(r)===10&&(n+=1,n>t))return n;return n},Ga=(e,t)=>Ee(Te.getState().dictionary,e,t),Ka=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`file not found`)||t.includes(`not found`)||t.includes(`enoent`)||t.includes(`no such file`)||t.includes(`does not exist`)?`missing`:`unreadable`},qa=async(e,t)=>{if(e.readFile){let n=await e.readFile(t,{optional:!0});if(typeof n.exists!=`boolean`)throw Error(`Optional file read requires an existence response header`);return{content:n.content??``,exists:n.exists}}let n=new URLSearchParams({path:t,optional:`true`}),r=await s(`/api/fs/read?${n.toString()}`,{cache:`no-store`});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to read file`)}let i=r.headers.get(`x-yuri-file-exists`);if(i!==`true`&&i!==`false`)throw Error(`Optional file read requires an existence response header`);return{content:await r.text(),exists:i===`true`}},Ja=async(e,t)=>{try{let{content:n,exists:r}=await qa(e,t);return r?Wa(n,5e3)>5e3?{ok:!1,reason:`too-large`}:{ok:!0}:{ok:!1,reason:`missing`}}catch(e){return{ok:!1,reason:Ka(e)}}},Ya=e=>e===`too-large`?Ga(`contextFileOpen.failure.tooLarge`,{count:Ua.toLocaleString(Ce())}):Ga(e===`missing`?`contextFileOpen.failure.missing`:`contextFileOpen.failure.unreadable`),Xa=(e,t)=>{let n=W(e);return!n||t.length===0?``:JSON.stringify([n,t])},Za=(e,t,n,r)=>({queryKey:[r.transport,`session-file-search`,r.generation,Xa(t,n)],staleTime:3e4,gcTime:6e4,retry:!1,queryFn:async({signal:r})=>{let i=W(t);if(!i||!n.trim())return[];r.throwIfAborted();let a=await e.search({directory:i,query:n,maxResults:10},{signal:r});r.throwIfAborted();let o=new Map;for(let e of a.slice(0,10)){let t=W(e.path);if(!t)continue;let n=t.split(`/`).pop()||t;o.has(t)||o.set(t,{path:t,name:n,directory:i})}return[...o.values()].sort((e,t)=>e.path.localeCompare(t.path))}}),Qa=(e,t)=>!t||e.length===0?[]:Pt(e,t,e=>e.name,{limit:10,threshold:.4}),$a=(e,t={})=>{let r=e.trim(),i=t.transport??n(),a=t.searchSessions??(e=>E.searchSessionsByTitle(e));return R({queryKey:V.sessionTitleSearch.query(r,i),enabled:r.length>0,queryFn:({signal:e})=>a({search:r,limit:30,signal:e}),staleTime:5e3,retry:1})},eo=e=>{let t=(0,qi.c)(13),{title:n,description:r,trailing:i}=e,a=r?`yuri-global-search-result-title min-w-0 max-w-[62%] shrink-0 truncate text-foreground`:`yuri-global-search-result-title min-w-0 flex-1 truncate text-foreground`,o;t[0]!==a||t[1]!==n?(o=(0,$.jsx)(`span`,{className:a,children:n}),t[0]=a,t[1]=n,t[2]=o):o=t[2];let s;t[3]===r?s=t[4]:(s=r?(0,$.jsx)(`span`,{className:`yuri-global-search-result-detail min-w-0 flex-1 truncate text-muted-foreground/65`,children:r}):null,t[3]=r,t[4]=s);let c;t[5]!==o||t[6]!==s?(c=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-baseline gap-4`,children:[o,s]}),t[5]=o,t[6]=s,t[7]=c):c=t[7];let l;t[8]===i?l=t[9]:(l=i?(0,$.jsx)(`div`,{className:`ml-auto flex shrink-0 items-center pl-2 text-muted-foreground/50`,children:i}):null,t[8]=i,t[9]=l);let u;return t[10]!==c||t[11]!==l?(u=(0,$.jsxs)($.Fragment,{children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12],u},to=`yuri-global-search-compact`,no=(e,t)=>(0,$.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,$.jsx)(`span`,{children:e}),(0,$.jsx)(`span`,{className:`yuri-global-search-group-count`,children:t})]}),ro=`rounded-[3px] bg-[color-mix(in_srgb,var(--primary-base)_28%,transparent)] font-[inherit] text-foreground`;function io(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);if(!n.length||!e)return e;let r=n.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)),i=RegExp(`(${r.join(`|`)})`,`gi`);return e.split(i).map((e,t)=>n.includes(e.toLowerCase())?(0,$.jsx)(`mark`,{className:ro,children:e},t):(0,$.jsx)(`span`,{children:e},t))}var ao=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},oo=[],so=Q.memo(function({presentation:e=`dialog`,onBack:t}){let{t:i,locale:o}=be(),s=I(),c=new Intl.DateTimeFormat(o,{dateStyle:`short`,timeStyle:`short`}),l=mr(),u=j(e=>e.isCommandPaletteOpen),[f,p]=Q.useState(u),m=j(e=>e.setCommandPaletteOpen),h=j(e=>e.setActiveMainTab),b=j(e=>e.setSettingsDialogOpen),x=j(e=>e.setSettingsPage),S=j(e=>e.setSessionSwitcherOpen),C=j(e=>e.toggleSidebar),w=j(e=>e.toggleContextPanel),T=j(e=>e.toggleBottomTerminal),E=j(e=>e.openContextOverview),O=j(e=>e.openContextFile),k=j(e=>e.shortcutOverrides),A=bt(e=>e.openNewSessionDraft),M=bt(e=>e.setCurrentSession),N=u||f,ee=bt(e=>N?e.currentSessionId:null),P=bt(e=>N?e.currentSessionDirectory:null),F=Ze(e=>N?e.activeSessions:oo),L=Ze(e=>N?e.status:`idle`),R=D(e=>e.currentDirectory),te=ct(e=>e.getActiveProject()),B=ct(e=>e.projects),V=jr(),{files:H}=ne(),{isMobile:re}=Yn(),U=e===`page`||re,W=Se(),ie=Q.useRef(null),ae=Q.useRef(null),oe=J(()=>{if(!U||!u||!ie.current)return;let e=window.visualViewport;ie.current.style.setProperty(`--search-viewport-height`,`${e?.height??window.innerHeight}px`),ie.current.style.setProperty(`--search-viewport-top`,`${e?.offsetTop??0}px`)});he(`resize`,oe,()=>U&&u?window.visualViewport??window:null),he(`scroll`,oe,()=>U&&u?window.visualViewport:null),Q.useEffect(()=>{oe()},[U,u]),Q.useEffect(()=>{e===`page`&&u&&ae.current?.focus({preventScroll:!0})},[e,u]);let[G,K]=Q.useState(``),[se,ce]=Q.useState({query:``,groups:[]}),q=vn(G,200).trim(),le=G.trim();Q.useEffect(()=>{u&&(K(``),ce({query:``,groups:[]}),p(!0))},[u]);let ue=J(()=>m(!1)),de=J(e=>()=>{ue(),e()}),fe=Q.useMemo(()=>{let e=[{id:`new-session`,title:i(`commandPalette.item.newSession`),shortcutId:`new_chat`,searchText:i(`commandPalette.item.newSession`),onSelect:de(()=>{h(`chat`),S(!1),A()})},{id:`new-worktree`,title:i(`commandPalette.item.newWorktreeDraft`),shortcutId:`new_chat_worktree`,searchText:i(`commandPalette.item.newWorktreeDraft`),onSelect:de(()=>{rn()})},{id:`add-project`,title:i(`commandPalette.item.addProject`),searchText:i(`commandPalette.item.addProject`),onSelect:de(()=>{Et.requestDirectoryDialog()})},{id:`toggle-sidebar`,title:i(U?`commandPalette.item.showSessionSwitcher`:`commandPalette.item.toggleSidebar`),shortcutId:`toggle_sidebar`,searchText:i(U?`commandPalette.item.showSessionSwitcher`:`commandPalette.item.toggleSidebar`),onSelect:de(()=>{if(U){let{isSessionSwitcherOpen:e}=j.getState();S(!e)}else C()})},{id:`toggle-right-sidebar`,title:i(`commandPalette.item.toggleRightSidebar`),shortcutId:`toggle_right_sidebar`,searchText:i(`commandPalette.item.toggleRightSidebar`),onSelect:de(()=>{V&&w(V)})},{id:`toggle-terminal`,title:i(`commandPalette.item.toggleTerminal`),shortcutId:`toggle_terminal`,searchText:i(`commandPalette.item.toggleTerminal`),onSelect:de(()=>T())},{id:`new-terminal-tab`,title:i(`commandPalette.item.newTerminalTab`),shortcutId:`open_new_terminal`,searchText:i(`commandPalette.item.newTerminalTab`),onSelect:de(()=>{V&&ln(V)})},{id:`context-usage`,title:i(`commandPalette.item.showContextUsage`),searchText:i(`commandPalette.item.showContextUsage`),onSelect:de(()=>{R&&E(R)})},{id:`open-settings`,title:i(`commandPalette.item.openSettings`),shortcutId:`open_settings`,searchText:i(`commandPalette.item.openSettings`),onSelect:de(()=>b(!0))}];return v()||e.push({id:`setup-tour`,title:i(`tour.open`),searchText:i(`tour.open`),onSelect:de(()=>{b(!1),wi.getState().open(a())})}),g()&&e.splice(1,0,{id:`new-mini-chat`,title:i(`commandPalette.item.newMiniChat`),shortcutId:`new_mini_chat`,searchText:i(`commandPalette.item.newMiniChat`),onSelect:de(()=>{_(`desktop_open_draft_mini_chat_window`,{directory:ao(R||te?.path||``),projectId:te?.id??null}).catch(e=>{console.warn(`[command-palette] failed to open draft mini chat window`,e)})})}),e},[i,de,U,h,S,A,C,w,T,R,V,E,b,te?.id,te?.path]),pe=Q.useMemo(()=>{let e=y();return{isVSCode:v(),isWeb:!e&&d(),isDesktop:e,isMobile:U}},[U]),me=Q.useMemo(()=>tr.filter(e=>e.slug!==`home`).filter(e=>!e.isAvailable||e.isAvailable(pe)).map(e=>{let t=(e.keywords??[]).join(` `);return{id:`settings:${e.slug}`,title:e.title,searchText:`${e.title} ${e.group} ${t}`,onSelect:de(()=>{x(e.slug),b(!0)})}}),[pe,de,x,b]),ge=Q.useMemo(()=>{let e=e=>(typeof e.time?.updated==`number`?e.time.updated:0)||(typeof e.time?.created==`number`?e.time.created:0);return[...F].sort((t,n)=>e(n)-e(t))},[F]),_e=bt(e=>e.worktreeMetadata),ve=bt(e=>e.availableWorktreesByProject),ye=Q.useMemo(()=>ee&&P&&ht(B,ve,P)?ao(P):null,[ee,P,B,ve]),xe=n(),Ce=r(),Y=Q.useMemo(()=>({transport:xe,generation:Ce,directory:``}),[xe,Ce]),X=Q.useMemo(()=>Za(H,ye,q,Y),[H,ye,q,Y]),Te=le.length>0,Ee=Q.useMemo(()=>Te?Pt(fe,le,e=>e.searchText,{limit:7,noFuzzy:!0}):fe.map(e=>({item:e,score:0})),[fe,le,Te]),De=Q.useMemo(()=>Te?Pt(me,le,e=>e.searchText,{limit:7,noFuzzy:!0}):[],[me,le,Te]),Oe=u&&le===q,ke=Q.useMemo(()=>$a(q,{transport:xe}),[q,xe]),Ae=z({...ke,enabled:Oe&&(q.length>0||e===`page`)}),je=JSON.stringify([Y.transport,Y.generation,le,u]),[Ne,Pe]=Q.useState(null),Fe=Ne?.key===je?Ne:null;Ne&&!Fe&&Pe(null);let Ie=Q.useMemo(()=>sa(q,{scope:Y}),[q,Y]),Le=z({...Ie,enabled:Oe&&q.length>0}),Re=z({...X,enabled:Oe&&q.length>0&&ye!==null&&!Ae.isPending&&!Le.isPending});Q.useEffect(()=>{if(!Oe)for(let e of[ke.queryKey,Ie.queryKey,X.queryKey])s.cancelQueries({queryKey:e,exact:!0})},[s,Oe,ke,Ie,X]);let ze=Q.useMemo(()=>Fe?.hits??Le.data??[],[Fe,Le.data]),Be=Te&&le===q&&Le.isError,Ve=Te&&le===q&&Ae.isSuccess,He=(Te||e===`page`)&&le===q&&Ae.isError,Ue=Q.useMemo(()=>He?Pt(ge,le,e=>e.title||``,{limit:30,threshold:.2}).map(({item:e})=>e):[],[He,ge,le]),We=Q.useMemo(()=>Fe?Fe.sessions:Te?Ve?Ae.data??[]:He?Ue:[]:e===`page`&&!q&&Ae.isSuccess?Ae.data:ge.slice(0,e===`page`?30:9),[Te,ge,Ve,He,Ue,Ae.data,Ae.isSuccess,e,q,Fe]),Ge=Q.useMemo(()=>!u&&!f||le!==q?[]:Qa(Re.data??[],q),[u,f,Re.data,q,le]),Ke=Q.useMemo(()=>{if(!Te)return[];let e=B.map(e=>({...e,displayName:e.label||e.path.split(`/`).pop()||e.path,searchText:`${e.label||``} ${e.path}`}));return Pt(e,le,e=>e.searchText,{limit:7,threshold:.4})},[B,le,Te]),qe=JSON.stringify([Y.transport,Y.generation,le]),Je=se.query===qe?se.groups:[],Ye=(e,t)=>Te&&!Je.includes(e)?t.slice(0,5):t,Xe=Ye(`commands`,Ee.map(e=>e.item)),Qe=Ye(`settings`,De.map(e=>e.item)),$e=Q.useMemo(()=>{let e=new Map;for(let t of ze){let n=e.get(t.sessionID);(!n||t.createdAt>n.createdAt||t.createdAt===n.createdAt&&t.messageID>n.messageID)&&e.set(t.sessionID,t)}let t=[],n=new Map(F.map(e=>[e.id,e]));for(let n of We)t.push({session:n,hit:e.get(n.id)}),e.delete(n.id);for(let r of e.values())t.push({session:n.get(r.sessionID)??{id:r.sessionID,title:r.title??``,directory:r.directory,location:{directory:r.directory}},hit:r});return t},[We,ze,F]),et=Ye(`sessions`,$e),tt=Te?Ye(`files`,Ge.map(e=>e.item)):[],nt=Te?Ye(`projects`,Ke.map(e=>e.item)):[],rt=(e,t,n)=>t>n?(0,$.jsx)(un,{value:`more:${e}`,onSelect:()=>ce({query:qe,groups:[...Je,e]}),className:`${to} text-muted-foreground`,children:i(`commandPalette.group.showMore`,{count:t-n})}):null,it=Q.useMemo(()=>{if(!Te)return[`sessions`,`commands`];let e=e=>e.length?e[0].score:1/0,t=[{key:`commands`,score:e(Ee)},{key:`settings`,score:e(De)},{key:`files`,score:e(Ge)},{key:`projects`,score:e(Ke)}];return t.sort((e,t)=>e.score-t.score),[`sessions`,...t.map(e=>e.key)]},[Te,Ee,De,Ge,Ke]),at=J((e,t)=>{ue(),h(`chat`),S(!1);let n=ot(e)||``;l?St.getState().openSession({sessionId:e.id,directory:n}):M(e.id,n),t&&Xt(t)}),st=J(e=>{let t=ge.find(t=>t.id===e.sessionID)??We.find(t=>t.id===e.sessionID)??{id:e.sessionID,title:e.title??``,directory:e.directory,location:{directory:e.directory}};at(t,e.messageID)}),lt=J(async e=>{let t=Re.data?.find(t=>t.path===e);if(!t)return;let i=n(),a=r(),o=await Ja(H,e);if(i===n()&&a===r()){if(!o.ok){yt.error(Ya(o.reason));return}l?l.openFile({path:e}):O(t.directory,e),ue()}}),ut=J((e,t)=>{ue();let n={selectedProjectId:e,directoryOverride:t};l?St.getState().openDraft(n):A(n)}),dt=e=>Un(Ln(e,k)),ft=e=>!wt&&(e.key===`Enter`||e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),e.stopPropagation(),!0),pt=J(e=>{if(ft(e)||(!Fe&&!e.nativeEvent.isComposing&&[`ArrowDown`,`ArrowUp`,`Enter`].includes(e.key)&&Pe({key:je,hits:ze,sessions:We}),U||e.nativeEvent.isComposing||e.altKey||e.shiftKey)||(W?!e.metaKey||e.ctrlKey:!e.ctrlKey||e.metaKey)||!/^[1-9]$/.test(e.key)||(e.preventDefault(),e.stopPropagation(),e.repeat||!wt))return;let t=et[Number(e.key)-1];t?.hit?st(t.hit):t&&at(t.session)}),mt=e=>{let t=ao(_e.get(e.id)?.projectDirectory||ot(e)||``),n=ht(B,ve,t);return n?.label||(n?.path||t).split(`/`).pop()||``},gt=Te&&le===q&&Re.isError,_t=Te&&le===q&&Re.isFetching&&!Re.isSuccess,vt=Te&&(le!==q||Ae.isFetching&&!Ae.isSuccess||Y!==null&&Le.isFetching&&!Le.isSuccess),[xt,Ct]=Q.useState(q);!vt&&xt!==q&&Ct(q);let wt=!Te||xt===q&&!vt,Tt=(0,$.jsx)(tn,{ref:ae,variant:U?`mobileGlass`:`default`,className:`font-normal`,"aria-label":i(`commandPalette.title`),inputMode:`search`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,value:G,onValueChange:e=>{Pe(null),K(e),ce({query:``,groups:[]})},placeholder:i(`commandPalette.input.placeholder`)}),Dt=(0,$.jsxs)(cn,{loop:!0,shouldFilter:!1,style:{"--yuri-search-shortcut-width":W?`1.75rem`:`3rem`},onKeyDownCapture:pt,onPointerDownCapture:e=>{let t=e.target.closest(`[cmdk-item]`);U&&t&&sr({currentTarget:t})},onPointerCancelCapture:e=>{let t=e.target.closest(`[cmdk-item]`);U&&t&&lr({currentTarget:t,detail:1})},onClickCapture:e=>{let t=e.target.closest(`[cmdk-item]`);U&&t&&e.detail>0&&!lr({currentTarget:t,detail:e.detail})&&(e.preventDefault(),e.stopPropagation())},className:`max-h-full min-h-0 rounded-[inherit] bg-transparent [&_[cmdk-group]]:px-0 [&_[cmdk-item][data-selected=true]]:!bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)] [&_[cmdk-item]:hover]:!bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)]`,children:[U?(0,$.jsx)(Me,{title:Tt,backAriaLabel:i(`header.actions.backAria`),onBack:t??ue}):Tt,(0,$.jsxs)(pn,{"aria-label":i(`commandPalette.title`),className:`yuri-global-search-results overscroll-contain`,children:[wt&&!_t&&!gt&&!He&&!Be&&L!==`loading`&&L!==`error`?(0,$.jsx)(fn,{className:`py-10 text-center typography-meta text-muted-foreground`,children:i(`commandPalette.empty.noResults`)}):null,u&&wt?(0,$.jsx)(Ha,{query:le,onSelect:ue}):null,wt?it.map(e=>e===`commands`&&Xe.length>0?(0,$.jsxs)(on,{heading:no(i(`settings.page.commands.title`),Ee.length),children:[Xe.map(e=>(0,$.jsx)(un,{value:e.id,onSelect:e.onSelect,className:to,children:(0,$.jsx)(eo,{title:io(e.title,le),trailing:!U&&e.shortcutId?(0,$.jsx)(mn,{variant:`hint`,children:dt(e.shortcutId)}):void 0})},e.id)),rt(`commands`,Ee.length,Xe.length)]},`commands`):e===`settings`&&Qe.length>0?(0,$.jsxs)(on,{heading:no(i(`settings.view.home.title`),De.length),children:[Qe.map(e=>(0,$.jsx)(un,{value:e.id,onSelect:e.onSelect,className:to,children:(0,$.jsx)(eo,{title:io(e.title,le)})},e.id)),rt(`settings`,De.length,Qe.length)]},`settings`):e===`sessions`&&et.length>0?(0,$.jsxs)(on,{heading:no(i(`layout.mainTab.chat`),$e.length),children:[et.map(({session:e,hit:t},n)=>{let r=t?.title||e.title||i(`commandPalette.session.untitled`),a=mt(e),s=t?.createdAt??e.time?.updated??e.time?.created,l=new Date(s??NaN),u=Number.isFinite(l.getTime());return(0,$.jsxs)(un,{value:t?`message:${e.id}:${t.messageID}`:`session:${e.id}`,onSelect:()=>t?st(t):at(e),className:`yuri-global-search-session`,"aria-keyshortcuts":!U&&n<9?`${W?`Meta`:`Control`}+${n+1}`:void 0,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`yuri-global-search-session-heading`,children:[(0,$.jsx)(`span`,{className:`yuri-global-search-session-title min-w-0 truncate text-foreground`,title:r,children:io(r,le)}),u?(0,$.jsx)(`time`,{dateTime:l.toISOString(),title:l.toLocaleString(o),className:`yuri-global-search-session-time shrink-0 whitespace-nowrap text-muted-foreground`,children:c.format(l)}):null]}),t?(0,$.jsxs)(`span`,{className:`yuri-global-search-session-excerpt text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`yuri-global-search-session-speaker`,children:[i(t.role===`user`?`commandPalette.message.user`:`commandPalette.message.assistant`),`: `]}),io(t.snippet.replace(/\s+/g,` `),le)]}):null]}),(0,$.jsx)(`span`,{className:`yuri-global-search-session-project min-w-0 truncate text-muted-foreground`,title:a,children:a}),!U&&n<9?(0,$.jsxs)(mn,{variant:`hint`,className:`yuri-global-search-session-shortcut justify-self-end`,children:[W?`⌘`:`Ctrl+`,n+1]}):null]},t?`message:${e.id}:${t.messageID}`:`session:${e.id}`)}),rt(`sessions`,$e.length,et.length)]},`sessions`):e===`files`&&tt.length>0?(0,$.jsxs)(on,{heading:no(i(`layout.mainTab.files`),Ge.length),children:[tt.map(e=>{let t=we(e.path,{maxLength:80});return(0,$.jsx)(un,{value:`file:${e.path}`,onSelect:()=>{lt(e.path)},className:to,children:(0,$.jsx)(eo,{title:io(e.name,le),description:t===e.name?void 0:io(t,le)})},`file:${e.path}`)}),rt(`files`,Ge.length,tt.length)]},`files`):e===`projects`&&nt.length>0?(0,$.jsxs)(on,{heading:no(i(`sessions.sidebar.projectsTitle`),Ke.length),children:[nt.map(e=>{let t=e.displayName;return(0,$.jsx)(un,{value:`project:${e.id}`,onSelect:()=>ut(e.id,e.path),className:to,children:(0,$.jsx)(eo,{title:io(t,le),description:io(we(e.path,{maxLength:80}),le)})},`project:${e.id}`)}),rt(`projects`,Ke.length,nt.length)]},`projects`):null):(0,$.jsx)(`div`,{role:`status`,className:`px-3 py-10 text-center typography-meta text-muted-foreground`,children:i(`common.loading`)}),wt&&L===`loading`?(0,$.jsx)(`div`,{role:`status`,className:`px-3 py-4 text-center typography-meta text-muted-foreground`,children:i(`common.loading`)}):null,wt&&L===`error`?(0,$.jsx)(`div`,{role:`alert`,className:`px-3 py-4 typography-meta text-[var(--status-error)]`,children:i(`commandPalette.error.sessions`)}):null,wt&&He?(0,$.jsx)(`div`,{role:`alert`,className:`px-3 py-4 typography-meta text-[var(--status-error)]`,children:i(`commandPalette.error.sessions`)}):null,wt&&Be?(0,$.jsx)(`div`,{role:`alert`,className:`px-3 py-4 typography-meta text-[var(--status-error)]`,children:i(`commandPalette.error.messages`)}):null,wt&&_t?(0,$.jsx)(`div`,{"data-file-search-pending":!0,role:`status`,className:`px-4 py-2 text-xs text-muted-foreground`,children:i(`common.loading`)}):null,wt&&gt?(0,$.jsx)(`div`,{"data-file-search-notice":!0,role:`status`,className:`px-4 py-2 text-xs text-muted-foreground`,children:i(`commandPalette.error.files`)}):null]})]});return e===`page`?(0,$.jsx)(`section`,{ref:ie,"data-global-search":`true`,"data-page-scroll-lock":`true`,"aria-label":i(`commandPalette.title`),className:`yuri-global-search-page flex min-h-0 w-full flex-col bg-background text-foreground`,children:Dt}):(0,$.jsx)(qt,{open:u,onOpenChange:m,onOpenChangeComplete:e=>{e||p(!1)},children:(0,$.jsxs)(Wt,{ref:ie,initialFocus:ae,"data-global-search":`true`,"data-mobile":U,"data-page-scroll-lock":`true`,presentation:U?`default`:`picker`,className:U?`yuri-global-search-page yuri-global-search-mobile fixed inset-0 z-50 m-0 flex max-w-none translate-x-0 translate-y-0 flex-col gap-0 overflow-hidden rounded-none border-0 bg-background p-0`:`yuri-global-search z-50 w-[min(56rem,calc(100vw-3rem))]`,containerClassName:`block p-0`,overlayClassName:`bg-transparent dark:bg-transparent`,showCloseButton:!1,children:[(0,$.jsxs)(Ht,{className:`sr-only`,children:[(0,$.jsx)(Gt,{children:i(`commandPalette.title`)}),(0,$.jsx)(Kt,{children:i(`commandPalette.description`)})]}),Dt]})})}),co=class extends Q.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){this.setState({error:e,errorInfo:t})}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};render(){return this.state.hasError?(0,$.jsx)(`div`,{className:`flex items-center justify-center min-h-screen p-4`,children:(0,$.jsxs)(zn,{className:`w-full max-w-md`,children:[(0,$.jsx)(Gn,{className:`text-center`,children:(0,$.jsxs)(Kn,{className:`flex items-center justify-center gap-2 text-destructive`,children:[(0,$.jsx)(Z,{name:`chat-3`,className:`h-5 w-5`}),this.props.texts.title]})}),(0,$.jsxs)(In,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground text-center`,children:this.props.texts.description}),this.props.sessionId&&(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground text-center`,children:[this.props.texts.sessionLabel,`: `,this.props.sessionId]}),this.state.error&&(0,$.jsxs)(`details`,{className:`text-xs font-mono bg-muted p-3 rounded`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer hover:bg-interactive-hover/80`,children:this.props.texts.detailsSummary}),(0,$.jsx)(`pre`,{className:`mt-2 max-h-48 overflow-auto`,children:this.state.error.toString()})]}),(0,$.jsx)(`div`,{className:`flex gap-2`,children:(0,$.jsxs)(X,{onClick:this.handleReset,variant:`outline`,className:`flex-1`,children:[(0,$.jsx)(Z,{name:`restart`,className:`h-4 w-4 mr-2`}),this.props.texts.resetAction]})}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground text-center`,children:this.props.texts.persistentHint})]})]})}):this.props.children}};function lo(e){let t=(0,qi.c)(22),{t:n}=be(),r;t[0]===n?r=t[1]:(r=n(`chat.errorBoundary.title`),t[0]=n,t[1]=r);let i;t[2]===n?i=t[3]:(i=n(`chat.errorBoundary.description`),t[2]=n,t[3]=i);let a;t[4]===n?a=t[5]:(a=n(`chat.errorBoundary.sessionLabel`),t[4]=n,t[5]=a);let o;t[6]===n?o=t[7]:(o=n(`chat.errorBoundary.detailsSummary`),t[6]=n,t[7]=o);let s;t[8]===n?s=t[9]:(s=n(`chat.errorBoundary.resetAction`),t[8]=n,t[9]=s);let c;t[10]===n?c=t[11]:(c=n(`chat.errorBoundary.persistentHint`),t[10]=n,t[11]=c);let l;t[12]!==r||t[13]!==i||t[14]!==a||t[15]!==o||t[16]!==s||t[17]!==c?(l={title:r,description:i,sessionLabel:a,detailsSummary:o,resetAction:s,persistentHint:c},t[12]=r,t[13]=i,t[14]=a,t[15]=o,t[16]=s,t[17]=c,t[18]=l):l=t[18];let u;return t[19]!==e||t[20]!==l?(u=(0,$.jsx)(co,{...e,texts:l}),t[19]=e,t[20]=l,t[21]=u):u=t[21],u}var uo=1440,fo=e=>{let t=(0,qi.c)(10),{isMobile:n,isVSCode:r,directory:i}=e,a=ge(`(min-width: ${uo}px)`),o;t[0]===i?o=t[1]:(o=i?A(i):``,t[0]=i,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=e=>{let t=M(e,s);return t?.isOpen?(t.tabs.find(e=>e.id===t.activeTabId)??t.tabs[t.tabs.length-1]??null)?.mode!==`chat`:!1},t[2]=s,t[3]=c);let l=j(c),u=j(po),d;t[4]===s?d=t[5]:(d=e=>e.isRightSidebarOpen&&!!M(e,s)?.isOpen,t[4]=s,t[5]=d);let f=j(d),p=!n&&!r&&!l&&!f,m=p&&a,h=u&&m,g;return t[6]!==m||t[7]!==p||t[8]!==h?(g={visible:h,fits:m,layoutAllows:p},t[6]=m,t[7]=p,t[8]=h,t[9]=g):g=t[9],g};function po(e){return e.workStatusPanelEnabled}var mo=async({directory:e,sessionID:t,signal:n})=>{let r=await E.getScopedSdkClient(e).session.list({directory:e,parentID:t,limit:200},{signal:n});if(!Array.isArray(r?.data))throw Error(`session.list children returned no data`);return r.data.flatMap(e=>{if(!e?.id)return[];let t=typeof e.title==`string`?e.title:void 0;return[{id:e.id,title:t}]})},ho=(e,t,n={})=>{let r=n.listChildren??mo;return R({queryKey:V.workStatusChildren.list(e,t,n.transport),enabled:!!(e&&t),queryFn:({signal:n})=>r({directory:e,sessionID:t,signal:n}),staleTime:5e3,refetchInterval:1e4})},go=[],_o=(...e)=>{let t=_n(...e);return t?t.charAt(0).toUpperCase()+t.slice(1):``},vo=(...e)=>{for(let t of e){if(!t||typeof t!=`object`)continue;let e=t.description;if(typeof e!=`string`)continue;let n=e.trim();if(n)return n}return``},yo=e=>e===`pending`||e===`running`,bo=e=>{let t=[],n=new Set;for(let r of e.messageOrder){let i=e.partsByMessageID[r];if(i)for(let e of i){if(!e?.id||n.has(e.id))continue;if(e.type===`tool`&&Qt(e.tool)){n.add(e.id);let r=e.state;t.push({id:e.id,sessionID:en(e),label:_o(r?.input,r?.metadata,e.metadata),description:vo(r?.input,e.metadata,r?.metadata),running:yo(r?.status)});continue}if(e.type!==`subtask`)continue;let r=e,i=typeof r.taskSessionID==`string`?r.taskSessionID.trim():``,a=typeof r.agent==`string`?r.agent.trim():``,o=typeof r.description==`string`?r.description.trim():``;n.add(e.id),t.push({id:e.id,sessionID:i||void 0,label:a?a.charAt(0).toUpperCase()+a.slice(1):``,description:o,running:yo(r.status)})}}return t.length===0?go:t},xo=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(!r||!i||r.id!==i.id||r.sessionID!==i.sessionID||r.label!==i.label||r.description!==i.description||r.running!==i.running)return!1}return!0},So=e=>e.childTitle||e.description||e.agent,Co=e=>({key:e.key,sessionID:e.sessionID,seed:e.key,label:So(e),phase:e.working?`working`:`done`}),wo=(e,t,n)=>{let r=new Map(t.map(e=>[e.id,e])),i=new Set,a=[],o=new Map,s=e=>{let t=e.sessionID;if(!t){a.push(e);return}i.add(t);let n=o.get(t);if(n===void 0){o.set(t,a.length),a.push({...e,key:t,sessionID:t});return}let r=a[n];r&&(a[n]={...r,description:r.description||e.description,agent:r.agent||e.agent,childTitle:e.childTitle||r.childTitle,working:r.working||e.working})};for(let t of e){let e=t.sessionID?r.get(t.sessionID):void 0;s({key:t.id,sessionID:t.sessionID,description:t.description,agent:t.label,childTitle:e?.title?.trim()||``,working:t.running||!!e?.busy||!!(t.sessionID&&n?.has(t.sessionID))})}for(let e of t)i.has(e.id)||s({key:e.id,sessionID:e.id,description:``,agent:``,childTitle:e.title?.trim()||``,working:e.busy});let c=a.map(Co),l=c.filter(e=>e.phase===`working`),u=c.filter(e=>e.phase===`done`);return l.length===0?u:u.length===0?l:[...l,...u]},To=new Set,Eo=e=>{if(!e)return``;let t=[];for(let n of Object.keys(e)){let r=e[n]?.type;(r===`busy`||r===`retry`)&&t.push(n)}return t.sort(),t.join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/OnboardingScreen-CgQGvlEs.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-fetch-D0YWp3FJ.js","assets/runtime-auth-DBn9yahL.js","assets/runtime-switch-DEZ1K7qW.js","assets/desktop-JwYqThiw.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/desktopHosts-CB0CTcMg.js","assets/vendor-base-ui-CzHs0bHY.js","assets/persistence-D-rnhgr4.js","assets/vendor-zustand-vDaAPGfl.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/useUIStore-CoWJ3ROq.js","assets/vendor-react-DlzBev0S.js","assets/queryRuntime-2dx7jbt9.js","assets/vendor-tanstack-query-core-Y_YoRHtC.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/button-Cjciq1yh.js","assets/store-CKIMMlXR.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/tour-Db44qwfs.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/Icon-BQczEnxm.js","assets/dialog-rVkj8VgE.js","assets/dialog-CTYD3Sbr.css","assets/input-GVRUiwuQ.js","assets/YuriLogo-CpccdHvS.js","assets/useThemeSystem-CNzUUkFn.js","assets/SetupTourDialog-CxsiEmUV.js","assets/vendor-tanstack-react-query-B-Wpqq5J.js","assets/vendor-reactuses-core-DWo5Wn6R.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/useMobileNavigationStore-DYc48dNS.js","assets/gitApiHttp-Ddik7PM_.js","assets/vendor-opencode-client-cQ47ywrT.js","assets/vendor-effect-X1Hqc7ba.js","assets/runtime-file-resource-BP4P52ry.js","assets/fileQueries-C2Rs6TPz.js","assets/runtime-file-store-BVRgEtI-.js","assets/path-utils-jGozTg9d.js","assets/platform-DFJEtBlo.js","assets/vendor-sonner-BEHGipm5.js","assets/useAssistantUIStore-BI_dAUjx.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/select-DeP9bukP.js","assets/device-DN1GigI_.js","assets/MobileResizableSheet-Bk3z4g6T.js","assets/vendor-framer-motion-DDMKlXiP.js","assets/MobileWindowStack-DGLdgoGr.js","assets/textarea-B4mWtnN5.js","assets/OverlayScrollbar-C9Ac564a.js","assets/MarkdownRenderer-D0UA-oW2.js","assets/useEffectiveDirectory-BCMjNzpx.js","assets/markdownHeightCache-C7UOJdkN.js","assets/dualLimitLru-D8Sphgua.js","assets/speechSettingsQueries-DfG7QJBy.js","assets/useDictation-CwX05CAo.js","assets/YuriWordmark-hZ6K7Smk.js","assets/usePluginsStore-BzZm-uao.js","assets/VoiceSettings-CTXfVzZh.js","assets/tooltip-BuZ86ipm.js","assets/url-MRa-FtQa.js","assets/VoiceSettings-C0HSdVvS.css","assets/SetupTourDialog-CUzqT2sw.css","assets/GuiPluginSurface-BqFdg497.js","assets/react-Bwr5-XPi.js","assets/readiness-CZbavzQq.js","assets/GuiPluginWindow-CIVNyw4s.js","assets/native-DsqzO52u.js","assets/native-errors-06if6eu-.js","assets/vendor-opencode-plugin-BmdTE4Te.js","assets/host-D776RHTx.js","assets/appearance--vFosLNi.js","assets/themes-BgDJcxRc.js","assets/theme-validation-BGYdrOu7.js","assets/fileReferenceParser-1HHDBUum.js","assets/vendor-solid-js-D98iXT7C.js","assets/gui-CJjEj3l4.js","assets/fileReferenceActions-CvDFcgBH.js","assets/toolHelpers-iEHVHQ9p.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,n as r,o as i,r as a,s as o}from"./runtime-switch-DEZ1K7qW.js";import{n as s}from"./runtime-fetch-D0YWp3FJ.js";import{A as c,G as l,M as u,T as d,U as f,b as p,c as m,s as h,t as g,v as _,w as v,x as y}from"./desktop-JwYqThiw.js";import{a as b,i as x,o as S}from"./vendor-zustand-vDaAPGfl.js";import{at as C,ot as w,st as T}from"./vendor-base-ui-CzHs0bHY.js";import{At as E,bt as D,sr as O}from"./gitApiHttp-Ddik7PM_.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{S as k,n as A,r as j,t as M}from"./useUIStore-CoWJ3ROq.js";import{At as N,Mt as ee,ot as P}from"./persistence-D-rnhgr4.js";import{n as F}from"./vendor-react-DlzBev0S.js";import{l as I,n as L,o as R,s as z,t as te}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{a as B,o as V}from"./queryRuntime-2dx7jbt9.js";import{l as H,u as ne}from"./fileQueries-C2Rs6TPz.js";import{o as re}from"./path-utils-jGozTg9d.js";import{o as U}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as W}from"./pathNormalization-ewtPqJWn.js";import{i as ie}from"./terminalApi-ChZhb60_.js";import{r as ae}from"./platform-DFJEtBlo.js";import{c as oe,d as G,f as K,l as se,m as ce,n as q,o as le,p as ue,s as de,t as fe,u as pe}from"./vendor-pierre-diffs-BFiZ3IhI.js";import{r as me}from"./vendor-sonner-BEHGipm5.js";import{a as he,d as ge,h as _e,i as J,o as ve}from"./vendor-reactuses-core-DWo5Wn6R.js";import{d as ye,f as be,i as xe,l as Se,p as Ce,r as Y,t as X,u as we}from"./button-Cjciq1yh.js";import{i as Te,t as Ee}from"./store-CKIMMlXR.js";import{A as De,D as Oe,E as ke,O as Ae,k as je,t as Me,v as Ne}from"./MobileDetailNavigation-DWx5Qg0b.js";import{$t as Pe,B as Fe,Br as Ie,Bt as Le,Dt as Re,Ei as ze,Et as Be,Ft as Ve,G as He,It as Ue,Jr as We,K as Ge,Kr as Ke,Nt as qe,Oa as Je,Oi as Ye,Pt as Xe,Qr as Ze,Rr as Qe,Ta as $e,Tt as et,Ur as tt,V as nt,Vr as rt,Wr as it,Xr as at,Yr as ot,Zr as st,_a as ct,an as lt,ar as ut,cr as dt,ei as ft,fr as pt,ft as mt,hr as ht,ii as gt,ja as _t,jn as vt,ni as yt,p as bt,q as xt,s as St,st as Ct,ti as wt,tn as Tt,tr as Et,ur as Dt,va as Ot,ya as kt,zi as At,zr as jt}from"./useMobileNavigationStore-DYc48dNS.js";import{i as Mt,t as Nt}from"./useAssistantUIStore-BI_dAUjx.js";import{g as Pt}from"./fileMentionAutocompleteState-BZJqfgae.js";import{n as Ft,t as It}from"./AgentAvatar-CR6dX_XT.js";import{n as Lt,r as Rt,t as zt}from"./useThemeSystem-CNzUUkFn.js";import{i as Bt,t as Vt}from"./vendor-framer-motion-DDMKlXiP.js";import{n as Z}from"./Icon-BQczEnxm.js";import{a as Ht,i as Ut,n as Wt,o as Gt,r as Kt,t as qt}from"./dialog-rVkj8VgE.js";import{d as Jt}from"./gitApi-D6P3ytSw.js";import{C as Yt,E as Xt,It as Zt,L as Qt,Q as $t,R as en,at as tn,bt as nn,ct as rn,et as an,it as on,mt as sn,nt as cn,o as ln,ot as un,pt as dn,rt as fn,st as pn,vt as mn,xt as hn,yt as gn,z as _n}from"./useAppFontEffects-iu-GyWPx.js";import{E as vn,b as yn,h as bn,k as xn,r as Sn,v as Cn,w as wn,x as Tn,y as En}from"./insertionBoundaries-DE9VLpxi.js";import{t as Dn}from"./input-GVRUiwuQ.js";import{i as On,n as kn,t as An}from"./tooltip-BuZ86ipm.js";import{$ as jn,J as Mn,X as Nn,Y as Pn,Z as Fn,_t as In,ct as Ln,et as Rn,gt as zn,ht as Bn,m as Vn,nt as Hn,ot as Un,p as Wn,vt as Gn,yt as Kn}from"./pwa-H5fgqBjr.js";import{n as qn,t as Jn}from"./YuriLogo-CpccdHvS.js";import{r as Yn}from"./device-DN1GigI_.js";import{r as Xn}from"./themes-BgDJcxRc.js";import{a as Zn,g as Qn,i as $n,r as er,s as tr,t as nr,u as rr}from"./scheduledTaskNavigation-Bp5rGr3m.js";import{C as ir,_ as ar,f as or,m as sr,n as cr,p as lr,r as ur,t as dr,u as fr,y as pr}from"./MobileResizableSheet-Bk3z4g6T.js";import{E as mr,n as hr,r as gr}from"./sessionLookup-CTnucWJc.js";import{c as _r,i as vr,n as yr,s as br,t as xr}from"./select-DeP9bukP.js";import{n as Sr,t as Cr}from"./appThemeRegistry-BLQvL9m5.js";import{o as wr}from"./MarkdownRenderer-D0UA-oW2.js";import{a as Tr,c as Er}from"./toolHelpers-iEHVHQ9p.js";import{i as Dr,n as Or,r as kr,t as Ar}from"./react-Bwr5-XPi.js";import{n as jr}from"./useEffectiveDirectory-BCMjNzpx.js";import{t as Mr}from"./LoadingImage-Ch5MyA20.js";import{_ as Nr,c as Pr,g as Fr,i as Ir,l as Lr,n as Rr,o as zr,s as Br,t as Vr,v as Hr,y as Ur}from"./vendor-dnd-kit-core-DK4OoOTr.js";import{a as Wr,o as Gr,s as Kr,t as qr}from"./vendor-dnd-kit-sortable-Cv69eQm1.js";import{t as Jr}from"./OverlayScrollbar-C9Ac564a.js";import{n as Yr,r as Xr,t as Zr}from"./textarea-B4mWtnN5.js";import{a as Qr,d as $r,f as ei,i as ti,l as ni,n as ri,p as ii,r as ai,s as oi,t as si}from"./projectMeta-UlBCJIBo.js";import{_ as ci,b as li,g as ui,n as di,v as fi,y as pi}from"./useWorkerHighlightedLines-B4sqe9Xq.js";import{t as mi}from"./vendor-tanstack-react-virtual-DSFNK3qc.js";import{t as hi}from"./vendor-motion-C9oiAdx-.js";import{G as gi,M as _i,N as vi,W as yi,d as bi,j as xi,t as Si,x as Ci}from"./MobileTabPageHeader-CwJW-4fw.js";import{n as wi}from"./YuriWordmark-hZ6K7Smk.js";import{c as Ti,l as Ei}from"./mcpQueries-BXdUXuLQ.js";import{t as Di}from"./usePluginsStore-BzZm-uao.js";import{n as Oi}from"./mobileBackNavigation-CoPwMqGc.js";import{i as ki,r as Ai}from"./AssistantUnreadBadge-i7n8bLaM.js";import{a as ji,i as Mi,n as Ni,r as Pi,t as Fi}from"./context-menu-BIjCIXOg.js";import{n as Ii,r as Li,t as Ri}from"./collapsible-BzCn4-sd.js";import{a as zi,i as Bi,n as Vi,t as Hi}from"./readiness-CZbavzQq.js";import{n as Ui,t as Wi}from"./native-errors-06if6eu-.js";import{t as Gi}from"./appearance--vFosLNi.js";import{t as Ki}from"./vendor-cron-parser-BmO80h0C.js";var Q=e(T(),1),qi=F(),$=w(),Ji=e(C(),1);function Yi(){return new Worker(fe,{type:`module`})}var Xi=[`typescript`,`javascript`,`tsx`,`jsx`,`json`,`markdown`],Zi={unified:{poolSize:1,totalASTLRUCacheSize:24,lineDiffType:`none`},split:{poolSize:2,totalASTLRUCacheSize:56,lineDiffType:`word-alt`}},Qi,$i,ea=e=>{let t=Zi[e],n=new ue({workerFactory:Yi,poolSize:t.poolSize,totalASTLRUCacheSize:t.totalASTLRUCacheSize},{theme:{light:`pierre-light`,dark:`pierre-dark`},langs:Xi,lineDiffType:t.lineDiffType,preferredHighlighter:`shiki-wasm`});return n.initialize(),n},ta=e=>{if(!(typeof window>`u`))return e===`split`?($i??=ea(`split`),$i):(Qi??=ea(`unified`),Qi)},na=e=>{let t=(0,qi.c)(7),{children:n,renderTheme:r}=e,i=ia(`unified`),a=ia(`split`),o,s;t[0]!==r||t[1]!==a||t[2]!==i?(o=()=>{i&&i.setRenderOptions({theme:r,lineDiffType:Zi.unified.lineDiffType}),a&&a.setRenderOptions({theme:r,lineDiffType:Zi.split.lineDiffType})},s=[r,a,i],t[0]=r,t[1]=a,t[2]=i,t[3]=o,t[4]=s):(o=t[3],s=t[4]),(0,Q.useEffect)(o,s);let c;return t[5]===n?c=t[6]:(c=(0,$.jsx)($.Fragment,{children:n}),t[5]=n,t[6]=c),c},ra=e=>{let t=(0,qi.c)(11),{children:n}=e,r=zt(),i,a;if(t[0]!==r?.availableThemes||t[1]!==r?.darkThemeId||t[2]!==r?.lightThemeId){let e=Xn(!1),n=Xn(!0),o=r?.lightThemeId??e.metadata.id,s=r?.darkThemeId??n.metadata.id;a=r?.availableThemes.find(e=>e.metadata.id===o)??e,i=r?.availableThemes.find(e=>e.metadata.id===s)??n,Cr(a),Cr(i),t[0]=r?.availableThemes,t[1]=r?.darkThemeId,t[2]=r?.lightThemeId,t[3]=i,t[4]=a}else i=t[3],a=t[4];let o;t[5]!==i.metadata.id||t[6]!==a.metadata.id?(o={light:a.metadata.id,dark:i.metadata.id},t[5]=i.metadata.id,t[6]=a.metadata.id,t[7]=o):o=t[7];let s=o,c;return t[8]!==n||t[9]!==s?(c=(0,$.jsx)(na,{renderTheme:s,children:n}),t[8]=n,t[9]=s,t[10]=c):c=t[10],c},ia=e=>{let t=(0,qi.c)(2),n=e===void 0?`unified`:e,r;return t[0]===n?r=t[1]:(r=ta(n),t[0]=n,t[1]=r),r},aa=(e,t)=>{if(!e||typeof e!=`object`)return!1;let n=e;return(n.role===`user`||n.role===`assistant`)&&typeof n.sessionID==`string`&&n.sessionID.length>0&&typeof n.messageID==`string`&&n.messageID.length>0&&typeof n.snippet==`string`&&typeof n.createdAt==`number`&&Number.isFinite(n.createdAt)&&t.length>0},oa=async e=>{let t=e.query.trim();if(!t)return[];let n=await(e.fetch??s)(`/api/yuri/content-search`,{query:{q:t,limit:String(e.limit??30)},signal:e.signal});if(!n.ok)throw Error(`session content search failed (${n.status})`);let r=await n.json();if(!Array.isArray(r?.hits))throw Error(`session content search returned no hits`);return r.hits.flatMap(e=>aa(e,typeof e?.directory==`string`?e.directory:``)?[e]:[])},sa=(e,t)=>{let i=e.trim(),a=t.scope,o=a?.transport??n(),s=a?.generation??r(),c=t.searchContent??oa;return R({queryKey:V.sessionContentSearch.query(i,``,s,o),enabled:i.length>0&&a!==null,queryFn:({signal:e})=>a?c({scope:a,query:i,limit:30,signal:e}):[],staleTime:0,refetchInterval:3e3,retry:1})},ca=(e=s)=>R({queryKey:[n(),`contentSearchStatus`,r()],queryFn:async({signal:t})=>{let n=await e(`/api/yuri/content-search`,{signal:t});if(n.status===404||n.status===501)return null;if(!n.ok)throw Error(`Content index unavailable (${n.status})`);let{index:r}=await n.json();if(!r||![`pending`,`indexing`,`ready`,`partial`,`error`].includes(r.phase)||![r.total,r.completed,r.failed,r.messages].every(e=>Number.isFinite(e)&&e>=0)||r.initializationRequired!==void 0&&typeof r.initializationRequired!=`boolean`||[r.indexStartedAt,r.indexCompletedAt,r.coveredSince,r.verifiedAt,r.updatedAt].some(e=>e!=null&&!Number.isFinite(e)))throw Error(`Invalid content index status`);return r},refetchInterval:3e3,staleTime:0}),la=wr(()=>U(()=>import(`./OnboardingScreen-CgQGvlEs.js`).then(e=>({default:e.OnboardingScreen})),__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])));function ua(){let e=(0,qi.c)(12),[t,n]=Q.useState(!1),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=ca(),e[0]=r):r=e[0];let i=!t,a;e[1]===i?a=e[2]:(a={...r,enabled:i,refetchOnWindowFocus:!1,refetchInterval:da},e[1]=i,e[2]=a);let o=z(a),s=o.data,c=o.isFetchedAfterMount&&!o.isError&&(s===null||s&&(s.initializationRequired===void 0||s.initializationRequired===!1&&s.updatedAt!=null)),l,u;if(e[3]===c?(l=e[4],u=e[5]):(l=()=>{c&&n(!0)},u=[c],e[3]=c,e[4]=l,e[5]=u),Q.useEffect(l,u),t||!s?.initializationRequired||s.total===0)return null;let d;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=e=>{e||n(!0)},e[6]=d):d=e[6];let f;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(f={transform:`none`,transition:`none`,opacity:1},e[7]=f):f=e[7];let p;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>n(!0),e[8]=p):p=e[8];let m;return e[9]!==s||e[10]!==o.isError?(m=(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(qt,{open:!0,onOpenChange:d,children:(0,$.jsx)(Wt,{showCloseButton:!1,className:`h-full max-w-none rounded-none border-0 p-0`,style:f,overlayClassName:`z-[9997]`,containerClassName:`z-[9997] items-stretch p-0`,children:(0,$.jsx)(la,{mode:`content-index`,indexStatus:s,indexStatusError:o.isError,onContinueInBackground:p})})})}),e[9]=s,e[10]=o.isError,e[11]=m):m=e[11],m}function da(e){let t=e.state.data;return t===null||t&&t.initializationRequired===void 0||t?.initializationRequired===!1&&t.updatedAt!=null?!1:3e3}function fa(){let e=(0,qi.c)(4);if(H())return null;let t,n;if(e[0]===Symbol.for(`react.memo_cache_sentinel`)){let r=ca().queryKey;t=ua,n=JSON.stringify(r),e[0]=t,e[1]=n}else t=e[0],n=e[1];let r;return e[2]===n?r=e[3]:(r=(0,$.jsx)(t,{},n),e[2]=n,e[3]=r),r}var pa=wr(()=>U(()=>import(`./SetupTourDialog-CxsiEmUV.js`).then(e=>({default:e.SetupTourDialog})),__vite__mapDeps([31,1,4,3,8,14,32,16,15,2,33,34,35,19,5,6,20,10,11,12,21,22,23,24,36,37,38,39,13,9,17,18,40,41,42,43,44,45,46,47,48,25,26,27,29,30,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,28,65,66,67,68])));function ma(e){let t=(0,qi.c)(29),{runtime:n,autoStart:r}=e,i;t[0]===n?i=t[1]:(i=e=>e.openedRuntime===n,t[0]=n,t[1]=i);let a=wi(i),o;t[2]===n?o=t[3]:(o=e=>e.progress[n],t[2]=n,t[3]=o);let s=wi(o),c=D(_a),l=D(ga),u=Ye(ha),[d,f]=Q.useState(!1),p,m;t[4]===n?(p=t[5],m=t[6]):(p=()=>{let e=!0;return Promise.resolve(Zt(n)).then(t=>{e&&t!==!1&&f(!0)}),()=>{e=!1}},m=[n],t[4]=n,t[5]=p,t[6]=m),Q.useEffect(p,m);let h=r&&d&&c&&u&&!s,g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(g=ut(),t[7]=g):g=t[7];let _;t[8]===h?_=t[9]:(_={...g,enabled:h},t[8]=h,t[9]=_);let v=z(_),y,b;if(t[10]!==r||t[11]!==d||t[12]!==u||t[13]!==a||t[14]!==s||t[15]!==v.data||t[16]!==v.isError||t[17]!==v.isFetchedAfterMount||t[18]!==v.isSuccess||t[19]!==c||t[20]!==n?(y=()=>{if(!r||!d||!c||!u||a||s?.dismissed)return;let e=wi.getState();if(s){e.open(n);return}!v.isSuccess||v.isError||!v.isFetchedAfterMount||(v.data.projects?.length?e.dismiss(n):e.open(n))},b=[r,d,c,u,n,a,s,v.isSuccess,v.isError,v.isFetchedAfterMount,v.data],t[10]=r,t[11]=d,t[12]=u,t[13]=a,t[14]=s,t[15]=v.data,t[16]=v.isError,t[17]=v.isFetchedAfterMount,t[18]=v.isSuccess,t[19]=c,t[20]=n,t[21]=y,t[22]=b):(y=t[21],b=t[22]),Q.useEffect(y,b),!a)return null;let x;t[23]===n?x=t[24]:(x=()=>wi.getState().dismiss(n),t[23]=n,t[24]=x);let S;return t[25]!==l||t[26]!==n||t[27]!==x?(S=(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(pa,{runtime:n,onClose:x},l)}),t[25]=l,t[26]=n,t[27]=x,t[28]=S):S=t[28],S}function ha(e){return e.isInitialized}function ga(e){return e.currentDirectory}function _a(e){return e.isHomeReady}function va(e){let i=(0,qi.c)(5),{autoStart:o}=e,s=o===void 0||o,c=H(),l=Q.useSyncExternalStore(t,a,a),u=Q.useSyncExternalStore(t,r,r);if(c)return null;let d;i[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=n(),i[0]=d):d=i[0];let f=`${l}:${u}:${d}`,p;return i[1]!==s||i[2]!==l||i[3]!==f?(p=(0,$.jsx)(ma,{runtime:l,autoStart:s},f),i[1]=s,i[2]=l,i[3]=f,i[4]=p):p=i[4],p}var ya={},ba=[],xa=(e,t)=>{if(!e)return t(`mcpDropdown.status.unknown`);switch(e.status){case`connected`:return t(`mcpDropdown.status.connected`);case`failed`:return t(`mcpDropdown.status.failed`,{error:e.error||t(`mcpDropdown.status.unknownError`)});case`needs_auth`:return t(`mcpDropdown.status.needsAuth`);case`needs_client_registration`:return t(`mcpDropdown.status.needsRegistration`,{error:e.error||``});default:return e.status}},Sa=e=>{switch(e?.status){case`connected`:return`success`;case`failed`:return`error`;case`needs_auth`:case`needs_client_registration`:return`warning`;default:return`default`}},Ca=({active:e,className:t,headerAction:n,listClassName:r,hideHeader:i=!1,mobileListDensity:a=!1})=>{let{t:o}=be(),s=D(e=>e.currentDirectory)??null,c=yi(e=>e.connect),l=yi(e=>e.disconnect),{data:u,refetch:d,isError:f,error:p}=Ei(s,{enabled:e}),{data:m}=Ti(s,{enabled:e}),h=u??ya,g=m??ba,[_,v]=Q.useState(!1),[y,b]=Q.useState(null),x=Q.useMemo(()=>{let e=new Set(Object.keys(h));for(let t of g)t?.name&&e.add(t.name);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[g,h]),S=Q.useCallback(e=>{if(e?.preventDefault(),_)return;v(!0);let t=new Promise(e=>setTimeout(e,500));Promise.all([d(),t]).finally(()=>{v(!1)})},[_,d]);return(0,$.jsxs)(`div`,{className:Y(`w-full`,t),children:[i?null:(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-2.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex items-baseline gap-2`,children:[(0,$.jsx)(`div`,{className:`typography-ui-header font-semibold text-foreground`,children:o(`mcpDropdown.title`)}),s&&(0,$.jsx)(`div`,{className:`truncate typography-micro text-muted-foreground`,children:s.split(`/`).pop()||s})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[n,(0,$.jsx)(`button`,{type:`button`,className:`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`,disabled:_,onClick:S,"aria-label":o(`mcpDropdown.actions.refreshAria`),children:(0,$.jsx)(Z,{name:`refresh`,className:Y(`h-4 w-4`,_&&`animate-spin`)})})]})]})}),(0,$.jsx)(`div`,{className:Y(`max-h-64 overflow-y-auto`,a?`space-y-1 py-3`:`px-3 py-2.5`,r),children:(0,$.jsxs)(`div`,{className:Y(!a&&x.length>0&&`rounded-xl bg-[var(--surface-muted)] p-1.5`),children:[x.map(e=>{let t=h[e]??(f&&!u&&g.some(t=>t.name===e)?{status:`failed`,error:p.message}:void 0),n=Sa(t),r=t?.status===`connected`,i=y===e,d=xa(t,o);return(0,$.jsxs)(`div`,{className:Y(`flex items-center justify-between rounded-lg hover:bg-interactive-hover/50`,a?`gap-3 px-4 py-3`:`gap-2 px-2.5 py-2`),children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsxs)(An,{children:[(0,$.jsx)(On,{asChild:!0,children:(0,$.jsx)(`span`,{className:Y(`rounded-full flex-shrink-0`,a?`h-2.5 w-2.5`:`h-2 w-2`,n===`success`&&`bg-status-success`,n===`error`&&`bg-status-error`,n===`warning`&&`bg-status-warning`,n==="default"&&`bg-muted-foreground/40`),"aria-label":d})}),(0,$.jsx)(kn,{side:`left`,children:(0,$.jsx)(`p`,{children:d})})]}),(0,$.jsx)(`span`,{className:Y(`truncate`,a?`text-[17px] leading-6 font-medium`:`typography-ui-label`),children:e})]})}),(0,$.jsx)(gi,{checked:r,disabled:i,className:`data-[checked]:bg-status-info`,onCheckedChange:async t=>{b(e);try{t?await c(e,s):await l(e,s)}finally{b(null)}}})]},e)}),x.length===0&&(0,$.jsx)(`div`,{className:`px-4 py-5 typography-ui-label text-muted-foreground text-center`,children:o(`mcpDropdown.empty.configureInConfig`)})]})})]})},wa=e=>!(e.dismissed===`true`||e.sessionShown===`true`||e.hasActiveToast),Ta=e=>!(!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),Ea=e=>{if(typeof e!=`object`||!e)return``;let t=e.version;return typeof t==`string`?t.trim():``},Da=e=>{if(!e||e.available!==!0||e.canManage===!1)return``;let t=typeof e.latestVersion==`string`?e.latestVersion:typeof e.targetVersion==`string`?e.targetVersion:``;return t?t.trim():``},Oa=e=>{let t=e.trim().replace(/^v/i,``);return t?{target:t}:null},ka=5e3,Aa={setTimeout:(e,t)=>globalThis.setTimeout(e,t),clearTimeout:e=>globalThis.clearTimeout(e)};function ja(e,t,n=Aa){if(!e)return()=>void 0;let r=n.setTimeout(()=>{t().catch(()=>void 0)},ka);return()=>n.clearTimeout(r)}var Ma=(e,t)=>({queryKey:[e,`opencode-update`,t],queryFn:async({signal:i})=>{let a=()=>e===n()&&t===r();if(!a())throw Error(`Stale OpenCode update check`);let o=await s(`/api/opencode/upgrade-status`,{headers:{Accept:`application/json`},signal:i});if(!o.ok)throw Error(`OpenCode update check failed`);let c=await o.json();if(i.aborted||!a())throw Error(`Stale OpenCode update check`);if(!c||typeof c!=`object`||Array.isArray(c))throw Error(`Invalid OpenCode update status`);return c},staleTime:3e4,refetchInterval:3e5,refetchOnWindowFocus:!0,refetchOnReconnect:!0,retry:1}),Na=`opencode-update-available`,Pa=`opencode-upgrade-progress`,Fa=`opencode-update-toast-dismissed-version`,Ia=()=>{let{t:e}=be(),i=j(e=>e.showOpenCodeUpdateNotifications),a=Q.useRef(new Set),o=Q.useRef(!1),c=Q.useSyncExternalStore(t,n,n),l=Q.useSyncExternalStore(t,r,r),u=I(),[d,f]=Q.useState(!1);Q.useEffect(()=>ja(i,async()=>{f(!0)}),[i]);let p=z({...Ma(c,l),enabled:i&&d});he(`yuri:opencode-update-available`,e=>{i&&Ea(e.detail)&&p.refetch()});let m=`${Fa}:${c}`;Q.useEffect(()=>{a.current.clear(),yt.dismiss(Na),yt.dismiss(Pa)},[c,l]),Q.useEffect(()=>{i||yt.dismiss(Na)},[i]);let h=J(async(t,i=!1)=>{if(o.current)return;o.current=!0;let a=()=>c===n()&&l===r();yt.dismiss(Na),yt.message(e(`opencodeUpdate.toast.upgrading.title`),{id:Pa,description:e(`opencodeUpdate.toast.upgrading.description`),duration:1/0,icon:(0,$.jsx)(Z,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})});try{let n=Oa(t);if(!n)throw Error(e(`opencodeUpdate.toast.failed.description`));let r=await s(`/api/opencode/upgrade`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({...n,confirmActiveTasks:i})}),o=await r.json().catch(()=>null);if(!a())return;if(o?.errorCode===`UPGRADE_ACTIVE_TASKS`){yt.error(e(`opencodeUpdate.toast.failed.title`),{id:Pa,description:o.error,duration:1/0,action:{label:e(`opencodeUpdate.toast.actions.update`),onClick:()=>{a()&&h(t,!0)}}});return}if(!r.ok||o?.success!==!0)throw Error(o?.error||r.statusText||e(`opencodeUpdate.toast.failed.description`));yt.success(e(`opencodeUpdate.toast.updated.title`),{id:Pa,description:o?.version?e(`opencodeUpdate.toast.updated.descriptionWithVersion`,{version:o.version}):e(`opencodeUpdate.toast.updated.description`),duration:1/0,icon:(0,$.jsx)(Z,{name:`check`,className:`h-4 w-4 text-[var(--status-success)]`})}),u.invalidateQueries({queryKey:[c,`opencode-update`,l]}),u.invalidateQueries({queryKey:[c,`about`,l]})}catch(n){if(!a())return;yt.error(e(`opencodeUpdate.toast.failed.title`),{id:Pa,description:n instanceof Error?n.message:e(`opencodeUpdate.toast.failed.description`),duration:1/0,action:{label:e(`opencodeUpdate.toast.actions.update`),onClick:()=>{a()&&h(t)}}})}finally{o.current=!1}});return Q.useEffect(()=>{let t=t=>{if(!j.getState().showOpenCodeUpdateNotifications){yt.dismiss(Na);return}Ta({version:t,dismissedVersion:k().getItem(m),seenVersions:a.current})&&(a.current.add(t),yt.info(e(`opencodeUpdate.toast.available.title`),{id:Na,description:e(`opencodeUpdate.toast.available.description`,{version:t}),duration:1/0,action:{label:e(`opencodeUpdate.toast.actions.update`),onClick:()=>{c===n()&&l===r()&&h(t)}},cancel:{label:e(`opencodeUpdate.toast.actions.dismiss`),onClick:()=>{k().setItem(m,t),yt.dismiss(Na)}}}))},i=Da(p.data);i?t(i):(p.data?.available===!1||p.data?.canManage===!1)&&yt.dismiss(Na)},[i,e,p.data,m,c,l,h]),null},La=`plugin-load-issue`,Ra=()=>{let e=(0,qi.c)(10),{t}=be(),n=vi(),r=mr(),i=Q.useRef(``),a;e[0]===r?a=e[1]:(a=e=>{if(Di.getState().setSelected(e),r){r.openSettings(`plugins`);return}let t=j.getState();t.setSettingsPage(`plugins`),t.setSettingsDialogOpen(!0)},e[0]=r,e[1]=a);let o=J(a),s;e[2]===n?s=e[3]:(s=n.map(za).join(``),e[2]=n,e[3]=s);let c=s,l,u;return e[4]!==n||e[5]!==o||e[6]!==c||e[7]!==t?(l=()=>{if(c===i.current)return;if(i.current=c,n.length===0){yt.dismiss(La);return}let[e]=n;yt.message(n.length===1?t(`settings.plugins.issue.toast`,{name:e.label}):t(`settings.plugins.issue.toastMany`,{count:n.length}),{id:La,action:{label:t(`settings.plugins.issue.view`),onClick:()=>o(e.id)}})},u=[n,o,c,t],e[4]=n,e[5]=o,e[6]=c,e[7]=t,e[8]=l,e[9]=u):(l=e[8],u=e[9]),Q.useEffect(l,u),null};function za(e){return`${e.id}\u0000${e.error}`}var Ba=()=>{let e=(0,qi.c)(3),[t,n]=Q.useState(Va),{isUpdating:r}=t,i,a;if(e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>kt(n),a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),Q.useEffect(i,a),!r)return null;let o;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center bg-background/90`,children:(0,$.jsx)(Jn,{width:80,height:80,isAnimated:!0})}),e[2]=o):o=e[2],o};function Va(){return Ot()}function Ha({query:e,onSelect:t}){let{host:n,snapshot:r}=Dr(),{t:i}=be(),[a,o]=Q.useState(null),s=Q.useMemo(()=>e.trim()?Pt([...r.commands],e.trim(),e=>`${e.title} ${e.description??``}`,{threshold:.4}).map(({item:e})=>e):r.commands,[r.commands,e]);if(!s.length)return null;let c=a===e?s:s.slice(0,5),l=async e=>{t();try{await n?.runCommand(e)}catch(e){yt.error(e instanceof Error?e.message:i(`guiPlugins.error`))}};return(0,$.jsxs)(on,{heading:(0,$.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,$.jsx)(`span`,{children:i(`guiPlugins.commands`)}),(0,$.jsx)(`span`,{className:`yuri-global-search-group-count`,children:s.length})]}),children:[c.map(e=>(0,$.jsxs)(un,{value:`gui-plugin:${e.key}`,className:`yuri-global-search-compact min-h-9 gap-4 rounded-lg px-3 py-2 typography-meta`,onSelect:()=>void l(e.key),children:[(0,$.jsx)(`span`,{className:`yuri-global-search-result-title min-w-0 flex-1 truncate`,children:e.title}),e.description?(0,$.jsx)(`span`,{className:`yuri-global-search-result-detail max-w-[50%] truncate text-muted-foreground`,children:e.description}):null]},e.key)),c.length<s.length?(0,$.jsx)(un,{value:`gui-plugin:show-more`,onSelect:()=>o(e),children:i(`commandPalette.group.showMore`,{count:s.length-c.length})}):null]})}var Ua=5e3,Wa=(e,t)=>{if(!e)return 1;let n=1;for(let r=0;r<e.length;r+=1)if(e.charCodeAt(r)===10&&(n+=1,n>t))return n;return n},Ga=(e,t)=>Ee(Te.getState().dictionary,e,t),Ka=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`file not found`)||t.includes(`not found`)||t.includes(`enoent`)||t.includes(`no such file`)||t.includes(`does not exist`)?`missing`:`unreadable`},qa=async(e,t)=>{if(e.readFile){let n=await e.readFile(t,{optional:!0});if(typeof n.exists!=`boolean`)throw Error(`Optional file read requires an existence response header`);return{content:n.content??``,exists:n.exists}}let n=new URLSearchParams({path:t,optional:`true`}),r=await s(`/api/fs/read?${n.toString()}`,{cache:`no-store`});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to read file`)}let i=r.headers.get(`x-yuri-file-exists`);if(i!==`true`&&i!==`false`)throw Error(`Optional file read requires an existence response header`);return{content:await r.text(),exists:i===`true`}},Ja=async(e,t)=>{try{let{content:n,exists:r}=await qa(e,t);return r?Wa(n,5e3)>5e3?{ok:!1,reason:`too-large`}:{ok:!0}:{ok:!1,reason:`missing`}}catch(e){return{ok:!1,reason:Ka(e)}}},Ya=e=>e===`too-large`?Ga(`contextFileOpen.failure.tooLarge`,{count:Ua.toLocaleString(Ce())}):Ga(e===`missing`?`contextFileOpen.failure.missing`:`contextFileOpen.failure.unreadable`),Xa=(e,t)=>{let n=W(e);return!n||t.length===0?``:JSON.stringify([n,t])},Za=(e,t,n,r)=>({queryKey:[r.transport,`session-file-search`,r.generation,Xa(t,n)],staleTime:3e4,gcTime:6e4,retry:!1,queryFn:async({signal:r})=>{let i=W(t);if(!i||!n.trim())return[];r.throwIfAborted();let a=await e.search({directory:i,query:n,maxResults:10},{signal:r});r.throwIfAborted();let o=new Map;for(let e of a.slice(0,10)){let t=W(e.path);if(!t)continue;let n=t.split(`/`).pop()||t;o.has(t)||o.set(t,{path:t,name:n,directory:i})}return[...o.values()].sort((e,t)=>e.path.localeCompare(t.path))}}),Qa=(e,t)=>!t||e.length===0?[]:Pt(e,t,e=>e.name,{limit:10,threshold:.4}),$a=(e,t={})=>{let r=e.trim(),i=t.transport??n(),a=t.searchSessions??(e=>E.searchSessionsByTitle(e));return R({queryKey:V.sessionTitleSearch.query(r,i),enabled:r.length>0,queryFn:({signal:e})=>a({search:r,limit:30,signal:e}),staleTime:5e3,retry:1})},eo=e=>{let t=(0,qi.c)(13),{title:n,description:r,trailing:i}=e,a=r?`yuri-global-search-result-title min-w-0 max-w-[62%] shrink-0 truncate text-foreground`:`yuri-global-search-result-title min-w-0 flex-1 truncate text-foreground`,o;t[0]!==a||t[1]!==n?(o=(0,$.jsx)(`span`,{className:a,children:n}),t[0]=a,t[1]=n,t[2]=o):o=t[2];let s;t[3]===r?s=t[4]:(s=r?(0,$.jsx)(`span`,{className:`yuri-global-search-result-detail min-w-0 flex-1 truncate text-muted-foreground/65`,children:r}):null,t[3]=r,t[4]=s);let c;t[5]!==o||t[6]!==s?(c=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-baseline gap-4`,children:[o,s]}),t[5]=o,t[6]=s,t[7]=c):c=t[7];let l;t[8]===i?l=t[9]:(l=i?(0,$.jsx)(`div`,{className:`ml-auto flex shrink-0 items-center pl-2 text-muted-foreground/50`,children:i}):null,t[8]=i,t[9]=l);let u;return t[10]!==c||t[11]!==l?(u=(0,$.jsxs)($.Fragment,{children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12],u},to=`yuri-global-search-compact`,no=(e,t)=>(0,$.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,$.jsx)(`span`,{children:e}),(0,$.jsx)(`span`,{className:`yuri-global-search-group-count`,children:t})]}),ro=`rounded-[3px] bg-[color-mix(in_srgb,var(--primary-base)_28%,transparent)] font-[inherit] text-foreground`;function io(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);if(!n.length||!e)return e;let r=n.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)),i=RegExp(`(${r.join(`|`)})`,`gi`);return e.split(i).map((e,t)=>n.includes(e.toLowerCase())?(0,$.jsx)(`mark`,{className:ro,children:e},t):(0,$.jsx)(`span`,{children:e},t))}var ao=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},oo=[],so=Q.memo(function({presentation:e=`dialog`,onBack:t}){let{t:i,locale:o}=be(),s=I(),c=new Intl.DateTimeFormat(o,{dateStyle:`short`,timeStyle:`short`}),l=mr(),u=j(e=>e.isCommandPaletteOpen),[f,p]=Q.useState(u),m=j(e=>e.setCommandPaletteOpen),h=j(e=>e.setActiveMainTab),b=j(e=>e.setSettingsDialogOpen),x=j(e=>e.setSettingsPage),S=j(e=>e.setSessionSwitcherOpen),C=j(e=>e.toggleSidebar),w=j(e=>e.toggleContextPanel),T=j(e=>e.toggleBottomTerminal),E=j(e=>e.openContextOverview),O=j(e=>e.openContextFile),k=j(e=>e.shortcutOverrides),A=bt(e=>e.openNewSessionDraft),M=bt(e=>e.setCurrentSession),N=u||f,ee=bt(e=>N?e.currentSessionId:null),P=bt(e=>N?e.currentSessionDirectory:null),F=Ze(e=>N?e.activeSessions:oo),L=Ze(e=>N?e.status:`idle`),R=D(e=>e.currentDirectory),te=ct(e=>e.getActiveProject()),B=ct(e=>e.projects),V=jr(),{files:H}=ne(),{isMobile:re}=Yn(),U=e===`page`||re,W=Se(),ie=Q.useRef(null),ae=Q.useRef(null),oe=J(()=>{if(!U||!u||!ie.current)return;let e=window.visualViewport;ie.current.style.setProperty(`--search-viewport-height`,`${e?.height??window.innerHeight}px`),ie.current.style.setProperty(`--search-viewport-top`,`${e?.offsetTop??0}px`)});he(`resize`,oe,()=>U&&u?window.visualViewport??window:null),he(`scroll`,oe,()=>U&&u?window.visualViewport:null),Q.useEffect(()=>{oe()},[U,u]),Q.useEffect(()=>{e===`page`&&u&&ae.current?.focus({preventScroll:!0})},[e,u]);let[G,K]=Q.useState(``),[se,ce]=Q.useState({query:``,groups:[]}),q=vn(G,200).trim(),le=G.trim();Q.useEffect(()=>{u&&(K(``),ce({query:``,groups:[]}),p(!0))},[u]);let ue=J(()=>m(!1)),de=J(e=>()=>{ue(),e()}),fe=Q.useMemo(()=>{let e=[{id:`new-session`,title:i(`commandPalette.item.newSession`),shortcutId:`new_chat`,searchText:i(`commandPalette.item.newSession`),onSelect:de(()=>{h(`chat`),S(!1),A()})},{id:`new-worktree`,title:i(`commandPalette.item.newWorktreeDraft`),shortcutId:`new_chat_worktree`,searchText:i(`commandPalette.item.newWorktreeDraft`),onSelect:de(()=>{rn()})},{id:`add-project`,title:i(`commandPalette.item.addProject`),searchText:i(`commandPalette.item.addProject`),onSelect:de(()=>{Et.requestDirectoryDialog()})},{id:`toggle-sidebar`,title:i(U?`commandPalette.item.showSessionSwitcher`:`commandPalette.item.toggleSidebar`),shortcutId:`toggle_sidebar`,searchText:i(U?`commandPalette.item.showSessionSwitcher`:`commandPalette.item.toggleSidebar`),onSelect:de(()=>{if(U){let{isSessionSwitcherOpen:e}=j.getState();S(!e)}else C()})},{id:`toggle-right-sidebar`,title:i(`commandPalette.item.toggleRightSidebar`),shortcutId:`toggle_right_sidebar`,searchText:i(`commandPalette.item.toggleRightSidebar`),onSelect:de(()=>{V&&w(V)})},{id:`toggle-terminal`,title:i(`commandPalette.item.toggleTerminal`),shortcutId:`toggle_terminal`,searchText:i(`commandPalette.item.toggleTerminal`),onSelect:de(()=>T())},{id:`new-terminal-tab`,title:i(`commandPalette.item.newTerminalTab`),shortcutId:`open_new_terminal`,searchText:i(`commandPalette.item.newTerminalTab`),onSelect:de(()=>{V&&ln(V)})},{id:`context-usage`,title:i(`commandPalette.item.showContextUsage`),searchText:i(`commandPalette.item.showContextUsage`),onSelect:de(()=>{R&&E(R)})},{id:`open-settings`,title:i(`commandPalette.item.openSettings`),shortcutId:`open_settings`,searchText:i(`commandPalette.item.openSettings`),onSelect:de(()=>b(!0))}];return v()||e.push({id:`setup-tour`,title:i(`tour.open`),searchText:i(`tour.open`),onSelect:de(()=>{b(!1),wi.getState().open(a())})}),g()&&e.splice(1,0,{id:`new-mini-chat`,title:i(`commandPalette.item.newMiniChat`),shortcutId:`new_mini_chat`,searchText:i(`commandPalette.item.newMiniChat`),onSelect:de(()=>{_(`desktop_open_draft_mini_chat_window`,{directory:ao(R||te?.path||``),projectId:te?.id??null}).catch(e=>{console.warn(`[command-palette] failed to open draft mini chat window`,e)})})}),e},[i,de,U,h,S,A,C,w,T,R,V,E,b,te?.id,te?.path]),pe=Q.useMemo(()=>{let e=y();return{isVSCode:v(),isWeb:!e&&d(),isDesktop:e,isMobile:U}},[U]),me=Q.useMemo(()=>tr.filter(e=>e.slug!==`home`).filter(e=>!e.isAvailable||e.isAvailable(pe)).map(e=>{let t=(e.keywords??[]).join(` `);return{id:`settings:${e.slug}`,title:e.title,searchText:`${e.title} ${e.group} ${t}`,onSelect:de(()=>{x(e.slug),b(!0)})}}),[pe,de,x,b]),ge=Q.useMemo(()=>{let e=e=>(typeof e.time?.updated==`number`?e.time.updated:0)||(typeof e.time?.created==`number`?e.time.created:0);return[...F].sort((t,n)=>e(n)-e(t))},[F]),_e=bt(e=>e.worktreeMetadata),ve=bt(e=>e.availableWorktreesByProject),ye=Q.useMemo(()=>ee&&P&&ht(B,ve,P)?ao(P):null,[ee,P,B,ve]),xe=n(),Ce=r(),Y=Q.useMemo(()=>({transport:xe,generation:Ce,directory:``}),[xe,Ce]),X=Q.useMemo(()=>Za(H,ye,q,Y),[H,ye,q,Y]),Te=le.length>0,Ee=Q.useMemo(()=>Te?Pt(fe,le,e=>e.searchText,{limit:7,noFuzzy:!0}):fe.map(e=>({item:e,score:0})),[fe,le,Te]),De=Q.useMemo(()=>Te?Pt(me,le,e=>e.searchText,{limit:7,noFuzzy:!0}):[],[me,le,Te]),Oe=u&&le===q,ke=Q.useMemo(()=>$a(q,{transport:xe}),[q,xe]),Ae=z({...ke,enabled:Oe&&(q.length>0||e===`page`)}),je=JSON.stringify([Y.transport,Y.generation,le,u]),[Ne,Pe]=Q.useState(null),Fe=Ne?.key===je?Ne:null;Ne&&!Fe&&Pe(null);let Ie=Q.useMemo(()=>sa(q,{scope:Y}),[q,Y]),Le=z({...Ie,enabled:Oe&&q.length>0}),Re=z({...X,enabled:Oe&&q.length>0&&ye!==null&&!Ae.isPending&&!Le.isPending});Q.useEffect(()=>{if(!Oe)for(let e of[ke.queryKey,Ie.queryKey,X.queryKey])s.cancelQueries({queryKey:e,exact:!0})},[s,Oe,ke,Ie,X]);let ze=Q.useMemo(()=>Fe?.hits??Le.data??[],[Fe,Le.data]),Be=Te&&le===q&&Le.isError,Ve=Te&&le===q&&Ae.isSuccess,He=(Te||e===`page`)&&le===q&&Ae.isError,Ue=Q.useMemo(()=>He?Pt(ge,le,e=>e.title||``,{limit:30,threshold:.2}).map(({item:e})=>e):[],[He,ge,le]),We=Q.useMemo(()=>Fe?Fe.sessions:Te?Ve?Ae.data??[]:He?Ue:[]:e===`page`&&!q&&Ae.isSuccess?Ae.data:ge.slice(0,e===`page`?30:9),[Te,ge,Ve,He,Ue,Ae.data,Ae.isSuccess,e,q,Fe]),Ge=Q.useMemo(()=>!u&&!f||le!==q?[]:Qa(Re.data??[],q),[u,f,Re.data,q,le]),Ke=Q.useMemo(()=>{if(!Te)return[];let e=B.map(e=>({...e,displayName:e.label||e.path.split(`/`).pop()||e.path,searchText:`${e.label||``} ${e.path}`}));return Pt(e,le,e=>e.searchText,{limit:7,threshold:.4})},[B,le,Te]),qe=JSON.stringify([Y.transport,Y.generation,le]),Je=se.query===qe?se.groups:[],Ye=(e,t)=>Te&&!Je.includes(e)?t.slice(0,5):t,Xe=Ye(`commands`,Ee.map(e=>e.item)),Qe=Ye(`settings`,De.map(e=>e.item)),$e=Q.useMemo(()=>{let e=new Map;for(let t of ze){let n=e.get(t.sessionID);(!n||t.createdAt>n.createdAt||t.createdAt===n.createdAt&&t.messageID>n.messageID)&&e.set(t.sessionID,t)}let t=[],n=new Map(F.map(e=>[e.id,e]));for(let n of We)t.push({session:n,hit:e.get(n.id)}),e.delete(n.id);for(let r of e.values())t.push({session:n.get(r.sessionID)??{id:r.sessionID,title:r.title??``,directory:r.directory,location:{directory:r.directory}},hit:r});return t},[We,ze,F]),et=Ye(`sessions`,$e),tt=Te?Ye(`files`,Ge.map(e=>e.item)):[],nt=Te?Ye(`projects`,Ke.map(e=>e.item)):[],rt=(e,t,n)=>t>n?(0,$.jsx)(un,{value:`more:${e}`,onSelect:()=>ce({query:qe,groups:[...Je,e]}),className:`${to} text-muted-foreground`,children:i(`commandPalette.group.showMore`,{count:t-n})}):null,it=Q.useMemo(()=>{if(!Te)return[`sessions`,`commands`];let e=e=>e.length?e[0].score:1/0,t=[{key:`commands`,score:e(Ee)},{key:`settings`,score:e(De)},{key:`files`,score:e(Ge)},{key:`projects`,score:e(Ke)}];return t.sort((e,t)=>e.score-t.score),[`sessions`,...t.map(e=>e.key)]},[Te,Ee,De,Ge,Ke]),at=J((e,t)=>{ue(),h(`chat`),S(!1);let n=ot(e)||``;l?St.getState().openSession({sessionId:e.id,directory:n}):M(e.id,n),t&&Xt(t)}),st=J(e=>{let t=ge.find(t=>t.id===e.sessionID)??We.find(t=>t.id===e.sessionID)??{id:e.sessionID,title:e.title??``,directory:e.directory,location:{directory:e.directory}};at(t,e.messageID)}),lt=J(async e=>{let t=Re.data?.find(t=>t.path===e);if(!t)return;let i=n(),a=r(),o=await Ja(H,e);if(i===n()&&a===r()){if(!o.ok){yt.error(Ya(o.reason));return}l?l.openFile({path:e}):O(t.directory,e),ue()}}),ut=J((e,t)=>{ue();let n={selectedProjectId:e,directoryOverride:t};l?St.getState().openDraft(n):A(n)}),dt=e=>Un(Ln(e,k)),ft=e=>!wt&&(e.key===`Enter`||e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),e.stopPropagation(),!0),pt=J(e=>{if(ft(e)||(!Fe&&!e.nativeEvent.isComposing&&[`ArrowDown`,`ArrowUp`,`Enter`].includes(e.key)&&Pe({key:je,hits:ze,sessions:We}),U||e.nativeEvent.isComposing||e.altKey||e.shiftKey)||(W?!e.metaKey||e.ctrlKey:!e.ctrlKey||e.metaKey)||!/^[1-9]$/.test(e.key)||(e.preventDefault(),e.stopPropagation(),e.repeat||!wt))return;let t=et[Number(e.key)-1];t?.hit?st(t.hit):t&&at(t.session)}),mt=e=>{let t=ao(_e.get(e.id)?.projectDirectory||ot(e)||``),n=ht(B,ve,t);return n?.label||(n?.path||t).split(`/`).pop()||``},gt=Te&&le===q&&Re.isError,_t=Te&&le===q&&Re.isFetching&&!Re.isSuccess,vt=Te&&(le!==q||Ae.isFetching&&!Ae.isSuccess||Y!==null&&Le.isFetching&&!Le.isSuccess),[xt,Ct]=Q.useState(q);!vt&&xt!==q&&Ct(q);let wt=!Te||xt===q&&!vt,Tt=(0,$.jsx)(tn,{ref:ae,variant:U?`mobileGlass`:`default`,className:`font-normal`,"aria-label":i(`commandPalette.title`),inputMode:`search`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,value:G,onValueChange:e=>{Pe(null),K(e),ce({query:``,groups:[]})},placeholder:i(`commandPalette.input.placeholder`)}),Dt=(0,$.jsxs)(cn,{loop:!0,shouldFilter:!1,style:{"--yuri-search-shortcut-width":W?`1.75rem`:`3rem`},onKeyDownCapture:pt,onPointerDownCapture:e=>{let t=e.target.closest(`[cmdk-item]`);U&&t&&sr({currentTarget:t})},onPointerCancelCapture:e=>{let t=e.target.closest(`[cmdk-item]`);U&&t&&lr({currentTarget:t,detail:1})},onClickCapture:e=>{let t=e.target.closest(`[cmdk-item]`);U&&t&&e.detail>0&&!lr({currentTarget:t,detail:e.detail})&&(e.preventDefault(),e.stopPropagation())},className:`max-h-full min-h-0 rounded-[inherit] bg-transparent [&_[cmdk-group]]:px-0 [&_[cmdk-item][data-selected=true]]:!bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)] [&_[cmdk-item]:hover]:!bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)]`,children:[U?(0,$.jsx)(Me,{title:Tt,backAriaLabel:i(`header.actions.backAria`),onBack:t??ue}):Tt,(0,$.jsxs)(pn,{"aria-label":i(`commandPalette.title`),className:`yuri-global-search-results overscroll-contain`,children:[wt&&!_t&&!gt&&!He&&!Be&&L!==`loading`&&L!==`error`?(0,$.jsx)(fn,{className:`py-10 text-center typography-meta text-muted-foreground`,children:i(`commandPalette.empty.noResults`)}):null,u&&wt?(0,$.jsx)(Ha,{query:le,onSelect:ue}):null,wt?it.map(e=>e===`commands`&&Xe.length>0?(0,$.jsxs)(on,{heading:no(i(`settings.page.commands.title`),Ee.length),children:[Xe.map(e=>(0,$.jsx)(un,{value:e.id,onSelect:e.onSelect,className:to,children:(0,$.jsx)(eo,{title:io(e.title,le),trailing:!U&&e.shortcutId?(0,$.jsx)(mn,{variant:`hint`,children:dt(e.shortcutId)}):void 0})},e.id)),rt(`commands`,Ee.length,Xe.length)]},`commands`):e===`settings`&&Qe.length>0?(0,$.jsxs)(on,{heading:no(i(`settings.view.home.title`),De.length),children:[Qe.map(e=>(0,$.jsx)(un,{value:e.id,onSelect:e.onSelect,className:to,children:(0,$.jsx)(eo,{title:io(e.title,le)})},e.id)),rt(`settings`,De.length,Qe.length)]},`settings`):e===`sessions`&&et.length>0?(0,$.jsxs)(on,{heading:no(i(`layout.mainTab.chat`),$e.length),children:[et.map(({session:e,hit:t},n)=>{let r=t?.title||e.title||i(`commandPalette.session.untitled`),a=mt(e),s=t?.createdAt??e.time?.updated??e.time?.created,l=new Date(s??NaN),u=Number.isFinite(l.getTime());return(0,$.jsxs)(un,{value:t?`message:${e.id}:${t.messageID}`:`session:${e.id}`,onSelect:()=>t?st(t):at(e),className:`yuri-global-search-session`,"aria-keyshortcuts":!U&&n<9?`${W?`Meta`:`Control`}+${n+1}`:void 0,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`yuri-global-search-session-heading`,children:[(0,$.jsx)(`span`,{className:`yuri-global-search-session-title min-w-0 truncate text-foreground`,title:r,children:io(r,le)}),u?(0,$.jsx)(`time`,{dateTime:l.toISOString(),title:l.toLocaleString(o),className:`yuri-global-search-session-time shrink-0 whitespace-nowrap text-muted-foreground`,children:c.format(l)}):null]}),t?(0,$.jsxs)(`span`,{className:`yuri-global-search-session-excerpt text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`yuri-global-search-session-speaker`,children:[i(t.role===`user`?`commandPalette.message.user`:`commandPalette.message.assistant`),`: `]}),io(t.snippet.replace(/\s+/g,` `),le)]}):null]}),(0,$.jsx)(`span`,{className:`yuri-global-search-session-project min-w-0 truncate text-muted-foreground`,title:a,children:a}),!U&&n<9?(0,$.jsxs)(mn,{variant:`hint`,className:`yuri-global-search-session-shortcut justify-self-end`,children:[W?`⌘`:`Ctrl+`,n+1]}):null]},t?`message:${e.id}:${t.messageID}`:`session:${e.id}`)}),rt(`sessions`,$e.length,et.length)]},`sessions`):e===`files`&&tt.length>0?(0,$.jsxs)(on,{heading:no(i(`layout.mainTab.files`),Ge.length),children:[tt.map(e=>{let t=we(e.path,{maxLength:80});return(0,$.jsx)(un,{value:`file:${e.path}`,onSelect:()=>{lt(e.path)},className:to,children:(0,$.jsx)(eo,{title:io(e.name,le),description:t===e.name?void 0:io(t,le)})},`file:${e.path}`)}),rt(`files`,Ge.length,tt.length)]},`files`):e===`projects`&&nt.length>0?(0,$.jsxs)(on,{heading:no(i(`sessions.sidebar.projectsTitle`),Ke.length),children:[nt.map(e=>{let t=e.displayName;return(0,$.jsx)(un,{value:`project:${e.id}`,onSelect:()=>ut(e.id,e.path),className:to,children:(0,$.jsx)(eo,{title:io(t,le),description:io(we(e.path,{maxLength:80}),le)})},`project:${e.id}`)}),rt(`projects`,Ke.length,nt.length)]},`projects`):null):(0,$.jsx)(`div`,{role:`status`,className:`px-3 py-10 text-center typography-meta text-muted-foreground`,children:i(`common.loading`)}),wt&&L===`loading`?(0,$.jsx)(`div`,{role:`status`,className:`px-3 py-4 text-center typography-meta text-muted-foreground`,children:i(`common.loading`)}):null,wt&&L===`error`?(0,$.jsx)(`div`,{role:`alert`,className:`px-3 py-4 typography-meta text-[var(--status-error)]`,children:i(`commandPalette.error.sessions`)}):null,wt&&He?(0,$.jsx)(`div`,{role:`alert`,className:`px-3 py-4 typography-meta text-[var(--status-error)]`,children:i(`commandPalette.error.sessions`)}):null,wt&&Be?(0,$.jsx)(`div`,{role:`alert`,className:`px-3 py-4 typography-meta text-[var(--status-error)]`,children:i(`commandPalette.error.messages`)}):null,wt&&_t?(0,$.jsx)(`div`,{"data-file-search-pending":!0,role:`status`,className:`px-4 py-2 text-xs text-muted-foreground`,children:i(`common.loading`)}):null,wt&&gt?(0,$.jsx)(`div`,{"data-file-search-notice":!0,role:`status`,className:`px-4 py-2 text-xs text-muted-foreground`,children:i(`commandPalette.error.files`)}):null]})]});return e===`page`?(0,$.jsx)(`section`,{ref:ie,"data-global-search":`true`,"data-page-scroll-lock":`true`,"aria-label":i(`commandPalette.title`),className:`yuri-global-search-page flex min-h-0 w-full flex-col bg-background text-foreground`,children:Dt}):(0,$.jsx)(qt,{open:u,onOpenChange:m,onOpenChangeComplete:e=>{e||p(!1)},children:(0,$.jsxs)(Wt,{ref:ie,initialFocus:ae,"data-global-search":`true`,"data-mobile":U,"data-page-scroll-lock":`true`,presentation:U?`default`:`picker`,className:U?`yuri-global-search-page yuri-global-search-mobile fixed inset-0 z-50 m-0 flex max-w-none translate-x-0 translate-y-0 flex-col gap-0 overflow-hidden rounded-none border-0 bg-background p-0`:`yuri-global-search z-50 w-[min(56rem,calc(100vw-3rem))]`,containerClassName:`block p-0`,overlayClassName:`bg-transparent dark:bg-transparent`,showCloseButton:!1,children:[(0,$.jsxs)(Ht,{className:`sr-only`,children:[(0,$.jsx)(Gt,{children:i(`commandPalette.title`)}),(0,$.jsx)(Kt,{children:i(`commandPalette.description`)})]}),Dt]})})}),co=class extends Q.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){this.setState({error:e,errorInfo:t})}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};render(){return this.state.hasError?(0,$.jsx)(`div`,{className:`flex items-center justify-center min-h-screen p-4`,children:(0,$.jsxs)(zn,{className:`w-full max-w-md`,children:[(0,$.jsx)(Gn,{className:`text-center`,children:(0,$.jsxs)(Kn,{className:`flex items-center justify-center gap-2 text-destructive`,children:[(0,$.jsx)(Z,{name:`chat-3`,className:`h-5 w-5`}),this.props.texts.title]})}),(0,$.jsxs)(In,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground text-center`,children:this.props.texts.description}),this.props.sessionId&&(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground text-center`,children:[this.props.texts.sessionLabel,`: `,this.props.sessionId]}),this.state.error&&(0,$.jsxs)(`details`,{className:`text-xs font-mono bg-muted p-3 rounded`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer hover:bg-interactive-hover/80`,children:this.props.texts.detailsSummary}),(0,$.jsx)(`pre`,{className:`mt-2 max-h-48 overflow-auto`,children:this.state.error.toString()})]}),(0,$.jsx)(`div`,{className:`flex gap-2`,children:(0,$.jsxs)(X,{onClick:this.handleReset,variant:`outline`,className:`flex-1`,children:[(0,$.jsx)(Z,{name:`restart`,className:`h-4 w-4 mr-2`}),this.props.texts.resetAction]})}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground text-center`,children:this.props.texts.persistentHint})]})]})}):this.props.children}};function lo(e){let t=(0,qi.c)(22),{t:n}=be(),r;t[0]===n?r=t[1]:(r=n(`chat.errorBoundary.title`),t[0]=n,t[1]=r);let i;t[2]===n?i=t[3]:(i=n(`chat.errorBoundary.description`),t[2]=n,t[3]=i);let a;t[4]===n?a=t[5]:(a=n(`chat.errorBoundary.sessionLabel`),t[4]=n,t[5]=a);let o;t[6]===n?o=t[7]:(o=n(`chat.errorBoundary.detailsSummary`),t[6]=n,t[7]=o);let s;t[8]===n?s=t[9]:(s=n(`chat.errorBoundary.resetAction`),t[8]=n,t[9]=s);let c;t[10]===n?c=t[11]:(c=n(`chat.errorBoundary.persistentHint`),t[10]=n,t[11]=c);let l;t[12]!==r||t[13]!==i||t[14]!==a||t[15]!==o||t[16]!==s||t[17]!==c?(l={title:r,description:i,sessionLabel:a,detailsSummary:o,resetAction:s,persistentHint:c},t[12]=r,t[13]=i,t[14]=a,t[15]=o,t[16]=s,t[17]=c,t[18]=l):l=t[18];let u;return t[19]!==e||t[20]!==l?(u=(0,$.jsx)(co,{...e,texts:l}),t[19]=e,t[20]=l,t[21]=u):u=t[21],u}var uo=1440,fo=e=>{let t=(0,qi.c)(10),{isMobile:n,isVSCode:r,directory:i}=e,a=ge(`(min-width: ${uo}px)`),o;t[0]===i?o=t[1]:(o=i?A(i):``,t[0]=i,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=e=>{let t=M(e,s);return t?.isOpen?(t.tabs.find(e=>e.id===t.activeTabId)??t.tabs[t.tabs.length-1]??null)?.mode!==`chat`:!1},t[2]=s,t[3]=c);let l=j(c),u=j(po),d;t[4]===s?d=t[5]:(d=e=>e.isRightSidebarOpen&&!!M(e,s)?.isOpen,t[4]=s,t[5]=d);let f=j(d),p=!n&&!r&&!l&&!f,m=p&&a,h=u&&m,g;return t[6]!==m||t[7]!==p||t[8]!==h?(g={visible:h,fits:m,layoutAllows:p},t[6]=m,t[7]=p,t[8]=h,t[9]=g):g=t[9],g};function po(e){return e.workStatusPanelEnabled}var mo=async({directory:e,sessionID:t,signal:n})=>{let r=await E.getScopedSdkClient(e).session.list({directory:e,parentID:t,limit:200},{signal:n});if(!Array.isArray(r?.data))throw Error(`session.list children returned no data`);return r.data.flatMap(e=>{if(!e?.id)return[];let t=typeof e.title==`string`?e.title:void 0;return[{id:e.id,title:t}]})},ho=(e,t,n={})=>{let r=n.listChildren??mo;return R({queryKey:V.workStatusChildren.list(e,t,n.transport),enabled:!!(e&&t),queryFn:({signal:n})=>r({directory:e,sessionID:t,signal:n}),staleTime:5e3,refetchInterval:1e4})},go=[],_o=(...e)=>{let t=_n(...e);return t?t.charAt(0).toUpperCase()+t.slice(1):``},vo=(...e)=>{for(let t of e){if(!t||typeof t!=`object`)continue;let e=t.description;if(typeof e!=`string`)continue;let n=e.trim();if(n)return n}return``},yo=e=>e===`pending`||e===`running`,bo=e=>{let t=[],n=new Set;for(let r of e.messageOrder){let i=e.partsByMessageID[r];if(i)for(let e of i){if(!e?.id||n.has(e.id))continue;if(e.type===`tool`&&Qt(e.tool)){n.add(e.id);let r=e.state;t.push({id:e.id,sessionID:en(e),label:_o(r?.input,r?.metadata,e.metadata),description:vo(r?.input,e.metadata,r?.metadata),running:yo(r?.status)});continue}if(e.type!==`subtask`)continue;let r=e,i=typeof r.taskSessionID==`string`?r.taskSessionID.trim():``,a=typeof r.agent==`string`?r.agent.trim():``,o=typeof r.description==`string`?r.description.trim():``;n.add(e.id),t.push({id:e.id,sessionID:i||void 0,label:a?a.charAt(0).toUpperCase()+a.slice(1):``,description:o,running:yo(r.status)})}}return t.length===0?go:t},xo=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(!r||!i||r.id!==i.id||r.sessionID!==i.sessionID||r.label!==i.label||r.description!==i.description||r.running!==i.running)return!1}return!0},So=e=>e.childTitle||e.description||e.agent,Co=e=>({key:e.key,sessionID:e.sessionID,seed:e.key,label:So(e),phase:e.working?`working`:`done`}),wo=(e,t,n)=>{let r=new Map(t.map(e=>[e.id,e])),i=new Set,a=[],o=new Map,s=e=>{let t=e.sessionID;if(!t){a.push(e);return}i.add(t);let n=o.get(t);if(n===void 0){o.set(t,a.length),a.push({...e,key:t,sessionID:t});return}let r=a[n];r&&(a[n]={...r,description:r.description||e.description,agent:r.agent||e.agent,childTitle:e.childTitle||r.childTitle,working:r.working||e.working})};for(let t of e){let e=t.sessionID?r.get(t.sessionID):void 0;s({key:t.id,sessionID:t.sessionID,description:t.description,agent:t.label,childTitle:e?.title?.trim()||``,working:t.running||!!e?.busy||!!(t.sessionID&&n?.has(t.sessionID))})}for(let e of t)i.has(e.id)||s({key:e.id,sessionID:e.id,description:``,agent:``,childTitle:e.title?.trim()||``,working:e.busy});let c=a.map(Co),l=c.filter(e=>e.phase===`working`),u=c.filter(e=>e.phase===`done`);return l.length===0?u:u.length===0?l:[...l,...u]},To=new Set,Eo=e=>{if(!e)return``;let t=[];for(let n of Object.keys(e)){let r=e[n]?.type;(r===`busy`||r===`retry`)&&t.push(n)}return t.sort(),t.join(`
3
3
  `)},Do=(e,t)=>{let n=(0,qi.c)(4),r;n[0]===t?r=n[1]:(r=e=>t?Eo(e.session_status):``,n[0]=t,n[1]=r);let i=S(e,r),a;return n[2]===i?a=n[3]:(a=i?new Set(i.split(`
4
4
  `)):To,n[2]=i,n[3]=a),a},Oo=(e,t)=>{let n=[];for(let r of e)!r.id||r.parentID!==t||n.push(`${r.id}\u0001${r.title??``}`);return n.join(``)},ko=e=>e?e.split(``).map(e=>{let t=e.indexOf(``);return{id:e.slice(0,t),title:e.slice(t+1)}}):[],Ao=(e,t,n)=>{let r=new Map;for(let t of e)t.id&&r.set(t.id,{id:t.id,title:t.title,busy:n.has(t.id)});for(let e of t??[]){if(!e.id)continue;let t=r.get(e.id),i=e.title?.trim()||t?.title;r.set(e.id,{id:e.id,title:i,busy:n.has(e.id)})}return[...r.values()]},jo=(e,t)=>{let n=(0,qi.c)(18),r=!!(e&&t),i;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={bootstrap:!1},n[0]=i):i=n[0];let a=Ge(t||void 0,i),o;n[1]!==r||n[2]!==e?(o=t=>r&&e?Oo(t.session,e):``,n[1]=r,n[2]=e,n[3]=o):o=n[3];let s=S(a,o),c=t??``,l=e??``,u;n[4]!==c||n[5]!==l?(u=ho(c,l),n[4]=c,n[5]=l,n[6]=u):u=n[6];let d;n[7]!==r||n[8]!==u?(d={...u,enabled:r},n[7]=r,n[8]=u,n[9]=d):d=n[9];let f=z(d),p;n[10]===r?p=n[11]:(p={enabled:r},n[10]=r,n[11]=p);let m=O(e??``,t??``,a,bo,xo,p),h=Do(a,r),g;bb0:{if(!e){let e;n[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],n[12]=e):e=n[12],g=e;break bb0}let t;n[13]!==h||n[14]!==s||n[15]!==f.data||n[16]!==m?(t=wo(m,Ao(ko(s),f.data,h),h),n[13]=h,n[14]=s,n[15]=f.data,n[16]=m,n[17]=t):t=n[17],g=t}return g},Mo=[],No=e=>{let t=(0,qi.c)(60),{sessionId:n,directory:r}=e,{t:i}=be(),a=Q.useId(),[o,s]=Q.useState(!0),[c,l]=Q.useState(!1),u,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{l(!0)},d=[],t[0]=u,t[1]=d):(u=t[0],d=t[1]),Q.useEffect(u,d);let f;t[2]===n?f=t[3]:(f=e=>(n?e.todo[n]:void 0)??Mo,t[2]=n,t[3]=f);let p=xt(f,r??void 0),m;t[4]===n?m=t[5]:(m=e=>{let t=n?e.session_status?.[n]?.type:void 0;return t===`busy`||t===`retry`},t[4]=n,t[5]=m);let h=xt(m,r??void 0),g;t[6]===n?g=t[7]:(g=e=>n?e.sessions[n]?.todos:void 0,t[6]=n,t[7]=g);let _=lt(g),v=Ct(n??``,r??void 0)??(p.length>0?p:_??Mo),y;t[8]===v?y=t[9]:(y=v.filter(Po),t[8]=v,t[9]=y);let b=y,x;t[10]===b?x=t[11]:(x=b.filter(Fo),t[10]=b,t[11]=x);let S=x.length,C;t[12]===b?C=t[13]:(C=b.filter(li),t[12]=b,t[13]=C);let w=C.length,T=Q.useRef(null),E=b.findIndex(Io),D,O;if(t[14]===E?(D=t[15],O=t[16]):(O=()=>{E<0||T.current?.children[E]?.scrollIntoView?.({block:`nearest`})},D=[E],t[14]=E,t[15]=D,t[16]=O),Q.useEffect(O,D),b.length===0)return null;let k=w===b.length,A=h&&!k,j;t[17]===i?j=t[18]:(j=i(`chat.workStatus.todos.title`),t[17]=i,t[18]=j);let M;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>s(Lo),t[19]=M):M=t[19];let N=k?`done`:`open`,ee=c&&`yuri-todo-icon-pop`,P;t[20]===ee?P=t[21]:(P=Y(`inline-flex shrink-0`,ee),t[20]=ee,t[21]=P);let F;t[22]!==k||t[23]!==S||t[24]!==A||t[25]!==b.length?(F=k?(0,$.jsx)(ui,{}):(0,$.jsx)(pi,{done:S,total:b.length,spinning:A}),t[22]=k,t[23]=S,t[24]=A,t[25]=b.length,t[26]=F):F=t[26];let I;t[27]!==N||t[28]!==P||t[29]!==F?(I=(0,$.jsx)(`span`,{className:P,children:F},N),t[27]=N,t[28]=P,t[29]=F,t[30]=I):I=t[30];let L;t[31]===i?L=t[32]:(L=i(`chat.workStatus.todos.title`),t[31]=i,t[32]=L);let R;t[33]===L?R=t[34]:(R=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:L}),t[33]=L,t[34]=R);let z;t[35]!==S||t[36]!==b.length?(z=(0,$.jsx)(ci,{done:S,total:b.length,className:`text-[0.92em]`}),t[35]=S,t[36]=b.length,t[37]=z):z=t[37];let te;t[38]!==o||t[39]!==a||t[40]!==I||t[41]!==R||t[42]!==z?(te=(0,$.jsxs)(X,{type:`button`,variant:`ghost`,size:`sm`,className:`yuri-work-status-action flex w-full min-w-0 items-center justify-start gap-2 px-2 text-left text-[1em] font-normal leading-5 tracking-normal text-muted-foreground [&_svg]:size-3.5`,"aria-expanded":o,"aria-controls":a,onClick:M,children:[I,R,z]}),t[38]=o,t[39]=a,t[40]=I,t[41]=R,t[42]=z,t[43]=te):te=t[43];let B=!o,V=!o,H=o?`grid-rows-[1fr] opacity-100`:`grid-rows-[0fr] opacity-0`,ne;t[44]===H?ne=t[45]:(ne=Y(`grid min-w-0 transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none`,H),t[44]=H,t[45]=ne);let re;t[46]!==h||t[47]!==c||t[48]!==b?(re=(0,$.jsx)(fi,{id:void 0,todos:b,isWorking:h,animate:c,listRef:T,rowClassName:`px-2 gap-2 [&_svg]:size-3.5 [&>span:first-child]:w-3.5`,className:`max-h-[15em] min-h-0 overflow-y-auto pt-[0.125em]`}),t[46]=h,t[47]=c,t[48]=b,t[49]=re):re=t[49];let U;t[50]!==a||t[51]!==B||t[52]!==V||t[53]!==ne||t[54]!==re?(U=(0,$.jsx)(`div`,{id:a,"aria-hidden":B,inert:V,className:ne,children:re}),t[50]=a,t[51]=B,t[52]=V,t[53]=ne,t[54]=re,t[55]=U):U=t[55];let W;return t[56]!==j||t[57]!==te||t[58]!==U?(W=(0,$.jsxs)(`div`,{role:`group`,"aria-label":j,className:`mt-2 flex min-w-0 flex-col text-[13px]`,children:[te,U]}),t[56]=j,t[57]=te,t[58]=U,t[59]=W):W=t[59],W};function Po(e){return e.content.length>0}function Fo(e){return e.status===`completed`}function Io(e){return e.status===`in_progress`}function Lo(e){return!e}var Ro=`flex w-full min-w-0 items-center justify-start gap-2 text-left text-[13px] font-normal leading-5 tracking-normal text-muted-foreground`,zo=`size-3.5 shrink-0`,Bo=`yuri-work-status-action pointer-events-none shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/copy:pointer-events-auto group-hover/copy:opacity-100 focus-visible:pointer-events-auto focus-visible:opacity-100`,Vo=e=>e.split(/[\\/]/).filter(Boolean).pop()||e,Ho=({sessionId:e,directory:t})=>{let{t:n}=be(),{git:r}=ne(),i=En(e=>e.ensureStatus),a=Cn(t),o=ct(e=>e.projects),s=bt(e=>e.availableWorktreesByProject),c=bt(t=>e?t.worktreeMetadata.get(e):void 0),{project:l,worktree:u}=Q.useMemo(()=>{let e=W(t),n=t=>{let n=W(t);return!!(e&&n&&(e===n||e.startsWith(`${n}/`)))},r=c&&n(c.path)?c:void 0,i=ht(o,s,r?.projectDirectory||t),a=i?s.get(i.path):void 0;return{project:i,worktree:r??a?.filter(e=>n(e.path)).sort((e,t)=>t.path.length-e.path.length)[0]}},[s,t,o,c]),d=l?.path||u?.projectDirectory||t,f=l?.label?.trim()||(d?Vo(d):null),p=u&&W(u.path)!==W(d)?u.name?.trim()||Vo(u.path):null,m=jo(e,t),h=[{phase:`working`,labelKey:`chat.workStatus.subagent.workingCount`,items:m.filter(e=>e.phase===`working`)},{phase:`done`,labelKey:`chat.workStatus.subagent.doneCount`,items:m.filter(e=>e.phase===`done`)}],g=h[0].items,_=(g.length>0?g:m).slice(0,3),[v,y]=Q.useState(!1),b=Q.useId(),x=j(e=>e.setRightSidebarOpen),S=j(e=>e.openContextPanel),C=j(e=>e.openContextPanelTab),w=j(e=>e.setRightSidebarTab),[T,E]=Q.useState(null),[,D]=_e(()=>E(null),1500,{immediate:!1}),O=J(async(e,t)=>{try{let n=await ye(t);if(!n.ok)throw Error(n.error);E(e),D()}catch{me.error(n(`gitView.toast.copyFailed`))}});Q.useEffect(()=>{!t||!r||i(t,r)},[t,i,r]);let k=a?.current||null,A=u?.worktreeStatus===`pending`?0:a?.files.length??0,M=0,N=0;if(a?.diffStats)for(let e of Object.values(a.diffStats))M+=e?.insertions??0,N+=e?.deletions??0;let ee=k?`branch:${k}`:``,P=u?.path?`worktree:${u.path}`:``,F=!!(ee&&T===ee),I=!!(P&&T===P),L=J(()=>{k&&O(ee,k)}),R=J(()=>{let e=u?.path;e&&O(P,e)}),z=J(()=>{t&&(S(t),w(`git`),x(!0))});return(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[f?(0,$.jsxs)(`div`,{className:`${Ro} h-8 px-2`,title:`${n(`chat.workStatus.section.project`)}: ${d}`,children:[(0,$.jsx)(Z,{name:`folder`,weight:`medium`,className:zo}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:f})]}):null,k?(0,$.jsxs)(`div`,{className:`${Ro} group/copy h-8 px-2`,title:`${n(`gitView.branch.currentBranchTooltip`)}: ${k}`,children:[(0,$.jsx)(Z,{name:`git-branch`,weight:`medium`,className:zo}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:k}),(0,$.jsx)(X,{variant:`ghost`,size:`xs`,className:Bo,"aria-label":n(`chat.workStatus.action.copyBranch`),title:n(F?`contextSidebar.actions.copied`:`chat.workStatus.action.copyBranch`),onClick:L,children:(0,$.jsx)(Z,{name:F?`check`:`file-copy`,className:zo})})]}):null,p?(0,$.jsxs)(`div`,{className:`${Ro} group/copy h-8 px-2`,title:`${n(`sessions.sidebar.sessionDialogs.worktree.label`)}: ${u?.path}`,children:[(0,$.jsx)(Z,{name:`node-tree`,weight:`medium`,className:zo}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:p}),(0,$.jsx)(X,{variant:`ghost`,size:`xs`,className:Bo,"aria-label":n(`agentManager.detail.actions.copyWorktreePath`),title:n(I?`contextSidebar.actions.copied`:`agentManager.detail.actions.copyWorktreePath`),onClick:R,children:(0,$.jsx)(Z,{name:I?`check`:`file-copy`,className:zo})})]}):null,A>0?(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:`yuri-work-status-action ${Ro}`,title:n(A===1?`chat.workStatus.git.changedFileSingle`:`chat.workStatus.git.changedFilePlural`,{count:A}),"aria-label":n(`chat.workStatus.action.openGit`),onClick:z,children:[(0,$.jsx)(Z,{name:`changes`,weight:`medium`,className:zo}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:n(`chat.workStatus.compact.changes`)}),M>0||N>0?(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 gap-1.5 text-[12px] tabular-nums`,children:[(0,$.jsx)(`span`,{className:`text-[var(--status-success)]`,children:`+${M}`}),(0,$.jsx)(`span`,{className:`text-[var(--status-error)]`,children:`−${N}`})]}):(0,$.jsx)(`span`,{className:`ml-auto tabular-nums`,children:A})]}):null,(0,$.jsx)(No,{sessionId:e,directory:t}),m.length>0?(0,$.jsxs)(`div`,{role:`group`,"aria-label":n(`chat.workStatus.section.subagents`),className:`flex min-w-0 flex-col`,children:[(0,$.jsxs)(X,{type:`button`,variant:`ghost`,size:`sm`,className:`yuri-work-status-action ${Ro} gap-1.5`,"aria-expanded":v,"aria-controls":b,onClick:()=>y(e=>!e),children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0 items-center`,children:_.map((e,t)=>{let r=e.label.trim()||n(`chat.workStatus.subagent.untitled`);return(0,$.jsx)(It,{name:e.seed,label:r,size:14,className:`relative bg-background ring-2 ring-background ${t>0?`-ml-1`:``}`},e.key)})}),(0,$.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-x-1 whitespace-nowrap text-left text-[11px] leading-5 tabular-nums`,children:h.filter(e=>e.items.length>0).map((e,t)=>(0,$.jsxs)(Q.Fragment,{children:[t>0?(0,$.jsx)(`span`,{"aria-hidden":`true`,children:`·`}):null,(0,$.jsx)(`span`,{children:n(e.labelKey,{count:e.items.length})})]},e.phase))}),(0,$.jsx)(Z,{name:v?`arrow-down-s`:`arrow-right-s`,className:`size-3.5 shrink-0 text-muted-foreground opacity-70`})]}),(0,$.jsx)(`div`,{id:b,hidden:!v,className:v?`mt-1 mb-1 flex min-w-0 flex-col gap-1`:`hidden`,children:v?h.filter(e=>e.items.length>0).map(e=>(0,$.jsxs)(`section`,{"aria-label":n(e.labelKey,{count:e.items.length}),className:`flex min-w-0 flex-col gap-1 [&+section]:mt-2`,children:[(0,$.jsx)(`div`,{className:`px-2 py-1 text-[11px] leading-4 text-muted-foreground/70`,children:n(e.labelKey,{count:e.items.length})}),e.items.map(e=>{let r=e.label.trim()||n(`chat.workStatus.subagent.untitled`);return(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,disabled:!e.sessionID||!t,className:`yuri-work-status-action flex w-full min-w-0 items-center justify-start gap-2 text-left text-[12px] font-normal leading-5 text-muted-foreground`,onClick:()=>{!e.sessionID||!t||C(t,{mode:`chat`,dedupeKey:`session:${e.sessionID}`,label:r,readOnly:!0})},children:[(0,$.jsx)(It,{name:e.seed,label:r,size:14}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:r,children:r})]},e.key)})]},e.phase)):null})]}):null]})},Uo=200,Wo=264,Go=e=>{let t=(0,qi.c)(31),{sessionId:n,directory:r,visible:i,overlay:a}=e,o=a!==void 0&&a,{t:s}=be(),c=j(Ko),l=Q.useRef(null),[u,d]=Q.useState(i),f,p;t[0]===i?(f=t[1],p=t[2]):(f=()=>{if(i){d(!0);return}let e=window.setTimeout(()=>d(!1),Uo);return()=>window.clearTimeout(e)},p=[i],t[0]=i,t[1]=f,t[2]=p),Q.useEffect(f,p);let m,h;t[3]!==o||t[4]!==c||t[5]!==i?(m=()=>{if(!o||!i)return;let e=e=>{let t=e.target instanceof Element?e.target:null;l.current?.contains(t)||t?.closest(`[data-work-status-toggle]`)||c(!1)},t=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`keydown`,t)}},h=[o,c,i],t[3]=o,t[4]=c,t[5]=i,t[6]=m,t[7]=h):(m=t[6],h=t[7]),Q.useEffect(m,h);let g;t[8]===s?g=t[9]:(g=s(`chat.workStatus.ariaLabel`),t[8]=s,t[9]=g);let _=!i,v=!i,y=o?`top-3 z-30 max-h-[calc(100%-1.5rem)] rounded-xl p-2 ${sn}`:`top-2`,b;t[10]===y?b=t[11]:(b=Y(`absolute z-20 flex max-h-[calc(100%-1rem)] flex-col overflow-x-hidden overflow-y-auto scrollbar-hidden bg-transparent`,y),t[10]=y,t[11]=b);let x=o?Wo:i?196:0,S=+!!i,C=i?`none`:o?`translateY(-6px)`:`translateX(24px)`,w=o?`opacity, transform`:`none`,T=i?void 0:`none`,E;t[12]!==x||t[13]!==S||t[14]!==C||t[15]!==w||t[16]!==T?(E={right:14,width:x,opacity:S,transform:C,transitionProperty:w,transitionDuration:`${Uo}ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`,pointerEvents:T},t[12]=x,t[13]=S,t[14]=C,t[15]=w,t[16]=T,t[17]=E):E=t[17];let D;t[18]!==u||t[19]!==r||t[20]!==o||t[21]!==n||t[22]!==i?(D=i||o&&u?(0,$.jsx)(Ho,{sessionId:n,directory:r}):null,t[18]=u,t[19]=r,t[20]=o,t[21]=n,t[22]=i,t[23]=D):D=t[23];let O;return t[24]!==b||t[25]!==E||t[26]!==D||t[27]!==g||t[28]!==_||t[29]!==v?(O=(0,$.jsx)(`aside`,{ref:l,"aria-label":g,"aria-hidden":_,inert:v,className:b,style:E,children:D}),t[24]=b,t[25]=E,t[26]=D,t[27]=g,t[28]=_,t[29]=v,t[30]=O):O=t[30],O};function Ko(e){return e.setWorkStatusOverlayOpen}var qo=e=>{let t=(0,qi.c)(10),{sessionId:n,directory:r,visible:i,overlay:a,publishVisible:o}=e,s=a!==void 0&&a,c=o!==void 0&&o,l=j(Yo),u,d;t[0]!==c||t[1]!==l||t[2]!==i?(u=()=>{if(c)return l(i),()=>l(!1)},d=[c,l,i],t[0]=c,t[1]=l,t[2]=i,t[3]=u,t[4]=d):(u=t[3],d=t[4]),Q.useEffect(u,d);let f;return t[5]!==r||t[6]!==s||t[7]!==n||t[8]!==i?(f=(0,$.jsx)(Go,{overlay:s,visible:i,sessionId:n,directory:r}),t[5]=r,t[6]=s,t[7]=n,t[8]=i,t[9]=f):f=t[9],f},Jo=({readOnly:e=!1,active:t=!0,selectionOverride:n})=>{let r=bt(e=>e.currentSessionId),i=bt(e=>e.currentSessionDirectory),a=bt(e=>!!e.newSessionDraft?.open),o=bt(e=>!!(e.newSessionDraft?.open&&e.newSessionDraft.pendingUserMessage&&(e.newSessionDraft.draftEstablishing||e.newSessionDraft.draftSubmitting))),s=jr(),c=j(e=>e.isMobile),l=j(e=>e.isExpandedInput),u=v(),d=j(e=>e.workStatusPanelEnabled),f=j(e=>e.workStatusOverlayOpen),p=j(e=>e.setWorkStatusPanelFits),m=n?.sessionId??r,h=n?.sessionId??r,g=n?.directory??i??s??null,{visible:_,fits:y,layoutAllows:b}=fo({isMobile:c,isVSCode:u,directory:g}),x=n?!!n.sessionId:a?o:!!h,S=t&&!c&&!u&&!l&&x,C=S&&_,w=S&&d&&!y&&f;return Q.useEffect(()=>(p(S&&y),()=>p(!1)),[y,S,p]),(0,$.jsxs)(`div`,{className:Y(`relative h-full min-h-0 min-w-0`,C&&`yuri-chat-work-status-inline`),style:C?{"--yuri-work-status-reserve":`210px`}:void 0,children:[(0,$.jsx)(`div`,{className:`absolute inset-0 min-h-0 min-w-0`,children:(0,$.jsx)(lo,{sessionId:m||void 0,children:(0,$.jsx)(Yt,{readOnly:e,active:t,explicitSession:n?{...n,active:t}:void 0})})}),S&&b?(0,$.jsx)(qo,{publishVisible:!0,visible:C,sessionId:h,directory:g}):null,S&&d&&!y?(0,$.jsx)(qo,{overlay:!0,visible:w,sessionId:h,directory:g}):null]})};function Yo(e){return e.setWorkStatusPanelVisible}function Xo(e){let t=(0,qi.c)(85),{draft:n,onEdit:r,onDelete:i,className:a,maxWidth:o}=e,{t:s}=be(),c=zt()?.currentTheme,[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),p=typeof n.text==`string`?n.text:``,m;t[0]===p?m=t[1]:(m=p.length>150||p.split(`
5
5
  `).length>3,t[0]=p,t[1]=m);let h=m,g;t[2]===a?g=t[3]:(g=Y(`rounded-lg border shadow-none w-full max-w-[min(100%,calc(var(--yuri-context-panel-width,100vw)-var(--yuri-editor-gutter-width,0px)))] overflow-hidden transition-all duration-200`,a),t[2]=a,t[3]=g);let _=c?.colors?.surface?.elevated,v=c?.colors?.interactive?.border,y=o?`${Math.max(200,Math.floor(o))}px`:void 0,b;t[4]!==_||t[5]!==v||t[6]!==y?(b={backgroundColor:_,borderColor:v,maxWidth:y},t[4]=_,t[5]=v,t[6]=y,t[7]=b):b=t[7];let x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>{e.preventDefault(),f(!0)},t[8]=x):x=t[8];let S;t[9]!==g||t[10]!==b?(S=(0,$.jsx)(`div`,{className:g,style:b,"data-comment-card":`true`,onContextMenu:x}),t[9]=g,t[10]=b,t[11]=S):S=t[11];let C;t[12]===n.fileLabel?C=t[13]:(C=(0,$.jsx)(`span`,{className:`truncate max-w-[200px]`,title:n.fileLabel,children:n.fileLabel}),t[12]=n.fileLabel,t[13]=C);let w;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(`span`,{children:`•`}),t[14]=w):w=t[14];let T;t[15]!==n.endLine||t[16]!==n.startLine||t[17]!==s?(T=s(`inlineComment.range.lines`,{start:n.startLine,end:n.endLine}),t[15]=n.endLine,t[16]=n.startLine,t[17]=s,t[18]=T):T=t[18];let E;t[19]===T?E=t[20]:(E=(0,$.jsx)(`span`,{children:T}),t[19]=T,t[20]=E);let D;t[21]===n.side?D=t[22]:(D=n.side&&(0,$.jsxs)(`span`,{children:[`(`,n.side,`)`]}),t[21]=n.side,t[22]=D);let O;t[23]!==E||t[24]!==D||t[25]!==C?(O=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-muted-foreground mb-1.5`,children:[C,w,E,D]}),t[23]=E,t[24]=D,t[25]=C,t[26]=O):O=t[26];let k=l||!h,A=!l&&h&&`line-clamp-3`,j;t[27]===A?j=t[28]:(j=Y(`text-sm whitespace-pre-wrap break-words leading-relaxed`,A),t[27]=A,t[28]=j);let M;t[29]!==p||t[30]!==j?(M=(0,$.jsx)(`div`,{className:j,children:p}),t[29]=p,t[30]=j,t[31]=M):M=t[31];let N;t[32]!==h||t[33]!==l||t[34]!==s?(N=h&&(0,$.jsx)(Li,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-6 px-0 mt-1 text-xs text-muted-foreground hover:text-foreground w-full justify-start`,children:l?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`arrow-up-s`,className:`size-3 mr-1`}),s(`inlineComment.actions.showLess`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`arrow-down-s`,className:`size-3 mr-1`}),s(`inlineComment.actions.showMore`)]})})}),t[32]=h,t[33]=l,t[34]=s,t[35]=N):N=t[35];let ee;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(Ii,{}),t[36]=ee):ee=t[36];let P;t[37]!==k||t[38]!==M||t[39]!==N?(P=(0,$.jsxs)(Ri,{open:k,onOpenChange:u,children:[M,N,ee]}),t[37]=k,t[38]=M,t[39]=N,t[40]=P):P=t[40];let F;t[41]!==O||t[42]!==P?(F=(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[O,P]}),t[41]=O,t[42]=P,t[43]=F):F=t[43];let I;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(Hn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-6 w-6 -mr-1 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(Z,{name:`more`,className:`size-4`})})}),t[44]=I):I=t[44];let L;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(Z,{name:`edit`,className:`size-4 mr-2`}),t[45]=L):L=t[45];let R;t[46]===s?R=t[47]:(R=s(`inlineComment.actions.editComment`),t[46]=s,t[47]=R);let z;t[48]!==r||t[49]!==R?(z=(0,$.jsxs)(Fn,{onClick:r,children:[L,R]}),t[48]=r,t[49]=R,t[50]=z):z=t[50];let te;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(Z,{name:`delete-bin`,className:`size-4 mr-2`}),t[51]=te):te=t[51];let B;t[52]===s?B=t[53]:(B=s(`inlineComment.actions.deleteComment`),t[52]=s,t[53]=B);let V;t[54]!==i||t[55]!==B?(V=(0,$.jsxs)(Fn,{onClick:i,className:`text-destructive`,children:[te,B]}),t[54]=i,t[55]=B,t[56]=V):V=t[56];let H;t[57]!==z||t[58]!==V?(H=(0,$.jsxs)(Pn,{children:[I,(0,$.jsxs)(Nn,{align:`end`,children:[z,V]})]}),t[57]=z,t[58]=V,t[59]=H):H=t[59];let ne;t[60]!==F||t[61]!==H?(ne=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2 p-3`,children:[F,H]}),t[60]=F,t[61]=H,t[62]=ne):ne=t[62];let re;t[63]!==ne||t[64]!==S?(re=(0,$.jsx)(ji,{render:S,children:ne}),t[63]=ne,t[64]=S,t[65]=re):re=t[65];let U;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(Z,{name:`edit`,className:`size-4 mr-2`}),t[66]=U):U=t[66];let W;t[67]===s?W=t[68]:(W=s(`inlineComment.actions.editComment`),t[67]=s,t[68]=W);let ie;t[69]!==r||t[70]!==W?(ie=(0,$.jsxs)(Pi,{onClick:r,children:[U,W]}),t[69]=r,t[70]=W,t[71]=ie):ie=t[71];let ae;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(Z,{name:`delete-bin`,className:`size-4 mr-2`}),t[72]=ae):ae=t[72];let oe;t[73]===s?oe=t[74]:(oe=s(`inlineComment.actions.deleteComment`),t[73]=s,t[74]=oe);let G;t[75]!==i||t[76]!==oe?(G=(0,$.jsxs)(Pi,{onClick:i,className:`text-destructive focus:text-destructive`,children:[ae,oe]}),t[75]=i,t[76]=oe,t[77]=G):G=t[77];let K;t[78]!==ie||t[79]!==G?(K=(0,$.jsxs)(Ni,{children:[ie,G]}),t[78]=ie,t[79]=G,t[80]=K):K=t[80];let se;return t[81]!==d||t[82]!==re||t[83]!==K?(se=(0,$.jsxs)(Fi,{open:d,onOpenChange:f,children:[re,K]}),t[81]=d,t[82]=re,t[83]=K,t[84]=se):se=t[84],se}function Zo(e){let t=(0,qi.c)(67),{initialText:n,onTextChange:r,onSave:i,onCancel:a,fileLabel:o,lineRange:s,isEditing:c,className:l,maxWidth:u,onAddToChat:d}=e,f=n===void 0?``:n,p=c!==void 0&&c,{t:m}=be(),h=zt()?.currentTheme,{isMobile:g}=Yn(),[_,v]=Q.useState(f),y=(0,Q.useRef)(null),b;t[0]===r?b=t[1]:(b=e=>{v(e),r?.(e)},t[0]=r,t[1]=b);let x=b,S=(0,Q.useRef)(s),C,w;t[2]===s?(C=t[3],w=t[4]):(C=()=>{s&&(S.current=s)},w=[s],t[2]=s,t[3]=C,t[4]=w),(0,Q.useEffect)(C,w);let T=as,E=T(s),D,O;t[5]===g?(D=t[6],O=t[7]):(D=()=>{let e=y.current;if(!e)return;let t=e.closest(`.overlay-scrollbar-container`),n=t?.scrollTop??window.scrollY,r=t?.scrollLeft??window.scrollX;if(g){e.scrollIntoView({behavior:`auto`,block:`nearest`});try{e.focus({preventScroll:!0})}catch{e.focus()}return}try{e.focus({preventScroll:!0})}catch{e.focus()}let i=e.value.length;try{e.setSelectionRange(i,i)}catch{}requestAnimationFrame(()=>{t?(t.scrollTop=n,t.scrollLeft=r):window.scrollTo({top:n,left:r})})},O=[g],t[5]=g,t[6]=D,t[7]=O),(0,Q.useEffect)(D,O);let k;t[8]!==a||t[9]!==i||t[10]!==_?(k=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`?(e.preventDefault(),_.trim()&&i(_,T(S.current))):e.key===`Escape`&&(e.preventDefault(),a())},t[8]=a,t[9]=i,t[10]=_,t[11]=k):k=t[11];let A=k,j;t[12]!==i||t[13]!==_?(j=e=>{e.stopPropagation(),_.trim()&&i(_,T(S.current))},t[12]=i,t[13]=_,t[14]=j):j=t[14];let M=j,N;t[15]===l?N=t[16]:(N=Y(`rounded-lg border shadow-none w-full max-w-[min(100%,calc(var(--yuri-context-panel-width,100vw)-var(--yuri-editor-gutter-width,0px)))] overflow-hidden animate-in fade-in zoom-in-95 duration-200`,l),t[15]=l,t[16]=N);let ee=h?.colors?.surface?.elevated,P=h?.colors?.interactive?.border,F=u?`${Math.max(200,Math.floor(u))}px`:void 0,I;t[17]!==ee||t[18]!==P||t[19]!==F?(I={backgroundColor:ee,borderColor:P,maxWidth:F},t[17]=ee,t[18]=P,t[19]=F,t[20]=I):I=t[20];let L=is,R=rs,z=(o||s)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-muted-foreground mb-2`,children:[o&&(0,$.jsx)(`span`,{className:`truncate max-w-[200px]`,children:o}),o&&s&&(0,$.jsx)(`span`,{children:`•`}),E&&(0,$.jsx)(`span`,{children:m(`inlineComment.range.lines`,{start:E.start,end:E.end})})]}),te;t[21]===x?te=t[22]:(te=e=>x(e.target.value),t[21]=x,t[22]=te);let B;t[23]!==g||t[24]!==m?(B=m(g?`inlineComment.input.placeholderShort`:`inlineComment.input.placeholder`),t[23]=g,t[24]=m,t[25]=B):B=t[25];let V;t[26]!==A||t[27]!==te||t[28]!==B||t[29]!==_?(V=(0,$.jsx)(Zr,{simple:!0,ref:y,value:_,onChange:te,onKeyDown:A,placeholder:B,outerClassName:`rounded-[var(--radius-xl)] bg-[var(--surface-subtle)] ring-1 ring-inset ring-border/60 focus-within:ring-2 focus-within:ring-[var(--interactive-focus-ring)]`,className:`min-h-[80px] px-3 py-2.5 text-sm resize-y`}),t[26]=A,t[27]=te,t[28]=B,t[29]=_,t[30]=V):V=t[30];let H;t[31]!==E||t[32]!==d||t[33]!==m?(H=E&&d?(0,$.jsxs)(X,{variant:`outline`,size:`sm`,onClick:()=>d(E),onPointerDown:ns,className:`mr-auto h-8 gap-1.5`,children:[(0,$.jsx)(Z,{name:`add`,className:`size-4`}),m(`chat.textSelection.actions.addToChat`),(0,$.jsx)(gn,{shortcut:`⌘+I`})]}):null,t[31]=E,t[32]=d,t[33]=m,t[34]=H):H=t[34];let ne;t[35]===m?ne=t[36]:(ne=m(`inlineComment.actions.cancel`),t[35]=m,t[36]=ne);let re;t[37]!==a||t[38]!==ne?(re=(0,$.jsx)(X,{variant:`ghost`,size:`sm`,onClick:a,onPointerDown:ts,onTouchStart:es,className:`h-8 text-muted-foreground hover:text-foreground`,children:ne}),t[37]=a,t[38]=ne,t[39]=re):re=t[39];let U;t[40]===_?U=t[41]:(U=_.trim(),t[40]=_,t[41]=U);let W=!U,ie=h?.colors?.status?.success,ae=h?.colors?.status?.successForeground,oe;t[42]!==ie||t[43]!==ae?(oe={backgroundColor:ie,color:ae},t[42]=ie,t[43]=ae,t[44]=oe):oe=t[44];let G;t[45]!==p||t[46]!==m?(G=m(p?`inlineComment.actions.save`:`inlineComment.actions.comment`),t[45]=p,t[46]=m,t[47]=G):G=t[47];let K;t[48]!==M||t[49]!==W||t[50]!==oe||t[51]!==G?(K=(0,$.jsx)(X,{size:`sm`,onClick:M,onPointerDown:$o,onTouchStart:Qo,disabled:W,className:`h-8 min-w-[80px]`,style:oe,children:G}),t[48]=M,t[49]=W,t[50]=oe,t[51]=G,t[52]=K):K=t[52];let se;t[53]!==H||t[54]!==re||t[55]!==K?(se=(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 mt-3`,children:[H,re,K]}),t[53]=H,t[54]=re,t[55]=K,t[56]=se):se=t[56];let ce;t[57]!==z||t[58]!==V||t[59]!==se?(ce=(0,$.jsxs)(`div`,{className:`p-3`,children:[z,V,se]}),t[57]=z,t[58]=V,t[59]=se,t[60]=ce):ce=t[60];let q;return t[61]!==N||t[62]!==I||t[63]!==L||t[64]!==R||t[65]!==ce?(q=(0,$.jsx)(`div`,{className:N,style:I,"data-comment-input":`true`,onPointerDown:L,onTouchStart:R,children:ce}),t[61]=N,t[62]=I,t[63]=L,t[64]=R,t[65]=ce,t[66]=q):q=t[66],q}function Qo(e){return e.stopPropagation()}function $o(e){return e.stopPropagation()}function es(e){return e.stopPropagation()}function ts(e){return e.stopPropagation()}function ns(e){return e.stopPropagation()}function rs(e){return e.stopPropagation()}function is(e){return e.stopPropagation()}function as(e){if(!e)return;let t=Math.min(e.start,e.end),n=Math.max(e.start,e.end);return{...e,start:t,end:n}}var os=e=>{let t=Math.min(e.startLine,e.endLine),n=Math.max(e.startLine,e.endLine);return{...e,startLine:t,endLine:n}},ss=e=>{let t=Math.min(e.start,e.end),n=Math.max(e.start,e.end);return{...e,start:t,end:n}};function cs(e){let t=(0,qi.c)(40),{t:n}=be(),{source:r,fileLabel:i,language:a,getCodeForRange:o,toStoreRange:s,fromDraftRange:c}=e,l=bt(ms),u=bt(ps),d=hn(fs),f=hn(ds),p=hn(us),m=hn(ls),[h,g]=Q.useState(null),[_,v]=Q.useState(``),[y,b]=Q.useState(null),x=l??(u?`draft`:null),S;bb0:{if(!x||!i){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],S=e;break bb0}let e;t[1]!==m||t[2]!==x?(e=m[x]??[],t[1]=m,t[2]=x,t[3]=e):e=t[3];let n=e,a;if(t[4]!==i||t[5]!==n||t[6]!==r){let e;t[8]!==i||t[9]!==r?(e=e=>e.source===r&&e.fileLabel===i,t[8]=i,t[9]=r,t[10]=e):e=t[10],a=n.filter(e),t[4]=i,t[5]=n,t[6]=r,t[7]=a}else a=t[7];S=a}let C=S,w;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>{g(null),v(``),b(null)},t[11]=w):w=t[11];let T=w,E;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{T()},t[12]=E):E=t[12];let D=E,O;t[13]===c?O=t[14]:(O=e=>{let t=ss(c(e));g(t),v(e.text),b(e.id)},t[13]=c,t[14]=O);let k=O,A;t[15]!==y||t[16]!==p?(A=e=>{p(e.sessionKey,e.id),y===e.id&&T()},t[15]=y,t[16]=p,t[17]=A):A=t[17];let j=A,M;t[18]!==d||t[19]!==y||t[20]!==i||t[21]!==o||t[22]!==a||t[23]!==h||t[24]!==x||t[25]!==r||t[26]!==n||t[27]!==s||t[28]!==f?(M=(e,t)=>{let c=t??h,l=e.trim();if(!c||!l||!i)return;if(!x){yt.error(n(`inlineComment.toast.selectSessionToSave`));return}let u=ss(c),p=os(s(u)),m=o(u);y?f(x,y,{fileLabel:i,startLine:p.startLine,endLine:p.endLine,side:p.side,code:m,language:a,text:l}):d({sessionKey:x,source:r,fileLabel:i,startLine:p.startLine,endLine:p.endLine,side:p.side,code:m,language:a,text:l}),T()},t[18]=d,t[19]=y,t[20]=i,t[21]=o,t[22]=a,t[23]=h,t[24]=x,t[25]=r,t[26]=n,t[27]=s,t[28]=f,t[29]=M):M=t[29];let N=M,ee;return t[30]!==_||t[31]!==j||t[32]!==C||t[33]!==y||t[34]!==c||t[35]!==N||t[36]!==h||t[37]!==x||t[38]!==k?(ee={sessionKey:x,drafts:C,selection:h,setSelection:g,commentText:_,setCommentText:v,editingDraftId:y,setEditingDraftId:b,reset:T,cancel:D,startEdit:k,deleteDraft:j,saveComment:N,fromDraftRange:c},t[30]=_,t[31]=j,t[32]=C,t[33]=y,t[34]=c,t[35]=N,t[36]=h,t[37]=x,t[38]=k,t[39]=ee):ee=t[39],ee}function ls(e){return e.drafts}function us(e){return e.removeDraft}function ds(e){return e.updateDraft}function fs(e){return e.addDraft}function ps(e){return e.newSessionDraft?.open}function ms(e){return e.currentSessionId}function hs(e){let{drafts:t,editingDraftId:n,commentText:r,onTextChange:i,selection:a,isDragging:o,fileLabel:s,newWidgetId:c,mapDraftToRange:l,onSave:u,onCancel:d,onEdit:f,onDelete:p,onAddToChat:m}=e,h=[];for(let e of t){let t=l(e);if(e.id===n){h.push({afterLine:t.end,id:`edit-${e.id}`,content:(0,$.jsx)(Zo,{initialText:r,onTextChange:i,fileLabel:s,lineRange:t,isEditing:!0,onSave:u,onCancel:d,onAddToChat:m},`edit-${e.id}`)});continue}h.push({afterLine:t.end,id:`card-${e.id}`,content:(0,$.jsx)(Xo,{draft:e,onEdit:()=>f(e),onDelete:()=>p(e)},`card-${e.id}`)})}if(a&&!n&&!o){let e={...a,start:Math.min(a.start,a.end),end:Math.max(a.start,a.end)};h.push({afterLine:e.end,id:c,content:(0,$.jsx)(Zo,{initialText:r,onTextChange:i,fileLabel:s,lineRange:e,isEditing:!1,onSave:u,onCancel:d,onAddToChat:m},c)})}return h}var gs=e=>{if(e.type===`new`){let t=Math.min(e.selection.start,e.selection.end),n=Math.max(e.selection.start,e.selection.end);return`new-comment-${e.selection.side??`additions`}-${t}-${n}`}return`draft-${e.draft.id}`},_s=e=>{let{drafts:t,editingDraftId:n,selection:r}=e,i=[];for(let e of t){if(!Number.isFinite(e.endLine))continue;let t=Math.max(1,Math.floor(e.endLine)),r=e.side===`original`?`deletions`:`additions`;i.push({lineNumber:t,side:r,metadata:{type:e.id===n?`edit`:`saved`,draft:e}})}return r&&!n&&i.push({lineNumber:Math.max(r.start,r.end),side:r.side??`additions`,metadata:{type:`new`,selection:r}}),i};function vs(e){let t=e.trim();if(!t)return null;if(/^-?\d+(\.\d+)?$/.test(t)){let e=Number.parseFloat(t);return Number.isFinite(e)?e:null}if(t.endsWith(`px`)){let e=Number.parseFloat(t.slice(0,-2));return Number.isFinite(e)?e:null}return null}function ys(e){if(!(!e||e<=0))return Math.max(200,Math.floor(e))}function bs(e){let{diffRootRef:t,drafts:n,selection:r,editingDraftId:i,commentText:a,onTextChange:o,fileLabel:s,onSave:c,onCancel:l,onEdit:u,onDelete:d,onAddToChat:f}=e,[p,m]=Q.useState(0),[h,g]=Q.useState(null),_=Q.useMemo(()=>!r||i?null:gs({type:`new`,selection:r}),[i,r]),v=Q.useMemo(()=>{let e=n.map(e=>gs({type:e.id===i?`edit`:`saved`,draft:e}));return _&&e.push(_),e},[n,i,_]),y=Q.useCallback(e=>{let n=t.current;if(!n)return null;let r=n.querySelector(`diffs-container`);if(!(r instanceof HTMLElement))return null;let i=r.querySelector(`[data-annotation-id="${e}"]`);if(i instanceof HTMLElement)return i;let a=r.shadowRoot;return a?a.querySelector(`[data-annotation-id="${e}"]`):null},[t]);Q.useEffect(()=>{if(v.length===0)return;let e=!1,t=0,n=()=>{e||v.every(e=>!!y(e))||t>=12||(t+=1,requestAnimationFrame(()=>{e||(m(e=>e+1),n())}))};return n(),()=>{e=!0}},[v,y]),Q.useEffect(()=>{let e=t.current;if(!e)return;let n=()=>{let t=vs(getComputedStyle(e).getPropertyValue(`--yuri-context-panel-width`)),n=e.getBoundingClientRect(),r=t??n.width;g(r>0?r:null)};n();let r=new ResizeObserver(()=>{n()});return r.observe(e),window.addEventListener(`resize`,n),()=>{r.disconnect(),window.removeEventListener(`resize`,n)}},[t]);let b=Q.useCallback(e=>{let n=t.current?.getBoundingClientRect(),r=e.closest(`[data-annotation-content]`),i=r instanceof HTMLElement?r.getBoundingClientRect():e.getBoundingClientRect(),a=[i.width];n&&a.push(n.right-i.left);let o=a.filter(e=>Number.isFinite(e)&&e>0);return o.length>0?ys(Math.min(...o)):ys(h)},[t,h]);return(0,$.jsxs)($.Fragment,{children:[n.map(e=>{let t=gs({type:e.id===i?`edit`:`saved`,draft:e}),n=y(t);if(!n)return null;let r=b(n);return e.id===i?(0,Ji.createPortal)((0,$.jsx)(Zo,{initialText:a,onTextChange:o,fileLabel:s,lineRange:{start:e.startLine,end:e.endLine,side:e.side===`original`?`deletions`:`additions`},isEditing:!0,onSave:c,onCancel:l,onAddToChat:f,maxWidth:r}),n,`draft-edit-${e.id}`):(0,Ji.createPortal)((0,$.jsx)(Xo,{draft:e,onEdit:()=>u(e),onDelete:()=>d(e),maxWidth:r}),n,`draft-card-${e.id}`)}),r&&!i&&_&&(()=>{let e=y(_);if(!e)return null;let t=b(e);return(0,Ji.createPortal)((0,$.jsx)(Zo,{initialText:a,onTextChange:o,fileLabel:s,lineRange:r,isEditing:!1,onSave:c,onCancel:l,onAddToChat:f,maxWidth:t}),e,_)})()]})}function xs(e){let t=(0,qi.c)(16),{position:n,onAddToChat:r,onDismiss:i}=e,{t:a}=be(),o=Q.useRef(null),s,c;t[0]===i?(s=t[1],c=t[2]):(s=()=>{if(!i)return;let e=e=>{o.current&&e.target instanceof Node&&o.current.contains(e.target)||i()};return window.addEventListener(`scroll`,e,{capture:!0,passive:!0}),()=>{window.removeEventListener(`scroll`,e,!0)}},c=[i],t[0]=i,t[1]=s,t[2]=c),Q.useEffect(s,c);let l;t[3]!==n.x||t[4]!==n.y?(l={left:n.x,top:n.y},t[3]=n.x,t[4]=n.y,t[5]=l):l=t[5];let u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(Z,{name:`add`,className:`size-4`}),t[6]=u):u=t[6];let d;t[7]===a?d=t[8]:(d=a(`chat.textSelection.actions.addToChat`),t[7]=a,t[8]=d);let f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(gn,{shortcut:`⌘+I`}),t[9]=f):f=t[9];let p;t[10]!==r||t[11]!==d?(p=(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-7 gap-1.5 px-2`,onClick:r,children:[u,d,f]}),t[10]=r,t[11]=d,t[12]=p):p=t[12];let m;return t[13]!==l||t[14]!==p?(m=(0,Ji.createPortal)((0,$.jsx)(`div`,{ref:o,"data-code-selection-action":`true`,className:`fixed z-[100] -translate-y-full rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-lg`,style:l,onPointerDown:Ss,children:p}),document.body),t[13]=l,t[14]=p,t[15]=m):m=t[15],m}function Ss(e){return e.preventDefault()}var Cs=`[data-code-selection-action]`;function ws(e){return e instanceof Element&&!!e.closest(Cs)}function Ts(e,t=[]){return ws(e)?!0:t.some(e=>e instanceof Element&&e.matches(`[data-column-number]`))}function Es(e,t){return e&&!!t?.trim()}function Ds(e,t,n,r){let i=r.side===`deletions`,a=Math.min(r.start,r.end),o=Math.max(r.start,r.end);if(!n){let n=(i?e:t).split(`
@@ -144,6 +144,6 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,n as r,o
144
144
  `),n=null;for(let e of t){let t=e.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(t){let e=Number.parseInt(t[1]??``,10);n=Number.isFinite(e)&&e>=1?e:null;continue}if(n!==null){if(e.startsWith(` `)){n+=1;continue}if(e.startsWith(`+`))return n;if(e.startsWith(`-`))return Math.max(1,n)}}return null},ec=e=>{let t=[],n=new Set;for(let r of e){let e=r.path.trim(),i=r.patch;if(!e||!i.trim()||n.has(e))continue;n.add(e);let a=0,o=0;for(let e of i.split(`
145
145
  `))e.startsWith(`+++`)||e.startsWith(`---`)||(e.startsWith(`+`)&&(a+=1),e.startsWith(`-`)&&(o+=1));let s=/^---\s+\/dev\/null(?:\s|$)/m.test(i)?`added`:/^\+\+\+\s+\/dev\/null(?:\s|$)/m.test(i)?`deleted`:`modified`;t.push({file:e,patch:i,status:s,additions:a,deletions:o})}return t},tc=e=>`${e.scope}:${e.navigationRequestKey??``}:${(e.targetFilePath??``).trim()}:${e.targetLine??``}`,nc=(e,t,n)=>n&&e!==t,rc=e=>`/api/yuri/sessions/${encodeURIComponent(e)}/changes`,ic=e=>e.trim(),ac=e=>e===404||e===405||e===501,oc=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e.diff;return!!t&&typeof t==`object`&&!Array.isArray(t)},sc=(e,t)=>{if(!Array.isArray(e))return null;for(let n of e)if(n&&typeof n==`object`&&!Array.isArray(n)&&n.file===t)return n;return null},cc=async(e,t)=>{let n={messageID:e.messageID,directory:e.directory};return typeof e.file==`string`&&e.file.length>0&&(n.file=e.file),s(rc(e.sessionID),{method:`GET`,headers:{Accept:`application/json`,"x-opencode-directory":e.directory},query:n,signal:t})},lc=async(e,t)=>{if(t.aborted)throw new DOMException(`Aborted`,`AbortError`);return E.getSessionDiff({sessionID:e.sessionID,directory:e.directory,messageID:e.messageID},{signal:t})},uc=(e,t=n())=>V.sessionTurnChanges.file(e.directory,e.sessionID,e.messageID,e.file,e.diffCount,t),dc=(e,t=n())=>({queryKey:uc(e,t),queryFn:async({signal:t})=>{let n=await cc(e,t);if(n.ok){let e=await n.json().catch(()=>null);if(oc(e))return e}else if(!ac(n.status))throw Error(`Session turn change file request failed (${n.status})`);let r=sc(await lc(e,t),e.file);if(!r)throw Error(`change file not found`);return{diff:r}},staleTime:0,gcTime:6e4,retry:!1}),fc=(e,t)=>{let r=(0,qi.c)(10),i;r[0]===t?i=r[1]:(i=t===void 0?{}:t,r[0]=t,r[1]=i);let a=i,o,s,c;if(r[2]!==e||r[3]!==a){let t=n();o=!!e&&!!e?.sessionID?.trim()&&!!e?.directory?.trim()&&!!e?.messageID?.trim()&&!!e?.file?.trim()&&a.enabled!==!1;let i=e??{sessionID:``,directory:``,messageID:``,file:``};c=z,s=dc({...i,directory:ic(i.directory),file:i.file},t),r[2]=e,r[3]=a,r[4]=o,r[5]=s,r[6]=c}else o=r[4],s=r[5],c=r[6];let l;return r[7]!==o||r[8]!==s?(l={...s,enabled:o},r[7]=o,r[8]=s,r[9]=l):l=r[9],c(l)},pc=1100,mc=15e3,hc=500,gc=300,_c=1e6,vc=3,yc=e=>e<=6?e:e<=12?6:e<=25?4:2,bc=Q.memo(()=>{let e=(0,qi.c)(4),{t}=be(),n;e[0]===t?n=e[1]:(n=t(`diffView.binary.unavailable`),e[0]=t,e[1]=n);let r;return e[2]===n?r=e[3]:(r=(0,$.jsx)(`div`,{className:`rounded-lg border border-border/60 bg-background px-3 py-2`,children:(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:n})}),e[2]=n,e[3]=r),r}),xc={"?":{code:`?`,color:`var(--status-info)`,descriptionKey:`diffView.change.untracked`},A:{code:`A`,color:`var(--status-success)`,descriptionKey:`diffView.change.new`},D:{code:`D`,color:`var(--status-error)`,descriptionKey:`diffView.change.deleted`},R:{code:`R`,color:`var(--status-info)`,descriptionKey:`diffView.change.renamed`},C:{code:`C`,color:`var(--status-info)`,descriptionKey:`diffView.change.copied`},M:{code:`M`,color:`var(--status-warning)`,descriptionKey:`diffView.change.modified`}},Sc=xc.M,Cc=e=>{let t=e.index?.trim(),n=e.working_dir?.trim();return t&&t!==`?`?t.charAt(0):n?n.charAt(0):t?.charAt(0)||n?.charAt(0)||`M`},wc=e=>xc[Cc(e)]??Sc,Tc=e=>{let{index:t,working_dir:n}=e;return t===`A`||n===`A`||t===`?`||n===`?`},Ec=e=>{let t=e.index?.trim();return!!(t&&t!==`?`)},Dc=e=>!!e.working_dir?.trim()||e.index===`?`,Oc=(e,t)=>re(e,t),kc=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/,``),Ac=(e,t)=>{let n=e.split(`
146
146
  `),r=t.split(`
147
- `),i=Math.min(n.length,r.length);for(let e=0;e<i;e+=1)if(n[e]!==r[e])return e+1;return r.length>n.length?n.length+1:n.length>r.length?Math.max(1,r.length):1},jc=e=>/^Binary files .+ differ$/m.test(e)||/^GIT binary patch$/m.test(e),Mc=e=>Array.isArray(e)?e.filter(e=>!e||typeof e!=`object`?!1:typeof e.file==`string`):[],Nc=e=>e===`added`?`A`:e===`deleted`?`D`:`M`,Pc=e=>e.isBinary||typeof e.patch==`string`&&e.patch.length>0||e.fileDiff?!0:e.original.length>0||e.modified.length>0,Fc=(e,t,n)=>jc(t)?{original:``,modified:``,isBinary:!0,patch:t,contextMode:n}:{original:``,modified:``,patch:t,fileDiff:Js(e,t),contextMode:n},Ic=(e,t,n)=>{let r=e??0,i=t??0;return!r&&!i?null:(0,$.jsxs)(`span`,{className:Y(`typography-code flex items-center gap-1 whitespace-nowrap`,n?.shrink?`min-w-0 overflow-hidden`:`flex-shrink-0`,n?.className),children:[r?(0,$.jsxs)(`span`,{style:{color:`var(--status-success)`},children:[`+`,r]}):null,i?(0,$.jsxs)(`span`,{style:{color:`var(--status-error)`},children:[`-`,i]}):null]})},Lc=Q.memo(e=>{let t=(0,qi.c)(53),{scope:n,workingCount:r,stagedCount:i,turnCount:a,onScopeChange:o}=e,{t:s}=be(),[c,l]=Q.useState(!1),u=n===`staged`?i:n===`turn`?a:r,d;t[0]!==n||t[1]!==s?(d=s(n===`staged`?`diffView.scope.staged`:n===`turn`?`diffView.scope.lastTurn`:`diffView.scope.changed`),t[0]=n,t[1]=s,t[2]=d):d=t[2];let f=d,p;t[3]===s?p=t[4]:(p=s(`diffView.scope.selectorAria`),t[3]=s,t[4]=p);let m;t[5]===u?m=t[6]:(m=(0,$.jsxs)(`span`,{className:`diff-toolbar__scope-count`,children:[`: `,u]}),t[5]=u,t[6]=m);let h;t[7]!==f||t[8]!==m?(h=(0,$.jsxs)(`span`,{className:`whitespace-nowrap`,children:[f,m]}),t[7]=f,t[8]=m,t[9]=h):h=t[9];let g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(Z,{name:`arrow-down-s`,className:`size-4 flex-shrink-0 opacity-60`}),t[10]=g):g=t[10];let _;t[11]!==p||t[12]!==h?(_=(0,$.jsx)(Hn,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-code font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":p,children:[h,g]})}),t[11]=p,t[12]=h,t[13]=_):_=t[13];let v;t[14]===o?v=t[15]:(v=e=>{(e===`working`||e===`staged`||e===`turn`)&&(o?.(e),l(!1))},t[14]=o,t[15]=v);let y;t[16]===s?y=t[17]:(y=s(`diffView.scope.changed`),t[16]=s,t[17]=y);let b;t[18]===y?b=t[19]:(b=(0,$.jsx)(`span`,{children:y}),t[18]=y,t[19]=b);let x;t[20]===r?x=t[21]:(x=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:r}),t[20]=r,t[21]=x);let S;t[22]!==x||t[23]!==b?(S=(0,$.jsx)(Rn,{value:`working`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center justify-between gap-3`,children:[b,x]})}),t[22]=x,t[23]=b,t[24]=S):S=t[24];let C;t[25]===s?C=t[26]:(C=s(`diffView.scope.staged`),t[25]=s,t[26]=C);let w;t[27]===C?w=t[28]:(w=(0,$.jsx)(`span`,{children:C}),t[27]=C,t[28]=w);let T;t[29]===i?T=t[30]:(T=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:i}),t[29]=i,t[30]=T);let E;t[31]!==w||t[32]!==T?(E=(0,$.jsx)(Rn,{value:`staged`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center justify-between gap-3`,children:[w,T]})}),t[31]=w,t[32]=T,t[33]=E):E=t[33];let D;t[34]===s?D=t[35]:(D=s(`diffView.scope.lastTurn`),t[34]=s,t[35]=D);let O;t[36]===D?O=t[37]:(O=(0,$.jsx)(`span`,{children:D}),t[36]=D,t[37]=O);let k;t[38]===a?k=t[39]:(k=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:a}),t[38]=a,t[39]=k);let A;t[40]!==O||t[41]!==k?(A=(0,$.jsx)(Rn,{value:`turn`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center justify-between gap-3`,children:[O,k]})}),t[40]=O,t[41]=k,t[42]=A):A=t[42];let j;t[43]!==n||t[44]!==S||t[45]!==E||t[46]!==A||t[47]!==v?(j=(0,$.jsx)(Nn,{align:`start`,className:`w-40`,children:(0,$.jsxs)(jn,{value:n,onValueChange:v,children:[S,E,A]})}),t[43]=n,t[44]=S,t[45]=E,t[46]=A,t[47]=v,t[48]=j):j=t[48];let M;return t[49]!==c||t[50]!==j||t[51]!==_?(M=(0,$.jsxs)(Pn,{open:c,onOpenChange:l,children:[_,j]}),t[49]=c,t[50]=j,t[51]=_,t[52]=M):M=t[52],M}),Rc=Q.memo(e=>{let t=(0,qi.c)(11),{changedFiles:n,selectedFile:r,onSelectFile:i}=e,{t:a}=be();if(n.length===0)return null;let o;if(t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==a){let e;t[5]!==i||t[6]!==r||t[7]!==a?(e=e=>{let t=wc(e),n=r===e.path;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i(e.path),className:Y(`flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left transition-colors`,n?`bg-interactive-selection text-interactive-selection-foreground`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),children:[(0,$.jsx)(nn,{filePath:e.path,className:`size-3 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`typography-code font-semibold w-3.5 text-center uppercase`,style:{color:t.color},title:a(t.descriptionKey),"aria-label":a(t.descriptionKey),children:t.code}),(0,$.jsx)(dn,{path:e.path,className:`min-w-0 flex-1 typography-code`,dirClassName:n?`text-interactive-selection-foreground`:`text-muted-foreground`,nameClassName:n?`text-interactive-selection-foreground`:`text-foreground`}),Ic(e.insertions,e.deletions)]})},e.path)},t[5]=i,t[6]=r,t[7]=a,t[8]=e):e=t[8],o=n.map(e),t[0]=n,t[1]=i,t[2]=r,t[3]=a,t[4]=o}else o=t[4];let s;return t[9]===o?s=t[10]:(s=(0,$.jsx)(Yr,{outerClassName:`flex-1 min-h-0`,className:`px-2 py-2`,children:(0,$.jsx)(`ul`,{className:`flex flex-col gap-1`,children:o})}),t[9]=o,t[10]=s),s}),zc=Q.memo(e=>{let t=(0,qi.c)(20),{filePath:n,diff:r,renderSideBySide:i}=e,{t:a}=be(),o=r.original.length>0,s=r.modified.length>0,c=i?`flex flex-row gap-6 items-start justify-center`:`flex flex-col gap-4 items-center`,l=i?`flex flex-col items-center gap-2 flex-1 min-w-0`:`flex flex-col items-center gap-2`,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u={contain:`layout`},t[0]=u):u=t[0];let d;t[1]!==r.original||t[2]!==n||t[3]!==o||t[4]!==l||t[5]!==i||t[6]!==a?(d=o&&(0,$.jsxs)(`div`,{className:l,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground font-medium`,children:a(`diffView.image.original`)}),(0,$.jsx)(Mr,{src:r.original,alt:a(`diffView.image.originalAlt`,{path:n}),className:i?`max-w-full max-h-[70vh] object-contain`:`max-w-full object-contain`,style:{imageRendering:`auto`}})]}),t[1]=r.original,t[2]=n,t[3]=o,t[4]=l,t[5]=i,t[6]=a,t[7]=d):d=t[7];let f;t[8]!==r.modified||t[9]!==n||t[10]!==s||t[11]!==o||t[12]!==l||t[13]!==i||t[14]!==a?(f=s&&(0,$.jsxs)(`div`,{className:l,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground font-medium`,children:a(o?`diffView.image.modified`:`diffView.image.new`)}),(0,$.jsx)(Mr,{src:r.modified,alt:a(`diffView.image.modifiedAlt`,{path:n}),className:i?`max-w-full max-h-[70vh] object-contain`:`max-w-full object-contain`,style:{imageRendering:`auto`}})]}),t[8]=r.modified,t[9]=n,t[10]=s,t[11]=o,t[12]=l,t[13]=i,t[14]=a,t[15]=f):f=t[15];let p;return t[16]!==c||t[17]!==d||t[18]!==f?(p=(0,$.jsx)(`div`,{className:`w-full overflow-auto p-4`,style:u,children:(0,$.jsxs)(`div`,{className:c,children:[d,f]})}),t[16]=c,t[17]=d,t[18]=f,t[19]=p):p=t[19],p}),Bc=Q.memo(e=>{let t=(0,qi.c)(18),{filePath:n,diff:r,renderSideBySide:i,wrapLines:a,expandUnchanged:o,focusLine:s}=e,c=o!==void 0&&o,l;t[0]===n?l=t[1]:(l=Tr(n)||`text`,t[0]=n,t[1]=l);let u=l;if(r.isBinary){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(bc,{}),t[2]=e):e=t[2],e}if(Er(n)){let e;return t[3]!==r||t[4]!==n||t[5]!==i?(e=(0,$.jsx)(zc,{filePath:n,diff:r,renderSideBySide:i}),t[3]=r,t[4]=n,t[5]=i,t[6]=e):e=t[6],e}let d;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d={contain:`layout`},t[7]=d):d=t[7];let f=c&&!r.fileDiff?.isPartial,p;return t[8]!==r.fileDiff||t[9]!==r.modified||t[10]!==r.original||t[11]!==n||t[12]!==s||t[13]!==u||t[14]!==i||t[15]!==f||t[16]!==a?(p=(0,$.jsx)(`div`,{className:`w-full`,style:d,children:(0,$.jsx)(Ws,{original:r.original,modified:r.modified,fileDiff:r.fileDiff,language:u,fileName:n,renderSideBySide:i,wrapLines:a,expandUnchanged:f,focusLine:s,layout:`inline`,enableSelectionActions:!0})}),t[8]=r.fileDiff,t[9]=r.modified,t[10]=r.original,t[11]=n,t[12]=s,t[13]=u,t[14]=i,t[15]=f,t[16]=a,t[17]=p):p=t[17],p}),Vc=Q.memo(e=>{let t=(0,qi.c)(7),{filePath:n,staged:r,busyAction:i,disabled:a,onAction:o}=e,{t:s}=be(),c;return t[0]!==i||t[1]!==a||t[2]!==n||t[3]!==o||t[4]!==r||t[5]!==s?(c=(0,$.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-lg backdrop-blur-md`,children:r?(0,$.jsx)(Hc,{label:s(`gitView.changes.unstageFileAria`,{path:n}),icon:`arrow-go-back`,loading:i===`unstage`,disabled:a,onClick:()=>o(`unstage`)}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Hc,{label:s(`gitView.changes.revertFileAria`,{path:n}),icon:`arrow-go-back`,loading:i===`discard`,disabled:a,tone:`failure`,onClick:()=>o(`discard`)}),(0,$.jsx)(Hc,{label:s(`gitView.changes.stageFileAria`,{path:n}),icon:`add`,loading:i===`stage`,disabled:a,tone:`success`,onClick:()=>o(`stage`)})]})}),t[0]=i,t[1]=a,t[2]=n,t[3]=o,t[4]=r,t[5]=s,t[6]=c):c=t[6],c}),Hc=e=>{let t=(0,qi.c)(14),{label:n,icon:r,loading:i,disabled:a,tone:o,onClick:s}=e,c=o===`failure`&&`text-[var(--status-error)] hover:text-[var(--status-error)]`,l=o===`success`&&`text-[var(--status-success)] hover:text-[var(--status-success)]`,u;t[0]!==c||t[1]!==l?(u=Y(`h-6 w-6 rounded-none bg-transparent p-0 text-muted-foreground opacity-70 hover:bg-transparent hover:text-foreground hover:opacity-100`,c,l),t[0]=c,t[1]=l,t[2]=u):u=t[2];let d;t[3]===s?d=t[4]:(d=e=>{e.stopPropagation(),s()},t[3]=s,t[4]=d);let f;t[5]!==r||t[6]!==i?(f=i?(0,$.jsx)(Z,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,$.jsx)(Z,{name:r,className:r===`add`?`size-4`:`size-3.5`}),t[5]=r,t[6]=i,t[7]=f):f=t[7];let p;return t[8]!==a||t[9]!==n||t[10]!==u||t[11]!==d||t[12]!==f?(p=(0,$.jsx)(X,{variant:`ghost`,size:`sm`,className:u,disabled:a,title:n,"aria-label":n,onClick:d,children:f}),t[8]=a,t[9]=n,t[10]=u,t[11]=d,t[12]=f,t[13]=p):p=t[13],p},Uc=Q.memo(({directory:e,file:t,layout:n,wrapLines:r,isSelected:i,isExpanded:a,isMounted:o,onSelect:s,onExpandedChange:c,registerSectionRef:l,showOpenInEditorAction:u=!1,isOpeningInEditor:d=!1,onOpenInEditor:f,onOpenFile:p,staged:m=!1,loadFullFiles:h=!1,preloadFullFiles:g=!1,initialDiffData:_=null,focusLine:v=null,showFileActions:y=!0,disableGitFetch:b=!1,turnChangesRequest:x=null,loadTurnChangeFile:S=!1})=>{let{t:C}=be(),{git:w}=ne(),T=En(Q.useCallback(n=>n.directories.get(e)?.diffCache.get(t.path)??null,[e,t.path])),E=En(e=>e.setDiff),D=En(e=>e.fetchStatus),[O,k]=Q.useState(0),[A,j]=Q.useState(null),[M,N]=Q.useState(!1),[ee,P]=Q.useState(null),[F,I]=Q.useState(!1),[L,R]=Q.useState(null),[z,te]=Q.useState(null),B=Q.useRef(null),V=Q.useMemo(()=>wc(t),[t]),H=n===`side-by-side`,re=g||h,U=re?`full`:`patch`,W=`${t.index}:${t.working_dir}:${t.insertions}:${t.deletions}`,ie=fc({sessionID:x?.sessionID??``,directory:x?.directory??``,messageID:x?.messageID??``,diffCount:x?.diffCount,file:t.path},{enabled:S&&!!x&&a&&o}),ae=Q.useMemo(()=>{let e=ie.data?.diff;return e?typeof e.patch==`string`&&e.patch.length>0?Fc(t.path,e.patch,`patch`):typeof e.before==`string`&&e.before.length>0||typeof e.after==`string`&&e.after.length>0?{original:e.before??``,modified:e.after??``,contextMode:`full`}:null:null},[t.path,ie.data]),oe=Q.useMemo(()=>{if(_)return _;if(ae)return ae;if(m)return z;if(L)return L;if(!T)return null;let e={original:T.original,modified:T.modified,isBinary:T.isBinary,contextMode:`full`};return Pc(e)?e:null},[T,_,L,m,z,ae]),G=ie.error instanceof Error?ie.error.message:ie.error?String(ie.error):null,K=oe?null:G??A,se=S&&ie.isPending||M,ce=Q.useCallback(e=>{B.current=e,l(t.path,e)},[t.path,l]),q=Q.useCallback(e=>{c(t.path,e)},[t.path,c]),le=Q.useCallback(()=>{s(t.path)},[t.path,s]);Q.useEffect(()=>{if(!a||!o||b||!e||_){N(!1);return}j(null),N(!0);let n=!1,r=re?_c:vc,i=Er(t.path)||re?w.getGitFileDiff(e,{path:t.path,staged:m}):w.getGitDiff(e,{path:t.path,staged:m,contextLines:r}),s=mc,c,l=new Promise((e,t)=>{c=setTimeout(()=>t(Error(`Timed out after ${s}ms`)),s)});return Promise.race([i,l]).then(r=>{if(!n){if(`diff`in r){let e=Fc(t.path,r.diff,U);m?te(e):R(e)}else{let n={original:r.original??``,modified:r.modified??``,isBinary:r.isBinary,contextMode:`full`};m?te(n):(R(n),E(e,t.path,n))}N(!1)}}).catch(e=>{if(n)return;let t=e instanceof Error?e.message:String(e);j(t),N(!1)}).finally(()=>clearTimeout(c)),()=>{n=!0,clearTimeout(c)}},[U,O,e,b,t.path,W,w,_,a,o,re,E,m]);let ue=Q.useCallback(()=>{q(!a),le()},[q,le,a]),de=Q.useCallback(async n=>{if(!(!e||ee!==null)){P(n);try{n===`stage`?await w.stageGitFile(e,t.path):n===`unstage`?await w.unstageGitFile(e,t.path):await w.revertGitFile(e,t.path,{scope:`working`}),k(e=>e+1),await D(e,w)}catch(e){let t=n===`unstage`?`gitView.toast.unstageFileFailed`:n===`stage`?`gitView.toast.stageFileFailed`:`gitView.toast.revertFailed`;yt.error(e instanceof Error?e.message:C(t))}finally{P(e=>e===n?null:e)}}},[e,D,t.path,ee,w,C]);return(0,$.jsxs)(`div`,{ref:ce,"aria-busy":se,className:`scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0`,children:[(0,$.jsx)(`div`,{className:`sticky top-0 z-30 border-b border-[var(--interactive-border)]/35 bg-background/95 backdrop-blur-md supports-[backdrop-filter]:bg-background/90`,"data-diff-file-header":!0,children:(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:ue,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),ue())},className:Y(`cursor-pointer`,`group/header relative grid min-h-8 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-1.5 overflow-hidden px-2 py-1`,`bg-transparent`,`text-muted-foreground hover:text-foreground`,i?`bg-[var(--interactive-selection)]/35`:null),children:[(0,$.jsx)(`div`,{className:`absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50`}),(0,$.jsxs)(`div`,{className:`relative flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`flex size-4 items-center justify-center opacity-70 group-hover/header:opacity-100`,children:a?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`size-3.5`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`size-3.5`})}),(0,$.jsx)(`span`,{className:`typography-code font-semibold leading-none w-3.5 text-center uppercase`,style:{color:V.color},title:C(V.descriptionKey),"aria-label":C(V.descriptionKey),children:V.code}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 overflow-hidden typography-code`,title:t.path,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(nn,{filePath:t.path,className:`size-3 flex-shrink-0 align-middle`}),(0,$.jsx)(dn,{path:t.path,className:`min-w-0 flex-1 typography-code`})]})})]}),(0,$.jsxs)(`div`,{className:`relative flex shrink-0 items-center justify-self-end gap-1.5`,children:[se&&oe?(0,$.jsx)(`span`,{role:`status`,"aria-label":C(`diffView.state.loadingDiff`),children:(0,$.jsx)(Z,{name:`loader-4`,className:`size-3.5 animate-spin`})}):null,Ic(t.insertions,t.deletions),u&&f?(0,$.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-5 w-5 p-0 opacity-70 hover:opacity-100`,title:C(`diffView.actions.openFileInEditorAtChange`),onClick:e=>{e.stopPropagation(),f(t.path,oe)},disabled:d,children:d?(0,$.jsx)(Z,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,$.jsx)(Z,{name:`edit`,className:`size-3.5`})}):null,p?(0,$.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-5 w-5 p-0 opacity-70 hover:opacity-100`,title:C(`diffView.actions.openFilePreview`),"aria-label":C(`diffView.actions.openFilePreview`),onClick:e=>{e.stopPropagation(),p(t.path)},children:(0,$.jsx)(Z,{name:`eye`,className:`size-3.5`})}):null]})]})}),a&&(0,$.jsxs)(`div`,{className:`relative bg-background overflow-hidden`,children:[oe&&A?(0,$.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 px-3 py-2 typography-meta text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[C(`diffView.state.failedToLoadDiff`),`: `,A]}),(0,$.jsx)(X,{variant:`ghost`,size:`xs`,onClick:()=>k(e=>e+1),children:C(`diffView.actions.retry`)})]}):null,!o&&!K?(0,$.jsx)(`div`,{className:`h-40 border border-border/40 bg-background/40`}):null,K?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-semibold text-foreground`,children:C(`diffView.state.failedToLoadDiff`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground max-w-[32rem] text-center`,children:K}),(0,$.jsx)(`button`,{type:`button`,className:`typography-ui-label text-primary hover:underline`,onClick:()=>{if(S){ie.refetch();return}k(e=>e+1)},children:C(`diffView.actions.retry`)})]}):null,o&&se&&!oe&&!K?(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground`,children:[(0,$.jsx)(Z,{name:`loader-4`,className:`size-4 animate-spin`}),C(`diffView.state.loadingDiff`)]}):null,o&&oe&&!F&&t.insertions+t.deletions>hc?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-semibold text-foreground`,children:C(`diffView.state.largeDiff`,{count:t.insertions+t.deletions})}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:C(`diffView.state.largeDiffDescription`)}),(0,$.jsx)(`button`,{type:`button`,className:`typography-ui-label text-primary hover:underline`,onClick:()=>I(!0),children:C(`diffView.actions.renderAnyway`)})]}):null,o&&oe&&(F||t.insertions+t.deletions<=hc)?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Bc,{filePath:t.path,diff:oe,renderSideBySide:H,wrapLines:r,expandUnchanged:h&&oe.contextMode===`full`,focusLine:v}),y?(0,$.jsx)(`div`,{className:`pointer-events-none absolute bottom-3 right-3 z-20`,children:(0,$.jsx)(`div`,{className:`pointer-events-auto`,children:(0,$.jsx)(Vc,{filePath:t.path,staged:m,busyAction:ee,disabled:ee!==null,onAction:de})})}):null]}):null]})]})}),Wc=({hideStackedFileSidebar:e=!1,stackedDefaultCollapsedAll:t=!1,pinSelectedFileHeaderToTopOnNavigate:n=!1,showOpenInEditorAction:r=!1,diffScope:i=`all`,turnMessageId:a=null,sessionId:o=null,directory:s=null,onDiffScopeChange:c,targetFilePath:l=null,targetLine:u=null,toolPatches:d=null,flushContent:f=!1,singleFileView:p=!1,toolbarInSheetHeader:m=!1,preloadFullFiles:h=!1,navigationRequestKey:g})=>{let{t:_}=be(),{git:v}=ne(),y=jr(),b=typeof s==`string`&&s.trim()?s.trim():y,{screenWidth:x,isMobile:S}=Yn(),C=yn(b??null),w=Cn(b??null),T=bn(b??null),E=En(e=>e.setActiveDirectory),D=En(e=>e.ensureStatus),O=En(e=>e.fetchStatus),k=En(e=>e.setDiff),[A,M]=Q.useState(null),[N,ee]=Q.useState(!1),[P,F]=Q.useState(null),[I,L]=Q.useState(null),[R,z]=Q.useState(()=>new Set),[te,B]=Q.useState(()=>new Set),[V,H]=Q.useState(!1),[re,U]=Q.useState(0),[W,ie]=Q.useState(i);Q.useEffect(()=>{ie(i)},[i]);let ae=j(e=>e.pendingDiffFile),oe=j(e=>e.pendingDiffStaged),G=j(e=>e.pendingDiffScope),K=j(e=>e.pendingDiffLine),se=j(e=>e.setPendingDiffFile),ce=j(e=>e.diffLayoutPreference),q=j(e=>e.diffFileLayout),le=j(e=>e.setDiffFileLayout),ue=j(e=>e.diffWrapLines),de=j(e=>e.setDiffWrapLines),fe=j(e=>e.openContextFileAtLine),pe=j(e=>e.openContextFile),me=mr(),he=bt(e=>e.currentSessionId),ge=typeof o==`string`&&o.trim()?o.trim():he,_e=mt(ge??``,b??void 0),ve=ue,ye=W===`staged`||W!==`working`&&null,xe=ye??N,Se=!e&&!(S||x<=768)&&x>=1024,Ce=Q.useRef(null),we=Q.useRef(new Map),Te=Q.useRef(null),Ee=Q.useRef(null),De=Q.useRef(!1),Oe=Q.useRef(null),ke=Q.useRef(null),Ae=Q.useRef(null),je=Q.useRef(null),Me=Q.useCallback(()=>{Te.current=null,De.current=!1,L(null),Ee.current!==null&&(window.cancelAnimationFrame(Ee.current),Ee.current=null)},[]),Ne=Q.useCallback(e=>{z(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),Pe=Q.useMemo(()=>{let e=_e.length-1;if(a&&(e=_e.findIndex(e=>e.id===a),e<0))return{messageID:null,count:0,hasDiffs:!1,thinDiffs:[]};for(let t=e;t>=0;--t){let e=_e[t];if(e.role!==`user`)continue;let n=Mc(e.summary?.diffs),r=typeof e.summary?.diffCount==`number`&&Number.isFinite(e.summary.diffCount)?Math.max(0,Math.trunc(e.summary.diffCount)):n.length;return{messageID:typeof e.id==`string`&&e.id?e.id:null,count:r,hasDiffs:e.summary?.hasDiffs===!0||r>0||n.length>0,thinDiffs:n}}return{messageID:null,count:0,hasDiffs:!1,thinDiffs:[]}},[_e,a]),Fe=Q.useMemo(()=>ec(d??[]),[d]),Ie=Fe.length>0,Le=Q.useMemo(()=>!ge||!b||!Pe.messageID?null:{sessionID:ge,directory:b,messageID:Pe.messageID,diffCount:Pe.count},[b,ge,Pe.count,Pe.messageID]),Re=Q.useMemo(()=>Ie?Fe:Pe.thinDiffs,[Fe,Pe.thinDiffs,Ie]),ze=Q.useMemo(()=>{let e=new Map;for(let t of Re)if(t.file){if(typeof t.patch==`string`&&t.patch.length>0){e.set(t.file,Fc(t.file,t.patch,`patch`));continue}(typeof t.before==`string`&&t.before.length>0||typeof t.after==`string`&&t.after.length>0)&&e.set(t.file,{original:t.before??``,modified:t.after??``,contextMode:`full`})}return e},[Re]),Be=Q.useMemo(()=>{if(W===`turn`)return Re.map(e=>({path:e.file??``,index:``,working_dir:Nc(e.status),insertions:e.additions??0,deletions:e.deletions??0,isNew:e.status===`added`})).filter(e=>e.path).sort((e,t)=>e.path.localeCompare(t.path));if(!w?.files)return[];let e=w.diffStats??{},t=W===`staged`?Ec:W===`working`?Dc:()=>!0;return w.files.filter(t).map(t=>({...t,insertions:e[t.path]?.insertions??0,deletions:e[t.path]?.deletions??0,isNew:Tc(t)})).sort((e,t)=>e.path.localeCompare(t.path))},[W,Re,w]),Ve=Q.useMemo(()=>w?.files?w.files.filter(Dc).length:0,[w]),He=Q.useMemo(()=>w?.files?w.files.filter(Ec).length:0,[w]),Ue=Ie?Re.length:Pe.count,We=Q.useMemo(()=>Be.map(e=>e.path).join(`\0`),[Be]),Ge=Q.useMemo(()=>{if(!p)return Be;let e=l?.trim()||A;return e?Be.filter(t=>t.path===e):[]},[Be,A,p,l]);Q.useEffect(()=>{let e=We?We.split(`\0`):[],n=new Set(e),r=`${b??``}:${W}:${a??``}:${t?`collapsed`:`default`}`,i=d!==null&&Ae.current!==d,o=ke.current!==r||i;ke.current=r,Ae.current=d,z(r=>{if(o){let n=t||W===`turn`&&!Ie?0:yc(e.length);return new Set(e.slice(0,n))}let i=!1,a=new Set;for(let e of r){if(!n.has(e)){i=!0;continue}a.add(e)}return i?a:r}),B(e=>{if(o)return new Set;let t=!1,r=new Set;for(let i of e){if(!n.has(i)){t=!0;continue}r.add(i)}return t?r:e})},[W,We,b,t,d,a,Ie]);let Ke=Q.useCallback(()=>{Oe.current=null;let e=Ce.current;if(!e)return;let t=e.getBoundingClientRect(),n=t.top-gc,r=t.bottom+gc,i={};for(let[e,t]of we.current){if(!t||!R.has(e))continue;let a=t.getBoundingClientRect();a.bottom<n||a.top>r||(i[e]=!0)}B(e=>{let t=!1,n=new Set(e);for(let e of Object.keys(i))n.has(e)||(n.add(e),t=!0);return t?n:e})},[R]),qe=Q.useCallback(()=>{typeof window>`u`||Oe.current===null&&(Oe.current=window.requestAnimationFrame(Ke))},[Ke]);Q.useEffect(()=>{let e=Ce.current;if(e)return qe(),e.addEventListener(`scroll`,qe,{passive:!0}),window.addEventListener(`resize`,qe),()=>{e.removeEventListener(`scroll`,qe),window.removeEventListener(`resize`,qe),Oe.current!==null&&(window.cancelAnimationFrame(Oe.current),Oe.current=null)}},[Be,R,qe]);let Je=Q.useCallback(e=>{let t=q[e.path];if(t)return t;if(ce===`inline`)return`inline`;if(ce===`side-by-side`)return`side-by-side`;let n=x<pc;return e.isNew||n?`inline`:`side-by-side`},[q,ce,x]),Ye=Q.useMemo(()=>Ge.length===0?null:Ge.every(e=>Je(e)===`side-by-side`)?`side-by-side`:`inline`,[Je,Ge]);Q.useEffect(()=>{b&&(E(b),D(b,v))},[b,E,D,v]),Q.useEffect(()=>{if(b)return Et.onGitRefreshHint(e=>{kc(e.directory)===kc(b)&&O(b,v)})},[b,O,v]),Q.useEffect(()=>{W!==`all`&&!G||ae&&(G&&ie(G),M(ae),ee(G===`staged`||!G&&oe),F(K),se(null),De.current=!0,Te.current=ae,Ne(ae),U(e=>e+1))},[W,Ne,ae,K,G,oe,se]),Q.useEffect(()=>{if(W===`all`)return;let e=l?.trim();if(!e)return;Ne(e),M(e),ee(W===`staged`),F(u);let t=tc({scope:W,navigationRequestKey:g,targetFilePath:e,targetLine:u}),n=Be.some(t=>t.path===e);nc(je.current,t,n)&&(je.current=t,De.current=!0,Te.current=e,U(e=>e+1))},[W,Be,Ne,g,l,u]),Q.useEffect(()=>{A&&(Be.some(e=>e.path===A)||(M(null),ee(!1)))},[Be,A]);let Xe=Q.useCallback((e,t)=>{let n=we.current;t?n.set(e,t):n.delete(e),qe()},[qe]),Ze=Q.useCallback((e,t)=>{Me(),z(n=>{if(t===n.has(e))return n;let r=new Set(n);return t?r.add(e):r.delete(e),r}),t||B(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),qe()},[Me,qe]),Qe=Q.useCallback(()=>{Me(),z(e=>e.size>0?new Set:new Set(Be.map(e=>e.path))),B(new Set),qe()},[Me,Be,qe]),$e=Q.useCallback(e=>{let t=we.current.get(e),n=Ce.current;if(!t||!n)return!1;let r=n.getBoundingClientRect(),i=t.getBoundingClientRect().top-r.top,a=Math.max(0,n.scrollHeight-n.clientHeight);return n.scrollTop=Math.min(a,Math.max(0,n.scrollTop+i)),!0},[]);Q.useEffect(()=>{if(!Te.current)return;let e=0,t=!1,r=()=>{t||(t=!0,Te.current=null,De.current=!1,L(null),Ee.current!==null&&(window.cancelAnimationFrame(Ee.current),Ee.current=null))},i=()=>{if(t){Ee.current=null;return}let a=Te.current;if(!a){r(),Ee.current=null;return}if(!$e(a)){e+=1,e<20?Ee.current=window.requestAnimationFrame(i):(r(),Ee.current=null);return}n&&De.current&&L(a),r()};return Ee.current=window.requestAnimationFrame(i),()=>{t=!0,Ee.current!==null&&(window.cancelAnimationFrame(Ee.current),Ee.current=null)}},[n,re,$e]);let et=Q.useCallback(e=>{},[]),tt=Q.useCallback(e=>{Me(),M(e),ee(!1),De.current=!0,Te.current=e,Ne(e),U(e=>e+1),$e(e)},[Me,Ne,$e]),nt=Q.useCallback(e=>{let t=e===`side-by-side`?`side-by-side`:`inline`;Ge.forEach(e=>{le(e.path,t)})},[le,Ge]),[rt,it]=Q.useState(null),at=Q.useCallback(async(e,t)=>{if(!(!b||!e)){it(e);try{let n=null;if(t?.patch&&!t.isBinary&&!Er(e)?n=$s(t.patch):t&&t.contextMode===`full`&&!t.isBinary&&!Er(e)&&(n=Ac(t.original,t.modified)),n===null)try{n=$s((await v.getGitDiff(b,{path:e,staged:xe,contextLines:3})).diff)}catch{n=null}let r=t;if(n===null||!r){let t=await v.getGitFileDiff(b,{path:e,staged:xe});r={original:t.original??``,modified:t.modified??``,isBinary:t.isBinary},xe||k(b,e,r)}let i=n??(r.isBinary||Er(e)?1:Ac(r.original,r.modified)),a=Oc(b,e);fe(b,a,i,1)}finally{it(t=>t===e?null:t)}}},[xe,b,v,fe,k]),ot=J(e=>{if(!b||!e)return;let t=Oc(b,e);if(me){me.openFile({path:t});return}pe(b,t)}),st=()=>{if(!b)return null;let e=e=>ye===null?N&&e===A:ye;return(0,$.jsxs)(`div`,{className:Y(`flex min-w-0 flex-1 min-h-0 h-full`,f?`gap-0`:`gap-3 px-3 pb-3 pt-2`),children:[Se&&(0,$.jsxs)(`section`,{className:`hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-b border-border/40`,children:[(0,$.jsx)(`span`,{className:`typography-code font-semibold text-foreground`,children:_(`diffView.section.files`)}),(0,$.jsx)(`span`,{className:`typography-code text-muted-foreground`,children:Be.length})]}),(0,$.jsx)(Rc,{changedFiles:Be,selectedFile:null,onSelectFile:tt})]}),(0,$.jsx)(`div`,{className:`relative flex-1 min-w-0 min-h-0 h-full`,children:(0,$.jsx)(Yr,{ref:Ce,outerClassName:`min-h-0 h-full`,className:`[overflow-anchor:none] pb-16 pwa-overlay-scroll`,disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:(0,$.jsx)(`div`,{className:`flex flex-col [overflow-anchor:none]`,"data-diff-virtual-content":!0,children:Ge.map(t=>(0,$.jsx)(Uc,{directory:b,file:t,layout:Je(t),wrapLines:ve,isSelected:!1,isExpanded:R.has(t.path),isMounted:te.has(t.path)||t.path===I||p&&Ge.length===1,onSelect:et,onExpandedChange:Ze,registerSectionRef:Xe,showOpenInEditorAction:r&&W!==`turn`,isOpeningInEditor:rt===t.path,onOpenInEditor:(e,t)=>{at(e,t)},onOpenFile:ot,staged:e(t.path),loadFullFiles:V,preloadFullFiles:h,initialDiffData:W===`turn`?ze.get(t.path)??null:null,focusLine:t.path===(l?.trim()||A)?u??P:null,showFileActions:W!==`turn`,disableGitFetch:W===`turn`,turnChangesRequest:Le,loadTurnChangeFile:W===`turn`&&!Ie},t.path))})})})]})},ct=()=>b?W!==`turn`&&T&&!w?(0,$.jsxs)(`div`,{className:`flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(Z,{name:`loader-4`,className:`size-4 animate-spin`}),_(`diffView.state.loadingRepositoryStatus`)]}):W!==`turn`&&C===!1?(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:_(`diffView.state.notGitRepository`)}):Ge.length===0?(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:_(W===`turn`?`diffView.state.noLastTurnChanges`:`diffView.state.cleanWorkingTree`)}):st():(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:_(`diffView.state.selectSessionDirectory`)}),lt=p?null:(0,$.jsxs)($.Fragment,{children:[!S&&!m&&(W===`working`||W===`staged`||W===`turn`?(0,$.jsx)(Lc,{scope:W,workingCount:Ve,stagedCount:He,turnCount:Ue,onScopeChange:e=>{ie(e),c?.(e)}}):(0,$.jsx)(`div`,{className:`flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0`,children:(0,$.jsx)(`span`,{className:`typography-code font-semibold text-foreground`,children:T&&!w?_(`diffView.state.loadingChanges`):Ge.length===1?_(`diffView.summary.changedFilesSingle`,{count:Ge.length}):_(`diffView.summary.changedFilesPlural`,{count:Ge.length})})})),!p&&Be.length>0&&(W!==`turn`||Ie)&&(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:Qe,className:Y(`diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground`,`ml-auto`),title:R.size>0?_(`diffView.actions.collapseAll`):_(`diffView.actions.expandAll`),children:[(0,$.jsx)(Z,{name:`expand-up-down`,className:`size-4`}),(0,$.jsx)(`span`,{className:Y(`diff-toolbar__expand-label typography-code`,m&&`hidden`),children:R.size>0?_(`diffView.actions.collapseAll`):_(`diffView.actions.expandAll`)})]}),Be.length>0&&W!==`turn`&&(0,$.jsxs)(An,{children:[(0,$.jsx)(On,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`sm`,onClick:()=>H(e=>!e),"aria-pressed":V,"aria-label":_(V?`diffView.actions.disableFullFiles`:`diffView.actions.loadFullFiles`),className:Y(`h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground`,V&&`bg-interactive-selection text-interactive-selection-foreground`),children:(0,$.jsx)(Z,{name:`file-download`,className:`size-4`})})}),(0,$.jsx)(kn,{children:(0,$.jsx)(`p`,{children:_(V?`diffView.actions.disableFullFiles`:`diffView.actions.loadFullFiles`)})})]}),Be.length>0&&(0,$.jsx)(X,{variant:`ghost`,size:`sm`,onClick:()=>de(!ue),className:Y(`h-5 w-5 p-0 transition-opacity`,ve?`text-foreground opacity-100`:`text-muted-foreground opacity-60 hover:opacity-100`),title:_(ve?`diffView.actions.disableLineWrap`:`diffView.actions.enableLineWrap`),children:(0,$.jsx)(Z,{name:`text-wrap`,className:`size-4`})}),Ye&&(0,$.jsx)(di,{mode:Ye===`side-by-side`?`side-by-side`:`unified`,onModeChange:nt})]});return(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background`,children:[lt?m?(0,$.jsx)(cr,{children:lt}):(0,$.jsx)(`div`,{className:`@container/diff-toolbar flex min-w-0 items-center gap-1.5 px-2 py-1.5 bg-background`,children:lt}):null,ct()]})};function Gc(e,t){if(!t||e.has(t))return e;let n=new Set(e);return n.add(t),n}function Kc(e){return Fe(e?.enabled??!0)}function qc(e){let t=(0,qi.c)(3),n=e?.includeCurrentSession??!0,r=Kc(e),i=bt(Jc),a;bb0:{if(!n){a=r;break bb0}let e;t[0]!==i||t[1]!==r?(e=Gc(r,i),t[0]=i,t[1]=r,t[2]=e):e=t[2],a=e}return a}function Jc(e){return e.currentSessionId}var Yc=e=>Object.fromEntries(e.map(e=>[e.id,ze(e)])),Xc=(e,t,n,r)=>{if(!t||t.length===0||!r)return[];let i=new Set(e),a=new Set(t),o=[...t.filter(e=>i.has(e)),...e.filter(e=>!a.has(e))];if(o.length===0)return[];if(Qe(n,r))return o;let s=e=>{let t=r[e];return t===void 0?!a.has(e):(n[e]??0)>t},c=[],l=[];if(o.forEach(e=>{s(e)?c.push(e):l.push(e)}),c.length===0)return o;let u=new Map(o.map((e,t)=>[e,t]));return c.sort((e,t)=>{let r=(n[t]??0)-(n[e]??0);return r===0?(u.get(e)??0)-(u.get(t)??0):r}),[...c,...l]},Zc=(e,t,n)=>{let r=Yc(e.map(e=>e.session)),i=Xc(e.map(e=>e.session.id),t,r,n);return new Map(i.map((e,t)=>[e,t]))},Qc=(e,t,n,r)=>{let i=Zc(e,t,n);return(e,t)=>{let n=i.get(e.session.id),a=i.get(t.session.id);if(n!==void 0||a!==void 0){if(n===void 0)return 1;if(a===void 0)return-1;if(n!==a)return n-a}return Wn(e.session,t.session,r)}},$c=({folders:e,visibleUngroupedNodes:t,collapsedFolderIds:n,hasSessionSearchQuery:r})=>{let i=new Map(e.map(e=>[e.folder.id,e])),a=new Map;e.forEach(({folder:e})=>{let t=e.parentId??null,n=a.get(t)??[];n.push(e.id),a.set(t,n)});let o=[],s=new Map,c=e=>{let t=i.get(e);t&&(!r&&n.has(e)||((a.get(e)??[]).forEach(c),t.nodes.forEach(t=>{o.push(t.session.id),s.set(t.session.id,e)})))};return(a.get(null)??[]).forEach(c),t.forEach(e=>{o.push(e.session.id),s.set(e.session.id,null)}),{sessionIds:o,folderIdBySessionId:s}},el=(e,t,n)=>n.get(e)===n.get(t),tl=e=>!!e.parentID,nl=(e,t)=>W(ot(e.session))??W(t.directory??null),rl=()=>3,il=(e,t,n,r)=>{let i=Math.min(e.length,Math.max(0,t)),a=e.slice(0,i);for(let t=i;t<e.length;t+=1){let i=e[t];i&&n.has(r(i))&&a.push(i)}return a},al=(e,t,n)=>il(e,t,n,e=>e.session.id),ol=(e,t,n)=>il(e,t,n,e=>e.id),sl=({targets:e,collapsedProjectIds:t,collapsedGroupKeys:n,collapsedFolderIds:r,visibleSessionCountByGroup:i,defaultVisibleSessionCount:a,hasSessionSearchQuery:o,alwaysVisibleSessionIds:s})=>e.filter(e=>{if(!e.projectId||t.has(e.projectId))return!1;if(o)return!0;if(e.groupKey&&n.has(e.groupKey)||e.folderAncestorIds?.some(e=>r.has(e)))return!1;if(e.groupKey&&e.visibleIndex!==void 0){let t=Math.max(a,i.get(e.groupKey)??a);if(e.visibleIndex>=t&&!s?.has(e.sessionId))return!1}return!0}),cl=(e,t,n)=>{if(!t||n==null||!Number.isInteger(n)||n<0)return null;if(e[n]?.session.id===t)return n;let r=e.findIndex(e=>e.session.id===t);return r>=0?r:null},ll=({sections:e,foldersMap:t,getOrderedGroups:n,pinnedSessionIds:r,sessionOrderByScope:i,sessionOrderActivityByScope:a})=>{let o=[];return e.forEach(e=>{let s=n(e.project.id,e.groups),c=s.find(e=>e.isMain)??null;(c?[c,...s.filter(e=>e.id!==c.id)]:s).forEach(n=>{if(n.isArchivedBucket)return;let s=`${e.project.id}:${n.id}`,c=n.folderScopeKey??W(n.directory??null),l=Qc(n.sessions,c?i[c]:void 0,c?a[c]:void 0,r),u=[...n.sessions].filter(e=>!e.session.time?.archived&&!tl(e.session)).sort(l),d=new Map(u.map(e=>[e.session.id,e])),f=c?t[c]??[]:[],p=new Map;f.forEach(e=>{let t=e.parentId??null,n=p.get(t)??[];n.push(e),p.set(t,n)});let m=new Set(f.flatMap(e=>e.sessionIds)),h=(t,r,i)=>{o.push({scope:`project`,sessionId:t.session.id,projectId:e.project.id,directory:nl(t,n),groupKey:s,folderAncestorIds:r,visibleIndex:i})},g=(e,t)=>{let n=f.find(t=>t.id===e);if(!n)return;let r=[...t,n.id];(p.get(n.id)??[]).forEach(e=>{g(e.id,r)}),n.sessionIds.map(e=>d.get(e)).filter(e=>!!e).sort(l).forEach(e=>h(e,r))};(p.get(null)??[]).forEach(e=>g(e.id,[])),u.filter(e=>!m.has(e.session.id)).forEach((e,t)=>h(e,void 0,t))})}),o},ul=b()(x(e=>({expandedWorktreeGroups:{},setWorktreeGroupExpanded:(t,n)=>e(e=>({expandedWorktreeGroups:{...e.expandedWorktreeGroups,[t]:n}}))}),{name:`mobile-session-statusbar-collapse`,storage:N()}));typeof window<`u`&&t(e=>{o(e)&&ul.persist.rehydrate()});var dl=e=>{let t=(0,qi.c)(24),{size:n,className:r}=e,i=n===void 0?14:n,a=(i-1.5)/2,o=2*Math.PI*a,s=o*.28,c;t[0]===r?c=t[1]:(c=Y(`inline-flex items-center justify-center shrink-0`,r),t[0]=r,t[1]=c);let l;t[2]===i?l=t[3]:(l={width:i,height:i},t[2]=i,t[3]=l);let u=`0 0 ${i} ${i}`,d;t[4]===i?d=t[5]:(d={width:i,height:i},t[4]=i,t[5]=d);let f=i/2,p=i/2,m;t[6]!==a||t[7]!==f||t[8]!==p?(m=(0,$.jsx)(`circle`,{cx:f,cy:p,r:a,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:1.5}),t[6]=a,t[7]=f,t[8]=p,t[9]=m):m=t[9];let h=i/2,g=i/2,_=`${s} ${o-s}`,v;t[10]!==a||t[11]!==g||t[12]!==_||t[13]!==h?(v=(0,$.jsx)(`circle`,{cx:h,cy:g,r:a,fill:`none`,stroke:`var(--surface-muted-foreground)`,strokeWidth:1.5,strokeLinecap:`round`,strokeDasharray:_}),t[10]=a,t[11]=g,t[12]=_,t[13]=h,t[14]=v):v=t[14];let y;t[15]!==v||t[16]!==u||t[17]!==d||t[18]!==m?(y=(0,$.jsxs)(`svg`,{viewBox:u,className:`animate-spin yuri-busy-ring`,style:d,"aria-hidden":`true`,children:[m,v]}),t[15]=v,t[16]=u,t[17]=d,t[18]=m,t[19]=y):y=t[19];let b;return t[20]!==y||t[21]!==c||t[22]!==l?(b=(0,$.jsx)(`span`,{className:c,style:l,"aria-hidden":`true`,children:y}),t[20]=y,t[21]=c,t[22]=l,t[23]=b):b=t[23],b};dl.displayName=`SessionBusyIndicator`;function fl({durationMs:e,size:t=15,className:n}){let r=1.5,i=(t-r)/2,a=2*Math.PI*i,[o,s]=Q.useState(!1),[c,l]=Q.useState(()=>Math.max(0,Math.ceil(e/1e3)-1));return Q.useEffect(()=>{let t=performance.now(),n=window.requestAnimationFrame(()=>s(!0)),r=window.setInterval(()=>{let n=performance.now()-t;l(Math.max(0,Math.ceil((e-n)/1e3)-1))},250);return()=>{window.cancelAnimationFrame(n),window.clearInterval(r)}},[e]),(0,$.jsxs)(`span`,{className:Y(`yuri-undo-countdown`,n),style:{"--yuri-undo-countdown-size":`${t}px`},"aria-hidden":`true`,children:[(0,$.jsxs)(`svg`,{viewBox:`0 0 ${t} ${t}`,width:t,height:t,className:`yuri-undo-countdown-svg`,children:[(0,$.jsx)(`circle`,{cx:t/2,cy:t/2,r:i,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:r}),(0,$.jsx)(`circle`,{cx:t/2,cy:t/2,r:i,fill:`none`,stroke:`var(--primary-base)`,strokeWidth:r,strokeLinecap:`round`,strokeDasharray:a,strokeDashoffset:o?a:0,style:{transition:`stroke-dashoffset ${e}ms linear`}})]}),(0,$.jsx)(`span`,{className:`yuri-undo-countdown-digit text-current`,children:c})]})}function pl(){j.getState().setArchivedSessionsDialogOpen(!0)}function ml(e){yt.custom(t=>Q.createElement(`div`,{className:`flex w-full min-w-0 max-w-full items-center gap-2.5 text-foreground`},Q.createElement(`span`,{className:`min-w-0 flex-1 truncate text-left typography-ui-label font-medium`},e.message),Q.createElement(`div`,{className:`flex shrink-0 items-center gap-1.5`},e.secondaryLabel&&e.onSecondary?Q.createElement(X,{variant:`ghost`,size:`sm`,className:`session-mutation-undo-action overflow-hidden !h-[26px] !min-h-0 !min-w-0 shrink-0 !px-2 !text-[12px]`,onClick:()=>{e.onSecondary?.(),yt.dismiss(t)}},e.secondaryLabel):null,Q.createElement(X,{variant:`ghost`,size:`sm`,className:`session-mutation-undo-action overflow-hidden !h-[26px] !min-h-0 !min-w-0 shrink-0 gap-1 !pl-2 !pr-1 !text-[12px]`,onClick:()=>{e.onPrimary(),yt.dismiss(t)}},e.primaryLabel,Q.createElement(fl,{durationMs:e.durationMs})))),{duration:e.durationMs,className:`session-mutation-undo-toast !max-w-[calc(100vw-2rem)]`})}function hl(e){let t=Array.from(new Set(e.sessionIds.filter(Boolean)));t.length!==0&&ml({durationMs:Ue,message:e.message,primaryLabel:e.undoLabel,onPrimary:()=>{(async()=>{(await Promise.all(t.map(e=>Tt(e)))).some(e=>!e)&&yt.error(e.undoFailedMessage)})()},secondaryLabel:e.settingsLabel,onSecondary:()=>{pl()}})}function gl(e){let t=Array.from(new Set(e.sessionIds.filter(Boolean)));if(t.length===0)return{batchId:``,scheduledIds:[]};let n=e.delayMs??1e4,{batchId:r,scheduledIds:i}=Pe(t,{delayMs:n,onSettled:({failedIds:t})=>{t.length>0&&yt.error(e.commitFailedMessage)}});return r&&ml({durationMs:n,message:e.message,primaryLabel:e.undoLabel,onPrimary:()=>{Le(r)}}),{batchId:r,scheduledIds:i}}var _l=500,vl=12,yl=(e={})=>{let t=e.delayMs??_l,n=(e.moveThresholdPx??vl)**2,r=e.schedule??((e,t)=>setTimeout(e,t)),i=e.clear??(e=>clearTimeout(e)),a=null,o=null,s=(t=!1)=>{a&&(i(a.timer),a=null,t||e.onPressedKeyChange?.(null))};return{start:({pointerId:n,key:i,clientX:c,clientY:l,onTrigger:u})=>{s(),e.onPressedKeyChange?.(i),a={pointerId:n,key:i,startX:c,startY:l,timer:r(()=>{!a||a.pointerId!==n||a.key!==i||(a.triggered=!0,o=i,u())},t),triggered:!1}},move:(e,t,r)=>{if(a?.pointerId!==e||a.triggered)return;let i=t-a.startX,o=r-a.startY;i*i+o*o>n&&s()},end:e=>{a?.pointerId===e&&s(a.triggered)},cancel:e=>{a?.pointerId===e&&s()},openFromContextMenu:(t,n)=>{s(),o=t,e.onPressedKeyChange?.(t),n()},consumeClick:e=>o===e&&(o=null,!0),reset:()=>{s(),o=null,e.onPressedKeyChange?.(null)}}},bl=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/,``),xl=e=>{let t=e;return bl(t.directory??t.project?.worktree??null)},Sl=({open:e,project:t,worktree:n,onClose:r,onDeleted:i})=>{let{t:a}=be(),o=nt(),s=Ze(e=>e.activeSessions),c=bt(e=>e.archiveSessions),l=D(e=>e.currentDirectory),[u,d]=Q.useState(!1),[f,p]=Q.useState(!1),[m,h]=Q.useState(!1),[g,_]=Q.useState(!1),v=bl(n?.path),y=typeof n?.branch==`string`&&n.branch.trim().length>0,b=Q.useMemo(()=>{if(!v)return[];let e=new Map;for(let t of[...s,...o])xl(t)===v&&e.set(t.id,t);return Array.from(e.values())},[s,o,v]);Q.useEffect(()=>{if(!e){d(!1),p(!1),h(!1),_(!1);return}if(!n?.path)return;let t=!1;return ii(n.path).then(e=>{t||h(!!e?.isDirty)}).catch(()=>{t||h(!!n.status?.isDirty)}),()=>{t=!0}},[e,n?.path,n?.status?.isDirty]);let x=J(e=>{(async()=>{try{await ni(e.project,e.worktree,{deleteRemoteBranch:e.hasBranch&&e.deleteRemoteBranch,deleteLocalBranch:e.hasBranch&&e.deleteLocalBranch}),bl(e.currentDirectory)===e.worktreePath&&bl(e.project.path)&&D.getState().setDirectory(bl(e.project.path),{showOverlay:!1}),yt.success(e.t(`sessions.sidebar.sessionDialogs.worktree.removedTitle`),{description:e.hasBranch&&e.deleteRemoteBranch?e.t(`sessions.sidebar.sessionDialogs.worktree.removedWithRemote`):e.t(`sessions.sidebar.sessionDialogs.worktree.removed`)}),e.onDeleted?.()}catch(t){yt.error(e.t(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:t instanceof Error?t.message:e.t(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}})()}),S=async()=>{if(!n||g)return;let o={worktree:n,project:t,hasBranch:y,deleteLocalBranch:u,deleteRemoteBranch:f,currentDirectory:l,worktreePath:v,onDeleted:i,archiveSessions:c,linkedSessionIds:b.map(e=>e.id),onClose:r,open:e,t:a};_(!0);try{if(o.linkedSessionIds.length>0){let{archivedIds:e,failedIds:t}=await o.archiveSessions(o.linkedSessionIds);if(t.length>0){e.length>0&&yt.success(e.length===1?o.t(`sessions.sidebar.bulkActions.archivedSingle`,{count:e.length}):o.t(`sessions.sidebar.bulkActions.archivedPlural`,{count:e.length})),yt.error(t.length===1?o.t(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:t.length}):o.t(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:t.length}),{description:o.t(`sessions.sidebar.dialogs.deleteResult.tryAgain`)}),_(!1);return}}x(o),o.onClose()}catch(e){yt.error(o.t(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:e instanceof Error?e.message:o.t(`sessions.sidebar.dialogs.deleteResult.tryAgain`)}),_(!1)}finally{o.open||_(!1)}};if(!n)return null;let C=n.branch||n.label||n.path,w=(e,t,n,r)=>(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":e,disabled:r,onClick:()=>t(!e),className:Y(`flex w-full items-center justify-between gap-3 rounded-xl border border-border/50 px-3.5 py-3 text-left transition-colors`,`hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r&&`pointer-events-none opacity-40`),style:{touchAction:`manipulation`},children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n}),(0,$.jsx)(`span`,{className:Y(`relative h-6 w-10 shrink-0 rounded-full transition-colors`,e?`bg-primary`:`bg-muted-foreground/30`),children:(0,$.jsx)(`span`,{className:Y(`absolute top-0.5 size-5 rounded-full bg-white transition-transform`,e?`translate-x-[1.125rem]`:`translate-x-0.5`)})})]});return(0,$.jsx)(Mn,{open:e,onClose:r,title:a(`mobile.projectEdit.deleteWorktreeTitle`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(X,{variant:`ghost`,className:`flex-1`,onClick:r,disabled:g,children:a(`projectEditDialog.actions.cancel`)}),(0,$.jsx)(X,{variant:`destructive`,className:`flex-1`,onClick:()=>void S(),disabled:g,children:a(`mobile.projectEdit.deleteWorktreeConfirmButton`)})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-1 py-1`,children:[(0,$.jsx)(`p`,{className:`typography-ui-body text-foreground`,children:a(`mobile.projectEdit.deleteWorktreeConfirm`,{name:C})}),m?(0,$.jsx)(`p`,{className:`rounded-xl border border-[var(--warning)]/40 bg-[color-mix(in_srgb,var(--warning)_10%,transparent)] px-3.5 py-3 typography-meta text-foreground`,children:a(`mobile.projectEdit.deleteWorktreeDirty`)}):null,b.length>0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:a(`mobile.projectEdit.deleteWorktreeArchiveNote`,{count:b.length})}):null,y?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[w(u,d,a(`mobile.projectEdit.deleteLocalBranch`),g),w(f,p,a(`mobile.projectEdit.deleteRemoteBranch`),g)]}):null]})})},Cl=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/,``),wl=e=>{let t=(0,qi.c)(36),{worktree:n,onDelete:r}=e,{t:i}=be(),a;t[0]===n.path?a=t[1]:(a={id:n.path},t[0]=n.path,t[1]=a);let{attributes:o,listeners:s,setNodeRef:c,transform:l,transition:u,isDragging:d}=Gr(a),f;t[2]===l?f=t[3]:(f=Ur.Transform.toString(l),t[2]=l,t[3]=f);let p=d?10:1,m;t[4]!==f||t[5]!==p||t[6]!==u?(m={transform:f,transition:u,zIndex:p},t[4]=f,t[5]=p,t[6]=u,t[7]=m):m=t[7];let h=m,g=n.branch||n.label||n.path,_=d&&`shadow-lg shadow-black/20`,v;t[8]===_?v=t[9]:(v=Y(`flex items-center gap-1 rounded-2xl border border-border/40 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors`,_),t[8]=_,t[9]=v);let y;t[10]!==g||t[11]!==i?(y=i(`mobile.projectEdit.dragWorktreeAria`,{label:g}),t[10]=g,t[11]=i,t[12]=y):y=t[12];let b;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(Z,{name:`drag-move-2`,className:`size-4`}),t[13]=b):b=t[13];let x;t[14]!==o||t[15]!==s||t[16]!==y?(x=(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing`,"aria-label":y,...o,...s,children:b}),t[14]=o,t[15]=s,t[16]=y,t[17]=x):x=t[17];let S;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(Z,{name:`node-tree`,className:`size-4 shrink-0 text-muted-foreground`}),t[18]=S):S=t[18];let C;t[19]===g?C=t[20]:(C=(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:g}),t[19]=g,t[20]=C);let w;t[21]!==g||t[22]!==i?(w=i(`mobile.projectEdit.deleteWorktreeAria`,{label:g}),t[21]=g,t[22]=i,t[23]=w):w=t[23];let T,E;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(T={touchAction:`manipulation`},E=(0,$.jsx)(Z,{name:`delete-bin`,className:`size-4`}),t[24]=T,t[25]=E):(T=t[24],E=t[25]);let D;t[26]!==r||t[27]!==w?(D=(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive`,"aria-label":w,onClick:r,style:T,children:E}),t[26]=r,t[27]=w,t[28]=D):D=t[28];let O;return t[29]!==c||t[30]!==h||t[31]!==C||t[32]!==D||t[33]!==v||t[34]!==x?(O=(0,$.jsxs)(`div`,{ref:c,style:h,className:v,children:[x,S,C,D]}),t[29]=c,t[30]=h,t[31]=C,t[32]=D,t[33]=v,t[34]=x,t[35]=O):O=t[35],O},Tl=({open:e,project:t,onClose:n,onWorktreesChanged:r})=>{let{t:i}=be(),{currentTheme:a}=Lt(),o=ct(e=>e.updateProjectMeta),s=ct(e=>e.discoverProjectIcon),c=ct(e=>e.removeProjectIcon),l=pt(e=>e.setWorktreeOrder),u=ct(e=>t?e.projects.find(e=>e.id===t.id)?.iconImage??null:null),[d,f]=Q.useState(``),[p,m]=Q.useState(null),[h,g]=Q.useState(null),[_,v]=Q.useState(!1),[y,b]=Q.useState([]),[x,S]=Q.useState(null),C=t?.id??null;Q.useEffect(()=>{!e||!t||(f(t.label),m(t.icon??null),g(t.color??null),b(t.worktrees))},[e,C]),Q.useEffect(()=>{!e||!t||b(e=>{let n=t.worktrees.map(e=>e.path),r=e.map(e=>e.path);return n.length===r.length&&n.every(e=>r.includes(e))?e:t.worktrees})},[t?.worktrees]);let w=Hr(Nr(Br,{activationConstraint:{distance:8}}),Nr(Ir,{coordinateGetter:Wr})),T=()=>{if(!t)return;let e=d.trim();o(t.id,{label:e||t.label,icon:p,color:h}),n()},E=()=>{!t||_||(v(!0),s(t.id).then(e=>{if(!e.ok){yt.error(e.error||i(`projectEditDialog.toast.failedToDiscoverIcon`));return}if(e.skipped){yt.success(i(`projectEditDialog.toast.customIconAlreadySet`));return}yt.success(i(`projectEditDialog.toast.iconDiscovered`))}).finally(()=>v(!1)))},D=()=>{t&&c(t.id).then(e=>{if(!e.ok){yt.error(e.error||i(`projectEditDialog.toast.failedToRemoveIcon`));return}yt.success(i(`projectEditDialog.toast.iconRemoved`))})},O=e=>{let{active:n,over:r}=e;if(!r||n.id===r.id||!t)return;let i=y.findIndex(e=>e.path===n.id),a=y.findIndex(e=>e.path===r.id);if(i<0||a<0)return;let o=[...y],[s]=o.splice(i,1);o.splice(a,0,s),b(o),l(t.id,t.path,o.map(e=>Cl(e.path)))},k=h?ri[h]??null:null,A=p?ti[p]:null,j=!!u;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(dr,{id:`mobile-project-edit`,open:e,onOpenChange:e=>{e||n()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:i(`projectEditDialog.title`)}),trailing:(0,$.jsxs)(X,{type:`button`,variant:`default`,size:`sm`,"aria-label":i(`projectEditDialog.actions.save`),onClick:T,disabled:!d.trim(),style:{touchAction:`manipulation`},children:[(0,$.jsx)(Z,{name:`check`,className:`size-4`}),i(`projectEditDialog.actions.save`)]}),ariaLabel:i(`projectEditDialog.title`),closeAriaLabel:i(`mobile.surface.closeAria`),resizeAriaLabel:i(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:t?(0,$.jsxs)(`div`,{className:`overlay-scrollbar-container h-full space-y-6 overflow-y-auto px-4 pb-8 pt-2`,children:[(0,$.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,$.jsx)(`span`,{className:`flex size-16 items-center justify-center overflow-hidden rounded-2xl bg-[var(--surface-muted)] text-muted-foreground`,style:t.iconBackground?{backgroundColor:t.iconBackground}:void 0,children:j?(0,$.jsx)(Qr,{project:{id:t.id,iconImage:u},options:{themeVariant:a.metadata.variant,iconColor:a.colors.surface.foreground},className:`size-full object-contain`,fallback:(0,$.jsx)(Z,{name:`folder-6`,className:`size-7`})}):A?(0,$.jsx)(Z,{name:A,className:`size-7`,style:k?{color:k}:void 0}):(0,$.jsx)(Z,{name:`folder-6`,className:`size-7`,style:k?{color:k}:void 0})})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:i(`projectEditDialog.field.name`)}),(0,$.jsx)(Dn,{value:d,onChange:e=>f(e.target.value),placeholder:i(`projectEditDialog.field.namePlaceholder`),className:`h-11`}),(0,$.jsx)(`p`,{className:`truncate typography-meta text-muted-foreground`,title:t.path,children:t.path})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:i(`projectEditDialog.field.color`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>g(null),"aria-label":i(`projectEditDialog.option.none`),className:Y(`flex size-9 items-center justify-center rounded-xl border-2 transition-all`,h===null?`border-foreground`:`border-border hover:border-border/80`),style:{touchAction:`manipulation`},children:(0,$.jsx)(`span`,{className:`h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40`})}),si.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>g(e.key),"aria-label":e.label,title:e.label,className:Y(`size-9 rounded-xl border-2 transition-all`,h===e.key?`border-foreground`:`border-transparent hover:border-border`),style:{backgroundColor:e.cssVar,touchAction:`manipulation`}},e.key))]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:i(`projectEditDialog.field.icon`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(null),"aria-label":i(`projectEditDialog.option.none`),className:Y(`flex size-9 items-center justify-center rounded-xl border-2 transition-all`,p===null?`border-foreground bg-[var(--surface-elevated)]`:`border-border hover:border-border/80`),style:{touchAction:`manipulation`},children:(0,$.jsx)(`span`,{className:`h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40`})}),ai.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(e.key),"aria-label":e.label,title:e.label,className:Y(`flex size-9 items-center justify-center rounded-xl border-2 transition-all`,p===e.key?`border-foreground bg-[var(--surface-elevated)]`:`border-border hover:border-border/80`),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:e.Icon,className:`size-4`,style:k?{color:k}:void 0})},e.key))]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[(0,$.jsx)(X,{size:`sm`,variant:`outline`,onClick:E,disabled:_,children:i(_?`projectEditDialog.actions.discovering`:`projectEditDialog.actions.discoverFavicon`)}),j?(0,$.jsx)(X,{size:`sm`,variant:`outline`,onClick:D,children:i(`projectEditDialog.actions.removeProjectIcon`)}):null]})]}),t.isGitRepo?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:i(`mobile.projectEdit.worktreesTitle`)}),y.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:i(`mobile.projectEdit.worktreesEmpty`)}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:i(`mobile.projectEdit.reorderHint`)}),(0,$.jsx)(Vr,{sensors:w,collisionDetection:Lr,onDragEnd:O,children:(0,$.jsx)(qr,{items:y.map(e=>e.path),strategy:Kr,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:y.map(e=>(0,$.jsx)(wl,{worktree:e,onDelete:()=>S(e)},e.path))})})})]})]}):null]}):null}),t?(0,$.jsx)(Sl,{open:!!x,project:{id:t.id,path:t.path},worktree:x,onClose:()=>S(null),onDeleted:()=>{b(e=>e.filter(e=>e.path!==x?.path)),r?.()}}):null]})},El=()=>3,Dl=()=>7,Ol=(e,t,n)=>{let r=new Map;for(let[n,i]of e)t.has(n)&&r.set(n,i);for(let e of n)e.status===`success`&&r.set(e.path,e.worktrees??[]);return $r(r,e)?e:r},kl=(e,t)=>{t&&e.push(t)},Al=e=>{let t=[];return kl(t,e.onRename?{id:`rename`,icon:`pencil-ai`,labelKey:`sessions.sidebar.session.menu.rename`,onClick:e.onRename}:null),kl(t,e.onTogglePin?{id:`pin`,icon:e.pinned?`unpin`:`pushpin`,labelKey:e.pinned?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`,onClick:e.onTogglePin}:null),e.shared?(kl(t,e.onCopyLink?{id:`copyLink`,icon:`file-copy`,labelKey:`sessions.sidebar.session.menu.copyLink`,onClick:e.onCopyLink}:null),kl(t,e.onUnshare?{id:`unshare`,icon:`link-unlink-m`,labelKey:`sessions.sidebar.session.menu.unshare`,onClick:e.onUnshare}:null)):kl(t,e.onShare?{id:`share`,icon:`share-2`,labelKey:`sessions.sidebar.session.menu.share`,onClick:e.onShare}:null),kl(t,e.onRefreshTranscript?{id:`refreshTranscript`,icon:`refresh`,labelKey:`sessions.sidebar.session.menu.refreshTranscript`,onClick:e.onRefreshTranscript,disabled:e.refreshTranscriptDisabled,spinning:e.refreshTranscriptSpinning}:null),kl(t,e.onArchive?{id:`archive`,icon:`archive`,labelKey:`sessions.sidebar.bulkActions.archive`,onClick:e.onArchive}:null),kl(t,e.onDelete?{id:`delete`,icon:`delete-bin`,labelKey:`sessions.sidebar.bulkActions.delete`,onClick:e.onDelete,destructive:!0,separated:!0}:null),e.extraItems?.length&&t.push(...e.extraItems),t},jl=e=>{let t=[];return kl(t,e.onNewSession?{id:`newSession`,icon:`add`,labelKey:`sessions.sidebar.project.actions.newSession`,onClick:e.onNewSession}:null),kl(t,e.gitRepository&&e.onNewWorktree?{id:`newWorktree`,icon:`node-tree`,labelKey:`sessions.sidebar.project.actions.newWorktree`,onClick:e.onNewWorktree}:null),kl(t,e.onSyncSessions?{id:`syncSessions`,icon:`refresh`,labelKey:`sessions.sidebar.project.actions.syncSessions`,onClick:e.onSyncSessions}:null),kl(t,e.onEditProject?{id:`edit`,icon:`pencil-ai`,labelKey:`sessions.sidebar.project.actions.edit`,onClick:e.onEditProject}:null),kl(t,e.onCloseProject?{id:`closeProject`,icon:`close`,labelKey:`sessions.sidebar.project.actions.closeProject`,onClick:e.onCloseProject,destructive:!0,separated:!0}:null),e.extraItems?.length&&t.push(...e.extraItems),t},Ml=e=>{let t=[];return kl(t,e.onNewSession?{id:`newSession`,icon:`add`,labelKey:`sessions.sidebar.project.actions.newSession`,onClick:e.onNewSession}:null),kl(t,e.onDeleteWorktree?{id:`deleteWorktree`,icon:`delete-bin`,labelKey:`mobile.projectEdit.deleteWorktreeConfirmButton`,onClick:e.onDeleteWorktree,destructive:!0,separated:!0}:null),e.extraItems?.length&&t.push(...e.extraItems),t},Nl=(e,t)=>t(e.labelKey),Pl=[],Fl=(e,t)=>{let n=e?.[t];return n?.type===`busy`||n?.type===`retry`?n.type:`idle`},Il=e=>{let t=new Set(e.map(e=>e.id)),n=new Map;for(let r of e){let e=r.parentID;if(e&&t.has(e)){let t=n.get(e)??[];t.push(r),n.set(e,t)}}return{allIds:t,parentChildMap:n}},Ll=(e,t)=>{let n=e.parentID;return!n||!t.has(n)};function Rl(e,t,n){let{allIds:r,parentChildMap:i}=Il(e),a=0,o=0;for(let s of e){if(!Ll(s,r))continue;let e=Fl(t,s.id),c=(i.get(s.id)??[]).filter(e=>Fl(t,e.id)!==`idle`).length;a+=(e===`idle`?0:1)+c,(n?.[s.id]??0)>0&&(o+=1)}return{totalRunning:a,totalUnread:o}}function zl(e,t,n,r,i){if(!r){let r=Rl(e,t,n);return{sessions:Pl,totalRunning:r.totalRunning,totalUnread:r.totalUnread,totalCount:0}}let{allIds:a,parentChildMap:o}=Il(e),s=e.filter(e=>Ll(e,a)),c=[],l=[];for(let e of s){let r=Fl(t,e.id),i=(o.get(e.id)??[]).filter(e=>Fl(t,e.id)!==`idle`),a=i.length>0,s=(n?.[e.id]??0)>0,u={...e,_statusType:r,_hasRunningChildren:a,_runningChildrenCount:i.length,_childIndicators:i.slice(0,3).map(e=>({session:e,isRunning:!0}))};r!==`idle`||a||s?c.push(u):l.push(u)}let u=(e,t)=>i(t)-i(e);c.sort(u),l.sort(u);let d=[...c,...l];return{sessions:d,totalRunning:d.reduce((e,t)=>e+(t._statusType===`idle`?0:1)+(t._runningChildrenCount??0),0),totalUnread:d.filter(e=>(n?.[e.id]??0)>0).length,totalCount:d.length}}function Bl(){let e=(0,qi.c)(3),t=nt(),n=Ze(Ul),r;if(e[0]!==n||e[1]!==t){let i=new Map(t.map(Hl));r=n.map(e=>{let t=i.get(e.id);return t?Ke(t,e):e});let a=new Set(r.map(Vl));for(let e of t)a.has(e.id)||r.push(e);e[0]=n,e[1]=t,e[2]=r}else r=e[2];return r}function Vl(e){return e.id}function Hl(e){return[e.id,e]}function Ul(e){return e.activeSessions}var Wl=`__pinned_sessions__`;function Gl(e){return e===null||e===Wl}function Kl(e){let{activeProjectId:t,currentFilterProjectId:n,projects:r}=e;return n===null?null:n===Wl||r.some(e=>e.id===n)?n:t??n}var ql=3,Jl=7,Yl=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.replace(/\/+$/,``)},Xl=e=>{let t=e;return Yl(t.directory??t.project?.worktree??``)},Zl=e=>{let t=new Set(e.map(e=>e.id));return e.filter(e=>{let n=e.parentID;return!n||!t.has(n)}).length};function Ql(e){e.preventBaseUIHandler()}function $l(e,t,n){t&&(e.preventBaseUIHandler(),n(e))}function eu(e){let t=(0,qi.c)(10),{icon:n,label:r,onClick:i,destructive:a}=e,o=a!==void 0&&a?`destructive`:`ghost`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,$.jsx)(Z,{name:n,className:`size-5 shrink-0`}),t[1]=n,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[3]=r,t[4]=l);let u;return t[5]!==i||t[6]!==o||t[7]!==c||t[8]!==l?(u=(0,$.jsxs)(X,{type:`button`,variant:o,size:`default`,className:`min-h-12 w-full justify-start gap-3 rounded-xl px-3`,onClick:i,style:s,children:[c,l]}),t[5]=i,t[6]=o,t[7]=c,t[8]=l,t[9]=u):u=t[9],u}function tu(e,t,n,r){let i=dt(e=>e.index.session.unseenCount),a=Q.useRef([]);return Q.useMemo(()=>{let o=zl(e,t,i,n,ze);return n?(a.current=o.sessions,o):r?{...o,sessions:a.current,totalCount:a.current.length}:(a.current=[],o)},[n,r,e,t,i])}function nu(){let e=(0,qi.c)(7),{t}=be(),n;e[0]===t?n=e[1]:(n=e=>{let n=e.title;return n&&n.trim()?n:t(`mobile.sessions.newChat`)},e[0]=t,e[1]=n);let r=n,i=dt(ru),a;e[2]===i?a=e[3]:(a=e=>(i[e]??0)>0,e[2]=i,e[3]=a);let o=a,s;return e[4]!==r||e[5]!==o?(s={getSessionTitle:r,needsAttention:o},e[4]=r,e[5]=o,e[6]=s):s=e[6],s}function ru(e){return e.index.session.unseenCount}function iu(e,t,n){let r=(0,qi.c)(6),i=bt(su),a=bt(ou),o=dt(au),s;return r[0]!==i||r[1]!==n||r[2]!==a||r[3]!==o||r[4]!==t?(s=e=>{let r=e=>{let n=t?.[e];return n?.type===`busy`||n?.type===`retry`?n.type:`idle`},s=Yl(e);if(!s)return{hasRunning:!1,hasUnread:!1};let c=[s],l=i.get(s)??[];for(let e of l){let t=e&&typeof e==`object`&&`path`in e?e.path:null;if(typeof t==`string`&&t.trim()){let e=Yl(t);e&&e!==s&&c.push(e)}}let u=new Set,d=!1,f=!1;for(let e of c){for(let t of a(e))if(!(!t?.id||u.has(t.id))&&(u.add(t.id),r(t.id)!==`idle`&&(d=!0),t.id!==n&&(o[t.id]??0)>0&&(f=!0),d&&f))break;if(d&&f)break}return{hasRunning:d,hasUnread:f}},r[0]=i,r[1]=n,r[2]=a,r[3]=o,r[4]=t,r[5]=s):s=r[5],s}function au(e){return e.index.session.unseenCount}function ou(e){return e.getSessionsByDirectory}function su(e){return e.availableWorktreesByProject}function cu(){let e=(0,qi.c)(2),t=bt(lu),n;return e[0]===t?n=e[1]:(n=e=>{let n=Yl(e.path),r=[n],i=t.get(n)??[];for(let e of i){let t=e&&typeof e==`object`&&`path`in e?e.path:null;if(typeof t==`string`&&t.trim()){let e=Yl(t);e&&r.push(e)}}return r},e[0]=t,e[1]=n),n}function lu(e){return e.availableWorktreesByProject}function uu(e){let t=(0,qi.c)(2),{isRunning:n,showUnread:r}=e;if(n){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(dl,{}),t[0]=e):e=t[0],e}if(r){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-[var(--status-info)]`}),t[1]=e):e=t[1],e}return null}function du(e){let t=(0,qi.c)(3),{count:n}=e;if(n===0)return null;let r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(dl,{}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[13px] text-[var(--surface-mutedForeground)]`,children:[r,n]}),t[1]=n,t[2]=i),i}function fu(e){let t=(0,qi.c)(3),{count:n}=e;if(n===0)return null;let r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-[var(--status-info)]`}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[13px] text-[var(--status-info)]`,children:[r,n]}),t[1]=n,t[2]=i),i}var pu=()=>{if(typeof window>`u`)return;let e=window.getSelection();e?.rangeCount&&e.removeAllRanges()},mu={touchAction:`manipulation`,userSelect:`none`,WebkitUserSelect:`none`,WebkitTouchCallout:`none`};function hu(e){let t=(0,qi.c)(72),{session:n,isCurrent:r,isPinned:i,contextLabel:a,getSessionTitle:o,onClick:s,onRename:c,onTogglePinned:l,onShare:u,onCopyShareUrl:d,onUnshare:f,onArchive:p,onDelete:m,needsAttention:h,longPressHandlers:g}=e,{t:_}=be(),[v,y]=Q.useState(!1),b;t[0]!==h||t[1]!==n.id?(b=h(n.id),t[0]=h,t[1]=n.id,t[2]=b):b=t[2];let x=b,S=n.share?.url,C=!!S,w=S?void 0:u,T;t[3]!==d||t[4]!==S?(T=S?()=>d(S):void 0,t[3]=d,t[4]=S,t[5]=T):T=t[5];let E=S?f:void 0,D;t[6]!==i||t[7]!==p||t[8]!==m||t[9]!==c||t[10]!==l||t[11]!==C||t[12]!==w||t[13]!==T||t[14]!==E?(D=Al({pinned:i,shared:C,onRename:c,onTogglePin:l,onShare:w,onCopyLink:T,onUnshare:E,onArchive:p,onDelete:m}),t[6]=i,t[7]=p,t[8]=m,t[9]=c,t[10]=l,t[11]=C,t[12]=w,t[13]=T,t[14]=E,t[15]=D):D=t[15];let O=D,k;t[16]!==g.onContextMenu||t[17]!==g.pressed?(k=e=>{$l(e,g.pressed,g.onContextMenu)},t[16]=g.onContextMenu,t[17]=g.pressed,t[18]=k):k=t[18];let A=n.id,j=`session:${n.id}`,M=g.onPointerDown,N=g.onPointerMove,ee=g.onPointerUp,P=g.onPointerCancel,F;t[19]!==v||t[20]!==s?(F=e=>{if(v){e.preventDefault();return}s()},t[19]=v,t[20]=s,t[21]=F):F=t[21];let I=g.pressed&&`bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)] scale-[0.99]`,L=r?`bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)]`:`hover:bg-[var(--interactive-hover)]`,R;t[22]!==I||t[23]!==L?(R=Y(`flex w-full min-h-[56px] items-center gap-3 rounded-xl px-3 py-3 text-left transition-colors select-none`,`active:bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)]`,I,L),t[22]=I,t[23]=L,t[24]=R):R=t[24];let z;t[25]!==g.onPointerCancel||t[26]!==g.onPointerDown||t[27]!==g.onPointerMove||t[28]!==g.onPointerUp||t[29]!==n.id||t[30]!==F||t[31]!==R||t[32]!==j?(z=(0,$.jsx)(`button`,{type:`button`,"data-mobile-session-context-trigger":A,"data-mobile-long-press-trigger":j,onPointerDown:M,onPointerMove:N,onPointerUp:ee,onPointerCancel:P,onClick:F,className:R,style:mu}),t[25]=g.onPointerCancel,t[26]=g.onPointerDown,t[27]=g.onPointerMove,t[28]=g.onPointerUp,t[29]=n.id,t[30]=F,t[31]=R,t[32]=j,t[33]=z):z=t[33];let te=n._statusType!==`idle`,B=x&&!r,V;t[34]!==te||t[35]!==B?(V=(0,$.jsx)(`span`,{className:`flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:(0,$.jsx)(uu,{isRunning:te,showUnread:B})}),t[34]=te,t[35]=B,t[36]=V):V=t[36];let H=r?`font-semibold text-[var(--surface-foreground)]`:`text-[var(--surface-foreground)]`,ne;t[37]===H?ne=t[38]:(ne=Y(`truncate text-[15px] leading-tight`,H),t[37]=H,t[38]=ne);let re;t[39]!==o||t[40]!==n?(re=o(n),t[39]=o,t[40]=n,t[41]=re):re=t[41];let U;t[42]!==ne||t[43]!==re?(U=(0,$.jsx)(`span`,{className:ne,children:re}),t[42]=ne,t[43]=re,t[44]=U):U=t[44];let W;t[45]===a?W=t[46]:(W=a?(0,$.jsx)(`span`,{className:`truncate text-[12px] leading-none text-[var(--surface-mutedForeground)]`,children:a}):null,t[45]=a,t[46]=W);let ie;t[47]!==U||t[48]!==W?(ie=(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[U,W]}),t[47]=U,t[48]=W,t[49]=ie):ie=t[49];let ae;t[50]===n._runningChildrenCount?ae=t[51]:(ae=(n._runningChildrenCount??0)>0&&(0,$.jsxs)(`span`,{className:`flex flex-shrink-0 items-center gap-1 text-[12px] text-[var(--surface-mutedForeground)]`,children:[(0,$.jsx)(dl,{size:12}),n._runningChildrenCount]}),t[50]=n._runningChildrenCount,t[51]=ae);let oe;t[52]===r?oe=t[53]:(oe=r&&(0,$.jsx)(Z,{name:`check`,className:`h-4 w-4 flex-shrink-0 text-[var(--primary-base)]`}),t[52]=r,t[53]=oe);let G;t[54]!==z||t[55]!==V||t[56]!==ie||t[57]!==ae||t[58]!==oe||t[59]!==k?(G=(0,$.jsxs)(ji,{onTouchStart:Ql,onContextMenu:k,render:z,children:[V,ie,ae,oe]}),t[54]=z,t[55]=V,t[56]=ie,t[57]=ae,t[58]=oe,t[59]=k,t[60]=G):G=t[60];let K;if(t[61]!==O||t[62]!==_){let e;t[64]===_?e=t[65]:(e=(e,t)=>(0,$.jsxs)(Q.Fragment,{children:[t>0&&(e.separated||e.id===`archive`)?(0,$.jsx)(Mi,{}):null,(0,$.jsxs)(Pi,{className:`min-h-10 px-3`,onClick:e.onClick,children:[(0,$.jsx)(Z,{name:e.icon,className:`size-4`}),Nl(e,_)]})]},e.id),t[64]=_,t[65]=e),K=O.map(e),t[61]=O,t[62]=_,t[63]=K}else K=t[63];let se;t[66]===K?se=t[67]:(se=(0,$.jsx)(Ni,{className:`min-w-[200px] p-1.5`,children:K}),t[66]=K,t[67]=se);let ce;return t[68]!==v||t[69]!==G||t[70]!==se?(ce=(0,$.jsxs)(Fi,{open:v,onOpenChange:y,children:[G,se]}),t[68]=v,t[69]=G,t[70]=se,t[71]=ce):ce=t[71],ce}function gu(e){let t=(0,qi.c)(23),{label:n,leadingIcon:r,icon:i,project:a,iconOptions:o,iconBackground:s,colorVar:c,isActive:l,status:u,onClick:d}=e,f=i?ti[i]:null,p;t[0]!==c||t[1]!==l||t[2]!==f?(p=f?(0,$.jsx)(Z,{name:f,className:`h-4 w-4`,style:!l&&c?{color:c}:void 0}):null,t[0]=c,t[1]=l,t[2]=f,t[3]=p):p=t[3];let m=p,h=l?`border-transparent bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)] text-[var(--surface-foreground)] font-medium`:`border-[var(--interactive-border)] bg-transparent text-[var(--surface-foreground)] active:bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)]`,g;t[4]===h?g=t[5]:(g=Y(`flex min-h-[40px] shrink-0 select-none items-center gap-1.5 rounded-full border px-3.5 text-[13px] leading-none whitespace-nowrap transition-colors`,h),t[4]=h,t[5]=g);let _;t[6]!==l||t[7]!==u?(_=u&&(u.hasRunning||u.hasUnread)&&!l&&(u.hasRunning?(0,$.jsx)(dl,{size:10}):(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--status-info)]`})),t[6]=l,t[7]=u,t[8]=_):_=t[8];let v;t[9]!==m||t[10]!==s||t[11]!==o||t[12]!==a?(v=a?.iconImage?(0,$.jsx)(`span`,{className:`inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]`,style:s?{backgroundColor:s}:void 0,children:(0,$.jsx)(Qr,{project:a,options:o,className:`h-full w-full object-contain`,fallback:m})}):m,t[9]=m,t[10]=s,t[11]=o,t[12]=a,t[13]=v):v=t[13];let y;t[14]===n?y=t[15]:(y=(0,$.jsx)(`span`,{className:`max-w-[140px] truncate`,children:n}),t[14]=n,t[15]=y);let b;return t[16]!==r||t[17]!==d||t[18]!==g||t[19]!==_||t[20]!==v||t[21]!==y?(b=(0,$.jsxs)(`button`,{type:`button`,onClick:d,className:g,children:[r,_,v,y]}),t[16]=r,t[17]=d,t[18]=g,t[19]=_,t[20]=v,t[21]=y,t[22]=b):b=t[22],b}var _u=({onSessionSwitch:e})=>{let{t}=be(),{git:n}=ne(),{currentTheme:r}=Lt(),i=j(e=>e.isMobile),a=Bl(),o=bt(e=>e.currentSessionId),s=Fe(),c=Q.useMemo(()=>Object.fromEntries([...s].map(e=>[e,{type:`busy`}])),[s]),l=bt(e=>e.setCurrentSession),u=bt(e=>e.openNewSessionDraft),d=Q.useCallback(e=>{if(!ae()){St.getState().openDraft(e);return}u(e)},[u]),f=bt(e=>e.archiveSession),p=bt(e=>e.shareSession),m=bt(e=>e.unshareSession),h=bt(e=>e.updateSessionTitle),g=bt(e=>e.requestSessionSmartTitle),_=j(e=>e.mobileSessionPanelOpen),v=j(e=>e.setMobileSessionPanelOpen),y=pr({onDismiss:()=>v(!1)}),b=ct(e=>e.projects),x=ct(e=>e.activeProjectId),S=ct(e=>e.setActiveProjectIdOnly),C=ct(e=>e.removeProject),w=ft(),T=wt(),E=bt(e=>e.availableWorktreesByProject),D=pt(e=>e.orderByProject),O=Ze(e=>e.activePaginationByDirectory),k=ul(e=>e.expandedWorktreeGroups),A=ul(e=>e.setWorktreeGroupExpanded),[M,N]=Q.useState(_),[ee,P]=Q.useState(!1),F=J(e=>{P(e),e&&N(!0)});Q.useEffect(()=>{_&&N(!0)},[_]);let I=J(()=>{y.reset(),N(!1)}),{sessions:L,totalRunning:R,totalUnread:z}=tu(a,c,_||ee,M),{getSessionTitle:te,needsAttention:B}=nu(),V=iu(a,c,o),H=cu(),[re,U]=Q.useState(new Map),W=qc(),[ie,oe]=Q.useState(new Map),[G,K]=Q.useState(!1),[se,ce]=Q.useState(null),[q,le]=Q.useState(null),[ue,de]=Q.useState(null),[fe,pe]=Q.useState(null),[me,he]=Q.useState(``),[ge,_e]=Q.useState(null),[ve,Se]=Q.useState(null),[Ce,we]=Q.useState(null),Te=Q.useRef(null);Te.current||=yl({onPressedKeyChange:de});let Ee=Q.useRef(null),[De,Oe]=Q.useState(!1),ke=j(e=>e.mobileSessionFilterProjectId),Ae=j(e=>e.setMobileSessionFilterProjectId),je=Q.useMemo(()=>a.some(e=>w.has(e.id)),[w,a]);Q.useEffect(()=>{!je&&ke===Wl&&Ae(null)},[ke,je,Ae]);let Me=Q.useRef(!1);Q.useEffect(()=>{let e=Me.current;if(Me.current=_,!_||e)return;let t=Kl({activeProjectId:x,currentFilterProjectId:ke,projects:b});t!==ke&&Ae(t)},[_,x,ke,b,Ae]),Q.useEffect(()=>{_||(le(null),we(null),Te.current?.reset())},[_]),Q.useEffect(()=>()=>{Te.current?.reset()},[]),Q.useEffect(()=>{if(!q)return;pu();let e=window.requestAnimationFrame(pu);return document.addEventListener(`selectionchange`,pu),()=>{window.cancelAnimationFrame(e),document.removeEventListener(`selectionchange`,pu),pu()}},[q]);let Ne=Q.useMemo(()=>ke&&ke!==Wl?b.find(e=>e.id===ke)??null:null,[ke,b]),Pe=Q.useMemo(()=>Ne??b.find(e=>e.id===x)??null,[x,b,Ne]);Q.useEffect(()=>{let e=Yl(Pe?.path??``);if(!_||!e){Oe(!1);return}let t=Ee.current;if(t?.git===n&&t.path===e){Oe(t.isGitRepository);return}let r=!1;return Oe(!1),n.checkIsGitRepository(e).then(t=>{r||(Ee.current={git:n,path:e,isGitRepository:t},Oe(t))}).catch(()=>{r||(Ee.current={git:n,path:e,isGitRepository:!1},Oe(!1))}),()=>{r=!0}},[n,_,Pe]),Q.useEffect(()=>{if(!_||b.length===0)return;let e=!1;return Promise.all(b.map(async e=>({projectId:e.id,branch:await ei(e.path).catch(()=>null)}))).then(t=>{e||oe(e=>{let n=new Map(e);for(let e of t){let t=e.branch?.trim();t&&t!==`HEAD`&&n.set(e.projectId,t),e.branch===`HEAD`&&n.delete(e.projectId)}return n})}),()=>{e=!0}},[_,b]);let Ie=Q.useMemo(()=>{if(ke&&ke!==Wl){let e=b.find(e=>e.id===ke);return e?H(e):[]}return b.flatMap(H)},[ke,b,H]);Q.useEffect(()=>{_&&We(Ie)},[_,Ie]),Q.useEffect(()=>{if(!_||b.length===0)return;let e=!1;return(async()=>{let t=await Promise.all(b.map(async t=>{let r=Yl(t.path);if(!r)return null;let i=!1;try{i=await n.checkIsGitRepository(r)}catch{return{path:r,status:`failed`}}if(!i)return{path:r,status:`success`,worktrees:[]};try{return{path:r,status:`success`,worktrees:(await oi({id:t.id,path:r},{isCurrent:()=>!e})).worktrees}}catch{return{path:r,status:`failed`}}}));if(e)return;let r=new Set(b.map(e=>Yl(e.path)).filter(Boolean)),i=t.flatMap(e=>e?[e]:[]);bt.setState(e=>{let t=Ol(e.availableWorktreesByProject,r,i);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:Array.from(t.values()).flat()}})})(),()=>{e=!0}},[n,_,b]);let Le=Q.useCallback(e=>xe(e.path)||e.path,[]),Re=Q.useMemo(()=>{if(!M||!ke)return L;if(ke===Wl)return L.filter(e=>w.has(e.id));let e=b.find(e=>e.id===ke);if(!e)return L;let t=H(e);return L.filter(e=>{let n=Xl(e);return t.some(e=>Yl(e)===n)})},[M,L,ke,w,b,H]),ze=Q.useMemo(()=>{if(!M||!Ne)return[];let e=Yl(Ne.path),t=Dt(D[Ne.id],E.get(e)??[]),n=[{key:`${Ne.id}::${e}`,directory:e,label:Le(Ne),worktree:null,sessions:[]}];for(let r of t){let t=Yl(r.path);!t||t===e||n.some(e=>e.directory===t)||n.push({key:`${Ne.id}::${t}`,directory:t,label:r.branch||r.label||xe(t),worktree:r,sessions:[]})}let r=new Map(n.map(e=>[e.directory,e]));for(let e of Re)r.get(Xl(e))?.sessions.push(e);return n},[E,Re,Le,M,Ne,D]),Be=Q.useCallback(e=>{let t=Xl(e);for(let e of b){let n=Yl(e.path),r=Le(e);if(t===n){let t=ie.get(e.id);return t?`${r} · ${t}`:r}let i=(E.get(n)??[]).find(e=>Yl(e.path)===t);if(i)return i.branch?`${r} · ${i.branch}`:r}return xe(t)||t||void 0},[E,Le,b,ie]),Ve=Q.useCallback(()=>{le(null),Te.current?.reset(),v(!1)},[v]),He=()=>{le(null),Te.current?.reset()},Ue=e=>({pressed:ue===e.key||q?.key===e.key,onPointerDown:t=>{t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||Te.current?.start({pointerId:t.pointerId,key:e.key,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>{pu(),le(e)}})},onPointerMove:e=>{Te.current?.move(e.pointerId,e.clientX,e.clientY)},onPointerUp:e=>{Te.current?.end(e.pointerId)},onPointerCancel:e=>{Te.current?.cancel(e.pointerId)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),pu(),Te.current?.openFromContextMenu(e.key,()=>le(e))}}),Ge=(e,t)=>{Te.current?.consumeClick(e)||t()},Ke=Q.useCallback(t=>{ir(),Ve();let n=Xl(t)||null,r=Gl(ke);ae()?l(t.id,n,{preserveActiveProject:r}):St.getState().openSession({sessionId:t.id,directory:n,preserveActiveProject:r}),e?.(t.id)},[Ve,ke,e,l]),qe=Q.useCallback(async e=>{try{if(!(await p(e.id))?.share?.url){yt.error(t(`sessions.sidebar.session.share.error`));return}yt.success(t(`sessions.sidebar.session.share.successTitle`),{description:t(`sessions.sidebar.session.share.successDescription`)})}catch{yt.error(t(`sessions.sidebar.session.share.error`))}},[p,t]),Je=Q.useCallback(async e=>{if((await ye(e)).ok){yt.success(t(`sessions.sidebar.session.menu.copied`));return}yt.error(t(`sessions.sidebar.session.share.copyUrlError`))},[t]),Ye=Q.useCallback(async e=>{try{if(!await m(e)){yt.error(t(`sessions.sidebar.session.unshare.error`));return}yt.success(t(`sessions.sidebar.session.unshare.success`))}catch{yt.error(t(`sessions.sidebar.session.unshare.error`))}},[t,m]),Xe=Q.useCallback(async e=>{if(!await f(e)){yt.error(t(`sessions.sidebar.session.archive.error`));return}hl({sessionIds:[e],message:t(`sessions.sidebar.session.archive.success`),undoLabel:t(`sessions.sidebar.undo`),settingsLabel:t(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:t(`sessions.sidebar.session.archive.undoFailed`)})},[f,t]),Qe=J(e=>{let t=new Map;for(let e of a){let n=e.parentID??null;if(!n)continue;let r=t.get(n)??[];r.push(e.id),t.set(n,r)}let n=[],r=new Set,i=e=>{if(!r.has(e)){r.add(e),n.push(e);for(let n of t.get(e)??[])i(n)}};return i(e),n}),$e=J(e=>{let n=Qe(e.id);gl({sessionIds:n,message:n.length===1?t(`sessions.sidebar.session.delete.success`):t(`sessions.sidebar.bulkActions.deletedPlural`,{count:n.length}),undoLabel:t(`sessions.sidebar.undo`),commitFailedMessage:t(`sessions.sidebar.session.delete.error`)})}),et=Q.useCallback(e=>{he(te(e)),pe(e)},[te]),tt=Q.useCallback(async()=>{if(!fe)return;let e=me.trim();if(e)try{await h(fe.id,e),pe(null),he(``)}catch{yt.error(t(`sessions.sidebar.session.menu.rename`),{description:t(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},[me,fe,t,h]),nt=Q.useCallback(async()=>{if(!fe)return;let e=fe.id;pe(null),he(``);try{await g(e)}catch{yt.error(t(`sessions.sidebar.session.rename.smartTitle`),{description:t(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},[fe,g,t]),rt=Q.useCallback(()=>{if(Ve(),ke){let e=b.find(e=>e.id===ke);if(e){d({selectedProjectId:e.id,directoryOverride:e.path});return}}let e=[...a].sort((e,t)=>{let n=e.time?.updated??0;return(t.time?.updated??0)-n})[0],t=e?Xl(e):``;d(t?{directoryOverride:t}:void 0)},[Ve,ke,b,a,d]),at=Q.useCallback(()=>{!Pe||!De||(Ve(),S(Pe.id),ce(Pe.id),K(!0))},[Ve,S,De,Pe]),ot=(e,t)=>{He(),v(!1),d({selectedProjectId:e.id,directoryOverride:t,preserveDirectoryOverride:!0})},lt=e=>{He(),(async()=>{try{await oi({id:e.project.id,path:e.project.path})}catch(e){console.warn(`[MobileStatus] Worktree refresh before session sync failed:`,e)}let t=bt.getState().availableWorktreesByProject.get(e.project.path)??e.worktrees;await st([e.project.path,...t.map(e=>e.path)],a)})()},ut=J(e=>{A(e,!k[e]),U(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})}),dt=Q.useCallback(e=>{let t=(re.get(e.key)??ql)+Jl;if(U(t=>{let n=new Map(t);return n.set(e.key,(t.get(e.key)??ql)+Jl),n}),t<e.sessions.length)return;let n=Ze.getState().activePaginationByDirectory.get(e.directory);n?.hasMore&&!n.loadingMore&&it(e.directory)},[re]),mt=Q.useCallback(e=>{U(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),ht=e=>{let n=e.worktree===null,r=n||k[e.key]===!0,i=re.get(e.key)??ql,a=ol(e.sessions,i,W),s=O.get(e.directory),c=a.length<e.sessions.length||s?.hasMore===!0,l=e.sessions.length>ql&&i>ql,u=n&&Ne?ie.get(Ne.id):null,d=e.label,f=n?`project:${Ne?.id??e.key}`:`worktree:${Ne?.id??e.key}:${e.directory}`,p=Ne?Ue(n?{key:f,kind:`project`,project:Ne,worktrees:ze.flatMap(e=>e.worktree?[e.worktree]:[]),isGitRepository:De}:{key:f,kind:`worktree`,project:Ne,worktree:e.worktree}):null;return(0,$.jsxs)(`section`,{className:`rounded-xl`,children:[n?(0,$.jsxs)(`div`,{"data-mobile-long-press-trigger":f,className:Y(`flex min-h-12 items-center gap-2 rounded-xl px-3 py-2 text-left transition-all select-none`,p?.pressed&&`bg-[var(--interactive-active)] scale-[0.99]`),onPointerDown:p?.onPointerDown,onPointerMove:p?.onPointerMove,onPointerUp:p?.onPointerUp,onPointerCancel:p?.onPointerCancel,onContextMenu:p?.onContextMenu,style:mu,children:[(0,$.jsx)(Z,{name:`folder-open`,className:`size-4 shrink-0 text-[var(--surface-mutedForeground)]`}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`truncate text-[14px] font-semibold text-[var(--surface-foreground)]`,children:d}),u?(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 text-[12px] text-[var(--surface-mutedForeground)]`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:u})]}):null]}),(0,$.jsx)(`span`,{className:`shrink-0 text-[12px] tabular-nums text-[var(--surface-mutedForeground)]`,children:Zl(e.sessions)})]}):(0,$.jsxs)(`button`,{type:`button`,"data-mobile-long-press-trigger":f,onClick:()=>Ge(f,()=>ut(e.key)),onPointerDown:p?.onPointerDown,onPointerMove:p?.onPointerMove,onPointerUp:p?.onPointerUp,onPointerCancel:p?.onPointerCancel,onContextMenu:p?.onContextMenu,"aria-expanded":r,"aria-label":t(r?`sessions.sidebar.group.collapseAria`:`sessions.sidebar.group.expandAria`,{label:d}),className:Y(`flex min-h-12 w-full items-center gap-2 rounded-xl px-3 py-2 text-left transition-all hover:bg-[var(--interactive-hover)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] select-none`,p?.pressed&&`bg-[var(--interactive-active)] scale-[0.99]`),style:mu,children:[(0,$.jsx)(Z,{name:`arrow-down-s`,className:Y(`size-4 shrink-0 text-[var(--surface-mutedForeground)] transition-transform`,r?`rotate-0`:`-rotate-90`)}),(0,$.jsx)(Z,{name:`node-tree`,className:`size-4 shrink-0 text-[var(--surface-mutedForeground)]`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[14px] font-semibold text-[var(--surface-foreground)]`,children:d}),(0,$.jsx)(`span`,{className:`shrink-0 text-[12px] tabular-nums text-[var(--surface-mutedForeground)]`,children:Zl(e.sessions)})]}),r?(0,$.jsxs)(`div`,{className:`pb-1`,children:[a.map(e=>(0,$.jsx)(hu,{session:e,isCurrent:e.id===o,isPinned:w.has(e.id),getSessionTitle:te,onClick:()=>Ge(`session:${e.id}`,()=>Ke(e)),onRename:()=>et(e),onTogglePinned:()=>T(e.id),onShare:()=>{qe(e)},onCopyShareUrl:e=>{Je(e)},onUnshare:()=>{Ye(e.id)},onArchive:()=>{Xe(e.id)},onDelete:()=>$e(e),needsAttention:B,longPressHandlers:Ue({key:`session:${e.id}`,kind:`session`,session:e})},e.id)),c||l?(0,$.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2 py-1 pr-3 pl-8`,children:[c?(0,$.jsx)(X,{variant:`ghost`,size:`xs`,disabled:s?.loadingMore===!0,onClick:()=>dt(e),className:`text-muted-foreground/70 hover:text-foreground`,children:t(`sessions.sidebar.group.showMore`)}):null,l?(0,$.jsx)(X,{variant:`ghost`,size:`xs`,onClick:()=>mt(e.key),className:`text-muted-foreground/70 hover:text-foreground`,children:t(`sessions.sidebar.group.showFewer`)}):null]}):null]}):null]},e.key)},gt=Q.useCallback(()=>(0,$.jsxs)(`div`,{className:`shrink-0`,children:[(0,$.jsx)(ar,{controller:y,ariaLabel:t(`mobile.sessions.sheet.resizeAria`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-4 pb-2`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground`,children:t(`mobile.sessions.sheet.title`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(du,{count:R}),(0,$.jsx)(fu,{count:z}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,onClick:rt,"aria-label":t(`mobile.sessions.newChat`),className:`text-[var(--surface-mutedForeground)]`,style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`add`,className:`h-5 w-5`})}),De&&Pe?(0,$.jsx)(X,{variant:`ghost`,size:`icon`,onClick:at,"aria-label":t(`sessions.sidebar.project.actions.newWorktree`),title:t(`sessions.sidebar.project.actions.newWorktree`),className:`text-[var(--surface-mutedForeground)]`,style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`node-tree`,className:`size-4`})}):null,(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ve,"aria-label":t(`mobile.surface.closeAria`),className:`text-[var(--surface-mutedForeground)]`,style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`close`,className:`h-5 w-5`})})]})]}),(b.length>1||je)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 overflow-x-auto px-4 py-2.5 scrollbar-none`,style:{scrollbarWidth:`none`,msOverflowStyle:`none`},children:[(0,$.jsx)(gu,{label:t(`chat.modelControls.modeValue.all`),isActive:ke===null,onClick:()=>Ae(null)}),je?(0,$.jsx)(gu,{label:t(`sessions.sidebar.session.actions.pinned`),leadingIcon:(0,$.jsx)(Z,{name:`pushpin-2-fill`,className:`size-3.5`}),isActive:ke===Wl,onClick:()=>Ae(Wl)}):null,b.map(e=>(0,$.jsx)(gu,{label:Le(e),icon:e.icon,project:{id:e.id,iconImage:e.iconImage??null},iconOptions:{themeVariant:r.metadata.variant,iconColor:r.colors.surface.foreground},iconBackground:e.iconBackground??null,colorVar:e.color?ri[e.color]??null:null,isActive:ke===e.id,status:V(e.path),onClick:()=>Ae(e.id)},e.id))]})]}),[t,R,z,b,je,ke,Ae,Le,r,V,rt,at,Ve,De,Pe,y]),_t=q?.kind===`project`?Le(q.project):q?.kind===`worktree`?q.worktree.branch||q.worktree.label||xe(q.worktree.path):q?.kind===`session`?te(q.session):``,vt=Q.useMemo(()=>{if(!ge)return null;let e=b.find(e=>e.id===ge);if(!e)return null;let t=Yl(e.path),n=Dt(D[e.id],E.get(t)??[]),r=q?.kind===`project`&&q.project.id===e.id?q.isGitRepository:n.length>0||!!ie.get(e.id);return{id:e.id,label:Le(e),path:t||e.path,icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:r,worktrees:n}},[q,E,ge,Le,b,ie,D]),xt=Q.useMemo(()=>{if(!q)return[];if(q.kind===`project`){let e=q.project;return jl({gitRepository:q.isGitRepository,onNewSession:()=>ot(e,e.path),onNewWorktree:()=>{let t=e.id;He(),Ve(),S(t),ce(t),K(!0)},onSyncSessions:()=>lt(q),onEditProject:()=>{He(),_e(e.id)},onCloseProject:()=>{He(),Se(e)}})}if(q.kind===`worktree`){let{project:e,worktree:t}=q;return Ml({onNewSession:()=>ot(e,t.path),onDeleteWorktree:()=>{He(),we({project:e,worktree:t})}})}let e=q.session,t=!!e.share?.url;return Al({pinned:w.has(e.id),shared:t,onRename:()=>{He(),et(e)},onTogglePin:()=>{He(),T(e.id)},onShare:t?void 0:()=>{He(),qe(e)},onCopyLink:t?()=>{let t=e.share?.url;He(),t&&Je(t)}:void 0,onUnshare:t?()=>{He(),Ye(e.id)}:void 0,onArchive:()=>{He(),Xe(e.id)},onDelete:()=>{He(),$e(e)}})},[q,et,He,Ve,Xe,Je,$e,qe,Ye,w,S,ot,lt,T]),Ct=xt.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,"data-mobile-session-action-sheet":q?.kind??`none`,children:xt.map(e=>{let n=(0,$.jsx)(eu,{icon:e.icon,label:Nl(e,t),destructive:e.destructive,onClick:e.onClick},e.id);return e.separated?(0,$.jsx)(`div`,{className:`mt-3 border-t border-[var(--surface-subtle)] pt-3`,children:n},e.id):n})}):null;return i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ur,{id:fr,open:_,onOpenChange:v,keepMounted:!0,presentation:`sheet`,edge:`bottom`,dismissGesture:{reservedTargetSelector:`[data-mobile-sheet-snap-handle]`},ariaLabel:t(`mobile.sessions.sheet.title`),surfaceClassName:y.snapPoint===.98?`h-[98dvh] max-h-[98dvh]`:`h-[72dvh] max-h-[98dvh]`,surfaceElementRef:y.surfaceRef,onExitComplete:I,onPreviewChange:F,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[gt(),(0,$.jsx)(Yr,{useScrollShadow:!0,disableHorizontal:!0,preventOverscroll:!0,outerClassName:`min-h-0 max-h-full flex-1`,className:`px-2 py-2 pwa-overlay-scroll`,children:(0,$.jsx)(`div`,{className:`flex min-h-full flex-col gap-0.5`,children:Ne?(0,$.jsxs)($.Fragment,{children:[ze.map(ht),ze.every(e=>e.sessions.length===0)?(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-8 text-[13px] text-[var(--surface-mutedForeground)]`,children:(0,$.jsx)(`span`,{children:t(`chat.mobileStatus.noSessionsInProject`)})}):null]}):Re.length===0?(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-10 text-[13px] text-[var(--surface-mutedForeground)]`,children:(0,$.jsx)(`span`,{children:t(`chat.mobileStatus.noSessionsInProject`)})}):Re.map(e=>(0,$.jsx)(hu,{session:e,isCurrent:e.id===o,isPinned:w.has(e.id),contextLabel:Be(e),getSessionTitle:te,onClick:()=>Ge(`session:${e.id}`,()=>Ke(e)),onRename:()=>et(e),onTogglePinned:()=>T(e.id),onShare:()=>{qe(e)},onCopyShareUrl:e=>{Je(e)},onUnshare:()=>{Ye(e.id)},onArchive:()=>{Xe(e.id)},onDelete:()=>$e(e),needsAttention:B,longPressHandlers:Ue({key:`session:${e.id}`,kind:`session`,session:e})},e.id))})})]})}),(0,$.jsx)(Mn,{open:!!q,title:_t,onClose:He,className:`select-none`,contentMaxHeightClassName:`max-h-[min(68dvh,560px)]`,children:Ct}),(0,$.jsx)(Mn,{open:!!fe,title:t(`sessions.sidebar.session.menu.rename`),onClose:()=>{pe(null),he(``)},footer:(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`default`,className:`flex-1`,onClick:()=>{pe(null),he(``)},children:t(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(X,{type:`button`,variant:`default`,className:`flex-1`,disabled:!me.trim(),onClick:()=>void tt(),children:t(`sessions.sidebar.session.rename.save`)})]}),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-3 px-1 py-1`,onSubmit:e=>{e.preventDefault(),tt()},children:[(0,$.jsx)(Dn,{value:me,onChange:e=>he(e.target.value),autoFocus:!0,className:`h-12`}),(0,$.jsxs)(X,{type:`button`,variant:`outline`,className:`w-full gap-2`,onClick:()=>void nt(),children:[(0,$.jsx)(Z,{name:`ai-generate-2`,className:`size-4`}),t(`sessions.sidebar.session.rename.smartTitle`)]})]})}),(0,$.jsx)(Mn,{open:!!ve,title:t(`sessions.sidebar.project.actions.closeProject`),onClose:()=>Se(null),closeAriaLabel:t(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>Se(null),children:t(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(X,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!ve)return;let e=ve;Se(null),C(e.id),yt.success(t(`mobile.sessions.toast.projectRemoved`,{label:Le(e)}))},children:t(`mobile.sessions.confirmRemoveProject`)})]}),children:(0,$.jsx)(`p`,{className:`px-1 py-1 typography-ui-label text-foreground`,children:t(`mobile.projects.closeConfirmMessage`,{title:ve?Le(ve):``})})}),(0,$.jsx)(an,{open:G,projectId:se,onOpenChange:e=>{K(e),e||ce(null)},onWorktreeCreated:(e,t)=>{K(!1),v(!1),t?.sessionId?ae()?l(t.sessionId,e):St.getState().openSession({sessionId:t.sessionId,directory:e}):se&&d({selectedProjectId:se,directoryOverride:e,preserveDirectoryOverride:!0})}}),Ce?(0,$.jsx)(Sl,{open:!0,project:{id:Ce.project.id,path:Ce.project.path},worktree:Ce.worktree,onClose:()=>we(null),onDeleted:()=>{let e=Yl(Ce.project.path),t=Yl(Ce.worktree.path);bt.setState(n=>{let r=new Map(n.availableWorktreesByProject);return r.set(e,(r.get(e)??[]).filter(e=>Yl(e.path)!==t)),{availableWorktreesByProject:r,availableWorktrees:Array.from(r.values()).flat()}}),we(null)}}):null,(0,$.jsx)(Tl,{open:ge!==null,project:vt,onClose:()=>_e(null)})]}):null},vu=e=>ee(`gui-plugins.disabled`,e);function yu(e,t){let n=e.getItem(t);if(n===null)return[];let r=JSON.parse(n);if(!Array.isArray(r)||!r.every(e=>typeof e==`string`))throw Error(`Invalid GUI plugin enable-state`);return[...new Set(r)]}function bu(e,t,n,r){let i=new Set(yu(e,t));r?i.delete(n):i.add(n);let a=[...i];return e.setItem(t,JSON.stringify(a)),a}function xu(e){return new Promise((t,n)=>{let r=0,i,a=()=>{cancelAnimationFrame(r),i!==void 0&&window.clearTimeout(i),e.removeEventListener(`abort`,o)},o=()=>{a(),n(e.reason??new DOMException(`Aborted`,`AbortError`))},s=()=>{a(),t()};if(e.aborted){o();return}e.addEventListener(`abort`,o,{once:!0}),r=requestAnimationFrame(()=>{r=requestAnimationFrame(()=>{i=window.setTimeout(s,0)})})})}function Su(){let e=Promise.resolve();return(t,n)=>{let r=e.then(async()=>{await xu(t),t.throwIfAborted(),n()});return e=r.catch(()=>{}),r}}var Cu=()=>Gi,wu=()=>()=>{};function Tu(e){let t=(0,qi.c)(19),{host:n,children:r}=e,i=n?.appearanceCatalog,a=Q.useSyncExternalStore(i?.subscribe??wu,i?.getSnapshot??Cu,Cu),o=Q.useContext(Rt),s=o?.registerPluginThemes,c=o?.currentTheme.metadata.variant??`dark`,l,u;t[0]!==s||t[1]!==a.themes?(l=()=>s?.(a.themes),u=[s,a.themes],t[0]=s,t[1]=a.themes,t[2]=l,t[3]=u):(l=t[2],u=t[3]),Q.useEffect(l,u);let d;t[4]!==c||t[5]!==a.branding?(d=a.branding.find(ku)?.logo?.[c],t[4]=c,t[5]=a.branding,t[6]=d):d=t[6];let f=d,p;t[7]===a.branding?p=t[8]:(p=a.branding.find(Ou),t[7]=a.branding,t[8]=p);let m=p,h=m?.dockIcon?.[c],g,_;t[9]!==m||t[10]!==h||t[11]!==n?(g=()=>{if(!(!n||!m||!h))return n.setDockIcon(m.pluginId,h).catch(Du),()=>{n.setDockIcon(m.pluginId,null).catch(Eu)}},_=[n,m,h],t[9]=m,t[10]=h,t[11]=n,t[12]=g,t[13]=_):(g=t[12],_=t[13]),Q.useEffect(g,_);let v;t[14]===f?v=t[15]:(v={logo:f},t[14]=f,t[15]=v);let y=v,b;return t[16]!==r||t[17]!==y?(b=(0,$.jsx)(qn.Provider,{value:y,children:r}),t[16]=r,t[17]=y,t[18]=b):b=t[18],b}function Eu(){}function Du(){}function Ou(e){return e.native&&e.dockIcon}function ku(e){return e.logo}var Au=()=>{},ju=()=>Au,Mu=e=>e?e instanceof Error?e.message:String(e):null,Nu=Q.lazy(()=>U(()=>import(`./GuiPluginSurface-DD2js1dF.js`).then(e=>({default:e.GuiPluginSurface})),__vite__mapDeps([69,1,8,14,19,5,3,4,6,20,10,11,12,21,22,23,24,50,44,70,71,33,34,35,36,2,37,38,39,13,9,15,16,17,18,40,41,32,42,43,45,46,47,48,72,26,25,27,51,52,53])));function Pu({host:e,id:t,transport:r,report:i,schedule:a}){let o=I(),s=z(qe(r,t)),[c,l]=Q.useState({loading:!1,error:null});return Q.useEffect(()=>{let i=!1,c=new AbortController,u=(i,o)=>a(c.signal,()=>{if(n()!==r){o?.dispose();return}o?e.install(t,i,o):e.install(t,i)}).catch(e=>{throw o?.dispose(),e}),d=h(),f=m();if(s.data&&!d&&e.getSnapshot().plugins.some(e=>e.id===t&&e.status===`active`&&e.revision===s.data.revision)){l({loading:!1,error:null});return}if(!s.data||!d&&!f){if(!s.data){l({loading:!1,error:null});return}return l({loading:!0,error:null}),u(s.data).then(()=>{i||l({loading:!1,error:null})}).catch(e=>{i||l({loading:!1,error:Mu(e)})}),()=>{i=!0,c.abort()}}l({loading:!0,error:null});let p=async()=>{f&&await Ui(f,`window-only`,{}),!(i||n()!==r)&&(await u(s.data),i||l({loading:!1,error:null}))};return U(async()=>{let{NativeGuiSession:e}=await import(`./native-DsqzO52u.js`);return{NativeGuiSession:e}},__vite__mapDeps([73,38,1,39,74,75])).then(async({NativeGuiSession:e})=>{if(i)return;if(!d){await p();return}let a=await Ui(d,`acquire`,{id:t,revision:s.data.revision});if(a===null){if(i||n()!==r)return;l({loading:!1,error:null}),await o.invalidateQueries({queryKey:Xe(r).queryKey,exact:!0});return}let c=new e(d,a);if(i||n()!==r){c.dispose();return}await u(a.bundle,c),i||l({loading:!1,error:null})}).catch(async e=>{if(!i){if(e instanceof Wi&&[`GUI_PLUGIN_UNTRUSTED_SOURCE`,`GUI_PLUGIN_DOCUMENT_RESTRICTED`,`GUI_PLUGIN_FORBIDDEN`].includes(e.code))try{await p();return}catch(t){e=t}i||l({loading:!1,error:Mu(e)})}}),()=>{i=!0,c.abort()}},[e,t,r,s.data,s.dataUpdatedAt,o,a]),Q.useEffect(()=>{i(e,t,{loading:c.loading||s.isPending,error:c.error??Mu(s.error)})},[e,t,c,s.error,s.isPending,i]),Q.useEffect(()=>()=>{e.uninstall(t),i(e,t,null)},[e,t,i]),null}function Fu({children:e,ready:r=!0}){let{files:i,viewExport:o}=ne(),s=I(),c=Q.useSyncExternalStore(t,n,n),l=vu(a()),[u,d]=Q.useState(null),f=u===c;Q.useEffect(()=>{if(!r||f)return;let e=new AbortController;return xu(e.signal).then(()=>{!e.signal.aborted&&n()===c&&d(c)}).catch(()=>{}),()=>{e.abort()}},[r,c,f]);let p=z({...Xe(c),enabled:f}),m=Q.useMemo(()=>({transport:c,run:Su()}),[c]),[h,g]=Q.useState(null),_=h?.key===l?h.disabled:null,v=h?.key===l?h.error:null,[y,b]=Q.useState({transport:c,requested:!1}),x=y.transport===c&&y.requested,S=J(()=>b(e=>e.transport===c&&e.requested?e:{transport:c,requested:!0})),[C,w]=Q.useState(null);y.transport!==c&&(b({transport:c,requested:!1}),w(null));let T=C?.transport===c?C.error:null,[E,D]=Q.useState(0),[O,k]=Q.useState(null),[A,M]=Q.useState(null),N=A?.transport===c?A.host:null,{locale:ee}=be(),P=Q.useContext(Rt)?.currentTheme.metadata.variant??`dark`,F=j(e=>e.isMobile),L=bt(e=>e.currentSessionId),R=He(L)?.directory,te=Q.useRef({locale:ee,mode:P,narrow:F});Q.useLayoutEffect(()=>{te.current={locale:ee,mode:P,narrow:F}},[ee,P,F]);let B=J(()=>{try{g({key:l,disabled:yu(window.localStorage,l),error:null})}catch(e){g({key:l,disabled:null,error:Mu(e)})}});Q.useEffect(()=>{B()},[l,B]),he(`storage`,e=>{(e.key===l||e.key===null)&&B()});let V=J((e,t)=>{try{g({key:l,disabled:bu(window.localStorage,l,e,t),error:null})}catch(e){g({key:l,disabled:_,error:Mu(e)})}}),H=J((e,t,n)=>{e===N&&k(r=>{let i=r?.host===e?r.states:{};if(i[t]?.loading===n?.loading&&i[t]?.error===n?.error)return r;let a={...i};return n?a[t]=n:delete a[t],{host:e,states:a}})}),re=Q.useMemo(()=>(p.data??[]).flatMap(e=>{if(!e.id||!e.features.gui)return[];let t=e.state.status===`failed`?e.state.error:O?.host===N?O.states[e.id]?.error:null;return[{id:e.id,source:e.source,enabled:_!==null&&!_.includes(e.id),...t?{error:t}:{}}]}),[p.data,_,O,N]),W=_!==null&&re.some(e=>e.enabled),ie=_!==null&&re.length>0,ae=Q.useMemo(()=>new Set((p.data??[]).filter(e=>e.state.status===`active`).map(e=>e.id)),[p.data]),oe=f&&x&&ie&&(W||N!==null);Q.useEffect(()=>{if(!f||x||!W||!re.some(e=>e.enabled&&ae.has(e.id)))return;let e=!1,t=()=>{!e&&n()===c&&S()};if(typeof window.requestIdleCallback==`function`){let n=window.requestIdleCallback(t,{timeout:2e3});return()=>{e=!0,window.cancelIdleCallback(n)}}let r=window.setTimeout(t,1e3);return()=>{e=!0,window.clearTimeout(r)}},[f,x,W,re,ae,c,S]),Q.useEffect(()=>{if(!oe)return;let e=new AbortController,t;return w(null),xu(e.signal).then(()=>Promise.all([U(()=>import(`./host-D776RHTx.js`),__vite__mapDeps([76,38,1,39,16,41,4,3,8,14,32,15,2,43,21,17,18,44,5,6,74,77,78,79,80,81,75])),U(()=>import(`./gui-CJjEj3l4.js`),__vite__mapDeps([82,4,3,1,2,38,39,42,12])),U(()=>import(`./fileReferenceActions-CvDFcgBH.js`).then(e=>e.r),__vite__mapDeps([83,1,4,3,2,5,6,13,10,8,11,12,43,84,80]))])).then(([{GuiPluginHost:r},{createGuiClient:a},{openFileReference:l}])=>{e.signal.aborted||n()!==c||(t=new r({client:a(e.signal),files:i,queryClient:s,transport:c,viewExport:o,toast:me,storage:window.localStorage,...te.current,focusFile:async(t,n)=>{e.signal.aborted||await l(t,!1,{effectiveDirectory:n})},openPage:t=>!e.signal.aborted&&n()===c&&!j.getState().isMobile&&j.getState().openGuiPage(t)}),M({transport:c,host:t}))}).catch(t=>{e.signal.aborted||w({transport:c,error:Mu(t)})}),()=>{e.abort(),t?.dispose(),M(e=>e?.host===t?null:e),k(e=>e?.host===t?null:e)}},[oe,i,s,c,E,o]),Q.useLayoutEffect(()=>{N?.setSession(L&&R?{id:L,directory:R}:void 0)},[N,L,R]),Q.useLayoutEffect(()=>{N?.appearanceCatalog.setOrder((p.data??[]).flatMap(e=>e.id?[e.id]:[]))},[N,p.data]),Q.useLayoutEffect(()=>{F&&j.getState().activeMainTab===`plugin`&&j.getState().closeGuiPage(),N?.setAppearance({locale:ee,mode:P,narrow:F})},[N,ee,P,F]),Q.useLayoutEffect(()=>{let e=()=>{let e=j.getState();N?.setPage(e.activeMainTab===`plugin`?e.activeGuiPage??void 0:void 0)};return e(),j.subscribe((t,n)=>{(t.activeMainTab!==n.activeMainTab||t.activeGuiPage!==n.activeGuiPage)&&e()})},[N]);let G=Q.useMemo(()=>N?e=>N.subscribe(e):ju,[N]),K=Q.useMemo(()=>N?()=>N.getSnapshot():kr,[N]),se=Q.useSyncExternalStore(G,K,kr),ce=J(()=>{B(),x&&T&&(w(null),D(e=>e+1)),s.invalidateQueries({queryKey:Xe(c).queryKey,exact:!0}).then(()=>{if(x)return Ve(s,c,!0,()=>n()===c)})}),q=x&&W&&!T&&(!N||re.some(e=>e.enabled&&ae.has(e.id)&&(O?.host!==N||(O.states[e.id]?.loading??!0)))),le={host:N,snapshot:se,inventory:re,error:v??T??Mu(p.error),loading:p.isPending||_===null&&!v||q,requested:x,requestLoad:S,setEnabled:V,refresh:ce};return(0,$.jsx)(Or.Provider,{value:le,children:(0,$.jsx)(Ar.Provider,{value:N?.fileIcons??null,children:(0,$.jsxs)(Tu,{host:N,children:[e,N&&re.filter(e=>e.enabled&&ae.has(e.id)).map(e=>(0,$.jsx)(Pu,{host:N,id:e.id,transport:c,report:H,schedule:m.run},e.id)),N&&(0,$.jsx)(Bn,{fallback:(0,$.jsx)($.Fragment,{}),children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Nu,{})})},`surface:${c}`)]})})})}var Iu=3e4;function Lu(){return typeof window>`u`?!1:window.__VSCODE_CONFIG__!==void 0}function Ru(){let e=Q.useMemo(()=>Lu(),[]),n=Q.useMemo(()=>Qn(),[]),r=Q.useRef(!1),a=Q.useRef(!1),o=Q.useRef(new Set),[s,c]=Q.useState(()=>Zn()),l=bt(e=>e.setCurrentSession),u=bt(e=>e.currentSessionId),d=bt(e=>e.currentSessionDirectory),f=j(e=>e.setActiveMainTab),p=j(e=>e.setSettingsDialogOpen),m=j(e=>e.setSettingsPage),h=j(e=>e.navigateToDiff),g=Ze(e=>e.hasLoaded),_=Ze(e=>e.activeSessions),v=Ze(e=>e.archivedSessions),y=Q.useCallback(t=>{if(!e&&Zn().sessionId===t){o.current.has(t)||(o.current.add(t),et(t,`missing-directory`)),a.current=!0;try{p(!1),f(`chat`),er({sessionId:t,tab:`chat`,isSettingsOpen:!1,settingsPath:`home`,diffFile:null},{replace:!0,force:!0}),c(Zn())}finally{a.current=!1}}},[e,f,c,p]),b=Q.useCallback(async e=>{if(!a.current){a.current=!0;try{if(e.settingsPath){m(rr(e.settingsPath)),p(!0);return}if(j.getState().isSettingsDialogOpen&&p(!1),e.tab===`plugin`&&e.guiPageKey){j.getState().isMobile?f(`chat`):j.getState().openGuiPage(e.guiPageKey);return}if(e.tab===`schedule`||e.tab===`assistant`){f(e.tab),e.tab===`assistant`&&e.assistantId&&Mt.getState().selectAssistant(e.assistantId);return}if(e.isNewSession){f(`chat`),bt.getState().newSessionDraft.open||bt.getState().openNewSessionDraft();return}if(e.sessionId){let t=e.sessionId,n=hr(t);if(!n){a.current=!1;let e=await gr(t);a.current=!0,n=e?.directory??null}let r=bt.getState();n&&(t!==r.currentSessionId||n!==r.currentSessionDirectory)&&l(t,n)}e.tab?f(e.tab):e.sessionId&&f(`chat`),e.diffFile&&(e.tab===`diff`||!e.tab)&&h(e.diffFile)}finally{a.current=!1}}},[l,f,p,m,h]),x=Q.useCallback(()=>{let e=bt.getState(),t=j.getState(),n=Zn(),r=t.activeMainTab,i=r===`schedule`||r===`assistant`||r===`plugin`,a=!i&&!!e.newSessionDraft?.open&&!e.currentSessionId,o=i&&r===`assistant`?Nt():null;return{isNewSession:a,guiPageKey:r===`plugin`?t.activeGuiPage:null,sessionId:i||a?null:e.currentSessionId??n.sessionId,tab:a?`chat`:i?r:t.activeMainTab||n.tab||`chat`,isSettingsOpen:t.isSettingsDialogOpen,settingsPath:t.settingsPage,settingsEntityId:n.settingsEntityId,diffFile:i||a?null:t.pendingDiffFile??n.diffFile,diffScope:i||a?null:n.diffScope,scheduleView:i&&r===`schedule`?n.scheduleView:null,scheduleProjectId:i&&r===`schedule`?n.scheduleProjectId:null,scheduleTaskId:i&&r===`schedule`?n.scheduleTaskId:null,assistantId:o,focusSessionId:i&&n.tab===r&&(r!==`assistant`||n.assistantId===o)?n.focusSessionId:null}},[]),S=Q.useCallback((t={})=>{if(e||n||a.current)return;let r=x();er(r,t),c(Zn())},[e,n,x]);Q.useEffect(()=>{if(r.current||(r.current=!0,!$n()))return;let t=Zn();(async()=>{await b(t),!e&&!n&&er({...x(),isNewSession:t.isNewSession||x().isNewSession,sessionId:t.isNewSession?null:t.sessionId??bt.getState().currentSessionId??x().sessionId,tab:t.tab===`plugin`&&j.getState().isMobile?`chat`:t.tab??j.getState().activeMainTab,settingsPath:t.settingsPath??j.getState().settingsPage,diffFile:t.isNewSession?null:t.diffFile??j.getState().pendingDiffFile},{replace:!0,force:!0})})()},[b,x,e,n]),Q.useEffect(()=>{if(!s.sessionId||s.isNewSession)return;let e=!1,t=s.sessionId;if(Zn().sessionId!==t||u===t&&d||o.current.has(t))return;let n=hr(t);if(n){o.current.delete(t),l(t,n);return}return(async()=>{let n=await gr(t);if(!e&&Zn().sessionId===t){if(n?.directory){o.current.delete(t);let e=bt.getState();(e.currentSessionId!==t||e.currentSessionDirectory!==n.directory)&&l(t,n.directory);return}Ze.getState().hasLoaded&&y(t)}})(),()=>{e=!0}},[_,v,d,u,y,g,s.isNewSession,s.sessionId,l]),Q.useEffect(()=>{let t=u===s.sessionId&&!!d;if(!s.sessionId||s.isNewSession||e||t)return;let n=s.sessionId,r=setTimeout(()=>{let e=bt.getState(),t=e.currentSessionId===n&&!!e.currentSessionDirectory;Zn().sessionId===n&&!t&&y(n)},Iu);return()=>clearTimeout(r)},[d,u,y,e,s.sessionId]),Q.useEffect(()=>{if(e||n)return;let t=bt.getState().currentSessionId,r=!!bt.getState().newSessionDraft?.open;return bt.subscribe(e=>{let n=e.currentSessionId,i=!!e.newSessionDraft?.open;n===t&&i===r||a.current||(t=n,r=i,S(),c(Zn()))})},[e,n,S]),Q.useEffect(()=>{if(e||n)return;let t=j.getState().activeMainTab,r=j.getState().isSettingsDialogOpen,i=j.getState().settingsPage,o=j.getState().pendingDiffFile,s=j.getState().activeGuiPage;return j.subscribe(e=>{if(a.current)return;let n=e.activeMainTab!==t,c=e.activeGuiPage!==s&&e.activeMainTab===`plugin`,l=e.isSettingsDialogOpen!==r,u=e.settingsPage!==i,d=e.pendingDiffFile!==o&&e.activeMainTab===`diff`;t=e.activeMainTab,s=e.activeGuiPage,r=e.isSettingsDialogOpen,i=e.settingsPage,o=e.pendingDiffFile,(n||c||l||u||d)&&S()})},[e,n,S]),Q.useEffect(()=>{if(e||n)return;let t=Nt();return Mt.subscribe(()=>{let e=Nt(),n=e!==t;t=e,!(!n||a.current||j.getState().activeMainTab!==`assistant`)&&S()})},[e,n,S]),Q.useEffect(()=>{if(typeof window>`u`||e||n)return;let t=()=>{let e=Zn();if(c(e),$n())b(e);else{let e=j.getState();e.isSettingsDialogOpen&&p(!1),e.activeMainTab!==`chat`&&f(`chat`)}};return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t)}},[b,e,n,f,p]),Q.useEffect(()=>{if(!(e||n))return t(e=>{i(e)&&(o.current.clear(),queueMicrotask(()=>{c(Zn())}))})},[e,n])}var zu=(e,t)=>{if(!t||t.length<2)return e;let n=t.map(e=>e.name).filter(Boolean).sort((e,t)=>t.length-e.length);return e.map(([e,t])=>{let r=n.find(t=>e.startsWith(`${t} · `));return r?[e,{...t,accountName:r}]:[e,t]})},Bu=(e,t)=>{let n=e[t]?.accountName;return!n||t>0&&e[t-1].accountName===n?null:new Set(e.map(e=>e.accountName).filter(Boolean)).size>1?n:null},Vu=(e,t)=>Bu(e.map(([,e])=>e),t),Hu=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``)||`/`,Uu=(e,t)=>{let n=new Set;for(let r of e){if(!r.trim())continue;let e=Hu(r);n.add(e);for(let[r,i]of t)if(Hu(r)===e)for(let e of i)e.path.trim()&&n.add(Hu(e.path))}return[...n]},Wu=(e,t,n)=>{let r=Uu(e,t),i=n?.currentDirectory?.trim()??``;if(!i)return{directories:r};let a=Hu(i),o=null;for(let t of e){if(!t.trim())continue;let e=Hu(t);(a===e||a.startsWith(`${e}/`))&&(!o||e.length>o.length)&&(o=e)}for(let[e,n]of t){let t=Hu(e);for(let e of n){if(!e.path.trim())continue;let n=Hu(e.path);(a===n||a.startsWith(`${n}/`))&&(!o||t.length>o.length)&&(o=t)}}if(!o)return r.includes(a)?{directories:r,priorityDirectories:[a]}:{directories:r};let s=new Set([o]);for(let[e,n]of t)if(Hu(e)===o)for(let e of n)e.path.trim()&&s.add(Hu(e.path));r.includes(a)&&s.add(a);let c=r.filter(e=>s.has(e));return c.length===0||c.length>=r.length?{directories:r}:{directories:r,priorityDirectories:c}},Gu=async(e,t=at,n)=>{try{await t(e,n)}catch(e){console.warn(`[SessionStartup] Initial session index sync failed:`,e)}finally{Je()}},Ku=async(e,t,n=at,r=tt)=>{r().catch(e=>{console.warn(`[SessionStartup] Early session index hydrate failed:`,e)}),await e;let i=t();await Gu(i.directories,n,{priorityDirectories:i.priorityDirectories})},qu=()=>{let e=(0,qi.c)(2),t=Q.useRef(!1),n,r;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>{if(t.current)return;t.current=!0;let e=Zt(a());Ku(e,Yu),Promise.resolve(e).then(Qu)},r=[],e[0]=n,e[1]=r):(n=e[0],r=e[1]),Q.useLayoutEffect(n,r),null};function Ju(e){return e.path}function Yu(){return Wu(ct.getState().projects.map(Ju),bt.getState().availableWorktreesByProject,{currentDirectory:D.getState().currentDirectory})}function Xu(e){return e.path}function Zu(e){console.warn(`[SessionStartup] Batch git discovery failed (fallback to per-directory):`,e)}function Qu(){let e=ct.getState().projects.map(Xu);e.length!==0&&Jt(e).catch(Zu)}var $u=()=>{let e=(0,qi.c)(13),[t,n]=(0,Q.useState)(!1),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{n(y())},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Q.useEffect)(r,i);let a;e[2]===t?a=e[3]:(a=async e=>t?await u(e):{success:!0,path:e},e[2]=t,e[3]=a);let o=a,s;e[4]===t?s=e[5]:(s=async e=>t?await f(e):{success:!0},e[4]=t,e[5]=s);let c=s,d;e[6]===t?d=e[7]:(d=async e=>t?await l(e):{success:!0},e[6]=t,e[7]=d);let p=d,m;return e[8]!==t||e[9]!==o||e[10]!==c||e[11]!==p?(m={isDesktop:t,requestAccess:o,startAccessing:c,stopAccessing:p},e[8]=t,e[9]=o,e[10]=c,e[11]=p,e[12]=m):m=e[12],m},ed=e=>e.trim().replace(/\s+/g,`-`).replace(/[^A-Za-z0-9._/-]/g,`-`).replace(/-+/g,`-`).replace(/\/{2,}/g,`/`).replace(/\/-+/g,`/`).replace(/-+\//g,`/`).replace(/^[-/]+/,``).replace(/[-/]+$/,``),td=({currentBranch:e,onRename:t,showEditButton:n=!0,iconOnly:r=!1})=>{let{t:i}=be(),[a,o]=Q.useState(!1),[s,c]=Q.useState(e||``),[l,u]=Q.useState(!1),d=Q.useRef(null),f=()=>{!e||!t||(c(e),o(!0),setTimeout(()=>d.current?.focus(),0))},p=async()=>{if(!e||!t||!s.trim())return;let n=ed(s);if(n===e){o(!1);return}u(!0);try{await t(e,n),o(!1),c(``)}finally{u(!1)}},m=()=>{o(!1),c(``)},h=e=>{e.key===`Enter`?(e.preventDefault(),p()):e.key===`Escape`&&(e.preventDefault(),m())};if(a)return(0,$.jsx)(`div`,{className:`flex h-6 items-center gap-1.5 rounded-md bg-primary/12 px-1.5`,children:(0,$.jsxs)(`form`,{className:`flex w-full items-center gap-1.5`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,$.jsx)(Z,{name:`git-branch`,className:`size-3.5 text-primary`}),(0,$.jsx)(`input`,{ref:d,value:s,onChange:e=>c(e.target.value),className:`flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground`,placeholder:i(`gitView.branch.namePlaceholder`),onKeyDown:h,autoFocus:!0}),(0,$.jsx)(`button`,{type:`submit`,disabled:l,"aria-label":i(l?`gitView.branch.renameSaving`:`gitView.branch.renameSave`),title:i(l?`gitView.branch.renameSaving`:`gitView.branch.renameSave`),className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:l?(0,$.jsx)(Z,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,$.jsx)(Z,{name:`check`,className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`button`,onClick:m,disabled:l,"aria-label":i(`gitView.branch.renameCancel`),title:i(`gitView.branch.renameCancel`),className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:(0,$.jsx)(Z,{name:`close`,className:`size-3.5`})})]})});let g=e||i(`gitView.branch.detachedHead`);return r?(0,$.jsxs)(An,{children:[(0,$.jsx)(On,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50`,onClick:f,disabled:!e||!t,"aria-label":g,children:(0,$.jsx)(Z,{name:`git-branch`,className:`size-3.5`})})}),(0,$.jsx)(kn,{sideOffset:8,children:g})]}):(0,$.jsxs)(`div`,{className:`flex h-6 w-full min-w-0 items-center gap-1 px-0`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`size-3.5 text-primary shrink-0`}),(0,$.jsxs)(`div`,{className:`inline-flex min-w-0 max-w-full items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:g}),n&&t&&e&&(0,$.jsx)(X,{variant:`ghost`,size:`xs`,className:`size-6 p-0 shrink-0`,onClick:f,title:i(`gitView.branch.renameTitle`),children:(0,$.jsx)(Z,{name:`edit`,className:`size-3.5`})})]})]})},nd=e=>{let t=(0,qi.c)(38),{syncAction:n,remotes:r,onSync:i,disabled:a,aheadCount:o,behindCount:s,trackingRemoteName:c,hasUncommittedChanges:l}=e,u;t[0]===r?u=t[1]:(u=r===void 0?[]:r,t[0]=r,t[1]=u);let d=u,f=o===void 0?0:o,p=s===void 0?0:s,m=l!==void 0&&l,{t:h}=be(),g;t[2]!==d||t[3]!==c?(g=d.find(e=>e.name===c)??d[0],t[2]=d,t[3]=c,t[4]=g):g=t[4];let _=g,v=p>0&&m,y=a||n!==null||!_||v,b=f>0||p>0,x;t[5]!==f||t[6]!==p||t[7]!==v||t[8]!==b||t[9]!==h||t[10]!==_?(x=v?h(`gitView.sync.commitOrStashTooltip`):_?b?h(`gitView.sync.syncChangesTooltip`,{ahead:f,behind:p}):h(`gitView.sync.syncChanges`):h(`gitView.sync.noRemoteTooltip`),t[5]=f,t[6]=p,t[7]=v,t[8]=b,t[9]=h,t[10]=_,t[11]=x):x=t[11];let S=x,C;t[12]!==i||t[13]!==_?(C=()=>{_&&i(_)},t[12]=i,t[13]=_,t[14]=C):C=t[14];let w=C,T=b?0:void 0,E;t[15]!==f||t[16]!==p||t[17]!==b||t[18]!==h?(E=b?h(`gitView.sync.syncChangesTooltip`,{ahead:f,behind:p}):h(`gitView.sync.syncChanges`),t[15]=f,t[16]=p,t[17]=b,t[18]=h,t[19]=E):E=t[19];let D;t[20]===n?D=t[21]:(D=n===`sync`?(0,$.jsx)(Z,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,$.jsx)(Z,{name:`refresh`,className:`size-3.5`}),t[20]=n,t[21]=D);let O;t[22]===b?O=t[23]:(O=b?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`absolute -right-0.5 top-0 size-1 rounded-full bg-[var(--status-error)] ring-1 ring-[var(--surface-background)]`}):null,t[22]=b,t[23]=O);let k;t[24]!==D||t[25]!==O?(k=(0,$.jsxs)(`span`,{className:`relative flex size-3.5 shrink-0`,children:[D,O]}),t[24]=D,t[25]=O,t[26]=k):k=t[26];let A;t[27]!==w||t[28]!==y||t[29]!==E||t[30]!==k?(A=(0,$.jsx)(On,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:w,disabled:y,className:`inline-flex h-6 w-fit shrink-0 items-center justify-center gap-1 rounded px-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":E,children:k})}),t[27]=w,t[28]=y,t[29]=E,t[30]=k,t[31]=A):A=t[31];let j;t[32]===S?j=t[33]:(j=(0,$.jsx)(kn,{side:`bottom`,sideOffset:8,children:S}),t[32]=S,t[33]=j);let M;return t[34]!==A||t[35]!==j||t[36]!==T?(M=(0,$.jsxs)(An,{delayDuration:T,children:[A,j]}),t[34]=A,t[35]=j,t[36]=T,t[37]=M):M=t[37],M},rd={branch:`git-branch`,briefcase:`briefcase`,house:`home`,graduation:`graduation-cap`,code:`code`,heart:`heart`,user:`user-3`},id={keyword:`var(--syntax-keyword)`,error:`var(--status-error)`,string:`var(--syntax-string)`,function:`var(--syntax-function)`,type:`var(--syntax-type)`,success:`var(--status-success)`,info:`var(--status-info)`,warning:`var(--status-warning)`};function ad(e){return e&&id[e]||`var(--primary)`}var od=e=>{let t=(0,qi.c)(36),{activeProfile:n,identities:r,onSelect:i,isApplying:a,iconOnly:o}=e,s=o!==void 0&&o,{t:c}=be(),l=rd[n?.icon??`branch`]??`user-3`,u=n?.color,d;t[0]===u?d=t[1]:(d=ad(u),t[0]=u,t[1]=d);let f;t[2]===d?f=t[3]:(f={color:d},t[2]=d,t[3]=f);let p=a||r.length===0,m=a?`loader-4`:l,h=a?`size-4 animate-spin`:`size-4`,g;t[4]!==m||t[5]!==h?(g=(0,$.jsx)(Z,{name:m,className:h}),t[4]=m,t[5]=h,t[6]=g):g=t[6];let _;t[7]!==n?.name||t[8]!==s||t[9]!==c?(_=s?null:(0,$.jsx)(`span`,{className:`git-identity-label min-w-0 flex-1 truncate text-left`,children:n?.name||c(`gitView.header.noIdentity`)}),t[7]=n?.name,t[8]=s,t[9]=c,t[10]=_):_=t[10];let v;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Z,{name:`arrow-down-s`,className:`size-4 opacity-60`}),t[11]=v):v=t[11];let y;t[12]!==f||t[13]!==p||t[14]!==g||t[15]!==_?(y=(0,$.jsx)(On,{asChild:!0,children:(0,$.jsx)(Hn,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-8 min-w-0 max-w-[15rem] justify-start gap-1.5 px-2 py-1 typography-ui-label`,style:f,disabled:p,children:[g,_,v]})})}),t[12]=f,t[13]=p,t[14]=g,t[15]=_,t[16]=y):y=t[16];let b;t[17]===c?b=t[18]:(b=c(`gitView.header.identityTooltip`),t[17]=c,t[18]=b);let x;t[19]===b?x=t[20]:(x=(0,$.jsx)(kn,{sideOffset:8,children:b}),t[19]=b,t[20]=x);let S;t[21]!==y||t[22]!==x?(S=(0,$.jsxs)(An,{children:[y,x]}),t[21]=y,t[22]=x,t[23]=S):S=t[23];let C;if(t[24]!==n?.id||t[25]!==r||t[26]!==i){let e;t[28]!==n?.id||t[29]!==i?(e=e=>(0,$.jsxs)(Fn,{onSelect:()=>i(e),children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e.name}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e.userEmail})]}),n?.id===e.id?(0,$.jsx)(Z,{name:`check`,className:`ml-auto size-4 text-foreground`}):null]},e.id),t[28]=n?.id,t[29]=i,t[30]=e):e=t[30],C=r.map(e),t[24]=n?.id,t[25]=r,t[26]=i,t[27]=C}else C=t[27];let w;t[31]===C?w=t[32]:(w=(0,$.jsx)(Nn,{align:`end`,className:`w-64`,children:C}),t[31]=C,t[32]=w);let T;return t[33]!==S||t[34]!==w?(T=(0,$.jsxs)(Pn,{children:[S,w]}),t[33]=S,t[34]=w,t[35]=T):T=t[35],T},sd=(e,t)=>e??t,cd=e=>e===`/`,ld=e=>e.replace(/\\/g,`/`),ud=e=>{if(!e||cd(e))return e;let t=e;for(;t.length>1&&t.endsWith(`/`);)t=t.slice(0,-1);return t},dd=e=>e.endsWith(`/`),fd=e=>{let t=e.trim();return!t||dd(t)?t:`${t}/`},pd=e=>e.lastIndexOf(`/`),md=e=>{if(dd(e))return e;let t=pd(e);return t<0?e:e.slice(0,t+1)},hd=e=>{let t=pd(e);return e.slice(t+1)},gd=e=>{let t=ud(e.trim());if(!t||t===`~`||t===`~/`||t===`/`)return null;let n=pd(t);return n<0?null:t.startsWith(`~/`)&&n<=1?`~/`:n===0?`/`:`${t.slice(0,n)}/`},_d=e=>dd(e)&&gd(e)!==null,vd=(e,t)=>`${md(e)}${t}/`,yd=e=>{if(!e)return null;let t=ud(ld(e.trim()));return t?t.toLowerCase():null},bd=(e,t)=>{let n=e.trim();return n===`~`?t:n.startsWith(`~/`)?`${t}${n.slice(1)}`:n},xd=e=>typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform)?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey,Sd=e=>{if(!e)return;e.focus({preventScroll:!0});let t=e.value.length;e.setSelectionRange(t,t),e.scrollLeft=e.scrollWidth},Cd=async()=>{try{let e=await s(`/api/fs/home`,{method:`GET`,headers:{Accept:`application/json`}});if(e.ok){let t=await e.json();if(typeof t.home==`string`&&t.home.trim().length>0)return ld(t.home.trim())}}catch{}return E.getFilesystemHome().catch(()=>null)},wd=({open:e,onOpenChange:t,forceMobile:n})=>{let{t:r}=be(),i=D(e=>e.homeDirectory),a=ct(e=>e.projects),o=ct(e=>e.addProject),s=Ci(e=>e.profiles),c=Ci(e=>e.globalIdentity),l=Ci(e=>e.defaultGitIdentityId),u=Ci(e=>e.loadProfiles),d=Ci(e=>e.loadGlobalIdentity),f=Ci(e=>e.loadDefaultGitIdentityId),{isDesktop:p,requestAccess:m,startAccessing:h}=$u(),g=sd(n,Yn().isMobile),_=Q.useRef(null),v=Q.useRef(new Map),[y,b]=Q.useState(``),[x,S]=Q.useState(`~/`),[C,w]=Q.useState([]),[T,O]=Q.useState(!1),[k,A]=Q.useState(!1),[j,M]=Q.useState(0),[N,ee]=Q.useState(!1),[P,F]=Q.useState(!1),[I,L]=Q.useState(!1),[R,z]=Q.useState(``),[te,B]=Q.useState(null),[V,H]=Q.useState(!1),ne=y||i,re=Q.useMemo(()=>new Set(a.map(e=>yd(e.path)).filter(e=>!!e)),[a]);Q.useEffect(()=>{if(!e)return;S(`~/`),w([]),M(0),ee(!1),F(!1),L(!1),z(``),B(null),H(!1),requestAnimationFrame(()=>Sd(_.current));let t=!1;return(async()=>{let e=await Cd();t||(b(e||i||``),requestAnimationFrame(()=>Sd(_.current)))})(),()=>{t=!0}},[i,e]),Q.useEffect(()=>{e&&(u(),d(),f())},[f,u,d,e]);let U=Q.useMemo(()=>{let e=new Map;c&&e.set(c.id,c);for(let t of s)e.set(t.id,t);return Array.from(e.values())},[s,c]);Q.useEffect(()=>{if(!e||!I||te!==null)return;let t=typeof l==`string`?l.trim():``;if(t&&U.some(e=>e.id===t)){B(t);return}let n=U.find(e=>e.authType===`ssh`||e.sshKey);n&&B(n.id)},[U,l,I,e,te]);let W=Q.useMemo(()=>U.find(e=>e.id===te)??null,[U,te]),ie=Q.useMemo(()=>md(x),[x]),ae=Q.useMemo(()=>dd(x)?``:hd(x),[x]),oe=Q.useMemo(()=>ne?bd(ie,ne):``,[ie,ne]);Q.useEffect(()=>{if(!e||!oe){w([]);return}let t=!1;return O(!0),A(!1),E.listLocalDirectory(oe).then(e=>{if(t)return;A(!1);let n=e.filter(e=>e.isDirectory).map(e=>({name:e.name,path:ld(e.path)})).sort((e,t)=>e.name.localeCompare(t.name));w(n)}).catch(()=>{t||(w([]),A(!0))}).finally(()=>{t||O(!1)}),()=>{t=!0}},[oe,e]);let G=Q.useMemo(()=>{let e=ae.toLowerCase(),t=V||ae.startsWith(`.`);return C.filter(n=>n.name.toLowerCase().startsWith(e)&&(t||!n.name.startsWith(`.`)))},[ae,C,V]),K=Q.useMemo(()=>{let e=[];_d(x)&&e.push({type:`up`,value:`browse:up`,name:`..`,path:gd(x)});for(let t of G){let n=yd(t.path);e.push({type:`directory`,value:`browse:${t.path}`,name:t.name,path:t.path,alreadyAdded:!!(n&&re.has(n))})}return e},[re,G,x]);Q.useEffect(()=>{M(0)},[x,K.length]);let se=Q.useMemo(()=>ne?ud(bd(x,ne)):``,[ne,x]),ce=yd(se),q=!!(ce&&re.has(ce)),le=Q.useMemo(()=>ae?G.find(e=>e.name===ae)??null:null,[ae,G]),ue=!!(se&&!q&&(dd(x)&&k||!dd(x)&&ae.trim().length>0&&le===null)),de=!N&&!P&&!q&&!!se,fe=de&&R.trim().length>0,pe=K[j]??null,me=!!pe,he=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform),ge=r(q?`directoryExplorerDialog.actions.alreadyAdded`:I?N?`directoryExplorerDialog.actions.cloning`:`directoryExplorerDialog.actions.cloneAndAdd`:N?`directoryExplorerDialog.actions.adding`:ue?`directoryExplorerDialog.actions.createAndAdd`:`directoryExplorerDialog.actions.addProject`);Q.useLayoutEffect(()=>{e&&Sd(_.current)},[e]),Q.useLayoutEffect(()=>{let e=K[j];e&&v.current.get(e.value)?.scrollIntoView({block:`nearest`})},[j,K]);let _e=J(()=>{t(!1)}),ve=J(e=>{let t=bt.getState();t.newSessionDraft?.open&&t.setNewSessionDraftTarget({projectId:e.id,directoryOverride:e.path},{force:!0})}),ye=J(e=>{let t={selectedProjectId:e.id,directoryOverride:e.path,preserveDirectoryOverride:!0};if(g){St.getState().openDraft(t);return}bt.getState().openNewSessionDraft(t)}),xe=J((e,t)=>{e.stopPropagation();let n=yd(t);if(n&&re.has(n))return;let i=o(t);if(!i){yt.error(r(`directoryExplorerDialog.toast.failedToAddProject`),{description:r(`directoryExplorerDialog.toast.selectValidDirectoryPath`)});return}ve(i)}),Se=J(async e=>{if(!e||N)return;let t=yd(e);if(t&&re.has(t))return;let n=e;ee(!0);try{let t=!I&&ue&&yd(e)===yd(se);if(I){let t=R.trim();if(!t){yt.error(r(`directoryExplorerDialog.toast.cloneUrlRequired`));return}n=(await E.cloneRepository({remoteUrl:t,destinationPath:e,gitIdentityId:W?.id??null})).path}else t&&await E.createDirectory(e);let i=o(n);if(!i){yt.error(r(`directoryExplorerDialog.toast.failedToAddProject`),{description:r(`directoryExplorerDialog.toast.selectValidDirectoryPath`)});return}ye(i),_e()}catch(e){yt.error(r(`directoryExplorerDialog.toast.failedToSelectDirectory`),{description:e instanceof Error?e.message:r(`directoryExplorerDialog.toast.unknownError`)})}finally{ee(!1)}}),Ce=J(e=>{S(fd(e))}),we=J(e=>{S(vd(x,e.name))}),Te=J(e=>{if(e){if(e.type===`up`){e.path&&Ce(e.path);return}we(e)}}),Ee=J(async()=>{if(!(!p||P)){F(!0);try{let e=await m(se);if(!e.success||!e.path){e.error&&e.error!==`Directory selection cancelled`&&yt.error(r(`directoryExplorerDialog.toast.failedToSelectDirectory`),{description:e.error});return}let t=await h(e.path);if(!t.success){yt.error(r(`directoryExplorerDialog.toast.failedToOpenDirectory`),{description:t.error||r(`directoryExplorerDialog.toast.desktopCouldNotGrantAccess`)});return}await Se(e.path)}catch(e){yt.error(r(`directoryExplorerDialog.toast.failedToSelectDirectory`),{description:e instanceof Error?e.message:r(`directoryExplorerDialog.toast.unknownError`)})}finally{F(!1)}}}),De=J(e=>{if(e.key===`ArrowDown`){e.preventDefault(),M(e=>Math.min(K.length-1,e+1));return}if(e.key===`ArrowUp`){e.preventDefault(),M(e=>Math.max(0,e-1));return}if(e.key===`Enter`){if(e.preventDefault(),xd(e)){Se(se);return}me&&Te(pe);return}e.key===`Backspace`&&x===``&&(e.preventDefault(),_e())}),Oe=(0,$.jsxs)(X,{type:`button`,variant:`ghost`,size:`xs`,"aria-pressed":V,onClick:()=>H(e=>!e),className:`yuri-directory-hidden-toggle shrink-0 text-muted-foreground`,children:[(0,$.jsx)(Z,{name:V?`checkbox`:`checkbox-blank`,className:`size-3.5`}),r(`directoryExplorerDialog.toggle.showHidden`)]}),ke=(0,$.jsxs)(`div`,{className:`yuri-directory-inputs`,children:[I?(0,$.jsxs)(`div`,{className:`yuri-directory-field`,children:[(0,$.jsx)(Dn,{value:R,onChange:e=>z(e.target.value),placeholder:r(`directoryExplorerDialog.clone.remoteUrlPlaceholder`),"aria-label":r(`directoryExplorerDialog.clone.remoteUrlPlaceholder`),className:`min-w-0 flex-1 font-mono`,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`}),(0,$.jsx)(od,{activeProfile:W,identities:U,onSelect:e=>B(e.id),isApplying:N,iconOnly:!0})]}):null,(0,$.jsxs)(`div`,{className:`yuri-directory-field`,children:[(0,$.jsx)(Z,{name:`folder-add`,className:`size-4 shrink-0 text-muted-foreground`}),(0,$.jsx)(Dn,{ref:_,value:x,onChange:e=>S(ld(e.target.value)),onKeyDown:De,placeholder:r(`directoryExplorerDialog.pathInput.placeholder`),"aria-label":r(`directoryExplorerDialog.pathInput.placeholder`),className:`min-w-0 flex-1 font-mono`,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`})]})]}),Ae=(0,$.jsx)(Yr,{outerClassName:`yuri-directory-results`,className:`yuri-directory-list`,"aria-label":r(`directoryExplorerDialog.browse.directories`),"aria-busy":T,disableHorizontal:!0,children:T?(0,$.jsx)(`div`,{className:`yuri-directory-empty text-center text-muted-foreground`,role:`status`,children:r(`directoryExplorerDialog.browse.loading`)}):K.length===0?(0,$.jsx)(`div`,{className:`yuri-directory-empty text-center text-muted-foreground`,role:`status`,children:r(`directoryExplorerDialog.browse.empty`)}):(0,$.jsx)(`div`,{children:K.map((e,t)=>{let n=t===j;return(0,$.jsxs)(`div`,{"data-directory-row":e.type,"data-selected":n,onMouseEnter:()=>M(t),className:Y(`yuri-directory-row`,n&&`bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)]`,!n&&`hover:bg-interactive-hover/50`),children:[(0,$.jsxs)(`button`,{ref:t=>{t?v.current.set(e.value,t):v.current.delete(e.value)},type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>Te(e),className:`yuri-directory-entry`,title:e.path??e.name,children:[e.type===`up`?(0,$.jsx)(Z,{name:`arrow-left-s`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground/80`}):(0,$.jsx)(Z,{name:`folder-6`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground/80`}),(0,$.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:(0,$.jsx)(`span`,{className:`yuri-directory-name truncate text-foreground`,children:e.name})})]}),e.type===`directory`&&e.alreadyAdded?(0,$.jsx)(`span`,{className:`yuri-directory-added shrink-0 text-muted-foreground`,children:r(`directoryExplorerDialog.browse.addedBadge`)}):e.type===`directory`?(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,onMouseDown:e=>e.stopPropagation(),onClick:t=>xe(t,e.path),className:`shrink-0 text-muted-foreground hover:text-foreground`,title:r(`directoryExplorerDialog.browse.quickAdd`),"aria-label":r(`directoryExplorerDialog.browse.quickAdd`),children:(0,$.jsx)(Z,{name:`add`,className:`h-3.5 w-3.5`})}):null]},e.value)})})}),je=(0,$.jsxs)(`div`,{className:`yuri-directory-content`,children:[ke,Ae]}),Me=g?null:(0,$.jsxs)(`div`,{className:`yuri-directory-shortcuts text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsxs)(mn,{variant:`hint`,className:`gap-0.5`,"aria-label":`↑ ↓`,children:[(0,$.jsx)(Z,{name:`arrow-up`,className:`size-2.5`}),(0,$.jsx)(Z,{name:`arrow-down`,className:`size-2.5`})]}),r(`directoryExplorerDialog.footer.navigate`)]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(mn,{variant:`hint`,"aria-label":`Enter`,children:(0,$.jsx)(Z,{name:`corner-down-left`,className:`size-2.5`})}),r(`directoryExplorerDialog.footer.select`)]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsxs)(mn,{variant:`hint`,className:`gap-0.5`,"aria-label":he?`⌘ Enter`:`Ctrl Enter`,children:[he?(0,$.jsx)(Z,{name:`command`,className:`size-2.5`}):`Ctrl`,(0,$.jsx)(Z,{name:`corner-down-left`,className:`size-2.5`})]}),r(`directoryExplorerDialog.footer.add`)]})]}),Ne=()=>(0,$.jsxs)(`div`,{className:`yuri-directory-actions`,children:[p?(0,$.jsx)(X,{variant:`ghost`,size:`xs`,onClick:Ee,disabled:N||P||I,children:r(P?`directoryExplorerDialog.actions.openingFinder`:`directoryExplorerDialog.actions.openInFinder`)}):null,(0,$.jsx)(X,{variant:`ghost`,size:`xs`,onClick:()=>L(e=>!e),disabled:N||P,children:r(I?`directoryExplorerDialog.actions.addLocalProject`:`directoryExplorerDialog.actions.cloneRepository`)}),(0,$.jsx)(X,{size:`xs`,onClick:()=>void Se(se),disabled:I?!fe:!de,children:ge})]});return g?(0,$.jsxs)(dr,{id:`mobile-directory-explorer-sheet`,open:e,onOpenChange:t,title:(0,$.jsx)(`h2`,{className:`yuri-directory-title truncate text-foreground`,children:r(`directoryExplorerDialog.title`)}),trailing:Oe,ariaLabel:r(`directoryExplorerDialog.title`),closeAriaLabel:r(`mobile.surface.closeAria`),resizeAriaLabel:r(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,className:`yuri-directory-mobile`,children:[je,(0,$.jsx)(`div`,{className:`yuri-directory-footer`,children:Ne()})]}):(0,$.jsx)(qt,{open:e,onOpenChange:t,children:(0,$.jsxs)(Wt,{presentation:`picker`,className:`yuri-directory-dialog`,initialFocus:!1,children:[(0,$.jsx)(Ht,{className:`yuri-directory-header`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,$.jsx)(Gt,{className:`yuri-directory-title truncate`,children:r(`directoryExplorerDialog.title`)}),Oe]})}),je,(0,$.jsxs)(Ut,{className:`yuri-directory-footer`,children:[Me,Ne()]})]})})},Td=`yuri-settings-group-row border-b border-[var(--yuri-settings-row-divider)] last:border-b-0`,Ed=`yuri-settings-group-label`,Dd=Ki();function Od(e){if(!e||!e.trim())return{valid:!1,error:`required`};try{return Dd.CronExpressionParser.parse(e),{valid:!0}}catch(e){return{valid:!1,error:e instanceof Error?e.message:`Invalid cron expression`}}}function kd(e,t,n=4){try{let r=t?{tz:t,currentDate:new Date}:{currentDate:new Date},i=Dd.CronExpressionParser.parse(e,r),a=[];for(let e=0;e<n;e+=1){let e=i.next();e&&a.push(e.toDate())}return a}catch{return[]}}var Ad=[{expression:`*/5 * * * *`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.every5min`},{expression:`0 * * * *`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.everyHour`},{expression:`0 9 * * 1`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.monday9am`},{expression:`0 9,17 * * *`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.9am5pm`},{expression:`0 0 1 * *`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.firstOfMonth`}],jd=[0,1,2,3,4,5,6],Md=`!h-9 !min-h-9 w-full min-w-0 rounded-full border-0 bg-[var(--surface-elevated)] px-3 py-1 ring-1 ring-inset ring-border/60 transition-[background-color,box-shadow] duration-150 ease-out hover:[&:not(:focus)]:bg-[var(--surface-subtle)] hover:[&:not(:focus)]:ring-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] data-[popup-open]:bg-[var(--surface-subtle)] data-[popup-open]:shadow-sm motion-reduce:transition-none`,Nd=`yuri-settings-inline-value`,Pd=`yuri-settings-split-row ${Td}`,Fd=Nd,Id=Pd,Ld=()=>{let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`},Rd=e=>{let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]),a=new Date(n,r-1,i);return Number.isNaN(a.getTime())||a.getFullYear()!==n||a.getMonth()!==r-1||a.getDate()!==i?null:a},zd=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`,Bd=(e,t,n)=>{let r=Rd(e);return r?new Intl.DateTimeFormat(n,{month:`short`,day:`numeric`,year:`numeric`}).format(r):t},Vd=(e,t)=>new Date(e.getFullYear(),e.getMonth()+t,1),Hd=(e,t)=>{let n=e.getFullYear(),r=e.getMonth(),i=(new Date(n,r,1).getDay()-t+7)%7,a=new Date(n,r+1,0).getDate(),o=new Date(n,r,0).getDate(),s=[];for(let e=0;e<42;e+=1){let t=e-i+1;if(t<=0){let e=o+t;s.push({date:new Date(n,r-1,e),inCurrentMonth:!1});continue}if(t>a){s.push({date:new Date(n,r+1,t-a),inCurrentMonth:!1});continue}s.push({date:new Date(n,r,t),inCurrentMonth:!0})}return s},Ud=e=>{let t=/^([01]\d|2[0-3]):([0-5]\d)$/.exec(e);if(!t)return{hour24:`00`,hour12:`12`,minute:`00`,meridiem:`AM`};let n=Number(t[1]),r=t[2],i=n>=12?`PM`:`AM`,a=n%12==0?12:n%12;return{hour24:String(n).padStart(2,`0`),hour12:String(a).padStart(2,`0`),minute:r,meridiem:i}},Wd=(e,t,n)=>{let r=Number(e),i=Number(t),a=Number.isFinite(r)?Math.min(12,Math.max(1,r)):12,o=Number.isFinite(i)?Math.min(59,Math.max(0,i)):0,s=a%12;return n===`PM`&&(s+=12),`${String(s).padStart(2,`0`)}:${String(o).padStart(2,`0`)}`},Gd=(e,t)=>{let{max:n,min:r=0,loop:i=!1}=t,a=Number.parseInt(e,10);return Number.isFinite(a)?(i?(a>n&&(a=r),a<r&&(a=n)):(a>n&&(a=n),a<r&&(a=r)),String(a).padStart(2,`0`)):`00`},Kd=e=>/^(0[1-9]|1[0-2])$/.test(e)?e:Gd(e,{min:1,max:12}),qd=e=>/^[0-5][0-9]$/.test(e)?e:Gd(e,{max:59}),Jd=(e,t)=>Gd(String(Number.parseInt(e,10)+t),{min:1,max:12,loop:!0}),Yd=(e,t)=>Gd(String(Number.parseInt(e,10)+t),{min:0,max:59,loop:!0}),Xd=e=>{try{let t=Intl.Locale;if(typeof t!=`function`)return 1;let n=new t(e).weekInfo?.firstDay;return typeof n==`number`?n%7:1}catch{return 1}},Zd=e=>{try{let t=new Intl.DateTimeFormat(e,{hour:`numeric`}).resolvedOptions();return typeof t.hour12==`boolean`?!t.hour12:t.hourCycle===`h23`||t.hourCycle===`h24`}catch{return!0}},Qd=e=>{let t=new Intl.DateTimeFormat(e,{weekday:`short`}),n=new Date(2023,0,1);return jd.map(e=>t.format(new Date(n.getFullYear(),n.getMonth(),n.getDate()+e)))},$d=(e,t)=>[...e.slice(t),...e.slice(0,t)],ef=e=>{let t=(0,qi.c)(9),{htmlFor:n,required:r,className:i,children:a}=e,o;t[0]===i?o=t[1]:(o=Y(`typography-ui-label font-normal text-foreground`,i),t[0]=i,t[1]=o);let s;t[2]===r?s=t[3]:(s=r&&(0,$.jsx)(`span`,{className:`ml-0.5 text-destructive`,children:`*`}),t[2]=r,t[3]=s);let c;return t[4]!==a||t[5]!==n||t[6]!==o||t[7]!==s?(c=(0,$.jsx)(`div`,{className:`flex items-center gap-1.5`,children:(0,$.jsxs)(`label`,{htmlFor:n,className:o,children:[a,s]})}),t[4]=a,t[5]=n,t[6]=o,t[7]=s,t[8]=c):c=t[8],c},tf=e=>{let t=(0,qi.c)(85),{value:n,onChange:r,className:i,use24Hour:a,hourAriaLabel:o,minuteAriaLabel:s,periodAriaLabel:c,amLabel:l,pmLabel:u}=e,d;t[0]===n?d=t[1]:(d=Ud(n),t[0]=n,t[1]=d);let f=d,p=Q.useRef(null),m=Q.useRef(null),[h,g]=Q.useState(null),[_,v]=Q.useState(null),y=Q.useRef(null),b=Q.useRef(null),x;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>{y.current=e,g(e)},t[2]=x):x=t[2];let S=x,C;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{b.current=e,v(e)},t[3]=C):C=t[3];let w=C,T=ff,E=pf,D=mf,O;t[4]!==r||t[5]!==f.meridiem||t[6]!==f.minute||t[7]!==a?(O=e=>{let t=e.replace(/\D/g,``).slice(0,2);S(t),t.length===2&&(r(a?D(T(t),f.minute):Wd(Kd(t),f.minute,f.meridiem)),S(null),m.current?.focus())},t[4]=r,t[5]=f.meridiem,t[6]=f.minute,t[7]=a,t[8]=O):O=t[8];let k=O,A;t[9]!==r||t[10]!==f.meridiem||t[11]!==f.minute||t[12]!==a?(A=()=>{let e=y.current;if(e!==null&&(S(null),e.length!==0)){if(a){r(D(T(e.padStart(2,`0`)),f.minute));return}r(Wd(Kd(e.padStart(2,`0`)),f.minute,f.meridiem))}},t[9]=r,t[10]=f.meridiem,t[11]=f.minute,t[12]=a,t[13]=A):A=t[13];let j=A,M;t[14]!==r||t[15]!==f.hour12||t[16]!==f.hour24||t[17]!==f.meridiem||t[18]!==a?(M=e=>{let t=e.replace(/\D/g,``).slice(0,2);w(t),t.length===2&&(r(a?D(f.hour24,qd(t)):Wd(f.hour12,qd(t),f.meridiem)),w(null))},t[14]=r,t[15]=f.hour12,t[16]=f.hour24,t[17]=f.meridiem,t[18]=a,t[19]=M):M=t[19];let N=M,ee;t[20]!==r||t[21]!==f.hour12||t[22]!==f.hour24||t[23]!==f.meridiem||t[24]!==a?(ee=()=>{let e=b.current;e!==null&&(w(null),e.length!==0&&r(a?D(f.hour24,qd(e.padStart(2,`0`))):Wd(f.hour12,qd(e.padStart(2,`0`)),f.meridiem)))},t[20]=r,t[21]=f.hour12,t[22]=f.hour24,t[23]=f.meridiem,t[24]=a,t[25]=ee):ee=t[25];let P=ee,F;t[26]!==r||t[27]!==f.hour12||t[28]!==f.hour24||t[29]!==f.meridiem||t[30]!==f.minute||t[31]!==a?(F=e=>r(a?D(E(f.hour24,e),f.minute):Wd(Jd(f.hour12,e),f.minute,f.meridiem)),t[26]=r,t[27]=f.hour12,t[28]=f.hour24,t[29]=f.meridiem,t[30]=f.minute,t[31]=a,t[32]=F):F=t[32];let I=F,L;t[33]!==r||t[34]!==f.hour12||t[35]!==f.hour24||t[36]!==f.meridiem||t[37]!==f.minute||t[38]!==a?(L=e=>r(a?D(f.hour24,Yd(f.minute,e)):Wd(f.hour12,Yd(f.minute,e),f.meridiem)),t[33]=r,t[34]=f.hour12,t[35]=f.hour24,t[36]=f.meridiem,t[37]=f.minute,t[38]=a,t[39]=L):L=t[39];let R=L,z;t[40]!==r||t[41]!==f.hour12||t[42]!==f.meridiem||t[43]!==f.minute?(z=e=>{e!==f.meridiem&&r(Wd(f.hour12,f.minute,e))},t[40]=r,t[41]=f.hour12,t[42]=f.meridiem,t[43]=f.minute,t[44]=z):z=t[44];let te=z,B;t[45]!==j||t[46]!==I?(B=e=>{if(e.key===`ArrowRight`){e.preventDefault(),j(),m.current?.focus();return}(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),S(null),I(e.key===`ArrowUp`?1:-1))},t[45]=j,t[46]=I,t[47]=B):B=t[47];let V=B,H;t[48]!==P||t[49]!==R?(H=e=>{if(e.key===`ArrowLeft`&&(e.currentTarget.selectionStart??0)===0){e.preventDefault(),P(),p.current?.focus();return}(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),w(null),R(e.key===`ArrowUp`?1:-1))},t[48]=P,t[49]=R,t[50]=H):H=t[50];let ne=H,re=a?`px-2`:`pl-2 pr-1`,U;t[51]!==i||t[52]!==re?(U=Y(`flex h-9 w-full min-w-0 items-center gap-1 rounded-full border-0 bg-[var(--surface-elevated)] ring-1 ring-inset ring-border/60 transition duration-200 ease-out hover:[&:not(:focus-within)]:bg-[var(--surface-subtle)] hover:[&:not(:focus-within)]:ring-transparent focus-within:ring-2 focus-within:ring-[var(--interactive-focus-ring)]`,re,i),t[51]=i,t[52]=re,t[53]=U):U=t[53];let W=h??(a?f.hour24:f.hour12),ie;t[54]===k?ie=t[55]:(ie=e=>k(e.target.value),t[54]=k,t[55]=ie);let ae;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>S(``),t[56]=ae):ae=t[56];let oe;t[57]!==j||t[58]!==o||t[59]!==V||t[60]!==W||t[61]!==ie?(oe=(0,$.jsx)(`input`,{ref:p,inputMode:`numeric`,value:W,onChange:ie,onKeyDown:V,onFocus:ae,onBlur:j,maxLength:2,"aria-label":o,className:`h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover`}),t[57]=j,t[58]=o,t[59]=V,t[60]=W,t[61]=ie,t[62]=oe):oe=t[62];let G;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(`span`,{className:`font-mono text-sm text-muted-foreground`,children:`:`}),t[63]=G):G=t[63];let K=_??f.minute,se;t[64]===N?se=t[65]:(se=e=>N(e.target.value),t[64]=N,t[65]=se);let ce;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(ce=()=>w(``),t[66]=ce):ce=t[66];let q;t[67]!==P||t[68]!==s||t[69]!==ne||t[70]!==K||t[71]!==se?(q=(0,$.jsx)(`input`,{ref:m,inputMode:`numeric`,value:K,onChange:se,onKeyDown:ne,onFocus:ce,onBlur:P,maxLength:2,"aria-label":s,className:`h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover`}),t[67]=P,t[68]=s,t[69]=ne,t[70]=K,t[71]=se,t[72]=q):q=t[72];let le;t[73]!==l||t[74]!==f.meridiem||t[75]!==c||t[76]!==u||t[77]!==te||t[78]!==a?(le=a?null:(0,$.jsxs)(xr,{value:f.meridiem,onValueChange:e=>te(e),children:[(0,$.jsx)(br,{"aria-label":c,className:`ml-1 h-7 w-fit border-0 bg-transparent pl-2 pr-1 shadow-none hover:bg-interactive-hover focus:ring-0`,children:(0,$.jsx)(_r,{})}),(0,$.jsxs)(yr,{className:`motion-reduce:transition-none`,children:[(0,$.jsx)(vr,{value:`AM`,children:l}),(0,$.jsx)(vr,{value:`PM`,children:u})]})]}),t[73]=l,t[74]=f.meridiem,t[75]=c,t[76]=u,t[77]=te,t[78]=a,t[79]=le):le=t[79];let ue;return t[80]!==U||t[81]!==oe||t[82]!==q||t[83]!==le?(ue=(0,$.jsxs)(`div`,{className:U,children:[oe,G,q,le]}),t[80]=U,t[81]=oe,t[82]=q,t[83]=le,t[84]=ue):ue=t[84],ue},nf=e=>new Date(e.getFullYear(),e.getMonth(),1),rf=()=>{let e=new Date;return new Date(e.getFullYear(),e.getMonth(),e.getDate())},af=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),of=e=>{if(!e)return[`09:00`];let t=(Array.isArray(e.schedule.times)?e.schedule.times:e.schedule.time?[e.schedule.time]:[]).filter(e=>typeof e==`string`&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(e)).map(e=>e.trim()),n=Array.from(new Set(t)).sort((e,t)=>e.localeCompare(t));return n.length>0?n:[`09:00`]},sf=(e,t)=>{let n=Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`;return e?{id:e.id,name:e.name,enabled:e.enabled,schedule:{kind:e.schedule.kind===`cron`?`cron`:e.schedule.kind===`once`?`once`:e.schedule.kind===`weekly`?`weekly`:`daily`,times:of(e),onceDate:typeof e.schedule.date==`string`&&/^\d{4}-\d{2}-\d{2}$/.test(e.schedule.date)?e.schedule.date:Ld(),onceTime:typeof e.schedule.time==`string`&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(e.schedule.time)?e.schedule.time:`09:00`,weekdays:Array.isArray(e.schedule.weekdays)?e.schedule.weekdays:[1],timezone:e.schedule.timezone||n,cronExpression:e.schedule.kind===`cron`&&typeof e.schedule.cron==`string`?e.schedule.cron:``},execution:{prompt:e.execution.prompt,providerID:e.execution.providerID,modelID:e.execution.modelID,variant:e.execution.variant||``,agent:e.execution.agent||``,goalEnabled:e.execution.goalEnabled===!0},state:e.state}:{name:``,enabled:!0,schedule:{kind:`daily`,times:[`09:00`],onceDate:Ld(),onceTime:`09:00`,weekdays:[1],timezone:n,cronExpression:``},execution:{prompt:``,providerID:t.providerID,modelID:t.modelID,variant:t.variant,agent:t.agent,goalEnabled:!1}}},cf=(e,t)=>{if(!e.name.trim())return t(`sessions.scheduledTasks.editor.validation.taskNameRequired`);if(!e.execution.prompt.trim())return t(`sessions.scheduledTasks.editor.validation.promptRequired`);if(!e.execution.providerID.trim()||!e.execution.modelID.trim())return t(`sessions.scheduledTasks.editor.validation.modelRequired`);if(e.schedule.kind===`once`){if(!/^\d{4}-\d{2}-\d{2}$/.test(e.schedule.onceDate))return t(`sessions.scheduledTasks.editor.validation.dateFormat`);if(!/^([01]\d|2[0-3]):([0-5]\d)$/.test(e.schedule.onceTime))return t(`sessions.scheduledTasks.editor.validation.timeFormat`)}else if(e.schedule.kind===`cron`){if(!e.schedule.cronExpression.trim())return t(`sessions.scheduledTasks.editor.validation.cronRequired`);if(!Od(e.schedule.cronExpression).valid)return t(`sessions.scheduledTasks.editor.validation.cronInvalid`)}else if(e.schedule.times.filter(e=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(e)).length===0)return t(`sessions.scheduledTasks.editor.validation.atLeastOneTime`);return e.schedule.kind===`weekly`&&e.schedule.weekdays.length===0?t(`sessions.scheduledTasks.editor.validation.atLeastOneWeekday`):e.schedule.timezone.trim()?null:t(`sessions.scheduledTasks.editor.validation.timezoneRequired`)},lf=e=>{let t=e.filter(e=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(e));return Array.from(new Set(t)).sort((e,t)=>e.localeCompare(t))},uf=e=>{let t=(0,qi.c)(74),{draft:n,setDraft:r,locale:i,t:a,panel:o,mobilePanel:s}=e,c=o!==void 0&&o,l=s!==void 0&&s,u=c||l,d=l?Id:Pd,f=n.schedule.cronExpression,p;t[0]===f?p=t[1]:(p=f.trim()?Od(f):null,t[0]=f,t[1]=p);let m=p,h;bb0:{if(!m?.valid||!f.trim()){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[2]=e):e=t[2],h=e;break bb0}let e;t[3]!==f||t[4]!==n.schedule.timezone?(e=kd(f,n.schedule.timezone),t[3]=f,t[4]=n.schedule.timezone,t[5]=e):e=t[5],h=e}let g=h,_;t[6]!==n.schedule.timezone||t[7]!==i?(_=e=>new Intl.DateTimeFormat(i,{timeZone:n.schedule.timezone,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}).format(e),t[6]=n.schedule.timezone,t[7]=i,t[8]=_):_=t[8];let v=_,y=u&&`gap-0`,b;t[9]===y?b=t[10]:(b=Y(`flex flex-col gap-3`,y),t[9]=y,t[10]=b);let x=u&&d,S;t[11]===x?S=t[12]:(S=Y(`flex flex-col gap-1`,x),t[11]=x,t[12]=S);let C;t[13]===a?C=t[14]:(C=a(`sessions.scheduledTasks.editor.cronExpression.label`),t[13]=a,t[14]=C);let w;t[15]===C?w=t[16]:(w=(0,$.jsx)(ef,{htmlFor:`sched-cron`,required:!0,children:C}),t[15]=C,t[16]=w);let T=u?``:void 0,E=u&&`yuri-settings-split-row-control flex-wrap`,D;t[17]===E?D=t[18]:(D=Y(`min-w-0`,E),t[17]=E,t[18]=D);let O;t[19]===r?O=t[20]:(O=e=>r(t=>({...t,schedule:{...t.schedule,cronExpression:e.target.value}})),t[19]=r,t[20]=O);let k;t[21]===a?k=t[22]:(k=a(`sessions.scheduledTasks.editor.cronExpression.placeholder`),t[21]=a,t[22]=k);let A=u&&`min-w-[140px] text-right`,j;t[23]===A?j=t[24]:(j=Y(`w-full font-mono`,A),t[23]=A,t[24]=j);let M;t[25]!==f||t[26]!==O||t[27]!==k||t[28]!==j?(M=(0,$.jsx)(Dn,{id:`sched-cron`,value:f,onChange:O,placeholder:k,className:j}),t[25]=f,t[26]=O,t[27]=k,t[28]=j,t[29]=M):M=t[29];let N;t[30]!==f||t[31]!==m||t[32]!==a?(N=m&&!m.valid&&f.trim()?(0,$.jsx)(`span`,{className:`w-full typography-micro text-right text-destructive`,children:a(`sessions.scheduledTasks.editor.validation.cronInvalid`)}):null,t[30]=f,t[31]=m,t[32]=a,t[33]=N):N=t[33];let ee;t[34]!==T||t[35]!==D||t[36]!==M||t[37]!==N?(ee=(0,$.jsxs)(`div`,{"data-settings-value":T,className:D,children:[M,N]}),t[34]=T,t[35]=D,t[36]=M,t[37]=N,t[38]=ee):ee=t[38];let P;t[39]!==w||t[40]!==ee||t[41]!==S?(P=(0,$.jsxs)(`div`,{className:S,children:[w,ee]}),t[39]=w,t[40]=ee,t[41]=S,t[42]=P):P=t[42];let F;t[43]!==v||t[44]!==u||t[45]!==g||t[46]!==d||t[47]!==a?(F=g.length>0?(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1`,u&&[d,`yuri-scheduled-task-detail-row`]),children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:a(`sessions.scheduledTasks.editor.cronExpression.nextRuns`)}),(0,$.jsx)(`span`,{"data-settings-value":u?``:void 0,className:`flex min-w-0 flex-wrap gap-x-4 gap-y-1 typography-micro text-muted-foreground`,children:g.map(e=>(0,$.jsx)(`span`,{className:`whitespace-nowrap tabular-nums`,children:v(e)},e.toISOString()))})]}):null,t[43]=v,t[44]=u,t[45]=g,t[46]=d,t[47]=a,t[48]=F):F=t[48];let I;t[49]!==u||t[50]!==d?(I=u&&[d,`yuri-scheduled-task-detail-row`],t[49]=u,t[50]=d,t[51]=I):I=t[51];let L;t[52]===I?L=t[53]:(L=Y(`flex flex-col gap-1`,I),t[52]=I,t[53]=L);let R;t[54]===a?R=t[55]:(R=a(`sessions.scheduledTasks.editor.cronExpression.examples`),t[54]=a,t[55]=R);let z;t[56]===R?z=t[57]:(z=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:R}),t[56]=R,t[57]=z);let te=u?``:void 0,B;t[58]!==f||t[59]!==r||t[60]!==a?(B=Ad.map(e=>(0,$.jsx)(X,{type:`button`,variant:`chip`,size:`xs`,"aria-pressed":f.trim()===e.expression,title:e.expression,onClick:()=>r(t=>({...t,schedule:{...t.schedule,cronExpression:e.expression}})),children:a(e.labelKey)},e.expression)),t[58]=f,t[59]=r,t[60]=a,t[61]=B):B=t[61];let V;t[62]!==te||t[63]!==B?(V=(0,$.jsx)(`div`,{"data-settings-value":te,className:`flex min-w-0 flex-wrap gap-1.5`,children:B}),t[62]=te,t[63]=B,t[64]=V):V=t[64];let H;t[65]!==L||t[66]!==z||t[67]!==V?(H=(0,$.jsxs)(`div`,{className:L,children:[z,V]}),t[65]=L,t[66]=z,t[67]=V,t[68]=H):H=t[68];let ne;return t[69]!==P||t[70]!==F||t[71]!==H||t[72]!==b?(ne=(0,$.jsxs)(`div`,{className:b,children:[P,F,H]}),t[69]=P,t[70]=F,t[71]=H,t[72]=b,t[73]=ne):ne=t[73],ne};function df(e){let{open:t,task:n,onOpenChange:r,onSave:i,presentation:a=`dialog`,onDirtyChange:o,onRun:s,onOpenTaskHistory:c,onDelete:l,onToggleEnabled:u,actionBusy:d=!1,projectID:f=``,projectOptions:p=[],onProjectChange:m}=e,h=a===`panel`,g=a===`mobile-panel`,_=a===`mobile-tab`,v=g||_,y=g||_,b=h||v,x=v?Fd:Nd,S=v?Id:Pd,{t:C,locale:w}=be(),T=Ye(e=>e.loadProviders),E=Ye(e=>e.loadAgents),D=Ye(e=>e.providers),O=Ye(e=>e.currentProviderId),k=Ye(e=>e.currentModelId),A=Ye(e=>e.currentVariant||``),M=Ye(e=>e.currentAgentName||``),N=j(e=>e.timeFormatPreference),ee=j(e=>e.weekStartPreference),P=j(e=>e.isMobile),[F,I]=Q.useState(()=>sf(n,{providerID:O,modelID:k,variant:A,agent:M})),[L,R]=Q.useState(!1),[z,te]=Q.useState(!1),[B,V]=Q.useState(!1),[H,ne]=Q.useState(``),[re,U]=Q.useState(!1),[W,ie]=Q.useState(``),[ae,oe]=Q.useState(()=>{let e=Rd(n?.schedule?.date||``)||new Date;return new Date(e.getFullYear(),e.getMonth(),1)}),G=Q.useRef(null),K=Q.useRef(null),se=Q.useRef(null),ce=Q.useRef(null),q=Q.useRef(``),le=Q.useRef(void 0),ue=Q.useRef(n);ue.current=n;let de=n?.id||null,fe=Q.useMemo(()=>Zd(w),[w]),pe=Q.useMemo(()=>Xd(w),[w]),me=Q.useMemo(()=>N===`24h`||N!==`12h`&&fe,[N,fe]),he=Q.useMemo(()=>ee===`sunday`?0:ee===`monday`?1:pe,[ee,pe]),ge=Q.useMemo(()=>{let e=Qd(w);return $d(jd.map(t=>({value:t,label:e[t]||``})),he)},[w,he]);Q.useEffect(()=>{t&&(T({source:`scheduledTaskEditor`}),E({source:`scheduledTaskEditor`}))},[t,T,E]),Q.useEffect(()=>{if(!t){le.current=void 0;return}if(le.current===de)return;le.current=de;let e=ue.current,n=sf(e,{providerID:O,modelID:k,variant:A,agent:M});q.current=JSON.stringify(n),I(n),o?.(!1);let r=Rd(e?.schedule?.date||``)||new Date;oe(new Date(r.getFullYear(),r.getMonth(),1)),te(!1),U(!1),V(!1),ie(``),ne(``)},[t,de,O,k,A,M,o]),Q.useEffect(()=>{if(!(!t||!n||F.id!==n.id||F.enabled===n.enabled)&&(I(e=>({...e,enabled:n.enabled})),q.current)){let e=JSON.parse(q.current);q.current=JSON.stringify({...e,enabled:n.enabled})}},[F.enabled,F.id,t,n]),Q.useEffect(()=>{!t||!q.current||o?.(JSON.stringify(F)!==q.current)},[F,o,t]),Q.useEffect(()=>{if(!z)return;let e=e=>{G.current&&!G.current.contains(e.target)&&te(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[z]);let _e=Q.useMemo(()=>D.find(e=>e.id===F.execution.providerID)?.models?.find(e=>e.id===F.execution.modelID),[F.execution.modelID,F.execution.providerID,D]),J=Q.useMemo(()=>_e?.variants?Object.keys(_e.variants):[],[_e]);Q.useEffect(()=>{!_e||!F.execution.variant||J.includes(F.execution.variant)||I(e=>({...e,execution:{...e.execution,variant:``}}))},[J,F.execution.variant,_e]);let ve=Q.useCallback((e,t)=>{I(n=>{let r=new Set(n.schedule.weekdays);return t?r.add(e):r.delete(e),{...n,schedule:{...n.schedule,weekdays:Array.from(r).sort((e,t)=>e-t)}}})},[]),ye=Q.useCallback((e,t)=>{I(n=>{let r=n.schedule.times.slice();return r[e]=t,{...n,schedule:{...n.schedule,times:r}}})},[]),xe=Q.useCallback(e=>{I(t=>{let n=t.schedule.times.filter((t,n)=>n!==e);return{...t,schedule:{...t.schedule,times:n.length>0?n:[`09:00`]}}})},[]),Se=Q.useCallback(()=>{I(e=>({...e,schedule:{...e.schedule,times:[...e.schedule.times,`12:00`]}}))},[]),Ce=Q.useMemo(()=>rf(),[]),we=Q.useMemo(()=>nf(Ce),[Ce]),Te=Q.useMemo(()=>{let e=Rd(F.schedule.onceDate);return e?af(e,Ce)?C(`sessions.scheduledTasks.editor.date.today`):new Intl.DateTimeFormat(w,{weekday:`short`}).format(e):null},[F.schedule.onceDate,w,C,Ce]),Ee=Q.useMemo(()=>nf(ae).getTime()<=we.getTime(),[ae,we]),De=Q.useMemo(()=>ge.map(e=>e.label),[ge]),Oe=Q.useCallback(e=>{I(t=>({...t,schedule:{...t.schedule,onceDate:e}}))},[]),ke=Q.useCallback((e,t)=>{if(e.startsWith(`/`)){let n=e.indexOf(` `),r=e.indexOf(`
147
+ `),i=Math.min(n.length,r.length);for(let e=0;e<i;e+=1)if(n[e]!==r[e])return e+1;return r.length>n.length?n.length+1:n.length>r.length?Math.max(1,r.length):1},jc=e=>/^Binary files .+ differ$/m.test(e)||/^GIT binary patch$/m.test(e),Mc=e=>Array.isArray(e)?e.filter(e=>!e||typeof e!=`object`?!1:typeof e.file==`string`):[],Nc=e=>e===`added`?`A`:e===`deleted`?`D`:`M`,Pc=e=>e.isBinary||typeof e.patch==`string`&&e.patch.length>0||e.fileDiff?!0:e.original.length>0||e.modified.length>0,Fc=(e,t,n)=>jc(t)?{original:``,modified:``,isBinary:!0,patch:t,contextMode:n}:{original:``,modified:``,patch:t,fileDiff:Js(e,t),contextMode:n},Ic=(e,t,n)=>{let r=e??0,i=t??0;return!r&&!i?null:(0,$.jsxs)(`span`,{className:Y(`typography-code flex items-center gap-1 whitespace-nowrap`,n?.shrink?`min-w-0 overflow-hidden`:`flex-shrink-0`,n?.className),children:[r?(0,$.jsxs)(`span`,{style:{color:`var(--status-success)`},children:[`+`,r]}):null,i?(0,$.jsxs)(`span`,{style:{color:`var(--status-error)`},children:[`-`,i]}):null]})},Lc=Q.memo(e=>{let t=(0,qi.c)(53),{scope:n,workingCount:r,stagedCount:i,turnCount:a,onScopeChange:o}=e,{t:s}=be(),[c,l]=Q.useState(!1),u=n===`staged`?i:n===`turn`?a:r,d;t[0]!==n||t[1]!==s?(d=s(n===`staged`?`diffView.scope.staged`:n===`turn`?`diffView.scope.lastTurn`:`diffView.scope.changed`),t[0]=n,t[1]=s,t[2]=d):d=t[2];let f=d,p;t[3]===s?p=t[4]:(p=s(`diffView.scope.selectorAria`),t[3]=s,t[4]=p);let m;t[5]===u?m=t[6]:(m=(0,$.jsxs)(`span`,{className:`diff-toolbar__scope-count`,children:[`: `,u]}),t[5]=u,t[6]=m);let h;t[7]!==f||t[8]!==m?(h=(0,$.jsxs)(`span`,{className:`whitespace-nowrap`,children:[f,m]}),t[7]=f,t[8]=m,t[9]=h):h=t[9];let g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(Z,{name:`arrow-down-s`,className:`size-4 flex-shrink-0 opacity-60`}),t[10]=g):g=t[10];let _;t[11]!==p||t[12]!==h?(_=(0,$.jsx)(Hn,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-code font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":p,children:[h,g]})}),t[11]=p,t[12]=h,t[13]=_):_=t[13];let v;t[14]===o?v=t[15]:(v=e=>{(e===`working`||e===`staged`||e===`turn`)&&(o?.(e),l(!1))},t[14]=o,t[15]=v);let y;t[16]===s?y=t[17]:(y=s(`diffView.scope.changed`),t[16]=s,t[17]=y);let b;t[18]===y?b=t[19]:(b=(0,$.jsx)(`span`,{children:y}),t[18]=y,t[19]=b);let x;t[20]===r?x=t[21]:(x=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:r}),t[20]=r,t[21]=x);let S;t[22]!==x||t[23]!==b?(S=(0,$.jsx)(Rn,{value:`working`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center justify-between gap-3`,children:[b,x]})}),t[22]=x,t[23]=b,t[24]=S):S=t[24];let C;t[25]===s?C=t[26]:(C=s(`diffView.scope.staged`),t[25]=s,t[26]=C);let w;t[27]===C?w=t[28]:(w=(0,$.jsx)(`span`,{children:C}),t[27]=C,t[28]=w);let T;t[29]===i?T=t[30]:(T=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:i}),t[29]=i,t[30]=T);let E;t[31]!==w||t[32]!==T?(E=(0,$.jsx)(Rn,{value:`staged`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center justify-between gap-3`,children:[w,T]})}),t[31]=w,t[32]=T,t[33]=E):E=t[33];let D;t[34]===s?D=t[35]:(D=s(`diffView.scope.lastTurn`),t[34]=s,t[35]=D);let O;t[36]===D?O=t[37]:(O=(0,$.jsx)(`span`,{children:D}),t[36]=D,t[37]=O);let k;t[38]===a?k=t[39]:(k=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:a}),t[38]=a,t[39]=k);let A;t[40]!==O||t[41]!==k?(A=(0,$.jsx)(Rn,{value:`turn`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center justify-between gap-3`,children:[O,k]})}),t[40]=O,t[41]=k,t[42]=A):A=t[42];let j;t[43]!==n||t[44]!==S||t[45]!==E||t[46]!==A||t[47]!==v?(j=(0,$.jsx)(Nn,{align:`start`,className:`w-40`,children:(0,$.jsxs)(jn,{value:n,onValueChange:v,children:[S,E,A]})}),t[43]=n,t[44]=S,t[45]=E,t[46]=A,t[47]=v,t[48]=j):j=t[48];let M;return t[49]!==c||t[50]!==j||t[51]!==_?(M=(0,$.jsxs)(Pn,{open:c,onOpenChange:l,children:[_,j]}),t[49]=c,t[50]=j,t[51]=_,t[52]=M):M=t[52],M}),Rc=Q.memo(e=>{let t=(0,qi.c)(11),{changedFiles:n,selectedFile:r,onSelectFile:i}=e,{t:a}=be();if(n.length===0)return null;let o;if(t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==a){let e;t[5]!==i||t[6]!==r||t[7]!==a?(e=e=>{let t=wc(e),n=r===e.path;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i(e.path),className:Y(`flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left transition-colors`,n?`bg-interactive-selection text-interactive-selection-foreground`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),children:[(0,$.jsx)(nn,{filePath:e.path,className:`size-3 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`typography-code font-semibold w-3.5 text-center uppercase`,style:{color:t.color},title:a(t.descriptionKey),"aria-label":a(t.descriptionKey),children:t.code}),(0,$.jsx)(dn,{path:e.path,className:`min-w-0 flex-1 typography-code`,dirClassName:n?`text-interactive-selection-foreground`:`text-muted-foreground`,nameClassName:n?`text-interactive-selection-foreground`:`text-foreground`}),Ic(e.insertions,e.deletions)]})},e.path)},t[5]=i,t[6]=r,t[7]=a,t[8]=e):e=t[8],o=n.map(e),t[0]=n,t[1]=i,t[2]=r,t[3]=a,t[4]=o}else o=t[4];let s;return t[9]===o?s=t[10]:(s=(0,$.jsx)(Yr,{outerClassName:`flex-1 min-h-0`,className:`px-2 py-2`,children:(0,$.jsx)(`ul`,{className:`flex flex-col gap-1`,children:o})}),t[9]=o,t[10]=s),s}),zc=Q.memo(e=>{let t=(0,qi.c)(20),{filePath:n,diff:r,renderSideBySide:i}=e,{t:a}=be(),o=r.original.length>0,s=r.modified.length>0,c=i?`flex flex-row gap-6 items-start justify-center`:`flex flex-col gap-4 items-center`,l=i?`flex flex-col items-center gap-2 flex-1 min-w-0`:`flex flex-col items-center gap-2`,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u={contain:`layout`},t[0]=u):u=t[0];let d;t[1]!==r.original||t[2]!==n||t[3]!==o||t[4]!==l||t[5]!==i||t[6]!==a?(d=o&&(0,$.jsxs)(`div`,{className:l,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground font-medium`,children:a(`diffView.image.original`)}),(0,$.jsx)(Mr,{src:r.original,alt:a(`diffView.image.originalAlt`,{path:n}),className:i?`max-w-full max-h-[70vh] object-contain`:`max-w-full object-contain`,style:{imageRendering:`auto`}})]}),t[1]=r.original,t[2]=n,t[3]=o,t[4]=l,t[5]=i,t[6]=a,t[7]=d):d=t[7];let f;t[8]!==r.modified||t[9]!==n||t[10]!==s||t[11]!==o||t[12]!==l||t[13]!==i||t[14]!==a?(f=s&&(0,$.jsxs)(`div`,{className:l,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground font-medium`,children:a(o?`diffView.image.modified`:`diffView.image.new`)}),(0,$.jsx)(Mr,{src:r.modified,alt:a(`diffView.image.modifiedAlt`,{path:n}),className:i?`max-w-full max-h-[70vh] object-contain`:`max-w-full object-contain`,style:{imageRendering:`auto`}})]}),t[8]=r.modified,t[9]=n,t[10]=s,t[11]=o,t[12]=l,t[13]=i,t[14]=a,t[15]=f):f=t[15];let p;return t[16]!==c||t[17]!==d||t[18]!==f?(p=(0,$.jsx)(`div`,{className:`w-full overflow-auto p-4`,style:u,children:(0,$.jsxs)(`div`,{className:c,children:[d,f]})}),t[16]=c,t[17]=d,t[18]=f,t[19]=p):p=t[19],p}),Bc=Q.memo(e=>{let t=(0,qi.c)(18),{filePath:n,diff:r,renderSideBySide:i,wrapLines:a,expandUnchanged:o,focusLine:s}=e,c=o!==void 0&&o,l;t[0]===n?l=t[1]:(l=Tr(n)||`text`,t[0]=n,t[1]=l);let u=l;if(r.isBinary){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(bc,{}),t[2]=e):e=t[2],e}if(Er(n)){let e;return t[3]!==r||t[4]!==n||t[5]!==i?(e=(0,$.jsx)(zc,{filePath:n,diff:r,renderSideBySide:i}),t[3]=r,t[4]=n,t[5]=i,t[6]=e):e=t[6],e}let d;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d={contain:`layout`},t[7]=d):d=t[7];let f=c&&!r.fileDiff?.isPartial,p;return t[8]!==r.fileDiff||t[9]!==r.modified||t[10]!==r.original||t[11]!==n||t[12]!==s||t[13]!==u||t[14]!==i||t[15]!==f||t[16]!==a?(p=(0,$.jsx)(`div`,{className:`w-full`,style:d,children:(0,$.jsx)(Ws,{original:r.original,modified:r.modified,fileDiff:r.fileDiff,language:u,fileName:n,renderSideBySide:i,wrapLines:a,expandUnchanged:f,focusLine:s,layout:`inline`,enableSelectionActions:!0})}),t[8]=r.fileDiff,t[9]=r.modified,t[10]=r.original,t[11]=n,t[12]=s,t[13]=u,t[14]=i,t[15]=f,t[16]=a,t[17]=p):p=t[17],p}),Vc=Q.memo(e=>{let t=(0,qi.c)(7),{filePath:n,staged:r,busyAction:i,disabled:a,onAction:o}=e,{t:s}=be(),c;return t[0]!==i||t[1]!==a||t[2]!==n||t[3]!==o||t[4]!==r||t[5]!==s?(c=(0,$.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-lg backdrop-blur-md`,children:r?(0,$.jsx)(Hc,{label:s(`gitView.changes.unstageFileAria`,{path:n}),icon:`arrow-go-back`,loading:i===`unstage`,disabled:a,onClick:()=>o(`unstage`)}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Hc,{label:s(`gitView.changes.revertFileAria`,{path:n}),icon:`arrow-go-back`,loading:i===`discard`,disabled:a,tone:`failure`,onClick:()=>o(`discard`)}),(0,$.jsx)(Hc,{label:s(`gitView.changes.stageFileAria`,{path:n}),icon:`add`,loading:i===`stage`,disabled:a,tone:`success`,onClick:()=>o(`stage`)})]})}),t[0]=i,t[1]=a,t[2]=n,t[3]=o,t[4]=r,t[5]=s,t[6]=c):c=t[6],c}),Hc=e=>{let t=(0,qi.c)(14),{label:n,icon:r,loading:i,disabled:a,tone:o,onClick:s}=e,c=o===`failure`&&`text-[var(--status-error)] hover:text-[var(--status-error)]`,l=o===`success`&&`text-[var(--status-success)] hover:text-[var(--status-success)]`,u;t[0]!==c||t[1]!==l?(u=Y(`h-6 w-6 rounded-none bg-transparent p-0 text-muted-foreground opacity-70 hover:bg-transparent hover:text-foreground hover:opacity-100`,c,l),t[0]=c,t[1]=l,t[2]=u):u=t[2];let d;t[3]===s?d=t[4]:(d=e=>{e.stopPropagation(),s()},t[3]=s,t[4]=d);let f;t[5]!==r||t[6]!==i?(f=i?(0,$.jsx)(Z,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,$.jsx)(Z,{name:r,className:r===`add`?`size-4`:`size-3.5`}),t[5]=r,t[6]=i,t[7]=f):f=t[7];let p;return t[8]!==a||t[9]!==n||t[10]!==u||t[11]!==d||t[12]!==f?(p=(0,$.jsx)(X,{variant:`ghost`,size:`sm`,className:u,disabled:a,title:n,"aria-label":n,onClick:d,children:f}),t[8]=a,t[9]=n,t[10]=u,t[11]=d,t[12]=f,t[13]=p):p=t[13],p},Uc=Q.memo(({directory:e,file:t,layout:n,wrapLines:r,isSelected:i,isExpanded:a,isMounted:o,onSelect:s,onExpandedChange:c,registerSectionRef:l,showOpenInEditorAction:u=!1,isOpeningInEditor:d=!1,onOpenInEditor:f,onOpenFile:p,staged:m=!1,loadFullFiles:h=!1,preloadFullFiles:g=!1,initialDiffData:_=null,focusLine:v=null,showFileActions:y=!0,disableGitFetch:b=!1,turnChangesRequest:x=null,loadTurnChangeFile:S=!1})=>{let{t:C}=be(),{git:w}=ne(),T=En(Q.useCallback(n=>n.directories.get(e)?.diffCache.get(t.path)??null,[e,t.path])),E=En(e=>e.setDiff),D=En(e=>e.fetchStatus),[O,k]=Q.useState(0),[A,j]=Q.useState(null),[M,N]=Q.useState(!1),[ee,P]=Q.useState(null),[F,I]=Q.useState(!1),[L,R]=Q.useState(null),[z,te]=Q.useState(null),B=Q.useRef(null),V=Q.useMemo(()=>wc(t),[t]),H=n===`side-by-side`,re=g||h,U=re?`full`:`patch`,W=`${t.index}:${t.working_dir}:${t.insertions}:${t.deletions}`,ie=fc({sessionID:x?.sessionID??``,directory:x?.directory??``,messageID:x?.messageID??``,diffCount:x?.diffCount,file:t.path},{enabled:S&&!!x&&a&&o}),ae=Q.useMemo(()=>{let e=ie.data?.diff;return e?typeof e.patch==`string`&&e.patch.length>0?Fc(t.path,e.patch,`patch`):typeof e.before==`string`&&e.before.length>0||typeof e.after==`string`&&e.after.length>0?{original:e.before??``,modified:e.after??``,contextMode:`full`}:null:null},[t.path,ie.data]),oe=Q.useMemo(()=>{if(_)return _;if(ae)return ae;if(m)return z;if(L)return L;if(!T)return null;let e={original:T.original,modified:T.modified,isBinary:T.isBinary,contextMode:`full`};return Pc(e)?e:null},[T,_,L,m,z,ae]),G=ie.error instanceof Error?ie.error.message:ie.error?String(ie.error):null,K=oe?null:G??A,se=S&&ie.isPending||M,ce=Q.useCallback(e=>{B.current=e,l(t.path,e)},[t.path,l]),q=Q.useCallback(e=>{c(t.path,e)},[t.path,c]),le=Q.useCallback(()=>{s(t.path)},[t.path,s]);Q.useEffect(()=>{if(!a||!o||b||!e||_){N(!1);return}j(null),N(!0);let n=!1,r=re?_c:vc,i=Er(t.path)||re?w.getGitFileDiff(e,{path:t.path,staged:m}):w.getGitDiff(e,{path:t.path,staged:m,contextLines:r}),s=mc,c,l=new Promise((e,t)=>{c=setTimeout(()=>t(Error(`Timed out after ${s}ms`)),s)});return Promise.race([i,l]).then(r=>{if(!n){if(`diff`in r){let e=Fc(t.path,r.diff,U);m?te(e):R(e)}else{let n={original:r.original??``,modified:r.modified??``,isBinary:r.isBinary,contextMode:`full`};m?te(n):(R(n),E(e,t.path,n))}N(!1)}}).catch(e=>{if(n)return;let t=e instanceof Error?e.message:String(e);j(t),N(!1)}).finally(()=>clearTimeout(c)),()=>{n=!0,clearTimeout(c)}},[U,O,e,b,t.path,W,w,_,a,o,re,E,m]);let ue=Q.useCallback(()=>{q(!a),le()},[q,le,a]),de=Q.useCallback(async n=>{if(!(!e||ee!==null)){P(n);try{n===`stage`?await w.stageGitFile(e,t.path):n===`unstage`?await w.unstageGitFile(e,t.path):await w.revertGitFile(e,t.path,{scope:`working`}),k(e=>e+1),await D(e,w)}catch(e){let t=n===`unstage`?`gitView.toast.unstageFileFailed`:n===`stage`?`gitView.toast.stageFileFailed`:`gitView.toast.revertFailed`;yt.error(e instanceof Error?e.message:C(t))}finally{P(e=>e===n?null:e)}}},[e,D,t.path,ee,w,C]);return(0,$.jsxs)(`div`,{ref:ce,"aria-busy":se,className:`scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0`,children:[(0,$.jsx)(`div`,{className:`sticky top-0 z-30 border-b border-[var(--interactive-border)]/35 bg-background/95 backdrop-blur-md supports-[backdrop-filter]:bg-background/90`,"data-diff-file-header":!0,children:(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:ue,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),ue())},className:Y(`cursor-pointer`,`group/header relative grid min-h-8 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-1.5 overflow-hidden px-2 py-1`,`bg-transparent`,`text-muted-foreground hover:text-foreground`,i?`bg-[var(--interactive-selection)]/35`:null),children:[(0,$.jsx)(`div`,{className:`absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50`}),(0,$.jsxs)(`div`,{className:`relative flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`flex size-4 items-center justify-center opacity-70 group-hover/header:opacity-100`,children:a?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`size-3.5`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`size-3.5`})}),(0,$.jsx)(`span`,{className:`typography-code font-semibold leading-none w-3.5 text-center uppercase`,style:{color:V.color},title:C(V.descriptionKey),"aria-label":C(V.descriptionKey),children:V.code}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 overflow-hidden typography-code`,title:t.path,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(nn,{filePath:t.path,className:`size-3 flex-shrink-0 align-middle`}),(0,$.jsx)(dn,{path:t.path,className:`min-w-0 flex-1 typography-code`})]})})]}),(0,$.jsxs)(`div`,{className:`relative flex shrink-0 items-center justify-self-end gap-1.5`,children:[se&&oe?(0,$.jsx)(`span`,{role:`status`,"aria-label":C(`diffView.state.loadingDiff`),children:(0,$.jsx)(Z,{name:`loader-4`,className:`size-3.5 animate-spin`})}):null,Ic(t.insertions,t.deletions),u&&f?(0,$.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-5 w-5 p-0 opacity-70 hover:opacity-100`,title:C(`diffView.actions.openFileInEditorAtChange`),onClick:e=>{e.stopPropagation(),f(t.path,oe)},disabled:d,children:d?(0,$.jsx)(Z,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,$.jsx)(Z,{name:`edit`,className:`size-3.5`})}):null,p?(0,$.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-5 w-5 p-0 opacity-70 hover:opacity-100`,title:C(`diffView.actions.openFilePreview`),"aria-label":C(`diffView.actions.openFilePreview`),onClick:e=>{e.stopPropagation(),p(t.path)},children:(0,$.jsx)(Z,{name:`eye`,className:`size-3.5`})}):null]})]})}),a&&(0,$.jsxs)(`div`,{className:`relative bg-background overflow-hidden`,children:[oe&&A?(0,$.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 px-3 py-2 typography-meta text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[C(`diffView.state.failedToLoadDiff`),`: `,A]}),(0,$.jsx)(X,{variant:`ghost`,size:`xs`,onClick:()=>k(e=>e+1),children:C(`diffView.actions.retry`)})]}):null,!o&&!K?(0,$.jsx)(`div`,{className:`h-40 border border-border/40 bg-background/40`}):null,K?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-semibold text-foreground`,children:C(`diffView.state.failedToLoadDiff`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground max-w-[32rem] text-center`,children:K}),(0,$.jsx)(`button`,{type:`button`,className:`typography-ui-label text-primary hover:underline`,onClick:()=>{if(S){ie.refetch();return}k(e=>e+1)},children:C(`diffView.actions.retry`)})]}):null,o&&se&&!oe&&!K?(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground`,children:[(0,$.jsx)(Z,{name:`loader-4`,className:`size-4 animate-spin`}),C(`diffView.state.loadingDiff`)]}):null,o&&oe&&!F&&t.insertions+t.deletions>hc?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-semibold text-foreground`,children:C(`diffView.state.largeDiff`,{count:t.insertions+t.deletions})}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:C(`diffView.state.largeDiffDescription`)}),(0,$.jsx)(`button`,{type:`button`,className:`typography-ui-label text-primary hover:underline`,onClick:()=>I(!0),children:C(`diffView.actions.renderAnyway`)})]}):null,o&&oe&&(F||t.insertions+t.deletions<=hc)?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Bc,{filePath:t.path,diff:oe,renderSideBySide:H,wrapLines:r,expandUnchanged:h&&oe.contextMode===`full`,focusLine:v}),y?(0,$.jsx)(`div`,{className:`pointer-events-none absolute bottom-3 right-3 z-20`,children:(0,$.jsx)(`div`,{className:`pointer-events-auto`,children:(0,$.jsx)(Vc,{filePath:t.path,staged:m,busyAction:ee,disabled:ee!==null,onAction:de})})}):null]}):null]})]})}),Wc=({hideStackedFileSidebar:e=!1,stackedDefaultCollapsedAll:t=!1,pinSelectedFileHeaderToTopOnNavigate:n=!1,showOpenInEditorAction:r=!1,diffScope:i=`all`,turnMessageId:a=null,sessionId:o=null,directory:s=null,onDiffScopeChange:c,targetFilePath:l=null,targetLine:u=null,toolPatches:d=null,flushContent:f=!1,singleFileView:p=!1,toolbarInSheetHeader:m=!1,preloadFullFiles:h=!1,navigationRequestKey:g})=>{let{t:_}=be(),{git:v}=ne(),y=jr(),b=typeof s==`string`&&s.trim()?s.trim():y,{screenWidth:x,isMobile:S}=Yn(),C=yn(b??null),w=Cn(b??null),T=bn(b??null),E=En(e=>e.setActiveDirectory),D=En(e=>e.ensureStatus),O=En(e=>e.fetchStatus),k=En(e=>e.setDiff),[A,M]=Q.useState(null),[N,ee]=Q.useState(!1),[P,F]=Q.useState(null),[I,L]=Q.useState(null),[R,z]=Q.useState(()=>new Set),[te,B]=Q.useState(()=>new Set),[V,H]=Q.useState(!1),[re,U]=Q.useState(0),[W,ie]=Q.useState(i);Q.useEffect(()=>{ie(i)},[i]);let ae=j(e=>e.pendingDiffFile),oe=j(e=>e.pendingDiffStaged),G=j(e=>e.pendingDiffScope),K=j(e=>e.pendingDiffLine),se=j(e=>e.setPendingDiffFile),ce=j(e=>e.diffLayoutPreference),q=j(e=>e.diffFileLayout),le=j(e=>e.setDiffFileLayout),ue=j(e=>e.diffWrapLines),de=j(e=>e.setDiffWrapLines),fe=j(e=>e.openContextFileAtLine),pe=j(e=>e.openContextFile),me=mr(),he=bt(e=>e.currentSessionId),ge=typeof o==`string`&&o.trim()?o.trim():he,_e=mt(ge??``,b??void 0),ve=ue,ye=W===`staged`||W!==`working`&&null,xe=ye??N,Se=!e&&!(S||x<=768)&&x>=1024,Ce=Q.useRef(null),we=Q.useRef(new Map),Te=Q.useRef(null),Ee=Q.useRef(null),De=Q.useRef(!1),Oe=Q.useRef(null),ke=Q.useRef(null),Ae=Q.useRef(null),je=Q.useRef(null),Me=Q.useCallback(()=>{Te.current=null,De.current=!1,L(null),Ee.current!==null&&(window.cancelAnimationFrame(Ee.current),Ee.current=null)},[]),Ne=Q.useCallback(e=>{z(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),Pe=Q.useMemo(()=>{let e=_e.length-1;if(a&&(e=_e.findIndex(e=>e.id===a),e<0))return{messageID:null,count:0,hasDiffs:!1,thinDiffs:[]};for(let t=e;t>=0;--t){let e=_e[t];if(e.role!==`user`)continue;let n=Mc(e.summary?.diffs),r=typeof e.summary?.diffCount==`number`&&Number.isFinite(e.summary.diffCount)?Math.max(0,Math.trunc(e.summary.diffCount)):n.length;return{messageID:typeof e.id==`string`&&e.id?e.id:null,count:r,hasDiffs:e.summary?.hasDiffs===!0||r>0||n.length>0,thinDiffs:n}}return{messageID:null,count:0,hasDiffs:!1,thinDiffs:[]}},[_e,a]),Fe=Q.useMemo(()=>ec(d??[]),[d]),Ie=Fe.length>0,Le=Q.useMemo(()=>!ge||!b||!Pe.messageID?null:{sessionID:ge,directory:b,messageID:Pe.messageID,diffCount:Pe.count},[b,ge,Pe.count,Pe.messageID]),Re=Q.useMemo(()=>Ie?Fe:Pe.thinDiffs,[Fe,Pe.thinDiffs,Ie]),ze=Q.useMemo(()=>{let e=new Map;for(let t of Re)if(t.file){if(typeof t.patch==`string`&&t.patch.length>0){e.set(t.file,Fc(t.file,t.patch,`patch`));continue}(typeof t.before==`string`&&t.before.length>0||typeof t.after==`string`&&t.after.length>0)&&e.set(t.file,{original:t.before??``,modified:t.after??``,contextMode:`full`})}return e},[Re]),Be=Q.useMemo(()=>{if(W===`turn`)return Re.map(e=>({path:e.file??``,index:``,working_dir:Nc(e.status),insertions:e.additions??0,deletions:e.deletions??0,isNew:e.status===`added`})).filter(e=>e.path).sort((e,t)=>e.path.localeCompare(t.path));if(!w?.files)return[];let e=w.diffStats??{},t=W===`staged`?Ec:W===`working`?Dc:()=>!0;return w.files.filter(t).map(t=>({...t,insertions:e[t.path]?.insertions??0,deletions:e[t.path]?.deletions??0,isNew:Tc(t)})).sort((e,t)=>e.path.localeCompare(t.path))},[W,Re,w]),Ve=Q.useMemo(()=>w?.files?w.files.filter(Dc).length:0,[w]),He=Q.useMemo(()=>w?.files?w.files.filter(Ec).length:0,[w]),Ue=Ie?Re.length:Pe.count,We=Q.useMemo(()=>Be.map(e=>e.path).join(`\0`),[Be]),Ge=Q.useMemo(()=>{if(!p)return Be;let e=l?.trim()||A;return e?Be.filter(t=>t.path===e):[]},[Be,A,p,l]);Q.useEffect(()=>{let e=We?We.split(`\0`):[],n=new Set(e),r=`${b??``}:${W}:${a??``}:${t?`collapsed`:`default`}`,i=d!==null&&Ae.current!==d,o=ke.current!==r||i;ke.current=r,Ae.current=d,z(r=>{if(o){let n=t||W===`turn`&&!Ie?0:yc(e.length);return new Set(e.slice(0,n))}let i=!1,a=new Set;for(let e of r){if(!n.has(e)){i=!0;continue}a.add(e)}return i?a:r}),B(e=>{if(o)return new Set;let t=!1,r=new Set;for(let i of e){if(!n.has(i)){t=!0;continue}r.add(i)}return t?r:e})},[W,We,b,t,d,a,Ie]);let Ke=Q.useCallback(()=>{Oe.current=null;let e=Ce.current;if(!e)return;let t=e.getBoundingClientRect(),n=t.top-gc,r=t.bottom+gc,i={};for(let[e,t]of we.current){if(!t||!R.has(e))continue;let a=t.getBoundingClientRect();a.bottom<n||a.top>r||(i[e]=!0)}B(e=>{let t=!1,n=new Set(e);for(let e of Object.keys(i))n.has(e)||(n.add(e),t=!0);return t?n:e})},[R]),qe=Q.useCallback(()=>{typeof window>`u`||Oe.current===null&&(Oe.current=window.requestAnimationFrame(Ke))},[Ke]);Q.useEffect(()=>{let e=Ce.current;if(e)return qe(),e.addEventListener(`scroll`,qe,{passive:!0}),window.addEventListener(`resize`,qe),()=>{e.removeEventListener(`scroll`,qe),window.removeEventListener(`resize`,qe),Oe.current!==null&&(window.cancelAnimationFrame(Oe.current),Oe.current=null)}},[Be,R,qe]);let Je=Q.useCallback(e=>{let t=q[e.path];if(t)return t;if(ce===`inline`)return`inline`;if(ce===`side-by-side`)return`side-by-side`;let n=x<pc;return e.isNew||n?`inline`:`side-by-side`},[q,ce,x]),Ye=Q.useMemo(()=>Ge.length===0?null:Ge.every(e=>Je(e)===`side-by-side`)?`side-by-side`:`inline`,[Je,Ge]);Q.useEffect(()=>{b&&(E(b),D(b,v))},[b,E,D,v]),Q.useEffect(()=>{if(b)return Et.onGitRefreshHint(e=>{kc(e.directory)===kc(b)&&O(b,v)})},[b,O,v]),Q.useEffect(()=>{W!==`all`&&!G||ae&&(G&&ie(G),M(ae),ee(G===`staged`||!G&&oe),F(K),se(null),De.current=!0,Te.current=ae,Ne(ae),U(e=>e+1))},[W,Ne,ae,K,G,oe,se]),Q.useEffect(()=>{if(W===`all`)return;let e=l?.trim();if(!e)return;Ne(e),M(e),ee(W===`staged`),F(u);let t=tc({scope:W,navigationRequestKey:g,targetFilePath:e,targetLine:u}),n=Be.some(t=>t.path===e);nc(je.current,t,n)&&(je.current=t,De.current=!0,Te.current=e,U(e=>e+1))},[W,Be,Ne,g,l,u]),Q.useEffect(()=>{A&&(Be.some(e=>e.path===A)||(M(null),ee(!1)))},[Be,A]);let Xe=Q.useCallback((e,t)=>{let n=we.current;t?n.set(e,t):n.delete(e),qe()},[qe]),Ze=Q.useCallback((e,t)=>{Me(),z(n=>{if(t===n.has(e))return n;let r=new Set(n);return t?r.add(e):r.delete(e),r}),t||B(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),qe()},[Me,qe]),Qe=Q.useCallback(()=>{Me(),z(e=>e.size>0?new Set:new Set(Be.map(e=>e.path))),B(new Set),qe()},[Me,Be,qe]),$e=Q.useCallback(e=>{let t=we.current.get(e),n=Ce.current;if(!t||!n)return!1;let r=n.getBoundingClientRect(),i=t.getBoundingClientRect().top-r.top,a=Math.max(0,n.scrollHeight-n.clientHeight);return n.scrollTop=Math.min(a,Math.max(0,n.scrollTop+i)),!0},[]);Q.useEffect(()=>{if(!Te.current)return;let e=0,t=!1,r=()=>{t||(t=!0,Te.current=null,De.current=!1,L(null),Ee.current!==null&&(window.cancelAnimationFrame(Ee.current),Ee.current=null))},i=()=>{if(t){Ee.current=null;return}let a=Te.current;if(!a){r(),Ee.current=null;return}if(!$e(a)){e+=1,e<20?Ee.current=window.requestAnimationFrame(i):(r(),Ee.current=null);return}n&&De.current&&L(a),r()};return Ee.current=window.requestAnimationFrame(i),()=>{t=!0,Ee.current!==null&&(window.cancelAnimationFrame(Ee.current),Ee.current=null)}},[n,re,$e]);let et=Q.useCallback(e=>{},[]),tt=Q.useCallback(e=>{Me(),M(e),ee(!1),De.current=!0,Te.current=e,Ne(e),U(e=>e+1),$e(e)},[Me,Ne,$e]),nt=Q.useCallback(e=>{let t=e===`side-by-side`?`side-by-side`:`inline`;Ge.forEach(e=>{le(e.path,t)})},[le,Ge]),[rt,it]=Q.useState(null),at=Q.useCallback(async(e,t)=>{if(!(!b||!e)){it(e);try{let n=null;if(t?.patch&&!t.isBinary&&!Er(e)?n=$s(t.patch):t&&t.contextMode===`full`&&!t.isBinary&&!Er(e)&&(n=Ac(t.original,t.modified)),n===null)try{n=$s((await v.getGitDiff(b,{path:e,staged:xe,contextLines:3})).diff)}catch{n=null}let r=t;if(n===null||!r){let t=await v.getGitFileDiff(b,{path:e,staged:xe});r={original:t.original??``,modified:t.modified??``,isBinary:t.isBinary},xe||k(b,e,r)}let i=n??(r.isBinary||Er(e)?1:Ac(r.original,r.modified)),a=Oc(b,e);fe(b,a,i,1)}finally{it(t=>t===e?null:t)}}},[xe,b,v,fe,k]),ot=J(e=>{if(!b||!e)return;let t=Oc(b,e);if(me){me.openFile({path:t});return}pe(b,t)}),st=()=>{if(!b)return null;let e=e=>ye===null?N&&e===A:ye;return(0,$.jsxs)(`div`,{className:Y(`flex min-w-0 flex-1 min-h-0 h-full`,f?`gap-0`:`gap-3 px-3 pb-3 pt-2`),children:[Se&&(0,$.jsxs)(`section`,{className:`hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-b border-border/40`,children:[(0,$.jsx)(`span`,{className:`typography-code font-semibold text-foreground`,children:_(`diffView.section.files`)}),(0,$.jsx)(`span`,{className:`typography-code text-muted-foreground`,children:Be.length})]}),(0,$.jsx)(Rc,{changedFiles:Be,selectedFile:null,onSelectFile:tt})]}),(0,$.jsx)(`div`,{className:`relative flex-1 min-w-0 min-h-0 h-full`,children:(0,$.jsx)(Yr,{ref:Ce,outerClassName:`min-h-0 h-full`,className:`[overflow-anchor:none] pb-16 pwa-overlay-scroll`,disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:(0,$.jsx)(`div`,{className:`flex flex-col [overflow-anchor:none]`,"data-diff-virtual-content":!0,children:Ge.map(t=>(0,$.jsx)(Uc,{directory:b,file:t,layout:Je(t),wrapLines:ve,isSelected:!1,isExpanded:R.has(t.path),isMounted:te.has(t.path)||t.path===I||p&&Ge.length===1,onSelect:et,onExpandedChange:Ze,registerSectionRef:Xe,showOpenInEditorAction:r&&W!==`turn`,isOpeningInEditor:rt===t.path,onOpenInEditor:(e,t)=>{at(e,t)},onOpenFile:ot,staged:e(t.path),loadFullFiles:V,preloadFullFiles:h,initialDiffData:W===`turn`?ze.get(t.path)??null:null,focusLine:t.path===(l?.trim()||A)?u??P:null,showFileActions:W!==`turn`,disableGitFetch:W===`turn`,turnChangesRequest:Le,loadTurnChangeFile:W===`turn`&&!Ie},t.path))})})})]})},ct=()=>b?W!==`turn`&&T&&!w?(0,$.jsxs)(`div`,{className:`flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(Z,{name:`loader-4`,className:`size-4 animate-spin`}),_(`diffView.state.loadingRepositoryStatus`)]}):W!==`turn`&&C===!1?(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:_(`diffView.state.notGitRepository`)}):Ge.length===0?(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:_(W===`turn`?`diffView.state.noLastTurnChanges`:`diffView.state.cleanWorkingTree`)}):st():(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:_(`diffView.state.selectSessionDirectory`)}),lt=p?null:(0,$.jsxs)($.Fragment,{children:[!S&&!m&&(W===`working`||W===`staged`||W===`turn`?(0,$.jsx)(Lc,{scope:W,workingCount:Ve,stagedCount:He,turnCount:Ue,onScopeChange:e=>{ie(e),c?.(e)}}):(0,$.jsx)(`div`,{className:`flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0`,children:(0,$.jsx)(`span`,{className:`typography-code font-semibold text-foreground`,children:T&&!w?_(`diffView.state.loadingChanges`):Ge.length===1?_(`diffView.summary.changedFilesSingle`,{count:Ge.length}):_(`diffView.summary.changedFilesPlural`,{count:Ge.length})})})),!p&&Be.length>0&&(W!==`turn`||Ie)&&(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:Qe,className:Y(`diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground`,`ml-auto`),title:R.size>0?_(`diffView.actions.collapseAll`):_(`diffView.actions.expandAll`),children:[(0,$.jsx)(Z,{name:`expand-up-down`,className:`size-4`}),(0,$.jsx)(`span`,{className:Y(`diff-toolbar__expand-label typography-code`,m&&`hidden`),children:R.size>0?_(`diffView.actions.collapseAll`):_(`diffView.actions.expandAll`)})]}),Be.length>0&&W!==`turn`&&(0,$.jsxs)(An,{children:[(0,$.jsx)(On,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`sm`,onClick:()=>H(e=>!e),"aria-pressed":V,"aria-label":_(V?`diffView.actions.disableFullFiles`:`diffView.actions.loadFullFiles`),className:Y(`h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground`,V&&`bg-interactive-selection text-interactive-selection-foreground`),children:(0,$.jsx)(Z,{name:`file-download`,className:`size-4`})})}),(0,$.jsx)(kn,{children:(0,$.jsx)(`p`,{children:_(V?`diffView.actions.disableFullFiles`:`diffView.actions.loadFullFiles`)})})]}),Be.length>0&&(0,$.jsx)(X,{variant:`ghost`,size:`sm`,onClick:()=>de(!ue),className:Y(`h-5 w-5 p-0 transition-opacity`,ve?`text-foreground opacity-100`:`text-muted-foreground opacity-60 hover:opacity-100`),title:_(ve?`diffView.actions.disableLineWrap`:`diffView.actions.enableLineWrap`),children:(0,$.jsx)(Z,{name:`text-wrap`,className:`size-4`})}),Ye&&(0,$.jsx)(di,{mode:Ye===`side-by-side`?`side-by-side`:`unified`,onModeChange:nt})]});return(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background`,children:[lt?m?(0,$.jsx)(cr,{children:lt}):(0,$.jsx)(`div`,{className:`@container/diff-toolbar flex min-w-0 items-center gap-1.5 px-2 py-1.5 bg-background`,children:lt}):null,ct()]})};function Gc(e,t){if(!t||e.has(t))return e;let n=new Set(e);return n.add(t),n}function Kc(e){return Fe(e?.enabled??!0)}function qc(e){let t=(0,qi.c)(3),n=e?.includeCurrentSession??!0,r=Kc(e),i=bt(Jc),a;bb0:{if(!n){a=r;break bb0}let e;t[0]!==i||t[1]!==r?(e=Gc(r,i),t[0]=i,t[1]=r,t[2]=e):e=t[2],a=e}return a}function Jc(e){return e.currentSessionId}var Yc=e=>Object.fromEntries(e.map(e=>[e.id,ze(e)])),Xc=(e,t,n,r)=>{if(!t||t.length===0||!r)return[];let i=new Set(e),a=new Set(t),o=[...t.filter(e=>i.has(e)),...e.filter(e=>!a.has(e))];if(o.length===0)return[];if(Qe(n,r))return o;let s=e=>{let t=r[e];return t===void 0?!a.has(e):(n[e]??0)>t},c=[],l=[];if(o.forEach(e=>{s(e)?c.push(e):l.push(e)}),c.length===0)return o;let u=new Map(o.map((e,t)=>[e,t]));return c.sort((e,t)=>{let r=(n[t]??0)-(n[e]??0);return r===0?(u.get(e)??0)-(u.get(t)??0):r}),[...c,...l]},Zc=(e,t,n)=>{let r=Yc(e.map(e=>e.session)),i=Xc(e.map(e=>e.session.id),t,r,n);return new Map(i.map((e,t)=>[e,t]))},Qc=(e,t,n,r)=>{let i=Zc(e,t,n);return(e,t)=>{let n=i.get(e.session.id),a=i.get(t.session.id);if(n!==void 0||a!==void 0){if(n===void 0)return 1;if(a===void 0)return-1;if(n!==a)return n-a}return Wn(e.session,t.session,r)}},$c=({folders:e,visibleUngroupedNodes:t,collapsedFolderIds:n,hasSessionSearchQuery:r})=>{let i=new Map(e.map(e=>[e.folder.id,e])),a=new Map;e.forEach(({folder:e})=>{let t=e.parentId??null,n=a.get(t)??[];n.push(e.id),a.set(t,n)});let o=[],s=new Map,c=e=>{let t=i.get(e);t&&(!r&&n.has(e)||((a.get(e)??[]).forEach(c),t.nodes.forEach(t=>{o.push(t.session.id),s.set(t.session.id,e)})))};return(a.get(null)??[]).forEach(c),t.forEach(e=>{o.push(e.session.id),s.set(e.session.id,null)}),{sessionIds:o,folderIdBySessionId:s}},el=(e,t,n)=>n.get(e)===n.get(t),tl=e=>!!e.parentID,nl=(e,t)=>W(ot(e.session))??W(t.directory??null),rl=()=>3,il=(e,t,n,r)=>{let i=Math.min(e.length,Math.max(0,t)),a=e.slice(0,i);for(let t=i;t<e.length;t+=1){let i=e[t];i&&n.has(r(i))&&a.push(i)}return a},al=(e,t,n)=>il(e,t,n,e=>e.session.id),ol=(e,t,n)=>il(e,t,n,e=>e.id),sl=({targets:e,collapsedProjectIds:t,collapsedGroupKeys:n,collapsedFolderIds:r,visibleSessionCountByGroup:i,defaultVisibleSessionCount:a,hasSessionSearchQuery:o,alwaysVisibleSessionIds:s})=>e.filter(e=>{if(!e.projectId||t.has(e.projectId))return!1;if(o)return!0;if(e.groupKey&&n.has(e.groupKey)||e.folderAncestorIds?.some(e=>r.has(e)))return!1;if(e.groupKey&&e.visibleIndex!==void 0){let t=Math.max(a,i.get(e.groupKey)??a);if(e.visibleIndex>=t&&!s?.has(e.sessionId))return!1}return!0}),cl=(e,t,n)=>{if(!t||n==null||!Number.isInteger(n)||n<0)return null;if(e[n]?.session.id===t)return n;let r=e.findIndex(e=>e.session.id===t);return r>=0?r:null},ll=({sections:e,foldersMap:t,getOrderedGroups:n,pinnedSessionIds:r,sessionOrderByScope:i,sessionOrderActivityByScope:a})=>{let o=[];return e.forEach(e=>{let s=n(e.project.id,e.groups),c=s.find(e=>e.isMain)??null;(c?[c,...s.filter(e=>e.id!==c.id)]:s).forEach(n=>{if(n.isArchivedBucket)return;let s=`${e.project.id}:${n.id}`,c=n.folderScopeKey??W(n.directory??null),l=Qc(n.sessions,c?i[c]:void 0,c?a[c]:void 0,r),u=[...n.sessions].filter(e=>!e.session.time?.archived&&!tl(e.session)).sort(l),d=new Map(u.map(e=>[e.session.id,e])),f=c?t[c]??[]:[],p=new Map;f.forEach(e=>{let t=e.parentId??null,n=p.get(t)??[];n.push(e),p.set(t,n)});let m=new Set(f.flatMap(e=>e.sessionIds)),h=(t,r,i)=>{o.push({scope:`project`,sessionId:t.session.id,projectId:e.project.id,directory:nl(t,n),groupKey:s,folderAncestorIds:r,visibleIndex:i})},g=(e,t)=>{let n=f.find(t=>t.id===e);if(!n)return;let r=[...t,n.id];(p.get(n.id)??[]).forEach(e=>{g(e.id,r)}),n.sessionIds.map(e=>d.get(e)).filter(e=>!!e).sort(l).forEach(e=>h(e,r))};(p.get(null)??[]).forEach(e=>g(e.id,[])),u.filter(e=>!m.has(e.session.id)).forEach((e,t)=>h(e,void 0,t))})}),o},ul=b()(x(e=>({expandedWorktreeGroups:{},setWorktreeGroupExpanded:(t,n)=>e(e=>({expandedWorktreeGroups:{...e.expandedWorktreeGroups,[t]:n}}))}),{name:`mobile-session-statusbar-collapse`,storage:N()}));typeof window<`u`&&t(e=>{o(e)&&ul.persist.rehydrate()});var dl=e=>{let t=(0,qi.c)(24),{size:n,className:r}=e,i=n===void 0?14:n,a=(i-1.5)/2,o=2*Math.PI*a,s=o*.28,c;t[0]===r?c=t[1]:(c=Y(`inline-flex items-center justify-center shrink-0`,r),t[0]=r,t[1]=c);let l;t[2]===i?l=t[3]:(l={width:i,height:i},t[2]=i,t[3]=l);let u=`0 0 ${i} ${i}`,d;t[4]===i?d=t[5]:(d={width:i,height:i},t[4]=i,t[5]=d);let f=i/2,p=i/2,m;t[6]!==a||t[7]!==f||t[8]!==p?(m=(0,$.jsx)(`circle`,{cx:f,cy:p,r:a,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:1.5}),t[6]=a,t[7]=f,t[8]=p,t[9]=m):m=t[9];let h=i/2,g=i/2,_=`${s} ${o-s}`,v;t[10]!==a||t[11]!==g||t[12]!==_||t[13]!==h?(v=(0,$.jsx)(`circle`,{cx:h,cy:g,r:a,fill:`none`,stroke:`var(--surface-muted-foreground)`,strokeWidth:1.5,strokeLinecap:`round`,strokeDasharray:_}),t[10]=a,t[11]=g,t[12]=_,t[13]=h,t[14]=v):v=t[14];let y;t[15]!==v||t[16]!==u||t[17]!==d||t[18]!==m?(y=(0,$.jsxs)(`svg`,{viewBox:u,className:`animate-spin yuri-busy-ring`,style:d,"aria-hidden":`true`,children:[m,v]}),t[15]=v,t[16]=u,t[17]=d,t[18]=m,t[19]=y):y=t[19];let b;return t[20]!==y||t[21]!==c||t[22]!==l?(b=(0,$.jsx)(`span`,{className:c,style:l,"aria-hidden":`true`,children:y}),t[20]=y,t[21]=c,t[22]=l,t[23]=b):b=t[23],b};dl.displayName=`SessionBusyIndicator`;function fl({durationMs:e,size:t=15,className:n}){let r=1.5,i=(t-r)/2,a=2*Math.PI*i,[o,s]=Q.useState(!1),[c,l]=Q.useState(()=>Math.max(0,Math.ceil(e/1e3)-1));return Q.useEffect(()=>{let t=performance.now(),n=window.requestAnimationFrame(()=>s(!0)),r=window.setInterval(()=>{let n=performance.now()-t;l(Math.max(0,Math.ceil((e-n)/1e3)-1))},250);return()=>{window.cancelAnimationFrame(n),window.clearInterval(r)}},[e]),(0,$.jsxs)(`span`,{className:Y(`yuri-undo-countdown`,n),style:{"--yuri-undo-countdown-size":`${t}px`},"aria-hidden":`true`,children:[(0,$.jsxs)(`svg`,{viewBox:`0 0 ${t} ${t}`,width:t,height:t,className:`yuri-undo-countdown-svg`,children:[(0,$.jsx)(`circle`,{cx:t/2,cy:t/2,r:i,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:r}),(0,$.jsx)(`circle`,{cx:t/2,cy:t/2,r:i,fill:`none`,stroke:`var(--primary-base)`,strokeWidth:r,strokeLinecap:`round`,strokeDasharray:a,strokeDashoffset:o?a:0,style:{transition:`stroke-dashoffset ${e}ms linear`}})]}),(0,$.jsx)(`span`,{className:`yuri-undo-countdown-digit text-current`,children:c})]})}function pl(){j.getState().setArchivedSessionsDialogOpen(!0)}function ml(e){yt.custom(t=>Q.createElement(`div`,{className:`flex w-full min-w-0 max-w-full items-center gap-2.5 text-foreground`},Q.createElement(`span`,{className:`min-w-0 flex-1 truncate text-left typography-ui-label font-medium`},e.message),Q.createElement(`div`,{className:`flex shrink-0 items-center gap-1.5`},e.secondaryLabel&&e.onSecondary?Q.createElement(X,{variant:`ghost`,size:`sm`,className:`session-mutation-undo-action overflow-hidden !h-[26px] !min-h-0 !min-w-0 shrink-0 !px-2 !text-[12px]`,onClick:()=>{e.onSecondary?.(),yt.dismiss(t)}},e.secondaryLabel):null,Q.createElement(X,{variant:`ghost`,size:`sm`,className:`session-mutation-undo-action overflow-hidden !h-[26px] !min-h-0 !min-w-0 shrink-0 gap-1 !pl-2 !pr-1 !text-[12px]`,onClick:()=>{e.onPrimary(),yt.dismiss(t)}},e.primaryLabel,Q.createElement(fl,{durationMs:e.durationMs})))),{duration:e.durationMs,className:`session-mutation-undo-toast !max-w-[calc(100vw-2rem)]`})}function hl(e){let t=Array.from(new Set(e.sessionIds.filter(Boolean)));t.length!==0&&ml({durationMs:Ue,message:e.message,primaryLabel:e.undoLabel,onPrimary:()=>{(async()=>{(await Promise.all(t.map(e=>Tt(e)))).some(e=>!e)&&yt.error(e.undoFailedMessage)})()},secondaryLabel:e.settingsLabel,onSecondary:()=>{pl()}})}function gl(e){let t=Array.from(new Set(e.sessionIds.filter(Boolean)));if(t.length===0)return{batchId:``,scheduledIds:[]};let n=e.delayMs??1e4,{batchId:r,scheduledIds:i}=Pe(t,{delayMs:n,onSettled:({failedIds:t})=>{t.length>0&&yt.error(e.commitFailedMessage)}});return r&&ml({durationMs:n,message:e.message,primaryLabel:e.undoLabel,onPrimary:()=>{Le(r)}}),{batchId:r,scheduledIds:i}}var _l=500,vl=12,yl=(e={})=>{let t=e.delayMs??_l,n=(e.moveThresholdPx??vl)**2,r=e.schedule??((e,t)=>setTimeout(e,t)),i=e.clear??(e=>clearTimeout(e)),a=null,o=null,s=(t=!1)=>{a&&(i(a.timer),a=null,t||e.onPressedKeyChange?.(null))};return{start:({pointerId:n,key:i,clientX:c,clientY:l,onTrigger:u})=>{s(),e.onPressedKeyChange?.(i),a={pointerId:n,key:i,startX:c,startY:l,timer:r(()=>{!a||a.pointerId!==n||a.key!==i||(a.triggered=!0,o=i,u())},t),triggered:!1}},move:(e,t,r)=>{if(a?.pointerId!==e||a.triggered)return;let i=t-a.startX,o=r-a.startY;i*i+o*o>n&&s()},end:e=>{a?.pointerId===e&&s(a.triggered)},cancel:e=>{a?.pointerId===e&&s()},openFromContextMenu:(t,n)=>{s(),o=t,e.onPressedKeyChange?.(t),n()},consumeClick:e=>o===e&&(o=null,!0),reset:()=>{s(),o=null,e.onPressedKeyChange?.(null)}}},bl=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/,``),xl=e=>{let t=e;return bl(t.directory??t.project?.worktree??null)},Sl=({open:e,project:t,worktree:n,onClose:r,onDeleted:i})=>{let{t:a}=be(),o=nt(),s=Ze(e=>e.activeSessions),c=bt(e=>e.archiveSessions),l=D(e=>e.currentDirectory),[u,d]=Q.useState(!1),[f,p]=Q.useState(!1),[m,h]=Q.useState(!1),[g,_]=Q.useState(!1),v=bl(n?.path),y=typeof n?.branch==`string`&&n.branch.trim().length>0,b=Q.useMemo(()=>{if(!v)return[];let e=new Map;for(let t of[...s,...o])xl(t)===v&&e.set(t.id,t);return Array.from(e.values())},[s,o,v]);Q.useEffect(()=>{if(!e){d(!1),p(!1),h(!1),_(!1);return}if(!n?.path)return;let t=!1;return ii(n.path).then(e=>{t||h(!!e?.isDirty)}).catch(()=>{t||h(!!n.status?.isDirty)}),()=>{t=!0}},[e,n?.path,n?.status?.isDirty]);let x=J(e=>{(async()=>{try{await ni(e.project,e.worktree,{deleteRemoteBranch:e.hasBranch&&e.deleteRemoteBranch,deleteLocalBranch:e.hasBranch&&e.deleteLocalBranch}),bl(e.currentDirectory)===e.worktreePath&&bl(e.project.path)&&D.getState().setDirectory(bl(e.project.path),{showOverlay:!1}),yt.success(e.t(`sessions.sidebar.sessionDialogs.worktree.removedTitle`),{description:e.hasBranch&&e.deleteRemoteBranch?e.t(`sessions.sidebar.sessionDialogs.worktree.removedWithRemote`):e.t(`sessions.sidebar.sessionDialogs.worktree.removed`)}),e.onDeleted?.()}catch(t){yt.error(e.t(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:t instanceof Error?t.message:e.t(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}})()}),S=async()=>{if(!n||g)return;let o={worktree:n,project:t,hasBranch:y,deleteLocalBranch:u,deleteRemoteBranch:f,currentDirectory:l,worktreePath:v,onDeleted:i,archiveSessions:c,linkedSessionIds:b.map(e=>e.id),onClose:r,open:e,t:a};_(!0);try{if(o.linkedSessionIds.length>0){let{archivedIds:e,failedIds:t}=await o.archiveSessions(o.linkedSessionIds);if(t.length>0){e.length>0&&yt.success(e.length===1?o.t(`sessions.sidebar.bulkActions.archivedSingle`,{count:e.length}):o.t(`sessions.sidebar.bulkActions.archivedPlural`,{count:e.length})),yt.error(t.length===1?o.t(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:t.length}):o.t(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:t.length}),{description:o.t(`sessions.sidebar.dialogs.deleteResult.tryAgain`)}),_(!1);return}}x(o),o.onClose()}catch(e){yt.error(o.t(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:e instanceof Error?e.message:o.t(`sessions.sidebar.dialogs.deleteResult.tryAgain`)}),_(!1)}finally{o.open||_(!1)}};if(!n)return null;let C=n.branch||n.label||n.path,w=(e,t,n,r)=>(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":e,disabled:r,onClick:()=>t(!e),className:Y(`flex w-full items-center justify-between gap-3 rounded-xl border border-border/50 px-3.5 py-3 text-left transition-colors`,`hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r&&`pointer-events-none opacity-40`),style:{touchAction:`manipulation`},children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n}),(0,$.jsx)(`span`,{className:Y(`relative h-6 w-10 shrink-0 rounded-full transition-colors`,e?`bg-primary`:`bg-muted-foreground/30`),children:(0,$.jsx)(`span`,{className:Y(`absolute top-0.5 size-5 rounded-full bg-white transition-transform`,e?`translate-x-[1.125rem]`:`translate-x-0.5`)})})]});return(0,$.jsx)(Mn,{open:e,onClose:r,title:a(`mobile.projectEdit.deleteWorktreeTitle`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(X,{variant:`ghost`,className:`flex-1`,onClick:r,disabled:g,children:a(`projectEditDialog.actions.cancel`)}),(0,$.jsx)(X,{variant:`destructive`,className:`flex-1`,onClick:()=>void S(),disabled:g,children:a(`mobile.projectEdit.deleteWorktreeConfirmButton`)})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-1 py-1`,children:[(0,$.jsx)(`p`,{className:`typography-ui-body text-foreground`,children:a(`mobile.projectEdit.deleteWorktreeConfirm`,{name:C})}),m?(0,$.jsx)(`p`,{className:`rounded-xl border border-[var(--warning)]/40 bg-[color-mix(in_srgb,var(--warning)_10%,transparent)] px-3.5 py-3 typography-meta text-foreground`,children:a(`mobile.projectEdit.deleteWorktreeDirty`)}):null,b.length>0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:a(`mobile.projectEdit.deleteWorktreeArchiveNote`,{count:b.length})}):null,y?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[w(u,d,a(`mobile.projectEdit.deleteLocalBranch`),g),w(f,p,a(`mobile.projectEdit.deleteRemoteBranch`),g)]}):null]})})},Cl=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/,``),wl=e=>{let t=(0,qi.c)(36),{worktree:n,onDelete:r}=e,{t:i}=be(),a;t[0]===n.path?a=t[1]:(a={id:n.path},t[0]=n.path,t[1]=a);let{attributes:o,listeners:s,setNodeRef:c,transform:l,transition:u,isDragging:d}=Gr(a),f;t[2]===l?f=t[3]:(f=Ur.Transform.toString(l),t[2]=l,t[3]=f);let p=d?10:1,m;t[4]!==f||t[5]!==p||t[6]!==u?(m={transform:f,transition:u,zIndex:p},t[4]=f,t[5]=p,t[6]=u,t[7]=m):m=t[7];let h=m,g=n.branch||n.label||n.path,_=d&&`shadow-lg shadow-black/20`,v;t[8]===_?v=t[9]:(v=Y(`flex items-center gap-1 rounded-2xl border border-border/40 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors`,_),t[8]=_,t[9]=v);let y;t[10]!==g||t[11]!==i?(y=i(`mobile.projectEdit.dragWorktreeAria`,{label:g}),t[10]=g,t[11]=i,t[12]=y):y=t[12];let b;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(Z,{name:`drag-move-2`,className:`size-4`}),t[13]=b):b=t[13];let x;t[14]!==o||t[15]!==s||t[16]!==y?(x=(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing`,"aria-label":y,...o,...s,children:b}),t[14]=o,t[15]=s,t[16]=y,t[17]=x):x=t[17];let S;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(Z,{name:`node-tree`,className:`size-4 shrink-0 text-muted-foreground`}),t[18]=S):S=t[18];let C;t[19]===g?C=t[20]:(C=(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:g}),t[19]=g,t[20]=C);let w;t[21]!==g||t[22]!==i?(w=i(`mobile.projectEdit.deleteWorktreeAria`,{label:g}),t[21]=g,t[22]=i,t[23]=w):w=t[23];let T,E;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(T={touchAction:`manipulation`},E=(0,$.jsx)(Z,{name:`delete-bin`,className:`size-4`}),t[24]=T,t[25]=E):(T=t[24],E=t[25]);let D;t[26]!==r||t[27]!==w?(D=(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive`,"aria-label":w,onClick:r,style:T,children:E}),t[26]=r,t[27]=w,t[28]=D):D=t[28];let O;return t[29]!==c||t[30]!==h||t[31]!==C||t[32]!==D||t[33]!==v||t[34]!==x?(O=(0,$.jsxs)(`div`,{ref:c,style:h,className:v,children:[x,S,C,D]}),t[29]=c,t[30]=h,t[31]=C,t[32]=D,t[33]=v,t[34]=x,t[35]=O):O=t[35],O},Tl=({open:e,project:t,onClose:n,onWorktreesChanged:r})=>{let{t:i}=be(),{currentTheme:a}=Lt(),o=ct(e=>e.updateProjectMeta),s=ct(e=>e.discoverProjectIcon),c=ct(e=>e.removeProjectIcon),l=pt(e=>e.setWorktreeOrder),u=ct(e=>t?e.projects.find(e=>e.id===t.id)?.iconImage??null:null),[d,f]=Q.useState(``),[p,m]=Q.useState(null),[h,g]=Q.useState(null),[_,v]=Q.useState(!1),[y,b]=Q.useState([]),[x,S]=Q.useState(null),C=t?.id??null;Q.useEffect(()=>{!e||!t||(f(t.label),m(t.icon??null),g(t.color??null),b(t.worktrees))},[e,C]),Q.useEffect(()=>{!e||!t||b(e=>{let n=t.worktrees.map(e=>e.path),r=e.map(e=>e.path);return n.length===r.length&&n.every(e=>r.includes(e))?e:t.worktrees})},[t?.worktrees]);let w=Hr(Nr(Br,{activationConstraint:{distance:8}}),Nr(Ir,{coordinateGetter:Wr})),T=()=>{if(!t)return;let e=d.trim();o(t.id,{label:e||t.label,icon:p,color:h}),n()},E=()=>{!t||_||(v(!0),s(t.id).then(e=>{if(!e.ok){yt.error(e.error||i(`projectEditDialog.toast.failedToDiscoverIcon`));return}if(e.skipped){yt.success(i(`projectEditDialog.toast.customIconAlreadySet`));return}yt.success(i(`projectEditDialog.toast.iconDiscovered`))}).finally(()=>v(!1)))},D=()=>{t&&c(t.id).then(e=>{if(!e.ok){yt.error(e.error||i(`projectEditDialog.toast.failedToRemoveIcon`));return}yt.success(i(`projectEditDialog.toast.iconRemoved`))})},O=e=>{let{active:n,over:r}=e;if(!r||n.id===r.id||!t)return;let i=y.findIndex(e=>e.path===n.id),a=y.findIndex(e=>e.path===r.id);if(i<0||a<0)return;let o=[...y],[s]=o.splice(i,1);o.splice(a,0,s),b(o),l(t.id,t.path,o.map(e=>Cl(e.path)))},k=h?ri[h]??null:null,A=p?ti[p]:null,j=!!u;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(dr,{id:`mobile-project-edit`,open:e,onOpenChange:e=>{e||n()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:i(`projectEditDialog.title`)}),trailing:(0,$.jsxs)(X,{type:`button`,variant:`default`,size:`sm`,"aria-label":i(`projectEditDialog.actions.save`),onClick:T,disabled:!d.trim(),style:{touchAction:`manipulation`},children:[(0,$.jsx)(Z,{name:`check`,className:`size-4`}),i(`projectEditDialog.actions.save`)]}),ariaLabel:i(`projectEditDialog.title`),closeAriaLabel:i(`mobile.surface.closeAria`),resizeAriaLabel:i(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:t?(0,$.jsxs)(`div`,{className:`overlay-scrollbar-container h-full space-y-6 overflow-y-auto px-4 pb-8 pt-2`,children:[(0,$.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,$.jsx)(`span`,{className:`flex size-16 items-center justify-center overflow-hidden rounded-2xl bg-[var(--surface-muted)] text-muted-foreground`,style:t.iconBackground?{backgroundColor:t.iconBackground}:void 0,children:j?(0,$.jsx)(Qr,{project:{id:t.id,iconImage:u},options:{themeVariant:a.metadata.variant,iconColor:a.colors.surface.foreground},className:`size-full object-contain`,fallback:(0,$.jsx)(Z,{name:`folder-6`,className:`size-7`})}):A?(0,$.jsx)(Z,{name:A,className:`size-7`,style:k?{color:k}:void 0}):(0,$.jsx)(Z,{name:`folder-6`,className:`size-7`,style:k?{color:k}:void 0})})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:i(`projectEditDialog.field.name`)}),(0,$.jsx)(Dn,{value:d,onChange:e=>f(e.target.value),placeholder:i(`projectEditDialog.field.namePlaceholder`),className:`h-11`}),(0,$.jsx)(`p`,{className:`truncate typography-meta text-muted-foreground`,title:t.path,children:t.path})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:i(`projectEditDialog.field.color`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>g(null),"aria-label":i(`projectEditDialog.option.none`),className:Y(`flex size-9 items-center justify-center rounded-xl border-2 transition-all`,h===null?`border-foreground`:`border-border hover:border-border/80`),style:{touchAction:`manipulation`},children:(0,$.jsx)(`span`,{className:`h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40`})}),si.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>g(e.key),"aria-label":e.label,title:e.label,className:Y(`size-9 rounded-xl border-2 transition-all`,h===e.key?`border-foreground`:`border-transparent hover:border-border`),style:{backgroundColor:e.cssVar,touchAction:`manipulation`}},e.key))]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:i(`projectEditDialog.field.icon`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(null),"aria-label":i(`projectEditDialog.option.none`),className:Y(`flex size-9 items-center justify-center rounded-xl border-2 transition-all`,p===null?`border-foreground bg-[var(--surface-elevated)]`:`border-border hover:border-border/80`),style:{touchAction:`manipulation`},children:(0,$.jsx)(`span`,{className:`h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40`})}),ai.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(e.key),"aria-label":e.label,title:e.label,className:Y(`flex size-9 items-center justify-center rounded-xl border-2 transition-all`,p===e.key?`border-foreground bg-[var(--surface-elevated)]`:`border-border hover:border-border/80`),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:e.Icon,className:`size-4`,style:k?{color:k}:void 0})},e.key))]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[(0,$.jsx)(X,{size:`sm`,variant:`outline`,onClick:E,disabled:_,children:i(_?`projectEditDialog.actions.discovering`:`projectEditDialog.actions.discoverFavicon`)}),j?(0,$.jsx)(X,{size:`sm`,variant:`outline`,onClick:D,children:i(`projectEditDialog.actions.removeProjectIcon`)}):null]})]}),t.isGitRepo?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:i(`mobile.projectEdit.worktreesTitle`)}),y.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:i(`mobile.projectEdit.worktreesEmpty`)}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:i(`mobile.projectEdit.reorderHint`)}),(0,$.jsx)(Vr,{sensors:w,collisionDetection:Lr,onDragEnd:O,children:(0,$.jsx)(qr,{items:y.map(e=>e.path),strategy:Kr,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:y.map(e=>(0,$.jsx)(wl,{worktree:e,onDelete:()=>S(e)},e.path))})})})]})]}):null]}):null}),t?(0,$.jsx)(Sl,{open:!!x,project:{id:t.id,path:t.path},worktree:x,onClose:()=>S(null),onDeleted:()=>{b(e=>e.filter(e=>e.path!==x?.path)),r?.()}}):null]})},El=()=>3,Dl=()=>7,Ol=(e,t,n)=>{let r=new Map;for(let[n,i]of e)t.has(n)&&r.set(n,i);for(let e of n)e.status===`success`&&r.set(e.path,e.worktrees??[]);return $r(r,e)?e:r},kl=(e,t)=>{t&&e.push(t)},Al=e=>{let t=[];return kl(t,e.onRename?{id:`rename`,icon:`pencil-ai`,labelKey:`sessions.sidebar.session.menu.rename`,onClick:e.onRename}:null),kl(t,e.onTogglePin?{id:`pin`,icon:e.pinned?`unpin`:`pushpin`,labelKey:e.pinned?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`,onClick:e.onTogglePin}:null),e.shared?(kl(t,e.onCopyLink?{id:`copyLink`,icon:`file-copy`,labelKey:`sessions.sidebar.session.menu.copyLink`,onClick:e.onCopyLink}:null),kl(t,e.onUnshare?{id:`unshare`,icon:`link-unlink-m`,labelKey:`sessions.sidebar.session.menu.unshare`,onClick:e.onUnshare}:null)):kl(t,e.onShare?{id:`share`,icon:`share-2`,labelKey:`sessions.sidebar.session.menu.share`,onClick:e.onShare}:null),kl(t,e.onRefreshTranscript?{id:`refreshTranscript`,icon:`refresh`,labelKey:`sessions.sidebar.session.menu.refreshTranscript`,onClick:e.onRefreshTranscript,disabled:e.refreshTranscriptDisabled,spinning:e.refreshTranscriptSpinning}:null),kl(t,e.onArchive?{id:`archive`,icon:`archive`,labelKey:`sessions.sidebar.bulkActions.archive`,onClick:e.onArchive}:null),kl(t,e.onDelete?{id:`delete`,icon:`delete-bin`,labelKey:`sessions.sidebar.bulkActions.delete`,onClick:e.onDelete,destructive:!0,separated:!0}:null),e.extraItems?.length&&t.push(...e.extraItems),t},jl=e=>{let t=[];return kl(t,e.onNewSession?{id:`newSession`,icon:`add`,labelKey:`sessions.sidebar.project.actions.newSession`,onClick:e.onNewSession}:null),kl(t,e.gitRepository&&e.onNewWorktree?{id:`newWorktree`,icon:`node-tree`,labelKey:`sessions.sidebar.project.actions.newWorktree`,onClick:e.onNewWorktree}:null),kl(t,e.onSyncSessions?{id:`syncSessions`,icon:`refresh`,labelKey:`sessions.sidebar.project.actions.syncSessions`,onClick:e.onSyncSessions}:null),kl(t,e.onEditProject?{id:`edit`,icon:`pencil-ai`,labelKey:`sessions.sidebar.project.actions.edit`,onClick:e.onEditProject}:null),kl(t,e.onCloseProject?{id:`closeProject`,icon:`close`,labelKey:`sessions.sidebar.project.actions.closeProject`,onClick:e.onCloseProject,destructive:!0,separated:!0}:null),e.extraItems?.length&&t.push(...e.extraItems),t},Ml=e=>{let t=[];return kl(t,e.onNewSession?{id:`newSession`,icon:`add`,labelKey:`sessions.sidebar.project.actions.newSession`,onClick:e.onNewSession}:null),kl(t,e.onDeleteWorktree?{id:`deleteWorktree`,icon:`delete-bin`,labelKey:`mobile.projectEdit.deleteWorktreeConfirmButton`,onClick:e.onDeleteWorktree,destructive:!0,separated:!0}:null),e.extraItems?.length&&t.push(...e.extraItems),t},Nl=(e,t)=>t(e.labelKey),Pl=[],Fl=(e,t)=>{let n=e?.[t];return n?.type===`busy`||n?.type===`retry`?n.type:`idle`},Il=e=>{let t=new Set(e.map(e=>e.id)),n=new Map;for(let r of e){let e=r.parentID;if(e&&t.has(e)){let t=n.get(e)??[];t.push(r),n.set(e,t)}}return{allIds:t,parentChildMap:n}},Ll=(e,t)=>{let n=e.parentID;return!n||!t.has(n)};function Rl(e,t,n){let{allIds:r,parentChildMap:i}=Il(e),a=0,o=0;for(let s of e){if(!Ll(s,r))continue;let e=Fl(t,s.id),c=(i.get(s.id)??[]).filter(e=>Fl(t,e.id)!==`idle`).length;a+=(e===`idle`?0:1)+c,(n?.[s.id]??0)>0&&(o+=1)}return{totalRunning:a,totalUnread:o}}function zl(e,t,n,r,i){if(!r){let r=Rl(e,t,n);return{sessions:Pl,totalRunning:r.totalRunning,totalUnread:r.totalUnread,totalCount:0}}let{allIds:a,parentChildMap:o}=Il(e),s=e.filter(e=>Ll(e,a)),c=[],l=[];for(let e of s){let r=Fl(t,e.id),i=(o.get(e.id)??[]).filter(e=>Fl(t,e.id)!==`idle`),a=i.length>0,s=(n?.[e.id]??0)>0,u={...e,_statusType:r,_hasRunningChildren:a,_runningChildrenCount:i.length,_childIndicators:i.slice(0,3).map(e=>({session:e,isRunning:!0}))};r!==`idle`||a||s?c.push(u):l.push(u)}let u=(e,t)=>i(t)-i(e);c.sort(u),l.sort(u);let d=[...c,...l];return{sessions:d,totalRunning:d.reduce((e,t)=>e+(t._statusType===`idle`?0:1)+(t._runningChildrenCount??0),0),totalUnread:d.filter(e=>(n?.[e.id]??0)>0).length,totalCount:d.length}}function Bl(){let e=(0,qi.c)(3),t=nt(),n=Ze(Ul),r;if(e[0]!==n||e[1]!==t){let i=new Map(t.map(Hl));r=n.map(e=>{let t=i.get(e.id);return t?Ke(t,e):e});let a=new Set(r.map(Vl));for(let e of t)a.has(e.id)||r.push(e);e[0]=n,e[1]=t,e[2]=r}else r=e[2];return r}function Vl(e){return e.id}function Hl(e){return[e.id,e]}function Ul(e){return e.activeSessions}var Wl=`__pinned_sessions__`;function Gl(e){return e===null||e===Wl}function Kl(e){let{activeProjectId:t,currentFilterProjectId:n,projects:r}=e;return n===null?null:n===Wl||r.some(e=>e.id===n)?n:t??n}var ql=3,Jl=7,Yl=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.replace(/\/+$/,``)},Xl=e=>{let t=e;return Yl(t.directory??t.project?.worktree??``)},Zl=e=>{let t=new Set(e.map(e=>e.id));return e.filter(e=>{let n=e.parentID;return!n||!t.has(n)}).length};function Ql(e){e.preventBaseUIHandler()}function $l(e,t,n){t&&(e.preventBaseUIHandler(),n(e))}function eu(e){let t=(0,qi.c)(10),{icon:n,label:r,onClick:i,destructive:a}=e,o=a!==void 0&&a?`destructive`:`ghost`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,$.jsx)(Z,{name:n,className:`size-5 shrink-0`}),t[1]=n,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[3]=r,t[4]=l);let u;return t[5]!==i||t[6]!==o||t[7]!==c||t[8]!==l?(u=(0,$.jsxs)(X,{type:`button`,variant:o,size:`default`,className:`min-h-12 w-full justify-start gap-3 rounded-xl px-3`,onClick:i,style:s,children:[c,l]}),t[5]=i,t[6]=o,t[7]=c,t[8]=l,t[9]=u):u=t[9],u}function tu(e,t,n,r){let i=dt(e=>e.index.session.unseenCount),a=Q.useRef([]);return Q.useMemo(()=>{let o=zl(e,t,i,n,ze);return n?(a.current=o.sessions,o):r?{...o,sessions:a.current,totalCount:a.current.length}:(a.current=[],o)},[n,r,e,t,i])}function nu(){let e=(0,qi.c)(7),{t}=be(),n;e[0]===t?n=e[1]:(n=e=>{let n=e.title;return n&&n.trim()?n:t(`mobile.sessions.newChat`)},e[0]=t,e[1]=n);let r=n,i=dt(ru),a;e[2]===i?a=e[3]:(a=e=>(i[e]??0)>0,e[2]=i,e[3]=a);let o=a,s;return e[4]!==r||e[5]!==o?(s={getSessionTitle:r,needsAttention:o},e[4]=r,e[5]=o,e[6]=s):s=e[6],s}function ru(e){return e.index.session.unseenCount}function iu(e,t,n){let r=(0,qi.c)(6),i=bt(su),a=bt(ou),o=dt(au),s;return r[0]!==i||r[1]!==n||r[2]!==a||r[3]!==o||r[4]!==t?(s=e=>{let r=e=>{let n=t?.[e];return n?.type===`busy`||n?.type===`retry`?n.type:`idle`},s=Yl(e);if(!s)return{hasRunning:!1,hasUnread:!1};let c=[s],l=i.get(s)??[];for(let e of l){let t=e&&typeof e==`object`&&`path`in e?e.path:null;if(typeof t==`string`&&t.trim()){let e=Yl(t);e&&e!==s&&c.push(e)}}let u=new Set,d=!1,f=!1;for(let e of c){for(let t of a(e))if(!(!t?.id||u.has(t.id))&&(u.add(t.id),r(t.id)!==`idle`&&(d=!0),t.id!==n&&(o[t.id]??0)>0&&(f=!0),d&&f))break;if(d&&f)break}return{hasRunning:d,hasUnread:f}},r[0]=i,r[1]=n,r[2]=a,r[3]=o,r[4]=t,r[5]=s):s=r[5],s}function au(e){return e.index.session.unseenCount}function ou(e){return e.getSessionsByDirectory}function su(e){return e.availableWorktreesByProject}function cu(){let e=(0,qi.c)(2),t=bt(lu),n;return e[0]===t?n=e[1]:(n=e=>{let n=Yl(e.path),r=[n],i=t.get(n)??[];for(let e of i){let t=e&&typeof e==`object`&&`path`in e?e.path:null;if(typeof t==`string`&&t.trim()){let e=Yl(t);e&&r.push(e)}}return r},e[0]=t,e[1]=n),n}function lu(e){return e.availableWorktreesByProject}function uu(e){let t=(0,qi.c)(2),{isRunning:n,showUnread:r}=e;if(n){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(dl,{}),t[0]=e):e=t[0],e}if(r){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-[var(--status-info)]`}),t[1]=e):e=t[1],e}return null}function du(e){let t=(0,qi.c)(3),{count:n}=e;if(n===0)return null;let r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(dl,{}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[13px] text-[var(--surface-mutedForeground)]`,children:[r,n]}),t[1]=n,t[2]=i),i}function fu(e){let t=(0,qi.c)(3),{count:n}=e;if(n===0)return null;let r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-[var(--status-info)]`}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[13px] text-[var(--status-info)]`,children:[r,n]}),t[1]=n,t[2]=i),i}var pu=()=>{if(typeof window>`u`)return;let e=window.getSelection();e?.rangeCount&&e.removeAllRanges()},mu={touchAction:`manipulation`,userSelect:`none`,WebkitUserSelect:`none`,WebkitTouchCallout:`none`};function hu(e){let t=(0,qi.c)(72),{session:n,isCurrent:r,isPinned:i,contextLabel:a,getSessionTitle:o,onClick:s,onRename:c,onTogglePinned:l,onShare:u,onCopyShareUrl:d,onUnshare:f,onArchive:p,onDelete:m,needsAttention:h,longPressHandlers:g}=e,{t:_}=be(),[v,y]=Q.useState(!1),b;t[0]!==h||t[1]!==n.id?(b=h(n.id),t[0]=h,t[1]=n.id,t[2]=b):b=t[2];let x=b,S=n.share?.url,C=!!S,w=S?void 0:u,T;t[3]!==d||t[4]!==S?(T=S?()=>d(S):void 0,t[3]=d,t[4]=S,t[5]=T):T=t[5];let E=S?f:void 0,D;t[6]!==i||t[7]!==p||t[8]!==m||t[9]!==c||t[10]!==l||t[11]!==C||t[12]!==w||t[13]!==T||t[14]!==E?(D=Al({pinned:i,shared:C,onRename:c,onTogglePin:l,onShare:w,onCopyLink:T,onUnshare:E,onArchive:p,onDelete:m}),t[6]=i,t[7]=p,t[8]=m,t[9]=c,t[10]=l,t[11]=C,t[12]=w,t[13]=T,t[14]=E,t[15]=D):D=t[15];let O=D,k;t[16]!==g.onContextMenu||t[17]!==g.pressed?(k=e=>{$l(e,g.pressed,g.onContextMenu)},t[16]=g.onContextMenu,t[17]=g.pressed,t[18]=k):k=t[18];let A=n.id,j=`session:${n.id}`,M=g.onPointerDown,N=g.onPointerMove,ee=g.onPointerUp,P=g.onPointerCancel,F;t[19]!==v||t[20]!==s?(F=e=>{if(v){e.preventDefault();return}s()},t[19]=v,t[20]=s,t[21]=F):F=t[21];let I=g.pressed&&`bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)] scale-[0.99]`,L=r?`bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)]`:`hover:bg-[var(--interactive-hover)]`,R;t[22]!==I||t[23]!==L?(R=Y(`flex w-full min-h-[56px] items-center gap-3 rounded-xl px-3 py-3 text-left transition-colors select-none`,`active:bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)]`,I,L),t[22]=I,t[23]=L,t[24]=R):R=t[24];let z;t[25]!==g.onPointerCancel||t[26]!==g.onPointerDown||t[27]!==g.onPointerMove||t[28]!==g.onPointerUp||t[29]!==n.id||t[30]!==F||t[31]!==R||t[32]!==j?(z=(0,$.jsx)(`button`,{type:`button`,"data-mobile-session-context-trigger":A,"data-mobile-long-press-trigger":j,onPointerDown:M,onPointerMove:N,onPointerUp:ee,onPointerCancel:P,onClick:F,className:R,style:mu}),t[25]=g.onPointerCancel,t[26]=g.onPointerDown,t[27]=g.onPointerMove,t[28]=g.onPointerUp,t[29]=n.id,t[30]=F,t[31]=R,t[32]=j,t[33]=z):z=t[33];let te=n._statusType!==`idle`,B=x&&!r,V;t[34]!==te||t[35]!==B?(V=(0,$.jsx)(`span`,{className:`flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:(0,$.jsx)(uu,{isRunning:te,showUnread:B})}),t[34]=te,t[35]=B,t[36]=V):V=t[36];let H=r?`font-semibold text-[var(--surface-foreground)]`:`text-[var(--surface-foreground)]`,ne;t[37]===H?ne=t[38]:(ne=Y(`truncate text-[15px] leading-tight`,H),t[37]=H,t[38]=ne);let re;t[39]!==o||t[40]!==n?(re=o(n),t[39]=o,t[40]=n,t[41]=re):re=t[41];let U;t[42]!==ne||t[43]!==re?(U=(0,$.jsx)(`span`,{className:ne,children:re}),t[42]=ne,t[43]=re,t[44]=U):U=t[44];let W;t[45]===a?W=t[46]:(W=a?(0,$.jsx)(`span`,{className:`truncate text-[12px] leading-none text-[var(--surface-mutedForeground)]`,children:a}):null,t[45]=a,t[46]=W);let ie;t[47]!==U||t[48]!==W?(ie=(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[U,W]}),t[47]=U,t[48]=W,t[49]=ie):ie=t[49];let ae;t[50]===n._runningChildrenCount?ae=t[51]:(ae=(n._runningChildrenCount??0)>0&&(0,$.jsxs)(`span`,{className:`flex flex-shrink-0 items-center gap-1 text-[12px] text-[var(--surface-mutedForeground)]`,children:[(0,$.jsx)(dl,{size:12}),n._runningChildrenCount]}),t[50]=n._runningChildrenCount,t[51]=ae);let oe;t[52]===r?oe=t[53]:(oe=r&&(0,$.jsx)(Z,{name:`check`,className:`h-4 w-4 flex-shrink-0 text-[var(--primary-base)]`}),t[52]=r,t[53]=oe);let G;t[54]!==z||t[55]!==V||t[56]!==ie||t[57]!==ae||t[58]!==oe||t[59]!==k?(G=(0,$.jsxs)(ji,{onTouchStart:Ql,onContextMenu:k,render:z,children:[V,ie,ae,oe]}),t[54]=z,t[55]=V,t[56]=ie,t[57]=ae,t[58]=oe,t[59]=k,t[60]=G):G=t[60];let K;if(t[61]!==O||t[62]!==_){let e;t[64]===_?e=t[65]:(e=(e,t)=>(0,$.jsxs)(Q.Fragment,{children:[t>0&&(e.separated||e.id===`archive`)?(0,$.jsx)(Mi,{}):null,(0,$.jsxs)(Pi,{className:`min-h-10 px-3`,onClick:e.onClick,children:[(0,$.jsx)(Z,{name:e.icon,className:`size-4`}),Nl(e,_)]})]},e.id),t[64]=_,t[65]=e),K=O.map(e),t[61]=O,t[62]=_,t[63]=K}else K=t[63];let se;t[66]===K?se=t[67]:(se=(0,$.jsx)(Ni,{className:`min-w-[200px] p-1.5`,children:K}),t[66]=K,t[67]=se);let ce;return t[68]!==v||t[69]!==G||t[70]!==se?(ce=(0,$.jsxs)(Fi,{open:v,onOpenChange:y,children:[G,se]}),t[68]=v,t[69]=G,t[70]=se,t[71]=ce):ce=t[71],ce}function gu(e){let t=(0,qi.c)(23),{label:n,leadingIcon:r,icon:i,project:a,iconOptions:o,iconBackground:s,colorVar:c,isActive:l,status:u,onClick:d}=e,f=i?ti[i]:null,p;t[0]!==c||t[1]!==l||t[2]!==f?(p=f?(0,$.jsx)(Z,{name:f,className:`h-4 w-4`,style:!l&&c?{color:c}:void 0}):null,t[0]=c,t[1]=l,t[2]=f,t[3]=p):p=t[3];let m=p,h=l?`border-transparent bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)] text-[var(--surface-foreground)] font-medium`:`border-[var(--interactive-border)] bg-transparent text-[var(--surface-foreground)] active:bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)]`,g;t[4]===h?g=t[5]:(g=Y(`flex min-h-[40px] shrink-0 select-none items-center gap-1.5 rounded-full border px-3.5 text-[13px] leading-none whitespace-nowrap transition-colors`,h),t[4]=h,t[5]=g);let _;t[6]!==l||t[7]!==u?(_=u&&(u.hasRunning||u.hasUnread)&&!l&&(u.hasRunning?(0,$.jsx)(dl,{size:10}):(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--status-info)]`})),t[6]=l,t[7]=u,t[8]=_):_=t[8];let v;t[9]!==m||t[10]!==s||t[11]!==o||t[12]!==a?(v=a?.iconImage?(0,$.jsx)(`span`,{className:`inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]`,style:s?{backgroundColor:s}:void 0,children:(0,$.jsx)(Qr,{project:a,options:o,className:`h-full w-full object-contain`,fallback:m})}):m,t[9]=m,t[10]=s,t[11]=o,t[12]=a,t[13]=v):v=t[13];let y;t[14]===n?y=t[15]:(y=(0,$.jsx)(`span`,{className:`max-w-[140px] truncate`,children:n}),t[14]=n,t[15]=y);let b;return t[16]!==r||t[17]!==d||t[18]!==g||t[19]!==_||t[20]!==v||t[21]!==y?(b=(0,$.jsxs)(`button`,{type:`button`,onClick:d,className:g,children:[r,_,v,y]}),t[16]=r,t[17]=d,t[18]=g,t[19]=_,t[20]=v,t[21]=y,t[22]=b):b=t[22],b}var _u=({onSessionSwitch:e})=>{let{t}=be(),{git:n}=ne(),{currentTheme:r}=Lt(),i=j(e=>e.isMobile),a=Bl(),o=bt(e=>e.currentSessionId),s=Fe(),c=Q.useMemo(()=>Object.fromEntries([...s].map(e=>[e,{type:`busy`}])),[s]),l=bt(e=>e.setCurrentSession),u=bt(e=>e.openNewSessionDraft),d=Q.useCallback(e=>{if(!ae()){St.getState().openDraft(e);return}u(e)},[u]),f=bt(e=>e.archiveSession),p=bt(e=>e.shareSession),m=bt(e=>e.unshareSession),h=bt(e=>e.updateSessionTitle),g=bt(e=>e.requestSessionSmartTitle),_=j(e=>e.mobileSessionPanelOpen),v=j(e=>e.setMobileSessionPanelOpen),y=pr({onDismiss:()=>v(!1)}),b=ct(e=>e.projects),x=ct(e=>e.activeProjectId),S=ct(e=>e.setActiveProjectIdOnly),C=ct(e=>e.removeProject),w=ft(),T=wt(),E=bt(e=>e.availableWorktreesByProject),D=pt(e=>e.orderByProject),O=Ze(e=>e.activePaginationByDirectory),k=ul(e=>e.expandedWorktreeGroups),A=ul(e=>e.setWorktreeGroupExpanded),[M,N]=Q.useState(_),[ee,P]=Q.useState(!1),F=J(e=>{P(e),e&&N(!0)});Q.useEffect(()=>{_&&N(!0)},[_]);let I=J(()=>{y.reset(),N(!1)}),{sessions:L,totalRunning:R,totalUnread:z}=tu(a,c,_||ee,M),{getSessionTitle:te,needsAttention:B}=nu(),V=iu(a,c,o),H=cu(),[re,U]=Q.useState(new Map),W=qc(),[ie,oe]=Q.useState(new Map),[G,K]=Q.useState(!1),[se,ce]=Q.useState(null),[q,le]=Q.useState(null),[ue,de]=Q.useState(null),[fe,pe]=Q.useState(null),[me,he]=Q.useState(``),[ge,_e]=Q.useState(null),[ve,Se]=Q.useState(null),[Ce,we]=Q.useState(null),Te=Q.useRef(null);Te.current||=yl({onPressedKeyChange:de});let Ee=Q.useRef(null),[De,Oe]=Q.useState(!1),ke=j(e=>e.mobileSessionFilterProjectId),Ae=j(e=>e.setMobileSessionFilterProjectId),je=Q.useMemo(()=>a.some(e=>w.has(e.id)),[w,a]);Q.useEffect(()=>{!je&&ke===Wl&&Ae(null)},[ke,je,Ae]);let Me=Q.useRef(!1);Q.useEffect(()=>{let e=Me.current;if(Me.current=_,!_||e)return;let t=Kl({activeProjectId:x,currentFilterProjectId:ke,projects:b});t!==ke&&Ae(t)},[_,x,ke,b,Ae]),Q.useEffect(()=>{_||(le(null),we(null),Te.current?.reset())},[_]),Q.useEffect(()=>()=>{Te.current?.reset()},[]),Q.useEffect(()=>{if(!q)return;pu();let e=window.requestAnimationFrame(pu);return document.addEventListener(`selectionchange`,pu),()=>{window.cancelAnimationFrame(e),document.removeEventListener(`selectionchange`,pu),pu()}},[q]);let Ne=Q.useMemo(()=>ke&&ke!==Wl?b.find(e=>e.id===ke)??null:null,[ke,b]),Pe=Q.useMemo(()=>Ne??b.find(e=>e.id===x)??null,[x,b,Ne]);Q.useEffect(()=>{let e=Yl(Pe?.path??``);if(!_||!e){Oe(!1);return}let t=Ee.current;if(t?.git===n&&t.path===e){Oe(t.isGitRepository);return}let r=!1;return Oe(!1),n.checkIsGitRepository(e).then(t=>{r||(Ee.current={git:n,path:e,isGitRepository:t},Oe(t))}).catch(()=>{r||(Ee.current={git:n,path:e,isGitRepository:!1},Oe(!1))}),()=>{r=!0}},[n,_,Pe]),Q.useEffect(()=>{if(!_||b.length===0)return;let e=!1;return Promise.all(b.map(async e=>({projectId:e.id,branch:await ei(e.path).catch(()=>null)}))).then(t=>{e||oe(e=>{let n=new Map(e);for(let e of t){let t=e.branch?.trim();t&&t!==`HEAD`&&n.set(e.projectId,t),e.branch===`HEAD`&&n.delete(e.projectId)}return n})}),()=>{e=!0}},[_,b]);let Ie=Q.useMemo(()=>{if(ke&&ke!==Wl){let e=b.find(e=>e.id===ke);return e?H(e):[]}return b.flatMap(H)},[ke,b,H]);Q.useEffect(()=>{_&&We(Ie)},[_,Ie]),Q.useEffect(()=>{if(!_||b.length===0)return;let e=!1;return(async()=>{let t=await Promise.all(b.map(async t=>{let r=Yl(t.path);if(!r)return null;let i=!1;try{i=await n.checkIsGitRepository(r)}catch{return{path:r,status:`failed`}}if(!i)return{path:r,status:`success`,worktrees:[]};try{return{path:r,status:`success`,worktrees:(await oi({id:t.id,path:r},{isCurrent:()=>!e})).worktrees}}catch{return{path:r,status:`failed`}}}));if(e)return;let r=new Set(b.map(e=>Yl(e.path)).filter(Boolean)),i=t.flatMap(e=>e?[e]:[]);bt.setState(e=>{let t=Ol(e.availableWorktreesByProject,r,i);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:Array.from(t.values()).flat()}})})(),()=>{e=!0}},[n,_,b]);let Le=Q.useCallback(e=>xe(e.path)||e.path,[]),Re=Q.useMemo(()=>{if(!M||!ke)return L;if(ke===Wl)return L.filter(e=>w.has(e.id));let e=b.find(e=>e.id===ke);if(!e)return L;let t=H(e);return L.filter(e=>{let n=Xl(e);return t.some(e=>Yl(e)===n)})},[M,L,ke,w,b,H]),ze=Q.useMemo(()=>{if(!M||!Ne)return[];let e=Yl(Ne.path),t=Dt(D[Ne.id],E.get(e)??[]),n=[{key:`${Ne.id}::${e}`,directory:e,label:Le(Ne),worktree:null,sessions:[]}];for(let r of t){let t=Yl(r.path);!t||t===e||n.some(e=>e.directory===t)||n.push({key:`${Ne.id}::${t}`,directory:t,label:r.branch||r.label||xe(t),worktree:r,sessions:[]})}let r=new Map(n.map(e=>[e.directory,e]));for(let e of Re)r.get(Xl(e))?.sessions.push(e);return n},[E,Re,Le,M,Ne,D]),Be=Q.useCallback(e=>{let t=Xl(e);for(let e of b){let n=Yl(e.path),r=Le(e);if(t===n){let t=ie.get(e.id);return t?`${r} · ${t}`:r}let i=(E.get(n)??[]).find(e=>Yl(e.path)===t);if(i)return i.branch?`${r} · ${i.branch}`:r}return xe(t)||t||void 0},[E,Le,b,ie]),Ve=Q.useCallback(()=>{le(null),Te.current?.reset(),v(!1)},[v]),He=()=>{le(null),Te.current?.reset()},Ue=e=>({pressed:ue===e.key||q?.key===e.key,onPointerDown:t=>{t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||Te.current?.start({pointerId:t.pointerId,key:e.key,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>{pu(),le(e)}})},onPointerMove:e=>{Te.current?.move(e.pointerId,e.clientX,e.clientY)},onPointerUp:e=>{Te.current?.end(e.pointerId)},onPointerCancel:e=>{Te.current?.cancel(e.pointerId)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),pu(),Te.current?.openFromContextMenu(e.key,()=>le(e))}}),Ge=(e,t)=>{Te.current?.consumeClick(e)||t()},Ke=Q.useCallback(t=>{ir(),Ve();let n=Xl(t)||null,r=Gl(ke);ae()?l(t.id,n,{preserveActiveProject:r}):St.getState().openSession({sessionId:t.id,directory:n,preserveActiveProject:r}),e?.(t.id)},[Ve,ke,e,l]),qe=Q.useCallback(async e=>{try{if(!(await p(e.id))?.share?.url){yt.error(t(`sessions.sidebar.session.share.error`));return}yt.success(t(`sessions.sidebar.session.share.successTitle`),{description:t(`sessions.sidebar.session.share.successDescription`)})}catch{yt.error(t(`sessions.sidebar.session.share.error`))}},[p,t]),Je=Q.useCallback(async e=>{if((await ye(e)).ok){yt.success(t(`sessions.sidebar.session.menu.copied`));return}yt.error(t(`sessions.sidebar.session.share.copyUrlError`))},[t]),Ye=Q.useCallback(async e=>{try{if(!await m(e)){yt.error(t(`sessions.sidebar.session.unshare.error`));return}yt.success(t(`sessions.sidebar.session.unshare.success`))}catch{yt.error(t(`sessions.sidebar.session.unshare.error`))}},[t,m]),Xe=Q.useCallback(async e=>{if(!await f(e)){yt.error(t(`sessions.sidebar.session.archive.error`));return}hl({sessionIds:[e],message:t(`sessions.sidebar.session.archive.success`),undoLabel:t(`sessions.sidebar.undo`),settingsLabel:t(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:t(`sessions.sidebar.session.archive.undoFailed`)})},[f,t]),Qe=J(e=>{let t=new Map;for(let e of a){let n=e.parentID??null;if(!n)continue;let r=t.get(n)??[];r.push(e.id),t.set(n,r)}let n=[],r=new Set,i=e=>{if(!r.has(e)){r.add(e),n.push(e);for(let n of t.get(e)??[])i(n)}};return i(e),n}),$e=J(e=>{let n=Qe(e.id);gl({sessionIds:n,message:n.length===1?t(`sessions.sidebar.session.delete.success`):t(`sessions.sidebar.bulkActions.deletedPlural`,{count:n.length}),undoLabel:t(`sessions.sidebar.undo`),commitFailedMessage:t(`sessions.sidebar.session.delete.error`)})}),et=Q.useCallback(e=>{he(te(e)),pe(e)},[te]),tt=Q.useCallback(async()=>{if(!fe)return;let e=me.trim();if(e)try{await h(fe.id,e),pe(null),he(``)}catch{yt.error(t(`sessions.sidebar.session.menu.rename`),{description:t(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},[me,fe,t,h]),nt=Q.useCallback(async()=>{if(!fe)return;let e=fe.id;pe(null),he(``);try{await g(e)}catch{yt.error(t(`sessions.sidebar.session.rename.smartTitle`),{description:t(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},[fe,g,t]),rt=Q.useCallback(()=>{if(Ve(),ke){let e=b.find(e=>e.id===ke);if(e){d({selectedProjectId:e.id,directoryOverride:e.path});return}}let e=[...a].sort((e,t)=>{let n=e.time?.updated??0;return(t.time?.updated??0)-n})[0],t=e?Xl(e):``;d(t?{directoryOverride:t}:void 0)},[Ve,ke,b,a,d]),at=Q.useCallback(()=>{!Pe||!De||(Ve(),S(Pe.id),ce(Pe.id),K(!0))},[Ve,S,De,Pe]),ot=(e,t)=>{He(),v(!1),d({selectedProjectId:e.id,directoryOverride:t,preserveDirectoryOverride:!0})},lt=e=>{He(),(async()=>{try{await oi({id:e.project.id,path:e.project.path})}catch(e){console.warn(`[MobileStatus] Worktree refresh before session sync failed:`,e)}let t=bt.getState().availableWorktreesByProject.get(e.project.path)??e.worktrees;await st([e.project.path,...t.map(e=>e.path)],a)})()},ut=J(e=>{A(e,!k[e]),U(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})}),dt=Q.useCallback(e=>{let t=(re.get(e.key)??ql)+Jl;if(U(t=>{let n=new Map(t);return n.set(e.key,(t.get(e.key)??ql)+Jl),n}),t<e.sessions.length)return;let n=Ze.getState().activePaginationByDirectory.get(e.directory);n?.hasMore&&!n.loadingMore&&it(e.directory)},[re]),mt=Q.useCallback(e=>{U(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),ht=e=>{let n=e.worktree===null,r=n||k[e.key]===!0,i=re.get(e.key)??ql,a=ol(e.sessions,i,W),s=O.get(e.directory),c=a.length<e.sessions.length||s?.hasMore===!0,l=e.sessions.length>ql&&i>ql,u=n&&Ne?ie.get(Ne.id):null,d=e.label,f=n?`project:${Ne?.id??e.key}`:`worktree:${Ne?.id??e.key}:${e.directory}`,p=Ne?Ue(n?{key:f,kind:`project`,project:Ne,worktrees:ze.flatMap(e=>e.worktree?[e.worktree]:[]),isGitRepository:De}:{key:f,kind:`worktree`,project:Ne,worktree:e.worktree}):null;return(0,$.jsxs)(`section`,{className:`rounded-xl`,children:[n?(0,$.jsxs)(`div`,{"data-mobile-long-press-trigger":f,className:Y(`flex min-h-12 items-center gap-2 rounded-xl px-3 py-2 text-left transition-all select-none`,p?.pressed&&`bg-[var(--interactive-active)] scale-[0.99]`),onPointerDown:p?.onPointerDown,onPointerMove:p?.onPointerMove,onPointerUp:p?.onPointerUp,onPointerCancel:p?.onPointerCancel,onContextMenu:p?.onContextMenu,style:mu,children:[(0,$.jsx)(Z,{name:`folder-open`,className:`size-4 shrink-0 text-[var(--surface-mutedForeground)]`}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`truncate text-[14px] font-semibold text-[var(--surface-foreground)]`,children:d}),u?(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 text-[12px] text-[var(--surface-mutedForeground)]`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:u})]}):null]}),(0,$.jsx)(`span`,{className:`shrink-0 text-[12px] tabular-nums text-[var(--surface-mutedForeground)]`,children:Zl(e.sessions)})]}):(0,$.jsxs)(`button`,{type:`button`,"data-mobile-long-press-trigger":f,onClick:()=>Ge(f,()=>ut(e.key)),onPointerDown:p?.onPointerDown,onPointerMove:p?.onPointerMove,onPointerUp:p?.onPointerUp,onPointerCancel:p?.onPointerCancel,onContextMenu:p?.onContextMenu,"aria-expanded":r,"aria-label":t(r?`sessions.sidebar.group.collapseAria`:`sessions.sidebar.group.expandAria`,{label:d}),className:Y(`flex min-h-12 w-full items-center gap-2 rounded-xl px-3 py-2 text-left transition-all hover:bg-[var(--interactive-hover)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] select-none`,p?.pressed&&`bg-[var(--interactive-active)] scale-[0.99]`),style:mu,children:[(0,$.jsx)(Z,{name:`arrow-down-s`,className:Y(`size-4 shrink-0 text-[var(--surface-mutedForeground)] transition-transform`,r?`rotate-0`:`-rotate-90`)}),(0,$.jsx)(Z,{name:`node-tree`,className:`size-4 shrink-0 text-[var(--surface-mutedForeground)]`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[14px] font-semibold text-[var(--surface-foreground)]`,children:d}),(0,$.jsx)(`span`,{className:`shrink-0 text-[12px] tabular-nums text-[var(--surface-mutedForeground)]`,children:Zl(e.sessions)})]}),r?(0,$.jsxs)(`div`,{className:`pb-1`,children:[a.map(e=>(0,$.jsx)(hu,{session:e,isCurrent:e.id===o,isPinned:w.has(e.id),getSessionTitle:te,onClick:()=>Ge(`session:${e.id}`,()=>Ke(e)),onRename:()=>et(e),onTogglePinned:()=>T(e.id),onShare:()=>{qe(e)},onCopyShareUrl:e=>{Je(e)},onUnshare:()=>{Ye(e.id)},onArchive:()=>{Xe(e.id)},onDelete:()=>$e(e),needsAttention:B,longPressHandlers:Ue({key:`session:${e.id}`,kind:`session`,session:e})},e.id)),c||l?(0,$.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2 py-1 pr-3 pl-8`,children:[c?(0,$.jsx)(X,{variant:`ghost`,size:`xs`,disabled:s?.loadingMore===!0,onClick:()=>dt(e),className:`text-muted-foreground/70 hover:text-foreground`,children:t(`sessions.sidebar.group.showMore`)}):null,l?(0,$.jsx)(X,{variant:`ghost`,size:`xs`,onClick:()=>mt(e.key),className:`text-muted-foreground/70 hover:text-foreground`,children:t(`sessions.sidebar.group.showFewer`)}):null]}):null]}):null]},e.key)},gt=Q.useCallback(()=>(0,$.jsxs)(`div`,{className:`shrink-0`,children:[(0,$.jsx)(ar,{controller:y,ariaLabel:t(`mobile.sessions.sheet.resizeAria`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-4 pb-2`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground`,children:t(`mobile.sessions.sheet.title`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(du,{count:R}),(0,$.jsx)(fu,{count:z}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,onClick:rt,"aria-label":t(`mobile.sessions.newChat`),className:`text-[var(--surface-mutedForeground)]`,style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`add`,className:`h-5 w-5`})}),De&&Pe?(0,$.jsx)(X,{variant:`ghost`,size:`icon`,onClick:at,"aria-label":t(`sessions.sidebar.project.actions.newWorktree`),title:t(`sessions.sidebar.project.actions.newWorktree`),className:`text-[var(--surface-mutedForeground)]`,style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`node-tree`,className:`size-4`})}):null,(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ve,"aria-label":t(`mobile.surface.closeAria`),className:`text-[var(--surface-mutedForeground)]`,style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`close`,className:`h-5 w-5`})})]})]}),(b.length>1||je)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 overflow-x-auto px-4 py-2.5 scrollbar-none`,style:{scrollbarWidth:`none`,msOverflowStyle:`none`},children:[(0,$.jsx)(gu,{label:t(`chat.modelControls.modeValue.all`),isActive:ke===null,onClick:()=>Ae(null)}),je?(0,$.jsx)(gu,{label:t(`sessions.sidebar.session.actions.pinned`),leadingIcon:(0,$.jsx)(Z,{name:`pushpin-2-fill`,className:`size-3.5`}),isActive:ke===Wl,onClick:()=>Ae(Wl)}):null,b.map(e=>(0,$.jsx)(gu,{label:Le(e),icon:e.icon,project:{id:e.id,iconImage:e.iconImage??null},iconOptions:{themeVariant:r.metadata.variant,iconColor:r.colors.surface.foreground},iconBackground:e.iconBackground??null,colorVar:e.color?ri[e.color]??null:null,isActive:ke===e.id,status:V(e.path),onClick:()=>Ae(e.id)},e.id))]})]}),[t,R,z,b,je,ke,Ae,Le,r,V,rt,at,Ve,De,Pe,y]),_t=q?.kind===`project`?Le(q.project):q?.kind===`worktree`?q.worktree.branch||q.worktree.label||xe(q.worktree.path):q?.kind===`session`?te(q.session):``,vt=Q.useMemo(()=>{if(!ge)return null;let e=b.find(e=>e.id===ge);if(!e)return null;let t=Yl(e.path),n=Dt(D[e.id],E.get(t)??[]),r=q?.kind===`project`&&q.project.id===e.id?q.isGitRepository:n.length>0||!!ie.get(e.id);return{id:e.id,label:Le(e),path:t||e.path,icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:r,worktrees:n}},[q,E,ge,Le,b,ie,D]),xt=Q.useMemo(()=>{if(!q)return[];if(q.kind===`project`){let e=q.project;return jl({gitRepository:q.isGitRepository,onNewSession:()=>ot(e,e.path),onNewWorktree:()=>{let t=e.id;He(),Ve(),S(t),ce(t),K(!0)},onSyncSessions:()=>lt(q),onEditProject:()=>{He(),_e(e.id)},onCloseProject:()=>{He(),Se(e)}})}if(q.kind===`worktree`){let{project:e,worktree:t}=q;return Ml({onNewSession:()=>ot(e,t.path),onDeleteWorktree:()=>{He(),we({project:e,worktree:t})}})}let e=q.session,t=!!e.share?.url;return Al({pinned:w.has(e.id),shared:t,onRename:()=>{He(),et(e)},onTogglePin:()=>{He(),T(e.id)},onShare:t?void 0:()=>{He(),qe(e)},onCopyLink:t?()=>{let t=e.share?.url;He(),t&&Je(t)}:void 0,onUnshare:t?()=>{He(),Ye(e.id)}:void 0,onArchive:()=>{He(),Xe(e.id)},onDelete:()=>{He(),$e(e)}})},[q,et,He,Ve,Xe,Je,$e,qe,Ye,w,S,ot,lt,T]),Ct=xt.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,"data-mobile-session-action-sheet":q?.kind??`none`,children:xt.map(e=>{let n=(0,$.jsx)(eu,{icon:e.icon,label:Nl(e,t),destructive:e.destructive,onClick:e.onClick},e.id);return e.separated?(0,$.jsx)(`div`,{className:`mt-3 border-t border-[var(--surface-subtle)] pt-3`,children:n},e.id):n})}):null;return i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ur,{id:fr,open:_,onOpenChange:v,keepMounted:!0,presentation:`sheet`,edge:`bottom`,dismissGesture:{reservedTargetSelector:`[data-mobile-sheet-snap-handle]`},ariaLabel:t(`mobile.sessions.sheet.title`),surfaceClassName:y.snapPoint===.98?`h-[98dvh] max-h-[98dvh]`:`h-[72dvh] max-h-[98dvh]`,surfaceElementRef:y.surfaceRef,onExitComplete:I,onPreviewChange:F,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[gt(),(0,$.jsx)(Yr,{useScrollShadow:!0,disableHorizontal:!0,preventOverscroll:!0,outerClassName:`min-h-0 max-h-full flex-1`,className:`px-2 py-2 pwa-overlay-scroll`,children:(0,$.jsx)(`div`,{className:`flex min-h-full flex-col gap-0.5`,children:Ne?(0,$.jsxs)($.Fragment,{children:[ze.map(ht),ze.every(e=>e.sessions.length===0)?(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-8 text-[13px] text-[var(--surface-mutedForeground)]`,children:(0,$.jsx)(`span`,{children:t(`chat.mobileStatus.noSessionsInProject`)})}):null]}):Re.length===0?(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-10 text-[13px] text-[var(--surface-mutedForeground)]`,children:(0,$.jsx)(`span`,{children:t(`chat.mobileStatus.noSessionsInProject`)})}):Re.map(e=>(0,$.jsx)(hu,{session:e,isCurrent:e.id===o,isPinned:w.has(e.id),contextLabel:Be(e),getSessionTitle:te,onClick:()=>Ge(`session:${e.id}`,()=>Ke(e)),onRename:()=>et(e),onTogglePinned:()=>T(e.id),onShare:()=>{qe(e)},onCopyShareUrl:e=>{Je(e)},onUnshare:()=>{Ye(e.id)},onArchive:()=>{Xe(e.id)},onDelete:()=>$e(e),needsAttention:B,longPressHandlers:Ue({key:`session:${e.id}`,kind:`session`,session:e})},e.id))})})]})}),(0,$.jsx)(Mn,{open:!!q,title:_t,onClose:He,className:`select-none`,contentMaxHeightClassName:`max-h-[min(68dvh,560px)]`,children:Ct}),(0,$.jsx)(Mn,{open:!!fe,title:t(`sessions.sidebar.session.menu.rename`),onClose:()=>{pe(null),he(``)},footer:(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`default`,className:`flex-1`,onClick:()=>{pe(null),he(``)},children:t(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(X,{type:`button`,variant:`default`,className:`flex-1`,disabled:!me.trim(),onClick:()=>void tt(),children:t(`sessions.sidebar.session.rename.save`)})]}),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-3 px-1 py-1`,onSubmit:e=>{e.preventDefault(),tt()},children:[(0,$.jsx)(Dn,{value:me,onChange:e=>he(e.target.value),autoFocus:!0,className:`h-12`}),(0,$.jsxs)(X,{type:`button`,variant:`outline`,className:`w-full gap-2`,onClick:()=>void nt(),children:[(0,$.jsx)(Z,{name:`ai-generate-2`,className:`size-4`}),t(`sessions.sidebar.session.rename.smartTitle`)]})]})}),(0,$.jsx)(Mn,{open:!!ve,title:t(`sessions.sidebar.project.actions.closeProject`),onClose:()=>Se(null),closeAriaLabel:t(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>Se(null),children:t(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(X,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!ve)return;let e=ve;Se(null),C(e.id),yt.success(t(`mobile.sessions.toast.projectRemoved`,{label:Le(e)}))},children:t(`mobile.sessions.confirmRemoveProject`)})]}),children:(0,$.jsx)(`p`,{className:`px-1 py-1 typography-ui-label text-foreground`,children:t(`mobile.projects.closeConfirmMessage`,{title:ve?Le(ve):``})})}),(0,$.jsx)(an,{open:G,projectId:se,onOpenChange:e=>{K(e),e||ce(null)},onWorktreeCreated:(e,t)=>{K(!1),v(!1),t?.sessionId?ae()?l(t.sessionId,e):St.getState().openSession({sessionId:t.sessionId,directory:e}):se&&d({selectedProjectId:se,directoryOverride:e,preserveDirectoryOverride:!0})}}),Ce?(0,$.jsx)(Sl,{open:!0,project:{id:Ce.project.id,path:Ce.project.path},worktree:Ce.worktree,onClose:()=>we(null),onDeleted:()=>{let e=Yl(Ce.project.path),t=Yl(Ce.worktree.path);bt.setState(n=>{let r=new Map(n.availableWorktreesByProject);return r.set(e,(r.get(e)??[]).filter(e=>Yl(e.path)!==t)),{availableWorktreesByProject:r,availableWorktrees:Array.from(r.values()).flat()}}),we(null)}}):null,(0,$.jsx)(Tl,{open:ge!==null,project:vt,onClose:()=>_e(null)})]}):null},vu=e=>ee(`gui-plugins.disabled`,e);function yu(e,t){let n=e.getItem(t);if(n===null)return[];let r=JSON.parse(n);if(!Array.isArray(r)||!r.every(e=>typeof e==`string`))throw Error(`Invalid GUI plugin enable-state`);return[...new Set(r)]}function bu(e,t,n,r){let i=new Set(yu(e,t));r?i.delete(n):i.add(n);let a=[...i];return e.setItem(t,JSON.stringify(a)),a}function xu(e){return new Promise((t,n)=>{let r=0,i,a=()=>{cancelAnimationFrame(r),i!==void 0&&window.clearTimeout(i),e.removeEventListener(`abort`,o)},o=()=>{a(),n(e.reason??new DOMException(`Aborted`,`AbortError`))},s=()=>{a(),t()};if(e.aborted){o();return}e.addEventListener(`abort`,o,{once:!0}),r=requestAnimationFrame(()=>{r=requestAnimationFrame(()=>{i=window.setTimeout(s,0)})})})}function Su(){let e=Promise.resolve();return(t,n)=>{let r=e.then(async()=>{await xu(t),t.throwIfAborted(),n()});return e=r.catch(()=>{}),r}}var Cu=()=>Gi,wu=()=>()=>{};function Tu(e){let t=(0,qi.c)(19),{host:n,children:r}=e,i=n?.appearanceCatalog,a=Q.useSyncExternalStore(i?.subscribe??wu,i?.getSnapshot??Cu,Cu),o=Q.useContext(Rt),s=o?.registerPluginThemes,c=o?.currentTheme.metadata.variant??`dark`,l,u;t[0]!==s||t[1]!==a.themes?(l=()=>s?.(a.themes),u=[s,a.themes],t[0]=s,t[1]=a.themes,t[2]=l,t[3]=u):(l=t[2],u=t[3]),Q.useEffect(l,u);let d;t[4]!==c||t[5]!==a.branding?(d=a.branding.find(ku)?.logo?.[c],t[4]=c,t[5]=a.branding,t[6]=d):d=t[6];let f=d,p;t[7]===a.branding?p=t[8]:(p=a.branding.find(Ou),t[7]=a.branding,t[8]=p);let m=p,h=m?.dockIcon?.[c],g,_;t[9]!==m||t[10]!==h||t[11]!==n?(g=()=>{if(!(!n||!m||!h))return n.setDockIcon(m.pluginId,h).catch(Du),()=>{n.setDockIcon(m.pluginId,null).catch(Eu)}},_=[n,m,h],t[9]=m,t[10]=h,t[11]=n,t[12]=g,t[13]=_):(g=t[12],_=t[13]),Q.useEffect(g,_);let v;t[14]===f?v=t[15]:(v={logo:f},t[14]=f,t[15]=v);let y=v,b;return t[16]!==r||t[17]!==y?(b=(0,$.jsx)(qn.Provider,{value:y,children:r}),t[16]=r,t[17]=y,t[18]=b):b=t[18],b}function Eu(){}function Du(){}function Ou(e){return e.native&&e.dockIcon}function ku(e){return e.logo}var Au=()=>{},ju=()=>Au,Mu=e=>e?e instanceof Error?e.message:String(e):null,Nu=Q.lazy(()=>U(()=>import(`./GuiPluginSurface-BqFdg497.js`).then(e=>({default:e.GuiPluginSurface})),__vite__mapDeps([69,1,8,14,19,5,3,4,6,20,10,11,12,21,22,23,24,50,44,70,71,33,34,35,36,2,37,38,39,13,9,15,16,17,18,40,41,32,42,43,45,46,47,48,72,26,25,27,51,52,53])));function Pu({host:e,id:t,transport:r,report:i,schedule:a}){let o=I(),s=z(qe(r,t)),[c,l]=Q.useState({loading:!1,error:null});return Q.useEffect(()=>{let i=!1,c=new AbortController,u=(i,o)=>a(c.signal,()=>{if(n()!==r){o?.dispose();return}o?e.install(t,i,o):e.install(t,i)}).catch(e=>{throw o?.dispose(),e}),d=h(),f=m();if(s.data&&!d&&e.getSnapshot().plugins.some(e=>e.id===t&&e.status===`active`&&e.revision===s.data.revision)){l({loading:!1,error:null});return}if(!s.data||!d&&!f){if(!s.data){l({loading:!1,error:null});return}return l({loading:!0,error:null}),u(s.data).then(()=>{i||l({loading:!1,error:null})}).catch(e=>{i||l({loading:!1,error:Mu(e)})}),()=>{i=!0,c.abort()}}l({loading:!0,error:null});let p=async()=>{f&&await Ui(f,`window-only`,{}),!(i||n()!==r)&&(await u(s.data),i||l({loading:!1,error:null}))};return U(async()=>{let{NativeGuiSession:e}=await import(`./native-DsqzO52u.js`);return{NativeGuiSession:e}},__vite__mapDeps([73,38,1,39,74,75])).then(async({NativeGuiSession:e})=>{if(i)return;if(!d){await p();return}let a=await Ui(d,`acquire`,{id:t,revision:s.data.revision});if(a===null){if(i||n()!==r)return;l({loading:!1,error:null}),await o.invalidateQueries({queryKey:Xe(r).queryKey,exact:!0});return}let c=new e(d,a);if(i||n()!==r){c.dispose();return}await u(a.bundle,c),i||l({loading:!1,error:null})}).catch(async e=>{if(!i){if(e instanceof Wi&&[`GUI_PLUGIN_UNTRUSTED_SOURCE`,`GUI_PLUGIN_DOCUMENT_RESTRICTED`,`GUI_PLUGIN_FORBIDDEN`].includes(e.code))try{await p();return}catch(t){e=t}i||l({loading:!1,error:Mu(e)})}}),()=>{i=!0,c.abort()}},[e,t,r,s.data,s.dataUpdatedAt,o,a]),Q.useEffect(()=>{i(e,t,{loading:c.loading||s.isPending,error:c.error??Mu(s.error)})},[e,t,c,s.error,s.isPending,i]),Q.useEffect(()=>()=>{e.uninstall(t),i(e,t,null)},[e,t,i]),null}function Fu({children:e,ready:r=!0}){let{files:i,viewExport:o}=ne(),s=I(),c=Q.useSyncExternalStore(t,n,n),l=vu(a()),[u,d]=Q.useState(null),f=u===c;Q.useEffect(()=>{if(!r||f)return;let e=new AbortController;return xu(e.signal).then(()=>{!e.signal.aborted&&n()===c&&d(c)}).catch(()=>{}),()=>{e.abort()}},[r,c,f]);let p=z({...Xe(c),enabled:f}),m=Q.useMemo(()=>({transport:c,run:Su()}),[c]),[h,g]=Q.useState(null),_=h?.key===l?h.disabled:null,v=h?.key===l?h.error:null,[y,b]=Q.useState({transport:c,requested:!1}),x=y.transport===c&&y.requested,S=J(()=>b(e=>e.transport===c&&e.requested?e:{transport:c,requested:!0})),[C,w]=Q.useState(null);y.transport!==c&&(b({transport:c,requested:!1}),w(null));let T=C?.transport===c?C.error:null,[E,D]=Q.useState(0),[O,k]=Q.useState(null),[A,M]=Q.useState(null),N=A?.transport===c?A.host:null,{locale:ee}=be(),P=Q.useContext(Rt)?.currentTheme.metadata.variant??`dark`,F=j(e=>e.isMobile),L=bt(e=>e.currentSessionId),R=He(L)?.directory,te=Q.useRef({locale:ee,mode:P,narrow:F});Q.useLayoutEffect(()=>{te.current={locale:ee,mode:P,narrow:F}},[ee,P,F]);let B=J(()=>{try{g({key:l,disabled:yu(window.localStorage,l),error:null})}catch(e){g({key:l,disabled:null,error:Mu(e)})}});Q.useEffect(()=>{B()},[l,B]),he(`storage`,e=>{(e.key===l||e.key===null)&&B()});let V=J((e,t)=>{try{g({key:l,disabled:bu(window.localStorage,l,e,t),error:null})}catch(e){g({key:l,disabled:_,error:Mu(e)})}}),H=J((e,t,n)=>{e===N&&k(r=>{let i=r?.host===e?r.states:{};if(i[t]?.loading===n?.loading&&i[t]?.error===n?.error)return r;let a={...i};return n?a[t]=n:delete a[t],{host:e,states:a}})}),re=Q.useMemo(()=>(p.data??[]).flatMap(e=>{if(!e.id||!e.features.gui)return[];let t=e.state.status===`failed`?e.state.error:O?.host===N?O.states[e.id]?.error:null;return[{id:e.id,source:e.source,enabled:_!==null&&!_.includes(e.id),...t?{error:t}:{}}]}),[p.data,_,O,N]),W=_!==null&&re.some(e=>e.enabled),ie=_!==null&&re.length>0,ae=Q.useMemo(()=>new Set((p.data??[]).filter(e=>e.state.status===`active`).map(e=>e.id)),[p.data]),oe=f&&x&&ie&&(W||N!==null);Q.useEffect(()=>{if(!f||x||!W||!re.some(e=>e.enabled&&ae.has(e.id)))return;let e=!1,t=()=>{!e&&n()===c&&S()};if(typeof window.requestIdleCallback==`function`){let n=window.requestIdleCallback(t,{timeout:2e3});return()=>{e=!0,window.cancelIdleCallback(n)}}let r=window.setTimeout(t,1e3);return()=>{e=!0,window.clearTimeout(r)}},[f,x,W,re,ae,c,S]),Q.useEffect(()=>{if(!oe)return;let e=new AbortController,t;return w(null),xu(e.signal).then(()=>Promise.all([U(()=>import(`./host-D776RHTx.js`),__vite__mapDeps([76,38,1,39,16,41,4,3,8,14,32,15,2,43,21,17,18,44,5,6,74,77,78,79,80,81,75])),U(()=>import(`./gui-CJjEj3l4.js`),__vite__mapDeps([82,4,3,1,2,38,39,42,12])),U(()=>import(`./fileReferenceActions-CvDFcgBH.js`).then(e=>e.r),__vite__mapDeps([83,1,4,3,2,5,6,13,10,8,11,12,43,84,80]))])).then(([{GuiPluginHost:r},{createGuiClient:a},{openFileReference:l}])=>{e.signal.aborted||n()!==c||(t=new r({client:a(e.signal),files:i,queryClient:s,transport:c,viewExport:o,toast:me,storage:window.localStorage,...te.current,focusFile:async(t,n)=>{e.signal.aborted||await l(t,!1,{effectiveDirectory:n})},openPage:t=>!e.signal.aborted&&n()===c&&!j.getState().isMobile&&j.getState().openGuiPage(t)}),M({transport:c,host:t}))}).catch(t=>{e.signal.aborted||w({transport:c,error:Mu(t)})}),()=>{e.abort(),t?.dispose(),M(e=>e?.host===t?null:e),k(e=>e?.host===t?null:e)}},[oe,i,s,c,E,o]),Q.useLayoutEffect(()=>{N?.setSession(L&&R?{id:L,directory:R}:void 0)},[N,L,R]),Q.useLayoutEffect(()=>{N?.appearanceCatalog.setOrder((p.data??[]).flatMap(e=>e.id?[e.id]:[]))},[N,p.data]),Q.useLayoutEffect(()=>{F&&j.getState().activeMainTab===`plugin`&&j.getState().closeGuiPage(),N?.setAppearance({locale:ee,mode:P,narrow:F})},[N,ee,P,F]),Q.useLayoutEffect(()=>{let e=()=>{let e=j.getState();N?.setPage(e.activeMainTab===`plugin`?e.activeGuiPage??void 0:void 0)};return e(),j.subscribe((t,n)=>{(t.activeMainTab!==n.activeMainTab||t.activeGuiPage!==n.activeGuiPage)&&e()})},[N]);let G=Q.useMemo(()=>N?e=>N.subscribe(e):ju,[N]),K=Q.useMemo(()=>N?()=>N.getSnapshot():kr,[N]),se=Q.useSyncExternalStore(G,K,kr),ce=J(()=>{B(),x&&T&&(w(null),D(e=>e+1)),s.invalidateQueries({queryKey:Xe(c).queryKey,exact:!0}).then(()=>{if(x)return Ve(s,c,!0,()=>n()===c)})}),q=x&&W&&!T&&(!N||re.some(e=>e.enabled&&ae.has(e.id)&&(O?.host!==N||(O.states[e.id]?.loading??!0)))),le={host:N,snapshot:se,inventory:re,error:v??T??Mu(p.error),loading:p.isPending||_===null&&!v||q,requested:x,requestLoad:S,setEnabled:V,refresh:ce};return(0,$.jsx)(Or.Provider,{value:le,children:(0,$.jsx)(Ar.Provider,{value:N?.fileIcons??null,children:(0,$.jsxs)(Tu,{host:N,children:[e,N&&re.filter(e=>e.enabled&&ae.has(e.id)).map(e=>(0,$.jsx)(Pu,{host:N,id:e.id,transport:c,report:H,schedule:m.run},e.id)),N&&(0,$.jsx)(Bn,{fallback:(0,$.jsx)($.Fragment,{}),children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Nu,{})})},`surface:${c}`)]})})})}var Iu=3e4;function Lu(){return typeof window>`u`?!1:window.__VSCODE_CONFIG__!==void 0}function Ru(){let e=Q.useMemo(()=>Lu(),[]),n=Q.useMemo(()=>Qn(),[]),r=Q.useRef(!1),a=Q.useRef(!1),o=Q.useRef(new Set),[s,c]=Q.useState(()=>Zn()),l=bt(e=>e.setCurrentSession),u=bt(e=>e.currentSessionId),d=bt(e=>e.currentSessionDirectory),f=j(e=>e.setActiveMainTab),p=j(e=>e.setSettingsDialogOpen),m=j(e=>e.setSettingsPage),h=j(e=>e.navigateToDiff),g=Ze(e=>e.hasLoaded),_=Ze(e=>e.activeSessions),v=Ze(e=>e.archivedSessions),y=Q.useCallback(t=>{if(!e&&Zn().sessionId===t){o.current.has(t)||(o.current.add(t),et(t,`missing-directory`)),a.current=!0;try{p(!1),f(`chat`),er({sessionId:t,tab:`chat`,isSettingsOpen:!1,settingsPath:`home`,diffFile:null},{replace:!0,force:!0}),c(Zn())}finally{a.current=!1}}},[e,f,c,p]),b=Q.useCallback(async e=>{if(!a.current){a.current=!0;try{if(e.settingsPath){m(rr(e.settingsPath)),p(!0);return}if(j.getState().isSettingsDialogOpen&&p(!1),e.tab===`plugin`&&e.guiPageKey){j.getState().isMobile?f(`chat`):j.getState().openGuiPage(e.guiPageKey);return}if(e.tab===`schedule`||e.tab===`assistant`){f(e.tab),e.tab===`assistant`&&e.assistantId&&Mt.getState().selectAssistant(e.assistantId);return}if(e.isNewSession){f(`chat`),bt.getState().newSessionDraft.open||bt.getState().openNewSessionDraft();return}if(e.sessionId){let t=e.sessionId,n=hr(t);if(!n){a.current=!1;let e=await gr(t);a.current=!0,n=e?.directory??null}let r=bt.getState();n&&(t!==r.currentSessionId||n!==r.currentSessionDirectory)&&l(t,n)}e.tab?f(e.tab):e.sessionId&&f(`chat`),e.diffFile&&(e.tab===`diff`||!e.tab)&&h(e.diffFile)}finally{a.current=!1}}},[l,f,p,m,h]),x=Q.useCallback(()=>{let e=bt.getState(),t=j.getState(),n=Zn(),r=t.activeMainTab,i=r===`schedule`||r===`assistant`||r===`plugin`,a=!i&&!!e.newSessionDraft?.open&&!e.currentSessionId,o=i&&r===`assistant`?Nt():null;return{isNewSession:a,guiPageKey:r===`plugin`?t.activeGuiPage:null,sessionId:i||a?null:e.currentSessionId??n.sessionId,tab:a?`chat`:i?r:t.activeMainTab||n.tab||`chat`,isSettingsOpen:t.isSettingsDialogOpen,settingsPath:t.settingsPage,settingsEntityId:n.settingsEntityId,diffFile:i||a?null:t.pendingDiffFile??n.diffFile,diffScope:i||a?null:n.diffScope,scheduleView:i&&r===`schedule`?n.scheduleView:null,scheduleProjectId:i&&r===`schedule`?n.scheduleProjectId:null,scheduleTaskId:i&&r===`schedule`?n.scheduleTaskId:null,assistantId:o,focusSessionId:i&&n.tab===r&&(r!==`assistant`||n.assistantId===o)?n.focusSessionId:null}},[]),S=Q.useCallback((t={})=>{if(e||n||a.current)return;let r=x();er(r,t),c(Zn())},[e,n,x]);Q.useEffect(()=>{if(r.current||(r.current=!0,!$n()))return;let t=Zn();(async()=>{await b(t),!e&&!n&&er({...x(),isNewSession:t.isNewSession||x().isNewSession,sessionId:t.isNewSession?null:t.sessionId??bt.getState().currentSessionId??x().sessionId,tab:t.tab===`plugin`&&j.getState().isMobile?`chat`:t.tab??j.getState().activeMainTab,settingsPath:t.settingsPath??j.getState().settingsPage,diffFile:t.isNewSession?null:t.diffFile??j.getState().pendingDiffFile},{replace:!0,force:!0})})()},[b,x,e,n]),Q.useEffect(()=>{if(!s.sessionId||s.isNewSession)return;let e=!1,t=s.sessionId;if(Zn().sessionId!==t||u===t&&d||o.current.has(t))return;let n=hr(t);if(n){o.current.delete(t),l(t,n);return}return(async()=>{let n=await gr(t);if(!e&&Zn().sessionId===t){if(n?.directory){o.current.delete(t);let e=bt.getState();(e.currentSessionId!==t||e.currentSessionDirectory!==n.directory)&&l(t,n.directory);return}Ze.getState().hasLoaded&&y(t)}})(),()=>{e=!0}},[_,v,d,u,y,g,s.isNewSession,s.sessionId,l]),Q.useEffect(()=>{let t=u===s.sessionId&&!!d;if(!s.sessionId||s.isNewSession||e||t)return;let n=s.sessionId,r=setTimeout(()=>{let e=bt.getState(),t=e.currentSessionId===n&&!!e.currentSessionDirectory;Zn().sessionId===n&&!t&&y(n)},Iu);return()=>clearTimeout(r)},[d,u,y,e,s.sessionId]),Q.useEffect(()=>{if(e||n)return;let t=bt.getState().currentSessionId,r=!!bt.getState().newSessionDraft?.open;return bt.subscribe(e=>{let n=e.currentSessionId,i=!!e.newSessionDraft?.open;n===t&&i===r||a.current||(t=n,r=i,S(),c(Zn()))})},[e,n,S]),Q.useEffect(()=>{if(e||n)return;let t=j.getState().activeMainTab,r=j.getState().isSettingsDialogOpen,i=j.getState().settingsPage,o=j.getState().pendingDiffFile,s=j.getState().activeGuiPage;return j.subscribe(e=>{if(a.current)return;let n=e.activeMainTab!==t,c=e.activeGuiPage!==s&&e.activeMainTab===`plugin`,l=e.isSettingsDialogOpen!==r,u=e.settingsPage!==i,d=e.pendingDiffFile!==o&&e.activeMainTab===`diff`;t=e.activeMainTab,s=e.activeGuiPage,r=e.isSettingsDialogOpen,i=e.settingsPage,o=e.pendingDiffFile,(n||c||l||u||d)&&S()})},[e,n,S]),Q.useEffect(()=>{if(e||n)return;let t=Nt();return Mt.subscribe(()=>{let e=Nt(),n=e!==t;t=e,!(!n||a.current||j.getState().activeMainTab!==`assistant`)&&S()})},[e,n,S]),Q.useEffect(()=>{if(typeof window>`u`||e||n)return;let t=()=>{let e=Zn();if(c(e),$n())b(e);else{let e=j.getState();e.isSettingsDialogOpen&&p(!1),e.activeMainTab!==`chat`&&f(`chat`)}};return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t)}},[b,e,n,f,p]),Q.useEffect(()=>{if(!(e||n))return t(e=>{i(e)&&(o.current.clear(),queueMicrotask(()=>{c(Zn())}))})},[e,n])}var zu=(e,t)=>{if(!t||t.length<2)return e;let n=t.map(e=>e.name).filter(Boolean).sort((e,t)=>t.length-e.length);return e.map(([e,t])=>{let r=n.find(t=>e.startsWith(`${t} · `));return r?[e,{...t,accountName:r}]:[e,t]})},Bu=(e,t)=>{let n=e[t]?.accountName;return!n||t>0&&e[t-1].accountName===n?null:new Set(e.map(e=>e.accountName).filter(Boolean)).size>1?n:null},Vu=(e,t)=>Bu(e.map(([,e])=>e),t),Hu=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``)||`/`,Uu=(e,t)=>{let n=new Set;for(let r of e){if(!r.trim())continue;let e=Hu(r);n.add(e);for(let[r,i]of t)if(Hu(r)===e)for(let e of i)e.path.trim()&&n.add(Hu(e.path))}return[...n]},Wu=(e,t,n)=>{let r=Uu(e,t),i=n?.currentDirectory?.trim()??``;if(!i)return{directories:r};let a=Hu(i),o=null;for(let t of e){if(!t.trim())continue;let e=Hu(t);(a===e||a.startsWith(`${e}/`))&&(!o||e.length>o.length)&&(o=e)}for(let[e,n]of t){let t=Hu(e);for(let e of n){if(!e.path.trim())continue;let n=Hu(e.path);(a===n||a.startsWith(`${n}/`))&&(!o||t.length>o.length)&&(o=t)}}if(!o)return r.includes(a)?{directories:r,priorityDirectories:[a]}:{directories:r};let s=new Set([o]);for(let[e,n]of t)if(Hu(e)===o)for(let e of n)e.path.trim()&&s.add(Hu(e.path));r.includes(a)&&s.add(a);let c=r.filter(e=>s.has(e));return c.length===0||c.length>=r.length?{directories:r}:{directories:r,priorityDirectories:c}},Gu=async(e,t=at,n)=>{try{await t(e,n)}catch(e){console.warn(`[SessionStartup] Initial session index sync failed:`,e)}finally{Je()}},Ku=async(e,t,n=at,r=tt)=>{r().catch(e=>{console.warn(`[SessionStartup] Early session index hydrate failed:`,e)}),await e;let i=t();await Gu(i.directories,n,{priorityDirectories:i.priorityDirectories})},qu=()=>{let e=(0,qi.c)(2),t=Q.useRef(!1),n,r;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>{if(t.current)return;t.current=!0;let e=Zt(a());Ku(e,Yu),Promise.resolve(e).then(Qu)},r=[],e[0]=n,e[1]=r):(n=e[0],r=e[1]),Q.useLayoutEffect(n,r),null};function Ju(e){return e.path}function Yu(){return Wu(ct.getState().projects.map(Ju),bt.getState().availableWorktreesByProject,{currentDirectory:D.getState().currentDirectory})}function Xu(e){return e.path}function Zu(e){console.warn(`[SessionStartup] Batch git discovery failed (fallback to per-directory):`,e)}function Qu(){let e=ct.getState().projects.map(Xu);e.length!==0&&Jt(e).catch(Zu)}var $u=()=>{let e=(0,qi.c)(13),[t,n]=(0,Q.useState)(!1),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{n(y())},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Q.useEffect)(r,i);let a;e[2]===t?a=e[3]:(a=async e=>t?await u(e):{success:!0,path:e},e[2]=t,e[3]=a);let o=a,s;e[4]===t?s=e[5]:(s=async e=>t?await f(e):{success:!0},e[4]=t,e[5]=s);let c=s,d;e[6]===t?d=e[7]:(d=async e=>t?await l(e):{success:!0},e[6]=t,e[7]=d);let p=d,m;return e[8]!==t||e[9]!==o||e[10]!==c||e[11]!==p?(m={isDesktop:t,requestAccess:o,startAccessing:c,stopAccessing:p},e[8]=t,e[9]=o,e[10]=c,e[11]=p,e[12]=m):m=e[12],m},ed=e=>e.trim().replace(/\s+/g,`-`).replace(/[^A-Za-z0-9._/-]/g,`-`).replace(/-+/g,`-`).replace(/\/{2,}/g,`/`).replace(/\/-+/g,`/`).replace(/-+\//g,`/`).replace(/^[-/]+/,``).replace(/[-/]+$/,``),td=({currentBranch:e,onRename:t,showEditButton:n=!0,iconOnly:r=!1})=>{let{t:i}=be(),[a,o]=Q.useState(!1),[s,c]=Q.useState(e||``),[l,u]=Q.useState(!1),d=Q.useRef(null),f=()=>{!e||!t||(c(e),o(!0),setTimeout(()=>d.current?.focus(),0))},p=async()=>{if(!e||!t||!s.trim())return;let n=ed(s);if(n===e){o(!1);return}u(!0);try{await t(e,n),o(!1),c(``)}finally{u(!1)}},m=()=>{o(!1),c(``)},h=e=>{e.key===`Enter`?(e.preventDefault(),p()):e.key===`Escape`&&(e.preventDefault(),m())};if(a)return(0,$.jsx)(`div`,{className:`flex h-6 items-center gap-1.5 rounded-md bg-primary/12 px-1.5`,children:(0,$.jsxs)(`form`,{className:`flex w-full items-center gap-1.5`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,$.jsx)(Z,{name:`git-branch`,className:`size-3.5 text-primary`}),(0,$.jsx)(`input`,{ref:d,value:s,onChange:e=>c(e.target.value),className:`flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground`,placeholder:i(`gitView.branch.namePlaceholder`),onKeyDown:h,autoFocus:!0}),(0,$.jsx)(`button`,{type:`submit`,disabled:l,"aria-label":i(l?`gitView.branch.renameSaving`:`gitView.branch.renameSave`),title:i(l?`gitView.branch.renameSaving`:`gitView.branch.renameSave`),className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:l?(0,$.jsx)(Z,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,$.jsx)(Z,{name:`check`,className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`button`,onClick:m,disabled:l,"aria-label":i(`gitView.branch.renameCancel`),title:i(`gitView.branch.renameCancel`),className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:(0,$.jsx)(Z,{name:`close`,className:`size-3.5`})})]})});let g=e||i(`gitView.branch.detachedHead`);return r?(0,$.jsxs)(An,{children:[(0,$.jsx)(On,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50`,onClick:f,disabled:!e||!t,"aria-label":g,children:(0,$.jsx)(Z,{name:`git-branch`,className:`size-3.5`})})}),(0,$.jsx)(kn,{sideOffset:8,children:g})]}):(0,$.jsxs)(`div`,{className:`flex h-6 w-full min-w-0 items-center gap-1 px-0`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`size-3.5 text-primary shrink-0`}),(0,$.jsxs)(`div`,{className:`inline-flex min-w-0 max-w-full items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:g}),n&&t&&e&&(0,$.jsx)(X,{variant:`ghost`,size:`xs`,className:`size-6 p-0 shrink-0`,onClick:f,title:i(`gitView.branch.renameTitle`),children:(0,$.jsx)(Z,{name:`edit`,className:`size-3.5`})})]})]})},nd=e=>{let t=(0,qi.c)(38),{syncAction:n,remotes:r,onSync:i,disabled:a,aheadCount:o,behindCount:s,trackingRemoteName:c,hasUncommittedChanges:l}=e,u;t[0]===r?u=t[1]:(u=r===void 0?[]:r,t[0]=r,t[1]=u);let d=u,f=o===void 0?0:o,p=s===void 0?0:s,m=l!==void 0&&l,{t:h}=be(),g;t[2]!==d||t[3]!==c?(g=d.find(e=>e.name===c)??d[0],t[2]=d,t[3]=c,t[4]=g):g=t[4];let _=g,v=p>0&&m,y=a||n!==null||!_||v,b=f>0||p>0,x;t[5]!==f||t[6]!==p||t[7]!==v||t[8]!==b||t[9]!==h||t[10]!==_?(x=v?h(`gitView.sync.commitOrStashTooltip`):_?b?h(`gitView.sync.syncChangesTooltip`,{ahead:f,behind:p}):h(`gitView.sync.syncChanges`):h(`gitView.sync.noRemoteTooltip`),t[5]=f,t[6]=p,t[7]=v,t[8]=b,t[9]=h,t[10]=_,t[11]=x):x=t[11];let S=x,C;t[12]!==i||t[13]!==_?(C=()=>{_&&i(_)},t[12]=i,t[13]=_,t[14]=C):C=t[14];let w=C,T=b?0:void 0,E;t[15]!==f||t[16]!==p||t[17]!==b||t[18]!==h?(E=b?h(`gitView.sync.syncChangesTooltip`,{ahead:f,behind:p}):h(`gitView.sync.syncChanges`),t[15]=f,t[16]=p,t[17]=b,t[18]=h,t[19]=E):E=t[19];let D;t[20]===n?D=t[21]:(D=n===`sync`?(0,$.jsx)(Z,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,$.jsx)(Z,{name:`refresh`,className:`size-3.5`}),t[20]=n,t[21]=D);let O;t[22]===b?O=t[23]:(O=b?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`absolute -right-0.5 top-0 size-1 rounded-full bg-[var(--status-error)] ring-1 ring-[var(--surface-background)]`}):null,t[22]=b,t[23]=O);let k;t[24]!==D||t[25]!==O?(k=(0,$.jsxs)(`span`,{className:`relative flex size-3.5 shrink-0`,children:[D,O]}),t[24]=D,t[25]=O,t[26]=k):k=t[26];let A;t[27]!==w||t[28]!==y||t[29]!==E||t[30]!==k?(A=(0,$.jsx)(On,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:w,disabled:y,className:`inline-flex h-6 w-fit shrink-0 items-center justify-center gap-1 rounded px-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":E,children:k})}),t[27]=w,t[28]=y,t[29]=E,t[30]=k,t[31]=A):A=t[31];let j;t[32]===S?j=t[33]:(j=(0,$.jsx)(kn,{side:`bottom`,sideOffset:8,children:S}),t[32]=S,t[33]=j);let M;return t[34]!==A||t[35]!==j||t[36]!==T?(M=(0,$.jsxs)(An,{delayDuration:T,children:[A,j]}),t[34]=A,t[35]=j,t[36]=T,t[37]=M):M=t[37],M},rd={branch:`git-branch`,briefcase:`briefcase`,house:`home`,graduation:`graduation-cap`,code:`code`,heart:`heart`,user:`user-3`},id={keyword:`var(--syntax-keyword)`,error:`var(--status-error)`,string:`var(--syntax-string)`,function:`var(--syntax-function)`,type:`var(--syntax-type)`,success:`var(--status-success)`,info:`var(--status-info)`,warning:`var(--status-warning)`};function ad(e){return e&&id[e]||`var(--primary)`}var od=e=>{let t=(0,qi.c)(36),{activeProfile:n,identities:r,onSelect:i,isApplying:a,iconOnly:o}=e,s=o!==void 0&&o,{t:c}=be(),l=rd[n?.icon??`branch`]??`user-3`,u=n?.color,d;t[0]===u?d=t[1]:(d=ad(u),t[0]=u,t[1]=d);let f;t[2]===d?f=t[3]:(f={color:d},t[2]=d,t[3]=f);let p=a||r.length===0,m=a?`loader-4`:l,h=a?`size-4 animate-spin`:`size-4`,g;t[4]!==m||t[5]!==h?(g=(0,$.jsx)(Z,{name:m,className:h}),t[4]=m,t[5]=h,t[6]=g):g=t[6];let _;t[7]!==n?.name||t[8]!==s||t[9]!==c?(_=s?null:(0,$.jsx)(`span`,{className:`git-identity-label min-w-0 flex-1 truncate text-left`,children:n?.name||c(`gitView.header.noIdentity`)}),t[7]=n?.name,t[8]=s,t[9]=c,t[10]=_):_=t[10];let v;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Z,{name:`arrow-down-s`,className:`size-4 opacity-60`}),t[11]=v):v=t[11];let y;t[12]!==f||t[13]!==p||t[14]!==g||t[15]!==_?(y=(0,$.jsx)(On,{asChild:!0,children:(0,$.jsx)(Hn,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-8 min-w-0 max-w-[15rem] justify-start gap-1.5 px-2 py-1 typography-ui-label`,style:f,disabled:p,children:[g,_,v]})})}),t[12]=f,t[13]=p,t[14]=g,t[15]=_,t[16]=y):y=t[16];let b;t[17]===c?b=t[18]:(b=c(`gitView.header.identityTooltip`),t[17]=c,t[18]=b);let x;t[19]===b?x=t[20]:(x=(0,$.jsx)(kn,{sideOffset:8,children:b}),t[19]=b,t[20]=x);let S;t[21]!==y||t[22]!==x?(S=(0,$.jsxs)(An,{children:[y,x]}),t[21]=y,t[22]=x,t[23]=S):S=t[23];let C;if(t[24]!==n?.id||t[25]!==r||t[26]!==i){let e;t[28]!==n?.id||t[29]!==i?(e=e=>(0,$.jsxs)(Fn,{onSelect:()=>i(e),children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e.name}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e.userEmail})]}),n?.id===e.id?(0,$.jsx)(Z,{name:`check`,className:`ml-auto size-4 text-foreground`}):null]},e.id),t[28]=n?.id,t[29]=i,t[30]=e):e=t[30],C=r.map(e),t[24]=n?.id,t[25]=r,t[26]=i,t[27]=C}else C=t[27];let w;t[31]===C?w=t[32]:(w=(0,$.jsx)(Nn,{align:`end`,className:`w-64`,children:C}),t[31]=C,t[32]=w);let T;return t[33]!==S||t[34]!==w?(T=(0,$.jsxs)(Pn,{children:[S,w]}),t[33]=S,t[34]=w,t[35]=T):T=t[35],T},sd=(e,t)=>e??t,cd=e=>e===`/`,ld=e=>e.replace(/\\/g,`/`),ud=e=>{if(!e||cd(e))return e;let t=e;for(;t.length>1&&t.endsWith(`/`);)t=t.slice(0,-1);return t},dd=e=>e.endsWith(`/`),fd=e=>{let t=e.trim();return!t||dd(t)?t:`${t}/`},pd=e=>e.lastIndexOf(`/`),md=e=>{if(dd(e))return e;let t=pd(e);return t<0?e:e.slice(0,t+1)},hd=e=>{let t=pd(e);return e.slice(t+1)},gd=e=>{let t=ud(e.trim());if(!t||t===`~`||t===`~/`||t===`/`)return null;let n=pd(t);return n<0?null:t.startsWith(`~/`)&&n<=1?`~/`:n===0?`/`:`${t.slice(0,n)}/`},_d=e=>dd(e)&&gd(e)!==null,vd=(e,t)=>`${md(e)}${t}/`,yd=e=>{if(!e)return null;let t=ud(ld(e.trim()));return t?t.toLowerCase():null},bd=(e,t)=>{let n=e.trim();return n===`~`?t:n.startsWith(`~/`)?`${t}${n.slice(1)}`:n},xd=e=>typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform)?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey,Sd=e=>{if(!e)return;e.focus({preventScroll:!0});let t=e.value.length;e.setSelectionRange(t,t),e.scrollLeft=e.scrollWidth},Cd=async()=>{try{let e=await s(`/api/fs/home`,{method:`GET`,headers:{Accept:`application/json`}});if(e.ok){let t=await e.json();if(typeof t.home==`string`&&t.home.trim().length>0)return ld(t.home.trim())}}catch{}return E.getFilesystemHome().catch(()=>null)},wd=({open:e,onOpenChange:t,forceMobile:n})=>{let{t:r}=be(),i=D(e=>e.homeDirectory),a=ct(e=>e.projects),o=ct(e=>e.addProject),s=Ci(e=>e.profiles),c=Ci(e=>e.globalIdentity),l=Ci(e=>e.defaultGitIdentityId),u=Ci(e=>e.loadProfiles),d=Ci(e=>e.loadGlobalIdentity),f=Ci(e=>e.loadDefaultGitIdentityId),{isDesktop:p,requestAccess:m,startAccessing:h}=$u(),g=sd(n,Yn().isMobile),_=Q.useRef(null),v=Q.useRef(new Map),[y,b]=Q.useState(``),[x,S]=Q.useState(`~/`),[C,w]=Q.useState([]),[T,O]=Q.useState(!1),[k,A]=Q.useState(!1),[j,M]=Q.useState(0),[N,ee]=Q.useState(!1),[P,F]=Q.useState(!1),[I,L]=Q.useState(!1),[R,z]=Q.useState(``),[te,B]=Q.useState(null),[V,H]=Q.useState(!1),ne=y||i,re=Q.useMemo(()=>new Set(a.map(e=>yd(e.path)).filter(e=>!!e)),[a]);Q.useEffect(()=>{if(!e)return;S(`~/`),w([]),M(0),ee(!1),F(!1),L(!1),z(``),B(null),H(!1),requestAnimationFrame(()=>Sd(_.current));let t=!1;return(async()=>{let e=await Cd();t||(b(e||i||``),requestAnimationFrame(()=>Sd(_.current)))})(),()=>{t=!0}},[i,e]),Q.useEffect(()=>{e&&(u(),d(),f())},[f,u,d,e]);let U=Q.useMemo(()=>{let e=new Map;c&&e.set(c.id,c);for(let t of s)e.set(t.id,t);return Array.from(e.values())},[s,c]);Q.useEffect(()=>{if(!e||!I||te!==null)return;let t=typeof l==`string`?l.trim():``;if(t&&U.some(e=>e.id===t)){B(t);return}let n=U.find(e=>e.authType===`ssh`||e.sshKey);n&&B(n.id)},[U,l,I,e,te]);let W=Q.useMemo(()=>U.find(e=>e.id===te)??null,[U,te]),ie=Q.useMemo(()=>md(x),[x]),ae=Q.useMemo(()=>dd(x)?``:hd(x),[x]),oe=Q.useMemo(()=>ne?bd(ie,ne):``,[ie,ne]);Q.useEffect(()=>{if(!e||!oe){w([]);return}let t=!1;return O(!0),A(!1),E.listLocalDirectory(oe).then(e=>{if(t)return;A(!1);let n=e.filter(e=>e.isDirectory).map(e=>({name:e.name,path:ld(e.path)})).sort((e,t)=>e.name.localeCompare(t.name));w(n)}).catch(()=>{t||(w([]),A(!0))}).finally(()=>{t||O(!1)}),()=>{t=!0}},[oe,e]);let G=Q.useMemo(()=>{let e=ae.toLowerCase(),t=V||ae.startsWith(`.`);return C.filter(n=>n.name.toLowerCase().startsWith(e)&&(t||!n.name.startsWith(`.`)))},[ae,C,V]),K=Q.useMemo(()=>{let e=[];_d(x)&&e.push({type:`up`,value:`browse:up`,name:`..`,path:gd(x)});for(let t of G){let n=yd(t.path);e.push({type:`directory`,value:`browse:${t.path}`,name:t.name,path:t.path,alreadyAdded:!!(n&&re.has(n))})}return e},[re,G,x]);Q.useEffect(()=>{M(0)},[x,K.length]);let se=Q.useMemo(()=>ne?ud(bd(x,ne)):``,[ne,x]),ce=yd(se),q=!!(ce&&re.has(ce)),le=Q.useMemo(()=>ae?G.find(e=>e.name===ae)??null:null,[ae,G]),ue=!!(se&&!q&&(dd(x)&&k||!dd(x)&&ae.trim().length>0&&le===null)),de=!N&&!P&&!q&&!!se,fe=de&&R.trim().length>0,pe=K[j]??null,me=!!pe,he=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform),ge=r(q?`directoryExplorerDialog.actions.alreadyAdded`:I?N?`directoryExplorerDialog.actions.cloning`:`directoryExplorerDialog.actions.cloneAndAdd`:N?`directoryExplorerDialog.actions.adding`:ue?`directoryExplorerDialog.actions.createAndAdd`:`directoryExplorerDialog.actions.addProject`);Q.useLayoutEffect(()=>{e&&Sd(_.current)},[e]),Q.useLayoutEffect(()=>{let e=K[j];e&&v.current.get(e.value)?.scrollIntoView({block:`nearest`})},[j,K]);let _e=J(()=>{t(!1)}),ve=J(e=>{let t=bt.getState();t.newSessionDraft?.open&&t.setNewSessionDraftTarget({projectId:e.id,directoryOverride:e.path},{force:!0})}),ye=J(e=>{let t={selectedProjectId:e.id,directoryOverride:e.path,preserveDirectoryOverride:!0};if(g){St.getState().openDraft(t);return}bt.getState().openNewSessionDraft(t)}),xe=J((e,t)=>{e.stopPropagation();let n=yd(t);if(n&&re.has(n))return;let i=o(t);if(!i){yt.error(r(`directoryExplorerDialog.toast.failedToAddProject`),{description:r(`directoryExplorerDialog.toast.selectValidDirectoryPath`)});return}ve(i)}),Se=J(async e=>{if(!e||N)return;let t=yd(e);if(t&&re.has(t))return;let n=e;ee(!0);try{let t=!I&&ue&&yd(e)===yd(se);if(I){let t=R.trim();if(!t){yt.error(r(`directoryExplorerDialog.toast.cloneUrlRequired`));return}n=(await E.cloneRepository({remoteUrl:t,destinationPath:e,gitIdentityId:W?.id??null})).path}else t&&await E.createDirectory(e);let i=o(n);if(!i){yt.error(r(`directoryExplorerDialog.toast.failedToAddProject`),{description:r(`directoryExplorerDialog.toast.selectValidDirectoryPath`)});return}ye(i),_e()}catch(e){yt.error(r(`directoryExplorerDialog.toast.failedToSelectDirectory`),{description:e instanceof Error?e.message:r(`directoryExplorerDialog.toast.unknownError`)})}finally{ee(!1)}}),Ce=J(e=>{S(fd(e))}),we=J(e=>{S(vd(x,e.name))}),Te=J(e=>{if(e){if(e.type===`up`){e.path&&Ce(e.path);return}we(e)}}),Ee=J(async()=>{if(!(!p||P)){F(!0);try{let e=await m(se);if(!e.success||!e.path){e.error&&e.error!==`Directory selection cancelled`&&yt.error(r(`directoryExplorerDialog.toast.failedToSelectDirectory`),{description:e.error});return}let t=await h(e.path);if(!t.success){yt.error(r(`directoryExplorerDialog.toast.failedToOpenDirectory`),{description:t.error||r(`directoryExplorerDialog.toast.desktopCouldNotGrantAccess`)});return}await Se(e.path)}catch(e){yt.error(r(`directoryExplorerDialog.toast.failedToSelectDirectory`),{description:e instanceof Error?e.message:r(`directoryExplorerDialog.toast.unknownError`)})}finally{F(!1)}}}),De=J(e=>{if(e.key===`ArrowDown`){e.preventDefault(),M(e=>Math.min(K.length-1,e+1));return}if(e.key===`ArrowUp`){e.preventDefault(),M(e=>Math.max(0,e-1));return}if(e.key===`Enter`){if(e.preventDefault(),xd(e)){Se(se);return}me&&Te(pe);return}e.key===`Backspace`&&x===``&&(e.preventDefault(),_e())}),Oe=(0,$.jsxs)(X,{type:`button`,variant:`ghost`,size:`xs`,"aria-pressed":V,onClick:()=>H(e=>!e),className:`yuri-directory-hidden-toggle shrink-0 text-muted-foreground`,children:[(0,$.jsx)(Z,{name:V?`checkbox`:`checkbox-blank`,className:`size-3.5`}),r(`directoryExplorerDialog.toggle.showHidden`)]}),ke=(0,$.jsxs)(`div`,{className:`yuri-directory-inputs`,children:[I?(0,$.jsxs)(`div`,{className:`yuri-directory-field`,children:[(0,$.jsx)(Dn,{value:R,onChange:e=>z(e.target.value),placeholder:r(`directoryExplorerDialog.clone.remoteUrlPlaceholder`),"aria-label":r(`directoryExplorerDialog.clone.remoteUrlPlaceholder`),className:`min-w-0 flex-1 font-mono`,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`}),(0,$.jsx)(od,{activeProfile:W,identities:U,onSelect:e=>B(e.id),isApplying:N,iconOnly:!0})]}):null,(0,$.jsxs)(`div`,{className:`yuri-directory-field`,children:[(0,$.jsx)(Z,{name:`folder-add`,className:`size-4 shrink-0 text-muted-foreground`}),(0,$.jsx)(Dn,{ref:_,value:x,onChange:e=>S(ld(e.target.value)),onKeyDown:De,placeholder:r(`directoryExplorerDialog.pathInput.placeholder`),"aria-label":r(`directoryExplorerDialog.pathInput.placeholder`),className:`min-w-0 flex-1 font-mono`,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`})]})]}),Ae=(0,$.jsx)(Yr,{outerClassName:`yuri-directory-results`,className:`yuri-directory-list`,"aria-label":r(`directoryExplorerDialog.browse.directories`),"aria-busy":T,disableHorizontal:!0,children:T?(0,$.jsx)(`div`,{className:`yuri-directory-empty text-center text-muted-foreground`,role:`status`,children:r(`directoryExplorerDialog.browse.loading`)}):K.length===0?(0,$.jsx)(`div`,{className:`yuri-directory-empty text-center text-muted-foreground`,role:`status`,children:r(`directoryExplorerDialog.browse.empty`)}):(0,$.jsx)(`div`,{children:K.map((e,t)=>{let n=t===j;return(0,$.jsxs)(`div`,{"data-directory-row":e.type,"data-selected":n,onMouseEnter:()=>M(t),className:Y(`yuri-directory-row`,n&&`bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)]`,!n&&`hover:bg-interactive-hover/50`),children:[(0,$.jsxs)(`button`,{ref:t=>{t?v.current.set(e.value,t):v.current.delete(e.value)},type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>Te(e),className:`yuri-directory-entry`,title:e.path??e.name,children:[e.type===`up`?(0,$.jsx)(Z,{name:`arrow-left-s`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground/80`}):(0,$.jsx)(Z,{name:`folder-6`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground/80`}),(0,$.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:(0,$.jsx)(`span`,{className:`yuri-directory-name truncate text-foreground`,children:e.name})})]}),e.type===`directory`&&e.alreadyAdded?(0,$.jsx)(`span`,{className:`yuri-directory-added shrink-0 text-muted-foreground`,children:r(`directoryExplorerDialog.browse.addedBadge`)}):e.type===`directory`?(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,onMouseDown:e=>e.stopPropagation(),onClick:t=>xe(t,e.path),className:`shrink-0 text-muted-foreground hover:text-foreground`,title:r(`directoryExplorerDialog.browse.quickAdd`),"aria-label":r(`directoryExplorerDialog.browse.quickAdd`),children:(0,$.jsx)(Z,{name:`add`,className:`h-3.5 w-3.5`})}):null]},e.value)})})}),je=(0,$.jsxs)(`div`,{className:`yuri-directory-content`,children:[ke,Ae]}),Me=g?null:(0,$.jsxs)(`div`,{className:`yuri-directory-shortcuts text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsxs)(mn,{variant:`hint`,className:`gap-0.5`,"aria-label":`↑ ↓`,children:[(0,$.jsx)(Z,{name:`arrow-up`,className:`size-2.5`}),(0,$.jsx)(Z,{name:`arrow-down`,className:`size-2.5`})]}),r(`directoryExplorerDialog.footer.navigate`)]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(mn,{variant:`hint`,"aria-label":`Enter`,children:(0,$.jsx)(Z,{name:`corner-down-left`,className:`size-2.5`})}),r(`directoryExplorerDialog.footer.select`)]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsxs)(mn,{variant:`hint`,className:`gap-0.5`,"aria-label":he?`⌘ Enter`:`Ctrl Enter`,children:[he?(0,$.jsx)(Z,{name:`command`,className:`size-2.5`}):`Ctrl`,(0,$.jsx)(Z,{name:`corner-down-left`,className:`size-2.5`})]}),r(`directoryExplorerDialog.footer.add`)]})]}),Ne=()=>(0,$.jsxs)(`div`,{className:`yuri-directory-actions`,children:[p?(0,$.jsx)(X,{variant:`ghost`,size:`xs`,onClick:Ee,disabled:N||P||I,children:r(P?`directoryExplorerDialog.actions.openingFinder`:`directoryExplorerDialog.actions.openInFinder`)}):null,(0,$.jsx)(X,{variant:`ghost`,size:`xs`,onClick:()=>L(e=>!e),disabled:N||P,children:r(I?`directoryExplorerDialog.actions.addLocalProject`:`directoryExplorerDialog.actions.cloneRepository`)}),(0,$.jsx)(X,{size:`xs`,onClick:()=>void Se(se),disabled:I?!fe:!de,children:ge})]});return g?(0,$.jsxs)(dr,{id:`mobile-directory-explorer-sheet`,open:e,onOpenChange:t,title:(0,$.jsx)(`h2`,{className:`yuri-directory-title truncate text-foreground`,children:r(`directoryExplorerDialog.title`)}),trailing:Oe,ariaLabel:r(`directoryExplorerDialog.title`),closeAriaLabel:r(`mobile.surface.closeAria`),resizeAriaLabel:r(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,className:`yuri-directory-mobile`,children:[je,(0,$.jsx)(`div`,{className:`yuri-directory-footer`,children:Ne()})]}):(0,$.jsx)(qt,{open:e,onOpenChange:t,children:(0,$.jsxs)(Wt,{presentation:`picker`,className:`yuri-directory-dialog`,initialFocus:!1,children:[(0,$.jsx)(Ht,{className:`yuri-directory-header`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,$.jsx)(Gt,{className:`yuri-directory-title truncate`,children:r(`directoryExplorerDialog.title`)}),Oe]})}),je,(0,$.jsxs)(Ut,{className:`yuri-directory-footer`,children:[Me,Ne()]})]})})},Td=`yuri-settings-group-row border-b border-[var(--yuri-settings-row-divider)] last:border-b-0`,Ed=`yuri-settings-group-label`,Dd=Ki();function Od(e){if(!e||!e.trim())return{valid:!1,error:`required`};try{return Dd.CronExpressionParser.parse(e),{valid:!0}}catch(e){return{valid:!1,error:e instanceof Error?e.message:`Invalid cron expression`}}}function kd(e,t,n=4){try{let r=t?{tz:t,currentDate:new Date}:{currentDate:new Date},i=Dd.CronExpressionParser.parse(e,r),a=[];for(let e=0;e<n;e+=1){let e=i.next();e&&a.push(e.toDate())}return a}catch{return[]}}var Ad=[{expression:`*/5 * * * *`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.every5min`},{expression:`0 * * * *`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.everyHour`},{expression:`0 9 * * 1`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.monday9am`},{expression:`0 9,17 * * *`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.9am5pm`},{expression:`0 0 1 * *`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.firstOfMonth`}],jd=[0,1,2,3,4,5,6],Md=`!h-9 !min-h-9 w-full min-w-0 rounded-full border-0 bg-[var(--surface-elevated)] px-3 py-1 ring-1 ring-inset ring-border/60 transition-[background-color,box-shadow] duration-150 ease-out hover:[&:not(:focus)]:bg-[var(--surface-subtle)] hover:[&:not(:focus)]:ring-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] data-[popup-open]:bg-[var(--surface-subtle)] data-[popup-open]:shadow-sm motion-reduce:transition-none`,Nd=`yuri-settings-inline-value`,Pd=`yuri-settings-split-row ${Td}`,Fd=Nd,Id=Pd,Ld=()=>{let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`},Rd=e=>{let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]),a=new Date(n,r-1,i);return Number.isNaN(a.getTime())||a.getFullYear()!==n||a.getMonth()!==r-1||a.getDate()!==i?null:a},zd=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`,Bd=(e,t,n)=>{let r=Rd(e);return r?new Intl.DateTimeFormat(n,{month:`short`,day:`numeric`,year:`numeric`}).format(r):t},Vd=(e,t)=>new Date(e.getFullYear(),e.getMonth()+t,1),Hd=(e,t)=>{let n=e.getFullYear(),r=e.getMonth(),i=(new Date(n,r,1).getDay()-t+7)%7,a=new Date(n,r+1,0).getDate(),o=new Date(n,r,0).getDate(),s=[];for(let e=0;e<42;e+=1){let t=e-i+1;if(t<=0){let e=o+t;s.push({date:new Date(n,r-1,e),inCurrentMonth:!1});continue}if(t>a){s.push({date:new Date(n,r+1,t-a),inCurrentMonth:!1});continue}s.push({date:new Date(n,r,t),inCurrentMonth:!0})}return s},Ud=e=>{let t=/^([01]\d|2[0-3]):([0-5]\d)$/.exec(e);if(!t)return{hour24:`00`,hour12:`12`,minute:`00`,meridiem:`AM`};let n=Number(t[1]),r=t[2],i=n>=12?`PM`:`AM`,a=n%12==0?12:n%12;return{hour24:String(n).padStart(2,`0`),hour12:String(a).padStart(2,`0`),minute:r,meridiem:i}},Wd=(e,t,n)=>{let r=Number(e),i=Number(t),a=Number.isFinite(r)?Math.min(12,Math.max(1,r)):12,o=Number.isFinite(i)?Math.min(59,Math.max(0,i)):0,s=a%12;return n===`PM`&&(s+=12),`${String(s).padStart(2,`0`)}:${String(o).padStart(2,`0`)}`},Gd=(e,t)=>{let{max:n,min:r=0,loop:i=!1}=t,a=Number.parseInt(e,10);return Number.isFinite(a)?(i?(a>n&&(a=r),a<r&&(a=n)):(a>n&&(a=n),a<r&&(a=r)),String(a).padStart(2,`0`)):`00`},Kd=e=>/^(0[1-9]|1[0-2])$/.test(e)?e:Gd(e,{min:1,max:12}),qd=e=>/^[0-5][0-9]$/.test(e)?e:Gd(e,{max:59}),Jd=(e,t)=>Gd(String(Number.parseInt(e,10)+t),{min:1,max:12,loop:!0}),Yd=(e,t)=>Gd(String(Number.parseInt(e,10)+t),{min:0,max:59,loop:!0}),Xd=e=>{try{let t=Intl.Locale;if(typeof t!=`function`)return 1;let n=new t(e).weekInfo?.firstDay;return typeof n==`number`?n%7:1}catch{return 1}},Zd=e=>{try{let t=new Intl.DateTimeFormat(e,{hour:`numeric`}).resolvedOptions();return typeof t.hour12==`boolean`?!t.hour12:t.hourCycle===`h23`||t.hourCycle===`h24`}catch{return!0}},Qd=e=>{let t=new Intl.DateTimeFormat(e,{weekday:`short`}),n=new Date(2023,0,1);return jd.map(e=>t.format(new Date(n.getFullYear(),n.getMonth(),n.getDate()+e)))},$d=(e,t)=>[...e.slice(t),...e.slice(0,t)],ef=e=>{let t=(0,qi.c)(9),{htmlFor:n,required:r,className:i,children:a}=e,o;t[0]===i?o=t[1]:(o=Y(`typography-ui-label font-normal text-foreground`,i),t[0]=i,t[1]=o);let s;t[2]===r?s=t[3]:(s=r&&(0,$.jsx)(`span`,{className:`ml-0.5 text-destructive`,children:`*`}),t[2]=r,t[3]=s);let c;return t[4]!==a||t[5]!==n||t[6]!==o||t[7]!==s?(c=(0,$.jsx)(`div`,{className:`flex items-center gap-1.5`,children:(0,$.jsxs)(`label`,{htmlFor:n,className:o,children:[a,s]})}),t[4]=a,t[5]=n,t[6]=o,t[7]=s,t[8]=c):c=t[8],c},tf=e=>{let t=(0,qi.c)(85),{value:n,onChange:r,className:i,use24Hour:a,hourAriaLabel:o,minuteAriaLabel:s,periodAriaLabel:c,amLabel:l,pmLabel:u}=e,d;t[0]===n?d=t[1]:(d=Ud(n),t[0]=n,t[1]=d);let f=d,p=Q.useRef(null),m=Q.useRef(null),[h,g]=Q.useState(null),[_,v]=Q.useState(null),y=Q.useRef(null),b=Q.useRef(null),x;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>{y.current=e,g(e)},t[2]=x):x=t[2];let S=x,C;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{b.current=e,v(e)},t[3]=C):C=t[3];let w=C,T=ff,E=pf,D=mf,O;t[4]!==r||t[5]!==f.meridiem||t[6]!==f.minute||t[7]!==a?(O=e=>{let t=e.replace(/\D/g,``).slice(0,2);S(t),t.length===2&&(r(a?D(T(t),f.minute):Wd(Kd(t),f.minute,f.meridiem)),S(null),m.current?.focus())},t[4]=r,t[5]=f.meridiem,t[6]=f.minute,t[7]=a,t[8]=O):O=t[8];let k=O,A;t[9]!==r||t[10]!==f.meridiem||t[11]!==f.minute||t[12]!==a?(A=()=>{let e=y.current;if(e!==null&&(S(null),e.length!==0)){if(a){r(D(T(e.padStart(2,`0`)),f.minute));return}r(Wd(Kd(e.padStart(2,`0`)),f.minute,f.meridiem))}},t[9]=r,t[10]=f.meridiem,t[11]=f.minute,t[12]=a,t[13]=A):A=t[13];let j=A,M;t[14]!==r||t[15]!==f.hour12||t[16]!==f.hour24||t[17]!==f.meridiem||t[18]!==a?(M=e=>{let t=e.replace(/\D/g,``).slice(0,2);w(t),t.length===2&&(r(a?D(f.hour24,qd(t)):Wd(f.hour12,qd(t),f.meridiem)),w(null))},t[14]=r,t[15]=f.hour12,t[16]=f.hour24,t[17]=f.meridiem,t[18]=a,t[19]=M):M=t[19];let N=M,ee;t[20]!==r||t[21]!==f.hour12||t[22]!==f.hour24||t[23]!==f.meridiem||t[24]!==a?(ee=()=>{let e=b.current;e!==null&&(w(null),e.length!==0&&r(a?D(f.hour24,qd(e.padStart(2,`0`))):Wd(f.hour12,qd(e.padStart(2,`0`)),f.meridiem)))},t[20]=r,t[21]=f.hour12,t[22]=f.hour24,t[23]=f.meridiem,t[24]=a,t[25]=ee):ee=t[25];let P=ee,F;t[26]!==r||t[27]!==f.hour12||t[28]!==f.hour24||t[29]!==f.meridiem||t[30]!==f.minute||t[31]!==a?(F=e=>r(a?D(E(f.hour24,e),f.minute):Wd(Jd(f.hour12,e),f.minute,f.meridiem)),t[26]=r,t[27]=f.hour12,t[28]=f.hour24,t[29]=f.meridiem,t[30]=f.minute,t[31]=a,t[32]=F):F=t[32];let I=F,L;t[33]!==r||t[34]!==f.hour12||t[35]!==f.hour24||t[36]!==f.meridiem||t[37]!==f.minute||t[38]!==a?(L=e=>r(a?D(f.hour24,Yd(f.minute,e)):Wd(f.hour12,Yd(f.minute,e),f.meridiem)),t[33]=r,t[34]=f.hour12,t[35]=f.hour24,t[36]=f.meridiem,t[37]=f.minute,t[38]=a,t[39]=L):L=t[39];let R=L,z;t[40]!==r||t[41]!==f.hour12||t[42]!==f.meridiem||t[43]!==f.minute?(z=e=>{e!==f.meridiem&&r(Wd(f.hour12,f.minute,e))},t[40]=r,t[41]=f.hour12,t[42]=f.meridiem,t[43]=f.minute,t[44]=z):z=t[44];let te=z,B;t[45]!==j||t[46]!==I?(B=e=>{if(e.key===`ArrowRight`){e.preventDefault(),j(),m.current?.focus();return}(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),S(null),I(e.key===`ArrowUp`?1:-1))},t[45]=j,t[46]=I,t[47]=B):B=t[47];let V=B,H;t[48]!==P||t[49]!==R?(H=e=>{if(e.key===`ArrowLeft`&&(e.currentTarget.selectionStart??0)===0){e.preventDefault(),P(),p.current?.focus();return}(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),w(null),R(e.key===`ArrowUp`?1:-1))},t[48]=P,t[49]=R,t[50]=H):H=t[50];let ne=H,re=a?`px-2`:`pl-2 pr-1`,U;t[51]!==i||t[52]!==re?(U=Y(`flex h-9 w-full min-w-0 items-center gap-1 rounded-full border-0 bg-[var(--surface-elevated)] ring-1 ring-inset ring-border/60 transition duration-200 ease-out hover:[&:not(:focus-within)]:bg-[var(--surface-subtle)] hover:[&:not(:focus-within)]:ring-transparent focus-within:ring-2 focus-within:ring-[var(--interactive-focus-ring)]`,re,i),t[51]=i,t[52]=re,t[53]=U):U=t[53];let W=h??(a?f.hour24:f.hour12),ie;t[54]===k?ie=t[55]:(ie=e=>k(e.target.value),t[54]=k,t[55]=ie);let ae;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>S(``),t[56]=ae):ae=t[56];let oe;t[57]!==j||t[58]!==o||t[59]!==V||t[60]!==W||t[61]!==ie?(oe=(0,$.jsx)(`input`,{ref:p,inputMode:`numeric`,value:W,onChange:ie,onKeyDown:V,onFocus:ae,onBlur:j,maxLength:2,"aria-label":o,className:`h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover`}),t[57]=j,t[58]=o,t[59]=V,t[60]=W,t[61]=ie,t[62]=oe):oe=t[62];let G;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(`span`,{className:`font-mono text-sm text-muted-foreground`,children:`:`}),t[63]=G):G=t[63];let K=_??f.minute,se;t[64]===N?se=t[65]:(se=e=>N(e.target.value),t[64]=N,t[65]=se);let ce;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(ce=()=>w(``),t[66]=ce):ce=t[66];let q;t[67]!==P||t[68]!==s||t[69]!==ne||t[70]!==K||t[71]!==se?(q=(0,$.jsx)(`input`,{ref:m,inputMode:`numeric`,value:K,onChange:se,onKeyDown:ne,onFocus:ce,onBlur:P,maxLength:2,"aria-label":s,className:`h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover`}),t[67]=P,t[68]=s,t[69]=ne,t[70]=K,t[71]=se,t[72]=q):q=t[72];let le;t[73]!==l||t[74]!==f.meridiem||t[75]!==c||t[76]!==u||t[77]!==te||t[78]!==a?(le=a?null:(0,$.jsxs)(xr,{value:f.meridiem,onValueChange:e=>te(e),children:[(0,$.jsx)(br,{"aria-label":c,className:`ml-1 h-7 w-fit border-0 bg-transparent pl-2 pr-1 shadow-none hover:bg-interactive-hover focus:ring-0`,children:(0,$.jsx)(_r,{})}),(0,$.jsxs)(yr,{className:`motion-reduce:transition-none`,children:[(0,$.jsx)(vr,{value:`AM`,children:l}),(0,$.jsx)(vr,{value:`PM`,children:u})]})]}),t[73]=l,t[74]=f.meridiem,t[75]=c,t[76]=u,t[77]=te,t[78]=a,t[79]=le):le=t[79];let ue;return t[80]!==U||t[81]!==oe||t[82]!==q||t[83]!==le?(ue=(0,$.jsxs)(`div`,{className:U,children:[oe,G,q,le]}),t[80]=U,t[81]=oe,t[82]=q,t[83]=le,t[84]=ue):ue=t[84],ue},nf=e=>new Date(e.getFullYear(),e.getMonth(),1),rf=()=>{let e=new Date;return new Date(e.getFullYear(),e.getMonth(),e.getDate())},af=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),of=e=>{if(!e)return[`09:00`];let t=(Array.isArray(e.schedule.times)?e.schedule.times:e.schedule.time?[e.schedule.time]:[]).filter(e=>typeof e==`string`&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(e)).map(e=>e.trim()),n=Array.from(new Set(t)).sort((e,t)=>e.localeCompare(t));return n.length>0?n:[`09:00`]},sf=(e,t)=>{let n=Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`;return e?{id:e.id,name:e.name,enabled:e.enabled,schedule:{kind:e.schedule.kind===`cron`?`cron`:e.schedule.kind===`once`?`once`:e.schedule.kind===`weekly`?`weekly`:`daily`,times:of(e),onceDate:typeof e.schedule.date==`string`&&/^\d{4}-\d{2}-\d{2}$/.test(e.schedule.date)?e.schedule.date:Ld(),onceTime:typeof e.schedule.time==`string`&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(e.schedule.time)?e.schedule.time:`09:00`,weekdays:Array.isArray(e.schedule.weekdays)?e.schedule.weekdays:[1],timezone:e.schedule.timezone||n,cronExpression:e.schedule.kind===`cron`&&typeof e.schedule.cron==`string`?e.schedule.cron:``},execution:{prompt:e.execution.prompt,providerID:e.execution.providerID,modelID:e.execution.modelID,variant:e.execution.variant||``,agent:e.execution.agent||``,goalEnabled:e.execution.goalEnabled===!0},state:e.state}:{name:``,enabled:!0,schedule:{kind:`daily`,times:[`09:00`],onceDate:Ld(),onceTime:`09:00`,weekdays:[1],timezone:n,cronExpression:``},execution:{prompt:``,providerID:t.providerID,modelID:t.modelID,variant:t.variant,agent:t.agent,goalEnabled:!1}}},cf=(e,t)=>{if(!e.name.trim())return t(`sessions.scheduledTasks.editor.validation.taskNameRequired`);if(!e.execution.prompt.trim())return t(`sessions.scheduledTasks.editor.validation.promptRequired`);if(!e.execution.providerID.trim()||!e.execution.modelID.trim())return t(`sessions.scheduledTasks.editor.validation.modelRequired`);if(e.schedule.kind===`once`){if(!/^\d{4}-\d{2}-\d{2}$/.test(e.schedule.onceDate))return t(`sessions.scheduledTasks.editor.validation.dateFormat`);if(!/^([01]\d|2[0-3]):([0-5]\d)$/.test(e.schedule.onceTime))return t(`sessions.scheduledTasks.editor.validation.timeFormat`)}else if(e.schedule.kind===`cron`){if(!e.schedule.cronExpression.trim())return t(`sessions.scheduledTasks.editor.validation.cronRequired`);if(!Od(e.schedule.cronExpression).valid)return t(`sessions.scheduledTasks.editor.validation.cronInvalid`)}else if(e.schedule.times.filter(e=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(e)).length===0)return t(`sessions.scheduledTasks.editor.validation.atLeastOneTime`);return e.schedule.kind===`weekly`&&e.schedule.weekdays.length===0?t(`sessions.scheduledTasks.editor.validation.atLeastOneWeekday`):e.schedule.timezone.trim()?null:t(`sessions.scheduledTasks.editor.validation.timezoneRequired`)},lf=e=>{let t=e.filter(e=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(e));return Array.from(new Set(t)).sort((e,t)=>e.localeCompare(t))},uf=e=>{let t=(0,qi.c)(74),{draft:n,setDraft:r,locale:i,t:a,panel:o,mobilePanel:s}=e,c=o!==void 0&&o,l=s!==void 0&&s,u=c||l,d=l?Id:Pd,f=n.schedule.cronExpression,p;t[0]===f?p=t[1]:(p=f.trim()?Od(f):null,t[0]=f,t[1]=p);let m=p,h;bb0:{if(!m?.valid||!f.trim()){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[2]=e):e=t[2],h=e;break bb0}let e;t[3]!==f||t[4]!==n.schedule.timezone?(e=kd(f,n.schedule.timezone),t[3]=f,t[4]=n.schedule.timezone,t[5]=e):e=t[5],h=e}let g=h,_;t[6]!==n.schedule.timezone||t[7]!==i?(_=e=>new Intl.DateTimeFormat(i,{timeZone:n.schedule.timezone,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}).format(e),t[6]=n.schedule.timezone,t[7]=i,t[8]=_):_=t[8];let v=_,y=u&&`gap-0`,b;t[9]===y?b=t[10]:(b=Y(`flex flex-col gap-3`,y),t[9]=y,t[10]=b);let x=u&&d,S;t[11]===x?S=t[12]:(S=Y(`flex flex-col gap-1`,x),t[11]=x,t[12]=S);let C;t[13]===a?C=t[14]:(C=a(`sessions.scheduledTasks.editor.cronExpression.label`),t[13]=a,t[14]=C);let w;t[15]===C?w=t[16]:(w=(0,$.jsx)(ef,{htmlFor:`sched-cron`,required:!0,children:C}),t[15]=C,t[16]=w);let T=u?``:void 0,E=u&&`yuri-settings-split-row-control flex-wrap`,D;t[17]===E?D=t[18]:(D=Y(`min-w-0`,E),t[17]=E,t[18]=D);let O;t[19]===r?O=t[20]:(O=e=>r(t=>({...t,schedule:{...t.schedule,cronExpression:e.target.value}})),t[19]=r,t[20]=O);let k;t[21]===a?k=t[22]:(k=a(`sessions.scheduledTasks.editor.cronExpression.placeholder`),t[21]=a,t[22]=k);let A=u&&`min-w-[140px] text-right`,j;t[23]===A?j=t[24]:(j=Y(`w-full font-mono`,A),t[23]=A,t[24]=j);let M;t[25]!==f||t[26]!==O||t[27]!==k||t[28]!==j?(M=(0,$.jsx)(Dn,{id:`sched-cron`,value:f,onChange:O,placeholder:k,className:j}),t[25]=f,t[26]=O,t[27]=k,t[28]=j,t[29]=M):M=t[29];let N;t[30]!==f||t[31]!==m||t[32]!==a?(N=m&&!m.valid&&f.trim()?(0,$.jsx)(`span`,{className:`w-full typography-micro text-right text-destructive`,children:a(`sessions.scheduledTasks.editor.validation.cronInvalid`)}):null,t[30]=f,t[31]=m,t[32]=a,t[33]=N):N=t[33];let ee;t[34]!==T||t[35]!==D||t[36]!==M||t[37]!==N?(ee=(0,$.jsxs)(`div`,{"data-settings-value":T,className:D,children:[M,N]}),t[34]=T,t[35]=D,t[36]=M,t[37]=N,t[38]=ee):ee=t[38];let P;t[39]!==w||t[40]!==ee||t[41]!==S?(P=(0,$.jsxs)(`div`,{className:S,children:[w,ee]}),t[39]=w,t[40]=ee,t[41]=S,t[42]=P):P=t[42];let F;t[43]!==v||t[44]!==u||t[45]!==g||t[46]!==d||t[47]!==a?(F=g.length>0?(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1`,u&&[d,`yuri-scheduled-task-detail-row`]),children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:a(`sessions.scheduledTasks.editor.cronExpression.nextRuns`)}),(0,$.jsx)(`span`,{"data-settings-value":u?``:void 0,className:`flex min-w-0 flex-wrap gap-x-4 gap-y-1 typography-micro text-muted-foreground`,children:g.map(e=>(0,$.jsx)(`span`,{className:`whitespace-nowrap tabular-nums`,children:v(e)},e.toISOString()))})]}):null,t[43]=v,t[44]=u,t[45]=g,t[46]=d,t[47]=a,t[48]=F):F=t[48];let I;t[49]!==u||t[50]!==d?(I=u&&[d,`yuri-scheduled-task-detail-row`],t[49]=u,t[50]=d,t[51]=I):I=t[51];let L;t[52]===I?L=t[53]:(L=Y(`flex flex-col gap-1`,I),t[52]=I,t[53]=L);let R;t[54]===a?R=t[55]:(R=a(`sessions.scheduledTasks.editor.cronExpression.examples`),t[54]=a,t[55]=R);let z;t[56]===R?z=t[57]:(z=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:R}),t[56]=R,t[57]=z);let te=u?``:void 0,B;t[58]!==f||t[59]!==r||t[60]!==a?(B=Ad.map(e=>(0,$.jsx)(X,{type:`button`,variant:`chip`,size:`xs`,"aria-pressed":f.trim()===e.expression,title:e.expression,onClick:()=>r(t=>({...t,schedule:{...t.schedule,cronExpression:e.expression}})),children:a(e.labelKey)},e.expression)),t[58]=f,t[59]=r,t[60]=a,t[61]=B):B=t[61];let V;t[62]!==te||t[63]!==B?(V=(0,$.jsx)(`div`,{"data-settings-value":te,className:`flex min-w-0 flex-wrap gap-1.5`,children:B}),t[62]=te,t[63]=B,t[64]=V):V=t[64];let H;t[65]!==L||t[66]!==z||t[67]!==V?(H=(0,$.jsxs)(`div`,{className:L,children:[z,V]}),t[65]=L,t[66]=z,t[67]=V,t[68]=H):H=t[68];let ne;return t[69]!==P||t[70]!==F||t[71]!==H||t[72]!==b?(ne=(0,$.jsxs)(`div`,{className:b,children:[P,F,H]}),t[69]=P,t[70]=F,t[71]=H,t[72]=b,t[73]=ne):ne=t[73],ne};function df(e){let{open:t,task:n,onOpenChange:r,onSave:i,presentation:a=`dialog`,onDirtyChange:o,onRun:s,onOpenTaskHistory:c,onDelete:l,onToggleEnabled:u,actionBusy:d=!1,projectID:f=``,projectOptions:p=[],onProjectChange:m}=e,h=a===`panel`,g=a===`mobile-panel`,_=a===`mobile-tab`,v=g||_,y=g||_,b=h||v,x=v?Fd:Nd,S=v?Id:Pd,{t:C,locale:w}=be(),T=Ye(e=>e.loadProviders),E=Ye(e=>e.loadAgents),D=Ye(e=>e.providers),O=Ye(e=>e.currentProviderId),k=Ye(e=>e.currentModelId),A=Ye(e=>e.currentVariant||``),M=Ye(e=>e.currentAgentName||``),N=j(e=>e.timeFormatPreference),ee=j(e=>e.weekStartPreference),P=j(e=>e.isMobile),[F,I]=Q.useState(()=>sf(n,{providerID:O,modelID:k,variant:A,agent:M})),[L,R]=Q.useState(!1),[z,te]=Q.useState(!1),[B,V]=Q.useState(!1),[H,ne]=Q.useState(``),[re,U]=Q.useState(!1),[W,ie]=Q.useState(``),[ae,oe]=Q.useState(()=>{let e=Rd(n?.schedule?.date||``)||new Date;return new Date(e.getFullYear(),e.getMonth(),1)}),G=Q.useRef(null),K=Q.useRef(null),se=Q.useRef(null),ce=Q.useRef(null),q=Q.useRef(``),le=Q.useRef(void 0),ue=Q.useRef(n);ue.current=n;let de=n?.id||null,fe=Q.useMemo(()=>Zd(w),[w]),pe=Q.useMemo(()=>Xd(w),[w]),me=Q.useMemo(()=>N===`24h`||N!==`12h`&&fe,[N,fe]),he=Q.useMemo(()=>ee===`sunday`?0:ee===`monday`?1:pe,[ee,pe]),ge=Q.useMemo(()=>{let e=Qd(w);return $d(jd.map(t=>({value:t,label:e[t]||``})),he)},[w,he]);Q.useEffect(()=>{t&&(T({source:`scheduledTaskEditor`}),E({source:`scheduledTaskEditor`}))},[t,T,E]),Q.useEffect(()=>{if(!t){le.current=void 0;return}if(le.current===de)return;le.current=de;let e=ue.current,n=sf(e,{providerID:O,modelID:k,variant:A,agent:M});q.current=JSON.stringify(n),I(n),o?.(!1);let r=Rd(e?.schedule?.date||``)||new Date;oe(new Date(r.getFullYear(),r.getMonth(),1)),te(!1),U(!1),V(!1),ie(``),ne(``)},[t,de,O,k,A,M,o]),Q.useEffect(()=>{if(!(!t||!n||F.id!==n.id||F.enabled===n.enabled)&&(I(e=>({...e,enabled:n.enabled})),q.current)){let e=JSON.parse(q.current);q.current=JSON.stringify({...e,enabled:n.enabled})}},[F.enabled,F.id,t,n]),Q.useEffect(()=>{!t||!q.current||o?.(JSON.stringify(F)!==q.current)},[F,o,t]),Q.useEffect(()=>{if(!z)return;let e=e=>{G.current&&!G.current.contains(e.target)&&te(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[z]);let _e=Q.useMemo(()=>D.find(e=>e.id===F.execution.providerID)?.models?.find(e=>e.id===F.execution.modelID),[F.execution.modelID,F.execution.providerID,D]),J=Q.useMemo(()=>_e?.variants?Object.keys(_e.variants):[],[_e]);Q.useEffect(()=>{!_e||!F.execution.variant||J.includes(F.execution.variant)||I(e=>({...e,execution:{...e.execution,variant:``}}))},[J,F.execution.variant,_e]);let ve=Q.useCallback((e,t)=>{I(n=>{let r=new Set(n.schedule.weekdays);return t?r.add(e):r.delete(e),{...n,schedule:{...n.schedule,weekdays:Array.from(r).sort((e,t)=>e-t)}}})},[]),ye=Q.useCallback((e,t)=>{I(n=>{let r=n.schedule.times.slice();return r[e]=t,{...n,schedule:{...n.schedule,times:r}}})},[]),xe=Q.useCallback(e=>{I(t=>{let n=t.schedule.times.filter((t,n)=>n!==e);return{...t,schedule:{...t.schedule,times:n.length>0?n:[`09:00`]}}})},[]),Se=Q.useCallback(()=>{I(e=>({...e,schedule:{...e.schedule,times:[...e.schedule.times,`12:00`]}}))},[]),Ce=Q.useMemo(()=>rf(),[]),we=Q.useMemo(()=>nf(Ce),[Ce]),Te=Q.useMemo(()=>{let e=Rd(F.schedule.onceDate);return e?af(e,Ce)?C(`sessions.scheduledTasks.editor.date.today`):new Intl.DateTimeFormat(w,{weekday:`short`}).format(e):null},[F.schedule.onceDate,w,C,Ce]),Ee=Q.useMemo(()=>nf(ae).getTime()<=we.getTime(),[ae,we]),De=Q.useMemo(()=>ge.map(e=>e.label),[ge]),Oe=Q.useCallback(e=>{I(t=>({...t,schedule:{...t.schedule,onceDate:e}}))},[]),ke=Q.useCallback((e,t)=>{if(e.startsWith(`/`)){let n=e.indexOf(` `),r=e.indexOf(`
148
148
  `),i=Math.min(n===-1?e.length:n,r===-1?e.length:r);if(t<=i&&n===-1){ie(e.substring(1,i)),U(!0),V(!1);return}}U(!1);let n=e.substring(0,t),r=n.lastIndexOf(`@`);if(r!==-1){let e=r>0?n[r-1]:null,t=n.substring(r+1);(!e||/\s/.test(e))&&!t.includes(` `)&&!t.includes(`
149
149
  `)?(ne(t),V(!0)):V(!1);return}V(!1)},[]),Ae=Q.useCallback(e=>{I(t=>({...t,execution:{...t.execution,prompt:e}}))},[]),je=Q.useCallback(e=>{let t=F.execution.prompt,n=K.current?.selectionStart??t.length,r=t.substring(0,n).lastIndexOf(`@`),i=e.relativePath&&e.relativePath.trim().length>0?e.relativePath.trim():e.path||e.name,a=Sn(t,r===-1?n:r,n,`@${i}`);Ae(a.text),V(!1),ne(``),requestAnimationFrame(()=>{let e=K.current;e&&(e.selectionStart=a.caret,e.selectionEnd=a.caret,e.focus()),ke(a.text,a.caret)})},[F.execution.prompt,Ae,ke]),Ne=Q.useCallback(e=>{let t=F.execution.prompt,n=K.current?.selectionStart??t.length,r=t.substring(0,n).lastIndexOf(`@`),i=Sn(t,r===-1?n:r,n,`@${e}`);Ae(i.text),V(!1),ne(``),requestAnimationFrame(()=>{let e=K.current;e&&(e.selectionStart=i.caret,e.selectionEnd=i.caret,e.focus()),ke(i.text,i.caret)})},[F.execution.prompt,Ae,ke]),Pe=Q.useCallback(e=>{let t=`/${e.name} `;Ae(t),U(!1),ie(``),requestAnimationFrame(()=>{let e=K.current;e&&(e.focus(),e.selectionStart=e.value.length,e.selectionEnd=e.value.length),ke(t,t.length)})},[Ae,ke]),Fe=Q.useCallback(e=>{if(re&&ce.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)){e.preventDefault(),ce.current.handleKeyDown(e.key);return}B&&se.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)&&(e.preventDefault(),se.current.handleKeyDown(e.key))},[re,B]),Ie=Q.useCallback(async()=>{let e=cf(F,C);if(e){yt.error(e);return}let t={...F.id?{id:F.id}:{},name:F.name.trim(),enabled:F.enabled,schedule:{kind:F.schedule.kind,timezone:F.schedule.timezone.trim(),...F.schedule.kind===`cron`?{cron:F.schedule.cronExpression.trim()}:F.schedule.kind===`once`?{date:F.schedule.onceDate,time:F.schedule.onceTime}:{times:lf(F.schedule.times),...F.schedule.kind===`weekly`?{weekdays:F.schedule.weekdays}:{}}},execution:{prompt:F.execution.prompt,providerID:F.execution.providerID,modelID:F.execution.modelID,...F.execution.variant.trim()?{variant:F.execution.variant.trim()}:{},...F.execution.agent.trim()?{agent:F.execution.agent.trim()}:{},...F.execution.goalEnabled?{goalEnabled:!0}:{}},...F.state?{state:F.state}:{}};R(!0);try{let e=await i(t);if(a===`panel`){let t=sf(e||n,{providerID:O,modelID:k,variant:A,agent:M});q.current=JSON.stringify(t),I(t),o?.(!1)}else r(!1)}catch(e){yt.error(e instanceof Error?e.message:C(`sessions.scheduledTasks.editor.toast.saveFailed`))}finally{R(!1)}},[M,k,O,A,F,o,r,i,a,C,n]),Le=Q.useId(),Re=Q.useCallback(()=>typeof document>`u`?!1:!!document.querySelector(`[data-slot="dropdown-menu-content"], [data-slot="select-content"]`),[]),ze=C(n?`sessions.scheduledTasks.editor.title.edit`:`sessions.scheduledTasks.editor.title.new`),Be=C(`sessions.scheduledTasks.editor.description`),Ve=(0,$.jsxs)(`div`,{className:Y(`yuri-settings-workspace yuri-settings-page-content yuri-scheduled-task-form`,P?`yuri-settings-workspace-mobile`:`yuri-settings-workspace-desktop`),children:[(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1`,(h||_)&&`hidden`),children:[(0,$.jsx)(ef,{htmlFor:`sched-name`,required:!0,children:C(`sessions.scheduledTasks.editor.taskName.label`)}),(0,$.jsx)(Dn,{id:`sched-name`,value:F.name,onChange:e=>I(t=>({...t,name:e.target.value})),placeholder:C(`sessions.scheduledTasks.editor.taskName.placeholder`),maxLength:80,required:!0,"aria-invalid":!F.name.trim(),className:`yuri-scheduled-task-title w-full`})]}),(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-3 border-t border-border/40 pt-5`,b&&`yuri-settings-group order-4 animate-in fade-in slide-in-from-right-1 border-0 pt-0 duration-200 [animation-delay:80ms] [animation-fill-mode:both] motion-reduce:animate-none`),children:[b?(0,$.jsx)(`h3`,{className:Ed,children:C(`sessions.scheduledTasks.editor.panel.frequency`)}):null,(0,$.jsxs)(`div`,{className:Y(b&&`yuri-settings-group-card`,b&&F.schedule.kind===`once`&&z&&`overflow-visible`),children:[(0,$.jsx)(`div`,{className:Y(`grid grid-cols-1 gap-x-4 gap-y-3`,b&&`flex flex-col gap-0`,!P&&!b&&`sm:grid-cols-2`),children:(0,$.jsxs)(`div`,{className:Y(`flex min-w-0 flex-col gap-1`,b&&[S,`last:border-b`]),children:[(0,$.jsx)(ef,{children:C(`sessions.scheduledTasks.editor.scheduleType.label`)}),(0,$.jsx)(`div`,{"data-settings-value":b?``:void 0,className:Y(b&&`yuri-settings-split-row-control`),children:(0,$.jsxs)(xr,{value:F.schedule.kind,onValueChange:e=>{I(t=>({...t,schedule:{...t.schedule,kind:e,...e===`cron`&&!t.schedule.cronExpression?{cronExpression:`0 * * * *`}:{}}}))},children:[(0,$.jsx)(br,{className:Y(!b&&Md,b&&x),children:(0,$.jsx)(_r,{children:e=>C(e===`daily`?`sessions.scheduledTasks.editor.scheduleType.daily`:e===`weekly`?`sessions.scheduledTasks.editor.scheduleType.weekly`:e===`cron`?`sessions.scheduledTasks.editor.scheduleType.cron`:`sessions.scheduledTasks.editor.scheduleType.once`)})}),(0,$.jsxs)(yr,{className:`motion-reduce:transition-none`,children:[(0,$.jsx)(vr,{value:`daily`,children:C(`sessions.scheduledTasks.editor.scheduleType.daily`)}),(0,$.jsx)(vr,{value:`weekly`,children:C(`sessions.scheduledTasks.editor.scheduleType.weekly`)}),(0,$.jsx)(vr,{value:`once`,children:C(`sessions.scheduledTasks.editor.scheduleType.once`)}),(0,$.jsx)(vr,{value:`cron`,children:C(`sessions.scheduledTasks.editor.scheduleType.cron`)})]})]})})]})}),F.schedule.kind===`cron`?(0,$.jsx)(uf,{draft:F,setDraft:I,locale:w,t:C,panel:h,mobilePanel:v}):F.schedule.kind===`once`?(0,$.jsxs)(`div`,{className:Y(`grid grid-cols-1 gap-x-4 gap-y-3`,b&&`flex flex-col gap-0`,!P&&!b&&`sm:grid-cols-2`),children:[(0,$.jsxs)(`div`,{className:Y(`flex min-w-0 flex-col gap-1`,b&&S),ref:G,children:[(0,$.jsx)(ef,{children:C(`sessions.scheduledTasks.editor.date.label`)}),(0,$.jsxs)(`div`,{"data-settings-value":b?``:void 0,className:Y(`relative`,b&&`yuri-settings-split-row-control`),children:[(0,$.jsxs)(`button`,{type:`button`,className:Y(!b&&Md,`flex items-center justify-between gap-2 text-left`,b&&[x,`w-full`]),onClick:()=>te(e=>!e),children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(Z,{name:`calendar`,className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-foreground`,children:Bd(F.schedule.onceDate,C(`sessions.scheduledTasks.editor.date.placeholder`),w)})]}),(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]}),z?(0,$.jsxs)(`div`,{className:Y(`absolute top-[calc(100%+6px)] z-50 w-[min(288px,calc(100vw-2rem))] animate-in fade-in zoom-in-95 slide-in-from-top-1 rounded-xl border border-border bg-background p-3 shadow-sm duration-150 motion-reduce:animate-none`,v?`right-0`:`left-0`),children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>oe(e=>Vd(e,-1)),"aria-label":C(`sessions.scheduledTasks.editor.date.previousMonth`),disabled:Ee,children:(0,$.jsx)(Z,{name:`arrow-left-s`,className:`h-4 w-4`})}),(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:new Intl.DateTimeFormat(w,{month:`long`,year:`numeric`}).format(ae)}),(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover`,onClick:()=>oe(e=>Vd(e,1)),"aria-label":C(`sessions.scheduledTasks.editor.date.nextMonth`),children:(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-4 w-4`})})]}),(0,$.jsx)(`div`,{className:`mb-1 grid grid-cols-7 gap-1 px-1`,children:De.map((e,t)=>(0,$.jsx)(`div`,{className:`py-1 text-center typography-micro text-muted-foreground`,children:e},`${e}-${t}`))}),(0,$.jsx)(`div`,{className:`grid grid-cols-7 gap-1`,children:Hd(ae,he).map(({date:e,inCurrentMonth:t})=>{let n=zd(e),r=n===F.schedule.onceDate,i=af(e,Ce),a=e.getTime()<Ce.getTime();return(0,$.jsx)(`button`,{type:`button`,onClick:()=>{a||(Oe(n),te(!1))},disabled:a,className:[`h-8 rounded-md typography-ui-label`,r?`bg-interactive-selection text-interactive-selection-foreground`:a?`text-muted-foreground/40`:t?`text-foreground hover:bg-interactive-hover`:`text-muted-foreground/60 hover:bg-interactive-hover`,i&&!r?`ring-1 ring-inset ring-interactive-focusRing bg-interactive-hover/50`:``,a?`cursor-not-allowed opacity-45`:``].join(` `),children:e.getDate()},n)})}),(0,$.jsxs)(`div`,{className:`mt-2 flex items-center justify-between border-t border-border pt-2`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:Te||``}),(0,$.jsx)(X,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>{Oe(zd(Ce)),oe(new Date(Ce.getFullYear(),Ce.getMonth(),1))},children:C(`sessions.scheduledTasks.editor.date.jumpToToday`)})]})]}):null]})]}),(0,$.jsxs)(`div`,{className:Y(`flex min-w-0 flex-col gap-1`,b&&S),children:[(0,$.jsx)(ef,{children:C(`sessions.scheduledTasks.editor.time.label`)}),(0,$.jsx)(`div`,{"data-settings-value":b?``:void 0,className:Y(b&&`yuri-settings-split-row-control`),children:(0,$.jsx)(tf,{value:F.schedule.onceTime,className:Y(b&&`yuri-settings-inline-value w-fit min-w-0 justify-end`),use24Hour:me,hourAriaLabel:C(`sessions.scheduledTasks.editor.time.hourAria`),minuteAriaLabel:C(`sessions.scheduledTasks.editor.time.minuteAria`),periodAriaLabel:C(`sessions.scheduledTasks.editor.time.periodAria`),amLabel:C(`sessions.scheduledTasks.editor.time.period.am`),pmLabel:C(`sessions.scheduledTasks.editor.time.period.pm`),onChange:e=>I(t=>({...t,schedule:{...t.schedule,onceTime:e}}))})})]})]}):(0,$.jsxs)(`div`,{className:Y(`grid grid-cols-1 gap-x-4 gap-y-3`,b&&`flex flex-col gap-0`,!P&&!b&&`sm:grid-cols-2`),children:[F.schedule.kind===`weekly`?(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1`,b&&[`yuri-settings-group-row border-b border-[var(--yuri-settings-row-divider)] last:border-b-0`,`yuri-settings-split-row`],!P&&!b&&`sm:col-span-2`),children:[(0,$.jsx)(ef,{children:C(`sessions.scheduledTasks.editor.weekdays.label`)}),(0,$.jsx)(`div`,{"data-settings-value":b?``:void 0,className:Y(`flex flex-wrap gap-x-3 gap-y-2`,b&&`yuri-settings-split-row-control justify-end`),children:ge.map(e=>{let t=F.schedule.weekdays.includes(e.value);return(0,$.jsxs)(`div`,{className:[`group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta`,t?`text-foreground`:`text-muted-foreground`].join(` `),children:[(0,$.jsx)(xn,{checked:t,onChange:t=>ve(e.value,t),ariaLabel:e.label}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>ve(e.value,!t),className:`group-hover:text-foreground`,children:e.label})]},e.value)})})]}):null,(0,$.jsxs)(`div`,{className:Y(`flex min-w-0 flex-col gap-2`,b&&[S,`justify-start`],v&&`flex-col items-stretch`),children:[(0,$.jsx)(ef,{children:C(`sessions.scheduledTasks.editor.times.label`)}),(0,$.jsxs)(`div`,{"data-settings-value":b?``:void 0,className:Y(b?`yuri-settings-split-row-control relative flex-wrap justify-end`:`contents`),children:[(0,$.jsx)(`div`,{className:Y(`flex flex-col gap-2`,b&&`flex-row flex-wrap justify-end transition-[padding] motion-reduce:transition-none`,h&&`group-hover:pr-8`),children:F.schedule.times.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(tf,{value:e,className:Y(b&&`yuri-settings-inline-value w-fit min-w-0`),use24Hour:me,hourAriaLabel:C(`sessions.scheduledTasks.editor.time.hourAria`),minuteAriaLabel:C(`sessions.scheduledTasks.editor.time.minuteAria`),periodAriaLabel:C(`sessions.scheduledTasks.editor.time.periodAria`),amLabel:C(`sessions.scheduledTasks.editor.time.period.am`),pmLabel:C(`sessions.scheduledTasks.editor.time.period.pm`),onChange:e=>ye(t,e)}),F.schedule.times.length>1?(0,$.jsx)(X,{type:`button`,size:`icon`,variant:`ghost`,onClick:()=>xe(t),"aria-label":C(`sessions.scheduledTasks.editor.times.removeAria`),children:(0,$.jsx)(Z,{name:`close`,className:`h-4 w-4`})}):null]},t))}),(0,$.jsx)(`div`,{className:Y(b&&`shrink-0`,h&&`absolute right-0`),children:(0,$.jsxs)(X,{type:`button`,size:b?`icon`:`sm`,variant:b?`ghost`:`outline`,className:Y(`h-9`,h&&`size-7 opacity-0 transition-opacity group-hover:opacity-100 focus-visible:opacity-100 motion-reduce:transition-none`,v&&`size-9`),onClick:Se,"aria-label":C(`sessions.scheduledTasks.editor.times.add`),children:[(0,$.jsx)(Z,{name:`add`,className:Y(`h-4 w-4`,!b&&`mr-1`)}),b?null:C(`sessions.scheduledTasks.editor.times.add`)]})})]})]})]})]})]}),(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-3 border-t border-border/40 pt-5`,b&&`contents`),children:[(0,$.jsxs)(`div`,{className:Y(b?`yuri-settings-group order-2`:`contents`),children:[b?(0,$.jsx)(`h3`,{className:Ed,children:C(`sessions.scheduledTasks.editor.panel.details`)}):null,(0,$.jsxs)(`div`,{className:Y(`grid grid-cols-1 gap-x-4 gap-y-3`,b&&[`flex flex-col gap-0 animate-in fade-in slide-in-from-right-1 duration-200 [animation-delay:40ms] [animation-fill-mode:both] motion-reduce:animate-none`,`yuri-settings-group-card`],!P&&!b&&`sm:grid-cols-2`),children:[p.length>0?(0,$.jsxs)(`div`,{className:Y(`flex min-w-0 flex-col gap-1`,b&&S),children:[(0,$.jsx)(ef,{children:C(`sessions.scheduledTasks.dialog.project.label`)}),(0,$.jsx)(`div`,{"data-settings-value":b?``:void 0,className:Y(b&&`yuri-settings-split-row-control`),children:(0,$.jsxs)(xr,{value:f,disabled:!m,onValueChange:m,children:[(0,$.jsx)(br,{className:Y(!b&&Md,b&&x),children:(0,$.jsx)(_r,{children:e=>p.find(t=>t.id===e)?.label})}),(0,$.jsx)(yr,{className:`motion-reduce:transition-none`,children:p.map(e=>(0,$.jsx)(vr,{value:e.id,children:e.label},e.id))})]})})]}):null,(0,$.jsxs)(`div`,{className:Y(`flex min-w-0 flex-col gap-1`,b&&S),children:[(0,$.jsx)(ef,{required:!0,children:C(`sessions.scheduledTasks.editor.model.label`)}),(0,$.jsx)(`div`,{"data-settings-value":b?``:void 0,className:Y(b&&`yuri-settings-split-row-control`),children:(0,$.jsx)(_i,{providerId:F.execution.providerID,modelId:F.execution.modelID,variant:F.execution.variant,className:Y(!b&&Md,b&&x,`[&>div]:min-w-0 [&>div]:flex-1 [&_span]:truncate`),showIcon:!h,onChange:(e,t,n=``)=>{I(r=>({...r,execution:{...r.execution,providerID:e,modelID:t,variant:n}}))}})})]}),b?(0,$.jsxs)(`div`,{className:S,children:[(0,$.jsx)(ef,{children:C(`sessions.scheduledTasks.editor.agent.label`)}),(0,$.jsx)(`div`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,$.jsx)(xi,{agentName:F.execution.agent,className:Y(x,`[&>div]:min-w-0 [&>div]:flex-1 [&_span]:truncate`),showIcon:!0,filter:e=>At(e.mode),onChange:e=>I(t=>({...t,execution:{...t.execution,agent:e}}))})})]}):null,b?(0,$.jsxs)(`label`,{className:Y(S,`cursor-pointer`),children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:C(`sessions.scheduledTasks.editor.goal.label`)}),(0,$.jsx)(`span`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,$.jsx)(xn,{checked:F.execution.goalEnabled,onChange:e=>I(t=>({...t,execution:{...t.execution,goalEnabled:e}})),ariaLabel:C(`sessions.scheduledTasks.editor.goal.aria`)})})]}):null]})]}),b?null:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,$.jsx)(ef,{children:C(`sessions.scheduledTasks.editor.agent.label`)}),(0,$.jsx)(xi,{agentName:F.execution.agent,className:Y(Md,`[&>div]:min-w-0 [&>div]:flex-1 [&_span]:truncate`),filter:e=>At(e.mode),onChange:e=>I(t=>({...t,execution:{...t.execution,agent:e}}))})]}),(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1`,b&&`order-1`),children:[(0,$.jsx)(`div`,{className:Y(b&&`sr-only`),children:(0,$.jsx)(ef,{htmlFor:`sched-prompt`,required:!0,children:C(`sessions.scheduledTasks.editor.prompt.label`)})}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(Zr,{id:`sched-prompt`,ref:K,value:F.execution.prompt,onChange:e=>{let t=e.target.value;Ae(t);let n=e.target.selectionStart??t.length;ke(t,n)},onKeyDown:Fe,rows:8,outerClassName:`h-64 min-h-32`,placeholder:C(`sessions.scheduledTasks.editor.prompt.placeholder`),className:Y(`typography-meta min-h-0 overflow-y-auto`,b&&`px-4 pt-4 text-base placeholder:text-muted-foreground/65`)}),re?(0,$.jsx)(Tn,{ref:ce,searchQuery:W,onCommandSelect:Pe,onClose:()=>U(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,B?(0,$.jsx)(wn,{ref:se,searchQuery:H,onFileSelect:je,onAgentSelect:Ne,onSkillSelect:e=>Ne(e.name),onClose:()=>V(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null]})]}),b?null:(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-8 gap-y-2`,children:(0,$.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-2`,children:[(0,$.jsx)(xn,{checked:F.execution.goalEnabled,onChange:e=>I(t=>({...t,execution:{...t.execution,goalEnabled:e}})),ariaLabel:C(`sessions.scheduledTasks.editor.goal.aria`)}),(0,$.jsx)(`span`,{className:`typography-meta`,children:C(`sessions.scheduledTasks.editor.goal.label`)})]})})]})]}),He=(0,$.jsxs)(`div`,{className:Y(`flex flex-wrap items-center justify-between gap-3`,a===`panel`&&`justify-end`,y&&`flex-nowrap gap-2`),children:[(0,$.jsxs)(`label`,{className:Y(`inline-flex items-center gap-2`,a===`panel`&&`hidden`),children:[(0,$.jsx)(xn,{checked:F.enabled,onChange:e=>I(t=>({...t,enabled:e})),ariaLabel:C(`sessions.scheduledTasks.editor.enabled.aria`)}),(0,$.jsx)(`span`,{className:`typography-meta`,children:C(`sessions.scheduledTasks.editor.enabled.label`)})]}),(0,$.jsxs)(`div`,{className:Y(`flex flex-wrap items-center justify-end gap-2`,y&&`ml-auto flex-nowrap`),children:[a!==`panel`&&!y?(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>r(!1),disabled:L,children:C(`sessions.scheduledTasks.editor.actions.cancel`)}):null,(0,$.jsx)(X,{type:`button`,size:`sm`,className:Y(a===`panel`&&`rounded-lg`,y&&`min-h-11 px-5`),onClick:Ie,disabled:L,children:C(L?`sessions.scheduledTasks.editor.actions.saving`:n?`sessions.scheduledTasks.editor.actions.save`:`sessions.scheduledTasks.dialog.actions.create`)})]})]}),Ue=!!(n&&c),We=n&&l&&s?(0,$.jsxs)(Pn,{children:[(0,$.jsx)(Hn,{asChild:!0,children:(0,$.jsx)(X,{type:`button`,variant:_?`mobileGlass`:`ghost`,size:_?`mobileIcon`:`icon`,className:Y(!_&&`rounded-lg`,!_&&(P?`size-11`:`size-8`)),disabled:L||d,"aria-label":C(`sessions.scheduledTasks.dialog.actions.moreAria`,{taskName:n.name}),children:(0,$.jsx)(Z,{name:`more-2`,className:_?`size-5`:`size-4`})})}),(0,$.jsxs)(Nn,{align:`end`,className:`min-w-40 motion-reduce:transition-none`,children:[(0,$.jsxs)(Fn,{className:Y(_&&`min-h-11`),onSelect:()=>void s(n),children:[(0,$.jsx)(Z,{name:`play`,className:`size-4`}),C(`sessions.scheduledTasks.dialog.actions.runNow`)]}),Ue?(0,$.jsxs)(Fn,{className:Y(_&&`min-h-11`),onSelect:()=>c?.(n),children:[(0,$.jsx)(Z,{name:`history`,className:`size-4`}),C(`sessions.scheduledTasks.workspace.views.history`)]}):null,u?(0,$.jsxs)(Fn,{className:Y(_&&`min-h-11`),onSelect:()=>void u(n,!n.enabled),children:[(0,$.jsx)(Z,{name:n.enabled?`pause`:`play`,className:`size-4`}),n.enabled?C(`sessions.scheduledTasks.dialog.taskToggle.pauseAria`,{taskName:n.name}):C(`sessions.scheduledTasks.dialog.taskToggle.enableAria`,{taskName:n.name})]}):null,(0,$.jsxs)(Fn,{variant:`destructive`,className:Y(_&&`min-h-11`),onSelect:()=>void l(n),children:[(0,$.jsx)(Z,{name:`delete-bin`,className:`size-4`}),C(`sessions.scheduledTasks.dialog.actions.delete`)]})]})]}):null;return a===`panel`?t?(0,$.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-labelledby":`scheduled-task-panel-title`,children:[(0,$.jsxs)(`header`,{className:`shrink-0 animate-in fade-in slide-in-from-right-1 px-6 pb-4 pt-5 duration-200 motion-reduce:animate-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:Y(`typography-meta font-medium`,n?.enabled?`text-[var(--status-info)]`:`text-muted-foreground`),children:n?n.enabled?C(`sessions.scheduledTasks.dialog.taskToggle.enabled`):C(`sessions.scheduledTasks.dialog.taskToggle.paused`):ze}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[We,n&&u?(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,className:Y(`rounded-lg`,P?`size-11`:`size-8`),disabled:L||d,onClick:()=>void u(n,!n.enabled),"aria-label":n.enabled?C(`sessions.scheduledTasks.dialog.taskToggle.pauseAria`,{taskName:n.name}):C(`sessions.scheduledTasks.dialog.taskToggle.enableAria`,{taskName:n.name}),children:(0,$.jsx)(Z,{name:n.enabled?`pause`:`play`,className:`size-4`})}):null,(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,className:Y(`rounded-lg`,P?`size-11`:`size-8`),onClick:()=>r(!1),"aria-label":C(`sessions.scheduledTasks.editor.actions.cancel`),children:(0,$.jsx)(Z,{name:P?`arrow-left`:`close`,className:`size-4`})})]})]}),(0,$.jsx)(`h2`,{id:`scheduled-task-panel-title`,className:`sr-only`,children:ze}),(0,$.jsx)(Dn,{value:F.name,onChange:e=>I(t=>({...t,name:e.target.value})),placeholder:C(`sessions.scheduledTasks.editor.taskName.placeholder`),"aria-label":C(`sessions.scheduledTasks.editor.taskName.label`),maxLength:80,required:!0,"aria-invalid":!F.name.trim(),className:`yuri-scheduled-task-title mt-1 !h-9 !min-h-9 border-0 bg-transparent px-0 text-lg font-semibold shadow-none ring-0 hover:!bg-transparent focus:!bg-transparent focus:ring-0`})]}),(0,$.jsx)(Xr,{className:`min-h-0 flex-1 overflow-auto [scrollbar-gutter:stable]`,size:64,hideTopShadow:!0,children:(0,$.jsx)(`div`,{className:`px-6 pb-6 pt-2`,children:Ve})}),(0,$.jsx)(`footer`,{className:`shrink-0 border-t border-border/50 bg-background/95 px-6 py-3 backdrop-blur-sm`,children:He})]}):null:a===`mobile-panel`?t?(0,$.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col bg-background`,"aria-label":ze,children:[(0,$.jsx)(Xr,{className:`min-h-0 flex-1 overflow-y-auto overflow-x-hidden`,size:48,hideTopShadow:!0,children:(0,$.jsx)(`div`,{className:`w-full px-3 pb-6 pt-4`,children:Ve})}),(0,$.jsx)(`footer`,{className:`shrink-0 border-t border-border/50 bg-background/95 px-3 py-2 backdrop-blur-sm`,children:He})]}):null:a===`mobile-tab`?t?(0,$.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-label":ze,children:[(0,$.jsx)(Me,{sticky:!0,title:ze,backAriaLabel:C(`header.actions.backAria`),onBack:()=>r(!1),backDisabled:L,trailing:[(0,$.jsx)(X,{type:`button`,size:`mobileIcon`,onClick:Ie,disabled:L,"aria-label":C(L?`sessions.scheduledTasks.editor.actions.saving`:n?`sessions.scheduledTasks.editor.actions.save`:`sessions.scheduledTasks.dialog.actions.create`),"aria-busy":L,children:(0,$.jsx)(Z,{name:L?`loader-4`:`check`,className:Y(`size-5`,L&&`animate-spin motion-reduce:animate-none`)})},`save`),We?(0,$.jsx)(Q.Fragment,{children:We},`more`):null]}),(0,$.jsxs)(`div`,{className:`yuri-mobile-scheduled-editor-body min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-[var(--yuri-mobile-page-inline-inset)] pt-4`,children:[(0,$.jsxs)(`div`,{className:`mb-5 flex items-center gap-4`,children:[(0,$.jsx)(Dn,{value:F.name,onChange:e=>I(t=>({...t,name:e.target.value})),placeholder:C(`sessions.scheduledTasks.editor.taskName.placeholder`),"aria-label":C(`sessions.scheduledTasks.editor.taskName.label`),maxLength:80,required:!0,"aria-invalid":!F.name.trim(),className:`yuri-scheduled-task-title yuri-mobile-detail-editor-title min-w-0 flex-1 !h-auto min-h-0 border-0 bg-transparent px-0 py-0 text-xl font-semibold shadow-none ring-0 hover:!bg-transparent focus:!bg-transparent focus:ring-0`}),(0,$.jsx)(gi,{checked:F.enabled,onCheckedChange:e=>I(t=>({...t,enabled:e})),disabled:L,"aria-label":C(`sessions.scheduledTasks.editor.enabled.aria`)})]}),Ve]})]}):null:P?(0,$.jsx)(Mn,{open:t,title:ze,onClose:()=>r(!1),contentMaxHeightClassName:`max-h-[min(80vh,640px)]`,renderHeader:e=>(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border/40 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:ze}),e]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:Be})]}),footer:He,children:Ve}):(0,$.jsx)(qt,{open:t,onOpenChange:e=>{!e&&Re()||r(e)},children:(0,$.jsxs)(Wt,{"aria-describedby":Le,className:`!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden`,children:[(0,$.jsx)(Kt,{id:Le,className:`sr-only`,children:Be}),(0,$.jsx)(`header`,{className:`shrink-0 px-4 sm:px-6 pt-5 pb-3`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl`,children:[(0,$.jsx)(Gt,{className:`typography-ui-label font-medium text-foreground`,children:ze}),(0,$.jsx)(`p`,{className:`typography-meta mt-0.5 text-muted-foreground`,children:Be})]})}),(0,$.jsx)(Xr,{className:`flex-1 min-h-0 overflow-auto [scrollbar-gutter:stable_both-edges]`,size:64,hideTopShadow:!0,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-2xl px-4 sm:px-6 pb-5`,children:Ve})}),(0,$.jsx)(`div`,{className:`shrink-0 px-4 sm:px-6 py-3`,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-2xl`,children:He})})]})})}function ff(e){return Gd(e,{min:0,max:23})}function pf(e,t){return Gd(String(Number.parseInt(e,10)+t),{min:0,max:23,loop:!0})}function mf(e,t){let n=Number(e),r=Number(t),i=Number.isFinite(n)?Math.min(23,Math.max(0,n)):0,a=Number.isFinite(r)?Math.min(59,Math.max(0,r)):0;return`${String(i).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`}var hf=e=>{if(!e.enabled)return null;let t=Ai(e.assistants).pinned[0]??e.assistants[0];return t?{id:t.id,name:t.name,seed:t.avatarSeed??t.id}:null};function gf(e){let t=(0,qi.c)(20),{assistant:n}=e,{t:r}=be(),[i,a]=Q.useState(!0),o=i?`true`:`false`,s;t[0]!==n.name||t[1]!==r?(s=r(`sessions.scheduledTasks.assistant.openAria`,{name:n.name}),t[0]=n.name,t[1]=r,t[2]=s):s=t[2];let c;t[3]===n.id?c=t[4]:(c=()=>St.getState().openAssistant(n.id),t[3]=n.id,t[4]=c);let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=e=>{e.target===e.currentTarget&&e.animationName===`yuri-schedule-assistant-clip`&&a(!1)},t[5]=l):l=t[5];let u;t[6]!==n.id||t[7]!==n.seed||t[8]!==i?(u=(0,$.jsx)(`span`,{className:`yuri-mobile-schedule-assistant-face`,"aria-hidden":`true`,children:(0,$.jsx)(Ft,{seed:n.seed,size:40,motion:`idle`,animateIdle:i,followPointer:!1,animationKey:n.id,blinkOnMount:2})}),t[6]=n.id,t[7]=n.seed,t[8]=i,t[9]=u):u=t[9];let d;t[10]===r?d=t[11]:(d=r(`sessions.scheduledTasks.assistant.offer`),t[10]=r,t[11]=d);let f;t[12]===d?f=t[13]:(f=(0,$.jsx)(`span`,{className:`yuri-mobile-schedule-assistant-label`,"aria-hidden":`true`,children:d}),t[12]=d,t[13]=f);let p;return t[14]!==o||t[15]!==s||t[16]!==c||t[17]!==u||t[18]!==f?(p=(0,$.jsx)(`span`,{className:`yuri-mobile-schedule-assistant-anchor`,children:(0,$.jsxs)(X,{type:`button`,variant:`ghost`,size:`mobileIcon`,className:`yuri-mobile-schedule-assistant`,"data-visiting":o,"aria-label":s,onClick:c,onAnimationEnd:l,children:[u,f]})}),t[14]=o,t[15]=s,t[16]=c,t[17]=u,t[18]=f,t[19]=p):p=t[19],p}function _f(){let e=(0,qi.c)(2),{data:t}=Ne(hf),n;return e[0]===t?n=e[1]:(n=t?(0,$.jsx)(gf,{assistant:t},t.id):null,e[0]=t,e[1]=n),n}var vf=Q.memo(function(e){let t=(0,qi.c)(3),{active:n}=e,r=St(yf),i;return t[0]!==n||t[1]!==r?(i=n&&r?(0,$.jsx)(_f,{}):null,t[0]=n,t[1]=r,t[2]=i):i=t[2],i});function yf(e){return e.activeTab===`scheduled`&&e.secondary===null}var bf=e=>{let t=(Array.isArray(e.schedule.times)?e.schedule.times:e.schedule.time?[e.schedule.time]:[]).filter(e=>typeof e==`string`&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(e));return Array.from(new Set(t)).sort((e,t)=>e.localeCompare(t))},xf=(e,t,n=!0)=>{let r=bf(e).join(`, `)||`--:--`,i=e=>t(e===0?`sessions.scheduledTasks.dialog.schedule.weekdayShort.sun`:e===1?`sessions.scheduledTasks.dialog.schedule.weekdayShort.mon`:e===2?`sessions.scheduledTasks.dialog.schedule.weekdayShort.tue`:e===3?`sessions.scheduledTasks.dialog.schedule.weekdayShort.wed`:e===4?`sessions.scheduledTasks.dialog.schedule.weekdayShort.thu`:e===5?`sessions.scheduledTasks.dialog.schedule.weekdayShort.fri`:e===6?`sessions.scheduledTasks.dialog.schedule.weekdayShort.sat`:`sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown`);if(e.schedule.kind===`daily`)return n&&e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.dailyWithTimezone`,{time:r,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.daily`,{time:r});if(e.schedule.kind===`weekly`){let a=Array.isArray(e.schedule.weekdays)?e.schedule.weekdays.map(e=>i(e)).join(`, `):``;return n&&e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone`,{days:a,time:r,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.weekly`,{days:a,time:r})}if(e.schedule.kind===`once`){let r=typeof e.schedule.date==`string`&&e.schedule.date.trim().length>0?e.schedule.date:t(`sessions.scheduledTasks.dialog.schedule.unknownDate`),i=typeof e.schedule.time==`string`&&e.schedule.time.trim().length>0?e.schedule.time:`--:--`;return n&&e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.onceWithTimezone`,{date:r,time:i,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.once`,{date:r,time:i})}return n&&e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.cronWithTimezone`,{cron:e.schedule.cron||``,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.cron`,{cron:e.schedule.cron||``})},Sf=(e,t)=>{if(!e||!Number.isFinite(e))return``;let n=e-Date.now(),r=Math.abs(n),i=6e4,a=60*i,o=24*a,s=n>=0;if(r<i)return t(s?`sessions.scheduledTasks.dialog.relativeTime.inLessThanOneMinute`:`sessions.scheduledTasks.dialog.relativeTime.justNow`);if(r<a){let e=Math.round(r/i);return t(s?`sessions.scheduledTasks.dialog.relativeTime.inMinutes`:`sessions.scheduledTasks.dialog.relativeTime.minutesAgo`,{count:e})}if(r<o){let e=Math.floor(r/a),n=Math.round(r%a/i),o=n>0?`${e}h ${n}m`:`${e}h`;return t(s?`sessions.scheduledTasks.dialog.relativeTime.inDuration`:`sessions.scheduledTasks.dialog.relativeTime.durationAgo`,{duration:o})}let c=Math.floor(r/o),l=Math.round(r%o/a),u=l>0?`${c}d ${l}h`:`${c}d`;return t(s?`sessions.scheduledTasks.dialog.relativeTime.inDuration`:`sessions.scheduledTasks.dialog.relativeTime.durationAgo`,{duration:u})},Cf=e=>new Intl.DateTimeFormat(Ce(),{month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}).format(new Date(e)),wf=(e,t)=>{if(e.status===`running`)return Math.max(0,t-e.startedAt);if(typeof e.finishedAt==`number`&&Number.isFinite(e.finishedAt)){let t=Math.max(0,e.finishedAt-e.startedAt);return typeof e.durationMs==`number`&&Number.isFinite(e.durationMs)&&e.durationMs>=0?Math.max(e.durationMs,t):t}return typeof e.durationMs==`number`&&Number.isFinite(e.durationMs)&&e.durationMs>=0?e.durationMs:null},Tf=e=>{if(e===null||!Number.isFinite(e)||e<0)return null;if(e<1e3)return`<1s`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;if(n<60)return r>0?`${n}m ${r}s`:`${n}m`;let i=Math.floor(n/60),a=n%60;return a>0?`${i}h ${a}m`:`${i}h`},Ef={success:{tone:`success`,Icon:`checkbox-circle`},error:{tone:`error`,Icon:`error-warning`},running:{tone:`warning`,Icon:`loader-4`,spin:!0},idle:{tone:`muted`,Icon:`pulse`}},Df=e=>e===`muted`?{}:{color:`var(--status-${e})`,backgroundColor:`var(--status-${e}-background)`,borderColor:`var(--status-${e}-border)`},Of=({projectId:e,taskId:t})=>`${e}:${t}`,kf=null,Af=()=>kf?kf():(j.getState().setScheduledTasksDialogOpen(!1),!0),jf=(e,t,n)=>({tasks:[...e?.tasks.filter(e=>e.projectId!==t)??[],...n.map(e=>({projectId:t,task:e}))],failedProjectIds:e?.failedProjectIds.filter(e=>e!==t)??[]});function Mf(){let e=(0,qi.c)(22),{t}=be(),n=j(If),r=j(Ff),i=j(Pf),a,o;if(e[0]!==i||e[1]!==r?(a=()=>{if(!i)return;let e=e=>{let t=Zn();t.tab===`schedule`&&t.scheduleProjectId&&t.scheduleTaskId?r(!0):e&&t.tab!==`schedule`&&r(!1)};return e(),window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},o=[i,r],e[0]=i,e[1]=r,e[2]=a,e[3]=o):(a=e[2],o=e[3]),Q.useEffect(a,o),!i)return null;let s;e[4]===t?s=e[5]:(s=t(`sessions.scheduledTasks.dialog.title`),e[4]=t,e[5]=s);let c;e[6]===t?c=e[7]:(c=t(`sessions.scheduledTasks.dialog.title`),e[6]=t,e[7]=c);let l;e[8]===t?l=e[9]:(l=t(`mobile.surface.closeAria`),e[8]=t,e[9]=l);let u;e[10]===t?u=e[11]:(u=t(`mobile.sessions.sheet.resizeAria`),e[10]=t,e[11]=u);let d;e[12]!==n||e[13]!==r?(d=(0,$.jsx)(Lf,{presentation:`mobile-panel`,open:n,onOpenChange:r}),e[12]=n,e[13]=r,e[14]=d):d=e[14];let f;return e[15]!==n||e[16]!==s||e[17]!==c||e[18]!==l||e[19]!==u||e[20]!==d?(f=(0,$.jsx)(dr,{id:`scheduled-tasks`,open:n,initiallyExpanded:!0,title:s,ariaLabel:c,closeAriaLabel:l,resizeAriaLabel:u,onOpenChange:Nf,children:d}),e[15]=n,e[16]=s,e[17]=c,e[18]=l,e[19]=u,e[20]=d,e[21]=f):f=e[21],f}function Nf(e){e||Af()}function Pf(e){return e.isMobile}function Ff(e){return e.setScheduledTasksDialogOpen}function If(e){return e.isScheduledTasksDialogOpen}function Lf({presentation:e=`workspace`,open:t=!0,onOpenChange:n,registerEditorBackHandler:r,onEditorActiveChange:i}={}){let{t:a}=be(),o=V.runtime()[0],s=Q.useMemo(()=>[o,`scheduled-tasks`],[o]),c=Q.useMemo(()=>[o,`scheduled-task-runs`],[o]),l=Vt(),u=j(e=>e.isMobile),d=j(e=>e.scheduledTaskOpenRequest),f=j(e=>e.isScheduledTasksDialogOpen),p=j(e=>e.setMainTabGuard),m=ct(e=>e.projects),h=ct(e=>e.getActiveProject())?.id||m[0]?.id||``,[g,_]=Q.useState(h),[v,y]=Q.useState(()=>{if(u&&e!==`mobile-panel`)return null;let t=Zn();return t.scheduleProjectId&&t.scheduleTaskId?{projectId:t.scheduleProjectId,taskId:t.scheduleTaskId}:null}),[b,x]=Q.useState(()=>v?`edit`:`closed`),[S,C]=Q.useState(`all`),[w,T]=Q.useState(()=>Zn().scheduleView===`history`?`history`:`tasks`),[E,D]=Q.useState(``),[O,k]=Q.useState(!1),A=Q.useRef(!1),M=J(e=>{A.current=e,k(e)}),[N,ee]=Q.useState(null),[P,F]=Q.useState(null),[I,R]=Q.useState(null),[H,ne]=Q.useState(null),re=Q.useRef(null),[U,W]=Q.useState(null),ie=Q.useRef(null),oe=Q.useRef(null),G=e===`mobile-tab`,K=e===`mobile-panel`||G,se=J(e=>{W(G?e?.closest(`[role="tabpanel"]`)??null:e)});Q.useEffect(()=>{if(G)return i?.(b!==`closed`),()=>i?.(!1)},[b,G,i]),Q.useEffect(()=>{if(!t)return;let r=t=>{let r=Zn();if(r.tab===`schedule`){if(u&&e!==`mobile-panel`&&r.scheduleTaskId){y(null),x(`closed`),M(!1);return}let t=r.scheduleView===`history`?`history`:`tasks`;T(e=>e===t?e:t);let n=r.scheduleProjectId&&r.scheduleTaskId?{projectId:r.scheduleProjectId,taskId:r.scheduleTaskId}:null;y(n),x(n?`edit`:`closed`),M(!1)}else t&&e===`mobile-panel`&&n?.(!1)};return r(),window.addEventListener(`popstate`,r),()=>window.removeEventListener(`popstate`,r)},[t,u,e,n,M]),Q.useEffect(()=>{!t||!d||u&&e!==`mobile-panel`&&f||(y(d),x(`edit`),T(`tasks`),M(!1),j.getState().setScheduledTaskOpenRequest(null))},[t,d,u,e,f,M]),Q.useEffect(()=>{m.some(e=>e.id===g)||_(h)},[g,h,m]);let ce=z({queryKey:s,enabled:t,refetchOnMount:`always`,queryFn:Oe,select:e=>({...e,tasks:[...e.tasks].sort((e,t)=>e.task.enabled===t.task.enabled?e.task.name.localeCompare(t.task.name):e.task.enabled?-1:1)})}),q=Q.useMemo(()=>ce.data?.tasks??[],[ce.data]),le=ce.data?.failedProjectIds??[],ue=Q.useMemo(()=>v?q.find(({projectId:e,task:t})=>e===v.projectId&&t.id===v.taskId)??null:null,[v,q]),de=ue?.task??null,fe=te({queryKey:[...c,H?.projectId??``,H?.taskId??``],enabled:t&&w===`history`,initialPageParam:void 0,queryFn:({pageParam:e,signal:t})=>Ae({before:e,limit:20,...H?{projectId:H.projectId,taskId:H.taskId}:{}},t),getNextPageParam:e=>e.complete?void 0:e.nextCursor??void 0,refetchOnMount:`always`}),pe=t&&w===`history`&&b===`closed`&&!!U&&fe.hasNextPage&&!fe.isFetching&&!fe.error;ve(pe?re:null,J(e=>{pe&&e.some(e=>e.isIntersecting)&&fe.fetchNextPage({cancelRefetch:!1})}),{root:U,rootMargin:`0px 0px 240px 0px`});let me=Q.useMemo(()=>{let e=new Set,t=[];for(let n of fe.data?.pages??[])for(let r of n.runs)e.has(r.id)||(e.add(r.id),t.push(r));return t},[fe.data]),he=Q.useMemo(()=>me.some(e=>e.status===`running`),[me]),ge=Q.useMemo(()=>{if(!H)return null;let e=q.find(({projectId:e,task:t})=>e===H.projectId&&t.id===H.taskId);return e?.task.name?e.task.name:me.find(e=>e.projectId===H.projectId&&e.taskId===H.taskId)?.taskName||H.taskId},[H,me,q]),[_e,ye]=Q.useState(()=>Date.now());Q.useEffect(()=>{if(!t||w!==`history`||!he)return;ye(Date.now());let e=window.setInterval(()=>ye(Date.now()),1e3);return()=>window.clearInterval(e)},[he,t,w]);let Se=Q.useMemo(()=>new Map(m.map(e=>[e.id,e])),[m]);Q.useEffect(()=>{let e=null,t=_t(t=>{(t.type===`scheduled-task-ran`||t.type===`event-stream-ready`)&&(e&&clearTimeout(e),e=setTimeout(()=>{B.invalidateQueries({queryKey:s,exact:!0}),B.invalidateQueries({queryKey:c})},400))});return()=>{e&&clearTimeout(e),t()}},[s,c]);let Ce=L({mutationFn:({projectID:e,taskDraft:t})=>De(e,t),onSuccess:(e,{projectID:t})=>{B.setQueryData(s,n=>jf(n,t,e))}}),we=L({mutationFn:({projectID:e,taskID:t})=>ke(e,t),onSuccess:(e,{projectID:t})=>{B.setQueryData(s,n=>jf(n,t,e))}}),Te=L({mutationFn:({projectID:e,taskID:t})=>je(e,t),onSuccess:()=>{B.invalidateQueries({queryKey:s,exact:!0}),B.invalidateQueries({queryKey:c})}}),Ee=L({mutationFn:({projectID:e,task:t})=>De(e,t),onMutate:({projectID:e,task:t})=>{let n=B.getQueryData(s);return B.setQueryData(s,n=>n&&{...n,tasks:n.tasks.map(n=>n.projectId===e&&n.task.id===t.id?{projectId:e,task:t}:n)}),{previousTasks:n}},onSuccess:(e,{projectID:t})=>{B.setQueryData(s,n=>jf(n,t,e))},onError:(e,t,n)=>{n?.previousTasks&&B.setQueryData(s,n.previousTasks)}}),Me=J(()=>!A.current||window.confirm(a(`sessions.scheduledTasks.workspace.confirm.discardChanges`)));Q.useEffect(()=>{if(!O){p(null);return}let e=e=>e===`schedule`||window.confirm(a(`sessions.scheduledTasks.workspace.confirm.discardChanges`));return p(e),()=>{j.getState().mainTabGuard===e&&p(null)}},[O,p,a]);let Ne=J(t=>{let n={projectId:t.projectId,taskId:t.task.id};if((Of(n)!==(v?Of(v):``)||b!==`edit`)&&Me()){if(u&&e!==`mobile-panel`){nr(n.projectId,n.taskId);return}y(n),x(`edit`),M(!1),Fe(`tasks`,n)}}),Pe=J(()=>{!g||!Me()||(y(null),x(`create`),M(!1),Fe(`tasks`,null))}),Fe=J((e,t)=>{let n=j.getState();er({sessionId:null,tab:`schedule`,isSettingsOpen:n.isSettingsDialogOpen,settingsPath:n.settingsPage,diffFile:null,scheduleView:e,scheduleProjectId:t?.projectId??null,scheduleTaskId:t?.taskId??null})}),Ie=J(e=>{w!==e&&(b!==`closed`&&!Me()||(y(null),x(`closed`),M(!1),ne(null),T(e),Fe(e,null)))}),Le=J((t,r)=>{e===`mobile-panel`&&t&&r&&n?.(!1),Be(t,r,{phoneShell:!!(K&&!ae()),switchToChat:!0})}),Re=J(e=>{Le(e.sessionId,e.directory)}),ze=J(e=>{b!==`closed`&&!Me()||(y(null),x(`closed`),M(!1),ne({projectId:e.projectId,taskId:e.task.id}),T(`history`),Fe(`history`,null))}),Ve=J(()=>{ne(null)}),He=J(()=>{ue&&ze(ue)}),Ue=J(async()=>{if(fe.data&&fe.hasNextPage){await fe.fetchNextPage();return}await fe.refetch()}),We=J(e=>{e||!Me()||(y(null),x(`closed`),M(!1),Fe(`tasks`,null))}),Ge=J(()=>e===`mobile-panel`?!Me()||(y(null),x(`closed`),M(!1),Fe(`tasks`,null),n?.(!1),!0):b===`closed`?(n?.(!1),!0):(We(!1),!0));Q.useEffect(()=>{if(e!==`mobile-panel`||!t)return;kf=Ge;let n=()=>Ge();return window.addEventListener(`yuri:scheduled-tasks-close-request`,n),()=>{kf===Ge&&(kf=null),window.removeEventListener(`yuri:scheduled-tasks-close-request`,n)}},[e,t]);let Ke=J(()=>b!==`closed`&&(We(!1),!0));Oi({id:`mobile-scheduled-editor`,active:G&&b!==`closed`,onBack:Ke,surfaceRef:ie,underlayRef:oe}),Q.useEffect(()=>{if(r)return r(Ke),()=>r(null)},[r]);let qe=J(async e=>{let t=v?.projectId||g;if(!t)throw Error(a(`sessions.scheduledTasks.dialog.error.chooseProjectFirst`));let n=new Set(q.filter(e=>e.projectId===t).map(e=>e.task.id)),r=await Ce.mutateAsync({projectID:t,taskDraft:e}),i=e.id?r.find(t=>t.id===e.id):r.find(e=>!n.has(e.id)),o=[...r].filter(t=>t.name===e.name).sort((e,t)=>(t.state?.updatedAt||0)-(e.state?.updatedAt||0))[0],s=i||o;return s&&(y({projectId:t,taskId:s.id}),x(`edit`),Fe(`tasks`,{projectId:t,taskId:s.id})),M(!1),yt.success(a(`sessions.scheduledTasks.dialog.toast.saved`)),s}),Je=J(async e=>{let{projectId:t,task:n}=e;if(window.confirm(a(`sessions.scheduledTasks.dialog.confirm.deleteTask`,{taskName:n.name}))){ee(Of({projectId:t,taskId:n.id}));try{await we.mutateAsync({projectID:t,taskID:n.id});let e=Of({projectId:t,taskId:n.id});v&&Of(v)===e&&(y(null),x(`closed`),M(!1),Fe(`tasks`,null)),yt.success(a(`sessions.scheduledTasks.dialog.toast.deleted`))}catch(e){yt.error(e instanceof Error?e.message:a(`sessions.scheduledTasks.dialog.toast.deleteFailed`))}finally{ee(null)}}}),Ye=J(async({projectId:e,task:t})=>{ee(Of({projectId:e,taskId:t.id}));try{await Te.mutateAsync({projectID:e,taskID:t.id}),yt.success(a(`sessions.scheduledTasks.dialog.toast.started`))}catch(e){yt.error(e instanceof Error?e.message:a(`sessions.scheduledTasks.dialog.toast.runFailed`))}finally{ee(null)}}),Xe=J(async({projectId:e,task:t},n)=>{ee(Of({projectId:e,taskId:t.id}));try{await Ee.mutateAsync({projectID:e,task:{...t,enabled:n}})}catch(e){yt.error(e instanceof Error?e.message:a(`sessions.scheduledTasks.dialog.toast.updateFailed`))}finally{ee(null)}}),Ze=Q.useMemo(()=>{let e=E.trim().toLocaleLowerCase();return q.filter(({task:t})=>S===`active`&&!t.enabled||S===`paused`&&t.enabled?!1:!e||t.name.toLocaleLowerCase().includes(e)||xf(t,a).toLocaleLowerCase().includes(e))},[S,E,a,q]),Qe=e=>{let t=e.icon?ti[e.icon]:null,n=e.color?ri[e.color]:void 0,r=(0,$.jsx)(Z,{name:t??`folder`,className:`size-3.5`,style:n?{color:n}:void 0});return(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center overflow-hidden text-muted-foreground`,children:e.iconImage?(0,$.jsx)(Qr,{project:e,className:`size-full object-contain`,fallback:r}):r}),(0,$.jsx)(`span`,{className:`truncate`,children:xe(e.path)})]})},$e=m.map(e=>({id:e.id,label:Qe(e)}));return(0,$.jsxs)(`div`,{className:Y(`relative flex min-h-0`,G?`yuri-mobile-scheduled-workspace w-full flex-col overflow-visible bg-transparent`:`h-full overflow-hidden bg-background`,K&&`flex-col`),"data-presentation":e,children:[(0,$.jsxs)(`div`,{ref:G?oe:void 0,"data-mobile-navigation-underlay":G?`true`:void 0,"aria-hidden":G&&b!==`closed`?!0:void 0,inert:G&&b!==`closed`?!0:void 0,className:Y(G?`flex w-full min-w-0 flex-col gap-[var(--yuri-mobile-page-gap)]`:`contents`),children:[G?(0,$.jsx)(Si,{title:a(`sessions.scheduledTasks.dialog.title`),trailing:(0,$.jsx)(vf,{active:b===`closed`})}):null,K&&!G?(0,$.jsx)(cr,{children:b===`edit`&&ue?(0,$.jsxs)(Pn,{children:[(0,$.jsx)(Hn,{asChild:!0,children:(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,className:`size-11 shrink-0 rounded-lg`,disabled:!!N,"aria-label":a(`sessions.scheduledTasks.dialog.actions.moreAria`,{taskName:ue.task.name}),children:(0,$.jsx)(Z,{name:`more-2`,className:`size-5`})})}),(0,$.jsxs)(Nn,{align:`end`,className:`min-w-40`,children:[(0,$.jsxs)(Fn,{className:`min-h-11`,onSelect:()=>void Ye(ue),children:[(0,$.jsx)(Z,{name:`play`,className:`size-4`}),a(`sessions.scheduledTasks.dialog.actions.runNow`)]}),(0,$.jsxs)(Fn,{className:`min-h-11`,onSelect:()=>ze(ue),children:[(0,$.jsx)(Z,{name:`history`,className:`size-4`}),a(`sessions.scheduledTasks.workspace.views.history`)]}),(0,$.jsxs)(Fn,{className:`min-h-11`,onSelect:()=>void Xe(ue,!ue.task.enabled),children:[(0,$.jsx)(Z,{name:ue.task.enabled?`pause`:`play`,className:`size-4`}),ue.task.enabled?a(`sessions.scheduledTasks.dialog.actions.pause`):a(`sessions.scheduledTasks.dialog.actions.resume`)]}),(0,$.jsxs)(Fn,{variant:`destructive`,className:`min-h-11`,onSelect:()=>void Je(ue),children:[(0,$.jsx)(Z,{name:`delete-bin`,className:`size-4`}),a(`sessions.scheduledTasks.dialog.actions.delete`)]})]})]}):null}):null,(0,$.jsxs)(`section`,{className:Y(`min-w-0 flex-col transition-[width] duration-300 ease-out`,G?`flex-none overflow-visible`:`flex-1 overflow-hidden`,K&&!G&&b!==`closed`?`hidden`:`flex`),children:[(0,$.jsx)(`header`,{className:Y(`shrink-0`,G?`pb-0 pt-0`:K?`px-3 pb-3 pt-3`:`px-4 pb-5 pt-4 sm:px-6`),children:(0,$.jsxs)(`div`,{className:Y(`mx-auto w-full`,G?`max-w-[26rem]`:`max-w-4xl`),children:[(0,$.jsx)(`div`,{className:Y((w===`tasks`||H||!G)&&`mb-3`,G?`yuri-mobile-floating-surface yuri-mobile-segmented-track`:`grid grid-cols-2 gap-1 rounded-xl bg-[var(--surface-muted)] p-1`),role:`tablist`,"aria-label":a(`sessions.scheduledTasks.workspace.views.aria`),children:[`tasks`,`history`].map(e=>(0,$.jsxs)(X,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":w===e,className:Y(G?`yuri-mobile-segmented-item`:`relative min-h-9 rounded-lg text-muted-foreground transition-[background-color,color,box-shadow] motion-reduce:transition-none`,!G&&K&&`min-h-11`,!G&&(w===e?`text-foreground hover:bg-transparent hover:text-foreground`:`hover:bg-interactive-hover/40 hover:text-foreground`)),onClick:()=>Ie(e),children:[w===e?(0,$.jsx)(hi.span,{layoutId:`scheduled-workspace-view-pill`,className:Y(`yuri-segmented-selected-pill absolute inset-0`,!G&&`rounded-lg`),transition:{duration:l?0:.18,ease:[.22,1,.36,1]},"aria-hidden":`true`}):null,(0,$.jsxs)(`span`,{className:`relative z-[1] inline-flex items-center gap-1.5`,children:[(0,$.jsx)(Z,{name:e===`tasks`?`calendar-schedule`:`history`,className:`size-4 shrink-0`}),a(`sessions.scheduledTasks.workspace.views.${e}`)]})]},e))}),w===`history`&&ge?(0,$.jsx)(`div`,{className:Y(`flex min-w-0 items-center`,G?`mt-[var(--yuri-mobile-page-gap)]`:`mt-3`),role:`status`,"aria-label":a(`sessions.scheduledTasks.history.filter.aria`,{name:ge}),children:(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1 rounded-full border border-border/60 bg-[var(--surface-elevated)] py-1 pl-3 pr-1`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate typography-meta text-foreground`,children:ge}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,className:Y(`shrink-0 rounded-full`,K?`size-8`:`size-7`),onClick:Ve,"aria-label":a(`sessions.scheduledTasks.history.filter.clearAria`),children:(0,$.jsx)(Z,{name:`close`,className:`size-3.5`})})]})}):null,w===`tasks`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:Y(G?`yuri-mobile-floating-surface yuri-mobile-segmented-track yuri-mobile-scheduled-controls`:Y(`flex items-center justify-between`,K?`gap-2`:`gap-3`)),children:[(0,$.jsx)(`div`,{className:Y(G?`yuri-mobile-segmented-group`:Y(`flex items-center gap-1`,K&&`min-w-0 flex-1`)),role:`group`,"aria-label":a(`sessions.scheduledTasks.dialog.title`),children:[`all`,`active`,`paused`].map(e=>(0,$.jsxs)(X,{type:`button`,variant:`ghost`,size:`sm`,className:Y(G?`yuri-mobile-segmented-item`:`relative border-0 bg-transparent text-muted-foreground shadow-none transition-[color,background-color] duration-150 ease-out motion-reduce:transition-none`,!G&&(K?`h-11 min-h-11 min-w-0 flex-1 rounded-xl px-2`:`!h-9 !min-h-9 rounded-xl px-3`),!G&&(S===e?`text-foreground hover:bg-transparent hover:text-foreground`:`hover:bg-interactive-hover/40 hover:text-foreground`)),"aria-pressed":S===e,onClick:()=>C(e),children:[S===e?(0,$.jsx)(hi.span,{layoutId:`scheduled-task-filter-pill`,className:Y(`yuri-segmented-selected-pill absolute inset-0`,!G&&`rounded-xl`),transition:{duration:l?0:.18,ease:[.22,1,.36,1]},"aria-hidden":`true`}):null,(0,$.jsx)(`span`,{className:`relative z-[1]`,children:a(`sessions.scheduledTasks.workspace.filters.${e}`)})]},e))}),G?(0,$.jsx)(X,{variant:`mobileGlass`,size:`mobileIcon`,"data-mobile-press-feedback":`compact`,className:`yuri-mobile-segmented-action yuri-mobile-inverse-action shrink-0`,onClick:Pe,disabled:!g,"aria-label":a(`sessions.scheduledTasks.dialog.actions.create`),children:(0,$.jsx)(Z,{name:`add`,className:`size-5`})}):(0,$.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,$.jsxs)(X,{variant:`ghost`,"data-mobile-press-feedback":K?`compact`:void 0,className:Y(`shrink-0 rounded-full bg-foreground text-background transition-[background-color,box-shadow] duration-150 ease-out hover:bg-foreground/90 hover:text-background hover:shadow-sm active:bg-interactive-active motion-reduce:transition-none`,K?`size-11 min-h-11 px-0 min-[400px]:w-auto min-[400px]:px-3.5`:`!h-9 !min-h-9 px-3.5`),onClick:Pe,disabled:!g,"aria-label":a(`sessions.scheduledTasks.dialog.actions.create`),children:[(0,$.jsx)(Z,{name:`add`,className:`h-4 w-4`}),` `,(0,$.jsx)(`span`,{className:Y(K&&`hidden min-[400px]:inline`),children:a(`sessions.scheduledTasks.dialog.actions.create`)})]})})]}),G?null:(0,$.jsxs)(`div`,{className:Y(`group relative w-full`,K?`mt-3`:`mt-7`),children:[(0,$.jsx)(Z,{name:`search`,className:`pointer-events-none absolute left-3.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground transition-[color,transform] duration-150 ease-out group-focus-within:scale-105 group-focus-within:text-foreground motion-reduce:transition-none`}),(0,$.jsx)(Dn,{value:E,onChange:e=>D(e.target.value),placeholder:a(`sessions.scheduledTasks.workspace.search.placeholder`),className:Y(`rounded-full bg-[var(--surface-elevated)] pl-10 pr-4 ring-1 ring-inset ring-border/50 transition-[background-color,box-shadow,color] duration-200 ease-out hover:[&:not(:focus)]:ring-border focus:bg-[var(--surface-elevated)] focus:shadow-sm focus:ring-2 focus:ring-[var(--interactive-focus-ring)] motion-reduce:transition-none`,K?`h-11 min-h-11`:`!h-9 !min-h-9`)})]})]}):null]})}),(0,$.jsx)(`div`,{ref:se,className:Y(G?`flex-none overflow-visible pt-[var(--yuri-mobile-page-gap)]`:`min-h-0 flex-1 overflow-y-auto`,!G&&(K?`overscroll-none px-3 pb-[max(1rem,env(safe-area-inset-bottom))]`:`px-6 pb-6 [scrollbar-gutter:stable]`)),children:(0,$.jsx)(`div`,{className:Y(`mx-auto w-full`,G?`max-w-[26rem]`:`max-w-4xl pt-4`),children:w===`history`?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[fe.isLoading?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 typography-meta text-muted-foreground`,children:[(0,$.jsx)(Z,{name:`loader-4`,className:`size-4 animate-spin motion-reduce:animate-none`}),a(`sessions.scheduledTasks.history.loading`)]}):fe.error&&me.length===0?(0,$.jsx)(`div`,{className:`rounded-xl border border-dashed border-border p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(Z,{name:`error-warning`,className:`mt-0.5 size-4 shrink-0 text-[var(--status-error)]`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-foreground`,children:a(`sessions.scheduledTasks.history.error.title`)}),(0,$.jsx)(`p`,{className:`mt-1 break-words typography-meta text-muted-foreground`,children:fe.error instanceof Error?fe.error.message:a(`sessions.scheduledTasks.history.error.description`)})]}),(0,$.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>void Ue(),children:a(`sessions.scheduledTasks.history.retry`)})]})}):me.length===0?(0,$.jsxs)(`div`,{className:`rounded-xl border border-dashed border-border p-6 text-center`,children:[(0,$.jsx)(Z,{name:`history`,className:`mx-auto size-5 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`mt-2 typography-ui-label font-medium text-foreground`,children:a(`sessions.scheduledTasks.history.empty.title`)}),(0,$.jsx)(`p`,{className:`mt-1 typography-meta text-muted-foreground`,children:a(`sessions.scheduledTasks.history.empty.description`)})]}):(0,$.jsxs)(`div`,{className:Y(G?`space-y-4`:K?`space-y-2`:`divide-y divide-border/50 overflow-hidden rounded-xl border border-border/60 bg-[var(--surface-elevated)]`),children:[me.map(e=>{let t=Se.get(e.projectId),n=t?xe(t.path):e.projectId,r=e.directory?xe(e.directory):null,i=r&&r!==n?`${n} · ${r}`:n,o=Ef[e.status],s=!!(e.sessionId&&e.directory),c=Tf(wf(e,_e))??(e.status===`running`?a(`sessions.scheduledTasks.history.duration.pending`):null),l=Cf(e.startedAt),u=a(`sessions.scheduledTasks.history.trigger.${e.trigger}`),d=e.trigger===`manual`?`play`:`calendar-schedule`,f=a(`sessions.scheduledTasks.dialog.status.${e.status}`),p=o.tone===`muted`?void 0:{color:`var(--status-${o.tone})`},m=t?.icon?ti[t.icon]??`folder`:`folder`,h=t?.color?ri[t.color]:void 0,g=(0,$.jsx)(`span`,{className:`flex size-3.5 shrink-0 items-center justify-center overflow-hidden text-muted-foreground`,children:t?.iconImage?(0,$.jsx)(Qr,{project:t,className:`size-full object-contain`,fallback:(0,$.jsx)(Z,{name:m,className:`size-3.5`,style:h?{color:h}:void 0})}):(0,$.jsx)(Z,{name:m,className:`size-3.5`,style:h?{color:h}:void 0})}),_=(0,$.jsx)(`span`,{className:Y(`mt-0.5 flex shrink-0 items-center justify-center rounded-full border`,K?`size-7`:`size-8`),style:Df(o.tone),title:f,"aria-label":f,children:(0,$.jsx)(Z,{name:o.Icon,className:Y(K?`size-3.5`:`size-4`,o.spin&&`animate-spin motion-reduce:animate-none`)})}),v=(0,$.jsxs)(`p`,{className:Y(`mt-0.5 flex min-w-0 items-center gap-1.5 text-muted-foreground`,K?`typography-micro`:`truncate typography-meta`),title:e.directory??n,children:[g,(0,$.jsx)(`span`,{className:Y(`min-w-0`,K?`break-words`:`truncate`),children:i})]}),y=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[c?(0,$.jsx)(`span`,{className:`typography-micro tabular-nums text-muted-foreground`,title:c,children:c}):null,(0,$.jsx)(`span`,{className:`typography-micro font-medium`,style:p,children:f})]}),b=(0,$.jsxs)(`div`,{className:Y(`flex w-full min-w-0 items-start`,K?`gap-2.5`:`gap-3`),children:[_,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex w-full min-w-0 items-start justify-between gap-2`,children:[(0,$.jsx)(`h3`,{className:Y(`min-w-0 flex-1 font-semibold text-foreground`,K?`break-words typography-meta leading-snug`:`truncate typography-ui-label`),children:e.taskName}),y]}),v,(0,$.jsxs)(`div`,{className:Y(`mt-1 flex w-full min-w-0 gap-2`,K?`items-center`:`items-center justify-between gap-3`),children:[(0,$.jsxs)(`div`,{className:Y(`flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-1 typography-micro text-muted-foreground`,K&&`gap-x-2.5 gap-y-0.5`),children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1`,title:l,children:[(0,$.jsx)(Z,{name:`time`,className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`whitespace-nowrap tabular-nums`,children:l})]}),(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1`,title:u,children:[(0,$.jsx)(Z,{name:d,className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`whitespace-nowrap`,children:u})]})]}),!K&&s?(0,$.jsx)(`span`,{className:`shrink-0 self-center typography-ui-label font-medium text-foreground`,children:a(`sessions.scheduledTasks.history.openSession`)}):null]}),e.error?(0,$.jsxs)(`p`,{className:Y(`mt-1.5 min-w-0 break-words typography-micro text-[var(--surface-muted-foreground)] [overflow-wrap:anywhere]`,K?`line-clamp-3`:`line-clamp-1`),title:e.error.slice(0,300),children:[(0,$.jsx)(Z,{name:`error-warning`,className:`mr-1 inline-block size-3 align-[-0.125em] text-[var(--status-error)]`,"aria-hidden":`true`}),e.error.slice(0,300)]}):null]})]});if(K){let t=a(`sessions.scheduledTasks.history.openSession`),n=Y(`yuri-mobile-scheduled-task-card w-full`,G?`yuri-mobile-floating-surface yuri-mobile-project-shell rounded-[var(--yuri-mobile-surface-radius)]`:`rounded-xl border border-border/60 bg-[var(--surface-elevated)] shadow-sm dark:shadow-none`);return s?(0,$.jsx)(`article`,{"data-mobile-press-surface":`soft`,className:n,children:(0,$.jsx)(`button`,{type:`button`,"data-mobile-press-surface-trigger":!0,className:Y(`yuri-mobile-scheduled-task-row w-full p-3 text-left outline-none`,`focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`),"aria-label":t,onClick:()=>Re(e),children:b})},e.id):(0,$.jsx)(`article`,{className:Y(n,`p-3`),children:b},e.id)}return s?(0,$.jsx)(`article`,{className:`w-full min-w-0`,children:(0,$.jsx)(`button`,{type:`button`,className:`w-full min-w-0 px-4 py-3 text-left outline-none transition-colors hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)] motion-reduce:transition-none`,"aria-label":a(`sessions.scheduledTasks.history.openSession`),onClick:()=>Re(e),children:b})},e.id):(0,$.jsx)(`article`,{className:`w-full min-w-0 px-4 py-3`,children:b},e.id)}),fe.error?(0,$.jsxs)(`div`,{className:Y(`flex flex-wrap items-center justify-between gap-2 p-3 typography-meta text-[var(--status-error-foreground)]`,K?`rounded-xl border border-[var(--status-error-border)] bg-[var(--status-error-background)]`:`border-t border-[var(--status-error-border)] bg-[var(--status-error-background)]`),children:[(0,$.jsx)(`span`,{children:a(`sessions.scheduledTasks.history.error.more`)}),(0,$.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>void Ue(),children:a(`sessions.scheduledTasks.history.retry`)})]}):null]}),fe.hasNextPage?(0,$.jsx)(`div`,{ref:re,className:`flex min-h-px justify-center`,children:fe.isFetchingNextPage?(0,$.jsx)(`span`,{role:`status`,"aria-label":a(`sessions.scheduledTasks.history.loadingMore`),className:`py-1 text-muted-foreground`,children:(0,$.jsx)(Z,{name:`loader-4`,className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":`true`})}):null}):null]}):(0,$.jsxs)($.Fragment,{children:[le.length>0?(0,$.jsx)(`div`,{className:`mb-3 rounded-xl border p-3 typography-meta`,style:Df(`warning`),children:a(`sessions.scheduledTasks.workspace.partialLoadWarning`)}):null,ce.isLoading?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 typography-meta text-muted-foreground`,children:[(0,$.jsx)(Z,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),` `,a(`sessions.scheduledTasks.dialog.loading`)]}):ce.error&&!ce.data?(0,$.jsx)(`div`,{className:`rounded-xl border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:ce.error instanceof Error?ce.error.message:a(`sessions.scheduledTasks.dialog.toast.loadFailed`)}):(0,$.jsx)(Bt,{initial:!1,mode:`popLayout`,children:Ze.length===0?(0,$.jsx)(hi.div,{initial:l?{opacity:0}:{opacity:0,y:4},animate:{opacity:1,y:0},exit:l?{opacity:0}:{opacity:0,y:-4},transition:{duration:l?0:.18,ease:[.22,1,.36,1]},className:`rounded-xl border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:q.length>0?a(`sessions.scheduledTasks.workspace.search.noResults`):a(`sessions.scheduledTasks.dialog.empty.noTasks`)},`empty`):(0,$.jsx)(hi.div,{initial:l?{opacity:0}:{opacity:0,y:4},animate:{opacity:1,y:0},exit:l?{opacity:0}:{opacity:0,y:-4},transition:{duration:l?0:.18,ease:[.22,1,.36,1]},className:Y(G?`space-y-4`:`space-y-1`),children:(0,$.jsx)(Bt,{initial:!1,mode:`popLayout`,children:Ze.map(e=>{let{projectId:t,task:n}=e,r=Of({projectId:t,taskId:n.id}),i=b===`edit`&&v!==null&&Of(v)===r,o=n.state?.nextRunAt,s=n.state?.lastStatus||`idle`,c=Ef[s],d=N===r,f=t=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(t,{className:Y(K&&`min-h-11`),onClick:t=>{t.stopPropagation(),Ye(e)},disabled:d,children:[(0,$.jsx)(Z,{name:`play`,className:`size-4`}),a(`sessions.scheduledTasks.dialog.actions.runNow`)]}),(0,$.jsxs)(t,{className:Y(K&&`min-h-11`),onClick:t=>{t.stopPropagation(),ze(e)},children:[(0,$.jsx)(Z,{name:`history`,className:`size-4`}),a(`sessions.scheduledTasks.workspace.views.history`)]}),(0,$.jsxs)(t,{className:Y(K&&`min-h-11`),onClick:t=>{t.stopPropagation(),Xe(e,!n.enabled)},disabled:d,children:[(0,$.jsx)(Z,{name:n.enabled?`pause`:`play`,className:`size-4`}),n.enabled?a(`sessions.scheduledTasks.dialog.actions.pause`):a(`sessions.scheduledTasks.dialog.actions.resume`)]}),(0,$.jsxs)(t,{onClick:t=>{t.stopPropagation(),Je(e)},disabled:d,className:Y(`text-destructive focus:text-destructive`,K&&`min-h-11`),children:[(0,$.jsx)(Z,{name:`delete-bin`,className:`size-4`}),a(`sessions.scheduledTasks.dialog.actions.delete`)]})]});return(0,$.jsx)(hi.div,{layout:`position`,initial:!l&&{opacity:0,y:6},animate:{opacity:1,y:0},exit:l?{opacity:0}:{opacity:0,y:-6},transition:{duration:l?0:.18,ease:[.22,1,.36,1]},"data-mobile-press-surface":G?`soft`:void 0,className:Y(G&&`yuri-mobile-floating-surface yuri-mobile-project-shell yuri-mobile-scheduled-task-card`),children:(0,$.jsxs)(Fi,{open:P===r,onOpenChange:e=>{e&&R(null),F(e?r:null)},children:[(0,$.jsxs)(`div`,{className:Y(`group flex w-full items-center gap-1`,G&&`yuri-mobile-project-card`),children:[(0,$.jsxs)(ji,{render:(0,$.jsx)(`button`,{type:`button`,onClick:()=>Ne(e),onContextMenu:!K&&!u?e=>{e.preventDefault(),R(null),F(r)}:void 0,"data-mobile-press-surface-trigger":G?!0:void 0,className:Y(`flex min-h-11 min-w-0 flex-1 items-center rounded-xl border py-3 text-left outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] motion-reduce:transition-none`,G?`yuri-mobile-project-trigger yuri-mobile-scheduled-task-row border-0 bg-transparent transition-opacity duration-150`:`transition-[background-color,border-color,box-shadow,opacity] duration-150 ease-out active:bg-interactive-active`,K&&!G?`gap-2.5 px-3`:G?void 0:`gap-3 px-4`,!G&&(i?`border-border/50 bg-[var(--surface-elevated)] shadow-sm dark:shadow-none`:`border-transparent hover:bg-interactive-hover`),!n.enabled&&`opacity-65`),"aria-pressed":i}),children:[(0,$.jsx)(`span`,{className:Y(`flex shrink-0 items-center justify-center rounded-full text-muted-foreground transition-[border-color,color,background-color] duration-150 motion-reduce:transition-none`,G?`yuri-mobile-project-icon yuri-mobile-glass-control`:`size-5 border border-border`),style:n.enabled&&c.tone!==`muted`?{color:`var(--status-${c.tone})`}:void 0,children:(0,$.jsx)(Bt,{initial:!1,mode:`wait`,children:(0,$.jsx)(hi.span,{initial:!l&&{opacity:0,scale:.72},animate:{opacity:1,scale:1},exit:l?{opacity:0}:{opacity:0,scale:.72},transition:{duration:l?0:.15},className:`flex`,children:(0,$.jsx)(Z,{name:n.enabled?c.Icon:`pause`,className:Y(G?`yuri-mobile-project-icon-glyph`:`size-3.5`,c.spin&&n.enabled&&`animate-spin`)})},`${n.enabled}-${s}`)})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:Y(`block truncate font-medium`,G?`yuri-mobile-project-title yuri-mobile-entity-title font-semibold`:`typography-ui-label`),children:n.name}),(0,$.jsxs)(`span`,{className:Y(`mt-1 flex min-w-0 items-center text-muted-foreground`,G?`yuri-mobile-project-meta yuri-mobile-entity-meta`:`gap-1 typography-micro`),children:[(0,$.jsx)(`span`,{className:`truncate`,children:xf(n,a,!G)}),(0,$.jsx)(`span`,{className:`shrink-0 text-muted-foreground/50`,children:`·`}),(0,$.jsx)(`span`,{className:`shrink-0 truncate`,children:o?Sf(o,a):`—`})]})]})]}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,className:Y(`shrink-0 self-center rounded-lg text-muted-foreground`,K?`size-11 rounded-full`:`size-9`),onClick:t=>{t.stopPropagation(),ze(e)},"aria-label":a(`sessions.scheduledTasks.workspace.views.history`),children:(0,$.jsx)(Z,{name:`history`,className:`size-4`})}),(0,$.jsxs)(Pn,{open:I===r,onOpenChange:e=>{e&&F(null),R(e?r:null)},children:[(0,$.jsx)(Hn,{asChild:!0,children:(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,className:Y(`shrink-0 self-center text-muted-foreground transition-[opacity,transform,background-color] duration-150 ease-out data-[popup-open]:bg-interactive-hover motion-reduce:transition-none`,G?`yuri-mobile-project-action yuri-mobile-scheduled-task-action rounded-full`:`rounded-lg`,G?void 0:K?`size-11`:`size-8 translate-x-1 opacity-0 group-hover:translate-x-0 group-hover:opacity-100 data-[popup-open]:translate-x-0 data-[popup-open]:opacity-100`,i&&!G&&`opacity-100`),onClick:e=>e.stopPropagation(),"aria-label":a(`sessions.scheduledTasks.dialog.actions.moreAria`,{taskName:n.name}),children:(0,$.jsx)(Z,{name:`more-2`,className:G?`size-5`:`size-4`})})}),(0,$.jsx)(Nn,{align:`end`,className:`min-w-40 motion-reduce:transition-none`,onClick:e=>e.stopPropagation(),children:f(Fn)})]})]}),(0,$.jsx)(Ni,{className:`min-w-40 motion-reduce:transition-none`,children:f(Pi)})]})},r)})})},`tasks`)})]})})})]})]}),b===`edit`&&!de?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-4`,role:`status`,children:[ce.isPending?a(`sessions.scheduledTasks.dialog.loading`):a(`common.unavailable`),ce.isPending?null:(0,$.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>void ce.refetch(),children:a(`assistants.actions.retry`)})]}):null,u?b===`create`||b===`edit`&&de?(0,$.jsx)(`div`,{ref:G?ie:void 0,className:Y(G?`yuri-mobile-scheduled-editor-overlay flex w-full min-w-0 max-w-full flex-col overflow-hidden bg-background [contain:layout_paint]`:`contents`),children:(0,$.jsx)(df,{open:!0,presentation:G?`mobile-tab`:K?`mobile-panel`:void 0,task:b===`edit`?de:null,onOpenChange:We,onSave:qe,onDirtyChange:M,onRun:async()=>{ue&&await Ye(ue)},onOpenTaskHistory:He,onDelete:async()=>{ue&&await Je(ue)},onToggleEnabled:async(e,t)=>{ue&&await Xe(ue,t)},actionBusy:!!N,projectID:v?.projectId||g,projectOptions:$e,onProjectChange:b===`create`?_:void 0})}):null:(0,$.jsx)(Bt,{initial:!1,children:b===`create`||b===`edit`&&de?(0,$.jsx)(hi.div,{initial:l?{opacity:1,width:0}:{opacity:0,width:0,x:24},animate:{opacity:1,width:`clamp(380px, 36vw, 480px)`,x:0},exit:l?{opacity:0,width:0}:{opacity:0,width:0,x:24},transition:{duration:l?0:.26,ease:[.22,1,.36,1]},className:`h-full min-h-0 max-w-[480px] shrink-0 overflow-hidden`,children:(0,$.jsx)(`aside`,{className:`h-full min-h-0 w-[clamp(380px,36vw,480px)] border-l border-border/60 bg-background`,children:(0,$.jsx)(df,{open:!0,presentation:`panel`,task:b===`edit`?de:null,onOpenChange:We,onSave:qe,onDirtyChange:M,onRun:async()=>{ue&&await Ye(ue)},onOpenTaskHistory:He,onDelete:async()=>{ue&&await Je(ue)},onToggleEnabled:async(e,t)=>{ue&&await Xe(ue,t)},actionBusy:!!N,projectID:v?.projectId||g,projectOptions:$e,onProjectChange:b===`create`?_:void 0})})},`scheduled-task-details`):null})]})}var Rf={"?":{code:`?`,color:`var(--status-info)`,description:`Untracked file`},A:{code:`A`,color:`var(--status-success)`,description:`New file`},D:{code:`D`,color:`var(--status-error)`,description:`Deleted file`},R:{code:`R`,color:`var(--status-info)`,description:`Renamed file`},C:{code:`C`,color:`var(--status-info)`,description:`Copied file`},M:{code:`M`,color:`var(--status-warning)`,description:`Modified file`}},zf=Rf.M;function Bf(e){let t=e.index?.trim(),n=e.working_dir?.trim();return t&&t!==`?`?t.charAt(0):n?n.charAt(0):t?.charAt(0)||n?.charAt(0)||`M`}function Vf(e){return Rf[Bf(e)]??zf}var Hf=Q.memo(function(e){let t=(0,qi.c)(57),{file:n,actionLabel:r,actionSymbol:i,onAction:a,onViewDiff:o,onRevert:s,isReverting:c,stats:l,rowPaddingClassName:u,indentPx:d,actionAtStart:f,showRevert:p,displayPath:m}=e,h=d===void 0?0:d,g=f!==void 0&&f,_=p===void 0||p,v;t[0]===n?v=t[1]:(v=Vf(n),t[0]=n,t[1]=v);let y=v,{t:b}=be(),x=y.description,S=l?.insertions??0,C=l?.deletions??0,w;t[2]!==a||t[3]!==o?(w=e=>{e.key===` `?(e.preventDefault(),a()):e.key===`Enter`&&(e.preventDefault(),o())},t[2]=a,t[3]=o,t[4]=w):w=t[4];let T=w,E;t[5]===a?E=t[6]:(E=e=>{e.preventDefault(),e.stopPropagation(),a()},t[5]=a,t[6]=E);let D=E,O;t[7]===s?O=t[8]:(O=e=>{e.preventDefault(),e.stopPropagation(),s()},t[7]=s,t[8]=O);let k=O,A;t[9]!==r||t[10]!==i||t[11]!==D?(A=(0,$.jsx)(`button`,{type:`button`,onClick:D,className:`flex size-6 items-center justify-center rounded typography-code font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-label":r,title:r,children:i}),t[9]=r,t[10]=i,t[11]=D,t[12]=A):A=t[12];let j=A,M=`group flex h-8 items-center cursor-pointer ${u??`px-3`}`,N;t[13]===h?N=t[14]:(N=h>0?{paddingLeft:`${h}px`}:void 0,t[13]=h,t[14]=N);let ee=g?j:null,P;t[15]===y.color?P=t[16]:(P={color:y.color},t[15]=y.color,t[16]=P);let F;t[17]!==y.code||t[18]!==x||t[19]!==P?(F=(0,$.jsx)(`span`,{className:`typography-code font-semibold w-3.5 shrink-0 text-center uppercase`,style:P,title:x,"aria-label":x,children:y.code}),t[17]=y.code,t[18]=x,t[19]=P,t[20]=F):F=t[20];let I;t[21]===n.path?I=t[22]:(I=(0,$.jsx)(nn,{filePath:n.path,className:`size-3 shrink-0`}),t[21]=n.path,t[22]=I);let L=m??n.path,R;t[23]!==n.path||t[24]!==L?(R=(0,$.jsx)(dn,{path:L,title:n.path,className:`min-w-0 flex-1 typography-code`}),t[23]=n.path,t[24]=L,t[25]=R):R=t[25];let z;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(z={color:`var(--status-success)`},t[26]=z):z=t[26];let te;t[27]===S?te=t[28]:(te=(0,$.jsxs)(`span`,{style:z,children:[`+`,S]}),t[27]=S,t[28]=te);let B,V;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(`span`,{className:`text-muted-foreground mx-0.5`,children:`/`}),V={color:`var(--status-error)`},t[29]=B,t[30]=V):(B=t[29],V=t[30]);let H;t[31]===C?H=t[32]:(H=(0,$.jsxs)(`span`,{style:V,children:[`-`,C]}),t[31]=C,t[32]=H);let ne;t[33]!==te||t[34]!==H?(ne=(0,$.jsxs)(`span`,{className:`shrink-0 typography-code tabular-nums`,children:[te,B,H]}),t[33]=te,t[34]=H,t[35]=ne):ne=t[35];let re;t[36]!==F||t[37]!==I||t[38]!==R||t[39]!==ne?(re=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[F,I,R,ne]}),t[36]=F,t[37]=I,t[38]=R,t[39]=ne,t[40]=re):re=t[40];let U;t[41]!==g||t[42]!==j||t[43]!==n.path||t[44]!==k||t[45]!==c||t[46]!==_||t[47]!==b?(U=g?null:(0,$.jsxs)(`div`,{className:`ml-auto grid shrink-0 grid-flow-col auto-cols-[1.5rem] items-center justify-end`,children:[_?(0,$.jsxs)(An,{children:[(0,$.jsx)(On,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:k,disabled:c,className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":b(`gitView.changes.revertFileAria`,{path:n.path}),children:c?(0,$.jsx)(Z,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,$.jsx)(Z,{name:`arrow-go-back`,className:`size-3.5`})})}),(0,$.jsx)(kn,{sideOffset:8,children:b(`gitView.changes.revertFileTooltip`)})]}):null,j]}),t[41]=g,t[42]=j,t[43]=n.path,t[44]=k,t[45]=c,t[46]=_,t[47]=b,t[48]=U):U=t[48];let W;return t[49]!==T||t[50]!==o||t[51]!==N||t[52]!==ee||t[53]!==re||t[54]!==U||t[55]!==M?(W=(0,$.jsxs)(`div`,{className:M,role:`button`,tabIndex:0,onClick:o,onKeyDown:T,style:N,children:[ee,re,U]}),t[49]=T,t[50]=o,t[51]=N,t[52]=ee,t[53]=re,t[54]=U,t[55]=M,t[56]=W):W=t[56],W}),Uf=e=>e.replace(/\\/g,`/`).replace(/^\/+/,``).trim(),Wf=e=>{let t=Uf(e);if(!t)return e;let n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t},Gf=(e,t)=>({id:`dir:${e}`,path:e,name:t,children:new Map,directFiles:[],files:[]}),Kf=e=>{let t=Gf(``,``);for(let n of e){let e=Uf(n.path);if(!e)continue;let r=e.split(`/`).filter(Boolean).slice(0,-1),i=t;if(i.files.push(n),r.length>0){let e=``;for(let t of r){e=e?`${e}/${t}`:t;let r=i.children.get(t);if(r){r.files.push(n),i=r;continue}let a=Gf(e,t);a.files.push(n),i.children.set(t,a),i=a}}i.directFiles.push(n)}return t},qf=(e,t)=>{let n=[],r=(e,i)=>{let a=Array.from(e.children.values()).sort((e,t)=>e.path.localeCompare(t.path));for(let e of a)n.push({key:e.id,kind:`directory`,depth:i,directory:e}),t.has(e.path)&&r(e,i+1);let o=[...e.directFiles].sort((e,t)=>e.path.localeCompare(t.path));for(let e of o)n.push({key:`file:${Uf(e.path)}`,kind:`file`,depth:i,file:e})};return r(e,0),n},Jf=1e3,Yf=32,Xf=30,Zf=`pl-0 pr-2`,Qf=`ml-auto grid shrink-0 grid-flow-col auto-cols-[1.5rem] items-center justify-end`,$f=`flex size-6 items-center justify-center tabular-nums typography-code text-muted-foreground`,ep=`flex size-6 items-center justify-center rounded typography-code font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50`,tp=`flex size-6 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50`,np=(e,t)=>`${e} ${t}`,rp=({compact:e=!1,groups:t,diffStats:n,revertingPaths:r,isRevertingAll:i=!1,headerBackgroundClassName:a=`bg-sidebar`,onVisiblePathsChange:o,onRevertAll:s,onRevertDirectory:c,headerLeadingActions:l,headerActions:u})=>{let{t:d}=be(),f=Q.useRef(null),p=j(e=>e.gitChangesViewMode),m=j(e=>e.setGitChangesViewMode),h=p===`tree`,g=Q.useMemo(()=>t.filter(e=>e.entries.length>0),[t]),[_,v]=Q.useState(new Set),[y,b]=Q.useState(new Set),[x,S]=Q.useState(!1),[C,w]=Q.useState(null),T=Q.useRef(new Set),E=Q.useMemo(()=>g.map(e=>Kf(e.entries)),[g]),D=Q.useMemo(()=>{let e=new Map;return g.forEach((t,n)=>{let r=[],i=e=>{e.children.forEach(e=>{r.push(np(t.id,e.path)),i(e)})},a=E[n];a&&i(a),e.set(t.id,r)}),e},[E,g]);Q.useEffect(()=>{if(!h){T.current=new Set;return}let e=new Set(Array.from(D.values()).flat()),t=T.current,n=t.size===0&&e.size>0;b(r=>{let i=new Set(r),a=!1;for(let t of i)e.has(t)||(i.delete(t),a=!0);for(let r of e){let e=!t.has(r);(n||e)&&!i.has(r)&&(i.add(r),a=!0)}return a?i:r}),T.current=e},[D,h]);let O=Q.useMemo(()=>{let e=[];return g.forEach((t,n)=>{if(e.push({type:`header`,key:`header:${t.id}`,groupIndex:n}),!_.has(t.id)){if(h){let r=new Set;y.forEach(e=>{e.startsWith(`${t.id} `)&&r.add(e.slice(t.id.length+1))}),qf(E[n],r).forEach(r=>{r.kind===`file`?e.push({type:`file`,key:`${t.id}:${r.key}`,groupIndex:n,file:r.file,depth:r.depth}):e.push({type:`directory`,key:`${t.id}:${r.key}`,groupIndex:n,directory:r.directory,depth:r.depth})});return}t.entries.forEach(r=>{e.push({type:`file`,key:`${t.id}:file:${r.path}`,groupIndex:n,file:r,depth:0})})}}),e},[_,y,h,E,g]),k=g[0]??null,A=Q.useMemo(()=>k?O.filter(e=>e.type!==`header`||e.groupIndex!==0):O,[k,O]),M=A.length,N=M>=Jf,ee=Q.useMemo(()=>e=>A[e]?.key??e,[A]),P=mi({count:M,enabled:N,getScrollElement:()=>f.current,estimateSize:()=>Yf,overscan:12,getItemKey:ee}),F=P.getVirtualItems(),I=P.scrollRect?.height??0,L=Q.useMemo(()=>{if(!N)return 0;let e=f.current?.scrollTop??0;return F.find(t=>t.end>e)?.index??0},[N,F,f]);Q.useEffect(()=>{if(!o)return;let e=e=>e&&e.type===`file`?e.file.path:null;if(M===0){o([]);return}if(!N){let e=[];for(let t of A)if(t.type===`file`&&(e.push(t.file.path),e.length>=Xf))break;o(e);return}o(A.slice(L,L+Math.ceil(I/Yf)+Xf).map(t=>e(t)).filter(e=>!!e).slice(0,Xf))},[o,M,A,N,I,L]);let R=Q.useCallback(e=>{v(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),z=Q.useCallback((e,t)=>{b(n=>{let r=new Set(n),i=np(e,t);return r.has(i)?r.delete(i):r.add(i),r})},[]),te=Q.useCallback(e=>{let t=D.get(e)??[];b(e=>{let n=new Set(e);return t.forEach(e=>n.add(e)),n})},[D]),B=Q.useCallback(e=>{let t=D.get(e)??[];b(e=>{let n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[D]),V=Q.useMemo(()=>{let e=new Set;return g.forEach(t=>t.entries.forEach(t=>e.add(t.path))),Array.from(e)},[g]),H=V.length,ne=C?i||C.paths.some(e=>r.has(e)):!1,re=Q.useCallback(async()=>{!s||i||V.length===0||(await s(V),S(!1))},[V,i,s]),U=Q.useCallback(async()=>{!c||!C||ne||(await c(C.paths),w(null))},[ne,c,C]),W=Q.useCallback((t,n={})=>{let{pinned:r=!1,showToolbar:o=!1}=n,c=_.has(t.id),f=t.entries.length,p=D.get(t.id)??[],g=p.length>0&&p.every(e=>y.has(e)),v=d(g?`diffView.actions.collapseAll`:`diffView.actions.expandAll`),b=d(h?`settings.yuri.git.option.flatList`:`settings.yuri.git.option.treeView`);return(0,$.jsxs)(`div`,{className:Y(`flex h-8 items-center gap-0`,r?`shrink-0`:`sticky top-0 z-10`,a,Zf,!r&&`mt-3`),children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>R(t.id),className:`flex min-w-0 flex-1 items-center gap-1.5 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-expanded":!c,children:[(0,$.jsx)(`h3`,{className:Y(`truncate font-semibold text-foreground`,e?`text-xs leading-4`:`typography-ui-label`),children:t.title}),(0,$.jsx)(`span`,{className:`typography-code text-muted-foreground`,children:f}),(0,$.jsx)(Z,{name:`arrow-down-s`,className:Y(`size-3 shrink-0 text-muted-foreground transition-transform`,c&&`-rotate-90`)})]}),(0,$.jsxs)(`div`,{className:Qf,children:[h?(0,$.jsx)(`button`,{type:`button`,onClick:()=>{if(g){B(t.id);return}te(t.id)},className:tp,"aria-label":v,title:v,children:(0,$.jsx)(Z,{name:g?`contract-up-down`:`expand-up-down`,className:`size-3.5`})}):null,(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(h?`flat`:`tree`),"aria-label":b,title:b,"aria-pressed":h,className:tp,children:(0,$.jsx)(Z,{name:h?`node-tree`:`list-unordered`,className:`size-3.5`})}),o&&s&&H>0?(0,$.jsx)(`button`,{type:`button`,onClick:()=>S(!0),disabled:i,className:tp,"aria-label":d(`gitView.changes.revertAll`),title:d(`gitView.changes.revertAll`),children:i?(0,$.jsx)(Z,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,$.jsx)(Z,{name:`arrow-go-back`,className:`size-3.5`})}):null,o?l:null,o?u:null,(0,$.jsx)(`button`,{type:`button`,onClick:()=>t.onActionAll(t.entries.map(e=>e.path)),className:ep,"aria-label":t.actionAllLabel,title:t.actionAllLabel,children:t.actionSymbol})]})]})},[B,_,e,D,te,y,u,a,l,i,h,s,H,m,d,R]),ie=Q.useCallback((e,t,n)=>{let a=y.has(np(e.id,t.path)),o=t.files.map(e=>e.path),s=i||o.some(e=>r.has(e)),l=e.showRevertActions!==!1&&!!c;return(0,$.jsxs)(`div`,{className:Y(`group flex h-8 items-center`,Zf),style:{paddingLeft:`${n*14}px`},children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>z(e.id,t.path),className:`flex min-w-0 flex-1 items-center gap-1.5 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":d(a?`gitView.changes.collapseDirectoryAria`:`gitView.changes.expandDirectoryAria`,{path:t.path}),children:[a?(0,$.jsx)(Z,{name:`folder-open-fill`,className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground`}):(0,$.jsx)(Z,{name:`folder-3-fill`,className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-code text-foreground`,title:t.path,children:t.name})]}),(0,$.jsxs)(`div`,{className:Qf,children:[(0,$.jsx)(`span`,{className:$f,children:t.files.length}),l?(0,$.jsx)(`button`,{type:`button`,onClick:()=>w({path:t.path,paths:o,count:o.length}),disabled:s,className:tp,"aria-label":d(`gitView.changes.revertDirectoryAria`,{path:t.path}),title:d(`gitView.changes.revertDirectoryTooltip`),children:s?(0,$.jsx)(Z,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,$.jsx)(Z,{name:`arrow-go-back`,className:`size-3.5`})}):null,(0,$.jsx)(`button`,{type:`button`,onClick:()=>e.onActionAll(t.files.map(e=>e.path)),className:ep,"aria-label":d(e.actionSymbol===`+`?`gitView.changes.stageDirectoryAria`:`gitView.changes.unstageDirectoryAria`,{path:t.path}),title:d(e.actionSymbol===`+`?`gitView.changes.stageDirectoryAria`:`gitView.changes.unstageDirectoryAria`,{path:t.path}),children:e.actionSymbol})]})]})},[y,i,c,r,d,z]),ae=Q.useCallback(e=>{let t=g[e.groupIndex];if(!t)return null;if(e.type===`header`)return W(t,{showToolbar:!1});if(e.type===`directory`)return ie(t,e.directory,e.depth);let a=e.file;return(0,$.jsx)(Hf,{file:a,actionLabel:t.getActionLabel(a.path),actionSymbol:t.actionSymbol,onAction:()=>t.onActionFile(a.path),stats:n?.[a.path],onViewDiff:()=>t.onViewDiff(a.path),onRevert:()=>t.onRevertFile(a.path),isReverting:r.has(a.path)||i,rowPaddingClassName:Zf,indentPx:e.depth*14,actionAtStart:!1,showRevert:t.showRevertActions!==!1,displayPath:h?Wf(a.path):void 0})},[n,i,h,ie,W,r,g]),oe=Q.useCallback(e=>{let t=A[e],n=A[e-1];return!t||!n||t.type!==`file`&&t.type!==`directory`||n.type!==`file`&&n.type!==`directory`?!1:n.groupIndex===t.groupIndex},[A]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`yuri-changes-panel relative flex h-full min-h-0 w-full flex-col overflow-hidden`,children:[k?(0,$.jsx)(`div`,{className:Y(`shrink-0`,a),children:W(k,{pinned:!0,showToolbar:!0})}):null,(0,$.jsx)(Xr,{ref:f,className:`overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto`,children:N?(0,$.jsx)(`div`,{style:{height:P.getTotalSize(),position:`relative`},children:F.map(e=>{let t=A[e.index];return t?(0,$.jsx)(`div`,{"data-index":e.index,ref:P.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},className:Y(oe(e.index)&&`before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60`),children:ae(t)},t.key):null})}):(0,$.jsx)(`div`,{role:`list`,"aria-label":d(`gitView.changes.changedFilesAria`),children:A.map((e,t)=>(0,$.jsx)(`div`,{className:Y(`relative`,oe(t)&&`before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60`),children:ae(e)},e.key))})}),(0,$.jsx)(Jr,{containerRef:f,disableHorizontal:!0})]}),(0,$.jsx)(qt,{open:x,onOpenChange:e=>{!i&&!e&&S(!1)},children:(0,$.jsxs)(Wt,{className:`max-w-md`,children:[(0,$.jsxs)(Ht,{children:[(0,$.jsx)(Gt,{children:d(`gitView.changes.revertAllDialogTitle`)}),(0,$.jsx)(Kt,{children:d(H===1?`gitView.changes.revertAllDescriptionSingle`:`gitView.changes.revertAllDescriptionPlural`,{count:H})})]}),(0,$.jsxs)(Ut,{children:[(0,$.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>S(!1),disabled:i,children:d(`gitView.common.cancel`)}),(0,$.jsx)(X,{variant:`destructive`,size:`sm`,onClick:()=>void re(),disabled:i,children:d(i?`gitView.changes.reverting`:`gitView.changes.revertAll`)})]})]})}),(0,$.jsx)(qt,{open:!!C,onOpenChange:e=>{!ne&&!e&&w(null)},children:(0,$.jsxs)(Wt,{className:`max-w-md`,children:[(0,$.jsxs)(Ht,{children:[(0,$.jsx)(Gt,{children:d(`gitView.changes.revertDirectoryDialogTitle`)}),(0,$.jsx)(Kt,{children:C?C.count===1?d(`gitView.changes.revertDirectoryDescriptionSingle`,{count:C.count,path:C.path}):d(`gitView.changes.revertDirectoryDescriptionPlural`,{count:C.count,path:C.path}):null})]}),(0,$.jsxs)(Ut,{children:[(0,$.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>w(null),disabled:ne,children:d(`gitView.common.cancel`)}),(0,$.jsx)(X,{variant:`destructive`,size:`sm`,onClick:()=>void U(),disabled:ne||!C,children:d(ne?`gitView.changes.reverting`:`gitView.changes.revertDirectory`)})]})]})})]})},ip=e=>{let t=(0,qi.c)(26),{stagedCount:n,unstagedCount:r,onLoad:i}=e,{t:a}=be(),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Z,{name:`loader-4`,className:`size-5 text-muted-foreground`}),t[0]=o):o=t[0];let s;t[1]!==n||t[2]!==a?(s=a(`gitView.changes.deferredStagedCount`,{count:n}),t[1]=n,t[2]=a,t[3]=s):s=t[3];let c;t[4]!==a||t[5]!==r?(c=a(`gitView.changes.deferredUnstagedCount`,{count:r}),t[4]=a,t[5]=r,t[6]=c):c=t[6];let l;t[7]!==s||t[8]!==c?(l=(0,$.jsxs)(`p`,{className:`typography-meta text-muted-foreground`,children:[s,` · `,c]}),t[7]=s,t[8]=c,t[9]=l):l=t[9];let u;t[10]===a?u=t[11]:(u=a(`gitView.changes.deferredHint`),t[10]=a,t[11]=u);let d;t[12]===u?d=t[13]:(d=(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:u}),t[12]=u,t[13]=d);let f;t[14]!==l||t[15]!==d?(f=(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-1`,children:[l,d]}),t[14]=l,t[15]=d,t[16]=f):f=t[16];let p;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(Z,{name:`refresh`,className:`size-3.5`}),t[17]=p):p=t[17];let m;t[18]===a?m=t[19]:(m=a(`gitView.changes.deferredLoadAction`),t[18]=a,t[19]=m);let h;t[20]!==i||t[21]!==m?(h=(0,$.jsxs)(X,{type:`button`,size:`sm`,variant:`outline`,onClick:i,children:[p,m]}),t[20]=i,t[21]=m,t[22]=h):h=t[22];let g;return t[23]!==h||t[24]!==f?(g=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 px-6 py-8 text-center`,children:[o,f,h]}),t[23]=h,t[24]=f,t[25]=g):g=t[25],g},ap=e=>e?e.oversized===!0:!1,op=38,sp=200,cp=e=>{let t=(0,qi.c)(49),{value:n,onChange:r,placeholder:i,disabled:a,hasTouchInput:o,isMobile:s,compact:c}=e,l=a!==void 0&&a,u=o!==void 0&&o,d=s!==void 0&&s,f=c!==void 0&&c,{t:p}=be(),m=Q.useRef(null),h=Q.useRef(null),g=j(lp),_;t[0]===d?_=t[1]:(_=()=>{if(!d)return;let e=m.current;if(!e)return;let t=document.activeElement===e,n=()=>{e.style.height=`${op}px`;let n=e.scrollHeight,r=Math.min(Math.max(n,op),sp);e.style.height=`${r}px`,e.style.overflowY=n>sp?`auto`:`hidden`,n>sp&&!t&&(e.scrollTop=e.scrollHeight)};n();let r=window.requestAnimationFrame(n);return()=>{window.cancelAnimationFrame(r)}},t[0]=d,t[1]=_);let v;t[2]!==d||t[3]!==n?(v=[d,op,n],t[2]=d,t[3]=n,t[4]=v):v=t[4],Q.useLayoutEffect(_,v);let y;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{h.current?.pointerId===e.pointerId&&(h.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},t[5]=y):y=t[5];let b=y,x;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(x=(e,t)=>{let n=m.current;if(!n)return;let r=Math.max(op,e);n.style.height=`${r}px`,t.setAttribute(`aria-valuenow`,String(Math.round(r)))},t[6]=x):x=t[6];let S=x,C;t[7]===r?C=t[8]:(C=e=>r(e.target.value),t[7]=r,t[8]=C);let w;t[9]!==i||t[10]!==p?(w=i??p(`gitView.commit.messagePlaceholder`),t[9]=i,t[10]=p,t[11]=w):w=t[11];let T=u?`on`:`off`,E=u?`sentences`:`off`,D=d||g,O;t[12]!==f||t[13]!==l?(O=Y(`block w-full resize-none outline-none text-foreground placeholder:text-muted-foreground`,f?[`appearance-none rounded-md px-2 py-1.5 text-xs leading-4`,`bg-[color-mix(in_srgb,var(--surface-foreground)_2%,var(--background))]`,`ring-1 ring-inset ring-border/60 transition-[background-color,box-shadow] duration-200 ease-out`,`hover:[&:not(:focus)]:bg-[color-mix(in_srgb,var(--surface-foreground)_4%,var(--background))] hover:[&:not(:focus)]:ring-transparent`,`focus:ring-1 focus:ring-[var(--interactive-focus-ring)] focus-visible:outline-none`]:[`border border-border/60 bg-surface-elevated rounded-lg px-3 py-2 typography-ui-label`,`transition-[border-color,box-shadow] duration-150 focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`],l&&`opacity-50`),t[12]=f,t[13]=l,t[14]=O):O=t[14];let k=d?void 0:op,A=d?sp:void 0,M=d?void 0:`auto`,N;t[15]!==k||t[16]!==A||t[17]!==M?(N={height:k,minHeight:op,maxHeight:A,overflowY:M},t[15]=k,t[16]=A,t[17]=M,t[18]=N):N=t[18];let ee;t[19]!==l||t[20]!==w||t[21]!==T||t[22]!==E||t[23]!==D||t[24]!==O||t[25]!==N||t[26]!==C||t[27]!==n?(ee=(0,$.jsx)(`textarea`,{ref:m,value:n,onChange:C,placeholder:w,rows:1,disabled:l,autoCorrect:T,autoCapitalize:E,spellCheck:D,className:O,style:N}),t[19]=l,t[20]=w,t[21]=T,t[22]=E,t[23]=D,t[24]=O,t[25]=N,t[26]=C,t[27]=n,t[28]=ee):ee=t[28];let P=ee;if(d)return P;let F;t[29]===p?F=t[30]:(F=p(`textarea.resizeHandleAria`),t[29]=p,t[30]=F);let I=l?-1:0,L=l&&`pointer-events-none`,R;t[31]===L?R=t[32]:(R=Y(`absolute inset-x-0 top-0 z-10 h-2 -translate-y-1/2 cursor-ns-resize touch-none select-none rounded-sm`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[var(--interactive-focus-ring)]`,L),t[31]=L,t[32]=R);let z,te;t[33]===l?(z=t[34],te=t[35]):(z=e=>{if(l||h.current||!e.isPrimary||e.button!==0)return;let t=m.current;t&&(h.current={pointerId:e.pointerId,startY:e.clientY,height:t.getBoundingClientRect().height},e.currentTarget.setPointerCapture(e.pointerId),e.preventDefault())},te=e=>{let t=h.current;l||!t||t.pointerId!==e.pointerId||S(t.height+t.startY-e.clientY,e.currentTarget)},t[33]=l,t[34]=z,t[35]=te);let B;t[36]===l?B=t[37]:(B=e=>{if(l||![`ArrowUp`,`ArrowDown`,`Home`].includes(e.key))return;e.preventDefault();let t=parseFloat(m.current?.style.height??``)||op;S(e.key===`Home`?op:t+(e.key===`ArrowUp`?10:-10),e.currentTarget)},t[36]=l,t[37]=B);let V;t[38]!==l||t[39]!==F||t[40]!==I||t[41]!==R||t[42]!==z||t[43]!==te||t[44]!==B?(V=(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":F,"aria-valuemin":op,"aria-valuenow":op,"aria-disabled":l,tabIndex:I,className:R,onPointerDown:z,onPointerMove:te,onPointerUp:b,onPointerCancel:b,onLostPointerCapture:b,onKeyDown:B}),t[38]=l,t[39]=F,t[40]=I,t[41]=R,t[42]=z,t[43]=te,t[44]=B,t[45]=V):V=t[45];let H;return t[46]!==P||t[47]!==V?(H=(0,$.jsxs)(`div`,{className:`relative min-w-0`,children:[P,V]}),t[46]=P,t[47]=V,t[48]=H):H=t[48],H};function lp(e){return e.inputSpellcheckEnabled}var up=e=>{let t=(0,qi.c)(30),{highlights:n,onInsert:r}=e,{t:i}=be();if(n.length===0)return null;let a;t[0]!==n||t[1]!==r?(a=()=>{r(n)},t[0]=n,t[1]=r,t[2]=a):a=t[2];let o=a,s;t[3]===i?s=t[4]:(s=i(`gitView.commit.aiHighlights.title`),t[3]=i,t[4]=s);let c;t[5]===s?c=t[6]:(c=(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:s}),t[5]=s,t[6]=c);let l;t[7]===i?l=t[8]:(l=i(`gitView.commit.aiHighlights.insertAria`),t[7]=i,t[8]=l);let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(Z,{name:`arrow-down`,className:`size-4`}),t[9]=u):u=t[9];let d;t[10]!==o||t[11]!==l?(d=(0,$.jsx)(On,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:o,"aria-label":l,children:u})}),t[10]=o,t[11]=l,t[12]=d):d=t[12];let f;t[13]===i?f=t[14]:(f=i(`gitView.commit.aiHighlights.insertTooltip`),t[13]=i,t[14]=f);let p;t[15]===f?p=t[16]:(p=(0,$.jsx)(kn,{sideOffset:8,children:f}),t[15]=f,t[16]=p);let m;t[17]!==d||t[18]!==p?(m=(0,$.jsxs)(An,{children:[d,p]}),t[17]=d,t[18]=p,t[19]=m):m=t[19];let h;t[20]!==c||t[21]!==m?(h=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[c,m]}),t[20]=c,t[21]=m,t[22]=h):h=t[22];let g;t[23]===n?g=t[24]:(g=n.map(dp),t[23]=n,t[24]=g);let _;t[25]===g?_=t[26]:(_=(0,$.jsx)(`ul`,{className:`space-y-1`,children:g}),t[25]=g,t[26]=_);let v;return t[27]!==h||t[28]!==_?(v=(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2`,children:[h,_]}),t[27]=h,t[28]=_,t[29]=v):v=t[29],v};function dp(e,t){return(0,$.jsx)(`li`,{className:`typography-meta text-foreground`,children:e},`${e}-${t}`)}var fp=e=>{let t=(0,qi.c)(105),{compact:n,stagedCount:r,commitMessage:i,onCommitMessageChange:a,generatedHighlights:o,onInsertHighlights:s,onGenerateMessage:c,isGeneratingMessage:l,onCommit:u,onCommitAndPush:d,commitAction:f,hasPendingIndexMutation:p,gitmojiEnabled:m,onOpenGitmojiPicker:h}=e,g=n!==void 0&&n,_=p!==void 0&&p,{t:v}=be(),y=r>0,b;t[0]!==f||t[1]!==i||t[2]!==_||t[3]!==y?(b=i.trim()&&y&&f===null&&!_,t[0]=f,t[1]=i,t[2]=_,t[3]=y,t[4]=b):b=t[4];let x=b,{isMobile:S,hasTouchInput:C}=Yn(),w=g?`pt-0`:`pt-2`,T;t[5]===w?T=t[6]:(T=Y(`flex w-full items-baseline gap-2 px-0 pb-1`,w),t[5]=w,t[6]=T);let E=T,D=g?`gap-1.5 pb-1`:`gap-3 pt-1 pb-3`,O;t[7]===D?O=t[8]:(O=Y(`flex flex-col px-0`,D),t[7]=D,t[8]=O);let k=O,A=g?`size-3.5`:`size-4`,j=g?`text-xs leading-4`:`typography-ui-header`,M;t[9]===j?M=t[10]:(M=Y(`shrink-0 font-semibold text-foreground`,j),t[9]=j,t[10]=M);let N;t[11]===v?N=t[12]:(N=v(`gitView.commit.title`),t[11]=v,t[12]=N);let ee;t[13]!==N||t[14]!==M?(ee=(0,$.jsx)(`h3`,{className:M,children:N}),t[13]=N,t[14]=M,t[15]=ee):ee=t[15];let P;t[16]!==g||t[17]!==y||t[18]!==v?(P=y?null:(0,$.jsx)(`span`,{className:Y(`min-w-0 truncate text-muted-foreground`,g?`text-[0.6875rem] leading-4`:`typography-meta`),children:v(`gitView.commit.stageFilesHint`)}),t[16]=g,t[17]=y,t[18]=v,t[19]=P):P=t[19];let F;t[20]!==E||t[21]!==ee||t[22]!==P?(F=(0,$.jsxs)(`div`,{className:E,children:[ee,P]}),t[20]=E,t[21]=ee,t[22]=P,t[23]=F):F=t[23];let I;t[24]!==o||t[25]!==s?(I=(0,$.jsx)(up,{highlights:o,onInsert:s}),t[24]=o,t[25]=s,t[26]=I):I=t[26];let L;t[27]===v?L=t[28]:(L=v(`gitView.commit.messagePlaceholder`),t[27]=v,t[28]=L);let R=f!==null,z;t[29]!==i||t[30]!==g||t[31]!==C||t[32]!==S||t[33]!==a||t[34]!==L||t[35]!==R?(z=(0,$.jsx)(cp,{value:i,onChange:a,placeholder:L,disabled:R,hasTouchInput:C,isMobile:S,compact:g}),t[29]=i,t[30]=g,t[31]=C,t[32]=S,t[33]=a,t[34]=L,t[35]=R,t[36]=z):z=t[36];let te=g?`gap-1`:`gap-2`,B;t[37]===te?B=t[38]:(B=Y(`@container/commit-actions flex items-center min-w-0`,te),t[37]=te,t[38]=B);let V=g?`ghost`:`outline`,H=g?`xs`:`sm`,ne=l||f!==null||_||r===0,re;t[39]===v?re=t[40]:(re=v(`gitView.commit.generateAria`),t[39]=v,t[40]=re);let U=g&&`text-xs`,W;t[41]===U?W=t[42]:(W=Y(`commit-actions__btn`,U),t[41]=U,t[42]=W);let ie;t[43]!==A||t[44]!==l?(ie=l?(0,$.jsx)(Z,{name:`loader-4`,className:Y(A,`animate-spin`)}):(0,$.jsx)(Z,{name:`ai-generate-2`,className:Y(A,`text-primary`)}),t[43]=A,t[44]=l,t[45]=ie):ie=t[45];let ae;t[46]===v?ae=t[47]:(ae=v(`gitView.commit.generate`),t[46]=v,t[47]=ae);let oe;t[48]===ae?oe=t[49]:(oe=(0,$.jsx)(`span`,{className:`commit-actions__label`,children:ae}),t[48]=ae,t[49]=oe);let G;t[50]!==c||t[51]!==V||t[52]!==H||t[53]!==ne||t[54]!==re||t[55]!==W||t[56]!==ie||t[57]!==oe?(G=(0,$.jsxs)(X,{variant:V,size:H,onClick:c,disabled:ne,type:`button`,"aria-label":re,className:W,children:[ie,oe]}),t[50]=c,t[51]=V,t[52]=H,t[53]=ne,t[54]=re,t[55]=W,t[56]=ie,t[57]=oe,t[58]=G):G=t[58];let K;t[59]!==g||t[60]!==m||t[61]!==A||t[62]!==h||t[63]!==v?(K=m?(0,$.jsxs)(An,{children:[(0,$.jsx)(On,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`xs`,type:`button`,onClick:h,"aria-label":v(`gitView.commit.addGitmoji`),className:Y(`shrink-0 p-0 text-muted-foreground`,g?`w-6`:`size-7`),children:(0,$.jsx)(Z,{name:`emotion-happy`,className:A})})}),(0,$.jsx)(kn,{side:`top`,children:(0,$.jsx)(`p`,{children:v(`gitView.commit.addGitmoji`)})})]}):null,t[59]=g,t[60]=m,t[61]=A,t[62]=h,t[63]=v,t[64]=K):K=t[64];let se;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(`div`,{className:`flex-1`}),t[65]=se):se=t[65];let ce=g?`xs`:`sm`,q=g?`default`:`outline`,le=!x||l,ue=g&&`text-xs`,de;t[66]===ue?de=t[67]:(de=Y(`commit-actions__btn whitespace-nowrap`,ue),t[66]=ue,t[67]=de);let fe;t[68]===v?fe=t[69]:(fe=v(`gitView.commit.commitAria`),t[68]=v,t[69]=fe);let pe;t[70]!==f||t[71]!==A||t[72]!==v?(pe=f===`commit`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`loader-4`,className:Y(A,`animate-spin`)}),(0,$.jsx)(`span`,{className:`commit-actions__label`,children:v(`gitView.commit.committing`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`git-commit`,className:A}),(0,$.jsx)(`span`,{className:`commit-actions__label`,children:v(`gitView.commit.commit`)})]}),t[70]=f,t[71]=A,t[72]=v,t[73]=pe):pe=t[73];let me;t[74]!==u||t[75]!==ce||t[76]!==q||t[77]!==le||t[78]!==de||t[79]!==fe||t[80]!==pe?(me=(0,$.jsx)(X,{size:ce,variant:q,onClick:u,disabled:le,className:de,"aria-label":fe,children:pe}),t[74]=u,t[75]=ce,t[76]=q,t[77]=le,t[78]=de,t[79]=fe,t[80]=pe,t[81]=me):me=t[81];let he;t[82]!==x||t[83]!==f||t[84]!==g||t[85]!==A||t[86]!==l||t[87]!==S||t[88]!==d||t[89]!==v?(he=S?(0,$.jsxs)(An,{children:[(0,$.jsx)(On,{asChild:!0,children:(0,$.jsx)(X,{variant:`default`,size:`sm`,onClick:()=>d(),disabled:!x||l,className:`h-7 w-7 p-0`,"aria-label":v(`gitView.commit.pushAria`),children:f===`commitAndPush`?(0,$.jsx)(Z,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(Z,{name:`arrow-up`,className:`size-3.5`})})}),(0,$.jsx)(kn,{side:`top`,children:(0,$.jsx)(`p`,{children:v(`gitView.commit.push`)})})]}):(0,$.jsx)(X,{size:g?`xs`:`sm`,variant:`default`,onClick:()=>d(),disabled:!x||l,className:Y(`commit-actions__btn`,g&&`text-xs`),"aria-label":v(`gitView.commit.pushAria`),children:f===`commitAndPush`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`loader-4`,className:Y(A,`animate-spin`)}),(0,$.jsx)(`span`,{className:`commit-actions__label commit-actions__label--push`,children:v(`gitView.commit.pushing`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`arrow-up`,className:`size-3.5`}),(0,$.jsx)(`span`,{className:`commit-actions__label commit-actions__label--push`,children:v(`gitView.commit.push`)})]})}),t[82]=x,t[83]=f,t[84]=g,t[85]=A,t[86]=l,t[87]=S,t[88]=d,t[89]=v,t[90]=he):he=t[90];let ge;t[91]!==B||t[92]!==G||t[93]!==K||t[94]!==me||t[95]!==he?(ge=(0,$.jsxs)(`div`,{className:B,children:[G,K,se,me,he]}),t[91]=B,t[92]=G,t[93]=K,t[94]=me,t[95]=he,t[96]=ge):ge=t[96];let _e;t[97]!==k||t[98]!==I||t[99]!==z||t[100]!==ge?(_e=(0,$.jsxs)(`div`,{className:k,children:[I,z,ge]}),t[97]=k,t[98]=I,t[99]=z,t[100]=ge,t[101]=_e):_e=t[101];let J;return t[102]!==F||t[103]!==_e?(J=(0,$.jsxs)(`section`,{className:`shrink-0 border-0 bg-transparent rounded-none`,"data-git-commit-section":!0,children:[F,_e]}),t[102]=F,t[103]=_e,t[104]=J):J=t[104],J};function pp(e){let t=(0,qi.c)(22),{onViewSource:n}=e,{t:r}=be(),i,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{d:`M23 9h23l13 13v43a6 6 0 0 1-6 6H23a6 6 0 0 1-6-6V15a6 6 0 0 1 6-6Z`,stroke:`currentColor`,strokeWidth:`1.5`,opacity:`.45`}),a=(0,$.jsx)(`path`,{d:`M46 9v10a3 3 0 0 0 3 3h10`,stroke:`currentColor`,strokeWidth:`1.5`,opacity:`.45`}),t[0]=i,t[1]=a):(i=t[0],a=t[1]);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsxs)(`svg`,{className:`size-20 shrink-0 text-muted-foreground`,viewBox:`0 0 80 80`,fill:`none`,"aria-hidden":`true`,focusable:`false`,children:[i,a,(0,$.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,className:`yuri-preview-loading-lines`,children:[(0,$.jsx)(`path`,{d:`M28 35h20`}),(0,$.jsx)(`path`,{d:`M28 45h20`}),(0,$.jsx)(`path`,{d:`M28 55h12`})]})]}),t[2]=o):o=t[2];let s;t[3]===r?s=t[4]:(s=r(`guiPlugins.preview.loadingTitle`),t[3]=r,t[4]=s);let c;t[5]===s?c=t[6]:(c=(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-foreground`,children:s}),t[5]=s,t[6]=c);let l;t[7]===r?l=t[8]:(l=r(`guiPlugins.preview.loadingDescription`),t[7]=r,t[8]=l);let u;t[9]===l?u=t[10]:(u=(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:l}),t[9]=l,t[10]=u);let d;t[11]!==c||t[12]!==u?(d=(0,$.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`max-w-sm space-y-1.5 break-words`,children:[c,u]}),t[11]=c,t[12]=u,t[13]=d):d=t[13];let f;t[14]===r?f=t[15]:(f=r(`guiPlugins.preview.viewSource`),t[14]=r,t[15]=f);let p;t[16]!==n||t[17]!==f?(p=(0,$.jsx)(X,{variant:`ghost`,size:`sm`,className:`focus-visible:bg-interactive-hover`,onClick:n,children:f}),t[16]=n,t[17]=f,t[18]=p):p=t[18];let m;return t[19]!==p||t[20]!==d?(m=(0,$.jsx)(`div`,{className:`flex h-full min-h-[240px]! min-w-0 flex-1`,"data-gui-preview-loading":!0,children:(0,$.jsxs)(Bi,{illustration:o,children:[d,p]})}),t[19]=p,t[20]=d,t[21]=m):m=t[21],m}function mp({path:e,base:t,active:n=!0,children:r}){let i=Q.useContext(or),a=n&&i,{host:o,snapshot:s,inventory:c,loading:l,error:u,requested:d,requestLoad:f}=Dr(),{t:p}=be(),m=Q.useRef(null),[h]=Q.useState(()=>document.createElement(`div`)),g=Q.useRef(null),_=Q.useRef(l),[v,y]=Q.useState(null),b=JSON.stringify([e,t,s.sessionKey]),[x,S]=Q.useState(null),C=Hi(s.plugins),w=s.plugins.some(e=>e.status===`active`),T=a&&o?o.filePanel(e,t):void 0,E=!!(T&&x!==b),D=u||c.find(e=>e.enabled&&e.error)?.error||s.plugins.find(e=>e.status===`failed`)?.error,O=a&&!E&&l&&!D&&x!==b;Q.useEffect(()=>{a&&e&&!d&&m.current&&!m.current.closest(`[inert], [hidden], [aria-hidden="true"]`)&&f()},[a,e,d,f]),Q.useLayoutEffect(()=>{if(!(!a||!o||!e||!w||m.current?.closest(`[inert], [hidden], [aria-hidden="true"]`)))return o.registerFileView(e,t)},[a,o,e,t,w,s.sessionKey]);let k=J(n=>{if(o){y(null);try{let r=o.openLink({href:e,exact:!0,base:t});n&&!r&&y(p(`guiPlugins.noPreview`))}catch(e){y(e instanceof Error?e.message:p(`guiPlugins.error`))}}});Q.useEffect(()=>{if(_.current&&!l&&(g.current=null),_.current=l,!a){g.current=null;return}if(!o||!e||!w||!m.current||m.current.closest(`[inert], [hidden], [aria-hidden="true"]`))return;let n=JSON.stringify([e,t,C,s.sessionKey]);(g.current?.host!==o||g.current.key!==n)&&(g.current={host:o,key:n},k(!1))},[a,l,o,e,t,C,w,s.sessionKey,k]);let A=p(E||O?`filesView.editor.switchToEditMode`:`filesView.editor.switchToPreviewMode`),j=a&&(T||v||O)?(0,$.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":A,title:A,disabled:!o&&!O,onClick:()=>{E||O?S(b):(S(null),k(!0))},children:(0,$.jsx)(Z,{name:E||O?`eye`:`eye-off`,className:`size-4`,"aria-hidden":`true`})}):null,M=j?(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[E?(0,$.jsx)(zi,{target:h}):null,j]}):null,N=E&&o&&T?(0,$.jsx)(Vi,{host:o,contributionKey:T.key,kind:`panel`,actions:h,revision:JSON.stringify([Hi(s.plugins,T.pluginId),s.sessionKey]),fallback:(0,$.jsx)(pp,{onViewSource:()=>S(b)})}):O?(0,$.jsx)(pp,{onViewSource:()=>S(b)}):null;return(0,$.jsxs)(`div`,{ref:m,className:`relative flex h-full min-h-0 min-w-0 flex-1 flex-col`,"data-gui-file-view":e,"data-mobile-edge-to-edge-preview":N?`true`:void 0,children:[v?(0,$.jsx)(`span`,{role:`status`,className:`shrink-0 px-3 py-1 break-words typography-meta text-muted-foreground`,children:v}):null,typeof r==`function`?r({preview:N,toggle:j,controls:M}):(0,$.jsxs)($.Fragment,{children:[M?(0,$.jsx)(`div`,{className:`absolute right-6 top-3 z-30 flex items-center gap-1`,"data-gui-preview-controls":!0,children:M}):null,N??r]})]})}function hp({path:e}){let{files:t,runtime:n}=ne(),{t:r}=be(),[i,a]=Q.useState(!1),o=n.isDesktop&&p(),s=async e=>{a(!0);try{await e()}catch{yt.error(r(`sidebarFilesTree.toast.operationFailed`))}finally{a(!1)}};return(0,$.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center p-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-4`,children:[(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground`,children:r(`filesView.binary.description`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[o&&(0,$.jsx)(X,{disabled:i,onClick:()=>void s(async()=>{if(!await c(e))throw Error(`System open failed`)}),children:r(`filesView.binary.openSystemApp`)}),t.downloadFile&&(0,$.jsx)(X,{disabled:i,onClick:()=>void s(()=>t.downloadFile(e)),children:r(`sidebarFilesTree.menu.save`)})]})]})})}function gp(){let e=(0,qi.c)(5),t=rt(),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Set,e[0]=r):r=e[0];let i=Q.useRef(r),a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=n(),e[1]=a):a=e[1];let o=a,s,c;e[2]===t.data?(s=e[3],c=e[4]):(s=()=>{if(!t.data)return;let e=jt.getState();for(let[n,r]of Object.entries(e.sessionOrderByScope)){let a=`${o}:${n}`;Object.hasOwn(t.data.sessionOrderByScope,n)||i.current.has(a)||e.isSessionOrderPending(n)||(i.current.add(a),Ie(n,r,e.sessionOrderActivityByScope[n]??{},!0).catch(()=>{i.current.delete(a)}))}e.applySessionOrderSnapshot(t.data)},c=[t.data,o],e[2]=t.data,e[3]=s,e[4]=c),Q.useEffect(s,c)}var _p=(0,Q.createContext)(!1),vp=[({transform:e})=>({...e,x:0})],yp=e=>{let t=(0,qi.c)(27),{sessionId:n,sessionDirectory:r,sessionTitle:i,children:a}=e,o=`session-drag:${n}`,s;t[0]!==r||t[1]!==n||t[2]!==i?(s={type:`session`,sessionId:n,sessionDirectory:r,sessionTitle:i},t[0]=r,t[1]=n,t[2]=i,t[3]=s):s=t[3];let c;t[4]!==o||t[5]!==s?(c={id:o,data:s},t[4]=o,t[5]=s,t[6]=c):c=t[6];let{attributes:l,listeners:u,setNodeRef:d,transform:f,transition:p,isDragging:m}=Gr(c),h;t[7]===u?h=t[8]:(h=e=>{e.target.closest(`input, textarea, button[aria-label], [data-session-drag-ignore]`)||(e.stopPropagation(),u?.onMouseDown?.(e))},t[7]=u,t[8]=h);let g=J(h),_;t[9]===u?_=t[10]:(_=e=>{e.target.closest(`input, textarea, button[aria-label], [data-session-drag-ignore]`)||(e.stopPropagation(),u?.onTouchStart?.(e))},t[9]=u,t[10]=_);let v=J(_),y;t[11]===f?y=t[12]:(y=Ur.Translate.toString(f),t[11]=f,t[12]=y);let b;t[13]!==y||t[14]!==p?(b={transform:y,transition:p},t[13]=y,t[14]=p,t[15]=b):b=t[15];let x=m?`opacity-30`:void 0,S;t[16]!==a||t[17]!==m?(S=(0,$.jsx)(_p.Provider,{value:m,children:a}),t[16]=a,t[17]=m,t[18]=S):S=t[18];let C;return t[19]!==l||t[20]!==g||t[21]!==v||t[22]!==d||t[23]!==b||t[24]!==x||t[25]!==S?(C=(0,$.jsx)(`div`,{ref:d,"data-session-sortable-row":!0,...l,onMouseDown:g,onTouchStart:v,style:b,className:x,children:S}),t[19]=l,t[20]=g,t[21]=v,t[22]=d,t[23]=b,t[24]=x,t[25]=S,t[26]=C):C=t[26],C},bp=e=>{let t=(0,qi.c)(11),{folderId:n,children:r}=e,i=`folder-drop:${n}`,a;t[0]===n?a=t[1]:(a={type:`folder`,folderId:n},t[0]=n,t[1]=a);let o;t[2]!==i||t[3]!==a?(o={id:i,data:a},t[2]=i,t[3]=a,t[4]=o):o=t[4];let{setNodeRef:s,isOver:c}=Fr(o),l;t[5]!==r||t[6]!==c||t[7]!==s?(l=r(s,c),t[5]=r,t[6]=c,t[7]=s,t[8]=l):l=t[8];let u;return t[9]===l?u=t[10]:(u=(0,$.jsx)($.Fragment,{children:l}),t[9]=l,t[10]=u),u},xp=e=>{let t=(0,qi.c)(25),{scopeKey:n,onSessionDroppedOnFolder:r,sessionIds:i,folderIdBySessionId:a,onSessionsReordered:o,children:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={activationConstraint:{distance:8}},t[0]=c):c=t[0];let l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l={activationConstraint:{delay:350,tolerance:6}},t[1]=l):l=t[1];let u=Hr(Nr(zr,c),Nr(Pr,l)),[d,f]=Q.useState(null),[p,m]=Q.useState(`Session`),[h,g]=Q.useState(null),[_,v]=Q.useState(null);if(!n){let e;return t[2]===s?e=t[3]:(e=(0,$.jsx)($.Fragment,{children:s}),t[2]=s,t[3]=e),e}let y;t[4]!==a||t[5]!==r||t[6]!==o?(y=e=>{gt(`light`,{bypassCadence:!0}),f(null),g(null),v(null);let{active:t,over:n}=e;if(!n)return;let i=t.data.current,s=n.data.current;if(i?.type===`session`&&i.sessionId&&s?.type===`folder`&&s.folderId){r(i.sessionId,s.folderId);return}if(i?.type===`session`&&i.sessionId&&s?.type===`session`&&typeof n.id==`string`){let e=n.id.replace(/^session-drag:/,``);el(i.sessionId,e,a)&&o(i.sessionId,e)}},t[4]=a,t[5]=r,t[6]=o,t[7]=y):y=t[7];let b=y,x,S;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>{let t=e.active.data.current;if(t?.type===`session`&&t.sessionId){gt(`medium`,{bypassCadence:!0}),f(t.sessionId),m(t.sessionTitle??`Session`);let n=e.active.rect.current.initial?.width,r=e.active.rect.current.initial?.height;g(typeof n==`number`?n:null),v(typeof r==`number`?r:null)}},S=()=>{gt(`light`,{bypassCadence:!0}),f(null),g(null),v(null)},t[8]=x,t[9]=S):(x=t[8],S=t[9]);let C;t[10]===i?C=t[11]:(C=i.map(Sp),t[10]=i,t[11]=C);let w;t[12]!==s||t[13]!==C?(w=(0,$.jsx)(qr,{items:C,strategy:Kr,children:s}),t[12]=s,t[13]=C,t[14]=w):w=t[14];let T;t[15]!==_||t[16]!==d||t[17]!==p||t[18]!==h?(T=typeof document<`u`?(0,Ji.createPortal)((0,$.jsx)(Rr,{children:d?(0,$.jsxs)(`div`,{style:{width:h?`${h}px`:`auto`,height:_?`${_}px`:`auto`},className:`flex items-center rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2.5 py-1 shadow-none pointer-events-none`,children:[(0,$.jsx)(Z,{name:`chat-thread`,className:`h-4 w-4 text-muted-foreground mr-2 flex-shrink-0`}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground`,children:p})]}):null}),document.body):null,t[15]=_,t[16]=d,t[17]=p,t[18]=h,t[19]=T):T=t[19];let E;return t[20]!==b||t[21]!==u||t[22]!==w||t[23]!==T?(E=(0,$.jsxs)(Vr,{sensors:u,modifiers:vp,collisionDetection:Lr,onDragStart:x,onDragCancel:S,onDragEnd:b,children:[w,T]}),t[20]=b,t[21]=u,t[22]=w,t[23]=T,t[24]=E):E=t[24],E};function Sp(e){return`session-drag:${e}`}var Cp=e=>{if(!e.enabled)return null;let t=ki(e.assistants.filter(e=>e.enabled))[0];return t?{id:t.id,seed:t.avatarSeed??t.id}:null};function wp(){let{data:e}=Ne(Cp);return e?.seed??null}var Tp=Q.memo(function(e){let t=(0,qi.c)(5),{className:n,size:r}=e,i=r===void 0?16:r,a=wp(),o=zt()?.currentTheme.metadata.variant===`dark`?`black`:`white`,s;return t[0]!==a||t[1]!==n||t[2]!==o||t[3]!==i?(s=a?(0,$.jsx)(`span`,{"aria-hidden":`true`,"data-assistant-navigation-avatar":``,className:`${n} inline-flex`,children:(0,$.jsx)(Ft,{seed:a,size:i,motion:`idle`,randomizeShape:!0,eyeColor:o})}):(0,$.jsx)(Z,{name:`ai-agent`,className:n}),t[0]=a,t[1]=n,t[2]=o,t[3]=i,t[4]=s):s=t[4],s}),Ep=e=>{let t=(0,qi.c)(29),{className:n,mobile:r}=e,i=r!==void 0&&r,{t:a}=be(),o=j(Dp),s=j(Op),c;t[0]===s?c=t[1]:(c=Un(Ln(`open_command_palette`,s)),t[0]=s,t[1]=c);let l=c,u=i?`mobileGlass`:`ghost`,d=i?`mobileIcon`:`icon`,f;t[2]===o?f=t[3]:(f=()=>o(!0),t[2]=o,t[3]=f);let p;t[4]===a?p=t[5]:(p=a(`commandPalette.title`),t[4]=a,t[5]=p);let m=!i&&`size-7 rounded-md text-muted-foreground/75 focus-visible:ring-2 focus-visible:ring-primary`,h;t[6]!==n||t[7]!==m?(h=Y(`app-region-no-drag`,m,n),t[6]=n,t[7]=m,t[8]=h):h=t[8];let g;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(Z,{name:`search`,className:`size-4 text-foreground/55 transition-colors group-hover:text-foreground group-focus-visible:text-foreground`}),t[9]=g):g=t[9];let _;t[10]!==u||t[11]!==d||t[12]!==f||t[13]!==p||t[14]!==h?(_=(0,$.jsx)(On,{asChild:!0,children:(0,$.jsx)(X,{variant:u,size:d,onClick:f,"aria-label":p,className:h,children:g})}),t[10]=u,t[11]=d,t[12]=f,t[13]=p,t[14]=h,t[15]=_):_=t[15];let v;t[16]===a?v=t[17]:(v=a(`commandPalette.title`),t[16]=a,t[17]=v);let y;t[18]===v?y=t[19]:(y=(0,$.jsx)(`span`,{children:v}),t[18]=v,t[19]=y);let b;t[20]!==i||t[21]!==l?(b=i?null:(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:l}),t[20]=i,t[21]=l,t[22]=b):b=t[22];let x;t[23]!==y||t[24]!==b?(x=(0,$.jsx)(kn,{children:(0,$.jsxs)(`p`,{className:`flex items-center gap-2`,children:[y,b]})}),t[23]=y,t[24]=b,t[25]=x):x=t[25];let S;return t[26]!==_||t[27]!==x?(S=(0,$.jsxs)(An,{children:[_,x]}),t[26]=_,t[27]=x,t[28]=S):S=t[28],S};function Dp(e){return e.setCommandPaletteOpen}function Op(e){return e.shortcutOverrides}var kp=`__pinned__`,Ap=e=>{let t=e.time?.created;return typeof t==`number`&&Number.isFinite(t)?t:0},jp=(e,t,n=[])=>{let r=new Map(n.map((e,t)=>[e,t]));return e.filter(e=>t.has(e.id)).sort((e,t)=>(r.get(e.id)??n.length)-(r.get(t.id)??n.length)||Ap(t)-Ap(e))},Mp=e=>e.parentID??null,Np=e=>{let t=e.time?.archived;return typeof t==`number`&&t>0},Pp=(e,t,n,r)=>{let i=[];for(let a of e){if(t.has(a.id)||Np(a)||Mp(a))continue;let e=n.has(a.id),o=(r[a.id]??0)>0;!e&&!o||i.push(a)}return i.sort((e,t)=>ze(t)-ze(e)),i},Fp=(e,t)=>{let n=e?.trim()||null;return!n||n===`HEAD`||t&&n===t?null:n},Ip=e=>{let t=e.projectLabel?.trim()||null;if(e.isVSCode)return t?{projectLabel:t,branchLabel:null}:null;let n;n=e.owner?.kind===`worktree`?e.worktrees.find(t=>W(t.path)===e.owner?.scopeDirectory)?.branch??e.sessionWorktree?.branch:e.projectRootBranch??e.sessionWorktree?.branch;let r=Fp(n,t);return!t&&!r?null:{projectLabel:t,branchLabel:r}};function Lp(e,t){return!t||t===`manual`?e:[...e].sort((e,n)=>{switch(t){case`a-z`:case`z-a`:{let r=(e.label||e.path).toLowerCase().localeCompare((n.label||n.path).toLowerCase(),`en`);return t===`z-a`?-r:r}case`date-added`:return(n.addedAt??0)-(e.addedAt??0);case`recent`:return(n.lastOpenedAt??0)-(e.lastOpenedAt??0);default:return 0}})}var Rp=e=>!!e.time?.archived,zp=e=>{let t=e.parentID;return typeof t==`string`&&t.trim()?t:null},Bp=(e,t={})=>{let n=t.pinnedSessionIds??new Set,r=t.omitPinnedSessions===!0,i=t.getWorktree??(()=>null),a=Vn(e).sort((e,t)=>Wn(e,t,n)),o=new Map(a.map(e=>[e.id,e])),s=new Map;a.forEach(e=>{let t=zp(e);if(!t)return;let i=o.get(t);if(!i||Rp(i)!==Rp(e)||r&&n.has(t))return;let a=s.get(t)??[];a.push(e),s.set(t,a)}),s.forEach(e=>e.sort((e,t)=>Wn(e,t,n)));let c=e=>({session:e,children:(s.get(e.id)??[]).filter(e=>!(r&&n.has(e.id))).map(e=>c(e)),worktree:i(e)});return a.filter(e=>!(r&&n.has(e.id)||zp(e))).map(e=>c(e))},Vp=()=>{let e=bt.getState(),t=e.currentSessionId,n=j.getState(),r=!!e.newSessionDraft?.open&&!t;er({sessionId:t,isNewSession:r,tab:n.activeMainTab||`chat`,isSettingsOpen:n.isSettingsDialogOpen,settingsPath:n.settingsPage,diffFile:null,diffScope:null},{replace:!0,force:!0})},Hp=()=>{ie(),E.reconnectToRuntimeBaseUrl(),Ye.setState({catalogTransportIdentity:n()}),vt()},Up=e=>{bt.getState().prepareForRuntimeSwitch(e.previousRuntimeKey),j.getState().prepareForRuntimeSwitch(e.previousRuntimeKey),ie(),E.reconnectToRuntimeBaseUrl();let t=Ye.persist.getOptions().storage;Ye.persist.setOptions({storage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{}}}),Ye.setState({catalogTransportIdentity:n(),activeDirectoryKey:`__global__`,directoryScoped:{},providerConfigLoadingByDirectory:{},agentConfigLoadingByDirectory:{},providers:[],agents:[],defaultProviders:{},currentProviderId:``,currentModelId:``,currentVariant:void 0,currentAgentName:void 0,selectedProviderId:``,agentModelSelections:{},lastSelectedAgentName:void 0,lastUserSelection:void 0,globalLastUserSelection:void 0,opencodeDefaultAgent:void 0,opencodeDefaultModel:void 0,selectionSource:`auto`,settingsDefaultModel:void 0,settingsDefaultVariant:void 0,settingsDefaultAgent:void 0,isConnected:!1,isInitialized:!1,connectionPhase:`connecting`,lastDisconnectReason:null}),Ye.persist.setOptions({storage:t}),Ye.persist.rehydrate(),ct.getState().resetForRuntimeSwitch(),Ze.getState().resetForRuntimeSwitch(),Re.getState().reset(),bi(),$t(),bt.getState().restoreForRuntimeSwitch(e.runtimeKey),j.getState().restoreForRuntimeSwitch(e.runtimeKey),Vp(),vt()};export{Yc as $,zu as A,Ol as B,Lf as C,ra as Ct,qu as D,td as E,Al as F,hl as G,Sl as H,Ml as I,sl as J,dl as K,Nl as L,Fu as M,_u as N,Vu as O,jl as P,ol as Q,El as R,Mf as S,fa as St,nd as T,yl as U,Tl as V,gl as W,cl as X,rl as Y,al as Z,mp as _,Ra as _t,kp as a,Wc as at,ip as b,Ca as bt,Ip as c,xs as ct,yp as d,cs as dt,$c as et,bp as f,Jo as ft,hp as g,Ba as gt,gp as h,Ja as ht,Lp as i,Kc as it,Ru as j,Bu as k,Ep as l,hs as lt,_p as m,Ya as mt,Up as n,Gc as nt,jp as o,As as ot,xp as p,so as pt,ll as q,Bp as r,qc as rt,Pp as s,Ws as st,Hp as t,Qc as tt,Tp as u,ss as ut,fp as v,Ia as vt,wd as w,rp as x,va as xt,ap as y,wa as yt,Dl as z};