@openchambery/web 2.0.0-beta.4 → 2.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentAvatar-Q1SmFRx2.js → AgentAvatar-BBmQXYDq.js} +1 -1
- package/dist/assets/{AssistantView-CwXkiCAd.js → AssistantView-BG8hK4y9.js} +3 -3
- package/dist/assets/{DiagramView-BW92schO.js → DiagramView-CN0qWNU5.js} +1 -1
- package/dist/assets/{FadeInOnReveal-BZmwl-zE.js → FadeInOnReveal-w_BQ7K7K.js} +1 -1
- package/dist/assets/Icon-B9kZgYZn.js +1 -0
- package/dist/assets/{MarkdownRenderer-Bv05iDZZ.js → MarkdownRenderer-Ds61--LT.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-C81xqYib.js → MarkdownRendererImpl-DOMmiOH0.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-CXUCQuKJ.js → MarkstreamRendererImpl-F7MGg5ER.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-BMgIu7zc.js → MobileDetailNavigation-DcmVOjkw.js} +1 -1
- package/dist/assets/{MobileShareBridge-BOXGNHmC.js → MobileShareBridge-C1Fc4ErB.js} +2 -2
- package/dist/assets/MobileSurface-BA7eS5Yd.js +2 -0
- package/dist/assets/{MultiRunWindow-B5At2Z95.js → MultiRunWindow-BoTnH6Yp.js} +1 -1
- package/dist/assets/{OnboardingScreen-bsPLgz4r.js → OnboardingScreen-BxItVnnO.js} +1 -1
- package/dist/assets/{OverlayScrollbar-4wp4migh.js → OverlayScrollbar-B4e0QD05.js} +1 -1
- package/dist/assets/SettingsView-CjesWNLw.js +25 -0
- package/dist/assets/{SettingsWindow-CMtX2bMl.js → SettingsWindow-CReMbg-w.js} +1 -1
- package/dist/assets/TerminalView-C64-QYOG.js +8 -0
- package/dist/assets/{ToolOutputDialog-uH1ZZDSS.js → ToolOutputDialog-CJu8DNrt.js} +1 -1
- package/dist/assets/{appThemeRegistry-DK7q2juD.js → appThemeRegistry-CF4lIxNt.js} +1 -1
- package/dist/assets/{button-CcNJUxUd.js → button-CwXyux0a.js} +1 -1
- package/dist/assets/collapsible-BZ6_cYJd.js +1 -0
- package/dist/assets/context-menu-DHrRifPE.js +1 -0
- package/dist/assets/{desktopHosts-C6HrP0jq.js → desktopHosts-JGFqhlaM.js} +1 -1
- package/dist/assets/{desktopRelayRestore-DdVBp45U.js → desktopRelayRestore-CHEwrI93.js} +1 -1
- package/dist/assets/{diagram-CxTs9hCQ.js → diagram-BwnPNKWt.js} +1 -1
- package/dist/assets/{dialog-KMVL9QKF.js → dialog-Dp0lQv5K.js} +1 -1
- package/dist/assets/es-DicJ8lKD.js +15 -0
- package/dist/assets/{fileMentionTouchSelection-7RIwlpkB.js → fileMentionTouchSelection-DPZRxNa2.js} +3 -4
- package/dist/assets/{fileQueries-CjdBRy8y.js → fileQueries-DN6gbLhM.js} +1 -1
- package/dist/assets/fr-lhgVcBW_.js +13 -0
- package/dist/assets/{gitApi-yuWg9BN4.js → gitApi-D8R7ic-T.js} +1 -1
- package/dist/assets/{imageSource-9vQBq3zp.js → imageSource-BMztRu0c.js} +1 -1
- package/dist/assets/{input-CrIvk3HZ.js → input-Biw8aNzR.js} +1 -1
- package/dist/assets/insertionBoundaries-DdwCD4S2.js +1 -0
- package/dist/assets/ja-B9EZwOcw.js +15 -0
- package/dist/assets/ko-Dxk-uJRb.js +15 -0
- package/dist/assets/main-BhlwwJ2c.js +169 -0
- package/dist/assets/main-D2BzpnUt.css +1 -0
- package/dist/assets/main-DSPCkT74.js +2 -0
- package/dist/assets/{markdownHeightCache-BmXVY_gc.js → markdownHeightCache-BOOrGCuG.js} +1 -1
- package/dist/assets/markdownTheme-DM5h1i18.js +1 -0
- package/dist/assets/{mcpQueries-C7jknHV8.js → mcpQueries-CE9tk-Jz.js} +1 -1
- package/dist/assets/miniChat-Ckk9ABql.js +2 -0
- package/dist/assets/mobile-cLMRZqI9.js +2 -0
- package/dist/assets/multirun-DVnFRb1V.js +4 -0
- package/dist/assets/persistence-D0y7226-.js +3 -0
- package/dist/assets/pl-CFhwWLJj.js +15 -0
- package/dist/assets/platform-D_c-T5nO.js +6 -0
- package/dist/assets/projectMeta-CSQgHequ.js +3 -0
- package/dist/assets/pt-BR-Ba6GfZ6J.js +15 -0
- package/dist/assets/renderElectronMiniChatApp-gGFkwoL_.js +2 -0
- package/dist/assets/{renderMobileApp-CGMMqbsO.js → renderMobileApp-B2w50kAc.js} +7 -7
- package/dist/assets/{runtimeConfig-BEANkvOd.js → runtimeConfig-BHH1hJDd.js} +1 -1
- package/dist/assets/runtimeEndpointReset-5uJ4sJk0.js +149 -0
- package/dist/assets/{sessionChangeSummary-qOLrP9fw.js → sessionChangeSummary-spf_atO8.js} +2 -2
- package/dist/assets/{sessionLookup-34XFmP9C.js → sessionLookup-BGjjwiCq.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-DyEV0Heg.js → sortable-tabs-strip-CTY_wG46.js} +1 -1
- package/dist/assets/src-BjEyU6if.css +2 -0
- package/dist/assets/store-DmowK-GO.js +15 -0
- package/dist/assets/{terminalApi-CXaBEoa_.js → terminalApi-Dhqqp4xi.js} +1 -1
- package/dist/assets/{textarea-BBOlRI9O.js → textarea-QxsmcBGj.js} +1 -1
- package/dist/assets/{tooltip-CPI4fr1a.js → tooltip-CpMLl5_k.js} +1 -1
- package/dist/assets/uk-ChchBzy6.js +15 -0
- package/dist/assets/{url-DRDQXjyX.js → url-CGbJbiJq.js} +1 -1
- package/dist/assets/{useAppFontEffects-CiDe42I5.js → useAppFontEffects-B1h7ab_J.js} +56 -51
- package/dist/assets/{useAssistantUIStore-asNG6K7n.js → useAssistantUIStore-Bz4tRflF.js} +1 -1
- package/dist/assets/useDesktopWindowControlsLayout-Cxsx84NO.js +1 -0
- package/dist/assets/{useEffectiveDirectory-C_CouL5v.js → useEffectiveDirectory-DsqhqsJR.js} +1 -1
- package/dist/assets/{useFontPreferences-B0oUZAiB.js → useFontPreferences-Xw1vSkmC.js} +1 -1
- package/dist/assets/useMobileNavigationStore-B1axS4g-.js +414 -0
- package/dist/assets/{useRuntimeAPIs-DwLtO0c_.js → useRuntimeAPIs-DSLXJybW.js} +1 -1
- package/dist/assets/useSessionAutoCleanup-B5FTG_qf.js +2 -0
- package/dist/assets/{useThemeSystem-BlNUWH47.js → useThemeSystem-DMzWVJaW.js} +1 -1
- package/dist/assets/useUIStore-syVmbuDA.js +1 -0
- package/dist/assets/{useWorkerHighlightedLines-CPNYz6Wf.js → useWorkerHighlightedLines-DC_Bc-RV.js} +1 -1
- package/dist/assets/{vendor-base-ui-CDjyofeD.js → vendor-base-ui-CnHfUmDN.js} +1 -1
- package/dist/assets/{vendor-cmdk-BFH0UpXX.js → vendor-cmdk-CeAGfrLo.js} +1 -1
- package/dist/assets/{vendor-dnd-kit-accessibility-BrR3AKvM.js → vendor-dnd-kit-accessibility-BY5LhhUB.js} +1 -1
- package/dist/assets/{vendor-dnd-kit-core-CNfdvk6H.js → vendor-dnd-kit-core-CvWxUPdb.js} +1 -1
- package/dist/assets/{vendor-dnd-kit-sortable-DQUaTeGj.js → vendor-dnd-kit-sortable-hHdP9lLb.js} +1 -1
- package/dist/assets/{vendor-framer-motion-4dogsUk3.js → vendor-framer-motion-DFy_BSVd.js} +1 -1
- package/dist/assets/{vendor-legendapp-list-BU7MdPZR.js → vendor-legendapp-list-WE32lwNk.js} +1 -1
- package/dist/assets/{vendor-markstream-react-qHC2FykU.js → vendor-markstream-react-DX55XLGO.js} +3 -3
- package/dist/assets/vendor-opencode-client-C12gfjag.js +12 -0
- package/dist/assets/{vendor-pierre-diffs-CUfqC003.js → vendor-pierre-diffs-DX7XTPG3.js} +1 -1
- package/dist/assets/{vendor-react-C94A0AHl.js → vendor-react-DLPElpoQ.js} +1 -1
- package/dist/assets/{vendor-react-drawio-FVlWqKVE.js → vendor-react-drawio-ECtEwvbc.js} +1 -1
- package/dist/assets/{vendor-reactuses-core-C2A3EjUi.js → vendor-reactuses-core-B8parU1Y.js} +1 -1
- package/dist/assets/{vendor-sonner-DNqHmUQs.js → vendor-sonner-DVzioF3d.js} +1 -1
- package/dist/assets/{vendor-stream-diffs-CwbKsmlv.js → vendor-stream-diffs-DWy3xSmp.js} +2 -2
- package/dist/assets/{vendor-tanstack-react-query-D0iFK57C.js → vendor-tanstack-react-query-D7pys_c9.js} +1 -1
- package/dist/assets/{vendor-tanstack-react-virtual-B2kV6cnT.js → vendor-tanstack-react-virtual-tlDgH6PG.js} +1 -1
- package/dist/assets/{vendor-zustand-BqLKf6ZY.js → vendor-zustand-B4dlGEM2.js} +1 -1
- package/dist/assets/zh-CN-Z_bkUQk5.js +15 -0
- package/dist/assets/zh-TW-CZeTm7kd.js +15 -0
- package/dist/index.html +13 -13
- package/dist/mini-chat.html +13 -13
- package/dist/mobile.html +13 -13
- package/package.json +3 -2
- package/server/index.js +38 -7
- package/server/lib/browser-provider/DOCUMENTATION.md +141 -0
- package/server/lib/browser-provider/contract.js +312 -0
- package/server/lib/browser-provider/host.js +421 -0
- package/server/lib/browser-provider/host.test.js +304 -0
- package/server/lib/browser-provider/routes.js +122 -0
- package/server/lib/browser-provider/routes.test.js +120 -0
- package/server/lib/browser-provider/selection-store.js +43 -0
- package/server/lib/browser-provider/selection-store.test.js +35 -0
- package/server/lib/notifications/DOCUMENTATION.md +3 -1
- package/server/lib/notifications/runtime.js +110 -26
- package/server/lib/notifications/runtime.test.js +92 -0
- package/server/lib/notifications/template-runtime.js +130 -38
- package/server/lib/notifications/template-runtime.test.js +96 -0
- package/server/lib/opencode/DOCUMENTATION.md +4 -0
- package/server/lib/opencode/ensure-cli.d.ts +8 -0
- package/server/lib/opencode/feature-routes-runtime.js +10 -0
- package/server/lib/opencode/feature-routes-runtime.test.js +7 -0
- package/server/lib/opencode/proxy.js +3 -1
- package/server/lib/opencode/proxy.test.js +3 -3
- package/server/lib/opencode/routes.js +30 -0
- package/server/lib/opencode/upgrade-screen.d.ts +30 -0
- package/server/lib/opencode/upgrade-screen.js +299 -0
- package/server/lib/opencode/upgrade-screen.test.js +196 -0
- package/server/lib/session-metadata/DOCUMENTATION.md +27 -17
- package/server/lib/session-metadata/opencode-session-record.d.ts +57 -0
- package/server/lib/session-metadata/opencode-session-record.js +316 -0
- package/server/lib/session-metadata/opencode-session-record.test.js +242 -0
- package/server/lib/session-metadata/routes.js +5 -1
- package/server/lib/session-metadata/session-archive.js +1 -1
- package/server/lib/session-metadata/session-metadata-store.d.ts +2 -0
- package/server/lib/session-metadata/session-metadata-store.js +63 -16
- package/server/lib/session-metadata/session-projection.js +26 -2
- package/dist/assets/Icon-AQPvxMiU.js +0 -1
- package/dist/assets/MobileSurface-xuc_z0_G.js +0 -2
- package/dist/assets/SettingsView-CJ6tcH5_.js +0 -25
- package/dist/assets/TerminalView-Dvr-ysTS.js +0 -8
- package/dist/assets/collapsible-ZmZ6rLWs.js +0 -3
- package/dist/assets/context-menu-B2LXJgXL.js +0 -1
- package/dist/assets/es-CN3E_zXj.js +0 -15
- package/dist/assets/fr-9zZvQZD2.js +0 -13
- package/dist/assets/insertionBoundaries-BiUCSkx-.js +0 -1
- package/dist/assets/ja-Dnjk_82N.js +0 -15
- package/dist/assets/ko-BxCEE99C.js +0 -15
- package/dist/assets/main-C9mIBo77.js +0 -2
- package/dist/assets/main-DiL6w6KF.js +0 -169
- package/dist/assets/main-qSeeJRW1.css +0 -1
- package/dist/assets/markdownTheme-CKac3wKC.js +0 -1
- package/dist/assets/miniChat-CwtUaElU.js +0 -2
- package/dist/assets/mobile-DB-6--ws.js +0 -2
- package/dist/assets/multirun-TAsxFI8e.js +0 -4
- package/dist/assets/persistence-56kq8Z4V.js +0 -3
- package/dist/assets/pl-CNNsWnPM.js +0 -15
- package/dist/assets/platform-C13fMVEs.js +0 -6
- package/dist/assets/pt-BR-BZB2DJMp.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-CGj0MNRU.js +0 -2
- package/dist/assets/runtimeEndpointReset-A_ZBUJFS.js +0 -147
- package/dist/assets/src-ubCWXZhR.css +0 -2
- package/dist/assets/store-DLCiZaA6.js +0 -15
- package/dist/assets/uk-rwQrxeYM.js +0 -15
- package/dist/assets/useDesktopWindowControlsLayout-BlizAlOt.js +0 -1
- package/dist/assets/useMobileNavigationStore-DfPClaW-.js +0 -414
- package/dist/assets/useSessionAutoCleanup-DtrfbxAp.js +0 -2
- package/dist/assets/useUIStore-CQYKJnrg.js +0 -1
- package/dist/assets/vendor-opencode-client-BOe2qpQb.js +0 -12
- package/dist/assets/zh-CN-BvmBDnkD.js +0 -15
- package/dist/assets/zh-TW-9wcHTX0y.js +0 -15
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-
|
|
2
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{p as t,t as n,v as r,w as i}from"./runtime-auth-D66yq6ie.js";import{c as a,f as o,i as s,l as c,s as l,t as u}from"./runtime-switch-LvWDU-SL.js";import{n as d}from"./runtime-fetch-Fs9ZV2V8.js";import{Cn as f,jt as p,n as m,t as h,tt as g,wn as _}from"./persistence-56kq8Z4V.js";import{a as v,i as y}from"./vendor-zustand-BqLKf6ZY.js";import{nt as b,rt as x,tt as S}from"./vendor-base-ui-CDjyofeD.js";import{Ar as C,Bn as w,Ct as T,Nt as E,jr as D,n as O,r as k,t as A}from"./platform-C13fMVEs.js";import{b as j,t as M}from"./useUIStore-CQYKJnrg.js";import{n as N,t as P}from"./vendor-react-C94A0AHl.js";import{a as F,n as I,o as L}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{t as R}from"./capgoAdapter-DCowZ2ab.js";/* empty css */import{a as z}from"./vendor-pierre-diffs-CUfqC003.js";import{r as B}from"./vendor-sonner-DNqHmUQs.js";import{n as V}from"./vendor-reactuses-core-C2A3EjUi.js";import{d as H,f as ee,m as U,r as W,t as G}from"./button-CcNJUxUd.js";import{i as K,n as te}from"./store-DLCiZaA6.js";import{a as q,c as ne,d as re,f as ie,l as ae,o as oe,s as se,t as J,u as ce}from"./MobileShareBridge-BOXGNHmC.js";import{b as le,g as ue,t as Y,y as de}from"./MobileDetailNavigation-BMgIu7zc.js";import{Br as fe,Ca as pe,Cn as me,Cr as he,Dr as ge,Er as _e,Ft as ve,Gt as ye,Hn as be,Ht as xe,I as Se,Ii as Ce,Li as we,Or as Te,Sa as Ee,Sr as De,Tr as Oe,Ut as ke,Xt as Ae,Zt as je,_r as Me,a as Ne,an as Pe,br as Fe,ci as Ie,cn as Le,d as Re,da as ze,dn as Be,io as Ve,kr as He,mr as Ue,o as We,pa as Ge,pr as Ke,si as qe,sn as Je,t as Ye,un as Xe,wr as Ze,xa as Qe,yr as $e,zn as et}from"./useMobileNavigationStore-DfPClaW-.js";import{i as tt,n as nt,r as rt}from"./useAssistantUIStore-asNG6K7n.js";import{n as X}from"./Icon-AQPvxMiU.js";import{F as it,I as at,M as ot,N as st,p as ct}from"./gitApi-yuWg9BN4.js";import{B as lt,C as ut,G as dt,H as ft,I as pt,Ot as mt,Pt as ht,S as gt,St as _t,V as vt,W as yt,_t as bt,bt as xt,dt as St,et as Ct,gt as wt,ht as Tt,i as Et,kt as Dt,mt as Ot,o as kt,r as At,s as jt,t as Mt,tt as Nt,ut as Pt,vt as Ft,xt as It,yt as Lt,z as Rt}from"./useAppFontEffects-CiDe42I5.js";import{O as zt,a as Bt,c as Vt,h as Ht,k as Ut,s as Wt,u as Gt}from"./collapsible-ZmZ6rLWs.js";import{t as Kt}from"./input-CrIvk3HZ.js";import{r as qt}from"./tooltip-CPI4fr1a.js";import{B as Jt,E as Yt,Q as Xt,S as Zt,X as Qt,Z as $t,b as en,g as tn,gt as nn,jt as rn,rt as an,w as on,x as sn}from"./useSessionAutoCleanup-DtrfbxAp.js";import{n as cn}from"./useThemeSystem-BlNUWH47.js";import{a as ln,n as un,s as dn}from"./OverlayScrollbar-4wp4migh.js";import{s as fn}from"./markdownTheme-CKac3wKC.js";import{n as pn}from"./useRuntimeAPIs-DwLtO0c_.js";import{C as mn,a as hn,c as gn,d as _n,f as vn,i as yn,l as bn,m as xn,p as Sn,r as Cn,s as wn,u as Tn}from"./textarea-BBOlRI9O.js";import{D as En,E as Dn,r as On,t as kn}from"./sessionChangeSummary-qOLrP9fw.js";import{b as An,g as jn,j as Mn,x as Nn,y as Pn}from"./insertionBoundaries-BiUCSkx-.js";import{D as Fn,M as In,N as Ln,a as Rn,g as zn,i as Bn,m as Vn,r as Hn,s as Un,t as Wn}from"./appThemeRegistry-DK7q2juD.js";import{i as Gn,n as Kn,o as qn}from"./MarkdownRenderer-Bv05iDZZ.js";import{a as Jn}from"./url-DRDQXjyX.js";import{c as Yn,d as Xn,f as Zn,l as Qn}from"./markdown-worker-bS5OgGO3.js";import{n as $n}from"./useEffectiveDirectory-C_CouL5v.js";import{f as er}from"./FadeInOnReveal-BZmwl-zE.js";import{C as tr,H as nr,J as rr,U as ir,Y as ar,a as or,b as sr,g as cr,i as lr,n as ur,o as dr,p as fr,r as pr,t as mr,x as hr,z as gr}from"./MobileSurface-xuc_z0_G.js";import{t as _r}from"./useFontPreferences-B0oUZAiB.js";import{A as vr,C as yr,D as br,E as xr,G as Sr,H as Cr,I as wr,J as Tr,O as Er,S as Dr,T as Or,U as kr,V as Ar,W as jr,Y as Mr,_ as Nr,a as Pr,at as Fr,b as Ir,c as Lr,d as Rr,et as zr,f as Br,g as Vr,i as Hr,it as Ur,k as Wr,l as Gr,m as Kr,n as qr,nt as Jr,p as Yr,r as Xr,s as Zr,t as Qr,tt as $r,u as ei,v as ti,w as ni,x as ri,y as ii}from"./runtimeEndpointReset-A_ZBUJFS.js";import{c as ai,l as oi}from"./mcpQueries-C7jknHV8.js";import{a as si,c as ci,i as li,l as ui,o as di,r as fi,s as pi,t as mi,u as hi}from"./SettingsView-CJ6tcH5_.js";import{a as gi,c as _i,i as vi,l as yi,o as bi,r as xi,s as Si,t as Ci}from"./AssistantView-CwXkiCAd.js";import{a as wi,i as Ti}from"./sessionLookup-34XFmP9C.js";import{a as Ei,i as Di,n as Oi,r as ki,t as Ai}from"./context-menu-B2LXJgXL.js";import{a as ji,i as Mi,o as Ni,r as Pi}from"./fileQueries-CjdBRy8y.js";var Z=e(x(),1),Fi=P(),Ii=null,Li=!1,Ri=new Promise(e=>{Ii=e});function zi(){Li||(Li=!0,Ii?.())}var Bi=6,Vi=e=>e.parentID??null,Hi=e=>{let t=e.replace(/\/+$/,``);return t.slice(t.lastIndexOf(`/`)+1)||t},Ui=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),Wi=(e,t)=>{if(!e)return``;let n=null,r=-1;for(let i of t){let t=Ui(i.path);(e===t||e.startsWith(`${t}/`))&&t.length>r&&(n=i,r=t.length)}return Hi(n?n.path:e)},Gi=()=>{let e=Fe.getState().activeSessions,t=et.getState().index.session.unseenCount,n=Ve.getState().projects,r=0,i=[];for(let a of e){let e=Vi(a)!==null,o=(t[a.id]??0)>0&&!e;o&&(r+=1),e||i.push({id:a.id,title:a.title??``,updated:a.time?.updated??a.time?.created??0,unread:o,project:Wi(Me(a),n)})}i.sort((e,t)=>t.updated-e.updated);let a=i.slice(0,Bi).map(({id:e,title:t,unread:n,project:r})=>({id:e,title:t,unread:n,project:r}));return{attentionCount:r,recentSessions:a}},Ki=`__OPENCHAMBER_WIDGET_SNAPSHOT__`,qi=()=>{typeof window>`u`||(window[Ki]=()=>{try{return JSON.stringify(Gi())}catch{return null}})},Q=N(),Ji=F(`OpenChamberExternalBrowser`),Yi={getPlatform:()=>I.getPlatform(),isPluginAvailable:e=>I.isPluginAvailable(e),openInSystemBrowser:e=>Ji.open(e),openExternal:Jn},Xi=async(e,t=Yi)=>{if(t.getPlatform()===`android`){if(!t.isPluginAvailable(`OpenChamberExternalBrowser`))return!1;try{return await t.openInSystemBrowser({url:e}),!0}catch{return!1}}return t.openExternal(e)},$=b(),Zi=`mobile-app-update-available`,Qi=`mobile-app-update-toast-dismissed-version`,$i=()=>{let e=(0,Q.c)(9),{t}=ee(),n=ir(ea),r=ir(ta),i=ir(na),a=ir(ra),o=ir(ia),s;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=new Set,e[0]=s):s=e[0];let c=Z.useRef(s),l,u;return e[1]!==n||e[2]!==a||e[3]!==o||e[4]!==r||e[5]!==t||e[6]!==i?(l=()=>{if(A()!==`android`||r!==`mobile`||!n||!i||!a||o){Ze.dismiss(Zi);return}j().getItem(Qi)!==i&&(c.current.has(i)||(c.current.add(i),Ze.info(t(`mobileUpdate.toast.available.title`),{id:Zi,description:t(`mobileUpdate.toast.available.description`,{version:i}),duration:1/0,icon:(0,$.jsx)(X,{name:`download`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.toast.actions.download`),onClick:()=>{Xi(a)}},cancel:{label:t(`mobileUpdate.toast.actions.dismiss`),onClick:()=>{j().setItem(Qi,i),Ze.dismiss(Zi)}}})))},u=[n,a,o,r,t,i],e[1]=n,e[2]=a,e[3]=o,e[4]=r,e[5]=t,e[6]=i,e[7]=l,e[8]=u):(l=e[7],u=e[8]),Z.useEffect(l,u),null};function ea(e){return e.available}function ta(e){return e.runtimeType}function na(e){return e.info?.version}function ra(e){return e.info?.downloadUrl}function ia(e){return e.info?.inAppApply===!0}var aa=e=>!(!e.enabled||e.runtimeType!==`mobile`||!e.available||!e.inAppApply||!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),oa=e=>e.enabled&&!e.alreadyChecked,sa=`mobile-ota-update-available`,ca=`mobile-ota-update-toast-dismissed-version`,la=()=>{let e=(0,Q.c)(24),{t}=ee(),[n,r]=Z.useState(!1),i=Z.useRef(!1),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,e[0]=a):a=e[0];let o=Z.useRef(a),s;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=O(),e[1]=s):s=e[1];let c=s,l=ir(ua),u=ir(da),d=ir(fa),f=ir(pa),p=ir(ma),m=ir(ha),h=ir(ga),g=ir(_a),_=ir(va),v=d?.version,y=d?.inAppApply===!0,b,x;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{oa({enabled:c,alreadyChecked:i.current})&&(i.current=!0,ir.getState().checkForUpdates().catch(ya))},x=[c],e[2]=b,e[3]=x):(b=e[2],x=e[3]),Z.useEffect(b,x);let S;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>{r(!0)},e[4]=S):S=e[4];let C=V(S),w=V(ba),T,E;if(e[5]!==l||e[6]!==w||e[7]!==y||e[8]!==C||e[9]!==u||e[10]!==t||e[11]!==v?(T=()=>{if(!aa({enabled:c,runtimeType:u,available:l,inAppApply:y,version:v??``,dismissedVersion:j().getItem(ca),seenVersions:o.current})||!v){(!l||!y||u!==`mobile`)&&Ze.dismiss(sa);return}o.current.add(v),Ze.info(t(`mobileUpdate.ota.toast.available.title`),{id:sa,description:t(`mobileUpdate.ota.toast.available.description`,{version:v}),duration:1/0,icon:(0,$.jsx)(X,{name:`refresh`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.ota.toast.actions.update`),onClick:C},cancel:{label:t(`mobileUpdate.ota.toast.actions.dismiss`),onClick:()=>{w(v)}}})},E=[l,y,c,C,w,u,t,v],e[5]=l,e[6]=w,e[7]=y,e[8]=C,e[9]=u,e[10]=t,e[11]=v,e[12]=T,e[13]=E):(T=e[12],E=e[13]),Z.useEffect(T,E),!c)return null;let D;return e[14]!==n||e[15]!==g||e[16]!==p||e[17]!==f||e[18]!==h||e[19]!==d||e[20]!==m||e[21]!==_||e[22]!==u?(D=(0,$.jsx)(nr,{open:n,onOpenChange:r,info:d,downloading:f,downloaded:p,progress:m,error:h,onDownload:g,onRestart:_,runtimeType:u}),e[14]=n,e[15]=g,e[16]=p,e[17]=f,e[18]=h,e[19]=d,e[20]=m,e[21]=_,e[22]=u,e[23]=D):D=e[23],D};function ua(e){return e.available}function da(e){return e.runtimeType}function fa(e){return e.info}function pa(e){return e.downloading}function ma(e){return e.downloaded}function ha(e){return e.progress}function ga(e){return e.error}function _a(e){return e.downloadUpdate}function va(e){return e.restartToUpdate}function ya(){}function ba(e){j().setItem(ca,e),Ze.dismiss(sa)}var xa=e=>{let t=(0,Q.c)(20),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({children:n,className:r,contentClassName:i,style:o,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===r?s=t[7]:(s=W(`oc-mobile-header relative z-30 shrink-0 border-b border-border/30 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80`,r),t[6]=r,t[7]=s);let c;t[8]===o?c=t[9]:(c={paddingTop:`var(--oc-safe-area-top, 0px)`,...o},t[8]=o,t[9]=c);let l;t[10]===i?l=t[11]:(l=W(`flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2`,i),t[10]=i,t[11]=l);let u;t[12]!==n||t[13]!==l?(u=(0,$.jsx)(`div`,{className:l,children:n}),t[12]=n,t[13]=l,t[14]=u):u=t[14];let d;return t[15]!==a||t[16]!==s||t[17]!==c||t[18]!==u?(d=(0,$.jsx)(`header`,{className:s,style:c,...a,children:u}),t[15]=a,t[16]=s,t[17]=c,t[18]=u,t[19]=d):d=t[19],d},Sa=`.oc-mobile-composer`,Ca=`[data-btw-composer]`;function wa(e,t){if(!e)return!1;let n=t;return!n||typeof n.closest!=`function`||!n.closest(Ca)}function Ta(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.closest==`function`&&!!t.closest(Sa)}function Ea(e){if(!e||typeof e!=`object`||Ta(e))return!1;let t=e,n=typeof t.tagName==`string`?t.tagName.toUpperCase():``;return n===`TEXTAREA`||n===`INPUT`||t.isContentEditable===!0}function Da(e){return Ta(e??null)}function Oa(e,t){return e?`cache`:Ta(t??null)?`open`:Ea(t??null)?`field`:`ignore`}function ka(e,t){return!(t>0)||!(e>=0)?!1:t>e+24}function Aa(e,t){return e>0?Math.max(0,Math.round(e/(Number.isFinite(t)&&t>0?t:1))):0}var ja=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Ma=e=>{let t=e.index?.trim();return!!(t&&t!==`?`)},Na=e=>{let t=e.working_dir?.trim(),n=e.index?.trim();return!!(t||n===`?`)},Pa=(e,t)=>t?`${e}\u0000staged`:e,Fa=({onClose:e,initialDiffPath:t,initialDiffStaged:n=!1,initialDiffTargetLine:r=null,hideDiffHeader:i=!1})=>{let{t:a}=ee(),{git:o}=pn(),s=ja($n()??null),c=Pn(s||null),l=Nn(s||null),u=jn(s||null),d=An(e=>e.setActiveDirectory),f=An(e=>e.ensureAll),p=An(e=>e.fetchStatus),m=An(e=>e.fetchBranches),h=An(e=>e.prefetchDiffs),g=An(e=>e.getDiff),_=An(e=>e.setDiff),[v,y]=Z.useState(()=>t?{type:`diff`,path:t,staged:n,targetLine:r}:{type:`list`}),b=Z.useRef(null);Z.useEffect(()=>{t&&y(e=>e.type===`diff`&&e.path===t&&e.staged===n&&e.targetLine===r?e:{type:`diff`,path:t,staged:n,targetLine:r})},[t,n,r]);let[x,S]=Z.useState(null),[C,w]=Z.useState(null),[T,E]=Z.useState(``),[D,O]=Z.useState(new Set),[k,A]=Z.useState(!1),[j,M]=Z.useState(!1),[N,P]=Z.useState([]),[F,I]=Z.useState([]),[L,R]=Z.useState([]),[z,B]=Z.useState(null),[H,U]=Z.useState({key:null,loading:!1,error:null,resolved:!1}),[W,G]=Z.useState(0),K=Z.useRef({key:null,generation:0}),[te,q]=Z.useState(!1),ne=Lr(c)&&!te,re=Z.useMemo(()=>{let e=c?.files??[];if(ne)return[];let t=new Map;for(let n of e)t.set(n.path,n);return Array.from(t.values()).sort((e,t)=>e.path.localeCompare(t.path))},[c?.files,ne]),ie=Z.useMemo(()=>re.filter(Ma),[re]),ae=Z.useMemo(()=>re.filter(Na),[re]),{deferredStagedCount:oe,deferredUnstagedCount:se}=Z.useMemo(()=>{if(!ne||!c)return{deferredStagedCount:0,deferredUnstagedCount:0};let e=0,t=0;for(let n of c.files??[])Ma(n)&&(e+=1),Na(n)&&(t+=1);return{deferredStagedCount:e,deferredUnstagedCount:t}},[ne,c]),J=Z.useMemo(()=>{if(L.length>0)return L;let e=c?.tracking?.includes(`/`)?c.tracking.split(`/`)[0]:null;return e||z?[{name:e||`origin`,fetchUrl:z??``,pushUrl:z??``}]:[]},[z,L,c?.tracking]),ce=Z.useMemo(()=>e=>!s||v.type!==`diff`?null:e.directories.get(s)?.diffCache.get(Pa(v.path,v.staged))??null,[s,v]),le=An(ce),ue=Z.useMemo(()=>v.type===`diff`?re.find(e=>e.path===v.path)??null:null,[re,v]),Y=v.type===`diff`&&s?`${s}\u0000${Pa(v.path,v.staged)}`:null,de=H.key===Y,fe=!!(Y&&!le&&(!de||H.loading)),pe=de?H.error:null,me=!!(ue||de&&H.resolved),he=V(async(e,t=!0)=>{try{await Promise.all([p(e,o),m(e,o)])}catch(e){t&&Ze.error(e instanceof Error?e.message:a(`gitView.toast.refreshRepositoryFailed`))}}),ge=V(async(e,t,n)=>{let r=()=>K.current.key===t&&K.current.generation===n;try{let[t,n]=await Promise.all([o.getRemotes(e).catch(()=>[]),o.getRemoteUrl?o.getRemoteUrl(e).catch(()=>null):Promise.resolve(null)]);if(!r())return;R(t),B(n)}catch{if(!r())return;R([]),B(null)}}),_e=V(e=>{if(e!==s)return{requestGeneration:null,promise:Promise.resolve()};let t=K.current.generation+1;return K.current={key:e,generation:t},{requestGeneration:t,promise:ge(e,e,t)}});Z.useEffect(()=>{s&&(d(s),f(s,o))},[s,f,o,d]),Z.useEffect(()=>{if(!s){K.current={key:null,generation:K.current.generation+1},R([]),B(null);return}let{requestGeneration:e,promise:t}=_e(s);return()=>{e!==null&&K.current.key===s&&K.current.generation===e&&(K.current={key:s,generation:e+1})}},[s,o,_e]),Z.useEffect(()=>{if(!s||re.length===0)return;let e=Array.from(new Set([...ie.map(e=>e.path),...F,...re.slice(0,20).map(e=>e.path)])).filter(Boolean);if(e.length===0)return;let t=window.setTimeout(()=>{h(s,o,e,{maxFiles:40})},120);return()=>window.clearTimeout(t)},[re,s,o,h,ie,F]),Z.useEffect(()=>{if(v.type!==`diff`){U({key:null,loading:!1,error:null,resolved:!1});return}let e=Pa(v.path,v.staged);if(!s||!Y){U({key:null,loading:!1,error:null,resolved:!1});return}if(g(s,e)){U(e=>({key:Y,loading:!1,error:null,resolved:e.key===Y&&e.resolved||!!ue}));return}let t=!1;return U({key:Y,loading:!0,error:null,resolved:!1}),o.getGitFileDiff(s,{path:v.path,staged:v.staged||void 0}).then(n=>{t||(_(s,e,{original:n.original??``,modified:n.modified??``,isBinary:n.isBinary}),U(e=>e.key===Y?{...e,loading:!1,error:null,resolved:!0}:e))}).catch(e=>{t||U(t=>t.key===Y?{...t,loading:!1,error:e instanceof Error?e.message:String(e),resolved:!1}:t)}),()=>{t=!0}},[Y,s,W,g,o,v,ue,_]);let ve=async(e,t)=>{if(!s)return;let n=s;S(e);try{let r=e=>{let t=`${e.name}/`,n=c?.tracking?.startsWith(t)?c.tracking.slice(t.length):void 0;return{remote:e.name,branch:n,rebase:!0}};if(e===`fetch`){if(!t)throw Error(a(`mobile.changes.noRemote`));await o.gitFetch(n,{remote:t.name}),Ze.success(a(`gitView.toast.fetchedFromRemote`,{name:t.name}))}else if(e===`sync`){if(!t)throw Error(a(`mobile.changes.noRemote`));await o.gitFetch(n,{remote:t.name});let e=await o.getGitStatus(n);if((e.behind??0)>0){if((e.files?.length??0)>0){Ze.error(a(`gitView.toast.commitOrStashBeforeSync`));return}await o.gitPull(n,r(t))}((await o.getGitStatus(n)).ahead??0)>0&&await o.gitPush(n),Ze.success(a(`gitView.toast.alreadyUpToDate`))}await he(n,!1),await _e(n).promise}catch(e){Ze.error(e instanceof Error?e.message:a(`gitView.toast.syncActionFailed`,{action:a(`gitView.sync.syncChanges`)}))}finally{S(null)}},ye=V(async(e,t)=>{if(!s||e.length===0)return;let n=s;try{t===`stage`?e.length>1?await st(n,e):await ot(n,e[0]):e.length>1?await at(n,e):await it(n,e[0]),await he(n,!1)}catch(e){Ze.error(e instanceof Error?e.message:a(t===`stage`?`gitView.toast.stageFileFailed`:`gitView.toast.unstageFileFailed`))}}),be=V((e,t=!1)=>{y({type:`diff`,path:e,staged:t,targetLine:null})}),xe=V(()=>v.type===`diff`&&(y({type:`list`}),!0));Bn({id:`mobile-changes-diff`,active:v.type===`diff`&&!i,layer:`overlay`,onBack:xe,surfaceRef:b});let Se=V(async e=>{if(!s)return;let t=s;O(t=>new Set(t).add(e));try{await o.revertGitFile(t,e),Ze.success(a(`gitView.toast.revertedFile`,{path:e})),await he(t,!1)}catch(e){Ze.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{O(t=>{let n=new Set(t);return n.delete(e),n})}}),Ce=V(async e=>{if(!s||e.length===0||k)return;let t=s,n=Array.from(new Set(e));A(!0),O(new Set(n));try{await Promise.all(n.map(e=>o.revertGitFile(t,e))),await he(t,!1),Ze.success(n.length===1?a(`gitView.toast.revertedFilesSingle`,{count:n.length}):a(`gitView.toast.revertedFilesPlural`,{count:n.length}))}catch(e){Ze.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{O(new Set),A(!1)}}),we=V(e=>{let t=e.map(e=>e.trim()).filter(Boolean);if(t.length===0){P([]);return}E(e=>`${e.trim()}${e.trim()?`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-CJu8DNrt.js","assets/rolldown-runtime-C0FnF6B9.js","assets/runtime-fetch-Fs9ZV2V8.js","assets/runtime-auth-D66yq6ie.js","assets/runtime-switch-LvWDU-SL.js","assets/vendor-base-ui-CnHfUmDN.js","assets/useUIStore-syVmbuDA.js","assets/vendor-zustand-B4dlGEM2.js","assets/vendor-react-DLPElpoQ.js","assets/vendor-pierre-diffs-DX7XTPG3.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/vendor-hast-util-to-html-B0p1k5Xa.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-DpDied8H.js","assets/vendor-reactuses-core-B8parU1Y.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button-CwXyux0a.js","assets/persistence-D0y7226-.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/store-DmowK-GO.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/dialog-Dp0lQv5K.js","assets/Icon-B9kZgYZn.js","assets/useThemeSystem-DMzWVJaW.js","assets/markdownTheme-DM5h1i18.js","assets/appThemeRegistry-CF4lIxNt.js","assets/platform-D_c-T5nO.js","assets/vendor-opencode-client-C12gfjag.js","assets/useMobileNavigationStore-B1axS4g-.js","assets/vendor-tanstack-react-query-D7pys_c9.js","assets/vendor-sonner-DVzioF3d.js","assets/useAssistantUIStore-Bz4tRflF.js","assets/vendor-zod-Dzk5kdUU.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/MarkdownRenderer-Ds61--LT.js","assets/markdownHeightCache-BOOrGCuG.js","assets/dualLimitLru-D8Sphgua.js","assets/markdown-worker-bS5OgGO3.js","assets/useEffectiveDirectory-DsqhqsJR.js","assets/imageSource-BMztRu0c.js","assets/relay-image-stream-DrdVj99c.js","assets/useWorkerHighlightedLines-DC_Bc-RV.js","assets/tooltip-CpMLl5_k.js","assets/vendor-tanstack-react-virtual-tlDgH6PG.js","assets/vendor-capacitor-app-PzT84wSx.js","assets/vendor-capacitor-push-notifications-DB3-G2vL.js","assets/vendor-capacitor-status-bar-DeAGEDuY.js","assets/vendor-capacitor-keyboard-BkRQ-Kv-.js","assets/gitApi-D8R7ic-T.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{p as t,t as n,v as r,w as i}from"./runtime-auth-D66yq6ie.js";import{c as a,f as o,i as s,l as c,s as l,t as u}from"./runtime-switch-LvWDU-SL.js";import{n as d}from"./runtime-fetch-Fs9ZV2V8.js";import{Cn as f,jt as p,n as m,t as h,tt as g,wn as _}from"./persistence-D0y7226-.js";import{a as v,i as y}from"./vendor-zustand-B4dlGEM2.js";import{nt as b,rt as x,tt as S}from"./vendor-base-ui-CnHfUmDN.js";import{Bn as C,Ct as w,Mr as T,Nt as E,jr as D,n as O,r as k,t as A}from"./platform-D_c-T5nO.js";import{n as j,x as M}from"./useUIStore-syVmbuDA.js";import{n as N,t as P}from"./vendor-react-DLPElpoQ.js";import{a as F,n as I,o as L}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{t as R}from"./capgoAdapter-DCowZ2ab.js";/* empty css */import{a as z}from"./vendor-pierre-diffs-DX7XTPG3.js";import{r as B}from"./vendor-sonner-DVzioF3d.js";import{n as V}from"./vendor-reactuses-core-B8parU1Y.js";import{d as H,f as ee,m as U,r as W,t as G}from"./button-CwXyux0a.js";import{i as K,n as te}from"./store-DmowK-GO.js";import{a as q,c as ne,d as re,f as ie,l as ae,o as oe,s as se,t as J,u as ce}from"./MobileShareBridge-C1Fc4ErB.js";import{b as le,g as ue,t as Y,y as de}from"./MobileDetailNavigation-DcmVOjkw.js";import{Br as fe,Ca as pe,Cn as me,Cr as he,Dr as ge,Er as _e,Ft as ve,Gt as ye,Hn as be,Ht as xe,I as Se,Ii as Ce,Li as we,Or as Te,Sa as Ee,Sr as De,Tr as Oe,Ut as ke,Xt as Ae,Zt as je,_r as Me,a as Ne,an as Pe,br as Fe,ci as Ie,cn as Le,d as Re,da as ze,dn as Be,io as Ve,kr as He,mr as Ue,o as We,pa as Ge,pr as Ke,si as qe,sn as Je,t as Ye,un as Xe,wr as Ze,xa as Qe,yr as $e,zn as et}from"./useMobileNavigationStore-B1axS4g-.js";import{i as tt,n as nt,r as rt}from"./useAssistantUIStore-Bz4tRflF.js";import{n as X}from"./Icon-B9kZgYZn.js";import{F as it,I as at,M as ot,N as st,p as ct}from"./gitApi-D8R7ic-T.js";import{Ct as lt,Et as ut,G as dt,J as ft,K as pt,Mt as mt,Nt as ht,Pt as gt,R as _t,St as vt,T as yt,Tt as bt,U as xt,W as St,Y as Ct,at as wt,bt as Tt,ht as Et,i as Dt,it as Ot,mt as kt,o as At,r as jt,s as Mt,t as Nt,vt as Pt,w as Ft,wt as It,xt as Lt,yt as Rt,zt}from"./useAppFontEffects-B1h7ab_J.js";import{E as Bt,T as Vt,a as Ht,f as Ut,i as Wt,n as Gt,s as Kt}from"./projectMeta-CSQgHequ.js";import{t as qt}from"./input-Biw8aNzR.js";import{r as Jt}from"./tooltip-CpMLl5_k.js";import{C as Yt,Ct as Xt,D as Zt,N as Qt,O as $t,Rt as en,at as tn,it as nn,j as rn,k as an,q as on,rt as sn,ut as cn}from"./useSessionAutoCleanup-B5FTG_qf.js";import{n as ln}from"./useThemeSystem-DMzWVJaW.js";import{a as un,n as dn,s as fn}from"./OverlayScrollbar-B4e0QD05.js";import{s as pn}from"./markdownTheme-DM5h1i18.js";import{n as mn}from"./useRuntimeAPIs-DSLXJybW.js";import{C as hn,a as gn,c as _n,d as vn,f as yn,i as bn,l as xn,m as Sn,p as Cn,r as wn,s as Tn,u as En}from"./textarea-QxsmcBGj.js";import{D as Dn,E as On,r as kn,t as An}from"./sessionChangeSummary-spf_atO8.js";import{A as jn,b as Mn,h as Nn,v as Pn,y as Fn}from"./insertionBoundaries-DdwCD4S2.js";import{D as In,M as Ln,N as Rn,a as zn,g as Bn,i as Vn,m as Hn,r as Un,s as Wn,t as Gn}from"./appThemeRegistry-CF4lIxNt.js";import{i as Kn,n as qn,o as Jn}from"./MarkdownRenderer-Ds61--LT.js";import{a as Yn}from"./url-CGbJbiJq.js";import{c as Xn,d as Zn,f as Qn,l as $n}from"./markdown-worker-bS5OgGO3.js";import{n as er}from"./useEffectiveDirectory-DsqhqsJR.js";import{f as tr}from"./FadeInOnReveal-w_BQ7K7K.js";import{C as nr,H as rr,J as ir,U as ar,Y as or,a as sr,b as cr,g as lr,i as ur,n as dr,o as fr,p as pr,r as mr,t as hr,x as gr,z as _r}from"./MobileSurface-BA7eS5Yd.js";import{t as vr}from"./useFontPreferences-Xw1vSkmC.js";import{A as yr,C as br,D as xr,E as Sr,G as Cr,H as wr,K as Tr,L as Er,O as Dr,S as Or,T as kr,U as Ar,W as jr,X as Mr,Y as Nr,_ as Pr,a as Fr,at as Ir,b as Lr,c as Rr,d as zr,f as Br,h as Vr,i as Hr,j as Ur,k as Wr,l as Gr,m as Kr,n as qr,nt as Jr,ot as Yr,p as Xr,r as Zr,rt as Qr,s as $r,t as ei,tt as ti,u as ni,v as ri,w as ii,x as ai,y as oi}from"./runtimeEndpointReset-5uJ4sJk0.js";import{c as si,l as ci}from"./mcpQueries-CE9tk-Jz.js";import{a as li,c as ui,i as di,l as fi,o as pi,r as mi,s as hi,t as gi,u as _i}from"./SettingsView-CjesWNLw.js";import{a as vi,c as yi,i as bi,l as xi,o as Si,r as Ci,s as wi,t as Ti}from"./AssistantView-BG8hK4y9.js";import{a as Ei,i as Di}from"./sessionLookup-BGjjwiCq.js";import{a as Oi,i as ki,n as Ai,r as ji,t as Mi}from"./context-menu-DHrRifPE.js";import{a as Ni,i as Pi,o as Fi,r as Ii}from"./fileQueries-DN6gbLhM.js";var Z=e(x(),1),Li=P(),Ri=null,zi=!1,Bi=new Promise(e=>{Ri=e});function Vi(){zi||(zi=!0,Ri?.())}var Hi=6,Ui=e=>e.parentID??null,Wi=e=>{let t=e.replace(/\/+$/,``);return t.slice(t.lastIndexOf(`/`)+1)||t},Gi=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),Ki=(e,t)=>{if(!e)return``;let n=null,r=-1;for(let i of t){let t=Gi(i.path);(e===t||e.startsWith(`${t}/`))&&t.length>r&&(n=i,r=t.length)}return Wi(n?n.path:e)},qi=()=>{let e=Fe.getState().activeSessions,t=et.getState().index.session.unseenCount,n=Ve.getState().projects,r=0,i=[];for(let a of e){let e=Ui(a)!==null,o=(t[a.id]??0)>0&&!e;o&&(r+=1),e||i.push({id:a.id,title:a.title??``,updated:a.time?.updated??a.time?.created??0,unread:o,project:Ki(Me(a),n)})}i.sort((e,t)=>t.updated-e.updated);let a=i.slice(0,Hi).map(({id:e,title:t,unread:n,project:r})=>({id:e,title:t,unread:n,project:r}));return{attentionCount:r,recentSessions:a}},Ji=`__OPENCHAMBER_WIDGET_SNAPSHOT__`,Yi=()=>{typeof window>`u`||(window[Ji]=()=>{try{return JSON.stringify(qi())}catch{return null}})},Q=N(),Xi=F(`OpenChamberExternalBrowser`),Zi={getPlatform:()=>I.getPlatform(),isPluginAvailable:e=>I.isPluginAvailable(e),openInSystemBrowser:e=>Xi.open(e),openExternal:Yn},Qi=async(e,t=Zi)=>{if(t.getPlatform()===`android`){if(!t.isPluginAvailable(`OpenChamberExternalBrowser`))return!1;try{return await t.openInSystemBrowser({url:e}),!0}catch{return!1}}return t.openExternal(e)},$=b(),$i=`mobile-app-update-available`,ea=`mobile-app-update-toast-dismissed-version`,ta=()=>{let e=(0,Q.c)(9),{t}=ee(),n=ar(na),r=ar(ra),i=ar(ia),a=ar(aa),o=ar(oa),s;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=new Set,e[0]=s):s=e[0];let c=Z.useRef(s),l,u;return e[1]!==n||e[2]!==a||e[3]!==o||e[4]!==r||e[5]!==t||e[6]!==i?(l=()=>{if(A()!==`android`||r!==`mobile`||!n||!i||!a||o){Ze.dismiss($i);return}M().getItem(ea)!==i&&(c.current.has(i)||(c.current.add(i),Ze.info(t(`mobileUpdate.toast.available.title`),{id:$i,description:t(`mobileUpdate.toast.available.description`,{version:i}),duration:1/0,icon:(0,$.jsx)(X,{name:`download`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.toast.actions.download`),onClick:()=>{Qi(a)}},cancel:{label:t(`mobileUpdate.toast.actions.dismiss`),onClick:()=>{M().setItem(ea,i),Ze.dismiss($i)}}})))},u=[n,a,o,r,t,i],e[1]=n,e[2]=a,e[3]=o,e[4]=r,e[5]=t,e[6]=i,e[7]=l,e[8]=u):(l=e[7],u=e[8]),Z.useEffect(l,u),null};function na(e){return e.available}function ra(e){return e.runtimeType}function ia(e){return e.info?.version}function aa(e){return e.info?.downloadUrl}function oa(e){return e.info?.inAppApply===!0}var sa=e=>!(!e.enabled||e.runtimeType!==`mobile`||!e.available||!e.inAppApply||!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),ca=e=>e.enabled&&!e.alreadyChecked,la=`mobile-ota-update-available`,ua=`mobile-ota-update-toast-dismissed-version`,da=()=>{let e=(0,Q.c)(24),{t}=ee(),[n,r]=Z.useState(!1),i=Z.useRef(!1),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,e[0]=a):a=e[0];let o=Z.useRef(a),s;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=O(),e[1]=s):s=e[1];let c=s,l=ar(fa),u=ar(pa),d=ar(ma),f=ar(ha),p=ar(ga),m=ar(_a),h=ar(va),g=ar(ya),_=ar(ba),v=d?.version,y=d?.inAppApply===!0,b,x;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{ca({enabled:c,alreadyChecked:i.current})&&(i.current=!0,ar.getState().checkForUpdates().catch(xa))},x=[c],e[2]=b,e[3]=x):(b=e[2],x=e[3]),Z.useEffect(b,x);let S;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>{r(!0)},e[4]=S):S=e[4];let C=V(S),w=V(Sa),T,E;if(e[5]!==l||e[6]!==w||e[7]!==y||e[8]!==C||e[9]!==u||e[10]!==t||e[11]!==v?(T=()=>{if(!sa({enabled:c,runtimeType:u,available:l,inAppApply:y,version:v??``,dismissedVersion:M().getItem(ua),seenVersions:o.current})||!v){(!l||!y||u!==`mobile`)&&Ze.dismiss(la);return}o.current.add(v),Ze.info(t(`mobileUpdate.ota.toast.available.title`),{id:la,description:t(`mobileUpdate.ota.toast.available.description`,{version:v}),duration:1/0,icon:(0,$.jsx)(X,{name:`refresh`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.ota.toast.actions.update`),onClick:C},cancel:{label:t(`mobileUpdate.ota.toast.actions.dismiss`),onClick:()=>{w(v)}}})},E=[l,y,c,C,w,u,t,v],e[5]=l,e[6]=w,e[7]=y,e[8]=C,e[9]=u,e[10]=t,e[11]=v,e[12]=T,e[13]=E):(T=e[12],E=e[13]),Z.useEffect(T,E),!c)return null;let D;return e[14]!==n||e[15]!==g||e[16]!==p||e[17]!==f||e[18]!==h||e[19]!==d||e[20]!==m||e[21]!==_||e[22]!==u?(D=(0,$.jsx)(rr,{open:n,onOpenChange:r,info:d,downloading:f,downloaded:p,progress:m,error:h,onDownload:g,onRestart:_,runtimeType:u}),e[14]=n,e[15]=g,e[16]=p,e[17]=f,e[18]=h,e[19]=d,e[20]=m,e[21]=_,e[22]=u,e[23]=D):D=e[23],D};function fa(e){return e.available}function pa(e){return e.runtimeType}function ma(e){return e.info}function ha(e){return e.downloading}function ga(e){return e.downloaded}function _a(e){return e.progress}function va(e){return e.error}function ya(e){return e.downloadUpdate}function ba(e){return e.restartToUpdate}function xa(){}function Sa(e){M().setItem(ua,e),Ze.dismiss(la)}var Ca=e=>{let t=(0,Q.c)(20),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({children:n,className:r,contentClassName:i,style:o,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===r?s=t[7]:(s=W(`oc-mobile-header relative z-30 shrink-0 border-b border-border/30 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80`,r),t[6]=r,t[7]=s);let c;t[8]===o?c=t[9]:(c={paddingTop:`var(--oc-safe-area-top, 0px)`,...o},t[8]=o,t[9]=c);let l;t[10]===i?l=t[11]:(l=W(`flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2`,i),t[10]=i,t[11]=l);let u;t[12]!==n||t[13]!==l?(u=(0,$.jsx)(`div`,{className:l,children:n}),t[12]=n,t[13]=l,t[14]=u):u=t[14];let d;return t[15]!==a||t[16]!==s||t[17]!==c||t[18]!==u?(d=(0,$.jsx)(`header`,{className:s,style:c,...a,children:u}),t[15]=a,t[16]=s,t[17]=c,t[18]=u,t[19]=d):d=t[19],d},wa=`.oc-mobile-composer`,Ta=`[data-btw-composer]`;function Ea(e,t){if(!e)return!1;let n=t;return!n||typeof n.closest!=`function`||!n.closest(Ta)}function Da(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.closest==`function`&&!!t.closest(wa)}function Oa(e){if(!e||typeof e!=`object`||Da(e))return!1;let t=e,n=typeof t.tagName==`string`?t.tagName.toUpperCase():``;return n===`TEXTAREA`||n===`INPUT`||t.isContentEditable===!0}function ka(e){return Da(e??null)}function Aa(e,t){return e?`cache`:Da(t??null)?`open`:Oa(t??null)?`field`:`ignore`}function ja(e,t){return!(t>0)||!(e>=0)?!1:t>e+24}function Ma(e,t){return e>0?Math.max(0,Math.round(e/(Number.isFinite(t)&&t>0?t:1))):0}var Na=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Pa=e=>{let t=e.index?.trim();return!!(t&&t!==`?`)},Fa=e=>{let t=e.working_dir?.trim(),n=e.index?.trim();return!!(t||n===`?`)},Ia=(e,t)=>t?`${e}\u0000staged`:e,La=({onClose:e,initialDiffPath:t,initialDiffStaged:n=!1,initialDiffTargetLine:r=null,hideDiffHeader:i=!1})=>{let{t:a}=ee(),{git:o}=mn(),s=Na(er()??null),c=Pn(s||null),l=Mn(s||null),u=Nn(s||null),d=Fn(e=>e.setActiveDirectory),f=Fn(e=>e.ensureAll),p=Fn(e=>e.fetchStatus),m=Fn(e=>e.fetchBranches),h=Fn(e=>e.prefetchDiffs),g=Fn(e=>e.getDiff),_=Fn(e=>e.setDiff),[v,y]=Z.useState(()=>t?{type:`diff`,path:t,staged:n,targetLine:r}:{type:`list`}),b=Z.useRef(null);Z.useEffect(()=>{t&&y(e=>e.type===`diff`&&e.path===t&&e.staged===n&&e.targetLine===r?e:{type:`diff`,path:t,staged:n,targetLine:r})},[t,n,r]);let[x,S]=Z.useState(null),[C,w]=Z.useState(null),[T,E]=Z.useState(``),[D,O]=Z.useState(new Set),[k,A]=Z.useState(!1),[j,M]=Z.useState(!1),[N,P]=Z.useState([]),[F,I]=Z.useState([]),[L,R]=Z.useState([]),[z,B]=Z.useState(null),[H,U]=Z.useState({key:null,loading:!1,error:null,resolved:!1}),[W,G]=Z.useState(0),K=Z.useRef({key:null,generation:0}),[te,q]=Z.useState(!1),ne=Gr(c)&&!te,re=Z.useMemo(()=>{let e=c?.files??[];if(ne)return[];let t=new Map;for(let n of e)t.set(n.path,n);return Array.from(t.values()).sort((e,t)=>e.path.localeCompare(t.path))},[c?.files,ne]),ie=Z.useMemo(()=>re.filter(Pa),[re]),ae=Z.useMemo(()=>re.filter(Fa),[re]),{deferredStagedCount:oe,deferredUnstagedCount:se}=Z.useMemo(()=>{if(!ne||!c)return{deferredStagedCount:0,deferredUnstagedCount:0};let e=0,t=0;for(let n of c.files??[])Pa(n)&&(e+=1),Fa(n)&&(t+=1);return{deferredStagedCount:e,deferredUnstagedCount:t}},[ne,c]),J=Z.useMemo(()=>{if(L.length>0)return L;let e=c?.tracking?.includes(`/`)?c.tracking.split(`/`)[0]:null;return e||z?[{name:e||`origin`,fetchUrl:z??``,pushUrl:z??``}]:[]},[z,L,c?.tracking]),ce=Z.useMemo(()=>e=>!s||v.type!==`diff`?null:e.directories.get(s)?.diffCache.get(Ia(v.path,v.staged))??null,[s,v]),le=Fn(ce),ue=Z.useMemo(()=>v.type===`diff`?re.find(e=>e.path===v.path)??null:null,[re,v]),Y=v.type===`diff`&&s?`${s}\u0000${Ia(v.path,v.staged)}`:null,de=H.key===Y,fe=!!(Y&&!le&&(!de||H.loading)),pe=de?H.error:null,me=!!(ue||de&&H.resolved),he=V(async(e,t=!0)=>{try{await Promise.all([p(e,o),m(e,o)])}catch(e){t&&Ze.error(e instanceof Error?e.message:a(`gitView.toast.refreshRepositoryFailed`))}}),ge=V(async(e,t,n)=>{let r=()=>K.current.key===t&&K.current.generation===n;try{let[t,n]=await Promise.all([o.getRemotes(e).catch(()=>[]),o.getRemoteUrl?o.getRemoteUrl(e).catch(()=>null):Promise.resolve(null)]);if(!r())return;R(t),B(n)}catch{if(!r())return;R([]),B(null)}}),_e=V(e=>{if(e!==s)return{requestGeneration:null,promise:Promise.resolve()};let t=K.current.generation+1;return K.current={key:e,generation:t},{requestGeneration:t,promise:ge(e,e,t)}});Z.useEffect(()=>{s&&(d(s),f(s,o))},[s,f,o,d]),Z.useEffect(()=>{if(!s){K.current={key:null,generation:K.current.generation+1},R([]),B(null);return}let{requestGeneration:e,promise:t}=_e(s);return()=>{e!==null&&K.current.key===s&&K.current.generation===e&&(K.current={key:s,generation:e+1})}},[s,o,_e]),Z.useEffect(()=>{if(!s||re.length===0)return;let e=Array.from(new Set([...ie.map(e=>e.path),...F,...re.slice(0,20).map(e=>e.path)])).filter(Boolean);if(e.length===0)return;let t=window.setTimeout(()=>{h(s,o,e,{maxFiles:40})},120);return()=>window.clearTimeout(t)},[re,s,o,h,ie,F]),Z.useEffect(()=>{if(v.type!==`diff`){U({key:null,loading:!1,error:null,resolved:!1});return}let e=Ia(v.path,v.staged);if(!s||!Y){U({key:null,loading:!1,error:null,resolved:!1});return}if(g(s,e)){U(e=>({key:Y,loading:!1,error:null,resolved:e.key===Y&&e.resolved||!!ue}));return}let t=!1;return U({key:Y,loading:!0,error:null,resolved:!1}),o.getGitFileDiff(s,{path:v.path,staged:v.staged||void 0}).then(n=>{t||(_(s,e,{original:n.original??``,modified:n.modified??``,isBinary:n.isBinary}),U(e=>e.key===Y?{...e,loading:!1,error:null,resolved:!0}:e))}).catch(e=>{t||U(t=>t.key===Y?{...t,loading:!1,error:e instanceof Error?e.message:String(e),resolved:!1}:t)}),()=>{t=!0}},[Y,s,W,g,o,v,ue,_]);let ve=async(e,t)=>{if(!s)return;let n=s;S(e);try{let r=e=>{let t=`${e.name}/`,n=c?.tracking?.startsWith(t)?c.tracking.slice(t.length):void 0;return{remote:e.name,branch:n,rebase:!0}};if(e===`fetch`){if(!t)throw Error(a(`mobile.changes.noRemote`));await o.gitFetch(n,{remote:t.name}),Ze.success(a(`gitView.toast.fetchedFromRemote`,{name:t.name}))}else if(e===`sync`){if(!t)throw Error(a(`mobile.changes.noRemote`));await o.gitFetch(n,{remote:t.name});let e=await o.getGitStatus(n);if((e.behind??0)>0){if((e.files?.length??0)>0){Ze.error(a(`gitView.toast.commitOrStashBeforeSync`));return}await o.gitPull(n,r(t))}((await o.getGitStatus(n)).ahead??0)>0&&await o.gitPush(n),Ze.success(a(`gitView.toast.alreadyUpToDate`))}await he(n,!1),await _e(n).promise}catch(e){Ze.error(e instanceof Error?e.message:a(`gitView.toast.syncActionFailed`,{action:a(`gitView.sync.syncChanges`)}))}finally{S(null)}},ye=V(async(e,t)=>{if(!s||e.length===0)return;let n=s;try{t===`stage`?e.length>1?await st(n,e):await ot(n,e[0]):e.length>1?await at(n,e):await it(n,e[0]),await he(n,!1)}catch(e){Ze.error(e instanceof Error?e.message:a(t===`stage`?`gitView.toast.stageFileFailed`:`gitView.toast.unstageFileFailed`))}}),be=V((e,t=!1)=>{y({type:`diff`,path:e,staged:t,targetLine:null})}),xe=V(()=>v.type===`diff`&&(y({type:`list`}),!0));Vn({id:`mobile-changes-diff`,active:v.type===`diff`&&!i,layer:`overlay`,onBack:xe,surfaceRef:b});let Se=V(async e=>{if(!s)return;let t=s;O(t=>new Set(t).add(e));try{await o.revertGitFile(t,e),Ze.success(a(`gitView.toast.revertedFile`,{path:e})),await he(t,!1)}catch(e){Ze.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{O(t=>{let n=new Set(t);return n.delete(e),n})}}),Ce=V(async e=>{if(!s||e.length===0||k)return;let t=s,n=Array.from(new Set(e));A(!0),O(new Set(n));try{await Promise.all(n.map(e=>o.revertGitFile(t,e))),await he(t,!1),Ze.success(n.length===1?a(`gitView.toast.revertedFilesSingle`,{count:n.length}):a(`gitView.toast.revertedFilesPlural`,{count:n.length}))}catch(e){Ze.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{O(new Set),A(!1)}}),we=V(e=>{let t=e.map(e=>e.trim()).filter(Boolean);if(t.length===0){P([]);return}E(e=>`${e.trim()}${e.trim()?`
|
|
3
3
|
|
|
4
4
|
`:``}${t.join(`
|
|
5
|
-
`)}`.trim()),P([])}),Te=V(async()=>{if(!s)return;let e=s,t=ie.map(e=>e.path).sort();if(t.length===0){Ze.error(a(`gitView.toast.selectFileToDescribe`));return}M(!0);try{let{message:n}=await ct(e,t);E(n.subject?.trim()??``),P(Array.isArray(n.highlights)?n.highlights:[])}catch(e){Ze.error(e instanceof Error?e.message:a(`gitView.toast.generateCommitMessageFailed`))}finally{M(!1)}}),Ee=async(e={})=>{if(!s)return;let t=s;if(!T.trim()){Ze.error(a(`gitView.toast.enterCommitMessage`));return}let n=ie.map(e=>e.path).sort();if(n.length===0){Ze.error(a(`gitView.toast.selectFileToCommit`));return}w(e.pushAfter?`commitAndPush`:`commit`);try{if(await o.createGitCommit(t,T.trim(),{files:n}),Ze.success(a(`gitView.toast.commitCreated`)),E(``),P([]),e.pushAfter){let e=c?.tracking?.split(`/`)[0],n=J.find(t=>t.name===e)??J[0];if(!n)throw Error(a(`mobile.changes.noRemote`));S(`sync`);let r=`${n.name}/`,i=c?.tracking?.startsWith(r)?c.tracking.slice(r.length):void 0;await o.gitFetch(t,{remote:n.name}),((await o.getGitStatus(t)).behind??0)>0&&await o.gitPull(t,{remote:n.name,branch:i,rebase:!0}),((await o.getGitStatus(t)).ahead??0)>0&&await o.gitPush(t),await he(t,!1),await _e(t).promise}else await he(t,!1)}catch(e){Ze.error(e instanceof Error?e.message:a(`gitView.toast.createCommitFailed`))}finally{w(null),e.pushAfter&&S(null)}},De=Z.useMemo(()=>{let e=[];return ie.length>0&&e.push({id:`staged`,title:a(`gitView.changes.stagedTitle`),entries:ie,actionSymbol:`-`,actionAllLabel:a(`gitView.changes.unstageAllAria`),getActionLabel:e=>a(`gitView.changes.unstageFileAria`,{path:e}),onActionFile:e=>void ye([e],`unstage`),onActionAll:e=>void ye(e,`unstage`),onViewDiff:e=>be(e,!0),onRevertFile:Se,showRevertActions:!1,accent:!0}),ae.length>0&&e.push({id:`unstaged`,title:a(`gitView.changes.title`),entries:ae,actionSymbol:`+`,actionAllLabel:a(`gitView.changes.stageAllAria`),getActionLabel:e=>a(`gitView.changes.stageFileAria`,{path:e}),onActionFile:e=>void ye([e],`stage`),onActionAll:e=>void ye(e,`stage`),onViewDiff:e=>be(e,!1),onRevertFile:Se}),e},[Se,be,ye,ie,a,ae]),Oe=t=>(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[i?null:(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,children:[e?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":a(`mobile.surface.closeAria`),onClick:e,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label text-foreground`,children:a(`mobile.nav.changes`)}),(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:c?.current||s||``})]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:t})]});return s?u&&l===null?Oe((0,$.jsx)(Ia,{loading:!0,message:a(`gitView.loading.checkingRepository`)})):l===!1?Oe((0,$.jsx)(Ia,{icon:!0,message:a(`gitView.empty.notGitRepository`),description:a(`gitView.empty.notGitRepositoryDescription`)})):v.type===`diff`?(0,$.jsx)(`div`,{ref:b,className:`h-full min-h-0`,children:(0,$.jsx)(La,{path:v.path,diff:le,fileExists:me,error:pe,loading:fe,targetLine:v.targetLine,onBack:xe,onRetry:()=>G(e=>e+1),hideHeader:i})}):(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,children:[e?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":a(`mobile.surface.closeAria`),onClick:e,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label text-foreground`,children:a(`mobile.nav.changes`)}),(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:c?.current||s})]}),(0,$.jsx)(Kr,{syncAction:x,remotes:J,onSync:e=>void ve(`sync`,e),disabled:C!==null||u,aheadCount:c?.ahead??0,behindCount:c?.behind??0,trackingRemoteName:c?.tracking?.split(`/`)[0],hasUncommittedChanges:(c?.files?.length??0)>0})]}),ne?(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Gr,{stagedCount:oe,unstagedCount:se,onLoad:()=>q(!0)})}):re.length>0?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden px-4 pt-4`,children:(0,$.jsx)(ei,{groups:De,diffStats:c?.diffStats,revertingPaths:D,onRevertAll:Ce,isRevertingAll:k,headerBackgroundClassName:`bg-transparent`,onVisiblePathsChange:I})}),(0,$.jsx)(`div`,{className:`shrink-0 border-t border-border/50 px-4 pb-4 pt-3`,children:(0,$.jsx)(Zr,{stagedCount:ie.length,commitMessage:T,onCommitMessageChange:E,generatedHighlights:N,onInsertHighlights:we,onGenerateMessage:Te,isGeneratingMessage:j,onCommit:()=>void Ee({pushAfter:!1}),onCommitAndPush:()=>void Ee({pushAfter:!0}),commitAction:C,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Ia,{icon:!0,message:a(`gitView.empty.cleanTitle`),description:a(`mobile.changes.cleanDescription`)})})]}):Oe((0,$.jsx)(Ia,{message:a(`gitView.empty.selectSessionOrDirectory`)}))},Ia=e=>{let t=(0,Q.c)(13),{message:n,description:r,loading:i,icon:a}=e,o=i!==void 0&&i,s=a!==void 0&&a,c;t[0]===o?c=t[1]:(c=o?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):null,t[0]=o,t[1]=c);let l;t[2]===s?l=t[3]:(l=s?(0,$.jsx)(X,{name:`git-branch`,className:`size-6 text-muted-foreground`}):null,t[2]=s,t[3]=l);let u;t[4]===n?u=t[5]:(u=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[4]=n,t[5]=u);let d;t[6]===r?d=t[7]:(d=r?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r}):null,t[6]=r,t[7]=d);let f;return t[8]!==c||t[9]!==l||t[10]!==u||t[11]!==d?(f=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[c,l,u,d]})}),t[8]=c,t[9]=l,t[10]=u,t[11]=d,t[12]=f):f=t[12],f},La=e=>{let t=(0,Q.c)(20),{path:n,diff:r,fileExists:i,error:a,loading:o,targetLine:s,onBack:c,onRetry:l,hideHeader:u}=e,d=u!==void 0&&u,{t:f}=ee(),p;t[0]===n?p=t[1]:(p=Qn(n)||`text`,t[0]=n,t[1]=p);let m=p,h;t[2]!==d||t[3]!==c||t[4]!==n||t[5]!==f?(h=d?null:(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/50 px-3 text-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":f(`header.actions.backAria`),onClick:c,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-2`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-header text-foreground`,children:n})})]}),t[2]=d,t[3]=c,t[4]=n,t[5]=f,t[6]=h):h=t[6];let g;t[7]!==r||t[8]!==a||t[9]!==i||t[10]!==m||t[11]!==o||t[12]!==l||t[13]!==n||t[14]!==f||t[15]!==s?(g=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:a?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:f(`mobile.changes.diffDetail.loadFailed`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:a}),(0,$.jsx)(G,{type:`button`,size:`sm`,variant:`outline`,onClick:l,children:f(`diffView.actions.retry`)})]})}):o?(0,$.jsx)(Ia,{loading:!0,message:f(`diffView.state.loadingDiff`)}):i?r?r.isBinary?(0,$.jsx)(Ia,{icon:!0,message:f(`diffView.binary.unavailable`)}):Zn(n)?(0,$.jsx)(Ia,{icon:!0,message:f(`mobile.changes.diffDetail.imageUnavailable`)}):(0,$.jsx)(Cn,{className:`h-full overflow-y-auto overflow-x-hidden p-3 pwa-overlay-scroll`,"data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:(0,$.jsx)(Mr,{original:r.original,modified:r.modified,language:m,fileName:n,renderSideBySide:!1,wrapLines:!0,focusLine:s,layout:`inline`})}):(0,$.jsx)(Ia,{loading:!0,message:f(`diffView.state.loadingDiff`)}):(0,$.jsx)(Ia,{icon:!0,message:f(`mobile.changes.diffDetail.missingTitle`),description:f(`mobile.changes.diffDetail.missingDescription`)})}),t[7]=r,t[8]=a,t[9]=i,t[10]=m,t[11]=o,t[12]=l,t[13]=n,t[14]=f,t[15]=s,t[16]=g):g=t[16];let _;return t[17]!==h||t[18]!==g?(_=(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[h,g]}),t[17]=h,t[18]=g,t[19]=_):_=t[19],_},Ra=e(S(),1),za=`data-oc-motion-id`,Ba=`data-oc-sheet-overscroll`,Va=`html, body { overscroll-behavior-y: none; }`,Ha=[`input`,`textarea`,`select`,`[contenteditable]:not([contenteditable="false"])`,`[data-mobile-sheet-no-dismiss]`].join(`, `),Ua=e=>e.closest(`[data-oc-motion-id]`)?.getAttribute(`data-oc-motion-id`)??null,Wa=e=>{try{let t=e.contentDocument;return t?t.scrollingElement??t.documentElement:null}catch{return null}},Ga=(e,t)=>Number.isFinite(e)&&Number.isFinite(t)&&e<=1&&t>0,Ka=(e,t,n)=>e?!0:Ga(t,n),qa=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.Element},Ja=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.HTMLElement},Ya=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.HTMLStyleElement},Xa=(e,t)=>{if(typeof e.item==`function`){let n=e.item(t);if(n)return n}return e[t]??null},Za=(e,t)=>{for(let n=0;n<e.length;n+=1){let r=Xa(e,n);if(r?.identifier===t)return r}return null},Qa=(e,t)=>{try{let n=e.defaultView?.getComputedStyle(t);if(!n)return!1;let r=n.overflowY;return(r===`auto`||r===`scroll`||r===`overlay`)&&t.scrollHeight>t.clientHeight+1}catch{return!1}},$a=(e,t)=>{let n=[],r=new Set,i=t=>{!t||r.has(t)||Qa(e,t)&&(r.add(t),n.push(t))},a=qa(e,t)?t:null;for(;a&&(Ja(e,a)&&i(a),a!==e.documentElement&&a!==e.body);)a=a.parentElement;let o=e.scrollingElement??e.documentElement;return Ja(e,o)&&i(o),n},eo=(e,t)=>{let n=$a(e,t);if(n.length===0){let t=(e.scrollingElement??e.documentElement)?.scrollTop??1/0;return Number.isFinite(t)&&t<=1}return n.every(e=>e.scrollTop<=1)},to=e=>{let t=e.closest(`[${za}]`);if(t instanceof HTMLElement){let e=t.getBoundingClientRect().height;if(Number.isFinite(e)&&e>0)return e}return window.innerHeight||1},no=e=>{let t=null,n=()=>{t?.(),t=null;let n=(()=>{try{return e.contentDocument}catch{return null}})();if(!n)return;let r=Ua(e);if(!r)return;let i=null;if(!Ya(n,n.querySelector(`style[${Ba}]`))){let e=n.createElement(`style`);e.setAttribute(Ba,`true`),e.textContent=Va,(n.head??n.documentElement).appendChild(e),i=e}let a=null,o=()=>{a?.active&&a.controller.finish(`cancel`),a=null},s=t=>{if(o(),t.touches.length!==1||(qa(n,t.target)?t.target:null)?.closest(Ha)||!eo(n,t.target))return;let r=Xa(t.touches,0);if(!r)return;let i=to(e);a={touchId:r.identifier,startX:r.screenX,startY:r.screenY,lastY:r.screenY,lastTime:t.timeStamp,lastVelocityTime:t.timeStamp,velocity:0,motionDistance:i,commitDistance:wn(i,.1,40,64),active:!1,controller:null}},c=t=>{if(!a)return;if(t.touches.length!==1){o();return}let i=Za(t.touches,a.touchId);if(!i){o();return}let s=i.screenY-a.startY,c=i.screenX-a.startX,l=t.timeStamp-a.lastTime;if(a.velocity=Tn(a.velocity,i.screenY-a.lastY,l,t.timeStamp-a.lastVelocityTime,1),i.screenY!==a.lastY&&l>0&&(a.lastVelocityTime=t.timeStamp),a.lastY=i.screenY,a.lastTime=t.timeStamp,!a.active){if(!eo(n,t.target)){a=null;return}if(!Ka(!1,Wa(e)?.scrollTop??0,s)){a=null;return}if(!_n(`bottom`,c,s,8,1))return;let i=xn(r);if(!i?.begin(`dismiss`)){a=null;return}a={...a,active:!0,controller:i}}let u=a;if(!u.active)return;t.preventDefault();let d=gn(`bottom`,c,s);u.controller.update(bn(d,u.motionDistance))},l=e=>{if(!a)return;let t=a,n=Za(e.changedTouches,t.touchId);if(a=null,!t.active)return;if(!n){t.controller.finish(`cancel`);return}let r=e.timeStamp-t.lastTime;t.velocity=Tn(t.velocity,n.screenY-t.lastY,r,e.timeStamp-t.lastVelocityTime,1),n.screenY!==t.lastY&&r>0&&(t.lastVelocityTime=e.timeStamp),t.lastY=n.screenY,t.lastTime=e.timeStamp;let i=n.screenY-t.startY,o=n.screenX-t.startX,s=gn(`bottom`,o,i),c=vn(s,t.velocity,t.commitDistance,.65,12);t.controller.finish(c?`commit`:`cancel`),e.preventDefault()},u=()=>o();n.addEventListener(`touchstart`,s,{capture:!0,passive:!0}),n.addEventListener(`touchmove`,c,{capture:!0,passive:!1}),n.addEventListener(`touchend`,l,{capture:!0,passive:!1}),n.addEventListener(`touchcancel`,u,{capture:!0,passive:!0}),t=()=>{o(),n.removeEventListener(`touchstart`,s,!0),n.removeEventListener(`touchmove`,c,!0),n.removeEventListener(`touchend`,l,!0),n.removeEventListener(`touchcancel`,u,!0);try{i?.remove()}catch{}i=null}};return e.addEventListener(`load`,n),n(),()=>{e.removeEventListener(`load`,n),t?.()}},ro=qn(()=>L(()=>import(`./ToolOutputDialog-uH1ZZDSS.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52]))),io=25e4,ao=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),oo=e=>{let t=ao(e);return!t||t===`/`?t||`/`:t.split(`/`).filter(Boolean).at(-1)??t},so=e=>{let t=ao(e);if(!t||t===`/`)return null;let n=t.lastIndexOf(`/`);return n<=0?t.startsWith(`/`)?`/`:null:t.slice(0,n)},co=(e,t)=>{let n=ao(e),r=ao(t);return!r||n===r?oo(n):n.startsWith(`${r}/`)?n.slice(r.length+1):n},lo=e=>{if(typeof e!=`number`||!Number.isFinite(e)||e<0)return``;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`],n=e/1024;for(let e of t){if(n<1024||e===t[t.length-1])return`${n.toFixed(n>=10?0:1)} ${e}`;n/=1024}return``},uo=e=>e.toLowerCase().endsWith(`.svg`)?``:o().authenticatedAsset(`/api/fs/raw`,{path:e}),fo=e=>/\.(md|mdx|markdown)$/i.test(e),po=e=>{let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return`/api/fs/serve${t.startsWith(`/`)?t:`/${t}`}`},mo=e=>o().authenticatedAsset(po(e)),ho=e=>{let t=(0,Q.c)(148),{onClose:n,initialFilePath:r,directFilePreview:i,hideFileHeader:a}=e,o=r===void 0?null:r,s=i!==void 0&&i,c=a!==void 0&&a,{t:l}=ee(),{files:u}=pn(),d=$n()??null,f;t[0]===d?f=t[1]:(f=ao(d),t[0]=d,t[1]=f);let p=f,m;t[2]!==o||t[3]!==p?(m=()=>{let e=ao(o);return e?{type:`file`,path:e,returnDirectory:so(e)??p}:{type:`browser`,directory:p}},t[2]=o,t[3]=p,t[4]=m):m=t[4];let[h,g]=Z.useState(m),_=Z.useRef(null),[v,y]=Z.useState(``),b=M(Co),x=M(wo),S,C;t[5]===p?(S=t[6],C=t[7]):(S=()=>{p&&g(e=>e.type===`file`?e.returnDirectory?e:{...e,returnDirectory:so(e.path)??p}:e.type===`browser`&&e.directory?e:{type:`browser`,directory:p})},C=[p],t[5]=p,t[6]=S,t[7]=C),Z.useEffect(S,C);let w,T;t[8]!==b||t[9]!==p||t[10]!==x?(T=()=>{if(!b||!p)return;let e=ao(b);if(!e){x(null);return}y(``),g({type:`file`,path:e,returnDirectory:so(e)??p}),x(null)},w=[b,p,x],t[8]=b,t[9]=p,t[10]=x,t[11]=w,t[12]=T):(w=t[11],T=t[12]),Z.useEffect(T,w);let E=h.type===`browser`?h.directory:h.returnDirectory,D=h.type===`browser`?h.directory:``,O=h.type===`file`?h.path:``,[k,A]=Z.useState(`preview`),j;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>{A(`preview`)},t[13]=j):j=t[13];let N;t[14]===O?N=t[15]:(N=[O],t[14]=O,t[15]=N),Z.useEffect(j,N);let P=Mn(v,250),F;t[16]===v?F=t[17]:(F=v.trim(),t[16]=v,t[17]=F);let I=F,L;t[18]===P?L=t[19]:(L=P.trim(),t[18]=P,t[19]=L);let R=L,z;t[20]!==D||t[21]!==p?(z={scopeDirectory:p,directory:D},t[20]=D,t[21]=p,t[22]=z):z=t[22];let B=!!D,U;t[23]===B?U=t[24]:(U={enabled:B,refetchOnMount:`always`},t[23]=B,t[24]=U);let G=Mi(z,U),K;t[25]!==D||t[26]!==R?(K={directory:D,query:R,maxResults:40},t[25]=D,t[26]=R,t[27]=K):K=t[27];let te=!!(D&&R),q;t[28]===te?q=t[29]:(q={enabled:te},t[28]=te,t[29]=q);let ne=ji(K,q),re;t[30]!==O||t[31]!==u||t[32]!==k?(re=O&&u.readFile&&(!Xn(O)||k===`source`)&&(!Zn(O)||O.toLowerCase().endsWith(`.svg`)),t[30]=O,t[31]=u,t[32]=k,t[33]=re):re=t[33];let ie=!!re,ae;t[34]!==O||t[35]!==p?(ae={scopeDirectory:p,path:O},t[34]=O,t[35]=p,t[36]=ae):ae=t[36];let oe;t[37]===ie?oe=t[38]:(oe={enabled:ie},t[37]=ie,t[38]=oe);let se=Pi(ae,oe),J;t[39]!==O||t[40]!==p?(J={scopeDirectory:p,path:O},t[39]=O,t[40]=p,t[41]=J):J=t[41];let ce;t[42]===ie?ce=t[43]:(ce={enabled:ie},t[42]=ie,t[43]=ce),Ni(J,ce);let le=G.data?.entries.slice().sort(To)??[],ue;t[44]!==G.error||t[45]!==l?(ue=G.error?G.error instanceof Error?G.error.message:l(`mobile.files.error.listFailed`):null,t[44]=G.error,t[45]=l,t[46]=ue):ue=t[46];let Y=ue,de=G.isFetching,fe;t[47]===ne.data?fe=t[48]:(fe=ne.data??[],t[47]=ne.data,t[48]=fe);let pe=fe,me=!!(I&&R&&v===P&&ne.isFetching),he;t[49]!==se.data||t[50]!==l?(he=se.data&&se.data.length>io?`${se.data.slice(0,io)}\n\n${l(`mobile.files.file.truncated`)}`:se.data??``,t[49]=se.data,t[50]=l,t[51]=he):he=t[51];let ge=he,_e;t[52]!==O||t[53]!==se.error||t[54]!==u||t[55]!==l?(_e=O&&!u.readFile?l(`mobile.files.error.readUnavailable`):se.error?se.error instanceof Error?se.error.message:l(`filesView.error.readFileFailed`):null,t[52]=O,t[53]=se.error,t[54]=u,t[55]=l,t[56]=_e):_e=t[56];let ve=_e,ye=ie&&se.isFetching,be;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(be=e=>{y(``),g({type:`browser`,directory:e})},t[57]=be):be=t[57];let xe=be,Se;t[58]!==E||t[59]!==p?(Se=e=>{g({type:`file`,path:e,returnDirectory:E||p})},t[58]=E,t[59]=p,t[60]=Se):Se=t[60];let Ce=Se,we;t[61]!==s||t[62]!==n||t[63]!==h.returnDirectory||t[64]!==h.type?(we=()=>h.type===`file`?s?(n?.(),!0):(g({type:`browser`,directory:h.returnDirectory}),!0):!1,t[61]=s,t[62]=n,t[63]=h.returnDirectory,t[64]=h.type,t[65]=we):we=t[65];let Te=V(we),Ee=h.type===`file`,De;t[66]!==Te||t[67]!==Ee?(De={id:`mobile-files-detail`,active:Ee,layer:`overlay`,onBack:Te,surfaceRef:_},t[66]=Te,t[67]=Ee,t[68]=De):De=t[68],Bn(De);let Oe;t[69]===l?Oe=t[70]:(Oe=async e=>{(await H(e)).ok||Ze.error(l(`mobile.files.toast.copyFailed`))},t[69]=l,t[70]=Oe);let ke=Oe,Ae;t[71]!==ge||t[72]!==l?(Ae=async()=>{(await H(ge)).ok?Ze.success(l(`mobile.files.toast.contentCopied`)):Ze.error(l(`mobile.files.toast.copyFailed`))},t[71]=ge,t[72]=l,t[73]=Ae):Ae=t[73];let je=Ae;if(!p){let e;t[74]===l?e=t[75]:(e=l(`mobile.files.empty.noDirectory`),t[74]=l,t[75]=e);let n;return t[76]===e?n=t[77]:(n=(0,$.jsx)(So,{message:e}),t[76]=e,t[77]=n),n}if(h.type===`file`){let e;t[78]!==ke||t[79]!==h.path?(e=()=>void ke(h.path),t[78]=ke,t[79]=h.path,t[80]=e):e=t[80];let n;t[81]===je?n=t[82]:(n=()=>void je(),t[81]=je,t[82]=n);let r;return t[83]!==Te||t[84]!==ge||t[85]!==ve||t[86]!==c||t[87]!==k||t[88]!==ye||t[89]!==h.path||t[90]!==e||t[91]!==n?(r=(0,$.jsx)(`div`,{ref:_,className:`flex h-full min-h-0 flex-col`,children:(0,$.jsx)(yo,{path:h.path,content:ge,error:ve,isLoading:ye,hideHeader:c,htmlViewMode:k,onHtmlViewModeChange:A,onBack:Te,onCopyPath:e,onCopyContent:n})}),t[83]=Te,t[84]=ge,t[85]=ve,t[86]=c,t[87]=k,t[88]=ye,t[89]=h.path,t[90]=e,t[91]=n,t[92]=r):r=t[92],r}let Me;t[93]!==p||t[94]!==h.directory||t[95]!==l?(Me=h.directory===p?l(`mobile.files.rootDirectory`):oo(h.directory),t[93]=p,t[94]=h.directory,t[95]=l,t[96]=Me):Me=t[96];let Ne=Me,Pe;t[97]!==v||t[98]!==pe?(Pe=v.trim()?pe:[],t[97]=v,t[98]=pe,t[99]=Pe):Pe=t[99];let Fe=Pe,Ie,Le,Re,ze;if(t[100]!==n||t[101]!==v||t[102]!==p||t[103]!==h.directory||t[104]!==l){let e=so(h.directory),r=h.directory!==p&&e!==null&&(e===p||e.startsWith(`${p}/`)),i=r&&!v.trim(),a=r?e:null;ze=`flex h-full flex-col overflow-hidden bg-background text-foreground`,Ie=`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,t[109]!==n||t[110]!==l?(Le=n?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":l(`mobile.surface.closeAria`),onClick:n,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,t[109]=n,t[110]=l,t[111]=Le):Le=t[111],Re=i&&a?(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":l(`mobile.files.backToParentAria`,{name:oo(a)}),onClick:()=>xe(a),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}):null,t[100]=n,t[101]=v,t[102]=p,t[103]=h.directory,t[104]=l,t[105]=Ie,t[106]=Le,t[107]=Re,t[108]=ze}else Ie=t[105],Le=t[106],Re=t[107],ze=t[108];let Be;t[112]===Ne?Be=t[113]:(Be=(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label text-foreground`,children:Ne})}),t[112]=Ne,t[113]=Be);let Ve;t[114]===l?Ve=t[115]:(Ve=l(`mobile.files.refreshAria`),t[114]=l,t[115]=Ve);let He;t[116]===G?He=t[117]:(He=()=>void G.refetch(),t[116]=G,t[117]=He);let Ue;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(Ue={touchAction:`manipulation`},t[118]=Ue):Ue=t[118];let We=de&&`animate-spin`,Ge;t[119]===We?Ge=t[120]:(Ge=W(`size-5`,We),t[119]=We,t[120]=Ge);let Ke;t[121]===Ge?Ke=t[122]:(Ke=(0,$.jsx)(X,{name:`refresh`,className:Ge}),t[121]=Ge,t[122]=Ke);let qe;t[123]!==Ve||t[124]!==He||t[125]!==Ke?(qe=(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":Ve,onClick:He,style:Ue,children:Ke}),t[123]=Ve,t[124]=He,t[125]=Ke,t[126]=qe):qe=t[126];let Je;t[127]!==Ie||t[128]!==Le||t[129]!==Re||t[130]!==Be||t[131]!==qe?(Je=(0,$.jsxs)(`header`,{className:Ie,children:[Le,Re,Be,qe]}),t[127]=Ie,t[128]=Le,t[129]=Re,t[130]=Be,t[131]=qe,t[132]=Je):Je=t[132];let Ye;t[133]===Symbol.for(`react.memo_cache_sentinel`)?(Ye=(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),t[133]=Ye):Ye=t[133];let Xe;t[134]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=e=>y(e.target.value),t[134]=Xe):Xe=t[134];let Qe;t[135]===l?Qe=t[136]:(Qe=l(`mobile.files.search.placeholder`),t[135]=l,t[136]=Qe);let $e;t[137]!==v||t[138]!==Qe?($e=(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,"data-mobile-sheet-no-dismiss":``,children:(0,$.jsxs)(`div`,{className:`relative`,children:[Ye,(0,$.jsx)(Kt,{type:`text`,inputMode:`search`,value:v,onChange:Xe,placeholder:Qe,className:`h-11 pl-9`})]})}),t[137]=v,t[138]=Qe,t[139]=$e):$e=t[139];let et=Cn,tt=Y?(0,$.jsx)(So,{message:Y}):v.trim()?(0,$.jsx)(_o,{results:Fe,isSearching:me,onOpenFile:Ce}):(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:[le.length===0&&!de?(0,$.jsx)(`div`,{className:`px-4 py-8 text-center typography-body text-muted-foreground`,children:l(`mobile.files.empty.directory`)}):null,le.map(e=>(0,$.jsx)(go,{name:e.name,path:e.path,directory:e.isDirectory,meta:e.isDirectory?void 0:lo(e.size),onClick:()=>e.isDirectory?xe(e.path):Ce(e.path)},e.path))]}),nt;t[140]!==et||t[141]!==tt?(nt=(0,$.jsx)(et,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto px-4 pb-3`,children:tt}),t[140]=et,t[141]=tt,t[142]=nt):nt=t[142];let rt;return t[143]!==ze||t[144]!==Je||t[145]!==$e||t[146]!==nt?(rt=(0,$.jsxs)(`div`,{className:ze,children:[Je,$e,nt]}),t[143]=ze,t[144]=Je,t[145]=$e,t[146]=nt,t[147]=rt):rt=t[147],rt},go=e=>{let t=(0,Q.c)(16),{name:n,path:r,directory:i,meta:a,onClick:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]!==i||t[2]!==r?(c=i?(0,$.jsx)(X,{name:`folder-3-fill`,className:`size-5 shrink-0 text-muted-foreground`}):(0,$.jsx)(St,{filePath:r,className:`size-5 shrink-0`}),t[1]=i,t[2]=r,t[3]=c):c=t[3];let l;t[4]===n?l=t[5]:(l=(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:n}),t[4]=n,t[5]=l);let u;t[6]===a?u=t[7]:(u=a?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:a}):null,t[6]=a,t[7]=u);let d;t[8]===i?d=t[9]:(d=i?(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground/60`}):null,t[8]=i,t[9]=d);let f;return t[10]!==o||t[11]!==c||t[12]!==l||t[13]!==u||t[14]!==d?(f=(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-14 w-full items-center gap-3 border-b border-border/30 px-3 py-2.5 text-left transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,onClick:o,style:s,children:[c,l,u,d]}),t[10]=o,t[11]=c,t[12]=l,t[13]=u,t[14]=d,t[15]=f):f=t[15],f},_o=e=>{let t=(0,Q.c)(10),{results:n,isSearching:r,onOpenFile:i}=e,{t:a}=ee(),o=ao($n()??null);if(r){let e;t[0]===a?e=t[1]:(e=a(`common.loading`),t[0]=a,t[1]=e);let n;return t[2]===e?n=t[3]:(n=(0,$.jsx)(So,{loading:!0,message:e}),t[2]=e,t[3]=n),n}if(n.length===0){let e;t[4]===a?e=t[5]:(e=a(`mobile.files.search.empty`),t[4]=a,t[5]=e);let n;return t[6]===e?n=t[7]:(n=(0,$.jsx)(So,{message:e}),t[6]=e,t[7]=n),n}let s=n.map(e=>(0,$.jsx)(go,{name:oo(e.path),path:e.path,directory:!1,meta:co(e.path,o),onClick:()=>i(e.path)},e.path)),c;return t[8]===s?c=t[9]:(c=(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:s}),t[8]=s,t[9]=c),c},vo=e=>{let t=(0,Q.c)(24),{path:n,htmlViewMode:r,htmlFullscreen:i,onToggleHtmlViewMode:a,onEnterHtmlFullscreen:o,onCopyPath:s,onCopyContent:c}=e,{t:l}=ee(),u;t[0]===n?u=t[1]:(u=Xn(n),t[0]=n,t[1]=u);let d=u,f;t[2]!==d||t[3]!==i||t[4]!==r||t[5]!==o||t[6]!==a||t[7]!==l?(f=d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,onClick:a,"aria-label":l(r===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(X,{name:r===`preview`?`file-code`:`eye`,className:`size-4`})}),i?null:(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,onClick:o,"aria-label":l(`mobile.files.html.fullscreenAria`),children:(0,$.jsx)(X,{name:`fullscreen`,className:`size-4`})})]}):null,t[2]=d,t[3]=i,t[4]=r,t[5]=o,t[6]=a,t[7]=l,t[8]=f):f=t[8];let p;t[9]!==d||t[10]!==c||t[11]!==n||t[12]!==l?(p=!Zn(n)&&!d?(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,onClick:c,"aria-label":l(`mobile.files.copyContentAria`),children:(0,$.jsx)(X,{name:`file-copy`,className:`size-4`})}):null,t[9]=d,t[10]=c,t[11]=n,t[12]=l,t[13]=p):p=t[13];let m;t[14]===l?m=t[15]:(m=l(`mobile.files.copyPathAria`),t[14]=l,t[15]=m);let h;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(X,{name:`clipboard`,className:`size-4`}),t[16]=h):h=t[16];let g;t[17]!==s||t[18]!==m?(g=(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,onClick:s,"aria-label":m,children:h}),t[17]=s,t[18]=m,t[19]=g):g=t[19];let _;return t[20]!==f||t[21]!==p||t[22]!==g?(_=(0,$.jsxs)($.Fragment,{children:[f,p,g]}),t[20]=f,t[21]=p,t[22]=g,t[23]=_):_=t[23],_},yo=e=>{let n=(0,Q.c)(100),{path:r,content:a,error:o,isLoading:c,hideHeader:l,htmlViewMode:f,onHtmlViewModeChange:p,onBack:m,onCopyPath:h,onCopyContent:g}=e,_=l!==void 0&&l,{t:v}=ee(),y=Z.useRef(null),b=Zn(r)&&!r.toLowerCase().endsWith(`.svg`)?r:``,x;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=s(),n[0]=x):x=n[0];let S=x,C;n[1]===b?C=n[2]:(C=b&&i()?`${S}|${b}`:``,n[1]=b,n[2]=C);let w=C,T=b&&!w?`${S}|${b}`:``,[E,D]=Z.useState(``),[O,k]=Z.useState(``),[A,j]=Z.useState(null),[M,N]=Z.useState(!1),P;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(P={open:!1,title:``,content:``},n[3]=P):P=n[3];let[F,I]=Z.useState(P),L,R;n[4]===T?(L=n[5],R=n[6]):(L=()=>{if(!T){D(``);return}let e=!1;return D(``),t(u()).then(t=>{!e&&t&&D(T)}).catch(Eo),()=>{e=!0}},R=[T],n[4]=T,n[5]=L,n[6]=R),Z.useEffect(L,R);let z,B;n[7]!==b||n[8]!==w||n[9]!==v?(z=()=>{if(!w){k(``),j(null),N(!1);return}let e=!1,t=``;return k(``),j(null),N(!0),d(`/api/fs/raw`,{query:{path:b}}).then(async e=>{if(!e.ok)throw Error(v(`filesView.error.readFileFailed`));return e.blob()}).then(n=>{if(t=URL.createObjectURL(n),e){URL.revokeObjectURL(t);return}k(t)}).catch(t=>{e||j(t instanceof Error?t.message:v(`filesView.error.readFileFailed`))}).finally(()=>{e||N(!1)}),()=>{e=!0,t&&URL.revokeObjectURL(t)}},B=[b,w,v],n[7]=b,n[8]=w,n[9]=v,n[10]=z,n[11]=B):(z=n[10],B=n[11]),Z.useEffect(z,B);let H=!!(T&&E!==T),U;n[12]!==H||n[13]!==r||n[14]!==w||n[15]!==O?(U=w?O:H?``:uo(r),n[12]=H,n[13]=r,n[14]=w,n[15]=O,n[16]=U):U=n[16];let W=U,K=o??A,te;n[17]===r?te=n[18]:(te=oo(r),n[17]=r,n[18]=te);let q=te,ne;n[19]!==a||n[20]!==r?(ne=Zn(r)?`data:${Yn(r)};utf8,${encodeURIComponent(a)}`:``,n[19]=a,n[20]=r,n[21]=ne):ne=n[21];let re=ne,ie;n[22]!==a||n[23]!==re||n[24]!==W||n[25]!==r?(ie=W||(Zn(r)&&a?re:``),n[22]=a,n[23]=re,n[24]=W,n[25]=r,n[26]=ie):ie=n[26];let ae=ie,oe;n[27]!==q||n[28]!==b||n[29]!==r||n[30]!==ae?(oe=()=>{let e=b||ae;e&&I({open:!0,title:q,content:``,metadata:{tool:`image-preview`,filename:q,mime:Yn(r)},image:{url:e,mimeType:Yn(r),filename:q}})},n[27]=q,n[28]=b,n[29]=r,n[30]=ae,n[31]=oe):oe=n[31];let se=V(oe),J;n[32]===Symbol.for(`react.memo_cache_sentinel`)?(J=e=>{I(t=>t.open===e?t:{...t,open:e})},n[32]=J):J=n[32];let ce=V(J),le;n[33]===r?le=n[34]:(le=Xn(r),n[33]=r,n[34]=le);let ue=le,[Y,de]=Z.useState(!1),fe=Z.useRef(null),pe;n[35]===Symbol.for(`react.memo_cache_sentinel`)?(pe=()=>{de(!1)},n[35]=pe):pe=n[35];let me;n[36]===r?me=n[37]:(me=[r],n[36]=r,n[37]=me),Z.useEffect(pe,me);let he;n[38]!==f||n[39]!==p?(he=()=>{p(f===`preview`?`source`:`preview`)},n[38]=f,n[39]=p,n[40]=he):he=n[40];let ge=V(he),_e;n[41]===Symbol.for(`react.memo_cache_sentinel`)?(_e=()=>{de(!0)},n[41]=_e):_e=n[41];let ve=V(_e),ye;n[42]===Symbol.for(`react.memo_cache_sentinel`)?(ye=()=>(de(!1),!0),n[42]=ye):ye=n[42];let be=V(ye),xe=ue&&Y,Se;n[43]!==be||n[44]!==xe?(Se={id:`mobile-html-fullscreen`,active:xe,layer:`overlay`,onBack:be,surfaceRef:fe},n[43]=be,n[44]=xe,n[45]=Se):Se=n[45],Bn(Se);let Ce;n[46]!==ve||n[47]!==Y||n[48]!==f||n[49]!==g||n[50]!==h||n[51]!==r||n[52]!==ge?(Ce=(0,$.jsx)(vo,{path:r,htmlViewMode:f,htmlFullscreen:Y,onToggleHtmlViewMode:ge,onEnterHtmlFullscreen:ve,onCopyPath:h,onCopyContent:g}),n[46]=ve,n[47]=Y,n[48]=f,n[49]=g,n[50]=h,n[51]=r,n[52]=ge,n[53]=Ce):Ce=n[53];let we=Ce,Te;n[54]!==a||n[55]!==o||n[56]!==f||n[57]!==c||n[58]!==r||n[59]!==v?(Te=f===`source`?c?(0,$.jsx)(So,{loading:!0,message:v(`filesView.state.loading`)}):o?(0,$.jsx)(So,{message:o}):(0,$.jsx)(xo,{path:r,content:a}):(0,$.jsx)(bo,{path:r}),n[54]=a,n[55]=o,n[56]=f,n[57]=c,n[58]=r,n[59]=v,n[60]=Te):Te=n[60];let Ee=Te,De;n[61]!==be||n[62]!==ue||n[63]!==Ee||n[64]!==Y||n[65]!==f||n[66]!==q||n[67]!==v||n[68]!==ge?(De=ue?(0,$.jsxs)(`div`,{ref:fe,"data-mobile-html-preview":f===`preview`&&!Y?`true`:void 0,"data-mobile-html-fullscreen":f===`preview`&&Y?`true`:void 0,className:Y?`fixed inset-0 z-[80] flex flex-col bg-background text-foreground`:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[Y?(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center gap-2 border-b border-border/50 px-3 pb-2 pt-[max(0.5rem,env(safe-area-inset-top))]`,children:[(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,onClick:be,"aria-label":v(`mobile.files.html.exitFullscreenAria`),className:`shrink-0 text-muted-foreground`,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-header text-foreground`,children:q}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,onClick:ge,"aria-label":v(f===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(X,{name:f===`preview`?`file-code`:`eye`,className:`size-4`})})]}):null,(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden bg-background`,children:Ee})]}):null,n[61]=be,n[62]=ue,n[63]=Ee,n[64]=Y,n[65]=f,n[66]=q,n[67]=v,n[68]=ge,n[69]=De):De=n[69];let Oe=De,ke;n[70]!==we||n[71]!==_||n[72]!==q||n[73]!==m||n[74]!==v?(ke=_?(0,$.jsx)(hn,{children:we}):(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/50 px-3 text-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":v(`header.actions.backAria`),onClick:m,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-header text-foreground`,children:q})}),we]}),n[70]=we,n[71]=_,n[72]=q,n[73]=m,n[74]=v,n[75]=ke):ke=n[75];let Ae;n[76]!==a||n[77]!==ue||n[78]!==Y||n[79]!==Oe||n[80]!==H||n[81]!==K||n[82]!==q||n[83]!==c||n[84]!==M||n[85]!==se||n[86]!==r||n[87]!==ae||n[88]!==v?(Ae=ue?Y&&typeof document<`u`?(0,Ra.createPortal)(Oe,document.body):Oe:c||H||M?(0,$.jsx)(So,{loading:!0,message:v(`filesView.state.loading`)}):K?(0,$.jsx)(So,{message:K}):Zn(r)&&ae?(0,$.jsx)(Cn,{className:`h-full overflow-auto p-4`,children:(0,$.jsx)(`button`,{type:`button`,className:`mx-auto block max-h-full max-w-full cursor-zoom-in rounded-lg border-0 bg-transparent p-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:se,"aria-label":q,children:(0,$.jsx)(`img`,{src:ae,alt:q,className:`mx-auto max-h-full max-w-full rounded-lg object-contain`,draggable:!1})})}):(0,$.jsx)(xo,{path:r,content:a}),n[76]=a,n[77]=ue,n[78]=Y,n[79]=Oe,n[80]=H,n[81]=K,n[82]=q,n[83]=c,n[84]=M,n[85]=se,n[86]=r,n[87]=ae,n[88]=v,n[89]=Ae):Ae=n[89];let je;n[90]===Ae?je=n[91]:(je=(0,$.jsx)(`div`,{ref:y,className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:Ae}),n[90]=Ae,n[91]=je);let Me;n[92]===Symbol.for(`react.memo_cache_sentinel`)?(Me=(0,$.jsx)(pt,{containerRef:y}),n[92]=Me):Me=n[92];let Ne;n[93]!==ce||n[94]!==F?(Ne=F.open?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ro,{popup:F,onOpenChange:ce,isMobile:!0})}):null,n[93]=ce,n[94]=F,n[95]=Ne):Ne=n[95];let Pe;return n[96]!==ke||n[97]!==je||n[98]!==Ne?(Pe=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[ke,je,Me,Ne]}),n[96]=ke,n[97]=je,n[98]=Ne,n[99]=Pe):Pe=n[99],Pe},bo=e=>{let a=(0,Q.c)(29),{path:o}=e,{t:s}=ee(),c;a[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=i(),a[0]=c):c=a[0];let l=c,f=Z.useRef(null),[p,m]=Z.useState(``),[h,g]=Z.useState(0),[_,v]=Z.useState(null),[y,b]=Z.useState(``),x,S;a[1]!==o||a[2]!==s?(x=()=>{let e=!1;if(m(``),v(null),b(``),l)return d(po(o)).then(async e=>{if(!e.ok)throw Error(s(`filesView.error.readFileFailed`));return e.text()}).then(t=>{e||(b(t),m(o))}).catch(t=>{e||(v(t instanceof Error?t.message:s(`filesView.error.readFileFailed`)),m(o))}),()=>{e=!0};let i=u(),a=n(i);t(i).then(t=>{e||!t||(m(o),v(null))}).catch(t=>{e||(v(t instanceof Error?t.message:s(`filesView.error.readFileFailed`)),m(o))});let c=r(()=>{e||(m(o),g(Do),v(null))});return()=>{e=!0,a(),c()}},S=[o,l,s],a[1]=o,a[2]=s,a[3]=x,a[4]=S):(x=a[3],S=a[4]),Z.useEffect(x,S);let C;a[5]!==o||a[6]!==p?(C=()=>{if(p!==o)return;let e=f.current;if(e)return no(e)},a[5]=o,a[6]=p,a[7]=C):C=a[7];let w;if(a[8]!==h||a[9]!==o||a[10]!==p||a[11]!==y?(w=[h,o,p,y],a[8]=h,a[9]=o,a[10]=p,a[11]=y,a[12]=w):w=a[12],Z.useEffect(C,w),_){let e;return a[13]===_?e=a[14]:(e=(0,$.jsx)(So,{message:_}),a[13]=_,a[14]=e),e}if(p!==o){let e;a[15]===s?e=a[16]:(e=s(`filesView.state.loading`),a[15]=s,a[16]=e);let t;return a[17]===e?t=a[18]:(t=(0,$.jsx)(So,{loading:!0,message:e}),a[17]=e,a[18]=t),t}let T;a[19]===o?T=a[20]:(T=l?void 0:mo(o),a[19]=o,a[20]=T);let E=l?y:void 0,D;a[21]===Symbol.for(`react.memo_cache_sentinel`)?(D={backgroundColor:`var(--surface-background)`},a[21]=D):D=a[21];let O;a[22]===s?O=a[23]:(O=s(`filesView.editor.htmlPreviewTitle`),a[22]=s,a[23]=O);let k;return a[24]!==h||a[25]!==T||a[26]!==E||a[27]!==O?(k=(0,$.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:(0,$.jsx)(`iframe`,{ref:f,src:T,srcDoc:E,className:`h-full min-h-0 w-full flex-1 border-none bg-background`,style:D,sandbox:`allow-scripts allow-same-origin allow-forms`,title:O},h)}),a[24]=h,a[25]=T,a[26]=E,a[27]=O,a[28]=k):k=a[28],k},xo=e=>{let t=(0,Q.c)(30),{path:n,content:r}=e,{currentTheme:i,availableThemes:a,lightThemeId:o,darkThemeId:s}=cn(),c;t[0]!==a||t[1]!==o?(c=a.find(e=>e.metadata.id===o)??fn(!1),t[0]=a,t[1]=o,t[2]=c):c=t[2];let l=c,u;t[3]!==a||t[4]!==s?(u=a.find(e=>e.metadata.id===s)??fn(!0),t[3]=a,t[4]=s,t[5]=u):u=t[5];let d=u,f,p;t[6]!==d||t[7]!==l?(f=()=>{Wn(l),Wn(d)},p=[d,l],t[6]=d,t[7]=l,t[8]=f,t[9]=p):(f=t[8],p=t[9]),Z.useEffect(f,p);let m;t[10]!==d.metadata.id||t[11]!==l.metadata.id?(m={light:l.metadata.id,dark:d.metadata.id},t[10]=d.metadata.id,t[11]=l.metadata.id,t[12]=m):m=t[12];let h=m;if(fo(n)){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(Cn,{className:`h-full overflow-y-auto px-4 py-4`,children:(0,$.jsx)(Kn,{content:r,enableFileReferences:!1})}),t[13]=r,t[14]=e),e}let g;t[15]===n?g=t[16]:(g=oo(n),t[15]=n,t[16]=g);let _;t[17]===n?_=t[18]:(_=Qn(n)||void 0,t[17]=n,t[18]=_);let v;t[19]!==r||t[20]!==g||t[21]!==_?(v={name:g,contents:r,lang:_},t[19]=r,t[20]=g,t[21]=_,t[22]=v):v=t[22];let y=i.metadata.variant===`dark`?`dark`:`light`,b;t[23]!==h||t[24]!==y?(b={disableFileHeader:!0,overflow:`wrap`,theme:h,themeType:y,unsafeCSS:Tr},t[23]=h,t[24]=y,t[25]=b):b=t[25];let x;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(x={minHeight:`100%`},t[26]=x):x=t[26];let S;return t[27]!==b||t[28]!==v?(S=(0,$.jsx)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:(0,$.jsx)(Cn,{className:`min-h-0 flex-1 overflow-auto bg-[var(--syntax-base-background)]`,children:(0,$.jsx)(z,{file:v,options:b,className:`block min-h-full w-full`,style:x})})}),t[27]=b,t[28]=v,t[29]=S):S=t[29],S},So=e=>{let t=(0,Q.c)(7),{message:n,loading:r}=e,i=r!==void 0&&r,a;t[0]===i?a=t[1]:(a=i?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):(0,$.jsx)(X,{name:`folder-open-fill`,className:`size-6 text-muted-foreground`}),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[2]=n,t[3]=o);let s;return t[4]!==a||t[5]!==o?(s=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[a,o]})}),t[4]=a,t[5]=o,t[6]=s):s=t[6],s};function Co(e){return e.pendingFileFocusPath}function wo(e){return e.setPendingFileFocusPath}function To(e,t){return e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1}function Eo(){}function Do(e){return e+1}var Oo=v(e=>({expandedParents:{},toggleParent:t=>e(e=>{let n={...e.expandedParents};return n[t]?delete n[t]:n[t]=!0,{expandedParents:n}})})),ko=v()(y(e=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(t,n)=>e(e=>({projectExpanded:{...e.projectExpanded,[t]:n}})),setWorktreeExpanded:(t,n)=>e(e=>({worktreeExpanded:{...e.worktreeExpanded,[t]:n}}))}),{name:`mobile-session-tree`,storage:p()}));typeof window<`u`&&a(e=>{l(e)&&ko.persist.rehydrate()});var Ao=36,jo=18,Mo=e=>e.parentID??null,No=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Po=e=>{let t=e;return No(t.directory??t.project?.worktree??null)},Fo=e=>{let t=No(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},Io=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},Lo=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),Ro=e=>{if(e<=0)return``;let t=Date.now()-e;if(t<6e4)return`now`;let n=Math.floor(t/6e4);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r<24)return`${r}h`;let i=Math.floor(r/24);return i<7?`${i}d`:new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))},zo=(e,t)=>{let n=No(e),r=No(t);return!!(n&&r&&(n===r||n.startsWith(`${r}/`)))},Bo=(e,t)=>e.worktrees.find(e=>No(e.path)===t)??null,Vo=(e,t)=>t===e.path||!!Bo(e,t),Ho=(e,t)=>{let n=No(t);return n?e.find(e=>Vo(e,n))??null:null},Uo=(e,t,n)=>!n||`${e.title??``} ${e.id} ${Po(e)} ${t}`.toLowerCase().includes(n),Wo=e=>{let t=(0,Q.c)(14),{project:n,size:r}=e,i=r===void 0?`md`:r,a=i===`sm`?`size-6 rounded-md`:`size-8 rounded-lg`,o=i===`sm`?`size-3.5`:`size-4`,s=n.icon?Wt[n.icon]:null,c=n.color?Bt[n.color]:void 0,l=s??`folder-open`,u;t[0]===c?u=t[1]:(u=c?{color:c}:void 0,t[0]=c,t[1]=u);let d;t[2]!==o||t[3]!==l||t[4]!==u?(d=(0,$.jsx)(X,{name:l,className:o,style:u}),t[2]=o,t[3]=l,t[4]=u,t[5]=d):d=t[5];let f=d,p;t[6]===a?p=t[7]:(p=W(`flex shrink-0 items-center justify-center overflow-hidden text-muted-foreground`,a),t[6]=a,t[7]=p);let m;t[8]!==f||t[9]!==n?(m=n.iconImage?(0,$.jsx)(Vt,{project:n,className:`size-full object-contain`,fallback:f}):f,t[8]=f,t[9]=n,t[10]=m):m=t[10];let h;return t[11]!==p||t[12]!==m?(h=(0,$.jsx)(`span`,{className:p,children:m}),t[11]=p,t[12]=m,t[13]=h):h=t[13],h},Go=e=>{let t=(0,Q.c)(5),{expanded:n}=e,r=n?`rotate-0`:`-rotate-90`,i;t[0]===r?i=t[1]:(i=W(`flex size-5 shrink-0 items-center justify-center text-muted-foreground/70 transition-transform duration-150`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4`}),t[2]=a):a=t[2];let o;return t[3]===i?o=t[4]:(o=(0,$.jsx)(`span`,{"aria-hidden":!0,className:i,children:a}),t[3]=i,t[4]=o),o},Ko=e=>{let t=(0,Q.c)(2),{ariaLabel:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`span`,{className:`inline-block size-1.5 shrink-0 rounded-full bg-primary`,"aria-label":n}),t[0]=n,t[1]=r),r},qo=e=>{let t=(0,Q.c)(12),{onClick:n,className:r}=e,{t:i}=ee(),a;t[0]===i?a=t[1]:(a=i(`sessions.sidebar.project.actions.newWorktree`),t[0]=i,t[1]=a);let o=a,s;t[2]===r?s=t[3]:(s=W(`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,r),t[2]=r,t[3]=s);let c;t[4]===n?c=t[5]:(c=e=>{e.stopPropagation(),n()},t[4]=n,t[5]=c);let l,u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l={touchAction:`manipulation`},u=(0,$.jsx)(X,{name:`node-tree`,className:`size-4`}),t[6]=l,t[7]=u):(l=t[6],u=t[7]);let d;return t[8]!==o||t[9]!==s||t[10]!==c?(d=(0,$.jsx)(`button`,{type:`button`,className:s,"aria-label":o,title:o,onClick:c,style:l,children:u}),t[8]=o,t[9]=s,t[10]=c,t[11]=d):d=t[11],d},Jo=e=>{let t=(0,Q.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)(X,{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)(G,{type:`button`,variant:o,size:`default`,className:`min-h-12 w-full justify-start gap-3 rounded-xl px-3 typography-ui-label`,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},Yo=e=>{let t=(0,Q.c)(100),{session:n,active:r,indent:i,contextLabel:a,confirmingArchive:o,hasChildren:s,expanded:c,onToggleChildren:l,onSelect:u,onRequestArchive:d,onConfirmArchive:f,onStop:p,stopAriaLabel:m,longPressHandlers:h,highlightQuery:g}=e,_=o!==void 0&&o,v=s!==void 0&&s,y=c!==void 0&&c,{t:b}=ee(),x;t[0]===n?x=t[1]:(x=Ro(Io(n)),t[0]=n,t[1]=x);let S=x,C,w,T,E,D,O,k,A,j,M,N,P,F,I,L,R,z,B;if(t[2]!==r||t[3]!==_||t[4]!==y||t[5]!==v||t[6]!==g||t[7]!==i||t[8]!==h.onContextMenu||t[9]!==h.onPointerCancel||t[10]!==h.onPointerDown||t[11]!==h.onPointerMove||t[12]!==h.onPointerUp||t[13]!==h.pressed||t[14]!==u||t[15]!==l||t[16]!==n.title||t[17]!==b){B=n.title?.trim()||b(`mobile.sessions.untitled`);let e=r&&!_&&`bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]`,a=_&&`bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]`;t[36]!==e||t[37]!==a?(N=W(`relative flex items-center gap-1 transition-colors`,e,a),t[36]=e,t[37]=a,t[38]=N):N=t[38],t[39]!==y||t[40]!==v||t[41]!==i||t[42]!==l||t[43]!==b?(P=v&&l?(0,$.jsx)(`button`,{type:`button`,className:`absolute z-10 flex w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,style:{left:Math.max(i-32,2),top:0,bottom:0,touchAction:`manipulation`},"aria-label":b(y?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:e=>{e.stopPropagation(),l()},children:(0,$.jsx)(X,{name:`arrow-down-s`,className:W(`size-[18px] transition-transform duration-150`,y?`rotate-0`:`-rotate-90`)})}):null,t[39]=y,t[40]=v,t[41]=i,t[42]=l,t[43]=b,t[44]=P):P=t[44],C=`button`;let o=_&&`opacity-50`,s=h.pressed&&`bg-interactive-active scale-[0.99]`;t[45]!==o||t[46]!==s?(w=W(`flex min-h-12 min-w-0 flex-1 items-center gap-2.5 py-2 pr-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,o,s),t[45]=o,t[46]=s,t[47]=w):w=t[47],t[48]===i?T=t[49]:(T={paddingLeft:i,touchAction:`manipulation`},t[48]=i,t[49]=T),E=u,D=h.onPointerDown,O=h.onPointerMove,k=h.onPointerUp,A=h.onPointerCancel,j=h.onContextMenu,M=_,z=`flex min-w-0 flex-1 flex-col`,L=`flex items-center gap-2.5`;let c=r?`bg-primary`:`bg-muted-foreground/30`,d;t[50]===c?d=t[51]:(d=W(`size-1.5 shrink-0 rounded-full`,c),t[50]=c,t[51]=d),t[52]===d?R=t[53]:(R=(0,$.jsx)(`span`,{className:d,"aria-hidden":!0}),t[52]=d,t[53]=R);let f=r?`text-primary`:`text-foreground`;t[54]===f?F=t[55]:(F=W(`block min-w-0 flex-1 truncate typography-ui-label`,f),t[54]=f,t[55]=F),I=g?tn(B,g):B,t[2]=r,t[3]=_,t[4]=y,t[5]=v,t[6]=g,t[7]=i,t[8]=h.onContextMenu,t[9]=h.onPointerCancel,t[10]=h.onPointerDown,t[11]=h.onPointerMove,t[12]=h.onPointerUp,t[13]=h.pressed,t[14]=u,t[15]=l,t[16]=n.title,t[17]=b,t[18]=C,t[19]=w,t[20]=T,t[21]=E,t[22]=D,t[23]=O,t[24]=k,t[25]=A,t[26]=j,t[27]=M,t[28]=N,t[29]=P,t[30]=F,t[31]=I,t[32]=L,t[33]=R,t[34]=z,t[35]=B}else C=t[18],w=t[19],T=t[20],E=t[21],D=t[22],O=t[23],k=t[24],A=t[25],j=t[26],M=t[27],N=t[28],P=t[29],F=t[30],I=t[31],L=t[32],R=t[33],z=t[34],B=t[35];let V;t[56]!==F||t[57]!==I?(V=(0,$.jsx)(`span`,{className:F,children:I}),t[56]=F,t[57]=I,t[58]=V):V=t[58];let H;t[59]===S?H=t[60]:(H=S?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:S}):null,t[59]=S,t[60]=H);let U;t[61]!==V||t[62]!==H||t[63]!==L||t[64]!==R?(U=(0,$.jsxs)(`span`,{className:L,children:[R,V,H]}),t[61]=V,t[62]=H,t[63]=L,t[64]=R,t[65]=U):U=t[65];let G;t[66]!==a||t[67]!==g?(G=a?(0,$.jsx)(`span`,{className:`block truncate typography-micro text-muted-foreground pl-4`,children:g?tn(a,g):a}):null,t[66]=a,t[67]=g,t[68]=G):G=t[68];let K;t[69]!==U||t[70]!==G||t[71]!==z?(K=(0,$.jsxs)(`span`,{className:z,children:[U,G]}),t[69]=U,t[70]=G,t[71]=z,t[72]=K):K=t[72];let te;t[73]!==C||t[74]!==w||t[75]!==T||t[76]!==E||t[77]!==D||t[78]!==O||t[79]!==k||t[80]!==A||t[81]!==j||t[82]!==M||t[83]!==K?(te=(0,$.jsx)(`button`,{type:C,className:w,style:T,onClick:E,onPointerDown:D,onPointerMove:O,onPointerUp:k,onPointerCancel:A,onContextMenu:j,disabled:M,children:K}),t[73]=C,t[74]=w,t[75]=T,t[76]=E,t[77]=D,t[78]=O,t[79]=k,t[80]=A,t[81]=j,t[82]=M,t[83]=K,t[84]=te):te=t[84];let q;t[85]!==p||t[86]!==m?(q=p?(0,$.jsx)(`button`,{type:`button`,className:`mr-0.5 flex size-9 shrink-0 items-center justify-center rounded-xl text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-label":m,onClick:e=>{e.stopPropagation(),p()},style:{touchAction:`manipulation`},children:(0,$.jsx)(vr,{})}):null,t[85]=p,t[86]=m,t[87]=q):q=t[87];let ne;t[88]!==_||t[89]!==f||t[90]!==d||t[91]!==b||t[92]!==B?(ne=d?(0,$.jsxs)($.Fragment,{children:[_?(0,$.jsxs)(`button`,{type:`button`,className:`flex h-9 shrink-0 items-center gap-1.5 rounded-xl bg-destructive px-3 text-destructive-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive`,"aria-label":b(`mobile.sessions.archiveSessionAria`,{title:B}),onClick:f,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`archive`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label`,children:b(`sessions.sidebar.bulkActions.archive`)})]}):null,(0,$.jsx)(`button`,{type:`button`,className:`mr-1.5 flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":b(_?`mobile.sessions.cancelArchiveAria`:`mobile.sessions.archiveSessionAria`,{title:B}),onClick:d,style:{touchAction:`manipulation`},children:_?(0,$.jsx)(X,{name:`close`,className:`size-4`}):(0,$.jsx)(X,{name:`archive`,className:`size-4`})})]}):null,t[88]=_,t[89]=f,t[90]=d,t[91]=b,t[92]=B,t[93]=ne):ne=t[93];let re;return t[94]!==N||t[95]!==P||t[96]!==te||t[97]!==q||t[98]!==ne?(re=(0,$.jsxs)(`div`,{className:N,children:[P,te,q,ne]}),t[94]=N,t[95]=P,t[96]=te,t[97]=q,t[98]=ne,t[99]=re):re=t[99],re},Xo=e=>{let t=(0,Q.c)(15),{indent:n,showMore:r,showFewer:i,loadingMore:a,onShowMore:o,onShowFewer:s}=e,c=a!==void 0&&a,{t:l}=ee();if(!r&&!i)return null;let u;t[0]===n?u=t[1]:(u={paddingLeft:n,touchAction:`manipulation`},t[0]=n,t[1]=u);let d;t[2]!==s||t[3]!==i||t[4]!==l?(d=i?(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-left transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,onClick:s,children:[(0,$.jsx)(X,{name:`arrow-up-s`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-micro`,children:l(`sessions.sidebar.group.showFewer`)})]}):null,t[2]=s,t[3]=i,t[4]=l,t[5]=d):d=t[5];let f;t[6]!==c||t[7]!==o||t[8]!==r||t[9]!==l?(f=r?(0,$.jsxs)(`button`,{type:`button`,className:W(`inline-flex items-center gap-1.5 text-left transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset disabled:pointer-events-none disabled:opacity-60`,c&&`animate-pulse`),onClick:o,disabled:c,children:[(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-micro`,children:l(`sessions.sidebar.group.showMore`)})]}):null,t[6]=c,t[7]=o,t[8]=r,t[9]=l,t[10]=f):f=t[10];let p;return t[11]!==u||t[12]!==d||t[13]!==f?(p=(0,$.jsxs)(`div`,{className:`flex min-h-10 w-full items-center gap-3 py-1.5 pr-3 text-muted-foreground`,style:u,children:[d,f]}),t[11]=u,t[12]=d,t[13]=f,t[14]=p):p=t[14],p},Zo=({open:e,onOpenChange:t,variant:n=`sheet`})=>{let{t:r}=ee(),{git:i}=pn(),a=Ie(),o=xe(),s=Fe(e=>e.activeSessions),c=Fe(e=>e.activePaginationByDirectory),l=Ve(e=>e.projects),u=Ve(e=>e.activeProjectId),d=T(e=>e.currentDirectory),f=Re(e=>e.currentSessionId),p=Re(e=>e.availableWorktreesByProject),m=Re(e=>e.setCurrentSession),h=Re(e=>e.archiveSession),g=Re(e=>e.archiveSessions),_=Re(e=>e.updateSessionTitle),v=Re(e=>e.requestSessionSmartTitle),y=Re(e=>e.shareSession),b=Re(e=>e.unshareSession),x=Re(e=>e.openNewSessionDraft),S=Ve(e=>e.setActiveProject),C=Ve(e=>e.setActiveProjectIdOnly),w=Ve(e=>e.removeProject),E=De(),D=he(),O=ko(e=>e.projectExpanded),k=ko(e=>e.worktreeExpanded),A=ko(e=>e.setProjectExpanded),j=ko(e=>e.setWorktreeExpanded),M=jt(e=>e.orderByProject),N=Oo(e=>e.expandedParents),P=Oo(e=>e.toggleParent),[F,I]=Z.useState(``),[L,R]=Z.useState(null),[z,B]=Z.useState(null),[U,K]=Z.useState(0),[te,q]=Z.useState(!1),[ne,re]=Z.useState(!1),[ie,ae]=Z.useState(null),[oe,se]=Z.useState(null),[J,ce]=Z.useState(null),[le,ue]=Z.useState(null),[Y,de]=Z.useState(null),[pe,me]=Z.useState(``),[ge,_e]=Z.useState(!1),[ve,ye]=Z.useState(null),be=Z.useRef(null);be.current||=er({onPressedKeyChange:ue});let[Ce,we]=Z.useState(new Set),[Te,Ee]=Z.useState(new Map),[Oe,ke]=Z.useState(new Map),Ae=jr(),je=kr(),Me=V(e=>{Se(e),fe(e)}),Ne=V(e=>{Promise.all(e.map(e=>(Se(e),fe(e))))});Z.useEffect(()=>{if(!e){I(``),ke(new Map),R(null),B(null),se(null),de(null),ye(null),be.current?.reset();return}},[e]),Z.useEffect(()=>()=>{be.current?.reset()},[]),Z.useEffect(()=>{if(!e)return;if(l.length===0){Re.setState(e=>{let t=Or(e.availableWorktreesByProject,new Set,[]);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:[]}}),we(e=>e.size===0?e:new Set),Ee(e=>e.size===0?e:new Map);return}let t=!1;return(async()=>{let e=await Promise.all(l.map(async e=>{let n=No(e.path);if(!n)return null;let r;try{r=await i.checkIsGitRepository(n)}catch{return{id:e.id,path:n,gitStatus:`failed`}}if(!r)return{id:e.id,path:n,gitStatus:`success`,isGitRepo:r,worktreeStatus:`success`,worktrees:[]};let[a,o]=await Promise.allSettled([Gt({id:e.id,path:n},{isCurrent:()=>!t}),Ht(n)]);return{id:e.id,path:n,gitStatus:`success`,isGitRepo:r,worktreeStatus:a.status===`fulfilled`?`success`:`failed`,worktrees:a.status===`fulfilled`?a.value.worktrees:void 0,rootBranchStatus:o.status===`fulfilled`?`success`:`failed`,rootBranch:o.status===`fulfilled`?o.value:void 0}}));if(t)return;let n=new Set(l.map(e=>No(e.path)).filter(Boolean)),r=e.flatMap(e=>e?.worktreeStatus?[{path:e.path,status:e.worktreeStatus,worktrees:e.worktrees}]:[]);Re.setState(e=>{let t=Or(e.availableWorktreesByProject,n,r);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:Array.from(t.values()).flat()}}),we(t=>{let r=new Set([...t].filter(e=>n.has(e)));for(let t of e)t?.gitStatus===`success`&&(t.isGitRepo?r.add(t.path):r.delete(t.path));return Lo(r,t)?t:r}),Ee(t=>{let n=new Set(l.map(e=>e.id)),r=new Map([...t].filter(([e])=>n.has(e)));for(let t of e){if(!t||t.gitStatus!==`success`)continue;if(!t.isGitRepo){r.delete(t.id);continue}if(t.rootBranchStatus!==`success`)continue;let e=t.rootBranch?.trim();e&&e!==`HEAD`?r.set(t.id,e):r.delete(t.id)}return r.size===t.size&&[...r].every(([e,n])=>t.get(e)===n)?t:r})})(),()=>{t=!0}},[i,e,l,U]);let Pe=Z.useMemo(()=>l.map(e=>({id:e.id,label:Fo(e.path),path:No(e.path),icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:Ce.has(No(e.path)),worktrees:kt(M[e.id],p.get(No(e.path))??[])})),[Ce,l,M,p]),Le=Z.useMemo(()=>{let e=new Map(o.map(e=>[e.id,e])),t=s.map(t=>{let n=e.get(t.id);return n?Ue(n,t):t}),n=new Set(t.map(e=>e.id));for(let e of o)n.has(e.id)||t.push(e);return t},[s,o]),Be=F.trim().toLowerCase(),He=Z.useMemo(()=>{let e=Pe.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===u})),t=(e,t,n)=>{let r=No(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||Fo(r),path:r,worktree:n,sessions:[]},e.buckets.push(a)),a};for(let n of e){t(n,n.project.path,null);for(let e of n.project.worktrees)t(n,e.path,e)}for(let n of Le){let r=Po(n);if(!r)continue;let i=No(r),a=e.find(e=>Vo(e.project,i));if(!a)continue;let o=Bo(a.project,i);(o?t(a,o.path,o):t(a,a.project.path,null)).sessions.push(n)}for(let t of e)for(let e of t.buckets){e.sessions.sort((e,t)=>ze(t)-ze(e));for(let n of e.sessions)Mo(n)||(t.totalSessions+=1)}return e},[u,Pe,Le]),We=No(d),Ge=e=>e.isActive?We===e.project.path?e.project.path:e.project.worktrees.find(e=>zo(We,e.path))?.path??e.project.path:null,qe=e=>O[e.project.id]??!0,Je=(e,t)=>k[`${e.project.id}::${t.key}`]??!1,Ye=e=>{ke(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},Xe=()=>{se(null),be.current?.reset()},Qe=e=>({pressed:le===e.key||oe?.key===e.key,onPointerDown:t=>{t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||be.current?.start({pointerId:t.pointerId,key:e.key,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>se(e)})},onPointerMove:e=>{be.current?.move(e.pointerId,e.clientX,e.clientY)},onPointerUp:e=>{be.current?.end(e.pointerId)},onPointerCancel:e=>{be.current?.cancel(e.pointerId)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),be.current?.openFromContextMenu(e.key,()=>se(e))}}),et=(e,t)=>{be.current?.consumeClick(e)||t()},tt=(e,t,n,r)=>{let i=yr(),a=ni();if(ke(t=>{let r=new Map(t),o=Math.max(i,t.get(e)??i,n);return r.set(e,o+a),r}),Math.max(i,n)+a<r)return;let o=No(t);if(!o)return;let s=Fe.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&Ke(o)},nt=(e,t,n)=>{let i=`${e.project.id}::${t.key}`,a=yr(),o=new Set(t.sessions.map(e=>e.id)),s=new Map;for(let e of t.sessions){let t=Mo(e);if(t&&o.has(t)){let n=s.get(t)??[];n.push(e),s.set(t,n)}}let l=t.sessions.filter(e=>!Mo(e)),u=Oe.get(i)??a,d=wr(l,u,je),p=l.length-d.length,m=c.get(No(t.path)),h=m?.hasMore===!0,g=m?.loadingMore===!0,_=l.length>a&&u>a,v=(e,t)=>{let n=s.get(e.id)??[],i=n.length>0,a=!!N[e.id],o=Ae.has(e.id),c=i&&!a?n.filter(e=>Ae.has(e.id)).map(e=>e.id):[],l=c.length>0,u=o?[e.id,...c]:c,d=e.title?.trim()||r(`mobile.sessions.untitled`),p=`session:${e.id}`;return(0,$.jsxs)(Z.Fragment,{children:[(0,$.jsx)(Yo,{session:e,active:f===e.id,indent:t,hasChildren:i,expanded:a,onToggleChildren:i?()=>P(e.id):void 0,confirmingArchive:z===e.id,onSelect:()=>et(p,()=>at(e)),onRequestArchive:()=>ot(e.id),onConfirmArchive:()=>void st(e),onStop:o||l?()=>Ne(u):void 0,stopAriaLabel:r(l?`mobile.sessions.stopSubsessionsAria`:`mobile.sessions.stopSessionAria`,{title:d}),longPressHandlers:Qe({key:p,kind:`session`,session:e})}),i&&a?n.map(e=>v(e,t+jo)):null]},e.id)};return(0,$.jsxs)(`div`,{children:[d.map(e=>v(e,n)),(0,$.jsx)(Xo,{indent:n,showMore:p>0||h,showFewer:_,loadingMore:g,onShowMore:()=>tt(i,t.path,u,l.length),onShowFewer:()=>Ye(i)})]})},rt=(e,t)=>{A(e,!t)},it=(e,t,n)=>{j(`${e}::${t}`,!n)},at=e=>{mn();let n=Po(e)||null,r=Ho(Pe,n??``);r&&C(r.id),m(e.id,n),t(!1)},ot=e=>{B(t=>t===e?null:e)},st=async e=>{B(null),await h(e.id)?Wr({sessionIds:[e.id],message:r(`sessions.sidebar.session.archive.success`),undoLabel:r(`sessions.sidebar.undo`),settingsLabel:r(`settings.openchamber.archivedSessions.actions.view`),undoFailedMessage:r(`sessions.sidebar.session.archive.undoFailed`)}):Ze.error(r(`sessions.sidebar.session.archive.error`))},ct=()=>{x(),t(!1)},lt=e=>{ae(e),C(e),re(!0)},ut=e=>{let t=new Map;for(let e of Le){let n=Mo(e);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},ft=async e=>{let t=ut(e.id),{archivedIds:n,failedIds:i}=await g(t);n.length>0&&Wr({sessionIds:n,message:n.length===1?r(`sessions.sidebar.session.archive.success`):r(`sessions.sidebar.bulkActions.archivedPlural`,{count:n.length}),undoLabel:r(`sessions.sidebar.undo`),settingsLabel:r(`settings.openchamber.archivedSessions.actions.view`),undoFailedMessage:n.length===1?r(`sessions.sidebar.session.archive.undoFailed`):r(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:n.length})}),i.length>0&&Ze.error(i.length===1?r(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):r(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}))},pt=e=>{let t=ut(e.id);Er({sessionIds:t,message:t.length===1?r(`sessions.sidebar.session.delete.success`):r(`sessions.sidebar.bulkActions.deletedPlural`,{count:t.length}),undoLabel:r(`sessions.sidebar.undo`),commitFailedMessage:r(`sessions.sidebar.session.delete.error`)})},mt=async e=>{try{if(!(await y(e.id))?.share?.url){Ze.error(r(`sessions.sidebar.session.share.error`));return}Ze.success(r(`sessions.sidebar.session.share.successTitle`),{description:r(`sessions.sidebar.session.share.successDescription`)})}catch{Ze.error(r(`sessions.sidebar.session.share.error`))}},ht=async e=>{if((await H(e)).ok){Ze.success(r(`sessions.sidebar.session.menu.copied`));return}Ze.error(r(`sessions.sidebar.session.share.copyUrlError`))},gt=async e=>{try{if(await b(e)){Ze.success(r(`sessions.sidebar.session.unshare.success`));return}Ze.error(r(`sessions.sidebar.session.unshare.error`))}catch{Ze.error(r(`sessions.sidebar.session.unshare.error`))}},_t=async()=>{if(!Y)return;let e=pe.trim();if(e)try{await _(Y.id,e),de(null),me(``)}catch{Ze.error(r(`sessions.sidebar.session.menu.rename`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},vt=async()=>{if(!Y||ge)return;let e=Y.id;de(null),me(``),_e(!0);try{await v(e)}catch{Ze.error(r(`sessions.sidebar.session.rename.smartTitle`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{_e(!1)}},yt=(e,n)=>{C(e.id),x({selectedProjectId:e.id,directoryOverride:n,preserveDirectoryOverride:!0}),t(!1)},bt=e=>{(async()=>{try{await Gt({id:e.id,path:e.path})}catch(e){console.warn(`[MobileSessions] Worktree refresh before session sync failed:`,e)}let t=Re.getState().availableWorktreesByProject.get(e.path)??e.worktrees,n=[e.path,...t.map(e=>e.path)];await $e(n,Le)})()},xt=e=>{let t=Po(e),n=Ho(Pe,t);if(!n)return Fo(t)||t;let r=Bo(n,No(t));return r?.branch?`${n.label} · ${r.branch}`:n.label},St=e=>{S(e.id),t(!1)},Ct=Z.useMemo(()=>Be?He.filter(e=>`${e.project.label} ${e.project.path}`.toLowerCase().includes(Be)?!0:e.buckets.some(t=>t.sessions.some(t=>Uo(t,e.project.label,Be)))):He,[Be,He]),wt=Z.useMemo(()=>Be?Le.filter(e=>{let t=Po(e);return Uo(e,Ho(Pe,t)?.label??``,Be)}).sort((e,t)=>ze(t)-ze(e)):[],[Be,Pe,Le]),Tt=Z.useMemo(()=>Be?Pe.filter(e=>`${e.label} ${e.path}`.toLowerCase().includes(Be)).map(e=>({...e,sessionCount:Le.filter(t=>!Mo(t)&&Vo(e,No(Po(t)))).length})):[],[Be,Pe,Le]),Et=Be&&wt.length===0&&Tt.length===0,Dt=Pe.length>0?(0,$.jsxs)(G,{type:`button`,variant:`default`,size:`sm`,"aria-label":r(`mobile.sessions.newChat`),onClick:ct,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`add`,className:`size-4`}),r(`mobile.sessions.newChat`)]}):null,Ot=Pe.find(e=>e.id===u)??null,At=Ot?.isGitRepo?(0,$.jsx)(G,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.project.actions.newWorktree`),title:r(`sessions.sidebar.project.actions.newWorktree`),onClick:()=>lt(Ot.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`node-tree`,className:`size-4`})}):null,Mt=(0,$.jsx)(G,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.header.actions.addProject`),title:r(`sessions.sidebar.header.actions.addProject`),onClick:()=>q(!0),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`folder-add`,className:`size-4`})}),Nt=Dt||Mt?(0,$.jsxs)($.Fragment,{children:[Dt,At,Mt]}):null,Pt=oe?.kind===`project`?oe.project.label:oe?.kind===`worktree`?oe.worktree.branch||oe.worktree.label||oe.worktree.path:oe?.kind===`session`?oe.session.title?.trim()||r(`mobile.sessions.untitled`):``,Ft=Z.useMemo(()=>{if(!oe)return[];if(oe.kind===`project`){let e=oe.project;return ii({gitRepository:e.isGitRepo,onNewSession:()=>{Xe(),yt(e,e.path)},onNewWorktree:()=>{Xe(),lt(e.id)},onSyncSessions:()=>{Xe(),bt(e)},onEditProject:()=>{Xe(),R(e.id)},onCloseProject:()=>{Xe(),ce(e)}})}if(oe.kind===`worktree`){let{project:e,worktree:t}=oe;return ri({onNewSession:()=>{Xe(),yt(e,t.path)},onDeleteWorktree:()=>{Xe(),ye({project:e,worktree:t})}})}let e=oe.session,t=!!e.share?.url;return Ir({pinned:E.has(e.id),shared:t,onRename:()=>{Xe(),me(e.title?.trim()||r(`mobile.sessions.untitled`)),de(e)},onTogglePin:()=>{Xe(),D(e.id)},onShare:!a||t?void 0:()=>{Xe(),mt(e)},onCopyLink:a&&t?()=>{let t=e.share?.url;Xe(),t&&ht(t)}:void 0,onUnshare:a&&t?()=>{Xe(),gt(e.id)}:void 0,onArchive:()=>{Xe(),ft(e)},onDelete:()=>{Xe(),pt(e)}})},[oe,Xe,ft,ht,pt,lt,mt,gt,E,yt,bt,r,D]),It=Ft.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:Ft.map(e=>{let t=(0,$.jsx)(Jo,{icon:e.icon,label:Dr(e,r),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:t},e.id):t})}):null,Lt=(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(Kt,{value:F,onChange:e=>I(e.target.value),placeholder:r(`mobile.sessions.search.placeholder`),className:W(`h-11 pl-9`,F&&`pr-10`)}),F?(0,$.jsx)(`button`,{type:`button`,className:`absolute right-1.5 top-1/2 flex size-8 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":r(`mobile.sessions.clearSearchAria`),onClick:()=>I(``),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-4`})}):null]})}),(0,$.jsx)(Cn,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto pb-4`,children:Pe.length===0?(0,$.jsx)(Qo,{title:r(`mobile.sessions.empty.noProjectsTitle`),description:r(`mobile.sessions.empty.noProjectsDescription`),action:(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center justify-center gap-2 rounded-2xl bg-primary px-5 py-3 typography-ui-label text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:()=>q(!0),children:[(0,$.jsx)(X,{name:`folder-add`,className:`size-4`}),r(`sessions.sidebar.header.actions.addProject`)]})}):Et?(0,$.jsx)(Qo,{title:r(`mobile.sessions.empty.searchTitle`),description:r(`mobile.sessions.empty.searchDescription`)}):Be?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-3 pt-2`,children:[wt.length>0?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-1 pb-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-semibold uppercase tracking-wider text-muted-foreground`,children:r(`mobile.sessions.search.section.sessions`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:wt.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:wt.map((e,t)=>{let n=Ae.has(e.id),i=e.title?.trim()||r(`mobile.sessions.untitled`);return(0,$.jsx)(`div`,{className:W(t>0&&`border-t border-border/30`),children:(0,$.jsx)(Yo,{session:e,active:f===e.id,indent:12,contextLabel:xt(e),highlightQuery:Be,onSelect:()=>et(`session:${e.id}`,()=>at(e)),longPressHandlers:Qe({key:`session:${e.id}`,kind:`session`,session:e}),onStop:n?()=>Me(e.id):void 0,stopAriaLabel:r(`mobile.sessions.stopSessionAria`,{title:i})})},e.id)})})]}):null,Tt.length>0?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-1 pb-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-semibold uppercase tracking-wider text-muted-foreground`,children:r(`mobile.sessions.search.section.projects`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:Tt.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:Tt.map((e,t)=>{let n=`project:${e.id}`,r=Qe({key:n,kind:`project`,project:e});return(0,$.jsxs)(`div`,{className:W(`flex items-center`,t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`button`,{type:`button`,className:W(`flex min-h-14 min-w-0 flex-1 items-center gap-3 px-3 py-2 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,r.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>et(n,()=>St(e)),onPointerDown:r.onPointerDown,onPointerMove:r.onPointerMove,onPointerUp:r.onPointerUp,onPointerCancel:r.onPointerCancel,onContextMenu:r.onContextMenu,style:{touchAction:`manipulation`},children:[(0,$.jsx)(Wo,{project:e}),(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:tn(e.label,Be)}),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.sessionCount})]}),e.isGitRepo?(0,$.jsx)(qo,{className:`mr-2`,onClick:()=>lt(e.id)}):null]},e.id)})})]}):null]}):(0,$.jsx)(`div`,{className:`flex flex-col`,children:Ct.map((e,t)=>{let n=qe(e),i=`project:${e.project.id}`,a=Qe({key:i,kind:`project`,project:e.project}),o=Be?e.buckets.filter(t=>t.sessions.some(t=>Uo(t,e.project.label,Be))):e.buckets,s=Ge(e);return(0,$.jsxs)(`section`,{className:W(t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`div`,{className:`flex min-h-14 w-full items-center`,children:[(0,$.jsxs)(`button`,{type:`button`,className:W(`flex min-h-14 min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,a.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>et(i,()=>rt(e.project.id,n)),onPointerDown:a.onPointerDown,onPointerMove:a.onPointerMove,onPointerUp:a.onPointerUp,onPointerCancel:a.onPointerCancel,onContextMenu:a.onContextMenu,"aria-expanded":n,"aria-label":r(n?`sessions.sidebar.group.collapseAria`:`sessions.sidebar.group.expandAria`,{label:e.project.label}),style:{touchAction:`manipulation`},children:[(0,$.jsx)(Wo,{project:e.project}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label font-semibold text-foreground`,children:e.project.label}),Te.get(e.project.id)?(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 typography-micro text-muted-foreground`,children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:Te.get(e.project.id)})]}):null]}),e.isActive?(0,$.jsx)(Ko,{ariaLabel:r(`mobile.sessions.activeProjectAria`)}):null,(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.totalSessions})]}),(()=>{let t=n?[]:[...new Set(e.buckets.flatMap(e=>e.sessions.filter(e=>Ae.has(e.id)).map(e=>e.id)))];return t.length>0?(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] mr-1`,"aria-label":r(`mobile.sessions.stopGroupAria`,{label:e.project.label}),onClick:e=>{e.stopPropagation(),Ne(t)},style:{touchAction:`manipulation`},children:(0,$.jsx)(vr,{})}):null})(),e.project.isGitRepo?(0,$.jsx)(qo,{className:`mr-2`,onClick:()=>lt(e.project.id)}):null]}),n?(0,$.jsx)(`div`,{className:`pb-2`,children:(()=>{let t=o.find(e=>e.worktree===null),n=o.filter(e=>e.worktree!==null);return(0,$.jsxs)($.Fragment,{children:[t&&t.sessions.length>0?nt(e,t,Ao):null,n.map(t=>{let n=Je(e,t),i=s===t.path,a=`worktree:${e.project.id}:${t.key}`,o=Qe({key:a,kind:`worktree`,project:e.project,worktree:t.worktree});return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,className:W(`flex min-h-11 w-full items-center gap-2 py-1.5 pl-4 pr-3 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,o.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>et(a,()=>it(e.project.id,t.key,n)),onPointerDown:o.onPointerDown,onPointerMove:o.onPointerMove,onPointerUp:o.onPointerUp,onPointerCancel:o.onPointerCancel,onContextMenu:o.onContextMenu,"aria-expanded":n,"aria-label":r(n?`sessions.sidebar.group.collapseAria`:`sessions.sidebar.group.expandAria`,{label:t.label}),style:{touchAction:`manipulation`},children:[(0,$.jsx)(Go,{expanded:n}),(0,$.jsx)(X,{name:`node-tree`,className:W(`size-4 shrink-0`,i?`text-primary`:`text-muted-foreground`)}),(0,$.jsx)(`span`,{className:W(`block min-w-0 flex-1 truncate typography-ui-label font-semibold`,i?`text-foreground`:`text-foreground/90`),children:t.label}),i?(0,$.jsx)(Ko,{ariaLabel:r(`mobile.sessions.activeWorktreeAria`)}):null,(()=>{let e=n?[]:t.sessions.filter(e=>Ae.has(e.id)).map(e=>e.id);return e.length>0?(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-label":r(`mobile.sessions.stopGroupAria`,{label:t.label}),onClick:t=>{t.stopPropagation(),Ne(e)},style:{touchAction:`manipulation`},children:(0,$.jsx)(vr,{})}):null})(),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:t.sessions.length})]}),n?nt(e,t,Ao):null]},t.key)})]})})()}):null]},e.project.id)})})}),(0,$.jsx)(Yr,{open:te,onOpenChange:q,forceMobile:!0}),(0,$.jsx)(dt,{open:ne,projectId:ie,onOpenChange:e=>{re(e),e||ae(null)},onWorktreeCreated:(e,n)=>{n?.sessionId?m(n.sessionId,e):x({selectedProjectId:ie,directoryOverride:e,preserveDirectoryOverride:!0}),t(!1)}}),(0,$.jsx)(Jt,{open:!!oe,title:Pt,onClose:Xe,contentMaxHeightClassName:`max-h-[min(68dvh,560px)]`,children:It}),(0,$.jsx)(Jt,{open:!!J,title:r(`sessions.sidebar.project.actions.closeProject`),onClose:()=>ce(null),closeAriaLabel:r(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(G,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>ce(null),children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(G,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!J)return;let e=J;ce(null),w(e.id),Ze.success(r(`mobile.sessions.toast.projectRemoved`,{label:e.label}))},children:r(`mobile.sessions.confirmRemoveProject`)})]}),children:(0,$.jsx)(`p`,{className:`px-1 py-1 typography-ui-body text-foreground`,children:r(`mobile.projects.closeConfirmMessage`,{title:J?.label??``})})}),(0,$.jsx)(Jt,{open:!!Y,title:r(`sessions.sidebar.session.menu.rename`),onClose:()=>{ge||(de(null),me(``))},footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(G,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:ge,onClick:()=>{de(null),me(``)},children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(G,{type:`button`,variant:`default`,className:`flex-1`,disabled:!pe.trim()||ge,onClick:()=>void _t(),children:r(`sessions.sidebar.session.rename.save`)})]}),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-3 px-1 py-1`,onSubmit:e=>{e.preventDefault(),_t()},children:[(0,$.jsx)(Kt,{value:pe,onChange:e=>me(e.target.value),autoFocus:!0,className:`h-12`,disabled:ge}),(0,$.jsxs)(G,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:ge,onClick:()=>void vt(),children:[ge?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`ai-generate-2`,className:`size-4`}),r(`sessions.sidebar.session.rename.smartTitle`)]})]})}),ve?(0,$.jsx)(br,{open:!0,project:{id:ve.project.id,path:ve.project.path},worktree:ve.worktree,onClose:()=>ye(null),onDeleted:()=>K(e=>e+1)}):null,(0,$.jsx)(xr,{open:L!==null,project:Pe.find(e=>e.id===L)??null,onClose:()=>R(null),onWorktreesChanged:()=>K(e=>e+1)})]});return n===`sidebar`?e?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsx)(`div`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center justify-end gap-2 px-4`,children:Nt?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:Nt}):null}),Lt]}):null:(0,$.jsx)(yn,{id:`mobile-sessions-sheet`,open:e,onOpenChange:t,trailing:Nt,ariaLabel:r(`mobile.sessions.sheet.title`),closeAriaLabel:r(`mobile.surface.closeAria`),resizeAriaLabel:r(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:Lt})},Qo=e=>{let t=(0,Q.c)(10),{title:n,description:r,action:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r}):null,t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=i?(0,$.jsx)(`div`,{className:`pt-2`,children:i}):null,t[4]=i,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[a,o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c},$o=`/assets/assistant-guide-hero-wide-DiFIThB0.jpg`,es=[{image:ci,titleKey:`assistants.guide.share.ios.title`,descriptionKey:`assistants.guide.share.ios.description`},{image:ui,titleKey:`assistants.guide.share.android.title`,descriptionKey:`assistants.guide.share.android.description`},{image:pi,titleKey:`assistants.guide.share.pick.title`,descriptionKey:`assistants.guide.share.pick.description`}];function ts(){let e=(0,Q.c)(8),{t}=ee(),n;e[0]===t?n=e[1]:(n=t(`common.loading`),e[0]=t,e[1]=n);let r,i,a,o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`div`,{className:`h-10 w-10 animate-pulse rounded-xl bg-[var(--surface-muted)] motion-reduce:animate-none`}),i=(0,$.jsx)(`div`,{className:`mt-2 h-4 w-2/3 animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),a=(0,$.jsx)(`div`,{className:`h-3.5 w-full animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),o=(0,$.jsx)(`div`,{className:`h-3.5 w-4/5 animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),e[2]=r,e[3]=i,e[4]=a,e[5]=o):(r=e[2],i=e[3],a=e[4],o=e[5]);let s;return e[6]===n?s=e[7]:(s=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3 p-5`,"aria-busy":`true`,"aria-label":n,children:[r,i,a,o]}),e[6]=n,e[7]=s),s}function ns(e){let t=(0,Q.c)(35),{onEnable:n}=e,{t:r}=ee(),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-guide-hero`,"aria-hidden":`true`,children:(0,$.jsx)(`img`,{src:$o,alt:``})}),t[0]=i):i=t[0];let a;t[1]===r?a=t[2]:(a=r(`assistants.guide.disabledTitle`),t[1]=r,t[2]=a);let o;t[3]===a?o=t[4]:(o=(0,$.jsx)(`h2`,{className:`oc-mobile-assistant-guide-title`,children:a}),t[3]=a,t[4]=o);let s;t[5]===r?s=t[6]:(s=r(`assistants.guide.disabledDescription`),t[5]=r,t[6]=s);let c;t[7]===s?c=t[8]:(c=(0,$.jsx)(`p`,{className:`oc-mobile-assistant-guide-description`,children:s}),t[7]=s,t[8]=c);let l;t[9]===r?l=t[10]:(l=r(`assistants.guide.enableAction`),t[9]=r,t[10]=l);let u;t[11]!==n||t[12]!==l?(u=(0,$.jsx)(G,{type:`button`,size:`lg`,onClick:n,children:l}),t[11]=n,t[12]=l,t[13]=u):u=t[13];let d;t[14]!==o||t[15]!==c||t[16]!==u?(d=(0,$.jsxs)(`div`,{className:`oc-mobile-assistant-guide-body`,children:[o,c,u]}),t[14]=o,t[15]=c,t[16]=u,t[17]=d):d=t[17];let f;t[18]===r?f=t[19]:(f=r(`assistants.guide.shareTitle`),t[18]=r,t[19]=f);let p;t[20]===f?p=t[21]:(p=(0,$.jsx)(`h3`,{className:`oc-mobile-assistant-guide-share-title`,children:f}),t[20]=f,t[21]=p);let m;t[22]===r?m=t[23]:(m=r(`assistants.guide.shareAria`),t[22]=r,t[23]=m);let h;t[24]===r?h=t[25]:(h=es.map(e=>(0,$.jsxs)(`article`,{className:`oc-mobile-assistant-guide-step`,children:[(0,$.jsx)(`div`,{className:`oc-mobile-assistant-guide-step-image`,children:(0,$.jsx)(`img`,{src:e.image,alt:``})}),(0,$.jsxs)(`div`,{className:`oc-mobile-assistant-guide-step-copy`,children:[(0,$.jsx)(`h4`,{children:r(e.titleKey)}),(0,$.jsx)(`p`,{children:r(e.descriptionKey)})]})]},e.titleKey)),t[24]=r,t[25]=h);let g;t[26]!==m||t[27]!==h?(g=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-guide-steps`,"aria-label":m,children:h}),t[26]=m,t[27]=h,t[28]=g):g=t[28];let _;t[29]!==p||t[30]!==g?(_=(0,$.jsxs)(`section`,{className:`oc-mobile-assistant-guide-share`,children:[p,g]}),t[29]=p,t[30]=g,t[31]=_):_=t[31];let v;return t[32]!==_||t[33]!==d?(v=(0,$.jsxs)(`article`,{className:`oc-mobile-assistant-guide`,children:[i,d,_]}),t[32]=_,t[33]=d,t[34]=v):v=t[34],v}function rs({unreadCount:e,assistantID:t,displayName:n,avatarEmoji:r,summary:i,enabled:a,editLabel:o,deleteLabel:s,onOpen:c,onEdit:l,onDelete:u,serverWorking:d=!1}){let f=bi(t,d),[p,m]=Z.useState(!1),[h,g]=Z.useState(!1),_=Z.useRef(null);_.current||=er({onPressedKeyChange:e=>g(e===t)}),Z.useEffect(()=>()=>_.current?.reset(),[]);let v=V(()=>{_.current?.consumeClick(t)||p||c()}),y=V(()=>{m(!1),l()}),b=V(()=>{m(!1),u()}),x=V(()=>{g(!1),m(!0)}),S=V(e=>{e.pointerType!==`touch`&&e.pointerType!==`pen`||e.button!==0||_.current?.start({pointerId:e.pointerId,key:t,clientX:e.clientX,clientY:e.clientY,onTrigger:x})}),C=V(e=>{_.current?.move(e.pointerId,e.clientX,e.clientY)}),w=V(e=>{_.current?.end(e.pointerId)}),T=V(e=>{_.current?.cancel(e.pointerId)}),E=V(e=>{e.preventDefault(),e.stopPropagation(),_.current?.openFromContextMenu(t,x)});return(0,$.jsxs)(Ai,{open:p,onOpenChange:m,children:[(0,$.jsx)(ur,{"data-mobile-press-surface":`soft`,className:W(`oc-mobile-assistant-card-shell`,h&&`bg-interactive-hover`),children:(0,$.jsxs)(Ei,{render:(0,$.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":`false`,"data-mobile-press-surface-trigger":!0,className:W(`oc-mobile-assistant-card`,!a&&`opacity-65`),onClick:v,onPointerDown:S,onPointerMove:C,onPointerUp:w,onPointerCancel:T,onContextMenu:E,style:{touchAction:`pan-y`}}),children:[(0,$.jsx)(`span`,{className:W(`oc-mobile-assistant-avatar`,r?`oc-mobile-assistant-avatar--emoji`:`oc-mobile-assistant-avatar--visual`),children:(0,$.jsx)(Si,{name:t,emoji:r,size:40,label:n,working:f})}),(0,$.jsxs)(`span`,{className:`oc-mobile-assistant-card-content min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`oc-mobile-entity-title oc-mobile-assistant-name block min-w-0 truncate font-semibold text-foreground`,children:n}),(0,$.jsx)(`span`,{className:W(`oc-mobile-assistant-summary`,xi),children:i})]}),(0,$.jsx)(wi,{count:e})]})}),(0,$.jsxs)(Oi,{className:`min-w-[10rem]`,children:[(0,$.jsxs)(ki,{className:`min-h-10 px-3`,onClick:y,children:[(0,$.jsx)(X,{name:`edit`,className:`size-4`}),o]}),(0,$.jsx)(Di,{}),(0,$.jsxs)(ki,{className:`min-h-10 px-3 text-[var(--status-error)] focus:text-[var(--status-error)] data-[highlighted]:text-[var(--status-error)] [&_svg]:text-[var(--status-error)]`,onClick:b,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`}),s]})]})]})}function is(e){let t=(0,Q.c)(118),{onEnable:n,onOpenAssistant:r,className:i}=e,{t:a}=ee(),o=En(),s=ue(),c=de();c.data?.assistants;let l;t[0]===c.data?.assistants?l=t[1]:(l=c.data?.assistants??[],t[0]=c.data?.assistants,t[1]=l);let u;t[2]===l?u=t[3]:(u=yi(l),t[2]=l,t[3]=u);let d=u,f=tt(as),[p,m]=Z.useState(null),h;t[4]===n?h=t[5]:(h=()=>n(),t[4]=n,t[5]=h);let g=V(h),_;t[6]!==o||t[7]!==f?(_=()=>{f(),o?.openSettings(`assistants`)},t[6]=o,t[7]=f,t[8]=_):_=t[8];let v=V(_),y;t[9]===r?y=t[10]:(y=e=>r(e),t[9]=r,t[10]=y);let b=V(y),x;t[11]===o?x=t[12]:(x=e=>{rt(e,o?{openMobileSettings:o.openSettings}:void 0)},t[11]=o,t[12]=x);let S=V(x),C;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{m(e)},t[13]=C):C=t[13];let w=V(C),T;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>{e||m(null)},t[14]=T):T=t[14];let E=V(T),D;t[15]===a?D=t[16]:(D=a(`assistants.title`),t[15]=a,t[16]=D);let O=D,k;t[17]===a?k=t[18]:(k=a(`assistants.menu.edit`),t[17]=a,t[18]=k);let A=k,j;t[19]===a?j=t[20]:(j=a(`assistants.settings.delete`),t[19]=a,t[20]=j);let M=j;if(s.isPending||s.data?.supported&&s.data.enabled&&c.isPending){let e;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ur,{className:`oc-mobile-assistant-loading`,children:(0,$.jsx)(ts,{})}),t[21]=e):e=t[21];let n;return t[22]!==i||t[23]!==O?(n=(0,$.jsx)(lr,{title:O,className:i,surface:!1,children:e}),t[22]=i,t[23]=O,t[24]=n):n=t[24],n}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length>0){let e;t[25]===a?e=t[26]:(e=a(`assistants.settings.create`),t[25]=a,t[26]=e);let n;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(X,{name:`add`,className:`size-5`}),t[27]=n):n=t[27];let r;t[28]!==v||t[29]!==e?(r=(0,$.jsx)(G,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":e,onClick:v,children:n}),t[28]=v,t[29]=e,t[30]=r):r=t[30];let o;t[31]===c.data?o=t[32]:(o=(0,$.jsx)(_i,{snapshot:c.data,rowClassName:`flex justify-end pb-2`}),t[31]=c.data,t[32]=o);let s;t[33]===a?s=t[34]:(s=a(`assistants.listAria`),t[33]=a,t[34]=s);let l;if(t[35]!==d||t[36]!==M||t[37]!==A||t[38]!==S||t[39]!==b||t[40]!==w||t[41]!==a){let e;t[43]!==M||t[44]!==A||t[45]!==S||t[46]!==b||t[47]!==w||t[48]!==a?(e=e=>{let t=q(e.name),n=t.displayName||e.name,r=vi(e.latestMessagePreview,a);return(0,$.jsx)(rs,{assistantID:e.id,unreadCount:e.unreadCount??0,displayName:n,avatarEmoji:t.avatarEmoji??void 0,summary:r,enabled:e.enabled,editLabel:A,deleteLabel:M,assignedSessionIDs:e.assignedSessionIDs,serverWorking:e.working,onOpen:()=>b(e.id),onEdit:()=>S(e.id),onDelete:()=>w(e)},e.id)},t[43]=M,t[44]=A,t[45]=S,t[46]=b,t[47]=w,t[48]=a,t[49]=e):e=t[49],l=d.map(e),t[35]=d,t[36]=M,t[37]=A,t[38]=S,t[39]=b,t[40]=w,t[41]=a,t[42]=l}else l=t[42];let u;t[50]!==s||t[51]!==l?(u=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-catalog`,role:`listbox`,"aria-label":s,children:l}),t[50]=s,t[51]=l,t[52]=u):u=t[52];let f=p!==null,m;t[53]!==p||t[54]!==E||t[55]!==f?(m=(0,$.jsx)(gi,{assistant:p,open:f,onOpenChange:E}),t[53]=p,t[54]=E,t[55]=f,t[56]=m):m=t[56];let h;return t[57]!==i||t[58]!==O||t[59]!==r||t[60]!==o||t[61]!==u||t[62]!==m?(h=(0,$.jsxs)(lr,{title:O,className:i,surface:!1,scrollsWithPage:!0,trailing:r,children:[o,u,m]}),t[57]=i,t[58]=O,t[59]=r,t[60]=o,t[61]=u,t[62]=m,t[63]=h):h=t[63],h}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length===0){let e;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`oc-mobile-assistant-onboarding-icon`,children:(0,$.jsx)(X,{name:`ai-agent`,className:`size-5`})}),t[64]=e):e=t[64];let n;t[65]===a?n=t[66]:(n=a(`assistants.onboarding.title`),t[65]=a,t[66]=n);let r;t[67]===n?r=t[68]:(r=(0,$.jsx)(`h2`,{children:n}),t[67]=n,t[68]=r);let o;t[69]===a?o=t[70]:(o=a(`assistants.onboarding.description`),t[69]=a,t[70]=o);let s;t[71]===o?s=t[72]:(s=(0,$.jsx)(`p`,{children:o}),t[71]=o,t[72]=s);let c;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(X,{name:`add`,className:`size-[18px]`}),t[73]=c):c=t[73];let l;t[74]===a?l=t[75]:(l=a(`assistants.onboarding.action`),t[74]=a,t[75]=l);let u;t[76]!==v||t[77]!==l?(u=(0,$.jsxs)(G,{type:`button`,size:`lg`,className:`mt-6 w-full`,onClick:v,children:[c,l]}),t[76]=v,t[77]=l,t[78]=u):u=t[78];let d;t[79]!==r||t[80]!==s||t[81]!==u?(d=(0,$.jsxs)(ur,{className:`oc-mobile-assistant-onboarding`,children:[e,r,s,u]}),t[79]=r,t[80]=s,t[81]=u,t[82]=d):d=t[82];let f;return t[83]!==i||t[84]!==O||t[85]!==d?(f=(0,$.jsx)(lr,{title:O,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:d}),t[83]=i,t[84]=O,t[85]=d,t[86]=f):f=t[86],f}let N=s.isSuccess&&s.data.supported===!1,P=s.isError||s.data?.supported===!0&&s.data.enabled&&c.isError,F=s.data?.supported===!0&&(s.data.enabled===!1||c.data?.enabled===!1),I;t[87]!==a||t[88]!==P||t[89]!==N?(I=a(P?`assistants.state.unavailable`:N?`assistants.state.unsupportedTitle`:`assistants.state.instanceDisabled`),t[87]=a,t[88]=P,t[89]=N,t[90]=I):I=t[90];let L=I;if(F&&!P){let e;t[91]===g?e=t[92]:(e=(0,$.jsx)(ns,{onEnable:g}),t[91]=g,t[92]=e);let n;return t[93]!==i||t[94]!==O||t[95]!==e?(n=(0,$.jsx)(lr,{title:O,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-guide-host`,children:e}),t[93]=i,t[94]=O,t[95]=e,t[96]=n):n=t[96],n}let R;t[97]===O?R=t[98]:(R=(0,$.jsx)(`span`,{className:`oc-mobile-page-section-label`,children:O}),t[97]=O,t[98]=R);let z=N?`cloud-off`:`sparkling`,B;t[99]===z?B=t[100]:(B=(0,$.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground`,children:(0,$.jsx)(X,{name:z,weight:`medium`,className:`size-5`})}),t[99]=z,t[100]=B);let H;t[101]===L?H=t[102]:(H=(0,$.jsx)(`h2`,{className:`mt-5 max-w-xs text-lg font-semibold leading-snug tracking-[-0.02em] text-foreground`,children:L}),t[101]=L,t[102]=H);let U;t[103]!==a||t[104]!==P||t[105]!==N?(U=P?null:(0,$.jsx)(`p`,{className:`mt-2 max-w-sm typography-small leading-relaxed text-muted-foreground`,children:a(N?`assistants.state.unsupportedDescription`:`assistants.state.instanceDisabledDescription`)}),t[103]=a,t[104]=P,t[105]=N,t[106]=U):U=t[106];let W;t[107]!==B||t[108]!==H||t[109]!==U?(W=(0,$.jsxs)(`section`,{className:`w-full max-w-md py-2`,children:[B,H,U]}),t[107]=B,t[108]=H,t[109]=U,t[110]=W):W=t[110];let K;t[111]!==R||t[112]!==W?(K=(0,$.jsx)(pr,{label:R,cardClassName:`oc-mobile-assistant-state-card`,children:W}),t[111]=R,t[112]=W,t[113]=K):K=t[113];let te;return t[114]!==i||t[115]!==O||t[116]!==K?(te=(0,$.jsx)(lr,{title:O,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:K}),t[114]=i,t[115]=O,t[116]=K,t[117]=te):te=t[117],te}function as(e){return e.requestCreate}function os(e){let t=(0,Q.c)(14),{assistantID:n,onBack:r}=e,{t:i}=ee(),a;t[0]===i?a=t[1]:(a=i(`assistants.title`),t[0]=i,t[1]=a);let o;t[2]===i?o=t[3]:(o=i(`settings.view.actions.back`),t[2]=i,t[3]=o);let s;t[4]!==r||t[5]!==a||t[6]!==o?(s=(0,$.jsx)(Y,{title:a,backAriaLabel:o,onBack:r}),t[4]=r,t[5]=a,t[6]=o,t[7]=s):s=t[7];let c;t[8]!==n||t[9]!==r?(c=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden px-[var(--oc-mobile-page-inline-inset)] pb-[var(--oc-safe-area-bottom,env(safe-area-inset-bottom,0px))]`,children:(0,$.jsx)(ur,{className:`oc-mobile-settings-detail-card h-full`,children:(0,$.jsx)(nn,{children:(0,$.jsx)(li,{assistantID:n,onItemDeleted:r},n)})})}),t[8]=n,t[9]=r,t[10]=c):c=t[10];let l;return t[11]!==s||t[12]!==c?(l=(0,$.jsxs)(`div`,{"data-settings-view":`true`,"data-mobile-settings-stage":`page-content`,className:`oc-settings-workspace oc-settings-workspace-mobile flex h-full min-h-0 flex-col overflow-hidden bg-background`,children:[s,c]}),t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function ss(e){let t=(0,Q.c)(13),{route:n}=e,{t:r}=ee(),i;t[0]===r?i=t[1]:(i=r(`chat.btw.title`),t[0]=r,t[1]=i);let a;t[2]===r?a=t[3]:(a=r(`header.actions.backAria`),t[2]=r,t[3]=a);let o;t[4]!==i||t[5]!==a?(o=(0,$.jsx)(Y,{title:i,backAriaLabel:a,onBack:cs}),t[4]=i,t[5]=a,t[6]=o):o=t[6];let s;t[7]!==n.directory||t[8]!==n.sessionId?(s=(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Rt,{scope:{sessionId:n.sessionId,directory:n.directory},foot:`page`})}),t[7]=n.directory,t[8]=n.sessionId,t[9]=s):s=t[9];let c;return t[10]!==o||t[11]!==s?(c=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[o,s]}),t[10]=o,t[11]=s,t[12]=c):c=t[12],c}function cs(){Hn.requestAnimatedBack(`root`)}var ls=[{id:`projects`,icon:`folder-open`,labelKey:`mobile.tabs.projects`},{id:`assistant`,icon:`sparkling`,labelKey:`mobile.tabs.assistant`},{id:`scheduled`,icon:`calendar-schedule`,labelKey:`mobile.tabs.scheduled`},{id:`settings`,icon:`settings-3`,labelKey:`mobile.tabs.settings`}];function us(e){let t=(0,Q.c)(17),{activeTab:n,onTabChange:r,className:i}=e,{t:a}=ee(),o;t[0]===r?o=t[1]:(o=e=>{r(e.currentTarget.dataset.tab)},t[0]=r,t[1]=o);let s=V(o),c;t[2]!==n||t[3]!==r?(c=e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=ls.findIndex(e=>e.id===n),i=ls[e.key===`Home`?0:e.key===`End`?ls.length-1:(t+(e.key===`ArrowRight`?1:-1)+ls.length)%ls.length];r(i.id),document.getElementById(`mobile-tab-${i.id}`)?.focus()},t[2]=n,t[3]=r,t[4]=c):c=t[4];let l=V(c),u;t[5]===a?u=t[6]:(u=a(`mobile.nav.aria`),t[5]=a,t[6]=u);let d;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d={role:`tablist`},t[7]=d):d=t[7];let f;t[8]!==n||t[9]!==s||t[10]!==l||t[11]!==a?(f=ls.map(e=>{let t=e.id===n,r=a(e.labelKey);return(0,$.jsxs)(G,{id:`mobile-tab-${e.id}`,"data-tab":e.id,type:`button`,role:`tab`,variant:`ghost`,size:`sm`,"aria-controls":`mobile-tabpanel-${e.id}`,"aria-label":r,"aria-describedby":e.id===`assistant`?`mobile-tab-assistant-unread`:void 0,"aria-selected":t,tabIndex:t?0:-1,title:r,onClick:s,onKeyDown:l,className:W(`oc-mobile-tab-button min-w-0 flex-1 flex-col overflow-visible`,`text-xs font-medium leading-none tracking-tight text-muted-foreground`,`transition-[background-color,color,box-shadow,transform] duration-100`,`hover:bg-transparent hover:text-foreground`,`active:bg-interactive-active`,`motion-reduce:transition-none`,t&&[`bg-interactive-selection/55 text-primary`,`hover:bg-interactive-selection/55 hover:text-primary`,`font-semibold`]),children:[(0,$.jsxs)(`span`,{className:`relative inline-flex shrink-0 overflow-visible`,children:[(0,$.jsx)(X,{name:e.icon,weight:`medium`,className:`size-[23px] shrink-0`}),e.id===`assistant`?(0,$.jsx)(`span`,{id:`mobile-tab-assistant-unread`,className:`pointer-events-none absolute left-full -top-1 ml-0.5 inline-flex z-10`,children:(0,$.jsx)(Ti,{className:`h-[18px] min-w-[18px] bg-foreground px-1 text-[11px] font-bold tracking-normal text-background shadow-none ring-2 ring-background`})}):null]}),(0,$.jsx)(`span`,{className:`oc-mobile-tab-label block max-w-full overflow-hidden text-ellipsis whitespace-nowrap`,children:r})]},e.id)}),t[8]=n,t[9]=s,t[10]=l,t[11]=a,t[12]=f):f=t[12];let p;return t[13]!==i||t[14]!==u||t[15]!==f?(p=(0,$.jsx)(mr,{as:`nav`,"aria-label":u,variant:`navigation`,surfaceProps:d,className:i,children:f}),t[13]=i,t[14]=u,t[15]=f,t[16]=p):p=t[16],p}var ds=`oc-native-ios-tab-bar`,fs=`OpenChamberTabBar`,ps=[`projects`,`assistant`,`scheduled`,`settings`],ms=F(fs),hs=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.nativeUiEnabled!==!1;function gs(){return typeof window>`u`?!1:hs({isCapacitor:O(),platform:A(),pluginAvailable:I.isPluginAvailable(fs),nativeUiEnabled:In()})}var _s=e=>e.classList.contains(`dark`)?`dark`:`light`,vs=()=>Fn(`--primary`),ys=e=>typeof e==`string`&&ps.includes(e),bs=e=>typeof e==`string`&&ys(e)?e:null,xs=(e,t)=>e.selectedTab===t.selectedTab&&e.appearance===t.appearance&&e.ariaLabel===t.ariaLabel&&e.accentColor===t.accentColor&&e.tabs.length===t.tabs.length&&e.tabs.every((e,n)=>e.id===t.tabs[n]?.id&&e.label===t.tabs[n]?.label&&e.badge===t.tabs[n]?.badge),Ss=(e,t)=>{e.classList.toggle(ds,t)},Cs=(e,t)=>e&&!t,ws=e=>e.visible?e.overlayHidden?{action:`present`}:e.lastState&&xs(e.lastState,e.nextState)?{action:`skip`}:{action:`present`}:e.overlayHidden?{action:`skip`}:{action:`hide`},Ts=()=>ms,Es=`mobile-overlay-root`;function Ds(e){let t=(0,Q.c)(28),n=Ln(),r;t[0]===n?r=t[1]:(r=n&&gs(),t[0]=n,t[1]=r);let i=r,[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(null),f=(0,Z.useRef)(!1),p=(0,Z.useRef)(!1),m=V(e.onTabChange),h;t[2]===e.tabs?h=t[3]:(h=JSON.stringify(e.tabs.map(ks)),t[2]=e.tabs,t[3]=h);let g=h,_;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=typeof document>`u`?`dark`:_s(document.documentElement),t[4]=_):_=t[4];let v=_,y;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=typeof document>`u`?``:vs(),t[5]=y):y=t[5];let b=y,x,S;t[6]===i?(x=t[7],S=t[8]):(x=()=>{if(!i||typeof document>`u`)return;let e=document.getElementById(Es);e||(e=document.createElement(`div`),e.id=Es,document.body.appendChild(e));let t=()=>u(Nt(e.children));t();let n=new MutationObserver(t);return n.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[Ct]}),()=>n.disconnect()},S=[i],t[6]=i,t[7]=x,t[8]=S),(0,Z.useEffect)(x,S);let C;t[9]!==i||t[10]!==m?(C=()=>{if(!i)return;let e=!1,t=Ts(),n=[];return t.addListener(`tabSelected`,e=>{let t=bs(e.tab);t&&m(t)}).then(t=>{if(e){t.remove();return}n.push(t)}),()=>{e=!0,d.current=null,t.hide();for(let e of n)e.remove();typeof document<`u`&&Ss(document.documentElement,!1)}},t[9]=i,t[10]=m,t[11]=C):C=t[11];let w;t[12]===i?w=t[13]:(w=[i],t[12]=i,t[13]=w),(0,Z.useEffect)(C,w);let T;t[14]!==e.activeTab||t[15]!==e.ariaLabel||t[16]!==e.tabs||t[17]!==e.visible||t[18]!==i||t[19]!==l?(T=()=>{if(!i||p.current)return;let t=!1,n=Ts(),r={tabs:e.tabs.map(Os),selectedTab:e.activeTab,appearance:v,accentColor:b,ariaLabel:e.ariaLabel},a=ws({visible:Cs(e.visible,l),overlayHidden:f.current,lastState:d.current,nextState:r});return(async()=>{if(a.action===`skip`)return;if(a.action===`hide`){f.current=!0,n.hide();return}let e=await n.present(r);if(!t){if(e.adopted!==!0){p.current=!0,c(!0),o(!1),typeof document<`u`&&Ss(document.documentElement,!1);return}f.current=!1,d.current=r,o(!0),typeof document<`u`&&Ss(document.documentElement,!0)}})().catch(()=>{t||(p.current=!0,c(!0),o(!1),typeof document<`u`&&Ss(document.documentElement,!1))}),()=>{t=!0}},t[14]=e.activeTab,t[15]=e.ariaLabel,t[16]=e.tabs,t[17]=e.visible,t[18]=i,t[19]=l,t[20]=T):T=t[20];let E;return t[21]!==e.activeTab||t[22]!==e.ariaLabel||t[23]!==e.visible||t[24]!==i||t[25]!==l||t[26]!==g?(E=[i,e.visible,l,e.activeTab,e.ariaLabel,v,b,g],t[21]=e.activeTab,t[22]=e.ariaLabel,t[23]=e.visible,t[24]=i,t[25]=l,t[26]=g,t[27]=E):E=t[27],(0,Z.useLayoutEffect)(T,E),!i||s?`web`:a?`native`:`pending`}function Os(e){return{id:e.id,label:e.label,badge:e.badge??null}}function ks(e){return[e.id,e.label,e.badge??null]}function As(e){let t=(0,Q.c)(40),{tabs:n,navigation:r,onTabChange:i,secondaryPages:a,showTabBar:o,tabBarCovered:s,className:c}=e,l=a===void 0?[]:a,u=o===void 0||o,d=s!==void 0&&s,{t:f}=ee(),p=r.activeTab,m=l.slice(-2),h=m.at(-1)??null,g=h?.key??null,_=h?.depth,v=m.length>1?m[m.length-2].key:null,y;t[0]===p?y=t[1]:(y=()=>new Set([p]),t[0]=p,t[1]=y);let[b,x]=Z.useState(y);b.has(p)||x(e=>{if(e.has(p))return e;let t=new Set(e);return t.add(p),t});let S=Z.useRef(null),C=Z.useRef(null),w=Z.useRef(null),T=Z.useRef(new Map),E=Z.useRef(null),D=Z.useRef(!1),O=Z.useRef(``),k=V(()=>h?.onBack());Bn({id:h?`mobile-secondary:${h.key}`:`mobile-secondary:inactive`,active:!!h,onBack:k,surfaceRef:S,underlayRef:C}),Z.useLayoutEffect(()=>{let e=g===null?null:T.current.get(g)??null,t=v===null?w.current:T.current.get(v)??null;S.current=e,C.current=t},[g,_,v]);let A;t[2]===h?A=t[3]:(A=[h],t[2]=h,t[3]=A),Z.useLayoutEffect(()=>{if(h){if(!D.current){let e=document.activeElement;E.current=e instanceof HTMLElement?e:null,D.current=!0}O.current!==h.key&&(O.current=h.key,S.current?.focus());return}if(D.current){D.current=!1,O.current=``;let e=E.current;E.current=null,e&&e.isConnected&&e.focus()}},A);let j;t[4]===i?j=t[5]:(j=e=>{i(e)},t[4]=i,t[5]=j);let M=V(j),N=le(),P;t[6]!==N||t[7]!==f?(P=ls.map(e=>({id:e.id,label:f(e.labelKey),badge:e.id===`assistant`&&N>0?N>99?`99+`:String(N):null})),t[6]=N,t[7]=f,t[8]=P):P=t[8];let F=P,I=u&&!d&&!h,L;t[9]===f?L=t[10]:(L=f(`mobile.nav.aria`),t[9]=f,t[10]=L);let R;t[11]!==M||t[12]!==I||t[13]!==F||t[14]!==p||t[15]!==L?(R={visible:I,activeTab:p,tabs:F,ariaLabel:L,onTabChange:M},t[11]=M,t[12]=I,t[13]=F,t[14]=p,t[15]=L,t[16]=R):R=t[16];let z=Ds(R),B=z===`native`,H=u&&z===`web`,U=Ln(),G,K;t[17]!==U||t[18]!==B?(G=()=>{if(!U){Un.shutdown();return}B&&Vn(!0)&&Un.warm()},K=[U,B],t[17]=U,t[18]=B,t[19]=G,t[20]=K):(G=t[19],K=t[20]),Z.useEffect(G,K);let te;t[21]===c?te=t[22]:(te=W(`oc-mobile-floating-shell relative isolate flex h-full min-h-0 flex-col overflow-hidden text-foreground`,`bg-[var(--oc-mobile-page-background)]`,c),t[21]=c,t[22]=te);let q=h?!0:void 0,ne=h?!0:void 0,re;t[23]!==p||t[24]!==u||t[25]!==H||t[26]!==f||t[27]!==n||t[28]!==b?(re=ls.map(e=>{let t=b.has(e.id);return(0,$.jsx)(`section`,{id:`mobile-tabpanel-${e.id}`,role:`tabpanel`,"aria-labelledby":H?`mobile-tab-${e.id}`:void 0,"aria-label":H?void 0:f(e.labelKey),hidden:p!==e.id,tabIndex:0,className:W(`scrollbar-none h-full min-h-0 flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--oc-mobile-page-inline-inset)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+1rem)] outline-none`,u?`pb-[calc(var(--oc-mobile-dock-height)+2.5rem+var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px)))]`:`pb-0`),children:t?n?.[e.id]??(0,$.jsx)(js,{tab:e.id,icon:e.icon}):null},e.id)}),t[23]=p,t[24]=u,t[25]=H,t[26]=f,t[27]=n,t[28]=b,t[29]=re):re=t[29];let ie;t[30]!==w||t[31]!==q||t[32]!==ne||t[33]!==re?(ie=(0,$.jsx)(`div`,{ref:w,"data-mobile-navigation-underlay":`true`,"aria-hidden":q,inert:ne,className:`flex h-full min-h-0 flex-1 flex-col`,children:re}),t[30]=w,t[31]=q,t[32]=ne,t[33]=re,t[34]=ie):ie=t[34];let ae=u?(0,$.jsx)(`div`,{"data-mobile-navigation-dock-underlay":`true`,"aria-hidden":h||B?!0:void 0,inert:h||B?!0:void 0,children:H?(0,$.jsx)(us,{activeTab:p,onTabChange:M}):null}):null,oe=m.map((e,t)=>{let n=t===m.length-1;return(0,$.jsx)(`div`,{ref:t=>{t?T.current.set(e.key,t):T.current.delete(e.key)},"data-mobile-secondary-page":`true`,"data-mobile-secondary-active":n?`true`:`false`,role:n?`dialog`:void 0,"aria-modal":n?!0:void 0,"aria-label":n?e.ariaLabel??f(`mobile.nav.secondaryPageAria`):void 0,"aria-hidden":!n||void 0,inert:!n||void 0,tabIndex:n?-1:void 0,className:W(`absolute inset-0 flex h-full min-h-0 flex-col overflow-hidden bg-background outline-none`,n?`z-50`:`z-40`),children:e.content},e.key)}),se;return t[35]!==te||t[36]!==ie||t[37]!==ae||t[38]!==oe?(se=(0,$.jsxs)(`div`,{className:te,children:[ie,ae,oe]}),t[35]=te,t[36]=ie,t[37]=ae,t[38]=oe,t[39]=se):se=t[39],se}function js(e){let t=(0,Q.c)(17),{tab:n,icon:r,className:i}=e,{t:a}=ee(),o,s,c,l;if(t[0]!==i||t[1]!==r||t[2]!==a||t[3]!==n){let e=ls.find(e=>e.id===n)??ls[0];t[8]===i?c=t[9]:(c=W(`flex min-h-[70dvh] flex-col items-center justify-center gap-3 text-center`,i),t[8]=i,t[9]=c),l=(0,$.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-2xl bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(X,{name:r??e.icon,className:`size-6`})}),o=`typography-ui-label font-semibold tracking-[-0.01em] text-foreground`,s=a(e.labelKey),t[0]=i,t[1]=r,t[2]=a,t[3]=n,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else o=t[4],s=t[5],c=t[6],l=t[7];let u;t[10]!==o||t[11]!==s?(u=(0,$.jsx)(`h1`,{className:o,children:s}),t[10]=o,t[11]=s,t[12]=u):u=t[12];let d;return t[13]!==c||t[14]!==l||t[15]!==u?(d=(0,$.jsxs)(`div`,{className:c,children:[l,u]}),t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}var Ms={neutral:void 0,info:{color:`var(--status-info)`,backgroundColor:`var(--status-info-background)`},success:{color:`var(--status-success)`,backgroundColor:`var(--status-success-background)`},warning:{color:`var(--status-warning)`,backgroundColor:`var(--status-warning-background)`},error:{color:`var(--status-error)`,backgroundColor:`var(--status-error-background)`}},Ns=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/g,``);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n.length<=1?t:n.length===2?n[0]:n.slice(-3,-1).join(`/`)};function Ps({project:e,expanded:t,embedded:n=!1,onToggle:r,onOpenActions:i,className:a,highlightQuery:o}){let{t:s}=ee(),[c,l]=Z.useState(!1),u=Z.useRef(null);u.current||=er({onPressedKeyChange:t=>l(t===e.id)}),Z.useEffect(()=>()=>u.current?.reset(),[]);let d=V(()=>{u.current?.consumeClick(e.id)||r(e)}),f=V(()=>i?.(e)),p=V(t=>{if(!i||t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0)return;let n=i;u.current?.start({pointerId:t.pointerId,key:e.id,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>{l(!1),n(e)}})}),m=V(e=>{u.current?.move(e.pointerId,e.clientX,e.clientY)}),h=V(e=>{u.current?.end(e.pointerId)}),g=V(e=>{u.current?.cancel(e.pointerId)}),_=V(t=>{if(!i)return;let n=i;t.preventDefault(),t.stopPropagation(),u.current?.openFromContextMenu(e.id,()=>{l(!1),n(e)})}),v=e.sessionCount===1?s(`mobile.sessions.project.sessionsSingle`):s(`mobile.sessions.project.sessionsPlural`,{count:e.sessionCount}),y=Ns(e.path),b=(0,$.jsxs)(`article`,{"data-mobile-press-surface":`soft`,"data-pressed":c?`true`:void 0,className:W(`oc-mobile-project-card relative flex items-stretch overflow-hidden rounded-[var(--oc-mobile-surface-radius)]`,a),children:[(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-surface-trigger":!0,className:`oc-mobile-project-trigger flex min-w-0 flex-1 items-center text-left outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-expanded":t,onClick:d,onPointerDown:p,onPointerMove:m,onPointerUp:h,onPointerCancel:g,onContextMenu:_,style:{touchAction:`pan-y`},children:[(0,$.jsx)(`span`,{className:W(`oc-mobile-project-icon oc-mobile-glass-control flex shrink-0 items-center justify-center rounded-full text-muted-foreground`),style:Ms[e.tone??`neutral`],"aria-hidden":!0,children:(0,$.jsx)(X,{name:e.icon??`code-box`,className:`oc-mobile-project-icon-glyph`})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`oc-mobile-project-title oc-mobile-entity-title truncate font-semibold text-foreground`,children:o?tn(e.name,o):e.name}),e.active?(0,$.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-[var(--status-success)] shadow-[0_0_0_3px_color-mix(in_srgb,var(--status-success)_12%,transparent)]`,"aria-label":s(`mobile.sessions.activeProjectAria`)}):null]}),(0,$.jsxs)(`span`,{className:`oc-mobile-project-meta oc-mobile-entity-meta flex min-w-0 items-center text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:v}),e.activityLabel?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`·`}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:e.activityLabel})]}):null,y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`·`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,title:e.path,children:y})]}):null]})]}),(0,$.jsx)(X,{name:`arrow-down-s`,className:W(`oc-mobile-project-chevron shrink-0 text-muted-foreground transition-transform duration-150 motion-reduce:transition-none`,t?`rotate-0`:`-rotate-90`)})]}),i?(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-mobile-project-action self-center rounded-full text-muted-foreground`,"aria-label":s(`sessions.sidebar.project.actions.projectMenu`),onClick:f,children:(0,$.jsx)(X,{name:`more-2`,className:`size-4`})}):null]});return n?b:(0,$.jsx)(ur,{asChild:!0,children:b})}var Fs=({hasPendingQuestion:e,hasPendingPermission:t,running:n,unread:r})=>e?`question`:t?`permission`:n?`running`:r?`completed-unread`:`idle`,Is=10,Ls=`oc:mobile-session-row-revealed`,Rs=e=>{window.dispatchEvent(new CustomEvent(Ls,{detail:e}))};function zs({session:e,depth:t=0,hasChildren:n=!1,expanded:r=!1,paginationContinues:i=!1,onToggleChildren:a,onSelect:o,onPin:s,onArchive:c,onOpenActions:l,indicator:u,className:d,highlightQuery:f}){let{t:p}=ee(),[m,h]=Z.useState(0),[g,_]=Z.useState(!1),v=Z.useRef(null),y=Z.useRef(!1),b=Z.useRef(null),x=Z.useRef(null);x.current||=er(),Z.useEffect(()=>()=>x.current?.reset(),[]),Z.useEffect(()=>{let t=t=>{t.detail!==e.id&&h(0)};return window.addEventListener(Ls,t),()=>window.removeEventListener(Ls,t)},[e.id]),Z.useEffect(()=>{h(0)},[e.id]);let S=V(()=>h(0)),C=m!==0,w=V(t=>{if(t.button!==0||t.pointerType!==`touch`&&t.pointerType!==`pen`)return;let n=b.current?.offsetWidth??0;n<=0||(v.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startOffset:m,actionWidth:n,intent:`pending`},y.current=!1,x.current?.start({pointerId:t.pointerId,key:e.id,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>{l(e)}}))}),T=V(t=>{let n=v.current;if(!n||n.pointerId!==t.pointerId)return;let r=t.clientX-n.startX,i=t.clientY-n.startY;if(x.current?.move(t.pointerId,t.clientX,t.clientY),n.intent===`pending`){let a=Math.abs(r),o=Math.abs(i);if(o>Is&&o>a){n.intent=`vertical`,v.current=null,x.current?.cancel(t.pointerId);return}if(a>Is&&a>o){n.intent=`horizontal`,_(!0),y.current=!0,x.current?.cancel(t.pointerId);try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}Rs(e.id)}}if(n.intent!==`horizontal`)return;t.preventDefault();let a=Math.max(-n.actionWidth,Math.min(0,n.startOffset+r));h(a)}),E=V(e=>{let t=v.current;x.current?.end(e.pointerId),!(!t||t.pointerId!==e.pointerId)&&(v.current=null,t.intent===`horizontal`&&(_(!1),h(e=>e<-(t.actionWidth*.35)?-t.actionWidth:0)))}),D=V(e=>{let t=v.current;v.current=null,x.current?.cancel(e.pointerId),_(!1),h(t?.startOffset??0)}),O=V(()=>{if(!x.current?.consumeClick(e.id)){if(y.current){y.current=!1;return}if(m!==0){S();return}Rs(e.id),o(e)}}),k=V(t=>{t.preventDefault(),t.stopPropagation(),x.current?.openFromContextMenu(e.id,()=>{l(e)})}),A=V(()=>{S(),s(e)}),j=V(()=>{S(),c(e)}),M=V(()=>l(e)),N=V(()=>a?.()),P=e.pinned?p(`sessions.sidebar.session.menu.unpin`):p(`sessions.sidebar.session.menu.pin`),F=u??Fs({hasPendingQuestion:!1,hasPendingPermission:!1,running:!1,unread:!!e.unread}),I=F===`question`?p(`sessions.sidebar.session.status.questionRequired`):F===`permission`?p(`sessions.sidebar.session.status.permissionRequired`):F===`running`?p(`sessions.sidebar.session.status.active`):F===`completed-unread`?p(`sessions.sidebar.session.status.unread`):void 0;return e.kind===`pagination`?(0,$.jsx)(`div`,{className:W(`oc-mobile-session-row`,i&&`oc-mobile-session-pagination-continues`,d),children:(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-session-pagination-row`,style:{touchAction:`pan-y`},onClick:O,onPointerDown:()=>void 0,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left font-medium text-foreground typography-meta`,children:e.title}),e.subtitle?(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.subtitle}):null,(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground`})]})}):(0,$.jsxs)(`div`,{className:W(`oc-mobile-session-row relative isolate`,d),children:[(0,$.jsxs)(`div`,{ref:b,className:W(`oc-mobile-session-actions absolute inset-y-0 right-0 z-0 flex items-stretch`,g?`transition-none`:`transition-transform duration-150 ease-out`,!C&&`invisible pointer-events-none`),style:{transform:`translate3d(calc(var(--oc-mobile-session-actions-width) + ${m}px), 0, 0)`,willChange:m===0?void 0:`transform`},"aria-hidden":!C,children:[(0,$.jsxs)(G,{type:`button`,variant:`secondary`,className:`oc-mobile-session-action h-full flex-col rounded-none border-0 bg-interactive-selection px-1 text-interactive-selection-foreground hover:bg-interactive-active`,"aria-label":P,tabIndex:C?0:-1,onClick:A,children:[(0,$.jsx)(X,{name:e.pinned?`unpin`:`pushpin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:P})]}),(0,$.jsxs)(G,{type:`button`,variant:`destructive`,className:`oc-mobile-session-action h-full flex-col rounded-none border-0 px-1`,"aria-label":p(`sessions.sidebar.bulkActions.archive`),tabIndex:C?0:-1,onClick:j,children:[(0,$.jsx)(X,{name:`archive`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:p(`sessions.sidebar.bulkActions.archive`)})]})]}),(0,$.jsxs)(`div`,{className:W(`oc-mobile-session-row-content relative z-10 flex items-center`,`text-foreground`,`ease-out motion-reduce:transition-none`,g?`transition-none`:`transition-[transform,background-color] duration-150`,e.archived&&`opacity-55`),"data-dragging":g?`true`:void 0,style:{transform:`translate3d(${m}px, 0, 0)`,willChange:m===0?void 0:`transform`},children:[n&&a?(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,className:`min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":p(r?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:N,children:(0,$.jsx)(X,{name:`arrow-down-s`,className:W(`size-3.5 transition-transform duration-150 motion-reduce:transition-none`,r?`rotate-0`:`-rotate-90`)})}):null,(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-session-row-main flex min-w-0 flex-1 items-center text-left outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,style:{paddingLeft:16+Math.min(t,4)*12,touchAction:`pan-y`},onClick:O,onPointerDown:w,onPointerMove:T,onPointerUp:E,onPointerCancel:D,onContextMenu:k,children:[(0,$.jsx)(`span`,{className:`oc-mobile-session-status shrink-0`,"data-session-status":F,"aria-hidden":!I||void 0,"aria-label":I,title:I,children:F===`running`?(0,$.jsx)(vr,{className:`motion-reduce:[&_svg]:animate-none`}):F===`question`?(0,$.jsx)(X,{name:`question`,className:`size-3.5 text-[var(--status-warning)]`}):F===`permission`?(0,$.jsx)(X,{name:`shield`,className:`size-3.5 text-destructive`}):(0,$.jsx)(`span`,{className:W(`oc-mobile-session-dot rounded-full`,F===`completed-unread`?`bg-[var(--status-info)]`:`bg-muted-foreground/35`)})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:W(`oc-mobile-session-title truncate`,e.unread?`font-semibold`:`font-medium`),children:f?tn(e.title,f):e.title}),e.changes?(0,$.jsx)(`span`,{className:`oc-mobile-session-changes shrink-0 tabular-nums text-muted-foreground`,children:e.changes}):null,e.archived?(0,$.jsx)(X,{name:`archive`,className:`size-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}):null]}),e.subtitle?(0,$.jsx)(`span`,{className:`oc-mobile-session-subtitle truncate text-muted-foreground`,children:f?tn(e.subtitle,f):e.subtitle}):null]}),(0,$.jsx)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-muted-foreground`,children:e.activityLabel?(0,$.jsx)(`span`,{className:`oc-mobile-session-time tabular-nums`,children:e.activityLabel}):null})]}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,className:`mr-1 min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":p(`sessions.sidebar.session.menu.label`),onClick:M,children:(0,$.jsx)(X,{name:`more-2`,className:`size-3.5`})})]})]})}var Bs=Z.memo(zs),Vs=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e)),Hs=e=>e.catalogSessions??e.sessions,Us=(e,t)=>e.filter(e=>e.kind!==`pagination`&&Vs(t,e.title,e.subtitle,e.id)),Ws=(e,t)=>{let n=Hs(e);if(Vs(t,e.name,e.path))return{...e,sessions:n.filter(e=>e.kind!==`pagination`)};let r=Us(n,t);return r.length>0?{...e,sessions:r}:null},Gs=(e,t)=>{let n=t.trim().toLowerCase();return n?e.flatMap(e=>{if(Vs(n,e.name,e.path))return[{...e,worktrees:[]}];let t=e.worktrees.flatMap(e=>{let t=Ws(e,n);return t?[t]:[]});return t.length>0?[{...e,worktrees:t}]:[]}):e},Ks=10,qs=`oc:mobile-worktree-row-revealed`,Js=e=>{window.dispatchEvent(new CustomEvent(qs,{detail:e}))};function Ys(e){let t=(0,Q.c)(10),n=Ae(e.session.id),r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={bootstrap:!1},t[0]=r):r=t[0];let i=Xe(e.session.id,e.session.directory,r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a={bootstrap:!1},t[1]=a):a=t[1];let o=Be(e.session.id,e.session.directory,a).length>0,s=i.length>0,c=n?.type===`busy`||n?.type===`retry`,l=!!e.session.unread,u;t[2]!==o||t[3]!==s||t[4]!==c||t[5]!==l?(u=Fs({hasPendingQuestion:o,hasPendingPermission:s,running:c,unread:l}),t[2]=o,t[3]=s,t[4]=c,t[5]=l,t[6]=u):u=t[6];let d=u,f;return t[7]!==d||t[8]!==e?(f=(0,$.jsx)(Bs,{...e,indicator:d}),t[7]=d,t[8]=e,t[9]=f):f=t[9],f}var Xs=Z.memo(Ys);function Zs(e){let t=(0,Q.c)(9),{sessions:n,onSelectSession:r,onPinSession:i,onArchiveSession:a,onOpenSessionActions:o,highlightQuery:s}=e,c;t[0]!==s||t[1]!==a||t[2]!==o||t[3]!==i||t[4]!==r||t[5]!==n?(c=n.map((e,t)=>{let c=e.kind===`pagination`&&n[t+1]?.kind===`pagination`,l=e.kind===`pagination`?Bs:Xs;return(0,$.jsx)(l,{session:e,paginationContinues:c,highlightQuery:s,onSelect:r,onPin:i,onArchive:a,onOpenActions:o},e.id)}),t[0]=s,t[1]=a,t[2]=o,t[3]=i,t[4]=r,t[5]=n,t[6]=c):c=t[6];let l;return t[7]===c?l=t[8]:(l=(0,$.jsx)($.Fragment,{children:c}),t[7]=c,t[8]=l),l}var Qs=Z.memo(Zs);function $s({project:e,worktree:t,expanded:n,onToggle:r,onNewSession:i,onOpenActions:a,onDelete:o,highlightQuery:s}){let{t:c}=ee(),l=`${e.id}::${t.id}`,u=!!(i||o),d=!!a,f=Number(!!i)+Number(!!o),[p,m]=Z.useState(0),[h,g]=Z.useState(!1),[_,v]=Z.useState(!1),y=Z.useRef(null),b=Z.useRef(!1),x=Z.useRef(null),S=Z.useRef(null);S.current||=er({onPressedKeyChange:e=>g(e===l)}),Z.useEffect(()=>()=>S.current?.reset(),[]),Z.useEffect(()=>{let e=e=>{e.detail!==l&&m(0)};return window.addEventListener(qs,e),()=>window.removeEventListener(qs,e)},[l]),Z.useEffect(()=>{m(0)},[l]);let C=V(()=>m(0)),w=p!==0,T=V(n=>{if(n.button===0&&(n.pointerType===`touch`||n.pointerType===`pen`)){if(u){let e=x.current?.offsetWidth??0;e>0&&(y.current={pointerId:n.pointerId,startX:n.clientX,startY:n.clientY,startOffset:p,actionWidth:e,intent:`pending`},b.current=!1)}d&&S.current?.start({pointerId:n.pointerId,key:l,clientX:n.clientX,clientY:n.clientY,onTrigger:()=>{g(!1),a?.(e,t)}})}}),E=V(e=>{let t=y.current;if(!t||t.pointerId!==e.pointerId){S.current?.move(e.pointerId,e.clientX,e.clientY);return}let n=e.clientX-t.startX,r=e.clientY-t.startY;if(S.current?.move(e.pointerId,e.clientX,e.clientY),t.intent===`pending`){let i=Math.abs(n),a=Math.abs(r);if(a>Ks&&a>i){t.intent=`vertical`,y.current=null,S.current?.cancel(e.pointerId);return}if(i>Ks&&i>a){t.intent=`horizontal`,v(!0),b.current=!0,S.current?.cancel(e.pointerId);try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}Js(l)}}if(t.intent!==`horizontal`)return;e.preventDefault();let i=Math.max(-t.actionWidth,Math.min(0,t.startOffset+n));m(i)}),D=V(e=>{let t=y.current;S.current?.end(e.pointerId),!(!t||t.pointerId!==e.pointerId)&&(y.current=null,t.intent===`horizontal`&&(v(!1),m(e=>e<-(t.actionWidth*.35)?-t.actionWidth:0)))}),O=V(e=>{let t=y.current;y.current=null,S.current?.cancel(e.pointerId),v(!1),m(t?.startOffset??0)}),k=V(()=>{if(!S.current?.consumeClick(l)){if(b.current){b.current=!1;return}if(p!==0){C();return}r()}}),A=V(n=>{d&&(n.preventDefault(),n.stopPropagation(),S.current?.openFromContextMenu(l,()=>{g(!1),a?.(e,t)}))}),j=V(()=>{C(),i?.(e,t)}),M=V(()=>{C(),o?.(e,t)}),N=V(()=>a?.(e,t)),P=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`oc-mobile-group-label-icon`,"aria-hidden":!0,children:(0,$.jsx)(X,{name:`git-branch`,className:`size-3.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left oc-mobile-entity-title font-semibold text-foreground`,children:s?tn(t.name,s):t.name}),(0,$.jsx)(`span`,{className:`typography-small text-muted-foreground tabular-nums`,children:t.sessionCount===1?c(`mobile.sessions.project.sessionsSingle`):c(`mobile.sessions.project.sessionsPlural`,{count:t.sessionCount})}),(0,$.jsx)(X,{name:`arrow-down-s`,className:W(`size-3.5 text-muted-foreground transition-transform duration-150 motion-reduce:transition-none`,n?`rotate-0`:`-rotate-90`)})]});return(0,$.jsxs)(`div`,{className:`oc-mobile-group-label oc-mobile-worktree-label relative isolate overflow-hidden`,children:[u?(0,$.jsxs)(`div`,{ref:x,className:W(`oc-mobile-worktree-actions absolute inset-y-0 right-0 z-0 flex items-stretch`,_?`transition-none`:`transition-transform duration-150 ease-out`,!w&&`invisible pointer-events-none`),style:{width:`calc(${f} * var(--oc-mobile-worktree-action-width))`,transform:`translate3d(calc(100% + ${p}px), 0, 0)`,willChange:p===0?void 0:`transform`},"aria-hidden":!w,children:[i?(0,$.jsxs)(G,{type:`button`,variant:`secondary`,className:`oc-mobile-worktree-action h-full flex-col rounded-none border-0 bg-interactive-selection px-1 text-interactive-selection-foreground hover:bg-interactive-active`,"aria-label":c(`mobile.sessions.newSessionAria`),tabIndex:w?0:-1,onClick:j,children:[(0,$.jsx)(X,{name:`add`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:c(`sessions.sidebar.project.actions.newSession`)})]}):null,o?(0,$.jsxs)(G,{type:`button`,variant:`destructive`,className:`oc-mobile-worktree-action h-full flex-col rounded-none border-0 px-1`,"aria-label":c(`mobile.projectEdit.deleteWorktreeAria`,{label:t.name}),tabIndex:w?0:-1,onClick:M,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:c(`mobile.projectEdit.deleteWorktreeConfirmButton`)})]}):null]}):null,(0,$.jsxs)(`div`,{className:W(`oc-mobile-worktree-label-content relative z-10 flex min-w-0 flex-1 items-center`,`ease-out motion-reduce:transition-none`,_?`transition-none`:`transition-transform duration-150`),style:{transform:`translate3d(${p}px, 0, 0)`,willChange:p===0?void 0:`transform`},"data-pressed":h?`true`:void 0,children:[(0,$.jsx)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-group-label-trigger oc-mobile-worktree-label-trigger`,"aria-expanded":n,onClick:k,onPointerDown:T,onPointerMove:E,onPointerUp:D,onPointerCancel:O,onContextMenu:A,style:{touchAction:`pan-y`},children:P}),d?(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-mobile-worktree-more rounded-full text-muted-foreground`,"aria-label":c(`agentManager.detail.actions.worktreeActionsAria`),onClick:N,children:(0,$.jsx)(X,{name:`more-2`,className:`size-3.5`})}):null]})]})}function ec(e){let t=(0,Q.c)(132),{projects:n,pinnedSessions:r,inProgressSessions:i,onAddProject:a,onNewSession:o,onScanQr:s,onSwitchInstance:c,onToggleProject:l,onOpenProjectActions:u,onToggleWorktree:d,onNewWorktreeSession:f,onOpenWorktreeActions:p,onDeleteWorktree:m,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v,className:y}=e,b;t[0]===i?b=t[1]:(b=i===void 0?[]:i,t[0]=i,t[1]=b);let x=b,{t:S}=ee(),[C,w]=Z.useState(!0),[T,E]=Z.useState(!1),[D,O]=Z.useState(!1),[k,A]=Z.useState(``),j;t[2]===k?j=t[3]:(j=k.trim().toLowerCase(),t[2]=k,t[3]=j);let M=j,N=M.length>0,P;t[4]!==M||t[5]!==n?(P=Gs(n,M),t[4]=M,t[5]=n,t[6]=P):P=t[6];let F=P,I=V(a),L=V(o),R;t[7]===s?R=t[8]:(R=()=>s?.(),t[7]=s,t[8]=R);let z=V(R),B;t[9]===c?B=t[10]:(B=()=>c?.(),t[9]=c,t[10]=B);let H=V(B),U;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(U=e=>O(e),t[11]=U):U=t[11];let K=V(U),te;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(te=()=>{A(``),E(!1)},t[12]=te):te=t[12];let q=V(te),ne;t[13]!==q||t[14]!==T?(ne=()=>{if(T){q();return}E(!0)},t[13]=q,t[14]=T,t[15]=ne):ne=t[15];let re=V(ne),ie;t[16]!==q||t[17]!==l?(ie=e=>{q(),e.expanded||l(e)},t[16]=q,t[17]=l,t[18]=ie):ie=t[18];let ae=V(ie),oe;t[19]!==q||t[20]!==l||t[21]!==d?(oe=(e,t)=>{q(),e.expanded||l(e),t.expanded||d(e,t)},t[19]=q,t[20]=l,t[21]=d,t[22]=oe):oe=t[22];let se=V(oe),J;t[23]!==q||t[24]!==h?(J=e=>{q(),h(e)},t[23]=q,t[24]=h,t[25]=J):J=t[25];let ce=V(J),le;t[26]===y?le=t[27]:(le=W(`relative isolate mx-auto flex w-full max-w-[26rem] flex-col gap-5`,y),t[26]=y,t[27]=le);let ue;t[28]===S?ue=t[29]:(ue=S(`mobile.sessions.section.projects`),t[28]=S,t[29]=ue);let Y;t[30]!==T||t[31]!==S?(Y=S(T?`mobile.sessions.clearSearchAria`:`mobile.sessions.searchAria`),t[30]=T,t[31]=S,t[32]=Y):Y=t[32];let de=T?`close`:`search`,fe;t[33]===de?fe=t[34]:(fe=(0,$.jsx)(X,{name:de,className:`size-5`}),t[33]=de,t[34]=fe);let pe;t[35]!==re||t[36]!==T||t[37]!==Y||t[38]!==fe?(pe=(0,$.jsx)(G,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":Y,"aria-expanded":T,onClick:re,children:fe}),t[35]=re,t[36]=T,t[37]=Y,t[38]=fe,t[39]=pe):pe=t[39];let me;t[40]===S?me=t[41]:(me=S(`mobile.projects.menu.label`),t[40]=S,t[41]=me);let he=D?`rotate-45`:`rotate-0`,ge;t[42]===he?ge=t[43]:(ge=W(`size-5 transition-transform duration-150 motion-reduce:transition-none`,he),t[42]=he,t[43]=ge);let _e;t[44]===ge?_e=t[45]:(_e=(0,$.jsx)(X,{name:`add`,className:ge}),t[44]=ge,t[45]=_e);let ve;t[46]!==me||t[47]!==_e?(ve=(0,$.jsx)(an,{asChild:!0,children:(0,$.jsx)(G,{type:`button`,size:`mobileIcon`,className:`oc-mobile-round-control border-transparent bg-[var(--primary-base)] text-[var(--primary-foreground)] shadow-[0_10px_22px_color-mix(in_srgb,var(--primary-base)_22%,transparent)] hover:bg-[var(--primary-hover)] dark:bg-[var(--primary-base)] dark:hover:bg-[var(--primary-hover)]`,"aria-label":me,children:_e})}),t[46]=me,t[47]=_e,t[48]=ve):ve=t[48];let ye;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,$.jsx)(X,{name:`chat-new`,className:`size-4`}),t[49]=ye):ye=t[49];let be;t[50]===S?be=t[51]:(be=S(`mobile.projects.menu.newChat`),t[50]=S,t[51]=be);let xe;t[52]!==L||t[53]!==be?(xe=(0,$.jsxs)(Xt,{className:`min-h-11`,onSelect:L,children:[ye,be]}),t[52]=L,t[53]=be,t[54]=xe):xe=t[54];let Se;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,$.jsx)(X,{name:`folder`,className:`size-4`}),t[55]=Se):Se=t[55];let Ce;t[56]===S?Ce=t[57]:(Ce=S(`mobile.projects.menu.newProject`),t[56]=S,t[57]=Ce);let we;t[58]!==I||t[59]!==Ce?(we=(0,$.jsxs)(Xt,{className:`min-h-11`,onSelect:I,children:[Se,Ce]}),t[58]=I,t[59]=Ce,t[60]=we):we=t[60];let Te;t[61]!==z||t[62]!==s||t[63]!==S?(Te=s?(0,$.jsxs)(Xt,{className:`min-h-11`,onSelect:z,children:[(0,$.jsx)(X,{name:`scan-2`,className:`size-4`}),S(`mobile.projects.menu.scanQr`)]}):null,t[61]=z,t[62]=s,t[63]=S,t[64]=Te):Te=t[64];let Ee;t[65]!==H||t[66]!==c||t[67]!==S?(Ee=c?(0,$.jsxs)(Xt,{className:`min-h-11`,onSelect:H,children:[(0,$.jsx)(X,{name:`server`,className:`size-4`}),S(`mobile.projects.menu.switchInstance`)]}):null,t[65]=H,t[66]=c,t[67]=S,t[68]=Ee):Ee=t[68];let De;t[69]!==xe||t[70]!==we||t[71]!==Te||t[72]!==Ee?(De=(0,$.jsxs)($t,{align:`end`,side:`bottom`,className:`min-w-44`,children:[xe,we,Te,Ee]}),t[69]=xe,t[70]=we,t[71]=Te,t[72]=Ee,t[73]=De):De=t[73];let Oe;t[74]!==K||t[75]!==D||t[76]!==ve||t[77]!==De?(Oe=(0,$.jsxs)(Qt,{open:D,onOpenChange:K,children:[ve,De]}),t[74]=K,t[75]=D,t[76]=ve,t[77]=De,t[78]=Oe):Oe=t[78];let ke;t[79]!==pe||t[80]!==Oe?(ke=(0,$.jsxs)($.Fragment,{children:[pe,Oe]}),t[79]=pe,t[80]=Oe,t[81]=ke):ke=t[81];let Ae;t[82]!==ue||t[83]!==ke?(Ae=(0,$.jsx)(or,{title:ue,trailing:ke}),t[82]=ue,t[83]=ke,t[84]=Ae):Ae=t[84];let je;t[85]!==q||t[86]!==T||t[87]!==k||t[88]!==S?(je=T?(0,$.jsxs)(`div`,{className:`relative mx-1`,role:`search`,children:[(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 z-10 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(Kt,{autoFocus:!0,type:`text`,inputMode:`search`,enterKeyHint:`search`,value:k,placeholder:S(`mobile.sessions.search.placeholder`),"aria-label":S(`mobile.sessions.searchAria`),className:W(`h-11 rounded-full pl-9`,k&&`pr-10`),onChange:e=>A(e.target.value),onKeyDown:e=>{e.key===`Escape`&&q()}}),k?(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute right-1.5 top-1/2 size-8 -translate-y-1/2 rounded-full text-muted-foreground`,"aria-label":S(`mobile.sessions.clearSearchAria`),onClick:()=>A(``),children:(0,$.jsx)(X,{name:`close`,className:`size-4`})}):null]}):null,t[85]=q,t[86]=T,t[87]=k,t[88]=S,t[89]=je):je=t[89];let Me;t[90]!==x||t[91]!==_||t[92]!==v||t[93]!==g||t[94]!==h||t[95]!==C||t[96]!==r||t[97]!==N||t[98]!==S?(Me=!N&&(r.length>0||x.length>0)?(0,$.jsx)(ur,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":S(`mobile.sessions.section.pinned`),children:[(0,$.jsx)(Ps,{project:{id:`__pinned__`,name:S(`mobile.sessions.section.pinned`),path:``,icon:`pushpin`,sessionCount:r.length+x.length},expanded:C,embedded:!0,onToggle:()=>w(nc)}),C?(0,$.jsxs)(`div`,{className:`oc-mobile-project-groups`,role:`group`,children:[r.length>0?(0,$.jsx)(`div`,{className:`oc-mobile-labeled-surface-group`,children:(0,$.jsx)(Qs,{sessions:r,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null,x.length>0?(0,$.jsx)(`div`,{className:`oc-mobile-labeled-surface-group`,children:(0,$.jsx)(Qs,{sessions:x,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null]}):null]})}):null,t[90]=x,t[91]=_,t[92]=v,t[93]=g,t[94]=h,t[95]=C,t[96]=r,t[97]=N,t[98]=S,t[99]=Me):Me=t[99];let Ne;t[100]!==I||t[101]!==ae||t[102]!==se||t[103]!==ce||t[104]!==M||t[105]!==_||t[106]!==m||t[107]!==f||t[108]!==u||t[109]!==v||t[110]!==p||t[111]!==g||t[112]!==h||t[113]!==l||t[114]!==d||t[115]!==n.length||t[116]!==N||t[117]!==S||t[118]!==F?(Ne=n.length===0?(0,$.jsxs)(`section`,{className:`flex min-h-[52dvh] flex-col items-center justify-center px-6 text-center`,children:[(0,$.jsx)(`span`,{className:`mb-4 flex size-14 items-center justify-center rounded-2xl bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(X,{name:`folder-add`,className:`size-6`})}),(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:S(`mobile.sessions.empty.noProjectsTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-xs typography-small text-muted-foreground`,children:S(`mobile.sessions.empty.noProjectsDescription`)}),(0,$.jsxs)(G,{type:`button`,size:`lg`,className:`mt-4 min-h-10 rounded-full px-5`,onClick:I,children:[(0,$.jsx)(X,{name:`folder-add`,className:`size-4`}),S(`sessions.sidebar.header.actions.addProject`)]})]}):N&&F.length===0?(0,$.jsxs)(`section`,{className:`flex min-h-[40dvh] flex-col items-center justify-center px-6 text-center`,children:[(0,$.jsx)(X,{name:`search`,className:`mb-4 size-6 text-muted-foreground`}),(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:S(`mobile.sessions.empty.searchTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-xs typography-small text-muted-foreground`,children:S(`mobile.sessions.empty.searchDescription`)})]}):F.map(e=>{let t=N||e.expanded,n=e.worktrees.find(tc)??(e.worktrees.length===1&&!e.worktrees[0]?.kind?e.worktrees[0]:void 0),r=e.worktrees.filter(e=>e!==n),i=n?.sessions??[];return(0,$.jsx)(ur,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":e.name,children:[(0,$.jsx)(Ps,{project:e,expanded:t,embedded:!0,highlightQuery:N?M:void 0,onToggle:()=>N?ae(e):l(e),onOpenActions:()=>u(e)}),t?(0,$.jsxs)(`div`,{className:`oc-mobile-project-groups`,role:`group`,"aria-label":e.name,children:[i.length>0?(0,$.jsx)(`div`,{className:`oc-mobile-labeled-surface-group`,children:(0,$.jsx)(Qs,{sessions:i,highlightQuery:N?M:void 0,onSelectSession:N?ce:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null,r.map(t=>{let n=N||!!t.expanded;return(0,$.jsx)(pr,{className:`oc-mobile-worktree-group`,ariaLabel:t.name,label:(0,$.jsx)($s,{project:e,worktree:t,expanded:n,highlightQuery:N?M:void 0,onToggle:()=>N?se(e,t):d(e,t),onNewSession:f,onOpenActions:N?void 0:p,onDelete:N?void 0:m}),children:n&&t.sessions.length>0?(0,$.jsx)(Qs,{sessions:t.sessions,highlightQuery:N?M:void 0,onSelectSession:N?ce:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v}):null},t.id)})]}):null]})},e.id)}),t[100]=I,t[101]=ae,t[102]=se,t[103]=ce,t[104]=M,t[105]=_,t[106]=m,t[107]=f,t[108]=u,t[109]=v,t[110]=p,t[111]=g,t[112]=h,t[113]=l,t[114]=d,t[115]=n.length,t[116]=N,t[117]=S,t[118]=F,t[119]=Ne):Ne=t[119];let Pe;t[120]===S?Pe=t[121]:(Pe=S(`sessions.sidebar.header.actions.addProject`),t[120]=S,t[121]=Pe);let Fe;t[122]!==I||t[123]!==Pe?(Fe=(0,$.jsx)(`button`,{type:`button`,className:`sr-only`,onClick:I,children:Pe}),t[122]=I,t[123]=Pe,t[124]=Fe):Fe=t[124];let Ie;return t[125]!==le||t[126]!==Ae||t[127]!==je||t[128]!==Me||t[129]!==Ne||t[130]!==Fe?(Ie=(0,$.jsxs)(`main`,{className:le,children:[Ae,je,Me,Ne,Fe]}),t[125]=le,t[126]=Ae,t[127]=je,t[128]=Me,t[129]=Ne,t[130]=Fe,t[131]=Ie):Ie=t[131],Ie}function tc(e){return e.kind===`main`}function nc(e){return!e}function rc(e){let t=(0,Q.c)(13),{icon:n,label:r,onClick:i,destructive:a,disabled:o,spinning:s}=e,c=a!==void 0&&a,l=o!==void 0&&o,u=s!==void 0&&s,d;t[0]===i?d=t[1]:(d=()=>{_e(`light`),i()},t[0]=i,t[1]=d);let f=V(d),p=c?`destructive`:`ghost`,m=u?`size-5 animate-spin`:`size-5`,h;t[2]!==n||t[3]!==m?(h=(0,$.jsx)(X,{name:n,className:m}),t[2]=n,t[3]=m,t[4]=h):h=t[4];let g;t[5]===r?g=t[6]:(g=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[5]=r,t[6]=g);let _;return t[7]!==l||t[8]!==f||t[9]!==p||t[10]!==h||t[11]!==g?(_=(0,$.jsxs)(G,{type:`button`,variant:p,size:`lg`,className:`h-auto min-h-14 w-full justify-start gap-3 rounded-none supports-[corner-shape:squircle]:rounded-none px-4 leading-6 border-b border-[var(--surface-subtle)] last:border-b-0 active:bg-interactive-active dark:active:bg-interactive-active`,"data-mobile-press-feedback":`none`,disabled:l,onClick:f,children:[h,g]}),t[7]=l,t[8]=f,t[9]=p,t[10]=h,t[11]=g,t[12]=_):_=t[12],_}function ic(e,t,n){return e.reduce((e,t)=>{let n=!!t.separated,r=e.at(-1);return r?.separated===n?r.items.push(t):e.push({separated:n,items:[t]}),e},[]).map(e=>(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl bg-[var(--surface-muted)]`,"data-mobile-action-group":e.separated?`separated`:`standard`,children:e.items.map(e=>(0,$.jsx)(rc,{icon:e.icon,label:Dr(e,t),onClick:n(e.onClick),destructive:e.destructive,disabled:e.disabled,spinning:e.spinning},e.id))},e.items[0]?.id))}function ac(e){let t=(0,Q.c)(46),{open:n,target:r,actions:i,onOpenChange:a,refreshTranscriptDisabled:o,refreshTranscriptSpinning:s}=e,c=o!==void 0&&o,l=s!==void 0&&s,{t:u}=ee(),d;t[0]===a?d=t[1]:(d=e=>()=>{a(!1),e?.()},t[0]=a,t[1]=d);let f=d,p;bb0:{if(!r){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[2]=e):e=t[2],p=e;break bb0}if(r.kind===`session`){let e;t[3]!==i.onArchive||t[4]!==i.onCopyLink||t[5]!==i.onDelete||t[6]!==i.onRefreshTranscript||t[7]!==i.onRename||t[8]!==i.onShare||t[9]!==i.onTogglePin||t[10]!==i.onUnshare||t[11]!==c||t[12]!==l||t[13]!==r.pinned||t[14]!==r.shared?(e=Ir({pinned:r.pinned,shared:r.shared,onRename:i.onRename,onTogglePin:i.onTogglePin,onShare:i.onShare,onCopyLink:i.onCopyLink,onUnshare:i.onUnshare,onRefreshTranscript:i.onRefreshTranscript,onArchive:i.onArchive,onDelete:i.onDelete,refreshTranscriptDisabled:c,refreshTranscriptSpinning:l}),t[3]=i.onArchive,t[4]=i.onCopyLink,t[5]=i.onDelete,t[6]=i.onRefreshTranscript,t[7]=i.onRename,t[8]=i.onShare,t[9]=i.onTogglePin,t[10]=i.onUnshare,t[11]=c,t[12]=l,t[13]=r.pinned,t[14]=r.shared,t[15]=e):e=t[15],p=e;break bb0}if(r.kind===`project`){let e;t[16]!==i.onCloseProject||t[17]!==i.onEditProject||t[18]!==i.onNewSession||t[19]!==i.onNewWorktree||t[20]!==i.onSyncSessions||t[21]!==r.gitRepository?(e=ii({gitRepository:r.gitRepository,onNewSession:i.onNewSession,onNewWorktree:i.onNewWorktree,onSyncSessions:i.onSyncSessions,onEditProject:i.onEditProject,onCloseProject:i.onCloseProject}),t[16]=i.onCloseProject,t[17]=i.onEditProject,t[18]=i.onNewSession,t[19]=i.onNewWorktree,t[20]=i.onSyncSessions,t[21]=r.gitRepository,t[22]=e):e=t[22],p=e;break bb0}let e;t[23]!==i.onDeleteWorktree||t[24]!==i.onNewSession?(e=ri({onNewSession:i.onNewSession,onDeleteWorktree:i.onDeleteWorktree}),t[23]=i.onDeleteWorktree,t[24]=i.onNewSession,t[25]=e):e=t[25],p=e}let m=p;if(!r)return null;let h;t[26]===r.title?h=t[27]:(h=(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold`,children:r.title}),t[26]=r.title,t[27]=h);let g=r.title,_;t[28]===u?_=t[29]:(_=u(`mobile.surface.closeAria`),t[28]=u,t[29]=_);let v;t[30]===u?v=t[31]:(v=u(`mobile.sessions.sheet.resizeAria`),t[30]=u,t[31]=v);let y;t[32]!==m||t[33]!==f||t[34]!==u?(y=ic(m,u,f),t[32]=m,t[33]=f,t[34]=u,t[35]=y):y=t[35];let b;t[36]===y?b=t[37]:(b=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-y-auto overscroll-contain px-3 pb-3`,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-5`,"data-page-scroll-lock":`true`,children:y})}),t[36]=y,t[37]=b);let x;return t[38]!==a||t[39]!==n||t[40]!==b||t[41]!==h||t[42]!==_||t[43]!==v||t[44]!==r.title?(x=(0,$.jsx)(yn,{id:`mobile-row-actions-sheet`,open:n,onOpenChange:a,title:h,ariaLabel:g,closeAriaLabel:_,resizeAriaLabel:v,fitContent:!0,children:b}),t[38]=a,t[39]=n,t[40]=b,t[41]=h,t[42]=_,t[43]=v,t[44]=r.title,t[45]=x):x=t[45],x}function oc(e,t){return e&&e.id===t.id&&e.kind===t.kind&&e.title===t.title&&e.subtitle===t.subtitle&&e.changes===t.changes&&e.activityLabel===t.activityLabel&&e.unread===t.unread&&e.pinned===t.pinned&&e.archived===t.archived&&e.active===t.active&&e.directory===t.directory&&e.expanded===t.expanded&&e.children===t.children?e:t}function sc(e,t){if(!e||e.length===0)return t.slice();let n=new Map(e.map(e=>[e.id,e])),r=e.length===t.length,i=t.map((t,i)=>{let a=oc(n.get(t.id)??e[i],t);return a!==e[i]&&(r=!1),a});if(r){let t=!0;for(let n=0;n<i.length;n+=1)if(i[n]!==e[n]){t=!1;break}if(t)return e}return i}var cc=`__show_more__:`,lc=`__show_fewer__:`,uc=e=>e.startsWith(cc),dc=e=>e.startsWith(lc),fc=e=>uc(e)||dc(e),pc=e=>{let t=uc(e)?cc:dc(e)?lc:null;if(!t)return null;let n=e.slice(t.length),r=n.indexOf(`::`);return r<=0?null:{kind:t===`__show_more__:`?`more`:`fewer`,projectId:n.slice(0,r),bucketKey:n.slice(r+2)}},mc=e=>e.parentID??null,hc=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),gc=e=>{let t=e;return hc(t.directory??t.project?.worktree??null)},_c=(e,t)=>{if(t?.trim())return t.trim();let n=hc(e);if(!n)return``;let r=n.split(`/`).filter(Boolean);return r[r.length-1]||n},vc=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},yc=e=>{if(e<=0)return``;let t=Date.now()-e;if(t<6e4)return`now`;let n=Math.floor(t/6e4);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r<24)return`${r}h`;let i=Math.floor(r/24);return i<7?`${i}d`:new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))},bc=e=>{let t=e.time?.archived;return typeof t==`number`&&t>0},xc=(e,t)=>e.worktrees.find(e=>hc(e.path)===t)??null,Sc=(e,t)=>{let n=t?.trim();return n?`${e} · ${n}`:e},Cc=(e,t)=>Xr(e,{pinnedSessionIds:t,omitPinnedSessions:!0}).map(e=>e.session);function wc(){let{t:e}=ee(),t=xe(),n=Fe(e=>e.activeSessions),r=Fe(e=>e.activePaginationByDirectory),i=Ve(e=>e.projects),a=Ve(e=>e.activeProjectId),o=T(e=>e.currentDirectory),s=Re(e=>e.currentSessionId),c=Re(e=>e.availableWorktreesByProject),l=jt(e=>e.orderByProject),u=De(),d=ko(e=>e.projectExpanded),f=ko(e=>e.worktreeExpanded),p=et(e=>e.index.session.unseenCount),[m,h]=Z.useState(new Map),g=jr(),_=Z.useMemo(()=>Cr(g,s),[s,g]),v=Z.useMemo(()=>i.map(e=>{let t=hc(e.path);return{id:e.id,label:_c(t,e.label),path:t,icon:e.icon,worktrees:kt(l[e.id],c.get(t)??[])}}),[i,l,c]),y=Z.useMemo(()=>{let e=new Map(t.map(e=>[e.id,e])),r=n.map(t=>{let n=e.get(t.id);return n?Ue(n,t):t}),i=new Set(r.map(e=>e.id));for(let e of t)i.has(e.id)||r.push(e);return r},[n,t]),b=Z.useMemo(()=>fr(y,v.map(e=>({id:e.id,normalizedPath:e.path})),c,!1),[v,y,c]),x=Z.useMemo(()=>{let e=v.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===a,latestActivity:0})),t=new Map(e.map(e=>[e.project.id,e])),n=(e,t,n)=>{let r=hc(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||n?.label||_c(r),path:r,worktree:n,sessions:[]},e.buckets.push(a)),a};for(let t of e){n(t,t.project.path,null);for(let e of t.project.worktrees)n(t,e.path,e)}for(let e of y){let r=b.bySessionId.get(e.id);if(!r)continue;let i=t.get(r.projectId);if(!i)continue;let a=r.kind===`worktree`?xc(i.project,r.scopeDirectory):null;(a?n(i,a.path,a):n(i,i.project.path,null)).sessions.push(e)}for(let t of e)for(let e of t.buckets){e.sessions.sort((e,t)=>ze(t)-ze(e));let n=Cc(e.sessions,u);t.totalSessions+=n.length;for(let n of e.sessions){let e=vc(n);e>t.latestActivity&&(t.latestActivity=e)}}return e},[a,b,u,v,y]),S=Z.useMemo(()=>{let e=new Map;for(let t of y)e.set(t.id,t);return e},[y]),C=Z.useMemo(()=>{let e=new Map;for(let t of v)e.set(t.id,t);return e},[v]),w=Z.useRef([]),E=Z.useRef([]),D=Z.useRef(new Map),{pinnedSessions:O,inProgressSessions:k}=Z.useMemo(()=>{let t=new Map(v.map(e=>[e.id,e])),n=e(`mobile.sessions.untitled`),r=new Map(w.current.map(e=>[e.id,e])),i=new Map(E.current.map(e=>[e.id,e])),a=(e,r,i)=>{let a=b.bySessionId.get(e.id),o=a?t.get(a.projectId):void 0;if(!o)return[];let c=a?.kind===`worktree`?xc(o,a.scopeDirectory):null,l={id:e.id,directory:gc(e),title:e.title?.trim()||n,subtitle:Sc(o.label,c?.branch),changes:kn(On(e))??void 0,activityLabel:yc(vc(e))||void 0,unread:(p[e.id]??0)>0,pinned:r,archived:bc(e),active:s===e.id};return[oc(i.get(e.id),l)]},o=Hr(y,u).flatMap(e=>a(e,!0,r)),c=Pr(y,u,g,p).flatMap(e=>a(e,!1,i)),l=sc(w.current,o),d=sc(E.current,c);return w.current=l,E.current=d,{pinnedSessions:l,inProgressSessions:d}},[s,b,u,v,g,y,e,p]),A=Z.useMemo(()=>{let e=new Map;for(let t of x){let n=t.project.worktrees.length>0;for(let r of t.buckets){let i=Cc(r.sessions,u).length;e.set(`${t.project.id}::${r.key}`,{path:r.path,rootCount:i,hasWorktrees:n})}}return e},[u,x]),j=Z.useMemo(()=>{let t=hc(o),n=new Map,i=e=>(e.kind!==`pagination`&&n.set(e.id,e),e),a=x.map(a=>{let o=d[a.project.id]??!0,c=yr(),l=a.project.icon?Wt[a.project.icon]:void 0,h=a.buckets.map(o=>{let l=`${a.project.id}::${o.key}`,d=f[l]??!1,h=m.get(l)??c,g=Cc(o.sessions,u),v=Xr(o.sessions,{pinnedSessionIds:u,omitPinnedSessions:!1}).map(e=>e.session),y=t=>{let r=mc(t),a=(p[t.id]??0)>0&&!r,c={id:t.id,directory:o.path,title:t.title?.trim()||e(`mobile.sessions.untitled`),changes:kn(On(t))??void 0,activityLabel:yc(vc(t))||void 0,unread:a,pinned:u.has(t.id),archived:bc(t),active:s===t.id},l=oc(D.current.get(t.id)??n.get(t.id),c);return i(l)},b=wr(g,h,_).map(y),x=g.length-b.length,S=r.get(hc(o.path)),C=S?.hasMore===!0,w=g.length>c&&h>c,T=[...b];w&&T.push({id:`${lc}${a.project.id}::${o.key}`,kind:`pagination`,title:e(`sessions.sidebar.group.showFewer`)}),(x>0||C)&&T.push({id:`${cc}${a.project.id}::${o.key}`,kind:`pagination`,title:e(`sessions.sidebar.group.showMore`),subtitle:S?.loadingMore?`…`:void 0});let E=hc(o.path),O=!!(a.isActive&&t&&E&&(t===E||t.startsWith(`${E}/`))),k=o.worktree==null;return{id:o.key,name:k?e(`mobile.sessions.mainWorkspace`):o.label,path:o.path,kind:k?`main`:`worktree`,active:O,expanded:k?!0:d,sessionCount:g.length,sessions:T,catalogSessions:v.map(y)}});return{id:a.project.id,name:a.project.label,path:a.project.path,icon:l,sessionCount:a.totalSessions,activityLabel:yc(a.latestActivity)||void 0,active:a.isActive,expanded:o,worktrees:h}});return D.current=n,a},[r,_,o,s,u,d,x,e,p,m,f]),M=e=>{for(let[t,n]of A)if(t.startsWith(`${e}::`))return n.hasWorktrees;return!1},N=(e,t)=>A.get(`${e}::${t}`)?.rootCount??0,P=e=>yr();return{projects:j,pinnedSessions:O,inProgressSessions:k,sessionById:S,projectMetaById:C,allSessions:y,projectHasWorktrees:M,getBucketRootCount:N,getBucketVisibleCount:(e,t)=>{let n=`${e}::${t}`;return m.get(n)??P(e)},getBucketPageSize:P,getBucketDirectory:(e,t)=>A.get(`${e}::${t}`)?.path??null,showMoreBucketSessions:(e,t)=>{let n=`${e}::${t}`,r=A.get(n),i=yr(),a=ni(),o=m.get(n)??i,s=r?.rootCount??0;if(h(e=>{let t=new Map(e),r=Math.max(i,e.get(n)??i,o);return t.set(n,r+a),t}),Math.max(i,o)+a<s)return;let c=r?.path,l=hc(c);if(!l)return;let u=Fe.getState().activePaginationByDirectory.get(l);u?.hasMore&&!u.loadingMore&&Ke(l)},resetBucketVisibleCount:(e,t)=>{let n=`${e}::${t}`;h(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t})}}}var Tc=(e,t,n)=>e?.kind===`project`&&e.project.id===t?{...e,isGitRepository:n}:e;function Ec({onOpenChat:e,onAddProject:t,onNewSession:n,onScanQr:r,onSwitchInstance:i,className:a}){let{t:o}=ee(),{git:s}=pn(),c=Ie(),l=wc(),u=ko(e=>e.setProjectExpanded),d=ko(e=>e.setWorktreeExpanded),f=he(),p=De(),m=Re(e=>e.archiveSessions),h=Re(e=>e.updateSessionTitle),_=Re(e=>e.requestSessionSmartTitle),v=Re(e=>e.shareSession),y=Re(e=>e.unshareSession),b=Re(e=>e.openNewSessionDraft),x=We(e=>e.openDraft),S=We(e=>e.openSession),C=Ve(e=>e.projects),w=Ve(e=>e.setActiveProjectIdOnly),T=Ve(e=>e.removeProject),E=Ot(),[D,O]=Z.useState(null),[k,A]=Z.useState(!1),[j,M]=Z.useState(null),[N,P]=Z.useState(null),[F,I]=Z.useState(null),[L,R]=Z.useState(``),[z,B]=Z.useState(!1),[U,W]=Z.useState(!1),[K,te]=Z.useState(null),[q,ne]=Z.useState(null),[re,ie]=Z.useState(null),ae=D?.kind===`session`?D.session.id:``,oe=Ae(ae),se=oe?.type===`busy`||oe?.type===`retry`,J=D?.kind===`session`?gc(D.session):``,ce=!!ae&&re===ae,le=!J||ce||se,ue=V(e=>{let t=new Map;for(let e of l.allSessions){let n=mc(e);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}),Y=V(()=>{A(!1),O(null)}),de=V(t=>{if(fc(t.id)){let e=pc(t.id);if(!e)return;e.kind===`more`?l.showMoreBucketSessions(e.projectId,e.bucketKey):l.resetBucketVisibleCount(e.projectId,e.bucketKey);return}let n=l.sessionById.get(t.id),r=n&&gc(n)||null;e({sessionId:t.id,directory:r})}),fe=V(e=>{fc(e.id)||f(e.id)}),pe=V(async e=>{if(fc(e.id))return;let t=ue(e.id),{archivedIds:n,failedIds:r}=await m(t);n.length>0&&Wr({sessionIds:n,message:n.length===1?o(`sessions.sidebar.session.archive.success`):o(`sessions.sidebar.bulkActions.archivedPlural`,{count:n.length}),undoLabel:o(`sessions.sidebar.undo`),settingsLabel:o(`settings.openchamber.archivedSessions.actions.view`),undoFailedMessage:n.length===1?o(`sessions.sidebar.session.archive.undoFailed`):o(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:n.length})}),r.length>0&&Ze.error(r.length===1?o(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):o(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}),me=V(()=>{if(!D||D.kind!==`session`)return;let e=D.session,t=gc(e),n=oe?.type??`idle`;!t||re===e.id||n===`busy`||n===`retry`||(ie(e.id),(async()=>{try{await E.refreshSessionTranscript(e.id,{directory:t}),Ze.success(o(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{Ze.error(o(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{ie(t=>t===e.id?null:t)}})())}),ge=V(e=>{if(fc(e.id))return;let t=l.sessionById.get(e.id);t&&(O({kind:`session`,session:t}),A(!0))}),_e=V(e=>{u(e.id,!e.expanded)}),ve=V((e,t)=>{d(`${e.id}::${t.id}`,!t.expanded)}),ye=V((e,t)=>{w(e.id),x({selectedProjectId:e.id,directoryOverride:t,preserveDirectoryOverride:!0})}),be=V(()=>{if(n){n();return}b()}),xe=V(e=>{let t=l.projectMetaById.get(e.id);t&&(O({kind:`project`,project:t,isGitRepository:!1}),A(!0),s.checkIsGitRepository(t.path).then(e=>{O(n=>Tc(n,t.id,e))}).catch(()=>{O(e=>Tc(e,t.id,!1))}))}),Se=V((e,t)=>{let n=g(t);return n?e.worktrees.find(e=>g(e.path)===n)||((Re.getState().availableWorktreesByProject.get(e.path)??[]).find(e=>g(e.path)===n)??null):null}),Ce=V((e,t)=>{let n=l.projectMetaById.get(e.id);n&&ye(n,t.path)}),we=V((e,t)=>{let n=l.projectMetaById.get(e.id);n&&(O({kind:`worktree`,project:n,worktreePath:t.path,worktreeName:t.name}),A(!0))}),Te=V((e,t)=>{let n=l.projectMetaById.get(e.id);if(!n)return;let r=Se(n,t.path);if(!r){Ze.error(o(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}ne({project:n,worktree:r})}),Ee=V(e=>{te(e),w(e),W(!0)}),Oe=V(e=>{(async()=>{let t=e.worktrees;try{t=(await Gt({id:e.id,path:e.path})).worktrees}catch(n){console.warn(`[MobileProjectsHome] Worktree refresh before session sync failed:`,n),t=Re.getState().availableWorktreesByProject.get(e.path)??e.worktrees}await $e([e.path,...t.map(e=>e.path)],l.allSessions)})()}),ke=V((e,t)=>{let n=K;if(W(!1),te(null),t?.sessionId){S({sessionId:t.sessionId,directory:e});return}x({selectedProjectId:n,directoryOverride:e,preserveDirectoryOverride:!0})}),je=V(async e=>{try{if(!(await v(e.id))?.share?.url){Ze.error(o(`sessions.sidebar.session.share.error`));return}Ze.success(o(`sessions.sidebar.session.share.successTitle`),{description:o(`sessions.sidebar.session.share.successDescription`)})}catch{Ze.error(o(`sessions.sidebar.session.share.error`))}}),Me=V(async e=>{if((await H(e)).ok){Ze.success(o(`sessions.sidebar.session.menu.copied`));return}Ze.error(o(`sessions.sidebar.session.share.copyUrlError`))}),Ne=V(async e=>{try{if(await y(e)){Ze.success(o(`sessions.sidebar.session.unshare.success`));return}Ze.error(o(`sessions.sidebar.session.unshare.error`))}catch{Ze.error(o(`sessions.sidebar.session.unshare.error`))}}),Pe=V(e=>{let t=ue(e.id);Er({sessionIds:t,message:t.length===1?o(`sessions.sidebar.session.delete.success`):o(`sessions.sidebar.bulkActions.deletedPlural`,{count:t.length}),undoLabel:o(`sessions.sidebar.undo`),commitFailedMessage:o(`sessions.sidebar.session.delete.error`)})}),Fe=V(async()=>{if(!F)return;let e=L.trim();if(e)try{await h(F.id,e),I(null),R(``)}catch{Ze.error(o(`sessions.sidebar.session.menu.rename`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}}),Le=V(async()=>{if(!F||z)return;let e=F.id;I(null),R(``),B(!0);try{await _(e)}catch{Ze.error(o(`sessions.sidebar.session.rename.smartTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{B(!1)}}),ze=Z.useMemo(()=>D?D.kind===`session`?{kind:`session`,title:D.session.title?.trim()||o(`mobile.sessions.untitled`),pinned:p.has(D.session.id),shared:!!D.session.share?.url}:D.kind===`project`?{kind:`project`,title:D.project.label,gitRepository:D.isGitRepository}:{kind:`worktree`,title:D.worktreeName}:null,[D,p,o]),Be=Z.useMemo(()=>{if(!D)return{};if(D.kind===`session`){let e=D.session;return{onRename:()=>{R(e.title?.trim()||o(`mobile.sessions.untitled`)),I(e)},onTogglePin:()=>f(e.id),onShare:c&&!e.share?.url?()=>{je(e)}:void 0,onCopyLink:c&&e.share?.url?()=>{Me(e.share.url)}:void 0,onUnshare:c&&e.share?.url?()=>{Ne(e.id)}:void 0,onRefreshTranscript:me,onArchive:()=>{pe({id:e.id,title:e.title?.trim()||o(`mobile.sessions.untitled`)})},onDelete:()=>Pe(e)}}if(D.kind===`project`){let e=D.project;return{onNewSession:()=>ye(e,e.path),onNewWorktree:()=>Ee(e.id),onSyncSessions:()=>Oe(e),onEditProject:()=>M(e.id),onCloseProject:()=>P(e)}}let{project:e,worktreePath:t}=D;return{onNewSession:()=>ye(e,t),onDeleteWorktree:()=>{let n=Se(e,t);if(!n){Ze.error(o(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}ne({project:e,worktree:n})}}},[D,pe,Me,Pe,me,Ee,Oe,je,Ne,Se,c,ye,o,f]),He=Z.useMemo(()=>{if(!j)return null;let e=C.find(e=>e.id===j),t=l.projectMetaById.get(j);if(!e||!t)return null;let n=D?.kind===`project`&&D.project.id===j?D.isGitRepository:t.worktrees.length>0;return{id:e.id,label:e.label?.trim()||t.label,path:g(e.path)||t.path,icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:n,worktrees:t.worktrees}},[D,j,l.projectMetaById,C]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ec,{className:a,projects:l.projects,pinnedSessions:l.pinnedSessions,inProgressSessions:l.inProgressSessions,onAddProject:t,onNewSession:be,onScanQr:r,onSwitchInstance:i,onToggleProject:_e,onOpenProjectActions:xe,onToggleWorktree:ve,onNewWorktreeSession:Ce,onOpenWorktreeActions:we,onDeleteWorktree:Te,onSelectSession:de,onPinSession:fe,onArchiveSession:e=>{pe(e)},onOpenSessionActions:ge}),(0,$.jsx)(ac,{open:k,target:ze,actions:Be,refreshTranscriptDisabled:le,refreshTranscriptSpinning:ce,onOpenChange:e=>{e?A(!0):Y()}}),(0,$.jsx)(dt,{open:U,projectId:K,onOpenChange:e=>{W(e),e||te(null)},onWorktreeCreated:ke}),q?(0,$.jsx)(br,{open:!0,project:{id:q.project.id,path:q.project.path},worktree:q.worktree,onClose:()=>ne(null)}):null,(0,$.jsx)(Jt,{open:!!N,title:o(`sessions.sidebar.project.actions.closeProject`),onClose:()=>P(null),closeAriaLabel:o(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(G,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>P(null),children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(G,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!N)return;let e=N;P(null),T(e.id),Ze.success(o(`mobile.sessions.toast.projectRemoved`,{label:e.label}))},children:o(`mobile.sessions.confirmRemoveProject`)})]}),children:(0,$.jsx)(`p`,{className:`px-1 py-1 typography-ui-body text-foreground`,children:o(`mobile.projects.closeConfirmMessage`,{title:N?.label??``})})}),(0,$.jsx)(Jt,{open:!!F,title:o(`sessions.sidebar.session.menu.rename`),onClose:()=>{z||(I(null),R(``))},closeAriaLabel:o(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(G,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:z,onClick:()=>{I(null),R(``)},children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(G,{type:`button`,variant:`default`,className:`flex-1`,disabled:!L.trim()||z,onClick:()=>void Fe(),children:o(`sessions.sidebar.session.rename.save`)})]}),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-3 px-1 py-1`,onSubmit:e=>{e.preventDefault(),Fe()},children:[(0,$.jsx)(Kt,{value:L,onChange:e=>R(e.target.value),autoFocus:!0,className:`h-12`,disabled:z}),(0,$.jsxs)(G,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:z,onClick:()=>void Le(),children:[z?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`ai-generate-2`,className:`size-4`}),o(`sessions.sidebar.session.rename.smartTitle`)]})]})}),(0,$.jsx)(xr,{open:j!==null,project:He,onClose:()=>M(null)})]})}function Dc(e){let t=(0,Q.c)(10),{children:n,content:r,className:i,contentClassName:a,showHeader:o}=e,s=o===void 0||o,{t:c}=ee(),l;t[0]===c?l=t[1]:(l=c(`sessions.scheduledTasks.dialog.title`),t[0]=c,t[1]=l);let u;t[2]===a?u=t[3]:(u=W(`oc-mobile-scheduled-content`,a),t[2]=a,t[3]=u);let d=n??r,f;return t[4]!==i||t[5]!==s||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,$.jsx)(lr,{title:l,className:i,surface:!1,scrollsWithPage:!0,showHeader:s,surfaceClassName:u,children:d}),t[4]=i,t[5]=s,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function Oc(e){let t=(0,Q.c)(10),{className:n,contentClassName:r,instancesPage:i}=e,{t:a}=ee(),o;t[0]===a?o=t[1]:(o=a(`mobile.settings.placeholder.title`),t[0]=a,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=[...dr],t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,$.jsx)(mi,{forceMobile:!0,isWindowed:!0,hideMobileHeader:!0,flowMobile:!0,autoOpenMobilePage:!0,visiblePageSlugs:s,mobileInstancesPage:i}),t[3]=i,t[4]=c);let l;return t[5]!==n||t[6]!==r||t[7]!==o||t[8]!==c?(l=(0,$.jsx)(lr,{title:o,className:n,surface:!1,scrollsWithPage:!0,showHeader:!1,surfaceClassName:r,children:c}),t[5]=n,t[6]=r,t[7]=o,t[8]=c,t[9]=l):l=t[9],l}function kc(e){let t=(0,Q.c)(110),{onAddProject:n,onScanQr:r,onSwitchInstance:i,onEnableAssistants:a,instancesPage:o,instancesSecondaryPage:s,parentSessionTarget:c,registerSecondaryBackHandler:l,scheduledContent:u,renderChat:d,className:f}=e,p=c===void 0?null:c,{t:m}=ee(),h=We(),_=We(qc),v=We(Kc),y=We(Gc),b=We(Wc),x=We(Uc),S=We(Hc),C=We(Vc),w=We(Bc),T=We(zc),E=We(Rc),D=We(Lc),O=We(Ic),k;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(k=[],t[0]=k):k=t[0],Z.useEffect(Fc,k);let A=h.secondary?.kind===`chat`?h.secondary.btw??null:null,j=Z.useRef(null),N,P;t[1]===A?(N=t[2],P=t[3]):(N=()=>{let e=j.current;j.current=A,e&&e!==A&&yt.getState().clear({sessionId:e.sessionId,directory:e.directory}),A?vt(lt):ft(lt)},P=[A],t[1]=A,t[2]=N,t[3]=P),Z.useEffect(N,P);let F;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(F=[],t[4]=F):F=t[4],Z.useEffect(Nc,F);let I;t[5]===_?I=t[6]:(I=e=>{e===`settings`&&M.getState().setSettingsPage(`home`),_(e)},t[5]=_,t[6]=I);let L=V(I),R;t[7]===v?R=t[8]:(R=e=>{v(e)},t[7]=v,t[8]=R);let z=V(R),B;t[9]===C?B=t[10]:(B=()=>{C()},t[9]=C,t[10]=B);let H=V(B),U;t[11]===y?U=t[12]:(U=()=>{y()},t[11]=y,t[12]=U);let W=V(U),G;t[13]===b?G=t[14]:(G=e=>{b(e)},t[13]=b,t[14]=G);let K=V(G),te=Z.useRef(null),[q,ne]=Z.useState(!1),re;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(re=e=>{te.current=e},t[15]=re):re=t[15];let ie=V(re),ae;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(ae=e=>{ne(e)},t[16]=ae):ae=t[16];let oe=V(ae),se;t[17]!==H||t[18]!==S||t[19]!==O||t[20]!==w?(se=()=>{if(te.current?.())return!0;let e=We.getState().secondary;return e?.kind===`chat`&&e.btw?(O(),!0):e?.kind===`assistant`&&e.settingsAssistantID?(S(),!0):e?.kind===`chat`&&e.routes.length>1?(w(),!0):e?(H(),!0):!1},t[17]=H,t[18]=S,t[19]=O,t[20]=w,t[21]=se):se=t[21];let J=V(se),ce=h.secondary!==null,le;t[22]!==J||t[23]!==l?(le=()=>{if(l)return l(()=>J()),()=>l(null)},t[22]=J,t[23]=l,t[24]=le):le=t[24];let ue;t[25]!==J||t[26]!==l||t[27]!==ce?(ue=[l,ce,J],t[25]=J,t[26]=l,t[27]=ce,t[28]=ue):ue=t[28],Z.useEffect(le,ue);let Y=Re(Mc),de;t[29]===Y?de=t[30]:(de=e=>Y?e.getDirectoryForSession(Y):null,t[29]=Y,t[30]=de);let fe=Re(de),pe,me;t[31]!==fe||t[32]!==Y||t[33]!==E||t[34]!==D?(pe=()=>{let e=We.getState().secondary;if(e?.kind===`draft`&&Y){E({sessionId:Y,directory:fe});return}if(e?.kind!==`chat`||!Y||Ye({sessionId:Y,directory:fe})===`internal`)return;let t=e.routes.at(-1);(t?.sessionId!==Y||g(t.directory)!==g(fe))&&D({sessionId:Y,directory:fe})},me=[fe,Y,E,D],t[31]=fe,t[32]=Y,t[33]=E,t[34]=D,t[35]=pe,t[36]=me):(pe=t[35],me=t[36]),Z.useEffect(pe,me);let he,ge;t[37]!==Y||t[38]!==p||t[39]!==T?(he=()=>{let e=We.getState().secondary;if(e?.kind!==`chat`||!p)return;let t=e.routes.at(-1);!t||t.sessionId!==Y||T({sessionId:p.id,directory:p.directory})},ge=[Y,p,T],t[37]=Y,t[38]=p,t[39]=T,t[40]=he,t[41]=ge):(he=t[40],ge=t[41]),Z.useEffect(he,ge);let _e;t[42]!==oe||t[43]!==ie||t[44]!==u?(_e=typeof u==`function`?u(ie,oe):u,t[42]=oe,t[43]=ie,t[44]=u,t[45]=_e):_e=t[45];let ve=_e,ye;t[46]!==W||t[47]!==n||t[48]!==r||t[49]!==i||t[50]!==z?(ye=(0,$.jsx)(Ec,{onOpenChat:z,onAddProject:n,onNewSession:W,onScanQr:r,onSwitchInstance:i}),t[46]=W,t[47]=n,t[48]=r,t[49]=i,t[50]=z,t[51]=ye):ye=t[51];let be;t[52]!==a||t[53]!==K?(be=(0,$.jsx)(is,{onEnable:a,onOpenAssistant:K}),t[52]=a,t[53]=K,t[54]=be):be=t[54];let xe;t[55]===ve?xe=t[56]:(xe=(0,$.jsx)(Dc,{showHeader:!1,children:ve}),t[55]=ve,t[56]=xe);let Se;t[57]===o?Se=t[58]:(Se=(0,$.jsx)(Oc,{instancesPage:o}),t[57]=o,t[58]=Se);let Ce;t[59]!==ye||t[60]!==be||t[61]!==xe||t[62]!==Se?(Ce={projects:ye,assistant:be,scheduled:xe,settings:Se},t[59]=ye,t[60]=be,t[61]=xe,t[62]=Se,t[63]=Ce):Ce=t[63];let we=Ce,Te=h.secondary?.kind??null,Ee;bb0:{if(!Te){Ee=null;break bb0}if(Te===`assistant`){let e=h.secondary?.kind===`assistant`?h.secondary.settingsAssistantID:void 0,n;t[64]===m?n=t[65]:(n=m(`assistants.title`),t[64]=m,t[65]=n);let r=!e,i;t[66]!==x||t[67]!==r?(i=(0,$.jsx)(Ci,{activeOverride:r,onMobileBack:jc,onMobileOpenSettings:x}),t[66]=x,t[67]=r,t[68]=i):i=t[68];let a;t[69]!==J||t[70]!==n||t[71]!==i?(a={key:`assistant-secondary`,depth:1,ariaLabel:n,onBack:J,content:i},t[69]=J,t[70]=n,t[71]=i,t[72]=a):a=t[72];let o;t[73]!==J||t[74]!==e||t[75]!==m?(o=e?[{key:`assistant-settings:${e}`,depth:2,ariaLabel:m(`assistants.conversation.openSettings`),onBack:J,content:(0,$.jsx)(os,{assistantID:e,onBack:Ac})}]:[],t[73]=J,t[74]=e,t[75]=m,t[76]=o):o=t[76];let s;t[77]!==a||t[78]!==o?(s=[a,...o],t[77]=a,t[78]=o,t[79]=s):s=t[79],Ee=s;break bb0}if(Te===`instances`){let e;t[80]===m?e=t[81]:(e=m(`mobile.settings.switchInstance`),t[80]=m,t[81]=e);let n;t[82]!==J||t[83]!==s||t[84]!==e?(n=[{key:`instances-secondary`,depth:1,ariaLabel:e,onBack:J,content:s}],t[82]=J,t[83]=s,t[84]=e,t[85]=n):n=t[85],Ee=n;break bb0}if(h.secondary?.kind===`draft`){let e;t[86]===m?e=t[87]:(e=m(`mobile.nav.secondaryPageAria`),t[86]=m,t[87]=e);let n;t[88]===d?n=t[89]:(n=d({sessionId:``,directory:null,viewKey:`chat-primary`,active:!0}),t[88]=d,t[89]=n);let r;t[90]!==J||t[91]!==e||t[92]!==n?(r=[{key:`chat-primary`,depth:1,ariaLabel:e,onBack:J,content:n}],t[90]=J,t[91]=e,t[92]=n,t[93]=r):r=t[93],Ee=r;break bb0}if(h.secondary?.kind!==`chat`){let e;t[94]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[94]=e):e=t[94],Ee=e;break bb0}let e=h.secondary.routes,n=h.secondary.btw,r;if(t[95]!==n||t[96]!==J||t[97]!==d||t[98]!==e||t[99]!==m){let i=e.slice(n?-1:-2),a=e.length-i.length+1,o=i.map((e,t)=>{let r=!n&&t===i.length-1;return{key:e.key,depth:a+t,ariaLabel:m(`mobile.nav.secondaryPageAria`),onBack:J,content:d({sessionId:e.sessionId,directory:e.directory,viewKey:e.key,active:r})}});r=n?[...o,{key:`chat-btw`,depth:e.length+1,ariaLabel:m(`chat.btw.title`),onBack:J,content:(0,$.jsx)(ss,{route:n})}]:o,t[95]=n,t[96]=J,t[97]=d,t[98]=e,t[99]=m,t[100]=r}else r=t[100];Ee=r}let De=Ee,Oe;t[101]===De?Oe=t[102]:(Oe=De??[],t[101]=De,t[102]=Oe);let ke;return t[103]!==f||t[104]!==h||t[105]!==q||t[106]!==L||t[107]!==Oe||t[108]!==we?(ke=(0,$.jsx)(As,{className:f,navigation:h,onTabChange:L,tabs:we,secondaryPages:Oe,tabBarCovered:q}),t[103]=f,t[104]=h,t[105]=q,t[106]=L,t[107]=Oe,t[108]=we,t[109]=ke):ke=t[109],ke}function Ac(){Hn.requestAnimatedBack(`root`)}function jc(){return Hn.requestAnimatedBack(`root`)}function Mc(e){return e.currentSessionId}function Nc(){return Pc}function Pc(){return ft(lt)}function Fc(){return Ne()}function Ic(e){return e.popBtw}function Lc(e){return e.replaceChatSession}function Rc(e){return e.materializeDraftSession}function zc(e){return e.reconcileChatPredecessor}function Bc(e){return e.popChatSession}function Vc(e){return e.closeSecondary}function Hc(e){return e.popAssistantSettings}function Uc(e){return e.pushAssistantSettings}function Wc(e){return e.openAssistant}function Gc(e){return e.openDraft}function Kc(e){return e.openSession}function qc(e){return e.setActiveTab}function Jc(e){let t=(0,Q.c)(19),{percentage:n}=e,r,i,a,o,s,c,l;if(t[0]!==n){a=en(n)??0;let e=Yt(n);i=e===`critical`?`var(--status-error)`:e===`warn`?`var(--status-warning)`:`var(--status-success)`,r=2*Math.PI*7.5,o=`0 0 18 18`,s=`size-[18px] -rotate-90`,c=`progressbar`,l=Math.round(a),t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7];let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:3}),t[8]=u):u=t[8];let d=r*(1-a/100),f;t[9]!==r||t[10]!==i||t[11]!==d?(f=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:i,strokeWidth:3,strokeLinecap:`round`,strokeDasharray:r,strokeDashoffset:d,className:`transition-[stroke-dashoffset,stroke] duration-300`}),t[9]=r,t[10]=i,t[11]=d,t[12]=f):f=t[12];let p;return t[13]!==o||t[14]!==s||t[15]!==c||t[16]!==l||t[17]!==f?(p=(0,$.jsxs)(`svg`,{viewBox:o,className:s,role:c,"aria-valuenow":l,"aria-valuemin":0,"aria-valuemax":100,children:[u,f]}),t[13]=o,t[14]=s,t[15]=c,t[16]=l,t[17]=f,t[18]=p):p=t[18],p}function Yc(e){let t=(0,Q.c)(16),{title:n,subtitle:r,onBack:i,onOpenMenu:a,menuOpen:o,elevated:s,trailing:c}=e,l=o!==void 0&&o,u=s!==void 0&&s,{t:d}=ee(),f=V(i),p=V(a),m;t[0]===d?m=t[1]:(m=d(`header.actions.backAria`),t[0]=d,t[1]=m);let h=u||l,g;t[2]===d?g=t[3]:(g=d(`mobile.menu.titleAria`),t[2]=d,t[3]=g);let _;t[4]!==p||t[5]!==l||t[6]!==g?(_=[{icon:`more-2`,ariaLabel:g,onClick:p,pressed:l}],t[4]=p,t[5]=l,t[6]=g,t[7]=_):_=t[7];let v;return t[8]!==f||t[9]!==r||t[10]!==m||t[11]!==h||t[12]!==_||t[13]!==n||t[14]!==c?(v=(0,$.jsx)(Y,{title:n,subtitle:r,backAriaLabel:m,onBack:f,overlay:!0,elevated:h,trailing:c,actions:_}),t[8]=f,t[9]=r,t[10]=m,t[11]=h,t[12]=_,t[13]=n,t[14]=c,t[15]=v):v=t[15],v}var Xc=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},Zc=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),Qc=e=>e>=90?`text-[var(--status-error)]`:e>=75?`text-[var(--status-warning)]`:`text-[var(--status-success)]`,$c=e=>{let{totalTokens:t,contextLimit:n,isDraft:r}=e;if(r||t<=0||n<=0)return null;let i=Math.min(t/n*100,999);return{percentage:i,tokens:`${Zc(t)}/${Zc(n)}`,colorClass:Qc(i)}},el=e=>{for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role!==`user`)continue;let r=typeof n.model?.providerID==`string`&&n.model.providerID.trim().length>0?n.model.providerID:void 0,i=typeof n.model?.modelID==`string`&&n.model.modelID.trim().length>0?n.model.modelID:void 0;if(r&&i)return{providerID:r,modelID:i}}return null},tl=(e,t)=>{let n=be(e,t??(()=>void 0));return!n||`compacted`in n?0:n.totalTokens},nl=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),rl=e=>{let t=e.usedPercent;return typeof t!=`number`||!Number.isFinite(t)?`text-foreground`:t>=80?`text-[var(--status-error)]`:t>=50?`text-[var(--status-warning)]`:`text-foreground`},il=e=>{let t=(0,Q.c)(13),{iconNode:n,iconName:r,label:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o=n??(r?(0,$.jsx)(X,{name:r,className:`size-[18px]`}):null),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s;t[3]===o?s=t[4]:(s=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:o}),t[3]=o,t[4]=s);let c;t[5]===i?c=t[6]:(c=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:i}),t[5]=i,t[6]=c);let l;t[7]===a?l=t[8]:(l=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground`,children:a}),t[7]=a,t[8]=l);let u;return t[9]!==s||t[10]!==c||t[11]!==l?(u=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5`,children:[s,c,l]}),t[9]=s,t[10]=c,t[11]=l,t[12]=u):u=t[12],u},al=e=>{let t=(0,Q.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=ee(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(X,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,$.jsx)(X,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,$.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(zt,{providerId:e.providerId,className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground`,children:e.providerName}),e.status&&e.rows.length===0?(0,$.jsx)(`span`,{className:`shrink-0 truncate typography-micro text-muted-foreground`,children:e.status}):null]}),e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:e.rows.map(e=>{let t=r===`remaining`?e.window.remainingPercent:e.window.usedPercent,n=Zt(e.window.valueLabel,t),i=sn(e.window.resetAt,e.window.resetAfterFormatted??e.window.resetAtFormatted,a);return(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-3`,children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-muted-foreground`,children:e.subtitle?`${e.subtitle} · ${e.label}`:e.label}),i?(0,$.jsx)(`span`,{className:`shrink-0 truncate typography-micro text-muted-foreground/70`,children:i}):null]}),(0,$.jsx)(`span`,{className:W(`shrink-0 typography-ui-label font-semibold tabular-nums`,rl(e.window)),children:n===`-`?``:n})]},e.key)})}):null,e.status&&e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 typography-micro text-muted-foreground`,children:e.status}):null]},e.providerId),t[22]=r,t[23]=a,t[24]=e):e=t[24],g=n.map(e),t[18]=r,t[19]=n,t[20]=a,t[21]=g}else g=t[21];let _;t[25]===g?_=t[26]:(_=(0,$.jsx)(`div`,{className:`space-y-1.5`,children:g}),t[25]=g,t[26]=_);let v;return t[27]!==_||t[28]!==h?(v=(0,$.jsxs)(`div`,{className:`pt-2.5`,children:[h,_]}),t[27]=_,t[28]=h,t[29]=v):v=t[29],v},ol=e=>{let t=(0,Q.c)(47),{open:n,onClose:r,contextDisplay:i,branchLabel:a,usageGroups:o,usageDisplayMode:s,isUsageLoading:c,timeFormatPreference:l}=e,{t:u}=ee(),d=Z.useRef(null),[f,p]=Z.useState(n),[m,h]=Z.useState(!1),g,_;t[0]!==n||t[1]!==f?(g=()=>{if(n){p(!0),h(!1);return}if(!f)return;h(!0);let e=window.setTimeout(()=>{p(!1),h(!1)},140);return()=>window.clearTimeout(e)},_=[n,f],t[0]=n,t[1]=f,t[2]=g,t[3]=_):(g=t[2],_=t[3]),Z.useEffect(g,_);let v,y;if(t[4]!==r||t[5]!==n?(v=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},y=[r,n],t[4]=r,t[5]=n,t[6]=v,t[7]=y):(v=t[6],y=t[7]),Z.useEffect(v,y),!f)return null;let b;t[8]===u?b=t[9]:(b=u(`mobile.surface.closeAria`),t[8]=u,t[9]=b);let x;t[10]===r?x=t[11]:(x=e=>{e.preventDefault(),r()},t[10]=r,t[11]=x);let S;t[12]!==b||t[13]!==x?(S=(0,$.jsx)(`button`,{type:`button`,className:`pointer-events-auto absolute inset-x-0 bottom-0 cursor-default top-[calc(var(--oc-safe-area-top,0px)+var(--oc-mobile-detail-navigation-height,3.5rem)+0.25rem)]`,"aria-label":b,onPointerDown:x}),t[12]=b,t[13]=x,t[14]=S):S=t[14];let C;t[15]===u?C=t[16]:(C=u(`mobile.header.openMetadataAria`),t[15]=u,t[16]=C);let w=m&&`pointer-events-none`,T;t[17]===w?T=t[18]:(T=W(`pointer-events-auto absolute inset-x-3 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-mobile-detail-navigation-height,3.5rem)+0.5rem)] overflow-y-auto overscroll-contain rounded-[20px] oc-mobile-overlay-surface oc-mobile-overlay-surface--translucent p-2 will-change-transform`,w),t[17]=w,t[18]=T);let E=`${m?`session-metadata-out`:`session-metadata-in`} ${m?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,D;t[19]===E?D=t[20]:(D={animation:E,maxHeight:`min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-mobile-detail-navigation-height, 3.5rem) - 1rem))`},t[19]=E,t[20]=D);let O;t[21]===u?O=t[22]:(O=u(`mobile.header.metadata.branch`),t[21]=u,t[22]=O);let k;t[23]!==a||t[24]!==O?(k=(0,$.jsx)(il,{iconName:`git-branch`,label:O,children:a}),t[23]=a,t[24]=O,t[25]=k):k=t[25];let A;t[26]!==i||t[27]!==u?(A=i?(0,$.jsx)(il,{iconNode:(0,$.jsx)(Jc,{percentage:i.percentage}),label:u(`mobile.header.metadata.context`),children:(0,$.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5 tabular-nums`,children:[(0,$.jsxs)(`span`,{className:W(`font-semibold`,i.colorClass),children:[i.percentage.toFixed(1),`%`]}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:i.tokens})]})}):null,t[26]=i,t[27]=u,t[28]=A):A=t[28];let j;t[29]!==c||t[30]!==l||t[31]!==s||t[32]!==o?(j=(0,$.jsx)(al,{groups:o,displayMode:s,isLoading:c,timeFormatPreference:l}),t[29]=c,t[30]=l,t[31]=s,t[32]=o,t[33]=j):j=t[33];let M;t[34]!==k||t[35]!==A||t[36]!==j?(M=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[k,A,j]}),t[34]=k,t[35]=A,t[36]=j,t[37]=M):M=t[37];let N;t[38]!==T||t[39]!==D||t[40]!==M||t[41]!==C?(N=(0,$.jsx)(`div`,{ref:d,role:`dialog`,"aria-label":C,className:T,style:D,onPointerDown:El,children:M}),t[38]=T,t[39]=D,t[40]=M,t[41]=C,t[42]=N):N=t[42];let P;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(`style`,{children:`
|
|
5
|
+
`)}`.trim()),P([])}),Te=V(async()=>{if(!s)return;let e=s,t=ie.map(e=>e.path).sort();if(t.length===0){Ze.error(a(`gitView.toast.selectFileToDescribe`));return}M(!0);try{let{message:n}=await ct(e,t);E(n.subject?.trim()??``),P(Array.isArray(n.highlights)?n.highlights:[])}catch(e){Ze.error(e instanceof Error?e.message:a(`gitView.toast.generateCommitMessageFailed`))}finally{M(!1)}}),Ee=async(e={})=>{if(!s)return;let t=s;if(!T.trim()){Ze.error(a(`gitView.toast.enterCommitMessage`));return}let n=ie.map(e=>e.path).sort();if(n.length===0){Ze.error(a(`gitView.toast.selectFileToCommit`));return}w(e.pushAfter?`commitAndPush`:`commit`);try{if(await o.createGitCommit(t,T.trim(),{files:n}),Ze.success(a(`gitView.toast.commitCreated`)),E(``),P([]),e.pushAfter){let e=c?.tracking?.split(`/`)[0],n=J.find(t=>t.name===e)??J[0];if(!n)throw Error(a(`mobile.changes.noRemote`));S(`sync`);let r=`${n.name}/`,i=c?.tracking?.startsWith(r)?c.tracking.slice(r.length):void 0;await o.gitFetch(t,{remote:n.name}),((await o.getGitStatus(t)).behind??0)>0&&await o.gitPull(t,{remote:n.name,branch:i,rebase:!0}),((await o.getGitStatus(t)).ahead??0)>0&&await o.gitPush(t),await he(t,!1),await _e(t).promise}else await he(t,!1)}catch(e){Ze.error(e instanceof Error?e.message:a(`gitView.toast.createCommitFailed`))}finally{w(null),e.pushAfter&&S(null)}},De=Z.useMemo(()=>{let e=[];return ie.length>0&&e.push({id:`staged`,title:a(`gitView.changes.stagedTitle`),entries:ie,actionSymbol:`-`,actionAllLabel:a(`gitView.changes.unstageAllAria`),getActionLabel:e=>a(`gitView.changes.unstageFileAria`,{path:e}),onActionFile:e=>void ye([e],`unstage`),onActionAll:e=>void ye(e,`unstage`),onViewDiff:e=>be(e,!0),onRevertFile:Se,showRevertActions:!1,accent:!0}),ae.length>0&&e.push({id:`unstaged`,title:a(`gitView.changes.title`),entries:ae,actionSymbol:`+`,actionAllLabel:a(`gitView.changes.stageAllAria`),getActionLabel:e=>a(`gitView.changes.stageFileAria`,{path:e}),onActionFile:e=>void ye([e],`stage`),onActionAll:e=>void ye(e,`stage`),onViewDiff:e=>be(e,!1),onRevertFile:Se}),e},[Se,be,ye,ie,a,ae]),Oe=t=>(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[i?null:(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,children:[e?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":a(`mobile.surface.closeAria`),onClick:e,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label text-foreground`,children:a(`mobile.nav.changes`)}),(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:c?.current||s||``})]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:t})]});return s?u&&l===null?Oe((0,$.jsx)(Ra,{loading:!0,message:a(`gitView.loading.checkingRepository`)})):l===!1?Oe((0,$.jsx)(Ra,{icon:!0,message:a(`gitView.empty.notGitRepository`),description:a(`gitView.empty.notGitRepositoryDescription`)})):v.type===`diff`?(0,$.jsx)(`div`,{ref:b,className:`h-full min-h-0`,children:(0,$.jsx)(za,{path:v.path,diff:le,fileExists:me,error:pe,loading:fe,targetLine:v.targetLine,onBack:xe,onRetry:()=>G(e=>e+1),hideHeader:i})}):(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,children:[e?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":a(`mobile.surface.closeAria`),onClick:e,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label text-foreground`,children:a(`mobile.nav.changes`)}),(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:c?.current||s})]}),(0,$.jsx)(Vr,{syncAction:x,remotes:J,onSync:e=>void ve(`sync`,e),disabled:C!==null||u,aheadCount:c?.ahead??0,behindCount:c?.behind??0,trackingRemoteName:c?.tracking?.split(`/`)[0],hasUncommittedChanges:(c?.files?.length??0)>0})]}),ne?(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(ni,{stagedCount:oe,unstagedCount:se,onLoad:()=>q(!0)})}):re.length>0?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden px-4 pt-4`,children:(0,$.jsx)(zr,{groups:De,diffStats:c?.diffStats,revertingPaths:D,onRevertAll:Ce,isRevertingAll:k,headerBackgroundClassName:`bg-transparent`,onVisiblePathsChange:I})}),(0,$.jsx)(`div`,{className:`shrink-0 border-t border-border/50 px-4 pb-4 pt-3`,children:(0,$.jsx)(Rr,{stagedCount:ie.length,commitMessage:T,onCommitMessageChange:E,generatedHighlights:N,onInsertHighlights:we,onGenerateMessage:Te,isGeneratingMessage:j,onCommit:()=>void Ee({pushAfter:!1}),onCommitAndPush:()=>void Ee({pushAfter:!0}),commitAction:C,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Ra,{icon:!0,message:a(`gitView.empty.cleanTitle`),description:a(`mobile.changes.cleanDescription`)})})]}):Oe((0,$.jsx)(Ra,{message:a(`gitView.empty.selectSessionOrDirectory`)}))},Ra=e=>{let t=(0,Q.c)(13),{message:n,description:r,loading:i,icon:a}=e,o=i!==void 0&&i,s=a!==void 0&&a,c;t[0]===o?c=t[1]:(c=o?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):null,t[0]=o,t[1]=c);let l;t[2]===s?l=t[3]:(l=s?(0,$.jsx)(X,{name:`git-branch`,className:`size-6 text-muted-foreground`}):null,t[2]=s,t[3]=l);let u;t[4]===n?u=t[5]:(u=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[4]=n,t[5]=u);let d;t[6]===r?d=t[7]:(d=r?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r}):null,t[6]=r,t[7]=d);let f;return t[8]!==c||t[9]!==l||t[10]!==u||t[11]!==d?(f=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[c,l,u,d]})}),t[8]=c,t[9]=l,t[10]=u,t[11]=d,t[12]=f):f=t[12],f},za=e=>{let t=(0,Q.c)(20),{path:n,diff:r,fileExists:i,error:a,loading:o,targetLine:s,onBack:c,onRetry:l,hideHeader:u}=e,d=u!==void 0&&u,{t:f}=ee(),p;t[0]===n?p=t[1]:(p=$n(n)||`text`,t[0]=n,t[1]=p);let m=p,h;t[2]!==d||t[3]!==c||t[4]!==n||t[5]!==f?(h=d?null:(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/50 px-3 text-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":f(`header.actions.backAria`),onClick:c,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-2`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-header text-foreground`,children:n})})]}),t[2]=d,t[3]=c,t[4]=n,t[5]=f,t[6]=h):h=t[6];let g;t[7]!==r||t[8]!==a||t[9]!==i||t[10]!==m||t[11]!==o||t[12]!==l||t[13]!==n||t[14]!==f||t[15]!==s?(g=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:a?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:f(`mobile.changes.diffDetail.loadFailed`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:a}),(0,$.jsx)(G,{type:`button`,size:`sm`,variant:`outline`,onClick:l,children:f(`diffView.actions.retry`)})]})}):o?(0,$.jsx)(Ra,{loading:!0,message:f(`diffView.state.loadingDiff`)}):i?r?r.isBinary?(0,$.jsx)(Ra,{icon:!0,message:f(`diffView.binary.unavailable`)}):Qn(n)?(0,$.jsx)(Ra,{icon:!0,message:f(`mobile.changes.diffDetail.imageUnavailable`)}):(0,$.jsx)(wn,{className:`h-full overflow-y-auto overflow-x-hidden p-3 pwa-overlay-scroll`,"data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:(0,$.jsx)(Mr,{original:r.original,modified:r.modified,language:m,fileName:n,renderSideBySide:!1,wrapLines:!0,focusLine:s,layout:`inline`})}):(0,$.jsx)(Ra,{loading:!0,message:f(`diffView.state.loadingDiff`)}):(0,$.jsx)(Ra,{icon:!0,message:f(`mobile.changes.diffDetail.missingTitle`),description:f(`mobile.changes.diffDetail.missingDescription`)})}),t[7]=r,t[8]=a,t[9]=i,t[10]=m,t[11]=o,t[12]=l,t[13]=n,t[14]=f,t[15]=s,t[16]=g):g=t[16];let _;return t[17]!==h||t[18]!==g?(_=(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[h,g]}),t[17]=h,t[18]=g,t[19]=_):_=t[19],_},Ba=e(S(),1),Va=`data-oc-motion-id`,Ha=`data-oc-sheet-overscroll`,Ua=`html, body { overscroll-behavior-y: none; }`,Wa=[`input`,`textarea`,`select`,`[contenteditable]:not([contenteditable="false"])`,`[data-mobile-sheet-no-dismiss]`].join(`, `),Ga=e=>e.closest(`[data-oc-motion-id]`)?.getAttribute(`data-oc-motion-id`)??null,Ka=e=>{try{let t=e.contentDocument;return t?t.scrollingElement??t.documentElement:null}catch{return null}},qa=(e,t)=>Number.isFinite(e)&&Number.isFinite(t)&&e<=1&&t>0,Ja=(e,t,n)=>e?!0:qa(t,n),Ya=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.Element},Xa=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.HTMLElement},Za=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.HTMLStyleElement},Qa=(e,t)=>{if(typeof e.item==`function`){let n=e.item(t);if(n)return n}return e[t]??null},$a=(e,t)=>{for(let n=0;n<e.length;n+=1){let r=Qa(e,n);if(r?.identifier===t)return r}return null},eo=(e,t)=>{try{let n=e.defaultView?.getComputedStyle(t);if(!n)return!1;let r=n.overflowY;return(r===`auto`||r===`scroll`||r===`overlay`)&&t.scrollHeight>t.clientHeight+1}catch{return!1}},to=(e,t)=>{let n=[],r=new Set,i=t=>{!t||r.has(t)||eo(e,t)&&(r.add(t),n.push(t))},a=Ya(e,t)?t:null;for(;a&&(Xa(e,a)&&i(a),a!==e.documentElement&&a!==e.body);)a=a.parentElement;let o=e.scrollingElement??e.documentElement;return Xa(e,o)&&i(o),n},no=(e,t)=>{let n=to(e,t);if(n.length===0){let t=(e.scrollingElement??e.documentElement)?.scrollTop??1/0;return Number.isFinite(t)&&t<=1}return n.every(e=>e.scrollTop<=1)},ro=e=>{let t=e.closest(`[${Va}]`);if(t instanceof HTMLElement){let e=t.getBoundingClientRect().height;if(Number.isFinite(e)&&e>0)return e}return window.innerHeight||1},io=e=>{let t=null,n=()=>{t?.(),t=null;let n=(()=>{try{return e.contentDocument}catch{return null}})();if(!n)return;let r=Ga(e);if(!r)return;let i=null;if(!Za(n,n.querySelector(`style[${Ha}]`))){let e=n.createElement(`style`);e.setAttribute(Ha,`true`),e.textContent=Ua,(n.head??n.documentElement).appendChild(e),i=e}let a=null,o=()=>{a?.active&&a.controller.finish(`cancel`),a=null},s=t=>{if(o(),t.touches.length!==1||(Ya(n,t.target)?t.target:null)?.closest(Wa)||!no(n,t.target))return;let r=Qa(t.touches,0);if(!r)return;let i=ro(e);a={touchId:r.identifier,startX:r.screenX,startY:r.screenY,lastY:r.screenY,lastTime:t.timeStamp,lastVelocityTime:t.timeStamp,velocity:0,motionDistance:i,commitDistance:Tn(i,.1,40,64),active:!1,controller:null}},c=t=>{if(!a)return;if(t.touches.length!==1){o();return}let i=$a(t.touches,a.touchId);if(!i){o();return}let s=i.screenY-a.startY,c=i.screenX-a.startX,l=t.timeStamp-a.lastTime;if(a.velocity=En(a.velocity,i.screenY-a.lastY,l,t.timeStamp-a.lastVelocityTime,1),i.screenY!==a.lastY&&l>0&&(a.lastVelocityTime=t.timeStamp),a.lastY=i.screenY,a.lastTime=t.timeStamp,!a.active){if(!no(n,t.target)){a=null;return}if(!Ja(!1,Ka(e)?.scrollTop??0,s)){a=null;return}if(!vn(`bottom`,c,s,8,1))return;let i=Sn(r);if(!i?.begin(`dismiss`)){a=null;return}a={...a,active:!0,controller:i}}let u=a;if(!u.active)return;t.preventDefault();let d=_n(`bottom`,c,s);u.controller.update(xn(d,u.motionDistance))},l=e=>{if(!a)return;let t=a,n=$a(e.changedTouches,t.touchId);if(a=null,!t.active)return;if(!n){t.controller.finish(`cancel`);return}let r=e.timeStamp-t.lastTime;t.velocity=En(t.velocity,n.screenY-t.lastY,r,e.timeStamp-t.lastVelocityTime,1),n.screenY!==t.lastY&&r>0&&(t.lastVelocityTime=e.timeStamp),t.lastY=n.screenY,t.lastTime=e.timeStamp;let i=n.screenY-t.startY,o=n.screenX-t.startX,s=_n(`bottom`,o,i),c=yn(s,t.velocity,t.commitDistance,.65,12);t.controller.finish(c?`commit`:`cancel`),e.preventDefault()},u=()=>o();n.addEventListener(`touchstart`,s,{capture:!0,passive:!0}),n.addEventListener(`touchmove`,c,{capture:!0,passive:!1}),n.addEventListener(`touchend`,l,{capture:!0,passive:!1}),n.addEventListener(`touchcancel`,u,{capture:!0,passive:!0}),t=()=>{o(),n.removeEventListener(`touchstart`,s,!0),n.removeEventListener(`touchmove`,c,!0),n.removeEventListener(`touchend`,l,!0),n.removeEventListener(`touchcancel`,u,!0);try{i?.remove()}catch{}i=null}};return e.addEventListener(`load`,n),n(),()=>{e.removeEventListener(`load`,n),t?.()}},ao=Jn(()=>L(()=>import(`./ToolOutputDialog-CJu8DNrt.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52]))),oo=25e4,so=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),co=e=>{let t=so(e);return!t||t===`/`?t||`/`:t.split(`/`).filter(Boolean).at(-1)??t},lo=e=>{let t=so(e);if(!t||t===`/`)return null;let n=t.lastIndexOf(`/`);return n<=0?t.startsWith(`/`)?`/`:null:t.slice(0,n)},uo=(e,t)=>{let n=so(e),r=so(t);return!r||n===r?co(n):n.startsWith(`${r}/`)?n.slice(r.length+1):n},fo=e=>{if(typeof e!=`number`||!Number.isFinite(e)||e<0)return``;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`],n=e/1024;for(let e of t){if(n<1024||e===t[t.length-1])return`${n.toFixed(n>=10?0:1)} ${e}`;n/=1024}return``},po=e=>e.toLowerCase().endsWith(`.svg`)?``:o().authenticatedAsset(`/api/fs/raw`,{path:e}),mo=e=>/\.(md|mdx|markdown)$/i.test(e),ho=e=>{let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return`/api/fs/serve${t.startsWith(`/`)?t:`/${t}`}`},go=e=>o().authenticatedAsset(ho(e)),_o=e=>{let t=(0,Q.c)(148),{onClose:n,initialFilePath:r,directFilePreview:i,hideFileHeader:a}=e,o=r===void 0?null:r,s=i!==void 0&&i,c=a!==void 0&&a,{t:l}=ee(),{files:u}=mn(),d=er()??null,f;t[0]===d?f=t[1]:(f=so(d),t[0]=d,t[1]=f);let p=f,m;t[2]!==o||t[3]!==p?(m=()=>{let e=so(o);return e?{type:`file`,path:e,returnDirectory:lo(e)??p}:{type:`browser`,directory:p}},t[2]=o,t[3]=p,t[4]=m):m=t[4];let[h,g]=Z.useState(m),_=Z.useRef(null),[v,y]=Z.useState(``),b=j(To),x=j(Eo),S,C;t[5]===p?(S=t[6],C=t[7]):(S=()=>{p&&g(e=>e.type===`file`?e.returnDirectory?e:{...e,returnDirectory:lo(e.path)??p}:e.type===`browser`&&e.directory?e:{type:`browser`,directory:p})},C=[p],t[5]=p,t[6]=S,t[7]=C),Z.useEffect(S,C);let w,T;t[8]!==b||t[9]!==p||t[10]!==x?(T=()=>{if(!b||!p)return;let e=so(b);if(!e){x(null);return}y(``),g({type:`file`,path:e,returnDirectory:lo(e)??p}),x(null)},w=[b,p,x],t[8]=b,t[9]=p,t[10]=x,t[11]=w,t[12]=T):(w=t[11],T=t[12]),Z.useEffect(T,w);let E=h.type===`browser`?h.directory:h.returnDirectory,D=h.type===`browser`?h.directory:``,O=h.type===`file`?h.path:``,[k,A]=Z.useState(`preview`),M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{A(`preview`)},t[13]=M):M=t[13];let N;t[14]===O?N=t[15]:(N=[O],t[14]=O,t[15]=N),Z.useEffect(M,N);let P=jn(v,250),F;t[16]===v?F=t[17]:(F=v.trim(),t[16]=v,t[17]=F);let I=F,L;t[18]===P?L=t[19]:(L=P.trim(),t[18]=P,t[19]=L);let R=L,z;t[20]!==D||t[21]!==p?(z={scopeDirectory:p,directory:D},t[20]=D,t[21]=p,t[22]=z):z=t[22];let B=!!D,U;t[23]===B?U=t[24]:(U={enabled:B,refetchOnMount:`always`},t[23]=B,t[24]=U);let G=Pi(z,U),K;t[25]!==D||t[26]!==R?(K={directory:D,query:R,maxResults:40},t[25]=D,t[26]=R,t[27]=K):K=t[27];let te=!!(D&&R),q;t[28]===te?q=t[29]:(q={enabled:te},t[28]=te,t[29]=q);let ne=Ni(K,q),re;t[30]!==O||t[31]!==u||t[32]!==k?(re=O&&u.readFile&&(!Zn(O)||k===`source`)&&(!Qn(O)||O.toLowerCase().endsWith(`.svg`)),t[30]=O,t[31]=u,t[32]=k,t[33]=re):re=t[33];let ie=!!re,ae;t[34]!==O||t[35]!==p?(ae={scopeDirectory:p,path:O},t[34]=O,t[35]=p,t[36]=ae):ae=t[36];let oe;t[37]===ie?oe=t[38]:(oe={enabled:ie},t[37]=ie,t[38]=oe);let se=Ii(ae,oe),J;t[39]!==O||t[40]!==p?(J={scopeDirectory:p,path:O},t[39]=O,t[40]=p,t[41]=J):J=t[41];let ce;t[42]===ie?ce=t[43]:(ce={enabled:ie},t[42]=ie,t[43]=ce),Fi(J,ce);let le=G.data?.entries.slice().sort(Do)??[],ue;t[44]!==G.error||t[45]!==l?(ue=G.error?G.error instanceof Error?G.error.message:l(`mobile.files.error.listFailed`):null,t[44]=G.error,t[45]=l,t[46]=ue):ue=t[46];let Y=ue,de=G.isFetching,fe;t[47]===ne.data?fe=t[48]:(fe=ne.data??[],t[47]=ne.data,t[48]=fe);let pe=fe,me=!!(I&&R&&v===P&&ne.isFetching),he;t[49]!==se.data||t[50]!==l?(he=se.data&&se.data.length>oo?`${se.data.slice(0,oo)}\n\n${l(`mobile.files.file.truncated`)}`:se.data??``,t[49]=se.data,t[50]=l,t[51]=he):he=t[51];let ge=he,_e;t[52]!==O||t[53]!==se.error||t[54]!==u||t[55]!==l?(_e=O&&!u.readFile?l(`mobile.files.error.readUnavailable`):se.error?se.error instanceof Error?se.error.message:l(`filesView.error.readFileFailed`):null,t[52]=O,t[53]=se.error,t[54]=u,t[55]=l,t[56]=_e):_e=t[56];let ve=_e,ye=ie&&se.isFetching,be;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(be=e=>{y(``),g({type:`browser`,directory:e})},t[57]=be):be=t[57];let xe=be,Se;t[58]!==E||t[59]!==p?(Se=e=>{g({type:`file`,path:e,returnDirectory:E||p})},t[58]=E,t[59]=p,t[60]=Se):Se=t[60];let Ce=Se,we;t[61]!==s||t[62]!==n||t[63]!==h.returnDirectory||t[64]!==h.type?(we=()=>h.type===`file`?s?(n?.(),!0):(g({type:`browser`,directory:h.returnDirectory}),!0):!1,t[61]=s,t[62]=n,t[63]=h.returnDirectory,t[64]=h.type,t[65]=we):we=t[65];let Te=V(we),Ee=h.type===`file`,De;t[66]!==Te||t[67]!==Ee?(De={id:`mobile-files-detail`,active:Ee,layer:`overlay`,onBack:Te,surfaceRef:_},t[66]=Te,t[67]=Ee,t[68]=De):De=t[68],Vn(De);let Oe;t[69]===l?Oe=t[70]:(Oe=async e=>{(await H(e)).ok||Ze.error(l(`mobile.files.toast.copyFailed`))},t[69]=l,t[70]=Oe);let ke=Oe,Ae;t[71]!==ge||t[72]!==l?(Ae=async()=>{(await H(ge)).ok?Ze.success(l(`mobile.files.toast.contentCopied`)):Ze.error(l(`mobile.files.toast.copyFailed`))},t[71]=ge,t[72]=l,t[73]=Ae):Ae=t[73];let je=Ae;if(!p){let e;t[74]===l?e=t[75]:(e=l(`mobile.files.empty.noDirectory`),t[74]=l,t[75]=e);let n;return t[76]===e?n=t[77]:(n=(0,$.jsx)(wo,{message:e}),t[76]=e,t[77]=n),n}if(h.type===`file`){let e;t[78]!==ke||t[79]!==h.path?(e=()=>void ke(h.path),t[78]=ke,t[79]=h.path,t[80]=e):e=t[80];let n;t[81]===je?n=t[82]:(n=()=>void je(),t[81]=je,t[82]=n);let r;return t[83]!==Te||t[84]!==ge||t[85]!==ve||t[86]!==c||t[87]!==k||t[88]!==ye||t[89]!==h.path||t[90]!==e||t[91]!==n?(r=(0,$.jsx)(`div`,{ref:_,className:`flex h-full min-h-0 flex-col`,children:(0,$.jsx)(xo,{path:h.path,content:ge,error:ve,isLoading:ye,hideHeader:c,htmlViewMode:k,onHtmlViewModeChange:A,onBack:Te,onCopyPath:e,onCopyContent:n})}),t[83]=Te,t[84]=ge,t[85]=ve,t[86]=c,t[87]=k,t[88]=ye,t[89]=h.path,t[90]=e,t[91]=n,t[92]=r):r=t[92],r}let Me;t[93]!==p||t[94]!==h.directory||t[95]!==l?(Me=h.directory===p?l(`mobile.files.rootDirectory`):co(h.directory),t[93]=p,t[94]=h.directory,t[95]=l,t[96]=Me):Me=t[96];let Ne=Me,Pe;t[97]!==v||t[98]!==pe?(Pe=v.trim()?pe:[],t[97]=v,t[98]=pe,t[99]=Pe):Pe=t[99];let Fe=Pe,Ie,Le,Re,ze;if(t[100]!==n||t[101]!==v||t[102]!==p||t[103]!==h.directory||t[104]!==l){let e=lo(h.directory),r=h.directory!==p&&e!==null&&(e===p||e.startsWith(`${p}/`)),i=r&&!v.trim(),a=r?e:null;ze=`flex h-full flex-col overflow-hidden bg-background text-foreground`,Ie=`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,t[109]!==n||t[110]!==l?(Le=n?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":l(`mobile.surface.closeAria`),onClick:n,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,t[109]=n,t[110]=l,t[111]=Le):Le=t[111],Re=i&&a?(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":l(`mobile.files.backToParentAria`,{name:co(a)}),onClick:()=>xe(a),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}):null,t[100]=n,t[101]=v,t[102]=p,t[103]=h.directory,t[104]=l,t[105]=Ie,t[106]=Le,t[107]=Re,t[108]=ze}else Ie=t[105],Le=t[106],Re=t[107],ze=t[108];let Be;t[112]===Ne?Be=t[113]:(Be=(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label text-foreground`,children:Ne})}),t[112]=Ne,t[113]=Be);let Ve;t[114]===l?Ve=t[115]:(Ve=l(`mobile.files.refreshAria`),t[114]=l,t[115]=Ve);let He;t[116]===G?He=t[117]:(He=()=>void G.refetch(),t[116]=G,t[117]=He);let Ue;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(Ue={touchAction:`manipulation`},t[118]=Ue):Ue=t[118];let We=de&&`animate-spin`,Ge;t[119]===We?Ge=t[120]:(Ge=W(`size-5`,We),t[119]=We,t[120]=Ge);let Ke;t[121]===Ge?Ke=t[122]:(Ke=(0,$.jsx)(X,{name:`refresh`,className:Ge}),t[121]=Ge,t[122]=Ke);let qe;t[123]!==Ve||t[124]!==He||t[125]!==Ke?(qe=(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":Ve,onClick:He,style:Ue,children:Ke}),t[123]=Ve,t[124]=He,t[125]=Ke,t[126]=qe):qe=t[126];let Je;t[127]!==Ie||t[128]!==Le||t[129]!==Re||t[130]!==Be||t[131]!==qe?(Je=(0,$.jsxs)(`header`,{className:Ie,children:[Le,Re,Be,qe]}),t[127]=Ie,t[128]=Le,t[129]=Re,t[130]=Be,t[131]=qe,t[132]=Je):Je=t[132];let Ye;t[133]===Symbol.for(`react.memo_cache_sentinel`)?(Ye=(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),t[133]=Ye):Ye=t[133];let Xe;t[134]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=e=>y(e.target.value),t[134]=Xe):Xe=t[134];let Qe;t[135]===l?Qe=t[136]:(Qe=l(`mobile.files.search.placeholder`),t[135]=l,t[136]=Qe);let $e;t[137]!==v||t[138]!==Qe?($e=(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,"data-mobile-sheet-no-dismiss":``,children:(0,$.jsxs)(`div`,{className:`relative`,children:[Ye,(0,$.jsx)(qt,{type:`text`,inputMode:`search`,value:v,onChange:Xe,placeholder:Qe,className:`h-11 pl-9`})]})}),t[137]=v,t[138]=Qe,t[139]=$e):$e=t[139];let et=wn,tt=Y?(0,$.jsx)(wo,{message:Y}):v.trim()?(0,$.jsx)(yo,{results:Fe,isSearching:me,onOpenFile:Ce}):(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:[le.length===0&&!de?(0,$.jsx)(`div`,{className:`px-4 py-8 text-center typography-body text-muted-foreground`,children:l(`mobile.files.empty.directory`)}):null,le.map(e=>(0,$.jsx)(vo,{name:e.name,path:e.path,directory:e.isDirectory,meta:e.isDirectory?void 0:fo(e.size),onClick:()=>e.isDirectory?xe(e.path):Ce(e.path)},e.path))]}),nt;t[140]!==et||t[141]!==tt?(nt=(0,$.jsx)(et,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto px-4 pb-3`,children:tt}),t[140]=et,t[141]=tt,t[142]=nt):nt=t[142];let rt;return t[143]!==ze||t[144]!==Je||t[145]!==$e||t[146]!==nt?(rt=(0,$.jsxs)(`div`,{className:ze,children:[Je,$e,nt]}),t[143]=ze,t[144]=Je,t[145]=$e,t[146]=nt,t[147]=rt):rt=t[147],rt},vo=e=>{let t=(0,Q.c)(16),{name:n,path:r,directory:i,meta:a,onClick:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]!==i||t[2]!==r?(c=i?(0,$.jsx)(X,{name:`folder-3-fill`,className:`size-5 shrink-0 text-muted-foreground`}):(0,$.jsx)(Et,{filePath:r,className:`size-5 shrink-0`}),t[1]=i,t[2]=r,t[3]=c):c=t[3];let l;t[4]===n?l=t[5]:(l=(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:n}),t[4]=n,t[5]=l);let u;t[6]===a?u=t[7]:(u=a?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:a}):null,t[6]=a,t[7]=u);let d;t[8]===i?d=t[9]:(d=i?(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground/60`}):null,t[8]=i,t[9]=d);let f;return t[10]!==o||t[11]!==c||t[12]!==l||t[13]!==u||t[14]!==d?(f=(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-14 w-full items-center gap-3 border-b border-border/30 px-3 py-2.5 text-left transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,onClick:o,style:s,children:[c,l,u,d]}),t[10]=o,t[11]=c,t[12]=l,t[13]=u,t[14]=d,t[15]=f):f=t[15],f},yo=e=>{let t=(0,Q.c)(10),{results:n,isSearching:r,onOpenFile:i}=e,{t:a}=ee(),o=so(er()??null);if(r){let e;t[0]===a?e=t[1]:(e=a(`common.loading`),t[0]=a,t[1]=e);let n;return t[2]===e?n=t[3]:(n=(0,$.jsx)(wo,{loading:!0,message:e}),t[2]=e,t[3]=n),n}if(n.length===0){let e;t[4]===a?e=t[5]:(e=a(`mobile.files.search.empty`),t[4]=a,t[5]=e);let n;return t[6]===e?n=t[7]:(n=(0,$.jsx)(wo,{message:e}),t[6]=e,t[7]=n),n}let s=n.map(e=>(0,$.jsx)(vo,{name:co(e.path),path:e.path,directory:!1,meta:uo(e.path,o),onClick:()=>i(e.path)},e.path)),c;return t[8]===s?c=t[9]:(c=(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:s}),t[8]=s,t[9]=c),c},bo=e=>{let t=(0,Q.c)(24),{path:n,htmlViewMode:r,htmlFullscreen:i,onToggleHtmlViewMode:a,onEnterHtmlFullscreen:o,onCopyPath:s,onCopyContent:c}=e,{t:l}=ee(),u;t[0]===n?u=t[1]:(u=Zn(n),t[0]=n,t[1]=u);let d=u,f;t[2]!==d||t[3]!==i||t[4]!==r||t[5]!==o||t[6]!==a||t[7]!==l?(f=d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,onClick:a,"aria-label":l(r===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(X,{name:r===`preview`?`file-code`:`eye`,className:`size-4`})}),i?null:(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,onClick:o,"aria-label":l(`mobile.files.html.fullscreenAria`),children:(0,$.jsx)(X,{name:`fullscreen`,className:`size-4`})})]}):null,t[2]=d,t[3]=i,t[4]=r,t[5]=o,t[6]=a,t[7]=l,t[8]=f):f=t[8];let p;t[9]!==d||t[10]!==c||t[11]!==n||t[12]!==l?(p=!Qn(n)&&!d?(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,onClick:c,"aria-label":l(`mobile.files.copyContentAria`),children:(0,$.jsx)(X,{name:`file-copy`,className:`size-4`})}):null,t[9]=d,t[10]=c,t[11]=n,t[12]=l,t[13]=p):p=t[13];let m;t[14]===l?m=t[15]:(m=l(`mobile.files.copyPathAria`),t[14]=l,t[15]=m);let h;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(X,{name:`clipboard`,className:`size-4`}),t[16]=h):h=t[16];let g;t[17]!==s||t[18]!==m?(g=(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,onClick:s,"aria-label":m,children:h}),t[17]=s,t[18]=m,t[19]=g):g=t[19];let _;return t[20]!==f||t[21]!==p||t[22]!==g?(_=(0,$.jsxs)($.Fragment,{children:[f,p,g]}),t[20]=f,t[21]=p,t[22]=g,t[23]=_):_=t[23],_},xo=e=>{let n=(0,Q.c)(100),{path:r,content:a,error:o,isLoading:c,hideHeader:l,htmlViewMode:f,onHtmlViewModeChange:p,onBack:m,onCopyPath:h,onCopyContent:g}=e,_=l!==void 0&&l,{t:v}=ee(),y=Z.useRef(null),b=Qn(r)&&!r.toLowerCase().endsWith(`.svg`)?r:``,x;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=s(),n[0]=x):x=n[0];let S=x,C;n[1]===b?C=n[2]:(C=b&&i()?`${S}|${b}`:``,n[1]=b,n[2]=C);let w=C,T=b&&!w?`${S}|${b}`:``,[E,D]=Z.useState(``),[O,k]=Z.useState(``),[A,j]=Z.useState(null),[M,N]=Z.useState(!1),P;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(P={open:!1,title:``,content:``},n[3]=P):P=n[3];let[F,I]=Z.useState(P),L,R;n[4]===T?(L=n[5],R=n[6]):(L=()=>{if(!T){D(``);return}let e=!1;return D(``),t(u()).then(t=>{!e&&t&&D(T)}).catch(Oo),()=>{e=!0}},R=[T],n[4]=T,n[5]=L,n[6]=R),Z.useEffect(L,R);let z,B;n[7]!==b||n[8]!==w||n[9]!==v?(z=()=>{if(!w){k(``),j(null),N(!1);return}let e=!1,t=``;return k(``),j(null),N(!0),d(`/api/fs/raw`,{query:{path:b}}).then(async e=>{if(!e.ok)throw Error(v(`filesView.error.readFileFailed`));return e.blob()}).then(n=>{if(t=URL.createObjectURL(n),e){URL.revokeObjectURL(t);return}k(t)}).catch(t=>{e||j(t instanceof Error?t.message:v(`filesView.error.readFileFailed`))}).finally(()=>{e||N(!1)}),()=>{e=!0,t&&URL.revokeObjectURL(t)}},B=[b,w,v],n[7]=b,n[8]=w,n[9]=v,n[10]=z,n[11]=B):(z=n[10],B=n[11]),Z.useEffect(z,B);let H=!!(T&&E!==T),U;n[12]!==H||n[13]!==r||n[14]!==w||n[15]!==O?(U=w?O:H?``:po(r),n[12]=H,n[13]=r,n[14]=w,n[15]=O,n[16]=U):U=n[16];let W=U,K=o??A,te;n[17]===r?te=n[18]:(te=co(r),n[17]=r,n[18]=te);let q=te,ne;n[19]!==a||n[20]!==r?(ne=Qn(r)?`data:${Xn(r)};utf8,${encodeURIComponent(a)}`:``,n[19]=a,n[20]=r,n[21]=ne):ne=n[21];let re=ne,ie;n[22]!==a||n[23]!==re||n[24]!==W||n[25]!==r?(ie=W||(Qn(r)&&a?re:``),n[22]=a,n[23]=re,n[24]=W,n[25]=r,n[26]=ie):ie=n[26];let ae=ie,oe;n[27]!==q||n[28]!==b||n[29]!==r||n[30]!==ae?(oe=()=>{let e=b||ae;e&&I({open:!0,title:q,content:``,metadata:{tool:`image-preview`,filename:q,mime:Xn(r)},image:{url:e,mimeType:Xn(r),filename:q}})},n[27]=q,n[28]=b,n[29]=r,n[30]=ae,n[31]=oe):oe=n[31];let se=V(oe),J;n[32]===Symbol.for(`react.memo_cache_sentinel`)?(J=e=>{I(t=>t.open===e?t:{...t,open:e})},n[32]=J):J=n[32];let ce=V(J),le;n[33]===r?le=n[34]:(le=Zn(r),n[33]=r,n[34]=le);let ue=le,[Y,de]=Z.useState(!1),fe=Z.useRef(null),pe;n[35]===Symbol.for(`react.memo_cache_sentinel`)?(pe=()=>{de(!1)},n[35]=pe):pe=n[35];let me;n[36]===r?me=n[37]:(me=[r],n[36]=r,n[37]=me),Z.useEffect(pe,me);let he;n[38]!==f||n[39]!==p?(he=()=>{p(f===`preview`?`source`:`preview`)},n[38]=f,n[39]=p,n[40]=he):he=n[40];let ge=V(he),_e;n[41]===Symbol.for(`react.memo_cache_sentinel`)?(_e=()=>{de(!0)},n[41]=_e):_e=n[41];let ve=V(_e),ye;n[42]===Symbol.for(`react.memo_cache_sentinel`)?(ye=()=>(de(!1),!0),n[42]=ye):ye=n[42];let be=V(ye),xe=ue&&Y,Se;n[43]!==be||n[44]!==xe?(Se={id:`mobile-html-fullscreen`,active:xe,layer:`overlay`,onBack:be,surfaceRef:fe},n[43]=be,n[44]=xe,n[45]=Se):Se=n[45],Vn(Se);let Ce;n[46]!==ve||n[47]!==Y||n[48]!==f||n[49]!==g||n[50]!==h||n[51]!==r||n[52]!==ge?(Ce=(0,$.jsx)(bo,{path:r,htmlViewMode:f,htmlFullscreen:Y,onToggleHtmlViewMode:ge,onEnterHtmlFullscreen:ve,onCopyPath:h,onCopyContent:g}),n[46]=ve,n[47]=Y,n[48]=f,n[49]=g,n[50]=h,n[51]=r,n[52]=ge,n[53]=Ce):Ce=n[53];let we=Ce,Te;n[54]!==a||n[55]!==o||n[56]!==f||n[57]!==c||n[58]!==r||n[59]!==v?(Te=f===`source`?c?(0,$.jsx)(wo,{loading:!0,message:v(`filesView.state.loading`)}):o?(0,$.jsx)(wo,{message:o}):(0,$.jsx)(Co,{path:r,content:a}):(0,$.jsx)(So,{path:r}),n[54]=a,n[55]=o,n[56]=f,n[57]=c,n[58]=r,n[59]=v,n[60]=Te):Te=n[60];let Ee=Te,De;n[61]!==be||n[62]!==ue||n[63]!==Ee||n[64]!==Y||n[65]!==f||n[66]!==q||n[67]!==v||n[68]!==ge?(De=ue?(0,$.jsxs)(`div`,{ref:fe,"data-mobile-html-preview":f===`preview`&&!Y?`true`:void 0,"data-mobile-html-fullscreen":f===`preview`&&Y?`true`:void 0,className:Y?`fixed inset-0 z-[80] flex flex-col bg-background text-foreground`:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[Y?(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center gap-2 border-b border-border/50 px-3 pb-2 pt-[max(0.5rem,env(safe-area-inset-top))]`,children:[(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,onClick:be,"aria-label":v(`mobile.files.html.exitFullscreenAria`),className:`shrink-0 text-muted-foreground`,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-header text-foreground`,children:q}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,onClick:ge,"aria-label":v(f===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(X,{name:f===`preview`?`file-code`:`eye`,className:`size-4`})})]}):null,(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden bg-background`,children:Ee})]}):null,n[61]=be,n[62]=ue,n[63]=Ee,n[64]=Y,n[65]=f,n[66]=q,n[67]=v,n[68]=ge,n[69]=De):De=n[69];let Oe=De,ke;n[70]!==we||n[71]!==_||n[72]!==q||n[73]!==m||n[74]!==v?(ke=_?(0,$.jsx)(gn,{children:we}):(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/50 px-3 text-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":v(`header.actions.backAria`),onClick:m,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-header text-foreground`,children:q})}),we]}),n[70]=we,n[71]=_,n[72]=q,n[73]=m,n[74]=v,n[75]=ke):ke=n[75];let Ae;n[76]!==a||n[77]!==ue||n[78]!==Y||n[79]!==Oe||n[80]!==H||n[81]!==K||n[82]!==q||n[83]!==c||n[84]!==M||n[85]!==se||n[86]!==r||n[87]!==ae||n[88]!==v?(Ae=ue?Y&&typeof document<`u`?(0,Ba.createPortal)(Oe,document.body):Oe:c||H||M?(0,$.jsx)(wo,{loading:!0,message:v(`filesView.state.loading`)}):K?(0,$.jsx)(wo,{message:K}):Qn(r)&&ae?(0,$.jsx)(wn,{className:`h-full overflow-auto p-4`,children:(0,$.jsx)(`button`,{type:`button`,className:`mx-auto block max-h-full max-w-full cursor-zoom-in rounded-lg border-0 bg-transparent p-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:se,"aria-label":q,children:(0,$.jsx)(`img`,{src:ae,alt:q,className:`mx-auto max-h-full max-w-full rounded-lg object-contain`,draggable:!1})})}):(0,$.jsx)(Co,{path:r,content:a}),n[76]=a,n[77]=ue,n[78]=Y,n[79]=Oe,n[80]=H,n[81]=K,n[82]=q,n[83]=c,n[84]=M,n[85]=se,n[86]=r,n[87]=ae,n[88]=v,n[89]=Ae):Ae=n[89];let je;n[90]===Ae?je=n[91]:(je=(0,$.jsx)(`div`,{ref:y,className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:Ae}),n[90]=Ae,n[91]=je);let Me;n[92]===Symbol.for(`react.memo_cache_sentinel`)?(Me=(0,$.jsx)(_t,{containerRef:y}),n[92]=Me):Me=n[92];let Ne;n[93]!==ce||n[94]!==F?(Ne=F.open?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ao,{popup:F,onOpenChange:ce,isMobile:!0})}):null,n[93]=ce,n[94]=F,n[95]=Ne):Ne=n[95];let Pe;return n[96]!==ke||n[97]!==je||n[98]!==Ne?(Pe=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[ke,je,Me,Ne]}),n[96]=ke,n[97]=je,n[98]=Ne,n[99]=Pe):Pe=n[99],Pe},So=e=>{let a=(0,Q.c)(29),{path:o}=e,{t:s}=ee(),c;a[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=i(),a[0]=c):c=a[0];let l=c,f=Z.useRef(null),[p,m]=Z.useState(``),[h,g]=Z.useState(0),[_,v]=Z.useState(null),[y,b]=Z.useState(``),x,S;a[1]!==o||a[2]!==s?(x=()=>{let e=!1;if(m(``),v(null),b(``),l)return d(ho(o)).then(async e=>{if(!e.ok)throw Error(s(`filesView.error.readFileFailed`));return e.text()}).then(t=>{e||(b(t),m(o))}).catch(t=>{e||(v(t instanceof Error?t.message:s(`filesView.error.readFileFailed`)),m(o))}),()=>{e=!0};let i=u(),a=n(i);t(i).then(t=>{e||!t||(m(o),v(null))}).catch(t=>{e||(v(t instanceof Error?t.message:s(`filesView.error.readFileFailed`)),m(o))});let c=r(()=>{e||(m(o),g(ko),v(null))});return()=>{e=!0,a(),c()}},S=[o,l,s],a[1]=o,a[2]=s,a[3]=x,a[4]=S):(x=a[3],S=a[4]),Z.useEffect(x,S);let C;a[5]!==o||a[6]!==p?(C=()=>{if(p!==o)return;let e=f.current;if(e)return io(e)},a[5]=o,a[6]=p,a[7]=C):C=a[7];let w;if(a[8]!==h||a[9]!==o||a[10]!==p||a[11]!==y?(w=[h,o,p,y],a[8]=h,a[9]=o,a[10]=p,a[11]=y,a[12]=w):w=a[12],Z.useEffect(C,w),_){let e;return a[13]===_?e=a[14]:(e=(0,$.jsx)(wo,{message:_}),a[13]=_,a[14]=e),e}if(p!==o){let e;a[15]===s?e=a[16]:(e=s(`filesView.state.loading`),a[15]=s,a[16]=e);let t;return a[17]===e?t=a[18]:(t=(0,$.jsx)(wo,{loading:!0,message:e}),a[17]=e,a[18]=t),t}let T;a[19]===o?T=a[20]:(T=l?void 0:go(o),a[19]=o,a[20]=T);let E=l?y:void 0,D;a[21]===Symbol.for(`react.memo_cache_sentinel`)?(D={backgroundColor:`var(--surface-background)`},a[21]=D):D=a[21];let O;a[22]===s?O=a[23]:(O=s(`filesView.editor.htmlPreviewTitle`),a[22]=s,a[23]=O);let k;return a[24]!==h||a[25]!==T||a[26]!==E||a[27]!==O?(k=(0,$.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:(0,$.jsx)(`iframe`,{ref:f,src:T,srcDoc:E,className:`h-full min-h-0 w-full flex-1 border-none bg-background`,style:D,sandbox:`allow-scripts allow-same-origin allow-forms`,title:O},h)}),a[24]=h,a[25]=T,a[26]=E,a[27]=O,a[28]=k):k=a[28],k},Co=e=>{let t=(0,Q.c)(30),{path:n,content:r}=e,{currentTheme:i,availableThemes:a,lightThemeId:o,darkThemeId:s}=ln(),c;t[0]!==a||t[1]!==o?(c=a.find(e=>e.metadata.id===o)??pn(!1),t[0]=a,t[1]=o,t[2]=c):c=t[2];let l=c,u;t[3]!==a||t[4]!==s?(u=a.find(e=>e.metadata.id===s)??pn(!0),t[3]=a,t[4]=s,t[5]=u):u=t[5];let d=u,f,p;t[6]!==d||t[7]!==l?(f=()=>{Gn(l),Gn(d)},p=[d,l],t[6]=d,t[7]=l,t[8]=f,t[9]=p):(f=t[8],p=t[9]),Z.useEffect(f,p);let m;t[10]!==d.metadata.id||t[11]!==l.metadata.id?(m={light:l.metadata.id,dark:d.metadata.id},t[10]=d.metadata.id,t[11]=l.metadata.id,t[12]=m):m=t[12];let h=m;if(mo(n)){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(wn,{className:`h-full overflow-y-auto px-4 py-4`,children:(0,$.jsx)(qn,{content:r,enableFileReferences:!1})}),t[13]=r,t[14]=e),e}let g;t[15]===n?g=t[16]:(g=co(n),t[15]=n,t[16]=g);let _;t[17]===n?_=t[18]:(_=$n(n)||void 0,t[17]=n,t[18]=_);let v;t[19]!==r||t[20]!==g||t[21]!==_?(v={name:g,contents:r,lang:_},t[19]=r,t[20]=g,t[21]=_,t[22]=v):v=t[22];let y=i.metadata.variant===`dark`?`dark`:`light`,b;t[23]!==h||t[24]!==y?(b={disableFileHeader:!0,overflow:`wrap`,theme:h,themeType:y,unsafeCSS:Nr},t[23]=h,t[24]=y,t[25]=b):b=t[25];let x;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(x={minHeight:`100%`},t[26]=x):x=t[26];let S;return t[27]!==b||t[28]!==v?(S=(0,$.jsx)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:(0,$.jsx)(wn,{className:`min-h-0 flex-1 overflow-auto bg-[var(--syntax-base-background)]`,children:(0,$.jsx)(z,{file:v,options:b,className:`block min-h-full w-full`,style:x})})}),t[27]=b,t[28]=v,t[29]=S):S=t[29],S},wo=e=>{let t=(0,Q.c)(7),{message:n,loading:r}=e,i=r!==void 0&&r,a;t[0]===i?a=t[1]:(a=i?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):(0,$.jsx)(X,{name:`folder-open-fill`,className:`size-6 text-muted-foreground`}),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[2]=n,t[3]=o);let s;return t[4]!==a||t[5]!==o?(s=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[a,o]})}),t[4]=a,t[5]=o,t[6]=s):s=t[6],s};function To(e){return e.pendingFileFocusPath}function Eo(e){return e.setPendingFileFocusPath}function Do(e,t){return e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1}function Oo(){}function ko(e){return e+1}var Ao=v(e=>({expandedParents:{},toggleParent:t=>e(e=>{let n={...e.expandedParents};return n[t]?delete n[t]:n[t]=!0,{expandedParents:n}})})),jo=v()(y(e=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(t,n)=>e(e=>({projectExpanded:{...e.projectExpanded,[t]:n}})),setWorktreeExpanded:(t,n)=>e(e=>({worktreeExpanded:{...e.worktreeExpanded,[t]:n}}))}),{name:`mobile-session-tree`,storage:p()}));typeof window<`u`&&a(e=>{l(e)&&jo.persist.rehydrate()});var Mo=36,No=18,Po=e=>e.parentID??null,Fo=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Io=e=>{let t=e;return Fo(t.directory??t.project?.worktree??null)},Lo=e=>{let t=Fo(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},Ro=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},zo=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),Bo=e=>{if(e<=0)return``;let t=Date.now()-e;if(t<6e4)return`now`;let n=Math.floor(t/6e4);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r<24)return`${r}h`;let i=Math.floor(r/24);return i<7?`${i}d`:new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))},Vo=(e,t)=>{let n=Fo(e),r=Fo(t);return!!(n&&r&&(n===r||n.startsWith(`${r}/`)))},Ho=(e,t)=>e.worktrees.find(e=>Fo(e.path)===t)??null,Uo=(e,t)=>t===e.path||!!Ho(e,t),Wo=(e,t)=>{let n=Fo(t);return n?e.find(e=>Uo(e,n))??null:null},Go=(e,t,n)=>!n||`${e.title??``} ${e.id} ${Io(e)} ${t}`.toLowerCase().includes(n),Ko=e=>{let t=(0,Q.c)(14),{project:n,size:r}=e,i=r===void 0?`md`:r,a=i===`sm`?`size-6 rounded-md`:`size-8 rounded-lg`,o=i===`sm`?`size-3.5`:`size-4`,s=n.icon?Wt[n.icon]:null,c=n.color?Gt[n.color]:void 0,l=s??`folder-open`,u;t[0]===c?u=t[1]:(u=c?{color:c}:void 0,t[0]=c,t[1]=u);let d;t[2]!==o||t[3]!==l||t[4]!==u?(d=(0,$.jsx)(X,{name:l,className:o,style:u}),t[2]=o,t[3]=l,t[4]=u,t[5]=d):d=t[5];let f=d,p;t[6]===a?p=t[7]:(p=W(`flex shrink-0 items-center justify-center overflow-hidden text-muted-foreground`,a),t[6]=a,t[7]=p);let m;t[8]!==f||t[9]!==n?(m=n.iconImage?(0,$.jsx)(Ht,{project:n,className:`size-full object-contain`,fallback:f}):f,t[8]=f,t[9]=n,t[10]=m):m=t[10];let h;return t[11]!==p||t[12]!==m?(h=(0,$.jsx)(`span`,{className:p,children:m}),t[11]=p,t[12]=m,t[13]=h):h=t[13],h},qo=e=>{let t=(0,Q.c)(5),{expanded:n}=e,r=n?`rotate-0`:`-rotate-90`,i;t[0]===r?i=t[1]:(i=W(`flex size-5 shrink-0 items-center justify-center text-muted-foreground/70 transition-transform duration-150`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4`}),t[2]=a):a=t[2];let o;return t[3]===i?o=t[4]:(o=(0,$.jsx)(`span`,{"aria-hidden":!0,className:i,children:a}),t[3]=i,t[4]=o),o},Jo=e=>{let t=(0,Q.c)(2),{ariaLabel:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`span`,{className:`inline-block size-1.5 shrink-0 rounded-full bg-primary`,"aria-label":n}),t[0]=n,t[1]=r),r},Yo=e=>{let t=(0,Q.c)(12),{onClick:n,className:r}=e,{t:i}=ee(),a;t[0]===i?a=t[1]:(a=i(`sessions.sidebar.project.actions.newWorktree`),t[0]=i,t[1]=a);let o=a,s;t[2]===r?s=t[3]:(s=W(`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,r),t[2]=r,t[3]=s);let c;t[4]===n?c=t[5]:(c=e=>{e.stopPropagation(),n()},t[4]=n,t[5]=c);let l,u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l={touchAction:`manipulation`},u=(0,$.jsx)(X,{name:`node-tree`,className:`size-4`}),t[6]=l,t[7]=u):(l=t[6],u=t[7]);let d;return t[8]!==o||t[9]!==s||t[10]!==c?(d=(0,$.jsx)(`button`,{type:`button`,className:s,"aria-label":o,title:o,onClick:c,style:l,children:u}),t[8]=o,t[9]=s,t[10]=c,t[11]=d):d=t[11],d},Xo=e=>{let t=(0,Q.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)(X,{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)(G,{type:`button`,variant:o,size:`default`,className:`min-h-12 w-full justify-start gap-3 rounded-xl px-3 typography-ui-label`,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},Zo=e=>{let t=(0,Q.c)(100),{session:n,active:r,indent:i,contextLabel:a,confirmingArchive:o,hasChildren:s,expanded:c,onToggleChildren:l,onSelect:u,onRequestArchive:d,onConfirmArchive:f,onStop:p,stopAriaLabel:m,longPressHandlers:h,highlightQuery:g}=e,_=o!==void 0&&o,v=s!==void 0&&s,y=c!==void 0&&c,{t:b}=ee(),x;t[0]===n?x=t[1]:(x=Bo(Ro(n)),t[0]=n,t[1]=x);let S=x,C,w,T,E,D,O,k,A,j,M,N,P,F,I,L,R,z,B;if(t[2]!==r||t[3]!==_||t[4]!==y||t[5]!==v||t[6]!==g||t[7]!==i||t[8]!==h.onContextMenu||t[9]!==h.onPointerCancel||t[10]!==h.onPointerDown||t[11]!==h.onPointerMove||t[12]!==h.onPointerUp||t[13]!==h.pressed||t[14]!==u||t[15]!==l||t[16]!==n.title||t[17]!==b){B=n.title?.trim()||b(`mobile.sessions.untitled`);let e=r&&!_&&`bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]`,a=_&&`bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]`;t[36]!==e||t[37]!==a?(N=W(`relative flex items-center gap-1 transition-colors`,e,a),t[36]=e,t[37]=a,t[38]=N):N=t[38],t[39]!==y||t[40]!==v||t[41]!==i||t[42]!==l||t[43]!==b?(P=v&&l?(0,$.jsx)(`button`,{type:`button`,className:`absolute z-10 flex w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,style:{left:Math.max(i-32,2),top:0,bottom:0,touchAction:`manipulation`},"aria-label":b(y?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:e=>{e.stopPropagation(),l()},children:(0,$.jsx)(X,{name:`arrow-down-s`,className:W(`size-[18px] transition-transform duration-150`,y?`rotate-0`:`-rotate-90`)})}):null,t[39]=y,t[40]=v,t[41]=i,t[42]=l,t[43]=b,t[44]=P):P=t[44],C=`button`;let o=_&&`opacity-50`,s=h.pressed&&`bg-interactive-active scale-[0.99]`;t[45]!==o||t[46]!==s?(w=W(`flex min-h-12 min-w-0 flex-1 items-center gap-2.5 py-2 pr-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,o,s),t[45]=o,t[46]=s,t[47]=w):w=t[47],t[48]===i?T=t[49]:(T={paddingLeft:i,touchAction:`manipulation`},t[48]=i,t[49]=T),E=u,D=h.onPointerDown,O=h.onPointerMove,k=h.onPointerUp,A=h.onPointerCancel,j=h.onContextMenu,M=_,z=`flex min-w-0 flex-1 flex-col`,L=`flex items-center gap-2.5`;let c=r?`bg-primary`:`bg-muted-foreground/30`,d;t[50]===c?d=t[51]:(d=W(`size-1.5 shrink-0 rounded-full`,c),t[50]=c,t[51]=d),t[52]===d?R=t[53]:(R=(0,$.jsx)(`span`,{className:d,"aria-hidden":!0}),t[52]=d,t[53]=R);let f=r?`text-primary`:`text-foreground`;t[54]===f?F=t[55]:(F=W(`block min-w-0 flex-1 truncate typography-ui-label`,f),t[54]=f,t[55]=F),I=g?Yt(B,g):B,t[2]=r,t[3]=_,t[4]=y,t[5]=v,t[6]=g,t[7]=i,t[8]=h.onContextMenu,t[9]=h.onPointerCancel,t[10]=h.onPointerDown,t[11]=h.onPointerMove,t[12]=h.onPointerUp,t[13]=h.pressed,t[14]=u,t[15]=l,t[16]=n.title,t[17]=b,t[18]=C,t[19]=w,t[20]=T,t[21]=E,t[22]=D,t[23]=O,t[24]=k,t[25]=A,t[26]=j,t[27]=M,t[28]=N,t[29]=P,t[30]=F,t[31]=I,t[32]=L,t[33]=R,t[34]=z,t[35]=B}else C=t[18],w=t[19],T=t[20],E=t[21],D=t[22],O=t[23],k=t[24],A=t[25],j=t[26],M=t[27],N=t[28],P=t[29],F=t[30],I=t[31],L=t[32],R=t[33],z=t[34],B=t[35];let V;t[56]!==F||t[57]!==I?(V=(0,$.jsx)(`span`,{className:F,children:I}),t[56]=F,t[57]=I,t[58]=V):V=t[58];let H;t[59]===S?H=t[60]:(H=S?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:S}):null,t[59]=S,t[60]=H);let U;t[61]!==V||t[62]!==H||t[63]!==L||t[64]!==R?(U=(0,$.jsxs)(`span`,{className:L,children:[R,V,H]}),t[61]=V,t[62]=H,t[63]=L,t[64]=R,t[65]=U):U=t[65];let G;t[66]!==a||t[67]!==g?(G=a?(0,$.jsx)(`span`,{className:`block truncate typography-micro text-muted-foreground pl-4`,children:g?Yt(a,g):a}):null,t[66]=a,t[67]=g,t[68]=G):G=t[68];let K;t[69]!==U||t[70]!==G||t[71]!==z?(K=(0,$.jsxs)(`span`,{className:z,children:[U,G]}),t[69]=U,t[70]=G,t[71]=z,t[72]=K):K=t[72];let te;t[73]!==C||t[74]!==w||t[75]!==T||t[76]!==E||t[77]!==D||t[78]!==O||t[79]!==k||t[80]!==A||t[81]!==j||t[82]!==M||t[83]!==K?(te=(0,$.jsx)(`button`,{type:C,className:w,style:T,onClick:E,onPointerDown:D,onPointerMove:O,onPointerUp:k,onPointerCancel:A,onContextMenu:j,disabled:M,children:K}),t[73]=C,t[74]=w,t[75]=T,t[76]=E,t[77]=D,t[78]=O,t[79]=k,t[80]=A,t[81]=j,t[82]=M,t[83]=K,t[84]=te):te=t[84];let q;t[85]!==p||t[86]!==m?(q=p?(0,$.jsx)(`button`,{type:`button`,className:`mr-0.5 flex size-9 shrink-0 items-center justify-center rounded-xl text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-label":m,onClick:e=>{e.stopPropagation(),p()},style:{touchAction:`manipulation`},children:(0,$.jsx)(Ur,{})}):null,t[85]=p,t[86]=m,t[87]=q):q=t[87];let ne;t[88]!==_||t[89]!==f||t[90]!==d||t[91]!==b||t[92]!==B?(ne=d?(0,$.jsxs)($.Fragment,{children:[_?(0,$.jsxs)(`button`,{type:`button`,className:`flex h-9 shrink-0 items-center gap-1.5 rounded-xl bg-destructive px-3 text-destructive-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive`,"aria-label":b(`mobile.sessions.archiveSessionAria`,{title:B}),onClick:f,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`archive`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label`,children:b(`sessions.sidebar.bulkActions.archive`)})]}):null,(0,$.jsx)(`button`,{type:`button`,className:`mr-1.5 flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":b(_?`mobile.sessions.cancelArchiveAria`:`mobile.sessions.archiveSessionAria`,{title:B}),onClick:d,style:{touchAction:`manipulation`},children:_?(0,$.jsx)(X,{name:`close`,className:`size-4`}):(0,$.jsx)(X,{name:`archive`,className:`size-4`})})]}):null,t[88]=_,t[89]=f,t[90]=d,t[91]=b,t[92]=B,t[93]=ne):ne=t[93];let re;return t[94]!==N||t[95]!==P||t[96]!==te||t[97]!==q||t[98]!==ne?(re=(0,$.jsxs)(`div`,{className:N,children:[P,te,q,ne]}),t[94]=N,t[95]=P,t[96]=te,t[97]=q,t[98]=ne,t[99]=re):re=t[99],re},Qo=e=>{let t=(0,Q.c)(15),{indent:n,showMore:r,showFewer:i,loadingMore:a,onShowMore:o,onShowFewer:s}=e,c=a!==void 0&&a,{t:l}=ee();if(!r&&!i)return null;let u;t[0]===n?u=t[1]:(u={paddingLeft:n,touchAction:`manipulation`},t[0]=n,t[1]=u);let d;t[2]!==s||t[3]!==i||t[4]!==l?(d=i?(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-left transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,onClick:s,children:[(0,$.jsx)(X,{name:`arrow-up-s`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-micro`,children:l(`sessions.sidebar.group.showFewer`)})]}):null,t[2]=s,t[3]=i,t[4]=l,t[5]=d):d=t[5];let f;t[6]!==c||t[7]!==o||t[8]!==r||t[9]!==l?(f=r?(0,$.jsxs)(`button`,{type:`button`,className:W(`inline-flex items-center gap-1.5 text-left transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset disabled:pointer-events-none disabled:opacity-60`,c&&`animate-pulse`),onClick:o,disabled:c,children:[(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-micro`,children:l(`sessions.sidebar.group.showMore`)})]}):null,t[6]=c,t[7]=o,t[8]=r,t[9]=l,t[10]=f):f=t[10];let p;return t[11]!==u||t[12]!==d||t[13]!==f?(p=(0,$.jsxs)(`div`,{className:`flex min-h-10 w-full items-center gap-3 py-1.5 pr-3 text-muted-foreground`,style:u,children:[d,f]}),t[11]=u,t[12]=d,t[13]=f,t[14]=p):p=t[14],p},$o=({open:e,onOpenChange:t,variant:n=`sheet`})=>{let{t:r}=ee(),{git:i}=mn(),a=Ie(),o=xe(),s=Fe(e=>e.activeSessions),c=Fe(e=>e.activePaginationByDirectory),l=Ve(e=>e.projects),u=Ve(e=>e.activeProjectId),d=w(e=>e.currentDirectory),f=Re(e=>e.currentSessionId),p=Re(e=>e.availableWorktreesByProject),m=Re(e=>e.setCurrentSession),h=Re(e=>e.archiveSession),g=Re(e=>e.archiveSessions),_=Re(e=>e.updateSessionTitle),v=Re(e=>e.requestSessionSmartTitle),y=Re(e=>e.shareSession),b=Re(e=>e.unshareSession),x=Re(e=>e.openNewSessionDraft),S=Ve(e=>e.setActiveProject),C=Ve(e=>e.setActiveProjectIdOnly),T=Ve(e=>e.removeProject),E=De(),D=he(),O=jo(e=>e.projectExpanded),k=jo(e=>e.worktreeExpanded),A=jo(e=>e.setProjectExpanded),j=jo(e=>e.setWorktreeExpanded),M=Mt(e=>e.orderByProject),N=Ao(e=>e.expandedParents),P=Ao(e=>e.toggleParent),[F,I]=Z.useState(``),[L,R]=Z.useState(null),[z,B]=Z.useState(null),[U,K]=Z.useState(0),[te,q]=Z.useState(!1),[ne,re]=Z.useState(!1),[ie,ae]=Z.useState(null),[oe,se]=Z.useState(null),[J,ce]=Z.useState(null),[le,ue]=Z.useState(null),[Y,de]=Z.useState(null),[pe,me]=Z.useState(``),[ge,_e]=Z.useState(!1),[ve,ye]=Z.useState(null),be=Z.useRef(null);be.current||=tr({onPressedKeyChange:ue});let[Ce,we]=Z.useState(new Set),[Te,Ee]=Z.useState(new Map),[Oe,ke]=Z.useState(new Map),Ae=Cr(),je=jr(),Me=V(e=>{Se(e),fe(e)}),Ne=V(e=>{Promise.all(e.map(e=>(Se(e),fe(e))))});Z.useEffect(()=>{if(!e){I(``),ke(new Map),R(null),B(null),se(null),de(null),ye(null),be.current?.reset();return}},[e]),Z.useEffect(()=>()=>{be.current?.reset()},[]),Z.useEffect(()=>{if(!e)return;if(l.length===0){Re.setState(e=>{let t=Sr(e.availableWorktreesByProject,new Set,[]);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:[]}}),we(e=>e.size===0?e:new Set),Ee(e=>e.size===0?e:new Map);return}let t=!1;return(async()=>{let e=await Promise.all(l.map(async e=>{let n=Fo(e.path);if(!n)return null;let r;try{r=await i.checkIsGitRepository(n)}catch{return{id:e.id,path:n,gitStatus:`failed`}}if(!r)return{id:e.id,path:n,gitStatus:`success`,isGitRepo:r,worktreeStatus:`success`,worktrees:[]};let[a,o]=await Promise.allSettled([Kt({id:e.id,path:n},{isCurrent:()=>!t}),Ut(n)]);return{id:e.id,path:n,gitStatus:`success`,isGitRepo:r,worktreeStatus:a.status===`fulfilled`?`success`:`failed`,worktrees:a.status===`fulfilled`?a.value.worktrees:void 0,rootBranchStatus:o.status===`fulfilled`?`success`:`failed`,rootBranch:o.status===`fulfilled`?o.value:void 0}}));if(t)return;let n=new Set(l.map(e=>Fo(e.path)).filter(Boolean)),r=e.flatMap(e=>e?.worktreeStatus?[{path:e.path,status:e.worktreeStatus,worktrees:e.worktrees}]:[]);Re.setState(e=>{let t=Sr(e.availableWorktreesByProject,n,r);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:Array.from(t.values()).flat()}}),we(t=>{let r=new Set([...t].filter(e=>n.has(e)));for(let t of e)t?.gitStatus===`success`&&(t.isGitRepo?r.add(t.path):r.delete(t.path));return zo(r,t)?t:r}),Ee(t=>{let n=new Set(l.map(e=>e.id)),r=new Map([...t].filter(([e])=>n.has(e)));for(let t of e){if(!t||t.gitStatus!==`success`)continue;if(!t.isGitRepo){r.delete(t.id);continue}if(t.rootBranchStatus!==`success`)continue;let e=t.rootBranch?.trim();e&&e!==`HEAD`?r.set(t.id,e):r.delete(t.id)}return r.size===t.size&&[...r].every(([e,n])=>t.get(e)===n)?t:r})})(),()=>{t=!0}},[i,e,l,U]);let Pe=Z.useMemo(()=>l.map(e=>({id:e.id,label:Lo(e.path),path:Fo(e.path),icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:Ce.has(Fo(e.path)),worktrees:At(M[e.id],p.get(Fo(e.path))??[])})),[Ce,l,M,p]),Le=Z.useMemo(()=>{let e=new Map(o.map(e=>[e.id,e])),t=s.map(t=>{let n=e.get(t.id);return n?Ue(n,t):t}),n=new Set(t.map(e=>e.id));for(let e of o)n.has(e.id)||t.push(e);return t},[s,o]),Be=F.trim().toLowerCase(),He=Z.useMemo(()=>{let e=Pe.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===u})),t=(e,t,n)=>{let r=Fo(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||Lo(r),path:r,worktree:n,sessions:[]},e.buckets.push(a)),a};for(let n of e){t(n,n.project.path,null);for(let e of n.project.worktrees)t(n,e.path,e)}for(let n of Le){let r=Io(n);if(!r)continue;let i=Fo(r),a=e.find(e=>Uo(e.project,i));if(!a)continue;let o=Ho(a.project,i);(o?t(a,o.path,o):t(a,a.project.path,null)).sessions.push(n)}for(let t of e)for(let e of t.buckets){e.sessions.sort((e,t)=>ze(t)-ze(e));for(let n of e.sessions)Po(n)||(t.totalSessions+=1)}return e},[u,Pe,Le]),We=Fo(d),Ge=e=>e.isActive?We===e.project.path?e.project.path:e.project.worktrees.find(e=>Vo(We,e.path))?.path??e.project.path:null,qe=e=>O[e.project.id]??!0,Je=(e,t)=>k[`${e.project.id}::${t.key}`]??!1,Ye=e=>{ke(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},Xe=()=>{se(null),be.current?.reset()},Qe=e=>({pressed:le===e.key||oe?.key===e.key,onPointerDown:t=>{t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||be.current?.start({pointerId:t.pointerId,key:e.key,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>se(e)})},onPointerMove:e=>{be.current?.move(e.pointerId,e.clientX,e.clientY)},onPointerUp:e=>{be.current?.end(e.pointerId)},onPointerCancel:e=>{be.current?.cancel(e.pointerId)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),be.current?.openFromContextMenu(e.key,()=>se(e))}}),et=(e,t)=>{be.current?.consumeClick(e)||t()},tt=(e,t,n,r)=>{let i=ii(),a=kr();if(ke(t=>{let r=new Map(t),o=Math.max(i,t.get(e)??i,n);return r.set(e,o+a),r}),Math.max(i,n)+a<r)return;let o=Fo(t);if(!o)return;let s=Fe.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&Ke(o)},nt=(e,t,n)=>{let i=`${e.project.id}::${t.key}`,a=ii(),o=new Set(t.sessions.map(e=>e.id)),s=new Map;for(let e of t.sessions){let t=Po(e);if(t&&o.has(t)){let n=s.get(t)??[];n.push(e),s.set(t,n)}}let l=t.sessions.filter(e=>!Po(e)),u=Oe.get(i)??a,d=Er(l,u,je),p=l.length-d.length,m=c.get(Fo(t.path)),h=m?.hasMore===!0,g=m?.loadingMore===!0,_=l.length>a&&u>a,v=(e,t)=>{let n=s.get(e.id)??[],i=n.length>0,a=!!N[e.id],o=Ae.has(e.id),c=i&&!a?n.filter(e=>Ae.has(e.id)).map(e=>e.id):[],l=c.length>0,u=o?[e.id,...c]:c,d=e.title?.trim()||r(`mobile.sessions.untitled`),p=`session:${e.id}`;return(0,$.jsxs)(Z.Fragment,{children:[(0,$.jsx)(Zo,{session:e,active:f===e.id,indent:t,hasChildren:i,expanded:a,onToggleChildren:i?()=>P(e.id):void 0,confirmingArchive:z===e.id,onSelect:()=>et(p,()=>at(e)),onRequestArchive:()=>ot(e.id),onConfirmArchive:()=>void st(e),onStop:o||l?()=>Ne(u):void 0,stopAriaLabel:r(l?`mobile.sessions.stopSubsessionsAria`:`mobile.sessions.stopSessionAria`,{title:d}),longPressHandlers:Qe({key:p,kind:`session`,session:e})}),i&&a?n.map(e=>v(e,t+No)):null]},e.id)};return(0,$.jsxs)(`div`,{children:[d.map(e=>v(e,n)),(0,$.jsx)(Qo,{indent:n,showMore:p>0||h,showFewer:_,loadingMore:g,onShowMore:()=>tt(i,t.path,u,l.length),onShowFewer:()=>Ye(i)})]})},rt=(e,t)=>{A(e,!t)},it=(e,t,n)=>{j(`${e}::${t}`,!n)},at=e=>{hn();let n=Io(e)||null,r=Wo(Pe,n??``);r&&C(r.id),m(e.id,n),t(!1)},ot=e=>{B(t=>t===e?null:e)},st=async e=>{B(null),await h(e.id)?yr({sessionIds:[e.id],message:r(`sessions.sidebar.session.archive.success`),undoLabel:r(`sessions.sidebar.undo`),settingsLabel:r(`settings.openchamber.archivedSessions.actions.view`),undoFailedMessage:r(`sessions.sidebar.session.archive.undoFailed`)}):Ze.error(r(`sessions.sidebar.session.archive.error`))},ct=()=>{x(),t(!1)},lt=e=>{ae(e),C(e),re(!0)},ut=e=>{let t=new Map;for(let e of Le){let n=Po(e);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},dt=async e=>{let t=ut(e.id),{archivedIds:n,failedIds:i}=await g(t);n.length>0&&yr({sessionIds:n,message:n.length===1?r(`sessions.sidebar.session.archive.success`):r(`sessions.sidebar.bulkActions.archivedPlural`,{count:n.length}),undoLabel:r(`sessions.sidebar.undo`),settingsLabel:r(`settings.openchamber.archivedSessions.actions.view`),undoFailedMessage:n.length===1?r(`sessions.sidebar.session.archive.undoFailed`):r(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:n.length})}),i.length>0&&Ze.error(i.length===1?r(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):r(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}))},ft=e=>{let t=ut(e.id);Wr({sessionIds:t,message:t.length===1?r(`sessions.sidebar.session.delete.success`):r(`sessions.sidebar.bulkActions.deletedPlural`,{count:t.length}),undoLabel:r(`sessions.sidebar.undo`),commitFailedMessage:r(`sessions.sidebar.session.delete.error`)})},pt=async e=>{try{if(!(await y(e.id))?.share?.url){Ze.error(r(`sessions.sidebar.session.share.error`));return}Ze.success(r(`sessions.sidebar.session.share.successTitle`),{description:r(`sessions.sidebar.session.share.successDescription`)})}catch{Ze.error(r(`sessions.sidebar.session.share.error`))}},mt=async e=>{if((await H(e)).ok){Ze.success(r(`sessions.sidebar.session.menu.copied`));return}Ze.error(r(`sessions.sidebar.session.share.copyUrlError`))},ht=async e=>{try{if(await b(e)){Ze.success(r(`sessions.sidebar.session.unshare.success`));return}Ze.error(r(`sessions.sidebar.session.unshare.error`))}catch{Ze.error(r(`sessions.sidebar.session.unshare.error`))}},gt=async()=>{if(!Y)return;let e=pe.trim();if(e)try{await _(Y.id,e),de(null),me(``)}catch{Ze.error(r(`sessions.sidebar.session.menu.rename`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},_t=async()=>{if(!Y||ge)return;let e=Y.id;de(null),me(``),_e(!0);try{await v(e)}catch{Ze.error(r(`sessions.sidebar.session.rename.smartTitle`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{_e(!1)}},vt=(e,n)=>{C(e.id),x({selectedProjectId:e.id,directoryOverride:n,preserveDirectoryOverride:!0}),t(!1)},yt=e=>{(async()=>{try{await Kt({id:e.id,path:e.path})}catch(e){console.warn(`[MobileSessions] Worktree refresh before session sync failed:`,e)}let t=Re.getState().availableWorktreesByProject.get(e.path)??e.worktrees,n=[e.path,...t.map(e=>e.path)];await $e(n,Le)})()},bt=e=>{let t=Io(e),n=Wo(Pe,t);if(!n)return Lo(t)||t;let r=Ho(n,Fo(t));return r?.branch?`${n.label} · ${r.branch}`:n.label},xt=e=>{S(e.id),t(!1)},St=Z.useMemo(()=>Be?He.filter(e=>`${e.project.label} ${e.project.path}`.toLowerCase().includes(Be)?!0:e.buckets.some(t=>t.sessions.some(t=>Go(t,e.project.label,Be)))):He,[Be,He]),wt=Z.useMemo(()=>Be?Le.filter(e=>{let t=Io(e);return Go(e,Wo(Pe,t)?.label??``,Be)}).sort((e,t)=>ze(t)-ze(e)):[],[Be,Pe,Le]),Tt=Z.useMemo(()=>Be?Pe.filter(e=>`${e.label} ${e.path}`.toLowerCase().includes(Be)).map(e=>({...e,sessionCount:Le.filter(t=>!Po(t)&&Uo(e,Fo(Io(t)))).length})):[],[Be,Pe,Le]),Et=Be&&wt.length===0&&Tt.length===0,Dt=Pe.length>0?(0,$.jsxs)(G,{type:`button`,variant:`default`,size:`sm`,"aria-label":r(`mobile.sessions.newChat`),onClick:ct,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`add`,className:`size-4`}),r(`mobile.sessions.newChat`)]}):null,Ot=Pe.find(e=>e.id===u)??null,kt=Ot?.isGitRepo?(0,$.jsx)(G,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.project.actions.newWorktree`),title:r(`sessions.sidebar.project.actions.newWorktree`),onClick:()=>lt(Ot.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`node-tree`,className:`size-4`})}):null,jt=(0,$.jsx)(G,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.header.actions.addProject`),title:r(`sessions.sidebar.header.actions.addProject`),onClick:()=>q(!0),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`folder-add`,className:`size-4`})}),Nt=Dt||jt?(0,$.jsxs)($.Fragment,{children:[Dt,kt,jt]}):null,Pt=oe?.kind===`project`?oe.project.label:oe?.kind===`worktree`?oe.worktree.branch||oe.worktree.label||oe.worktree.path:oe?.kind===`session`?oe.session.title?.trim()||r(`mobile.sessions.untitled`):``,Ft=Z.useMemo(()=>{if(!oe)return[];if(oe.kind===`project`){let e=oe.project;return Lr({gitRepository:e.isGitRepo,onNewSession:()=>{Xe(),vt(e,e.path)},onNewWorktree:()=>{Xe(),lt(e.id)},onSyncSessions:()=>{Xe(),yt(e)},onEditProject:()=>{Xe(),R(e.id)},onCloseProject:()=>{Xe(),ce(e)}})}if(oe.kind===`worktree`){let{project:e,worktree:t}=oe;return Or({onNewSession:()=>{Xe(),vt(e,t.path)},onDeleteWorktree:()=>{Xe(),ye({project:e,worktree:t})}})}let e=oe.session,t=!!e.share?.url;return ai({pinned:E.has(e.id),shared:t,onRename:()=>{Xe(),me(e.title?.trim()||r(`mobile.sessions.untitled`)),de(e)},onTogglePin:()=>{Xe(),D(e.id)},onShare:!a||t?void 0:()=>{Xe(),pt(e)},onCopyLink:a&&t?()=>{let t=e.share?.url;Xe(),t&&mt(t)}:void 0,onUnshare:a&&t?()=>{Xe(),ht(e.id)}:void 0,onArchive:()=>{Xe(),dt(e)},onDelete:()=>{Xe(),ft(e)}})},[oe,Xe,dt,mt,ft,lt,pt,ht,E,vt,yt,r,D]),It=Ft.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:Ft.map(e=>{let t=(0,$.jsx)(Xo,{icon:e.icon,label:br(e,r),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:t},e.id):t})}):null,Lt=(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(qt,{value:F,onChange:e=>I(e.target.value),placeholder:r(`mobile.sessions.search.placeholder`),className:W(`h-11 pl-9`,F&&`pr-10`)}),F?(0,$.jsx)(`button`,{type:`button`,className:`absolute right-1.5 top-1/2 flex size-8 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":r(`mobile.sessions.clearSearchAria`),onClick:()=>I(``),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-4`})}):null]})}),(0,$.jsx)(wn,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto pb-4`,children:Pe.length===0?(0,$.jsx)(es,{title:r(`mobile.sessions.empty.noProjectsTitle`),description:r(`mobile.sessions.empty.noProjectsDescription`),action:(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center justify-center gap-2 rounded-2xl bg-primary px-5 py-3 typography-ui-label text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:()=>q(!0),children:[(0,$.jsx)(X,{name:`folder-add`,className:`size-4`}),r(`sessions.sidebar.header.actions.addProject`)]})}):Et?(0,$.jsx)(es,{title:r(`mobile.sessions.empty.searchTitle`),description:r(`mobile.sessions.empty.searchDescription`)}):Be?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-3 pt-2`,children:[wt.length>0?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-1 pb-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-semibold uppercase tracking-wider text-muted-foreground`,children:r(`mobile.sessions.search.section.sessions`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:wt.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:wt.map((e,t)=>{let n=Ae.has(e.id),i=e.title?.trim()||r(`mobile.sessions.untitled`);return(0,$.jsx)(`div`,{className:W(t>0&&`border-t border-border/30`),children:(0,$.jsx)(Zo,{session:e,active:f===e.id,indent:12,contextLabel:bt(e),highlightQuery:Be,onSelect:()=>et(`session:${e.id}`,()=>at(e)),longPressHandlers:Qe({key:`session:${e.id}`,kind:`session`,session:e}),onStop:n?()=>Me(e.id):void 0,stopAriaLabel:r(`mobile.sessions.stopSessionAria`,{title:i})})},e.id)})})]}):null,Tt.length>0?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-1 pb-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-semibold uppercase tracking-wider text-muted-foreground`,children:r(`mobile.sessions.search.section.projects`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:Tt.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:Tt.map((e,t)=>{let n=`project:${e.id}`,r=Qe({key:n,kind:`project`,project:e});return(0,$.jsxs)(`div`,{className:W(`flex items-center`,t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`button`,{type:`button`,className:W(`flex min-h-14 min-w-0 flex-1 items-center gap-3 px-3 py-2 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,r.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>et(n,()=>xt(e)),onPointerDown:r.onPointerDown,onPointerMove:r.onPointerMove,onPointerUp:r.onPointerUp,onPointerCancel:r.onPointerCancel,onContextMenu:r.onContextMenu,style:{touchAction:`manipulation`},children:[(0,$.jsx)(Ko,{project:e}),(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:Yt(e.label,Be)}),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.sessionCount})]}),e.isGitRepo?(0,$.jsx)(Yo,{className:`mr-2`,onClick:()=>lt(e.id)}):null]},e.id)})})]}):null]}):(0,$.jsx)(`div`,{className:`flex flex-col`,children:St.map((e,t)=>{let n=qe(e),i=`project:${e.project.id}`,a=Qe({key:i,kind:`project`,project:e.project}),o=Be?e.buckets.filter(t=>t.sessions.some(t=>Go(t,e.project.label,Be))):e.buckets,s=Ge(e);return(0,$.jsxs)(`section`,{className:W(t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`div`,{className:`flex min-h-14 w-full items-center`,children:[(0,$.jsxs)(`button`,{type:`button`,className:W(`flex min-h-14 min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,a.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>et(i,()=>rt(e.project.id,n)),onPointerDown:a.onPointerDown,onPointerMove:a.onPointerMove,onPointerUp:a.onPointerUp,onPointerCancel:a.onPointerCancel,onContextMenu:a.onContextMenu,"aria-expanded":n,"aria-label":r(n?`sessions.sidebar.group.collapseAria`:`sessions.sidebar.group.expandAria`,{label:e.project.label}),style:{touchAction:`manipulation`},children:[(0,$.jsx)(Ko,{project:e.project}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label font-semibold text-foreground`,children:e.project.label}),Te.get(e.project.id)?(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 typography-micro text-muted-foreground`,children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:Te.get(e.project.id)})]}):null]}),e.isActive?(0,$.jsx)(Jo,{ariaLabel:r(`mobile.sessions.activeProjectAria`)}):null,(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.totalSessions})]}),(()=>{let t=n?[]:[...new Set(e.buckets.flatMap(e=>e.sessions.filter(e=>Ae.has(e.id)).map(e=>e.id)))];return t.length>0?(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] mr-1`,"aria-label":r(`mobile.sessions.stopGroupAria`,{label:e.project.label}),onClick:e=>{e.stopPropagation(),Ne(t)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Ur,{})}):null})(),e.project.isGitRepo?(0,$.jsx)(Yo,{className:`mr-2`,onClick:()=>lt(e.project.id)}):null]}),n?(0,$.jsx)(`div`,{className:`pb-2`,children:(()=>{let t=o.find(e=>e.worktree===null),n=o.filter(e=>e.worktree!==null);return(0,$.jsxs)($.Fragment,{children:[t&&t.sessions.length>0?nt(e,t,Mo):null,n.map(t=>{let n=Je(e,t),i=s===t.path,a=`worktree:${e.project.id}:${t.key}`,o=Qe({key:a,kind:`worktree`,project:e.project,worktree:t.worktree});return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,className:W(`flex min-h-11 w-full items-center gap-2 py-1.5 pl-4 pr-3 text-left transition-all hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,o.pressed&&`bg-interactive-active scale-[0.99]`),onClick:()=>et(a,()=>it(e.project.id,t.key,n)),onPointerDown:o.onPointerDown,onPointerMove:o.onPointerMove,onPointerUp:o.onPointerUp,onPointerCancel:o.onPointerCancel,onContextMenu:o.onContextMenu,"aria-expanded":n,"aria-label":r(n?`sessions.sidebar.group.collapseAria`:`sessions.sidebar.group.expandAria`,{label:t.label}),style:{touchAction:`manipulation`},children:[(0,$.jsx)(qo,{expanded:n}),(0,$.jsx)(X,{name:`node-tree`,className:W(`size-4 shrink-0`,i?`text-primary`:`text-muted-foreground`)}),(0,$.jsx)(`span`,{className:W(`block min-w-0 flex-1 truncate typography-ui-label font-semibold`,i?`text-foreground`:`text-foreground/90`),children:t.label}),i?(0,$.jsx)(Jo,{ariaLabel:r(`mobile.sessions.activeWorktreeAria`)}):null,(()=>{let e=n?[]:t.sessions.filter(e=>Ae.has(e.id)).map(e=>e.id);return e.length>0?(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-label":r(`mobile.sessions.stopGroupAria`,{label:t.label}),onClick:t=>{t.stopPropagation(),Ne(e)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Ur,{})}):null})(),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:t.sessions.length})]}),n?nt(e,t,Mo):null]},t.key)})]})})()}):null]},e.project.id)})})}),(0,$.jsx)(Kr,{open:te,onOpenChange:q,forceMobile:!0}),(0,$.jsx)(Ct,{open:ne,projectId:ie,onOpenChange:e=>{re(e),e||ae(null)},onWorktreeCreated:(e,n)=>{n?.sessionId?m(n.sessionId,e):x({selectedProjectId:ie,directoryOverride:e,preserveDirectoryOverride:!0}),t(!1)}}),(0,$.jsx)(on,{open:!!oe,title:Pt,onClose:Xe,contentMaxHeightClassName:`max-h-[min(68dvh,560px)]`,children:It}),(0,$.jsx)(on,{open:!!J,title:r(`sessions.sidebar.project.actions.closeProject`),onClose:()=>ce(null),closeAriaLabel:r(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(G,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>ce(null),children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(G,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!J)return;let e=J;ce(null),T(e.id),Ze.success(r(`mobile.sessions.toast.projectRemoved`,{label:e.label}))},children:r(`mobile.sessions.confirmRemoveProject`)})]}),children:(0,$.jsx)(`p`,{className:`px-1 py-1 typography-ui-body text-foreground`,children:r(`mobile.projects.closeConfirmMessage`,{title:J?.label??``})})}),(0,$.jsx)(on,{open:!!Y,title:r(`sessions.sidebar.session.menu.rename`),onClose:()=>{ge||(de(null),me(``))},footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(G,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:ge,onClick:()=>{de(null),me(``)},children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(G,{type:`button`,variant:`default`,className:`flex-1`,disabled:!pe.trim()||ge,onClick:()=>void gt(),children:r(`sessions.sidebar.session.rename.save`)})]}),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-3 px-1 py-1`,onSubmit:e=>{e.preventDefault(),gt()},children:[(0,$.jsx)(qt,{value:pe,onChange:e=>me(e.target.value),autoFocus:!0,className:`h-12`,disabled:ge}),(0,$.jsxs)(G,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:ge,onClick:()=>void _t(),children:[ge?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`ai-generate-2`,className:`size-4`}),r(`sessions.sidebar.session.rename.smartTitle`)]})]})}),ve?(0,$.jsx)(Dr,{open:!0,project:{id:ve.project.id,path:ve.project.path},worktree:ve.worktree,onClose:()=>ye(null),onDeleted:()=>K(e=>e+1)}):null,(0,$.jsx)(xr,{open:L!==null,project:Pe.find(e=>e.id===L)??null,onClose:()=>R(null),onWorktreesChanged:()=>K(e=>e+1)})]});return n===`sidebar`?e?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsx)(`div`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center justify-end gap-2 px-4`,children:Nt?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:Nt}):null}),Lt]}):null:(0,$.jsx)(bn,{id:`mobile-sessions-sheet`,open:e,onOpenChange:t,trailing:Nt,ariaLabel:r(`mobile.sessions.sheet.title`),closeAriaLabel:r(`mobile.surface.closeAria`),resizeAriaLabel:r(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:Lt})},es=e=>{let t=(0,Q.c)(10),{title:n,description:r,action:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r}):null,t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=i?(0,$.jsx)(`div`,{className:`pt-2`,children:i}):null,t[4]=i,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[a,o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c},ts=`/assets/assistant-guide-hero-wide-DiFIThB0.jpg`,ns=[{image:ui,titleKey:`assistants.guide.share.ios.title`,descriptionKey:`assistants.guide.share.ios.description`},{image:fi,titleKey:`assistants.guide.share.android.title`,descriptionKey:`assistants.guide.share.android.description`},{image:hi,titleKey:`assistants.guide.share.pick.title`,descriptionKey:`assistants.guide.share.pick.description`}];function rs(){let e=(0,Q.c)(8),{t}=ee(),n;e[0]===t?n=e[1]:(n=t(`common.loading`),e[0]=t,e[1]=n);let r,i,a,o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`div`,{className:`h-10 w-10 animate-pulse rounded-xl bg-[var(--surface-muted)] motion-reduce:animate-none`}),i=(0,$.jsx)(`div`,{className:`mt-2 h-4 w-2/3 animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),a=(0,$.jsx)(`div`,{className:`h-3.5 w-full animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),o=(0,$.jsx)(`div`,{className:`h-3.5 w-4/5 animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),e[2]=r,e[3]=i,e[4]=a,e[5]=o):(r=e[2],i=e[3],a=e[4],o=e[5]);let s;return e[6]===n?s=e[7]:(s=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3 p-5`,"aria-busy":`true`,"aria-label":n,children:[r,i,a,o]}),e[6]=n,e[7]=s),s}function is(e){let t=(0,Q.c)(35),{onEnable:n}=e,{t:r}=ee(),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-guide-hero`,"aria-hidden":`true`,children:(0,$.jsx)(`img`,{src:ts,alt:``})}),t[0]=i):i=t[0];let a;t[1]===r?a=t[2]:(a=r(`assistants.guide.disabledTitle`),t[1]=r,t[2]=a);let o;t[3]===a?o=t[4]:(o=(0,$.jsx)(`h2`,{className:`oc-mobile-assistant-guide-title`,children:a}),t[3]=a,t[4]=o);let s;t[5]===r?s=t[6]:(s=r(`assistants.guide.disabledDescription`),t[5]=r,t[6]=s);let c;t[7]===s?c=t[8]:(c=(0,$.jsx)(`p`,{className:`oc-mobile-assistant-guide-description`,children:s}),t[7]=s,t[8]=c);let l;t[9]===r?l=t[10]:(l=r(`assistants.guide.enableAction`),t[9]=r,t[10]=l);let u;t[11]!==n||t[12]!==l?(u=(0,$.jsx)(G,{type:`button`,size:`lg`,onClick:n,children:l}),t[11]=n,t[12]=l,t[13]=u):u=t[13];let d;t[14]!==o||t[15]!==c||t[16]!==u?(d=(0,$.jsxs)(`div`,{className:`oc-mobile-assistant-guide-body`,children:[o,c,u]}),t[14]=o,t[15]=c,t[16]=u,t[17]=d):d=t[17];let f;t[18]===r?f=t[19]:(f=r(`assistants.guide.shareTitle`),t[18]=r,t[19]=f);let p;t[20]===f?p=t[21]:(p=(0,$.jsx)(`h3`,{className:`oc-mobile-assistant-guide-share-title`,children:f}),t[20]=f,t[21]=p);let m;t[22]===r?m=t[23]:(m=r(`assistants.guide.shareAria`),t[22]=r,t[23]=m);let h;t[24]===r?h=t[25]:(h=ns.map(e=>(0,$.jsxs)(`article`,{className:`oc-mobile-assistant-guide-step`,children:[(0,$.jsx)(`div`,{className:`oc-mobile-assistant-guide-step-image`,children:(0,$.jsx)(`img`,{src:e.image,alt:``})}),(0,$.jsxs)(`div`,{className:`oc-mobile-assistant-guide-step-copy`,children:[(0,$.jsx)(`h4`,{children:r(e.titleKey)}),(0,$.jsx)(`p`,{children:r(e.descriptionKey)})]})]},e.titleKey)),t[24]=r,t[25]=h);let g;t[26]!==m||t[27]!==h?(g=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-guide-steps`,"aria-label":m,children:h}),t[26]=m,t[27]=h,t[28]=g):g=t[28];let _;t[29]!==p||t[30]!==g?(_=(0,$.jsxs)(`section`,{className:`oc-mobile-assistant-guide-share`,children:[p,g]}),t[29]=p,t[30]=g,t[31]=_):_=t[31];let v;return t[32]!==_||t[33]!==d?(v=(0,$.jsxs)(`article`,{className:`oc-mobile-assistant-guide`,children:[i,d,_]}),t[32]=_,t[33]=d,t[34]=v):v=t[34],v}function as({unreadCount:e,assistantID:t,displayName:n,avatarEmoji:r,summary:i,enabled:a,editLabel:o,deleteLabel:s,onOpen:c,onEdit:l,onDelete:u,serverWorking:d=!1}){let f=Si(t,d),[p,m]=Z.useState(!1),[h,g]=Z.useState(!1),_=Z.useRef(null);_.current||=tr({onPressedKeyChange:e=>g(e===t)}),Z.useEffect(()=>()=>_.current?.reset(),[]);let v=V(()=>{_.current?.consumeClick(t)||p||c()}),y=V(()=>{m(!1),l()}),b=V(()=>{m(!1),u()}),x=V(()=>{g(!1),m(!0)}),S=V(e=>{e.pointerType!==`touch`&&e.pointerType!==`pen`||e.button!==0||_.current?.start({pointerId:e.pointerId,key:t,clientX:e.clientX,clientY:e.clientY,onTrigger:x})}),C=V(e=>{_.current?.move(e.pointerId,e.clientX,e.clientY)}),w=V(e=>{_.current?.end(e.pointerId)}),T=V(e=>{_.current?.cancel(e.pointerId)}),E=V(e=>{e.preventDefault(),e.stopPropagation(),_.current?.openFromContextMenu(t,x)});return(0,$.jsxs)(Mi,{open:p,onOpenChange:m,children:[(0,$.jsx)(dr,{"data-mobile-press-surface":`soft`,className:W(`oc-mobile-assistant-card-shell`,h&&`bg-interactive-hover`),children:(0,$.jsxs)(Oi,{render:(0,$.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":`false`,"data-mobile-press-surface-trigger":!0,className:W(`oc-mobile-assistant-card`,!a&&`opacity-65`),onClick:v,onPointerDown:S,onPointerMove:C,onPointerUp:w,onPointerCancel:T,onContextMenu:E,style:{touchAction:`pan-y`}}),children:[(0,$.jsx)(`span`,{className:W(`oc-mobile-assistant-avatar`,r?`oc-mobile-assistant-avatar--emoji`:`oc-mobile-assistant-avatar--visual`),children:(0,$.jsx)(wi,{name:t,emoji:r,size:40,label:n,working:f})}),(0,$.jsxs)(`span`,{className:`oc-mobile-assistant-card-content min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`oc-mobile-entity-title oc-mobile-assistant-name block min-w-0 truncate font-semibold text-foreground`,children:n}),(0,$.jsx)(`span`,{className:W(`oc-mobile-assistant-summary`,Ci),children:i})]}),(0,$.jsx)(Ei,{count:e})]})}),(0,$.jsxs)(Ai,{className:`min-w-[10rem]`,children:[(0,$.jsxs)(ji,{className:`min-h-10 px-3`,onClick:y,children:[(0,$.jsx)(X,{name:`edit`,className:`size-4`}),o]}),(0,$.jsx)(ki,{}),(0,$.jsxs)(ji,{className:`min-h-10 px-3 text-[var(--status-error)] focus:text-[var(--status-error)] data-[highlighted]:text-[var(--status-error)] [&_svg]:text-[var(--status-error)]`,onClick:b,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`}),s]})]})]})}function os(e){let t=(0,Q.c)(118),{onEnable:n,onOpenAssistant:r,className:i}=e,{t:a}=ee(),o=Dn(),s=ue(),c=de();c.data?.assistants;let l;t[0]===c.data?.assistants?l=t[1]:(l=c.data?.assistants??[],t[0]=c.data?.assistants,t[1]=l);let u;t[2]===l?u=t[3]:(u=xi(l),t[2]=l,t[3]=u);let d=u,f=tt(ss),[p,m]=Z.useState(null),h;t[4]===n?h=t[5]:(h=()=>n(),t[4]=n,t[5]=h);let g=V(h),_;t[6]!==o||t[7]!==f?(_=()=>{f(),o?.openSettings(`assistants`)},t[6]=o,t[7]=f,t[8]=_):_=t[8];let v=V(_),y;t[9]===r?y=t[10]:(y=e=>r(e),t[9]=r,t[10]=y);let b=V(y),x;t[11]===o?x=t[12]:(x=e=>{rt(e,o?{openMobileSettings:o.openSettings}:void 0)},t[11]=o,t[12]=x);let S=V(x),C;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{m(e)},t[13]=C):C=t[13];let w=V(C),T;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>{e||m(null)},t[14]=T):T=t[14];let E=V(T),D;t[15]===a?D=t[16]:(D=a(`assistants.title`),t[15]=a,t[16]=D);let O=D,k;t[17]===a?k=t[18]:(k=a(`assistants.menu.edit`),t[17]=a,t[18]=k);let A=k,j;t[19]===a?j=t[20]:(j=a(`assistants.settings.delete`),t[19]=a,t[20]=j);let M=j;if(s.isPending||s.data?.supported&&s.data.enabled&&c.isPending){let e;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(dr,{className:`oc-mobile-assistant-loading`,children:(0,$.jsx)(rs,{})}),t[21]=e):e=t[21];let n;return t[22]!==i||t[23]!==O?(n=(0,$.jsx)(ur,{title:O,className:i,surface:!1,children:e}),t[22]=i,t[23]=O,t[24]=n):n=t[24],n}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length>0){let e;t[25]===a?e=t[26]:(e=a(`assistants.settings.create`),t[25]=a,t[26]=e);let n;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(X,{name:`add`,className:`size-5`}),t[27]=n):n=t[27];let r;t[28]!==v||t[29]!==e?(r=(0,$.jsx)(G,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":e,onClick:v,children:n}),t[28]=v,t[29]=e,t[30]=r):r=t[30];let o;t[31]===c.data?o=t[32]:(o=(0,$.jsx)(yi,{snapshot:c.data,rowClassName:`flex justify-end pb-2`}),t[31]=c.data,t[32]=o);let s;t[33]===a?s=t[34]:(s=a(`assistants.listAria`),t[33]=a,t[34]=s);let l;if(t[35]!==d||t[36]!==M||t[37]!==A||t[38]!==S||t[39]!==b||t[40]!==w||t[41]!==a){let e;t[43]!==M||t[44]!==A||t[45]!==S||t[46]!==b||t[47]!==w||t[48]!==a?(e=e=>{let t=q(e.name),n=t.displayName||e.name,r=bi(e.latestMessagePreview,a);return(0,$.jsx)(as,{assistantID:e.id,unreadCount:e.unreadCount??0,displayName:n,avatarEmoji:t.avatarEmoji??void 0,summary:r,enabled:e.enabled,editLabel:A,deleteLabel:M,assignedSessionIDs:e.assignedSessionIDs,serverWorking:e.working,onOpen:()=>b(e.id),onEdit:()=>S(e.id),onDelete:()=>w(e)},e.id)},t[43]=M,t[44]=A,t[45]=S,t[46]=b,t[47]=w,t[48]=a,t[49]=e):e=t[49],l=d.map(e),t[35]=d,t[36]=M,t[37]=A,t[38]=S,t[39]=b,t[40]=w,t[41]=a,t[42]=l}else l=t[42];let u;t[50]!==s||t[51]!==l?(u=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-catalog`,role:`listbox`,"aria-label":s,children:l}),t[50]=s,t[51]=l,t[52]=u):u=t[52];let f=p!==null,m;t[53]!==p||t[54]!==E||t[55]!==f?(m=(0,$.jsx)(vi,{assistant:p,open:f,onOpenChange:E}),t[53]=p,t[54]=E,t[55]=f,t[56]=m):m=t[56];let h;return t[57]!==i||t[58]!==O||t[59]!==r||t[60]!==o||t[61]!==u||t[62]!==m?(h=(0,$.jsxs)(ur,{title:O,className:i,surface:!1,scrollsWithPage:!0,trailing:r,children:[o,u,m]}),t[57]=i,t[58]=O,t[59]=r,t[60]=o,t[61]=u,t[62]=m,t[63]=h):h=t[63],h}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length===0){let e;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`oc-mobile-assistant-onboarding-icon`,children:(0,$.jsx)(X,{name:`ai-agent`,className:`size-5`})}),t[64]=e):e=t[64];let n;t[65]===a?n=t[66]:(n=a(`assistants.onboarding.title`),t[65]=a,t[66]=n);let r;t[67]===n?r=t[68]:(r=(0,$.jsx)(`h2`,{children:n}),t[67]=n,t[68]=r);let o;t[69]===a?o=t[70]:(o=a(`assistants.onboarding.description`),t[69]=a,t[70]=o);let s;t[71]===o?s=t[72]:(s=(0,$.jsx)(`p`,{children:o}),t[71]=o,t[72]=s);let c;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(X,{name:`add`,className:`size-[18px]`}),t[73]=c):c=t[73];let l;t[74]===a?l=t[75]:(l=a(`assistants.onboarding.action`),t[74]=a,t[75]=l);let u;t[76]!==v||t[77]!==l?(u=(0,$.jsxs)(G,{type:`button`,size:`lg`,className:`mt-6 w-full`,onClick:v,children:[c,l]}),t[76]=v,t[77]=l,t[78]=u):u=t[78];let d;t[79]!==r||t[80]!==s||t[81]!==u?(d=(0,$.jsxs)(dr,{className:`oc-mobile-assistant-onboarding`,children:[e,r,s,u]}),t[79]=r,t[80]=s,t[81]=u,t[82]=d):d=t[82];let f;return t[83]!==i||t[84]!==O||t[85]!==d?(f=(0,$.jsx)(ur,{title:O,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:d}),t[83]=i,t[84]=O,t[85]=d,t[86]=f):f=t[86],f}let N=s.isSuccess&&s.data.supported===!1,P=s.isError||s.data?.supported===!0&&s.data.enabled&&c.isError,F=s.data?.supported===!0&&(s.data.enabled===!1||c.data?.enabled===!1),I;t[87]!==a||t[88]!==P||t[89]!==N?(I=a(P?`assistants.state.unavailable`:N?`assistants.state.unsupportedTitle`:`assistants.state.instanceDisabled`),t[87]=a,t[88]=P,t[89]=N,t[90]=I):I=t[90];let L=I;if(F&&!P){let e;t[91]===g?e=t[92]:(e=(0,$.jsx)(is,{onEnable:g}),t[91]=g,t[92]=e);let n;return t[93]!==i||t[94]!==O||t[95]!==e?(n=(0,$.jsx)(ur,{title:O,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-guide-host`,children:e}),t[93]=i,t[94]=O,t[95]=e,t[96]=n):n=t[96],n}let R;t[97]===O?R=t[98]:(R=(0,$.jsx)(`span`,{className:`oc-mobile-page-section-label`,children:O}),t[97]=O,t[98]=R);let z=N?`cloud-off`:`sparkling`,B;t[99]===z?B=t[100]:(B=(0,$.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground`,children:(0,$.jsx)(X,{name:z,weight:`medium`,className:`size-5`})}),t[99]=z,t[100]=B);let H;t[101]===L?H=t[102]:(H=(0,$.jsx)(`h2`,{className:`mt-5 max-w-xs text-lg font-semibold leading-snug tracking-[-0.02em] text-foreground`,children:L}),t[101]=L,t[102]=H);let U;t[103]!==a||t[104]!==P||t[105]!==N?(U=P?null:(0,$.jsx)(`p`,{className:`mt-2 max-w-sm typography-small leading-relaxed text-muted-foreground`,children:a(N?`assistants.state.unsupportedDescription`:`assistants.state.instanceDisabledDescription`)}),t[103]=a,t[104]=P,t[105]=N,t[106]=U):U=t[106];let W;t[107]!==B||t[108]!==H||t[109]!==U?(W=(0,$.jsxs)(`section`,{className:`w-full max-w-md py-2`,children:[B,H,U]}),t[107]=B,t[108]=H,t[109]=U,t[110]=W):W=t[110];let K;t[111]!==R||t[112]!==W?(K=(0,$.jsx)(mr,{label:R,cardClassName:`oc-mobile-assistant-state-card`,children:W}),t[111]=R,t[112]=W,t[113]=K):K=t[113];let te;return t[114]!==i||t[115]!==O||t[116]!==K?(te=(0,$.jsx)(ur,{title:O,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:K}),t[114]=i,t[115]=O,t[116]=K,t[117]=te):te=t[117],te}function ss(e){return e.requestCreate}function cs(e){let t=(0,Q.c)(14),{assistantID:n,onBack:r}=e,{t:i}=ee(),a;t[0]===i?a=t[1]:(a=i(`assistants.title`),t[0]=i,t[1]=a);let o;t[2]===i?o=t[3]:(o=i(`settings.view.actions.back`),t[2]=i,t[3]=o);let s;t[4]!==r||t[5]!==a||t[6]!==o?(s=(0,$.jsx)(Y,{title:a,backAriaLabel:o,onBack:r}),t[4]=r,t[5]=a,t[6]=o,t[7]=s):s=t[7];let c;t[8]!==n||t[9]!==r?(c=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden px-[var(--oc-mobile-page-inline-inset)] pb-[var(--oc-safe-area-bottom,env(safe-area-inset-bottom,0px))]`,children:(0,$.jsx)(dr,{className:`oc-mobile-settings-detail-card h-full`,children:(0,$.jsx)(Xt,{children:(0,$.jsx)(di,{assistantID:n,onItemDeleted:r},n)})})}),t[8]=n,t[9]=r,t[10]=c):c=t[10];let l;return t[11]!==s||t[12]!==c?(l=(0,$.jsxs)(`div`,{"data-settings-view":`true`,"data-mobile-settings-stage":`page-content`,className:`oc-settings-workspace oc-settings-workspace-mobile flex h-full min-h-0 flex-col overflow-hidden bg-background`,children:[s,c]}),t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function ls(e){let t=(0,Q.c)(13),{route:n}=e,{t:r}=ee(),i;t[0]===r?i=t[1]:(i=r(`chat.btw.title`),t[0]=r,t[1]=i);let a;t[2]===r?a=t[3]:(a=r(`header.actions.backAria`),t[2]=r,t[3]=a);let o;t[4]!==i||t[5]!==a?(o=(0,$.jsx)(Y,{title:i,backAriaLabel:a,onBack:us}),t[4]=i,t[5]=a,t[6]=o):o=t[6];let s;t[7]!==n.directory||t[8]!==n.sessionId?(s=(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(xt,{scope:{sessionId:n.sessionId,directory:n.directory},foot:`page`})}),t[7]=n.directory,t[8]=n.sessionId,t[9]=s):s=t[9];let c;return t[10]!==o||t[11]!==s?(c=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[o,s]}),t[10]=o,t[11]=s,t[12]=c):c=t[12],c}function us(){Un.requestAnimatedBack(`root`)}var ds=[{id:`projects`,icon:`folder-open`,labelKey:`mobile.tabs.projects`},{id:`assistant`,icon:`sparkling`,labelKey:`mobile.tabs.assistant`},{id:`scheduled`,icon:`calendar-schedule`,labelKey:`mobile.tabs.scheduled`},{id:`settings`,icon:`settings-3`,labelKey:`mobile.tabs.settings`}];function fs(e){let t=(0,Q.c)(17),{activeTab:n,onTabChange:r,className:i}=e,{t:a}=ee(),o;t[0]===r?o=t[1]:(o=e=>{r(e.currentTarget.dataset.tab)},t[0]=r,t[1]=o);let s=V(o),c;t[2]!==n||t[3]!==r?(c=e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=ds.findIndex(e=>e.id===n),i=ds[e.key===`Home`?0:e.key===`End`?ds.length-1:(t+(e.key===`ArrowRight`?1:-1)+ds.length)%ds.length];r(i.id),document.getElementById(`mobile-tab-${i.id}`)?.focus()},t[2]=n,t[3]=r,t[4]=c):c=t[4];let l=V(c),u;t[5]===a?u=t[6]:(u=a(`mobile.nav.aria`),t[5]=a,t[6]=u);let d;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d={role:`tablist`},t[7]=d):d=t[7];let f;t[8]!==n||t[9]!==s||t[10]!==l||t[11]!==a?(f=ds.map(e=>{let t=e.id===n,r=a(e.labelKey);return(0,$.jsxs)(G,{id:`mobile-tab-${e.id}`,"data-tab":e.id,type:`button`,role:`tab`,variant:`ghost`,size:`sm`,"aria-controls":`mobile-tabpanel-${e.id}`,"aria-label":r,"aria-describedby":e.id===`assistant`?`mobile-tab-assistant-unread`:void 0,"aria-selected":t,tabIndex:t?0:-1,title:r,onClick:s,onKeyDown:l,className:W(`oc-mobile-tab-button min-w-0 flex-1 flex-col overflow-visible`,`text-xs font-medium leading-none tracking-tight text-muted-foreground`,`transition-[background-color,color,box-shadow,transform] duration-100`,`hover:bg-transparent hover:text-foreground`,`active:bg-interactive-active`,`motion-reduce:transition-none`,t&&[`bg-interactive-selection/55 text-primary`,`hover:bg-interactive-selection/55 hover:text-primary`,`font-semibold`]),children:[(0,$.jsxs)(`span`,{className:`relative inline-flex shrink-0 overflow-visible`,children:[(0,$.jsx)(X,{name:e.icon,weight:`medium`,className:`size-[23px] shrink-0`}),e.id===`assistant`?(0,$.jsx)(`span`,{id:`mobile-tab-assistant-unread`,className:`pointer-events-none absolute left-full -top-1 ml-0.5 inline-flex z-10`,children:(0,$.jsx)(Di,{className:`h-[18px] min-w-[18px] bg-foreground px-1 text-[11px] font-bold tracking-normal text-background shadow-none ring-2 ring-background`})}):null]}),(0,$.jsx)(`span`,{className:`oc-mobile-tab-label block max-w-full overflow-hidden text-ellipsis whitespace-nowrap`,children:r})]},e.id)}),t[8]=n,t[9]=s,t[10]=l,t[11]=a,t[12]=f):f=t[12];let p;return t[13]!==i||t[14]!==u||t[15]!==f?(p=(0,$.jsx)(hr,{as:`nav`,"aria-label":u,variant:`navigation`,surfaceProps:d,className:i,children:f}),t[13]=i,t[14]=u,t[15]=f,t[16]=p):p=t[16],p}var ps=`oc-native-ios-tab-bar`,ms=`OpenChamberTabBar`,hs=[`projects`,`assistant`,`scheduled`,`settings`],gs=F(ms),_s=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.nativeUiEnabled!==!1;function vs(){return typeof window>`u`?!1:_s({isCapacitor:O(),platform:A(),pluginAvailable:I.isPluginAvailable(ms),nativeUiEnabled:Ln()})}var ys=e=>e.classList.contains(`dark`)?`dark`:`light`,bs=()=>In(`--primary`),xs=e=>typeof e==`string`&&hs.includes(e),Ss=e=>typeof e==`string`&&xs(e)?e:null,Cs=(e,t)=>e.selectedTab===t.selectedTab&&e.appearance===t.appearance&&e.ariaLabel===t.ariaLabel&&e.accentColor===t.accentColor&&e.tabs.length===t.tabs.length&&e.tabs.every((e,n)=>e.id===t.tabs[n]?.id&&e.label===t.tabs[n]?.label&&e.badge===t.tabs[n]?.badge),ws=(e,t)=>{e.classList.toggle(ps,t)},Ts=(e,t)=>e&&!t,Es=e=>e.visible?e.overlayHidden?{action:`present`}:e.lastState&&Cs(e.lastState,e.nextState)?{action:`skip`}:{action:`present`}:e.overlayHidden?{action:`skip`}:{action:`hide`},Ds=()=>gs,Os=`mobile-overlay-root`;function ks(e){let t=(0,Q.c)(28),n=Rn(),r;t[0]===n?r=t[1]:(r=n&&vs(),t[0]=n,t[1]=r);let i=r,[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(null),f=(0,Z.useRef)(!1),p=(0,Z.useRef)(!1),m=V(e.onTabChange),h;t[2]===e.tabs?h=t[3]:(h=JSON.stringify(e.tabs.map(js)),t[2]=e.tabs,t[3]=h);let g=h,_;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=typeof document>`u`?`dark`:ys(document.documentElement),t[4]=_):_=t[4];let v=_,y;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=typeof document>`u`?``:bs(),t[5]=y):y=t[5];let b=y,x,S;t[6]===i?(x=t[7],S=t[8]):(x=()=>{if(!i||typeof document>`u`)return;let e=document.getElementById(Os);e||(e=document.createElement(`div`),e.id=Os,document.body.appendChild(e));let t=()=>u(wt(e.children));t();let n=new MutationObserver(t);return n.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[Ot]}),()=>n.disconnect()},S=[i],t[6]=i,t[7]=x,t[8]=S),(0,Z.useEffect)(x,S);let C;t[9]!==i||t[10]!==m?(C=()=>{if(!i)return;let e=!1,t=Ds(),n=[];return t.addListener(`tabSelected`,e=>{let t=Ss(e.tab);t&&m(t)}).then(t=>{if(e){t.remove();return}n.push(t)}),()=>{e=!0,d.current=null,t.hide();for(let e of n)e.remove();typeof document<`u`&&ws(document.documentElement,!1)}},t[9]=i,t[10]=m,t[11]=C):C=t[11];let w;t[12]===i?w=t[13]:(w=[i],t[12]=i,t[13]=w),(0,Z.useEffect)(C,w);let T;t[14]!==e.activeTab||t[15]!==e.ariaLabel||t[16]!==e.tabs||t[17]!==e.visible||t[18]!==i||t[19]!==l?(T=()=>{if(!i||p.current)return;let t=!1,n=Ds(),r={tabs:e.tabs.map(As),selectedTab:e.activeTab,appearance:v,accentColor:b,ariaLabel:e.ariaLabel},a=Es({visible:Ts(e.visible,l),overlayHidden:f.current,lastState:d.current,nextState:r});return(async()=>{if(a.action===`skip`)return;if(a.action===`hide`){f.current=!0,n.hide();return}let e=await n.present(r);if(!t){if(e.adopted!==!0){p.current=!0,c(!0),o(!1),typeof document<`u`&&ws(document.documentElement,!1);return}f.current=!1,d.current=r,o(!0),typeof document<`u`&&ws(document.documentElement,!0)}})().catch(()=>{t||(p.current=!0,c(!0),o(!1),typeof document<`u`&&ws(document.documentElement,!1))}),()=>{t=!0}},t[14]=e.activeTab,t[15]=e.ariaLabel,t[16]=e.tabs,t[17]=e.visible,t[18]=i,t[19]=l,t[20]=T):T=t[20];let E;return t[21]!==e.activeTab||t[22]!==e.ariaLabel||t[23]!==e.visible||t[24]!==i||t[25]!==l||t[26]!==g?(E=[i,e.visible,l,e.activeTab,e.ariaLabel,v,b,g],t[21]=e.activeTab,t[22]=e.ariaLabel,t[23]=e.visible,t[24]=i,t[25]=l,t[26]=g,t[27]=E):E=t[27],(0,Z.useLayoutEffect)(T,E),!i||s?`web`:a?`native`:`pending`}function As(e){return{id:e.id,label:e.label,badge:e.badge??null}}function js(e){return[e.id,e.label,e.badge??null]}function Ms(e){let t=(0,Q.c)(40),{tabs:n,navigation:r,onTabChange:i,secondaryPages:a,showTabBar:o,tabBarCovered:s,className:c}=e,l=a===void 0?[]:a,u=o===void 0||o,d=s!==void 0&&s,{t:f}=ee(),p=r.activeTab,m=l.slice(-2),h=m.at(-1)??null,g=h?.key??null,_=h?.depth,v=m.length>1?m[m.length-2].key:null,y;t[0]===p?y=t[1]:(y=()=>new Set([p]),t[0]=p,t[1]=y);let[b,x]=Z.useState(y);b.has(p)||x(e=>{if(e.has(p))return e;let t=new Set(e);return t.add(p),t});let S=Z.useRef(null),C=Z.useRef(null),w=Z.useRef(null),T=Z.useRef(new Map),E=Z.useRef(null),D=Z.useRef(!1),O=Z.useRef(``),k=V(()=>h?.onBack());Vn({id:h?`mobile-secondary:${h.key}`:`mobile-secondary:inactive`,active:!!h,onBack:k,surfaceRef:S,underlayRef:C}),Z.useLayoutEffect(()=>{let e=g===null?null:T.current.get(g)??null,t=v===null?w.current:T.current.get(v)??null;S.current=e,C.current=t},[g,_,v]);let A;t[2]===h?A=t[3]:(A=[h],t[2]=h,t[3]=A),Z.useLayoutEffect(()=>{if(h){if(!D.current){let e=document.activeElement;E.current=e instanceof HTMLElement?e:null,D.current=!0}O.current!==h.key&&(O.current=h.key,S.current?.focus());return}if(D.current){D.current=!1,O.current=``;let e=E.current;E.current=null,e&&e.isConnected&&e.focus()}},A);let j;t[4]===i?j=t[5]:(j=e=>{i(e)},t[4]=i,t[5]=j);let M=V(j),N=le(),P;t[6]!==N||t[7]!==f?(P=ds.map(e=>({id:e.id,label:f(e.labelKey),badge:e.id===`assistant`&&N>0?N>99?`99+`:String(N):null})),t[6]=N,t[7]=f,t[8]=P):P=t[8];let F=P,I=u&&!d&&!h,L;t[9]===f?L=t[10]:(L=f(`mobile.nav.aria`),t[9]=f,t[10]=L);let R;t[11]!==M||t[12]!==I||t[13]!==F||t[14]!==p||t[15]!==L?(R={visible:I,activeTab:p,tabs:F,ariaLabel:L,onTabChange:M},t[11]=M,t[12]=I,t[13]=F,t[14]=p,t[15]=L,t[16]=R):R=t[16];let z=ks(R),B=z===`native`,H=u&&z===`web`,U=Rn(),G,K;t[17]!==U||t[18]!==B?(G=()=>{if(!U){Wn.shutdown();return}B&&Hn(!0)&&Wn.warm()},K=[U,B],t[17]=U,t[18]=B,t[19]=G,t[20]=K):(G=t[19],K=t[20]),Z.useEffect(G,K);let te;t[21]===c?te=t[22]:(te=W(`oc-mobile-floating-shell relative isolate flex h-full min-h-0 flex-col overflow-hidden text-foreground`,`bg-[var(--oc-mobile-page-background)]`,c),t[21]=c,t[22]=te);let q=h?!0:void 0,ne=h?!0:void 0,re;t[23]!==p||t[24]!==u||t[25]!==H||t[26]!==f||t[27]!==n||t[28]!==b?(re=ds.map(e=>{let t=b.has(e.id);return(0,$.jsx)(`section`,{id:`mobile-tabpanel-${e.id}`,role:`tabpanel`,"aria-labelledby":H?`mobile-tab-${e.id}`:void 0,"aria-label":H?void 0:f(e.labelKey),hidden:p!==e.id,tabIndex:0,className:W(`scrollbar-none h-full min-h-0 flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--oc-mobile-page-inline-inset)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+1rem)] outline-none`,u?`pb-[calc(var(--oc-mobile-dock-height)+2.5rem+var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px)))]`:`pb-0`),children:t?n?.[e.id]??(0,$.jsx)(Ns,{tab:e.id,icon:e.icon}):null},e.id)}),t[23]=p,t[24]=u,t[25]=H,t[26]=f,t[27]=n,t[28]=b,t[29]=re):re=t[29];let ie;t[30]!==w||t[31]!==q||t[32]!==ne||t[33]!==re?(ie=(0,$.jsx)(`div`,{ref:w,"data-mobile-navigation-underlay":`true`,"aria-hidden":q,inert:ne,className:`flex h-full min-h-0 flex-1 flex-col`,children:re}),t[30]=w,t[31]=q,t[32]=ne,t[33]=re,t[34]=ie):ie=t[34];let ae=u?(0,$.jsx)(`div`,{"data-mobile-navigation-dock-underlay":`true`,"aria-hidden":h||B?!0:void 0,inert:h||B?!0:void 0,children:H?(0,$.jsx)(fs,{activeTab:p,onTabChange:M}):null}):null,oe=m.map((e,t)=>{let n=t===m.length-1;return(0,$.jsx)(`div`,{ref:t=>{t?T.current.set(e.key,t):T.current.delete(e.key)},"data-mobile-secondary-page":`true`,"data-mobile-secondary-active":n?`true`:`false`,role:n?`dialog`:void 0,"aria-modal":n?!0:void 0,"aria-label":n?e.ariaLabel??f(`mobile.nav.secondaryPageAria`):void 0,"aria-hidden":!n||void 0,inert:!n||void 0,tabIndex:n?-1:void 0,className:W(`absolute inset-0 flex h-full min-h-0 flex-col overflow-hidden bg-background outline-none`,n?`z-50`:`z-40`),children:e.content},e.key)}),se;return t[35]!==te||t[36]!==ie||t[37]!==ae||t[38]!==oe?(se=(0,$.jsxs)(`div`,{className:te,children:[ie,ae,oe]}),t[35]=te,t[36]=ie,t[37]=ae,t[38]=oe,t[39]=se):se=t[39],se}function Ns(e){let t=(0,Q.c)(17),{tab:n,icon:r,className:i}=e,{t:a}=ee(),o,s,c,l;if(t[0]!==i||t[1]!==r||t[2]!==a||t[3]!==n){let e=ds.find(e=>e.id===n)??ds[0];t[8]===i?c=t[9]:(c=W(`flex min-h-[70dvh] flex-col items-center justify-center gap-3 text-center`,i),t[8]=i,t[9]=c),l=(0,$.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-2xl bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(X,{name:r??e.icon,className:`size-6`})}),o=`typography-ui-label font-semibold tracking-[-0.01em] text-foreground`,s=a(e.labelKey),t[0]=i,t[1]=r,t[2]=a,t[3]=n,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else o=t[4],s=t[5],c=t[6],l=t[7];let u;t[10]!==o||t[11]!==s?(u=(0,$.jsx)(`h1`,{className:o,children:s}),t[10]=o,t[11]=s,t[12]=u):u=t[12];let d;return t[13]!==c||t[14]!==l||t[15]!==u?(d=(0,$.jsxs)(`div`,{className:c,children:[l,u]}),t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}var Ps={neutral:void 0,info:{color:`var(--status-info)`,backgroundColor:`var(--status-info-background)`},success:{color:`var(--status-success)`,backgroundColor:`var(--status-success-background)`},warning:{color:`var(--status-warning)`,backgroundColor:`var(--status-warning-background)`},error:{color:`var(--status-error)`,backgroundColor:`var(--status-error-background)`}},Fs=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/g,``);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n.length<=1?t:n.length===2?n[0]:n.slice(-3,-1).join(`/`)};function Is({project:e,expanded:t,embedded:n=!1,onToggle:r,onOpenActions:i,className:a,highlightQuery:o}){let{t:s}=ee(),[c,l]=Z.useState(!1),u=Z.useRef(null);u.current||=tr({onPressedKeyChange:t=>l(t===e.id)}),Z.useEffect(()=>()=>u.current?.reset(),[]);let d=V(()=>{u.current?.consumeClick(e.id)||r(e)}),f=V(()=>i?.(e)),p=V(t=>{if(!i||t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0)return;let n=i;u.current?.start({pointerId:t.pointerId,key:e.id,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>{l(!1),n(e)}})}),m=V(e=>{u.current?.move(e.pointerId,e.clientX,e.clientY)}),h=V(e=>{u.current?.end(e.pointerId)}),g=V(e=>{u.current?.cancel(e.pointerId)}),_=V(t=>{if(!i)return;let n=i;t.preventDefault(),t.stopPropagation(),u.current?.openFromContextMenu(e.id,()=>{l(!1),n(e)})}),v=e.sessionCount===1?s(`mobile.sessions.project.sessionsSingle`):s(`mobile.sessions.project.sessionsPlural`,{count:e.sessionCount}),y=Fs(e.path),b=(0,$.jsxs)(`article`,{"data-mobile-press-surface":`soft`,"data-pressed":c?`true`:void 0,className:W(`oc-mobile-project-card relative flex items-stretch overflow-hidden rounded-[var(--oc-mobile-surface-radius)]`,a),children:[(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-surface-trigger":!0,className:`oc-mobile-project-trigger flex min-w-0 flex-1 items-center text-left outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-expanded":t,onClick:d,onPointerDown:p,onPointerMove:m,onPointerUp:h,onPointerCancel:g,onContextMenu:_,style:{touchAction:`pan-y`},children:[(0,$.jsx)(`span`,{className:W(`oc-mobile-project-icon oc-mobile-glass-control flex shrink-0 items-center justify-center rounded-full text-muted-foreground`),style:Ps[e.tone??`neutral`],"aria-hidden":!0,children:(0,$.jsx)(X,{name:e.icon??`code-box`,className:`oc-mobile-project-icon-glyph`})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`oc-mobile-project-title oc-mobile-entity-title truncate font-semibold text-foreground`,children:o?Yt(e.name,o):e.name}),e.active?(0,$.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-[var(--status-success)] shadow-[0_0_0_3px_color-mix(in_srgb,var(--status-success)_12%,transparent)]`,"aria-label":s(`mobile.sessions.activeProjectAria`)}):null]}),(0,$.jsxs)(`span`,{className:`oc-mobile-project-meta oc-mobile-entity-meta flex min-w-0 items-center text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:v}),e.activityLabel?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`·`}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:e.activityLabel})]}):null,y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`·`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,title:e.path,children:y})]}):null]})]}),(0,$.jsx)(X,{name:`arrow-down-s`,className:W(`oc-mobile-project-chevron shrink-0 text-muted-foreground transition-transform duration-150 motion-reduce:transition-none`,t?`rotate-0`:`-rotate-90`)})]}),i?(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-mobile-project-action self-center rounded-full text-muted-foreground`,"aria-label":s(`sessions.sidebar.project.actions.projectMenu`),onClick:f,children:(0,$.jsx)(X,{name:`more-2`,className:`size-4`})}):null]});return n?b:(0,$.jsx)(dr,{asChild:!0,children:b})}var Ls=({hasPendingQuestion:e,hasPendingPermission:t,running:n,unread:r})=>e?`question`:t?`permission`:n?`running`:r?`completed-unread`:`idle`,Rs=10,zs=`oc:mobile-session-row-revealed`,Bs=e=>{window.dispatchEvent(new CustomEvent(zs,{detail:e}))};function Vs({session:e,depth:t=0,hasChildren:n=!1,expanded:r=!1,paginationContinues:i=!1,onToggleChildren:a,onSelect:o,onPin:s,onArchive:c,onOpenActions:l,indicator:u,className:d,highlightQuery:f}){let{t:p}=ee(),[m,h]=Z.useState(0),[g,_]=Z.useState(!1),v=Z.useRef(null),y=Z.useRef(!1),b=Z.useRef(null),x=Z.useRef(null);x.current||=tr(),Z.useEffect(()=>()=>x.current?.reset(),[]),Z.useEffect(()=>{let t=t=>{t.detail!==e.id&&h(0)};return window.addEventListener(zs,t),()=>window.removeEventListener(zs,t)},[e.id]),Z.useEffect(()=>{h(0)},[e.id]);let S=V(()=>h(0)),C=m!==0,w=V(t=>{if(t.button!==0||t.pointerType!==`touch`&&t.pointerType!==`pen`)return;let n=b.current?.offsetWidth??0;n<=0||(v.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startOffset:m,actionWidth:n,intent:`pending`},y.current=!1,x.current?.start({pointerId:t.pointerId,key:e.id,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>{l(e)}}))}),T=V(t=>{let n=v.current;if(!n||n.pointerId!==t.pointerId)return;let r=t.clientX-n.startX,i=t.clientY-n.startY;if(x.current?.move(t.pointerId,t.clientX,t.clientY),n.intent===`pending`){let a=Math.abs(r),o=Math.abs(i);if(o>Rs&&o>a){n.intent=`vertical`,v.current=null,x.current?.cancel(t.pointerId);return}if(a>Rs&&a>o){n.intent=`horizontal`,_(!0),y.current=!0,x.current?.cancel(t.pointerId);try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}Bs(e.id)}}if(n.intent!==`horizontal`)return;t.preventDefault();let a=Math.max(-n.actionWidth,Math.min(0,n.startOffset+r));h(a)}),E=V(e=>{let t=v.current;x.current?.end(e.pointerId),!(!t||t.pointerId!==e.pointerId)&&(v.current=null,t.intent===`horizontal`&&(_(!1),h(e=>e<-(t.actionWidth*.35)?-t.actionWidth:0)))}),D=V(e=>{let t=v.current;v.current=null,x.current?.cancel(e.pointerId),_(!1),h(t?.startOffset??0)}),O=V(()=>{if(!x.current?.consumeClick(e.id)){if(y.current){y.current=!1;return}if(m!==0){S();return}Bs(e.id),o(e)}}),k=V(t=>{t.preventDefault(),t.stopPropagation(),x.current?.openFromContextMenu(e.id,()=>{l(e)})}),A=V(()=>{S(),s(e)}),j=V(()=>{S(),c(e)}),M=V(()=>l(e)),N=V(()=>a?.()),P=e.pinned?p(`sessions.sidebar.session.menu.unpin`):p(`sessions.sidebar.session.menu.pin`),F=u??Ls({hasPendingQuestion:!1,hasPendingPermission:!1,running:!1,unread:!!e.unread}),I=F===`question`?p(`sessions.sidebar.session.status.questionRequired`):F===`permission`?p(`sessions.sidebar.session.status.permissionRequired`):F===`running`?p(`sessions.sidebar.session.status.active`):F===`completed-unread`?p(`sessions.sidebar.session.status.unread`):void 0;return e.kind===`pagination`?(0,$.jsx)(`div`,{className:W(`oc-mobile-session-row`,i&&`oc-mobile-session-pagination-continues`,d),children:(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-session-pagination-row`,style:{touchAction:`pan-y`},onClick:O,onPointerDown:()=>void 0,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left font-medium text-foreground typography-meta`,children:e.title}),e.subtitle?(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.subtitle}):null,(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground`})]})}):(0,$.jsxs)(`div`,{className:W(`oc-mobile-session-row relative isolate`,d),children:[(0,$.jsxs)(`div`,{ref:b,className:W(`oc-mobile-session-actions absolute inset-y-0 right-0 z-0 flex items-stretch`,g?`transition-none`:`transition-transform duration-150 ease-out`,!C&&`invisible pointer-events-none`),style:{transform:`translate3d(calc(var(--oc-mobile-session-actions-width) + ${m}px), 0, 0)`,willChange:m===0?void 0:`transform`},"aria-hidden":!C,children:[(0,$.jsxs)(G,{type:`button`,variant:`secondary`,className:`oc-mobile-session-action h-full flex-col rounded-none border-0 bg-interactive-selection px-1 text-interactive-selection-foreground hover:bg-interactive-active`,"aria-label":P,tabIndex:C?0:-1,onClick:A,children:[(0,$.jsx)(X,{name:e.pinned?`unpin`:`pushpin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:P})]}),(0,$.jsxs)(G,{type:`button`,variant:`destructive`,className:`oc-mobile-session-action h-full flex-col rounded-none border-0 px-1`,"aria-label":p(`sessions.sidebar.bulkActions.archive`),tabIndex:C?0:-1,onClick:j,children:[(0,$.jsx)(X,{name:`archive`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:p(`sessions.sidebar.bulkActions.archive`)})]})]}),(0,$.jsxs)(`div`,{className:W(`oc-mobile-session-row-content relative z-10 flex items-center`,`text-foreground`,`ease-out motion-reduce:transition-none`,g?`transition-none`:`transition-[transform,background-color] duration-150`,e.archived&&`opacity-55`),"data-dragging":g?`true`:void 0,style:{transform:`translate3d(${m}px, 0, 0)`,willChange:m===0?void 0:`transform`},children:[n&&a?(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,className:`min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":p(r?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:N,children:(0,$.jsx)(X,{name:`arrow-down-s`,className:W(`size-3.5 transition-transform duration-150 motion-reduce:transition-none`,r?`rotate-0`:`-rotate-90`)})}):null,(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-session-row-main flex min-w-0 flex-1 items-center text-left outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,style:{paddingLeft:16+Math.min(t,4)*12,touchAction:`pan-y`},onClick:O,onPointerDown:w,onPointerMove:T,onPointerUp:E,onPointerCancel:D,onContextMenu:k,children:[(0,$.jsx)(`span`,{className:`oc-mobile-session-status shrink-0`,"data-session-status":F,"aria-hidden":!I||void 0,"aria-label":I,title:I,children:F===`running`?(0,$.jsx)(Ur,{className:`motion-reduce:[&_svg]:animate-none`}):F===`question`?(0,$.jsx)(X,{name:`question`,className:`size-3.5 text-[var(--status-warning)]`}):F===`permission`?(0,$.jsx)(X,{name:`shield`,className:`size-3.5 text-destructive`}):(0,$.jsx)(`span`,{className:W(`oc-mobile-session-dot rounded-full`,F===`completed-unread`?`bg-[var(--status-info)]`:`bg-muted-foreground/35`)})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:W(`oc-mobile-session-title truncate`,e.unread?`font-semibold`:`font-medium`),children:f?Yt(e.title,f):e.title}),e.changes?(0,$.jsx)(`span`,{className:`oc-mobile-session-changes shrink-0 tabular-nums text-muted-foreground`,children:e.changes}):null,e.archived?(0,$.jsx)(X,{name:`archive`,className:`size-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}):null]}),e.subtitle?(0,$.jsx)(`span`,{className:`oc-mobile-session-subtitle truncate text-muted-foreground`,children:f?Yt(e.subtitle,f):e.subtitle}):null]}),(0,$.jsx)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-muted-foreground`,children:e.activityLabel?(0,$.jsx)(`span`,{className:`oc-mobile-session-time tabular-nums`,children:e.activityLabel}):null})]}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,className:`mr-1 min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":p(`sessions.sidebar.session.menu.label`),onClick:M,children:(0,$.jsx)(X,{name:`more-2`,className:`size-3.5`})})]})]})}var Hs=Z.memo(Vs),Us=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e)),Ws=e=>e.catalogSessions??e.sessions,Gs=(e,t)=>e.filter(e=>e.kind!==`pagination`&&Us(t,e.title,e.subtitle,e.id)),Ks=(e,t)=>{let n=Ws(e);if(Us(t,e.name,e.path))return{...e,sessions:n.filter(e=>e.kind!==`pagination`)};let r=Gs(n,t);return r.length>0?{...e,sessions:r}:null},qs=(e,t)=>{let n=t.trim().toLowerCase();return n?e.flatMap(e=>{if(Us(n,e.name,e.path))return[{...e,worktrees:[]}];let t=e.worktrees.flatMap(e=>{let t=Ks(e,n);return t?[t]:[]});return t.length>0?[{...e,worktrees:t}]:[]}):e},Js=10,Ys=`oc:mobile-worktree-row-revealed`,Xs=e=>{window.dispatchEvent(new CustomEvent(Ys,{detail:e}))};function Zs(e){let t=(0,Q.c)(10),n=Ae(e.session.id),r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={bootstrap:!1},t[0]=r):r=t[0];let i=Xe(e.session.id,e.session.directory,r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a={bootstrap:!1},t[1]=a):a=t[1];let o=Be(e.session.id,e.session.directory,a).length>0,s=i.length>0,c=n?.type===`busy`||n?.type===`retry`,l=!!e.session.unread,u;t[2]!==o||t[3]!==s||t[4]!==c||t[5]!==l?(u=Ls({hasPendingQuestion:o,hasPendingPermission:s,running:c,unread:l}),t[2]=o,t[3]=s,t[4]=c,t[5]=l,t[6]=u):u=t[6];let d=u,f;return t[7]!==d||t[8]!==e?(f=(0,$.jsx)(Hs,{...e,indicator:d}),t[7]=d,t[8]=e,t[9]=f):f=t[9],f}var Qs=Z.memo(Zs);function $s(e){let t=(0,Q.c)(9),{sessions:n,onSelectSession:r,onPinSession:i,onArchiveSession:a,onOpenSessionActions:o,highlightQuery:s}=e,c;t[0]!==s||t[1]!==a||t[2]!==o||t[3]!==i||t[4]!==r||t[5]!==n?(c=n.map((e,t)=>{let c=e.kind===`pagination`&&n[t+1]?.kind===`pagination`,l=e.kind===`pagination`?Hs:Qs;return(0,$.jsx)(l,{session:e,paginationContinues:c,highlightQuery:s,onSelect:r,onPin:i,onArchive:a,onOpenActions:o},e.id)}),t[0]=s,t[1]=a,t[2]=o,t[3]=i,t[4]=r,t[5]=n,t[6]=c):c=t[6];let l;return t[7]===c?l=t[8]:(l=(0,$.jsx)($.Fragment,{children:c}),t[7]=c,t[8]=l),l}var ec=Z.memo($s);function tc({project:e,worktree:t,expanded:n,onToggle:r,onNewSession:i,onOpenActions:a,onDelete:o,highlightQuery:s}){let{t:c}=ee(),l=`${e.id}::${t.id}`,u=!!(i||o),d=!!a,f=Number(!!i)+Number(!!o),[p,m]=Z.useState(0),[h,g]=Z.useState(!1),[_,v]=Z.useState(!1),y=Z.useRef(null),b=Z.useRef(!1),x=Z.useRef(null),S=Z.useRef(null);S.current||=tr({onPressedKeyChange:e=>g(e===l)}),Z.useEffect(()=>()=>S.current?.reset(),[]),Z.useEffect(()=>{let e=e=>{e.detail!==l&&m(0)};return window.addEventListener(Ys,e),()=>window.removeEventListener(Ys,e)},[l]),Z.useEffect(()=>{m(0)},[l]);let C=V(()=>m(0)),w=p!==0,T=V(n=>{if(n.button===0&&(n.pointerType===`touch`||n.pointerType===`pen`)){if(u){let e=x.current?.offsetWidth??0;e>0&&(y.current={pointerId:n.pointerId,startX:n.clientX,startY:n.clientY,startOffset:p,actionWidth:e,intent:`pending`},b.current=!1)}d&&S.current?.start({pointerId:n.pointerId,key:l,clientX:n.clientX,clientY:n.clientY,onTrigger:()=>{g(!1),a?.(e,t)}})}}),E=V(e=>{let t=y.current;if(!t||t.pointerId!==e.pointerId){S.current?.move(e.pointerId,e.clientX,e.clientY);return}let n=e.clientX-t.startX,r=e.clientY-t.startY;if(S.current?.move(e.pointerId,e.clientX,e.clientY),t.intent===`pending`){let i=Math.abs(n),a=Math.abs(r);if(a>Js&&a>i){t.intent=`vertical`,y.current=null,S.current?.cancel(e.pointerId);return}if(i>Js&&i>a){t.intent=`horizontal`,v(!0),b.current=!0,S.current?.cancel(e.pointerId);try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}Xs(l)}}if(t.intent!==`horizontal`)return;e.preventDefault();let i=Math.max(-t.actionWidth,Math.min(0,t.startOffset+n));m(i)}),D=V(e=>{let t=y.current;S.current?.end(e.pointerId),!(!t||t.pointerId!==e.pointerId)&&(y.current=null,t.intent===`horizontal`&&(v(!1),m(e=>e<-(t.actionWidth*.35)?-t.actionWidth:0)))}),O=V(e=>{let t=y.current;y.current=null,S.current?.cancel(e.pointerId),v(!1),m(t?.startOffset??0)}),k=V(()=>{if(!S.current?.consumeClick(l)){if(b.current){b.current=!1;return}if(p!==0){C();return}r()}}),A=V(n=>{d&&(n.preventDefault(),n.stopPropagation(),S.current?.openFromContextMenu(l,()=>{g(!1),a?.(e,t)}))}),j=V(()=>{C(),i?.(e,t)}),M=V(()=>{C(),o?.(e,t)}),N=V(()=>a?.(e,t)),P=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`oc-mobile-group-label-icon`,"aria-hidden":!0,children:(0,$.jsx)(X,{name:`git-branch`,className:`size-3.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left oc-mobile-entity-title font-semibold text-foreground`,children:s?Yt(t.name,s):t.name}),(0,$.jsx)(`span`,{className:`typography-small text-muted-foreground tabular-nums`,children:t.sessionCount===1?c(`mobile.sessions.project.sessionsSingle`):c(`mobile.sessions.project.sessionsPlural`,{count:t.sessionCount})}),(0,$.jsx)(X,{name:`arrow-down-s`,className:W(`size-3.5 text-muted-foreground transition-transform duration-150 motion-reduce:transition-none`,n?`rotate-0`:`-rotate-90`)})]});return(0,$.jsxs)(`div`,{className:`oc-mobile-group-label oc-mobile-worktree-label relative isolate overflow-hidden`,children:[u?(0,$.jsxs)(`div`,{ref:x,className:W(`oc-mobile-worktree-actions absolute inset-y-0 right-0 z-0 flex items-stretch`,_?`transition-none`:`transition-transform duration-150 ease-out`,!w&&`invisible pointer-events-none`),style:{width:`calc(${f} * var(--oc-mobile-worktree-action-width))`,transform:`translate3d(calc(100% + ${p}px), 0, 0)`,willChange:p===0?void 0:`transform`},"aria-hidden":!w,children:[i?(0,$.jsxs)(G,{type:`button`,variant:`secondary`,className:`oc-mobile-worktree-action h-full flex-col rounded-none border-0 bg-interactive-selection px-1 text-interactive-selection-foreground hover:bg-interactive-active`,"aria-label":c(`mobile.sessions.newSessionAria`),tabIndex:w?0:-1,onClick:j,children:[(0,$.jsx)(X,{name:`add`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:c(`sessions.sidebar.project.actions.newSession`)})]}):null,o?(0,$.jsxs)(G,{type:`button`,variant:`destructive`,className:`oc-mobile-worktree-action h-full flex-col rounded-none border-0 px-1`,"aria-label":c(`mobile.projectEdit.deleteWorktreeAria`,{label:t.name}),tabIndex:w?0:-1,onClick:M,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:c(`mobile.projectEdit.deleteWorktreeConfirmButton`)})]}):null]}):null,(0,$.jsxs)(`div`,{className:W(`oc-mobile-worktree-label-content relative z-10 flex min-w-0 flex-1 items-center`,`ease-out motion-reduce:transition-none`,_?`transition-none`:`transition-transform duration-150`),style:{transform:`translate3d(${p}px, 0, 0)`,willChange:p===0?void 0:`transform`},"data-pressed":h?`true`:void 0,children:[(0,$.jsx)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-group-label-trigger oc-mobile-worktree-label-trigger`,"aria-expanded":n,onClick:k,onPointerDown:T,onPointerMove:E,onPointerUp:D,onPointerCancel:O,onContextMenu:A,style:{touchAction:`pan-y`},children:P}),d?(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-mobile-worktree-more rounded-full text-muted-foreground`,"aria-label":c(`agentManager.detail.actions.worktreeActionsAria`),onClick:N,children:(0,$.jsx)(X,{name:`more-2`,className:`size-3.5`})}):null]})]})}function nc(e){let t=(0,Q.c)(130),{projects:n,pinnedSessions:r,inProgressSessions:i,onAddProject:a,onNewSession:o,onScanQr:s,onSwitchInstance:c,onToggleProject:l,onOpenProjectActions:u,onToggleWorktree:d,onNewWorktreeSession:f,onOpenWorktreeActions:p,onDeleteWorktree:m,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v,className:y}=e,b;t[0]===i?b=t[1]:(b=i===void 0?[]:i,t[0]=i,t[1]=b);let x=b,{t:S}=ee(),[C,w]=Z.useState(!0),[T,E]=Z.useState(!1),[D,O]=Z.useState(!1),[k,A]=Z.useState(``),j;t[2]===k?j=t[3]:(j=k.trim().toLowerCase(),t[2]=k,t[3]=j);let M=j,N=M.length>0,P;t[4]!==M||t[5]!==n?(P=qs(n,M),t[4]=M,t[5]=n,t[6]=P):P=t[6];let F=P,I=V(a),L=V(o),R;t[7]===s?R=t[8]:(R=()=>s?.(),t[7]=s,t[8]=R);let z=V(R),B;t[9]===c?B=t[10]:(B=()=>c?.(),t[9]=c,t[10]=B);let H=V(B),U;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(U=e=>O(e),t[11]=U):U=t[11];let K=V(U),te;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(te=()=>{A(``),E(!1)},t[12]=te):te=t[12];let q=V(te),ne;t[13]!==q||t[14]!==T?(ne=()=>{if(T){q();return}E(!0)},t[13]=q,t[14]=T,t[15]=ne):ne=t[15];let re=V(ne),ie;t[16]!==q||t[17]!==l?(ie=e=>{q(),e.expanded||l(e)},t[16]=q,t[17]=l,t[18]=ie):ie=t[18];let ae=V(ie),oe;t[19]!==q||t[20]!==l||t[21]!==d?(oe=(e,t)=>{q(),e.expanded||l(e),t.expanded||d(e,t)},t[19]=q,t[20]=l,t[21]=d,t[22]=oe):oe=t[22];let se=V(oe),J;t[23]!==q||t[24]!==h?(J=e=>{q(),h(e)},t[23]=q,t[24]=h,t[25]=J):J=t[25];let ce=V(J),le;t[26]===y?le=t[27]:(le=W(`relative isolate mx-auto flex w-full max-w-[26rem] flex-col gap-5`,y),t[26]=y,t[27]=le);let ue;t[28]===S?ue=t[29]:(ue=S(`mobile.sessions.section.projects`),t[28]=S,t[29]=ue);let Y;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,$.jsx)($r,{mobile:!0}),t[30]=Y):Y=t[30];let de;t[31]===S?de=t[32]:(de=S(`mobile.projects.menu.label`),t[31]=S,t[32]=de);let fe=D?`rotate-45`:`rotate-0`,pe;t[33]===fe?pe=t[34]:(pe=W(`size-5 transition-transform duration-150 motion-reduce:transition-none`,fe),t[33]=fe,t[34]=pe);let me;t[35]===pe?me=t[36]:(me=(0,$.jsx)(X,{name:`add`,className:pe}),t[35]=pe,t[36]=me);let he;t[37]!==de||t[38]!==me?(he=(0,$.jsx)(cn,{asChild:!0,children:(0,$.jsx)(G,{type:`button`,size:`mobileIcon`,className:`oc-mobile-round-control border-transparent bg-[var(--primary-base)] text-[var(--primary-foreground)] shadow-[0_10px_22px_color-mix(in_srgb,var(--primary-base)_22%,transparent)] hover:bg-[var(--primary-hover)] dark:bg-[var(--primary-base)] dark:hover:bg-[var(--primary-hover)]`,"aria-label":de,children:me})}),t[37]=de,t[38]=me,t[39]=he):he=t[39];let ge=T?`close`:`search`,_e;t[40]===ge?_e=t[41]:(_e=(0,$.jsx)(X,{name:ge,className:`size-4`}),t[40]=ge,t[41]=_e);let ve;t[42]!==T||t[43]!==S?(ve=S(T?`mobile.sessions.clearSearchAria`:`mobile.sessions.searchAria`),t[42]=T,t[43]=S,t[44]=ve):ve=t[44];let ye;t[45]!==re||t[46]!==_e||t[47]!==ve?(ye=(0,$.jsxs)(tn,{className:`min-h-11`,onSelect:re,children:[_e,ve]}),t[45]=re,t[46]=_e,t[47]=ve,t[48]=ye):ye=t[48];let be;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,$.jsx)(X,{name:`chat-new`,className:`size-4`}),t[49]=be):be=t[49];let xe;t[50]===S?xe=t[51]:(xe=S(`mobile.projects.menu.newChat`),t[50]=S,t[51]=xe);let Se;t[52]!==L||t[53]!==xe?(Se=(0,$.jsxs)(tn,{className:`min-h-11`,onSelect:L,children:[be,xe]}),t[52]=L,t[53]=xe,t[54]=Se):Se=t[54];let Ce;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,$.jsx)(X,{name:`folder`,className:`size-4`}),t[55]=Ce):Ce=t[55];let we;t[56]===S?we=t[57]:(we=S(`mobile.projects.menu.newProject`),t[56]=S,t[57]=we);let Te;t[58]!==I||t[59]!==we?(Te=(0,$.jsxs)(tn,{className:`min-h-11`,onSelect:I,children:[Ce,we]}),t[58]=I,t[59]=we,t[60]=Te):Te=t[60];let Ee;t[61]!==z||t[62]!==s||t[63]!==S?(Ee=s?(0,$.jsxs)(tn,{className:`min-h-11`,onSelect:z,children:[(0,$.jsx)(X,{name:`scan-2`,className:`size-4`}),S(`mobile.projects.menu.scanQr`)]}):null,t[61]=z,t[62]=s,t[63]=S,t[64]=Ee):Ee=t[64];let De;t[65]!==H||t[66]!==c||t[67]!==S?(De=c?(0,$.jsxs)(tn,{className:`min-h-11`,onSelect:H,children:[(0,$.jsx)(X,{name:`server`,className:`size-4`}),S(`mobile.projects.menu.switchInstance`)]}):null,t[65]=H,t[66]=c,t[67]=S,t[68]=De):De=t[68];let Oe;t[69]!==ye||t[70]!==Se||t[71]!==Te||t[72]!==Ee||t[73]!==De?(Oe=(0,$.jsxs)(nn,{align:`end`,side:`bottom`,className:`min-w-44`,children:[ye,Se,Te,Ee,De]}),t[69]=ye,t[70]=Se,t[71]=Te,t[72]=Ee,t[73]=De,t[74]=Oe):Oe=t[74];let ke;t[75]!==K||t[76]!==D||t[77]!==he||t[78]!==Oe?(ke=(0,$.jsxs)($.Fragment,{children:[Y,(0,$.jsxs)(sn,{open:D,onOpenChange:K,children:[he,Oe]})]}),t[75]=K,t[76]=D,t[77]=he,t[78]=Oe,t[79]=ke):ke=t[79];let Ae;t[80]!==ue||t[81]!==ke?(Ae=(0,$.jsx)(sr,{title:ue,trailing:ke}),t[80]=ue,t[81]=ke,t[82]=Ae):Ae=t[82];let je;t[83]!==q||t[84]!==T||t[85]!==k||t[86]!==S?(je=T?(0,$.jsxs)(`div`,{className:`relative mx-1`,role:`search`,children:[(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 z-10 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(qt,{autoFocus:!0,type:`text`,inputMode:`search`,enterKeyHint:`search`,value:k,placeholder:S(`mobile.sessions.search.placeholder`),"aria-label":S(`mobile.sessions.searchAria`),className:W(`h-11 rounded-full pl-9`,k&&`pr-10`),onChange:e=>A(e.target.value),onKeyDown:e=>{e.key===`Escape`&&q()}}),k?(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute right-1.5 top-1/2 size-8 -translate-y-1/2 rounded-full text-muted-foreground`,"aria-label":S(`mobile.sessions.clearSearchAria`),onClick:()=>A(``),children:(0,$.jsx)(X,{name:`close`,className:`size-4`})}):null]}):null,t[83]=q,t[84]=T,t[85]=k,t[86]=S,t[87]=je):je=t[87];let Me;t[88]!==x||t[89]!==_||t[90]!==v||t[91]!==g||t[92]!==h||t[93]!==C||t[94]!==r||t[95]!==N||t[96]!==S?(Me=!N&&(r.length>0||x.length>0)?(0,$.jsx)(dr,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":S(`mobile.sessions.section.pinned`),children:[(0,$.jsx)(Is,{project:{id:`__pinned__`,name:S(`mobile.sessions.section.pinned`),path:``,icon:`pushpin`,sessionCount:r.length+x.length},expanded:C,embedded:!0,onToggle:()=>w(ic)}),C?(0,$.jsxs)(`div`,{className:`oc-mobile-project-groups`,role:`group`,children:[r.length>0?(0,$.jsx)(`div`,{className:`oc-mobile-labeled-surface-group`,children:(0,$.jsx)(ec,{sessions:r,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null,x.length>0?(0,$.jsx)(`div`,{className:`oc-mobile-labeled-surface-group`,children:(0,$.jsx)(ec,{sessions:x,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null]}):null]})}):null,t[88]=x,t[89]=_,t[90]=v,t[91]=g,t[92]=h,t[93]=C,t[94]=r,t[95]=N,t[96]=S,t[97]=Me):Me=t[97];let Ne;t[98]!==I||t[99]!==ae||t[100]!==se||t[101]!==ce||t[102]!==M||t[103]!==_||t[104]!==m||t[105]!==f||t[106]!==u||t[107]!==v||t[108]!==p||t[109]!==g||t[110]!==h||t[111]!==l||t[112]!==d||t[113]!==n.length||t[114]!==N||t[115]!==S||t[116]!==F?(Ne=n.length===0?(0,$.jsxs)(`section`,{className:`flex min-h-[52dvh] flex-col items-center justify-center px-6 text-center`,children:[(0,$.jsx)(`span`,{className:`mb-4 flex size-14 items-center justify-center rounded-2xl bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(X,{name:`folder-add`,className:`size-6`})}),(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:S(`mobile.sessions.empty.noProjectsTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-xs typography-small text-muted-foreground`,children:S(`mobile.sessions.empty.noProjectsDescription`)}),(0,$.jsxs)(G,{type:`button`,size:`lg`,className:`mt-4 min-h-10 rounded-full px-5`,onClick:I,children:[(0,$.jsx)(X,{name:`folder-add`,className:`size-4`}),S(`sessions.sidebar.header.actions.addProject`)]})]}):N&&F.length===0?(0,$.jsxs)(`section`,{className:`flex min-h-[40dvh] flex-col items-center justify-center px-6 text-center`,children:[(0,$.jsx)(X,{name:`search`,className:`mb-4 size-6 text-muted-foreground`}),(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:S(`mobile.sessions.empty.searchTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-xs typography-small text-muted-foreground`,children:S(`mobile.sessions.empty.searchDescription`)})]}):F.map(e=>{let t=N||e.expanded,n=e.worktrees.find(rc)??(e.worktrees.length===1&&!e.worktrees[0]?.kind?e.worktrees[0]:void 0),r=e.worktrees.filter(e=>e!==n),i=n?.sessions??[];return(0,$.jsx)(dr,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":e.name,children:[(0,$.jsx)(Is,{project:e,expanded:t,embedded:!0,highlightQuery:N?M:void 0,onToggle:()=>N?ae(e):l(e),onOpenActions:()=>u(e)}),t?(0,$.jsxs)(`div`,{className:`oc-mobile-project-groups`,role:`group`,"aria-label":e.name,children:[i.length>0?(0,$.jsx)(`div`,{className:`oc-mobile-labeled-surface-group`,children:(0,$.jsx)(ec,{sessions:i,highlightQuery:N?M:void 0,onSelectSession:N?ce:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null,r.map(t=>{let n=N||!!t.expanded;return(0,$.jsx)(mr,{className:`oc-mobile-worktree-group`,ariaLabel:t.name,label:(0,$.jsx)(tc,{project:e,worktree:t,expanded:n,highlightQuery:N?M:void 0,onToggle:()=>N?se(e,t):d(e,t),onNewSession:f,onOpenActions:N?void 0:p,onDelete:N?void 0:m}),children:n&&t.sessions.length>0?(0,$.jsx)(ec,{sessions:t.sessions,highlightQuery:N?M:void 0,onSelectSession:N?ce:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v}):null},t.id)})]}):null]})},e.id)}),t[98]=I,t[99]=ae,t[100]=se,t[101]=ce,t[102]=M,t[103]=_,t[104]=m,t[105]=f,t[106]=u,t[107]=v,t[108]=p,t[109]=g,t[110]=h,t[111]=l,t[112]=d,t[113]=n.length,t[114]=N,t[115]=S,t[116]=F,t[117]=Ne):Ne=t[117];let Pe;t[118]===S?Pe=t[119]:(Pe=S(`sessions.sidebar.header.actions.addProject`),t[118]=S,t[119]=Pe);let Fe;t[120]!==I||t[121]!==Pe?(Fe=(0,$.jsx)(`button`,{type:`button`,className:`sr-only`,onClick:I,children:Pe}),t[120]=I,t[121]=Pe,t[122]=Fe):Fe=t[122];let Ie;return t[123]!==le||t[124]!==Ae||t[125]!==je||t[126]!==Me||t[127]!==Ne||t[128]!==Fe?(Ie=(0,$.jsxs)(`main`,{className:le,children:[Ae,je,Me,Ne,Fe]}),t[123]=le,t[124]=Ae,t[125]=je,t[126]=Me,t[127]=Ne,t[128]=Fe,t[129]=Ie):Ie=t[129],Ie}function rc(e){return e.kind===`main`}function ic(e){return!e}function ac(e){let t=(0,Q.c)(13),{icon:n,label:r,onClick:i,destructive:a,disabled:o,spinning:s}=e,c=a!==void 0&&a,l=o!==void 0&&o,u=s!==void 0&&s,d;t[0]===i?d=t[1]:(d=()=>{_e(`light`),i()},t[0]=i,t[1]=d);let f=V(d),p=c?`destructive`:`ghost`,m=u?`size-5 animate-spin`:`size-5`,h;t[2]!==n||t[3]!==m?(h=(0,$.jsx)(X,{name:n,className:m}),t[2]=n,t[3]=m,t[4]=h):h=t[4];let g;t[5]===r?g=t[6]:(g=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[5]=r,t[6]=g);let _;return t[7]!==l||t[8]!==f||t[9]!==p||t[10]!==h||t[11]!==g?(_=(0,$.jsxs)(G,{type:`button`,variant:p,size:`lg`,className:`h-auto min-h-14 w-full justify-start gap-3 rounded-none supports-[corner-shape:squircle]:rounded-none px-4 leading-6 border-b border-[var(--surface-subtle)] last:border-b-0 active:bg-interactive-active dark:active:bg-interactive-active`,"data-mobile-press-feedback":`none`,disabled:l,onClick:f,children:[h,g]}),t[7]=l,t[8]=f,t[9]=p,t[10]=h,t[11]=g,t[12]=_):_=t[12],_}function oc(e,t,n){return e.reduce((e,t)=>{let n=!!t.separated,r=e.at(-1);return r?.separated===n?r.items.push(t):e.push({separated:n,items:[t]}),e},[]).map(e=>(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl bg-[var(--surface-muted)]`,"data-mobile-action-group":e.separated?`separated`:`standard`,children:e.items.map(e=>(0,$.jsx)(ac,{icon:e.icon,label:br(e,t),onClick:n(e.onClick),destructive:e.destructive,disabled:e.disabled,spinning:e.spinning},e.id))},e.items[0]?.id))}function sc(e){let t=(0,Q.c)(46),{open:n,target:r,actions:i,onOpenChange:a,refreshTranscriptDisabled:o,refreshTranscriptSpinning:s}=e,c=o!==void 0&&o,l=s!==void 0&&s,{t:u}=ee(),d;t[0]===a?d=t[1]:(d=e=>()=>{a(!1),e?.()},t[0]=a,t[1]=d);let f=d,p;bb0:{if(!r){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[2]=e):e=t[2],p=e;break bb0}if(r.kind===`session`){let e;t[3]!==i.onArchive||t[4]!==i.onCopyLink||t[5]!==i.onDelete||t[6]!==i.onRefreshTranscript||t[7]!==i.onRename||t[8]!==i.onShare||t[9]!==i.onTogglePin||t[10]!==i.onUnshare||t[11]!==c||t[12]!==l||t[13]!==r.pinned||t[14]!==r.shared?(e=ai({pinned:r.pinned,shared:r.shared,onRename:i.onRename,onTogglePin:i.onTogglePin,onShare:i.onShare,onCopyLink:i.onCopyLink,onUnshare:i.onUnshare,onRefreshTranscript:i.onRefreshTranscript,onArchive:i.onArchive,onDelete:i.onDelete,refreshTranscriptDisabled:c,refreshTranscriptSpinning:l}),t[3]=i.onArchive,t[4]=i.onCopyLink,t[5]=i.onDelete,t[6]=i.onRefreshTranscript,t[7]=i.onRename,t[8]=i.onShare,t[9]=i.onTogglePin,t[10]=i.onUnshare,t[11]=c,t[12]=l,t[13]=r.pinned,t[14]=r.shared,t[15]=e):e=t[15],p=e;break bb0}if(r.kind===`project`){let e;t[16]!==i.onCloseProject||t[17]!==i.onEditProject||t[18]!==i.onNewSession||t[19]!==i.onNewWorktree||t[20]!==i.onSyncSessions||t[21]!==r.gitRepository?(e=Lr({gitRepository:r.gitRepository,onNewSession:i.onNewSession,onNewWorktree:i.onNewWorktree,onSyncSessions:i.onSyncSessions,onEditProject:i.onEditProject,onCloseProject:i.onCloseProject}),t[16]=i.onCloseProject,t[17]=i.onEditProject,t[18]=i.onNewSession,t[19]=i.onNewWorktree,t[20]=i.onSyncSessions,t[21]=r.gitRepository,t[22]=e):e=t[22],p=e;break bb0}let e;t[23]!==i.onDeleteWorktree||t[24]!==i.onNewSession?(e=Or({onNewSession:i.onNewSession,onDeleteWorktree:i.onDeleteWorktree}),t[23]=i.onDeleteWorktree,t[24]=i.onNewSession,t[25]=e):e=t[25],p=e}let m=p;if(!r)return null;let h;t[26]===r.title?h=t[27]:(h=(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold`,children:r.title}),t[26]=r.title,t[27]=h);let g=r.title,_;t[28]===u?_=t[29]:(_=u(`mobile.surface.closeAria`),t[28]=u,t[29]=_);let v;t[30]===u?v=t[31]:(v=u(`mobile.sessions.sheet.resizeAria`),t[30]=u,t[31]=v);let y;t[32]!==m||t[33]!==f||t[34]!==u?(y=oc(m,u,f),t[32]=m,t[33]=f,t[34]=u,t[35]=y):y=t[35];let b;t[36]===y?b=t[37]:(b=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-y-auto overscroll-contain px-3 pb-3`,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-5`,"data-page-scroll-lock":`true`,children:y})}),t[36]=y,t[37]=b);let x;return t[38]!==a||t[39]!==n||t[40]!==b||t[41]!==h||t[42]!==_||t[43]!==v||t[44]!==r.title?(x=(0,$.jsx)(bn,{id:`mobile-row-actions-sheet`,open:n,onOpenChange:a,title:h,ariaLabel:g,closeAriaLabel:_,resizeAriaLabel:v,fitContent:!0,children:b}),t[38]=a,t[39]=n,t[40]=b,t[41]=h,t[42]=_,t[43]=v,t[44]=r.title,t[45]=x):x=t[45],x}function cc(e,t){return e&&e.id===t.id&&e.kind===t.kind&&e.title===t.title&&e.subtitle===t.subtitle&&e.changes===t.changes&&e.activityLabel===t.activityLabel&&e.unread===t.unread&&e.pinned===t.pinned&&e.archived===t.archived&&e.active===t.active&&e.directory===t.directory&&e.expanded===t.expanded&&e.children===t.children?e:t}function lc(e,t){if(!e||e.length===0)return t.slice();let n=new Map(e.map(e=>[e.id,e])),r=e.length===t.length,i=t.map((t,i)=>{let a=cc(n.get(t.id)??e[i],t);return a!==e[i]&&(r=!1),a});if(r){let t=!0;for(let n=0;n<i.length;n+=1)if(i[n]!==e[n]){t=!1;break}if(t)return e}return i}var uc=`__show_more__:`,dc=`__show_fewer__:`,fc=e=>e.startsWith(uc),pc=e=>e.startsWith(dc),mc=e=>fc(e)||pc(e),hc=e=>{let t=fc(e)?uc:pc(e)?dc:null;if(!t)return null;let n=e.slice(t.length),r=n.indexOf(`::`);return r<=0?null:{kind:t===`__show_more__:`?`more`:`fewer`,projectId:n.slice(0,r),bucketKey:n.slice(r+2)}},gc=e=>e.parentID??null,_c=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),vc=e=>{let t=e;return _c(t.directory??t.project?.worktree??null)},yc=(e,t)=>{if(t?.trim())return t.trim();let n=_c(e);if(!n)return``;let r=n.split(`/`).filter(Boolean);return r[r.length-1]||n},bc=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},xc=e=>{if(e<=0)return``;let t=Date.now()-e;if(t<6e4)return`now`;let n=Math.floor(t/6e4);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r<24)return`${r}h`;let i=Math.floor(r/24);return i<7?`${i}d`:new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))},Sc=e=>{let t=e.time?.archived;return typeof t==`number`&&t>0},Cc=(e,t)=>e.worktrees.find(e=>_c(e.path)===t)??null,wc=(e,t)=>{let n=t?.trim();return n?`${e} · ${n}`:e},Tc=(e,t)=>Zr(e,{pinnedSessionIds:t,omitPinnedSessions:!0}).map(e=>e.session);function Ec(){let{t:e}=ee(),t=xe(),n=Fe(e=>e.activeSessions),r=Fe(e=>e.activePaginationByDirectory),i=Ve(e=>e.projects),a=Ve(e=>e.activeProjectId),o=w(e=>e.currentDirectory),s=Re(e=>e.currentSessionId),c=Re(e=>e.availableWorktreesByProject),l=Mt(e=>e.orderByProject),u=De(),d=jo(e=>e.projectExpanded),f=jo(e=>e.worktreeExpanded),p=et(e=>e.index.session.unseenCount),[m,h]=Z.useState(new Map),g=Cr(),_=Z.useMemo(()=>Ar(g,s),[s,g]),v=Z.useMemo(()=>i.map(e=>{let t=_c(e.path);return{id:e.id,label:yc(t,e.label),path:t,icon:e.icon,worktrees:At(l[e.id],c.get(t)??[])}}),[i,l,c]),y=Z.useMemo(()=>{let e=new Map(t.map(e=>[e.id,e])),r=n.map(t=>{let n=e.get(t.id);return n?Ue(n,t):t}),i=new Set(r.map(e=>e.id));for(let e of t)i.has(e.id)||r.push(e);return r},[n,t]),b=Z.useMemo(()=>pr(y,v.map(e=>({id:e.id,normalizedPath:e.path})),c,!1),[v,y,c]),x=Z.useMemo(()=>{let e=v.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===a,latestActivity:0})),t=new Map(e.map(e=>[e.project.id,e])),n=(e,t,n)=>{let r=_c(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||n?.label||yc(r),path:r,worktree:n,sessions:[]},e.buckets.push(a)),a};for(let t of e){n(t,t.project.path,null);for(let e of t.project.worktrees)n(t,e.path,e)}for(let e of y){let r=b.bySessionId.get(e.id);if(!r)continue;let i=t.get(r.projectId);if(!i)continue;let a=r.kind===`worktree`?Cc(i.project,r.scopeDirectory):null;(a?n(i,a.path,a):n(i,i.project.path,null)).sessions.push(e)}for(let t of e)for(let e of t.buckets){e.sessions.sort((e,t)=>ze(t)-ze(e));let n=Tc(e.sessions,u);t.totalSessions+=n.length;for(let n of e.sessions){let e=bc(n);e>t.latestActivity&&(t.latestActivity=e)}}return e},[a,b,u,v,y]),S=Z.useMemo(()=>{let e=new Map;for(let t of y)e.set(t.id,t);return e},[y]),C=Z.useMemo(()=>{let e=new Map;for(let t of v)e.set(t.id,t);return e},[v]),T=Z.useRef([]),E=Z.useRef([]),D=Z.useRef(new Map),{pinnedSessions:O,inProgressSessions:k}=Z.useMemo(()=>{let t=new Map(v.map(e=>[e.id,e])),n=e(`mobile.sessions.untitled`),r=new Map(T.current.map(e=>[e.id,e])),i=new Map(E.current.map(e=>[e.id,e])),a=(e,r,i)=>{let a=b.bySessionId.get(e.id),o=a?t.get(a.projectId):void 0;if(!o)return[];let c=a?.kind===`worktree`?Cc(o,a.scopeDirectory):null,l={id:e.id,directory:vc(e),title:e.title?.trim()||n,subtitle:wc(o.label,c?.branch),changes:An(kn(e))??void 0,activityLabel:xc(bc(e))||void 0,unread:(p[e.id]??0)>0,pinned:r,archived:Sc(e),active:s===e.id};return[cc(i.get(e.id),l)]},o=Hr(y,u).flatMap(e=>a(e,!0,r)),c=Fr(y,u,g,p).flatMap(e=>a(e,!1,i)),l=lc(T.current,o),d=lc(E.current,c);return T.current=l,E.current=d,{pinnedSessions:l,inProgressSessions:d}},[s,b,u,v,g,y,e,p]),A=Z.useMemo(()=>{let e=new Map;for(let t of x){let n=t.project.worktrees.length>0;for(let r of t.buckets){let i=Tc(r.sessions,u).length;e.set(`${t.project.id}::${r.key}`,{path:r.path,rootCount:i,hasWorktrees:n})}}return e},[u,x]),j=Z.useMemo(()=>{let t=_c(o),n=new Map,i=e=>(e.kind!==`pagination`&&n.set(e.id,e),e),a=x.map(a=>{let o=d[a.project.id]??!0,c=ii(),l=a.project.icon?Wt[a.project.icon]:void 0,h=a.buckets.map(o=>{let l=`${a.project.id}::${o.key}`,d=f[l]??!1,h=m.get(l)??c,g=Tc(o.sessions,u),v=Zr(o.sessions,{pinnedSessionIds:u,omitPinnedSessions:!1}).map(e=>e.session),y=t=>{let r=gc(t),a=(p[t.id]??0)>0&&!r,c={id:t.id,directory:o.path,title:t.title?.trim()||e(`mobile.sessions.untitled`),changes:An(kn(t))??void 0,activityLabel:xc(bc(t))||void 0,unread:a,pinned:u.has(t.id),archived:Sc(t),active:s===t.id},l=cc(D.current.get(t.id)??n.get(t.id),c);return i(l)},b=Er(g,h,_).map(y),x=g.length-b.length,S=r.get(_c(o.path)),C=S?.hasMore===!0,w=g.length>c&&h>c,T=[...b];w&&T.push({id:`${dc}${a.project.id}::${o.key}`,kind:`pagination`,title:e(`sessions.sidebar.group.showFewer`)}),(x>0||C)&&T.push({id:`${uc}${a.project.id}::${o.key}`,kind:`pagination`,title:e(`sessions.sidebar.group.showMore`),subtitle:S?.loadingMore?`…`:void 0});let E=_c(o.path),O=!!(a.isActive&&t&&E&&(t===E||t.startsWith(`${E}/`))),k=o.worktree==null;return{id:o.key,name:k?e(`mobile.sessions.mainWorkspace`):o.label,path:o.path,kind:k?`main`:`worktree`,active:O,expanded:k?!0:d,sessionCount:g.length,sessions:T,catalogSessions:v.map(y)}});return{id:a.project.id,name:a.project.label,path:a.project.path,icon:l,sessionCount:a.totalSessions,activityLabel:xc(a.latestActivity)||void 0,active:a.isActive,expanded:o,worktrees:h}});return D.current=n,a},[r,_,o,s,u,d,x,e,p,m,f]),M=e=>{for(let[t,n]of A)if(t.startsWith(`${e}::`))return n.hasWorktrees;return!1},N=(e,t)=>A.get(`${e}::${t}`)?.rootCount??0,P=e=>ii();return{projects:j,pinnedSessions:O,inProgressSessions:k,sessionById:S,projectMetaById:C,allSessions:y,projectHasWorktrees:M,getBucketRootCount:N,getBucketVisibleCount:(e,t)=>{let n=`${e}::${t}`;return m.get(n)??P(e)},getBucketPageSize:P,getBucketDirectory:(e,t)=>A.get(`${e}::${t}`)?.path??null,showMoreBucketSessions:(e,t)=>{let n=`${e}::${t}`,r=A.get(n),i=ii(),a=kr(),o=m.get(n)??i,s=r?.rootCount??0;if(h(e=>{let t=new Map(e),r=Math.max(i,e.get(n)??i,o);return t.set(n,r+a),t}),Math.max(i,o)+a<s)return;let c=r?.path,l=_c(c);if(!l)return;let u=Fe.getState().activePaginationByDirectory.get(l);u?.hasMore&&!u.loadingMore&&Ke(l)},resetBucketVisibleCount:(e,t)=>{let n=`${e}::${t}`;h(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t})}}}var Dc=(e,t,n)=>e?.kind===`project`&&e.project.id===t?{...e,isGitRepository:n}:e;function Oc({onOpenChat:e,onAddProject:t,onNewSession:n,onScanQr:r,onSwitchInstance:i,className:a}){let{t:o}=ee(),{git:s}=mn(),c=Ie(),l=Ec(),u=jo(e=>e.setProjectExpanded),d=jo(e=>e.setWorktreeExpanded),f=he(),p=De(),m=Re(e=>e.archiveSessions),h=Re(e=>e.updateSessionTitle),_=Re(e=>e.requestSessionSmartTitle),v=Re(e=>e.shareSession),y=Re(e=>e.unshareSession),b=Re(e=>e.openNewSessionDraft),x=We(e=>e.openDraft),S=We(e=>e.openSession),C=Ve(e=>e.projects),w=Ve(e=>e.setActiveProjectIdOnly),T=Ve(e=>e.removeProject),E=Pt(),[D,O]=Z.useState(null),[k,A]=Z.useState(!1),[j,M]=Z.useState(null),[N,P]=Z.useState(null),[F,I]=Z.useState(null),[L,R]=Z.useState(``),[z,B]=Z.useState(!1),[U,W]=Z.useState(!1),[K,te]=Z.useState(null),[q,ne]=Z.useState(null),[re,ie]=Z.useState(null),ae=D?.kind===`session`?D.session.id:``,oe=Ae(ae),se=oe?.type===`busy`||oe?.type===`retry`,J=D?.kind===`session`?vc(D.session):``,ce=!!ae&&re===ae,le=!J||ce||se,ue=V(e=>{let t=new Map;for(let e of l.allSessions){let n=gc(e);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}),Y=V(()=>{A(!1),O(null)}),de=V(t=>{if(mc(t.id)){let e=hc(t.id);if(!e)return;e.kind===`more`?l.showMoreBucketSessions(e.projectId,e.bucketKey):l.resetBucketVisibleCount(e.projectId,e.bucketKey);return}let n=l.sessionById.get(t.id),r=n&&vc(n)||null;e({sessionId:t.id,directory:r})}),fe=V(e=>{mc(e.id)||f(e.id)}),pe=V(async e=>{if(mc(e.id))return;let t=ue(e.id),{archivedIds:n,failedIds:r}=await m(t);n.length>0&&yr({sessionIds:n,message:n.length===1?o(`sessions.sidebar.session.archive.success`):o(`sessions.sidebar.bulkActions.archivedPlural`,{count:n.length}),undoLabel:o(`sessions.sidebar.undo`),settingsLabel:o(`settings.openchamber.archivedSessions.actions.view`),undoFailedMessage:n.length===1?o(`sessions.sidebar.session.archive.undoFailed`):o(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:n.length})}),r.length>0&&Ze.error(r.length===1?o(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):o(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}),me=V(()=>{if(!D||D.kind!==`session`)return;let e=D.session,t=vc(e),n=oe?.type??`idle`;!t||re===e.id||n===`busy`||n===`retry`||(ie(e.id),(async()=>{try{await E.refreshSessionTranscript(e.id,{directory:t}),Ze.success(o(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{Ze.error(o(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{ie(t=>t===e.id?null:t)}})())}),ge=V(e=>{if(mc(e.id))return;let t=l.sessionById.get(e.id);t&&(O({kind:`session`,session:t}),A(!0))}),_e=V(e=>{u(e.id,!e.expanded)}),ve=V((e,t)=>{d(`${e.id}::${t.id}`,!t.expanded)}),ye=V((e,t)=>{w(e.id),x({selectedProjectId:e.id,directoryOverride:t,preserveDirectoryOverride:!0})}),be=V(()=>{if(n){n();return}b()}),xe=V(e=>{let t=l.projectMetaById.get(e.id);t&&(O({kind:`project`,project:t,isGitRepository:!1}),A(!0),s.checkIsGitRepository(t.path).then(e=>{O(n=>Dc(n,t.id,e))}).catch(()=>{O(e=>Dc(e,t.id,!1))}))}),Se=V((e,t)=>{let n=g(t);return n?e.worktrees.find(e=>g(e.path)===n)||((Re.getState().availableWorktreesByProject.get(e.path)??[]).find(e=>g(e.path)===n)??null):null}),Ce=V((e,t)=>{let n=l.projectMetaById.get(e.id);n&&ye(n,t.path)}),we=V((e,t)=>{let n=l.projectMetaById.get(e.id);n&&(O({kind:`worktree`,project:n,worktreePath:t.path,worktreeName:t.name}),A(!0))}),Te=V((e,t)=>{let n=l.projectMetaById.get(e.id);if(!n)return;let r=Se(n,t.path);if(!r){Ze.error(o(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}ne({project:n,worktree:r})}),Ee=V(e=>{te(e),w(e),W(!0)}),Oe=V(e=>{(async()=>{let t=e.worktrees;try{t=(await Kt({id:e.id,path:e.path})).worktrees}catch(n){console.warn(`[MobileProjectsHome] Worktree refresh before session sync failed:`,n),t=Re.getState().availableWorktreesByProject.get(e.path)??e.worktrees}await $e([e.path,...t.map(e=>e.path)],l.allSessions)})()}),ke=V((e,t)=>{let n=K;if(W(!1),te(null),t?.sessionId){S({sessionId:t.sessionId,directory:e});return}x({selectedProjectId:n,directoryOverride:e,preserveDirectoryOverride:!0})}),je=V(async e=>{try{if(!(await v(e.id))?.share?.url){Ze.error(o(`sessions.sidebar.session.share.error`));return}Ze.success(o(`sessions.sidebar.session.share.successTitle`),{description:o(`sessions.sidebar.session.share.successDescription`)})}catch{Ze.error(o(`sessions.sidebar.session.share.error`))}}),Me=V(async e=>{if((await H(e)).ok){Ze.success(o(`sessions.sidebar.session.menu.copied`));return}Ze.error(o(`sessions.sidebar.session.share.copyUrlError`))}),Ne=V(async e=>{try{if(await y(e)){Ze.success(o(`sessions.sidebar.session.unshare.success`));return}Ze.error(o(`sessions.sidebar.session.unshare.error`))}catch{Ze.error(o(`sessions.sidebar.session.unshare.error`))}}),Pe=V(e=>{let t=ue(e.id);Wr({sessionIds:t,message:t.length===1?o(`sessions.sidebar.session.delete.success`):o(`sessions.sidebar.bulkActions.deletedPlural`,{count:t.length}),undoLabel:o(`sessions.sidebar.undo`),commitFailedMessage:o(`sessions.sidebar.session.delete.error`)})}),Fe=V(async()=>{if(!F)return;let e=L.trim();if(e)try{await h(F.id,e),I(null),R(``)}catch{Ze.error(o(`sessions.sidebar.session.menu.rename`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}}),Le=V(async()=>{if(!F||z)return;let e=F.id;I(null),R(``),B(!0);try{await _(e)}catch{Ze.error(o(`sessions.sidebar.session.rename.smartTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{B(!1)}}),ze=Z.useMemo(()=>D?D.kind===`session`?{kind:`session`,title:D.session.title?.trim()||o(`mobile.sessions.untitled`),pinned:p.has(D.session.id),shared:!!D.session.share?.url}:D.kind===`project`?{kind:`project`,title:D.project.label,gitRepository:D.isGitRepository}:{kind:`worktree`,title:D.worktreeName}:null,[D,p,o]),Be=Z.useMemo(()=>{if(!D)return{};if(D.kind===`session`){let e=D.session;return{onRename:()=>{R(e.title?.trim()||o(`mobile.sessions.untitled`)),I(e)},onTogglePin:()=>f(e.id),onShare:c&&!e.share?.url?()=>{je(e)}:void 0,onCopyLink:c&&e.share?.url?()=>{Me(e.share.url)}:void 0,onUnshare:c&&e.share?.url?()=>{Ne(e.id)}:void 0,onRefreshTranscript:me,onArchive:()=>{pe({id:e.id,title:e.title?.trim()||o(`mobile.sessions.untitled`)})},onDelete:()=>Pe(e)}}if(D.kind===`project`){let e=D.project;return{onNewSession:()=>ye(e,e.path),onNewWorktree:()=>Ee(e.id),onSyncSessions:()=>Oe(e),onEditProject:()=>M(e.id),onCloseProject:()=>P(e)}}let{project:e,worktreePath:t}=D;return{onNewSession:()=>ye(e,t),onDeleteWorktree:()=>{let n=Se(e,t);if(!n){Ze.error(o(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}ne({project:e,worktree:n})}}},[D,pe,Me,Pe,me,Ee,Oe,je,Ne,Se,c,ye,o,f]),He=Z.useMemo(()=>{if(!j)return null;let e=C.find(e=>e.id===j),t=l.projectMetaById.get(j);if(!e||!t)return null;let n=D?.kind===`project`&&D.project.id===j?D.isGitRepository:t.worktrees.length>0;return{id:e.id,label:e.label?.trim()||t.label,path:g(e.path)||t.path,icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:n,worktrees:t.worktrees}},[D,j,l.projectMetaById,C]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(nc,{className:a,projects:l.projects,pinnedSessions:l.pinnedSessions,inProgressSessions:l.inProgressSessions,onAddProject:t,onNewSession:be,onScanQr:r,onSwitchInstance:i,onToggleProject:_e,onOpenProjectActions:xe,onToggleWorktree:ve,onNewWorktreeSession:Ce,onOpenWorktreeActions:we,onDeleteWorktree:Te,onSelectSession:de,onPinSession:fe,onArchiveSession:e=>{pe(e)},onOpenSessionActions:ge}),(0,$.jsx)(sc,{open:k,target:ze,actions:Be,refreshTranscriptDisabled:le,refreshTranscriptSpinning:ce,onOpenChange:e=>{e?A(!0):Y()}}),(0,$.jsx)(Ct,{open:U,projectId:K,onOpenChange:e=>{W(e),e||te(null)},onWorktreeCreated:ke}),q?(0,$.jsx)(Dr,{open:!0,project:{id:q.project.id,path:q.project.path},worktree:q.worktree,onClose:()=>ne(null)}):null,(0,$.jsx)(on,{open:!!N,title:o(`sessions.sidebar.project.actions.closeProject`),onClose:()=>P(null),closeAriaLabel:o(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(G,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>P(null),children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(G,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!N)return;let e=N;P(null),T(e.id),Ze.success(o(`mobile.sessions.toast.projectRemoved`,{label:e.label}))},children:o(`mobile.sessions.confirmRemoveProject`)})]}),children:(0,$.jsx)(`p`,{className:`px-1 py-1 typography-ui-body text-foreground`,children:o(`mobile.projects.closeConfirmMessage`,{title:N?.label??``})})}),(0,$.jsx)(on,{open:!!F,title:o(`sessions.sidebar.session.menu.rename`),onClose:()=>{z||(I(null),R(``))},closeAriaLabel:o(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(G,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:z,onClick:()=>{I(null),R(``)},children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(G,{type:`button`,variant:`default`,className:`flex-1`,disabled:!L.trim()||z,onClick:()=>void Fe(),children:o(`sessions.sidebar.session.rename.save`)})]}),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-3 px-1 py-1`,onSubmit:e=>{e.preventDefault(),Fe()},children:[(0,$.jsx)(qt,{value:L,onChange:e=>R(e.target.value),autoFocus:!0,className:`h-12`,disabled:z}),(0,$.jsxs)(G,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:z,onClick:()=>void Le(),children:[z?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`ai-generate-2`,className:`size-4`}),o(`sessions.sidebar.session.rename.smartTitle`)]})]})}),(0,$.jsx)(xr,{open:j!==null,project:He,onClose:()=>M(null)})]})}function kc(e){let t=(0,Q.c)(10),{children:n,content:r,className:i,contentClassName:a,showHeader:o}=e,s=o===void 0||o,{t:c}=ee(),l;t[0]===c?l=t[1]:(l=c(`sessions.scheduledTasks.dialog.title`),t[0]=c,t[1]=l);let u;t[2]===a?u=t[3]:(u=W(`oc-mobile-scheduled-content`,a),t[2]=a,t[3]=u);let d=n??r,f;return t[4]!==i||t[5]!==s||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,$.jsx)(ur,{title:l,className:i,surface:!1,scrollsWithPage:!0,showHeader:s,surfaceClassName:u,children:d}),t[4]=i,t[5]=s,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function Ac(e){let t=(0,Q.c)(10),{className:n,contentClassName:r,instancesPage:i}=e,{t:a}=ee(),o;t[0]===a?o=t[1]:(o=a(`mobile.settings.placeholder.title`),t[0]=a,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=[...fr],t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,$.jsx)(gi,{forceMobile:!0,isWindowed:!0,hideMobileHeader:!0,flowMobile:!0,autoOpenMobilePage:!0,visiblePageSlugs:s,mobileInstancesPage:i}),t[3]=i,t[4]=c);let l;return t[5]!==n||t[6]!==r||t[7]!==o||t[8]!==c?(l=(0,$.jsx)(ur,{title:o,className:n,surface:!1,scrollsWithPage:!0,showHeader:!1,surfaceClassName:r,children:c}),t[5]=n,t[6]=r,t[7]=o,t[8]=c,t[9]=l):l=t[9],l}function jc(e){let t=(0,Q.c)(110),{onAddProject:n,onScanQr:r,onSwitchInstance:i,onEnableAssistants:a,instancesPage:o,instancesSecondaryPage:s,parentSessionTarget:c,registerSecondaryBackHandler:l,scheduledContent:u,renderChat:d,className:f}=e,p=c===void 0?null:c,{t:m}=ee(),h=We(),_=We(Yc),v=We(Jc),y=We(qc),b=We(Kc),x=We(Gc),S=We(Wc),C=We(Uc),w=We(Hc),T=We(Vc),E=We(Bc),D=We(zc),O=We(Rc),k;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(k=[],t[0]=k):k=t[0],Z.useEffect(Lc,k);let A=h.secondary?.kind===`chat`?h.secondary.btw??null:null,M=Z.useRef(null),N,P;t[1]===A?(N=t[2],P=t[3]):(N=()=>{let e=M.current;M.current=A,e&&e!==A&&ft.getState().clear({sessionId:e.sessionId,directory:e.directory}),A?dt(St):pt(St)},P=[A],t[1]=A,t[2]=N,t[3]=P),Z.useEffect(N,P);let F;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(F=[],t[4]=F):F=t[4],Z.useEffect(Fc,F);let I;t[5]===_?I=t[6]:(I=e=>{e===`settings`&&j.getState().setSettingsPage(`home`),_(e)},t[5]=_,t[6]=I);let L=V(I),R;t[7]===v?R=t[8]:(R=e=>{v(e)},t[7]=v,t[8]=R);let z=V(R),B;t[9]===C?B=t[10]:(B=()=>{C()},t[9]=C,t[10]=B);let H=V(B),U;t[11]===y?U=t[12]:(U=()=>{y()},t[11]=y,t[12]=U);let W=V(U),G;t[13]===b?G=t[14]:(G=e=>{b(e)},t[13]=b,t[14]=G);let K=V(G),te=Z.useRef(null),[q,ne]=Z.useState(!1),re;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(re=e=>{te.current=e},t[15]=re):re=t[15];let ie=V(re),ae;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(ae=e=>{ne(e)},t[16]=ae):ae=t[16];let oe=V(ae),se;t[17]!==H||t[18]!==S||t[19]!==O||t[20]!==w?(se=()=>{if(te.current?.())return!0;let e=We.getState().secondary;return e?.kind===`chat`&&e.btw?(O(),!0):e?.kind===`assistant`&&e.settingsAssistantID?(S(),!0):e?.kind===`chat`&&e.routes.length>1?(w(),!0):e?(H(),!0):!1},t[17]=H,t[18]=S,t[19]=O,t[20]=w,t[21]=se):se=t[21];let J=V(se),ce=h.secondary!==null,le;t[22]!==J||t[23]!==l?(le=()=>{if(l)return l(()=>J()),()=>l(null)},t[22]=J,t[23]=l,t[24]=le):le=t[24];let ue;t[25]!==J||t[26]!==l||t[27]!==ce?(ue=[l,ce,J],t[25]=J,t[26]=l,t[27]=ce,t[28]=ue):ue=t[28],Z.useEffect(le,ue);let Y=Re(Pc),de;t[29]===Y?de=t[30]:(de=e=>Y?e.getDirectoryForSession(Y):null,t[29]=Y,t[30]=de);let fe=Re(de),pe,me;t[31]!==fe||t[32]!==Y||t[33]!==E||t[34]!==D?(pe=()=>{let e=We.getState().secondary;if(e?.kind===`draft`&&Y){E({sessionId:Y,directory:fe});return}if(e?.kind!==`chat`||!Y||Ye({sessionId:Y,directory:fe})===`internal`)return;let t=e.routes.at(-1);(t?.sessionId!==Y||g(t.directory)!==g(fe))&&D({sessionId:Y,directory:fe})},me=[fe,Y,E,D],t[31]=fe,t[32]=Y,t[33]=E,t[34]=D,t[35]=pe,t[36]=me):(pe=t[35],me=t[36]),Z.useEffect(pe,me);let he,ge;t[37]!==Y||t[38]!==p||t[39]!==T?(he=()=>{let e=We.getState().secondary;if(e?.kind!==`chat`||!p)return;let t=e.routes.at(-1);!t||t.sessionId!==Y||T({sessionId:p.id,directory:p.directory})},ge=[Y,p,T],t[37]=Y,t[38]=p,t[39]=T,t[40]=he,t[41]=ge):(he=t[40],ge=t[41]),Z.useEffect(he,ge);let _e;t[42]!==oe||t[43]!==ie||t[44]!==u?(_e=typeof u==`function`?u(ie,oe):u,t[42]=oe,t[43]=ie,t[44]=u,t[45]=_e):_e=t[45];let ve=_e,ye;t[46]!==W||t[47]!==n||t[48]!==r||t[49]!==i||t[50]!==z?(ye=(0,$.jsx)(Oc,{onOpenChat:z,onAddProject:n,onNewSession:W,onScanQr:r,onSwitchInstance:i}),t[46]=W,t[47]=n,t[48]=r,t[49]=i,t[50]=z,t[51]=ye):ye=t[51];let be;t[52]!==a||t[53]!==K?(be=(0,$.jsx)(os,{onEnable:a,onOpenAssistant:K}),t[52]=a,t[53]=K,t[54]=be):be=t[54];let xe;t[55]===ve?xe=t[56]:(xe=(0,$.jsx)(kc,{showHeader:!1,children:ve}),t[55]=ve,t[56]=xe);let Se;t[57]===o?Se=t[58]:(Se=(0,$.jsx)(Ac,{instancesPage:o}),t[57]=o,t[58]=Se);let Ce;t[59]!==ye||t[60]!==be||t[61]!==xe||t[62]!==Se?(Ce={projects:ye,assistant:be,scheduled:xe,settings:Se},t[59]=ye,t[60]=be,t[61]=xe,t[62]=Se,t[63]=Ce):Ce=t[63];let we=Ce,Te=h.secondary?.kind??null,Ee;bb0:{if(!Te){Ee=null;break bb0}if(Te===`assistant`){let e=h.secondary?.kind===`assistant`?h.secondary.settingsAssistantID:void 0,n;t[64]===m?n=t[65]:(n=m(`assistants.title`),t[64]=m,t[65]=n);let r=!e,i;t[66]!==x||t[67]!==r?(i=(0,$.jsx)(Ti,{activeOverride:r,onMobileBack:Nc,onMobileOpenSettings:x}),t[66]=x,t[67]=r,t[68]=i):i=t[68];let a;t[69]!==J||t[70]!==n||t[71]!==i?(a={key:`assistant-secondary`,depth:1,ariaLabel:n,onBack:J,content:i},t[69]=J,t[70]=n,t[71]=i,t[72]=a):a=t[72];let o;t[73]!==J||t[74]!==e||t[75]!==m?(o=e?[{key:`assistant-settings:${e}`,depth:2,ariaLabel:m(`assistants.conversation.openSettings`),onBack:J,content:(0,$.jsx)(cs,{assistantID:e,onBack:Mc})}]:[],t[73]=J,t[74]=e,t[75]=m,t[76]=o):o=t[76];let s;t[77]!==a||t[78]!==o?(s=[a,...o],t[77]=a,t[78]=o,t[79]=s):s=t[79],Ee=s;break bb0}if(Te===`instances`){let e;t[80]===m?e=t[81]:(e=m(`mobile.settings.switchInstance`),t[80]=m,t[81]=e);let n;t[82]!==J||t[83]!==s||t[84]!==e?(n=[{key:`instances-secondary`,depth:1,ariaLabel:e,onBack:J,content:s}],t[82]=J,t[83]=s,t[84]=e,t[85]=n):n=t[85],Ee=n;break bb0}if(h.secondary?.kind===`draft`){let e;t[86]===m?e=t[87]:(e=m(`mobile.nav.secondaryPageAria`),t[86]=m,t[87]=e);let n;t[88]===d?n=t[89]:(n=d({sessionId:``,directory:null,viewKey:`chat-primary`,active:!0}),t[88]=d,t[89]=n);let r;t[90]!==J||t[91]!==e||t[92]!==n?(r=[{key:`chat-primary`,depth:1,ariaLabel:e,onBack:J,content:n}],t[90]=J,t[91]=e,t[92]=n,t[93]=r):r=t[93],Ee=r;break bb0}if(h.secondary?.kind!==`chat`){let e;t[94]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[94]=e):e=t[94],Ee=e;break bb0}let e=h.secondary.routes,n=h.secondary.btw,r;if(t[95]!==n||t[96]!==J||t[97]!==d||t[98]!==e||t[99]!==m){let i=e.slice(n?-1:-2),a=e.length-i.length+1,o=i.map((e,t)=>{let r=!n&&t===i.length-1;return{key:e.key,depth:a+t,ariaLabel:m(`mobile.nav.secondaryPageAria`),onBack:J,content:d({sessionId:e.sessionId,directory:e.directory,viewKey:e.key,active:r})}});r=n?[...o,{key:`chat-btw`,depth:e.length+1,ariaLabel:m(`chat.btw.title`),onBack:J,content:(0,$.jsx)(ls,{route:n})}]:o,t[95]=n,t[96]=J,t[97]=d,t[98]=e,t[99]=m,t[100]=r}else r=t[100];Ee=r}let De=Ee,Oe;t[101]===De?Oe=t[102]:(Oe=De??[],t[101]=De,t[102]=Oe);let ke;return t[103]!==f||t[104]!==h||t[105]!==q||t[106]!==L||t[107]!==Oe||t[108]!==we?(ke=(0,$.jsx)(Ms,{className:f,navigation:h,onTabChange:L,tabs:we,secondaryPages:Oe,tabBarCovered:q}),t[103]=f,t[104]=h,t[105]=q,t[106]=L,t[107]=Oe,t[108]=we,t[109]=ke):ke=t[109],ke}function Mc(){Un.requestAnimatedBack(`root`)}function Nc(){return Un.requestAnimatedBack(`root`)}function Pc(e){return e.currentSessionId}function Fc(){return Ic}function Ic(){return pt(St)}function Lc(){return Ne()}function Rc(e){return e.popBtw}function zc(e){return e.replaceChatSession}function Bc(e){return e.materializeDraftSession}function Vc(e){return e.reconcileChatPredecessor}function Hc(e){return e.popChatSession}function Uc(e){return e.closeSecondary}function Wc(e){return e.popAssistantSettings}function Gc(e){return e.pushAssistantSettings}function Kc(e){return e.openAssistant}function qc(e){return e.openDraft}function Jc(e){return e.openSession}function Yc(e){return e.setActiveTab}function Xc(e){let t=(0,Q.c)(19),{percentage:n}=e,r,i,a,o,s,c,l;if(t[0]!==n){a=Zt(n)??0;let e=Qt(n);i=e===`critical`?`var(--status-error)`:e===`warn`?`var(--status-warning)`:`var(--status-success)`,r=2*Math.PI*7.5,o=`0 0 18 18`,s=`size-[18px] -rotate-90`,c=`progressbar`,l=Math.round(a),t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7];let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:3}),t[8]=u):u=t[8];let d=r*(1-a/100),f;t[9]!==r||t[10]!==i||t[11]!==d?(f=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:i,strokeWidth:3,strokeLinecap:`round`,strokeDasharray:r,strokeDashoffset:d,className:`transition-[stroke-dashoffset,stroke] duration-300`}),t[9]=r,t[10]=i,t[11]=d,t[12]=f):f=t[12];let p;return t[13]!==o||t[14]!==s||t[15]!==c||t[16]!==l||t[17]!==f?(p=(0,$.jsxs)(`svg`,{viewBox:o,className:s,role:c,"aria-valuenow":l,"aria-valuemin":0,"aria-valuemax":100,children:[u,f]}),t[13]=o,t[14]=s,t[15]=c,t[16]=l,t[17]=f,t[18]=p):p=t[18],p}function Zc(e){let t=(0,Q.c)(16),{title:n,subtitle:r,onBack:i,onOpenMenu:a,menuOpen:o,elevated:s,trailing:c}=e,l=o!==void 0&&o,u=s!==void 0&&s,{t:d}=ee(),f=V(i),p=V(a),m;t[0]===d?m=t[1]:(m=d(`header.actions.backAria`),t[0]=d,t[1]=m);let h=u||l,g;t[2]===d?g=t[3]:(g=d(`mobile.menu.titleAria`),t[2]=d,t[3]=g);let _;t[4]!==p||t[5]!==l||t[6]!==g?(_=[{icon:`more-2`,ariaLabel:g,onClick:p,pressed:l}],t[4]=p,t[5]=l,t[6]=g,t[7]=_):_=t[7];let v;return t[8]!==f||t[9]!==r||t[10]!==m||t[11]!==h||t[12]!==_||t[13]!==n||t[14]!==c?(v=(0,$.jsx)(Y,{title:n,subtitle:r,backAriaLabel:m,onBack:f,overlay:!0,elevated:h,trailing:c,actions:_}),t[8]=f,t[9]=r,t[10]=m,t[11]=h,t[12]=_,t[13]=n,t[14]=c,t[15]=v):v=t[15],v}var Qc=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},$c=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),el=e=>e>=90?`text-[var(--status-error)]`:e>=75?`text-[var(--status-warning)]`:`text-[var(--status-success)]`,tl=e=>{let{totalTokens:t,contextLimit:n,isDraft:r}=e;if(r||t<=0||n<=0)return null;let i=Math.min(t/n*100,999);return{percentage:i,tokens:`${$c(t)}/${$c(n)}`,colorClass:el(i)}},nl=e=>{for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role!==`user`)continue;let r=typeof n.model?.providerID==`string`&&n.model.providerID.trim().length>0?n.model.providerID:void 0,i=typeof n.model?.modelID==`string`&&n.model.modelID.trim().length>0?n.model.modelID:void 0;if(r&&i)return{providerID:r,modelID:i}}return null},rl=(e,t)=>{let n=be(e,t??(()=>void 0));return!n||`compacted`in n?0:n.totalTokens},il=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),al=e=>{let t=e.usedPercent;return typeof t!=`number`||!Number.isFinite(t)?`text-foreground`:t>=80?`text-[var(--status-error)]`:t>=50?`text-[var(--status-warning)]`:`text-foreground`},ol=e=>{let t=(0,Q.c)(13),{iconNode:n,iconName:r,label:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o=n??(r?(0,$.jsx)(X,{name:r,className:`size-[18px]`}):null),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s;t[3]===o?s=t[4]:(s=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:o}),t[3]=o,t[4]=s);let c;t[5]===i?c=t[6]:(c=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:i}),t[5]=i,t[6]=c);let l;t[7]===a?l=t[8]:(l=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground`,children:a}),t[7]=a,t[8]=l);let u;return t[9]!==s||t[10]!==c||t[11]!==l?(u=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5`,children:[s,c,l]}),t[9]=s,t[10]=c,t[11]=l,t[12]=u):u=t[12],u},sl=e=>{let t=(0,Q.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=ee(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(X,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,$.jsx)(X,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,$.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(Vt,{providerId:e.providerId,className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground`,children:e.providerName}),e.status&&e.rows.length===0?(0,$.jsx)(`span`,{className:`shrink-0 truncate typography-micro text-muted-foreground`,children:e.status}):null]}),e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:e.rows.map(e=>{let t=r===`remaining`?e.window.remainingPercent:e.window.usedPercent,n=an(e.window.valueLabel,t),i=$t(e.window.resetAt,e.window.resetAfterFormatted??e.window.resetAtFormatted,a);return(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-3`,children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-muted-foreground`,children:e.subtitle?`${e.subtitle} · ${e.label}`:e.label}),i?(0,$.jsx)(`span`,{className:`shrink-0 truncate typography-micro text-muted-foreground/70`,children:i}):null]}),(0,$.jsx)(`span`,{className:W(`shrink-0 typography-ui-label font-semibold tabular-nums`,al(e.window)),children:n===`-`?``:n})]},e.key)})}):null,e.status&&e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 typography-micro text-muted-foreground`,children:e.status}):null]},e.providerId),t[22]=r,t[23]=a,t[24]=e):e=t[24],g=n.map(e),t[18]=r,t[19]=n,t[20]=a,t[21]=g}else g=t[21];let _;t[25]===g?_=t[26]:(_=(0,$.jsx)(`div`,{className:`space-y-1.5`,children:g}),t[25]=g,t[26]=_);let v;return t[27]!==_||t[28]!==h?(v=(0,$.jsxs)(`div`,{className:`pt-2.5`,children:[h,_]}),t[27]=_,t[28]=h,t[29]=v):v=t[29],v},cl=e=>{let t=(0,Q.c)(47),{open:n,onClose:r,contextDisplay:i,branchLabel:a,usageGroups:o,usageDisplayMode:s,isUsageLoading:c,timeFormatPreference:l}=e,{t:u}=ee(),d=Z.useRef(null),[f,p]=Z.useState(n),[m,h]=Z.useState(!1),g,_;t[0]!==n||t[1]!==f?(g=()=>{if(n){p(!0),h(!1);return}if(!f)return;h(!0);let e=window.setTimeout(()=>{p(!1),h(!1)},140);return()=>window.clearTimeout(e)},_=[n,f],t[0]=n,t[1]=f,t[2]=g,t[3]=_):(g=t[2],_=t[3]),Z.useEffect(g,_);let v,y;if(t[4]!==r||t[5]!==n?(v=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},y=[r,n],t[4]=r,t[5]=n,t[6]=v,t[7]=y):(v=t[6],y=t[7]),Z.useEffect(v,y),!f)return null;let b;t[8]===u?b=t[9]:(b=u(`mobile.surface.closeAria`),t[8]=u,t[9]=b);let x;t[10]===r?x=t[11]:(x=e=>{e.preventDefault(),r()},t[10]=r,t[11]=x);let S;t[12]!==b||t[13]!==x?(S=(0,$.jsx)(`button`,{type:`button`,className:`pointer-events-auto absolute inset-x-0 bottom-0 cursor-default top-[calc(var(--oc-safe-area-top,0px)+var(--oc-mobile-detail-navigation-height,3.5rem)+0.25rem)]`,"aria-label":b,onPointerDown:x}),t[12]=b,t[13]=x,t[14]=S):S=t[14];let C;t[15]===u?C=t[16]:(C=u(`mobile.header.openMetadataAria`),t[15]=u,t[16]=C);let w=m&&`pointer-events-none`,T;t[17]===w?T=t[18]:(T=W(`pointer-events-auto absolute inset-x-3 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-mobile-detail-navigation-height,3.5rem)+0.5rem)] overflow-y-auto overscroll-contain rounded-[20px] oc-mobile-overlay-surface oc-mobile-overlay-surface--translucent p-2 will-change-transform`,w),t[17]=w,t[18]=T);let E=`${m?`session-metadata-out`:`session-metadata-in`} ${m?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,D;t[19]===E?D=t[20]:(D={animation:E,maxHeight:`min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-mobile-detail-navigation-height, 3.5rem) - 1rem))`},t[19]=E,t[20]=D);let O;t[21]===u?O=t[22]:(O=u(`mobile.header.metadata.branch`),t[21]=u,t[22]=O);let k;t[23]!==a||t[24]!==O?(k=(0,$.jsx)(ol,{iconName:`git-branch`,label:O,children:a}),t[23]=a,t[24]=O,t[25]=k):k=t[25];let A;t[26]!==i||t[27]!==u?(A=i?(0,$.jsx)(ol,{iconNode:(0,$.jsx)(Xc,{percentage:i.percentage}),label:u(`mobile.header.metadata.context`),children:(0,$.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5 tabular-nums`,children:[(0,$.jsxs)(`span`,{className:W(`font-semibold`,i.colorClass),children:[i.percentage.toFixed(1),`%`]}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:i.tokens})]})}):null,t[26]=i,t[27]=u,t[28]=A):A=t[28];let j;t[29]!==c||t[30]!==l||t[31]!==s||t[32]!==o?(j=(0,$.jsx)(sl,{groups:o,displayMode:s,isLoading:c,timeFormatPreference:l}),t[29]=c,t[30]=l,t[31]=s,t[32]=o,t[33]=j):j=t[33];let M;t[34]!==k||t[35]!==A||t[36]!==j?(M=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[k,A,j]}),t[34]=k,t[35]=A,t[36]=j,t[37]=M):M=t[37];let N;t[38]!==T||t[39]!==D||t[40]!==M||t[41]!==C?(N=(0,$.jsx)(`div`,{ref:d,role:`dialog`,"aria-label":C,className:T,style:D,onPointerDown:Ol,children:M}),t[38]=T,t[39]=D,t[40]=M,t[41]=C,t[42]=N):N=t[42];let P;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(`style`,{children:`
|
|
6
6
|
@keyframes session-metadata-in {
|
|
7
7
|
from { opacity: 0; transform: translateY(-8px) scale(0.985); }
|
|
8
8
|
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
@@ -11,12 +11,12 @@ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{p as t,t as n,v as r,w
|
|
|
11
11
|
from { opacity: 1; transform: translateY(0) scale(1); }
|
|
12
12
|
to { opacity: 0; transform: translateY(-6px) scale(0.985); }
|
|
13
13
|
}
|
|
14
|
-
`}),t[43]=P):P=t[43];let F;return t[44]!==N||t[45]!==S?(F=(0,$.jsxs)(`div`,{className:`fixed inset-0 z-40 pointer-events-none`,children:[S,N,P]}),t[44]=N,t[45]=S,t[46]=F):F=t[46],F};function sl(e){let t=(0,Q.c)(95),{sessionId:n,open:r,onOpenChange:i}=e,{t:a}=ee(),{git:o}=pn(),[s,c]=Z.useState(!1),l=r!==void 0,u=l?r:s,d=n.length===0,f;t[0]!==l||t[1]!==i||t[2]!==u?(f=e=>{let t=typeof e==`function`?e(u):e;l||c(t),i?.(t)},t[0]=l,t[1]=i,t[2]=u,t[3]=f):f=t[3];let p=V(f),m=T(Tl),h;t[4]===n?h=t[5]:(h=e=>n?e.getDirectoryForSession(n):null,t[4]=n,t[5]=h);let g=Re(h)||m,_;t[6]===g?_=t[7]:(_=nl(g)||null,t[6]=g,t[7]=_);let v=_,y=Je(n,g||void 0),b=Nn(v),x=Pn(v),S=An(wl),C=An(Cl),E=Ge(Sl),D=Ge(xl),O=Ge(bl),k=Ge(yl),A;t[8]===n?A=t[9]:(A=e=>n?e.sessionModelSelections.get(n)??null:null,t[8]=n,t[9]=A);let j=pe(A),N=hr(vl),P=hr(_l),F=hr(gl),I=hr(hl),L=hr(ml),R=hr(pl),z=hr(fl),B=M(dl);sr();let H;t[10]===p?H=t[11]:(H=()=>{p(!1)},t[10]=p,t[11]=H);let U;t[12]!==g||t[13]!==n?(U=[n,g],t[12]=g,t[13]=n,t[14]=U):U=t[14],Z.useEffect(H,U);let W,K;t[15]!==S||t[16]!==o||t[17]!==v?(W=()=>{v&&S(v,o)},K=[S,o,v],t[15]=S,t[16]=o,t[17]=v,t[18]=W,t[19]=K):(W=t[18],K=t[19]),Z.useEffect(W,K);let te,q;t[20]!==C||t[21]!==o||t[22]!==v?(q=()=>{if(v)return qe.onGitRefreshHint(e=>{nl(e.directory)===v&&C(v,o)})},te=[C,o,v],t[20]=C,t[21]=o,t[22]=v,t[23]=te,t[24]=q):(te=t[23],q=t[24]),Z.useEffect(q,te);let ne,re;t[25]===P?(ne=t[26],re=t[27]):(ne=()=>{P()},re=[P],t[25]=P,t[26]=ne,t[27]=re),Z.useEffect(ne,re);let ie,ae;t[28]===R?(ie=t[29],ae=t[30]):(ie=()=>{Ut(R)},ae=[R],t[28]=R,t[29]=ie,t[30]=ae),Z.useEffect(ie,ae);let oe,se;t[31]!==R||t[32]!==F||t[33]!==I||t[34]!==u||t[35]!==N?(oe=()=>{!u||I||R.some(e=>!N.some(t=>t.providerId===e))&&F()},se=[R,F,I,u,N],t[31]=R,t[32]=F,t[33]=I,t[34]=u,t[35]=N,t[36]=oe,t[37]=se):(oe=t[36],se=t[37]),Z.useEffect(oe,se);let J;t[38]===y?J=t[39]:(J=el(y),t[38]=y,t[39]=J);let ce=J,le;if(t[40]!==y||t[41]!==O||t[42]!==D||t[43]!==g||t[44]!==k||t[45]!==d||t[46]!==ce||t[47]!==E||t[48]!==j){let e=ce??(j?{providerID:j.providerId,modelID:j.modelId}:null)??(D&&O?{providerID:D,modelID:O}:null),n=(e?E.find(t=>t.id===e.providerID):void 0)?.models.find(t=>t.id===e?.modelID),r=e?k(e.providerID,e.modelID):void 0,i=Xc(n?.limit,`context`)??r?.limit?.context??0,a;t[50]===g?a=t[51]:(a=e=>w(e,g||void 0),t[50]=g,t[51]=a);let o;t[52]!==y||t[53]!==a?(o=tl(y,a),t[52]=y,t[53]=a,t[54]=o):o=t[54],le=$c({totalTokens:o,contextLimit:i,isDraft:d}),t[40]=y,t[41]=O,t[42]=D,t[43]=g,t[44]=k,t[45]=d,t[46]=ce,t[47]=E,t[48]=j,t[49]=le}else le=t[49];let ue=le,Y;t[55]!==x?.current||t[56]!==b||t[57]!==a?(Y=b===!0?x?.current?.trim()||a(`gitView.branch.detachedHead`):a(`common.unavailable`),t[55]=x?.current,t[56]=b,t[57]=a,t[58]=Y):Y=t[58];let de=Y,fe;if(t[59]!==R||t[60]!==N||t[61]!==z||t[62]!==a){let e=new Map(N.map(ul)),n;t[64]===R?n=t[65]:(n=e=>R.includes(e.id),t[64]=R,t[65]=n),fe=ar.filter(n).filter(t=>e.get(t.id)?.configured===!0).map(t=>{let n=e.get(t.id),r=[];for(let[e,t]of Object.entries(n?.usage?.windows??{}))r.push({key:`window-${e}`,label:on(e),window:t});let i=Object.entries(n?.usage?.models??{}),o=z[t.id]??[],s=o.length>0?i.filter(e=>{let[t]=e;return o.includes(t)}):i;for(let[e,t]of s){let n=Object.entries(t.windows??{});if(n.length===0)continue;let[i,a]=n[0];r.push({key:`model-${e}-${i}`,label:on(i),subtitle:tr(e),window:a})}let c=!n.ok&&n.error?n.error:r.length===0?a(`header.services.noRateLimitsReported`):null;return{providerId:t.id,providerName:t.name,rows:r,status:c}}),t[59]=R,t[60]=N,t[61]=z,t[62]=a,t[63]=fe}else fe=t[63];let me=fe,he,ge;t[66]!==u||t[67]!==me?(he=()=>{!u||me.length===0||Ut(me.map(ll))},ge=[u,me],t[66]=u,t[67]=me,t[68]=he,t[69]=ge):(he=t[68],ge=t[69]),Z.useEffect(he,ge);let _e;t[70]===p?_e=t[71]:(_e=()=>{p(cl)},t[70]=p,t[71]=_e);let ve=V(_e),ye;t[72]===p?ye=t[73]:(ye=()=>{p(!1)},t[72]=p,t[73]=ye);let be=V(ye),xe;t[74]===a?xe=t[75]:(xe=a(`mobile.header.openMetadataAria`),t[74]=a,t[75]=xe);let Se=ue?.percentage??0,Ce;t[76]===Se?Ce=t[77]:(Ce=(0,$.jsx)(Jc,{percentage:Se}),t[76]=Se,t[77]=Ce);let we;t[78]!==ve||t[79]!==u||t[80]!==xe||t[81]!==Ce?(we=(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsx)(G,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":xe,"aria-expanded":u,onClick:ve,children:Ce})}),t[78]=ve,t[79]=u,t[80]=xe,t[81]=Ce,t[82]=we):we=t[82];let Te;t[83]!==de||t[84]!==ue||t[85]!==be||t[86]!==I||t[87]!==u||t[88]!==L||t[89]!==B||t[90]!==me?(Te=(0,$.jsx)(ol,{open:u,onClose:be,contextDisplay:ue,branchLabel:de,usageGroups:me,usageDisplayMode:L,isUsageLoading:I,timeFormatPreference:B}),t[83]=de,t[84]=ue,t[85]=be,t[86]=I,t[87]=u,t[88]=L,t[89]=B,t[90]=me,t[91]=Te):Te=t[91];let Ee;return t[92]!==we||t[93]!==Te?(Ee=(0,$.jsxs)($.Fragment,{children:[we,Te]}),t[92]=we,t[93]=Te,t[94]=Ee):Ee=t[94],Ee}function cl(e){return!e}function ll(e){return e.providerId}function ul(e){return[e.providerId,e]}function dl(e){return e.timeFormatPreference}function fl(e){return e.selectedModels}function pl(e){return e.dropdownProviderIds}function ml(e){return e.displayMode}function hl(e){return e.isLoading}function gl(e){return e.fetchAllQuotas}function _l(e){return e.loadSettings}function vl(e){return e.results}function yl(e){return e.getModelMetadata}function bl(e){return e.currentModelId}function xl(e){return e.currentProviderId}function Sl(e){return e.providers}function Cl(e){return e.fetchStatus}function wl(e){return e.ensureStatus}function Tl(e){return e.currentDirectory}function El(e){e.stopPropagation()}function Dl(e){return e.sessionId?e.userRefreshInFlight||e.backgroundResyncInFlight?`syncing`:e.hasTranscript?null:!e.isConnected&&e.connectionPhase===`reconnecting`||e.loadStatus===`loading`?`syncing`:null:null}function Ol(e,t){let n=t?.showDelayMs??250,r=t?.hideGraceMs??1e3,i=!1,a=!1,o=null,s=()=>{o=null,a!==i&&(a=i,e(a))};return{setRaw(e){i=e,o&&clearTimeout(o),o=setTimeout(s,i?n:r)},cancel(){i=!1,o&&=(clearTimeout(o),null)}}}function kl(e){let[t,n]=(0,Z.useState)(!1),r=(0,Z.useRef)(null);r.current||=Ol(n);let i=r.current;return(0,Z.useEffect)(()=>(i.setRaw(e),()=>i.cancel()),[e,i]),t}function Al(e,t){let n=(0,Q.c)(17),{t:r}=ee(),i=Pe(e,t),a=Le(e,t),o=Ge(Pl),s=Ge(Nl),c;n[0]!==t||n[1]!==e?(c=()=>C(e,t),n[0]=t,n[1]=e,n[2]=c):c=n[2];let l=(0,Z.useSyncExternalStore)(D,c,Ml),u;n[3]!==t||n[4]!==e?(u=()=>Ce(e,t),n[3]=t,n[4]=e,n[5]=u):u=n[5];let d=(0,Z.useSyncExternalStore)(we,u,jl),f=i?.status,p;n[6]!==d||n[7]!==s||n[8]!==a||n[9]!==o||n[10]!==e||n[11]!==f||n[12]!==l?(p=Dl({sessionId:e,hasTranscript:a,loadStatus:f,userRefreshInFlight:l,backgroundResyncInFlight:d,isConnected:o,connectionPhase:s}),n[6]=d,n[7]=s,n[8]=a,n[9]=o,n[10]=e,n[11]=f,n[12]=l,n[13]=p):p=n[13];let m=kl(p===`syncing`),h;return n[14]!==r||n[15]!==m?(h=m?r(`mobile.chat.syncingMessages`):null,n[14]=r,n[15]=m,n[16]=h):h=n[16],h}function jl(){return!1}function Ml(){return!1}function Nl(e){return e.connectionPhase}function Pl(e){return e.isConnected}function Fl(e){let t=(0,Q.c)(32),{sessionId:n,directory:r,title:i,onBack:a,onOpenMenu:o,onCloseMenu:s,menuOpen:c,children:l,className:u}=e,d=c!==void 0&&c,{t:f}=ee(),p=n.length===0,m=ye(p?null:n),h;t[0]!==p||t[1]!==m?.title||t[2]!==f||t[3]!==i?(h=p?i?.trim()||f(`mobile.menu.newSession`):i?.trim()||m?.title?.trim()||f(`mobile.sessions.untitled`),t[0]=p,t[1]=m?.title,t[2]=f,t[3]=i,t[4]=h):h=t[4];let g=h,_=Al(p?``:n,r||void 0),[v,y]=Z.useState(!1),b;t[5]!==d||t[6]!==s?(b=e=>{e&&d&&s?.(),y(e)},t[5]=d,t[6]=s,t[7]=b):b=t[7];let x=V(b),S;t[8]!==v||t[9]!==o?(S=()=>{v&&y(!1),o()},t[8]=v,t[9]=o,t[10]=S):S=t[10];let C=V(S),w=d||v,T;t[11]===u?T=t[12]:(T=W(`relative isolate flex h-full min-h-0 w-full flex-col overflow-hidden bg-background text-foreground`,u),t[11]=u,t[12]=T);let E;t[13]!==v||t[14]!==x||t[15]!==n?(E=(0,$.jsx)(sl,{sessionId:n,open:v,onOpenChange:x}),t[13]=v,t[14]=x,t[15]=n,t[16]=E):E=t[16];let D;t[17]!==C||t[18]!==w||t[19]!==d||t[20]!==a||t[21]!==g||t[22]!==_||t[23]!==E?(D=(0,$.jsx)(Yc,{title:g,subtitle:_,onBack:a,onOpenMenu:C,menuOpen:d,elevated:w,trailing:E}),t[17]=C,t[18]=w,t[19]=d,t[20]=a,t[21]=g,t[22]=_,t[23]=E,t[24]=D):D=t[24];let O;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(O=W(`mobile-chat-screen__content relative h-full min-h-0 flex-1`,`[&_[data-scrollbar=chat]>.oc-chat-scroll-content]:pt-[calc(max(0.625rem,var(--oc-safe-area-top,0px))+var(--oc-mobile-detail-navigation-height)+1.25rem)]`),t[25]=O):O=t[25];let k;t[26]===l?k=t[27]:(k=(0,$.jsx)(`div`,{className:O,children:l}),t[26]=l,t[27]=k);let A;return t[28]!==T||t[29]!==D||t[30]!==k?(A=(0,$.jsxs)(`main`,{className:T,children:[D,k]}),t[28]=T,t[29]=D,t[30]=k,t[31]=A):A=t[31],A}var Il=F(`BarcodeScanner`),Ll=`oc-barcode-scanner-active`,Rl=()=>$l()?Il:null,zl=()=>window.Capacitor?.getPlatform?.()===`android`,Bl=e=>typeof e==`object`&&e&&`message`in e?String(e.message??``):String(e??``),Vl=e=>/^\s*scan canceled\.?\s*$/i.test(Bl(e)),Hl=e=>/denied access to camera/i.test(Bl(e)),Ul=e=>!Vl(e)&&!Hl(e),Wl=e=>{let t=Bl(e);return/module/i.test(t)&&/not\s*available|unavailable/i.test(t)},Gl=e=>{e.installGoogleBarcodeScannerModule?.().catch(()=>void 0)},Kl=e=>{let t=e.trim();if(!t)return null;if(/^openchamber:\/\//i.test(t)){let e=fi(t);return e?{pairing:e}:null}return/^https?:\/\//i.test(t)?{url:t}:null},ql=e=>{let t=Kl(e);return t?`pairing`in t?{status:`pairing`,...t}:{status:`ok`,...t}:{status:`invalid`}},Jl=e=>{typeof document>`u`||document.documentElement.classList.toggle(Ll,e)},Yl=e=>{try{e()}catch{}},Xl=e=>{if(typeof document>`u`)return()=>void 0;let t=document.body,n=document.createElement(`button`);n.type=`button`,n.className=`oc-barcode-scanner-chrome`,n.setAttribute(`aria-label`,`Cancel`),n.textContent=`×`,n.addEventListener(`click`,e),t.appendChild(n);let r=!1;return()=>{r||(r=!0,n.removeEventListener(`click`,e),n.parentNode===t&&t.removeChild(n))}},Zl=async e=>{if(!e.startScan||!e.stopScan||!e.addListener)return{status:`unsupported`};let t,n,r,i=!1,a=()=>void 0,o=new Promise(e=>{a=e}),s=e=>{i||(i=!0,a(e))};Jl(!0);let c=Xl(()=>s({status:`cancelled`}));try{let{App:e}=await L(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([53,1,10])),t=await e.addListener(`backButton`,()=>s({status:`cancelled`}));r=()=>void t.remove()}catch{r=void 0}try{return(await Promise.allSettled([Promise.resolve(e.addListener(`barcodesScanned`,({barcodes:e})=>{let t=e?.[0],n=(t?.rawValue??t?.displayValue??``).trim();n&&s(ql(n))})).then(e=>{t=e}),Promise.resolve(e.addListener(`scanError`,()=>s({status:`failed`}))).then(e=>{n=e})])).some(({status:e})=>e===`rejected`)?s({status:`failed`}):i||e.startScan({formats:[`QR_CODE`]}).catch(e=>{Hl(e)?s({status:`permission-denied`}):s({status:`failed`})}),await o}finally{Jl(!1),Yl(c),Yl(()=>r?.()),await Promise.allSettled([Promise.resolve(t?.remove()),Promise.resolve(n?.remove()),e.stopScan()])}},Ql=e=>e.isNativePlatform&&e.isPluginAvailable,$l=()=>Ql({isNativePlatform:I.isNativePlatform(),isPluginAvailable:I.isPluginAvailable(`BarcodeScanner`)}),eu=async()=>{let e=Rl();if(!e)return{status:`unsupported`};try{if(e.requestPermissions){let t=(await e.requestPermissions())?.camera;if(t&&t!==`granted`&&t!==`limited`)return{status:`permission-denied`}}if(e.scan)try{let t=(await e.scan({formats:[`QR_CODE`]}))?.barcodes?.[0],n=(t?.rawValue??t?.displayValue??``).trim();return n?ql(n):{status:`cancelled`}}catch(t){return Vl(t)?{status:`cancelled`}:Hl(t)?{status:`permission-denied`}:zl()&&Ul(t)&&e.startScan?(Wl(t)&&Gl(e),Zl(e)):{status:`failed`}}return zl()&&e.startScan?Zl(e):{status:`unsupported`}}catch{return{status:`failed`}}},tu={autoComplete:`off`,autoCorrect:`off`,spellCheck:!1},nu=e=>{let t=(0,Q.c)(32),{disabled:n,isBusy:r,tabIndex:i,inputClassName:a,buttonVariant:o,buttonClassName:s,onRedeem:c,onInvalid:l}=e,u=n!==void 0&&n,d=r!==void 0&&r,f=o===void 0?`outline`:o,p=s===void 0?`h-12 w-full`:s,{t:m}=ee(),[h,g]=Z.useState(``),_;t[0]!==l||t[1]!==c||t[2]!==h?(_=e=>{e.preventDefault();let t=Kl(h);if(!t||!(`pairing`in t)){l();return}c(t.pairing)},t[0]=l,t[1]=c,t[2]=h,t[3]=_):_=t[3];let v=V(_),y;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>g(e.target.value),t[4]=y):y=t[4];let b;t[5]===m?b=t[6]:(b=m(`mobile.connect.link.placeholder`),t[5]=m,t[6]=b);let x;t[7]===m?x=t[8]:(x=m(`mobile.connect.link.label`),t[7]=m,t[8]=x);let S;t[9]!==u||t[10]!==a||t[11]!==h||t[12]!==b||t[13]!==x||t[14]!==i?(S=(0,$.jsx)(`input`,{...tu,value:h,onChange:y,placeholder:b,"aria-label":x,inputMode:`url`,autoCapitalize:`none`,tabIndex:i,disabled:u,className:a}),t[9]=u,t[10]=a,t[11]=h,t[12]=b,t[13]=x,t[14]=i,t[15]=S):S=t[15];let C;t[16]!==u||t[17]!==d||t[18]!==h?(C=u||d||!h.trim(),t[16]=u,t[17]=d,t[18]=h,t[19]=C):C=t[19];let w;t[20]!==d||t[21]!==m?(w=m(d?`mobile.connect.connecting`:`mobile.connect.connectButton`),t[20]=d,t[21]=m,t[22]=w):w=t[22];let T;t[23]!==p||t[24]!==f||t[25]!==C||t[26]!==w?(T=(0,$.jsx)(G,{type:`submit`,variant:f,size:`lg`,className:p,disabled:C,children:w}),t[23]=p,t[24]=f,t[25]=C,t[26]=w,t[27]=T):T=t[27];let E;return t[28]!==v||t[29]!==T||t[30]!==S?(E=(0,$.jsxs)(`form`,{className:`flex w-full flex-col gap-3`,onSubmit:v,children:[S,T]}),t[28]=v,t[29]=T,t[30]=S,t[31]=E):E=t[31],E},ru=e=>{let t=(0,Q.c)(6),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`span`,{className:`h-px flex-1 bg-border/70`}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:n}),t[1]=n,t[2]=i);let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(`span`,{className:`h-px flex-1 bg-border/70`}),t[3]=a):a=t[3];let o;return t[4]===i?o=t[5]:(o=(0,$.jsxs)(`div`,{className:`flex items-center gap-3 py-3`,"aria-hidden":`true`,children:[r,i,a]}),t[4]=i,t[5]=o),o};function iu(e){let t=(0,Q.c)(4),n=e===void 0?2500:e,{uiFont:r}=_r(),[i,a]=Z.useState(!1),o,s;return t[0]!==n||t[1]!==r?(o=()=>{let e=!1,t=()=>{e||a(!0)},i=()=>{requestAnimationFrame(()=>requestAnimationFrame(t))},o=Promise.all([At(r).catch(lu),document.fonts?.ready?.then(cu).catch(su)??Promise.resolve(),Ri.catch(ou)]).then(au),s=new Promise(e=>{window.setTimeout(e,n)});return Promise.race([o,s]).then(i),()=>{e=!0}},s=[r,n],t[0]=n,t[1]=r,t[2]=o,t[3]=s):(o=t[2],s=t[3]),Z.useEffect(o,s),i}function au(){}function ou(){}function su(){}function cu(){}function lu(){}var uu=e=>e.replace(/^\/+|\/+$/g,``),du=e=>{let t=e.get(`directory`)||e.get(`dir`)||e.get(`path`);if(typeof t!=`string`)return;let n=t.trim();return n.length>0?n:void 0},fu=e=>{let t=uu(e.pathname).split(`/`).filter(Boolean);return e.host?[e.host,...t]:t};function pu(e){if(typeof e!=`string`||e.length===0)return null;let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`openchamber:`)return null;let n=fu(t),r=(n[0]??``).toLowerCase(),i=n.slice(1),a=t.searchParams;switch(r){case`connect`:{let t=fi(e);return t?{type:`connect`,pairing:t}:null}case`session`:{let e=i[0]||a.get(`id`)||``;return e?{type:`session`,sessionId:e,directory:du(a)}:null}case`assistant`:{let e=i[0]||a.get(`id`)||``;return e?{type:`assistant`,assistantId:e}:null}case`new`:case`new-session`:{let e=a.get(`prompt`)?.trim();return{type:`new-session`,directory:du(a),projectId:a.get(`project`)??void 0,agent:a.get(`agent`)??void 0,model:a.get(`model`)??void 0,prompt:e||void 0}}case`project`:case`open-project`:{let e;if(i.length>0)try{e=decodeURIComponent(i.join(`/`))}catch{e=i.join(`/`)}let t=du(a)||e;return t?{type:`open-project`,directory:t}:null}case`sessions`:{let e=a.get(`filter`);return{type:`sessions`,filter:e===`attention`||e===`recent`||e===`all`?e:void 0}}case`status`:return{type:`status`};case`settings`:return{type:`settings`,section:i[0]||a.get(`section`)||void 0};case`changes`:return{type:`changes`,path:i.join(`/`)||a.get(`path`)||void 0,staged:a.get(`staged`)===`true`};case`view`:{let e=(i[0]||``).toLowerCase();return e===`changes`?{type:`changes`}:e===`files`||e===`mcp`||e===`instances`||e===`update`?{type:`view`,target:e}:null}default:return null}}var mu={},hu=null,gu=!1,_u=null,vu=e=>{switch(e.type){case`connect`:return hu?(hu(e.pairing),!0):!1;case`session`:return k()?(Re.getState().setCurrentSession(e.sessionId,e.directory??null),!0):(We.getState().openSession({sessionId:e.sessionId,directory:e.directory??null}),!0);case`assistant`:if(!k()){let t=We.getState();return t.setActiveTab(`assistant`),t.openAssistant(e.assistantId),!0}return nt(e.assistantId),!0;case`new-session`:return k()?(Re.getState().openNewSessionDraft({directoryOverride:e.directory??null,selectedProjectId:e.projectId??null,preserveDirectoryOverride:!!e.directory,ensureProjectForDirectory:!!e.directory,initialPrompt:e.prompt}),!0):(We.getState().openDraft({directoryOverride:e.directory??null,selectedProjectId:e.projectId??null,preserveDirectoryOverride:!!e.directory,ensureProjectForDirectory:!!e.directory,initialPrompt:e.prompt}),!0);case`open-project`:return k()?(Re.getState().openNewSessionDraft({directoryOverride:e.directory,preserveDirectoryOverride:!0}),!0):(We.getState().openDraft({directoryOverride:e.directory,preserveDirectoryOverride:!0}),!0);case`sessions`:return mu.openSessions?(mu.openSessions(e.filter),!0):!1;case`status`:return mu.openSessions?(mu.openSessions(),!0):(M.getState().setMobileSessionPanelOpen(!0),!0);case`view`:return mu.openView?(mu.openView(e.target),!0):!1;case`changes`:return mu.openChanges?(mu.openChanges({path:e.path,staged:e.staged}),!0):!1;case`settings`:return mu.openSettings?(mu.openSettings(e.section),!0):!1}return!1},yu=()=>{if(!_u||!gu&&_u.type!==`connect`)return;let e=_u;_u=null,vu(e)||(_u=e)},bu=e=>{_u=e,yu()},xu=e=>{let t=pu(e);t&&bu(t)},Su=e=>{gu=e,yu()},Cu=e=>{let t=(0,Q.c)(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>(mu=e,yu(),()=>{mu===e&&(mu={})}),r=[e],t[0]=e,t[1]=n,t[2]=r),Z.useEffect(n,r)},wu=e=>{let t=(0,Q.c)(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>(hu=e,yu(),()=>{hu===e&&(hu=null)}),r=[e],t[0]=e,t[1]=n,t[2]=r),Z.useEffect(n,r)},Tu=e=>{let{ready:t}=e,[n,r]=Z.useState(()=>O()?`pending`:`none`);return Z.useEffect(()=>{Su(t)},[t]),Z.useEffect(()=>{if(!O())return;let e=!1,t=[];return L(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([53,1,10])).then(async({App:n})=>{if(e)return;let i=await n.addListener(`appUrlOpen`,e=>{xu(e?.url)});if(e){i.remove();return}t.push(()=>void i.remove());let a=await n.getLaunchUrl().catch(()=>void 0);if(e)return;let o=pu(a?.url);r(o?.type===`connect`?`connect`:o?`other`:`none`),o&&bu(o)}).catch(()=>{e||r(`none`)}),L(async()=>{let{PushNotifications:e}=await import(`./vendor-capacitor-push-notifications-DB3-G2vL.js`).then(e=>e.t);return{PushNotifications:e}},__vite__mapDeps([54,1,10])).then(async({PushNotifications:n})=>{if(e)return;let r=await n.addListener(`pushNotificationActionPerformed`,e=>{let t=e?.notification?.data,n=typeof t?.url==`string`?t.url:typeof t?.deeplink==`string`?t.deeplink:void 0;if(n){xu(n);return}let r=typeof t?.assistantID==`string`?t.assistantID.trim():``;if(r){bu({type:`assistant`,assistantId:r});return}let i=typeof t?.sessionId==`string`?t.sessionId:void 0;i&&bu({type:`session`,sessionId:i})});if(e){r.remove();return}t.push(()=>void r.remove())}).catch(()=>void 0),()=>{e=!0,t.forEach(e=>e())}},[]),n},Eu=64,Du=.6,Ou=28,ku=`[class*="code-block"], [class*="codeBlock"], pre, .cm-editor`,Au=`[data-session-swipe-surface="true"]`,ju=e=>e?e.matches(ku)||e.closest(ku)!==null:!1,Mu=(e,t)=>{let n=e;for(;n&&n!==document.body&&n!==document.documentElement;){let e=window.getComputedStyle(n);if(t){let t=e.overflowX;if((t===`auto`||t===`scroll`)&&n.scrollWidth>n.clientWidth)return!0}else{let t=e.overflowY;if((t===`auto`||t===`scroll`)&&n.scrollHeight>n.clientHeight)return!0}n=n.parentElement}return!1},Nu=e=>e.composerActive||e.onCodeBlock||e.withinHorizontalScroller||e.withinNativeBackEdge?!1:e.onExplicitSurface,Pu=e=>O()&&A()===`ios`&&e<=Ou,Fu=e=>{let t=e.endX-e.startX,n=e.endY-e.startY,r=Math.abs(t);return r<Eu||Math.abs(n)>r*Du?null:t<0?`next`:`prev`},Iu=(e,t)=>{let n=e.endX-e.startX,r=e.endY-e.startY,i=Math.abs(n);if(i<8||Math.abs(r)>i*Du)return null;let a=n<0?`next`:`prev`;return{direction:a,progress:Math.min(i/Eu,1),offsetX:n,canSwitch:t[a]}},Lu=e=>e.parentID??null,Ru=e=>e.time?.updated??e.time?.created??0,zu=()=>Fe.getState().activeSessions.filter(e=>Lu(e)===null).slice().sort((e,t)=>Ru(t)-Ru(e)),Bu=()=>{let e=zu(),t=Re.getState().currentSessionId,n=e.findIndex(e=>e.id===t);return{currentId:t,prevId:n>0?e[n-1].id:null,nextId:n>=0&&n<e.length-1?e[n+1].id:null}},Vu=(e,t)=>{if(Re.getState().currentSessionId!==t.currentId)return!1;let n=e===`prev`?t.prevId:t.nextId;if(!n)return!1;let r=Fe.getState().activeSessions.find(e=>e.id===n);return r?(Re.getState().setCurrentSession(r.id,Me(r)),!0):!1},Hu=(e,t,n)=>{let r=Z.useRef(t?.onSwitch);r.current=t?.onSwitch;let i=Z.useRef(t?.onProgress);i.current=t?.onProgress,Z.useEffect(()=>{let t=e.current;if(!t)return;let n=!1,a=0,o=0,s={currentId:null,prevId:null,nextId:null},c={prev:!1,next:!1},l=!1,u=!1,d=!1,f=!1,p=null,m=e=>{if(e.touches.length!==1){n=!1;return}let t=e.touches[0],r=document.elementFromPoint(t.clientX,t.clientY);if(!r){n=!1;return}let i=r.closest(Au),f=document.documentElement,p=i!==null&&(i.contains(document.activeElement)||f.classList.contains(`oc-keyboard-open`)||f.classList.contains(`oc-browser-keyboard-open`));if(p){n=!1;return}if(!Nu({onExplicitSurface:i!==null,onCodeBlock:ju(r),withinHorizontalScroller:Mu(r,!0),withinNativeBackEdge:Pu(t.clientX),composerActive:p})){n=!1;return}n=!0,a=t.clientX,o=t.clientY,s=Bu(),c={prev:s.prevId!==null,next:s.nextId!==null},l=!1,u=!1,d=!1},h=e=>{if(!n)return;if(e.touches.length!==1){n=!1,l&&_e(`light`,{bypassCadence:!0}),l=!1,u=!1,d&&i.current?.(null),d=!1;return}let t=e.touches[0],r=Iu({startX:a,startY:o,endX:t.clientX,endY:t.clientY},c);if(!r){l&&(l=!1,_e(`light`,{bypassCadence:!0}),u=!1),d&&i.current?.(null),d=!1;return}e.cancelable&&e.preventDefault(),d=!0,i.current?.(r);let s=Math.abs(r.offsetX),f=Oe({thresholdReached:l,distance:s,enterDistance:Eu,cancelDistance:56,available:r.canSwitch});l=f.thresholdReached,f.event===`enter`&&(u=_e(`medium`,{bypassCadence:!0})),f.event===`cancel`&&(_e(`light`,{bypassCadence:!0}),u=!1)},g=e=>{if(!n)return;n=!1;let t=e.changedTouches[0];if(!t){l&&_e(`light`,{bypassCadence:!0}),l=!1,u=!1,d&&i.current?.(null),d=!1;return}if(Mu(document.elementFromPoint(t.clientX,t.clientY),!0)){l&&_e(`light`,{bypassCadence:!0}),l=!1,u=!1,d&&i.current?.(null),d=!1;return}let c=Fu({startX:a,startY:o,endX:t.clientX,endY:t.clientY});if(!c){l&&_e(`light`,{bypassCadence:!0}),l=!1,u=!1,d&&i.current?.(null),d=!1;return}Vu(c,s)?(u||_e(`medium`,{bypassCadence:!0}),f=!0,p!==null&&window.clearTimeout(p),p=window.setTimeout(()=>{f=!1,p=null},500),r.current?.(c)):l&&_e(`light`,{bypassCadence:!0}),l=!1,u=!1,d&&i.current?.(null),d=!1},_=()=>{n=!1,l&&_e(`light`,{bypassCadence:!0}),l=!1,u=!1,d&&i.current?.(null),d=!1},v=e=>{f&&(f=!1,p!==null&&(window.clearTimeout(p),p=null),e.preventDefault(),e.stopPropagation())};return t.addEventListener(`touchstart`,m,{passive:!0}),t.addEventListener(`touchmove`,h,{passive:!1}),t.addEventListener(`touchend`,g,{passive:!0}),t.addEventListener(`touchcancel`,_,{passive:!0}),t.addEventListener(`click`,v,!0),()=>{p!==null&&window.clearTimeout(p),t.removeEventListener(`touchstart`,m),t.removeEventListener(`touchmove`,h),t.removeEventListener(`touchend`,g),t.removeEventListener(`touchcancel`,_),t.removeEventListener(`click`,v,!0)}},[e,n])},Uu=.85,Wu=8,Gu=.35,Ku=.22,qu=e=>({segmentStart:e,lastTouch:e,open:!1}),Ju=e=>e*Gu,Yu=e=>e*Ku,Xu=(e,t)=>Math.max(0,e-t),Zu=(e,t)=>Math.max(0,t-e),Qu=(e,t)=>{let n=Math.abs(e);return n<Wu||Math.abs(t)<=n*Uu},$u=(e,t,n)=>{let r=t.clientX-e.segmentStart.clientX,i=t.clientY-e.segmentStart.clientY,a=Xu(e.segmentStart.clientX,t.clientX),o=Ju(n),s=Yu(n),c=e.open;return c=a<=0?!1:e.open?a>=s:a>=o&&Qu(r,i),{segmentStart:e.segmentStart,lastTouch:t,open:c}},ed=e=>{if(e.disabled||e.startedOnExcludedTarget)return{open:!1,back:!1};let t=e.endX-e.startX,n=e.endY-e.startY,r=Xu(e.startX,e.endX),i=Zu(e.startX,e.endX),a=Ju(e.viewportWidth),o=Qu(t,n);return{open:r>=a&&o,back:i>=a&&o}},td=(e,t,n)=>Math.min(Xu(e,t)/Math.max(1,Ju(n)),1),nd=(e,t,n)=>Math.min(Zu(e,t)/Math.max(1,Ju(n)),1),rd=e=>{let t=e;for(;t&&t!==document.body&&t!==document.documentElement;){let e=window.getComputedStyle(t).overflowX;if((e===`auto`||e===`scroll`)&&t.scrollWidth>t.clientWidth)return!0;t=t.parentElement}return!1},id=e=>{let t=document.elementFromPoint(e.clientX,e.clientY);return!!t?.closest(`[data-session-swipe-surface="true"]`)||rd(t)},ad=1,od=(e,t)=>{if(!e||e.rangeCount===0||e.isCollapsed)return!1;if(!t)return!0;let n=e.anchorNode;if(!n)return!1;let r=n.nodeType===ad?n:n.parentElement;return!!(r&&t.contains(r))},sd=e=>od(window.getSelection(),e),cd=(e,t,n)=>{let r=Z.useRef(t.onOpen);r.current=t.onOpen;let i=Z.useRef(t.onPreviewStart);i.current=t.onPreviewStart;let a=Z.useRef(t.onPreviewCancel);a.current=t.onPreviewCancel;let o=Z.useRef(t.onProgress);o.current=t.onProgress;let s=Z.useRef(t.onBack);s.current=t.onBack;let c=Z.useRef(t.onBackProgress);c.current=t.onBackProgress;let l=Z.useRef(t.disabled);l.current=t.disabled,Z.useEffect(()=>{let t=e.current;if(!t)return;let n=!1,u=!1,d=null,f=!1,p=!1,m=!1,h=0,g=0,_=null,v=e=>{let t=Ju(g),n=Oe({thresholdReached:p,distance:e,enterDistance:t,cancelDistance:Yu(g),available:!0});p=n.thresholdReached,n.event===`enter`&&(m=_e(`medium`,{bypassCadence:!0})),n.event===`cancel`&&(_e(`light`,{bypassCadence:!0}),m=!1)},y=e=>{o.current?.(null),p&&!e&&_e(`light`,{bypassCadence:!0}),p=!1,m=!1,e?r.current():f&&a.current?.(),f=!1},b=e=>{c.current?.(null),p&&!e&&_e(`light`,{bypassCadence:!0}),p=!1,m=!1,e&&s.current?.()},x=e=>{if(e.touches.length!==1){n=!1,_=null;return}if(l.current){n=!1,_=null;return}let r=e.touches[0];n=!0,g=window.innerWidth,u=id(r)||sd(t),d=null,f=!1,p=!1,m=!1,h=0,_=qu(r)},S=e=>{if(!n||u||!_)return;if(e.touches.length!==1){d===`sessions`&&y(!1),d===`back`&&b(!1),n=!1,_=null;return}let r=e.touches[0];_=$u(_,r,g);let a=r.clientX-_.segmentStart.clientX,l=r.clientY-_.segmentStart.clientY;if(d===null){if(sd(t))return;let e=Math.abs(a);if(e<Wu||Math.abs(l)>e*Uu)return;if(a<0)d=`sessions`,f=!0,i.current?.();else if(s.current)d=`back`;else return}e.preventDefault(),h=d===`sessions`?Xu(_.segmentStart.clientX,r.clientX):Zu(_.segmentStart.clientX,r.clientX),v(h),d===`sessions`?o.current?.(td(_.segmentStart.clientX,r.clientX,g)):c.current?.(nd(_.segmentStart.clientX,r.clientX,g))},C=e=>{if(!n||!_)return;if(n=!1,!d){_=null;return}let t=e.changedTouches[0];t&&(_=$u(_,t,g),h=d===`sessions`?Xu(_.segmentStart.clientX,t.clientX):Zu(_.segmentStart.clientX,t.clientX),v(h));let r=d===`sessions`?_.open:ed({startX:_.segmentStart.clientX,startY:_.segmentStart.clientY,endX:_.lastTouch.clientX,endY:_.lastTouch.clientY,viewportWidth:g,disabled:!1,startedOnExcludedTarget:!1}).back;_=null,e.preventDefault(),r&&!m&&_e(`medium`,{bypassCadence:!0}),d===`sessions`?y(r):b(r)},w=()=>{d===`sessions`&&y(!1),d===`back`&&b(!1),n=!1,_=null};return t.addEventListener(`touchstart`,x,{passive:!0,capture:!0}),t.addEventListener(`touchmove`,S,{passive:!1,capture:!0}),t.addEventListener(`touchend`,C,{passive:!1,capture:!0}),t.addEventListener(`touchcancel`,w,{passive:!0,capture:!0}),()=>{f&&y(!1),d===`back`&&b(!1),t.removeEventListener(`touchstart`,x,!0),t.removeEventListener(`touchmove`,S,!0),t.removeEventListener(`touchend`,C,!0),t.removeEventListener(`touchcancel`,w,!0)}},[e,n])},ld=()=>{if(typeof window>`u`)return!1;let e=window.Capacitor?.getPlatform?.();return e===`ios`||e===`android`},ud=(e,t)=>{f()?.push?.registerApnsToken?.({token:e,platform:A(),locale:t})},dd=e=>{let{enabled:t}=e,n=M(e=>e.nativeNotificationsEnabled),r=K(e=>e.locale),i=Z.useRef(null),a=Z.useRef(r);a.current=r,Z.useEffect(()=>{if(!t||!n||!ld())return;let e=!1,r=[];return L(async()=>{let{PushNotifications:e}=await import(`./vendor-capacitor-push-notifications-DB3-G2vL.js`).then(e=>e.t);return{PushNotifications:e}},__vite__mapDeps([54,1,10])).then(async({PushNotifications:t})=>{if(e)return;let n=await t.checkPermissions().catch(()=>null);if(n?.receive!==`granted`&&(n=await t.requestPermissions().catch(()=>null)),n?.receive!==`granted`)return;let o=await t.addListener(`registration`,e=>{i.current=e.value,ud(e.value,a.current)}),s=await t.addListener(`registrationError`,e=>{console.warn(`[Push] APNs registration error:`,e)});if(await t.register().catch(()=>void 0),e){o.remove(),s.remove();return}r.push(()=>void o.remove(),()=>void s.remove())}).catch(()=>void 0),()=>{e=!0,r.forEach(e=>e())}},[t,n]),Z.useEffect(()=>{if(!t||!n||!ld())return;let e=i.current;e&&ud(e,r)},[t,n,r]),Z.useEffect(()=>{if(n)return;let e=i.current;e&&(i.current=null,f()?.push?.unregisterApnsToken?.({token:e}))},[n])},fd=`OpenChamberLiveActivity`,pd=5e3,md=3600,hd=`live`,gd=F(fd),_d=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable;function vd(){return typeof window>`u`?!1:_d({isCapacitor:O(),platform:A(),pluginAvailable:I.isPluginAvailable(fd)})}var yd=()=>gd,bd=new Set([`permission`,`input`,`retry`]),xd=()=>({trackedSessionId:null,started:!1,startedAt:null,busySince:null,lastStatus:null,eventVersion:0,items:[]}),Sd=(e,t)=>Math.max(Math.floor(e),t+1),Cd=e=>e.failedEpoch===e.currentEpoch?e.previous:e.current,wd=e=>e.failedEpoch===e.currentEpoch&&e.retryCount<1,Td=e=>e.hasSessionError?`error`:e.hasPendingPermissions?`permission`:e.hasPendingQuestions?`input`:e.statusType===`retry`?`retry`:e.statusType===`busy`?`working`:e.statusType===`idle`?`complete`:null,Ed=e=>{let t=e.trim();return t.length<=80?t:`${t.slice(0,79)}…`},Dd=e=>typeof e.parentID==`string`&&e.parentID.length>0?e.parentID:null,Od=e=>{if(e.runningIds.size===0)return[];let t=[];for(let n of e.sessions)!e.runningIds.has(n.id)||Dd(n)||t.push({sessionId:n.id,title:Ed(n.title??``),statusType:e.statuses[n.id]?.type??`busy`});return t},kd=e=>e!==`complete`&&e!==`error`,Ad=e=>e.some(e=>e.status===`permission`)?`permission`:e.some(e=>e.status===`input`)?`input`:e.some(e=>e.status===`retry`)?`retry`:e.some(e=>e.status===`tool`)?`tool`:e.some(e=>e.status===`stale`)?`stale`:e.some(e=>e.status===`working`)?`working`:e.some(e=>e.status===`error`)?`error`:`complete`,jd=e=>{if(e.length<=4)return e;let t=e.filter(e=>kd(e.status)),n=e.filter(e=>!kd(e.status)).sort((e,t)=>(t.endedAt??0)-(e.endedAt??0)),r=[...t];for(let e of n){if(r.length>=4)break;r.push(e)}return r.slice(0,4)},Md=(e,t,n,r)=>{if(n&&n.length>0)return n;let i=r?.[e];return i&&i.length>0?i:t},Nd=(e,t,n,r,i)=>{let a=new Map;for(let e of t)a.set(e.sessionId,e);let o=[],s=new Set;for(let t of e){if(i&&!i.has(t.sessionId))continue;let e=a.get(t.sessionId);if(e){let i=Td({statusType:e.statusType,hasPendingPermissions:e.hasPendingPermissions===!0,hasPendingQuestions:e.hasPendingQuestions===!0,hasSessionError:e.hasSessionError===!0})??`working`;o.push({sessionId:t.sessionId,title:Md(t.sessionId,t.title,e.title,r),status:i,startedAt:t.startedAt,busySince:i===`working`?t.busySince??n:null})}else if(kd(t.status))o.push({...t,title:Md(t.sessionId,t.title,void 0,r),status:`complete`,endedAt:n,busySince:null});else{let e=Md(t.sessionId,t.title,void 0,r);o.push(e===t.title?t:{...t,title:e})}s.add(t.sessionId)}for(let e of t){if(s.has(e.sessionId))continue;let t=Td({statusType:e.statusType,hasPendingPermissions:e.hasPendingPermissions===!0,hasPendingQuestions:e.hasPendingQuestions===!0,hasSessionError:e.hasSessionError===!0})??`working`;o.push({sessionId:e.sessionId,title:e.title,status:t,startedAt:n,busySince:t===`working`?n:null})}return jd(o)},Pd=e=>e.map(e=>`${e.sessionId}\0${e.title}\0${e.status}\0${e.endedAt??``}`).join(`
|
|
15
|
-
`),Fd=e=>e.map(e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:e.startedAt};return e.endedAt!==void 0&&(t.endedAt=e.endedAt),t}),Id=(e,t,n,r,i)=>{let a=e.filter(e=>kd(e.status)),o=a[0]??e[0],s={sessionId:hd,startedAt:o?.startedAt??r,status:t,eventVersion:n,updatedAt:r,title:o?.title,workingCount:a.length,items:Fd(e)};return i?.endedAt!==void 0&&(s.endedAt=i.endedAt),i?.dismissalSeconds!==void 0&&(s.dismissalSeconds=i.dismissalSeconds),s},Ld=e=>{let t={sessionId:e.sessionId,startedAt:e.startedAt,status:e.status,eventVersion:e.eventVersion,updatedAt:e.updatedAt};return e.endedAt!==void 0&&(t.endedAt=e.endedAt),e.dismissalSeconds!==void 0&&(t.dismissalSeconds=e.dismissalSeconds),e.title!==void 0&&(t.title=e.title),e.workingCount!==void 0&&(t.workingCount=e.workingCount),e.items!==void 0&&(t.items=e.items),t},Rd=(e,t,n,r)=>{let i=e.trackedSessionId;if(!i||!e.started)return{state:xd(),commands:[]};let a=Sd(t,e.eventVersion);return{state:xd(),commands:[{type:`end`,payload:Ld({sessionId:i,startedAt:e.startedAt??t,status:n,eventVersion:a,updatedAt:t,endedAt:t,dismissalSeconds:r})}]}},zd=(e,t,n,r,i)=>{let a=Sd(r,i);return{state:{trackedSessionId:e,started:!0,startedAt:n,busySince:null,lastStatus:t,eventVersion:a,items:[]},commands:[{type:`start`,payload:Ld({sessionId:e,startedAt:n,status:t,eventVersion:a,updatedAt:r})}]}},Bd=(e,t,n)=>{let r=Td(t),i=e.busySince;if(r===`working`?i??=t.now:(!e.started&&!r||!e.started&&r===`complete`||!e.started&&r===`error`)&&(i=null),!e.started){if(r===`working`){let r=pd-(t.now-(i??t.now));if(r>0)return{state:{...e,trackedSessionId:n,busySince:i},commands:[{type:`wait`,delayMs:r}]}}else if(!r||!bd.has(r))return{state:{...xd(),trackedSessionId:n},commands:[]};return zd(n,r,i??t.now,t.now,e.eventVersion)}if(r===`complete`)return Rd({...e,busySince:i},t.now,`complete`,900);if(r===`error`)return Rd({...e,busySince:i},t.now,`error`,md);if(!r||r===e.lastStatus)return{state:{...e,trackedSessionId:n,busySince:i},commands:[]};let a=Sd(t.now,e.eventVersion);return{state:{trackedSessionId:n,started:!0,startedAt:e.startedAt??t.now,busySince:r===`working`?i:null,lastStatus:r,eventVersion:a,items:e.items},commands:[{type:`update`,payload:Ld({sessionId:n,startedAt:e.startedAt??t.now,status:r,eventVersion:a,updatedAt:t.now})}]}},Vd=(e,t,n)=>{let r=e.trackedSessionId;if(!r||!e.started)return{state:e,commands:[]};let i=Sd(n,e.eventVersion);return{state:{...e,busySince:null,lastStatus:t,eventVersion:i},commands:[{type:`update`,payload:Ld({sessionId:r,startedAt:e.startedAt??n,status:t,eventVersion:i,updatedAt:n})}]}},Hd=(e,t,n)=>{let r=Nd(e.items,n,t.now,t.sessionTitles,t.rootSessionIds),i=r.filter(e=>kd(e.status)),a=Ad(r),o=i.reduce((e,t)=>{let n=t.busySince??t.startedAt;return e===null||n<e?n:e},null);if(!t.connected){let n=e.busySince===null?e:{...e,busySince:null};if(!n.started||n.lastStatus===`stale`)return{state:{...n,items:r},commands:[]};let i=Sd(t.now,n.eventVersion),a=r.map(e=>kd(e.status)?{...e,status:`stale`}:e);return{state:{...n,items:a,lastStatus:`stale`,eventVersion:i,busySince:null},commands:[{type:`update`,payload:Ld(Id(a,`stale`,i,t.now))}]}}if(!e.started){if(i.length===0)return{state:xd(),commands:[]};if(!i.some(e=>bd.has(e.status))){let n=pd-(t.now-(o??t.now));if(n>0)return{state:{...e,trackedSessionId:hd,items:r,busySince:o},commands:[{type:`wait`,delayMs:n}]}}let n=o??t.now,s=r.map(e=>kd(e.status)?{...e,startedAt:e.busySince??n}:e),c=Sd(t.now,e.eventVersion);return{state:{trackedSessionId:hd,started:!0,startedAt:n,busySince:null,lastStatus:a,eventVersion:c,items:s},commands:[{type:`start`,payload:Ld(Id(s,a,c,t.now))}]}}if(i.length===0){let n=r.some(e=>e.status===`error`)?`error`:`complete`,i=Sd(t.now,e.eventVersion);return{state:xd(),commands:[{type:`end`,payload:Ld(Id(r,n,i,t.now,{endedAt:t.now,dismissalSeconds:n===`error`?md:900}))}]}}if(Pd(e.items)===Pd(r)&&e.lastStatus===a)return{state:{...e,trackedSessionId:hd,items:r,busySince:null},commands:[]};let s=Sd(t.now,e.eventVersion);return{state:{trackedSessionId:hd,started:!0,startedAt:e.startedAt??o??t.now,busySince:null,lastStatus:a,eventVersion:s,items:r},commands:[{type:`update`,payload:Ld(Id(r,a,s,t.now))}]}},Ud=(e,t)=>{if(t.catalog)return Hd(e,t,t.catalog);if(!t.connected){let n=e.busySince===null?e:{...e,busySince:null};return!n.started||n.lastStatus===`stale`||!n.trackedSessionId?{state:n,commands:[]}:Vd(n,`stale`,t.now)}let n=[],r=e;if(r.trackedSessionId&&r.trackedSessionId!==t.sessionId)if(r.started){let e=Rd(r,t.now,r.lastStatus??`complete`,0);n.push(...e.commands),r=e.state}else r=xd();if(!t.sessionId){if(r.started){let e=Rd(r,t.now,`complete`,900);return{state:e.state,commands:[...n,...e.commands]}}return{state:xd(),commands:n}}let i=Bd(r,t,t.sessionId);return{state:i.state,commands:[...n,...i.commands]}},Wd=e=>e/1e3,Gd=e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:Wd(e.startedAt)};return e.endedAt!==void 0&&(t.endedAt=Wd(e.endedAt)),t},Kd=e=>{let t={sessionId:e.sessionId,startedAt:Wd(e.startedAt),status:e.status,eventVersion:e.eventVersion,updatedAt:Wd(e.updatedAt)};return e.endedAt!==void 0&&(t.endedAt=Wd(e.endedAt)),e.dismissalSeconds!==void 0&&(t.dismissalSeconds=e.dismissalSeconds),e.title!==void 0&&(t.title=e.title),e.workingCount!==void 0&&(t.workingCount=e.workingCount),e.items!==void 0&&(t.items=e.items.map(Gd)),t},qd=e=>{let t={};return e.title!==void 0&&(t.title=e.title),e.workingCount!==void 0&&(t.workingCount=e.workingCount),e.items!==void 0&&(t.items=e.items),t},Jd=(e,t,n)=>{if(!e||n.type===`wait`)return Promise.resolve();let r=Kd(n.payload),i=qd(r);return n.type===`start`?t.start({sessionId:r.sessionId,startedAt:r.startedAt,status:r.status,eventVersion:r.eventVersion,updatedAt:r.updatedAt,...i}):n.type===`update`?t.update({sessionId:r.sessionId,startedAt:r.startedAt,status:r.status,eventVersion:r.eventVersion,updatedAt:r.updatedAt,...i}):t.end({sessionId:r.sessionId,startedAt:r.startedAt,status:r.status,eventVersion:r.eventVersion,updatedAt:r.updatedAt,endedAt:r.endedAt,dismissalSeconds:r.dismissalSeconds,...i})},Yd=e=>e.getCurrentEpoch()===e.epoch?!e.getCurrentSessionId||e.getCurrentSessionId()===e.observation.sessionId:!1,Xd=async e=>{let t=e.state;if(!Yd(e))return{state:t,delayMs:null,retry:!1,superseded:!0};let n=Ud(t,e.observation),r=n.commands.find(e=>e.type===`wait`),i=r?.type===`wait`?r.delayMs:null,a=n.commands.filter(e=>e.type!==`wait`);if(a.length===0)return Yd(e)?{state:n.state,delayMs:i,retry:!1,superseded:!1}:{state:t,delayMs:null,retry:!1,superseded:!0};let o=t;try{for(let[r,i]of a.entries()){if(!Yd(e)||(await Jd(e.available,e.plugin,i),!Yd(e)))return{state:t,delayMs:null,retry:!1,superseded:!0};let s=r===a.length-1;o=i.type===`end`&&!s?xd():n.state}return{state:n.state,delayMs:i,retry:!1,superseded:!1}}catch{if(!Yd(e))return{state:t,delayMs:null,retry:!1,superseded:!0};let r=Cd({failedEpoch:e.epoch,currentEpoch:e.getCurrentEpoch(),previous:o,current:n.state}),i=wd({failedEpoch:e.epoch,currentEpoch:e.getCurrentEpoch(),retryCount:e.retryCount});return{state:r,delayMs:i?250:null,retry:i,superseded:!1}}},Zd=()=>({desired:null,registered:null}),Qd=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null},$d=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=Qd(t.activityId),r=Qd(t.sessionId),i=Qd(t.token);return!n||!r||!i?null:{activityId:n,sessionId:r,token:i}},ef=(e,t)=>e.activityId===t.activityId&&e.token===t.token,tf=(e,t)=>{let n=e.registered?.runtimeIdentity===t?e.registered:null;return e.desired===null&&n===e.registered?e:{desired:null,registered:n}},nf=(e,t)=>{if(!t.connected)return[];if(e.desired&&t.enabled&&t.selectedSessionId&&e.desired.sessionId===t.selectedSessionId){let n=e.registered;return n&&ef(n,e.desired)&&n.runtimeIdentity===t.runtimeIdentity?[]:[{type:`register`,payload:{activityId:e.desired.activityId,sessionId:e.desired.sessionId,token:e.desired.token},runtimeIdentity:t.runtimeIdentity}]}return e.registered&&e.registered.runtimeIdentity===t.runtimeIdentity?[{type:`unregister`,payload:{token:e.registered.token},runtimeIdentity:t.runtimeIdentity}]:[]},rf=(e,t,n)=>{let r=e;if(n.type===`pushToken`){if(!t.enabled||n.sessionId!==t.selectedSessionId)return{state:e,commands:[]};r={...e,desired:{activityId:n.activityId,sessionId:n.sessionId,token:n.token}}}else n.type===`localEndSucceeded`||n.type===`dispose`||!t.enabled||e.desired&&e.desired.sessionId!==t.selectedSessionId?r=tf(e,t.runtimeIdentity):e.registered&&e.registered.runtimeIdentity!==t.runtimeIdentity&&!e.desired&&(r={...e,registered:null});return{state:r,commands:nf(r,t)}},af=async e=>{try{return await e}catch{return null}},of=async e=>{let t=e.state;for(let n of e.commands){if(n.runtimeIdentity!==e.getRuntimeIdentity()){n.type===`unregister`&&t.registered?.runtimeIdentity===n.runtimeIdentity&&(t={...t,registered:null});continue}if(n.type===`register`){let r=t.registered;if(n.runtimeIdentity!==e.getRuntimeIdentity()||(await af(e.register(n.payload)))?.ok!==!0||n.runtimeIdentity!==e.getRuntimeIdentity())continue;if(t={...t,registered:{...n.payload,runtimeIdentity:n.runtimeIdentity}},r&&r.runtimeIdentity===n.runtimeIdentity&&r.token!==n.payload.token){if(n.runtimeIdentity!==e.getRuntimeIdentity())continue;await af(e.unregister({token:r.token}))}continue}if(n.runtimeIdentity!==e.getRuntimeIdentity()){t.registered?.runtimeIdentity===n.runtimeIdentity&&(t={...t,registered:null});continue}(await af(e.unregister(n.payload)))?.ok===!0&&t.registered?.token===n.payload.token&&(t={...t,registered:null})}return t},sf=new Map,cf=[];function lf(){let e=vd(),t=Ge(e=>e.isConnected),n=ke({enabled:e}),r=me(t=>e?t.statusById:sf),i=Fe(t=>e?t.activeSessions:cf),o=(0,Z.useMemo)(()=>e?Ar(n,r):new Set,[e,r,n]),c=(0,Z.useMemo)(()=>e?Od({runningIds:o,statuses:n,sessions:i}):[],[e,n,o,i]),l=(0,Z.useMemo)(()=>{if(!e)return{};let t={};for(let e of i){let n=e.parentID;if(typeof n==`string`&&n.length>0)continue;let r=typeof e.title==`string`?e.title.trim():``;r&&(t[e.id]=r.length<=80?r:`${r.slice(0,79)}…`)}return t},[e,i]),u=(0,Z.useMemo)(()=>{if(!e)return new Set;let t=new Set;for(let e of i){let n=e.parentID;typeof n==`string`&&n.length>0||t.add(e.id)}return t},[e,i]),d=(0,Z.useMemo)(()=>[c.map(e=>`${e.sessionId}\0${e.title}\0${e.statusType??``}`).join(`
|
|
14
|
+
`}),t[43]=P):P=t[43];let F;return t[44]!==N||t[45]!==S?(F=(0,$.jsxs)(`div`,{className:`fixed inset-0 z-40 pointer-events-none`,children:[S,N,P]}),t[44]=N,t[45]=S,t[46]=F):F=t[46],F};function ll(e){let t=(0,Q.c)(95),{sessionId:n,open:r,onOpenChange:i}=e,{t:a}=ee(),{git:o}=mn(),[s,c]=Z.useState(!1),l=r!==void 0,u=l?r:s,d=n.length===0,f;t[0]!==l||t[1]!==i||t[2]!==u?(f=e=>{let t=typeof e==`function`?e(u):e;l||c(t),i?.(t)},t[0]=l,t[1]=i,t[2]=u,t[3]=f):f=t[3];let p=V(f),m=w(Dl),h;t[4]===n?h=t[5]:(h=e=>n?e.getDirectoryForSession(n):null,t[4]=n,t[5]=h);let g=Re(h)||m,_;t[6]===g?_=t[7]:(_=il(g)||null,t[6]=g,t[7]=_);let v=_,y=Je(n,g||void 0),b=Mn(v),x=Pn(v),S=Fn(El),T=Fn(Tl),E=Ge(wl),D=Ge(Cl),O=Ge(Sl),k=Ge(xl),A;t[8]===n?A=t[9]:(A=e=>n?e.sessionModelSelections.get(n)??null:null,t[8]=n,t[9]=A);let M=pe(A),N=gr(bl),P=gr(yl),F=gr(vl),I=gr(_l),L=gr(gl),R=gr(hl),z=gr(ml),B=j(pl);cr();let H;t[10]===p?H=t[11]:(H=()=>{p(!1)},t[10]=p,t[11]=H);let U;t[12]!==g||t[13]!==n?(U=[n,g],t[12]=g,t[13]=n,t[14]=U):U=t[14],Z.useEffect(H,U);let W,K;t[15]!==S||t[16]!==o||t[17]!==v?(W=()=>{v&&S(v,o)},K=[S,o,v],t[15]=S,t[16]=o,t[17]=v,t[18]=W,t[19]=K):(W=t[18],K=t[19]),Z.useEffect(W,K);let te,q;t[20]!==T||t[21]!==o||t[22]!==v?(q=()=>{if(v)return qe.onGitRefreshHint(e=>{il(e.directory)===v&&T(v,o)})},te=[T,o,v],t[20]=T,t[21]=o,t[22]=v,t[23]=te,t[24]=q):(te=t[23],q=t[24]),Z.useEffect(q,te);let ne,re;t[25]===P?(ne=t[26],re=t[27]):(ne=()=>{P()},re=[P],t[25]=P,t[26]=ne,t[27]=re),Z.useEffect(ne,re);let ie,ae;t[28]===R?(ie=t[29],ae=t[30]):(ie=()=>{Bt(R)},ae=[R],t[28]=R,t[29]=ie,t[30]=ae),Z.useEffect(ie,ae);let oe,se;t[31]!==R||t[32]!==F||t[33]!==I||t[34]!==u||t[35]!==N?(oe=()=>{!u||I||R.some(e=>!N.some(t=>t.providerId===e))&&F()},se=[R,F,I,u,N],t[31]=R,t[32]=F,t[33]=I,t[34]=u,t[35]=N,t[36]=oe,t[37]=se):(oe=t[36],se=t[37]),Z.useEffect(oe,se);let J;t[38]===y?J=t[39]:(J=nl(y),t[38]=y,t[39]=J);let ce=J,le;if(t[40]!==y||t[41]!==O||t[42]!==D||t[43]!==g||t[44]!==k||t[45]!==d||t[46]!==ce||t[47]!==E||t[48]!==M){let e=ce??(M?{providerID:M.providerId,modelID:M.modelId}:null)??(D&&O?{providerID:D,modelID:O}:null),n=(e?E.find(t=>t.id===e.providerID):void 0)?.models.find(t=>t.id===e?.modelID),r=e?k(e.providerID,e.modelID):void 0,i=Qc(n?.limit,`context`)??r?.limit?.context??0,a;t[50]===g?a=t[51]:(a=e=>C(e,g||void 0),t[50]=g,t[51]=a);let o;t[52]!==y||t[53]!==a?(o=rl(y,a),t[52]=y,t[53]=a,t[54]=o):o=t[54],le=tl({totalTokens:o,contextLimit:i,isDraft:d}),t[40]=y,t[41]=O,t[42]=D,t[43]=g,t[44]=k,t[45]=d,t[46]=ce,t[47]=E,t[48]=M,t[49]=le}else le=t[49];let ue=le,Y;t[55]!==x?.current||t[56]!==b||t[57]!==a?(Y=b===!0?x?.current?.trim()||a(`gitView.branch.detachedHead`):a(`common.unavailable`),t[55]=x?.current,t[56]=b,t[57]=a,t[58]=Y):Y=t[58];let de=Y,fe;if(t[59]!==R||t[60]!==N||t[61]!==z||t[62]!==a){let e=new Map(N.map(fl)),n;t[64]===R?n=t[65]:(n=e=>R.includes(e.id),t[64]=R,t[65]=n),fe=or.filter(n).filter(t=>e.get(t.id)?.configured===!0).map(t=>{let n=e.get(t.id),r=[];for(let[e,t]of Object.entries(n?.usage?.windows??{}))r.push({key:`window-${e}`,label:rn(e),window:t});let i=Object.entries(n?.usage?.models??{}),o=z[t.id]??[],s=o.length>0?i.filter(e=>{let[t]=e;return o.includes(t)}):i;for(let[e,t]of s){let n=Object.entries(t.windows??{});if(n.length===0)continue;let[i,a]=n[0];r.push({key:`model-${e}-${i}`,label:rn(i),subtitle:nr(e),window:a})}let c=!n.ok&&n.error?n.error:r.length===0?a(`header.services.noRateLimitsReported`):null;return{providerId:t.id,providerName:t.name,rows:r,status:c}}),t[59]=R,t[60]=N,t[61]=z,t[62]=a,t[63]=fe}else fe=t[63];let me=fe,he,ge;t[66]!==u||t[67]!==me?(he=()=>{!u||me.length===0||Bt(me.map(dl))},ge=[u,me],t[66]=u,t[67]=me,t[68]=he,t[69]=ge):(he=t[68],ge=t[69]),Z.useEffect(he,ge);let _e;t[70]===p?_e=t[71]:(_e=()=>{p(ul)},t[70]=p,t[71]=_e);let ve=V(_e),ye;t[72]===p?ye=t[73]:(ye=()=>{p(!1)},t[72]=p,t[73]=ye);let be=V(ye),xe;t[74]===a?xe=t[75]:(xe=a(`mobile.header.openMetadataAria`),t[74]=a,t[75]=xe);let Se=ue?.percentage??0,Ce;t[76]===Se?Ce=t[77]:(Ce=(0,$.jsx)(Xc,{percentage:Se}),t[76]=Se,t[77]=Ce);let we;t[78]!==ve||t[79]!==u||t[80]!==xe||t[81]!==Ce?(we=(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsx)(G,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":xe,"aria-expanded":u,onClick:ve,children:Ce})}),t[78]=ve,t[79]=u,t[80]=xe,t[81]=Ce,t[82]=we):we=t[82];let Te;t[83]!==de||t[84]!==ue||t[85]!==be||t[86]!==I||t[87]!==u||t[88]!==L||t[89]!==B||t[90]!==me?(Te=(0,$.jsx)(cl,{open:u,onClose:be,contextDisplay:ue,branchLabel:de,usageGroups:me,usageDisplayMode:L,isUsageLoading:I,timeFormatPreference:B}),t[83]=de,t[84]=ue,t[85]=be,t[86]=I,t[87]=u,t[88]=L,t[89]=B,t[90]=me,t[91]=Te):Te=t[91];let Ee;return t[92]!==we||t[93]!==Te?(Ee=(0,$.jsxs)($.Fragment,{children:[we,Te]}),t[92]=we,t[93]=Te,t[94]=Ee):Ee=t[94],Ee}function ul(e){return!e}function dl(e){return e.providerId}function fl(e){return[e.providerId,e]}function pl(e){return e.timeFormatPreference}function ml(e){return e.selectedModels}function hl(e){return e.dropdownProviderIds}function gl(e){return e.displayMode}function _l(e){return e.isLoading}function vl(e){return e.fetchAllQuotas}function yl(e){return e.loadSettings}function bl(e){return e.results}function xl(e){return e.getModelMetadata}function Sl(e){return e.currentModelId}function Cl(e){return e.currentProviderId}function wl(e){return e.providers}function Tl(e){return e.fetchStatus}function El(e){return e.ensureStatus}function Dl(e){return e.currentDirectory}function Ol(e){e.stopPropagation()}function kl(e){return e.sessionId?e.userRefreshInFlight||e.backgroundResyncInFlight?`syncing`:e.hasTranscript?null:!e.isConnected&&e.connectionPhase===`reconnecting`||e.loadStatus===`loading`?`syncing`:null:null}function Al(e,t){let n=t?.showDelayMs??250,r=t?.hideGraceMs??1e3,i=!1,a=!1,o=null,s=()=>{o=null,a!==i&&(a=i,e(a))};return{setRaw(e){i=e,o&&clearTimeout(o),o=setTimeout(s,i?n:r)},cancel(){i=!1,o&&=(clearTimeout(o),null)}}}function jl(e){let[t,n]=(0,Z.useState)(!1),r=(0,Z.useRef)(null);r.current||=Al(n);let i=r.current;return(0,Z.useEffect)(()=>(i.setRaw(e),()=>i.cancel()),[e,i]),t}function Ml(e,t){let n=(0,Q.c)(17),{t:r}=ee(),i=Pe(e,t),a=Le(e,t),o=Ge(Il),s=Ge(Fl),c;n[0]!==t||n[1]!==e?(c=()=>D(e,t),n[0]=t,n[1]=e,n[2]=c):c=n[2];let l=(0,Z.useSyncExternalStore)(T,c,Pl),u;n[3]!==t||n[4]!==e?(u=()=>Ce(e,t),n[3]=t,n[4]=e,n[5]=u):u=n[5];let d=(0,Z.useSyncExternalStore)(we,u,Nl),f=i?.status,p;n[6]!==d||n[7]!==s||n[8]!==a||n[9]!==o||n[10]!==e||n[11]!==f||n[12]!==l?(p=kl({sessionId:e,hasTranscript:a,loadStatus:f,userRefreshInFlight:l,backgroundResyncInFlight:d,isConnected:o,connectionPhase:s}),n[6]=d,n[7]=s,n[8]=a,n[9]=o,n[10]=e,n[11]=f,n[12]=l,n[13]=p):p=n[13];let m=jl(p===`syncing`),h;return n[14]!==r||n[15]!==m?(h=m?r(`mobile.chat.syncingMessages`):null,n[14]=r,n[15]=m,n[16]=h):h=n[16],h}function Nl(){return!1}function Pl(){return!1}function Fl(e){return e.connectionPhase}function Il(e){return e.isConnected}function Ll(e){let t=(0,Q.c)(32),{sessionId:n,directory:r,title:i,onBack:a,onOpenMenu:o,onCloseMenu:s,menuOpen:c,children:l,className:u}=e,d=c!==void 0&&c,{t:f}=ee(),p=n.length===0,m=ye(p?null:n),h;t[0]!==p||t[1]!==m?.title||t[2]!==f||t[3]!==i?(h=p?i?.trim()||f(`mobile.menu.newSession`):i?.trim()||m?.title?.trim()||f(`mobile.sessions.untitled`),t[0]=p,t[1]=m?.title,t[2]=f,t[3]=i,t[4]=h):h=t[4];let g=h,_=Ml(p?``:n,r||void 0),[v,y]=Z.useState(!1),b;t[5]!==d||t[6]!==s?(b=e=>{e&&d&&s?.(),y(e)},t[5]=d,t[6]=s,t[7]=b):b=t[7];let x=V(b),S;t[8]!==v||t[9]!==o?(S=()=>{v&&y(!1),o()},t[8]=v,t[9]=o,t[10]=S):S=t[10];let C=V(S),w=d||v,T;t[11]===u?T=t[12]:(T=W(`relative isolate flex h-full min-h-0 w-full flex-col overflow-hidden bg-background text-foreground`,u),t[11]=u,t[12]=T);let E;t[13]!==v||t[14]!==x||t[15]!==n?(E=(0,$.jsx)(ll,{sessionId:n,open:v,onOpenChange:x}),t[13]=v,t[14]=x,t[15]=n,t[16]=E):E=t[16];let D;t[17]!==C||t[18]!==w||t[19]!==d||t[20]!==a||t[21]!==g||t[22]!==_||t[23]!==E?(D=(0,$.jsx)(Zc,{title:g,subtitle:_,onBack:a,onOpenMenu:C,menuOpen:d,elevated:w,trailing:E}),t[17]=C,t[18]=w,t[19]=d,t[20]=a,t[21]=g,t[22]=_,t[23]=E,t[24]=D):D=t[24];let O;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(O=W(`mobile-chat-screen__content relative h-full min-h-0 flex-1`,`[&_[data-scrollbar=chat]>.oc-chat-scroll-content]:pt-[calc(max(0.625rem,var(--oc-safe-area-top,0px))+var(--oc-mobile-detail-navigation-height)+1.25rem)]`),t[25]=O):O=t[25];let k;t[26]===l?k=t[27]:(k=(0,$.jsx)(`div`,{className:O,children:l}),t[26]=l,t[27]=k);let A;return t[28]!==T||t[29]!==D||t[30]!==k?(A=(0,$.jsxs)(`main`,{className:T,children:[D,k]}),t[28]=T,t[29]=D,t[30]=k,t[31]=A):A=t[31],A}var Rl=F(`BarcodeScanner`),zl=`oc-barcode-scanner-active`,Bl=()=>tu()?Rl:null,Vl=()=>window.Capacitor?.getPlatform?.()===`android`,Hl=e=>typeof e==`object`&&e&&`message`in e?String(e.message??``):String(e??``),Ul=e=>/^\s*scan canceled\.?\s*$/i.test(Hl(e)),Wl=e=>/denied access to camera/i.test(Hl(e)),Gl=e=>!Ul(e)&&!Wl(e),Kl=e=>{let t=Hl(e);return/module/i.test(t)&&/not\s*available|unavailable/i.test(t)},ql=e=>{e.installGoogleBarcodeScannerModule?.().catch(()=>void 0)},Jl=e=>{let t=e.trim();if(!t)return null;if(/^openchamber:\/\//i.test(t)){let e=mi(t);return e?{pairing:e}:null}return/^https?:\/\//i.test(t)?{url:t}:null},Yl=e=>{let t=Jl(e);return t?`pairing`in t?{status:`pairing`,...t}:{status:`ok`,...t}:{status:`invalid`}},Xl=e=>{typeof document>`u`||document.documentElement.classList.toggle(zl,e)},Zl=e=>{try{e()}catch{}},Ql=e=>{if(typeof document>`u`)return()=>void 0;let t=document.body,n=document.createElement(`button`);n.type=`button`,n.className=`oc-barcode-scanner-chrome`,n.setAttribute(`aria-label`,`Cancel`),n.textContent=`×`,n.addEventListener(`click`,e),t.appendChild(n);let r=!1;return()=>{r||(r=!0,n.removeEventListener(`click`,e),n.parentNode===t&&t.removeChild(n))}},$l=async e=>{if(!e.startScan||!e.stopScan||!e.addListener)return{status:`unsupported`};let t,n,r,i=!1,a=()=>void 0,o=new Promise(e=>{a=e}),s=e=>{i||(i=!0,a(e))};Xl(!0);let c=Ql(()=>s({status:`cancelled`}));try{let{App:e}=await L(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([53,1,10])),t=await e.addListener(`backButton`,()=>s({status:`cancelled`}));r=()=>void t.remove()}catch{r=void 0}try{return(await Promise.allSettled([Promise.resolve(e.addListener(`barcodesScanned`,({barcodes:e})=>{let t=e?.[0],n=(t?.rawValue??t?.displayValue??``).trim();n&&s(Yl(n))})).then(e=>{t=e}),Promise.resolve(e.addListener(`scanError`,()=>s({status:`failed`}))).then(e=>{n=e})])).some(({status:e})=>e===`rejected`)?s({status:`failed`}):i||e.startScan({formats:[`QR_CODE`]}).catch(e=>{Wl(e)?s({status:`permission-denied`}):s({status:`failed`})}),await o}finally{Xl(!1),Zl(c),Zl(()=>r?.()),await Promise.allSettled([Promise.resolve(t?.remove()),Promise.resolve(n?.remove()),e.stopScan()])}},eu=e=>e.isNativePlatform&&e.isPluginAvailable,tu=()=>eu({isNativePlatform:I.isNativePlatform(),isPluginAvailable:I.isPluginAvailable(`BarcodeScanner`)}),nu=async()=>{let e=Bl();if(!e)return{status:`unsupported`};try{if(e.requestPermissions){let t=(await e.requestPermissions())?.camera;if(t&&t!==`granted`&&t!==`limited`)return{status:`permission-denied`}}if(e.scan)try{let t=(await e.scan({formats:[`QR_CODE`]}))?.barcodes?.[0],n=(t?.rawValue??t?.displayValue??``).trim();return n?Yl(n):{status:`cancelled`}}catch(t){return Ul(t)?{status:`cancelled`}:Wl(t)?{status:`permission-denied`}:Vl()&&Gl(t)&&e.startScan?(Kl(t)&&ql(e),$l(e)):{status:`failed`}}return Vl()&&e.startScan?$l(e):{status:`unsupported`}}catch{return{status:`failed`}}},ru={autoComplete:`off`,autoCorrect:`off`,spellCheck:!1},iu=e=>{let t=(0,Q.c)(32),{disabled:n,isBusy:r,tabIndex:i,inputClassName:a,buttonVariant:o,buttonClassName:s,onRedeem:c,onInvalid:l}=e,u=n!==void 0&&n,d=r!==void 0&&r,f=o===void 0?`outline`:o,p=s===void 0?`h-12 w-full`:s,{t:m}=ee(),[h,g]=Z.useState(``),_;t[0]!==l||t[1]!==c||t[2]!==h?(_=e=>{e.preventDefault();let t=Jl(h);if(!t||!(`pairing`in t)){l();return}c(t.pairing)},t[0]=l,t[1]=c,t[2]=h,t[3]=_):_=t[3];let v=V(_),y;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>g(e.target.value),t[4]=y):y=t[4];let b;t[5]===m?b=t[6]:(b=m(`mobile.connect.link.placeholder`),t[5]=m,t[6]=b);let x;t[7]===m?x=t[8]:(x=m(`mobile.connect.link.label`),t[7]=m,t[8]=x);let S;t[9]!==u||t[10]!==a||t[11]!==h||t[12]!==b||t[13]!==x||t[14]!==i?(S=(0,$.jsx)(`input`,{...ru,value:h,onChange:y,placeholder:b,"aria-label":x,inputMode:`url`,autoCapitalize:`none`,tabIndex:i,disabled:u,className:a}),t[9]=u,t[10]=a,t[11]=h,t[12]=b,t[13]=x,t[14]=i,t[15]=S):S=t[15];let C;t[16]!==u||t[17]!==d||t[18]!==h?(C=u||d||!h.trim(),t[16]=u,t[17]=d,t[18]=h,t[19]=C):C=t[19];let w;t[20]!==d||t[21]!==m?(w=m(d?`mobile.connect.connecting`:`mobile.connect.connectButton`),t[20]=d,t[21]=m,t[22]=w):w=t[22];let T;t[23]!==p||t[24]!==f||t[25]!==C||t[26]!==w?(T=(0,$.jsx)(G,{type:`submit`,variant:f,size:`lg`,className:p,disabled:C,children:w}),t[23]=p,t[24]=f,t[25]=C,t[26]=w,t[27]=T):T=t[27];let E;return t[28]!==v||t[29]!==T||t[30]!==S?(E=(0,$.jsxs)(`form`,{className:`flex w-full flex-col gap-3`,onSubmit:v,children:[S,T]}),t[28]=v,t[29]=T,t[30]=S,t[31]=E):E=t[31],E},au=e=>{let t=(0,Q.c)(6),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`span`,{className:`h-px flex-1 bg-border/70`}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:n}),t[1]=n,t[2]=i);let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(`span`,{className:`h-px flex-1 bg-border/70`}),t[3]=a):a=t[3];let o;return t[4]===i?o=t[5]:(o=(0,$.jsxs)(`div`,{className:`flex items-center gap-3 py-3`,"aria-hidden":`true`,children:[r,i,a]}),t[4]=i,t[5]=o),o};function ou(e){let t=(0,Q.c)(4),n=e===void 0?2500:e,{uiFont:r}=vr(),[i,a]=Z.useState(!1),o,s;return t[0]!==n||t[1]!==r?(o=()=>{let e=!1,t=()=>{e||a(!0)},i=()=>{requestAnimationFrame(()=>requestAnimationFrame(t))},o=Promise.all([jt(r).catch(du),document.fonts?.ready?.then(uu).catch(lu)??Promise.resolve(),Bi.catch(cu)]).then(su),s=new Promise(e=>{window.setTimeout(e,n)});return Promise.race([o,s]).then(i),()=>{e=!0}},s=[r,n],t[0]=n,t[1]=r,t[2]=o,t[3]=s):(o=t[2],s=t[3]),Z.useEffect(o,s),i}function su(){}function cu(){}function lu(){}function uu(){}function du(){}var fu=e=>e.replace(/^\/+|\/+$/g,``),pu=e=>{let t=e.get(`directory`)||e.get(`dir`)||e.get(`path`);if(typeof t!=`string`)return;let n=t.trim();return n.length>0?n:void 0},mu=e=>{let t=fu(e.pathname).split(`/`).filter(Boolean);return e.host?[e.host,...t]:t};function hu(e){if(typeof e!=`string`||e.length===0)return null;let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`openchamber:`)return null;let n=mu(t),r=(n[0]??``).toLowerCase(),i=n.slice(1),a=t.searchParams;switch(r){case`connect`:{let t=mi(e);return t?{type:`connect`,pairing:t}:null}case`session`:{let e=i[0]||a.get(`id`)||``;return e?{type:`session`,sessionId:e,directory:pu(a)}:null}case`assistant`:{let e=i[0]||a.get(`id`)||``;return e?{type:`assistant`,assistantId:e}:null}case`new`:case`new-session`:{let e=a.get(`prompt`)?.trim();return{type:`new-session`,directory:pu(a),projectId:a.get(`project`)??void 0,agent:a.get(`agent`)??void 0,model:a.get(`model`)??void 0,prompt:e||void 0}}case`project`:case`open-project`:{let e;if(i.length>0)try{e=decodeURIComponent(i.join(`/`))}catch{e=i.join(`/`)}let t=pu(a)||e;return t?{type:`open-project`,directory:t}:null}case`sessions`:{let e=a.get(`filter`);return{type:`sessions`,filter:e===`attention`||e===`recent`||e===`all`?e:void 0}}case`status`:return{type:`status`};case`settings`:return{type:`settings`,section:i[0]||a.get(`section`)||void 0};case`changes`:return{type:`changes`,path:i.join(`/`)||a.get(`path`)||void 0,staged:a.get(`staged`)===`true`};case`view`:{let e=(i[0]||``).toLowerCase();return e===`changes`?{type:`changes`}:e===`files`||e===`mcp`||e===`instances`||e===`update`?{type:`view`,target:e}:null}default:return null}}var gu={},_u=null,vu=!1,yu=null,bu=e=>{switch(e.type){case`connect`:return _u?(_u(e.pairing),!0):!1;case`session`:return k()?(Re.getState().setCurrentSession(e.sessionId,e.directory??null),!0):(We.getState().openSession({sessionId:e.sessionId,directory:e.directory??null}),!0);case`assistant`:if(!k()){let t=We.getState();return t.setActiveTab(`assistant`),t.openAssistant(e.assistantId),!0}return nt(e.assistantId),!0;case`new-session`:return k()?(Re.getState().openNewSessionDraft({directoryOverride:e.directory??null,selectedProjectId:e.projectId??null,preserveDirectoryOverride:!!e.directory,ensureProjectForDirectory:!!e.directory,initialPrompt:e.prompt}),!0):(We.getState().openDraft({directoryOverride:e.directory??null,selectedProjectId:e.projectId??null,preserveDirectoryOverride:!!e.directory,ensureProjectForDirectory:!!e.directory,initialPrompt:e.prompt}),!0);case`open-project`:return k()?(Re.getState().openNewSessionDraft({directoryOverride:e.directory,preserveDirectoryOverride:!0}),!0):(We.getState().openDraft({directoryOverride:e.directory,preserveDirectoryOverride:!0}),!0);case`sessions`:return gu.openSessions?(gu.openSessions(e.filter),!0):!1;case`status`:return gu.openSessions?(gu.openSessions(),!0):(j.getState().setMobileSessionPanelOpen(!0),!0);case`view`:return gu.openView?(gu.openView(e.target),!0):!1;case`changes`:return gu.openChanges?(gu.openChanges({path:e.path,staged:e.staged}),!0):!1;case`settings`:return gu.openSettings?(gu.openSettings(e.section),!0):!1}return!1},xu=()=>{if(!yu||!vu&&yu.type!==`connect`)return;let e=yu;yu=null,bu(e)||(yu=e)},Su=e=>{yu=e,xu()},Cu=e=>{let t=hu(e);t&&Su(t)},wu=e=>{vu=e,xu()},Tu=e=>{let t=(0,Q.c)(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>(gu=e,xu(),()=>{gu===e&&(gu={})}),r=[e],t[0]=e,t[1]=n,t[2]=r),Z.useEffect(n,r)},Eu=e=>{let t=(0,Q.c)(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>(_u=e,xu(),()=>{_u===e&&(_u=null)}),r=[e],t[0]=e,t[1]=n,t[2]=r),Z.useEffect(n,r)},Du=e=>{let{ready:t}=e,[n,r]=Z.useState(()=>O()?`pending`:`none`);return Z.useEffect(()=>{wu(t)},[t]),Z.useEffect(()=>{if(!O())return;let e=!1,t=[];return L(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([53,1,10])).then(async({App:n})=>{if(e)return;let i=await n.addListener(`appUrlOpen`,e=>{Cu(e?.url)});if(e){i.remove();return}t.push(()=>void i.remove());let a=await n.getLaunchUrl().catch(()=>void 0);if(e)return;let o=hu(a?.url);r(o?.type===`connect`?`connect`:o?`other`:`none`),o&&Su(o)}).catch(()=>{e||r(`none`)}),L(async()=>{let{PushNotifications:e}=await import(`./vendor-capacitor-push-notifications-DB3-G2vL.js`).then(e=>e.t);return{PushNotifications:e}},__vite__mapDeps([54,1,10])).then(async({PushNotifications:n})=>{if(e)return;let r=await n.addListener(`pushNotificationActionPerformed`,e=>{let t=e?.notification?.data,n=typeof t?.url==`string`?t.url:typeof t?.deeplink==`string`?t.deeplink:void 0;if(n){Cu(n);return}let r=typeof t?.assistantID==`string`?t.assistantID.trim():``;if(r){Su({type:`assistant`,assistantId:r});return}let i=typeof t?.sessionId==`string`?t.sessionId:void 0;i&&Su({type:`session`,sessionId:i})});if(e){r.remove();return}t.push(()=>void r.remove())}).catch(()=>void 0),()=>{e=!0,t.forEach(e=>e())}},[]),n},Ou=64,ku=.6,Au=28,ju=`[class*="code-block"], [class*="codeBlock"], pre, .cm-editor`,Mu=`[data-session-swipe-surface="true"]`,Nu=e=>e?e.matches(ju)||e.closest(ju)!==null:!1,Pu=(e,t)=>{let n=e;for(;n&&n!==document.body&&n!==document.documentElement;){let e=window.getComputedStyle(n);if(t){let t=e.overflowX;if((t===`auto`||t===`scroll`)&&n.scrollWidth>n.clientWidth)return!0}else{let t=e.overflowY;if((t===`auto`||t===`scroll`)&&n.scrollHeight>n.clientHeight)return!0}n=n.parentElement}return!1},Fu=e=>e.composerActive||e.onCodeBlock||e.withinHorizontalScroller||e.withinNativeBackEdge?!1:e.onExplicitSurface,Iu=e=>O()&&A()===`ios`&&e<=Au,Lu=e=>{let t=e.endX-e.startX,n=e.endY-e.startY,r=Math.abs(t);return r<Ou||Math.abs(n)>r*ku?null:t<0?`next`:`prev`},Ru=(e,t)=>{let n=e.endX-e.startX,r=e.endY-e.startY,i=Math.abs(n);if(i<8||Math.abs(r)>i*ku)return null;let a=n<0?`next`:`prev`;return{direction:a,progress:Math.min(i/Ou,1),offsetX:n,canSwitch:t[a]}},zu=e=>e.parentID??null,Bu=e=>e.time?.updated??e.time?.created??0,Vu=()=>Fe.getState().activeSessions.filter(e=>zu(e)===null).slice().sort((e,t)=>Bu(t)-Bu(e)),Hu=()=>{let e=Vu(),t=Re.getState().currentSessionId,n=e.findIndex(e=>e.id===t);return{currentId:t,prevId:n>0?e[n-1].id:null,nextId:n>=0&&n<e.length-1?e[n+1].id:null}},Uu=(e,t)=>{if(Re.getState().currentSessionId!==t.currentId)return!1;let n=e===`prev`?t.prevId:t.nextId;if(!n)return!1;let r=Fe.getState().activeSessions.find(e=>e.id===n);return r?(Re.getState().setCurrentSession(r.id,Me(r)),!0):!1},Wu=(e,t,n)=>{let r=Z.useRef(t?.onSwitch);r.current=t?.onSwitch;let i=Z.useRef(t?.onProgress);i.current=t?.onProgress,Z.useEffect(()=>{let t=e.current;if(!t)return;let n=!1,a=0,o=0,s={currentId:null,prevId:null,nextId:null},c={prev:!1,next:!1},l=!1,u=!1,d=!1,f=!1,p=null,m=e=>{if(e.touches.length!==1){n=!1;return}let t=e.touches[0],r=document.elementFromPoint(t.clientX,t.clientY);if(!r){n=!1;return}let i=r.closest(Mu),f=document.documentElement,p=i!==null&&(i.contains(document.activeElement)||f.classList.contains(`oc-keyboard-open`)||f.classList.contains(`oc-browser-keyboard-open`));if(p){n=!1;return}if(!Fu({onExplicitSurface:i!==null,onCodeBlock:Nu(r),withinHorizontalScroller:Pu(r,!0),withinNativeBackEdge:Iu(t.clientX),composerActive:p})){n=!1;return}n=!0,a=t.clientX,o=t.clientY,s=Hu(),c={prev:s.prevId!==null,next:s.nextId!==null},l=!1,u=!1,d=!1},h=e=>{if(!n)return;if(e.touches.length!==1){n=!1,l&&_e(`light`,{bypassCadence:!0}),l=!1,u=!1,d&&i.current?.(null),d=!1;return}let t=e.touches[0],r=Ru({startX:a,startY:o,endX:t.clientX,endY:t.clientY},c);if(!r){l&&(l=!1,_e(`light`,{bypassCadence:!0}),u=!1),d&&i.current?.(null),d=!1;return}e.cancelable&&e.preventDefault(),d=!0,i.current?.(r);let s=Math.abs(r.offsetX),f=Oe({thresholdReached:l,distance:s,enterDistance:Ou,cancelDistance:56,available:r.canSwitch});l=f.thresholdReached,f.event===`enter`&&(u=_e(`medium`,{bypassCadence:!0})),f.event===`cancel`&&(_e(`light`,{bypassCadence:!0}),u=!1)},g=e=>{if(!n)return;n=!1;let t=e.changedTouches[0];if(!t){l&&_e(`light`,{bypassCadence:!0}),l=!1,u=!1,d&&i.current?.(null),d=!1;return}if(Pu(document.elementFromPoint(t.clientX,t.clientY),!0)){l&&_e(`light`,{bypassCadence:!0}),l=!1,u=!1,d&&i.current?.(null),d=!1;return}let c=Lu({startX:a,startY:o,endX:t.clientX,endY:t.clientY});if(!c){l&&_e(`light`,{bypassCadence:!0}),l=!1,u=!1,d&&i.current?.(null),d=!1;return}Uu(c,s)?(u||_e(`medium`,{bypassCadence:!0}),f=!0,p!==null&&window.clearTimeout(p),p=window.setTimeout(()=>{f=!1,p=null},500),r.current?.(c)):l&&_e(`light`,{bypassCadence:!0}),l=!1,u=!1,d&&i.current?.(null),d=!1},_=()=>{n=!1,l&&_e(`light`,{bypassCadence:!0}),l=!1,u=!1,d&&i.current?.(null),d=!1},v=e=>{f&&(f=!1,p!==null&&(window.clearTimeout(p),p=null),e.preventDefault(),e.stopPropagation())};return t.addEventListener(`touchstart`,m,{passive:!0}),t.addEventListener(`touchmove`,h,{passive:!1}),t.addEventListener(`touchend`,g,{passive:!0}),t.addEventListener(`touchcancel`,_,{passive:!0}),t.addEventListener(`click`,v,!0),()=>{p!==null&&window.clearTimeout(p),t.removeEventListener(`touchstart`,m),t.removeEventListener(`touchmove`,h),t.removeEventListener(`touchend`,g),t.removeEventListener(`touchcancel`,_),t.removeEventListener(`click`,v,!0)}},[e,n])},Gu=.85,Ku=8,qu=.35,Ju=.22,Yu=e=>({segmentStart:e,lastTouch:e,open:!1}),Xu=e=>e*qu,Zu=e=>e*Ju,Qu=(e,t)=>Math.max(0,e-t),$u=(e,t)=>Math.max(0,t-e),ed=(e,t)=>{let n=Math.abs(e);return n<Ku||Math.abs(t)<=n*Gu},td=(e,t,n)=>{let r=t.clientX-e.segmentStart.clientX,i=t.clientY-e.segmentStart.clientY,a=Qu(e.segmentStart.clientX,t.clientX),o=Xu(n),s=Zu(n),c=e.open;return c=a<=0?!1:e.open?a>=s:a>=o&&ed(r,i),{segmentStart:e.segmentStart,lastTouch:t,open:c}},nd=e=>{if(e.disabled||e.startedOnExcludedTarget)return{open:!1,back:!1};let t=e.endX-e.startX,n=e.endY-e.startY,r=Qu(e.startX,e.endX),i=$u(e.startX,e.endX),a=Xu(e.viewportWidth),o=ed(t,n);return{open:r>=a&&o,back:i>=a&&o}},rd=(e,t,n)=>Math.min(Qu(e,t)/Math.max(1,Xu(n)),1),id=(e,t,n)=>Math.min($u(e,t)/Math.max(1,Xu(n)),1),ad=e=>{let t=e;for(;t&&t!==document.body&&t!==document.documentElement;){let e=window.getComputedStyle(t).overflowX;if((e===`auto`||e===`scroll`)&&t.scrollWidth>t.clientWidth)return!0;t=t.parentElement}return!1},od=e=>{let t=document.elementFromPoint(e.clientX,e.clientY);return!!t?.closest(`[data-session-swipe-surface="true"]`)||ad(t)},sd=1,cd=(e,t)=>{if(!e||e.rangeCount===0||e.isCollapsed)return!1;if(!t)return!0;let n=e.anchorNode;if(!n)return!1;let r=n.nodeType===sd?n:n.parentElement;return!!(r&&t.contains(r))},ld=e=>cd(window.getSelection(),e),ud=(e,t,n)=>{let r=Z.useRef(t.onOpen);r.current=t.onOpen;let i=Z.useRef(t.onPreviewStart);i.current=t.onPreviewStart;let a=Z.useRef(t.onPreviewCancel);a.current=t.onPreviewCancel;let o=Z.useRef(t.onProgress);o.current=t.onProgress;let s=Z.useRef(t.onBack);s.current=t.onBack;let c=Z.useRef(t.onBackProgress);c.current=t.onBackProgress;let l=Z.useRef(t.disabled);l.current=t.disabled,Z.useEffect(()=>{let t=e.current;if(!t)return;let n=!1,u=!1,d=null,f=!1,p=!1,m=!1,h=0,g=0,_=null,v=e=>{let t=Xu(g),n=Oe({thresholdReached:p,distance:e,enterDistance:t,cancelDistance:Zu(g),available:!0});p=n.thresholdReached,n.event===`enter`&&(m=_e(`medium`,{bypassCadence:!0})),n.event===`cancel`&&(_e(`light`,{bypassCadence:!0}),m=!1)},y=e=>{o.current?.(null),p&&!e&&_e(`light`,{bypassCadence:!0}),p=!1,m=!1,e?r.current():f&&a.current?.(),f=!1},b=e=>{c.current?.(null),p&&!e&&_e(`light`,{bypassCadence:!0}),p=!1,m=!1,e&&s.current?.()},x=e=>{if(e.touches.length!==1){n=!1,_=null;return}if(l.current){n=!1,_=null;return}let r=e.touches[0];n=!0,g=window.innerWidth,u=od(r)||ld(t),d=null,f=!1,p=!1,m=!1,h=0,_=Yu(r)},S=e=>{if(!n||u||!_)return;if(e.touches.length!==1){d===`sessions`&&y(!1),d===`back`&&b(!1),n=!1,_=null;return}let r=e.touches[0];_=td(_,r,g);let a=r.clientX-_.segmentStart.clientX,l=r.clientY-_.segmentStart.clientY;if(d===null){if(ld(t))return;let e=Math.abs(a);if(e<Ku||Math.abs(l)>e*Gu)return;if(a<0)d=`sessions`,f=!0,i.current?.();else if(s.current)d=`back`;else return}e.preventDefault(),h=d===`sessions`?Qu(_.segmentStart.clientX,r.clientX):$u(_.segmentStart.clientX,r.clientX),v(h),d===`sessions`?o.current?.(rd(_.segmentStart.clientX,r.clientX,g)):c.current?.(id(_.segmentStart.clientX,r.clientX,g))},C=e=>{if(!n||!_)return;if(n=!1,!d){_=null;return}let t=e.changedTouches[0];t&&(_=td(_,t,g),h=d===`sessions`?Qu(_.segmentStart.clientX,t.clientX):$u(_.segmentStart.clientX,t.clientX),v(h));let r=d===`sessions`?_.open:nd({startX:_.segmentStart.clientX,startY:_.segmentStart.clientY,endX:_.lastTouch.clientX,endY:_.lastTouch.clientY,viewportWidth:g,disabled:!1,startedOnExcludedTarget:!1}).back;_=null,e.preventDefault(),r&&!m&&_e(`medium`,{bypassCadence:!0}),d===`sessions`?y(r):b(r)},w=()=>{d===`sessions`&&y(!1),d===`back`&&b(!1),n=!1,_=null};return t.addEventListener(`touchstart`,x,{passive:!0,capture:!0}),t.addEventListener(`touchmove`,S,{passive:!1,capture:!0}),t.addEventListener(`touchend`,C,{passive:!1,capture:!0}),t.addEventListener(`touchcancel`,w,{passive:!0,capture:!0}),()=>{f&&y(!1),d===`back`&&b(!1),t.removeEventListener(`touchstart`,x,!0),t.removeEventListener(`touchmove`,S,!0),t.removeEventListener(`touchend`,C,!0),t.removeEventListener(`touchcancel`,w,!0)}},[e,n])},dd=()=>{if(typeof window>`u`)return!1;let e=window.Capacitor?.getPlatform?.();return e===`ios`||e===`android`},fd=(e,t)=>{f()?.push?.registerApnsToken?.({token:e,platform:A(),locale:t})},pd=e=>{let{enabled:t}=e,n=j(e=>e.nativeNotificationsEnabled),r=K(e=>e.locale),i=Z.useRef(null),a=Z.useRef(r);a.current=r,Z.useEffect(()=>{if(!t||!n||!dd())return;let e=!1,r=[];return L(async()=>{let{PushNotifications:e}=await import(`./vendor-capacitor-push-notifications-DB3-G2vL.js`).then(e=>e.t);return{PushNotifications:e}},__vite__mapDeps([54,1,10])).then(async({PushNotifications:t})=>{if(e)return;let n=await t.checkPermissions().catch(()=>null);if(n?.receive!==`granted`&&(n=await t.requestPermissions().catch(()=>null)),n?.receive!==`granted`)return;let o=await t.addListener(`registration`,e=>{i.current=e.value,fd(e.value,a.current)}),s=await t.addListener(`registrationError`,e=>{console.warn(`[Push] APNs registration error:`,e)});if(await t.register().catch(()=>void 0),e){o.remove(),s.remove();return}r.push(()=>void o.remove(),()=>void s.remove())}).catch(()=>void 0),()=>{e=!0,r.forEach(e=>e())}},[t,n]),Z.useEffect(()=>{if(!t||!n||!dd())return;let e=i.current;e&&fd(e,r)},[t,n,r]),Z.useEffect(()=>{if(n)return;let e=i.current;e&&(i.current=null,f()?.push?.unregisterApnsToken?.({token:e}))},[n])},md=`OpenChamberLiveActivity`,hd=5e3,gd=3600,_d=`live`,vd=F(md),yd=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable;function bd(){return typeof window>`u`?!1:yd({isCapacitor:O(),platform:A(),pluginAvailable:I.isPluginAvailable(md)})}var xd=()=>vd,Sd=new Set([`permission`,`input`,`retry`]),Cd=()=>({trackedSessionId:null,started:!1,startedAt:null,busySince:null,lastStatus:null,eventVersion:0,items:[]}),wd=(e,t)=>Math.max(Math.floor(e),t+1),Td=e=>e.failedEpoch===e.currentEpoch?e.previous:e.current,Ed=e=>e.failedEpoch===e.currentEpoch&&e.retryCount<1,Dd=e=>e.hasSessionError?`error`:e.hasPendingPermissions?`permission`:e.hasPendingQuestions?`input`:e.statusType===`retry`?`retry`:e.statusType===`busy`?`working`:e.statusType===`idle`?`complete`:null,Od=e=>{let t=e.trim();return t.length<=80?t:`${t.slice(0,79)}…`},kd=e=>typeof e.parentID==`string`&&e.parentID.length>0?e.parentID:null,Ad=e=>{if(e.runningIds.size===0)return[];let t=[];for(let n of e.sessions)!e.runningIds.has(n.id)||kd(n)||t.push({sessionId:n.id,title:Od(n.title??``),statusType:e.statuses[n.id]?.type??`busy`});return t},jd=e=>e!==`complete`&&e!==`error`,Md=e=>e.some(e=>e.status===`permission`)?`permission`:e.some(e=>e.status===`input`)?`input`:e.some(e=>e.status===`retry`)?`retry`:e.some(e=>e.status===`tool`)?`tool`:e.some(e=>e.status===`stale`)?`stale`:e.some(e=>e.status===`working`)?`working`:e.some(e=>e.status===`error`)?`error`:`complete`,Nd=e=>{if(e.length<=4)return e;let t=e.filter(e=>jd(e.status)),n=e.filter(e=>!jd(e.status)).sort((e,t)=>(t.endedAt??0)-(e.endedAt??0)),r=[...t];for(let e of n){if(r.length>=4)break;r.push(e)}return r.slice(0,4)},Pd=(e,t,n,r)=>{if(n&&n.length>0)return n;let i=r?.[e];return i&&i.length>0?i:t},Fd=(e,t,n,r,i)=>{let a=new Map;for(let e of t)a.set(e.sessionId,e);let o=[],s=new Set;for(let t of e){if(i&&!i.has(t.sessionId))continue;let e=a.get(t.sessionId);if(e){let i=Dd({statusType:e.statusType,hasPendingPermissions:e.hasPendingPermissions===!0,hasPendingQuestions:e.hasPendingQuestions===!0,hasSessionError:e.hasSessionError===!0})??`working`;o.push({sessionId:t.sessionId,title:Pd(t.sessionId,t.title,e.title,r),status:i,startedAt:t.startedAt,busySince:i===`working`?t.busySince??n:null})}else if(jd(t.status))o.push({...t,title:Pd(t.sessionId,t.title,void 0,r),status:`complete`,endedAt:n,busySince:null});else{let e=Pd(t.sessionId,t.title,void 0,r);o.push(e===t.title?t:{...t,title:e})}s.add(t.sessionId)}for(let e of t){if(s.has(e.sessionId))continue;let t=Dd({statusType:e.statusType,hasPendingPermissions:e.hasPendingPermissions===!0,hasPendingQuestions:e.hasPendingQuestions===!0,hasSessionError:e.hasSessionError===!0})??`working`;o.push({sessionId:e.sessionId,title:e.title,status:t,startedAt:n,busySince:t===`working`?n:null})}return Nd(o)},Id=e=>e.map(e=>`${e.sessionId}\0${e.title}\0${e.status}\0${e.endedAt??``}`).join(`
|
|
15
|
+
`),Ld=e=>e.map(e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:e.startedAt};return e.endedAt!==void 0&&(t.endedAt=e.endedAt),t}),Rd=(e,t,n,r,i)=>{let a=e.filter(e=>jd(e.status)),o=a[0]??e[0],s={sessionId:_d,startedAt:o?.startedAt??r,status:t,eventVersion:n,updatedAt:r,title:o?.title,workingCount:a.length,items:Ld(e)};return i?.endedAt!==void 0&&(s.endedAt=i.endedAt),i?.dismissalSeconds!==void 0&&(s.dismissalSeconds=i.dismissalSeconds),s},zd=e=>{let t={sessionId:e.sessionId,startedAt:e.startedAt,status:e.status,eventVersion:e.eventVersion,updatedAt:e.updatedAt};return e.endedAt!==void 0&&(t.endedAt=e.endedAt),e.dismissalSeconds!==void 0&&(t.dismissalSeconds=e.dismissalSeconds),e.title!==void 0&&(t.title=e.title),e.workingCount!==void 0&&(t.workingCount=e.workingCount),e.items!==void 0&&(t.items=e.items),t},Bd=(e,t,n,r)=>{let i=e.trackedSessionId;if(!i||!e.started)return{state:Cd(),commands:[]};let a=wd(t,e.eventVersion);return{state:Cd(),commands:[{type:`end`,payload:zd({sessionId:i,startedAt:e.startedAt??t,status:n,eventVersion:a,updatedAt:t,endedAt:t,dismissalSeconds:r})}]}},Vd=(e,t,n,r,i)=>{let a=wd(r,i);return{state:{trackedSessionId:e,started:!0,startedAt:n,busySince:null,lastStatus:t,eventVersion:a,items:[]},commands:[{type:`start`,payload:zd({sessionId:e,startedAt:n,status:t,eventVersion:a,updatedAt:r})}]}},Hd=(e,t,n)=>{let r=Dd(t),i=e.busySince;if(r===`working`?i??=t.now:(!e.started&&!r||!e.started&&r===`complete`||!e.started&&r===`error`)&&(i=null),!e.started){if(r===`working`){let r=hd-(t.now-(i??t.now));if(r>0)return{state:{...e,trackedSessionId:n,busySince:i},commands:[{type:`wait`,delayMs:r}]}}else if(!r||!Sd.has(r))return{state:{...Cd(),trackedSessionId:n},commands:[]};return Vd(n,r,i??t.now,t.now,e.eventVersion)}if(r===`complete`)return Bd({...e,busySince:i},t.now,`complete`,900);if(r===`error`)return Bd({...e,busySince:i},t.now,`error`,gd);if(!r||r===e.lastStatus)return{state:{...e,trackedSessionId:n,busySince:i},commands:[]};let a=wd(t.now,e.eventVersion);return{state:{trackedSessionId:n,started:!0,startedAt:e.startedAt??t.now,busySince:r===`working`?i:null,lastStatus:r,eventVersion:a,items:e.items},commands:[{type:`update`,payload:zd({sessionId:n,startedAt:e.startedAt??t.now,status:r,eventVersion:a,updatedAt:t.now})}]}},Ud=(e,t,n)=>{let r=e.trackedSessionId;if(!r||!e.started)return{state:e,commands:[]};let i=wd(n,e.eventVersion);return{state:{...e,busySince:null,lastStatus:t,eventVersion:i},commands:[{type:`update`,payload:zd({sessionId:r,startedAt:e.startedAt??n,status:t,eventVersion:i,updatedAt:n})}]}},Wd=(e,t,n)=>{let r=Fd(e.items,n,t.now,t.sessionTitles,t.rootSessionIds),i=r.filter(e=>jd(e.status)),a=Md(r),o=i.reduce((e,t)=>{let n=t.busySince??t.startedAt;return e===null||n<e?n:e},null);if(!t.connected){let n=e.busySince===null?e:{...e,busySince:null};if(!n.started||n.lastStatus===`stale`)return{state:{...n,items:r},commands:[]};let i=wd(t.now,n.eventVersion),a=r.map(e=>jd(e.status)?{...e,status:`stale`}:e);return{state:{...n,items:a,lastStatus:`stale`,eventVersion:i,busySince:null},commands:[{type:`update`,payload:zd(Rd(a,`stale`,i,t.now))}]}}if(!e.started){if(i.length===0)return{state:Cd(),commands:[]};if(!i.some(e=>Sd.has(e.status))){let n=hd-(t.now-(o??t.now));if(n>0)return{state:{...e,trackedSessionId:_d,items:r,busySince:o},commands:[{type:`wait`,delayMs:n}]}}let n=o??t.now,s=r.map(e=>jd(e.status)?{...e,startedAt:e.busySince??n}:e),c=wd(t.now,e.eventVersion);return{state:{trackedSessionId:_d,started:!0,startedAt:n,busySince:null,lastStatus:a,eventVersion:c,items:s},commands:[{type:`start`,payload:zd(Rd(s,a,c,t.now))}]}}if(i.length===0){let n=r.some(e=>e.status===`error`)?`error`:`complete`,i=wd(t.now,e.eventVersion);return{state:Cd(),commands:[{type:`end`,payload:zd(Rd(r,n,i,t.now,{endedAt:t.now,dismissalSeconds:n===`error`?gd:900}))}]}}if(Id(e.items)===Id(r)&&e.lastStatus===a)return{state:{...e,trackedSessionId:_d,items:r,busySince:null},commands:[]};let s=wd(t.now,e.eventVersion);return{state:{trackedSessionId:_d,started:!0,startedAt:e.startedAt??o??t.now,busySince:null,lastStatus:a,eventVersion:s,items:r},commands:[{type:`update`,payload:zd(Rd(r,a,s,t.now))}]}},Gd=(e,t)=>{if(t.catalog)return Wd(e,t,t.catalog);if(!t.connected){let n=e.busySince===null?e:{...e,busySince:null};return!n.started||n.lastStatus===`stale`||!n.trackedSessionId?{state:n,commands:[]}:Ud(n,`stale`,t.now)}let n=[],r=e;if(r.trackedSessionId&&r.trackedSessionId!==t.sessionId)if(r.started){let e=Bd(r,t.now,r.lastStatus??`complete`,0);n.push(...e.commands),r=e.state}else r=Cd();if(!t.sessionId){if(r.started){let e=Bd(r,t.now,`complete`,900);return{state:e.state,commands:[...n,...e.commands]}}return{state:Cd(),commands:n}}let i=Hd(r,t,t.sessionId);return{state:i.state,commands:[...n,...i.commands]}},Kd=e=>e/1e3,qd=e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:Kd(e.startedAt)};return e.endedAt!==void 0&&(t.endedAt=Kd(e.endedAt)),t},Jd=e=>{let t={sessionId:e.sessionId,startedAt:Kd(e.startedAt),status:e.status,eventVersion:e.eventVersion,updatedAt:Kd(e.updatedAt)};return e.endedAt!==void 0&&(t.endedAt=Kd(e.endedAt)),e.dismissalSeconds!==void 0&&(t.dismissalSeconds=e.dismissalSeconds),e.title!==void 0&&(t.title=e.title),e.workingCount!==void 0&&(t.workingCount=e.workingCount),e.items!==void 0&&(t.items=e.items.map(qd)),t},Yd=e=>{let t={};return e.title!==void 0&&(t.title=e.title),e.workingCount!==void 0&&(t.workingCount=e.workingCount),e.items!==void 0&&(t.items=e.items),t},Xd=(e,t,n)=>{if(!e||n.type===`wait`)return Promise.resolve();let r=Jd(n.payload),i=Yd(r);return n.type===`start`?t.start({sessionId:r.sessionId,startedAt:r.startedAt,status:r.status,eventVersion:r.eventVersion,updatedAt:r.updatedAt,...i}):n.type===`update`?t.update({sessionId:r.sessionId,startedAt:r.startedAt,status:r.status,eventVersion:r.eventVersion,updatedAt:r.updatedAt,...i}):t.end({sessionId:r.sessionId,startedAt:r.startedAt,status:r.status,eventVersion:r.eventVersion,updatedAt:r.updatedAt,endedAt:r.endedAt,dismissalSeconds:r.dismissalSeconds,...i})},Zd=e=>e.getCurrentEpoch()===e.epoch?!e.getCurrentSessionId||e.getCurrentSessionId()===e.observation.sessionId:!1,Qd=async e=>{let t=e.state;if(!Zd(e))return{state:t,delayMs:null,retry:!1,superseded:!0};let n=Gd(t,e.observation),r=n.commands.find(e=>e.type===`wait`),i=r?.type===`wait`?r.delayMs:null,a=n.commands.filter(e=>e.type!==`wait`);if(a.length===0)return Zd(e)?{state:n.state,delayMs:i,retry:!1,superseded:!1}:{state:t,delayMs:null,retry:!1,superseded:!0};let o=t;try{for(let[r,i]of a.entries()){if(!Zd(e)||(await Xd(e.available,e.plugin,i),!Zd(e)))return{state:t,delayMs:null,retry:!1,superseded:!0};let s=r===a.length-1;o=i.type===`end`&&!s?Cd():n.state}return{state:n.state,delayMs:i,retry:!1,superseded:!1}}catch{if(!Zd(e))return{state:t,delayMs:null,retry:!1,superseded:!0};let r=Td({failedEpoch:e.epoch,currentEpoch:e.getCurrentEpoch(),previous:o,current:n.state}),i=Ed({failedEpoch:e.epoch,currentEpoch:e.getCurrentEpoch(),retryCount:e.retryCount});return{state:r,delayMs:i?250:null,retry:i,superseded:!1}}},$d=()=>({desired:null,registered:null}),ef=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null},tf=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=ef(t.activityId),r=ef(t.sessionId),i=ef(t.token);return!n||!r||!i?null:{activityId:n,sessionId:r,token:i}},nf=(e,t)=>e.activityId===t.activityId&&e.token===t.token,rf=(e,t)=>{let n=e.registered?.runtimeIdentity===t?e.registered:null;return e.desired===null&&n===e.registered?e:{desired:null,registered:n}},af=(e,t)=>{if(!t.connected)return[];if(e.desired&&t.enabled&&t.selectedSessionId&&e.desired.sessionId===t.selectedSessionId){let n=e.registered;return n&&nf(n,e.desired)&&n.runtimeIdentity===t.runtimeIdentity?[]:[{type:`register`,payload:{activityId:e.desired.activityId,sessionId:e.desired.sessionId,token:e.desired.token},runtimeIdentity:t.runtimeIdentity}]}return e.registered&&e.registered.runtimeIdentity===t.runtimeIdentity?[{type:`unregister`,payload:{token:e.registered.token},runtimeIdentity:t.runtimeIdentity}]:[]},of=(e,t,n)=>{let r=e;if(n.type===`pushToken`){if(!t.enabled||n.sessionId!==t.selectedSessionId)return{state:e,commands:[]};r={...e,desired:{activityId:n.activityId,sessionId:n.sessionId,token:n.token}}}else n.type===`localEndSucceeded`||n.type===`dispose`||!t.enabled||e.desired&&e.desired.sessionId!==t.selectedSessionId?r=rf(e,t.runtimeIdentity):e.registered&&e.registered.runtimeIdentity!==t.runtimeIdentity&&!e.desired&&(r={...e,registered:null});return{state:r,commands:af(r,t)}},sf=async e=>{try{return await e}catch{return null}},cf=async e=>{let t=e.state;for(let n of e.commands){if(n.runtimeIdentity!==e.getRuntimeIdentity()){n.type===`unregister`&&t.registered?.runtimeIdentity===n.runtimeIdentity&&(t={...t,registered:null});continue}if(n.type===`register`){let r=t.registered;if(n.runtimeIdentity!==e.getRuntimeIdentity()||(await sf(e.register(n.payload)))?.ok!==!0||n.runtimeIdentity!==e.getRuntimeIdentity())continue;if(t={...t,registered:{...n.payload,runtimeIdentity:n.runtimeIdentity}},r&&r.runtimeIdentity===n.runtimeIdentity&&r.token!==n.payload.token){if(n.runtimeIdentity!==e.getRuntimeIdentity())continue;await sf(e.unregister({token:r.token}))}continue}if(n.runtimeIdentity!==e.getRuntimeIdentity()){t.registered?.runtimeIdentity===n.runtimeIdentity&&(t={...t,registered:null});continue}(await sf(e.unregister(n.payload)))?.ok===!0&&t.registered?.token===n.payload.token&&(t={...t,registered:null})}return t},lf=new Map,uf=[];function df(){let e=bd(),t=Ge(e=>e.isConnected),n=ke({enabled:e}),r=me(t=>e?t.statusById:lf),i=Fe(t=>e?t.activeSessions:uf),o=(0,Z.useMemo)(()=>e?wr(n,r):new Set,[e,r,n]),c=(0,Z.useMemo)(()=>e?Ad({runningIds:o,statuses:n,sessions:i}):[],[e,n,o,i]),l=(0,Z.useMemo)(()=>{if(!e)return{};let t={};for(let e of i){let n=e.parentID;if(typeof n==`string`&&n.length>0)continue;let r=typeof e.title==`string`?e.title.trim():``;r&&(t[e.id]=r.length<=80?r:`${r.slice(0,79)}…`)}return t},[e,i]),u=(0,Z.useMemo)(()=>{if(!e)return new Set;let t=new Set;for(let e of i){let n=e.parentID;typeof n==`string`&&n.length>0||t.add(e.id)}return t},[e,i]),d=(0,Z.useMemo)(()=>[c.map(e=>`${e.sessionId}\0${e.title}\0${e.statusType??``}`).join(`
|
|
16
16
|
`),Object.entries(l).map(([e,t])=>`${e}\0${t}`).join(`
|
|
17
17
|
`)].join(`
|
|
18
18
|
---
|
|
19
|
-
`),[c,l]),p=(0,Z.useRef)(xd()),m=(0,Z.useRef)(Zd()),h=(0,Z.useRef)(null),g=(0,Z.useRef)(0),_=(0,Z.useRef)(Promise.resolve()),v=(0,Z.useRef)(Promise.resolve()),y=(0,Z.useRef)(null),b=V(()=>({sessionId:hd,statusType:void 0,hasPendingPermissions:!1,hasPendingQuestions:!1,hasSessionError:!1,now:Date.now(),connected:t,catalog:c,sessionTitles:l,rootSessionIds:u})),x=V(n=>{v.current=v.current.then(async()=>{let r=rf(m.current,{selectedSessionId:hd,runtimeIdentity:s(),connected:t,enabled:e},n);m.current=r.state,r.commands.length!==0&&(m.current=await of({state:m.current,commands:r.commands,getRuntimeIdentity:s,register:e=>f()?.push?.registerLiveActivityToken?.({...e,items:p.current.items.map(e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:Wd(e.startedAt)};return e.endedAt===void 0?t:{...t,endedAt:Wd(e.endedAt)}})})??Promise.resolve(null),unregister:e=>f()?.push?.unregisterLiveActivityToken?.(e)??Promise.resolve(null)}))}).catch(()=>void 0)}),S=V(e=>{let t=$d(e);t&&x({type:`pushToken`,...t,sessionId:hd})});(0,Z.useEffect)(()=>{x({type:e?`sync`:`dispose`})},[e,t]),(0,Z.useEffect)(()=>a(()=>{x({type:`sync`})}),[]),(0,Z.useEffect)(()=>{if(!e){y.current?.remove(),y.current=null;return}let t=!1,n=null,r=0,i=yd(),a=g.current+1;g.current=a;let o=()=>{_.current=_.current.then(async()=>{if(t||g.current!==a)return;if(h.current!==!0){if(h.current===!1)return;let e=await i.isSupported().catch(()=>({supported:!1}));if(t||g.current!==a||(h.current=e.supported===!0,!h.current))return}let e=b(),s=p.current.started,c=await Xd({available:!0,plugin:i,state:p.current,observation:e,epoch:a,getCurrentEpoch:()=>g.current,retryCount:r});if(!(t||g.current!==a||c.superseded)){if(p.current=c.state,s&&!c.state.started)x({type:`localEndSucceeded`});else if(c.state.started){let e=m.current.desired;e&&f()?.push?.registerLiveActivityToken?.({activityId:e.activityId,sessionId:hd,token:e.token,items:c.state.items.map(e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:Wd(e.startedAt)};return e.endedAt===void 0?t:{...t,endedAt:Wd(e.endedAt)}})})}c.retry?r+=1:r=0,c.delayMs!=null&&(n=setTimeout(()=>{o()},c.delayMs))}}).catch(()=>void 0)};return _.current=_.current.then(async()=>{if(!(t||g.current!==a)&&!y.current)try{let e=await i.addListener(`pushToken`,e=>{S(e)});if(t){await e.remove();return}y.current=e}catch{return}}).then(()=>{!t&&g.current===a&&o()}).catch(()=>void 0),()=>{t=!0,g.current===a&&(g.current+=1),n!==null&&clearTimeout(n)}},[e,t,d]),(0,Z.useEffect)(()=>()=>{y.current?.remove(),y.current=null,x({type:`dispose`})},[])}var uf=`mobile-direct-diff`,df=`mobile-turn-diff`,ff=`mobile-direct-file`,pf=`mobile-files`,mf=`mobile-changes`,hf=`mobile-mcp`,gf=`mobile-settings`,_f=`mobile-update`,vf=`mobile-overflow-menu`,yf=320,bf=380,xf=280,Sf=560,Cf=380,wf=e=>Math.min(Sf,Math.max(xf,Math.round(e))),Tf=(e,t)=>{let n=e.current;n&&(n.style.width=`${t}px`,n.style.minWidth=`${t}px`,n.style.maxWidth=`${t}px`,n.style.setProperty(`--oc-ipad-sidebar-width`,`${t}px`))};function Ef(e,t,n){let r=(0,Q.c)(17),i=Z.useRef(null),a;r[0]!==n||r[1]!==t?(a=()=>{if(typeof window>`u`)return n;let e=Number.parseInt(window.localStorage.getItem(t)??``,10);return Number.isFinite(e)?Math.min(Sf,Math.max(xf,e)):n},r[0]=n,r[1]=t,r[2]=a):a=r[2];let[o,s]=Z.useState(a),[c,l]=Z.useState(!1),u=Z.useRef(0),d=Z.useRef(o),f=Z.useRef(null),p=Z.useRef(null),m;r[3]===o?m=r[4]:(m=e=>{try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}p.current=e.pointerId,u.current=e.clientX,d.current=o,f.current=o,l(!0),e.preventDefault()},r[3]=o,r[4]=m);let h=V(m),g;r[5]===e?g=r[6]:(g=t=>{if(p.current!==t.pointerId)return;let n=t.clientX-u.current,r=wf(d.current+(e===`left`?n:-n));f.current!==r&&(f.current=r,Tf(i,r))},r[5]=e,r[6]=g);let _=V(g),v;r[7]===t?v=r[8]:(v=e=>{if(p.current!==e.pointerId)return;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}let n=wf(f.current??d.current);p.current=null,f.current=null,l(!1),s(n);try{window.localStorage.setItem(t,String(n))}catch{}},r[7]=t,r[8]=v);let y=V(v),b;r[9]!==h||r[10]!==y||r[11]!==_?(b={onPointerDown:h,onPointerMove:_,onPointerUp:y,onPointerCancel:y},r[9]=h,r[10]=y,r[11]=_,r[12]=b):b=r[12];let x=b,S;return r[13]!==x||r[14]!==c||r[15]!==o?(S={asideRef:i,width:o,isResizing:c,handleProps:x},r[13]=x,r[14]=c,r[15]=o,r[16]=S):S=r[16],S}var Df=e=>{let t=(0,Q.c)(12),{side:n,isResizing:r,ariaLabel:i,handleProps:a}=e,o=n===`left`?`right-0`:`left-0`,s;t[0]===o?s=t[1]:(s=W(`absolute inset-y-0 z-30 w-6 cursor-col-resize touch-none`,o),t[0]=o,t[1]=s);let c=n===`left`?`right-0`:`left-0`,l=r&&`bg-[var(--interactive-border)]`,u;t[2]!==c||t[3]!==l?(u=W(`absolute inset-y-0 w-[3px] transition-colors`,c,l),t[2]=c,t[3]=l,t[4]=u):u=t[4];let d;t[5]===u?d=t[6]:(d=(0,$.jsx)(`div`,{className:u}),t[5]=u,t[6]=d);let f;return t[7]!==i||t[8]!==a||t[9]!==s||t[10]!==d?(f=(0,$.jsx)(`div`,{className:s,role:`separator`,"aria-orientation":`vertical`,"aria-label":i,...a,children:d}),t[7]=i,t[8]=a,t[9]=s,t[10]=d,t[11]=f):f=t[11],f},Of=()=>typeof window>`u`?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`,kf=()=>{Z.useEffect(()=>{if(!Of())return;document.documentElement.classList.add(`oc-native-app-active`);let e=!1,t=[],n=document.documentElement;n.classList.add(`oc-capacitor-app`),window.Capacitor?.getPlatform?.()===`android`&&n.classList.add(`oc-platform-android`);let r=e=>{n.style.setProperty(`--oc-keyboard-inset`,`${Math.max(0,Math.round(e))}px`)};return L(async()=>{let{StatusBar:e,Style:t}=await import(`./vendor-capacitor-status-bar-DeAGEDuY.js`).then(e=>e.t);return{StatusBar:e,Style:t}},__vite__mapDeps([55,1,10])).then(async({StatusBar:n,Style:r})=>{if(e)return;let i=window.Capacitor?.getPlatform?.(),a=async()=>{if(i===`android`){let e=document.documentElement.classList.contains(`dark`),t=(e?localStorage.getItem(`splashBgDark`):localStorage.getItem(`splashBgLight`))||(e?`#121212`:`#FFFFFF`);await n.setOverlaysWebView({overlay:!1}).catch(()=>void 0),await n.setBackgroundColor({color:t}).catch(()=>void 0),await n.setStyle({style:e?r.Dark:r.Light}).catch(()=>void 0),await n.show().catch(()=>void 0);return}await n.setStyle({style:r.Default}).catch(()=>void 0),await n.setOverlaysWebView({overlay:!0}).catch(()=>void 0),await n.show().catch(()=>void 0)};await a();let o=window.setTimeout(()=>void a(),400);t.push(()=>window.clearTimeout(o));let{App:s}=await L(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([53,1,10])),c=await s.addListener(`appStateChange`,({isActive:e})=>{e&&a()});if(e){c.remove();return}t.push(()=>void c.remove())}).catch(()=>void 0),L(async()=>{let{Keyboard:e}=await import(`./vendor-capacitor-keyboard-BkRQ-Kv-.js`).then(e=>e.t);return{Keyboard:e}},__vite__mapDeps([56,1,10])).then(async({Keyboard:i})=>{if(e)return;let a=window.Capacitor?.getPlatform?.()===`android`;await i.setAccessoryBarVisible({isVisible:!1}).catch(()=>void 0);let o=`cubic-bezier(0.38, 0.7, 0.125, 1)`,s=null,c=null,l=0,u=!1,d=0,f=!1,p=(e,t)=>{n.style.setProperty(e,`${Math.max(0,Math.round(t))}px`)},m=()=>{s!==null&&(window.clearTimeout(s),s=null)},h=(e,t)=>{window.dispatchEvent(new CustomEvent(e,{detail:t}))},g=e=>e.getClientRects().length>0&&getComputedStyle(e).visibility!==`hidden`,_=e=>{for(let t of document.querySelectorAll(e))if(g(t))return t;return null},v=e=>{let t=[],n=e instanceof Element?e:null;if(n&&!Ta(n))return t;let r=n?.closest(`.oc-mobile-composer`)??null,i=r&&g(r)?r:_(`.oc-mobile-composer`);if(i&&t.push({el:i,factor:1}),i){let e=_(`.oc-draft-center`);e&&t.push({el:e,factor:.5})}return t},y=e=>e instanceof HTMLElement&&(e.tagName===`TEXTAREA`||e.tagName===`INPUT`||e.isContentEditable),b=()=>{let e=document.activeElement;return!(y(e)&&!Ta(e))},x=e=>Ta(e),S=()=>{for(let e of document.querySelectorAll(`.oc-mobile-composer, .oc-draft-center`))e.style.transition=``,e.style.transform=``},C=()=>{let e=document.querySelector(`.oc-mobile-app-shell`);d=e&&parseFloat(getComputedStyle(e).paddingBottom)||0};if(a){let i=`openchamber.androidImeHeightRatio.v2`,a=`cubic-bezier(0.2, 0, 0, 1)`,o=`cubic-bezier(0.4, 0, 1, 1)`,s=null,c=!1,l=y,u=e=>Number.isFinite(e)?Math.min(.68,Math.max(.28,e)):.39,m=Math.round(window.innerHeight*(()=>{try{return u(Number.parseFloat(localStorage.getItem(i)??``))}catch{return .39}})()),g=0,_=e=>{if(m=Math.max(0,Math.round(e)),!(m<=0||window.innerHeight<=0))try{localStorage.setItem(i,String(u(m/window.innerHeight)))}catch{}},w=()=>{s!==null&&(window.clearTimeout(s),s=null)},T=e=>Math.max(0,Math.round(e-d)),E=(e,t)=>`translate3d(0, ${-e*t}px, 0)`,D=(e,t,r,i)=>{w();let a=T(e),o=v(i);n.classList.add(`oc-kb-animating`);for(let{el:e,factor:n}of o)e.style.transition=`transform ${t}ms ${r}`,e.style.transform=E(a,n);return s=window.setTimeout(()=>{s=null,n.classList.remove(`oc-kb-animating`);for(let{el:e}of o)e.style.transition=``},t+20),a},O=e=>{C();let t=Math.max(0,Math.round(e));f=!0,c=!1,g=t,n.classList.remove(`oc-keyboard-open`,`oc-kb-animating`),r(t),p(`--oc-kb-layout`,0),p(`--oc-kb-scroll-inset`,T(t)),w(),S(),h(`oc:keyboard-settled`,{open:!0})},k=(e,t=`focus`)=>{if(t===`intent`){if(!b())return}else if(t===`focus`){if(!x(e))return}else if(!f&&!x(document.activeElement))return;if(C(),f){let i=g||m,o=T(i),s=v(t===`focus`?e:void 0);if(s.length===0||(c=!0,n.classList.add(`oc-keyboard-open`),r(0),p(`--oc-kb-scroll-inset`,0),s.every(({el:e,factor:t})=>e.style.transform===E(o,t))))return;D(i,60,a,t===`focus`?e:void 0),h(`oc:keyboard-anim`,{phase:`show`,slide:o,durationMs:60,easing:a}),h(`oc:keyboard-settled`,{open:!0});return}f=!0,c=!0,n.classList.add(`oc-keyboard-open`),r(0),p(`--oc-kb-layout`,0),p(`--oc-kb-scroll-inset`,0),g=m;let i=D(g,200,a,t===`focus`?e:void 0);h(`oc:keyboard-anim`,{phase:`show`,slide:i,durationMs:200,easing:a}),h(`oc:keyboard-settled`,{open:!0})},A=e=>{if(!f){e&&l(document.activeElement)&&Ta(document.activeElement)&&document.activeElement.blur();return}let t=g||m,i=c;f=!1,c=!1,g=0,e&&l(document.activeElement)&&Ta(document.activeElement)&&document.activeElement.blur(),n.classList.remove(`oc-keyboard-open`),r(0),p(`--oc-kb-layout`,0),p(`--oc-kb-scroll-inset`,0),h(`oc:keyboard-intent`,{open:!1});let a=T(t);if(!i){w(),S(),h(`oc:keyboard-settled`,{open:!1});return}D(0,100,o),h(`oc:keyboard-anim`,{phase:`hide`,slide:a,durationMs:100,easing:o}),w(),s=window.setTimeout(()=>{s=null,n.classList.remove(`oc-kb-animating`),S(),h(`oc:keyboard-settled`,{open:!1})},120)},j=e=>{if(l(e.target)){if(Ta(e.target)){k(e.target,`focus`);return}O(g||m)}},M=e=>{if(l(e.target)&&!Da(e.relatedTarget)){if(Ea(e.relatedTarget)){h(`oc:keyboard-intent`,{open:!1}),O(g||m);return}A(!1)}},N=e=>{let t=e,n=t.detail??t;if(n?.open===!0){let e=Aa(n.height??0,window.devicePixelRatio||1),t=Oa(c,document.activeElement);if(e>0&&(t===`open`||t===`cache`)&&_(e),t===`open`&&k(document.activeElement,`ime`),t===`cache`&&ka(g||m,e)){g=e;let t=D(e,60,a,Ta(document.activeElement)?document.activeElement:void 0);h(`oc:keyboard-anim`,{phase:`show`,slide:t,durationMs:60,easing:a})}t===`field`&&O(e||m)}n?.open===!1&&A(!0)},P=e=>{e.detail?.open===!0&&k(void 0,`intent`)};if(document.addEventListener(`focusin`,j,!0),document.addEventListener(`focusout`,M,!0),window.addEventListener(`oc:ime-state`,N),window.addEventListener(`oc:keyboard-intent`,P),e){w(),document.removeEventListener(`focusin`,j,!0),document.removeEventListener(`focusout`,M,!0),window.removeEventListener(`oc:ime-state`,N),window.removeEventListener(`oc:keyboard-intent`,P);return}t.push(w,()=>document.removeEventListener(`focusin`,j,!0),()=>document.removeEventListener(`focusout`,M,!0),()=>window.removeEventListener(`oc:ime-state`,N),()=>window.removeEventListener(`oc:keyboard-intent`,P));return}let w=`openchamber.iosImeHeightRatio.v1`,T=e=>Number.isFinite(e)?Math.min(.68,Math.max(.28,e)):.39,E=()=>{try{let e=T(Number.parseFloat(localStorage.getItem(w)??``));return Math.round(window.innerHeight*e)}catch{return Math.round(window.innerHeight*.39)}},D=e=>{if(!(e<=0||window.innerHeight<=0))try{localStorage.setItem(w,String(T(e/window.innerHeight)))}catch{}},O=e=>{C();let t=Math.max(0,e-d);r(e),p(`--oc-kb-layout`,e),p(`--oc-kb-scroll-inset`,0),u=!0,S(),window.scrollTo(0,0),document.body.scrollTop!==0&&(document.body.scrollTop=0);let n=document.activeElement instanceof Element?document.activeElement.closest(`.oc-mobile-composer`):null;return(n&&g(n)?n:_(`.oc-mobile-composer`))?.scrollIntoView({block:`end`,inline:`nearest`}),t},k=e=>{if(wa(n.classList.contains(`oc-native-ios-composer`),document.activeElement)||e.detail?.open!==!0||u||y(document.activeElement)&&!Ta(document.activeElement))return;f=!0,n.classList.remove(`oc-kb-hide`),n.classList.add(`oc-keyboard-open`);let t=l>0?l:E(),r=O(t);h(`oc:keyboard-anim`,{phase:`show`,slide:r,durationMs:0,easing:o}),h(`oc:keyboard-settled`,{open:!0})};window.addEventListener(`oc:keyboard-intent`,k);let A=await i.addListener(`keyboardWillShow`,e=>{if(wa(n.classList.contains(`oc-native-ios-composer`),document.activeElement))return;m(),l=e.keyboardHeight,D(l);let t=Ta(document.activeElement)||n.classList.contains(`oc-keyboard-open`)&&!y(document.activeElement);if(f=!0,n.classList.remove(`oc-kb-hide`),c!==null&&(window.clearTimeout(c),c=null),!t){r(l),p(`--oc-kb-layout`,0),C(),p(`--oc-kb-scroll-inset`,Math.max(0,l-d)),n.classList.remove(`oc-keyboard-open`,`oc-kb-animating`,`oc-kb-caret-hold`),S(),u=!1,h(`oc:keyboard-settled`,{open:!0});return}n.classList.add(`oc-keyboard-open`);let i=O(l);h(`oc:keyboard-settled`,{open:!0}),h(`oc:keyboard-anim`,{phase:`show`,slide:i,durationMs:0,easing:o})}),j=()=>{let e=document.activeElement;e instanceof HTMLElement&&Ta(e)&&e.blur()},M=()=>{f||(window.scrollTo(0,0),document.body.scrollTop!==0&&(document.body.scrollTop=0))},N=()=>{f=!1,m(),c!==null&&(window.clearTimeout(c),c=null),n.classList.remove(`oc-keyboard-open`,`oc-kb-animating`,`oc-kb-caret-hold`,`oc-kb-hide`),r(0),p(`--oc-kb-scroll-inset`,0),p(`--oc-kb-layout`,0),u=!1,S(),M(),window.setTimeout(M,350)},P=()=>{if(n.classList.contains(`oc-native-ios-composer`)){N(),zn().blur(),h(`oc:keyboard-settled`,{open:!1});return}if(!f)return;f=!1,m(),h(`oc:keyboard-intent`,{open:!1}),j(),window.setTimeout(()=>{f||Ta(document.activeElement)&&(j(),h(`oc:keyboard-intent`,{open:!1}))},80),c!==null&&(window.clearTimeout(c),c=null),n.classList.remove(`oc-kb-caret-hold`,`oc-kb-animating`);let e=Math.max(0,l-d);n.classList.remove(`oc-keyboard-open`),r(0),p(`--oc-kb-scroll-inset`,0),p(`--oc-kb-layout`,0),u=!1,S(),M(),window.setTimeout(M,350),h(`oc:keyboard-anim`,{phase:`hide`,slide:e,durationMs:0,easing:o}),n.classList.add(`oc-kb-animating`,`oc-kb-hide`),s=window.setTimeout(()=>{s=null,n.classList.remove(`oc-kb-animating`,`oc-kb-hide`),h(`oc:keyboard-settled`,{open:!1})},260)},F=await i.addListener(`keyboardWillHide`,P),I=e=>e instanceof HTMLElement&&(e.tagName===`TEXTAREA`||e.tagName===`INPUT`||e.isContentEditable),L=e=>{if(f&&I(e.target)){if(Da(e.relatedTarget)){p(`--oc-kb-scroll-inset`,0);return}window.setTimeout(()=>{if(f&&!Ta(document.activeElement)){if(I(document.activeElement)){m(),n.classList.remove(`oc-keyboard-open`,`oc-kb-animating`,`oc-kb-caret-hold`,`oc-kb-hide`),r(l),p(`--oc-kb-layout`,0),C(),p(`--oc-kb-scroll-inset`,Math.max(0,l-d)),u=!1,S(),h(`oc:keyboard-intent`,{open:!1}),h(`oc:keyboard-settled`,{open:!0});return}P()}},0)}};if(document.addEventListener(`focusout`,L,!0),e){m(),document.removeEventListener(`focusout`,L,!0),window.removeEventListener(`oc:keyboard-intent`,k),A.remove(),F.remove();return}t.push(m,()=>{c!==null&&(window.clearTimeout(c),c=null)},()=>document.removeEventListener(`focusout`,L,!0),()=>window.removeEventListener(`oc:keyboard-intent`,k),()=>void A.remove(),()=>void F.remove())}).catch(()=>void 0),()=>{e=!0,t.forEach(e=>e()),n.classList.remove(`oc-capacitor-app`,`oc-keyboard-open`,`oc-kb-animating`,`oc-kb-hide`,`oc-kb-caret-hold`,`oc-platform-android`),n.style.removeProperty(`--oc-keyboard-inset`),n.style.removeProperty(`--oc-kb-shift`),n.style.removeProperty(`--oc-kb-layout`),n.style.removeProperty(`--oc-kb-scroll-inset`)}},[])},Af=e=>{let t=Z.useRef(!1);Z.useEffect(()=>{if(!Of())return;let n=!1,r=[],i=()=>{t.current&&(t.current=!1,e())},a=()=>{if(document.visibilityState===`hidden`){t.current=!0;return}i()};return document.addEventListener(`visibilitychange`,a),r.push(()=>document.removeEventListener(`visibilitychange`,a)),L(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([53,1,10])).then(async({App:e})=>{if(n)return;let a=await e.getState().catch(()=>null);if(n)return;a&&document.documentElement.classList.toggle(`oc-native-app-active`,a.isActive);let o=await e.addListener(`appStateChange`,({isActive:e})=>{if(document.documentElement.classList.toggle(`oc-native-app-active`,e),!e){t.current=!0;return}i()}),s=await e.addListener(`resume`,i);if(n){o.remove(),s.remove();return}r.push(()=>void o.remove(),()=>void s.remove())}).catch(()=>void 0),()=>{n=!0,r.forEach(e=>e()),document.documentElement.classList.remove(`oc-native-app-active`)}},[e])},jf=e=>{Z.useEffect(()=>{if(!Of())return;let t=!1,n=null;return L(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([53,1,10])).then(async({App:r})=>{if(t)return;let i=await r.addListener(`backButton`,()=>{e()||r.minimizeApp().catch(()=>void 0)});if(t){i.remove();return}n=()=>void i.remove()}).catch(()=>void 0),()=>{t=!0,n?.()}},[e])},Mf=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Nf={autoComplete:`off`,autoCorrect:`off`,spellCheck:!1},Pf=1e3,Ff=e=>{let t=Mf(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},If=(e,t)=>Ff(e?e.path:t),Lf=`h-12 w-full rounded-[16px] border border-border/70 bg-surface-elevated px-4 text-center text-[16px] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-primary focus:ring-2 focus:ring-primary/20`,Rf=({connection:e})=>{let{t}=ee(),n=e,{connections:r,isBusy:i,isPasswordBusy:a,error:o,pendingConnection:s}=n,[c,l]=Z.useState(``),[u,d]=Z.useState(``),[f,p]=Z.useState(``),[m,h]=Z.useState(!1),g=Z.useMemo(()=>$l(),[]),[_,v]=Z.useState(()=>!$l()),[y,b]=Z.useState(null),[x,S]=Z.useState(``),C=V(e=>{e.preventDefault(),n.connect({url:c,clientToken:f,label:u})}),w=V(e=>{n.redeemPairingConnection(e)}),T=V(()=>{n.setError(t(`mobile.connect.link.invalid`))}),E=V(async()=>{if(!(m||i)){n.setError(null),h(!0);try{let e=await eu();switch(e.status){case`ok`:l(e.url),e.label&&d(e.label),e.clientToken&&p(e.clientToken),await n.connect({url:e.url,clientToken:e.clientToken,label:e.label});break;case`pairing`:await n.redeemPairingConnection(e.pairing);break;case`permission-denied`:n.setError(t(`mobile.connect.scan.permissionDenied`));break;case`invalid`:n.setError(t(`mobile.connect.scan.invalid`));break;case`unsupported`:n.setError(t(`mobile.connect.scan.unsupported`));break;case`failed`:n.setError(t(`mobile.connect.scan.failed`))}}finally{h(!1)}}}),D=V(e=>{e.preventDefault(),n.submitPassword(x)}),O=V(()=>{S(``),n.cancelPassword()});return(0,$.jsx)(`main`,{className:`oc-keyboard-fill-screen flex min-h-dvh flex-col overflow-y-auto bg-background px-6 pb-[calc(var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))+28px)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+28px)] text-foreground`,children:(0,$.jsxs)(`div`,{className:`m-auto flex w-full max-w-[360px] shrink-0 flex-col items-center gap-9 py-8`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-5 text-center`,children:[(0,$.jsx)(rn,{width:72,height:72,className:`size-[72px]`}),(0,$.jsx)(`h1`,{className:`typography-h2 text-foreground`,children:t(`mobile.connect.welcome.title`)})]}),s?(0,$.jsxs)(`form`,{className:`flex w-full flex-col gap-3`,onSubmit:D,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3`,children:[(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground`,children:(0,$.jsx)(X,{name:`lock`,className:`size-[18px]`})}),(0,$.jsxs)(`div`,{className:`min-w-0 text-left`,children:[(0,$.jsx)(`p`,{className:`truncate typography-ui-label text-foreground`,children:s.label}),(0,$.jsx)(`p`,{className:`truncate typography-small text-muted-foreground`,children:s.candidates.some(e=>e.kind===`direct`)?ne(s):t(`mobile.connect.relay.badge`)})]})]}),(0,$.jsx)(`input`,{...Nf,value:x,onChange:e=>S(e.target.value),placeholder:t(`mobile.connect.password.placeholder`),"aria-label":t(`mobile.connect.password.label`),type:`password`,autoFocus:!0,className:`h-12 w-full rounded-[16px] border border-border/70 bg-surface-elevated px-4 text-[16px] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-primary focus:ring-2 focus:ring-primary/20`}),o?(0,$.jsx)(`p`,{className:`px-1 text-center typography-small text-[var(--status-error)]`,children:o}):null,(0,$.jsx)(G,{type:`submit`,size:`lg`,className:`mt-1 h-12 w-full`,disabled:a||!x.trim(),children:t(a?`mobile.connect.connecting`:`mobile.connect.unlockButton`)}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,className:`w-full`,onClick:O,children:t(`mobile.connect.cancelPassword`)})]}):(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-6`,children:[g?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,children:[(0,$.jsxs)(G,{type:`button`,size:`lg`,className:`h-12 w-full`,onClick:()=>void E(),disabled:m||i,children:[(0,$.jsx)(X,{name:`scan-2`,className:W(`size-[18px]`,m&&`animate-pulse`)}),t(i?`mobile.connect.connecting`:`mobile.connect.scanQr`)]}),(0,$.jsx)(`p`,{className:`px-2 text-center typography-small text-muted-foreground`,children:t(`mobile.connect.welcome.scanHint`)})]}):null,o&&!_?(0,$.jsx)(`p`,{className:`px-1 text-center typography-small text-[var(--status-error)]`,children:o}):null,r.length>0?(0,$.jsxs)(`section`,{className:`flex w-full flex-col gap-2.5`,children:[(0,$.jsx)(`h2`,{className:`text-center typography-micro uppercase tracking-[0.14em] text-muted-foreground`,children:t(`mobile.connect.saved.title`)}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated`,children:r.map(e=>{let r=y===e.id;return(0,$.jsxs)(`button`,{type:`button`,disabled:i,className:`flex min-h-14 w-full items-center gap-3 border-b border-border/60 px-3.5 py-2.5 text-left last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:opacity-70`,onClick:()=>{b(e.id),n.connect({id:e.id,candidates:e.candidates,clientToken:e.clientToken,label:e.label}).finally(()=>b(null))},children:[(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground`,children:(0,$.jsx)(X,{name:`server`,className:`size-[18px]`})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:e.label}),(0,$.jsx)(`span`,{className:W(`block truncate typography-small`,r?`text-foreground`:`text-muted-foreground`),children:t(r?`mobile.connect.connecting`:`mobile.instances.status.saved`)})]}),r?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-5 text-muted-foreground`})]},e.id)})})]}):null,(0,$.jsxs)(`div`,{className:`flex w-full flex-col`,children:[g?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>v(e=>!e),"aria-expanded":_,className:`mx-auto flex items-center gap-1 rounded-full px-2 py-1 typography-small text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:[(0,$.jsx)(`span`,{children:t(`mobile.connect.manual.toggle`)}),(0,$.jsx)(X,{name:`arrow-down-s`,className:W(`size-4 transition-transform duration-200`,_&&`rotate-180`)})]}):null,(0,$.jsx)(`div`,{className:`grid transition-[grid-template-rows] duration-200 ease-out`,style:{gridTemplateRows:_?`1fr`:`0fr`},children:(0,$.jsxs)(`div`,{className:`min-h-0 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`pt-3`,children:(0,$.jsx)(nu,{disabled:i||m,isBusy:i,tabIndex:_?void 0:-1,inputClassName:Lf,buttonVariant:g?`outline`:`default`,onRedeem:w,onInvalid:T})}),(0,$.jsx)(ru,{label:t(`mobile.connect.address.divider`)}),(0,$.jsxs)(`form`,{className:`flex w-full flex-col gap-3`,onSubmit:C,children:[(0,$.jsx)(`input`,{...Nf,value:c,onChange:e=>l(e.target.value),placeholder:t(`mobile.connect.url.placeholder`),"aria-label":t(`mobile.connect.url.label`),type:`url`,inputMode:`url`,autoCapitalize:`none`,tabIndex:_?void 0:-1,className:Lf}),(0,$.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),placeholder:t(`mobile.instances.label.placeholder`),"aria-label":t(`mobile.instances.label.label`),autoComplete:`off`,autoCapitalize:`words`,autoCorrect:`off`,spellCheck:!1,tabIndex:_?void 0:-1,className:Lf}),(0,$.jsx)(`input`,{...Nf,value:f,onChange:e=>p(e.target.value),placeholder:t(`mobile.connect.token.placeholder`),"aria-label":t(`mobile.connect.token.label`),tabIndex:_?void 0:-1,autoCapitalize:`none`,className:Lf}),(0,$.jsx)(`p`,{className:`px-1 text-center typography-micro text-muted-foreground`,children:t(`mobile.connect.token.hint`)}),(0,$.jsx)(G,{type:`submit`,variant:`outline`,size:`lg`,className:`h-12 w-full`,disabled:i||m||!c.trim(),children:t(i?`mobile.connect.connecting`:`mobile.connect.connectButton`)})]}),o?(0,$.jsx)(`p`,{className:`px-1 pt-3 text-center typography-small text-[var(--status-error)]`,children:o}):null]})})]})]})]})})},zf=({connection:e,onActiveConnectionDeleted:t,onConnect:n})=>{let{t:r}=ee(),i=e,{connections:a,isBusy:o,isPasswordBusy:s,error:c,pendingConnection:l,connect:u,submitPassword:d,cancelPassword:f,saveConnection:p,removeConnection:m,subscribeConnected:h,setError:g}=i,[_,v]=Z.useState(null),y=_?a.find(e=>e.id===_)??null:null,b=y?!y.candidates.some(e=>e.kind===`direct`):!1,[x,S]=Z.useState(null),[C,w]=Z.useState(``),[T,E]=Z.useState(``),[D,O]=Z.useState(``),[k,A]=Z.useState(``),[j,M]=Z.useState(!1),N=Z.useMemo(()=>$l(),[]),[P,F]=Z.useState(!1),[I,L]=Z.useState(null),R=V(n);Z.useEffect(()=>h(R),[R,h]);let z=V(()=>{v(null),w(``),E(``),O(``),g(null),F(!1)}),B=V(e=>{e.preventDefault(),p({id:_??void 0,url:C,label:T,clientToken:D}).then(e=>{e&&z()})}),H=V(e=>{i.redeemPairingConnection(e)}),U=V(()=>{g(r(`mobile.connect.link.invalid`))}),K=V(async()=>{if(!j){g(null),M(!0);try{let e=await eu();switch(e.status){case`ok`:w(e.url),e.label&&E(e.label),e.clientToken&&O(e.clientToken),F(!0);break;case`pairing`:await i.redeemPairingConnection(e.pairing);break;case`permission-denied`:g(r(`mobile.connect.scan.permissionDenied`));break;case`invalid`:g(r(`mobile.connect.scan.invalid`));break;case`unsupported`:g(r(`mobile.connect.scan.unsupported`));break;case`failed`:g(r(`mobile.connect.scan.failed`))}}finally{M(!1)}}}),te=V(e=>{e.preventDefault(),d(k)}),q=V(()=>{A(``),f()}),re=V(e=>{S(t=>t===e?null:e)}),ie=V(e=>{S(null),_===e&&z();let n=a.length===1;m(e).then(e=>{e&&(n||ce(e))&&t()})}),ae=`h-12 w-full rounded-[16px] border border-border/70 bg-surface-elevated px-4 text-[16px] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-primary focus:ring-2 focus:ring-primary/20`;return l?(0,$.jsx)(`div`,{className:`oc-settings-page-content`,children:(0,$.jsx)(gr,{label:r(`mobile.connect.password.label`),itemId:`instances.manage`,children:(0,$.jsxs)(`form`,{className:`oc-settings-group-row flex flex-col gap-3`,onSubmit:te,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3`,children:[(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground`,children:(0,$.jsx)(X,{name:`lock`,className:`size-[18px]`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`truncate typography-ui-label text-foreground`,children:l.label}),(0,$.jsx)(`p`,{className:`truncate typography-small text-muted-foreground`,children:l.candidates.some(e=>e.kind===`direct`)?ne(l):r(`mobile.connect.relay.badge`)})]})]}),(0,$.jsx)(`input`,{...Nf,value:k,onChange:e=>A(e.target.value),placeholder:r(`mobile.connect.password.placeholder`),"aria-label":r(`mobile.connect.password.label`),type:`password`,autoFocus:!0,className:ae}),c?(0,$.jsx)(`p`,{className:`px-1 typography-small text-[var(--status-error)]`,children:c}):null,(0,$.jsx)(G,{type:`submit`,size:`lg`,className:`mt-1 h-12 w-full`,disabled:s||!k.trim(),children:r(s?`mobile.connect.connecting`:`mobile.connect.unlockButton`)}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,className:`w-full`,onClick:q,children:r(`mobile.connect.cancelPassword`)})]})})}):(0,$.jsxs)(`div`,{className:`oc-settings-page-content`,children:[(0,$.jsx)(gr,{label:r(`mobile.connect.saved.title`),itemId:`instances.manage`,children:a.length>0?a.map(e=>{let t=x===e.id,n=ce(e),i=I===e.id,a=r(i?`mobile.connect.connecting`:n?`mobile.instances.status.connected`:`mobile.instances.status.saved`);return(0,$.jsxs)(`div`,{className:W(`oc-settings-group-row relative flex items-center`,t&&`bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]`),children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":r(`desktopHostSwitcher.actions.switchToAria`,{instance:e.label}),"data-mobile-press-feedback":`none`,className:`absolute inset-0 z-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:pointer-events-none`,onClick:()=>{n||(L(e.id),u({id:e.id,candidates:e.candidates,clientToken:e.clientToken,label:e.label}).finally(()=>L(null)))},disabled:n||o&&!i||t,style:{touchAction:`manipulation`}}),(0,$.jsxs)(`div`,{className:`pointer-events-none relative z-[1] flex min-w-0 flex-1 items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`relative flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground`,children:(0,$.jsx)(X,{name:`server`,className:`size-[18px]`})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:e.label})}),(0,$.jsx)(`span`,{className:W(`block truncate typography-small`,n&&!i?`text-[var(--status-success)]`:`text-muted-foreground`),children:a})]})]}),(0,$.jsxs)(`div`,{className:`relative z-10 flex shrink-0 items-center gap-0.5 pr-2`,children:[t?(0,$.jsxs)(`button`,{type:`button`,"aria-label":r(`mobile.instances.confirmDeleteAria`,{label:e.label}),className:`flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-destructive px-3 text-destructive-foreground transition-opacity active:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive`,onClick:()=>ie(e.id),style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`typography-ui-label`,children:r(`mobile.instances.delete`)})]}):i?(0,$.jsx)(`span`,{className:`flex size-9 items-center justify-center text-muted-foreground`,"aria-hidden":!0,children:(0,$.jsx)(X,{name:`loader-4`,className:`size-[18px] animate-spin`})}):(0,$.jsx)(`button`,{type:`button`,"aria-label":r(`mobile.instances.edit`),className:`flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:()=>{v(e.id),w(e.candidates.some(e=>e.kind===`direct`)?ne(e):``),E(e.label),O(e.clientToken||``),g(null)},style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`edit`,className:`size-[18px]`})}),(0,$.jsx)(`button`,{type:`button`,"aria-label":r(t?`mobile.instances.cancelDeleteAria`:`mobile.instances.deleteAria`,{label:e.label}),className:`flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:()=>re(e.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:t?`close`:`delete-bin`,className:`size-[18px]`})})]})]},e.id)}):(0,$.jsx)(`div`,{className:`oc-settings-group-row flex items-center justify-center text-center typography-small text-muted-foreground`,children:r(`mobile.connect.saved.empty`)})}),(0,$.jsx)(gr,{label:r(y?`mobile.instances.editTitle`:`mobile.instances.addTitle`),children:!P&&!y?(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex flex-col items-stretch gap-2`,children:[N?(0,$.jsxs)(G,{type:`button`,size:`lg`,className:`h-12 w-full`,onClick:()=>void K(),disabled:j,children:[(0,$.jsx)(X,{name:`scan-2`,className:W(`size-[18px]`,j&&`animate-pulse`)}),r(`mobile.connect.scanQr`)]}):null,(0,$.jsxs)(G,{type:`button`,variant:N?`ghost`:`outline`,size:`lg`,className:`h-12 w-full`,onClick:()=>{g(null),F(!0)},children:[(0,$.jsx)(X,{name:`add`,className:`size-[18px]`}),r(`mobile.instances.addManual`)]}),c?(0,$.jsx)(`p`,{className:`px-1 text-center typography-small text-[var(--status-error)]`,children:c}):null]}):(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex flex-col gap-3`,children:[(0,$.jsx)(`div`,{className:`flex min-h-8 items-center justify-end px-1`,children:(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`xs`,onClick:z,children:r(`mobile.instances.cancelEdit`)})}),(0,$.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:B,children:[b?null:(0,$.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,$.jsx)(`span`,{className:`block px-1 typography-ui-label text-foreground`,children:r(`mobile.connect.url.label`)}),(0,$.jsx)(`input`,{...Nf,value:C,onChange:e=>w(e.target.value),placeholder:r(`mobile.connect.url.placeholder`),type:`url`,inputMode:`url`,autoCapitalize:`none`,className:ae})]}),(0,$.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,$.jsx)(`span`,{className:`block px-1 typography-ui-label text-foreground`,children:r(`mobile.instances.label.label`)}),(0,$.jsx)(`input`,{value:T,onChange:e=>E(e.target.value),placeholder:r(`mobile.instances.label.placeholder`),autoComplete:`off`,autoCapitalize:`words`,autoCorrect:`off`,spellCheck:!1,className:ae})]}),(0,$.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,$.jsx)(`span`,{className:`block px-1 typography-ui-label text-foreground`,children:r(`mobile.connect.token.label`)}),(0,$.jsx)(`input`,{...Nf,value:D,onChange:e=>O(e.target.value),placeholder:r(`mobile.connect.token.placeholder`),autoCapitalize:`none`,className:ae}),(0,$.jsx)(`p`,{className:`px-1 typography-micro text-muted-foreground`,children:r(`mobile.connect.token.hint`)})]}),(0,$.jsx)(G,{type:`submit`,size:`lg`,className:`mt-1 h-12 w-full`,children:r(y?`mobile.instances.saveEdit`:`mobile.instances.saveNew`)})]}),y?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ru,{label:r(`mobile.connect.link.divider`)}),(0,$.jsx)(nu,{disabled:o||j,isBusy:o,inputClassName:ae,onRedeem:H,onInvalid:U})]}),c?(0,$.jsx)(`p`,{className:`px-1 typography-small text-[var(--status-error)]`,children:c}):null]})})]})},Bf=e=>{let t=e.usedPercent;return typeof t!=`number`||!Number.isFinite(t)?`text-foreground`:t>=80?`text-[var(--status-error)]`:t>=50?`text-[var(--status-warning)]`:`text-foreground`},Vf=e=>{let t=(0,Q.c)(13),{icon:n,iconNode:r,label:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=r??(n?(0,$.jsx)(X,{name:n,className:`size-[18px]`}):null),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]===o?s=t[4]:(s=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:o}),t[3]=o,t[4]=s);let c;t[5]===i?c=t[6]:(c=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:i}),t[5]=i,t[6]=c);let l;t[7]===a?l=t[8]:(l=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground`,children:a}),t[7]=a,t[8]=l);let u;return t[9]!==s||t[10]!==c||t[11]!==l?(u=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5`,children:[s,c,l]}),t[9]=s,t[10]=c,t[11]=l,t[12]=u):u=t[12],u},Hf=e=>{let t=(0,Q.c)(55),{open:n,onClose:r,anchorRef:i,contextDisplay:a,branchLabel:o,usageGroups:s,usageDisplayMode:c,isUsageLoading:l,timeFormatPreference:u}=e,{t:d}=ee(),f=Z.useRef(null),[p,m]=Z.useState(n),[h,g]=Z.useState(!1),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=k(),t[0]=_):_=t[0];let v=_,y=Z.useRef(null),[b,x]=Z.useState(null),S,C;t[1]!==i||t[2]!==n||t[3]!==p?(S=()=>{if(!n||!v||!p)return;let e=()=>{let e=i.current?.getBoundingClientRect(),t=y.current?.getBoundingClientRect();if(!e||!t){x(null);return}let n=e.left-t.left,r=Math.min(Math.max(n,8),Math.max(8,t.width-Cf-8));x(r)};e();let t=y.current;if(typeof ResizeObserver>`u`||!t)return;let r=new ResizeObserver(e);return r.observe(t),()=>r.disconnect()},C=[i,v,n,p],t[1]=i,t[2]=n,t[3]=p,t[4]=S,t[5]=C):(S=t[4],C=t[5]),Z.useLayoutEffect(S,C);let w=v&&b!==null,T,E;t[6]!==n||t[7]!==p?(T=()=>{if(n){m(!0),g(!1);return}if(!p)return;g(!0);let e=window.setTimeout(()=>{m(!1),g(!1)},140);return()=>window.clearTimeout(e)},E=[n,p],t[6]=n,t[7]=p,t[8]=T,t[9]=E):(T=t[8],E=t[9]),Z.useEffect(T,E);let D,O;t[10]!==r||t[11]!==n?(D=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},O=[r,n],t[10]=r,t[11]=n,t[12]=D,t[13]=O):(D=t[12],O=t[13]),Z.useEffect(D,O);let A,j;if(t[14]!==i||t[15]!==r||t[16]!==n?(A=()=>{if(!n)return;let e=e=>{let t=e.target;if(!(t instanceof Node)){r();return}f.current?.contains(t)||i.current?.contains(t)||r()};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`wheel`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`wheel`,e,!0)}},j=[i,r,n],t[14]=i,t[15]=r,t[16]=n,t[17]=A,t[18]=j):(A=t[17],j=t[18]),Z.useEffect(A,j),!p)return null;let M;t[19]===d?M=t[20]:(M=d(`mobile.header.openMetadataAria`),t[19]=d,t[20]=M);let N=w?`absolute origin-top-left`:`mx-3 mt-2`,P=h?`pointer-events-none`:`pointer-events-auto`,F;t[21]!==N||t[22]!==P?(F=W(`overflow-y-auto overscroll-contain rounded-[20px] oc-mobile-overlay-surface p-2 will-change-transform`,N,P),t[21]=N,t[22]=P,t[23]=F):F=t[23];let I=`${h?`session-metadata-out`:`session-metadata-in`} ${h?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,L;t[24]!==b||t[25]!==w?(L=w?{top:8,left:b??8,width:`min(${Cf}px, calc(100% - 16px))`}:null,t[24]=b,t[25]=w,t[26]=L):L=t[26];let R;t[27]!==I||t[28]!==L?(R={animation:I,maxHeight:`min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))`,...L},t[27]=I,t[28]=L,t[29]=R):R=t[29];let z;t[30]===d?z=t[31]:(z=d(`mobile.header.metadata.branch`),t[30]=d,t[31]=z);let B;t[32]!==o||t[33]!==z?(B=(0,$.jsx)(Vf,{icon:`git-branch`,label:z,children:o}),t[32]=o,t[33]=z,t[34]=B):B=t[34];let V;t[35]!==a||t[36]!==d?(V=a?(0,$.jsx)(Vf,{iconNode:(0,$.jsx)(Jc,{percentage:a.percentage}),label:d(`mobile.header.metadata.context`),children:(0,$.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5 tabular-nums`,children:[(0,$.jsxs)(`span`,{className:W(`font-semibold`,a.colorClass),children:[a.percentage.toFixed(1),`%`]}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:a.tokens})]})}):null,t[35]=a,t[36]=d,t[37]=V):V=t[37];let H;t[38]!==l||t[39]!==u||t[40]!==c||t[41]!==s?(H=(0,$.jsx)(Uf,{groups:s,displayMode:c,isLoading:l,timeFormatPreference:u}),t[38]=l,t[39]=u,t[40]=c,t[41]=s,t[42]=H):H=t[42];let U;t[43]!==B||t[44]!==V||t[45]!==H?(U=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[B,V,H]}),t[43]=B,t[44]=V,t[45]=H,t[46]=U):U=t[46];let G;t[47]!==M||t[48]!==F||t[49]!==R||t[50]!==U?(G=(0,$.jsx)(`div`,{ref:f,role:`dialog`,"aria-label":M,className:F,style:R,children:U}),t[47]=M,t[48]=F,t[49]=R,t[50]=U,t[51]=G):G=t[51];let K;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,$.jsx)(`style`,{children:`
|
|
19
|
+
`),[c,l]),p=(0,Z.useRef)(Cd()),m=(0,Z.useRef)($d()),h=(0,Z.useRef)(null),g=(0,Z.useRef)(0),_=(0,Z.useRef)(Promise.resolve()),v=(0,Z.useRef)(Promise.resolve()),y=(0,Z.useRef)(null),b=V(()=>({sessionId:_d,statusType:void 0,hasPendingPermissions:!1,hasPendingQuestions:!1,hasSessionError:!1,now:Date.now(),connected:t,catalog:c,sessionTitles:l,rootSessionIds:u})),x=V(n=>{v.current=v.current.then(async()=>{let r=of(m.current,{selectedSessionId:_d,runtimeIdentity:s(),connected:t,enabled:e},n);m.current=r.state,r.commands.length!==0&&(m.current=await cf({state:m.current,commands:r.commands,getRuntimeIdentity:s,register:e=>f()?.push?.registerLiveActivityToken?.({...e,items:p.current.items.map(e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:Kd(e.startedAt)};return e.endedAt===void 0?t:{...t,endedAt:Kd(e.endedAt)}})})??Promise.resolve(null),unregister:e=>f()?.push?.unregisterLiveActivityToken?.(e)??Promise.resolve(null)}))}).catch(()=>void 0)}),S=V(e=>{let t=tf(e);t&&x({type:`pushToken`,...t,sessionId:_d})});(0,Z.useEffect)(()=>{x({type:e?`sync`:`dispose`})},[e,t]),(0,Z.useEffect)(()=>a(()=>{x({type:`sync`})}),[]),(0,Z.useEffect)(()=>{if(!e){y.current?.remove(),y.current=null;return}let t=!1,n=null,r=0,i=xd(),a=g.current+1;g.current=a;let o=()=>{_.current=_.current.then(async()=>{if(t||g.current!==a)return;if(h.current!==!0){if(h.current===!1)return;let e=await i.isSupported().catch(()=>({supported:!1}));if(t||g.current!==a||(h.current=e.supported===!0,!h.current))return}let e=b(),s=p.current.started,c=await Qd({available:!0,plugin:i,state:p.current,observation:e,epoch:a,getCurrentEpoch:()=>g.current,retryCount:r});if(!(t||g.current!==a||c.superseded)){if(p.current=c.state,s&&!c.state.started)x({type:`localEndSucceeded`});else if(c.state.started){let e=m.current.desired;e&&f()?.push?.registerLiveActivityToken?.({activityId:e.activityId,sessionId:_d,token:e.token,items:c.state.items.map(e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:Kd(e.startedAt)};return e.endedAt===void 0?t:{...t,endedAt:Kd(e.endedAt)}})})}c.retry?r+=1:r=0,c.delayMs!=null&&(n=setTimeout(()=>{o()},c.delayMs))}}).catch(()=>void 0)};return _.current=_.current.then(async()=>{if(!(t||g.current!==a)&&!y.current)try{let e=await i.addListener(`pushToken`,e=>{S(e)});if(t){await e.remove();return}y.current=e}catch{return}}).then(()=>{!t&&g.current===a&&o()}).catch(()=>void 0),()=>{t=!0,g.current===a&&(g.current+=1),n!==null&&clearTimeout(n)}},[e,t,d]),(0,Z.useEffect)(()=>()=>{y.current?.remove(),y.current=null,x({type:`dispose`})},[])}var ff=`mobile-direct-diff`,pf=`mobile-turn-diff`,mf=`mobile-direct-file`,hf=`mobile-files`,gf=`mobile-changes`,_f=`mobile-mcp`,vf=`mobile-settings`,yf=`mobile-update`,bf=`mobile-overflow-menu`,xf=320,Sf=380,Cf=280,wf=560,Tf=380,Ef=e=>Math.min(wf,Math.max(Cf,Math.round(e))),Df=(e,t)=>{let n=e.current;n&&(n.style.width=`${t}px`,n.style.minWidth=`${t}px`,n.style.maxWidth=`${t}px`,n.style.setProperty(`--oc-ipad-sidebar-width`,`${t}px`))};function Of(e,t,n){let r=(0,Q.c)(17),i=Z.useRef(null),a;r[0]!==n||r[1]!==t?(a=()=>{if(typeof window>`u`)return n;let e=Number.parseInt(window.localStorage.getItem(t)??``,10);return Number.isFinite(e)?Math.min(wf,Math.max(Cf,e)):n},r[0]=n,r[1]=t,r[2]=a):a=r[2];let[o,s]=Z.useState(a),[c,l]=Z.useState(!1),u=Z.useRef(0),d=Z.useRef(o),f=Z.useRef(null),p=Z.useRef(null),m;r[3]===o?m=r[4]:(m=e=>{try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}p.current=e.pointerId,u.current=e.clientX,d.current=o,f.current=o,l(!0),e.preventDefault()},r[3]=o,r[4]=m);let h=V(m),g;r[5]===e?g=r[6]:(g=t=>{if(p.current!==t.pointerId)return;let n=t.clientX-u.current,r=Ef(d.current+(e===`left`?n:-n));f.current!==r&&(f.current=r,Df(i,r))},r[5]=e,r[6]=g);let _=V(g),v;r[7]===t?v=r[8]:(v=e=>{if(p.current!==e.pointerId)return;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}let n=Ef(f.current??d.current);p.current=null,f.current=null,l(!1),s(n);try{window.localStorage.setItem(t,String(n))}catch{}},r[7]=t,r[8]=v);let y=V(v),b;r[9]!==h||r[10]!==y||r[11]!==_?(b={onPointerDown:h,onPointerMove:_,onPointerUp:y,onPointerCancel:y},r[9]=h,r[10]=y,r[11]=_,r[12]=b):b=r[12];let x=b,S;return r[13]!==x||r[14]!==c||r[15]!==o?(S={asideRef:i,width:o,isResizing:c,handleProps:x},r[13]=x,r[14]=c,r[15]=o,r[16]=S):S=r[16],S}var kf=e=>{let t=(0,Q.c)(12),{side:n,isResizing:r,ariaLabel:i,handleProps:a}=e,o=n===`left`?`right-0`:`left-0`,s;t[0]===o?s=t[1]:(s=W(`absolute inset-y-0 z-30 w-6 cursor-col-resize touch-none`,o),t[0]=o,t[1]=s);let c=n===`left`?`right-0`:`left-0`,l=r&&`bg-[var(--interactive-border)]`,u;t[2]!==c||t[3]!==l?(u=W(`absolute inset-y-0 w-[3px] transition-colors`,c,l),t[2]=c,t[3]=l,t[4]=u):u=t[4];let d;t[5]===u?d=t[6]:(d=(0,$.jsx)(`div`,{className:u}),t[5]=u,t[6]=d);let f;return t[7]!==i||t[8]!==a||t[9]!==s||t[10]!==d?(f=(0,$.jsx)(`div`,{className:s,role:`separator`,"aria-orientation":`vertical`,"aria-label":i,...a,children:d}),t[7]=i,t[8]=a,t[9]=s,t[10]=d,t[11]=f):f=t[11],f},Af=()=>typeof window>`u`?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`,jf=()=>{Z.useEffect(()=>{if(!Af())return;document.documentElement.classList.add(`oc-native-app-active`);let e=!1,t=[],n=document.documentElement;n.classList.add(`oc-capacitor-app`),window.Capacitor?.getPlatform?.()===`android`&&n.classList.add(`oc-platform-android`);let r=e=>{n.style.setProperty(`--oc-keyboard-inset`,`${Math.max(0,Math.round(e))}px`)};return L(async()=>{let{StatusBar:e,Style:t}=await import(`./vendor-capacitor-status-bar-DeAGEDuY.js`).then(e=>e.t);return{StatusBar:e,Style:t}},__vite__mapDeps([55,1,10])).then(async({StatusBar:n,Style:r})=>{if(e)return;let i=window.Capacitor?.getPlatform?.(),a=async()=>{if(i===`android`){let e=document.documentElement.classList.contains(`dark`),t=(e?localStorage.getItem(`splashBgDark`):localStorage.getItem(`splashBgLight`))||(e?`#121212`:`#FFFFFF`);await n.setOverlaysWebView({overlay:!1}).catch(()=>void 0),await n.setBackgroundColor({color:t}).catch(()=>void 0),await n.setStyle({style:e?r.Dark:r.Light}).catch(()=>void 0),await n.show().catch(()=>void 0);return}await n.setStyle({style:r.Default}).catch(()=>void 0),await n.setOverlaysWebView({overlay:!0}).catch(()=>void 0),await n.show().catch(()=>void 0)};await a();let o=window.setTimeout(()=>void a(),400);t.push(()=>window.clearTimeout(o));let{App:s}=await L(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([53,1,10])),c=await s.addListener(`appStateChange`,({isActive:e})=>{e&&a()});if(e){c.remove();return}t.push(()=>void c.remove())}).catch(()=>void 0),L(async()=>{let{Keyboard:e}=await import(`./vendor-capacitor-keyboard-BkRQ-Kv-.js`).then(e=>e.t);return{Keyboard:e}},__vite__mapDeps([56,1,10])).then(async({Keyboard:i})=>{if(e)return;let a=window.Capacitor?.getPlatform?.()===`android`;await i.setAccessoryBarVisible({isVisible:!1}).catch(()=>void 0);let o=`cubic-bezier(0.38, 0.7, 0.125, 1)`,s=null,c=null,l=0,u=!1,d=0,f=!1,p=(e,t)=>{n.style.setProperty(e,`${Math.max(0,Math.round(t))}px`)},m=()=>{s!==null&&(window.clearTimeout(s),s=null)},h=(e,t)=>{window.dispatchEvent(new CustomEvent(e,{detail:t}))},g=e=>e.getClientRects().length>0&&getComputedStyle(e).visibility!==`hidden`,_=e=>{for(let t of document.querySelectorAll(e))if(g(t))return t;return null},v=e=>{let t=[],n=e instanceof Element?e:null;if(n&&!Da(n))return t;let r=n?.closest(`.oc-mobile-composer`)??null,i=r&&g(r)?r:_(`.oc-mobile-composer`);if(i&&t.push({el:i,factor:1}),i){let e=_(`.oc-draft-center`);e&&t.push({el:e,factor:.5})}return t},y=e=>e instanceof HTMLElement&&(e.tagName===`TEXTAREA`||e.tagName===`INPUT`||e.isContentEditable),b=()=>{let e=document.activeElement;return!(y(e)&&!Da(e))},x=e=>Da(e),S=()=>{for(let e of document.querySelectorAll(`.oc-mobile-composer, .oc-draft-center`))e.style.transition=``,e.style.transform=``},C=()=>{let e=document.querySelector(`.oc-mobile-app-shell`);d=e&&parseFloat(getComputedStyle(e).paddingBottom)||0};if(a){let i=`openchamber.androidImeHeightRatio.v2`,a=`cubic-bezier(0.2, 0, 0, 1)`,o=`cubic-bezier(0.4, 0, 1, 1)`,s=null,c=!1,l=y,u=e=>Number.isFinite(e)?Math.min(.68,Math.max(.28,e)):.39,m=Math.round(window.innerHeight*(()=>{try{return u(Number.parseFloat(localStorage.getItem(i)??``))}catch{return .39}})()),g=0,_=e=>{if(m=Math.max(0,Math.round(e)),!(m<=0||window.innerHeight<=0))try{localStorage.setItem(i,String(u(m/window.innerHeight)))}catch{}},w=()=>{s!==null&&(window.clearTimeout(s),s=null)},T=e=>Math.max(0,Math.round(e-d)),E=(e,t)=>`translate3d(0, ${-e*t}px, 0)`,D=(e,t,r,i)=>{w();let a=T(e),o=v(i);n.classList.add(`oc-kb-animating`);for(let{el:e,factor:n}of o)e.style.transition=`transform ${t}ms ${r}`,e.style.transform=E(a,n);return s=window.setTimeout(()=>{s=null,n.classList.remove(`oc-kb-animating`);for(let{el:e}of o)e.style.transition=``},t+20),a},O=e=>{C();let t=Math.max(0,Math.round(e));f=!0,c=!1,g=t,n.classList.remove(`oc-keyboard-open`,`oc-kb-animating`),r(t),p(`--oc-kb-layout`,0),p(`--oc-kb-scroll-inset`,T(t)),w(),S(),h(`oc:keyboard-settled`,{open:!0})},k=(e,t=`focus`)=>{if(t===`intent`){if(!b())return}else if(t===`focus`){if(!x(e))return}else if(!f&&!x(document.activeElement))return;if(C(),f){let i=g||m,o=T(i),s=v(t===`focus`?e:void 0);if(s.length===0||(c=!0,n.classList.add(`oc-keyboard-open`),r(0),p(`--oc-kb-scroll-inset`,0),s.every(({el:e,factor:t})=>e.style.transform===E(o,t))))return;D(i,60,a,t===`focus`?e:void 0),h(`oc:keyboard-anim`,{phase:`show`,slide:o,durationMs:60,easing:a}),h(`oc:keyboard-settled`,{open:!0});return}f=!0,c=!0,n.classList.add(`oc-keyboard-open`),r(0),p(`--oc-kb-layout`,0),p(`--oc-kb-scroll-inset`,0),g=m;let i=D(g,200,a,t===`focus`?e:void 0);h(`oc:keyboard-anim`,{phase:`show`,slide:i,durationMs:200,easing:a}),h(`oc:keyboard-settled`,{open:!0})},A=e=>{if(!f){e&&l(document.activeElement)&&Da(document.activeElement)&&document.activeElement.blur();return}let t=g||m,i=c;f=!1,c=!1,g=0,e&&l(document.activeElement)&&Da(document.activeElement)&&document.activeElement.blur(),n.classList.remove(`oc-keyboard-open`),r(0),p(`--oc-kb-layout`,0),p(`--oc-kb-scroll-inset`,0),h(`oc:keyboard-intent`,{open:!1});let a=T(t);if(!i){w(),S(),h(`oc:keyboard-settled`,{open:!1});return}D(0,100,o),h(`oc:keyboard-anim`,{phase:`hide`,slide:a,durationMs:100,easing:o}),w(),s=window.setTimeout(()=>{s=null,n.classList.remove(`oc-kb-animating`),S(),h(`oc:keyboard-settled`,{open:!1})},120)},j=e=>{if(l(e.target)){if(Da(e.target)){k(e.target,`focus`);return}O(g||m)}},M=e=>{if(l(e.target)&&!ka(e.relatedTarget)){if(Oa(e.relatedTarget)){h(`oc:keyboard-intent`,{open:!1}),O(g||m);return}A(!1)}},N=e=>{let t=e,n=t.detail??t;if(n?.open===!0){let e=Ma(n.height??0,window.devicePixelRatio||1),t=Aa(c,document.activeElement);if(e>0&&(t===`open`||t===`cache`)&&_(e),t===`open`&&k(document.activeElement,`ime`),t===`cache`&&ja(g||m,e)){g=e;let t=D(e,60,a,Da(document.activeElement)?document.activeElement:void 0);h(`oc:keyboard-anim`,{phase:`show`,slide:t,durationMs:60,easing:a})}t===`field`&&O(e||m)}n?.open===!1&&A(!0)},P=e=>{e.detail?.open===!0&&k(void 0,`intent`)};if(document.addEventListener(`focusin`,j,!0),document.addEventListener(`focusout`,M,!0),window.addEventListener(`oc:ime-state`,N),window.addEventListener(`oc:keyboard-intent`,P),e){w(),document.removeEventListener(`focusin`,j,!0),document.removeEventListener(`focusout`,M,!0),window.removeEventListener(`oc:ime-state`,N),window.removeEventListener(`oc:keyboard-intent`,P);return}t.push(w,()=>document.removeEventListener(`focusin`,j,!0),()=>document.removeEventListener(`focusout`,M,!0),()=>window.removeEventListener(`oc:ime-state`,N),()=>window.removeEventListener(`oc:keyboard-intent`,P));return}let w=`openchamber.iosImeHeightRatio.v1`,T=e=>Number.isFinite(e)?Math.min(.68,Math.max(.28,e)):.39,E=()=>{try{let e=T(Number.parseFloat(localStorage.getItem(w)??``));return Math.round(window.innerHeight*e)}catch{return Math.round(window.innerHeight*.39)}},D=e=>{if(!(e<=0||window.innerHeight<=0))try{localStorage.setItem(w,String(T(e/window.innerHeight)))}catch{}},O=e=>{C();let t=Math.max(0,e-d);r(e),p(`--oc-kb-layout`,e),p(`--oc-kb-scroll-inset`,0),u=!0,S(),window.scrollTo(0,0),document.body.scrollTop!==0&&(document.body.scrollTop=0);let n=document.activeElement instanceof Element?document.activeElement.closest(`.oc-mobile-composer`):null;return(n&&g(n)?n:_(`.oc-mobile-composer`))?.scrollIntoView({block:`end`,inline:`nearest`}),t},k=e=>{if(Ea(n.classList.contains(`oc-native-ios-composer`),document.activeElement)||e.detail?.open!==!0||u||y(document.activeElement)&&!Da(document.activeElement))return;f=!0,n.classList.remove(`oc-kb-hide`),n.classList.add(`oc-keyboard-open`);let t=l>0?l:E(),r=O(t);h(`oc:keyboard-anim`,{phase:`show`,slide:r,durationMs:0,easing:o}),h(`oc:keyboard-settled`,{open:!0})};window.addEventListener(`oc:keyboard-intent`,k);let A=await i.addListener(`keyboardWillShow`,e=>{if(Ea(n.classList.contains(`oc-native-ios-composer`),document.activeElement))return;m(),l=e.keyboardHeight,D(l);let t=Da(document.activeElement)||n.classList.contains(`oc-keyboard-open`)&&!y(document.activeElement);if(f=!0,n.classList.remove(`oc-kb-hide`),c!==null&&(window.clearTimeout(c),c=null),!t){r(l),p(`--oc-kb-layout`,0),C(),p(`--oc-kb-scroll-inset`,Math.max(0,l-d)),n.classList.remove(`oc-keyboard-open`,`oc-kb-animating`,`oc-kb-caret-hold`),S(),u=!1,h(`oc:keyboard-settled`,{open:!0});return}n.classList.add(`oc-keyboard-open`);let i=O(l);h(`oc:keyboard-settled`,{open:!0}),h(`oc:keyboard-anim`,{phase:`show`,slide:i,durationMs:0,easing:o})}),j=()=>{let e=document.activeElement;e instanceof HTMLElement&&Da(e)&&e.blur()},M=()=>{f||(window.scrollTo(0,0),document.body.scrollTop!==0&&(document.body.scrollTop=0))},N=()=>{f=!1,m(),c!==null&&(window.clearTimeout(c),c=null),n.classList.remove(`oc-keyboard-open`,`oc-kb-animating`,`oc-kb-caret-hold`,`oc-kb-hide`),r(0),p(`--oc-kb-scroll-inset`,0),p(`--oc-kb-layout`,0),u=!1,S(),M(),window.setTimeout(M,350)},P=()=>{if(n.classList.contains(`oc-native-ios-composer`)){N(),Bn().blur(),h(`oc:keyboard-settled`,{open:!1});return}if(!f)return;f=!1,m(),h(`oc:keyboard-intent`,{open:!1}),j(),window.setTimeout(()=>{f||Da(document.activeElement)&&(j(),h(`oc:keyboard-intent`,{open:!1}))},80),c!==null&&(window.clearTimeout(c),c=null),n.classList.remove(`oc-kb-caret-hold`,`oc-kb-animating`);let e=Math.max(0,l-d);n.classList.remove(`oc-keyboard-open`),r(0),p(`--oc-kb-scroll-inset`,0),p(`--oc-kb-layout`,0),u=!1,S(),M(),window.setTimeout(M,350),h(`oc:keyboard-anim`,{phase:`hide`,slide:e,durationMs:0,easing:o}),n.classList.add(`oc-kb-animating`,`oc-kb-hide`),s=window.setTimeout(()=>{s=null,n.classList.remove(`oc-kb-animating`,`oc-kb-hide`),h(`oc:keyboard-settled`,{open:!1})},260)},F=await i.addListener(`keyboardWillHide`,P),I=e=>e instanceof HTMLElement&&(e.tagName===`TEXTAREA`||e.tagName===`INPUT`||e.isContentEditable),L=e=>{if(f&&I(e.target)){if(ka(e.relatedTarget)){p(`--oc-kb-scroll-inset`,0);return}window.setTimeout(()=>{if(f&&!Da(document.activeElement)){if(I(document.activeElement)){m(),n.classList.remove(`oc-keyboard-open`,`oc-kb-animating`,`oc-kb-caret-hold`,`oc-kb-hide`),r(l),p(`--oc-kb-layout`,0),C(),p(`--oc-kb-scroll-inset`,Math.max(0,l-d)),u=!1,S(),h(`oc:keyboard-intent`,{open:!1}),h(`oc:keyboard-settled`,{open:!0});return}P()}},0)}};if(document.addEventListener(`focusout`,L,!0),e){m(),document.removeEventListener(`focusout`,L,!0),window.removeEventListener(`oc:keyboard-intent`,k),A.remove(),F.remove();return}t.push(m,()=>{c!==null&&(window.clearTimeout(c),c=null)},()=>document.removeEventListener(`focusout`,L,!0),()=>window.removeEventListener(`oc:keyboard-intent`,k),()=>void A.remove(),()=>void F.remove())}).catch(()=>void 0),()=>{e=!0,t.forEach(e=>e()),n.classList.remove(`oc-capacitor-app`,`oc-keyboard-open`,`oc-kb-animating`,`oc-kb-hide`,`oc-kb-caret-hold`,`oc-platform-android`),n.style.removeProperty(`--oc-keyboard-inset`),n.style.removeProperty(`--oc-kb-shift`),n.style.removeProperty(`--oc-kb-layout`),n.style.removeProperty(`--oc-kb-scroll-inset`)}},[])},Mf=e=>{let t=Z.useRef(!1);Z.useEffect(()=>{if(!Af())return;let n=!1,r=[],i=()=>{t.current&&(t.current=!1,e())},a=()=>{if(document.visibilityState===`hidden`){t.current=!0;return}i()};return document.addEventListener(`visibilitychange`,a),r.push(()=>document.removeEventListener(`visibilitychange`,a)),L(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([53,1,10])).then(async({App:e})=>{if(n)return;let a=await e.getState().catch(()=>null);if(n)return;a&&document.documentElement.classList.toggle(`oc-native-app-active`,a.isActive);let o=await e.addListener(`appStateChange`,({isActive:e})=>{if(document.documentElement.classList.toggle(`oc-native-app-active`,e),!e){t.current=!0;return}i()}),s=await e.addListener(`resume`,i);if(n){o.remove(),s.remove();return}r.push(()=>void o.remove(),()=>void s.remove())}).catch(()=>void 0),()=>{n=!0,r.forEach(e=>e()),document.documentElement.classList.remove(`oc-native-app-active`)}},[e])},Nf=e=>{Z.useEffect(()=>{if(!Af())return;let t=!1,n=null;return L(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([53,1,10])).then(async({App:r})=>{if(t)return;let i=await r.addListener(`backButton`,()=>{e()||r.minimizeApp().catch(()=>void 0)});if(t){i.remove();return}n=()=>void i.remove()}).catch(()=>void 0),()=>{t=!0,n?.()}},[e])},Pf=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Ff={autoComplete:`off`,autoCorrect:`off`,spellCheck:!1},If=1e3,Lf=e=>{let t=Pf(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},Rf=(e,t)=>Lf(e?e.path:t),zf=`h-12 w-full rounded-[16px] border border-border/70 bg-surface-elevated px-4 text-center text-[16px] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-primary focus:ring-2 focus:ring-primary/20`,Bf=({connection:e})=>{let{t}=ee(),n=e,{connections:r,isBusy:i,isPasswordBusy:a,error:o,pendingConnection:s}=n,[c,l]=Z.useState(``),[u,d]=Z.useState(``),[f,p]=Z.useState(``),[m,h]=Z.useState(!1),g=Z.useMemo(()=>tu(),[]),[_,v]=Z.useState(()=>!tu()),[y,b]=Z.useState(null),[x,S]=Z.useState(``),C=V(e=>{e.preventDefault(),n.connect({url:c,clientToken:f,label:u})}),w=V(e=>{n.redeemPairingConnection(e)}),T=V(()=>{n.setError(t(`mobile.connect.link.invalid`))}),E=V(async()=>{if(!(m||i)){n.setError(null),h(!0);try{let e=await nu();switch(e.status){case`ok`:l(e.url),e.label&&d(e.label),e.clientToken&&p(e.clientToken),await n.connect({url:e.url,clientToken:e.clientToken,label:e.label});break;case`pairing`:await n.redeemPairingConnection(e.pairing);break;case`permission-denied`:n.setError(t(`mobile.connect.scan.permissionDenied`));break;case`invalid`:n.setError(t(`mobile.connect.scan.invalid`));break;case`unsupported`:n.setError(t(`mobile.connect.scan.unsupported`));break;case`failed`:n.setError(t(`mobile.connect.scan.failed`))}}finally{h(!1)}}}),D=V(e=>{e.preventDefault(),n.submitPassword(x)}),O=V(()=>{S(``),n.cancelPassword()});return(0,$.jsx)(`main`,{className:`oc-keyboard-fill-screen flex min-h-dvh flex-col overflow-y-auto bg-background px-6 pb-[calc(var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))+28px)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+28px)] text-foreground`,children:(0,$.jsxs)(`div`,{className:`m-auto flex w-full max-w-[360px] shrink-0 flex-col items-center gap-9 py-8`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-5 text-center`,children:[(0,$.jsx)(en,{width:72,height:72,className:`size-[72px]`}),(0,$.jsx)(`h1`,{className:`typography-h2 text-foreground`,children:t(`mobile.connect.welcome.title`)})]}),s?(0,$.jsxs)(`form`,{className:`flex w-full flex-col gap-3`,onSubmit:D,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3`,children:[(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground`,children:(0,$.jsx)(X,{name:`lock`,className:`size-[18px]`})}),(0,$.jsxs)(`div`,{className:`min-w-0 text-left`,children:[(0,$.jsx)(`p`,{className:`truncate typography-ui-label text-foreground`,children:s.label}),(0,$.jsx)(`p`,{className:`truncate typography-small text-muted-foreground`,children:s.candidates.some(e=>e.kind===`direct`)?ne(s):t(`mobile.connect.relay.badge`)})]})]}),(0,$.jsx)(`input`,{...Ff,value:x,onChange:e=>S(e.target.value),placeholder:t(`mobile.connect.password.placeholder`),"aria-label":t(`mobile.connect.password.label`),type:`password`,autoFocus:!0,className:`h-12 w-full rounded-[16px] border border-border/70 bg-surface-elevated px-4 text-[16px] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-primary focus:ring-2 focus:ring-primary/20`}),o?(0,$.jsx)(`p`,{className:`px-1 text-center typography-small text-[var(--status-error)]`,children:o}):null,(0,$.jsx)(G,{type:`submit`,size:`lg`,className:`mt-1 h-12 w-full`,disabled:a||!x.trim(),children:t(a?`mobile.connect.connecting`:`mobile.connect.unlockButton`)}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,className:`w-full`,onClick:O,children:t(`mobile.connect.cancelPassword`)})]}):(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-6`,children:[g?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,children:[(0,$.jsxs)(G,{type:`button`,size:`lg`,className:`h-12 w-full`,onClick:()=>void E(),disabled:m||i,children:[(0,$.jsx)(X,{name:`scan-2`,className:W(`size-[18px]`,m&&`animate-pulse`)}),t(i?`mobile.connect.connecting`:`mobile.connect.scanQr`)]}),(0,$.jsx)(`p`,{className:`px-2 text-center typography-small text-muted-foreground`,children:t(`mobile.connect.welcome.scanHint`)})]}):null,o&&!_?(0,$.jsx)(`p`,{className:`px-1 text-center typography-small text-[var(--status-error)]`,children:o}):null,r.length>0?(0,$.jsxs)(`section`,{className:`flex w-full flex-col gap-2.5`,children:[(0,$.jsx)(`h2`,{className:`text-center typography-micro uppercase tracking-[0.14em] text-muted-foreground`,children:t(`mobile.connect.saved.title`)}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated`,children:r.map(e=>{let r=y===e.id;return(0,$.jsxs)(`button`,{type:`button`,disabled:i,className:`flex min-h-14 w-full items-center gap-3 border-b border-border/60 px-3.5 py-2.5 text-left last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:opacity-70`,onClick:()=>{b(e.id),n.connect({id:e.id,candidates:e.candidates,clientToken:e.clientToken,label:e.label}).finally(()=>b(null))},children:[(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground`,children:(0,$.jsx)(X,{name:`server`,className:`size-[18px]`})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:e.label}),(0,$.jsx)(`span`,{className:W(`block truncate typography-small`,r?`text-foreground`:`text-muted-foreground`),children:t(r?`mobile.connect.connecting`:`mobile.instances.status.saved`)})]}),r?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-5 text-muted-foreground`})]},e.id)})})]}):null,(0,$.jsxs)(`div`,{className:`flex w-full flex-col`,children:[g?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>v(e=>!e),"aria-expanded":_,className:`mx-auto flex items-center gap-1 rounded-full px-2 py-1 typography-small text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:[(0,$.jsx)(`span`,{children:t(`mobile.connect.manual.toggle`)}),(0,$.jsx)(X,{name:`arrow-down-s`,className:W(`size-4 transition-transform duration-200`,_&&`rotate-180`)})]}):null,(0,$.jsx)(`div`,{className:`grid transition-[grid-template-rows] duration-200 ease-out`,style:{gridTemplateRows:_?`1fr`:`0fr`},children:(0,$.jsxs)(`div`,{className:`min-h-0 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`pt-3`,children:(0,$.jsx)(iu,{disabled:i||m,isBusy:i,tabIndex:_?void 0:-1,inputClassName:zf,buttonVariant:g?`outline`:`default`,onRedeem:w,onInvalid:T})}),(0,$.jsx)(au,{label:t(`mobile.connect.address.divider`)}),(0,$.jsxs)(`form`,{className:`flex w-full flex-col gap-3`,onSubmit:C,children:[(0,$.jsx)(`input`,{...Ff,value:c,onChange:e=>l(e.target.value),placeholder:t(`mobile.connect.url.placeholder`),"aria-label":t(`mobile.connect.url.label`),type:`url`,inputMode:`url`,autoCapitalize:`none`,tabIndex:_?void 0:-1,className:zf}),(0,$.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),placeholder:t(`mobile.instances.label.placeholder`),"aria-label":t(`mobile.instances.label.label`),autoComplete:`off`,autoCapitalize:`words`,autoCorrect:`off`,spellCheck:!1,tabIndex:_?void 0:-1,className:zf}),(0,$.jsx)(`input`,{...Ff,value:f,onChange:e=>p(e.target.value),placeholder:t(`mobile.connect.token.placeholder`),"aria-label":t(`mobile.connect.token.label`),tabIndex:_?void 0:-1,autoCapitalize:`none`,className:zf}),(0,$.jsx)(`p`,{className:`px-1 text-center typography-micro text-muted-foreground`,children:t(`mobile.connect.token.hint`)}),(0,$.jsx)(G,{type:`submit`,variant:`outline`,size:`lg`,className:`h-12 w-full`,disabled:i||m||!c.trim(),children:t(i?`mobile.connect.connecting`:`mobile.connect.connectButton`)})]}),o?(0,$.jsx)(`p`,{className:`px-1 pt-3 text-center typography-small text-[var(--status-error)]`,children:o}):null]})})]})]})]})})},Vf=({connection:e,onActiveConnectionDeleted:t,onConnect:n})=>{let{t:r}=ee(),i=e,{connections:a,isBusy:o,isPasswordBusy:s,error:c,pendingConnection:l,connect:u,submitPassword:d,cancelPassword:f,saveConnection:p,removeConnection:m,subscribeConnected:h,setError:g}=i,[_,v]=Z.useState(null),y=_?a.find(e=>e.id===_)??null:null,b=y?!y.candidates.some(e=>e.kind===`direct`):!1,[x,S]=Z.useState(null),[C,w]=Z.useState(``),[T,E]=Z.useState(``),[D,O]=Z.useState(``),[k,A]=Z.useState(``),[j,M]=Z.useState(!1),N=Z.useMemo(()=>tu(),[]),[P,F]=Z.useState(!1),[I,L]=Z.useState(null),R=V(n);Z.useEffect(()=>h(R),[R,h]);let z=V(()=>{v(null),w(``),E(``),O(``),g(null),F(!1)}),B=V(e=>{e.preventDefault(),p({id:_??void 0,url:C,label:T,clientToken:D}).then(e=>{e&&z()})}),H=V(e=>{i.redeemPairingConnection(e)}),U=V(()=>{g(r(`mobile.connect.link.invalid`))}),K=V(async()=>{if(!j){g(null),M(!0);try{let e=await nu();switch(e.status){case`ok`:w(e.url),e.label&&E(e.label),e.clientToken&&O(e.clientToken),F(!0);break;case`pairing`:await i.redeemPairingConnection(e.pairing);break;case`permission-denied`:g(r(`mobile.connect.scan.permissionDenied`));break;case`invalid`:g(r(`mobile.connect.scan.invalid`));break;case`unsupported`:g(r(`mobile.connect.scan.unsupported`));break;case`failed`:g(r(`mobile.connect.scan.failed`))}}finally{M(!1)}}}),te=V(e=>{e.preventDefault(),d(k)}),q=V(()=>{A(``),f()}),re=V(e=>{S(t=>t===e?null:e)}),ie=V(e=>{S(null),_===e&&z();let n=a.length===1;m(e).then(e=>{e&&(n||ce(e))&&t()})}),ae=`h-12 w-full rounded-[16px] border border-border/70 bg-surface-elevated px-4 text-[16px] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-primary focus:ring-2 focus:ring-primary/20`;return l?(0,$.jsx)(`div`,{className:`oc-settings-page-content`,children:(0,$.jsx)(_r,{label:r(`mobile.connect.password.label`),itemId:`instances.manage`,children:(0,$.jsxs)(`form`,{className:`oc-settings-group-row flex flex-col gap-3`,onSubmit:te,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3`,children:[(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground`,children:(0,$.jsx)(X,{name:`lock`,className:`size-[18px]`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`truncate typography-ui-label text-foreground`,children:l.label}),(0,$.jsx)(`p`,{className:`truncate typography-small text-muted-foreground`,children:l.candidates.some(e=>e.kind===`direct`)?ne(l):r(`mobile.connect.relay.badge`)})]})]}),(0,$.jsx)(`input`,{...Ff,value:k,onChange:e=>A(e.target.value),placeholder:r(`mobile.connect.password.placeholder`),"aria-label":r(`mobile.connect.password.label`),type:`password`,autoFocus:!0,className:ae}),c?(0,$.jsx)(`p`,{className:`px-1 typography-small text-[var(--status-error)]`,children:c}):null,(0,$.jsx)(G,{type:`submit`,size:`lg`,className:`mt-1 h-12 w-full`,disabled:s||!k.trim(),children:r(s?`mobile.connect.connecting`:`mobile.connect.unlockButton`)}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,className:`w-full`,onClick:q,children:r(`mobile.connect.cancelPassword`)})]})})}):(0,$.jsxs)(`div`,{className:`oc-settings-page-content`,children:[(0,$.jsx)(_r,{label:r(`mobile.connect.saved.title`),itemId:`instances.manage`,children:a.length>0?a.map(e=>{let t=x===e.id,n=ce(e),i=I===e.id,a=r(i?`mobile.connect.connecting`:n?`mobile.instances.status.connected`:`mobile.instances.status.saved`);return(0,$.jsxs)(`div`,{className:W(`oc-settings-group-row relative flex items-center`,t&&`bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]`),children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":r(`desktopHostSwitcher.actions.switchToAria`,{instance:e.label}),"data-mobile-press-feedback":`none`,className:`absolute inset-0 z-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:pointer-events-none`,onClick:()=>{n||(L(e.id),u({id:e.id,candidates:e.candidates,clientToken:e.clientToken,label:e.label}).finally(()=>L(null)))},disabled:n||o&&!i||t,style:{touchAction:`manipulation`}}),(0,$.jsxs)(`div`,{className:`pointer-events-none relative z-[1] flex min-w-0 flex-1 items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`relative flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground`,children:(0,$.jsx)(X,{name:`server`,className:`size-[18px]`})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:e.label})}),(0,$.jsx)(`span`,{className:W(`block truncate typography-small`,n&&!i?`text-[var(--status-success)]`:`text-muted-foreground`),children:a})]})]}),(0,$.jsxs)(`div`,{className:`relative z-10 flex shrink-0 items-center gap-0.5 pr-2`,children:[t?(0,$.jsxs)(`button`,{type:`button`,"aria-label":r(`mobile.instances.confirmDeleteAria`,{label:e.label}),className:`flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-destructive px-3 text-destructive-foreground transition-opacity active:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive`,onClick:()=>ie(e.id),style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`typography-ui-label`,children:r(`mobile.instances.delete`)})]}):i?(0,$.jsx)(`span`,{className:`flex size-9 items-center justify-center text-muted-foreground`,"aria-hidden":!0,children:(0,$.jsx)(X,{name:`loader-4`,className:`size-[18px] animate-spin`})}):(0,$.jsx)(`button`,{type:`button`,"aria-label":r(`mobile.instances.edit`),className:`flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:()=>{v(e.id),w(e.candidates.some(e=>e.kind===`direct`)?ne(e):``),E(e.label),O(e.clientToken||``),g(null)},style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`edit`,className:`size-[18px]`})}),(0,$.jsx)(`button`,{type:`button`,"aria-label":r(t?`mobile.instances.cancelDeleteAria`:`mobile.instances.deleteAria`,{label:e.label}),className:`flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:()=>re(e.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:t?`close`:`delete-bin`,className:`size-[18px]`})})]})]},e.id)}):(0,$.jsx)(`div`,{className:`oc-settings-group-row flex items-center justify-center text-center typography-small text-muted-foreground`,children:r(`mobile.connect.saved.empty`)})}),(0,$.jsx)(_r,{label:r(y?`mobile.instances.editTitle`:`mobile.instances.addTitle`),children:!P&&!y?(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex flex-col items-stretch gap-2`,children:[N?(0,$.jsxs)(G,{type:`button`,size:`lg`,className:`h-12 w-full`,onClick:()=>void K(),disabled:j,children:[(0,$.jsx)(X,{name:`scan-2`,className:W(`size-[18px]`,j&&`animate-pulse`)}),r(`mobile.connect.scanQr`)]}):null,(0,$.jsxs)(G,{type:`button`,variant:N?`ghost`:`outline`,size:`lg`,className:`h-12 w-full`,onClick:()=>{g(null),F(!0)},children:[(0,$.jsx)(X,{name:`add`,className:`size-[18px]`}),r(`mobile.instances.addManual`)]}),c?(0,$.jsx)(`p`,{className:`px-1 text-center typography-small text-[var(--status-error)]`,children:c}):null]}):(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex flex-col gap-3`,children:[(0,$.jsx)(`div`,{className:`flex min-h-8 items-center justify-end px-1`,children:(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`xs`,onClick:z,children:r(`mobile.instances.cancelEdit`)})}),(0,$.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:B,children:[b?null:(0,$.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,$.jsx)(`span`,{className:`block px-1 typography-ui-label text-foreground`,children:r(`mobile.connect.url.label`)}),(0,$.jsx)(`input`,{...Ff,value:C,onChange:e=>w(e.target.value),placeholder:r(`mobile.connect.url.placeholder`),type:`url`,inputMode:`url`,autoCapitalize:`none`,className:ae})]}),(0,$.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,$.jsx)(`span`,{className:`block px-1 typography-ui-label text-foreground`,children:r(`mobile.instances.label.label`)}),(0,$.jsx)(`input`,{value:T,onChange:e=>E(e.target.value),placeholder:r(`mobile.instances.label.placeholder`),autoComplete:`off`,autoCapitalize:`words`,autoCorrect:`off`,spellCheck:!1,className:ae})]}),(0,$.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,$.jsx)(`span`,{className:`block px-1 typography-ui-label text-foreground`,children:r(`mobile.connect.token.label`)}),(0,$.jsx)(`input`,{...Ff,value:D,onChange:e=>O(e.target.value),placeholder:r(`mobile.connect.token.placeholder`),autoCapitalize:`none`,className:ae}),(0,$.jsx)(`p`,{className:`px-1 typography-micro text-muted-foreground`,children:r(`mobile.connect.token.hint`)})]}),(0,$.jsx)(G,{type:`submit`,size:`lg`,className:`mt-1 h-12 w-full`,children:r(y?`mobile.instances.saveEdit`:`mobile.instances.saveNew`)})]}),y?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(au,{label:r(`mobile.connect.link.divider`)}),(0,$.jsx)(iu,{disabled:o||j,isBusy:o,inputClassName:ae,onRedeem:H,onInvalid:U})]}),c?(0,$.jsx)(`p`,{className:`px-1 typography-small text-[var(--status-error)]`,children:c}):null]})})]})},Hf=e=>{let t=e.usedPercent;return typeof t!=`number`||!Number.isFinite(t)?`text-foreground`:t>=80?`text-[var(--status-error)]`:t>=50?`text-[var(--status-warning)]`:`text-foreground`},Uf=e=>{let t=(0,Q.c)(13),{icon:n,iconNode:r,label:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=r??(n?(0,$.jsx)(X,{name:n,className:`size-[18px]`}):null),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]===o?s=t[4]:(s=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:o}),t[3]=o,t[4]=s);let c;t[5]===i?c=t[6]:(c=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:i}),t[5]=i,t[6]=c);let l;t[7]===a?l=t[8]:(l=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground`,children:a}),t[7]=a,t[8]=l);let u;return t[9]!==s||t[10]!==c||t[11]!==l?(u=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5`,children:[s,c,l]}),t[9]=s,t[10]=c,t[11]=l,t[12]=u):u=t[12],u},Wf=e=>{let t=(0,Q.c)(55),{open:n,onClose:r,anchorRef:i,contextDisplay:a,branchLabel:o,usageGroups:s,usageDisplayMode:c,isUsageLoading:l,timeFormatPreference:u}=e,{t:d}=ee(),f=Z.useRef(null),[p,m]=Z.useState(n),[h,g]=Z.useState(!1),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=k(),t[0]=_):_=t[0];let v=_,y=Z.useRef(null),[b,x]=Z.useState(null),S,C;t[1]!==i||t[2]!==n||t[3]!==p?(S=()=>{if(!n||!v||!p)return;let e=()=>{let e=i.current?.getBoundingClientRect(),t=y.current?.getBoundingClientRect();if(!e||!t){x(null);return}let n=e.left-t.left,r=Math.min(Math.max(n,8),Math.max(8,t.width-Tf-8));x(r)};e();let t=y.current;if(typeof ResizeObserver>`u`||!t)return;let r=new ResizeObserver(e);return r.observe(t),()=>r.disconnect()},C=[i,v,n,p],t[1]=i,t[2]=n,t[3]=p,t[4]=S,t[5]=C):(S=t[4],C=t[5]),Z.useLayoutEffect(S,C);let w=v&&b!==null,T,E;t[6]!==n||t[7]!==p?(T=()=>{if(n){m(!0),g(!1);return}if(!p)return;g(!0);let e=window.setTimeout(()=>{m(!1),g(!1)},140);return()=>window.clearTimeout(e)},E=[n,p],t[6]=n,t[7]=p,t[8]=T,t[9]=E):(T=t[8],E=t[9]),Z.useEffect(T,E);let D,O;t[10]!==r||t[11]!==n?(D=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},O=[r,n],t[10]=r,t[11]=n,t[12]=D,t[13]=O):(D=t[12],O=t[13]),Z.useEffect(D,O);let A,j;if(t[14]!==i||t[15]!==r||t[16]!==n?(A=()=>{if(!n)return;let e=e=>{let t=e.target;if(!(t instanceof Node)){r();return}f.current?.contains(t)||i.current?.contains(t)||r()};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`wheel`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`wheel`,e,!0)}},j=[i,r,n],t[14]=i,t[15]=r,t[16]=n,t[17]=A,t[18]=j):(A=t[17],j=t[18]),Z.useEffect(A,j),!p)return null;let M;t[19]===d?M=t[20]:(M=d(`mobile.header.openMetadataAria`),t[19]=d,t[20]=M);let N=w?`absolute origin-top-left`:`mx-3 mt-2`,P=h?`pointer-events-none`:`pointer-events-auto`,F;t[21]!==N||t[22]!==P?(F=W(`overflow-y-auto overscroll-contain rounded-[20px] oc-mobile-overlay-surface p-2 will-change-transform`,N,P),t[21]=N,t[22]=P,t[23]=F):F=t[23];let I=`${h?`session-metadata-out`:`session-metadata-in`} ${h?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,L;t[24]!==b||t[25]!==w?(L=w?{top:8,left:b??8,width:`min(${Tf}px, calc(100% - 16px))`}:null,t[24]=b,t[25]=w,t[26]=L):L=t[26];let R;t[27]!==I||t[28]!==L?(R={animation:I,maxHeight:`min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))`,...L},t[27]=I,t[28]=L,t[29]=R):R=t[29];let z;t[30]===d?z=t[31]:(z=d(`mobile.header.metadata.branch`),t[30]=d,t[31]=z);let B;t[32]!==o||t[33]!==z?(B=(0,$.jsx)(Uf,{icon:`git-branch`,label:z,children:o}),t[32]=o,t[33]=z,t[34]=B):B=t[34];let V;t[35]!==a||t[36]!==d?(V=a?(0,$.jsx)(Uf,{iconNode:(0,$.jsx)(Xc,{percentage:a.percentage}),label:d(`mobile.header.metadata.context`),children:(0,$.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5 tabular-nums`,children:[(0,$.jsxs)(`span`,{className:W(`font-semibold`,a.colorClass),children:[a.percentage.toFixed(1),`%`]}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:a.tokens})]})}):null,t[35]=a,t[36]=d,t[37]=V):V=t[37];let H;t[38]!==l||t[39]!==u||t[40]!==c||t[41]!==s?(H=(0,$.jsx)(Gf,{groups:s,displayMode:c,isLoading:l,timeFormatPreference:u}),t[38]=l,t[39]=u,t[40]=c,t[41]=s,t[42]=H):H=t[42];let U;t[43]!==B||t[44]!==V||t[45]!==H?(U=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[B,V,H]}),t[43]=B,t[44]=V,t[45]=H,t[46]=U):U=t[46];let G;t[47]!==M||t[48]!==F||t[49]!==R||t[50]!==U?(G=(0,$.jsx)(`div`,{ref:f,role:`dialog`,"aria-label":M,className:F,style:R,children:U}),t[47]=M,t[48]=F,t[49]=R,t[50]=U,t[51]=G):G=t[51];let K;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,$.jsx)(`style`,{children:`
|
|
20
20
|
@keyframes session-metadata-in {
|
|
21
21
|
from { opacity: 0; transform: translateY(-8px) scale(0.985); }
|
|
22
22
|
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
@@ -25,4 +25,4 @@ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{p as t,t as n,v as r,w
|
|
|
25
25
|
from { opacity: 1; transform: translateY(0) scale(1); }
|
|
26
26
|
to { opacity: 0; transform: translateY(-6px) scale(0.985); }
|
|
27
27
|
}
|
|
28
|
-
`}),t[52]=K):K=t[52];let te;return t[53]===G?te=t[54]:(te=(0,$.jsxs)(`div`,{ref:y,className:`fixed inset-x-0 bottom-0 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-header-height,56px))] z-20 pointer-events-none`,children:[G,K]}),t[53]=G,t[54]=te),te},Uf=e=>{let t=(0,Q.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=ee(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(X,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,$.jsx)(X,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,$.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(zt,{providerId:e.providerId,className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground`,children:e.providerName}),e.status&&e.rows.length===0?(0,$.jsx)(`span`,{className:`shrink-0 truncate typography-micro text-muted-foreground`,children:e.status}):null]}),e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:e.rows.map(e=>{let t=r===`remaining`?e.window.remainingPercent:e.window.usedPercent,n=Zt(e.window.valueLabel,t),i=sn(e.window.resetAt,e.window.resetAfterFormatted??e.window.resetAtFormatted,a);return(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-3`,children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-muted-foreground`,children:e.subtitle?`${e.subtitle} · ${e.label}`:e.label}),i?(0,$.jsx)(`span`,{className:`shrink-0 truncate typography-micro text-muted-foreground/70`,children:i}):null]}),(0,$.jsx)(`span`,{className:W(`shrink-0 typography-ui-label font-semibold tabular-nums`,Bf(e.window)),children:n===`-`?``:n})]},e.key)})}):null,e.status&&e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 typography-micro text-muted-foreground`,children:e.status}):null]},e.providerId),t[22]=r,t[23]=a,t[24]=e):e=t[24],g=n.map(e),t[18]=r,t[19]=n,t[20]=a,t[21]=g}else g=t[21];let _;t[25]===g?_=t[26]:(_=(0,$.jsx)(`div`,{className:`space-y-1.5`,children:g}),t[25]=g,t[26]=_);let v;return t[27]!==_||t[28]!==h?(v=(0,$.jsxs)(`div`,{className:`pt-2.5`,children:[h,_]}),t[27]=_,t[28]=h,t[29]=v):v=t[29],v},Wf=e=>{let t=(0,Q.c)(28),{open:n,onClose:r,items:i,rightOffset:a}=e,o=a===void 0?0:a,{t:s}=ee(),c,l;if(t[0]!==r||t[1]!==n?(c=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},l=[r,n],t[0]=r,t[1]=n,t[2]=c,t[3]=l):(c=t[2],l=t[3]),Z.useEffect(c,l),!n)return null;let u;t[4]===s?u=t[5]:(u=s(`mobile.menu.titleAria`),t[4]=s,t[5]=u);let d;t[6]===s?d=t[7]:(d=s(`mobile.surface.closeAria`),t[6]=s,t[7]=d);let f;t[8]===r?f=t[9]:(f=e=>{e.preventDefault(),r()},t[8]=r,t[9]=f);let p;t[10]!==d||t[11]!==f?(p=(0,$.jsx)(`button`,{type:`button`,className:`pointer-events-auto absolute inset-x-0 bottom-0 cursor-default top-[calc(var(--oc-safe-area-top,0px)+var(--oc-mobile-detail-navigation-height,3.5rem)+0.25rem)]`,"aria-label":d,onPointerDown:f}),t[10]=d,t[11]=f,t[12]=p):p=t[12];let m=`max(1rem, calc(8px + ${o}px + var(--oc-safe-area-right, 0px)))`,h;t[13]===m?h=t[14]:(h={right:m,animation:`mobile-menu-in 160ms cubic-bezier(0.32, 0.72, 0, 1) forwards`},t[13]=m,t[14]=h);let g;if(t[15]!==i||t[16]!==r){let e;t[18]===r?e=t[19]:(e=(e,t)=>(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,className:W(`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,t>0&&`border-t border-border/30`,e.disabled&&`cursor-not-allowed opacity-60`),style:{touchAction:`manipulation`},disabled:e.disabled,onClick:()=>{e.onSelect(),r()},children:[e.iconNode??(e.icon?(0,$.jsx)(X,{name:e.icon,className:W(`size-5 shrink-0 text-muted-foreground`,e.spinning&&`animate-spin`)}):null),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:e.label}),e.badge&&e.badge>0?(0,$.jsx)(`span`,{className:`inline-flex size-2 shrink-0 rounded-full bg-primary`,"aria-hidden":!0}):null]},e.key),t[18]=r,t[19]=e),g=i.map(e),t[15]=i,t[16]=r,t[17]=g}else g=t[17];let _;t[20]!==g||t[21]!==h?(_=(0,$.jsx)(`div`,{id:vf,className:`pointer-events-auto absolute top-[calc(var(--oc-safe-area-top,0px)+var(--oc-mobile-detail-navigation-height,3.5rem)+0.25rem)] w-[min(220px,calc(100vw-1rem))] origin-top-right overflow-hidden rounded-2xl oc-mobile-overlay-surface`,role:`menu`,style:h,onAnimationEnd:Yf,children:g}),t[20]=g,t[21]=h,t[22]=_):_=t[22];let v;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`style`,{children:`@keyframes mobile-menu-in { from { opacity: 0; transform: translateY(-6px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }`}),t[23]=v):v=t[23];let y;return t[24]!==_||t[25]!==u||t[26]!==p?(y=(0,$.jsxs)(`div`,{className:`pointer-events-none fixed inset-0 z-50`,role:`dialog`,"aria-modal":`true`,"aria-label":u,children:[p,_,v]}),t[24]=_,t[25]=u,t[26]=p,t[27]=y):y=t[27],y},Gf=Z.memo(function(e){let t=(0,Q.c)(88),{open:n,onOpenChange:r,currentSessionId:i,effectiveDirectory:a,gitDirectory:o,isNewSessionDraftOpen:s,primaryLabel:c,secondaryLabel:l}=e,{t:u}=ee(),{git:d}=pn(),f=Al(i??``,a||void 0),p=f??l,m=Z.useRef(null),h=Je(i??``,a||void 0),g=Nn(o),_=Pn(o),v=An(Xf),y=An(Zf),b=Ge(Qf),x=Ge($f),S=Ge(ep),C=Ge(tp),w;t[0]===i?w=t[1]:(w=e=>i?e.sessionModelSelections.get(i)??null:null,t[0]=i,t[1]=w);let T=pe(w),E=hr(np),D=hr(rp),O=hr(ip),k=hr(ap),A=hr(op),j=hr(sp),N=hr(cp),P=M(lp);sr();let F,I;t[2]!==v||t[3]!==d||t[4]!==o?(F=()=>{o&&v(o,d)},I=[v,d,o],t[2]=v,t[3]=d,t[4]=o,t[5]=F,t[6]=I):(F=t[5],I=t[6]),Z.useEffect(F,I);let L,R;t[7]!==y||t[8]!==d||t[9]!==o?(L=()=>{if(o)return qe.onGitRefreshHint(e=>{Mf(e.directory)===o&&y(o,d)})},R=[y,d,o],t[7]=y,t[8]=d,t[9]=o,t[10]=L,t[11]=R):(L=t[10],R=t[11]),Z.useEffect(L,R);let z,B;t[12]===D?(z=t[13],B=t[14]):(z=()=>{D()},B=[D],t[12]=D,t[13]=z,t[14]=B),Z.useEffect(z,B);let V,H;t[15]===j?(V=t[16],H=t[17]):(V=()=>{Ut(j)},H=[j],t[15]=j,t[16]=V,t[17]=H),Z.useEffect(V,H);let U,G;t[18]!==j||t[19]!==O||t[20]!==k||t[21]!==n||t[22]!==E?(U=()=>{!n||k||j.some(e=>!E.some(t=>t.providerId===e))&&O()},G=[j,O,k,n,E],t[18]=j,t[19]=O,t[20]=k,t[21]=n,t[22]=E,t[23]=U,t[24]=G):(U=t[23],G=t[24]),Z.useEffect(U,G);let K;t[25]===h?K=t[26]:(K=el(h),t[25]=h,t[26]=K);let te=K,q;if(t[27]!==h||t[28]!==S||t[29]!==x||t[30]!==C||t[31]!==s||t[32]!==te||t[33]!==b||t[34]!==T){let e=te??(T?{providerID:T.providerId,modelID:T.modelId}:null)??(x&&S?{providerID:x,modelID:S}:null),n=(e?b.find(t=>t.id===e.providerID):void 0)?.models.find(t=>t.id===e?.modelID),r=e?C(e.providerID,e.modelID):void 0,i=Xc(n?.limit,`context`)??r?.limit?.context??0,a;t[36]===h?a=t[37]:(a=tl(h),t[36]=h,t[37]=a),q=$c({totalTokens:a,contextLimit:i,isDraft:s}),t[27]=h,t[28]=S,t[29]=x,t[30]=C,t[31]=s,t[32]=te,t[33]=b,t[34]=T,t[35]=q}else q=t[35];let ne=q,re;t[38]!==_?.current||t[39]!==g||t[40]!==u?(re=g===!0?_?.current?.trim()||u(`gitView.branch.detachedHead`):u(`common.unavailable`),t[38]=_?.current,t[39]=g,t[40]=u,t[41]=re):re=t[41];let ie=re,ae;if(t[42]!==j||t[43]!==E||t[44]!==N||t[45]!==u){let e=new Map(E.map(up)),n;t[47]===j?n=t[48]:(n=e=>j.includes(e.id),t[47]=j,t[48]=n),ae=ar.filter(n).filter(t=>e.get(t.id)?.configured===!0).map(t=>{let n=e.get(t.id),r=[];for(let[e,t]of Object.entries(n?.usage?.windows??{}))r.push({key:`window-${e}`,label:on(e),window:t});let i=Object.entries(n?.usage?.models??{}),a=N[t.id]??[],o=a.length>0?i.filter(e=>{let[t]=e;return a.includes(t)}):i;for(let[e,t]of o){let n=Object.entries(t.windows??{});if(n.length===0)continue;let[i,a]=n[0];r.push({key:`model-${e}-${i}`,label:on(i),subtitle:tr(e),window:a})}let s=!n.ok&&n.error?n.error:r.length===0?u(`header.services.noRateLimitsReported`):null;return{providerId:t.id,providerName:t.name,rows:r,status:s}}),t[42]=j,t[43]=E,t[44]=N,t[45]=u,t[46]=ae}else ae=t[46];let oe=ae,se,J;t[49]!==n||t[50]!==oe?(se=()=>{!n||oe.length===0||Ut(oe.map(dp))},J=[n,oe],t[49]=n,t[50]=oe,t[51]=se,t[52]=J):(se=t[51],J=t[52]),Z.useEffect(se,J);let ce;t[53]===c?ce=t[54]:(ce=(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:c}),t[53]=c,t[54]=ce);let le;t[55]!==p||t[56]!==f?(le=p?(0,$.jsx)(`span`,{className:W(`block truncate`,f?`oc-mobile-detail-subtitle text-muted-foreground`:`typography-micro text-muted-foreground`),"aria-live":`polite`,children:p}):null,t[55]=p,t[56]=f,t[57]=le):le=t[57];let ue;t[58]!==ce||t[59]!==le?(ue=(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center px-2 py-1.5 text-left`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[ce,le]})}),t[58]=ce,t[59]=le,t[60]=ue):ue=t[60];let Y;t[61]===u?Y=t[62]:(Y=u(`mobile.header.openMetadataAria`),t[61]=u,t[62]=Y);let de;t[63]===r?de=t[64]:(de=()=>r(fp),t[63]=r,t[64]=de);let fe;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(fe={touchAction:`manipulation`},t[65]=fe):fe=t[65];let me=ne?.percentage??0,he;t[66]===me?he=t[67]:(he=(0,$.jsx)(Jc,{percentage:me}),t[66]=me,t[67]=he);let ge;t[68]!==n||t[69]!==Y||t[70]!==de||t[71]!==he?(ge=(0,$.jsx)(`button`,{ref:m,type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":Y,"aria-expanded":n,onClick:de,style:fe,children:he}),t[68]=n,t[69]=Y,t[70]=de,t[71]=he,t[72]=ge):ge=t[72];let _e;t[73]===r?_e=t[74]:(_e=()=>r(!1),t[73]=r,t[74]=_e);let ve;t[75]!==ie||t[76]!==ne||t[77]!==k||t[78]!==n||t[79]!==A||t[80]!==_e||t[81]!==P||t[82]!==oe?(ve=(0,$.jsx)(Hf,{open:n,onClose:_e,anchorRef:m,contextDisplay:ne,branchLabel:ie,usageGroups:oe,usageDisplayMode:A,isUsageLoading:k,timeFormatPreference:P}),t[75]=ie,t[76]=ne,t[77]=k,t[78]=n,t[79]=A,t[80]=_e,t[81]=P,t[82]=oe,t[83]=ve):ve=t[83];let ye;return t[84]!==ue||t[85]!==ge||t[86]!==ve?(ye=(0,$.jsxs)($.Fragment,{children:[ue,ge,ve]}),t[84]=ue,t[85]=ge,t[86]=ve,t[87]=ye):ye=t[87],ye}),Kf=({onOpenSessions:e,menuOpen:t,onToggleMenu:n,surfaceShortcuts:r})=>{let{t:i}=ee(),[a,o]=Z.useState(!1),s=T(e=>e.currentDirectory),c=Re(e=>e.currentSessionId),l=Z.useMemo(()=>e=>c?e.getDirectoryForSession(c):null,[c]),u=Re(l)||s,d=Mf(u)||null,f=Ve(e=>e.projects),p=Re(e=>e.availableWorktreesByProject),m=Z.useMemo(()=>e=>c?e.worktreeMetadata.get(c)??null:null,[c]),h=Re(m),g=ye(c),_=Re(e=>!!e.newSessionDraft?.open),v=Z.useMemo(()=>{let e=Mf(u);return e&&If((h?.projectDirectory?Qe(f,h.projectDirectory):null)??Ee(f,p,e),e)||i(`mobile.header.noProject`)},[p,h?.projectDirectory,u,f,i]),y=g?.title?.trim()||(c?i(`mobile.sessions.untitled`):v),b=c?v:``;Z.useEffect(()=>{o(!1)},[c,u]);let x=V(()=>{o(!1),e()}),S=V(()=>{o(!1),n()});return(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(xa,{children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":i(`mobile.sessions.openSheetAria`),onClick:x,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`folders`,className:`size-5`})}),(0,$.jsx)(Gf,{open:a,onOpenChange:o,currentSessionId:c,effectiveDirectory:u,gitDirectory:d,isNewSessionDraftOpen:_,primaryLabel:y,secondaryLabel:b}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,className:W(`flex size-10 shrink-0 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r.activePanel===`files`?`bg-[var(--interactive-selection)] text-[var(--interactive-selectionForeground)]`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),"aria-label":i(`mobile.menu.files`),"aria-pressed":r.activePanel===`files`,onClick:r.onToggleFiles,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`file-text`,className:`size-5`})}),(0,$.jsxs)(`button`,{type:`button`,className:W(`relative flex size-10 shrink-0 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r.activePanel===`changes`?`bg-[var(--interactive-selection)] text-[var(--interactive-selectionForeground)]`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),"aria-label":i(`mobile.menu.changes`),"aria-pressed":r.activePanel===`changes`,onClick:r.onToggleChanges,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-5`}),r.changesDirty?(0,$.jsx)(`span`,{className:`absolute right-2 top-2 inline-flex size-2 rounded-full bg-primary`,"aria-hidden":!0}):null]})]}):null,(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":i(`mobile.header.openMenuAria`),"aria-controls":vf,"aria-expanded":t,"aria-haspopup":`menu`,onClick:S,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`more-2`,className:`size-5`})})]})})},qf=({connection:e,onActiveConnectionDeleted:t})=>{let{t:n}=ee(),r=Ot();Te(),ge();let i=M(e=>e.mobileSessionPanelOpen),a=M(e=>e.setMobileSessionPanelOpen),o=M(e=>e.isScheduledTasksDialogOpen),s=M(e=>e.activeMainTab),c=ue(),l=M(e=>e.setActiveMainTab),[u,d]=Z.useState(!1),[f,p]=Z.useState(!1),[m,h]=Z.useState(null),[g,_]=Z.useState(!1),[v,y]=Z.useState(!1),[b,x]=Z.useState(null),[S,C]=Z.useState(null),[w,E]=Z.useState(null),[D,O]=Z.useState(0),[A,j]=Z.useState(!1),[N,P]=Z.useState(!1),[F,I]=Z.useState(!1),[L,R]=Z.useState(!1),[z,H]=Z.useState(!1),[U,K]=Z.useState(!1),[te,q]=Z.useState(`nav`),[ne,re]=Z.useState(!1),[ie,ae]=Z.useState(!1),oe=V(()=>re(e=>!e)),se=V(()=>re(!1)),[J,ce]=Z.useState(null),le=T(e=>e.currentDirectory),de=M(e=>e.setSettingsPage),fe=ir(e=>e.available),pe=ir(e=>e.runtimeType),me=Z.useMemo(()=>Of(),[]),he=Z.useMemo(()=>$l(),[]),{data:_e=[],refetch:ve}=ai(le??null,{enabled:A}),{refetch:ye}=oi(le??null,{enabled:A}),be=si(e=>e.setMcpDraft),xe=si(e=>e.setSelectedMcp),Se=Pn(Mf(le)||null)?.files?.length??0;Z.useEffect(()=>qe.onDirectoryRequest(()=>H(!0)),[]);let Ce=Z.useMemo(()=>k(),[]),we=ln()===`portrait`,[Ee,De]=Z.useState(Ce&&!we),[Oe,ke]=Z.useState(null),Me=V(e=>{if(e&&de(e),Ce){q(e?`page-content`:`nav`),I(!0);return}let t=We.getState();if(e){t.openSettingsFromCurrent();return}de(`home`),t.setActiveTab(`settings`)}),Ne=V(()=>{Me(`instances`)}),Pe=V(()=>{We.getState().openInstances()}),Fe=V(()=>{We.getState().closeSecondary()}),Ie=V(async()=>{if(!U){K(!0);try{let t=await eu();switch(t.status){case`ok`:await e.connect({url:t.url,clientToken:t.clientToken,label:t.label});break;case`pairing`:await e.redeemPairingConnection(t.pairing);break;case`permission-denied`:B.error(n(`mobile.connect.scan.permissionDenied`));break;case`invalid`:B.error(n(`mobile.connect.scan.invalid`));break;case`unsupported`:B.error(n(`mobile.connect.scan.unsupported`));break;case`failed`:B.error(n(`mobile.connect.scan.failed`))}}finally{K(!1)}}});Rn({enabled:!Ce,rootRoutesBlocked:i||u||f||g||v||o||A||F||L||z||ne});let Le=V(()=>{let e=!Ee;e&&we&&ke(null),De(e)}),ze=V(()=>{if(y(!1),x(null),C(null),p(!1),h(null),Ce){ce(null),ke(`files`),we&&De(!1);return}d(!0)}),Be=V(()=>{p(!1),h(null)}),Ve=V(e=>{let t=e.path.trim();if(t){if(y(!1),x(null),C(null),ce(null),_(!1),Ce){M.getState().setPendingFileFocusPath(t),ke(`files`),we&&De(!1);return}d(!1),h({path:t,targetLine:typeof e.targetLine==`number`&&Number.isFinite(e.targetLine)?Math.max(1,Math.trunc(e.targetLine)):void 0}),p(!0)}}),He=M(e=>e.pendingFileFocusPath);Z.useEffect(()=>{if(He){if(Ce){ze();return}Ve({path:He}),M.getState().setPendingFileFocusPath(null)}},[He,Ce,ze,Ve]);let Ue=V((e=null)=>{if(y(!1),x(null),C(null),E(null),p(!1),h(null),ce(e),Ce){ke(`changes`),we&&De(!1);return}_(!0)}),Ge=V((e,t,n)=>{ce(null),_(!1),p(!1),h(null),x(e??null),C(typeof t==`string`&&t.trim()?t.trim():null);let r=typeof n==`string`&&n.trim()?n.trim():null;if(E(r),O(e=>e+1),Ce){ke(`turn-diff`),we&&De(!1);return}y(!0)}),Ke=V(()=>{ke(null),ce(null),E(null)}),Je=V(e=>{if(Oe===e){Ke();return}e===`files`?ze():Ue()}),Ye=Z.useRef(`changes`);Oe&&(Ye.current=Oe);let[Xe,Ze]=Z.useState(!1);Z.useEffect(()=>{if(!Ce)return;if(Oe){Ze(!0);return}let e=window.setTimeout(()=>Ze(!1),240);return()=>window.clearTimeout(e)},[Oe,Ce]);let Qe=Oe??Ye.current,$e=Ef(`left`,`openchamber.ipad.leftSidebarWidth`,yf),et=Ef(`right`,`openchamber.ipad.rightSidebarWidth`,bf),tt=Z.useMemo(()=>({openChanges:({diffPath:e,staged:t,targetLine:n}={})=>{Ue(e?{path:e,staged:t===!0,targetLine:n}:null)},openToolDiff:({diffPath:e,patches:t,targetLine:n})=>{Ue({path:e,staged:!1,targetLine:n,toolPatches:t})},openTurnDiff:Ge,openFile:({path:e,targetLine:t})=>{Ve({path:e,targetLine:t})},openFiles:()=>ze(),openSettings:e=>{Me(e)}}),[Ue,Ve,ze,Me,Ge]),nt=V(()=>{_(!1),ce(null)}),rt=V(()=>{y(!1),E(null)});Cu(Z.useMemo(()=>({openSessions:()=>{if(Ce){De(!0);return}We.getState().setActiveTab(`projects`)},openView:e=>{e===`files`?ze():e===`mcp`?j(!0):e===`instances`?Ne():e===`update`&&R(!0)},openChanges:({path:e,staged:t}={})=>{Ue(e?{path:e,staged:t===!0}:null)},openSettings:e=>{Me(e)}}),[Ce,Ue,ze,Ne,Me]));let it=Z.useRef(null),at=Z.useRef(null),ot=Z.useRef(null),st=Z.useRef(null),ct=Z.useRef(null),lt=Z.useRef(null),ut=Re(e=>e.currentSessionId),dt=Re(e=>e.setCurrentSession),ft=Z.useMemo(()=>e=>ut?e.getDirectoryForSession(ut):null,[ut]),pt=Re(ft),mt=je(ut,pt||le||void 0),ht=Ae(ut??``);lf();let gt=ht?.type===`busy`||ht?.type===`retry`,_t=V(()=>{let e=ut;if(!e||ie||gt)return;let t=pt||le||void 0;ae(!0),(async()=>{try{await r.refreshSessionTranscript(e,{directory:t}),B.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{B.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{ae(!1)}})()}),vt=V(e=>{lt.current=e}),yt=V(e=>{let t=ot.current,n=st.current,r=ct.current;if(!t)return;if(!e){t.style.transform=``,t.style.opacity=``,t.style.willChange=``,n&&(n.style.transform=``,n.style.willChange=``),r&&(r.style.transform=``,r.style.willChange=``);return}t.style.willChange||t.getAnimations().forEach(e=>e.cancel()),t.style.willChange=`transform, opacity`,t.style.transform=`translate3d(${e.offsetX}px, 0, 0)`,t.style.opacity=String(1-e.progress*.08),n&&(n.style.willChange=`transform`,n.style.transform=`translate3d(${e.offsetX}px, 0, 0)`),r&&(r.style.willChange=`transform`,r.style.transform=`translate3d(${e.offsetX}px, 0, 0)`);let i=e.direction===`prev`?n:r;i&&Array.from(i.children).forEach(t=>{t instanceof HTMLElement&&(t.style.opacity=e.canSwitch?`1`:`0.35`)})}),bt=We(e=>e.secondary?.kind??null),xt=!Ce&&(bt===`chat`||bt===`draft`);Z.useEffect(()=>{!Ce&&!xt&&re(!1)},[Ce,xt]),Z.useEffect(()=>{re(!1)},[ut]),Hu(at,{onSwitch:vt,onProgress:yt},Ce||xt);let St=Ce&&s===`assistant`||!Ce&&!xt||i||u||f||g||v||o||A||F||L||z||ne;cd(at,{onOpen:V(()=>{xn(Sn)?.finish(`commit`)}),onPreviewStart:V(()=>{xn(Sn)?.begin(`present`)}),onPreviewCancel:V(()=>{xn(Sn)?.finish(`cancel`)}),onProgress:V(e=>{e!==null&&xn(Sn)?.update(e)}),disabled:St},Ce||xt),Z.useLayoutEffect(()=>{let e=lt.current;if(lt.current=null,!e)return;let t=ot.current;if(!t||typeof t.animate!=`function`)return;t.getAnimations().forEach(e=>e.cancel());let n=e===`prev`?-70:70;t.animate([{opacity:.1,transform:`translateX(${n}px)`},{opacity:1,transform:`translateX(0)`}],{duration:300,easing:`cubic-bezier(0.22, 1, 0.36, 1)`})},[ut]);let Ct=V(e=>{it.current=e});jf(V(()=>ne?(re(!1),!0):z?(H(!1),!0):o?(window.dispatchEvent(new Event(`oc:scheduled-tasks-close-request`)),!0):i?(a(!1),!0):Hn.backImmediately(`overlay`)?!0:f?(Be(),!0):u?(d(!1),!0):v?(rt(),!0):g?(nt(),!0):A?(j(!1),!0):F?(I(!1),!0):L?(R(!1),!0):Hn.requestAnimatedBack(`root`)||it.current?.()?!0:s===`assistant`?(l(`chat`),!0):mt?(dt(mt.id,mt.directory),!0):!1));let wt=fe&&(pe===`desktop`||pe===`web`),Tt=V(()=>{let e=`new-mcp-server`,t=e,n=1;for(;_e.some(e=>e.name===t);)t=`${e}-${n}`,n+=1;be({name:t,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),xe(t),j(!1),Me(`mcp`)}),Et=V(()=>{if(N)return;P(!0);let e=new Promise(e=>window.setTimeout(e,500));Promise.all([ye(),ve(),e]).finally(()=>P(!1))}),Dt=Re(e=>e.openNewSessionDraft),kt=Z.useMemo(()=>{let e=[{key:`new-session`,icon:`chat-new`,label:n(`mobile.menu.newSession`),onSelect:()=>{if(Ce){l(`chat`),Dt();return}We.getState().openDraft()}}];return Ce||e.push({key:`files`,icon:`file-text`,label:n(`mobile.menu.files`),onSelect:()=>ze()},{key:`changes`,icon:`git-branch`,label:n(`mobile.menu.changes`),badge:Se,onSelect:()=>Ue()}),e.push({key:`mcp`,iconNode:(0,$.jsx)(rr,{className:`size-5 shrink-0 text-muted-foreground`}),label:n(`mobile.menu.mcp`),onSelect:()=>j(!0)}),wt&&e.push({key:`update`,icon:`download`,label:n(`mobile.menu.update`),onSelect:()=>R(!0)}),Ce&&e.push({key:`settings`,icon:`settings-3`,label:n(`mobile.menu.settings`),onSelect:()=>Me()}),ut&&e.push({key:`refresh-transcript`,icon:`refresh`,label:n(`sessions.sidebar.session.menu.refreshTranscript`),disabled:ie||gt,spinning:ie,onSelect:_t}),e},[ut,Se,Ce,gt,ie,Ue,ze,Dt,Me,_t,l,wt,n]);return(0,$.jsxs)(Dn,{actions:tt,children:[(0,$.jsxs)(`div`,{className:`oc-mobile-app-shell main-content-safe-area flex h-[100dvh] flex-row text-foreground`,"data-page-scroll-lock":`true`,children:[Ce?(0,$.jsxs)(`aside`,{ref:$e.asideRef,className:W(`relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/50 bg-sidebar will-change-[width] motion-reduce:transition-none`,!Ee&&`border-r-0`),style:{width:Ee?$e.width:0,minWidth:Ee?$e.width:0,maxWidth:Ee?$e.width:0,"--oc-ipad-sidebar-width":`${$e.width}px`,overflowX:`clip`,paddingTop:`var(--oc-safe-area-top, 0px)`,transitionProperty:$e.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!Ee,"data-page-scroll-lock":`true`,children:[Ee?(0,$.jsx)(Df,{side:`left`,isResizing:$e.isResizing,ariaLabel:n(`sidebar.resize.leftPanelAria`),handleProps:$e.handleProps}):null,(0,$.jsx)(`div`,{className:W(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,$e.isResizing&&`pointer-events-none`,!Ee&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:(0,$.jsx)(nn,{children:(0,$.jsx)(Zo,{open:!0,variant:`sidebar`,onOpenChange:e=>{!e&&we&&De(!1)}})})})]}):null,(0,$.jsx)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,"data-page-scroll-lock":`true`,children:Ce?(0,$.jsxs)($.Fragment,{children:[s===`assistant`?null:(0,$.jsx)(`div`,{children:(0,$.jsx)(Kf,{onOpenSessions:()=>Le(),menuOpen:ne,onToggleMenu:oe,surfaceShortcuts:{activePanel:Oe===`turn-diff`?`changes`:Oe,changesDirty:Se>0,onToggleFiles:()=>Je(`files`),onToggleChanges:()=>Je(`changes`)}})}),(0,$.jsxs)(`main`,{ref:at,className:`relative min-h-0 flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:[(0,$.jsxs)(`div`,{ref:st,"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 -left-full flex w-full items-center justify-end gap-3 bg-background pr-4`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-medium tracking-wide text-muted-foreground/60`,children:n(`helpDialog.item.previousSession`)}),(0,$.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-full border border-border/70 bg-[var(--surface-elevated)] text-foreground shadow-sm`,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})})]}),(0,$.jsxs)(`div`,{ref:ct,"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 left-full flex w-full items-center justify-start gap-3 bg-background pl-4`,children:[(0,$.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-full border border-border/70 bg-[var(--surface-elevated)] text-foreground shadow-sm`,children:(0,$.jsx)(X,{name:`arrow-right`,className:`size-5`})}),(0,$.jsx)(`span`,{className:`typography-micro font-medium tracking-wide text-muted-foreground/60`,children:n(`helpDialog.item.nextSession`)})]}),(0,$.jsx)(`div`,{ref:ot,className:`relative h-full w-full bg-background`,children:(0,$.jsx)(nn,{children:s===`assistant`?(0,$.jsx)(Ci,{}):(0,$.jsx)(zr,{})})})]})]}):(0,$.jsx)(kc,{className:`min-h-0 flex-1`,onAddProject:()=>H(!0),onScanQr:me&&he?()=>{Ie()}:void 0,onSwitchInstance:me?Pe:void 0,onEnableAssistants:()=>{Me(`assistants`)},instancesPage:me?(0,$.jsx)(zf,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t}):void 0,instancesSecondaryPage:me?(0,$.jsxs)(`div`,{className:`oc-settings-workspace oc-settings-workspace-mobile flex h-full min-h-0 flex-col bg-[var(--surface-background)]`,children:[(0,$.jsx)(Y,{title:n(`mobile.settings.switchInstance`),backAriaLabel:n(`header.actions.backAria`),onBack:Fe}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-[var(--oc-mobile-page-inline-inset)]`,children:(0,$.jsx)(ur,{className:`oc-mobile-settings-detail-card`,children:(0,$.jsx)(zf,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t})})})]}):void 0,parentSessionTarget:mt?{id:mt.id,directory:mt.directory}:null,registerSecondaryBackHandler:Ct,scheduledContent:(e,t)=>(0,$.jsx)(Br,{presentation:`mobile-tab`,registerEditorBackHandler:e,onEditorActiveChange:t}),renderChat:e=>(0,$.jsx)(Fl,{sessionId:e.sessionId,directory:e.directory,onBack:()=>{se(),Hn.requestAnimatedBack(`root`)},onOpenMenu:oe,onCloseMenu:se,menuOpen:e.active&&ne,children:(0,$.jsxs)(`main`,{ref:e.active?at:void 0,className:`relative h-full min-h-0 flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:[e.active?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{ref:st,"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 -left-full flex w-full items-center justify-end gap-3 bg-background pr-4`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-medium tracking-wide text-muted-foreground/60`,children:n(`helpDialog.item.previousSession`)}),(0,$.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-full border border-border/70 bg-[var(--surface-elevated)] text-foreground shadow-sm`,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})})]}),(0,$.jsxs)(`div`,{ref:ct,"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 left-full flex w-full items-center justify-start gap-3 bg-background pl-4`,children:[(0,$.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-full border border-border/70 bg-[var(--surface-elevated)] text-foreground shadow-sm`,children:(0,$.jsx)(X,{name:`arrow-right`,className:`size-5`})}),(0,$.jsx)(`span`,{className:`typography-micro font-medium tracking-wide text-muted-foreground/60`,children:n(`helpDialog.item.nextSession`)})]})]}):null,(0,$.jsx)(`div`,{ref:e.active?ot:void 0,className:`relative h-full w-full bg-background`,children:(0,$.jsx)(nn,{children:(0,$.jsx)(zr,{readOnly:!e.active,active:e.active,selectionOverride:{sessionId:e.sessionId||null,directory:e.directory,viewKey:e.viewKey}})})})]})})})}),Ce?(0,$.jsxs)(`aside`,{ref:et.asideRef,className:W(`relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/50 bg-background will-change-[width] motion-reduce:transition-none`,!Oe&&`border-l-0`),style:{width:Oe?et.width:0,minWidth:Oe?et.width:0,maxWidth:Oe?et.width:0,"--oc-ipad-sidebar-width":`${et.width}px`,overflowX:`clip`,paddingTop:`var(--oc-safe-area-top, 0px)`,transitionProperty:et.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!Oe,"data-page-scroll-lock":`true`,children:[Oe?(0,$.jsx)(Df,{side:`right`,isResizing:et.isResizing,ariaLabel:n(`sidebar.resize.rightPanelAria`),handleProps:et.handleProps}):null,(0,$.jsx)(`div`,{className:W(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,et.isResizing&&`pointer-events-none`,!Oe&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:Xe?(0,$.jsx)(nn,{children:Qe===`files`?(0,$.jsx)(ho,{onClose:Ke}):Qe===`turn-diff`?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/40 px-3`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground`,children:n(`mobile.nav.changes`)}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ke,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(Sr,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:b,sessionId:S,targetFilePath:w,navigationRequestKey:D,flushContent:!0})})]}):J?.toolPatches?.length?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/40 px-3`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground`,children:J.toolPatches.length>1?n(`mobile.nav.changes`):J.path}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ke,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(Sr,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:J.path,targetLine:J.targetLine??null,toolPatches:J.toolPatches,singleFileView:J.toolPatches.length===1,flushContent:!0})})]}):(0,$.jsx)(Fa,{onClose:Ke,initialDiffPath:J?.path??null,initialDiffStaged:J?.staged===!0,initialDiffTargetLine:J?.targetLine??null})}):null})]}):null,(0,$.jsx)(Yr,{open:z,onOpenChange:H,forceMobile:!0}),(0,$.jsx)(Wf,{open:ne,onClose:()=>re(!1),items:kt,rightOffset:Ce&&Oe?et.width:0}),(0,$.jsx)(Rr,{}),u?(0,$.jsx)(yn,{id:pf,open:u,onOpenChange:e=>{e||d(!1)},ariaLabel:n(`mobile.menu.files`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(nn,{children:(0,$.jsx)(ho,{onClose:()=>d(!1)})})}):null,f&&m?(0,$.jsx)(yn,{id:ff,open:f,onOpenChange:e=>{e||Be()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:m.path.split(/[/\\]/).filter(Boolean).at(-1)??m.path}),ariaLabel:n(`mobile.menu.files`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(nn,{children:(0,$.jsx)(ho,{onClose:Be,initialFilePath:m.path,directFilePreview:!0,hideFileHeader:!0},m.path)})}):null,(0,$.jsx)(yn,{id:df,open:v,onOpenChange:e=>{e||rt()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mobile.nav.changes`)}),ariaLabel:n(`mobile.nav.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(nn,{children:(0,$.jsx)(Sr,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:b,sessionId:S,targetFilePath:w,navigationRequestKey:D,flushContent:!0})})}),g&&J?(0,$.jsx)(yn,{id:uf,open:g,onOpenChange:e=>{e||nt()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:J.toolPatches&&J.toolPatches.length>1?n(`mobile.nav.changes`):J.path}),ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(nn,{children:J.toolPatches?.length?(0,$.jsx)(Sr,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:J.path,targetLine:J.targetLine??null,toolPatches:J.toolPatches,singleFileView:J.toolPatches.length===1,flushContent:!0}):(0,$.jsx)(Fa,{initialDiffPath:J.path,initialDiffStaged:J.staged,initialDiffTargetLine:J.targetLine??null,hideDiffHeader:!0})})}):g?(0,$.jsx)(yn,{id:mf,open:g,onOpenChange:e=>{e||nt()},ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(nn,{children:(0,$.jsx)(Fa,{onClose:nt,initialDiffPath:J?.path??null,initialDiffStaged:J?.staged===!0,initialDiffTargetLine:J?.targetLine??null})})}):null,A?(0,$.jsx)(yn,{id:hf,open:A,onOpenChange:e=>{e||j(!1)},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mcpDropdown.title`)}),trailing:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,onClick:Tt,"aria-label":n(`settings.mcp.sidebar.actions.addServerTitle`),title:n(`settings.mcp.sidebar.actions.addServerTitle`),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`add`,className:`size-5`})}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,onClick:Et,disabled:N,"aria-label":n(`mcpDropdown.actions.refreshAria`),title:n(`mcpDropdown.actions.refreshAria`),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`refresh`,className:W(`size-5`,N&&`animate-spin`)})})]}),ariaLabel:n(`mcpDropdown.title`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(nn,{children:(0,$.jsx)(Ur,{active:!0,className:`h-full`,listClassName:`max-h-none`,hideHeader:!0,mobileListDensity:!0})})}):null,F&&Ce?(0,$.jsx)(yn,{id:gf,open:F,onOpenChange:e=>{e||I(!1)},ariaLabel:n(`mobile.menu.settings`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(nn,{children:(0,$.jsx)(mi,{forceMobile:!0,isWindowed:!0,initialMobileStage:te,visiblePageSlugs:[...dr],onClose:()=>I(!1),mobileInstancesPage:me?(0,$.jsx)(zf,{connection:e,onConnect:()=>I(!1),onActiveConnectionDeleted:t}):void 0})})}):null,L?(0,$.jsx)(yn,{id:_f,open:L,onOpenChange:e=>{e||R(!1)},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mobile.menu.update`)}),ariaLabel:n(`mobile.menu.update`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(nn,{children:(0,$.jsx)(`div`,{className:`h-full overflow-auto px-5 py-4`,children:(0,$.jsx)(hi,{initialUpdateDialogOpen:!0})})})}):null]}),(0,$.jsx)(di,{enabled:me&&s===`assistant`&&c.data?.supported===!0&&c.data?.enabled===!0}),(0,$.jsx)(nn,{children:(0,$.jsx)(ti,{})})]})};function Jf({apis:e}){Z.useEffect(()=>He(),[]);let{t}=ee(),n=Ge(e=>e.initializeApp),r=Ge(e=>e.isInitialized),i=Ge(e=>e.isConnected),o=Ge(e=>e.connectionPhase),s=T(e=>e.currentDirectory),l=Re(e=>e.currentSessionId),d=Re(e=>!!e.newSessionDraft?.open),f=Re(e=>e.error),p=Re(e=>e.clearError),m=M(e=>e.setIsMobile),h=cr(e=>e.refreshStatus),g=Ve(e=>e.projects),[v,y]=Z.useState(0),[b,x]=Z.useState(0),[S,C]=Z.useState(!1),[w,D]=Z.useState(`pending`),O=Z.useMemo(()=>ae(),[]),[,k]=Z.useReducer(e=>e+1,0),A=Z.useMemo(()=>Of(),[]),j=Z.useRef(0),N=Z.useRef(0),P=ie(()=>{D(`done`),y(e=>e+1)});wu(V(e=>{P.redeemPairingConnection(e)}));let F=Tu({ready:A&&i&&r});Z.useEffect(()=>{!P.error||!u()||B.error(P.error)},[P.error]);let I=V(()=>{let t=u(),r=N.current+1;if(N.current=r,!t){se();return}let i=()=>{n(),h(e.github,{force:!0}),Ge.getState().refreshMissingCatalogs({source:`mobileApp:nativeResume`})},a=()=>{c({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),y(e=>e+1)};re().then(e=>{if(N.current===r){if(e===`no-connection`){a();return}if(e===`unreachable`){window.setTimeout(()=>{N.current===r&&re().then(e=>{if(N.current===r&&e!==`switched`&&e===`unchanged`){i();return}})},4e3);return}e!==`switched`&&i()}});let o=Date.now();o-j.current>=Pf&&(j.current=o,window.dispatchEvent(new Event(`openchamber:system-resume`)))});kf(),Af(I),Z.useEffect(()=>{if(!A)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>I(),1500)};return window.addEventListener(`online`,t),()=>{window.removeEventListener(`online`,t),window.clearTimeout(e)}},[A,I]),Z.useEffect(()=>(_(e),()=>_(null)),[e]),Z.useEffect(()=>{A&&R().then(e=>{e&&e.notifyAppReady().catch(()=>void 0)})},[A]),Z.useEffect(()=>{if(!A)return;let e=!1,t=[];return R().then(async n=>{if(!(!n||e))try{let r=await n.addListener(`download`,e=>{ir.getState().setOtaDownloadPercent(e.percent)}),i=await n.addListener(`downloadFailed`,()=>{ir.getState().setOtaDownloadFailed()}),a=await n.addListener(`downloadComplete`,()=>{ir.getState().setOtaPhase(`pending_restart`)}),o=await n.addListener(`appReloaded`,()=>{ir.getState().setOtaPhase(`pending_restart`)}),s=await n.addListener(`autoRevert`,()=>{console.warn(`[OTA] Capgo auto-reverted the last bundle`),ir.getState().setOtaPhase(`error`,`OTA update was reverted`)});if(e){r.remove(),i.remove(),a.remove(),o.remove(),s.remove();return}t.push(()=>void r.remove(),()=>void i.remove(),()=>void a.remove(),()=>void o.remove(),()=>void s.remove())}catch(e){console.warn(`[OTA] Failed to subscribe to Capgo updater events:`,e)}}),()=>{e=!0;for(let e of t)e()}},[A]),Z.useEffect(()=>a(e=>{if(e.runtimeKey&&e.runtimeKey===e.previousRuntimeKey){Qr(),k();return}qr(e),We.getState().reset(),x(e=>e+1),y(e=>e+1)}),[]),Z.useEffect(()=>{if(F===`pending`)return;if(F===`connect`){D(`done`);return}if(!A||i||u()){D(`done`);return}let e=!1;return D(`attempting`),oe().then(e=>e?!0:se()).catch(()=>!1).then(()=>{e||D(`done`)}),()=>{e=!0}},[F]),Z.useEffect(()=>{m(!0)},[m]),Z.useEffect(()=>{A&&!u()||n()},[v,n,A]),bt({enabled:!A||!!u(),source:`mobileApp:recovery`}),Z.useEffect(()=>{i&&E.setDirectory(s)},[s,i]),Z.useEffect(()=>{i&&h(e.github,{force:!0})},[e.github,i,h]),Z.useEffect(()=>{if(!i||g.length===0)return;let e=!1;return(async()=>{await Promise.all(g.map(async t=>{let n=Mf(t.path);if(n)try{if(!(An.getState().directories.get(n)?.isGitRepo??await L(()=>import(`./gitApi-yuWg9BN4.js`).then(e=>e.S).then(e=>e.checkIsGitRepository(n)),__vite__mapDeps([57,1,4,3,2,24,7,5,6,8,25,26,35,36,10,37,38,39,20,21,22,23,27,28,29,40,41,42])))||e)return;await Gt({id:t.id,path:n},{isCurrent:()=>!e})}catch{}}))})(),()=>{e=!0}},[i,g]),Z.useEffect(()=>{if(!f)return;let e=window.setTimeout(()=>p(),5e3);return()=>window.clearTimeout(e)},[p,f]),Z.useEffect(()=>{if(!(!i&&(!A||u()))){C(!1);return}let e=window.setTimeout(()=>C(!0),8e3);return()=>window.clearTimeout(e)},[i,A,v,b]),Mt(),ut({enabled:!0}),gt(),Nr(),dd({enabled:A&&i});let z=iu(),H=!i&&o===`reconnecting`;if(!z)return(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(rn,{width:120,height:120,isAnimated:!0})});let U=!!u();return A&&(!U||!i&&!H)?U?(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-4`,children:[(0,$.jsx)(rn,{width:120,height:120,isAnimated:!S}),S?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h1`,{className:`typography-h3 text-foreground`,children:t(`sessionAuth.error.networkTitle`)}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:t(`sessionAuth.error.networkDescription`)})]}),(0,$.jsx)(G,{type:`button`,variant:`outline`,onClick:()=>{c({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),y(e=>e+1)},children:t(`mobile.connect.cancelPassword`)})]}):null]})}):w===`done`?(0,$.jsx)(Rf,{connection:P}):(0,$.jsxs)(`main`,{className:`relative flex min-h-dvh items-center justify-center bg-background text-foreground`,children:[(0,$.jsx)(rn,{width:120,height:120,isAnimated:!0}),O?(0,$.jsxs)(`div`,{className:`absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center`,children:[(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:t(`mobile.connect.splash.connectingTo`)}),(0,$.jsxs)(`p`,{className:`typography-small text-foreground`,children:[O,(0,$.jsx)(Pt,{})]})]}):null]}):!i&&!H?S?(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground`,children:(0,$.jsxs)(`div`,{className:`max-w-sm space-y-3`,children:[(0,$.jsx)(`h1`,{className:`typography-h3 text-foreground`,children:t(`sessionAuth.error.networkTitle`)}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:t(`sessionAuth.error.networkDescription`)})]})}):(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(rn,{width:120,height:120,isAnimated:!0})}):(0,$.jsx)(nn,{children:(0,$.jsx)(ve,{sdk:E.getSdkClient(),directory:s||``,bootstrapDirectory:!(d&&l===null),children:(0,$.jsx)(wt,{apis:e,children:(0,$.jsx)(qt,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:`h-full bg-background text-foreground`,children:[(0,$.jsx)(Vr,{}),(0,$.jsx)(J,{}),(0,$.jsx)(Et,{embeddedBackgroundWorkEnabled:r}),(0,$.jsx)(Jr,{}),(0,$.jsx)($i,{}),(0,$.jsx)(la,{}),(0,$.jsx)(qf,{connection:P,onActiveConnectionDeleted:()=>{c({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),We.getState().reset(),y(e=>e+1)}}),(0,$.jsx)(Tt,{position:`top-center`,offset:`calc(var(--oc-safe-area-top, 0px) + 16px)`}),r?(0,$.jsx)($r,{}):null]})})})},b)})}function Yf(e){e.currentTarget.style.transform=`none`}function Xf(e){return e.ensureStatus}function Zf(e){return e.fetchStatus}function Qf(e){return e.providers}function $f(e){return e.currentProviderId}function ep(e){return e.currentModelId}function tp(e){return e.getModelMetadata}function np(e){return e.results}function rp(e){return e.loadSettings}function ip(e){return e.fetchAllQuotas}function ap(e){return e.isLoading}function op(e){return e.displayMode}function sp(e){return e.dropdownProviderIds}function cp(e){return e.selectedModels}function lp(e){return e.timeFormatPreference}function up(e){return[e.providerId,e]}function dp(e){return e.providerId}function fp(e){return!e}var pp=()=>{te(),h().then(()=>{Promise.all([m(),ht()]).catch(e=>{console.error(`[mobile-main] settings init failed:`,e)}),It(),xt(),Lt()}).catch(e=>{console.error(`[mobile-main] appearance init failed:`,e)}).finally(()=>{zi()})};function mp(e){Gn(),pp(),M.getState().setIsMobile(!0),qi(),un(),dn();let t=document.getElementById(`root`);if(!t)throw Error(`Root element not found`);let n=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`;n&&document.documentElement.classList.add(`oc-native-app-active`);let r=n?{...e,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:e,i=(0,$.jsx)(Jf,{apis:r});(0,Fi.createRoot)(t).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(Ft,{children:(0,$.jsx)(U,{children:(0,$.jsx)(_t,{children:(0,$.jsx)(mt,{children:(0,$.jsx)(Fr,{children:n?i:(0,$.jsx)(Dt,{children:i})})})})})})}))}export{mp as renderMobileApp};
|
|
28
|
+
`}),t[52]=K):K=t[52];let te;return t[53]===G?te=t[54]:(te=(0,$.jsxs)(`div`,{ref:y,className:`fixed inset-x-0 bottom-0 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-header-height,56px))] z-20 pointer-events-none`,children:[G,K]}),t[53]=G,t[54]=te),te},Gf=e=>{let t=(0,Q.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=ee(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(X,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,$.jsx)(X,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,$.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(Vt,{providerId:e.providerId,className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground`,children:e.providerName}),e.status&&e.rows.length===0?(0,$.jsx)(`span`,{className:`shrink-0 truncate typography-micro text-muted-foreground`,children:e.status}):null]}),e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:e.rows.map(e=>{let t=r===`remaining`?e.window.remainingPercent:e.window.usedPercent,n=an(e.window.valueLabel,t),i=$t(e.window.resetAt,e.window.resetAfterFormatted??e.window.resetAtFormatted,a);return(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-3`,children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-muted-foreground`,children:e.subtitle?`${e.subtitle} · ${e.label}`:e.label}),i?(0,$.jsx)(`span`,{className:`shrink-0 truncate typography-micro text-muted-foreground/70`,children:i}):null]}),(0,$.jsx)(`span`,{className:W(`shrink-0 typography-ui-label font-semibold tabular-nums`,Hf(e.window)),children:n===`-`?``:n})]},e.key)})}):null,e.status&&e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 typography-micro text-muted-foreground`,children:e.status}):null]},e.providerId),t[22]=r,t[23]=a,t[24]=e):e=t[24],g=n.map(e),t[18]=r,t[19]=n,t[20]=a,t[21]=g}else g=t[21];let _;t[25]===g?_=t[26]:(_=(0,$.jsx)(`div`,{className:`space-y-1.5`,children:g}),t[25]=g,t[26]=_);let v;return t[27]!==_||t[28]!==h?(v=(0,$.jsxs)(`div`,{className:`pt-2.5`,children:[h,_]}),t[27]=_,t[28]=h,t[29]=v):v=t[29],v},Kf=e=>{let t=(0,Q.c)(28),{open:n,onClose:r,items:i,rightOffset:a}=e,o=a===void 0?0:a,{t:s}=ee(),c,l;if(t[0]!==r||t[1]!==n?(c=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},l=[r,n],t[0]=r,t[1]=n,t[2]=c,t[3]=l):(c=t[2],l=t[3]),Z.useEffect(c,l),!n)return null;let u;t[4]===s?u=t[5]:(u=s(`mobile.menu.titleAria`),t[4]=s,t[5]=u);let d;t[6]===s?d=t[7]:(d=s(`mobile.surface.closeAria`),t[6]=s,t[7]=d);let f;t[8]===r?f=t[9]:(f=e=>{e.preventDefault(),r()},t[8]=r,t[9]=f);let p;t[10]!==d||t[11]!==f?(p=(0,$.jsx)(`button`,{type:`button`,className:`pointer-events-auto absolute inset-x-0 bottom-0 cursor-default top-[calc(var(--oc-safe-area-top,0px)+var(--oc-mobile-detail-navigation-height,3.5rem)+0.25rem)]`,"aria-label":d,onPointerDown:f}),t[10]=d,t[11]=f,t[12]=p):p=t[12];let m=`max(1rem, calc(8px + ${o}px + var(--oc-safe-area-right, 0px)))`,h;t[13]===m?h=t[14]:(h={right:m,animation:`mobile-menu-in 160ms cubic-bezier(0.32, 0.72, 0, 1) forwards`},t[13]=m,t[14]=h);let g;if(t[15]!==i||t[16]!==r){let e;t[18]===r?e=t[19]:(e=(e,t)=>(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,className:W(`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,t>0&&`border-t border-border/30`,e.disabled&&`cursor-not-allowed opacity-60`),style:{touchAction:`manipulation`},disabled:e.disabled,onClick:()=>{e.onSelect(),r()},children:[e.iconNode??(e.icon?(0,$.jsx)(X,{name:e.icon,className:W(`size-5 shrink-0 text-muted-foreground`,e.spinning&&`animate-spin`)}):null),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:e.label}),e.badge&&e.badge>0?(0,$.jsx)(`span`,{className:`inline-flex size-2 shrink-0 rounded-full bg-primary`,"aria-hidden":!0}):null]},e.key),t[18]=r,t[19]=e),g=i.map(e),t[15]=i,t[16]=r,t[17]=g}else g=t[17];let _;t[20]!==g||t[21]!==h?(_=(0,$.jsx)(`div`,{id:bf,className:`pointer-events-auto absolute top-[calc(var(--oc-safe-area-top,0px)+var(--oc-mobile-detail-navigation-height,3.5rem)+0.25rem)] w-[min(220px,calc(100vw-1rem))] origin-top-right overflow-hidden rounded-2xl oc-mobile-overlay-surface`,role:`menu`,style:h,onAnimationEnd:Zf,children:g}),t[20]=g,t[21]=h,t[22]=_):_=t[22];let v;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`style`,{children:`@keyframes mobile-menu-in { from { opacity: 0; transform: translateY(-6px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }`}),t[23]=v):v=t[23];let y;return t[24]!==_||t[25]!==u||t[26]!==p?(y=(0,$.jsxs)(`div`,{className:`pointer-events-none fixed inset-0 z-50`,role:`dialog`,"aria-modal":`true`,"aria-label":u,children:[p,_,v]}),t[24]=_,t[25]=u,t[26]=p,t[27]=y):y=t[27],y},qf=Z.memo(function(e){let t=(0,Q.c)(88),{open:n,onOpenChange:r,currentSessionId:i,effectiveDirectory:a,gitDirectory:o,isNewSessionDraftOpen:s,primaryLabel:c,secondaryLabel:l}=e,{t:u}=ee(),{git:d}=mn(),f=Ml(i??``,a||void 0),p=f??l,m=Z.useRef(null),h=Je(i??``,a||void 0),g=Mn(o),_=Pn(o),v=Fn(Qf),y=Fn($f),b=Ge(ep),x=Ge(tp),S=Ge(np),C=Ge(rp),w;t[0]===i?w=t[1]:(w=e=>i?e.sessionModelSelections.get(i)??null:null,t[0]=i,t[1]=w);let T=pe(w),E=gr(ip),D=gr(ap),O=gr(op),k=gr(sp),A=gr(cp),M=gr(lp),N=gr(up),P=j(dp);cr();let F,I;t[2]!==v||t[3]!==d||t[4]!==o?(F=()=>{o&&v(o,d)},I=[v,d,o],t[2]=v,t[3]=d,t[4]=o,t[5]=F,t[6]=I):(F=t[5],I=t[6]),Z.useEffect(F,I);let L,R;t[7]!==y||t[8]!==d||t[9]!==o?(L=()=>{if(o)return qe.onGitRefreshHint(e=>{Pf(e.directory)===o&&y(o,d)})},R=[y,d,o],t[7]=y,t[8]=d,t[9]=o,t[10]=L,t[11]=R):(L=t[10],R=t[11]),Z.useEffect(L,R);let z,B;t[12]===D?(z=t[13],B=t[14]):(z=()=>{D()},B=[D],t[12]=D,t[13]=z,t[14]=B),Z.useEffect(z,B);let V,H;t[15]===M?(V=t[16],H=t[17]):(V=()=>{Bt(M)},H=[M],t[15]=M,t[16]=V,t[17]=H),Z.useEffect(V,H);let U,G;t[18]!==M||t[19]!==O||t[20]!==k||t[21]!==n||t[22]!==E?(U=()=>{!n||k||M.some(e=>!E.some(t=>t.providerId===e))&&O()},G=[M,O,k,n,E],t[18]=M,t[19]=O,t[20]=k,t[21]=n,t[22]=E,t[23]=U,t[24]=G):(U=t[23],G=t[24]),Z.useEffect(U,G);let K;t[25]===h?K=t[26]:(K=nl(h),t[25]=h,t[26]=K);let te=K,q;if(t[27]!==h||t[28]!==S||t[29]!==x||t[30]!==C||t[31]!==s||t[32]!==te||t[33]!==b||t[34]!==T){let e=te??(T?{providerID:T.providerId,modelID:T.modelId}:null)??(x&&S?{providerID:x,modelID:S}:null),n=(e?b.find(t=>t.id===e.providerID):void 0)?.models.find(t=>t.id===e?.modelID),r=e?C(e.providerID,e.modelID):void 0,i=Qc(n?.limit,`context`)??r?.limit?.context??0,a;t[36]===h?a=t[37]:(a=rl(h),t[36]=h,t[37]=a),q=tl({totalTokens:a,contextLimit:i,isDraft:s}),t[27]=h,t[28]=S,t[29]=x,t[30]=C,t[31]=s,t[32]=te,t[33]=b,t[34]=T,t[35]=q}else q=t[35];let ne=q,re;t[38]!==_?.current||t[39]!==g||t[40]!==u?(re=g===!0?_?.current?.trim()||u(`gitView.branch.detachedHead`):u(`common.unavailable`),t[38]=_?.current,t[39]=g,t[40]=u,t[41]=re):re=t[41];let ie=re,ae;if(t[42]!==M||t[43]!==E||t[44]!==N||t[45]!==u){let e=new Map(E.map(fp)),n;t[47]===M?n=t[48]:(n=e=>M.includes(e.id),t[47]=M,t[48]=n),ae=or.filter(n).filter(t=>e.get(t.id)?.configured===!0).map(t=>{let n=e.get(t.id),r=[];for(let[e,t]of Object.entries(n?.usage?.windows??{}))r.push({key:`window-${e}`,label:rn(e),window:t});let i=Object.entries(n?.usage?.models??{}),a=N[t.id]??[],o=a.length>0?i.filter(e=>{let[t]=e;return a.includes(t)}):i;for(let[e,t]of o){let n=Object.entries(t.windows??{});if(n.length===0)continue;let[i,a]=n[0];r.push({key:`model-${e}-${i}`,label:rn(i),subtitle:nr(e),window:a})}let s=!n.ok&&n.error?n.error:r.length===0?u(`header.services.noRateLimitsReported`):null;return{providerId:t.id,providerName:t.name,rows:r,status:s}}),t[42]=M,t[43]=E,t[44]=N,t[45]=u,t[46]=ae}else ae=t[46];let oe=ae,se,J;t[49]!==n||t[50]!==oe?(se=()=>{!n||oe.length===0||Bt(oe.map(pp))},J=[n,oe],t[49]=n,t[50]=oe,t[51]=se,t[52]=J):(se=t[51],J=t[52]),Z.useEffect(se,J);let ce;t[53]===c?ce=t[54]:(ce=(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:c}),t[53]=c,t[54]=ce);let le;t[55]!==p||t[56]!==f?(le=p?(0,$.jsx)(`span`,{className:W(`block truncate`,f?`oc-mobile-detail-subtitle text-muted-foreground`:`typography-micro text-muted-foreground`),"aria-live":`polite`,children:p}):null,t[55]=p,t[56]=f,t[57]=le):le=t[57];let ue;t[58]!==ce||t[59]!==le?(ue=(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center px-2 py-1.5 text-left`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[ce,le]})}),t[58]=ce,t[59]=le,t[60]=ue):ue=t[60];let Y;t[61]===u?Y=t[62]:(Y=u(`mobile.header.openMetadataAria`),t[61]=u,t[62]=Y);let de;t[63]===r?de=t[64]:(de=()=>r(mp),t[63]=r,t[64]=de);let fe;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(fe={touchAction:`manipulation`},t[65]=fe):fe=t[65];let me=ne?.percentage??0,he;t[66]===me?he=t[67]:(he=(0,$.jsx)(Xc,{percentage:me}),t[66]=me,t[67]=he);let ge;t[68]!==n||t[69]!==Y||t[70]!==de||t[71]!==he?(ge=(0,$.jsx)(`button`,{ref:m,type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":Y,"aria-expanded":n,onClick:de,style:fe,children:he}),t[68]=n,t[69]=Y,t[70]=de,t[71]=he,t[72]=ge):ge=t[72];let _e;t[73]===r?_e=t[74]:(_e=()=>r(!1),t[73]=r,t[74]=_e);let ve;t[75]!==ie||t[76]!==ne||t[77]!==k||t[78]!==n||t[79]!==A||t[80]!==_e||t[81]!==P||t[82]!==oe?(ve=(0,$.jsx)(Wf,{open:n,onClose:_e,anchorRef:m,contextDisplay:ne,branchLabel:ie,usageGroups:oe,usageDisplayMode:A,isUsageLoading:k,timeFormatPreference:P}),t[75]=ie,t[76]=ne,t[77]=k,t[78]=n,t[79]=A,t[80]=_e,t[81]=P,t[82]=oe,t[83]=ve):ve=t[83];let ye;return t[84]!==ue||t[85]!==ge||t[86]!==ve?(ye=(0,$.jsxs)($.Fragment,{children:[ue,ge,ve]}),t[84]=ue,t[85]=ge,t[86]=ve,t[87]=ye):ye=t[87],ye}),Jf=({onOpenSessions:e,menuOpen:t,onToggleMenu:n,surfaceShortcuts:r})=>{let{t:i}=ee(),[a,o]=Z.useState(!1),s=w(e=>e.currentDirectory),c=Re(e=>e.currentSessionId),l=Z.useMemo(()=>e=>c?e.getDirectoryForSession(c):null,[c]),u=Re(l)||s,d=Pf(u)||null,f=Ve(e=>e.projects),p=Re(e=>e.availableWorktreesByProject),m=Z.useMemo(()=>e=>c?e.worktreeMetadata.get(c)??null:null,[c]),h=Re(m),g=ye(c),_=Re(e=>!!e.newSessionDraft?.open),v=Z.useMemo(()=>{let e=Pf(u);return e&&Rf((h?.projectDirectory?Qe(f,h.projectDirectory):null)??Ee(f,p,e),e)||i(`mobile.header.noProject`)},[p,h?.projectDirectory,u,f,i]),y=g?.title?.trim()||(c?i(`mobile.sessions.untitled`):v),b=c?v:``;Z.useEffect(()=>{o(!1)},[c,u]);let x=V(()=>{o(!1),e()}),S=V(()=>{o(!1),n()});return(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(Ca,{children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":i(`mobile.sessions.openSheetAria`),onClick:x,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`folders`,className:`size-5`})}),(0,$.jsx)(qf,{open:a,onOpenChange:o,currentSessionId:c,effectiveDirectory:u,gitDirectory:d,isNewSessionDraftOpen:_,primaryLabel:y,secondaryLabel:b}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,className:W(`flex size-10 shrink-0 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r.activePanel===`files`?`bg-[var(--interactive-selection)] text-[var(--interactive-selectionForeground)]`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),"aria-label":i(`mobile.menu.files`),"aria-pressed":r.activePanel===`files`,onClick:r.onToggleFiles,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`file-text`,className:`size-5`})}),(0,$.jsxs)(`button`,{type:`button`,className:W(`relative flex size-10 shrink-0 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r.activePanel===`changes`?`bg-[var(--interactive-selection)] text-[var(--interactive-selectionForeground)]`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),"aria-label":i(`mobile.menu.changes`),"aria-pressed":r.activePanel===`changes`,onClick:r.onToggleChanges,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-5`}),r.changesDirty?(0,$.jsx)(`span`,{className:`absolute right-2 top-2 inline-flex size-2 rounded-full bg-primary`,"aria-hidden":!0}):null]})]}):null,(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":i(`mobile.header.openMenuAria`),"aria-controls":bf,"aria-expanded":t,"aria-haspopup":`menu`,onClick:S,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`more-2`,className:`size-5`})})]})})},Yf=({connection:e,onActiveConnectionDeleted:t})=>{let{t:n}=ee(),r=Pt();Te(),ge();let i=j(e=>e.mobileSessionPanelOpen),a=j(e=>e.setMobileSessionPanelOpen),o=j(e=>e.isScheduledTasksDialogOpen),s=j(e=>e.activeMainTab),c=ue(),l=j(e=>e.setActiveMainTab),[u,d]=Z.useState(!1),[f,p]=Z.useState(!1),[m,h]=Z.useState(null),[g,_]=Z.useState(!1),[v,y]=Z.useState(!1),[b,x]=Z.useState(null),[S,C]=Z.useState(null),[T,E]=Z.useState(null),[D,O]=Z.useState(0),[A,M]=Z.useState(!1),[N,P]=Z.useState(!1),[F,I]=Z.useState(!1),[L,R]=Z.useState(!1),[z,H]=Z.useState(!1),[U,K]=Z.useState(!1),[te,q]=Z.useState(`nav`),[ne,re]=Z.useState(!1),[ie,ae]=Z.useState(!1),oe=V(()=>re(e=>!e)),se=V(()=>re(!1)),[J,ce]=Z.useState(null),le=w(e=>e.currentDirectory),de=j(e=>e.setSettingsPage),fe=ar(e=>e.available),pe=ar(e=>e.runtimeType),me=Z.useMemo(()=>Af(),[]),he=Z.useMemo(()=>tu(),[]),{data:_e=[],refetch:ve}=si(le??null,{enabled:A}),{refetch:ye}=ci(le??null,{enabled:A}),be=li(e=>e.setMcpDraft),xe=li(e=>e.setSelectedMcp),Se=Pn(Pf(le)||null)?.files?.length??0;Z.useEffect(()=>qe.onDirectoryRequest(()=>H(!0)),[]);let Ce=Z.useMemo(()=>k(),[]),we=un()===`portrait`,[Ee,De]=Z.useState(Ce&&!we),[Oe,ke]=Z.useState(null),Me=V(e=>{if(e&&de(e),Ce){q(e?`page-content`:`nav`),I(!0);return}let t=We.getState();if(e){t.openSettingsFromCurrent();return}de(`home`),t.setActiveTab(`settings`)}),Ne=V(()=>{Me(`instances`)}),Pe=V(()=>{We.getState().openInstances()}),Fe=V(()=>{We.getState().closeSecondary()}),Ie=V(async()=>{if(!U){K(!0);try{let t=await nu();switch(t.status){case`ok`:await e.connect({url:t.url,clientToken:t.clientToken,label:t.label});break;case`pairing`:await e.redeemPairingConnection(t.pairing);break;case`permission-denied`:B.error(n(`mobile.connect.scan.permissionDenied`));break;case`invalid`:B.error(n(`mobile.connect.scan.invalid`));break;case`unsupported`:B.error(n(`mobile.connect.scan.unsupported`));break;case`failed`:B.error(n(`mobile.connect.scan.failed`))}}finally{K(!1)}}});zn({enabled:!Ce,rootRoutesBlocked:i||u||f||g||v||o||A||F||L||z||ne});let Le=V(()=>{let e=!Ee;e&&we&&ke(null),De(e)}),ze=V(()=>{if(y(!1),x(null),C(null),p(!1),h(null),Ce){ce(null),ke(`files`),we&&De(!1);return}d(!0)}),Be=V(()=>{p(!1),h(null)}),Ve=V(e=>{let t=e.path.trim();if(t){if(y(!1),x(null),C(null),ce(null),_(!1),Ce){j.getState().setPendingFileFocusPath(t),ke(`files`),we&&De(!1);return}d(!1),h({path:t,targetLine:typeof e.targetLine==`number`&&Number.isFinite(e.targetLine)?Math.max(1,Math.trunc(e.targetLine)):void 0}),p(!0)}}),He=j(e=>e.pendingFileFocusPath);Z.useEffect(()=>{if(He){if(Ce){ze();return}Ve({path:He}),j.getState().setPendingFileFocusPath(null)}},[He,Ce,ze,Ve]);let Ue=V((e=null)=>{if(y(!1),x(null),C(null),E(null),p(!1),h(null),ce(e),Ce){ke(`changes`),we&&De(!1);return}_(!0)}),Ge=V((e,t,n)=>{ce(null),_(!1),p(!1),h(null),x(e??null),C(typeof t==`string`&&t.trim()?t.trim():null);let r=typeof n==`string`&&n.trim()?n.trim():null;if(E(r),O(e=>e+1),Ce){ke(`turn-diff`),we&&De(!1);return}y(!0)}),Ke=V(()=>{ke(null),ce(null),E(null)}),Je=V(e=>{if(Oe===e){Ke();return}e===`files`?ze():Ue()}),Ye=Z.useRef(`changes`);Oe&&(Ye.current=Oe);let[Xe,Ze]=Z.useState(!1);Z.useEffect(()=>{if(!Ce)return;if(Oe){Ze(!0);return}let e=window.setTimeout(()=>Ze(!1),240);return()=>window.clearTimeout(e)},[Oe,Ce]);let Qe=Oe??Ye.current,$e=Of(`left`,`openchamber.ipad.leftSidebarWidth`,xf),et=Of(`right`,`openchamber.ipad.rightSidebarWidth`,Sf),tt=Z.useMemo(()=>({openChanges:({diffPath:e,staged:t,targetLine:n}={})=>{Ue(e?{path:e,staged:t===!0,targetLine:n}:null)},openToolDiff:({diffPath:e,patches:t,targetLine:n})=>{Ue({path:e,staged:!1,targetLine:n,toolPatches:t})},openTurnDiff:Ge,openFile:({path:e,targetLine:t})=>{Ve({path:e,targetLine:t})},openFiles:()=>ze(),openSettings:e=>{Me(e)}}),[Ue,Ve,ze,Me,Ge]),nt=V(()=>{_(!1),ce(null)}),rt=V(()=>{y(!1),E(null)});Tu(Z.useMemo(()=>({openSessions:()=>{if(Ce){De(!0);return}We.getState().setActiveTab(`projects`)},openView:e=>{e===`files`?ze():e===`mcp`?M(!0):e===`instances`?Ne():e===`update`&&R(!0)},openChanges:({path:e,staged:t}={})=>{Ue(e?{path:e,staged:t===!0}:null)},openSettings:e=>{Me(e)}}),[Ce,Ue,ze,Ne,Me]));let it=Z.useRef(null),at=Z.useRef(null),ot=Z.useRef(null),st=Z.useRef(null),ct=Z.useRef(null),lt=Z.useRef(null),ut=Re(e=>e.currentSessionId),dt=Re(e=>e.setCurrentSession),ft=Z.useMemo(()=>e=>ut?e.getDirectoryForSession(ut):null,[ut]),pt=Re(ft),mt=je(ut,pt||le||void 0),ht=Ae(ut??``);df();let gt=ht?.type===`busy`||ht?.type===`retry`,_t=V(()=>{let e=ut;if(!e||ie||gt)return;let t=pt||le||void 0;ae(!0),(async()=>{try{await r.refreshSessionTranscript(e,{directory:t}),B.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{B.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{ae(!1)}})()}),vt=V(e=>{lt.current=e}),yt=V(e=>{let t=ot.current,n=st.current,r=ct.current;if(!t)return;if(!e){t.style.transform=``,t.style.opacity=``,t.style.willChange=``,n&&(n.style.transform=``,n.style.willChange=``),r&&(r.style.transform=``,r.style.willChange=``);return}t.style.willChange||t.getAnimations().forEach(e=>e.cancel()),t.style.willChange=`transform, opacity`,t.style.transform=`translate3d(${e.offsetX}px, 0, 0)`,t.style.opacity=String(1-e.progress*.08),n&&(n.style.willChange=`transform`,n.style.transform=`translate3d(${e.offsetX}px, 0, 0)`),r&&(r.style.willChange=`transform`,r.style.transform=`translate3d(${e.offsetX}px, 0, 0)`);let i=e.direction===`prev`?n:r;i&&Array.from(i.children).forEach(t=>{t instanceof HTMLElement&&(t.style.opacity=e.canSwitch?`1`:`0.35`)})}),bt=We(e=>e.secondary?.kind??null),xt=!Ce&&(bt===`chat`||bt===`draft`);Z.useEffect(()=>{!Ce&&!xt&&re(!1)},[Ce,xt]),Z.useEffect(()=>{re(!1)},[ut]),Wu(at,{onSwitch:vt,onProgress:yt},Ce||xt);let St=Ce&&s===`assistant`||!Ce&&!xt||i||u||f||g||v||o||A||F||L||z||ne;ud(at,{onOpen:V(()=>{Sn(Cn)?.finish(`commit`)}),onPreviewStart:V(()=>{Sn(Cn)?.begin(`present`)}),onPreviewCancel:V(()=>{Sn(Cn)?.finish(`cancel`)}),onProgress:V(e=>{e!==null&&Sn(Cn)?.update(e)}),disabled:St},Ce||xt),Z.useLayoutEffect(()=>{let e=lt.current;if(lt.current=null,!e)return;let t=ot.current;if(!t||typeof t.animate!=`function`)return;t.getAnimations().forEach(e=>e.cancel());let n=e===`prev`?-70:70;t.animate([{opacity:.1,transform:`translateX(${n}px)`},{opacity:1,transform:`translateX(0)`}],{duration:300,easing:`cubic-bezier(0.22, 1, 0.36, 1)`})},[ut]);let Ct=V(e=>{it.current=e});Nf(V(()=>ne?(re(!1),!0):z?(H(!1),!0):o?(window.dispatchEvent(new Event(`oc:scheduled-tasks-close-request`)),!0):i?(a(!1),!0):Un.backImmediately(`overlay`)?!0:f?(Be(),!0):u?(d(!1),!0):v?(rt(),!0):g?(nt(),!0):A?(M(!1),!0):F?(I(!1),!0):L?(R(!1),!0):Un.requestAnimatedBack(`root`)||it.current?.()?!0:s===`assistant`?(l(`chat`),!0):mt?(dt(mt.id,mt.directory),!0):!1));let wt=fe&&(pe===`desktop`||pe===`web`),Tt=V(()=>{let e=`new-mcp-server`,t=e,n=1;for(;_e.some(e=>e.name===t);)t=`${e}-${n}`,n+=1;be({name:t,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),xe(t),M(!1),Me(`mcp`)}),Et=V(()=>{if(N)return;P(!0);let e=new Promise(e=>window.setTimeout(e,500));Promise.all([ye(),ve(),e]).finally(()=>P(!1))}),Dt=Re(e=>e.openNewSessionDraft),Ot=Z.useMemo(()=>{let e=[{key:`new-session`,icon:`chat-new`,label:n(`mobile.menu.newSession`),onSelect:()=>{if(Ce){l(`chat`),Dt();return}We.getState().openDraft()}}];return Ce||e.push({key:`files`,icon:`file-text`,label:n(`mobile.menu.files`),onSelect:()=>ze()},{key:`changes`,icon:`git-branch`,label:n(`mobile.menu.changes`),badge:Se,onSelect:()=>Ue()}),e.push({key:`mcp`,iconNode:(0,$.jsx)(ir,{className:`size-5 shrink-0 text-muted-foreground`}),label:n(`mobile.menu.mcp`),onSelect:()=>M(!0)}),wt&&e.push({key:`update`,icon:`download`,label:n(`mobile.menu.update`),onSelect:()=>R(!0)}),Ce&&e.push({key:`settings`,icon:`settings-3`,label:n(`mobile.menu.settings`),onSelect:()=>Me()}),ut&&e.push({key:`refresh-transcript`,icon:`refresh`,label:n(`sessions.sidebar.session.menu.refreshTranscript`),disabled:ie||gt,spinning:ie,onSelect:_t}),e},[ut,Se,Ce,gt,ie,Ue,ze,Dt,Me,_t,l,wt,n]);return(0,$.jsxs)(On,{actions:tt,children:[(0,$.jsxs)(`div`,{className:`oc-mobile-app-shell main-content-safe-area flex h-[100dvh] flex-row text-foreground`,"data-page-scroll-lock":`true`,children:[Ce?(0,$.jsxs)(`aside`,{ref:$e.asideRef,className:W(`relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/50 bg-sidebar will-change-[width] motion-reduce:transition-none`,!Ee&&`border-r-0`),style:{width:Ee?$e.width:0,minWidth:Ee?$e.width:0,maxWidth:Ee?$e.width:0,"--oc-ipad-sidebar-width":`${$e.width}px`,overflowX:`clip`,paddingTop:`var(--oc-safe-area-top, 0px)`,transitionProperty:$e.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!Ee,"data-page-scroll-lock":`true`,children:[Ee?(0,$.jsx)(kf,{side:`left`,isResizing:$e.isResizing,ariaLabel:n(`sidebar.resize.leftPanelAria`),handleProps:$e.handleProps}):null,(0,$.jsx)(`div`,{className:W(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,$e.isResizing&&`pointer-events-none`,!Ee&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:(0,$.jsx)(Xt,{children:(0,$.jsx)($o,{open:!0,variant:`sidebar`,onOpenChange:e=>{!e&&we&&De(!1)}})})})]}):null,(0,$.jsx)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,"data-page-scroll-lock":`true`,children:Ce?(0,$.jsxs)($.Fragment,{children:[s===`assistant`?null:(0,$.jsx)(`div`,{children:(0,$.jsx)(Jf,{onOpenSessions:()=>Le(),menuOpen:ne,onToggleMenu:oe,surfaceShortcuts:{activePanel:Oe===`turn-diff`?`changes`:Oe,changesDirty:Se>0,onToggleFiles:()=>Je(`files`),onToggleChanges:()=>Je(`changes`)}})}),(0,$.jsxs)(`main`,{ref:at,className:`relative min-h-0 flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:[(0,$.jsxs)(`div`,{ref:st,"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 -left-full flex w-full items-center justify-end gap-3 bg-background pr-4`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-medium tracking-wide text-muted-foreground/60`,children:n(`helpDialog.item.previousSession`)}),(0,$.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-full border border-border/70 bg-[var(--surface-elevated)] text-foreground shadow-sm`,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})})]}),(0,$.jsxs)(`div`,{ref:ct,"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 left-full flex w-full items-center justify-start gap-3 bg-background pl-4`,children:[(0,$.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-full border border-border/70 bg-[var(--surface-elevated)] text-foreground shadow-sm`,children:(0,$.jsx)(X,{name:`arrow-right`,className:`size-5`})}),(0,$.jsx)(`span`,{className:`typography-micro font-medium tracking-wide text-muted-foreground/60`,children:n(`helpDialog.item.nextSession`)})]}),(0,$.jsx)(`div`,{ref:ot,className:`relative h-full w-full bg-background`,children:(0,$.jsx)(Xt,{children:s===`assistant`?(0,$.jsx)(Ti,{}):(0,$.jsx)(ti,{})})})]})]}):(0,$.jsx)(jc,{className:`min-h-0 flex-1`,onAddProject:()=>H(!0),onScanQr:me&&he?()=>{Ie()}:void 0,onSwitchInstance:me?Pe:void 0,onEnableAssistants:()=>{Me(`assistants`)},instancesPage:me?(0,$.jsx)(Vf,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t}):void 0,instancesSecondaryPage:me?(0,$.jsxs)(`div`,{className:`oc-settings-workspace oc-settings-workspace-mobile flex h-full min-h-0 flex-col bg-[var(--surface-background)]`,children:[(0,$.jsx)(Y,{title:n(`mobile.settings.switchInstance`),backAriaLabel:n(`header.actions.backAria`),onBack:Fe}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-[var(--oc-mobile-page-inline-inset)]`,children:(0,$.jsx)(dr,{className:`oc-mobile-settings-detail-card`,children:(0,$.jsx)(Vf,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t})})})]}):void 0,parentSessionTarget:mt?{id:mt.id,directory:mt.directory}:null,registerSecondaryBackHandler:Ct,scheduledContent:(e,t)=>(0,$.jsx)(Xr,{presentation:`mobile-tab`,registerEditorBackHandler:e,onEditorActiveChange:t}),renderChat:e=>(0,$.jsx)(Ll,{sessionId:e.sessionId,directory:e.directory,onBack:()=>{se(),Un.requestAnimatedBack(`root`)},onOpenMenu:oe,onCloseMenu:se,menuOpen:e.active&&ne,children:(0,$.jsxs)(`main`,{ref:e.active?at:void 0,className:`relative h-full min-h-0 flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:[e.active?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{ref:st,"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 -left-full flex w-full items-center justify-end gap-3 bg-background pr-4`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-medium tracking-wide text-muted-foreground/60`,children:n(`helpDialog.item.previousSession`)}),(0,$.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-full border border-border/70 bg-[var(--surface-elevated)] text-foreground shadow-sm`,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})})]}),(0,$.jsxs)(`div`,{ref:ct,"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 left-full flex w-full items-center justify-start gap-3 bg-background pl-4`,children:[(0,$.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-full border border-border/70 bg-[var(--surface-elevated)] text-foreground shadow-sm`,children:(0,$.jsx)(X,{name:`arrow-right`,className:`size-5`})}),(0,$.jsx)(`span`,{className:`typography-micro font-medium tracking-wide text-muted-foreground/60`,children:n(`helpDialog.item.nextSession`)})]})]}):null,(0,$.jsx)(`div`,{ref:e.active?ot:void 0,className:`relative h-full w-full bg-background`,children:(0,$.jsx)(Xt,{children:(0,$.jsx)(ti,{readOnly:!e.active,active:e.active,selectionOverride:{sessionId:e.sessionId||null,directory:e.directory,viewKey:e.viewKey}})})})]})})})}),Ce?(0,$.jsxs)(`aside`,{ref:et.asideRef,className:W(`relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/50 bg-background will-change-[width] motion-reduce:transition-none`,!Oe&&`border-l-0`),style:{width:Oe?et.width:0,minWidth:Oe?et.width:0,maxWidth:Oe?et.width:0,"--oc-ipad-sidebar-width":`${et.width}px`,overflowX:`clip`,paddingTop:`var(--oc-safe-area-top, 0px)`,transitionProperty:et.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!Oe,"data-page-scroll-lock":`true`,children:[Oe?(0,$.jsx)(kf,{side:`right`,isResizing:et.isResizing,ariaLabel:n(`sidebar.resize.rightPanelAria`),handleProps:et.handleProps}):null,(0,$.jsx)(`div`,{className:W(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,et.isResizing&&`pointer-events-none`,!Oe&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:Xe?(0,$.jsx)(Xt,{children:Qe===`files`?(0,$.jsx)(_o,{onClose:Ke}):Qe===`turn-diff`?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/40 px-3`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground`,children:n(`mobile.nav.changes`)}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ke,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(Tr,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:b,sessionId:S,targetFilePath:T,navigationRequestKey:D,flushContent:!0})})]}):J?.toolPatches?.length?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/40 px-3`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground`,children:J.toolPatches.length>1?n(`mobile.nav.changes`):J.path}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ke,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(Tr,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:J.path,targetLine:J.targetLine??null,toolPatches:J.toolPatches,singleFileView:J.toolPatches.length===1,flushContent:!0})})]}):(0,$.jsx)(La,{onClose:Ke,initialDiffPath:J?.path??null,initialDiffStaged:J?.staged===!0,initialDiffTargetLine:J?.targetLine??null})}):null})]}):null,(0,$.jsx)(Kr,{open:z,onOpenChange:H,forceMobile:!0}),(0,$.jsx)(Kf,{open:ne,onClose:()=>re(!1),items:Ot,rightOffset:Ce&&Oe?et.width:0}),(0,$.jsx)(Br,{}),u?(0,$.jsx)(bn,{id:hf,open:u,onOpenChange:e=>{e||d(!1)},ariaLabel:n(`mobile.menu.files`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(Xt,{children:(0,$.jsx)(_o,{onClose:()=>d(!1)})})}):null,f&&m?(0,$.jsx)(bn,{id:mf,open:f,onOpenChange:e=>{e||Be()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:m.path.split(/[/\\]/).filter(Boolean).at(-1)??m.path}),ariaLabel:n(`mobile.menu.files`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(Xt,{children:(0,$.jsx)(_o,{onClose:Be,initialFilePath:m.path,directFilePreview:!0,hideFileHeader:!0},m.path)})}):null,(0,$.jsx)(bn,{id:pf,open:v,onOpenChange:e=>{e||rt()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mobile.nav.changes`)}),ariaLabel:n(`mobile.nav.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(Xt,{children:(0,$.jsx)(Tr,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:b,sessionId:S,targetFilePath:T,navigationRequestKey:D,flushContent:!0})})}),g&&J?(0,$.jsx)(bn,{id:ff,open:g,onOpenChange:e=>{e||nt()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:J.toolPatches&&J.toolPatches.length>1?n(`mobile.nav.changes`):J.path}),ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(Xt,{children:J.toolPatches?.length?(0,$.jsx)(Tr,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:J.path,targetLine:J.targetLine??null,toolPatches:J.toolPatches,singleFileView:J.toolPatches.length===1,flushContent:!0}):(0,$.jsx)(La,{initialDiffPath:J.path,initialDiffStaged:J.staged,initialDiffTargetLine:J.targetLine??null,hideDiffHeader:!0})})}):g?(0,$.jsx)(bn,{id:gf,open:g,onOpenChange:e=>{e||nt()},ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(Xt,{children:(0,$.jsx)(La,{onClose:nt,initialDiffPath:J?.path??null,initialDiffStaged:J?.staged===!0,initialDiffTargetLine:J?.targetLine??null})})}):null,A?(0,$.jsx)(bn,{id:_f,open:A,onOpenChange:e=>{e||M(!1)},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mcpDropdown.title`)}),trailing:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,onClick:Tt,"aria-label":n(`settings.mcp.sidebar.actions.addServerTitle`),title:n(`settings.mcp.sidebar.actions.addServerTitle`),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`add`,className:`size-5`})}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,onClick:Et,disabled:N,"aria-label":n(`mcpDropdown.actions.refreshAria`),title:n(`mcpDropdown.actions.refreshAria`),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`refresh`,className:W(`size-5`,N&&`animate-spin`)})})]}),ariaLabel:n(`mcpDropdown.title`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(Xt,{children:(0,$.jsx)(Ir,{active:!0,className:`h-full`,listClassName:`max-h-none`,hideHeader:!0,mobileListDensity:!0})})}):null,F&&Ce?(0,$.jsx)(bn,{id:vf,open:F,onOpenChange:e=>{e||I(!1)},ariaLabel:n(`mobile.menu.settings`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(Xt,{children:(0,$.jsx)(gi,{forceMobile:!0,isWindowed:!0,initialMobileStage:te,visiblePageSlugs:[...fr],onClose:()=>I(!1),mobileInstancesPage:me?(0,$.jsx)(Vf,{connection:e,onConnect:()=>I(!1),onActiveConnectionDeleted:t}):void 0})})}):null,L?(0,$.jsx)(bn,{id:yf,open:L,onOpenChange:e=>{e||R(!1)},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mobile.menu.update`)}),ariaLabel:n(`mobile.menu.update`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(Xt,{children:(0,$.jsx)(`div`,{className:`h-full overflow-auto px-5 py-4`,children:(0,$.jsx)(_i,{initialUpdateDialogOpen:!0})})})}):null]}),(0,$.jsx)(pi,{enabled:me&&s===`assistant`&&c.data?.supported===!0&&c.data?.enabled===!0}),(0,$.jsx)(Xt,{children:(0,$.jsx)(oi,{})})]})};function Xf({apis:e}){Z.useEffect(()=>He(),[]);let{t}=ee(),n=Ge(e=>e.initializeApp),r=Ge(e=>e.isInitialized),i=Ge(e=>e.isConnected),o=Ge(e=>e.connectionPhase),s=w(e=>e.currentDirectory),l=Re(e=>e.currentSessionId),d=Re(e=>!!e.newSessionDraft?.open),f=Re(e=>e.error),p=Re(e=>e.clearError),m=j(e=>e.setIsMobile),h=lr(e=>e.refreshStatus),g=Ve(e=>e.projects),[v,y]=Z.useState(0),[b,x]=Z.useState(0),[S,C]=Z.useState(!1),[T,D]=Z.useState(`pending`),O=Z.useMemo(()=>ae(),[]),[,k]=Z.useReducer(e=>e+1,0),A=Z.useMemo(()=>Af(),[]),M=Z.useRef(0),N=Z.useRef(0),P=ie(()=>{D(`done`),y(e=>e+1)});Eu(V(e=>{P.redeemPairingConnection(e)}));let F=Du({ready:A&&i&&r});Z.useEffect(()=>{!P.error||!u()||B.error(P.error)},[P.error]);let I=V(()=>{let t=u(),r=N.current+1;if(N.current=r,!t){se();return}let i=()=>{n(),h(e.github,{force:!0}),Ge.getState().refreshMissingCatalogs({source:`mobileApp:nativeResume`})},a=()=>{c({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),y(e=>e+1)};re().then(e=>{if(N.current===r){if(e===`no-connection`){a();return}if(e===`unreachable`){window.setTimeout(()=>{N.current===r&&re().then(e=>{if(N.current===r&&e!==`switched`&&e===`unchanged`){i();return}})},4e3);return}e!==`switched`&&i()}});let o=Date.now();o-M.current>=If&&(M.current=o,window.dispatchEvent(new Event(`openchamber:system-resume`)))});jf(),Mf(I),Z.useEffect(()=>{if(!A)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>I(),1500)};return window.addEventListener(`online`,t),()=>{window.removeEventListener(`online`,t),window.clearTimeout(e)}},[A,I]),Z.useEffect(()=>(_(e),()=>_(null)),[e]),Z.useEffect(()=>{A&&R().then(e=>{e&&e.notifyAppReady().catch(()=>void 0)})},[A]),Z.useEffect(()=>{if(!A)return;let e=!1,t=[];return R().then(async n=>{if(!(!n||e))try{let r=await n.addListener(`download`,e=>{ar.getState().setOtaDownloadPercent(e.percent)}),i=await n.addListener(`downloadFailed`,()=>{ar.getState().setOtaDownloadFailed()}),a=await n.addListener(`downloadComplete`,()=>{ar.getState().setOtaPhase(`pending_restart`)}),o=await n.addListener(`appReloaded`,()=>{ar.getState().setOtaPhase(`pending_restart`)}),s=await n.addListener(`autoRevert`,()=>{console.warn(`[OTA] Capgo auto-reverted the last bundle`),ar.getState().setOtaPhase(`error`,`OTA update was reverted`)});if(e){r.remove(),i.remove(),a.remove(),o.remove(),s.remove();return}t.push(()=>void r.remove(),()=>void i.remove(),()=>void a.remove(),()=>void o.remove(),()=>void s.remove())}catch(e){console.warn(`[OTA] Failed to subscribe to Capgo updater events:`,e)}}),()=>{e=!0;for(let e of t)e()}},[A]),Z.useEffect(()=>a(e=>{if(e.runtimeKey&&e.runtimeKey===e.previousRuntimeKey){ei(),k();return}qr(e),We.getState().reset(),x(e=>e+1),y(e=>e+1)}),[]),Z.useEffect(()=>{if(F===`pending`)return;if(F===`connect`){D(`done`);return}if(!A||i||u()){D(`done`);return}let e=!1;return D(`attempting`),oe().then(e=>e?!0:se()).catch(()=>!1).then(()=>{e||D(`done`)}),()=>{e=!0}},[F]),Z.useEffect(()=>{m(!0)},[m]),Z.useEffect(()=>{A&&!u()||n()},[v,n,A]),Lt({enabled:!A||!!u(),source:`mobileApp:recovery`}),Z.useEffect(()=>{i&&E.setDirectory(s)},[s,i]),Z.useEffect(()=>{i&&h(e.github,{force:!0})},[e.github,i,h]),Z.useEffect(()=>{if(!i||g.length===0)return;let e=!1;return(async()=>{await Promise.all(g.map(async t=>{let n=Pf(t.path);if(n)try{if(!(Fn.getState().directories.get(n)?.isGitRepo??await L(()=>import(`./gitApi-D8R7ic-T.js`).then(e=>e.S).then(e=>e.checkIsGitRepository(n)),__vite__mapDeps([57,1,4,3,2,24,7,5,6,8,25,26,35,36,10,37,38,39,20,21,22,23,27,28,29,40,41,42])))||e)return;await Kt({id:t.id,path:n},{isCurrent:()=>!e})}catch{}}))})(),()=>{e=!0}},[i,g]),Z.useEffect(()=>{if(!f)return;let e=window.setTimeout(()=>p(),5e3);return()=>window.clearTimeout(e)},[p,f]),Z.useEffect(()=>{if(!(!i&&(!A||u()))){C(!1);return}let e=window.setTimeout(()=>C(!0),8e3);return()=>window.clearTimeout(e)},[i,A,v,b]),Nt(),yt({enabled:!0}),Ft(),ri(),pd({enabled:A&&i});let z=ou(),H=!i&&o===`reconnecting`;if(!z)return(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(en,{width:120,height:120,isAnimated:!0})});let U=!!u();return A&&(!U||!i&&!H)?U?(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-4`,children:[(0,$.jsx)(en,{width:120,height:120,isAnimated:!S}),S?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h1`,{className:`typography-h3 text-foreground`,children:t(`sessionAuth.error.networkTitle`)}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:t(`sessionAuth.error.networkDescription`)})]}),(0,$.jsx)(G,{type:`button`,variant:`outline`,onClick:()=>{c({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),y(e=>e+1)},children:t(`mobile.connect.cancelPassword`)})]}):null]})}):T===`done`?(0,$.jsx)(Bf,{connection:P}):(0,$.jsxs)(`main`,{className:`relative flex min-h-dvh items-center justify-center bg-background text-foreground`,children:[(0,$.jsx)(en,{width:120,height:120,isAnimated:!0}),O?(0,$.jsxs)(`div`,{className:`absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center`,children:[(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:t(`mobile.connect.splash.connectingTo`)}),(0,$.jsxs)(`p`,{className:`typography-small text-foreground`,children:[O,(0,$.jsx)(kt,{})]})]}):null]}):!i&&!H?S?(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground`,children:(0,$.jsxs)(`div`,{className:`max-w-sm space-y-3`,children:[(0,$.jsx)(`h1`,{className:`typography-h3 text-foreground`,children:t(`sessionAuth.error.networkTitle`)}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:t(`sessionAuth.error.networkDescription`)})]})}):(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(en,{width:120,height:120,isAnimated:!0})}):(0,$.jsx)(Xt,{children:(0,$.jsx)(ve,{sdk:E.getSdkClient(),directory:s||``,bootstrapDirectory:!(d&&l===null),children:(0,$.jsx)(Tt,{apis:e,children:(0,$.jsx)(Jt,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:`h-full bg-background text-foreground`,children:[(0,$.jsx)(Pr,{}),(0,$.jsx)(J,{}),(0,$.jsx)(Dt,{embeddedBackgroundWorkEnabled:r}),(0,$.jsx)(Qr,{}),(0,$.jsx)(ta,{}),(0,$.jsx)(da,{}),(0,$.jsx)(Yf,{connection:P,onActiveConnectionDeleted:()=>{c({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),We.getState().reset(),y(e=>e+1)}}),(0,$.jsx)(Rt,{position:`top-center`,offset:`calc(var(--oc-safe-area-top, 0px) + 16px)`}),r?(0,$.jsx)(Jr,{}):null]})})})},b)})}function Zf(e){e.currentTarget.style.transform=`none`}function Qf(e){return e.ensureStatus}function $f(e){return e.fetchStatus}function ep(e){return e.providers}function tp(e){return e.currentProviderId}function np(e){return e.currentModelId}function rp(e){return e.getModelMetadata}function ip(e){return e.results}function ap(e){return e.loadSettings}function op(e){return e.fetchAllQuotas}function sp(e){return e.isLoading}function cp(e){return e.displayMode}function lp(e){return e.dropdownProviderIds}function up(e){return e.selectedModels}function dp(e){return e.timeFormatPreference}function fp(e){return[e.providerId,e]}function pp(e){return e.providerId}function mp(e){return!e}var hp=()=>{te(),h().then(()=>{Promise.all([m(),zt()]).catch(e=>{console.error(`[mobile-main] settings init failed:`,e)}),bt(),It(),lt()}).catch(e=>{console.error(`[mobile-main] appearance init failed:`,e)}).finally(()=>{Vi()})};function gp(e){Kn(),hp(),j.getState().setIsMobile(!0),Yi(),dn(),fn();let t=document.getElementById(`root`);if(!t)throw Error(`Root element not found`);let n=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`;n&&document.documentElement.classList.add(`oc-native-app-active`);let r=n?{...e,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:e,i=(0,$.jsx)(Xf,{apis:r});(0,Li.createRoot)(t).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(vt,{children:(0,$.jsx)(U,{children:(0,$.jsx)(ut,{children:(0,$.jsx)(mt,{children:(0,$.jsx)(Yr,{children:(0,$.jsx)(ht,{children:n?i:(0,$.jsx)(gt,{children:i})})})})})})})}))}export{gp as renderMobileApp};
|