@openchambery/web 1.17.1 → 1.18.0
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/bin/lib/DOCUMENTATION.md +1 -0
- package/dist/assets/{AgentAvatar-C6Hxu5_o.js → AgentAvatar-B2kZjgaf.js} +1 -1
- package/dist/assets/{AssistantView-CbnxMZU0.js → AssistantView-Dc9MhgcD.js} +1 -1
- package/dist/assets/{ChatContainer-DEDGosbz.js → ChatContainer-CA3RO1yP.js} +40 -40
- package/dist/assets/{DiagramView-Byxhaduz.js → DiagramView-CpT4q2Jg.js} +1 -1
- package/dist/assets/{FadeInOnReveal-CvNA_aGD.js → FadeInOnReveal-aeWlaqVB.js} +1 -1
- package/dist/assets/{Icon-BPJ_quEe.js → Icon-AXqa-fYB.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-Cv8V-Q5l.js → MarkdownRendererImpl-DLnXrjCS.js} +2 -2
- package/dist/assets/{MobileDetailNavigation-lVtCe-5P.js → MobileDetailNavigation-BYX8jFRg.js} +1 -1
- package/dist/assets/MobileShareBridge-BJzGsvUa.js +4 -0
- package/dist/assets/MobileSurface-Cfe17dw4.js +2 -0
- package/dist/assets/{MultiRunWindow-1kkKTh4h.js → MultiRunWindow-DEYIMkSg.js} +1 -1
- package/dist/assets/{OnboardingScreen-CdvaEBtt.js → OnboardingScreen-CCfdEtW6.js} +1 -1
- package/dist/assets/{OverlayScrollbar-Dqk1zGJB.js → OverlayScrollbar-CpQvV-qY.js} +1 -1
- package/dist/assets/SettingsView-PjA5aLCR.js +25 -0
- package/dist/assets/{SettingsWindow-DMQMRgc3.js → SettingsWindow-DOe4sCjl.js} +1 -1
- package/dist/assets/{TerminalView-jYq0JQPc.js → TerminalView-Bf-2wMV0.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DJefd2N6.js → ToolOutputDialog-DuT5ne12.js} +1 -1
- package/dist/assets/{appThemeRegistry-BXeIggYO.js → appThemeRegistry--wNZ5yxf.js} +2 -2
- package/dist/assets/{button-BmNJBT13.js → button-CDvMVaiO.js} +1 -1
- package/dist/assets/{clipboard-CXWbHCAk.js → clipboard-Jdqe05db.js} +1 -1
- package/dist/assets/{collapsible-68IqWBM1.js → collapsible-C2aamDvD.js} +1 -1
- package/dist/assets/{context-menu-BbRpMBQh.js → context-menu-CS_u7xxB.js} +1 -1
- package/dist/assets/desktopHosts-CBoBpJ1Z.js +1 -0
- package/dist/assets/desktopRelayRestore-l2R9muux.js +1 -0
- package/dist/assets/{diagram-YN0GZ1Q0.js → diagram-CEon0BQs.js} +1 -1
- package/dist/assets/{dialog-BV1ENlLf.js → dialog-BzZ3cKxG.js} +1 -1
- package/dist/assets/es-C25PRSjo.js +15 -0
- package/dist/assets/{fileQueries-i4oziMnC.js → fileQueries-CE_DaZWQ.js} +1 -1
- package/dist/assets/fr-Cv8ZWQdW.js +13 -0
- package/dist/assets/{gitApi-Bs_2iBAm.js → gitApi-DSLGdswL.js} +3 -3
- package/dist/assets/gitApiHttp-D8j1qRH4.js +2 -0
- package/dist/assets/{input-BLVhPvhN.js → input-k9DGGyZ6.js} +1 -1
- package/dist/assets/insertionBoundaries-BkoTIR-0.js +1 -0
- package/dist/assets/{ja-Dcb0VtDE.js → ja-Ue9m9eSe.js} +3 -3
- package/dist/assets/{ko-CX71xNDX.js → ko-DWBUCCV6.js} +3 -3
- package/dist/assets/main-CTnxV3y3.js +172 -0
- package/dist/assets/{main-CT0DuuLm.js → main-D1Xze0xA.js} +2 -2
- package/dist/assets/{markdown-worker-Cq3Twp1A.js → markdown-worker-DkeWiER6.js} +1 -1
- package/dist/assets/{markdownTheme-CCnvI6L0.js → markdownTheme-DNT93i5L.js} +1 -1
- package/dist/assets/miniChat-Dxajshg_.js +2 -0
- package/dist/assets/mobile-CisSv-ca.js +2 -0
- package/dist/assets/multirun-BOb2dW9T.js +4 -0
- package/dist/assets/persistence-DPNMIbF5.js +3 -0
- package/dist/assets/{pl-mR_3Sqr8.js → pl-DaBaPCyE.js} +3 -3
- package/dist/assets/projectMeta-WTDhB__y.js +3 -0
- package/dist/assets/pt-BR-C2cJZ43o.js +15 -0
- package/dist/assets/radio-DZwuHb7-.js +1 -0
- package/dist/assets/renderElectronMiniChatApp-DpYFpBSy.js +2 -0
- package/dist/assets/renderMobileApp-DB1TXtLg.js +23 -0
- package/dist/assets/runtimeConfig-BtWi74Pm.js +1 -0
- package/dist/assets/runtimeEndpointReset-BnA1DoNG.js +145 -0
- package/dist/assets/{sortable-tabs-strip-oKJ700WG.js → sortable-tabs-strip-DADoz-JR.js} +1 -1
- package/dist/assets/src-oHrYIqHF.css +2 -0
- package/dist/assets/{store-oojlrF4d.js → store-SqV3zfE8.js} +4 -4
- package/dist/assets/{terminalApi-BYTA045F.js → terminalApi-tB3qLcfa.js} +1 -1
- package/dist/assets/{tooltip-BYGBBTc2.js → tooltip-DMNR5rN0.js} +1 -1
- package/dist/assets/uk-DJz_P8OZ.js +15 -0
- package/dist/assets/{url-CGHw6D-E.js → url-7MqoLs9X.js} +1 -1
- package/dist/assets/useAppFontEffects-CeS0e0FK.js +7 -0
- package/dist/assets/{useAssistantUIStore-ESTV1mEY.js → useAssistantUIStore-Bq3cPj2x.js} +1 -1
- package/dist/assets/{useDesktopWindowControlsLayout-Cq5a2gcJ.js → useDesktopWindowControlsLayout-DwFMUFtC.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-DG6uPzBG.js → useEffectiveDirectory-Dp8McufI.js} +1 -1
- package/dist/assets/{useFontPreferences-Bu4ME5hk.js → useFontPreferences-CIurCeNv.js} +1 -1
- package/dist/assets/useMobileNavigationStore-kWPnKBP1.js +475 -0
- package/dist/assets/useSessionAutoCleanup-BLiIZW0x.js +1 -0
- package/dist/assets/useUIStore-5agS8bsW.js +1 -0
- package/dist/assets/{useWorkerHighlightedLines-ADgu9578.js → useWorkerHighlightedLines-Cnxz7HaG.js} +1 -1
- package/dist/assets/{utils-DyUyiLje.js → utils-Co19EJEL.js} +1 -1
- package/dist/assets/zh-CN-DLAKDOM9.js +15 -0
- package/dist/assets/zh-TW-s3Jjx1_n.js +15 -0
- package/dist/index.html +9 -9
- package/dist/mini-chat.html +9 -9
- package/dist/mobile.html +9 -9
- package/package.json +1 -1
- package/server/index.d.ts +4 -0
- package/server/index.js +29 -15
- package/server/lib/client-auth/pairing.js +7 -1
- package/server/lib/client-auth/pairing.test.js +45 -0
- package/server/lib/desktop-hosts/routes.js +157 -0
- package/server/lib/desktop-hosts/routes.test.js +227 -0
- package/server/lib/message-queue/DOCUMENTATION.md +1 -1
- package/server/lib/message-queue/routes.js +1 -1
- package/server/lib/message-queue/routes.test.js +1 -0
- package/server/lib/message-queue/service.js +12 -1
- package/server/lib/message-queue/service.test.js +30 -0
- package/server/lib/opencode/DOCUMENTATION.md +4 -4
- package/server/lib/opencode/bootstrap-runtime.js +7 -0
- package/server/lib/opencode/cli-entry-runtime.js +6 -0
- package/server/lib/opencode/cli-entry-runtime.test.js +43 -0
- package/server/lib/opencode/core-routes.js +4 -1
- package/server/lib/opencode/core-routes.test.js +29 -0
- package/server/lib/opencode/openchamber-routes.js +12 -0
- package/server/lib/opencode/settings-runtime.js +1 -1
- package/server/lib/package-manager.js +3 -1
- package/server/lib/relay/DOCUMENTATION.md +44 -1
- package/server/lib/relay/host-client.js +4 -1
- package/server/lib/relay/service.js +16 -8
- package/server/lib/relay/service.test.js +21 -6
- package/server/lib/relay/tunnel-host.js +57 -4
- package/server/lib/relay/tunnel-host.test.js +250 -2
- package/dist/assets/MobileShareBridge-DAlvgjo1.js +0 -4
- package/dist/assets/MobileSurface-Bde8yLWo.js +0 -2
- package/dist/assets/SettingsView-D0dhTIur.js +0 -25
- package/dist/assets/desktopHosts-BpjUSDz4.js +0 -1
- package/dist/assets/desktopRelayRestore-BzUEk1i7.js +0 -1
- package/dist/assets/es-EXZUX1sB.js +0 -15
- package/dist/assets/fr-jWNPO91J.js +0 -13
- package/dist/assets/gitApiHttp-C1DaEMKR.js +0 -2
- package/dist/assets/insertionBoundaries-BAFtAotq.js +0 -1
- package/dist/assets/main-G8tKFcTV.js +0 -172
- package/dist/assets/miniChat-BP3OHqNF.js +0 -2
- package/dist/assets/mobile-BtwuDs-C.js +0 -2
- package/dist/assets/multirun-B-L3JH60.js +0 -4
- package/dist/assets/persistence-C_KCiMcY.js +0 -3
- package/dist/assets/projectMeta-Cp74cItv.js +0 -3
- package/dist/assets/pt-BR-D1RpVOvC.js +0 -15
- package/dist/assets/radio-Bs4mdPv5.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-dgirEOtR.js +0 -2
- package/dist/assets/renderMobileApp-DK9qzy0P.js +0 -23
- package/dist/assets/runtimeConfig-JSaYFA5x.js +0 -1
- package/dist/assets/runtimeEndpointReset-C0eCWIE6.js +0 -145
- package/dist/assets/src-8zziWB78.css +0 -2
- package/dist/assets/uk-UvnVqWv-.js +0 -15
- package/dist/assets/useAppFontEffects-BhLcUfRB.js +0 -7
- package/dist/assets/useMobileNavigationStore-1xHjnAsg.js +0 -475
- package/dist/assets/useSessionAutoCleanup-BFletAeV.js +0 -1
- package/dist/assets/useUIStore-D6BTB4va.js +0 -1
- package/dist/assets/zh-CN-9v-RC966.js +0 -15
- package/dist/assets/zh-TW-BZ_wZdC-.js +0 -15
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-PzT84wSx.js","assets/rolldown-runtime-C0FnF6B9.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.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-Bs_2iBAm.js","assets/persistence-C_KCiMcY.js","assets/useUIStore-D6BTB4va.js","assets/vendor-zustand-B4dlGEM2.js","assets/vendor-base-ui-CnHfUmDN.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-react-DLPElpoQ.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/gitApiHttp-C1DaEMKR.js","assets/vendor-opencode-sdk-C07HQypa.js","assets/useMobileNavigationStore-1xHjnAsg.js","assets/vendor-tanstack-react-query-D7pys_c9.js","assets/vendor-sonner-DVzioF3d.js","assets/clipboard-CXWbHCAk.js","assets/store-oojlrF4d.js","assets/useAssistantUIStore-ESTV1mEY.js","assets/vendor-fuse.js-DB5wDJbI.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{A as t,C as n,E as r,P as i,U as a,Y as o,b as s,j as c,k as l,t as u}from"./useUIStore-D6BTB4va.js";import{$ as d,Sn as f,kn as p,kt as m,n as h,t as g,xn as _}from"./persistence-C_KCiMcY.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{kt as C,yt as w}from"./gitApiHttp-C1DaEMKR.js";import{a as T,n as E,o as D}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as O,t as k}from"./vendor-react-DLPElpoQ.js";/* empty css */import{r as A}from"./vendor-sonner-DVzioF3d.js";import{n as j}from"./vendor-reactuses-core-DDoDDyM9.js";import{i as M,n as ee,t as N}from"./clipboard-CXWbHCAk.js";import{n as P}from"./store-oojlrF4d.js";import{$n as F,Co as I,Da as L,Ea as R,En as z,Gt as B,Hi as V,I as H,It as te,Lt as ne,Qt as re,So as U,Sr as W,Ta as ie,Wt as ae,co as G,ei as oe,en as se,er as ce,gr as le,hr as ue,in as de,jr as fe,kt as pe,l as K,ma as q,nr as me,pa as he,r as ge,rn as _e,rr as ve,t as ye,tn as be,tr as xe,wo as Se,xr as Ce,yr as we,zt as Te}from"./useMobileNavigationStore-1xHjnAsg.js";import{a as Ee,c as De,d as Oe,f as ke,l as Ae,o as je,p as Me,t as Ne,u as Pe}from"./MobileShareBridge-DAlvgjo1.js";import{_ as Fe,t as Ie,y as Le}from"./MobileDetailNavigation-lVtCe-5P.js";import{r as Re}from"./useAssistantUIStore-ESTV1mEY.js";import{t as ze}from"./AgentAvatar-C6Hxu5_o.js";import{t as J}from"./utils-DyUyiLje.js";import{n as Y}from"./Icon-BPJ_quEe.js";import{t as X}from"./button-BmNJBT13.js";import{F as Be,I as Ve,M as He,N as Ue,p as We}from"./gitApi-Bs_2iBAm.js";import{$ as Ge,B as Ke,C as qe,G as Je,H as Ye,J as Xe,K as Ze,R as Qe,S as $e,U as et,V as tt,W as nt,i as rt,o as it,q as at,r as ot,s as st,t as ct,z as lt}from"./useAppFontEffects-BhLcUfRB.js";import{D as ut,E as dt,a as ft,c as pt,i as mt,j as ht,n as gt,p as _t,r as vt,t as yt}from"./projectMeta-Cp74cItv.js";import{t as bt}from"./input-BLVhPvhN.js";import{r as xt}from"./tooltip-BYGBBTc2.js";import{c as St,f as Ct,o as wt,p as Tt,s as Et,u as Dt}from"./useSessionAutoCleanup-BFletAeV.js";import{n as Ot}from"./useThemeSystem-DMzWVJaW.js";import{J as kt,X as At,Y as jt,_ as Mt,b as Nt,y as Pt}from"./radio-Bs4mdPv5.js";import{a as Ft,n as It}from"./OverlayScrollbar-Dqk1zGJB.js";import{x as Lt}from"./markdownTheme-CCnvI6L0.js";import{H as Rt,M as zt,U as Bt,j as Vt,m as Ht,q as Ut,y as Wt,z as Gt}from"./ChatContainer-DEDGosbz.js";import{n as Kt}from"./useRuntimeAPIs-DSLXJybW.js";import{c as qt,i as Jt,l as Yt,o as Xt,s as Zt,t as Qt}from"./appThemeRegistry-BXeIggYO.js";import{_ as $t,i as en,l as tn,s as nn,t as rn,v as an,y as on}from"./vendor-dnd-kit-core-CvWxUPdb.js";import{a as sn,o as cn,s as ln,t as un}from"./vendor-dnd-kit-sortable-hHdP9lLb.js";import{a as dn}from"./url-CGHw6D-E.js";import{f as fn,h as pn,p as mn}from"./markdown-worker-Cq3Twp1A.js";import{n as hn}from"./useEffectiveDirectory-DG6uPzBG.js";import{f as gn}from"./FadeInOnReveal-CvNA_aGD.js";import{M as _n,b as vn,g as yn,x as bn,y as xn}from"./insertionBoundaries-BAFtAotq.js";import{a as Sn}from"./vendor-pierre-diffs-BenIz2TM.js";import{B as Cn,I as wn,J as Tn,Q as En,Y as Dn,Z as On,_ as kn,a as An,b as jn,i as Mn,n as Nn,o as Pn,p as Fn,r as In,t as Ln,v as Rn}from"./MobileSurface-Bde8yLWo.js";import{t as zn}from"./useFontPreferences-Bu4ME5hk.js";import{A as Bn,C as Vn,N as Hn,P as Un,_ as Wn,a as Gn,b as Kn,c as qn,d as Jn,f as Yn,g as Xn,h as Zn,i as Qn,j as $n,k as er,m as tr,n as nr,o as rr,p as ir,r as ar,s as or,t as sr,u as cr,v as lr,w as ur,y as dr}from"./runtimeEndpointReset-C0eCWIE6.js";import{a as fr,i as pr,o as mr,r as hr,t as gr}from"./SettingsView-D0dhTIur.js";import{a as _r,i as vr,n as yr,r as br,t as xr}from"./context-menu-BbRpMBQh.js";import{r as Sr,t as Cr}from"./AssistantView-CbnxMZU0.js";import{a as wr,i as Tr,r as Er}from"./fileQueries-i4oziMnC.js";var Z=e(x(),1),Dr=k(),Or=null,kr=!1,Ar=new Promise(e=>{Or=e});function jr(){kr||(kr=!0,Or?.())}var Mr=6,Nr=e=>e.parentID??null,Pr=e=>{let t=e.replace(/\/+$/,``);return t.slice(t.lastIndexOf(`/`)+1)||t},Fr=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),Ir=(e,t)=>{if(!e)return``;let n=null,r=-1;for(let i of t){let t=Fr(i.path);(e===t||e.startsWith(`${t}/`))&&t.length>r&&(n=i,r=t.length)}return Pr(n?n.path:e)},Lr=()=>{let e=W.getState().activeSessions,t=z.getState().index.session.unseenCount,n=G.getState().projects,r=0,i=[];for(let a of e){let e=Nr(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:Ir(we(a),n)})}i.sort((e,t)=>t.updated-e.updated);let a=i.slice(0,Mr).map(({id:e,title:t,unread:n,project:r})=>({id:e,title:t,unread:n,project:r}));return{attentionCount:r,recentSessions:a}},Rr=`__OPENCHAMBER_WIDGET_SNAPSHOT__`,zr=()=>{typeof window>`u`||(window[Rr]=()=>{try{return JSON.stringify(Lr())}catch{return null}})},Q=O(),Br=T(`OpenChamberExternalBrowser`),Vr={getPlatform:()=>E.getPlatform(),isPluginAvailable:e=>E.isPluginAvailable(e),openInSystemBrowser:e=>Br.open(e),openExternal:dn},Hr=async(e,t=Vr)=>{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(),Ur=`mobile-app-update-available`,Wr=`mobile-app-update-toast-dismissed-version`,Gr=()=>{let e=(0,Q.c)(8),{t}=ee(),n=Cn(Kr),r=Cn(qr),i=Cn(Jr),a=Cn(Yr),o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=new Set,e[0]=o):o=e[0];let c=Z.useRef(o),l,u;return e[1]!==n||e[2]!==a||e[3]!==r||e[4]!==t||e[5]!==i?(l=()=>{if(U()!==`android`||r!==`mobile`||!n||!i||!a){F.dismiss(Ur);return}s().getItem(Wr)!==i&&(c.current.has(i)||(c.current.add(i),F.info(t(`mobileUpdate.toast.available.title`),{id:Ur,description:t(`mobileUpdate.toast.available.description`,{version:i}),duration:1/0,icon:(0,$.jsx)(Y,{name:`download`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.toast.actions.download`),onClick:()=>{Hr(a)}},cancel:{label:t(`mobileUpdate.toast.actions.dismiss`),onClick:()=>{s().setItem(Wr,i),F.dismiss(Ur)}}})))},u=[n,a,r,t,i],e[1]=n,e[2]=a,e[3]=r,e[4]=t,e[5]=i,e[6]=l,e[7]=u):(l=e[6],u=e[7]),Z.useEffect(l,u),null};function Kr(e){return e.available}function qr(e){return e.runtimeType}function Jr(e){return e.info?.version}function Yr(e){return e.info?.downloadUrl}var Xr=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=J(`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=J(`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},Zr=`.oc-mobile-composer`;function Qr(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.closest==`function`&&!!t.closest(Zr)}function $r(e){if(!e||typeof e!=`object`||Qr(e))return!1;let t=e,n=typeof t.tagName==`string`?t.tagName.toUpperCase():``;return n===`TEXTAREA`||n===`INPUT`||t.isContentEditable===!0}function ei(e){return Qr(e??null)}function ti(e,t){return e?`cache`:Qr(t??null)?`open`:$r(t??null)?`field`:`ignore`}var ni=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),ri=e=>{let t=e.index?.trim();return!!(t&&t!==`?`)},ii=e=>{let t=e.working_dir?.trim(),n=e.index?.trim();return!!(t||n===`?`)},ai=(e,t)=>t?`${e}\u0000staged`:e,oi=({onClose:e,initialDiffPath:t,initialDiffStaged:n=!1,initialDiffTargetLine:r=null,hideDiffHeader:i=!1})=>{let{t:a}=ee(),{git:o}=Kt(),s=ni(hn()??null),c=xn(s||null),l=bn(s||null),u=yn(s||null),d=vn(e=>e.setActiveDirectory),f=vn(e=>e.ensureAll),p=vn(e=>e.fetchStatus),m=vn(e=>e.fetchBranches),h=vn(e=>e.prefetchDiffs),g=vn(e=>e.getDiff),_=vn(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),[M,N]=Z.useState(!1),[P,I]=Z.useState([]),[L,R]=Z.useState([]),[z,B]=Z.useState([]),[V,H]=Z.useState(null),[te,ne]=Z.useState({key:null,loading:!1,error:null,resolved:!1}),[re,U]=Z.useState(0),W=Z.useRef({key:null,generation:0}),ie=Z.useMemo(()=>{let e=c?.files??[],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]),ae=Z.useMemo(()=>ie.filter(ri),[ie]),G=Z.useMemo(()=>ie.filter(ii),[ie]),oe=Z.useMemo(()=>{if(z.length>0)return z;let e=c?.tracking?.includes(`/`)?c.tracking.split(`/`)[0]:null;return e||V?[{name:e||`origin`,fetchUrl:V??``,pushUrl:V??``}]:[]},[V,z,c?.tracking]),se=Z.useMemo(()=>e=>!s||v.type!==`diff`?null:e.directories.get(s)?.diffCache.get(ai(v.path,v.staged))??null,[s,v]),ce=vn(se),le=Z.useMemo(()=>v.type===`diff`?ie.find(e=>e.path===v.path)??null:null,[ie,v]),ue=v.type===`diff`&&s?`${s}\u0000${ai(v.path,v.staged)}`:null,de=te.key===ue,fe=!!(ue&&!ce&&(!de||te.loading)),pe=de?te.error:null,K=!!(le||de&&te.resolved),q=j(async(e,t=!0)=>{try{await Promise.all([p(e,o),m(e,o)])}catch(e){t&&F.error(e instanceof Error?e.message:a(`gitView.toast.refreshRepositoryFailed`))}}),me=j(async(e,t,n)=>{let r=()=>W.current.key===t&&W.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;B(t),H(n)}catch{if(!r())return;B([]),H(null)}}),he=j(e=>{if(e!==s)return{requestGeneration:null,promise:Promise.resolve()};let t=W.current.generation+1;return W.current={key:e,generation:t},{requestGeneration:t,promise:me(e,e,t)}});Z.useEffect(()=>{s&&(d(s),f(s,o))},[s,f,o,d]),Z.useEffect(()=>{if(!s){W.current={key:null,generation:W.current.generation+1},B([]),H(null);return}let{requestGeneration:e,promise:t}=he(s);return()=>{e!==null&&W.current.key===s&&W.current.generation===e&&(W.current={key:s,generation:e+1})}},[s,o,he]),Z.useEffect(()=>{if(!s||ie.length===0)return;let e=Array.from(new Set([...ae.map(e=>e.path),...L,...ie.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)},[ie,s,o,h,ae,L]),Z.useEffect(()=>{if(v.type!==`diff`){ne({key:null,loading:!1,error:null,resolved:!1});return}let e=ai(v.path,v.staged);if(!s||!ue){ne({key:null,loading:!1,error:null,resolved:!1});return}if(g(s,e)){ne(e=>({key:ue,loading:!1,error:null,resolved:e.key===ue&&e.resolved||!!le}));return}let t=!1;return ne({key:ue,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}),ne(e=>e.key===ue?{...e,loading:!1,error:null,resolved:!0}:e))}).catch(e=>{t||ne(t=>t.key===ue?{...t,loading:!1,error:e instanceof Error?e.message:String(e),resolved:!1}:t)}),()=>{t=!0}},[ue,s,re,g,o,v,le,_]);let ge=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}),F.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){F.error(a(`gitView.toast.commitOrStashBeforeSync`));return}await o.gitPull(n,r(t))}((await o.getGitStatus(n)).ahead??0)>0&&await o.gitPush(n),F.success(a(`gitView.toast.alreadyUpToDate`))}await q(n,!1),await he(n).promise}catch(e){F.error(e instanceof Error?e.message:a(`gitView.toast.syncActionFailed`,{action:a(`gitView.sync.syncChanges`)}))}finally{S(null)}},_e=j(async(e,t)=>{if(!s||e.length===0)return;let n=s;try{t===`stage`?e.length>1?await Ue(n,e):await He(n,e[0]):e.length>1?await Ve(n,e):await Be(n,e[0]),await q(n,!1)}catch(e){F.error(e instanceof Error?e.message:a(t===`stage`?`gitView.toast.stageFileFailed`:`gitView.toast.unstageFileFailed`))}}),ve=j((e,t=!1)=>{y({type:`diff`,path:e,staged:t,targetLine:null})}),ye=j(()=>v.type===`diff`&&(y({type:`list`}),!0));qt({id:`mobile-changes-diff`,active:v.type===`diff`&&!i,layer:`overlay`,onBack:ye,surfaceRef:b});let be=j(async e=>{if(!s)return;let t=s;O(t=>new Set(t).add(e));try{await o.revertGitFile(t,e),F.success(a(`gitView.toast.revertedFile`,{path:e})),await q(t,!1)}catch(e){F.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{O(t=>{let n=new Set(t);return n.delete(e),n})}}),xe=j(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 q(t,!1),F.success(n.length===1?a(`gitView.toast.revertedFilesSingle`,{count:n.length}):a(`gitView.toast.revertedFilesPlural`,{count:n.length}))}catch(e){F.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{O(new Set),A(!1)}}),Se=j(e=>{let t=e.map(e=>e.trim()).filter(Boolean);if(t.length===0){I([]);return}E(e=>`${e.trim()}${e.trim()?`
|
|
3
|
-
|
|
4
|
-
`:``}${t.join(`
|
|
5
|
-
`)}`.trim()),I([])}),Ce=j(async()=>{if(!s)return;let e=s,t=ae.map(e=>e.path).sort();if(t.length===0){F.error(a(`gitView.toast.selectFileToDescribe`));return}N(!0);try{let{message:n}=await We(e,t);E(n.subject?.trim()??``),I(Array.isArray(n.highlights)?n.highlights:[])}catch(e){F.error(e instanceof Error?e.message:a(`gitView.toast.generateCommitMessageFailed`))}finally{N(!1)}}),we=async(e={})=>{if(!s)return;let t=s;if(!T.trim()){F.error(a(`gitView.toast.enterCommitMessage`));return}let n=ae.map(e=>e.path).sort();if(n.length===0){F.error(a(`gitView.toast.selectFileToCommit`));return}w(e.pushAfter?`commitAndPush`:`commit`);try{if(await o.createGitCommit(t,T.trim(),{files:n}),F.success(a(`gitView.toast.commitCreated`)),E(``),I([]),e.pushAfter){let e=c?.tracking?.split(`/`)[0],n=oe.find(t=>t.name===e)??oe[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 q(t,!1),await he(t).promise}else await q(t,!1)}catch(e){F.error(e instanceof Error?e.message:a(`gitView.toast.createCommitFailed`))}finally{w(null),e.pushAfter&&S(null)}},Te=Z.useMemo(()=>{let e=[];return ae.length>0&&e.push({id:`staged`,title:a(`gitView.changes.stagedTitle`),entries:ae,actionSymbol:`-`,actionAllLabel:a(`gitView.changes.unstageAllAria`),getActionLabel:e=>a(`gitView.changes.unstageFileAria`,{path:e}),onActionFile:e=>void _e([e],`unstage`),onActionAll:e=>void _e(e,`unstage`),onViewDiff:e=>ve(e,!0),onRevertFile:be,showRevertActions:!1,accent:!0}),G.length>0&&e.push({id:`unstaged`,title:a(`gitView.changes.title`),entries:G,actionSymbol:`+`,actionAllLabel:a(`gitView.changes.stageAllAria`),getActionLabel:e=>a(`gitView.changes.stageFileAria`,{path:e}),onActionFile:e=>void _e([e],`stage`),onActionAll:e=>void _e(e,`stage`),onViewDiff:e=>ve(e,!1),onRevertFile:be}),e},[be,ve,_e,ae,a,G]),Ee=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)(Y,{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?Ee((0,$.jsx)(si,{loading:!0,message:a(`gitView.loading.checkingRepository`)})):l===!1?Ee((0,$.jsx)(si,{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)(ci,{path:v.path,diff:ce,fileExists:K,error:pe,loading:fe,targetLine:v.targetLine,onBack:ye,onRetry:()=>U(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)(Y,{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)(qn,{syncAction:x,remotes:oe,onSync:e=>void ge(`sync`,e),disabled:C!==null||u,aheadCount:c?.ahead??0,behindCount:c?.behind??0,trackingRemoteName:c?.tracking?.split(`/`)[0],hasUncommittedChanges:ie.length>0})]}),ie.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)(Qn,{groups:Te,diffStats:c?.diffStats,revertingPaths:D,onRevertAll:xe,isRevertingAll:k,headerBackgroundClassName:`bg-transparent`,onVisiblePathsChange:R})}),(0,$.jsx)(`div`,{className:`shrink-0 border-t border-border/50 px-4 pb-4 pt-3`,children:(0,$.jsx)(ar,{stagedCount:ae.length,commitMessage:T,onCommitMessageChange:E,generatedHighlights:P,onInsertHighlights:Se,onGenerateMessage:Ce,isGeneratingMessage:M,onCommit:()=>void we({pushAfter:!1}),onCommitAndPush:()=>void we({pushAfter:!0}),commitAction:C,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(si,{icon:!0,message:a(`gitView.empty.cleanTitle`),description:a(`mobile.changes.cleanDescription`)})})]}):Ee((0,$.jsx)(si,{message:a(`gitView.empty.selectSessionOrDirectory`)}))},si=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)(Y,{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)(Y,{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},ci=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=mn(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)(Y,{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)(X,{type:`button`,size:`sm`,variant:`outline`,onClick:l,children:f(`diffView.actions.retry`)})]})}):o?(0,$.jsx)(si,{loading:!0,message:f(`diffView.state.loadingDiff`)}):i?r?r.isBinary?(0,$.jsx)(si,{icon:!0,message:f(`diffView.binary.unavailable`)}):pn(n)?(0,$.jsx)(si,{icon:!0,message:f(`mobile.changes.diffDetail.imageUnavailable`)}):(0,$.jsx)(ht,{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)(ur,{original:r.original,modified:r.modified,language:m,fileName:n,renderSideBySide:!1,wrapLines:!0,focusLine:s,layout:`inline`})}):(0,$.jsx)(si,{loading:!0,message:f(`diffView.state.loadingDiff`)}):(0,$.jsx)(si,{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],_},li=25e4,ui=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),di=e=>{let t=ui(e);return!t||t===`/`?t||`/`:t.split(`/`).filter(Boolean).at(-1)??t},fi=e=>{let t=ui(e);if(!t||t===`/`)return null;let n=t.lastIndexOf(`/`);return n<=0?t.startsWith(`/`)?`/`:null:t.slice(0,n)},pi=(e,t)=>{let n=ui(e),r=ui(t);return!r||n===r?di(n):n.startsWith(`${r}/`)?n.slice(r.length+1):n},mi=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``},hi=e=>e.toLowerCase().endsWith(`.svg`)?``:i().authenticatedAsset(`/api/fs/raw`,{path:e}),gi=e=>/\.(md|mdx|markdown)$/i.test(e),_i=e=>{let t=(0,Q.c)(138),{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:d}=Kt(),f=hn()??null,p;t[0]===f?p=t[1]:(p=ui(f),t[0]=f,t[1]=p);let m=p,h;t[2]!==o||t[3]!==m?(h=()=>{let e=ui(o);return e?{type:`file`,path:e,returnDirectory:fi(e)??m}:{type:`browser`,directory:m}},t[2]=o,t[3]=m,t[4]=h):h=t[4];let[g,_]=Z.useState(h),v=Z.useRef(null),[y,b]=Z.useState(``),x=u(Ci),S=u(wi),C,w;t[5]===m?(C=t[6],w=t[7]):(C=()=>{m&&_(e=>e.type===`file`?e.returnDirectory?e:{...e,returnDirectory:fi(e.path)??m}:e.type===`browser`&&e.directory?e:{type:`browser`,directory:m})},w=[m],t[5]=m,t[6]=C,t[7]=w),Z.useEffect(C,w);let T,E;t[8]!==x||t[9]!==m||t[10]!==S?(E=()=>{if(!x||!m)return;let e=ui(x);if(!e){S(null);return}b(``),_({type:`file`,path:e,returnDirectory:fi(e)??m}),S(null)},T=[x,m,S],t[8]=x,t[9]=m,t[10]=S,t[11]=T,t[12]=E):(T=t[11],E=t[12]),Z.useEffect(E,T);let D=g.type===`browser`?g.directory:g.returnDirectory,O=g.type===`browser`?g.directory:``,k=g.type===`file`?g.path:``,A=_n(y,250),M;t[13]===y?M=t[14]:(M=y.trim(),t[13]=y,t[14]=M);let P=M,I;t[15]===A?I=t[16]:(I=A.trim(),t[15]=A,t[16]=I);let L=I,R;t[17]!==O||t[18]!==m?(R={scopeDirectory:m,directory:O},t[17]=O,t[18]=m,t[19]=R):R=t[19];let z=!!O,B;t[20]===z?B=t[21]:(B={enabled:z,refetchOnMount:`always`},t[20]=z,t[21]=B);let V=Tr(R,B),H;t[22]!==O||t[23]!==L?(H={directory:O,query:L,maxResults:40},t[22]=O,t[23]=L,t[24]=H):H=t[24];let te=!!(O&&L),ne;t[25]===te?ne=t[26]:(ne={enabled:te},t[25]=te,t[26]=ne);let re=wr(H,ne),U;t[27]!==k||t[28]!==d?(U=k&&d.readFile&&(!pn(k)||k.toLowerCase().endsWith(`.svg`)),t[27]=k,t[28]=d,t[29]=U):U=t[29];let W=!!U,ie;t[30]!==k||t[31]!==m?(ie={scopeDirectory:m,path:k},t[30]=k,t[31]=m,t[32]=ie):ie=t[32];let ae;t[33]===W?ae=t[34]:(ae={enabled:W},t[33]=W,t[34]=ae);let G=Er(ie,ae),oe=V.data?.entries.slice().sort(Ti)??[],se;t[35]!==V.error||t[36]!==l?(se=V.error?V.error instanceof Error?V.error.message:l(`mobile.files.error.listFailed`):null,t[35]=V.error,t[36]=l,t[37]=se):se=t[37];let ce=se,le=V.isFetching,ue;t[38]===re.data?ue=t[39]:(ue=re.data??[],t[38]=re.data,t[39]=ue);let de=ue,fe=!!(P&&L&&y===A&&re.isFetching),pe;t[40]!==G.data||t[41]!==l?(pe=G.data&&G.data.length>li?`${G.data.slice(0,li)}\n\n${l(`mobile.files.file.truncated`)}`:G.data??``,t[40]=G.data,t[41]=l,t[42]=pe):pe=t[42];let K=pe,q;t[43]!==k||t[44]!==G.error||t[45]!==d||t[46]!==l?(q=k&&!d.readFile?l(`mobile.files.error.readUnavailable`):G.error?G.error instanceof Error?G.error.message:l(`filesView.error.readFileFailed`):null,t[43]=k,t[44]=G.error,t[45]=d,t[46]=l,t[47]=q):q=t[47];let me=q,he=W&&G.isFetching,ge;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(ge=e=>{b(``),_({type:`browser`,directory:e})},t[48]=ge):ge=t[48];let _e=ge,ve;t[49]!==D||t[50]!==m?(ve=e=>{_({type:`file`,path:e,returnDirectory:D||m})},t[49]=D,t[50]=m,t[51]=ve):ve=t[51];let ye=ve,be;t[52]!==s||t[53]!==n||t[54]!==g.returnDirectory||t[55]!==g.type?(be=()=>g.type===`file`?s?(n?.(),!0):(_({type:`browser`,directory:g.returnDirectory}),!0):!1,t[52]=s,t[53]=n,t[54]=g.returnDirectory,t[55]=g.type,t[56]=be):be=t[56];let xe=j(be),Se=g.type===`file`,Ce;t[57]!==xe||t[58]!==Se?(Ce={id:`mobile-files-detail`,active:Se,layer:`overlay`,onBack:xe,surfaceRef:v},t[57]=xe,t[58]=Se,t[59]=Ce):Ce=t[59],qt(Ce);let we;t[60]===l?we=t[61]:(we=async e=>{(await N(e)).ok||F.error(l(`mobile.files.toast.copyFailed`))},t[60]=l,t[61]=we);let Te=we,Ee;t[62]!==K||t[63]!==l?(Ee=async()=>{(await N(K)).ok?F.success(l(`mobile.files.toast.contentCopied`)):F.error(l(`mobile.files.toast.copyFailed`))},t[62]=K,t[63]=l,t[64]=Ee):Ee=t[64];let De=Ee;if(!m){let e;t[65]===l?e=t[66]:(e=l(`mobile.files.empty.noDirectory`),t[65]=l,t[66]=e);let n;return t[67]===e?n=t[68]:(n=(0,$.jsx)(Si,{message:e}),t[67]=e,t[68]=n),n}if(g.type===`file`){let e;t[69]!==Te||t[70]!==g.path?(e=()=>void Te(g.path),t[69]=Te,t[70]=g.path,t[71]=e):e=t[71];let n;t[72]===De?n=t[73]:(n=()=>void De(),t[72]=De,t[73]=n);let r;return t[74]!==xe||t[75]!==K||t[76]!==me||t[77]!==c||t[78]!==he||t[79]!==g.path||t[80]!==e||t[81]!==n?(r=(0,$.jsx)(`div`,{ref:v,className:`h-full min-h-0`,children:(0,$.jsx)(bi,{path:g.path,content:K,error:me,isLoading:he,hideHeader:c,onBack:xe,onCopyPath:e,onCopyContent:n})}),t[74]=xe,t[75]=K,t[76]=me,t[77]=c,t[78]=he,t[79]=g.path,t[80]=e,t[81]=n,t[82]=r):r=t[82],r}let Oe;t[83]!==m||t[84]!==g.directory||t[85]!==l?(Oe=g.directory===m?l(`mobile.files.rootDirectory`):di(g.directory),t[83]=m,t[84]=g.directory,t[85]=l,t[86]=Oe):Oe=t[86];let ke=Oe,Ae;t[87]!==y||t[88]!==de?(Ae=y.trim()?de:[],t[87]=y,t[88]=de,t[89]=Ae):Ae=t[89];let je=Ae,Me,Ne,Pe,Fe;if(t[90]!==n||t[91]!==y||t[92]!==m||t[93]!==g.directory||t[94]!==l){let e=fi(g.directory),r=g.directory!==m&&e!==null&&(e===m||e.startsWith(`${m}/`)),i=r&&!y.trim(),a=r?e:null;Fe=`flex h-full flex-col overflow-hidden bg-background text-foreground`,Me=`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,t[99]!==n||t[100]!==l?(Ne=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)(Y,{name:`close`,className:`size-5`})}):null,t[99]=n,t[100]=l,t[101]=Ne):Ne=t[101],Pe=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:di(a)}),onClick:()=>_e(a),style:{touchAction:`manipulation`},children:(0,$.jsx)(Y,{name:`arrow-left`,className:`size-5`})}):null,t[90]=n,t[91]=y,t[92]=m,t[93]=g.directory,t[94]=l,t[95]=Me,t[96]=Ne,t[97]=Pe,t[98]=Fe}else Me=t[95],Ne=t[96],Pe=t[97],Fe=t[98];let Ie;t[102]===ke?Ie=t[103]:(Ie=(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label text-foreground`,children:ke})}),t[102]=ke,t[103]=Ie);let Le;t[104]===l?Le=t[105]:(Le=l(`mobile.files.refreshAria`),t[104]=l,t[105]=Le);let Re;t[106]===V?Re=t[107]:(Re=()=>void V.refetch(),t[106]=V,t[107]=Re);let ze;t[108]===Symbol.for(`react.memo_cache_sentinel`)?(ze={touchAction:`manipulation`},t[108]=ze):ze=t[108];let X=le&&`animate-spin`,Be;t[109]===X?Be=t[110]:(Be=J(`size-5`,X),t[109]=X,t[110]=Be);let Ve;t[111]===Be?Ve=t[112]:(Ve=(0,$.jsx)(Y,{name:`refresh`,className:Be}),t[111]=Be,t[112]=Ve);let He;t[113]!==Le||t[114]!==Re||t[115]!==Ve?(He=(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":Le,onClick:Re,style:ze,children:Ve}),t[113]=Le,t[114]=Re,t[115]=Ve,t[116]=He):He=t[116];let Ue;t[117]!==Me||t[118]!==Ne||t[119]!==Pe||t[120]!==Ie||t[121]!==He?(Ue=(0,$.jsxs)(`header`,{className:Me,children:[Ne,Pe,Ie,He]}),t[117]=Me,t[118]=Ne,t[119]=Pe,t[120]=Ie,t[121]=He,t[122]=Ue):Ue=t[122];let We;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(We=(0,$.jsx)(Y,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),t[123]=We):We=t[123];let Ge;t[124]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=e=>b(e.target.value),t[124]=Ge):Ge=t[124];let Ke;t[125]===l?Ke=t[126]:(Ke=l(`mobile.files.search.placeholder`),t[125]=l,t[126]=Ke);let qe;t[127]!==y||t[128]!==Ke?(qe=(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[We,(0,$.jsx)(bt,{value:y,onChange:Ge,placeholder:Ke,className:`h-11 pl-9`})]})}),t[127]=y,t[128]=Ke,t[129]=qe):qe=t[129];let Je=ht,Ye=ce?(0,$.jsx)(Si,{message:ce}):y.trim()?(0,$.jsx)(yi,{results:je,isSearching:fe,onOpenFile:ye}):(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:[oe.length===0&&!le?(0,$.jsx)(`div`,{className:`px-4 py-8 text-center typography-body text-muted-foreground`,children:l(`mobile.files.empty.directory`)}):null,oe.map(e=>(0,$.jsx)(vi,{name:e.name,path:e.path,directory:e.isDirectory,meta:e.isDirectory?void 0:mi(e.size),onClick:()=>e.isDirectory?_e(e.path):ye(e.path)},e.path))]}),Xe;t[130]!==Je||t[131]!==Ye?(Xe=(0,$.jsx)(Je,{className:`min-h-0 flex-1 overflow-y-auto px-4 pb-3`,children:Ye}),t[130]=Je,t[131]=Ye,t[132]=Xe):Xe=t[132];let Ze;return t[133]!==Fe||t[134]!==Ue||t[135]!==qe||t[136]!==Xe?(Ze=(0,$.jsxs)(`div`,{className:Fe,children:[Ue,qe,Xe]}),t[133]=Fe,t[134]=Ue,t[135]=qe,t[136]=Xe,t[137]=Ze):Ze=t[137],Ze},vi=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)(Y,{name:`folder-3-fill`,className:`size-5 shrink-0 text-muted-foreground`}):(0,$.jsx)(Bt,{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)(Y,{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},yi=e=>{let t=(0,Q.c)(10),{results:n,isSearching:r,onOpenFile:i}=e,{t:a}=ee(),o=ui(hn()??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)(Si,{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)(Si,{message:e}),t[6]=e,t[7]=n),n}let s=n.map(e=>(0,$.jsx)(vi,{name:di(e.path),path:e.path,directory:!1,meta:pi(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},bi=e=>{let t=(0,Q.c)(35),{path:i,content:s,error:c,isLoading:l,hideHeader:u,onBack:d,onCopyPath:f,onCopyContent:m}=e,h=u!==void 0&&u,{t:g}=ee(),_=pn(i)&&!i.toLowerCase().endsWith(`.svg`)?i:``,v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=r(),t[0]=v):v=t[0];let y=v,b;t[1]===_?b=t[2]:(b=_&&o()?`${y}|${_}`:``,t[1]=_,t[2]=b);let x=b,S=_&&!x?`${y}|${_}`:``,[C,w]=Z.useState(``),[T,E]=Z.useState(``),[D,O]=Z.useState(null),[k,A]=Z.useState(!1),j,M;t[3]===S?(j=t[4],M=t[5]):(j=()=>{if(!S){w(``);return}let e=!1;return w(``),a(n()).then(t=>{!e&&t&&w(S)}).catch(Ei),()=>{e=!0}},M=[S],t[3]=S,t[4]=j,t[5]=M),Z.useEffect(j,M);let N,P;t[6]!==_||t[7]!==x||t[8]!==g?(N=()=>{if(!x){E(``),O(null),A(!1);return}let e=!1,t=``;return E(``),O(null),A(!0),p(`/api/fs/raw`,{query:{path:_}}).then(async e=>{if(!e.ok)throw Error(g(`filesView.error.readFileFailed`));return e.blob()}).then(n=>{if(t=URL.createObjectURL(n),e){URL.revokeObjectURL(t);return}E(t)}).catch(t=>{e||O(t instanceof Error?t.message:g(`filesView.error.readFileFailed`))}).finally(()=>{e||A(!1)}),()=>{e=!0,t&&URL.revokeObjectURL(t)}},P=[_,x,g],t[6]=_,t[7]=x,t[8]=g,t[9]=N,t[10]=P):(N=t[9],P=t[10]),Z.useEffect(N,P);let F=!!(S&&C!==S),I;t[11]!==F||t[12]!==i||t[13]!==x||t[14]!==T?(I=x?T:F?``:hi(i),t[11]=F,t[12]=i,t[13]=x,t[14]=T,t[15]=I):I=t[15];let L=I,R=c??D,z;t[16]!==h||t[17]!==d||t[18]!==m||t[19]!==f||t[20]!==i||t[21]!==g?(z=h?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1 px-3 pb-1`,children:[pn(i)?null:(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,onClick:m,"aria-label":g(`mobile.files.copyContentAria`),children:(0,$.jsx)(Y,{name:`file-copy`,className:`size-4`})}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,onClick:f,"aria-label":g(`mobile.files.copyPathAria`),children:(0,$.jsx)(Y,{name:`clipboard`,className:`size-4`})})]}):(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":g(`header.actions.backAria`),onClick:d,children:(0,$.jsx)(Y,{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:di(i)})}),pn(i)?null:(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,onClick:m,"aria-label":g(`mobile.files.copyContentAria`),children:(0,$.jsx)(Y,{name:`file-copy`,className:`size-4`})}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,onClick:f,"aria-label":g(`mobile.files.copyPathAria`),children:(0,$.jsx)(Y,{name:`clipboard`,className:`size-4`})})]}),t[16]=h,t[17]=d,t[18]=m,t[19]=f,t[20]=i,t[21]=g,t[22]=z):z=t[22];let B;t[23]!==s||t[24]!==F||t[25]!==R||t[26]!==L||t[27]!==l||t[28]!==k||t[29]!==i||t[30]!==g?(B=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:l||F||k?(0,$.jsx)(Si,{loading:!0,message:g(`filesView.state.loading`)}):R?(0,$.jsx)(Si,{message:R}):pn(i)&&L?(0,$.jsx)(ht,{className:`h-full overflow-auto p-4`,children:(0,$.jsx)(`img`,{src:L,alt:di(i),className:`mx-auto max-h-full max-w-full rounded-lg object-contain`})}):pn(i)?(0,$.jsx)(ht,{className:`h-full overflow-auto p-4`,children:(0,$.jsx)(`img`,{src:`data:${fn(i)};utf8,${encodeURIComponent(s)}`,alt:di(i),className:`mx-auto max-h-full max-w-full rounded-lg object-contain`})}):(0,$.jsx)(xi,{path:i,content:s})}),t[23]=s,t[24]=F,t[25]=R,t[26]=L,t[27]=l,t[28]=k,t[29]=i,t[30]=g,t[31]=B):B=t[31];let V;return t[32]!==B||t[33]!==z?(V=(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[z,B]}),t[32]=B,t[33]=z,t[34]=V):V=t[34],V},xi=e=>{let t=(0,Q.c)(30),{path:n,content:r}=e,{currentTheme:i,availableThemes:a,lightThemeId:o,darkThemeId:s}=Ot(),c;t[0]!==a||t[1]!==o?(c=a.find(e=>e.metadata.id===o)??Lt(!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)??Lt(!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=()=>{Qt(l),Qt(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(gi(n)){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(ht,{className:`h-full overflow-y-auto px-4 py-4`,children:(0,$.jsx)(Jt,{content:r,enableFileReferences:!1})}),t[13]=r,t[14]=e),e}let g;t[15]===n?g=t[16]:(g=di(n),t[15]=n,t[16]=g);let _;t[17]===n?_=t[18]:(_=mn(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:Vn},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)(ht,{className:`min-h-0 flex-1 overflow-auto bg-[var(--syntax-base-background)]`,children:(0,$.jsx)(Sn,{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},Si=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)(Y,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):(0,$.jsx)(Y,{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 Ci(e){return e.pendingFileFocusPath}function wi(e){return e.setPendingFileFocusPath}function Ti(e,t){return e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1}function Ei(){}var Di=v(e=>({expandedParents:{},toggleParent:t=>e(e=>{let n={...e.expandedParents};return n[t]?delete n[t]:n[t]=!0,{expandedParents:n}})})),Oi=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:m()}));typeof window<`u`&&t(e=>{l(e)&&Oi.persist.rehydrate()});var ki=e(S(),1),Ai=`mobile-surface-root`,ji=90,Mi=16,Ni=100,Pi=48,Fi=8,Ii=()=>{if(typeof document>`u`)return null;let e=document.getElementById(Ai);return e||(e=document.createElement(`div`),e.id=Ai,document.body.appendChild(e)),e},Li=({open:e,onClose:t,title:n,subtitle:r,trailing:i,onBack:a,disableSwipeDismiss:o=!1,headerless:s=!1,ariaLabel:c,children:l})=>{let{t:u}=ee(),d=Z.useRef(null),[f,p]=Z.useState(!1),[m,h]=Z.useState(!1),[g,_]=Z.useState(!1),[v,y]=Z.useState(0),b=Z.useRef(null),x=Z.useRef(!1),S=Z.useRef(null),C=Z.useRef(null),w=Z.useRef(t);Z.useEffect(()=>{w.current=t},[t]),typeof document<`u`&&!d.current&&(d.current=Ii()),Z.useEffect(()=>{if(e){p(!0);let e=window.setTimeout(()=>h(!0),Mi);return()=>window.clearTimeout(e)}h(!1);let t=window.setTimeout(()=>p(!1),300);return()=>window.clearTimeout(t)},[e]),Z.useEffect(()=>{if(!e){_(!1);return}let t=window.setTimeout(()=>_(!0),196);return()=>window.clearTimeout(t)},[e]),Z.useEffect(()=>{if(!e)return;let t=document.body.style.overflow;C.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow=`hidden`;let n=window.setTimeout(()=>{let e=S.current;e&&(e.querySelector(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)??e).focus({preventScroll:!0})},Mi),r=e=>{if(e.key===`Escape`){w.current();return}if(e.key!==`Tab`)return;let t=S.current;if(!t)return;let n=Array.from(t.querySelectorAll(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.hasAttribute(`disabled`)&&e.getAttribute(`aria-hidden`)!==`true`);if(n.length===0){e.preventDefault(),t.focus({preventScroll:!0});return}let r=n[0],i=n[n.length-1],a=document.activeElement;e.shiftKey&&a===r?(e.preventDefault(),i.focus({preventScroll:!0})):!e.shiftKey&&a===i&&(e.preventDefault(),r.focus({preventScroll:!0}))};return document.addEventListener(`keydown`,r),()=>{window.clearTimeout(n),document.body.style.overflow=t,document.removeEventListener(`keydown`,r),kt()||C.current?.focus?.({preventScroll:!0}),C.current=null}},[e]);let T=e=>{o||(b.current=e.touches[0]?.clientY??null,x.current=!0)},E=e=>{if(!x.current||b.current==null)return;let t=(e.touches[0]?.clientY??b.current)-b.current;y(t>0?t:0)},D=()=>{x.current&&(x.current=!1,b.current=null,v>=ji?(y(0),t()):y(0))};if(!f||!d.current)return null;let O=a?(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":u(`header.actions.backAria`),onClick:a,style:{touchAction:`manipulation`},children:(0,$.jsx)(Y,{name:`arrow-left`,className:`size-5`})}):(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":u(`mobile.surface.closeAria`),onClick:t,style:{touchAction:`manipulation`},children:(0,$.jsx)(Y,{name:`close`,className:`size-5`})}),k=m?v>0?`translateY(${v}px)`:`none`:`translateY(${Pi}px)`,A=n!=null||r!=null;return(0,ki.createPortal)((0,$.jsxs)(`div`,{className:J(`oc-keyboard-inset-surface fixed inset-0 z-50 flex flex-col bg-[rgb(0_0_0_/_0.45)]`,`transition-opacity duration-200 ease-out`,m?`opacity-100`:`opacity-0`),role:`dialog`,"aria-modal":`true`,"aria-label":c,onClick:t,children:[(0,$.jsxs)(`section`,{ref:S,className:`oc-mobile-surface-shell oc-mobile-floating-shell mt-auto flex min-h-0 w-full flex-col overflow-hidden rounded-t-[20px] border-t border-border/40 bg-background text-foreground`,tabIndex:-1,onClick:e=>e.stopPropagation(),onTransitionEnd:e=>{m&&e.target===e.currentTarget&&e.propertyName===`transform`&&_(!0)},style:{height:`calc(100% - var(--oc-safe-area-top, 0px) - ${Fi}px)`,transform:k,transition:x.current?`none`:`transform ${Ni}ms cubic-bezier(0.32, 0.72, 0, 1)`},children:[(0,$.jsxs)(`div`,{className:`shrink-0 select-none`,onTouchStart:T,onTouchMove:E,onTouchEnd:D,onTouchCancel:D,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-center pt-2 pb-1`,children:(0,$.jsx)(`span`,{className:`h-1 w-10 rounded-full bg-[var(--surface-muted)]`,"aria-hidden":!0})}),s?null:(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] items-center gap-2 px-3`,children:[A?O:null,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 px-1`,children:[n?typeof n==`string`?(0,$.jsx)(`h2`,{className:`truncate typography-ui-label text-foreground`,children:n}):n:null,r?typeof r==`string`?(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:r}):r:null]}),i?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:i}):null,A?null:O]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:g?(0,$.jsx)(`div`,{className:`h-full`,style:{animation:`oc-surface-content-in 200ms ease-out`},children:l}):null})]}),(0,$.jsx)(`style`,{children:`@keyframes oc-surface-content-in { from { opacity: 0 } to { opacity: 1 } }`})]}),d.current)},Ri=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/,``),zi=e=>{let t=(0,Q.c)(36),{worktree:n,onDelete:r}=e,{t:i}=ee(),a;t[0]===n.path?a=t[1]:(a={id:n.path},t[0]=n.path,t[1]=a);let{attributes:o,listeners:s,setNodeRef:c,transform:l,transition:u,isDragging:d}=cn(a),f;t[2]===l?f=t[3]:(f=on.Transform.toString(l),t[2]=l,t[3]=f);let p=d?10:1,m;t[4]!==f||t[5]!==p||t[6]!==u?(m={transform:f,transition:u,zIndex:p},t[4]=f,t[5]=p,t[6]=u,t[7]=m):m=t[7];let h=m,g=n.branch||n.label||n.path,_=d&&`shadow-lg shadow-black/20`,v;t[8]===_?v=t[9]:(v=J(`flex items-center gap-1 rounded-2xl border border-border/40 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors`,_),t[8]=_,t[9]=v);let y;t[10]!==g||t[11]!==i?(y=i(`mobile.projectEdit.dragWorktreeAria`,{label:g}),t[10]=g,t[11]=i,t[12]=y):y=t[12];let b;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(Y,{name:`drag-move-2`,className:`size-4`}),t[13]=b):b=t[13];let x;t[14]!==o||t[15]!==s||t[16]!==y?(x=(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing`,"aria-label":y,...o,...s,children:b}),t[14]=o,t[15]=s,t[16]=y,t[17]=x):x=t[17];let S;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(Y,{name:`node-tree`,className:`size-4 shrink-0 text-muted-foreground`}),t[18]=S):S=t[18];let C;t[19]===g?C=t[20]:(C=(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:g}),t[19]=g,t[20]=C);let w;t[21]!==g||t[22]!==i?(w=i(`mobile.projectEdit.deleteWorktreeAria`,{label:g}),t[21]=g,t[22]=i,t[23]=w):w=t[23];let T,E;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(T={touchAction:`manipulation`},E=(0,$.jsx)(Y,{name:`delete-bin`,className:`size-4`}),t[24]=T,t[25]=E):(T=t[24],E=t[25]);let D;t[26]!==r||t[27]!==w?(D=(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive`,"aria-label":w,onClick:r,style:T,children:E}),t[26]=r,t[27]=w,t[28]=D):D=t[28];let O;return t[29]!==c||t[30]!==h||t[31]!==C||t[32]!==D||t[33]!==v||t[34]!==x?(O=(0,$.jsxs)(`div`,{ref:c,style:h,className:v,children:[x,S,C,D]}),t[29]=c,t[30]=h,t[31]=C,t[32]=D,t[33]=v,t[34]=x,t[35]=O):O=t[35],O},Bi=({open:e,project:t,onClose:n,onWorktreesChanged:r})=>{let{t:i}=ee(),{currentTheme:a}=Ot(),o=G(e=>e.updateProjectMeta),s=G(e=>e.discoverProjectIcon),c=G(e=>e.removeProjectIcon),l=st(e=>e.setWorktreeOrder),u=G(e=>t?e.projects.find(e=>e.id===t.id)?.iconImage??null:null),[d,f]=Z.useState(``),[p,m]=Z.useState(null),[h,g]=Z.useState(null),[_,v]=Z.useState(!1),[y,b]=Z.useState([]),[x,S]=Z.useState(null),C=t?.id??null;Z.useEffect(()=>{!e||!t||(f(t.label),m(t.icon??null),g(t.color??null),b(t.worktrees))},[e,C]),Z.useEffect(()=>{!e||!t||b(e=>{let n=t.worktrees.map(e=>e.path),r=e.map(e=>e.path);return n.length===r.length&&n.every(e=>r.includes(e))?e:t.worktrees})},[t?.worktrees]);let w=an($t(nn,{activationConstraint:{distance:8}}),$t(en,{coordinateGetter:sn})),T=()=>{if(!t)return;let e=d.trim();o(t.id,{label:e||t.label,icon:p,color:h}),n()},E=()=>{!t||_||(v(!0),s(t.id).then(e=>{if(!e.ok){F.error(e.error||i(`projectEditDialog.toast.failedToDiscoverIcon`));return}if(e.skipped){F.success(i(`projectEditDialog.toast.customIconAlreadySet`));return}F.success(i(`projectEditDialog.toast.iconDiscovered`))}).finally(()=>v(!1)))},D=()=>{t&&c(t.id).then(e=>{if(!e.ok){F.error(e.error||i(`projectEditDialog.toast.failedToRemoveIcon`));return}F.success(i(`projectEditDialog.toast.iconRemoved`))})},O=e=>{let{active:n,over:r}=e;if(!r||n.id===r.id||!t)return;let i=y.findIndex(e=>e.path===n.id),a=y.findIndex(e=>e.path===r.id);if(i<0||a<0)return;let o=[...y],[s]=o.splice(i,1);o.splice(a,0,s),b(o),l(t.id,t.path,o.map(e=>Ri(e.path)))},k=h?gt[h]??null:null,A=p?mt[p]:null,j=!!u;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Li,{open:e,onClose:n,onBack:n,title:i(`projectEditDialog.title`),ariaLabel:i(`projectEditDialog.title`),trailing:(0,$.jsxs)(X,{type:`button`,variant:`default`,size:`sm`,"aria-label":i(`projectEditDialog.actions.save`),onClick:T,disabled:!d.trim(),style:{touchAction:`manipulation`},children:[(0,$.jsx)(Y,{name:`check`,className:`size-4`}),i(`projectEditDialog.actions.save`)]}),children:t?(0,$.jsxs)(`div`,{className:`h-full space-y-6 overflow-y-auto px-4 pb-8 pt-2`,children:[(0,$.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,$.jsx)(`span`,{className:`flex size-16 items-center justify-center overflow-hidden rounded-2xl bg-[var(--surface-muted)] text-muted-foreground`,style:t.iconBackground?{backgroundColor:t.iconBackground}:void 0,children:j?(0,$.jsx)(ft,{project:{id:t.id,iconImage:u},options:{themeVariant:a.metadata.variant,iconColor:a.colors.surface.foreground},className:`size-full object-contain`,fallback:(0,$.jsx)(Y,{name:`folder-6`,className:`size-7`})}):A?(0,$.jsx)(Y,{name:A,className:`size-7`,style:k?{color:k}:void 0}):(0,$.jsx)(Y,{name:`folder-6`,className:`size-7`,style:k?{color:k}:void 0})})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:i(`projectEditDialog.field.name`)}),(0,$.jsx)(bt,{value:d,onChange:e=>f(e.target.value),placeholder:i(`projectEditDialog.field.namePlaceholder`),className:`h-11`}),(0,$.jsx)(`p`,{className:`truncate typography-meta text-muted-foreground`,title:t.path,children:t.path})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:i(`projectEditDialog.field.color`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>g(null),"aria-label":i(`projectEditDialog.option.none`),className:J(`flex size-9 items-center justify-center rounded-xl border-2 transition-all`,h===null?`border-foreground`:`border-border hover:border-border/80`),style:{touchAction:`manipulation`},children:(0,$.jsx)(`span`,{className:`h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40`})}),yt.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>g(e.key),"aria-label":e.label,title:e.label,className:J(`size-9 rounded-xl border-2 transition-all`,h===e.key?`border-foreground`:`border-transparent hover:border-border`),style:{backgroundColor:e.cssVar,touchAction:`manipulation`}},e.key))]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:i(`projectEditDialog.field.icon`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(null),"aria-label":i(`projectEditDialog.option.none`),className:J(`flex size-9 items-center justify-center rounded-xl border-2 transition-all`,p===null?`border-foreground bg-[var(--surface-elevated)]`:`border-border hover:border-border/80`),style:{touchAction:`manipulation`},children:(0,$.jsx)(`span`,{className:`h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40`})}),vt.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(e.key),"aria-label":e.label,title:e.label,className:J(`flex size-9 items-center justify-center rounded-xl border-2 transition-all`,p===e.key?`border-foreground bg-[var(--surface-elevated)]`:`border-border hover:border-border/80`),style:{touchAction:`manipulation`},children:(0,$.jsx)(Y,{name:e.Icon,className:`size-4`,style:k?{color:k}:void 0})},e.key))]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[(0,$.jsx)(X,{size:`sm`,variant:`outline`,onClick:E,disabled:_,children:i(_?`projectEditDialog.actions.discovering`:`projectEditDialog.actions.discoverFavicon`)}),j?(0,$.jsx)(X,{size:`sm`,variant:`outline`,onClick:D,children:i(`projectEditDialog.actions.removeProjectIcon`)}):null]})]}),t.isGitRepo?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:i(`mobile.projectEdit.worktreesTitle`)}),y.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:i(`mobile.projectEdit.worktreesEmpty`)}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:i(`mobile.projectEdit.reorderHint`)}),(0,$.jsx)(rn,{sensors:w,collisionDetection:tn,onDragEnd:O,children:(0,$.jsx)(un,{items:y.map(e=>e.path),strategy:ln,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:y.map(e=>(0,$.jsx)(zi,{worktree:e,onDelete:()=>S(e)},e.path))})})})]})]}):null]}):null}),t?(0,$.jsx)(Xn,{open:!!x,project:{id:t.id,path:t.path},worktree:x,onClose:()=>S(null),onDeleted:()=>{b(e=>e.filter(e=>e.path!==x?.path)),r?.()}}):null]})},Vi=36,Hi=18,Ui=e=>e.parentID??null,Wi=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Gi=e=>{let t=e;return Wi(t.directory??t.project?.worktree??null)},Ki=e=>{let t=Wi(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},qi=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},Ji=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),Yi=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))},Xi=(e,t)=>{let n=Wi(e),r=Wi(t);return!!(n&&r&&(n===r||n.startsWith(`${r}/`)))},Zi=(e,t)=>e.worktrees.find(e=>Wi(e.path)===t)??null,Qi=(e,t)=>t===e.path||!!Zi(e,t),$i=(e,t)=>{let n=Wi(t);return n?e.find(e=>Qi(e,n))??null:null},ea=(e,t,n)=>!n||`${e.title??``} ${e.id} ${Gi(e)} ${t}`.toLowerCase().includes(n),ta=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?mt[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)(Y,{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=J(`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)(ft,{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},na=e=>{let t=(0,Q.c)(5),{expanded:n}=e,r=n?`rotate-0`:`-rotate-90`,i;t[0]===r?i=t[1]:(i=J(`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)(Y,{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},ra=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},ia=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=J(`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)(Y,{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},aa=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)(Y,{name:n,className:`size-5 shrink-0`}),t[1]=n,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[3]=r,t[4]=l);let u;return t[5]!==i||t[6]!==o||t[7]!==c||t[8]!==l?(u=(0,$.jsxs)(X,{type:`button`,variant:o,size:`default`,className:`min-h-12 w-full justify-start gap-3 rounded-xl px-3 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},oa=e=>{let t=(0,Q.c)(65),{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}=e,g=o!==void 0&&o,_=s!==void 0&&s,v=c!==void 0&&c,{t:y}=ee(),b;t[0]===n?b=t[1]:(b=Yi(qi(n)),t[0]=n,t[1]=b);let x=b,S;t[2]!==n.title||t[3]!==y?(S=n.title?.trim()||y(`mobile.sessions.untitled`),t[2]=n.title,t[3]=y,t[4]=S):S=t[4];let C=S,w=r&&!g&&`bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]`,T=g&&`bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]`,E;t[5]!==w||t[6]!==T?(E=J(`relative flex items-center gap-1 transition-colors`,w,T),t[5]=w,t[6]=T,t[7]=E):E=t[7];let D;t[8]!==v||t[9]!==_||t[10]!==i||t[11]!==l||t[12]!==y?(D=_&&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":y(v?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:e=>{e.stopPropagation(),l()},children:(0,$.jsx)(Y,{name:`arrow-down-s`,className:J(`size-[18px] transition-transform duration-150`,v?`rotate-0`:`-rotate-90`)})}):null,t[8]=v,t[9]=_,t[10]=i,t[11]=l,t[12]=y,t[13]=D):D=t[13];let O=g&&`opacity-50`,k=h.pressed&&`bg-interactive-active scale-[0.99]`,A;t[14]!==O||t[15]!==k?(A=J(`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,k),t[14]=O,t[15]=k,t[16]=A):A=t[16];let j;t[17]===i?j=t[18]:(j={paddingLeft:i,touchAction:`manipulation`},t[17]=i,t[18]=j);let M=h.onPointerDown,N=h.onPointerMove,P=h.onPointerUp,F=h.onPointerCancel,I=h.onContextMenu,L=r?`bg-primary`:`bg-muted-foreground/30`,R;t[19]===L?R=t[20]:(R=J(`size-1.5 shrink-0 rounded-full`,L),t[19]=L,t[20]=R);let z;t[21]===R?z=t[22]:(z=(0,$.jsx)(`span`,{className:R,"aria-hidden":!0}),t[21]=R,t[22]=z);let B=r?`text-primary`:`text-foreground`,V;t[23]===B?V=t[24]:(V=J(`block min-w-0 flex-1 truncate typography-ui-label`,B),t[23]=B,t[24]=V);let H;t[25]!==V||t[26]!==C?(H=(0,$.jsx)(`span`,{className:V,children:C}),t[25]=V,t[26]=C,t[27]=H):H=t[27];let te;t[28]===x?te=t[29]:(te=x?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:x}):null,t[28]=x,t[29]=te);let ne;t[30]!==z||t[31]!==H||t[32]!==te?(ne=(0,$.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[z,H,te]}),t[30]=z,t[31]=H,t[32]=te,t[33]=ne):ne=t[33];let re;t[34]===a?re=t[35]:(re=a?(0,$.jsx)(`span`,{className:`block truncate typography-micro text-muted-foreground pl-4`,children:a}):null,t[34]=a,t[35]=re);let U;t[36]!==ne||t[37]!==re?(U=(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[ne,re]}),t[36]=ne,t[37]=re,t[38]=U):U=t[38];let W;t[39]!==g||t[40]!==h.onContextMenu||t[41]!==h.onPointerCancel||t[42]!==h.onPointerDown||t[43]!==h.onPointerMove||t[44]!==h.onPointerUp||t[45]!==u||t[46]!==A||t[47]!==j||t[48]!==U?(W=(0,$.jsx)(`button`,{type:`button`,className:A,style:j,onClick:u,onPointerDown:M,onPointerMove:N,onPointerUp:P,onPointerCancel:F,onContextMenu:I,disabled:g,children:U}),t[39]=g,t[40]=h.onContextMenu,t[41]=h.onPointerCancel,t[42]=h.onPointerDown,t[43]=h.onPointerMove,t[44]=h.onPointerUp,t[45]=u,t[46]=A,t[47]=j,t[48]=U,t[49]=W):W=t[49];let ie;t[50]!==p||t[51]!==m?(ie=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)(dr,{})}):null,t[50]=p,t[51]=m,t[52]=ie):ie=t[52];let ae;t[53]!==g||t[54]!==f||t[55]!==d||t[56]!==y||t[57]!==C?(ae=d?(0,$.jsxs)($.Fragment,{children:[g?(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":y(`mobile.sessions.archiveSessionAria`,{title:C}),onClick:f,style:{touchAction:`manipulation`},children:[(0,$.jsx)(Y,{name:`archive`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label`,children:y(`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":y(g?`mobile.sessions.cancelArchiveAria`:`mobile.sessions.archiveSessionAria`,{title:C}),onClick:d,style:{touchAction:`manipulation`},children:g?(0,$.jsx)(Y,{name:`close`,className:`size-4`}):(0,$.jsx)(Y,{name:`archive`,className:`size-4`})})]}):null,t[53]=g,t[54]=f,t[55]=d,t[56]=y,t[57]=C,t[58]=ae):ae=t[58];let G;return t[59]!==W||t[60]!==ie||t[61]!==ae||t[62]!==E||t[63]!==D?(G=(0,$.jsxs)(`div`,{className:E,children:[D,W,ie,ae]}),t[59]=W,t[60]=ie,t[61]=ae,t[62]=E,t[63]=D,t[64]=G):G=t[64],G},sa=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)(Y,{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:J(`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)(Y,{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},ca=({open:e,onOpenChange:t,variant:n=`sheet`})=>{let{t:r}=ee(),{git:i}=Kt(),a=te(),o=W(e=>e.activeSessions),s=W(e=>e.activePaginationByDirectory),c=G(e=>e.projects),l=G(e=>e.activeProjectId),u=w(e=>e.currentDirectory),d=K(e=>e.currentSessionId),f=K(e=>e.availableWorktreesByProject),p=K(e=>e.setCurrentSession),m=K(e=>e.archiveSession),h=K(e=>e.archiveSessions),g=K(e=>e.updateSessionTitle),_=K(e=>e.requestSessionSmartTitle),v=K(e=>e.shareSession),y=K(e=>e.unshareSession),b=K(e=>e.openNewSessionDraft),x=G(e=>e.setActiveProject),S=G(e=>e.setActiveProjectIdOnly),C=G(e=>e.removeProject),T=Qe(e=>e.ids),E=Qe(e=>e.toggle),D=Oi(e=>e.projectExpanded),O=Oi(e=>e.worktreeExpanded),k=Oi(e=>e.setProjectExpanded),A=Oi(e=>e.setWorktreeExpanded),M=st(e=>e.orderByProject),P=Di(e=>e.expandedParents),I=Di(e=>e.toggleParent),[L,R]=Z.useState(``),[z,B]=Z.useState(null),[V,re]=Z.useState(null),[U,ie]=Z.useState(0),[ae,oe]=Z.useState(!1),[se,ce]=Z.useState(!1),[de,pe]=Z.useState(null),[q,me]=Z.useState(null),[he,ge]=Z.useState(null),[_e,ve]=Z.useState(null),[ye,be]=Z.useState(null),[xe,Se]=Z.useState(``),[we,Te]=Z.useState(!1),[Ee,De]=Z.useState(null),Oe=Z.useRef(null);Oe.current||=gn({onPressedKeyChange:ve});let[ke,Ae]=Z.useState(new Set),[je,Me]=Z.useState(new Map),[Ne,Pe]=Z.useState(new Map),Fe=ne(),Ie=Z.useMemo(()=>{let e={};for(let[t,n]of Object.entries(Fe))e[t]=n.type===`busy`||n.type===`retry`;return e},[Fe]),Le=j(e=>{H(e),fe(e)}),Re=j(e=>{Promise.all(e.map(e=>(H(e),fe(e))))});Z.useEffect(()=>{if(!e){R(``),Pe(new Map),B(null),re(null),me(null),be(null),De(null),Oe.current?.reset();return}},[e]),Z.useEffect(()=>()=>{Oe.current?.reset()},[]),Z.useEffect(()=>{if(!e)return;if(c.length===0){K.setState(e=>{let t=Zn(e.availableWorktreesByProject,new Set,[]);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:[]}}),Ae(e=>e.size===0?e:new Set),Me(e=>e.size===0?e:new Map);return}let t=!1;return(async()=>{let e=await Promise.all(c.map(async e=>{let n=Wi(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([pt({id:e.id,path:n},{isCurrent:()=>!t}),_t(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(c.map(e=>Wi(e.path)).filter(Boolean)),r=e.flatMap(e=>e?.worktreeStatus?[{path:e.path,status:e.worktreeStatus,worktrees:e.worktrees}]:[]);K.setState(e=>{let t=Zn(e.availableWorktreesByProject,n,r);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:Array.from(t.values()).flat()}}),Ae(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 Ji(r,t)?t:r}),Me(t=>{let n=new Set(c.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,c,U]);let ze=Z.useMemo(()=>c.map(e=>({id:e.id,label:Ki(e.path),path:Wi(e.path),icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:ke.has(Wi(e.path)),worktrees:it(M[e.id],f.get(Wi(e.path))??[])})),[ke,c,M,f]),Be=Z.useMemo(()=>{let e=new Map(a.map(e=>[e.id,e])),t=o.map(t=>{let n=e.get(t.id);return n?le(n,t):t}),n=new Set(t.map(e=>e.id));for(let e of a)n.has(e.id)||t.push(e);return t},[o,a]),Ve=L.trim().toLowerCase(),He=Z.useMemo(()=>{let e=ze.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===l})),t=(e,t,n)=>{let r=Wi(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||Ki(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 Be){let r=Gi(n);if(!r)continue;let i=Wi(r),a=e.find(e=>Qi(e.project,i));if(!a)continue;let o=Zi(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)=>qi(t)-qi(e));for(let n of e.sessions)Ui(n)||(t.totalSessions+=1)}return e},[l,ze,Be]),Ue=Wi(u),We=e=>e.isActive?Ue===e.project.path?e.project.path:e.project.worktrees.find(e=>Xi(Ue,e.path))?.path??e.project.path:null,Ge=e=>D[e.project.id]??!0,Ke=(e,t)=>O[`${e.project.id}::${t.key}`]??!1,qe=e=>{Pe(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},Je=()=>{me(null),Oe.current?.reset()},Ye=e=>({pressed:_e===e.key||q?.key===e.key,onPointerDown:t=>{t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||Oe.current?.start({pointerId:t.pointerId,key:e.key,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>me(e)})},onPointerMove:e=>{Oe.current?.move(e.pointerId,e.clientX,e.clientY)},onPointerUp:e=>{Oe.current?.end(e.pointerId)},onPointerCancel:e=>{Oe.current?.cancel(e.pointerId)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),Oe.current?.openFromContextMenu(e.key,()=>me(e))}}),Xe=(e,t)=>{Oe.current?.consumeClick(e)||t()},Ze=(e,t,n,r)=>{let i=ir(),a=tr();if(Pe(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=Wi(t);if(!o)return;let s=W.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&ue(o)},$e=(e,t,n)=>{let i=`${e.project.id}::${t.key}`,a=ir(),o=new Set(t.sessions.map(e=>e.id)),c=new Map;for(let e of t.sessions){let t=Ui(e);if(t&&o.has(t)){let n=c.get(t)??[];n.push(e),c.set(t,n)}}let l=t.sessions.filter(e=>!Ui(e)),u=Ne.get(i)??a,f=l.slice(0,u),p=l.length-f.length,m=s.get(Wi(t.path)),h=m?.hasMore===!0,g=m?.loadingMore===!0,_=l.length>a&&u>a,v=(e,t)=>{let n=c.get(e.id)??[],i=n.length>0,a=!!P[e.id],o=Ie[e.id]||!1,s=i&&!a?n.filter(e=>Ie[e.id]).map(e=>e.id):[],l=s.length>0,u=o?[e.id,...s]:s,f=e.title?.trim()||r(`mobile.sessions.untitled`),p=`session:${e.id}`;return(0,$.jsxs)(Z.Fragment,{children:[(0,$.jsx)(oa,{session:e,active:d===e.id,indent:t,hasChildren:i,expanded:a,onToggleChildren:i?()=>I(e.id):void 0,confirmingArchive:V===e.id,onSelect:()=>Xe(p,()=>nt(e)),onRequestArchive:()=>rt(e.id),onConfirmArchive:()=>void at(e),onStop:o||l?()=>Re(u):void 0,stopAriaLabel:r(l?`mobile.sessions.stopSubsessionsAria`:`mobile.sessions.stopSessionAria`,{title:f}),longPressHandlers:Ye({key:p,kind:`session`,session:e})}),i&&a?n.map(e=>v(e,t+Hi)):null]},e.id)};return(0,$.jsxs)(`div`,{children:[f.map(e=>v(e,n)),(0,$.jsx)(sa,{indent:n,showMore:p>0||h,showFewer:_,loadingMore:g,onShowMore:()=>Ze(i,t.path,f.length,l.length),onShowFewer:()=>qe(i)})]})},et=(e,t)=>{k(e,!t)},tt=(e,t,n)=>{A(`${e}::${t}`,!n)},nt=e=>{jt();let n=Gi(e)||null,r=$i(ze,n??``);r&&S(r.id),p(e.id,n),t(!1)},rt=e=>{re(t=>t===e?null:e)},at=async e=>{re(null),await m(e.id)?lr({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`)}):F.error(r(`sessions.sidebar.session.archive.error`))},ot=()=>{b(),t(!1)},ct=e=>{pe(e),S(e),ce(!0)},lt=e=>{let t=new Map;for(let e of Be){let n=Ui(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},ut=async e=>{let t=lt(e.id),{archivedIds:n,failedIds:i}=await h(t);n.length>0&&lr({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&&F.error(i.length===1?r(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):r(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}))},dt=e=>{let t=lt(e.id);Wn({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`)})},ft=async e=>{try{if(!(await v(e.id))?.share?.url){F.error(r(`sessions.sidebar.session.share.error`));return}F.success(r(`sessions.sidebar.session.share.successTitle`),{description:r(`sessions.sidebar.session.share.successDescription`)})}catch{F.error(r(`sessions.sidebar.session.share.error`))}},mt=async e=>{if((await N(e)).ok){F.success(r(`sessions.sidebar.session.menu.copied`));return}F.error(r(`sessions.sidebar.session.share.copyUrlError`))},gt=async e=>{try{if(await y(e)){F.success(r(`sessions.sidebar.session.unshare.success`));return}F.error(r(`sessions.sidebar.session.unshare.error`))}catch{F.error(r(`sessions.sidebar.session.unshare.error`))}},vt=async()=>{if(!ye)return;let e=xe.trim();if(e)try{await g(ye.id,e),be(null),Se(``)}catch{F.error(r(`sessions.sidebar.session.menu.rename`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},yt=async()=>{if(!ye||we)return;let e=ye.id;be(null),Se(``),Te(!0);try{await _(e)}catch{F.error(r(`sessions.sidebar.session.rename.smartTitle`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{Te(!1)}},xt=(e,n)=>{S(e.id),b({selectedProjectId:e.id,directoryOverride:n,preserveDirectoryOverride:!0}),t(!1)},St=e=>{(async()=>{try{await pt({id:e.id,path:e.path})}catch(e){console.warn(`[MobileSessions] Worktree refresh before session sync failed:`,e)}let t=K.getState().availableWorktreesByProject.get(e.path)??e.worktrees,n=[e.path,...t.map(e=>e.path)];await Ce(n,Be)})()},Ct=e=>{let t=Gi(e),n=$i(ze,t);if(!n)return Ki(t)||t;let r=Zi(n,Wi(t));return r?.branch?`${n.label} · ${r.branch}`:n.label},wt=e=>{x(e.id),t(!1)},Tt=Z.useMemo(()=>Ve?He.filter(e=>`${e.project.label} ${e.project.path}`.toLowerCase().includes(Ve)?!0:e.buckets.some(t=>t.sessions.some(t=>ea(t,e.project.label,Ve)))):He,[Ve,He]),Et=Z.useMemo(()=>Ve?Be.filter(e=>{let t=Gi(e);return ea(e,$i(ze,t)?.label??``,Ve)}).sort((e,t)=>qi(t)-qi(e)):[],[Ve,ze,Be]),Dt=Z.useMemo(()=>Ve?ze.filter(e=>`${e.label} ${e.path}`.toLowerCase().includes(Ve)).map(e=>({...e,sessionCount:Be.filter(t=>!Ui(t)&&Qi(e,Wi(Gi(t)))).length})):[],[Ve,ze,Be]),Ot=Ve&&Et.length===0&&Dt.length===0,kt=ze.length>0?(0,$.jsxs)(X,{type:`button`,variant:`default`,size:`sm`,"aria-label":r(`mobile.sessions.newChat`),onClick:ot,style:{touchAction:`manipulation`},children:[(0,$.jsx)(Y,{name:`add`,className:`size-4`}),r(`mobile.sessions.newChat`)]}):null,At=ze.find(e=>e.id===l)??null,Mt=At?.isGitRepo?(0,$.jsx)(X,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.project.actions.newWorktree`),title:r(`sessions.sidebar.project.actions.newWorktree`),onClick:()=>ct(At.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(Y,{name:`node-tree`,className:`size-4`})}):null,Nt=(0,$.jsx)(X,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.header.actions.addProject`),title:r(`sessions.sidebar.header.actions.addProject`),onClick:()=>oe(!0),style:{touchAction:`manipulation`},children:(0,$.jsx)(Y,{name:`folder-add`,className:`size-4`})}),Pt=kt||Nt?(0,$.jsxs)($.Fragment,{children:[kt,Mt,Nt]}):null,Ft=q?.kind===`project`?q.project.label:q?.kind===`worktree`?q.worktree.branch||q.worktree.label||q.worktree.path:q?.kind===`session`?q.session.title?.trim()||r(`mobile.sessions.untitled`):``,It=q?.kind===`project`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(aa,{icon:`add`,label:r(`sessions.sidebar.project.actions.newSession`),onClick:()=>{let e=q.project;Je(),xt(e,e.path)}}),q.project.isGitRepo?(0,$.jsx)(aa,{icon:`node-tree`,label:r(`sessions.sidebar.project.actions.newWorktree`),onClick:()=>{let e=q.project.id;Je(),ct(e)}}):null,(0,$.jsx)(aa,{icon:`refresh`,label:r(`sessions.sidebar.project.actions.syncSessions`),onClick:()=>{let e=q.project;Je(),St(e)}}),(0,$.jsx)(aa,{icon:`pencil-ai`,label:r(`sessions.sidebar.project.actions.edit`),onClick:()=>{let e=q.project.id;Je(),B(e)}}),(0,$.jsx)(`div`,{className:`mt-3 border-t border-[var(--surface-subtle)] pt-3`,children:(0,$.jsx)(aa,{icon:`close`,label:r(`sessions.sidebar.project.actions.closeProject`),destructive:!0,onClick:()=>{let e=q.project;Je(),ge(e)}})})]}):q?.kind===`worktree`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(aa,{icon:`add`,label:r(`sessions.sidebar.project.actions.newSession`),onClick:()=>{let{project:e,worktree:t}=q;Je(),xt(e,t.path)}}),(0,$.jsx)(`div`,{className:`mt-3 border-t border-[var(--surface-subtle)] pt-3`,children:(0,$.jsx)(aa,{icon:`delete-bin`,label:r(`mobile.projectEdit.deleteWorktreeConfirmButton`),destructive:!0,onClick:()=>{let e={project:q.project,worktree:q.worktree};Je(),De(e)}})})]}):q?.kind===`session`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(aa,{icon:`pencil-ai`,label:r(`sessions.sidebar.session.menu.rename`),onClick:()=>{let e=q.session;Je(),Se(e.title?.trim()||r(`mobile.sessions.untitled`)),be(e)}}),(0,$.jsx)(aa,{icon:T.has(q.session.id)?`unpin`:`pushpin`,label:T.has(q.session.id)?r(`sessions.sidebar.session.menu.unpin`):r(`sessions.sidebar.session.menu.pin`),onClick:()=>{let e=q.session.id;Je(),E(e)}}),q.session.share?.url?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(aa,{icon:`file-copy`,label:r(`sessions.sidebar.session.menu.copyLink`),onClick:()=>{let e=q.session.share?.url;Je(),e&&mt(e)}}),(0,$.jsx)(aa,{icon:`link-unlink-m`,label:r(`sessions.sidebar.session.menu.unshare`),onClick:()=>{let e=q.session.id;Je(),gt(e)}})]}):(0,$.jsx)(aa,{icon:`share-2`,label:r(`sessions.sidebar.session.menu.share`),onClick:()=>{let e=q.session;Je(),ft(e)}}),(0,$.jsx)(aa,{icon:`archive`,label:r(`sessions.sidebar.bulkActions.archive`),onClick:()=>{let e=q.session;Je(),ut(e)}}),(0,$.jsx)(`div`,{className:`mt-3 border-t border-[var(--surface-subtle)] pt-3`,children:(0,$.jsx)(aa,{icon:`delete-bin`,label:r(`sessions.sidebar.bulkActions.delete`),destructive:!0,onClick:()=>{let e=q.session;Je(),dt(e)}})})]}):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)(Y,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(bt,{value:L,onChange:e=>R(e.target.value),placeholder:r(`mobile.sessions.search.placeholder`),className:J(`h-11 pl-9`,L&&`pr-10`)}),L?(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:()=>R(``),style:{touchAction:`manipulation`},children:(0,$.jsx)(Y,{name:`close`,className:`size-4`})}):null]})}),(0,$.jsx)(ht,{className:`min-h-0 flex-1 overflow-y-auto pb-4`,children:ze.length===0?(0,$.jsx)(la,{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:()=>oe(!0),children:[(0,$.jsx)(Y,{name:`folder-add`,className:`size-4`}),r(`sessions.sidebar.header.actions.addProject`)]})}):Ot?(0,$.jsx)(la,{title:r(`mobile.sessions.empty.searchTitle`),description:r(`mobile.sessions.empty.searchDescription`)}):Ve?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-3 pt-2`,children:[Et.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:Et.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:Et.map((e,t)=>{let n=Ie[e.id]||!1,i=e.title?.trim()||r(`mobile.sessions.untitled`);return(0,$.jsx)(`div`,{className:J(t>0&&`border-t border-border/30`),children:(0,$.jsx)(oa,{session:e,active:d===e.id,indent:12,contextLabel:Ct(e),onSelect:()=>Xe(`session:${e.id}`,()=>nt(e)),longPressHandlers:Ye({key:`session:${e.id}`,kind:`session`,session:e}),onStop:n?()=>Le(e.id):void 0,stopAriaLabel:r(`mobile.sessions.stopSessionAria`,{title:i})})},e.id)})})]}):null,Dt.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:Dt.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:Dt.map((e,t)=>{let n=`project:${e.id}`,r=Ye({key:n,kind:`project`,project:e});return(0,$.jsxs)(`div`,{className:J(`flex items-center`,t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`button`,{type:`button`,className:J(`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:()=>Xe(n,()=>wt(e)),onPointerDown:r.onPointerDown,onPointerMove:r.onPointerMove,onPointerUp:r.onPointerUp,onPointerCancel:r.onPointerCancel,onContextMenu:r.onContextMenu,style:{touchAction:`manipulation`},children:[(0,$.jsx)(ta,{project:e}),(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:e.label}),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.sessionCount})]}),e.isGitRepo?(0,$.jsx)(ia,{className:`mr-2`,onClick:()=>ct(e.id)}):null]},e.id)})})]}):null]}):(0,$.jsx)(`div`,{className:`flex flex-col`,children:Tt.map((e,t)=>{let n=Ge(e),i=`project:${e.project.id}`,a=Ye({key:i,kind:`project`,project:e.project}),o=Ve?e.buckets.filter(t=>t.sessions.some(t=>ea(t,e.project.label,Ve))):e.buckets,s=We(e);return(0,$.jsxs)(`section`,{className:J(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:J(`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:()=>Xe(i,()=>et(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)(ta,{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}),je.get(e.project.id)?(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 typography-micro text-muted-foreground`,children:[(0,$.jsx)(Y,{name:`git-branch`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:je.get(e.project.id)})]}):null]}),e.isActive?(0,$.jsx)(ra,{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=>Ie[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(),Re(t)},style:{touchAction:`manipulation`},children:(0,$.jsx)(dr,{})}):null})(),e.project.isGitRepo?(0,$.jsx)(ia,{className:`mr-2`,onClick:()=>ct(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?$e(e,t,Vi):null,n.map(t=>{let n=Ke(e,t),i=s===t.path,a=`worktree:${e.project.id}:${t.key}`,o=Ye({key:a,kind:`worktree`,project:e.project,worktree:t.worktree});return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,className:J(`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:()=>Xe(a,()=>tt(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)(na,{expanded:n}),(0,$.jsx)(Y,{name:`node-tree`,className:J(`size-4 shrink-0`,i?`text-primary`:`text-muted-foreground`)}),(0,$.jsx)(`span`,{className:J(`block min-w-0 flex-1 truncate typography-ui-label font-semibold`,i?`text-foreground`:`text-foreground/90`),children:t.label}),i?(0,$.jsx)(ra,{ariaLabel:r(`mobile.sessions.activeWorktreeAria`)}):null,(()=>{let e=n?[]:t.sessions.filter(e=>Ie[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(),Re(e)},style:{touchAction:`manipulation`},children:(0,$.jsx)(dr,{})}):null})(),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:t.sessions.length})]}),n?$e(e,t,Vi):null]},t.key)})]})})()}):null]},e.project.id)})})}),(0,$.jsx)(or,{open:ae,onOpenChange:oe,forceMobile:!0}),(0,$.jsx)(Wt,{open:se,projectId:de,onOpenChange:e=>{ce(e),e||pe(null)},onWorktreeCreated:(e,n)=>{n?.sessionId?p(n.sessionId,e):b({selectedProjectId:de,directoryOverride:e,preserveDirectoryOverride:!0}),t(!1)}}),(0,$.jsx)(Gt,{open:!!q,title:Ft,onClose:Je,contentMaxHeightClassName:`max-h-[min(68dvh,560px)]`,children:It}),(0,$.jsx)(Gt,{open:!!he,title:r(`sessions.sidebar.project.actions.closeProject`),onClose:()=>ge(null),closeAriaLabel:r(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>ge(null),children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(X,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!he)return;let e=he;ge(null),C(e.id),F.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:he?.label??``})})}),(0,$.jsx)(Gt,{open:!!ye,title:r(`sessions.sidebar.session.menu.rename`),onClose:()=>{we||(be(null),Se(``))},footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:we,onClick:()=>{be(null),Se(``)},children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(X,{type:`button`,variant:`default`,className:`flex-1`,disabled:!xe.trim()||we,onClick:()=>void vt(),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(),vt()},children:[(0,$.jsx)(bt,{value:xe,onChange:e=>Se(e.target.value),autoFocus:!0,className:`h-12`,disabled:we}),(0,$.jsxs)(X,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:we,onClick:()=>void yt(),children:[we?(0,$.jsx)(Y,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(Y,{name:`ai-generate-2`,className:`size-4`}),r(`sessions.sidebar.session.rename.smartTitle`)]})]})}),Ee?(0,$.jsx)(Xn,{open:!0,project:{id:Ee.project.id,path:Ee.project.path},worktree:Ee.worktree,onClose:()=>De(null),onDeleted:()=>ie(e=>e+1)}):null,(0,$.jsx)(Bi,{open:z!==null,project:ze.find(e=>e.id===z)??null,onClose:()=>B(null),onWorktreesChanged:()=>ie(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:Pt?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:Pt}):null}),Lt]}):null:(0,$.jsx)(Li,{open:e,onClose:()=>t(!1),ariaLabel:r(`mobile.sessions.sheet.title`),trailing:Pt,children:Lt})},la=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};function ua(){let e=(0,Q.c)(8),{t}=ee(),n;e[0]===t?n=e[1]:(n=t(`assistants.state.unavailable`),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 da({assistantID:e,displayName:t,avatarEmoji:n,modeLabel:r,summary:i,enabled:a,editLabel:o,deleteLabel:s,onOpen:c,onEdit:l,onDelete:u}){let[d,f]=Z.useState(!1),[p,m]=Z.useState(!1),h=Z.useRef(null);h.current||=gn({onPressedKeyChange:t=>m(t===e)}),Z.useEffect(()=>()=>h.current?.reset(),[]);let g=j(()=>{h.current?.consumeClick(e)||d||c()}),_=j(()=>{f(!1),l()}),v=j(()=>{f(!1),u()}),y=j(()=>{m(!1),f(!0)}),b=j(t=>{t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||h.current?.start({pointerId:t.pointerId,key:e,clientX:t.clientX,clientY:t.clientY,onTrigger:y})}),x=j(e=>{h.current?.move(e.pointerId,e.clientX,e.clientY)}),S=j(e=>{h.current?.end(e.pointerId)}),C=j(e=>{h.current?.cancel(e.pointerId)}),w=j(t=>{t.preventDefault(),t.stopPropagation(),h.current?.openFromContextMenu(e,y)});return(0,$.jsxs)(xr,{open:d,onOpenChange:f,children:[(0,$.jsx)(Nn,{"data-mobile-press-surface":`soft`,className:J(`oc-mobile-assistant-card-shell`,p&&`bg-interactive-hover`),children:(0,$.jsxs)(_r,{render:(0,$.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":`false`,"data-mobile-press-surface-trigger":!0,"data-mobile-press-feedback":`none`,className:J(`oc-mobile-assistant-card`,!a&&`opacity-65`),onClick:g,onPointerDown:b,onPointerMove:x,onPointerUp:S,onPointerCancel:C,onContextMenu:w,style:{touchAction:`pan-y`}}),children:[(0,$.jsx)(`span`,{className:`oc-mobile-assistant-avatar oc-mobile-glass-control oc-mobile-glass-control--clear rounded-full`,children:(0,$.jsx)(ze,{name:e,emoji:n,size:28,label:t})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`oc-mobile-entity-title block truncate font-semibold text-foreground`,children:t}),(0,$.jsxs)(`span`,{className:`oc-mobile-entity-meta mt-0.5 flex min-w-0 items-center text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`shrink-0`,children:r}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`·`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:i})]})]}),(0,$.jsx)(Y,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground`})]})}),(0,$.jsxs)(yr,{className:`min-w-[10rem]`,children:[(0,$.jsxs)(br,{className:`min-h-10 px-3`,onClick:_,children:[(0,$.jsx)(Y,{name:`edit`,className:`size-4`}),o]}),(0,$.jsx)(vr,{}),(0,$.jsxs)(br,{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:v,children:[(0,$.jsx)(Y,{name:`delete-bin`,className:`size-4`}),s]})]})]})}function fa(e){let t=(0,Q.c)(77),{onEnable:n,onOpenAssistant:r,className:i}=e,{t:a}=ee(),o=zt(),s=Fe(),c=Le(),[l,u]=Z.useState(null),d;t[0]===n?d=t[1]:(d=()=>n(),t[0]=n,t[1]=d);let f=j(d),p;t[2]===r?p=t[3]:(p=e=>r(e),t[2]=r,t[3]=p);let m=j(p),h;t[4]===o?h=t[5]:(h=e=>{Re(e,o?{openMobileSettings:o.openSettings}:void 0)},t[4]=o,t[5]=h);let g=j(h),_;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>{u(e)},t[6]=_):_=t[6];let v=j(_),y;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{e||u(null)},t[7]=y):y=t[7];let b=j(y),x;t[8]===a?x=t[9]:(x=a(`assistants.title`),t[8]=a,t[9]=x);let S=x,C;t[10]===a?C=t[11]:(C=a(`assistants.menu.edit`),t[10]=a,t[11]=C);let w=C,T;t[12]===a?T=t[13]:(T=a(`assistants.settings.delete`),t[12]=a,t[13]=T);let E=T;if(s.isPending||s.data?.supported&&s.data.enabled&&c.isPending){let e;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Nn,{className:`oc-mobile-assistant-loading`,children:(0,$.jsx)(ua,{})}),t[14]=e):e=t[14];let n;return t[15]!==i||t[16]!==S?(n=(0,$.jsx)(Mn,{title:S,className:i,surface:!1,children:e}),t[15]=i,t[16]=S,t[17]=n):n=t[17],n}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length>0){let e;t[18]===a?e=t[19]:(e=a(`assistants.listAria`),t[18]=a,t[19]=e);let n;if(t[20]!==E||t[21]!==w||t[22]!==g||t[23]!==m||t[24]!==v||t[25]!==c.data.assistants||t[26]!==a){let e;t[28]!==E||t[29]!==w||t[30]!==g||t[31]!==m||t[32]!==v||t[33]!==a?(e=e=>{let t=Ee(e.name),n=t.displayName||e.name,r=e.mode===`stateless`?a(`assistants.mode.stateless`):a(`assistants.mode.continuous`),i=e.defaultPrompt.trim()||(e.mode===`stateless`?a(`assistants.conversation.statelessHint`):a(`assistants.conversation.continuousHint`));return(0,$.jsx)(da,{assistantID:e.id,displayName:n,avatarEmoji:t.avatarEmoji??void 0,modeLabel:r,summary:i,enabled:e.enabled,editLabel:w,deleteLabel:E,onOpen:()=>m(e.id),onEdit:()=>g(e.id),onDelete:()=>v(e)},e.id)},t[28]=E,t[29]=w,t[30]=g,t[31]=m,t[32]=v,t[33]=a,t[34]=e):e=t[34],n=c.data.assistants.map(e),t[20]=E,t[21]=w,t[22]=g,t[23]=m,t[24]=v,t[25]=c.data.assistants,t[26]=a,t[27]=n}else n=t[27];let r;t[35]!==n||t[36]!==e?(r=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-catalog`,role:`listbox`,"aria-label":e,children:n}),t[35]=n,t[36]=e,t[37]=r):r=t[37];let o=l!==null,s;t[38]!==l||t[39]!==b||t[40]!==o?(s=(0,$.jsx)(Sr,{assistant:l,open:o,onOpenChange:b}),t[38]=l,t[39]=b,t[40]=o,t[41]=s):s=t[41];let u;return t[42]!==i||t[43]!==S||t[44]!==r||t[45]!==s?(u=(0,$.jsxs)(Mn,{title:S,className:i,surface:!1,scrollsWithPage:!0,children:[r,s]}),t[42]=i,t[43]=S,t[44]=r,t[45]=s,t[46]=u):u=t[46],u}let D=s.isSuccess&&s.data.supported===!1,O=s.isError||c.isError,k;t[47]!==a||t[48]!==O||t[49]!==D?(k=a(O?`assistants.state.unavailable`:D?`assistants.state.unsupportedTitle`:`assistants.state.instanceDisabled`),t[47]=a,t[48]=O,t[49]=D,t[50]=k):k=t[50];let A=k,M;t[51]===S?M=t[52]:(M=(0,$.jsx)(`span`,{className:`oc-mobile-page-section-label`,children:S}),t[51]=S,t[52]=M);let N=D?`cloud-off`:`sparkling`,P;t[53]===N?P=t[54]:(P=(0,$.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground`,children:(0,$.jsx)(Y,{name:N,weight:`medium`,className:`size-5`})}),t[53]=N,t[54]=P);let F;t[55]===A?F=t[56]:(F=(0,$.jsx)(`h2`,{className:`mt-5 max-w-xs text-lg font-semibold leading-snug tracking-[-0.02em] text-foreground`,children:A}),t[55]=A,t[56]=F);let I;t[57]!==a||t[58]!==O||t[59]!==D?(I=O?null:(0,$.jsx)(`p`,{className:`mt-2 max-w-sm typography-small leading-relaxed text-muted-foreground`,children:a(D?`assistants.state.unsupportedDescription`:`assistants.state.instanceDisabledDescription`)}),t[57]=a,t[58]=O,t[59]=D,t[60]=I):I=t[60];let L;t[61]!==s.data?.supported||t[62]!==f||t[63]!==a?(L=s.data?.supported===!0?(0,$.jsxs)(X,{type:`button`,size:`lg`,className:`mt-6 w-full`,onClick:f,children:[(0,$.jsx)(Y,{name:`settings-3`,className:`size-[18px]`}),a(`assistants.settings.instanceEnabled`)]}):null,t[61]=s.data?.supported,t[62]=f,t[63]=a,t[64]=L):L=t[64];let R;t[65]!==P||t[66]!==F||t[67]!==I||t[68]!==L?(R=(0,$.jsxs)(`section`,{className:`w-full max-w-md py-2`,children:[P,F,I,L]}),t[65]=P,t[66]=F,t[67]=I,t[68]=L,t[69]=R):R=t[69];let z;t[70]!==M||t[71]!==R?(z=(0,$.jsx)(In,{label:M,cardClassName:`oc-mobile-assistant-state-card`,children:R}),t[70]=M,t[71]=R,t[72]=z):z=t[72];let B;return t[73]!==i||t[74]!==S||t[75]!==z?(B=(0,$.jsx)(Mn,{title:S,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:z}),t[73]=i,t[74]=S,t[75]=z,t[76]=B):B=t[76],B}var pa=[{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 ma(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=j(o),c;t[2]!==n||t[3]!==r?(c=e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=pa.findIndex(e=>e.id===n),i=pa[e.key===`Home`?0:e.key===`End`?pa.length-1:(t+(e.key===`ArrowRight`?1:-1)+pa.length)%pa.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=j(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=pa.map(e=>{let t=e.id===n,r=a(e.labelKey);return(0,$.jsxs)(X,{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-selected":t,tabIndex:t?0:-1,title:r,onClick:s,onKeyDown:l,"data-mobile-press-feedback":`none`,className:J(`oc-mobile-tab-button min-w-0 flex-1 flex-col overflow-hidden`,`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:scale-[0.985]`,`motion-reduce:transition-none`,t&&[`bg-interactive-selection/55 text-primary`,`hover:bg-interactive-selection/55 hover:text-primary`,`font-semibold`]),children:[(0,$.jsx)(Y,{name:e.icon,weight:`medium`,className:`size-[23px] shrink-0`}),(0,$.jsx)(`span`,{className:`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)(Ln,{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}function ha(e){let t=(0,Q.c)(23),{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=j(()=>h?.onBack());qt({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 M;t[4]===i?M=t[5]:(M=e=>{i(e)},t[4]=i,t[5]=M);let N=j(M),P;t[6]===c?P=t[7]:(P=J(`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[6]=c,t[7]=P);let F=h?!0:void 0,I=h?!0:void 0,L;t[8]!==p||t[9]!==u||t[10]!==n||t[11]!==b?(L=pa.map(e=>{let t=b.has(e.id);return(0,$.jsx)(`section`,{id:`mobile-tabpanel-${e.id}`,role:`tabpanel`,"aria-labelledby":`mobile-tab-${e.id}`,hidden:p!==e.id,tabIndex:0,className:J(`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)(ga,{tab:e.id,icon:e.icon}):null},e.id)}),t[8]=p,t[9]=u,t[10]=n,t[11]=b,t[12]=L):L=t[12];let R;t[13]!==w||t[14]!==L||t[15]!==F||t[16]!==I?(R=(0,$.jsx)(`div`,{ref:w,"data-mobile-navigation-underlay":`true`,"aria-hidden":F,inert:I,className:`flex h-full min-h-0 flex-1 flex-col`,children:L}),t[13]=w,t[14]=L,t[15]=F,t[16]=I,t[17]=R):R=t[17];let z=u?(0,$.jsx)(`div`,{"data-mobile-navigation-dock-underlay":`true`,"aria-hidden":h||d?!0:void 0,inert:h||d?!0:void 0,children:(0,$.jsx)(ma,{activeTab:p,onTabChange:N})}):null,B=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:J(`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)}),V;return t[18]!==R||t[19]!==z||t[20]!==B||t[21]!==P?(V=(0,$.jsxs)(`div`,{className:P,children:[R,z,B]}),t[18]=R,t[19]=z,t[20]=B,t[21]=P,t[22]=V):V=t[22],V}function ga(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=pa.find(e=>e.id===n)??pa[0];t[8]===i?c=t[9]:(c=J(`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)(Y,{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 _a={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)`}},va=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 ya({project:e,expanded:t,embedded:n=!1,onToggle:r,onOpenActions:i,className:a}){let{t:o}=ee(),[s,c]=Z.useState(!1),l=Z.useRef(null);l.current||=gn({onPressedKeyChange:t=>c(t===e.id)}),Z.useEffect(()=>()=>l.current?.reset(),[]);let u=j(()=>{l.current?.consumeClick(e.id)||r(e)}),d=j(()=>i(e)),f=j(t=>{t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||l.current?.start({pointerId:t.pointerId,key:e.id,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>{c(!1),i(e)}})}),p=j(e=>{l.current?.move(e.pointerId,e.clientX,e.clientY)}),m=j(e=>{l.current?.end(e.pointerId)}),h=j(e=>{l.current?.cancel(e.pointerId)}),g=j(t=>{t.preventDefault(),t.stopPropagation(),l.current?.openFromContextMenu(e.id,()=>{c(!1),i(e)})}),_=e.sessionCount===1?o(`mobile.sessions.project.sessionsSingle`):o(`mobile.sessions.project.sessionsPlural`,{count:e.sessionCount}),v=va(e.path),y=(0,$.jsxs)(`article`,{"data-mobile-press-surface":`soft`,className:J(`oc-mobile-project-card relative flex items-stretch overflow-hidden rounded-[var(--oc-mobile-surface-radius)]`,s&&`bg-interactive-hover`,a),children:[(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-surface-trigger":!0,"data-mobile-press-feedback":`none`,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:u,onPointerDown:f,onPointerMove:p,onPointerUp:m,onPointerCancel:h,onContextMenu:g,style:{touchAction:`pan-y`},children:[(0,$.jsx)(`span`,{className:J(`oc-mobile-project-icon oc-mobile-glass-control flex shrink-0 items-center justify-center rounded-full text-muted-foreground`),style:_a[e.tone??`neutral`],"aria-hidden":!0,children:(0,$.jsx)(Y,{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: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":o(`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:_}),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,v?(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:v})]}):null]})]}),(0,$.jsx)(Y,{name:`arrow-down-s`,className:J(`oc-mobile-project-chevron shrink-0 text-muted-foreground transition-transform duration-150 motion-reduce:transition-none`,t?`rotate-0`:`-rotate-90`)})]}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-mobile-project-action self-center rounded-full text-muted-foreground`,"aria-label":o(`sessions.sidebar.project.actions.projectMenu`),onClick:d,children:(0,$.jsx)(Y,{name:`more-2`,className:`size-4`})})]});return n?y:(0,$.jsx)(Nn,{asChild:!0,children:y})}var ba=({hasPendingQuestion:e,hasPendingPermission:t,running:n,unread:r})=>e?`question`:t?`permission`:n?`running`:r?`completed-unread`:`idle`,xa=10,Sa=`oc:mobile-session-row-revealed`,Ca=e=>{window.dispatchEvent(new CustomEvent(Sa,{detail:e}))};function wa({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}){let{t:f}=ee(),[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||=gn({onPressedKeyChange:t=>g(t===e.id)}),Z.useEffect(()=>()=>S.current?.reset(),[]),Z.useEffect(()=>{let t=t=>{t.detail!==e.id&&m(0)};return window.addEventListener(Sa,t),()=>window.removeEventListener(Sa,t)},[e.id]),Z.useEffect(()=>{m(0)},[e.id]);let C=j(()=>m(0)),w=p!==0,T=j(t=>{if(t.button!==0||t.pointerType!==`touch`&&t.pointerType!==`pen`)return;let n=x.current?.offsetWidth??0;n<=0||(y.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startOffset:p,actionWidth:n,intent:`pending`},b.current=!1,S.current?.start({pointerId:t.pointerId,key:e.id,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>{g(!1),l(e)}}))}),E=j(t=>{let n=y.current;if(!n||n.pointerId!==t.pointerId)return;let r=t.clientX-n.startX,i=t.clientY-n.startY;if(S.current?.move(t.pointerId,t.clientX,t.clientY),n.intent===`pending`){let a=Math.abs(r),o=Math.abs(i);if(o>xa&&o>a){n.intent=`vertical`,y.current=null,S.current?.cancel(t.pointerId);return}if(a>xa&&a>o){n.intent=`horizontal`,v(!0),b.current=!0,S.current?.cancel(t.pointerId);try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}Ca(e.id)}}if(n.intent!==`horizontal`)return;t.preventDefault();let a=Math.max(-n.actionWidth,Math.min(0,n.startOffset+r));m(a)}),D=j(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=j(e=>{let t=y.current;y.current=null,S.current?.cancel(e.pointerId),v(!1),m(t?.startOffset??0)}),k=j(()=>{if(!S.current?.consumeClick(e.id)){if(b.current){b.current=!1;return}if(p!==0){C();return}Ca(e.id),o(e)}}),A=j(t=>{t.preventDefault(),t.stopPropagation(),S.current?.openFromContextMenu(e.id,()=>{g(!1),l(e)})}),M=j(()=>{C(),s(e)}),N=j(()=>{C(),c(e)}),P=j(()=>l(e)),F=j(()=>a?.()),I=e.pinned?f(`sessions.sidebar.session.menu.unpin`):f(`sessions.sidebar.session.menu.pin`),L=u??ba({hasPendingQuestion:!1,hasPendingPermission:!1,running:!1,unread:!!e.unread}),R=L===`question`?f(`sessions.sidebar.session.status.questionRequired`):L===`permission`?f(`sessions.sidebar.session.status.permissionRequired`):L===`running`?f(`sessions.sidebar.session.status.active`):L===`completed-unread`?f(`sessions.sidebar.session.status.unread`):void 0;return e.kind===`pagination`?(0,$.jsx)(`div`,{className:J(`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`,onClick:k,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left font-medium text-foreground`,children:e.title}),e.subtitle?(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.subtitle}):null,(0,$.jsx)(Y,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground`})]})}):(0,$.jsxs)(`div`,{className:J(`oc-mobile-session-row relative isolate overflow-hidden`,d),children:[(0,$.jsxs)(`div`,{ref:x,className:J(`oc-mobile-session-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:{transform:`translate3d(calc(var(--oc-mobile-session-actions-width) + ${p}px), 0, 0)`,willChange:p===0?void 0:`transform`},"aria-hidden":!w,children:[(0,$.jsxs)(X,{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":I,tabIndex:w?0:-1,onClick:M,children:[(0,$.jsx)(Y,{name:e.pinned?`unpin`:`pushpin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:I})]}),(0,$.jsxs)(X,{type:`button`,variant:`destructive`,className:`oc-mobile-session-action h-full flex-col rounded-none border-0 px-1`,"aria-label":f(`sessions.sidebar.bulkActions.archive`),tabIndex:w?0:-1,onClick:N,children:[(0,$.jsx)(Y,{name:`archive`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:f(`sessions.sidebar.bulkActions.archive`)})]})]}),(0,$.jsxs)(`div`,{className:J(`oc-mobile-session-row-content relative z-10 flex items-center`,`text-foreground`,`ease-out motion-reduce:transition-none`,_?`transition-none`:`transition-[transform,background-color] duration-150`,e.active&&`bg-interactive-selection/50`,e.archived&&`opacity-55`,h&&!e.active&&`bg-interactive-hover`),style:{transform:`translate3d(${p}px, 0, 0)`,willChange:p===0?void 0:`transform`},children:[n&&a?(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,className:`min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":f(r?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:F,children:(0,$.jsx)(Y,{name:`arrow-down-s`,className:J(`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:k,onPointerDown:T,onPointerMove:E,onPointerUp:D,onPointerCancel:O,onContextMenu:A,children:[(0,$.jsx)(`span`,{className:`oc-mobile-session-status shrink-0`,"data-session-status":L,"aria-hidden":!R||void 0,"aria-label":R,title:R,children:L===`running`?(0,$.jsx)(dr,{className:`motion-reduce:[&_svg]:animate-none`}):L===`question`?(0,$.jsx)(Y,{name:`question`,className:`size-3.5 text-[var(--status-warning)]`}):L===`permission`?(0,$.jsx)(Y,{name:`shield`,className:`size-3.5 text-destructive`}):(0,$.jsx)(`span`,{className:J(`oc-mobile-session-dot rounded-full`,L===`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:J(`oc-mobile-session-title truncate`,e.unread?`font-semibold`:`font-medium`),children:e.title}),e.pinned?(0,$.jsx)(Y,{name:`pushpin`,className:`size-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}):null,e.archived?(0,$.jsx)(Y,{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: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)(X,{type:`button`,variant:`ghost`,size:`icon`,className:`mr-1 min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":f(`sessions.sidebar.session.menu.label`),onClick:P,children:(0,$.jsx)(Y,{name:`more-2`,className:`size-3.5`})})]})]})}var Ta=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e)),Ea=(e,t)=>e.filter(e=>e.kind!==`pagination`&&Ta(t,e.title,e.subtitle,e.id)),Da=(e,t)=>{if(Ta(t,e.name,e.path))return{...e,sessions:e.sessions.filter(e=>e.kind!==`pagination`)};let n=Ea(e.sessions,t);return n.length>0?{...e,sessions:n}:null},Oa=(e,t)=>{let n=t.trim().toLowerCase();return n?e.flatMap(e=>{if(Ta(n,e.name,e.path))return[{...e,worktrees:[]}];let t=e.worktrees.flatMap(e=>{let t=Da(e,n);return t?[t]:[]});return t.length>0?[{...e,worktrees:t}]:[]}):e},ka=10,Aa=`oc:mobile-worktree-row-revealed`,ja=e=>{window.dispatchEvent(new CustomEvent(Aa,{detail:e}))};function Ma(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=_e(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=de(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=ba({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)(wa,{...e,indicator:d}),t[7]=d,t[8]=e,t[9]=f):f=t[9],f}function Na(e){let t=(0,Q.c)(8),{sessions:n,onSelectSession:r,onPinSession:i,onArchiveSession:a,onOpenSessionActions:o}=e,s;t[0]!==a||t[1]!==o||t[2]!==i||t[3]!==r||t[4]!==n?(s=n.map((e,t)=>{let s=e.kind===`pagination`&&n[t+1]?.kind===`pagination`,c=e.kind===`pagination`?wa:Ma;return(0,$.jsx)(c,{session:e,paginationContinues:s,onSelect:r,onPin:i,onArchive:a,onOpenActions:o},e.id)}),t[0]=a,t[1]=o,t[2]=i,t[3]=r,t[4]=n,t[5]=s):s=t[5];let c;return t[6]===s?c=t[7]:(c=(0,$.jsx)($.Fragment,{children:s}),t[6]=s,t[7]=c),c}function Pa(e){let t=(0,Q.c)(22),{icon:n,label:r,count:i,expanded:a,onToggle:o,actions:s}=e,{t:c}=ee(),l;t[0]===n?l=t[1]:(l=(0,$.jsx)(`span`,{className:`oc-mobile-group-label-icon`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=l);let u;t[2]===r?u=t[3]:(u=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left typography-ui-label font-semibold text-foreground`,children:r}),t[2]=r,t[3]=u);let d;t[4]!==i||t[5]!==c?(d=typeof i==`number`?(0,$.jsx)(`span`,{className:`typography-small text-muted-foreground tabular-nums`,children:i===1?c(`mobile.sessions.project.sessionsSingle`):c(`mobile.sessions.project.sessionsPlural`,{count:i})}):null,t[4]=i,t[5]=c,t[6]=d):d=t[6];let f;t[7]!==a||t[8]!==o?(f=o?(0,$.jsx)(Y,{name:`arrow-down-s`,className:J(`size-3.5 text-muted-foreground transition-transform duration-150 motion-reduce:transition-none`,a?`rotate-0`:`-rotate-90`)}):null,t[7]=a,t[8]=o,t[9]=f):f=t[9];let p;t[10]!==l||t[11]!==u||t[12]!==d||t[13]!==f?(p=(0,$.jsxs)($.Fragment,{children:[l,u,d,f]}),t[10]=l,t[11]=u,t[12]=d,t[13]=f,t[14]=p):p=t[14];let m=p,h;t[15]!==m||t[16]!==a||t[17]!==o?(h=o?(0,$.jsx)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-group-label-trigger`,"aria-expanded":a,onClick:o,children:m}):(0,$.jsx)(`div`,{className:`oc-mobile-group-label-trigger`,children:m}),t[15]=m,t[16]=a,t[17]=o,t[18]=h):h=t[18];let g;return t[19]!==s||t[20]!==h?(g=(0,$.jsxs)(`div`,{className:`oc-mobile-group-label`,children:[h,s]}),t[19]=s,t[20]=h,t[21]=g):g=t[21],g}function Fa({project:e,worktree:t,expanded:n,onToggle:r,onNewSession:i,onOpenActions:a,onDelete:o}){let{t:s}=ee(),c=`${e.id}::${t.id}`,l=!!(i||o),u=!!a,d=Number(!!i)+Number(!!o),[f,p]=Z.useState(0),[m,h]=Z.useState(!1),[g,_]=Z.useState(!1),v=Z.useRef(null),y=Z.useRef(!1),b=Z.useRef(null),x=Z.useRef(null);x.current||=gn({onPressedKeyChange:e=>h(e===c)}),Z.useEffect(()=>()=>x.current?.reset(),[]),Z.useEffect(()=>{let e=e=>{e.detail!==c&&p(0)};return window.addEventListener(Aa,e),()=>window.removeEventListener(Aa,e)},[c]),Z.useEffect(()=>{p(0)},[c]);let S=j(()=>p(0)),C=f!==0,w=j(n=>{if(n.button===0&&(n.pointerType===`touch`||n.pointerType===`pen`)){if(l){let e=b.current?.offsetWidth??0;e>0&&(v.current={pointerId:n.pointerId,startX:n.clientX,startY:n.clientY,startOffset:f,actionWidth:e,intent:`pending`},y.current=!1)}u&&x.current?.start({pointerId:n.pointerId,key:c,clientX:n.clientX,clientY:n.clientY,onTrigger:()=>{h(!1),a?.(e,t)}})}}),T=j(e=>{let t=v.current;if(!t||t.pointerId!==e.pointerId){x.current?.move(e.pointerId,e.clientX,e.clientY);return}let n=e.clientX-t.startX,r=e.clientY-t.startY;if(x.current?.move(e.pointerId,e.clientX,e.clientY),t.intent===`pending`){let i=Math.abs(n),a=Math.abs(r);if(a>ka&&a>i){t.intent=`vertical`,v.current=null,x.current?.cancel(e.pointerId);return}if(i>ka&&i>a){t.intent=`horizontal`,_(!0),y.current=!0,x.current?.cancel(e.pointerId);try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}ja(c)}}if(t.intent!==`horizontal`)return;e.preventDefault();let i=Math.max(-t.actionWidth,Math.min(0,t.startOffset+n));p(i)}),E=j(e=>{let t=v.current;x.current?.end(e.pointerId),!(!t||t.pointerId!==e.pointerId)&&(v.current=null,t.intent===`horizontal`&&(_(!1),p(e=>e<-(t.actionWidth*.35)?-t.actionWidth:0)))}),D=j(e=>{let t=v.current;v.current=null,x.current?.cancel(e.pointerId),_(!1),p(t?.startOffset??0)}),O=j(()=>{if(!x.current?.consumeClick(c)){if(y.current){y.current=!1;return}if(f!==0){S();return}r()}}),k=j(n=>{u&&(n.preventDefault(),n.stopPropagation(),x.current?.openFromContextMenu(c,()=>{h(!1),a?.(e,t)}))}),A=j(()=>{S(),i?.(e,t)}),M=j(()=>{S(),o?.(e,t)}),N=j(()=>a?.(e,t)),P=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`oc-mobile-group-label-icon`,"aria-hidden":!0,children:(0,$.jsx)(Y,{name:`git-branch`,className:`size-3.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left typography-ui-label font-semibold text-foreground`,children:t.name}),(0,$.jsx)(`span`,{className:`typography-small text-muted-foreground tabular-nums`,children:t.sessionCount===1?s(`mobile.sessions.project.sessionsSingle`):s(`mobile.sessions.project.sessionsPlural`,{count:t.sessionCount})}),(0,$.jsx)(Y,{name:`arrow-down-s`,className:J(`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:[l?(0,$.jsxs)(`div`,{ref:b,className:J(`oc-mobile-worktree-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:{width:`calc(${d} * var(--oc-mobile-worktree-action-width))`,transform:`translate3d(calc(100% + ${f}px), 0, 0)`,willChange:f===0?void 0:`transform`},"aria-hidden":!C,children:[i?(0,$.jsxs)(X,{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":s(`mobile.sessions.newSessionAria`),tabIndex:C?0:-1,onClick:A,children:[(0,$.jsx)(Y,{name:`add`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:s(`sessions.sidebar.project.actions.newSession`)})]}):null,o?(0,$.jsxs)(X,{type:`button`,variant:`destructive`,className:`oc-mobile-worktree-action h-full flex-col rounded-none border-0 px-1`,"aria-label":s(`mobile.projectEdit.deleteWorktreeAria`,{label:t.name}),tabIndex:C?0:-1,onClick:M,children:[(0,$.jsx)(Y,{name:`delete-bin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:s(`mobile.projectEdit.deleteWorktreeConfirmButton`)})]}):null]}):null,(0,$.jsxs)(`div`,{className:J(`oc-mobile-worktree-label-content relative z-10 flex min-w-0 flex-1 items-center`,`ease-out motion-reduce:transition-none`,g?`transition-none`:`transition-transform duration-150`),style:{transform:`translate3d(${f}px, 0, 0)`,willChange:f===0?void 0:`transform`},"data-pressed":m?`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:O,onPointerDown:w,onPointerMove:T,onPointerUp:E,onPointerCancel:D,onContextMenu:k,style:{touchAction:`pan-y`},children:P}),u?(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-mobile-worktree-more rounded-full text-muted-foreground`,"aria-label":s(`agentManager.detail.actions.worktreeActionsAria`),onClick:N,children:(0,$.jsx)(Y,{name:`more-2`,className:`size-3.5`})}):null]})]})}var Ia=e=>e.filter(e=>!e.id.startsWith(`__show_`)),La=e=>({pinned:Ia(e).filter(e=>e.pinned),rest:e.filter(e=>!e.pinned)});function Ra(e){let t=(0,Q.c)(82),{projects:n,onAddProject:r,onNewSession:i,onToggleProject:a,onOpenProjectActions:o,onToggleWorktree:s,onNewWorktreeSession:c,onOpenWorktreeActions:l,onDeleteWorktree:u,onSelectSession:d,onPinSession:f,onArchiveSession:p,onOpenSessionActions:m,className:h}=e,{t:g}=ee(),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_={},t[0]=_):_=t[0];let[v,y]=Z.useState(_),[b,x]=Z.useState(!1),[S,C]=Z.useState(``),w;t[1]===S?w=t[2]:(w=S.trim().toLowerCase(),t[1]=S,t[2]=w);let T=w,E=T.length>0,D;t[3]!==T||t[4]!==n?(D=Oa(n,T),t[3]=T,t[4]=n,t[5]=D):D=t[5];let O=D,k=j(r),A=j(i),M;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{C(``),x(!1)},t[6]=M):M=t[6];let N=j(M),P;t[7]!==N||t[8]!==b?(P=()=>{if(b){N();return}x(!0)},t[7]=N,t[8]=b,t[9]=P):P=t[9];let F=j(P),I;t[10]!==N||t[11]!==a?(I=e=>{N(),e.expanded||a(e)},t[10]=N,t[11]=a,t[12]=I):I=t[12];let L=j(I),R;t[13]!==N||t[14]!==a||t[15]!==s?(R=(e,t)=>{N(),e.expanded||a(e),t.expanded||s(e,t)},t[13]=N,t[14]=a,t[15]=s,t[16]=R):R=t[16];let z=j(R),B;t[17]!==N||t[18]!==d?(B=e=>{N(),d(e)},t[17]=N,t[18]=d,t[19]=B):B=t[19];let V=j(B),H;t[20]===h?H=t[21]:(H=J(`relative isolate mx-auto flex w-full max-w-[26rem] flex-col gap-5`,h),t[20]=h,t[21]=H);let te;t[22]===g?te=t[23]:(te=g(`mobile.sessions.section.projects`),t[22]=g,t[23]=te);let ne;t[24]!==b||t[25]!==g?(ne=g(b?`mobile.sessions.clearSearchAria`:`mobile.sessions.searchAria`),t[24]=b,t[25]=g,t[26]=ne):ne=t[26];let re=b?`close`:`search`,U;t[27]===re?U=t[28]:(U=(0,$.jsx)(Y,{name:re,className:`size-5`}),t[27]=re,t[28]=U);let W;t[29]!==F||t[30]!==b||t[31]!==ne||t[32]!==U?(W=(0,$.jsx)(X,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":ne,"aria-expanded":b,onClick:F,children:U}),t[29]=F,t[30]=b,t[31]=ne,t[32]=U,t[33]=W):W=t[33];let ie;t[34]===g?ie=t[35]:(ie=g(`mobile.sessions.newChat`),t[34]=g,t[35]=ie);let ae;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(Y,{name:`add`,className:`size-5`}),t[36]=ae):ae=t[36];let G;t[37]!==A||t[38]!==ie?(G=(0,$.jsx)(X,{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":ie,onClick:A,children:ae}),t[37]=A,t[38]=ie,t[39]=G):G=t[39];let oe;t[40]!==W||t[41]!==G?(oe=(0,$.jsxs)($.Fragment,{children:[W,G]}),t[40]=W,t[41]=G,t[42]=oe):oe=t[42];let se;t[43]!==te||t[44]!==oe?(se=(0,$.jsx)(An,{title:te,trailing:oe}),t[43]=te,t[44]=oe,t[45]=se):se=t[45];let ce;t[46]!==N||t[47]!==b||t[48]!==S||t[49]!==g?(ce=b?(0,$.jsxs)(`div`,{className:`relative mx-1`,role:`search`,children:[(0,$.jsx)(Y,{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)(bt,{autoFocus:!0,type:`text`,inputMode:`search`,enterKeyHint:`search`,value:S,placeholder:g(`mobile.sessions.search.placeholder`),"aria-label":g(`mobile.sessions.searchAria`),className:J(`h-11 rounded-full pl-9`,S&&`pr-10`),onChange:e=>C(e.target.value),onKeyDown:e=>{e.key===`Escape`&&N()}}),S?(0,$.jsx)(X,{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":g(`mobile.sessions.clearSearchAria`),onClick:()=>C(``),children:(0,$.jsx)(Y,{name:`close`,className:`size-4`})}):null]}):null,t[46]=N,t[47]=b,t[48]=S,t[49]=g,t[50]=ce):ce=t[50];let le;t[51]!==k||t[52]!==L||t[53]!==z||t[54]!==V||t[55]!==p||t[56]!==u||t[57]!==c||t[58]!==o||t[59]!==m||t[60]!==l||t[61]!==f||t[62]!==d||t[63]!==a||t[64]!==s||t[65]!==v||t[66]!==n.length||t[67]!==E||t[68]!==g||t[69]!==O?(le=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)(Y,{name:`folder-add`,className:`size-6`})}),(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:g(`mobile.sessions.empty.noProjectsTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-xs typography-small text-muted-foreground`,children:g(`mobile.sessions.empty.noProjectsDescription`)}),(0,$.jsxs)(X,{type:`button`,size:`lg`,className:`mt-4 min-h-10 rounded-full px-5`,onClick:k,children:[(0,$.jsx)(Y,{name:`folder-add`,className:`size-4`}),g(`sessions.sidebar.header.actions.addProject`)]})]}):E&&O.length===0?(0,$.jsxs)(`section`,{className:`flex min-h-[40dvh] flex-col items-center justify-center px-6 text-center`,children:[(0,$.jsx)(Y,{name:`search`,className:`mb-4 size-6 text-muted-foreground`}),(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:g(`mobile.sessions.empty.searchTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-xs typography-small text-muted-foreground`,children:g(`mobile.sessions.empty.searchDescription`)})]}):O.map(e=>{let t=E||e.expanded,n=e.worktrees.find(Ha)??(e.worktrees.length===1&&!e.worktrees[0]?.kind?e.worktrees[0]:void 0),r=e.worktrees.filter(e=>e!==n),{pinned:i,rest:h}=La(n?.sessions??[]),_=r.flatMap(Ba),b=[...i,..._],x=E||(v[e.id]??!0);return(0,$.jsx)(Nn,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":e.name,children:[(0,$.jsx)(ya,{project:e,expanded:t,embedded:!0,onToggle:()=>E?L(e):a(e),onOpenActions:()=>o(e)}),t?(0,$.jsxs)(`div`,{className:`oc-mobile-project-groups`,role:`group`,"aria-label":e.name,children:[b.length>0?(0,$.jsx)(In,{ariaLabel:g(`mobile.sessions.section.pinned`),label:(0,$.jsx)(Pa,{icon:(0,$.jsx)(Y,{name:`pushpin`,className:`size-3.5`}),label:g(`mobile.sessions.section.pinned`),count:b.length,expanded:x,onToggle:E?void 0:()=>{y(t=>({...t,[e.id]:!(t[e.id]??!0)}))}}),children:x?(0,$.jsx)(Na,{sessions:b,onSelectSession:E?V:d,onPinSession:f,onArchiveSession:p,onOpenSessionActions:m}):null}):null,h.length>0?(0,$.jsx)(`div`,{className:`oc-mobile-labeled-surface-group`,children:(0,$.jsx)(Na,{sessions:h,onSelectSession:E?V:d,onPinSession:f,onArchiveSession:p,onOpenSessionActions:m})}):null,r.map(t=>{let n=t.sessions.filter(za),r=E||!!t.expanded;return(0,$.jsx)(In,{className:`oc-mobile-worktree-group`,ariaLabel:t.name,label:(0,$.jsx)(Fa,{project:e,worktree:t,expanded:r,onToggle:()=>E?z(e,t):s(e,t),onNewSession:c,onOpenActions:E?void 0:l,onDelete:E?void 0:u}),children:r&&n.length>0?(0,$.jsx)(Na,{sessions:n,onSelectSession:E?V:d,onPinSession:f,onArchiveSession:p,onOpenSessionActions:m}):null},t.id)})]}):null]})},e.id)}),t[51]=k,t[52]=L,t[53]=z,t[54]=V,t[55]=p,t[56]=u,t[57]=c,t[58]=o,t[59]=m,t[60]=l,t[61]=f,t[62]=d,t[63]=a,t[64]=s,t[65]=v,t[66]=n.length,t[67]=E,t[68]=g,t[69]=O,t[70]=le):le=t[70];let ue;t[71]===g?ue=t[72]:(ue=g(`sessions.sidebar.header.actions.addProject`),t[71]=g,t[72]=ue);let de;t[73]!==k||t[74]!==ue?(de=(0,$.jsx)(`button`,{type:`button`,className:`sr-only`,onClick:k,children:ue}),t[73]=k,t[74]=ue,t[75]=de):de=t[75];let fe;return t[76]!==se||t[77]!==ce||t[78]!==le||t[79]!==de||t[80]!==H?(fe=(0,$.jsxs)(`main`,{className:H,children:[se,ce,le,de]}),t[76]=se,t[77]=ce,t[78]=le,t[79]=de,t[80]=H,t[81]=fe):fe=t[81],fe}function za(e){return!e.pinned}function Ba(e){return Ia(e.sessions).filter(Va)}function Va(e){return e.pinned}function Ha(e){return e.kind===`main`}function Ua(e){let t=(0,Q.c)(11),{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=j(i),f=c?`destructive`:`ghost`,p=u?`size-5 animate-spin`:`size-5`,m;t[0]!==n||t[1]!==p?(m=(0,$.jsx)(Y,{name:n,className:p}),t[0]=n,t[1]=p,t[2]=m):m=t[2];let h;t[3]===r?h=t[4]:(h=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[3]=r,t[4]=h);let g;return t[5]!==l||t[6]!==d||t[7]!==f||t[8]!==m||t[9]!==h?(g=(0,$.jsxs)(X,{type:`button`,variant:f,size:`lg`,className:`min-h-12 w-full justify-start gap-3 rounded-lg px-4`,disabled:l,onClick:d,children:[m,h]}),t[5]=l,t[6]=d,t[7]=f,t[8]=m,t[9]=h,t[10]=g):g=t[10],g}function Wa(e){let t=(0,Q.c)(40),{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;if(!r)return null;let p;t[2]===r.title?p=t[3]:(p=(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold`,children:r.title}),t[2]=r.title,t[3]=p);let m=r.title,h;t[4]===u?h=t[5]:(h=u(`mobile.surface.closeAria`),t[4]=u,t[5]=h);let g;t[6]===u?g=t[7]:(g=u(`mobile.sessions.sheet.resizeAria`),t[6]=u,t[7]=g);let _;t[8]!==i||t[9]!==c||t[10]!==l||t[11]!==f||t[12]!==u||t[13]!==r.kind||t[14]!==r.pinned||t[15]!==r.shared?(_=r.kind===`session`?(0,$.jsxs)($.Fragment,{children:[i.onRename?(0,$.jsx)(Ua,{icon:`pencil-ai`,label:u(`sessions.sidebar.session.menu.rename`),onClick:f(i.onRename)}):null,i.onTogglePin?(0,$.jsx)(Ua,{icon:r.pinned?`unpin`:`pushpin`,label:r.pinned?u(`sessions.sidebar.session.menu.unpin`):u(`sessions.sidebar.session.menu.pin`),onClick:f(i.onTogglePin)}):null,r.shared?(0,$.jsxs)($.Fragment,{children:[i.onCopyLink?(0,$.jsx)(Ua,{icon:`file-copy`,label:u(`sessions.sidebar.session.menu.copyLink`),onClick:f(i.onCopyLink)}):null,i.onUnshare?(0,$.jsx)(Ua,{icon:`link-unlink-m`,label:u(`sessions.sidebar.session.menu.unshare`),onClick:f(i.onUnshare)}):null]}):i.onShare?(0,$.jsx)(Ua,{icon:`share-2`,label:u(`sessions.sidebar.session.menu.share`),onClick:f(i.onShare)}):null,i.onRefreshTranscript?(0,$.jsx)(Ua,{icon:`refresh`,label:u(`sessions.sidebar.session.menu.refreshTranscript`),disabled:c,spinning:l,onClick:f(i.onRefreshTranscript)}):null,i.onArchive?(0,$.jsx)(Ua,{icon:`archive`,label:u(`sessions.sidebar.bulkActions.archive`),onClick:f(i.onArchive)}):null,i.onDelete?(0,$.jsx)(`div`,{className:`mt-3 border-t border-[var(--surface-subtle)] pt-3`,children:(0,$.jsx)(Ua,{icon:`delete-bin`,label:u(`sessions.sidebar.bulkActions.delete`),onClick:f(i.onDelete),destructive:!0})}):null]}):null,t[8]=i,t[9]=c,t[10]=l,t[11]=f,t[12]=u,t[13]=r.kind,t[14]=r.pinned,t[15]=r.shared,t[16]=_):_=t[16];let v;t[17]!==i||t[18]!==f||t[19]!==u||t[20]!==r.gitRepository||t[21]!==r.kind?(v=r.kind===`project`?(0,$.jsxs)($.Fragment,{children:[i.onNewSession?(0,$.jsx)(Ua,{icon:`add`,label:u(`sessions.sidebar.project.actions.newSession`),onClick:f(i.onNewSession)}):null,r.gitRepository&&i.onNewWorktree?(0,$.jsx)(Ua,{icon:`node-tree`,label:u(`sessions.sidebar.project.actions.newWorktree`),onClick:f(i.onNewWorktree)}):null,i.onSyncSessions?(0,$.jsx)(Ua,{icon:`refresh`,label:u(`sessions.sidebar.project.actions.syncSessions`),onClick:f(i.onSyncSessions)}):null,i.onEditProject?(0,$.jsx)(Ua,{icon:`pencil-ai`,label:u(`sessions.sidebar.project.actions.edit`),onClick:f(i.onEditProject)}):null,i.onCloseProject?(0,$.jsx)(`div`,{className:`mt-3 border-t border-[var(--surface-subtle)] pt-3`,children:(0,$.jsx)(Ua,{icon:`close`,label:u(`sessions.sidebar.project.actions.closeProject`),onClick:f(i.onCloseProject),destructive:!0})}):null]}):null,t[17]=i,t[18]=f,t[19]=u,t[20]=r.gitRepository,t[21]=r.kind,t[22]=v):v=t[22];let y;t[23]!==i||t[24]!==f||t[25]!==u||t[26]!==r.kind?(y=r.kind===`worktree`?(0,$.jsxs)($.Fragment,{children:[i.onNewSession?(0,$.jsx)(Ua,{icon:`add`,label:u(`sessions.sidebar.project.actions.newSession`),onClick:f(i.onNewSession)}):null,i.onDeleteWorktree?(0,$.jsx)(`div`,{className:`mt-3 border-t border-[var(--surface-subtle)] pt-3`,children:(0,$.jsx)(Ua,{icon:`delete-bin`,label:u(`mobile.projectEdit.deleteWorktreeConfirmButton`),onClick:f(i.onDeleteWorktree),destructive:!0})}):null]}):null,t[23]=i,t[24]=f,t[25]=u,t[26]=r.kind,t[27]=y):y=t[27];let b;t[28]!==y||t[29]!==_||t[30]!==v?(b=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto overscroll-contain px-2`,children:[_,v,y]}),t[28]=y,t[29]=_,t[30]=v,t[31]=b):b=t[31];let x;return t[32]!==a||t[33]!==n||t[34]!==b||t[35]!==p||t[36]!==h||t[37]!==g||t[38]!==r.title?(x=(0,$.jsx)(Mt,{id:`mobile-row-actions-sheet`,open:n,onOpenChange:a,title:p,ariaLabel:m,closeAriaLabel:h,resizeAriaLabel:g,fitContent:!0,children:b}),t[32]=a,t[33]=n,t[34]=b,t[35]=p,t[36]=h,t[37]=g,t[38]=r.title,t[39]=x):x=t[39],x}var Ga=`__show_more__:`,Ka=`__show_fewer__:`,qa=e=>e.startsWith(Ga),Ja=e=>e.startsWith(Ka),Ya=e=>qa(e)||Ja(e),Xa=e=>{let t=qa(e)?Ga:Ja(e)?Ka: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)}},Za=e=>e.parentID??null,Qa=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),$a=e=>{let t=e;return Qa(t.directory??t.project?.worktree??null)},eo=(e,t)=>{if(t?.trim())return t.trim();let n=Qa(e);if(!n)return``;let r=n.split(`/`).filter(Boolean);return r[r.length-1]||n},to=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},no=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))},ro=e=>{let t=e.time?.archived;return typeof t==`number`&&t>0},io=(e,t)=>e.worktrees.find(e=>Qa(e.path)===t)??null,ao=(e,t)=>t===e.path||!!io(e,t);function oo(){let e=(0,Q.c)(56),{t}=ee(),n=te(),r=W(Eo),i=W(To),a=G(wo),o=G(Co),s=w(So),c=K(xo),l=K(bo),u=st(yo),d=Qe(vo),f=Oi(_o),p=Oi(go),m=z(ho),h;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=new Map,e[0]=h):h=e[0];let[g,_]=Z.useState(h),v;if(e[1]!==a||e[2]!==u||e[3]!==l){let t;e[5]!==u||e[6]!==l?(t=e=>{let t=Qa(e.path);return{id:e.id,label:eo(t,e.label),path:t,icon:e.icon,worktrees:it(u[e.id],l.get(t)??[])}},e[5]=u,e[6]=l,e[7]=t):t=e[7],v=a.map(t),e[1]=a,e[2]=u,e[3]=l,e[4]=v}else v=e[4];let y=v,b;if(e[8]!==r||e[9]!==n){let t=new Map(n.map(mo));b=r.map(e=>{let n=t.get(e.id);return n?le(n,e):e});let i=new Set(b.map(po));for(let e of n)i.has(e.id)||b.push(e);e[8]=r,e[9]=n,e[10]=b}else b=e[10];let x=b,S;if(e[11]!==o||e[12]!==y||e[13]!==x){let t;e[15]===o?t=e[16]:(t=e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===o,latestActivity:0}),e[15]=o,e[16]=t),S=y.map(t);let n=fo;for(let e of S){n(e,e.project.path,null);for(let t of e.project.worktrees)n(e,t.path,t)}for(let e of x){let t=$a(e);if(!t)continue;let r=Qa(t),i=S.find(e=>ao(e.project,r));if(!i)continue;let a=io(i.project,r);(a?n(i,a.path,a):n(i,i.project.path,null)).sessions.push(e)}for(let e of S)for(let t of e.buckets){t.sessions.sort(uo);for(let n of t.sessions){Za(n)||(e.totalSessions+=1);let t=to(n);t>e.latestActivity&&(e.latestActivity=t)}}e[11]=o,e[12]=y,e[13]=x,e[14]=S}else S=e[14];let C=S,T;if(e[17]!==x){T=new Map;for(let e of x)T.set(e.id,e);e[17]=x,e[18]=T}else T=e[18];let E=T,D;if(e[19]!==y){D=new Map;for(let e of y)D.set(e.id,e);e[19]=y,e[20]=D}else D=e[20];let O=D,k;if(e[21]!==C){k=new Map;for(let e of C){let t=e.project.worktrees.length>0;for(let n of e.buckets){let r=n.sessions.filter(lo).length;k.set(`${e.project.id}::${n.key}`,{path:n.path,rootCount:r,hasWorktrees:t})}}e[21]=C,e[22]=k}else k=e[22];let A=k,j;if(e[23]!==i||e[24]!==s||e[25]!==c||e[26]!==d||e[27]!==f||e[28]!==C||e[29]!==t||e[30]!==m||e[31]!==g||e[32]!==p){let n=Qa(s);j=C.map(e=>{let r=f[e.project.id]??!0,a=ir(),o=e.project.icon?mt[e.project.icon]:void 0,s=e.buckets.map(r=>{let o=`${e.project.id}::${r.key}`,s=p[o]??!1,l=g.get(o)??a,u=r.sessions.filter(co),f=u.slice(0,l).map(e=>{let n=Za(e),i=(m[e.id]??0)>0&&!n;return{id:e.id,directory:r.path,title:e.title?.trim()||t(`mobile.sessions.untitled`),activityLabel:no(to(e))||void 0,unread:i,pinned:d.has(e.id),archived:ro(e),active:c===e.id}}),h=u.length-f.length,_=i.get(Qa(r.path)),v=_?.hasMore===!0,y=u.length>a&&l>a,b=[...f];y&&b.push({id:`${Ka}${e.project.id}::${r.key}`,kind:`pagination`,title:t(`sessions.sidebar.group.showFewer`)}),(h>0||v)&&b.push({id:`${Ga}${e.project.id}::${r.key}`,kind:`pagination`,title:t(`sessions.sidebar.group.showMore`),subtitle:_?.loadingMore?`…`:void 0});let x=Qa(r.path),S=!!(e.isActive&&n&&x&&(n===x||n.startsWith(`${x}/`))),C=r.worktree==null;return{id:r.key,name:C?t(`mobile.sessions.mainWorkspace`):r.label,path:r.path,kind:C?`main`:`worktree`,active:S,expanded:C?!0:s,sessionCount:u.length,sessions:b}});return{id:e.project.id,name:e.project.label,path:e.project.path,icon:o,sessionCount:e.totalSessions,activityLabel:no(e.latestActivity)||void 0,active:e.isActive,expanded:r,worktrees:s}}),e[23]=i,e[24]=s,e[25]=c,e[26]=d,e[27]=f,e[28]=C,e[29]=t,e[30]=m,e[31]=g,e[32]=p,e[33]=j}else j=e[33];let M=j,N;e[34]===A?N=e[35]:(N=e=>{for(let[t,n]of A)if(t.startsWith(`${e}::`))return n.hasWorktrees;return!1},e[34]=A,e[35]=N);let P=N,F;e[36]===A?F=e[37]:(F=(e,t)=>A.get(`${e}::${t}`)?.rootCount??0,e[36]=A,e[37]=F);let I=F,L=so,R;e[38]===g?R=e[39]:(R=(e,t)=>{let n=`${e}::${t}`;return g.get(n)??L(e)},e[38]=g,e[39]=R);let B=R,V;e[40]===A?V=e[41]:(V=(e,t)=>A.get(`${e}::${t}`)?.path??null,e[40]=A,e[41]=V);let H=V,ne;e[42]!==A||e[43]!==g?(ne=(e,t)=>{let n=`${e}::${t}`,r=A.get(n),i=ir(),a=tr(),o=g.get(n)??i,s=r?.rootCount??0;if(_(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=Qa(c);if(!l)return;let u=W.getState().activePaginationByDirectory.get(l);u?.hasMore&&!u.loadingMore&&ue(l)},e[42]=A,e[43]=g,e[44]=ne):ne=e[44];let re=ne,U;e[45]===Symbol.for(`react.memo_cache_sentinel`)?(U=(e,t)=>{let n=`${e}::${t}`;_(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t})},e[45]=U):U=e[45];let ie=U,ae;return e[46]!==H||e[47]!==I||e[48]!==B||e[49]!==M||e[50]!==P||e[51]!==O||e[52]!==E||e[53]!==x||e[54]!==re?(ae={projects:M,sessionById:E,projectMetaById:O,allSessions:x,projectHasWorktrees:P,getBucketRootCount:I,getBucketVisibleCount:B,getBucketPageSize:L,getBucketDirectory:H,showMoreBucketSessions:re,resetBucketVisibleCount:ie},e[46]=H,e[47]=I,e[48]=B,e[49]=M,e[50]=P,e[51]=O,e[52]=E,e[53]=x,e[54]=re,e[55]=ae):ae=e[55],ae}function so(e){return ir()}function co(e){return!Za(e)}function lo(e){return!Za(e)}function uo(e,t){return to(t)-to(e)}function fo(e,t,n){let r=Qa(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||eo(r),path:r,worktree:n,sessions:[]},e.buckets.push(a)),a}function po(e){return e.id}function mo(e){return[e.id,e]}function ho(e){return e.index.session.unseenCount}function go(e){return e.worktreeExpanded}function _o(e){return e.projectExpanded}function vo(e){return e.ids}function yo(e){return e.orderByProject}function bo(e){return e.availableWorktreesByProject}function xo(e){return e.currentSessionId}function So(e){return e.currentDirectory}function Co(e){return e.activeProjectId}function wo(e){return e.projects}function To(e){return e.activePaginationByDirectory}function Eo(e){return e.activeSessions}var Do=(e,t,n)=>e?.kind===`project`&&e.project.id===t?{...e,isGitRepository:n}:e;function Oo({onOpenChat:e,onAddProject:t,onNewSession:n,className:r}){let{t:i}=ee(),{git:a}=Kt(),o=oo(),s=Oi(e=>e.setProjectExpanded),c=Oi(e=>e.setWorktreeExpanded),l=Qe(e=>e.toggle),u=Qe(e=>e.ids),f=K(e=>e.archiveSessions),p=K(e=>e.updateSessionTitle),m=K(e=>e.requestSessionSmartTitle),h=K(e=>e.shareSession),g=K(e=>e.unshareSession),_=K(e=>e.openNewSessionDraft),v=ge(e=>e.openDraft),y=ge(e=>e.openSession),b=G(e=>e.setActiveProjectIdOnly),x=G(e=>e.removeProject),S=Ut(),[C,w]=Z.useState(null),[T,E]=Z.useState(!1),[D,O]=Z.useState(null),[k,A]=Z.useState(null),[M,P]=Z.useState(``),[I,L]=Z.useState(!1),[R,z]=Z.useState(!1),[B,V]=Z.useState(null),[H,te]=Z.useState(null),[ne,re]=Z.useState(null),U=C?.kind===`session`?C.session.id:``,W=ae(U),ie=W?.type===`busy`||W?.type===`retry`,oe=C?.kind===`session`?$a(C.session):``,se=!!U&&ne===U,ce=!oe||se||ie,le=j(e=>{let t=new Map;for(let e of o.allSessions){let n=Za(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}),ue=j(()=>{E(!1),w(null)}),de=j(t=>{if(Ya(t.id)){let e=Xa(t.id);if(!e)return;e.kind===`more`?o.showMoreBucketSessions(e.projectId,e.bucketKey):o.resetBucketVisibleCount(e.projectId,e.bucketKey);return}let n=o.sessionById.get(t.id),r=n&&$a(n)||null;e({sessionId:t.id,directory:r})}),fe=j(e=>{Ya(e.id)||l(e.id)}),pe=j(async e=>{if(Ya(e.id))return;let t=le(e.id),{archivedIds:n,failedIds:r}=await f(t);n.length>0&&lr({sessionIds:n,message:n.length===1?i(`sessions.sidebar.session.archive.success`):i(`sessions.sidebar.bulkActions.archivedPlural`,{count:n.length}),undoLabel:i(`sessions.sidebar.undo`),settingsLabel:i(`settings.openchamber.archivedSessions.actions.view`),undoFailedMessage:n.length===1?i(`sessions.sidebar.session.archive.undoFailed`):i(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:n.length})}),r.length>0&&F.error(r.length===1?i(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):i(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}),q=j(()=>{if(!C||C.kind!==`session`)return;let e=C.session,t=$a(e),n=W?.type??`idle`;!t||ne===e.id||n===`busy`||n===`retry`||(re(e.id),(async()=>{try{await S.refreshSessionTranscript(e.id,{directory:t}),F.success(i(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{F.error(i(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{re(t=>t===e.id?null:t)}})())}),me=j(e=>{if(Ya(e.id))return;let t=o.sessionById.get(e.id);t&&(w({kind:`session`,session:t}),E(!0))}),he=j(e=>{s(e.id,!e.expanded)}),_e=j((e,t)=>{c(`${e.id}::${t.id}`,!t.expanded)}),ve=j((e,t)=>{b(e.id),v({selectedProjectId:e.id,directoryOverride:t,preserveDirectoryOverride:!0})}),ye=j(()=>{if(n){n();return}_()}),be=j(e=>{let t=o.projectMetaById.get(e.id);t&&(w({kind:`project`,project:t,isGitRepository:!1}),E(!0),a.checkIsGitRepository(t.path).then(e=>{w(n=>Do(n,t.id,e))}).catch(()=>{w(e=>Do(e,t.id,!1))}))}),xe=j((e,t)=>{let n=d(t);return n?e.worktrees.find(e=>d(e.path)===n)||((K.getState().availableWorktreesByProject.get(e.path)??[]).find(e=>d(e.path)===n)??null):null}),Se=j((e,t)=>{let n=o.projectMetaById.get(e.id);n&&ve(n,t.path)}),we=j((e,t)=>{let n=o.projectMetaById.get(e.id);n&&(w({kind:`worktree`,project:n,worktreePath:t.path,worktreeName:t.name}),E(!0))}),Te=j((e,t)=>{let n=o.projectMetaById.get(e.id);if(!n)return;let r=xe(n,t.path);if(!r){F.error(i(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:i(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}te({project:n,worktree:r})}),Ee=j(e=>{V(e),b(e),z(!0)}),De=j(e=>{(async()=>{let t=e.worktrees;try{t=(await pt({id:e.id,path:e.path})).worktrees}catch(n){console.warn(`[MobileProjectsHome] Worktree refresh before session sync failed:`,n),t=K.getState().availableWorktreesByProject.get(e.path)??e.worktrees}await Ce([e.path,...t.map(e=>e.path)],o.allSessions)})()}),Oe=j((e,t)=>{let n=B;if(z(!1),V(null),t?.sessionId){y({sessionId:t.sessionId,directory:e});return}v({selectedProjectId:n,directoryOverride:e,preserveDirectoryOverride:!0})}),ke=j(async e=>{try{if(!(await h(e.id))?.share?.url){F.error(i(`sessions.sidebar.session.share.error`));return}F.success(i(`sessions.sidebar.session.share.successTitle`),{description:i(`sessions.sidebar.session.share.successDescription`)})}catch{F.error(i(`sessions.sidebar.session.share.error`))}}),Ae=j(async e=>{if((await N(e)).ok){F.success(i(`sessions.sidebar.session.menu.copied`));return}F.error(i(`sessions.sidebar.session.share.copyUrlError`))}),je=j(async e=>{try{if(await g(e)){F.success(i(`sessions.sidebar.session.unshare.success`));return}F.error(i(`sessions.sidebar.session.unshare.error`))}catch{F.error(i(`sessions.sidebar.session.unshare.error`))}}),Me=j(e=>{let t=le(e.id);Wn({sessionIds:t,message:t.length===1?i(`sessions.sidebar.session.delete.success`):i(`sessions.sidebar.bulkActions.deletedPlural`,{count:t.length}),undoLabel:i(`sessions.sidebar.undo`),commitFailedMessage:i(`sessions.sidebar.session.delete.error`)})}),Ne=j(async()=>{if(!k)return;let e=M.trim();if(e)try{await p(k.id,e),A(null),P(``)}catch{F.error(i(`sessions.sidebar.session.menu.rename`),{description:i(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}}),Pe=j(async()=>{if(!k||I)return;let e=k.id;A(null),P(``),L(!0);try{await m(e)}catch{F.error(i(`sessions.sidebar.session.rename.smartTitle`),{description:i(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{L(!1)}}),Fe=Z.useMemo(()=>C?C.kind===`session`?{kind:`session`,title:C.session.title?.trim()||i(`mobile.sessions.untitled`),pinned:u.has(C.session.id),shared:!!C.session.share?.url}:C.kind===`project`?{kind:`project`,title:C.project.label,gitRepository:C.isGitRepository}:{kind:`worktree`,title:C.worktreeName}:null,[C,u,i]),Ie=Z.useMemo(()=>{if(!C)return{};if(C.kind===`session`){let e=C.session;return{onRename:()=>{P(e.title?.trim()||i(`mobile.sessions.untitled`)),A(e)},onTogglePin:()=>l(e.id),onShare:e.share?.url?void 0:()=>{ke(e)},onCopyLink:e.share?.url?()=>{Ae(e.share.url)}:void 0,onUnshare:e.share?.url?()=>{je(e.id)}:void 0,onRefreshTranscript:q,onArchive:()=>{pe({id:e.id,title:e.title?.trim()||i(`mobile.sessions.untitled`)})},onDelete:()=>Me(e)}}if(C.kind===`project`){let e=C.project;return{onNewSession:()=>ve(e,e.path),onNewWorktree:()=>Ee(e.id),onSyncSessions:()=>De(e),onEditProject:void 0,onCloseProject:()=>O(e)}}let{project:e,worktreePath:t}=C;return{onNewSession:()=>ve(e,t),onDeleteWorktree:()=>{let n=xe(e,t);if(!n){F.error(i(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:i(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}te({project:e,worktree:n})}}},[C,pe,Ae,Me,q,Ee,De,ke,je,xe,ve,i,l]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ra,{className:r,projects:o.projects,onAddProject:t,onNewSession:ye,onToggleProject:he,onOpenProjectActions:be,onToggleWorktree:_e,onNewWorktreeSession:Se,onOpenWorktreeActions:we,onDeleteWorktree:Te,onSelectSession:de,onPinSession:fe,onArchiveSession:e=>{pe(e)},onOpenSessionActions:me}),(0,$.jsx)(Wa,{open:T,target:Fe,actions:Ie,refreshTranscriptDisabled:ce,refreshTranscriptSpinning:se,onOpenChange:e=>{e?E(!0):ue()}}),(0,$.jsx)(Wt,{open:R,projectId:B,onOpenChange:e=>{z(e),e||V(null)},onWorktreeCreated:Oe}),H?(0,$.jsx)(Xn,{open:!0,project:{id:H.project.id,path:H.project.path},worktree:H.worktree,onClose:()=>te(null)}):null,(0,$.jsx)(Gt,{open:!!D,title:i(`sessions.sidebar.project.actions.closeProject`),onClose:()=>O(null),closeAriaLabel:i(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>O(null),children:i(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(X,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!D)return;let e=D;O(null),x(e.id),F.success(i(`mobile.sessions.toast.projectRemoved`,{label:e.label}))},children:i(`mobile.sessions.confirmRemoveProject`)})]}),children:(0,$.jsx)(`p`,{className:`px-1 py-1 typography-ui-body text-foreground`,children:i(`mobile.projects.closeConfirmMessage`,{title:D?.label??``})})}),(0,$.jsx)(Gt,{open:!!k,title:i(`sessions.sidebar.session.menu.rename`),onClose:()=>{I||(A(null),P(``))},closeAriaLabel:i(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:I,onClick:()=>{A(null),P(``)},children:i(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(X,{type:`button`,variant:`default`,className:`flex-1`,disabled:!M.trim()||I,onClick:()=>void Ne(),children:i(`sessions.sidebar.session.rename.save`)})]}),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-3 px-1 py-1`,onSubmit:e=>{e.preventDefault(),Ne()},children:[(0,$.jsx)(bt,{value:M,onChange:e=>P(e.target.value),autoFocus:!0,className:`h-12`,disabled:I}),(0,$.jsxs)(X,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:I,onClick:()=>void Pe(),children:[I?(0,$.jsx)(Y,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(Y,{name:`ai-generate-2`,className:`size-4`}),i(`sessions.sidebar.session.rename.smartTitle`)]})]})})]})}function ko(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=J(`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)(Mn,{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 Ao(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=[...Pn],t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,$.jsx)(gr,{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)(Mn,{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 jo(e){let t=(0,Q.c)(84),{onAddProject:n,onEnableAssistants:r,instancesPage:i,parentSessionTarget:a,registerSecondaryBackHandler:o,scheduledContent:s,renderChat:c,className:l}=e,u=a===void 0?null:a,{t:f}=ee(),p=ge(),m=ge(Ho),h=ge(Vo),g=ge(Bo),_=ge(zo),v=ge(Ro),y=ge(Lo),b=ge(Io),x=ge(Fo),S=ge(Po),C;t[0]===m?C=t[1]:(C=e=>{m(e)},t[0]=m,t[1]=C);let w=j(C),T;t[2]===h?T=t[3]:(T=e=>{h(e)},t[2]=h,t[3]=T);let E=j(T),D;t[4]===v?D=t[5]:(D=()=>{v()},t[4]=v,t[5]=D);let O=j(D),k;t[6]===g?k=t[7]:(k=()=>{g()},t[6]=g,t[7]=k);let A=j(k),M;t[8]===_?M=t[9]:(M=e=>{_(e)},t[8]=_,t[9]=M);let N=j(M),P=Z.useRef(null),[F,I]=Z.useState(!1),L;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>{P.current=e},t[10]=L):L=t[10];let R=j(L),z;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>{I(e)},t[11]=z):z=t[11];let B=j(z),V;t[12]!==O||t[13]!==y?(V=()=>{if(P.current?.())return!0;let e=ge.getState().secondary;return e?.kind===`chat`&&e.routes.length>1?(y(),!0):e?(O(),!0):!1},t[12]=O,t[13]=y,t[14]=V):V=t[14];let H=j(V),te=p.secondary!==null,ne;t[15]!==H||t[16]!==o?(ne=()=>{if(o)return o(()=>H()),()=>o(null)},t[15]=H,t[16]=o,t[17]=ne):ne=t[17];let re;t[18]!==H||t[19]!==o||t[20]!==te?(re=[o,te,H],t[18]=H,t[19]=o,t[20]=te,t[21]=re):re=t[21],Z.useEffect(ne,re);let U=K(No),W;t[22]===U?W=t[23]:(W=e=>U?e.getDirectoryForSession(U):null,t[22]=U,t[23]=W);let ie=K(W),ae,G;t[24]!==ie||t[25]!==U||t[26]!==x||t[27]!==S?(ae=()=>{let e=ge.getState().secondary;if(e?.kind===`draft`&&U){x({sessionId:U,directory:ie});return}if(e?.kind!==`chat`||!U||ye({sessionId:U,directory:ie})===`internal`)return;let t=e.routes.at(-1);(t?.sessionId!==U||d(t.directory)!==d(ie))&&S({sessionId:U,directory:ie})},G=[ie,U,x,S],t[24]=ie,t[25]=U,t[26]=x,t[27]=S,t[28]=ae,t[29]=G):(ae=t[28],G=t[29]),Z.useEffect(ae,G);let oe,se;t[30]!==U||t[31]!==u||t[32]!==b?(oe=()=>{let e=ge.getState().secondary;if(e?.kind!==`chat`||!u)return;let t=e.routes.at(-1);!t||t.sessionId!==U||b({sessionId:u.id,directory:u.directory})},se=[U,u,b],t[30]=U,t[31]=u,t[32]=b,t[33]=oe,t[34]=se):(oe=t[33],se=t[34]),Z.useEffect(oe,se);let ce;t[35]!==B||t[36]!==R||t[37]!==s?(ce=typeof s==`function`?s(R,B):s,t[35]=B,t[36]=R,t[37]=s,t[38]=ce):ce=t[38];let le=ce,ue;t[39]!==A||t[40]!==n||t[41]!==E?(ue=(0,$.jsx)(Oo,{onOpenChat:E,onAddProject:n,onNewSession:A}),t[39]=A,t[40]=n,t[41]=E,t[42]=ue):ue=t[42];let de;t[43]!==r||t[44]!==N?(de=(0,$.jsx)(fa,{onEnable:r,onOpenAssistant:N}),t[43]=r,t[44]=N,t[45]=de):de=t[45];let fe;t[46]===le?fe=t[47]:(fe=(0,$.jsx)(ko,{showHeader:!1,children:le}),t[46]=le,t[47]=fe);let pe;t[48]===i?pe=t[49]:(pe=(0,$.jsx)(Ao,{instancesPage:i}),t[48]=i,t[49]=pe);let q;t[50]!==ue||t[51]!==de||t[52]!==fe||t[53]!==pe?(q={projects:ue,assistant:de,scheduled:fe,settings:pe},t[50]=ue,t[51]=de,t[52]=fe,t[53]=pe,t[54]=q):q=t[54];let me=q,he=p.secondary?.kind??null,_e;bb0:{if(!he){_e=null;break bb0}if(he===`assistant`){let e;t[55]===f?e=t[56]:(e=f(`assistants.title`),t[55]=f,t[56]=e);let n;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(Cr,{activeOverride:!0,onMobileBack:Mo}),t[57]=n):n=t[57];let r;t[58]!==H||t[59]!==e?(r=[{key:`assistant-secondary`,depth:1,ariaLabel:e,onBack:H,content:n}],t[58]=H,t[59]=e,t[60]=r):r=t[60],_e=r;break bb0}if(p.secondary?.kind===`draft`){let e;t[61]===f?e=t[62]:(e=f(`mobile.nav.secondaryPageAria`),t[61]=f,t[62]=e);let n;t[63]===c?n=t[64]:(n=c({sessionId:``,directory:null,viewKey:`chat-primary`,active:!0}),t[63]=c,t[64]=n);let r;t[65]!==H||t[66]!==e||t[67]!==n?(r=[{key:`chat-primary`,depth:1,ariaLabel:e,onBack:H,content:n}],t[65]=H,t[66]=e,t[67]=n,t[68]=r):r=t[68],_e=r;break bb0}if(p.secondary?.kind!==`chat`){let e;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[69]=e):e=t[69],_e=e;break bb0}let e=p.secondary.routes,n;if(t[70]!==H||t[71]!==c||t[72]!==e||t[73]!==f){let r=e.slice(-2),i=e.length-r.length+1;n=r.map((e,t)=>{let n=t===r.length-1;return{key:e.key,depth:i+t,ariaLabel:f(`mobile.nav.secondaryPageAria`),onBack:H,content:c({sessionId:e.sessionId,directory:e.directory,viewKey:e.key,active:n})}}),t[70]=H,t[71]=c,t[72]=e,t[73]=f,t[74]=n}else n=t[74];_e=n}let ve=_e,be;t[75]===ve?be=t[76]:(be=ve??[],t[75]=ve,t[76]=be);let xe;return t[77]!==l||t[78]!==p||t[79]!==F||t[80]!==w||t[81]!==be||t[82]!==me?(xe=(0,$.jsx)(ha,{className:l,navigation:p,onTabChange:w,tabs:me,secondaryPages:be,tabBarCovered:F}),t[77]=l,t[78]=p,t[79]=F,t[80]=w,t[81]=be,t[82]=me,t[83]=xe):xe=t[83],xe}function Mo(){return Zt.requestAnimatedBack(`root`)}function No(e){return e.currentSessionId}function Po(e){return e.replaceChatSession}function Fo(e){return e.materializeDraftSession}function Io(e){return e.reconcileChatPredecessor}function Lo(e){return e.popChatSession}function Ro(e){return e.closeSecondary}function zo(e){return e.openAssistant}function Bo(e){return e.openDraft}function Vo(e){return e.openSession}function Ho(e){return e.setActiveTab}function Uo(e){let t=(0,Q.c)(19),{percentage:n}=e,r,i,a,o,s,c,l;if(t[0]!==n){a=wt(n)??0;let e=Ct(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 Wo(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=j(i),p=j(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)(Ie,{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 Go=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},Ko=e=>typeof e==`number`&&Number.isFinite(e)?e:0,qo=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),Jo=e=>e>=90?`text-[var(--status-error)]`:e>=75?`text-[var(--status-warning)]`:`text-[var(--status-success)]`,Yo=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:`${qo(t)}/${qo(n)}`,colorClass:Jo(i)}},Xo=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},Zo=e=>{for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role!==`assistant`||!n.tokens)continue;let r=Ko(n.tokens.input)+Ko(n.tokens.output)+Ko(n.tokens.reasoning)+Ko(n.tokens.cache?.read)+Ko(n.tokens.cache?.write);if(r>0)return r}return 0},Qo=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),$o=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`},es=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)(Y,{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},ts=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)(Y,{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)(Y,{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)(dt,{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=St(e.window.valueLabel,t),i=Et(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:J(`shrink-0 typography-ui-label font-semibold tabular-nums`,$o(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},ns=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=J(`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)(es,{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)(es,{iconNode:(0,$.jsx)(Uo,{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:J(`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)(ts,{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:Ss,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
|
-
@keyframes session-metadata-in {
|
|
7
|
-
from { opacity: 0; transform: translateY(-8px) scale(0.985); }
|
|
8
|
-
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
9
|
-
}
|
|
10
|
-
@keyframes session-metadata-out {
|
|
11
|
-
from { opacity: 1; transform: translateY(0) scale(1); }
|
|
12
|
-
to { opacity: 0; transform: translateY(-6px) scale(0.985); }
|
|
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 rs(e){let t=(0,Q.c)(91),{sessionId:n,open:r,onOpenChange:i}=e,{t:a}=ee(),{git:o}=Kt(),[s,c]=Z.useState(!1),l=r!==void 0,d=l?r:s,f=n.length===0,p;t[0]!==l||t[1]!==i||t[2]!==d?(p=e=>{let t=typeof e==`function`?e(d):e;l||c(t),i?.(t)},t[0]=l,t[1]=i,t[2]=d,t[3]=p):p=t[3];let m=j(p),h=w(xs),g;t[4]===n?g=t[5]:(g=e=>n?e.getDirectoryForSession(n):null,t[4]=n,t[5]=g);let _=K(g)||h,v;t[6]===_?v=t[7]:(v=Qo(_)||null,t[6]=_,t[7]=v);let y=v,b=se(n,_||void 0),x=bn(y),S=xn(y),C=vn(bs),T=vn(ys),E=V(vs),D=V(_s),O=V(gs),k=V(hs),A;t[8]===n?A=t[9]:(A=e=>n?e.sessionModelSelections.get(n)??null:null,t[8]=n,t[9]=A);let M=L(A),N=Rn(ms),P=Rn(ps),F=Rn(fs),I=Rn(ds),R=Rn(us),z=Rn(ls),B=Rn(cs),H=u(ss);kn();let te;t[10]===m?te=t[11]:(te=()=>{m(!1)},t[10]=m,t[11]=te);let ne;t[12]!==_||t[13]!==n?(ne=[n,_],t[12]=_,t[13]=n,t[14]=ne):ne=t[14],Z.useEffect(te,ne);let re,U;t[15]!==C||t[16]!==o||t[17]!==y?(re=()=>{y&&C(y,o)},U=[C,o,y],t[15]=C,t[16]=o,t[17]=y,t[18]=re,t[19]=U):(re=t[18],U=t[19]),Z.useEffect(re,U);let W,ie;t[20]!==T||t[21]!==o||t[22]!==y?(ie=()=>{if(y)return oe.onGitRefreshHint(e=>{Qo(e.directory)===y&&T(y,o)})},W=[T,o,y],t[20]=T,t[21]=o,t[22]=y,t[23]=W,t[24]=ie):(W=t[23],ie=t[24]),Z.useEffect(ie,W);let ae,G;t[25]===P?(ae=t[26],G=t[27]):(ae=()=>{P()},G=[P],t[25]=P,t[26]=ae,t[27]=G),Z.useEffect(ae,G);let ce,le;t[28]===z?(ce=t[29],le=t[30]):(ce=()=>{ut(z)},le=[z],t[28]=z,t[29]=ce,t[30]=le),Z.useEffect(ce,le);let ue,de;t[31]!==z||t[32]!==F||t[33]!==I||t[34]!==d||t[35]!==N?(ue=()=>{!d||I||z.some(e=>!N.some(t=>t.providerId===e))&&F()},de=[z,F,I,d,N],t[31]=z,t[32]=F,t[33]=I,t[34]=d,t[35]=N,t[36]=ue,t[37]=de):(ue=t[36],de=t[37]),Z.useEffect(ue,de);let fe;t[38]===b?fe=t[39]:(fe=Xo(b),t[38]=b,t[39]=fe);let pe=fe,q;if(t[40]!==b||t[41]!==O||t[42]!==D||t[43]!==k||t[44]!==f||t[45]!==pe||t[46]!==E||t[47]!==M){let e=pe??(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=Go(n?.limit,`context`)??r?.limit?.context??0,a;t[49]===b?a=t[50]:(a=Zo(b),t[49]=b,t[50]=a),q=Yo({totalTokens:a,contextLimit:i,isDraft:f}),t[40]=b,t[41]=O,t[42]=D,t[43]=k,t[44]=f,t[45]=pe,t[46]=E,t[47]=M,t[48]=q}else q=t[48];let me=q,he;t[51]!==S?.current||t[52]!==x||t[53]!==a?(he=x===!0?S?.current?.trim()||a(`gitView.branch.detachedHead`):a(`common.unavailable`),t[51]=S?.current,t[52]=x,t[53]=a,t[54]=he):he=t[54];let ge=he,_e;if(t[55]!==z||t[56]!==N||t[57]!==B||t[58]!==a){let e=new Map(N.map(os)),n;t[60]===z?n=t[61]:(n=e=>z.includes(e.id),t[60]=z,t[61]=n),_e=En.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:Dt(e),window:t});let i=Object.entries(n?.usage?.models??{}),o=B[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:Dt(i),subtitle:jn(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[55]=z,t[56]=N,t[57]=B,t[58]=a,t[59]=_e}else _e=t[59];let ve=_e,ye,be;t[62]!==d||t[63]!==ve?(ye=()=>{!d||ve.length===0||ut(ve.map(as))},be=[d,ve],t[62]=d,t[63]=ve,t[64]=ye,t[65]=be):(ye=t[64],be=t[65]),Z.useEffect(ye,be);let xe;t[66]===m?xe=t[67]:(xe=()=>{m(is)},t[66]=m,t[67]=xe);let Se=j(xe),Ce;t[68]===m?Ce=t[69]:(Ce=()=>{m(!1)},t[68]=m,t[69]=Ce);let we=j(Ce),Te;t[70]===a?Te=t[71]:(Te=a(`mobile.header.openMetadataAria`),t[70]=a,t[71]=Te);let Ee=me?.percentage??0,De;t[72]===Ee?De=t[73]:(De=(0,$.jsx)(Uo,{percentage:Ee}),t[72]=Ee,t[73]=De);let Oe;t[74]!==Se||t[75]!==d||t[76]!==Te||t[77]!==De?(Oe=(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsx)(X,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":Te,"aria-expanded":d,onClick:Se,children:De})}),t[74]=Se,t[75]=d,t[76]=Te,t[77]=De,t[78]=Oe):Oe=t[78];let ke;t[79]!==ge||t[80]!==me||t[81]!==we||t[82]!==I||t[83]!==d||t[84]!==R||t[85]!==H||t[86]!==ve?(ke=(0,$.jsx)(ns,{open:d,onClose:we,contextDisplay:me,branchLabel:ge,usageGroups:ve,usageDisplayMode:R,isUsageLoading:I,timeFormatPreference:H}),t[79]=ge,t[80]=me,t[81]=we,t[82]=I,t[83]=d,t[84]=R,t[85]=H,t[86]=ve,t[87]=ke):ke=t[87];let Ae;return t[88]!==Oe||t[89]!==ke?(Ae=(0,$.jsxs)($.Fragment,{children:[Oe,ke]}),t[88]=Oe,t[89]=ke,t[90]=Ae):Ae=t[90],Ae}function is(e){return!e}function as(e){return e.providerId}function os(e){return[e.providerId,e]}function ss(e){return e.timeFormatPreference}function cs(e){return e.selectedModels}function ls(e){return e.dropdownProviderIds}function us(e){return e.displayMode}function ds(e){return e.isLoading}function fs(e){return e.fetchAllQuotas}function ps(e){return e.loadSettings}function ms(e){return e.results}function hs(e){return e.getModelMetadata}function gs(e){return e.currentModelId}function _s(e){return e.currentProviderId}function vs(e){return e.providers}function ys(e){return e.fetchStatus}function bs(e){return e.ensureStatus}function xs(e){return e.currentDirectory}function Ss(e){e.stopPropagation()}function Cs(e){return e.sessionId?e.userRefreshInFlight?`syncing`:e.hasTranscript?null:!e.isConnected&&e.connectionPhase===`reconnecting`||e.loadStatus===`loading`?`syncing`:null:null}function ws(e,t){let n=(0,Q.c)(13),{t:r}=ee(),i=re(e,t),a=be(e,t),o=V(Ds),s=V(Es),c;n[0]!==t||n[1]!==e?(c=()=>he(e,t),n[0]=t,n[1]=e,n[2]=c):c=n[2];let l=(0,Z.useSyncExternalStore)(q,c,Ts),u=i?.status,d;n[3]!==s||n[4]!==a||n[5]!==o||n[6]!==e||n[7]!==u||n[8]!==l?(d=Cs({sessionId:e,hasTranscript:a,loadStatus:u,userRefreshInFlight:l,isConnected:o,connectionPhase:s}),n[3]=s,n[4]=a,n[5]=o,n[6]=e,n[7]=u,n[8]=l,n[9]=d):d=n[9];let f=d,p;return n[10]!==f||n[11]!==r?(p=f===`syncing`?r(`mobile.chat.syncingMessages`):null,n[10]=f,n[11]=r,n[12]=p):p=n[12],p}function Ts(){return!1}function Es(e){return e.connectionPhase}function Ds(e){return e.isConnected}function Os(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=Te(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,_=ws(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=j(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=j(S),w=d||v,T;t[11]===u?T=t[12]:(T=J(`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)(rs,{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)(Wo,{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=J(`mobile-chat-screen__content relative h-full min-h-0 flex-1`,`[&_[data-scrollbar=chat]>div]: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 ks=T(`BarcodeScanner`),As=`oc-barcode-scanner-active`,js=()=>Gs()?ks:null,Ms=()=>window.Capacitor?.getPlatform?.()===`android`,Ns=e=>typeof e==`object`&&e&&`message`in e?String(e.message??``):String(e??``),Ps=e=>/^\s*scan canceled\.?\s*$/i.test(Ns(e)),Fs=e=>/denied access to camera/i.test(Ns(e)),Is=e=>!Ps(e)&&!Fs(e),Ls=e=>{let t=Ns(e);return/module/i.test(t)&&/not\s*available|unavailable/i.test(t)},Rs=e=>{e.installGoogleBarcodeScannerModule?.().catch(()=>void 0)},zs=e=>{let t=e.trim();if(!t)return null;if(/^openchamber:\/\//i.test(t)){let e=hr(t);return e?{pairing:e}:null}return/^https?:\/\//i.test(t)?{url:t}:null},Bs=e=>{let t=zs(e);return t?`pairing`in t?{status:`pairing`,...t}:{status:`ok`,...t}:{status:`invalid`}},Vs=e=>{typeof document>`u`||document.documentElement.classList.toggle(As,e)},Hs=e=>{if(typeof document>`u`)return()=>void 0;let t=document.createElement(`button`);return t.type=`button`,t.className=`oc-barcode-scanner-chrome`,t.setAttribute(`aria-label`,`Cancel`),t.textContent=`×`,t.addEventListener(`click`,e),document.body.appendChild(t),()=>{t.removeEventListener(`click`,e),t.remove()}},Us=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))};Vs(!0);let c=Hs(()=>s({status:`cancelled`}));try{let{App:e}=await D(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])),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(Bs(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=>{Fs(e)?s({status:`permission-denied`}):s({status:`failed`})}),await o}finally{c(),r?.(),Vs(!1),await Promise.allSettled([Promise.resolve(t?.remove()),Promise.resolve(n?.remove()),e.stopScan()])}},Ws=e=>e.isNativePlatform&&e.isPluginAvailable,Gs=()=>Ws({isNativePlatform:E.isNativePlatform(),isPluginAvailable:E.isPluginAvailable(`BarcodeScanner`)}),Ks=async()=>{let e=js();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?Bs(n):{status:`cancelled`}}catch(t){return Ps(t)?{status:`cancelled`}:Fs(t)?{status:`permission-denied`}:Ms()&&Is(t)&&e.startScan?(Ls(t)&&Rs(e),Us(e)):{status:`failed`}}return Ms()&&e.startScan?Us(e):{status:`unsupported`}}catch{return{status:`failed`}}},qs={autoComplete:`off`,autoCorrect:`off`,spellCheck:!1},Js=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=zs(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=j(_),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`,{...qs,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)(X,{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},Ys=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 Xs(e){let t=(0,Q.c)(4),n=e===void 0?2500:e,{uiFont:r}=zn(),[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([ot(r).catch(tc),document.fonts?.ready?.then(ec).catch($s)??Promise.resolve(),Ar.catch(Qs)]).then(Zs),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 Zs(){}function Qs(){}function $s(){}function ec(){}function tc(){}var nc=e=>e.replace(/^\/+|\/+$/g,``),rc=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},ic=e=>{let t=nc(e.pathname).split(`/`).filter(Boolean);return e.host?[e.host,...t]:t};function ac(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=ic(t),r=(n[0]??``).toLowerCase(),i=n.slice(1),a=t.searchParams;switch(r){case`connect`:{let t=hr(e);return t?{type:`connect`,pairing:t}:null}case`session`:{let e=i[0]||a.get(`id`)||``;return e?{type:`session`,sessionId:e,directory:rc(a)}:null}case`new`:case`new-session`:{let e=a.get(`prompt`)?.trim();return{type:`new-session`,directory:rc(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=rc(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 oc={},sc=null,cc=!1,lc=null,uc=e=>{switch(e.type){case`connect`:return sc?(sc(e.pairing),!0):!1;case`session`:return Se()?(K.getState().setCurrentSession(e.sessionId,e.directory??null),!0):(ge.getState().openSession({sessionId:e.sessionId,directory:e.directory??null}),!0);case`new-session`:return Se()?(K.getState().openNewSessionDraft({directoryOverride:e.directory??null,selectedProjectId:e.projectId??null,preserveDirectoryOverride:!!e.directory,ensureProjectForDirectory:!!e.directory,initialPrompt:e.prompt}),!0):(ge.getState().openDraft({directoryOverride:e.directory??null,selectedProjectId:e.projectId??null,preserveDirectoryOverride:!!e.directory,ensureProjectForDirectory:!!e.directory,initialPrompt:e.prompt}),!0);case`open-project`:return Se()?(K.getState().openNewSessionDraft({directoryOverride:e.directory,preserveDirectoryOverride:!0}),!0):(ge.getState().openDraft({directoryOverride:e.directory,preserveDirectoryOverride:!0}),!0);case`sessions`:return oc.openSessions?(oc.openSessions(e.filter),!0):!1;case`status`:return oc.openSessions?(oc.openSessions(),!0):(u.getState().setMobileSessionPanelOpen(!0),!0);case`view`:return oc.openView?(oc.openView(e.target),!0):!1;case`changes`:return oc.openChanges?(oc.openChanges({path:e.path,staged:e.staged}),!0):!1;case`settings`:return oc.openSettings?(oc.openSettings(e.section),!0):!1}},dc=()=>{if(!lc||!cc&&lc.type!==`connect`)return;let e=lc;lc=null,uc(e)||(lc=e)},fc=e=>{lc=e,dc()},pc=e=>{let t=ac(e);t&&fc(t)},mc=e=>{cc=e,dc()},hc=e=>{let t=(0,Q.c)(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>(oc=e,dc(),()=>{oc===e&&(oc={})}),r=[e],t[0]=e,t[1]=n,t[2]=r),Z.useEffect(n,r)},gc=e=>{let t=(0,Q.c)(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>(sc=e,dc(),()=>{sc===e&&(sc=null)}),r=[e],t[0]=e,t[1]=n,t[2]=r),Z.useEffect(n,r)},_c=e=>{let{ready:t}=e,[n,r]=Z.useState(()=>I()?`pending`:`none`);return Z.useEffect(()=>{mc(t)},[t]),Z.useEffect(()=>{if(!I())return;let e=!1,t=[];return D(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])).then(async({App:n})=>{if(e)return;let i=await n.addListener(`appUrlOpen`,e=>{pc(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=ac(a?.url);r(o?.type===`connect`?`connect`:o?`other`:`none`),o&&fc(o)}).catch(()=>{e||r(`none`)}),D(async()=>{let{PushNotifications:e}=await import(`./vendor-capacitor-push-notifications-DB3-G2vL.js`).then(e=>e.t);return{PushNotifications:e}},__vite__mapDeps([3,1,2])).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){pc(n);return}let r=typeof t?.sessionId==`string`?t.sessionId:void 0;r&&fc({type:`session`,sessionId:r})});if(e){r.remove();return}t.push(()=>void r.remove())}).catch(()=>void 0),()=>{e=!0,t.forEach(e=>e())}},[]),n},vc=64,yc=.6,bc=28,xc=`[class*="code-block"], [class*="codeBlock"], pre, .cm-editor`,Sc=`[data-session-swipe-surface="true"]`,Cc=e=>e?e.matches(xc)||e.closest(xc)!==null:!1,wc=(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},Tc=e=>e.composerActive||e.onCodeBlock||e.withinHorizontalScroller||e.withinNativeBackEdge?!1:e.onExplicitSurface,Ec=e=>I()&&U()===`ios`&&e<=bc,Dc=e=>{let t=e.endX-e.startX,n=e.endY-e.startY,r=Math.abs(t);return r<vc||Math.abs(n)>r*yc?null:t<0?`next`:`prev`},Oc=(e,t)=>{let n=e.endX-e.startX,r=e.endY-e.startY,i=Math.abs(n);if(i<8||Math.abs(r)>i*yc)return null;let a=n<0?`next`:`prev`;return{direction:a,progress:Math.min(i/vc,1),offsetX:n,canSwitch:t[a]}},kc=e=>e.parentID??null,Ac=e=>e.time?.updated??e.time?.created??0,jc=()=>W.getState().activeSessions.filter(e=>kc(e)===null).slice().sort((e,t)=>Ac(t)-Ac(e)),Mc=()=>{let e=jc(),t=K.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}},Nc=(e,t)=>{if(K.getState().currentSessionId!==t.currentId)return!1;let n=e===`prev`?t.prevId:t.nextId;if(!n)return!1;let r=W.getState().activeSessions.find(e=>e.id===n);return r?(K.getState().setCurrentSession(r.id,we(r)),!0):!1},Pc=(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(Sc),f=i!==null&&(!i.classList.contains(`oc-mobile-composer-collapsed`)||i.contains(document.activeElement));if(f){n=!1;return}if(!Tc({onExplicitSurface:i!==null,onCodeBlock:Cc(r),withinHorizontalScroller:wc(r,!0),withinNativeBackEdge:Ec(t.clientX),composerActive:f})){n=!1;return}n=!0,a=t.clientX,o=t.clientY,s=Mc(),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&&xe(`light`,{bypassCadence:!0}),l=!1,u=!1,d&&i.current?.(null),d=!1;return}let t=e.touches[0],r=Oc({startX:a,startY:o,endX:t.clientX,endY:t.clientY},c);if(!r){l&&(l=!1,xe(`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=ce({thresholdReached:l,distance:s,enterDistance:vc,cancelDistance:56,available:r.canSwitch});l=f.thresholdReached,f.event===`enter`&&(u=xe(`medium`,{bypassCadence:!0})),f.event===`cancel`&&(xe(`light`,{bypassCadence:!0}),u=!1)},g=e=>{if(!n)return;n=!1;let t=e.changedTouches[0];if(!t){l&&xe(`light`,{bypassCadence:!0}),l=!1,u=!1,d&&i.current?.(null),d=!1;return}if(wc(document.elementFromPoint(t.clientX,t.clientY),!0)){l&&xe(`light`,{bypassCadence:!0}),l=!1,u=!1,d&&i.current?.(null),d=!1;return}let c=Dc({startX:a,startY:o,endX:t.clientX,endY:t.clientY});if(!c){l&&xe(`light`,{bypassCadence:!0}),l=!1,u=!1,d&&i.current?.(null),d=!1;return}Nc(c,s)?(u||xe(`medium`,{bypassCadence:!0}),f=!0,p!==null&&window.clearTimeout(p),p=window.setTimeout(()=>{f=!1,p=null},500),r.current?.(c)):l&&xe(`light`,{bypassCadence:!0}),l=!1,u=!1,d&&i.current?.(null),d=!1},_=()=>{n=!1,l&&xe(`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])},Fc=.85,Ic=8,Lc=.35,Rc=.22,zc=e=>({segmentStart:e,lastTouch:e,open:!1}),Bc=e=>e*Lc,Vc=e=>e*Rc,Hc=(e,t)=>Math.max(0,e-t),Uc=(e,t)=>Math.max(0,t-e),Wc=(e,t)=>{let n=Math.abs(e);return n<Ic||Math.abs(t)<=n*Fc},Gc=(e,t,n)=>{let r=t.clientX-e.segmentStart.clientX,i=t.clientY-e.segmentStart.clientY,a=Hc(e.segmentStart.clientX,t.clientX),o=Bc(n),s=Vc(n),c=e.open;return c=a<=0?!1:e.open?a>=s:a>=o&&Wc(r,i),{segmentStart:e.segmentStart,lastTouch:t,open:c}},Kc=e=>{if(e.disabled||e.startedOnExcludedTarget)return{open:!1,back:!1};let t=e.endX-e.startX,n=e.endY-e.startY,r=Hc(e.startX,e.endX),i=Uc(e.startX,e.endX),a=Bc(e.viewportWidth),o=Wc(t,n);return{open:r>=a&&o,back:i>=a&&o}},qc=(e,t,n)=>Math.min(Hc(e,t)/Math.max(1,Bc(n)),1),Jc=(e,t,n)=>Math.min(Uc(e,t)/Math.max(1,Bc(n)),1),Yc=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},Xc=e=>{let t=document.elementFromPoint(e.clientX,e.clientY);return!!t?.closest(`[data-session-swipe-surface="true"]`)||Yc(t)},Zc=1,Qc=(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===Zc?n:n.parentElement;return!!(r&&t.contains(r))},$c=e=>Qc(window.getSelection(),e),el=(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=Bc(g),n=ce({thresholdReached:p,distance:e,enterDistance:t,cancelDistance:Vc(g),available:!0});p=n.thresholdReached,n.event===`enter`&&(m=xe(`medium`,{bypassCadence:!0})),n.event===`cancel`&&(xe(`light`,{bypassCadence:!0}),m=!1)},y=e=>{o.current?.(null),p&&!e&&xe(`light`,{bypassCadence:!0}),p=!1,m=!1,e?r.current():f&&a.current?.(),f=!1},b=e=>{c.current?.(null),p&&!e&&xe(`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=Xc(r)||$c(t),d=null,f=!1,p=!1,m=!1,h=0,_=zc(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];_=Gc(_,r,g);let a=r.clientX-_.segmentStart.clientX,l=r.clientY-_.segmentStart.clientY;if(d===null){if($c(t))return;let e=Math.abs(a);if(e<Ic||Math.abs(l)>e*Fc)return;if(a<0)d=`sessions`,f=!0,i.current?.();else if(s.current)d=`back`;else return}e.preventDefault(),h=d===`sessions`?Hc(_.segmentStart.clientX,r.clientX):Uc(_.segmentStart.clientX,r.clientX),v(h),d===`sessions`?o.current?.(qc(_.segmentStart.clientX,r.clientX,g)):c.current?.(Jc(_.segmentStart.clientX,r.clientX,g))},C=e=>{if(!n||!_)return;if(n=!1,!d){_=null;return}let t=e.changedTouches[0];t&&(_=Gc(_,t,g),h=d===`sessions`?Hc(_.segmentStart.clientX,t.clientX):Uc(_.segmentStart.clientX,t.clientX),v(h));let r=d===`sessions`?_.open:Kc({startX:_.segmentStart.clientX,startY:_.segmentStart.clientY,endX:_.lastTouch.clientX,endY:_.lastTouch.clientY,viewportWidth:g,disabled:!1,startedOnExcludedTarget:!1}).back;_=null,e.preventDefault(),r&&!m&&xe(`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])},tl=()=>{if(typeof window>`u`)return!1;let e=window.Capacitor?.getPlatform?.();return e===`ios`||e===`android`},nl=e=>{let{enabled:t}=e,n=u(e=>e.nativeNotificationsEnabled),r=Z.useRef(null);Z.useEffect(()=>{if(!t||!n||!tl())return;let e=!1,i=[];return D(async()=>{let{PushNotifications:e}=await import(`./vendor-capacitor-push-notifications-DB3-G2vL.js`).then(e=>e.t);return{PushNotifications:e}},__vite__mapDeps([3,1,2])).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 a=await t.addListener(`registration`,e=>{r.current=e.value,_()?.push?.registerApnsToken?.({token:e.value,platform:U()})}),o=await t.addListener(`registrationError`,e=>{console.warn(`[Push] APNs registration error:`,e)});if(await t.register().catch(()=>void 0),e){a.remove(),o.remove();return}i.push(()=>void a.remove(),()=>void o.remove())}).catch(()=>void 0),()=>{e=!0,i.forEach(e=>e())}},[t,n]),Z.useEffect(()=>{if(n)return;let e=r.current;e&&(r.current=null,_()?.push?.unregisterApnsToken?.({token:e}))},[n])},rl=`mobile-direct-diff`,il=`mobile-turn-diff`,al=`mobile-direct-file`,ol=`mobile-overflow-menu`,sl=320,cl=380,ll=280,ul=560,dl=380,fl=e=>Math.min(ul,Math.max(ll,Math.round(e))),pl=(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 ml(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(ul,Math.max(ll,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=j(m),g;r[5]===e?g=r[6]:(g=t=>{if(p.current!==t.pointerId)return;let n=t.clientX-u.current,r=fl(d.current+(e===`left`?n:-n));f.current!==r&&(f.current=r,pl(i,r))},r[5]=e,r[6]=g);let _=j(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=fl(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=j(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 hl=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=J(`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=J(`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},gl=()=>typeof window>`u`?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`,_l=()=>{Z.useEffect(()=>{if(!gl())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 D(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([4,1,2])).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?`#171515`:`#fffdf4`);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 D(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])),c=await s.addListener(`appStateChange`,({isActive:e})=>{e&&a()});if(e){c.remove();return}t.push(()=>void c.remove())}).catch(()=>void 0),D(async()=>{let{Keyboard:e}=await import(`./vendor-capacitor-keyboard-BkRQ-Kv-.js`).then(e=>e.t);return{Keyboard:e}},__vite__mapDeps([5,1,2])).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&&!Qr(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)&&!Qr(e))},x=e=>Qr(e),S=()=>{for(let e of document.querySelectorAll(`.oc-mobile-composer, .oc-draft-center`))e.style.transition=``,e.style.transform=``,e.style.willChange=``},C=()=>{let e=document.querySelector(`.oc-mobile-app-shell`);d=e&&parseFloat(getComputedStyle(e).paddingBottom)||0};if(a){let i=`openchamber.androidImeHeightRatio.v1`,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.willChange=`transform`,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=``,e.style.willChange=``},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)&&document.activeElement.blur();return}let t=g||m,i=c;f=!1,c=!1,g=0,e&&l(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(Qr(e.target)){k(e.target,`focus`);return}O(g||m)}},M=e=>{if(l(e.target)&&!ei(e.relatedTarget)){if($r(e.relatedTarget)){h(`oc:keyboard-intent`,{open:!1}),O(g||m);return}A(!1)}},ee=e=>{let t=e,n=t.detail??t;if(n?.open===!0){let e=Math.max(0,Math.round(n.height??0)),t=ti(c,document.activeElement);e>0&&(t===`open`||t===`cache`)&&_(e),t===`open`&&k(document.activeElement,`ime`),t===`field`&&O(e||m)}n?.open===!1&&A(!0)},N=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`,ee),window.addEventListener(`oc:keyboard-intent`,N),e){w(),document.removeEventListener(`focusin`,j,!0),document.removeEventListener(`focusout`,M,!0),window.removeEventListener(`oc:ime-state`,ee),window.removeEventListener(`oc:keyboard-intent`,N);return}t.push(w,()=>document.removeEventListener(`focusin`,j,!0),()=>document.removeEventListener(`focusout`,M,!0),()=>window.removeEventListener(`oc:ime-state`,ee),()=>window.removeEventListener(`oc:keyboard-intent`,N));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,t)=>{C();let n=Math.max(0,e-d);for(let{el:e,factor:r}of v(t))e.style.willChange=`transform`,e.style.transition=`transform 250ms ${o}`,e.style.transform=`translateY(${-n*r}px)`;return n},k=e=>{if(e.detail?.open!==!0||u||y(document.activeElement)&&!Qr(document.activeElement))return;f=!0,n.classList.remove(`oc-kb-hide`),n.classList.add(`oc-keyboard-open`,`oc-kb-animating`,`oc-kb-caret-hold`);let t=l>0?l:E(),r=O(t,e.target);h(`oc:keyboard-anim`,{phase:`show`,slide:r,durationMs:250,easing:o})};window.addEventListener(`oc:keyboard-intent`,k);let A=await i.addListener(`keyboardWillShow`,e=>{m(),l=e.keyboardHeight,D(l);let t=Qr(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),n.classList.add(`oc-keyboard-open`),r(l),!t){p(`--oc-kb-layout`,0),C(),p(`--oc-kb-scroll-inset`,Math.max(0,l-d)),n.classList.remove(`oc-keyboard-open`),S(),u=!1,h(`oc:keyboard-settled`,{open:!0});return}u||C();let i=Math.max(0,l-d);n.classList.add(`oc-kb-animating`,`oc-kb-caret-hold`);for(let{el:e,factor:t}of v())e.style.transition=`transform 250ms ${o}`,e.style.transform=`translateY(${-i*t}px)`;p(`--oc-kb-scroll-inset`,i),h(`oc:keyboard-settled`,{open:!0}),h(`oc:keyboard-anim`,{phase:`show`,slide:i,durationMs:250,easing:o}),s=window.setTimeout(()=>{s=null,n.classList.remove(`oc-kb-animating`),p(`--oc-kb-layout`,l),u=!0,S(),h(`oc:keyboard-settled`,{open:!0}),c=window.setTimeout(()=>{c=null,n.classList.remove(`oc-kb-caret-hold`)},250)},270)}),j=()=>{let e=document.activeElement;e instanceof HTMLElement&&(e.tagName!==`TEXTAREA`&&e.tagName!==`INPUT`&&!e.isContentEditable||e.blur())},M=()=>{if(!f)return;f=!1,m(),j(),h(`oc:keyboard-intent`,{open:!1}),c!==null&&(window.clearTimeout(c),c=null),n.classList.remove(`oc-kb-caret-hold`);let e=Math.max(0,l-d);if(n.classList.remove(`oc-keyboard-open`),r(0),p(`--oc-kb-scroll-inset`,0),u){n.classList.remove(`oc-kb-animating`),p(`--oc-kb-layout`,0),u=!1;for(let{el:t,factor:n}of v())t.style.transition=`none`,t.style.transform=`translateY(${-e*n}px)`;document.querySelector(`.oc-mobile-app-shell`)?.offsetHeight}h(`oc:keyboard-anim`,{phase:`hide`,slide:e,durationMs:200,easing:o}),n.classList.add(`oc-kb-animating`,`oc-kb-hide`);for(let{el:e}of v())e.style.transition=`transform 200ms ${o}`,e.style.transform=`translateY(0px)`;s=window.setTimeout(()=>{s=null,n.classList.remove(`oc-kb-animating`,`oc-kb-hide`),S(),h(`oc:keyboard-settled`,{open:!1})},220)},ee=await i.addListener(`keyboardWillHide`,M),N=e=>e instanceof HTMLElement&&(e.tagName===`TEXTAREA`||e.tagName===`INPUT`||e.isContentEditable),P=e=>{if(f&&N(e.target)){if(ei(e.relatedTarget)){p(`--oc-kb-scroll-inset`,0);return}window.setTimeout(()=>{if(f&&!Qr(document.activeElement)){if(N(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}M()}},0)}};if(document.addEventListener(`focusout`,P,!0),e){m(),document.removeEventListener(`focusout`,P,!0),window.removeEventListener(`oc:keyboard-intent`,k),A.remove(),ee.remove();return}t.push(m,()=>{c!==null&&(window.clearTimeout(c),c=null)},()=>document.removeEventListener(`focusout`,P,!0),()=>window.removeEventListener(`oc:keyboard-intent`,k),()=>void A.remove(),()=>void ee.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`)}},[])},vl=e=>{let t=Z.useRef(!1);Z.useEffect(()=>{if(!gl())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)),D(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])).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])},yl=e=>{Z.useEffect(()=>{if(!gl())return;let t=!1,n=null;return D(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])).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])},bl=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),xl={autoComplete:`off`,autoCorrect:`off`,spellCheck:!1},Sl=1e3,Cl=e=>{let t=bl(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},wl=(e,t)=>Cl(e?e.path:t),Tl=`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`,El=({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(()=>Gs(),[]),[_,v]=Z.useState(()=>!Gs()),[y,b]=Z.useState(null),[x,S]=Z.useState(``),C=j(e=>{e.preventDefault(),n.connect({url:c,clientToken:f,label:u})}),w=j(e=>{n.redeemPairingConnection(e)}),T=j(()=>{n.setError(t(`mobile.connect.link.invalid`))}),E=j(async()=>{if(!(m||i)){n.setError(null),h(!0);try{let e=await Ks();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=j(e=>{e.preventDefault(),n.submitPassword(x)}),O=j(()=>{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)(At,{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)(Y,{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`)?Ae(s):t(`mobile.connect.relay.badge`)})]})]}),(0,$.jsx)(`input`,{...xl,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)(X,{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)(X,{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)(X,{type:`button`,size:`lg`,className:`h-12 w-full`,onClick:()=>void E(),disabled:m||i,children:[(0,$.jsx)(Y,{name:`scan-2`,className:J(`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)(Y,{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:J(`block truncate typography-small`,r?`text-foreground`:`text-muted-foreground`),children:r?t(`mobile.connect.connecting`):e.candidates.some(e=>e.kind===`direct`)?Ae(e):t(`mobile.connect.relay.badge`)})]}),r?(0,$.jsx)(Y,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):(0,$.jsx)(Y,{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)(Y,{name:`arrow-down-s`,className:J(`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)(Js,{disabled:i||m,isBusy:i,tabIndex:_?void 0:-1,inputClassName:Tl,buttonVariant:g?`outline`:`default`,onRedeem:w,onInvalid:T})}),(0,$.jsx)(Ys,{label:t(`mobile.connect.address.divider`)}),(0,$.jsxs)(`form`,{className:`flex w-full flex-col gap-3`,onSubmit:C,children:[(0,$.jsx)(`input`,{...xl,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:Tl}),(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:Tl}),(0,$.jsx)(`input`,{...xl,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:Tl}),(0,$.jsx)(`p`,{className:`px-1 text-center typography-micro text-muted-foreground`,children:t(`mobile.connect.token.hint`)}),(0,$.jsx)(X,{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]})})]})]})]})})},Dl=({connection:e,onActiveConnectionDeleted:t,onConnect:n})=>{let{t:r}=ee(),i=e,{connections:a,isBusy:s,isPasswordBusy:c,error:l,pendingConnection:u,connect:d,submitPassword:f,cancelPassword:p,saveConnection:m,removeConnection:h,subscribeConnected:g,setError:_}=i,[v,y]=Z.useState(null),b=v?a.find(e=>e.id===v)??null:null,[x,S]=Z.useState(null),[C,w]=Z.useState(``),[T,E]=Z.useState(``),[D,O]=Z.useState(``),[k,A]=Z.useState(``),[M,N]=Z.useState(!1),P=Z.useMemo(()=>Gs(),[]),[F,I]=Z.useState(!1),[L,R]=Z.useState(null),z=j(n);Z.useEffect(()=>g(z),[z,g]);let B=j(()=>{y(null),w(``),E(``),O(``),_(null),I(!1)}),V=j(e=>{e.preventDefault(),m({id:v??void 0,url:C,label:T,clientToken:D}).then(e=>{e&&B()})}),H=j(e=>{i.redeemPairingConnection(e)}),te=j(()=>{_(r(`mobile.connect.link.invalid`))}),ne=j(async()=>{if(!M){_(null),N(!0);try{let e=await Ks();switch(e.status){case`ok`:w(e.url),e.label&&E(e.label),e.clientToken&&O(e.clientToken),I(!0);break;case`pairing`:await i.redeemPairingConnection(e.pairing);break;case`permission-denied`:_(r(`mobile.connect.scan.permissionDenied`));break;case`invalid`:_(r(`mobile.connect.scan.invalid`));break;case`unsupported`:_(r(`mobile.connect.scan.unsupported`));break;case`failed`:_(r(`mobile.connect.scan.failed`))}}finally{N(!1)}}}),re=j(e=>{e.preventDefault(),f(k)}),U=j(()=>{A(``),p()}),W=j(e=>{S(t=>t===e?null:e)}),ie=j(e=>{S(null),v===e&&B();let n=a.length===1;h(e).then(e=>{e&&(n||Oe(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 u?(0,$.jsx)(`div`,{className:`oc-settings-page-content`,children:(0,$.jsx)(wn,{label:r(`mobile.connect.password.label`),itemId:`instances.manage`,children:(0,$.jsxs)(`form`,{className:`oc-settings-group-row flex flex-col gap-3`,onSubmit:re,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)(Y,{name:`lock`,className:`size-[18px]`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`truncate typography-ui-label text-foreground`,children:u.label}),(0,$.jsx)(`p`,{className:`truncate typography-small text-muted-foreground`,children:u.candidates.some(e=>e.kind===`direct`)?Ae(u):r(`mobile.connect.relay.badge`)})]})]}),(0,$.jsx)(`input`,{...xl,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}),l?(0,$.jsx)(`p`,{className:`px-1 typography-small text-[var(--status-error)]`,children:l}):null,(0,$.jsx)(X,{type:`submit`,size:`lg`,className:`mt-1 h-12 w-full`,disabled:c||!k.trim(),children:r(c?`mobile.connect.connecting`:`mobile.connect.unlockButton`)}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`sm`,className:`w-full`,onClick:U,children:r(`mobile.connect.cancelPassword`)})]})})}):(0,$.jsxs)(`div`,{className:`oc-settings-page-content`,children:[(0,$.jsx)(wn,{label:r(`mobile.connect.saved.title`),itemId:`instances.manage`,children:a.length>0?a.map(e=>{let t=x===e.id,n=Oe(e),i=L===e.id,a=i?r(`mobile.connect.connecting`):n?o()?r(`mobile.instances.status.connectedRelay`):r(`mobile.instances.status.connectedDirect`):e.candidates.some(e=>e.kind===`direct`)?Ae(e):r(`mobile.connect.relay.badge`);return(0,$.jsxs)(`div`,{className:J(`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||(R(e.id),d({id:e.id,candidates:e.candidates,clientToken:e.clientToken,label:e.label}).finally(()=>R(null)))},disabled:n||s&&!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,$.jsxs)(`span`,{className:`relative flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground`,children:[(0,$.jsx)(Y,{name:`server`,className:`size-[18px]`}),n?(0,$.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-[var(--surface-elevated)] bg-[var(--status-success)]`,"aria-hidden":!0}):null]}),(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:J(`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)(Y,{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)(Y,{name:`loader-4`,className:`size-[18px] animate-spin`})}):e.candidates.some(e=>e.kind===`direct`)?(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:()=>{y(e.id),w(Ae(e)),E(e.label),O(e.clientToken||``),_(null)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Y,{name:`edit`,className:`size-[18px]`})}):null,(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:()=>W(e.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(Y,{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)(wn,{label:r(b?`mobile.instances.editTitle`:`mobile.instances.addTitle`),children:!F&&!b?(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex flex-col items-stretch gap-2`,children:[P?(0,$.jsxs)(X,{type:`button`,size:`lg`,className:`h-12 w-full`,onClick:()=>void ne(),disabled:M,children:[(0,$.jsx)(Y,{name:`scan-2`,className:J(`size-[18px]`,M&&`animate-pulse`)}),r(`mobile.connect.scanQr`)]}):null,(0,$.jsxs)(X,{type:`button`,variant:P?`ghost`:`outline`,size:`lg`,className:`h-12 w-full`,onClick:()=>{_(null),I(!0)},children:[(0,$.jsx)(Y,{name:`add`,className:`size-[18px]`}),r(`mobile.instances.addManual`)]}),l?(0,$.jsx)(`p`,{className:`px-1 text-center typography-small text-[var(--status-error)]`,children:l}):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)(X,{type:`button`,variant:`ghost`,size:`xs`,onClick:B,children:r(`mobile.instances.cancelEdit`)})}),(0,$.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:V,children:[(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`,{...xl,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`,{...xl,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)(X,{type:`submit`,size:`lg`,className:`mt-1 h-12 w-full`,children:r(b?`mobile.instances.saveEdit`:`mobile.instances.saveNew`)})]}),b?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ys,{label:r(`mobile.connect.link.divider`)}),(0,$.jsx)(Js,{disabled:s||M,isBusy:s,inputClassName:ae,onRedeem:H,onInvalid:te})]}),l?(0,$.jsx)(`p`,{className:`px-1 typography-small text-[var(--status-error)]`,children:l}):null]})})]})},Ol=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`},kl=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)(Y,{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},Al=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`)?(_=Se(),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-dl-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 k,A;if(t[14]!==i||t[15]!==r||t[16]!==n?(k=()=>{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)}},A=[i,r,n],t[14]=i,t[15]=r,t[16]=n,t[17]=k,t[18]=A):(k=t[17],A=t[18]),Z.useEffect(k,A),!p)return null;let j;t[19]===d?j=t[20]:(j=d(`mobile.header.openMetadataAria`),t[19]=d,t[20]=j);let M=w?`absolute origin-top-left`:`mx-3 mt-2`,N=h?`pointer-events-none`:`pointer-events-auto`,P;t[21]!==M||t[22]!==N?(P=J(`overflow-y-auto overscroll-contain rounded-[20px] oc-mobile-overlay-surface p-2 will-change-transform`,M,N),t[21]=M,t[22]=N,t[23]=P):P=t[23];let F=`${h?`session-metadata-out`:`session-metadata-in`} ${h?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,I;t[24]!==b||t[25]!==w?(I=w?{top:8,left:b??8,width:`min(${dl}px, calc(100% - 16px))`}:null,t[24]=b,t[25]=w,t[26]=I):I=t[26];let L;t[27]!==F||t[28]!==I?(L={animation:F,maxHeight:`min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))`,...I},t[27]=F,t[28]=I,t[29]=L):L=t[29];let R;t[30]===d?R=t[31]:(R=d(`mobile.header.metadata.branch`),t[30]=d,t[31]=R);let z;t[32]!==o||t[33]!==R?(z=(0,$.jsx)(kl,{icon:`git-branch`,label:R,children:o}),t[32]=o,t[33]=R,t[34]=z):z=t[34];let B;t[35]!==a||t[36]!==d?(B=a?(0,$.jsx)(kl,{iconNode:(0,$.jsx)(Uo,{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:J(`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]=B):B=t[37];let V;t[38]!==l||t[39]!==u||t[40]!==c||t[41]!==s?(V=(0,$.jsx)(jl,{groups:s,displayMode:c,isLoading:l,timeFormatPreference:u}),t[38]=l,t[39]=u,t[40]=c,t[41]=s,t[42]=V):V=t[42];let H;t[43]!==z||t[44]!==B||t[45]!==V?(H=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[z,B,V]}),t[43]=z,t[44]=B,t[45]=V,t[46]=H):H=t[46];let te;t[47]!==j||t[48]!==P||t[49]!==L||t[50]!==H?(te=(0,$.jsx)(`div`,{ref:f,role:`dialog`,"aria-label":j,className:P,style:L,children:H}),t[47]=j,t[48]=P,t[49]=L,t[50]=H,t[51]=te):te=t[51];let ne;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(`style`,{children:`
|
|
15
|
-
@keyframes session-metadata-in {
|
|
16
|
-
from { opacity: 0; transform: translateY(-8px) scale(0.985); }
|
|
17
|
-
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
18
|
-
}
|
|
19
|
-
@keyframes session-metadata-out {
|
|
20
|
-
from { opacity: 1; transform: translateY(0) scale(1); }
|
|
21
|
-
to { opacity: 0; transform: translateY(-6px) scale(0.985); }
|
|
22
|
-
}
|
|
23
|
-
`}),t[52]=ne):ne=t[52];let re;return t[53]===te?re=t[54]:(re=(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:[te,ne]}),t[53]=te,t[54]=re),re},jl=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)(Y,{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)(Y,{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)(dt,{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=St(e.window.valueLabel,t),i=Et(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:J(`shrink-0 typography-ui-label font-semibold tabular-nums`,Ol(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},Ml=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:J(`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)(Y,{name:e.icon,className:J(`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:ol,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:Ll,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},Nl=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:d}=ee(),{git:f}=Kt(),p=ws(i??``,a||void 0),m=p??l,h=Z.useRef(null),g=se(i??``,a||void 0),_=bn(o),v=xn(o),y=vn(Rl),b=vn(zl),x=V(Bl),S=V(Vl),C=V(Hl),w=V(Ul),T;t[0]===i?T=t[1]:(T=e=>i?e.sessionModelSelections.get(i)??null:null,t[0]=i,t[1]=T);let E=L(T),D=Rn(Wl),O=Rn(Gl),k=Rn(Kl),A=Rn(ql),j=Rn(Jl),M=Rn(Yl),N=Rn(Xl),P=u(Zl);kn();let F,I;t[2]!==y||t[3]!==f||t[4]!==o?(F=()=>{o&&y(o,f)},I=[y,f,o],t[2]=y,t[3]=f,t[4]=o,t[5]=F,t[6]=I):(F=t[5],I=t[6]),Z.useEffect(F,I);let R,z;t[7]!==b||t[8]!==f||t[9]!==o?(R=()=>{if(o)return oe.onGitRefreshHint(e=>{bl(e.directory)===o&&b(o,f)})},z=[b,f,o],t[7]=b,t[8]=f,t[9]=o,t[10]=R,t[11]=z):(R=t[10],z=t[11]),Z.useEffect(R,z);let B,H;t[12]===O?(B=t[13],H=t[14]):(B=()=>{O()},H=[O],t[12]=O,t[13]=B,t[14]=H),Z.useEffect(B,H);let te,ne;t[15]===M?(te=t[16],ne=t[17]):(te=()=>{ut(M)},ne=[M],t[15]=M,t[16]=te,t[17]=ne),Z.useEffect(te,ne);let re,U;t[18]!==M||t[19]!==k||t[20]!==A||t[21]!==n||t[22]!==D?(re=()=>{!n||A||M.some(e=>!D.some(t=>t.providerId===e))&&k()},U=[M,k,A,n,D],t[18]=M,t[19]=k,t[20]=A,t[21]=n,t[22]=D,t[23]=re,t[24]=U):(re=t[23],U=t[24]),Z.useEffect(re,U);let W;t[25]===g?W=t[26]:(W=Xo(g),t[25]=g,t[26]=W);let ie=W,ae;if(t[27]!==g||t[28]!==C||t[29]!==S||t[30]!==w||t[31]!==s||t[32]!==ie||t[33]!==x||t[34]!==E){let e=ie??(E?{providerID:E.providerId,modelID:E.modelId}:null)??(S&&C?{providerID:S,modelID:C}:null),n=(e?x.find(t=>t.id===e.providerID):void 0)?.models.find(t=>t.id===e?.modelID),r=e?w(e.providerID,e.modelID):void 0,i=Go(n?.limit,`context`)??r?.limit?.context??0,a;t[36]===g?a=t[37]:(a=Zo(g),t[36]=g,t[37]=a),ae=Yo({totalTokens:a,contextLimit:i,isDraft:s}),t[27]=g,t[28]=C,t[29]=S,t[30]=w,t[31]=s,t[32]=ie,t[33]=x,t[34]=E,t[35]=ae}else ae=t[35];let G=ae,ce;t[38]!==v?.current||t[39]!==_||t[40]!==d?(ce=_===!0?v?.current?.trim()||d(`gitView.branch.detachedHead`):d(`common.unavailable`),t[38]=v?.current,t[39]=_,t[40]=d,t[41]=ce):ce=t[41];let le=ce,ue;if(t[42]!==M||t[43]!==D||t[44]!==N||t[45]!==d){let e=new Map(D.map(Ql)),n;t[47]===M?n=t[48]:(n=e=>M.includes(e.id),t[47]=M,t[48]=n),ue=En.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:Dt(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:Dt(i),subtitle:jn(e),window:a})}let s=!n.ok&&n.error?n.error:r.length===0?d(`header.services.noRateLimitsReported`):null;return{providerId:t.id,providerName:t.name,rows:r,status:s}}),t[42]=M,t[43]=D,t[44]=N,t[45]=d,t[46]=ue}else ue=t[46];let de=ue,fe,pe;t[49]!==n||t[50]!==de?(fe=()=>{!n||de.length===0||ut(de.map($l))},pe=[n,de],t[49]=n,t[50]=de,t[51]=fe,t[52]=pe):(fe=t[51],pe=t[52]),Z.useEffect(fe,pe);let K;t[53]===c?K=t[54]:(K=(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:c}),t[53]=c,t[54]=K);let q;t[55]!==m||t[56]!==p?(q=m?(0,$.jsx)(`span`,{className:J(`block truncate`,p?`oc-mobile-detail-subtitle text-muted-foreground`:`typography-micro text-muted-foreground`),"aria-live":`polite`,children:m}):null,t[55]=m,t[56]=p,t[57]=q):q=t[57];let me;t[58]!==K||t[59]!==q?(me=(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:[K,q]})}),t[58]=K,t[59]=q,t[60]=me):me=t[60];let he;t[61]===d?he=t[62]:(he=d(`mobile.header.openMetadataAria`),t[61]=d,t[62]=he);let ge;t[63]===r?ge=t[64]:(ge=()=>r(eu),t[63]=r,t[64]=ge);let _e;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(_e={touchAction:`manipulation`},t[65]=_e):_e=t[65];let ve=G?.percentage??0,ye;t[66]===ve?ye=t[67]:(ye=(0,$.jsx)(Uo,{percentage:ve}),t[66]=ve,t[67]=ye);let be;t[68]!==n||t[69]!==he||t[70]!==ge||t[71]!==ye?(be=(0,$.jsx)(`button`,{ref:h,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":he,"aria-expanded":n,onClick:ge,style:_e,children:ye}),t[68]=n,t[69]=he,t[70]=ge,t[71]=ye,t[72]=be):be=t[72];let xe;t[73]===r?xe=t[74]:(xe=()=>r(!1),t[73]=r,t[74]=xe);let Se;t[75]!==le||t[76]!==G||t[77]!==A||t[78]!==n||t[79]!==j||t[80]!==xe||t[81]!==P||t[82]!==de?(Se=(0,$.jsx)(Al,{open:n,onClose:xe,anchorRef:h,contextDisplay:G,branchLabel:le,usageGroups:de,usageDisplayMode:j,isUsageLoading:A,timeFormatPreference:P}),t[75]=le,t[76]=G,t[77]=A,t[78]=n,t[79]=j,t[80]=xe,t[81]=P,t[82]=de,t[83]=Se):Se=t[83];let Ce;return t[84]!==me||t[85]!==be||t[86]!==Se?(Ce=(0,$.jsxs)($.Fragment,{children:[me,be,Se]}),t[84]=me,t[85]=be,t[86]=Se,t[87]=Ce):Ce=t[87],Ce}),Pl=({onOpenSessions:e,menuOpen:t,onToggleMenu:n,surfaceShortcuts:r})=>{let{t:i}=ee(),[a,o]=Z.useState(!1),s=w(e=>e.currentDirectory),c=K(e=>e.currentSessionId),l=Z.useMemo(()=>e=>c?e.getDirectoryForSession(c):null,[c]),u=K(l)||s,d=bl(u)||null,f=G(e=>e.projects),p=K(e=>e.availableWorktreesByProject),m=Z.useMemo(()=>e=>c?e.worktreeMetadata.get(c)??null:null,[c]),h=K(m),g=Te(c),_=K(e=>!!e.newSessionDraft?.open),v=Z.useMemo(()=>{let e=bl(u);return e&&wl((h?.projectDirectory?ie(f,h.projectDirectory):null)??R(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=j(()=>{o(!1),e()}),S=j(()=>{o(!1),n()});return(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(Xr,{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)(Y,{name:`folders`,className:`size-5`})}),(0,$.jsx)(Nl,{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:J(`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)(Y,{name:`file-text`,className:`size-5`})}),(0,$.jsxs)(`button`,{type:`button`,className:J(`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)(Y,{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":ol,"aria-expanded":t,"aria-haspopup":`menu`,onClick:S,style:{touchAction:`manipulation`},children:(0,$.jsx)(Y,{name:`more-2`,className:`size-5`})})]})})},Fl=({connection:e,onActiveConnectionDeleted:t})=>{let{t:n}=ee(),r=Ut();ve(),me();let i=u(e=>e.mobileSessionPanelOpen),a=u(e=>e.setMobileSessionPanelOpen),o=u(e=>e.isScheduledTasksDialogOpen),s=u(e=>e.activeMainTab),c=Fe(),l=u(e=>e.setActiveMainTab),[d,f]=Z.useState(!1),[p,m]=Z.useState(!1),[h,g]=Z.useState(null),[_,v]=Z.useState(!1),[y,b]=Z.useState(!1),[x,S]=Z.useState(null),[C,T]=Z.useState(null),[E,D]=Z.useState(!1),[O,k]=Z.useState(!1),[M,N]=Z.useState(!1),[P,F]=Z.useState(!1),[I,L]=Z.useState(!1),[R,z]=Z.useState(`nav`),[V,H]=Z.useState(!1),[te,ne]=Z.useState(!1),re=j(()=>H(e=>!e)),U=j(()=>H(!1)),[W,ie]=Z.useState(null),G=w(e=>e.currentDirectory),se=u(e=>e.setSettingsPage),ce=Cn(e=>e.available),le=Cn(e=>e.runtimeType),ue=Z.useMemo(()=>gl(),[]),{data:de=[],refetch:fe}=Tn(G??null,{enabled:E}),{refetch:pe}=Dn(G??null,{enabled:E}),q=pr(e=>e.setMcpDraft),he=pr(e=>e.setSelectedMcp),_e=xn(bl(G)||null)?.files?.length??0;Z.useEffect(()=>oe.onDirectoryRequest(()=>L(!0)),[]);let ye=Z.useMemo(()=>Se(),[]),be=Ft()===`portrait`,[xe,Ce]=Z.useState(ye&&!be),[we,Te]=Z.useState(null),Ee=j(e=>{if(e&&se(e),ye){z(e?`page-content`:`nav`),N(!0);return}ge.getState().setActiveTab(`settings`)}),De=j(()=>{Ee(`instances`)});Yt({enabled:!ye,rootRoutesBlocked:i||d||p||_||y||o||E||M||P||I||V});let Oe=j(()=>{let e=!xe;e&&be&&Te(null),Ce(e)}),ke=j(()=>{if(b(!1),S(null),T(null),m(!1),g(null),ye){ie(null),Te(`files`),be&&Ce(!1);return}f(!0)}),Ae=j(()=>{m(!1),g(null)}),je=j(e=>{let t=e.path.trim();if(t){if(b(!1),S(null),T(null),ie(null),v(!1),ye){u.getState().setPendingFileFocusPath(t),Te(`files`),be&&Ce(!1);return}f(!1),g({path:t,targetLine:typeof e.targetLine==`number`&&Number.isFinite(e.targetLine)?Math.max(1,Math.trunc(e.targetLine)):void 0}),m(!0)}}),Me=u(e=>e.pendingFileFocusPath);Z.useEffect(()=>{if(Me){if(ye){ke();return}je({path:Me}),u.getState().setPendingFileFocusPath(null)}},[Me,ye,ke,je]);let Ne=j((e=null)=>{if(b(!1),S(null),T(null),m(!1),g(null),ie(e),ye){Te(`changes`),be&&Ce(!1);return}v(!0)}),Pe=j((e,t)=>{if(ie(null),v(!1),m(!1),g(null),S(e??null),T(typeof t==`string`&&t.trim()?t.trim():null),ye){Te(`turn-diff`),be&&Ce(!1);return}b(!0)}),Ie=j(()=>{Te(null),ie(null)}),Le=j(e=>{if(we===e){Ie();return}e===`files`?ke():Ne()}),Re=Z.useRef(`changes`);we&&(Re.current=we);let[ze,Be]=Z.useState(!1);Z.useEffect(()=>{if(!ye)return;if(we){Be(!0);return}let e=window.setTimeout(()=>Be(!1),240);return()=>window.clearTimeout(e)},[we,ye]);let Ve=we??Re.current,He=ml(`left`,`openchamber.ipad.leftSidebarWidth`,sl),Ue=ml(`right`,`openchamber.ipad.rightSidebarWidth`,cl),We=Z.useMemo(()=>({openChanges:({diffPath:e,staged:t,targetLine:n}={})=>{Ne(e?{path:e,staged:t===!0,targetLine:n}:null)},openToolDiff:({diffPath:e,patches:t,targetLine:n})=>{Ne({path:e,staged:!1,targetLine:n,toolPatches:t})},openTurnDiff:Pe,openFile:({path:e,targetLine:t})=>{je({path:e,targetLine:t})},openFiles:()=>ke(),openSettings:e=>{Ee(e)}}),[Ne,je,ke,Ee,Pe]),Ge=j(()=>{v(!1),ie(null)}),Ke=j(()=>{b(!1)});hc(Z.useMemo(()=>({openSessions:()=>{if(ye){Ce(!0);return}ge.getState().setActiveTab(`projects`)},openView:e=>{e===`files`?ke():e===`mcp`?D(!0):e===`instances`?De():e===`update`&&F(!0)},openChanges:({path:e,staged:t}={})=>{Ne(e?{path:e,staged:t===!0}:null)},openSettings:e=>{Ee(e)}}),[ye,Ne,ke,De,Ee]));let qe=Z.useRef(null),Je=Z.useRef(null),Ye=Z.useRef(null),Xe=Z.useRef(null),Ze=Z.useRef(null),Qe=Z.useRef(null),$e=K(e=>e.currentSessionId),et=K(e=>e.setCurrentSession),tt=Z.useMemo(()=>e=>$e?e.getDirectoryForSession($e):null,[$e]),nt=K(tt),rt=B($e,nt||G||void 0),it=ae($e??``),at=it?.type===`busy`||it?.type===`retry`,ot=j(()=>{let e=$e;if(!e||te||at)return;let t=nt||G||void 0;ne(!0),(async()=>{try{await r.refreshSessionTranscript(e,{directory:t}),A.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{A.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{ne(!1)}})()}),st=j(e=>{Qe.current=e}),ct=j(e=>{let t=Ye.current,n=Xe.current,r=Ze.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`)})}),lt=ge(e=>e.secondary?.kind??null),ut=!ye&&(lt===`chat`||lt===`draft`);Z.useEffect(()=>{!ye&&!ut&&H(!1)},[ye,ut]),Z.useEffect(()=>{H(!1)},[$e]),Pc(Je,{onSwitch:st,onProgress:ct},ye||ut);let dt=ye&&s===`assistant`||!ye&&!ut||i||d||p||_||y||o||E||M||P||I||V;el(Je,{onOpen:j(()=>{Nt(Pt)?.finish(`commit`)}),onPreviewStart:j(()=>{Nt(Pt)?.begin(`present`)}),onPreviewCancel:j(()=>{Nt(Pt)?.finish(`cancel`)}),onProgress:j(e=>{e!==null&&Nt(Pt)?.update(e)}),disabled:dt},ye||ut),Z.useLayoutEffect(()=>{let e=Qe.current;if(Qe.current=null,!e)return;let t=Ye.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)`})},[$e]);let ft=j(e=>{qe.current=e});yl(j(()=>V?(H(!1),!0):I?(L(!1),!0):o?(window.dispatchEvent(new Event(`oc:scheduled-tasks-close-request`)),!0):i?(a(!1),!0):Zt.backImmediately(`overlay`)?!0:p?(Ae(),!0):d?(f(!1),!0):y?(Ke(),!0):_?(Ge(),!0):E?(D(!1),!0):M?(N(!1),!0):P?(F(!1),!0):Zt.requestAnimatedBack(`root`)||qe.current?.()?!0:s===`assistant`?(l(`chat`),!0):rt?(et(rt.id,rt.directory),!0):!1));let pt=ce&&(le===`desktop`||le===`web`),mt=j(()=>{let e=`new-mcp-server`,t=e,n=1;for(;de.some(e=>e.name===t);)t=`${e}-${n}`,n+=1;q({name:t,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),he(t),D(!1),Ee(`mcp`)}),ht=j(()=>{if(O)return;k(!0);let e=new Promise(e=>window.setTimeout(e,500));Promise.all([pe(),fe(),e]).finally(()=>k(!1))}),gt=K(e=>e.openNewSessionDraft),_t=Z.useMemo(()=>{let e=[{key:`new-session`,icon:`chat-new`,label:n(`mobile.menu.newSession`),onSelect:()=>{if(ye){l(`chat`),gt();return}ge.getState().openDraft()}}];return ye||e.push({key:`files`,icon:`file-text`,label:n(`mobile.menu.files`),onSelect:()=>ke()},{key:`changes`,icon:`git-branch`,label:n(`mobile.menu.changes`),badge:_e,onSelect:()=>Ne()}),e.push({key:`mcp`,iconNode:(0,$.jsx)(On,{className:`size-5 shrink-0 text-muted-foreground`}),label:n(`mobile.menu.mcp`),onSelect:()=>D(!0)}),pt&&e.push({key:`update`,icon:`download`,label:n(`mobile.menu.update`),onSelect:()=>F(!0)}),ye&&e.push({key:`settings`,icon:`settings-3`,label:n(`mobile.menu.settings`),onSelect:()=>Ee()}),$e&&e.push({key:`refresh-transcript`,icon:`refresh`,label:n(`sessions.sidebar.session.menu.refreshTranscript`),disabled:te||at,spinning:te,onSelect:ot}),e},[$e,_e,ye,at,te,Ne,ke,gt,Ee,ot,l,pt,n]);return(0,$.jsxs)(Vt,{actions:We,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:[ye?(0,$.jsxs)(`aside`,{ref:He.asideRef,className:J(`relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/50 bg-sidebar will-change-[width] motion-reduce:transition-none`,!xe&&`border-r-0`),style:{width:xe?He.width:0,minWidth:xe?He.width:0,maxWidth:xe?He.width:0,"--oc-ipad-sidebar-width":`${He.width}px`,overflowX:`clip`,paddingTop:`var(--oc-safe-area-top, 0px)`,transitionProperty:He.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!xe,"data-page-scroll-lock":`true`,children:[xe?(0,$.jsx)(hl,{side:`left`,isResizing:He.isResizing,ariaLabel:n(`sidebar.resize.leftPanelAria`),handleProps:He.handleProps}):null,(0,$.jsx)(`div`,{className:J(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,He.isResizing&&`pointer-events-none`,!xe&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:(0,$.jsx)(Tt,{children:(0,$.jsx)(ca,{open:!0,variant:`sidebar`,onOpenChange:e=>{!e&&be&&Ce(!1)}})})})]}):null,(0,$.jsx)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,"data-page-scroll-lock":`true`,children:ye?(0,$.jsxs)($.Fragment,{children:[s===`assistant`?null:(0,$.jsx)(`div`,{children:(0,$.jsx)(Pl,{onOpenSessions:()=>Oe(),menuOpen:V,onToggleMenu:re,surfaceShortcuts:{activePanel:we===`turn-diff`?`changes`:we,changesDirty:_e>0,onToggleFiles:()=>Le(`files`),onToggleChanges:()=>Le(`changes`)}})}),(0,$.jsxs)(`main`,{ref:Je,className:`relative min-h-0 flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:[(0,$.jsxs)(`div`,{ref:Xe,"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)(Y,{name:`arrow-left`,className:`size-5`})})]}),(0,$.jsxs)(`div`,{ref:Ze,"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)(Y,{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:Ye,className:`relative h-full w-full bg-background`,children:(0,$.jsx)(Tt,{children:s===`assistant`?(0,$.jsx)(Cr,{}):(0,$.jsx)(er,{})})})]})]}):(0,$.jsx)(jo,{className:`min-h-0 flex-1`,onAddProject:()=>L(!0),onEnableAssistants:()=>{Ee(`assistants`)},instancesPage:ue?(0,$.jsx)(Dl,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t}):void 0,parentSessionTarget:rt?{id:rt.id,directory:rt.directory}:null,registerSecondaryBackHandler:ft,scheduledContent:(e,t)=>(0,$.jsx)(rr,{presentation:`mobile-tab`,registerEditorBackHandler:e,onEditorActiveChange:t}),renderChat:e=>(0,$.jsx)(Os,{sessionId:e.sessionId,directory:e.directory,onBack:()=>{U(),Zt.requestAnimatedBack(`root`)},onOpenMenu:re,onCloseMenu:U,menuOpen:e.active&&V,children:(0,$.jsxs)(`main`,{ref:e.active?Je: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:Xe,"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)(Y,{name:`arrow-left`,className:`size-5`})})]}),(0,$.jsxs)(`div`,{ref:Ze,"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)(Y,{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?Ye:void 0,className:`relative h-full w-full bg-background`,children:(0,$.jsx)(Tt,{children:(0,$.jsx)(er,{readOnly:!e.active,active:e.active,selectionOverride:{sessionId:e.sessionId||null,directory:e.directory,viewKey:e.viewKey}})})})]})})})}),ye?(0,$.jsxs)(`aside`,{ref:Ue.asideRef,className:J(`relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/50 bg-background will-change-[width] motion-reduce:transition-none`,!we&&`border-l-0`),style:{width:we?Ue.width:0,minWidth:we?Ue.width:0,maxWidth:we?Ue.width:0,"--oc-ipad-sidebar-width":`${Ue.width}px`,overflowX:`clip`,paddingTop:`var(--oc-safe-area-top, 0px)`,transitionProperty:Ue.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!we,"data-page-scroll-lock":`true`,children:[we?(0,$.jsx)(hl,{side:`right`,isResizing:Ue.isResizing,ariaLabel:n(`sidebar.resize.rightPanelAria`),handleProps:Ue.handleProps}):null,(0,$.jsx)(`div`,{className:J(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,Ue.isResizing&&`pointer-events-none`,!we&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:ze?(0,$.jsx)(Tt,{children:Ve===`files`?(0,$.jsx)(_i,{onClose:Ie}):Ve===`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)(X,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ie,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(Y,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(Kn,{hideStackedFileSidebar:!0,diffScope:`turn`,turnMessageId:x,sessionId:C,flushContent:!0})})]}):W?.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:W.toolPatches.length>1?n(`mobile.nav.changes`):W.path}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ie,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(Y,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(Kn,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:W.path,targetLine:W.targetLine??null,toolPatches:W.toolPatches,singleFileView:W.toolPatches.length===1,flushContent:!0})})]}):(0,$.jsx)(oi,{onClose:Ie,initialDiffPath:W?.path??null,initialDiffStaged:W?.staged===!0,initialDiffTargetLine:W?.targetLine??null})}):null})]}):null,(0,$.jsx)(or,{open:I,onOpenChange:L,forceMobile:!0}),(0,$.jsx)(Ml,{open:V,onClose:()=>H(!1),items:_t,rightOffset:ye&&we?Ue.width:0}),(0,$.jsx)(Gn,{}),d?(0,$.jsx)(Li,{open:!0,onClose:()=>f(!1),ariaLabel:n(`mobile.menu.files`),headerless:!0,children:(0,$.jsx)(Tt,{children:(0,$.jsx)(_i,{onClose:()=>f(!1)})})}):null,p&&h?(0,$.jsx)(Mt,{id:al,open:!0,onOpenChange:e=>{e||Ae()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:h.path.split(/[/\\]/).filter(Boolean).at(-1)??h.path}),ariaLabel:n(`mobile.menu.files`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(Tt,{children:(0,$.jsx)(_i,{onClose:Ae,initialFilePath:h.path,directFilePreview:!0,hideFileHeader:!0},h.path)})}):null,(0,$.jsx)(Mt,{id:il,open:y,onOpenChange:e=>{e||Ke()},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)(Tt,{children:(0,$.jsx)(Kn,{hideStackedFileSidebar:!0,diffScope:`turn`,turnMessageId:x,sessionId:C,flushContent:!0})})}),_&&W?(0,$.jsx)(Mt,{id:rl,open:!0,onOpenChange:e=>{e||Ge()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:W.toolPatches&&W.toolPatches.length>1?n(`mobile.nav.changes`):W.path}),ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(Tt,{children:W.toolPatches?.length?(0,$.jsx)(Kn,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:W.path,targetLine:W.targetLine??null,toolPatches:W.toolPatches,singleFileView:W.toolPatches.length===1,flushContent:!0}):(0,$.jsx)(oi,{initialDiffPath:W.path,initialDiffStaged:W.staged,initialDiffTargetLine:W.targetLine??null,hideDiffHeader:!0})})}):_?(0,$.jsx)(Li,{open:!0,onClose:Ge,ariaLabel:n(`mobile.menu.changes`),headerless:!0,children:(0,$.jsx)(Tt,{children:(0,$.jsx)(oi,{onClose:Ge,initialDiffPath:W?.path??null,initialDiffStaged:W?.staged===!0,initialDiffTargetLine:W?.targetLine??null})})}):null,E?(0,$.jsx)(Gt,{open:!0,onClose:()=>D(!1),title:n(`mcpDropdown.title`),className:`h-[72vh]`,contentMaxHeightClassName:`max-h-full`,renderHeader:e=>(0,$.jsxs)(`div`,{className:`shrink-0`,children:[(0,$.jsx)(`div`,{className:`flex justify-center pt-2.5 pb-1`,children:(0,$.jsx)(`div`,{className:`h-1 w-9 rounded-full bg-[color-mix(in_srgb,var(--surface-mutedForeground)_40%,transparent)]`})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-4 pb-2`,children:[(0,$.jsx)(`h2`,{className:`text-[16px] font-semibold text-[var(--surface-foreground)]`,children:n(`mcpDropdown.title`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]`,onClick:mt,"aria-label":n(`settings.mcp.sidebar.actions.addServerTitle`),title:n(`settings.mcp.sidebar.actions.addServerTitle`),style:{touchAction:`manipulation`},children:(0,$.jsx)(Y,{name:`add`,className:`h-5 w-5`})}),(0,$.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] disabled:opacity-60`,onClick:ht,disabled:O,"aria-label":n(`mcpDropdown.actions.refreshAria`),title:n(`mcpDropdown.actions.refreshAria`),style:{touchAction:`manipulation`},children:(0,$.jsx)(Y,{name:`refresh`,className:J(`h-5 w-5`,O&&`animate-spin`)})}),e]})]})]}),children:(0,$.jsx)(Tt,{children:(0,$.jsx)(Hn,{active:!0,className:`h-full`,listClassName:`max-h-none`,hideHeader:!0,mobileListDensity:!0})})}):null,M&&ye?(0,$.jsx)(Li,{open:!0,onClose:()=>N(!1),ariaLabel:n(`mobile.menu.settings`),headerless:!0,children:(0,$.jsx)(Tt,{children:(0,$.jsx)(gr,{forceMobile:!0,isWindowed:!0,initialMobileStage:R,visiblePageSlugs:[...Pn],onClose:()=>N(!1),mobileInstancesPage:ue?(0,$.jsx)(Dl,{connection:e,onConnect:()=>N(!1),onActiveConnectionDeleted:t}):void 0})})}):null,P?(0,$.jsx)(Li,{open:!0,onClose:()=>F(!1),ariaLabel:n(`mobile.menu.update`),title:n(`mobile.menu.update`),children:(0,$.jsx)(Tt,{children:(0,$.jsx)(`div`,{className:`h-full overflow-auto px-5 py-4`,children:(0,$.jsx)(mr,{initialUpdateDialogOpen:!0})})})}):null]}),(0,$.jsx)(fr,{enabled:ue&&s===`assistant`&&c.data?.supported===!0&&c.data?.enabled===!0}),(0,$.jsx)(Tt,{children:(0,$.jsx)(Yn,{})})]})};function Il({apis:e}){let{t:r}=ee(),i=V(e=>e.initializeApp),a=V(e=>e.isInitialized),o=V(e=>e.isConnected),s=V(e=>e.connectionPhase),l=w(e=>e.currentDirectory),d=K(e=>e.currentSessionId),m=K(e=>!!e.newSessionDraft?.open),h=K(e=>e.error),g=K(e=>e.clearError),_=u(e=>e.setIsMobile),v=Fn(e=>e.refreshStatus),y=Ht(e=>e.setPlanModeEnabled),b=G(e=>e.projects),[x,S]=Z.useState(0),[T,E]=Z.useState(0),[O,k]=Z.useState(!1),[M,N]=Z.useState(`pending`),P=Z.useMemo(()=>Pe(),[]),[,F]=Z.useReducer(e=>e+1,0),I=Z.useMemo(()=>gl(),[]),L=Z.useRef(0),R=Z.useRef(0),z=Me(()=>{N(`done`),S(e=>e+1)});gc(j(e=>{z.redeemPairingConnection(e)}));let B=_c({ready:I&&o&&a});Z.useEffect(()=>{!z.error||!n()||A.error(z.error)},[z.error]);let H=j(()=>{let t=n(),r=R.current+1;if(R.current=r,!t){De();return}let a=()=>{i(),v(e.github,{force:!0}),V.getState().refreshMissingCatalogs({source:`mobileApp:nativeResume`})},o=()=>{c({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),S(e=>e+1)};ke().then(e=>{if(R.current===r){if(e===`no-connection`){o();return}if(e===`unreachable`){window.setTimeout(()=>{R.current===r&&ke().then(e=>{if(R.current===r&&e!==`switched`&&e===`unchanged`){a();return}})},4e3);return}e!==`switched`&&a()}});let s=Date.now();s-L.current>=Sl&&(L.current=s,window.dispatchEvent(new Event(`openchamber:system-resume`)))});_l(),vl(H),Z.useEffect(()=>{if(!I)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>H(),1500)};return window.addEventListener(`online`,t),()=>{window.removeEventListener(`online`,t),window.clearTimeout(e)}},[I,H]),Z.useEffect(()=>(f(e),()=>f(null)),[e]),Z.useEffect(()=>t(e=>{if(e.runtimeKey&&e.runtimeKey===e.previousRuntimeKey){sr(),F();return}nr(e),ge.getState().reset(),E(e=>e+1),S(e=>e+1)}),[]),Z.useEffect(()=>{if(B===`pending`)return;if(B===`connect`){N(`done`);return}if(!I||o||n()){N(`done`);return}let e=!1;return N(`attempting`),je().then(e=>e?!0:De()).catch(()=>!1).then(()=>{e||N(`done`)}),()=>{e=!0}},[B]),Z.useEffect(()=>{_(!0)},[_]),Z.useEffect(()=>{I&&!n()||i()},[x,i,I]),tt({enabled:!I||!!n(),source:`mobileApp:recovery`}),Z.useEffect(()=>{o&&C.setDirectory(l)},[l,o]),Z.useEffect(()=>{o&&v(e.github,{force:!0})},[e.github,o,v]),Z.useEffect(()=>{if(!o||b.length===0)return;let e=!1;return(async()=>{await Promise.all(b.map(async t=>{let n=bl(t.path);if(n)try{if(!(vn.getState().directories.get(n)?.isGitRepo??await D(()=>import(`./gitApi-Bs_2iBAm.js`).then(e=>e.S).then(e=>e.checkIsGitRepository(n)),__vite__mapDeps([6,1,7,8,9,10,11,12,13,14,15,2,16,17,18,19,20,21,22])))||e)return;await pt({id:t.id,path:n},{isCurrent:()=>!e})}catch{}}))})(),()=>{e=!0}},[o,b]),Z.useEffect(()=>{let e=!1;return(async()=>{let t=await p(`/health`,{method:`GET`}).catch(()=>null);if(!t||!t.ok||e)return;let n=await t.json().catch(()=>null);if(!n||e)return;let r=n.planModeExperimentalEnabled;y(r===!0||r===1||r===`1`||r===`true`)})(),()=>{e=!0}},[y]),Z.useEffect(()=>{if(!h)return;let e=window.setTimeout(()=>g(),5e3);return()=>window.clearTimeout(e)},[g,h]),Z.useEffect(()=>{if(!(!o&&(!I||n()))){k(!1);return}let e=window.setTimeout(()=>k(!0),8e3);return()=>window.clearTimeout(e)},[o,I,x,T]),ct(),qe({enabled:!0}),$e(),Jn(),nl({enabled:I&&o});let te=Xs(),ne=!o&&s===`reconnecting`;if(!te)return(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(At,{width:120,height:120,isAnimated:!0})});let re=!!n();return I&&(!re||!o&&!ne)?re?(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)(At,{width:120,height:120,isAnimated:!O}),O?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h1`,{className:`typography-h3 text-foreground`,children:r(`sessionAuth.error.networkTitle`)}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:r(`sessionAuth.error.networkDescription`)})]}),(0,$.jsx)(X,{type:`button`,variant:`outline`,onClick:()=>{c({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),S(e=>e+1)},children:r(`mobile.connect.cancelPassword`)})]}):null]})}):M===`done`?(0,$.jsx)(El,{connection:z}):(0,$.jsxs)(`main`,{className:`relative flex min-h-dvh items-center justify-center bg-background text-foreground`,children:[(0,$.jsx)(At,{width:120,height:120,isAnimated:!0}),P?(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:r(`mobile.connect.splash.connectingTo`)}),(0,$.jsxs)(`p`,{className:`typography-small text-foreground`,children:[P,(0,$.jsx)(Rt,{})]})]}):null]}):!o&&!ne?O?(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:r(`sessionAuth.error.networkTitle`)}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:r(`sessionAuth.error.networkDescription`)})]})}):(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(At,{width:120,height:120,isAnimated:!0})}):(0,$.jsx)(Tt,{children:(0,$.jsx)(pe,{sdk:C.getSdkClient(),directory:l||``,bootstrapDirectory:!(m&&d===null),children:(0,$.jsx)(Ke,{apis:e,children:(0,$.jsx)(xt,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:`h-full bg-background text-foreground`,children:[(0,$.jsx)(cr,{}),(0,$.jsx)(Ne,{}),(0,$.jsx)(rt,{embeddedBackgroundWorkEnabled:a}),(0,$.jsx)($n,{}),(0,$.jsx)(Gr,{}),(0,$.jsx)(Fl,{connection:z,onActiveConnectionDeleted:()=>{c({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),ge.getState().reset(),S(e=>e+1)}}),(0,$.jsx)(lt,{position:`top-center`,offset:`calc(var(--oc-safe-area-top, 0px) + 16px)`}),a?(0,$.jsx)(Bn,{}):null]})})})},T)})}function Ll(e){e.currentTarget.style.transform=`none`}function Rl(e){return e.ensureStatus}function zl(e){return e.fetchStatus}function Bl(e){return e.providers}function Vl(e){return e.currentProviderId}function Hl(e){return e.currentModelId}function Ul(e){return e.getModelMetadata}function Wl(e){return e.results}function Gl(e){return e.loadSettings}function Kl(e){return e.fetchAllQuotas}function ql(e){return e.isLoading}function Jl(e){return e.displayMode}function Yl(e){return e.dropdownProviderIds}function Xl(e){return e.selectedModels}function Zl(e){return e.timeFormatPreference}function Ql(e){return[e.providerId,e]}function $l(e){return e.providerId}function eu(e){return!e}var tu=()=>{P(),g().then(()=>{Promise.all([h(),Ge()]).catch(e=>{console.error(`[mobile-main] settings init failed:`,e)}),Je(),nt(),et()}).catch(e=>{console.error(`[mobile-main] appearance init failed:`,e)}).finally(()=>{jr()})};function nu(e){Xt(),tu(),u.getState().setIsMobile(!0),zr(),It();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)(Il,{apis:r});(0,Dr.createRoot)(t).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(Ye,{children:(0,$.jsx)(M,{children:(0,$.jsx)(Ze,{children:(0,$.jsx)(at,{children:(0,$.jsx)(Un,{children:n?i:(0,$.jsx)(Xe,{children:i})})})})})})}))}export{nu as renderMobileApp};
|