@openchambery/web 1.19.5-beta.9 → 1.19.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentAvatar-BceI_qBC.js → AgentAvatar-CecaXP3U.js} +1 -1
- package/dist/assets/{AssistantView-D5uRIhdd.js → AssistantView-EVdG6eL4.js} +1 -1
- package/dist/assets/{ChatContainer-vRoWqx9I.js → ChatContainer-CI9R1YEw.js} +39 -39
- package/dist/assets/ContextPanel-BKypMSdw.js +285 -0
- package/dist/assets/{DiagramView-tg_cF9bP.js → DiagramView-Cv8NeQZw.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-BoNGeBaU.js +7 -0
- package/dist/assets/{MobileDetailNavigation-C3FPxLXw.js → MobileDetailNavigation-D_A3VHWc.js} +1 -1
- package/dist/assets/{MobileShareBridge-CwfVGh1E.js → MobileShareBridge-BhrdIMbw.js} +1 -1
- package/dist/assets/MobileSurface-CW5N2v0z.js +2 -0
- package/dist/assets/{MultiRunWindow-DeM0arSL.js → MultiRunWindow-Bh_4iSsl.js} +1 -1
- package/dist/assets/{OnboardingScreen-Czusf7rR.js → OnboardingScreen-BkbprNa7.js} +1 -1
- package/dist/assets/{SettingsView-3mxG03Kg.js → SettingsView-DjI_CkV3.js} +8 -8
- package/dist/assets/{SettingsWindow-CKVr8vEW.js → SettingsWindow-DD0gPVO2.js} +1 -1
- package/dist/assets/{TerminalView-B2vNAAGI.js → TerminalView-BdWZzQZR.js} +1 -1
- package/dist/assets/{ToolOutputDialog-FY1p6ABd.js → ToolOutputDialog-cAhekX_M.js} +1 -1
- package/dist/assets/appThemeRegistry-Z7AwGiu9.js +2 -0
- package/dist/assets/{clipboard-Ca2PSbr_.js → clipboard-C0bgPFn5.js} +1 -1
- package/dist/assets/{dialog-B2ieeCSR.js → dialog-Bjnvo5pk.js} +1 -1
- package/dist/assets/{es-Bj9HwM-0.js → es-D9KcV5TX.js} +1 -1
- package/dist/assets/{fr-BgEHZGug.js → fr-DPA9qUl3.js} +1 -1
- package/dist/assets/{gitApi-CIStyhfQ.js → gitApi-9I-wy4Pz.js} +1 -1
- package/dist/assets/insertionBoundaries-Dy_9x0TV.js +4 -0
- package/dist/assets/{ja-clyxf6re.js → ja-Dsif3NoD.js} +1 -1
- package/dist/assets/{ko-BZb3gnuq.js → ko-Dixx4Ctg.js} +1 -1
- package/dist/assets/{main-4AJr41lz.js → main-Dy2r9c5q.js} +2 -2
- package/dist/assets/{main-BXQdBQ0u.js → main-ssS4AQpG.js} +4 -4
- package/dist/assets/{miniChat-xTsSFILb.js → miniChat-CQqw310g.js} +2 -2
- package/dist/assets/{mobile-BCQf1Sdm.js → mobile-ClMMhPzX.js} +2 -2
- package/dist/assets/multirun-3dsNL_2z.js +4 -0
- package/dist/assets/{pl-CwZzSvrm.js → pl-Bj78ZGgf.js} +1 -1
- package/dist/assets/{projectMeta-DPKKf4Of.js → projectMeta-CZLzky9G.js} +2 -2
- package/dist/assets/{pt-BR-6ali2BQX.js → pt-BR-CFL3xSAf.js} +1 -1
- package/dist/assets/radio-D44bfX2h.js +1 -0
- package/dist/assets/{renderElectronMiniChatApp-BLlVyeOM.js → renderElectronMiniChatApp-Douqsp9n.js} +2 -2
- package/dist/assets/renderMobileApp-ScH1FVE6.js +25 -0
- package/dist/assets/{runtimeConfig-HOGA9fV1.js → runtimeConfig-D2zUK5uB.js} +1 -1
- package/dist/assets/runtimeEndpointReset-CFWN_nYN.js +4 -0
- package/dist/assets/{shikiHighlight-CYGn2J0U.js → shikiHighlight-CRK1juTA.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-CxLE1X9x.js → sortable-tabs-strip-oDpTDVoQ.js} +1 -1
- package/dist/assets/src-2eFAiBLq.css +2 -0
- package/dist/assets/{store-BvrCRq6U.js → store-DzpbXWX1.js} +2 -2
- package/dist/assets/{uk-qRqJs4GS.js → uk-BY60Ub3Z.js} +1 -1
- package/dist/assets/{useAppFontEffects-Bs2vXOZc.js → useAppFontEffects-BIaLn7X0.js} +3 -3
- package/dist/assets/{useDesktopWindowControlsLayout-BF-8wlNn.js → useDesktopWindowControlsLayout-B9oOTdt_.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-VgouJnIr.js → useEffectiveDirectory-BuzzKlL1.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-KGRUWzjR.js → useMobileNavigationStore-SLsstI7D.js} +4 -4
- package/dist/assets/{useSessionAutoCleanup-Bw0QGMfA.js → useSessionAutoCleanup-C3QX4RaU.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-CGgUFz01.js → useWorkerHighlightedLines-Ct_wpd4P.js} +1 -1
- package/dist/assets/{zh-CN-CwZ0adcY.js → zh-CN-Cox1LaOW.js} +2 -2
- package/dist/assets/{zh-TW-DC0jiCzA.js → zh-TW-B6RU0mxa.js} +2 -2
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/dist/assets/ContextPanel-BsZ6pucf.js +0 -285
- package/dist/assets/MarkdownRendererImpl-CUbq7MnV.js +0 -7
- package/dist/assets/MobileSurface-D7DvzqGV.js +0 -2
- package/dist/assets/appThemeRegistry-CxYhYWfx.js +0 -2
- package/dist/assets/insertionBoundaries-DKaP2akF.js +0 -4
- package/dist/assets/multirun-BGtjVyHw.js +0 -4
- package/dist/assets/radio-CkwG8Ru_.js +0 -1
- package/dist/assets/renderMobileApp-CCjMtagc.js +0 -25
- package/dist/assets/runtimeEndpointReset-pH89Ln7s.js +0 -4
- package/dist/assets/src-Bd_0IB9v.css +0 -2
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-FY1p6ABd.js","assets/rolldown-runtime-C0FnF6B9.js","assets/useUIStore-BXjMQrel.js","assets/vendor-zustand-B4dlGEM2.js","assets/vendor-base-ui-CnHfUmDN.js","assets/persistence-CLUawIlm.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-react-DLPElpoQ.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/vendor-reactuses-core-DDoDDyM9.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/clipboard-Ca2PSbr_.js","assets/store-BvrCRq6U.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/dialog-B2ieeCSR.js","assets/utils-D94hxQYq.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/Icon-Du1LX11Q.js","assets/button-p6vbd3r6.js","assets/useThemeSystem-DMzWVJaW.js","assets/markdownTheme-St8zxDvJ.js","assets/vendor-pierre-diffs-BenIz2TM.js","assets/vendor-hast-util-to-html-B0p1k5Xa.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-DpDied8H.js","assets/appThemeRegistry-CxYhYWfx.js","assets/platform-BrncW9ab.js","assets/vendor-opencode-sdk-C07HQypa.js","assets/useMobileNavigationStore-KGRUWzjR.js","assets/vendor-tanstack-react-query-D7pys_c9.js","assets/vendor-sonner-DVzioF3d.js","assets/useAssistantUIStore-D699Sbdb.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/markdown-worker-CoO82KYF.js","assets/useEffectiveDirectory-VgouJnIr.js","assets/useWorkerHighlightedLines-CGgUFz01.js","assets/tooltip-D1a6rKLA.js","assets/vendor-tanstack-react-virtual-tlDgH6PG.js","assets/vendor-capacitor-app-PzT84wSx.js","assets/vendor-capacitor-push-notifications-DB3-G2vL.js","assets/vendor-capacitor-status-bar-DeAGEDuY.js","assets/vendor-capacitor-keyboard-BkRQ-Kv-.js","assets/gitApi-CIStyhfQ.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,I as i,K as a,P as o,U as s,X as c,b as l,j as u,k as d,t as f}from"./useUIStore-BXjMQrel.js";import{$ as p,Sn as m,kn as h,kt as g,n as _,t as v,xn as y}from"./persistence-CLUawIlm.js";import{a as b,i as x}from"./vendor-zustand-B4dlGEM2.js";import{nt as S,rt as C}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as w,Nt as T,n as E,r as D,t as O}from"./platform-BrncW9ab.js";import{a as k,n as A,o as j}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as M,t as N}from"./vendor-react-DLPElpoQ.js";import{t as P}from"./capgoAdapter-DCowZ2ab.js";/* empty css */import{r as F}from"./vendor-sonner-DVzioF3d.js";import{n as I}from"./vendor-reactuses-core-DDoDDyM9.js";import{i as L,n as ee,t as R}from"./clipboard-Ca2PSbr_.js";import{i as z,n as B}from"./store-BvrCRq6U.js";import{a as V,c as H,d as U,f as te,l as W,o as G,p as ne,t as re,u as K}from"./MobileShareBridge-CwfVGh1E.js";import{$i as ie,$r as q,Di as ae,Ea as oe,F as J,Ht as se,La as ce,Oi as le,Pn as ue,Pt as de,Ra as fe,Ta as pe,Vt as me,Wt as he,Xt as ge,Yt as _e,_r as ve,an as ye,ar as be,bo as xe,br as Se,cn as Ce,dr as we,fr as Te,gr as Ee,hr as Y,jn as De,jr as Oe,l as ke,ln as Ae,lr as je,mr as Me,oa as Ne,on as Pe,or as Fe,pr as Ie,r as Le,rn as Re,t as ze,ta as Be,vr as Ve,xn as He,yr as Ue,za as We}from"./useMobileNavigationStore-KGRUWzjR.js";import{_ as Ge,t as Ke,y as qe}from"./MobileDetailNavigation-C3FPxLXw.js";import{i as Je,r as Ye}from"./useAssistantUIStore-D699Sbdb.js";import{t as X}from"./utils-D94hxQYq.js";import{t as Xe}from"./AgentAvatar-BceI_qBC.js";import{n as Z}from"./Icon-Du1LX11Q.js";import{t as Ze}from"./button-p6vbd3r6.js";import{F as Qe,I as $e,M as et,N as tt,p as nt}from"./gitApi-CIStyhfQ.js";import{B as rt,C as it,G as at,H as ot,I as st,K as ct,Q as lt,R as ut,S as dt,U as ft,V as pt,W as mt,i as ht,o as gt,q as _t,r as vt,s as yt,t as bt,z as xt}from"./useAppFontEffects-Bs2vXOZc.js";import{D as St,E as Ct,F as wt,I as Tt,M as Et,N as Dt,a as Ot,c as kt,i as At,j as jt,n as Mt,p as Nt,q as Pt}from"./projectMeta-DPKKf4Of.js";import{t as Ft}from"./input-gaFVNq1P.js";import{r as It}from"./tooltip-D1a6rKLA.js";import{c as Lt,f as Rt,o as zt,s as Bt,u as Vt}from"./useSessionAutoCleanup-Bw0QGMfA.js";import{n as Ht}from"./useThemeSystem-DMzWVJaW.js";import{K as Ut,V as Wt,_ as Gt,v as Kt,w as qt,y as Jt}from"./radio-CkwG8Ru_.js";import{a as Yt,n as Xt,s as Zt}from"./OverlayScrollbar-oOLMqq2s.js";import{x as Qt}from"./markdownTheme-St8zxDvJ.js";import{A as $t,F as en,I as tn,K as nn,U as rn,X as an,h as on,j as sn,q as cn,x as ln}from"./ChatContainer-vRoWqx9I.js";import{n as un}from"./useRuntimeAPIs-DSLXJybW.js";import{P as dn,b as fn,g as pn,x as mn,y as hn}from"./insertionBoundaries-DKaP2akF.js";import{I as gn,L as _n,b as vn,c as yn,f as bn,i as xn,j as Sn,l as Cn,o as wn,s as Tn,t as En,u as Dn,v as On}from"./appThemeRegistry-CxYhYWfx.js";import{a as kn}from"./url-zwuNq3GS.js";import{_ as An,g as jn,m as Mn,p as Nn}from"./markdown-worker-CoO82KYF.js";import{n as Pn}from"./useEffectiveDirectory-VgouJnIr.js";import{f as Fn}from"./FadeInOnReveal-Cj9ZC3Ab.js";import{a as In}from"./vendor-pierre-diffs-BenIz2TM.js";import{F as Ln,I as Rn,J as zn,K as Bn,M as Vn,Y as Hn,_ as Un,a as Wn,b as Gn,i as Kn,n as qn,o as Jn,p as Yn,q as Xn,r as Zn,t as Qn,v as $n}from"./MobileSurface-D7DvzqGV.js";import{t as er}from"./useFontPreferences-F2QPNE2V.js";import{h as tr,m as nr,p as rr,u as ir}from"./ContextPanel-BsZ6pucf.js";import{A as ar,C as or,D as sr,E as cr,G as lr,H as ur,J as dr,K as fr,L as pr,O as mr,S as hr,T as gr,U as _r,W as vr,X as yr,_ as br,a as xr,b as Sr,c as Cr,d as wr,f as Tr,h as Er,i as Dr,j as Or,k as kr,l as Ar,m as jr,n as Mr,o as Nr,p as Pr,q as Fr,r as Ir,t as Lr,u as Rr,v as zr,w as Br,x as Vr,y as Hr}from"./runtimeEndpointReset-pH89Ln7s.js";import{a as Ur,c as Wr,i as Gr,l as Kr,o as qr,r as Jr,s as Yr,t as Xr}from"./SettingsView-3mxG03Kg.js";import{a as Zr,c as Qr,l as $r,o as ei,s as ti}from"./shikiHighlight-CYGn2J0U.js";import{r as ni,t as ri}from"./AssistantView-D5uRIhdd.js";import{a as ii,i as ai,o as oi,r as si}from"./fileQueries-BDld6h3B.js";var Q=e(C(),1),ci=N(),li=null,ui=!1,di=new Promise(e=>{li=e});function fi(){ui||(ui=!0,li?.())}var pi=6,mi=e=>e.parentID??null,hi=e=>{let t=e.replace(/\/+$/,``);return t.slice(t.lastIndexOf(`/`)+1)||t},gi=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),_i=(e,t)=>{if(!e)return``;let n=null,r=-1;for(let i of t){let t=gi(i.path);(e===t||e.startsWith(`${t}/`))&&t.length>r&&(n=i,r=t.length)}return hi(n?n.path:e)},vi=()=>{let e=Te.getState().activeSessions,t=De.getState().index.session.unseenCount,n=xe.getState().projects,r=0,i=[];for(let a of e){let e=mi(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:_i(je(a),n)})}i.sort((e,t)=>t.updated-e.updated);let a=i.slice(0,pi).map(({id:e,title:t,unread:n,project:r})=>({id:e,title:t,unread:n,project:r}));return{attentionCount:r,recentSessions:a}},yi=`__OPENCHAMBER_WIDGET_SNAPSHOT__`,bi=()=>{typeof window>`u`||(window[yi]=()=>{try{return JSON.stringify(vi())}catch{return null}})},xi=M(),Si=k(`OpenChamberExternalBrowser`),Ci={getPlatform:()=>A.getPlatform(),isPluginAvailable:e=>A.isPluginAvailable(e),openInSystemBrowser:e=>Si.open(e),openExternal:kn},wi=async(e,t=Ci)=>{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)},$=S(),Ti=`mobile-app-update-available`,Ei=`mobile-app-update-toast-dismissed-version`,Di=()=>{let e=(0,xi.c)(9),{t}=ee(),n=Rn(Oi),r=Rn(ki),i=Rn(Ai),a=Rn(ji),o=Rn(Mi),s;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=new Set,e[0]=s):s=e[0];let c=Q.useRef(s),u,d;return e[1]!==n||e[2]!==a||e[3]!==o||e[4]!==r||e[5]!==t||e[6]!==i?(u=()=>{if(O()!==`android`||r!==`mobile`||!n||!i||!a||o){Y.dismiss(Ti);return}l().getItem(Ei)!==i&&(c.current.has(i)||(c.current.add(i),Y.info(t(`mobileUpdate.toast.available.title`),{id:Ti,description:t(`mobileUpdate.toast.available.description`,{version:i}),duration:1/0,icon:(0,$.jsx)(Z,{name:`download`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.toast.actions.download`),onClick:()=>{wi(a)}},cancel:{label:t(`mobileUpdate.toast.actions.dismiss`),onClick:()=>{l().setItem(Ei,i),Y.dismiss(Ti)}}})))},d=[n,a,o,r,t,i],e[1]=n,e[2]=a,e[3]=o,e[4]=r,e[5]=t,e[6]=i,e[7]=u,e[8]=d):(u=e[7],d=e[8]),Q.useEffect(u,d),null};function Oi(e){return e.available}function ki(e){return e.runtimeType}function Ai(e){return e.info?.version}function ji(e){return e.info?.downloadUrl}function Mi(e){return e.info?.inAppApply===!0}var Ni=e=>!(!e.enabled||e.runtimeType!==`mobile`||!e.available||!e.inAppApply||!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),Pi=e=>e.enabled&&!e.alreadyChecked,Fi=`mobile-ota-update-available`,Ii=`mobile-ota-update-toast-dismissed-version`,Li=()=>{let e=(0,xi.c)(24),{t}=ee(),[n,r]=Q.useState(!1),i=Q.useRef(!1),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,e[0]=a):a=e[0];let o=Q.useRef(a),s;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=E(),e[1]=s):s=e[1];let c=s,u=Rn(Ri),d=Rn(zi),f=Rn(Bi),p=Rn(Vi),m=Rn(Hi),h=Rn(Ui),g=Rn(Wi),_=Rn(Gi),v=Rn(Ki),y=f?.version,b=f?.inAppApply===!0,x,S;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{Pi({enabled:c,alreadyChecked:i.current})&&(i.current=!0,Rn.getState().checkForUpdates().catch(qi))},S=[c],e[2]=x,e[3]=S):(x=e[2],S=e[3]),Q.useEffect(x,S);let C;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{r(!0)},e[4]=C):C=e[4];let w=I(C),T=I(Ji),D,O;if(e[5]!==u||e[6]!==T||e[7]!==b||e[8]!==w||e[9]!==d||e[10]!==t||e[11]!==y?(D=()=>{if(!Ni({enabled:c,runtimeType:d,available:u,inAppApply:b,version:y??``,dismissedVersion:l().getItem(Ii),seenVersions:o.current})||!y){(!u||!b||d!==`mobile`)&&Y.dismiss(Fi);return}o.current.add(y),Y.info(t(`mobileUpdate.ota.toast.available.title`),{id:Fi,description:t(`mobileUpdate.ota.toast.available.description`,{version:y}),duration:1/0,icon:(0,$.jsx)(Z,{name:`refresh`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.ota.toast.actions.update`),onClick:w},cancel:{label:t(`mobileUpdate.ota.toast.actions.dismiss`),onClick:()=>{T(y)}}})},O=[u,b,c,w,T,d,t,y],e[5]=u,e[6]=T,e[7]=b,e[8]=w,e[9]=d,e[10]=t,e[11]=y,e[12]=D,e[13]=O):(D=e[12],O=e[13]),Q.useEffect(D,O),!c)return null;let k;return e[14]!==n||e[15]!==_||e[16]!==m||e[17]!==p||e[18]!==g||e[19]!==f||e[20]!==h||e[21]!==v||e[22]!==d?(k=(0,$.jsx)(Ln,{open:n,onOpenChange:r,info:f,downloading:p,downloaded:m,progress:h,error:g,onDownload:_,onRestart:v,runtimeType:d}),e[14]=n,e[15]=_,e[16]=m,e[17]=p,e[18]=g,e[19]=f,e[20]=h,e[21]=v,e[22]=d,e[23]=k):k=e[23],k};function Ri(e){return e.available}function zi(e){return e.runtimeType}function Bi(e){return e.info}function Vi(e){return e.downloading}function Hi(e){return e.downloaded}function Ui(e){return e.progress}function Wi(e){return e.error}function Gi(e){return e.downloadUpdate}function Ki(e){return e.restartToUpdate}function qi(){}function Ji(e){l().setItem(Ii,e),Y.dismiss(Fi)}var Yi=e=>{let t=(0,xi.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=X(`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=X(`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},Xi=`.oc-mobile-composer`;function Zi(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.closest==`function`&&!!t.closest(Xi)}function Qi(e){if(!e||typeof e!=`object`||Zi(e))return!1;let t=e,n=typeof t.tagName==`string`?t.tagName.toUpperCase():``;return n===`TEXTAREA`||n===`INPUT`||t.isContentEditable===!0}function $i(e){return Zi(e??null)}function ea(e,t){return e?`cache`:Zi(t??null)?`open`:Qi(t??null)?`field`:`ignore`}function ta(e,t){return!(t>0)||!(e>=0)?!1:t>e+24}function na(e,t){return e>0?Math.max(0,Math.round(e/(Number.isFinite(t)&&t>0?t:1))):0}var ra=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),ia=e=>{let t=e.index?.trim();return!!(t&&t!==`?`)},aa=e=>{let t=e.working_dir?.trim(),n=e.index?.trim();return!!(t||n===`?`)},oa=(e,t)=>t?`${e}\u0000staged`:e,sa=({onClose:e,initialDiffPath:t,initialDiffStaged:n=!1,initialDiffTargetLine:r=null,hideDiffHeader:i=!1})=>{let{t:a}=ee(),{git:o}=un(),s=ra(Pn()??null),c=hn(s||null),l=mn(s||null),u=pn(s||null),d=fn(e=>e.setActiveDirectory),f=fn(e=>e.ensureAll),p=fn(e=>e.fetchStatus),m=fn(e=>e.fetchBranches),h=fn(e=>e.prefetchDiffs),g=fn(e=>e.getDiff),_=fn(e=>e.setDiff),[v,y]=Q.useState(()=>t?{type:`diff`,path:t,staged:n,targetLine:r}:{type:`list`}),b=Q.useRef(null);Q.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]=Q.useState(null),[C,w]=Q.useState(null),[T,E]=Q.useState(``),[D,O]=Q.useState(new Set),[k,A]=Q.useState(!1),[j,M]=Q.useState(!1),[N,P]=Q.useState([]),[F,L]=Q.useState([]),[R,z]=Q.useState([]),[B,V]=Q.useState(null),[H,U]=Q.useState({key:null,loading:!1,error:null,resolved:!1}),[te,W]=Q.useState(0),G=Q.useRef({key:null,generation:0}),[ne,re]=Q.useState(!1),K=Ar(c)&&!ne,ie=Q.useMemo(()=>{let e=c?.files??[];if(K)return[];let t=new Map;for(let n of e)t.set(n.path,n);return Array.from(t.values()).sort((e,t)=>e.path.localeCompare(t.path))},[c?.files,K]),q=Q.useMemo(()=>ie.filter(ia),[ie]),ae=Q.useMemo(()=>ie.filter(aa),[ie]),{deferredStagedCount:oe,deferredUnstagedCount:J}=Q.useMemo(()=>{if(!K||!c)return{deferredStagedCount:0,deferredUnstagedCount:0};let e=0,t=0;for(let n of c.files??[])ia(n)&&(e+=1),aa(n)&&(t+=1);return{deferredStagedCount:e,deferredUnstagedCount:t}},[K,c]),se=Q.useMemo(()=>{if(R.length>0)return R;let e=c?.tracking?.includes(`/`)?c.tracking.split(`/`)[0]:null;return e||B?[{name:e||`origin`,fetchUrl:B??``,pushUrl:B??``}]:[]},[B,R,c?.tracking]),ce=Q.useMemo(()=>e=>!s||v.type!==`diff`?null:e.directories.get(s)?.diffCache.get(oa(v.path,v.staged))??null,[s,v]),le=fn(ce),ue=Q.useMemo(()=>v.type===`diff`?ie.find(e=>e.path===v.path)??null:null,[ie,v]),de=v.type===`diff`&&s?`${s}\u0000${oa(v.path,v.staged)}`:null,fe=H.key===de,pe=!!(de&&!le&&(!fe||H.loading)),me=fe?H.error:null,he=!!(ue||fe&&H.resolved),ge=I(async(e,t=!0)=>{try{await Promise.all([p(e,o),m(e,o)])}catch(e){t&&Y.error(e instanceof Error?e.message:a(`gitView.toast.refreshRepositoryFailed`))}}),_e=I(async(e,t,n)=>{let r=()=>G.current.key===t&&G.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;z(t),V(n)}catch{if(!r())return;z([]),V(null)}}),ve=I(e=>{if(e!==s)return{requestGeneration:null,promise:Promise.resolve()};let t=G.current.generation+1;return G.current={key:e,generation:t},{requestGeneration:t,promise:_e(e,e,t)}});Q.useEffect(()=>{s&&(d(s),f(s,o))},[s,f,o,d]),Q.useEffect(()=>{if(!s){G.current={key:null,generation:G.current.generation+1},z([]),V(null);return}let{requestGeneration:e,promise:t}=ve(s);return()=>{e!==null&&G.current.key===s&&G.current.generation===e&&(G.current={key:s,generation:e+1})}},[s,o,ve]),Q.useEffect(()=>{if(!s||ie.length===0)return;let e=Array.from(new Set([...q.map(e=>e.path),...F,...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,q,F]),Q.useEffect(()=>{if(v.type!==`diff`){U({key:null,loading:!1,error:null,resolved:!1});return}let e=oa(v.path,v.staged);if(!s||!de){U({key:null,loading:!1,error:null,resolved:!1});return}if(g(s,e)){U(e=>({key:de,loading:!1,error:null,resolved:e.key===de&&e.resolved||!!ue}));return}let t=!1;return U({key:de,loading:!0,error:null,resolved:!1}),o.getGitFileDiff(s,{path:v.path,staged:v.staged||void 0}).then(n=>{t||(_(s,e,{original:n.original??``,modified:n.modified??``,isBinary:n.isBinary}),U(e=>e.key===de?{...e,loading:!1,error:null,resolved:!0}:e))}).catch(e=>{t||U(t=>t.key===de?{...t,loading:!1,error:e instanceof Error?e.message:String(e),resolved:!1}:t)}),()=>{t=!0}},[de,s,te,g,o,v,ue,_]);let ye=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}),Y.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){Y.error(a(`gitView.toast.commitOrStashBeforeSync`));return}await o.gitPull(n,r(t))}((await o.getGitStatus(n)).ahead??0)>0&&await o.gitPush(n),Y.success(a(`gitView.toast.alreadyUpToDate`))}await ge(n,!1),await ve(n).promise}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.syncActionFailed`,{action:a(`gitView.sync.syncChanges`)}))}finally{S(null)}},be=I(async(e,t)=>{if(!s||e.length===0)return;let n=s;try{t===`stage`?e.length>1?await tt(n,e):await et(n,e[0]):e.length>1?await $e(n,e):await Qe(n,e[0]),await ge(n,!1)}catch(e){Y.error(e instanceof Error?e.message:a(t===`stage`?`gitView.toast.stageFileFailed`:`gitView.toast.unstageFileFailed`))}}),xe=I((e,t=!1)=>{y({type:`diff`,path:e,staged:t,targetLine:null})}),Se=I(()=>v.type===`diff`&&(y({type:`list`}),!0));yn({id:`mobile-changes-diff`,active:v.type===`diff`&&!i,layer:`overlay`,onBack:Se,surfaceRef:b});let Ce=I(async e=>{if(!s)return;let t=s;O(t=>new Set(t).add(e));try{await o.revertGitFile(t,e),Y.success(a(`gitView.toast.revertedFile`,{path:e})),await ge(t,!1)}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{O(t=>{let n=new Set(t);return n.delete(e),n})}}),we=I(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 ge(t,!1),Y.success(n.length===1?a(`gitView.toast.revertedFilesSingle`,{count:n.length}):a(`gitView.toast.revertedFilesPlural`,{count:n.length}))}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{O(new Set),A(!1)}}),Te=I(e=>{let t=e.map(e=>e.trim()).filter(Boolean);if(t.length===0){P([]);return}E(e=>`${e.trim()}${e.trim()?`
|
|
3
|
-
|
|
4
|
-
`:``}${t.join(`
|
|
5
|
-
`)}`.trim()),P([])}),Ee=I(async()=>{if(!s)return;let e=s,t=q.map(e=>e.path).sort();if(t.length===0){Y.error(a(`gitView.toast.selectFileToDescribe`));return}M(!0);try{let{message:n}=await nt(e,t);E(n.subject?.trim()??``),P(Array.isArray(n.highlights)?n.highlights:[])}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.generateCommitMessageFailed`))}finally{M(!1)}}),De=async(e={})=>{if(!s)return;let t=s;if(!T.trim()){Y.error(a(`gitView.toast.enterCommitMessage`));return}let n=q.map(e=>e.path).sort();if(n.length===0){Y.error(a(`gitView.toast.selectFileToCommit`));return}w(e.pushAfter?`commitAndPush`:`commit`);try{if(await o.createGitCommit(t,T.trim(),{files:n}),Y.success(a(`gitView.toast.commitCreated`)),E(``),P([]),e.pushAfter){let e=c?.tracking?.split(`/`)[0],n=se.find(t=>t.name===e)??se[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 ge(t,!1),await ve(t).promise}else await ge(t,!1)}catch(e){Y.error(e instanceof Error?e.message:a(`gitView.toast.createCommitFailed`))}finally{w(null),e.pushAfter&&S(null)}},Oe=Q.useMemo(()=>{let e=[];return q.length>0&&e.push({id:`staged`,title:a(`gitView.changes.stagedTitle`),entries:q,actionSymbol:`-`,actionAllLabel:a(`gitView.changes.unstageAllAria`),getActionLabel:e=>a(`gitView.changes.unstageFileAria`,{path:e}),onActionFile:e=>void be([e],`unstage`),onActionAll:e=>void be(e,`unstage`),onViewDiff:e=>xe(e,!0),onRevertFile:Ce,showRevertActions:!1,accent:!0}),ae.length>0&&e.push({id:`unstaged`,title:a(`gitView.changes.title`),entries:ae,actionSymbol:`+`,actionAllLabel:a(`gitView.changes.stageAllAria`),getActionLabel:e=>a(`gitView.changes.stageFileAria`,{path:e}),onActionFile:e=>void be([e],`stage`),onActionAll:e=>void be(e,`stage`),onViewDiff:e=>xe(e,!1),onRevertFile:Ce}),e},[Ce,xe,be,q,a,ae]),ke=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)(Z,{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?ke((0,$.jsx)(ca,{loading:!0,message:a(`gitView.loading.checkingRepository`)})):l===!1?ke((0,$.jsx)(ca,{icon:!0,message:a(`gitView.empty.notGitRepository`),description:a(`gitView.empty.notGitRepositoryDescription`)})):v.type===`diff`?(0,$.jsx)(`div`,{ref:b,className:`h-full min-h-0`,children:(0,$.jsx)(la,{path:v.path,diff:le,fileExists:he,error:me,loading:pe,targetLine:v.targetLine,onBack:Se,onRetry:()=>W(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)(Z,{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)(Er,{syncAction:x,remotes:se,onSync:e=>void ye(`sync`,e),disabled:C!==null||u,aheadCount:c?.ahead??0,behindCount:c?.behind??0,trackingRemoteName:c?.tracking?.split(`/`)[0],hasUncommittedChanges:(c?.files?.length??0)>0})]}),K?(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Rr,{stagedCount:oe,unstagedCount:J,onLoad:()=>re(!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)(wr,{groups:Oe,diffStats:c?.diffStats,revertingPaths:D,onRevertAll:we,isRevertingAll:k,headerBackgroundClassName:`bg-transparent`,onVisiblePathsChange:L})}),(0,$.jsx)(`div`,{className:`shrink-0 border-t border-border/50 px-4 pb-4 pt-3`,children:(0,$.jsx)(Cr,{stagedCount:q.length,commitMessage:T,onCommitMessageChange:E,generatedHighlights:N,onInsertHighlights:Te,onGenerateMessage:Ee,isGeneratingMessage:j,onCommit:()=>void De({pushAfter:!1}),onCommitAndPush:()=>void De({pushAfter:!0}),commitAction:C,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(ca,{icon:!0,message:a(`gitView.empty.cleanTitle`),description:a(`mobile.changes.cleanDescription`)})})]}):ke((0,$.jsx)(ca,{message:a(`gitView.empty.selectSessionOrDirectory`)}))},ca=e=>{let t=(0,xi.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)(Z,{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)(Z,{name:`git-branch`,className:`size-6 text-muted-foreground`}):null,t[2]=s,t[3]=l);let u;t[4]===n?u=t[5]:(u=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[4]=n,t[5]=u);let d;t[6]===r?d=t[7]:(d=r?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r}):null,t[6]=r,t[7]=d);let f;return t[8]!==c||t[9]!==l||t[10]!==u||t[11]!==d?(f=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[c,l,u,d]})}),t[8]=c,t[9]=l,t[10]=u,t[11]=d,t[12]=f):f=t[12],f},la=e=>{let t=(0,xi.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)(Z,{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)(Ze,{type:`button`,size:`sm`,variant:`outline`,onClick:l,children:f(`diffView.actions.retry`)})]})}):o?(0,$.jsx)(ca,{loading:!0,message:f(`diffView.state.loadingDiff`)}):i?r?r.isBinary?(0,$.jsx)(ca,{icon:!0,message:f(`diffView.binary.unavailable`)}):An(n)?(0,$.jsx)(ca,{icon:!0,message:f(`mobile.changes.diffDetail.imageUnavailable`)}):(0,$.jsx)(jt,{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)(nr,{original:r.original,modified:r.modified,language:m,fileName:n,renderSideBySide:!1,wrapLines:!0,focusLine:s,layout:`inline`})}):(0,$.jsx)(ca,{loading:!0,message:f(`diffView.state.loadingDiff`)}):(0,$.jsx)(ca,{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],_},ua=Dn(()=>j(()=>import(`./ToolOutputDialog-FY1p6ABd.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45]))),da=25e4,fa=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),pa=e=>{let t=fa(e);return!t||t===`/`?t||`/`:t.split(`/`).filter(Boolean).at(-1)??t},ma=e=>{let t=fa(e);if(!t||t===`/`)return null;let n=t.lastIndexOf(`/`);return n<=0?t.startsWith(`/`)?`/`:null:t.slice(0,n)},ha=(e,t)=>{let n=fa(e),r=fa(t);return!r||n===r?pa(n):n.startsWith(`${r}/`)?n.slice(r.length+1):n},ga=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``},_a=e=>e.toLowerCase().endsWith(`.svg`)?``:o().authenticatedAsset(`/api/fs/raw`,{path:e}),va=e=>/\.(md|mdx|markdown)$/i.test(e),ya=e=>{let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return o().authenticatedAsset(`/api/fs/serve${t.startsWith(`/`)?t:`/${t}`}`)},ba=e=>{let t=(0,xi.c)(143),{onClose:n,initialFilePath:r,directFilePreview:i,hideFileHeader:a}=e,o=r===void 0?null:r,s=i!==void 0&&i,c=a!==void 0&&a,{t:l}=ee(),{files:u}=un(),d=Pn()??null,p;t[0]===d?p=t[1]:(p=fa(d),t[0]=d,t[1]=p);let m=p,h;t[2]!==o||t[3]!==m?(h=()=>{let e=fa(o);return e?{type:`file`,path:e,returnDirectory:ma(e)??m}:{type:`browser`,directory:m}},t[2]=o,t[3]=m,t[4]=h):h=t[4];let[g,_]=Q.useState(h),v=Q.useRef(null),[y,b]=Q.useState(``),x=f(Oa),S=f(ka),C,w;t[5]===m?(C=t[6],w=t[7]):(C=()=>{m&&_(e=>e.type===`file`?e.returnDirectory?e:{...e,returnDirectory:ma(e.path)??m}:e.type===`browser`&&e.directory?e:{type:`browser`,directory:m})},w=[m],t[5]=m,t[6]=C,t[7]=w),Q.useEffect(C,w);let T,E;t[8]!==x||t[9]!==m||t[10]!==S?(E=()=>{if(!x||!m)return;let e=fa(x);if(!e){S(null);return}b(``),_({type:`file`,path:e,returnDirectory:ma(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]),Q.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=dn(y,250),j;t[13]===y?j=t[14]:(j=y.trim(),t[13]=y,t[14]=j);let M=j,N;t[15]===A?N=t[16]:(N=A.trim(),t[15]=A,t[16]=N);let P=N,F;t[17]!==O||t[18]!==m?(F={scopeDirectory:m,directory:O},t[17]=O,t[18]=m,t[19]=F):F=t[19];let L=!!O,z;t[20]===L?z=t[21]:(z={enabled:L,refetchOnMount:`always`},t[20]=L,t[21]=z);let B=ai(F,z),V;t[22]!==O||t[23]!==P?(V={directory:O,query:P,maxResults:40},t[22]=O,t[23]=P,t[24]=V):V=t[24];let H=!!(O&&P),U;t[25]===H?U=t[26]:(U={enabled:H},t[25]=H,t[26]=U);let te=ii(V,U),W;t[27]!==k||t[28]!==u?(W=k&&u.readFile&&!jn(k)&&(!An(k)||k.toLowerCase().endsWith(`.svg`)),t[27]=k,t[28]=u,t[29]=W):W=t[29];let G=!!W,ne;t[30]!==k||t[31]!==m?(ne={scopeDirectory:m,path:k},t[30]=k,t[31]=m,t[32]=ne):ne=t[32];let re;t[33]===G?re=t[34]:(re={enabled:G},t[33]=G,t[34]=re);let K=si(ne,re),ie;t[35]!==k||t[36]!==m?(ie={scopeDirectory:m,path:k},t[35]=k,t[36]=m,t[37]=ie):ie=t[37];let q;t[38]===G?q=t[39]:(q={enabled:G},t[38]=G,t[39]=q),oi(ie,q);let ae=B.data?.entries.slice().sort(Aa)??[],oe;t[40]!==B.error||t[41]!==l?(oe=B.error?B.error instanceof Error?B.error.message:l(`mobile.files.error.listFailed`):null,t[40]=B.error,t[41]=l,t[42]=oe):oe=t[42];let J=oe,se=B.isFetching,ce;t[43]===te.data?ce=t[44]:(ce=te.data??[],t[43]=te.data,t[44]=ce);let le=ce,ue=!!(M&&P&&y===A&&te.isFetching),de;t[45]!==K.data||t[46]!==l?(de=K.data&&K.data.length>da?`${K.data.slice(0,da)}\n\n${l(`mobile.files.file.truncated`)}`:K.data??``,t[45]=K.data,t[46]=l,t[47]=de):de=t[47];let fe=de,pe;t[48]!==k||t[49]!==K.error||t[50]!==u||t[51]!==l?(pe=k&&!u.readFile?l(`mobile.files.error.readUnavailable`):K.error?K.error instanceof Error?K.error.message:l(`filesView.error.readFileFailed`):null,t[48]=k,t[49]=K.error,t[50]=u,t[51]=l,t[52]=pe):pe=t[52];let me=pe,he=G&&K.isFetching,ge;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(ge=e=>{b(``),_({type:`browser`,directory:e})},t[53]=ge):ge=t[53];let _e=ge,ve;t[54]!==D||t[55]!==m?(ve=e=>{_({type:`file`,path:e,returnDirectory:D||m})},t[54]=D,t[55]=m,t[56]=ve):ve=t[56];let ye=ve,be;t[57]!==s||t[58]!==n||t[59]!==g.returnDirectory||t[60]!==g.type?(be=()=>g.type===`file`?s?(n?.(),!0):(_({type:`browser`,directory:g.returnDirectory}),!0):!1,t[57]=s,t[58]=n,t[59]=g.returnDirectory,t[60]=g.type,t[61]=be):be=t[61];let xe=I(be),Se=g.type===`file`,Ce;t[62]!==xe||t[63]!==Se?(Ce={id:`mobile-files-detail`,active:Se,layer:`overlay`,onBack:xe,surfaceRef:v},t[62]=xe,t[63]=Se,t[64]=Ce):Ce=t[64],yn(Ce);let we;t[65]===l?we=t[66]:(we=async e=>{(await R(e)).ok||Y.error(l(`mobile.files.toast.copyFailed`))},t[65]=l,t[66]=we);let Te=we,Ee;t[67]!==fe||t[68]!==l?(Ee=async()=>{(await R(fe)).ok?Y.success(l(`mobile.files.toast.contentCopied`)):Y.error(l(`mobile.files.toast.copyFailed`))},t[67]=fe,t[68]=l,t[69]=Ee):Ee=t[69];let De=Ee;if(!m){let e;t[70]===l?e=t[71]:(e=l(`mobile.files.empty.noDirectory`),t[70]=l,t[71]=e);let n;return t[72]===e?n=t[73]:(n=(0,$.jsx)(Da,{message:e}),t[72]=e,t[73]=n),n}if(g.type===`file`){let e;t[74]!==Te||t[75]!==g.path?(e=()=>void Te(g.path),t[74]=Te,t[75]=g.path,t[76]=e):e=t[76];let n;t[77]===De?n=t[78]:(n=()=>void De(),t[77]=De,t[78]=n);let r;return t[79]!==xe||t[80]!==fe||t[81]!==me||t[82]!==c||t[83]!==he||t[84]!==g.path||t[85]!==e||t[86]!==n?(r=(0,$.jsx)(`div`,{ref:v,className:`h-full min-h-0`,children:(0,$.jsx)(wa,{path:g.path,content:fe,error:me,isLoading:he,hideHeader:c,onBack:xe,onCopyPath:e,onCopyContent:n})}),t[79]=xe,t[80]=fe,t[81]=me,t[82]=c,t[83]=he,t[84]=g.path,t[85]=e,t[86]=n,t[87]=r):r=t[87],r}let Oe;t[88]!==m||t[89]!==g.directory||t[90]!==l?(Oe=g.directory===m?l(`mobile.files.rootDirectory`):pa(g.directory),t[88]=m,t[89]=g.directory,t[90]=l,t[91]=Oe):Oe=t[91];let ke=Oe,Ae;t[92]!==y||t[93]!==le?(Ae=y.trim()?le:[],t[92]=y,t[93]=le,t[94]=Ae):Ae=t[94];let je=Ae,Me,Ne,Pe,Fe;if(t[95]!==n||t[96]!==y||t[97]!==m||t[98]!==g.directory||t[99]!==l){let e=ma(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[104]!==n||t[105]!==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)(Z,{name:`close`,className:`size-5`})}):null,t[104]=n,t[105]=l,t[106]=Ne):Ne=t[106],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:pa(a)}),onClick:()=>_e(a),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`arrow-left`,className:`size-5`})}):null,t[95]=n,t[96]=y,t[97]=m,t[98]=g.directory,t[99]=l,t[100]=Me,t[101]=Ne,t[102]=Pe,t[103]=Fe}else Me=t[100],Ne=t[101],Pe=t[102],Fe=t[103];let Ie;t[107]===ke?Ie=t[108]:(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[107]=ke,t[108]=Ie);let Le;t[109]===l?Le=t[110]:(Le=l(`mobile.files.refreshAria`),t[109]=l,t[110]=Le);let Re;t[111]===B?Re=t[112]:(Re=()=>void B.refetch(),t[111]=B,t[112]=Re);let ze;t[113]===Symbol.for(`react.memo_cache_sentinel`)?(ze={touchAction:`manipulation`},t[113]=ze):ze=t[113];let Be=se&&`animate-spin`,Ve;t[114]===Be?Ve=t[115]:(Ve=X(`size-5`,Be),t[114]=Be,t[115]=Ve);let He;t[116]===Ve?He=t[117]:(He=(0,$.jsx)(Z,{name:`refresh`,className:Ve}),t[116]=Ve,t[117]=He);let Ue;t[118]!==Le||t[119]!==Re||t[120]!==He?(Ue=(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:He}),t[118]=Le,t[119]=Re,t[120]=He,t[121]=Ue):Ue=t[121];let We;t[122]!==Me||t[123]!==Ne||t[124]!==Pe||t[125]!==Ie||t[126]!==Ue?(We=(0,$.jsxs)(`header`,{className:Me,children:[Ne,Pe,Ie,Ue]}),t[122]=Me,t[123]=Ne,t[124]=Pe,t[125]=Ie,t[126]=Ue,t[127]=We):We=t[127];let Ge;t[128]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=(0,$.jsx)(Z,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),t[128]=Ge):Ge=t[128];let Ke;t[129]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=e=>b(e.target.value),t[129]=Ke):Ke=t[129];let qe;t[130]===l?qe=t[131]:(qe=l(`mobile.files.search.placeholder`),t[130]=l,t[131]=qe);let Je;t[132]!==y||t[133]!==qe?(Je=(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,"data-mobile-sheet-no-dismiss":``,children:(0,$.jsxs)(`div`,{className:`relative`,children:[Ge,(0,$.jsx)(Ft,{type:`text`,inputMode:`search`,value:y,onChange:Ke,placeholder:qe,className:`h-11 pl-9`})]})}),t[132]=y,t[133]=qe,t[134]=Je):Je=t[134];let Ye=jt,Xe=J?(0,$.jsx)(Da,{message:J}):y.trim()?(0,$.jsx)(Sa,{results:je,isSearching:ue,onOpenFile:ye}):(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:[ae.length===0&&!se?(0,$.jsx)(`div`,{className:`px-4 py-8 text-center typography-body text-muted-foreground`,children:l(`mobile.files.empty.directory`)}):null,ae.map(e=>(0,$.jsx)(xa,{name:e.name,path:e.path,directory:e.isDirectory,meta:e.isDirectory?void 0:ga(e.size),onClick:()=>e.isDirectory?_e(e.path):ye(e.path)},e.path))]}),Ze;t[135]!==Ye||t[136]!==Xe?(Ze=(0,$.jsx)(Ye,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto px-4 pb-3`,children:Xe}),t[135]=Ye,t[136]=Xe,t[137]=Ze):Ze=t[137];let Qe;return t[138]!==Fe||t[139]!==We||t[140]!==Je||t[141]!==Ze?(Qe=(0,$.jsxs)(`div`,{className:Fe,children:[We,Je,Ze]}),t[138]=Fe,t[139]=We,t[140]=Je,t[141]=Ze,t[142]=Qe):Qe=t[142],Qe},xa=e=>{let t=(0,xi.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)(Z,{name:`folder-3-fill`,className:`size-5 shrink-0 text-muted-foreground`}):(0,$.jsx)(cn,{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)(Z,{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},Sa=e=>{let t=(0,xi.c)(10),{results:n,isSearching:r,onOpenFile:i}=e,{t:a}=ee(),o=fa(Pn()??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)(Da,{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)(Da,{message:e}),t[6]=e,t[7]=n),n}let s=n.map(e=>(0,$.jsx)(xa,{name:pa(e.path),path:e.path,directory:!1,meta:ha(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},Ca=e=>{let t=(0,xi.c)(13),{path:n,onCopyPath:r,onCopyContent:i}=e,{t:a}=ee(),o;t[0]!==i||t[1]!==n||t[2]!==a?(o=!An(n)&&!jn(n)?(0,$.jsx)(Ze,{type:`button`,variant:`ghost`,size:`icon`,onClick:i,"aria-label":a(`mobile.files.copyContentAria`),children:(0,$.jsx)(Z,{name:`file-copy`,className:`size-4`})}):null,t[0]=i,t[1]=n,t[2]=a,t[3]=o):o=t[3];let s;t[4]===a?s=t[5]:(s=a(`mobile.files.copyPathAria`),t[4]=a,t[5]=s);let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Z,{name:`clipboard`,className:`size-4`}),t[6]=c):c=t[6];let l;t[7]!==r||t[8]!==s?(l=(0,$.jsx)(Ze,{type:`button`,variant:`ghost`,size:`icon`,onClick:r,"aria-label":s,children:c}),t[7]=r,t[8]=s,t[9]=l):l=t[9];let u;return t[10]!==o||t[11]!==l?(u=(0,$.jsxs)($.Fragment,{children:[o,l]}),t[10]=o,t[11]=l,t[12]=u):u=t[12],u},wa=e=>{let t=(0,xi.c)(60),{path:i,content:a,error:o,isLoading:l,hideHeader:u,onBack:d,onCopyPath:f,onCopyContent:p}=e,m=u!==void 0&&u,{t:g}=ee(),_=Q.useRef(null),v=An(i)&&!i.toLowerCase().endsWith(`.svg`)?i:``,y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=r(),t[0]=y):y=t[0];let b=y,x;t[1]===v?x=t[2]:(x=v&&c()?`${b}|${v}`:``,t[1]=v,t[2]=x);let S=x,C=v&&!S?`${b}|${v}`:``,[w,T]=Q.useState(``),[E,D]=Q.useState(``),[O,k]=Q.useState(null),[A,j]=Q.useState(!1),M;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(M={open:!1,title:``,content:``},t[3]=M):M=t[3];let[N,P]=Q.useState(M),F,L;t[4]===C?(F=t[5],L=t[6]):(F=()=>{if(!C){T(``);return}let e=!1;return T(``),s(n()).then(t=>{!e&&t&&T(C)}).catch(ja),()=>{e=!0}},L=[C],t[4]=C,t[5]=F,t[6]=L),Q.useEffect(F,L);let R,z;t[7]!==v||t[8]!==S||t[9]!==g?(R=()=>{if(!S){D(``),k(null),j(!1);return}let e=!1,t=``;return D(``),k(null),j(!0),h(`/api/fs/raw`,{query:{path:v}}).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}D(t)}).catch(t=>{e||k(t instanceof Error?t.message:g(`filesView.error.readFileFailed`))}).finally(()=>{e||j(!1)}),()=>{e=!0,t&&URL.revokeObjectURL(t)}},z=[v,S,g],t[7]=v,t[8]=S,t[9]=g,t[10]=R,t[11]=z):(R=t[10],z=t[11]),Q.useEffect(R,z);let B=!!(C&&w!==C),V;t[12]!==B||t[13]!==i||t[14]!==S||t[15]!==E?(V=S?E:B?``:_a(i),t[12]=B,t[13]=i,t[14]=S,t[15]=E,t[16]=V):V=t[16];let H=V,U=o??O,te;t[17]===i?te=t[18]:(te=pa(i),t[17]=i,t[18]=te);let W=te,G;t[19]!==a||t[20]!==i?(G=An(i)?`data:${Nn(i)};utf8,${encodeURIComponent(a)}`:``,t[19]=a,t[20]=i,t[21]=G):G=t[21];let ne=G,re;t[22]!==a||t[23]!==ne||t[24]!==H||t[25]!==i?(re=H||(An(i)&&a?ne:``),t[22]=a,t[23]=ne,t[24]=H,t[25]=i,t[26]=re):re=t[26];let K=re,ie;t[27]!==W||t[28]!==v||t[29]!==i||t[30]!==K?(ie=()=>{let e=v||K;e&&P({open:!0,title:W,content:``,metadata:{tool:`image-preview`,filename:W,mime:Nn(i)},image:{url:e,mimeType:Nn(i),filename:W}})},t[27]=W,t[28]=v,t[29]=i,t[30]=K,t[31]=ie):ie=t[31];let q=I(ie),ae;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(ae=e=>{P(t=>t.open===e?t:{...t,open:e})},t[32]=ae):ae=t[32];let oe=I(ae),J;t[33]!==m||t[34]!==W||t[35]!==d||t[36]!==p||t[37]!==f||t[38]!==i||t[39]!==g?(J=m?(0,$.jsx)(Dt,{children:(0,$.jsx)(Ca,{path:i,onCopyPath:f,onCopyContent:p})}):(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)(Z,{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:W})}),(0,$.jsx)(Ca,{path:i,onCopyPath:f,onCopyContent:p})]}),t[33]=m,t[34]=W,t[35]=d,t[36]=p,t[37]=f,t[38]=i,t[39]=g,t[40]=J):J=t[40];let se;t[41]!==a||t[42]!==B||t[43]!==U||t[44]!==W||t[45]!==l||t[46]!==A||t[47]!==q||t[48]!==i||t[49]!==K||t[50]!==g?(se=(0,$.jsx)(`div`,{ref:_,className:`min-h-0 flex-1 overflow-hidden`,children:l||B||A?(0,$.jsx)(Da,{loading:!0,message:g(`filesView.state.loading`)}):U&&!jn(i)?(0,$.jsx)(Da,{message:U}):jn(i)?(0,$.jsx)(Ta,{path:i}):An(i)&&K?(0,$.jsx)(jt,{className:`h-full overflow-auto p-4`,children:(0,$.jsx)(`button`,{type:`button`,className:`mx-auto block max-h-full max-w-full cursor-zoom-in rounded-lg border-0 bg-transparent p-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:q,"aria-label":W,children:(0,$.jsx)(`img`,{src:K,alt:W,className:`mx-auto max-h-full max-w-full rounded-lg object-contain`,draggable:!1})})}):(0,$.jsx)(Ea,{path:i,content:a})}),t[41]=a,t[42]=B,t[43]=U,t[44]=W,t[45]=l,t[46]=A,t[47]=q,t[48]=i,t[49]=K,t[50]=g,t[51]=se):se=t[51];let ce;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(on,{containerRef:_}),t[52]=ce):ce=t[52];let le;t[53]!==oe||t[54]!==N?(le=N.open?(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(ua,{popup:N,onOpenChange:oe,isMobile:!0})}):null,t[53]=oe,t[54]=N,t[55]=le):le=t[55];let ue;return t[56]!==J||t[57]!==se||t[58]!==le?(ue=(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[J,se,ce,le]}),t[56]=J,t[57]=se,t[58]=le,t[59]=ue):ue=t[59],ue},Ta=e=>{let t=(0,xi.c)(18),{path:r}=e,{t:o}=ee(),[c,l]=Q.useState(``),[u,d]=Q.useState(0),[f,p]=Q.useState(null),m,h;if(t[0]!==r||t[1]!==o?(m=()=>{let e=!1;l(``);let t=n(),c=i(t);s(t).then(t=>{e||!t||(l(r),p(null))}).catch(t=>{e||(p(t instanceof Error?t.message:o(`filesView.error.readFileFailed`)),l(r))});let u=a(()=>{e||(l(r),d(Ma),p(null))});return()=>{e=!0,c(),u()}},h=[r,o],t[0]=r,t[1]=o,t[2]=m,t[3]=h):(m=t[2],h=t[3]),Q.useEffect(m,h),f){let e;return t[4]===f?e=t[5]:(e=(0,$.jsx)(Da,{message:f}),t[4]=f,t[5]=e),e}if(c!==r){let e;t[6]===o?e=t[7]:(e=o(`filesView.state.loading`),t[6]=o,t[7]=e);let n;return t[8]===e?n=t[9]:(n=(0,$.jsx)(Da,{loading:!0,message:e}),t[8]=e,t[9]=n),n}let g;t[10]===r?g=t[11]:(g=ya(r),t[10]=r,t[11]=g);let _;t[12]===o?_=t[13]:(_=o(`filesView.editor.htmlPreviewTitle`),t[12]=o,t[13]=_);let v;return t[14]!==u||t[15]!==g||t[16]!==_?(v=(0,$.jsx)(`iframe`,{src:g,className:`h-full w-full border-none`,sandbox:`allow-scripts allow-same-origin allow-forms`,title:_},u),t[14]=u,t[15]=g,t[16]=_,t[17]=v):v=t[17],v},Ea=e=>{let t=(0,xi.c)(30),{path:n,content:r}=e,{currentTheme:i,availableThemes:a,lightThemeId:o,darkThemeId:s}=Ht(),c;t[0]!==a||t[1]!==o?(c=a.find(e=>e.metadata.id===o)??Qt(!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)??Qt(!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=()=>{En(l),En(d)},p=[d,l],t[6]=d,t[7]=l,t[8]=f,t[9]=p):(f=t[8],p=t[9]),Q.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(va(n)){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(jt,{className:`h-full overflow-y-auto px-4 py-4`,children:(0,$.jsx)(xn,{content:r,enableFileReferences:!1})}),t[13]=r,t[14]=e),e}let g;t[15]===n?g=t[16]:(g=pa(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:rr},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)(jt,{className:`min-h-0 flex-1 overflow-auto bg-[var(--syntax-base-background)]`,children:(0,$.jsx)(In,{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},Da=e=>{let t=(0,xi.c)(7),{message:n,loading:r}=e,i=r!==void 0&&r,a;t[0]===i?a=t[1]:(a=i?(0,$.jsx)(Z,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):(0,$.jsx)(Z,{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 Oa(e){return e.pendingFileFocusPath}function ka(e){return e.setPendingFileFocusPath}function Aa(e,t){return e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1}function ja(){}function Ma(e){return e+1}var Na=b(e=>({expandedParents:{},toggleParent:t=>e(e=>{let n={...e.expandedParents};return n[t]?delete n[t]:n[t]=!0,{expandedParents:n}})})),Pa=b()(x(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:g()}));typeof window<`u`&&t(e=>{d(e)&&Pa.persist.rehydrate()});var Fa=36,Ia=18,La=e=>e.parentID??null,Ra=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),za=e=>{let t=e;return Ra(t.directory??t.project?.worktree??null)},Ba=e=>{let t=Ra(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},Va=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},Ha=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),Ua=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))},Wa=(e,t)=>{let n=Ra(e),r=Ra(t);return!!(n&&r&&(n===r||n.startsWith(`${r}/`)))},Ga=(e,t)=>e.worktrees.find(e=>Ra(e.path)===t)??null,Ka=(e,t)=>t===e.path||!!Ga(e,t),qa=(e,t)=>{let n=Ra(t);return n?e.find(e=>Ka(e,n))??null:null},Ja=(e,t,n)=>!n||`${e.title??``} ${e.id} ${za(e)} ${t}`.toLowerCase().includes(n),Ya=e=>{let t=(0,xi.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?At[n.icon]:null,c=n.color?Mt[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)(Z,{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=X(`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)(Ot,{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},Xa=e=>{let t=(0,xi.c)(5),{expanded:n}=e,r=n?`rotate-0`:`-rotate-90`,i;t[0]===r?i=t[1]:(i=X(`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)(Z,{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},Za=e=>{let t=(0,xi.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},Qa=e=>{let t=(0,xi.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=X(`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)(Z,{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},$a=e=>{let t=(0,xi.c)(10),{icon:n,label:r,onClick:i,destructive:a}=e,o=a!==void 0&&a?`destructive`:`ghost`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,$.jsx)(Z,{name:n,className:`size-5 shrink-0`}),t[1]=n,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[3]=r,t[4]=l);let u;return t[5]!==i||t[6]!==o||t[7]!==c||t[8]!==l?(u=(0,$.jsxs)(Ze,{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},eo=e=>{let t=(0,xi.c)(100),{session:n,active:r,indent:i,contextLabel:a,confirmingArchive:o,hasChildren:s,expanded:c,onToggleChildren:l,onSelect:u,onRequestArchive:d,onConfirmArchive:f,onStop:p,stopAriaLabel:m,longPressHandlers:h,highlightQuery:g}=e,_=o!==void 0&&o,v=s!==void 0&&s,y=c!==void 0&&c,{t:b}=ee(),x;t[0]===n?x=t[1]:(x=Ua(Va(n)),t[0]=n,t[1]=x);let S=x,C,w,T,E,D,O,k,A,j,M,N,P,F,I,L,R,z,B;if(t[2]!==r||t[3]!==_||t[4]!==y||t[5]!==v||t[6]!==g||t[7]!==i||t[8]!==h.onContextMenu||t[9]!==h.onPointerCancel||t[10]!==h.onPointerDown||t[11]!==h.onPointerMove||t[12]!==h.onPointerUp||t[13]!==h.pressed||t[14]!==u||t[15]!==l||t[16]!==n.title||t[17]!==b){B=n.title?.trim()||b(`mobile.sessions.untitled`);let e=r&&!_&&`bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]`,a=_&&`bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]`;t[36]!==e||t[37]!==a?(N=X(`relative flex items-center gap-1 transition-colors`,e,a),t[36]=e,t[37]=a,t[38]=N):N=t[38],t[39]!==y||t[40]!==v||t[41]!==i||t[42]!==l||t[43]!==b?(P=v&&l?(0,$.jsx)(`button`,{type:`button`,className:`absolute z-10 flex w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,style:{left:Math.max(i-32,2),top:0,bottom:0,touchAction:`manipulation`},"aria-label":b(y?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:e=>{e.stopPropagation(),l()},children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:X(`size-[18px] transition-transform duration-150`,y?`rotate-0`:`-rotate-90`)})}):null,t[39]=y,t[40]=v,t[41]=i,t[42]=l,t[43]=b,t[44]=P):P=t[44],C=`button`;let o=_&&`opacity-50`,s=h.pressed&&`bg-interactive-active scale-[0.99]`;t[45]!==o||t[46]!==s?(w=X(`flex min-h-12 min-w-0 flex-1 items-center gap-2.5 py-2 pr-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,o,s),t[45]=o,t[46]=s,t[47]=w):w=t[47],t[48]===i?T=t[49]:(T={paddingLeft:i,touchAction:`manipulation`},t[48]=i,t[49]=T),E=u,D=h.onPointerDown,O=h.onPointerMove,k=h.onPointerUp,A=h.onPointerCancel,j=h.onContextMenu,M=_,z=`flex min-w-0 flex-1 flex-col`,L=`flex items-center gap-2.5`;let c=r?`bg-primary`:`bg-muted-foreground/30`,d;t[50]===c?d=t[51]:(d=X(`size-1.5 shrink-0 rounded-full`,c),t[50]=c,t[51]=d),t[52]===d?R=t[53]:(R=(0,$.jsx)(`span`,{className:d,"aria-hidden":!0}),t[52]=d,t[53]=R);let f=r?`text-primary`:`text-foreground`;t[54]===f?F=t[55]:(F=X(`block min-w-0 flex-1 truncate typography-ui-label`,f),t[54]=f,t[55]=F),I=g?st(B,g):B,t[2]=r,t[3]=_,t[4]=y,t[5]=v,t[6]=g,t[7]=i,t[8]=h.onContextMenu,t[9]=h.onPointerCancel,t[10]=h.onPointerDown,t[11]=h.onPointerMove,t[12]=h.onPointerUp,t[13]=h.pressed,t[14]=u,t[15]=l,t[16]=n.title,t[17]=b,t[18]=C,t[19]=w,t[20]=T,t[21]=E,t[22]=D,t[23]=O,t[24]=k,t[25]=A,t[26]=j,t[27]=M,t[28]=N,t[29]=P,t[30]=F,t[31]=I,t[32]=L,t[33]=R,t[34]=z,t[35]=B}else C=t[18],w=t[19],T=t[20],E=t[21],D=t[22],O=t[23],k=t[24],A=t[25],j=t[26],M=t[27],N=t[28],P=t[29],F=t[30],I=t[31],L=t[32],R=t[33],z=t[34],B=t[35];let V;t[56]!==F||t[57]!==I?(V=(0,$.jsx)(`span`,{className:F,children:I}),t[56]=F,t[57]=I,t[58]=V):V=t[58];let H;t[59]===S?H=t[60]:(H=S?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:S}):null,t[59]=S,t[60]=H);let U;t[61]!==V||t[62]!==H||t[63]!==L||t[64]!==R?(U=(0,$.jsxs)(`span`,{className:L,children:[R,V,H]}),t[61]=V,t[62]=H,t[63]=L,t[64]=R,t[65]=U):U=t[65];let te;t[66]!==a||t[67]!==g?(te=a?(0,$.jsx)(`span`,{className:`block truncate typography-micro text-muted-foreground pl-4`,children:g?st(a,g):a}):null,t[66]=a,t[67]=g,t[68]=te):te=t[68];let W;t[69]!==U||t[70]!==te||t[71]!==z?(W=(0,$.jsxs)(`span`,{className:z,children:[U,te]}),t[69]=U,t[70]=te,t[71]=z,t[72]=W):W=t[72];let G;t[73]!==C||t[74]!==w||t[75]!==T||t[76]!==E||t[77]!==D||t[78]!==O||t[79]!==k||t[80]!==A||t[81]!==j||t[82]!==M||t[83]!==W?(G=(0,$.jsx)(`button`,{type:C,className:w,style:T,onClick:E,onPointerDown:D,onPointerMove:O,onPointerUp:k,onPointerCancel:A,onContextMenu:j,disabled:M,children:W}),t[73]=C,t[74]=w,t[75]=T,t[76]=E,t[77]=D,t[78]=O,t[79]=k,t[80]=A,t[81]=j,t[82]=M,t[83]=W,t[84]=G):G=t[84];let ne;t[85]!==p||t[86]!==m?(ne=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)(Or,{})}):null,t[85]=p,t[86]=m,t[87]=ne):ne=t[87];let re;t[88]!==_||t[89]!==f||t[90]!==d||t[91]!==b||t[92]!==B?(re=d?(0,$.jsxs)($.Fragment,{children:[_?(0,$.jsxs)(`button`,{type:`button`,className:`flex h-9 shrink-0 items-center gap-1.5 rounded-xl bg-destructive px-3 text-destructive-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive`,"aria-label":b(`mobile.sessions.archiveSessionAria`,{title:B}),onClick:f,style:{touchAction:`manipulation`},children:[(0,$.jsx)(Z,{name:`archive`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label`,children:b(`sessions.sidebar.bulkActions.archive`)})]}):null,(0,$.jsx)(`button`,{type:`button`,className:`mr-1.5 flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":b(_?`mobile.sessions.cancelArchiveAria`:`mobile.sessions.archiveSessionAria`,{title:B}),onClick:d,style:{touchAction:`manipulation`},children:_?(0,$.jsx)(Z,{name:`close`,className:`size-4`}):(0,$.jsx)(Z,{name:`archive`,className:`size-4`})})]}):null,t[88]=_,t[89]=f,t[90]=d,t[91]=b,t[92]=B,t[93]=re):re=t[93];let K;return t[94]!==N||t[95]!==P||t[96]!==G||t[97]!==ne||t[98]!==re?(K=(0,$.jsxs)(`div`,{className:N,children:[P,G,ne,re]}),t[94]=N,t[95]=P,t[96]=G,t[97]=ne,t[98]=re,t[99]=K):K=t[99],K},to=e=>{let t=(0,xi.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)(Z,{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:X(`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)(Z,{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},no=({open:e,onOpenChange:t,variant:n=`sheet`})=>{let{t:r}=ee(),{git:i}=un(),a=me(),o=Te(e=>e.activeSessions),s=Te(e=>e.activePaginationByDirectory),c=xe(e=>e.projects),l=xe(e=>e.activeProjectId),u=w(e=>e.currentDirectory),d=ke(e=>e.currentSessionId),f=ke(e=>e.availableWorktreesByProject),p=ke(e=>e.setCurrentSession),m=ke(e=>e.archiveSession),h=ke(e=>e.archiveSessions),g=ke(e=>e.updateSessionTitle),_=ke(e=>e.requestSessionSmartTitle),v=ke(e=>e.shareSession),y=ke(e=>e.unshareSession),b=ke(e=>e.openNewSessionDraft),x=xe(e=>e.setActiveProject),S=xe(e=>e.setActiveProjectIdOnly),C=xe(e=>e.removeProject),T=Ie(),E=Me(),D=Pa(e=>e.projectExpanded),O=Pa(e=>e.worktreeExpanded),k=Pa(e=>e.setProjectExpanded),A=Pa(e=>e.setWorktreeExpanded),j=yt(e=>e.orderByProject),M=Na(e=>e.expandedParents),N=Na(e=>e.toggleParent),[P,F]=Q.useState(``),[L,z]=Q.useState(null),[B,V]=Q.useState(null),[H,U]=Q.useState(0),[te,W]=Q.useState(!1),[G,ne]=Q.useState(!1),[re,K]=Q.useState(null),[q,ae]=Q.useState(null),[oe,se]=Q.useState(null),[ce,le]=Q.useState(null),[ue,de]=Q.useState(null),[fe,pe]=Q.useState(``),[he,ge]=Q.useState(!1),[_e,ve]=Q.useState(null),ye=Q.useRef(null);ye.current||=Fn({onPressedKeyChange:le});let[Se,Ce]=Q.useState(new Set),[Ee,De]=Q.useState(new Map),[Ae,je]=Q.useState(new Map),Ne=lr(),Pe=vr(),Le=I(e=>{J(e),Oe(e)}),Re=I(e=>{Promise.all(e.map(e=>(J(e),Oe(e))))});Q.useEffect(()=>{if(!e){F(``),je(new Map),z(null),V(null),ae(null),de(null),ve(null),ye.current?.reset();return}},[e]),Q.useEffect(()=>()=>{ye.current?.reset()},[]),Q.useEffect(()=>{if(!e)return;if(c.length===0){ke.setState(e=>{let t=cr(e.availableWorktreesByProject,new Set,[]);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:[]}}),Ce(e=>e.size===0?e:new Set),De(e=>e.size===0?e:new Map);return}let t=!1;return(async()=>{let e=await Promise.all(c.map(async e=>{let n=Ra(e.path);if(!n)return null;let r;try{r=await i.checkIsGitRepository(n)}catch{return{id:e.id,path:n,gitStatus:`failed`}}if(!r)return{id:e.id,path:n,gitStatus:`success`,isGitRepo:r,worktreeStatus:`success`,worktrees:[]};let[a,o]=await Promise.allSettled([kt({id:e.id,path:n},{isCurrent:()=>!t}),Nt(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=>Ra(e.path)).filter(Boolean)),r=e.flatMap(e=>e?.worktreeStatus?[{path:e.path,status:e.worktreeStatus,worktrees:e.worktrees}]:[]);ke.setState(e=>{let t=cr(e.availableWorktreesByProject,n,r);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:Array.from(t.values()).flat()}}),Ce(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 Ha(r,t)?t:r}),De(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,H]);let ze=Q.useMemo(()=>c.map(e=>({id:e.id,label:Ba(e.path),path:Ra(e.path),icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:Se.has(Ra(e.path)),worktrees:gt(j[e.id],f.get(Ra(e.path))??[])})),[Se,c,j,f]),Be=Q.useMemo(()=>{let e=new Map(a.map(e=>[e.id,e])),t=o.map(t=>{let n=e.get(t.id);return n?Fe(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=P.trim().toLowerCase(),He=Q.useMemo(()=>{let e=ze.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===l})),t=(e,t,n)=>{let r=Ra(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||Ba(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=za(n);if(!r)continue;let i=Ra(r),a=e.find(e=>Ka(e.project,i));if(!a)continue;let o=Ga(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)=>ie(t)-ie(e));for(let n of e.sessions)La(n)||(t.totalSessions+=1)}return e},[l,ze,Be]),Ue=Ra(u),We=e=>e.isActive?Ue===e.project.path?e.project.path:e.project.worktrees.find(e=>Wa(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=>{je(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},Je=()=>{ae(null),ye.current?.reset()},Ye=e=>({pressed:ce===e.key||q?.key===e.key,onPointerDown:t=>{t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||ye.current?.start({pointerId:t.pointerId,key:e.key,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>ae(e)})},onPointerMove:e=>{ye.current?.move(e.pointerId,e.clientX,e.clientY)},onPointerUp:e=>{ye.current?.end(e.pointerId)},onPointerCancel:e=>{ye.current?.cancel(e.pointerId)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),ye.current?.openFromContextMenu(e.key,()=>ae(e))}}),Xe=(e,t)=>{ye.current?.consumeClick(e)||t()},Qe=(e,t,n,r)=>{let i=Br(),a=gr();if(je(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=Ra(t);if(!o)return;let s=Te.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&be(o)},$e=(e,t,n)=>{let i=`${e.project.id}::${t.key}`,a=Br(),o=new Set(t.sessions.map(e=>e.id)),c=new Map;for(let e of t.sessions){let t=La(e);if(t&&o.has(t)){let n=c.get(t)??[];n.push(e),c.set(t,n)}}let l=t.sessions.filter(e=>!La(e)),u=Ae.get(i)??a,f=pr(l,u,Pe),p=l.length-f.length,m=s.get(Ra(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=!!M[e.id],o=Ne.has(e.id),s=i&&!a?n.filter(e=>Ne.has(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)(Q.Fragment,{children:[(0,$.jsx)(eo,{session:e,active:d===e.id,indent:t,hasChildren:i,expanded:a,onToggleChildren:i?()=>N(e.id):void 0,confirmingArchive:B===e.id,onSelect:()=>Xe(p,()=>nt(e)),onRequestArchive:()=>rt(e.id),onConfirmArchive:()=>void it(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+Ia)):null]},e.id)};return(0,$.jsxs)(`div`,{children:[f.map(e=>v(e,n)),(0,$.jsx)(to,{indent:n,showMore:p>0||h,showFewer:_,loadingMore:g,onShowMore:()=>Qe(i,t.path,u,l.length),onShowFewer:()=>qe(i)})]})},et=(e,t)=>{k(e,!t)},tt=(e,t,n)=>{A(`${e}::${t}`,!n)},nt=e=>{Pt();let n=za(e)||null,r=qa(ze,n??``);r&&S(r.id),p(e.id,n),t(!1)},rt=e=>{V(t=>t===e?null:e)},it=async e=>{V(null),await m(e.id)?ar({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`)}):Y.error(r(`sessions.sidebar.session.archive.error`))},at=()=>{b(),t(!1)},ot=e=>{K(e),S(e),ne(!0)},ct=e=>{let t=new Map;for(let e of Be){let n=La(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},lt=async e=>{let t=ct(e.id),{archivedIds:n,failedIds:i}=await h(t);n.length>0&&ar({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&&Y.error(i.length===1?r(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):r(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}))},ut=e=>{let t=ct(e.id);kr({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`)})},dt=async e=>{try{if(!(await v(e.id))?.share?.url){Y.error(r(`sessions.sidebar.session.share.error`));return}Y.success(r(`sessions.sidebar.session.share.successTitle`),{description:r(`sessions.sidebar.session.share.successDescription`)})}catch{Y.error(r(`sessions.sidebar.session.share.error`))}},ft=async e=>{if((await R(e)).ok){Y.success(r(`sessions.sidebar.session.menu.copied`));return}Y.error(r(`sessions.sidebar.session.share.copyUrlError`))},pt=async e=>{try{if(await y(e)){Y.success(r(`sessions.sidebar.session.unshare.success`));return}Y.error(r(`sessions.sidebar.session.unshare.error`))}catch{Y.error(r(`sessions.sidebar.session.unshare.error`))}},mt=async()=>{if(!ue)return;let e=fe.trim();if(e)try{await g(ue.id,e),de(null),pe(``)}catch{Y.error(r(`sessions.sidebar.session.menu.rename`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},ht=async()=>{if(!ue||he)return;let e=ue.id;de(null),pe(``),ge(!0);try{await _(e)}catch{Y.error(r(`sessions.sidebar.session.rename.smartTitle`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{ge(!1)}},_t=(e,n)=>{S(e.id),b({selectedProjectId:e.id,directoryOverride:n,preserveDirectoryOverride:!0}),t(!1)},vt=e=>{(async()=>{try{await kt({id:e.id,path:e.path})}catch(e){console.warn(`[MobileSessions] Worktree refresh before session sync failed:`,e)}let t=ke.getState().availableWorktreesByProject.get(e.path)??e.worktrees,n=[e.path,...t.map(e=>e.path)];await we(n,Be)})()},bt=e=>{let t=za(e),n=qa(ze,t);if(!n)return Ba(t)||t;let r=Ga(n,Ra(t));return r?.branch?`${n.label} · ${r.branch}`:n.label},xt=e=>{x(e.id),t(!1)},St=Q.useMemo(()=>Ve?He.filter(e=>`${e.project.label} ${e.project.path}`.toLowerCase().includes(Ve)?!0:e.buckets.some(t=>t.sessions.some(t=>Ja(t,e.project.label,Ve)))):He,[Ve,He]),Ct=Q.useMemo(()=>Ve?Be.filter(e=>{let t=za(e);return Ja(e,qa(ze,t)?.label??``,Ve)}).sort((e,t)=>ie(t)-ie(e)):[],[Ve,ze,Be]),wt=Q.useMemo(()=>Ve?ze.filter(e=>`${e.label} ${e.path}`.toLowerCase().includes(Ve)).map(e=>({...e,sessionCount:Be.filter(t=>!La(t)&&Ka(e,Ra(za(t)))).length})):[],[Ve,ze,Be]),Tt=Ve&&Ct.length===0&&wt.length===0,Dt=ze.length>0?(0,$.jsxs)(Ze,{type:`button`,variant:`default`,size:`sm`,"aria-label":r(`mobile.sessions.newChat`),onClick:at,style:{touchAction:`manipulation`},children:[(0,$.jsx)(Z,{name:`add`,className:`size-4`}),r(`mobile.sessions.newChat`)]}):null,Ot=ze.find(e=>e.id===l)??null,At=Ot?.isGitRepo?(0,$.jsx)(Ze,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.project.actions.newWorktree`),title:r(`sessions.sidebar.project.actions.newWorktree`),onClick:()=>ot(Ot.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`node-tree`,className:`size-4`})}):null,Mt=(0,$.jsx)(Ze,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.header.actions.addProject`),title:r(`sessions.sidebar.header.actions.addProject`),onClick:()=>W(!0),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`folder-add`,className:`size-4`})}),It=Dt||Mt?(0,$.jsxs)($.Fragment,{children:[Dt,At,Mt]}):null,Lt=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`):``,Rt=Q.useMemo(()=>{if(!q)return[];if(q.kind===`project`){let e=q.project;return Sr({gitRepository:e.isGitRepo,onNewSession:()=>{Je(),_t(e,e.path)},onNewWorktree:()=>{Je(),ot(e.id)},onSyncSessions:()=>{Je(),vt(e)},onEditProject:()=>{Je(),z(e.id)},onCloseProject:()=>{Je(),se(e)}})}if(q.kind===`worktree`){let{project:e,worktree:t}=q;return hr({onNewSession:()=>{Je(),_t(e,t.path)},onDeleteWorktree:()=>{Je(),ve({project:e,worktree:t})}})}let e=q.session,t=!!e.share?.url;return Vr({pinned:T.has(e.id),shared:t,onRename:()=>{Je(),pe(e.title?.trim()||r(`mobile.sessions.untitled`)),de(e)},onTogglePin:()=>{Je(),E(e.id)},onShare:t?void 0:()=>{Je(),dt(e)},onCopyLink:t?()=>{let t=e.share?.url;Je(),t&&ft(t)}:void 0,onUnshare:t?()=>{Je(),pt(e.id)}:void 0,onArchive:()=>{Je(),lt(e)},onDelete:()=>{Je(),ut(e)}})},[q,Je,lt,ft,ut,ot,dt,pt,T,_t,vt,r,E]),zt=Rt.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:Rt.map(e=>{let t=(0,$.jsx)($a,{icon:e.icon,label:or(e,r),destructive:e.destructive,onClick:e.onClick},e.id);return e.separated?(0,$.jsx)(`div`,{className:`mt-3 border-t border-[var(--surface-subtle)] pt-3`,children:t},e.id):t})}):null,Bt=(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)(Z,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(Ft,{value:P,onChange:e=>F(e.target.value),placeholder:r(`mobile.sessions.search.placeholder`),className:X(`h-11 pl-9`,P&&`pr-10`)}),P?(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:()=>F(``),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`close`,className:`size-4`})}):null]})}),(0,$.jsx)(jt,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto pb-4`,children:ze.length===0?(0,$.jsx)(ro,{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:()=>W(!0),children:[(0,$.jsx)(Z,{name:`folder-add`,className:`size-4`}),r(`sessions.sidebar.header.actions.addProject`)]})}):Tt?(0,$.jsx)(ro,{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:[Ct.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:Ct.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:Ct.map((e,t)=>{let n=Ne.has(e.id),i=e.title?.trim()||r(`mobile.sessions.untitled`);return(0,$.jsx)(`div`,{className:X(t>0&&`border-t border-border/30`),children:(0,$.jsx)(eo,{session:e,active:d===e.id,indent:12,contextLabel:bt(e),highlightQuery:Ve,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,wt.length>0?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-1 pb-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-semibold uppercase tracking-wider text-muted-foreground`,children:r(`mobile.sessions.search.section.projects`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:wt.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:wt.map((e,t)=>{let n=`project:${e.id}`,r=Ye({key:n,kind:`project`,project:e});return(0,$.jsxs)(`div`,{className:X(`flex items-center`,t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`button`,{type:`button`,className:X(`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,()=>xt(e)),onPointerDown:r.onPointerDown,onPointerMove:r.onPointerMove,onPointerUp:r.onPointerUp,onPointerCancel:r.onPointerCancel,onContextMenu:r.onContextMenu,style:{touchAction:`manipulation`},children:[(0,$.jsx)(Ya,{project:e}),(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:st(e.label,Ve)}),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.sessionCount})]}),e.isGitRepo?(0,$.jsx)(Qa,{className:`mr-2`,onClick:()=>ot(e.id)}):null]},e.id)})})]}):null]}):(0,$.jsx)(`div`,{className:`flex flex-col`,children:St.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=>Ja(t,e.project.label,Ve))):e.buckets,s=We(e);return(0,$.jsxs)(`section`,{className:X(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:X(`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)(Ya,{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}),Ee.get(e.project.id)?(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 typography-micro text-muted-foreground`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:Ee.get(e.project.id)})]}):null]}),e.isActive?(0,$.jsx)(Za,{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=>Ne.has(e.id)).map(e=>e.id)))];return t.length>0?(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] mr-1`,"aria-label":r(`mobile.sessions.stopGroupAria`,{label:e.project.label}),onClick:e=>{e.stopPropagation(),Re(t)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Or,{})}):null})(),e.project.isGitRepo?(0,$.jsx)(Qa,{className:`mr-2`,onClick:()=>ot(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,Fa):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:X(`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)(Xa,{expanded:n}),(0,$.jsx)(Z,{name:`node-tree`,className:X(`size-4 shrink-0`,i?`text-primary`:`text-muted-foreground`)}),(0,$.jsx)(`span`,{className:X(`block min-w-0 flex-1 truncate typography-ui-label font-semibold`,i?`text-foreground`:`text-foreground/90`),children:t.label}),i?(0,$.jsx)(Za,{ariaLabel:r(`mobile.sessions.activeWorktreeAria`)}):null,(()=>{let e=n?[]:t.sessions.filter(e=>Ne.has(e.id)).map(e=>e.id);return e.length>0?(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-label":r(`mobile.sessions.stopGroupAria`,{label:t.label}),onClick:t=>{t.stopPropagation(),Re(e)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Or,{})}):null})(),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:t.sessions.length})]}),n?$e(e,t,Fa):null]},t.key)})]})})()}):null]},e.project.id)})})}),(0,$.jsx)(jr,{open:te,onOpenChange:W,forceMobile:!0}),(0,$.jsx)(ln,{open:G,projectId:re,onOpenChange:e=>{ne(e),e||K(null)},onWorktreeCreated:(e,n)=>{n?.sessionId?p(n.sessionId,e):b({selectedProjectId:re,directoryOverride:e,preserveDirectoryOverride:!0}),t(!1)}}),(0,$.jsx)(rn,{open:!!q,title:Lt,onClose:Je,contentMaxHeightClassName:`max-h-[min(68dvh,560px)]`,children:zt}),(0,$.jsx)(rn,{open:!!oe,title:r(`sessions.sidebar.project.actions.closeProject`),onClose:()=>se(null),closeAriaLabel:r(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Ze,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>se(null),children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Ze,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!oe)return;let e=oe;se(null),C(e.id),Y.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:oe?.label??``})})}),(0,$.jsx)(rn,{open:!!ue,title:r(`sessions.sidebar.session.menu.rename`),onClose:()=>{he||(de(null),pe(``))},footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Ze,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:he,onClick:()=>{de(null),pe(``)},children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Ze,{type:`button`,variant:`default`,className:`flex-1`,disabled:!fe.trim()||he,onClick:()=>void mt(),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(),mt()},children:[(0,$.jsx)(Ft,{value:fe,onChange:e=>pe(e.target.value),autoFocus:!0,className:`h-12`,disabled:he}),(0,$.jsxs)(Ze,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:he,onClick:()=>void ht(),children:[he?(0,$.jsx)(Z,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(Z,{name:`ai-generate-2`,className:`size-4`}),r(`sessions.sidebar.session.rename.smartTitle`)]})]})}),_e?(0,$.jsx)(mr,{open:!0,project:{id:_e.project.id,path:_e.project.path},worktree:_e.worktree,onClose:()=>ve(null),onDeleted:()=>U(e=>e+1)}):null,(0,$.jsx)(sr,{open:L!==null,project:ze.find(e=>e.id===L)??null,onClose:()=>z(null),onWorktreesChanged:()=>U(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:It?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:It}):null}),Bt]}):null:(0,$.jsx)(Et,{id:`mobile-sessions-sheet`,open:e,onOpenChange:t,trailing:It,ariaLabel:r(`mobile.sessions.sheet.title`),closeAriaLabel:r(`mobile.surface.closeAria`),resizeAriaLabel:r(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:Bt})},ro=e=>{let t=(0,xi.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},io=`/assets/assistant-guide-hero-wide-DiFIThB0.jpg`,ao=[{image:Yr,titleKey:`assistants.guide.share.ios.title`,descriptionKey:`assistants.guide.share.ios.description`},{image:Wr,titleKey:`assistants.guide.share.android.title`,descriptionKey:`assistants.guide.share.android.description`},{image:qr,titleKey:`assistants.guide.share.pick.title`,descriptionKey:`assistants.guide.share.pick.description`}];function oo(){let e=(0,xi.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 so(e){let t=(0,xi.c)(35),{onEnable:n}=e,{t:r}=ee(),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-guide-hero`,"aria-hidden":`true`,children:(0,$.jsx)(`img`,{src:io,alt:``})}),t[0]=i):i=t[0];let a;t[1]===r?a=t[2]:(a=r(`assistants.guide.disabledTitle`),t[1]=r,t[2]=a);let o;t[3]===a?o=t[4]:(o=(0,$.jsx)(`h2`,{className:`oc-mobile-assistant-guide-title`,children:a}),t[3]=a,t[4]=o);let s;t[5]===r?s=t[6]:(s=r(`assistants.guide.disabledDescription`),t[5]=r,t[6]=s);let c;t[7]===s?c=t[8]:(c=(0,$.jsx)(`p`,{className:`oc-mobile-assistant-guide-description`,children:s}),t[7]=s,t[8]=c);let l;t[9]===r?l=t[10]:(l=r(`assistants.guide.enableAction`),t[9]=r,t[10]=l);let u;t[11]!==n||t[12]!==l?(u=(0,$.jsx)(Ze,{type:`button`,size:`lg`,onClick:n,children:l}),t[11]=n,t[12]=l,t[13]=u):u=t[13];let d;t[14]!==o||t[15]!==c||t[16]!==u?(d=(0,$.jsxs)(`div`,{className:`oc-mobile-assistant-guide-body`,children:[o,c,u]}),t[14]=o,t[15]=c,t[16]=u,t[17]=d):d=t[17];let f;t[18]===r?f=t[19]:(f=r(`assistants.guide.shareTitle`),t[18]=r,t[19]=f);let p;t[20]===f?p=t[21]:(p=(0,$.jsx)(`h3`,{className:`oc-mobile-assistant-guide-share-title`,children:f}),t[20]=f,t[21]=p);let m;t[22]===r?m=t[23]:(m=r(`assistants.guide.shareAria`),t[22]=r,t[23]=m);let h;t[24]===r?h=t[25]:(h=ao.map(e=>(0,$.jsxs)(`article`,{className:`oc-mobile-assistant-guide-step`,children:[(0,$.jsx)(`div`,{className:`oc-mobile-assistant-guide-step-image`,children:(0,$.jsx)(`img`,{src:e.image,alt:``})}),(0,$.jsxs)(`div`,{className:`oc-mobile-assistant-guide-step-copy`,children:[(0,$.jsx)(`h4`,{children:r(e.titleKey)}),(0,$.jsx)(`p`,{children:r(e.descriptionKey)})]})]},e.titleKey)),t[24]=r,t[25]=h);let g;t[26]!==m||t[27]!==h?(g=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-guide-steps`,"aria-label":m,children:h}),t[26]=m,t[27]=h,t[28]=g):g=t[28];let _;t[29]!==p||t[30]!==g?(_=(0,$.jsxs)(`section`,{className:`oc-mobile-assistant-guide-share`,children:[p,g]}),t[29]=p,t[30]=g,t[31]=_):_=t[31];let v;return t[32]!==_||t[33]!==d?(v=(0,$.jsxs)(`article`,{className:`oc-mobile-assistant-guide`,children:[i,d,_]}),t[32]=_,t[33]=d,t[34]=v):v=t[34],v}function co({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]=Q.useState(!1),[p,m]=Q.useState(!1),h=Q.useRef(null);h.current||=Fn({onPressedKeyChange:t=>m(t===e)}),Q.useEffect(()=>()=>h.current?.reset(),[]);let g=I(()=>{h.current?.consumeClick(e)||d||c()}),_=I(()=>{f(!1),l()}),v=I(()=>{f(!1),u()}),y=I(()=>{m(!1),f(!0)}),b=I(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=I(e=>{h.current?.move(e.pointerId,e.clientX,e.clientY)}),S=I(e=>{h.current?.end(e.pointerId)}),C=I(e=>{h.current?.cancel(e.pointerId)}),w=I(t=>{t.preventDefault(),t.stopPropagation(),h.current?.openFromContextMenu(e,y)});return(0,$.jsxs)(Zr,{open:d,onOpenChange:f,children:[(0,$.jsx)(qn,{"data-mobile-press-surface":`soft`,className:X(`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,className:X(`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:X(`oc-mobile-assistant-avatar`,n?`oc-mobile-assistant-avatar--emoji`:`oc-mobile-assistant-avatar--visual`),children:(0,$.jsx)(Xe,{name:e,emoji:n,size:n?40:38,label:t})}),(0,$.jsxs)(`span`,{className:`oc-mobile-assistant-card-content min-w-0 flex-1`,children:[(0,$.jsxs)(`span`,{className:`oc-mobile-assistant-card-header`,children:[(0,$.jsx)(`span`,{className:`oc-mobile-entity-title oc-mobile-assistant-name min-w-0 flex-1 truncate font-semibold text-foreground`,children:t}),(0,$.jsx)(`span`,{className:`oc-mobile-entity-meta oc-mobile-assistant-mode shrink-0 text-muted-foreground`,children:r})]}),(0,$.jsx)(`span`,{className:`oc-mobile-assistant-summary text-muted-foreground`,children:i})]})]})}),(0,$.jsxs)(ei,{className:`min-w-[10rem]`,children:[(0,$.jsxs)(ti,{className:`min-h-10 px-3`,onClick:_,children:[(0,$.jsx)(Z,{name:`edit`,className:`size-4`}),o]}),(0,$.jsx)(Qr,{}),(0,$.jsxs)(ti,{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)(Z,{name:`delete-bin`,className:`size-4`}),s]})]})]})}function lo(e){let t=(0,xi.c)(104),{onEnable:n,onOpenAssistant:r,className:i}=e,{t:a}=ee(),o=tn(),s=Ge(),c=qe(),l=Je(uo),[u,d]=Q.useState(null),f;t[0]===n?f=t[1]:(f=()=>n(),t[0]=n,t[1]=f);let p=I(f),m;t[2]!==o||t[3]!==l?(m=()=>{l(),o?.openSettings(`assistants`)},t[2]=o,t[3]=l,t[4]=m):m=t[4];let h=I(m),g;t[5]===r?g=t[6]:(g=e=>r(e),t[5]=r,t[6]=g);let _=I(g),v;t[7]===o?v=t[8]:(v=e=>{Ye(e,o?{openMobileSettings:o.openSettings}:void 0)},t[7]=o,t[8]=v);let y=I(v),b;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>{d(e)},t[9]=b):b=t[9];let x=I(b),S;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>{e||d(null)},t[10]=S):S=t[10];let C=I(S),w;t[11]===a?w=t[12]:(w=a(`assistants.title`),t[11]=a,t[12]=w);let T=w,E;t[13]===a?E=t[14]:(E=a(`assistants.menu.edit`),t[13]=a,t[14]=E);let D=E,O;t[15]===a?O=t[16]:(O=a(`assistants.settings.delete`),t[15]=a,t[16]=O);let k=O;if(s.isPending||s.data?.supported&&s.data.enabled&&c.isPending){let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(qn,{className:`oc-mobile-assistant-loading`,children:(0,$.jsx)(oo,{})}),t[17]=e):e=t[17];let n;return t[18]!==i||t[19]!==T?(n=(0,$.jsx)(Kn,{title:T,className:i,surface:!1,children:e}),t[18]=i,t[19]=T,t[20]=n):n=t[20],n}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length>0){let e;t[21]===a?e=t[22]:(e=a(`assistants.listAria`),t[21]=a,t[22]=e);let n;if(t[23]!==k||t[24]!==D||t[25]!==y||t[26]!==_||t[27]!==x||t[28]!==c.data.assistants||t[29]!==a){let e;t[31]!==k||t[32]!==D||t[33]!==y||t[34]!==_||t[35]!==x||t[36]!==a?(e=e=>{let t=V(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)(co,{assistantID:e.id,displayName:n,avatarEmoji:t.avatarEmoji??void 0,modeLabel:r,summary:i,enabled:e.enabled,editLabel:D,deleteLabel:k,onOpen:()=>_(e.id),onEdit:()=>y(e.id),onDelete:()=>x(e)},e.id)},t[31]=k,t[32]=D,t[33]=y,t[34]=_,t[35]=x,t[36]=a,t[37]=e):e=t[37],n=c.data.assistants.map(e),t[23]=k,t[24]=D,t[25]=y,t[26]=_,t[27]=x,t[28]=c.data.assistants,t[29]=a,t[30]=n}else n=t[30];let r;t[38]!==e||t[39]!==n?(r=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-catalog`,role:`listbox`,"aria-label":e,children:n}),t[38]=e,t[39]=n,t[40]=r):r=t[40];let o=u!==null,s;t[41]!==u||t[42]!==C||t[43]!==o?(s=(0,$.jsx)(ni,{assistant:u,open:o,onOpenChange:C}),t[41]=u,t[42]=C,t[43]=o,t[44]=s):s=t[44];let l;return t[45]!==i||t[46]!==T||t[47]!==r||t[48]!==s?(l=(0,$.jsxs)(Kn,{title:T,className:i,surface:!1,scrollsWithPage:!0,children:[r,s]}),t[45]=i,t[46]=T,t[47]=r,t[48]=s,t[49]=l):l=t[49],l}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length===0){let e;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`oc-mobile-assistant-onboarding-icon`,children:(0,$.jsx)(Z,{name:`ai-agent`,className:`size-5`})}),t[50]=e):e=t[50];let n;t[51]===a?n=t[52]:(n=a(`assistants.onboarding.title`),t[51]=a,t[52]=n);let r;t[53]===n?r=t[54]:(r=(0,$.jsx)(`h2`,{children:n}),t[53]=n,t[54]=r);let o;t[55]===a?o=t[56]:(o=a(`assistants.onboarding.description`),t[55]=a,t[56]=o);let s;t[57]===o?s=t[58]:(s=(0,$.jsx)(`p`,{children:o}),t[57]=o,t[58]=s);let c;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Z,{name:`add`,className:`size-[18px]`}),t[59]=c):c=t[59];let l;t[60]===a?l=t[61]:(l=a(`assistants.onboarding.action`),t[60]=a,t[61]=l);let u;t[62]!==h||t[63]!==l?(u=(0,$.jsxs)(Ze,{type:`button`,size:`lg`,className:`mt-6 w-full`,onClick:h,children:[c,l]}),t[62]=h,t[63]=l,t[64]=u):u=t[64];let d;t[65]!==r||t[66]!==s||t[67]!==u?(d=(0,$.jsxs)(qn,{className:`oc-mobile-assistant-onboarding`,children:[e,r,s,u]}),t[65]=r,t[66]=s,t[67]=u,t[68]=d):d=t[68];let f;return t[69]!==i||t[70]!==T||t[71]!==d?(f=(0,$.jsx)(Kn,{title:T,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:d}),t[69]=i,t[70]=T,t[71]=d,t[72]=f):f=t[72],f}let A=s.isSuccess&&s.data.supported===!1,j=s.isError||s.data?.supported===!0&&s.data.enabled&&c.isError,M=s.data?.supported===!0&&(s.data.enabled===!1||c.data?.enabled===!1),N;t[73]!==a||t[74]!==j||t[75]!==A?(N=a(j?`assistants.state.unavailable`:A?`assistants.state.unsupportedTitle`:`assistants.state.instanceDisabled`),t[73]=a,t[74]=j,t[75]=A,t[76]=N):N=t[76];let P=N;if(M&&!j){let e;t[77]===p?e=t[78]:(e=(0,$.jsx)(so,{onEnable:p}),t[77]=p,t[78]=e);let n;return t[79]!==i||t[80]!==T||t[81]!==e?(n=(0,$.jsx)(Kn,{title:T,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-guide-host`,children:e}),t[79]=i,t[80]=T,t[81]=e,t[82]=n):n=t[82],n}let F;t[83]===T?F=t[84]:(F=(0,$.jsx)(`span`,{className:`oc-mobile-page-section-label`,children:T}),t[83]=T,t[84]=F);let L=A?`cloud-off`:`sparkling`,R;t[85]===L?R=t[86]:(R=(0,$.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground`,children:(0,$.jsx)(Z,{name:L,weight:`medium`,className:`size-5`})}),t[85]=L,t[86]=R);let z;t[87]===P?z=t[88]:(z=(0,$.jsx)(`h2`,{className:`mt-5 max-w-xs text-lg font-semibold leading-snug tracking-[-0.02em] text-foreground`,children:P}),t[87]=P,t[88]=z);let B;t[89]!==a||t[90]!==j||t[91]!==A?(B=j?null:(0,$.jsx)(`p`,{className:`mt-2 max-w-sm typography-small leading-relaxed text-muted-foreground`,children:a(A?`assistants.state.unsupportedDescription`:`assistants.state.instanceDisabledDescription`)}),t[89]=a,t[90]=j,t[91]=A,t[92]=B):B=t[92];let H;t[93]!==R||t[94]!==z||t[95]!==B?(H=(0,$.jsxs)(`section`,{className:`w-full max-w-md py-2`,children:[R,z,B]}),t[93]=R,t[94]=z,t[95]=B,t[96]=H):H=t[96];let U;t[97]!==F||t[98]!==H?(U=(0,$.jsx)(Zn,{label:F,cardClassName:`oc-mobile-assistant-state-card`,children:H}),t[97]=F,t[98]=H,t[99]=U):U=t[99];let te;return t[100]!==i||t[101]!==T||t[102]!==U?(te=(0,$.jsx)(Kn,{title:T,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:U}),t[100]=i,t[101]=T,t[102]=U,t[103]=te):te=t[103],te}function uo(e){return e.requestCreate}var fo=[{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 po(e){let t=(0,xi.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=I(o),c;t[2]!==n||t[3]!==r?(c=e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=fo.findIndex(e=>e.id===n),i=fo[e.key===`Home`?0:e.key===`End`?fo.length-1:(t+(e.key===`ArrowRight`?1:-1)+fo.length)%fo.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=I(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=fo.map(e=>{let t=e.id===n,r=a(e.labelKey);return(0,$.jsxs)(Ze,{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,className:X(`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:bg-interactive-active`,`motion-reduce:transition-none`,t&&[`bg-interactive-selection/55 text-primary`,`hover:bg-interactive-selection/55 hover:text-primary`,`font-semibold`]),children:[(0,$.jsx)(Z,{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)(Qn,{as:`nav`,"aria-label":u,variant:`navigation`,surfaceProps:d,className:i,children:f}),t[13]=i,t[14]=u,t[15]=f,t[16]=p):p=t[16],p}var mo=`oc-native-ios-tab-bar`,ho=`OpenChamberTabBar`,go=[`projects`,`assistant`,`scheduled`,`settings`],_o=k(ho),vo=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.nativeUiEnabled!==!1;function yo(){return typeof window>`u`?!1:vo({isCapacitor:E(),platform:O(),pluginAvailable:A.isPluginAvailable(ho),nativeUiEnabled:gn()})}var bo=e=>e.classList.contains(`dark`)?`dark`:`light`,xo=()=>Sn(`--primary`),So=e=>typeof e==`string`&&go.includes(e),Co=e=>typeof e==`string`&&So(e)?e:null,wo=(e,t)=>e.selectedTab===t.selectedTab&&e.appearance===t.appearance&&e.ariaLabel===t.ariaLabel&&e.accentColor===t.accentColor&&e.tabs.length===t.tabs.length&&e.tabs.every((e,n)=>e.id===t.tabs[n]?.id&&e.label===t.tabs[n]?.label),To=(e,t)=>{e.classList.toggle(mo,t)},Eo=(e,t)=>e&&!t,Do=e=>e.visible?e.overlayHidden?{action:`present`}:e.lastState&&wo(e.lastState,e.nextState)?{action:`skip`}:{action:`present`}:e.overlayHidden?{action:`skip`}:{action:`hide`},Oo=()=>_o,ko=`mobile-overlay-root`;function Ao(e){let t=(0,xi.c)(28),n=_n(),r;t[0]===n?r=t[1]:(r=n&&yo(),t[0]=n,t[1]=r);let i=r,[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(null),f=(0,Q.useRef)(!1),p=(0,Q.useRef)(!1),m=I(e.onTabChange),h;t[2]===e.tabs?h=t[3]:(h=e.tabs.map(Mo).join(`|`),t[2]=e.tabs,t[3]=h);let g=h,_;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=typeof document>`u`?`dark`:bo(document.documentElement),t[4]=_):_=t[4];let v=_,y;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=typeof document>`u`?``:xo(),t[5]=y):y=t[5];let b=y,x,S;t[6]===i?(x=t[7],S=t[8]):(x=()=>{if(!i||typeof document>`u`)return;let e=document.getElementById(ko);e||(e=document.createElement(`div`),e.id=ko,document.body.appendChild(e));let t=()=>u(sn(e.children));t();let n=new MutationObserver(t);return n.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[$t]}),()=>n.disconnect()},S=[i],t[6]=i,t[7]=x,t[8]=S),(0,Q.useEffect)(x,S);let C;t[9]!==i||t[10]!==m?(C=()=>{if(!i)return;let e=!1,t=Oo(),n=[];return t.addListener(`tabSelected`,e=>{let t=Co(e.tab);t&&m(t)}).then(t=>{if(e){t.remove();return}n.push(t)}),()=>{e=!0,d.current=null,t.hide();for(let e of n)e.remove();typeof document<`u`&&To(document.documentElement,!1)}},t[9]=i,t[10]=m,t[11]=C):C=t[11];let w;t[12]===i?w=t[13]:(w=[i],t[12]=i,t[13]=w),(0,Q.useEffect)(C,w);let T;t[14]!==e.activeTab||t[15]!==e.ariaLabel||t[16]!==e.tabs||t[17]!==e.visible||t[18]!==i||t[19]!==l?(T=()=>{if(!i||p.current)return;let t=!1,n=Oo(),r={tabs:e.tabs.map(jo),selectedTab:e.activeTab,appearance:v,accentColor:b,ariaLabel:e.ariaLabel},a=Do({visible:Eo(e.visible,l),overlayHidden:f.current,lastState:d.current,nextState:r});return(async()=>{if(a.action===`skip`)return;if(a.action===`hide`){f.current=!0,n.hide();return}let e=await n.present(r);if(!t){if(e.adopted!==!0){p.current=!0,c(!0),o(!1),typeof document<`u`&&To(document.documentElement,!1);return}f.current=!1,d.current=r,o(!0),typeof document<`u`&&To(document.documentElement,!0)}})().catch(()=>{t||(p.current=!0,c(!0),o(!1),typeof document<`u`&&To(document.documentElement,!1))}),()=>{t=!0}},t[14]=e.activeTab,t[15]=e.ariaLabel,t[16]=e.tabs,t[17]=e.visible,t[18]=i,t[19]=l,t[20]=T):T=t[20];let E;return t[21]!==e.activeTab||t[22]!==e.ariaLabel||t[23]!==e.visible||t[24]!==i||t[25]!==l||t[26]!==g?(E=[i,e.visible,l,e.activeTab,e.ariaLabel,v,b,g],t[21]=e.activeTab,t[22]=e.ariaLabel,t[23]=e.visible,t[24]=i,t[25]=l,t[26]=g,t[27]=E):E=t[27],(0,Q.useLayoutEffect)(T,E),!i||s?`web`:a?`native`:`pending`}function jo(e){return{id:e.id,label:e.label}}function Mo(e){return`${e.id}:${e.label}`}function No(e){let t=(0,xi.c)(39),{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]=Q.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=Q.useRef(null),C=Q.useRef(null),w=Q.useRef(null),T=Q.useRef(new Map),E=Q.useRef(null),D=Q.useRef(!1),O=Q.useRef(``),k=I(()=>h?.onBack());yn({id:h?`mobile-secondary:${h.key}`:`mobile-secondary:inactive`,active:!!h,onBack:k,surfaceRef:S,underlayRef:C}),Q.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),Q.useLayoutEffect(()=>{if(h){if(!D.current){let e=document.activeElement;E.current=e instanceof HTMLElement?e:null,D.current=!0}O.current!==h.key&&(O.current=h.key,S.current?.focus());return}if(D.current){D.current=!1,O.current=``;let e=E.current;E.current=null,e&&e.isConnected&&e.focus()}},A);let j;t[4]===i?j=t[5]:(j=e=>{i(e)},t[4]=i,t[5]=j);let M=I(j),N;t[6]===f?N=t[7]:(N=fo.map(e=>({id:e.id,label:f(e.labelKey)})),t[6]=f,t[7]=N);let P=N,F=u&&!d&&!h,L;t[8]===f?L=t[9]:(L=f(`mobile.nav.aria`),t[8]=f,t[9]=L);let R;t[10]!==M||t[11]!==F||t[12]!==P||t[13]!==p||t[14]!==L?(R={visible:F,activeTab:p,tabs:P,ariaLabel:L,onTabChange:M},t[10]=M,t[11]=F,t[12]=P,t[13]=p,t[14]=L,t[15]=R):R=t[15];let z=Ao(R),B=z===`native`,V=u&&z===`web`,H=_n(),U,te;t[16]!==H||t[17]!==B?(U=()=>{if(!H){bn.shutdown();return}B&&On(!0)&&bn.warm()},te=[H,B],t[16]=H,t[17]=B,t[18]=U,t[19]=te):(U=t[18],te=t[19]),Q.useEffect(U,te);let W;t[20]===c?W=t[21]:(W=X(`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[20]=c,t[21]=W);let G=h?!0:void 0,ne=h?!0:void 0,re;t[22]!==p||t[23]!==u||t[24]!==V||t[25]!==f||t[26]!==n||t[27]!==b?(re=fo.map(e=>{let t=b.has(e.id);return(0,$.jsx)(`section`,{id:`mobile-tabpanel-${e.id}`,role:`tabpanel`,"aria-labelledby":V?`mobile-tab-${e.id}`:void 0,"aria-label":V?void 0:f(e.labelKey),hidden:p!==e.id,tabIndex:0,className:X(`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)(Po,{tab:e.id,icon:e.icon}):null},e.id)}),t[22]=p,t[23]=u,t[24]=V,t[25]=f,t[26]=n,t[27]=b,t[28]=re):re=t[28];let K;t[29]!==w||t[30]!==G||t[31]!==ne||t[32]!==re?(K=(0,$.jsx)(`div`,{ref:w,"data-mobile-navigation-underlay":`true`,"aria-hidden":G,inert:ne,className:`flex h-full min-h-0 flex-1 flex-col`,children:re}),t[29]=w,t[30]=G,t[31]=ne,t[32]=re,t[33]=K):K=t[33];let ie=u?(0,$.jsx)(`div`,{"data-mobile-navigation-dock-underlay":`true`,"aria-hidden":h||B?!0:void 0,inert:h||B?!0:void 0,children:V?(0,$.jsx)(po,{activeTab:p,onTabChange:M}):null}):null,q=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:X(`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)}),ae;return t[34]!==W||t[35]!==K||t[36]!==ie||t[37]!==q?(ae=(0,$.jsxs)(`div`,{className:W,children:[K,ie,q]}),t[34]=W,t[35]=K,t[36]=ie,t[37]=q,t[38]=ae):ae=t[38],ae}function Po(e){let t=(0,xi.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=fo.find(e=>e.id===n)??fo[0];t[8]===i?c=t[9]:(c=X(`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)(Z,{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 Fo={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)`}},Io=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 Lo({project:e,expanded:t,embedded:n=!1,onToggle:r,onOpenActions:i,className:a,highlightQuery:o}){let{t:s}=ee(),[c,l]=Q.useState(!1),u=Q.useRef(null);u.current||=Fn({onPressedKeyChange:t=>l(t===e.id)}),Q.useEffect(()=>()=>u.current?.reset(),[]);let d=I(()=>{u.current?.consumeClick(e.id)||r(e)}),f=I(()=>i?.(e)),p=I(t=>{if(!i||t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0)return;let n=i;u.current?.start({pointerId:t.pointerId,key:e.id,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>{l(!1),n(e)}})}),m=I(e=>{u.current?.move(e.pointerId,e.clientX,e.clientY)}),h=I(e=>{u.current?.end(e.pointerId)}),g=I(e=>{u.current?.cancel(e.pointerId)}),_=I(t=>{if(!i)return;let n=i;t.preventDefault(),t.stopPropagation(),u.current?.openFromContextMenu(e.id,()=>{l(!1),n(e)})}),v=e.sessionCount===1?s(`mobile.sessions.project.sessionsSingle`):s(`mobile.sessions.project.sessionsPlural`,{count:e.sessionCount}),y=Io(e.path),b=(0,$.jsxs)(`article`,{"data-mobile-press-surface":`soft`,"data-pressed":c?`true`:void 0,className:X(`oc-mobile-project-card relative flex items-stretch overflow-hidden rounded-[var(--oc-mobile-surface-radius)]`,a),children:[(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-surface-trigger":!0,className:`oc-mobile-project-trigger flex min-w-0 flex-1 items-center text-left outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-expanded":t,onClick:d,onPointerDown:p,onPointerMove:m,onPointerUp:h,onPointerCancel:g,onContextMenu:_,style:{touchAction:`pan-y`},children:[(0,$.jsx)(`span`,{className:X(`oc-mobile-project-icon oc-mobile-glass-control flex shrink-0 items-center justify-center rounded-full text-muted-foreground`),style:Fo[e.tone??`neutral`],"aria-hidden":!0,children:(0,$.jsx)(Z,{name:e.icon??`code-box`,className:`oc-mobile-project-icon-glyph`})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`oc-mobile-project-title oc-mobile-entity-title truncate font-semibold text-foreground`,children:o?st(e.name,o):e.name}),e.active?(0,$.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-[var(--status-success)] shadow-[0_0_0_3px_color-mix(in_srgb,var(--status-success)_12%,transparent)]`,"aria-label":s(`mobile.sessions.activeProjectAria`)}):null]}),(0,$.jsxs)(`span`,{className:`oc-mobile-project-meta oc-mobile-entity-meta flex min-w-0 items-center text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:v}),e.activityLabel?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`·`}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:e.activityLabel})]}):null,y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`·`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,title:e.path,children:y})]}):null]})]}),(0,$.jsx)(Z,{name:`arrow-down-s`,className:X(`oc-mobile-project-chevron shrink-0 text-muted-foreground transition-transform duration-150 motion-reduce:transition-none`,t?`rotate-0`:`-rotate-90`)})]}),i?(0,$.jsx)(Ze,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-mobile-project-action self-center rounded-full text-muted-foreground`,"aria-label":s(`sessions.sidebar.project.actions.projectMenu`),onClick:f,children:(0,$.jsx)(Z,{name:`more-2`,className:`size-4`})}):null]});return n?b:(0,$.jsx)(qn,{asChild:!0,children:b})}var Ro=({hasPendingQuestion:e,hasPendingPermission:t,running:n,unread:r})=>e?`question`:t?`permission`:n?`running`:r?`completed-unread`:`idle`,zo=10,Bo=`oc:mobile-session-row-revealed`,Vo=e=>{window.dispatchEvent(new CustomEvent(Bo,{detail:e}))};function Ho({session:e,depth:t=0,hasChildren:n=!1,expanded:r=!1,paginationContinues:i=!1,onToggleChildren:a,onSelect:o,onPin:s,onArchive:c,onOpenActions:l,indicator:u,className:d,highlightQuery:f}){let{t:p}=ee(),[m,h]=Q.useState(0),[g,_]=Q.useState(!1),v=Q.useRef(null),y=Q.useRef(!1),b=Q.useRef(null),x=Q.useRef(null);x.current||=Fn(),Q.useEffect(()=>()=>x.current?.reset(),[]),Q.useEffect(()=>{let t=t=>{t.detail!==e.id&&h(0)};return window.addEventListener(Bo,t),()=>window.removeEventListener(Bo,t)},[e.id]),Q.useEffect(()=>{h(0)},[e.id]);let S=I(()=>h(0)),C=m!==0,w=I(t=>{if(t.button!==0||t.pointerType!==`touch`&&t.pointerType!==`pen`)return;let n=b.current?.offsetWidth??0;n<=0||(v.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startOffset:m,actionWidth:n,intent:`pending`},y.current=!1,x.current?.start({pointerId:t.pointerId,key:e.id,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>{l(e)}}))}),T=I(t=>{let n=v.current;if(!n||n.pointerId!==t.pointerId)return;let r=t.clientX-n.startX,i=t.clientY-n.startY;if(x.current?.move(t.pointerId,t.clientX,t.clientY),n.intent===`pending`){let a=Math.abs(r),o=Math.abs(i);if(o>zo&&o>a){n.intent=`vertical`,v.current=null,x.current?.cancel(t.pointerId);return}if(a>zo&&a>o){n.intent=`horizontal`,_(!0),y.current=!0,x.current?.cancel(t.pointerId);try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}Vo(e.id)}}if(n.intent!==`horizontal`)return;t.preventDefault();let a=Math.max(-n.actionWidth,Math.min(0,n.startOffset+r));h(a)}),E=I(e=>{let t=v.current;x.current?.end(e.pointerId),!(!t||t.pointerId!==e.pointerId)&&(v.current=null,t.intent===`horizontal`&&(_(!1),h(e=>e<-(t.actionWidth*.35)?-t.actionWidth:0)))}),D=I(e=>{let t=v.current;v.current=null,x.current?.cancel(e.pointerId),_(!1),h(t?.startOffset??0)}),O=I(()=>{if(!x.current?.consumeClick(e.id)){if(y.current){y.current=!1;return}if(m!==0){S();return}Vo(e.id),o(e)}}),k=I(t=>{t.preventDefault(),t.stopPropagation(),x.current?.openFromContextMenu(e.id,()=>{l(e)})}),A=I(()=>{S(),s(e)}),j=I(()=>{S(),c(e)}),M=I(()=>l(e)),N=I(()=>a?.()),P=e.pinned?p(`sessions.sidebar.session.menu.unpin`):p(`sessions.sidebar.session.menu.pin`),F=u??Ro({hasPendingQuestion:!1,hasPendingPermission:!1,running:!1,unread:!!e.unread}),L=F===`question`?p(`sessions.sidebar.session.status.questionRequired`):F===`permission`?p(`sessions.sidebar.session.status.permissionRequired`):F===`running`?p(`sessions.sidebar.session.status.active`):F===`completed-unread`?p(`sessions.sidebar.session.status.unread`):void 0;return e.kind===`pagination`?(0,$.jsx)(`div`,{className:X(`oc-mobile-session-row`,i&&`oc-mobile-session-pagination-continues`,d),children:(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-session-pagination-row`,style:{touchAction:`pan-y`},onClick:O,onPointerDown:()=>void 0,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left font-medium text-foreground typography-meta`,children:e.title}),e.subtitle?(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.subtitle}):null,(0,$.jsx)(Z,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground`})]})}):(0,$.jsxs)(`div`,{className:X(`oc-mobile-session-row relative isolate`,d),children:[(0,$.jsxs)(`div`,{ref:b,className:X(`oc-mobile-session-actions absolute inset-y-0 right-0 z-0 flex items-stretch`,g?`transition-none`:`transition-transform duration-150 ease-out`,!C&&`invisible pointer-events-none`),style:{transform:`translate3d(calc(var(--oc-mobile-session-actions-width) + ${m}px), 0, 0)`,willChange:m===0?void 0:`transform`},"aria-hidden":!C,children:[(0,$.jsxs)(Ze,{type:`button`,variant:`secondary`,className:`oc-mobile-session-action h-full flex-col rounded-none border-0 bg-interactive-selection px-1 text-interactive-selection-foreground hover:bg-interactive-active`,"aria-label":P,tabIndex:C?0:-1,onClick:A,children:[(0,$.jsx)(Z,{name:e.pinned?`unpin`:`pushpin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:P})]}),(0,$.jsxs)(Ze,{type:`button`,variant:`destructive`,className:`oc-mobile-session-action h-full flex-col rounded-none border-0 px-1`,"aria-label":p(`sessions.sidebar.bulkActions.archive`),tabIndex:C?0:-1,onClick:j,children:[(0,$.jsx)(Z,{name:`archive`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:p(`sessions.sidebar.bulkActions.archive`)})]})]}),(0,$.jsxs)(`div`,{className:X(`oc-mobile-session-row-content relative z-10 flex items-center`,`text-foreground`,`ease-out motion-reduce:transition-none`,g?`transition-none`:`transition-[transform,background-color] duration-150`,e.archived&&`opacity-55`),"data-dragging":g?`true`:void 0,style:{transform:`translate3d(${m}px, 0, 0)`,willChange:m===0?void 0:`transform`},children:[n&&a?(0,$.jsx)(Ze,{type:`button`,variant:`ghost`,size:`icon`,className:`min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":p(r?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:N,children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:X(`size-3.5 transition-transform duration-150 motion-reduce:transition-none`,r?`rotate-0`:`-rotate-90`)})}):null,(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-session-row-main flex min-w-0 flex-1 items-center text-left outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,style:{paddingLeft:16+Math.min(t,4)*12,touchAction:`pan-y`},onClick:O,onPointerDown:w,onPointerMove:T,onPointerUp:E,onPointerCancel:D,onContextMenu:k,children:[(0,$.jsx)(`span`,{className:`oc-mobile-session-status shrink-0`,"data-session-status":F,"aria-hidden":!L||void 0,"aria-label":L,title:L,children:F===`running`?(0,$.jsx)(Or,{className:`motion-reduce:[&_svg]:animate-none`}):F===`question`?(0,$.jsx)(Z,{name:`question`,className:`size-3.5 text-[var(--status-warning)]`}):F===`permission`?(0,$.jsx)(Z,{name:`shield`,className:`size-3.5 text-destructive`}):(0,$.jsx)(`span`,{className:X(`oc-mobile-session-dot rounded-full`,F===`completed-unread`?`bg-[var(--status-info)]`:`bg-muted-foreground/35`)})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:X(`oc-mobile-session-title truncate`,e.unread?`font-semibold`:`font-medium`),children:f?st(e.title,f):e.title}),e.archived?(0,$.jsx)(Z,{name:`archive`,className:`size-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}):null]}),e.subtitle?(0,$.jsx)(`span`,{className:`oc-mobile-session-subtitle truncate text-muted-foreground`,children:f?st(e.subtitle,f):e.subtitle}):null]}),(0,$.jsx)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-muted-foreground`,children:e.activityLabel?(0,$.jsx)(`span`,{className:`oc-mobile-session-time tabular-nums`,children:e.activityLabel}):null})]}),(0,$.jsx)(Ze,{type:`button`,variant:`ghost`,size:`icon`,className:`mr-1 min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":p(`sessions.sidebar.session.menu.label`),onClick:M,children:(0,$.jsx)(Z,{name:`more-2`,className:`size-3.5`})})]})]})}var Uo=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e)),Wo=e=>e.catalogSessions??e.sessions,Go=(e,t)=>e.filter(e=>e.kind!==`pagination`&&Uo(t,e.title,e.subtitle,e.id)),Ko=(e,t)=>{let n=Wo(e);if(Uo(t,e.name,e.path))return{...e,sessions:n.filter(e=>e.kind!==`pagination`)};let r=Go(n,t);return r.length>0?{...e,sessions:r}:null},qo=(e,t)=>{let n=t.trim().toLowerCase();return n?e.flatMap(e=>{if(Uo(n,e.name,e.path))return[{...e,worktrees:[]}];let t=e.worktrees.flatMap(e=>{let t=Ko(e,n);return t?[t]:[]});return t.length>0?[{...e,worktrees:t}]:[]}):e},Jo=10,Yo=`oc:mobile-worktree-row-revealed`,Xo=e=>{window.dispatchEvent(new CustomEvent(Yo,{detail:e}))};function Zo(e){let t=(0,xi.c)(10),n=_e(e.session.id),r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={bootstrap:!1},t[0]=r):r=t[0];let i=Ce(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=Ae(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=Ro({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)(Ho,{...e,indicator:d}),t[7]=d,t[8]=e,t[9]=f):f=t[9],f}function Qo(e){let t=(0,xi.c)(9),{sessions:n,onSelectSession:r,onPinSession:i,onArchiveSession:a,onOpenSessionActions:o,highlightQuery:s}=e,c;t[0]!==s||t[1]!==a||t[2]!==o||t[3]!==i||t[4]!==r||t[5]!==n?(c=n.map((e,t)=>{let c=e.kind===`pagination`&&n[t+1]?.kind===`pagination`,l=e.kind===`pagination`?Ho:Zo;return(0,$.jsx)(l,{session:e,paginationContinues:c,highlightQuery:s,onSelect:r,onPin:i,onArchive:a,onOpenActions:o},e.id)}),t[0]=s,t[1]=a,t[2]=o,t[3]=i,t[4]=r,t[5]=n,t[6]=c):c=t[6];let l;return t[7]===c?l=t[8]:(l=(0,$.jsx)($.Fragment,{children:c}),t[7]=c,t[8]=l),l}function $o({project:e,worktree:t,expanded:n,onToggle:r,onNewSession:i,onOpenActions:a,onDelete:o,highlightQuery:s}){let{t:c}=ee(),l=`${e.id}::${t.id}`,u=!!(i||o),d=!!a,f=Number(!!i)+Number(!!o),[p,m]=Q.useState(0),[h,g]=Q.useState(!1),[_,v]=Q.useState(!1),y=Q.useRef(null),b=Q.useRef(!1),x=Q.useRef(null),S=Q.useRef(null);S.current||=Fn({onPressedKeyChange:e=>g(e===l)}),Q.useEffect(()=>()=>S.current?.reset(),[]),Q.useEffect(()=>{let e=e=>{e.detail!==l&&m(0)};return window.addEventListener(Yo,e),()=>window.removeEventListener(Yo,e)},[l]),Q.useEffect(()=>{m(0)},[l]);let C=I(()=>m(0)),w=p!==0,T=I(n=>{if(n.button===0&&(n.pointerType===`touch`||n.pointerType===`pen`)){if(u){let e=x.current?.offsetWidth??0;e>0&&(y.current={pointerId:n.pointerId,startX:n.clientX,startY:n.clientY,startOffset:p,actionWidth:e,intent:`pending`},b.current=!1)}d&&S.current?.start({pointerId:n.pointerId,key:l,clientX:n.clientX,clientY:n.clientY,onTrigger:()=>{g(!1),a?.(e,t)}})}}),E=I(e=>{let t=y.current;if(!t||t.pointerId!==e.pointerId){S.current?.move(e.pointerId,e.clientX,e.clientY);return}let n=e.clientX-t.startX,r=e.clientY-t.startY;if(S.current?.move(e.pointerId,e.clientX,e.clientY),t.intent===`pending`){let i=Math.abs(n),a=Math.abs(r);if(a>Jo&&a>i){t.intent=`vertical`,y.current=null,S.current?.cancel(e.pointerId);return}if(i>Jo&&i>a){t.intent=`horizontal`,v(!0),b.current=!0,S.current?.cancel(e.pointerId);try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}Xo(l)}}if(t.intent!==`horizontal`)return;e.preventDefault();let i=Math.max(-t.actionWidth,Math.min(0,t.startOffset+n));m(i)}),D=I(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=I(e=>{let t=y.current;y.current=null,S.current?.cancel(e.pointerId),v(!1),m(t?.startOffset??0)}),k=I(()=>{if(!S.current?.consumeClick(l)){if(b.current){b.current=!1;return}if(p!==0){C();return}r()}}),A=I(n=>{d&&(n.preventDefault(),n.stopPropagation(),S.current?.openFromContextMenu(l,()=>{g(!1),a?.(e,t)}))}),j=I(()=>{C(),i?.(e,t)}),M=I(()=>{C(),o?.(e,t)}),N=I(()=>a?.(e,t)),P=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`oc-mobile-group-label-icon`,"aria-hidden":!0,children:(0,$.jsx)(Z,{name:`git-branch`,className:`size-3.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left oc-mobile-entity-title font-semibold text-foreground`,children:s?st(t.name,s):t.name}),(0,$.jsx)(`span`,{className:`typography-small text-muted-foreground tabular-nums`,children:t.sessionCount===1?c(`mobile.sessions.project.sessionsSingle`):c(`mobile.sessions.project.sessionsPlural`,{count:t.sessionCount})}),(0,$.jsx)(Z,{name:`arrow-down-s`,className:X(`size-3.5 text-muted-foreground transition-transform duration-150 motion-reduce:transition-none`,n?`rotate-0`:`-rotate-90`)})]});return(0,$.jsxs)(`div`,{className:`oc-mobile-group-label oc-mobile-worktree-label relative isolate overflow-hidden`,children:[u?(0,$.jsxs)(`div`,{ref:x,className:X(`oc-mobile-worktree-actions absolute inset-y-0 right-0 z-0 flex items-stretch`,_?`transition-none`:`transition-transform duration-150 ease-out`,!w&&`invisible pointer-events-none`),style:{width:`calc(${f} * var(--oc-mobile-worktree-action-width))`,transform:`translate3d(calc(100% + ${p}px), 0, 0)`,willChange:p===0?void 0:`transform`},"aria-hidden":!w,children:[i?(0,$.jsxs)(Ze,{type:`button`,variant:`secondary`,className:`oc-mobile-worktree-action h-full flex-col rounded-none border-0 bg-interactive-selection px-1 text-interactive-selection-foreground hover:bg-interactive-active`,"aria-label":c(`mobile.sessions.newSessionAria`),tabIndex:w?0:-1,onClick:j,children:[(0,$.jsx)(Z,{name:`add`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:c(`sessions.sidebar.project.actions.newSession`)})]}):null,o?(0,$.jsxs)(Ze,{type:`button`,variant:`destructive`,className:`oc-mobile-worktree-action h-full flex-col rounded-none border-0 px-1`,"aria-label":c(`mobile.projectEdit.deleteWorktreeAria`,{label:t.name}),tabIndex:w?0:-1,onClick:M,children:[(0,$.jsx)(Z,{name:`delete-bin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:c(`mobile.projectEdit.deleteWorktreeConfirmButton`)})]}):null]}):null,(0,$.jsxs)(`div`,{className:X(`oc-mobile-worktree-label-content relative z-10 flex min-w-0 flex-1 items-center`,`ease-out motion-reduce:transition-none`,_?`transition-none`:`transition-transform duration-150`),style:{transform:`translate3d(${p}px, 0, 0)`,willChange:p===0?void 0:`transform`},"data-pressed":h?`true`:void 0,children:[(0,$.jsx)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-group-label-trigger oc-mobile-worktree-label-trigger`,"aria-expanded":n,onClick:k,onPointerDown:T,onPointerMove:E,onPointerUp:D,onPointerCancel:O,onContextMenu:A,style:{touchAction:`pan-y`},children:P}),d?(0,$.jsx)(Ze,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-mobile-worktree-more rounded-full text-muted-foreground`,"aria-label":c(`agentManager.detail.actions.worktreeActionsAria`),onClick:N,children:(0,$.jsx)(Z,{name:`more-2`,className:`size-3.5`})}):null]})]})}function es(e){let t=(0,xi.c)(132),{projects:n,pinnedSessions:r,inProgressSessions:i,onAddProject:a,onNewSession:o,onScanQr:s,onSwitchInstance:c,onToggleProject:l,onOpenProjectActions:u,onToggleWorktree:d,onNewWorktreeSession:f,onOpenWorktreeActions:p,onDeleteWorktree:m,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v,className:y}=e,b;t[0]===i?b=t[1]:(b=i===void 0?[]:i,t[0]=i,t[1]=b);let x=b,{t:S}=ee(),[C,w]=Q.useState(!0),[T,E]=Q.useState(!1),[D,O]=Q.useState(!1),[k,A]=Q.useState(``),j;t[2]===k?j=t[3]:(j=k.trim().toLowerCase(),t[2]=k,t[3]=j);let M=j,N=M.length>0,P;t[4]!==M||t[5]!==n?(P=qo(n,M),t[4]=M,t[5]=n,t[6]=P):P=t[6];let F=P,L=I(a),R=I(o),z;t[7]===s?z=t[8]:(z=()=>s?.(),t[7]=s,t[8]=z);let B=I(z),V;t[9]===c?V=t[10]:(V=()=>c?.(),t[9]=c,t[10]=V);let H=I(V),U;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(U=e=>O(e),t[11]=U):U=t[11];let te=I(U),W;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(W=()=>{A(``),E(!1)},t[12]=W):W=t[12];let G=I(W),ne;t[13]!==G||t[14]!==T?(ne=()=>{if(T){G();return}E(!0)},t[13]=G,t[14]=T,t[15]=ne):ne=t[15];let re=I(ne),K;t[16]!==G||t[17]!==l?(K=e=>{G(),e.expanded||l(e)},t[16]=G,t[17]=l,t[18]=K):K=t[18];let ie=I(K),q;t[19]!==G||t[20]!==l||t[21]!==d?(q=(e,t)=>{G(),e.expanded||l(e),t.expanded||d(e,t)},t[19]=G,t[20]=l,t[21]=d,t[22]=q):q=t[22];let ae=I(q),oe;t[23]!==G||t[24]!==h?(oe=e=>{G(),h(e)},t[23]=G,t[24]=h,t[25]=oe):oe=t[25];let J=I(oe),se;t[26]===y?se=t[27]:(se=X(`relative isolate mx-auto flex w-full max-w-[26rem] flex-col gap-5`,y),t[26]=y,t[27]=se);let ce;t[28]===S?ce=t[29]:(ce=S(`mobile.sessions.section.projects`),t[28]=S,t[29]=ce);let le;t[30]!==T||t[31]!==S?(le=S(T?`mobile.sessions.clearSearchAria`:`mobile.sessions.searchAria`),t[30]=T,t[31]=S,t[32]=le):le=t[32];let ue=T?`close`:`search`,de;t[33]===ue?de=t[34]:(de=(0,$.jsx)(Z,{name:ue,className:`size-5`}),t[33]=ue,t[34]=de);let fe;t[35]!==re||t[36]!==T||t[37]!==le||t[38]!==de?(fe=(0,$.jsx)(Ze,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":le,"aria-expanded":T,onClick:re,children:de}),t[35]=re,t[36]=T,t[37]=le,t[38]=de,t[39]=fe):fe=t[39];let pe;t[40]===S?pe=t[41]:(pe=S(`mobile.projects.menu.label`),t[40]=S,t[41]=pe);let me=D?`rotate-45`:`rotate-0`,he;t[42]===me?he=t[43]:(he=X(`size-5 transition-transform duration-150 motion-reduce:transition-none`,me),t[42]=me,t[43]=he);let ge;t[44]===he?ge=t[45]:(ge=(0,$.jsx)(Z,{name:`add`,className:he}),t[44]=he,t[45]=ge);let _e;t[46]!==pe||t[47]!==ge?(_e=(0,$.jsx)(qt,{asChild:!0,children:(0,$.jsx)(Ze,{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":pe,children:ge})}),t[46]=pe,t[47]=ge,t[48]=_e):_e=t[48];let ve;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,$.jsx)(Z,{name:`chat-new`,className:`size-4`}),t[49]=ve):ve=t[49];let ye;t[50]===S?ye=t[51]:(ye=S(`mobile.projects.menu.newChat`),t[50]=S,t[51]=ye);let be;t[52]!==R||t[53]!==ye?(be=(0,$.jsxs)(Jt,{className:`min-h-11`,onSelect:R,children:[ve,ye]}),t[52]=R,t[53]=ye,t[54]=be):be=t[54];let xe;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,$.jsx)(Z,{name:`folder`,className:`size-4`}),t[55]=xe):xe=t[55];let Se;t[56]===S?Se=t[57]:(Se=S(`mobile.projects.menu.newProject`),t[56]=S,t[57]=Se);let Ce;t[58]!==L||t[59]!==Se?(Ce=(0,$.jsxs)(Jt,{className:`min-h-11`,onSelect:L,children:[xe,Se]}),t[58]=L,t[59]=Se,t[60]=Ce):Ce=t[60];let we;t[61]!==B||t[62]!==s||t[63]!==S?(we=s?(0,$.jsxs)(Jt,{className:`min-h-11`,onSelect:B,children:[(0,$.jsx)(Z,{name:`scan-2`,className:`size-4`}),S(`mobile.projects.menu.scanQr`)]}):null,t[61]=B,t[62]=s,t[63]=S,t[64]=we):we=t[64];let Te;t[65]!==H||t[66]!==c||t[67]!==S?(Te=c?(0,$.jsxs)(Jt,{className:`min-h-11`,onSelect:H,children:[(0,$.jsx)(Z,{name:`server`,className:`size-4`}),S(`mobile.projects.menu.switchInstance`)]}):null,t[65]=H,t[66]=c,t[67]=S,t[68]=Te):Te=t[68];let Ee;t[69]!==be||t[70]!==Ce||t[71]!==we||t[72]!==Te?(Ee=(0,$.jsxs)(Kt,{align:`end`,side:`bottom`,className:`min-w-44`,children:[be,Ce,we,Te]}),t[69]=be,t[70]=Ce,t[71]=we,t[72]=Te,t[73]=Ee):Ee=t[73];let Y;t[74]!==te||t[75]!==D||t[76]!==_e||t[77]!==Ee?(Y=(0,$.jsxs)(Gt,{open:D,onOpenChange:te,children:[_e,Ee]}),t[74]=te,t[75]=D,t[76]=_e,t[77]=Ee,t[78]=Y):Y=t[78];let De;t[79]!==fe||t[80]!==Y?(De=(0,$.jsxs)($.Fragment,{children:[fe,Y]}),t[79]=fe,t[80]=Y,t[81]=De):De=t[81];let Oe;t[82]!==ce||t[83]!==De?(Oe=(0,$.jsx)(Wn,{title:ce,trailing:De}),t[82]=ce,t[83]=De,t[84]=Oe):Oe=t[84];let ke;t[85]!==G||t[86]!==T||t[87]!==k||t[88]!==S?(ke=T?(0,$.jsxs)(`div`,{className:`relative mx-1`,role:`search`,children:[(0,$.jsx)(Z,{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)(Ft,{autoFocus:!0,type:`text`,inputMode:`search`,enterKeyHint:`search`,value:k,placeholder:S(`mobile.sessions.search.placeholder`),"aria-label":S(`mobile.sessions.searchAria`),className:X(`h-11 rounded-full pl-9`,k&&`pr-10`),onChange:e=>A(e.target.value),onKeyDown:e=>{e.key===`Escape`&&G()}}),k?(0,$.jsx)(Ze,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute right-1.5 top-1/2 size-8 -translate-y-1/2 rounded-full text-muted-foreground`,"aria-label":S(`mobile.sessions.clearSearchAria`),onClick:()=>A(``),children:(0,$.jsx)(Z,{name:`close`,className:`size-4`})}):null]}):null,t[85]=G,t[86]=T,t[87]=k,t[88]=S,t[89]=ke):ke=t[89];let Ae;t[90]!==x||t[91]!==_||t[92]!==v||t[93]!==g||t[94]!==h||t[95]!==C||t[96]!==r||t[97]!==N||t[98]!==S?(Ae=!N&&(r.length>0||x.length>0)?(0,$.jsx)(qn,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":S(`mobile.sessions.section.pinned`),children:[(0,$.jsx)(Lo,{project:{id:`__pinned__`,name:S(`mobile.sessions.section.pinned`),path:``,icon:`pushpin`,sessionCount:r.length+x.length},expanded:C,embedded:!0,onToggle:()=>w(ns)}),C?(0,$.jsxs)(`div`,{className:`oc-mobile-project-groups`,role:`group`,children:[r.length>0?(0,$.jsx)(`div`,{className:`oc-mobile-labeled-surface-group`,children:(0,$.jsx)(Qo,{sessions:r,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null,x.length>0?(0,$.jsx)(`div`,{className:`oc-mobile-labeled-surface-group`,children:(0,$.jsx)(Qo,{sessions:x,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null]}):null]})}):null,t[90]=x,t[91]=_,t[92]=v,t[93]=g,t[94]=h,t[95]=C,t[96]=r,t[97]=N,t[98]=S,t[99]=Ae):Ae=t[99];let je;t[100]!==L||t[101]!==ie||t[102]!==ae||t[103]!==J||t[104]!==M||t[105]!==_||t[106]!==m||t[107]!==f||t[108]!==u||t[109]!==v||t[110]!==p||t[111]!==g||t[112]!==h||t[113]!==l||t[114]!==d||t[115]!==n.length||t[116]!==N||t[117]!==S||t[118]!==F?(je=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)(Z,{name:`folder-add`,className:`size-6`})}),(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:S(`mobile.sessions.empty.noProjectsTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-xs typography-small text-muted-foreground`,children:S(`mobile.sessions.empty.noProjectsDescription`)}),(0,$.jsxs)(Ze,{type:`button`,size:`lg`,className:`mt-4 min-h-10 rounded-full px-5`,onClick:L,children:[(0,$.jsx)(Z,{name:`folder-add`,className:`size-4`}),S(`sessions.sidebar.header.actions.addProject`)]})]}):N&&F.length===0?(0,$.jsxs)(`section`,{className:`flex min-h-[40dvh] flex-col items-center justify-center px-6 text-center`,children:[(0,$.jsx)(Z,{name:`search`,className:`mb-4 size-6 text-muted-foreground`}),(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:S(`mobile.sessions.empty.searchTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-xs typography-small text-muted-foreground`,children:S(`mobile.sessions.empty.searchDescription`)})]}):F.map(e=>{let t=N||e.expanded,n=e.worktrees.find(ts)??(e.worktrees.length===1&&!e.worktrees[0]?.kind?e.worktrees[0]:void 0),r=e.worktrees.filter(e=>e!==n),i=n?.sessions??[];return(0,$.jsx)(qn,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":e.name,children:[(0,$.jsx)(Lo,{project:e,expanded:t,embedded:!0,highlightQuery:N?M:void 0,onToggle:()=>N?ie(e):l(e),onOpenActions:()=>u(e)}),t?(0,$.jsxs)(`div`,{className:`oc-mobile-project-groups`,role:`group`,"aria-label":e.name,children:[i.length>0?(0,$.jsx)(`div`,{className:`oc-mobile-labeled-surface-group`,children:(0,$.jsx)(Qo,{sessions:i,highlightQuery:N?M:void 0,onSelectSession:N?J:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null,r.map(t=>{let n=N||!!t.expanded;return(0,$.jsx)(Zn,{className:`oc-mobile-worktree-group`,ariaLabel:t.name,label:(0,$.jsx)($o,{project:e,worktree:t,expanded:n,highlightQuery:N?M:void 0,onToggle:()=>N?ae(e,t):d(e,t),onNewSession:f,onOpenActions:N?void 0:p,onDelete:N?void 0:m}),children:n&&t.sessions.length>0?(0,$.jsx)(Qo,{sessions:t.sessions,highlightQuery:N?M:void 0,onSelectSession:N?J:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v}):null},t.id)})]}):null]})},e.id)}),t[100]=L,t[101]=ie,t[102]=ae,t[103]=J,t[104]=M,t[105]=_,t[106]=m,t[107]=f,t[108]=u,t[109]=v,t[110]=p,t[111]=g,t[112]=h,t[113]=l,t[114]=d,t[115]=n.length,t[116]=N,t[117]=S,t[118]=F,t[119]=je):je=t[119];let Me;t[120]===S?Me=t[121]:(Me=S(`sessions.sidebar.header.actions.addProject`),t[120]=S,t[121]=Me);let Ne;t[122]!==L||t[123]!==Me?(Ne=(0,$.jsx)(`button`,{type:`button`,className:`sr-only`,onClick:L,children:Me}),t[122]=L,t[123]=Me,t[124]=Ne):Ne=t[124];let Pe;return t[125]!==se||t[126]!==Oe||t[127]!==ke||t[128]!==Ae||t[129]!==je||t[130]!==Ne?(Pe=(0,$.jsxs)(`main`,{className:se,children:[Oe,ke,Ae,je,Ne]}),t[125]=se,t[126]=Oe,t[127]=ke,t[128]=Ae,t[129]=je,t[130]=Ne,t[131]=Pe):Pe=t[131],Pe}function ts(e){return e.kind===`main`}function ns(e){return!e}function rs(e){let t=(0,xi.c)(13),{icon:n,label:r,onClick:i,destructive:a,disabled:o,spinning:s}=e,c=a!==void 0&&a,l=o!==void 0&&o,u=s!==void 0&&s,d;t[0]===i?d=t[1]:(d=()=>{ve(`light`),i()},t[0]=i,t[1]=d);let f=I(d),p=c?`destructive`:`ghost`,m=u?`size-5 animate-spin`:`size-5`,h;t[2]!==n||t[3]!==m?(h=(0,$.jsx)(Z,{name:n,className:m}),t[2]=n,t[3]=m,t[4]=h):h=t[4];let g;t[5]===r?g=t[6]:(g=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[5]=r,t[6]=g);let _;return t[7]!==l||t[8]!==f||t[9]!==p||t[10]!==h||t[11]!==g?(_=(0,$.jsxs)(Ze,{type:`button`,variant:p,size:`lg`,className:`h-auto min-h-14 w-full justify-start gap-3 rounded-none supports-[corner-shape:squircle]:rounded-none px-4 leading-6 border-b border-[var(--surface-subtle)] last:border-b-0 active:bg-interactive-active dark:active:bg-interactive-active`,"data-mobile-press-feedback":`none`,disabled:l,onClick:f,children:[h,g]}),t[7]=l,t[8]=f,t[9]=p,t[10]=h,t[11]=g,t[12]=_):_=t[12],_}function is(e,t,n){return e.reduce((e,t)=>{let n=!!t.separated,r=e.at(-1);return r?.separated===n?r.items.push(t):e.push({separated:n,items:[t]}),e},[]).map(e=>(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl bg-[var(--surface-muted)]`,"data-mobile-action-group":e.separated?`separated`:`standard`,children:e.items.map(e=>(0,$.jsx)(rs,{icon:e.icon,label:or(e,t),onClick:n(e.onClick),destructive:e.destructive,disabled:e.disabled,spinning:e.spinning},e.id))},e.items[0]?.id))}function as(e){let t=(0,xi.c)(46),{open:n,target:r,actions:i,onOpenChange:a,refreshTranscriptDisabled:o,refreshTranscriptSpinning:s}=e,c=o!==void 0&&o,l=s!==void 0&&s,{t:u}=ee(),d;t[0]===a?d=t[1]:(d=e=>()=>{a(!1),e?.()},t[0]=a,t[1]=d);let f=d,p;bb0:{if(!r){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[2]=e):e=t[2],p=e;break bb0}if(r.kind===`session`){let e;t[3]!==i.onArchive||t[4]!==i.onCopyLink||t[5]!==i.onDelete||t[6]!==i.onRefreshTranscript||t[7]!==i.onRename||t[8]!==i.onShare||t[9]!==i.onTogglePin||t[10]!==i.onUnshare||t[11]!==c||t[12]!==l||t[13]!==r.pinned||t[14]!==r.shared?(e=Vr({pinned:r.pinned,shared:r.shared,onRename:i.onRename,onTogglePin:i.onTogglePin,onShare:i.onShare,onCopyLink:i.onCopyLink,onUnshare:i.onUnshare,onRefreshTranscript:i.onRefreshTranscript,onArchive:i.onArchive,onDelete:i.onDelete,refreshTranscriptDisabled:c,refreshTranscriptSpinning:l}),t[3]=i.onArchive,t[4]=i.onCopyLink,t[5]=i.onDelete,t[6]=i.onRefreshTranscript,t[7]=i.onRename,t[8]=i.onShare,t[9]=i.onTogglePin,t[10]=i.onUnshare,t[11]=c,t[12]=l,t[13]=r.pinned,t[14]=r.shared,t[15]=e):e=t[15],p=e;break bb0}if(r.kind===`project`){let e;t[16]!==i.onCloseProject||t[17]!==i.onEditProject||t[18]!==i.onNewSession||t[19]!==i.onNewWorktree||t[20]!==i.onSyncSessions||t[21]!==r.gitRepository?(e=Sr({gitRepository:r.gitRepository,onNewSession:i.onNewSession,onNewWorktree:i.onNewWorktree,onSyncSessions:i.onSyncSessions,onEditProject:i.onEditProject,onCloseProject:i.onCloseProject}),t[16]=i.onCloseProject,t[17]=i.onEditProject,t[18]=i.onNewSession,t[19]=i.onNewWorktree,t[20]=i.onSyncSessions,t[21]=r.gitRepository,t[22]=e):e=t[22],p=e;break bb0}let e;t[23]!==i.onDeleteWorktree||t[24]!==i.onNewSession?(e=hr({onNewSession:i.onNewSession,onDeleteWorktree:i.onDeleteWorktree}),t[23]=i.onDeleteWorktree,t[24]=i.onNewSession,t[25]=e):e=t[25],p=e}let m=p;if(!r)return null;let h;t[26]===r.title?h=t[27]:(h=(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold`,children:r.title}),t[26]=r.title,t[27]=h);let g=r.title,_;t[28]===u?_=t[29]:(_=u(`mobile.surface.closeAria`),t[28]=u,t[29]=_);let v;t[30]===u?v=t[31]:(v=u(`mobile.sessions.sheet.resizeAria`),t[30]=u,t[31]=v);let y;t[32]!==m||t[33]!==f||t[34]!==u?(y=is(m,u,f),t[32]=m,t[33]=f,t[34]=u,t[35]=y):y=t[35];let b;t[36]===y?b=t[37]:(b=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-y-auto overscroll-contain px-3 pb-3`,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-5`,"data-page-scroll-lock":`true`,children:y})}),t[36]=y,t[37]=b);let x;return t[38]!==a||t[39]!==n||t[40]!==b||t[41]!==h||t[42]!==_||t[43]!==v||t[44]!==r.title?(x=(0,$.jsx)(Et,{id:`mobile-row-actions-sheet`,open:n,onOpenChange:a,title:h,ariaLabel:g,closeAriaLabel:_,resizeAriaLabel:v,fitContent:!0,children:b}),t[38]=a,t[39]=n,t[40]=b,t[41]=h,t[42]=_,t[43]=v,t[44]=r.title,t[45]=x):x=t[45],x}var os=`__show_more__:`,ss=`__show_fewer__:`,cs=e=>e.startsWith(os),ls=e=>e.startsWith(ss),us=e=>cs(e)||ls(e),ds=e=>{let t=cs(e)?os:ls(e)?ss: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)}},fs=e=>e.parentID??null,ps=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),ms=e=>{let t=e;return ps(t.directory??t.project?.worktree??null)},hs=(e,t)=>{if(t?.trim())return t.trim();let n=ps(e);if(!n)return``;let r=n.split(`/`).filter(Boolean);return r[r.length-1]||n},gs=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},_s=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))},vs=e=>{let t=e.time?.archived;return typeof t==`number`&&t>0},ys=(e,t)=>e.worktrees.find(e=>ps(e.path)===t)??null,bs=(e,t)=>{let n=t?.trim();return n?`${e} · ${n}`:e},xs=(e,t)=>Ir(e,{pinnedSessionIds:t,omitPinnedSessions:!0}).map(e=>e.session);function Ss(){let e=(0,xi.c)(82),{t}=ee(),n=me(),r=Te(Hs),i=Te(Vs),a=xe(Bs),o=xe(zs),s=w(Rs),c=ke(Ls),l=ke(Is),u=yt(Fs),d=Ie(),f=Pa(Ps),p=Pa(Ns),m=De(Ms),h;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=new Map,e[0]=h):h=e[0];let[g,_]=Q.useState(h),v=lr(),y;e[1]!==c||e[2]!==v?(y=_r(v,c),e[1]=c,e[2]=v,e[3]=y):y=e[3];let b=y,x;if(e[4]!==a||e[5]!==u||e[6]!==l){let t;e[8]!==u||e[9]!==l?(t=e=>{let t=ps(e.path);return{id:e.id,label:hs(t,e.label),path:t,icon:e.icon,worktrees:gt(u[e.id],l.get(t)??[])}},e[8]=u,e[9]=l,e[10]=t):t=e[10],x=a.map(t),e[4]=a,e[5]=u,e[6]=l,e[7]=x}else x=e[7];let S=x,C;if(e[11]!==r||e[12]!==n){let t=new Map(n.map(js));C=r.map(e=>{let n=t.get(e.id);return n?Fe(n,e):e});let i=new Set(C.map(As));for(let e of n)i.has(e.id)||C.push(e);e[11]=r,e[12]=n,e[13]=C}else C=e[13];let T=C,E;e[14]!==S||e[15]!==T||e[16]!==l?(E=Dr(T,S.map(ks),l,!1),e[14]=S,e[15]=T,e[16]=l,e[17]=E):E=e[17];let D=E,O;if(e[18]!==o||e[19]!==D||e[20]!==d||e[21]!==S||e[22]!==T){let t;e[24]===o?t=e[25]:(t=e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===o,latestActivity:0}),e[24]=o,e[25]=t),O=S.map(t);let n=new Map(O.map(Os)),r=Ds;for(let e of O){r(e,e.project.path,null);for(let t of e.project.worktrees)r(e,t.path,t)}for(let e of T){let t=D.bySessionId.get(e.id);if(!t)continue;let i=n.get(t.projectId);if(!i)continue;let a=t.kind===`worktree`?ys(i.project,t.scopeDirectory):null;(a?r(i,a.path,a):r(i,i.project.path,null)).sessions.push(e)}for(let e of O)for(let t of e.buckets){t.sessions.sort(Es);let n=xs(t.sessions,d);e.totalSessions+=n.length;for(let n of t.sessions){let t=gs(n);t>e.latestActivity&&(e.latestActivity=t)}}e[18]=o,e[19]=D,e[20]=d,e[21]=S,e[22]=T,e[23]=O}else O=e[23];let k=O,A;if(e[26]!==T){A=new Map;for(let e of T)A.set(e.id,e);e[26]=T,e[27]=A}else A=e[27];let j=A,M;if(e[28]!==S){M=new Map;for(let e of S)M.set(e.id,e);e[28]=S,e[29]=M}else M=e[29];let N=M,P,F;if(e[30]!==c||e[31]!==D||e[32]!==d||e[33]!==S||e[34]!==v||e[35]!==T||e[36]!==t||e[37]!==m){let n=new Map(S.map(Ts)),r=t(`mobile.sessions.untitled`),i=(e,t)=>{let i=D.bySessionId.get(e.id),a=i?n.get(i.projectId):void 0;if(!a)return[];let o=i?.kind===`worktree`?ys(a,i.scopeDirectory):null;return[{id:e.id,directory:ms(e),title:e.title?.trim()||r,subtitle:bs(a.label,o?.branch),activityLabel:_s(gs(e))||void 0,unread:(m[e.id]??0)>0,pinned:t,archived:vs(e),active:c===e.id}]};P=xr(T,d).flatMap(e=>i(e,!0)),F=Nr(T,d,v,m).flatMap(e=>i(e,!1)),e[30]=c,e[31]=D,e[32]=d,e[33]=S,e[34]=v,e[35]=T,e[36]=t,e[37]=m,e[38]=P,e[39]=F}else P=e[38],F=e[39];let I;e[40]!==P||e[41]!==F?(I={pinnedSessions:P,inProgressSessions:F},e[40]=P,e[41]=F,e[42]=I):I=e[42];let{pinnedSessions:L,inProgressSessions:R}=I,z;if(e[43]!==d||e[44]!==k){z=new Map;for(let e of k){let t=e.project.worktrees.length>0;for(let n of e.buckets){let r=xs(n.sessions,d).length;z.set(`${e.project.id}::${n.key}`,{path:n.path,rootCount:r,hasWorktrees:t})}}e[43]=d,e[44]=k,e[45]=z}else z=e[45];let B=z,V;if(e[46]!==i||e[47]!==b||e[48]!==s||e[49]!==c||e[50]!==d||e[51]!==f||e[52]!==k||e[53]!==t||e[54]!==m||e[55]!==g||e[56]!==p){let n=ps(s);V=k.map(e=>{let r=f[e.project.id]??!0,a=Br(),o=e.project.icon?At[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=xs(r.sessions,d),f=Ir(r.sessions,{pinnedSessionIds:d,omitPinnedSessions:!1}).map(ws),h=e=>{let n=fs(e),i=(m[e.id]??0)>0&&!n;return{id:e.id,directory:r.path,title:e.title?.trim()||t(`mobile.sessions.untitled`),activityLabel:_s(gs(e))||void 0,unread:i,pinned:d.has(e.id),archived:vs(e),active:c===e.id}},_=pr(u,l,b).map(h),v=u.length-_.length,y=i.get(ps(r.path)),x=y?.hasMore===!0,S=u.length>a&&l>a,C=[..._];S&&C.push({id:`${ss}${e.project.id}::${r.key}`,kind:`pagination`,title:t(`sessions.sidebar.group.showFewer`)}),(v>0||x)&&C.push({id:`${os}${e.project.id}::${r.key}`,kind:`pagination`,title:t(`sessions.sidebar.group.showMore`),subtitle:y?.loadingMore?`…`:void 0});let w=ps(r.path),T=!!(e.isActive&&n&&w&&(n===w||n.startsWith(`${w}/`))),E=r.worktree==null;return{id:r.key,name:E?t(`mobile.sessions.mainWorkspace`):r.label,path:r.path,kind:E?`main`:`worktree`,active:T,expanded:E?!0:s,sessionCount:u.length,sessions:C,catalogSessions:f.map(h)}});return{id:e.project.id,name:e.project.label,path:e.project.path,icon:o,sessionCount:e.totalSessions,activityLabel:_s(e.latestActivity)||void 0,active:e.isActive,expanded:r,worktrees:s}}),e[46]=i,e[47]=b,e[48]=s,e[49]=c,e[50]=d,e[51]=f,e[52]=k,e[53]=t,e[54]=m,e[55]=g,e[56]=p,e[57]=V}else V=e[57];let H=V,U;e[58]===B?U=e[59]:(U=e=>{for(let[t,n]of B)if(t.startsWith(`${e}::`))return n.hasWorktrees;return!1},e[58]=B,e[59]=U);let te=U,W;e[60]===B?W=e[61]:(W=(e,t)=>B.get(`${e}::${t}`)?.rootCount??0,e[60]=B,e[61]=W);let G=W,ne=Cs,re;e[62]===g?re=e[63]:(re=(e,t)=>{let n=`${e}::${t}`;return g.get(n)??ne(e)},e[62]=g,e[63]=re);let K=re,ie;e[64]===B?ie=e[65]:(ie=(e,t)=>B.get(`${e}::${t}`)?.path??null,e[64]=B,e[65]=ie);let q=ie,ae;e[66]!==B||e[67]!==g?(ae=(e,t)=>{let n=`${e}::${t}`,r=B.get(n),i=Br(),a=gr(),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=ps(c);if(!l)return;let u=Te.getState().activePaginationByDirectory.get(l);u?.hasMore&&!u.loadingMore&&be(l)},e[66]=B,e[67]=g,e[68]=ae):ae=e[68];let oe=ae,J;e[69]===Symbol.for(`react.memo_cache_sentinel`)?(J=(e,t)=>{let n=`${e}::${t}`;_(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t})},e[69]=J):J=e[69];let se=J,ce;return e[70]!==q||e[71]!==G||e[72]!==K||e[73]!==H||e[74]!==R||e[75]!==L||e[76]!==te||e[77]!==N||e[78]!==j||e[79]!==T||e[80]!==oe?(ce={projects:H,pinnedSessions:L,inProgressSessions:R,sessionById:j,projectMetaById:N,allSessions:T,projectHasWorktrees:te,getBucketRootCount:G,getBucketVisibleCount:K,getBucketPageSize:ne,getBucketDirectory:q,showMoreBucketSessions:oe,resetBucketVisibleCount:se},e[70]=q,e[71]=G,e[72]=K,e[73]=H,e[74]=R,e[75]=L,e[76]=te,e[77]=N,e[78]=j,e[79]=T,e[80]=oe,e[81]=ce):ce=e[81],ce}function Cs(e){return Br()}function ws(e){return e.session}function Ts(e){return[e.id,e]}function Es(e,t){return ie(t)-ie(e)}function Ds(e,t,n){let r=ps(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||hs(r),path:r,worktree:n,sessions:[]},e.buckets.push(a)),a}function Os(e){return[e.project.id,e]}function ks(e){return{id:e.id,normalizedPath:e.path}}function As(e){return e.id}function js(e){return[e.id,e]}function Ms(e){return e.index.session.unseenCount}function Ns(e){return e.worktreeExpanded}function Ps(e){return e.projectExpanded}function Fs(e){return e.orderByProject}function Is(e){return e.availableWorktreesByProject}function Ls(e){return e.currentSessionId}function Rs(e){return e.currentDirectory}function zs(e){return e.activeProjectId}function Bs(e){return e.projects}function Vs(e){return e.activePaginationByDirectory}function Hs(e){return e.activeSessions}var Us=(e,t,n)=>e?.kind===`project`&&e.project.id===t?{...e,isGitRepository:n}:e;function Ws({onOpenChat:e,onAddProject:t,onNewSession:n,onScanQr:r,onSwitchInstance:i,className:a}){let{t:o}=ee(),{git:s}=un(),c=Ss(),l=Pa(e=>e.setProjectExpanded),u=Pa(e=>e.setWorktreeExpanded),d=Me(),f=Ie(),m=ke(e=>e.archiveSessions),h=ke(e=>e.updateSessionTitle),g=ke(e=>e.requestSessionSmartTitle),_=ke(e=>e.shareSession),v=ke(e=>e.unshareSession),y=ke(e=>e.openNewSessionDraft),b=Le(e=>e.openDraft),x=Le(e=>e.openSession),S=xe(e=>e.projects),C=xe(e=>e.setActiveProjectIdOnly),w=xe(e=>e.removeProject),T=an(),[E,D]=Q.useState(null),[O,k]=Q.useState(!1),[A,j]=Q.useState(null),[M,N]=Q.useState(null),[P,F]=Q.useState(null),[L,z]=Q.useState(``),[B,V]=Q.useState(!1),[H,U]=Q.useState(!1),[te,W]=Q.useState(null),[G,ne]=Q.useState(null),[re,K]=Q.useState(null),ie=E?.kind===`session`?E.session.id:``,q=_e(ie),ae=q?.type===`busy`||q?.type===`retry`,oe=E?.kind===`session`?ms(E.session):``,J=!!ie&&re===ie,se=!oe||J||ae,ce=I(e=>{let t=new Map;for(let e of c.allSessions){let n=fs(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}),le=I(()=>{k(!1),D(null)}),ue=I(t=>{if(us(t.id)){let e=ds(t.id);if(!e)return;e.kind===`more`?c.showMoreBucketSessions(e.projectId,e.bucketKey):c.resetBucketVisibleCount(e.projectId,e.bucketKey);return}let n=c.sessionById.get(t.id),r=n&&ms(n)||null;e({sessionId:t.id,directory:r})}),de=I(e=>{us(e.id)||d(e.id)}),fe=I(async e=>{if(us(e.id))return;let t=ce(e.id),{archivedIds:n,failedIds:r}=await m(t);n.length>0&&ar({sessionIds:n,message:n.length===1?o(`sessions.sidebar.session.archive.success`):o(`sessions.sidebar.bulkActions.archivedPlural`,{count:n.length}),undoLabel:o(`sessions.sidebar.undo`),settingsLabel:o(`settings.openchamber.archivedSessions.actions.view`),undoFailedMessage:n.length===1?o(`sessions.sidebar.session.archive.undoFailed`):o(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:n.length})}),r.length>0&&Y.error(r.length===1?o(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):o(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}),pe=I(()=>{if(!E||E.kind!==`session`)return;let e=E.session,t=ms(e),n=q?.type??`idle`;!t||re===e.id||n===`busy`||n===`retry`||(K(e.id),(async()=>{try{await T.refreshSessionTranscript(e.id,{directory:t}),Y.success(o(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{Y.error(o(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{K(t=>t===e.id?null:t)}})())}),me=I(e=>{if(us(e.id))return;let t=c.sessionById.get(e.id);t&&(D({kind:`session`,session:t}),k(!0))}),he=I(e=>{l(e.id,!e.expanded)}),ge=I((e,t)=>{u(`${e.id}::${t.id}`,!t.expanded)}),ve=I((e,t)=>{C(e.id),b({selectedProjectId:e.id,directoryOverride:t,preserveDirectoryOverride:!0})}),ye=I(()=>{if(n){n();return}y()}),be=I(e=>{let t=c.projectMetaById.get(e.id);t&&(D({kind:`project`,project:t,isGitRepository:!1}),k(!0),s.checkIsGitRepository(t.path).then(e=>{D(n=>Us(n,t.id,e))}).catch(()=>{D(e=>Us(e,t.id,!1))}))}),Se=I((e,t)=>{let n=p(t);return n?e.worktrees.find(e=>p(e.path)===n)||((ke.getState().availableWorktreesByProject.get(e.path)??[]).find(e=>p(e.path)===n)??null):null}),Ce=I((e,t)=>{let n=c.projectMetaById.get(e.id);n&&ve(n,t.path)}),Te=I((e,t)=>{let n=c.projectMetaById.get(e.id);n&&(D({kind:`worktree`,project:n,worktreePath:t.path,worktreeName:t.name}),k(!0))}),Ee=I((e,t)=>{let n=c.projectMetaById.get(e.id);if(!n)return;let r=Se(n,t.path);if(!r){Y.error(o(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}ne({project:n,worktree:r})}),De=I(e=>{W(e),C(e),U(!0)}),Oe=I(e=>{(async()=>{let t=e.worktrees;try{t=(await kt({id:e.id,path:e.path})).worktrees}catch(n){console.warn(`[MobileProjectsHome] Worktree refresh before session sync failed:`,n),t=ke.getState().availableWorktreesByProject.get(e.path)??e.worktrees}await we([e.path,...t.map(e=>e.path)],c.allSessions)})()}),Ae=I((e,t)=>{let n=te;if(U(!1),W(null),t?.sessionId){x({sessionId:t.sessionId,directory:e});return}b({selectedProjectId:n,directoryOverride:e,preserveDirectoryOverride:!0})}),je=I(async e=>{try{if(!(await _(e.id))?.share?.url){Y.error(o(`sessions.sidebar.session.share.error`));return}Y.success(o(`sessions.sidebar.session.share.successTitle`),{description:o(`sessions.sidebar.session.share.successDescription`)})}catch{Y.error(o(`sessions.sidebar.session.share.error`))}}),Ne=I(async e=>{if((await R(e)).ok){Y.success(o(`sessions.sidebar.session.menu.copied`));return}Y.error(o(`sessions.sidebar.session.share.copyUrlError`))}),Pe=I(async e=>{try{if(await v(e)){Y.success(o(`sessions.sidebar.session.unshare.success`));return}Y.error(o(`sessions.sidebar.session.unshare.error`))}catch{Y.error(o(`sessions.sidebar.session.unshare.error`))}}),Fe=I(e=>{let t=ce(e.id);kr({sessionIds:t,message:t.length===1?o(`sessions.sidebar.session.delete.success`):o(`sessions.sidebar.bulkActions.deletedPlural`,{count:t.length}),undoLabel:o(`sessions.sidebar.undo`),commitFailedMessage:o(`sessions.sidebar.session.delete.error`)})}),Re=I(async()=>{if(!P)return;let e=L.trim();if(e)try{await h(P.id,e),F(null),z(``)}catch{Y.error(o(`sessions.sidebar.session.menu.rename`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}}),ze=I(async()=>{if(!P||B)return;let e=P.id;F(null),z(``),V(!0);try{await g(e)}catch{Y.error(o(`sessions.sidebar.session.rename.smartTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{V(!1)}}),Be=Q.useMemo(()=>E?E.kind===`session`?{kind:`session`,title:E.session.title?.trim()||o(`mobile.sessions.untitled`),pinned:f.has(E.session.id),shared:!!E.session.share?.url}:E.kind===`project`?{kind:`project`,title:E.project.label,gitRepository:E.isGitRepository}:{kind:`worktree`,title:E.worktreeName}:null,[E,f,o]),Ve=Q.useMemo(()=>{if(!E)return{};if(E.kind===`session`){let e=E.session;return{onRename:()=>{z(e.title?.trim()||o(`mobile.sessions.untitled`)),F(e)},onTogglePin:()=>d(e.id),onShare:e.share?.url?void 0:()=>{je(e)},onCopyLink:e.share?.url?()=>{Ne(e.share.url)}:void 0,onUnshare:e.share?.url?()=>{Pe(e.id)}:void 0,onRefreshTranscript:pe,onArchive:()=>{fe({id:e.id,title:e.title?.trim()||o(`mobile.sessions.untitled`)})},onDelete:()=>Fe(e)}}if(E.kind===`project`){let e=E.project;return{onNewSession:()=>ve(e,e.path),onNewWorktree:()=>De(e.id),onSyncSessions:()=>Oe(e),onEditProject:()=>j(e.id),onCloseProject:()=>N(e)}}let{project:e,worktreePath:t}=E;return{onNewSession:()=>ve(e,t),onDeleteWorktree:()=>{let n=Se(e,t);if(!n){Y.error(o(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}ne({project:e,worktree:n})}}},[E,fe,Ne,Fe,pe,De,Oe,je,Pe,Se,ve,o,d]),He=Q.useMemo(()=>{if(!A)return null;let e=S.find(e=>e.id===A),t=c.projectMetaById.get(A);if(!e||!t)return null;let n=E?.kind===`project`&&E.project.id===A?E.isGitRepository:t.worktrees.length>0;return{id:e.id,label:e.label?.trim()||t.label,path:p(e.path)||t.path,icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:n,worktrees:t.worktrees}},[E,A,c.projectMetaById,S]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(es,{className:a,projects:c.projects,pinnedSessions:c.pinnedSessions,inProgressSessions:c.inProgressSessions,onAddProject:t,onNewSession:ye,onScanQr:r,onSwitchInstance:i,onToggleProject:he,onOpenProjectActions:be,onToggleWorktree:ge,onNewWorktreeSession:Ce,onOpenWorktreeActions:Te,onDeleteWorktree:Ee,onSelectSession:ue,onPinSession:de,onArchiveSession:e=>{fe(e)},onOpenSessionActions:me}),(0,$.jsx)(as,{open:O,target:Be,actions:Ve,refreshTranscriptDisabled:se,refreshTranscriptSpinning:J,onOpenChange:e=>{e?k(!0):le()}}),(0,$.jsx)(ln,{open:H,projectId:te,onOpenChange:e=>{U(e),e||W(null)},onWorktreeCreated:Ae}),G?(0,$.jsx)(mr,{open:!0,project:{id:G.project.id,path:G.project.path},worktree:G.worktree,onClose:()=>ne(null)}):null,(0,$.jsx)(rn,{open:!!M,title:o(`sessions.sidebar.project.actions.closeProject`),onClose:()=>N(null),closeAriaLabel:o(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Ze,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>N(null),children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Ze,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!M)return;let e=M;N(null),w(e.id),Y.success(o(`mobile.sessions.toast.projectRemoved`,{label:e.label}))},children:o(`mobile.sessions.confirmRemoveProject`)})]}),children:(0,$.jsx)(`p`,{className:`px-1 py-1 typography-ui-body text-foreground`,children:o(`mobile.projects.closeConfirmMessage`,{title:M?.label??``})})}),(0,$.jsx)(rn,{open:!!P,title:o(`sessions.sidebar.session.menu.rename`),onClose:()=>{B||(F(null),z(``))},closeAriaLabel:o(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Ze,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:B,onClick:()=>{F(null),z(``)},children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Ze,{type:`button`,variant:`default`,className:`flex-1`,disabled:!L.trim()||B,onClick:()=>void Re(),children:o(`sessions.sidebar.session.rename.save`)})]}),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-3 px-1 py-1`,onSubmit:e=>{e.preventDefault(),Re()},children:[(0,$.jsx)(Ft,{value:L,onChange:e=>z(e.target.value),autoFocus:!0,className:`h-12`,disabled:B}),(0,$.jsxs)(Ze,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:B,onClick:()=>void ze(),children:[B?(0,$.jsx)(Z,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(Z,{name:`ai-generate-2`,className:`size-4`}),o(`sessions.sidebar.session.rename.smartTitle`)]})]})}),(0,$.jsx)(sr,{open:A!==null,project:He,onClose:()=>j(null)})]})}function Gs(e){let t=(0,xi.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=X(`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)(Kn,{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 Ks(e){let t=(0,xi.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=[...Jn],t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,$.jsx)(Xr,{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)(Kn,{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 qs(e){let t=(0,xi.c)(92),{onAddProject:n,onScanQr:r,onSwitchInstance:i,onEnableAssistants:a,instancesPage:o,instancesSecondaryPage:s,parentSessionTarget:c,registerSecondaryBackHandler:l,scheduledContent:u,renderChat:d,className:f}=e,m=c===void 0?null:c,{t:h}=ee(),g=Le(),_=Le(ic),v=Le(rc),y=Le(nc),b=Le(tc),x=Le(ec),S=Le($s),C=Le(Qs),w=Le(Zs),T=Le(Xs),E;t[0]===_?E=t[1]:(E=e=>{_(e)},t[0]=_,t[1]=E);let D=I(E),O;t[2]===v?O=t[3]:(O=e=>{v(e)},t[2]=v,t[3]=O);let k=I(O),A;t[4]===x?A=t[5]:(A=()=>{x()},t[4]=x,t[5]=A);let j=I(A),M;t[6]===y?M=t[7]:(M=()=>{y()},t[6]=y,t[7]=M);let N=I(M),P;t[8]===b?P=t[9]:(P=e=>{b(e)},t[8]=b,t[9]=P);let F=I(P),L=Q.useRef(null),[R,z]=Q.useState(!1),B;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>{L.current=e},t[10]=B):B=t[10];let V=I(B),H;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(H=e=>{z(e)},t[11]=H):H=t[11];let U=I(H),te;t[12]!==j||t[13]!==S?(te=()=>{if(L.current?.())return!0;let e=Le.getState().secondary;return e?.kind===`chat`&&e.routes.length>1?(S(),!0):e?(j(),!0):!1},t[12]=j,t[13]=S,t[14]=te):te=t[14];let W=I(te),G=g.secondary!==null,ne;t[15]!==W||t[16]!==l?(ne=()=>{if(l)return l(()=>W()),()=>l(null)},t[15]=W,t[16]=l,t[17]=ne):ne=t[17];let re;t[18]!==W||t[19]!==l||t[20]!==G?(re=[l,G,W],t[18]=W,t[19]=l,t[20]=G,t[21]=re):re=t[21],Q.useEffect(ne,re);let K=ke(Ys),ie;t[22]===K?ie=t[23]:(ie=e=>K?e.getDirectoryForSession(K):null,t[22]=K,t[23]=ie);let q=ke(ie),ae,oe;t[24]!==q||t[25]!==K||t[26]!==w||t[27]!==T?(ae=()=>{let e=Le.getState().secondary;if(e?.kind===`draft`&&K){w({sessionId:K,directory:q});return}if(e?.kind!==`chat`||!K||ze({sessionId:K,directory:q})===`internal`)return;let t=e.routes.at(-1);(t?.sessionId!==K||p(t.directory)!==p(q))&&T({sessionId:K,directory:q})},oe=[q,K,w,T],t[24]=q,t[25]=K,t[26]=w,t[27]=T,t[28]=ae,t[29]=oe):(ae=t[28],oe=t[29]),Q.useEffect(ae,oe);let J,se;t[30]!==K||t[31]!==m||t[32]!==C?(J=()=>{let e=Le.getState().secondary;if(e?.kind!==`chat`||!m)return;let t=e.routes.at(-1);!t||t.sessionId!==K||C({sessionId:m.id,directory:m.directory})},se=[K,m,C],t[30]=K,t[31]=m,t[32]=C,t[33]=J,t[34]=se):(J=t[33],se=t[34]),Q.useEffect(J,se);let ce;t[35]!==U||t[36]!==V||t[37]!==u?(ce=typeof u==`function`?u(V,U):u,t[35]=U,t[36]=V,t[37]=u,t[38]=ce):ce=t[38];let le=ce,ue;t[39]!==N||t[40]!==n||t[41]!==r||t[42]!==i||t[43]!==k?(ue=(0,$.jsx)(Ws,{onOpenChat:k,onAddProject:n,onNewSession:N,onScanQr:r,onSwitchInstance:i}),t[39]=N,t[40]=n,t[41]=r,t[42]=i,t[43]=k,t[44]=ue):ue=t[44];let de;t[45]!==a||t[46]!==F?(de=(0,$.jsx)(lo,{onEnable:a,onOpenAssistant:F}),t[45]=a,t[46]=F,t[47]=de):de=t[47];let fe;t[48]===le?fe=t[49]:(fe=(0,$.jsx)(Gs,{showHeader:!1,children:le}),t[48]=le,t[49]=fe);let pe;t[50]===o?pe=t[51]:(pe=(0,$.jsx)(Ks,{instancesPage:o}),t[50]=o,t[51]=pe);let me;t[52]!==ue||t[53]!==de||t[54]!==fe||t[55]!==pe?(me={projects:ue,assistant:de,scheduled:fe,settings:pe},t[52]=ue,t[53]=de,t[54]=fe,t[55]=pe,t[56]=me):me=t[56];let he=me,ge=g.secondary?.kind??null,_e;bb0:{if(!ge){_e=null;break bb0}if(ge===`assistant`){let e;t[57]===h?e=t[58]:(e=h(`assistants.title`),t[57]=h,t[58]=e);let n;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(ri,{activeOverride:!0,onMobileBack:Js}),t[59]=n):n=t[59];let r;t[60]!==W||t[61]!==e?(r=[{key:`assistant-secondary`,depth:1,ariaLabel:e,onBack:W,content:n}],t[60]=W,t[61]=e,t[62]=r):r=t[62],_e=r;break bb0}if(ge===`instances`){let e;t[63]===h?e=t[64]:(e=h(`mobile.settings.switchInstance`),t[63]=h,t[64]=e);let n;t[65]!==W||t[66]!==s||t[67]!==e?(n=[{key:`instances-secondary`,depth:1,ariaLabel:e,onBack:W,content:s}],t[65]=W,t[66]=s,t[67]=e,t[68]=n):n=t[68],_e=n;break bb0}if(g.secondary?.kind===`draft`){let e;t[69]===h?e=t[70]:(e=h(`mobile.nav.secondaryPageAria`),t[69]=h,t[70]=e);let n;t[71]===d?n=t[72]:(n=d({sessionId:``,directory:null,viewKey:`chat-primary`,active:!0}),t[71]=d,t[72]=n);let r;t[73]!==W||t[74]!==e||t[75]!==n?(r=[{key:`chat-primary`,depth:1,ariaLabel:e,onBack:W,content:n}],t[73]=W,t[74]=e,t[75]=n,t[76]=r):r=t[76],_e=r;break bb0}if(g.secondary?.kind!==`chat`){let e;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[77]=e):e=t[77],_e=e;break bb0}let e=g.secondary.routes,n;if(t[78]!==W||t[79]!==d||t[80]!==e||t[81]!==h){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:h(`mobile.nav.secondaryPageAria`),onBack:W,content:d({sessionId:e.sessionId,directory:e.directory,viewKey:e.key,active:n})}}),t[78]=W,t[79]=d,t[80]=e,t[81]=h,t[82]=n}else n=t[82];_e=n}let ve=_e,ye;t[83]===ve?ye=t[84]:(ye=ve??[],t[83]=ve,t[84]=ye);let be;return t[85]!==f||t[86]!==g||t[87]!==R||t[88]!==D||t[89]!==ye||t[90]!==he?(be=(0,$.jsx)(No,{className:f,navigation:g,onTabChange:D,tabs:he,secondaryPages:ye,tabBarCovered:R}),t[85]=f,t[86]=g,t[87]=R,t[88]=D,t[89]=ye,t[90]=he,t[91]=be):be=t[91],be}function Js(){return Tn.requestAnimatedBack(`root`)}function Ys(e){return e.currentSessionId}function Xs(e){return e.replaceChatSession}function Zs(e){return e.materializeDraftSession}function Qs(e){return e.reconcileChatPredecessor}function $s(e){return e.popChatSession}function ec(e){return e.closeSecondary}function tc(e){return e.openAssistant}function nc(e){return e.openDraft}function rc(e){return e.openSession}function ic(e){return e.setActiveTab}function ac(e){let t=(0,xi.c)(19),{percentage:n}=e,r,i,a,o,s,c,l;if(t[0]!==n){a=zt(n)??0;let e=Rt(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 oc(e){let t=(0,xi.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=I(i),p=I(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)(Ke,{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 sc=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},cc=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),lc=e=>e>=90?`text-[var(--status-error)]`:e>=75?`text-[var(--status-warning)]`:`text-[var(--status-success)]`,uc=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:`${cc(t)}/${cc(n)}`,colorClass:lc(i)}},dc=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},fc=(e,t)=>{let n=ue(e,t??(()=>void 0));return!n||`compacted`in n?0:n.totalTokens},pc=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),mc=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`},hc=e=>{let t=(0,xi.c)(13),{iconNode:n,iconName:r,label:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o=n??(r?(0,$.jsx)(Z,{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},gc=e=>{let t=(0,xi.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)(Z,{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)(Z,{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)(Ct,{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=Lt(e.window.valueLabel,t),i=Bt(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:X(`shrink-0 typography-ui-label font-semibold tabular-nums`,mc(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},_c=e=>{let t=(0,xi.c)(47),{open:n,onClose:r,contextDisplay:i,branchLabel:a,usageGroups:o,usageDisplayMode:s,isUsageLoading:c,timeFormatPreference:l}=e,{t:u}=ee(),d=Q.useRef(null),[f,p]=Q.useState(n),[m,h]=Q.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]),Q.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]),Q.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=X(`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)(hc,{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)(hc,{iconNode:(0,$.jsx)(ac,{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:X(`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)(gc,{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:Lc,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 vc(e){let t=(0,xi.c)(95),{sessionId:n,open:r,onOpenChange:i}=e,{t:a}=ee(),{git:o}=un(),[s,c]=Q.useState(!1),l=r!==void 0,u=l?r:s,d=n.length===0,p;t[0]!==l||t[1]!==i||t[2]!==u?(p=e=>{let t=typeof e==`function`?e(u):e;l||c(t),i?.(t)},t[0]=l,t[1]=i,t[2]=u,t[3]=p):p=t[3];let m=I(p),h=w(Ic),g;t[4]===n?g=t[5]:(g=e=>n?e.getDirectoryForSession(n):null,t[4]=n,t[5]=g);let _=ke(g)||h,v;t[6]===_?v=t[7]:(v=pc(_)||null,t[6]=_,t[7]=v);let y=v,b=ye(n,_||void 0),x=mn(y),S=hn(y),C=fn(Fc),T=fn(Pc),E=Be(Nc),D=Be(Mc),O=Be(jc),k=Be(Ac),A;t[8]===n?A=t[9]:(A=e=>n?e.sessionModelSelections.get(n)??null:null,t[8]=n,t[9]=A);let j=We(A),M=$n(kc),N=$n(Oc),P=$n(Dc),F=$n(Ec),L=$n(Tc),R=$n(wc),z=$n(Cc),B=f(Sc);Un();let V;t[10]===m?V=t[11]:(V=()=>{m(!1)},t[10]=m,t[11]=V);let H;t[12]!==_||t[13]!==n?(H=[n,_],t[12]=_,t[13]=n,t[14]=H):H=t[14],Q.useEffect(V,H);let U,te;t[15]!==C||t[16]!==o||t[17]!==y?(U=()=>{y&&C(y,o)},te=[C,o,y],t[15]=C,t[16]=o,t[17]=y,t[18]=U,t[19]=te):(U=t[18],te=t[19]),Q.useEffect(U,te);let W,G;t[20]!==T||t[21]!==o||t[22]!==y?(G=()=>{if(y)return q.onGitRefreshHint(e=>{pc(e.directory)===y&&T(y,o)})},W=[T,o,y],t[20]=T,t[21]=o,t[22]=y,t[23]=W,t[24]=G):(W=t[23],G=t[24]),Q.useEffect(G,W);let ne,re;t[25]===N?(ne=t[26],re=t[27]):(ne=()=>{N()},re=[N],t[25]=N,t[26]=ne,t[27]=re),Q.useEffect(ne,re);let K,ie;t[28]===R?(K=t[29],ie=t[30]):(K=()=>{St(R)},ie=[R],t[28]=R,t[29]=K,t[30]=ie),Q.useEffect(K,ie);let ae,oe;t[31]!==R||t[32]!==P||t[33]!==F||t[34]!==u||t[35]!==M?(ae=()=>{!u||F||R.some(e=>!M.some(t=>t.providerId===e))&&P()},oe=[R,P,F,u,M],t[31]=R,t[32]=P,t[33]=F,t[34]=u,t[35]=M,t[36]=ae,t[37]=oe):(ae=t[36],oe=t[37]),Q.useEffect(ae,oe);let J;t[38]===b?J=t[39]:(J=dc(b),t[38]=b,t[39]=J);let se=J,ce;if(t[40]!==b||t[41]!==O||t[42]!==D||t[43]!==_||t[44]!==k||t[45]!==d||t[46]!==se||t[47]!==E||t[48]!==j){let e=se??(j?{providerID:j.providerId,modelID:j.modelId}:null)??(D&&O?{providerID:D,modelID:O}:null),n=(e?E.find(t=>t.id===e.providerID):void 0)?.models.find(t=>t.id===e?.modelID),r=e?k(e.providerID,e.modelID):void 0,i=sc(n?.limit,`context`)??r?.limit?.context??0,a;t[50]===_?a=t[51]:(a=e=>Ne(e,_||void 0),t[50]=_,t[51]=a);let o;t[52]!==b||t[53]!==a?(o=fc(b,a),t[52]=b,t[53]=a,t[54]=o):o=t[54],ce=uc({totalTokens:o,contextLimit:i,isDraft:d}),t[40]=b,t[41]=O,t[42]=D,t[43]=_,t[44]=k,t[45]=d,t[46]=se,t[47]=E,t[48]=j,t[49]=ce}else ce=t[49];let le=ce,ue;t[55]!==S?.current||t[56]!==x||t[57]!==a?(ue=x===!0?S?.current?.trim()||a(`gitView.branch.detachedHead`):a(`common.unavailable`),t[55]=S?.current,t[56]=x,t[57]=a,t[58]=ue):ue=t[58];let de=ue,fe;if(t[59]!==R||t[60]!==M||t[61]!==z||t[62]!==a){let e=new Map(M.map(xc)),n;t[64]===R?n=t[65]:(n=e=>R.includes(e.id),t[64]=R,t[65]=n),fe=Hn.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:Vt(e),window:t});let i=Object.entries(n?.usage?.models??{}),o=z[t.id]??[],s=o.length>0?i.filter(e=>{let[t]=e;return o.includes(t)}):i;for(let[e,t]of s){let n=Object.entries(t.windows??{});if(n.length===0)continue;let[i,a]=n[0];r.push({key:`model-${e}-${i}`,label:Vt(i),subtitle:Gn(e),window:a})}let c=!n.ok&&n.error?n.error:r.length===0?a(`header.services.noRateLimitsReported`):null;return{providerId:t.id,providerName:t.name,rows:r,status:c}}),t[59]=R,t[60]=M,t[61]=z,t[62]=a,t[63]=fe}else fe=t[63];let pe=fe,me,he;t[66]!==u||t[67]!==pe?(me=()=>{!u||pe.length===0||St(pe.map(bc))},he=[u,pe],t[66]=u,t[67]=pe,t[68]=me,t[69]=he):(me=t[68],he=t[69]),Q.useEffect(me,he);let ge;t[70]===m?ge=t[71]:(ge=()=>{m(yc)},t[70]=m,t[71]=ge);let _e=I(ge),ve;t[72]===m?ve=t[73]:(ve=()=>{m(!1)},t[72]=m,t[73]=ve);let be=I(ve),xe;t[74]===a?xe=t[75]:(xe=a(`mobile.header.openMetadataAria`),t[74]=a,t[75]=xe);let Se=le?.percentage??0,Ce;t[76]===Se?Ce=t[77]:(Ce=(0,$.jsx)(ac,{percentage:Se}),t[76]=Se,t[77]=Ce);let we;t[78]!==_e||t[79]!==u||t[80]!==xe||t[81]!==Ce?(we=(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsx)(Ze,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":xe,"aria-expanded":u,onClick:_e,children:Ce})}),t[78]=_e,t[79]=u,t[80]=xe,t[81]=Ce,t[82]=we):we=t[82];let Te;t[83]!==de||t[84]!==le||t[85]!==be||t[86]!==F||t[87]!==u||t[88]!==L||t[89]!==B||t[90]!==pe?(Te=(0,$.jsx)(_c,{open:u,onClose:be,contextDisplay:le,branchLabel:de,usageGroups:pe,usageDisplayMode:L,isUsageLoading:F,timeFormatPreference:B}),t[83]=de,t[84]=le,t[85]=be,t[86]=F,t[87]=u,t[88]=L,t[89]=B,t[90]=pe,t[91]=Te):Te=t[91];let Ee;return t[92]!==we||t[93]!==Te?(Ee=(0,$.jsxs)($.Fragment,{children:[we,Te]}),t[92]=we,t[93]=Te,t[94]=Ee):Ee=t[94],Ee}function yc(e){return!e}function bc(e){return e.providerId}function xc(e){return[e.providerId,e]}function Sc(e){return e.timeFormatPreference}function Cc(e){return e.selectedModels}function wc(e){return e.dropdownProviderIds}function Tc(e){return e.displayMode}function Ec(e){return e.isLoading}function Dc(e){return e.fetchAllQuotas}function Oc(e){return e.loadSettings}function kc(e){return e.results}function Ac(e){return e.getModelMetadata}function jc(e){return e.currentModelId}function Mc(e){return e.currentProviderId}function Nc(e){return e.providers}function Pc(e){return e.fetchStatus}function Fc(e){return e.ensureStatus}function Ic(e){return e.currentDirectory}function Lc(e){e.stopPropagation()}function Rc(e){return e.sessionId?e.userRefreshInFlight||e.backgroundResyncInFlight?`syncing`:e.hasTranscript?null:!e.isConnected&&e.connectionPhase===`reconnecting`||e.loadStatus===`loading`?`syncing`:null:null}function zc(e,t){let n=t?.showDelayMs??250,r=t?.hideGraceMs??1e3,i=!1,a=!1,o=null,s=()=>{o=null,a!==i&&(a=i,e(a))};return{setRaw(e){i=e,o&&clearTimeout(o),o=setTimeout(s,i?n:r)},cancel(){i=!1,o&&=(clearTimeout(o),null)}}}function Bc(e){let[t,n]=(0,Q.useState)(!1),r=(0,Q.useRef)(null);r.current||=zc(n);let i=r.current;return(0,Q.useEffect)(()=>(i.setRaw(e),()=>i.cancel()),[e,i]),t}function Vc(e,t){let n=(0,xi.c)(17),{t:r}=ee(),i=Re(e,t),a=Pe(e,t),o=Be(Gc),s=Be(Wc),c;n[0]!==t||n[1]!==e?(c=()=>pe(e,t),n[0]=t,n[1]=e,n[2]=c):c=n[2];let l=(0,Q.useSyncExternalStore)(oe,c,Uc),u;n[3]!==t||n[4]!==e?(u=()=>ae(e,t),n[3]=t,n[4]=e,n[5]=u):u=n[5];let d=(0,Q.useSyncExternalStore)(le,u,Hc),f=i?.status,p;n[6]!==d||n[7]!==s||n[8]!==a||n[9]!==o||n[10]!==e||n[11]!==f||n[12]!==l?(p=Rc({sessionId:e,hasTranscript:a,loadStatus:f,userRefreshInFlight:l,backgroundResyncInFlight:d,isConnected:o,connectionPhase:s}),n[6]=d,n[7]=s,n[8]=a,n[9]=o,n[10]=e,n[11]=f,n[12]=l,n[13]=p):p=n[13];let m=Bc(p===`syncing`),h;return n[14]!==r||n[15]!==m?(h=m?r(`mobile.chat.syncingMessages`):null,n[14]=r,n[15]=m,n[16]=h):h=n[16],h}function Hc(){return!1}function Uc(){return!1}function Wc(e){return e.connectionPhase}function Gc(e){return e.isConnected}function Kc(e){let t=(0,xi.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=he(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,_=Vc(p?``:n,r||void 0),[v,y]=Q.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=I(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=I(S),w=d||v,T;t[11]===u?T=t[12]:(T=X(`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)(vc,{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)(oc,{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=X(`mobile-chat-screen__content relative h-full min-h-0 flex-1`,`[&_[data-scrollbar=chat]>.oc-chat-scroll-content]:pt-[calc(max(0.625rem,var(--oc-safe-area-top,0px))+var(--oc-mobile-detail-navigation-height)+1.25rem)]`),t[25]=O):O=t[25];let k;t[26]===l?k=t[27]:(k=(0,$.jsx)(`div`,{className:O,children:l}),t[26]=l,t[27]=k);let A;return t[28]!==T||t[29]!==D||t[30]!==k?(A=(0,$.jsxs)(`main`,{className:T,children:[D,k]}),t[28]=T,t[29]=D,t[30]=k,t[31]=A):A=t[31],A}var qc=k(`BarcodeScanner`),Jc=`oc-barcode-scanner-active`,Yc=()=>ul()?qc:null,Xc=()=>window.Capacitor?.getPlatform?.()===`android`,Zc=e=>typeof e==`object`&&e&&`message`in e?String(e.message??``):String(e??``),Qc=e=>/^\s*scan canceled\.?\s*$/i.test(Zc(e)),$c=e=>/denied access to camera/i.test(Zc(e)),el=e=>!Qc(e)&&!$c(e),tl=e=>{let t=Zc(e);return/module/i.test(t)&&/not\s*available|unavailable/i.test(t)},nl=e=>{e.installGoogleBarcodeScannerModule?.().catch(()=>void 0)},rl=e=>{let t=e.trim();if(!t)return null;if(/^openchamber:\/\//i.test(t)){let e=Jr(t);return e?{pairing:e}:null}return/^https?:\/\//i.test(t)?{url:t}:null},il=e=>{let t=rl(e);return t?`pairing`in t?{status:`pairing`,...t}:{status:`ok`,...t}:{status:`invalid`}},al=e=>{typeof document>`u`||document.documentElement.classList.toggle(Jc,e)},ol=e=>{try{e()}catch{}},sl=e=>{if(typeof document>`u`)return()=>void 0;let t=document.body,n=document.createElement(`button`);n.type=`button`,n.className=`oc-barcode-scanner-chrome`,n.setAttribute(`aria-label`,`Cancel`),n.textContent=`×`,n.addEventListener(`click`,e),t.appendChild(n);let r=!1;return()=>{r||(r=!0,n.removeEventListener(`click`,e),n.parentNode===t&&t.removeChild(n))}},cl=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))};al(!0);let c=sl(()=>s({status:`cancelled`}));try{let{App:e}=await j(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([46,1,14])),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(il(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=>{$c(e)?s({status:`permission-denied`}):s({status:`failed`})}),await o}finally{al(!1),ol(c),ol(()=>r?.()),await Promise.allSettled([Promise.resolve(t?.remove()),Promise.resolve(n?.remove()),e.stopScan()])}},ll=e=>e.isNativePlatform&&e.isPluginAvailable,ul=()=>ll({isNativePlatform:A.isNativePlatform(),isPluginAvailable:A.isPluginAvailable(`BarcodeScanner`)}),dl=async()=>{let e=Yc();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?il(n):{status:`cancelled`}}catch(t){return Qc(t)?{status:`cancelled`}:$c(t)?{status:`permission-denied`}:Xc()&&el(t)&&e.startScan?(tl(t)&&nl(e),cl(e)):{status:`failed`}}return Xc()&&e.startScan?cl(e):{status:`unsupported`}}catch{return{status:`failed`}}},fl={autoComplete:`off`,autoCorrect:`off`,spellCheck:!1},pl=e=>{let t=(0,xi.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]=Q.useState(``),_;t[0]!==l||t[1]!==c||t[2]!==h?(_=e=>{e.preventDefault();let t=rl(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=I(_),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`,{...fl,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)(Ze,{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},ml=e=>{let t=(0,xi.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 hl(e){let t=(0,xi.c)(4),n=e===void 0?2500:e,{uiFont:r}=er(),[i,a]=Q.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([vt(r).catch(bl),document.fonts?.ready?.then(yl).catch(vl)??Promise.resolve(),di.catch(_l)]).then(gl),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]),Q.useEffect(o,s),i}function gl(){}function _l(){}function vl(){}function yl(){}function bl(){}var xl=e=>e.replace(/^\/+|\/+$/g,``),Sl=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},Cl=e=>{let t=xl(e.pathname).split(`/`).filter(Boolean);return e.host?[e.host,...t]:t};function wl(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=Cl(t),r=(n[0]??``).toLowerCase(),i=n.slice(1),a=t.searchParams;switch(r){case`connect`:{let t=Jr(e);return t?{type:`connect`,pairing:t}:null}case`session`:{let e=i[0]||a.get(`id`)||``;return e?{type:`session`,sessionId:e,directory:Sl(a)}:null}case`new`:case`new-session`:{let e=a.get(`prompt`)?.trim();return{type:`new-session`,directory:Sl(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=Sl(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 Tl={},El=null,Dl=!1,Ol=null,kl=e=>{switch(e.type){case`connect`:return El?(El(e.pairing),!0):!1;case`session`:return D()?(ke.getState().setCurrentSession(e.sessionId,e.directory??null),!0):(Le.getState().openSession({sessionId:e.sessionId,directory:e.directory??null}),!0);case`new-session`:return D()?(ke.getState().openNewSessionDraft({directoryOverride:e.directory??null,selectedProjectId:e.projectId??null,preserveDirectoryOverride:!!e.directory,ensureProjectForDirectory:!!e.directory,initialPrompt:e.prompt}),!0):(Le.getState().openDraft({directoryOverride:e.directory??null,selectedProjectId:e.projectId??null,preserveDirectoryOverride:!!e.directory,ensureProjectForDirectory:!!e.directory,initialPrompt:e.prompt}),!0);case`open-project`:return D()?(ke.getState().openNewSessionDraft({directoryOverride:e.directory,preserveDirectoryOverride:!0}),!0):(Le.getState().openDraft({directoryOverride:e.directory,preserveDirectoryOverride:!0}),!0);case`sessions`:return Tl.openSessions?(Tl.openSessions(e.filter),!0):!1;case`status`:return Tl.openSessions?(Tl.openSessions(),!0):(f.getState().setMobileSessionPanelOpen(!0),!0);case`view`:return Tl.openView?(Tl.openView(e.target),!0):!1;case`changes`:return Tl.openChanges?(Tl.openChanges({path:e.path,staged:e.staged}),!0):!1;case`settings`:return Tl.openSettings?(Tl.openSettings(e.section),!0):!1}},Al=()=>{if(!Ol||!Dl&&Ol.type!==`connect`)return;let e=Ol;Ol=null,kl(e)||(Ol=e)},jl=e=>{Ol=e,Al()},Ml=e=>{let t=wl(e);t&&jl(t)},Nl=e=>{Dl=e,Al()},Pl=e=>{let t=(0,xi.c)(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>(Tl=e,Al(),()=>{Tl===e&&(Tl={})}),r=[e],t[0]=e,t[1]=n,t[2]=r),Q.useEffect(n,r)},Fl=e=>{let t=(0,xi.c)(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>(El=e,Al(),()=>{El===e&&(El=null)}),r=[e],t[0]=e,t[1]=n,t[2]=r),Q.useEffect(n,r)},Il=e=>{let{ready:t}=e,[n,r]=Q.useState(()=>E()?`pending`:`none`);return Q.useEffect(()=>{Nl(t)},[t]),Q.useEffect(()=>{if(!E())return;let e=!1,t=[];return j(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([46,1,14])).then(async({App:n})=>{if(e)return;let i=await n.addListener(`appUrlOpen`,e=>{Ml(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=wl(a?.url);r(o?.type===`connect`?`connect`:o?`other`:`none`),o&&jl(o)}).catch(()=>{e||r(`none`)}),j(async()=>{let{PushNotifications:e}=await import(`./vendor-capacitor-push-notifications-DB3-G2vL.js`).then(e=>e.t);return{PushNotifications:e}},__vite__mapDeps([47,1,14])).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){Ml(n);return}let r=typeof t?.sessionId==`string`?t.sessionId:void 0;r&&jl({type:`session`,sessionId:r})});if(e){r.remove();return}t.push(()=>void r.remove())}).catch(()=>void 0),()=>{e=!0,t.forEach(e=>e())}},[]),n},Ll=64,Rl=.6,zl=28,Bl=`[class*="code-block"], [class*="codeBlock"], pre, .cm-editor`,Vl=`[data-session-swipe-surface="true"]`,Hl=e=>e?e.matches(Bl)||e.closest(Bl)!==null:!1,Ul=(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},Wl=e=>e.composerActive||e.onCodeBlock||e.withinHorizontalScroller||e.withinNativeBackEdge?!1:e.onExplicitSurface,Gl=e=>E()&&O()===`ios`&&e<=zl,Kl=e=>{let t=e.endX-e.startX,n=e.endY-e.startY,r=Math.abs(t);return r<Ll||Math.abs(n)>r*Rl?null:t<0?`next`:`prev`},ql=(e,t)=>{let n=e.endX-e.startX,r=e.endY-e.startY,i=Math.abs(n);if(i<8||Math.abs(r)>i*Rl)return null;let a=n<0?`next`:`prev`;return{direction:a,progress:Math.min(i/Ll,1),offsetX:n,canSwitch:t[a]}},Jl=e=>e.parentID??null,Yl=e=>e.time?.updated??e.time?.created??0,Xl=()=>Te.getState().activeSessions.filter(e=>Jl(e)===null).slice().sort((e,t)=>Yl(t)-Yl(e)),Zl=()=>{let e=Xl(),t=ke.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}},Ql=(e,t)=>{if(ke.getState().currentSessionId!==t.currentId)return!1;let n=e===`prev`?t.prevId:t.nextId;if(!n)return!1;let r=Te.getState().activeSessions.find(e=>e.id===n);return r?(ke.getState().setCurrentSession(r.id,je(r)),!0):!1},$l=(e,t,n)=>{let r=Q.useRef(t?.onSwitch);r.current=t?.onSwitch;let i=Q.useRef(t?.onProgress);i.current=t?.onProgress,Q.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(Vl),f=document.documentElement,p=i!==null&&(i.contains(document.activeElement)||f.classList.contains(`oc-keyboard-open`)||f.classList.contains(`oc-browser-keyboard-open`));if(p){n=!1;return}if(!Wl({onExplicitSurface:i!==null,onCodeBlock:Hl(r),withinHorizontalScroller:Ul(r,!0),withinNativeBackEdge:Gl(t.clientX),composerActive:p})){n=!1;return}n=!0,a=t.clientX,o=t.clientY,s=Zl(),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&&ve(`light`,{bypassCadence:!0}),l=!1,u=!1,d&&i.current?.(null),d=!1;return}let t=e.touches[0],r=ql({startX:a,startY:o,endX:t.clientX,endY:t.clientY},c);if(!r){l&&(l=!1,ve(`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=Ee({thresholdReached:l,distance:s,enterDistance:Ll,cancelDistance:56,available:r.canSwitch});l=f.thresholdReached,f.event===`enter`&&(u=ve(`medium`,{bypassCadence:!0})),f.event===`cancel`&&(ve(`light`,{bypassCadence:!0}),u=!1)},g=e=>{if(!n)return;n=!1;let t=e.changedTouches[0];if(!t){l&&ve(`light`,{bypassCadence:!0}),l=!1,u=!1,d&&i.current?.(null),d=!1;return}if(Ul(document.elementFromPoint(t.clientX,t.clientY),!0)){l&&ve(`light`,{bypassCadence:!0}),l=!1,u=!1,d&&i.current?.(null),d=!1;return}let c=Kl({startX:a,startY:o,endX:t.clientX,endY:t.clientY});if(!c){l&&ve(`light`,{bypassCadence:!0}),l=!1,u=!1,d&&i.current?.(null),d=!1;return}Ql(c,s)?(u||ve(`medium`,{bypassCadence:!0}),f=!0,p!==null&&window.clearTimeout(p),p=window.setTimeout(()=>{f=!1,p=null},500),r.current?.(c)):l&&ve(`light`,{bypassCadence:!0}),l=!1,u=!1,d&&i.current?.(null),d=!1},_=()=>{n=!1,l&&ve(`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])},eu=.85,tu=8,nu=.35,ru=.22,iu=e=>({segmentStart:e,lastTouch:e,open:!1}),au=e=>e*nu,ou=e=>e*ru,su=(e,t)=>Math.max(0,e-t),cu=(e,t)=>Math.max(0,t-e),lu=(e,t)=>{let n=Math.abs(e);return n<tu||Math.abs(t)<=n*eu},uu=(e,t,n)=>{let r=t.clientX-e.segmentStart.clientX,i=t.clientY-e.segmentStart.clientY,a=su(e.segmentStart.clientX,t.clientX),o=au(n),s=ou(n),c=e.open;return c=a<=0?!1:e.open?a>=s:a>=o&&lu(r,i),{segmentStart:e.segmentStart,lastTouch:t,open:c}},du=e=>{if(e.disabled||e.startedOnExcludedTarget)return{open:!1,back:!1};let t=e.endX-e.startX,n=e.endY-e.startY,r=su(e.startX,e.endX),i=cu(e.startX,e.endX),a=au(e.viewportWidth),o=lu(t,n);return{open:r>=a&&o,back:i>=a&&o}},fu=(e,t,n)=>Math.min(su(e,t)/Math.max(1,au(n)),1),pu=(e,t,n)=>Math.min(cu(e,t)/Math.max(1,au(n)),1),mu=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},hu=e=>{let t=document.elementFromPoint(e.clientX,e.clientY);return!!t?.closest(`[data-session-swipe-surface="true"]`)||mu(t)},gu=1,_u=(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===gu?n:n.parentElement;return!!(r&&t.contains(r))},vu=e=>_u(window.getSelection(),e),yu=(e,t,n)=>{let r=Q.useRef(t.onOpen);r.current=t.onOpen;let i=Q.useRef(t.onPreviewStart);i.current=t.onPreviewStart;let a=Q.useRef(t.onPreviewCancel);a.current=t.onPreviewCancel;let o=Q.useRef(t.onProgress);o.current=t.onProgress;let s=Q.useRef(t.onBack);s.current=t.onBack;let c=Q.useRef(t.onBackProgress);c.current=t.onBackProgress;let l=Q.useRef(t.disabled);l.current=t.disabled,Q.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=au(g),n=Ee({thresholdReached:p,distance:e,enterDistance:t,cancelDistance:ou(g),available:!0});p=n.thresholdReached,n.event===`enter`&&(m=ve(`medium`,{bypassCadence:!0})),n.event===`cancel`&&(ve(`light`,{bypassCadence:!0}),m=!1)},y=e=>{o.current?.(null),p&&!e&&ve(`light`,{bypassCadence:!0}),p=!1,m=!1,e?r.current():f&&a.current?.(),f=!1},b=e=>{c.current?.(null),p&&!e&&ve(`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=hu(r)||vu(t),d=null,f=!1,p=!1,m=!1,h=0,_=iu(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];_=uu(_,r,g);let a=r.clientX-_.segmentStart.clientX,l=r.clientY-_.segmentStart.clientY;if(d===null){if(vu(t))return;let e=Math.abs(a);if(e<tu||Math.abs(l)>e*eu)return;if(a<0)d=`sessions`,f=!0,i.current?.();else if(s.current)d=`back`;else return}e.preventDefault(),h=d===`sessions`?su(_.segmentStart.clientX,r.clientX):cu(_.segmentStart.clientX,r.clientX),v(h),d===`sessions`?o.current?.(fu(_.segmentStart.clientX,r.clientX,g)):c.current?.(pu(_.segmentStart.clientX,r.clientX,g))},C=e=>{if(!n||!_)return;if(n=!1,!d){_=null;return}let t=e.changedTouches[0];t&&(_=uu(_,t,g),h=d===`sessions`?su(_.segmentStart.clientX,t.clientX):cu(_.segmentStart.clientX,t.clientX),v(h));let r=d===`sessions`?_.open:du({startX:_.segmentStart.clientX,startY:_.segmentStart.clientY,endX:_.lastTouch.clientX,endY:_.lastTouch.clientY,viewportWidth:g,disabled:!1,startedOnExcludedTarget:!1}).back;_=null,e.preventDefault(),r&&!m&&ve(`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])},bu=()=>{if(typeof window>`u`)return!1;let e=window.Capacitor?.getPlatform?.();return e===`ios`||e===`android`},xu=(e,t)=>{y()?.push?.registerApnsToken?.({token:e,platform:O(),locale:t})},Su=e=>{let{enabled:t}=e,n=f(e=>e.nativeNotificationsEnabled),r=z(e=>e.locale),i=Q.useRef(null),a=Q.useRef(r);a.current=r,Q.useEffect(()=>{if(!t||!n||!bu())return;let e=!1,r=[];return j(async()=>{let{PushNotifications:e}=await import(`./vendor-capacitor-push-notifications-DB3-G2vL.js`).then(e=>e.t);return{PushNotifications:e}},__vite__mapDeps([47,1,14])).then(async({PushNotifications:t})=>{if(e)return;let n=await t.checkPermissions().catch(()=>null);if(n?.receive!==`granted`&&(n=await t.requestPermissions().catch(()=>null)),n?.receive!==`granted`)return;let o=await t.addListener(`registration`,e=>{i.current=e.value,xu(e.value,a.current)}),s=await t.addListener(`registrationError`,e=>{console.warn(`[Push] APNs registration error:`,e)});if(await t.register().catch(()=>void 0),e){o.remove(),s.remove();return}r.push(()=>void o.remove(),()=>void s.remove())}).catch(()=>void 0),()=>{e=!0,r.forEach(e=>e())}},[t,n]),Q.useEffect(()=>{if(!t||!n||!bu())return;let e=i.current;e&&xu(e,r)},[t,n,r]),Q.useEffect(()=>{if(n)return;let e=i.current;e&&(i.current=null,y()?.push?.unregisterApnsToken?.({token:e}))},[n])},Cu=`OpenChamberLiveActivity`,wu=5e3,Tu=3600,Eu=`live`,Du=k(Cu),Ou=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable;function ku(){return typeof window>`u`?!1:Ou({isCapacitor:E(),platform:O(),pluginAvailable:A.isPluginAvailable(Cu)})}var Au=()=>Du,ju=new Set([`permission`,`input`,`retry`]),Mu=()=>({trackedSessionId:null,started:!1,startedAt:null,busySince:null,lastStatus:null,eventVersion:0,items:[]}),Nu=(e,t)=>Math.max(Math.floor(e),t+1),Pu=e=>e.failedEpoch===e.currentEpoch?e.previous:e.current,Fu=e=>e.failedEpoch===e.currentEpoch&&e.retryCount<1,Iu=e=>e.hasSessionError?`error`:e.hasPendingPermissions?`permission`:e.hasPendingQuestions?`input`:e.statusType===`retry`?`retry`:e.statusType===`busy`?`working`:e.statusType===`idle`?`complete`:null,Lu=e=>{let t=e.trim();return t.length<=80?t:`${t.slice(0,79)}…`},Ru=e=>typeof e.parentID==`string`&&e.parentID.length>0?e.parentID:null,zu=e=>{if(e.runningIds.size===0)return[];let t=new Map(e.sessions.map(e=>[e.id,e])),n=[],r=new Set;for(let t of e.sessions)!e.runningIds.has(t.id)||Ru(t)||(r.add(t.id),n.push({sessionId:t.id,title:Lu(t.title??``),statusType:e.statuses[t.id]?.type??`busy`}));for(let i of e.runningIds){if(r.has(i))continue;let a=t.get(i);a&&Ru(a)||n.push({sessionId:i,title:Lu(a?.title??``),statusType:e.statuses[i]?.type??`busy`})}return n},Bu=e=>e!==`complete`&&e!==`error`,Vu=e=>e.some(e=>e.status===`permission`)?`permission`:e.some(e=>e.status===`input`)?`input`:e.some(e=>e.status===`retry`)?`retry`:e.some(e=>e.status===`tool`)?`tool`:e.some(e=>e.status===`stale`)?`stale`:e.some(e=>e.status===`working`)?`working`:e.some(e=>e.status===`error`)?`error`:`complete`,Hu=e=>{if(e.length<=4)return e;let t=e.filter(e=>Bu(e.status)),n=e.filter(e=>!Bu(e.status)).sort((e,t)=>(t.endedAt??0)-(e.endedAt??0)),r=[...t];for(let e of n){if(r.length>=4)break;r.push(e)}return r.slice(0,4)},Uu=(e,t,n)=>{let r=new Map;for(let e of t)r.set(e.sessionId,e);let i=[],a=new Set;for(let t of e){let e=r.get(t.sessionId);if(e){let r=Iu({statusType:e.statusType,hasPendingPermissions:e.hasPendingPermissions===!0,hasPendingQuestions:e.hasPendingQuestions===!0,hasSessionError:e.hasSessionError===!0})??`working`;i.push({sessionId:t.sessionId,title:e.title||t.title,status:r,startedAt:t.startedAt,busySince:r===`working`?t.busySince??n:null})}else Bu(t.status)?i.push({...t,status:`complete`,endedAt:n,busySince:null}):i.push(t);a.add(t.sessionId)}for(let e of t){if(a.has(e.sessionId))continue;let t=Iu({statusType:e.statusType,hasPendingPermissions:e.hasPendingPermissions===!0,hasPendingQuestions:e.hasPendingQuestions===!0,hasSessionError:e.hasSessionError===!0})??`working`;i.push({sessionId:e.sessionId,title:e.title,status:t,startedAt:n,busySince:t===`working`?n:null})}return Hu(i)},Wu=e=>e.map(e=>`${e.sessionId}\0${e.title}\0${e.status}\0${e.endedAt??``}`).join(`
|
|
15
|
-
`),Gu=e=>e.map(e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:e.startedAt};return e.endedAt!==void 0&&(t.endedAt=e.endedAt),t}),Ku=(e,t,n,r,i)=>{let a=e.filter(e=>Bu(e.status)),o=a[0]??e[0],s={sessionId:Eu,startedAt:o?.startedAt??r,status:t,eventVersion:n,updatedAt:r,title:o?.title,workingCount:a.length,items:Gu(e)};return i?.endedAt!==void 0&&(s.endedAt=i.endedAt),i?.dismissalSeconds!==void 0&&(s.dismissalSeconds=i.dismissalSeconds),s},qu=e=>{let t={sessionId:e.sessionId,startedAt:e.startedAt,status:e.status,eventVersion:e.eventVersion,updatedAt:e.updatedAt};return e.endedAt!==void 0&&(t.endedAt=e.endedAt),e.dismissalSeconds!==void 0&&(t.dismissalSeconds=e.dismissalSeconds),e.title!==void 0&&(t.title=e.title),e.workingCount!==void 0&&(t.workingCount=e.workingCount),e.items!==void 0&&(t.items=e.items),t},Ju=(e,t,n,r)=>{let i=e.trackedSessionId;if(!i||!e.started)return{state:Mu(),commands:[]};let a=Nu(t,e.eventVersion);return{state:Mu(),commands:[{type:`end`,payload:qu({sessionId:i,startedAt:e.startedAt??t,status:n,eventVersion:a,updatedAt:t,endedAt:t,dismissalSeconds:r})}]}},Yu=(e,t,n,r,i)=>{let a=Nu(r,i);return{state:{trackedSessionId:e,started:!0,startedAt:n,busySince:null,lastStatus:t,eventVersion:a,items:[]},commands:[{type:`start`,payload:qu({sessionId:e,startedAt:n,status:t,eventVersion:a,updatedAt:r})}]}},Xu=(e,t,n)=>{let r=Iu(t),i=e.busySince;if(r===`working`?i??=t.now:(!e.started&&!r||!e.started&&r===`complete`||!e.started&&r===`error`)&&(i=null),!e.started){if(r===`working`){let r=wu-(t.now-(i??t.now));if(r>0)return{state:{...e,trackedSessionId:n,busySince:i},commands:[{type:`wait`,delayMs:r}]}}else if(!r||!ju.has(r))return{state:{...Mu(),trackedSessionId:n},commands:[]};return Yu(n,r,i??t.now,t.now,e.eventVersion)}if(r===`complete`)return Ju({...e,busySince:i},t.now,`complete`,900);if(r===`error`)return Ju({...e,busySince:i},t.now,`error`,Tu);if(!r||r===e.lastStatus)return{state:{...e,trackedSessionId:n,busySince:i},commands:[]};let a=Nu(t.now,e.eventVersion);return{state:{trackedSessionId:n,started:!0,startedAt:e.startedAt??t.now,busySince:r===`working`?i:null,lastStatus:r,eventVersion:a,items:e.items},commands:[{type:`update`,payload:qu({sessionId:n,startedAt:e.startedAt??t.now,status:r,eventVersion:a,updatedAt:t.now})}]}},Zu=(e,t,n)=>{let r=e.trackedSessionId;if(!r||!e.started)return{state:e,commands:[]};let i=Nu(n,e.eventVersion);return{state:{...e,busySince:null,lastStatus:t,eventVersion:i},commands:[{type:`update`,payload:qu({sessionId:r,startedAt:e.startedAt??n,status:t,eventVersion:i,updatedAt:n})}]}},Qu=(e,t,n)=>{let r=Uu(e.items,n,t.now),i=r.filter(e=>Bu(e.status)),a=Vu(r),o=i.reduce((e,t)=>{let n=t.busySince??t.startedAt;return e===null||n<e?n:e},null);if(!t.connected){let n=e.busySince===null?e:{...e,busySince:null};if(!n.started||n.lastStatus===`stale`)return{state:{...n,items:r},commands:[]};let i=Nu(t.now,n.eventVersion),a=r.map(e=>Bu(e.status)?{...e,status:`stale`}:e);return{state:{...n,items:a,lastStatus:`stale`,eventVersion:i,busySince:null},commands:[{type:`update`,payload:qu(Ku(a,`stale`,i,t.now))}]}}if(!e.started){if(i.length===0)return{state:Mu(),commands:[]};if(!i.some(e=>ju.has(e.status))){let n=wu-(t.now-(o??t.now));if(n>0)return{state:{...e,trackedSessionId:Eu,items:r,busySince:o},commands:[{type:`wait`,delayMs:n}]}}let n=o??t.now,s=r.map(e=>Bu(e.status)?{...e,startedAt:e.busySince??n}:e),c=Nu(t.now,e.eventVersion);return{state:{trackedSessionId:Eu,started:!0,startedAt:n,busySince:null,lastStatus:a,eventVersion:c,items:s},commands:[{type:`start`,payload:qu(Ku(s,a,c,t.now))}]}}if(i.length===0){let n=r.some(e=>e.status===`error`)?`error`:`complete`,i=Nu(t.now,e.eventVersion);return{state:Mu(),commands:[{type:`end`,payload:qu(Ku(r,n,i,t.now,{endedAt:t.now,dismissalSeconds:n===`error`?Tu:900}))}]}}if(Wu(e.items)===Wu(r)&&e.lastStatus===a)return{state:{...e,trackedSessionId:Eu,items:r,busySince:null},commands:[]};let s=Nu(t.now,e.eventVersion);return{state:{trackedSessionId:Eu,started:!0,startedAt:e.startedAt??o??t.now,busySince:null,lastStatus:a,eventVersion:s,items:r},commands:[{type:`update`,payload:qu(Ku(r,a,s,t.now))}]}},$u=(e,t)=>{if(t.catalog)return Qu(e,t,t.catalog);if(!t.connected){let n=e.busySince===null?e:{...e,busySince:null};return!n.started||n.lastStatus===`stale`||!n.trackedSessionId?{state:n,commands:[]}:Zu(n,`stale`,t.now)}let n=[],r=e;if(r.trackedSessionId&&r.trackedSessionId!==t.sessionId)if(r.started){let e=Ju(r,t.now,r.lastStatus??`complete`,0);n.push(...e.commands),r=e.state}else r=Mu();if(!t.sessionId){if(r.started){let e=Ju(r,t.now,`complete`,900);return{state:e.state,commands:[...n,...e.commands]}}return{state:Mu(),commands:n}}let i=Xu(r,t,t.sessionId);return{state:i.state,commands:[...n,...i.commands]}},ed=e=>e/1e3,td=e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:ed(e.startedAt)};return e.endedAt!==void 0&&(t.endedAt=ed(e.endedAt)),t},nd=e=>{let t={sessionId:e.sessionId,startedAt:ed(e.startedAt),status:e.status,eventVersion:e.eventVersion,updatedAt:ed(e.updatedAt)};return e.endedAt!==void 0&&(t.endedAt=ed(e.endedAt)),e.dismissalSeconds!==void 0&&(t.dismissalSeconds=e.dismissalSeconds),e.title!==void 0&&(t.title=e.title),e.workingCount!==void 0&&(t.workingCount=e.workingCount),e.items!==void 0&&(t.items=e.items.map(td)),t},rd=e=>{let t={};return e.title!==void 0&&(t.title=e.title),e.workingCount!==void 0&&(t.workingCount=e.workingCount),e.items!==void 0&&(t.items=e.items),t},id=(e,t,n)=>{if(!e||n.type===`wait`)return Promise.resolve();let r=nd(n.payload),i=rd(r);return n.type===`start`?t.start({sessionId:r.sessionId,startedAt:r.startedAt,status:r.status,eventVersion:r.eventVersion,updatedAt:r.updatedAt,...i}):n.type===`update`?t.update({sessionId:r.sessionId,startedAt:r.startedAt,status:r.status,eventVersion:r.eventVersion,updatedAt:r.updatedAt,...i}):t.end({sessionId:r.sessionId,startedAt:r.startedAt,status:r.status,eventVersion:r.eventVersion,updatedAt:r.updatedAt,endedAt:r.endedAt,dismissalSeconds:r.dismissalSeconds,...i})},ad=e=>e.getCurrentEpoch()===e.epoch?!e.getCurrentSessionId||e.getCurrentSessionId()===e.observation.sessionId:!1,od=async e=>{let t=e.state;if(!ad(e))return{state:t,delayMs:null,retry:!1,superseded:!0};let n=$u(t,e.observation),r=n.commands.find(e=>e.type===`wait`),i=r?.type===`wait`?r.delayMs:null,a=n.commands.filter(e=>e.type!==`wait`);if(a.length===0)return ad(e)?{state:n.state,delayMs:i,retry:!1,superseded:!1}:{state:t,delayMs:null,retry:!1,superseded:!0};let o=t;try{for(let[r,i]of a.entries()){if(!ad(e)||(await id(e.available,e.plugin,i),!ad(e)))return{state:t,delayMs:null,retry:!1,superseded:!0};let s=r===a.length-1;o=i.type===`end`&&!s?Mu():n.state}return{state:n.state,delayMs:i,retry:!1,superseded:!1}}catch{if(!ad(e))return{state:t,delayMs:null,retry:!1,superseded:!0};let r=Pu({failedEpoch:e.epoch,currentEpoch:e.getCurrentEpoch(),previous:o,current:n.state}),i=Fu({failedEpoch:e.epoch,currentEpoch:e.getCurrentEpoch(),retryCount:e.retryCount});return{state:r,delayMs:i?250:null,retry:i,superseded:!1}}},sd=()=>({desired:null,registered:null}),cd=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null},ld=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=cd(t.activityId),r=cd(t.sessionId),i=cd(t.token);return!n||!r||!i?null:{activityId:n,sessionId:r,token:i}},ud=(e,t)=>e.activityId===t.activityId&&e.token===t.token,dd=(e,t)=>{let n=e.registered?.runtimeIdentity===t?e.registered:null;return e.desired===null&&n===e.registered?e:{desired:null,registered:n}},fd=(e,t)=>{if(!t.connected)return[];if(e.desired&&t.enabled&&t.selectedSessionId&&e.desired.sessionId===t.selectedSessionId){let n=e.registered;return n&&ud(n,e.desired)&&n.runtimeIdentity===t.runtimeIdentity?[]:[{type:`register`,payload:{activityId:e.desired.activityId,sessionId:e.desired.sessionId,token:e.desired.token},runtimeIdentity:t.runtimeIdentity}]}return e.registered&&e.registered.runtimeIdentity===t.runtimeIdentity?[{type:`unregister`,payload:{token:e.registered.token},runtimeIdentity:t.runtimeIdentity}]:[]},pd=(e,t,n)=>{let r=e;if(n.type===`pushToken`){if(!t.enabled||n.sessionId!==t.selectedSessionId)return{state:e,commands:[]};r={...e,desired:{activityId:n.activityId,sessionId:n.sessionId,token:n.token}}}else n.type===`localEndSucceeded`||n.type===`dispose`||!t.enabled||e.desired&&e.desired.sessionId!==t.selectedSessionId?r=dd(e,t.runtimeIdentity):e.registered&&e.registered.runtimeIdentity!==t.runtimeIdentity&&!e.desired&&(r={...e,registered:null});return{state:r,commands:fd(r,t)}},md=async e=>{try{return await e}catch{return null}},hd=async e=>{let t=e.state;for(let n of e.commands){if(n.runtimeIdentity!==e.getRuntimeIdentity()){n.type===`unregister`&&t.registered?.runtimeIdentity===n.runtimeIdentity&&(t={...t,registered:null});continue}if(n.type===`register`){let r=t.registered;if(n.runtimeIdentity!==e.getRuntimeIdentity()||(await md(e.register(n.payload)))?.ok!==!0||n.runtimeIdentity!==e.getRuntimeIdentity())continue;if(t={...t,registered:{...n.payload,runtimeIdentity:n.runtimeIdentity}},r&&r.runtimeIdentity===n.runtimeIdentity&&r.token!==n.payload.token){if(n.runtimeIdentity!==e.getRuntimeIdentity())continue;await md(e.unregister({token:r.token}))}continue}if(n.runtimeIdentity!==e.getRuntimeIdentity()){t.registered?.runtimeIdentity===n.runtimeIdentity&&(t={...t,registered:null});continue}(await md(e.unregister(n.payload)))?.ok===!0&&t.registered?.token===n.payload.token&&(t={...t,registered:null})}return t},gd=new Map,_d=[];function vd(){let e=ku(),n=Be(e=>e.isConnected),i=se({enabled:e}),a=He(t=>e?t.statusById:gd),o=Te(t=>e?t.activeSessions:_d),s=(0,Q.useMemo)(()=>e?ur(i,a):new Set,[e,a,i]),c=(0,Q.useMemo)(()=>e?zu({runningIds:s,statuses:i,sessions:o}):[],[e,i,s,o]),l=(0,Q.useMemo)(()=>c.map(e=>`${e.sessionId}\0${e.title}\0${e.statusType??``}`).join(`
|
|
16
|
-
`),[c]),u=(0,Q.useRef)(Mu()),d=(0,Q.useRef)(sd()),f=(0,Q.useRef)(null),p=(0,Q.useRef)(0),m=(0,Q.useRef)(Promise.resolve()),h=(0,Q.useRef)(Promise.resolve()),g=(0,Q.useRef)(null),_=I(()=>({sessionId:Eu,statusType:void 0,hasPendingPermissions:!1,hasPendingQuestions:!1,hasSessionError:!1,now:Date.now(),connected:n,catalog:c})),v=I(t=>{h.current=h.current.then(async()=>{let i=pd(d.current,{selectedSessionId:Eu,runtimeIdentity:r(),connected:n,enabled:e},t);d.current=i.state,i.commands.length!==0&&(d.current=await hd({state:d.current,commands:i.commands,getRuntimeIdentity:r,register:e=>y()?.push?.registerLiveActivityToken?.(e)??Promise.resolve(null),unregister:e=>y()?.push?.unregisterLiveActivityToken?.(e)??Promise.resolve(null)}))}).catch(()=>void 0)}),b=I(e=>{let t=ld(e);t&&v({type:`pushToken`,...t,sessionId:Eu})});(0,Q.useEffect)(()=>{v({type:e?`sync`:`dispose`})},[e,n]),(0,Q.useEffect)(()=>t(()=>{v({type:`sync`})}),[]),(0,Q.useEffect)(()=>{if(!e){g.current?.remove(),g.current=null;return}let t=!1,n=null,r=0,i=Au(),a=p.current+1;p.current=a;let o=()=>{m.current=m.current.then(async()=>{if(t||p.current!==a)return;if(f.current!==!0){if(f.current===!1)return;let e=await i.isSupported().catch(()=>({supported:!1}));if(t||p.current!==a||(f.current=e.supported===!0,!f.current))return}let e=_(),s=u.current.started,c=await od({available:!0,plugin:i,state:u.current,observation:e,epoch:a,getCurrentEpoch:()=>p.current,retryCount:r});t||p.current!==a||c.superseded||(u.current=c.state,s&&!c.state.started&&v({type:`localEndSucceeded`}),c.retry?r+=1:r=0,c.delayMs!=null&&(n=setTimeout(()=>{o()},c.delayMs)))}).catch(()=>void 0)};return m.current=m.current.then(async()=>{if(!(t||p.current!==a)&&!g.current)try{let e=await i.addListener(`pushToken`,e=>{b(e)});if(t){await e.remove();return}g.current=e}catch{return}}).then(()=>{!t&&p.current===a&&o()}).catch(()=>void 0),()=>{t=!0,p.current===a&&(p.current+=1),n!==null&&clearTimeout(n)}},[e,n,l]),(0,Q.useEffect)(()=>()=>{g.current?.remove(),g.current=null,v({type:`dispose`})},[])}var yd=`mobile-direct-diff`,bd=`mobile-turn-diff`,xd=`mobile-direct-file`,Sd=`mobile-files`,Cd=`mobile-changes`,wd=`mobile-mcp`,Td=`mobile-settings`,Ed=`mobile-update`,Dd=`mobile-overflow-menu`,Od=320,kd=380,Ad=280,jd=560,Md=380,Nd=e=>Math.min(jd,Math.max(Ad,Math.round(e))),Pd=(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 Fd(e,t,n){let r=(0,xi.c)(17),i=Q.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(jd,Math.max(Ad,e)):n},r[0]=n,r[1]=t,r[2]=a):a=r[2];let[o,s]=Q.useState(a),[c,l]=Q.useState(!1),u=Q.useRef(0),d=Q.useRef(o),f=Q.useRef(null),p=Q.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=I(m),g;r[5]===e?g=r[6]:(g=t=>{if(p.current!==t.pointerId)return;let n=t.clientX-u.current,r=Nd(d.current+(e===`left`?n:-n));f.current!==r&&(f.current=r,Pd(i,r))},r[5]=e,r[6]=g);let _=I(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=Nd(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=I(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 Id=e=>{let t=(0,xi.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=X(`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=X(`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},Ld=()=>typeof window>`u`?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`,Rd=()=>{Q.useEffect(()=>{if(!Ld())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 j(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([48,1,14])).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 j(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([46,1,14])),c=await s.addListener(`appStateChange`,({isActive:e})=>{e&&a()});if(e){c.remove();return}t.push(()=>void c.remove())}).catch(()=>void 0),j(async()=>{let{Keyboard:e}=await import(`./vendor-capacitor-keyboard-BkRQ-Kv-.js`).then(e=>e.t);return{Keyboard:e}},__vite__mapDeps([49,1,14])).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&&!Zi(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)&&!Zi(e))},x=e=>Zi(e),S=()=>{for(let e of document.querySelectorAll(`.oc-mobile-composer, .oc-draft-center`))e.style.transition=``,e.style.transform=``},C=()=>{let e=document.querySelector(`.oc-mobile-app-shell`);d=e&&parseFloat(getComputedStyle(e).paddingBottom)||0};if(a){let i=`openchamber.androidImeHeightRatio.v2`,a=`cubic-bezier(0.2, 0, 0, 1)`,o=`cubic-bezier(0.4, 0, 1, 1)`,s=null,c=!1,l=y,u=e=>Number.isFinite(e)?Math.min(.68,Math.max(.28,e)):.39,m=Math.round(window.innerHeight*(()=>{try{return u(Number.parseFloat(localStorage.getItem(i)??``))}catch{return .39}})()),g=0,_=e=>{if(m=Math.max(0,Math.round(e)),!(m<=0||window.innerHeight<=0))try{localStorage.setItem(i,String(u(m/window.innerHeight)))}catch{}},w=()=>{s!==null&&(window.clearTimeout(s),s=null)},T=e=>Math.max(0,Math.round(e-d)),E=(e,t)=>`translate3d(0, ${-e*t}px, 0)`,D=(e,t,r,i)=>{w();let a=T(e),o=v(i);n.classList.add(`oc-kb-animating`);for(let{el:e,factor:n}of o)e.style.transition=`transform ${t}ms ${r}`,e.style.transform=E(a,n);return s=window.setTimeout(()=>{s=null,n.classList.remove(`oc-kb-animating`);for(let{el:e}of o)e.style.transition=``},t+20),a},O=e=>{C();let t=Math.max(0,Math.round(e));f=!0,c=!1,g=t,n.classList.remove(`oc-keyboard-open`,`oc-kb-animating`),r(t),p(`--oc-kb-layout`,0),p(`--oc-kb-scroll-inset`,T(t)),w(),S(),h(`oc:keyboard-settled`,{open:!0})},k=(e,t=`focus`)=>{if(t===`intent`){if(!b())return}else if(t===`focus`){if(!x(e))return}else if(!f&&!x(document.activeElement))return;if(C(),f){let i=g||m,o=T(i),s=v(t===`focus`?e:void 0);if(s.length===0||(c=!0,n.classList.add(`oc-keyboard-open`),r(0),p(`--oc-kb-scroll-inset`,0),s.every(({el:e,factor:t})=>e.style.transform===E(o,t))))return;D(i,60,a,t===`focus`?e:void 0),h(`oc:keyboard-anim`,{phase:`show`,slide:o,durationMs:60,easing:a}),h(`oc:keyboard-settled`,{open:!0});return}f=!0,c=!0,n.classList.add(`oc-keyboard-open`),r(0),p(`--oc-kb-layout`,0),p(`--oc-kb-scroll-inset`,0),g=m;let i=D(g,200,a,t===`focus`?e:void 0);h(`oc:keyboard-anim`,{phase:`show`,slide:i,durationMs:200,easing:a}),h(`oc:keyboard-settled`,{open:!0})},A=e=>{if(!f){e&&l(document.activeElement)&&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(Zi(e.target)){k(e.target,`focus`);return}O(g||m)}},M=e=>{if(l(e.target)&&!$i(e.relatedTarget)){if(Qi(e.relatedTarget)){h(`oc:keyboard-intent`,{open:!1}),O(g||m);return}A(!1)}},N=e=>{let t=e,n=t.detail??t;if(n?.open===!0){let e=na(n.height??0,window.devicePixelRatio||1),t=ea(c,document.activeElement);if(e>0&&(t===`open`||t===`cache`)&&_(e),t===`open`&&k(document.activeElement,`ime`),t===`cache`&&ta(g||m,e)){g=e;let t=D(e,60,a,Zi(document.activeElement)?document.activeElement:void 0);h(`oc:keyboard-anim`,{phase:`show`,slide:t,durationMs:60,easing:a})}t===`field`&&O(e||m)}n?.open===!1&&A(!0)},P=e=>{e.detail?.open===!0&&k(void 0,`intent`)};if(document.addEventListener(`focusin`,j,!0),document.addEventListener(`focusout`,M,!0),window.addEventListener(`oc:ime-state`,N),window.addEventListener(`oc:keyboard-intent`,P),e){w(),document.removeEventListener(`focusin`,j,!0),document.removeEventListener(`focusout`,M,!0),window.removeEventListener(`oc:ime-state`,N),window.removeEventListener(`oc:keyboard-intent`,P);return}t.push(w,()=>document.removeEventListener(`focusin`,j,!0),()=>document.removeEventListener(`focusout`,M,!0),()=>window.removeEventListener(`oc:ime-state`,N),()=>window.removeEventListener(`oc:keyboard-intent`,P));return}let w=`openchamber.iosImeHeightRatio.v1`,T=e=>Number.isFinite(e)?Math.min(.68,Math.max(.28,e)):.39,E=()=>{try{let e=T(Number.parseFloat(localStorage.getItem(w)??``));return Math.round(window.innerHeight*e)}catch{return Math.round(window.innerHeight*.39)}},D=e=>{if(!(e<=0||window.innerHeight<=0))try{localStorage.setItem(w,String(T(e/window.innerHeight)))}catch{}},O=e=>{C();let t=Math.max(0,e-d);return r(e),p(`--oc-kb-layout`,e),p(`--oc-kb-scroll-inset`,0),u=!0,S(),window.scrollTo(0,0),document.body.scrollTop!==0&&(document.body.scrollTop=0),_(`.oc-mobile-composer`)?.scrollIntoView({block:`end`,inline:`nearest`}),t},k=e=>{if(n.classList.contains(`oc-native-ios-composer`)||e.detail?.open!==!0||u||y(document.activeElement)&&!Zi(document.activeElement))return;f=!0,n.classList.remove(`oc-kb-hide`),n.classList.add(`oc-keyboard-open`);let t=l>0?l:E(),r=O(t);h(`oc:keyboard-anim`,{phase:`show`,slide:r,durationMs:0,easing:o}),h(`oc:keyboard-settled`,{open:!0})};window.addEventListener(`oc:keyboard-intent`,k);let A=await i.addListener(`keyboardWillShow`,e=>{if(n.classList.contains(`oc-native-ios-composer`))return;m(),l=e.keyboardHeight,D(l);let t=Zi(document.activeElement)||n.classList.contains(`oc-keyboard-open`)&&!y(document.activeElement);if(f=!0,n.classList.remove(`oc-kb-hide`),c!==null&&(window.clearTimeout(c),c=null),!t){r(l),p(`--oc-kb-layout`,0),C(),p(`--oc-kb-scroll-inset`,Math.max(0,l-d)),n.classList.remove(`oc-keyboard-open`,`oc-kb-animating`,`oc-kb-caret-hold`),S(),u=!1,h(`oc:keyboard-settled`,{open:!0});return}n.classList.add(`oc-keyboard-open`);let i=O(l);h(`oc:keyboard-settled`,{open:!0}),h(`oc:keyboard-anim`,{phase:`show`,slide:i,durationMs:0,easing:o})}),j=()=>{let e=document.activeElement;e instanceof HTMLElement&&(e.tagName!==`TEXTAREA`&&e.tagName!==`INPUT`&&!e.isContentEditable||e.blur())},M=()=>{f||(window.scrollTo(0,0),document.body.scrollTop!==0&&(document.body.scrollTop=0))},N=()=>{f=!1,m(),c!==null&&(window.clearTimeout(c),c=null),n.classList.remove(`oc-keyboard-open`,`oc-kb-animating`,`oc-kb-caret-hold`,`oc-kb-hide`),r(0),p(`--oc-kb-scroll-inset`,0),p(`--oc-kb-layout`,0),u=!1,S(),M(),window.setTimeout(M,350)},P=()=>{if(n.classList.contains(`oc-native-ios-composer`)){N(),vn().blur(),h(`oc:keyboard-settled`,{open:!1});return}if(!f)return;f=!1,m(),h(`oc:keyboard-intent`,{open:!1}),j(),window.setTimeout(()=>{f||Zi(document.activeElement)&&(j(),h(`oc:keyboard-intent`,{open:!1}))},80),c!==null&&(window.clearTimeout(c),c=null),n.classList.remove(`oc-kb-caret-hold`,`oc-kb-animating`);let e=Math.max(0,l-d);n.classList.remove(`oc-keyboard-open`),r(0),p(`--oc-kb-scroll-inset`,0),p(`--oc-kb-layout`,0),u=!1,S(),M(),window.setTimeout(M,350),h(`oc:keyboard-anim`,{phase:`hide`,slide:e,durationMs:0,easing:o}),n.classList.add(`oc-kb-animating`,`oc-kb-hide`),s=window.setTimeout(()=>{s=null,n.classList.remove(`oc-kb-animating`,`oc-kb-hide`),h(`oc:keyboard-settled`,{open:!1})},260)},F=await i.addListener(`keyboardWillHide`,P),I=e=>e instanceof HTMLElement&&(e.tagName===`TEXTAREA`||e.tagName===`INPUT`||e.isContentEditable),L=e=>{if(f&&I(e.target)){if($i(e.relatedTarget)){p(`--oc-kb-scroll-inset`,0);return}window.setTimeout(()=>{if(f&&!Zi(document.activeElement)){if(I(document.activeElement)){m(),n.classList.remove(`oc-keyboard-open`,`oc-kb-animating`,`oc-kb-caret-hold`,`oc-kb-hide`),r(l),p(`--oc-kb-layout`,0),C(),p(`--oc-kb-scroll-inset`,Math.max(0,l-d)),u=!1,S(),h(`oc:keyboard-intent`,{open:!1}),h(`oc:keyboard-settled`,{open:!0});return}P()}},0)}};if(document.addEventListener(`focusout`,L,!0),e){m(),document.removeEventListener(`focusout`,L,!0),window.removeEventListener(`oc:keyboard-intent`,k),A.remove(),F.remove();return}t.push(m,()=>{c!==null&&(window.clearTimeout(c),c=null)},()=>document.removeEventListener(`focusout`,L,!0),()=>window.removeEventListener(`oc:keyboard-intent`,k),()=>void A.remove(),()=>void F.remove())}).catch(()=>void 0),()=>{e=!0,t.forEach(e=>e()),n.classList.remove(`oc-capacitor-app`,`oc-keyboard-open`,`oc-kb-animating`,`oc-kb-hide`,`oc-kb-caret-hold`,`oc-platform-android`),n.style.removeProperty(`--oc-keyboard-inset`),n.style.removeProperty(`--oc-kb-shift`),n.style.removeProperty(`--oc-kb-layout`),n.style.removeProperty(`--oc-kb-scroll-inset`)}},[])},zd=e=>{let t=Q.useRef(!1);Q.useEffect(()=>{if(!Ld())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)),j(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([46,1,14])).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])},Bd=e=>{Q.useEffect(()=>{if(!Ld())return;let t=!1,n=null;return j(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([46,1,14])).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])},Vd=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Hd={autoComplete:`off`,autoCorrect:`off`,spellCheck:!1},Ud=1e3,Wd=e=>{let t=Vd(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},Gd=(e,t)=>Wd(e?e.path:t),Kd=`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`,qd=({connection:e})=>{let{t}=ee(),n=e,{connections:r,isBusy:i,isPasswordBusy:a,error:o,pendingConnection:s}=n,[c,l]=Q.useState(``),[u,d]=Q.useState(``),[f,p]=Q.useState(``),[m,h]=Q.useState(!1),g=Q.useMemo(()=>ul(),[]),[_,v]=Q.useState(()=>!ul()),[y,b]=Q.useState(null),[x,S]=Q.useState(``),C=I(e=>{e.preventDefault(),n.connect({url:c,clientToken:f,label:u})}),w=I(e=>{n.redeemPairingConnection(e)}),T=I(()=>{n.setError(t(`mobile.connect.link.invalid`))}),E=I(async()=>{if(!(m||i)){n.setError(null),h(!0);try{let e=await dl();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=I(e=>{e.preventDefault(),n.submitPassword(x)}),O=I(()=>{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)(Ut,{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)(Z,{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`)?W(s):t(`mobile.connect.relay.badge`)})]})]}),(0,$.jsx)(`input`,{...Hd,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)(Ze,{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)(Ze,{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)(Ze,{type:`button`,size:`lg`,className:`h-12 w-full`,onClick:()=>void E(),disabled:m||i,children:[(0,$.jsx)(Z,{name:`scan-2`,className:X(`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)(Z,{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:X(`block truncate typography-small`,r?`text-foreground`:`text-muted-foreground`),children:t(r?`mobile.connect.connecting`:`mobile.instances.status.saved`)})]}),r?(0,$.jsx)(Z,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):(0,$.jsx)(Z,{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)(Z,{name:`arrow-down-s`,className:X(`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)(pl,{disabled:i||m,isBusy:i,tabIndex:_?void 0:-1,inputClassName:Kd,buttonVariant:g?`outline`:`default`,onRedeem:w,onInvalid:T})}),(0,$.jsx)(ml,{label:t(`mobile.connect.address.divider`)}),(0,$.jsxs)(`form`,{className:`flex w-full flex-col gap-3`,onSubmit:C,children:[(0,$.jsx)(`input`,{...Hd,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:Kd}),(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:Kd}),(0,$.jsx)(`input`,{...Hd,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:Kd}),(0,$.jsx)(`p`,{className:`px-1 text-center typography-micro text-muted-foreground`,children:t(`mobile.connect.token.hint`)}),(0,$.jsx)(Ze,{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]})})]})]})]})})},Jd=({connection:e,onActiveConnectionDeleted:t,onConnect:n})=>{let{t:r}=ee(),i=e,{connections:a,isBusy:o,isPasswordBusy:s,error:c,pendingConnection:l,connect:u,submitPassword:d,cancelPassword:f,saveConnection:p,removeConnection:m,subscribeConnected:h,setError:g}=i,[_,v]=Q.useState(null),y=_?a.find(e=>e.id===_)??null:null,b=y?!y.candidates.some(e=>e.kind===`direct`):!1,[x,S]=Q.useState(null),[C,w]=Q.useState(``),[T,E]=Q.useState(``),[D,O]=Q.useState(``),[k,A]=Q.useState(``),[j,M]=Q.useState(!1),N=Q.useMemo(()=>ul(),[]),[P,F]=Q.useState(!1),[L,R]=Q.useState(null),z=I(n);Q.useEffect(()=>h(z),[z,h]);let B=I(()=>{v(null),w(``),E(``),O(``),g(null),F(!1)}),V=I(e=>{e.preventDefault(),p({id:_??void 0,url:C,label:T,clientToken:D}).then(e=>{e&&B()})}),H=I(e=>{i.redeemPairingConnection(e)}),te=I(()=>{g(r(`mobile.connect.link.invalid`))}),G=I(async()=>{if(!j){g(null),M(!0);try{let e=await dl();switch(e.status){case`ok`:w(e.url),e.label&&E(e.label),e.clientToken&&O(e.clientToken),F(!0);break;case`pairing`:await i.redeemPairingConnection(e.pairing);break;case`permission-denied`:g(r(`mobile.connect.scan.permissionDenied`));break;case`invalid`:g(r(`mobile.connect.scan.invalid`));break;case`unsupported`:g(r(`mobile.connect.scan.unsupported`));break;case`failed`:g(r(`mobile.connect.scan.failed`))}}finally{M(!1)}}}),ne=I(e=>{e.preventDefault(),d(k)}),re=I(()=>{A(``),f()}),K=I(e=>{S(t=>t===e?null:e)}),ie=I(e=>{S(null),_===e&&B();let n=a.length===1;m(e).then(e=>{e&&(n||U(e))&&t()})}),q=`h-12 w-full rounded-[16px] border border-border/70 bg-surface-elevated px-4 text-[16px] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-primary focus:ring-2 focus:ring-primary/20`;return l?(0,$.jsx)(`div`,{className:`oc-settings-page-content`,children:(0,$.jsx)(Vn,{label:r(`mobile.connect.password.label`),itemId:`instances.manage`,children:(0,$.jsxs)(`form`,{className:`oc-settings-group-row flex flex-col gap-3`,onSubmit:ne,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)(Z,{name:`lock`,className:`size-[18px]`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`truncate typography-ui-label text-foreground`,children:l.label}),(0,$.jsx)(`p`,{className:`truncate typography-small text-muted-foreground`,children:l.candidates.some(e=>e.kind===`direct`)?W(l):r(`mobile.connect.relay.badge`)})]})]}),(0,$.jsx)(`input`,{...Hd,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:q}),c?(0,$.jsx)(`p`,{className:`px-1 typography-small text-[var(--status-error)]`,children:c}):null,(0,$.jsx)(Ze,{type:`submit`,size:`lg`,className:`mt-1 h-12 w-full`,disabled:s||!k.trim(),children:r(s?`mobile.connect.connecting`:`mobile.connect.unlockButton`)}),(0,$.jsx)(Ze,{type:`button`,variant:`ghost`,size:`sm`,className:`w-full`,onClick:re,children:r(`mobile.connect.cancelPassword`)})]})})}):(0,$.jsxs)(`div`,{className:`oc-settings-page-content`,children:[(0,$.jsx)(Vn,{label:r(`mobile.connect.saved.title`),itemId:`instances.manage`,children:a.length>0?a.map(e=>{let t=x===e.id,n=U(e),i=L===e.id,a=r(i?`mobile.connect.connecting`:n?`mobile.instances.status.connected`:`mobile.instances.status.saved`);return(0,$.jsxs)(`div`,{className:X(`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),u({id:e.id,candidates:e.candidates,clientToken:e.clientToken,label:e.label}).finally(()=>R(null)))},disabled:n||o&&!i||t,style:{touchAction:`manipulation`}}),(0,$.jsxs)(`div`,{className:`pointer-events-none relative z-[1] flex min-w-0 flex-1 items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`relative flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground`,children:(0,$.jsx)(Z,{name:`server`,className:`size-[18px]`})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:e.label})}),(0,$.jsx)(`span`,{className:X(`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)(Z,{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)(Z,{name:`loader-4`,className:`size-[18px] animate-spin`})}):(0,$.jsx)(`button`,{type:`button`,"aria-label":r(`mobile.instances.edit`),className:`flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:()=>{v(e.id),w(e.candidates.some(e=>e.kind===`direct`)?W(e):``),E(e.label),O(e.clientToken||``),g(null)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`edit`,className:`size-[18px]`})}),(0,$.jsx)(`button`,{type:`button`,"aria-label":r(t?`mobile.instances.cancelDeleteAria`:`mobile.instances.deleteAria`,{label:e.label}),className:`flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:()=>K(e.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{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)(Vn,{label:r(y?`mobile.instances.editTitle`:`mobile.instances.addTitle`),children:!P&&!y?(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex flex-col items-stretch gap-2`,children:[N?(0,$.jsxs)(Ze,{type:`button`,size:`lg`,className:`h-12 w-full`,onClick:()=>void G(),disabled:j,children:[(0,$.jsx)(Z,{name:`scan-2`,className:X(`size-[18px]`,j&&`animate-pulse`)}),r(`mobile.connect.scanQr`)]}):null,(0,$.jsxs)(Ze,{type:`button`,variant:N?`ghost`:`outline`,size:`lg`,className:`h-12 w-full`,onClick:()=>{g(null),F(!0)},children:[(0,$.jsx)(Z,{name:`add`,className:`size-[18px]`}),r(`mobile.instances.addManual`)]}),c?(0,$.jsx)(`p`,{className:`px-1 text-center typography-small text-[var(--status-error)]`,children:c}):null]}):(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex flex-col gap-3`,children:[(0,$.jsx)(`div`,{className:`flex min-h-8 items-center justify-end px-1`,children:(0,$.jsx)(Ze,{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:[b?null:(0,$.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,$.jsx)(`span`,{className:`block px-1 typography-ui-label text-foreground`,children:r(`mobile.connect.url.label`)}),(0,$.jsx)(`input`,{...Hd,value:C,onChange:e=>w(e.target.value),placeholder:r(`mobile.connect.url.placeholder`),type:`url`,inputMode:`url`,autoCapitalize:`none`,className:q})]}),(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:q})]}),(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`,{...Hd,value:D,onChange:e=>O(e.target.value),placeholder:r(`mobile.connect.token.placeholder`),autoCapitalize:`none`,className:q}),(0,$.jsx)(`p`,{className:`px-1 typography-micro text-muted-foreground`,children:r(`mobile.connect.token.hint`)})]}),(0,$.jsx)(Ze,{type:`submit`,size:`lg`,className:`mt-1 h-12 w-full`,children:r(y?`mobile.instances.saveEdit`:`mobile.instances.saveNew`)})]}),y?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ml,{label:r(`mobile.connect.link.divider`)}),(0,$.jsx)(pl,{disabled:o||j,isBusy:o,inputClassName:q,onRedeem:H,onInvalid:te})]}),c?(0,$.jsx)(`p`,{className:`px-1 typography-small text-[var(--status-error)]`,children:c}):null]})})]})},Yd=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`},Xd=e=>{let t=(0,xi.c)(13),{icon:n,iconNode:r,label:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=r??(n?(0,$.jsx)(Z,{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},Zd=e=>{let t=(0,xi.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=Q.useRef(null),[p,m]=Q.useState(n),[h,g]=Q.useState(!1),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=D(),t[0]=_):_=t[0];let v=_,y=Q.useRef(null),[b,x]=Q.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-Md-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]),Q.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]),Q.useEffect(T,E);let O,k;t[10]!==r||t[11]!==n?(O=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},k=[r,n],t[10]=r,t[11]=n,t[12]=O,t[13]=k):(O=t[12],k=t[13]),Q.useEffect(O,k);let A,j;if(t[14]!==i||t[15]!==r||t[16]!==n?(A=()=>{if(!n)return;let e=e=>{let t=e.target;if(!(t instanceof Node)){r();return}f.current?.contains(t)||i.current?.contains(t)||r()};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`wheel`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`wheel`,e,!0)}},j=[i,r,n],t[14]=i,t[15]=r,t[16]=n,t[17]=A,t[18]=j):(A=t[17],j=t[18]),Q.useEffect(A,j),!p)return null;let M;t[19]===d?M=t[20]:(M=d(`mobile.header.openMetadataAria`),t[19]=d,t[20]=M);let N=w?`absolute origin-top-left`:`mx-3 mt-2`,P=h?`pointer-events-none`:`pointer-events-auto`,F;t[21]!==N||t[22]!==P?(F=X(`overflow-y-auto overscroll-contain rounded-[20px] oc-mobile-overlay-surface p-2 will-change-transform`,N,P),t[21]=N,t[22]=P,t[23]=F):F=t[23];let I=`${h?`session-metadata-out`:`session-metadata-in`} ${h?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,L;t[24]!==b||t[25]!==w?(L=w?{top:8,left:b??8,width:`min(${Md}px, calc(100% - 16px))`}:null,t[24]=b,t[25]=w,t[26]=L):L=t[26];let R;t[27]!==I||t[28]!==L?(R={animation:I,maxHeight:`min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))`,...L},t[27]=I,t[28]=L,t[29]=R):R=t[29];let z;t[30]===d?z=t[31]:(z=d(`mobile.header.metadata.branch`),t[30]=d,t[31]=z);let B;t[32]!==o||t[33]!==z?(B=(0,$.jsx)(Xd,{icon:`git-branch`,label:z,children:o}),t[32]=o,t[33]=z,t[34]=B):B=t[34];let V;t[35]!==a||t[36]!==d?(V=a?(0,$.jsx)(Xd,{iconNode:(0,$.jsx)(ac,{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:X(`font-semibold`,a.colorClass),children:[a.percentage.toFixed(1),`%`]}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:a.tokens})]})}):null,t[35]=a,t[36]=d,t[37]=V):V=t[37];let H;t[38]!==l||t[39]!==u||t[40]!==c||t[41]!==s?(H=(0,$.jsx)(Qd,{groups:s,displayMode:c,isLoading:l,timeFormatPreference:u}),t[38]=l,t[39]=u,t[40]=c,t[41]=s,t[42]=H):H=t[42];let U;t[43]!==B||t[44]!==V||t[45]!==H?(U=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[B,V,H]}),t[43]=B,t[44]=V,t[45]=H,t[46]=U):U=t[46];let te;t[47]!==M||t[48]!==F||t[49]!==R||t[50]!==U?(te=(0,$.jsx)(`div`,{ref:f,role:`dialog`,"aria-label":M,className:F,style:R,children:U}),t[47]=M,t[48]=F,t[49]=R,t[50]=U,t[51]=te):te=t[51];let W;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(`style`,{children:`
|
|
17
|
-
@keyframes session-metadata-in {
|
|
18
|
-
from { opacity: 0; transform: translateY(-8px) scale(0.985); }
|
|
19
|
-
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
20
|
-
}
|
|
21
|
-
@keyframes session-metadata-out {
|
|
22
|
-
from { opacity: 1; transform: translateY(0) scale(1); }
|
|
23
|
-
to { opacity: 0; transform: translateY(-6px) scale(0.985); }
|
|
24
|
-
}
|
|
25
|
-
`}),t[52]=W):W=t[52];let G;return t[53]===te?G=t[54]:(G=(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,W]}),t[53]=te,t[54]=G),G},Qd=e=>{let t=(0,xi.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)(Z,{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)(Z,{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)(Ct,{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=Lt(e.window.valueLabel,t),i=Bt(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:X(`shrink-0 typography-ui-label font-semibold tabular-nums`,Yd(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},$d=e=>{let t=(0,xi.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]),Q.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:X(`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)(Z,{name:e.icon,className:X(`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:Dd,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:af,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},ef=Q.memo(function(e){let t=(0,xi.c)(88),{open:n,onOpenChange:r,currentSessionId:i,effectiveDirectory:a,gitDirectory:o,isNewSessionDraftOpen:s,primaryLabel:c,secondaryLabel:l}=e,{t:u}=ee(),{git:d}=un(),p=Vc(i??``,a||void 0),m=p??l,h=Q.useRef(null),g=ye(i??``,a||void 0),_=mn(o),v=hn(o),y=fn(of),b=fn(sf),x=Be(cf),S=Be(lf),C=Be(uf),w=Be(df),T;t[0]===i?T=t[1]:(T=e=>i?e.sessionModelSelections.get(i)??null:null,t[0]=i,t[1]=T);let E=We(T),D=$n(ff),O=$n(pf),k=$n(mf),A=$n(hf),j=$n(gf),M=$n(_f),N=$n(vf),P=f(yf);Un();let F,I;t[2]!==y||t[3]!==d||t[4]!==o?(F=()=>{o&&y(o,d)},I=[y,d,o],t[2]=y,t[3]=d,t[4]=o,t[5]=F,t[6]=I):(F=t[5],I=t[6]),Q.useEffect(F,I);let L,R;t[7]!==b||t[8]!==d||t[9]!==o?(L=()=>{if(o)return q.onGitRefreshHint(e=>{Vd(e.directory)===o&&b(o,d)})},R=[b,d,o],t[7]=b,t[8]=d,t[9]=o,t[10]=L,t[11]=R):(L=t[10],R=t[11]),Q.useEffect(L,R);let z,B;t[12]===O?(z=t[13],B=t[14]):(z=()=>{O()},B=[O],t[12]=O,t[13]=z,t[14]=B),Q.useEffect(z,B);let V,H;t[15]===M?(V=t[16],H=t[17]):(V=()=>{St(M)},H=[M],t[15]=M,t[16]=V,t[17]=H),Q.useEffect(V,H);let U,te;t[18]!==M||t[19]!==k||t[20]!==A||t[21]!==n||t[22]!==D?(U=()=>{!n||A||M.some(e=>!D.some(t=>t.providerId===e))&&k()},te=[M,k,A,n,D],t[18]=M,t[19]=k,t[20]=A,t[21]=n,t[22]=D,t[23]=U,t[24]=te):(U=t[23],te=t[24]),Q.useEffect(U,te);let W;t[25]===g?W=t[26]:(W=dc(g),t[25]=g,t[26]=W);let G=W,ne;if(t[27]!==g||t[28]!==C||t[29]!==S||t[30]!==w||t[31]!==s||t[32]!==G||t[33]!==x||t[34]!==E){let e=G??(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=sc(n?.limit,`context`)??r?.limit?.context??0,a;t[36]===g?a=t[37]:(a=fc(g),t[36]=g,t[37]=a),ne=uc({totalTokens:a,contextLimit:i,isDraft:s}),t[27]=g,t[28]=C,t[29]=S,t[30]=w,t[31]=s,t[32]=G,t[33]=x,t[34]=E,t[35]=ne}else ne=t[35];let re=ne,K;t[38]!==v?.current||t[39]!==_||t[40]!==u?(K=_===!0?v?.current?.trim()||u(`gitView.branch.detachedHead`):u(`common.unavailable`),t[38]=v?.current,t[39]=_,t[40]=u,t[41]=K):K=t[41];let ie=K,ae;if(t[42]!==M||t[43]!==D||t[44]!==N||t[45]!==u){let e=new Map(D.map(bf)),n;t[47]===M?n=t[48]:(n=e=>M.includes(e.id),t[47]=M,t[48]=n),ae=Hn.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:Vt(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:Vt(i),subtitle:Gn(e),window:a})}let s=!n.ok&&n.error?n.error:r.length===0?u(`header.services.noRateLimitsReported`):null;return{providerId:t.id,providerName:t.name,rows:r,status:s}}),t[42]=M,t[43]=D,t[44]=N,t[45]=u,t[46]=ae}else ae=t[46];let oe=ae,J,se;t[49]!==n||t[50]!==oe?(J=()=>{!n||oe.length===0||St(oe.map(xf))},se=[n,oe],t[49]=n,t[50]=oe,t[51]=J,t[52]=se):(J=t[51],se=t[52]),Q.useEffect(J,se);let ce;t[53]===c?ce=t[54]:(ce=(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:c}),t[53]=c,t[54]=ce);let le;t[55]!==m||t[56]!==p?(le=m?(0,$.jsx)(`span`,{className:X(`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]=le):le=t[57];let ue;t[58]!==ce||t[59]!==le?(ue=(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center px-2 py-1.5 text-left`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[ce,le]})}),t[58]=ce,t[59]=le,t[60]=ue):ue=t[60];let de;t[61]===u?de=t[62]:(de=u(`mobile.header.openMetadataAria`),t[61]=u,t[62]=de);let fe;t[63]===r?fe=t[64]:(fe=()=>r(Sf),t[63]=r,t[64]=fe);let pe;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(pe={touchAction:`manipulation`},t[65]=pe):pe=t[65];let me=re?.percentage??0,he;t[66]===me?he=t[67]:(he=(0,$.jsx)(ac,{percentage:me}),t[66]=me,t[67]=he);let ge;t[68]!==n||t[69]!==de||t[70]!==fe||t[71]!==he?(ge=(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":de,"aria-expanded":n,onClick:fe,style:pe,children:he}),t[68]=n,t[69]=de,t[70]=fe,t[71]=he,t[72]=ge):ge=t[72];let _e;t[73]===r?_e=t[74]:(_e=()=>r(!1),t[73]=r,t[74]=_e);let ve;t[75]!==ie||t[76]!==re||t[77]!==A||t[78]!==n||t[79]!==j||t[80]!==_e||t[81]!==P||t[82]!==oe?(ve=(0,$.jsx)(Zd,{open:n,onClose:_e,anchorRef:h,contextDisplay:re,branchLabel:ie,usageGroups:oe,usageDisplayMode:j,isUsageLoading:A,timeFormatPreference:P}),t[75]=ie,t[76]=re,t[77]=A,t[78]=n,t[79]=j,t[80]=_e,t[81]=P,t[82]=oe,t[83]=ve):ve=t[83];let be;return t[84]!==ue||t[85]!==ge||t[86]!==ve?(be=(0,$.jsxs)($.Fragment,{children:[ue,ge,ve]}),t[84]=ue,t[85]=ge,t[86]=ve,t[87]=be):be=t[87],be}),tf=({onOpenSessions:e,menuOpen:t,onToggleMenu:n,surfaceShortcuts:r})=>{let{t:i}=ee(),[a,o]=Q.useState(!1),s=w(e=>e.currentDirectory),c=ke(e=>e.currentSessionId),l=Q.useMemo(()=>e=>c?e.getDirectoryForSession(c):null,[c]),u=ke(l)||s,d=Vd(u)||null,f=xe(e=>e.projects),p=ke(e=>e.availableWorktreesByProject),m=Q.useMemo(()=>e=>c?e.worktreeMetadata.get(c)??null:null,[c]),h=ke(m),g=he(c),_=ke(e=>!!e.newSessionDraft?.open),v=Q.useMemo(()=>{let e=Vd(u);return e&&Gd((h?.projectDirectory?ce(f,h.projectDirectory):null)??fe(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:``;Q.useEffect(()=>{o(!1)},[c,u]);let x=I(()=>{o(!1),e()}),S=I(()=>{o(!1),n()});return(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(Yi,{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)(Z,{name:`folders`,className:`size-5`})}),(0,$.jsx)(ef,{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:X(`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)(Z,{name:`file-text`,className:`size-5`})}),(0,$.jsxs)(`button`,{type:`button`,className:X(`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)(Z,{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":Dd,"aria-expanded":t,"aria-haspopup":`menu`,onClick:S,style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`more-2`,className:`size-5`})})]})})},nf=({connection:e,onActiveConnectionDeleted:t})=>{let{t:n}=ee(),r=an();Ue(),Ve();let i=f(e=>e.mobileSessionPanelOpen),a=f(e=>e.setMobileSessionPanelOpen),o=f(e=>e.isScheduledTasksDialogOpen),s=f(e=>e.activeMainTab),c=Ge(),l=f(e=>e.setActiveMainTab),[u,d]=Q.useState(!1),[p,m]=Q.useState(!1),[h,g]=Q.useState(null),[_,v]=Q.useState(!1),[y,b]=Q.useState(!1),[x,S]=Q.useState(null),[C,T]=Q.useState(null),[E,O]=Q.useState(null),[k,A]=Q.useState(0),[j,M]=Q.useState(!1),[N,P]=Q.useState(!1),[L,R]=Q.useState(!1),[z,B]=Q.useState(!1),[V,H]=Q.useState(!1),[U,te]=Q.useState(!1),[W,G]=Q.useState(`nav`),[ne,re]=Q.useState(!1),[K,ie]=Q.useState(!1),ae=I(()=>re(e=>!e)),oe=I(()=>re(!1)),[J,se]=Q.useState(null),ce=w(e=>e.currentDirectory),le=f(e=>e.setSettingsPage),ue=Rn(e=>e.available),de=Rn(e=>e.runtimeType),fe=Q.useMemo(()=>Ld(),[]),pe=Q.useMemo(()=>ul(),[]),{data:me=[],refetch:he}=Bn(ce??null,{enabled:j}),{refetch:ve}=Xn(ce??null,{enabled:j}),ye=Gr(e=>e.setMcpDraft),be=Gr(e=>e.setSelectedMcp),xe=hn(Vd(ce)||null)?.files?.length??0;Q.useEffect(()=>q.onDirectoryRequest(()=>H(!0)),[]);let Se=Q.useMemo(()=>D(),[]),Ce=Yt()===`portrait`,[we,Te]=Q.useState(Se&&!Ce),[Ee,Y]=Q.useState(null),De=I(e=>{if(e&&le(e),Se){G(e?`page-content`:`nav`),R(!0);return}Le.getState().setActiveTab(`settings`)}),Oe=I(()=>{De(`instances`)}),Ae=I(()=>{Le.getState().openInstances()}),je=I(()=>{Le.getState().closeSecondary()}),Me=I(async()=>{if(!U){te(!0);try{let t=await dl();switch(t.status){case`ok`:await e.connect({url:t.url,clientToken:t.clientToken,label:t.label});break;case`pairing`:await e.redeemPairingConnection(t.pairing);break;case`permission-denied`:F.error(n(`mobile.connect.scan.permissionDenied`));break;case`invalid`:F.error(n(`mobile.connect.scan.invalid`));break;case`unsupported`:F.error(n(`mobile.connect.scan.unsupported`));break;case`failed`:F.error(n(`mobile.connect.scan.failed`))}}finally{te(!1)}}});Cn({enabled:!Se,rootRoutesBlocked:i||u||p||_||y||o||j||L||z||V||ne});let Ne=I(()=>{let e=!we;e&&Ce&&Y(null),Te(e)}),Pe=I(()=>{if(b(!1),S(null),T(null),m(!1),g(null),Se){se(null),Y(`files`),Ce&&Te(!1);return}d(!0)}),Fe=I(()=>{m(!1),g(null)}),Ie=I(e=>{let t=e.path.trim();if(t){if(b(!1),S(null),T(null),se(null),v(!1),Se){f.getState().setPendingFileFocusPath(t),Y(`files`),Ce&&Te(!1);return}d(!1),g({path:t,targetLine:typeof e.targetLine==`number`&&Number.isFinite(e.targetLine)?Math.max(1,Math.trunc(e.targetLine)):void 0}),m(!0)}}),Re=f(e=>e.pendingFileFocusPath);Q.useEffect(()=>{if(Re){if(Se){Pe();return}Ie({path:Re}),f.getState().setPendingFileFocusPath(null)}},[Re,Se,Pe,Ie]);let ze=I((e=null)=>{if(b(!1),S(null),T(null),O(null),m(!1),g(null),se(e),Se){Y(`changes`),Ce&&Te(!1);return}v(!0)}),Be=I((e,t,n)=>{se(null),v(!1),m(!1),g(null),S(e??null),T(typeof t==`string`&&t.trim()?t.trim():null);let r=typeof n==`string`&&n.trim()?n.trim():null;if(O(r),A(e=>e+1),Se){Y(`turn-diff`),Ce&&Te(!1);return}b(!0)}),He=I(()=>{Y(null),se(null),O(null)}),We=I(e=>{if(Ee===e){He();return}e===`files`?Pe():ze()}),qe=Q.useRef(`changes`);Ee&&(qe.current=Ee);let[Je,Ye]=Q.useState(!1);Q.useEffect(()=>{if(!Se)return;if(Ee){Ye(!0);return}let e=window.setTimeout(()=>Ye(!1),240);return()=>window.clearTimeout(e)},[Ee,Se]);let Xe=Ee??qe.current,Qe=Fd(`left`,`openchamber.ipad.leftSidebarWidth`,Od),$e=Fd(`right`,`openchamber.ipad.rightSidebarWidth`,kd),et=Q.useMemo(()=>({openChanges:({diffPath:e,staged:t,targetLine:n}={})=>{ze(e?{path:e,staged:t===!0,targetLine:n}:null)},openToolDiff:({diffPath:e,patches:t,targetLine:n})=>{ze({path:e,staged:!1,targetLine:n,toolPatches:t})},openTurnDiff:Be,openFile:({path:e,targetLine:t})=>{Ie({path:e,targetLine:t})},openFiles:()=>Pe(),openSettings:e=>{De(e)}}),[ze,Ie,Pe,De,Be]),tt=I(()=>{v(!1),se(null)}),nt=I(()=>{b(!1),O(null)});Pl(Q.useMemo(()=>({openSessions:()=>{if(Se){Te(!0);return}Le.getState().setActiveTab(`projects`)},openView:e=>{e===`files`?Pe():e===`mcp`?M(!0):e===`instances`?Oe():e===`update`&&B(!0)},openChanges:({path:e,staged:t}={})=>{ze(e?{path:e,staged:t===!0}:null)},openSettings:e=>{De(e)}}),[Se,ze,Pe,Oe,De]));let rt=Q.useRef(null),it=Q.useRef(null),at=Q.useRef(null),ot=Q.useRef(null),st=Q.useRef(null),ct=Q.useRef(null),lt=ke(e=>e.currentSessionId),ut=ke(e=>e.setCurrentSession),dt=Q.useMemo(()=>e=>lt?e.getDirectoryForSession(lt):null,[lt]),ft=ke(dt),pt=ge(lt,ft||ce||void 0),mt=_e(lt??``);vd();let ht=mt?.type===`busy`||mt?.type===`retry`,gt=I(()=>{let e=lt;if(!e||K||ht)return;let t=ft||ce||void 0;ie(!0),(async()=>{try{await r.refreshSessionTranscript(e,{directory:t}),F.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{F.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{ie(!1)}})()}),_t=I(e=>{ct.current=e}),vt=I(e=>{let t=at.current,n=ot.current,r=st.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`)})}),yt=Le(e=>e.secondary?.kind??null),bt=!Se&&(yt===`chat`||yt===`draft`);Q.useEffect(()=>{!Se&&!bt&&re(!1)},[Se,bt]),Q.useEffect(()=>{re(!1)},[lt]),$l(it,{onSwitch:_t,onProgress:vt},Se||bt);let xt=Se&&s===`assistant`||!Se&&!bt||i||u||p||_||y||o||j||L||z||V||ne;yu(it,{onOpen:I(()=>{Tt(wt)?.finish(`commit`)}),onPreviewStart:I(()=>{Tt(wt)?.begin(`present`)}),onPreviewCancel:I(()=>{Tt(wt)?.finish(`cancel`)}),onProgress:I(e=>{e!==null&&Tt(wt)?.update(e)}),disabled:xt},Se||bt),Q.useLayoutEffect(()=>{let e=ct.current;if(ct.current=null,!e)return;let t=at.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)`})},[lt]);let St=I(e=>{rt.current=e});Bd(I(()=>ne?(re(!1),!0):V?(H(!1),!0):o?(window.dispatchEvent(new Event(`oc:scheduled-tasks-close-request`)),!0):i?(a(!1),!0):Tn.backImmediately(`overlay`)?!0:p?(Fe(),!0):u?(d(!1),!0):y?(nt(),!0):_?(tt(),!0):j?(M(!1),!0):L?(R(!1),!0):z?(B(!1),!0):Tn.requestAnimatedBack(`root`)||rt.current?.()?!0:s===`assistant`?(l(`chat`),!0):pt?(ut(pt.id,pt.directory),!0):!1));let Ct=ue&&(de===`desktop`||de===`web`),Dt=I(()=>{let e=`new-mcp-server`,t=e,n=1;for(;me.some(e=>e.name===t);)t=`${e}-${n}`,n+=1;ye({name:t,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),be(t),M(!1),De(`mcp`)}),Ot=I(()=>{if(N)return;P(!0);let e=new Promise(e=>window.setTimeout(e,500));Promise.all([ve(),he(),e]).finally(()=>P(!1))}),kt=ke(e=>e.openNewSessionDraft),At=Q.useMemo(()=>{let e=[{key:`new-session`,icon:`chat-new`,label:n(`mobile.menu.newSession`),onSelect:()=>{if(Se){l(`chat`),kt();return}Le.getState().openDraft()}}];return Se||e.push({key:`files`,icon:`file-text`,label:n(`mobile.menu.files`),onSelect:()=>Pe()},{key:`changes`,icon:`git-branch`,label:n(`mobile.menu.changes`),badge:xe,onSelect:()=>ze()}),e.push({key:`mcp`,iconNode:(0,$.jsx)(zn,{className:`size-5 shrink-0 text-muted-foreground`}),label:n(`mobile.menu.mcp`),onSelect:()=>M(!0)}),Ct&&e.push({key:`update`,icon:`download`,label:n(`mobile.menu.update`),onSelect:()=>B(!0)}),Se&&e.push({key:`settings`,icon:`settings-3`,label:n(`mobile.menu.settings`),onSelect:()=>De()}),lt&&e.push({key:`refresh-transcript`,icon:`refresh`,label:n(`sessions.sidebar.session.menu.refreshTranscript`),disabled:K||ht,spinning:K,onSelect:gt}),e},[lt,xe,Se,ht,K,ze,Pe,kt,De,gt,l,Ct,n]);return(0,$.jsxs)(en,{actions:et,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:[Se?(0,$.jsxs)(`aside`,{ref:Qe.asideRef,className:X(`relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/50 bg-sidebar will-change-[width] motion-reduce:transition-none`,!we&&`border-r-0`),style:{width:we?Qe.width:0,minWidth:we?Qe.width:0,maxWidth:we?Qe.width:0,"--oc-ipad-sidebar-width":`${Qe.width}px`,overflowX:`clip`,paddingTop:`var(--oc-safe-area-top, 0px)`,transitionProperty:Qe.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)(Id,{side:`left`,isResizing:Qe.isResizing,ariaLabel:n(`sidebar.resize.leftPanelAria`),handleProps:Qe.handleProps}):null,(0,$.jsx)(`div`,{className:X(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,Qe.isResizing&&`pointer-events-none`,!we&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:(0,$.jsx)(Wt,{children:(0,$.jsx)(no,{open:!0,variant:`sidebar`,onOpenChange:e=>{!e&&Ce&&Te(!1)}})})})]}):null,(0,$.jsx)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,"data-page-scroll-lock":`true`,children:Se?(0,$.jsxs)($.Fragment,{children:[s===`assistant`?null:(0,$.jsx)(`div`,{children:(0,$.jsx)(tf,{onOpenSessions:()=>Ne(),menuOpen:ne,onToggleMenu:ae,surfaceShortcuts:{activePanel:Ee===`turn-diff`?`changes`:Ee,changesDirty:xe>0,onToggleFiles:()=>We(`files`),onToggleChanges:()=>We(`changes`)}})}),(0,$.jsxs)(`main`,{ref:it,className:`relative min-h-0 flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:[(0,$.jsxs)(`div`,{ref:ot,"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)(Z,{name:`arrow-left`,className:`size-5`})})]}),(0,$.jsxs)(`div`,{ref:st,"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)(Z,{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:at,className:`relative h-full w-full bg-background`,children:(0,$.jsx)(Wt,{children:s===`assistant`?(0,$.jsx)(ri,{}):(0,$.jsx)(fr,{})})})]})]}):(0,$.jsx)(qs,{className:`min-h-0 flex-1`,onAddProject:()=>H(!0),onScanQr:fe&&pe?()=>{Me()}:void 0,onSwitchInstance:fe?Ae:void 0,onEnableAssistants:()=>{De(`assistants`)},instancesPage:fe?(0,$.jsx)(Jd,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t}):void 0,instancesSecondaryPage:fe?(0,$.jsxs)(`div`,{className:`oc-settings-workspace oc-settings-workspace-mobile flex h-full min-h-0 flex-col bg-[var(--surface-background)]`,children:[(0,$.jsx)(Ke,{title:n(`mobile.settings.switchInstance`),backAriaLabel:n(`header.actions.backAria`),onBack:je}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-[var(--oc-mobile-page-inline-inset)]`,children:(0,$.jsx)(qn,{className:`oc-mobile-settings-detail-card`,children:(0,$.jsx)(Jd,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t})})})]}):void 0,parentSessionTarget:pt?{id:pt.id,directory:pt.directory}:null,registerSecondaryBackHandler:St,scheduledContent:(e,t)=>(0,$.jsx)(Pr,{presentation:`mobile-tab`,registerEditorBackHandler:e,onEditorActiveChange:t}),renderChat:e=>(0,$.jsx)(Kc,{sessionId:e.sessionId,directory:e.directory,onBack:()=>{oe(),Tn.requestAnimatedBack(`root`)},onOpenMenu:ae,onCloseMenu:oe,menuOpen:e.active&&ne,children:(0,$.jsxs)(`main`,{ref:e.active?it: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:ot,"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)(Z,{name:`arrow-left`,className:`size-5`})})]}),(0,$.jsxs)(`div`,{ref:st,"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)(Z,{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?at:void 0,className:`relative h-full w-full bg-background`,children:(0,$.jsx)(Wt,{children:(0,$.jsx)(fr,{readOnly:!e.active,active:e.active,selectionOverride:{sessionId:e.sessionId||null,directory:e.directory,viewKey:e.viewKey}})})})]})})})}),Se?(0,$.jsxs)(`aside`,{ref:$e.asideRef,className:X(`relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/50 bg-background will-change-[width] motion-reduce:transition-none`,!Ee&&`border-l-0`),style:{width:Ee?$e.width:0,minWidth:Ee?$e.width:0,maxWidth:Ee?$e.width:0,"--oc-ipad-sidebar-width":`${$e.width}px`,overflowX:`clip`,paddingTop:`var(--oc-safe-area-top, 0px)`,transitionProperty:$e.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!Ee,"data-page-scroll-lock":`true`,children:[Ee?(0,$.jsx)(Id,{side:`right`,isResizing:$e.isResizing,ariaLabel:n(`sidebar.resize.rightPanelAria`),handleProps:$e.handleProps}):null,(0,$.jsx)(`div`,{className:X(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,$e.isResizing&&`pointer-events-none`,!Ee&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:Je?(0,$.jsx)(Wt,{children:Xe===`files`?(0,$.jsx)(ba,{onClose:He}):Xe===`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)(Ze,{type:`button`,variant:`ghost`,size:`icon`,onClick:He,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(ir,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:x,sessionId:C,targetFilePath:E,navigationRequestKey:k,flushContent:!0})})]}):J?.toolPatches?.length?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/40 px-3`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground`,children:J.toolPatches.length>1?n(`mobile.nav.changes`):J.path}),(0,$.jsx)(Ze,{type:`button`,variant:`ghost`,size:`icon`,onClick:He,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(ir,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:J.path,targetLine:J.targetLine??null,toolPatches:J.toolPatches,singleFileView:J.toolPatches.length===1,flushContent:!0})})]}):(0,$.jsx)(sa,{onClose:He,initialDiffPath:J?.path??null,initialDiffStaged:J?.staged===!0,initialDiffTargetLine:J?.targetLine??null})}):null})]}):null,(0,$.jsx)(jr,{open:V,onOpenChange:H,forceMobile:!0}),(0,$.jsx)($d,{open:ne,onClose:()=>re(!1),items:At,rightOffset:Se&&Ee?$e.width:0}),(0,$.jsx)(Tr,{}),u?(0,$.jsx)(Et,{id:Sd,open:u,onOpenChange:e=>{e||d(!1)},ariaLabel:n(`mobile.menu.files`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(Wt,{children:(0,$.jsx)(ba,{onClose:()=>d(!1)})})}):null,p&&h?(0,$.jsx)(Et,{id:xd,open:p,onOpenChange:e=>{e||Fe()},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)(Wt,{children:(0,$.jsx)(ba,{onClose:Fe,initialFilePath:h.path,directFilePreview:!0,hideFileHeader:!0},h.path)})}):null,(0,$.jsx)(Et,{id:bd,open:y,onOpenChange:e=>{e||nt()},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)(Wt,{children:(0,$.jsx)(ir,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:x,sessionId:C,targetFilePath:E,navigationRequestKey:k,flushContent:!0})})}),_&&J?(0,$.jsx)(Et,{id:yd,open:_,onOpenChange:e=>{e||tt()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:J.toolPatches&&J.toolPatches.length>1?n(`mobile.nav.changes`):J.path}),ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(Wt,{children:J.toolPatches?.length?(0,$.jsx)(ir,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:J.path,targetLine:J.targetLine??null,toolPatches:J.toolPatches,singleFileView:J.toolPatches.length===1,flushContent:!0}):(0,$.jsx)(sa,{initialDiffPath:J.path,initialDiffStaged:J.staged,initialDiffTargetLine:J.targetLine??null,hideDiffHeader:!0})})}):_?(0,$.jsx)(Et,{id:Cd,open:_,onOpenChange:e=>{e||tt()},ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(Wt,{children:(0,$.jsx)(sa,{onClose:tt,initialDiffPath:J?.path??null,initialDiffStaged:J?.staged===!0,initialDiffTargetLine:J?.targetLine??null})})}):null,j?(0,$.jsx)(Et,{id:wd,open:j,onOpenChange:e=>{e||M(!1)},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mcpDropdown.title`)}),trailing:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ze,{type:`button`,variant:`ghost`,size:`icon`,onClick:Dt,"aria-label":n(`settings.mcp.sidebar.actions.addServerTitle`),title:n(`settings.mcp.sidebar.actions.addServerTitle`),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`add`,className:`size-5`})}),(0,$.jsx)(Ze,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ot,disabled:N,"aria-label":n(`mcpDropdown.actions.refreshAria`),title:n(`mcpDropdown.actions.refreshAria`),style:{touchAction:`manipulation`},children:(0,$.jsx)(Z,{name:`refresh`,className:X(`size-5`,N&&`animate-spin`)})})]}),ariaLabel:n(`mcpDropdown.title`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(Wt,{children:(0,$.jsx)(yr,{active:!0,className:`h-full`,listClassName:`max-h-none`,hideHeader:!0,mobileListDensity:!0})})}):null,L&&Se?(0,$.jsx)(Et,{id:Td,open:L,onOpenChange:e=>{e||R(!1)},ariaLabel:n(`mobile.menu.settings`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(Wt,{children:(0,$.jsx)(Xr,{forceMobile:!0,isWindowed:!0,initialMobileStage:W,visiblePageSlugs:[...Jn],onClose:()=>R(!1),mobileInstancesPage:fe?(0,$.jsx)(Jd,{connection:e,onConnect:()=>R(!1),onActiveConnectionDeleted:t}):void 0})})}):null,z?(0,$.jsx)(Et,{id:Ed,open:z,onOpenChange:e=>{e||B(!1)},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mobile.menu.update`)}),ariaLabel:n(`mobile.menu.update`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(Wt,{children:(0,$.jsx)(`div`,{className:`h-full overflow-auto px-5 py-4`,children:(0,$.jsx)(Kr,{initialUpdateDialogOpen:!0})})})}):null]}),(0,$.jsx)(Ur,{enabled:fe&&s===`assistant`&&c.data?.supported===!0&&c.data?.enabled===!0}),(0,$.jsx)(Wt,{children:(0,$.jsx)(Hr,{})})]})};function rf({apis:e}){Q.useEffect(()=>Se(),[]);let{t:r}=ee(),i=Be(e=>e.initializeApp),a=Be(e=>e.isInitialized),o=Be(e=>e.isConnected),s=Be(e=>e.connectionPhase),c=w(e=>e.currentDirectory),l=ke(e=>e.currentSessionId),d=ke(e=>!!e.newSessionDraft?.open),p=ke(e=>e.error),h=ke(e=>e.clearError),g=f(e=>e.setIsMobile),_=Yn(e=>e.refreshStatus),v=xe(e=>e.projects),[y,b]=Q.useState(0),[x,S]=Q.useState(0),[C,E]=Q.useState(!1),[D,O]=Q.useState(`pending`),k=Q.useMemo(()=>K(),[]),[,A]=Q.useReducer(e=>e+1,0),M=Q.useMemo(()=>Ld(),[]),N=Q.useRef(0),L=Q.useRef(0),R=ne(()=>{O(`done`),b(e=>e+1)});Fl(I(e=>{R.redeemPairingConnection(e)}));let z=Il({ready:M&&o&&a});Q.useEffect(()=>{!R.error||!n()||F.error(R.error)},[R.error]);let B=I(()=>{let t=n(),r=L.current+1;if(L.current=r,!t){H();return}let a=()=>{i(),_(e.github,{force:!0}),Be.getState().refreshMissingCatalogs({source:`mobileApp:nativeResume`})},o=()=>{u({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),b(e=>e+1)};te().then(e=>{if(L.current===r){if(e===`no-connection`){o();return}if(e===`unreachable`){window.setTimeout(()=>{L.current===r&&te().then(e=>{if(L.current===r&&e!==`switched`&&e===`unchanged`){a();return}})},4e3);return}e!==`switched`&&a()}});let s=Date.now();s-N.current>=Ud&&(N.current=s,window.dispatchEvent(new Event(`openchamber:system-resume`)))});Rd(),zd(B),Q.useEffect(()=>{if(!M)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>B(),1500)};return window.addEventListener(`online`,t),()=>{window.removeEventListener(`online`,t),window.clearTimeout(e)}},[M,B]),Q.useEffect(()=>(m(e),()=>m(null)),[e]),Q.useEffect(()=>{M&&P().then(e=>{e&&e.notifyAppReady().catch(()=>void 0)})},[M]),Q.useEffect(()=>{if(!M)return;let e=!1,t=[];return P().then(async n=>{if(!(!n||e))try{let r=await n.addListener(`download`,e=>{Rn.getState().setOtaDownloadPercent(e.percent)}),i=await n.addListener(`downloadFailed`,()=>{Rn.getState().setOtaDownloadFailed()}),a=await n.addListener(`downloadComplete`,()=>{Rn.getState().setOtaPhase(`pending_restart`)}),o=await n.addListener(`appReloaded`,()=>{Rn.getState().setOtaPhase(`pending_restart`)}),s=await n.addListener(`autoRevert`,()=>{console.warn(`[OTA] Capgo auto-reverted the last bundle`),Rn.getState().setOtaPhase(`error`,`OTA update was reverted`)});if(e){r.remove(),i.remove(),a.remove(),o.remove(),s.remove();return}t.push(()=>void r.remove(),()=>void i.remove(),()=>void a.remove(),()=>void o.remove(),()=>void s.remove())}catch(e){console.warn(`[OTA] Failed to subscribe to Capgo updater events:`,e)}}),()=>{e=!0;for(let e of t)e()}},[M]),Q.useEffect(()=>t(e=>{if(e.runtimeKey&&e.runtimeKey===e.previousRuntimeKey){Lr(),A();return}Mr(e),Le.getState().reset(),S(e=>e+1),b(e=>e+1)}),[]),Q.useEffect(()=>{if(z===`pending`)return;if(z===`connect`){O(`done`);return}if(!M||o||n()){O(`done`);return}let e=!1;return O(`attempting`),G().then(e=>e?!0:H()).catch(()=>!1).then(()=>{e||O(`done`)}),()=>{e=!0}},[z]),Q.useEffect(()=>{g(!0)},[g]),Q.useEffect(()=>{M&&!n()||i()},[y,i,M]),rt({enabled:!M||!!n(),source:`mobileApp:recovery`}),Q.useEffect(()=>{o&&T.setDirectory(c)},[c,o]),Q.useEffect(()=>{o&&_(e.github,{force:!0})},[e.github,o,_]),Q.useEffect(()=>{if(!o||v.length===0)return;let e=!1;return(async()=>{await Promise.all(v.map(async t=>{let n=Vd(t.path);if(n)try{if(!(fn.getState().directories.get(n)?.isGitRepo??await j(()=>import(`./gitApi-CIStyhfQ.js`).then(e=>e.S).then(e=>e.checkIsGitRepository(n)),__vite__mapDeps([50,1,5,2,3,4,6,7,8,34,35,14,36,37,38,9,10,11,12,13,39,40])))||e)return;await kt({id:t.id,path:n},{isCurrent:()=>!e})}catch{}}))})(),()=>{e=!0}},[o,v]),Q.useEffect(()=>{if(!p)return;let e=window.setTimeout(()=>h(),5e3);return()=>window.clearTimeout(e)},[h,p]),Q.useEffect(()=>{if(!(!o&&(!M||n()))){E(!1);return}let e=window.setTimeout(()=>E(!0),8e3);return()=>window.clearTimeout(e)},[o,M,y,x]),bt(),it({enabled:!0}),dt(),zr(),Su({enabled:M&&o});let V=hl(),U=!o&&s===`reconnecting`;if(!V)return(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(Ut,{width:120,height:120,isAnimated:!0})});let W=!!n();return M&&(!W||!o&&!U)?W?(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)(Ut,{width:120,height:120,isAnimated:!C}),C?(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)(Ze,{type:`button`,variant:`outline`,onClick:()=>{u({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),b(e=>e+1)},children:r(`mobile.connect.cancelPassword`)})]}):null]})}):D===`done`?(0,$.jsx)(qd,{connection:R}):(0,$.jsxs)(`main`,{className:`relative flex min-h-dvh items-center justify-center bg-background text-foreground`,children:[(0,$.jsx)(Ut,{width:120,height:120,isAnimated:!0}),k?(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:[k,(0,$.jsx)(nn,{})]})]}):null]}):!o&&!U?C?(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)(Ut,{width:120,height:120,isAnimated:!0})}):(0,$.jsx)(Wt,{children:(0,$.jsx)(de,{sdk:T.getSdkClient(),directory:c||``,bootstrapDirectory:!(d&&l===null),children:(0,$.jsx)(xt,{apis:e,children:(0,$.jsx)(It,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:`h-full bg-background text-foreground`,children:[(0,$.jsx)(br,{}),(0,$.jsx)(re,{}),(0,$.jsx)(ht,{embeddedBackgroundWorkEnabled:a}),(0,$.jsx)(dr,{}),(0,$.jsx)(Di,{}),(0,$.jsx)(Li,{}),(0,$.jsx)(nf,{connection:R,onActiveConnectionDeleted:()=>{u({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),Le.getState().reset(),b(e=>e+1)}}),(0,$.jsx)(ut,{position:`top-center`,offset:`calc(var(--oc-safe-area-top, 0px) + 16px)`}),a?(0,$.jsx)(Fr,{}):null]})})})},x)})}function af(e){e.currentTarget.style.transform=`none`}function of(e){return e.ensureStatus}function sf(e){return e.fetchStatus}function cf(e){return e.providers}function lf(e){return e.currentProviderId}function uf(e){return e.currentModelId}function df(e){return e.getModelMetadata}function ff(e){return e.results}function pf(e){return e.loadSettings}function mf(e){return e.fetchAllQuotas}function hf(e){return e.isLoading}function gf(e){return e.displayMode}function _f(e){return e.dropdownProviderIds}function vf(e){return e.selectedModels}function yf(e){return e.timeFormatPreference}function bf(e){return[e.providerId,e]}function xf(e){return e.providerId}function Sf(e){return!e}var Cf=()=>{B(),v().then(()=>{Promise.all([_(),lt()]).catch(e=>{console.error(`[mobile-main] settings init failed:`,e)}),mt(),ft(),ot()}).catch(e=>{console.error(`[mobile-main] appearance init failed:`,e)}).finally(()=>{fi()})};function wf(e){wn(),Cf(),f.getState().setIsMobile(!0),bi(),Xt(),Zt();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)(rf,{apis:r});(0,ci.createRoot)(t).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(pt,{children:(0,$.jsx)(L,{children:(0,$.jsx)(at,{children:(0,$.jsx)(ct,{children:(0,$.jsx)(tr,{children:n?i:(0,$.jsx)(_t,{children:i})})})})})})}))}export{wf as renderMobileApp};
|