@openchambery/web 1.19.14 → 1.19.15-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/assets/{AssistantView-Dncbu_Z2.js → AssistantView-D5rEZ-Ss.js} +2 -2
  2. package/dist/assets/{DiagramView-CovEl1BY.js → DiagramView-DaB9Sb7S.js} +1 -1
  3. package/dist/assets/MarkdownRenderer-emLeoNjI.js +2 -0
  4. package/dist/assets/{MarkdownRendererImpl-CCfHY-86.js → MarkdownRendererImpl-BWCAPlqn.js} +1 -1
  5. package/dist/assets/{MarkstreamRendererImpl-y6QgIUZA.js → MarkstreamRendererImpl-BD_NFKUv.js} +1 -1
  6. package/dist/assets/MobileDetailNavigation-DqXVAIap.js +1 -0
  7. package/dist/assets/{MobileShareBridge-B4S7BaUj.js → MobileShareBridge-Bk2fdkJk.js} +1 -1
  8. package/dist/assets/MobileSurface-C4mpcOCh.js +2 -0
  9. package/dist/assets/{MultiRunWindow-BeHa-CG6.js → MultiRunWindow-rs49_K1E.js} +1 -1
  10. package/dist/assets/{SettingsView-Dn7odtQz.js → SettingsView-b8LUjoad.js} +2 -2
  11. package/dist/assets/{SettingsWindow-C0tWPS5f.js → SettingsWindow-D8JFlPdA.js} +1 -1
  12. package/dist/assets/{TerminalView-BnJgC7Qo.js → TerminalView-DCd-Godi.js} +1 -1
  13. package/dist/assets/{ToolOutputDialog-D9S-X8hM.js → ToolOutputDialog-B50L_nUP.js} +1 -1
  14. package/dist/assets/{appThemeRegistry-DBrvaJnq.js → appThemeRegistry-BWtCaTMe.js} +1 -1
  15. package/dist/assets/{fileMentionTouchSelection-Dc004xOh.js → fileMentionTouchSelection-DKYkoypI.js} +1 -1
  16. package/dist/assets/{gitApi-Cm3JLQqh.js → gitApi-D4PyYgLZ.js} +1 -1
  17. package/dist/assets/{insertionBoundaries-CTWYFsbH.js → insertionBoundaries-Bnnx03Wj.js} +1 -1
  18. package/dist/assets/{main-CSqu3MB4.js → main-BRiQTNFX.js} +4 -4
  19. package/dist/assets/{main-DwMprEyr.js → main-CnY0LWNc.js} +2 -2
  20. package/dist/assets/{miniChat-C8bzY_Ye.js → miniChat-B0pw_mUs.js} +2 -2
  21. package/dist/assets/{mobile-Oy-SRKkr.js → mobile-BKHmxwXz.js} +2 -2
  22. package/dist/assets/{multirun-ClcuaiKU.js → multirun-BQKqVfFT.js} +1 -1
  23. package/dist/assets/{projectMeta-F93wE2Ye.js → projectMeta-BvG8sdtC.js} +1 -1
  24. package/dist/assets/{renderElectronMiniChatApp-rOOhMVlQ.js → renderElectronMiniChatApp-E5a0yy7E.js} +2 -2
  25. package/dist/assets/{renderMobileApp-BP_hGwHP.js → renderMobileApp-DT0L4Ah6.js} +4 -4
  26. package/dist/assets/{runtimeConfig-iJ2mTBVN.js → runtimeConfig-utWzrDwa.js} +1 -1
  27. package/dist/assets/{runtimeEndpointReset-ISnhAS3q.js → runtimeEndpointReset-DE6lwHyg.js} +1 -1
  28. package/dist/assets/sessionChangeSummary-BG7l2heP.js +2 -0
  29. package/dist/assets/{sessionLookup-DQQ9-DuP.js → sessionLookup-12zVOR0J.js} +1 -1
  30. package/dist/assets/src-CFUi4riW.css +2 -0
  31. package/dist/assets/{useAppFontEffects--IcU7jyv.js → useAppFontEffects-BhYuP4L2.js} +5 -5
  32. package/dist/assets/{useDesktopWindowControlsLayout-BqJ5R_T2.js → useDesktopWindowControlsLayout-DPNMRkrI.js} +1 -1
  33. package/dist/assets/{useEffectiveDirectory-ChWXV8xM.js → useEffectiveDirectory-Ji8AKgzY.js} +1 -1
  34. package/dist/assets/{useMobileNavigationStore-DQkgxuzg.js → useMobileNavigationStore-BYdpuwL7.js} +1 -1
  35. package/dist/assets/{useSessionAutoCleanup-DWWAvQQ0.js → useSessionAutoCleanup-CADZCvZL.js} +1 -1
  36. package/dist/assets/{useWorkerHighlightedLines-D2oQszsk.js → useWorkerHighlightedLines-CuG88Lsj.js} +1 -1
  37. package/dist/index.html +3 -3
  38. package/dist/mini-chat.html +3 -3
  39. package/dist/mobile.html +3 -3
  40. package/package.json +1 -1
  41. package/server/lib/assistants/DOCUMENTATION.md +33 -12
  42. package/server/lib/assistants/contact-store.js +25 -1
  43. package/server/lib/assistants/contact-store.test.js +39 -5
  44. package/server/lib/assistants/contact-tools.js +3 -3
  45. package/server/lib/assistants/harness.js +136 -101
  46. package/server/lib/assistants/harness.test.js +235 -8
  47. package/server/lib/assistants/pi-tools.js +2 -0
  48. package/server/lib/assistants/pi-tools.test.js +8 -0
  49. package/server/lib/assistants/service.js +313 -74
  50. package/server/lib/assistants/service.test.js +555 -18
  51. package/server/lib/llm/DOCUMENTATION.md +9 -4
  52. package/server/lib/llm/generate.js +45 -6
  53. package/server/lib/llm/generate.test.js +52 -0
  54. package/dist/assets/MarkdownRenderer-CZqok-Cf.js +0 -2
  55. package/dist/assets/MobileDetailNavigation-Ca-d5eZ9.js +0 -1
  56. package/dist/assets/MobileSurface-xL5Jby4U.js +0 -2
  57. package/dist/assets/sessionChangeSummary-BAzU2J1H.js +0 -2
  58. package/dist/assets/src-DYeppLfP.css +0 -2
@@ -1,8 +1,8 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-D9S-X8hM.js","assets/rolldown-runtime-C0FnF6B9.js","assets/runtime-fetch-zIalUnbb.js","assets/runtime-auth-D66yq6ie.js","assets/runtime-switch-LvWDU-SL.js","assets/vendor-base-ui-CnHfUmDN.js","assets/useUIStore-CxOoCv7B.js","assets/vendor-zustand-B4dlGEM2.js","assets/vendor-react-DLPElpoQ.js","assets/vendor-pierre-diffs-DX7XTPG3.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/vendor-hast-util-to-html-B0p1k5Xa.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-DpDied8H.js","assets/vendor-reactuses-core-BnW6GxJt.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/clipboard-GUUNlWIv.js","assets/persistence-DwRBC4zl.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/store-ClnJdJSj.js","assets/dialog-DhMGbF_B.js","assets/utils-2ZK8yboQ.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/Icon-D1BcR8Tz.js","assets/button-9R-WgVMl.js","assets/useThemeSystem-DMzWVJaW.js","assets/markdownTheme-DOfGg-A7.js","assets/appThemeRegistry-DBrvaJnq.js","assets/platform-DQ5_LNKO.js","assets/vendor-opencode-sdk-C07HQypa.js","assets/useMobileNavigationStore-DQkgxuzg.js","assets/vendor-tanstack-react-query-D7pys_c9.js","assets/vendor-sonner-DVzioF3d.js","assets/useAssistantUIStore-CLPCNoj_.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/MarkdownRenderer-CZqok-Cf.js","assets/markdownHeightCache-BL8CUQ0M.js","assets/dualLimitLru-D8Sphgua.js","assets/markdown-worker-CptoICmq.js","assets/useEffectiveDirectory-ChWXV8xM.js","assets/imageSource-BlAJJUEI.js","assets/relay-image-stream-DM7atqJs.js","assets/useWorkerHighlightedLines-D2oQszsk.js","assets/tooltip-DSjr26A_.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-Cm3JLQqh.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{p as t,t as n,v as r,w as i}from"./runtime-auth-D66yq6ie.js";import{c as a,f as o,i as s,l as c,s as l,t as u}from"./runtime-switch-LvWDU-SL.js";import{n as d}from"./runtime-fetch-zIalUnbb.js";import{Cn as f,jt as p,n as m,t as h,tt as g,wn as _}from"./persistence-DwRBC4zl.js";import{a as v,i as y}from"./vendor-zustand-B4dlGEM2.js";import{nt as b,rt as x,tt as S}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as C,Nt as w,n as T,r as E,t as D}from"./platform-DQ5_LNKO.js";import{b as O,t as k}from"./useUIStore-CxOoCv7B.js";import{a as A,n as j,o as M}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as N,t as P}from"./vendor-react-DLPElpoQ.js";import{t as F}from"./capgoAdapter-DCowZ2ab.js";/* empty css */import{a as I}from"./vendor-pierre-diffs-DX7XTPG3.js";import{r as L}from"./vendor-sonner-DVzioF3d.js";import{n as R}from"./vendor-reactuses-core-BnW6GxJt.js";import{i as z,n as ee,t as te}from"./clipboard-GUUNlWIv.js";import{i as B,n as V}from"./store-ClnJdJSj.js";import{a as ne,c as H,d as re,f as U,l as W,o as ie,s as ae,t as G,u as oe}from"./MobileShareBridge-B4S7BaUj.js";import{b as se,g as ce,t as le,y as K}from"./MobileDetailNavigation-Ca-d5eZ9.js";import{An as ue,Bt as de,Ca as fe,Fa as pe,Ia as me,Jt as he,Nn as ge,Nt as _e,P as ve,Pa as ye,Qi as be,Sa as xe,Ti as Se,Ut as Ce,Vt as we,Xi as Te,Yt as Ee,Zr as De,_r as Oe,an as ke,ar as Ae,bn as je,br as Me,c as q,cn as Ne,cr as Pe,dr as Fe,go as Ie,gr as Le,hr as J,in as Re,ir as ze,jr as Be,mr as Ve,nn as He,pr as Ue,r as We,ra as Ge,sn as Ke,t as qe,ur as Je,vr as Ye,wi as Xe,yr as Ze}from"./useMobileNavigationStore-DQkgxuzg.js";import{i as Qe,n as $e,r as et}from"./useAssistantUIStore-CLPCNoj_.js";import{t as Y}from"./utils-2ZK8yboQ.js";import{n as X}from"./Icon-D1BcR8Tz.js";import{t as Z}from"./button-9R-WgVMl.js";import{F as tt,I as nt,M as rt,N as it,p as at}from"./gitApi-Cm3JLQqh.js";import{C as ot,Dt as st,F as ct,J as lt,R as ut,S as dt,St as ft,ct as pt,dt as mt,ft as ht,ht as gt,i as _t,it as vt,lt as yt,mt as bt,o as xt,pt as St,q as Ct,r as wt,rt as Tt,s as Et,st as Dt,t as Ot,ut as kt,xt as At}from"./useAppFontEffects--IcU7jyv.js";import{A as jt,E as Mt,F as Nt,I as Pt,L as Ft,M as It,N as Lt,P as Rt,R as zt,T as Bt,X as Vt,a as Ht,f as Ut,i as Wt,k as Gt,n as Kt,s as qt,z as Jt}from"./projectMeta-F93wE2Ye.js";import{t as Yt}from"./input-Cd_1HyQv.js";import{r as Xt}from"./tooltip-DSjr26A_.js";import{At as Zt,E as Qt,S as $t,X as en,Y as tn,Z as nn,b as rn,g as an,ht as on,nt as sn,w as cn,x as ln,z as un}from"./useSessionAutoCleanup-DWWAvQQ0.js";import{n as dn}from"./useThemeSystem-DMzWVJaW.js";import{a as fn,n as pn,s as mn}from"./OverlayScrollbar-Bahg_P3r.js";import{s as hn}from"./markdownTheme-DOfGg-A7.js";import{n as gn}from"./useRuntimeAPIs-DSLXJybW.js";import{b as _n,g as vn,j as yn,x as bn,y as xn}from"./insertionBoundaries-CTWYFsbH.js";import{E as Sn,M as Cn,a as wn,h as Tn,i as En,j as Dn,p as On,r as kn,s as An,t as jn}from"./appThemeRegistry-DBrvaJnq.js";import{i as Mn,n as Nn,o as Pn}from"./MarkdownRenderer-CZqok-Cf.js";import{r as Fn}from"./textarea-B9CmN13Z.js";import{a as In}from"./url-CMQwHq4k.js";import{c as Ln,d as Rn,s as zn,u as Bn}from"./markdown-worker-CptoICmq.js";import{n as Vn}from"./useEffectiveDirectory-ChWXV8xM.js";import{f as Hn}from"./FadeInOnReveal-UGwClbL_.js";import{D as Un,E as Wn,r as Gn,t as Kn}from"./sessionChangeSummary-BAzU2J1H.js";import{$ as qn,C as Jn,H as Yn,U as Xn,a as Zn,b as Qn,et as $n,g as er,i as tr,n as nr,nt as rr,o as ir,p as ar,r as or,t as sr,tt as cr,x as lr,z as ur}from"./MobileSurface-xL5Jby4U.js";import{t as dr}from"./useFontPreferences-DCaY8NbU.js";import{A as fr,C as pr,D as mr,E as hr,G as gr,H as _r,I as vr,J as yr,O as br,S as xr,T as Sr,U as Cr,V as wr,W as Tr,Y as Er,_ as Dr,a as Or,at as kr,b as Ar,c as jr,d as Mr,et as Nr,f as Pr,g as Fr,i as Ir,it as Lr,k as Rr,l as zr,m as Br,n as Vr,nt as Hr,p as Ur,r as Wr,s as Gr,t as Kr,tt as qr,u as Jr,v as Yr,w as Xr,x as Zr,y as Qr}from"./runtimeEndpointReset-ISnhAS3q.js";import{a as $r,c as ei,i as ti,l as ni,o as ri,r as ii,s as ai,t as oi}from"./SettingsView-Dn7odtQz.js";import{a as si,c as ci,i as li,l as ui,o as di,r as fi,s as pi,t as mi}from"./AssistantView-Dncbu_Z2.js";import{a as hi,i as gi}from"./sessionLookup-DQQ9-DuP.js";import{a as _i,i as vi,n as yi,r as bi,t as xi}from"./context-menu-CSyOhRz8.js";import{a as Si,i as Ci,o as wi,r as Ti}from"./fileQueries-B_s_B-fH.js";var Q=e(x(),1),Ei=P(),Di=null,Oi=!1,ki=new Promise(e=>{Di=e});function Ai(){Oi||(Oi=!0,Di?.())}var ji=6,Mi=e=>e.parentID??null,Ni=e=>{let t=e.replace(/\/+$/,``);return t.slice(t.lastIndexOf(`/`)+1)||t},Pi=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),Fi=(e,t)=>{if(!e)return``;let n=null,r=-1;for(let i of t){let t=Pi(i.path);(e===t||e.startsWith(`${t}/`))&&t.length>r&&(n=i,r=t.length)}return Ni(n?n.path:e)},Ii=()=>{let e=Fe.getState().activeSessions,t=ue.getState().index.session.unseenCount,n=Ie.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:Fi(Pe(a),n)})}i.sort((e,t)=>t.updated-e.updated);let a=i.slice(0,ji).map(({id:e,title:t,unread:n,project:r})=>({id:e,title:t,unread:n,project:r}));return{attentionCount:r,recentSessions:a}},Li=`__OPENCHAMBER_WIDGET_SNAPSHOT__`,Ri=()=>{typeof window>`u`||(window[Li]=()=>{try{return JSON.stringify(Ii())}catch{return null}})},zi=N(),Bi=A(`OpenChamberExternalBrowser`),Vi={getPlatform:()=>j.getPlatform(),isPluginAvailable:e=>j.isPluginAvailable(e),openInSystemBrowser:e=>Bi.open(e),openExternal:In},Hi=async(e,t=Vi)=>{if(t.getPlatform()===`android`){if(!t.isPluginAvailable(`OpenChamberExternalBrowser`))return!1;try{return await t.openInSystemBrowser({url:e}),!0}catch{return!1}}return t.openExternal(e)},$=b(),Ui=`mobile-app-update-available`,Wi=`mobile-app-update-toast-dismissed-version`,Gi=()=>{let e=(0,zi.c)(9),{t}=ee(),n=Xn(Ki),r=Xn(qi),i=Xn(Ji),a=Xn(Yi),o=Xn(Xi),s;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=new Set,e[0]=s):s=e[0];let c=Q.useRef(s),l,u;return e[1]!==n||e[2]!==a||e[3]!==o||e[4]!==r||e[5]!==t||e[6]!==i?(l=()=>{if(D()!==`android`||r!==`mobile`||!n||!i||!a||o){J.dismiss(Ui);return}O().getItem(Wi)!==i&&(c.current.has(i)||(c.current.add(i),J.info(t(`mobileUpdate.toast.available.title`),{id:Ui,description:t(`mobileUpdate.toast.available.description`,{version:i}),duration:1/0,icon:(0,$.jsx)(X,{name:`download`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.toast.actions.download`),onClick:()=>{Hi(a)}},cancel:{label:t(`mobileUpdate.toast.actions.dismiss`),onClick:()=>{O().setItem(Wi,i),J.dismiss(Ui)}}})))},u=[n,a,o,r,t,i],e[1]=n,e[2]=a,e[3]=o,e[4]=r,e[5]=t,e[6]=i,e[7]=l,e[8]=u):(l=e[7],u=e[8]),Q.useEffect(l,u),null};function Ki(e){return e.available}function qi(e){return e.runtimeType}function Ji(e){return e.info?.version}function Yi(e){return e.info?.downloadUrl}function Xi(e){return e.info?.inAppApply===!0}var Zi=e=>!(!e.enabled||e.runtimeType!==`mobile`||!e.available||!e.inAppApply||!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),Qi=e=>e.enabled&&!e.alreadyChecked,$i=`mobile-ota-update-available`,ea=`mobile-ota-update-toast-dismissed-version`,ta=()=>{let e=(0,zi.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=T(),e[1]=s):s=e[1];let c=s,l=Xn(na),u=Xn(ra),d=Xn(ia),f=Xn(aa),p=Xn(oa),m=Xn(sa),h=Xn(ca),g=Xn(la),_=Xn(ua),v=d?.version,y=d?.inAppApply===!0,b,x;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{Qi({enabled:c,alreadyChecked:i.current})&&(i.current=!0,Xn.getState().checkForUpdates().catch(da))},x=[c],e[2]=b,e[3]=x):(b=e[2],x=e[3]),Q.useEffect(b,x);let S;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>{r(!0)},e[4]=S):S=e[4];let C=R(S),w=R(fa),E,D;if(e[5]!==l||e[6]!==w||e[7]!==y||e[8]!==C||e[9]!==u||e[10]!==t||e[11]!==v?(E=()=>{if(!Zi({enabled:c,runtimeType:u,available:l,inAppApply:y,version:v??``,dismissedVersion:O().getItem(ea),seenVersions:o.current})||!v){(!l||!y||u!==`mobile`)&&J.dismiss($i);return}o.current.add(v),J.info(t(`mobileUpdate.ota.toast.available.title`),{id:$i,description:t(`mobileUpdate.ota.toast.available.description`,{version:v}),duration:1/0,icon:(0,$.jsx)(X,{name:`refresh`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.ota.toast.actions.update`),onClick:C},cancel:{label:t(`mobileUpdate.ota.toast.actions.dismiss`),onClick:()=>{w(v)}}})},D=[l,y,c,C,w,u,t,v],e[5]=l,e[6]=w,e[7]=y,e[8]=C,e[9]=u,e[10]=t,e[11]=v,e[12]=E,e[13]=D):(E=e[12],D=e[13]),Q.useEffect(E,D),!c)return null;let k;return e[14]!==n||e[15]!==g||e[16]!==p||e[17]!==f||e[18]!==h||e[19]!==d||e[20]!==m||e[21]!==_||e[22]!==u?(k=(0,$.jsx)(Yn,{open:n,onOpenChange:r,info:d,downloading:f,downloaded:p,progress:m,error:h,onDownload:g,onRestart:_,runtimeType:u}),e[14]=n,e[15]=g,e[16]=p,e[17]=f,e[18]=h,e[19]=d,e[20]=m,e[21]=_,e[22]=u,e[23]=k):k=e[23],k};function na(e){return e.available}function ra(e){return e.runtimeType}function ia(e){return e.info}function aa(e){return e.downloading}function oa(e){return e.downloaded}function sa(e){return e.progress}function ca(e){return e.error}function la(e){return e.downloadUpdate}function ua(e){return e.restartToUpdate}function da(){}function fa(e){O().setItem(ea,e),J.dismiss($i)}var pa=e=>{let t=(0,zi.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=Y(`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=Y(`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},ma=`.oc-mobile-composer`;function ha(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.closest==`function`&&!!t.closest(ma)}function ga(e){if(!e||typeof e!=`object`||ha(e))return!1;let t=e,n=typeof t.tagName==`string`?t.tagName.toUpperCase():``;return n===`TEXTAREA`||n===`INPUT`||t.isContentEditable===!0}function _a(e){return ha(e??null)}function va(e,t){return e?`cache`:ha(t??null)?`open`:ga(t??null)?`field`:`ignore`}function ya(e,t){return!(t>0)||!(e>=0)?!1:t>e+24}function ba(e,t){return e>0?Math.max(0,Math.round(e/(Number.isFinite(t)&&t>0?t:1))):0}var xa=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Sa=e=>{let t=e.index?.trim();return!!(t&&t!==`?`)},Ca=e=>{let t=e.working_dir?.trim(),n=e.index?.trim();return!!(t||n===`?`)},wa=(e,t)=>t?`${e}\u0000staged`:e,Ta=({onClose:e,initialDiffPath:t,initialDiffStaged:n=!1,initialDiffTargetLine:r=null,hideDiffHeader:i=!1})=>{let{t:a}=ee(),{git:o}=gn(),s=xa(Vn()??null),c=xn(s||null),l=bn(s||null),u=vn(s||null),d=_n(e=>e.setActiveDirectory),f=_n(e=>e.ensureAll),p=_n(e=>e.fetchStatus),m=_n(e=>e.fetchBranches),h=_n(e=>e.prefetchDiffs),g=_n(e=>e.getDiff),_=_n(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,I]=Q.useState([]),[L,z]=Q.useState([]),[te,B]=Q.useState(null),[V,ne]=Q.useState({key:null,loading:!1,error:null,resolved:!1}),[H,re]=Q.useState(0),U=Q.useRef({key:null,generation:0}),[W,ie]=Q.useState(!1),ae=jr(c)&&!W,G=Q.useMemo(()=>{let e=c?.files??[];if(ae)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,ae]),oe=Q.useMemo(()=>G.filter(Sa),[G]),se=Q.useMemo(()=>G.filter(Ca),[G]),{deferredStagedCount:ce,deferredUnstagedCount:le}=Q.useMemo(()=>{if(!ae||!c)return{deferredStagedCount:0,deferredUnstagedCount:0};let e=0,t=0;for(let n of c.files??[])Sa(n)&&(e+=1),Ca(n)&&(t+=1);return{deferredStagedCount:e,deferredUnstagedCount:t}},[ae,c]),K=Q.useMemo(()=>{if(L.length>0)return L;let e=c?.tracking?.includes(`/`)?c.tracking.split(`/`)[0]:null;return e||te?[{name:e||`origin`,fetchUrl:te??``,pushUrl:te??``}]:[]},[te,L,c?.tracking]),ue=Q.useMemo(()=>e=>!s||v.type!==`diff`?null:e.directories.get(s)?.diffCache.get(wa(v.path,v.staged))??null,[s,v]),de=_n(ue),fe=Q.useMemo(()=>v.type===`diff`?G.find(e=>e.path===v.path)??null:null,[G,v]),pe=v.type===`diff`&&s?`${s}\u0000${wa(v.path,v.staged)}`:null,me=V.key===pe,he=!!(pe&&!de&&(!me||V.loading)),ge=me?V.error:null,_e=!!(fe||me&&V.resolved),ve=R(async(e,t=!0)=>{try{await Promise.all([p(e,o),m(e,o)])}catch(e){t&&J.error(e instanceof Error?e.message:a(`gitView.toast.refreshRepositoryFailed`))}}),ye=R(async(e,t,n)=>{let r=()=>U.current.key===t&&U.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),B(n)}catch{if(!r())return;z([]),B(null)}}),be=R(e=>{if(e!==s)return{requestGeneration:null,promise:Promise.resolve()};let t=U.current.generation+1;return U.current={key:e,generation:t},{requestGeneration:t,promise:ye(e,e,t)}});Q.useEffect(()=>{s&&(d(s),f(s,o))},[s,f,o,d]),Q.useEffect(()=>{if(!s){U.current={key:null,generation:U.current.generation+1},z([]),B(null);return}let{requestGeneration:e,promise:t}=be(s);return()=>{e!==null&&U.current.key===s&&U.current.generation===e&&(U.current={key:s,generation:e+1})}},[s,o,be]),Q.useEffect(()=>{if(!s||G.length===0)return;let e=Array.from(new Set([...oe.map(e=>e.path),...F,...G.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)},[G,s,o,h,oe,F]),Q.useEffect(()=>{if(v.type!==`diff`){ne({key:null,loading:!1,error:null,resolved:!1});return}let e=wa(v.path,v.staged);if(!s||!pe){ne({key:null,loading:!1,error:null,resolved:!1});return}if(g(s,e)){ne(e=>({key:pe,loading:!1,error:null,resolved:e.key===pe&&e.resolved||!!fe}));return}let t=!1;return ne({key:pe,loading:!0,error:null,resolved:!1}),o.getGitFileDiff(s,{path:v.path,staged:v.staged||void 0}).then(n=>{t||(_(s,e,{original:n.original??``,modified:n.modified??``,isBinary:n.isBinary}),ne(e=>e.key===pe?{...e,loading:!1,error:null,resolved:!0}:e))}).catch(e=>{t||ne(t=>t.key===pe?{...t,loading:!1,error:e instanceof Error?e.message:String(e),resolved:!1}:t)}),()=>{t=!0}},[pe,s,H,g,o,v,fe,_]);let xe=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}),J.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){J.error(a(`gitView.toast.commitOrStashBeforeSync`));return}await o.gitPull(n,r(t))}((await o.getGitStatus(n)).ahead??0)>0&&await o.gitPush(n),J.success(a(`gitView.toast.alreadyUpToDate`))}await ve(n,!1),await be(n).promise}catch(e){J.error(e instanceof Error?e.message:a(`gitView.toast.syncActionFailed`,{action:a(`gitView.sync.syncChanges`)}))}finally{S(null)}},Se=R(async(e,t)=>{if(!s||e.length===0)return;let n=s;try{t===`stage`?e.length>1?await it(n,e):await rt(n,e[0]):e.length>1?await nt(n,e):await tt(n,e[0]),await ve(n,!1)}catch(e){J.error(e instanceof Error?e.message:a(t===`stage`?`gitView.toast.stageFileFailed`:`gitView.toast.unstageFileFailed`))}}),Ce=R((e,t=!1)=>{y({type:`diff`,path:e,staged:t,targetLine:null})}),we=R(()=>v.type===`diff`&&(y({type:`list`}),!0));En({id:`mobile-changes-diff`,active:v.type===`diff`&&!i,layer:`overlay`,onBack:we,surfaceRef:b});let Te=R(async e=>{if(!s)return;let t=s;O(t=>new Set(t).add(e));try{await o.revertGitFile(t,e),J.success(a(`gitView.toast.revertedFile`,{path:e})),await ve(t,!1)}catch(e){J.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{O(t=>{let n=new Set(t);return n.delete(e),n})}}),Ee=R(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 ve(t,!1),J.success(n.length===1?a(`gitView.toast.revertedFilesSingle`,{count:n.length}):a(`gitView.toast.revertedFilesPlural`,{count:n.length}))}catch(e){J.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{O(new Set),A(!1)}}),De=R(e=>{let t=e.map(e=>e.trim()).filter(Boolean);if(t.length===0){P([]);return}E(e=>`${e.trim()}${e.trim()?`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-B50L_nUP.js","assets/rolldown-runtime-C0FnF6B9.js","assets/runtime-fetch-zIalUnbb.js","assets/runtime-auth-D66yq6ie.js","assets/runtime-switch-LvWDU-SL.js","assets/vendor-base-ui-CnHfUmDN.js","assets/useUIStore-CxOoCv7B.js","assets/vendor-zustand-B4dlGEM2.js","assets/vendor-react-DLPElpoQ.js","assets/vendor-pierre-diffs-DX7XTPG3.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/vendor-hast-util-to-html-B0p1k5Xa.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-DpDied8H.js","assets/vendor-reactuses-core-BnW6GxJt.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/clipboard-GUUNlWIv.js","assets/persistence-DwRBC4zl.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/store-ClnJdJSj.js","assets/dialog-DhMGbF_B.js","assets/utils-2ZK8yboQ.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/Icon-D1BcR8Tz.js","assets/button-9R-WgVMl.js","assets/useThemeSystem-DMzWVJaW.js","assets/markdownTheme-DOfGg-A7.js","assets/appThemeRegistry-BWtCaTMe.js","assets/platform-DQ5_LNKO.js","assets/vendor-opencode-sdk-C07HQypa.js","assets/useMobileNavigationStore-BYdpuwL7.js","assets/vendor-tanstack-react-query-D7pys_c9.js","assets/vendor-sonner-DVzioF3d.js","assets/useAssistantUIStore-CLPCNoj_.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/MarkdownRenderer-emLeoNjI.js","assets/markdownHeightCache-BL8CUQ0M.js","assets/dualLimitLru-D8Sphgua.js","assets/markdown-worker-CptoICmq.js","assets/useEffectiveDirectory-Ji8AKgzY.js","assets/imageSource-BlAJJUEI.js","assets/relay-image-stream-DM7atqJs.js","assets/useWorkerHighlightedLines-CuG88Lsj.js","assets/tooltip-DSjr26A_.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-D4PyYgLZ.js"])))=>i.map(i=>d[i]);
2
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{p as t,t as n,v as r,w as i}from"./runtime-auth-D66yq6ie.js";import{c as a,f as o,i as s,l as c,s as l,t as u}from"./runtime-switch-LvWDU-SL.js";import{n as d}from"./runtime-fetch-zIalUnbb.js";import{Cn as f,jt as p,n as m,t as h,tt as g,wn as _}from"./persistence-DwRBC4zl.js";import{a as v,i as y}from"./vendor-zustand-B4dlGEM2.js";import{nt as b,rt as x,tt as S}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as C,Nt as w,n as T,r as E,t as D}from"./platform-DQ5_LNKO.js";import{b as O,t as k}from"./useUIStore-CxOoCv7B.js";import{a as A,n as j,o as M}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as N,t as P}from"./vendor-react-DLPElpoQ.js";import{t as F}from"./capgoAdapter-DCowZ2ab.js";/* empty css */import{a as I}from"./vendor-pierre-diffs-DX7XTPG3.js";import{r as L}from"./vendor-sonner-DVzioF3d.js";import{n as R}from"./vendor-reactuses-core-BnW6GxJt.js";import{i as z,n as ee,t as te}from"./clipboard-GUUNlWIv.js";import{i as B,n as V}from"./store-ClnJdJSj.js";import{a as ne,c as H,d as re,f as U,l as W,o as ie,s as ae,t as G,u as oe}from"./MobileShareBridge-Bk2fdkJk.js";import{b as se,g as ce,t as le,y as K}from"./MobileDetailNavigation-DqXVAIap.js";import{An as ue,Bt as de,Ca as fe,Fa as pe,Ia as me,Jt as he,Nn as ge,Nt as _e,P as ve,Pa as ye,Qi as be,Sa as xe,Ti as Se,Ut as Ce,Vt as we,Xi as Te,Yt as Ee,Zr as De,_r as Oe,an as ke,ar as Ae,bn as je,br as Me,c as q,cn as Ne,cr as Pe,dr as Fe,go as Ie,gr as Le,hr as J,in as Re,ir as ze,jr as Be,mr as Ve,nn as He,pr as Ue,r as We,ra as Ge,sn as Ke,t as qe,ur as Je,vr as Ye,wi as Xe,yr as Ze}from"./useMobileNavigationStore-BYdpuwL7.js";import{i as Qe,n as $e,r as et}from"./useAssistantUIStore-CLPCNoj_.js";import{t as Y}from"./utils-2ZK8yboQ.js";import{n as X}from"./Icon-D1BcR8Tz.js";import{t as Z}from"./button-9R-WgVMl.js";import{F as tt,I as nt,M as rt,N as it,p as at}from"./gitApi-D4PyYgLZ.js";import{C as ot,Dt as st,F as ct,J as lt,R as ut,S as dt,St as ft,ct as pt,dt as mt,ft as ht,ht as gt,i as _t,it as vt,lt as yt,mt as bt,o as xt,pt as St,q as Ct,r as wt,rt as Tt,s as Et,st as Dt,t as Ot,ut as kt,xt as At}from"./useAppFontEffects-BhYuP4L2.js";import{A as jt,E as Mt,F as Nt,I as Pt,L as Ft,M as It,N as Lt,P as Rt,R as zt,T as Bt,X as Vt,a as Ht,f as Ut,i as Wt,k as Gt,n as Kt,s as qt,z as Jt}from"./projectMeta-BvG8sdtC.js";import{t as Yt}from"./input-Cd_1HyQv.js";import{r as Xt}from"./tooltip-DSjr26A_.js";import{At as Zt,E as Qt,S as $t,X as en,Y as tn,Z as nn,b as rn,g as an,ht as on,nt as sn,w as cn,x as ln,z as un}from"./useSessionAutoCleanup-CADZCvZL.js";import{n as dn}from"./useThemeSystem-DMzWVJaW.js";import{a as fn,n as pn,s as mn}from"./OverlayScrollbar-Bahg_P3r.js";import{s as hn}from"./markdownTheme-DOfGg-A7.js";import{n as gn}from"./useRuntimeAPIs-DSLXJybW.js";import{b as _n,g as vn,j as yn,x as bn,y as xn}from"./insertionBoundaries-Bnnx03Wj.js";import{E as Sn,M as Cn,a as wn,h as Tn,i as En,j as Dn,p as On,r as kn,s as An,t as jn}from"./appThemeRegistry-BWtCaTMe.js";import{i as Mn,n as Nn,o as Pn}from"./MarkdownRenderer-emLeoNjI.js";import{r as Fn}from"./textarea-B9CmN13Z.js";import{a as In}from"./url-CMQwHq4k.js";import{c as Ln,d as Rn,s as zn,u as Bn}from"./markdown-worker-CptoICmq.js";import{n as Vn}from"./useEffectiveDirectory-Ji8AKgzY.js";import{f as Hn}from"./FadeInOnReveal-UGwClbL_.js";import{D as Un,E as Wn,r as Gn,t as Kn}from"./sessionChangeSummary-BG7l2heP.js";import{$ as qn,C as Jn,H as Yn,U as Xn,a as Zn,b as Qn,et as $n,g as er,i as tr,n as nr,nt as rr,o as ir,p as ar,r as or,t as sr,tt as cr,x as lr,z as ur}from"./MobileSurface-C4mpcOCh.js";import{t as dr}from"./useFontPreferences-DCaY8NbU.js";import{A as fr,C as pr,D as mr,E as hr,G as gr,H as _r,I as vr,J as yr,O as br,S as xr,T as Sr,U as Cr,V as wr,W as Tr,Y as Er,_ as Dr,a as Or,at as kr,b as Ar,c as jr,d as Mr,et as Nr,f as Pr,g as Fr,i as Ir,it as Lr,k as Rr,l as zr,m as Br,n as Vr,nt as Hr,p as Ur,r as Wr,s as Gr,t as Kr,tt as qr,u as Jr,v as Yr,w as Xr,x as Zr,y as Qr}from"./runtimeEndpointReset-DE6lwHyg.js";import{a as $r,c as ei,i as ti,l as ni,o as ri,r as ii,s as ai,t as oi}from"./SettingsView-b8LUjoad.js";import{a as si,c as ci,i as li,l as ui,o as di,r as fi,s as pi,t as mi}from"./AssistantView-D5rEZ-Ss.js";import{a as hi,i as gi}from"./sessionLookup-12zVOR0J.js";import{a as _i,i as vi,n as yi,r as bi,t as xi}from"./context-menu-CSyOhRz8.js";import{a as Si,i as Ci,o as wi,r as Ti}from"./fileQueries-B_s_B-fH.js";var Q=e(x(),1),Ei=P(),Di=null,Oi=!1,ki=new Promise(e=>{Di=e});function Ai(){Oi||(Oi=!0,Di?.())}var ji=6,Mi=e=>e.parentID??null,Ni=e=>{let t=e.replace(/\/+$/,``);return t.slice(t.lastIndexOf(`/`)+1)||t},Pi=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),Fi=(e,t)=>{if(!e)return``;let n=null,r=-1;for(let i of t){let t=Pi(i.path);(e===t||e.startsWith(`${t}/`))&&t.length>r&&(n=i,r=t.length)}return Ni(n?n.path:e)},Ii=()=>{let e=Fe.getState().activeSessions,t=ue.getState().index.session.unseenCount,n=Ie.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:Fi(Pe(a),n)})}i.sort((e,t)=>t.updated-e.updated);let a=i.slice(0,ji).map(({id:e,title:t,unread:n,project:r})=>({id:e,title:t,unread:n,project:r}));return{attentionCount:r,recentSessions:a}},Li=`__OPENCHAMBER_WIDGET_SNAPSHOT__`,Ri=()=>{typeof window>`u`||(window[Li]=()=>{try{return JSON.stringify(Ii())}catch{return null}})},zi=N(),Bi=A(`OpenChamberExternalBrowser`),Vi={getPlatform:()=>j.getPlatform(),isPluginAvailable:e=>j.isPluginAvailable(e),openInSystemBrowser:e=>Bi.open(e),openExternal:In},Hi=async(e,t=Vi)=>{if(t.getPlatform()===`android`){if(!t.isPluginAvailable(`OpenChamberExternalBrowser`))return!1;try{return await t.openInSystemBrowser({url:e}),!0}catch{return!1}}return t.openExternal(e)},$=b(),Ui=`mobile-app-update-available`,Wi=`mobile-app-update-toast-dismissed-version`,Gi=()=>{let e=(0,zi.c)(9),{t}=ee(),n=Xn(Ki),r=Xn(qi),i=Xn(Ji),a=Xn(Yi),o=Xn(Xi),s;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=new Set,e[0]=s):s=e[0];let c=Q.useRef(s),l,u;return e[1]!==n||e[2]!==a||e[3]!==o||e[4]!==r||e[5]!==t||e[6]!==i?(l=()=>{if(D()!==`android`||r!==`mobile`||!n||!i||!a||o){J.dismiss(Ui);return}O().getItem(Wi)!==i&&(c.current.has(i)||(c.current.add(i),J.info(t(`mobileUpdate.toast.available.title`),{id:Ui,description:t(`mobileUpdate.toast.available.description`,{version:i}),duration:1/0,icon:(0,$.jsx)(X,{name:`download`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.toast.actions.download`),onClick:()=>{Hi(a)}},cancel:{label:t(`mobileUpdate.toast.actions.dismiss`),onClick:()=>{O().setItem(Wi,i),J.dismiss(Ui)}}})))},u=[n,a,o,r,t,i],e[1]=n,e[2]=a,e[3]=o,e[4]=r,e[5]=t,e[6]=i,e[7]=l,e[8]=u):(l=e[7],u=e[8]),Q.useEffect(l,u),null};function Ki(e){return e.available}function qi(e){return e.runtimeType}function Ji(e){return e.info?.version}function Yi(e){return e.info?.downloadUrl}function Xi(e){return e.info?.inAppApply===!0}var Zi=e=>!(!e.enabled||e.runtimeType!==`mobile`||!e.available||!e.inAppApply||!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),Qi=e=>e.enabled&&!e.alreadyChecked,$i=`mobile-ota-update-available`,ea=`mobile-ota-update-toast-dismissed-version`,ta=()=>{let e=(0,zi.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=T(),e[1]=s):s=e[1];let c=s,l=Xn(na),u=Xn(ra),d=Xn(ia),f=Xn(aa),p=Xn(oa),m=Xn(sa),h=Xn(ca),g=Xn(la),_=Xn(ua),v=d?.version,y=d?.inAppApply===!0,b,x;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{Qi({enabled:c,alreadyChecked:i.current})&&(i.current=!0,Xn.getState().checkForUpdates().catch(da))},x=[c],e[2]=b,e[3]=x):(b=e[2],x=e[3]),Q.useEffect(b,x);let S;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>{r(!0)},e[4]=S):S=e[4];let C=R(S),w=R(fa),E,D;if(e[5]!==l||e[6]!==w||e[7]!==y||e[8]!==C||e[9]!==u||e[10]!==t||e[11]!==v?(E=()=>{if(!Zi({enabled:c,runtimeType:u,available:l,inAppApply:y,version:v??``,dismissedVersion:O().getItem(ea),seenVersions:o.current})||!v){(!l||!y||u!==`mobile`)&&J.dismiss($i);return}o.current.add(v),J.info(t(`mobileUpdate.ota.toast.available.title`),{id:$i,description:t(`mobileUpdate.ota.toast.available.description`,{version:v}),duration:1/0,icon:(0,$.jsx)(X,{name:`refresh`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.ota.toast.actions.update`),onClick:C},cancel:{label:t(`mobileUpdate.ota.toast.actions.dismiss`),onClick:()=>{w(v)}}})},D=[l,y,c,C,w,u,t,v],e[5]=l,e[6]=w,e[7]=y,e[8]=C,e[9]=u,e[10]=t,e[11]=v,e[12]=E,e[13]=D):(E=e[12],D=e[13]),Q.useEffect(E,D),!c)return null;let k;return e[14]!==n||e[15]!==g||e[16]!==p||e[17]!==f||e[18]!==h||e[19]!==d||e[20]!==m||e[21]!==_||e[22]!==u?(k=(0,$.jsx)(Yn,{open:n,onOpenChange:r,info:d,downloading:f,downloaded:p,progress:m,error:h,onDownload:g,onRestart:_,runtimeType:u}),e[14]=n,e[15]=g,e[16]=p,e[17]=f,e[18]=h,e[19]=d,e[20]=m,e[21]=_,e[22]=u,e[23]=k):k=e[23],k};function na(e){return e.available}function ra(e){return e.runtimeType}function ia(e){return e.info}function aa(e){return e.downloading}function oa(e){return e.downloaded}function sa(e){return e.progress}function ca(e){return e.error}function la(e){return e.downloadUpdate}function ua(e){return e.restartToUpdate}function da(){}function fa(e){O().setItem(ea,e),J.dismiss($i)}var pa=e=>{let t=(0,zi.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=Y(`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=Y(`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},ma=`.oc-mobile-composer`;function ha(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.closest==`function`&&!!t.closest(ma)}function ga(e){if(!e||typeof e!=`object`||ha(e))return!1;let t=e,n=typeof t.tagName==`string`?t.tagName.toUpperCase():``;return n===`TEXTAREA`||n===`INPUT`||t.isContentEditable===!0}function _a(e){return ha(e??null)}function va(e,t){return e?`cache`:ha(t??null)?`open`:ga(t??null)?`field`:`ignore`}function ya(e,t){return!(t>0)||!(e>=0)?!1:t>e+24}function ba(e,t){return e>0?Math.max(0,Math.round(e/(Number.isFinite(t)&&t>0?t:1))):0}var xa=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Sa=e=>{let t=e.index?.trim();return!!(t&&t!==`?`)},Ca=e=>{let t=e.working_dir?.trim(),n=e.index?.trim();return!!(t||n===`?`)},wa=(e,t)=>t?`${e}\u0000staged`:e,Ta=({onClose:e,initialDiffPath:t,initialDiffStaged:n=!1,initialDiffTargetLine:r=null,hideDiffHeader:i=!1})=>{let{t:a}=ee(),{git:o}=gn(),s=xa(Vn()??null),c=xn(s||null),l=bn(s||null),u=vn(s||null),d=_n(e=>e.setActiveDirectory),f=_n(e=>e.ensureAll),p=_n(e=>e.fetchStatus),m=_n(e=>e.fetchBranches),h=_n(e=>e.prefetchDiffs),g=_n(e=>e.getDiff),_=_n(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,I]=Q.useState([]),[L,z]=Q.useState([]),[te,B]=Q.useState(null),[V,ne]=Q.useState({key:null,loading:!1,error:null,resolved:!1}),[H,re]=Q.useState(0),U=Q.useRef({key:null,generation:0}),[W,ie]=Q.useState(!1),ae=jr(c)&&!W,G=Q.useMemo(()=>{let e=c?.files??[];if(ae)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,ae]),oe=Q.useMemo(()=>G.filter(Sa),[G]),se=Q.useMemo(()=>G.filter(Ca),[G]),{deferredStagedCount:ce,deferredUnstagedCount:le}=Q.useMemo(()=>{if(!ae||!c)return{deferredStagedCount:0,deferredUnstagedCount:0};let e=0,t=0;for(let n of c.files??[])Sa(n)&&(e+=1),Ca(n)&&(t+=1);return{deferredStagedCount:e,deferredUnstagedCount:t}},[ae,c]),K=Q.useMemo(()=>{if(L.length>0)return L;let e=c?.tracking?.includes(`/`)?c.tracking.split(`/`)[0]:null;return e||te?[{name:e||`origin`,fetchUrl:te??``,pushUrl:te??``}]:[]},[te,L,c?.tracking]),ue=Q.useMemo(()=>e=>!s||v.type!==`diff`?null:e.directories.get(s)?.diffCache.get(wa(v.path,v.staged))??null,[s,v]),de=_n(ue),fe=Q.useMemo(()=>v.type===`diff`?G.find(e=>e.path===v.path)??null:null,[G,v]),pe=v.type===`diff`&&s?`${s}\u0000${wa(v.path,v.staged)}`:null,me=V.key===pe,he=!!(pe&&!de&&(!me||V.loading)),ge=me?V.error:null,_e=!!(fe||me&&V.resolved),ve=R(async(e,t=!0)=>{try{await Promise.all([p(e,o),m(e,o)])}catch(e){t&&J.error(e instanceof Error?e.message:a(`gitView.toast.refreshRepositoryFailed`))}}),ye=R(async(e,t,n)=>{let r=()=>U.current.key===t&&U.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),B(n)}catch{if(!r())return;z([]),B(null)}}),be=R(e=>{if(e!==s)return{requestGeneration:null,promise:Promise.resolve()};let t=U.current.generation+1;return U.current={key:e,generation:t},{requestGeneration:t,promise:ye(e,e,t)}});Q.useEffect(()=>{s&&(d(s),f(s,o))},[s,f,o,d]),Q.useEffect(()=>{if(!s){U.current={key:null,generation:U.current.generation+1},z([]),B(null);return}let{requestGeneration:e,promise:t}=be(s);return()=>{e!==null&&U.current.key===s&&U.current.generation===e&&(U.current={key:s,generation:e+1})}},[s,o,be]),Q.useEffect(()=>{if(!s||G.length===0)return;let e=Array.from(new Set([...oe.map(e=>e.path),...F,...G.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)},[G,s,o,h,oe,F]),Q.useEffect(()=>{if(v.type!==`diff`){ne({key:null,loading:!1,error:null,resolved:!1});return}let e=wa(v.path,v.staged);if(!s||!pe){ne({key:null,loading:!1,error:null,resolved:!1});return}if(g(s,e)){ne(e=>({key:pe,loading:!1,error:null,resolved:e.key===pe&&e.resolved||!!fe}));return}let t=!1;return ne({key:pe,loading:!0,error:null,resolved:!1}),o.getGitFileDiff(s,{path:v.path,staged:v.staged||void 0}).then(n=>{t||(_(s,e,{original:n.original??``,modified:n.modified??``,isBinary:n.isBinary}),ne(e=>e.key===pe?{...e,loading:!1,error:null,resolved:!0}:e))}).catch(e=>{t||ne(t=>t.key===pe?{...t,loading:!1,error:e instanceof Error?e.message:String(e),resolved:!1}:t)}),()=>{t=!0}},[pe,s,H,g,o,v,fe,_]);let xe=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}),J.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){J.error(a(`gitView.toast.commitOrStashBeforeSync`));return}await o.gitPull(n,r(t))}((await o.getGitStatus(n)).ahead??0)>0&&await o.gitPush(n),J.success(a(`gitView.toast.alreadyUpToDate`))}await ve(n,!1),await be(n).promise}catch(e){J.error(e instanceof Error?e.message:a(`gitView.toast.syncActionFailed`,{action:a(`gitView.sync.syncChanges`)}))}finally{S(null)}},Se=R(async(e,t)=>{if(!s||e.length===0)return;let n=s;try{t===`stage`?e.length>1?await it(n,e):await rt(n,e[0]):e.length>1?await nt(n,e):await tt(n,e[0]),await ve(n,!1)}catch(e){J.error(e instanceof Error?e.message:a(t===`stage`?`gitView.toast.stageFileFailed`:`gitView.toast.unstageFileFailed`))}}),Ce=R((e,t=!1)=>{y({type:`diff`,path:e,staged:t,targetLine:null})}),we=R(()=>v.type===`diff`&&(y({type:`list`}),!0));En({id:`mobile-changes-diff`,active:v.type===`diff`&&!i,layer:`overlay`,onBack:we,surfaceRef:b});let Te=R(async e=>{if(!s)return;let t=s;O(t=>new Set(t).add(e));try{await o.revertGitFile(t,e),J.success(a(`gitView.toast.revertedFile`,{path:e})),await ve(t,!1)}catch(e){J.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{O(t=>{let n=new Set(t);return n.delete(e),n})}}),Ee=R(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 ve(t,!1),J.success(n.length===1?a(`gitView.toast.revertedFilesSingle`,{count:n.length}):a(`gitView.toast.revertedFilesPlural`,{count:n.length}))}catch(e){J.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{O(new Set),A(!1)}}),De=R(e=>{let t=e.map(e=>e.trim()).filter(Boolean);if(t.length===0){P([]);return}E(e=>`${e.trim()}${e.trim()?`
3
3
 
4
4
  `:``}${t.join(`
5
- `)}`.trim()),P([])}),Oe=R(async()=>{if(!s)return;let e=s,t=oe.map(e=>e.path).sort();if(t.length===0){J.error(a(`gitView.toast.selectFileToDescribe`));return}M(!0);try{let{message:n}=await at(e,t);E(n.subject?.trim()??``),P(Array.isArray(n.highlights)?n.highlights:[])}catch(e){J.error(e instanceof Error?e.message:a(`gitView.toast.generateCommitMessageFailed`))}finally{M(!1)}}),ke=async(e={})=>{if(!s)return;let t=s;if(!T.trim()){J.error(a(`gitView.toast.enterCommitMessage`));return}let n=oe.map(e=>e.path).sort();if(n.length===0){J.error(a(`gitView.toast.selectFileToCommit`));return}w(e.pushAfter?`commitAndPush`:`commit`);try{if(await o.createGitCommit(t,T.trim(),{files:n}),J.success(a(`gitView.toast.commitCreated`)),E(``),P([]),e.pushAfter){let e=c?.tracking?.split(`/`)[0],n=K.find(t=>t.name===e)??K[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 ve(t,!1),await be(t).promise}else await ve(t,!1)}catch(e){J.error(e instanceof Error?e.message:a(`gitView.toast.createCommitFailed`))}finally{w(null),e.pushAfter&&S(null)}},Ae=Q.useMemo(()=>{let e=[];return oe.length>0&&e.push({id:`staged`,title:a(`gitView.changes.stagedTitle`),entries:oe,actionSymbol:`-`,actionAllLabel:a(`gitView.changes.unstageAllAria`),getActionLabel:e=>a(`gitView.changes.unstageFileAria`,{path:e}),onActionFile:e=>void Se([e],`unstage`),onActionAll:e=>void Se(e,`unstage`),onViewDiff:e=>Ce(e,!0),onRevertFile:Te,showRevertActions:!1,accent:!0}),se.length>0&&e.push({id:`unstaged`,title:a(`gitView.changes.title`),entries:se,actionSymbol:`+`,actionAllLabel:a(`gitView.changes.stageAllAria`),getActionLabel:e=>a(`gitView.changes.stageFileAria`,{path:e}),onActionFile:e=>void Se([e],`stage`),onActionAll:e=>void Se(e,`stage`),onViewDiff:e=>Ce(e,!1),onRevertFile:Te}),e},[Te,Ce,Se,oe,a,se]),je=t=>(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[i?null:(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,children:[e?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":a(`mobile.surface.closeAria`),onClick:e,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label text-foreground`,children:a(`mobile.nav.changes`)}),(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:c?.current||s||``})]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:t})]});return s?u&&l===null?je((0,$.jsx)(Ea,{loading:!0,message:a(`gitView.loading.checkingRepository`)})):l===!1?je((0,$.jsx)(Ea,{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)(Da,{path:v.path,diff:de,fileExists:_e,error:ge,loading:he,targetLine:v.targetLine,onBack:we,onRetry:()=>re(e=>e+1),hideHeader:i})}):(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,children:[e?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":a(`mobile.surface.closeAria`),onClick:e,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label text-foreground`,children:a(`mobile.nav.changes`)}),(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:c?.current||s})]}),(0,$.jsx)(Br,{syncAction:x,remotes:K,onSync:e=>void xe(`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})]}),ae?(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(zr,{stagedCount:ce,unstagedCount:le,onLoad:()=>ie(!0)})}):G.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)(Jr,{groups:Ae,diffStats:c?.diffStats,revertingPaths:D,onRevertAll:Ee,isRevertingAll:k,headerBackgroundClassName:`bg-transparent`,onVisiblePathsChange:I})}),(0,$.jsx)(`div`,{className:`shrink-0 border-t border-border/50 px-4 pb-4 pt-3`,children:(0,$.jsx)(Gr,{stagedCount:oe.length,commitMessage:T,onCommitMessageChange:E,generatedHighlights:N,onInsertHighlights:De,onGenerateMessage:Oe,isGeneratingMessage:j,onCommit:()=>void ke({pushAfter:!1}),onCommitAndPush:()=>void ke({pushAfter:!0}),commitAction:C,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Ea,{icon:!0,message:a(`gitView.empty.cleanTitle`),description:a(`mobile.changes.cleanDescription`)})})]}):je((0,$.jsx)(Ea,{message:a(`gitView.empty.selectSessionOrDirectory`)}))},Ea=e=>{let t=(0,zi.c)(13),{message:n,description:r,loading:i,icon:a}=e,o=i!==void 0&&i,s=a!==void 0&&a,c;t[0]===o?c=t[1]:(c=o?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):null,t[0]=o,t[1]=c);let l;t[2]===s?l=t[3]:(l=s?(0,$.jsx)(X,{name:`git-branch`,className:`size-6 text-muted-foreground`}):null,t[2]=s,t[3]=l);let u;t[4]===n?u=t[5]:(u=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[4]=n,t[5]=u);let d;t[6]===r?d=t[7]:(d=r?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r}):null,t[6]=r,t[7]=d);let f;return t[8]!==c||t[9]!==l||t[10]!==u||t[11]!==d?(f=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[c,l,u,d]})}),t[8]=c,t[9]=l,t[10]=u,t[11]=d,t[12]=f):f=t[12],f},Da=e=>{let t=(0,zi.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=Ln(n)||`text`,t[0]=n,t[1]=p);let m=p,h;t[2]!==d||t[3]!==c||t[4]!==n||t[5]!==f?(h=d?null:(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/50 px-3 text-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":f(`header.actions.backAria`),onClick:c,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-2`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-header text-foreground`,children:n})})]}),t[2]=d,t[3]=c,t[4]=n,t[5]=f,t[6]=h):h=t[6];let g;t[7]!==r||t[8]!==a||t[9]!==i||t[10]!==m||t[11]!==o||t[12]!==l||t[13]!==n||t[14]!==f||t[15]!==s?(g=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:a?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:f(`mobile.changes.diffDetail.loadFailed`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:a}),(0,$.jsx)(Z,{type:`button`,size:`sm`,variant:`outline`,onClick:l,children:f(`diffView.actions.retry`)})]})}):o?(0,$.jsx)(Ea,{loading:!0,message:f(`diffView.state.loadingDiff`)}):i?r?r.isBinary?(0,$.jsx)(Ea,{icon:!0,message:f(`diffView.binary.unavailable`)}):Rn(n)?(0,$.jsx)(Ea,{icon:!0,message:f(`mobile.changes.diffDetail.imageUnavailable`)}):(0,$.jsx)(Fn,{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)(Er,{original:r.original,modified:r.modified,language:m,fileName:n,renderSideBySide:!1,wrapLines:!0,focusLine:s,layout:`inline`})}):(0,$.jsx)(Ea,{loading:!0,message:f(`diffView.state.loadingDiff`)}):(0,$.jsx)(Ea,{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],_},Oa=e(S(),1),ka=`data-oc-motion-id`,Aa=`data-oc-sheet-overscroll`,ja=`html, body { overscroll-behavior-y: none; }`,Ma=[`input`,`textarea`,`select`,`[contenteditable]:not([contenteditable="false"])`,`[data-mobile-sheet-no-dismiss]`].join(`, `),Na=e=>e.closest(`[data-oc-motion-id]`)?.getAttribute(`data-oc-motion-id`)??null,Pa=e=>{try{let t=e.contentDocument;return t?t.scrollingElement??t.documentElement:null}catch{return null}},Fa=(e,t)=>Number.isFinite(e)&&Number.isFinite(t)&&e<=1&&t>0,Ia=(e,t,n)=>e?!0:Fa(t,n),La=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.Element},Ra=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.HTMLElement},za=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.HTMLStyleElement},Ba=(e,t)=>{if(typeof e.item==`function`){let n=e.item(t);if(n)return n}return e[t]??null},Va=(e,t)=>{for(let n=0;n<e.length;n+=1){let r=Ba(e,n);if(r?.identifier===t)return r}return null},Ha=(e,t)=>{try{let n=e.defaultView?.getComputedStyle(t);if(!n)return!1;let r=n.overflowY;return(r===`auto`||r===`scroll`||r===`overlay`)&&t.scrollHeight>t.clientHeight+1}catch{return!1}},Ua=(e,t)=>{let n=[],r=new Set,i=t=>{!t||r.has(t)||Ha(e,t)&&(r.add(t),n.push(t))},a=La(e,t)?t:null;for(;a&&(Ra(e,a)&&i(a),a!==e.documentElement&&a!==e.body);)a=a.parentElement;let o=e.scrollingElement??e.documentElement;return Ra(e,o)&&i(o),n},Wa=(e,t)=>{let n=Ua(e,t);if(n.length===0){let t=(e.scrollingElement??e.documentElement)?.scrollTop??1/0;return Number.isFinite(t)&&t<=1}return n.every(e=>e.scrollTop<=1)},Ga=e=>{let t=e.closest(`[${ka}]`);if(t instanceof HTMLElement){let e=t.getBoundingClientRect().height;if(Number.isFinite(e)&&e>0)return e}return window.innerHeight||1},Ka=e=>{let t=null,n=()=>{t?.(),t=null;let n=(()=>{try{return e.contentDocument}catch{return null}})();if(!n)return;let r=Na(e);if(!r)return;let i=null;if(!za(n,n.querySelector(`style[${Aa}]`))){let e=n.createElement(`style`);e.setAttribute(Aa,`true`),e.textContent=ja,(n.head??n.documentElement).appendChild(e),i=e}let a=null,o=()=>{a?.active&&a.controller.finish(`cancel`),a=null},s=t=>{if(o(),t.touches.length!==1||(La(n,t.target)?t.target:null)?.closest(Ma)||!Wa(n,t.target))return;let r=Ba(t.touches,0);if(!r)return;let i=Ga(e);a={touchId:r.identifier,startX:r.screenX,startY:r.screenY,lastY:r.screenY,lastTime:t.timeStamp,lastVelocityTime:t.timeStamp,velocity:0,motionDistance:i,commitDistance:It(i,.1,40,64),active:!1,controller:null}},c=t=>{if(!a)return;if(t.touches.length!==1){o();return}let i=Va(t.touches,a.touchId);if(!i){o();return}let s=i.screenY-a.startY,c=i.screenX-a.startX,l=t.timeStamp-a.lastTime;if(a.velocity=Nt(a.velocity,i.screenY-a.lastY,l,t.timeStamp-a.lastVelocityTime,1),i.screenY!==a.lastY&&l>0&&(a.lastVelocityTime=t.timeStamp),a.lastY=i.screenY,a.lastTime=t.timeStamp,!a.active){if(!Wa(n,t.target)){a=null;return}if(!Ia(!1,Pa(e)?.scrollTop??0,s)){a=null;return}if(!Pt(`bottom`,c,s,8,1))return;let i=Jt(r);if(!i?.begin(`dismiss`)){a=null;return}a={...a,active:!0,controller:i}}let u=a;if(!u.active)return;t.preventDefault();let d=Lt(`bottom`,c,s);u.controller.update(Rt(d,u.motionDistance))},l=e=>{if(!a)return;let t=a,n=Va(e.changedTouches,t.touchId);if(a=null,!t.active)return;if(!n){t.controller.finish(`cancel`);return}let r=e.timeStamp-t.lastTime;t.velocity=Nt(t.velocity,n.screenY-t.lastY,r,e.timeStamp-t.lastVelocityTime,1),n.screenY!==t.lastY&&r>0&&(t.lastVelocityTime=e.timeStamp),t.lastY=n.screenY,t.lastTime=e.timeStamp;let i=n.screenY-t.startY,o=n.screenX-t.startX,s=Lt(`bottom`,o,i),c=Ft(s,t.velocity,t.commitDistance,.65,12);t.controller.finish(c?`commit`:`cancel`),e.preventDefault()},u=()=>o();n.addEventListener(`touchstart`,s,{capture:!0,passive:!0}),n.addEventListener(`touchmove`,c,{capture:!0,passive:!1}),n.addEventListener(`touchend`,l,{capture:!0,passive:!1}),n.addEventListener(`touchcancel`,u,{capture:!0,passive:!0}),t=()=>{o(),n.removeEventListener(`touchstart`,s,!0),n.removeEventListener(`touchmove`,c,!0),n.removeEventListener(`touchend`,l,!0),n.removeEventListener(`touchcancel`,u,!0);try{i?.remove()}catch{}i=null}};return e.addEventListener(`load`,n),n(),()=>{e.removeEventListener(`load`,n),t?.()}},qa=Pn(()=>M(()=>import(`./ToolOutputDialog-D9S-X8hM.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53]))),Ja=25e4,Ya=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Xa=e=>{let t=Ya(e);return!t||t===`/`?t||`/`:t.split(`/`).filter(Boolean).at(-1)??t},Za=e=>{let t=Ya(e);if(!t||t===`/`)return null;let n=t.lastIndexOf(`/`);return n<=0?t.startsWith(`/`)?`/`:null:t.slice(0,n)},Qa=(e,t)=>{let n=Ya(e),r=Ya(t);return!r||n===r?Xa(n):n.startsWith(`${r}/`)?n.slice(r.length+1):n},$a=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``},eo=e=>e.toLowerCase().endsWith(`.svg`)?``:o().authenticatedAsset(`/api/fs/raw`,{path:e}),to=e=>/\.(md|mdx|markdown)$/i.test(e),no=e=>{let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return`/api/fs/serve${t.startsWith(`/`)?t:`/${t}`}`},ro=e=>o().authenticatedAsset(no(e)),io=e=>{let t=(0,zi.c)(148),{onClose:n,initialFilePath:r,directFilePreview:i,hideFileHeader:a}=e,o=r===void 0?null:r,s=i!==void 0&&i,c=a!==void 0&&a,{t:l}=ee(),{files:u}=gn(),d=Vn()??null,f;t[0]===d?f=t[1]:(f=Ya(d),t[0]=d,t[1]=f);let p=f,m;t[2]!==o||t[3]!==p?(m=()=>{let e=Ya(o);return e?{type:`file`,path:e,returnDirectory:Za(e)??p}:{type:`browser`,directory:p}},t[2]=o,t[3]=p,t[4]=m):m=t[4];let[h,g]=Q.useState(m),_=Q.useRef(null),[v,y]=Q.useState(``),b=k(po),x=k(mo),S,C;t[5]===p?(S=t[6],C=t[7]):(S=()=>{p&&g(e=>e.type===`file`?e.returnDirectory?e:{...e,returnDirectory:Za(e.path)??p}:e.type===`browser`&&e.directory?e:{type:`browser`,directory:p})},C=[p],t[5]=p,t[6]=S,t[7]=C),Q.useEffect(S,C);let w,T;t[8]!==b||t[9]!==p||t[10]!==x?(T=()=>{if(!b||!p)return;let e=Ya(b);if(!e){x(null);return}y(``),g({type:`file`,path:e,returnDirectory:Za(e)??p}),x(null)},w=[b,p,x],t[8]=b,t[9]=p,t[10]=x,t[11]=w,t[12]=T):(w=t[11],T=t[12]),Q.useEffect(T,w);let E=h.type===`browser`?h.directory:h.returnDirectory,D=h.type===`browser`?h.directory:``,O=h.type===`file`?h.path:``,[A,j]=Q.useState(`preview`),M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{j(`preview`)},t[13]=M):M=t[13];let N;t[14]===O?N=t[15]:(N=[O],t[14]=O,t[15]=N),Q.useEffect(M,N);let P=yn(v,250),F;t[16]===v?F=t[17]:(F=v.trim(),t[16]=v,t[17]=F);let I=F,L;t[18]===P?L=t[19]:(L=P.trim(),t[18]=P,t[19]=L);let z=L,B;t[20]!==D||t[21]!==p?(B={scopeDirectory:p,directory:D},t[20]=D,t[21]=p,t[22]=B):B=t[22];let V=!!D,ne;t[23]===V?ne=t[24]:(ne={enabled:V,refetchOnMount:`always`},t[23]=V,t[24]=ne);let H=Ci(B,ne),re;t[25]!==D||t[26]!==z?(re={directory:D,query:z,maxResults:40},t[25]=D,t[26]=z,t[27]=re):re=t[27];let U=!!(D&&z),W;t[28]===U?W=t[29]:(W={enabled:U},t[28]=U,t[29]=W);let ie=Si(re,W),ae;t[30]!==O||t[31]!==u||t[32]!==A?(ae=O&&u.readFile&&(!Bn(O)||A===`source`)&&(!Rn(O)||O.toLowerCase().endsWith(`.svg`)),t[30]=O,t[31]=u,t[32]=A,t[33]=ae):ae=t[33];let G=!!ae,oe;t[34]!==O||t[35]!==p?(oe={scopeDirectory:p,path:O},t[34]=O,t[35]=p,t[36]=oe):oe=t[36];let se;t[37]===G?se=t[38]:(se={enabled:G},t[37]=G,t[38]=se);let ce=Ti(oe,se),le;t[39]!==O||t[40]!==p?(le={scopeDirectory:p,path:O},t[39]=O,t[40]=p,t[41]=le):le=t[41];let K;t[42]===G?K=t[43]:(K={enabled:G},t[42]=G,t[43]=K),wi(le,K);let ue=H.data?.entries.slice().sort(ho)??[],de;t[44]!==H.error||t[45]!==l?(de=H.error?H.error instanceof Error?H.error.message:l(`mobile.files.error.listFailed`):null,t[44]=H.error,t[45]=l,t[46]=de):de=t[46];let fe=de,pe=H.isFetching,me;t[47]===ie.data?me=t[48]:(me=ie.data??[],t[47]=ie.data,t[48]=me);let he=me,ge=!!(I&&z&&v===P&&ie.isFetching),_e;t[49]!==ce.data||t[50]!==l?(_e=ce.data&&ce.data.length>Ja?`${ce.data.slice(0,Ja)}\n\n${l(`mobile.files.file.truncated`)}`:ce.data??``,t[49]=ce.data,t[50]=l,t[51]=_e):_e=t[51];let ve=_e,ye;t[52]!==O||t[53]!==ce.error||t[54]!==u||t[55]!==l?(ye=O&&!u.readFile?l(`mobile.files.error.readUnavailable`):ce.error?ce.error instanceof Error?ce.error.message:l(`filesView.error.readFileFailed`):null,t[52]=O,t[53]=ce.error,t[54]=u,t[55]=l,t[56]=ye):ye=t[56];let be=ye,xe=G&&ce.isFetching,Se;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(Se=e=>{y(``),g({type:`browser`,directory:e})},t[57]=Se):Se=t[57];let Ce=Se,we;t[58]!==E||t[59]!==p?(we=e=>{g({type:`file`,path:e,returnDirectory:E||p})},t[58]=E,t[59]=p,t[60]=we):we=t[60];let Te=we,Ee;t[61]!==s||t[62]!==n||t[63]!==h.returnDirectory||t[64]!==h.type?(Ee=()=>h.type===`file`?s?(n?.(),!0):(g({type:`browser`,directory:h.returnDirectory}),!0):!1,t[61]=s,t[62]=n,t[63]=h.returnDirectory,t[64]=h.type,t[65]=Ee):Ee=t[65];let De=R(Ee),Oe=h.type===`file`,ke;t[66]!==De||t[67]!==Oe?(ke={id:`mobile-files-detail`,active:Oe,layer:`overlay`,onBack:De,surfaceRef:_},t[66]=De,t[67]=Oe,t[68]=ke):ke=t[68],En(ke);let Ae;t[69]===l?Ae=t[70]:(Ae=async e=>{(await te(e)).ok||J.error(l(`mobile.files.toast.copyFailed`))},t[69]=l,t[70]=Ae);let je=Ae,Me;t[71]!==ve||t[72]!==l?(Me=async()=>{(await te(ve)).ok?J.success(l(`mobile.files.toast.contentCopied`)):J.error(l(`mobile.files.toast.copyFailed`))},t[71]=ve,t[72]=l,t[73]=Me):Me=t[73];let q=Me;if(!p){let e;t[74]===l?e=t[75]:(e=l(`mobile.files.empty.noDirectory`),t[74]=l,t[75]=e);let n;return t[76]===e?n=t[77]:(n=(0,$.jsx)(fo,{message:e}),t[76]=e,t[77]=n),n}if(h.type===`file`){let e;t[78]!==je||t[79]!==h.path?(e=()=>void je(h.path),t[78]=je,t[79]=h.path,t[80]=e):e=t[80];let n;t[81]===q?n=t[82]:(n=()=>void q(),t[81]=q,t[82]=n);let r;return t[83]!==De||t[84]!==ve||t[85]!==be||t[86]!==c||t[87]!==A||t[88]!==xe||t[89]!==h.path||t[90]!==e||t[91]!==n?(r=(0,$.jsx)(`div`,{ref:_,className:`flex h-full min-h-0 flex-col`,children:(0,$.jsx)(co,{path:h.path,content:ve,error:be,isLoading:xe,hideHeader:c,htmlViewMode:A,onHtmlViewModeChange:j,onBack:De,onCopyPath:e,onCopyContent:n})}),t[83]=De,t[84]=ve,t[85]=be,t[86]=c,t[87]=A,t[88]=xe,t[89]=h.path,t[90]=e,t[91]=n,t[92]=r):r=t[92],r}let Ne;t[93]!==p||t[94]!==h.directory||t[95]!==l?(Ne=h.directory===p?l(`mobile.files.rootDirectory`):Xa(h.directory),t[93]=p,t[94]=h.directory,t[95]=l,t[96]=Ne):Ne=t[96];let Pe=Ne,Fe;t[97]!==v||t[98]!==he?(Fe=v.trim()?he:[],t[97]=v,t[98]=he,t[99]=Fe):Fe=t[99];let Ie=Fe,Le,Re,ze,Be;if(t[100]!==n||t[101]!==v||t[102]!==p||t[103]!==h.directory||t[104]!==l){let e=Za(h.directory),r=h.directory!==p&&e!==null&&(e===p||e.startsWith(`${p}/`)),i=r&&!v.trim(),a=r?e:null;Be=`flex h-full flex-col overflow-hidden bg-background text-foreground`,Le=`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,t[109]!==n||t[110]!==l?(Re=n?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":l(`mobile.surface.closeAria`),onClick:n,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,t[109]=n,t[110]=l,t[111]=Re):Re=t[111],ze=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:Xa(a)}),onClick:()=>Ce(a),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}):null,t[100]=n,t[101]=v,t[102]=p,t[103]=h.directory,t[104]=l,t[105]=Le,t[106]=Re,t[107]=ze,t[108]=Be}else Le=t[105],Re=t[106],ze=t[107],Be=t[108];let Ve;t[112]===Pe?Ve=t[113]:(Ve=(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label text-foreground`,children:Pe})}),t[112]=Pe,t[113]=Ve);let He;t[114]===l?He=t[115]:(He=l(`mobile.files.refreshAria`),t[114]=l,t[115]=He);let Ue;t[116]===H?Ue=t[117]:(Ue=()=>void H.refetch(),t[116]=H,t[117]=Ue);let We;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(We={touchAction:`manipulation`},t[118]=We):We=t[118];let Ge=pe&&`animate-spin`,Ke;t[119]===Ge?Ke=t[120]:(Ke=Y(`size-5`,Ge),t[119]=Ge,t[120]=Ke);let qe;t[121]===Ke?qe=t[122]:(qe=(0,$.jsx)(X,{name:`refresh`,className:Ke}),t[121]=Ke,t[122]=qe);let Je;t[123]!==He||t[124]!==Ue||t[125]!==qe?(Je=(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":He,onClick:Ue,style:We,children:qe}),t[123]=He,t[124]=Ue,t[125]=qe,t[126]=Je):Je=t[126];let Ye;t[127]!==Le||t[128]!==Re||t[129]!==ze||t[130]!==Ve||t[131]!==Je?(Ye=(0,$.jsxs)(`header`,{className:Le,children:[Re,ze,Ve,Je]}),t[127]=Le,t[128]=Re,t[129]=ze,t[130]=Ve,t[131]=Je,t[132]=Ye):Ye=t[132];let Xe;t[133]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),t[133]=Xe):Xe=t[133];let Ze;t[134]===Symbol.for(`react.memo_cache_sentinel`)?(Ze=e=>y(e.target.value),t[134]=Ze):Ze=t[134];let Qe;t[135]===l?Qe=t[136]:(Qe=l(`mobile.files.search.placeholder`),t[135]=l,t[136]=Qe);let $e;t[137]!==v||t[138]!==Qe?($e=(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,"data-mobile-sheet-no-dismiss":``,children:(0,$.jsxs)(`div`,{className:`relative`,children:[Xe,(0,$.jsx)(Yt,{type:`text`,inputMode:`search`,value:v,onChange:Ze,placeholder:Qe,className:`h-11 pl-9`})]})}),t[137]=v,t[138]=Qe,t[139]=$e):$e=t[139];let et=Fn,Z=fe?(0,$.jsx)(fo,{message:fe}):v.trim()?(0,$.jsx)(oo,{results:Ie,isSearching:ge,onOpenFile:Te}):(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:[ue.length===0&&!pe?(0,$.jsx)(`div`,{className:`px-4 py-8 text-center typography-body text-muted-foreground`,children:l(`mobile.files.empty.directory`)}):null,ue.map(e=>(0,$.jsx)(ao,{name:e.name,path:e.path,directory:e.isDirectory,meta:e.isDirectory?void 0:$a(e.size),onClick:()=>e.isDirectory?Ce(e.path):Te(e.path)},e.path))]}),tt;t[140]!==et||t[141]!==Z?(tt=(0,$.jsx)(et,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto px-4 pb-3`,children:Z}),t[140]=et,t[141]=Z,t[142]=tt):tt=t[142];let nt;return t[143]!==Be||t[144]!==Ye||t[145]!==$e||t[146]!==tt?(nt=(0,$.jsxs)(`div`,{className:Be,children:[Ye,$e,tt]}),t[143]=Be,t[144]=Ye,t[145]=$e,t[146]=tt,t[147]=nt):nt=t[147],nt},ao=e=>{let t=(0,zi.c)(16),{name:n,path:r,directory:i,meta:a,onClick:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]!==i||t[2]!==r?(c=i?(0,$.jsx)(X,{name:`folder-3-fill`,className:`size-5 shrink-0 text-muted-foreground`}):(0,$.jsx)(vt,{filePath:r,className:`size-5 shrink-0`}),t[1]=i,t[2]=r,t[3]=c):c=t[3];let l;t[4]===n?l=t[5]:(l=(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:n}),t[4]=n,t[5]=l);let u;t[6]===a?u=t[7]:(u=a?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:a}):null,t[6]=a,t[7]=u);let d;t[8]===i?d=t[9]:(d=i?(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground/60`}):null,t[8]=i,t[9]=d);let f;return t[10]!==o||t[11]!==c||t[12]!==l||t[13]!==u||t[14]!==d?(f=(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-14 w-full items-center gap-3 border-b border-border/30 px-3 py-2.5 text-left transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,onClick:o,style:s,children:[c,l,u,d]}),t[10]=o,t[11]=c,t[12]=l,t[13]=u,t[14]=d,t[15]=f):f=t[15],f},oo=e=>{let t=(0,zi.c)(10),{results:n,isSearching:r,onOpenFile:i}=e,{t:a}=ee(),o=Ya(Vn()??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)(fo,{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)(fo,{message:e}),t[6]=e,t[7]=n),n}let s=n.map(e=>(0,$.jsx)(ao,{name:Xa(e.path),path:e.path,directory:!1,meta:Qa(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},so=e=>{let t=(0,zi.c)(24),{path:n,htmlViewMode:r,htmlFullscreen:i,onToggleHtmlViewMode:a,onEnterHtmlFullscreen:o,onCopyPath:s,onCopyContent:c}=e,{t:l}=ee(),u;t[0]===n?u=t[1]:(u=Bn(n),t[0]=n,t[1]=u);let d=u,f;t[2]!==d||t[3]!==i||t[4]!==r||t[5]!==o||t[6]!==a||t[7]!==l?(f=d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,onClick:a,"aria-label":l(r===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(X,{name:r===`preview`?`file-code`:`eye`,className:`size-4`})}),i?null:(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,onClick:o,"aria-label":l(`mobile.files.html.fullscreenAria`),children:(0,$.jsx)(X,{name:`fullscreen`,className:`size-4`})})]}):null,t[2]=d,t[3]=i,t[4]=r,t[5]=o,t[6]=a,t[7]=l,t[8]=f):f=t[8];let p;t[9]!==d||t[10]!==c||t[11]!==n||t[12]!==l?(p=!Rn(n)&&!d?(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,onClick:c,"aria-label":l(`mobile.files.copyContentAria`),children:(0,$.jsx)(X,{name:`file-copy`,className:`size-4`})}):null,t[9]=d,t[10]=c,t[11]=n,t[12]=l,t[13]=p):p=t[13];let m;t[14]===l?m=t[15]:(m=l(`mobile.files.copyPathAria`),t[14]=l,t[15]=m);let h;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(X,{name:`clipboard`,className:`size-4`}),t[16]=h):h=t[16];let g;t[17]!==s||t[18]!==m?(g=(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,onClick:s,"aria-label":m,children:h}),t[17]=s,t[18]=m,t[19]=g):g=t[19];let _;return t[20]!==f||t[21]!==p||t[22]!==g?(_=(0,$.jsxs)($.Fragment,{children:[f,p,g]}),t[20]=f,t[21]=p,t[22]=g,t[23]=_):_=t[23],_},co=e=>{let n=(0,zi.c)(100),{path:r,content:a,error:o,isLoading:c,hideHeader:l,htmlViewMode:f,onHtmlViewModeChange:p,onBack:m,onCopyPath:h,onCopyContent:g}=e,_=l!==void 0&&l,{t:v}=ee(),y=Q.useRef(null),b=Rn(r)&&!r.toLowerCase().endsWith(`.svg`)?r:``,x;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=s(),n[0]=x):x=n[0];let S=x,C;n[1]===b?C=n[2]:(C=b&&i()?`${S}|${b}`:``,n[1]=b,n[2]=C);let w=C,T=b&&!w?`${S}|${b}`:``,[E,D]=Q.useState(``),[O,k]=Q.useState(``),[A,j]=Q.useState(null),[M,N]=Q.useState(!1),P;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(P={open:!1,title:``,content:``},n[3]=P):P=n[3];let[F,I]=Q.useState(P),L,z;n[4]===T?(L=n[5],z=n[6]):(L=()=>{if(!T){D(``);return}let e=!1;return D(``),t(u()).then(t=>{!e&&t&&D(T)}).catch(go),()=>{e=!0}},z=[T],n[4]=T,n[5]=L,n[6]=z),Q.useEffect(L,z);let te,B;n[7]!==b||n[8]!==w||n[9]!==v?(te=()=>{if(!w){k(``),j(null),N(!1);return}let e=!1,t=``;return k(``),j(null),N(!0),d(`/api/fs/raw`,{query:{path:b}}).then(async e=>{if(!e.ok)throw Error(v(`filesView.error.readFileFailed`));return e.blob()}).then(n=>{if(t=URL.createObjectURL(n),e){URL.revokeObjectURL(t);return}k(t)}).catch(t=>{e||j(t instanceof Error?t.message:v(`filesView.error.readFileFailed`))}).finally(()=>{e||N(!1)}),()=>{e=!0,t&&URL.revokeObjectURL(t)}},B=[b,w,v],n[7]=b,n[8]=w,n[9]=v,n[10]=te,n[11]=B):(te=n[10],B=n[11]),Q.useEffect(te,B);let V=!!(T&&E!==T),ne;n[12]!==V||n[13]!==r||n[14]!==w||n[15]!==O?(ne=w?O:V?``:eo(r),n[12]=V,n[13]=r,n[14]=w,n[15]=O,n[16]=ne):ne=n[16];let H=ne,re=o??A,U;n[17]===r?U=n[18]:(U=Xa(r),n[17]=r,n[18]=U);let W=U,ie;n[19]!==a||n[20]!==r?(ie=Rn(r)?`data:${zn(r)};utf8,${encodeURIComponent(a)}`:``,n[19]=a,n[20]=r,n[21]=ie):ie=n[21];let ae=ie,G;n[22]!==a||n[23]!==ae||n[24]!==H||n[25]!==r?(G=H||(Rn(r)&&a?ae:``),n[22]=a,n[23]=ae,n[24]=H,n[25]=r,n[26]=G):G=n[26];let oe=G,se;n[27]!==W||n[28]!==b||n[29]!==r||n[30]!==oe?(se=()=>{let e=b||oe;e&&I({open:!0,title:W,content:``,metadata:{tool:`image-preview`,filename:W,mime:zn(r)},image:{url:e,mimeType:zn(r),filename:W}})},n[27]=W,n[28]=b,n[29]=r,n[30]=oe,n[31]=se):se=n[31];let ce=R(se),le;n[32]===Symbol.for(`react.memo_cache_sentinel`)?(le=e=>{I(t=>t.open===e?t:{...t,open:e})},n[32]=le):le=n[32];let K=R(le),ue;n[33]===r?ue=n[34]:(ue=Bn(r),n[33]=r,n[34]=ue);let de=ue,[fe,pe]=Q.useState(!1),me=Q.useRef(null),he;n[35]===Symbol.for(`react.memo_cache_sentinel`)?(he=()=>{pe(!1)},n[35]=he):he=n[35];let ge;n[36]===r?ge=n[37]:(ge=[r],n[36]=r,n[37]=ge),Q.useEffect(he,ge);let _e;n[38]!==f||n[39]!==p?(_e=()=>{p(f===`preview`?`source`:`preview`)},n[38]=f,n[39]=p,n[40]=_e):_e=n[40];let ve=R(_e),ye;n[41]===Symbol.for(`react.memo_cache_sentinel`)?(ye=()=>{pe(!0)},n[41]=ye):ye=n[41];let be=R(ye),xe;n[42]===Symbol.for(`react.memo_cache_sentinel`)?(xe=()=>(pe(!1),!0),n[42]=xe):xe=n[42];let Se=R(xe),Ce=de&&fe,we;n[43]!==Se||n[44]!==Ce?(we={id:`mobile-html-fullscreen`,active:Ce,layer:`overlay`,onBack:Se,surfaceRef:me},n[43]=Se,n[44]=Ce,n[45]=we):we=n[45],En(we);let Te;n[46]!==be||n[47]!==fe||n[48]!==f||n[49]!==g||n[50]!==h||n[51]!==r||n[52]!==ve?(Te=(0,$.jsx)(so,{path:r,htmlViewMode:f,htmlFullscreen:fe,onToggleHtmlViewMode:ve,onEnterHtmlFullscreen:be,onCopyPath:h,onCopyContent:g}),n[46]=be,n[47]=fe,n[48]=f,n[49]=g,n[50]=h,n[51]=r,n[52]=ve,n[53]=Te):Te=n[53];let Ee=Te,De;n[54]!==a||n[55]!==o||n[56]!==f||n[57]!==c||n[58]!==r||n[59]!==v?(De=f===`source`?c?(0,$.jsx)(fo,{loading:!0,message:v(`filesView.state.loading`)}):o?(0,$.jsx)(fo,{message:o}):(0,$.jsx)(uo,{path:r,content:a}):(0,$.jsx)(lo,{path:r}),n[54]=a,n[55]=o,n[56]=f,n[57]=c,n[58]=r,n[59]=v,n[60]=De):De=n[60];let Oe=De,ke;n[61]!==Se||n[62]!==de||n[63]!==Oe||n[64]!==fe||n[65]!==f||n[66]!==W||n[67]!==v||n[68]!==ve?(ke=de?(0,$.jsxs)(`div`,{ref:me,"data-mobile-html-preview":f===`preview`&&!fe?`true`:void 0,"data-mobile-html-fullscreen":f===`preview`&&fe?`true`:void 0,className:fe?`fixed inset-0 z-[80] flex flex-col bg-background text-foreground`:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[fe?(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center gap-2 border-b border-border/50 px-3 pb-2 pt-[max(0.5rem,env(safe-area-inset-top))]`,children:[(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,onClick:Se,"aria-label":v(`mobile.files.html.exitFullscreenAria`),className:`shrink-0 text-muted-foreground`,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-header text-foreground`,children:W}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,onClick:ve,"aria-label":v(f===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(X,{name:f===`preview`?`file-code`:`eye`,className:`size-4`})})]}):null,(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden bg-background`,children:Oe})]}):null,n[61]=Se,n[62]=de,n[63]=Oe,n[64]=fe,n[65]=f,n[66]=W,n[67]=v,n[68]=ve,n[69]=ke):ke=n[69];let Ae=ke,je;n[70]!==Ee||n[71]!==_||n[72]!==W||n[73]!==m||n[74]!==v?(je=_?(0,$.jsx)(jt,{children:Ee}):(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/50 px-3 text-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":v(`header.actions.backAria`),onClick:m,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-header text-foreground`,children:W})}),Ee]}),n[70]=Ee,n[71]=_,n[72]=W,n[73]=m,n[74]=v,n[75]=je):je=n[75];let Me;n[76]!==a||n[77]!==de||n[78]!==fe||n[79]!==Ae||n[80]!==V||n[81]!==re||n[82]!==W||n[83]!==c||n[84]!==M||n[85]!==ce||n[86]!==r||n[87]!==oe||n[88]!==v?(Me=de?fe&&typeof document<`u`?(0,Oa.createPortal)(Ae,document.body):Ae:c||V||M?(0,$.jsx)(fo,{loading:!0,message:v(`filesView.state.loading`)}):re?(0,$.jsx)(fo,{message:re}):Rn(r)&&oe?(0,$.jsx)(Fn,{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:ce,"aria-label":W,children:(0,$.jsx)(`img`,{src:oe,alt:W,className:`mx-auto max-h-full max-w-full rounded-lg object-contain`,draggable:!1})})}):(0,$.jsx)(uo,{path:r,content:a}),n[76]=a,n[77]=de,n[78]=fe,n[79]=Ae,n[80]=V,n[81]=re,n[82]=W,n[83]=c,n[84]=M,n[85]=ce,n[86]=r,n[87]=oe,n[88]=v,n[89]=Me):Me=n[89];let q;n[90]===Me?q=n[91]:(q=(0,$.jsx)(`div`,{ref:y,className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:Me}),n[90]=Me,n[91]=q);let Ne;n[92]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=(0,$.jsx)(ct,{containerRef:y}),n[92]=Ne):Ne=n[92];let Pe;n[93]!==K||n[94]!==F?(Pe=F.open?(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(qa,{popup:F,onOpenChange:K,isMobile:!0})}):null,n[93]=K,n[94]=F,n[95]=Pe):Pe=n[95];let Fe;return n[96]!==je||n[97]!==q||n[98]!==Pe?(Fe=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[je,q,Ne,Pe]}),n[96]=je,n[97]=q,n[98]=Pe,n[99]=Fe):Fe=n[99],Fe},lo=e=>{let a=(0,zi.c)(29),{path:o}=e,{t:s}=ee(),c;a[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=i(),a[0]=c):c=a[0];let l=c,f=Q.useRef(null),[p,m]=Q.useState(``),[h,g]=Q.useState(0),[_,v]=Q.useState(null),[y,b]=Q.useState(``),x,S;a[1]!==o||a[2]!==s?(x=()=>{let e=!1;if(m(``),v(null),b(``),l)return d(no(o)).then(async e=>{if(!e.ok)throw Error(s(`filesView.error.readFileFailed`));return e.text()}).then(t=>{e||(b(t),m(o))}).catch(t=>{e||(v(t instanceof Error?t.message:s(`filesView.error.readFileFailed`)),m(o))}),()=>{e=!0};let i=u(),a=n(i);t(i).then(t=>{e||!t||(m(o),v(null))}).catch(t=>{e||(v(t instanceof Error?t.message:s(`filesView.error.readFileFailed`)),m(o))});let c=r(()=>{e||(m(o),g(_o),v(null))});return()=>{e=!0,a(),c()}},S=[o,l,s],a[1]=o,a[2]=s,a[3]=x,a[4]=S):(x=a[3],S=a[4]),Q.useEffect(x,S);let C;a[5]!==o||a[6]!==p?(C=()=>{if(p!==o)return;let e=f.current;if(e)return Ka(e)},a[5]=o,a[6]=p,a[7]=C):C=a[7];let w;if(a[8]!==h||a[9]!==o||a[10]!==p||a[11]!==y?(w=[h,o,p,y],a[8]=h,a[9]=o,a[10]=p,a[11]=y,a[12]=w):w=a[12],Q.useEffect(C,w),_){let e;return a[13]===_?e=a[14]:(e=(0,$.jsx)(fo,{message:_}),a[13]=_,a[14]=e),e}if(p!==o){let e;a[15]===s?e=a[16]:(e=s(`filesView.state.loading`),a[15]=s,a[16]=e);let t;return a[17]===e?t=a[18]:(t=(0,$.jsx)(fo,{loading:!0,message:e}),a[17]=e,a[18]=t),t}let T;a[19]===o?T=a[20]:(T=l?void 0:ro(o),a[19]=o,a[20]=T);let E=l?y:void 0,D;a[21]===Symbol.for(`react.memo_cache_sentinel`)?(D={backgroundColor:`var(--surface-background)`},a[21]=D):D=a[21];let O;a[22]===s?O=a[23]:(O=s(`filesView.editor.htmlPreviewTitle`),a[22]=s,a[23]=O);let k;return a[24]!==h||a[25]!==T||a[26]!==E||a[27]!==O?(k=(0,$.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:(0,$.jsx)(`iframe`,{ref:f,src:T,srcDoc:E,className:`h-full min-h-0 w-full flex-1 border-none bg-background`,style:D,sandbox:`allow-scripts allow-same-origin allow-forms`,title:O},h)}),a[24]=h,a[25]=T,a[26]=E,a[27]=O,a[28]=k):k=a[28],k},uo=e=>{let t=(0,zi.c)(30),{path:n,content:r}=e,{currentTheme:i,availableThemes:a,lightThemeId:o,darkThemeId:s}=dn(),c;t[0]!==a||t[1]!==o?(c=a.find(e=>e.metadata.id===o)??hn(!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)??hn(!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=()=>{jn(l),jn(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(to(n)){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(Fn,{className:`h-full overflow-y-auto px-4 py-4`,children:(0,$.jsx)(Nn,{content:r,enableFileReferences:!1})}),t[13]=r,t[14]=e),e}let g;t[15]===n?g=t[16]:(g=Xa(n),t[15]=n,t[16]=g);let _;t[17]===n?_=t[18]:(_=Ln(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:yr},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)(Fn,{className:`min-h-0 flex-1 overflow-auto bg-[var(--syntax-base-background)]`,children:(0,$.jsx)(I,{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},fo=e=>{let t=(0,zi.c)(7),{message:n,loading:r}=e,i=r!==void 0&&r,a;t[0]===i?a=t[1]:(a=i?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):(0,$.jsx)(X,{name:`folder-open-fill`,className:`size-6 text-muted-foreground`}),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[2]=n,t[3]=o);let s;return t[4]!==a||t[5]!==o?(s=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[a,o]})}),t[4]=a,t[5]=o,t[6]=s):s=t[6],s};function po(e){return e.pendingFileFocusPath}function mo(e){return e.setPendingFileFocusPath}function ho(e,t){return e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1}function go(){}function _o(e){return e+1}var vo=v(e=>({expandedParents:{},toggleParent:t=>e(e=>{let n={...e.expandedParents};return n[t]?delete n[t]:n[t]=!0,{expandedParents:n}})})),yo=v()(y(e=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(t,n)=>e(e=>({projectExpanded:{...e.projectExpanded,[t]:n}})),setWorktreeExpanded:(t,n)=>e(e=>({worktreeExpanded:{...e.worktreeExpanded,[t]:n}}))}),{name:`mobile-session-tree`,storage:p()}));typeof window<`u`&&a(e=>{l(e)&&yo.persist.rehydrate()});var bo=36,xo=18,So=e=>e.parentID??null,Co=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),wo=e=>{let t=e;return Co(t.directory??t.project?.worktree??null)},To=e=>{let t=Co(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},Eo=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},Do=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),Oo=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))},ko=(e,t)=>{let n=Co(e),r=Co(t);return!!(n&&r&&(n===r||n.startsWith(`${r}/`)))},Ao=(e,t)=>e.worktrees.find(e=>Co(e.path)===t)??null,jo=(e,t)=>t===e.path||!!Ao(e,t),Mo=(e,t)=>{let n=Co(t);return n?e.find(e=>jo(e,n))??null:null},No=(e,t,n)=>!n||`${e.title??``} ${e.id} ${wo(e)} ${t}`.toLowerCase().includes(n),Po=e=>{let t=(0,zi.c)(14),{project:n,size:r}=e,i=r===void 0?`md`:r,a=i===`sm`?`size-6 rounded-md`:`size-8 rounded-lg`,o=i===`sm`?`size-3.5`:`size-4`,s=n.icon?Wt[n.icon]:null,c=n.color?Kt[n.color]:void 0,l=s??`folder-open`,u;t[0]===c?u=t[1]:(u=c?{color:c}:void 0,t[0]=c,t[1]=u);let d;t[2]!==o||t[3]!==l||t[4]!==u?(d=(0,$.jsx)(X,{name:l,className:o,style:u}),t[2]=o,t[3]=l,t[4]=u,t[5]=d):d=t[5];let f=d,p;t[6]===a?p=t[7]:(p=Y(`flex shrink-0 items-center justify-center overflow-hidden text-muted-foreground`,a),t[6]=a,t[7]=p);let m;t[8]!==f||t[9]!==n?(m=n.iconImage?(0,$.jsx)(Ht,{project:n,className:`size-full object-contain`,fallback:f}):f,t[8]=f,t[9]=n,t[10]=m):m=t[10];let h;return t[11]!==p||t[12]!==m?(h=(0,$.jsx)(`span`,{className:p,children:m}),t[11]=p,t[12]=m,t[13]=h):h=t[13],h},Fo=e=>{let t=(0,zi.c)(5),{expanded:n}=e,r=n?`rotate-0`:`-rotate-90`,i;t[0]===r?i=t[1]:(i=Y(`flex size-5 shrink-0 items-center justify-center text-muted-foreground/70 transition-transform duration-150`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4`}),t[2]=a):a=t[2];let o;return t[3]===i?o=t[4]:(o=(0,$.jsx)(`span`,{"aria-hidden":!0,className:i,children:a}),t[3]=i,t[4]=o),o},Io=e=>{let t=(0,zi.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},Lo=e=>{let t=(0,zi.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=Y(`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,r),t[2]=r,t[3]=s);let c;t[4]===n?c=t[5]:(c=e=>{e.stopPropagation(),n()},t[4]=n,t[5]=c);let l,u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l={touchAction:`manipulation`},u=(0,$.jsx)(X,{name:`node-tree`,className:`size-4`}),t[6]=l,t[7]=u):(l=t[6],u=t[7]);let d;return t[8]!==o||t[9]!==s||t[10]!==c?(d=(0,$.jsx)(`button`,{type:`button`,className:s,"aria-label":o,title:o,onClick:c,style:l,children:u}),t[8]=o,t[9]=s,t[10]=c,t[11]=d):d=t[11],d},Ro=e=>{let t=(0,zi.c)(10),{icon:n,label:r,onClick:i,destructive:a}=e,o=a!==void 0&&a?`destructive`:`ghost`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,$.jsx)(X,{name:n,className:`size-5 shrink-0`}),t[1]=n,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[3]=r,t[4]=l);let u;return t[5]!==i||t[6]!==o||t[7]!==c||t[8]!==l?(u=(0,$.jsxs)(Z,{type:`button`,variant:o,size:`default`,className:`min-h-12 w-full justify-start gap-3 rounded-xl px-3 typography-ui-label`,onClick:i,style:s,children:[c,l]}),t[5]=i,t[6]=o,t[7]=c,t[8]=l,t[9]=u):u=t[9],u},zo=e=>{let t=(0,zi.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=Oo(Eo(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,te;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){te=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=Y(`relative flex items-center gap-1 transition-colors`,e,a),t[36]=e,t[37]=a,t[38]=N):N=t[38],t[39]!==y||t[40]!==v||t[41]!==i||t[42]!==l||t[43]!==b?(P=v&&l?(0,$.jsx)(`button`,{type:`button`,className:`absolute z-10 flex w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,style:{left:Math.max(i-32,2),top:0,bottom:0,touchAction:`manipulation`},"aria-label":b(y?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:e=>{e.stopPropagation(),l()},children:(0,$.jsx)(X,{name:`arrow-down-s`,className:Y(`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=Y(`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=Y(`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=Y(`block min-w-0 flex-1 truncate typography-ui-label`,f),t[54]=f,t[55]=F),I=g?an(te,g):te,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]=te}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],te=t[35];let B;t[56]!==F||t[57]!==I?(B=(0,$.jsx)(`span`,{className:F,children:I}),t[56]=F,t[57]=I,t[58]=B):B=t[58];let V;t[59]===S?V=t[60]:(V=S?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:S}):null,t[59]=S,t[60]=V);let ne;t[61]!==B||t[62]!==V||t[63]!==L||t[64]!==R?(ne=(0,$.jsxs)(`span`,{className:L,children:[R,B,V]}),t[61]=B,t[62]=V,t[63]=L,t[64]=R,t[65]=ne):ne=t[65];let H;t[66]!==a||t[67]!==g?(H=a?(0,$.jsx)(`span`,{className:`block truncate typography-micro text-muted-foreground pl-4`,children:g?an(a,g):a}):null,t[66]=a,t[67]=g,t[68]=H):H=t[68];let re;t[69]!==ne||t[70]!==H||t[71]!==z?(re=(0,$.jsxs)(`span`,{className:z,children:[ne,H]}),t[69]=ne,t[70]=H,t[71]=z,t[72]=re):re=t[72];let U;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]!==re?(U=(0,$.jsx)(`button`,{type:C,className:w,style:T,onClick:E,onPointerDown:D,onPointerMove:O,onPointerUp:k,onPointerCancel:A,onContextMenu:j,disabled:M,children:re}),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]=re,t[84]=U):U=t[84];let W;t[85]!==p||t[86]!==m?(W=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)(fr,{})}):null,t[85]=p,t[86]=m,t[87]=W):W=t[87];let ie;t[88]!==_||t[89]!==f||t[90]!==d||t[91]!==b||t[92]!==te?(ie=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:te}),onClick:f,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`archive`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label`,children:b(`sessions.sidebar.bulkActions.archive`)})]}):null,(0,$.jsx)(`button`,{type:`button`,className:`mr-1.5 flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":b(_?`mobile.sessions.cancelArchiveAria`:`mobile.sessions.archiveSessionAria`,{title:te}),onClick:d,style:{touchAction:`manipulation`},children:_?(0,$.jsx)(X,{name:`close`,className:`size-4`}):(0,$.jsx)(X,{name:`archive`,className:`size-4`})})]}):null,t[88]=_,t[89]=f,t[90]=d,t[91]=b,t[92]=te,t[93]=ie):ie=t[93];let ae;return t[94]!==N||t[95]!==P||t[96]!==U||t[97]!==W||t[98]!==ie?(ae=(0,$.jsxs)(`div`,{className:N,children:[P,U,W,ie]}),t[94]=N,t[95]=P,t[96]=U,t[97]=W,t[98]=ie,t[99]=ae):ae=t[99],ae},Bo=e=>{let t=(0,zi.c)(15),{indent:n,showMore:r,showFewer:i,loadingMore:a,onShowMore:o,onShowFewer:s}=e,c=a!==void 0&&a,{t:l}=ee();if(!r&&!i)return null;let u;t[0]===n?u=t[1]:(u={paddingLeft:n,touchAction:`manipulation`},t[0]=n,t[1]=u);let d;t[2]!==s||t[3]!==i||t[4]!==l?(d=i?(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-left transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,onClick:s,children:[(0,$.jsx)(X,{name:`arrow-up-s`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-micro`,children:l(`sessions.sidebar.group.showFewer`)})]}):null,t[2]=s,t[3]=i,t[4]=l,t[5]=d):d=t[5];let f;t[6]!==c||t[7]!==o||t[8]!==r||t[9]!==l?(f=r?(0,$.jsxs)(`button`,{type:`button`,className:Y(`inline-flex items-center gap-1.5 text-left transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset disabled:pointer-events-none disabled:opacity-60`,c&&`animate-pulse`),onClick:o,disabled:c,children:[(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-micro`,children:l(`sessions.sidebar.group.showMore`)})]}):null,t[6]=c,t[7]=o,t[8]=r,t[9]=l,t[10]=f):f=t[10];let p;return t[11]!==u||t[12]!==d||t[13]!==f?(p=(0,$.jsxs)(`div`,{className:`flex min-h-10 w-full items-center gap-3 py-1.5 pr-3 text-muted-foreground`,style:u,children:[d,f]}),t[11]=u,t[12]=d,t[13]=f,t[14]=p):p=t[14],p},Vo=({open:e,onOpenChange:t,variant:n=`sheet`})=>{let{t:r}=ee(),{git:i}=gn(),a=de(),o=Fe(e=>e.activeSessions),s=Fe(e=>e.activePaginationByDirectory),c=Ie(e=>e.projects),l=Ie(e=>e.activeProjectId),u=C(e=>e.currentDirectory),d=q(e=>e.currentSessionId),f=q(e=>e.availableWorktreesByProject),p=q(e=>e.setCurrentSession),m=q(e=>e.archiveSession),h=q(e=>e.archiveSessions),g=q(e=>e.updateSessionTitle),_=q(e=>e.requestSessionSmartTitle),v=q(e=>e.shareSession),y=q(e=>e.unshareSession),b=q(e=>e.openNewSessionDraft),x=Ie(e=>e.setActiveProject),S=Ie(e=>e.setActiveProjectIdOnly),w=Ie(e=>e.removeProject),T=Ue(),E=Ve(),D=yo(e=>e.projectExpanded),O=yo(e=>e.worktreeExpanded),k=yo(e=>e.setProjectExpanded),A=yo(e=>e.setWorktreeExpanded),j=Et(e=>e.orderByProject),M=vo(e=>e.expandedParents),N=vo(e=>e.toggleParent),[P,F]=Q.useState(``),[I,L]=Q.useState(null),[z,B]=Q.useState(null),[V,ne]=Q.useState(0),[H,re]=Q.useState(!1),[U,W]=Q.useState(!1),[ie,ae]=Q.useState(null),[G,oe]=Q.useState(null),[se,ce]=Q.useState(null),[le,K]=Q.useState(null),[ue,fe]=Q.useState(null),[pe,me]=Q.useState(``),[he,ge]=Q.useState(!1),[_e,ye]=Q.useState(null),be=Q.useRef(null);be.current||=Hn({onPressedKeyChange:K});let[xe,Se]=Q.useState(new Set),[Ce,we]=Q.useState(new Map),[Ee,De]=Q.useState(new Map),Oe=Tr(),ke=Cr(),je=R(e=>{ve(e),Be(e)}),Me=R(e=>{Promise.all(e.map(e=>(ve(e),Be(e))))});Q.useEffect(()=>{if(!e){F(``),De(new Map),L(null),B(null),oe(null),fe(null),ye(null),be.current?.reset();return}},[e]),Q.useEffect(()=>()=>{be.current?.reset()},[]),Q.useEffect(()=>{if(!e)return;if(c.length===0){q.setState(e=>{let t=Sr(e.availableWorktreesByProject,new Set,[]);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:[]}}),Se(e=>e.size===0?e:new Set),we(e=>e.size===0?e:new Map);return}let t=!1;return(async()=>{let e=await Promise.all(c.map(async e=>{let n=Co(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([qt({id:e.id,path:n},{isCurrent:()=>!t}),Ut(n)]);return{id:e.id,path:n,gitStatus:`success`,isGitRepo:r,worktreeStatus:a.status===`fulfilled`?`success`:`failed`,worktrees:a.status===`fulfilled`?a.value.worktrees:void 0,rootBranchStatus:o.status===`fulfilled`?`success`:`failed`,rootBranch:o.status===`fulfilled`?o.value:void 0}}));if(t)return;let n=new Set(c.map(e=>Co(e.path)).filter(Boolean)),r=e.flatMap(e=>e?.worktreeStatus?[{path:e.path,status:e.worktreeStatus,worktrees:e.worktrees}]:[]);q.setState(e=>{let t=Sr(e.availableWorktreesByProject,n,r);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:Array.from(t.values()).flat()}}),Se(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 Do(r,t)?t:r}),we(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,V]);let Ne=Q.useMemo(()=>c.map(e=>({id:e.id,label:To(e.path),path:Co(e.path),icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:xe.has(Co(e.path)),worktrees:xt(j[e.id],f.get(Co(e.path))??[])})),[xe,c,j,f]),Pe=Q.useMemo(()=>{let e=new Map(a.map(e=>[e.id,e])),t=o.map(t=>{let n=e.get(t.id);return n?Ae(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]),Le=P.trim().toLowerCase(),Re=Q.useMemo(()=>{let e=Ne.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===l})),t=(e,t,n)=>{let r=Co(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||To(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 Pe){let r=wo(n);if(!r)continue;let i=Co(r),a=e.find(e=>jo(e.project,i));if(!a)continue;let o=Ao(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)=>Te(t)-Te(e));for(let n of e.sessions)So(n)||(t.totalSessions+=1)}return e},[l,Ne,Pe]),He=Co(u),We=e=>e.isActive?He===e.project.path?e.project.path:e.project.worktrees.find(e=>ko(He,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=>{De(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},Ye=()=>{oe(null),be.current?.reset()},Xe=e=>({pressed:le===e.key||G?.key===e.key,onPointerDown:t=>{t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||be.current?.start({pointerId:t.pointerId,key:e.key,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>oe(e)})},onPointerMove:e=>{be.current?.move(e.pointerId,e.clientX,e.clientY)},onPointerUp:e=>{be.current?.end(e.pointerId)},onPointerCancel:e=>{be.current?.cancel(e.pointerId)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),be.current?.openFromContextMenu(e.key,()=>oe(e))}}),Ze=(e,t)=>{be.current?.consumeClick(e)||t()},Qe=(e,t,n,r)=>{let i=pr(),a=Xr();if(De(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=Co(t);if(!o)return;let s=Fe.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&ze(o)},$e=(e,t,n)=>{let i=`${e.project.id}::${t.key}`,a=pr(),o=new Set(t.sessions.map(e=>e.id)),c=new Map;for(let e of t.sessions){let t=So(e);if(t&&o.has(t)){let n=c.get(t)??[];n.push(e),c.set(t,n)}}let l=t.sessions.filter(e=>!So(e)),u=Ee.get(i)??a,f=vr(l,u,ke),p=l.length-f.length,m=s.get(Co(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=Oe.has(e.id),s=i&&!a?n.filter(e=>Oe.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)(zo,{session:e,active:d===e.id,indent:t,hasChildren:i,expanded:a,onToggleChildren:i?()=>N(e.id):void 0,confirmingArchive:z===e.id,onSelect:()=>Ze(p,()=>nt(e)),onRequestArchive:()=>rt(e.id),onConfirmArchive:()=>void it(e),onStop:o||l?()=>Me(u):void 0,stopAriaLabel:r(l?`mobile.sessions.stopSubsessionsAria`:`mobile.sessions.stopSessionAria`,{title:f}),longPressHandlers:Xe({key:p,kind:`session`,session:e})}),i&&a?n.map(e=>v(e,t+xo)):null]},e.id)};return(0,$.jsxs)(`div`,{children:[f.map(e=>v(e,n)),(0,$.jsx)(Bo,{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=>{Vt();let n=wo(e)||null,r=Mo(Ne,n??``);r&&S(r.id),p(e.id,n),t(!1)},rt=e=>{B(t=>t===e?null:e)},it=async e=>{B(null),await m(e.id)?Rr({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`)}):J.error(r(`sessions.sidebar.session.archive.error`))},at=()=>{b(),t(!1)},ot=e=>{ae(e),S(e),W(!0)},st=e=>{let t=new Map;for(let e of Pe){let n=So(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},ct=async e=>{let t=st(e.id),{archivedIds:n,failedIds:i}=await h(t);n.length>0&&Rr({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&&J.error(i.length===1?r(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):r(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}))},lt=e=>{let t=st(e.id);br({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){J.error(r(`sessions.sidebar.session.share.error`));return}J.success(r(`sessions.sidebar.session.share.successTitle`),{description:r(`sessions.sidebar.session.share.successDescription`)})}catch{J.error(r(`sessions.sidebar.session.share.error`))}},ft=async e=>{if((await te(e)).ok){J.success(r(`sessions.sidebar.session.menu.copied`));return}J.error(r(`sessions.sidebar.session.share.copyUrlError`))},pt=async e=>{try{if(await y(e)){J.success(r(`sessions.sidebar.session.unshare.success`));return}J.error(r(`sessions.sidebar.session.unshare.error`))}catch{J.error(r(`sessions.sidebar.session.unshare.error`))}},mt=async()=>{if(!ue)return;let e=pe.trim();if(e)try{await g(ue.id,e),fe(null),me(``)}catch{J.error(r(`sessions.sidebar.session.menu.rename`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},ht=async()=>{if(!ue||he)return;let e=ue.id;fe(null),me(``),ge(!0);try{await _(e)}catch{J.error(r(`sessions.sidebar.session.rename.smartTitle`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{ge(!1)}},gt=(e,n)=>{S(e.id),b({selectedProjectId:e.id,directoryOverride:n,preserveDirectoryOverride:!0}),t(!1)},_t=e=>{(async()=>{try{await qt({id:e.id,path:e.path})}catch(e){console.warn(`[MobileSessions] Worktree refresh before session sync failed:`,e)}let t=q.getState().availableWorktreesByProject.get(e.path)??e.worktrees,n=[e.path,...t.map(e=>e.path)];await Je(n,Pe)})()},vt=e=>{let t=wo(e),n=Mo(Ne,t);if(!n)return To(t)||t;let r=Ao(n,Co(t));return r?.branch?`${n.label} · ${r.branch}`:n.label},yt=e=>{x(e.id),t(!1)},bt=Q.useMemo(()=>Le?Re.filter(e=>`${e.project.label} ${e.project.path}`.toLowerCase().includes(Le)?!0:e.buckets.some(t=>t.sessions.some(t=>No(t,e.project.label,Le)))):Re,[Le,Re]),St=Q.useMemo(()=>Le?Pe.filter(e=>{let t=wo(e);return No(e,Mo(Ne,t)?.label??``,Le)}).sort((e,t)=>Te(t)-Te(e)):[],[Le,Ne,Pe]),Ct=Q.useMemo(()=>Le?Ne.filter(e=>`${e.label} ${e.path}`.toLowerCase().includes(Le)).map(e=>({...e,sessionCount:Pe.filter(t=>!So(t)&&jo(e,Co(wo(t)))).length})):[],[Le,Ne,Pe]),wt=Le&&St.length===0&&Ct.length===0,Tt=Ne.length>0?(0,$.jsxs)(Z,{type:`button`,variant:`default`,size:`sm`,"aria-label":r(`mobile.sessions.newChat`),onClick:at,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`add`,className:`size-4`}),r(`mobile.sessions.newChat`)]}):null,Dt=Ne.find(e=>e.id===l)??null,Ot=Dt?.isGitRepo?(0,$.jsx)(Z,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.project.actions.newWorktree`),title:r(`sessions.sidebar.project.actions.newWorktree`),onClick:()=>ot(Dt.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`node-tree`,className:`size-4`})}):null,kt=(0,$.jsx)(Z,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.header.actions.addProject`),title:r(`sessions.sidebar.header.actions.addProject`),onClick:()=>re(!0),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`folder-add`,className:`size-4`})}),At=Tt||kt?(0,$.jsxs)($.Fragment,{children:[Tt,Ot,kt]}):null,jt=G?.kind===`project`?G.project.label:G?.kind===`worktree`?G.worktree.branch||G.worktree.label||G.worktree.path:G?.kind===`session`?G.session.title?.trim()||r(`mobile.sessions.untitled`):``,Mt=Q.useMemo(()=>{if(!G)return[];if(G.kind===`project`){let e=G.project;return Qr({gitRepository:e.isGitRepo,onNewSession:()=>{Ye(),gt(e,e.path)},onNewWorktree:()=>{Ye(),ot(e.id)},onSyncSessions:()=>{Ye(),_t(e)},onEditProject:()=>{Ye(),L(e.id)},onCloseProject:()=>{Ye(),ce(e)}})}if(G.kind===`worktree`){let{project:e,worktree:t}=G;return Zr({onNewSession:()=>{Ye(),gt(e,t.path)},onDeleteWorktree:()=>{Ye(),ye({project:e,worktree:t})}})}let e=G.session,t=!!e.share?.url;return Ar({pinned:T.has(e.id),shared:t,onRename:()=>{Ye(),me(e.title?.trim()||r(`mobile.sessions.untitled`)),fe(e)},onTogglePin:()=>{Ye(),E(e.id)},onShare:t?void 0:()=>{Ye(),dt(e)},onCopyLink:t?()=>{let t=e.share?.url;Ye(),t&&ft(t)}:void 0,onUnshare:t?()=>{Ye(),pt(e.id)}:void 0,onArchive:()=>{Ye(),ct(e)},onDelete:()=>{Ye(),lt(e)}})},[G,Ye,ct,ft,lt,ot,dt,pt,T,gt,_t,r,E]),Nt=Mt.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:Mt.map(e=>{let t=(0,$.jsx)(Ro,{icon:e.icon,label:xr(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,Pt=(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(Yt,{value:P,onChange:e=>F(e.target.value),placeholder:r(`mobile.sessions.search.placeholder`),className:Y(`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)(X,{name:`close`,className:`size-4`})}):null]})}),(0,$.jsx)(Fn,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto pb-4`,children:Ne.length===0?(0,$.jsx)(Ho,{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:()=>re(!0),children:[(0,$.jsx)(X,{name:`folder-add`,className:`size-4`}),r(`sessions.sidebar.header.actions.addProject`)]})}):wt?(0,$.jsx)(Ho,{title:r(`mobile.sessions.empty.searchTitle`),description:r(`mobile.sessions.empty.searchDescription`)}):Le?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-3 pt-2`,children:[St.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:St.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:St.map((e,t)=>{let n=Oe.has(e.id),i=e.title?.trim()||r(`mobile.sessions.untitled`);return(0,$.jsx)(`div`,{className:Y(t>0&&`border-t border-border/30`),children:(0,$.jsx)(zo,{session:e,active:d===e.id,indent:12,contextLabel:vt(e),highlightQuery:Le,onSelect:()=>Ze(`session:${e.id}`,()=>nt(e)),longPressHandlers:Xe({key:`session:${e.id}`,kind:`session`,session:e}),onStop:n?()=>je(e.id):void 0,stopAriaLabel:r(`mobile.sessions.stopSessionAria`,{title:i})})},e.id)})})]}):null,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.projects`)}),(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=`project:${e.id}`,r=Xe({key:n,kind:`project`,project:e});return(0,$.jsxs)(`div`,{className:Y(`flex items-center`,t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`button`,{type:`button`,className:Y(`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:()=>Ze(n,()=>yt(e)),onPointerDown:r.onPointerDown,onPointerMove:r.onPointerMove,onPointerUp:r.onPointerUp,onPointerCancel:r.onPointerCancel,onContextMenu:r.onContextMenu,style:{touchAction:`manipulation`},children:[(0,$.jsx)(Po,{project:e}),(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:an(e.label,Le)}),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.sessionCount})]}),e.isGitRepo?(0,$.jsx)(Lo,{className:`mr-2`,onClick:()=>ot(e.id)}):null]},e.id)})})]}):null]}):(0,$.jsx)(`div`,{className:`flex flex-col`,children:bt.map((e,t)=>{let n=Ge(e),i=`project:${e.project.id}`,a=Xe({key:i,kind:`project`,project:e.project}),o=Le?e.buckets.filter(t=>t.sessions.some(t=>No(t,e.project.label,Le))):e.buckets,s=We(e);return(0,$.jsxs)(`section`,{className:Y(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:Y(`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:()=>Ze(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)(Po,{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}),Ce.get(e.project.id)?(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 typography-micro text-muted-foreground`,children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:Ce.get(e.project.id)})]}):null]}),e.isActive?(0,$.jsx)(Io,{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=>Oe.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(),Me(t)},style:{touchAction:`manipulation`},children:(0,$.jsx)(fr,{})}):null})(),e.project.isGitRepo?(0,$.jsx)(Lo,{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,bo):null,n.map(t=>{let n=Ke(e,t),i=s===t.path,a=`worktree:${e.project.id}:${t.key}`,o=Xe({key:a,kind:`worktree`,project:e.project,worktree:t.worktree});return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,className:Y(`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:()=>Ze(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)(Fo,{expanded:n}),(0,$.jsx)(X,{name:`node-tree`,className:Y(`size-4 shrink-0`,i?`text-primary`:`text-muted-foreground`)}),(0,$.jsx)(`span`,{className:Y(`block min-w-0 flex-1 truncate typography-ui-label font-semibold`,i?`text-foreground`:`text-foreground/90`),children:t.label}),i?(0,$.jsx)(Io,{ariaLabel:r(`mobile.sessions.activeWorktreeAria`)}):null,(()=>{let e=n?[]:t.sessions.filter(e=>Oe.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(),Me(e)},style:{touchAction:`manipulation`},children:(0,$.jsx)(fr,{})}):null})(),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:t.sessions.length})]}),n?$e(e,t,bo):null]},t.key)})]})})()}):null]},e.project.id)})})}),(0,$.jsx)(Ur,{open:H,onOpenChange:re,forceMobile:!0}),(0,$.jsx)(ut,{open:U,projectId:ie,onOpenChange:e=>{W(e),e||ae(null)},onWorktreeCreated:(e,n)=>{n?.sessionId?p(n.sessionId,e):b({selectedProjectId:ie,directoryOverride:e,preserveDirectoryOverride:!0}),t(!1)}}),(0,$.jsx)(un,{open:!!G,title:jt,onClose:Ye,contentMaxHeightClassName:`max-h-[min(68dvh,560px)]`,children:Nt}),(0,$.jsx)(un,{open:!!se,title:r(`sessions.sidebar.project.actions.closeProject`),onClose:()=>ce(null),closeAriaLabel:r(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Z,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>ce(null),children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Z,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!se)return;let e=se;ce(null),w(e.id),J.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:se?.label??``})})}),(0,$.jsx)(un,{open:!!ue,title:r(`sessions.sidebar.session.menu.rename`),onClose:()=>{he||(fe(null),me(``))},footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Z,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:he,onClick:()=>{fe(null),me(``)},children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Z,{type:`button`,variant:`default`,className:`flex-1`,disabled:!pe.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)(Yt,{value:pe,onChange:e=>me(e.target.value),autoFocus:!0,className:`h-12`,disabled:he}),(0,$.jsxs)(Z,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:he,onClick:()=>void ht(),children:[he?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`ai-generate-2`,className:`size-4`}),r(`sessions.sidebar.session.rename.smartTitle`)]})]})}),_e?(0,$.jsx)(mr,{open:!0,project:{id:_e.project.id,path:_e.project.path},worktree:_e.worktree,onClose:()=>ye(null),onDeleted:()=>ne(e=>e+1)}):null,(0,$.jsx)(hr,{open:I!==null,project:Ne.find(e=>e.id===I)??null,onClose:()=>L(null),onWorktreesChanged:()=>ne(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:At?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:At}):null}),Pt]}):null:(0,$.jsx)(Gt,{id:`mobile-sessions-sheet`,open:e,onOpenChange:t,trailing:At,ariaLabel:r(`mobile.sessions.sheet.title`),closeAriaLabel:r(`mobile.surface.closeAria`),resizeAriaLabel:r(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:Pt})},Ho=e=>{let t=(0,zi.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},Uo=`/assets/assistant-guide-hero-wide-DiFIThB0.jpg`,Wo=[{image:ai,titleKey:`assistants.guide.share.ios.title`,descriptionKey:`assistants.guide.share.ios.description`},{image:ei,titleKey:`assistants.guide.share.android.title`,descriptionKey:`assistants.guide.share.android.description`},{image:ri,titleKey:`assistants.guide.share.pick.title`,descriptionKey:`assistants.guide.share.pick.description`}];function Go(){let e=(0,zi.c)(8),{t}=ee(),n;e[0]===t?n=e[1]:(n=t(`common.loading`),e[0]=t,e[1]=n);let r,i,a,o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`div`,{className:`h-10 w-10 animate-pulse rounded-xl bg-[var(--surface-muted)] motion-reduce:animate-none`}),i=(0,$.jsx)(`div`,{className:`mt-2 h-4 w-2/3 animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),a=(0,$.jsx)(`div`,{className:`h-3.5 w-full animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),o=(0,$.jsx)(`div`,{className:`h-3.5 w-4/5 animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),e[2]=r,e[3]=i,e[4]=a,e[5]=o):(r=e[2],i=e[3],a=e[4],o=e[5]);let s;return e[6]===n?s=e[7]:(s=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3 p-5`,"aria-busy":`true`,"aria-label":n,children:[r,i,a,o]}),e[6]=n,e[7]=s),s}function Ko(e){let t=(0,zi.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:Uo,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)(Z,{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=Wo.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 qo({unreadCount:e,assistantID:t,displayName:n,avatarEmoji:r,summary:i,enabled:a,editLabel:o,deleteLabel:s,onOpen:c,onEdit:l,onDelete:u,serverWorking:d=!1}){let f=di(t,d),[p,m]=Q.useState(!1),[h,g]=Q.useState(!1),_=Q.useRef(null);_.current||=Hn({onPressedKeyChange:e=>g(e===t)}),Q.useEffect(()=>()=>_.current?.reset(),[]);let v=R(()=>{_.current?.consumeClick(t)||p||c()}),y=R(()=>{m(!1),l()}),b=R(()=>{m(!1),u()}),x=R(()=>{g(!1),m(!0)}),S=R(e=>{e.pointerType!==`touch`&&e.pointerType!==`pen`||e.button!==0||_.current?.start({pointerId:e.pointerId,key:t,clientX:e.clientX,clientY:e.clientY,onTrigger:x})}),C=R(e=>{_.current?.move(e.pointerId,e.clientX,e.clientY)}),w=R(e=>{_.current?.end(e.pointerId)}),T=R(e=>{_.current?.cancel(e.pointerId)}),E=R(e=>{e.preventDefault(),e.stopPropagation(),_.current?.openFromContextMenu(t,x)});return(0,$.jsxs)(xi,{open:p,onOpenChange:m,children:[(0,$.jsx)(nr,{"data-mobile-press-surface":`soft`,className:Y(`oc-mobile-assistant-card-shell`,h&&`bg-interactive-hover`),children:(0,$.jsxs)(_i,{render:(0,$.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":`false`,"data-mobile-press-surface-trigger":!0,className:Y(`oc-mobile-assistant-card`,!a&&`opacity-65`),onClick:v,onPointerDown:S,onPointerMove:C,onPointerUp:w,onPointerCancel:T,onContextMenu:E,style:{touchAction:`pan-y`}}),children:[(0,$.jsx)(`span`,{className:Y(`oc-mobile-assistant-avatar`,r?`oc-mobile-assistant-avatar--emoji`:`oc-mobile-assistant-avatar--visual`),children:(0,$.jsx)(pi,{name:t,emoji:r,size:40,label:n,working:f})}),(0,$.jsxs)(`span`,{className:`oc-mobile-assistant-card-content min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`oc-mobile-entity-title oc-mobile-assistant-name block min-w-0 truncate font-semibold text-foreground`,children:n}),(0,$.jsx)(`span`,{className:Y(`oc-mobile-assistant-summary`,fi),children:i})]}),(0,$.jsx)(hi,{count:e})]})}),(0,$.jsxs)(yi,{className:`min-w-[10rem]`,children:[(0,$.jsxs)(bi,{className:`min-h-10 px-3`,onClick:y,children:[(0,$.jsx)(X,{name:`edit`,className:`size-4`}),o]}),(0,$.jsx)(vi,{}),(0,$.jsxs)(bi,{className:`min-h-10 px-3 text-[var(--status-error)] focus:text-[var(--status-error)] data-[highlighted]:text-[var(--status-error)] [&_svg]:text-[var(--status-error)]`,onClick:b,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`}),s]})]})]})}function Jo(e){let t=(0,zi.c)(118),{onEnable:n,onOpenAssistant:r,className:i}=e,{t:a}=ee(),o=Un(),s=ce(),c=K();c.data?.assistants;let l;t[0]===c.data?.assistants?l=t[1]:(l=c.data?.assistants??[],t[0]=c.data?.assistants,t[1]=l);let u;t[2]===l?u=t[3]:(u=ui(l),t[2]=l,t[3]=u);let d=u,f=Qe(Yo),[p,m]=Q.useState(null),h;t[4]===n?h=t[5]:(h=()=>n(),t[4]=n,t[5]=h);let g=R(h),_;t[6]!==o||t[7]!==f?(_=()=>{f(),o?.openSettings(`assistants`)},t[6]=o,t[7]=f,t[8]=_):_=t[8];let v=R(_),y;t[9]===r?y=t[10]:(y=e=>r(e),t[9]=r,t[10]=y);let b=R(y),x;t[11]===o?x=t[12]:(x=e=>{et(e,o?{openMobileSettings:o.openSettings}:void 0)},t[11]=o,t[12]=x);let S=R(x),C;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{m(e)},t[13]=C):C=t[13];let w=R(C),T;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>{e||m(null)},t[14]=T):T=t[14];let E=R(T),D;t[15]===a?D=t[16]:(D=a(`assistants.title`),t[15]=a,t[16]=D);let O=D,k;t[17]===a?k=t[18]:(k=a(`assistants.menu.edit`),t[17]=a,t[18]=k);let A=k,j;t[19]===a?j=t[20]:(j=a(`assistants.settings.delete`),t[19]=a,t[20]=j);let M=j;if(s.isPending||s.data?.supported&&s.data.enabled&&c.isPending){let e;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(nr,{className:`oc-mobile-assistant-loading`,children:(0,$.jsx)(Go,{})}),t[21]=e):e=t[21];let n;return t[22]!==i||t[23]!==O?(n=(0,$.jsx)(tr,{title:O,className:i,surface:!1,children:e}),t[22]=i,t[23]=O,t[24]=n):n=t[24],n}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length>0){let e;t[25]===a?e=t[26]:(e=a(`assistants.settings.create`),t[25]=a,t[26]=e);let n;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(X,{name:`add`,className:`size-5`}),t[27]=n):n=t[27];let r;t[28]!==v||t[29]!==e?(r=(0,$.jsx)(Z,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":e,onClick:v,children:n}),t[28]=v,t[29]=e,t[30]=r):r=t[30];let o;t[31]===c.data?o=t[32]:(o=(0,$.jsx)(`div`,{className:`flex justify-end pb-2`,children:(0,$.jsx)(ci,{snapshot:c.data})}),t[31]=c.data,t[32]=o);let s;t[33]===a?s=t[34]:(s=a(`assistants.listAria`),t[33]=a,t[34]=s);let l;if(t[35]!==d||t[36]!==M||t[37]!==A||t[38]!==S||t[39]!==b||t[40]!==w||t[41]!==a){let e;t[43]!==M||t[44]!==A||t[45]!==S||t[46]!==b||t[47]!==w||t[48]!==a?(e=e=>{let t=ne(e.name),n=t.displayName||e.name,r=li(e.latestMessagePreview,a);return(0,$.jsx)(qo,{assistantID:e.id,unreadCount:e.unreadCount??0,displayName:n,avatarEmoji:t.avatarEmoji??void 0,summary:r,enabled:e.enabled,editLabel:A,deleteLabel:M,assignedSessionIDs:e.assignedSessionIDs,serverWorking:e.working,onOpen:()=>b(e.id),onEdit:()=>S(e.id),onDelete:()=>w(e)},e.id)},t[43]=M,t[44]=A,t[45]=S,t[46]=b,t[47]=w,t[48]=a,t[49]=e):e=t[49],l=d.map(e),t[35]=d,t[36]=M,t[37]=A,t[38]=S,t[39]=b,t[40]=w,t[41]=a,t[42]=l}else l=t[42];let u;t[50]!==s||t[51]!==l?(u=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-catalog`,role:`listbox`,"aria-label":s,children:l}),t[50]=s,t[51]=l,t[52]=u):u=t[52];let f=p!==null,m;t[53]!==p||t[54]!==E||t[55]!==f?(m=(0,$.jsx)(si,{assistant:p,open:f,onOpenChange:E}),t[53]=p,t[54]=E,t[55]=f,t[56]=m):m=t[56];let h;return t[57]!==i||t[58]!==O||t[59]!==r||t[60]!==o||t[61]!==u||t[62]!==m?(h=(0,$.jsxs)(tr,{title:O,className:i,surface:!1,scrollsWithPage:!0,trailing:r,children:[o,u,m]}),t[57]=i,t[58]=O,t[59]=r,t[60]=o,t[61]=u,t[62]=m,t[63]=h):h=t[63],h}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length===0){let e;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`oc-mobile-assistant-onboarding-icon`,children:(0,$.jsx)(X,{name:`ai-agent`,className:`size-5`})}),t[64]=e):e=t[64];let n;t[65]===a?n=t[66]:(n=a(`assistants.onboarding.title`),t[65]=a,t[66]=n);let r;t[67]===n?r=t[68]:(r=(0,$.jsx)(`h2`,{children:n}),t[67]=n,t[68]=r);let o;t[69]===a?o=t[70]:(o=a(`assistants.onboarding.description`),t[69]=a,t[70]=o);let s;t[71]===o?s=t[72]:(s=(0,$.jsx)(`p`,{children:o}),t[71]=o,t[72]=s);let c;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(X,{name:`add`,className:`size-[18px]`}),t[73]=c):c=t[73];let l;t[74]===a?l=t[75]:(l=a(`assistants.onboarding.action`),t[74]=a,t[75]=l);let u;t[76]!==v||t[77]!==l?(u=(0,$.jsxs)(Z,{type:`button`,size:`lg`,className:`mt-6 w-full`,onClick:v,children:[c,l]}),t[76]=v,t[77]=l,t[78]=u):u=t[78];let d;t[79]!==r||t[80]!==s||t[81]!==u?(d=(0,$.jsxs)(nr,{className:`oc-mobile-assistant-onboarding`,children:[e,r,s,u]}),t[79]=r,t[80]=s,t[81]=u,t[82]=d):d=t[82];let f;return t[83]!==i||t[84]!==O||t[85]!==d?(f=(0,$.jsx)(tr,{title:O,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:d}),t[83]=i,t[84]=O,t[85]=d,t[86]=f):f=t[86],f}let N=s.isSuccess&&s.data.supported===!1,P=s.isError||s.data?.supported===!0&&s.data.enabled&&c.isError,F=s.data?.supported===!0&&(s.data.enabled===!1||c.data?.enabled===!1),I;t[87]!==a||t[88]!==P||t[89]!==N?(I=a(P?`assistants.state.unavailable`:N?`assistants.state.unsupportedTitle`:`assistants.state.instanceDisabled`),t[87]=a,t[88]=P,t[89]=N,t[90]=I):I=t[90];let L=I;if(F&&!P){let e;t[91]===g?e=t[92]:(e=(0,$.jsx)(Ko,{onEnable:g}),t[91]=g,t[92]=e);let n;return t[93]!==i||t[94]!==O||t[95]!==e?(n=(0,$.jsx)(tr,{title:O,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-guide-host`,children:e}),t[93]=i,t[94]=O,t[95]=e,t[96]=n):n=t[96],n}let z;t[97]===O?z=t[98]:(z=(0,$.jsx)(`span`,{className:`oc-mobile-page-section-label`,children:O}),t[97]=O,t[98]=z);let te=N?`cloud-off`:`sparkling`,B;t[99]===te?B=t[100]:(B=(0,$.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground`,children:(0,$.jsx)(X,{name:te,weight:`medium`,className:`size-5`})}),t[99]=te,t[100]=B);let V;t[101]===L?V=t[102]:(V=(0,$.jsx)(`h2`,{className:`mt-5 max-w-xs text-lg font-semibold leading-snug tracking-[-0.02em] text-foreground`,children:L}),t[101]=L,t[102]=V);let H;t[103]!==a||t[104]!==P||t[105]!==N?(H=P?null:(0,$.jsx)(`p`,{className:`mt-2 max-w-sm typography-small leading-relaxed text-muted-foreground`,children:a(N?`assistants.state.unsupportedDescription`:`assistants.state.instanceDisabledDescription`)}),t[103]=a,t[104]=P,t[105]=N,t[106]=H):H=t[106];let re;t[107]!==B||t[108]!==V||t[109]!==H?(re=(0,$.jsxs)(`section`,{className:`w-full max-w-md py-2`,children:[B,V,H]}),t[107]=B,t[108]=V,t[109]=H,t[110]=re):re=t[110];let U;t[111]!==z||t[112]!==re?(U=(0,$.jsx)(or,{label:z,cardClassName:`oc-mobile-assistant-state-card`,children:re}),t[111]=z,t[112]=re,t[113]=U):U=t[113];let W;return t[114]!==i||t[115]!==O||t[116]!==U?(W=(0,$.jsx)(tr,{title:O,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:U}),t[114]=i,t[115]=O,t[116]=U,t[117]=W):W=t[117],W}function Yo(e){return e.requestCreate}var Xo=[{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 Zo(e){let t=(0,zi.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=R(o),c;t[2]!==n||t[3]!==r?(c=e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=Xo.findIndex(e=>e.id===n),i=Xo[e.key===`Home`?0:e.key===`End`?Xo.length-1:(t+(e.key===`ArrowRight`?1:-1)+Xo.length)%Xo.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=R(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=Xo.map(e=>{let t=e.id===n,r=a(e.labelKey);return(0,$.jsxs)(Z,{id:`mobile-tab-${e.id}`,"data-tab":e.id,type:`button`,role:`tab`,variant:`ghost`,size:`sm`,"aria-controls":`mobile-tabpanel-${e.id}`,"aria-label":r,"aria-describedby":e.id===`assistant`?`mobile-tab-assistant-unread`:void 0,"aria-selected":t,tabIndex:t?0:-1,title:r,onClick:s,onKeyDown:l,className:Y(`oc-mobile-tab-button min-w-0 flex-1 flex-col overflow-visible`,`text-xs font-medium leading-none tracking-tight text-muted-foreground`,`transition-[background-color,color,box-shadow,transform] duration-100`,`hover:bg-transparent hover:text-foreground`,`active:bg-interactive-active`,`motion-reduce:transition-none`,t&&[`bg-interactive-selection/55 text-primary`,`hover:bg-interactive-selection/55 hover:text-primary`,`font-semibold`]),children:[(0,$.jsxs)(`span`,{className:`relative inline-flex shrink-0 overflow-visible`,children:[(0,$.jsx)(X,{name:e.icon,weight:`medium`,className:`size-[23px] shrink-0`}),e.id===`assistant`?(0,$.jsx)(`span`,{id:`mobile-tab-assistant-unread`,className:`pointer-events-none absolute left-full -top-1 ml-0.5 inline-flex z-10`,children:(0,$.jsx)(gi,{className:`h-[18px] min-w-[18px] bg-foreground px-1 text-[11px] font-bold tracking-normal text-background shadow-none ring-2 ring-background`})}):null]}),(0,$.jsx)(`span`,{className:`oc-mobile-tab-label block max-w-full overflow-hidden text-ellipsis whitespace-nowrap`,children:r})]},e.id)}),t[8]=n,t[9]=s,t[10]=l,t[11]=a,t[12]=f):f=t[12];let p;return t[13]!==i||t[14]!==u||t[15]!==f?(p=(0,$.jsx)(sr,{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 Qo=`oc-native-ios-tab-bar`,$o=`OpenChamberTabBar`,es=[`projects`,`assistant`,`scheduled`,`settings`],ts=A($o),ns=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.nativeUiEnabled!==!1;function rs(){return typeof window>`u`?!1:ns({isCapacitor:T(),platform:D(),pluginAvailable:j.isPluginAvailable($o),nativeUiEnabled:Dn()})}var is=e=>e.classList.contains(`dark`)?`dark`:`light`,as=()=>Sn(`--primary`),os=e=>typeof e==`string`&&es.includes(e),ss=e=>typeof e==`string`&&os(e)?e:null,cs=(e,t)=>e.selectedTab===t.selectedTab&&e.appearance===t.appearance&&e.ariaLabel===t.ariaLabel&&e.accentColor===t.accentColor&&e.tabs.length===t.tabs.length&&e.tabs.every((e,n)=>e.id===t.tabs[n]?.id&&e.label===t.tabs[n]?.label&&e.badge===t.tabs[n]?.badge),ls=(e,t)=>{e.classList.toggle(Qo,t)},us=(e,t)=>e&&!t,ds=e=>e.visible?e.overlayHidden?{action:`present`}:e.lastState&&cs(e.lastState,e.nextState)?{action:`skip`}:{action:`present`}:e.overlayHidden?{action:`skip`}:{action:`hide`},fs=()=>ts,ps=`mobile-overlay-root`;function ms(e){let t=(0,zi.c)(28),n=Cn(),r;t[0]===n?r=t[1]:(r=n&&rs(),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=R(e.onTabChange),h;t[2]===e.tabs?h=t[3]:(h=JSON.stringify(e.tabs.map(gs)),t[2]=e.tabs,t[3]=h);let g=h,_;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=typeof document>`u`?`dark`:is(document.documentElement),t[4]=_):_=t[4];let v=_,y;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=typeof document>`u`?``:as(),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(ps);e||(e=document.createElement(`div`),e.id=ps,document.body.appendChild(e));let t=()=>u(lt(e.children));t();let n=new MutationObserver(t);return n.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[Ct]}),()=>n.disconnect()},S=[i],t[6]=i,t[7]=x,t[8]=S),(0,Q.useEffect)(x,S);let C;t[9]!==i||t[10]!==m?(C=()=>{if(!i)return;let e=!1,t=fs(),n=[];return t.addListener(`tabSelected`,e=>{let t=ss(e.tab);t&&m(t)}).then(t=>{if(e){t.remove();return}n.push(t)}),()=>{e=!0,d.current=null,t.hide();for(let e of n)e.remove();typeof document<`u`&&ls(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=fs(),r={tabs:e.tabs.map(hs),selectedTab:e.activeTab,appearance:v,accentColor:b,ariaLabel:e.ariaLabel},a=ds({visible:us(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`&&ls(document.documentElement,!1);return}f.current=!1,d.current=r,o(!0),typeof document<`u`&&ls(document.documentElement,!0)}})().catch(()=>{t||(p.current=!0,c(!0),o(!1),typeof document<`u`&&ls(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 hs(e){return{id:e.id,label:e.label,badge:e.badge??null}}function gs(e){return[e.id,e.label,e.badge??null]}function _s(e){let t=(0,zi.c)(40),{tabs:n,navigation:r,onTabChange:i,secondaryPages:a,showTabBar:o,tabBarCovered:s,className:c}=e,l=a===void 0?[]:a,u=o===void 0||o,d=s!==void 0&&s,{t:f}=ee(),p=r.activeTab,m=l.slice(-2),h=m.at(-1)??null,g=h?.key??null,_=h?.depth,v=m.length>1?m[m.length-2].key:null,y;t[0]===p?y=t[1]:(y=()=>new Set([p]),t[0]=p,t[1]=y);let[b,x]=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=R(()=>h?.onBack());En({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=R(j),N=se(),P;t[6]!==N||t[7]!==f?(P=Xo.map(e=>({id:e.id,label:f(e.labelKey),badge:e.id===`assistant`&&N>0?N>99?`99+`:String(N):null})),t[6]=N,t[7]=f,t[8]=P):P=t[8];let F=P,I=u&&!d&&!h,L;t[9]===f?L=t[10]:(L=f(`mobile.nav.aria`),t[9]=f,t[10]=L);let z;t[11]!==M||t[12]!==I||t[13]!==F||t[14]!==p||t[15]!==L?(z={visible:I,activeTab:p,tabs:F,ariaLabel:L,onTabChange:M},t[11]=M,t[12]=I,t[13]=F,t[14]=p,t[15]=L,t[16]=z):z=t[16];let te=ms(z),B=te===`native`,V=u&&te===`web`,ne=Cn(),H,re;t[17]!==ne||t[18]!==B?(H=()=>{if(!ne){An.shutdown();return}B&&On(!0)&&An.warm()},re=[ne,B],t[17]=ne,t[18]=B,t[19]=H,t[20]=re):(H=t[19],re=t[20]),Q.useEffect(H,re);let U;t[21]===c?U=t[22]:(U=Y(`oc-mobile-floating-shell relative isolate flex h-full min-h-0 flex-col overflow-hidden text-foreground`,`bg-[var(--oc-mobile-page-background)]`,c),t[21]=c,t[22]=U);let W=h?!0:void 0,ie=h?!0:void 0,ae;t[23]!==p||t[24]!==u||t[25]!==V||t[26]!==f||t[27]!==n||t[28]!==b?(ae=Xo.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:Y(`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)(vs,{tab:e.id,icon:e.icon}):null},e.id)}),t[23]=p,t[24]=u,t[25]=V,t[26]=f,t[27]=n,t[28]=b,t[29]=ae):ae=t[29];let G;t[30]!==w||t[31]!==W||t[32]!==ie||t[33]!==ae?(G=(0,$.jsx)(`div`,{ref:w,"data-mobile-navigation-underlay":`true`,"aria-hidden":W,inert:ie,className:`flex h-full min-h-0 flex-1 flex-col`,children:ae}),t[30]=w,t[31]=W,t[32]=ie,t[33]=ae,t[34]=G):G=t[34];let oe=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)(Zo,{activeTab:p,onTabChange:M}):null}):null,ce=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:Y(`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)}),le;return t[35]!==U||t[36]!==G||t[37]!==oe||t[38]!==ce?(le=(0,$.jsxs)(`div`,{className:U,children:[G,oe,ce]}),t[35]=U,t[36]=G,t[37]=oe,t[38]=ce,t[39]=le):le=t[39],le}function vs(e){let t=(0,zi.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=Xo.find(e=>e.id===n)??Xo[0];t[8]===i?c=t[9]:(c=Y(`flex min-h-[70dvh] flex-col items-center justify-center gap-3 text-center`,i),t[8]=i,t[9]=c),l=(0,$.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-2xl bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(X,{name:r??e.icon,className:`size-6`})}),o=`typography-ui-label font-semibold tracking-[-0.01em] text-foreground`,s=a(e.labelKey),t[0]=i,t[1]=r,t[2]=a,t[3]=n,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else o=t[4],s=t[5],c=t[6],l=t[7];let u;t[10]!==o||t[11]!==s?(u=(0,$.jsx)(`h1`,{className:o,children:s}),t[10]=o,t[11]=s,t[12]=u):u=t[12];let d;return t[13]!==c||t[14]!==l||t[15]!==u?(d=(0,$.jsxs)(`div`,{className:c,children:[l,u]}),t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}var ys={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)`}},bs=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 xs({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||=Hn({onPressedKeyChange:t=>l(t===e.id)}),Q.useEffect(()=>()=>u.current?.reset(),[]);let d=R(()=>{u.current?.consumeClick(e.id)||r(e)}),f=R(()=>i?.(e)),p=R(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=R(e=>{u.current?.move(e.pointerId,e.clientX,e.clientY)}),h=R(e=>{u.current?.end(e.pointerId)}),g=R(e=>{u.current?.cancel(e.pointerId)}),_=R(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=bs(e.path),b=(0,$.jsxs)(`article`,{"data-mobile-press-surface":`soft`,"data-pressed":c?`true`:void 0,className:Y(`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:Y(`oc-mobile-project-icon oc-mobile-glass-control flex shrink-0 items-center justify-center rounded-full text-muted-foreground`),style:ys[e.tone??`neutral`],"aria-hidden":!0,children:(0,$.jsx)(X,{name:e.icon??`code-box`,className:`oc-mobile-project-icon-glyph`})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`oc-mobile-project-title oc-mobile-entity-title truncate font-semibold text-foreground`,children:o?an(e.name,o):e.name}),e.active?(0,$.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-[var(--status-success)] shadow-[0_0_0_3px_color-mix(in_srgb,var(--status-success)_12%,transparent)]`,"aria-label":s(`mobile.sessions.activeProjectAria`)}):null]}),(0,$.jsxs)(`span`,{className:`oc-mobile-project-meta oc-mobile-entity-meta flex min-w-0 items-center text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:v}),e.activityLabel?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`·`}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:e.activityLabel})]}):null,y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`·`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,title:e.path,children:y})]}):null]})]}),(0,$.jsx)(X,{name:`arrow-down-s`,className:Y(`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)(Z,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-mobile-project-action self-center rounded-full text-muted-foreground`,"aria-label":s(`sessions.sidebar.project.actions.projectMenu`),onClick:f,children:(0,$.jsx)(X,{name:`more-2`,className:`size-4`})}):null]});return n?b:(0,$.jsx)(nr,{asChild:!0,children:b})}var Ss=({hasPendingQuestion:e,hasPendingPermission:t,running:n,unread:r})=>e?`question`:t?`permission`:n?`running`:r?`completed-unread`:`idle`,Cs=10,ws=`oc:mobile-session-row-revealed`,Ts=e=>{window.dispatchEvent(new CustomEvent(ws,{detail:e}))};function Es({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||=Hn(),Q.useEffect(()=>()=>x.current?.reset(),[]),Q.useEffect(()=>{let t=t=>{t.detail!==e.id&&h(0)};return window.addEventListener(ws,t),()=>window.removeEventListener(ws,t)},[e.id]),Q.useEffect(()=>{h(0)},[e.id]);let S=R(()=>h(0)),C=m!==0,w=R(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=R(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>Cs&&o>a){n.intent=`vertical`,v.current=null,x.current?.cancel(t.pointerId);return}if(a>Cs&&a>o){n.intent=`horizontal`,_(!0),y.current=!0,x.current?.cancel(t.pointerId);try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}Ts(e.id)}}if(n.intent!==`horizontal`)return;t.preventDefault();let a=Math.max(-n.actionWidth,Math.min(0,n.startOffset+r));h(a)}),E=R(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=R(e=>{let t=v.current;v.current=null,x.current?.cancel(e.pointerId),_(!1),h(t?.startOffset??0)}),O=R(()=>{if(!x.current?.consumeClick(e.id)){if(y.current){y.current=!1;return}if(m!==0){S();return}Ts(e.id),o(e)}}),k=R(t=>{t.preventDefault(),t.stopPropagation(),x.current?.openFromContextMenu(e.id,()=>{l(e)})}),A=R(()=>{S(),s(e)}),j=R(()=>{S(),c(e)}),M=R(()=>l(e)),N=R(()=>a?.()),P=e.pinned?p(`sessions.sidebar.session.menu.unpin`):p(`sessions.sidebar.session.menu.pin`),F=u??Ss({hasPendingQuestion:!1,hasPendingPermission:!1,running:!1,unread:!!e.unread}),I=F===`question`?p(`sessions.sidebar.session.status.questionRequired`):F===`permission`?p(`sessions.sidebar.session.status.permissionRequired`):F===`running`?p(`sessions.sidebar.session.status.active`):F===`completed-unread`?p(`sessions.sidebar.session.status.unread`):void 0;return e.kind===`pagination`?(0,$.jsx)(`div`,{className:Y(`oc-mobile-session-row`,i&&`oc-mobile-session-pagination-continues`,d),children:(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-session-pagination-row`,style:{touchAction:`pan-y`},onClick:O,onPointerDown:()=>void 0,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left font-medium text-foreground typography-meta`,children:e.title}),e.subtitle?(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.subtitle}):null,(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground`})]})}):(0,$.jsxs)(`div`,{className:Y(`oc-mobile-session-row relative isolate`,d),children:[(0,$.jsxs)(`div`,{ref:b,className:Y(`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)(Z,{type:`button`,variant:`secondary`,className:`oc-mobile-session-action h-full flex-col rounded-none border-0 bg-interactive-selection px-1 text-interactive-selection-foreground hover:bg-interactive-active`,"aria-label":P,tabIndex:C?0:-1,onClick:A,children:[(0,$.jsx)(X,{name:e.pinned?`unpin`:`pushpin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:P})]}),(0,$.jsxs)(Z,{type:`button`,variant:`destructive`,className:`oc-mobile-session-action h-full flex-col rounded-none border-0 px-1`,"aria-label":p(`sessions.sidebar.bulkActions.archive`),tabIndex:C?0:-1,onClick:j,children:[(0,$.jsx)(X,{name:`archive`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:p(`sessions.sidebar.bulkActions.archive`)})]})]}),(0,$.jsxs)(`div`,{className:Y(`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)(Z,{type:`button`,variant:`ghost`,size:`icon`,className:`min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":p(r?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:N,children:(0,$.jsx)(X,{name:`arrow-down-s`,className:Y(`size-3.5 transition-transform duration-150 motion-reduce:transition-none`,r?`rotate-0`:`-rotate-90`)})}):null,(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-session-row-main flex min-w-0 flex-1 items-center text-left outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,style:{paddingLeft:16+Math.min(t,4)*12,touchAction:`pan-y`},onClick:O,onPointerDown:w,onPointerMove:T,onPointerUp:E,onPointerCancel:D,onContextMenu:k,children:[(0,$.jsx)(`span`,{className:`oc-mobile-session-status shrink-0`,"data-session-status":F,"aria-hidden":!I||void 0,"aria-label":I,title:I,children:F===`running`?(0,$.jsx)(fr,{className:`motion-reduce:[&_svg]:animate-none`}):F===`question`?(0,$.jsx)(X,{name:`question`,className:`size-3.5 text-[var(--status-warning)]`}):F===`permission`?(0,$.jsx)(X,{name:`shield`,className:`size-3.5 text-destructive`}):(0,$.jsx)(`span`,{className:Y(`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:Y(`oc-mobile-session-title truncate`,e.unread?`font-semibold`:`font-medium`),children:f?an(e.title,f):e.title}),e.changes?(0,$.jsx)(`span`,{className:`oc-mobile-session-changes shrink-0 tabular-nums text-muted-foreground`,children:e.changes}):null,e.archived?(0,$.jsx)(X,{name:`archive`,className:`size-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}):null]}),e.subtitle?(0,$.jsx)(`span`,{className:`oc-mobile-session-subtitle truncate text-muted-foreground`,children:f?an(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)(Z,{type:`button`,variant:`ghost`,size:`icon`,className:`mr-1 min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":p(`sessions.sidebar.session.menu.label`),onClick:M,children:(0,$.jsx)(X,{name:`more-2`,className:`size-3.5`})})]})]})}var Ds=Q.memo(Es),Os=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e)),ks=e=>e.catalogSessions??e.sessions,As=(e,t)=>e.filter(e=>e.kind!==`pagination`&&Os(t,e.title,e.subtitle,e.id)),js=(e,t)=>{let n=ks(e);if(Os(t,e.name,e.path))return{...e,sessions:n.filter(e=>e.kind!==`pagination`)};let r=As(n,t);return r.length>0?{...e,sessions:r}:null},Ms=(e,t)=>{let n=t.trim().toLowerCase();return n?e.flatMap(e=>{if(Os(n,e.name,e.path))return[{...e,worktrees:[]}];let t=e.worktrees.flatMap(e=>{let t=js(e,n);return t?[t]:[]});return t.length>0?[{...e,worktrees:t}]:[]}):e},Ns=10,Ps=`oc:mobile-worktree-row-revealed`,Fs=e=>{window.dispatchEvent(new CustomEvent(Ps,{detail:e}))};function Is(e){let t=(0,zi.c)(10),n=he(e.session.id),r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={bootstrap:!1},t[0]=r):r=t[0];let i=Ke(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=Ne(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=Ss({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)(Ds,{...e,indicator:d}),t[7]=d,t[8]=e,t[9]=f):f=t[9],f}var Ls=Q.memo(Is);function Rs(e){let t=(0,zi.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`?Ds:Ls;return(0,$.jsx)(l,{session:e,paginationContinues:c,highlightQuery:s,onSelect:r,onPin:i,onArchive:a,onOpenActions:o},e.id)}),t[0]=s,t[1]=a,t[2]=o,t[3]=i,t[4]=r,t[5]=n,t[6]=c):c=t[6];let l;return t[7]===c?l=t[8]:(l=(0,$.jsx)($.Fragment,{children:c}),t[7]=c,t[8]=l),l}var zs=Q.memo(Rs);function Bs({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||=Hn({onPressedKeyChange:e=>g(e===l)}),Q.useEffect(()=>()=>S.current?.reset(),[]),Q.useEffect(()=>{let e=e=>{e.detail!==l&&m(0)};return window.addEventListener(Ps,e),()=>window.removeEventListener(Ps,e)},[l]),Q.useEffect(()=>{m(0)},[l]);let C=R(()=>m(0)),w=p!==0,T=R(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=R(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>Ns&&a>i){t.intent=`vertical`,y.current=null,S.current?.cancel(e.pointerId);return}if(i>Ns&&i>a){t.intent=`horizontal`,v(!0),b.current=!0,S.current?.cancel(e.pointerId);try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}Fs(l)}}if(t.intent!==`horizontal`)return;e.preventDefault();let i=Math.max(-t.actionWidth,Math.min(0,t.startOffset+n));m(i)}),D=R(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=R(e=>{let t=y.current;y.current=null,S.current?.cancel(e.pointerId),v(!1),m(t?.startOffset??0)}),k=R(()=>{if(!S.current?.consumeClick(l)){if(b.current){b.current=!1;return}if(p!==0){C();return}r()}}),A=R(n=>{d&&(n.preventDefault(),n.stopPropagation(),S.current?.openFromContextMenu(l,()=>{g(!1),a?.(e,t)}))}),j=R(()=>{C(),i?.(e,t)}),M=R(()=>{C(),o?.(e,t)}),N=R(()=>a?.(e,t)),P=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`oc-mobile-group-label-icon`,"aria-hidden":!0,children:(0,$.jsx)(X,{name:`git-branch`,className:`size-3.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left oc-mobile-entity-title font-semibold text-foreground`,children:s?an(t.name,s):t.name}),(0,$.jsx)(`span`,{className:`typography-small text-muted-foreground tabular-nums`,children:t.sessionCount===1?c(`mobile.sessions.project.sessionsSingle`):c(`mobile.sessions.project.sessionsPlural`,{count:t.sessionCount})}),(0,$.jsx)(X,{name:`arrow-down-s`,className:Y(`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:Y(`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)(Z,{type:`button`,variant:`secondary`,className:`oc-mobile-worktree-action h-full flex-col rounded-none border-0 bg-interactive-selection px-1 text-interactive-selection-foreground hover:bg-interactive-active`,"aria-label":c(`mobile.sessions.newSessionAria`),tabIndex:w?0:-1,onClick:j,children:[(0,$.jsx)(X,{name:`add`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:c(`sessions.sidebar.project.actions.newSession`)})]}):null,o?(0,$.jsxs)(Z,{type:`button`,variant:`destructive`,className:`oc-mobile-worktree-action h-full flex-col rounded-none border-0 px-1`,"aria-label":c(`mobile.projectEdit.deleteWorktreeAria`,{label:t.name}),tabIndex:w?0:-1,onClick:M,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:c(`mobile.projectEdit.deleteWorktreeConfirmButton`)})]}):null]}):null,(0,$.jsxs)(`div`,{className:Y(`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)(Z,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-mobile-worktree-more rounded-full text-muted-foreground`,"aria-label":c(`agentManager.detail.actions.worktreeActionsAria`),onClick:N,children:(0,$.jsx)(X,{name:`more-2`,className:`size-3.5`})}):null]})]})}function Vs(e){let t=(0,zi.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=Ms(n,M),t[4]=M,t[5]=n,t[6]=P):P=t[6];let F=P,I=R(a),L=R(o),z;t[7]===s?z=t[8]:(z=()=>s?.(),t[7]=s,t[8]=z);let te=R(z),B;t[9]===c?B=t[10]:(B=()=>c?.(),t[9]=c,t[10]=B);let V=R(B),ne;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(ne=e=>O(e),t[11]=ne):ne=t[11];let H=R(ne),re;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>{A(``),E(!1)},t[12]=re):re=t[12];let U=R(re),W;t[13]!==U||t[14]!==T?(W=()=>{if(T){U();return}E(!0)},t[13]=U,t[14]=T,t[15]=W):W=t[15];let ie=R(W),ae;t[16]!==U||t[17]!==l?(ae=e=>{U(),e.expanded||l(e)},t[16]=U,t[17]=l,t[18]=ae):ae=t[18];let G=R(ae),oe;t[19]!==U||t[20]!==l||t[21]!==d?(oe=(e,t)=>{U(),e.expanded||l(e),t.expanded||d(e,t)},t[19]=U,t[20]=l,t[21]=d,t[22]=oe):oe=t[22];let se=R(oe),ce;t[23]!==U||t[24]!==h?(ce=e=>{U(),h(e)},t[23]=U,t[24]=h,t[25]=ce):ce=t[25];let le=R(ce),K;t[26]===y?K=t[27]:(K=Y(`relative isolate mx-auto flex w-full max-w-[26rem] flex-col gap-5`,y),t[26]=y,t[27]=K);let ue;t[28]===S?ue=t[29]:(ue=S(`mobile.sessions.section.projects`),t[28]=S,t[29]=ue);let de;t[30]!==T||t[31]!==S?(de=S(T?`mobile.sessions.clearSearchAria`:`mobile.sessions.searchAria`),t[30]=T,t[31]=S,t[32]=de):de=t[32];let fe=T?`close`:`search`,pe;t[33]===fe?pe=t[34]:(pe=(0,$.jsx)(X,{name:fe,className:`size-5`}),t[33]=fe,t[34]=pe);let me;t[35]!==ie||t[36]!==T||t[37]!==de||t[38]!==pe?(me=(0,$.jsx)(Z,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":de,"aria-expanded":T,onClick:ie,children:pe}),t[35]=ie,t[36]=T,t[37]=de,t[38]=pe,t[39]=me):me=t[39];let he;t[40]===S?he=t[41]:(he=S(`mobile.projects.menu.label`),t[40]=S,t[41]=he);let ge=D?`rotate-45`:`rotate-0`,_e;t[42]===ge?_e=t[43]:(_e=Y(`size-5 transition-transform duration-150 motion-reduce:transition-none`,ge),t[42]=ge,t[43]=_e);let ve;t[44]===_e?ve=t[45]:(ve=(0,$.jsx)(X,{name:`add`,className:_e}),t[44]=_e,t[45]=ve);let ye;t[46]!==he||t[47]!==ve?(ye=(0,$.jsx)(sn,{asChild:!0,children:(0,$.jsx)(Z,{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":he,children:ve})}),t[46]=he,t[47]=ve,t[48]=ye):ye=t[48];let be;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,$.jsx)(X,{name:`chat-new`,className:`size-4`}),t[49]=be):be=t[49];let xe;t[50]===S?xe=t[51]:(xe=S(`mobile.projects.menu.newChat`),t[50]=S,t[51]=xe);let Se;t[52]!==L||t[53]!==xe?(Se=(0,$.jsxs)(nn,{className:`min-h-11`,onSelect:L,children:[be,xe]}),t[52]=L,t[53]=xe,t[54]=Se):Se=t[54];let Ce;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,$.jsx)(X,{name:`folder`,className:`size-4`}),t[55]=Ce):Ce=t[55];let we;t[56]===S?we=t[57]:(we=S(`mobile.projects.menu.newProject`),t[56]=S,t[57]=we);let Te;t[58]!==I||t[59]!==we?(Te=(0,$.jsxs)(nn,{className:`min-h-11`,onSelect:I,children:[Ce,we]}),t[58]=I,t[59]=we,t[60]=Te):Te=t[60];let Ee;t[61]!==te||t[62]!==s||t[63]!==S?(Ee=s?(0,$.jsxs)(nn,{className:`min-h-11`,onSelect:te,children:[(0,$.jsx)(X,{name:`scan-2`,className:`size-4`}),S(`mobile.projects.menu.scanQr`)]}):null,t[61]=te,t[62]=s,t[63]=S,t[64]=Ee):Ee=t[64];let De;t[65]!==V||t[66]!==c||t[67]!==S?(De=c?(0,$.jsxs)(nn,{className:`min-h-11`,onSelect:V,children:[(0,$.jsx)(X,{name:`server`,className:`size-4`}),S(`mobile.projects.menu.switchInstance`)]}):null,t[65]=V,t[66]=c,t[67]=S,t[68]=De):De=t[68];let Oe;t[69]!==Se||t[70]!==Te||t[71]!==Ee||t[72]!==De?(Oe=(0,$.jsxs)(en,{align:`end`,side:`bottom`,className:`min-w-44`,children:[Se,Te,Ee,De]}),t[69]=Se,t[70]=Te,t[71]=Ee,t[72]=De,t[73]=Oe):Oe=t[73];let ke;t[74]!==H||t[75]!==D||t[76]!==ye||t[77]!==Oe?(ke=(0,$.jsxs)(tn,{open:D,onOpenChange:H,children:[ye,Oe]}),t[74]=H,t[75]=D,t[76]=ye,t[77]=Oe,t[78]=ke):ke=t[78];let Ae;t[79]!==me||t[80]!==ke?(Ae=(0,$.jsxs)($.Fragment,{children:[me,ke]}),t[79]=me,t[80]=ke,t[81]=Ae):Ae=t[81];let je;t[82]!==ue||t[83]!==Ae?(je=(0,$.jsx)(Zn,{title:ue,trailing:Ae}),t[82]=ue,t[83]=Ae,t[84]=je):je=t[84];let Me;t[85]!==U||t[86]!==T||t[87]!==k||t[88]!==S?(Me=T?(0,$.jsxs)(`div`,{className:`relative mx-1`,role:`search`,children:[(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 z-10 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(Yt,{autoFocus:!0,type:`text`,inputMode:`search`,enterKeyHint:`search`,value:k,placeholder:S(`mobile.sessions.search.placeholder`),"aria-label":S(`mobile.sessions.searchAria`),className:Y(`h-11 rounded-full pl-9`,k&&`pr-10`),onChange:e=>A(e.target.value),onKeyDown:e=>{e.key===`Escape`&&U()}}),k?(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute right-1.5 top-1/2 size-8 -translate-y-1/2 rounded-full text-muted-foreground`,"aria-label":S(`mobile.sessions.clearSearchAria`),onClick:()=>A(``),children:(0,$.jsx)(X,{name:`close`,className:`size-4`})}):null]}):null,t[85]=U,t[86]=T,t[87]=k,t[88]=S,t[89]=Me):Me=t[89];let q;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?(q=!N&&(r.length>0||x.length>0)?(0,$.jsx)(nr,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":S(`mobile.sessions.section.pinned`),children:[(0,$.jsx)(xs,{project:{id:`__pinned__`,name:S(`mobile.sessions.section.pinned`),path:``,icon:`pushpin`,sessionCount:r.length+x.length},expanded:C,embedded:!0,onToggle:()=>w(Us)}),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)(zs,{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)(zs,{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]=q):q=t[99];let Ne;t[100]!==I||t[101]!==G||t[102]!==se||t[103]!==le||t[104]!==M||t[105]!==_||t[106]!==m||t[107]!==f||t[108]!==u||t[109]!==v||t[110]!==p||t[111]!==g||t[112]!==h||t[113]!==l||t[114]!==d||t[115]!==n.length||t[116]!==N||t[117]!==S||t[118]!==F?(Ne=n.length===0?(0,$.jsxs)(`section`,{className:`flex min-h-[52dvh] flex-col items-center justify-center px-6 text-center`,children:[(0,$.jsx)(`span`,{className:`mb-4 flex size-14 items-center justify-center rounded-2xl bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(X,{name:`folder-add`,className:`size-6`})}),(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:S(`mobile.sessions.empty.noProjectsTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-xs typography-small text-muted-foreground`,children:S(`mobile.sessions.empty.noProjectsDescription`)}),(0,$.jsxs)(Z,{type:`button`,size:`lg`,className:`mt-4 min-h-10 rounded-full px-5`,onClick:I,children:[(0,$.jsx)(X,{name:`folder-add`,className:`size-4`}),S(`sessions.sidebar.header.actions.addProject`)]})]}):N&&F.length===0?(0,$.jsxs)(`section`,{className:`flex min-h-[40dvh] flex-col items-center justify-center px-6 text-center`,children:[(0,$.jsx)(X,{name:`search`,className:`mb-4 size-6 text-muted-foreground`}),(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:S(`mobile.sessions.empty.searchTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-xs typography-small text-muted-foreground`,children:S(`mobile.sessions.empty.searchDescription`)})]}):F.map(e=>{let t=N||e.expanded,n=e.worktrees.find(Hs)??(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)(nr,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":e.name,children:[(0,$.jsx)(xs,{project:e,expanded:t,embedded:!0,highlightQuery:N?M:void 0,onToggle:()=>N?G(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)(zs,{sessions:i,highlightQuery:N?M:void 0,onSelectSession:N?le:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null,r.map(t=>{let n=N||!!t.expanded;return(0,$.jsx)(or,{className:`oc-mobile-worktree-group`,ariaLabel:t.name,label:(0,$.jsx)(Bs,{project:e,worktree:t,expanded:n,highlightQuery:N?M:void 0,onToggle:()=>N?se(e,t):d(e,t),onNewSession:f,onOpenActions:N?void 0:p,onDelete:N?void 0:m}),children:n&&t.sessions.length>0?(0,$.jsx)(zs,{sessions:t.sessions,highlightQuery:N?M:void 0,onSelectSession:N?le:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v}):null},t.id)})]}):null]})},e.id)}),t[100]=I,t[101]=G,t[102]=se,t[103]=le,t[104]=M,t[105]=_,t[106]=m,t[107]=f,t[108]=u,t[109]=v,t[110]=p,t[111]=g,t[112]=h,t[113]=l,t[114]=d,t[115]=n.length,t[116]=N,t[117]=S,t[118]=F,t[119]=Ne):Ne=t[119];let Pe;t[120]===S?Pe=t[121]:(Pe=S(`sessions.sidebar.header.actions.addProject`),t[120]=S,t[121]=Pe);let Fe;t[122]!==I||t[123]!==Pe?(Fe=(0,$.jsx)(`button`,{type:`button`,className:`sr-only`,onClick:I,children:Pe}),t[122]=I,t[123]=Pe,t[124]=Fe):Fe=t[124];let Ie;return t[125]!==K||t[126]!==je||t[127]!==Me||t[128]!==q||t[129]!==Ne||t[130]!==Fe?(Ie=(0,$.jsxs)(`main`,{className:K,children:[je,Me,q,Ne,Fe]}),t[125]=K,t[126]=je,t[127]=Me,t[128]=q,t[129]=Ne,t[130]=Fe,t[131]=Ie):Ie=t[131],Ie}function Hs(e){return e.kind===`main`}function Us(e){return!e}function Ws(e){let t=(0,zi.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=()=>{Oe(`light`),i()},t[0]=i,t[1]=d);let f=R(d),p=c?`destructive`:`ghost`,m=u?`size-5 animate-spin`:`size-5`,h;t[2]!==n||t[3]!==m?(h=(0,$.jsx)(X,{name:n,className:m}),t[2]=n,t[3]=m,t[4]=h):h=t[4];let g;t[5]===r?g=t[6]:(g=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[5]=r,t[6]=g);let _;return t[7]!==l||t[8]!==f||t[9]!==p||t[10]!==h||t[11]!==g?(_=(0,$.jsxs)(Z,{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 Gs(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)(Ws,{icon:e.icon,label:xr(e,t),onClick:n(e.onClick),destructive:e.destructive,disabled:e.disabled,spinning:e.spinning},e.id))},e.items[0]?.id))}function Ks(e){let t=(0,zi.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=Ar({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=Qr({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=Zr({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=Gs(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)(Gt,{id:`mobile-row-actions-sheet`,open:n,onOpenChange:a,title:h,ariaLabel:g,closeAriaLabel:_,resizeAriaLabel:v,fitContent:!0,children:b}),t[38]=a,t[39]=n,t[40]=b,t[41]=h,t[42]=_,t[43]=v,t[44]=r.title,t[45]=x):x=t[45],x}function qs(e,t){return e&&e.id===t.id&&e.kind===t.kind&&e.title===t.title&&e.subtitle===t.subtitle&&e.changes===t.changes&&e.activityLabel===t.activityLabel&&e.unread===t.unread&&e.pinned===t.pinned&&e.archived===t.archived&&e.active===t.active&&e.directory===t.directory&&e.expanded===t.expanded&&e.children===t.children?e:t}function Js(e,t){if(!e||e.length===0)return t.slice();let n=new Map(e.map(e=>[e.id,e])),r=e.length===t.length,i=t.map((t,i)=>{let a=qs(n.get(t.id)??e[i],t);return a!==e[i]&&(r=!1),a});if(r){let t=!0;for(let n=0;n<i.length;n+=1)if(i[n]!==e[n]){t=!1;break}if(t)return e}return i}var Ys=`__show_more__:`,Xs=`__show_fewer__:`,Zs=e=>e.startsWith(Ys),Qs=e=>e.startsWith(Xs),$s=e=>Zs(e)||Qs(e),ec=e=>{let t=Zs(e)?Ys:Qs(e)?Xs: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)}},tc=e=>e.parentID??null,nc=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),rc=e=>{let t=e;return nc(t.directory??t.project?.worktree??null)},ic=(e,t)=>{if(t?.trim())return t.trim();let n=nc(e);if(!n)return``;let r=n.split(`/`).filter(Boolean);return r[r.length-1]||n},ac=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},oc=e=>{if(e<=0)return``;let t=Date.now()-e;if(t<6e4)return`now`;let n=Math.floor(t/6e4);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r<24)return`${r}h`;let i=Math.floor(r/24);return i<7?`${i}d`:new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))},sc=e=>{let t=e.time?.archived;return typeof t==`number`&&t>0},cc=(e,t)=>e.worktrees.find(e=>nc(e.path)===t)??null,lc=(e,t)=>{let n=t?.trim();return n?`${e} · ${n}`:e},uc=(e,t)=>Wr(e,{pinnedSessionIds:t,omitPinnedSessions:!0}).map(e=>e.session);function dc(){let{t:e}=ee(),t=de(),n=Fe(e=>e.activeSessions),r=Fe(e=>e.activePaginationByDirectory),i=Ie(e=>e.projects),a=Ie(e=>e.activeProjectId),o=C(e=>e.currentDirectory),s=q(e=>e.currentSessionId),c=q(e=>e.availableWorktreesByProject),l=Et(e=>e.orderByProject),u=Ue(),d=yo(e=>e.projectExpanded),f=yo(e=>e.worktreeExpanded),p=ue(e=>e.index.session.unseenCount),[m,h]=Q.useState(new Map),g=Tr(),_=Q.useMemo(()=>_r(g,s),[s,g]),v=Q.useMemo(()=>i.map(e=>{let t=nc(e.path);return{id:e.id,label:ic(t,e.label),path:t,icon:e.icon,worktrees:xt(l[e.id],c.get(t)??[])}}),[i,l,c]),y=Q.useMemo(()=>{let e=new Map(t.map(e=>[e.id,e])),r=n.map(t=>{let n=e.get(t.id);return n?Ae(n,t):t}),i=new Set(r.map(e=>e.id));for(let e of t)i.has(e.id)||r.push(e);return r},[n,t]),b=Q.useMemo(()=>ar(y,v.map(e=>({id:e.id,normalizedPath:e.path})),c,!1),[v,y,c]),x=Q.useMemo(()=>{let e=v.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===a,latestActivity:0})),t=new Map(e.map(e=>[e.project.id,e])),n=(e,t,n)=>{let r=nc(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||ic(r),path:r,worktree:n,sessions:[]},e.buckets.push(a)),a};for(let t of e){n(t,t.project.path,null);for(let e of t.project.worktrees)n(t,e.path,e)}for(let e of y){let r=b.bySessionId.get(e.id);if(!r)continue;let i=t.get(r.projectId);if(!i)continue;let a=r.kind===`worktree`?cc(i.project,r.scopeDirectory):null;(a?n(i,a.path,a):n(i,i.project.path,null)).sessions.push(e)}for(let t of e)for(let e of t.buckets){e.sessions.sort((e,t)=>Te(t)-Te(e));let n=uc(e.sessions,u);t.totalSessions+=n.length;for(let n of e.sessions){let e=ac(n);e>t.latestActivity&&(t.latestActivity=e)}}return e},[a,b,u,v,y]),S=Q.useMemo(()=>{let e=new Map;for(let t of y)e.set(t.id,t);return e},[y]),w=Q.useMemo(()=>{let e=new Map;for(let t of v)e.set(t.id,t);return e},[v]),T=Q.useRef([]),E=Q.useRef([]),D=Q.useRef(new Map),{pinnedSessions:O,inProgressSessions:k}=Q.useMemo(()=>{let t=new Map(v.map(e=>[e.id,e])),n=e(`mobile.sessions.untitled`),r=new Map(T.current.map(e=>[e.id,e])),i=new Map(E.current.map(e=>[e.id,e])),a=(e,r,i)=>{let a=b.bySessionId.get(e.id),o=a?t.get(a.projectId):void 0;if(!o)return[];let c=a?.kind===`worktree`?cc(o,a.scopeDirectory):null,l={id:e.id,directory:rc(e),title:e.title?.trim()||n,subtitle:lc(o.label,c?.branch),changes:Kn(Gn(e))??void 0,activityLabel:oc(ac(e))||void 0,unread:(p[e.id]??0)>0,pinned:r,archived:sc(e),active:s===e.id};return[qs(i.get(e.id),l)]},o=Ir(y,u).flatMap(e=>a(e,!0,r)),c=Or(y,u,g,p).flatMap(e=>a(e,!1,i)),l=Js(T.current,o),d=Js(E.current,c);return T.current=l,E.current=d,{pinnedSessions:l,inProgressSessions:d}},[s,b,u,v,g,y,e,p]),A=Q.useMemo(()=>{let e=new Map;for(let t of x){let n=t.project.worktrees.length>0;for(let r of t.buckets){let i=uc(r.sessions,u).length;e.set(`${t.project.id}::${r.key}`,{path:r.path,rootCount:i,hasWorktrees:n})}}return e},[u,x]),j=Q.useMemo(()=>{let t=nc(o),n=new Map,i=e=>(e.kind!==`pagination`&&n.set(e.id,e),e),a=x.map(a=>{let o=d[a.project.id]??!0,c=pr(),l=a.project.icon?Wt[a.project.icon]:void 0,h=a.buckets.map(o=>{let l=`${a.project.id}::${o.key}`,d=f[l]??!1,h=m.get(l)??c,g=uc(o.sessions,u),v=Wr(o.sessions,{pinnedSessionIds:u,omitPinnedSessions:!1}).map(e=>e.session),y=t=>{let r=tc(t),a=(p[t.id]??0)>0&&!r,c={id:t.id,directory:o.path,title:t.title?.trim()||e(`mobile.sessions.untitled`),changes:Kn(Gn(t))??void 0,activityLabel:oc(ac(t))||void 0,unread:a,pinned:u.has(t.id),archived:sc(t),active:s===t.id},l=qs(D.current.get(t.id)??n.get(t.id),c);return i(l)},b=vr(g,h,_).map(y),x=g.length-b.length,S=r.get(nc(o.path)),C=S?.hasMore===!0,w=g.length>c&&h>c,T=[...b];w&&T.push({id:`${Xs}${a.project.id}::${o.key}`,kind:`pagination`,title:e(`sessions.sidebar.group.showFewer`)}),(x>0||C)&&T.push({id:`${Ys}${a.project.id}::${o.key}`,kind:`pagination`,title:e(`sessions.sidebar.group.showMore`),subtitle:S?.loadingMore?`…`:void 0});let E=nc(o.path),O=!!(a.isActive&&t&&E&&(t===E||t.startsWith(`${E}/`))),k=o.worktree==null;return{id:o.key,name:k?e(`mobile.sessions.mainWorkspace`):o.label,path:o.path,kind:k?`main`:`worktree`,active:O,expanded:k?!0:d,sessionCount:g.length,sessions:T,catalogSessions:v.map(y)}});return{id:a.project.id,name:a.project.label,path:a.project.path,icon:l,sessionCount:a.totalSessions,activityLabel:oc(a.latestActivity)||void 0,active:a.isActive,expanded:o,worktrees:h}});return D.current=n,a},[r,_,o,s,u,d,x,e,p,m,f]),M=e=>{for(let[t,n]of A)if(t.startsWith(`${e}::`))return n.hasWorktrees;return!1},N=(e,t)=>A.get(`${e}::${t}`)?.rootCount??0,P=e=>pr();return{projects:j,pinnedSessions:O,inProgressSessions:k,sessionById:S,projectMetaById:w,allSessions:y,projectHasWorktrees:M,getBucketRootCount:N,getBucketVisibleCount:(e,t)=>{let n=`${e}::${t}`;return m.get(n)??P(e)},getBucketPageSize:P,getBucketDirectory:(e,t)=>A.get(`${e}::${t}`)?.path??null,showMoreBucketSessions:(e,t)=>{let n=`${e}::${t}`,r=A.get(n),i=pr(),a=Xr(),o=m.get(n)??i,s=r?.rootCount??0;if(h(e=>{let t=new Map(e),r=Math.max(i,e.get(n)??i,o);return t.set(n,r+a),t}),Math.max(i,o)+a<s)return;let c=r?.path,l=nc(c);if(!l)return;let u=Fe.getState().activePaginationByDirectory.get(l);u?.hasMore&&!u.loadingMore&&ze(l)},resetBucketVisibleCount:(e,t)=>{let n=`${e}::${t}`;h(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t})}}}var fc=(e,t,n)=>e?.kind===`project`&&e.project.id===t?{...e,isGitRepository:n}:e;function pc({onOpenChat:e,onAddProject:t,onNewSession:n,onScanQr:r,onSwitchInstance:i,className:a}){let{t:o}=ee(),{git:s}=gn(),c=dc(),l=yo(e=>e.setProjectExpanded),u=yo(e=>e.setWorktreeExpanded),d=Ve(),f=Ue(),p=q(e=>e.archiveSessions),m=q(e=>e.updateSessionTitle),h=q(e=>e.requestSessionSmartTitle),_=q(e=>e.shareSession),v=q(e=>e.unshareSession),y=q(e=>e.openNewSessionDraft),b=We(e=>e.openDraft),x=We(e=>e.openSession),S=Ie(e=>e.projects),C=Ie(e=>e.setActiveProjectIdOnly),w=Ie(e=>e.removeProject),T=Dt(),[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),[I,L]=Q.useState(``),[z,B]=Q.useState(!1),[V,ne]=Q.useState(!1),[H,re]=Q.useState(null),[U,W]=Q.useState(null),[ie,ae]=Q.useState(null),G=E?.kind===`session`?E.session.id:``,oe=he(G),se=oe?.type===`busy`||oe?.type===`retry`,ce=E?.kind===`session`?rc(E.session):``,le=!!G&&ie===G,K=!ce||le||se,ue=R(e=>{let t=new Map;for(let e of c.allSessions){let n=tc(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}),de=R(()=>{k(!1),D(null)}),fe=R(t=>{if($s(t.id)){let e=ec(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&&rc(n)||null;e({sessionId:t.id,directory:r})}),pe=R(e=>{$s(e.id)||d(e.id)}),me=R(async e=>{if($s(e.id))return;let t=ue(e.id),{archivedIds:n,failedIds:r}=await p(t);n.length>0&&Rr({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&&J.error(r.length===1?o(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):o(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}),ge=R(()=>{if(!E||E.kind!==`session`)return;let e=E.session,t=rc(e),n=oe?.type??`idle`;!t||ie===e.id||n===`busy`||n===`retry`||(ae(e.id),(async()=>{try{await T.refreshSessionTranscript(e.id,{directory:t}),J.success(o(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{J.error(o(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{ae(t=>t===e.id?null:t)}})())}),_e=R(e=>{if($s(e.id))return;let t=c.sessionById.get(e.id);t&&(D({kind:`session`,session:t}),k(!0))}),ve=R(e=>{l(e.id,!e.expanded)}),ye=R((e,t)=>{u(`${e.id}::${t.id}`,!t.expanded)}),be=R((e,t)=>{C(e.id),b({selectedProjectId:e.id,directoryOverride:t,preserveDirectoryOverride:!0})}),xe=R(()=>{if(n){n();return}y()}),Se=R(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=>fc(n,t.id,e))}).catch(()=>{D(e=>fc(e,t.id,!1))}))}),Ce=R((e,t)=>{let n=g(t);return n?e.worktrees.find(e=>g(e.path)===n)||((q.getState().availableWorktreesByProject.get(e.path)??[]).find(e=>g(e.path)===n)??null):null}),we=R((e,t)=>{let n=c.projectMetaById.get(e.id);n&&be(n,t.path)}),Te=R((e,t)=>{let n=c.projectMetaById.get(e.id);n&&(D({kind:`worktree`,project:n,worktreePath:t.path,worktreeName:t.name}),k(!0))}),Ee=R((e,t)=>{let n=c.projectMetaById.get(e.id);if(!n)return;let r=Ce(n,t.path);if(!r){J.error(o(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}W({project:n,worktree:r})}),De=R(e=>{re(e),C(e),ne(!0)}),Oe=R(e=>{(async()=>{let t=e.worktrees;try{t=(await qt({id:e.id,path:e.path})).worktrees}catch(n){console.warn(`[MobileProjectsHome] Worktree refresh before session sync failed:`,n),t=q.getState().availableWorktreesByProject.get(e.path)??e.worktrees}await Je([e.path,...t.map(e=>e.path)],c.allSessions)})()}),ke=R((e,t)=>{let n=H;if(ne(!1),re(null),t?.sessionId){x({sessionId:t.sessionId,directory:e});return}b({selectedProjectId:n,directoryOverride:e,preserveDirectoryOverride:!0})}),Ae=R(async e=>{try{if(!(await _(e.id))?.share?.url){J.error(o(`sessions.sidebar.session.share.error`));return}J.success(o(`sessions.sidebar.session.share.successTitle`),{description:o(`sessions.sidebar.session.share.successDescription`)})}catch{J.error(o(`sessions.sidebar.session.share.error`))}}),je=R(async e=>{if((await te(e)).ok){J.success(o(`sessions.sidebar.session.menu.copied`));return}J.error(o(`sessions.sidebar.session.share.copyUrlError`))}),Me=R(async e=>{try{if(await v(e)){J.success(o(`sessions.sidebar.session.unshare.success`));return}J.error(o(`sessions.sidebar.session.unshare.error`))}catch{J.error(o(`sessions.sidebar.session.unshare.error`))}}),Ne=R(e=>{let t=ue(e.id);br({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`)})}),Pe=R(async()=>{if(!P)return;let e=I.trim();if(e)try{await m(P.id,e),F(null),L(``)}catch{J.error(o(`sessions.sidebar.session.menu.rename`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}}),Fe=R(async()=>{if(!P||z)return;let e=P.id;F(null),L(``),B(!0);try{await h(e)}catch{J.error(o(`sessions.sidebar.session.rename.smartTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{B(!1)}}),Le=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]),Re=Q.useMemo(()=>{if(!E)return{};if(E.kind===`session`){let e=E.session;return{onRename:()=>{L(e.title?.trim()||o(`mobile.sessions.untitled`)),F(e)},onTogglePin:()=>d(e.id),onShare:e.share?.url?void 0:()=>{Ae(e)},onCopyLink:e.share?.url?()=>{je(e.share.url)}:void 0,onUnshare:e.share?.url?()=>{Me(e.id)}:void 0,onRefreshTranscript:ge,onArchive:()=>{me({id:e.id,title:e.title?.trim()||o(`mobile.sessions.untitled`)})},onDelete:()=>Ne(e)}}if(E.kind===`project`){let e=E.project;return{onNewSession:()=>be(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:()=>be(e,t),onDeleteWorktree:()=>{let n=Ce(e,t);if(!n){J.error(o(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}W({project:e,worktree:n})}}},[E,me,je,Ne,ge,De,Oe,Ae,Me,Ce,be,o,d]),ze=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:g(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)(Vs,{className:a,projects:c.projects,pinnedSessions:c.pinnedSessions,inProgressSessions:c.inProgressSessions,onAddProject:t,onNewSession:xe,onScanQr:r,onSwitchInstance:i,onToggleProject:ve,onOpenProjectActions:Se,onToggleWorktree:ye,onNewWorktreeSession:we,onOpenWorktreeActions:Te,onDeleteWorktree:Ee,onSelectSession:fe,onPinSession:pe,onArchiveSession:e=>{me(e)},onOpenSessionActions:_e}),(0,$.jsx)(Ks,{open:O,target:Le,actions:Re,refreshTranscriptDisabled:K,refreshTranscriptSpinning:le,onOpenChange:e=>{e?k(!0):de()}}),(0,$.jsx)(ut,{open:V,projectId:H,onOpenChange:e=>{ne(e),e||re(null)},onWorktreeCreated:ke}),U?(0,$.jsx)(mr,{open:!0,project:{id:U.project.id,path:U.project.path},worktree:U.worktree,onClose:()=>W(null)}):null,(0,$.jsx)(un,{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)(Z,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>N(null),children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Z,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!M)return;let e=M;N(null),w(e.id),J.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)(un,{open:!!P,title:o(`sessions.sidebar.session.menu.rename`),onClose:()=>{z||(F(null),L(``))},closeAriaLabel:o(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Z,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:z,onClick:()=>{F(null),L(``)},children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Z,{type:`button`,variant:`default`,className:`flex-1`,disabled:!I.trim()||z,onClick:()=>void Pe(),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(),Pe()},children:[(0,$.jsx)(Yt,{value:I,onChange:e=>L(e.target.value),autoFocus:!0,className:`h-12`,disabled:z}),(0,$.jsxs)(Z,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:z,onClick:()=>void Fe(),children:[z?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`ai-generate-2`,className:`size-4`}),o(`sessions.sidebar.session.rename.smartTitle`)]})]})}),(0,$.jsx)(hr,{open:A!==null,project:ze,onClose:()=>j(null)})]})}function mc(e){let t=(0,zi.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=Y(`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)(tr,{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 hc(e){let t=(0,zi.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=[...ir],t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,$.jsx)(oi,{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)(tr,{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 gc(e){let t=(0,zi.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,p=c===void 0?null:c,{t:m}=ee(),h=We(),_=We(Dc),v=We(Ec),y=We(Tc),b=We(wc),x=We(Cc),S=We(Sc),C=We(xc),w=We(bc),T=We(yc),E;t[0]===_?E=t[1]:(E=e=>{e===`settings`&&k.getState().setSettingsPage(`home`),_(e)},t[0]=_,t[1]=E);let D=R(E),O;t[2]===v?O=t[3]:(O=e=>{v(e)},t[2]=v,t[3]=O);let A=R(O),j;t[4]===x?j=t[5]:(j=()=>{x()},t[4]=x,t[5]=j);let M=R(j),N;t[6]===y?N=t[7]:(N=()=>{y()},t[6]=y,t[7]=N);let P=R(N),F;t[8]===b?F=t[9]:(F=e=>{b(e)},t[8]=b,t[9]=F);let I=R(F),L=Q.useRef(null),[z,te]=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=R(B),ne;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(ne=e=>{te(e)},t[11]=ne):ne=t[11];let H=R(ne),re;t[12]!==M||t[13]!==S?(re=()=>{if(L.current?.())return!0;let e=We.getState().secondary;return e?.kind===`chat`&&e.routes.length>1?(S(),!0):e?(M(),!0):!1},t[12]=M,t[13]=S,t[14]=re):re=t[14];let U=R(re),W=h.secondary!==null,ie;t[15]!==U||t[16]!==l?(ie=()=>{if(l)return l(()=>U()),()=>l(null)},t[15]=U,t[16]=l,t[17]=ie):ie=t[17];let ae;t[18]!==U||t[19]!==l||t[20]!==W?(ae=[l,W,U],t[18]=U,t[19]=l,t[20]=W,t[21]=ae):ae=t[21],Q.useEffect(ie,ae);let G=q(vc),oe;t[22]===G?oe=t[23]:(oe=e=>G?e.getDirectoryForSession(G):null,t[22]=G,t[23]=oe);let se=q(oe),ce,le;t[24]!==se||t[25]!==G||t[26]!==w||t[27]!==T?(ce=()=>{let e=We.getState().secondary;if(e?.kind===`draft`&&G){w({sessionId:G,directory:se});return}if(e?.kind!==`chat`||!G||qe({sessionId:G,directory:se})===`internal`)return;let t=e.routes.at(-1);(t?.sessionId!==G||g(t.directory)!==g(se))&&T({sessionId:G,directory:se})},le=[se,G,w,T],t[24]=se,t[25]=G,t[26]=w,t[27]=T,t[28]=ce,t[29]=le):(ce=t[28],le=t[29]),Q.useEffect(ce,le);let K,ue;t[30]!==G||t[31]!==p||t[32]!==C?(K=()=>{let e=We.getState().secondary;if(e?.kind!==`chat`||!p)return;let t=e.routes.at(-1);!t||t.sessionId!==G||C({sessionId:p.id,directory:p.directory})},ue=[G,p,C],t[30]=G,t[31]=p,t[32]=C,t[33]=K,t[34]=ue):(K=t[33],ue=t[34]),Q.useEffect(K,ue);let de;t[35]!==H||t[36]!==V||t[37]!==u?(de=typeof u==`function`?u(V,H):u,t[35]=H,t[36]=V,t[37]=u,t[38]=de):de=t[38];let fe=de,pe;t[39]!==P||t[40]!==n||t[41]!==r||t[42]!==i||t[43]!==A?(pe=(0,$.jsx)(pc,{onOpenChat:A,onAddProject:n,onNewSession:P,onScanQr:r,onSwitchInstance:i}),t[39]=P,t[40]=n,t[41]=r,t[42]=i,t[43]=A,t[44]=pe):pe=t[44];let me;t[45]!==a||t[46]!==I?(me=(0,$.jsx)(Jo,{onEnable:a,onOpenAssistant:I}),t[45]=a,t[46]=I,t[47]=me):me=t[47];let he;t[48]===fe?he=t[49]:(he=(0,$.jsx)(mc,{showHeader:!1,children:fe}),t[48]=fe,t[49]=he);let ge;t[50]===o?ge=t[51]:(ge=(0,$.jsx)(hc,{instancesPage:o}),t[50]=o,t[51]=ge);let _e;t[52]!==pe||t[53]!==me||t[54]!==he||t[55]!==ge?(_e={projects:pe,assistant:me,scheduled:he,settings:ge},t[52]=pe,t[53]=me,t[54]=he,t[55]=ge,t[56]=_e):_e=t[56];let ve=_e,ye=h.secondary?.kind??null,be;bb0:{if(!ye){be=null;break bb0}if(ye===`assistant`){let e;t[57]===m?e=t[58]:(e=m(`assistants.title`),t[57]=m,t[58]=e);let n;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(mi,{activeOverride:!0,onMobileBack:_c}),t[59]=n):n=t[59];let r;t[60]!==U||t[61]!==e?(r=[{key:`assistant-secondary`,depth:1,ariaLabel:e,onBack:U,content:n}],t[60]=U,t[61]=e,t[62]=r):r=t[62],be=r;break bb0}if(ye===`instances`){let e;t[63]===m?e=t[64]:(e=m(`mobile.settings.switchInstance`),t[63]=m,t[64]=e);let n;t[65]!==U||t[66]!==s||t[67]!==e?(n=[{key:`instances-secondary`,depth:1,ariaLabel:e,onBack:U,content:s}],t[65]=U,t[66]=s,t[67]=e,t[68]=n):n=t[68],be=n;break bb0}if(h.secondary?.kind===`draft`){let e;t[69]===m?e=t[70]:(e=m(`mobile.nav.secondaryPageAria`),t[69]=m,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]!==U||t[74]!==e||t[75]!==n?(r=[{key:`chat-primary`,depth:1,ariaLabel:e,onBack:U,content:n}],t[73]=U,t[74]=e,t[75]=n,t[76]=r):r=t[76],be=r;break bb0}if(h.secondary?.kind!==`chat`){let e;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[77]=e):e=t[77],be=e;break bb0}let e=h.secondary.routes,n;if(t[78]!==U||t[79]!==d||t[80]!==e||t[81]!==m){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:m(`mobile.nav.secondaryPageAria`),onBack:U,content:d({sessionId:e.sessionId,directory:e.directory,viewKey:e.key,active:n})}}),t[78]=U,t[79]=d,t[80]=e,t[81]=m,t[82]=n}else n=t[82];be=n}let xe=be,Se;t[83]===xe?Se=t[84]:(Se=xe??[],t[83]=xe,t[84]=Se);let Ce;return t[85]!==f||t[86]!==h||t[87]!==z||t[88]!==D||t[89]!==Se||t[90]!==ve?(Ce=(0,$.jsx)(_s,{className:f,navigation:h,onTabChange:D,tabs:ve,secondaryPages:Se,tabBarCovered:z}),t[85]=f,t[86]=h,t[87]=z,t[88]=D,t[89]=Se,t[90]=ve,t[91]=Ce):Ce=t[91],Ce}function _c(){return kn.requestAnimatedBack(`root`)}function vc(e){return e.currentSessionId}function yc(e){return e.replaceChatSession}function bc(e){return e.materializeDraftSession}function xc(e){return e.reconcileChatPredecessor}function Sc(e){return e.popChatSession}function Cc(e){return e.closeSecondary}function wc(e){return e.openAssistant}function Tc(e){return e.openDraft}function Ec(e){return e.openSession}function Dc(e){return e.setActiveTab}function Oc(e){let t=(0,zi.c)(19),{percentage:n}=e,r,i,a,o,s,c,l;if(t[0]!==n){a=rn(n)??0;let e=Qt(n);i=e===`critical`?`var(--status-error)`:e===`warn`?`var(--status-warning)`:`var(--status-success)`,r=2*Math.PI*7.5,o=`0 0 18 18`,s=`size-[18px] -rotate-90`,c=`progressbar`,l=Math.round(a),t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7];let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:3}),t[8]=u):u=t[8];let d=r*(1-a/100),f;t[9]!==r||t[10]!==i||t[11]!==d?(f=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:i,strokeWidth:3,strokeLinecap:`round`,strokeDasharray:r,strokeDashoffset:d,className:`transition-[stroke-dashoffset,stroke] duration-300`}),t[9]=r,t[10]=i,t[11]=d,t[12]=f):f=t[12];let p;return t[13]!==o||t[14]!==s||t[15]!==c||t[16]!==l||t[17]!==f?(p=(0,$.jsxs)(`svg`,{viewBox:o,className:s,role:c,"aria-valuenow":l,"aria-valuemin":0,"aria-valuemax":100,children:[u,f]}),t[13]=o,t[14]=s,t[15]=c,t[16]=l,t[17]=f,t[18]=p):p=t[18],p}function kc(e){let t=(0,zi.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=R(i),p=R(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)(le,{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 Ac=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},jc=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),Mc=e=>e>=90?`text-[var(--status-error)]`:e>=75?`text-[var(--status-warning)]`:`text-[var(--status-success)]`,Nc=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:`${jc(t)}/${jc(n)}`,colorClass:Mc(i)}},Pc=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=ge(e,t??(()=>void 0));return!n||`compacted`in n?0:n.totalTokens},Ic=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Lc=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`},Rc=e=>{let t=(0,zi.c)(13),{iconNode:n,iconName:r,label:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o=n??(r?(0,$.jsx)(X,{name:r,className:`size-[18px]`}):null),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s;t[3]===o?s=t[4]:(s=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:o}),t[3]=o,t[4]=s);let c;t[5]===i?c=t[6]:(c=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:i}),t[5]=i,t[6]=c);let l;t[7]===a?l=t[8]:(l=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground`,children:a}),t[7]=a,t[8]=l);let u;return t[9]!==s||t[10]!==c||t[11]!==l?(u=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5`,children:[s,c,l]}),t[9]=s,t[10]=c,t[11]=l,t[12]=u):u=t[12],u},zc=e=>{let t=(0,zi.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=ee(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(X,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,$.jsx)(X,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,$.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(Bt,{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=$t(e.window.valueLabel,t),i=ln(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:Y(`shrink-0 typography-ui-label font-semibold tabular-nums`,Lc(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},Bc=e=>{let t=(0,zi.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=Y(`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)(Rc,{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)(Rc,{iconNode:(0,$.jsx)(Oc,{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:Y(`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)(zc,{groups:o,displayMode:s,isLoading:c,timeFormatPreference:l}),t[29]=c,t[30]=l,t[31]=s,t[32]=o,t[33]=j):j=t[33];let M;t[34]!==k||t[35]!==A||t[36]!==j?(M=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[k,A,j]}),t[34]=k,t[35]=A,t[36]=j,t[37]=M):M=t[37];let N;t[38]!==T||t[39]!==D||t[40]!==M||t[41]!==C?(N=(0,$.jsx)(`div`,{ref:d,role:`dialog`,"aria-label":C,className:T,style:D,onPointerDown:ol,children:M}),t[38]=T,t[39]=D,t[40]=M,t[41]=C,t[42]=N):N=t[42];let P;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(`style`,{children:`
5
+ `)}`.trim()),P([])}),Oe=R(async()=>{if(!s)return;let e=s,t=oe.map(e=>e.path).sort();if(t.length===0){J.error(a(`gitView.toast.selectFileToDescribe`));return}M(!0);try{let{message:n}=await at(e,t);E(n.subject?.trim()??``),P(Array.isArray(n.highlights)?n.highlights:[])}catch(e){J.error(e instanceof Error?e.message:a(`gitView.toast.generateCommitMessageFailed`))}finally{M(!1)}}),ke=async(e={})=>{if(!s)return;let t=s;if(!T.trim()){J.error(a(`gitView.toast.enterCommitMessage`));return}let n=oe.map(e=>e.path).sort();if(n.length===0){J.error(a(`gitView.toast.selectFileToCommit`));return}w(e.pushAfter?`commitAndPush`:`commit`);try{if(await o.createGitCommit(t,T.trim(),{files:n}),J.success(a(`gitView.toast.commitCreated`)),E(``),P([]),e.pushAfter){let e=c?.tracking?.split(`/`)[0],n=K.find(t=>t.name===e)??K[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 ve(t,!1),await be(t).promise}else await ve(t,!1)}catch(e){J.error(e instanceof Error?e.message:a(`gitView.toast.createCommitFailed`))}finally{w(null),e.pushAfter&&S(null)}},Ae=Q.useMemo(()=>{let e=[];return oe.length>0&&e.push({id:`staged`,title:a(`gitView.changes.stagedTitle`),entries:oe,actionSymbol:`-`,actionAllLabel:a(`gitView.changes.unstageAllAria`),getActionLabel:e=>a(`gitView.changes.unstageFileAria`,{path:e}),onActionFile:e=>void Se([e],`unstage`),onActionAll:e=>void Se(e,`unstage`),onViewDiff:e=>Ce(e,!0),onRevertFile:Te,showRevertActions:!1,accent:!0}),se.length>0&&e.push({id:`unstaged`,title:a(`gitView.changes.title`),entries:se,actionSymbol:`+`,actionAllLabel:a(`gitView.changes.stageAllAria`),getActionLabel:e=>a(`gitView.changes.stageFileAria`,{path:e}),onActionFile:e=>void Se([e],`stage`),onActionAll:e=>void Se(e,`stage`),onViewDiff:e=>Ce(e,!1),onRevertFile:Te}),e},[Te,Ce,Se,oe,a,se]),je=t=>(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[i?null:(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,children:[e?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":a(`mobile.surface.closeAria`),onClick:e,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label text-foreground`,children:a(`mobile.nav.changes`)}),(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:c?.current||s||``})]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:t})]});return s?u&&l===null?je((0,$.jsx)(Ea,{loading:!0,message:a(`gitView.loading.checkingRepository`)})):l===!1?je((0,$.jsx)(Ea,{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)(Da,{path:v.path,diff:de,fileExists:_e,error:ge,loading:he,targetLine:v.targetLine,onBack:we,onRetry:()=>re(e=>e+1),hideHeader:i})}):(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,children:[e?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":a(`mobile.surface.closeAria`),onClick:e,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label text-foreground`,children:a(`mobile.nav.changes`)}),(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:c?.current||s})]}),(0,$.jsx)(Br,{syncAction:x,remotes:K,onSync:e=>void xe(`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})]}),ae?(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(zr,{stagedCount:ce,unstagedCount:le,onLoad:()=>ie(!0)})}):G.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)(Jr,{groups:Ae,diffStats:c?.diffStats,revertingPaths:D,onRevertAll:Ee,isRevertingAll:k,headerBackgroundClassName:`bg-transparent`,onVisiblePathsChange:I})}),(0,$.jsx)(`div`,{className:`shrink-0 border-t border-border/50 px-4 pb-4 pt-3`,children:(0,$.jsx)(Gr,{stagedCount:oe.length,commitMessage:T,onCommitMessageChange:E,generatedHighlights:N,onInsertHighlights:De,onGenerateMessage:Oe,isGeneratingMessage:j,onCommit:()=>void ke({pushAfter:!1}),onCommitAndPush:()=>void ke({pushAfter:!0}),commitAction:C,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Ea,{icon:!0,message:a(`gitView.empty.cleanTitle`),description:a(`mobile.changes.cleanDescription`)})})]}):je((0,$.jsx)(Ea,{message:a(`gitView.empty.selectSessionOrDirectory`)}))},Ea=e=>{let t=(0,zi.c)(13),{message:n,description:r,loading:i,icon:a}=e,o=i!==void 0&&i,s=a!==void 0&&a,c;t[0]===o?c=t[1]:(c=o?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):null,t[0]=o,t[1]=c);let l;t[2]===s?l=t[3]:(l=s?(0,$.jsx)(X,{name:`git-branch`,className:`size-6 text-muted-foreground`}):null,t[2]=s,t[3]=l);let u;t[4]===n?u=t[5]:(u=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[4]=n,t[5]=u);let d;t[6]===r?d=t[7]:(d=r?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r}):null,t[6]=r,t[7]=d);let f;return t[8]!==c||t[9]!==l||t[10]!==u||t[11]!==d?(f=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[c,l,u,d]})}),t[8]=c,t[9]=l,t[10]=u,t[11]=d,t[12]=f):f=t[12],f},Da=e=>{let t=(0,zi.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=Ln(n)||`text`,t[0]=n,t[1]=p);let m=p,h;t[2]!==d||t[3]!==c||t[4]!==n||t[5]!==f?(h=d?null:(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/50 px-3 text-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":f(`header.actions.backAria`),onClick:c,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-2`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-header text-foreground`,children:n})})]}),t[2]=d,t[3]=c,t[4]=n,t[5]=f,t[6]=h):h=t[6];let g;t[7]!==r||t[8]!==a||t[9]!==i||t[10]!==m||t[11]!==o||t[12]!==l||t[13]!==n||t[14]!==f||t[15]!==s?(g=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:a?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:f(`mobile.changes.diffDetail.loadFailed`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:a}),(0,$.jsx)(Z,{type:`button`,size:`sm`,variant:`outline`,onClick:l,children:f(`diffView.actions.retry`)})]})}):o?(0,$.jsx)(Ea,{loading:!0,message:f(`diffView.state.loadingDiff`)}):i?r?r.isBinary?(0,$.jsx)(Ea,{icon:!0,message:f(`diffView.binary.unavailable`)}):Rn(n)?(0,$.jsx)(Ea,{icon:!0,message:f(`mobile.changes.diffDetail.imageUnavailable`)}):(0,$.jsx)(Fn,{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)(Er,{original:r.original,modified:r.modified,language:m,fileName:n,renderSideBySide:!1,wrapLines:!0,focusLine:s,layout:`inline`})}):(0,$.jsx)(Ea,{loading:!0,message:f(`diffView.state.loadingDiff`)}):(0,$.jsx)(Ea,{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],_},Oa=e(S(),1),ka=`data-oc-motion-id`,Aa=`data-oc-sheet-overscroll`,ja=`html, body { overscroll-behavior-y: none; }`,Ma=[`input`,`textarea`,`select`,`[contenteditable]:not([contenteditable="false"])`,`[data-mobile-sheet-no-dismiss]`].join(`, `),Na=e=>e.closest(`[data-oc-motion-id]`)?.getAttribute(`data-oc-motion-id`)??null,Pa=e=>{try{let t=e.contentDocument;return t?t.scrollingElement??t.documentElement:null}catch{return null}},Fa=(e,t)=>Number.isFinite(e)&&Number.isFinite(t)&&e<=1&&t>0,Ia=(e,t,n)=>e?!0:Fa(t,n),La=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.Element},Ra=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.HTMLElement},za=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.HTMLStyleElement},Ba=(e,t)=>{if(typeof e.item==`function`){let n=e.item(t);if(n)return n}return e[t]??null},Va=(e,t)=>{for(let n=0;n<e.length;n+=1){let r=Ba(e,n);if(r?.identifier===t)return r}return null},Ha=(e,t)=>{try{let n=e.defaultView?.getComputedStyle(t);if(!n)return!1;let r=n.overflowY;return(r===`auto`||r===`scroll`||r===`overlay`)&&t.scrollHeight>t.clientHeight+1}catch{return!1}},Ua=(e,t)=>{let n=[],r=new Set,i=t=>{!t||r.has(t)||Ha(e,t)&&(r.add(t),n.push(t))},a=La(e,t)?t:null;for(;a&&(Ra(e,a)&&i(a),a!==e.documentElement&&a!==e.body);)a=a.parentElement;let o=e.scrollingElement??e.documentElement;return Ra(e,o)&&i(o),n},Wa=(e,t)=>{let n=Ua(e,t);if(n.length===0){let t=(e.scrollingElement??e.documentElement)?.scrollTop??1/0;return Number.isFinite(t)&&t<=1}return n.every(e=>e.scrollTop<=1)},Ga=e=>{let t=e.closest(`[${ka}]`);if(t instanceof HTMLElement){let e=t.getBoundingClientRect().height;if(Number.isFinite(e)&&e>0)return e}return window.innerHeight||1},Ka=e=>{let t=null,n=()=>{t?.(),t=null;let n=(()=>{try{return e.contentDocument}catch{return null}})();if(!n)return;let r=Na(e);if(!r)return;let i=null;if(!za(n,n.querySelector(`style[${Aa}]`))){let e=n.createElement(`style`);e.setAttribute(Aa,`true`),e.textContent=ja,(n.head??n.documentElement).appendChild(e),i=e}let a=null,o=()=>{a?.active&&a.controller.finish(`cancel`),a=null},s=t=>{if(o(),t.touches.length!==1||(La(n,t.target)?t.target:null)?.closest(Ma)||!Wa(n,t.target))return;let r=Ba(t.touches,0);if(!r)return;let i=Ga(e);a={touchId:r.identifier,startX:r.screenX,startY:r.screenY,lastY:r.screenY,lastTime:t.timeStamp,lastVelocityTime:t.timeStamp,velocity:0,motionDistance:i,commitDistance:It(i,.1,40,64),active:!1,controller:null}},c=t=>{if(!a)return;if(t.touches.length!==1){o();return}let i=Va(t.touches,a.touchId);if(!i){o();return}let s=i.screenY-a.startY,c=i.screenX-a.startX,l=t.timeStamp-a.lastTime;if(a.velocity=Nt(a.velocity,i.screenY-a.lastY,l,t.timeStamp-a.lastVelocityTime,1),i.screenY!==a.lastY&&l>0&&(a.lastVelocityTime=t.timeStamp),a.lastY=i.screenY,a.lastTime=t.timeStamp,!a.active){if(!Wa(n,t.target)){a=null;return}if(!Ia(!1,Pa(e)?.scrollTop??0,s)){a=null;return}if(!Pt(`bottom`,c,s,8,1))return;let i=Jt(r);if(!i?.begin(`dismiss`)){a=null;return}a={...a,active:!0,controller:i}}let u=a;if(!u.active)return;t.preventDefault();let d=Lt(`bottom`,c,s);u.controller.update(Rt(d,u.motionDistance))},l=e=>{if(!a)return;let t=a,n=Va(e.changedTouches,t.touchId);if(a=null,!t.active)return;if(!n){t.controller.finish(`cancel`);return}let r=e.timeStamp-t.lastTime;t.velocity=Nt(t.velocity,n.screenY-t.lastY,r,e.timeStamp-t.lastVelocityTime,1),n.screenY!==t.lastY&&r>0&&(t.lastVelocityTime=e.timeStamp),t.lastY=n.screenY,t.lastTime=e.timeStamp;let i=n.screenY-t.startY,o=n.screenX-t.startX,s=Lt(`bottom`,o,i),c=Ft(s,t.velocity,t.commitDistance,.65,12);t.controller.finish(c?`commit`:`cancel`),e.preventDefault()},u=()=>o();n.addEventListener(`touchstart`,s,{capture:!0,passive:!0}),n.addEventListener(`touchmove`,c,{capture:!0,passive:!1}),n.addEventListener(`touchend`,l,{capture:!0,passive:!1}),n.addEventListener(`touchcancel`,u,{capture:!0,passive:!0}),t=()=>{o(),n.removeEventListener(`touchstart`,s,!0),n.removeEventListener(`touchmove`,c,!0),n.removeEventListener(`touchend`,l,!0),n.removeEventListener(`touchcancel`,u,!0);try{i?.remove()}catch{}i=null}};return e.addEventListener(`load`,n),n(),()=>{e.removeEventListener(`load`,n),t?.()}},qa=Pn(()=>M(()=>import(`./ToolOutputDialog-B50L_nUP.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53]))),Ja=25e4,Ya=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Xa=e=>{let t=Ya(e);return!t||t===`/`?t||`/`:t.split(`/`).filter(Boolean).at(-1)??t},Za=e=>{let t=Ya(e);if(!t||t===`/`)return null;let n=t.lastIndexOf(`/`);return n<=0?t.startsWith(`/`)?`/`:null:t.slice(0,n)},Qa=(e,t)=>{let n=Ya(e),r=Ya(t);return!r||n===r?Xa(n):n.startsWith(`${r}/`)?n.slice(r.length+1):n},$a=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``},eo=e=>e.toLowerCase().endsWith(`.svg`)?``:o().authenticatedAsset(`/api/fs/raw`,{path:e}),to=e=>/\.(md|mdx|markdown)$/i.test(e),no=e=>{let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return`/api/fs/serve${t.startsWith(`/`)?t:`/${t}`}`},ro=e=>o().authenticatedAsset(no(e)),io=e=>{let t=(0,zi.c)(148),{onClose:n,initialFilePath:r,directFilePreview:i,hideFileHeader:a}=e,o=r===void 0?null:r,s=i!==void 0&&i,c=a!==void 0&&a,{t:l}=ee(),{files:u}=gn(),d=Vn()??null,f;t[0]===d?f=t[1]:(f=Ya(d),t[0]=d,t[1]=f);let p=f,m;t[2]!==o||t[3]!==p?(m=()=>{let e=Ya(o);return e?{type:`file`,path:e,returnDirectory:Za(e)??p}:{type:`browser`,directory:p}},t[2]=o,t[3]=p,t[4]=m):m=t[4];let[h,g]=Q.useState(m),_=Q.useRef(null),[v,y]=Q.useState(``),b=k(po),x=k(mo),S,C;t[5]===p?(S=t[6],C=t[7]):(S=()=>{p&&g(e=>e.type===`file`?e.returnDirectory?e:{...e,returnDirectory:Za(e.path)??p}:e.type===`browser`&&e.directory?e:{type:`browser`,directory:p})},C=[p],t[5]=p,t[6]=S,t[7]=C),Q.useEffect(S,C);let w,T;t[8]!==b||t[9]!==p||t[10]!==x?(T=()=>{if(!b||!p)return;let e=Ya(b);if(!e){x(null);return}y(``),g({type:`file`,path:e,returnDirectory:Za(e)??p}),x(null)},w=[b,p,x],t[8]=b,t[9]=p,t[10]=x,t[11]=w,t[12]=T):(w=t[11],T=t[12]),Q.useEffect(T,w);let E=h.type===`browser`?h.directory:h.returnDirectory,D=h.type===`browser`?h.directory:``,O=h.type===`file`?h.path:``,[A,j]=Q.useState(`preview`),M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{j(`preview`)},t[13]=M):M=t[13];let N;t[14]===O?N=t[15]:(N=[O],t[14]=O,t[15]=N),Q.useEffect(M,N);let P=yn(v,250),F;t[16]===v?F=t[17]:(F=v.trim(),t[16]=v,t[17]=F);let I=F,L;t[18]===P?L=t[19]:(L=P.trim(),t[18]=P,t[19]=L);let z=L,B;t[20]!==D||t[21]!==p?(B={scopeDirectory:p,directory:D},t[20]=D,t[21]=p,t[22]=B):B=t[22];let V=!!D,ne;t[23]===V?ne=t[24]:(ne={enabled:V,refetchOnMount:`always`},t[23]=V,t[24]=ne);let H=Ci(B,ne),re;t[25]!==D||t[26]!==z?(re={directory:D,query:z,maxResults:40},t[25]=D,t[26]=z,t[27]=re):re=t[27];let U=!!(D&&z),W;t[28]===U?W=t[29]:(W={enabled:U},t[28]=U,t[29]=W);let ie=Si(re,W),ae;t[30]!==O||t[31]!==u||t[32]!==A?(ae=O&&u.readFile&&(!Bn(O)||A===`source`)&&(!Rn(O)||O.toLowerCase().endsWith(`.svg`)),t[30]=O,t[31]=u,t[32]=A,t[33]=ae):ae=t[33];let G=!!ae,oe;t[34]!==O||t[35]!==p?(oe={scopeDirectory:p,path:O},t[34]=O,t[35]=p,t[36]=oe):oe=t[36];let se;t[37]===G?se=t[38]:(se={enabled:G},t[37]=G,t[38]=se);let ce=Ti(oe,se),le;t[39]!==O||t[40]!==p?(le={scopeDirectory:p,path:O},t[39]=O,t[40]=p,t[41]=le):le=t[41];let K;t[42]===G?K=t[43]:(K={enabled:G},t[42]=G,t[43]=K),wi(le,K);let ue=H.data?.entries.slice().sort(ho)??[],de;t[44]!==H.error||t[45]!==l?(de=H.error?H.error instanceof Error?H.error.message:l(`mobile.files.error.listFailed`):null,t[44]=H.error,t[45]=l,t[46]=de):de=t[46];let fe=de,pe=H.isFetching,me;t[47]===ie.data?me=t[48]:(me=ie.data??[],t[47]=ie.data,t[48]=me);let he=me,ge=!!(I&&z&&v===P&&ie.isFetching),_e;t[49]!==ce.data||t[50]!==l?(_e=ce.data&&ce.data.length>Ja?`${ce.data.slice(0,Ja)}\n\n${l(`mobile.files.file.truncated`)}`:ce.data??``,t[49]=ce.data,t[50]=l,t[51]=_e):_e=t[51];let ve=_e,ye;t[52]!==O||t[53]!==ce.error||t[54]!==u||t[55]!==l?(ye=O&&!u.readFile?l(`mobile.files.error.readUnavailable`):ce.error?ce.error instanceof Error?ce.error.message:l(`filesView.error.readFileFailed`):null,t[52]=O,t[53]=ce.error,t[54]=u,t[55]=l,t[56]=ye):ye=t[56];let be=ye,xe=G&&ce.isFetching,Se;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(Se=e=>{y(``),g({type:`browser`,directory:e})},t[57]=Se):Se=t[57];let Ce=Se,we;t[58]!==E||t[59]!==p?(we=e=>{g({type:`file`,path:e,returnDirectory:E||p})},t[58]=E,t[59]=p,t[60]=we):we=t[60];let Te=we,Ee;t[61]!==s||t[62]!==n||t[63]!==h.returnDirectory||t[64]!==h.type?(Ee=()=>h.type===`file`?s?(n?.(),!0):(g({type:`browser`,directory:h.returnDirectory}),!0):!1,t[61]=s,t[62]=n,t[63]=h.returnDirectory,t[64]=h.type,t[65]=Ee):Ee=t[65];let De=R(Ee),Oe=h.type===`file`,ke;t[66]!==De||t[67]!==Oe?(ke={id:`mobile-files-detail`,active:Oe,layer:`overlay`,onBack:De,surfaceRef:_},t[66]=De,t[67]=Oe,t[68]=ke):ke=t[68],En(ke);let Ae;t[69]===l?Ae=t[70]:(Ae=async e=>{(await te(e)).ok||J.error(l(`mobile.files.toast.copyFailed`))},t[69]=l,t[70]=Ae);let je=Ae,Me;t[71]!==ve||t[72]!==l?(Me=async()=>{(await te(ve)).ok?J.success(l(`mobile.files.toast.contentCopied`)):J.error(l(`mobile.files.toast.copyFailed`))},t[71]=ve,t[72]=l,t[73]=Me):Me=t[73];let q=Me;if(!p){let e;t[74]===l?e=t[75]:(e=l(`mobile.files.empty.noDirectory`),t[74]=l,t[75]=e);let n;return t[76]===e?n=t[77]:(n=(0,$.jsx)(fo,{message:e}),t[76]=e,t[77]=n),n}if(h.type===`file`){let e;t[78]!==je||t[79]!==h.path?(e=()=>void je(h.path),t[78]=je,t[79]=h.path,t[80]=e):e=t[80];let n;t[81]===q?n=t[82]:(n=()=>void q(),t[81]=q,t[82]=n);let r;return t[83]!==De||t[84]!==ve||t[85]!==be||t[86]!==c||t[87]!==A||t[88]!==xe||t[89]!==h.path||t[90]!==e||t[91]!==n?(r=(0,$.jsx)(`div`,{ref:_,className:`flex h-full min-h-0 flex-col`,children:(0,$.jsx)(co,{path:h.path,content:ve,error:be,isLoading:xe,hideHeader:c,htmlViewMode:A,onHtmlViewModeChange:j,onBack:De,onCopyPath:e,onCopyContent:n})}),t[83]=De,t[84]=ve,t[85]=be,t[86]=c,t[87]=A,t[88]=xe,t[89]=h.path,t[90]=e,t[91]=n,t[92]=r):r=t[92],r}let Ne;t[93]!==p||t[94]!==h.directory||t[95]!==l?(Ne=h.directory===p?l(`mobile.files.rootDirectory`):Xa(h.directory),t[93]=p,t[94]=h.directory,t[95]=l,t[96]=Ne):Ne=t[96];let Pe=Ne,Fe;t[97]!==v||t[98]!==he?(Fe=v.trim()?he:[],t[97]=v,t[98]=he,t[99]=Fe):Fe=t[99];let Ie=Fe,Le,Re,ze,Be;if(t[100]!==n||t[101]!==v||t[102]!==p||t[103]!==h.directory||t[104]!==l){let e=Za(h.directory),r=h.directory!==p&&e!==null&&(e===p||e.startsWith(`${p}/`)),i=r&&!v.trim(),a=r?e:null;Be=`flex h-full flex-col overflow-hidden bg-background text-foreground`,Le=`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,t[109]!==n||t[110]!==l?(Re=n?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":l(`mobile.surface.closeAria`),onClick:n,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):null,t[109]=n,t[110]=l,t[111]=Re):Re=t[111],ze=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:Xa(a)}),onClick:()=>Ce(a),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}):null,t[100]=n,t[101]=v,t[102]=p,t[103]=h.directory,t[104]=l,t[105]=Le,t[106]=Re,t[107]=ze,t[108]=Be}else Le=t[105],Re=t[106],ze=t[107],Be=t[108];let Ve;t[112]===Pe?Ve=t[113]:(Ve=(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label text-foreground`,children:Pe})}),t[112]=Pe,t[113]=Ve);let He;t[114]===l?He=t[115]:(He=l(`mobile.files.refreshAria`),t[114]=l,t[115]=He);let Ue;t[116]===H?Ue=t[117]:(Ue=()=>void H.refetch(),t[116]=H,t[117]=Ue);let We;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(We={touchAction:`manipulation`},t[118]=We):We=t[118];let Ge=pe&&`animate-spin`,Ke;t[119]===Ge?Ke=t[120]:(Ke=Y(`size-5`,Ge),t[119]=Ge,t[120]=Ke);let qe;t[121]===Ke?qe=t[122]:(qe=(0,$.jsx)(X,{name:`refresh`,className:Ke}),t[121]=Ke,t[122]=qe);let Je;t[123]!==He||t[124]!==Ue||t[125]!==qe?(Je=(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":He,onClick:Ue,style:We,children:qe}),t[123]=He,t[124]=Ue,t[125]=qe,t[126]=Je):Je=t[126];let Ye;t[127]!==Le||t[128]!==Re||t[129]!==ze||t[130]!==Ve||t[131]!==Je?(Ye=(0,$.jsxs)(`header`,{className:Le,children:[Re,ze,Ve,Je]}),t[127]=Le,t[128]=Re,t[129]=ze,t[130]=Ve,t[131]=Je,t[132]=Ye):Ye=t[132];let Xe;t[133]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),t[133]=Xe):Xe=t[133];let Ze;t[134]===Symbol.for(`react.memo_cache_sentinel`)?(Ze=e=>y(e.target.value),t[134]=Ze):Ze=t[134];let Qe;t[135]===l?Qe=t[136]:(Qe=l(`mobile.files.search.placeholder`),t[135]=l,t[136]=Qe);let $e;t[137]!==v||t[138]!==Qe?($e=(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,"data-mobile-sheet-no-dismiss":``,children:(0,$.jsxs)(`div`,{className:`relative`,children:[Xe,(0,$.jsx)(Yt,{type:`text`,inputMode:`search`,value:v,onChange:Ze,placeholder:Qe,className:`h-11 pl-9`})]})}),t[137]=v,t[138]=Qe,t[139]=$e):$e=t[139];let et=Fn,Z=fe?(0,$.jsx)(fo,{message:fe}):v.trim()?(0,$.jsx)(oo,{results:Ie,isSearching:ge,onOpenFile:Te}):(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:[ue.length===0&&!pe?(0,$.jsx)(`div`,{className:`px-4 py-8 text-center typography-body text-muted-foreground`,children:l(`mobile.files.empty.directory`)}):null,ue.map(e=>(0,$.jsx)(ao,{name:e.name,path:e.path,directory:e.isDirectory,meta:e.isDirectory?void 0:$a(e.size),onClick:()=>e.isDirectory?Ce(e.path):Te(e.path)},e.path))]}),tt;t[140]!==et||t[141]!==Z?(tt=(0,$.jsx)(et,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto px-4 pb-3`,children:Z}),t[140]=et,t[141]=Z,t[142]=tt):tt=t[142];let nt;return t[143]!==Be||t[144]!==Ye||t[145]!==$e||t[146]!==tt?(nt=(0,$.jsxs)(`div`,{className:Be,children:[Ye,$e,tt]}),t[143]=Be,t[144]=Ye,t[145]=$e,t[146]=tt,t[147]=nt):nt=t[147],nt},ao=e=>{let t=(0,zi.c)(16),{name:n,path:r,directory:i,meta:a,onClick:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]!==i||t[2]!==r?(c=i?(0,$.jsx)(X,{name:`folder-3-fill`,className:`size-5 shrink-0 text-muted-foreground`}):(0,$.jsx)(vt,{filePath:r,className:`size-5 shrink-0`}),t[1]=i,t[2]=r,t[3]=c):c=t[3];let l;t[4]===n?l=t[5]:(l=(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:n}),t[4]=n,t[5]=l);let u;t[6]===a?u=t[7]:(u=a?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:a}):null,t[6]=a,t[7]=u);let d;t[8]===i?d=t[9]:(d=i?(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground/60`}):null,t[8]=i,t[9]=d);let f;return t[10]!==o||t[11]!==c||t[12]!==l||t[13]!==u||t[14]!==d?(f=(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-14 w-full items-center gap-3 border-b border-border/30 px-3 py-2.5 text-left transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,onClick:o,style:s,children:[c,l,u,d]}),t[10]=o,t[11]=c,t[12]=l,t[13]=u,t[14]=d,t[15]=f):f=t[15],f},oo=e=>{let t=(0,zi.c)(10),{results:n,isSearching:r,onOpenFile:i}=e,{t:a}=ee(),o=Ya(Vn()??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)(fo,{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)(fo,{message:e}),t[6]=e,t[7]=n),n}let s=n.map(e=>(0,$.jsx)(ao,{name:Xa(e.path),path:e.path,directory:!1,meta:Qa(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},so=e=>{let t=(0,zi.c)(24),{path:n,htmlViewMode:r,htmlFullscreen:i,onToggleHtmlViewMode:a,onEnterHtmlFullscreen:o,onCopyPath:s,onCopyContent:c}=e,{t:l}=ee(),u;t[0]===n?u=t[1]:(u=Bn(n),t[0]=n,t[1]=u);let d=u,f;t[2]!==d||t[3]!==i||t[4]!==r||t[5]!==o||t[6]!==a||t[7]!==l?(f=d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,onClick:a,"aria-label":l(r===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(X,{name:r===`preview`?`file-code`:`eye`,className:`size-4`})}),i?null:(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,onClick:o,"aria-label":l(`mobile.files.html.fullscreenAria`),children:(0,$.jsx)(X,{name:`fullscreen`,className:`size-4`})})]}):null,t[2]=d,t[3]=i,t[4]=r,t[5]=o,t[6]=a,t[7]=l,t[8]=f):f=t[8];let p;t[9]!==d||t[10]!==c||t[11]!==n||t[12]!==l?(p=!Rn(n)&&!d?(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,onClick:c,"aria-label":l(`mobile.files.copyContentAria`),children:(0,$.jsx)(X,{name:`file-copy`,className:`size-4`})}):null,t[9]=d,t[10]=c,t[11]=n,t[12]=l,t[13]=p):p=t[13];let m;t[14]===l?m=t[15]:(m=l(`mobile.files.copyPathAria`),t[14]=l,t[15]=m);let h;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(X,{name:`clipboard`,className:`size-4`}),t[16]=h):h=t[16];let g;t[17]!==s||t[18]!==m?(g=(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,onClick:s,"aria-label":m,children:h}),t[17]=s,t[18]=m,t[19]=g):g=t[19];let _;return t[20]!==f||t[21]!==p||t[22]!==g?(_=(0,$.jsxs)($.Fragment,{children:[f,p,g]}),t[20]=f,t[21]=p,t[22]=g,t[23]=_):_=t[23],_},co=e=>{let n=(0,zi.c)(100),{path:r,content:a,error:o,isLoading:c,hideHeader:l,htmlViewMode:f,onHtmlViewModeChange:p,onBack:m,onCopyPath:h,onCopyContent:g}=e,_=l!==void 0&&l,{t:v}=ee(),y=Q.useRef(null),b=Rn(r)&&!r.toLowerCase().endsWith(`.svg`)?r:``,x;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=s(),n[0]=x):x=n[0];let S=x,C;n[1]===b?C=n[2]:(C=b&&i()?`${S}|${b}`:``,n[1]=b,n[2]=C);let w=C,T=b&&!w?`${S}|${b}`:``,[E,D]=Q.useState(``),[O,k]=Q.useState(``),[A,j]=Q.useState(null),[M,N]=Q.useState(!1),P;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(P={open:!1,title:``,content:``},n[3]=P):P=n[3];let[F,I]=Q.useState(P),L,z;n[4]===T?(L=n[5],z=n[6]):(L=()=>{if(!T){D(``);return}let e=!1;return D(``),t(u()).then(t=>{!e&&t&&D(T)}).catch(go),()=>{e=!0}},z=[T],n[4]=T,n[5]=L,n[6]=z),Q.useEffect(L,z);let te,B;n[7]!==b||n[8]!==w||n[9]!==v?(te=()=>{if(!w){k(``),j(null),N(!1);return}let e=!1,t=``;return k(``),j(null),N(!0),d(`/api/fs/raw`,{query:{path:b}}).then(async e=>{if(!e.ok)throw Error(v(`filesView.error.readFileFailed`));return e.blob()}).then(n=>{if(t=URL.createObjectURL(n),e){URL.revokeObjectURL(t);return}k(t)}).catch(t=>{e||j(t instanceof Error?t.message:v(`filesView.error.readFileFailed`))}).finally(()=>{e||N(!1)}),()=>{e=!0,t&&URL.revokeObjectURL(t)}},B=[b,w,v],n[7]=b,n[8]=w,n[9]=v,n[10]=te,n[11]=B):(te=n[10],B=n[11]),Q.useEffect(te,B);let V=!!(T&&E!==T),ne;n[12]!==V||n[13]!==r||n[14]!==w||n[15]!==O?(ne=w?O:V?``:eo(r),n[12]=V,n[13]=r,n[14]=w,n[15]=O,n[16]=ne):ne=n[16];let H=ne,re=o??A,U;n[17]===r?U=n[18]:(U=Xa(r),n[17]=r,n[18]=U);let W=U,ie;n[19]!==a||n[20]!==r?(ie=Rn(r)?`data:${zn(r)};utf8,${encodeURIComponent(a)}`:``,n[19]=a,n[20]=r,n[21]=ie):ie=n[21];let ae=ie,G;n[22]!==a||n[23]!==ae||n[24]!==H||n[25]!==r?(G=H||(Rn(r)&&a?ae:``),n[22]=a,n[23]=ae,n[24]=H,n[25]=r,n[26]=G):G=n[26];let oe=G,se;n[27]!==W||n[28]!==b||n[29]!==r||n[30]!==oe?(se=()=>{let e=b||oe;e&&I({open:!0,title:W,content:``,metadata:{tool:`image-preview`,filename:W,mime:zn(r)},image:{url:e,mimeType:zn(r),filename:W}})},n[27]=W,n[28]=b,n[29]=r,n[30]=oe,n[31]=se):se=n[31];let ce=R(se),le;n[32]===Symbol.for(`react.memo_cache_sentinel`)?(le=e=>{I(t=>t.open===e?t:{...t,open:e})},n[32]=le):le=n[32];let K=R(le),ue;n[33]===r?ue=n[34]:(ue=Bn(r),n[33]=r,n[34]=ue);let de=ue,[fe,pe]=Q.useState(!1),me=Q.useRef(null),he;n[35]===Symbol.for(`react.memo_cache_sentinel`)?(he=()=>{pe(!1)},n[35]=he):he=n[35];let ge;n[36]===r?ge=n[37]:(ge=[r],n[36]=r,n[37]=ge),Q.useEffect(he,ge);let _e;n[38]!==f||n[39]!==p?(_e=()=>{p(f===`preview`?`source`:`preview`)},n[38]=f,n[39]=p,n[40]=_e):_e=n[40];let ve=R(_e),ye;n[41]===Symbol.for(`react.memo_cache_sentinel`)?(ye=()=>{pe(!0)},n[41]=ye):ye=n[41];let be=R(ye),xe;n[42]===Symbol.for(`react.memo_cache_sentinel`)?(xe=()=>(pe(!1),!0),n[42]=xe):xe=n[42];let Se=R(xe),Ce=de&&fe,we;n[43]!==Se||n[44]!==Ce?(we={id:`mobile-html-fullscreen`,active:Ce,layer:`overlay`,onBack:Se,surfaceRef:me},n[43]=Se,n[44]=Ce,n[45]=we):we=n[45],En(we);let Te;n[46]!==be||n[47]!==fe||n[48]!==f||n[49]!==g||n[50]!==h||n[51]!==r||n[52]!==ve?(Te=(0,$.jsx)(so,{path:r,htmlViewMode:f,htmlFullscreen:fe,onToggleHtmlViewMode:ve,onEnterHtmlFullscreen:be,onCopyPath:h,onCopyContent:g}),n[46]=be,n[47]=fe,n[48]=f,n[49]=g,n[50]=h,n[51]=r,n[52]=ve,n[53]=Te):Te=n[53];let Ee=Te,De;n[54]!==a||n[55]!==o||n[56]!==f||n[57]!==c||n[58]!==r||n[59]!==v?(De=f===`source`?c?(0,$.jsx)(fo,{loading:!0,message:v(`filesView.state.loading`)}):o?(0,$.jsx)(fo,{message:o}):(0,$.jsx)(uo,{path:r,content:a}):(0,$.jsx)(lo,{path:r}),n[54]=a,n[55]=o,n[56]=f,n[57]=c,n[58]=r,n[59]=v,n[60]=De):De=n[60];let Oe=De,ke;n[61]!==Se||n[62]!==de||n[63]!==Oe||n[64]!==fe||n[65]!==f||n[66]!==W||n[67]!==v||n[68]!==ve?(ke=de?(0,$.jsxs)(`div`,{ref:me,"data-mobile-html-preview":f===`preview`&&!fe?`true`:void 0,"data-mobile-html-fullscreen":f===`preview`&&fe?`true`:void 0,className:fe?`fixed inset-0 z-[80] flex flex-col bg-background text-foreground`:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[fe?(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center gap-2 border-b border-border/50 px-3 pb-2 pt-[max(0.5rem,env(safe-area-inset-top))]`,children:[(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,onClick:Se,"aria-label":v(`mobile.files.html.exitFullscreenAria`),className:`shrink-0 text-muted-foreground`,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-header text-foreground`,children:W}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,onClick:ve,"aria-label":v(f===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(X,{name:f===`preview`?`file-code`:`eye`,className:`size-4`})})]}):null,(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden bg-background`,children:Oe})]}):null,n[61]=Se,n[62]=de,n[63]=Oe,n[64]=fe,n[65]=f,n[66]=W,n[67]=v,n[68]=ve,n[69]=ke):ke=n[69];let Ae=ke,je;n[70]!==Ee||n[71]!==_||n[72]!==W||n[73]!==m||n[74]!==v?(je=_?(0,$.jsx)(jt,{children:Ee}):(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/50 px-3 text-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":v(`header.actions.backAria`),onClick:m,children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-header text-foreground`,children:W})}),Ee]}),n[70]=Ee,n[71]=_,n[72]=W,n[73]=m,n[74]=v,n[75]=je):je=n[75];let Me;n[76]!==a||n[77]!==de||n[78]!==fe||n[79]!==Ae||n[80]!==V||n[81]!==re||n[82]!==W||n[83]!==c||n[84]!==M||n[85]!==ce||n[86]!==r||n[87]!==oe||n[88]!==v?(Me=de?fe&&typeof document<`u`?(0,Oa.createPortal)(Ae,document.body):Ae:c||V||M?(0,$.jsx)(fo,{loading:!0,message:v(`filesView.state.loading`)}):re?(0,$.jsx)(fo,{message:re}):Rn(r)&&oe?(0,$.jsx)(Fn,{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:ce,"aria-label":W,children:(0,$.jsx)(`img`,{src:oe,alt:W,className:`mx-auto max-h-full max-w-full rounded-lg object-contain`,draggable:!1})})}):(0,$.jsx)(uo,{path:r,content:a}),n[76]=a,n[77]=de,n[78]=fe,n[79]=Ae,n[80]=V,n[81]=re,n[82]=W,n[83]=c,n[84]=M,n[85]=ce,n[86]=r,n[87]=oe,n[88]=v,n[89]=Me):Me=n[89];let q;n[90]===Me?q=n[91]:(q=(0,$.jsx)(`div`,{ref:y,className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:Me}),n[90]=Me,n[91]=q);let Ne;n[92]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=(0,$.jsx)(ct,{containerRef:y}),n[92]=Ne):Ne=n[92];let Pe;n[93]!==K||n[94]!==F?(Pe=F.open?(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(qa,{popup:F,onOpenChange:K,isMobile:!0})}):null,n[93]=K,n[94]=F,n[95]=Pe):Pe=n[95];let Fe;return n[96]!==je||n[97]!==q||n[98]!==Pe?(Fe=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[je,q,Ne,Pe]}),n[96]=je,n[97]=q,n[98]=Pe,n[99]=Fe):Fe=n[99],Fe},lo=e=>{let a=(0,zi.c)(29),{path:o}=e,{t:s}=ee(),c;a[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=i(),a[0]=c):c=a[0];let l=c,f=Q.useRef(null),[p,m]=Q.useState(``),[h,g]=Q.useState(0),[_,v]=Q.useState(null),[y,b]=Q.useState(``),x,S;a[1]!==o||a[2]!==s?(x=()=>{let e=!1;if(m(``),v(null),b(``),l)return d(no(o)).then(async e=>{if(!e.ok)throw Error(s(`filesView.error.readFileFailed`));return e.text()}).then(t=>{e||(b(t),m(o))}).catch(t=>{e||(v(t instanceof Error?t.message:s(`filesView.error.readFileFailed`)),m(o))}),()=>{e=!0};let i=u(),a=n(i);t(i).then(t=>{e||!t||(m(o),v(null))}).catch(t=>{e||(v(t instanceof Error?t.message:s(`filesView.error.readFileFailed`)),m(o))});let c=r(()=>{e||(m(o),g(_o),v(null))});return()=>{e=!0,a(),c()}},S=[o,l,s],a[1]=o,a[2]=s,a[3]=x,a[4]=S):(x=a[3],S=a[4]),Q.useEffect(x,S);let C;a[5]!==o||a[6]!==p?(C=()=>{if(p!==o)return;let e=f.current;if(e)return Ka(e)},a[5]=o,a[6]=p,a[7]=C):C=a[7];let w;if(a[8]!==h||a[9]!==o||a[10]!==p||a[11]!==y?(w=[h,o,p,y],a[8]=h,a[9]=o,a[10]=p,a[11]=y,a[12]=w):w=a[12],Q.useEffect(C,w),_){let e;return a[13]===_?e=a[14]:(e=(0,$.jsx)(fo,{message:_}),a[13]=_,a[14]=e),e}if(p!==o){let e;a[15]===s?e=a[16]:(e=s(`filesView.state.loading`),a[15]=s,a[16]=e);let t;return a[17]===e?t=a[18]:(t=(0,$.jsx)(fo,{loading:!0,message:e}),a[17]=e,a[18]=t),t}let T;a[19]===o?T=a[20]:(T=l?void 0:ro(o),a[19]=o,a[20]=T);let E=l?y:void 0,D;a[21]===Symbol.for(`react.memo_cache_sentinel`)?(D={backgroundColor:`var(--surface-background)`},a[21]=D):D=a[21];let O;a[22]===s?O=a[23]:(O=s(`filesView.editor.htmlPreviewTitle`),a[22]=s,a[23]=O);let k;return a[24]!==h||a[25]!==T||a[26]!==E||a[27]!==O?(k=(0,$.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:(0,$.jsx)(`iframe`,{ref:f,src:T,srcDoc:E,className:`h-full min-h-0 w-full flex-1 border-none bg-background`,style:D,sandbox:`allow-scripts allow-same-origin allow-forms`,title:O},h)}),a[24]=h,a[25]=T,a[26]=E,a[27]=O,a[28]=k):k=a[28],k},uo=e=>{let t=(0,zi.c)(30),{path:n,content:r}=e,{currentTheme:i,availableThemes:a,lightThemeId:o,darkThemeId:s}=dn(),c;t[0]!==a||t[1]!==o?(c=a.find(e=>e.metadata.id===o)??hn(!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)??hn(!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=()=>{jn(l),jn(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(to(n)){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(Fn,{className:`h-full overflow-y-auto px-4 py-4`,children:(0,$.jsx)(Nn,{content:r,enableFileReferences:!1})}),t[13]=r,t[14]=e),e}let g;t[15]===n?g=t[16]:(g=Xa(n),t[15]=n,t[16]=g);let _;t[17]===n?_=t[18]:(_=Ln(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:yr},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)(Fn,{className:`min-h-0 flex-1 overflow-auto bg-[var(--syntax-base-background)]`,children:(0,$.jsx)(I,{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},fo=e=>{let t=(0,zi.c)(7),{message:n,loading:r}=e,i=r!==void 0&&r,a;t[0]===i?a=t[1]:(a=i?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):(0,$.jsx)(X,{name:`folder-open-fill`,className:`size-6 text-muted-foreground`}),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[2]=n,t[3]=o);let s;return t[4]!==a||t[5]!==o?(s=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[a,o]})}),t[4]=a,t[5]=o,t[6]=s):s=t[6],s};function po(e){return e.pendingFileFocusPath}function mo(e){return e.setPendingFileFocusPath}function ho(e,t){return e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1}function go(){}function _o(e){return e+1}var vo=v(e=>({expandedParents:{},toggleParent:t=>e(e=>{let n={...e.expandedParents};return n[t]?delete n[t]:n[t]=!0,{expandedParents:n}})})),yo=v()(y(e=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(t,n)=>e(e=>({projectExpanded:{...e.projectExpanded,[t]:n}})),setWorktreeExpanded:(t,n)=>e(e=>({worktreeExpanded:{...e.worktreeExpanded,[t]:n}}))}),{name:`mobile-session-tree`,storage:p()}));typeof window<`u`&&a(e=>{l(e)&&yo.persist.rehydrate()});var bo=36,xo=18,So=e=>e.parentID??null,Co=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),wo=e=>{let t=e;return Co(t.directory??t.project?.worktree??null)},To=e=>{let t=Co(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},Eo=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},Do=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),Oo=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))},ko=(e,t)=>{let n=Co(e),r=Co(t);return!!(n&&r&&(n===r||n.startsWith(`${r}/`)))},Ao=(e,t)=>e.worktrees.find(e=>Co(e.path)===t)??null,jo=(e,t)=>t===e.path||!!Ao(e,t),Mo=(e,t)=>{let n=Co(t);return n?e.find(e=>jo(e,n))??null:null},No=(e,t,n)=>!n||`${e.title??``} ${e.id} ${wo(e)} ${t}`.toLowerCase().includes(n),Po=e=>{let t=(0,zi.c)(14),{project:n,size:r}=e,i=r===void 0?`md`:r,a=i===`sm`?`size-6 rounded-md`:`size-8 rounded-lg`,o=i===`sm`?`size-3.5`:`size-4`,s=n.icon?Wt[n.icon]:null,c=n.color?Kt[n.color]:void 0,l=s??`folder-open`,u;t[0]===c?u=t[1]:(u=c?{color:c}:void 0,t[0]=c,t[1]=u);let d;t[2]!==o||t[3]!==l||t[4]!==u?(d=(0,$.jsx)(X,{name:l,className:o,style:u}),t[2]=o,t[3]=l,t[4]=u,t[5]=d):d=t[5];let f=d,p;t[6]===a?p=t[7]:(p=Y(`flex shrink-0 items-center justify-center overflow-hidden text-muted-foreground`,a),t[6]=a,t[7]=p);let m;t[8]!==f||t[9]!==n?(m=n.iconImage?(0,$.jsx)(Ht,{project:n,className:`size-full object-contain`,fallback:f}):f,t[8]=f,t[9]=n,t[10]=m):m=t[10];let h;return t[11]!==p||t[12]!==m?(h=(0,$.jsx)(`span`,{className:p,children:m}),t[11]=p,t[12]=m,t[13]=h):h=t[13],h},Fo=e=>{let t=(0,zi.c)(5),{expanded:n}=e,r=n?`rotate-0`:`-rotate-90`,i;t[0]===r?i=t[1]:(i=Y(`flex size-5 shrink-0 items-center justify-center text-muted-foreground/70 transition-transform duration-150`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4`}),t[2]=a):a=t[2];let o;return t[3]===i?o=t[4]:(o=(0,$.jsx)(`span`,{"aria-hidden":!0,className:i,children:a}),t[3]=i,t[4]=o),o},Io=e=>{let t=(0,zi.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},Lo=e=>{let t=(0,zi.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=Y(`flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,r),t[2]=r,t[3]=s);let c;t[4]===n?c=t[5]:(c=e=>{e.stopPropagation(),n()},t[4]=n,t[5]=c);let l,u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l={touchAction:`manipulation`},u=(0,$.jsx)(X,{name:`node-tree`,className:`size-4`}),t[6]=l,t[7]=u):(l=t[6],u=t[7]);let d;return t[8]!==o||t[9]!==s||t[10]!==c?(d=(0,$.jsx)(`button`,{type:`button`,className:s,"aria-label":o,title:o,onClick:c,style:l,children:u}),t[8]=o,t[9]=s,t[10]=c,t[11]=d):d=t[11],d},Ro=e=>{let t=(0,zi.c)(10),{icon:n,label:r,onClick:i,destructive:a}=e,o=a!==void 0&&a?`destructive`:`ghost`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,$.jsx)(X,{name:n,className:`size-5 shrink-0`}),t[1]=n,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[3]=r,t[4]=l);let u;return t[5]!==i||t[6]!==o||t[7]!==c||t[8]!==l?(u=(0,$.jsxs)(Z,{type:`button`,variant:o,size:`default`,className:`min-h-12 w-full justify-start gap-3 rounded-xl px-3 typography-ui-label`,onClick:i,style:s,children:[c,l]}),t[5]=i,t[6]=o,t[7]=c,t[8]=l,t[9]=u):u=t[9],u},zo=e=>{let t=(0,zi.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=Oo(Eo(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,te;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){te=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=Y(`relative flex items-center gap-1 transition-colors`,e,a),t[36]=e,t[37]=a,t[38]=N):N=t[38],t[39]!==y||t[40]!==v||t[41]!==i||t[42]!==l||t[43]!==b?(P=v&&l?(0,$.jsx)(`button`,{type:`button`,className:`absolute z-10 flex w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,style:{left:Math.max(i-32,2),top:0,bottom:0,touchAction:`manipulation`},"aria-label":b(y?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:e=>{e.stopPropagation(),l()},children:(0,$.jsx)(X,{name:`arrow-down-s`,className:Y(`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=Y(`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=Y(`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=Y(`block min-w-0 flex-1 truncate typography-ui-label`,f),t[54]=f,t[55]=F),I=g?an(te,g):te,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]=te}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],te=t[35];let B;t[56]!==F||t[57]!==I?(B=(0,$.jsx)(`span`,{className:F,children:I}),t[56]=F,t[57]=I,t[58]=B):B=t[58];let V;t[59]===S?V=t[60]:(V=S?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:S}):null,t[59]=S,t[60]=V);let ne;t[61]!==B||t[62]!==V||t[63]!==L||t[64]!==R?(ne=(0,$.jsxs)(`span`,{className:L,children:[R,B,V]}),t[61]=B,t[62]=V,t[63]=L,t[64]=R,t[65]=ne):ne=t[65];let H;t[66]!==a||t[67]!==g?(H=a?(0,$.jsx)(`span`,{className:`block truncate typography-micro text-muted-foreground pl-4`,children:g?an(a,g):a}):null,t[66]=a,t[67]=g,t[68]=H):H=t[68];let re;t[69]!==ne||t[70]!==H||t[71]!==z?(re=(0,$.jsxs)(`span`,{className:z,children:[ne,H]}),t[69]=ne,t[70]=H,t[71]=z,t[72]=re):re=t[72];let U;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]!==re?(U=(0,$.jsx)(`button`,{type:C,className:w,style:T,onClick:E,onPointerDown:D,onPointerMove:O,onPointerUp:k,onPointerCancel:A,onContextMenu:j,disabled:M,children:re}),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]=re,t[84]=U):U=t[84];let W;t[85]!==p||t[86]!==m?(W=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)(fr,{})}):null,t[85]=p,t[86]=m,t[87]=W):W=t[87];let ie;t[88]!==_||t[89]!==f||t[90]!==d||t[91]!==b||t[92]!==te?(ie=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:te}),onClick:f,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`archive`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label`,children:b(`sessions.sidebar.bulkActions.archive`)})]}):null,(0,$.jsx)(`button`,{type:`button`,className:`mr-1.5 flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":b(_?`mobile.sessions.cancelArchiveAria`:`mobile.sessions.archiveSessionAria`,{title:te}),onClick:d,style:{touchAction:`manipulation`},children:_?(0,$.jsx)(X,{name:`close`,className:`size-4`}):(0,$.jsx)(X,{name:`archive`,className:`size-4`})})]}):null,t[88]=_,t[89]=f,t[90]=d,t[91]=b,t[92]=te,t[93]=ie):ie=t[93];let ae;return t[94]!==N||t[95]!==P||t[96]!==U||t[97]!==W||t[98]!==ie?(ae=(0,$.jsxs)(`div`,{className:N,children:[P,U,W,ie]}),t[94]=N,t[95]=P,t[96]=U,t[97]=W,t[98]=ie,t[99]=ae):ae=t[99],ae},Bo=e=>{let t=(0,zi.c)(15),{indent:n,showMore:r,showFewer:i,loadingMore:a,onShowMore:o,onShowFewer:s}=e,c=a!==void 0&&a,{t:l}=ee();if(!r&&!i)return null;let u;t[0]===n?u=t[1]:(u={paddingLeft:n,touchAction:`manipulation`},t[0]=n,t[1]=u);let d;t[2]!==s||t[3]!==i||t[4]!==l?(d=i?(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-left transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,onClick:s,children:[(0,$.jsx)(X,{name:`arrow-up-s`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-micro`,children:l(`sessions.sidebar.group.showFewer`)})]}):null,t[2]=s,t[3]=i,t[4]=l,t[5]=d):d=t[5];let f;t[6]!==c||t[7]!==o||t[8]!==r||t[9]!==l?(f=r?(0,$.jsxs)(`button`,{type:`button`,className:Y(`inline-flex items-center gap-1.5 text-left transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset disabled:pointer-events-none disabled:opacity-60`,c&&`animate-pulse`),onClick:o,disabled:c,children:[(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-micro`,children:l(`sessions.sidebar.group.showMore`)})]}):null,t[6]=c,t[7]=o,t[8]=r,t[9]=l,t[10]=f):f=t[10];let p;return t[11]!==u||t[12]!==d||t[13]!==f?(p=(0,$.jsxs)(`div`,{className:`flex min-h-10 w-full items-center gap-3 py-1.5 pr-3 text-muted-foreground`,style:u,children:[d,f]}),t[11]=u,t[12]=d,t[13]=f,t[14]=p):p=t[14],p},Vo=({open:e,onOpenChange:t,variant:n=`sheet`})=>{let{t:r}=ee(),{git:i}=gn(),a=de(),o=Fe(e=>e.activeSessions),s=Fe(e=>e.activePaginationByDirectory),c=Ie(e=>e.projects),l=Ie(e=>e.activeProjectId),u=C(e=>e.currentDirectory),d=q(e=>e.currentSessionId),f=q(e=>e.availableWorktreesByProject),p=q(e=>e.setCurrentSession),m=q(e=>e.archiveSession),h=q(e=>e.archiveSessions),g=q(e=>e.updateSessionTitle),_=q(e=>e.requestSessionSmartTitle),v=q(e=>e.shareSession),y=q(e=>e.unshareSession),b=q(e=>e.openNewSessionDraft),x=Ie(e=>e.setActiveProject),S=Ie(e=>e.setActiveProjectIdOnly),w=Ie(e=>e.removeProject),T=Ue(),E=Ve(),D=yo(e=>e.projectExpanded),O=yo(e=>e.worktreeExpanded),k=yo(e=>e.setProjectExpanded),A=yo(e=>e.setWorktreeExpanded),j=Et(e=>e.orderByProject),M=vo(e=>e.expandedParents),N=vo(e=>e.toggleParent),[P,F]=Q.useState(``),[I,L]=Q.useState(null),[z,B]=Q.useState(null),[V,ne]=Q.useState(0),[H,re]=Q.useState(!1),[U,W]=Q.useState(!1),[ie,ae]=Q.useState(null),[G,oe]=Q.useState(null),[se,ce]=Q.useState(null),[le,K]=Q.useState(null),[ue,fe]=Q.useState(null),[pe,me]=Q.useState(``),[he,ge]=Q.useState(!1),[_e,ye]=Q.useState(null),be=Q.useRef(null);be.current||=Hn({onPressedKeyChange:K});let[xe,Se]=Q.useState(new Set),[Ce,we]=Q.useState(new Map),[Ee,De]=Q.useState(new Map),Oe=Tr(),ke=Cr(),je=R(e=>{ve(e),Be(e)}),Me=R(e=>{Promise.all(e.map(e=>(ve(e),Be(e))))});Q.useEffect(()=>{if(!e){F(``),De(new Map),L(null),B(null),oe(null),fe(null),ye(null),be.current?.reset();return}},[e]),Q.useEffect(()=>()=>{be.current?.reset()},[]),Q.useEffect(()=>{if(!e)return;if(c.length===0){q.setState(e=>{let t=Sr(e.availableWorktreesByProject,new Set,[]);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:[]}}),Se(e=>e.size===0?e:new Set),we(e=>e.size===0?e:new Map);return}let t=!1;return(async()=>{let e=await Promise.all(c.map(async e=>{let n=Co(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([qt({id:e.id,path:n},{isCurrent:()=>!t}),Ut(n)]);return{id:e.id,path:n,gitStatus:`success`,isGitRepo:r,worktreeStatus:a.status===`fulfilled`?`success`:`failed`,worktrees:a.status===`fulfilled`?a.value.worktrees:void 0,rootBranchStatus:o.status===`fulfilled`?`success`:`failed`,rootBranch:o.status===`fulfilled`?o.value:void 0}}));if(t)return;let n=new Set(c.map(e=>Co(e.path)).filter(Boolean)),r=e.flatMap(e=>e?.worktreeStatus?[{path:e.path,status:e.worktreeStatus,worktrees:e.worktrees}]:[]);q.setState(e=>{let t=Sr(e.availableWorktreesByProject,n,r);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:Array.from(t.values()).flat()}}),Se(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 Do(r,t)?t:r}),we(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,V]);let Ne=Q.useMemo(()=>c.map(e=>({id:e.id,label:To(e.path),path:Co(e.path),icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:xe.has(Co(e.path)),worktrees:xt(j[e.id],f.get(Co(e.path))??[])})),[xe,c,j,f]),Pe=Q.useMemo(()=>{let e=new Map(a.map(e=>[e.id,e])),t=o.map(t=>{let n=e.get(t.id);return n?Ae(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]),Le=P.trim().toLowerCase(),Re=Q.useMemo(()=>{let e=Ne.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===l})),t=(e,t,n)=>{let r=Co(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||To(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 Pe){let r=wo(n);if(!r)continue;let i=Co(r),a=e.find(e=>jo(e.project,i));if(!a)continue;let o=Ao(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)=>Te(t)-Te(e));for(let n of e.sessions)So(n)||(t.totalSessions+=1)}return e},[l,Ne,Pe]),He=Co(u),We=e=>e.isActive?He===e.project.path?e.project.path:e.project.worktrees.find(e=>ko(He,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=>{De(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},Ye=()=>{oe(null),be.current?.reset()},Xe=e=>({pressed:le===e.key||G?.key===e.key,onPointerDown:t=>{t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||be.current?.start({pointerId:t.pointerId,key:e.key,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>oe(e)})},onPointerMove:e=>{be.current?.move(e.pointerId,e.clientX,e.clientY)},onPointerUp:e=>{be.current?.end(e.pointerId)},onPointerCancel:e=>{be.current?.cancel(e.pointerId)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),be.current?.openFromContextMenu(e.key,()=>oe(e))}}),Ze=(e,t)=>{be.current?.consumeClick(e)||t()},Qe=(e,t,n,r)=>{let i=pr(),a=Xr();if(De(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=Co(t);if(!o)return;let s=Fe.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&ze(o)},$e=(e,t,n)=>{let i=`${e.project.id}::${t.key}`,a=pr(),o=new Set(t.sessions.map(e=>e.id)),c=new Map;for(let e of t.sessions){let t=So(e);if(t&&o.has(t)){let n=c.get(t)??[];n.push(e),c.set(t,n)}}let l=t.sessions.filter(e=>!So(e)),u=Ee.get(i)??a,f=vr(l,u,ke),p=l.length-f.length,m=s.get(Co(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=Oe.has(e.id),s=i&&!a?n.filter(e=>Oe.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)(zo,{session:e,active:d===e.id,indent:t,hasChildren:i,expanded:a,onToggleChildren:i?()=>N(e.id):void 0,confirmingArchive:z===e.id,onSelect:()=>Ze(p,()=>nt(e)),onRequestArchive:()=>rt(e.id),onConfirmArchive:()=>void it(e),onStop:o||l?()=>Me(u):void 0,stopAriaLabel:r(l?`mobile.sessions.stopSubsessionsAria`:`mobile.sessions.stopSessionAria`,{title:f}),longPressHandlers:Xe({key:p,kind:`session`,session:e})}),i&&a?n.map(e=>v(e,t+xo)):null]},e.id)};return(0,$.jsxs)(`div`,{children:[f.map(e=>v(e,n)),(0,$.jsx)(Bo,{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=>{Vt();let n=wo(e)||null,r=Mo(Ne,n??``);r&&S(r.id),p(e.id,n),t(!1)},rt=e=>{B(t=>t===e?null:e)},it=async e=>{B(null),await m(e.id)?Rr({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`)}):J.error(r(`sessions.sidebar.session.archive.error`))},at=()=>{b(),t(!1)},ot=e=>{ae(e),S(e),W(!0)},st=e=>{let t=new Map;for(let e of Pe){let n=So(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},ct=async e=>{let t=st(e.id),{archivedIds:n,failedIds:i}=await h(t);n.length>0&&Rr({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&&J.error(i.length===1?r(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):r(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}))},lt=e=>{let t=st(e.id);br({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){J.error(r(`sessions.sidebar.session.share.error`));return}J.success(r(`sessions.sidebar.session.share.successTitle`),{description:r(`sessions.sidebar.session.share.successDescription`)})}catch{J.error(r(`sessions.sidebar.session.share.error`))}},ft=async e=>{if((await te(e)).ok){J.success(r(`sessions.sidebar.session.menu.copied`));return}J.error(r(`sessions.sidebar.session.share.copyUrlError`))},pt=async e=>{try{if(await y(e)){J.success(r(`sessions.sidebar.session.unshare.success`));return}J.error(r(`sessions.sidebar.session.unshare.error`))}catch{J.error(r(`sessions.sidebar.session.unshare.error`))}},mt=async()=>{if(!ue)return;let e=pe.trim();if(e)try{await g(ue.id,e),fe(null),me(``)}catch{J.error(r(`sessions.sidebar.session.menu.rename`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},ht=async()=>{if(!ue||he)return;let e=ue.id;fe(null),me(``),ge(!0);try{await _(e)}catch{J.error(r(`sessions.sidebar.session.rename.smartTitle`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{ge(!1)}},gt=(e,n)=>{S(e.id),b({selectedProjectId:e.id,directoryOverride:n,preserveDirectoryOverride:!0}),t(!1)},_t=e=>{(async()=>{try{await qt({id:e.id,path:e.path})}catch(e){console.warn(`[MobileSessions] Worktree refresh before session sync failed:`,e)}let t=q.getState().availableWorktreesByProject.get(e.path)??e.worktrees,n=[e.path,...t.map(e=>e.path)];await Je(n,Pe)})()},vt=e=>{let t=wo(e),n=Mo(Ne,t);if(!n)return To(t)||t;let r=Ao(n,Co(t));return r?.branch?`${n.label} · ${r.branch}`:n.label},yt=e=>{x(e.id),t(!1)},bt=Q.useMemo(()=>Le?Re.filter(e=>`${e.project.label} ${e.project.path}`.toLowerCase().includes(Le)?!0:e.buckets.some(t=>t.sessions.some(t=>No(t,e.project.label,Le)))):Re,[Le,Re]),St=Q.useMemo(()=>Le?Pe.filter(e=>{let t=wo(e);return No(e,Mo(Ne,t)?.label??``,Le)}).sort((e,t)=>Te(t)-Te(e)):[],[Le,Ne,Pe]),Ct=Q.useMemo(()=>Le?Ne.filter(e=>`${e.label} ${e.path}`.toLowerCase().includes(Le)).map(e=>({...e,sessionCount:Pe.filter(t=>!So(t)&&jo(e,Co(wo(t)))).length})):[],[Le,Ne,Pe]),wt=Le&&St.length===0&&Ct.length===0,Tt=Ne.length>0?(0,$.jsxs)(Z,{type:`button`,variant:`default`,size:`sm`,"aria-label":r(`mobile.sessions.newChat`),onClick:at,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`add`,className:`size-4`}),r(`mobile.sessions.newChat`)]}):null,Dt=Ne.find(e=>e.id===l)??null,Ot=Dt?.isGitRepo?(0,$.jsx)(Z,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.project.actions.newWorktree`),title:r(`sessions.sidebar.project.actions.newWorktree`),onClick:()=>ot(Dt.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`node-tree`,className:`size-4`})}):null,kt=(0,$.jsx)(Z,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.header.actions.addProject`),title:r(`sessions.sidebar.header.actions.addProject`),onClick:()=>re(!0),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`folder-add`,className:`size-4`})}),At=Tt||kt?(0,$.jsxs)($.Fragment,{children:[Tt,Ot,kt]}):null,jt=G?.kind===`project`?G.project.label:G?.kind===`worktree`?G.worktree.branch||G.worktree.label||G.worktree.path:G?.kind===`session`?G.session.title?.trim()||r(`mobile.sessions.untitled`):``,Mt=Q.useMemo(()=>{if(!G)return[];if(G.kind===`project`){let e=G.project;return Qr({gitRepository:e.isGitRepo,onNewSession:()=>{Ye(),gt(e,e.path)},onNewWorktree:()=>{Ye(),ot(e.id)},onSyncSessions:()=>{Ye(),_t(e)},onEditProject:()=>{Ye(),L(e.id)},onCloseProject:()=>{Ye(),ce(e)}})}if(G.kind===`worktree`){let{project:e,worktree:t}=G;return Zr({onNewSession:()=>{Ye(),gt(e,t.path)},onDeleteWorktree:()=>{Ye(),ye({project:e,worktree:t})}})}let e=G.session,t=!!e.share?.url;return Ar({pinned:T.has(e.id),shared:t,onRename:()=>{Ye(),me(e.title?.trim()||r(`mobile.sessions.untitled`)),fe(e)},onTogglePin:()=>{Ye(),E(e.id)},onShare:t?void 0:()=>{Ye(),dt(e)},onCopyLink:t?()=>{let t=e.share?.url;Ye(),t&&ft(t)}:void 0,onUnshare:t?()=>{Ye(),pt(e.id)}:void 0,onArchive:()=>{Ye(),ct(e)},onDelete:()=>{Ye(),lt(e)}})},[G,Ye,ct,ft,lt,ot,dt,pt,T,gt,_t,r,E]),Nt=Mt.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:Mt.map(e=>{let t=(0,$.jsx)(Ro,{icon:e.icon,label:xr(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,Pt=(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(Yt,{value:P,onChange:e=>F(e.target.value),placeholder:r(`mobile.sessions.search.placeholder`),className:Y(`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)(X,{name:`close`,className:`size-4`})}):null]})}),(0,$.jsx)(Fn,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto pb-4`,children:Ne.length===0?(0,$.jsx)(Ho,{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:()=>re(!0),children:[(0,$.jsx)(X,{name:`folder-add`,className:`size-4`}),r(`sessions.sidebar.header.actions.addProject`)]})}):wt?(0,$.jsx)(Ho,{title:r(`mobile.sessions.empty.searchTitle`),description:r(`mobile.sessions.empty.searchDescription`)}):Le?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-3 pt-2`,children:[St.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:St.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:St.map((e,t)=>{let n=Oe.has(e.id),i=e.title?.trim()||r(`mobile.sessions.untitled`);return(0,$.jsx)(`div`,{className:Y(t>0&&`border-t border-border/30`),children:(0,$.jsx)(zo,{session:e,active:d===e.id,indent:12,contextLabel:vt(e),highlightQuery:Le,onSelect:()=>Ze(`session:${e.id}`,()=>nt(e)),longPressHandlers:Xe({key:`session:${e.id}`,kind:`session`,session:e}),onStop:n?()=>je(e.id):void 0,stopAriaLabel:r(`mobile.sessions.stopSessionAria`,{title:i})})},e.id)})})]}):null,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.projects`)}),(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=`project:${e.id}`,r=Xe({key:n,kind:`project`,project:e});return(0,$.jsxs)(`div`,{className:Y(`flex items-center`,t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`button`,{type:`button`,className:Y(`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:()=>Ze(n,()=>yt(e)),onPointerDown:r.onPointerDown,onPointerMove:r.onPointerMove,onPointerUp:r.onPointerUp,onPointerCancel:r.onPointerCancel,onContextMenu:r.onContextMenu,style:{touchAction:`manipulation`},children:[(0,$.jsx)(Po,{project:e}),(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:an(e.label,Le)}),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.sessionCount})]}),e.isGitRepo?(0,$.jsx)(Lo,{className:`mr-2`,onClick:()=>ot(e.id)}):null]},e.id)})})]}):null]}):(0,$.jsx)(`div`,{className:`flex flex-col`,children:bt.map((e,t)=>{let n=Ge(e),i=`project:${e.project.id}`,a=Xe({key:i,kind:`project`,project:e.project}),o=Le?e.buckets.filter(t=>t.sessions.some(t=>No(t,e.project.label,Le))):e.buckets,s=We(e);return(0,$.jsxs)(`section`,{className:Y(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:Y(`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:()=>Ze(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)(Po,{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}),Ce.get(e.project.id)?(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 typography-micro text-muted-foreground`,children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:Ce.get(e.project.id)})]}):null]}),e.isActive?(0,$.jsx)(Io,{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=>Oe.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(),Me(t)},style:{touchAction:`manipulation`},children:(0,$.jsx)(fr,{})}):null})(),e.project.isGitRepo?(0,$.jsx)(Lo,{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,bo):null,n.map(t=>{let n=Ke(e,t),i=s===t.path,a=`worktree:${e.project.id}:${t.key}`,o=Xe({key:a,kind:`worktree`,project:e.project,worktree:t.worktree});return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,className:Y(`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:()=>Ze(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)(Fo,{expanded:n}),(0,$.jsx)(X,{name:`node-tree`,className:Y(`size-4 shrink-0`,i?`text-primary`:`text-muted-foreground`)}),(0,$.jsx)(`span`,{className:Y(`block min-w-0 flex-1 truncate typography-ui-label font-semibold`,i?`text-foreground`:`text-foreground/90`),children:t.label}),i?(0,$.jsx)(Io,{ariaLabel:r(`mobile.sessions.activeWorktreeAria`)}):null,(()=>{let e=n?[]:t.sessions.filter(e=>Oe.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(),Me(e)},style:{touchAction:`manipulation`},children:(0,$.jsx)(fr,{})}):null})(),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:t.sessions.length})]}),n?$e(e,t,bo):null]},t.key)})]})})()}):null]},e.project.id)})})}),(0,$.jsx)(Ur,{open:H,onOpenChange:re,forceMobile:!0}),(0,$.jsx)(ut,{open:U,projectId:ie,onOpenChange:e=>{W(e),e||ae(null)},onWorktreeCreated:(e,n)=>{n?.sessionId?p(n.sessionId,e):b({selectedProjectId:ie,directoryOverride:e,preserveDirectoryOverride:!0}),t(!1)}}),(0,$.jsx)(un,{open:!!G,title:jt,onClose:Ye,contentMaxHeightClassName:`max-h-[min(68dvh,560px)]`,children:Nt}),(0,$.jsx)(un,{open:!!se,title:r(`sessions.sidebar.project.actions.closeProject`),onClose:()=>ce(null),closeAriaLabel:r(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Z,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>ce(null),children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Z,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!se)return;let e=se;ce(null),w(e.id),J.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:se?.label??``})})}),(0,$.jsx)(un,{open:!!ue,title:r(`sessions.sidebar.session.menu.rename`),onClose:()=>{he||(fe(null),me(``))},footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Z,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:he,onClick:()=>{fe(null),me(``)},children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Z,{type:`button`,variant:`default`,className:`flex-1`,disabled:!pe.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)(Yt,{value:pe,onChange:e=>me(e.target.value),autoFocus:!0,className:`h-12`,disabled:he}),(0,$.jsxs)(Z,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:he,onClick:()=>void ht(),children:[he?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`ai-generate-2`,className:`size-4`}),r(`sessions.sidebar.session.rename.smartTitle`)]})]})}),_e?(0,$.jsx)(mr,{open:!0,project:{id:_e.project.id,path:_e.project.path},worktree:_e.worktree,onClose:()=>ye(null),onDeleted:()=>ne(e=>e+1)}):null,(0,$.jsx)(hr,{open:I!==null,project:Ne.find(e=>e.id===I)??null,onClose:()=>L(null),onWorktreesChanged:()=>ne(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:At?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:At}):null}),Pt]}):null:(0,$.jsx)(Gt,{id:`mobile-sessions-sheet`,open:e,onOpenChange:t,trailing:At,ariaLabel:r(`mobile.sessions.sheet.title`),closeAriaLabel:r(`mobile.surface.closeAria`),resizeAriaLabel:r(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:Pt})},Ho=e=>{let t=(0,zi.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},Uo=`/assets/assistant-guide-hero-wide-DiFIThB0.jpg`,Wo=[{image:ai,titleKey:`assistants.guide.share.ios.title`,descriptionKey:`assistants.guide.share.ios.description`},{image:ei,titleKey:`assistants.guide.share.android.title`,descriptionKey:`assistants.guide.share.android.description`},{image:ri,titleKey:`assistants.guide.share.pick.title`,descriptionKey:`assistants.guide.share.pick.description`}];function Go(){let e=(0,zi.c)(8),{t}=ee(),n;e[0]===t?n=e[1]:(n=t(`common.loading`),e[0]=t,e[1]=n);let r,i,a,o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`div`,{className:`h-10 w-10 animate-pulse rounded-xl bg-[var(--surface-muted)] motion-reduce:animate-none`}),i=(0,$.jsx)(`div`,{className:`mt-2 h-4 w-2/3 animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),a=(0,$.jsx)(`div`,{className:`h-3.5 w-full animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),o=(0,$.jsx)(`div`,{className:`h-3.5 w-4/5 animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`}),e[2]=r,e[3]=i,e[4]=a,e[5]=o):(r=e[2],i=e[3],a=e[4],o=e[5]);let s;return e[6]===n?s=e[7]:(s=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3 p-5`,"aria-busy":`true`,"aria-label":n,children:[r,i,a,o]}),e[6]=n,e[7]=s),s}function Ko(e){let t=(0,zi.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:Uo,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)(Z,{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=Wo.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 qo({unreadCount:e,assistantID:t,displayName:n,avatarEmoji:r,summary:i,enabled:a,editLabel:o,deleteLabel:s,onOpen:c,onEdit:l,onDelete:u,serverWorking:d=!1}){let f=di(t,d),[p,m]=Q.useState(!1),[h,g]=Q.useState(!1),_=Q.useRef(null);_.current||=Hn({onPressedKeyChange:e=>g(e===t)}),Q.useEffect(()=>()=>_.current?.reset(),[]);let v=R(()=>{_.current?.consumeClick(t)||p||c()}),y=R(()=>{m(!1),l()}),b=R(()=>{m(!1),u()}),x=R(()=>{g(!1),m(!0)}),S=R(e=>{e.pointerType!==`touch`&&e.pointerType!==`pen`||e.button!==0||_.current?.start({pointerId:e.pointerId,key:t,clientX:e.clientX,clientY:e.clientY,onTrigger:x})}),C=R(e=>{_.current?.move(e.pointerId,e.clientX,e.clientY)}),w=R(e=>{_.current?.end(e.pointerId)}),T=R(e=>{_.current?.cancel(e.pointerId)}),E=R(e=>{e.preventDefault(),e.stopPropagation(),_.current?.openFromContextMenu(t,x)});return(0,$.jsxs)(xi,{open:p,onOpenChange:m,children:[(0,$.jsx)(nr,{"data-mobile-press-surface":`soft`,className:Y(`oc-mobile-assistant-card-shell`,h&&`bg-interactive-hover`),children:(0,$.jsxs)(_i,{render:(0,$.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":`false`,"data-mobile-press-surface-trigger":!0,className:Y(`oc-mobile-assistant-card`,!a&&`opacity-65`),onClick:v,onPointerDown:S,onPointerMove:C,onPointerUp:w,onPointerCancel:T,onContextMenu:E,style:{touchAction:`pan-y`}}),children:[(0,$.jsx)(`span`,{className:Y(`oc-mobile-assistant-avatar`,r?`oc-mobile-assistant-avatar--emoji`:`oc-mobile-assistant-avatar--visual`),children:(0,$.jsx)(pi,{name:t,emoji:r,size:40,label:n,working:f})}),(0,$.jsxs)(`span`,{className:`oc-mobile-assistant-card-content min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`oc-mobile-entity-title oc-mobile-assistant-name block min-w-0 truncate font-semibold text-foreground`,children:n}),(0,$.jsx)(`span`,{className:Y(`oc-mobile-assistant-summary`,fi),children:i})]}),(0,$.jsx)(hi,{count:e})]})}),(0,$.jsxs)(yi,{className:`min-w-[10rem]`,children:[(0,$.jsxs)(bi,{className:`min-h-10 px-3`,onClick:y,children:[(0,$.jsx)(X,{name:`edit`,className:`size-4`}),o]}),(0,$.jsx)(vi,{}),(0,$.jsxs)(bi,{className:`min-h-10 px-3 text-[var(--status-error)] focus:text-[var(--status-error)] data-[highlighted]:text-[var(--status-error)] [&_svg]:text-[var(--status-error)]`,onClick:b,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`}),s]})]})]})}function Jo(e){let t=(0,zi.c)(118),{onEnable:n,onOpenAssistant:r,className:i}=e,{t:a}=ee(),o=Un(),s=ce(),c=K();c.data?.assistants;let l;t[0]===c.data?.assistants?l=t[1]:(l=c.data?.assistants??[],t[0]=c.data?.assistants,t[1]=l);let u;t[2]===l?u=t[3]:(u=ui(l),t[2]=l,t[3]=u);let d=u,f=Qe(Yo),[p,m]=Q.useState(null),h;t[4]===n?h=t[5]:(h=()=>n(),t[4]=n,t[5]=h);let g=R(h),_;t[6]!==o||t[7]!==f?(_=()=>{f(),o?.openSettings(`assistants`)},t[6]=o,t[7]=f,t[8]=_):_=t[8];let v=R(_),y;t[9]===r?y=t[10]:(y=e=>r(e),t[9]=r,t[10]=y);let b=R(y),x;t[11]===o?x=t[12]:(x=e=>{et(e,o?{openMobileSettings:o.openSettings}:void 0)},t[11]=o,t[12]=x);let S=R(x),C;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{m(e)},t[13]=C):C=t[13];let w=R(C),T;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>{e||m(null)},t[14]=T):T=t[14];let E=R(T),D;t[15]===a?D=t[16]:(D=a(`assistants.title`),t[15]=a,t[16]=D);let O=D,k;t[17]===a?k=t[18]:(k=a(`assistants.menu.edit`),t[17]=a,t[18]=k);let A=k,j;t[19]===a?j=t[20]:(j=a(`assistants.settings.delete`),t[19]=a,t[20]=j);let M=j;if(s.isPending||s.data?.supported&&s.data.enabled&&c.isPending){let e;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(nr,{className:`oc-mobile-assistant-loading`,children:(0,$.jsx)(Go,{})}),t[21]=e):e=t[21];let n;return t[22]!==i||t[23]!==O?(n=(0,$.jsx)(tr,{title:O,className:i,surface:!1,children:e}),t[22]=i,t[23]=O,t[24]=n):n=t[24],n}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length>0){let e;t[25]===a?e=t[26]:(e=a(`assistants.settings.create`),t[25]=a,t[26]=e);let n;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(X,{name:`add`,className:`size-5`}),t[27]=n):n=t[27];let r;t[28]!==v||t[29]!==e?(r=(0,$.jsx)(Z,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":e,onClick:v,children:n}),t[28]=v,t[29]=e,t[30]=r):r=t[30];let o;t[31]===c.data?o=t[32]:(o=(0,$.jsx)(ci,{snapshot:c.data,rowClassName:`flex justify-end pb-2`}),t[31]=c.data,t[32]=o);let s;t[33]===a?s=t[34]:(s=a(`assistants.listAria`),t[33]=a,t[34]=s);let l;if(t[35]!==d||t[36]!==M||t[37]!==A||t[38]!==S||t[39]!==b||t[40]!==w||t[41]!==a){let e;t[43]!==M||t[44]!==A||t[45]!==S||t[46]!==b||t[47]!==w||t[48]!==a?(e=e=>{let t=ne(e.name),n=t.displayName||e.name,r=li(e.latestMessagePreview,a);return(0,$.jsx)(qo,{assistantID:e.id,unreadCount:e.unreadCount??0,displayName:n,avatarEmoji:t.avatarEmoji??void 0,summary:r,enabled:e.enabled,editLabel:A,deleteLabel:M,assignedSessionIDs:e.assignedSessionIDs,serverWorking:e.working,onOpen:()=>b(e.id),onEdit:()=>S(e.id),onDelete:()=>w(e)},e.id)},t[43]=M,t[44]=A,t[45]=S,t[46]=b,t[47]=w,t[48]=a,t[49]=e):e=t[49],l=d.map(e),t[35]=d,t[36]=M,t[37]=A,t[38]=S,t[39]=b,t[40]=w,t[41]=a,t[42]=l}else l=t[42];let u;t[50]!==s||t[51]!==l?(u=(0,$.jsx)(`div`,{className:`oc-mobile-assistant-catalog`,role:`listbox`,"aria-label":s,children:l}),t[50]=s,t[51]=l,t[52]=u):u=t[52];let f=p!==null,m;t[53]!==p||t[54]!==E||t[55]!==f?(m=(0,$.jsx)(si,{assistant:p,open:f,onOpenChange:E}),t[53]=p,t[54]=E,t[55]=f,t[56]=m):m=t[56];let h;return t[57]!==i||t[58]!==O||t[59]!==r||t[60]!==o||t[61]!==u||t[62]!==m?(h=(0,$.jsxs)(tr,{title:O,className:i,surface:!1,scrollsWithPage:!0,trailing:r,children:[o,u,m]}),t[57]=i,t[58]=O,t[59]=r,t[60]=o,t[61]=u,t[62]=m,t[63]=h):h=t[63],h}if(s.data?.supported&&s.data.enabled&&c.data?.enabled&&c.data.assistants.length===0){let e;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`oc-mobile-assistant-onboarding-icon`,children:(0,$.jsx)(X,{name:`ai-agent`,className:`size-5`})}),t[64]=e):e=t[64];let n;t[65]===a?n=t[66]:(n=a(`assistants.onboarding.title`),t[65]=a,t[66]=n);let r;t[67]===n?r=t[68]:(r=(0,$.jsx)(`h2`,{children:n}),t[67]=n,t[68]=r);let o;t[69]===a?o=t[70]:(o=a(`assistants.onboarding.description`),t[69]=a,t[70]=o);let s;t[71]===o?s=t[72]:(s=(0,$.jsx)(`p`,{children:o}),t[71]=o,t[72]=s);let c;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(X,{name:`add`,className:`size-[18px]`}),t[73]=c):c=t[73];let l;t[74]===a?l=t[75]:(l=a(`assistants.onboarding.action`),t[74]=a,t[75]=l);let u;t[76]!==v||t[77]!==l?(u=(0,$.jsxs)(Z,{type:`button`,size:`lg`,className:`mt-6 w-full`,onClick:v,children:[c,l]}),t[76]=v,t[77]=l,t[78]=u):u=t[78];let d;t[79]!==r||t[80]!==s||t[81]!==u?(d=(0,$.jsxs)(nr,{className:`oc-mobile-assistant-onboarding`,children:[e,r,s,u]}),t[79]=r,t[80]=s,t[81]=u,t[82]=d):d=t[82];let f;return t[83]!==i||t[84]!==O||t[85]!==d?(f=(0,$.jsx)(tr,{title:O,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:d}),t[83]=i,t[84]=O,t[85]=d,t[86]=f):f=t[86],f}let N=s.isSuccess&&s.data.supported===!1,P=s.isError||s.data?.supported===!0&&s.data.enabled&&c.isError,F=s.data?.supported===!0&&(s.data.enabled===!1||c.data?.enabled===!1),I;t[87]!==a||t[88]!==P||t[89]!==N?(I=a(P?`assistants.state.unavailable`:N?`assistants.state.unsupportedTitle`:`assistants.state.instanceDisabled`),t[87]=a,t[88]=P,t[89]=N,t[90]=I):I=t[90];let L=I;if(F&&!P){let e;t[91]===g?e=t[92]:(e=(0,$.jsx)(Ko,{onEnable:g}),t[91]=g,t[92]=e);let n;return t[93]!==i||t[94]!==O||t[95]!==e?(n=(0,$.jsx)(tr,{title:O,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-guide-host`,children:e}),t[93]=i,t[94]=O,t[95]=e,t[96]=n):n=t[96],n}let z;t[97]===O?z=t[98]:(z=(0,$.jsx)(`span`,{className:`oc-mobile-page-section-label`,children:O}),t[97]=O,t[98]=z);let te=N?`cloud-off`:`sparkling`,B;t[99]===te?B=t[100]:(B=(0,$.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground`,children:(0,$.jsx)(X,{name:te,weight:`medium`,className:`size-5`})}),t[99]=te,t[100]=B);let V;t[101]===L?V=t[102]:(V=(0,$.jsx)(`h2`,{className:`mt-5 max-w-xs text-lg font-semibold leading-snug tracking-[-0.02em] text-foreground`,children:L}),t[101]=L,t[102]=V);let H;t[103]!==a||t[104]!==P||t[105]!==N?(H=P?null:(0,$.jsx)(`p`,{className:`mt-2 max-w-sm typography-small leading-relaxed text-muted-foreground`,children:a(N?`assistants.state.unsupportedDescription`:`assistants.state.instanceDisabledDescription`)}),t[103]=a,t[104]=P,t[105]=N,t[106]=H):H=t[106];let re;t[107]!==B||t[108]!==V||t[109]!==H?(re=(0,$.jsxs)(`section`,{className:`w-full max-w-md py-2`,children:[B,V,H]}),t[107]=B,t[108]=V,t[109]=H,t[110]=re):re=t[110];let U;t[111]!==z||t[112]!==re?(U=(0,$.jsx)(or,{label:z,cardClassName:`oc-mobile-assistant-state-card`,children:re}),t[111]=z,t[112]=re,t[113]=U):U=t[113];let W;return t[114]!==i||t[115]!==O||t[116]!==U?(W=(0,$.jsx)(tr,{title:O,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:U}),t[114]=i,t[115]=O,t[116]=U,t[117]=W):W=t[117],W}function Yo(e){return e.requestCreate}var Xo=[{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 Zo(e){let t=(0,zi.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=R(o),c;t[2]!==n||t[3]!==r?(c=e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=Xo.findIndex(e=>e.id===n),i=Xo[e.key===`Home`?0:e.key===`End`?Xo.length-1:(t+(e.key===`ArrowRight`?1:-1)+Xo.length)%Xo.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=R(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=Xo.map(e=>{let t=e.id===n,r=a(e.labelKey);return(0,$.jsxs)(Z,{id:`mobile-tab-${e.id}`,"data-tab":e.id,type:`button`,role:`tab`,variant:`ghost`,size:`sm`,"aria-controls":`mobile-tabpanel-${e.id}`,"aria-label":r,"aria-describedby":e.id===`assistant`?`mobile-tab-assistant-unread`:void 0,"aria-selected":t,tabIndex:t?0:-1,title:r,onClick:s,onKeyDown:l,className:Y(`oc-mobile-tab-button min-w-0 flex-1 flex-col overflow-visible`,`text-xs font-medium leading-none tracking-tight text-muted-foreground`,`transition-[background-color,color,box-shadow,transform] duration-100`,`hover:bg-transparent hover:text-foreground`,`active:bg-interactive-active`,`motion-reduce:transition-none`,t&&[`bg-interactive-selection/55 text-primary`,`hover:bg-interactive-selection/55 hover:text-primary`,`font-semibold`]),children:[(0,$.jsxs)(`span`,{className:`relative inline-flex shrink-0 overflow-visible`,children:[(0,$.jsx)(X,{name:e.icon,weight:`medium`,className:`size-[23px] shrink-0`}),e.id===`assistant`?(0,$.jsx)(`span`,{id:`mobile-tab-assistant-unread`,className:`pointer-events-none absolute left-full -top-1 ml-0.5 inline-flex z-10`,children:(0,$.jsx)(gi,{className:`h-[18px] min-w-[18px] bg-foreground px-1 text-[11px] font-bold tracking-normal text-background shadow-none ring-2 ring-background`})}):null]}),(0,$.jsx)(`span`,{className:`oc-mobile-tab-label block max-w-full overflow-hidden text-ellipsis whitespace-nowrap`,children:r})]},e.id)}),t[8]=n,t[9]=s,t[10]=l,t[11]=a,t[12]=f):f=t[12];let p;return t[13]!==i||t[14]!==u||t[15]!==f?(p=(0,$.jsx)(sr,{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 Qo=`oc-native-ios-tab-bar`,$o=`OpenChamberTabBar`,es=[`projects`,`assistant`,`scheduled`,`settings`],ts=A($o),ns=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.nativeUiEnabled!==!1;function rs(){return typeof window>`u`?!1:ns({isCapacitor:T(),platform:D(),pluginAvailable:j.isPluginAvailable($o),nativeUiEnabled:Dn()})}var is=e=>e.classList.contains(`dark`)?`dark`:`light`,as=()=>Sn(`--primary`),os=e=>typeof e==`string`&&es.includes(e),ss=e=>typeof e==`string`&&os(e)?e:null,cs=(e,t)=>e.selectedTab===t.selectedTab&&e.appearance===t.appearance&&e.ariaLabel===t.ariaLabel&&e.accentColor===t.accentColor&&e.tabs.length===t.tabs.length&&e.tabs.every((e,n)=>e.id===t.tabs[n]?.id&&e.label===t.tabs[n]?.label&&e.badge===t.tabs[n]?.badge),ls=(e,t)=>{e.classList.toggle(Qo,t)},us=(e,t)=>e&&!t,ds=e=>e.visible?e.overlayHidden?{action:`present`}:e.lastState&&cs(e.lastState,e.nextState)?{action:`skip`}:{action:`present`}:e.overlayHidden?{action:`skip`}:{action:`hide`},fs=()=>ts,ps=`mobile-overlay-root`;function ms(e){let t=(0,zi.c)(28),n=Cn(),r;t[0]===n?r=t[1]:(r=n&&rs(),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=R(e.onTabChange),h;t[2]===e.tabs?h=t[3]:(h=JSON.stringify(e.tabs.map(gs)),t[2]=e.tabs,t[3]=h);let g=h,_;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=typeof document>`u`?`dark`:is(document.documentElement),t[4]=_):_=t[4];let v=_,y;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=typeof document>`u`?``:as(),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(ps);e||(e=document.createElement(`div`),e.id=ps,document.body.appendChild(e));let t=()=>u(lt(e.children));t();let n=new MutationObserver(t);return n.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[Ct]}),()=>n.disconnect()},S=[i],t[6]=i,t[7]=x,t[8]=S),(0,Q.useEffect)(x,S);let C;t[9]!==i||t[10]!==m?(C=()=>{if(!i)return;let e=!1,t=fs(),n=[];return t.addListener(`tabSelected`,e=>{let t=ss(e.tab);t&&m(t)}).then(t=>{if(e){t.remove();return}n.push(t)}),()=>{e=!0,d.current=null,t.hide();for(let e of n)e.remove();typeof document<`u`&&ls(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=fs(),r={tabs:e.tabs.map(hs),selectedTab:e.activeTab,appearance:v,accentColor:b,ariaLabel:e.ariaLabel},a=ds({visible:us(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`&&ls(document.documentElement,!1);return}f.current=!1,d.current=r,o(!0),typeof document<`u`&&ls(document.documentElement,!0)}})().catch(()=>{t||(p.current=!0,c(!0),o(!1),typeof document<`u`&&ls(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 hs(e){return{id:e.id,label:e.label,badge:e.badge??null}}function gs(e){return[e.id,e.label,e.badge??null]}function _s(e){let t=(0,zi.c)(40),{tabs:n,navigation:r,onTabChange:i,secondaryPages:a,showTabBar:o,tabBarCovered:s,className:c}=e,l=a===void 0?[]:a,u=o===void 0||o,d=s!==void 0&&s,{t:f}=ee(),p=r.activeTab,m=l.slice(-2),h=m.at(-1)??null,g=h?.key??null,_=h?.depth,v=m.length>1?m[m.length-2].key:null,y;t[0]===p?y=t[1]:(y=()=>new Set([p]),t[0]=p,t[1]=y);let[b,x]=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=R(()=>h?.onBack());En({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=R(j),N=se(),P;t[6]!==N||t[7]!==f?(P=Xo.map(e=>({id:e.id,label:f(e.labelKey),badge:e.id===`assistant`&&N>0?N>99?`99+`:String(N):null})),t[6]=N,t[7]=f,t[8]=P):P=t[8];let F=P,I=u&&!d&&!h,L;t[9]===f?L=t[10]:(L=f(`mobile.nav.aria`),t[9]=f,t[10]=L);let z;t[11]!==M||t[12]!==I||t[13]!==F||t[14]!==p||t[15]!==L?(z={visible:I,activeTab:p,tabs:F,ariaLabel:L,onTabChange:M},t[11]=M,t[12]=I,t[13]=F,t[14]=p,t[15]=L,t[16]=z):z=t[16];let te=ms(z),B=te===`native`,V=u&&te===`web`,ne=Cn(),H,re;t[17]!==ne||t[18]!==B?(H=()=>{if(!ne){An.shutdown();return}B&&On(!0)&&An.warm()},re=[ne,B],t[17]=ne,t[18]=B,t[19]=H,t[20]=re):(H=t[19],re=t[20]),Q.useEffect(H,re);let U;t[21]===c?U=t[22]:(U=Y(`oc-mobile-floating-shell relative isolate flex h-full min-h-0 flex-col overflow-hidden text-foreground`,`bg-[var(--oc-mobile-page-background)]`,c),t[21]=c,t[22]=U);let W=h?!0:void 0,ie=h?!0:void 0,ae;t[23]!==p||t[24]!==u||t[25]!==V||t[26]!==f||t[27]!==n||t[28]!==b?(ae=Xo.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:Y(`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)(vs,{tab:e.id,icon:e.icon}):null},e.id)}),t[23]=p,t[24]=u,t[25]=V,t[26]=f,t[27]=n,t[28]=b,t[29]=ae):ae=t[29];let G;t[30]!==w||t[31]!==W||t[32]!==ie||t[33]!==ae?(G=(0,$.jsx)(`div`,{ref:w,"data-mobile-navigation-underlay":`true`,"aria-hidden":W,inert:ie,className:`flex h-full min-h-0 flex-1 flex-col`,children:ae}),t[30]=w,t[31]=W,t[32]=ie,t[33]=ae,t[34]=G):G=t[34];let oe=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)(Zo,{activeTab:p,onTabChange:M}):null}):null,ce=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:Y(`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)}),le;return t[35]!==U||t[36]!==G||t[37]!==oe||t[38]!==ce?(le=(0,$.jsxs)(`div`,{className:U,children:[G,oe,ce]}),t[35]=U,t[36]=G,t[37]=oe,t[38]=ce,t[39]=le):le=t[39],le}function vs(e){let t=(0,zi.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=Xo.find(e=>e.id===n)??Xo[0];t[8]===i?c=t[9]:(c=Y(`flex min-h-[70dvh] flex-col items-center justify-center gap-3 text-center`,i),t[8]=i,t[9]=c),l=(0,$.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-2xl bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(X,{name:r??e.icon,className:`size-6`})}),o=`typography-ui-label font-semibold tracking-[-0.01em] text-foreground`,s=a(e.labelKey),t[0]=i,t[1]=r,t[2]=a,t[3]=n,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else o=t[4],s=t[5],c=t[6],l=t[7];let u;t[10]!==o||t[11]!==s?(u=(0,$.jsx)(`h1`,{className:o,children:s}),t[10]=o,t[11]=s,t[12]=u):u=t[12];let d;return t[13]!==c||t[14]!==l||t[15]!==u?(d=(0,$.jsxs)(`div`,{className:c,children:[l,u]}),t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}var ys={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)`}},bs=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 xs({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||=Hn({onPressedKeyChange:t=>l(t===e.id)}),Q.useEffect(()=>()=>u.current?.reset(),[]);let d=R(()=>{u.current?.consumeClick(e.id)||r(e)}),f=R(()=>i?.(e)),p=R(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=R(e=>{u.current?.move(e.pointerId,e.clientX,e.clientY)}),h=R(e=>{u.current?.end(e.pointerId)}),g=R(e=>{u.current?.cancel(e.pointerId)}),_=R(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=bs(e.path),b=(0,$.jsxs)(`article`,{"data-mobile-press-surface":`soft`,"data-pressed":c?`true`:void 0,className:Y(`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:Y(`oc-mobile-project-icon oc-mobile-glass-control flex shrink-0 items-center justify-center rounded-full text-muted-foreground`),style:ys[e.tone??`neutral`],"aria-hidden":!0,children:(0,$.jsx)(X,{name:e.icon??`code-box`,className:`oc-mobile-project-icon-glyph`})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`oc-mobile-project-title oc-mobile-entity-title truncate font-semibold text-foreground`,children:o?an(e.name,o):e.name}),e.active?(0,$.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-[var(--status-success)] shadow-[0_0_0_3px_color-mix(in_srgb,var(--status-success)_12%,transparent)]`,"aria-label":s(`mobile.sessions.activeProjectAria`)}):null]}),(0,$.jsxs)(`span`,{className:`oc-mobile-project-meta oc-mobile-entity-meta flex min-w-0 items-center text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:v}),e.activityLabel?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`·`}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:e.activityLabel})]}):null,y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`·`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,title:e.path,children:y})]}):null]})]}),(0,$.jsx)(X,{name:`arrow-down-s`,className:Y(`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)(Z,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-mobile-project-action self-center rounded-full text-muted-foreground`,"aria-label":s(`sessions.sidebar.project.actions.projectMenu`),onClick:f,children:(0,$.jsx)(X,{name:`more-2`,className:`size-4`})}):null]});return n?b:(0,$.jsx)(nr,{asChild:!0,children:b})}var Ss=({hasPendingQuestion:e,hasPendingPermission:t,running:n,unread:r})=>e?`question`:t?`permission`:n?`running`:r?`completed-unread`:`idle`,Cs=10,ws=`oc:mobile-session-row-revealed`,Ts=e=>{window.dispatchEvent(new CustomEvent(ws,{detail:e}))};function Es({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||=Hn(),Q.useEffect(()=>()=>x.current?.reset(),[]),Q.useEffect(()=>{let t=t=>{t.detail!==e.id&&h(0)};return window.addEventListener(ws,t),()=>window.removeEventListener(ws,t)},[e.id]),Q.useEffect(()=>{h(0)},[e.id]);let S=R(()=>h(0)),C=m!==0,w=R(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=R(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>Cs&&o>a){n.intent=`vertical`,v.current=null,x.current?.cancel(t.pointerId);return}if(a>Cs&&a>o){n.intent=`horizontal`,_(!0),y.current=!0,x.current?.cancel(t.pointerId);try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}Ts(e.id)}}if(n.intent!==`horizontal`)return;t.preventDefault();let a=Math.max(-n.actionWidth,Math.min(0,n.startOffset+r));h(a)}),E=R(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=R(e=>{let t=v.current;v.current=null,x.current?.cancel(e.pointerId),_(!1),h(t?.startOffset??0)}),O=R(()=>{if(!x.current?.consumeClick(e.id)){if(y.current){y.current=!1;return}if(m!==0){S();return}Ts(e.id),o(e)}}),k=R(t=>{t.preventDefault(),t.stopPropagation(),x.current?.openFromContextMenu(e.id,()=>{l(e)})}),A=R(()=>{S(),s(e)}),j=R(()=>{S(),c(e)}),M=R(()=>l(e)),N=R(()=>a?.()),P=e.pinned?p(`sessions.sidebar.session.menu.unpin`):p(`sessions.sidebar.session.menu.pin`),F=u??Ss({hasPendingQuestion:!1,hasPendingPermission:!1,running:!1,unread:!!e.unread}),I=F===`question`?p(`sessions.sidebar.session.status.questionRequired`):F===`permission`?p(`sessions.sidebar.session.status.permissionRequired`):F===`running`?p(`sessions.sidebar.session.status.active`):F===`completed-unread`?p(`sessions.sidebar.session.status.unread`):void 0;return e.kind===`pagination`?(0,$.jsx)(`div`,{className:Y(`oc-mobile-session-row`,i&&`oc-mobile-session-pagination-continues`,d),children:(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-session-pagination-row`,style:{touchAction:`pan-y`},onClick:O,onPointerDown:()=>void 0,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left font-medium text-foreground typography-meta`,children:e.title}),e.subtitle?(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.subtitle}):null,(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground`})]})}):(0,$.jsxs)(`div`,{className:Y(`oc-mobile-session-row relative isolate`,d),children:[(0,$.jsxs)(`div`,{ref:b,className:Y(`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)(Z,{type:`button`,variant:`secondary`,className:`oc-mobile-session-action h-full flex-col rounded-none border-0 bg-interactive-selection px-1 text-interactive-selection-foreground hover:bg-interactive-active`,"aria-label":P,tabIndex:C?0:-1,onClick:A,children:[(0,$.jsx)(X,{name:e.pinned?`unpin`:`pushpin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:P})]}),(0,$.jsxs)(Z,{type:`button`,variant:`destructive`,className:`oc-mobile-session-action h-full flex-col rounded-none border-0 px-1`,"aria-label":p(`sessions.sidebar.bulkActions.archive`),tabIndex:C?0:-1,onClick:j,children:[(0,$.jsx)(X,{name:`archive`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:p(`sessions.sidebar.bulkActions.archive`)})]})]}),(0,$.jsxs)(`div`,{className:Y(`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)(Z,{type:`button`,variant:`ghost`,size:`icon`,className:`min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":p(r?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:N,children:(0,$.jsx)(X,{name:`arrow-down-s`,className:Y(`size-3.5 transition-transform duration-150 motion-reduce:transition-none`,r?`rotate-0`:`-rotate-90`)})}):null,(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-session-row-main flex min-w-0 flex-1 items-center text-left outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,style:{paddingLeft:16+Math.min(t,4)*12,touchAction:`pan-y`},onClick:O,onPointerDown:w,onPointerMove:T,onPointerUp:E,onPointerCancel:D,onContextMenu:k,children:[(0,$.jsx)(`span`,{className:`oc-mobile-session-status shrink-0`,"data-session-status":F,"aria-hidden":!I||void 0,"aria-label":I,title:I,children:F===`running`?(0,$.jsx)(fr,{className:`motion-reduce:[&_svg]:animate-none`}):F===`question`?(0,$.jsx)(X,{name:`question`,className:`size-3.5 text-[var(--status-warning)]`}):F===`permission`?(0,$.jsx)(X,{name:`shield`,className:`size-3.5 text-destructive`}):(0,$.jsx)(`span`,{className:Y(`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:Y(`oc-mobile-session-title truncate`,e.unread?`font-semibold`:`font-medium`),children:f?an(e.title,f):e.title}),e.changes?(0,$.jsx)(`span`,{className:`oc-mobile-session-changes shrink-0 tabular-nums text-muted-foreground`,children:e.changes}):null,e.archived?(0,$.jsx)(X,{name:`archive`,className:`size-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}):null]}),e.subtitle?(0,$.jsx)(`span`,{className:`oc-mobile-session-subtitle truncate text-muted-foreground`,children:f?an(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)(Z,{type:`button`,variant:`ghost`,size:`icon`,className:`mr-1 min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":p(`sessions.sidebar.session.menu.label`),onClick:M,children:(0,$.jsx)(X,{name:`more-2`,className:`size-3.5`})})]})]})}var Ds=Q.memo(Es),Os=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e)),ks=e=>e.catalogSessions??e.sessions,As=(e,t)=>e.filter(e=>e.kind!==`pagination`&&Os(t,e.title,e.subtitle,e.id)),js=(e,t)=>{let n=ks(e);if(Os(t,e.name,e.path))return{...e,sessions:n.filter(e=>e.kind!==`pagination`)};let r=As(n,t);return r.length>0?{...e,sessions:r}:null},Ms=(e,t)=>{let n=t.trim().toLowerCase();return n?e.flatMap(e=>{if(Os(n,e.name,e.path))return[{...e,worktrees:[]}];let t=e.worktrees.flatMap(e=>{let t=js(e,n);return t?[t]:[]});return t.length>0?[{...e,worktrees:t}]:[]}):e},Ns=10,Ps=`oc:mobile-worktree-row-revealed`,Fs=e=>{window.dispatchEvent(new CustomEvent(Ps,{detail:e}))};function Is(e){let t=(0,zi.c)(10),n=he(e.session.id),r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={bootstrap:!1},t[0]=r):r=t[0];let i=Ke(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=Ne(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=Ss({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)(Ds,{...e,indicator:d}),t[7]=d,t[8]=e,t[9]=f):f=t[9],f}var Ls=Q.memo(Is);function Rs(e){let t=(0,zi.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`?Ds:Ls;return(0,$.jsx)(l,{session:e,paginationContinues:c,highlightQuery:s,onSelect:r,onPin:i,onArchive:a,onOpenActions:o},e.id)}),t[0]=s,t[1]=a,t[2]=o,t[3]=i,t[4]=r,t[5]=n,t[6]=c):c=t[6];let l;return t[7]===c?l=t[8]:(l=(0,$.jsx)($.Fragment,{children:c}),t[7]=c,t[8]=l),l}var zs=Q.memo(Rs);function Bs({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||=Hn({onPressedKeyChange:e=>g(e===l)}),Q.useEffect(()=>()=>S.current?.reset(),[]),Q.useEffect(()=>{let e=e=>{e.detail!==l&&m(0)};return window.addEventListener(Ps,e),()=>window.removeEventListener(Ps,e)},[l]),Q.useEffect(()=>{m(0)},[l]);let C=R(()=>m(0)),w=p!==0,T=R(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=R(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>Ns&&a>i){t.intent=`vertical`,y.current=null,S.current?.cancel(e.pointerId);return}if(i>Ns&&i>a){t.intent=`horizontal`,v(!0),b.current=!0,S.current?.cancel(e.pointerId);try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}Fs(l)}}if(t.intent!==`horizontal`)return;e.preventDefault();let i=Math.max(-t.actionWidth,Math.min(0,t.startOffset+n));m(i)}),D=R(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=R(e=>{let t=y.current;y.current=null,S.current?.cancel(e.pointerId),v(!1),m(t?.startOffset??0)}),k=R(()=>{if(!S.current?.consumeClick(l)){if(b.current){b.current=!1;return}if(p!==0){C();return}r()}}),A=R(n=>{d&&(n.preventDefault(),n.stopPropagation(),S.current?.openFromContextMenu(l,()=>{g(!1),a?.(e,t)}))}),j=R(()=>{C(),i?.(e,t)}),M=R(()=>{C(),o?.(e,t)}),N=R(()=>a?.(e,t)),P=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`oc-mobile-group-label-icon`,"aria-hidden":!0,children:(0,$.jsx)(X,{name:`git-branch`,className:`size-3.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left oc-mobile-entity-title font-semibold text-foreground`,children:s?an(t.name,s):t.name}),(0,$.jsx)(`span`,{className:`typography-small text-muted-foreground tabular-nums`,children:t.sessionCount===1?c(`mobile.sessions.project.sessionsSingle`):c(`mobile.sessions.project.sessionsPlural`,{count:t.sessionCount})}),(0,$.jsx)(X,{name:`arrow-down-s`,className:Y(`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:Y(`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)(Z,{type:`button`,variant:`secondary`,className:`oc-mobile-worktree-action h-full flex-col rounded-none border-0 bg-interactive-selection px-1 text-interactive-selection-foreground hover:bg-interactive-active`,"aria-label":c(`mobile.sessions.newSessionAria`),tabIndex:w?0:-1,onClick:j,children:[(0,$.jsx)(X,{name:`add`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:c(`sessions.sidebar.project.actions.newSession`)})]}):null,o?(0,$.jsxs)(Z,{type:`button`,variant:`destructive`,className:`oc-mobile-worktree-action h-full flex-col rounded-none border-0 px-1`,"aria-label":c(`mobile.projectEdit.deleteWorktreeAria`,{label:t.name}),tabIndex:w?0:-1,onClick:M,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:c(`mobile.projectEdit.deleteWorktreeConfirmButton`)})]}):null]}):null,(0,$.jsxs)(`div`,{className:Y(`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)(Z,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-mobile-worktree-more rounded-full text-muted-foreground`,"aria-label":c(`agentManager.detail.actions.worktreeActionsAria`),onClick:N,children:(0,$.jsx)(X,{name:`more-2`,className:`size-3.5`})}):null]})]})}function Vs(e){let t=(0,zi.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=Ms(n,M),t[4]=M,t[5]=n,t[6]=P):P=t[6];let F=P,I=R(a),L=R(o),z;t[7]===s?z=t[8]:(z=()=>s?.(),t[7]=s,t[8]=z);let te=R(z),B;t[9]===c?B=t[10]:(B=()=>c?.(),t[9]=c,t[10]=B);let V=R(B),ne;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(ne=e=>O(e),t[11]=ne):ne=t[11];let H=R(ne),re;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>{A(``),E(!1)},t[12]=re):re=t[12];let U=R(re),W;t[13]!==U||t[14]!==T?(W=()=>{if(T){U();return}E(!0)},t[13]=U,t[14]=T,t[15]=W):W=t[15];let ie=R(W),ae;t[16]!==U||t[17]!==l?(ae=e=>{U(),e.expanded||l(e)},t[16]=U,t[17]=l,t[18]=ae):ae=t[18];let G=R(ae),oe;t[19]!==U||t[20]!==l||t[21]!==d?(oe=(e,t)=>{U(),e.expanded||l(e),t.expanded||d(e,t)},t[19]=U,t[20]=l,t[21]=d,t[22]=oe):oe=t[22];let se=R(oe),ce;t[23]!==U||t[24]!==h?(ce=e=>{U(),h(e)},t[23]=U,t[24]=h,t[25]=ce):ce=t[25];let le=R(ce),K;t[26]===y?K=t[27]:(K=Y(`relative isolate mx-auto flex w-full max-w-[26rem] flex-col gap-5`,y),t[26]=y,t[27]=K);let ue;t[28]===S?ue=t[29]:(ue=S(`mobile.sessions.section.projects`),t[28]=S,t[29]=ue);let de;t[30]!==T||t[31]!==S?(de=S(T?`mobile.sessions.clearSearchAria`:`mobile.sessions.searchAria`),t[30]=T,t[31]=S,t[32]=de):de=t[32];let fe=T?`close`:`search`,pe;t[33]===fe?pe=t[34]:(pe=(0,$.jsx)(X,{name:fe,className:`size-5`}),t[33]=fe,t[34]=pe);let me;t[35]!==ie||t[36]!==T||t[37]!==de||t[38]!==pe?(me=(0,$.jsx)(Z,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":de,"aria-expanded":T,onClick:ie,children:pe}),t[35]=ie,t[36]=T,t[37]=de,t[38]=pe,t[39]=me):me=t[39];let he;t[40]===S?he=t[41]:(he=S(`mobile.projects.menu.label`),t[40]=S,t[41]=he);let ge=D?`rotate-45`:`rotate-0`,_e;t[42]===ge?_e=t[43]:(_e=Y(`size-5 transition-transform duration-150 motion-reduce:transition-none`,ge),t[42]=ge,t[43]=_e);let ve;t[44]===_e?ve=t[45]:(ve=(0,$.jsx)(X,{name:`add`,className:_e}),t[44]=_e,t[45]=ve);let ye;t[46]!==he||t[47]!==ve?(ye=(0,$.jsx)(sn,{asChild:!0,children:(0,$.jsx)(Z,{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":he,children:ve})}),t[46]=he,t[47]=ve,t[48]=ye):ye=t[48];let be;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,$.jsx)(X,{name:`chat-new`,className:`size-4`}),t[49]=be):be=t[49];let xe;t[50]===S?xe=t[51]:(xe=S(`mobile.projects.menu.newChat`),t[50]=S,t[51]=xe);let Se;t[52]!==L||t[53]!==xe?(Se=(0,$.jsxs)(nn,{className:`min-h-11`,onSelect:L,children:[be,xe]}),t[52]=L,t[53]=xe,t[54]=Se):Se=t[54];let Ce;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,$.jsx)(X,{name:`folder`,className:`size-4`}),t[55]=Ce):Ce=t[55];let we;t[56]===S?we=t[57]:(we=S(`mobile.projects.menu.newProject`),t[56]=S,t[57]=we);let Te;t[58]!==I||t[59]!==we?(Te=(0,$.jsxs)(nn,{className:`min-h-11`,onSelect:I,children:[Ce,we]}),t[58]=I,t[59]=we,t[60]=Te):Te=t[60];let Ee;t[61]!==te||t[62]!==s||t[63]!==S?(Ee=s?(0,$.jsxs)(nn,{className:`min-h-11`,onSelect:te,children:[(0,$.jsx)(X,{name:`scan-2`,className:`size-4`}),S(`mobile.projects.menu.scanQr`)]}):null,t[61]=te,t[62]=s,t[63]=S,t[64]=Ee):Ee=t[64];let De;t[65]!==V||t[66]!==c||t[67]!==S?(De=c?(0,$.jsxs)(nn,{className:`min-h-11`,onSelect:V,children:[(0,$.jsx)(X,{name:`server`,className:`size-4`}),S(`mobile.projects.menu.switchInstance`)]}):null,t[65]=V,t[66]=c,t[67]=S,t[68]=De):De=t[68];let Oe;t[69]!==Se||t[70]!==Te||t[71]!==Ee||t[72]!==De?(Oe=(0,$.jsxs)(en,{align:`end`,side:`bottom`,className:`min-w-44`,children:[Se,Te,Ee,De]}),t[69]=Se,t[70]=Te,t[71]=Ee,t[72]=De,t[73]=Oe):Oe=t[73];let ke;t[74]!==H||t[75]!==D||t[76]!==ye||t[77]!==Oe?(ke=(0,$.jsxs)(tn,{open:D,onOpenChange:H,children:[ye,Oe]}),t[74]=H,t[75]=D,t[76]=ye,t[77]=Oe,t[78]=ke):ke=t[78];let Ae;t[79]!==me||t[80]!==ke?(Ae=(0,$.jsxs)($.Fragment,{children:[me,ke]}),t[79]=me,t[80]=ke,t[81]=Ae):Ae=t[81];let je;t[82]!==ue||t[83]!==Ae?(je=(0,$.jsx)(Zn,{title:ue,trailing:Ae}),t[82]=ue,t[83]=Ae,t[84]=je):je=t[84];let Me;t[85]!==U||t[86]!==T||t[87]!==k||t[88]!==S?(Me=T?(0,$.jsxs)(`div`,{className:`relative mx-1`,role:`search`,children:[(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 z-10 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(Yt,{autoFocus:!0,type:`text`,inputMode:`search`,enterKeyHint:`search`,value:k,placeholder:S(`mobile.sessions.search.placeholder`),"aria-label":S(`mobile.sessions.searchAria`),className:Y(`h-11 rounded-full pl-9`,k&&`pr-10`),onChange:e=>A(e.target.value),onKeyDown:e=>{e.key===`Escape`&&U()}}),k?(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute right-1.5 top-1/2 size-8 -translate-y-1/2 rounded-full text-muted-foreground`,"aria-label":S(`mobile.sessions.clearSearchAria`),onClick:()=>A(``),children:(0,$.jsx)(X,{name:`close`,className:`size-4`})}):null]}):null,t[85]=U,t[86]=T,t[87]=k,t[88]=S,t[89]=Me):Me=t[89];let q;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?(q=!N&&(r.length>0||x.length>0)?(0,$.jsx)(nr,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":S(`mobile.sessions.section.pinned`),children:[(0,$.jsx)(xs,{project:{id:`__pinned__`,name:S(`mobile.sessions.section.pinned`),path:``,icon:`pushpin`,sessionCount:r.length+x.length},expanded:C,embedded:!0,onToggle:()=>w(Us)}),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)(zs,{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)(zs,{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]=q):q=t[99];let Ne;t[100]!==I||t[101]!==G||t[102]!==se||t[103]!==le||t[104]!==M||t[105]!==_||t[106]!==m||t[107]!==f||t[108]!==u||t[109]!==v||t[110]!==p||t[111]!==g||t[112]!==h||t[113]!==l||t[114]!==d||t[115]!==n.length||t[116]!==N||t[117]!==S||t[118]!==F?(Ne=n.length===0?(0,$.jsxs)(`section`,{className:`flex min-h-[52dvh] flex-col items-center justify-center px-6 text-center`,children:[(0,$.jsx)(`span`,{className:`mb-4 flex size-14 items-center justify-center rounded-2xl bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(X,{name:`folder-add`,className:`size-6`})}),(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:S(`mobile.sessions.empty.noProjectsTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-xs typography-small text-muted-foreground`,children:S(`mobile.sessions.empty.noProjectsDescription`)}),(0,$.jsxs)(Z,{type:`button`,size:`lg`,className:`mt-4 min-h-10 rounded-full px-5`,onClick:I,children:[(0,$.jsx)(X,{name:`folder-add`,className:`size-4`}),S(`sessions.sidebar.header.actions.addProject`)]})]}):N&&F.length===0?(0,$.jsxs)(`section`,{className:`flex min-h-[40dvh] flex-col items-center justify-center px-6 text-center`,children:[(0,$.jsx)(X,{name:`search`,className:`mb-4 size-6 text-muted-foreground`}),(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:S(`mobile.sessions.empty.searchTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-xs typography-small text-muted-foreground`,children:S(`mobile.sessions.empty.searchDescription`)})]}):F.map(e=>{let t=N||e.expanded,n=e.worktrees.find(Hs)??(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)(nr,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":e.name,children:[(0,$.jsx)(xs,{project:e,expanded:t,embedded:!0,highlightQuery:N?M:void 0,onToggle:()=>N?G(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)(zs,{sessions:i,highlightQuery:N?M:void 0,onSelectSession:N?le:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null,r.map(t=>{let n=N||!!t.expanded;return(0,$.jsx)(or,{className:`oc-mobile-worktree-group`,ariaLabel:t.name,label:(0,$.jsx)(Bs,{project:e,worktree:t,expanded:n,highlightQuery:N?M:void 0,onToggle:()=>N?se(e,t):d(e,t),onNewSession:f,onOpenActions:N?void 0:p,onDelete:N?void 0:m}),children:n&&t.sessions.length>0?(0,$.jsx)(zs,{sessions:t.sessions,highlightQuery:N?M:void 0,onSelectSession:N?le:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v}):null},t.id)})]}):null]})},e.id)}),t[100]=I,t[101]=G,t[102]=se,t[103]=le,t[104]=M,t[105]=_,t[106]=m,t[107]=f,t[108]=u,t[109]=v,t[110]=p,t[111]=g,t[112]=h,t[113]=l,t[114]=d,t[115]=n.length,t[116]=N,t[117]=S,t[118]=F,t[119]=Ne):Ne=t[119];let Pe;t[120]===S?Pe=t[121]:(Pe=S(`sessions.sidebar.header.actions.addProject`),t[120]=S,t[121]=Pe);let Fe;t[122]!==I||t[123]!==Pe?(Fe=(0,$.jsx)(`button`,{type:`button`,className:`sr-only`,onClick:I,children:Pe}),t[122]=I,t[123]=Pe,t[124]=Fe):Fe=t[124];let Ie;return t[125]!==K||t[126]!==je||t[127]!==Me||t[128]!==q||t[129]!==Ne||t[130]!==Fe?(Ie=(0,$.jsxs)(`main`,{className:K,children:[je,Me,q,Ne,Fe]}),t[125]=K,t[126]=je,t[127]=Me,t[128]=q,t[129]=Ne,t[130]=Fe,t[131]=Ie):Ie=t[131],Ie}function Hs(e){return e.kind===`main`}function Us(e){return!e}function Ws(e){let t=(0,zi.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=()=>{Oe(`light`),i()},t[0]=i,t[1]=d);let f=R(d),p=c?`destructive`:`ghost`,m=u?`size-5 animate-spin`:`size-5`,h;t[2]!==n||t[3]!==m?(h=(0,$.jsx)(X,{name:n,className:m}),t[2]=n,t[3]=m,t[4]=h):h=t[4];let g;t[5]===r?g=t[6]:(g=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[5]=r,t[6]=g);let _;return t[7]!==l||t[8]!==f||t[9]!==p||t[10]!==h||t[11]!==g?(_=(0,$.jsxs)(Z,{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 Gs(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)(Ws,{icon:e.icon,label:xr(e,t),onClick:n(e.onClick),destructive:e.destructive,disabled:e.disabled,spinning:e.spinning},e.id))},e.items[0]?.id))}function Ks(e){let t=(0,zi.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=Ar({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=Qr({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=Zr({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=Gs(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)(Gt,{id:`mobile-row-actions-sheet`,open:n,onOpenChange:a,title:h,ariaLabel:g,closeAriaLabel:_,resizeAriaLabel:v,fitContent:!0,children:b}),t[38]=a,t[39]=n,t[40]=b,t[41]=h,t[42]=_,t[43]=v,t[44]=r.title,t[45]=x):x=t[45],x}function qs(e,t){return e&&e.id===t.id&&e.kind===t.kind&&e.title===t.title&&e.subtitle===t.subtitle&&e.changes===t.changes&&e.activityLabel===t.activityLabel&&e.unread===t.unread&&e.pinned===t.pinned&&e.archived===t.archived&&e.active===t.active&&e.directory===t.directory&&e.expanded===t.expanded&&e.children===t.children?e:t}function Js(e,t){if(!e||e.length===0)return t.slice();let n=new Map(e.map(e=>[e.id,e])),r=e.length===t.length,i=t.map((t,i)=>{let a=qs(n.get(t.id)??e[i],t);return a!==e[i]&&(r=!1),a});if(r){let t=!0;for(let n=0;n<i.length;n+=1)if(i[n]!==e[n]){t=!1;break}if(t)return e}return i}var Ys=`__show_more__:`,Xs=`__show_fewer__:`,Zs=e=>e.startsWith(Ys),Qs=e=>e.startsWith(Xs),$s=e=>Zs(e)||Qs(e),ec=e=>{let t=Zs(e)?Ys:Qs(e)?Xs: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)}},tc=e=>e.parentID??null,nc=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),rc=e=>{let t=e;return nc(t.directory??t.project?.worktree??null)},ic=(e,t)=>{if(t?.trim())return t.trim();let n=nc(e);if(!n)return``;let r=n.split(`/`).filter(Boolean);return r[r.length-1]||n},ac=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},oc=e=>{if(e<=0)return``;let t=Date.now()-e;if(t<6e4)return`now`;let n=Math.floor(t/6e4);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r<24)return`${r}h`;let i=Math.floor(r/24);return i<7?`${i}d`:new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(new Date(e))},sc=e=>{let t=e.time?.archived;return typeof t==`number`&&t>0},cc=(e,t)=>e.worktrees.find(e=>nc(e.path)===t)??null,lc=(e,t)=>{let n=t?.trim();return n?`${e} · ${n}`:e},uc=(e,t)=>Wr(e,{pinnedSessionIds:t,omitPinnedSessions:!0}).map(e=>e.session);function dc(){let{t:e}=ee(),t=de(),n=Fe(e=>e.activeSessions),r=Fe(e=>e.activePaginationByDirectory),i=Ie(e=>e.projects),a=Ie(e=>e.activeProjectId),o=C(e=>e.currentDirectory),s=q(e=>e.currentSessionId),c=q(e=>e.availableWorktreesByProject),l=Et(e=>e.orderByProject),u=Ue(),d=yo(e=>e.projectExpanded),f=yo(e=>e.worktreeExpanded),p=ue(e=>e.index.session.unseenCount),[m,h]=Q.useState(new Map),g=Tr(),_=Q.useMemo(()=>_r(g,s),[s,g]),v=Q.useMemo(()=>i.map(e=>{let t=nc(e.path);return{id:e.id,label:ic(t,e.label),path:t,icon:e.icon,worktrees:xt(l[e.id],c.get(t)??[])}}),[i,l,c]),y=Q.useMemo(()=>{let e=new Map(t.map(e=>[e.id,e])),r=n.map(t=>{let n=e.get(t.id);return n?Ae(n,t):t}),i=new Set(r.map(e=>e.id));for(let e of t)i.has(e.id)||r.push(e);return r},[n,t]),b=Q.useMemo(()=>ar(y,v.map(e=>({id:e.id,normalizedPath:e.path})),c,!1),[v,y,c]),x=Q.useMemo(()=>{let e=v.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===a,latestActivity:0})),t=new Map(e.map(e=>[e.project.id,e])),n=(e,t,n)=>{let r=nc(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||ic(r),path:r,worktree:n,sessions:[]},e.buckets.push(a)),a};for(let t of e){n(t,t.project.path,null);for(let e of t.project.worktrees)n(t,e.path,e)}for(let e of y){let r=b.bySessionId.get(e.id);if(!r)continue;let i=t.get(r.projectId);if(!i)continue;let a=r.kind===`worktree`?cc(i.project,r.scopeDirectory):null;(a?n(i,a.path,a):n(i,i.project.path,null)).sessions.push(e)}for(let t of e)for(let e of t.buckets){e.sessions.sort((e,t)=>Te(t)-Te(e));let n=uc(e.sessions,u);t.totalSessions+=n.length;for(let n of e.sessions){let e=ac(n);e>t.latestActivity&&(t.latestActivity=e)}}return e},[a,b,u,v,y]),S=Q.useMemo(()=>{let e=new Map;for(let t of y)e.set(t.id,t);return e},[y]),w=Q.useMemo(()=>{let e=new Map;for(let t of v)e.set(t.id,t);return e},[v]),T=Q.useRef([]),E=Q.useRef([]),D=Q.useRef(new Map),{pinnedSessions:O,inProgressSessions:k}=Q.useMemo(()=>{let t=new Map(v.map(e=>[e.id,e])),n=e(`mobile.sessions.untitled`),r=new Map(T.current.map(e=>[e.id,e])),i=new Map(E.current.map(e=>[e.id,e])),a=(e,r,i)=>{let a=b.bySessionId.get(e.id),o=a?t.get(a.projectId):void 0;if(!o)return[];let c=a?.kind===`worktree`?cc(o,a.scopeDirectory):null,l={id:e.id,directory:rc(e),title:e.title?.trim()||n,subtitle:lc(o.label,c?.branch),changes:Kn(Gn(e))??void 0,activityLabel:oc(ac(e))||void 0,unread:(p[e.id]??0)>0,pinned:r,archived:sc(e),active:s===e.id};return[qs(i.get(e.id),l)]},o=Ir(y,u).flatMap(e=>a(e,!0,r)),c=Or(y,u,g,p).flatMap(e=>a(e,!1,i)),l=Js(T.current,o),d=Js(E.current,c);return T.current=l,E.current=d,{pinnedSessions:l,inProgressSessions:d}},[s,b,u,v,g,y,e,p]),A=Q.useMemo(()=>{let e=new Map;for(let t of x){let n=t.project.worktrees.length>0;for(let r of t.buckets){let i=uc(r.sessions,u).length;e.set(`${t.project.id}::${r.key}`,{path:r.path,rootCount:i,hasWorktrees:n})}}return e},[u,x]),j=Q.useMemo(()=>{let t=nc(o),n=new Map,i=e=>(e.kind!==`pagination`&&n.set(e.id,e),e),a=x.map(a=>{let o=d[a.project.id]??!0,c=pr(),l=a.project.icon?Wt[a.project.icon]:void 0,h=a.buckets.map(o=>{let l=`${a.project.id}::${o.key}`,d=f[l]??!1,h=m.get(l)??c,g=uc(o.sessions,u),v=Wr(o.sessions,{pinnedSessionIds:u,omitPinnedSessions:!1}).map(e=>e.session),y=t=>{let r=tc(t),a=(p[t.id]??0)>0&&!r,c={id:t.id,directory:o.path,title:t.title?.trim()||e(`mobile.sessions.untitled`),changes:Kn(Gn(t))??void 0,activityLabel:oc(ac(t))||void 0,unread:a,pinned:u.has(t.id),archived:sc(t),active:s===t.id},l=qs(D.current.get(t.id)??n.get(t.id),c);return i(l)},b=vr(g,h,_).map(y),x=g.length-b.length,S=r.get(nc(o.path)),C=S?.hasMore===!0,w=g.length>c&&h>c,T=[...b];w&&T.push({id:`${Xs}${a.project.id}::${o.key}`,kind:`pagination`,title:e(`sessions.sidebar.group.showFewer`)}),(x>0||C)&&T.push({id:`${Ys}${a.project.id}::${o.key}`,kind:`pagination`,title:e(`sessions.sidebar.group.showMore`),subtitle:S?.loadingMore?`…`:void 0});let E=nc(o.path),O=!!(a.isActive&&t&&E&&(t===E||t.startsWith(`${E}/`))),k=o.worktree==null;return{id:o.key,name:k?e(`mobile.sessions.mainWorkspace`):o.label,path:o.path,kind:k?`main`:`worktree`,active:O,expanded:k?!0:d,sessionCount:g.length,sessions:T,catalogSessions:v.map(y)}});return{id:a.project.id,name:a.project.label,path:a.project.path,icon:l,sessionCount:a.totalSessions,activityLabel:oc(a.latestActivity)||void 0,active:a.isActive,expanded:o,worktrees:h}});return D.current=n,a},[r,_,o,s,u,d,x,e,p,m,f]),M=e=>{for(let[t,n]of A)if(t.startsWith(`${e}::`))return n.hasWorktrees;return!1},N=(e,t)=>A.get(`${e}::${t}`)?.rootCount??0,P=e=>pr();return{projects:j,pinnedSessions:O,inProgressSessions:k,sessionById:S,projectMetaById:w,allSessions:y,projectHasWorktrees:M,getBucketRootCount:N,getBucketVisibleCount:(e,t)=>{let n=`${e}::${t}`;return m.get(n)??P(e)},getBucketPageSize:P,getBucketDirectory:(e,t)=>A.get(`${e}::${t}`)?.path??null,showMoreBucketSessions:(e,t)=>{let n=`${e}::${t}`,r=A.get(n),i=pr(),a=Xr(),o=m.get(n)??i,s=r?.rootCount??0;if(h(e=>{let t=new Map(e),r=Math.max(i,e.get(n)??i,o);return t.set(n,r+a),t}),Math.max(i,o)+a<s)return;let c=r?.path,l=nc(c);if(!l)return;let u=Fe.getState().activePaginationByDirectory.get(l);u?.hasMore&&!u.loadingMore&&ze(l)},resetBucketVisibleCount:(e,t)=>{let n=`${e}::${t}`;h(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t})}}}var fc=(e,t,n)=>e?.kind===`project`&&e.project.id===t?{...e,isGitRepository:n}:e;function pc({onOpenChat:e,onAddProject:t,onNewSession:n,onScanQr:r,onSwitchInstance:i,className:a}){let{t:o}=ee(),{git:s}=gn(),c=dc(),l=yo(e=>e.setProjectExpanded),u=yo(e=>e.setWorktreeExpanded),d=Ve(),f=Ue(),p=q(e=>e.archiveSessions),m=q(e=>e.updateSessionTitle),h=q(e=>e.requestSessionSmartTitle),_=q(e=>e.shareSession),v=q(e=>e.unshareSession),y=q(e=>e.openNewSessionDraft),b=We(e=>e.openDraft),x=We(e=>e.openSession),S=Ie(e=>e.projects),C=Ie(e=>e.setActiveProjectIdOnly),w=Ie(e=>e.removeProject),T=Dt(),[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),[I,L]=Q.useState(``),[z,B]=Q.useState(!1),[V,ne]=Q.useState(!1),[H,re]=Q.useState(null),[U,W]=Q.useState(null),[ie,ae]=Q.useState(null),G=E?.kind===`session`?E.session.id:``,oe=he(G),se=oe?.type===`busy`||oe?.type===`retry`,ce=E?.kind===`session`?rc(E.session):``,le=!!G&&ie===G,K=!ce||le||se,ue=R(e=>{let t=new Map;for(let e of c.allSessions){let n=tc(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}),de=R(()=>{k(!1),D(null)}),fe=R(t=>{if($s(t.id)){let e=ec(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&&rc(n)||null;e({sessionId:t.id,directory:r})}),pe=R(e=>{$s(e.id)||d(e.id)}),me=R(async e=>{if($s(e.id))return;let t=ue(e.id),{archivedIds:n,failedIds:r}=await p(t);n.length>0&&Rr({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&&J.error(r.length===1?o(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):o(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}),ge=R(()=>{if(!E||E.kind!==`session`)return;let e=E.session,t=rc(e),n=oe?.type??`idle`;!t||ie===e.id||n===`busy`||n===`retry`||(ae(e.id),(async()=>{try{await T.refreshSessionTranscript(e.id,{directory:t}),J.success(o(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{J.error(o(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{ae(t=>t===e.id?null:t)}})())}),_e=R(e=>{if($s(e.id))return;let t=c.sessionById.get(e.id);t&&(D({kind:`session`,session:t}),k(!0))}),ve=R(e=>{l(e.id,!e.expanded)}),ye=R((e,t)=>{u(`${e.id}::${t.id}`,!t.expanded)}),be=R((e,t)=>{C(e.id),b({selectedProjectId:e.id,directoryOverride:t,preserveDirectoryOverride:!0})}),xe=R(()=>{if(n){n();return}y()}),Se=R(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=>fc(n,t.id,e))}).catch(()=>{D(e=>fc(e,t.id,!1))}))}),Ce=R((e,t)=>{let n=g(t);return n?e.worktrees.find(e=>g(e.path)===n)||((q.getState().availableWorktreesByProject.get(e.path)??[]).find(e=>g(e.path)===n)??null):null}),we=R((e,t)=>{let n=c.projectMetaById.get(e.id);n&&be(n,t.path)}),Te=R((e,t)=>{let n=c.projectMetaById.get(e.id);n&&(D({kind:`worktree`,project:n,worktreePath:t.path,worktreeName:t.name}),k(!0))}),Ee=R((e,t)=>{let n=c.projectMetaById.get(e.id);if(!n)return;let r=Ce(n,t.path);if(!r){J.error(o(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}W({project:n,worktree:r})}),De=R(e=>{re(e),C(e),ne(!0)}),Oe=R(e=>{(async()=>{let t=e.worktrees;try{t=(await qt({id:e.id,path:e.path})).worktrees}catch(n){console.warn(`[MobileProjectsHome] Worktree refresh before session sync failed:`,n),t=q.getState().availableWorktreesByProject.get(e.path)??e.worktrees}await Je([e.path,...t.map(e=>e.path)],c.allSessions)})()}),ke=R((e,t)=>{let n=H;if(ne(!1),re(null),t?.sessionId){x({sessionId:t.sessionId,directory:e});return}b({selectedProjectId:n,directoryOverride:e,preserveDirectoryOverride:!0})}),Ae=R(async e=>{try{if(!(await _(e.id))?.share?.url){J.error(o(`sessions.sidebar.session.share.error`));return}J.success(o(`sessions.sidebar.session.share.successTitle`),{description:o(`sessions.sidebar.session.share.successDescription`)})}catch{J.error(o(`sessions.sidebar.session.share.error`))}}),je=R(async e=>{if((await te(e)).ok){J.success(o(`sessions.sidebar.session.menu.copied`));return}J.error(o(`sessions.sidebar.session.share.copyUrlError`))}),Me=R(async e=>{try{if(await v(e)){J.success(o(`sessions.sidebar.session.unshare.success`));return}J.error(o(`sessions.sidebar.session.unshare.error`))}catch{J.error(o(`sessions.sidebar.session.unshare.error`))}}),Ne=R(e=>{let t=ue(e.id);br({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`)})}),Pe=R(async()=>{if(!P)return;let e=I.trim();if(e)try{await m(P.id,e),F(null),L(``)}catch{J.error(o(`sessions.sidebar.session.menu.rename`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}}),Fe=R(async()=>{if(!P||z)return;let e=P.id;F(null),L(``),B(!0);try{await h(e)}catch{J.error(o(`sessions.sidebar.session.rename.smartTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{B(!1)}}),Le=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]),Re=Q.useMemo(()=>{if(!E)return{};if(E.kind===`session`){let e=E.session;return{onRename:()=>{L(e.title?.trim()||o(`mobile.sessions.untitled`)),F(e)},onTogglePin:()=>d(e.id),onShare:e.share?.url?void 0:()=>{Ae(e)},onCopyLink:e.share?.url?()=>{je(e.share.url)}:void 0,onUnshare:e.share?.url?()=>{Me(e.id)}:void 0,onRefreshTranscript:ge,onArchive:()=>{me({id:e.id,title:e.title?.trim()||o(`mobile.sessions.untitled`)})},onDelete:()=>Ne(e)}}if(E.kind===`project`){let e=E.project;return{onNewSession:()=>be(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:()=>be(e,t),onDeleteWorktree:()=>{let n=Ce(e,t);if(!n){J.error(o(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}W({project:e,worktree:n})}}},[E,me,je,Ne,ge,De,Oe,Ae,Me,Ce,be,o,d]),ze=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:g(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)(Vs,{className:a,projects:c.projects,pinnedSessions:c.pinnedSessions,inProgressSessions:c.inProgressSessions,onAddProject:t,onNewSession:xe,onScanQr:r,onSwitchInstance:i,onToggleProject:ve,onOpenProjectActions:Se,onToggleWorktree:ye,onNewWorktreeSession:we,onOpenWorktreeActions:Te,onDeleteWorktree:Ee,onSelectSession:fe,onPinSession:pe,onArchiveSession:e=>{me(e)},onOpenSessionActions:_e}),(0,$.jsx)(Ks,{open:O,target:Le,actions:Re,refreshTranscriptDisabled:K,refreshTranscriptSpinning:le,onOpenChange:e=>{e?k(!0):de()}}),(0,$.jsx)(ut,{open:V,projectId:H,onOpenChange:e=>{ne(e),e||re(null)},onWorktreeCreated:ke}),U?(0,$.jsx)(mr,{open:!0,project:{id:U.project.id,path:U.project.path},worktree:U.worktree,onClose:()=>W(null)}):null,(0,$.jsx)(un,{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)(Z,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>N(null),children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Z,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!M)return;let e=M;N(null),w(e.id),J.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)(un,{open:!!P,title:o(`sessions.sidebar.session.menu.rename`),onClose:()=>{z||(F(null),L(``))},closeAriaLabel:o(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Z,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:z,onClick:()=>{F(null),L(``)},children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Z,{type:`button`,variant:`default`,className:`flex-1`,disabled:!I.trim()||z,onClick:()=>void Pe(),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(),Pe()},children:[(0,$.jsx)(Yt,{value:I,onChange:e=>L(e.target.value),autoFocus:!0,className:`h-12`,disabled:z}),(0,$.jsxs)(Z,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:z,onClick:()=>void Fe(),children:[z?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`ai-generate-2`,className:`size-4`}),o(`sessions.sidebar.session.rename.smartTitle`)]})]})}),(0,$.jsx)(hr,{open:A!==null,project:ze,onClose:()=>j(null)})]})}function mc(e){let t=(0,zi.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=Y(`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)(tr,{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 hc(e){let t=(0,zi.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=[...ir],t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,$.jsx)(oi,{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)(tr,{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 gc(e){let t=(0,zi.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,p=c===void 0?null:c,{t:m}=ee(),h=We(),_=We(Dc),v=We(Ec),y=We(Tc),b=We(wc),x=We(Cc),S=We(Sc),C=We(xc),w=We(bc),T=We(yc),E;t[0]===_?E=t[1]:(E=e=>{e===`settings`&&k.getState().setSettingsPage(`home`),_(e)},t[0]=_,t[1]=E);let D=R(E),O;t[2]===v?O=t[3]:(O=e=>{v(e)},t[2]=v,t[3]=O);let A=R(O),j;t[4]===x?j=t[5]:(j=()=>{x()},t[4]=x,t[5]=j);let M=R(j),N;t[6]===y?N=t[7]:(N=()=>{y()},t[6]=y,t[7]=N);let P=R(N),F;t[8]===b?F=t[9]:(F=e=>{b(e)},t[8]=b,t[9]=F);let I=R(F),L=Q.useRef(null),[z,te]=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=R(B),ne;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(ne=e=>{te(e)},t[11]=ne):ne=t[11];let H=R(ne),re;t[12]!==M||t[13]!==S?(re=()=>{if(L.current?.())return!0;let e=We.getState().secondary;return e?.kind===`chat`&&e.routes.length>1?(S(),!0):e?(M(),!0):!1},t[12]=M,t[13]=S,t[14]=re):re=t[14];let U=R(re),W=h.secondary!==null,ie;t[15]!==U||t[16]!==l?(ie=()=>{if(l)return l(()=>U()),()=>l(null)},t[15]=U,t[16]=l,t[17]=ie):ie=t[17];let ae;t[18]!==U||t[19]!==l||t[20]!==W?(ae=[l,W,U],t[18]=U,t[19]=l,t[20]=W,t[21]=ae):ae=t[21],Q.useEffect(ie,ae);let G=q(vc),oe;t[22]===G?oe=t[23]:(oe=e=>G?e.getDirectoryForSession(G):null,t[22]=G,t[23]=oe);let se=q(oe),ce,le;t[24]!==se||t[25]!==G||t[26]!==w||t[27]!==T?(ce=()=>{let e=We.getState().secondary;if(e?.kind===`draft`&&G){w({sessionId:G,directory:se});return}if(e?.kind!==`chat`||!G||qe({sessionId:G,directory:se})===`internal`)return;let t=e.routes.at(-1);(t?.sessionId!==G||g(t.directory)!==g(se))&&T({sessionId:G,directory:se})},le=[se,G,w,T],t[24]=se,t[25]=G,t[26]=w,t[27]=T,t[28]=ce,t[29]=le):(ce=t[28],le=t[29]),Q.useEffect(ce,le);let K,ue;t[30]!==G||t[31]!==p||t[32]!==C?(K=()=>{let e=We.getState().secondary;if(e?.kind!==`chat`||!p)return;let t=e.routes.at(-1);!t||t.sessionId!==G||C({sessionId:p.id,directory:p.directory})},ue=[G,p,C],t[30]=G,t[31]=p,t[32]=C,t[33]=K,t[34]=ue):(K=t[33],ue=t[34]),Q.useEffect(K,ue);let de;t[35]!==H||t[36]!==V||t[37]!==u?(de=typeof u==`function`?u(V,H):u,t[35]=H,t[36]=V,t[37]=u,t[38]=de):de=t[38];let fe=de,pe;t[39]!==P||t[40]!==n||t[41]!==r||t[42]!==i||t[43]!==A?(pe=(0,$.jsx)(pc,{onOpenChat:A,onAddProject:n,onNewSession:P,onScanQr:r,onSwitchInstance:i}),t[39]=P,t[40]=n,t[41]=r,t[42]=i,t[43]=A,t[44]=pe):pe=t[44];let me;t[45]!==a||t[46]!==I?(me=(0,$.jsx)(Jo,{onEnable:a,onOpenAssistant:I}),t[45]=a,t[46]=I,t[47]=me):me=t[47];let he;t[48]===fe?he=t[49]:(he=(0,$.jsx)(mc,{showHeader:!1,children:fe}),t[48]=fe,t[49]=he);let ge;t[50]===o?ge=t[51]:(ge=(0,$.jsx)(hc,{instancesPage:o}),t[50]=o,t[51]=ge);let _e;t[52]!==pe||t[53]!==me||t[54]!==he||t[55]!==ge?(_e={projects:pe,assistant:me,scheduled:he,settings:ge},t[52]=pe,t[53]=me,t[54]=he,t[55]=ge,t[56]=_e):_e=t[56];let ve=_e,ye=h.secondary?.kind??null,be;bb0:{if(!ye){be=null;break bb0}if(ye===`assistant`){let e;t[57]===m?e=t[58]:(e=m(`assistants.title`),t[57]=m,t[58]=e);let n;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(mi,{activeOverride:!0,onMobileBack:_c}),t[59]=n):n=t[59];let r;t[60]!==U||t[61]!==e?(r=[{key:`assistant-secondary`,depth:1,ariaLabel:e,onBack:U,content:n}],t[60]=U,t[61]=e,t[62]=r):r=t[62],be=r;break bb0}if(ye===`instances`){let e;t[63]===m?e=t[64]:(e=m(`mobile.settings.switchInstance`),t[63]=m,t[64]=e);let n;t[65]!==U||t[66]!==s||t[67]!==e?(n=[{key:`instances-secondary`,depth:1,ariaLabel:e,onBack:U,content:s}],t[65]=U,t[66]=s,t[67]=e,t[68]=n):n=t[68],be=n;break bb0}if(h.secondary?.kind===`draft`){let e;t[69]===m?e=t[70]:(e=m(`mobile.nav.secondaryPageAria`),t[69]=m,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]!==U||t[74]!==e||t[75]!==n?(r=[{key:`chat-primary`,depth:1,ariaLabel:e,onBack:U,content:n}],t[73]=U,t[74]=e,t[75]=n,t[76]=r):r=t[76],be=r;break bb0}if(h.secondary?.kind!==`chat`){let e;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[77]=e):e=t[77],be=e;break bb0}let e=h.secondary.routes,n;if(t[78]!==U||t[79]!==d||t[80]!==e||t[81]!==m){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:m(`mobile.nav.secondaryPageAria`),onBack:U,content:d({sessionId:e.sessionId,directory:e.directory,viewKey:e.key,active:n})}}),t[78]=U,t[79]=d,t[80]=e,t[81]=m,t[82]=n}else n=t[82];be=n}let xe=be,Se;t[83]===xe?Se=t[84]:(Se=xe??[],t[83]=xe,t[84]=Se);let Ce;return t[85]!==f||t[86]!==h||t[87]!==z||t[88]!==D||t[89]!==Se||t[90]!==ve?(Ce=(0,$.jsx)(_s,{className:f,navigation:h,onTabChange:D,tabs:ve,secondaryPages:Se,tabBarCovered:z}),t[85]=f,t[86]=h,t[87]=z,t[88]=D,t[89]=Se,t[90]=ve,t[91]=Ce):Ce=t[91],Ce}function _c(){return kn.requestAnimatedBack(`root`)}function vc(e){return e.currentSessionId}function yc(e){return e.replaceChatSession}function bc(e){return e.materializeDraftSession}function xc(e){return e.reconcileChatPredecessor}function Sc(e){return e.popChatSession}function Cc(e){return e.closeSecondary}function wc(e){return e.openAssistant}function Tc(e){return e.openDraft}function Ec(e){return e.openSession}function Dc(e){return e.setActiveTab}function Oc(e){let t=(0,zi.c)(19),{percentage:n}=e,r,i,a,o,s,c,l;if(t[0]!==n){a=rn(n)??0;let e=Qt(n);i=e===`critical`?`var(--status-error)`:e===`warn`?`var(--status-warning)`:`var(--status-success)`,r=2*Math.PI*7.5,o=`0 0 18 18`,s=`size-[18px] -rotate-90`,c=`progressbar`,l=Math.round(a),t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7];let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:3}),t[8]=u):u=t[8];let d=r*(1-a/100),f;t[9]!==r||t[10]!==i||t[11]!==d?(f=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:i,strokeWidth:3,strokeLinecap:`round`,strokeDasharray:r,strokeDashoffset:d,className:`transition-[stroke-dashoffset,stroke] duration-300`}),t[9]=r,t[10]=i,t[11]=d,t[12]=f):f=t[12];let p;return t[13]!==o||t[14]!==s||t[15]!==c||t[16]!==l||t[17]!==f?(p=(0,$.jsxs)(`svg`,{viewBox:o,className:s,role:c,"aria-valuenow":l,"aria-valuemin":0,"aria-valuemax":100,children:[u,f]}),t[13]=o,t[14]=s,t[15]=c,t[16]=l,t[17]=f,t[18]=p):p=t[18],p}function kc(e){let t=(0,zi.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=R(i),p=R(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)(le,{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 Ac=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},jc=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),Mc=e=>e>=90?`text-[var(--status-error)]`:e>=75?`text-[var(--status-warning)]`:`text-[var(--status-success)]`,Nc=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:`${jc(t)}/${jc(n)}`,colorClass:Mc(i)}},Pc=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=ge(e,t??(()=>void 0));return!n||`compacted`in n?0:n.totalTokens},Ic=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Lc=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`},Rc=e=>{let t=(0,zi.c)(13),{iconNode:n,iconName:r,label:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o=n??(r?(0,$.jsx)(X,{name:r,className:`size-[18px]`}):null),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s;t[3]===o?s=t[4]:(s=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:o}),t[3]=o,t[4]=s);let c;t[5]===i?c=t[6]:(c=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:i}),t[5]=i,t[6]=c);let l;t[7]===a?l=t[8]:(l=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground`,children:a}),t[7]=a,t[8]=l);let u;return t[9]!==s||t[10]!==c||t[11]!==l?(u=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5`,children:[s,c,l]}),t[9]=s,t[10]=c,t[11]=l,t[12]=u):u=t[12],u},zc=e=>{let t=(0,zi.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=ee(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(X,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,$.jsx)(X,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,$.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(Bt,{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=$t(e.window.valueLabel,t),i=ln(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:Y(`shrink-0 typography-ui-label font-semibold tabular-nums`,Lc(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},Bc=e=>{let t=(0,zi.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=Y(`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)(Rc,{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)(Rc,{iconNode:(0,$.jsx)(Oc,{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:Y(`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)(zc,{groups:o,displayMode:s,isLoading:c,timeFormatPreference:l}),t[29]=c,t[30]=l,t[31]=s,t[32]=o,t[33]=j):j=t[33];let M;t[34]!==k||t[35]!==A||t[36]!==j?(M=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[k,A,j]}),t[34]=k,t[35]=A,t[36]=j,t[37]=M):M=t[37];let N;t[38]!==T||t[39]!==D||t[40]!==M||t[41]!==C?(N=(0,$.jsx)(`div`,{ref:d,role:`dialog`,"aria-label":C,className:T,style:D,onPointerDown:ol,children:M}),t[38]=T,t[39]=D,t[40]=M,t[41]=C,t[42]=N):N=t[42];let P;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(`style`,{children:`
6
6
  @keyframes session-metadata-in {
7
7
  from { opacity: 0; transform: translateY(-8px) scale(0.985); }
8
8
  to { opacity: 1; transform: translateY(0) scale(1); }
@@ -25,4 +25,4 @@ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{p as t,t as n,v as r,w
25
25
  from { opacity: 1; transform: translateY(0) scale(1); }
26
26
  to { opacity: 0; transform: translateY(-6px) scale(0.985); }
27
27
  }
28
- `}),t[52]=re):re=t[52];let U;return t[53]===H?U=t[54]:(U=(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:[H,re]}),t[53]=H,t[54]=U),U},Cf=e=>{let t=(0,zi.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=ee(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(X,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,$.jsx)(X,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,$.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(Bt,{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=$t(e.window.valueLabel,t),i=ln(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:Y(`shrink-0 typography-ui-label font-semibold tabular-nums`,bf(e.window)),children:n===`-`?``:n})]},e.key)})}):null,e.status&&e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 typography-micro text-muted-foreground`,children:e.status}):null]},e.providerId),t[22]=r,t[23]=a,t[24]=e):e=t[24],g=n.map(e),t[18]=r,t[19]=n,t[20]=a,t[21]=g}else g=t[21];let _;t[25]===g?_=t[26]:(_=(0,$.jsx)(`div`,{className:`space-y-1.5`,children:g}),t[25]=g,t[26]=_);let v;return t[27]!==_||t[28]!==h?(v=(0,$.jsxs)(`div`,{className:`pt-2.5`,children:[h,_]}),t[27]=_,t[28]=h,t[29]=v):v=t[29],v},wf=e=>{let t=(0,zi.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:Y(`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,t>0&&`border-t border-border/30`,e.disabled&&`cursor-not-allowed opacity-60`),style:{touchAction:`manipulation`},disabled:e.disabled,onClick:()=>{e.onSelect(),r()},children:[e.iconNode??(e.icon?(0,$.jsx)(X,{name:e.icon,className:Y(`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:Zd,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:kf,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},Tf=Q.memo(function(e){let t=(0,zi.c)(88),{open:n,onOpenChange:r,currentSessionId:i,effectiveDirectory:a,gitDirectory:o,isNewSessionDraftOpen:s,primaryLabel:c,secondaryLabel:l}=e,{t:u}=ee(),{git:d}=gn(),f=ul(i??``,a||void 0),p=f??l,m=Q.useRef(null),h=Re(i??``,a||void 0),g=bn(o),_=xn(o),v=_n(Af),y=_n(jf),b=be(Mf),x=be(Nf),S=be(Pf),C=be(Ff),w;t[0]===i?w=t[1]:(w=e=>i?e.sessionModelSelections.get(i)??null:null,t[0]=i,t[1]=w);let T=me(w),E=lr(If),D=lr(Lf),O=lr(Rf),A=lr(zf),j=lr(Bf),M=lr(Vf),N=lr(Hf),P=k(Uf);Qn();let F,I;t[2]!==v||t[3]!==d||t[4]!==o?(F=()=>{o&&v(o,d)},I=[v,d,o],t[2]=v,t[3]=d,t[4]=o,t[5]=F,t[6]=I):(F=t[5],I=t[6]),Q.useEffect(F,I);let L,R;t[7]!==y||t[8]!==d||t[9]!==o?(L=()=>{if(o)return De.onGitRefreshHint(e=>{ff(e.directory)===o&&y(o,d)})},R=[y,d,o],t[7]=y,t[8]=d,t[9]=o,t[10]=L,t[11]=R):(L=t[10],R=t[11]),Q.useEffect(L,R);let z,te;t[12]===D?(z=t[13],te=t[14]):(z=()=>{D()},te=[D],t[12]=D,t[13]=z,t[14]=te),Q.useEffect(z,te);let B,V;t[15]===M?(B=t[16],V=t[17]):(B=()=>{Mt(M)},V=[M],t[15]=M,t[16]=B,t[17]=V),Q.useEffect(B,V);let ne,H;t[18]!==M||t[19]!==O||t[20]!==A||t[21]!==n||t[22]!==E?(ne=()=>{!n||A||M.some(e=>!E.some(t=>t.providerId===e))&&O()},H=[M,O,A,n,E],t[18]=M,t[19]=O,t[20]=A,t[21]=n,t[22]=E,t[23]=ne,t[24]=H):(ne=t[23],H=t[24]),Q.useEffect(ne,H);let re;t[25]===h?re=t[26]:(re=Pc(h),t[25]=h,t[26]=re);let U=re,W;if(t[27]!==h||t[28]!==S||t[29]!==x||t[30]!==C||t[31]!==s||t[32]!==U||t[33]!==b||t[34]!==T){let e=U??(T?{providerID:T.providerId,modelID:T.modelId}:null)??(x&&S?{providerID:x,modelID:S}:null),n=(e?b.find(t=>t.id===e.providerID):void 0)?.models.find(t=>t.id===e?.modelID),r=e?C(e.providerID,e.modelID):void 0,i=Ac(n?.limit,`context`)??r?.limit?.context??0,a;t[36]===h?a=t[37]:(a=Fc(h),t[36]=h,t[37]=a),W=Nc({totalTokens:a,contextLimit:i,isDraft:s}),t[27]=h,t[28]=S,t[29]=x,t[30]=C,t[31]=s,t[32]=U,t[33]=b,t[34]=T,t[35]=W}else W=t[35];let ie=W,ae;t[38]!==_?.current||t[39]!==g||t[40]!==u?(ae=g===!0?_?.current?.trim()||u(`gitView.branch.detachedHead`):u(`common.unavailable`),t[38]=_?.current,t[39]=g,t[40]=u,t[41]=ae):ae=t[41];let G=ae,oe;if(t[42]!==M||t[43]!==E||t[44]!==N||t[45]!==u){let e=new Map(E.map(Wf)),n;t[47]===M?n=t[48]:(n=e=>M.includes(e.id),t[47]=M,t[48]=n),oe=rr.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:cn(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:cn(i),subtitle:Jn(e),window:a})}let s=!n.ok&&n.error?n.error:r.length===0?u(`header.services.noRateLimitsReported`):null;return{providerId:t.id,providerName:t.name,rows:r,status:s}}),t[42]=M,t[43]=E,t[44]=N,t[45]=u,t[46]=oe}else oe=t[46];let se=oe,ce,le;t[49]!==n||t[50]!==se?(ce=()=>{!n||se.length===0||Mt(se.map(Gf))},le=[n,se],t[49]=n,t[50]=se,t[51]=ce,t[52]=le):(ce=t[51],le=t[52]),Q.useEffect(ce,le);let K;t[53]===c?K=t[54]:(K=(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:c}),t[53]=c,t[54]=K);let ue;t[55]!==p||t[56]!==f?(ue=p?(0,$.jsx)(`span`,{className:Y(`block truncate`,f?`oc-mobile-detail-subtitle text-muted-foreground`:`typography-micro text-muted-foreground`),"aria-live":`polite`,children:p}):null,t[55]=p,t[56]=f,t[57]=ue):ue=t[57];let de;t[58]!==K||t[59]!==ue?(de=(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center px-2 py-1.5 text-left`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[K,ue]})}),t[58]=K,t[59]=ue,t[60]=de):de=t[60];let fe;t[61]===u?fe=t[62]:(fe=u(`mobile.header.openMetadataAria`),t[61]=u,t[62]=fe);let pe;t[63]===r?pe=t[64]:(pe=()=>r(Kf),t[63]=r,t[64]=pe);let he;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(he={touchAction:`manipulation`},t[65]=he):he=t[65];let ge=ie?.percentage??0,_e;t[66]===ge?_e=t[67]:(_e=(0,$.jsx)(Oc,{percentage:ge}),t[66]=ge,t[67]=_e);let ve;t[68]!==n||t[69]!==fe||t[70]!==pe||t[71]!==_e?(ve=(0,$.jsx)(`button`,{ref:m,type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":fe,"aria-expanded":n,onClick:pe,style:he,children:_e}),t[68]=n,t[69]=fe,t[70]=pe,t[71]=_e,t[72]=ve):ve=t[72];let ye;t[73]===r?ye=t[74]:(ye=()=>r(!1),t[73]=r,t[74]=ye);let xe;t[75]!==G||t[76]!==ie||t[77]!==A||t[78]!==n||t[79]!==j||t[80]!==ye||t[81]!==P||t[82]!==se?(xe=(0,$.jsx)(Sf,{open:n,onClose:ye,anchorRef:m,contextDisplay:ie,branchLabel:G,usageGroups:se,usageDisplayMode:j,isUsageLoading:A,timeFormatPreference:P}),t[75]=G,t[76]=ie,t[77]=A,t[78]=n,t[79]=j,t[80]=ye,t[81]=P,t[82]=se,t[83]=xe):xe=t[83];let Se;return t[84]!==de||t[85]!==ve||t[86]!==xe?(Se=(0,$.jsxs)($.Fragment,{children:[de,ve,xe]}),t[84]=de,t[85]=ve,t[86]=xe,t[87]=Se):Se=t[87],Se}),Ef=({onOpenSessions:e,menuOpen:t,onToggleMenu:n,surfaceShortcuts:r})=>{let{t:i}=ee(),[a,o]=Q.useState(!1),s=C(e=>e.currentDirectory),c=q(e=>e.currentSessionId),l=Q.useMemo(()=>e=>c?e.getDirectoryForSession(c):null,[c]),u=q(l)||s,d=ff(u)||null,f=Ie(e=>e.projects),p=q(e=>e.availableWorktreesByProject),m=Q.useMemo(()=>e=>c?e.worktreeMetadata.get(c)??null:null,[c]),h=q(m),g=Ce(c),_=q(e=>!!e.newSessionDraft?.open),v=Q.useMemo(()=>{let e=ff(u);return e&&gf((h?.projectDirectory?ye(f,h.projectDirectory):null)??pe(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=R(()=>{o(!1),e()}),S=R(()=>{o(!1),n()});return(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(pa,{children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":i(`mobile.sessions.openSheetAria`),onClick:x,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`folders`,className:`size-5`})}),(0,$.jsx)(Tf,{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:Y(`flex size-10 shrink-0 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r.activePanel===`files`?`bg-[var(--interactive-selection)] text-[var(--interactive-selectionForeground)]`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),"aria-label":i(`mobile.menu.files`),"aria-pressed":r.activePanel===`files`,onClick:r.onToggleFiles,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`file-text`,className:`size-5`})}),(0,$.jsxs)(`button`,{type:`button`,className:Y(`relative flex size-10 shrink-0 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r.activePanel===`changes`?`bg-[var(--interactive-selection)] text-[var(--interactive-selectionForeground)]`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),"aria-label":i(`mobile.menu.changes`),"aria-pressed":r.activePanel===`changes`,onClick:r.onToggleChanges,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-5`}),r.changesDirty?(0,$.jsx)(`span`,{className:`absolute right-2 top-2 inline-flex size-2 rounded-full bg-primary`,"aria-hidden":!0}):null]})]}):null,(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":i(`mobile.header.openMenuAria`),"aria-controls":Zd,"aria-expanded":t,"aria-haspopup":`menu`,onClick:S,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`more-2`,className:`size-5`})})]})})},Df=({connection:e,onActiveConnectionDeleted:t})=>{let{t:n}=ee(),r=Dt();Ze(),Ye();let i=k(e=>e.mobileSessionPanelOpen),a=k(e=>e.setMobileSessionPanelOpen),o=k(e=>e.isScheduledTasksDialogOpen),s=k(e=>e.activeMainTab),c=ce(),l=k(e=>e.setActiveMainTab),[u,d]=Q.useState(!1),[f,p]=Q.useState(!1),[m,h]=Q.useState(null),[g,_]=Q.useState(!1),[v,y]=Q.useState(!1),[b,x]=Q.useState(null),[S,w]=Q.useState(null),[T,D]=Q.useState(null),[O,A]=Q.useState(0),[j,M]=Q.useState(!1),[N,P]=Q.useState(!1),[F,I]=Q.useState(!1),[z,te]=Q.useState(!1),[B,V]=Q.useState(!1),[ne,H]=Q.useState(!1),[re,U]=Q.useState(`nav`),[W,ie]=Q.useState(!1),[ae,G]=Q.useState(!1),oe=R(()=>ie(e=>!e)),se=R(()=>ie(!1)),[K,ue]=Q.useState(null),de=C(e=>e.currentDirectory),fe=k(e=>e.setSettingsPage),pe=Xn(e=>e.available),me=Xn(e=>e.runtimeType),ge=Q.useMemo(()=>cf(),[]),_e=Q.useMemo(()=>Nl(),[]),{data:ve=[],refetch:ye}=qn(de??null,{enabled:j}),{refetch:be}=$n(de??null,{enabled:j}),xe=ti(e=>e.setMcpDraft),Se=ti(e=>e.setSelectedMcp),Ce=xn(ff(de)||null)?.files?.length??0;Q.useEffect(()=>De.onDirectoryRequest(()=>V(!0)),[]);let we=Q.useMemo(()=>E(),[]),Te=fn()===`portrait`,[Oe,ke]=Q.useState(we&&!Te),[Ae,je]=Q.useState(null),Me=R(e=>{if(e&&fe(e),we){U(e?`page-content`:`nav`),I(!0);return}let t=We.getState();if(e){t.openSettingsFromCurrent();return}fe(`home`),t.setActiveTab(`settings`)}),Ne=R(()=>{Me(`instances`)}),Pe=R(()=>{We.getState().openInstances()}),Fe=R(()=>{We.getState().closeSecondary()}),Ie=R(async()=>{if(!ne){H(!0);try{let t=await Pl();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`:L.error(n(`mobile.connect.scan.permissionDenied`));break;case`invalid`:L.error(n(`mobile.connect.scan.invalid`));break;case`unsupported`:L.error(n(`mobile.connect.scan.unsupported`));break;case`failed`:L.error(n(`mobile.connect.scan.failed`))}}finally{H(!1)}}});wn({enabled:!we,rootRoutesBlocked:i||u||f||g||v||o||j||F||z||B||W});let Le=R(()=>{let e=!Oe;e&&Te&&je(null),ke(e)}),J=R(()=>{if(y(!1),x(null),w(null),p(!1),h(null),we){ue(null),je(`files`),Te&&ke(!1);return}d(!0)}),Re=R(()=>{p(!1),h(null)}),ze=R(e=>{let t=e.path.trim();if(t){if(y(!1),x(null),w(null),ue(null),_(!1),we){k.getState().setPendingFileFocusPath(t),je(`files`),Te&&ke(!1);return}d(!1),h({path:t,targetLine:typeof e.targetLine==`number`&&Number.isFinite(e.targetLine)?Math.max(1,Math.trunc(e.targetLine)):void 0}),p(!0)}}),Be=k(e=>e.pendingFileFocusPath);Q.useEffect(()=>{if(Be){if(we){J();return}ze({path:Be}),k.getState().setPendingFileFocusPath(null)}},[Be,we,J,ze]);let Ve=R((e=null)=>{if(y(!1),x(null),w(null),D(null),p(!1),h(null),ue(e),we){je(`changes`),Te&&ke(!1);return}_(!0)}),He=R((e,t,n)=>{ue(null),_(!1),p(!1),h(null),x(e??null),w(typeof t==`string`&&t.trim()?t.trim():null);let r=typeof n==`string`&&n.trim()?n.trim():null;if(D(r),A(e=>e+1),we){je(`turn-diff`),Te&&ke(!1);return}y(!0)}),Ue=R(()=>{je(null),ue(null),D(null)}),Ge=R(e=>{if(Ae===e){Ue();return}e===`files`?J():Ve()}),Ke=Q.useRef(`changes`);Ae&&(Ke.current=Ae);let[qe,Je]=Q.useState(!1);Q.useEffect(()=>{if(!we)return;if(Ae){Je(!0);return}let e=window.setTimeout(()=>Je(!1),240);return()=>window.clearTimeout(e)},[Ae,we]);let Xe=Ae??Ke.current,Qe=of(`left`,`openchamber.ipad.leftSidebarWidth`,Qd),$e=of(`right`,`openchamber.ipad.rightSidebarWidth`,$d),et=Q.useMemo(()=>({openChanges:({diffPath:e,staged:t,targetLine:n}={})=>{Ve(e?{path:e,staged:t===!0,targetLine:n}:null)},openToolDiff:({diffPath:e,patches:t,targetLine:n})=>{Ve({path:e,staged:!1,targetLine:n,toolPatches:t})},openTurnDiff:He,openFile:({path:e,targetLine:t})=>{ze({path:e,targetLine:t})},openFiles:()=>J(),openSettings:e=>{Me(e)}}),[Ve,ze,J,Me,He]),tt=R(()=>{_(!1),ue(null)}),nt=R(()=>{y(!1),D(null)});ru(Q.useMemo(()=>({openSessions:()=>{if(we){ke(!0);return}We.getState().setActiveTab(`projects`)},openView:e=>{e===`files`?J():e===`mcp`?M(!0):e===`instances`?Ne():e===`update`&&te(!0)},openChanges:({path:e,staged:t}={})=>{Ve(e?{path:e,staged:t===!0}:null)},openSettings:e=>{Me(e)}}),[we,Ve,J,Ne,Me]));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=q(e=>e.currentSessionId),ut=q(e=>e.setCurrentSession),dt=Q.useMemo(()=>e=>lt?e.getDirectoryForSession(lt):null,[lt]),ft=q(dt),pt=Ee(lt,ft||de||void 0),mt=he(lt??``);Hd();let ht=mt?.type===`busy`||mt?.type===`retry`,gt=R(()=>{let e=lt;if(!e||ae||ht)return;let t=ft||de||void 0;G(!0),(async()=>{try{await r.refreshSessionTranscript(e,{directory:t}),L.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{L.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{G(!1)}})()}),_t=R(e=>{ct.current=e}),vt=R(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=We(e=>e.secondary?.kind??null),bt=!we&&(yt===`chat`||yt===`draft`);Q.useEffect(()=>{!we&&!bt&&ie(!1)},[we,bt]),Q.useEffect(()=>{ie(!1)},[lt]),Su(it,{onSwitch:_t,onProgress:vt},we||bt);let xt=we&&s===`assistant`||!we&&!bt||i||u||f||g||v||o||j||F||z||B||W;Hu(it,{onOpen:R(()=>{Jt(zt)?.finish(`commit`)}),onPreviewStart:R(()=>{Jt(zt)?.begin(`present`)}),onPreviewCancel:R(()=>{Jt(zt)?.finish(`cancel`)}),onProgress:R(e=>{e!==null&&Jt(zt)?.update(e)}),disabled:xt},we||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=R(e=>{rt.current=e});df(R(()=>W?(ie(!1),!0):B?(V(!1),!0):o?(window.dispatchEvent(new Event(`oc:scheduled-tasks-close-request`)),!0):i?(a(!1),!0):kn.backImmediately(`overlay`)?!0:f?(Re(),!0):u?(d(!1),!0):v?(nt(),!0):g?(tt(),!0):j?(M(!1),!0):F?(I(!1),!0):z?(te(!1),!0):kn.requestAnimatedBack(`root`)||rt.current?.()?!0:s===`assistant`?(l(`chat`),!0):pt?(ut(pt.id,pt.directory),!0):!1));let Ct=pe&&(me===`desktop`||me===`web`),wt=R(()=>{let e=`new-mcp-server`,t=e,n=1;for(;ve.some(e=>e.name===t);)t=`${e}-${n}`,n+=1;xe({name:t,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),Se(t),M(!1),Me(`mcp`)}),Tt=R(()=>{if(N)return;P(!0);let e=new Promise(e=>window.setTimeout(e,500));Promise.all([be(),ye(),e]).finally(()=>P(!1))}),Et=q(e=>e.openNewSessionDraft),Ot=Q.useMemo(()=>{let e=[{key:`new-session`,icon:`chat-new`,label:n(`mobile.menu.newSession`),onSelect:()=>{if(we){l(`chat`),Et();return}We.getState().openDraft()}}];return we||e.push({key:`files`,icon:`file-text`,label:n(`mobile.menu.files`),onSelect:()=>J()},{key:`changes`,icon:`git-branch`,label:n(`mobile.menu.changes`),badge:Ce,onSelect:()=>Ve()}),e.push({key:`mcp`,iconNode:(0,$.jsx)(cr,{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:()=>te(!0)}),we&&e.push({key:`settings`,icon:`settings-3`,label:n(`mobile.menu.settings`),onSelect:()=>Me()}),lt&&e.push({key:`refresh-transcript`,icon:`refresh`,label:n(`sessions.sidebar.session.menu.refreshTranscript`),disabled:ae||ht,spinning:ae,onSelect:gt}),e},[lt,Ce,we,ht,ae,Ve,J,Et,Me,gt,l,Ct,n]);return(0,$.jsxs)(Wn,{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:[we?(0,$.jsxs)(`aside`,{ref:Qe.asideRef,className:Y(`relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/50 bg-sidebar will-change-[width] motion-reduce:transition-none`,!Oe&&`border-r-0`),style:{width:Oe?Qe.width:0,minWidth:Oe?Qe.width:0,maxWidth:Oe?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":!Oe,"data-page-scroll-lock":`true`,children:[Oe?(0,$.jsx)(sf,{side:`left`,isResizing:Qe.isResizing,ariaLabel:n(`sidebar.resize.leftPanelAria`),handleProps:Qe.handleProps}):null,(0,$.jsx)(`div`,{className:Y(`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`,!Oe&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:(0,$.jsx)(on,{children:(0,$.jsx)(Vo,{open:!0,variant:`sidebar`,onOpenChange:e=>{!e&&Te&&ke(!1)}})})})]}):null,(0,$.jsx)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,"data-page-scroll-lock":`true`,children:we?(0,$.jsxs)($.Fragment,{children:[s===`assistant`?null:(0,$.jsx)(`div`,{children:(0,$.jsx)(Ef,{onOpenSessions:()=>Le(),menuOpen:W,onToggleMenu:oe,surfaceShortcuts:{activePanel:Ae===`turn-diff`?`changes`:Ae,changesDirty:Ce>0,onToggleFiles:()=>Ge(`files`),onToggleChanges:()=>Ge(`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)(X,{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)(X,{name:`arrow-right`,className:`size-5`})}),(0,$.jsx)(`span`,{className:`typography-micro font-medium tracking-wide text-muted-foreground/60`,children:n(`helpDialog.item.nextSession`)})]}),(0,$.jsx)(`div`,{ref:at,className:`relative h-full w-full bg-background`,children:(0,$.jsx)(on,{children:s===`assistant`?(0,$.jsx)(mi,{}):(0,$.jsx)(Nr,{})})})]})]}):(0,$.jsx)(gc,{className:`min-h-0 flex-1`,onAddProject:()=>V(!0),onScanQr:ge&&_e?()=>{Ie()}:void 0,onSwitchInstance:ge?Pe:void 0,onEnableAssistants:()=>{Me(`assistants`)},instancesPage:ge?(0,$.jsx)(yf,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t}):void 0,instancesSecondaryPage:ge?(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)(le,{title:n(`mobile.settings.switchInstance`),backAriaLabel:n(`header.actions.backAria`),onBack:Fe}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-[var(--oc-mobile-page-inline-inset)]`,children:(0,$.jsx)(nr,{className:`oc-mobile-settings-detail-card`,children:(0,$.jsx)(yf,{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)(hl,{sessionId:e.sessionId,directory:e.directory,onBack:()=>{se(),kn.requestAnimatedBack(`root`)},onOpenMenu:oe,onCloseMenu:se,menuOpen:e.active&&W,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)(X,{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)(X,{name:`arrow-right`,className:`size-5`})}),(0,$.jsx)(`span`,{className:`typography-micro font-medium tracking-wide text-muted-foreground/60`,children:n(`helpDialog.item.nextSession`)})]})]}):null,(0,$.jsx)(`div`,{ref:e.active?at:void 0,className:`relative h-full w-full bg-background`,children:(0,$.jsx)(on,{children:(0,$.jsx)(Nr,{readOnly:!e.active,active:e.active,selectionOverride:{sessionId:e.sessionId||null,directory:e.directory,viewKey:e.viewKey}})})})]})})})}),we?(0,$.jsxs)(`aside`,{ref:$e.asideRef,className:Y(`relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/50 bg-background will-change-[width] motion-reduce:transition-none`,!Ae&&`border-l-0`),style:{width:Ae?$e.width:0,minWidth:Ae?$e.width:0,maxWidth:Ae?$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":!Ae,"data-page-scroll-lock":`true`,children:[Ae?(0,$.jsx)(sf,{side:`right`,isResizing:$e.isResizing,ariaLabel:n(`sidebar.resize.rightPanelAria`),handleProps:$e.handleProps}):null,(0,$.jsx)(`div`,{className:Y(`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`,!Ae&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:qe?(0,$.jsx)(on,{children:Xe===`files`?(0,$.jsx)(io,{onClose:Ue}):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)(Z,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ue,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(gr,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:b,sessionId:S,targetFilePath:T,navigationRequestKey:O,flushContent:!0})})]}):K?.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:K.toolPatches.length>1?n(`mobile.nav.changes`):K.path}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ue,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(gr,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:K.path,targetLine:K.targetLine??null,toolPatches:K.toolPatches,singleFileView:K.toolPatches.length===1,flushContent:!0})})]}):(0,$.jsx)(Ta,{onClose:Ue,initialDiffPath:K?.path??null,initialDiffStaged:K?.staged===!0,initialDiffTargetLine:K?.targetLine??null})}):null})]}):null,(0,$.jsx)(Ur,{open:B,onOpenChange:V,forceMobile:!0}),(0,$.jsx)(wf,{open:W,onClose:()=>ie(!1),items:Ot,rightOffset:we&&Ae?$e.width:0}),(0,$.jsx)(Mr,{}),u?(0,$.jsx)(Gt,{id:Kd,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)(on,{children:(0,$.jsx)(io,{onClose:()=>d(!1)})})}):null,f&&m?(0,$.jsx)(Gt,{id:Gd,open:f,onOpenChange:e=>{e||Re()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:m.path.split(/[/\\]/).filter(Boolean).at(-1)??m.path}),ariaLabel:n(`mobile.menu.files`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(on,{children:(0,$.jsx)(io,{onClose:Re,initialFilePath:m.path,directFilePreview:!0,hideFileHeader:!0},m.path)})}):null,(0,$.jsx)(Gt,{id:Wd,open:v,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)(on,{children:(0,$.jsx)(gr,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:b,sessionId:S,targetFilePath:T,navigationRequestKey:O,flushContent:!0})})}),g&&K?(0,$.jsx)(Gt,{id:Ud,open:g,onOpenChange:e=>{e||tt()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:K.toolPatches&&K.toolPatches.length>1?n(`mobile.nav.changes`):K.path}),ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(on,{children:K.toolPatches?.length?(0,$.jsx)(gr,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:K.path,targetLine:K.targetLine??null,toolPatches:K.toolPatches,singleFileView:K.toolPatches.length===1,flushContent:!0}):(0,$.jsx)(Ta,{initialDiffPath:K.path,initialDiffStaged:K.staged,initialDiffTargetLine:K.targetLine??null,hideDiffHeader:!0})})}):g?(0,$.jsx)(Gt,{id:qd,open:g,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)(on,{children:(0,$.jsx)(Ta,{onClose:tt,initialDiffPath:K?.path??null,initialDiffStaged:K?.staged===!0,initialDiffTargetLine:K?.targetLine??null})})}):null,j?(0,$.jsx)(Gt,{id:Jd,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)(Z,{type:`button`,variant:`ghost`,size:`icon`,onClick:wt,"aria-label":n(`settings.mcp.sidebar.actions.addServerTitle`),title:n(`settings.mcp.sidebar.actions.addServerTitle`),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`add`,className:`size-5`})}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,onClick:Tt,disabled:N,"aria-label":n(`mcpDropdown.actions.refreshAria`),title:n(`mcpDropdown.actions.refreshAria`),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`refresh`,className:Y(`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)(on,{children:(0,$.jsx)(Lr,{active:!0,className:`h-full`,listClassName:`max-h-none`,hideHeader:!0,mobileListDensity:!0})})}):null,F&&we?(0,$.jsx)(Gt,{id:Yd,open:F,onOpenChange:e=>{e||I(!1)},ariaLabel:n(`mobile.menu.settings`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(on,{children:(0,$.jsx)(oi,{forceMobile:!0,isWindowed:!0,initialMobileStage:re,visiblePageSlugs:[...ir],onClose:()=>I(!1),mobileInstancesPage:ge?(0,$.jsx)(yf,{connection:e,onConnect:()=>I(!1),onActiveConnectionDeleted:t}):void 0})})}):null,z?(0,$.jsx)(Gt,{id:Xd,open:z,onOpenChange:e=>{e||te(!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)(on,{children:(0,$.jsx)(`div`,{className:`h-full overflow-auto px-5 py-4`,children:(0,$.jsx)(ni,{initialUpdateDialogOpen:!0})})})}):null]}),(0,$.jsx)($r,{enabled:ge&&s===`assistant`&&c.data?.supported===!0&&c.data?.enabled===!0}),(0,$.jsx)(on,{children:(0,$.jsx)(Yr,{})})]})};function Of({apis:e}){Q.useEffect(()=>Me(),[]);let{t}=ee(),n=be(e=>e.initializeApp),r=be(e=>e.isInitialized),i=be(e=>e.isConnected),o=be(e=>e.connectionPhase),s=C(e=>e.currentDirectory),l=q(e=>e.currentSessionId),d=q(e=>!!e.newSessionDraft?.open),f=q(e=>e.error),p=q(e=>e.clearError),m=k(e=>e.setIsMobile),h=er(e=>e.refreshStatus),g=Ie(e=>e.projects),[v,y]=Q.useState(0),[b,x]=Q.useState(0),[S,T]=Q.useState(!1),[E,D]=Q.useState(`pending`),O=Q.useMemo(()=>W(),[]),[,A]=Q.useReducer(e=>e+1,0),j=Q.useMemo(()=>cf(),[]),N=Q.useRef(0),P=Q.useRef(0),I=U(()=>{D(`done`),y(e=>e+1)});iu(R(e=>{I.redeemPairingConnection(e)}));let z=au({ready:j&&i&&r});Q.useEffect(()=>{!I.error||!u()||L.error(I.error)},[I.error]);let te=R(()=>{let t=u(),r=P.current+1;if(P.current=r,!t){ae();return}let i=()=>{n(),h(e.github,{force:!0}),be.getState().refreshMissingCatalogs({source:`mobileApp:nativeResume`})},a=()=>{c({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),y(e=>e+1)};re().then(e=>{if(P.current===r){if(e===`no-connection`){a();return}if(e===`unreachable`){window.setTimeout(()=>{P.current===r&&re().then(e=>{if(P.current===r&&e!==`switched`&&e===`unchanged`){i();return}})},4e3);return}e!==`switched`&&i()}});let o=Date.now();o-N.current>=mf&&(N.current=o,window.dispatchEvent(new Event(`openchamber:system-resume`)))});lf(),uf(te),Q.useEffect(()=>{if(!j)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>te(),1500)};return window.addEventListener(`online`,t),()=>{window.removeEventListener(`online`,t),window.clearTimeout(e)}},[j,te]),Q.useEffect(()=>(_(e),()=>_(null)),[e]),Q.useEffect(()=>{j&&F().then(e=>{e&&e.notifyAppReady().catch(()=>void 0)})},[j]),Q.useEffect(()=>{if(!j)return;let e=!1,t=[];return F().then(async n=>{if(!(!n||e))try{let r=await n.addListener(`download`,e=>{Xn.getState().setOtaDownloadPercent(e.percent)}),i=await n.addListener(`downloadFailed`,()=>{Xn.getState().setOtaDownloadFailed()}),a=await n.addListener(`downloadComplete`,()=>{Xn.getState().setOtaPhase(`pending_restart`)}),o=await n.addListener(`appReloaded`,()=>{Xn.getState().setOtaPhase(`pending_restart`)}),s=await n.addListener(`autoRevert`,()=>{console.warn(`[OTA] Capgo auto-reverted the last bundle`),Xn.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()}},[j]),Q.useEffect(()=>a(e=>{if(e.runtimeKey&&e.runtimeKey===e.previousRuntimeKey){Kr(),A();return}Vr(e),We.getState().reset(),x(e=>e+1),y(e=>e+1)}),[]),Q.useEffect(()=>{if(z===`pending`)return;if(z===`connect`){D(`done`);return}if(!j||i||u()){D(`done`);return}let e=!1;return D(`attempting`),ie().then(e=>e?!0:ae()).catch(()=>!1).then(()=>{e||D(`done`)}),()=>{e=!0}},[z]),Q.useEffect(()=>{m(!0)},[m]),Q.useEffect(()=>{j&&!u()||n()},[v,n,j]),kt({enabled:!j||!!u(),source:`mobileApp:recovery`}),Q.useEffect(()=>{i&&w.setDirectory(s)},[s,i]),Q.useEffect(()=>{i&&h(e.github,{force:!0})},[e.github,i,h]),Q.useEffect(()=>{if(!i||g.length===0)return;let e=!1;return(async()=>{await Promise.all(g.map(async t=>{let n=ff(t.path);if(n)try{if(!(_n.getState().directories.get(n)?.isGitRepo??await M(()=>import(`./gitApi-Cm3JLQqh.js`).then(e=>e.S).then(e=>e.checkIsGitRepository(n)),__vite__mapDeps([58,1,2,3,4,24,7,5,6,25,8,26,37,38,10,39,40,41,20,21,22,23,27,42,43])))||e)return;await qt({id:t.id,path:n},{isCurrent:()=>!e})}catch{}}))})(),()=>{e=!0}},[i,g]),Q.useEffect(()=>{if(!f)return;let e=window.setTimeout(()=>p(),5e3);return()=>window.clearTimeout(e)},[p,f]),Q.useEffect(()=>{if(!(!i&&(!j||u()))){T(!1);return}let e=window.setTimeout(()=>T(!0),8e3);return()=>window.clearTimeout(e)},[i,j,v,b]),Ot(),ot({enabled:!0}),dt(),Dr(),Gu({enabled:j&&i});let B=Rl(),V=!i&&o===`reconnecting`;if(!B)return(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(Zt,{width:120,height:120,isAnimated:!0})});let ne=!!u();return j&&(!ne||!i&&!V)?ne?(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)(Zt,{width:120,height:120,isAnimated:!S}),S?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h1`,{className:`typography-h3 text-foreground`,children:t(`sessionAuth.error.networkTitle`)}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:t(`sessionAuth.error.networkDescription`)})]}),(0,$.jsx)(Z,{type:`button`,variant:`outline`,onClick:()=>{c({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),y(e=>e+1)},children:t(`mobile.connect.cancelPassword`)})]}):null]})}):E===`done`?(0,$.jsx)(vf,{connection:I}):(0,$.jsxs)(`main`,{className:`relative flex min-h-dvh items-center justify-center bg-background text-foreground`,children:[(0,$.jsx)(Zt,{width:120,height:120,isAnimated:!0}),O?(0,$.jsxs)(`div`,{className:`absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center`,children:[(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:t(`mobile.connect.splash.connectingTo`)}),(0,$.jsxs)(`p`,{className:`typography-small text-foreground`,children:[O,(0,$.jsx)(Tt,{})]})]}):null]}):!i&&!V?S?(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground`,children:(0,$.jsxs)(`div`,{className:`max-w-sm space-y-3`,children:[(0,$.jsx)(`h1`,{className:`typography-h3 text-foreground`,children:t(`sessionAuth.error.networkTitle`)}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:t(`sessionAuth.error.networkDescription`)})]})}):(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(Zt,{width:120,height:120,isAnimated:!0})}):(0,$.jsx)(on,{children:(0,$.jsx)(_e,{sdk:w.getSdkClient(),directory:s||``,bootstrapDirectory:!(d&&l===null),children:(0,$.jsx)(yt,{apis:e,children:(0,$.jsx)(Xt,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:`h-full bg-background text-foreground`,children:[(0,$.jsx)(Fr,{}),(0,$.jsx)(G,{}),(0,$.jsx)(_t,{embeddedBackgroundWorkEnabled:r}),(0,$.jsx)(Hr,{}),(0,$.jsx)(Gi,{}),(0,$.jsx)(ta,{}),(0,$.jsx)(Df,{connection:I,onActiveConnectionDeleted:()=>{c({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),We.getState().reset(),y(e=>e+1)}}),(0,$.jsx)(pt,{position:`top-center`,offset:`calc(var(--oc-safe-area-top, 0px) + 16px)`}),r?(0,$.jsx)(qr,{}):null]})})})},b)})}function kf(e){e.currentTarget.style.transform=`none`}function Af(e){return e.ensureStatus}function jf(e){return e.fetchStatus}function Mf(e){return e.providers}function Nf(e){return e.currentProviderId}function Pf(e){return e.currentModelId}function Ff(e){return e.getModelMetadata}function If(e){return e.results}function Lf(e){return e.loadSettings}function Rf(e){return e.fetchAllQuotas}function zf(e){return e.isLoading}function Bf(e){return e.displayMode}function Vf(e){return e.dropdownProviderIds}function Hf(e){return e.selectedModels}function Uf(e){return e.timeFormatPreference}function Wf(e){return[e.providerId,e]}function Gf(e){return e.providerId}function Kf(e){return!e}var qf=()=>{V(),h().then(()=>{Promise.all([m(),st()]).catch(e=>{console.error(`[mobile-main] settings init failed:`,e)}),bt(),St(),ht()}).catch(e=>{console.error(`[mobile-main] appearance init failed:`,e)}).finally(()=>{Ai()})};function Jf(e){Mn(),qf(),k.getState().setIsMobile(!0),Ri(),pn(),mn();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)(Of,{apis:r});(0,Ei.createRoot)(t).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(mt,{children:(0,$.jsx)(z,{children:(0,$.jsx)(gt,{children:(0,$.jsx)(At,{children:(0,$.jsx)(kr,{children:n?i:(0,$.jsx)(ft,{children:i})})})})})})}))}export{Jf as renderMobileApp};
28
+ `}),t[52]=re):re=t[52];let U;return t[53]===H?U=t[54]:(U=(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:[H,re]}),t[53]=H,t[54]=U),U},Cf=e=>{let t=(0,zi.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=ee(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(X,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,$.jsx)(X,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,$.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(Bt,{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=$t(e.window.valueLabel,t),i=ln(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:Y(`shrink-0 typography-ui-label font-semibold tabular-nums`,bf(e.window)),children:n===`-`?``:n})]},e.key)})}):null,e.status&&e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 typography-micro text-muted-foreground`,children:e.status}):null]},e.providerId),t[22]=r,t[23]=a,t[24]=e):e=t[24],g=n.map(e),t[18]=r,t[19]=n,t[20]=a,t[21]=g}else g=t[21];let _;t[25]===g?_=t[26]:(_=(0,$.jsx)(`div`,{className:`space-y-1.5`,children:g}),t[25]=g,t[26]=_);let v;return t[27]!==_||t[28]!==h?(v=(0,$.jsxs)(`div`,{className:`pt-2.5`,children:[h,_]}),t[27]=_,t[28]=h,t[29]=v):v=t[29],v},wf=e=>{let t=(0,zi.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:Y(`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset`,t>0&&`border-t border-border/30`,e.disabled&&`cursor-not-allowed opacity-60`),style:{touchAction:`manipulation`},disabled:e.disabled,onClick:()=>{e.onSelect(),r()},children:[e.iconNode??(e.icon?(0,$.jsx)(X,{name:e.icon,className:Y(`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:Zd,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:kf,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},Tf=Q.memo(function(e){let t=(0,zi.c)(88),{open:n,onOpenChange:r,currentSessionId:i,effectiveDirectory:a,gitDirectory:o,isNewSessionDraftOpen:s,primaryLabel:c,secondaryLabel:l}=e,{t:u}=ee(),{git:d}=gn(),f=ul(i??``,a||void 0),p=f??l,m=Q.useRef(null),h=Re(i??``,a||void 0),g=bn(o),_=xn(o),v=_n(Af),y=_n(jf),b=be(Mf),x=be(Nf),S=be(Pf),C=be(Ff),w;t[0]===i?w=t[1]:(w=e=>i?e.sessionModelSelections.get(i)??null:null,t[0]=i,t[1]=w);let T=me(w),E=lr(If),D=lr(Lf),O=lr(Rf),A=lr(zf),j=lr(Bf),M=lr(Vf),N=lr(Hf),P=k(Uf);Qn();let F,I;t[2]!==v||t[3]!==d||t[4]!==o?(F=()=>{o&&v(o,d)},I=[v,d,o],t[2]=v,t[3]=d,t[4]=o,t[5]=F,t[6]=I):(F=t[5],I=t[6]),Q.useEffect(F,I);let L,R;t[7]!==y||t[8]!==d||t[9]!==o?(L=()=>{if(o)return De.onGitRefreshHint(e=>{ff(e.directory)===o&&y(o,d)})},R=[y,d,o],t[7]=y,t[8]=d,t[9]=o,t[10]=L,t[11]=R):(L=t[10],R=t[11]),Q.useEffect(L,R);let z,te;t[12]===D?(z=t[13],te=t[14]):(z=()=>{D()},te=[D],t[12]=D,t[13]=z,t[14]=te),Q.useEffect(z,te);let B,V;t[15]===M?(B=t[16],V=t[17]):(B=()=>{Mt(M)},V=[M],t[15]=M,t[16]=B,t[17]=V),Q.useEffect(B,V);let ne,H;t[18]!==M||t[19]!==O||t[20]!==A||t[21]!==n||t[22]!==E?(ne=()=>{!n||A||M.some(e=>!E.some(t=>t.providerId===e))&&O()},H=[M,O,A,n,E],t[18]=M,t[19]=O,t[20]=A,t[21]=n,t[22]=E,t[23]=ne,t[24]=H):(ne=t[23],H=t[24]),Q.useEffect(ne,H);let re;t[25]===h?re=t[26]:(re=Pc(h),t[25]=h,t[26]=re);let U=re,W;if(t[27]!==h||t[28]!==S||t[29]!==x||t[30]!==C||t[31]!==s||t[32]!==U||t[33]!==b||t[34]!==T){let e=U??(T?{providerID:T.providerId,modelID:T.modelId}:null)??(x&&S?{providerID:x,modelID:S}:null),n=(e?b.find(t=>t.id===e.providerID):void 0)?.models.find(t=>t.id===e?.modelID),r=e?C(e.providerID,e.modelID):void 0,i=Ac(n?.limit,`context`)??r?.limit?.context??0,a;t[36]===h?a=t[37]:(a=Fc(h),t[36]=h,t[37]=a),W=Nc({totalTokens:a,contextLimit:i,isDraft:s}),t[27]=h,t[28]=S,t[29]=x,t[30]=C,t[31]=s,t[32]=U,t[33]=b,t[34]=T,t[35]=W}else W=t[35];let ie=W,ae;t[38]!==_?.current||t[39]!==g||t[40]!==u?(ae=g===!0?_?.current?.trim()||u(`gitView.branch.detachedHead`):u(`common.unavailable`),t[38]=_?.current,t[39]=g,t[40]=u,t[41]=ae):ae=t[41];let G=ae,oe;if(t[42]!==M||t[43]!==E||t[44]!==N||t[45]!==u){let e=new Map(E.map(Wf)),n;t[47]===M?n=t[48]:(n=e=>M.includes(e.id),t[47]=M,t[48]=n),oe=rr.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:cn(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:cn(i),subtitle:Jn(e),window:a})}let s=!n.ok&&n.error?n.error:r.length===0?u(`header.services.noRateLimitsReported`):null;return{providerId:t.id,providerName:t.name,rows:r,status:s}}),t[42]=M,t[43]=E,t[44]=N,t[45]=u,t[46]=oe}else oe=t[46];let se=oe,ce,le;t[49]!==n||t[50]!==se?(ce=()=>{!n||se.length===0||Mt(se.map(Gf))},le=[n,se],t[49]=n,t[50]=se,t[51]=ce,t[52]=le):(ce=t[51],le=t[52]),Q.useEffect(ce,le);let K;t[53]===c?K=t[54]:(K=(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:c}),t[53]=c,t[54]=K);let ue;t[55]!==p||t[56]!==f?(ue=p?(0,$.jsx)(`span`,{className:Y(`block truncate`,f?`oc-mobile-detail-subtitle text-muted-foreground`:`typography-micro text-muted-foreground`),"aria-live":`polite`,children:p}):null,t[55]=p,t[56]=f,t[57]=ue):ue=t[57];let de;t[58]!==K||t[59]!==ue?(de=(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center px-2 py-1.5 text-left`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[K,ue]})}),t[58]=K,t[59]=ue,t[60]=de):de=t[60];let fe;t[61]===u?fe=t[62]:(fe=u(`mobile.header.openMetadataAria`),t[61]=u,t[62]=fe);let pe;t[63]===r?pe=t[64]:(pe=()=>r(Kf),t[63]=r,t[64]=pe);let he;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(he={touchAction:`manipulation`},t[65]=he):he=t[65];let ge=ie?.percentage??0,_e;t[66]===ge?_e=t[67]:(_e=(0,$.jsx)(Oc,{percentage:ge}),t[66]=ge,t[67]=_e);let ve;t[68]!==n||t[69]!==fe||t[70]!==pe||t[71]!==_e?(ve=(0,$.jsx)(`button`,{ref:m,type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":fe,"aria-expanded":n,onClick:pe,style:he,children:_e}),t[68]=n,t[69]=fe,t[70]=pe,t[71]=_e,t[72]=ve):ve=t[72];let ye;t[73]===r?ye=t[74]:(ye=()=>r(!1),t[73]=r,t[74]=ye);let xe;t[75]!==G||t[76]!==ie||t[77]!==A||t[78]!==n||t[79]!==j||t[80]!==ye||t[81]!==P||t[82]!==se?(xe=(0,$.jsx)(Sf,{open:n,onClose:ye,anchorRef:m,contextDisplay:ie,branchLabel:G,usageGroups:se,usageDisplayMode:j,isUsageLoading:A,timeFormatPreference:P}),t[75]=G,t[76]=ie,t[77]=A,t[78]=n,t[79]=j,t[80]=ye,t[81]=P,t[82]=se,t[83]=xe):xe=t[83];let Se;return t[84]!==de||t[85]!==ve||t[86]!==xe?(Se=(0,$.jsxs)($.Fragment,{children:[de,ve,xe]}),t[84]=de,t[85]=ve,t[86]=xe,t[87]=Se):Se=t[87],Se}),Ef=({onOpenSessions:e,menuOpen:t,onToggleMenu:n,surfaceShortcuts:r})=>{let{t:i}=ee(),[a,o]=Q.useState(!1),s=C(e=>e.currentDirectory),c=q(e=>e.currentSessionId),l=Q.useMemo(()=>e=>c?e.getDirectoryForSession(c):null,[c]),u=q(l)||s,d=ff(u)||null,f=Ie(e=>e.projects),p=q(e=>e.availableWorktreesByProject),m=Q.useMemo(()=>e=>c?e.worktreeMetadata.get(c)??null:null,[c]),h=q(m),g=Ce(c),_=q(e=>!!e.newSessionDraft?.open),v=Q.useMemo(()=>{let e=ff(u);return e&&gf((h?.projectDirectory?ye(f,h.projectDirectory):null)??pe(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=R(()=>{o(!1),e()}),S=R(()=>{o(!1),n()});return(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(pa,{children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":i(`mobile.sessions.openSheetAria`),onClick:x,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`folders`,className:`size-5`})}),(0,$.jsx)(Tf,{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:Y(`flex size-10 shrink-0 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r.activePanel===`files`?`bg-[var(--interactive-selection)] text-[var(--interactive-selectionForeground)]`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),"aria-label":i(`mobile.menu.files`),"aria-pressed":r.activePanel===`files`,onClick:r.onToggleFiles,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`file-text`,className:`size-5`})}),(0,$.jsxs)(`button`,{type:`button`,className:Y(`relative flex size-10 shrink-0 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r.activePanel===`changes`?`bg-[var(--interactive-selection)] text-[var(--interactive-selectionForeground)]`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),"aria-label":i(`mobile.menu.changes`),"aria-pressed":r.activePanel===`changes`,onClick:r.onToggleChanges,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-5`}),r.changesDirty?(0,$.jsx)(`span`,{className:`absolute right-2 top-2 inline-flex size-2 rounded-full bg-primary`,"aria-hidden":!0}):null]})]}):null,(0,$.jsx)(`button`,{type:`button`,className:`flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":i(`mobile.header.openMenuAria`),"aria-controls":Zd,"aria-expanded":t,"aria-haspopup":`menu`,onClick:S,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`more-2`,className:`size-5`})})]})})},Df=({connection:e,onActiveConnectionDeleted:t})=>{let{t:n}=ee(),r=Dt();Ze(),Ye();let i=k(e=>e.mobileSessionPanelOpen),a=k(e=>e.setMobileSessionPanelOpen),o=k(e=>e.isScheduledTasksDialogOpen),s=k(e=>e.activeMainTab),c=ce(),l=k(e=>e.setActiveMainTab),[u,d]=Q.useState(!1),[f,p]=Q.useState(!1),[m,h]=Q.useState(null),[g,_]=Q.useState(!1),[v,y]=Q.useState(!1),[b,x]=Q.useState(null),[S,w]=Q.useState(null),[T,D]=Q.useState(null),[O,A]=Q.useState(0),[j,M]=Q.useState(!1),[N,P]=Q.useState(!1),[F,I]=Q.useState(!1),[z,te]=Q.useState(!1),[B,V]=Q.useState(!1),[ne,H]=Q.useState(!1),[re,U]=Q.useState(`nav`),[W,ie]=Q.useState(!1),[ae,G]=Q.useState(!1),oe=R(()=>ie(e=>!e)),se=R(()=>ie(!1)),[K,ue]=Q.useState(null),de=C(e=>e.currentDirectory),fe=k(e=>e.setSettingsPage),pe=Xn(e=>e.available),me=Xn(e=>e.runtimeType),ge=Q.useMemo(()=>cf(),[]),_e=Q.useMemo(()=>Nl(),[]),{data:ve=[],refetch:ye}=qn(de??null,{enabled:j}),{refetch:be}=$n(de??null,{enabled:j}),xe=ti(e=>e.setMcpDraft),Se=ti(e=>e.setSelectedMcp),Ce=xn(ff(de)||null)?.files?.length??0;Q.useEffect(()=>De.onDirectoryRequest(()=>V(!0)),[]);let we=Q.useMemo(()=>E(),[]),Te=fn()===`portrait`,[Oe,ke]=Q.useState(we&&!Te),[Ae,je]=Q.useState(null),Me=R(e=>{if(e&&fe(e),we){U(e?`page-content`:`nav`),I(!0);return}let t=We.getState();if(e){t.openSettingsFromCurrent();return}fe(`home`),t.setActiveTab(`settings`)}),Ne=R(()=>{Me(`instances`)}),Pe=R(()=>{We.getState().openInstances()}),Fe=R(()=>{We.getState().closeSecondary()}),Ie=R(async()=>{if(!ne){H(!0);try{let t=await Pl();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`:L.error(n(`mobile.connect.scan.permissionDenied`));break;case`invalid`:L.error(n(`mobile.connect.scan.invalid`));break;case`unsupported`:L.error(n(`mobile.connect.scan.unsupported`));break;case`failed`:L.error(n(`mobile.connect.scan.failed`))}}finally{H(!1)}}});wn({enabled:!we,rootRoutesBlocked:i||u||f||g||v||o||j||F||z||B||W});let Le=R(()=>{let e=!Oe;e&&Te&&je(null),ke(e)}),J=R(()=>{if(y(!1),x(null),w(null),p(!1),h(null),we){ue(null),je(`files`),Te&&ke(!1);return}d(!0)}),Re=R(()=>{p(!1),h(null)}),ze=R(e=>{let t=e.path.trim();if(t){if(y(!1),x(null),w(null),ue(null),_(!1),we){k.getState().setPendingFileFocusPath(t),je(`files`),Te&&ke(!1);return}d(!1),h({path:t,targetLine:typeof e.targetLine==`number`&&Number.isFinite(e.targetLine)?Math.max(1,Math.trunc(e.targetLine)):void 0}),p(!0)}}),Be=k(e=>e.pendingFileFocusPath);Q.useEffect(()=>{if(Be){if(we){J();return}ze({path:Be}),k.getState().setPendingFileFocusPath(null)}},[Be,we,J,ze]);let Ve=R((e=null)=>{if(y(!1),x(null),w(null),D(null),p(!1),h(null),ue(e),we){je(`changes`),Te&&ke(!1);return}_(!0)}),He=R((e,t,n)=>{ue(null),_(!1),p(!1),h(null),x(e??null),w(typeof t==`string`&&t.trim()?t.trim():null);let r=typeof n==`string`&&n.trim()?n.trim():null;if(D(r),A(e=>e+1),we){je(`turn-diff`),Te&&ke(!1);return}y(!0)}),Ue=R(()=>{je(null),ue(null),D(null)}),Ge=R(e=>{if(Ae===e){Ue();return}e===`files`?J():Ve()}),Ke=Q.useRef(`changes`);Ae&&(Ke.current=Ae);let[qe,Je]=Q.useState(!1);Q.useEffect(()=>{if(!we)return;if(Ae){Je(!0);return}let e=window.setTimeout(()=>Je(!1),240);return()=>window.clearTimeout(e)},[Ae,we]);let Xe=Ae??Ke.current,Qe=of(`left`,`openchamber.ipad.leftSidebarWidth`,Qd),$e=of(`right`,`openchamber.ipad.rightSidebarWidth`,$d),et=Q.useMemo(()=>({openChanges:({diffPath:e,staged:t,targetLine:n}={})=>{Ve(e?{path:e,staged:t===!0,targetLine:n}:null)},openToolDiff:({diffPath:e,patches:t,targetLine:n})=>{Ve({path:e,staged:!1,targetLine:n,toolPatches:t})},openTurnDiff:He,openFile:({path:e,targetLine:t})=>{ze({path:e,targetLine:t})},openFiles:()=>J(),openSettings:e=>{Me(e)}}),[Ve,ze,J,Me,He]),tt=R(()=>{_(!1),ue(null)}),nt=R(()=>{y(!1),D(null)});ru(Q.useMemo(()=>({openSessions:()=>{if(we){ke(!0);return}We.getState().setActiveTab(`projects`)},openView:e=>{e===`files`?J():e===`mcp`?M(!0):e===`instances`?Ne():e===`update`&&te(!0)},openChanges:({path:e,staged:t}={})=>{Ve(e?{path:e,staged:t===!0}:null)},openSettings:e=>{Me(e)}}),[we,Ve,J,Ne,Me]));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=q(e=>e.currentSessionId),ut=q(e=>e.setCurrentSession),dt=Q.useMemo(()=>e=>lt?e.getDirectoryForSession(lt):null,[lt]),ft=q(dt),pt=Ee(lt,ft||de||void 0),mt=he(lt??``);Hd();let ht=mt?.type===`busy`||mt?.type===`retry`,gt=R(()=>{let e=lt;if(!e||ae||ht)return;let t=ft||de||void 0;G(!0),(async()=>{try{await r.refreshSessionTranscript(e,{directory:t}),L.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{L.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{G(!1)}})()}),_t=R(e=>{ct.current=e}),vt=R(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=We(e=>e.secondary?.kind??null),bt=!we&&(yt===`chat`||yt===`draft`);Q.useEffect(()=>{!we&&!bt&&ie(!1)},[we,bt]),Q.useEffect(()=>{ie(!1)},[lt]),Su(it,{onSwitch:_t,onProgress:vt},we||bt);let xt=we&&s===`assistant`||!we&&!bt||i||u||f||g||v||o||j||F||z||B||W;Hu(it,{onOpen:R(()=>{Jt(zt)?.finish(`commit`)}),onPreviewStart:R(()=>{Jt(zt)?.begin(`present`)}),onPreviewCancel:R(()=>{Jt(zt)?.finish(`cancel`)}),onProgress:R(e=>{e!==null&&Jt(zt)?.update(e)}),disabled:xt},we||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=R(e=>{rt.current=e});df(R(()=>W?(ie(!1),!0):B?(V(!1),!0):o?(window.dispatchEvent(new Event(`oc:scheduled-tasks-close-request`)),!0):i?(a(!1),!0):kn.backImmediately(`overlay`)?!0:f?(Re(),!0):u?(d(!1),!0):v?(nt(),!0):g?(tt(),!0):j?(M(!1),!0):F?(I(!1),!0):z?(te(!1),!0):kn.requestAnimatedBack(`root`)||rt.current?.()?!0:s===`assistant`?(l(`chat`),!0):pt?(ut(pt.id,pt.directory),!0):!1));let Ct=pe&&(me===`desktop`||me===`web`),wt=R(()=>{let e=`new-mcp-server`,t=e,n=1;for(;ve.some(e=>e.name===t);)t=`${e}-${n}`,n+=1;xe({name:t,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),Se(t),M(!1),Me(`mcp`)}),Tt=R(()=>{if(N)return;P(!0);let e=new Promise(e=>window.setTimeout(e,500));Promise.all([be(),ye(),e]).finally(()=>P(!1))}),Et=q(e=>e.openNewSessionDraft),Ot=Q.useMemo(()=>{let e=[{key:`new-session`,icon:`chat-new`,label:n(`mobile.menu.newSession`),onSelect:()=>{if(we){l(`chat`),Et();return}We.getState().openDraft()}}];return we||e.push({key:`files`,icon:`file-text`,label:n(`mobile.menu.files`),onSelect:()=>J()},{key:`changes`,icon:`git-branch`,label:n(`mobile.menu.changes`),badge:Ce,onSelect:()=>Ve()}),e.push({key:`mcp`,iconNode:(0,$.jsx)(cr,{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:()=>te(!0)}),we&&e.push({key:`settings`,icon:`settings-3`,label:n(`mobile.menu.settings`),onSelect:()=>Me()}),lt&&e.push({key:`refresh-transcript`,icon:`refresh`,label:n(`sessions.sidebar.session.menu.refreshTranscript`),disabled:ae||ht,spinning:ae,onSelect:gt}),e},[lt,Ce,we,ht,ae,Ve,J,Et,Me,gt,l,Ct,n]);return(0,$.jsxs)(Wn,{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:[we?(0,$.jsxs)(`aside`,{ref:Qe.asideRef,className:Y(`relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/50 bg-sidebar will-change-[width] motion-reduce:transition-none`,!Oe&&`border-r-0`),style:{width:Oe?Qe.width:0,minWidth:Oe?Qe.width:0,maxWidth:Oe?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":!Oe,"data-page-scroll-lock":`true`,children:[Oe?(0,$.jsx)(sf,{side:`left`,isResizing:Qe.isResizing,ariaLabel:n(`sidebar.resize.leftPanelAria`),handleProps:Qe.handleProps}):null,(0,$.jsx)(`div`,{className:Y(`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`,!Oe&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:(0,$.jsx)(on,{children:(0,$.jsx)(Vo,{open:!0,variant:`sidebar`,onOpenChange:e=>{!e&&Te&&ke(!1)}})})})]}):null,(0,$.jsx)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,"data-page-scroll-lock":`true`,children:we?(0,$.jsxs)($.Fragment,{children:[s===`assistant`?null:(0,$.jsx)(`div`,{children:(0,$.jsx)(Ef,{onOpenSessions:()=>Le(),menuOpen:W,onToggleMenu:oe,surfaceShortcuts:{activePanel:Ae===`turn-diff`?`changes`:Ae,changesDirty:Ce>0,onToggleFiles:()=>Ge(`files`),onToggleChanges:()=>Ge(`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)(X,{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)(X,{name:`arrow-right`,className:`size-5`})}),(0,$.jsx)(`span`,{className:`typography-micro font-medium tracking-wide text-muted-foreground/60`,children:n(`helpDialog.item.nextSession`)})]}),(0,$.jsx)(`div`,{ref:at,className:`relative h-full w-full bg-background`,children:(0,$.jsx)(on,{children:s===`assistant`?(0,$.jsx)(mi,{}):(0,$.jsx)(Nr,{})})})]})]}):(0,$.jsx)(gc,{className:`min-h-0 flex-1`,onAddProject:()=>V(!0),onScanQr:ge&&_e?()=>{Ie()}:void 0,onSwitchInstance:ge?Pe:void 0,onEnableAssistants:()=>{Me(`assistants`)},instancesPage:ge?(0,$.jsx)(yf,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t}):void 0,instancesSecondaryPage:ge?(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)(le,{title:n(`mobile.settings.switchInstance`),backAriaLabel:n(`header.actions.backAria`),onBack:Fe}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-[var(--oc-mobile-page-inline-inset)]`,children:(0,$.jsx)(nr,{className:`oc-mobile-settings-detail-card`,children:(0,$.jsx)(yf,{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)(hl,{sessionId:e.sessionId,directory:e.directory,onBack:()=>{se(),kn.requestAnimatedBack(`root`)},onOpenMenu:oe,onCloseMenu:se,menuOpen:e.active&&W,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)(X,{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)(X,{name:`arrow-right`,className:`size-5`})}),(0,$.jsx)(`span`,{className:`typography-micro font-medium tracking-wide text-muted-foreground/60`,children:n(`helpDialog.item.nextSession`)})]})]}):null,(0,$.jsx)(`div`,{ref:e.active?at:void 0,className:`relative h-full w-full bg-background`,children:(0,$.jsx)(on,{children:(0,$.jsx)(Nr,{readOnly:!e.active,active:e.active,selectionOverride:{sessionId:e.sessionId||null,directory:e.directory,viewKey:e.viewKey}})})})]})})})}),we?(0,$.jsxs)(`aside`,{ref:$e.asideRef,className:Y(`relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/50 bg-background will-change-[width] motion-reduce:transition-none`,!Ae&&`border-l-0`),style:{width:Ae?$e.width:0,minWidth:Ae?$e.width:0,maxWidth:Ae?$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":!Ae,"data-page-scroll-lock":`true`,children:[Ae?(0,$.jsx)(sf,{side:`right`,isResizing:$e.isResizing,ariaLabel:n(`sidebar.resize.rightPanelAria`),handleProps:$e.handleProps}):null,(0,$.jsx)(`div`,{className:Y(`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`,!Ae&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:qe?(0,$.jsx)(on,{children:Xe===`files`?(0,$.jsx)(io,{onClose:Ue}):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)(Z,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ue,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(gr,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:b,sessionId:S,targetFilePath:T,navigationRequestKey:O,flushContent:!0})})]}):K?.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:K.toolPatches.length>1?n(`mobile.nav.changes`):K.path}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ue,"aria-label":n(`mobile.surface.closeAria`),className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(gr,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:K.path,targetLine:K.targetLine??null,toolPatches:K.toolPatches,singleFileView:K.toolPatches.length===1,flushContent:!0})})]}):(0,$.jsx)(Ta,{onClose:Ue,initialDiffPath:K?.path??null,initialDiffStaged:K?.staged===!0,initialDiffTargetLine:K?.targetLine??null})}):null})]}):null,(0,$.jsx)(Ur,{open:B,onOpenChange:V,forceMobile:!0}),(0,$.jsx)(wf,{open:W,onClose:()=>ie(!1),items:Ot,rightOffset:we&&Ae?$e.width:0}),(0,$.jsx)(Mr,{}),u?(0,$.jsx)(Gt,{id:Kd,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)(on,{children:(0,$.jsx)(io,{onClose:()=>d(!1)})})}):null,f&&m?(0,$.jsx)(Gt,{id:Gd,open:f,onOpenChange:e=>{e||Re()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:m.path.split(/[/\\]/).filter(Boolean).at(-1)??m.path}),ariaLabel:n(`mobile.menu.files`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(on,{children:(0,$.jsx)(io,{onClose:Re,initialFilePath:m.path,directFilePreview:!0,hideFileHeader:!0},m.path)})}):null,(0,$.jsx)(Gt,{id:Wd,open:v,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)(on,{children:(0,$.jsx)(gr,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:b,sessionId:S,targetFilePath:T,navigationRequestKey:O,flushContent:!0})})}),g&&K?(0,$.jsx)(Gt,{id:Ud,open:g,onOpenChange:e=>{e||tt()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:K.toolPatches&&K.toolPatches.length>1?n(`mobile.nav.changes`):K.path}),ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(on,{children:K.toolPatches?.length?(0,$.jsx)(gr,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:K.path,targetLine:K.targetLine??null,toolPatches:K.toolPatches,singleFileView:K.toolPatches.length===1,flushContent:!0}):(0,$.jsx)(Ta,{initialDiffPath:K.path,initialDiffStaged:K.staged,initialDiffTargetLine:K.targetLine??null,hideDiffHeader:!0})})}):g?(0,$.jsx)(Gt,{id:qd,open:g,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)(on,{children:(0,$.jsx)(Ta,{onClose:tt,initialDiffPath:K?.path??null,initialDiffStaged:K?.staged===!0,initialDiffTargetLine:K?.targetLine??null})})}):null,j?(0,$.jsx)(Gt,{id:Jd,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)(Z,{type:`button`,variant:`ghost`,size:`icon`,onClick:wt,"aria-label":n(`settings.mcp.sidebar.actions.addServerTitle`),title:n(`settings.mcp.sidebar.actions.addServerTitle`),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`add`,className:`size-5`})}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,onClick:Tt,disabled:N,"aria-label":n(`mcpDropdown.actions.refreshAria`),title:n(`mcpDropdown.actions.refreshAria`),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`refresh`,className:Y(`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)(on,{children:(0,$.jsx)(Lr,{active:!0,className:`h-full`,listClassName:`max-h-none`,hideHeader:!0,mobileListDensity:!0})})}):null,F&&we?(0,$.jsx)(Gt,{id:Yd,open:F,onOpenChange:e=>{e||I(!1)},ariaLabel:n(`mobile.menu.settings`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(on,{children:(0,$.jsx)(oi,{forceMobile:!0,isWindowed:!0,initialMobileStage:re,visiblePageSlugs:[...ir],onClose:()=>I(!1),mobileInstancesPage:ge?(0,$.jsx)(yf,{connection:e,onConnect:()=>I(!1),onActiveConnectionDeleted:t}):void 0})})}):null,z?(0,$.jsx)(Gt,{id:Xd,open:z,onOpenChange:e=>{e||te(!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)(on,{children:(0,$.jsx)(`div`,{className:`h-full overflow-auto px-5 py-4`,children:(0,$.jsx)(ni,{initialUpdateDialogOpen:!0})})})}):null]}),(0,$.jsx)($r,{enabled:ge&&s===`assistant`&&c.data?.supported===!0&&c.data?.enabled===!0}),(0,$.jsx)(on,{children:(0,$.jsx)(Yr,{})})]})};function Of({apis:e}){Q.useEffect(()=>Me(),[]);let{t}=ee(),n=be(e=>e.initializeApp),r=be(e=>e.isInitialized),i=be(e=>e.isConnected),o=be(e=>e.connectionPhase),s=C(e=>e.currentDirectory),l=q(e=>e.currentSessionId),d=q(e=>!!e.newSessionDraft?.open),f=q(e=>e.error),p=q(e=>e.clearError),m=k(e=>e.setIsMobile),h=er(e=>e.refreshStatus),g=Ie(e=>e.projects),[v,y]=Q.useState(0),[b,x]=Q.useState(0),[S,T]=Q.useState(!1),[E,D]=Q.useState(`pending`),O=Q.useMemo(()=>W(),[]),[,A]=Q.useReducer(e=>e+1,0),j=Q.useMemo(()=>cf(),[]),N=Q.useRef(0),P=Q.useRef(0),I=U(()=>{D(`done`),y(e=>e+1)});iu(R(e=>{I.redeemPairingConnection(e)}));let z=au({ready:j&&i&&r});Q.useEffect(()=>{!I.error||!u()||L.error(I.error)},[I.error]);let te=R(()=>{let t=u(),r=P.current+1;if(P.current=r,!t){ae();return}let i=()=>{n(),h(e.github,{force:!0}),be.getState().refreshMissingCatalogs({source:`mobileApp:nativeResume`})},a=()=>{c({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),y(e=>e+1)};re().then(e=>{if(P.current===r){if(e===`no-connection`){a();return}if(e===`unreachable`){window.setTimeout(()=>{P.current===r&&re().then(e=>{if(P.current===r&&e!==`switched`&&e===`unchanged`){i();return}})},4e3);return}e!==`switched`&&i()}});let o=Date.now();o-N.current>=mf&&(N.current=o,window.dispatchEvent(new Event(`openchamber:system-resume`)))});lf(),uf(te),Q.useEffect(()=>{if(!j)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>te(),1500)};return window.addEventListener(`online`,t),()=>{window.removeEventListener(`online`,t),window.clearTimeout(e)}},[j,te]),Q.useEffect(()=>(_(e),()=>_(null)),[e]),Q.useEffect(()=>{j&&F().then(e=>{e&&e.notifyAppReady().catch(()=>void 0)})},[j]),Q.useEffect(()=>{if(!j)return;let e=!1,t=[];return F().then(async n=>{if(!(!n||e))try{let r=await n.addListener(`download`,e=>{Xn.getState().setOtaDownloadPercent(e.percent)}),i=await n.addListener(`downloadFailed`,()=>{Xn.getState().setOtaDownloadFailed()}),a=await n.addListener(`downloadComplete`,()=>{Xn.getState().setOtaPhase(`pending_restart`)}),o=await n.addListener(`appReloaded`,()=>{Xn.getState().setOtaPhase(`pending_restart`)}),s=await n.addListener(`autoRevert`,()=>{console.warn(`[OTA] Capgo auto-reverted the last bundle`),Xn.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()}},[j]),Q.useEffect(()=>a(e=>{if(e.runtimeKey&&e.runtimeKey===e.previousRuntimeKey){Kr(),A();return}Vr(e),We.getState().reset(),x(e=>e+1),y(e=>e+1)}),[]),Q.useEffect(()=>{if(z===`pending`)return;if(z===`connect`){D(`done`);return}if(!j||i||u()){D(`done`);return}let e=!1;return D(`attempting`),ie().then(e=>e?!0:ae()).catch(()=>!1).then(()=>{e||D(`done`)}),()=>{e=!0}},[z]),Q.useEffect(()=>{m(!0)},[m]),Q.useEffect(()=>{j&&!u()||n()},[v,n,j]),kt({enabled:!j||!!u(),source:`mobileApp:recovery`}),Q.useEffect(()=>{i&&w.setDirectory(s)},[s,i]),Q.useEffect(()=>{i&&h(e.github,{force:!0})},[e.github,i,h]),Q.useEffect(()=>{if(!i||g.length===0)return;let e=!1;return(async()=>{await Promise.all(g.map(async t=>{let n=ff(t.path);if(n)try{if(!(_n.getState().directories.get(n)?.isGitRepo??await M(()=>import(`./gitApi-D4PyYgLZ.js`).then(e=>e.S).then(e=>e.checkIsGitRepository(n)),__vite__mapDeps([58,1,2,3,4,24,7,5,6,25,8,26,37,38,10,39,40,41,20,21,22,23,27,42,43])))||e)return;await qt({id:t.id,path:n},{isCurrent:()=>!e})}catch{}}))})(),()=>{e=!0}},[i,g]),Q.useEffect(()=>{if(!f)return;let e=window.setTimeout(()=>p(),5e3);return()=>window.clearTimeout(e)},[p,f]),Q.useEffect(()=>{if(!(!i&&(!j||u()))){T(!1);return}let e=window.setTimeout(()=>T(!0),8e3);return()=>window.clearTimeout(e)},[i,j,v,b]),Ot(),ot({enabled:!0}),dt(),Dr(),Gu({enabled:j&&i});let B=Rl(),V=!i&&o===`reconnecting`;if(!B)return(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(Zt,{width:120,height:120,isAnimated:!0})});let ne=!!u();return j&&(!ne||!i&&!V)?ne?(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)(Zt,{width:120,height:120,isAnimated:!S}),S?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h1`,{className:`typography-h3 text-foreground`,children:t(`sessionAuth.error.networkTitle`)}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:t(`sessionAuth.error.networkDescription`)})]}),(0,$.jsx)(Z,{type:`button`,variant:`outline`,onClick:()=>{c({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),y(e=>e+1)},children:t(`mobile.connect.cancelPassword`)})]}):null]})}):E===`done`?(0,$.jsx)(vf,{connection:I}):(0,$.jsxs)(`main`,{className:`relative flex min-h-dvh items-center justify-center bg-background text-foreground`,children:[(0,$.jsx)(Zt,{width:120,height:120,isAnimated:!0}),O?(0,$.jsxs)(`div`,{className:`absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center`,children:[(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:t(`mobile.connect.splash.connectingTo`)}),(0,$.jsxs)(`p`,{className:`typography-small text-foreground`,children:[O,(0,$.jsx)(Tt,{})]})]}):null]}):!i&&!V?S?(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground`,children:(0,$.jsxs)(`div`,{className:`max-w-sm space-y-3`,children:[(0,$.jsx)(`h1`,{className:`typography-h3 text-foreground`,children:t(`sessionAuth.error.networkTitle`)}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:t(`sessionAuth.error.networkDescription`)})]})}):(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(Zt,{width:120,height:120,isAnimated:!0})}):(0,$.jsx)(on,{children:(0,$.jsx)(_e,{sdk:w.getSdkClient(),directory:s||``,bootstrapDirectory:!(d&&l===null),children:(0,$.jsx)(yt,{apis:e,children:(0,$.jsx)(Xt,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:`h-full bg-background text-foreground`,children:[(0,$.jsx)(Fr,{}),(0,$.jsx)(G,{}),(0,$.jsx)(_t,{embeddedBackgroundWorkEnabled:r}),(0,$.jsx)(Hr,{}),(0,$.jsx)(Gi,{}),(0,$.jsx)(ta,{}),(0,$.jsx)(Df,{connection:I,onActiveConnectionDeleted:()=>{c({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),We.getState().reset(),y(e=>e+1)}}),(0,$.jsx)(pt,{position:`top-center`,offset:`calc(var(--oc-safe-area-top, 0px) + 16px)`}),r?(0,$.jsx)(qr,{}):null]})})})},b)})}function kf(e){e.currentTarget.style.transform=`none`}function Af(e){return e.ensureStatus}function jf(e){return e.fetchStatus}function Mf(e){return e.providers}function Nf(e){return e.currentProviderId}function Pf(e){return e.currentModelId}function Ff(e){return e.getModelMetadata}function If(e){return e.results}function Lf(e){return e.loadSettings}function Rf(e){return e.fetchAllQuotas}function zf(e){return e.isLoading}function Bf(e){return e.displayMode}function Vf(e){return e.dropdownProviderIds}function Hf(e){return e.selectedModels}function Uf(e){return e.timeFormatPreference}function Wf(e){return[e.providerId,e]}function Gf(e){return e.providerId}function Kf(e){return!e}var qf=()=>{V(),h().then(()=>{Promise.all([m(),st()]).catch(e=>{console.error(`[mobile-main] settings init failed:`,e)}),bt(),St(),ht()}).catch(e=>{console.error(`[mobile-main] appearance init failed:`,e)}).finally(()=>{Ai()})};function Jf(e){Mn(),qf(),k.getState().setIsMobile(!0),Ri(),pn(),mn();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)(Of,{apis:r});(0,Ei.createRoot)(t).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(mt,{children:(0,$.jsx)(z,{children:(0,$.jsx)(gt,{children:(0,$.jsx)(At,{children:(0,$.jsx)(kr,{children:n?i:(0,$.jsx)(ft,{children:i})})})})})})}))}export{Jf as renderMobileApp};