@openchambery/web 2.1.10-beta.12 → 2.1.10-beta.14

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 (82) hide show
  1. package/dist/assets/{AgentAvatar-D8ipj0Vr.js → AgentAvatar-VWQTTR4M.js} +1 -1
  2. package/dist/assets/{AssistantView-o_2FGmWi.js → AssistantView-uhR4tG6b.js} +3 -3
  3. package/dist/assets/{DiagramView-BkIY1i8Z.js → DiagramView-BfhJnCcf.js} +1 -1
  4. package/dist/assets/{FadeInOnReveal-CUnBy-rf.js → FadeInOnReveal-fsguD-xX.js} +1 -1
  5. package/dist/assets/{Icon-DJOJhmkK.js → Icon-CEQUcqTJ.js} +1 -1
  6. package/dist/assets/{ImageLoadingPlaceholder-BfOy_RFL.js → ImageLoadingPlaceholder-Bel8eqgg.js} +1 -1
  7. package/dist/assets/{LoadingImage-DAp7ygoZ.js → LoadingImage-DjkSZxMq.js} +1 -1
  8. package/dist/assets/{MarkdownRenderer-CVFTXv6T.js → MarkdownRenderer-Dhwafy6t.js} +2 -2
  9. package/dist/assets/{MarkdownRendererImpl-xDJ3_wfo.js → MarkdownRendererImpl-D39bq7ia.js} +1 -1
  10. package/dist/assets/{MarkstreamRendererImpl-CARsxzOk.js → MarkstreamRendererImpl-s1tH7v6E.js} +1 -1
  11. package/dist/assets/{MobileDetailNavigation-C7XoCy6_.js → MobileDetailNavigation-DoOzaME3.js} +1 -1
  12. package/dist/assets/MobileShareBridge-WSUxqxLs.js +4 -0
  13. package/dist/assets/{MobileTabPageHeader-BfA3Blg2.js → MobileTabPageHeader-PM2MKTCR.js} +1 -1
  14. package/dist/assets/{MultiRunWindow-DEzF6uXQ.js → MultiRunWindow-COhHKQIm.js} +1 -1
  15. package/dist/assets/{OnboardingScreen-C2l09plq.js → OnboardingScreen-CQuSd1SL.js} +1 -1
  16. package/dist/assets/{OverlayScrollbar-Dr5XwsW5.js → OverlayScrollbar-DI271QYq.js} +1 -1
  17. package/dist/assets/{SettingsView-D75F19Z9.js → SettingsView-BkJBlkrH.js} +11 -11
  18. package/dist/assets/{SettingsWindow-DyBoEjPj.js → SettingsWindow-DmGQR_de.js} +1 -1
  19. package/dist/assets/{TerminalView-DRgyfXdO.js → TerminalView-BLylm4N1.js} +1 -1
  20. package/dist/assets/{ToolOutputDialog-KoIg0zrK.js → ToolOutputDialog-BgKvvlMQ.js} +3 -3
  21. package/dist/assets/{ToolOutputDialog-C1c4G7q4.css → ToolOutputDialog-C7usOU7_.css} +1 -1
  22. package/dist/assets/{appThemeRegistry-D7s0BCM_.js → appThemeRegistry-C21TnFyE.js} +1 -1
  23. package/dist/assets/{assistant-attachment-cache-dU-EaPYt.js → assistant-attachment-cache-BWe8KqRS.js} +1 -1
  24. package/dist/assets/{button--NSU9MZj.js → button-9V3jJ3gG.js} +1 -1
  25. package/dist/assets/{collapsible-B9JDgD12.js → collapsible-Cx3lMy_W.js} +1 -1
  26. package/dist/assets/{diagram-Xy80Pnhl.js → diagram-Bpt5dSrL.js} +1 -1
  27. package/dist/assets/{dialog-DMF6va3u.js → dialog-Yxau54Tq.js} +1 -1
  28. package/dist/assets/{dropdown-menu.styles-DSndmPAq.js → dropdown-menu.styles-CtzReuqO.js} +1 -1
  29. package/dist/assets/{es-ChfgOskU.js → es-DsJ_HQyU.js} +1 -1
  30. package/dist/assets/{fileMentionTouchSelection-CagpeffM.js → fileMentionTouchSelection-CFpbCHok.js} +1 -1
  31. package/dist/assets/{fr-DnKqN4E3.js → fr-Dfkjku77.js} +1 -1
  32. package/dist/assets/{gitApi-BVwik90d.js → gitApi-BEDLfTkj.js} +1 -1
  33. package/dist/assets/{image-loading-BbXaWHv9.js → image-loading-ClZBSNMo.js} +1 -1
  34. package/dist/assets/{input-C0EI9bKy.js → input-BqE6rFfR.js} +1 -1
  35. package/dist/assets/{insertionBoundaries-B1UojqLv.js → insertionBoundaries-CvY1e0tv.js} +1 -1
  36. package/dist/assets/{ja-DH-a_ThB.js → ja-C71g0jYh.js} +1 -1
  37. package/dist/assets/{ko-BXABOKd9.js → ko-32s8rv0M.js} +1 -1
  38. package/dist/assets/{main-B-JMz9Zg.js → main--y4Qwozg.js} +4 -4
  39. package/dist/assets/{main-2yJj_50W.js → main-D7KanlAY.js} +2 -2
  40. package/dist/assets/{markdownHeightCache-_0n435fL.js → markdownHeightCache-lTJfaoDe.js} +1 -1
  41. package/dist/assets/{mcpQueries-CBvyBo4z.js → mcpQueries-D_Kk_S1v.js} +1 -1
  42. package/dist/assets/{miniChat-QLQvDR18.js → miniChat-D4bJD1va.js} +2 -2
  43. package/dist/assets/{mobile-D2W9Os9Y.js → mobile-DqLAqfH8.js} +2 -2
  44. package/dist/assets/{mobileBackNavigation-DUcdCT-q.js → mobileBackNavigation-DMOXePrM.js} +1 -1
  45. package/dist/assets/{multirun-BNXvhpnK.js → multirun-B5rB3ZpA.js} +1 -1
  46. package/dist/assets/{pl-D-KNROrB.js → pl-eAbyJFO9.js} +1 -1
  47. package/dist/assets/{platform-jaHE0AyQ.js → platform-C5jNCIbB.js} +1 -1
  48. package/dist/assets/{projectMeta-B7-8QrCr.js → projectMeta-BH3RDv7q.js} +1 -1
  49. package/dist/assets/{pt-BR-UDs5YUzv.js → pt-BR-nVxduPt0.js} +1 -1
  50. package/dist/assets/{renderElectronMiniChatApp-cXQ0iiAs.js → renderElectronMiniChatApp-BtEm3c28.js} +2 -2
  51. package/dist/assets/renderMobileApp-BGP-Q03v.css +1 -0
  52. package/dist/assets/renderMobileApp-YT9hecwY.js +28 -0
  53. package/dist/assets/{runtime-file-download-CzOWaZO_.js → runtime-file-download-CEzr1Pfg.js} +1 -1
  54. package/dist/assets/{runtime-file-resource-WtDqIbiH.js → runtime-file-resource-BUFMRmIF.js} +1 -1
  55. package/dist/assets/{runtimeConfig-WZniSuc4.js → runtimeConfig-CkCyYZXh.js} +1 -1
  56. package/dist/assets/{runtimeEndpointReset-BdC1LMDQ.js → runtimeEndpointReset-DCZ8Voev.js} +2 -2
  57. package/dist/assets/{scheduledTaskNavigation-CUbKrS_Q.js → scheduledTaskNavigation-j6F6n0ym.js} +1 -1
  58. package/dist/assets/{sessionChangeSummary-FnRoTUCa.js → sessionChangeSummary-C3_UQtMT.js} +1 -1
  59. package/dist/assets/{sessionLookup-Dyf9EV-B.js → sessionLookup-BwSgUERM.js} +1 -1
  60. package/dist/assets/{sortable-tabs-strip-ubL98Ysr.js → sortable-tabs-strip-DFi-Mck5.js} +1 -1
  61. package/dist/assets/{speechSettingsQueries-B5rRSSZa.js → speechSettingsQueries-mJxWFvgZ.js} +2 -2
  62. package/dist/assets/src-DzBIReeh.css +2 -0
  63. package/dist/assets/{store-D79UkOhB.js → store-D4rR0svj.js} +2 -2
  64. package/dist/assets/{terminalApi-CK8s1iYr.js → terminalApi-B8arordk.js} +1 -1
  65. package/dist/assets/{textarea-D2NwOmCU.js → textarea-DoWm-pRV.js} +1 -1
  66. package/dist/assets/{tooltip-CRvh1CJe.js → tooltip-DWlA7PRY.js} +1 -1
  67. package/dist/assets/{uk-CkliYeRs.js → uk-DOvCFanR.js} +1 -1
  68. package/dist/assets/{useAppFontEffects-CICX6ccA.js → useAppFontEffects-BADGZPdc.js} +51 -51
  69. package/dist/assets/{useDesktopWindowControlsLayout-DPp8-6hC.js → useDesktopWindowControlsLayout-Psu62aui.js} +1 -1
  70. package/dist/assets/{useEffectiveDirectory-CzkOEaY-.js → useEffectiveDirectory-CxHHduLw.js} +1 -1
  71. package/dist/assets/{useFontPreferences-BLwhdOar.js → useFontPreferences-Ctm4A_2D.js} +1 -1
  72. package/dist/assets/{useMobileNavigationStore-CeMnArss.js → useMobileNavigationStore-C4OpUIeW.js} +6 -6
  73. package/dist/assets/{useWorkerHighlightedLines-DxLthSDl.js → useWorkerHighlightedLines-BYB6GGCp.js} +1 -1
  74. package/dist/assets/{zh-CN-DdInLm-R.js → zh-CN-CuYFLeS4.js} +1 -1
  75. package/dist/assets/{zh-TW-QxWs2t3K.js → zh-TW-DKJIyd5A.js} +1 -1
  76. package/dist/index.html +7 -7
  77. package/dist/mini-chat.html +7 -7
  78. package/dist/mobile.html +7 -7
  79. package/package.json +1 -1
  80. package/dist/assets/MobileShareBridge-0q0bC1g-.js +0 -4
  81. package/dist/assets/renderMobileApp-BZ-dHkIL.js +0 -28
  82. package/dist/assets/src-DvTg6DjE.css +0 -2
@@ -1,28 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-KoIg0zrK.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-auth-BpCQ-dPr.js","assets/runtime-switch-CMiMO5Yj.js","assets/queryRuntime-DRiRiAgZ.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/persistence-CAKBi4bp.js","assets/vendor-zustand-o69pgTEK.js","assets/vendor-base-ui-CdzJ6My_.js","assets/useUIStore-CEqU9Ujv.js","assets/vendor-react-BP2cRVqX.js","assets/vendor-pathe-vBmvQE8f.js","assets/platform-jaHE0AyQ.js","assets/vendor-opencode-client-MF2GBrFx.js","assets/runtime-file-resource-WtDqIbiH.js","assets/vendor-tanstack-react-query-CdqCAt40.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-download-CzOWaZO_.js","assets/vendor-pierre-diffs-DPBtNDJ5.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.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-BMOrLc9L.js","assets/vendor-reactuses-core-BpfIZ1tg.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button--NSU9MZj.js","assets/store-D79UkOhB.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useThemeSystem-8jhE4Zyk.js","assets/Icon-DJOJhmkK.js","assets/dialog-DMF6va3u.js","assets/image-loading-BbXaWHv9.js","assets/image-loading-j2FgxzZQ.css","assets/MobileWindowStack-DGLdgoGr.js","assets/appThemeRegistry-D7s0BCM_.js","assets/useMobileNavigationStore-CeMnArss.js","assets/vendor-sonner-ZS8XIOVl.js","assets/useAssistantUIStore-OyPm_4M_.js","assets/vendor-zod-Dzk5kdUU.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/agentColors-DWSbQXy2.js","assets/rasterizePng-056Poix7.js","assets/MarkdownRenderer-CVFTXv6T.js","assets/useEffectiveDirectory-CzkOEaY-.js","assets/markdownHeightCache-_0n435fL.js","assets/dualLimitLru-D8Sphgua.js","assets/markdown-worker-DFNZ3KJ_.js","assets/ImageLoadingPlaceholder-BfOy_RFL.js","assets/useWorkerHighlightedLines-DxLthSDl.js","assets/tooltip-CRvh1CJe.js","assets/vendor-tanstack-react-virtual-B_EO--9t.js","assets/markdownTheme-BUfvCGAn.js","assets/mobileBackNavigation-DUcdCT-q.js","assets/ToolOutputDialog-C1c4G7q4.css","assets/vendor-capacitor-app-B5H_XtmE.js","assets/vendor-capacitor-push-notifications-D5cqJIPw.js","assets/vendor-capacitor-status-bar-D9bcMr9Q.js","assets/vendor-capacitor-keyboard-BRVcFyc9.js","assets/gitApi-BVwik90d.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{S as t,_ as n,p as r,r as i,t as a,v as o,w as s}from"./runtime-auth-BpCQ-dPr.js";import{c,i as l,l as u,r as d,s as f,t as p}from"./runtime-switch-CMiMO5Yj.js";import{c as m,s as h}from"./queryRuntime-DRiRiAgZ.js";import{Mt as g,et as _,r as v,t as y}from"./persistence-CAKBi4bp.js";import{a as b,i as x}from"./vendor-zustand-o69pgTEK.js";import{it as S,nt as C,rt as w}from"./vendor-base-ui-CdzJ6My_.js";import{Ct as T,Ir as E,Lr as D,Nt as O,n as k,r as A,t as j}from"./platform-jaHE0AyQ.js";import{n as M,x as N}from"./useUIStore-CEqU9Ujv.js";import{n as P,t as F}from"./vendor-react-BP2cRVqX.js";import{A as ee,D as I,E as L,O as R,T as z,r as te,s as ne}from"./runtime-file-resource-WtDqIbiH.js";import{a as B,n as V,o as H}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{t as U}from"./capgoAdapter-KNLHDj7G.js";/* empty css */import{a as re}from"./vendor-pierre-diffs-DPBtNDJ5.js";import{r as ie}from"./vendor-sonner-ZS8XIOVl.js";import{c as ae,n as W,r as oe}from"./vendor-reactuses-core-BpfIZ1tg.js";import{d as se,f as ce,m as G,r as K,t as q}from"./button--NSU9MZj.js";import{i as J,n as le}from"./store-D79UkOhB.js";import{a as ue,c as de,d as Y,f as fe,l as pe,m as me,o as he,p as ge,s as _e,t as ve,u as ye}from"./MobileShareBridge-0q0bC1g-.js";import{S as be,_ as xe,b as Se,t as Ce,w as we,x as Te}from"./MobileDetailNavigation-C7XoCy6_.js";import{$n as Ee,Aa as De,Bi as Oe,Br as ke,Bt as Ae,Er as je,F as Me,Hi as Ne,Hr as Pe,Ir as Fe,Jt as Ie,Kn as Le,Lr as Re,Mt as ze,Nr as Be,Or as Ve,Pr as He,Ri as Ue,Rr as We,Sa as Ge,Ui as Ke,Ur as qe,Ut as Je,Vi as Ye,Vr as Xe,Vt as Ze,Yn as Qe,Yt as $e,Zn as et,a as tt,bi as nt,cn as rt,d as it,dn as at,ei as ot,en as st,fn as ct,fo as lt,in as ut,jn as dt,jr as ft,ln as pt,o as mt,on as ht,t as gt,tn as _t,wa as vt,xi as yt,xr as bt,zr as xt}from"./useMobileNavigationStore-CeMnArss.js";import{i as St,n as Ct,r as wt}from"./useAssistantUIStore-OyPm_4M_.js";import{n as Tt}from"./useThemeSystem-8jhE4Zyk.js";import{n as X}from"./Icon-DJOJhmkK.js";import{F as Et,I as Dt,M as Ot,N as kt,p as At}from"./gitApi-BVwik90d.js";import{$ as jt,At as Mt,B as Nt,C as Pt,Ct as Ft,Dt as It,Et as Lt,J as Rt,K as zt,L as Bt,Mt as Vt,Nt as Ht,Ot as Ut,Q as Wt,R as Gt,Rt as Kt,S as qt,St as Jt,Tt as Yt,X as Xt,Y as Zt,ct as Qt,i as $t,jt as en,kt as tn,lt as nn,q as rn,r as an,t as on,vt as sn,wt as cn,yt as ln,z as un}from"./useAppFontEffects-CICX6ccA.js";import{E as dn,T as fn,a as pn,f as mn,i as hn,n as gn,s as _n}from"./projectMeta-B7-8QrCr.js";import{t as vn}from"./input-C0EI9bKy.js";import{r as yn}from"./tooltip-CRvh1CJe.js";import{A as bn,Ct as xn,F as Sn,N as Cn,Rt as wn,T as Tn,at as En,it as Dn,j as On,k as kn,q as An,rt as jn,ut as Mn}from"./speechSettingsQueries-B5rRSSZa.js";import{a as Nn,n as Pn,s as Fn}from"./OverlayScrollbar-Dr5XwsW5.js";import{d as In,o as Ln}from"./image-loading-BbXaWHv9.js";import{T as Rn,a as zn,c as Bn,d as Vn,f as Hn,i as Un,l as Wn,m as Gn,p as Kn,r as qn,s as Jn,u as Yn}from"./textarea-D2NwOmCU.js";import{C as Xn,r as Zn,t as Qn,w as $n}from"./sessionChangeSummary-FnRoTUCa.js";import{b as er,h as tr,k as nr,v as rr,y as ir}from"./insertionBoundaries-B1UojqLv.js";import{A as ar,T as or,a as sr,f as cr,j as lr,m as ur,t as dr}from"./appThemeRegistry-D7s0BCM_.js";import{i as fr,n as pr,o as mr}from"./MarkdownRenderer-CVFTXv6T.js";import{a as hr,o as gr}from"./url-BD7mCWgV.js";import{c as _r,d as vr,f as yr,l as br}from"./markdown-worker-DFNZ3KJ_.js";import{n as xr}from"./useEffectiveDirectory-CzkOEaY-.js";import{t as Sr}from"./ImageLoadingPlaceholder-BfOy_RFL.js";import{t as Cr}from"./LoadingImage-DAp7ygoZ.js";import{F as wr,I as Tr,M as Er,U as Dr,V as Or,d as kr,f as Ar,i as jr,m as Mr,s as Nr,t as Pr}from"./MobileTabPageHeader-BfA3Blg2.js";import{t as Fr}from"./useFontPreferences-BLwhdOar.js";import{$ as Ir,A as Lr,D as Rr,E as zr,F as Br,G as Vr,I as Hr,J as Ur,K as Wr,L as Gr,M as Kr,N as qr,O as Jr,P as Yr,Q as Xr,R as Zr,S as Qr,T as $r,X as ei,Y as ti,Z as ni,_ as ri,a as ii,at as ai,b as oi,et as si,f as ci,ft as li,g as ui,h as di,i as fi,j as pi,k as mi,l as hi,lt as gi,m as _i,mt as vi,n as yi,o as bi,ot as xi,p as Si,pt as Ci,r as wi,s as Ti,t as Ei,u as Di,ut as Oi,v as ki,w as Ai,x as ji,y as Mi,z as Ni}from"./runtimeEndpointReset-BdC1LMDQ.js";import{c as Pi,l as Fi}from"./mcpQueries-CBvyBo4z.js";import{a as Ii,c as Li,d as Ri,f as zi,i as Bi,l as Vi,m as Hi,o as Ui,p as Wi,r as Gi,s as Ki,t as qi,u as Ji}from"./SettingsView-D75F19Z9.js";import{u as Yi}from"./scheduledTaskNavigation-CUbKrS_Q.js";import{n as Xi,r as Zi,t as Qi}from"./mobileBackNavigation-DUcdCT-q.js";import{a as $i,c as ea,i as ta,l as na,o as ra,r as ia,s as aa,t as oa}from"./AssistantView-o_2FGmWi.js";import{a as sa,i as ca}from"./sessionLookup-Dyf9EV-B.js";var Z=e(S(),1),la=F(),ua=null,da=!1,fa=new Promise(e=>{ua=e});function pa(){da||(da=!0,ua?.())}var ma=6,ha=e=>e.parentID??null,ga=e=>{let t=e.replace(/\/+$/,``);return t.slice(t.lastIndexOf(`/`)+1)||t},_a=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),va=(e,t)=>{if(!e)return``;let n=null,r=-1;for(let i of t){let t=_a(i.path);(e===t||e.startsWith(`${t}/`))&&t.length>r&&(n=i,r=t.length)}return ga(n?n.path:e)},ya=()=>{let e=He.getState().activeSessions,t=Qe.getState().index.session.unseenCount,n=lt.getState().projects,r=0,i=[];for(let a of e){let e=ha(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:va(ft(a),n)})}i.sort((e,t)=>t.updated-e.updated);let a=i.slice(0,ma).map(({id:e,title:t,unread:n,project:r})=>({id:e,title:t,unread:n,project:r}));return{attentionCount:r,recentSessions:a}},ba=`__OPENCHAMBER_WIDGET_SNAPSHOT__`,xa=()=>{typeof window>`u`||(window[ba]=()=>{try{return JSON.stringify(ya())}catch{return null}})},Q=P(),Sa=B(`OpenChamberScreenAwake`),Ca=Promise.resolve(),wa=0;function Ta(e){let t=Ca.then(()=>Sa.setEnabled({enabled:e}));return Ca=t.catch(()=>void 0),t}async function Ea(){if(V.isNativePlatform()&&V.isPluginAvailable(`OpenChamberScreenAwake`)){wa+=1;try{await Ta(!0)}catch(e){throw--wa,e}let e=!1;return async()=>{e||(e=!0,--wa,wa===0&&await Ta(!1))}}if(!navigator.wakeLock)throw Error(`Screen wake lock unavailable`);let e=await navigator.wakeLock.request(`screen`);return async()=>{e.released||await e.release()}}var $=w();function Da({sessionId:e,directory:t,active:n,children:r}){let{t:i}=ce(),a=rt(e,t),o=pt(e,t),[s,l]=ae(`openchamber.auto-read`,!1),u=s===!0,[d,f]=(0,Z.useState)(0),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(document.visibilityState===`visible`),y=Nt({enabled:p}),b=(0,Z.useRef)({enabled:!1,generation:0,floor:0,seen:new Set,observed:new Set,pending:[],playing:!1}),x=(0,Z.useRef)(!1),S=n&&!!e&&o,C=W(()=>{let e=b.current;e.enabled=!1,e.generation+=1,e.pending=[],e.playing=!1,e.seen.clear(),e.observed.clear(),x.current=!1,y.stop(),g(null),m(!1)}),w=W(()=>{let e=b.current;if(!e.enabled||e.playing||!n||document.visibilityState!==`visible`)return;let t=e.pending.shift();if(!t)return;e.playing=!0,g(t);let r=e.generation;y.play(t.text,t=>{if(r===e.generation){if(e.playing=!1,g(null),t){C(),ie.error(i(`mobile.menu.autoReadFailed`));return}w()}})}),T=W(t=>{let n=b.current;!n.enabled||!S||t.sessionId!==e||!t.text.trim()||t.created<n.floor&&!n.observed.has(t.messageId)||n.seen.has(t.messageId)||(n.seen.add(t.messageId),n.pending.push(t),w())}),E=W((t,n)=>{b.current.enabled&&S&&t===e&&b.current.observed.add(n)}),D=W(()=>{if(u){l(!1),C();return}S&&(l(!0),y.unlock().catch(()=>{ie.error(i(`mobile.menu.autoReadFailed`))}))}),O=W(()=>{let e=b.current;e.floor=Math.max(0,...a.map(e=>e.time.created)),e.seen=new Set(a.filter(e=>e.time.completed!=null||e.role!==`assistant`).map(e=>e.id)),e.enabled=!0,m(!0)});(0,Z.useEffect)(()=>(C(),u&&S&&O(),C),[e,t,u,S,d,O,C]),(0,Z.useEffect)(()=>c(()=>{C(),f(e=>e+1)}),[C]);let k=W(()=>{l(!1),C()});oe(`pointerdown`,()=>{if(!b.current.enabled||x.current)return;x.current=!0;let e=b.current.generation;y.unlock().catch(()=>{e===b.current.generation&&(x.current=!1)})},document),oe(`visibilitychange`,()=>{v(document.visibilityState===`visible`),document.visibilityState===`visible`?w():(b.current.generation+=1,b.current.playing=!1,b.current.pending=[],y.stop(),g(null))},document),(0,Z.useEffect)(()=>{if(!p||!n||!_)return;let e=!1,t;return Ea().then(n=>{e?n().catch(()=>void 0):t=n}).catch(()=>{e||ie.warning(i(`mobile.menu.autoReadAwakeFailed`))}),()=>{e=!0,t?.().catch(()=>void 0)}},[p,n,_,e,t,d,i]);let A=(0,Z.useMemo)(()=>({enabled:u,available:S,toggle:D,rendered:T,streaming:E}),[u,S,D,T,E]),j=(0,Z.useMemo)(()=>p&&n&&_&&y.isPlaying&&h?.sessionId===e?{sessionId:e,messageId:h.messageId,stop:k}:null,[p,n,_,y.isPlaying,h,e,k]);return(0,$.jsx)(Gt.Provider,{value:A,children:(0,$.jsx)(un.Provider,{value:j,children:r})})}function Oa(e){let t=(0,Q.c)(3),{children:n}=e,r=(0,Z.useContext)(Gt);if(!r)return null;let i;return t[0]!==n||t[1]!==r?(i=n(r),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}var ka={getPlatform:()=>V.getPlatform(),isPluginAvailable:e=>V.isPluginAvailable(e),openInSystemBrowser:e=>gr.open(e),openExternal:hr},Aa=async(e,t=ka)=>{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)},ja=`mobile-app-update-available`,Ma=`mobile-app-update-toast-dismissed-version`,Na=()=>{let e=(0,Q.c)(9),{t}=ce(),n=Tr(Pa),r=Tr(Fa),i=Tr(Ia),a=Tr(La),o=Tr(Ra),s;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=new Set,e[0]=s):s=e[0];let c=Z.useRef(s),l,u;return e[1]!==n||e[2]!==a||e[3]!==o||e[4]!==r||e[5]!==t||e[6]!==i?(l=()=>{if(j()!==`android`||r!==`mobile`||!n||!i||!a||o){We.dismiss(ja);return}N().getItem(Ma)!==i&&(c.current.has(i)||(c.current.add(i),We.info(t(`mobileUpdate.toast.available.title`),{id:ja,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:()=>{Aa(a)}},cancel:{label:t(`mobileUpdate.toast.actions.dismiss`),onClick:()=>{N().setItem(Ma,i),We.dismiss(ja)}}})))},u=[n,a,o,r,t,i],e[1]=n,e[2]=a,e[3]=o,e[4]=r,e[5]=t,e[6]=i,e[7]=l,e[8]=u):(l=e[7],u=e[8]),Z.useEffect(l,u),null};function Pa(e){return e.available}function Fa(e){return e.runtimeType}function Ia(e){return e.info?.version}function La(e){return e.info?.downloadUrl}function Ra(e){return e.info?.inAppApply===!0}var za=e=>!(!e.enabled||e.runtimeType!==`mobile`||!e.available||!e.inAppApply||!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),Ba=e=>e.enabled&&!e.alreadyChecked,Va=`mobile-ota-update-available`,Ha=`mobile-ota-update-toast-dismissed-version`,Ua=()=>{let e=(0,Q.c)(24),{t}=ce(),[n,r]=Z.useState(!1),i=Z.useRef(!1),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,e[0]=a):a=e[0];let o=Z.useRef(a),s;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=k(),e[1]=s):s=e[1];let c=s,l=Tr(Wa),u=Tr(Ga),d=Tr(Ka),f=Tr(qa),p=Tr(Ja),m=Tr(Ya),h=Tr(Xa),g=Tr(Za),_=Tr(Qa),v=d?.version,y=d?.inAppApply===!0,b,x;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{Ba({enabled:c,alreadyChecked:i.current})&&(i.current=!0,Tr.getState().checkForUpdates().catch($a))},x=[c],e[2]=b,e[3]=x):(b=e[2],x=e[3]),Z.useEffect(b,x);let S;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>{r(!0)},e[4]=S):S=e[4];let C=W(S),w=W(eo),T,E;if(e[5]!==l||e[6]!==w||e[7]!==y||e[8]!==C||e[9]!==u||e[10]!==t||e[11]!==v?(T=()=>{if(!za({enabled:c,runtimeType:u,available:l,inAppApply:y,version:v??``,dismissedVersion:N().getItem(Ha),seenVersions:o.current})||!v){(!l||!y||u!==`mobile`)&&We.dismiss(Va);return}o.current.add(v),We.info(t(`mobileUpdate.ota.toast.available.title`),{id:Va,description:t(`mobileUpdate.ota.toast.available.description`,{version:v}),duration:1/0,icon:(0,$.jsx)(X,{name:`refresh`,className:`h-4 w-4 text-muted-foreground`}),action:{label:t(`mobileUpdate.ota.toast.actions.update`),onClick:C},cancel:{label:t(`mobileUpdate.ota.toast.actions.dismiss`),onClick:()=>{w(v)}}})},E=[l,y,c,C,w,u,t,v],e[5]=l,e[6]=w,e[7]=y,e[8]=C,e[9]=u,e[10]=t,e[11]=v,e[12]=T,e[13]=E):(T=e[12],E=e[13]),Z.useEffect(T,E),!c)return null;let D;return e[14]!==n||e[15]!==g||e[16]!==p||e[17]!==f||e[18]!==h||e[19]!==d||e[20]!==m||e[21]!==_||e[22]!==u?(D=(0,$.jsx)(wr,{open:n,onOpenChange:r,info:d,downloading:f,downloaded:p,progress:m,error:h,onDownload:g,onRestart:_,runtimeType:u}),e[14]=n,e[15]=g,e[16]=p,e[17]=f,e[18]=h,e[19]=d,e[20]=m,e[21]=_,e[22]=u,e[23]=D):D=e[23],D};function Wa(e){return e.available}function Ga(e){return e.runtimeType}function Ka(e){return e.info}function qa(e){return e.downloading}function Ja(e){return e.downloaded}function Ya(e){return e.progress}function Xa(e){return e.error}function Za(e){return e.downloadUpdate}function Qa(e){return e.restartToUpdate}function $a(){}function eo(e){N().setItem(Ha,e),We.dismiss(Va)}function to(e){let t=(0,Q.c)(17),{children:n}=e,r=M(io),i=M(ro),a=Z.useRef(null),o=Z.useRef(null),s;t[0]===i?s=t[1]:(s=()=>i(!1),t[0]=i,t[1]=s);let c;t[2]!==r||t[3]!==s?(c={id:`mobile-global-search`,active:r,onBack:s,surfaceRef:a,underlayRef:o},t[2]=r,t[3]=s,t[4]=c):c=t[4],Xi(c);let l,u;t[5]===r?(l=t[6],u=t[7]):(l=()=>{if(!r)return;let e=document.activeElement,t=Zt(`global-search-page`);return()=>{t(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},u=[r],t[5]=r,t[6]=l,t[7]=u),Z.useLayoutEffect(l,u);let d=r||void 0,f=r||void 0,p;t[8]!==n||t[9]!==d||t[10]!==f?(p=(0,$.jsx)(`div`,{ref:o,inert:d,"aria-hidden":f,className:`h-full min-h-0 w-full`,children:n}),t[8]=n,t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===r?m=t[13]:(m=r?(0,$.jsx)(`div`,{ref:a,"data-mobile-search-page":`true`,className:`absolute inset-0 z-50 flex min-h-0 flex-col overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(xi,{presentation:`page`,onBack:no})}):null,t[12]=r,t[13]=m);let h;return t[14]!==p||t[15]!==m?(h=(0,$.jsxs)(`div`,{className:`relative isolate flex h-[100dvh] min-h-0 w-full flex-col overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:[p,m]}),t[14]=p,t[15]=m,t[16]=h):h=t[16],h}function no(){Qi.requestAnimatedBack(`root`)}function ro(e){return e.setCommandPaletteOpen}function io(e){return e.isCommandPaletteOpen}var ao=e=>{let t=(0,Q.c)(20),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({children:n,className:r,contentClassName:i,style:o,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===r?s=t[7]:(s=K(`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=K(`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},oo=`.oc-mobile-composer`,so=`[data-btw-composer]`;function co(e,t){if(!e)return!1;let n=t;return!n||typeof n.closest!=`function`||!n.closest(so)}function lo(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.closest==`function`&&!!t.closest(oo)}function uo(e){if(!e||typeof e!=`object`||lo(e))return!1;let t=e,n=typeof t.tagName==`string`?t.tagName.toUpperCase():``;return n===`TEXTAREA`||n===`INPUT`||t.isContentEditable===!0}function fo(e){return lo(e??null)}function po(e,t){return e?`cache`:lo(t??null)?`open`:uo(t??null)?`field`:`ignore`}function mo(e,t){return!(t>0)||!(e>=0)?!1:t>e+24}function ho(e,t){return e>0?Math.max(0,Math.round(e/(Number.isFinite(t)&&t>0?t:1))):0}var go=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),_o=e=>{let t=e.index?.trim();return!!(t&&t!==`?`)},vo=e=>{let t=e.working_dir?.trim(),n=e.index?.trim();return!!(t||n===`?`)},yo=(e,t)=>t?`${e}\u0000staged`:e,bo=({onClose:e,initialDiffPath:t,initialDiffStaged:n=!1,initialDiffTargetLine:r=null,hideDiffHeader:i=!1})=>{let{t:a}=ce(),{git:o}=ee(),s=go(xr()??null),c=rr(s||null),l=er(s||null),u=tr(s||null),d=ir(e=>e.setActiveDirectory),f=ir(e=>e.ensureAll),p=ir(e=>e.fetchStatus),m=ir(e=>e.fetchBranches),h=ir(e=>e.prefetchDiffs),g=ir(e=>e.getDiff),_=ir(e=>e.setDiff),[v,y]=Z.useState(()=>t?{type:`diff`,path:t,staged:n,targetLine:r}:{type:`list`}),b=Z.useRef(null);Z.useEffect(()=>{t&&y(e=>e.type===`diff`&&e.path===t&&e.staged===n&&e.targetLine===r?e:{type:`diff`,path:t,staged:n,targetLine:r})},[t,n,r]);let[x,S]=Z.useState(null),[C,w]=Z.useState(null),[T,E]=Z.useState(``),[D,O]=Z.useState(new Set),[k,A]=Z.useState(!1),[j,M]=Z.useState(!1),[N,P]=Z.useState([]),[F,I]=Z.useState([]),[L,R]=Z.useState([]),[z,te]=Z.useState(null),[ne,B]=Z.useState({key:null,loading:!1,error:null,resolved:!1}),[V,H]=Z.useState(0),U=Z.useRef({key:null,generation:0}),[re,ie]=Z.useState(!1),ae=ui(c)&&!re,oe=Z.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]),se=Z.useMemo(()=>oe.filter(_o),[oe]),G=Z.useMemo(()=>oe.filter(vo),[oe]),{deferredStagedCount:K,deferredUnstagedCount:q}=Z.useMemo(()=>{if(!ae||!c)return{deferredStagedCount:0,deferredUnstagedCount:0};let e=0,t=0;for(let n of c.files??[])_o(n)&&(e+=1),vo(n)&&(t+=1);return{deferredStagedCount:e,deferredUnstagedCount:t}},[ae,c]),J=Z.useMemo(()=>{if(L.length>0)return L;let e=c?.tracking?.includes(`/`)?c.tracking.split(`/`)[0]:null;return e||z?[{name:e||`origin`,fetchUrl:z??``,pushUrl:z??``}]:[]},[z,L,c?.tracking]),le=Z.useMemo(()=>e=>!s||v.type!==`diff`?null:e.directories.get(s)?.diffCache.get(yo(v.path,v.staged))??null,[s,v]),ue=ir(le),de=Z.useMemo(()=>v.type===`diff`?oe.find(e=>e.path===v.path)??null:null,[oe,v]),Y=v.type===`diff`&&s?`${s}\u0000${yo(v.path,v.staged)}`:null,fe=ne.key===Y,pe=!!(Y&&!ue&&(!fe||ne.loading)),me=fe?ne.error:null,he=!!(de||fe&&ne.resolved),ge=W(async(e,t=!0)=>{try{await Promise.all([p(e,o),m(e,o)])}catch(e){t&&We.error(e instanceof Error?e.message:a(`gitView.toast.refreshRepositoryFailed`))}}),_e=W(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;R(t),te(n)}catch{if(!r())return;R([]),te(null)}}),ve=W(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:_e(e,e,t)}});Z.useEffect(()=>{s&&(d(s),f(s,o))},[s,f,o,d]),Z.useEffect(()=>{if(!s){U.current={key:null,generation:U.current.generation+1},R([]),te(null);return}let{requestGeneration:e,promise:t}=ve(s);return()=>{e!==null&&U.current.key===s&&U.current.generation===e&&(U.current={key:s,generation:e+1})}},[s,o,ve]),Z.useEffect(()=>{if(!s||oe.length===0)return;let e=Array.from(new Set([...se.map(e=>e.path),...F,...oe.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)},[oe,s,o,h,se,F]),Z.useEffect(()=>{if(v.type!==`diff`){B({key:null,loading:!1,error:null,resolved:!1});return}let e=yo(v.path,v.staged);if(!s||!Y){B({key:null,loading:!1,error:null,resolved:!1});return}if(g(s,e)){B(e=>({key:Y,loading:!1,error:null,resolved:e.key===Y&&e.resolved||!!de}));return}let t=!1;return B({key:Y,loading:!0,error:null,resolved:!1}),o.getGitFileDiff(s,{path:v.path,staged:v.staged||void 0}).then(n=>{t||(_(s,e,{original:n.original??``,modified:n.modified??``,isBinary:n.isBinary}),B(e=>e.key===Y?{...e,loading:!1,error:null,resolved:!0}:e))}).catch(e=>{t||B(t=>t.key===Y?{...t,loading:!1,error:e instanceof Error?e.message:String(e),resolved:!1}:t)}),()=>{t=!0}},[Y,s,V,g,o,v,de,_]);let ye=async(e,t)=>{if(!s)return;let n=s;S(e);try{let r=e=>{let t=`${e.name}/`,n=c?.tracking?.startsWith(t)?c.tracking.slice(t.length):void 0;return{remote:e.name,branch:n,rebase:!0}};if(e===`fetch`){if(!t)throw Error(a(`mobile.changes.noRemote`));await o.gitFetch(n,{remote:t.name}),We.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){We.error(a(`gitView.toast.commitOrStashBeforeSync`));return}await o.gitPull(n,r(t))}((await o.getGitStatus(n)).ahead??0)>0&&await o.gitPush(n),We.success(a(`gitView.toast.alreadyUpToDate`))}await ge(n,!1),await ve(n).promise}catch(e){We.error(e instanceof Error?e.message:a(`gitView.toast.syncActionFailed`,{action:a(`gitView.sync.syncChanges`)}))}finally{S(null)}},be=W(async(e,t)=>{if(!s||e.length===0)return;let n=s;try{t===`stage`?e.length>1?await kt(n,e):await Ot(n,e[0]):e.length>1?await Dt(n,e):await Et(n,e[0]),await ge(n,!1)}catch(e){We.error(e instanceof Error?e.message:a(t===`stage`?`gitView.toast.stageFileFailed`:`gitView.toast.unstageFileFailed`))}}),xe=W((e,t=!1)=>{y({type:`diff`,path:e,staged:t,targetLine:null})}),Se=W(()=>v.type===`diff`&&(y({type:`list`}),!0));Xi({id:`mobile-changes-diff`,active:v.type===`diff`&&!i,layer:`overlay`,onBack:Se,surfaceRef:b});let Ce=W(async e=>{if(!s)return;let t=s;O(t=>new Set(t).add(e));try{await o.revertGitFile(t,e),We.success(a(`gitView.toast.revertedFile`,{path:e})),await ge(t,!1)}catch(e){We.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{O(t=>{let n=new Set(t);return n.delete(e),n})}}),we=W(async e=>{if(!s||e.length===0||k)return;let t=s,n=Array.from(new Set(e));A(!0),O(new Set(n));try{await Promise.all(n.map(e=>o.revertGitFile(t,e))),await ge(t,!1),We.success(n.length===1?a(`gitView.toast.revertedFilesSingle`,{count:n.length}):a(`gitView.toast.revertedFilesPlural`,{count:n.length}))}catch(e){We.error(e instanceof Error?e.message:a(`gitView.toast.revertFailed`))}finally{O(new Set),A(!1)}}),Te=W(e=>{let t=e.map(e=>e.trim()).filter(Boolean);if(t.length===0){P([]);return}E(e=>`${e.trim()}${e.trim()?`
3
-
4
- `:``}${t.join(`
5
- `)}`.trim()),P([])}),Ee=W(async()=>{if(!s)return;let e=s,t=se.map(e=>e.path).sort();if(t.length===0){We.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){We.error(e instanceof Error?e.message:a(`gitView.toast.generateCommitMessageFailed`))}finally{M(!1)}}),De=async(e={})=>{if(!s)return;let t=s;if(!T.trim()){We.error(a(`gitView.toast.enterCommitMessage`));return}let n=se.map(e=>e.path).sort();if(n.length===0){We.error(a(`gitView.toast.selectFileToCommit`));return}w(e.pushAfter?`commitAndPush`:`commit`);try{if(await o.createGitCommit(t,T.trim(),{files:n}),We.success(a(`gitView.toast.commitCreated`)),E(``),P([]),e.pushAfter){let e=c?.tracking?.split(`/`)[0],n=J.find(t=>t.name===e)??J[0];if(!n)throw Error(a(`mobile.changes.noRemote`));S(`sync`);let r=`${n.name}/`,i=c?.tracking?.startsWith(r)?c.tracking.slice(r.length):void 0;await o.gitFetch(t,{remote:n.name}),((await o.getGitStatus(t)).behind??0)>0&&await o.gitPull(t,{remote:n.name,branch:i,rebase:!0}),((await o.getGitStatus(t)).ahead??0)>0&&await o.gitPush(t),await ge(t,!1),await ve(t).promise}else await ge(t,!1)}catch(e){We.error(e instanceof Error?e.message:a(`gitView.toast.createCommitFailed`))}finally{w(null),e.pushAfter&&S(null)}},Oe=Z.useMemo(()=>{let e=[];return se.length>0&&e.push({id:`staged`,title:a(`gitView.changes.stagedTitle`),entries:se,actionSymbol:`-`,actionAllLabel:a(`gitView.changes.unstageAllAria`),getActionLabel:e=>a(`gitView.changes.unstageFileAria`,{path:e}),onActionFile:e=>void be([e],`unstage`),onActionAll:e=>void be(e,`unstage`),onViewDiff:e=>xe(e,!0),onRevertFile:Ce,showRevertActions:!1,accent:!0}),G.length>0&&e.push({id:`unstaged`,title:a(`gitView.changes.title`),entries:G,actionSymbol:`+`,actionAllLabel:a(`gitView.changes.stageAllAria`),getActionLabel:e=>a(`gitView.changes.stageFileAria`,{path:e}),onActionFile:e=>void be([e],`stage`),onActionAll:e=>void be(e,`stage`),onViewDiff:e=>xe(e,!1),onRevertFile:Ce}),e},[Ce,xe,be,se,a,G]),ke=t=>(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background text-foreground`,children:[i?null:(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,children:[e?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":a(`mobile.surface.closeAria`),onClick:e,style:{touchAction:`manipulation`},children:(0,$.jsx)(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?ke((0,$.jsx)(xo,{loading:!0,message:a(`gitView.loading.checkingRepository`)})):l===!1?ke((0,$.jsx)(xo,{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)(So,{path:v.path,diff:ue,fileExists:he,error:me,loading:pe,targetLine:v.targetLine,onBack:Se,onRetry:()=>H(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)(Qr,{syncAction:x,remotes:J,onSync:e=>void ye(`sync`,e),disabled:C!==null||u,aheadCount:c?.ahead??0,behindCount:c?.behind??0,trackingRemoteName:c?.tracking?.split(`/`)[0],hasUncommittedChanges:(c?.files?.length??0)>0})]}),ae?(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(ri,{stagedCount:K,unstagedCount:q,onLoad:()=>ie(!0)})}):oe.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)(ki,{groups:Oe,diffStats:c?.diffStats,revertingPaths:D,onRevertAll:we,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)(di,{stagedCount:se.length,commitMessage:T,onCommitMessageChange:E,generatedHighlights:N,onInsertHighlights:Te,onGenerateMessage:Ee,isGeneratingMessage:j,onCommit:()=>void De({pushAfter:!1}),onCommitAndPush:()=>void De({pushAfter:!0}),commitAction:C,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(xo,{icon:!0,message:a(`gitView.empty.cleanTitle`),description:a(`mobile.changes.cleanDescription`)})})]}):ke((0,$.jsx)(xo,{message:a(`gitView.empty.selectSessionOrDirectory`)}))},xo=e=>{let t=(0,Q.c)(13),{message:n,description:r,loading:i,icon:a}=e,o=i!==void 0&&i,s=a!==void 0&&a,c;t[0]===o?c=t[1]:(c=o?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):null,t[0]=o,t[1]=c);let l;t[2]===s?l=t[3]:(l=s?(0,$.jsx)(X,{name:`git-branch`,className:`size-6 text-muted-foreground`}):null,t[2]=s,t[3]=l);let u;t[4]===n?u=t[5]:(u=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[4]=n,t[5]=u);let d;t[6]===r?d=t[7]:(d=r?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r}):null,t[6]=r,t[7]=d);let f;return t[8]!==c||t[9]!==l||t[10]!==u||t[11]!==d?(f=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[c,l,u,d]})}),t[8]=c,t[9]=l,t[10]=u,t[11]=d,t[12]=f):f=t[12],f},So=e=>{let t=(0,Q.c)(20),{path:n,diff:r,fileExists:i,error:a,loading:o,targetLine:s,onBack:c,onRetry:l,hideHeader:u}=e,d=u!==void 0&&u,{t:f}=ce(),p;t[0]===n?p=t[1]:(p=br(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)(q,{type:`button`,size:`sm`,variant:`outline`,onClick:l,children:f(`diffView.actions.retry`)})]})}):o?(0,$.jsx)(xo,{loading:!0,message:f(`diffView.state.loadingDiff`)}):i?r?r.isBinary?(0,$.jsx)(xo,{icon:!0,message:f(`diffView.binary.unavailable`)}):yr(n)?(0,$.jsx)(xo,{icon:!0,message:f(`mobile.changes.diffDetail.imageUnavailable`)}):(0,$.jsx)(qn,{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)(si,{original:r.original,modified:r.modified,language:m,fileName:n,renderSideBySide:!1,wrapLines:!0,focusLine:s,layout:`inline`})}):(0,$.jsx)(xo,{loading:!0,message:f(`diffView.state.loadingDiff`)}):(0,$.jsx)(xo,{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],_},Co=e(C(),1),wo=`data-oc-motion-id`,To=`data-oc-sheet-overscroll`,Eo=`html, body { overscroll-behavior-y: none; }`,Do=[`input`,`textarea`,`select`,`[contenteditable]:not([contenteditable="false"])`,`[data-mobile-sheet-no-dismiss]`].join(`, `),Oo=e=>e.closest(`[data-oc-motion-id]`)?.getAttribute(`data-oc-motion-id`)??null,ko=e=>{try{let t=e.contentDocument;return t?t.scrollingElement??t.documentElement:null}catch{return null}},Ao=(e,t)=>Number.isFinite(e)&&Number.isFinite(t)&&e<=1&&t>0,jo=(e,t,n)=>e?!0:Ao(t,n),Mo=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.Element},No=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.HTMLElement},Po=(e,t)=>{let n=e.defaultView;return!n||t==null?!1:t instanceof n.HTMLStyleElement},Fo=(e,t)=>{if(typeof e.item==`function`){let n=e.item(t);if(n)return n}return e[t]??null},Io=(e,t)=>{for(let n=0;n<e.length;n+=1){let r=Fo(e,n);if(r?.identifier===t)return r}return null},Lo=(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}},Ro=(e,t)=>{let n=[],r=new Set,i=t=>{!t||r.has(t)||Lo(e,t)&&(r.add(t),n.push(t))},a=Mo(e,t)?t:null;for(;a&&(No(e,a)&&i(a),a!==e.documentElement&&a!==e.body);)a=a.parentElement;let o=e.scrollingElement??e.documentElement;return No(e,o)&&i(o),n},zo=(e,t)=>{let n=Ro(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)},Bo=e=>{let t=e.closest(`[${wo}]`);if(t instanceof HTMLElement){let e=t.getBoundingClientRect().height;if(Number.isFinite(e)&&e>0)return e}return window.innerHeight||1},Vo=e=>{let t=null,n=()=>{t?.(),t=null;let n=(()=>{try{return e.contentDocument}catch{return null}})();if(!n)return;let r=Oo(e);if(!r)return;let i=null;if(!Po(n,n.querySelector(`style[${To}]`))){let e=n.createElement(`style`);e.setAttribute(To,`true`),e.textContent=Eo,(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||(Mo(n,t.target)?t.target:null)?.closest(Do)||!zo(n,t.target))return;let r=Fo(t.touches,0);if(!r)return;let i=Bo(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:Jn(i,.1,40,64),active:!1,controller:null}},c=t=>{if(!a)return;if(t.touches.length!==1){o();return}let i=Io(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=Yn(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(!zo(n,t.target)){a=null;return}if(!jo(!1,ko(e)?.scrollTop??0,s)){a=null;return}if(!Vn(`bottom`,c,s,8,1))return;let i=Gn(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=Bn(`bottom`,c,s);u.controller.update(Wn(d,u.motionDistance))},l=e=>{if(!a)return;let t=a,n=Io(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=Yn(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=Bn(`bottom`,o,i),c=Hn(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?.()}},Ho=mr(()=>H(()=>import(`./ToolOutputDialog-KoIg0zrK.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,54,55,56,57,58,59,60]))),Uo=25e4,Wo=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Go=e=>{let t=Wo(e);return!t||t===`/`?t||`/`:t.split(`/`).filter(Boolean).at(-1)??t},Ko=e=>{let t=Wo(e);if(!t||t===`/`)return null;let n=t.lastIndexOf(`/`);return n<=0?t.startsWith(`/`)?`/`:null:t.slice(0,n)},qo=(e,t)=>{let n=Wo(e),r=Wo(t);return!r||n===r?Go(n):n.startsWith(`${r}/`)?n.slice(r.length+1):n},Jo=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``},Yo=e=>/\.(md|mdx|markdown)$/i.test(e),Xo=e=>{let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return`/api/fs/serve${t.startsWith(`/`)?t:`/${t}`}`},Zo=e=>te(Xo(e)).url,Qo=e=>{let t=(0,Q.c)(148),{onClose:n,initialFilePath:r,directFilePreview:i,hideFileHeader:a}=e,o=r===void 0?null:r,s=i!==void 0&&i,c=a!==void 0&&a,{t:l}=ce(),{files:u}=ee(),d=xr()??null,f;t[0]===d?f=t[1]:(f=Wo(d),t[0]=d,t[1]=f);let p=f,m;t[2]!==o||t[3]!==p?(m=()=>{let e=Wo(o);return e?{type:`file`,path:e,returnDirectory:Ko(e)??p}:{type:`browser`,directory:p}},t[2]=o,t[3]=p,t[4]=m):m=t[4];let[h,g]=Z.useState(m),_=Z.useRef(null),[v,y]=Z.useState(``),b=M(os),x=M(ss),S,C;t[5]===p?(S=t[6],C=t[7]):(S=()=>{p&&g(e=>e.type===`file`?e.returnDirectory?e:{...e,returnDirectory:Ko(e.path)??p}:e.type===`browser`&&e.directory?e:{type:`browser`,directory:p})},C=[p],t[5]=p,t[6]=S,t[7]=C),Z.useEffect(S,C);let w,T;t[8]!==b||t[9]!==p||t[10]!==x?(T=()=>{if(!b||!p)return;let e=Wo(b);if(!e){x(null);return}y(``),g({type:`file`,path:e,returnDirectory:Ko(e)??p}),x(null)},w=[b,p,x],t[8]=b,t[9]=p,t[10]=x,t[11]=w,t[12]=T):(w=t[11],T=t[12]),Z.useEffect(T,w);let E=h.type===`browser`?h.directory:h.returnDirectory,D=h.type===`browser`?h.directory:``,O=h.type===`file`?h.path:``,[k,A]=Z.useState(`preview`),j;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>{A(`preview`)},t[13]=j):j=t[13];let N;t[14]===O?N=t[15]:(N=[O],t[14]=O,t[15]=N),Z.useEffect(j,N);let P=nr(v,250),F;t[16]===v?F=t[17]:(F=v.trim(),t[16]=v,t[17]=F);let te=F,ne;t[18]===P?ne=t[19]:(ne=P.trim(),t[18]=P,t[19]=ne);let B=ne,V;t[20]!==D||t[21]!==p?(V={scopeDirectory:p,directory:D},t[20]=D,t[21]=p,t[22]=V):V=t[22];let H=!!D,U;t[23]===H?U=t[24]:(U={enabled:H,refetchOnMount:`always`},t[23]=H,t[24]=U);let re=L(V,U),ie;t[25]!==D||t[26]!==B?(ie={directory:D,query:B,maxResults:40},t[25]=D,t[26]=B,t[27]=ie):ie=t[27];let ae=!!(D&&B),oe;t[28]===ae?oe=t[29]:(oe={enabled:ae},t[28]=ae,t[29]=oe);let G=I(ie,oe),q;t[30]!==O||t[31]!==u||t[32]!==k?(q=O&&u.readFile&&(!vr(O)||k===`source`)&&(!yr(O)||O.toLowerCase().endsWith(`.svg`)),t[30]=O,t[31]=u,t[32]=k,t[33]=q):q=t[33];let J=!!q,le;t[34]!==O||t[35]!==p?(le={scopeDirectory:p,path:O},t[34]=O,t[35]=p,t[36]=le):le=t[36];let ue;t[37]===J?ue=t[38]:(ue={enabled:J},t[37]=J,t[38]=ue);let de=z(le,ue),Y;t[39]!==O||t[40]!==p?(Y={scopeDirectory:p,path:O},t[39]=O,t[40]=p,t[41]=Y):Y=t[41];let fe;t[42]===J?fe=t[43]:(fe={enabled:J},t[42]=J,t[43]=fe),R(Y,fe);let pe=re.data?.entries.slice().sort(cs)??[],me;t[44]!==re.error||t[45]!==l?(me=re.error?re.error instanceof Error?re.error.message:l(`mobile.files.error.listFailed`):null,t[44]=re.error,t[45]=l,t[46]=me):me=t[46];let he=me,ge=re.isFetching,_e;t[47]===G.data?_e=t[48]:(_e=G.data??[],t[47]=G.data,t[48]=_e);let ve=_e,ye=!!(te&&B&&v===P&&G.isFetching),be;t[49]!==de.data||t[50]!==l?(be=de.data&&de.data.length>Uo?`${de.data.slice(0,Uo)}\n\n${l(`mobile.files.file.truncated`)}`:de.data??``,t[49]=de.data,t[50]=l,t[51]=be):be=t[51];let xe=be,Se;t[52]!==O||t[53]!==de.error||t[54]!==u||t[55]!==l?(Se=O&&!u.readFile?l(`mobile.files.error.readUnavailable`):de.error?de.error instanceof Error?de.error.message:l(`filesView.error.readFileFailed`):null,t[52]=O,t[53]=de.error,t[54]=u,t[55]=l,t[56]=Se):Se=t[56];let Ce=Se,we=J&&de.isFetching,Te;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(Te=e=>{y(``),g({type:`browser`,directory:e})},t[57]=Te):Te=t[57];let Ee=Te,De;t[58]!==E||t[59]!==p?(De=e=>{g({type:`file`,path:e,returnDirectory:E||p})},t[58]=E,t[59]=p,t[60]=De):De=t[60];let Oe=De,ke;t[61]!==s||t[62]!==n||t[63]!==h.returnDirectory||t[64]!==h.type?(ke=()=>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]=ke):ke=t[65];let Ae=W(ke),je=h.type===`file`,Me;t[66]!==Ae||t[67]!==je?(Me={id:`mobile-files-detail`,active:je,layer:`overlay`,onBack:Ae,surfaceRef:_},t[66]=Ae,t[67]=je,t[68]=Me):Me=t[68],Xi(Me);let Ne;t[69]===l?Ne=t[70]:(Ne=async e=>{(await se(e)).ok||We.error(l(`mobile.files.toast.copyFailed`))},t[69]=l,t[70]=Ne);let Pe=Ne,Fe;t[71]!==xe||t[72]!==l?(Fe=async()=>{(await se(xe)).ok?We.success(l(`mobile.files.toast.contentCopied`)):We.error(l(`mobile.files.toast.copyFailed`))},t[71]=xe,t[72]=l,t[73]=Fe):Fe=t[73];let Ie=Fe;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)(as,{message:e}),t[76]=e,t[77]=n),n}if(h.type===`file`){let e;t[78]!==Pe||t[79]!==h.path?(e=()=>void Pe(h.path),t[78]=Pe,t[79]=h.path,t[80]=e):e=t[80];let n;t[81]===Ie?n=t[82]:(n=()=>void Ie(),t[81]=Ie,t[82]=n);let r;return t[83]!==Ae||t[84]!==xe||t[85]!==Ce||t[86]!==c||t[87]!==k||t[88]!==we||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)(ns,{path:h.path,content:xe,error:Ce,isLoading:we,hideHeader:c,htmlViewMode:k,onHtmlViewModeChange:A,onBack:Ae,onCopyPath:e,onCopyContent:n})}),t[83]=Ae,t[84]=xe,t[85]=Ce,t[86]=c,t[87]=k,t[88]=we,t[89]=h.path,t[90]=e,t[91]=n,t[92]=r):r=t[92],r}let Le;t[93]!==p||t[94]!==h.directory||t[95]!==l?(Le=h.directory===p?l(`mobile.files.rootDirectory`):Go(h.directory),t[93]=p,t[94]=h.directory,t[95]=l,t[96]=Le):Le=t[96];let Re=Le,ze;t[97]!==v||t[98]!==ve?(ze=v.trim()?ve:[],t[97]=v,t[98]=ve,t[99]=ze):ze=t[99];let Be=ze,Ve,He,Ue,Ge;if(t[100]!==n||t[101]!==v||t[102]!==p||t[103]!==h.directory||t[104]!==l){let e=Ko(h.directory),r=h.directory!==p&&e!==null&&(e===p||e.startsWith(`${p}/`)),i=r&&!v.trim(),a=r?e:null;Ge=`flex h-full flex-col overflow-hidden bg-background text-foreground`,Ve=`flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground`,t[109]!==n||t[110]!==l?(He=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]=He):He=t[111],Ue=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:Go(a)}),onClick:()=>Ee(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]=Ve,t[106]=He,t[107]=Ue,t[108]=Ge}else Ve=t[105],He=t[106],Ue=t[107],Ge=t[108];let Ke;t[112]===Re?Ke=t[113]:(Ke=(0,$.jsx)(`div`,{className:`min-w-0 flex-1 px-1`,children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label text-foreground`,children:Re})}),t[112]=Re,t[113]=Ke);let qe;t[114]===l?qe=t[115]:(qe=l(`mobile.files.refreshAria`),t[114]=l,t[115]=qe);let Je;t[116]===re?Je=t[117]:(Je=()=>void re.refetch(),t[116]=re,t[117]=Je);let Ye;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(Ye={touchAction:`manipulation`},t[118]=Ye):Ye=t[118];let Xe=ge&&`animate-spin`,Ze;t[119]===Xe?Ze=t[120]:(Ze=K(`size-5`,Xe),t[119]=Xe,t[120]=Ze);let Qe;t[121]===Ze?Qe=t[122]:(Qe=(0,$.jsx)(X,{name:`refresh`,className:Ze}),t[121]=Ze,t[122]=Qe);let $e;t[123]!==qe||t[124]!==Je||t[125]!==Qe?($e=(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":qe,onClick:Je,style:Ye,children:Qe}),t[123]=qe,t[124]=Je,t[125]=Qe,t[126]=$e):$e=t[126];let et;t[127]!==Ve||t[128]!==He||t[129]!==Ue||t[130]!==Ke||t[131]!==$e?(et=(0,$.jsxs)(`header`,{className:Ve,children:[He,Ue,Ke,$e]}),t[127]=Ve,t[128]=He,t[129]=Ue,t[130]=Ke,t[131]=$e,t[132]=et):et=t[132];let tt;t[133]===Symbol.for(`react.memo_cache_sentinel`)?(tt=(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]=tt):tt=t[133];let nt;t[134]===Symbol.for(`react.memo_cache_sentinel`)?(nt=e=>y(e.target.value),t[134]=nt):nt=t[134];let rt;t[135]===l?rt=t[136]:(rt=l(`mobile.files.search.placeholder`),t[135]=l,t[136]=rt);let it;t[137]!==v||t[138]!==rt?(it=(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2 pt-1`,"data-mobile-sheet-no-dismiss":``,children:(0,$.jsxs)(`div`,{className:`relative`,children:[tt,(0,$.jsx)(vn,{type:`text`,inputMode:`search`,value:v,onChange:nt,placeholder:rt,className:`h-11 pl-9`})]})}),t[137]=v,t[138]=rt,t[139]=it):it=t[139];let at=qn,ot=he?(0,$.jsx)(as,{message:he}):v.trim()?(0,$.jsx)(es,{results:Be,isSearching:ye,onOpenFile:Oe}):(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:[pe.length===0&&!ge?(0,$.jsx)(`div`,{className:`px-4 py-8 text-center typography-body text-muted-foreground`,children:l(`mobile.files.empty.directory`)}):null,pe.map(e=>(0,$.jsx)($o,{name:e.name,path:e.path,directory:e.isDirectory,meta:e.isDirectory?void 0:Jo(e.size),onClick:()=>e.isDirectory?Ee(e.path):Oe(e.path)},e.path))]}),st;t[140]!==at||t[141]!==ot?(st=(0,$.jsx)(at,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto px-4 pb-3`,children:ot}),t[140]=at,t[141]=ot,t[142]=st):st=t[142];let ct;return t[143]!==Ge||t[144]!==et||t[145]!==it||t[146]!==st?(ct=(0,$.jsxs)(`div`,{className:Ge,children:[et,it,st]}),t[143]=Ge,t[144]=et,t[145]=it,t[146]=st,t[147]=ct):ct=t[147],ct},$o=e=>{let t=(0,Q.c)(16),{name:n,path:r,directory:i,meta:a,onClick:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]!==i||t[2]!==r?(c=i?(0,$.jsx)(X,{name:`folder-3-fill`,className:`size-5 shrink-0 text-muted-foreground`}):(0,$.jsx)(ln,{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},es=e=>{let t=(0,Q.c)(10),{results:n,isSearching:r,onOpenFile:i}=e,{t:a}=ce(),o=Wo(xr()??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)(as,{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)(as,{message:e}),t[6]=e,t[7]=n),n}let s=n.map(e=>(0,$.jsx)($o,{name:Go(e.path),path:e.path,directory:!1,meta:qo(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},ts=e=>{let t=(0,Q.c)(24),{path:n,htmlViewMode:r,htmlFullscreen:i,onToggleHtmlViewMode:a,onEnterHtmlFullscreen:o,onCopyPath:s,onCopyContent:c}=e,{t:l}=ce(),u;t[0]===n?u=t[1]:(u=vr(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)(q,{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)(q,{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=!yr(n)&&!d?(0,$.jsx)(q,{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)(q,{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],_},ns=e=>{let t=(0,Q.c)(94),{path:n,content:r,error:i,isLoading:a,hideHeader:o,htmlViewMode:s,onHtmlViewModeChange:c,onBack:l,onCopyPath:u,onCopyContent:d}=e,f=o!==void 0&&o,{t:p}=ce(),m=Z.useRef(null),h=yr(n)&&!n.toLowerCase().endsWith(`.svg`)?n:``,g;t[0]===n?g=t[1]:(g=Ko(n)??``,t[0]=n,t[1]=g);let _=Ln(h,g,`preview`),[v,y]=Z.useState(``),b;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(b={open:!1,title:``,content:``},t[2]=b):b=t[2];let[x,S]=Z.useState(b),C=_.source,w;t[3]===n?w=t[4]:(w=Go(n),t[3]=n,t[4]=w);let T=w,E;t[5]!==r||t[6]!==n?(E=yr(n)?`data:${_r(n)};utf8,${encodeURIComponent(r)}`:``,t[5]=r,t[6]=n,t[7]=E):E=t[7];let D=E,O;t[8]!==r||t[9]!==D||t[10]!==C||t[11]!==n?(O=C||(yr(n)&&r?D:``),t[8]=r,t[9]=D,t[10]=C,t[11]=n,t[12]=O):O=t[12];let k=O,A;t[13]!==i||t[14]!==v||t[15]!==_.error||t[16]!==k||t[17]!==p?(A=i??_.error??(k&&v===k?p(`filesView.error.readFileFailed`):null),t[13]=i,t[14]=v,t[15]=_.error,t[16]=k,t[17]=p,t[18]=A):A=t[18];let j=A,M;t[19]===k?M=t[20]:(M=()=>y(k),t[19]=k,t[20]=M);let N=W(M),P;t[21]!==T||t[22]!==h||t[23]!==n||t[24]!==k?(P=e=>{let t=h||k;t&&S({open:!0,title:T,content:``,previewSource:e.currentTarget.querySelector(`img`)??void 0,metadata:{tool:`image-preview`,filename:T,mime:_r(n)},image:{url:t,mimeType:_r(n),filename:T}})},t[21]=T,t[22]=h,t[23]=n,t[24]=k,t[25]=P):P=t[25];let F=W(P),ee;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(ee=e=>{S(t=>t.open===e?t:{...t,open:e})},t[26]=ee):ee=t[26];let I=W(ee),L;t[27]===n?L=t[28]:(L=vr(n),t[27]=n,t[28]=L);let R=L,[z,te]=Z.useState(!1),ne=Z.useRef(null),B;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>{te(!1)},t[29]=B):B=t[29];let V;t[30]===n?V=t[31]:(V=[n],t[30]=n,t[31]=V),Z.useEffect(B,V);let H;t[32]!==s||t[33]!==c?(H=()=>{c(s===`preview`?`source`:`preview`)},t[32]=s,t[33]=c,t[34]=H):H=t[34];let U=W(H),re;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>{te(!0)},t[35]=re):re=t[35];let ie=W(re),ae;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>(te(!1),!0),t[36]=ae):ae=t[36];let oe=W(ae),se=R&&z,G;t[37]!==oe||t[38]!==se?(G={id:`mobile-html-fullscreen`,active:se,layer:`overlay`,onBack:oe,surfaceRef:ne},t[37]=oe,t[38]=se,t[39]=G):G=t[39],Xi(G);let K;t[40]!==ie||t[41]!==z||t[42]!==s||t[43]!==d||t[44]!==u||t[45]!==n||t[46]!==U?(K=(0,$.jsx)(ts,{path:n,htmlViewMode:s,htmlFullscreen:z,onToggleHtmlViewMode:U,onEnterHtmlFullscreen:ie,onCopyPath:u,onCopyContent:d}),t[40]=ie,t[41]=z,t[42]=s,t[43]=d,t[44]=u,t[45]=n,t[46]=U,t[47]=K):K=t[47];let J=K,le;t[48]!==r||t[49]!==i||t[50]!==s||t[51]!==a||t[52]!==n||t[53]!==p?(le=s===`source`?a?(0,$.jsx)(as,{loading:!0,message:p(`filesView.state.loading`)}):i?(0,$.jsx)(as,{message:i}):(0,$.jsx)(is,{path:n,content:r}):(0,$.jsx)(rs,{path:n}),t[48]=r,t[49]=i,t[50]=s,t[51]=a,t[52]=n,t[53]=p,t[54]=le):le=t[54];let ue=le,de;t[55]!==oe||t[56]!==R||t[57]!==ue||t[58]!==z||t[59]!==s||t[60]!==T||t[61]!==p||t[62]!==U?(de=R?(0,$.jsxs)(`div`,{ref:ne,"data-mobile-html-preview":s===`preview`&&!z?`true`:void 0,"data-mobile-html-fullscreen":s===`preview`&&z?`true`:void 0,className:z?`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:[z?(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)(q,{type:`button`,variant:`ghost`,size:`icon`,onClick:oe,"aria-label":p(`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:T}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,onClick:U,"aria-label":p(s===`preview`?`mobile.files.html.viewSourceAria`:`mobile.files.html.viewPreviewAria`),children:(0,$.jsx)(X,{name:s===`preview`?`file-code`:`eye`,className:`size-4`})})]}):null,(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden bg-background`,children:ue})]}):null,t[55]=oe,t[56]=R,t[57]=ue,t[58]=z,t[59]=s,t[60]=T,t[61]=p,t[62]=U,t[63]=de):de=t[63];let Y=de,fe;t[64]!==J||t[65]!==f||t[66]!==T||t[67]!==l||t[68]!==p?(fe=f?(0,$.jsx)(zn,{children:J}):(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":p(`header.actions.backAria`),onClick:l,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:T})}),J]}),t[64]=J,t[65]=f,t[66]=T,t[67]=l,t[68]=p,t[69]=fe):fe=t[69];let pe;t[70]!==r||t[71]!==N||t[72]!==R||t[73]!==z||t[74]!==Y||t[75]!==j||t[76]!==T||t[77]!==_.loading||t[78]!==a||t[79]!==F||t[80]!==n||t[81]!==k||t[82]!==p?(pe=R?z&&typeof document<`u`?(0,Co.createPortal)(Y,document.body):Y:a||_.loading?yr(n)?(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-4`,children:(0,$.jsx)(Sr,{className:`aspect-square w-64 max-w-full rounded-lg`})}):(0,$.jsx)(as,{loading:!0,message:p(`filesView.state.loading`)}):j?(0,$.jsx)(as,{message:j}):yr(n)&&k?(0,$.jsx)(qn,{className:`h-full overflow-auto p-4`,children:(0,$.jsx)(`button`,{type:`button`,className:`mx-auto block 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 [&>.oc-image-frame]:w-full`,onClick:F,"aria-label":T,children:(0,$.jsx)(Cr,{src:k,alt:T,className:`h-auto w-full rounded-lg object-contain`,draggable:!1,onError:N})})}):(0,$.jsx)(is,{path:n,content:r}),t[70]=r,t[71]=N,t[72]=R,t[73]=z,t[74]=Y,t[75]=j,t[76]=T,t[77]=_.loading,t[78]=a,t[79]=F,t[80]=n,t[81]=k,t[82]=p,t[83]=pe):pe=t[83];let me;t[84]===pe?me=t[85]:(me=(0,$.jsx)(`div`,{ref:m,className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:pe}),t[84]=pe,t[85]=me);let he;t[86]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,$.jsx)(Bt,{containerRef:m}),t[86]=he):he=t[86];let ge;t[87]!==I||t[88]!==x?(ge=x.open?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ho,{popup:x,onOpenChange:I,isMobile:!0})}):null,t[87]=I,t[88]=x,t[89]=ge):ge=t[89];let _e;return t[90]!==fe||t[91]!==me||t[92]!==ge?(_e=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground`,children:[fe,me,he,ge]}),t[90]=fe,t[91]=me,t[92]=ge,t[93]=_e):_e=t[93],_e},rs=e=>{let t=(0,Q.c)(29),{path:n}=e,{t:i}=ce(),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=s(),t[0]=c):c=t[0];let l=c,u=Z.useRef(null),[d,f]=Z.useState(``),[m,h]=Z.useState(0),[g,_]=Z.useState(null),[v,y]=Z.useState(``),b,x;t[1]!==n||t[2]!==i?(b=()=>{let e=!1;if(f(``),_(null),y(``),l)return ne({path:n}).then(async e=>{if(!e.ok)throw Error(i(`filesView.error.readFileFailed`));return e.text()}).then(t=>{e||(y(t),f(n))}).catch(t=>{e||(_(t instanceof Error?t.message:i(`filesView.error.readFileFailed`)),f(n))}),()=>{e=!0};let t=p(),s=a(t);r(t).then(t=>{e||!t||(f(n),_(null))}).catch(t=>{e||(_(t instanceof Error?t.message:i(`filesView.error.readFileFailed`)),f(n))});let c=o(()=>{e||(f(n),h(ls),_(null))});return()=>{e=!0,s(),c()}},x=[n,l,i],t[1]=n,t[2]=i,t[3]=b,t[4]=x):(b=t[3],x=t[4]),Z.useEffect(b,x);let S;t[5]!==n||t[6]!==d?(S=()=>{if(d!==n)return;let e=u.current;if(e)return Vo(e)},t[5]=n,t[6]=d,t[7]=S):S=t[7];let C;if(t[8]!==m||t[9]!==n||t[10]!==d||t[11]!==v?(C=[m,n,d,v],t[8]=m,t[9]=n,t[10]=d,t[11]=v,t[12]=C):C=t[12],Z.useEffect(S,C),g){let e;return t[13]===g?e=t[14]:(e=(0,$.jsx)(as,{message:g}),t[13]=g,t[14]=e),e}if(d!==n){let e;t[15]===i?e=t[16]:(e=i(`filesView.state.loading`),t[15]=i,t[16]=e);let n;return t[17]===e?n=t[18]:(n=(0,$.jsx)(as,{loading:!0,message:e}),t[17]=e,t[18]=n),n}let w;t[19]===n?w=t[20]:(w=l?void 0:Zo(n),t[19]=n,t[20]=w);let T=l?v:void 0,E;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(E={backgroundColor:`var(--surface-background)`},t[21]=E):E=t[21];let D;t[22]===i?D=t[23]:(D=i(`filesView.editor.htmlPreviewTitle`),t[22]=i,t[23]=D);let O;return t[24]!==m||t[25]!==w||t[26]!==T||t[27]!==D?(O=(0,$.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:(0,$.jsx)(`iframe`,{ref:u,src:w,srcDoc:T,className:`h-full min-h-0 w-full flex-1 border-none bg-background`,style:E,sandbox:`allow-scripts allow-same-origin allow-forms`,title:D},m)}),t[24]=m,t[25]=w,t[26]=T,t[27]=D,t[28]=O):O=t[28],O},is=e=>{let t=(0,Q.c)(30),{path:n,content:r}=e,{currentTheme:i,availableThemes:a,lightThemeId:o,darkThemeId:s}=Tt(),c;t[0]!==a||t[1]!==o?(c=a.find(e=>e.metadata.id===o)??In(!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)??In(!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=()=>{dr(l),dr(d)},p=[d,l],t[6]=d,t[7]=l,t[8]=f,t[9]=p):(f=t[8],p=t[9]),Z.useEffect(f,p);let m;t[10]!==d.metadata.id||t[11]!==l.metadata.id?(m={light:l.metadata.id,dark:d.metadata.id},t[10]=d.metadata.id,t[11]=l.metadata.id,t[12]=m):m=t[12];let h=m;if(Yo(n)){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(qn,{className:`h-full overflow-y-auto px-4 py-4`,children:(0,$.jsx)(pr,{content:r,enableFileReferences:!1})}),t[13]=r,t[14]=e),e}let g;t[15]===n?g=t[16]:(g=Go(n),t[15]=n,t[16]=g);let _;t[17]===n?_=t[18]:(_=br(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:Ir},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)(qn,{className:`min-h-0 flex-1 overflow-auto bg-[var(--syntax-base-background)]`,children:(0,$.jsx)(re,{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},as=e=>{let t=(0,Q.c)(7),{message:n,loading:r}=e,i=r!==void 0&&r,a;t[0]===i?a=t[1]:(a=i?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):(0,$.jsx)(X,{name:`folder-open-fill`,className:`size-6 text-muted-foreground`}),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:n}),t[2]=n,t[3]=o);let s;return t[4]!==a||t[5]!==o?(s=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-2`,children:[a,o]})}),t[4]=a,t[5]=o,t[6]=s):s=t[6],s};function os(e){return e.pendingFileFocusPath}function ss(e){return e.setPendingFileFocusPath}function cs(e,t){return e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1}function ls(e){return e+1}var us=b(e=>({expandedParents:{},toggleParent:t=>e(e=>{let n={...e.expandedParents};return n[t]?delete n[t]:n[t]=!0,{expandedParents:n}})})),ds=b()(x(e=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(t,n)=>e(e=>({projectExpanded:{...e.projectExpanded,[t]:n}})),setWorktreeExpanded:(t,n)=>e(e=>({worktreeExpanded:{...e.worktreeExpanded,[t]:n}}))}),{name:`mobile-session-tree`,storage:g()}));typeof window<`u`&&c(e=>{f(e)&&ds.persist.rehydrate()});var fs=36,ps=18,ms=e=>e.parentID??null,hs=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),gs=e=>{let t=e;return hs(t.directory??t.project?.worktree??null)},_s=e=>{let t=hs(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},vs=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},ys=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),bs=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))},xs=(e,t)=>{let n=hs(e),r=hs(t);return!!(n&&r&&(n===r||n.startsWith(`${r}/`)))},Ss=(e,t)=>e.worktrees.find(e=>hs(e.path)===t)??null,Cs=(e,t)=>t===e.path||!!Ss(e,t),ws=(e,t)=>{let n=hs(t);return n?e.find(e=>Cs(e,n))??null:null},Ts=(e,t,n)=>!n||`${e.title??``} ${e.id} ${gs(e)} ${t}`.toLowerCase().includes(n),Es=e=>{let t=(0,Q.c)(14),{project:n,size:r}=e,i=r===void 0?`md`:r,a=i===`sm`?`size-6 rounded-md`:`size-8 rounded-lg`,o=i===`sm`?`size-3.5`:`size-4`,s=n.icon?hn[n.icon]:null,c=n.color?gn[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=K(`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)(pn,{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},Ds=e=>{let t=(0,Q.c)(5),{expanded:n}=e,r=n?`rotate-0`:`-rotate-90`,i;t[0]===r?i=t[1]:(i=K(`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},Os=e=>{let t=(0,Q.c)(2),{ariaLabel:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`span`,{className:`inline-block size-1.5 shrink-0 rounded-full bg-primary`,"aria-label":n}),t[0]=n,t[1]=r),r},ks=e=>{let t=(0,Q.c)(12),{onClick:n,className:r}=e,{t:i}=ce(),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=K(`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},As=e=>{let t=(0,Q.c)(10),{icon:n,label:r,onClick:i,destructive:a}=e,o=a!==void 0&&a?`destructive`:`ghost`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,$.jsx)(X,{name:n,className:`size-5 shrink-0`}),t[1]=n,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[3]=r,t[4]=l);let u;return t[5]!==i||t[6]!==o||t[7]!==c||t[8]!==l?(u=(0,$.jsxs)(q,{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},js=e=>{let t=(0,Q.c)(107),{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}=ce(),x;t[0]===n?x=t[1]:(x=bs(vs(n)),t[0]=n,t[1]=x);let S=x,C,w,T,E,D,O,k,A,j,M,N,P,F,ee,I,L,R,z;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){z=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=K(`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:K(`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=K(`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=_,R=`flex min-w-0 flex-1 flex-col`,I=`flex items-center gap-2.5`;let c=r?`bg-primary`:`bg-muted-foreground/30`,d;t[50]===c?d=t[51]:(d=K(`size-1.5 shrink-0 rounded-full`,c),t[50]=c,t[51]=d),t[52]===d?L=t[53]:(L=(0,$.jsx)(`span`,{className:d,"aria-hidden":!0}),t[52]=d,t[53]=L);let f=r?`text-primary`:`text-foreground`;t[54]===f?F=t[55]:(F=K(`block min-w-0 flex-1 truncate typography-ui-label`,f),t[54]=f,t[55]=F),ee=g?Tn(z,g):z,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]=ee,t[32]=I,t[33]=L,t[34]=R,t[35]=z}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],ee=t[31],I=t[32],L=t[33],R=t[34],z=t[35];let te;t[56]!==F||t[57]!==ee?(te=(0,$.jsx)(`span`,{className:F,children:ee}),t[56]=F,t[57]=ee,t[58]=te):te=t[58];let ne;t[59]===S?ne=t[60]:(ne=S?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:S}):null,t[59]=S,t[60]=ne);let B;t[61]!==te||t[62]!==ne||t[63]!==I||t[64]!==L?(B=(0,$.jsxs)(`span`,{className:I,children:[L,te,ne]}),t[61]=te,t[62]=ne,t[63]=I,t[64]=L,t[65]=B):B=t[65];let V;t[66]!==a||t[67]!==g?(V=a?(0,$.jsx)(`span`,{className:`block truncate typography-micro text-muted-foreground pl-4`,children:g?Tn(a,g):a}):null,t[66]=a,t[67]=g,t[68]=V):V=t[68];let H;t[69]!==B||t[70]!==V||t[71]!==R?(H=(0,$.jsxs)(`span`,{className:R,children:[B,V]}),t[69]=B,t[70]=V,t[71]=R,t[72]=H):H=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]!==H?(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:H}),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]=H,t[84]=U):U=t[84];let re;t[85]!==p||t[86]!==m?(re=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)(Ni,{})}):null,t[85]=p,t[86]=m,t[87]=re):re=t[87];let ie;t[88]===b?ie=t[89]:(ie=b(`sessions.sidebar.session.menu.label`),t[88]=b,t[89]=ie);let ae;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(X,{name:`more-2`,className:`size-4`}),t[90]=ae):ae=t[90];let W;t[91]!==h.onOpenActions||t[92]!==ie?(W=(0,$.jsx)(q,{variant:`ghost`,size:`icon`,"data-session-drag-ignore":!0,"aria-label":ie,onClick:h.onOpenActions,children:ae}),t[91]=h.onOpenActions,t[92]=ie,t[93]=W):W=t[93];let oe;t[94]!==_||t[95]!==f||t[96]!==d||t[97]!==b||t[98]!==z?(oe=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:z}),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:z}),onClick:d,style:{touchAction:`manipulation`},children:_?(0,$.jsx)(X,{name:`close`,className:`size-4`}):(0,$.jsx)(X,{name:`archive`,className:`size-4`})})]}):null,t[94]=_,t[95]=f,t[96]=d,t[97]=b,t[98]=z,t[99]=oe):oe=t[99];let se;return t[100]!==N||t[101]!==P||t[102]!==U||t[103]!==re||t[104]!==W||t[105]!==oe?(se=(0,$.jsxs)(`div`,{className:N,children:[P,U,re,W,oe]}),t[100]=N,t[101]=P,t[102]=U,t[103]=re,t[104]=W,t[105]=oe,t[106]=se):se=t[106],se},Ms=e=>{let t=(0,Q.c)(15),{indent:n,showMore:r,showFewer:i,loadingMore:a,onShowMore:o,onShowFewer:s}=e,c=a!==void 0&&a,{t:l}=ce();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:K(`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},Ns=({open:e,onOpenChange:t,variant:n=`sheet`})=>{let{t:r}=ce(),{git:i}=ee(),a=yt(),o=Ae(),s=He(e=>e.activeSessions),c=He(e=>e.activePaginationByDirectory),l=lt(e=>e.projects),u=lt(e=>e.activeProjectId),d=T(e=>e.currentDirectory),f=it(e=>e.currentSessionId),p=it(e=>e.availableWorktreesByProject),m=it(e=>e.setCurrentSession),h=it(e=>e.archiveSession),g=it(e=>e.archiveSessions),_=it(e=>e.updateSessionTitle),v=it(e=>e.requestSessionSmartTitle),y=it(e=>e.shareSession),b=it(e=>e.unshareSession),x=it(e=>e.openNewSessionDraft),S=lt(e=>e.setActiveProject),C=lt(e=>e.setActiveProjectIdOnly),w=lt(e=>e.removeProject),E=Fe();_i();let D=bt(e=>e.sessionOrderByScope),O=bt(e=>e.sessionOrderActivityByScope),k=Re(),A=ds(e=>e.projectExpanded),j=ds(e=>e.worktreeExpanded),M=ds(e=>e.setProjectExpanded),N=ds(e=>e.setWorktreeExpanded),P=Ee(e=>e.orderByProject),F=us(e=>e.expandedParents),I=us(e=>e.toggleParent),[L,R]=Z.useState(``),[z,te]=Z.useState(null),[ne,B]=Z.useState(null),[V,H]=Z.useState(0),[U,re]=Z.useState(!1),[ie,ae]=Z.useState(!1),[oe,G]=Z.useState(null),[J,le]=Z.useState(null),[ue,de]=Z.useState(null),[Y,fe]=Z.useState(null),[pe,me]=Z.useState(null),[he,ge]=Z.useState(``),[_e,ve]=Z.useState(!1),[ye,be]=Z.useState(null),xe=Z.useRef(null);xe.current||=Hr({onPressedKeyChange:fe});let[Se,Ce]=Z.useState(new Set),[we,Te]=Z.useState(new Map),[De,Oe]=Z.useState(new Map),ke=ni(),Ne=ei(),Pe=W(e=>{Me(e),ot(e)}),Ie=W(e=>{Promise.all(e.map(e=>(Me(e),ot(e))))});Z.useEffect(()=>{if(!e){R(``),Oe(new Map),te(null),B(null),le(null),me(null),be(null),xe.current?.reset();return}},[e]),Z.useEffect(()=>()=>{xe.current?.reset()},[]),Z.useEffect(()=>{if(!e)return;if(l.length===0){it.setState(e=>{let t=qr(e.availableWorktreesByProject,new Set,[]);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:[]}}),Ce(e=>e.size===0?e:new Set),Te(e=>e.size===0?e:new Map);return}let t=!1;return(async()=>{let e=await Promise.all(l.map(async e=>{let n=hs(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([_n({id:e.id,path:n},{isCurrent:()=>!t}),mn(n)]);return{id:e.id,path:n,gitStatus:`success`,isGitRepo:r,worktreeStatus:a.status===`fulfilled`?`success`:`failed`,worktrees:a.status===`fulfilled`?a.value.worktrees:void 0,rootBranchStatus:o.status===`fulfilled`?`success`:`failed`,rootBranch:o.status===`fulfilled`?o.value:void 0}}));if(t)return;let n=new Set(l.map(e=>hs(e.path)).filter(Boolean)),r=e.flatMap(e=>e?.worktreeStatus?[{path:e.path,status:e.worktreeStatus,worktrees:e.worktrees}]:[]);it.setState(e=>{let t=qr(e.availableWorktreesByProject,n,r);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:Array.from(t.values()).flat()}}),Ce(t=>{let r=new Set([...t].filter(e=>n.has(e)));for(let t of e)t?.gitStatus===`success`&&(t.isGitRepo?r.add(t.path):r.delete(t.path));return ys(r,t)?t:r}),Te(t=>{let n=new Set(l.map(e=>e.id)),r=new Map([...t].filter(([e])=>n.has(e)));for(let t of e){if(!t||t.gitStatus!==`success`)continue;if(!t.isGitRepo){r.delete(t.id);continue}if(t.rootBranchStatus!==`success`)continue;let e=t.rootBranch?.trim();e&&e!==`HEAD`?r.set(t.id,e):r.delete(t.id)}return r.size===t.size&&[...r].every(([e,n])=>t.get(e)===n)?t:r})})(),()=>{t=!0}},[i,e,l,V]);let Le=Z.useMemo(()=>l.map(e=>({id:e.id,label:_s(e.path),path:hs(e.path),icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:Se.has(hs(e.path)),worktrees:et(P[e.id],p.get(hs(e.path))??[])})),[Se,l,P,p]),ze=Z.useMemo(()=>{let e=new Map(o.map(e=>[e.id,e])),t=s.map(t=>{let n=e.get(t.id);return n?Ve(n,t):t}),n=new Set(t.map(e=>e.id));for(let e of o)n.has(e.id)||t.push(e);return t},[s,o]),Ue=L.trim().toLowerCase(),Ke=Z.useMemo(()=>{let e=Le.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===u})),t=(e,t,n)=>{let r=hs(t)||e.project.path,i=r||`__root__`,a=e.buckets.find(e=>e.key===i);return a||(a={key:i,label:n?.branch||_s(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 ze){let r=gs(n);if(!r)continue;let i=hs(r),a=e.find(e=>Cs(e.project,i));if(!a)continue;let o=Ss(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){let n=hs(e.path),r=Ur(e.sessions.map(e=>({session:e})),D[n],O[n],E);e.sessions.sort((e,t)=>r({session:e},{session:t}));for(let n of e.sessions)ms(n)||(t.totalSessions+=1)}return e},[u,Le,ze,D,O,E]),qe=hs(d),Je=e=>e.isActive?qe===e.project.path?e.project.path:e.project.worktrees.find(e=>xs(qe,e.path))?.path??e.project.path:null,Ye=e=>A[e.project.id]??!0,Xe=(e,t)=>j[`${e.project.id}::${t.key}`]??!1,Ze=e=>{Oe(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},Qe=()=>{le(null),xe.current?.reset()},$e=e=>({onOpenActions:()=>le(e),pressed:Y===e.key||J?.key===e.key,onPointerDown:t=>{e.kind!==`session`&&(t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||xe.current?.start({pointerId:t.pointerId,key:e.key,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>le(e)}))},onPointerMove:e=>{xe.current?.move(e.pointerId,e.clientX,e.clientY)},onPointerUp:e=>{xe.current?.end(e.pointerId)},onPointerCancel:e=>{xe.current?.cancel(e.pointerId)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),e.kind!==`session`&&xe.current?.openFromContextMenu(e.key,()=>le(e))}}),tt=(e,t)=>{xe.current?.consumeClick(e)||t()},nt=(e,t,n,r)=>{let i=pi(),a=Kr();if(Oe(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=hs(t);if(!o)return;let s=He.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&je(o)},rt=(e,t,n)=>{let i=`${e.project.id}::${t.key}`,a=pi(),o=new Set(t.sessions.map(e=>e.id)),s=new Map;for(let e of t.sessions){let t=ms(e);if(t&&o.has(t)){let n=s.get(t)??[];n.push(e),s.set(t,n)}}let l=t.sessions.filter(e=>!ms(e)),u=De.get(i)??a,d=Vr(l,u,Ne),p=l.length-d.length,m=c.get(hs(t.path)),h=m?.hasMore===!0,g=m?.loadingMore===!0,_=l.length>a&&u>a,v=(e,t)=>{let n=s.get(e.id)??[],i=n.length>0,a=!!F[e.id],o=ke.has(e.id),c=i&&!a?n.filter(e=>ke.has(e.id)).map(e=>e.id):[],l=c.length>0,u=o?[e.id,...c]:c,d=e.title?.trim()||r(`mobile.sessions.untitled`),p=`session:${e.id}`;return(0,$.jsxs)(Z.Fragment,{children:[(0,$.jsx)(js,{session:e,active:f===e.id,indent:t,hasChildren:i,expanded:a,onToggleChildren:i?()=>I(e.id):void 0,confirmingArchive:ne===e.id,onSelect:()=>tt(p,()=>ct(e)),onRequestArchive:()=>ut(e.id),onConfirmArchive:()=>void dt(e),onStop:o||l?()=>Ie(u):void 0,stopAriaLabel:r(l?`mobile.sessions.stopSubsessionsAria`:`mobile.sessions.stopSessionAria`,{title:d}),longPressHandlers:$e({key:p,kind:`session`,session:e})}),i&&a?n.map(e=>v(e,t+ps)):null]},e.id)};return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(ci,{scopeKey:ne?null:hs(t.path),sessionIds:d.map(e=>e.id),folderIdBySessionId:new Map(d.map(e=>[e.id,bt.getState().getSessionFolderId(hs(t.path),e.id)])),onSessionDroppedOnFolder:()=>{},onSessionsReordered:(e,n)=>{bt.getState().reorderSessions(hs(t.path),d.map(e=>e.id),e,n,Wr(t.sessions)).catch(()=>We.error(r(`sessions.order.saveFailed`)))},children:d.map(e=>ne?v(e,n):(0,$.jsx)(Di,{sessionId:e.id,sessionDirectory:t.path,sessionTitle:e.title??``,children:v(e,n)},e.id))}),(0,$.jsx)(Ms,{indent:n,showMore:p>0||h,showFewer:_,loadingMore:g,onShowMore:()=>nt(i,t.path,u,l.length),onShowFewer:()=>Ze(i)})]})},at=(e,t)=>{M(e,!t)},st=(e,t,n)=>{N(`${e}::${t}`,!n)},ct=e=>{Rn();let n=gs(e)||null,r=ws(Le,n??``);r&&C(r.id),m(e.id,n),t(!1)},ut=e=>{B(t=>t===e?null:e)},dt=async e=>{B(null),await h(e.id)?Zr({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`)}):We.error(r(`sessions.sidebar.session.archive.error`))},ft=()=>{x(),t(!1)},pt=e=>{G(e),C(e),ae(!0)},mt=e=>{let t=new Map;for(let e of ze){let n=ms(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},ht=async e=>{let t=mt(e.id),{archivedIds:n,failedIds:i}=await g(t);n.length>0&&Zr({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&&We.error(i.length===1?r(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):r(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}))},gt=e=>{let t=mt(e.id);Gr({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`)})},_t=async e=>{try{if(!(await y(e.id))?.share?.url){We.error(r(`sessions.sidebar.session.share.error`));return}We.success(r(`sessions.sidebar.session.share.successTitle`),{description:r(`sessions.sidebar.session.share.successDescription`)})}catch{We.error(r(`sessions.sidebar.session.share.error`))}},vt=async e=>{if((await se(e)).ok){We.success(r(`sessions.sidebar.session.menu.copied`));return}We.error(r(`sessions.sidebar.session.share.copyUrlError`))},xt=async e=>{try{if(await b(e)){We.success(r(`sessions.sidebar.session.unshare.success`));return}We.error(r(`sessions.sidebar.session.unshare.error`))}catch{We.error(r(`sessions.sidebar.session.unshare.error`))}},St=async()=>{if(!pe)return;let e=he.trim();if(e)try{await _(pe.id,e),me(null),ge(``)}catch{We.error(r(`sessions.sidebar.session.menu.rename`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},Ct=async()=>{if(!pe||_e)return;let e=pe.id;me(null),ge(``),ve(!0);try{await v(e)}catch{We.error(r(`sessions.sidebar.session.rename.smartTitle`),{description:r(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{ve(!1)}},wt=(e,n)=>{C(e.id),x({selectedProjectId:e.id,directoryOverride:n,preserveDirectoryOverride:!0}),t(!1)},Tt=e=>{(async()=>{try{await _n({id:e.id,path:e.path})}catch(e){console.warn(`[MobileSessions] Worktree refresh before session sync failed:`,e)}let t=it.getState().availableWorktreesByProject.get(e.path)??e.worktrees,n=[e.path,...t.map(e=>e.path)];await Be(n,ze)})()},Et=e=>{let t=gs(e),n=ws(Le,t);if(!n)return _s(t)||t;let r=Ss(n,hs(t));return r?.branch?`${n.label} · ${r.branch}`:n.label},Dt=e=>{S(e.id),t(!1)},Ot=Z.useMemo(()=>Ue?Ke.filter(e=>`${e.project.label} ${e.project.path}`.toLowerCase().includes(Ue)?!0:e.buckets.some(t=>t.sessions.some(t=>Ts(t,e.project.label,Ue)))):Ke,[Ue,Ke]),kt=Z.useMemo(()=>Ue?ze.filter(e=>{let t=gs(e);return Ts(e,ws(Le,t)?.label??``,Ue)}).sort((e,t)=>Ge(t)-Ge(e)):[],[Ue,Le,ze]),At=Z.useMemo(()=>Ue?Le.filter(e=>`${e.label} ${e.path}`.toLowerCase().includes(Ue)).map(e=>({...e,sessionCount:ze.filter(t=>!ms(t)&&Cs(e,hs(gs(t)))).length})):[],[Ue,Le,ze]),Mt=Ue&&kt.length===0&&At.length===0,Nt=Le.length>0?(0,$.jsxs)(q,{type:`button`,variant:`default`,size:`sm`,"aria-label":r(`mobile.sessions.newChat`),onClick:ft,style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`add`,className:`size-4`}),r(`mobile.sessions.newChat`)]}):null,Pt=Le.find(e=>e.id===u)??null,Ft=Pt?.isGitRepo?(0,$.jsx)(q,{type:`button`,variant:`chip`,size:`sm`,"aria-label":r(`sessions.sidebar.project.actions.newWorktree`),title:r(`sessions.sidebar.project.actions.newWorktree`),onClick:()=>pt(Pt.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`node-tree`,className:`size-4`})}):null,It=(0,$.jsx)(q,{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`})}),Lt=Nt||It?(0,$.jsxs)($.Fragment,{children:[Nt,Ft,It]}):null,Rt=J?.kind===`project`?J.project.label:J?.kind===`worktree`?J.worktree.branch||J.worktree.label||J.worktree.path:J?.kind===`session`?J.session.title?.trim()||r(`mobile.sessions.untitled`):``,zt=Z.useMemo(()=>{if(!J)return[];if(J.kind===`project`){let e=J.project;return Rr({gitRepository:e.isGitRepo,onNewSession:()=>{Qe(),wt(e,e.path)},onNewWorktree:()=>{Qe(),pt(e.id)},onSyncSessions:()=>{Qe(),Tt(e)},onEditProject:()=>{Qe(),te(e.id)},onCloseProject:()=>{Qe(),de(e)}})}if(J.kind===`worktree`){let{project:e,worktree:t}=J;return mi({onNewSession:()=>{Qe(),wt(e,t.path)},onDeleteWorktree:()=>{Qe(),be({project:e,worktree:t})}})}let e=J.session,t=!!e.share?.url;return Jr({pinned:E.has(e.id),shared:t,onRename:()=>{Qe(),ge(e.title?.trim()||r(`mobile.sessions.untitled`)),me(e)},onTogglePin:()=>{Qe(),k(e.id)},onShare:!a||t?void 0:()=>{Qe(),_t(e)},onCopyLink:a&&t?()=>{let t=e.share?.url;Qe(),t&&vt(t)}:void 0,onUnshare:a&&t?()=>{Qe(),xt(e.id)}:void 0,onArchive:()=>{Qe(),ht(e)},onDelete:()=>{Qe(),gt(e)}})},[J,Qe,ht,vt,gt,pt,_t,xt,E,wt,Tt,r,k]),Bt=zt.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:zt.map(e=>{let t=(0,$.jsx)(As,{icon:e.icon,label:Lr(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,Vt=(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)(vn,{value:L,onChange:e=>R(e.target.value),placeholder:r(`mobile.sessions.search.placeholder`),className:K(`h-11 pl-9`,L&&`pr-10`)}),L?(0,$.jsx)(`button`,{type:`button`,className:`absolute right-1.5 top-1/2 flex size-8 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":r(`mobile.sessions.clearSearchAria`),onClick:()=>R(``),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-4`})}):null]})}),(0,$.jsx)(qn,{className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto pb-4`,children:Le.length===0?(0,$.jsx)(Ps,{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`)]})}):Mt?(0,$.jsx)(Ps,{title:r(`mobile.sessions.empty.searchTitle`),description:r(`mobile.sessions.empty.searchDescription`)}):Ue?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-3 pt-2`,children:[kt.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:kt.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:kt.map((e,t)=>{let n=ke.has(e.id),i=e.title?.trim()||r(`mobile.sessions.untitled`);return(0,$.jsx)(`div`,{className:K(t>0&&`border-t border-border/30`),children:(0,$.jsx)(js,{session:e,active:f===e.id,indent:12,contextLabel:Et(e),highlightQuery:Ue,onSelect:()=>tt(`session:${e.id}`,()=>ct(e)),longPressHandlers:$e({key:`session:${e.id}`,kind:`session`,session:e}),onStop:n?()=>Pe(e.id):void 0,stopAriaLabel:r(`mobile.sessions.stopSessionAria`,{title:i})})},e.id)})})]}):null,At.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:At.length})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/40 bg-[var(--surface-elevated)]`,children:At.map((e,t)=>{let n=`project:${e.id}`,r=$e({key:n,kind:`project`,project:e});return(0,$.jsxs)(`div`,{className:K(`flex items-center`,t>0&&`border-t border-border/30`),children:[(0,$.jsxs)(`button`,{type:`button`,className:K(`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:()=>tt(n,()=>Dt(e)),onPointerDown:r.onPointerDown,onPointerMove:r.onPointerMove,onPointerUp:r.onPointerUp,onPointerCancel:r.onPointerCancel,onContextMenu:r.onContextMenu,style:{touchAction:`manipulation`},children:[(0,$.jsx)(Es,{project:e}),(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:Tn(e.label,Ue)}),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:e.sessionCount})]}),e.isGitRepo?(0,$.jsx)(ks,{className:`mr-2`,onClick:()=>pt(e.id)}):null]},e.id)})})]}):null]}):(0,$.jsx)(`div`,{className:`flex flex-col`,children:Ot.map((e,t)=>{let n=Ye(e),i=`project:${e.project.id}`,a=$e({key:i,kind:`project`,project:e.project}),o=Ue?e.buckets.filter(t=>t.sessions.some(t=>Ts(t,e.project.label,Ue))):e.buckets,s=Je(e);return(0,$.jsxs)(`section`,{className:K(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:K(`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:()=>tt(i,()=>at(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)(Es,{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}),we.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:we.get(e.project.id)})]}):null]}),e.isActive?(0,$.jsx)(Os,{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=>ke.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(),Ie(t)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Ni,{})}):null})(),e.project.isGitRepo?(0,$.jsx)(ks,{className:`mr-2`,onClick:()=>pt(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?rt(e,t,fs):null,n.map(t=>{let n=Xe(e,t),i=s===t.path,a=`worktree:${e.project.id}:${t.key}`,o=$e({key:a,kind:`worktree`,project:e.project,worktree:t.worktree});return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,className:K(`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:()=>tt(a,()=>st(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)(Ds,{expanded:n}),(0,$.jsx)(X,{name:`node-tree`,className:K(`size-4 shrink-0`,i?`text-primary`:`text-muted-foreground`)}),(0,$.jsx)(`span`,{className:K(`block min-w-0 flex-1 truncate typography-ui-label font-semibold`,i?`text-foreground`:`text-foreground/90`),children:t.label}),i?(0,$.jsx)(Os,{ariaLabel:r(`mobile.sessions.activeWorktreeAria`)}):null,(()=>{let e=n?[]:t.sessions.filter(e=>ke.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(),Ie(e)},style:{touchAction:`manipulation`},children:(0,$.jsx)(Ni,{})}):null})(),(0,$.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground tabular-nums`,children:t.sessions.length})]}),n?rt(e,t,fs):null]},t.key)})]})})()}):null]},e.project.id)})})}),(0,$.jsx)(ji,{open:U,onOpenChange:re,forceMobile:!0}),(0,$.jsx)(jt,{open:ie,projectId:oe,onOpenChange:e=>{ae(e),e||G(null)},onWorktreeCreated:(e,n)=>{n?.sessionId?m(n.sessionId,e):x({selectedProjectId:oe,directoryOverride:e,preserveDirectoryOverride:!0}),t(!1)}}),(0,$.jsx)(An,{open:!!J,title:Rt,onClose:Qe,contentMaxHeightClassName:`max-h-[min(68dvh,560px)]`,children:Bt}),(0,$.jsx)(An,{open:!!ue,title:r(`sessions.sidebar.project.actions.closeProject`),onClose:()=>de(null),closeAriaLabel:r(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>de(null),children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(q,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!ue)return;let e=ue;de(null),w(e.id),We.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:ue?.label??``})})}),(0,$.jsx)(An,{open:!!pe,title:r(`sessions.sidebar.session.menu.rename`),onClose:()=>{_e||(me(null),ge(``))},footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:_e,onClick:()=>{me(null),ge(``)},children:r(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(q,{type:`button`,variant:`default`,className:`flex-1`,disabled:!he.trim()||_e,onClick:()=>void St(),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(),St()},children:[(0,$.jsx)(vn,{value:he,onChange:e=>ge(e.target.value),autoFocus:!0,className:`h-12`,disabled:_e}),(0,$.jsxs)(q,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:_e,onClick:()=>void Ct(),children:[_e?(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`)]})]})}),ye?(0,$.jsx)(Br,{open:!0,project:{id:ye.project.id,path:ye.project.path},worktree:ye.worktree,onClose:()=>be(null),onDeleted:()=>H(e=>e+1)}):null,(0,$.jsx)(Yr,{open:z!==null,project:Le.find(e=>e.id===z)??null,onClose:()=>te(null),onWorktreesChanged:()=>H(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:Lt?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:Lt}):null}),Vt]}):null:(0,$.jsx)(Un,{id:`mobile-sessions-sheet`,open:e,onOpenChange:t,trailing:Lt,ariaLabel:r(`mobile.sessions.sheet.title`),closeAriaLabel:r(`mobile.surface.closeAria`),resizeAriaLabel:r(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:Vt})},Ps=e=>{let t=(0,Q.c)(10),{title:n,description:r,action:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r}):null,t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=i?(0,$.jsx)(`div`,{className:`pt-2`,children:i}):null,t[4]=i,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[a,o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c},Fs=`/assets/assistant-guide-hero-wide-DiFIThB0.jpg`;function Is(e){let t=(0,Q.c)(19),{swipe:n,actions:r}=e,{offset:i,dragging:a,actionRailRef:o,closeActions:s}=n,c=i!==0,l=a?`transition-none`:`transition-transform duration-150 ease-out`,u=!c&&`invisible pointer-events-none`,d;t[0]!==l||t[1]!==u?(d=K(`oc-mobile-session-actions absolute inset-y-0 right-0 z-0 flex items-stretch`,l,u),t[0]=l,t[1]=u,t[2]=d):d=t[2];let f=`translate3d(calc(var(--oc-mobile-session-actions-width) + ${i}px), 0, 0)`,p=c?`transform`:void 0,m;t[3]!==f||t[4]!==p?(m={transform:f,willChange:p},t[3]=f,t[4]=p,t[5]=m):m=t[5];let h=!c,g;if(t[6]!==r||t[7]!==s||t[8]!==c){let e;t[10]!==s||t[11]!==c?(e=e=>(0,$.jsxs)(q,{type:`button`,variant:e.destructive?`destructive`:`secondary`,className:K(`oc-mobile-session-action h-full flex-col rounded-none border-0 px-1`,!e.destructive&&`bg-interactive-selection text-interactive-selection-foreground hover:bg-interactive-active`),"aria-label":e.label,tabIndex:c?0:-1,onClick:()=>{s(),e.onClick()},children:[(0,$.jsx)(X,{name:e.icon,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`oc-mobile-session-action-label font-medium`,children:e.label})]},e.label),t[10]=s,t[11]=c,t[12]=e):e=t[12],g=r.map(e),t[6]=r,t[7]=s,t[8]=c,t[9]=g}else g=t[9];let _;return t[13]!==o||t[14]!==d||t[15]!==m||t[16]!==h||t[17]!==g?(_=(0,$.jsx)(`div`,{ref:o,"data-session-drag-ignore":!0,className:d,style:m,"aria-hidden":h,children:g}),t[13]=o,t[14]=d,t[15]=m,t[16]=h,t[17]=g,t[18]=_):_=t[18],_}var Ls=10,Rs=`oc:mobile-session-row-revealed`,zs=e=>{window.dispatchEvent(new CustomEvent(Rs,{detail:e}))};function Bs(e,t,n){let r=(0,Q.c)(32),i=n!==void 0&&n,[a,o]=Z.useState(0),[s,c]=Z.useState(!1),l=Z.useRef(null),u=Z.useRef(!1),d=Z.useRef(null),f,p;r[0]===i?(f=r[1],p=r[2]):(f=()=>{i&&(l.current=null,u.current=!0,o(0),c(!1))},p=[i],r[0]=i,r[1]=f,r[2]=p),Z.useEffect(f,p);let m;r[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{o(0)},r[3]=m):m=r[3];let h;r[4]===e?h=r[5]:(h=[e],r[4]=e,r[5]=h),Z.useEffect(m,h);let g;r[6]===e?g=r[7]:(g=t=>{t.detail!==e&&o(0)},r[6]=e,r[7]=g),oe(Rs,g);let _;r[8]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>o(0),r[8]=_):_=r[8];let v=W(_),y;r[9]!==i||r[10]!==a?(y=e=>{if(i||e.button!==0||e.pointerType!==`touch`&&e.pointerType!==`pen`)return;let t=d.current?.offsetWidth??0;t<=0||(l.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startOffset:a,actionWidth:t,intent:`pending`},u.current=!1)},r[9]=i,r[10]=a,r[11]=y):y=r[11];let b=W(y),x;r[12]!==i||r[13]!==e?(x=t=>{if(i)return;let n=l.current;if(!n||n.pointerId!==t.pointerId)return;let r=t.clientX-n.startX,a=t.clientY-n.startY;if(n.intent===`pending`){let i=Math.abs(r),o=Math.abs(a);if(o>Ls&&o>i){n.intent=`vertical`,l.current=null;return}if(i>Ls&&i>o){n.intent=`horizontal`,c(!0),u.current=!0;try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}zs(e)}}n.intent===`horizontal`&&(t.preventDefault(),o(Math.max(-n.actionWidth,Math.min(0,n.startOffset+r))))},r[12]=i,r[13]=e,r[14]=x):x=r[14];let S=W(x),C;r[15]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{let t=l.current;!t||t.pointerId!==e.pointerId||(l.current=null,t.intent===`horizontal`&&(c(!1),o(e=>e<-(t.actionWidth*.35)?-t.actionWidth:0)))},r[15]=C):C=r[15];let w=W(C),T;r[16]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>{let e=l.current;l.current=null,c(!1),o(e?.startOffset??0)},r[16]=T):T=r[16];let E=W(T),D;r[17]!==v||r[18]!==e||r[19]!==a||r[20]!==t?(D=()=>{if(u.current){u.current=!1;return}if(a!==0){v();return}zs(e),t()},r[17]=v,r[18]=e,r[19]=a,r[20]=t,r[21]=D):D=r[21];let O=W(D),k=W(Vs),A;return r[22]!==v||r[23]!==s||r[24]!==w||r[25]!==k||r[26]!==E||r[27]!==b||r[28]!==S||r[29]!==O||r[30]!==a?(A={offset:a,dragging:s,actionRailRef:d,closeActions:v,handleSelect:O,handlePointerDown:b,handlePointerMove:S,finishGesture:w,handlePointerCancel:E,handleContextMenu:k},r[22]=v,r[23]=s,r[24]=w,r[25]=k,r[26]=E,r[27]=b,r[28]=S,r[29]=O,r[30]=a,r[31]=A):A=r[31],A}function Vs(e){e.preventDefault(),e.stopPropagation()}var Hs=[{image:zi,titleKey:`assistants.guide.share.ios.title`,descriptionKey:`assistants.guide.share.ios.description`},{image:Wi,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 Us(){let e=(0,Q.c)(8),{t}=ce(),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 Ws(e){let t=(0,Q.c)(35),{onEnable:n}=e,{t:r}=ce(),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:Fs,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)(q,{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=Hs.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 Gs(e){let t=(0,Q.c)(48),{avatarSeed:n,unreadCount:r,assistantID:i,displayName:a,summary:o,enabled:s,editLabel:c,deleteLabel:l,onOpen:u,onEdit:d,onDelete:f,serverWorking:p}=e,m=aa(i,p!==void 0&&p),h=Bs(`assistant:${i}`,u),g;t[0]!==c||t[1]!==d?(g={label:c,icon:`edit`,onClick:d},t[0]=c,t[1]=d,t[2]=g):g=t[2];let _;t[3]!==l||t[4]!==f?(_={label:l,icon:`delete-bin`,destructive:!0,onClick:f},t[3]=l,t[4]=f,t[5]=_):_=t[5];let v;t[6]!==g||t[7]!==_?(v=[g,_],t[6]=g,t[7]=_,t[8]=v):v=t[8];let y;t[9]!==h||t[10]!==v?(y=(0,$.jsx)(Is,{swipe:h,actions:v}),t[9]=h,t[10]=v,t[11]=y):y=t[11];let b=h.dragging?`transition-none`:`transition-transform duration-150 ease-out`,x=!s&&`opacity-65`,S;t[12]!==b||t[13]!==x?(S=K(`oc-mobile-assistant-card relative z-10 motion-reduce:transition-none`,b,x),t[12]=b,t[13]=x,t[14]=S):S=t[14];let C=h.handleSelect,w=h.handlePointerDown,T=h.handlePointerMove,E=h.finishGesture,D=h.handlePointerCancel,O=h.handleContextMenu,k=`translate3d(${h.offset}px, 0, 0)`,A=h.offset===0?void 0:`transform`,j;t[15]!==k||t[16]!==A?(j={touchAction:`pan-y`,transform:k,willChange:A},t[15]=k,t[16]=A,t[17]=j):j=t[17];let M;t[18]!==i||t[19]!==n||t[20]!==a||t[21]!==m?(M=(0,$.jsx)(`span`,{className:`oc-mobile-assistant-avatar`,children:(0,$.jsx)(ra,{name:i,avatarSeed:n,size:44,label:a,working:m})}),t[18]=i,t[19]=n,t[20]=a,t[21]=m,t[22]=M):M=t[22];let N;t[23]===a?N=t[24]:(N=(0,$.jsx)(`span`,{className:`oc-mobile-entity-title oc-mobile-assistant-name block min-w-0 truncate font-semibold text-foreground`,children:a}),t[23]=a,t[24]=N);let P;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(P=K(`oc-mobile-assistant-summary`,ia),t[25]=P):P=t[25];let F;t[26]===o?F=t[27]:(F=(0,$.jsx)(`span`,{className:P,children:o}),t[26]=o,t[27]=F);let ee;t[28]!==N||t[29]!==F?(ee=(0,$.jsxs)(`span`,{className:`oc-mobile-assistant-card-content min-w-0 flex-1`,children:[N,F]}),t[28]=N,t[29]=F,t[30]=ee):ee=t[30];let I;t[31]===r?I=t[32]:(I=(0,$.jsx)(sa,{count:r}),t[31]=r,t[32]=I);let L;t[33]!==h.finishGesture||t[34]!==h.handleContextMenu||t[35]!==h.handlePointerCancel||t[36]!==h.handlePointerDown||t[37]!==h.handlePointerMove||t[38]!==h.handleSelect||t[39]!==j||t[40]!==M||t[41]!==ee||t[42]!==I||t[43]!==S?(L=(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":`false`,"data-mobile-press-feedback":`soft`,className:S,onClick:C,onPointerDown:w,onPointerMove:T,onPointerUp:E,onPointerCancel:D,onContextMenu:O,style:j,children:[M,ee,I]}),t[33]=h.finishGesture,t[34]=h.handleContextMenu,t[35]=h.handlePointerCancel,t[36]=h.handlePointerDown,t[37]=h.handlePointerMove,t[38]=h.handleSelect,t[39]=j,t[40]=M,t[41]=ee,t[42]=I,t[43]=S,t[44]=L):L=t[44];let R;return t[45]!==L||t[46]!==y?(R=(0,$.jsxs)(Bi,{className:`oc-mobile-assistant-card-shell relative isolate overflow-hidden`,children:[y,L]}),t[45]=L,t[46]=y,t[47]=R):R=t[47],R}function Ks(e){let t=(0,Q.c)(118),{onEnable:n,onOpenAssistant:r,className:i}=e,{t:a}=ce(),o=$n(),s=xe(),c=Se();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=na(l),t[2]=l,t[3]=u);let d=u,f=St(qs),[p,m]=Z.useState(null),h;t[4]===n?h=t[5]:(h=()=>n(),t[4]=n,t[5]=h);let g=W(h),_;t[6]!==o||t[7]!==f?(_=()=>{f(),o?.openSettings(`assistants`)},t[6]=o,t[7]=f,t[8]=_):_=t[8];let v=W(_),y;t[9]===r?y=t[10]:(y=e=>r(e),t[9]=r,t[10]=y);let b=W(y),x;t[11]===o?x=t[12]:(x=e=>{wt(e,o?{openMobileSettings:o.openSettings}:void 0)},t[11]=o,t[12]=x);let S=W(x),C;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{m(e)},t[13]=C):C=t[13];let w=W(C),T;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>{e||m(null)},t[14]=T):T=t[14];let E=W(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)(Bi,{className:`oc-mobile-assistant-loading`,children:(0,$.jsx)(Us,{})}),t[21]=e):e=t[21];let n;return t[22]!==i||t[23]!==O?(n=(0,$.jsx)(Ui,{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)(q,{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)(ea,{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=ue(e.name).displayName||e.name,n=ta(e.latestMessagePreview,a);return(0,$.jsx)(Gs,{assistantID:e.id,avatarSeed:e.avatarSeed,unreadCount:e.unreadCount??0,displayName:t,summary:n,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)($i,{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)(Ui,{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)(q,{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)(Bi,{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)(Ui,{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),ee;t[87]!==a||t[88]!==P||t[89]!==N?(ee=a(P?`assistants.state.unavailable`:N?`assistants.state.unsupportedTitle`:`assistants.state.instanceDisabled`),t[87]=a,t[88]=P,t[89]=N,t[90]=ee):ee=t[90];let I=ee;if(F&&!P){let e;t[91]===g?e=t[92]:(e=(0,$.jsx)(Ws,{onEnable:g}),t[91]=g,t[92]=e);let n;return t[93]!==i||t[94]!==O||t[95]!==e?(n=(0,$.jsx)(Ui,{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 L;t[97]===O?L=t[98]:(L=(0,$.jsx)(`span`,{className:`oc-mobile-page-section-label`,children:O}),t[97]=O,t[98]=L);let R=N?`cloud-off`:`sparkling`,z;t[99]===R?z=t[100]:(z=(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:R,weight:`medium`,className:`size-5`})}),t[99]=R,t[100]=z);let te;t[101]===I?te=t[102]:(te=(0,$.jsx)(`h2`,{className:`mt-5 max-w-xs text-lg font-semibold leading-snug tracking-[-0.02em] text-foreground`,children:I}),t[101]=I,t[102]=te);let ne;t[103]!==a||t[104]!==P||t[105]!==N?(ne=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]=ne):ne=t[106];let B;t[107]!==z||t[108]!==te||t[109]!==ne?(B=(0,$.jsxs)(`section`,{className:`w-full max-w-md py-2`,children:[z,te,ne]}),t[107]=z,t[108]=te,t[109]=ne,t[110]=B):B=t[110];let V;t[111]!==L||t[112]!==B?(V=(0,$.jsx)(Ii,{label:L,cardClassName:`oc-mobile-assistant-state-card`,children:B}),t[111]=L,t[112]=B,t[113]=V):V=t[113];let H;return t[114]!==i||t[115]!==O||t[116]!==V?(H=(0,$.jsx)(Ui,{title:O,className:i,surface:!1,surfaceClassName:`oc-mobile-assistant-state`,children:V}),t[114]=i,t[115]=O,t[116]=V,t[117]=H):H=t[117],H}function qs(e){return e.requestCreate}function Js(e){let t=(0,Q.c)(16),{assistantID:n,onBack:r}=e,{t:i}=ce(),[a,o]=(0,Z.useState)(null),s;t[0]===i?s=t[1]:(s=i(`assistants.title`),t[0]=i,t[1]=s);let c;t[2]===i?c=t[3]:(c=i(`settings.view.actions.back`),t[2]=i,t[3]=c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`div`,{ref:o}),t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==s||t[7]!==c?(u=(0,$.jsx)(Ce,{title:s,backAriaLabel:c,onBack:r,trailing:l}),t[5]=r,t[6]=s,t[7]=c,t[8]=u):u=t[8];let d;t[9]!==n||t[10]!==r||t[11]!==a?(d=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden px-[var(--oc-mobile-page-inline-inset)] pb-[var(--oc-safe-area-bottom,env(safe-area-inset-bottom,0px))]`,children:(0,$.jsx)(Bi,{className:`oc-mobile-settings-detail-card h-full`,children:(0,$.jsx)(xn,{children:(0,$.jsx)(Li,{assistantID:n,onItemDeleted:r,saveActionContainer:a},n)})})}),t[9]=n,t[10]=r,t[11]=a,t[12]=d):d=t[12];let f;return t[13]!==u||t[14]!==d?(f=(0,$.jsxs)(`div`,{"data-settings-view":`true`,"data-mobile-settings-stage":`page-content`,className:`oc-settings-workspace oc-settings-workspace-mobile flex h-full min-h-0 flex-col overflow-hidden bg-background`,children:[u,d]}),t[13]=u,t[14]=d,t[15]=f):f=t[15],f}function Ys(e){let t=(0,Q.c)(13),{route:n}=e,{t:r}=ce(),i;t[0]===r?i=t[1]:(i=r(`chat.btw.title`),t[0]=r,t[1]=i);let a;t[2]===r?a=t[3]:(a=r(`header.actions.backAria`),t[2]=r,t[3]=a);let o;t[4]!==i||t[5]!==a?(o=(0,$.jsx)(Ce,{title:i,backAriaLabel:a,onBack:Xs}),t[4]=i,t[5]=a,t[6]=o):o=t[6];let s;t[7]!==n.directory||t[8]!==n.sessionId?(s=(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(zt,{scope:{sessionId:n.sessionId,directory:n.directory},foot:`page`})}),t[7]=n.directory,t[8]=n.sessionId,t[9]=s):s=t[9];let c;return t[10]!==o||t[11]!==s?(c=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[o,s]}),t[10]=o,t[11]=s,t[12]=c):c=t[12],c}function Xs(){Qi.requestAnimatedBack(`root`)}var Zs=[{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 Qs(e){let t=(0,Q.c)(22),{activeTab:n,onTabChange:r,className:i,tabMarks:a}=e,{t:o}=ce(),s=Te(),c;t[0]===o?c=t[1]:(c=o(`mobile.tabs.activity.loading`),t[0]=o,t[1]=c);let l=c,u;t[2]===r?u=t[3]:(u=e=>{r(e.currentTarget.dataset.tab)},t[2]=r,t[3]=u);let d=W(u),f;t[4]!==n||t[5]!==r?(f=e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=Zs.findIndex(e=>e.id===n),i=Zs[e.key===`Home`?0:e.key===`End`?Zs.length-1:(t+(e.key===`ArrowRight`?1:-1)+Zs.length)%Zs.length];r(i.id),document.getElementById(`mobile-tab-${i.id}`)?.focus()},t[4]=n,t[5]=r,t[6]=f):f=t[6];let p=W(f),m;t[7]===o?m=t[8]:(m=o(`mobile.nav.aria`),t[7]=o,t[8]=m);let h;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(h={role:`tablist`},t[9]=h):h=t[9];let g;t[10]!==n||t[11]!==s||t[12]!==d||t[13]!==p||t[14]!==l||t[15]!==o||t[16]!==a?(g=Zs.map(e=>{let t=e.id===n,r=o(e.labelKey),i=e.id===`assistant`&&s>0,c=!i&&a?.[e.id]===`loading`,u=i?`mobile-tab-assistant-unread`:c?`mobile-tab-${e.id}-activity`:void 0;return(0,$.jsxs)(q,{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":u,"aria-selected":t,tabIndex:t?0:-1,title:r,onClick:d,onKeyDown:p,className:K(`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`}),u?(0,$.jsx)(`span`,{id:u,role:c?`status`:void 0,"aria-label":c?l:void 0,"data-mobile-tab-activity":c?`loading`:void 0,className:`pointer-events-none absolute left-full -top-1 ml-0.5 inline-flex z-10`,children:i?(0,$.jsx)(ca,{className:`h-[18px] min-w-[18px] bg-foreground px-1 text-[11px] font-bold tracking-normal text-background shadow-none ring-2 ring-background`}):(0,$.jsx)(`span`,{className:`inline-flex size-[18px] items-center justify-center rounded-full bg-foreground text-background ring-2 ring-background`,children:(0,$.jsx)(X,{name:`loader-4`,className:`size-3 animate-spin`})})}):null]}),(0,$.jsx)(`span`,{className:`oc-mobile-tab-label block max-w-full overflow-hidden text-ellipsis whitespace-nowrap`,children:r})]},e.id)}),t[10]=n,t[11]=s,t[12]=d,t[13]=p,t[14]=l,t[15]=o,t[16]=a,t[17]=g):g=t[17];let _;return t[18]!==i||t[19]!==m||t[20]!==g?(_=(0,$.jsx)(Gi,{as:`nav`,"aria-label":m,variant:`navigation`,surfaceProps:h,className:i,children:g}),t[18]=i,t[19]=m,t[20]=g,t[21]=_):_=t[21],_}function $s(e){return e.unreadCount>0?`unread`:e.working?`loading`:null}var ec=`oc-native-ios-tab-bar`,tc=`OpenChamberTabBar`,nc=[`projects`,`assistant`,`scheduled`,`settings`],rc=B(tc),ic=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.nativeUiEnabled!==!1;function ac(){return typeof window>`u`?!1:ic({isCapacitor:k(),platform:j(),pluginAvailable:V.isPluginAvailable(tc),nativeUiEnabled:ar()})}var oc=e=>e.classList.contains(`dark`)?`dark`:`light`,sc=()=>or(`--primary`),cc=e=>typeof e==`string`&&nc.includes(e),lc=e=>typeof e==`string`&&cc(e)?e:null,uc=(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&&e.activity===!0==(t.tabs[n]?.activity===!0)&&(e.activity===!0?e.activityLabel??null:null)===(t.tabs[n]?.activity===!0?t.tabs[n]?.activityLabel??null:null)),dc=(e,t)=>{e.classList.toggle(ec,t)},fc=(e,t)=>e&&!t,pc=e=>e.visible?e.overlayHidden?{action:`present`}:e.lastState&&uc(e.lastState,e.nextState)?{action:`skip`}:{action:`present`}:e.overlayHidden?{action:`skip`}:{action:`hide`},mc=()=>rc,hc=`mobile-overlay-root`;function gc(e){let t=(0,Q.c)(28),n=lr(),r;t[0]===n?r=t[1]:(r=n&&ac(),t[0]=n,t[1]=r);let i=r,[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(null),f=(0,Z.useRef)(!1),p=(0,Z.useRef)(!1),m=W(e.onTabChange),h;t[2]===e.tabs?h=t[3]:(h=JSON.stringify(e.tabs.map(vc)),t[2]=e.tabs,t[3]=h);let g=h,_;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=typeof document>`u`?`dark`:oc(document.documentElement),t[4]=_):_=t[4];let v=_,y;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=typeof document>`u`?``:sc(),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(hc);e||(e=document.createElement(`div`),e.id=hc,document.body.appendChild(e));let t=()=>u(nn(e.children));t();let n=new MutationObserver(t);return n.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[Qt]}),()=>n.disconnect()},S=[i],t[6]=i,t[7]=x,t[8]=S),(0,Z.useEffect)(x,S);let C;t[9]!==i||t[10]!==m?(C=()=>{if(!i)return;let e=!1,t=mc(),n=[];return t.addListener(`tabSelected`,e=>{let t=lc(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`&&dc(document.documentElement,!1)}},t[9]=i,t[10]=m,t[11]=C):C=t[11];let w;t[12]===i?w=t[13]:(w=[i],t[12]=i,t[13]=w),(0,Z.useEffect)(C,w);let T;t[14]!==e.activeTab||t[15]!==e.ariaLabel||t[16]!==e.tabs||t[17]!==e.visible||t[18]!==i||t[19]!==l?(T=()=>{if(!i||p.current)return;let t=!1,n=mc(),r={tabs:e.tabs.map(_c),selectedTab:e.activeTab,appearance:v,accentColor:b,ariaLabel:e.ariaLabel},a=pc({visible:fc(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`&&dc(document.documentElement,!1);return}f.current=!1,d.current=r,o(!0),typeof document<`u`&&dc(document.documentElement,!0)}})().catch(()=>{t||(p.current=!0,c(!0),o(!1),typeof document<`u`&&dc(document.documentElement,!1))}),()=>{t=!0}},t[14]=e.activeTab,t[15]=e.ariaLabel,t[16]=e.tabs,t[17]=e.visible,t[18]=i,t[19]=l,t[20]=T):T=t[20];let E;return t[21]!==e.activeTab||t[22]!==e.ariaLabel||t[23]!==e.visible||t[24]!==i||t[25]!==l||t[26]!==g?(E=[i,e.visible,l,e.activeTab,e.ariaLabel,v,b,g],t[21]=e.activeTab,t[22]=e.ariaLabel,t[23]=e.visible,t[24]=i,t[25]=l,t[26]=g,t[27]=E):E=t[27],(0,Z.useLayoutEffect)(T,E),!i||s?`web`:a?`native`:`pending`}function _c(e){return{id:e.id,label:e.label,badge:e.badge??null,activity:e.activity===!0,activityLabel:e.activity===!0?e.activityLabel??null:null}}function vc(e){return[e.id,e.label,e.badge??null,e.activity===!0,e.activity===!0?e.activityLabel??null:null]}function yc(e){let t=(0,Q.c)(50),{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}=ce(),p=r.activeTab,m=l.slice(-2),h=m.at(-1)??null,g=h?.key??null,_=h?.depth,v=m.length>1?m[m.length-2].key:null,y;t[0]===p?y=t[1]:(y=()=>new Set([p]),t[0]=p,t[1]=y);let[b,x]=Z.useState(y);b.has(p)||x(e=>{if(e.has(p))return e;let t=new Set(e);return t.add(p),t});let S=Z.useRef(null),C=Z.useRef(null),w=Z.useRef(null),T=Z.useRef(new Map),E=Z.useRef(null),D=Z.useRef(!1),O=Z.useRef(``),k=W(()=>h?.onBack());Xi({id:h?`mobile-secondary:${h.key}`:`mobile-secondary:inactive`,active:!!h,onBack:k,surfaceRef:S,underlayRef:C}),Z.useLayoutEffect(()=>{let e=g===null?null:T.current.get(g)??null,t=v===null?w.current:T.current.get(v)??null;S.current=e,C.current=t},[g,_,v]);let A;t[2]===h?A=t[3]:(A=[h],t[2]=h,t[3]=A),Z.useLayoutEffect(()=>{if(h){if(!D.current){let e=document.activeElement;E.current=e instanceof HTMLElement?e:null,D.current=!0}O.current!==h.key&&(O.current=h.key,S.current?.focus());return}if(D.current){D.current=!1,O.current=``;let e=E.current;E.current=null,e&&e.isConnected&&e.focus()}},A);let j;t[4]===i?j=t[5]:(j=e=>{i(e)},t[4]=i,t[5]=j);let M=W(j),N=Te(),P=be(),F=we(),ee;t[6]===f?ee=t[7]:(ee=f(`mobile.tabs.activity.loading`),t[6]=f,t[7]=ee);let I=ee,L;t[8]!==N||t[9]!==P?(L=$s({unreadCount:N,working:P}),t[8]=N,t[9]=P,t[10]=L):L=t[10];let R=L,z;t[11]===F?z=t[12]:(z=$s({unreadCount:0,working:F}),t[11]=F,t[12]=z);let te=z,ne;t[13]!==R||t[14]!==N||t[15]!==I||t[16]!==te||t[17]!==f?(ne=Zs.map(e=>{let t=e.id===`assistant`&&R===`loading`||e.id===`scheduled`&&te===`loading`;return{id:e.id,label:f(e.labelKey),badge:e.id===`assistant`&&R===`unread`?N>99?`99+`:String(N):null,activity:t,activityLabel:t?I:null}}),t[13]=R,t[14]=N,t[15]=I,t[16]=te,t[17]=f,t[18]=ne):ne=t[18];let B=ne,V=u&&!d&&!h,H;t[19]===f?H=t[20]:(H=f(`mobile.nav.aria`),t[19]=f,t[20]=H);let U;t[21]!==M||t[22]!==V||t[23]!==B||t[24]!==p||t[25]!==H?(U={visible:V,activeTab:p,tabs:B,ariaLabel:H,onTabChange:M},t[21]=M,t[22]=V,t[23]=B,t[24]=p,t[25]=H,t[26]=U):U=t[26];let re=gc(U),ie=re===`native`,ae=u&&re===`web`,oe=lr(),se,G;t[27]!==oe||t[28]!==ie?(se=()=>{if(!oe){sr.shutdown();return}ie&&cr(!0)&&sr.warm()},G=[oe,ie],t[27]=oe,t[28]=ie,t[29]=se,t[30]=G):(se=t[29],G=t[30]),Z.useEffect(se,G);let q;t[31]===c?q=t[32]:(q=K(`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[31]=c,t[32]=q);let J=h?!0:void 0,le=h?!0:void 0,ue;t[33]!==p||t[34]!==u||t[35]!==ae||t[36]!==f||t[37]!==n||t[38]!==b?(ue=Zs.map(e=>{let t=b.has(e.id);return(0,$.jsx)(`section`,{id:`mobile-tabpanel-${e.id}`,role:`tabpanel`,"aria-labelledby":ae?`mobile-tab-${e.id}`:void 0,"aria-label":ae?void 0:f(e.labelKey),hidden:p!==e.id,tabIndex:0,className:K(`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)(bc,{tab:e.id,icon:e.icon}):null},e.id)}),t[33]=p,t[34]=u,t[35]=ae,t[36]=f,t[37]=n,t[38]=b,t[39]=ue):ue=t[39];let de;t[40]!==w||t[41]!==J||t[42]!==le||t[43]!==ue?(de=(0,$.jsx)(`div`,{ref:w,"data-mobile-navigation-underlay":`true`,"aria-hidden":J,inert:le,className:`flex h-full min-h-0 flex-1 flex-col`,children:ue}),t[40]=w,t[41]=J,t[42]=le,t[43]=ue,t[44]=de):de=t[44];let Y=u?(0,$.jsx)(`div`,{"data-mobile-navigation-dock-underlay":`true`,"aria-hidden":h||ie?!0:void 0,inert:h||ie?!0:void 0,children:ae?(0,$.jsx)(Qs,{activeTab:p,onTabChange:M,tabMarks:{assistant:R===`loading`?`loading`:null,scheduled:te===`loading`?`loading`:null}}):null}):null,fe=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:K(`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)}),pe;return t[45]!==q||t[46]!==de||t[47]!==Y||t[48]!==fe?(pe=(0,$.jsxs)(`div`,{className:q,children:[de,Y,fe]}),t[45]=q,t[46]=de,t[47]=Y,t[48]=fe,t[49]=pe):pe=t[49],pe}function bc(e){let t=(0,Q.c)(17),{tab:n,icon:r,className:i}=e,{t:a}=ce(),o,s,c,l;if(t[0]!==i||t[1]!==r||t[2]!==a||t[3]!==n){let e=Zs.find(e=>e.id===n)??Zs[0];t[8]===i?c=t[9]:(c=K(`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 xc={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)`}},Sc=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 Cc({project:e,expanded:t,embedded:n=!1,onToggle:r,onOpenActions:i,className:a,highlightQuery:o}){let{t:s}=ce(),[c,l]=Z.useState(!1),u=Z.useRef(null);u.current||=Hr({onPressedKeyChange:t=>l(t===e.id)}),Z.useEffect(()=>()=>u.current?.reset(),[]);let d=W(()=>{u.current?.consumeClick(e.id)||r(e)}),f=W(()=>i?.(e)),p=W(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=W(e=>{u.current?.move(e.pointerId,e.clientX,e.clientY)}),h=W(e=>{u.current?.end(e.pointerId)}),g=W(e=>{u.current?.cancel(e.pointerId)}),_=W(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=Sc(e.path),b=(0,$.jsxs)(`article`,{"data-mobile-press-surface":`soft`,"data-pressed":c?`true`:void 0,className:K(`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:K(`oc-mobile-project-icon oc-mobile-glass-control flex shrink-0 items-center justify-center rounded-full text-muted-foreground`),style:xc[e.tone??`neutral`],"aria-hidden":!0,children:(0,$.jsx)(X,{name:e.icon??`code-box`,className:`oc-mobile-project-icon-glyph`})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`oc-mobile-project-title oc-mobile-entity-title truncate font-semibold text-foreground`,children:o?Tn(e.name,o):e.name}),e.active?(0,$.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-[var(--status-success)] shadow-[0_0_0_3px_color-mix(in_srgb,var(--status-success)_12%,transparent)]`,"aria-label":s(`mobile.sessions.activeProjectAria`)}):null]}),(0,$.jsxs)(`span`,{className:`oc-mobile-project-meta oc-mobile-entity-meta flex min-w-0 items-center text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:v}),e.activityLabel?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`·`}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:e.activityLabel})]}):null,y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`·`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,title:e.path,children:y})]}):null]})]}),(0,$.jsx)(X,{name:`arrow-down-s`,className:K(`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)(q,{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)(Bi,{asChild:!0,children:b})}var wc=({hasPendingQuestion:e,hasPendingPermission:t,running:n,unread:r})=>e?`question`:t?`permission`:n?`running`:r?`completed-unread`:`idle`;function Tc(e){let t=(0,Q.c)(131),{session:n,depth:r,hasChildren:i,expanded:a,paginationContinues:o,onToggleChildren:s,onSelect:c,onPin:l,onArchive:u,onOpenActions:d,indicator:f,className:p,highlightQuery:m}=e,h=r===void 0?0:r,g=i!==void 0&&i,_=a!==void 0&&a,v=o!==void 0&&o,{t:y}=ce(),b=Z.useContext(Si),x;t[0]!==c||t[1]!==n?(x=()=>c(n),t[0]=c,t[1]=n,t[2]=x):x=t[2];let S=Bs(n.id,x,b),{offset:C,dragging:w,handleSelect:T,handlePointerDown:E,handlePointerMove:D,finishGesture:O,handlePointerCancel:k,handleContextMenu:A}=S,j;t[3]!==d||t[4]!==n?(j=()=>d(n),t[3]=d,t[4]=n,t[5]=j):j=t[5];let M=W(j),N;t[6]===s?N=t[7]:(N=()=>s?.(),t[6]=s,t[7]=N);let P=W(N),F;t[8]!==n.pinned||t[9]!==y?(F=n.pinned?y(`sessions.sidebar.session.menu.unpin`):y(`sessions.sidebar.session.menu.pin`),t[8]=n.pinned,t[9]=y,t[10]=F):F=t[10];let ee=F,I;t[11]!==f||t[12]!==n.unread?(I=f??wc({hasPendingQuestion:!1,hasPendingPermission:!1,running:!1,unread:!!n.unread}),t[11]=f,t[12]=n.unread,t[13]=I):I=t[13];let L=I,R;t[14]!==L||t[15]!==y?(R=L===`question`?y(`sessions.sidebar.session.status.questionRequired`):L===`permission`?y(`sessions.sidebar.session.status.permissionRequired`):L===`running`?y(`sessions.sidebar.session.status.active`):L===`completed-unread`?y(`sessions.sidebar.session.status.unread`):void 0,t[14]=L,t[15]=y,t[16]=R):R=t[16];let z=R;if(n.kind===`pagination`){let e=v&&`oc-mobile-session-pagination-continues`,r;t[17]!==p||t[18]!==e?(r=K(`oc-mobile-session-row`,e,p),t[17]=p,t[18]=e,t[19]=r):r=t[19];let i;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(i={touchAction:`pan-y`},t[20]=i):i=t[20];let a;t[21]===n.title?a=t[22]:(a=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left font-medium text-foreground typography-meta`,children:n.title}),t[21]=n.title,t[22]=a);let o;t[23]===n.subtitle?o=t[24]:(o=n.subtitle?(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:n.subtitle}):null,t[23]=n.subtitle,t[24]=o);let s;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground`}),t[25]=s):s=t[25];let c;t[26]!==T||t[27]!==a||t[28]!==o?(c=(0,$.jsxs)(`button`,{type:`button`,"data-mobile-press-feedback":`soft`,className:`oc-mobile-session-pagination-row`,style:i,onClick:T,onPointerDown:Ec,children:[a,o,s]}),t[26]=T,t[27]=a,t[28]=o,t[29]=c):c=t[29];let l;return t[30]!==r||t[31]!==c?(l=(0,$.jsx)(`div`,{className:r,children:c}),t[30]=r,t[31]=c,t[32]=l):l=t[32],l}let te;t[33]===p?te=t[34]:(te=K(`oc-mobile-session-row relative isolate`,p),t[33]=p,t[34]=te);let ne=n.pinned?`unpin`:`pushpin`,B;t[35]!==l||t[36]!==n?(B=()=>l(n),t[35]=l,t[36]=n,t[37]=B):B=t[37];let V;t[38]!==ee||t[39]!==ne||t[40]!==B?(V={label:ee,icon:ne,onClick:B},t[38]=ee,t[39]=ne,t[40]=B,t[41]=V):V=t[41];let H;t[42]===y?H=t[43]:(H=y(`sessions.sidebar.bulkActions.archive`),t[42]=y,t[43]=H);let U;t[44]!==u||t[45]!==n?(U=()=>u(n),t[44]=u,t[45]=n,t[46]=U):U=t[46];let re;t[47]!==H||t[48]!==U?(re={label:H,icon:`archive`,destructive:!0,onClick:U},t[47]=H,t[48]=U,t[49]=re):re=t[49];let ie;t[50]!==V||t[51]!==re?(ie=[V,re],t[50]=V,t[51]=re,t[52]=ie):ie=t[52];let ae;t[53]!==S||t[54]!==ie?(ae=(0,$.jsx)(Is,{swipe:S,actions:ie}),t[53]=S,t[54]=ie,t[55]=ae):ae=t[55];let oe=w?`transition-none`:`transition-[transform,background-color] duration-150`,se=n.archived&&`opacity-55`,G;t[56]!==oe||t[57]!==se?(G=K(`oc-mobile-session-row-content relative z-10 flex items-center`,`text-foreground`,`ease-out motion-reduce:transition-none`,oe,se),t[56]=oe,t[57]=se,t[58]=G):G=t[58];let J=w?`true`:void 0,le=`translate3d(${C}px, 0, 0)`,ue=C===0?void 0:`transform`,de;t[59]!==le||t[60]!==ue?(de={transform:le,willChange:ue},t[59]=le,t[60]=ue,t[61]=de):de=t[61];let Y;t[62]!==_||t[63]!==P||t[64]!==g||t[65]!==s||t[66]!==y?(Y=g&&s?(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:`min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":y(_?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),onClick:P,children:(0,$.jsx)(X,{name:`arrow-down-s`,className:K(`size-3.5 transition-transform duration-150 motion-reduce:transition-none`,_?`rotate-0`:`-rotate-90`)})}):null,t[62]=_,t[63]=P,t[64]=g,t[65]=s,t[66]=y,t[67]=Y):Y=t[67];let fe=16+Math.min(h,4)*12,pe;t[68]===fe?pe=t[69]:(pe={paddingLeft:fe,touchAction:`pan-y`},t[68]=fe,t[69]=pe);let me=!z||void 0,he;t[70]===L?he=t[71]:(he=L===`running`?(0,$.jsx)(Ni,{className:`motion-reduce:[&_svg]:animate-none`}):L===`question`?(0,$.jsx)(X,{name:`question`,className:`size-3.5 text-[var(--status-warning)]`}):L===`permission`?(0,$.jsx)(X,{name:`shield`,className:`size-3.5 text-destructive`}):(0,$.jsx)(`span`,{className:K(`oc-mobile-session-dot rounded-full`,L===`completed-unread`?`bg-[var(--status-info)]`:`bg-muted-foreground/35`)}),t[70]=L,t[71]=he);let ge;t[72]!==z||t[73]!==L||t[74]!==me||t[75]!==he?(ge=(0,$.jsx)(`span`,{className:`oc-mobile-session-status shrink-0`,"data-session-status":L,"aria-hidden":me,"aria-label":z,title:z,children:he}),t[72]=z,t[73]=L,t[74]=me,t[75]=he,t[76]=ge):ge=t[76];let _e=n.unread?`font-semibold`:`font-medium`,ve;t[77]===_e?ve=t[78]:(ve=K(`oc-mobile-session-title truncate`,_e),t[77]=_e,t[78]=ve);let ye;t[79]!==m||t[80]!==n.title?(ye=m?Tn(n.title,m):n.title,t[79]=m,t[80]=n.title,t[81]=ye):ye=t[81];let be;t[82]!==ve||t[83]!==ye?(be=(0,$.jsx)(`span`,{className:ve,children:ye}),t[82]=ve,t[83]=ye,t[84]=be):be=t[84];let xe;t[85]===n.changes?xe=t[86]:(xe=n.changes?(0,$.jsx)(`span`,{className:`oc-mobile-session-changes shrink-0 tabular-nums text-muted-foreground`,children:n.changes}):null,t[85]=n.changes,t[86]=xe);let Se;t[87]===n.archived?Se=t[88]:(Se=n.archived?(0,$.jsx)(X,{name:`archive`,className:`size-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}):null,t[87]=n.archived,t[88]=Se);let Ce;t[89]!==be||t[90]!==xe||t[91]!==Se?(Ce=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[be,xe,Se]}),t[89]=be,t[90]=xe,t[91]=Se,t[92]=Ce):Ce=t[92];let we;t[93]!==m||t[94]!==n.subtitle?(we=n.subtitle?(0,$.jsx)(`span`,{className:`oc-mobile-session-subtitle truncate text-muted-foreground`,children:m?Tn(n.subtitle,m):n.subtitle}):null,t[93]=m,t[94]=n.subtitle,t[95]=we):we=t[95];let Te;t[96]!==Ce||t[97]!==we?(Te=(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[Ce,we]}),t[96]=Ce,t[97]=we,t[98]=Te):Te=t[98];let Ee;t[99]===n.activityLabel?Ee=t[100]:(Ee=n.activityLabel?(0,$.jsx)(`span`,{className:`oc-mobile-session-time tabular-nums`,children:n.activityLabel}):null,t[99]=n.activityLabel,t[100]=Ee);let De;t[101]===Ee?De=t[102]:(De=(0,$.jsx)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-muted-foreground`,children:Ee}),t[101]=Ee,t[102]=De);let Oe;t[103]!==O||t[104]!==A||t[105]!==k||t[106]!==E||t[107]!==D||t[108]!==T||t[109]!==pe||t[110]!==ge||t[111]!==Te||t[112]!==De?(Oe=(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:pe,onClick:T,onPointerDown:E,onPointerMove:D,onPointerUp:O,onPointerCancel:k,onContextMenu:A,children:[ge,Te,De]}),t[103]=O,t[104]=A,t[105]=k,t[106]=E,t[107]=D,t[108]=T,t[109]=pe,t[110]=ge,t[111]=Te,t[112]=De,t[113]=Oe):Oe=t[113];let ke;t[114]===y?ke=t[115]:(ke=y(`sessions.sidebar.session.menu.label`),t[114]=y,t[115]=ke);let Ae;t[116]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=(0,$.jsx)(X,{name:`more-2`,className:`size-3.5`}),t[116]=Ae):Ae=t[116];let je;t[117]!==M||t[118]!==ke?(je=(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:`mr-1 min-h-9 min-w-9 shrink-0 rounded-full text-muted-foreground`,"aria-label":ke,"data-session-drag-ignore":!0,onClick:M,children:Ae}),t[117]=M,t[118]=ke,t[119]=je):je=t[119];let Me;t[120]!==G||t[121]!==J||t[122]!==de||t[123]!==Y||t[124]!==Oe||t[125]!==je?(Me=(0,$.jsxs)(`div`,{className:G,"data-dragging":J,style:de,children:[Y,Oe,je]}),t[120]=G,t[121]=J,t[122]=de,t[123]=Y,t[124]=Oe,t[125]=je,t[126]=Me):Me=t[126];let Ne;return t[127]!==te||t[128]!==ae||t[129]!==Me?(Ne=(0,$.jsxs)(`div`,{className:te,children:[ae,Me]}),t[127]=te,t[128]=ae,t[129]=Me,t[130]=Ne):Ne=t[130],Ne}function Ec(){}var Dc=Z.memo(Tc),Oc=10,kc=`oc:mobile-worktree-row-revealed`,Ac=e=>{window.dispatchEvent(new CustomEvent(kc,{detail:e}))};function jc(e){let t=(0,Q.c)(10),n=st(e.session.id),r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={bootstrap:!1},t[0]=r):r=t[0];let i=at(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=ct(e.session.id,e.session.directory,a).length>0,s=i.length>0,c=!!e.session.unread,l;t[2]!==n||t[3]!==o||t[4]!==s||t[5]!==c?(l=wc({hasPendingQuestion:o,hasPendingPermission:s,running:n,unread:c}),t[2]=n,t[3]=o,t[4]=s,t[5]=c,t[6]=l):l=t[6];let u=l,d;return t[7]!==u||t[8]!==e?(d=(0,$.jsx)(Dc,{...e,indicator:u}),t[7]=u,t[8]=e,t[9]=d):d=t[9],d}var Mc=Z.memo(jc);function Nc(e){let t=(0,Q.c)(25),{sessions:n,onSelectSession:r,onPinSession:i,onArchiveSession:a,onOpenSessionActions:o,highlightQuery:s,orderScope:c,onReorderSessions:l}=e,u;t[0]===n?u=t[1]:(u=n.filter(Lc).map(Ic),t[0]=n,t[1]=u);let d=u,f;t[2]===d?f=t[3]:(f=new Map(d.map(Fc)),t[2]=d,t[3]=f);let p=f,m=!!(c&&l&&!s&&d.length>1),h;t[4]!==l||t[5]!==c||t[6]!==d?(h=(e,t)=>{c&&l?.(c,d,e,t)},t[4]=l,t[5]=c,t[6]=d,t[7]=h):h=t[7];let g=W(h),_;t[8]!==s||t[9]!==a||t[10]!==o||t[11]!==i||t[12]!==r||t[13]!==n||t[14]!==m?(_=n.map((e,t)=>{let c=e.kind===`pagination`&&n[t+1]?.kind===`pagination`,l=e.kind===`pagination`?Dc:Mc,u=(0,$.jsx)(l,{session:e,paginationContinues:c,highlightQuery:s,onSelect:r,onPin:i,onArchive:a,onOpenActions:o},e.id);return m&&e.kind!==`pagination`?(0,$.jsx)(Di,{sessionId:e.id,sessionDirectory:e.directory??null,sessionTitle:e.title,children:u},e.id):u}),t[8]=s,t[9]=a,t[10]=o,t[11]=i,t[12]=r,t[13]=n,t[14]=m,t[15]=_):_=t[15];let v;t[16]===_?v=t[17]:(v=(0,$.jsx)($.Fragment,{children:_}),t[16]=_,t[17]=v);let y=v,b;return t[18]!==p||t[19]!==g||t[20]!==c||t[21]!==y||t[22]!==d||t[23]!==m?(b=m?(0,$.jsx)(ci,{scopeKey:c,sessionIds:d,folderIdBySessionId:p,onSessionDroppedOnFolder:Pc,onSessionsReordered:g,children:y}):y,t[18]=p,t[19]=g,t[20]=c,t[21]=y,t[22]=d,t[23]=m,t[24]=b):b=t[24],b}function Pc(){}function Fc(e){return[e,null]}function Ic(e){return e.id}function Lc(e){return e.kind!==`pagination`}var Rc=Z.memo(Nc);function zc({project:e,worktree:t,expanded:n,onToggle:r,onNewSession:i,onOpenActions:a,onDelete:o,highlightQuery:s}){let{t:c}=ce(),l=`${e.id}::${t.id}`,u=!!(i||o),d=!!a,f=Number(!!i)+Number(!!o),[p,m]=Z.useState(0),[h,g]=Z.useState(!1),[_,v]=Z.useState(!1),y=Z.useRef(null),b=Z.useRef(!1),x=Z.useRef(null),S=Z.useRef(null);S.current||=Hr({onPressedKeyChange:e=>g(e===l)}),Z.useEffect(()=>()=>S.current?.reset(),[]),Z.useEffect(()=>{let e=e=>{e.detail!==l&&m(0)};return window.addEventListener(kc,e),()=>window.removeEventListener(kc,e)},[l]),Z.useEffect(()=>{m(0)},[l]);let C=W(()=>m(0)),w=p!==0,T=W(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=W(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>Oc&&a>i){t.intent=`vertical`,y.current=null,S.current?.cancel(e.pointerId);return}if(i>Oc&&i>a){t.intent=`horizontal`,v(!0),b.current=!0,S.current?.cancel(e.pointerId);try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}Ac(l)}}if(t.intent!==`horizontal`)return;e.preventDefault();let i=Math.max(-t.actionWidth,Math.min(0,t.startOffset+n));m(i)}),D=W(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=W(e=>{let t=y.current;y.current=null,S.current?.cancel(e.pointerId),v(!1),m(t?.startOffset??0)}),k=W(()=>{if(!S.current?.consumeClick(l)){if(b.current){b.current=!1;return}if(p!==0){C();return}r()}}),A=W(n=>{d&&(n.preventDefault(),n.stopPropagation(),S.current?.openFromContextMenu(l,()=>{g(!1),a?.(e,t)}))}),j=W(()=>{C(),i?.(e,t)}),M=W(()=>{C(),o?.(e,t)}),N=W(()=>a?.(e,t)),P=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`oc-mobile-group-label-icon`,"aria-hidden":!0,children:(0,$.jsx)(X,{name:`git-branch`,className:`size-3.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left oc-mobile-entity-title font-semibold text-foreground`,children:s?Tn(t.name,s):t.name}),(0,$.jsx)(`span`,{className:`typography-small text-muted-foreground tabular-nums`,children:t.sessionCount===1?c(`mobile.sessions.project.sessionsSingle`):c(`mobile.sessions.project.sessionsPlural`,{count:t.sessionCount})}),(0,$.jsx)(X,{name:`arrow-down-s`,className:K(`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:K(`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)(q,{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)(q,{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:K(`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)(q,{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 Bc(e){let t=(0,Q.c)(90),{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,onReorderSessions:b}=e,x;t[0]===i?x=t[1]:(x=i===void 0?[]:i,t[0]=i,t[1]=x);let S=x,{t:C}=ce(),[w,T]=Z.useState(!0),[E,D]=Z.useState(!1),O=W(a),k=W(o),A;t[2]===s?A=t[3]:(A=()=>s?.(),t[2]=s,t[3]=A);let j=W(A),M;t[4]===c?M=t[5]:(M=()=>c?.(),t[4]=c,t[5]=M);let N=W(M),P;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>D(e),t[6]=P):P=t[6];let F=W(P),ee;t[7]===y?ee=t[8]:(ee=K(`relative isolate mx-auto flex w-full max-w-[26rem] flex-col gap-5`,y),t[7]=y,t[8]=ee);let I;t[9]===C?I=t[10]:(I=C(`mobile.sessions.section.projects`),t[9]=C,t[10]=I);let L;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(hi,{mobile:!0}),t[11]=L):L=t[11];let R;t[12]===C?R=t[13]:(R=C(`mobile.projects.menu.label`),t[12]=C,t[13]=R);let z=E?`rotate-45`:`rotate-0`,te;t[14]===z?te=t[15]:(te=K(`size-5 transition-transform duration-150 motion-reduce:transition-none`,z),t[14]=z,t[15]=te);let ne;t[16]===te?ne=t[17]:(ne=(0,$.jsx)(X,{name:`add`,className:te}),t[16]=te,t[17]=ne);let B;t[18]!==ne||t[19]!==R?(B=(0,$.jsx)(Mn,{asChild:!0,children:(0,$.jsx)(q,{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":R,children:ne})}),t[18]=ne,t[19]=R,t[20]=B):B=t[20];let V;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(X,{name:`chat-new`,className:`size-4`}),t[21]=V):V=t[21];let H;t[22]===C?H=t[23]:(H=C(`mobile.projects.menu.newChat`),t[22]=C,t[23]=H);let U;t[24]!==k||t[25]!==H?(U=(0,$.jsxs)(En,{className:`min-h-11`,onSelect:k,children:[V,H]}),t[24]=k,t[25]=H,t[26]=U):U=t[26];let re;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(X,{name:`folder`,className:`size-4`}),t[27]=re):re=t[27];let ie;t[28]===C?ie=t[29]:(ie=C(`mobile.projects.menu.newProject`),t[28]=C,t[29]=ie);let ae;t[30]!==O||t[31]!==ie?(ae=(0,$.jsxs)(En,{className:`min-h-11`,onSelect:O,children:[re,ie]}),t[30]=O,t[31]=ie,t[32]=ae):ae=t[32];let oe;t[33]!==j||t[34]!==s||t[35]!==C?(oe=s?(0,$.jsxs)(En,{className:`min-h-11`,onSelect:j,children:[(0,$.jsx)(X,{name:`scan-2`,className:`size-4`}),C(`mobile.projects.menu.scanQr`)]}):null,t[33]=j,t[34]=s,t[35]=C,t[36]=oe):oe=t[36];let se;t[37]!==N||t[38]!==c||t[39]!==C?(se=c?(0,$.jsxs)(En,{className:`min-h-11`,onSelect:N,children:[(0,$.jsx)(X,{name:`server`,className:`size-4`}),C(`mobile.projects.menu.switchInstance`)]}):null,t[37]=N,t[38]=c,t[39]=C,t[40]=se):se=t[40];let G;t[41]!==U||t[42]!==ae||t[43]!==oe||t[44]!==se?(G=(0,$.jsxs)(Dn,{align:`end`,side:`bottom`,className:`min-w-44`,children:[U,ae,oe,se]}),t[41]=U,t[42]=ae,t[43]=oe,t[44]=se,t[45]=G):G=t[45];let J;t[46]!==F||t[47]!==E||t[48]!==B||t[49]!==G?(J=(0,$.jsxs)($.Fragment,{children:[L,(0,$.jsxs)(jn,{open:E,onOpenChange:F,children:[B,G]})]}),t[46]=F,t[47]=E,t[48]=B,t[49]=G,t[50]=J):J=t[50];let le;t[51]!==J||t[52]!==I?(le=(0,$.jsx)(Pr,{title:I,trailing:J}),t[51]=J,t[52]=I,t[53]=le):le=t[53];let ue;t[54]!==S||t[55]!==_||t[56]!==v||t[57]!==g||t[58]!==b||t[59]!==h||t[60]!==w||t[61]!==r||t[62]!==C?(ue=r.length>0||S.length>0?(0,$.jsx)(Bi,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":C(`mobile.sessions.section.pinned`),children:[(0,$.jsx)(Cc,{project:{id:`__pinned__`,name:C(`mobile.sessions.section.pinned`),path:``,icon:`pushpin`,sessionCount:r.length+S.length},expanded:w,embedded:!0,onToggle:()=>T(Hc)}),w?(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)(Rc,{sessions:r,orderScope:ii,onReorderSessions:b,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null,S.length>0?(0,$.jsx)(`div`,{className:`oc-mobile-labeled-surface-group`,children:(0,$.jsx)(Rc,{sessions:S,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null]}):null]})}):null,t[54]=S,t[55]=_,t[56]=v,t[57]=g,t[58]=b,t[59]=h,t[60]=w,t[61]=r,t[62]=C,t[63]=ue):ue=t[63];let de;t[64]!==O||t[65]!==_||t[66]!==m||t[67]!==f||t[68]!==u||t[69]!==v||t[70]!==p||t[71]!==g||t[72]!==b||t[73]!==h||t[74]!==l||t[75]!==d||t[76]!==n||t[77]!==C?(de=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:C(`mobile.sessions.empty.noProjectsTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-xs typography-small text-muted-foreground`,children:C(`mobile.sessions.empty.noProjectsDescription`)}),(0,$.jsxs)(q,{type:`button`,size:`lg`,className:`mt-4 min-h-10 rounded-full px-5`,onClick:O,children:[(0,$.jsx)(X,{name:`folder-add`,className:`size-4`}),C(`sessions.sidebar.header.actions.addProject`)]})]}):n.map(e=>{let t=e.expanded,n=e.worktrees.find(Vc)??(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)(Bi,{asChild:!0,children:(0,$.jsxs)(`section`,{className:`oc-mobile-project-shell`,"aria-label":e.name,children:[(0,$.jsx)(Cc,{project:e,expanded:t,embedded:!0,onToggle:()=>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)(Rc,{sessions:i,orderScope:n?.path,onReorderSessions:b,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v})}):null,r.map(t=>{let n=!!t.expanded;return(0,$.jsx)(Ii,{className:`oc-mobile-worktree-group`,ariaLabel:t.name,label:(0,$.jsx)(zc,{project:e,worktree:t,expanded:n,onToggle:()=>d(e,t),onNewSession:f,onOpenActions:p,onDelete:m}),children:n&&t.sessions.length>0?(0,$.jsx)(Rc,{sessions:t.sessions,orderScope:t.path,onReorderSessions:b,onSelectSession:h,onPinSession:g,onArchiveSession:_,onOpenSessionActions:v}):null},t.id)})]}):null]})},e.id)}),t[64]=O,t[65]=_,t[66]=m,t[67]=f,t[68]=u,t[69]=v,t[70]=p,t[71]=g,t[72]=b,t[73]=h,t[74]=l,t[75]=d,t[76]=n,t[77]=C,t[78]=de):de=t[78];let Y;t[79]===C?Y=t[80]:(Y=C(`sessions.sidebar.header.actions.addProject`),t[79]=C,t[80]=Y);let fe;t[81]!==O||t[82]!==Y?(fe=(0,$.jsx)(`button`,{type:`button`,className:`sr-only`,onClick:O,children:Y}),t[81]=O,t[82]=Y,t[83]=fe):fe=t[83];let pe;return t[84]!==le||t[85]!==ue||t[86]!==de||t[87]!==fe||t[88]!==ee?(pe=(0,$.jsxs)(`main`,{className:ee,children:[le,ue,de,fe]}),t[84]=le,t[85]=ue,t[86]=de,t[87]=fe,t[88]=ee,t[89]=pe):pe=t[89],pe}function Vc(e){return e.kind===`main`}function Hc(e){return!e}function Uc(e){let t=(0,Q.c)(13),{icon:n,label:r,onClick:i,destructive:a,disabled:o,spinning:s}=e,c=a!==void 0&&a,l=o!==void 0&&o,u=s!==void 0&&s,d;t[0]===i?d=t[1]:(d=()=>{ke(`light`),i()},t[0]=i,t[1]=d);let f=W(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)(q,{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 Wc(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)(Uc,{icon:e.icon,label:Lr(e,t),onClick:n(e.onClick),destructive:e.destructive,disabled:e.disabled,spinning:e.spinning},e.id))},e.items[0]?.id))}function Gc(e){let t=(0,Q.c)(46),{open:n,target:r,actions:i,onOpenChange:a,refreshTranscriptDisabled:o,refreshTranscriptSpinning:s}=e,c=o!==void 0&&o,l=s!==void 0&&s,{t:u}=ce(),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=Jr({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=Rr({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=mi({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=Wc(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)(Un,{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 Kc(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 qc(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=Kc(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 Jc=`__show_more__:`,Yc=`__show_fewer__:`,Xc=e=>e.startsWith(Jc),Zc=e=>e.startsWith(Yc),Qc=e=>Xc(e)||Zc(e),$c=e=>{let t=Xc(e)?Jc:Zc(e)?Yc: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)}},el=e=>e.parentID??null,tl=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),nl=e=>{let t=e;return tl(t.directory??t.project?.worktree??null)},rl=(e,t)=>{if(t?.trim())return t.trim();let n=tl(e);if(!n)return``;let r=n.split(`/`).filter(Boolean);return r[r.length-1]||n},il=e=>{let t=e.time?.updated??e.time?.created,n=typeof t==`number`?t:Number(t);return Number.isFinite(n)&&n>0?n:0},al=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))},ol=e=>{let t=e.time?.archived;return typeof t==`number`&&t>0},sl=(e,t)=>e.worktrees.find(e=>tl(e.path)===t)??null,cl=(e,t)=>{let n=t?.trim();return n?`${e} · ${n}`:e},ll=(e,t)=>wi(e,{pinnedSessionIds:t,omitPinnedSessions:!1}).map(e=>e.session);function ul(){_i();let e=bt(e=>e.sessionOrderByScope),t=bt(e=>e.sessionOrderActivityByScope),{t:n}=ce(),r=Ae(),i=He(e=>e.activeSessions),a=He(e=>e.activePaginationByDirectory),o=lt(e=>e.projects),s=Le(e=>e.projectSortOrder),c=Z.useMemo(()=>fi(o,s),[o,s]),l=lt(e=>e.activeProjectId),u=T(e=>e.currentDirectory),d=it(e=>e.currentSessionId),f=it(e=>e.availableWorktreesByProject),p=Ee(e=>e.orderByProject),m=Fe(),h=ds(e=>e.projectExpanded),g=ds(e=>e.worktreeExpanded),_=Qe(e=>e.index.session.unseenCount),[v,y]=Z.useState(new Map),b=ni(),x=Z.useMemo(()=>ti(b,d),[d,b]),S=Z.useMemo(()=>c.map(e=>{let t=tl(e.path);return{id:e.id,label:rl(t,e.label),path:t,icon:e.icon,worktrees:et(p[e.id],f.get(t)??[])}}),[c,p,f]),C=Z.useMemo(()=>{let e=new Map(r.map(e=>[e.id,e])),t=i.map(t=>{let n=e.get(t.id);return n?Ve(n,t):t}),n=new Set(t.map(e=>e.id));for(let e of r)n.has(e.id)||t.push(e);return t},[i,r]),w=Z.useMemo(()=>jr(C,S.map(e=>({id:e.id,normalizedPath:e.path})),f,!1),[S,C,f]),E=Z.useMemo(()=>{let e=S.map(e=>({project:e,buckets:[],totalSessions:0,isActive:e.id===l,latestActivity:0})),t=new Map(e.map(e=>[e.project.id,e])),n=(e,t,n)=>{let r=tl(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||rl(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 C){let r=w.bySessionId.get(e.id);if(!r)continue;let i=t.get(r.projectId);if(!i)continue;let a=r.kind===`worktree`?sl(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)=>Ge(t)-Ge(e));let n=ll(e.sessions,m);t.totalSessions+=n.length;for(let n of e.sessions){let e=il(n);e>t.latestActivity&&(t.latestActivity=e)}}return e},[l,w,m,S,C]),D=Z.useMemo(()=>{let e=new Map;for(let t of C)e.set(t.id,t);return e},[C]),O=Z.useMemo(()=>{let e=new Map;for(let t of S)e.set(t.id,t);return e},[S]),k=Z.useRef([]),A=Z.useRef([]),j=Z.useRef(new Map),{pinnedSessions:M,inProgressSessions:N}=Z.useMemo(()=>{let t=new Map(S.map(e=>[e.id,e])),r=n(`mobile.sessions.untitled`),i=new Map(k.current.map(e=>[e.id,e])),a=new Map(A.current.map(e=>[e.id,e])),o=(e,n,i)=>{let a=w.bySessionId.get(e.id),o=a?t.get(a.projectId):void 0;if(!o)return[];let s=a?.kind===`worktree`?sl(o,a.scopeDirectory):null,c={id:e.id,directory:nl(e),title:e.title?.trim()||r,subtitle:cl(o.label,s?.branch),changes:Qn(Zn(e))??void 0,activityLabel:al(il(e))||void 0,unread:(_[e.id]??0)>0,pinned:n,archived:ol(e),active:d===e.id};return[Kc(i.get(e.id),c)]},s=bi(C,m,e[ii]).flatMap(e=>o(e,!0,i)),c=Ti(C,m,b,_).flatMap(e=>o(e,!1,a)),l=qc(k.current,s),u=qc(A.current,c);return k.current=l,A.current=u,{pinnedSessions:l,inProgressSessions:u}},[d,w,e,m,S,b,C,n,_]),P=Z.useMemo(()=>{let e=new Map;for(let t of E){let n=t.project.worktrees.length>0;for(let r of t.buckets){let i=ll(r.sessions,m).length;e.set(`${t.project.id}::${r.key}`,{path:r.path,rootCount:i,hasWorktrees:n})}}return e},[m,E]),F=Z.useMemo(()=>{let r=tl(u),i=new Map,o=e=>(e.kind!==`pagination`&&i.set(e.id,e),e),s=E.map(s=>{let c=h[s.project.id]??!0,l=pi(),u=s.project.icon?hn[s.project.icon]:void 0,f=s.buckets.map(c=>{let u=`${s.project.id}::${c.key}`,f=g[u]??!1,p=v.get(u)??l,h=tl(c.path),y=ll(c.sessions,m).map(e=>({session:e})),b=y.sort(Ur(y,e[h],t[h],m)).map(e=>e.session),S=wi(c.sessions,{pinnedSessionIds:m,omitPinnedSessions:!1}).map(e=>e.session),C=e=>{let t=el(e),r=(_[e.id]??0)>0&&!t,a={id:e.id,directory:c.path,title:e.title?.trim()||n(`mobile.sessions.untitled`),changes:Qn(Zn(e))??void 0,activityLabel:al(il(e))||void 0,unread:r,pinned:m.has(e.id),archived:ol(e),active:d===e.id},s=Kc(j.current.get(e.id)??i.get(e.id),a);return o(s)},w=Vr(b,p,x).map(C),T=b.length-w.length,E=a.get(tl(c.path)),D=E?.hasMore===!0,O=b.length>l&&p>l,k=[...w];O&&k.push({id:`${Yc}${s.project.id}::${c.key}`,kind:`pagination`,title:n(`sessions.sidebar.group.showFewer`)}),(T>0||D)&&k.push({id:`${Jc}${s.project.id}::${c.key}`,kind:`pagination`,title:n(`sessions.sidebar.group.showMore`),subtitle:E?.loadingMore?`…`:void 0});let A=tl(c.path),M=!!(s.isActive&&r&&A&&(r===A||r.startsWith(`${A}/`))),N=c.worktree==null;return{id:c.key,name:N?n(`mobile.sessions.mainWorkspace`):c.label,path:c.path,kind:N?`main`:`worktree`,active:M,expanded:N?!0:f,sessionCount:b.length,sessions:k,catalogSessions:S.map(C)}});return{id:s.project.id,name:s.project.label,path:s.project.path,icon:u,sessionCount:s.totalSessions,activityLabel:al(s.latestActivity)||void 0,active:s.isActive,expanded:c,worktrees:f}});return j.current=i,s},[a,x,u,d,m,h,e,t,E,n,_,v,g]),ee=e=>{for(let[t,n]of P)if(t.startsWith(`${e}::`))return n.hasWorktrees;return!1},I=(e,t)=>P.get(`${e}::${t}`)?.rootCount??0,L=e=>pi();return{projects:F,pinnedSessions:M,inProgressSessions:N,sessionById:D,projectMetaById:O,allSessions:C,projectHasWorktrees:ee,getBucketRootCount:I,getBucketVisibleCount:(e,t)=>{let n=`${e}::${t}`;return v.get(n)??L(e)},getBucketPageSize:L,getBucketDirectory:(e,t)=>P.get(`${e}::${t}`)?.path??null,showMoreBucketSessions:(e,t)=>{let n=`${e}::${t}`,r=P.get(n),i=pi(),a=Kr(),o=v.get(n)??i,s=r?.rootCount??0;if(y(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=tl(c);if(!l)return;let u=He.getState().activePaginationByDirectory.get(l);u?.hasMore&&!u.loadingMore&&je(l)},resetBucketVisibleCount:(e,t)=>{let n=`${e}::${t}`;y(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t})}}}var dl=(e,t,n)=>e?.kind===`project`&&e.project.id===t?{...e,isGitRepository:n}:e;function fl({onOpenChat:e,onAddProject:t,onNewSession:n,onScanQr:r,onSwitchInstance:i,className:a}){let{t:o}=ce(),{git:s}=ee(),c=yt(),l=ul(),u=W((e,t,n,r)=>{let i=bt.getState(),a=e===`__pinned__`?e:_(e);if(!a||a!==`__pinned__`&&i.getSessionFolderId(a,n)!==i.getSessionFolderId(a,r))return;let s=a===`__pinned__`?{}:Wr(l.allSessions.filter(e=>nl(e)===a));i.reorderSessions(a,t,n,r,s).catch(()=>We.error(o(`sessions.order.saveFailed`)))}),d=ds(e=>e.setProjectExpanded),f=ds(e=>e.setWorktreeExpanded),p=Re(),m=Fe(),h=it(e=>e.archiveSessions),g=it(e=>e.updateSessionTitle),v=it(e=>e.requestSessionSmartTitle),y=it(e=>e.shareSession),b=it(e=>e.unshareSession),x=it(e=>e.openNewSessionDraft),S=mt(e=>e.openDraft),C=mt(e=>e.openSession),w=lt(e=>e.projects),T=lt(e=>e.setActiveProjectIdOnly),E=lt(e=>e.removeProject),D=Jt(),[O,k]=Z.useState(null),[A,j]=Z.useState(!1),[M,N]=Z.useState(null),[P,F]=Z.useState(null),[I,L]=Z.useState(null),[R,z]=Z.useState(``),[te,ne]=Z.useState(!1),[B,V]=Z.useState(!1),[H,U]=Z.useState(null),[re,ie]=Z.useState(null),[ae,oe]=Z.useState(null),G=O?.kind===`session`?O.session.id:``,K=Ie(G),J=K?.type===`busy`||K?.type===`retry`,le=O?.kind===`session`?nl(O.session):``,ue=!!G&&ae===G,de=!le||ue||J,Y=W(e=>{let t=new Map;for(let e of l.allSessions){let n=el(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}),fe=W(()=>{j(!1),k(null)}),pe=W(t=>{if(Qc(t.id)){let e=$c(t.id);if(!e)return;e.kind===`more`?l.showMoreBucketSessions(e.projectId,e.bucketKey):l.resetBucketVisibleCount(e.projectId,e.bucketKey);return}let n=l.sessionById.get(t.id),r=n&&nl(n)||null;e({sessionId:t.id,directory:r})}),me=W(e=>{Qc(e.id)||p(e.id)}),he=W(async e=>{if(Qc(e.id))return;let t=Y(e.id),{archivedIds:n,failedIds:r}=await h(t);n.length>0&&Zr({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&&We.error(r.length===1?o(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):o(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}),ge=W(()=>{if(!O||O.kind!==`session`)return;let e=O.session,t=nl(e),n=K?.type??`idle`;!t||ae===e.id||n===`busy`||n===`retry`||(oe(e.id),(async()=>{try{await D.refreshSessionTranscript(e.id,{directory:t}),We.success(o(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{We.error(o(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{oe(t=>t===e.id?null:t)}})())}),_e=W(e=>{if(Qc(e.id))return;let t=l.sessionById.get(e.id);t&&(k({kind:`session`,session:t}),j(!0))}),ve=W(e=>{d(e.id,!e.expanded)}),ye=W((e,t)=>{f(`${e.id}::${t.id}`,!t.expanded)}),be=W((e,t)=>{T(e.id),S({selectedProjectId:e.id,directoryOverride:t,preserveDirectoryOverride:!0})}),xe=W(()=>{if(n){n();return}x()}),Se=W(e=>{let t=l.projectMetaById.get(e.id);t&&(k({kind:`project`,project:t,isGitRepository:!1}),j(!0),s.checkIsGitRepository(t.path).then(e=>{k(n=>dl(n,t.id,e))}).catch(()=>{k(e=>dl(e,t.id,!1))}))}),Ce=W((e,t)=>{let n=_(t);return n?e.worktrees.find(e=>_(e.path)===n)||((it.getState().availableWorktreesByProject.get(e.path)??[]).find(e=>_(e.path)===n)??null):null}),we=W((e,t)=>{let n=l.projectMetaById.get(e.id);n&&be(n,t.path)}),Te=W((e,t)=>{let n=l.projectMetaById.get(e.id);n&&(k({kind:`worktree`,project:n,worktreePath:t.path,worktreeName:t.name}),j(!0))}),Ee=W((e,t)=>{let n=l.projectMetaById.get(e.id);if(!n)return;let r=Ce(n,t.path);if(!r){We.error(o(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}ie({project:n,worktree:r})}),De=W(e=>{U(e),T(e),V(!0)}),Oe=W(e=>{(async()=>{let t=e.worktrees;try{t=(await _n({id:e.id,path:e.path})).worktrees}catch(n){console.warn(`[MobileProjectsHome] Worktree refresh before session sync failed:`,n),t=it.getState().availableWorktreesByProject.get(e.path)??e.worktrees}await Be([e.path,...t.map(e=>e.path)],l.allSessions)})()}),ke=W((e,t)=>{let n=H;if(V(!1),U(null),t?.sessionId){C({sessionId:t.sessionId,directory:e});return}S({selectedProjectId:n,directoryOverride:e,preserveDirectoryOverride:!0})}),Ae=W(async e=>{try{if(!(await y(e.id))?.share?.url){We.error(o(`sessions.sidebar.session.share.error`));return}We.success(o(`sessions.sidebar.session.share.successTitle`),{description:o(`sessions.sidebar.session.share.successDescription`)})}catch{We.error(o(`sessions.sidebar.session.share.error`))}}),je=W(async e=>{if((await se(e)).ok){We.success(o(`sessions.sidebar.session.menu.copied`));return}We.error(o(`sessions.sidebar.session.share.copyUrlError`))}),Me=W(async e=>{try{if(await b(e)){We.success(o(`sessions.sidebar.session.unshare.success`));return}We.error(o(`sessions.sidebar.session.unshare.error`))}catch{We.error(o(`sessions.sidebar.session.unshare.error`))}}),Ne=W(e=>{let t=Y(e.id);Gr({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=W(async()=>{if(!I)return;let e=R.trim();if(e)try{await g(I.id,e),L(null),z(``)}catch{We.error(o(`sessions.sidebar.session.menu.rename`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}}),Le=W(async()=>{if(!I||te)return;let e=I.id;L(null),z(``),ne(!0);try{await v(e)}catch{We.error(o(`sessions.sidebar.session.rename.smartTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}finally{ne(!1)}}),ze=Z.useMemo(()=>O?O.kind===`session`?{kind:`session`,title:O.session.title?.trim()||o(`mobile.sessions.untitled`),pinned:m.has(O.session.id),shared:!!O.session.share?.url}:O.kind===`project`?{kind:`project`,title:O.project.label,gitRepository:O.isGitRepository}:{kind:`worktree`,title:O.worktreeName}:null,[O,m,o]),Ve=Z.useMemo(()=>{if(!O)return{};if(O.kind===`session`){let e=O.session;return{onRename:()=>{z(e.title?.trim()||o(`mobile.sessions.untitled`)),L(e)},onTogglePin:()=>p(e.id),onShare:c&&!e.share?.url?()=>{Ae(e)}:void 0,onCopyLink:c&&e.share?.url?()=>{je(e.share.url)}:void 0,onUnshare:c&&e.share?.url?()=>{Me(e.id)}:void 0,onRefreshTranscript:ge,onArchive:()=>{he({id:e.id,title:e.title?.trim()||o(`mobile.sessions.untitled`)})},onDelete:()=>Ne(e)}}if(O.kind===`project`){let e=O.project;return{onNewSession:()=>be(e,e.path),onNewWorktree:()=>De(e.id),onSyncSessions:()=>Oe(e),onEditProject:()=>N(e.id),onCloseProject:()=>F(e)}}let{project:e,worktreePath:t}=O;return{onNewSession:()=>be(e,t),onDeleteWorktree:()=>{let n=Ce(e,t);if(!n){We.error(o(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:o(`sessions.sidebar.dialogs.deleteResult.tryAgain`)});return}ie({project:e,worktree:n})}}},[O,he,je,Ne,ge,De,Oe,Ae,Me,Ce,c,be,o,p]),He=Z.useMemo(()=>{if(!M)return null;let e=w.find(e=>e.id===M),t=l.projectMetaById.get(M);if(!e||!t)return null;let n=O?.kind===`project`&&O.project.id===M?O.isGitRepository:t.worktrees.length>0;return{id:e.id,label:e.label?.trim()||t.label,path:_(e.path)||t.path,icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:n,worktrees:t.worktrees}},[O,M,l.projectMetaById,w]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Bc,{className:a,projects:l.projects,pinnedSessions:l.pinnedSessions,inProgressSessions:l.inProgressSessions,onAddProject:t,onNewSession:xe,onScanQr:r,onSwitchInstance:i,onToggleProject:ve,onOpenProjectActions:Se,onToggleWorktree:ye,onNewWorktreeSession:we,onOpenWorktreeActions:Te,onDeleteWorktree:Ee,onSelectSession:pe,onPinSession:me,onArchiveSession:e=>{he(e)},onOpenSessionActions:_e,onReorderSessions:u}),(0,$.jsx)(Gc,{open:A,target:ze,actions:Ve,refreshTranscriptDisabled:de,refreshTranscriptSpinning:ue,onOpenChange:e=>{e?j(!0):fe()}}),(0,$.jsx)(jt,{open:B,projectId:H,onOpenChange:e=>{V(e),e||U(null)},onWorktreeCreated:ke}),re?(0,$.jsx)(Br,{open:!0,project:{id:re.project.id,path:re.project.path},worktree:re.worktree,onClose:()=>ie(null)}):null,(0,$.jsx)(An,{open:!!P,title:o(`sessions.sidebar.project.actions.closeProject`),onClose:()=>F(null),closeAriaLabel:o(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>F(null),children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(q,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!P)return;let e=P;F(null),E(e.id),We.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:P?.label??``})})}),(0,$.jsx)(An,{open:!!I,title:o(`sessions.sidebar.session.menu.rename`),onClose:()=>{te||(L(null),z(``))},closeAriaLabel:o(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:te,onClick:()=>{L(null),z(``)},children:o(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(q,{type:`button`,variant:`default`,className:`flex-1`,disabled:!R.trim()||te,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)(vn,{value:R,onChange:e=>z(e.target.value),autoFocus:!0,className:`h-12`,disabled:te}),(0,$.jsxs)(q,{type:`button`,variant:`outline`,className:`w-full gap-2`,disabled:te,onClick:()=>void Le(),children:[te?(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)(Yr,{open:M!==null,project:He,onClose:()=>N(null)})]})}function pl(e){let t=(0,Q.c)(10),{children:n,content:r,className:i,contentClassName:a,showHeader:o}=e,s=o===void 0||o,{t:c}=ce(),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=K(`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)(Ui,{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 ml(e){let t=(0,Q.c)(10),{className:n,contentClassName:r,instancesPage:i}=e,{t:a}=ce(),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=[...Yi],t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,$.jsx)(qi,{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)(Ui,{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 hl(e){let t=(0,Q.c)(110),{onAddProject:n,onScanQr:r,onSwitchInstance:i,onEnableAssistants:a,instancesPage:o,instancesSecondaryPage:s,parentSessionTarget:c,registerSecondaryBackHandler:l,scheduledContent:u,renderChat:d,className:f}=e,p=c===void 0?null:c,{t:m}=ce(),h=M(Pl),g=mt(),v=mt(Nl),y=mt(Ml),b=mt(jl),x=mt(Al),S=mt(kl),C=mt(Ol),w=mt(Dl),T=mt(El),E=mt(Tl),D=mt(wl),O=mt(Cl),k=mt(Sl),A;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(A=[],t[0]=A):A=t[0],Z.useEffect(xl,A);let j=g.secondary?.kind===`chat`?g.secondary.btw??null:null,N=Z.useRef(null),P,F;t[1]===j?(P=t[2],F=t[3]):(P=()=>{let e=N.current;N.current=j,e&&e!==j&&Wt.getState().clear({sessionId:e.sessionId,directory:e.directory}),j?Rt(rn):Xt(rn)},F=[j],t[1]=j,t[2]=P,t[3]=F),Z.useEffect(P,F);let ee;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(ee=[],t[4]=ee):ee=t[4],Z.useEffect(yl,ee);let I;t[5]===v?I=t[6]:(I=e=>{e===`settings`&&M.getState().setSettingsPage(`home`),v(e)},t[5]=v,t[6]=I);let L=W(I),R;t[7]===y?R=t[8]:(R=e=>{y(e)},t[7]=y,t[8]=R);let z=W(R),te;t[9]===w?te=t[10]:(te=()=>{w()},t[9]=w,t[10]=te);let ne=W(te),B;t[11]===b?B=t[12]:(B=()=>{b()},t[11]=b,t[12]=B);let V=W(B),H;t[13]===x?H=t[14]:(H=e=>{x(e)},t[13]=x,t[14]=H);let U=W(H),re=Z.useRef(null),[ie,ae]=Z.useState(!1),oe;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(oe=e=>{re.current=e},t[15]=oe):oe=t[15];let se=W(oe),G;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(G=e=>{ae(e)},t[16]=G):G=t[16];let K=W(G),q;t[17]!==ne||t[18]!==C||t[19]!==k||t[20]!==T?(q=()=>{if(re.current?.())return!0;let e=mt.getState().secondary;return e?.kind===`chat`&&e.btw?(k(),!0):e?.kind===`assistant`&&e.settingsAssistantID?(C(),!0):e?.kind===`chat`&&e.routes.length>1?(T(),!0):e?(ne(),!0):!1},t[17]=ne,t[18]=C,t[19]=k,t[20]=T,t[21]=q):q=t[21];let J=W(q),le=g.secondary!==null,ue;t[22]!==J||t[23]!==l?(ue=()=>{if(l)return l(()=>J()),()=>l(null)},t[22]=J,t[23]=l,t[24]=ue):ue=t[24];let de;t[25]!==J||t[26]!==l||t[27]!==le?(de=[l,le,J],t[25]=J,t[26]=l,t[27]=le,t[28]=de):de=t[28],Z.useEffect(ue,de);let Y=it(vl),fe;t[29]===Y?fe=t[30]:(fe=e=>Y?e.getDirectoryForSession(Y):null,t[29]=Y,t[30]=fe);let pe=it(fe),me,he;t[31]!==pe||t[32]!==Y||t[33]!==D||t[34]!==O?(me=()=>{let e=mt.getState().secondary;if(e?.kind===`draft`&&Y){D({sessionId:Y,directory:pe});return}if(e?.kind!==`chat`||!Y||gt({sessionId:Y,directory:pe})===`internal`)return;let t=e.routes.at(-1);(t?.sessionId!==Y||_(t.directory)!==_(pe))&&O({sessionId:Y,directory:pe})},he=[pe,Y,D,O],t[31]=pe,t[32]=Y,t[33]=D,t[34]=O,t[35]=me,t[36]=he):(me=t[35],he=t[36]),Z.useEffect(me,he);let ge,_e;t[37]!==Y||t[38]!==p||t[39]!==E?(ge=()=>{let e=mt.getState().secondary;if(e?.kind!==`chat`||!p)return;let t=e.routes.at(-1);!t||t.sessionId!==Y||E({sessionId:p.id,directory:p.directory})},_e=[Y,p,E],t[37]=Y,t[38]=p,t[39]=E,t[40]=ge,t[41]=_e):(ge=t[40],_e=t[41]),Z.useEffect(ge,_e);let ve;t[42]!==K||t[43]!==se||t[44]!==u?(ve=typeof u==`function`?u(se,K):u,t[42]=K,t[43]=se,t[44]=u,t[45]=ve):ve=t[45];let ye=ve,be;t[46]!==V||t[47]!==n||t[48]!==r||t[49]!==i||t[50]!==z?(be=(0,$.jsx)(fl,{onOpenChat:z,onAddProject:n,onNewSession:V,onScanQr:r,onSwitchInstance:i}),t[46]=V,t[47]=n,t[48]=r,t[49]=i,t[50]=z,t[51]=be):be=t[51];let xe;t[52]!==a||t[53]!==U?(xe=(0,$.jsx)(Ks,{onEnable:a,onOpenAssistant:U}),t[52]=a,t[53]=U,t[54]=xe):xe=t[54];let Se;t[55]===ye?Se=t[56]:(Se=(0,$.jsx)(pl,{showHeader:!1,children:ye}),t[55]=ye,t[56]=Se);let Ce;t[57]===o?Ce=t[58]:(Ce=(0,$.jsx)(ml,{instancesPage:o}),t[57]=o,t[58]=Ce);let we;t[59]!==be||t[60]!==xe||t[61]!==Se||t[62]!==Ce?(we={projects:be,assistant:xe,scheduled:Se,settings:Ce},t[59]=be,t[60]=xe,t[61]=Se,t[62]=Ce,t[63]=we):we=t[63];let Te=we,Ee=g.secondary?.kind??null,De;bb0:{if(!Ee){De=null;break bb0}if(Ee===`assistant`){let e=g.secondary?.kind===`assistant`?g.secondary.settingsAssistantID:void 0,n;t[64]===m?n=t[65]:(n=m(`assistants.title`),t[64]=m,t[65]=n);let r=!e,i;t[66]!==S||t[67]!==r?(i=(0,$.jsx)(oa,{activeOverride:r,onMobileBack:_l,onMobileOpenSettings:S}),t[66]=S,t[67]=r,t[68]=i):i=t[68];let a;t[69]!==J||t[70]!==n||t[71]!==i?(a={key:`assistant-secondary`,depth:1,ariaLabel:n,onBack:J,content:i},t[69]=J,t[70]=n,t[71]=i,t[72]=a):a=t[72];let o;t[73]!==J||t[74]!==e||t[75]!==m?(o=e?[{key:`assistant-settings:${e}`,depth:2,ariaLabel:m(`assistants.conversation.openSettings`),onBack:J,content:(0,$.jsx)(Js,{assistantID:e,onBack:gl})}]:[],t[73]=J,t[74]=e,t[75]=m,t[76]=o):o=t[76];let s;t[77]!==a||t[78]!==o?(s=[a,...o],t[77]=a,t[78]=o,t[79]=s):s=t[79],De=s;break bb0}if(Ee===`instances`){let e;t[80]===m?e=t[81]:(e=m(`mobile.settings.switchInstance`),t[80]=m,t[81]=e);let n;t[82]!==J||t[83]!==s||t[84]!==e?(n=[{key:`instances-secondary`,depth:1,ariaLabel:e,onBack:J,content:s}],t[82]=J,t[83]=s,t[84]=e,t[85]=n):n=t[85],De=n;break bb0}if(g.secondary?.kind===`draft`){let e;t[86]===m?e=t[87]:(e=m(`mobile.nav.secondaryPageAria`),t[86]=m,t[87]=e);let n;t[88]===d?n=t[89]:(n=d({sessionId:``,directory:null,viewKey:`chat-primary`,active:!0}),t[88]=d,t[89]=n);let r;t[90]!==J||t[91]!==e||t[92]!==n?(r=[{key:`chat-primary`,depth:1,ariaLabel:e,onBack:J,content:n}],t[90]=J,t[91]=e,t[92]=n,t[93]=r):r=t[93],De=r;break bb0}if(g.secondary?.kind!==`chat`){let e;t[94]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[94]=e):e=t[94],De=e;break bb0}let e=g.secondary.routes,n=g.secondary.btw,r;if(t[95]!==n||t[96]!==J||t[97]!==d||t[98]!==e||t[99]!==m){let i=e.slice(n?-1:-2),a=e.length-i.length+1,o=i.map((e,t)=>{let r=!n&&t===i.length-1;return{key:e.key,depth:a+t,ariaLabel:m(`mobile.nav.secondaryPageAria`),onBack:J,content:d({sessionId:e.sessionId,directory:e.directory,viewKey:e.key,active:r})}});r=n?[...o,{key:`chat-btw`,depth:e.length+1,ariaLabel:m(`chat.btw.title`),onBack:J,content:(0,$.jsx)(Ys,{route:n})}]:o,t[95]=n,t[96]=J,t[97]=d,t[98]=e,t[99]=m,t[100]=r}else r=t[100];De=r}let Oe=De,ke;t[101]===Oe?ke=t[102]:(ke=Oe??[],t[101]=Oe,t[102]=ke);let Ae=ie||h,je;return t[103]!==f||t[104]!==g||t[105]!==L||t[106]!==ke||t[107]!==Ae||t[108]!==Te?(je=(0,$.jsx)(yc,{className:f,navigation:g,onTabChange:L,tabs:Te,secondaryPages:ke,tabBarCovered:Ae}),t[103]=f,t[104]=g,t[105]=L,t[106]=ke,t[107]=Ae,t[108]=Te,t[109]=je):je=t[109],je}function gl(){Qi.requestAnimatedBack(`root`)}function _l(){return Qi.requestAnimatedBack(`root`)}function vl(e){return e.currentSessionId}function yl(){return bl}function bl(){return Xt(rn)}function xl(){return tt()}function Sl(e){return e.popBtw}function Cl(e){return e.replaceChatSession}function wl(e){return e.materializeDraftSession}function Tl(e){return e.reconcileChatPredecessor}function El(e){return e.popChatSession}function Dl(e){return e.closeSecondary}function Ol(e){return e.popAssistantSettings}function kl(e){return e.pushAssistantSettings}function Al(e){return e.openAssistant}function jl(e){return e.openDraft}function Ml(e){return e.openSession}function Nl(e){return e.setActiveTab}function Pl(e){return e.isCommandPaletteOpen}function Fl(e){let t=(0,Q.c)(30),{percentage:n,pending:r}=e,i=r!==void 0&&r,{t:a}=ce(),o,s,c,l,u,d,f,p,m;if(t[0]!==i||t[1]!==n||t[2]!==a){c=i?0:kn(n)??0;let e=Sn(n);s=i?`var(--surface-muted-foreground)`:e===`critical`?`var(--status-error)`:e===`warn`?`var(--status-warning)`:`var(--status-success)`,o=2*Math.PI*7.5,l=`0 0 18 18`,u=`size-[18px] -rotate-90`,d=`progressbar`,t[12]===a?f=t[13]:(f=a(`contextUsage.aria.label`),t[12]=a,t[13]=f),t[14]!==i||t[15]!==a?(p=i?a(`contextUsage.pending`):void 0,t[14]=i,t[15]=a,t[16]=p):p=t[16],m=i?void 0:Math.round(c),t[0]=i,t[1]=n,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m}else o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11];let h;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:3}),t[17]=h):h=t[17];let g=o*(1-c/100),_;t[18]!==o||t[19]!==s||t[20]!==g?(_=(0,$.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:s,strokeWidth:3,strokeLinecap:`round`,strokeDasharray:o,strokeDashoffset:g,className:`transition-[stroke-dashoffset,stroke] duration-300`}),t[18]=o,t[19]=s,t[20]=g,t[21]=_):_=t[21];let v;return t[22]!==_||t[23]!==l||t[24]!==u||t[25]!==d||t[26]!==f||t[27]!==p||t[28]!==m?(v=(0,$.jsxs)(`svg`,{viewBox:l,className:u,role:d,"aria-label":f,"aria-valuetext":p,"aria-valuenow":m,"aria-valuemin":0,"aria-valuemax":100,children:[h,_]}),t[22]=_,t[23]=l,t[24]=u,t[25]=d,t[26]=f,t[27]=p,t[28]=m,t[29]=v):v=t[29],v}function Il(e){let t=(0,Q.c)(16),{title:n,subtitle:r,onBack:i,onOpenMenu:a,menuOpen:o,elevated:s,trailing:c}=e,l=o!==void 0&&o,u=s!==void 0&&s,{t:d}=ce(),f=W(i),p=W(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)(Ce,{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 Ll=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},Rl=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),zl=e=>e>=90?`text-[var(--status-error)]`:e>=75?`text-[var(--status-warning)]`:`text-[var(--status-success)]`,Bl=e=>{let{totalTokens:t,contextLimit:n,isDraft:r}=e;if(!r&&t===null)return{pending:!0,percentage:0,tokens:`—`,colorClass:`text-muted-foreground`};if(t===null||r||t<=0||n<=0)return null;let i=Math.min(t/n*100,999);return{percentage:i,tokens:`${Rl(t)}/${Rl(n)}`,colorClass:zl(i)}},Vl=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},Hl=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),Ul=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`},Wl=e=>{let t=(0,Q.c)(13),{iconNode:n,iconName:r,label:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o=n??(r?(0,$.jsx)(X,{name:r,className:`size-[18px]`}):null),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s;t[3]===o?s=t[4]:(s=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:o}),t[3]=o,t[4]=s);let c;t[5]===i?c=t[6]:(c=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:i}),t[5]=i,t[6]=c);let l;t[7]===a?l=t[8]:(l=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground`,children:a}),t[7]=a,t[8]=l);let u;return t[9]!==s||t[10]!==c||t[11]!==l?(u=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5`,children:[s,c,l]}),t[9]=s,t[10]=c,t[11]=l,t[12]=u):u=t[12],u},Gl=e=>{let t=(0,Q.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=ce(),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)(fn,{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:`min-w-0 max-w-[60%] 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=On(e.window.valueLabel,t),i=bn(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:`min-w-0 truncate typography-micro text-muted-foreground/70`,children:i}):null]}),(0,$.jsx)(`span`,{className:K(`min-w-0 max-w-[60%] shrink-0 truncate typography-ui-label font-semibold tabular-nums`,Ul(e.window)),children:n===`-`?``:n})]},e.key)})}):null,e.status&&e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 truncate typography-micro text-muted-foreground`,title:e.status,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},Kl=e=>{let t=(0,Q.c)(47),{open:n,onClose:r,contextDisplay:i,branchLabel:a,usageGroups:o,usageDisplayMode:s,isUsageLoading:c,timeFormatPreference:l}=e,{t:u}=ce(),d=Z.useRef(null),[f,p]=Z.useState(n),[m,h]=Z.useState(!1),g,_;t[0]!==n||t[1]!==f?(g=()=>{if(n){p(!0),h(!1);return}if(!f)return;h(!0);let e=window.setTimeout(()=>{p(!1),h(!1)},140);return()=>window.clearTimeout(e)},_=[n,f],t[0]=n,t[1]=f,t[2]=g,t[3]=_):(g=t[2],_=t[3]),Z.useEffect(g,_);let v,y;if(t[4]!==r||t[5]!==n?(v=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},y=[r,n],t[4]=r,t[5]=n,t[6]=v,t[7]=y):(v=t[6],y=t[7]),Z.useEffect(v,y),!f)return null;let b;t[8]===u?b=t[9]:(b=u(`mobile.surface.closeAria`),t[8]=u,t[9]=b);let x;t[10]===r?x=t[11]:(x=e=>{e.preventDefault(),r()},t[10]=r,t[11]=x);let S;t[12]!==b||t[13]!==x?(S=(0,$.jsx)(`button`,{type:`button`,className:`pointer-events-auto absolute inset-x-0 bottom-0 cursor-default top-[calc(var(--oc-safe-area-top,0px)+var(--oc-mobile-detail-navigation-height,3.5rem)+0.25rem)]`,"aria-label":b,onPointerDown:x}),t[12]=b,t[13]=x,t[14]=S):S=t[14];let C;t[15]===u?C=t[16]:(C=u(`mobile.header.openMetadataAria`),t[15]=u,t[16]=C);let w=m&&`pointer-events-none`,T;t[17]===w?T=t[18]:(T=K(`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-x-hidden 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)(Wl,{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)(Wl,{iconNode:(0,$.jsx)(Fl,{percentage:i.percentage,pending:i.pending}),label:u(`mobile.header.metadata.context`),children:(0,$.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5 tabular-nums`,children:[(0,$.jsx)(`span`,{className:K(`font-semibold`,i.colorClass),children:i.pending?u(`contextUsage.pending`):`${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)(Gl,{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:fu,children:M}),t[38]=T,t[39]=D,t[40]=M,t[41]=C,t[42]=N):N=t[42];let P;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(`style`,{children:`
6
- @keyframes session-metadata-in {
7
- from { opacity: 0; transform: translateY(-8px) scale(0.985); }
8
- to { opacity: 1; transform: translateY(0) scale(1); }
9
- }
10
- @keyframes session-metadata-out {
11
- from { opacity: 1; transform: translateY(0) scale(1); }
12
- to { opacity: 0; transform: translateY(-6px) scale(0.985); }
13
- }
14
- `}),t[43]=P):P=t[43];let F;return t[44]!==N||t[45]!==S?(F=(0,$.jsxs)(`div`,{className:`fixed inset-0 z-40 pointer-events-none`,children:[S,N,P]}),t[44]=N,t[45]=S,t[46]=F):F=t[46],F};function ql(e){let t=(0,Q.c)(97),{sessionId:n,open:r,onOpenChange:i}=e,{t:a}=ce(),{git:o}=ee(),[s,c]=Z.useState(!1),l=r!==void 0,u=l?r:s,d=n.length===0,f;t[0]!==l||t[1]!==i||t[2]!==u?(f=e=>{let t=typeof e==`function`?e(u):e;l||c(t),i?.(t)},t[0]=l,t[1]=i,t[2]=u,t[3]=f):f=t[3];let p=W(f),m=T(du),h;t[4]===n?h=t[5]:(h=e=>n?e.getDirectoryForSession(n):null,t[4]=n,t[5]=h);let g=it(h)||m,_;t[6]===g?_=t[7]:(_=Hl(g)||null,t[6]=g,t[7]=_);let v=_,y=rt(n,g||void 0),b=er(v),x=rr(v),S=ir(uu),C=ir(lu),w=vt(cu),E=vt(su),D=vt(ou),O=vt(au),k;t[8]===n?k=t[9]:(k=e=>n?e.sessionModelSelections.get(n)??null:null,t[8]=n,t[9]=k);let A=De(k),j=Ar(iu),N=Ar(ru),P=Ar(nu),F=Ar(tu),I=Ar(eu),L=Ar($l),R=Ar(Ql),z=M(Zl);kr();let te;t[10]===p?te=t[11]:(te=()=>{p(!1)},t[10]=p,t[11]=te);let ne;t[12]!==g||t[13]!==n?(ne=[n,g],t[12]=g,t[13]=n,t[14]=ne):ne=t[14],Z.useEffect(te,ne);let B,V;t[15]!==S||t[16]!==o||t[17]!==v?(B=()=>{v&&S(v,o)},V=[S,o,v],t[15]=S,t[16]=o,t[17]=v,t[18]=B,t[19]=V):(B=t[18],V=t[19]),Z.useEffect(B,V);let H,U;t[20]!==C||t[21]!==o||t[22]!==v?(U=()=>{if(v)return nt.onGitRefreshHint(e=>{Hl(e.directory)===v&&C(v,o)})},H=[C,o,v],t[20]=C,t[21]=o,t[22]=v,t[23]=H,t[24]=U):(H=t[23],U=t[24]),Z.useEffect(U,H);let re,ie;t[25]===N?(re=t[26],ie=t[27]):(re=()=>{N()},ie=[N],t[25]=N,t[26]=re,t[27]=ie),Z.useEffect(re,ie);let ae,oe;t[28]===L?(ae=t[29],oe=t[30]):(ae=()=>{dn(L)},oe=[L],t[28]=L,t[29]=ae,t[30]=oe),Z.useEffect(ae,oe);let se,G;t[31]!==L||t[32]!==P||t[33]!==F||t[34]!==u||t[35]!==j?(se=()=>{!u||F||L.some(e=>!j.some(t=>t?.providerId===e))&&P()},G=[L,P,F,u,j],t[31]=L,t[32]=P,t[33]=F,t[34]=u,t[35]=j,t[36]=se,t[37]=G):(se=t[36],G=t[37]),Z.useEffect(se,G);let K;t[38]===y?K=t[39]:(K=Vl(y),t[38]=y,t[39]=K);let J=K,le;t[40]!==D||t[41]!==E||t[42]!==J||t[43]!==A?(le=J??(A?{providerID:A.providerId,modelID:A.modelId}:null)??(E&&D?{providerID:E,modelID:D}:null),t[40]=D,t[41]=E,t[42]=J,t[43]=A,t[44]=le):le=t[44];let ue=le,de;if(t[45]!==O||t[46]!==ue||t[47]!==w){let e=(ue?w.find(e=>e.id===ue.providerID):void 0)?.models.find(e=>e.id===ue?.modelID),n;t[49]!==O||t[50]!==ue?(n=ue?O(ue.providerID,ue.modelID):void 0,t[49]=O,t[50]=ue,t[51]=n):n=t[51];let r=n;de=Ll(e?.limit,`context`)??r?.limit?.context??0,t[45]=O,t[46]=ue,t[47]=w,t[48]=de}else de=t[48];let Y=de,fe=_t(n,Y,0,g||void 0),pe=fe?.pending?null:fe?.totalTokens??0,me;t[52]!==Y||t[53]!==d||t[54]!==pe?(me=Bl({totalTokens:pe,contextLimit:Y,isDraft:d}),t[52]=Y,t[53]=d,t[54]=pe,t[55]=me):me=t[55];let he=me,ge;t[56]!==x?.current||t[57]!==b||t[58]!==a?(ge=b===!0?x?.current?.trim()||a(`gitView.branch.detachedHead`):a(`common.unavailable`),t[56]=x?.current,t[57]=b,t[58]=a,t[59]=ge):ge=t[59];let _e=ge,ve;if(t[60]!==L||t[61]!==j||t[62]!==R||t[63]!==a){let e=new Map(j.map(Xl)),n;t[65]===L?n=t[66]:(n=e=>L.includes(e.id),t[65]=L,t[66]=n),ve=Dr(j).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(t.label??e),window:t});let i=Object.entries(n?.usage?.models??{}),o=R[t.id]??[],s=o.length>0?i.filter(e=>{let[t]=e;return o.includes(t)}):i;for(let[e,t]of s){let n=Object.entries(t.windows??{});if(n.length===0)continue;let[i,a]=n[0];r.push({key:`model-${e}-${i}`,label:Cn(a.label??i),subtitle:Mr(e),window:a})}let c=!n.ok&&n.error?n.error:r.length===0?a(`header.services.noRateLimitsReported`):null;return{providerId:t.id,providerName:t.name,rows:r,status:c}}),t[60]=L,t[61]=j,t[62]=R,t[63]=a,t[64]=ve}else ve=t[64];let ye=ve,be,xe;t[67]!==u||t[68]!==ye?(be=()=>{!u||ye.length===0||dn(ye.map(Yl))},xe=[u,ye],t[67]=u,t[68]=ye,t[69]=be,t[70]=xe):(be=t[69],xe=t[70]),Z.useEffect(be,xe);let Se;t[71]===p?Se=t[72]:(Se=()=>{p(Jl)},t[71]=p,t[72]=Se);let Ce=W(Se),we;t[73]===p?we=t[74]:(we=()=>{p(!1)},t[73]=p,t[74]=we);let Te=W(we),Ee;t[75]===a?Ee=t[76]:(Ee=a(`mobile.header.openMetadataAria`),t[75]=a,t[76]=Ee);let Oe=he?.percentage??0,ke=he?.pending,Ae;t[77]!==Oe||t[78]!==ke?(Ae=(0,$.jsx)(Fl,{percentage:Oe,pending:ke}),t[77]=Oe,t[78]=ke,t[79]=Ae):Ae=t[79];let je;t[80]!==Ce||t[81]!==u||t[82]!==Ee||t[83]!==Ae?(je=(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsx)(q,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,"aria-label":Ee,"aria-expanded":u,onClick:Ce,children:Ae})}),t[80]=Ce,t[81]=u,t[82]=Ee,t[83]=Ae,t[84]=je):je=t[84];let Me;t[85]!==_e||t[86]!==he||t[87]!==Te||t[88]!==F||t[89]!==u||t[90]!==I||t[91]!==z||t[92]!==ye?(Me=(0,$.jsx)(Kl,{open:u,onClose:Te,contextDisplay:he,branchLabel:_e,usageGroups:ye,usageDisplayMode:I,isUsageLoading:F,timeFormatPreference:z}),t[85]=_e,t[86]=he,t[87]=Te,t[88]=F,t[89]=u,t[90]=I,t[91]=z,t[92]=ye,t[93]=Me):Me=t[93];let Ne;return t[94]!==je||t[95]!==Me?(Ne=(0,$.jsxs)($.Fragment,{children:[je,Me]}),t[94]=je,t[95]=Me,t[96]=Ne):Ne=t[96],Ne}function Jl(e){return!e}function Yl(e){return e.providerId}function Xl(e){return[e?.providerId,e]}function Zl(e){return e.timeFormatPreference}function Ql(e){return e.selectedModels}function $l(e){return e.dropdownProviderIds}function eu(e){return e.displayMode}function tu(e){return e.isLoading}function nu(e){return e.fetchAllQuotas}function ru(e){return e.loadSettings}function iu(e){return e.results}function au(e){return e.getModelMetadata}function ou(e){return e.currentModelId}function su(e){return e.currentProviderId}function cu(e){return e.providers}function lu(e){return e.fetchStatus}function uu(e){return e.ensureStatus}function du(e){return e.currentDirectory}function fu(e){e.stopPropagation()}function pu(e){return e.sessionId?e.userRefreshInFlight||e.backgroundResyncInFlight?`syncing`:e.hasRenderableTranscript?null:!e.isConnected&&e.connectionPhase===`reconnecting`||e.loadStatus!==`error`?`syncing`:null:null}function mu(e,t){let n=t?.showDelayMs??250,r=t?.hideGraceMs??1e3,i=!1,a=!1,o=null,s=()=>{o=null,a!==i&&(a=i,e(a))};return{setRaw(e){i=e,o&&clearTimeout(o),o=setTimeout(s,i?n:r)},cancel(){i=!1,o&&=(clearTimeout(o),null)}}}function hu(e,t){let n=(0,Q.c)(10),r;n[0]===t?r=n[1]:(r={key:t},n[0]=t,n[1]=r);let i=r,a;n[2]===i?a=n[3]:(a={scope:i,visible:!1},n[2]=i,n[3]=a);let[o,s]=(0,Z.useState)(a),c;n[4]===i?c=n[5]:(c=mu(e=>s({scope:i,visible:e})),n[4]=i,n[5]=c);let l=c,u,d;return n[6]!==e||n[7]!==l?(u=()=>(l.setRaw(e),()=>l.cancel()),d=[e,l],n[6]=e,n[7]=l,n[8]=u,n[9]=d):(u=n[8],d=n[9]),(0,Z.useEffect)(u,d),o.scope===i&&o.visible}function gu(e,t){let n=(0,Q.c)(20),{t:r}=ce(),i=ht(e,t),{renderable:a}=ut(e,t),o=vt(bu),s=vt(yu),c;n[0]!==t||n[1]!==e?(c=()=>E(e,t),n[0]=t,n[1]=e,n[2]=c):c=n[2];let l=(0,Z.useSyncExternalStore)(D,c,vu),u;n[3]!==t||n[4]!==e?(u=()=>Ne(e,t),n[3]=t,n[4]=e,n[5]=u):u=n[5];let d=(0,Z.useSyncExternalStore)(Ke,u,_u),f=i?.status,p;n[6]!==d||n[7]!==s||n[8]!==a||n[9]!==o||n[10]!==e||n[11]!==f||n[12]!==l?(p=pu({sessionId:e,hasRenderableTranscript:a,loadStatus:f,userRefreshInFlight:l,backgroundResyncInFlight:d,isConnected:o,connectionPhase:s}),n[6]=d,n[7]=s,n[8]=a,n[9]=o,n[10]=e,n[11]=f,n[12]=l,n[13]=p):p=n[13];let m=p,h;n[14]!==t||n[15]!==e?(h=JSON.stringify([t,e]),n[14]=t,n[15]=e,n[16]=h):h=n[16];let g=hu(m===`syncing`,h),_;return n[17]!==r||n[18]!==g?(_=g?r(`mobile.chat.syncingMessages`):null,n[17]=r,n[18]=g,n[19]=_):_=n[19],_}function _u(){return!1}function vu(){return!1}function yu(e){return e.connectionPhase}function bu(e){return e.isConnected}function xu(e){let t=(0,Q.c)(32),{sessionId:n,directory:r,title:i,onBack:a,onOpenMenu:o,onCloseMenu:s,menuOpen:c,children:l,className:u}=e,d=c!==void 0&&c,{t:f}=ce(),p=n.length===0,m=Je(p?null:n),h;t[0]!==p||t[1]!==m?.title||t[2]!==f||t[3]!==i?(h=p?i?.trim()||f(`mobile.menu.newSession`):i?.trim()||m?.title?.trim()||f(`mobile.sessions.untitled`),t[0]=p,t[1]=m?.title,t[2]=f,t[3]=i,t[4]=h):h=t[4];let g=h,_=gu(p?``:n,r||void 0),[v,y]=Z.useState(!1),b;t[5]!==d||t[6]!==s?(b=e=>{e&&d&&s?.(),y(e)},t[5]=d,t[6]=s,t[7]=b):b=t[7];let x=W(b),S;t[8]!==v||t[9]!==o?(S=()=>{v&&y(!1),o()},t[8]=v,t[9]=o,t[10]=S):S=t[10];let C=W(S),w=d||v,T;t[11]===u?T=t[12]:(T=K(`relative isolate flex h-full min-h-0 w-full flex-col overflow-hidden bg-background text-foreground`,u),t[11]=u,t[12]=T);let E;t[13]!==v||t[14]!==x||t[15]!==n?(E=(0,$.jsx)(ql,{sessionId:n,open:v,onOpenChange:x}),t[13]=v,t[14]=x,t[15]=n,t[16]=E):E=t[16];let D;t[17]!==C||t[18]!==w||t[19]!==d||t[20]!==a||t[21]!==g||t[22]!==_||t[23]!==E?(D=(0,$.jsx)(Il,{title:g,subtitle:_,onBack:a,onOpenMenu:C,menuOpen:d,elevated:w,trailing:E}),t[17]=C,t[18]=w,t[19]=d,t[20]=a,t[21]=g,t[22]=_,t[23]=E,t[24]=D):D=t[24];let O;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(O=K(`mobile-chat-screen__content relative h-full min-h-0 flex-1`,`[&_[data-scrollbar=chat]>.oc-chat-scroll-content]:pt-[calc(max(0.625rem,var(--oc-safe-area-top,0px))+var(--oc-mobile-detail-navigation-height)+1.25rem)]`),t[25]=O):O=t[25];let k;t[26]===l?k=t[27]:(k=(0,$.jsx)(`div`,{className:O,children:l}),t[26]=l,t[27]=k);let A;return t[28]!==T||t[29]!==D||t[30]!==k?(A=(0,$.jsxs)(`main`,{className:T,children:[D,k]}),t[28]=T,t[29]=D,t[30]=k,t[31]=A):A=t[31],A}var Su=B(`BarcodeScanner`),Cu=`oc-barcode-scanner-active`,wu=()=>zu()?Su:null,Tu=()=>window.Capacitor?.getPlatform?.()===`android`,Eu=e=>typeof e==`object`&&e&&`message`in e?String(e.message??``):String(e??``),Du=e=>/^\s*scan canceled\.?\s*$/i.test(Eu(e)),Ou=e=>/denied access to camera/i.test(Eu(e)),ku=e=>!Du(e)&&!Ou(e),Au=e=>{let t=Eu(e);return/module/i.test(t)&&/not\s*available|unavailable/i.test(t)},ju=e=>{e.installGoogleBarcodeScannerModule?.().catch(()=>void 0)},Mu=e=>{let t=e.trim();if(!t)return null;if(/^openchamber:\/\//i.test(t)){let e=Ki(t);return e?{pairing:e}:null}return/^https?:\/\//i.test(t)?{url:t}:null},Nu=e=>{let t=Mu(e);return t?`pairing`in t?{status:`pairing`,...t}:{status:`ok`,...t}:{status:`invalid`}},Pu=e=>{typeof document>`u`||document.documentElement.classList.toggle(Cu,e)},Fu=e=>{try{e()}catch{}},Iu=e=>{if(typeof document>`u`)return()=>void 0;let t=document.body,n=document.createElement(`button`);n.type=`button`,n.className=`oc-barcode-scanner-chrome`,n.setAttribute(`aria-label`,`Cancel`),n.textContent=`×`,n.addEventListener(`click`,e),t.appendChild(n);let r=!1;return()=>{r||(r=!0,n.removeEventListener(`click`,e),n.parentNode===t&&t.removeChild(n))}},Lu=async e=>{if(!e.startScan||!e.stopScan||!e.addListener)return{status:`unsupported`};let t,n,r,i=!1,a=()=>void 0,o=new Promise(e=>{a=e}),s=e=>{i||(i=!0,a(e))};Pu(!0);let c=Iu(()=>s({status:`cancelled`}));try{let{App:e}=await H(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([61,1,16])),t=await e.addListener(`backButton`,()=>s({status:`cancelled`}));r=()=>void t.remove()}catch{r=void 0}try{return(await Promise.allSettled([Promise.resolve(e.addListener(`barcodesScanned`,({barcodes:e})=>{let t=e?.[0],n=(t?.rawValue??t?.displayValue??``).trim();n&&s(Nu(n))})).then(e=>{t=e}),Promise.resolve(e.addListener(`scanError`,()=>s({status:`failed`}))).then(e=>{n=e})])).some(({status:e})=>e===`rejected`)?s({status:`failed`}):i||e.startScan({formats:[`QR_CODE`]}).catch(e=>{Ou(e)?s({status:`permission-denied`}):s({status:`failed`})}),await o}finally{Pu(!1),Fu(c),Fu(()=>r?.()),await Promise.allSettled([Promise.resolve(t?.remove()),Promise.resolve(n?.remove()),e.stopScan()])}},Ru=e=>e.isNativePlatform&&e.isPluginAvailable,zu=()=>Ru({isNativePlatform:V.isNativePlatform(),isPluginAvailable:V.isPluginAvailable(`BarcodeScanner`)}),Bu=async()=>{let e=wu();if(!e)return{status:`unsupported`};try{if(e.requestPermissions){let t=(await e.requestPermissions())?.camera;if(t&&t!==`granted`&&t!==`limited`)return{status:`permission-denied`}}if(e.scan)try{let t=(await e.scan({formats:[`QR_CODE`]}))?.barcodes?.[0],n=(t?.rawValue??t?.displayValue??``).trim();return n?Nu(n):{status:`cancelled`}}catch(t){return Du(t)?{status:`cancelled`}:Ou(t)?{status:`permission-denied`}:Tu()&&ku(t)&&e.startScan?(Au(t)&&ju(e),Lu(e)):{status:`failed`}}return Tu()&&e.startScan?Lu(e):{status:`unsupported`}}catch{return{status:`failed`}}},Vu={autoComplete:`off`,autoCorrect:`off`,spellCheck:!1},Hu=e=>{let t=(0,Q.c)(32),{disabled:n,isBusy:r,tabIndex:i,inputClassName:a,buttonVariant:o,buttonClassName:s,onRedeem:c,onInvalid:l}=e,u=n!==void 0&&n,d=r!==void 0&&r,f=o===void 0?`outline`:o,p=s===void 0?`h-12 w-full`:s,{t:m}=ce(),[h,g]=Z.useState(``),_;t[0]!==l||t[1]!==c||t[2]!==h?(_=e=>{e.preventDefault();let t=Mu(h);if(!t||!(`pairing`in t)){l();return}c(t.pairing)},t[0]=l,t[1]=c,t[2]=h,t[3]=_):_=t[3];let v=W(_),y;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>g(e.target.value),t[4]=y):y=t[4];let b;t[5]===m?b=t[6]:(b=m(`mobile.connect.link.placeholder`),t[5]=m,t[6]=b);let x;t[7]===m?x=t[8]:(x=m(`mobile.connect.link.label`),t[7]=m,t[8]=x);let S;t[9]!==u||t[10]!==a||t[11]!==h||t[12]!==b||t[13]!==x||t[14]!==i?(S=(0,$.jsx)(`input`,{...Vu,value:h,onChange:y,placeholder:b,"aria-label":x,inputMode:`url`,autoCapitalize:`none`,tabIndex:i,disabled:u,className:a}),t[9]=u,t[10]=a,t[11]=h,t[12]=b,t[13]=x,t[14]=i,t[15]=S):S=t[15];let C;t[16]!==u||t[17]!==d||t[18]!==h?(C=u||d||!h.trim(),t[16]=u,t[17]=d,t[18]=h,t[19]=C):C=t[19];let w;t[20]!==d||t[21]!==m?(w=m(d?`mobile.connect.connecting`:`mobile.connect.connectButton`),t[20]=d,t[21]=m,t[22]=w):w=t[22];let T;t[23]!==p||t[24]!==f||t[25]!==C||t[26]!==w?(T=(0,$.jsx)(q,{type:`submit`,variant:f,size:`lg`,className:p,disabled:C,children:w}),t[23]=p,t[24]=f,t[25]=C,t[26]=w,t[27]=T):T=t[27];let E;return t[28]!==v||t[29]!==T||t[30]!==S?(E=(0,$.jsxs)(`form`,{className:`flex w-full flex-col gap-3`,onSubmit:v,children:[S,T]}),t[28]=v,t[29]=T,t[30]=S,t[31]=E):E=t[31],E},Uu=e=>{let t=(0,Q.c)(6),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`span`,{className:`h-px flex-1 bg-border/70`}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:n}),t[1]=n,t[2]=i);let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(`span`,{className:`h-px flex-1 bg-border/70`}),t[3]=a):a=t[3];let o;return t[4]===i?o=t[5]:(o=(0,$.jsxs)(`div`,{className:`flex items-center gap-3 py-3`,"aria-hidden":`true`,children:[r,i,a]}),t[4]=i,t[5]=o),o};function Wu(e){let t=(0,Q.c)(4),n=e===void 0?2500:e,{uiFont:r}=Fr(),[i,a]=Z.useState(!1),o,s;return t[0]!==n||t[1]!==r?(o=()=>{let e=!1,t=()=>{e||a(!0)},i=()=>{requestAnimationFrame(()=>requestAnimationFrame(t))},o=Promise.all([an(r).catch(Yu),document.fonts?.ready?.then(Ju).catch(qu)??Promise.resolve(),fa.catch(Ku)]).then(Gu),s=new Promise(e=>{window.setTimeout(e,n)});return Promise.race([o,s]).then(i),()=>{e=!0}},s=[r,n],t[0]=n,t[1]=r,t[2]=o,t[3]=s):(o=t[2],s=t[3]),Z.useEffect(o,s),i}function Gu(){}function Ku(){}function qu(){}function Ju(){}function Yu(){}var Xu=e=>e.replace(/^\/+|\/+$/g,``),Zu=e=>{let t=e.get(`directory`)||e.get(`dir`)||e.get(`path`);if(typeof t!=`string`)return;let n=t.trim();return n.length>0?n:void 0},Qu=e=>{let t=Xu(e.pathname).split(`/`).filter(Boolean);return e.host?[e.host,...t]:t};function $u(e){if(typeof e!=`string`||e.length===0)return null;let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`openchamber:`)return null;let n=Qu(t),r=(n[0]??``).toLowerCase(),i=n.slice(1),a=t.searchParams;switch(r){case`connect`:{let t=Ki(e);return t?{type:`connect`,pairing:t}:null}case`session`:{let e=i[0]||a.get(`id`)||``;return e?{type:`session`,sessionId:e,directory:Zu(a)}:null}case`assistant`:{let e=i[0]||a.get(`id`)||``;return e?{type:`assistant`,assistantId:e}:null}case`new`:case`new-session`:{let e=a.get(`prompt`)?.trim();return{type:`new-session`,directory:Zu(a),projectId:a.get(`project`)??void 0,agent:a.get(`agent`)??void 0,model:a.get(`model`)??void 0,prompt:e||void 0}}case`project`:case`open-project`:{let e;if(i.length>0)try{e=decodeURIComponent(i.join(`/`))}catch{e=i.join(`/`)}let t=Zu(a)||e;return t?{type:`open-project`,directory:t}:null}case`sessions`:{let e=a.get(`filter`);return{type:`sessions`,filter:e===`attention`||e===`recent`||e===`all`?e:void 0}}case`status`:return{type:`status`};case`settings`:return{type:`settings`,section:i[0]||a.get(`section`)||void 0};case`changes`:return{type:`changes`,path:i.join(`/`)||a.get(`path`)||void 0,staged:a.get(`staged`)===`true`};case`view`:{let e=(i[0]||``).toLowerCase();return e===`changes`?{type:`changes`}:e===`files`||e===`mcp`||e===`instances`||e===`update`?{type:`view`,target:e}:null}default:return null}}var ed={},td=null,nd=!1,rd=null,id=e=>{switch(e.type){case`connect`:return td?(td(e.pairing),!0):!1;case`session`:return A()?(it.getState().setCurrentSession(e.sessionId,e.directory??null),!0):(mt.getState().openSession({sessionId:e.sessionId,directory:e.directory??null}),!0);case`assistant`:if(!A()){let t=mt.getState();return t.setActiveTab(`assistant`),t.openAssistant(e.assistantId),!0}return Ct(e.assistantId),!0;case`new-session`:return A()?(it.getState().openNewSessionDraft({directoryOverride:e.directory??null,selectedProjectId:e.projectId??null,preserveDirectoryOverride:!!e.directory,ensureProjectForDirectory:!!e.directory,initialPrompt:e.prompt}),!0):(mt.getState().openDraft({directoryOverride:e.directory??null,selectedProjectId:e.projectId??null,preserveDirectoryOverride:!!e.directory,ensureProjectForDirectory:!!e.directory,initialPrompt:e.prompt}),!0);case`open-project`:return A()?(it.getState().openNewSessionDraft({directoryOverride:e.directory,preserveDirectoryOverride:!0}),!0):(mt.getState().openDraft({directoryOverride:e.directory,preserveDirectoryOverride:!0}),!0);case`sessions`:return ed.openSessions?(ed.openSessions(e.filter),!0):!1;case`status`:return ed.openSessions?(ed.openSessions(),!0):(M.getState().setMobileSessionPanelOpen(!0),!0);case`view`:return ed.openView?(ed.openView(e.target),!0):!1;case`changes`:return ed.openChanges?(ed.openChanges({path:e.path,staged:e.staged}),!0):!1;case`settings`:return ed.openSettings?(ed.openSettings(e.section),!0):!1}return!1},ad=()=>{if(!rd||!nd&&rd.type!==`connect`)return;let e=rd;rd=null,id(e)||(rd=e)},od=e=>{rd=e,ad()},sd=e=>{let t=$u(e);t&&od(t)},cd=e=>{nd=e,ad()},ld=e=>{let t=(0,Q.c)(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>(ed=e,ad(),()=>{ed===e&&(ed={})}),r=[e],t[0]=e,t[1]=n,t[2]=r),Z.useEffect(n,r)},ud=e=>{let t=(0,Q.c)(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>(td=e,ad(),()=>{td===e&&(td=null)}),r=[e],t[0]=e,t[1]=n,t[2]=r),Z.useEffect(n,r)},dd=e=>{let{ready:t}=e,[n,r]=Z.useState(()=>k()?`pending`:`none`);return Z.useEffect(()=>{cd(t)},[t]),Z.useEffect(()=>{if(!k())return;let e=!1,t=[];return H(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([61,1,16])).then(async({App:n})=>{if(e)return;let i=await n.addListener(`appUrlOpen`,e=>{sd(e?.url)});if(e){i.remove();return}t.push(()=>void i.remove());let a=await n.getLaunchUrl().catch(()=>void 0);if(e)return;let o=$u(a?.url);r(o?.type===`connect`?`connect`:o?`other`:`none`),o&&od(o)}).catch(()=>{e||r(`none`)}),H(async()=>{let{PushNotifications:e}=await import(`./vendor-capacitor-push-notifications-D5cqJIPw.js`).then(e=>e.t);return{PushNotifications:e}},__vite__mapDeps([62,1,16])).then(async({PushNotifications:n})=>{if(e)return;let r=await n.addListener(`pushNotificationActionPerformed`,e=>{let t=e?.notification?.data,n=typeof t?.url==`string`?t.url:typeof t?.deeplink==`string`?t.deeplink:void 0;if(n){sd(n);return}let r=typeof t?.assistantID==`string`?t.assistantID.trim():``;if(r){od({type:`assistant`,assistantId:r});return}let i=typeof t?.sessionId==`string`?t.sessionId:void 0;i&&od({type:`session`,sessionId:i})});if(e){r.remove();return}t.push(()=>void r.remove())}).catch(()=>void 0),()=>{e=!0,t.forEach(e=>e())}},[]),n},fd=.85,pd=8,md=.35,hd=.22,gd=e=>({segmentStart:e,lastTouch:e,open:!1}),_d=e=>e*md,vd=e=>e*hd,yd=(e,t)=>Math.max(0,e-t),bd=(e,t)=>Math.max(0,t-e),xd=(e,t)=>{let n=Math.abs(e);return n<pd||Math.abs(t)<=n*fd},Sd=(e,t,n)=>{let r=t.clientX-e.segmentStart.clientX,i=t.clientY-e.segmentStart.clientY,a=yd(e.segmentStart.clientX,t.clientX),o=_d(n),s=vd(n),c=e.open;return c=a<=0?!1:e.open?a>=s:a>=o&&xd(r,i),{segmentStart:e.segmentStart,lastTouch:t,open:c}},Cd=e=>{if(e.disabled||e.startedOnExcludedTarget)return{open:!1,back:!1};let t=e.endX-e.startX,n=e.endY-e.startY,r=yd(e.startX,e.endX),i=bd(e.startX,e.endX),a=_d(e.viewportWidth),o=xd(t,n);return{open:r>=a&&o,back:i>=a&&o}},wd=(e,t,n)=>Math.min(yd(e,t)/Math.max(1,_d(n)),1),Td=(e,t,n)=>Math.min(bd(e,t)/Math.max(1,_d(n)),1),Ed=e=>{let t=e;for(;t&&t!==document.body&&t!==document.documentElement;){let e=window.getComputedStyle(t).overflowX;if((e===`auto`||e===`scroll`)&&t.scrollWidth>t.clientWidth)return!0;t=t.parentElement}return!1},Dd=e=>{let t=document.elementFromPoint(e.clientX,e.clientY);return!!t?.closest(`.oc-mobile-composer`)||Ed(t)},Od=1,kd=(e,t)=>{if(!e||e.rangeCount===0||e.isCollapsed)return!1;if(!t)return!0;let n=e.anchorNode;if(!n)return!1;let r=n.nodeType===Od?n:n.parentElement;return!!(r&&t.contains(r))},Ad=e=>kd(window.getSelection(),e),jd=(e,t,n)=>{let r=Z.useRef(t.onOpen);r.current=t.onOpen;let i=Z.useRef(t.onPreviewStart);i.current=t.onPreviewStart;let a=Z.useRef(t.onPreviewCancel);a.current=t.onPreviewCancel;let o=Z.useRef(t.onProgress);o.current=t.onProgress;let s=Z.useRef(t.onBack);s.current=t.onBack;let c=Z.useRef(t.onBackProgress);c.current=t.onBackProgress;let l=Z.useRef(t.disabled);l.current=t.disabled,Z.useEffect(()=>{let t=e.current;if(!t)return;let n=!1,u=!1,d=null,f=!1,p=!1,m=!1,h=0,g=0,_=null,v=e=>{let t=_d(g),n=xt({thresholdReached:p,distance:e,enterDistance:t,cancelDistance:vd(g),available:!0});p=n.thresholdReached,n.event===`enter`&&(m=ke(`medium`,{bypassCadence:!0})),n.event===`cancel`&&(ke(`light`,{bypassCadence:!0}),m=!1)},y=e=>{o.current?.(null),p&&!e&&ke(`light`,{bypassCadence:!0}),p=!1,m=!1,e?r.current():f&&a.current?.(),f=!1},b=e=>{c.current?.(null),p&&!e&&ke(`light`,{bypassCadence:!0}),p=!1,m=!1,e&&s.current?.()},x=e=>{if(e.touches.length!==1){n=!1,_=null;return}if(l.current){n=!1,_=null;return}let r=e.touches[0];n=!0,g=window.innerWidth,u=Dd(r)||Ad(t),d=null,f=!1,p=!1,m=!1,h=0,_=gd(r)},S=e=>{if(!n||u||!_)return;if(e.touches.length!==1){d===`sessions`&&y(!1),d===`back`&&b(!1),n=!1,_=null;return}let r=e.touches[0];_=Sd(_,r,g);let a=r.clientX-_.segmentStart.clientX,l=r.clientY-_.segmentStart.clientY;if(d===null){if(Ad(t))return;let e=Math.abs(a);if(e<pd||Math.abs(l)>e*fd)return;if(a<0)d=`sessions`,f=!0,i.current?.();else if(s.current)d=`back`;else return}e.preventDefault(),h=d===`sessions`?yd(_.segmentStart.clientX,r.clientX):bd(_.segmentStart.clientX,r.clientX),v(h),d===`sessions`?o.current?.(wd(_.segmentStart.clientX,r.clientX,g)):c.current?.(Td(_.segmentStart.clientX,r.clientX,g))},C=e=>{if(!n||!_)return;if(n=!1,!d){_=null;return}let t=e.changedTouches[0];t&&(_=Sd(_,t,g),h=d===`sessions`?yd(_.segmentStart.clientX,t.clientX):bd(_.segmentStart.clientX,t.clientX),v(h));let r=d===`sessions`?_.open:Cd({startX:_.segmentStart.clientX,startY:_.segmentStart.clientY,endX:_.lastTouch.clientX,endY:_.lastTouch.clientY,viewportWidth:g,disabled:!1,startedOnExcludedTarget:!1}).back;_=null,e.preventDefault(),r&&!m&&ke(`medium`,{bypassCadence:!0}),d===`sessions`?y(r):b(r)},w=()=>{d===`sessions`&&y(!1),d===`back`&&b(!1),n=!1,_=null};return t.addEventListener(`touchstart`,x,{passive:!0,capture:!0}),t.addEventListener(`touchmove`,S,{passive:!1,capture:!0}),t.addEventListener(`touchend`,C,{passive:!1,capture:!0}),t.addEventListener(`touchcancel`,w,{passive:!0,capture:!0}),()=>{f&&y(!1),d===`back`&&b(!1),t.removeEventListener(`touchstart`,x,!0),t.removeEventListener(`touchmove`,S,!0),t.removeEventListener(`touchend`,C,!0),t.removeEventListener(`touchcancel`,w,!0)}},[e,n])},Md=B(`OpenChamberNotifications`),Nd=()=>V.getPlatform()===`android`&&V.isPluginAvailable(`OpenChamberNotifications`);async function Pd(e,n){let r=d(),a=t(),o=a?``:p();if(!a&&!/^https?:\/\//.test(o))return null;let s=await i();s.set(`Accept-Language`,n);let c=(await Y()).find(e=>fe(e)===r)?.candidates.find(e=>e.kind===`relay`);return{runtimeKey:r,baseUrl:o,relay:a??(c?.kind===`relay`?c.relay:void 0),preferRelay:!!a,headers:Object.fromEntries(s.entries()),labels:e}}function Fd(e){let t=0,n=!1;return{refresh:async()=>{let r=++t;try{if(await e.plugin.stop(),n||r!==t)return;let i=await e.resolveConfig();if(n||r!==t||!i)return;let a=await e.plugin.configure({config:i});!n&&r===t&&e.onState(a.state)}catch{!n&&r===t&&e.onError()}},stop:()=>{++t,e.plugin.stop().catch(e.onError)},dispose:()=>{n=!0,++t,e.plugin.stop().catch(e.onError)}}}var Id=()=>{if(Nd()||typeof window>`u`)return!1;let e=window.Capacitor?.getPlatform?.();return e===`ios`||e===`android`},Ld=(e,t)=>{h()?.push?.registerApnsToken?.({token:e,platform:j(),locale:t})},Rd=e=>{let{enabled:t}=e,n=M(e=>e.nativeNotificationsEnabled),r=J(e=>e.locale),i=Z.useRef(null),a=Z.useRef(r);a.current=r,Z.useEffect(()=>{if(!t||!n||!Id())return;let e=!1,r=[];return H(async()=>{let{PushNotifications:e}=await import(`./vendor-capacitor-push-notifications-D5cqJIPw.js`).then(e=>e.t);return{PushNotifications:e}},__vite__mapDeps([62,1,16])).then(async({PushNotifications:t})=>{if(e)return;let n=await t.checkPermissions().catch(()=>null);if(n?.receive!==`granted`&&(n=await t.requestPermissions().catch(()=>null)),n?.receive!==`granted`)return;let o=await t.addListener(`registration`,e=>{i.current=e.value,Ld(e.value,a.current)}),s=await t.addListener(`registrationError`,e=>{console.warn(`[Push] APNs registration error:`,e)});if(await t.register().catch(()=>void 0),e){o.remove(),s.remove();return}r.push(()=>void o.remove(),()=>void s.remove())}).catch(()=>void 0),()=>{e=!0,r.forEach(e=>e())}},[t,n]),Z.useEffect(()=>{if(!t||!n||!Id())return;let e=i.current;e&&Ld(e,r)},[t,n,r]),Z.useEffect(()=>{if(n)return;let e=i.current;e&&(i.current=null,h()?.push?.unregisterApnsToken?.({token:e}))},[n])},zd=`OpenChamberLiveActivity`,Bd=5e3,Vd=3600,Hd=`live`,Ud=B(zd),Wd=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable;function Gd(){return typeof window>`u`?!1:Wd({isCapacitor:k(),platform:j(),pluginAvailable:V.isPluginAvailable(zd)})}var Kd=()=>Ud,qd=new Set([`permission`,`input`,`retry`]),Jd=()=>({trackedSessionId:null,started:!1,startedAt:null,busySince:null,lastStatus:null,eventVersion:0,items:[]}),Yd=(e,t)=>Math.max(Math.floor(e),t+1),Xd=e=>e.failedEpoch===e.currentEpoch?e.previous:e.current,Zd=e=>e.failedEpoch===e.currentEpoch&&e.retryCount<1,Qd=e=>e.hasSessionError?`error`:e.hasPendingPermissions?`permission`:e.hasPendingQuestions?`input`:e.statusType===`retry`?`retry`:e.statusType===`busy`?`working`:e.statusType===`idle`?`complete`:null,$d=e=>{let t=e.trim();return t.length<=80?t:`${t.slice(0,79)}…`},ef=e=>typeof e.parentID==`string`&&e.parentID.length>0?e.parentID:null,tf=e=>{if(e.runningIds.size===0)return[];let t=[];for(let n of e.sessions)!e.runningIds.has(n.id)||ef(n)||t.push({sessionId:n.id,title:$d(n.title??``),statusType:e.statuses[n.id]?.type??`busy`});return t},nf=e=>e!==`complete`&&e!==`error`,rf=e=>e.some(e=>e.status===`permission`)?`permission`:e.some(e=>e.status===`input`)?`input`:e.some(e=>e.status===`retry`)?`retry`:e.some(e=>e.status===`tool`)?`tool`:e.some(e=>e.status===`stale`)?`stale`:e.some(e=>e.status===`working`)?`working`:e.some(e=>e.status===`error`)?`error`:`complete`,af=e=>{if(e.length<=4)return e;let t=e.filter(e=>nf(e.status)),n=e.filter(e=>!nf(e.status)).sort((e,t)=>(t.endedAt??0)-(e.endedAt??0)),r=[...t];for(let e of n){if(r.length>=4)break;r.push(e)}return r.slice(0,4)},of=(e,t,n,r)=>{if(n&&n.length>0)return n;let i=r?.[e];return i&&i.length>0?i:t},sf=(e,t,n,r,i)=>{let a=new Map;for(let e of t)a.set(e.sessionId,e);let o=[],s=new Set;for(let t of e){if(i&&!i.has(t.sessionId))continue;let e=a.get(t.sessionId);if(e){let i=Qd({statusType:e.statusType,hasPendingPermissions:e.hasPendingPermissions===!0,hasPendingQuestions:e.hasPendingQuestions===!0,hasSessionError:e.hasSessionError===!0})??`working`;o.push({sessionId:t.sessionId,title:of(t.sessionId,t.title,e.title,r),status:i,startedAt:t.startedAt,busySince:i===`working`?t.busySince??n:null})}else if(nf(t.status))o.push({...t,title:of(t.sessionId,t.title,void 0,r),status:`complete`,endedAt:n,busySince:null});else{let e=of(t.sessionId,t.title,void 0,r);o.push(e===t.title?t:{...t,title:e})}s.add(t.sessionId)}for(let e of t){if(s.has(e.sessionId))continue;let t=Qd({statusType:e.statusType,hasPendingPermissions:e.hasPendingPermissions===!0,hasPendingQuestions:e.hasPendingQuestions===!0,hasSessionError:e.hasSessionError===!0})??`working`;o.push({sessionId:e.sessionId,title:e.title,status:t,startedAt:n,busySince:t===`working`?n:null})}return af(o)},cf=e=>e.map(e=>`${e.sessionId}\0${e.title}\0${e.status}\0${e.endedAt??``}`).join(`
15
- `),lf=e=>e.map(e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:e.startedAt};return e.endedAt!==void 0&&(t.endedAt=e.endedAt),t}),uf=(e,t,n,r,i)=>{let a=e.filter(e=>nf(e.status)),o=a[0]??e[0],s={sessionId:Hd,startedAt:o?.startedAt??r,status:t,eventVersion:n,updatedAt:r,title:o?.title,workingCount:a.length,items:lf(e)};return i?.endedAt!==void 0&&(s.endedAt=i.endedAt),i?.dismissalSeconds!==void 0&&(s.dismissalSeconds=i.dismissalSeconds),s},df=e=>{let t={sessionId:e.sessionId,startedAt:e.startedAt,status:e.status,eventVersion:e.eventVersion,updatedAt:e.updatedAt};return e.endedAt!==void 0&&(t.endedAt=e.endedAt),e.dismissalSeconds!==void 0&&(t.dismissalSeconds=e.dismissalSeconds),e.title!==void 0&&(t.title=e.title),e.workingCount!==void 0&&(t.workingCount=e.workingCount),e.items!==void 0&&(t.items=e.items),t},ff=(e,t,n,r)=>{let i=e.trackedSessionId;if(!i||!e.started)return{state:Jd(),commands:[]};let a=Yd(t,e.eventVersion);return{state:Jd(),commands:[{type:`end`,payload:df({sessionId:i,startedAt:e.startedAt??t,status:n,eventVersion:a,updatedAt:t,endedAt:t,dismissalSeconds:r})}]}},pf=(e,t,n,r,i)=>{let a=Yd(r,i);return{state:{trackedSessionId:e,started:!0,startedAt:n,busySince:null,lastStatus:t,eventVersion:a,items:[]},commands:[{type:`start`,payload:df({sessionId:e,startedAt:n,status:t,eventVersion:a,updatedAt:r})}]}},mf=(e,t,n)=>{let r=Qd(t),i=e.busySince;if(r===`working`?i??=t.now:(!e.started&&!r||!e.started&&r===`complete`||!e.started&&r===`error`)&&(i=null),!e.started){if(r===`working`){let r=Bd-(t.now-(i??t.now));if(r>0)return{state:{...e,trackedSessionId:n,busySince:i},commands:[{type:`wait`,delayMs:r}]}}else if(!r||!qd.has(r))return{state:{...Jd(),trackedSessionId:n},commands:[]};return pf(n,r,i??t.now,t.now,e.eventVersion)}if(r===`complete`)return ff({...e,busySince:i},t.now,`complete`,900);if(r===`error`)return ff({...e,busySince:i},t.now,`error`,Vd);if(!r||r===e.lastStatus)return{state:{...e,trackedSessionId:n,busySince:i},commands:[]};let a=Yd(t.now,e.eventVersion);return{state:{trackedSessionId:n,started:!0,startedAt:e.startedAt??t.now,busySince:r===`working`?i:null,lastStatus:r,eventVersion:a,items:e.items},commands:[{type:`update`,payload:df({sessionId:n,startedAt:e.startedAt??t.now,status:r,eventVersion:a,updatedAt:t.now})}]}},hf=(e,t,n)=>{let r=e.trackedSessionId;if(!r||!e.started)return{state:e,commands:[]};let i=Yd(n,e.eventVersion);return{state:{...e,busySince:null,lastStatus:t,eventVersion:i},commands:[{type:`update`,payload:df({sessionId:r,startedAt:e.startedAt??n,status:t,eventVersion:i,updatedAt:n})}]}},gf=(e,t,n)=>{let r=sf(e.items,n,t.now,t.sessionTitles,t.rootSessionIds),i=r.filter(e=>nf(e.status)),a=rf(r),o=i.reduce((e,t)=>{let n=t.busySince??t.startedAt;return e===null||n<e?n:e},null);if(!t.connected){let n=e.busySince===null?e:{...e,busySince:null};if(!n.started||n.lastStatus===`stale`)return{state:{...n,items:r},commands:[]};let i=Yd(t.now,n.eventVersion),a=r.map(e=>nf(e.status)?{...e,status:`stale`}:e);return{state:{...n,items:a,lastStatus:`stale`,eventVersion:i,busySince:null},commands:[{type:`update`,payload:df(uf(a,`stale`,i,t.now))}]}}if(!e.started){if(i.length===0)return{state:Jd(),commands:[]};if(!i.some(e=>qd.has(e.status))){let n=Bd-(t.now-(o??t.now));if(n>0)return{state:{...e,trackedSessionId:Hd,items:r,busySince:o},commands:[{type:`wait`,delayMs:n}]}}let n=o??t.now,s=r.map(e=>nf(e.status)?{...e,startedAt:e.busySince??n}:e),c=Yd(t.now,e.eventVersion);return{state:{trackedSessionId:Hd,started:!0,startedAt:n,busySince:null,lastStatus:a,eventVersion:c,items:s},commands:[{type:`start`,payload:df(uf(s,a,c,t.now))}]}}if(i.length===0){let n=r.some(e=>e.status===`error`)?`error`:`complete`,i=Yd(t.now,e.eventVersion);return{state:Jd(),commands:[{type:`end`,payload:df(uf(r,n,i,t.now,{endedAt:t.now,dismissalSeconds:n===`error`?Vd:900}))}]}}if(cf(e.items)===cf(r)&&e.lastStatus===a)return{state:{...e,trackedSessionId:Hd,items:r,busySince:null},commands:[]};let s=Yd(t.now,e.eventVersion);return{state:{trackedSessionId:Hd,started:!0,startedAt:e.startedAt??o??t.now,busySince:null,lastStatus:a,eventVersion:s,items:r},commands:[{type:`update`,payload:df(uf(r,a,s,t.now))}]}},_f=(e,t)=>{if(t.catalog)return gf(e,t,t.catalog);if(!t.connected){let n=e.busySince===null?e:{...e,busySince:null};return!n.started||n.lastStatus===`stale`||!n.trackedSessionId?{state:n,commands:[]}:hf(n,`stale`,t.now)}let n=[],r=e;if(r.trackedSessionId&&r.trackedSessionId!==t.sessionId)if(r.started){let e=ff(r,t.now,r.lastStatus??`complete`,0);n.push(...e.commands),r=e.state}else r=Jd();if(!t.sessionId){if(r.started){let e=ff(r,t.now,`complete`,900);return{state:e.state,commands:[...n,...e.commands]}}return{state:Jd(),commands:n}}let i=mf(r,t,t.sessionId);return{state:i.state,commands:[...n,...i.commands]}},vf=e=>e/1e3,yf=e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:vf(e.startedAt)};return e.endedAt!==void 0&&(t.endedAt=vf(e.endedAt)),t},bf=e=>{let t={sessionId:e.sessionId,startedAt:vf(e.startedAt),status:e.status,eventVersion:e.eventVersion,updatedAt:vf(e.updatedAt)};return e.endedAt!==void 0&&(t.endedAt=vf(e.endedAt)),e.dismissalSeconds!==void 0&&(t.dismissalSeconds=e.dismissalSeconds),e.title!==void 0&&(t.title=e.title),e.workingCount!==void 0&&(t.workingCount=e.workingCount),e.items!==void 0&&(t.items=e.items.map(yf)),t},xf=e=>{let t={};return e.title!==void 0&&(t.title=e.title),e.workingCount!==void 0&&(t.workingCount=e.workingCount),e.items!==void 0&&(t.items=e.items),t},Sf=(e,t,n)=>{if(!e||n.type===`wait`)return Promise.resolve();let r=bf(n.payload),i=xf(r);return n.type===`start`?t.start({sessionId:r.sessionId,startedAt:r.startedAt,status:r.status,eventVersion:r.eventVersion,updatedAt:r.updatedAt,...i}):n.type===`update`?t.update({sessionId:r.sessionId,startedAt:r.startedAt,status:r.status,eventVersion:r.eventVersion,updatedAt:r.updatedAt,...i}):t.end({sessionId:r.sessionId,startedAt:r.startedAt,status:r.status,eventVersion:r.eventVersion,updatedAt:r.updatedAt,endedAt:r.endedAt,dismissalSeconds:r.dismissalSeconds,...i})},Cf=e=>e.getCurrentEpoch()===e.epoch?!e.getCurrentSessionId||e.getCurrentSessionId()===e.observation.sessionId:!1,wf=async e=>{let t=e.state;if(!Cf(e))return{state:t,delayMs:null,retry:!1,superseded:!0};let n=_f(t,e.observation),r=n.commands.find(e=>e.type===`wait`),i=r?.type===`wait`?r.delayMs:null,a=n.commands.filter(e=>e.type!==`wait`);if(a.length===0)return Cf(e)?{state:n.state,delayMs:i,retry:!1,superseded:!1}:{state:t,delayMs:null,retry:!1,superseded:!0};let o=t;try{for(let[r,i]of a.entries()){if(!Cf(e)||(await Sf(e.available,e.plugin,i),!Cf(e)))return{state:t,delayMs:null,retry:!1,superseded:!0};let s=r===a.length-1;o=i.type===`end`&&!s?Jd():n.state}return{state:n.state,delayMs:i,retry:!1,superseded:!1}}catch{if(!Cf(e))return{state:t,delayMs:null,retry:!1,superseded:!0};let r=Xd({failedEpoch:e.epoch,currentEpoch:e.getCurrentEpoch(),previous:o,current:n.state}),i=Zd({failedEpoch:e.epoch,currentEpoch:e.getCurrentEpoch(),retryCount:e.retryCount});return{state:r,delayMs:i?250:null,retry:i,superseded:!1}}},Tf=()=>({desired:null,registered:null}),Ef=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null},Df=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=Ef(t.activityId),r=Ef(t.sessionId),i=Ef(t.token);return!n||!r||!i?null:{activityId:n,sessionId:r,token:i}},Of=(e,t)=>e.activityId===t.activityId&&e.token===t.token,kf=(e,t)=>{let n=e.registered?.runtimeIdentity===t?e.registered:null;return e.desired===null&&n===e.registered?e:{desired:null,registered:n}},Af=(e,t)=>{if(!t.connected)return[];if(e.desired&&t.enabled&&t.selectedSessionId&&e.desired.sessionId===t.selectedSessionId){let n=e.registered;return n&&Of(n,e.desired)&&n.runtimeIdentity===t.runtimeIdentity?[]:[{type:`register`,payload:{activityId:e.desired.activityId,sessionId:e.desired.sessionId,token:e.desired.token},runtimeIdentity:t.runtimeIdentity}]}return e.registered&&e.registered.runtimeIdentity===t.runtimeIdentity?[{type:`unregister`,payload:{token:e.registered.token},runtimeIdentity:t.runtimeIdentity}]:[]},jf=(e,t,n)=>{let r=e;if(n.type===`pushToken`){if(!t.enabled||n.sessionId!==t.selectedSessionId)return{state:e,commands:[]};r={...e,desired:{activityId:n.activityId,sessionId:n.sessionId,token:n.token}}}else n.type===`localEndSucceeded`||n.type===`dispose`||!t.enabled||e.desired&&e.desired.sessionId!==t.selectedSessionId?r=kf(e,t.runtimeIdentity):e.registered&&e.registered.runtimeIdentity!==t.runtimeIdentity&&!e.desired&&(r={...e,registered:null});return{state:r,commands:Af(r,t)}},Mf=async e=>{try{return await e}catch{return null}},Nf=async e=>{let t=e.state;for(let n of e.commands){if(n.runtimeIdentity!==e.getRuntimeIdentity()){n.type===`unregister`&&t.registered?.runtimeIdentity===n.runtimeIdentity&&(t={...t,registered:null});continue}if(n.type===`register`){let r=t.registered;if(n.runtimeIdentity!==e.getRuntimeIdentity()||(await Mf(e.register(n.payload)))?.ok!==!0||n.runtimeIdentity!==e.getRuntimeIdentity())continue;if(t={...t,registered:{...n.payload,runtimeIdentity:n.runtimeIdentity}},r&&r.runtimeIdentity===n.runtimeIdentity&&r.token!==n.payload.token){if(n.runtimeIdentity!==e.getRuntimeIdentity())continue;await Mf(e.unregister({token:r.token}))}continue}if(n.runtimeIdentity!==e.getRuntimeIdentity()){t.registered?.runtimeIdentity===n.runtimeIdentity&&(t={...t,registered:null});continue}(await Mf(e.unregister(n.payload)))?.ok===!0&&t.registered?.token===n.payload.token&&(t={...t,registered:null})}return t},Pf=new Map,Ff=[];function If(){let e=Gd(),t=vt(e=>e.isConnected),n=Ze({enabled:e}),r=Ue(t=>e?t.statusById:Pf),i=He(t=>e?t.activeSessions:Ff),a=(0,Z.useMemo)(()=>e?dt(n,r):new Set,[e,r,n]),o=(0,Z.useMemo)(()=>e?tf({runningIds:a,statuses:n,sessions:i}):[],[e,n,a,i]),s=(0,Z.useMemo)(()=>{if(!e)return{};let t={};for(let e of i){let n=e.parentID;if(typeof n==`string`&&n.length>0)continue;let r=typeof e.title==`string`?e.title.trim():``;r&&(t[e.id]=r.length<=80?r:`${r.slice(0,79)}…`)}return t},[e,i]),u=(0,Z.useMemo)(()=>{if(!e)return new Set;let t=new Set;for(let e of i){let n=e.parentID;typeof n==`string`&&n.length>0||t.add(e.id)}return t},[e,i]),d=(0,Z.useMemo)(()=>[o.map(e=>`${e.sessionId}\0${e.title}\0${e.statusType??``}`).join(`
16
- `),Object.entries(s).map(([e,t])=>`${e}\0${t}`).join(`
17
- `)].join(`
18
- ---
19
- `),[o,s]),f=(0,Z.useRef)(Jd()),p=(0,Z.useRef)(Tf()),m=(0,Z.useRef)(null),g=(0,Z.useRef)(0),_=(0,Z.useRef)(Promise.resolve()),v=(0,Z.useRef)(Promise.resolve()),y=(0,Z.useRef)(null),b=W(()=>({sessionId:Hd,statusType:void 0,hasPendingPermissions:!1,hasPendingQuestions:!1,hasSessionError:!1,now:Date.now(),connected:t,catalog:o,sessionTitles:s,rootSessionIds:u})),x=W(n=>{v.current=v.current.then(async()=>{let r=jf(p.current,{selectedSessionId:Hd,runtimeIdentity:l(),connected:t,enabled:e},n);p.current=r.state,r.commands.length!==0&&(p.current=await Nf({state:p.current,commands:r.commands,getRuntimeIdentity:l,register:e=>h()?.push?.registerLiveActivityToken?.({...e,items:f.current.items.map(e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:vf(e.startedAt)};return e.endedAt===void 0?t:{...t,endedAt:vf(e.endedAt)}})})??Promise.resolve(null),unregister:e=>h()?.push?.unregisterLiveActivityToken?.(e)??Promise.resolve(null)}))}).catch(()=>void 0)}),S=W(e=>{let t=Df(e);t&&x({type:`pushToken`,...t,sessionId:Hd})});(0,Z.useEffect)(()=>{x({type:e?`sync`:`dispose`})},[e,t]),(0,Z.useEffect)(()=>c(()=>{x({type:`sync`})}),[]),(0,Z.useEffect)(()=>{if(!e){y.current?.remove(),y.current=null;return}let t=!1,n=null,r=0,i=Kd(),a=g.current+1;g.current=a;let o=()=>{_.current=_.current.then(async()=>{if(t||g.current!==a)return;if(m.current!==!0){if(m.current===!1)return;let e=await i.isSupported().catch(()=>({supported:!1}));if(t||g.current!==a||(m.current=e.supported===!0,!m.current))return}let e=b(),s=f.current.started,c=await wf({available:!0,plugin:i,state:f.current,observation:e,epoch:a,getCurrentEpoch:()=>g.current,retryCount:r});if(!(t||g.current!==a||c.superseded)){if(f.current=c.state,s&&!c.state.started)x({type:`localEndSucceeded`});else if(c.state.started){let e=p.current.desired;e&&h()?.push?.registerLiveActivityToken?.({activityId:e.activityId,sessionId:Hd,token:e.token,items:c.state.items.map(e=>{let t={sessionId:e.sessionId,title:e.title,status:e.status,startedAt:vf(e.startedAt)};return e.endedAt===void 0?t:{...t,endedAt:vf(e.endedAt)}})})}c.retry?r+=1:r=0,c.delayMs!=null&&(n=setTimeout(()=>{o()},c.delayMs))}}).catch(()=>void 0)};return _.current=_.current.then(async()=>{if(!(t||g.current!==a)&&!y.current)try{let e=await i.addListener(`pushToken`,e=>{S(e)});if(t){await e.remove();return}y.current=e}catch{return}}).then(()=>{!t&&g.current===a&&o()}).catch(()=>void 0),()=>{t=!0,g.current===a&&(g.current+=1),n!==null&&clearTimeout(n)}},[e,t,d]),(0,Z.useEffect)(()=>()=>{y.current?.remove(),y.current=null,x({type:`dispose`})},[])}function Lf(){let e=(0,Q.c)(49),t=M(zf),{t:r,locale:i}=ce(),a;e[0]===r?a=e[1]:(a=r(`mobile.notifications.service`),e[0]=r,e[1]=a);let o=a,s;e[2]===r?s=e[3]:(s=r(`settings.page.notifications.title`),e[2]=r,e[3]=s);let l=s,u;e[4]===r?u=e[5]:(u=r(`mobile.connect.connecting`),e[4]=r,e[5]=u);let d=u,f;e[6]===r?f=e[7]:(f=r(`mobile.notifications.connected`),e[6]=r,e[7]=f);let p=f,m;e[8]===r?m=e[9]:(m=r(`layout.browserProvider.status.reconnecting`),e[8]=r,e[9]=m);let h=m,g;e[10]===r?g=e[11]:(g=r(`mobile.notifications.unavailable`),e[10]=r,e[11]=g);let _=g,v;e[12]===r?v=e[13]:(v=r(`mobile.notifications.gap`),e[12]=r,e[13]=v);let y=v,b;e[14]===r?b=e[15]:(b=r(`settings.notifications.page.toast.permissionDenied.title`),e[14]=r,e[15]=b);let x=b,S;e[16]===r?S=e[17]:(S=r(`settings.notifications.page.template.defaults.error.title`),e[16]=r,e[17]=S);let C=S,w;e[18]===r?w=e[19]:(w=r(`mobile.notifications.auth`),e[18]=r,e[19]=w);let T=w,E;e[20]===r?E=e[21]:(E=r(`mobile.notifications.endpoint`),e[20]=r,e[21]=E);let D=E,O;e[22]===r?O=e[23]:(O=r(`mobile.notifications.response`),e[22]=r,e[23]=O);let k=O,A;e[24]===r?A=e[25]:(A=r(`mobile.notifications.server`),e[24]=r,e[25]=A);let j=A,N;e[26]===r?N=e[27]:(N=r(`mobile.notifications.relay`),e[26]=r,e[27]=N);let P=N,F;e[28]===r?F=e[29]:(F=r(`mobile.notifications.identity`),e[28]=r,e[29]=F);let ee=F,I,L;e[30]!==l||e[31]!==T||e[32]!==p||e[33]!==d||e[34]!==x||e[35]!==t||e[36]!==D||e[37]!==C||e[38]!==y||e[39]!==ee||e[40]!==i||e[41]!==h||e[42]!==P||e[43]!==k||e[44]!==j||e[45]!==o||e[46]!==_?(I=()=>{if(!Nd())return;if(!t){Md.stop().catch(Rf);return}let e=!1,r=t=>{e||(e=!0,We.error(t))},a=Fd({plugin:Md,resolveConfig:()=>Pd({service:o,alerts:l,connecting:d,connected:p,reconnecting:h,unavailable:_,gap:y,error:C,auth:T,endpoint:D,response:k,server:j,relay:P,identity:ee},i),onState:e=>{(e===`denied`||e===`unavailable`)&&r(e===`denied`?x:_)},onError:()=>r(_)}),s=c(()=>{a.refresh()}),u=n(e=>{let{reason:t}=e;t===`invalidate`?a.stop():t!==`endpoint-switch`&&a.refresh()});return a.refresh(),()=>{s(),u(),a.dispose()}},L=[t,i,o,l,d,p,h,_,y,x,C,T,D,k,j,P,ee],e[30]=l,e[31]=T,e[32]=p,e[33]=d,e[34]=x,e[35]=t,e[36]=D,e[37]=C,e[38]=y,e[39]=ee,e[40]=i,e[41]=h,e[42]=P,e[43]=k,e[44]=j,e[45]=o,e[46]=_,e[47]=I,e[48]=L):(I=e[47],L=e[48]),(0,Z.useEffect)(I,L)}function Rf(){console.warn(`[Native notifications] stop failed`)}function zf(e){return e.nativeNotificationsEnabled}var Bf=`mobile-direct-diff`,Vf=`mobile-turn-diff`,Hf=`mobile-direct-file`,Uf=`mobile-files`,Wf=`mobile-changes`,Gf=`mobile-mcp`,Kf=`mobile-settings`,qf=`mobile-update`,Jf=`mobile-overflow-menu`,Yf=320,Xf=380,Zf=280,Qf=560,$f=380,ep=e=>Math.min(Qf,Math.max(Zf,Math.round(e))),tp=(e,t)=>{let n=e.current;n&&(n.style.width=`${t}px`,n.style.minWidth=`${t}px`,n.style.maxWidth=`${t}px`,n.style.setProperty(`--oc-ipad-sidebar-width`,`${t}px`))};function np(e,t,n){let r=(0,Q.c)(17),i=Z.useRef(null),a;r[0]!==n||r[1]!==t?(a=()=>{if(typeof window>`u`)return n;let e=Number.parseInt(window.localStorage.getItem(t)??``,10);return Number.isFinite(e)?Math.min(Qf,Math.max(Zf,e)):n},r[0]=n,r[1]=t,r[2]=a):a=r[2];let[o,s]=Z.useState(a),[c,l]=Z.useState(!1),u=Z.useRef(0),d=Z.useRef(o),f=Z.useRef(null),p=Z.useRef(null),m;r[3]===o?m=r[4]:(m=e=>{try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}p.current=e.pointerId,u.current=e.clientX,d.current=o,f.current=o,l(!0),e.preventDefault()},r[3]=o,r[4]=m);let h=W(m),g;r[5]===e?g=r[6]:(g=t=>{if(p.current!==t.pointerId)return;let n=t.clientX-u.current,r=ep(d.current+(e===`left`?n:-n));f.current!==r&&(f.current=r,tp(i,r))},r[5]=e,r[6]=g);let _=W(g),v;r[7]===t?v=r[8]:(v=e=>{if(p.current!==e.pointerId)return;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}let n=ep(f.current??d.current);p.current=null,f.current=null,l(!1),s(n);try{window.localStorage.setItem(t,String(n))}catch{}},r[7]=t,r[8]=v);let y=W(v),b;r[9]!==h||r[10]!==y||r[11]!==_?(b={onPointerDown:h,onPointerMove:_,onPointerUp:y,onPointerCancel:y},r[9]=h,r[10]=y,r[11]=_,r[12]=b):b=r[12];let x=b,S;return r[13]!==x||r[14]!==c||r[15]!==o?(S={asideRef:i,width:o,isResizing:c,handleProps:x},r[13]=x,r[14]=c,r[15]=o,r[16]=S):S=r[16],S}var rp=e=>{let t=(0,Q.c)(12),{side:n,isResizing:r,ariaLabel:i,handleProps:a}=e,o=n===`left`?`right-0`:`left-0`,s;t[0]===o?s=t[1]:(s=K(`absolute inset-y-0 z-30 w-6 cursor-col-resize touch-none`,o),t[0]=o,t[1]=s);let c=n===`left`?`right-0`:`left-0`,l=r&&`bg-[var(--interactive-border)]`,u;t[2]!==c||t[3]!==l?(u=K(`absolute inset-y-0 w-[3px] transition-colors`,c,l),t[2]=c,t[3]=l,t[4]=u):u=t[4];let d;t[5]===u?d=t[6]:(d=(0,$.jsx)(`div`,{className:u}),t[5]=u,t[6]=d);let f;return t[7]!==i||t[8]!==a||t[9]!==s||t[10]!==d?(f=(0,$.jsx)(`div`,{className:s,role:`separator`,"aria-orientation":`vertical`,"aria-label":i,...a,children:d}),t[7]=i,t[8]=a,t[9]=s,t[10]=d,t[11]=f):f=t[11],f},ip=()=>typeof window>`u`?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`,ap=()=>{Z.useEffect(()=>{if(!ip())return;document.documentElement.classList.add(`oc-native-app-active`);let e=!1,t=[],n=document.documentElement;n.classList.add(`oc-capacitor-app`),window.Capacitor?.getPlatform?.()===`android`&&n.classList.add(`oc-platform-android`);let r=e=>{n.style.setProperty(`--oc-keyboard-inset`,`${Math.max(0,Math.round(e))}px`)};return H(async()=>{let{StatusBar:e,Style:t}=await import(`./vendor-capacitor-status-bar-D9bcMr9Q.js`).then(e=>e.t);return{StatusBar:e,Style:t}},__vite__mapDeps([63,1,16])).then(async({StatusBar:n,Style:r})=>{if(e)return;let i=window.Capacitor?.getPlatform?.(),a=async()=>{if(i===`android`){let e=document.documentElement.classList.contains(`dark`),t=(e?localStorage.getItem(`splashBgDark`):localStorage.getItem(`splashBgLight`))||(e?`#121212`:`#FFFFFF`);await n.setOverlaysWebView({overlay:!1}).catch(()=>void 0),await n.setBackgroundColor({color:t}).catch(()=>void 0),await n.setStyle({style:e?r.Dark:r.Light}).catch(()=>void 0),await n.show().catch(()=>void 0);return}await n.setStyle({style:r.Default}).catch(()=>void 0),await n.setOverlaysWebView({overlay:!0}).catch(()=>void 0),await n.show().catch(()=>void 0)};await a();let o=window.setTimeout(()=>void a(),400);t.push(()=>window.clearTimeout(o));let{App:s}=await H(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([61,1,16])),c=await s.addListener(`appStateChange`,({isActive:e})=>{e&&a()});if(e){c.remove();return}t.push(()=>void c.remove())}).catch(()=>void 0),H(async()=>{let{Keyboard:e}=await import(`./vendor-capacitor-keyboard-BRVcFyc9.js`).then(e=>e.t);return{Keyboard:e}},__vite__mapDeps([64,1,16])).then(async({Keyboard:i})=>{if(e)return;let a=window.Capacitor?.getPlatform?.()===`android`;await i.setAccessoryBarVisible({isVisible:!1}).catch(()=>void 0);let o=`cubic-bezier(0.38, 0.7, 0.125, 1)`,s=null,c=null,l=0,u=!1,d=0,f=!1,p=(e,t)=>{n.style.setProperty(e,`${Math.max(0,Math.round(t))}px`)},m=()=>{s!==null&&(window.clearTimeout(s),s=null)},h=(e,t)=>{window.dispatchEvent(new CustomEvent(e,{detail:t}))},g=e=>e.getClientRects().length>0&&getComputedStyle(e).visibility!==`hidden`,_=e=>{for(let t of document.querySelectorAll(e))if(g(t))return t;return null},v=e=>{let t=[],n=e instanceof Element?e:null;if(n&&!lo(n))return t;let r=n?.closest(`.oc-mobile-composer`)??null,i=r&&g(r)?r:_(`.oc-mobile-composer`);if(i&&t.push({el:i,factor:1}),i){let e=_(`.oc-draft-center`);e&&t.push({el:e,factor:.5})}return t},y=e=>e instanceof HTMLElement&&(e.tagName===`TEXTAREA`||e.tagName===`INPUT`||e.isContentEditable),b=()=>{let e=document.activeElement;return!(y(e)&&!lo(e))},x=e=>lo(e),S=()=>{for(let e of document.querySelectorAll(`.oc-mobile-composer, .oc-draft-center`))e.style.transition=``,e.style.transform=``},C=()=>{let e=document.querySelector(`.oc-mobile-app-shell`);d=e&&parseFloat(getComputedStyle(e).paddingBottom)||0};if(a){let i=`openchamber.androidImeHeightRatio.v2`,a=`cubic-bezier(0.2, 0, 0, 1)`,o=`cubic-bezier(0.4, 0, 1, 1)`,s=null,c=!1,l=y,u=e=>Number.isFinite(e)?Math.min(.68,Math.max(.28,e)):.39,m=Math.round(window.innerHeight*(()=>{try{return u(Number.parseFloat(localStorage.getItem(i)??``))}catch{return .39}})()),g=0,_=e=>{if(m=Math.max(0,Math.round(e)),!(m<=0||window.innerHeight<=0))try{localStorage.setItem(i,String(u(m/window.innerHeight)))}catch{}},w=()=>{s!==null&&(window.clearTimeout(s),s=null)},T=e=>Math.max(0,Math.round(e-d)),E=(e,t)=>`translate3d(0, ${-e*t}px, 0)`,D=(e,t,r,i)=>{w();let a=T(e),o=v(i);n.classList.add(`oc-kb-animating`);for(let{el:e,factor:n}of o)e.style.transition=`transform ${t}ms ${r}`,e.style.transform=E(a,n);return s=window.setTimeout(()=>{s=null,n.classList.remove(`oc-kb-animating`);for(let{el:e}of o)e.style.transition=``},t+20),a},O=e=>{C();let t=Math.max(0,Math.round(e));f=!0,c=!1,g=t,n.classList.remove(`oc-keyboard-open`,`oc-kb-animating`),r(t),p(`--oc-kb-layout`,0),p(`--oc-kb-scroll-inset`,T(t)),w(),S(),h(`oc:keyboard-settled`,{open:!0})},k=(e,t=`focus`)=>{if(t===`intent`){if(!b())return}else if(t===`focus`){if(!x(e))return}else if(!f&&!x(document.activeElement))return;if(C(),f){let i=g||m,o=T(i),s=v(t===`focus`?e:void 0);if(s.length===0||(c=!0,n.classList.add(`oc-keyboard-open`),r(0),p(`--oc-kb-scroll-inset`,0),s.every(({el:e,factor:t})=>e.style.transform===E(o,t))))return;D(i,60,a,t===`focus`?e:void 0),h(`oc:keyboard-anim`,{phase:`show`,slide:o,durationMs:60,easing:a}),h(`oc:keyboard-settled`,{open:!0});return}f=!0,c=!0,n.classList.add(`oc-keyboard-open`),r(0),p(`--oc-kb-layout`,0),p(`--oc-kb-scroll-inset`,0),g=m;let i=D(g,200,a,t===`focus`?e:void 0);h(`oc:keyboard-anim`,{phase:`show`,slide:i,durationMs:200,easing:a}),h(`oc:keyboard-settled`,{open:!0})},A=e=>{if(!f){e&&l(document.activeElement)&&lo(document.activeElement)&&document.activeElement.blur();return}let t=g||m,i=c;f=!1,c=!1,g=0,e&&l(document.activeElement)&&lo(document.activeElement)&&document.activeElement.blur(),n.classList.remove(`oc-keyboard-open`),r(0),p(`--oc-kb-layout`,0),p(`--oc-kb-scroll-inset`,0),h(`oc:keyboard-intent`,{open:!1});let a=T(t);if(!i){w(),S(),h(`oc:keyboard-settled`,{open:!1});return}D(0,100,o),h(`oc:keyboard-anim`,{phase:`hide`,slide:a,durationMs:100,easing:o}),w(),s=window.setTimeout(()=>{s=null,n.classList.remove(`oc-kb-animating`),S(),h(`oc:keyboard-settled`,{open:!1})},120)},j=e=>{if(l(e.target)){if(lo(e.target)){k(e.target,`focus`);return}O(g||m)}},M=e=>{if(l(e.target)&&!fo(e.relatedTarget)){if(uo(e.relatedTarget)){h(`oc:keyboard-intent`,{open:!1}),O(g||m);return}A(!1)}},N=e=>{let t=e,n=t.detail??t;if(n?.open===!0){let e=ho(n.height??0,window.devicePixelRatio||1),t=po(c,document.activeElement);if(e>0&&(t===`open`||t===`cache`)&&_(e),t===`open`&&k(document.activeElement,`ime`),t===`cache`&&mo(g||m,e)){g=e;let t=D(e,60,a,lo(document.activeElement)?document.activeElement:void 0);h(`oc:keyboard-anim`,{phase:`show`,slide:t,durationMs:60,easing:a})}t===`field`&&O(e||m)}n?.open===!1&&A(!0)},P=e=>{e.detail?.open===!0&&k(void 0,`intent`)};if(document.addEventListener(`focusin`,j,!0),document.addEventListener(`focusout`,M,!0),window.addEventListener(`oc:ime-state`,N),window.addEventListener(`oc:keyboard-intent`,P),e){w(),document.removeEventListener(`focusin`,j,!0),document.removeEventListener(`focusout`,M,!0),window.removeEventListener(`oc:ime-state`,N),window.removeEventListener(`oc:keyboard-intent`,P);return}t.push(w,()=>document.removeEventListener(`focusin`,j,!0),()=>document.removeEventListener(`focusout`,M,!0),()=>window.removeEventListener(`oc:ime-state`,N),()=>window.removeEventListener(`oc:keyboard-intent`,P));return}let w=`openchamber.iosImeHeightRatio.v1`,T=e=>Number.isFinite(e)?Math.min(.68,Math.max(.28,e)):.39,E=()=>{try{let e=T(Number.parseFloat(localStorage.getItem(w)??``));return Math.round(window.innerHeight*e)}catch{return Math.round(window.innerHeight*.39)}},D=e=>{if(!(e<=0||window.innerHeight<=0))try{localStorage.setItem(w,String(T(e/window.innerHeight)))}catch{}},O=e=>{C();let t=Math.max(0,e-d);r(e),p(`--oc-kb-layout`,e),p(`--oc-kb-scroll-inset`,0),u=!0,S(),window.scrollTo(0,0),document.body.scrollTop!==0&&(document.body.scrollTop=0);let n=document.activeElement instanceof Element?document.activeElement.closest(`.oc-mobile-composer`):null;return(n&&g(n)?n:_(`.oc-mobile-composer`))?.scrollIntoView({block:`end`,inline:`nearest`}),t},k=e=>{if(co(n.classList.contains(`oc-native-ios-composer`),document.activeElement)||e.detail?.open!==!0||u||y(document.activeElement)&&!lo(document.activeElement))return;f=!0,n.classList.remove(`oc-kb-hide`),n.classList.add(`oc-keyboard-open`);let t=l>0?l:E(),r=O(t);h(`oc:keyboard-anim`,{phase:`show`,slide:r,durationMs:0,easing:o}),h(`oc:keyboard-settled`,{open:!0})};window.addEventListener(`oc:keyboard-intent`,k);let A=await i.addListener(`keyboardWillShow`,e=>{if(co(n.classList.contains(`oc-native-ios-composer`),document.activeElement))return;m(),l=e.keyboardHeight,D(l);let t=lo(document.activeElement)||n.classList.contains(`oc-keyboard-open`)&&!y(document.activeElement);if(f=!0,n.classList.remove(`oc-kb-hide`),c!==null&&(window.clearTimeout(c),c=null),!t){r(l),p(`--oc-kb-layout`,0),C(),p(`--oc-kb-scroll-inset`,Math.max(0,l-d)),n.classList.remove(`oc-keyboard-open`,`oc-kb-animating`,`oc-kb-caret-hold`),S(),u=!1,h(`oc:keyboard-settled`,{open:!0});return}n.classList.add(`oc-keyboard-open`);let i=O(l);h(`oc:keyboard-settled`,{open:!0}),h(`oc:keyboard-anim`,{phase:`show`,slide:i,durationMs:0,easing:o})}),j=()=>{let e=document.activeElement;e instanceof HTMLElement&&lo(e)&&e.blur()},M=()=>{f||(window.scrollTo(0,0),document.body.scrollTop!==0&&(document.body.scrollTop=0))},N=()=>{f=!1,m(),c!==null&&(window.clearTimeout(c),c=null),n.classList.remove(`oc-keyboard-open`,`oc-kb-animating`,`oc-kb-caret-hold`,`oc-kb-hide`),r(0),p(`--oc-kb-scroll-inset`,0),p(`--oc-kb-layout`,0),u=!1,S(),M(),window.setTimeout(M,350)},P=()=>{if(n.classList.contains(`oc-native-ios-composer`)){N(),ur().blur(),h(`oc:keyboard-settled`,{open:!1});return}if(!f)return;f=!1,m(),h(`oc:keyboard-intent`,{open:!1}),j(),window.setTimeout(()=>{f||lo(document.activeElement)&&(j(),h(`oc:keyboard-intent`,{open:!1}))},80),c!==null&&(window.clearTimeout(c),c=null),n.classList.remove(`oc-kb-caret-hold`,`oc-kb-animating`);let e=Math.max(0,l-d);n.classList.remove(`oc-keyboard-open`),r(0),p(`--oc-kb-scroll-inset`,0),p(`--oc-kb-layout`,0),u=!1,S(),M(),window.setTimeout(M,350),h(`oc:keyboard-anim`,{phase:`hide`,slide:e,durationMs:0,easing:o}),n.classList.add(`oc-kb-animating`,`oc-kb-hide`),s=window.setTimeout(()=>{s=null,n.classList.remove(`oc-kb-animating`,`oc-kb-hide`),h(`oc:keyboard-settled`,{open:!1})},260)},F=await i.addListener(`keyboardWillHide`,P),ee=e=>e instanceof HTMLElement&&(e.tagName===`TEXTAREA`||e.tagName===`INPUT`||e.isContentEditable),I=e=>{if(f&&ee(e.target)){if(fo(e.relatedTarget)){p(`--oc-kb-scroll-inset`,0);return}window.setTimeout(()=>{if(f&&!lo(document.activeElement)){if(ee(document.activeElement)){m(),n.classList.remove(`oc-keyboard-open`,`oc-kb-animating`,`oc-kb-caret-hold`,`oc-kb-hide`),r(l),p(`--oc-kb-layout`,0),C(),p(`--oc-kb-scroll-inset`,Math.max(0,l-d)),u=!1,S(),h(`oc:keyboard-intent`,{open:!1}),h(`oc:keyboard-settled`,{open:!0});return}P()}},0)}};if(document.addEventListener(`focusout`,I,!0),e){m(),document.removeEventListener(`focusout`,I,!0),window.removeEventListener(`oc:keyboard-intent`,k),A.remove(),F.remove();return}t.push(m,()=>{c!==null&&(window.clearTimeout(c),c=null)},()=>document.removeEventListener(`focusout`,I,!0),()=>window.removeEventListener(`oc:keyboard-intent`,k),()=>void A.remove(),()=>void F.remove())}).catch(()=>void 0),()=>{e=!0,t.forEach(e=>e()),n.classList.remove(`oc-capacitor-app`,`oc-keyboard-open`,`oc-kb-animating`,`oc-kb-hide`,`oc-kb-caret-hold`,`oc-platform-android`),n.style.removeProperty(`--oc-keyboard-inset`),n.style.removeProperty(`--oc-kb-shift`),n.style.removeProperty(`--oc-kb-layout`),n.style.removeProperty(`--oc-kb-scroll-inset`)}},[])},op=e=>{let t=Z.useRef(!1);Z.useEffect(()=>{if(!ip())return;let n=!1,r=[],i=()=>{t.current&&(t.current=!1,e())},a=()=>{if(document.visibilityState===`hidden`){t.current=!0;return}i()};return document.addEventListener(`visibilitychange`,a),r.push(()=>document.removeEventListener(`visibilitychange`,a)),H(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([61,1,16])).then(async({App:e})=>{if(n)return;let a=await e.getState().catch(()=>null);if(n)return;a&&document.documentElement.classList.toggle(`oc-native-app-active`,a.isActive);let o=await e.addListener(`appStateChange`,({isActive:e})=>{if(document.documentElement.classList.toggle(`oc-native-app-active`,e),!e){t.current=!0;return}i()}),s=await e.addListener(`resume`,i);if(n){o.remove(),s.remove();return}r.push(()=>void o.remove(),()=>void s.remove())}).catch(()=>void 0),()=>{n=!0,r.forEach(e=>e()),document.documentElement.classList.remove(`oc-native-app-active`)}},[e])},sp=e=>{Z.useEffect(()=>{if(!ip())return;let t=!1,n=null;return H(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([61,1,16])).then(async({App:r})=>{if(t)return;let i=await r.addListener(`backButton`,()=>{e()||r.minimizeApp().catch(()=>void 0)});if(t){i.remove();return}n=()=>void i.remove()}).catch(()=>void 0),()=>{t=!0,n?.()}},[e])},cp=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``),lp={autoComplete:`off`,autoCorrect:`off`,spellCheck:!1},up=1e3,dp=e=>{let t=cp(e);if(!t)return``;let n=t.split(`/`).filter(Boolean);return n[n.length-1]||t},fp=(e,t)=>dp(e?e.path:t),pp=`h-12 w-full rounded-[16px] border border-border/70 bg-surface-elevated px-4 text-center text-[16px] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-primary focus:ring-2 focus:ring-primary/20`,mp=({connection:e})=>{let{t}=ce(),n=e,{connections:r,isBusy:i,isPasswordBusy:a,error:o,pendingConnection:s}=n,[c,l]=Z.useState(``),[u,d]=Z.useState(``),[f,p]=Z.useState(``),[m,h]=Z.useState(!1),g=Z.useMemo(()=>zu(),[]),[_,v]=Z.useState(()=>!zu()),[y,b]=Z.useState(null),[x,S]=Z.useState(``),C=W(e=>{e.preventDefault(),n.connect({url:c,clientToken:f,label:u})}),w=W(e=>{n.redeemPairingConnection(e)}),T=W(()=>{n.setError(t(`mobile.connect.link.invalid`))}),E=W(async()=>{if(!(m||i)){n.setError(null),h(!0);try{let e=await Bu();switch(e.status){case`ok`:l(e.url),e.label&&d(e.label),e.clientToken&&p(e.clientToken),await n.connect({url:e.url,clientToken:e.clientToken,label:e.label});break;case`pairing`:await n.redeemPairingConnection(e.pairing);break;case`permission-denied`:n.setError(t(`mobile.connect.scan.permissionDenied`));break;case`invalid`:n.setError(t(`mobile.connect.scan.invalid`));break;case`unsupported`:n.setError(t(`mobile.connect.scan.unsupported`));break;case`failed`:n.setError(t(`mobile.connect.scan.failed`))}}finally{h(!1)}}}),D=W(e=>{e.preventDefault(),n.submitPassword(x)}),O=W(()=>{S(``),n.cancelPassword()});return(0,$.jsx)(`main`,{className:`oc-keyboard-fill-screen flex min-h-dvh flex-col overflow-y-auto bg-background px-6 pb-[calc(var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))+28px)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+28px)] text-foreground`,children:(0,$.jsxs)(`div`,{className:`m-auto flex w-full max-w-[360px] shrink-0 flex-col items-center gap-9 py-8`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-5 text-center`,children:[(0,$.jsx)(wn,{width:72,height:72,className:`size-[72px]`}),(0,$.jsx)(`h1`,{className:`typography-h2 text-foreground`,children:t(`mobile.connect.welcome.title`)})]}),s?(0,$.jsxs)(`form`,{className:`flex w-full flex-col gap-3`,onSubmit:D,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3`,children:[(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground`,children:(0,$.jsx)(X,{name:`lock`,className:`size-[18px]`})}),(0,$.jsxs)(`div`,{className:`min-w-0 text-left`,children:[(0,$.jsx)(`p`,{className:`truncate typography-ui-label text-foreground`,children:s.label}),(0,$.jsx)(`p`,{className:`truncate typography-small text-muted-foreground`,children:s.candidates.some(e=>e.kind===`direct`)?de(s):t(`mobile.connect.relay.badge`)})]})]}),(0,$.jsx)(`input`,{...lp,value:x,onChange:e=>S(e.target.value),placeholder:t(`mobile.connect.password.placeholder`),"aria-label":t(`mobile.connect.password.label`),type:`password`,autoFocus:!0,className:`h-12 w-full rounded-[16px] border border-border/70 bg-surface-elevated px-4 text-[16px] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-primary focus:ring-2 focus:ring-primary/20`}),o?(0,$.jsx)(`p`,{className:`px-1 text-center typography-small text-[var(--status-error)]`,children:o}):null,(0,$.jsx)(q,{type:`submit`,size:`lg`,className:`mt-1 h-12 w-full`,disabled:a||!x.trim(),children:t(a?`mobile.connect.connecting`:`mobile.connect.unlockButton`)}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`w-full`,onClick:O,children:t(`mobile.connect.cancelPassword`)})]}):(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-6`,children:[g?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,children:[(0,$.jsxs)(q,{type:`button`,size:`lg`,className:`h-12 w-full`,onClick:()=>void E(),disabled:m||i,children:[(0,$.jsx)(X,{name:`scan-2`,className:K(`size-[18px]`,m&&`animate-pulse`)}),t(i?`mobile.connect.connecting`:`mobile.connect.scanQr`)]}),(0,$.jsx)(`p`,{className:`px-2 text-center typography-small text-muted-foreground`,children:t(`mobile.connect.welcome.scanHint`)})]}):null,o&&!_?(0,$.jsx)(`p`,{className:`px-1 text-center typography-small text-[var(--status-error)]`,children:o}):null,r.length>0?(0,$.jsxs)(`section`,{className:`flex w-full flex-col gap-2.5`,children:[(0,$.jsx)(`h2`,{className:`text-center typography-micro uppercase tracking-[0.14em] text-muted-foreground`,children:t(`mobile.connect.saved.title`)}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated`,children:r.map(e=>{let r=y===e.id;return(0,$.jsxs)(`button`,{type:`button`,disabled:i,className:`flex min-h-14 w-full items-center gap-3 border-b border-border/60 px-3.5 py-2.5 text-left last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:opacity-70`,onClick:()=>{b(e.id),n.connect({id:e.id,candidates:e.candidates,clientToken:e.clientToken,label:e.label}).finally(()=>b(null))},children:[(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground`,children:(0,$.jsx)(X,{name:`server`,className:`size-[18px]`})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:e.label}),(0,$.jsx)(`span`,{className:K(`block truncate typography-small`,r?`text-foreground`:`text-muted-foreground`),children:t(r?`mobile.connect.connecting`:`mobile.instances.status.saved`)})]}),r?(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin text-muted-foreground`}):(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-5 text-muted-foreground`})]},e.id)})})]}):null,(0,$.jsxs)(`div`,{className:`flex w-full flex-col`,children:[g?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>v(e=>!e),"aria-expanded":_,className:`mx-auto flex items-center gap-1 rounded-full px-2 py-1 typography-small text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:[(0,$.jsx)(`span`,{children:t(`mobile.connect.manual.toggle`)}),(0,$.jsx)(X,{name:`arrow-down-s`,className:K(`size-4 transition-transform duration-200`,_&&`rotate-180`)})]}):null,(0,$.jsx)(`div`,{className:`grid transition-[grid-template-rows] duration-200 ease-out`,style:{gridTemplateRows:_?`1fr`:`0fr`},children:(0,$.jsxs)(`div`,{className:`min-h-0 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`pt-3`,children:(0,$.jsx)(Hu,{disabled:i||m,isBusy:i,tabIndex:_?void 0:-1,inputClassName:pp,buttonVariant:g?`outline`:`default`,onRedeem:w,onInvalid:T})}),(0,$.jsx)(Uu,{label:t(`mobile.connect.address.divider`)}),(0,$.jsxs)(`form`,{className:`flex w-full flex-col gap-3`,onSubmit:C,children:[(0,$.jsx)(`input`,{...lp,value:c,onChange:e=>l(e.target.value),placeholder:t(`mobile.connect.url.placeholder`),"aria-label":t(`mobile.connect.url.label`),type:`url`,inputMode:`url`,autoCapitalize:`none`,tabIndex:_?void 0:-1,className:pp}),(0,$.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),placeholder:t(`mobile.instances.label.placeholder`),"aria-label":t(`mobile.instances.label.label`),autoComplete:`off`,autoCapitalize:`words`,autoCorrect:`off`,spellCheck:!1,tabIndex:_?void 0:-1,className:pp}),(0,$.jsx)(`input`,{...lp,value:f,onChange:e=>p(e.target.value),placeholder:t(`mobile.connect.token.placeholder`),"aria-label":t(`mobile.connect.token.label`),tabIndex:_?void 0:-1,autoCapitalize:`none`,className:pp}),(0,$.jsx)(`p`,{className:`px-1 text-center typography-micro text-muted-foreground`,children:t(`mobile.connect.token.hint`)}),(0,$.jsx)(q,{type:`submit`,variant:`outline`,size:`lg`,className:`h-12 w-full`,disabled:i||m||!c.trim(),children:t(i?`mobile.connect.connecting`:`mobile.connect.connectButton`)})]}),o?(0,$.jsx)(`p`,{className:`px-1 pt-3 text-center typography-small text-[var(--status-error)]`,children:o}):null]})})]})]})]})})},hp=({connection:e,onActiveConnectionDeleted:t,onConnect:n})=>{let{t:r}=ce(),i=e,{connections:a,isBusy:o,isPasswordBusy:s,error:c,pendingConnection:l,connect:u,submitPassword:d,cancelPassword:f,saveConnection:p,removeConnection:m,subscribeConnected:h,setError:g}=i,[_,v]=Z.useState(null),y=_?a.find(e=>e.id===_)??null:null,b=y?!y.candidates.some(e=>e.kind===`direct`):!1,[x,S]=Z.useState(null),[C,w]=Z.useState(``),[T,E]=Z.useState(``),[D,O]=Z.useState(``),[k,A]=Z.useState(``),[j,M]=Z.useState(!1),N=Z.useMemo(()=>zu(),[]),[P,F]=Z.useState(!1),[ee,I]=Z.useState(null),L=W(n);Z.useEffect(()=>h(L),[L,h]);let R=W(()=>{v(null),w(``),E(``),O(``),g(null),F(!1)}),z=W(e=>{e.preventDefault(),p({id:_??void 0,url:C,label:T,clientToken:D}).then(e=>{e&&R()})}),te=W(e=>{i.redeemPairingConnection(e)}),ne=W(()=>{g(r(`mobile.connect.link.invalid`))}),B=W(async()=>{if(!j){g(null),M(!0);try{let e=await Bu();switch(e.status){case`ok`:w(e.url),e.label&&E(e.label),e.clientToken&&O(e.clientToken),F(!0);break;case`pairing`:await i.redeemPairingConnection(e.pairing);break;case`permission-denied`:g(r(`mobile.connect.scan.permissionDenied`));break;case`invalid`:g(r(`mobile.connect.scan.invalid`));break;case`unsupported`:g(r(`mobile.connect.scan.unsupported`));break;case`failed`:g(r(`mobile.connect.scan.failed`))}}finally{M(!1)}}}),V=W(e=>{e.preventDefault(),d(k)}),H=W(()=>{A(``),f()}),U=W(e=>{S(t=>t===e?null:e)}),re=W(e=>{S(null),_===e&&R();let n=a.length===1;m(e).then(e=>{e&&(n||ye(e))&&t()})}),ie=`h-12 w-full rounded-[16px] border border-border/70 bg-surface-elevated px-4 text-[16px] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-primary focus:ring-2 focus:ring-primary/20`;return l?(0,$.jsx)(`div`,{className:`oc-settings-page-content`,children:(0,$.jsx)(Er,{label:r(`mobile.connect.password.label`),itemId:`instances.manage`,children:(0,$.jsxs)(`form`,{className:`oc-settings-group-row flex flex-col gap-3`,onSubmit:V,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3`,children:[(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground`,children:(0,$.jsx)(X,{name:`lock`,className:`size-[18px]`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`truncate typography-ui-label text-foreground`,children:l.label}),(0,$.jsx)(`p`,{className:`truncate typography-small text-muted-foreground`,children:l.candidates.some(e=>e.kind===`direct`)?de(l):r(`mobile.connect.relay.badge`)})]})]}),(0,$.jsx)(`input`,{...lp,value:k,onChange:e=>A(e.target.value),placeholder:r(`mobile.connect.password.placeholder`),"aria-label":r(`mobile.connect.password.label`),type:`password`,autoFocus:!0,className:ie}),c?(0,$.jsx)(`p`,{className:`px-1 typography-small text-[var(--status-error)]`,children:c}):null,(0,$.jsx)(q,{type:`submit`,size:`lg`,className:`mt-1 h-12 w-full`,disabled:s||!k.trim(),children:r(s?`mobile.connect.connecting`:`mobile.connect.unlockButton`)}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`w-full`,onClick:H,children:r(`mobile.connect.cancelPassword`)})]})})}):(0,$.jsxs)(`div`,{className:`oc-settings-page-content`,children:[(0,$.jsx)(Er,{label:r(`mobile.connect.saved.title`),itemId:`instances.manage`,children:a.length>0?a.map(e=>{let t=x===e.id,n=ye(e),i=ee===e.id,a=r(i?`mobile.connect.connecting`:n?`mobile.instances.status.connected`:`mobile.instances.status.saved`);return(0,$.jsxs)(`div`,{className:K(`oc-settings-group-row relative flex items-center`,t&&`bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]`),children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":r(`desktopHostSwitcher.actions.switchToAria`,{instance:e.label}),"data-mobile-press-feedback":`none`,className:`absolute inset-0 z-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:pointer-events-none`,onClick:()=>{n||(I(e.id),u({id:e.id,candidates:e.candidates,clientToken:e.clientToken,label:e.label}).finally(()=>I(null)))},disabled:n||o&&!i||t,style:{touchAction:`manipulation`}}),(0,$.jsxs)(`div`,{className:`pointer-events-none relative z-[1] flex min-w-0 flex-1 items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`relative flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground`,children:(0,$.jsx)(X,{name:`server`,className:`size-[18px]`})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:e.label})}),(0,$.jsx)(`span`,{className:K(`block truncate typography-small`,n&&!i?`text-[var(--status-success)]`:`text-muted-foreground`),children:a})]})]}),(0,$.jsxs)(`div`,{className:`relative z-10 flex shrink-0 items-center gap-0.5 pr-2`,children:[t?(0,$.jsxs)(`button`,{type:`button`,"aria-label":r(`mobile.instances.confirmDeleteAria`,{label:e.label}),className:`flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-destructive px-3 text-destructive-foreground transition-opacity active:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive`,onClick:()=>re(e.id),style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-[18px]`}),(0,$.jsx)(`span`,{className:`typography-ui-label`,children:r(`mobile.instances.delete`)})]}):i?(0,$.jsx)(`span`,{className:`flex size-9 items-center justify-center text-muted-foreground`,"aria-hidden":!0,children:(0,$.jsx)(X,{name:`loader-4`,className:`size-[18px] animate-spin`})}):(0,$.jsx)(`button`,{type:`button`,"aria-label":r(`mobile.instances.edit`),className:`flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:()=>{v(e.id),w(e.candidates.some(e=>e.kind===`direct`)?de(e):``),E(e.label),O(e.clientToken||``),g(null)},style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`edit`,className:`size-[18px]`})}),(0,$.jsx)(`button`,{type:`button`,"aria-label":r(t?`mobile.instances.cancelDeleteAria`:`mobile.instances.deleteAria`,{label:e.label}),className:`flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:()=>U(e.id),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:t?`close`:`delete-bin`,className:`size-[18px]`})})]})]},e.id)}):(0,$.jsx)(`div`,{className:`oc-settings-group-row flex items-center justify-center text-center typography-small text-muted-foreground`,children:r(`mobile.connect.saved.empty`)})}),(0,$.jsx)(Er,{label:r(y?`mobile.instances.editTitle`:`mobile.instances.addTitle`),children:!P&&!y?(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex flex-col items-stretch gap-2`,children:[N?(0,$.jsxs)(q,{type:`button`,size:`lg`,className:`h-12 w-full`,onClick:()=>void B(),disabled:j,children:[(0,$.jsx)(X,{name:`scan-2`,className:K(`size-[18px]`,j&&`animate-pulse`)}),r(`mobile.connect.scanQr`)]}):null,(0,$.jsxs)(q,{type:`button`,variant:N?`ghost`:`outline`,size:`lg`,className:`h-12 w-full`,onClick:()=>{g(null),F(!0)},children:[(0,$.jsx)(X,{name:`add`,className:`size-[18px]`}),r(`mobile.instances.addManual`)]}),c?(0,$.jsx)(`p`,{className:`px-1 text-center typography-small text-[var(--status-error)]`,children:c}):null]}):(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex flex-col gap-3`,children:[(0,$.jsx)(`div`,{className:`flex min-h-8 items-center justify-end px-1`,children:(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,onClick:R,children:r(`mobile.instances.cancelEdit`)})}),(0,$.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:z,children:[b?null:(0,$.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,$.jsx)(`span`,{className:`block px-1 typography-ui-label text-foreground`,children:r(`mobile.connect.url.label`)}),(0,$.jsx)(`input`,{...lp,value:C,onChange:e=>w(e.target.value),placeholder:r(`mobile.connect.url.placeholder`),type:`url`,inputMode:`url`,autoCapitalize:`none`,className:ie})]}),(0,$.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,$.jsx)(`span`,{className:`block px-1 typography-ui-label text-foreground`,children:r(`mobile.instances.label.label`)}),(0,$.jsx)(`input`,{value:T,onChange:e=>E(e.target.value),placeholder:r(`mobile.instances.label.placeholder`),autoComplete:`off`,autoCapitalize:`words`,autoCorrect:`off`,spellCheck:!1,className:ie})]}),(0,$.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,$.jsx)(`span`,{className:`block px-1 typography-ui-label text-foreground`,children:r(`mobile.connect.token.label`)}),(0,$.jsx)(`input`,{...lp,value:D,onChange:e=>O(e.target.value),placeholder:r(`mobile.connect.token.placeholder`),autoCapitalize:`none`,className:ie}),(0,$.jsx)(`p`,{className:`px-1 typography-micro text-muted-foreground`,children:r(`mobile.connect.token.hint`)})]}),(0,$.jsx)(q,{type:`submit`,size:`lg`,className:`mt-1 h-12 w-full`,children:r(y?`mobile.instances.saveEdit`:`mobile.instances.saveNew`)})]}),y?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Uu,{label:r(`mobile.connect.link.divider`)}),(0,$.jsx)(Hu,{disabled:o||j,isBusy:o,inputClassName:ie,onRedeem:te,onInvalid:ne})]}),c?(0,$.jsx)(`p`,{className:`px-1 typography-small text-[var(--status-error)]`,children:c}):null]})})]})},gp=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`},_p=e=>{let t=(0,Q.c)(13),{icon:n,iconNode:r,label:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=r??(n?(0,$.jsx)(X,{name:n,className:`size-[18px]`}):null),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]===o?s=t[4]:(s=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:o}),t[3]=o,t[4]=s);let c;t[5]===i?c=t[6]:(c=(0,$.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:i}),t[5]=i,t[6]=c);let l;t[7]===a?l=t[8]:(l=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground`,children:a}),t[7]=a,t[8]=l);let u;return t[9]!==s||t[10]!==c||t[11]!==l?(u=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5`,children:[s,c,l]}),t[9]=s,t[10]=c,t[11]=l,t[12]=u):u=t[12],u},vp=e=>{let t=(0,Q.c)(55),{open:n,onClose:r,anchorRef:i,contextDisplay:a,branchLabel:o,usageGroups:s,usageDisplayMode:c,isUsageLoading:l,timeFormatPreference:u}=e,{t:d}=ce(),f=Z.useRef(null),[p,m]=Z.useState(n),[h,g]=Z.useState(!1),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=A(),t[0]=_):_=t[0];let v=_,y=Z.useRef(null),[b,x]=Z.useState(null),S,C;t[1]!==i||t[2]!==n||t[3]!==p?(S=()=>{if(!n||!v||!p)return;let e=()=>{let e=i.current?.getBoundingClientRect(),t=y.current?.getBoundingClientRect();if(!e||!t){x(null);return}let n=e.left-t.left,r=Math.min(Math.max(n,8),Math.max(8,t.width-$f-8));x(r)};e();let t=y.current;if(typeof ResizeObserver>`u`||!t)return;let r=new ResizeObserver(e);return r.observe(t),()=>r.disconnect()},C=[i,v,n,p],t[1]=i,t[2]=n,t[3]=p,t[4]=S,t[5]=C):(S=t[4],C=t[5]),Z.useLayoutEffect(S,C);let w=v&&b!==null,T,E;t[6]!==n||t[7]!==p?(T=()=>{if(n){m(!0),g(!1);return}if(!p)return;g(!0);let e=window.setTimeout(()=>{m(!1),g(!1)},140);return()=>window.clearTimeout(e)},E=[n,p],t[6]=n,t[7]=p,t[8]=T,t[9]=E):(T=t[8],E=t[9]),Z.useEffect(T,E);let D,O;t[10]!==r||t[11]!==n?(D=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},O=[r,n],t[10]=r,t[11]=n,t[12]=D,t[13]=O):(D=t[12],O=t[13]),Z.useEffect(D,O);let k,j;if(t[14]!==i||t[15]!==r||t[16]!==n?(k=()=>{if(!n)return;let e=e=>{let t=e.target;if(!(t instanceof Node)){r();return}f.current?.contains(t)||i.current?.contains(t)||r()};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`wheel`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`wheel`,e,!0)}},j=[i,r,n],t[14]=i,t[15]=r,t[16]=n,t[17]=k,t[18]=j):(k=t[17],j=t[18]),Z.useEffect(k,j),!p)return null;let M;t[19]===d?M=t[20]:(M=d(`mobile.header.openMetadataAria`),t[19]=d,t[20]=M);let N=w?`absolute origin-top-left`:`mx-3 mt-2`,P=h?`pointer-events-none`:`pointer-events-auto`,F;t[21]!==N||t[22]!==P?(F=K(`overflow-x-hidden overflow-y-auto overscroll-contain rounded-[20px] oc-mobile-overlay-surface p-2 will-change-transform`,N,P),t[21]=N,t[22]=P,t[23]=F):F=t[23];let ee=`${h?`session-metadata-out`:`session-metadata-in`} ${h?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,I;t[24]!==b||t[25]!==w?(I=w?{top:8,left:b??8,width:`min(${$f}px, calc(100% - 16px))`}:null,t[24]=b,t[25]=w,t[26]=I):I=t[26];let L;t[27]!==ee||t[28]!==I?(L={animation:ee,maxHeight:`min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))`,...I},t[27]=ee,t[28]=I,t[29]=L):L=t[29];let R;t[30]===d?R=t[31]:(R=d(`mobile.header.metadata.branch`),t[30]=d,t[31]=R);let z;t[32]!==o||t[33]!==R?(z=(0,$.jsx)(_p,{icon:`git-branch`,label:R,children:o}),t[32]=o,t[33]=R,t[34]=z):z=t[34];let te;t[35]!==a||t[36]!==d?(te=a?(0,$.jsx)(_p,{iconNode:(0,$.jsx)(Fl,{percentage:a.percentage,pending:a.pending}),label:d(`mobile.header.metadata.context`),children:(0,$.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5 tabular-nums`,children:[(0,$.jsx)(`span`,{className:K(`font-semibold`,a.colorClass),children:a.pending?d(`contextUsage.pending`):`${a.percentage.toFixed(1)}%`}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:a.tokens})]})}):null,t[35]=a,t[36]=d,t[37]=te):te=t[37];let ne;t[38]!==l||t[39]!==u||t[40]!==c||t[41]!==s?(ne=(0,$.jsx)(yp,{groups:s,displayMode:c,isLoading:l,timeFormatPreference:u}),t[38]=l,t[39]=u,t[40]=c,t[41]=s,t[42]=ne):ne=t[42];let B;t[43]!==z||t[44]!==te||t[45]!==ne?(B=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[z,te,ne]}),t[43]=z,t[44]=te,t[45]=ne,t[46]=B):B=t[46];let V;t[47]!==M||t[48]!==F||t[49]!==L||t[50]!==B?(V=(0,$.jsx)(`div`,{ref:f,role:`dialog`,"aria-label":M,className:F,style:L,children:B}),t[47]=M,t[48]=F,t[49]=L,t[50]=B,t[51]=V):V=t[51];let H;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(`style`,{children:`
20
- @keyframes session-metadata-in {
21
- from { opacity: 0; transform: translateY(-8px) scale(0.985); }
22
- to { opacity: 1; transform: translateY(0) scale(1); }
23
- }
24
- @keyframes session-metadata-out {
25
- from { opacity: 1; transform: translateY(0) scale(1); }
26
- to { opacity: 0; transform: translateY(-6px) scale(0.985); }
27
- }
28
- `}),t[52]=H):H=t[52];let U;return t[53]===V?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:[V,H]}),t[53]=V,t[54]=U),U},yp=e=>{let t=(0,Q.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=ce(),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)(fn,{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:`min-w-0 max-w-[60%] 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=On(e.window.valueLabel,t),i=bn(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:`min-w-0 truncate typography-micro text-muted-foreground/70`,children:i}):null]}),(0,$.jsx)(`span`,{className:K(`min-w-0 max-w-[60%] shrink-0 truncate typography-ui-label font-semibold tabular-nums`,gp(e.window)),children:n===`-`?``:n})]},e.key)})}):null,e.status&&e.rows.length>0?(0,$.jsx)(`div`,{className:`mt-1.5 truncate typography-micro text-muted-foreground`,title:e.status,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},bp=e=>{let t=(0,Q.c)(35),{open:n,onClose:r,items:i,rightOffset:a}=e,o=a===void 0?0:a,{t:s}=ce(),c,l;if(t[0]!==r||t[1]!==n?(c=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},l=[r,n],t[0]=r,t[1]=n,t[2]=c,t[3]=l):(c=t[2],l=t[3]),Z.useEffect(c,l),!n)return null;let u;t[4]===r?u=t[5]:(u=(e,t,n)=>(0,$.jsxs)(`button`,{type:`button`,role:n===void 0?`menuitem`:`menuitemcheckbox`,"aria-checked":n,className:K(`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:K(`size-5 shrink-0 text-muted-foreground`,e.spinning&&`animate-spin`,e.key===`auto-read`&&`translate-x-px`)}):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,n&&(0,$.jsx)(X,{name:`check`,className:`size-4 shrink-0 text-muted-foreground`})]},e.key),t[4]=r,t[5]=u);let d=u,f;t[6]===s?f=t[7]:(f=s(`mobile.menu.titleAria`),t[6]=s,t[7]=f);let p;t[8]===s?p=t[9]:(p=s(`mobile.surface.closeAria`),t[8]=s,t[9]=p);let m;t[10]===r?m=t[11]:(m=e=>{e.preventDefault(),r()},t[10]=r,t[11]=m);let h;t[12]!==p||t[13]!==m?(h=(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":p,onPointerDown:m}),t[12]=p,t[13]=m,t[14]=h):h=t[14];let g=`max(1rem, calc(8px + ${o}px + var(--oc-safe-area-right, 0px)))`,_;t[15]===g?_=t[16]:(_={right:g,animation:`mobile-menu-in 160ms cubic-bezier(0.32, 0.72, 0, 1) forwards`},t[15]=g,t[16]=_);let v;if(t[17]!==i||t[18]!==d){let e;t[20]===d?e=t[21]:(e=(e,t)=>d(e,t),t[20]=d,t[21]=e),v=i.map(e),t[17]=i,t[18]=d,t[19]=v}else v=t[19];let y;t[22]!==i.length||t[23]!==d||t[24]!==s?(y=(0,$.jsx)(Oa,{children:e=>{let{enabled:t,available:n,toggle:r}=e;return d({key:`auto-read`,icon:`volume-up`,label:s(`mobile.menu.autoRead`),disabled:!n,onSelect:r},i.length,t)}}),t[22]=i.length,t[23]=d,t[24]=s,t[25]=y):y=t[25];let b;t[26]!==_||t[27]!==v||t[28]!==y?(b=(0,$.jsxs)(`div`,{id:Jf,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:_,onAnimationEnd:Tp,children:[v,y]}),t[26]=_,t[27]=v,t[28]=y,t[29]=b):b=t[29];let x;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(x=(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[30]=x):x=t[30];let S;return t[31]!==b||t[32]!==f||t[33]!==h?(S=(0,$.jsxs)(`div`,{className:`pointer-events-none fixed inset-0 z-50`,role:`dialog`,"aria-modal":`true`,"aria-label":f,children:[h,b,x]}),t[31]=b,t[32]=f,t[33]=h,t[34]=S):S=t[34],S},xp=Z.memo(function(e){let t=(0,Q.c)(94),{open:n,onOpenChange:r,currentSessionId:i,effectiveDirectory:a,gitDirectory:o,isNewSessionDraftOpen:s,primaryLabel:c,secondaryLabel:l}=e,{t:u}=ce(),{git:d}=ee(),f=gu(i??``,a||void 0),p=f??l,m=Z.useRef(null),h=rt(i??``,a||void 0),g=er(o),_=rr(o),v=ir(Ep),y=ir(Dp),b=vt(Op),x=vt(kp),S=vt(Ap),C=vt(jp),w;t[0]===i?w=t[1]:(w=e=>i?e.sessionModelSelections.get(i)??null:null,t[0]=i,t[1]=w);let T=De(w),E=Ar(Mp),D=Ar(Np),O=Ar(Pp),k=Ar(Fp),A=Ar(Ip),j=Ar(Lp),N=Ar(Rp),P=M(zp);kr();let F,I;t[2]!==v||t[3]!==d||t[4]!==o?(F=()=>{o&&v(o,d)},I=[v,d,o],t[2]=v,t[3]=d,t[4]=o,t[5]=F,t[6]=I):(F=t[5],I=t[6]),Z.useEffect(F,I);let L,R;t[7]!==y||t[8]!==d||t[9]!==o?(L=()=>{if(o)return nt.onGitRefreshHint(e=>{cp(e.directory)===o&&y(o,d)})},R=[y,d,o],t[7]=y,t[8]=d,t[9]=o,t[10]=L,t[11]=R):(L=t[10],R=t[11]),Z.useEffect(L,R);let z,te;t[12]===D?(z=t[13],te=t[14]):(z=()=>{D()},te=[D],t[12]=D,t[13]=z,t[14]=te),Z.useEffect(z,te);let ne,B;t[15]===j?(ne=t[16],B=t[17]):(ne=()=>{dn(j)},B=[j],t[15]=j,t[16]=ne,t[17]=B),Z.useEffect(ne,B);let V,H;t[18]!==j||t[19]!==O||t[20]!==k||t[21]!==n||t[22]!==E?(V=()=>{!n||k||j.some(e=>!E.some(t=>t?.providerId===e))&&O()},H=[j,O,k,n,E],t[18]=j,t[19]=O,t[20]=k,t[21]=n,t[22]=E,t[23]=V,t[24]=H):(V=t[23],H=t[24]),Z.useEffect(V,H);let U;t[25]===h?U=t[26]:(U=Vl(h),t[25]=h,t[26]=U);let re=U,ie;t[27]!==S||t[28]!==x||t[29]!==re||t[30]!==T?(ie=re??(T?{providerID:T.providerId,modelID:T.modelId}:null)??(x&&S?{providerID:x,modelID:S}:null),t[27]=S,t[28]=x,t[29]=re,t[30]=T,t[31]=ie):ie=t[31];let ae=ie,W;if(t[32]!==C||t[33]!==ae||t[34]!==b){let e=(ae?b.find(e=>e.id===ae.providerID):void 0)?.models.find(e=>e.id===ae?.modelID),n;t[36]!==C||t[37]!==ae?(n=ae?C(ae.providerID,ae.modelID):void 0,t[36]=C,t[37]=ae,t[38]=n):n=t[38];let r=n;W=Ll(e?.limit,`context`)??r?.limit?.context??0,t[32]=C,t[33]=ae,t[34]=b,t[35]=W}else W=t[35];let oe=W,se=_t(i??``,oe,0,a||void 0),G=se?.pending?null:se?.totalTokens??0,q;t[39]!==oe||t[40]!==s||t[41]!==G?(q=Bl({totalTokens:G,contextLimit:oe,isDraft:s}),t[39]=oe,t[40]=s,t[41]=G,t[42]=q):q=t[42];let J=q,le;t[43]!==_?.current||t[44]!==g||t[45]!==u?(le=g===!0?_?.current?.trim()||u(`gitView.branch.detachedHead`):u(`common.unavailable`),t[43]=_?.current,t[44]=g,t[45]=u,t[46]=le):le=t[46];let ue=le,de;if(t[47]!==j||t[48]!==E||t[49]!==N||t[50]!==u){let e=new Map(E.map(Bp)),n;t[52]===j?n=t[53]:(n=e=>j.includes(e.id),t[52]=j,t[53]=n),de=Dr(E).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(t.label??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(a.label??i),subtitle:Mr(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[47]=j,t[48]=E,t[49]=N,t[50]=u,t[51]=de}else de=t[51];let Y=de,fe,pe;t[54]!==n||t[55]!==Y?(fe=()=>{!n||Y.length===0||dn(Y.map(Vp))},pe=[n,Y],t[54]=n,t[55]=Y,t[56]=fe,t[57]=pe):(fe=t[56],pe=t[57]),Z.useEffect(fe,pe);let me;t[58]===c?me=t[59]:(me=(0,$.jsx)(`span`,{className:`block truncate typography-ui-label text-foreground`,children:c}),t[58]=c,t[59]=me);let he;t[60]!==p||t[61]!==f?(he=p?(0,$.jsx)(`span`,{className:K(`block truncate`,f?`oc-mobile-detail-subtitle text-muted-foreground`:`typography-micro text-muted-foreground`),"aria-live":`polite`,children:p}):null,t[60]=p,t[61]=f,t[62]=he):he=t[62];let ge;t[63]!==me||t[64]!==he?(ge=(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:[me,he]})}),t[63]=me,t[64]=he,t[65]=ge):ge=t[65];let _e;t[66]===u?_e=t[67]:(_e=u(`mobile.header.openMetadataAria`),t[66]=u,t[67]=_e);let ve;t[68]===r?ve=t[69]:(ve=()=>r(Hp),t[68]=r,t[69]=ve);let ye;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ye={touchAction:`manipulation`},t[70]=ye):ye=t[70];let be=J?.percentage??0,xe=J?.pending,Se;t[71]!==be||t[72]!==xe?(Se=(0,$.jsx)(Fl,{percentage:be,pending:xe}),t[71]=be,t[72]=xe,t[73]=Se):Se=t[73];let Ce;t[74]!==n||t[75]!==_e||t[76]!==ve||t[77]!==Se?(Ce=(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":_e,"aria-expanded":n,onClick:ve,style:ye,children:Se}),t[74]=n,t[75]=_e,t[76]=ve,t[77]=Se,t[78]=Ce):Ce=t[78];let we;t[79]===r?we=t[80]:(we=()=>r(!1),t[79]=r,t[80]=we);let Te;t[81]!==ue||t[82]!==J||t[83]!==k||t[84]!==n||t[85]!==A||t[86]!==we||t[87]!==P||t[88]!==Y?(Te=(0,$.jsx)(vp,{open:n,onClose:we,anchorRef:m,contextDisplay:J,branchLabel:ue,usageGroups:Y,usageDisplayMode:A,isUsageLoading:k,timeFormatPreference:P}),t[81]=ue,t[82]=J,t[83]=k,t[84]=n,t[85]=A,t[86]=we,t[87]=P,t[88]=Y,t[89]=Te):Te=t[89];let Ee;return t[90]!==ge||t[91]!==Ce||t[92]!==Te?(Ee=(0,$.jsxs)($.Fragment,{children:[ge,Ce,Te]}),t[90]=ge,t[91]=Ce,t[92]=Te,t[93]=Ee):Ee=t[93],Ee}),Sp=({onOpenSessions:e,menuOpen:t,onToggleMenu:n,surfaceShortcuts:r})=>{let{t:i}=ce(),[a,o]=Z.useState(!1),s=T(e=>e.currentDirectory),c=it(e=>e.currentSessionId),l=Z.useMemo(()=>e=>c?e.getDirectoryForSession(c):null,[c]),u=it(l)||s,d=cp(u)||null,f=lt(e=>e.projects),p=it(e=>e.availableWorktreesByProject),m=Z.useMemo(()=>e=>c?e.worktreeMetadata.get(c)??null:null,[c]),h=it(m),g=Je(c),_=it(e=>!!e.newSessionDraft?.open),v=Z.useMemo(()=>{let e=cp(u);return e&&fp((h?.projectDirectory?Oe(f,h.projectDirectory):null)??Ye(f,p,e),e)||i(`mobile.header.noProject`)},[p,h?.projectDirectory,u,f,i]),y=g?.title?.trim()||(c?i(`mobile.sessions.untitled`):v),b=c?v:``;Z.useEffect(()=>{o(!1)},[c,u]);let x=W(()=>{o(!1),e()}),S=W(()=>{o(!1),n()});return(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(ao,{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)(xp,{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:K(`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:K(`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":Jf,"aria-expanded":t,"aria-haspopup":`menu`,onClick:S,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`more-2`,className:`size-5`})})]})})},Cp=({connection:e,onActiveConnectionDeleted:t})=>{let{t:n}=ce(),r=Jt();Pe(),Xe();let i=M(e=>e.mobileSessionPanelOpen),a=M(e=>e.setMobileSessionPanelOpen),o=M(e=>e.isScheduledTasksDialogOpen),s=M(e=>e.activeMainTab),c=xe(),l=M(e=>e.setActiveMainTab),[u,d]=Z.useState(!1),[f,p]=Z.useState(!1),[m,h]=Z.useState(null),[g,_]=Z.useState(!1),[v,y]=Z.useState(!1),[b,x]=Z.useState(null),[S,C]=Z.useState(null),[w,E]=Z.useState(null),[D,O]=Z.useState(0),[k,j]=Z.useState(!1),[N,P]=Z.useState(!1),[F,ee]=Z.useState(!1),[I,L]=Z.useState(!1),[R,z]=Z.useState(!1),[te,ne]=Z.useState(!1),[B,V]=Z.useState(`nav`),[H,U]=Z.useState(!1),[re,ae]=Z.useState(!1),oe=W(()=>U(e=>!e)),se=W(()=>U(!1)),[G,J]=Z.useState(null),le=T(e=>e.currentDirectory),ue=M(e=>e.setSettingsPage),de=Tr(e=>e.available),Y=Tr(e=>e.runtimeType),fe=Z.useMemo(()=>ip(),[]),pe=Z.useMemo(()=>zu(),[]),{data:me=[],refetch:he}=Pi(le??null,{enabled:k}),{refetch:ge}=Fi(le??null,{enabled:k}),_e=Vi(e=>e.setMcpDraft),ve=Vi(e=>e.setSelectedMcp),ye=rr(cp(le)||null)?.files?.length??0;Z.useEffect(()=>nt.onDirectoryRequest(()=>z(!0)),[]);let be=Z.useMemo(()=>A(),[]),Se=Nn()===`portrait`,[we,Te]=Z.useState(be&&!Se),[Ee,De]=Z.useState(null),Oe=W(e=>{if(e&&ue(e),be){V(e?`page-content`:`nav`),ee(!0);return}let t=mt.getState();if(e){t.openSettingsFromCurrent();return}ue(`home`),t.setActiveTab(`settings`)}),ke=W(()=>{Oe(`instances`)}),Ae=W(()=>{mt.getState().openInstances()}),je=W(()=>{mt.getState().closeSecondary()}),Me=W(async()=>{if(!te){ne(!0);try{let t=await Bu();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`:ie.error(n(`mobile.connect.scan.permissionDenied`));break;case`invalid`:ie.error(n(`mobile.connect.scan.invalid`));break;case`unsupported`:ie.error(n(`mobile.connect.scan.unsupported`));break;case`failed`:ie.error(n(`mobile.connect.scan.failed`))}}finally{ne(!1)}}});Zi({enabled:!be,rootRoutesBlocked:i||u||f||g||v||o||k||F||I||R||H});let Ne=W(()=>{let e=!we;e&&Se&&De(null),Te(e)}),Fe=W(()=>{if(y(!1),x(null),C(null),p(!1),h(null),be){J(null),De(`files`),Se&&Te(!1);return}d(!0)}),Ie=W(()=>{p(!1),h(null)}),Le=W(e=>{let t=e.path.trim();if(t){if(y(!1),x(null),C(null),J(null),_(!1),be){M.getState().setPendingFileFocusPath(t),De(`files`),Se&&Te(!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)}}),Re=M(e=>e.pendingFileFocusPath);Z.useEffect(()=>{if(Re){if(be){Fe();return}Le({path:Re}),M.getState().setPendingFileFocusPath(null)}},[Re,be,Fe,Le]);let ze=W((e=null)=>{if(y(!1),x(null),C(null),E(null),p(!1),h(null),J(e),be){De(`changes`),Se&&Te(!1);return}_(!0)}),Be=W((e,t,n)=>{J(null),_(!1),p(!1),h(null),x(e??null),C(typeof t==`string`&&t.trim()?t.trim():null);let r=typeof n==`string`&&n.trim()?n.trim():null;if(E(r),O(e=>e+1),be){De(`turn-diff`),Se&&Te(!1);return}y(!0)}),Ve=W(()=>{De(null),J(null),E(null)}),He=W(e=>{if(Ee===e){Ve();return}e===`files`?Fe():ze()}),Ue=Z.useRef(`changes`);Ee&&(Ue.current=Ee);let[We,Ge]=Z.useState(!1);Z.useEffect(()=>{if(!be)return;if(Ee){Ge(!0);return}let e=window.setTimeout(()=>Ge(!1),240);return()=>window.clearTimeout(e)},[Ee,be]);let Ke=Ee??Ue.current,qe=np(`left`,`openchamber.ipad.leftSidebarWidth`,Yf),Je=np(`right`,`openchamber.ipad.rightSidebarWidth`,Xf),Ye=Z.useMemo(()=>({openChanges:({diffPath:e,staged:t,targetLine:n}={})=>{ze(e?{path:e,staged:t===!0,targetLine:n}:null)},openToolDiff:({diffPath:e,patches:t,targetLine:n})=>{ze({path:e,staged:!1,targetLine:n,toolPatches:t})},openTurnDiff:Be,openFile:({path:e,targetLine:t})=>{Le({path:e,targetLine:t})},openFiles:()=>Fe(),openSettings:e=>{Oe(e)}}),[ze,Le,Fe,Oe,Be]),Ze=W(()=>{_(!1),J(null)}),Qe=W(()=>{y(!1),E(null)});ld(Z.useMemo(()=>({openSessions:()=>{if(be){Te(!0);return}mt.getState().setActiveTab(`projects`)},openView:e=>{e===`files`?Fe():e===`mcp`?j(!0):e===`instances`?ke():e===`update`&&L(!0)},openChanges:({path:e,staged:t}={})=>{ze(e?{path:e,staged:t===!0}:null)},openSettings:e=>{Oe(e)}}),[be,ze,Fe,ke,Oe]));let et=Z.useRef(null),tt=Z.useRef(null),rt=it(e=>e.currentSessionId),at=it(e=>e.setCurrentSession),ot=Z.useMemo(()=>e=>rt?e.getDirectoryForSession(rt):null,[rt]),st=it(ot),ct=$e(rt,st||le||void 0);If();let lt=W(()=>{let e=rt;if(!e||re)return;let t=st||le||void 0;ae(!0),(async()=>{try{await r.refreshSessionTranscript(e,{directory:t}),ie.success(n(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{ie.error(n(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{ae(!1)}})()}),ut=mt(e=>e.secondary?.kind??null),dt=!be&&(ut===`chat`||ut===`draft`);Z.useEffect(()=>{!be&&!dt&&U(!1)},[be,dt]),Z.useEffect(()=>{U(!1)},[rt]);let ft=be&&s===`assistant`||!be&&!dt||i||u||f||g||v||o||k||F||I||R||H;jd(tt,{onOpen:W(()=>{Gn(Kn)?.finish(`commit`)}),onPreviewStart:W(()=>{Gn(Kn)?.begin(`present`)}),onPreviewCancel:W(()=>{Gn(Kn)?.finish(`cancel`)}),onProgress:W(e=>{e!==null&&Gn(Kn)?.update(e)}),disabled:ft},be||dt);let pt=W(e=>{et.current=e});sp(W(()=>H?(U(!1),!0):R?(z(!1),!0):o?(window.dispatchEvent(new Event(`oc:scheduled-tasks-close-request`)),!0):i?(a(!1),!0):Qi.backImmediately(`overlay`)?!0:f?(Ie(),!0):u?(d(!1),!0):v?(Qe(),!0):g?(Ze(),!0):k?(j(!1),!0):F?(ee(!1),!0):I?(L(!1),!0):Qi.requestAnimatedBack(`root`)||et.current?.()?!0:s===`assistant`?(l(`chat`),!0):ct?(at(ct.id,ct.directory),!0):!1));let ht=de&&(Y===`desktop`||Y===`web`),gt=W(()=>{let e=`new-mcp-server`,t=e,n=1;for(;me.some(e=>e.name===t);)t=`${e}-${n}`,n+=1;_e({name:t,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),ve(t),j(!1),Oe(`mcp`)}),_t=W(()=>{if(N)return;P(!0);let e=new Promise(e=>window.setTimeout(e,500));Promise.all([ge(),he(),e]).finally(()=>P(!1))}),vt=it(e=>e.openNewSessionDraft),yt=Z.useMemo(()=>{let e=[{key:`new-session`,icon:`chat-new`,label:n(`mobile.menu.newSession`),onSelect:()=>{if(be){l(`chat`),vt();return}mt.getState().openDraft()}}];return be||e.push({key:`files`,icon:`file-text`,label:n(`mobile.menu.files`),onSelect:()=>Fe()},{key:`changes`,icon:`git-branch`,label:n(`mobile.menu.changes`),badge:ye,onSelect:()=>ze()}),e.push({key:`mcp`,iconNode:(0,$.jsx)(Or,{className:`size-5 shrink-0 text-muted-foreground`}),label:n(`mobile.menu.mcp`),onSelect:()=>j(!0)}),ht&&e.push({key:`update`,icon:`download`,label:n(`mobile.menu.update`),onSelect:()=>L(!0)}),be&&e.push({key:`settings`,icon:`settings-3`,label:n(`mobile.menu.settings`),onSelect:()=>Oe()}),rt&&e.push({key:`refresh-transcript`,icon:`refresh`,label:n(`sessions.sidebar.session.menu.refreshTranscript`),disabled:re,spinning:re,onSelect:lt}),e},[rt,ye,be,re,ze,Fe,vt,Oe,lt,l,ht,n]);return(0,$.jsx)(Da,{sessionId:rt??``,directory:st||le||void 0,active:be?s!==`assistant`:ut===`chat`,children:(0,$.jsx)(Xn,{actions:Ye,children:(0,$.jsxs)(to,{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:[be?(0,$.jsxs)(`aside`,{ref:qe.asideRef,className:K(`relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/50 bg-sidebar will-change-[width] motion-reduce:transition-none`,!we&&`border-r-0`),style:{width:we?qe.width:0,minWidth:we?qe.width:0,maxWidth:we?qe.width:0,"--oc-ipad-sidebar-width":`${qe.width}px`,overflowX:`clip`,paddingTop:`var(--oc-safe-area-top, 0px)`,transitionProperty:qe.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!we,"data-page-scroll-lock":`true`,children:[we?(0,$.jsx)(rp,{side:`left`,isResizing:qe.isResizing,ariaLabel:n(`sidebar.resize.leftPanelAria`),handleProps:qe.handleProps}):null,(0,$.jsx)(`div`,{className:K(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,qe.isResizing&&`pointer-events-none`,!we&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:(0,$.jsx)(xn,{children:(0,$.jsx)(Ns,{open:!0,variant:`sidebar`,onOpenChange:e=>{!e&&Se&&Te(!1)}})})})]}):null,(0,$.jsx)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,"data-page-scroll-lock":`true`,children:be?(0,$.jsxs)($.Fragment,{children:[s===`assistant`?null:(0,$.jsx)(`div`,{children:(0,$.jsx)(Sp,{onOpenSessions:()=>Ne(),menuOpen:H,onToggleMenu:oe,surfaceShortcuts:{activePanel:Ee===`turn-diff`?`changes`:Ee,changesDirty:ye>0,onToggleFiles:()=>He(`files`),onToggleChanges:()=>He(`changes`)}})}),(0,$.jsx)(`main`,{ref:tt,className:`relative min-h-0 flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(`div`,{className:`relative h-full w-full bg-background`,children:(0,$.jsx)(xn,{children:s===`assistant`?(0,$.jsx)(oa,{}):(0,$.jsx)(ai,{})})})})]}):(0,$.jsx)(hl,{className:`min-h-0 flex-1`,onAddProject:()=>z(!0),onScanQr:fe&&pe?()=>{Me()}:void 0,onSwitchInstance:fe?Ae:void 0,onEnableAssistants:()=>{Oe(`assistants`)},instancesPage:fe?(0,$.jsx)(hp,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t}):void 0,instancesSecondaryPage:fe?(0,$.jsxs)(`div`,{className:`oc-settings-workspace oc-settings-workspace-mobile flex h-full min-h-0 flex-col bg-[var(--surface-background)]`,children:[(0,$.jsx)(Ce,{title:n(`mobile.settings.switchInstance`),backAriaLabel:n(`header.actions.backAria`),onBack:je}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-[var(--oc-mobile-page-inline-inset)]`,children:(0,$.jsx)(Bi,{className:`oc-mobile-settings-detail-card`,children:(0,$.jsx)(hp,{connection:e,onConnect:()=>void 0,onActiveConnectionDeleted:t})})})]}):void 0,parentSessionTarget:ct?{id:ct.id,directory:ct.directory}:null,registerSecondaryBackHandler:pt,scheduledContent:(e,t)=>(0,$.jsx)(oi,{presentation:`mobile-tab`,registerEditorBackHandler:e,onEditorActiveChange:t}),renderChat:e=>(0,$.jsx)(xu,{sessionId:e.sessionId,directory:e.directory,onBack:()=>{se(),Qi.requestAnimatedBack(`root`)},onOpenMenu:oe,onCloseMenu:se,menuOpen:e.active&&H,children:(0,$.jsx)(`main`,{ref:e.active?tt:void 0,className:`relative h-full min-h-0 flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(`div`,{className:`relative h-full w-full bg-background`,children:(0,$.jsx)(xn,{children:(0,$.jsx)(ai,{readOnly:!e.active,active:e.active,selectionOverride:{sessionId:e.sessionId||null,directory:e.directory,viewKey:e.viewKey}})})})})})})}),be?(0,$.jsxs)(`aside`,{ref:Je.asideRef,className:K(`relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/50 bg-background will-change-[width] motion-reduce:transition-none`,!Ee&&`border-l-0`),style:{width:Ee?Je.width:0,minWidth:Ee?Je.width:0,maxWidth:Ee?Je.width:0,"--oc-ipad-sidebar-width":`${Je.width}px`,overflowX:`clip`,paddingTop:`var(--oc-safe-area-top, 0px)`,transitionProperty:Je.isResizing?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!Ee,"data-page-scroll-lock":`true`,children:[Ee?(0,$.jsx)(rp,{side:`right`,isResizing:Je.isResizing,ariaLabel:n(`sidebar.resize.rightPanelAria`),handleProps:Je.handleProps}):null,(0,$.jsx)(`div`,{className:K(`flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,Je.isResizing&&`pointer-events-none`,!Ee&&`pointer-events-none select-none opacity-0`),style:{width:`var(--oc-ipad-sidebar-width)`,overflowX:`hidden`},children:We?(0,$.jsx)(xn,{children:Ke===`files`?(0,$.jsx)(Qo,{onClose:Ve}):Ke===`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)(q,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ve,"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)(Xr,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,diffScope:`turn`,turnMessageId:b,sessionId:S,targetFilePath:w,navigationRequestKey:D,flushContent:!0})})]}):G?.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:G.toolPatches.length>1?n(`mobile.nav.changes`):G.path}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ve,"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)(Xr,{hideStackedFileSidebar:!0,diffScope:`turn`,targetFilePath:G.path,targetLine:G.targetLine??null,toolPatches:G.toolPatches,singleFileView:G.toolPatches.length===1,flushContent:!0})})]}):(0,$.jsx)(bo,{onClose:Ve,initialDiffPath:G?.path??null,initialDiffStaged:G?.staged===!0,initialDiffTargetLine:G?.targetLine??null})}):null})]}):null,(0,$.jsx)(ji,{open:R,onOpenChange:z,forceMobile:!0}),(0,$.jsx)(bp,{open:H,onClose:()=>U(!1),items:yt,rightOffset:be&&Ee?Je.width:0}),(0,$.jsx)(Mi,{}),u?(0,$.jsx)(Un,{id:Uf,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)(xn,{children:(0,$.jsx)(Qo,{onClose:()=>d(!1)})})}):null,f&&m?(0,$.jsx)(Un,{id:Hf,open:f,onOpenChange:e=>{e||Ie()},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)(xn,{children:(0,$.jsx)(Qo,{onClose:Ie,initialFilePath:m.path,directFilePreview:!0,hideFileHeader:!0},m.path)})}):null,(0,$.jsx)(Un,{id:Vf,open:v,onOpenChange:e=>{e||Qe()},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)(xn,{children:(0,$.jsx)(Xr,{hideStackedFileSidebar:!0,pinSelectedFileHeaderToTopOnNavigate:!0,toolbarInSheetHeader:!0,diffScope:`turn`,turnMessageId:b,sessionId:S,targetFilePath:w,navigationRequestKey:D,flushContent:!0})})}),g&&G?(0,$.jsx)(Un,{id:Bf,open:g,onOpenChange:e=>{e||Ze()},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:G.toolPatches&&G.toolPatches.length>1?n(`mobile.nav.changes`):G.path}),ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(xn,{children:G.toolPatches?.length?(0,$.jsx)(Xr,{hideStackedFileSidebar:!0,toolbarInSheetHeader:!0,diffScope:`turn`,targetFilePath:G.path,targetLine:G.targetLine??null,toolPatches:G.toolPatches,singleFileView:G.toolPatches.length===1,flushContent:!0}):(0,$.jsx)(bo,{initialDiffPath:G.path,initialDiffStaged:G.staged,initialDiffTargetLine:G.targetLine??null,hideDiffHeader:!0})})}):g?(0,$.jsx)(Un,{id:Wf,open:g,onOpenChange:e=>{e||Ze()},ariaLabel:n(`mobile.menu.changes`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.changes.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(xn,{children:(0,$.jsx)(bo,{onClose:Ze,initialDiffPath:G?.path??null,initialDiffStaged:G?.staged===!0,initialDiffTargetLine:G?.targetLine??null})})}):null,k?(0,$.jsx)(Un,{id:Gf,open:k,onOpenChange:e=>{e||j(!1)},title:(0,$.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:n(`mcpDropdown.title`)}),trailing:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,onClick:gt,"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)(q,{type:`button`,variant:`ghost`,size:`icon`,onClick:_t,disabled:N,"aria-label":n(`mcpDropdown.actions.refreshAria`),title:n(`mcpDropdown.actions.refreshAria`),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`refresh`,className:K(`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)(xn,{children:(0,$.jsx)(li,{active:!0,className:`h-full`,listClassName:`max-h-none`,hideHeader:!0,mobileListDensity:!0})})}):null,F&&be?(0,$.jsx)(Un,{id:Kf,open:F,onOpenChange:e=>{e||ee(!1)},ariaLabel:n(`mobile.menu.settings`),closeAriaLabel:n(`mobile.surface.closeAria`),resizeAriaLabel:n(`mobile.sessions.sheet.resizeAria`),initiallyExpanded:!0,children:(0,$.jsx)(xn,{children:(0,$.jsx)(qi,{forceMobile:!0,isWindowed:!0,initialMobileStage:B,visiblePageSlugs:[...Yi],onClose:()=>ee(!1),mobileInstancesPage:fe?(0,$.jsx)(hp,{connection:e,onConnect:()=>ee(!1),onActiveConnectionDeleted:t}):void 0})})}):null,I?(0,$.jsx)(Un,{id:qf,open:I,onOpenChange:e=>{e||L(!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)(xn,{children:(0,$.jsx)(`div`,{className:`h-full overflow-auto px-5 py-4`,children:(0,$.jsx)(Hi,{initialUpdateDialogOpen:!0})})})}):null]}),(0,$.jsx)(Ji,{enabled:fe&&s===`assistant`&&c.data?.supported===!0&&c.data?.enabled===!0}),(0,$.jsx)(xn,{children:(0,$.jsx)(zr,{})})]})})})};function wp({apis:e}){Z.useEffect(()=>qe(),[]);let{t}=ce(),n=vt(e=>e.initializeApp),r=vt(e=>e.isInitialized),i=vt(e=>e.isConnected),a=vt(e=>e.connectionPhase),o=T(e=>e.currentDirectory),s=it(e=>e.currentSessionId),l=it(e=>!!e.newSessionDraft?.open),d=it(e=>e.error),f=it(e=>e.clearError),h=M(e=>e.setIsMobile),g=Nr(e=>e.refreshStatus),_=lt(e=>e.projects),[v,y]=Z.useState(0),[b,x]=Z.useState(0),[S,C]=Z.useState(!1),[w,E]=Z.useState(`pending`),D=Z.useMemo(()=>pe(),[]),[,k]=Z.useReducer(e=>e+1,0),A=Z.useMemo(()=>ip(),[]),j=Z.useRef(0),N=Z.useRef(0),P=me(()=>{E(`done`),y(e=>e+1)});ud(W(e=>{P.redeemPairingConnection(e)}));let F=dd({ready:A&&i&&r});Z.useEffect(()=>{!P.error||!p()||ie.error(P.error)},[P.error]);let ee=W(()=>{let t=p(),r=N.current+1;if(N.current=r,!t){_e();return}let i=()=>{n(),g(e.github,{force:!0}),vt.getState().refreshMissingCatalogs({source:`mobileApp:nativeResume`})},a=()=>{u({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),y(e=>e+1)};ge().then(e=>{if(N.current===r){if(e===`no-connection`){a();return}if(e===`unreachable`){window.setTimeout(()=>{N.current===r&&ge().then(e=>{if(N.current===r&&e!==`switched`&&e===`unchanged`){i();return}})},4e3);return}e!==`switched`&&i()}});let o=Date.now();o-j.current>=up&&(j.current=o,window.dispatchEvent(new Event(`openchamber:system-resume`)))});ap(),op(ee),Z.useEffect(()=>{if(!A)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>ee(),1500)};return window.addEventListener(`online`,t),()=>{window.removeEventListener(`online`,t),window.clearTimeout(e)}},[A,ee]),Z.useEffect(()=>(m(e),()=>m(null)),[e]),Z.useEffect(()=>{A&&U().then(e=>{e&&e.notifyAppReady().catch(()=>void 0)})},[A]),Z.useEffect(()=>{if(!A)return;let e=!1,t=[];return U().then(async n=>{if(!(!n||e))try{let r=await n.addListener(`download`,e=>{Tr.getState().setOtaDownloadPercent(e.percent)}),i=await n.addListener(`downloadFailed`,()=>{Tr.getState().setOtaDownloadFailed()}),a=await n.addListener(`downloadComplete`,()=>{Tr.getState().setOtaPhase(`pending_restart`)}),o=await n.addListener(`appReloaded`,()=>{Tr.getState().setOtaPhase(`pending_restart`)}),s=await n.addListener(`autoRevert`,()=>{console.warn(`[OTA] Capgo auto-reverted the last bundle`),Tr.getState().setOtaPhase(`error`,`OTA update was reverted`)});if(e){r.remove(),i.remove(),a.remove(),o.remove(),s.remove();return}t.push(()=>void r.remove(),()=>void i.remove(),()=>void a.remove(),()=>void o.remove(),()=>void s.remove())}catch(e){console.warn(`[OTA] Failed to subscribe to Capgo updater events:`,e)}}),()=>{e=!0;for(let e of t)e()}},[A]),Z.useEffect(()=>c(e=>{if(e.runtimeKey&&e.runtimeKey===e.previousRuntimeKey){Ei(),k();return}yi(e),mt.getState().reset(),x(e=>e+1),y(e=>e+1)}),[]),Z.useEffect(()=>{if(F===`pending`)return;if(F===`connect`){E(`done`);return}if(!A||i||p()){E(`done`);return}let e=!1;return E(`attempting`),he().then(e=>e?!0:_e()).catch(()=>!1).then(()=>{e||E(`done`)}),()=>{e=!0}},[F]),Z.useEffect(()=>{h(!0)},[h]),Z.useEffect(()=>{A&&!p()||n()},[v,n,A]),Yt({enabled:!A||!!p(),source:`mobileApp:recovery`}),Z.useEffect(()=>{i&&O.setDirectory(o)},[o,i]),Z.useEffect(()=>{i&&g(e.github,{force:!0})},[e.github,i,g]),Z.useEffect(()=>{if(!i||_.length===0)return;let e=!1;return(async()=>{await Promise.all(_.map(async t=>{let n=cp(t.path);if(n)try{if(!(ir.getState().directories.get(n)?.isGitRepo??await H(()=>import(`./gitApi-BVwik90d.js`).then(e=>e.S).then(e=>e.checkIsGitRepository(n)),__vite__mapDeps([65,1,3,2,4,5,12,6,7,8,9,10,11,13,14,15,16,42,43,28,29,30,31,32,33,34,44,45,46])))||e)return;await _n({id:t.id,path:n},{isCurrent:()=>!e})}catch{}}))})(),()=>{e=!0}},[i,_]),Z.useEffect(()=>{if(!d)return;let e=window.setTimeout(()=>f(),5e3);return()=>window.clearTimeout(e)},[f,d]),Z.useEffect(()=>{if(!(!i&&(!A||p()))){C(!1);return}let e=window.setTimeout(()=>C(!0),8e3);return()=>window.clearTimeout(e)},[i,A,v,b]),on(),Pt({enabled:!0}),qt(),$r(),Rd({enabled:A&&i}),Lf();let I=Wu(),L=!i&&a===`reconnecting`;if(!I)return(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,$.jsx)(wn,{width:120,height:120,isAnimated:!0})});let R=!!p();return A&&(!R||!i&&!L)?R?(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)(wn,{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)(q,{type:`button`,variant:`outline`,onClick:()=>{u({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),y(e=>e+1)},children:t(`mobile.connect.cancelPassword`)})]}):null]})}):w===`done`?(0,$.jsx)(mp,{connection:P}):(0,$.jsxs)(`main`,{className:`relative flex min-h-dvh items-center justify-center bg-background text-foreground`,children:[(0,$.jsx)(wn,{width:120,height:120,isAnimated:!0}),D?(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:[D,(0,$.jsx)(sn,{})]})]}):null]}):!i&&!L?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)(wn,{width:120,height:120,isAnimated:!0})}):(0,$.jsx)(xn,{children:(0,$.jsx)(ze,{sdk:O.getSdkClient(),directory:o||``,bootstrapDirectory:!(l&&s===null),children:(0,$.jsx)(cn,{apis:e,children:(0,$.jsx)(yn,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:`h-full bg-background text-foreground`,children:[(0,$.jsx)(Ai,{}),(0,$.jsx)(ve,{}),(0,$.jsx)($t,{embeddedBackgroundWorkEnabled:r}),(0,$.jsx)(Oi,{}),(0,$.jsx)(Na,{}),(0,$.jsx)(Ua,{}),(0,$.jsx)(Cp,{connection:P,onActiveConnectionDeleted:()=>{u({apiBaseUrl:``,clientToken:null,runtimeKey:`mobile-disconnected`}),mt.getState().reset(),y(e=>e+1)}}),(0,$.jsx)(Ft,{position:`top-center`,offset:`calc(var(--oc-safe-area-top, 0px) + 16px)`}),r?(0,$.jsx)(gi,{}):null,r?(0,$.jsx)(Ci,{}):null]})})})},b)})}function Tp(e){e.currentTarget.style.transform=`none`}function Ep(e){return e.ensureStatus}function Dp(e){return e.fetchStatus}function Op(e){return e.providers}function kp(e){return e.currentProviderId}function Ap(e){return e.currentModelId}function jp(e){return e.getModelMetadata}function Mp(e){return e.results}function Np(e){return e.loadSettings}function Pp(e){return e.fetchAllQuotas}function Fp(e){return e.isLoading}function Ip(e){return e.displayMode}function Lp(e){return e.dropdownProviderIds}function Rp(e){return e.selectedModels}function zp(e){return e.timeFormatPreference}function Bp(e){return[e?.providerId,e]}function Vp(e){return e.providerId}function Hp(e){return!e}var Up=()=>{le(),y().then(()=>{Promise.all([v(),Kt()]).catch(e=>{console.error(`[mobile-main] settings init failed:`,e)}),tn(),Ut(),It()}).catch(e=>{console.error(`[mobile-main] appearance init failed:`,e)}).finally(()=>{pa()})};function Wp(e){fr(),Up(),M.getState().setIsMobile(!0),xa(),Pn(),Fn();let t=document.getElementById(`root`);if(!t)throw Error(`Root element not found`);let n=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`;n&&document.documentElement.classList.add(`oc-native-app-active`);let r=n?{...e,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:e,i=(0,$.jsx)(wp,{apis:r});(0,la.createRoot)(t).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(Lt,{children:(0,$.jsx)(G,{children:(0,$.jsx)(Mt,{children:(0,$.jsx)(en,{children:(0,$.jsx)(vi,{children:(0,$.jsx)(Vt,{children:n?i:(0,$.jsx)(Ht,{children:i})})})})})})})}))}export{Wp as renderMobileApp};