@vantran-se/openchamber-web 2.4.2 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AboutDialog-Dz_8z7Rq.js → AboutDialog-C8mAGhnz.js} +1 -1
- package/dist/assets/{ArchiveView-BoMjLD0N.js → ArchiveView-4-LVDLmf.js} +1 -1
- package/dist/assets/{ChangedPathLabel-BirEUxH2.js → ChangedPathLabel-BCiU4QDF.js} +1 -1
- package/dist/assets/{CommandPalette-DkLX-AKB.js → CommandPalette-DEcmPHdC.js} +1 -1
- package/dist/assets/{DiffView-DwyXDHsF.js → DiffView-CaDZ4gTk.js} +3 -3
- package/dist/assets/{FilesView-BFi9HBg1.js → FilesView-Csrs_BGv.js} +1 -1
- package/dist/assets/{GitView-BzWRNg_F.js → GitView-DvxCZgCW.js} +3 -3
- package/dist/assets/{GuestSurfacePane-zDcKyz78.js → GuestSurfacePane-DNg0xBTD.js} +1 -1
- package/dist/assets/{HelpDialog-DZVlv3x2.js → HelpDialog-CLyz3_xd.js} +1 -1
- package/dist/assets/{InProgressOperationBanner-BiEntIfh.js → InProgressOperationBanner-BVDKUDqn.js} +2 -2
- package/dist/assets/{IntegrationsCatalogView-CCHFMcZP.js → IntegrationsCatalogView-u1gS0Vk8.js} +1 -1
- package/dist/assets/{JsonTreeView-BwELoub1.js → JsonTreeView-BpJU14WJ.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-DxBYkSKd.js → MarkdownRendererImpl-t3OoYn_0.js} +1 -1
- package/dist/assets/{MemoryDebugPanel-C9zpPXVo.js → MemoryDebugPanel-9z1jGWze.js} +1 -1
- package/dist/assets/{OnboardingScreen-Cnzzs_TQ.js → OnboardingScreen-xzT7ckY0.js} +1 -1
- package/dist/assets/{OpenCodeStatusDialog-DizE9xAy.js → OpenCodeStatusDialog-skpJZSjK.js} +1 -1
- package/dist/assets/{PatchDiff-Cz_UxB-k.js → PatchDiff-BWW_8bob.js} +1 -1
- package/dist/assets/{PierreDiffViewer-BT3MrXwN.js → PierreDiffViewer-BZDNV4Uj.js} +1 -1
- package/dist/assets/{PlanView-B-SCCd7M.js → PlanView-D7wshtfZ.js} +1 -1
- package/dist/assets/{ProjectActionsDialog-4OSNuzpG.js → ProjectActionsDialog-BPh74BCt.js} +1 -1
- package/dist/assets/{PullRequestComparisonSelector-lp98DrYm.js → PullRequestComparisonSelector-BBdU2rL1.js} +3 -3
- package/dist/assets/{RunOverview-DJhjR9uR.js → RunOverview-Cngm2OOp.js} +2 -2
- package/dist/assets/{ScheduledTasksDialog-Dwil7zsx.js → ScheduledTasksDialog-DUjDdkw2.js} +1 -1
- package/dist/assets/{SettingsView-DVcV2Rk9.js → SettingsView-CCZOw018.js} +2 -2
- package/dist/assets/{SettingsWindow-DbbAS4Se.js → SettingsWindow-Cndsj5Vu.js} +1 -1
- package/dist/assets/{SourceBoardView-BVcmYpvE.js → SourceBoardView-8Wp0oUvB.js} +1 -1
- package/dist/assets/{SpaceAccessDialog-DxjFUcHZ.js → SpaceAccessDialog-CxfCzTpe.js} +1 -1
- package/dist/assets/{SpaceApplyDialog-Dbrbh-j4.js → SpaceApplyDialog-CYp0A76N.js} +1 -1
- package/dist/assets/{SpaceRow-Cwam4mHh.js → SpaceRow-CQp4PkPJ.js} +1 -1
- package/dist/assets/{SpaceSetupOutput-B_w02jDi.js → SpaceSetupOutput-RNo0mWrR.js} +1 -1
- package/dist/assets/{SpacesView-CGrFWnO-.js → SpacesView-BwcDCv3D.js} +1 -1
- package/dist/assets/{SubmoduleDiffSummary-DFL-m_eu.js → SubmoduleDiffSummary-BQduif5s.js} +1 -1
- package/dist/assets/{ToolOutputDialog-Co0VXa0y.js → ToolOutputDialog-BVCvqYsK.js} +1 -1
- package/dist/assets/{ToolPartDiffPreview-CBSzwkat.js → ToolPartDiffPreview-BXpCHBW9.js} +1 -1
- package/dist/assets/{UsageStatsView-BjtTNSt8.js → UsageStatsView-CsC_RzAH.js} +1 -1
- package/dist/assets/{Virtualizer-Cmng0Q1E.js → Virtualizer-nenVQKi3.js} +1 -1
- package/dist/assets/{WalkthroughView-C7AkVuHQ.js → WalkthroughView-CdIYpttA.js} +1 -1
- package/dist/assets/{WorktreesView-CYU2KJ6E.js → WorktreesView-D102xE1o.js} +1 -1
- package/dist/assets/{appThemeRegistry-CDGE1wtP.js → appThemeRegistry-BWap7OfW.js} +1 -1
- package/dist/assets/{ar-BlEU--PN.js → ar-9CiK5cuu.js} +3 -3
- package/dist/assets/{computeVirtualFileMetrics-BgqasG86.js → computeVirtualFileMetrics-DDyA16hp.js} +1 -1
- package/dist/assets/{de-DWs4Mcjc.js → de-Drq6oIkP.js} +3 -3
- package/dist/assets/{decorate-CpxLqoVw.js → decorate-CemSwkUs.js} +1 -1
- package/dist/assets/{es-k5T7CE97.js → es-0bkFr34F.js} +3 -3
- package/dist/assets/{flexokiTheme-BG4cSAMb.js → flexokiTheme-PoX6Vqyn.js} +1 -1
- package/dist/assets/{fr-CzmypgZ8.js → fr-CjgWVupK.js} +3 -3
- package/dist/assets/{he-DdkxJnUn.js → he-BrJa9oPB.js} +4 -4
- package/dist/assets/{index-BrL960j-.js → index-B2WHEal3.js} +1 -1
- package/dist/assets/{initializeSharedPreferences-CrnmmfFs.js → initializeSharedPreferences-1Vo6G7CM.js} +1 -1
- package/dist/assets/{install-DvRQsTjX.js → install-FletzeYD.js} +1 -1
- package/dist/assets/{isDiffPlainText-KGYbp86N.js → isDiffPlainText-yXcpftjI.js} +1 -1
- package/dist/assets/{isFilePlainText-D7rclQrA.js → isFilePlainText-Dpm-_Qu8.js} +1 -1
- package/dist/assets/{ja-Qqkyglaf.js → ja-cfyrqWPa.js} +3 -3
- package/dist/assets/katex.min-F4TD1ekM.js +69 -0
- package/dist/assets/{ko-B8idPK2d.js → ko-herKAlGO.js} +3 -3
- package/dist/assets/{main-D4-y6PQ0.js → main-CO7wKNtS.js} +2 -2
- package/dist/assets/{main-Cmc8m6dZ.js → main-DN47yDMe.js} +19 -19
- package/dist/assets/markdownCore-BY21GJ_M.js +10 -0
- package/dist/assets/{miniChat-CjJ77DDL.js → miniChat-BmFJFQph.js} +2 -2
- package/dist/assets/{mobile-DlFdLxjR.js → mobile-DTi98S93.js} +2 -2
- package/dist/assets/{moveWorkspacePath-CVdEBQ6v.js → moveWorkspacePath-CENAo75W.js} +1 -1
- package/dist/assets/{nl-CFXZKHp7.js → nl-mZ4VCoiQ.js} +3 -3
- package/dist/assets/{parseDiffFromFile-DWemyyqU.js → parseDiffFromFile-BSmRvd3V.js} +1 -1
- package/dist/assets/{pierreDiffTint-B7qPTZmL.js → pierreDiffTint-cyYFR1bm.js} +1 -1
- package/dist/assets/{pl-slLgZWDu.js → pl-C98lvkcZ.js} +4 -4
- package/dist/assets/{pt-BR-C319g_nn.js → pt-BR-CB63WPLS.js} +3 -3
- package/dist/assets/{relocateRestoredSession-cOuWlgWB.js → relocateRestoredSession-D8Sf_FG_.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-DFnEi5Tr.js → renderElectronMiniChatApp-DmQ8i5jp.js} +2 -2
- package/dist/assets/{renderMobileApp-C2TYqVOV.js → renderMobileApp-CND9CafV.js} +3 -3
- package/dist/assets/{restartOpenCode-Dvk4CWW7.js → restartOpenCode-D8ExMl55.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-D7viEboD.js → runtimeEndpointReset-lg1O2gVX.js} +3 -3
- package/dist/assets/{scheduledTasksApi-FZ9stPNl.js → scheduledTasksApi-CJBNpwgy.js} +1 -1
- package/dist/assets/{selectionMarkdown-CCursbAw.js → selectionMarkdown-B_3WTOUr.js} +1 -1
- package/dist/assets/{shikiHighlight-CLj7Oan9.js → shikiHighlight-DBj_a_TN.js} +1 -1
- package/dist/assets/{space-apply-DdhqZWNy.js → space-apply-COMscpEL.js} +1 -1
- package/dist/assets/{space-close-KXdazynX.js → space-close-DDLvYCUc.js} +1 -1
- package/dist/assets/{spaceNetwork-DzU3SK9K.js → spaceNetwork-CNxs51y4.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-C-jxkZJj.js → textMateThemeFromAppTheme-tYpAceV3.js} +1 -1
- package/dist/assets/{tr-DNnJ5oqk.js → tr-C5KUa-8X.js} +3 -3
- package/dist/assets/{uk-Bw0BJwHw.js → uk-D44Grdmc.js} +3 -3
- package/dist/assets/{useAppFontEffects-DAUhSLPu.js → useAppFontEffects-Dm6zEvrf.js} +200 -199
- package/dist/assets/{useCallableModelProviders-B-UCRuyn.js → useCallableModelProviders-BK3j8Sde.js} +1 -1
- package/dist/assets/{useDiffFindSurface-CU_63uoI.js → useDiffFindSurface-CaCh-qt2.js} +1 -1
- package/dist/assets/{useInlineCommentController-bYCeqE6r.js → useInlineCommentController-a2JepiF3.js} +1 -1
- package/dist/assets/{useMarkdownLocalAssets-CnMxnDdI.js → useMarkdownLocalAssets-BEApAshz.js} +2 -2
- package/dist/assets/{useRootScrollLock-DNYaZ34X.js → useRootScrollLock-mqVhK2HB.js} +2 -2
- package/dist/assets/{useWalkthroughReview-DGPyQ634.js → useWalkthroughReview-BspAr9Aa.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-KulAIuMz.js → vendor-codemirror-language-data-VzNDjH03.js} +2 -2
- package/dist/assets/{zh-CN-Brx5Btej.js → zh-CN-DwBC4Qtd.js} +3 -3
- package/dist/assets/{zh-TW-WokiutLA.js → zh-TW-DXEqDBAm.js} +3 -3
- package/dist/index.html +2 -2
- package/dist/mini-chat.html +2 -2
- package/dist/mobile.html +2 -2
- package/package.json +2 -2
- package/server/lib/git/service.test.js +1 -1
- package/server/lib/opencode/openchamber-routes.test.js +1 -0
- package/server/lib/opencode/settings-helpers.js +2 -2
- package/server/lib/opencode/settings-helpers.test.js +1 -1
- package/server/lib/opencode/settings-registry.json +1 -1
- package/server/lib/outbound-proxy.test.js +2 -2
- package/server/lib/spaces/tools.test.js +2 -2
- package/dist/assets/katex.min-u4DtE8E5.js +0 -69
- package/dist/assets/markdownCore-D_5e0Wl7.js +0 -10
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesView-
|
|
2
|
-
import{f as fe,r as ui,j as t,R as d,c as Hs,h as sc}from"./vendor-react-BUCujlKS.js";import{u as Ve,a5 as Mn,bi as Ii,bj as go,bk as nt,b3 as Mt,bl as Ws,bm as In,k as ya,bn as yr,bo as va,bp as nc,bq as wa,br as rc,bs as ic,bt as oc,bu as ac,e as ws,n as _n,y as lc,z as cc,bv as Ct,az as Qn,bw as dc,a6 as pn,b as bo,aU as Fs,a_ as uc,t as fi,aD as xo,ap as fc,ao as mc,bx as pc,by as hc,bz as yo,a8 as gc,a7 as ja,bA as vo,bB as bc,aC as wo,bC as Zn,bD as xc}from"./katex.min-u4DtE8E5.js";import{H as vs,e2 as yc,a5 as ut,d5 as ka,d6 as Sa,K as Na,gS as vc,u as xe,A as pe,cx as wc,I as Y,dM as jc,B as Ie,aA as Ca,ac as Vs,al as Ra,N as se,c8 as Ia,gT as kc,gU as Sc,dw as Ea,a1 as wt,aO as Nc,gV as hs,gW as Cc,gX as jo,gY as Rc,gZ as Ic,eW as Ei,ds as Ec,dt as Ac,G as $e,eE as Tc,eG as Ai,eH as Ti,g_ as Pi,eJ as Pc,eI as Aa,g$ as Di,e0 as ur,cF as Ta,h0 as Dc,bd as Pa,aD as gt,cE as Da,b7 as vr,h1 as Mc,h2 as _c,h3 as Oc,h4 as zc,fp as ar,gc as mi,fX as ns,h5 as Bc,k as Ma,aG as _a,cR as Oa,cS as za,cT as Ba,h6 as Lc,h7 as Fc,h8 as $c,e1 as ko,de as La,h9 as Fa,br as Mi,y as $a,ha as Wc,hb as Vc,hc as Wa,hd as Uc,d7 as Gc,a7 as Kc,dk as qc,eP as Hc,he as Xc,hf as er,hg as Jc,dc as qr,a6 as Yc,hh as Qc,dj as gs,hi as Hr,hj as Zc,hk as Va,L as ed,hl as td,aR as pi,aS as hi,aT as gi,bi as Xr,bg as tr,aU as hn,cQ as wr,cC as sd,c1 as Ua,dS as Ga,dA as nd,hm as rd,eq as bi,hn as id,ho as Ka,hp as $s,hq as Ks,hr as od,V as ad,W as ld,X as cd,hs as dd,g5 as ud,fZ as qa,aE as Ha,b3 as fd,b5 as md,b6 as pd,fi as hd,fd as gd,b9 as Xa,fe as bd,fj as xd,ej as yd,b8 as vd,fY as wd,g1 as jd,ek as kd,ht as Sd,hu as Nd,hv as Cd,hw as Rd,g4 as So,bc as sr,be as Id,bj as Ed,bf as gn,em as Ad,fg as Td,bT as Pd,el as Dd,g9 as Md,gb as _d,g6 as Od,dp as Ja,aV as st,cD as zd,hx as Bd,dh as Ld,hy as Fd,hz as $d,hA as Wd,dm as Vd,hB as Ud,fb as No,hC as _i,ce as Gd,hD as Kd,hE as qd,cU as xi,dF as Hd,dG as Xd,dH as Jd,dI as Yd,hF as Qd,dO as Zd,dN as eu,dJ as tu,hG as su,dK as nu,dL as ru,dT as iu,dR as ou,hH as au,hI as lu,hJ as cu,hK as du,hL as uu,hM as fu,hN as mu,hO as pu,dU as hu,dV as gu,dW as bu,dX as xu}from"./useAppFontEffects-DAUhSLPu.js";import{ac as Us,ad as yu,ae as vu,af as wu,ag as ju,ah as Ya,ai as Qa,aj as Za,ak as ku,al as Su,am as Nu,S as Cu,an as Ru,a as Iu,ao as Eu,z as Au,ap as Tu,aq as Pu,$ as el,K as lr,ar as Du,R as nr,a0 as Mu,a1 as _u,X as Ou,a3 as Jr,a6 as zu,a7 as Bu,O as Lu,as as Fu,U as $u,V as Wu,at as Vu,au as Uu,Y as Gu,d as Ku,a8 as qu,a4 as tl,N as Hu,av as Xu,aw as Ju,aa as Yu,ax as Qu,ay as Zu,az as ef,aA as tf,aB as sf,aC as nf,aD as rf,aE as of,aF as af,aG as lf,aH as cf,aI as df,aJ as uf,aK as ff,aL as mf,aM as pf,aN as hf,aO as gf,aP as bf,aQ as xf}from"./runtimeEndpointReset-D7viEboD.js";import{i as yf}from"./initializeSharedPreferences-CrnmmfFs.js";import{_ as Xs}from"./vendor-vite-runtime-DD1OZmLC.js";import{S as vf,A as wf}from"./SettingsView-DVcV2Rk9.js";import{PlanView as jf}from"./PlanView-B-SCCd7M.js";import{SpaceAccessDialog as kf}from"./SpaceAccessDialog-DxjFUcHZ.js";import{SpaceApplyDialog as Sf}from"./SpaceApplyDialog-Dbrbh-j4.js";import{SpaceSetupOutputDialog as Nf}from"./SpaceSetupOutput-B_w02jDi.js";import{RunOverview as Cf}from"./RunOverview-DJhjR9uR.js";import{p as Rf}from"./vendor-aparajita-capacitor-secure-storage-5IShChL0.js";import{Capacitor as If,registerPlugin as sl}from"./vendor-capacitor-core-B4EWRrHz.js";import{k as yi,d as Ef,M as fr,J as nl,a as Oi,s as rl,p as Af,_ as Co,f as zi,V as Tf,K as Ro,P as Pf,b as Df,c as Mf,U as _f,Z as Of,Q as zf,r as Bf}from"./vendor-remixicon-react-D6dZ0UwF.js";import{f as Bi,h as Js,i as Li,P as Fi,D as $i,j as Wi}from"./vendor-dnd-kit-core-BZknOX2w.js";import{S as Vi,v as Ui,u as Gi,s as Ki,a as Lf}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as qi}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{c as Hi,p as il}from"./vendor-zustand-BAGL70zf.js";import{toast as vi}from"./vendor-sonner-DFyL3AvE.js";import{S as Ff}from"./SpaceRow-Cwam4mHh.js";import{UsageStatsView as $f}from"./UsageStatsView-BjtTNSt8.js";import{ArchiveSessionsView as Wf}from"./ArchiveView-BoMjLD0N.js";import{MobileSourceBoard as Vf}from"./SourceBoardView-BVcmYpvE.js";import{ScheduledTasksView as Uf}from"./ScheduledTasksDialog-Dwil7zsx.js";import{i as Gf,a as Kf,b as qf,c as Hf,d as Xf,s as Jf,S as Yf,W as Qf}from"./SubmoduleDiffSummary-DFL-m_eu.js";import{R as Zf,I as em,C as tm,a as sm,b as nm,D as rm}from"./InProgressOperationBanner-BiEntIfh.js";import{C as ol}from"./ChangedPathLabel-BirEUxH2.js";import{u as im,W as om,c as am,d as lm,g as cm,f as dm,h as um,l as fm,k as mm}from"./useWalkthroughReview-DGPyQ634.js";import{u as Io,a as pm,b as hm,c as gm,i as Eo,f as Yr,B as bm,C as xm,P as Ao}from"./PullRequestComparisonSelector-lp98DrYm.js";import{P as ym}from"./PierreDiffViewer-BT3MrXwN.js";import{p as vm}from"./parseDiffFromFile-DWemyyqU.js";import{o as al,s as To}from"./vendor-zod-DDir2TeQ.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-opencode-client-h8RufjAw.js";import"./vendor-base-ui-CPKyhvxM.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tanstack-react-virtual-Bmi0tTrf.js";import"./vendor-tanstack-virtual-core-CdGDGrnp.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-dar6chwA.js";import"./vendor-codemirror-state-Dek9sMtw.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-B66jUSmE.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-language-DyL0aCoH.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-streamparser-CmlTsbN2.js";import"./vendor-codemirror-lang-javascript-Cem6LjJ8.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-CIqXJolH.js";import"./vendor-codemirror-lang-json-C9rLLO0q.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-9qjxcVkg.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-D7VQUxeE.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-Cikh4w2I.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-KulAIuMz.js";import"./vendor-codemirror-lang-python-DVl8-2Op.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-legendapp-list-D2O6oUGf.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./install-DvRQsTjX.js";import"./vendor-yaml-CE-D_49-.js";import"./flexokiTheme-BG4cSAMb.js";import"./vendor-codemirror-search-BKAwkhkm.js";import"./vendor-replit-codemirror-vim-CKWqK1yR.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./shikiHighlight-CLj7Oan9.js";import"./appThemeRegistry-CDGE1wtP.js";import"./textMateThemeFromAppTheme-C-jxkZJj.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-qrcode-DTJ12-WC.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./vendor-strip-json-comments-5dJlOkP1.js";import"./useCallableModelProviders-B-UCRuyn.js";import"./restartOpenCode-Dvk4CWW7.js";import"./useInlineCommentController-bYCeqE6r.js";import"./useMarkdownLocalAssets-CnMxnDdI.js";import"./spaceNetwork-DzU3SK9K.js";import"./space-apply-DdhqZWNy.js";import"./scheduledTasksApi-FZ9stPNl.js";import"./vendor-cron-parser-CjvYVigk.js";import"./vendor-luxon-BZ0puJYg.js";import"./computeVirtualFileMetrics-BgqasG86.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isDiffPlainText-KGYbp86N.js";import"./vendor-diff-C3JhlQdm.js";import"./pierreDiffTint-B7qPTZmL.js";import"./Virtualizer-Cmng0Q1E.js";let ll=null,Po=!1;const wm=new Promise(n=>{ll=n});function jm(){Po||(Po=!0,ll?.())}const km=6,Sm=n=>n.parentID??null,wi=n=>{const e=n.replace(/\/+$/,"");return e.slice(e.lastIndexOf("/")+1)||e},Nm=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),Cm=(n,e)=>{if(!n)return"";let s=null,r=-1;for(const i of e){const l=Nm(i.path);(n===l||n.startsWith(`${l}/`))&&l.length>r&&(s=i,r=l.length)}return s?s.label?.trim()||wi(s.path):wi(n)},Rm=()=>{const n=vs.getState().activeSessions,e=yc.getState().index.session.unseenCount,s=Ve.getState().notifyOnSubtasks,r=ut.getState().projects,i=ka.getState().ids,l=Sa.getState().rankById;let o=0;const a=[];for(const p of n){const m=Sm(p)!==null,b=(e[p.id]??0)>0&&(!m||s);b&&(o+=1),m||a.push({session:p,unread:b,project:Cm(Na(p),r)})}a.sort((p,m)=>vc(p.session,m.session,i,l));const f=a.slice(0,km).map(({session:p,unread:m,project:h})=>({id:p.id,title:p.title??"",unread:m,project:h}));return{runtimeKey:Mn(),attentionCount:o,recentSessions:f,projects:r.map(p=>({id:p.id,label:p.label?.trim()||wi(p.path)}))}},Im="__OPENCHAMBER_WIDGET_SNAPSHOT__",Em=()=>{typeof window>"u"||(window[Im]=()=>{try{return JSON.stringify(Rm())}catch{return null}})},Qr="mobile-app-update-available",Do="mobile-app-update-toast-dismissed-version",Am=()=>{const n=fe.c(8),{t:e}=xe(),s=Us(Tm),r=Us(Pm),i=Us(Dm),l=Us(Mm);let o;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=new Set,n[0]=o):o=n[0];const a=ui.useRef(o);let f,p;return n[1]!==s||n[2]!==l||n[3]!==r||n[4]!==e||n[5]!==i?(f=()=>{if(Ii()!=="android"||r!=="mobile"||!s||!i||!l){pe.dismiss(Qr);return}go().getItem(Do)!==i&&(a.current.has(i)||(a.current.add(i),pe.info(e("mobileUpdate.toast.available.title"),{id:Qr,description:e("mobileUpdate.toast.available.description",{version:i}),duration:1/0,icon:t.jsx(Y,{name:"download",className:"h-4 w-4 text-muted-foreground"}),action:{label:e("mobileUpdate.toast.actions.download"),onClick:()=>{wc(l)}},cancel:{label:e("mobileUpdate.toast.actions.dismiss"),onClick:()=>{go().setItem(Do,i),pe.dismiss(Qr)}}})))},p=[s,l,r,e,i],n[1]=s,n[2]=l,n[3]=r,n[4]=e,n[5]=i,n[6]=f,n[7]=p):(f=n[6],p=n[7]),ui.useEffect(f,p),null};function Tm(n){return n.available}function Pm(n){return n.runtimeType}function Dm(n){return n.info?.version}function Mm(n){return n.info?.downloadUrl}const Mo="calc(var(--oc-safe-area-top, 0px) + var(--oc-visual-viewport-offset-top, 0px) + 16px)";function _m(n){const e=fe.c(3);let s,r;e[0]!==n?(s=()=>{const i=window.visualViewport,l=n.current;if(!i||!l)return;let o="";const a=()=>{const f=`${Math.max(0,Math.round(i.offsetTop))}px`;f!==o&&(o=f,l.style.setProperty("--oc-visual-viewport-offset-top",f))};return a(),i.addEventListener("scroll",a),i.addEventListener("resize",a),()=>{i.removeEventListener("scroll",a),i.removeEventListener("resize",a)}},r=[n],e[0]=n,e[1]=s,e[2]=r):(s=e[1],r=e[2]),d.useEffect(s,r)}function Om(){const n=fe.c(1),e=d.useRef(null);_m(e);let s;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx("div",{ref:e,className:"contents",children:t.jsx(jc,{position:"top-center",offset:Mo,mobileOffset:{top:Mo}})}),n[0]=s):s=n[0],s}const _o=300,zm="openchamber.mobile.connectLog.v1",Gs=[];if(typeof window<"u")try{window.localStorage.removeItem(zm)}catch{}const Xi=(n,e)=>{Gs.push({at:Date.now(),step:n,detail:e}),Gs.length>_o&&Gs.splice(0,Gs.length-_o)};typeof window<"u"&&Xi("app:launch","{}");const Bm=()=>[...Gs],Lm=n=>{const e=new Date(n),s=(r,i=2)=>String(r).padStart(i,"0");return`${s(e.getHours())}:${s(e.getMinutes())}:${s(e.getSeconds())}.${s(e.getMilliseconds(),3)}`},cl=n=>`${Lm(n.at)} ${n.step}${n.detail&&n.detail!=="{}"?` ${n.detail}`:""}`,Fm=()=>Gs.map(cl).join(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesView-Csrs_BGv.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/katex.min-F4TD1ekM.js","assets/vendor-zod-DDir2TeQ.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-h8RufjAw.js","assets/katex-CQK6Iqoe.css","assets/useAppFontEffects-Dm6zEvrf.js","assets/vendor-base-ui-CPKyhvxM.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-tanstack-react-virtual-Bmi0tTrf.js","assets/vendor-tanstack-virtual-core-CdGDGrnp.js","assets/vendor-framer-motion-DxDVhOLc.js","assets/vendor-motion-dom-HXPOMxb7.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-codemirror-commands-dar6chwA.js","assets/vendor-codemirror-state-Dek9sMtw.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-B66jUSmE.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-codemirror-language-DyL0aCoH.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-streamparser-CmlTsbN2.js","assets/vendor-codemirror-lang-javascript-Cem6LjJ8.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-CIqXJolH.js","assets/vendor-codemirror-lang-json-C9rLLO0q.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-9qjxcVkg.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-D7VQUxeE.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-Cikh4w2I.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-VzNDjH03.js","assets/vendor-codemirror-lang-python-DVl8-2Op.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-legendapp-list-D2O6oUGf.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/flexokiTheme-PoX6Vqyn.js","assets/vendor-codemirror-search-BKAwkhkm.js","assets/vendor-replit-codemirror-vim-CKWqK1yR.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/moveWorkspacePath-CENAo75W.js","assets/runtimeEndpointReset-lg1O2gVX.js","assets/useMarkdownLocalAssets-BEApAshz.js","assets/useInlineCommentController-a2JepiF3.js","assets/JsonTreeView-BpJU14WJ.js","assets/parseDiffFromFile-BSmRvd3V.js","assets/computeVirtualFileMetrics-DDyA16hp.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-yJ9XpNMI.js","assets/vendor-pierre-theming-Dgp7B_O4.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/vendor-diff-C3JhlQdm.js","assets/Virtualizer-BP6uuKe_.js","assets/isFilePlainText-Dpm-_Qu8.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/shikiHighlight-DBj_a_TN.js","assets/appThemeRegistry-BWap7OfW.js","assets/textMateThemeFromAppTheme-tYpAceV3.js","assets/Virtualizer-nenVQKi3.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/scheduledTasksApi-CJBNpwgy.js","assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-capacitor-push-notifications-KNe1zSBF.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{f as fe,r as ui,j as t,R as d,c as Hs,h as sc}from"./vendor-react-BUCujlKS.js";import{u as Ve,a5 as Mn,bi as Ii,bj as go,bk as nt,b3 as Mt,bl as Ws,bm as In,k as ya,bn as yr,bo as va,bp as nc,bq as wa,br as rc,bs as ic,bt as oc,bu as ac,e as ws,n as _n,y as lc,z as cc,bv as Ct,az as Qn,bw as dc,a6 as pn,b as bo,aU as Fs,a_ as uc,t as fi,aD as xo,ap as fc,ao as mc,bx as pc,by as hc,bz as yo,a8 as gc,a7 as ja,bA as vo,bB as bc,aC as wo,bC as Zn,bD as xc}from"./katex.min-F4TD1ekM.js";import{H as vs,e3 as yc,a5 as ut,d6 as ka,d7 as Sa,K as Na,gT as vc,u as xe,A as pe,cy as wc,I as Y,dN as jc,B as Ie,aA as Ca,ac as Vs,al as Ra,N as se,c9 as Ia,gU as kc,gV as Sc,dx as Ea,a1 as wt,aO as Nc,gW as hs,gX as Cc,gY as jo,gZ as Rc,g_ as Ic,eX as Ei,dt as Ec,du as Ac,G as $e,eF as Tc,eH as Ai,eI as Ti,g$ as Pi,eK as Pc,eJ as Aa,h0 as Di,e1 as ur,cG as Ta,h1 as Dc,bd as Pa,aD as gt,cF as Da,b7 as vr,h2 as Mc,h3 as _c,h4 as Oc,h5 as zc,fq as ar,gd as mi,fY as ns,h6 as Bc,k as Ma,aG as _a,cS as Oa,cT as za,cU as Ba,h7 as Lc,h8 as Fc,h9 as $c,e2 as ko,df as La,ha as Fa,br as Mi,y as $a,hb as Wc,hc as Vc,hd as Wa,he as Uc,d8 as Gc,a7 as Kc,dl as qc,eQ as Hc,hf as Xc,hg as er,hh as Jc,dd as qr,a6 as Yc,hi as Qc,dk as gs,hj as Hr,hk as Zc,hl as Va,L as ed,hm as td,aR as pi,aS as hi,aT as gi,bi as Xr,bg as tr,aU as hn,cR as wr,cD as sd,c2 as Ua,dT as Ga,dB as nd,hn as rd,er as bi,ho as id,hp as Ka,hq as $s,hr as Ks,hs as od,V as ad,W as ld,X as cd,ht as dd,g6 as ud,f_ as qa,aE as Ha,b3 as fd,b5 as md,b6 as pd,fj as hd,fe as gd,b9 as Xa,ff as bd,fk as xd,ek as yd,b8 as vd,fZ as wd,g2 as jd,el as kd,hu as Sd,hv as Nd,hw as Cd,hx as Rd,g5 as So,bc as sr,be as Id,bj as Ed,bf as gn,en as Ad,fh as Td,bU as Pd,em as Dd,ga as Md,gc as _d,g7 as Od,dq as Ja,aV as st,cE as zd,hy as Bd,di as Ld,hz as Fd,hA as $d,hB as Wd,dn as Vd,hC as Ud,fc as No,hD as _i,cf as Gd,hE as Kd,hF as qd,cV as xi,dG as Hd,dH as Xd,dI as Jd,dJ as Yd,hG as Qd,dP as Zd,dO as eu,dK as tu,hH as su,dL as nu,dM as ru,dU as iu,dS as ou,hI as au,hJ as lu,hK as cu,hL as du,hM as uu,hN as fu,hO as mu,hP as pu,dV as hu,dW as gu,dX as bu,dY as xu}from"./useAppFontEffects-Dm6zEvrf.js";import{ac as Us,ad as yu,ae as vu,af as wu,ag as ju,ah as Ya,ai as Qa,aj as Za,ak as ku,al as Su,am as Nu,S as Cu,an as Ru,a as Iu,ao as Eu,z as Au,ap as Tu,aq as Pu,$ as el,K as lr,ar as Du,R as nr,a0 as Mu,a1 as _u,X as Ou,a3 as Jr,a6 as zu,a7 as Bu,O as Lu,as as Fu,U as $u,V as Wu,at as Vu,au as Uu,Y as Gu,d as Ku,a8 as qu,a4 as tl,N as Hu,av as Xu,aw as Ju,aa as Yu,ax as Qu,ay as Zu,az as ef,aA as tf,aB as sf,aC as nf,aD as rf,aE as of,aF as af,aG as lf,aH as cf,aI as df,aJ as uf,aK as ff,aL as mf,aM as pf,aN as hf,aO as gf,aP as bf,aQ as xf}from"./runtimeEndpointReset-lg1O2gVX.js";import{i as yf}from"./initializeSharedPreferences-1Vo6G7CM.js";import{_ as Xs}from"./vendor-vite-runtime-DD1OZmLC.js";import{S as vf,A as wf}from"./SettingsView-CCZOw018.js";import{PlanView as jf}from"./PlanView-D7wshtfZ.js";import{SpaceAccessDialog as kf}from"./SpaceAccessDialog-CxfCzTpe.js";import{SpaceApplyDialog as Sf}from"./SpaceApplyDialog-CYp0A76N.js";import{SpaceSetupOutputDialog as Nf}from"./SpaceSetupOutput-RNo0mWrR.js";import{RunOverview as Cf}from"./RunOverview-Cngm2OOp.js";import{p as Rf}from"./vendor-aparajita-capacitor-secure-storage-5IShChL0.js";import{Capacitor as If,registerPlugin as sl}from"./vendor-capacitor-core-B4EWRrHz.js";import{k as yi,d as Ef,M as fr,J as nl,a as Oi,s as rl,p as Af,_ as Co,f as zi,V as Tf,K as Ro,P as Pf,b as Df,c as Mf,U as _f,Z as Of,Q as zf,r as Bf}from"./vendor-remixicon-react-D6dZ0UwF.js";import{f as Bi,h as Js,i as Li,P as Fi,D as $i,j as Wi}from"./vendor-dnd-kit-core-BZknOX2w.js";import{S as Vi,v as Ui,u as Gi,s as Ki,a as Lf}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as qi}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{c as Hi,p as il}from"./vendor-zustand-BAGL70zf.js";import{toast as vi}from"./vendor-sonner-DFyL3AvE.js";import{S as Ff}from"./SpaceRow-CQp4PkPJ.js";import{UsageStatsView as $f}from"./UsageStatsView-CsC_RzAH.js";import{ArchiveSessionsView as Wf}from"./ArchiveView-4-LVDLmf.js";import{MobileSourceBoard as Vf}from"./SourceBoardView-8Wp0oUvB.js";import{ScheduledTasksView as Uf}from"./ScheduledTasksDialog-DUjDdkw2.js";import{i as Gf,a as Kf,b as qf,c as Hf,d as Xf,s as Jf,S as Yf,W as Qf}from"./SubmoduleDiffSummary-BQduif5s.js";import{R as Zf,I as em,C as tm,a as sm,b as nm,D as rm}from"./InProgressOperationBanner-BVDKUDqn.js";import{C as ol}from"./ChangedPathLabel-BCiU4QDF.js";import{u as im,W as om,c as am,d as lm,g as cm,f as dm,h as um,l as fm,k as mm}from"./useWalkthroughReview-BspAr9Aa.js";import{u as Io,a as pm,b as hm,c as gm,i as Eo,f as Yr,B as bm,C as xm,P as Ao}from"./PullRequestComparisonSelector-BBdU2rL1.js";import{P as ym}from"./PierreDiffViewer-BZDNV4Uj.js";import{p as vm}from"./parseDiffFromFile-BSmRvd3V.js";import{o as al,s as To}from"./vendor-zod-DDir2TeQ.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-opencode-client-h8RufjAw.js";import"./vendor-base-ui-CPKyhvxM.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tanstack-react-virtual-Bmi0tTrf.js";import"./vendor-tanstack-virtual-core-CdGDGrnp.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-dar6chwA.js";import"./vendor-codemirror-state-Dek9sMtw.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-B66jUSmE.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-language-DyL0aCoH.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-streamparser-CmlTsbN2.js";import"./vendor-codemirror-lang-javascript-Cem6LjJ8.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-CIqXJolH.js";import"./vendor-codemirror-lang-json-C9rLLO0q.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-9qjxcVkg.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-D7VQUxeE.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-Cikh4w2I.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-VzNDjH03.js";import"./vendor-codemirror-lang-python-DVl8-2Op.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-legendapp-list-D2O6oUGf.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./install-FletzeYD.js";import"./vendor-yaml-CE-D_49-.js";import"./flexokiTheme-PoX6Vqyn.js";import"./vendor-codemirror-search-BKAwkhkm.js";import"./vendor-replit-codemirror-vim-CKWqK1yR.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./shikiHighlight-DBj_a_TN.js";import"./appThemeRegistry-BWap7OfW.js";import"./textMateThemeFromAppTheme-tYpAceV3.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-qrcode-DTJ12-WC.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./vendor-strip-json-comments-5dJlOkP1.js";import"./useCallableModelProviders-BK3j8Sde.js";import"./restartOpenCode-D8ExMl55.js";import"./useInlineCommentController-a2JepiF3.js";import"./useMarkdownLocalAssets-BEApAshz.js";import"./spaceNetwork-CNxs51y4.js";import"./space-apply-COMscpEL.js";import"./scheduledTasksApi-CJBNpwgy.js";import"./vendor-cron-parser-CjvYVigk.js";import"./vendor-luxon-BZ0puJYg.js";import"./computeVirtualFileMetrics-DDyA16hp.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isDiffPlainText-yXcpftjI.js";import"./vendor-diff-C3JhlQdm.js";import"./pierreDiffTint-cyYFR1bm.js";import"./Virtualizer-nenVQKi3.js";let ll=null,Po=!1;const wm=new Promise(n=>{ll=n});function jm(){Po||(Po=!0,ll?.())}const km=6,Sm=n=>n.parentID??null,wi=n=>{const e=n.replace(/\/+$/,"");return e.slice(e.lastIndexOf("/")+1)||e},Nm=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),Cm=(n,e)=>{if(!n)return"";let s=null,r=-1;for(const i of e){const l=Nm(i.path);(n===l||n.startsWith(`${l}/`))&&l.length>r&&(s=i,r=l.length)}return s?s.label?.trim()||wi(s.path):wi(n)},Rm=()=>{const n=vs.getState().activeSessions,e=yc.getState().index.session.unseenCount,s=Ve.getState().notifyOnSubtasks,r=ut.getState().projects,i=ka.getState().ids,l=Sa.getState().rankById;let o=0;const a=[];for(const p of n){const m=Sm(p)!==null,b=(e[p.id]??0)>0&&(!m||s);b&&(o+=1),m||a.push({session:p,unread:b,project:Cm(Na(p),r)})}a.sort((p,m)=>vc(p.session,m.session,i,l));const f=a.slice(0,km).map(({session:p,unread:m,project:h})=>({id:p.id,title:p.title??"",unread:m,project:h}));return{runtimeKey:Mn(),attentionCount:o,recentSessions:f,projects:r.map(p=>({id:p.id,label:p.label?.trim()||wi(p.path)}))}},Im="__OPENCHAMBER_WIDGET_SNAPSHOT__",Em=()=>{typeof window>"u"||(window[Im]=()=>{try{return JSON.stringify(Rm())}catch{return null}})},Qr="mobile-app-update-available",Do="mobile-app-update-toast-dismissed-version",Am=()=>{const n=fe.c(8),{t:e}=xe(),s=Us(Tm),r=Us(Pm),i=Us(Dm),l=Us(Mm);let o;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=new Set,n[0]=o):o=n[0];const a=ui.useRef(o);let f,p;return n[1]!==s||n[2]!==l||n[3]!==r||n[4]!==e||n[5]!==i?(f=()=>{if(Ii()!=="android"||r!=="mobile"||!s||!i||!l){pe.dismiss(Qr);return}go().getItem(Do)!==i&&(a.current.has(i)||(a.current.add(i),pe.info(e("mobileUpdate.toast.available.title"),{id:Qr,description:e("mobileUpdate.toast.available.description",{version:i}),duration:1/0,icon:t.jsx(Y,{name:"download",className:"h-4 w-4 text-muted-foreground"}),action:{label:e("mobileUpdate.toast.actions.download"),onClick:()=>{wc(l)}},cancel:{label:e("mobileUpdate.toast.actions.dismiss"),onClick:()=>{go().setItem(Do,i),pe.dismiss(Qr)}}})))},p=[s,l,r,e,i],n[1]=s,n[2]=l,n[3]=r,n[4]=e,n[5]=i,n[6]=f,n[7]=p):(f=n[6],p=n[7]),ui.useEffect(f,p),null};function Tm(n){return n.available}function Pm(n){return n.runtimeType}function Dm(n){return n.info?.version}function Mm(n){return n.info?.downloadUrl}const Mo="calc(var(--oc-safe-area-top, 0px) + var(--oc-visual-viewport-offset-top, 0px) + 16px)";function _m(n){const e=fe.c(3);let s,r;e[0]!==n?(s=()=>{const i=window.visualViewport,l=n.current;if(!i||!l)return;let o="";const a=()=>{const f=`${Math.max(0,Math.round(i.offsetTop))}px`;f!==o&&(o=f,l.style.setProperty("--oc-visual-viewport-offset-top",f))};return a(),i.addEventListener("scroll",a),i.addEventListener("resize",a),()=>{i.removeEventListener("scroll",a),i.removeEventListener("resize",a)}},r=[n],e[0]=n,e[1]=s,e[2]=r):(s=e[1],r=e[2]),d.useEffect(s,r)}function Om(){const n=fe.c(1),e=d.useRef(null);_m(e);let s;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx("div",{ref:e,className:"contents",children:t.jsx(jc,{position:"top-center",offset:Mo,mobileOffset:{top:Mo}})}),n[0]=s):s=n[0],s}const _o=300,zm="openchamber.mobile.connectLog.v1",Gs=[];if(typeof window<"u")try{window.localStorage.removeItem(zm)}catch{}const Xi=(n,e)=>{Gs.push({at:Date.now(),step:n,detail:e}),Gs.length>_o&&Gs.splice(0,Gs.length-_o)};typeof window<"u"&&Xi("app:launch","{}");const Bm=()=>[...Gs],Lm=n=>{const e=new Date(n),s=(r,i=2)=>String(r).padStart(i,"0");return`${s(e.getHours())}:${s(e.getMinutes())}:${s(e.getSeconds())}.${s(e.getMilliseconds(),3)}`},cl=n=>`${Lm(n.at)} ${n.step}${n.detail&&n.detail!=="{}"?` ${n.detail}`:""}`,Fm=()=>Gs.map(cl).join(`
|
|
3
3
|
`),dl=(n,e)=>{const s=fe.c(10),r=700,i=d.useRef(null),l=d.useRef(null),o=d.useRef(!1);let a;s[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{i.current!==null&&window.clearTimeout(i.current),i.current=null,l.current=null},s[0]=a):a=s[0];const f=a;let p,m;s[1]===Symbol.for("react.memo_cache_sentinel")?(p=()=>f,m=[f],s[1]=p,s[2]=m):(p=s[1],m=s[2]),d.useEffect(p,m);let h;s[3]!==r||s[4]!==n?(h=S=>{o.current=!1,l.current={x:S.clientX,y:S.clientY},i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>{i.current=null,o.current=!0,n()},r)},s[3]=r,s[4]=n,s[5]=h):h=s[5];const b=h;let u;s[6]===Symbol.for("react.memo_cache_sentinel")?(u=S=>{const M=l.current;M&&(Math.abs(S.clientX-M.x)>10||Math.abs(S.clientY-M.y)>10)&&f()},s[6]=u):u=s[6];const g=u;let y;s[7]===Symbol.for("react.memo_cache_sentinel")?(y=S=>{o.current&&(o.current=!1,S.preventDefault(),S.stopPropagation())},s[7]=y):y=s[7];const w=y;let j;return s[8]!==b?(j={onPointerDown:b,onPointerMove:g,onPointerUp:f,onPointerCancel:f,onClickCapture:w},s[8]=b,s[9]=j):j=s[9],j},$m=async(n,e)=>{let s;const r=new Promise(i=>{s=setTimeout(()=>i({response:null,failure:"timeout"}),n)});try{return await Promise.race([e.then(i=>({response:i,failure:null}),i=>({response:null,failure:i instanceof Error?i.message:String(i)})),r])}finally{s!==void 0&&clearTimeout(s)}},Wm=(n,e)=>new Promise(s=>{const r=a=>{clearTimeout(l),o(),s(a)},i=a=>{a.state==="connected"?r(!0):(a.state==="idle"||a.terminal)&&r(!1)},l=setTimeout(()=>r(!1),e),o=n.subscribeStatus(i);i(n.getStatus())}),Ys=(n,e,s,r)=>$m(r,n.fetch(e,s)),ul=async(n,e,s,r)=>{const i=Date.now()+r;let l=await Ys(n,e,s,r);for(;!l.response&&l.failure!=="timeout"&&n.getStatus().state!=="connected";){const o=i-Date.now();if(o<=0||!await Wm(n,o))return l;const a=i-Date.now();if(a<=0)return l;l=await Ys(n,e,s,a)}return l},mr="openchamber.mobile.connections.v1",Vm="openchamber.mobile.",Oo="openchamber.mobile.deviceId",Um=()=>{try{const n=window.localStorage.getItem(Oo);if(n&&n.trim())return n.trim();const e=crypto.randomUUID();return window.localStorage.setItem(Oo,e),e}catch{return crypto.randomUUID()}},zo=()=>`mobile:${Um()}`,Bo=()=>{try{const n=If.getPlatform();return n==="ios"||n==="android"?n:void 0}catch{return}},fl=12,Ji=8e3,Gm=2500,Km=3e3,pr=2500,qm=()=>{let n=0;return{begin:()=>(n+=1,n),cancel:()=>{n+=1},isCurrent:e=>e===n}},tn=n=>{const e=n.trim();if(!e)return"";const s=/^https?:\/\//i.test(e)?e:`http://${e}`,r=new URL(s);return r.hash="",r.search="",r.pathname=r.pathname.replace(/\/+$/,""),r.toString().replace(/\/+$/,"")},cr=n=>{try{return new URL(n).host}catch{return n}},Qs=n=>{try{return tn(n)}catch{return n.trim().replace(/\/+$/g,"")}},ml=(n,e)=>Qs(n)===Qs(e),pl=n=>`relay:${n.serverId}@${n.relayUrl.trim()}`,Hm=n=>`relay://${n.serverId}`,jr=n=>n.candidates.filter(e=>e.kind==="direct"),rs=n=>{const e=n.candidates.find(s=>s.kind==="relay");return e&&e.kind==="relay"?e.relay:null},Gt=n=>{const e=jr(n)[0];if(e)return e.url;const s=rs(n);return s?Hm(s):""},Lo=n=>n.serverId||rs(n)?.serverId||null,bt=n=>{const e=rs(n);if(e)return pl(e);if(n.serverId)return`server:${n.serverId}`;const s=jr(n)[0];return s?Qs(s.url):""},Fo=(n,e)=>{const s=Lo(n),r=Lo(e);return s&&r?s===r:hl(n.candidates,e.candidates)},hl=(n,e)=>{const s=n.find(l=>l.kind==="relay"),r=s&&s.kind==="relay"?s.relay.serverId:null,i=new Set(n.filter(l=>l.kind==="direct").map(l=>Qs(l.url)));return e.some(l=>l.kind==="relay"?r!==null&&l.relay.serverId===r:i.has(Qs(l.url)))},Yi=n=>{const e=(()=>{try{return tn(n)}catch{return""}})();return e?[{kind:"direct",url:e}]:[]},$o=n=>{if(n.candidates&&n.candidates.length>0)return n.candidates;const e=[];return typeof n.url=="string"&&n.url.trim()&&!/^relay:\/\//i.test(n.url.trim())&&e.push(...Yi(n.url)),n.relay&&e.push({kind:"relay",relay:n.relay}),e},Qi=n=>{if(!n||typeof n!="object"||Array.isArray(n))return null;const e=n;if(typeof e.relayUrl!="string"||!e.relayUrl.trim()||typeof e.serverId!="string"||!e.serverId.trim())return null;const s=e.hostEncPubJwk;if(!s||typeof s!="object"||Array.isArray(s))return null;const r=s;return r.kty!=="EC"||r.crv!=="P-256"||typeof r.x!="string"||!r.x||typeof r.y!="string"||!r.y?null:{relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:{kty:"EC",crv:"P-256",x:r.x,y:r.y}}},gl=n=>{try{return JSON.stringify(n)}catch{return String(n)}},Pe=(n,e={})=>{const s=gl(e);console.info("[mobile-connect]",n,s),Xi(n,s)},bn=(n,e={})=>{Pe(n,e)},Zs=(n,e={})=>{const s=gl(e);console.info("[mobile-storage]",n,s),Xi(n,s)},Xm=n=>{if(typeof n!="string")return n;try{return JSON.parse(n)}catch{return n}},Jm=n=>{if(typeof n!="string")return n??void 0;try{return JSON.parse(n)}catch{return n}},Ym=async(n,e)=>{if(!nt())return null;try{const{CapacitorHttp:s}=await Xs(async()=>{const{CapacitorHttp:l}=await import("./vendor-capacitor-core-B4EWRrHz.js");return{CapacitorHttp:l}},[]),r=ic(n,new Headers(e?.headers)),i=await s.request({url:n,method:e?.method||"GET",headers:Object.fromEntries(r.entries()),data:Jm(e?.body)});return{ok:i.status>=200&&i.status<300,status:i.status,source:"native-http",json:async()=>Xm(i.data)}}catch(s){return Pe("native-http:failed",{url:n,error:s instanceof Error?s.message:String(s)}),null}},Qm=async(n,e)=>{const s=await fetch(n,e).catch(r=>(Pe("browser-fetch:failed",{url:n,error:r instanceof Error?r.message:String(r)}),null));return s?{ok:s.ok,status:s.status,source:"browser-fetch",json:()=>s.json()}:null},hr=async(n,e,s)=>{let r;const i=new Promise(l=>{r=window.setTimeout(()=>{s?.(),l(null)},n)});try{return await Promise.race([e,i])}catch{return null}finally{r!==void 0&&window.clearTimeout(r)}},js=async(n,e,s)=>{const r=s?.totalTimeoutMs??Ji,i=Date.now(),l=await hr(Math.min(Gm,r),Ym(n,e));if(l)return l;const o=new AbortController,a=Math.max(500,r-(Date.now()-i));return hr(a,Qm(n,{...e,signal:o.signal}),()=>o.abort())},kr=async n=>{if(!n)return null;const e=await n.json().catch(()=>null);if(!e||typeof e!="object")return null;const s=e;return{authenticated:typeof s.authenticated=="boolean"?s.authenticated:void 0,disabled:typeof s.disabled=="boolean"?s.disabled:void 0,scope:typeof s.scope=="string"?s.scope:void 0}},bl=async n=>{const e=await n.json().catch(()=>null),s=e&&typeof e=="object"?e.serverId:null;return typeof s=="string"&&s?s:void 0},en=15e3,xl=n=>{n?.owned&&n.client.close()},Wo=async(n,e)=>{if(n.status===401)return e?"auth-failed":"needs-login";if(!n.ok&&n.status!==404)return"auth-failed";const s=await kr(n);return s&&s.disabled!==!0&&s.authenticated===!1?e?"auth-failed":"needs-login":"ok"},Zm=async(n,e,s,r=en,i)=>{const l=e?{Authorization:`Bearer ${e}`}:void 0,o=wl(n);if(o){const{response:f,failure:p}=await Ys(o,"/auth/session",{headers:l},r);if(Pe("relay:session",{shared:!0,ok:f?.ok===!0,status:f?.status??null,hasToken:!!e,error:p}),f){const m=await Wo(f,e);return m==="ok"&&i?.keepTunnel?{outcome:m,tunnel:{client:o,owned:!1}}:{outcome:m}}}const a=wa({relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk});try{const{response:f,failure:p}=await ul(a,"/auth/session",{headers:l},r);Pe("relay:session",{shared:!1,ok:f?.ok===!0,status:f?.status??null,hasToken:!!e,error:p});const m=f?await Wo(f,e):yr(a.getStatus())?"relay-limit":"unreachable";return m==="ok"&&i?.keepTunnel?{outcome:m,tunnel:{client:a,owned:!0}}:(a.close(),{outcome:m})}catch(f){throw a.close(),f}},ep=(n,e,s,r,i)=>{const l=typeof window<"u"?window.location.origin:"",o={relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk,...s?{grant:s}:{}};i&&nc(o,i),Ws({apiBaseUrl:l,clientToken:e,runtimeKey:r??pl(n),relay:o})},tp=n=>{if(!n||typeof n!="object")return null;const e=n;if(e.kind==="direct")return typeof e.url=="string"&&e.url.trim()?{kind:"direct",url:e.url}:null;if(e.kind==="relay"){const s=Qi(e.relay);return s?{kind:"relay",relay:s}:null}return null},sp=n=>{if(n.mode==="relay"){const e=Qi(n.relay);return e?[{kind:"relay",relay:e}]:[]}return typeof n.url=="string"?Yi(n.url):[]},ks=()=>{if(typeof window>"u")return[];let n;try{n=JSON.parse(window.localStorage.getItem(mr)||"[]")}catch{return[]}if(!Array.isArray(n))return[];const e=nt();return n.flatMap(s=>{if(!s||typeof s!="object")return[];const r=s;if(typeof r.id!="string")return[];const i=Array.isArray(r.candidates)?r.candidates.map(tp).filter(f=>!!f):sp(r);if(i.length===0)return[];const l=typeof r.clientToken=="string"&&r.clientToken.trim()?r.clientToken:void 0,o=typeof r.label=="string"&&r.label.trim()?r.label:cr(Gt({candidates:i})),a={id:r.id,label:o,candidates:i,serverId:typeof r.serverId=="string"&&r.serverId.trim()?r.serverId:void 0,lastUsedAt:typeof r.lastUsedAt=="number"?r.lastUsedAt:0};return e?[{...a,hasToken:!!r.hasToken||!!l}]:[{...a,clientToken:l,hasToken:!!l}]}).sort((s,r)=>r.lastUsedAt-s.lastUsedAt)},ji=n=>n.kind==="relay"?{kind:"relay",relay:{relayUrl:n.relay.relayUrl,serverId:n.relay.serverId,hostEncPubJwk:n.relay.hostEncPubJwk}}:{kind:"direct",url:n.url},Zi=n=>{if(typeof window>"u")return;const e=nt(),s=n.slice(0,fl).map(r=>{const i={id:r.id,label:r.label,candidates:r.candidates.map(ji),serverId:r.serverId,lastUsedAt:r.lastUsedAt};return e?{...i,hasToken:!!(r.hasToken||r.clientToken)}:{...i,clientToken:r.clientToken}});try{window.localStorage.setItem(mr,JSON.stringify(s))}catch(r){console.warn("[mobile-storage] failed to persist connection metadata",r)}},yl=(n,e)=>{const s=(e.id?n.find(l=>l.id===e.id):void 0)??n.find(l=>Fo(l,e)),r=nt(),i={id:e.id||s?.id||crypto.randomUUID(),label:e.label,candidates:e.candidates,serverId:e.serverId??s?.serverId,lastUsedAt:Date.now(),...r?{hasToken:e.hasToken??(!!e.clientToken||s?.hasToken||!1)}:{clientToken:e.clientToken??s?.clientToken,hasToken:!!(e.clientToken??s?.clientToken)}};return[i,...n.filter(l=>l.id!==i.id&&!Fo(l,i))].slice(0,fl)},eo=Rf,np=0,to=n=>`${Vm}token.${encodeURIComponent(n)}`,rp=async(n,e)=>{let s;const r=new Promise(i=>{s=window.setTimeout(()=>i(e),Km)});try{return await Promise.race([n.catch(()=>e),r])}finally{s!==void 0&&window.clearTimeout(s)}},so=async(n,e,s)=>nt()?rp(e().catch(r=>(console.warn(`[mobile-storage] ${n} failed`,r),s)),s):s,En=async n=>{Zs("secure:read-start",{key:n});const e=await so("secure:read",async()=>(await eo.internalGetItem({prefixedKey:to(n),sync:!1})).data,null),s=typeof e=="string"&&e.trim()?e:void 0;return Zs("secure:read",{key:n,hasToken:!!s}),s},xs=async(n,e)=>{Zs("secure:write-start",{key:n});const s=await so("secure:write",async()=>(await eo.internalSetItem({prefixedKey:to(n),data:e,sync:!1,access:np}),!0),!1);return Zs("secure:write",{key:n,ok:s}),s},ip=async n=>{await so("secure:delete",async()=>(await eo.internalRemoveItem({prefixedKey:to(n),sync:!1}),!0),!1)},op=async(n,e)=>{let s=0,r=0;return{records:await Promise.all(n.map(async l=>{if(!l||typeof l!="object")return l;const o=l,a=typeof o.url=="string"?o.url:null,f=typeof o.clientToken=="string"?o.clientToken.trim():"";if(!a||!f)return l;if(!await e(a,f))return r+=1,l;s+=1;const{clientToken:p,...m}=o;return{...m,hasToken:!0}})),migrated:s,failed:r}},vl=async()=>{if(typeof window>"u"||!nt())return;let n;try{n=JSON.parse(window.localStorage.getItem(mr)||"[]")}catch{return}if(!Array.isArray(n))return;const e=n.filter(r=>!!r&&typeof r=="object"&&typeof r.url=="string"&&typeof r.clientToken=="string"&&!!r.clientToken.trim());if(e.length===0)return;Zs("secure:migrate-start",{count:e.length});const s=await op(n,async(r,i)=>{const l=Qs(r);return await xs(l,i)?await En(l)===i:!1});if(s.migrated>0)try{window.localStorage.setItem(mr,JSON.stringify(s.records))}catch(r){console.warn("[mobile-storage] failed to finalize secure token migration",r);return}Zs("secure:migrate-done",{migrated:s.migrated,failed:s.failed})},ap=async()=>(await vl(),ks()),gr=async n=>{const e=yl(ks(),n);return Zi(e),nt()&&n.clientToken&&await xs(bt(e[0]),n.clientToken),e},lp=async n=>{const e=ks(),s=e.find(i=>i.id===n)??null,r=e.filter(i=>i.id!==n);return Zi(r),s&&nt()&&await ip(bt(s)),r},cp=1500,br=async(n,e,s)=>{const r=s?.fast?{totalTimeoutMs:pr}:void 0,i=rs({candidates:n})?.serverId??null,l=n.find(p=>p.kind==="relay")??null,o=n.filter(p=>p.kind==="direct"),a=async()=>{for(const p of o){const m=tn(p.url)||p.url,h=e?{Authorization:`Bearer ${e}`}:void 0,b=await js(`${m}/health`,{method:"GET"},r);if(Pe("probe:direct:health",{url:m,ok:b?.ok===!0,status:b?.status??null,source:b?.source??null}),!b?.ok)continue;if(i){const w=await bl(b);if(w&&w!==i){Pe("probe:server-id-mismatch",{url:m});continue}}const u=await js(`${m}/auth/session`,{method:"GET",credentials:e?"omit":"include",headers:h},r);if(Pe("probe:direct:session",{url:m,ok:u?.ok===!0,status:u?.status??null,source:u?.source??null,hasToken:!!e}),u?.status===401)return{status:"needs-login"};if(!u||!u.ok&&u.status!==404)continue;const g=await kr(u);if(g&&g.disabled!==!0&&g.authenticated===!1)return{status:"needs-login"};const y=g?.disabled===!0;return!e&&nt()&&!y&&g?.scope!=="client"?{status:"needs-login"}:{status:"ok",transport:{kind:"direct",url:m}}}return{status:"unreachable"}},f=async()=>{if(!l)return{status:"unreachable"};const{outcome:p,tunnel:m}=await Zm(l.relay,e,void 0,s?.fast?pr:Ji,{keepTunnel:!0});return p==="ok"?{status:"ok",transport:{kind:"relay",relay:l.relay,tunnel:m}}:p==="needs-login"||p==="auth-failed"?{status:"needs-login"}:p==="relay-limit"?{status:"relay-limit"}:{status:"unreachable"}};return l?o.length===0?f():new Promise(p=>{let m=!1,h=!1,b,u=null,g=null;const y=S=>{S?.status==="ok"&&S.transport.kind==="relay"&&xl(S.transport.tunnel)},w=S=>{m||(m=!0,p(S))},j=()=>{h||m||(b!==void 0&&(window.clearTimeout(b),b=void 0),f().then(S=>{if(g=S,m||h){y(S);return}if(S.status==="ok"||S.status==="needs-login"){w(S);return}u&&w(S)}))};a().then(S=>{if(u=S,!m){if(S.status==="ok"||S.status==="needs-login"){h=!0,b!==void 0&&window.clearTimeout(b),y(g),w(S);return}if(g){w(g);return}j()}}),b=window.setTimeout(j,cp)}):a()},ys=(n,e,s)=>{no=!1,n.kind==="relay"?ep(n.relay,e,s?.grant,s?.runtimeKey,n.tunnel?.client):Ws({apiBaseUrl:n.url,clientToken:e,runtimeKey:s?.runtimeKey}),kl()},bs=()=>{const n=ks()[0];return n?.label?.trim()?n.label:null};let no=!1;const dp=()=>{no=!0},xn=async n=>{if(no)return Pe("auto-connect:suppressed",{}),{status:"no-candidate"};const e=n?.fast!==!1;await vl();const s=ks()[0];if(Pe("auto-connect:start",{hasCandidate:!!s,fast:e}),!s)return{status:"no-candidate"};let r;if(nt()){if(s.hasToken&&(r=await En(bt(s)),!r))return{status:"no-candidate"}}else if(r=s.clientToken,!r&&s.hasToken)return{status:"no-candidate"};const i=await br(s.candidates,r,{fast:e});return Pe("auto-connect:probe",{status:i.status,candidates:s.candidates.map(l=>l.kind)}),i.status==="needs-login"?{status:"needs-login",label:s.label}:i.status==="relay-limit"?{status:"relay-limit",label:s.label}:i.status!=="ok"?{status:"unreachable",label:s.label}:n?.skipIfConnected&&Mt()?(i.transport.kind==="relay"&&xl(i.transport.tunnel),Pe("auto-connect:superseded",{}),{status:"no-candidate"}):(await gr({id:s.id,label:s.label,candidates:s.candidates}),ys(i.transport,r??null,{runtimeKey:bt(s)}),{status:"connected"})},up=async(n,e)=>{let s="";try{s=tn(n.url)}catch{return!1}if(!s)return!1;const r=n.clientToken?.trim()||void 0,i=r?{Authorization:`Bearer ${r}`}:void 0,l=e?.fast?{totalTimeoutMs:pr}:void 0;if(!(await js(`${s}/health`,{method:"GET",headers:i},l))?.ok)return!1;const a=await js(`${s}/auth/session`,{method:"GET",credentials:r?"omit":"include",headers:i},l);if(!a||!a.ok&&a.status!==404)return!1;const f=await kr(a);return!(f&&f.disabled!==!0&&f.authenticated===!1)},Vo=(n,e)=>{n?.kind==="relay"&&n.owned&&!e&&n.tunnel.close()},fp=(n,e)=>n.kty===e.kty&&n.crv===e.crv&&n.x===e.x&&n.y===e.y,wl=n=>{const e=va(),s=rc();return!e||!s||e.getStatus().state!=="connected"?null:s.relayUrl===n.relayUrl&&s.serverId===n.serverId&&fp(s.hostEncPubJwk,n.hostEncPubJwk)?e:null},mp=n=>[...n].sort((e,s)=>{const r=(e.priority??100)-(s.priority??100);if(r!==0)return r;const i=l=>l.type==="relay"?2:l.url.startsWith("https://")?0:1;return i(e)-i(s)}).flatMap(e=>{if(e.type==="relay"){const s=Qi({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk});return s?[{kind:"relay",relay:s}]:[]}return Yi(e.url)}),Uo=async n=>{let e=!1;const s=rs({candidates:n})?.serverId??null;for(const r of n){if(r.kind==="relay"){const a=wl(r.relay);if(a){const h=await Ys(a,"/health",void 0,Ji);if(Pe("establish:relay:health",{shared:!0,ok:h.response?.ok===!0,status:h.response?.status??null,error:h.failure}),h.response?.ok)return{kind:"relay",relay:r.relay,tunnel:a,owned:!1}}const f=wa(r.relay),{response:p,failure:m}=await ul(f,"/health",void 0,en);if(Pe("establish:relay:health",{shared:!1,ok:p?.ok===!0,status:p?.status??null,error:m}),p?.ok)return{kind:"relay",relay:r.relay,tunnel:f,owned:!0};e||=yr(f.getStatus()),f.close();continue}const i=tn(r.url)||r.url,l=await js(`${i}/health`,{method:"GET"});if(Pe("establish:direct:health",{ok:l?.ok===!0,status:l?.status??null}),!l?.ok)continue;const o=await bl(l);if(s&&o&&o!==s){Pe("establish:server-id-mismatch",{url:i});continue}return{kind:"direct",url:i,serverId:o}}return e?"relay-limit":null},pp=async(n,e)=>{if(!In())return await up(n,e)?"valid":"invalid";const s=await hr(e?.fast?pr:en,ya("/auth/session").then(i=>i).catch(()=>null));if(!s)return yr(va()?.getStatus())?"relay-limit":"valid";if(s.status===401)return"invalid";if(!s.ok&&s.status!==404)return"valid";const r=await kr(s);return r&&r.disabled!==!0&&r.authenticated===!1?"invalid":"valid"},hp=n=>n.kind==="relay"?In():!In()&&ml(n.url,Mt()),jl=()=>{const n=Mn();return n?ks().find(e=>bt(e)===n)??null:null},Go=n=>{const e=Mn();return!!e&&bt(n)===e},dr=async n=>{const e=n?.fast!==!1,s=jl();if(!s)return Pe("reprobe:no-connection",{runtimeKey:!!Mn()}),"no-connection";let r;if(nt()?r=s.hasToken?await En(bt(s)):void 0:r=s.clientToken,!r&&s.hasToken)return Pe("reprobe:no-token",{hasToken:!0}),"unreachable";Pe("reprobe:start",{candidates:s.candidates.map(m=>m.kind),fast:e,hasToken:!!r});const i=s.candidates.findIndex(m=>hp(m.kind==="relay"?{kind:"relay",relay:m.relay}:{kind:"direct",url:m.url})),l=i>=0?s.candidates.slice(0,i):s.candidates,o=await br(l,r,{fast:e});if(Pe("reprobe:better",{status:o.status,probed:l.length}),o.status==="ok")return await gr({id:s.id,label:s.label,candidates:s.candidates}),ys(o.transport,r??null,{runtimeKey:bt(s)}),"switched";if(o.status==="needs-login")return"needs-login";let a=null;if(i>=0&&(a=await pp({url:Mt(),clientToken:r},{fast:e}),Pe("reprobe:current",{current:a}),a==="valid"))return kl(),"unchanged";const f=i>=0?s.candidates.slice(i+1):[],p=await br(f,r,{fast:e});return Pe("reprobe:fallback",{status:p.status,probed:f.length}),p.status==="ok"?(await gr({id:s.id,label:s.label,candidates:s.candidates}),ys(p.transport,r??null,{runtimeKey:bt(s)}),"switched"):p.status==="needs-login"?"needs-login":[o.status,p.status,a].includes("relay-limit")?"relay-limit":"unreachable"},gp=5e3;let Zr=!1;const bp=async()=>{if(Zr)return"skipped";const n=jl();if(!n)return Pe("candidates:refresh-skip",{reason:"no-active-connection"}),"skipped";const e=rs(n);if(!e)return Pe("candidates:refresh-skip",{reason:"no-relay-candidate"}),"skipped";Zr=!0;try{const s=await hr(en,ya("/api/client-auth/connection/candidates").then(p=>p).catch(()=>null));if(!s?.ok)return Pe("candidates:refresh-skip",{reason:"fetch-failed",status:s?.status??null}),"skipped";const r=await s.json().catch(()=>null);if(!r||r.serverId!==e.serverId)return Pe("candidates:refresh-skip",{reason:"server-id-mismatch"}),"skipped";const i=Array.isArray(r.candidates)?r.candidates:[],l=[];for(const p of i){if(!p||typeof p!="object")continue;const m=p;if(!(m.type!=="lan"||typeof m.url!="string"))try{const h=tn(m.url);h&&!l.includes(h)&&l.push(h)}catch{}}if(l.length===0)return Pe("candidates:refresh-skip",{reason:"no-lan-reported"}),"skipped";const o=jr(n).filter(p=>p.url.startsWith("https://")),a=[...l.map(p=>({kind:"direct",url:p})),...o,{kind:"relay",relay:e}];return JSON.stringify(n.candidates.map(ji))===JSON.stringify(a.map(ji))?"unchanged":(Pe("candidates:refreshed",{lanCount:l.length}),await gr({id:n.id,label:n.label,candidates:a}),"updated")}finally{Zr=!1}},kl=()=>{typeof window>"u"||window.setTimeout(()=>{(async()=>{const n=await bp().catch(()=>"skipped");Pe("candidates:refresh-result",{result:n}),n==="updated"&&In()&&await dr().catch(()=>null)})()},gp)},Sl=n=>{const{t:e}=xe(),[s,r]=d.useState(()=>ks()),[i,l]=d.useState(null),[o,a]=d.useState(null),[f,p]=d.useState(null),m=d.useRef(s),h=d.useRef(null),b=d.useRef(qm()),u=d.useCallback(N=>{m.current=N,r(N)},[]),g=d.useCallback(N=>{h.current=N,l(N)},[]),y=d.useCallback(N=>{h.current===N&&(h.current=null,l(null))},[]);d.useEffect(()=>{let N=!1;return ap().then(v=>{N||u(v)}),()=>{N=!0}},[u]);const w=d.useCallback(N=>{const v=yl(m.current,N);return u(v),Zi(v),v},[u]),j=d.useCallback(async N=>{a(null),g("connect");try{const v=$o(N);if(v.length===0){a(e("mobile.connect.error.urlRequired"));return}const T=N.id?m.current.find(D=>D.id===N.id):m.current.find(D=>hl(D.candidates,v)),O=N.label?.trim()||T?.label||cr(Gt({candidates:v})),B=N.relayGrant,z=bt({candidates:v,serverId:T?.serverId});let _=N.clientToken?.trim()||void 0;const A=!!_;_||(nt()?T?.hasToken&&(_=await En(z)):_=T?.clientToken),Pe("connect:start",{candidates:v.map(D=>D.kind),hasToken:!!_});const R=await br(v,_);if(Pe("connect:probe",{status:R.status}),R.status==="unreachable"){a(e("mobile.connect.error.unreachable"));return}if(R.status==="relay-limit"){a(e("mobile.connect.error.relayLimit"));return}if(R.status==="needs-login"){w({id:T?.id,label:O,candidates:v}),p({id:T?.id??crypto.randomUUID(),label:O,candidates:v,serverId:T?.serverId,relay:rs({candidates:v})??void 0,relayGrant:B});return}_&&A&&nt()&&await xs(z,_),w({id:T?.id,label:O,candidates:v,clientToken:_}),ys(R.transport,_??null,{runtimeKey:z,grant:B}),n()}catch(v){console.warn("[mobile-connect] connect threw",v),a(e("mobile.connect.error.invalidUrl"))}finally{y("connect")}},[g,y,n,w,e]),S=d.useCallback(async N=>{if(h.current==="pairing")return;a(null),g("pairing");const v=mp(N.candidates);let T=null,O=!1;try{const B=await Uo(v);if(!B||B==="relay-limit"){a(e(B?"mobile.connect.error.relayLimit":"mobile.connect.error.unreachable"));return}T=B;const z=JSON.stringify({pairingId:N.pairingId,secret:N.secret,clientLabel:"OpenChamber Mobile",clientKind:"mobile",deviceName:"OpenChamber Mobile",devicePlatform:Bo(),dedupeKey:zo()}),_={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:z},A=T.kind==="relay"?await Ys(T.tunnel,"/api/client-auth/pairing/redeem",_,en):{response:await js(`${T.url}/api/client-auth/pairing/redeem`,_),failure:null},R=A.response;if(Pe("pairing:redeem",{transport:T.kind,ok:R?.ok===!0,status:R?.status??null,error:A.failure}),!R?.ok){a(e("mobile.connect.error.authRequired"));return}const D=await R.json().catch(()=>null),V=typeof D?.clientToken=="string"?D.clientToken.trim():"";if(!V){a(e("mobile.connect.error.authRequired"));return}const L=typeof D?.server?.label=="string"?D.server.label:"",K=N.label||L||cr(Gt({candidates:v})),F=T.kind==="direct"?T.serverId:void 0,U=bt({candidates:v,serverId:F});if(nt()&&!await xs(U,V)){a(e("mobile.connect.error.authRequired"));return}w({label:K,candidates:v,serverId:F,clientToken:V}),ys(T.kind==="relay"?{kind:"relay",relay:T.relay,tunnel:{client:T.tunnel,owned:T.owned}}:{kind:"direct",url:T.url},V,{runtimeKey:U}),O=T.kind==="relay",n()}catch(B){console.warn("[mobile-connect] pairing threw",B),a(e("mobile.connect.error.authRequired"))}finally{Vo(T,O),y("pairing")}},[g,y,n,w,e]),M=d.useCallback(async N=>{if(!f||!N.trim()||h.current==="password")return;a(null),g("password");const v=b.current.begin(),T=()=>b.current.isCurrent(v),{id:O,label:B,candidates:z,serverId:_}=f,A=bt({candidates:z,serverId:_});let R=null,D=!1;try{const V=await Uo(z);if(V!=="relay-limit"&&(R=V),!T())return;if(!R){a(e(V==="relay-limit"?"mobile.connect.error.relayLimit":"mobile.connect.error.unreachable"));return}const L={method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({password:N,trustDevice:!0,issueClientToken:!0,clientLabel:"OpenChamber Mobile",clientKind:"mobile",devicePlatform:Bo(),dedupeKey:zo()})};Pe("password:start",{transport:R.kind});const K=R.kind==="relay"?await Ys(R.tunnel,"/auth/session",L,en):{response:await js(`${R.url}/auth/session`,L),failure:null},F=K.response;if(!T())return;if(Pe("password:done",{ok:F?.ok===!0,status:F?.status??null,error:K.failure}),!F?.ok){a(e("mobile.connect.error.passwordFailed"));return}const U=await F.json().catch(()=>null);if(!T())return;const Q=typeof U?.clientToken=="string"?U.clientToken.trim():"";if(Pe("password:token",{issued:!!Q}),!Q){if(R.kind==="direct"&&!nt()){w({id:O,label:B,candidates:z}),p(null),ys({kind:"direct",url:R.url},null,{runtimeKey:A}),n();return}a(e("mobile.connect.error.authRequired"));return}if(nt()&&(!T()||(await xs(A,Q),!T()))||!T()||(w({id:O,label:B,candidates:z,clientToken:Q}),p(null),ys(R.kind==="relay"?{kind:"relay",relay:R.relay,tunnel:{client:R.tunnel,owned:R.owned}}:{kind:"direct",url:R.url},Q,{runtimeKey:A}),D=R.kind==="relay",!T()))return;n()}catch(V){if(!T())return;console.warn("[mobile-connect] password threw",V),a(e("mobile.connect.error.passwordFailed"))}finally{Vo(R,D),T()&&y("password")}},[g,y,n,f,w,e]),I=d.useCallback(()=>{b.current.cancel(),y("password"),p(null),a(null)},[y]),E=d.useCallback(async N=>{a(null);let v=$o(N);const T=N.id?m.current.find(_=>_.id===N.id)??null:null;if(T){const _=v.filter(D=>D.kind==="direct"),A=jr(T).filter(D=>D.url.startsWith("https://")&&!_.some(V=>ml(V.url,D.url))),R=rs(T);v=[..._,...A,...R?[{kind:"relay",relay:R}]:[]]}if(v.length===0)return a(e("mobile.connect.error.urlRequired")),null;const O=N.clientToken?.trim()||void 0,B=N.label?.trim()||cr(Gt({candidates:v}));if(nt()){const _=bt({candidates:v,serverId:T?.serverId});if(O)await xs(_,O);else if(T?.hasToken){const A=bt(T);if(A&&_&&A!==_){const R=await En(A);R&&await xs(_,R)}}}return w({id:N.id,label:B,candidates:v,clientToken:O})[0]??null},[w,e]),C=d.useCallback(async N=>{const v=m.current.find(O=>O.id===N)??null,T=await lp(N);return u(T),v},[u]);return{connections:s,isBusy:i!==null,isPasswordBusy:i==="password",error:o,pendingConnection:f,connect:j,redeemPairingConnection:S,submitPassword:M,cancelPassword:I,saveConnection:E,removeConnection:C,setError:a}},Nl=n=>{const e=fe.c(31),{onClose:s}=n,{t:r}=xe(),[i,l]=d.useState(!1);let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=Bm(),e[0]=o):o=e[0];const a=o;let f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{Ca(Fm()).then(N=>{N.ok&&(l(!0),window.setTimeout(()=>l(!1),2e3))})},e[1]=f):f=e[1];const p=f;let m;e[2]!==r?(m=r("mobile.connectionDebug.title"),e[2]=r,e[3]=m):m=e[3];let h;e[4]!==m?(h=t.jsx("h2",{className:"min-w-0 truncate typography-ui-label text-foreground",children:m}),e[4]=m,e[5]=h):h=e[5];const b=i?"check":"file-copy";let u;e[6]!==b?(u=t.jsx(Y,{name:b,className:"size-4"}),e[6]=b,e[7]=u):u=e[7];let g;e[8]!==i||e[9]!==r?(g=r(i?"mobile.connectionDebug.copied":"mobile.connectionDebug.copy"),e[8]=i,e[9]=r,e[10]=g):g=e[10];let y;e[11]!==u||e[12]!==g?(y=t.jsxs(Ie,{type:"button",variant:"outline",size:"sm",onClick:p,disabled:a.length===0,children:[u,g]}),e[11]=u,e[12]=g,e[13]=y):y=e[13];let w;e[14]!==r?(w=r("mobile.connectionDebug.close"),e[14]=r,e[15]=w):w=e[15];let j;e[16]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx(Y,{name:"close",className:"size-[18px]"}),e[16]=j):j=e[16];let S;e[17]!==s||e[18]!==w?(S=t.jsx(Ie,{type:"button",variant:"ghost",size:"icon","aria-label":w,onClick:s,children:j}),e[17]=s,e[18]=w,e[19]=S):S=e[19];let M;e[20]!==S||e[21]!==y?(M=t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[y,S]}),e[20]=S,e[21]=y,e[22]=M):M=e[22];let I;e[23]!==M||e[24]!==h?(I=t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border/70 px-4 py-2.5",children:[h,M]}),e[23]=M,e[24]=h,e[25]=I):I=e[25];let E;e[26]!==r?(E=t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 py-3",children:a.length===0?t.jsx("p",{className:"typography-small text-muted-foreground",children:r("mobile.connectionDebug.empty")}):t.jsx("pre",{className:"whitespace-pre-wrap break-words typography-code text-muted-foreground",children:a.map(cl).join(`
|
|
4
4
|
`)})}),e[26]=r,e[27]=E):E=e[27];let C;return e[28]!==I||e[29]!==E?(C=t.jsxs("div",{className:"fixed inset-0 z-[70] flex flex-col bg-background pb-[var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))] pt-[var(--safe-area-inset-top,env(safe-area-inset-top,0px))] text-foreground",children:[I,E]}),e[28]=I,e[29]=E,e[30]=C):C=e[30],C},Cl=()=>{if(typeof window>"u")return null;const e=window.Capacitor?.Plugins?.BarcodeScanner;return e&&(typeof e.scan=="function"||typeof e.startScan=="function")?e:null},xp=()=>window.Capacitor?.getPlatform?.()==="android",Rl=n=>{const e=n.trim();if(!e)return null;if(/^openchamber:\/\//i.test(e)){const s=oc(e);return s?{pairing:s}:null}return/^https?:\/\//i.test(e)?{url:e}:null},Il=(n,e)=>{const s=Rl(n);if(!s&&e?.pairingStringFallback){const r=ac(n);if(r)return{status:"pairing",pairing:r}}return s?"pairing"in s?{status:"pairing",...s}:{status:"ok",...s}:{status:"invalid"}},yp=async(n,e)=>{if(!n.startScan||!n.stopScan||!n.addListener)return{status:"unsupported"};if(e?.aborted)return{status:"cancelled"};let s,r,i=!1,l=()=>{};const o=new Promise(p=>{l=p}),a=p=>{i||(i=!0,l(p))},f=()=>a({status:"cancelled"});e?.addEventListener("abort",f,{once:!0});try{return(await Promise.allSettled([Promise.resolve(n.addListener("barcodesScanned",({barcodes:m})=>{const h=m?.[0],b=(h?.rawValue??h?.displayValue??"").trim();b&&a(Il(b,{pairingStringFallback:!0}))})).then(m=>{s=m}),Promise.resolve(n.addListener("scanError",()=>a({status:"failed"}))).then(m=>{r=m})])).some(({status:m})=>m==="rejected")?a({status:"failed"}):i||n.startScan({formats:["QR_CODE"]}).catch(()=>a({status:"failed"})),await o}finally{e?.removeEventListener("abort",f),await Promise.allSettled([Promise.resolve(s?.remove()),Promise.resolve(r?.remove()),n.stopScan()])}},ki=()=>Cl()!==null,El=async n=>{const e=Cl();if(!e)return{status:"unsupported"};try{if(e.requestPermissions){const o=(await e.requestPermissions())?.camera;if(o&&o!=="granted"&&o!=="limited")return{status:"permission-denied"}}if(n?.signal?.aborted)return{status:"cancelled"};if(xp())return yp(e,n?.signal);if(!e.scan)return{status:"unsupported"};const r=(await e.scan({formats:["QR_CODE"]}))?.barcodes?.[0],i=(r?.rawValue??r?.displayValue??"").trim();return i?Il(i):{status:"cancelled"}}catch{return{status:"failed"}}},qs={autoComplete:"off",autoCorrect:"off",spellCheck:!1},jn="oc-surface-elevated h-12 w-full oc-raised oc-field rounded-[16px] bg-surface-elevated px-4 text-[16px] text-foreground outline-none placeholder:text-muted-foreground",Al=n=>{const e=fe.c(22),{onCancel:s}=n,{t:r}=xe(),i=d.useRef(null);let l,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{const j={value:document.documentElement.style.getPropertyValue("background-color"),priority:document.documentElement.style.getPropertyPriority("background-color")},S={value:document.body.style.getPropertyValue("background-color"),priority:document.body.style.getPropertyPriority("background-color")};document.documentElement.style.setProperty("background-color","rgba(0, 0, 0, 0)","important"),document.body.style.setProperty("background-color","rgba(0, 0, 0, 0)","important");const M=new Map,I=C=>{!(C instanceof HTMLElement)||C===i.current||M.has(C)||(M.set(C,{opacity:C.style.opacity,pointerEvents:C.style.pointerEvents}),C.style.setProperty("opacity","0"),C.style.setProperty("pointer-events","none"))};Array.from(document.body.children).forEach(I);const E=new MutationObserver(C=>{C.forEach(N=>N.addedNodes.forEach(I))});return E.observe(document.body,{childList:!0}),()=>{E.disconnect(),M.forEach(vp),j.value?document.documentElement.style.setProperty("background-color",j.value,j.priority):document.documentElement.style.removeProperty("background-color"),S.value?document.body.style.setProperty("background-color",S.value,S.priority):document.body.style.removeProperty("background-color")}},o=[],e[0]=l,e[1]=o):(l=e[0],o=e[1]),d.useLayoutEffect(l,o);let a,f;e[2]!==s?(a=()=>{const j=()=>{document.visibilityState==="hidden"&&s()};return document.addEventListener("visibilitychange",j),()=>document.removeEventListener("visibilitychange",j)},f=[s],e[2]=s,e[3]=a,e[4]=f):(a=e[3],f=e[4]),d.useEffect(a,f);let p;e[5]!==r?(p=r("mobile.connect.scanQr"),e[5]=r,e[6]=p):p=e[6];let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx("div",{className:"aspect-square w-full max-w-72 rounded-[28px] border-2 border-foreground/90 shadow-[0_0_0_9999px_color-mix(in_srgb,var(--surface-background)_18%,transparent)]","aria-hidden":!0}),e[7]=m):m=e[7];let h;e[8]!==r?(h=r("mobile.connect.welcome.scanHint"),e[8]=r,e[9]=h):h=e[9];let b;e[10]!==h?(b=t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-6",children:[m,t.jsx("p",{className:"max-w-sm rounded-[16px] border border-border/60 bg-background px-4 py-3 text-center typography-markdown text-foreground shadow-sm",children:h})]}),e[10]=h,e[11]=b):b=e[11];let u;e[12]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(Y,{name:"close",className:"size-[18px]"}),e[12]=u):u=e[12];let g;e[13]!==r?(g=r("mobile.instances.cancelEdit"),e[13]=r,e[14]=g):g=e[14];let y;e[15]!==s||e[16]!==g?(y=t.jsxs(Ie,{type:"button",variant:"outline",size:"lg",className:"mx-auto min-h-12 w-full max-w-sm bg-background",onClick:s,children:[u,g]}),e[15]=s,e[16]=g,e[17]=y):y=e[17];let w;return e[18]!==y||e[19]!==p||e[20]!==b?(w=Hs.createPortal(t.jsxs("div",{ref:i,role:"dialog","aria-modal":"true","aria-label":p,className:"fixed inset-0 z-[1000] flex flex-col bg-transparent px-6 pb-[calc(var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))+24px)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+24px)] text-foreground",children:[b,y]}),document.body),e[18]=y,e[19]=p,e[20]=b,e[21]=w):w=e[21],w},Tl=()=>{const n=fe.c(6),{t:e}=xe();let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx(Vs,{width:96,height:96,isAnimated:!0}),n[0]=s):s=n[0];let r;n[1]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(Y,{name:"loader-4",className:"size-[18px] animate-spin"}),n[1]=r):r=n[1];let i;n[2]!==e?(i=e("mobile.connect.connecting"),n[2]=e,n[3]=i):i=n[3];let l;return n[4]!==i?(l=Hs.createPortal(t.jsxs("div",{role:"status",className:"fixed inset-0 z-[1000] flex flex-col items-center justify-center gap-5 bg-background px-6 text-foreground",children:[s,t.jsxs("div",{className:"flex items-center gap-2 typography-ui-label text-muted-foreground",children:[r,t.jsx("span",{children:i})]})]}),document.body),n[4]=i,n[5]=l):l=n[5],l};function vp(n,e){e.style.opacity=n.opacity,e.style.pointerEvents=n.pointerEvents}const wp=({onConnected:n,notice:e=null})=>{const{t:s}=xe(),r=Sl(n),{connections:i,isBusy:l,isPasswordBusy:o,error:a,pendingConnection:f}=r,[p,m]=d.useState(""),[h,b]=d.useState(""),[u,g]=d.useState(""),[y,w]=d.useState(!1),j=Ra(y),[S,M]=d.useState(!1),I=d.useRef(null),E=d.useMemo(()=>ki(),[]),[C,N]=d.useState(()=>!ki()),[v,T]=d.useState(null),[O,B]=d.useState(""),[z,_]=d.useState(!1),A=dl(d.useCallback(()=>_(!0),[])),R=d.useCallback(F=>{F.preventDefault(),r.connect({url:p,clientToken:u,label:h})},[u,r,h,p]),D=d.useCallback(F=>{if(/^openchamber:\/\//i.test(F.trim())){const U=Rl(F);if(U){if("pairing"in U){r.redeemPairingConnection(U.pairing);return}m(U.url),U.label&&b(U.label),U.clientToken&&g(U.clientToken);return}}m(F)},[r]),V=d.useCallback(async()=>{if(I.current||l)return;r.setError(null),w(!0);const F=new AbortController;I.current=F;try{const U=await El({signal:F.signal});switch(I.current===F&&(I.current=null,w(!1)),U.status){case"ok":M(!0),m(U.url),U.label&&b(U.label),U.clientToken&&g(U.clientToken),await r.connect({url:U.url,clientToken:U.clientToken,label:U.label});break;case"pairing":M(!0),await r.redeemPairingConnection(U.pairing);break;case"permission-denied":r.setError(s("mobile.connect.scan.permissionDenied"));break;case"invalid":r.setError(s("mobile.connect.scan.invalid"));break;case"unsupported":r.setError(s("mobile.connect.scan.unsupported"));break;case"failed":r.setError(s("mobile.connect.scan.failed"));break;default:break}}finally{M(!1),I.current===F&&(I.current=null,w(!1))}},[r,l,s]);d.useEffect(()=>()=>I.current?.abort(),[]);const L=d.useCallback(F=>{F.preventDefault(),r.submitPassword(O)},[r,O]),K=d.useCallback(()=>{B(""),r.cancelPassword()},[r]);return t.jsxs(t.Fragment,{children:[y?t.jsx(Al,{onCancel:()=>I.current?.abort()}):null,S?t.jsx(Tl,{}):null,z?t.jsx(Nl,{onClose:()=>_(!1)}):null,t.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:t.jsxs("div",{className:"m-auto flex w-full max-w-[360px] shrink-0 flex-col items-center gap-9 py-8",children:[t.jsxs("div",{className:"flex flex-col items-center gap-5 text-center",children:[t.jsx("span",{...A,className:"select-none",style:{touchAction:"manipulation"},children:t.jsx(Vs,{width:72,height:72,className:"size-[72px]"})}),t.jsx("h1",{className:"typography-h2 text-foreground",children:s("mobile.connect.welcome.title")})]}),e?t.jsxs("div",{role:"status",className:"flex w-full items-center gap-3 rounded-[18px] border border-[color-mix(in_srgb,var(--status-warning)_35%,transparent)] bg-[color-mix(in_srgb,var(--status-warning)_10%,transparent)] px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-[color-mix(in_srgb,var(--status-warning)_16%,transparent)] text-[var(--status-warning)]",children:t.jsx(Y,{name:e.kind==="auth-expired"?"lock":"cloud-off",className:"size-[18px]"})}),t.jsx("p",{className:"min-w-0 flex-1 typography-small text-foreground",children:e.kind==="auth-expired"?s("mobile.connect.notice.authExpired",{label:e.label}):e.kind==="relay-limit"?s("mobile.connect.notice.relayLimit",{label:e.label}):s("mobile.connect.notice.unreachable",{label:e.label})})]}):null,f?t.jsxs("form",{className:"flex w-full flex-col gap-3",onSubmit:L,children:[t.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(Y,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0 text-start",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:f.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:f.candidates.some(F=>F.kind==="direct")?Gt(f):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...qs,value:O,onChange:F=>B(F.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:jn}),a?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:a}):null,t.jsx(Ie,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:o||!O.trim(),children:s(o?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(Ie,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:K,children:s("mobile.connect.cancelPassword")})]}):t.jsxs("div",{className:"flex w-full flex-col gap-6",children:[E?t.jsxs("div",{className:"flex w-full flex-col gap-2",children:[t.jsxs(Ie,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{V()},disabled:y||l,children:[t.jsx(Y,{name:"scan-2",className:se("size-[18px]",j)}),s(l?"mobile.connect.connecting":"mobile.connect.scanQr")]}),t.jsx("p",{className:"px-2 text-center typography-small text-muted-foreground",children:s("mobile.connect.welcome.scanHint")})]}):null,a&&!C?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:a}):null,i.length>0?t.jsxs("section",{className:"flex w-full flex-col gap-2.5",children:[t.jsx("h2",{className:"text-center typography-micro uppercase tracking-[0.14em] text-muted-foreground",children:s("mobile.connect.saved.title")}),t.jsx("div",{className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:i.map(F=>{const U=v===F.id;return t.jsxs("button",{type:"button",disabled:l,className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3.5 py-2.5 text-start last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:opacity-70",onClick:()=>{T(F.id),r.connect({id:F.id,candidates:F.candidates,clientToken:F.clientToken,label:F.label}).finally(()=>T(null))},children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(Y,{name:"server",className:"size-[18px]"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:F.label}),t.jsx("span",{className:se("block truncate typography-small",U?"text-foreground":"text-muted-foreground"),children:U?s("mobile.connect.connecting"):F.candidates.some(Q=>Q.kind==="direct")?Gt(F):s("mobile.connect.relay.badge")})]}),U?t.jsx(Y,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):t.jsx(Y,{name:"arrow-right-s",className:"size-5 text-muted-foreground"})]},F.id)})})]}):null,t.jsxs("div",{className:"flex w-full flex-col",children:[E?t.jsxs("button",{type:"button",onClick:()=>N(F=>!F),"aria-expanded":C,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-ring",children:[t.jsx("span",{children:s("mobile.connect.manual.toggle")}),t.jsx(Y,{name:"arrow-down-s",className:se("size-4 transition-transform duration-200",C&&"rotate-180")})]}):null,t.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:C?"1fr":"0fr"},children:t.jsx("div",{className:"min-h-0 overflow-hidden",children:t.jsxs("form",{className:"flex w-full flex-col gap-3 pt-3",onSubmit:R,children:[t.jsx("input",{...qs,value:p,onChange:F=>D(F.target.value),placeholder:s("mobile.connect.url.placeholder"),"aria-label":s("mobile.connect.url.label"),type:"url",inputMode:"url",autoCapitalize:"none",tabIndex:C?void 0:-1,className:se(jn,"text-center")}),t.jsx("input",{value:h,onChange:F=>b(F.target.value),placeholder:s("mobile.instances.label.placeholder"),"aria-label":s("mobile.instances.label.label"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,tabIndex:C?void 0:-1,className:se(jn,"text-center")}),t.jsx("input",{...qs,value:u,onChange:F=>g(F.target.value),placeholder:s("mobile.connect.token.placeholder"),"aria-label":s("mobile.connect.token.label"),tabIndex:C?void 0:-1,autoCapitalize:"none",className:se(jn,"text-center")}),t.jsx("p",{className:"px-1 text-center typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")}),a?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:a}):null,t.jsx(Ie,{type:"submit",variant:E?"outline":"default",size:"lg",className:"h-12 w-full",disabled:l||y||!p.trim(),children:s(l?"mobile.connect.connecting":"mobile.connect.connectButton")})]})})})]})]})]})})]})},jp=n=>{const e=n.usedPercent;return typeof e!="number"||!Number.isFinite(e)?"text-foreground":e>=80?"text-[var(--status-error)]":e>=50?"text-[var(--status-warning)]":"text-foreground"},kp=n=>{const e=fe.c(12),{groups:s,displayMode:r,timeFormatPreference:i,className:l}=n;let o;e[0]!==l?(o=se("space-y-1.5",l),e[0]=l,e[1]=o):o=e[1];let a;if(e[2]!==r||e[3]!==s||e[4]!==i){let p;e[6]!==r||e[7]!==i?(p=m=>t.jsxs("div",{className:"min-w-0 rounded-xl bg-foreground/[0.03] p-2.5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ia,{providerId:m.providerId,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground",children:m.providerName}),m.planLabel?t.jsx("span",{className:"shrink-0 typography-micro capitalize text-muted-foreground",children:m.planLabel}):null,m.status&&m.rows.length===0?t.jsx("span",{className:"shrink-0 truncate typography-micro text-muted-foreground",children:m.status}):null]}),m.rows.length>0?t.jsx("div",{className:"mt-1.5 space-y-1",children:m.rows.map(h=>{const b=r==="remaining"?h.window.remainingPercent:h.window.usedPercent,u=kc(h.window.valueLabel,b),g=Sc(h.window.resetAt,h.window.resetAfterFormatted??h.window.resetAtFormatted,i);return t.jsxs("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"shrink-0 truncate typography-ui-label text-muted-foreground",children:h.subtitle?`${h.subtitle} · ${h.label}`:h.label}),g?t.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/70",children:g}):null]}),t.jsx("span",{className:se("shrink-0 typography-ui-label font-semibold tabular-nums",jp(h.window)),children:u==="-"?"":u})]},h.key)})}):null,m.status&&m.rows.length>0?t.jsx("div",{className:"mt-1.5 typography-micro text-muted-foreground",children:m.status}):null]},m.providerId),e[6]=r,e[7]=i,e[8]=p):p=e[8],a=s.map(p),e[2]=r,e[3]=s,e[4]=i,e[5]=a}else a=e[5];let f;return e[9]!==o||e[10]!==a?(f=t.jsx("div",{className:o,children:a}),e[9]=o,e[10]=a,e[11]=f):f=e[11],f},Ko=380,Sp=(n,e)=>{if(!n||typeof n!="object")return;const s=n[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0},ei=n=>n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:String(n),Np="—",Pl=n=>{const e=fe.c(20),{percentage:s}=n;let r,i,l,o,a,f,p;if(e[0]!==s){l=Ec(s??0)??0;const u=Ac(s??0);i=u==="critical"?"var(--status-error)":u==="warn"?"var(--status-warning)":"var(--status-success)",r=2*Math.PI*7.5,o="0 0 18 18",a="size-[18px] -rotate-90",f="progressbar",p=s===null?void 0:Math.round(l),e[0]=s,e[1]=r,e[2]=i,e[3]=l,e[4]=o,e[5]=a,e[6]=f,e[7]=p}else r=e[1],i=e[2],l=e[3],o=e[4],a=e[5],f=e[6],p=e[7];let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),e[8]=m):m=e[8];let h;e[9]!==r||e[10]!==s||e[11]!==i||e[12]!==l?(h=s===null?null:t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:i,strokeWidth:3,strokeLinecap:"round",strokeDasharray:r,strokeDashoffset:r*(1-l/100),className:"transition-[stroke-dashoffset,stroke] duration-300"}),e[9]=r,e[10]=s,e[11]=i,e[12]=l,e[13]=h):h=e[13];let b;return e[14]!==o||e[15]!==a||e[16]!==f||e[17]!==p||e[18]!==h?(b=t.jsxs("svg",{viewBox:o,className:a,role:f,"aria-valuenow":p,"aria-valuemin":0,"aria-valuemax":100,children:[m,h]}),e[14]=o,e[15]=a,e[16]=f,e[17]=p,e[18]=h,e[19]=b):b=e[19],b},Cp=n=>{const e=fe.c(13),{icon:s,iconNode:r,label:i,children:l}=n;let o;e[0]!==s||e[1]!==r?(o=r??(s?t.jsx(Y,{name:s,className:"size-[18px]"}):null),e[0]=s,e[1]=r,e[2]=o):o=e[2];let a;e[3]!==o?(a=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:o}),e[3]=o,e[4]=a):a=e[4];let f;e[5]!==i?(f=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:i}),e[5]=i,e[6]=f):f=e[6];let p;e[7]!==l?(p=t.jsx("span",{className:"min-w-0 flex-1 truncate text-end typography-ui-label font-medium text-foreground",children:l}),e[7]=l,e[8]=p):p=e[8];let m;return e[9]!==a||e[10]!==f||e[11]!==p?(m=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5",children:[a,f,p]}),e[9]=a,e[10]=f,e[11]=p,e[12]=m):m=e[12],m},Rp=n=>{const e=fe.c(57),{open:s,onClose:r,anchorRef:i,contextDisplay:l,usageGroups:o,usageDisplayMode:a,isUsageLoading:f,timeFormatPreference:p}=n,{t:m}=xe(),h=d.useRef(null),[b,u]=d.useState(s),[g,y]=d.useState(!1),{enabled:w}=Ei(),j=d.useRef(null),[S,M]=d.useState(null);let I,E;e[0]!==i||e[1]!==w||e[2]!==s||e[3]!==b?(I=()=>{if(!s||!w||!b)return;const k=()=>{const Z=i.current?.getBoundingClientRect(),me=j.current?.getBoundingClientRect();if(!Z||!me){M(null);return}const ue=Z.left-me.left,X=Math.min(Math.max(ue,8),Math.max(8,me.width-Ko-8));M(X)};k();const q=j.current;if(typeof ResizeObserver>"u"||!q)return;const G=new ResizeObserver(k);return G.observe(q),()=>G.disconnect()},E=[i,w,s,b],e[0]=i,e[1]=w,e[2]=s,e[3]=b,e[4]=I,e[5]=E):(I=e[4],E=e[5]),d.useLayoutEffect(I,E);const C=w&&S!==null;let N,v;e[6]!==s||e[7]!==b?(N=()=>{if(s){u(!0),y(!1);return}if(!b)return;y(!0);const k=window.setTimeout(()=>{u(!1),y(!1)},140);return()=>window.clearTimeout(k)},v=[s,b],e[6]=s,e[7]=b,e[8]=N,e[9]=v):(N=e[8],v=e[9]),d.useEffect(N,v);let T,O;e[10]!==r||e[11]!==s?(T=()=>{if(!s)return;const k=q=>{q.key==="Escape"&&r()};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},O=[r,s],e[10]=r,e[11]=s,e[12]=T,e[13]=O):(T=e[12],O=e[13]),d.useEffect(T,O);let B,z;if(e[14]!==i||e[15]!==r||e[16]!==s?(B=()=>{if(!s)return;const k=q=>{const G=q.target;if(!(G instanceof Node)){r();return}h.current?.contains(G)||i.current?.contains(G)||r()};return document.addEventListener("pointerdown",k,!0),document.addEventListener("wheel",k,!0),()=>{document.removeEventListener("pointerdown",k,!0),document.removeEventListener("wheel",k,!0)}},z=[i,r,s],e[14]=i,e[15]=r,e[16]=s,e[17]=B,e[18]=z):(B=e[17],z=e[18]),d.useEffect(B,z),!b)return null;let _;e[19]!==m?(_=m("mobile.header.openMetadataAria"),e[19]=m,e[20]=_):_=e[20];const A=C?"absolute origin-top-left":"mx-3 mt-2",R=g?"pointer-events-none":"pointer-events-auto";let D;e[21]!==A||e[22]!==R?(D=se("oc-surface-elevated overflow-y-auto overscroll-contain rounded-[20px] border border-border/70 bg-surface-elevated p-2 shadow-[0_12px_32px_rgb(0_0_0_/_0.2)] will-change-transform",A,R),e[21]=A,e[22]=R,e[23]=D):D=e[23];const V=`${g?"session-metadata-out":"session-metadata-in"} ${g?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let L;e[24]!==S||e[25]!==C?(L=C?{top:8,left:S??8,width:`min(${Ko}px, calc(100% - 16px))`}:null,e[24]=S,e[25]=C,e[26]=L):L=e[26];let K;e[27]!==V||e[28]!==L?(K={animation:V,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...L},e[27]=V,e[28]=L,e[29]=K):K=e[29];let F;e[30]!==l||e[31]!==m?(F=l?t.jsx(Cp,{iconNode:t.jsx(Pl,{percentage:l.state==="measured"?l.percentage:null}),label:m("mobile.header.metadata.context"),children:l.state==="pending"?null:t.jsxs("span",{className:"inline-flex items-baseline gap-1.5 tabular-nums",children:[l.state==="measured"?t.jsxs("span",{className:se("font-semibold",l.colorClass),children:[l.percentage.toFixed(1),"%"]}):null,t.jsx("span",{className:"text-muted-foreground",children:l.tokens})]})}):null,e[30]=l,e[31]=m,e[32]=F):F=e[32];let U;e[33]!==l?.state||e[34]!==m?(U=l?.state==="compacted"?t.jsx("p",{className:"px-2.5 pb-1 typography-meta text-muted-foreground",children:m("contextUsage.compacted.description")}):null,e[33]=l?.state,e[34]=m,e[35]=U):U=e[35];let Q;e[36]!==l?.state||e[37]!==m?(Q=l?.state==="pending"?t.jsx("p",{className:"px-2.5 pb-1 typography-meta text-muted-foreground",children:m("mobile.header.metadata.contextPending")}):null,e[36]=l?.state,e[37]=m,e[38]=Q):Q=e[38];let le;e[39]!==f||e[40]!==p||e[41]!==a||e[42]!==o?(le=t.jsx(Ip,{groups:o,displayMode:a,isLoading:f,timeFormatPreference:p}),e[39]=f,e[40]=p,e[41]=a,e[42]=o,e[43]=le):le=e[43];let ce;e[44]!==F||e[45]!==U||e[46]!==Q||e[47]!==le?(ce=t.jsxs("div",{className:"space-y-1",children:[F,U,Q,le]}),e[44]=F,e[45]=U,e[46]=Q,e[47]=le,e[48]=ce):ce=e[48];let oe;e[49]!==D||e[50]!==K||e[51]!==ce||e[52]!==_?(oe=t.jsx("div",{ref:h,role:"dialog","aria-label":_,className:D,style:K,children:ce}),e[49]=D,e[50]=K,e[51]=ce,e[52]=_,e[53]=oe):oe=e[53];let re;e[54]===Symbol.for("react.memo_cache_sentinel")?(re=t.jsx("style",{children:`
|
|
5
5
|
@keyframes session-metadata-in {
|
|
@@ -22,4 +22,4 @@ import{f as fe,r as ui,j as t,R as d,c as Hs,h as sc}from"./vendor-react-BUCujlK
|
|
|
22
22
|
`}),e[47]=oe):oe=e[47];let re;return e[48]!==ce?(re=t.jsxs("div",{ref:b,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:[ce,oe]}),e[48]=ce,e[49]=re):re=e[49],re};function Mp(n){return n.currentSessionId}function _p(n){return n.setCurrentSession}function Op(n){return n.setActiveProjectIdOnly}const zp=n=>{const e=fe.c(84),{onOpenSessions:s,onOpenWorkspace:r,compactTitle:i}=n,l=i===void 0?!1:i,{t:o}=xe(),[a,f]=d.useState(!1),[p,m]=d.useState(!1),h=d.useRef(null),b=ws(Bp),u=$e(Lp);let g;e[0]!==u?(g=ge=>u?ge.getDirectoryForSession(u):null,e[0]=u,e[1]=g):g=e[1];const w=$e(g)||b,j=Dc(u,w||void 0),S=$e(Fp),M=Pa(w||null);let I;e[2]!==w||e[3]!==M?(I=ge=>{if(!w||M!==!0)return!1;const Ce=ge.directories.get(w)?.status;return!!(Ce&&!Ce.isClean)},e[2]=w,e[3]=M,e[4]=I):I=e[4];const E=gt(I),C=Ve($p),N=yu(C);let v;e[5]!==j?.title?(v=j?.title?.trim(),e[5]=j?.title,e[6]=v):v=e[6];const T=v;let O;e[7]!==u||e[8]!==C||e[9]!==N||e[10]!==T||e[11]!==o?(O=(C?N:null)||T||o(u?"mobile.sessions.untitled":"sessions.switcher.draftTitle"),e[7]=u,e[8]=C,e[9]=N,e[10]=T,e[11]=o,e[12]=O):O=e[12];const B=O;let z;e[13]===Symbol.for("react.memo_cache_sentinel")?(z=()=>{f(!1),m(!1)},e[13]=z):z=e[13];let _;e[14]!==u||e[15]!==w?(_=[u,w],e[14]=u,e[15]=w,e[16]=_):_=e[16],d.useEffect(z,_);let A;e[17]!==s?(A=()=>{f(!1),m(!1),s()},e[17]=s,e[18]=A):A=e[18];const R=A;let D;e[19]===Symbol.for("react.memo_cache_sentinel")?(D=ge=>{f(Ce=>{const Be=typeof ge=="function"?ge(Ce):ge;return Be&&m(!1),Be})},e[19]=D):D=e[19];const V=D;let L;e[20]===Symbol.for("react.memo_cache_sentinel")?(L=()=>{m(ge=>{const Ce=!ge;return Ce&&f(!1),Ce})},e[20]=L):L=e[20];const K=L;let F;e[21]===Symbol.for("react.memo_cache_sentinel")?(F={paddingTop:"var(--oc-safe-area-top, 0px)"},e[21]=F):F=e[21];let U;e[22]!==o?(U=o("mobile.sessions.openSheetAria"),e[22]=o,e[23]=U):U=e[23];let Q,le;e[24]===Symbol.for("react.memo_cache_sentinel")?(Q={touchAction:"manipulation"},le=t.jsx(Y,{name:"list-unordered",className:"size-5"}),e[24]=Q,e[25]=le):(Q=e[24],le=e[25]);let ce;e[26]!==R||e[27]!==U?(ce=t.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-ring","aria-label":U,onClick:R,style:Q,children:le}),e[26]=R,e[27]=U,e[28]=ce):ce=e[28];const oe=l?"shrink":"flex-1";let re;e[29]!==oe?(re=se("flex min-w-0 items-center rounded-lg px-2 py-1.5 text-start transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",oe),e[29]=oe,e[30]=re):re=e[30];let ie;e[31]!==o?(ie=o("sessions.switcher.openAria"),e[31]=o,e[32]=ie):ie=e[32];let k;e[33]===Symbol.for("react.memo_cache_sentinel")?(k={touchAction:"manipulation"},e[33]=k):k=e[33];let q;e[34]!==B?(q=t.jsx("span",{dir:"auto",className:"block min-w-0 truncate oc-ui-start-align typography-ui-label text-foreground",children:B}),e[34]=B,e[35]=q):q=e[35];const G=p&&"rotate-180";let Z;e[36]!==G?(Z=se("size-4 shrink-0 text-muted-foreground transition-transform duration-150",G),e[36]=G,e[37]=Z):Z=e[37];let me;e[38]!==Z?(me=t.jsx(Y,{name:"arrow-down-s",className:Z}),e[38]=Z,e[39]=me):me=e[39];let ue;e[40]!==q||e[41]!==me?(ue=t.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[q,me]}),e[40]=q,e[41]=me,e[42]=ue):ue=e[42];let X;e[43]!==p||e[44]!==re||e[45]!==ie||e[46]!==ue?(X=t.jsx("button",{ref:h,type:"button",className:re,"aria-label":ie,"aria-haspopup":"dialog","aria-expanded":p,onClick:K,style:k,children:ue}),e[43]=p,e[44]=re,e[45]=ie,e[46]=ue,e[47]=X):X=e[47];let de;e[48]!==l?(de=l?t.jsx("div",{className:"min-w-0 flex-1"}):null,e[48]=l,e[49]=de):de=e[49];let we;e[50]!==u||e[51]!==w||e[52]!==S||e[53]!==a||e[54]!==C?(we=C?null:t.jsx(Ep,{open:a,onOpenChange:V,currentSessionId:u,effectiveDirectory:w,isNewSessionDraftOpen:S}),e[50]=u,e[51]=w,e[52]=S,e[53]=a,e[54]=C,e[55]=we):we=e[55];let Se;e[56]!==w?(Se=t.jsx(vu,{directory:w,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-ring",iconClassName:"size-5"}),e[56]=w,e[57]=Se):Se=e[57];let be;e[58]!==E||e[59]!==o?(be=o(E?"mobile.header.openWorkspaceWithChangesAria":"mobile.header.openWorkspaceAria"),e[58]=E,e[59]=o,e[60]=be):be=e[60];let ye;e[61]!==r?(ye=()=>{f(!1),m(!1),r()},e[61]=r,e[62]=ye):ye=e[62];let Te,Ee;e[63]===Symbol.for("react.memo_cache_sentinel")?(Te={touchAction:"manipulation"},Ee=t.jsx(Y,{name:"pencil-ruler-2",className:"size-5"}),e[63]=Te,e[64]=Ee):(Te=e[63],Ee=e[64]);let De;e[65]!==E?(De=E?t.jsx("span",{className:"absolute inset-e-1.5 top-1.5 size-2.5 rounded-full border-2 border-[var(--background)] bg-[var(--status-warning)]","aria-hidden":!0}):null,e[65]=E,e[66]=De):De=e[66];let je;e[67]!==be||e[68]!==ye||e[69]!==De?(je=t.jsxs("button",{type:"button",className:"relative 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-ring","aria-label":be,onClick:ye,style:Te,children:[Ee,De]}),e[67]=be,e[68]=ye,e[69]=De,e[70]=je):je=e[70];let Ne;e[71]!==ce||e[72]!==X||e[73]!==de||e[74]!==we||e[75]!==Se||e[76]!==je?(Ne=t.jsx("header",{className:"oc-mobile-header relative z-30 flex shrink-0 items-center gap-1 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",style:F,children:t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[ce,X,de,we,Se,je]})}),e[71]=ce,e[72]=X,e[73]=de,e[74]=we,e[75]=Se,e[76]=je,e[77]=Ne):Ne=e[77];let H;e[78]===Symbol.for("react.memo_cache_sentinel")?(H=()=>m(!1),e[78]=H):H=e[78];let ee;e[79]!==p?(ee=t.jsx(Dp,{open:p,onClose:H,anchorRef:h}),e[79]=p,e[80]=ee):ee=e[80];let ve;return e[81]!==Ne||e[82]!==ee?(ve=t.jsxs(t.Fragment,{children:[Ne,ee]}),e[81]=Ne,e[82]=ee,e[83]=ve):ve=e[83],ve};function Bp(n){return n.currentDirectory}function Lp(n){return n.currentSessionId}function Fp(n){return!!n.newSessionDraft?.open}function $p(n){return n.runOverviewKey}const Wp=({onActiveConnectionDeleted:n,onConnect:e})=>{const{t:s}=xe(),r=Sl(e),{connections:i,isBusy:l,isPasswordBusy:o,error:a,pendingConnection:f,connect:p,submitPassword:m,cancelPassword:h,saveConnection:b,removeConnection:u,setError:g}=r,[y,w]=d.useState(null),j=y?i.find(X=>X.id===y)??null:null,[S,M]=d.useState(null),[I,E]=d.useState(""),[C,N]=d.useState(""),[v,T]=d.useState(""),[O,B]=d.useState(""),[z,_]=d.useState(!1),A=Ra(z),[R,D]=d.useState(!1),V=d.useRef(null),L=d.useMemo(()=>ki(),[]),[K,F]=d.useState(!1),[U,Q]=d.useState(null),[le,ce]=d.useState(!1),oe=dl(d.useCallback(()=>ce(!0),[])),re=d.useCallback(()=>{w(null),E(""),N(""),T(""),g(null),F(!1)},[g]),ie=d.useCallback(X=>{X.preventDefault(),b({id:y??void 0,url:I,label:C,clientToken:v}).then(de=>{de&&re()})},[v,y,C,re,b,I]),k=d.useCallback(async()=>{if(V.current)return;g(null),_(!0);const X=new AbortController;V.current=X;try{const de=await El({signal:X.signal});switch(V.current===X&&(V.current=null,_(!1)),de.status){case"ok":E(de.url),de.label&&N(de.label),de.clientToken&&T(de.clientToken),F(!0);break;case"pairing":D(!0),await r.redeemPairingConnection(de.pairing);break;case"permission-denied":g(s("mobile.connect.scan.permissionDenied"));break;case"invalid":g(s("mobile.connect.scan.invalid"));break;case"unsupported":g(s("mobile.connect.scan.unsupported"));break;case"failed":g(s("mobile.connect.scan.failed"));break;default:break}}finally{D(!1),V.current===X&&(V.current=null,_(!1))}},[r,g,s]);d.useEffect(()=>()=>V.current?.abort(),[]);const q=d.useCallback(X=>{X.preventDefault(),m(O)},[O,m]),G=d.useCallback(()=>{B(""),h()},[h]),Z=d.useCallback(X=>{M(de=>de===X?null:X)},[]),me=d.useCallback(X=>{M(null),y===X&&re();const de=i.length===1;u(X).then(we=>{we&&(de||Go(we))&&n()})},[i.length,y,n,u,re]),ue=jn;return f?t.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:t.jsx("form",{className:"flex-1 overflow-y-auto px-5 py-4",onSubmit:q,children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(Y,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:f.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:f.candidates.some(X=>X.kind==="direct")?Gt(f):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...qs,value:O,onChange:X=>B(X.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:ue}),a?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:a}):null,t.jsx(Ie,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:o||!O.trim(),children:s(o?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(Ie,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:G,children:s("mobile.connect.cancelPassword")})]})})}):t.jsxs(t.Fragment,{children:[z?t.jsx(Al,{onCancel:()=>V.current?.abort()}):null,R?t.jsx(Tl,{}):null,le?t.jsx(Nl,{onClose:()=>ce(!1)}):null,t.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:t.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:t.jsxs("div",{className:"space-y-6",children:[i.length>0?t.jsx("div",{...oe,className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:i.map(X=>{const de=S===X.id,we=Go(X),Se=U===X.id,be=Se?s("mobile.connect.connecting"):we?In()?s("mobile.instances.status.connectedRelay"):s("mobile.instances.status.connectedDirect"):X.candidates.some(ye=>ye.kind==="direct")?Gt(X):s("mobile.connect.relay.badge");return t.jsxs("div",{className:se("flex items-center border-b border-border/70 transition-colors last:border-b-0",de&&"bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]"),children:[t.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-3 px-3.5 py-3 text-start transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:opacity-60",onClick:()=>{we||(Q(X.id),p({id:X.id,candidates:X.candidates,clientToken:X.clientToken,label:X.label}).finally(()=>Q(null)))},disabled:l&&!Se||de,children:[t.jsxs("span",{className:"relative flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:[t.jsx(Y,{name:"server",className:"size-[18px]"}),we?t.jsx("span",{className:"absolute -inset-e-0.5 -top-0.5 size-2.5 rounded-full border-2 border-[var(--surface-elevated)] bg-[var(--status-success)]","aria-hidden":!0}):null]}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:X.label}),t.jsx("span",{className:se("block truncate typography-small",we&&!Se?"text-[var(--status-success)]":"text-muted-foreground"),children:be})]}),Se?t.jsx(Y,{name:"loader-4",className:"size-5 shrink-0 animate-spin text-muted-foreground"}):null]}),t.jsxs("div",{className:"flex items-center gap-0.5 pe-2",children:[de?t.jsxs("button",{type:"button","aria-label":s("mobile.instances.confirmDeleteAria",{label:X.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:()=>me(X.id),style:{touchAction:"manipulation"},children:[t.jsx(Y,{name:"delete-bin",className:"size-[18px]"}),t.jsx("span",{className:"typography-ui-label",children:s("mobile.instances.delete")})]}):X.candidates.some(ye=>ye.kind==="direct")?t.jsx("button",{type:"button","aria-label":s("mobile.instances.edit"),className:"flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>{w(X.id),E(Gt(X)),N(X.label),T(X.clientToken||""),g(null)},style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"edit",className:"size-[18px]"})}):null,t.jsx("button",{type:"button","aria-label":de?s("mobile.instances.cancelDeleteAria",{label:X.label}):s("mobile.instances.deleteAria",{label:X.label}),className:"flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>Z(X.id),style:{touchAction:"manipulation"},children:t.jsx(Y,{name:de?"close":"delete-bin",className:"size-[18px]"})})]})]},X.id)})}):t.jsx("p",{...oe,className:"rounded-[18px] border border-dashed border-border/70 px-4 py-6 text-center typography-small text-muted-foreground",children:s("mobile.connect.saved.empty")}),!K&&!j?t.jsxs("div",{className:"space-y-2",children:[L?t.jsxs(Ie,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{k()},disabled:z,children:[t.jsx(Y,{name:"scan-2",className:se("size-[18px]",A)}),s("mobile.connect.scanQr")]}):null,t.jsxs(Ie,{type:"button",variant:L?"ghost":"outline",size:"lg",className:"h-12 w-full",onClick:()=>{g(null),F(!0)},children:[t.jsx(Y,{name:"add",className:"size-[18px]"}),s("mobile.instances.addManual")]}),a?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:a}):null]}):t.jsxs("form",{className:"space-y-3",onSubmit:ie,children:[t.jsxs("div",{className:"flex h-8 items-center justify-between gap-3 px-1",children:[t.jsx("h3",{className:"typography-ui-label text-foreground",children:s(j?"mobile.instances.editTitle":"mobile.instances.addTitle")}),t.jsx(Ie,{type:"button",variant:"ghost",size:"xs",onClick:re,children:s("mobile.instances.cancelEdit")})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"block px-1 typography-ui-label text-foreground",children:s("mobile.connect.url.label")}),t.jsx("input",{...qs,value:I,onChange:X=>E(X.target.value),placeholder:s("mobile.connect.url.placeholder"),type:"url",inputMode:"url",autoCapitalize:"none",className:ue})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"block px-1 typography-ui-label text-foreground",children:s("mobile.instances.label.label")}),t.jsx("input",{value:C,onChange:X=>N(X.target.value),placeholder:s("mobile.instances.label.placeholder"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,className:ue})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"block px-1 typography-ui-label text-foreground",children:s("mobile.connect.token.label")}),t.jsx("input",{...qs,value:v,onChange:X=>T(X.target.value),placeholder:s("mobile.connect.token.placeholder"),autoCapitalize:"none",className:ue}),t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")})]}),a?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:a}):null,t.jsx(Ie,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",children:s(j?"mobile.instances.saveEdit":"mobile.instances.saveNew")})]})]})})})]})},Ze=n=>_n(n)??"",ti=n=>{const e=Ze(n);if(!e)return"";const s=e.split("/").filter(Boolean);return s[s.length-1]?.replace(/[-_]/g," ")||e},Ho=Hi(n=>({expandedParents:{},toggleParent:e=>n(s=>{const r={...s.expandedParents};return r[e]?delete r[e]:r[e]=!0,{expandedParents:r}})})),rr=Hi()(il(n=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(e,s)=>n(r=>({projectExpanded:{...r.projectExpanded,[e]:s}})),setWorktreeExpanded:(e,s)=>n(r=>({worktreeExpanded:{...r.worktreeExpanded,[e]:s}}))}),{name:"mobile-session-tree"})),Si=Hi()(il(n=>({orderByProject:{},setWorktreeOrder:(e,s)=>n(r=>({orderByProject:{...r.orderByProject,[e]:s}}))}),{name:"mobile-worktree-order"})),Xo=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),Vp=(n,e)=>{if(!n||n.length===0)return e;const s=new Map(n.map((i,l)=>[Xo(i),l])),r=i=>s.get(Xo(i.path))??Number.MAX_SAFE_INTEGER;return e.map((i,l)=>({worktree:i,index:l})).sort((i,l)=>{const o=r(i.worktree)-r(l.worktree);return o!==0?o:i.index-l.index}).map(i=>i.worktree)},kn=n=>_n(n)??"",Up=n=>{const e=n;return kn(e.directory??e.project?.worktree??null)},Dl=({open:n,project:e,worktree:s,onClose:r,onDeleted:i})=>{const{t:l}=xe(),o=Da(),a=vs(A=>A.activeSessions),f=$e(A=>A.archiveSessions),p=ws(A=>A.currentDirectory),{git:m,sourceControl:h}=vr(),[b,u]=d.useState(!1),[g,y]=d.useState(!1),[w,j]=d.useState(!1),[S,M]=d.useState(null),[I,E]=d.useState(!1),C=kn(s?.path),N=typeof s?.branch=="string"&&s.branch.trim().length>0,v=d.useMemo(()=>{if(!C)return[];const A=new Map;for(const R of[...a,...o])Up(R)===C&&A.set(R.id,R);return Array.from(A.values())},[a,o,C]);d.useEffect(()=>{if(!n){u(!1),y(!1),j(!1),M(null),E(!1);return}if(!s?.path)return;let A=!1;return Mc(s.path).then(R=>{A||(j(!!R?.isDirty),M(R?.upstream?.split("/")[0]?.trim()||null))}).catch(()=>{A||j(!!s.status?.isDirty)}),()=>{A=!0}},[n,s?.path,s?.status?.isDirty]);const T=d.useCallback(async A=>(await _c(e,A,{deleteRemoteBranch:N&&g,deleteLocalBranch:N&&b,remoteName:S??void 0,network:{git:m,sourceControl:h}}),kn(p)===C&&kn(e.path)&&ws.getState().setDirectory(kn(e.path),{showOverlay:!1}),!0),[p,b,g,m,N,e,S,h,C]),O=d.useCallback((A,R)=>{const D=Oc(A),V=pe.loading(l("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:D}));zc(A.path),(async()=>{try{const L=await wu({sessionIds:R,removeWorktree:()=>T(A),archiveSessions:f});if(!L.removed){pe.dismiss(V);return}const{failedIds:K}=L.archive;if(K.length>0){pe.error(K.length===1?l("sessions.sidebar.bulkActions.failedArchiveSingle",{count:K.length}):l("sessions.sidebar.bulkActions.failedArchivePlural",{count:K.length}),{id:V,description:l("sessions.sidebar.dialogs.deleteResult.tryAgain")});return}pe.success(l("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:D}),{id:V,description:l(N&&g?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed")}),i?.()}catch(L){const K=L instanceof ar?L.message||l("sessions.sidebar.dialogs.deleteResult.tryAgain"):L instanceof mi||L instanceof ns&&!L.message.includes(" ")?l("gitView.publish.remoteNotGranted"):L instanceof Error?L.message:l("sessions.sidebar.dialogs.deleteResult.tryAgain");pe.error(l("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:D}),{id:V,description:K})}finally{Bc(A.path)}})()},[f,g,N,i,T,l]),B=()=>{!s||I||(O(s,v.map(A=>A.id)),r())};if(!s)return null;const z=s.branch||s.label||s.path,_=(A,R,D,V)=>t.jsxs("button",{type:"button",role:"switch","aria-checked":A,disabled:V,onClick:()=>R(!A),className:se("flex w-full items-center justify-between gap-3 rounded-xl border border-border/70 px-3.5 py-3 text-start transition-colors","hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",V&&"pointer-events-none opacity-40"),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:D}),t.jsx("span",{className:se("relative h-6 w-10 shrink-0 rounded-full transition-colors",A?"bg-primary":"bg-muted-foreground/30"),children:t.jsx("span",{className:se("absolute top-0.5 size-5 rounded-full bg-white transition-transform",A?"translate-x-[1.125rem] rtl:-translate-x-[1.125rem]":"translate-x-0.5 rtl:-translate-x-0.5")})})]});return t.jsx(Ma,{open:n,onClose:r,title:l("mobile.projectEdit.deleteWorktreeTitle"),footer:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Ie,{variant:"ghost",className:"flex-1",onClick:r,disabled:I,children:l("projectEditDialog.actions.cancel")}),t.jsx(Ie,{variant:"destructive",className:"flex-1",onClick:()=>{B()},disabled:I,children:l("mobile.projectEdit.deleteWorktreeConfirmButton")})]}),children:t.jsxs("div",{className:"flex flex-col gap-4 px-1 py-1",children:[t.jsx("p",{className:"typography-ui-body text-foreground",children:l("mobile.projectEdit.deleteWorktreeConfirm",{name:z})}),w?t.jsx("p",{className:"rounded-xl border border-[var(--warning)]/40 bg-[color-mix(in_srgb,var(--warning)_10%,transparent)] px-3.5 py-3 typography-meta text-foreground",children:l("mobile.projectEdit.deleteWorktreeDirty")}):null,v.length>0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:l("mobile.projectEdit.deleteWorktreeArchiveNote",{count:v.length})}):null,N?t.jsxs("div",{className:"flex flex-col gap-2",children:[_(b,u,l("mobile.projectEdit.deleteLocalBranch"),I),_(g,y,l("mobile.projectEdit.deleteRemoteBranch"),I||!S)]}):null]})})},An=n=>{const e=fe.c(20),{project:s,size:r}=n,i=r===void 0?"md":r,{currentTheme:l}=_a(),o=s.icon?Oa[s.icon]:null;let a;e[0]!==s.color?(a=za(s.color),e[0]=s.color,e[1]=a):a=e[1];const f=a,p=i==="md"?"size-5":"size-3.5";let m;e[2]!==o||e[3]!==p||e[4]!==f?(m=o?t.jsx(Y,{name:o,className:p,style:f?{color:f}:void 0}):t.jsx(yi,{className:p,style:f?{color:f}:void 0}),e[2]=o,e[3]=p,e[4]=f,e[5]=m):m=e[5];const h=m;let b;e[6]!==l||e[7]!==h||e[8]!==s.iconImage||e[9]!==s.id?(b=s.iconImage?t.jsx(Ba,{project:{id:s.id,iconImage:s.iconImage??null},options:{themeVariant:l.metadata.variant,iconColor:l.colors.surface.foreground},className:"size-full object-contain",fallback:h}):null,e[6]=l,e[7]=h,e[8]=s.iconImage,e[9]=s.id,e[10]=b):b=e[10];const u=b;let g;e[11]!==s.iconBackground?(g=s.iconBackground?{backgroundColor:s.iconBackground}:void 0,e[11]=s.iconBackground,e[12]=g):g=e[12];const y=g;if(i==="md"){let S;return e[13]!==h||e[14]!==u||e[15]!==y?(S=t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground",children:u?t.jsx("span",{className:"flex size-6 items-center justify-center overflow-hidden rounded-md",style:y,children:u}):h}),e[13]=h,e[14]=u,e[15]=y,e[16]=S):S=e[16],S}const w=u??h;let j;return e[17]!==y||e[18]!==w?(j=t.jsx("span",{className:"flex size-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px] text-muted-foreground",style:y,children:w}),e[17]=y,e[18]=w,e[19]=j):j=e[19],j},Ml=n=>{const e=fe.c(57),{initialTitle:s,indent:r,className:i,aiRename:l,onSubmit:o,onCancel:a}=n,{t:f}=xe(),[p,m]=d.useState(s),h=Gp;let b;e[0]!==s||e[1]!==a||e[2]!==o||e[3]!==p?(b=()=>{const Q=p.trim();if(!Q||Q===s.trim()){a();return}o(Q)},e[0]=s,e[1]=a,e[2]=o,e[3]=p,e[4]=b):b=e[4];const u=b;let g;e[5]!==i?(g=se("flex h-9 min-w-0 flex-1 items-center gap-2 pe-2",i),e[5]=i,e[6]=g):g=e[6];let y;e[7]!==r?(y={paddingInlineStart:r},e[7]=r,e[8]=y):y=e[8];let w;e[9]!==u?(w=Q=>{Q.preventDefault(),u()},e[9]=u,e[10]=w):w=e[10];let j;e[11]===Symbol.for("react.memo_cache_sentinel")?(j=Q=>m(Q.target.value),e[11]=j):j=e[11];let S;e[12]!==a?(S=Q=>ju(Q,a),e[12]=a,e[13]=S):S=e[13];let M;e[14]!==f?(M=f("sessions.sidebar.session.rename.save"),e[14]=f,e[15]=M):M=e[15];let I;e[16]!==f?(I=f("sessions.sidebar.session.menu.rename"),e[16]=f,e[17]=I):I=e[17];let E;e[18]===Symbol.for("react.memo_cache_sentinel")?(E={minHeight:0},e[18]=E):E=e[18];let C;e[19]!==S||e[20]!==M||e[21]!==I||e[22]!==p?(C=t.jsx("input",{ref:h,value:p,onChange:j,onKeyDown:S,"aria-label":M,placeholder:I,className:"min-w-0 flex-1 bg-transparent text-[16px] typography-ui-label text-foreground outline-none placeholder:text-muted-foreground",style:E,enterKeyHint:"done"}),e[19]=S,e[20]=M,e[21]=I,e[22]=p,e[23]=C):C=e[23];const N=l.disabled;let v;e[24]!==l||e[25]!==a?(v=()=>{l.run(),a()},e[24]=l,e[25]=a,e[26]=v):v=e[26];let T;e[27]!==f?(T=f("sessions.aiRename.action"),e[27]=f,e[28]=T):T=e[28];let O,B;e[29]===Symbol.for("react.memo_cache_sentinel")?(O={touchAction:"manipulation",minHeight:0,minWidth:0},B=t.jsx(Y,{name:"ai-generate-2",className:"size-4"}),e[29]=O,e[30]=B):(O=e[29],B=e[30]);let z;e[31]!==l.disabled||e[32]!==l.hint||e[33]!==v||e[34]!==T?(z=t.jsx("button",{type:"button",disabled:N,onClick:v,"aria-label":T,"aria-description":l.hint,title:l.hint,className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground disabled:opacity-40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:O,children:B}),e[31]=l.disabled,e[32]=l.hint,e[33]=v,e[34]=T,e[35]=z):z=e[35];let _;e[36]!==f?(_=f("sessions.sidebar.session.rename.save"),e[36]=f,e[37]=_):_=e[37];let A,R;e[38]===Symbol.for("react.memo_cache_sentinel")?(A={touchAction:"manipulation",minHeight:0,minWidth:0},R=t.jsx(Y,{name:"check",className:"size-4"}),e[38]=A,e[39]=R):(A=e[38],R=e[39]);let D;e[40]!==_?(D=t.jsx("button",{type:"submit","aria-label":_,className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:A,children:R}),e[40]=_,e[41]=D):D=e[41];let V;e[42]!==f?(V=f("sessions.sidebar.session.rename.cancel"),e[42]=f,e[43]=V):V=e[43];let L,K;e[44]===Symbol.for("react.memo_cache_sentinel")?(L={touchAction:"manipulation",minHeight:0,minWidth:0},K=t.jsx(Y,{name:"close",className:"size-4"}),e[44]=L,e[45]=K):(L=e[44],K=e[45]);let F;e[46]!==a||e[47]!==V?(F=t.jsx("button",{type:"button",onClick:a,"aria-label":V,className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:L,children:K}),e[46]=a,e[47]=V,e[48]=F):F=e[48];let U;return e[49]!==C||e[50]!==z||e[51]!==g||e[52]!==D||e[53]!==F||e[54]!==y||e[55]!==w?(U=t.jsxs("form",{className:g,style:y,onSubmit:w,children:[C,z,D,F]}),e[49]=C,e[50]=z,e[51]=g,e[52]=D,e[53]=F,e[54]=y,e[55]=w,e[56]=U):U=e[56],U};function Gp(n){n&&(n.focus(),n.select())}const Tn=48,_l=4*Tn,Kp=180,xr=n=>{const e=fe.c(32),{actionsWidth:s,actions:r,revealed:i,onRevealedChange:l,dataActiveSession:o,contentClassName:a,children:f}=n,p=a===void 0?"relative flex w-full items-center bg-background":a,{direction:m}=xe(),h=m==="rtl"?-1:1,b=d.useRef(null),u=d.useRef(null),g=d.useRef(!1),y=d.useRef(0),w=d.useRef(i);let j;e[0]!==h?(j=(L,K)=>{const F=b.current;F&&(F.style.transition=K?`transform ${Kp}ms ease-out`:"none",F.style.transform=L===0?"none":`translateX(${L*h}px)`,y.current=L)},e[0]=h,e[1]=j):j=e[1];const S=j;let M,I;e[2]!==s||e[3]!==S||e[4]!==i?(M=()=>{w.current=i,S(i?s:0,!0)},I=[s,S,i],e[2]=s,e[3]=S,e[4]=i,e[5]=M,e[6]=I):(M=e[5],I=e[6]),d.useEffect(M,I);let E;e[7]===Symbol.for("react.memo_cache_sentinel")?(E=L=>{if(L.touches.length!==1)return;const K=L.touches[0];u.current={x:K.clientX,y:K.clientY},g.current=!1},e[7]=E):E=e[7];const C=E;let N;e[8]!==s||e[9]!==S||e[10]!==h?(N=L=>{if(!u.current)return;const K=L.touches[0],F=(K.clientX-u.current.x)*h,U=K.clientY-u.current.y;if(!g.current){if(Math.abs(F)<8||Math.abs(F)<=Math.abs(U))return;g.current=!0}const Q=w.current?s:0;S(Math.max(0,Math.min(s,Q+F)),!1)},e[8]=s,e[9]=S,e[10]=h,e[11]=N):N=e[11];const v=N;let T;e[12]!==s||e[13]!==S||e[14]!==l?(T=()=>{if(u.current=null,!g.current)return;g.current=!1;const L=y.current>s/2;S(L?s:0,!0),L!==w.current&&l(L)},e[12]=s,e[13]=S,e[14]=l,e[15]=T):T=e[15];const O=T,B=o||void 0;let z;e[16]===Symbol.for("react.memo_cache_sentinel")?(z={touchAction:"pan-y"},e[16]=z):z=e[16];let _;e[17]!==s?(_={width:s},e[17]=s,e[18]=_):_=e[18];const A=!i;let R;e[19]!==r||e[20]!==_||e[21]!==A?(R=t.jsx("div",{className:"absolute inset-y-0 inset-s-0 flex items-stretch",style:_,"aria-hidden":A,children:r}),e[19]=r,e[20]=_,e[21]=A,e[22]=R):R=e[22];let D;e[23]!==f||e[24]!==p?(D=t.jsx("div",{ref:b,className:p,children:f}),e[23]=f,e[24]=p,e[25]=D):D=e[25];let V;return e[26]!==O||e[27]!==v||e[28]!==R||e[29]!==D||e[30]!==B?(V=t.jsxs("div",{"data-active-session":B,className:"relative overflow-hidden",onTouchStart:C,onTouchMove:v,onTouchEnd:O,onTouchCancel:O,style:z,children:[R,D]}),e[26]=O,e[27]=v,e[28]=R,e[29]=D,e[30]=B,e[31]=V):V=e[31],V},Ol=n=>{const e=fe.c(62),{sessionId:s,title:r,revealed:i,confirmingDelete:l,onArchive:o,onRequestDelete:a,onConfirmDelete:f,onRequestRename:p,onRevealedChange:m,work:h,pin:b}=n,{t:u}=xe(),g=i?0:-1;let y;e[0]!==m||e[1]!==s||e[2]!==u?(y=async()=>{if(!(await Ca(s).catch(qp))?.ok){vi.error(u("sessions.sidebar.session.copyId.error"));return}m?.(!1),vi.success(u("sessions.sidebar.session.copyId.success"))},e[0]=m,e[1]=s,e[2]=u,e[3]=y):y=e[3];const w=y;let j;e[4]!==u||e[5]!==r?(j=u("mobile.sessions.archiveSessionAria",{title:r}),e[4]=u,e[5]=r,e[6]=j):j=e[6];let S,M;e[7]===Symbol.for("react.memo_cache_sentinel")?(S={touchAction:"manipulation"},M=t.jsx(Ef,{className:"size-[18px]"}),e[7]=S,e[8]=M):(S=e[7],M=e[8]);let I;e[9]!==o||e[10]!==j||e[11]!==g?(I=t.jsx("button",{type:"button",tabIndex:g,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":j,onClick:o,style:S,children:M}),e[9]=o,e[10]=j,e[11]=g,e[12]=I):I=e[12];let E;e[13]!==m||e[14]!==b||e[15]!==u||e[16]!==g?(E=b?t.jsx("button",{type:"button",tabIndex:g,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":b.pinned?u("sessions.sidebar.session.menu.unpin"):u("sessions.sidebar.session.menu.pin"),onClick:()=>{b.onToggle(),m?.(!1)},style:{touchAction:"manipulation"},children:t.jsx(Y,{name:b.pinned?"unpin":"pushpin",className:"size-[18px]"})}):null,e[13]=m,e[14]=b,e[15]=u,e[16]=g,e[17]=E):E=e[17];let C;e[18]!==m||e[19]!==u||e[20]!==g||e[21]!==h?(C=h?t.jsx("button",{type:"button",tabIndex:g,className:se("flex flex-1 items-center justify-center transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",h.inWork?"text-status-success":"text-muted-foreground active:text-foreground"),"aria-label":h.inWork?u("sessions.sidebar.session.work.markDone"):u("sessions.sidebar.session.work.track"),onClick:()=>{h.onToggle(),m?.(!1)},style:{touchAction:"manipulation"},children:t.jsx(Y,{name:h.inWork?"check":"eye",className:h.inWork?"size-5":"size-[18px]"})}):null,e[18]=m,e[19]=u,e[20]=g,e[21]=h,e[22]=C):C=e[22];const N=l?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80";let v;e[23]!==N?(v=se("flex flex-1 items-center justify-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive",N),e[23]=N,e[24]=v):v=e[24];let T;e[25]!==l||e[26]!==u||e[27]!==r?(T=l?u("mobile.sessions.confirmDeleteSessionAria",{title:r}):u("mobile.sessions.deleteSessionAria",{title:r}),e[25]=l,e[26]=u,e[27]=r,e[28]=T):T=e[28];const O=l?f:a;let B,z;e[29]===Symbol.for("react.memo_cache_sentinel")?(B={touchAction:"manipulation"},z=t.jsx(fr,{className:"size-[18px]"}),e[29]=B,e[30]=z):(B=e[29],z=e[30]);let _;e[31]!==T||e[32]!==O||e[33]!==v||e[34]!==g?(_=t.jsx("button",{type:"button",tabIndex:g,className:v,"aria-label":T,onClick:O,style:B,children:z}),e[31]=T,e[32]=O,e[33]=v,e[34]=g,e[35]=_):_=e[35];let A;e[36]!==u||e[37]!==r?(A=u("mobile.sessions.renameSessionAria",{title:r}),e[36]=u,e[37]=r,e[38]=A):A=e[38];let R,D;e[39]===Symbol.for("react.memo_cache_sentinel")?(R={touchAction:"manipulation"},D=t.jsx(nl,{className:"size-[18px]"}),e[39]=R,e[40]=D):(R=e[39],D=e[40]);let V;e[41]!==p||e[42]!==A||e[43]!==g?(V=t.jsx("button",{type:"button",tabIndex:g,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":A,onClick:p,style:R,children:D}),e[41]=p,e[42]=A,e[43]=g,e[44]=V):V=e[44];let L;e[45]!==u?(L=u("sessions.sidebar.session.menu.copyId"),e[45]=u,e[46]=L):L=e[46];let K;e[47]!==w?(K=()=>{w()},e[47]=w,e[48]=K):K=e[48];let F,U;e[49]===Symbol.for("react.memo_cache_sentinel")?(F={touchAction:"manipulation"},U=t.jsx(Y,{name:"file-copy",className:"size-[18px]"}),e[49]=F,e[50]=U):(F=e[49],U=e[50]);let Q;e[51]!==L||e[52]!==K||e[53]!==g?(Q=t.jsx("button",{type:"button",tabIndex:g,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":L,onClick:K,style:F,children:U}),e[51]=L,e[52]=K,e[53]=g,e[54]=Q):Q=e[54];let le;return e[55]!==_||e[56]!==V||e[57]!==Q||e[58]!==I||e[59]!==E||e[60]!==C?(le=t.jsxs(t.Fragment,{children:[I,E,C,_,V,Q]}),e[55]=_,e[56]=V,e[57]=Q,e[58]=I,e[59]=E,e[60]=C,e[61]=le):le=e[61],le};function qp(){return null}const ht=n=>n.parentID??null,Rt=n=>{const e=n;return Ze(e.directory??e.project?.worktree??null)},zl=n=>Aa(n),Sr=n=>{if(n<=0)return"";const e=Date.now()-n;if(e<6e4)return"now";const s=Math.floor(e/6e4);if(s<60)return`${s}m`;const r=Math.floor(s/60);if(r<24)return`${r}h`;const i=Math.floor(r/24);return i<7?`${i}d`:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(n))},Hp=4,Bl=n=>{const e=fe.c(4),{providerIDs:s}=n;let r;e[0]!==s?(r=s.slice(0,Hp).map(Xp),e[0]=s,e[1]=r):r=e[1];let i;return e[2]!==r?(i=t.jsx("span",{className:"inline-flex shrink-0 items-center -space-x-1",children:r}),e[2]=r,e[3]=i):i=e[3],i};function Xp(n){return t.jsx("span",{className:"inline-flex size-4 items-center justify-center rounded-full bg-background ring-1 ring-background",children:t.jsx(Ia,{providerId:n,className:"size-3 opacity-80"})},n)}const Ni=n=>{const e=fe.c(8),{session:s}=n,{t:r}=xe(),i=Lc(s);if(!i)return null;const l=Fc[i.status];let o;e[0]!==r||e[1]!==l?(o=r(l),e[0]=r,e[1]=l,e[2]=o):o=e[2];const a=o,f=$c[i.status];let p;e[3]!==f?(p={color:f},e[3]=f,e[4]=p):p=e[4];let m;return e[5]!==a||e[6]!==p?(m=t.jsx(Y,{name:"target",className:"size-3.5 shrink-0",style:p,"aria-label":a}),e[5]=a,e[6]=p,e[7]=m):m=e[7],m},Ci=n=>{const e=fe.c(9),{hasPermission:s,hasForm:r}=n,{t:i}=xe();if(!s&&!r)return null;let l;e[0]!==s||e[1]!==i?(l=s?t.jsx("span",{className:"inline-flex shrink-0 items-center rounded bg-destructive/10 px-1 py-0.5 text-destructive","aria-label":i("sessions.sidebar.session.status.permissionRequired"),children:t.jsx(Y,{name:"shield",className:"size-3"})}):null,e[0]=s,e[1]=i,e[2]=l):l=e[2];let o;e[3]!==r||e[4]!==i?(o=r?t.jsx("span",{className:"inline-flex shrink-0 items-center rounded bg-status-info/10 px-1 py-0.5 text-status-info","aria-label":i("sessions.sidebar.session.status.questionPending"),children:t.jsx(Y,{name:"question",className:"size-3"})}):null,e[3]=r,e[4]=i,e[5]=o):o=e[5];let a;return e[6]!==l||e[7]!==o?(a=t.jsxs(t.Fragment,{children:[l,o]}),e[6]=l,e[7]=o,e[8]=a):a=e[8],a},Ll=n=>{const e=fe.c(7);let s;e[0]!==n?(s=a=>n.some(f=>!!a.bySession.get(f)?.permissions.length),e[0]=n,e[1]=s):s=e[1];const r=ko(s);let i;e[2]!==n?(i=a=>n.some(f=>{const p=a.bySession.get(f);return!!(p?.forms.length||p?.pages.length)}),e[2]=n,e[3]=i):i=e[3];const l=ko(i);let o;return e[4]!==l||e[5]!==r?(o={hasPermission:r,hasForm:l},e[4]=l,e[5]=r,e[6]=o):o=e[6],o},Fl=({active:n,unread:e,running:s,pending:r})=>n?"text-primary":e||r.hasPermission||r.hasForm?"font-semibold text-foreground":s?"text-foreground":"text-muted-foreground",Pn=12,$l="flex min-w-0 flex-1 flex-col gap-1 py-2.5 pe-3 text-start",Wl="flex h-4 min-w-0 items-center gap-1.5 text-muted-foreground",Vl="flex min-w-0 flex-1 flex-col justify-center py-2.5 pe-3 text-start",Ul=n=>{const e=fe.c(5),{project:s}=n;let r;e[0]!==s?(r=t.jsx(An,{project:s,size:"xs"}),e[0]=s,e[1]=r):r=e[1];let i;return e[2]!==s.label||e[3]!==r?(i=t.jsx("span",{role:"img","aria-label":s.label,className:"inline-flex shrink-0",children:r}),e[2]=s.label,e[3]=r,e[4]=i):i=e[4],i},Gl=n=>{const e=fe.c(10),{project:s,children:r}=n;let i;e[0]!==s?(i=t.jsx(An,{project:s,size:"xs"}),e[0]=s,e[1]=i):i=e[1];let l;e[2]!==s.label?(l=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-micro text-muted-foreground",children:s.label}),e[2]=s.label,e[3]=l):l=e[3];let o;e[4]!==r?(o=t.jsx("span",{className:"flex shrink-0 items-center gap-2",children:r}),e[4]=r,e[5]=o):o=e[5];let a;return e[6]!==i||e[7]!==l||e[8]!==o?(a=t.jsxs("span",{className:"flex h-4 min-w-0 items-center gap-1.5",children:[i,l,o]}),e[6]=i,e[7]=l,e[8]=o,e[9]=a):a=e[9],a},Jp=n=>{const e=fe.c(52),{entry:s,showProject:r,projectLine:i,compact:l}=n,{t:o}=xe(),{run:a,project:f}=s;let p;e[0]!==a.key?(p=U=>U.runOverviewKey===a.key,e[0]=a.key,e[1]=p):p=e[1];const m=Ve(p);let h;e[2]!==s.laneNodes?(h={nodes:s.laneNodes,includeUnreadSubtasks:!1},e[2]=s.laneNodes,e[3]=h):h=e[3];const b=Ya(h);let u;e[4]!==a.lastActivity?(u=Sr(a.lastActivity),e[4]=a.lastActivity,e[5]=u):u=e[5];const g=u,y=a.lanes.length,w=m||void 0,j=m&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let S;e[6]!==j?(S=se("relative bg-background transition-colors",j),e[6]=j,e[7]=S):S=e[7];const M=l?Vl:$l;let I;e[8]!==M?(I=se(M,"w-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"),e[8]=M,e[9]=I):I=e[9];let E;e[10]===Symbol.for("react.memo_cache_sentinel")?(E={paddingInlineStart:Pn,touchAction:"manipulation"},e[10]=E):E=e[10];let C;e[11]!==a.key?(C=()=>Ve.getState().setRunOverviewKey(a.key),e[11]=a.key,e[12]=C):C=e[12];let N;e[13]!==a.title||e[14]!==o?(N=o("sessions.sidebar.run.openOverviewAria",{title:a.title}),e[13]=a.title,e[14]=o,e[15]=N):N=e[15];let v;e[16]!==b?(v=b?t.jsx(Za,{state:b}):null,e[16]=b,e[17]=v):v=e[17];let T;e[18]!==g?(T=g?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:g}):null,e[18]=g,e[19]=T):T=e[19];let O;e[20]!==v||e[21]!==T?(O=t.jsxs(t.Fragment,{children:[v,T]}),e[20]=v,e[21]=T,e[22]=O):O=e[22];const B=O,z=m?"text-primary":"text-foreground";let _;e[23]!==z?(_=se("block min-w-0 flex-1 truncate oc-ui-start-align typography-ui-label",z),e[23]=z,e[24]=_):_=e[24];let A;e[25]!==a.title||e[26]!==_?(A=t.jsx("span",{dir:"auto",className:_,children:a.title}),e[25]=a.title,e[26]=_,e[27]=A):A=e[27];const R=A;let D;e[28]!==l||e[29]!==f||e[30]!==i||e[31]!==B||e[32]!==R?(D=i&&!l?t.jsxs(t.Fragment,{children:[t.jsx(Gl,{project:f,children:B}),t.jsx("span",{className:"flex min-w-0 items-center",children:R})]}):t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[R,B]}),e[28]=l,e[29]=f,e[30]=i,e[31]=B,e[32]=R,e[33]=D):D=e[33];const V=D;let L;e[34]!==l||e[35]!==y||e[36]!==f||e[37]!==i||e[38]!==a.providerIDs||e[39]!==r||e[40]!==o?(L=l?null:t.jsxs("span",{className:Wl,children:[r&&!i?t.jsx(Ul,{project:f}):null,t.jsx(La,{className:"size-3.5 shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-micro",children:y===1?o("sessions.sidebar.run.laneCountSingle",{count:y}):o("sessions.sidebar.run.laneCountPlural",{count:y})}),t.jsx(Bl,{providerIDs:a.providerIDs})]}),e[34]=l,e[35]=y,e[36]=f,e[37]=i,e[38]=a.providerIDs,e[39]=r,e[40]=o,e[41]=L):L=e[41];let K;e[42]!==C||e[43]!==N||e[44]!==V||e[45]!==L||e[46]!==I?(K=t.jsxs("button",{type:"button",className:I,style:E,onClick:C,"aria-label":N,children:[V,L]}),e[42]=C,e[43]=N,e[44]=V,e[45]=L,e[46]=I,e[47]=K):K=e[47];let F;return e[48]!==K||e[49]!==w||e[50]!==S?(F=t.jsx("div",{"data-active-session":w,className:S,children:K}),e[48]=K,e[49]=w,e[50]=S,e[51]=F):F=e[51],F},Yp=n=>{const e=fe.c(130),{entry:s,showProject:r,projectLine:i,compact:l,pinMarker:o,active:a,revealed:f,confirmingDelete:p,renaming:m,handlers:h}=n,{t:b}=xe(),{session:u,project:g,branch:y,inSpace:w}=s;let j;e[0]!==u.title||e[1]!==b?(j=u.title?.trim()||b("mobile.sessions.untitled"),e[0]=u.title,e[1]=b,e[2]=j):j=e[2];const S=j;let M;e[3]!==u?(M=Sr(zl(u)),e[3]=u,e[4]=M):M=e[4];const I=M,E=Qa(u.id,u.directory,f||m),C=Ai(u.id),N=Ti(u.id),v=N!==null,T=!v&&C>0&&!a,O=Pi(u.id,v),B=(v||T)&&O,z=h.onToggleWork;let _;e[5]!==u?(_=Fa(u),e[5]=u,e[6]=_):_=e[6];const A=_;let R;e[7]!==A||e[8]!==z||e[9]!==u?(R=z?{inWork:A,onToggle:()=>z(u,A)}:void 0,e[7]=A,e[8]=z,e[9]=u,e[10]=R):R=e[10];const D=R;let V;e[11]!==h||e[12]!==u?(V=h.isPinned(u),e[11]=h,e[12]=u,e[13]=V):V=e[13];const L=V;let K;e[14]!==h||e[15]!==u?(K=()=>h.onTogglePin(u),e[14]=h,e[15]=u,e[16]=K):K=e[16];let F;e[17]!==L||e[18]!==K?(F={pinned:L,onToggle:K},e[17]=L,e[18]=K,e[19]=F):F=e[19];const U=F,{descendantIdsOf:Q}=h;let le;e[20]!==Q||e[21]!==u.id?(le=[u.id,...Q(u.id)],e[20]=Q,e[21]=u.id,e[22]=le):le=e[22];const oe=Ll(le),re=_l+Tn+(D?Tn:0);let ie;e[23]!==h||e[24]!==u.id?(ie=be=>h.onRevealedChange(u.id,be),e[23]=h,e[24]=u.id,e[25]=ie):ie=e[25];const k=a&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let q;e[26]!==k?(q=se("relative flex w-full items-center bg-background transition-colors",k),e[26]=k,e[27]=q):q=e[27];let G;e[28]!==h||e[29]!==u?(G=()=>h.onArchive(u),e[28]=h,e[29]=u,e[30]=G):G=e[30];let Z;e[31]!==h||e[32]!==u.id?(Z=()=>h.onRequestDelete(u.id),e[31]=h,e[32]=u.id,e[33]=Z):Z=e[33];let me;e[34]!==h||e[35]!==u?(me=()=>h.onConfirmDelete(u),e[34]=h,e[35]=u,e[36]=me):me=e[36];let ue,X;e[37]!==h||e[38]!==u.id?(ue=()=>h.onRequestRename(u.id),X=be=>h.onRevealedChange(u.id,be),e[37]=h,e[38]=u.id,e[39]=ue,e[40]=X):(ue=e[39],X=e[40]);let de;e[41]!==p||e[42]!==U||e[43]!==f||e[44]!==u.id||e[45]!==G||e[46]!==Z||e[47]!==me||e[48]!==ue||e[49]!==X||e[50]!==S||e[51]!==D?(de=t.jsx(Ol,{sessionId:u.id,title:S,revealed:f,confirmingDelete:p,onArchive:G,onRequestDelete:Z,onConfirmDelete:me,onRequestRename:ue,onRevealedChange:X,work:D,pin:U}),e[41]=p,e[42]=U,e[43]=f,e[44]=u.id,e[45]=G,e[46]=Z,e[47]=me,e[48]=ue,e[49]=X,e[50]=S,e[51]=D,e[52]=de):de=e[52];let we;e:{let be;e[53]!==l||e[54]!==oe||e[55]!==u?(be=l?t.jsxs(t.Fragment,{children:[t.jsx(Ni,{session:u}),t.jsx(Ci,{...oe})]}):null,e[53]=l,e[54]=oe,e[55]=u,e[56]=be):be=e[56];let ye;e[57]!==o||e[58]!==L||e[59]!==b?(ye=L&&o?t.jsx(Y,{name:"pushpin",className:"size-3 shrink-0 text-muted-foreground","aria-label":b("sessions.sidebar.session.status.pinned")}):null,e[57]=o,e[58]=L,e[59]=b,e[60]=ye):ye=e[60];let Te;e[61]!==E.pending||e[62]!==v||e[63]!==T||e[64]!==b||e[65]!==N?(Te=E.pending?t.jsx(Y,{name:"loader-4",className:"size-3 shrink-0 animate-spin text-primary","aria-label":b("sessions.aiRename.generating")}):v||T?t.jsx(ur,{state:N??"unread"}):null,e[61]=E.pending,e[62]=v,e[63]=T,e[64]=b,e[65]=N,e[66]=Te):Te=e[66];let Ee;e[67]!==v||e[68]!==u.id||e[69]!==B||e[70]!==I?(Ee=B?t.jsx(Di,{sessionId:u.id,running:v,className:"shrink-0 typography-micro"}):I?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:I}):null,e[67]=v,e[68]=u.id,e[69]=B,e[70]=I,e[71]=Ee):Ee=e[71];let De;e[72]!==be||e[73]!==ye||e[74]!==Te||e[75]!==Ee?(De=t.jsxs(t.Fragment,{children:[be,ye,Te,Ee]}),e[72]=be,e[73]=ye,e[74]=Te,e[75]=Ee,e[76]=De):De=e[76];const je=De,Ne=i&&!l;let H;e[77]!==g||e[78]!==je||e[79]!==Ne?(H=Ne?t.jsx(Gl,{project:g,children:je}):null,e[77]=g,e[78]=je,e[79]=Ne,e[80]=H):H=e[80];let ee;e[81]!==a||e[82]!==E||e[83]!==h||e[84]!==v||e[85]!==oe||e[86]!==m||e[87]!==u.id||e[88]!==T||e[89]!==je||e[90]!==S||e[91]!==Ne?(ee=m?t.jsx(Ml,{initialTitle:S,indent:0,aiRename:E,className:"h-[1lh] pe-0 typography-ui-label [&_button]:size-6 [&_button>svg]:size-3.5",onSubmit:qe=>h.onSubmitRename(u.id,qe),onCancel:h.onCancelRename}):t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{dir:"auto",className:se("block min-w-0 flex-1 truncate oc-ui-start-align typography-ui-label",Fl({active:a,unread:T,running:v,pending:oe})),children:S}),Ne?null:je]}),e[81]=a,e[82]=E,e[83]=h,e[84]=v,e[85]=oe,e[86]=m,e[87]=u.id,e[88]=T,e[89]=je,e[90]=S,e[91]=Ne,e[92]=ee):ee=e[92];let ve;e[93]!==y||e[94]!==l||e[95]!==w||e[96]!==oe||e[97]!==g||e[98]!==u||e[99]!==r||e[100]!==b||e[101]!==Ne?(ve=l?null:t.jsxs("span",{className:Wl,children:[r&&!Ne?t.jsx(Ul,{project:g}):null,y?t.jsxs(t.Fragment,{children:[w?t.jsx(Y,{name:"box-3",className:"size-3.5 shrink-0","aria-hidden":!1,role:"img","aria-label":b("sessions.sidebar.group.space")}):t.jsx(Y,{name:"git-branch",className:"size-3.5 shrink-0"}),t.jsx("span",{className:"block min-w-0 truncate typography-micro",children:y})]}):null,t.jsxs("span",{className:"ms-auto flex shrink-0 items-center gap-1.5",children:[t.jsx(Ni,{session:u}),t.jsx(Ci,{...oe})]})]}),e[93]=y,e[94]=l,e[95]=w,e[96]=oe,e[97]=g,e[98]=u,e[99]=r,e[100]=b,e[101]=Ne,e[102]=ve):ve=e[102];let ge;e[103]!==H||e[104]!==ee||e[105]!==ve?(ge=t.jsxs(t.Fragment,{children:[H,ee,ve]}),e[103]=H,e[104]=ee,e[105]=ve,e[106]=ge):ge=e[106];const Ce=ge,Be=l?Vl:$l;if(m){let qe;e[107]===Symbol.for("react.memo_cache_sentinel")?(qe={paddingInlineStart:Pn},e[107]=qe):qe=e[107];let it;e[108]!==Be||e[109]!==Ce?(it=t.jsx("div",{className:Be,style:qe,children:Ce}),e[108]=Be,e[109]=Ce,e[110]=it):it=e[110],we=it;break e}let Le;e[111]!==Be?(Le=se(Be,"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"),e[111]=Be,e[112]=Le):Le=e[112];let et;e[113]===Symbol.for("react.memo_cache_sentinel")?(et={paddingInlineStart:Pn,touchAction:"manipulation"},e[113]=et):et=e[113];let Fe;e[114]!==h||e[115]!==f||e[116]!==u?(Fe=()=>{if(f){h.onRevealedChange(u.id,!1);return}h.onSelect(u)},e[114]=h,e[115]=f,e[116]=u,e[117]=Fe):Fe=e[117];let jt;e[118]!==Ce||e[119]!==Le||e[120]!==Fe?(jt=t.jsx("button",{type:"button",className:Le,style:et,onClick:Fe,children:Ce}),e[118]=Ce,e[119]=Le,e[120]=Fe,e[121]=jt):jt=e[121],we=jt}let Se;return e[122]!==a||e[123]!==f||e[124]!==ie||e[125]!==q||e[126]!==de||e[127]!==we||e[128]!==re?(Se=t.jsx(xr,{actionsWidth:re,revealed:f,onRevealedChange:ie,dataActiveSession:a,contentClassName:q,actions:de,children:we}),e[122]=a,e[123]=f,e[124]=ie,e[125]=q,e[126]=de,e[127]=we,e[128]=re,e[129]=Se):Se=e[129],Se},si=n=>{const e=fe.c(15),{entries:s,showProject:r,projectLine:i,compact:l,pinMarker:o,handlers:a}=n,f=i===void 0?!1:i,p=l===void 0?!1:l,m=o===void 0?!0:o;let h;if(e[0]!==p||e[1]!==s||e[2]!==a||e[3]!==m||e[4]!==f||e[5]!==r){let u;e[7]!==p||e[8]!==a||e[9]!==m||e[10]!==f||e[11]!==r?(u=g=>g.kind==="run"?t.jsx(Jp,{entry:g,showProject:r,projectLine:f,compact:p},`run:${g.run.key}`):t.jsx(Yp,{entry:g,showProject:r,projectLine:f,compact:p,pinMarker:m,active:a.currentSessionId===g.session.id,revealed:a.revealedSessionId===g.session.id,confirmingDelete:a.confirmingDeleteSessionId===g.session.id,renaming:a.renamingSessionId===g.session.id,handlers:a},g.session.id),e[7]=p,e[8]=a,e[9]=m,e[10]=f,e[11]=r,e[12]=u):u=e[12],h=s.map(u),e[0]=p,e[1]=s,e[2]=a,e[3]=m,e[4]=f,e[5]=r,e[6]=h}else h=e[6];let b;return e[13]!==h?(b=t.jsx(t.Fragment,{children:h}),e[13]=h,e[14]=b):b=e[14],b},Qp=n=>{const e=fe.c(9),{scrollRootRef:s,visibleCount:r,onReachEnd:i}=n,l=d.useRef(null),o=d.useRef(i);let a,f;e[0]!==i?(a=()=>{o.current=i},f=[i],e[0]=i,e[1]=a,e[2]=f):(a=e[1],f=e[2]),d.useEffect(a,f);let p;e[3]!==s?(p=()=>{const b=l.current;if(!b)return;const u=new IntersectionObserver(g=>{g.some(Zp)&&o.current()},{root:s.current??null,rootMargin:"400px 0px"});return u.observe(b),()=>u.disconnect()},e[3]=s,e[4]=p):p=e[4];let m;e[5]!==s||e[6]!==r?(m=[s,r],e[5]=s,e[6]=r,e[7]=m):m=e[7],d.useEffect(p,m);let h;return e[8]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx("div",{ref:l,"aria-hidden":!0,className:"h-px w-full"}),e[8]=h):h=e[8],h};function Zp(n){return n.isIntersecting}const Jo="mobile-surface-root",ni=16,ir=200,eh=()=>{if(typeof document>"u")return null;let n=document.getElementById(Jo);return n||(n=document.createElement("div"),n.id=Jo,document.body.appendChild(n)),n},Ut=({open:n,onClose:e,title:s,subtitle:r,trailing:i,disableEscapeDismiss:l=!1,headerless:o=!1,noHeaderBorder:a=!1,ariaLabel:f,variant:p="fullscreen",dialogAlign:m="chat",children:h})=>{const{t:b,direction:u}=xe(),g=d.useRef(null),[y,w]=d.useState(!1),[j,S]=d.useState(!1),M=d.useRef(null),I=d.useRef(null),E=d.useRef(e);if(d.useEffect(()=>{E.current=e},[e]),typeof document<"u"&&!g.current&&(g.current=eh()),d.useEffect(()=>{if(!n){w(!1);return}const v=window.setTimeout(()=>w(!0),ni);return()=>window.clearTimeout(v)},[n]),d.useEffect(()=>{if(!n){S(!1);return}const v=window.setTimeout(()=>S(!0),ni+ir+80);return()=>window.clearTimeout(v)},[n]),d.useEffect(()=>{if(!n)return;const v=document.body.style.overflow;I.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow="hidden";const T=()=>{const z=M.current;if(!z)return;(z.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??z).focus({preventScroll:!0})},O=window.setTimeout(T,ni),B=z=>{if(z.key==="Escape"&&!l){if(Mi(z))return;E.current();return}if(z.key!=="Tab")return;const _=M.current;if(!_)return;const A=Array.from(_.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(L=>!L.hasAttribute("disabled")&&L.getAttribute("aria-hidden")!=="true");if(A.length===0){z.preventDefault(),_.focus({preventScroll:!0});return}const R=A[0],D=A[A.length-1],V=document.activeElement;z.shiftKey&&V===R?(z.preventDefault(),D.focus({preventScroll:!0})):!z.shiftKey&&V===D&&(z.preventDefault(),R.focus({preventScroll:!0}))};return document.addEventListener("keydown",B),()=>{window.clearTimeout(O),document.body.style.overflow=v,document.removeEventListener("keydown",B),I.current?.focus?.({preventScroll:!0}),I.current=null}},[l,n]),!n||!g.current)return null;const C=p==="dialog",N=t.jsxs("section",{ref:M,role:"dialog","aria-modal":"true","aria-label":f,tabIndex:-1,className:se("flex flex-col bg-background text-foreground",C?"h-[min(88dvh,860px)] w-full max-w-[720px] overflow-hidden rounded-2xl border border-border/70 shadow-[0_24px_64px_rgb(0_0_0_/_0.32)]":"oc-keyboard-inset-surface oc-bottom-safe-surface fixed inset-0 z-50"),style:C?{opacity:y?1:0,transform:y?"none":"scale(0.97)",transition:`opacity ${ir}ms ease-out, transform ${ir}ms cubic-bezier(0.32, 0.72, 0, 1)`}:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:y?"none":u==="rtl"?"translateX(-100%)":"translateX(100%)",transition:`transform ${ir}ms cubic-bezier(0.32, 0.72, 0, 1)`},onTransitionEnd:v=>{y&&v.target===v.currentTarget&&v.propertyName==="transform"&&S(!0)},children:[o?null:t.jsxs("header",{className:se("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",!a&&"border-b border-border/70"),children:[t.jsx("button",{type:"button",className:"-ms-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-ring","aria-label":b("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"close",className:"size-5"})}),t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[s?typeof s=="string"?t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:s}):s:null,r?typeof r=="string"?t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:r}):r:null]}),i?t.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:i}):null]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:j?t.jsx("div",{className:"h-full",style:{animation:"oc-surface-content-in 200ms ease-out"},children:h}):null}),t.jsx("style",{children:"@keyframes oc-surface-content-in { from { opacity: 0 } to { opacity: 1 } }"})]});return C?Hs.createPortal(t.jsx("div",{className:"oc-keyboard-inset-surface oc-bottom-safe-surface fixed inset-0 z-50 flex items-center justify-center p-4 transition-opacity duration-200 ease-out",style:{background:"rgb(0 0 0 / 0.45)",opacity:y?1:0,paddingLeft:m==="chat"?"max(1rem, var(--oc-chat-inset-left, 0px))":"1rem",paddingRight:m==="chat"?"max(1rem, var(--oc-chat-inset-right, 0px))":"1rem",paddingTop:"max(1rem, var(--oc-safe-area-top, 0px))"},onClick:e,children:t.jsx("div",{className:"flex w-full max-w-[720px] justify-center",onClick:v=>v.stopPropagation(),children:N})}),g.current):Hs.createPortal(N,g.current)},th=n=>{const e=fe.c(8),{projectPath:s}=n,{t:r}=xe(),{journey:i}=lc();let l;if(e[0]!==i||e[1]!==s||e[2]!==r){const o=i?cc(i,s):[];let a;e[4]!==r?(a=r("mobile.projectEdit.spacesTitle"),e[4]=r,e[5]=a):a=e[5];let f;e[6]!==a?(f=t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:a}),e[6]=a,e[7]=f):f=e[7],l=t.jsxs("div",{className:"flex flex-col gap-2",children:[f,i!==null&&o.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:r("spaces.page.empty")}):null,o.map(ih)]}),e[0]=i,e[1]=s,e[2]=r,e[3]=l}else l=e[3];return l},sh=n=>_n(n)??"",nh=n=>{const e=fe.c(38),{worktree:s,onDelete:r}=n,{t:i}=xe();let l;e[0]!==s.path?(l={id:s.path},e[0]=s.path,e[1]=l):l=e[1];const{attributes:o,listeners:a,setNodeRef:f,transform:p,transition:m,isDragging:h}=Gi(l);let b;e[2]!==p?(b=qi.Transform.toString(p),e[2]=p,e[3]=b):b=e[3];const u=h?10:1;let g;e[4]!==b||e[5]!==u||e[6]!==m?(g={transform:b,transition:m,zIndex:u},e[4]=b,e[5]=u,e[6]=m,e[7]=g):g=e[7];const y=g,w=s.branch||s.label||s.path,j=Wa(s.path),S=h&&"shadow-lg shadow-black/20",M=j&&"opacity-60";let I;e[8]!==S||e[9]!==M?(I=se("flex items-center gap-1 rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",S,M),e[8]=S,e[9]=M,e[10]=I):I=e[10];const E=j||void 0;let C;e[11]!==w||e[12]!==i?(C=i("mobile.projectEdit.dragWorktreeAria",{label:w}),e[11]=w,e[12]=i,e[13]=C):C=e[13];let N;e[14]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx(Oi,{className:"size-4"}),e[14]=N):N=e[14];let v;e[15]!==o||e[16]!==a||e[17]!==C?(v=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":C,...o,...a,children:N}),e[15]=o,e[16]=a,e[17]=C,e[18]=v):v=e[18];let T;e[19]!==j||e[20]!==i?(T=j?t.jsx("span",{className:"inline-flex shrink-0 text-muted-foreground",role:"status","aria-label":i("sessions.sidebar.group.worktreeRemoving"),children:t.jsx(Y,{name:"loader-4",className:"size-4 animate-spin"})}):t.jsx(Y,{name:"node-tree",className:"size-4 shrink-0 text-muted-foreground"}),e[19]=j,e[20]=i,e[21]=T):T=e[21];let O;e[22]!==w?(O=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:w}),e[22]=w,e[23]=O):O=e[23];let B;e[24]!==w||e[25]!==r||e[26]!==j||e[27]!==i?(B=j?null:t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive","aria-label":i("mobile.projectEdit.deleteWorktreeAria",{label:w}),onClick:r,style:{touchAction:"manipulation"},children:t.jsx(fr,{className:"size-4"})}),e[24]=w,e[25]=r,e[26]=j,e[27]=i,e[28]=B):B=e[28];let z;return e[29]!==f||e[30]!==y||e[31]!==v||e[32]!==T||e[33]!==O||e[34]!==B||e[35]!==I||e[36]!==E?(z=t.jsxs("div",{ref:f,style:y,className:I,"aria-busy":E,children:[v,T,O,B]}),e[29]=f,e[30]=y,e[31]=v,e[32]=T,e[33]=O,e[34]=B,e[35]=I,e[36]=E,e[37]=z):z=e[37],z},rh=n=>{const e=fe.c(87),{open:s,project:r,onClose:i,onWorktreesChanged:l}=n,{t:o}=xe(),{currentTheme:a}=_a(),f=Ve(oh),p=ut(ah),m=ut(lh),h=ut(ch),b=Si(dh);let u;e[0]!==r?(u=ee=>r?ee.projects.find(ve=>ve.id===r.id)?.iconImage??null:null,e[0]=r,e[1]=u):u=e[1];const g=ut(u),[y,w]=d.useState(""),[j,S]=d.useState(null),[M,I]=d.useState(null),[E,C]=d.useState(!1);let N;e[2]===Symbol.for("react.memo_cache_sentinel")?(N=[],e[2]=N):N=e[2];const[v,T]=d.useState(N),[O,B]=d.useState(null),z=r?.id??null;let _;e[3]!==s||e[4]!==r?(_=()=>{!s||!r||(w(r.label),S(r.icon??null),I(r.color??null),T(r.worktrees))},e[3]=s,e[4]=r,e[5]=_):_=e[5];let A;e[6]!==s||e[7]!==z?(A=[s,z],e[6]=s,e[7]=z,e[8]=A):A=e[8],d.useEffect(_,A);let R;e[9]!==s||e[10]!==r?(R=()=>{!s||!r||T(ee=>{const ve=r.worktrees.map(uh),ge=ee.map(fh);return ve.length===ge.length&&ve.every(Be=>ge.includes(Be))?ee:r.worktrees})},e[9]=s,e[10]=r,e[11]=R):R=e[11];const D=r?.worktrees;let V;e[12]!==D?(V=[D],e[12]=D,e[13]=V):V=e[13],d.useEffect(R,V);let L;e[14]===Symbol.for("react.memo_cache_sentinel")?(L={activationConstraint:{distance:8}},e[14]=L):L=e[14];let K;e[15]===Symbol.for("react.memo_cache_sentinel")?(K={coordinateGetter:Ki},e[15]=K):K=e[15];const F=Bi(Js(Fi,L),Js(Li,K));let U;e[16]!==M||e[17]!==j||e[18]!==y||e[19]!==i||e[20]!==r||e[21]!==p?(U=()=>{if(!r)return;const ve={label:y.trim()||r.label,icon:j,color:M};M!==(r.color??null)&&(ve.iconBackground=Uc(M)),p(r.id,ve),i()},e[16]=M,e[17]=j,e[18]=y,e[19]=i,e[20]=r,e[21]=p,e[22]=U):U=e[22];const Q=U;let le;e[23]!==m||e[24]!==E||e[25]!==r||e[26]!==o?(le=()=>{!r||E||(C(!0),m(r.id).then(ee=>{if(!ee.ok){pe.error(ee.error||o("projectEditDialog.toast.failedToDiscoverIcon"));return}if(ee.skipped){pe.success(o("projectEditDialog.toast.customIconAlreadySet"));return}pe.success(o("projectEditDialog.toast.iconDiscovered"))}).finally(()=>C(!1)))},e[23]=m,e[24]=E,e[25]=r,e[26]=o,e[27]=le):le=e[27];const ce=le;let oe;e[28]!==r||e[29]!==h||e[30]!==o?(oe=()=>{r&&h(r.id).then(ee=>{if(!ee.ok){pe.error(ee.error||o("projectEditDialog.toast.failedToRemoveIcon"));return}pe.success(o("projectEditDialog.toast.iconRemoved"))})},e[28]=r,e[29]=h,e[30]=o,e[31]=oe):oe=e[31];const re=oe;let ie;e[32]!==v||e[33]!==r||e[34]!==b?(ie=ee=>{const{active:ve,over:ge}=ee;if(!ge||ve.id===ge.id||!r)return;const Ce=v.findIndex(Fe=>Fe.path===ve.id),Be=v.findIndex(Fe=>Fe.path===ge.id);if(Ce<0||Be<0)return;const Le=[...v],[et]=Le.splice(Ce,1);Le.splice(Be,0,et),T(Le),b(r.id,Le.map(mh))},e[32]=v,e[33]=r,e[34]=b,e[35]=ie):ie=e[35];const k=ie;let q;e[36]!==M?(q=za(M),e[36]=M,e[37]=q):q=e[37];const G=q,Z=j?Oa[j]:null,me=!!g;let ue;e[38]!==o?(ue=o("projectEditDialog.title"),e[38]=o,e[39]=ue):ue=e[39];let X;e[40]!==o?(X=o("projectEditDialog.title"),e[40]=o,e[41]=X):X=e[41];let de;e[42]!==o?(de=o("projectEditDialog.actions.save"),e[42]=o,e[43]=de):de=e[43];let we;e[44]!==y?(we=y.trim(),e[44]=y,e[45]=we):we=e[45];const Se=!we;let be,ye;e[46]===Symbol.for("react.memo_cache_sentinel")?(be={touchAction:"manipulation"},ye=t.jsx(rl,{className:"size-4"}),e[46]=be,e[47]=ye):(be=e[46],ye=e[47]);let Te;e[48]!==o?(Te=o("projectEditDialog.actions.save"),e[48]=o,e[49]=Te):Te=e[49];let Ee;e[50]!==Q||e[51]!==de||e[52]!==Se||e[53]!==Te?(Ee=t.jsxs(Ie,{type:"button",variant:"default",size:"sm","aria-label":de,onClick:Q,disabled:Se,style:be,children:[ye,Te]}),e[50]=Q,e[51]=de,e[52]=Se,e[53]=Te,e[54]=Ee):Ee=e[54];let De;e[55]!==M||e[56]!==G||e[57]!==g||e[58]!==a||e[59]!==F||e[60]!==ce||e[61]!==re||e[62]!==k||e[63]!==me||e[64]!==j||e[65]!==E||e[66]!==f||e[67]!==y||e[68]!==v||e[69]!==Z||e[70]!==r||e[71]!==o?(De=r?t.jsxs("div",{className:"h-full space-y-6 overflow-y-auto px-4 pb-8 pt-2",children:[t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx("span",{className:"flex size-16 items-center justify-center overflow-hidden rounded-2xl bg-[var(--surface-muted)] text-muted-foreground",style:r.iconBackground?{backgroundColor:r.iconBackground}:void 0,children:me?t.jsx(Ba,{project:{id:r.id,iconImage:g},options:{themeVariant:a.metadata.variant,iconColor:a.colors.surface.foreground},className:"size-full object-contain",fallback:t.jsx(yi,{className:"size-7"})}):Z?t.jsx(Y,{name:Z,className:"size-7",style:G?{color:G}:void 0}):t.jsx(yi,{className:"size-7",style:G?{color:G}:void 0})})}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:o("projectEditDialog.field.name")}),t.jsx($a,{value:y,onChange:ee=>w(ee.target.value),placeholder:o("projectEditDialog.field.namePlaceholder"),className:"h-11"}),t.jsx("p",{className:"truncate typography-meta text-muted-foreground",title:r.path,children:r.path})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:o("projectEditDialog.field.color")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>I(null),"aria-label":o("projectEditDialog.option.none"),className:se("flex size-9 items-center justify-center rounded-xl border-2 transition-all",M===null?"border-foreground":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx("span",{className:"h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40"})}),Wc.map(ee=>t.jsx("button",{type:"button",onClick:()=>I(ee),"aria-label":o("settings.projects.appearance.colorSwatchAria",{color:ee}),title:ee,className:se("size-9 rounded-xl border-2 transition-all",M===ee?"border-foreground":"border-transparent hover:border-border/70"),style:{backgroundColor:ee,touchAction:"manipulation"}},ee))]})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:o("projectEditDialog.field.icon")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>S(null),"aria-label":o("projectEditDialog.option.none"),className:se("flex size-9 items-center justify-center rounded-xl border-2 transition-all",j===null?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx("span",{className:"h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40"})}),Vc.map(ee=>t.jsx("button",{type:"button",onClick:()=>S(ee.key),"aria-label":ee.label,title:ee.label,className:se("flex size-9 items-center justify-center rounded-xl border-2 transition-all",j===ee.key?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx(Y,{name:ee.Icon,className:"size-4",style:G?{color:G}:void 0})},ee.key))]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[t.jsx(Ie,{size:"sm",variant:"outline",onClick:ce,disabled:E,children:o(E?"projectEditDialog.actions.discovering":"projectEditDialog.actions.discoverFavicon")}),me?t.jsx(Ie,{size:"sm",variant:"outline",onClick:re,children:o("projectEditDialog.actions.removeProjectIcon")}):null]})]}),r.isGitRepo?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:o("mobile.projectEdit.worktreesTitle")}),v.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("mobile.projectEdit.worktreesEmpty")}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("mobile.projectEdit.reorderHint")}),t.jsx($i,{sensors:F,collisionDetection:Wi,onDragEnd:k,children:t.jsx(Vi,{items:v.map(ph),strategy:Ui,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:v.map(ee=>t.jsx(nh,{worktree:ee,onDelete:()=>B(ee)},ee.path))})})})]})]}):null,r.isGitRepo&&f?t.jsx(th,{projectPath:r.path}):null]}):null,e[55]=M,e[56]=G,e[57]=g,e[58]=a,e[59]=F,e[60]=ce,e[61]=re,e[62]=k,e[63]=me,e[64]=j,e[65]=E,e[66]=f,e[67]=y,e[68]=v,e[69]=Z,e[70]=r,e[71]=o,e[72]=De):De=e[72];let je;e[73]!==i||e[74]!==s||e[75]!==ue||e[76]!==X||e[77]!==Ee||e[78]!==De?(je=t.jsx(Ut,{open:s,onClose:i,title:ue,ariaLabel:X,noHeaderBorder:!0,trailing:Ee,children:De}),e[73]=i,e[74]=s,e[75]=ue,e[76]=X,e[77]=Ee,e[78]=De,e[79]=je):je=e[79];let Ne;e[80]!==l||e[81]!==r||e[82]!==O?(Ne=r?t.jsx(Dl,{open:!!O,project:{id:r.id,path:r.path},worktree:O,onClose:()=>B(null),onDeleted:()=>{T(ee=>ee.filter(ve=>ve.path!==O?.path)),l?.()}}):null,e[80]=l,e[81]=r,e[82]=O,e[83]=Ne):Ne=e[83];let H;return e[84]!==je||e[85]!==Ne?(H=t.jsxs(t.Fragment,{children:[je,Ne]}),e[84]=je,e[85]=Ne,e[86]=H):H=e[86],H};function ih(n){return t.jsx(Ff,{entry:n,actions:"sheet"},n.id)}function oh(n){return n.isolatedSpacesEnabled}function ah(n){return n.updateProjectMeta}function lh(n){return n.discoverProjectIcon}function ch(n){return n.removeProjectIcon}function dh(n){return n.setWorktreeOrder}function uh(n){return n.path}function fh(n){return n.path}function mh(n){return sh(n.path)}function ph(n){return n.path}const hh=32,gh=80,bh=64,xh=.7,yh=140,vh=.4,wh=(n,e,s)=>{const r=e.ownerDocument.defaultView;if(!r)return"drawer";let i=!1;for(let l=n instanceof r.Element?n:null;l&&l!==e;l=l.parentElement){const o=l.scrollWidth-l.clientWidth;if(o<=1)continue;const a=r.getComputedStyle(l);if(a.overflowX!=="auto"&&a.overflowX!=="scroll")continue;const f=a.direction==="rtl"?-o:0,p=f+o;if(s?l.scrollLeft>f+1:l.scrollLeft<p-1)return"content";i=!0}return i?"content-end":"drawer"},ro=(n,e)=>{const s=d.useRef(e);s.current=e;const r=e.enabled??!0;d.useEffect(()=>{if(!r)return;const i=n.current;if(!i)return;const o=window.Capacitor?.getPlatform?.()==="android"?gh:hh,a=i.ownerDocument;let f=!1,p=!1,m="drawer",h=0,b=0;const u=()=>a.getSelection()?.isCollapsed===!1,g=()=>{f=!1},y=()=>{f&&u()&&g()},w=S=>{if(S.touches.length!==1||u()){f=!1;return}const M=S.touches[0],I=i.clientWidth,E=M.clientX<=o,C=M.clientX>=I-o;p=E,m=E||C?wh(S.target,i,p):"drawer",f=(E||C)&&m!=="content",h=M.clientX,b=M.clientY},j=S=>{if(!f||(f=!1,u()))return;const M=S.changedTouches[0];if(!M)return;const I=M.clientX-h,E=M.clientY-b,C=m==="content-end"?yh:bh,N=m==="content-end"?vh:xh;Math.abs(I)<C||Math.abs(E)>Math.abs(I)*N||p&&I<=0||!p&&I>=0||(p?s.current.onLeftEdgeSwipe?.():s.current.onRightEdgeSwipe?.())};return i.addEventListener("touchstart",w,{passive:!0}),i.addEventListener("touchend",j,{passive:!0}),i.addEventListener("touchcancel",g,{passive:!0}),i.addEventListener("selectstart",g),a.addEventListener("selectionchange",y),()=>{i.removeEventListener("touchstart",w),i.removeEventListener("touchend",j),i.removeEventListener("touchcancel",g),i.removeEventListener("selectstart",g),a.removeEventListener("selectionchange",y)}},[r,n])},jh=()=>globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0;function yn(n){const e=fe.c(11),{open:s,children:r}=n,[i,l]=d.useState(s);s&&!i&&l(!0);const o=d.useRef(null),a=d.useRef(null),f=d.useRef(s);let p,m;e[0]!==s?(p=()=>{const j=o.current;if(f.current===s||!j)return;if(f.current=s,jh()){s||l(!1);return}const S=a.current||!s?j.getBoundingClientRect().height:0;a.current?.cancel();const M=s?j.scrollHeight:0;j.style.overflow="hidden";const I=j.animate([{height:`${S}px`,opacity:s?0:1},{height:`${M}px`,opacity:s?1:0}],{duration:Su,easing:ku,fill:s?"none":"forwards"});a.current=I,I.finished.then(()=>{a.current===I&&(a.current=null,s?j.style.overflow="":l(!1))},kh)},m=[s],e[0]=s,e[1]=p,e[2]=m):(p=e[1],m=e[2]),d.useLayoutEffect(p,m);let h,b;if(e[3]===Symbol.for("react.memo_cache_sentinel")?(h=()=>()=>a.current?.cancel(),b=[],e[3]=h,e[4]=b):(h=e[3],b=e[4]),d.useEffect(h,b),!i)return null;const u=!s||void 0,g=!s;let y;e[5]!==r?(y=r(),e[5]=r,e[6]=y):y=e[6];let w;return e[7]!==u||e[8]!==g||e[9]!==y?(w=t.jsx("div",{ref:o,"aria-hidden":u,inert:g,children:y}),e[7]=u,e[8]=g,e[9]=y,e[10]=w):w=e[10],w}function kh(){}const Sh=new Set,ri=[],Nh=[["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"],["z-a","sessions.sidebar.header.projectSort.zToA"],["date-added","sessions.sidebar.header.projectSort.dateAdded"],["recent","sessions.sidebar.header.projectSort.recent"]],Ch=[["projects","mobile.sessions.viewMode.projects"],["timeline","mobile.sessions.viewMode.timeline"]],Rh=[["project","sessions.sidebar.header.listGrouping.project"],["time","sessions.sidebar.header.listGrouping.time"]],vn="min-h-10 items-center justify-between",wn=7,Yo=40,Ih=3,Kl=32,Dn=n=>Kl+n*12,Nn=n=>Dn(n)+20,ii="openchamber:pinned",Qo="openchamber:work",oi="openchamber:time-list",ai=12,Eh=(n,e)=>{const s=Ze(n),r=Ze(e),i=r.endsWith("/")?r:`${r}/`;return!!(s&&r&&(s===r||s.startsWith(i)))},li=(n,e)=>nd(n.worktrees,e)??null,ci=(n,e,s)=>Va([n.title,n.id,Rt(n),e],s),Ah=n=>{const e=fe.c(3),{path:s,children:r}=n,i=Wa(s);let l;return e[0]!==r||e[1]!==i?(l=r(i),e[0]=r,e[1]=i,e[2]=l):l=e[2],l},Th=n=>{const e=fe.c(2),{ariaLabel:s}=n;let r;return e[0]!==s?(r=t.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-primary","aria-label":s}),e[0]=s,e[1]=r):r=e[1],r},Zo=n=>{const e=fe.c(12),{onClick:s,className:r}=n,{t:i}=xe();let l;e[0]!==i?(l=i("sessions.sidebar.project.actions.newWorktree"),e[0]=i,e[1]=l):l=e[1];const o=l;let a;e[2]!==r?(a=se("flex size-9 shrink-0 items-center justify-center rounded-full text-muted-foreground 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),e[2]=r,e[3]=a):a=e[3];let f;e[4]!==s?(f=b=>{b.stopPropagation(),s()},e[4]=s,e[5]=f):f=e[5];let p,m;e[6]===Symbol.for("react.memo_cache_sentinel")?(p={touchAction:"manipulation"},m=t.jsx(Y,{name:"node-tree",className:"size-3.5"}),e[6]=p,e[7]=m):(p=e[6],m=e[7]);let h;return e[8]!==o||e[9]!==a||e[10]!==f?(h=t.jsx("button",{type:"button",className:a,"aria-label":o,title:o,onClick:f,style:p,children:m}),e[8]=o,e[9]=a,e[10]=f,e[11]=h):h=e[11],h},ea=n=>{const e=fe.c(10),{label:s,onClick:r,className:i}=n;let l;e[0]!==i?(l=se("flex size-9 shrink-0 items-center justify-center rounded-full text-muted-foreground 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)]",i),e[0]=i,e[1]=l):l=e[1];let o;e[2]!==r?(o=m=>{m.stopPropagation(),r()},e[2]=r,e[3]=o):o=e[3];let a,f;e[4]===Symbol.for("react.memo_cache_sentinel")?(a={touchAction:"manipulation"},f=t.jsx(Y,{name:"add",className:"size-4"}),e[4]=a,e[5]=f):(a=e[4],f=e[5]);let p;return e[6]!==s||e[7]!==l||e[8]!==o?(p=t.jsx("button",{type:"button",className:l,"aria-label":s,title:s,onClick:o,style:a,children:f}),e[6]=s,e[7]=l,e[8]=o,e[9]=p):p=e[9],p},ta=n=>{const e=fe.c(106),{session:s,active:r,indent:i,contextLabel:l,statusOnRight:o,treeDepth:a,hasChildren:f,expanded:p,onToggleChildren:m,onSelect:h,revealed:b,onRevealedChange:u,confirmingDelete:g,onArchive:y,onRequestDelete:w,onConfirmDelete:j,renaming:S,onRequestRename:M,onSubmitRename:I,onCancelRename:E,work:C,pin:N,descendantIdsOf:v}=n,T=o===void 0?!1:o,O=f===void 0?!1:f,B=p===void 0?!1:p,z=b===void 0?!1:b,_=g===void 0?!1:g,A=S===void 0?!1:S,{t:R}=xe();let D;e[0]!==s?(D=Sr(zl(s)),e[0]=s,e[1]=D):D=e[1];const V=D;let L;e[2]!==s.title||e[3]!==R?(L=s.title?.trim()||R("mobile.sessions.untitled"),e[2]=s.title,e[3]=R,e[4]=L):L=e[4];const K=L,F=!!(u&&y),U=a!==void 0,Q=T||U;let le;e[5]!==i||e[6]!==U||e[7]!==a?(le=U?Nn(a):i,e[5]=i,e[6]=U,e[7]=a,e[8]=le):le=e[8];const ce=le,oe=Qa(s.id,s.directory,F&&(z||A)),re=Ai(s.id),ie=Ti(s.id),k=ie!==null,q=!k&&re>0&&!r,G=Pi(s.id,k),Z=(k||q)&&G;let me;e[9]!==k||e[10]!==s||e[11]!==C?.inWork?(me=!!C?.inWork&&!k&&rd(s),e[9]=k,e[10]=s,e[11]=C?.inWork,e[12]=me):me=e[12];const ue=me;let X;e[13]!==v||e[14]!==B||e[15]!==O||e[16]!==s.id?(X=v&&!(O&&B)?[s.id,...v(s.id)]:[s.id],e[13]=v,e[14]=B,e[15]=O,e[16]=s.id,e[17]=X):X=e[17];const we=Ll(X),Se=oe.pending||k||q;let be;e[18]!==oe.pending||e[19]!==R||e[20]!==ie?(be=oe.pending?t.jsx(Y,{name:"loader-4",className:"size-3 shrink-0 animate-spin text-primary","aria-label":R("sessions.aiRename.generating")}):t.jsx(ur,{state:ie??"unread"}),e[18]=oe.pending,e[19]=R,e[20]=ie,e[21]=be):be=e[21];const ye=be,Te=U&&Se&&!(O&&m);let Ee;e[22]!==ye||e[23]!==Te||e[24]!==a?(Ee=Te?t.jsx("span",{className:"pointer-events-none absolute z-10 flex w-3.5 items-center justify-center",style:{insetInlineStart:Dn(a??0),top:0,bottom:0},children:ye}):null,e[22]=ye,e[23]=Te,e[24]=a,e[25]=Ee):Ee=e[25];let De;e[26]!==B||e[27]!==O||e[28]!==U||e[29]!==m||e[30]!==R||e[31]!==a?(De=U&&O&&m?t.jsx("button",{type:"button",className:"absolute z-10 flex w-[30px] items-center justify-center text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:{insetInlineStart:Dn(a)-8,top:0,bottom:0,touchAction:"manipulation"},"aria-label":R(B?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),"aria-expanded":B,onClick:Fe=>{Fe.stopPropagation(),m()},children:t.jsx(bi,{expanded:B})}):null,e[26]=B,e[27]=O,e[28]=U,e[29]=m,e[30]=R,e[31]=a,e[32]=De):De=e[32];let je;e[33]!==oe.pending||e[34]!==B||e[35]!==O||e[36]!==i||e[37]!==k||e[38]!==m||e[39]!==q||e[40]!==Q||e[41]!==R||e[42]!==ie?(je=!Q&&(oe.pending||k||q||O&&m)?t.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-ring",style:{insetInlineStart:Math.max(i-32,2),top:0,bottom:0,touchAction:"manipulation"},"aria-label":oe.pending?R("sessions.aiRename.generating"):R(B?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),disabled:!O||!m,onClick:Fe=>{Fe.stopPropagation(),m?.()},children:oe.pending?t.jsx(Y,{name:"loader-4",className:"size-3 animate-spin text-primary","aria-label":R("sessions.aiRename.generating")}):k||q?t.jsx(ur,{state:ie??"unread"}):t.jsx(zi,{className:se("size-[18px] transition-transform duration-150",B?"rotate-0":"-rotate-90 rtl:rotate-90")})}):null,e[33]=oe.pending,e[34]=B,e[35]=O,e[36]=i,e[37]=k,e[38]=m,e[39]=q,e[40]=Q,e[41]=R,e[42]=ie,e[43]=je):je=e[43];let Ne;e[44]!==r||e[45]!==oe||e[46]!==l||e[47]!==Se||e[48]!==k||e[49]!==ye||e[50]!==E||e[51]!==u||e[52]!==h||e[53]!==I||e[54]!==we||e[55]!==N?.pinned||e[56]!==A||e[57]!==z||e[58]!==s||e[59]!==Z||e[60]!==ue||e[61]!==q||e[62]!==Te||e[63]!==Q||e[64]!==R||e[65]!==ce||e[66]!==V||e[67]!==K?(Ne=A&&I&&E?t.jsx(Ml,{initialTitle:K,indent:ce,aiRename:oe,onSubmit:I,onCancel:E}):t.jsx("button",{type:"button",className:se("flex min-w-0 flex-1 items-center gap-2.5 pe-3.5 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",l?"min-h-10 py-1":"h-9"),style:{paddingInlineStart:ce,touchAction:"manipulation"},onClick:()=>{if(z){u?.(!1);return}h()},children:t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[t.jsxs("span",{className:"flex items-center gap-2.5",children:[t.jsx("span",{dir:"auto",className:se("block min-w-0 flex-1 truncate oc-ui-start-align typography-ui-label",Fl({active:r,unread:q,running:k,pending:we})),children:K}),N?.pinned?t.jsx(Y,{name:"pushpin",className:"size-3 shrink-0 text-muted-foreground","aria-label":R("sessions.sidebar.session.status.pinned")}):null,Q&&Se&&!Te?ye:null,ue?t.jsx(Y,{name:"check",className:"size-3.5 shrink-0 text-muted-foreground","aria-label":R("sessions.sidebar.session.work.doneSuggested")}):null,t.jsx(Ni,{session:s}),t.jsx(Ci,{...we}),Z?t.jsx(Di,{sessionId:s.id,running:k,className:"typography-micro"}):V?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:V}):null]}),l?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:l}):null]})}),e[44]=r,e[45]=oe,e[46]=l,e[47]=Se,e[48]=k,e[49]=ye,e[50]=E,e[51]=u,e[52]=h,e[53]=I,e[54]=we,e[55]=N?.pinned,e[56]=A,e[57]=z,e[58]=s,e[59]=Z,e[60]=ue,e[61]=q,e[62]=Te,e[63]=Q,e[64]=R,e[65]=ce,e[66]=V,e[67]=K,e[68]=Ne):Ne=e[68];let H;e[69]!==Ee||e[70]!==De||e[71]!==je||e[72]!==Ne?(H=t.jsxs(t.Fragment,{children:[Ee,De,je,Ne]}),e[69]=Ee,e[70]=De,e[71]=je,e[72]=Ne,e[73]=H):H=e[73];const ee=H;if(!F){const Fe=r||void 0,jt=r&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let qe;e[74]!==jt?(qe=se("relative flex items-center gap-1 transition-colors",jt),e[74]=jt,e[75]=qe):qe=e[75];let it;e[76]!==ee||e[77]!==qe?(it=t.jsx("div",{className:qe,children:ee}),e[76]=ee,e[77]=qe,e[78]=it):it=e[78];let It;return e[79]!==Fe||e[80]!==it?(It=t.jsx("div",{"data-active-session":Fe,className:"relative overflow-hidden",children:it}),e[79]=Fe,e[80]=it,e[81]=It):It=e[81],It}const ve=_l+(C?Tn:0)+(N?Tn:0);let ge;e[82]!==u?(ge=Fe=>u?.(Fe),e[82]=u,e[83]=ge):ge=e[83];const Ce=r&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let Be;e[84]!==Ce?(Be=se("relative flex w-full items-center gap-1 bg-background transition-colors",Ce),e[84]=Ce,e[85]=Be):Be=e[85];let Le;e[86]!==_||e[87]!==y||e[88]!==j||e[89]!==w||e[90]!==M||e[91]!==u||e[92]!==N||e[93]!==z||e[94]!==s.id||e[95]!==K||e[96]!==C?(Le=t.jsx(Ol,{sessionId:s.id,title:K,revealed:z,confirmingDelete:_,onArchive:y,onRequestDelete:w,onConfirmDelete:j,onRequestRename:M,onRevealedChange:u,work:C,pin:N}),e[86]=_,e[87]=y,e[88]=j,e[89]=w,e[90]=M,e[91]=u,e[92]=N,e[93]=z,e[94]=s.id,e[95]=K,e[96]=C,e[97]=Le):Le=e[97];let et;return e[98]!==r||e[99]!==z||e[100]!==ee||e[101]!==ve||e[102]!==ge||e[103]!==Be||e[104]!==Le?(et=t.jsx(xr,{actionsWidth:ve,revealed:z,onRevealedChange:ge,dataActiveSession:r,contentClassName:Be,actions:Le,children:ee}),e[98]=r,e[99]=z,e[100]=ee,e[101]=ve,e[102]=ge,e[103]=Be,e[104]=Le,e[105]=et):et=e[105],et},sa=[],Ph=n=>{const e=fe.c(41),{run:s,laneNodes:r,depth:i}=n,{t:l}=xe();let o;e[0]!==s.key?(o=z=>z.runOverviewKey===s.key,e[0]=s.key,e[1]=o):o=e[1];const a=Ve(o);let f;e[2]!==r?(f={nodes:r,includeUnreadSubtasks:!1},e[2]=r,e[3]=f):f=e[3];const p=Ya(f);let m;e[4]!==s.lastActivity?(m=Sr(s.lastActivity),e[4]=s.lastActivity,e[5]=m):m=e[5];const h=m,b=a||void 0,u=a&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let g;e[6]!==u?(g=se("relative flex items-center overflow-hidden transition-colors",u),e[6]=u,e[7]=g):g=e[7];let y;e[8]!==i?(y=Nn(i),e[8]=i,e[9]=y):y=e[9];let w;e[10]!==y?(w={paddingInlineStart:y,touchAction:"manipulation"},e[10]=y,e[11]=w):w=e[11];let j;e[12]!==s.key?(j=()=>Ve.getState().setRunOverviewKey(s.key),e[12]=s.key,e[13]=j):j=e[13];let S;e[14]!==s.title||e[15]!==l?(S=l("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[14]=s.title,e[15]=l,e[16]=S):S=e[16];let M;e[17]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx(La,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[17]=M):M=e[17];const I=a?"text-primary":"text-muted-foreground";let E;e[18]!==I?(E=se("block min-w-0 flex-1 truncate oc-ui-start-align typography-ui-label",I),e[18]=I,e[19]=E):E=e[19];let C;e[20]!==s.title||e[21]!==E?(C=t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[M,t.jsx("span",{dir:"auto",className:E,children:s.title})]}),e[20]=s.title,e[21]=E,e[22]=C):C=e[22];let N;e[23]!==s.providerIDs?(N=t.jsx(Bl,{providerIDs:s.providerIDs}),e[23]=s.providerIDs,e[24]=N):N=e[24];let v;e[25]!==p?(v=p?t.jsx(Za,{state:p}):null,e[25]=p,e[26]=v):v=e[26];let T;e[27]!==h?(T=h?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:h}):null,e[27]=h,e[28]=T):T=e[28];let O;e[29]!==S||e[30]!==C||e[31]!==N||e[32]!==v||e[33]!==T||e[34]!==w||e[35]!==j?(O=t.jsxs("button",{type:"button",className:"flex h-9 w-full min-w-0 items-center gap-2.5 pe-3.5 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:w,onClick:j,"aria-label":S,children:[C,N,v,T]}),e[29]=S,e[30]=C,e[31]=N,e[32]=v,e[33]=T,e[34]=w,e[35]=j,e[36]=O):O=e[36];let B;return e[37]!==O||e[38]!==b||e[39]!==g?(B=t.jsx("div",{"data-active-session":b,className:g,children:O}),e[37]=O,e[38]=b,e[39]=g,e[40]=B):B=e[40],B},na=n=>{const e=fe.c(11),{indent:s,onClick:r}=n,{t:i}=xe();let l;e[0]!==s?(l={paddingInlineStart:s,touchAction:"manipulation"},e[0]=s,e[1]=l):l=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx(zi,{className:"size-4"}),e[2]=o):o=e[2];let a;e[3]!==i?(a=i("sessions.sidebar.group.showMore"),e[3]=i,e[4]=a):a=e[4];let f;e[5]!==a?(f=t.jsx("span",{className:"typography-micro",children:a}),e[5]=a,e[6]=f):f=e[6];let p;return e[7]!==r||e[8]!==l||e[9]!==f?(p=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pe-3 text-start text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:l,onClick:r,children:[o,f]}),e[7]=r,e[8]=l,e[9]=f,e[10]=p):p=e[10],p},ra=n=>{const e=fe.c(11),{indent:s,onClick:r}=n,{t:i}=xe();let l;e[0]!==s?(l={paddingInlineStart:s,touchAction:"manipulation"},e[0]=s,e[1]=l):l=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx(Tf,{className:"size-4"}),e[2]=o):o=e[2];let a;e[3]!==i?(a=i("sessions.sidebar.group.showFewer"),e[3]=i,e[4]=a):a=e[4];let f;e[5]!==a?(f=t.jsx("span",{className:"typography-micro",children:a}),e[5]=a,e[6]=f):f=e[6];let p;return e[7]!==r||e[8]!==l||e[9]!==f?(p=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pe-3 text-start text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:l,onClick:r,children:[o,f]}),e[7]=r,e[8]=l,e[9]=f,e[10]=p):p=e[10],p},Dh=n=>{const e=fe.c(29),{worktree:s}=n,{t:r}=xe();let i;e[0]!==s.path?(i=Ze(s.path),e[0]=s.path,e[1]=i):i=e[1];const l=i;let o;e[2]!==l?(o={id:l},e[2]=l,e[3]=o):o=e[3];const{attributes:a,listeners:f,setNodeRef:p,transform:m,transition:h,isDragging:b}=Gi(o),u=s.branch||s.label||s.path;let g;e[4]!==m?(g=qi.Transform.toString(m),e[4]=m,e[5]=g):g=e[5];const y=b?10:1;let w;e[6]!==g||e[7]!==y||e[8]!==h?(w={transform:g,transition:h,zIndex:y},e[6]=g,e[7]=y,e[8]=h,e[9]=w):w=e[9];const j=b&&"shadow-lg shadow-black/20";let S;e[10]!==j?(S=se("flex items-center gap-1 rounded-xl bg-background px-1 py-1",j),e[10]=j,e[11]=S):S=e[11];let M;e[12]!==u||e[13]!==r?(M=r("mobile.sessions.dragHandleAria",{label:u}),e[12]=u,e[13]=r,e[14]=M):M=e[14];let I;e[15]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(Oi,{className:"size-4"}),e[15]=I):I=e[15];let E;e[16]!==a||e[17]!==f||e[18]!==M?(E=t.jsx("button",{type:"button",className:"flex size-8 shrink-0 cursor-grab touch-none items-center justify-center rounded-lg text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":M,...a,...f,children:I}),e[16]=a,e[17]=f,e[18]=M,e[19]=E):E=e[19];let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx(Y,{name:"git-branch",className:"size-4 shrink-0 text-muted-foreground"}),e[20]=C):C=e[20];let N;e[21]!==u?(N=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-bold text-muted-foreground",children:u}),e[21]=u,e[22]=N):N=e[22];let v;return e[23]!==p||e[24]!==E||e[25]!==N||e[26]!==w||e[27]!==S?(v=t.jsxs("div",{ref:p,style:w,className:S,children:[E,C,N]}),e[23]=p,e[24]=E,e[25]=N,e[26]=w,e[27]=S,e[28]=v):v=e[28],v},Mh=n=>{const e=fe.c(58),{project:s,expanded:r,onToggleExpanded:i,onReorderWorktrees:l}=n,{t:o}=xe();let a;e[0]!==s.id?(a={id:s.id},e[0]=s.id,e[1]=a):a=e[1];const{attributes:f,listeners:p,setNodeRef:m,transform:h,transition:b,isDragging:u}=Gi(a);let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g={activationConstraint:{distance:8}},e[2]=g):g=e[2];let y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y={coordinateGetter:Ki},e[3]=y):y=e[3];const w=Bi(Js(Fi,g),Js(Li,y)),j=s.worktrees.length>0;let S;e[4]!==l||e[5]!==s.worktrees?(S=Q=>{const{active:le,over:ce}=Q;if(!ce||le.id===ce.id)return;const oe=s.worktrees.map(Bh),re=oe.indexOf(String(le.id)),ie=oe.indexOf(String(ce.id));if(re<0||ie<0)return;const k=[...oe],[q]=k.splice(re,1);k.splice(ie,0,q),l(k)},e[4]=l,e[5]=s.worktrees,e[6]=S):S=e[6];const M=S;let I;e[7]!==h?(I=qi.Transform.toString(h),e[7]=h,e[8]=I):I=e[8];const E=u?10:1;let C;e[9]!==I||e[10]!==E||e[11]!==b?(C={transform:I,transition:b,zIndex:E},e[9]=I,e[10]=E,e[11]=b,e[12]=C):C=e[12];const N=u&&"shadow-lg shadow-black/20";let v;e[13]!==N?(v=se("rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",N),e[13]=N,e[14]=v):v=e[14];let T;e[15]!==s.label||e[16]!==o?(T=o("mobile.sessions.dragHandleAria",{label:s.label}),e[15]=s.label,e[16]=o,e[17]=T):T=e[17];let O;e[18]===Symbol.for("react.memo_cache_sentinel")?(O=t.jsx(Oi,{className:"size-4"}),e[18]=O):O=e[18];let B;e[19]!==f||e[20]!==p||e[21]!==T?(B=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":T,...f,...p,children:O}),e[19]=f,e[20]=p,e[21]=T,e[22]=B):B=e[22];let z;e[23]!==r||e[24]!==s.label||e[25]!==o?(z=r?o("sessions.sidebar.group.collapseAria",{label:s.label}):o("sessions.sidebar.group.expandAria",{label:s.label}),e[23]=r,e[24]=s.label,e[25]=o,e[26]=z):z=e[26];const _=!j;let A;e[27]===Symbol.for("react.memo_cache_sentinel")?(A={touchAction:"manipulation"},e[27]=A):A=e[27];let R;e[28]!==s?(R=t.jsx(An,{project:s}),e[28]=s,e[29]=R):R=e[29];let D;e[30]!==s.label?(D=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:s.label}),e[30]=s.label,e[31]=D):D=e[31];let V;e[32]!==r||e[33]!==j?(V=j?t.jsx(zi,{className:se("size-4 shrink-0 text-muted-foreground transition-transform",r&&"rotate-180")}):null,e[32]=r,e[33]=j,e[34]=V):V=e[34];let L;e[35]!==r||e[36]!==i||e[37]!==z||e[38]!==_||e[39]!==R||e[40]!==D||e[41]!==V?(L=t.jsxs("button",{type:"button",className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 rounded-xl px-1 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:i,"aria-expanded":r,"aria-label":z,disabled:_,style:A,children:[R,D,V]}),e[35]=r,e[36]=i,e[37]=z,e[38]=_,e[39]=R,e[40]=D,e[41]=V,e[42]=L):L=e[42];let K;e[43]!==B||e[44]!==L?(K=t.jsxs("div",{className:"flex items-center gap-1",children:[B,L]}),e[43]=B,e[44]=L,e[45]=K):K=e[45];let F;e[46]!==r||e[47]!==M||e[48]!==j||e[49]!==s.worktrees||e[50]!==w?(F=r&&j?t.jsx($i,{sensors:w,collisionDetection:Wi,onDragEnd:M,children:t.jsx(Vi,{items:s.worktrees.map(Lh),strategy:Ui,children:t.jsx("div",{className:"mt-1 flex flex-col gap-0.5 ps-3",children:s.worktrees.map(Fh)})})}):null,e[46]=r,e[47]=M,e[48]=j,e[49]=s.worktrees,e[50]=w,e[51]=F):F=e[51];let U;return e[52]!==m||e[53]!==K||e[54]!==F||e[55]!==C||e[56]!==v?(U=t.jsxs("div",{ref:m,style:C,className:v,children:[K,F]}),e[52]=m,e[53]=K,e[54]=F,e[55]=C,e[56]=v,e[57]=U):U=e[57],U},ia=({open:n,onOpenChange:e,variant:s="drawer",footer:r})=>{const{t:i}=xe(),{git:l}=vr(),o=gt(c=>c.ensureStatus),a=Da(),f=vs(c=>c.activeSessions),p=vs(c=>c.hasLoaded),m=n||s==="sidebar",h=d.useRef(Sh),b=ka(d.useCallback(c=>(m&&(h.current=c.ids),h.current),[m])),u=d.useRef(Gc),g=Sa(d.useCallback(c=>(m&&(u.current=c.rankById),u.current),[m])),y=ut(c=>c.projects),w=Kc(c=>c.projects),j=ut(c=>c.activeProjectId),S=ws(c=>c.currentDirectory),M=$e(c=>c.currentSessionId),I=$e(c=>c.setCurrentSession),E=$e(c=>c.archiveSession),C=$e(c=>c.archiveSessions),N=$e(c=>c.deleteSession),v=$e(c=>c.deleteSessions),T=$e(c=>c.updateSessionTitle),O=$e(c=>c.openNewSessionDraft),B=ut(c=>c.setActiveProject),z=ut(c=>c.setActiveProjectIdOnly),_=ut(c=>c.reorderProjects),A=ut(c=>c.manualProjectOrder),R=Ct(c=>c.projectSortOrder),D=Ct(c=>c.setProjectSortOrder),V=Ct(c=>c.sidebarViewMode),L=V==="timeline"?"manual":R,K=Ct(c=>c.setSidebarViewMode),F=Ct(c=>c.listSessionGrouping),U=Ct(c=>c.setListSessionGrouping),Q=Ct(c=>c.showWorkSection),le=Ct(c=>c.setShowWorkSection),ce=Ct(c=>c.showPinnedSection),oe=Ct(c=>c.setShowPinnedSection),re=Ct(c=>c.detailedZoneRows),ie=Ct(c=>c.setDetailedZoneRows),k=qc(m),q=ut(c=>c.removeProject),G=rr(c=>c.projectExpanded),Z=rr(c=>c.worktreeExpanded),me=rr(c=>c.setProjectExpanded),ue=rr(c=>c.setWorktreeExpanded),X=Si(c=>c.orderByProject),de=Si(c=>c.setWorktreeOrder),we=Ho(c=>c.expandedParents),Se=Ho(c=>c.toggleParent),[be,ye]=d.useState(""),[Te,Ee]=d.useState(null),[De,je]=d.useState(null),[Ne,H]=d.useState(null),[ee,ve]=d.useState(null),[ge,Ce]=d.useState(null),[Be,Le]=d.useState(null),[et,Fe]=d.useState(null),[jt,qe]=d.useState(0),[it,It]=d.useState(!1),[Nr,On]=d.useState(!1),[Ss,ft]=d.useState(null),[Et,Ns]=d.useState(()=>new Map($e.getState().availableWorktreesByProject)),[is,Cr]=d.useState(()=>{const c=new Set;for(const[P,W]of $e.getState().availableWorktreesByProject)W.length>0&&c.add(P);return c}),[mt,Kt]=d.useState(!1),[Rr,Cs]=d.useState(new Set),[sn,kt]=d.useState(new Map),He=d.useRef(null);d.useEffect(()=>{if(!n){ye(""),Kt(!1),Cs(new Set),kt(new Map),Ee(null),je(null),H(null),ve(null),Ce(null),Le(null);return}Ta(a).then(()=>Hc())},[n]),d.useEffect(()=>{mt||Cs(new Set)},[mt]),d.useEffect(()=>{kt(new Map)},[F,V]),d.useEffect(()=>{if(!n||y.length===0)return;let c=!1;return(async()=>{const W=await Promise.all(y.map(async J=>{const te=Ze(J.path);if(!te)return null;const he=await l.checkIsGitRepository(te).catch(()=>null),Ae=he?await Ua({id:J.id,path:te}).catch(()=>null):[];return[te,Ae,he]}));c||(Ns(J=>{const te=new Map;for(const he of W){if(!he)continue;const[Ae,Qe,lt]=he,ps=lt===null||Qe===null;te.set(Ae,ps?J.get(Ae)??[]:Qe)}return Ga(y,te)}),Cr(J=>{const te=new Set;for(const he of W){if(!he)continue;const[Ae,,Qe]=he;(Qe===null?J.has(Ae):Qe)&&te.add(Ae)}return te}))})(),()=>{c=!0}},[l,n,y,jt]);const Me=d.useMemo(()=>Xc(y.map(c=>({id:c.id,label:c.label?.trim()||ti(c.path),path:Ze(c.path),icon:c.icon,color:c.color,iconImage:c.iconImage,iconBackground:c.iconBackground,isGitRepo:is.has(Ze(c.path)),worktrees:Vp(X[c.id],Et.get(Ze(c.path))??[]),addedAt:c.addedAt,lastOpenedAt:c.lastOpenedAt})),L,A),[is,A,L,y,X,Et]),tt=d.useMemo(()=>{const c=[...f],P=new Set(c.map(W=>W.id));for(const W of a)P.has(W.id)||(P.add(W.id),c.push(W));return c.filter(W=>!W.time?.archived)},[f,a]),Xe=d.useMemo(()=>{const c=new Map;for(const P of tt){const W=ht(P);if(!W)continue;const J=c.get(W)??[];J.push(P),c.set(W,J)}return c},[tt]),Lt=d.useCallback(c=>er(Xe,c),[Xe]),{projectSessions:Oe,chatSessions:Rs}=d.useMemo(()=>Jc(tt,!1),[tt]),Je=Ve(c=>c.sessionWorkEnabled),Ft=d.useMemo(()=>{const c=new Set;if(!Je||!Q)return c;for(const P of tt)if(!(ht(P)||Qn(Rt(P))||!Fa(P))){c.add(P.id);for(const W of er(Xe,P.id))c.add(W)}return c},[Xe,Je,tt,Q]),qt=d.useMemo(()=>{const c=new Set;if(!ce)return c;for(const P of tt){const W=Rt(P);if(!(ht(P)||Qn(W)||!qr(b,W||null,P.id))){c.add(P.id);for(const J of er(Xe,P.id))c.add(J)}}return c},[Xe,b,tt,ce]),os=d.useMemo(()=>Ft.size>0?Rs.filter(c=>!Ft.has(c.id)):Rs,[Rs,Ft]),At=dc(),Is=d.useMemo(()=>new Map(At.map(c=>[c.id,c])),[At]),zn=d.useMemo(()=>new Map(At.map(c=>[c.id,c.name||i("sessions.sidebar.grouping.spaceUnnamed")])),[At,i]),Ye=d.useMemo(()=>Yc(Oe,Me.map(c=>({id:c.id,normalizedPath:c.path})),new Map(Me.map(c=>[c.path,c.worktrees])),!1,[],w,At),[w,Oe,Me,At]),We=d.useMemo(()=>Qc(Oe,c=>{const P=Ye.bySessionId.get(c.id);return(P?Me.find(J=>J.id===P.projectId):void 0)?.path||Ze(Rt(c))||null}),[Oe,Me,Ye]),St=d.useMemo(()=>{const c=new Map(tt.map(J=>[J.id,J])),P=J=>({session:J,children:(Xe.get(J.id)??[]).map(P),worktree:null}),W=new Map;for(const J of We.runs.values())W.set(J.key,J.memberIds.flatMap(te=>{const he=c.get(te);return he?[P(he)]:[]}));return W},[Xe,We,tt]),xt=d.useMemo(()=>({key:pn,label:"",path:"",worktree:null,space:null,sessions:gs(os,b,g)}),[b,os,g]),nn=d.useMemo(()=>new Set(xt.sessions.filter(c=>qr(b,Rt(c)||null,c.id)).map(c=>c.id)),[xt,b]),Ht=d.useMemo(()=>({key:ii,label:"",path:"",worktree:null,space:null,sessions:qt.size>0?gs(tt.filter(c=>qt.has(c.id)),b,g):[]}),[b,qt,g,tt]),Tt=d.useMemo(()=>({key:Qo,label:"",path:"",worktree:null,space:null,sessions:Ft.size>0?gs(tt.filter(c=>Ft.has(c.id)&&!qt.has(c.id)),b,g):[]}),[b,qt,g,tt,Ft]),Bn=`${pn}::${pn}`,Ir=d.useMemo(()=>os.filter(c=>!ht(c)).length,[os]),Ge=be.trim().toLowerCase(),Ln=Hr(c=>c.foldersMap),Es=Hr(c=>c.collapsedFolderIds),Er=Hr(c=>c.toggleFolderCollapse),rn=c=>Ge?ri:Ln[c.path]??ri,Fn=d.useRef(null);d.useEffect(()=>{if(!n)return;const c=window.requestAnimationFrame(()=>{const P=Fn.current;if(!P)return;(P.querySelector('[data-active-session="true"]')??P.querySelector('[data-active-project="true"]'))?.scrollIntoView({block:"center"})});return()=>window.cancelAnimationFrame(c)},[n]);const $t=d.useMemo(()=>{const c=Zc(Me,L,W=>W.id,Ye.sessionsByProject).map(W=>({project:W,buckets:[],isActive:W.id===j})),P=(W,J,te,he=null)=>{const Ae=Ze(J)||W.project.path,Qe=Ae||"__root__";let lt=W.buckets.find(ps=>ps.key===Qe);return lt||(lt={key:Qe,label:(he?he.name||i("sessions.sidebar.grouping.spaceUnnamed"):null)||te?.branch||ti(Ae),path:Ae,worktree:te,space:he,sessions:[]},W.buckets.push(lt)),lt};for(const W of c){P(W,W.project.path,null);for(const J of W.project.worktrees)P(W,J.path,J);for(const J of At)J.directory&&Ze(J.projectDirectory)===Ze(W.project.path)&&P(W,J.directory,null,J)}for(const W of Oe){const J=Ye.bySessionId.get(W.id);if(!J)continue;const te=c.find(lt=>lt.project.id===J.projectId);if(!te)continue;const he=li(te.project,J.scopeDirectory),Ae=J.kind==="space"&&J.spaceId?Is.get(J.spaceId)??null:null;(Ae?P(te,J.scopeDirectory,null,Ae):he&&!We.runKeyBySessionId.has(W.id)?P(te,he.path,he):P(te,te.project.path,null)).sessions.push(W)}for(const W of c)for(const J of W.buckets)J.sessions=gs(J.sessions,b,g);return c},[j,b,L,Me,We,Oe,g,Ye,At,Is,i]),$n=Ze(S),as=c=>c.isActive?$n===c.project.path?c.project.path:c.project.worktrees.find(W=>Eh($n,W.path))?.path??c.project.path:null,Xt=c=>G[c.project.id]??!0,ls=(c,P)=>P.sessions.length===0||(Z[`${c.project.id}::${P.key}`]??!0);d.useEffect(()=>{if(!(!m||!p))for(const c of $t)for(const P of c.buckets){const W=`${c.project.id}::${P.key}`;P.sessions.length===0&&Z[W]===!1&&ue(W,!0)}},[p,m,$t,ue,Z]);const _e=c=>{kt(P=>{if(!P.has(c))return P;const W=new Map(P);return W.delete(c),W})},As=c=>{kt(P=>{let W=!1;const J=new Map(P),te=`${c}::`;for(const he of J.keys())he.startsWith(te)&&(J.delete(he),W=!0);return W?J:P})},Ts=(c,P,W)=>{kt(J=>{const te=new Map(J);return te.set(c,P+W),te})},_t=(c,P,W,J)=>{const te=J?.pageSize??wn,he=W===null?ai:Nn(W),Ae=J?.alwaysVisibleIds,Qe=J?.folders??ri,lt=new Set(P.sessions.map(ne=>ne.id)),ps=new Map;for(const ne of P.sessions){const ke=ht(ne);if(ke&<.has(ke)){const Ke=ps.get(ke)??[];Ke.push(ne),ps.set(ke,Ke)}}const oo=P.sessions.filter(ne=>{const ke=ht(ne);return!ke||!lt.has(ke)}),Lr=new Map;for(const ne of Qe)for(const ke of ne.sessionIds)Lr.has(ke)||Lr.set(ke,ne.id);const Fr=new Map,Jl=Qe.length===0?oo:oo.filter(ne=>{const ke=Lr.get(ne.id);return ke?(Fr.set(ke,[...Fr.get(ke)??[],ne]),!1):!0}),ao=new Set,$r=Jl.flatMap(ne=>{const ke=We.runKeyBySessionId.get(ne.id),Ke=ke?We.runs.get(ke):void 0;return Ke?ao.has(Ke.key)?[]:(ao.add(Ke.key),[{kind:"run",run:Ke}]):[{kind:"session",session:ne}]}),lo=ne=>ne.kind==="session"&&!!Ae?.has(ne.session.id),Yl=Ae?$r.filter(lo):[],Wr=Ae?$r.filter(ne=>!lo(ne)):$r,Ql=sn.get(c)??te,Vr=Wr.slice(0,Ql),co=[...Yl,...Vr],uo=Wr.length-Vr.length,Zl=Wr.length>te&&uo===0,fo=(ne,ke,Ke)=>{if(ne===null||ne<1)return[];const yt=[];for(let ct=1;ct<ne;ct+=1)ke[ct]&&yt.push({level:ct,end:!1});return yt.push({level:ne,end:Ke}),yt},mo=(ne,ke)=>ne.length>0?t.jsxs("div",{className:"relative flow-root",children:[ke,t.jsx(Eu,{guides:ne,slotStartPx:Kl})]}):ke,Ur=(ne,ke,Ke,yt)=>{const ct=ps.get(ne.id)??[],Wt=ct.length>0,Jn=ke!==null&&!!we[ne.id],Yn=[...Ke];return ke!==null&&(Yn[ke]=!yt),t.jsxs(d.Fragment,{children:[mo(fo(ke,Ke,yt),t.jsx(ta,{session:ne,active:M===ne.id,indent:ai,treeDepth:ke??void 0,statusOnRight:ke===null,hasChildren:Wt,expanded:Jn,onToggleChildren:Wt?()=>Se(ne.id):void 0,onSelect:()=>on(ne),revealed:De===ne.id,onRevealedChange:mn=>Wn(ne.id,mn),confirmingDelete:Ne===ne.id,onArchive:()=>{pt(ne)},onRequestDelete:()=>H(ne.id),onConfirmDelete:()=>{ds(ne)},renaming:ee===ne.id,onRequestRename:()=>Ms(ne.id),onSubmitRename:mn=>{Kn(ne.id,mn)},onCancelRename:()=>ve(null),work:Un(ne),pin:Ds(ne),descendantIdsOf:Lt})),Wt&&Jn&&ke!==null?ct.map((mn,tc)=>Ur(mn,ke+1,Yn,tc===ct.length-1)):null]},ne.id)},po=new Set(Qe.map(ne=>ne.id)),Gr=new Map;for(const ne of Qe)!ne.parentId||!po.has(ne.parentId)||Gr.set(ne.parentId,[...Gr.get(ne.parentId)??[],ne]);const Kr=[],ho=(ne,ke)=>{if(Kr.some(yt=>yt.folder.id===ne.id))return;const Ke=ke?`${ke} / ${ne.name}`:ne.name;Kr.push({folder:ne,displayName:Ke});for(const yt of Gr.get(ne.id)??[])ho(yt,Ke)};for(const ne of Qe)(!ne.parentId||!po.has(ne.parentId))&&ho(ne,"");const ec=({folder:ne,displayName:ke})=>{const Ke=Fr.get(ne.id)??[],yt=W??0,ct=Ke.length===0,Wt=ct||!Es.has(ne.id);return t.jsxs(d.Fragment,{children:[t.jsxs("button",{type:"button",className:"flex min-h-10 w-full items-center gap-0.5 py-1 pe-3 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ge){Ot(ge,!1);return}ct||Er(ne.id)},"aria-expanded":ct?void 0:Wt,"aria-label":ct?ke:Wt?i("sessions.sidebar.folderItem.collapseAria",{folderName:ke}):i("sessions.sidebar.folderItem.expandAria",{folderName:ke}),style:{paddingInlineStart:Dn(yt),touchAction:"manipulation"},children:[ct?t.jsx("span",{"aria-hidden":!0,className:"size-3.5 shrink-0"}):t.jsx(bi,{expanded:Wt}),t.jsx(Y,{name:Wt&&!ct?"folder-open":"folder",className:"mx-px size-3 shrink-0 text-muted-foreground"}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground/85",children:ke})]}),Wt?Ke.map((Jn,Yn)=>Ur(Jn,yt+1,[],Yn===Ke.length-1)):null]},`folder:${ne.id}`)};return t.jsxs("div",{children:[Kr.map(ec),co.map((ne,ke)=>{const Ke=ke===co.length-1;return ne.kind==="run"?t.jsx(d.Fragment,{children:mo(fo(W,[],Ke),t.jsx(Ph,{run:ne.run,laneNodes:St.get(ne.run.key)??sa,depth:W??0}))},`run:${ne.run.key}`):Ur(ne.session,W,[],Ke)}),uo>0?t.jsx(na,{indent:he,onClick:()=>Ts(c,Vr.length,wn)}):null,Zl?t.jsx(ra,{indent:he,onClick:()=>_e(c)}):null]})},ot=(c,P)=>{me(c,!P),As(c)},Ar=(c,P,W)=>{ue(`${c}::${P}`,!W),_e(`${c}::${P}`)},on=c=>{const P=Rt(c)||null,W=Ye.bySessionId.get(c.id),J=W?Me.find(te=>te.id===W.projectId)??null:null;if(J){z(J.id),me(J.id,!0);const te=li(J,W?.scopeDirectory??"");te&&ue(`${J.id}::${Ze(te.path)}`,!0)}I(c.id,P),e(!1)},Wn=(c,P)=>{je(P?c:null),H(null),Ce(null),Le(null)},Ot=(c,P)=>{Ce(P?c:null),Le(null),je(null),H(null)},Vn=(c,P)=>(je(null),H(null),Tu(c,P,Pu(P.id,er(Xe,P.id),c==="delete"),{archiveSession:E,archiveSessions:C,deleteSession:N,deleteSessions:v},i)),pt=c=>Vn("archive",c),Ps=async(c,P)=>{try{await id(c.id,Rt(c)||null,P?"done":"open")}catch{pe.error(i("sessions.sidebar.session.work.updateFailed"))}},Un=c=>{if(!Je||ht(c)||Qn(Rt(c)))return;const P=Ft.has(c.id);return{inWork:P,onToggle:()=>{Ps(c,P)}}},cs=c=>qr(b,Rt(c)||null,c.id),Gn=c=>{const P=Rt(c);if(!P)return;const W=cs(c)?"sessions.sidebar.session.pin.unpinFailed":"sessions.sidebar.session.pin.pinFailed";Au({directory:P,sessionId:c.id}).catch(()=>pe.error(i(W)))},Ds=c=>{if(!(ht(c)||!Rt(c)))return{pinned:cs(c),onToggle:()=>Gn(c)}},ds=c=>Vn("delete",c),Ms=c=>{je(null),H(null),ve(c)},Kn=async(c,P)=>{ve(null);try{await T(c,P)}catch{pe.error(i("mobile.sessions.renameError"))}},at=()=>{O(),e(!1)},us=c=>{ft(c),z(c),On(!0)},Pt=Bi(Js(Fi,{activationConstraint:{distance:8}}),Js(Li,{coordinateGetter:Ki})),an=c=>{D(c),Fs({sidebarProjectSortOrder:c}),c!=="manual"&&Kt(!1)},Tr=c=>{K(c),Fs({sidebarViewMode:c}),c==="timeline"&&Kt(!1)},Pr=c=>{U(c),Fs({sidebarListSessionGrouping:c}),c==="time"&&Kt(!1)},Dr=()=>{const c=!Q;le(c),Fs({sidebarShowWorkSection:c})},rt=()=>{const c=!ce;oe(c),Fs({sidebarShowPinnedSection:c})},Mr=()=>{const c=!re;ie(c),Fs({sidebarDetailedZoneRows:c})},Jt=(c,P,W,J)=>t.jsxs(hn,{onClick:J,className:vn,children:[t.jsx("span",{children:i(P)}),W?t.jsx(Y,{name:"check",className:"size-4 text-primary"}):null]},c),_s=c=>{const{active:P,over:W}=c;if(!W||P.id===W.id)return;const J=Me.findIndex(he=>he.id===P.id),te=Me.findIndex(he=>he.id===W.id);J<0||te<0||_(J,te)},_r=c=>{Cs(P=>{const W=new Set(P);return W.has(c)?W.delete(c):W.add(c),W})},Or=d.useCallback(c=>{const P=Rt(c);if(Qn(P))return i("mobile.sessions.section.chats");const W=Ye.bySessionId.get(c.id),J=W?Me.find(Ae=>Ae.id===W.projectId)??null:null;if(!J)return ti(P)||P;const te=W?.kind==="space"&&W.spaceId?Is.get(W.spaceId):void 0;if(te)return`${J.label} · ${te.name||i("sessions.sidebar.grouping.spaceUnnamed")}`;const he=li(J,W?.scopeDirectory??"");return he?.branch?`${J.label} · ${he.branch}`:J.label},[Me,Ye,Is,i]),Os=c=>{B(c.id),e(!1)},zt=c=>{z(c.id),O({selectedProjectId:c.id,directoryOverride:c.path}),e(!1)},fs=d.useMemo(()=>Ge?$t.filter(c=>Va([c.project.label,c.project.path],Ge)?!0:c.buckets.some(P=>P.sessions.some(W=>ci(W,c.project.label,Ge)))):$t,[Ge,$t]),Yt=d.useMemo(()=>Ge?gs(tt.filter(c=>{if(ht(c))return!1;const P=Ye.bySessionId.get(c.id),W=P?Me.find(J=>J.id===P.projectId)??null:null;return ci(c,W?.label??"",Ge)}),b,g):[],[Ge,b,Me,g,Ye,tt]),Qt=d.useMemo(()=>Ge?ed(Me,Ge,c=>[c.label,c.path]):[],[Ge,Me]),Zt=V==="timeline"&&!Ge&&!mt,es=Zt&&F==="time",ms=!Ge&&!mt,qn=V!=="timeline"&&!re,ln=Zt||ms&&(Tt.sessions.length>0||Ht.sessions.length>0),ts=ln;d.useEffect(()=>{if(!(!ts||!l))for(const c of Me){const P=Ze(c.path);P&&td(()=>o(P,l))}},[o,l,ts,Me]);const ss=d.useMemo(()=>{const c=new Map;if(!ln)return c;const P=Nu({sessions:Oe,projects:Me.map(W=>({id:W.id,normalizedPath:W.path,label:W.label})),ownerBySessionId:Ye.bySessionId,availableWorktreesByProject:new Map(Me.map(W=>[W.path,W.worktrees])),gitBranches:k,homeDirectory:null,hideBranchMatchingProjectLabel:!1,spaceLabelById:zn});for(const W of Oe){if(ht(W))continue;const J=P.get(W.id),te=J?Me.find(he=>he.id===J.projectId):null;!te||!J||c.set(W.id,{project:te,branch:J.branchLabel,inSpace:J.inSpace})}return c},[k,ln,Oe,Me,Ye,zn]),Dt=d.useCallback(c=>{const P=new Set;return c.flatMap(W=>{const J=ss.get(W.id);if(!J)return[];const te=We.runKeyBySessionId.get(W.id),he=te?We.runs.get(te):void 0;return he?P.has(he.key)?[]:(P.add(he.key),[{kind:"run",run:he,laneNodes:St.get(he.key)??sa,project:J.project}]):[{kind:"session",session:W,project:J.project,branch:J.branch,inSpace:J.inSpace}]})},[We,St,ss]),zr=d.useMemo(()=>{const c=new Map;if(!Zt||es)return c;const P=gs(Oe.filter(W=>!ht(W)&&ss.has(W.id)),b,g);for(const W of Dt(P)){const J=c.get(W.project.id);J?J.push(W):c.set(W.project.id,[W])}return c},[b,Oe,g,es,Zt,ss,Dt]),Bs=d.useMemo(()=>{if(!es)return[];const c=new Set([...Ht.sessions,...Tt.sessions].map(P=>P.id));return Dt(gs(Oe.filter(P=>!ht(P)&&!c.has(P.id)&&ss.has(P.id)),b,g))},[Ht,b,Oe,g,es,ss,Dt,Tt]),Hn=d.useMemo(()=>ms?Dt(Tt.sessions.filter(c=>!ht(c))):[],[ms,Dt,Tt]),cn=d.useMemo(()=>ms?Dt(Ht.sessions.filter(c=>!ht(c))):[],[ms,Dt,Ht]),Ls=(c,P,W,J)=>{const te=ls(c,P),he=P.sessions.length===0,Ae=J===P.path;return t.jsxs(t.Fragment,{children:[t.jsx(xr,{actionsWidth:P.space?96:48,revealed:ge===`wt:${P.key}`,onRevealedChange:Qe=>Ot(`wt:${P.key}`,Qe),actions:P.space?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:ge===`wt:${P.key}`?0:-1,className:"flex flex-1 items-center justify-center text-foreground transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":i("spaces.group.access.giveAria",{label:P.label}),onClick:()=>{Ce(null),P.space&&bo.getState().openAccessDialog(P.space.id)},style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"key",className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:ge===`wt:${P.key}`?0:-1,className:"flex flex-1 items-center justify-center text-foreground transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":i("spaces.actions.menuAria",{label:P.label}),onClick:()=>{Ce(null),P.space&&bo.getState().openActionsSheet(P.space.id)},style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"more-2",className:"size-[18px]"})})]}):P.worktree&&!W?t.jsx("button",{type:"button",tabIndex:ge===`wt:${P.key}`?0:-1,className:"flex flex-1 items-center justify-center text-[var(--status-error)] transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive","aria-label":i("mobile.projectEdit.deleteWorktreeAria",{label:P.label}),onClick:()=>{Ce(null),P.worktree&&Fe({project:c.project,worktree:P.worktree})},style:{touchAction:"manipulation"},children:t.jsx(fr,{className:"size-[18px]"})}):null,children:t.jsxs("button",{type:"button",className:"flex min-h-10 w-full items-center gap-0.5 py-1 pe-3 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ge){Ot(ge,!1);return}he||Ar(c.project.id,P.key,te)},"aria-expanded":he?void 0:te,"aria-label":he?P.label:te?i("sessions.sidebar.group.collapseAria",{label:P.label}):i("sessions.sidebar.group.expandAria",{label:P.label}),style:{paddingInlineStart:Dn(0),touchAction:"manipulation"},children:[he?t.jsx("span",{"aria-hidden":!0,className:"size-3.5 shrink-0"}):t.jsx(bi,{expanded:te}),W?t.jsx("span",{className:"inline-flex size-3.5 shrink-0 items-center justify-center text-muted-foreground",role:"status","aria-label":i("sessions.sidebar.group.worktreeRemoving"),children:t.jsx(Y,{name:"loader-4",className:"size-3.5 animate-spin"})}):t.jsx(Y,{name:P.space?"box-3":"git-branch",className:se("mx-px size-3 shrink-0",Ae?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground/85",children:P.label}),Ae?t.jsx(Th,{ariaLabel:i("mobile.sessions.activeWorktreeAria")}):null]})}),P.space?t.jsx("div",{className:"pb-1 pe-3",style:{paddingInlineStart:Nn(1)},children:t.jsx(Iu,{spaceId:P.space.id})}):null]})},dn=(c,P,W)=>{const J=sn.get(c)??wn,te=P.slice(0,J),he=P.length-te.length;return t.jsxs(t.Fragment,{children:[t.jsx(si,{entries:te,showProject:W,handlers:x}),he>0?t.jsx(na,{indent:Pn,onClick:()=>Ts(c,te.length,wn)}):P.length>wn?t.jsx(ra,{indent:Pn,onClick:()=>_e(c)}):null]})},Xn=(c,P,W,J,te)=>{if(te.length===0)return null;const he=G[c]??!0;return t.jsxs("section",{children:[t.jsxs("button",{type:"button",className:"flex min-h-12 w-full min-w-0 items-center gap-2 px-3 py-1.5 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ge){Ot(ge,!1);return}ot(c,he)},"aria-expanded":he,"aria-label":he?i("sessions.sidebar.group.collapseAria",{label:W}):i("sessions.sidebar.group.expandAria",{label:W}),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(Y,{name:P,className:"size-5"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-header font-semibold text-foreground",children:W}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:te.length})]}),t.jsx(yn,{open:he,children:()=>t.jsx("div",{className:"pb-2",children:qn?_t(c,J,0,{pageSize:Number.MAX_SAFE_INTEGER}):t.jsx(si,{entries:te,showProject:!0,projectLine:es,compact:!1,pinMarker:c!==ii,handlers:x})})})]})},Br=()=>{if(Bs.length===0)return null;const c=G[oi]??!0,P=i("sessions.sidebar.activity.projectsTitle"),W=`${oi}::rows`,J=sn.get(W)??Yo,te=Bs.slice(0,J);return t.jsxs("section",{children:[t.jsxs("button",{type:"button",className:"flex min-h-12 w-full min-w-0 items-center gap-2 px-3 py-1.5 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ge){Ot(ge,!1);return}ot(oi,c)},"aria-expanded":c,"aria-label":c?i("sessions.sidebar.group.collapseAria",{label:P}):i("sessions.sidebar.group.expandAria",{label:P}),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(Y,{name:"history",className:"size-5"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-header font-semibold text-foreground",children:P}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:Bs.length})]}),t.jsx(yn,{open:c,children:()=>t.jsxs("div",{className:"pb-2",children:[t.jsx(si,{entries:te,showProject:!0,projectLine:!0,handlers:x}),te.length<Bs.length?t.jsx(Qp,{scrollRootRef:He,visibleCount:te.length,onReachEnd:()=>Ts(W,te.length,Yo)}):null]})})]})},x={currentSessionId:M,revealedSessionId:De,confirmingDeleteSessionId:Ne,renamingSessionId:ee,onSelect:on,onRevealedChange:Wn,onArchive:c=>{pt(c)},onRequestDelete:H,onConfirmDelete:c=>{ds(c)},onRequestRename:Ms,onSubmitRename:(c,P)=>{Kn(c,P)},onCancelRename:()=>ve(null),onToggleWork:Je?(c,P)=>{Ps(c,P)}:void 0,isPinned:cs,onTogglePin:Gn,descendantIdsOf:Lt},$=Ge&&Yt.length===0&&Qt.length===0,ae=!Ge&&Me.length>1&&L==="manual"&&!(V==="timeline"&&F==="time"),Re=!mt&&!Ge&&Me.length>0?t.jsxs(pi,{children:[t.jsx(hi,{asChild:!0,children:t.jsx(Ie,{type:"button",variant:"chip",size:"sm","aria-label":i("sessions.sidebar.header.displayMode.label"),title:i("sessions.sidebar.header.displayMode.label"),style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"equalizer-2",className:"size-4"})})}),t.jsxs(gi,{align:"end",className:"w-64",children:[t.jsx(Xr,{children:i("mobile.sessions.viewMode.label")}),Ch.map(([c,P])=>Jt(c,P,V===c,()=>Tr(c))),V==="timeline"?t.jsxs(t.Fragment,{children:[t.jsx(tr,{}),t.jsx(Xr,{children:i("sessions.sidebar.header.listGrouping.label")}),Rh.map(([c,P])=>Jt(c,P,F===c,()=>Pr(c)))]}):null,V==="timeline"?null:t.jsxs(t.Fragment,{children:[t.jsx(tr,{}),t.jsx(Xr,{children:i("sessions.sidebar.header.actions.sortProjects")}),Nh.map(([c,P])=>Jt(c,P,L===c,()=>an(c)))]}),t.jsx(tr,{}),Jt("pinned","sessions.sidebar.header.displayMode.showPinned",ce,rt),Je?Jt("work","sessions.sidebar.header.displayMode.showWork",Q,Dr):null,V==="timeline"?null:Jt("detailed","sessions.sidebar.header.displayMode.detailedZoneRows",re,Mr),ae?t.jsxs(t.Fragment,{children:[t.jsx(tr,{}),t.jsx(hn,{onClick:()=>Kt(!0),className:vn,children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Y,{name:"drag-move-2",className:"size-4"}),i("mobile.sessions.editOrder")]})})]}):null]})]}):null,ze=mt?t.jsx(Ie,{type:"button",variant:"chip",size:"sm","aria-label":i("mobile.sessions.doneEditing"),"aria-pressed":!0,onClick:()=>Kt(!1),style:{touchAction:"manipulation"},children:t.jsx(rl,{className:"size-4"})}):null,Nt=!mt&&Me.length>0?t.jsxs(Ie,{type:"button",variant:"default",size:"sm","aria-label":i("mobile.sessions.newChat"),onClick:at,style:{touchAction:"manipulation"},children:[t.jsx(Af,{className:"size-4"}),i("mobile.sessions.newChat")]}):null,Ue=mt?null:t.jsx(Ie,{type:"button",variant:"chip",size:"sm","aria-label":i("sessions.sidebar.header.actions.addProject"),title:i("sessions.sidebar.header.actions.addProject"),onClick:()=>It(!0),style:{touchAction:"manipulation"},children:t.jsx(Co,{className:"size-4"})}),un=Nt||Ue||Re||ze?t.jsxs(t.Fragment,{children:[Ue,Re,ze,Nt]}):null,fn=t.jsxs("div",{ref:Fn,className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs(wr,{ref:He,className:"min-h-0 flex-1 overflow-y-auto pb-4",children:[t.jsx("div",{className:se("px-4 pb-2 pt-1",mt&&"hidden"),children:t.jsx(Cu,{value:be,onSearch:ye,active:n||s==="sidebar",mobile:!0,placeholder:i("mobile.sessions.search.placeholder"),clearLabel:i("mobile.sessions.clearSearchAria")})}),Me.length===0&&Rs.length===0?t.jsx(la,{title:i("mobile.sessions.empty.noProjectsTitle"),description:i("mobile.sessions.empty.noProjectsDescription"),action:t.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-ring",onClick:()=>It(!0),children:[t.jsx(Co,{className:"size-4"}),i("sessions.sidebar.header.actions.addProject")]})}):$?t.jsx(la,{title:i("mobile.sessions.empty.searchTitle"),description:i("mobile.sessions.empty.searchDescription")}):Ge&&!mt?t.jsxs("div",{className:"flex flex-col gap-3 px-3 pt-2",children:[Yt.length>0?t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center justify-between px-1 pb-1.5",children:[t.jsx("span",{className:"typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:i("mobile.sessions.search.section.sessions")}),t.jsx("span",{className:"typography-micro text-muted-foreground tabular-nums",children:Yt.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:Yt.map((c,P)=>t.jsx("div",{className:se(P>0&&"border-t border-border/70"),children:t.jsx(ta,{session:c,active:M===c.id,indent:12,contextLabel:Or(c),onSelect:()=>on(c)})},c.id))})]}):null,Qt.length>0?t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center justify-between px-1 pb-1.5",children:[t.jsx("span",{className:"typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:i("mobile.sessions.search.section.projects")}),t.jsx("span",{className:"typography-micro text-muted-foreground tabular-nums",children:Qt.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:Qt.map((c,P)=>t.jsxs("div",{className:se("flex items-center",P>0&&"border-t border-border/70"),children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-3 px-3 py-1.5 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>Os(c),style:{touchAction:"manipulation"},children:[t.jsx(An,{project:c}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:c.label})]}),c.isGitRepo?t.jsx(Zo,{onClick:()=>us(c.id)}):null,t.jsx(ea,{className:"me-2",label:i("mobile.sessions.newSessionInProjectAria",{label:c.label}),onClick:()=>zt(c)})]},c.id))})]}):null]}):mt?t.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2",children:[t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:i("mobile.sessions.editOrderHint")}),t.jsx($i,{sensors:Pt,collisionDetection:Wi,onDragEnd:_s,children:t.jsx(Vi,{items:Me.map(c=>c.id),strategy:Ui,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:Me.map(c=>t.jsx(Mh,{project:c,expanded:Rr.has(c.id),onToggleExpanded:()=>_r(c.id),onReorderWorktrees:P=>de(c.id,P)},c.id))})})})]}):t.jsxs("div",{className:"flex flex-col",children:[(()=>{const c=G[pn]??!0,P=i("mobile.sessions.section.chats");return t.jsxs("section",{children:[t.jsx("div",{className:"flex min-h-12 w-full items-center",children:t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ge){Ot(ge,!1);return}ot(pn,c)},"aria-expanded":c,"aria-label":c?i("sessions.sidebar.group.collapseAria",{label:P}):i("sessions.sidebar.group.expandAria",{label:P}),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(Y,{name:"chat-4",className:"size-5"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-header font-semibold text-foreground",children:P}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:Ir})]})}),t.jsx(yn,{open:c,children:()=>t.jsx("div",{className:"pb-2",children:xt.sessions.length>0?_t(Bn,xt,V==="timeline"?null:0,{pageSize:Ih,alwaysVisibleIds:nn}):t.jsx("p",{className:"px-3 pb-1 typography-micro text-muted-foreground",style:{paddingInlineStart:V==="timeline"?ai:Nn(0)},children:i("sessions.sidebar.activity.chatsEmpty")})})})]})})(),Xn(ii,"pushpin",i("sessions.sidebar.activity.pinnedTitle"),Ht,cn),Xn(Qo,"eye",i("sessions.sidebar.work.title"),Tt,Hn),es?Br():fs.map(c=>{const P=Xt(c),W=Ge?c.buckets.filter(te=>te.sessions.some(he=>ci(he,c.project.label,Ge))):c.buckets,J=as(c);return t.jsxs("section",{children:[t.jsx(xr,{actionsWidth:96,revealed:ge===`project:${c.project.id}`,onRevealedChange:te=>Ot(`project:${c.project.id}`,te),actions:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:ge===`project:${c.project.id}`?0:-1,className:se("flex flex-1 items-center justify-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive",Be===c.project.id?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80"),"aria-label":Be===c.project.id?i("mobile.sessions.confirmRemoveProjectAria",{label:c.project.label}):i("mobile.sessions.removeProjectAria",{label:c.project.label}),onClick:()=>{if(Be===c.project.id){Ce(null),Le(null),q(c.project.id),pe.success(i("mobile.sessions.toast.projectRemoved",{label:c.project.label}));return}Le(c.project.id)},style:{touchAction:"manipulation"},children:t.jsx(fr,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:ge===`project:${c.project.id}`?0:-1,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":i("mobile.sessions.editProjectAria",{label:c.project.label}),onClick:()=>{Ce(null),Ee(c.project.id)},style:{touchAction:"manipulation"},children:t.jsx(nl,{className:"size-[18px]"})})]}),children:t.jsxs("div",{"data-active-project":c.isActive||void 0,className:"flex min-h-12 w-full items-center",children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ge){Ot(ge,!1);return}ot(c.project.id,P)},"aria-expanded":P,"aria-label":P?i("sessions.sidebar.group.collapseAria",{label:c.project.label}):i("sessions.sidebar.group.expandAria",{label:c.project.label}),style:{touchAction:"manipulation"},children:[t.jsx(An,{project:c.project}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-header font-semibold text-foreground",children:c.project.label})]}),c.project.isGitRepo?t.jsx(Zo,{onClick:()=>us(c.project.id)}):null,t.jsx(ea,{className:"me-2",label:i("mobile.sessions.newSessionInProjectAria",{label:c.project.label}),onClick:()=>zt(c.project)})]})}),t.jsx(yn,{open:P,children:()=>Zt?t.jsxs("div",{className:"pb-2",children:[(p?W:[]).filter(te=>te.space&&te.sessions.length===0).map(te=>t.jsx("div",{className:"mt-1.5",children:Ls(c,te,!1,J)},te.key)),dn(`${c.project.id}::timeline`,zr.get(c.project.id)??[],!1)]}):t.jsx("div",{className:"pb-2",children:(()=>{const te=W.find(Ae=>Ae.worktree===null&&Ae.space===null),he=W.filter(Ae=>Ae!==te);return t.jsxs(t.Fragment,{children:[te&&(te.sessions.length>0||rn(te).length>0)?_t(`${c.project.id}::${te.key}`,te,0,{folders:rn(te)}):null,he.map(Ae=>{const Qe=ls(c,Ae);return t.jsx(Ah,{path:Ae.worktree?.path??null,children:lt=>t.jsxs("div",{className:se("mt-1.5",lt&&"opacity-60"),"aria-busy":lt||void 0,children:[Ls(c,Ae,lt,J),t.jsx(yn,{open:Qe,children:()=>_t(`${c.project.id}::${Ae.key}`,Ae,1,{folders:rn(Ae)})})]})},Ae.key)})]})})()})})]},c.project.id)})]})]}),r?t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-border/70 px-2 pt-1.5",style:{paddingBottom:"calc(0.375rem + var(--oc-safe-area-bottom, 0px))"},children:[r.instanceLabel&&r.onOpenInstances?t.jsxs(Ie,{type:"button",variant:"info",size:"lg",className:"min-w-0 shrink justify-start",onClick:r.onOpenInstances,"aria-label":i("mobile.menu.instances"),style:{touchAction:"manipulation"},children:[t.jsx(Y,{name:"server",className:"size-[18px]"}),t.jsx("span",{className:"block min-w-0 truncate",children:r.instanceLabel})]}):t.jsx("div",{className:"min-w-0 flex-1"}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[r.onOpenUpdate?t.jsxs(Ie,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:r.onOpenUpdate,"aria-label":i("mobile.menu.update"),title:i("mobile.menu.update"),style:{touchAction:"manipulation"},children:[t.jsx(Y,{name:"download",className:"size-5"}),t.jsx("span",{className:"absolute inset-e-2 top-2 inline-flex size-2 rounded-full bg-primary","aria-hidden":!0})]}):null,t.jsx(Ie,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:r.onOpenSourceBoard,"aria-label":i("sourceBoard.title"),title:i("sourceBoard.title"),style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"git-pull-request",className:"size-5"})}),t.jsx(Ie,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:r.onOpenSettings,"aria-label":i("mobile.menu.settings"),title:i("mobile.menu.settings"),style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"settings-3",className:"size-5"})}),t.jsxs(pi,{children:[t.jsx(hi,{asChild:!0,children:t.jsx(Ie,{type:"button",variant:"default",size:"lg",className:"w-10 px-0","aria-label":i("mobile.sessions.footer.more"),title:i("mobile.sessions.footer.more"),style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"more",className:"size-5"})})}),t.jsxs(gi,{side:"top",align:"end",className:"w-56",children:[t.jsx(hn,{onClick:r.onOpenScheduled,className:vn,children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Y,{name:"calendar-schedule",className:"size-4"}),i("sessions.sidebar.header.actions.scheduledTasks")]})}),t.jsx(hn,{onClick:r.onOpenArchive,className:vn,children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Y,{name:"archive",className:"size-4"}),i("sessions.sidebar.nav.archive")]})}),t.jsx(hn,{onClick:r.onOpenUsage,className:vn,children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Y,{name:"bar-chart",className:"size-4"}),i("usageStats.openAction")]})})]})]})]})]}):null,t.jsx(Ru,{open:it,onOpenChange:It}),t.jsx(sd,{open:Nr,onOpenChange:c=>{On(c),c||ft(null)},project:(()=>{const c=Me.find(P=>P.id===Ss);return c?{id:c.id,path:c.path}:void 0})(),onWorktreeCreated:c=>{O({selectedProjectId:Ss,directoryOverride:c,preserveDirectoryOverride:!0}),e(!1)}}),t.jsx(rh,{open:Te!==null,project:Me.find(c=>c.id===Te)??null,onClose:()=>Ee(null),onWorktreesChanged:()=>qe(c=>c+1)}),et?t.jsx(Dl,{open:!0,project:{id:et.project.id,path:et.project.path},worktree:et.worktree,onClose:()=>Fe(null),onDeleted:()=>qe(c=>c+1)}):null]});return s==="sidebar"?n?t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsx("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center justify-end gap-2 border-b border-border/70 px-4",children:un?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:un}):null}),fn]}):null:t.jsxs(zh,{open:n,onClose:()=>e(!1),onSwipeClose:()=>{if(De||ge){je(null),Ce(null),H(null),Le(null);return}e(!1)},ariaLabel:i("mobile.sessions.sheet.title"),children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",children:[t.jsx("button",{type:"button",className:"-ms-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-ring","aria-label":i("mobile.surface.closeAria"),onClick:()=>e(!1),style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"close",className:"size-5"})}),un?t.jsx("div",{className:"ms-auto flex shrink-0 items-center gap-2",children:un}):null]}),fn]})},oa="mobile-surface-root",_h=16,aa=320,Oh="cubic-bezier(0.22, 1, 0.36, 1)",zh=({open:n,onClose:e,onSwipeClose:s,ariaLabel:r,children:i})=>{const{direction:l}=xe(),o=d.useRef(null),a=d.useRef(null),[f,p]=d.useState(!1),[m,h]=d.useState(n),b=d.useRef(e);d.useEffect(()=>{b.current=e},[e]);const u=d.useRef(s);d.useEffect(()=>{u.current=s},[s]);const g=()=>(u.current??b.current)();if(ro(a,{enabled:n,...l==="rtl"?{onLeftEdgeSwipe:g}:{onRightEdgeSwipe:g}}),typeof document<"u"&&!o.current){let y=document.getElementById(oa);y||(y=document.createElement("div"),y.id=oa,document.body.appendChild(y)),o.current=y}return d.useEffect(()=>{if(n){h(!0);const w=window.setTimeout(()=>p(!0),_h);return()=>window.clearTimeout(w)}p(!1);const y=window.setTimeout(()=>h(!1),aa+40);return()=>window.clearTimeout(y)},[n]),d.useEffect(()=>{if(!n)return;const y=document.body.style.overflow;document.body.style.overflow="hidden";const w=j=>{j.key==="Escape"&&!Mi(j)&&b.current()};return document.addEventListener("keydown",w),()=>{document.body.style.overflow=y,document.removeEventListener("keydown",w)}},[n]),o.current?Hs.createPortal(t.jsx("section",{ref:a,role:"dialog","aria-modal":"true","aria-label":r,"aria-hidden":!n,className:"oc-keyboard-inset-surface fixed inset-0 z-50 flex flex-col bg-background text-foreground",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:f?"none":l==="rtl"?"translateX(100%)":"translateX(-100%)",transition:`transform ${aa}ms ${Oh}`,visibility:m?"visible":"hidden",pointerEvents:n?"auto":"none"},children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:i})}),o.current):null},la=n=>{const e=fe.c(10),{title:s,description:r,action:i}=n;let l;e[0]!==s?(l=t.jsx("p",{className:"typography-ui-label text-foreground",children:s}),e[0]=s,e[1]=l):l=e[1];let o;e[2]!==r?(o=r?t.jsx("p",{className:"typography-meta text-muted-foreground",children:r}):null,e[2]=r,e[3]=o):o=e[3];let a;e[4]!==i?(a=i?t.jsx("div",{className:"pt-2",children:i}):null,e[4]=i,e[5]=a):a=e[5];let f;return e[6]!==l||e[7]!==o||e[8]!==a?(f=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[l,o,a]}),e[6]=l,e[7]=o,e[8]=a,e[9]=f):f=e[9],f};function Bh(n){return Ze(n.path)}function Lh(n){return Ze(n.path)}function Fh(n){return t.jsx(Dh,{worktree:n},Ze(n.path))}const $h=6e4,Wh=(n,e)=>{if(!n)return e("mcpDropdown.status.unknown");const s=n.status;switch(s.status){case"connected":return e("mcpDropdown.status.connected");case"failed":return e("mcpDropdown.status.failed",{error:s.error||e("mcpDropdown.status.unknownError")});case"needs_auth":return e("mcpDropdown.status.needsAuth");default:return s.status}},Vh=n=>{switch(n?.status.status){case"connected":return"success";case"failed":return"error";case"needs_auth":return"warning";default:return"default"}},Uh=({active:n,className:e,headerAction:s,listClassName:r,hideHeader:i=!1,mobileListDensity:l=!1})=>{const{t:o}=xe(),a=Ka(n),f=$s(E=>a?E.getStatusForDirectory(a):null),p=$s(E=>E.refresh),m=$s(E=>E.ensureFresh),h=$s(E=>E.connect),b=$s(E=>E.disconnect),u=Ks(E=>a?od(E,a):null),g=Ks(E=>E.loadMcpConfigs),[y,w]=d.useState(!1),[j,S]=d.useState(null);d.useEffect(()=>{!n||!a||Promise.all([m({directory:a,silent:!0,maxAgeMs:$h}),g({force:!0,directory:a})])},[n,m,a,g]);const M=d.useMemo(()=>{const E=new Set(Object.keys(f??{}));for(const C of u??[])C?.name&&E.add(C.name);return Array.from(E).sort((C,N)=>C.localeCompare(N))},[u,f]),I=d.useCallback(E=>{if(E?.preventDefault(),y||!a)return;w(!0);const C=new Promise(N=>setTimeout(N,500));Promise.all([p({directory:a}),C]).finally(()=>{w(!1)})},[y,p,a]);return t.jsxs("div",{className:se("w-full",e),children:[i?null:t.jsx("div",{className:"border-b border-[var(--interactive-border)]",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5",children:[t.jsxs("div",{className:"min-w-0 flex items-baseline gap-2",children:[t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:o("mcpDropdown.title")}),a&&t.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:a.split("/").pop()||a})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s,t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",disabled:y||!a,onClick:I,"aria-label":o("mcpDropdown.actions.refreshAria"),children:t.jsx(Y,{name:"refresh",className:se("h-4 w-4",y&&"animate-spin")})})]})]})}),t.jsx("div",{className:se("max-h-64 overflow-y-auto",l?"space-y-1 py-3":"px-3 py-2.5",r),children:t.jsxs("div",{className:se(!l&&M.length>0&&"p-1.5"),children:[M.map(E=>{const C=f?.[E],N=Vh(C),v=C?.status.status==="connected",T=j===E,O=Wh(C,o);return t.jsxs("div",{className:se("flex items-center justify-between rounded-lg hover:bg-interactive-hover",l?"gap-3 px-4 py-3":"gap-2 px-2.5 py-2"),children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsxs(ad,{children:[t.jsx(ld,{asChild:!0,children:t.jsx("span",{className:se("rounded-full flex-shrink-0",l?"h-2.5 w-2.5":"h-2 w-2",N==="success"&&"bg-status-success",N==="error"&&"bg-status-error",N==="warning"&&"bg-status-warning",N==="default"&&"bg-muted-foreground/40"),"aria-label":O})}),t.jsx(cd,{side:"left",children:t.jsx("p",{children:O})})]}),t.jsx("span",{className:se("truncate",l?"text-[17px] leading-6 font-medium":"typography-ui-label"),children:E})]})}),t.jsx(dd,{checked:v,disabled:T,className:"data-[checked]:bg-status-info",onCheckedChange:async B=>{if(a){S(E);try{B?await h(E,a):await b(E,a)}catch(z){vi.error(z instanceof Error?z.message:o("mcpDropdown.status.unknownError"))}finally{S(null)}}}})]},E)}),a&&M.length===0&&t.jsx("div",{className:"px-4 py-5 typography-ui-label text-muted-foreground text-center",children:o("mcpDropdown.empty.configureInConfig")})]})})]})},or="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",Gh=n=>{const e=fe.c(59),{directory:s,target:r,subtitle:i,revision:l,visible:o,onBack:a}=n,{t:f}=xe();let p;e[0]!==s||e[1]!==l||e[2]!==r||e[3]!==o?(p={directory:s,target:r,visible:o,needsSourceSelection:!1,revision:l},e[0]=s,e[1]=l,e[2]=r,e[3]=o,e[4]=p):p=e[4];const m=im(p),{view:h}=m,[b,u]=d.useState(!1),g=m.entry.result?.generatedAt??null,[y,w]=d.useState(null),j=h!==null&&y!==null&&y===g;let S;e[5]!==g||e[6]!==m?(S=ce=>{m.handleSelectStop(ce),w(g)},e[5]=g,e[6]=m,e[7]=S):S=e[7];const M=S;let I;e[8]!==a||e[9]!==j?(I=()=>{j?w(null):a()},e[8]=a,e[9]=j,e[10]=I):I=e[10];const E=I;let C;e[11]!==f?(C=f("header.actions.backAria"),e[11]=f,e[12]=C):C=e[12];let N;e[13]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx(Y,{name:"arrow-left",className:"size-5"}),e[13]=N):N=e[13];let v;e[14]!==E||e[15]!==C?(v=t.jsx("button",{type:"button",className:or,"aria-label":C,onClick:E,children:N}),e[14]=E,e[15]=C,e[16]=v):v=e[16];let T;e[17]!==f?(T=f("contextPanel.mode.walkthrough"),e[17]=f,e[18]=T):T=e[18];let O;e[19]!==T?(O=t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:T}),e[19]=T,e[20]=O):O=e[20];let B;e[21]!==i?(B=t.jsx("p",{className:"truncate typography-meta text-muted-foreground",children:i}),e[21]=i,e[22]=B):B=e[22];let z;e[23]!==O||e[24]!==B?(z=t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[O,B]}),e[23]=O,e[24]=B,e[25]=z):z=e[25];let _;e[26]!==j||e[27]!==m||e[28]!==f||e[29]!==h?(_=j&&h?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:or,"aria-label":f("walkthrough.action.previous"),onClick:()=>m.step(-1),children:t.jsx(Y,{name:"arrow-right-s",className:"size-5 rotate-180"})}),t.jsx(om,{review:m,view:h,size:"mobile"}),t.jsx("button",{type:"button",className:or,"aria-label":f("walkthrough.action.next"),onClick:()=>m.step(1),children:t.jsx(Y,{name:"arrow-right-s",className:"size-5"})})]}):t.jsx("button",{type:"button",className:or,"aria-label":f("walkthrough.options.moreAria"),"aria-haspopup":"dialog",onClick:()=>u(!0),children:t.jsx(Y,{name:"more",className:"size-5"})}),e[26]=j,e[27]=m,e[28]=f,e[29]=h,e[30]=_):_=e[30];let A;e[31]!==z||e[32]!==_||e[33]!==v?(A=t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-1.5 border-b border-border/70 px-3 text-foreground",children:[v,z,_]}),e[31]=z,e[32]=_,e[33]=v,e[34]=A):A=e[34];let R;e[35]!==m||e[36]!==h?(R=t.jsx(fm,{review:m,view:h}),e[35]=m,e[36]=h,e[37]=R):R=e[37];let D;e[38]!==M||e[39]!==j||e[40]!==m||e[41]!==h?(D=t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:m.blocked?t.jsx(am,{reason:m.blocked.reason,model:m.blocked.model,requiredChars:m.blocked.requiredChars,availableChars:m.blocked.availableChars,onRetry:m.retry}):m.showStages?t.jsx("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-8",children:t.jsx(lm,{progress:m.stageProgress})}):h&&j?t.jsx(cm,{view:h,activeStopId:m.activeStopId,scrollToStopId:m.scrollToStopId,onActiveStopChange:m.handleActiveStopChange,onScrollHandled:m.clearScrollRequest,renderSideBySide:!1,wrapLines:!0}):h?t.jsx(dm,{view:h,activeStopId:m.activeStopId,visitedStopIds:m.visitedStopIds,onSelectStop:M}):t.jsx(um,{review:m,size:"mobile"})}),e[38]=M,e[39]=j,e[40]=m,e[41]=h,e[42]=D):D=e[42];let V;e[43]===Symbol.for("react.memo_cache_sentinel")?(V=()=>u(!1),e[43]=V):V=e[43];let L;e[44]!==f?(L=f("walkthrough.options.title"),e[44]=f,e[45]=L):L=e[45];const K=h!==null;let F;e[46]===Symbol.for("react.memo_cache_sentinel")?(F=()=>u(!1),e[46]=F):F=e[46];let U;e[47]!==m||e[48]!==K?(U=t.jsx("div",{className:"px-2 py-2",children:t.jsx(mm,{review:m,hasView:K,size:"mobile",onActed:F})}),e[47]=m,e[48]=K,e[49]=U):U=e[49];let Q;e[50]!==b||e[51]!==L||e[52]!==U?(Q=t.jsx(Ma,{open:b,onClose:V,title:L,children:U}),e[50]=b,e[51]=L,e[52]=U,e[53]=Q):Q=e[53];let le;return e[54]!==A||e[55]!==R||e[56]!==D||e[57]!==Q?(le=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[A,R,D,Q]}),e[54]=A,e[55]=R,e[56]=D,e[57]=Q,e[58]=le):le=e[58],le};async function Kh(n,e,s=Number.POSITIVE_INFINITY){const r=Array.from(new Set(n)),i=[];return await ud(r,s,async l=>{try{await e(l)}catch(o){i.push({path:l,error:o instanceof Error?o:null})}}),{paths:r,failures:i}}const qh=async(n,e,s)=>{const{targetBranch:r,directory:i,sourceBranch:l,git:o,publishChooser:a,toast:f,t:p}=s;if(!(!r||!i)){if(await o.createGitCommit(i,n,{addAll:!0}),e)try{await(await a.prepare("push"))()}catch{f.error(p("gitView.dirtySwitch.pushFailed")),await s.refreshStatusAndBranches(),s.closeDialog();return}f.success(l?e?p("gitView.publish.succeeded"):p("gitView.dirtySwitch.committedNotPushed",{branch:l}):p("gitView.toast.commitCreated")),await s.refreshStatusAndBranches(),s.closeDialog(),await s.performCheckout(r)}},ca={status:"loading"},Hh=1e6,Vt={type:"list"},Xh=2,Jh=n=>{const e=n.index?.trim();return!!(e&&e!=="?")},Yh=n=>{const e=n.working_dir?.trim(),s=n.index?.trim();return!!(e||s==="?")},da=(n,e)=>e?`${n}\0staged`:n,Qh=n=>{const e=fe.c(12),s=el(),r=_n(qa(s,Ha()))??"",i=n.visible??!0;let l;e[0]!==i?(l={enabled:i,recheckOnOpen:!0},e[0]=i,e[1]=l):l=e[1];const o=fd(r||null,l);let a;e[2]!==r?(a=b=>r?b.changesRepositories.get(r):void 0,e[2]=r,e[3]=a):a=e[3];const f=lr(a);let p;e[4]!==o||e[5]!==f?(p=f&&o.repositoryOptions?.includes(f)?{...o,gitDirectory:f}:o,e[4]=o,e[5]=f,e[6]=p):p=e[6];const m=p;if(s?.kind==="preparing"){let b;return e[7]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(tl,{}),e[7]=b):b=e[7],b}let h;return e[8]!==n||e[9]!==m||e[10]!==r?(h=t.jsx(Zh,{...n,rootDirectory:r,repository:m}),e[8]=n,e[9]=m,e[10]=r,e[11]=h):h=e[11],h},Zh=({rootDirectory:n,repository:e,onClose:s,initialDiff:r,visible:i=!0,onNavigatedToChat:l})=>{const{t:o}=xe(),{git:a,sourceControl:f}=vr(),{rootIsGitRepo:p,gitDirectory:m,nestedRepos:h,repositoryOptions:b}=e,u=m??n,g=md(u||null),y=Du(u),w=pd(u||null),j=hd(u||null),[S,M]=d.useState(!1),[I,E]=d.useState(!1),C=nr(x=>x.profiles),N=nr(x=>x.globalIdentity),v=nr(x=>x.loadProfiles),T=nr(x=>x.loadGlobalIdentity);d.useEffect(()=>{v(),T()},[v,T]);const O=gd(),B=Xa(x=>x.refreshIdentityAccounts),z=d.useMemo(()=>bd(C,N,x=>uc(x)&&xd(x,O)),[C,N,O]),_=async x=>{if(!(!u||I)){E(!0);try{(await qu({directory:u,identity:x,remoteName:os||null},{git:a,sourceControl:f})).status==="failed"?pe.error(o("gitView.toast.applyIdentityFailed")):pe.success(o("gitView.toast.appliedIdentity",{name:Md(x,o)}))}finally{E(!1)}}},A=Pa(u||null),R=yd(u||null),D=gt(x=>x.setActiveDirectory),V=gt(x=>x.ensureAll),L=gt(x=>x.ensureNestedRepos),K=gt(x=>x.selectNestedRepo),F=gt(x=>x.fetchStatus),U=gt(x=>x.fetchBranches),Q=gt(x=>x.prefetchDiffs),le=gt(x=>x.getDiff),ce=gt(x=>x.setDiff),oe=gt(x=>x.runtimeKey),re=JSON.stringify([oe,u]),ie=d.useRef(re);ie.current=re;const[k,q]=d.useState(()=>({ownerKey:re,mode:"working",route:r?.path?{type:"diff",path:r.path,staged:r.staged}:Vt})),G=k.ownerKey===re?k.mode:"working",Z=k.ownerKey===re?k.route:Vt,[me,ue]=d.useState(!1),X=d.useCallback(x=>{q({ownerKey:re,mode:x,route:Vt}),ue(!1)},[re]),de=d.useCallback(x=>{q($=>({ownerKey:re,mode:$.ownerKey===re?$.mode:"working",route:x}))},[re]);d.useEffect(()=>{q(x=>x.ownerKey===re?x:{ownerKey:re,mode:"working",route:Vt}),ue(!1)},[re]),d.useEffect(()=>{i||ue(!1)},[i]),d.useEffect(()=>{r?.path&&q({ownerKey:ie.current,mode:"working",route:{type:"diff",path:r.path,staged:r.staged}})},[r]);const[we,Se]=d.useState(null),[be,ye]=d.useState(null),[Te,Ee]=d.useState(""),[De,je]=d.useState(new Set),[Ne,H]=d.useState(!1),[ee,ve]=d.useState(!1),[ge,Ce]=d.useState([]),[Be,Le]=d.useState([]),[et,Fe]=d.useState([]),[jt,qe]=d.useState(null),[it,It]=d.useState(null),[Nr,On]=d.useState(0),Ss=Mu(),ft=_u({directory:u,branch:g?.current,chooseContributor:Ss.choose}),Et=Ou(u,a,f),[Ns,is]=d.useState(null),[Cr,mt]=d.useState(!1),[Kt,Rr]=d.useState([]),[Cs,sn]=d.useState("rebase"),kt=d.useCallback((x,$)=>{Rr(x),sn($),mt(!0)},[]),He=g?.current??null,Me=Io(x=>x.setOverride),tt=Io(x=>x.clearOverride),Xe=pm(u||null,He,i&&G==="commit"&&A===!0),Lt=Xe.selectedCommit?.hash??null,Oe=vd(u||null,f),Rs=d.useMemo(()=>new Set(Oe.read?.repository.remotes.map(x=>x.name)??[]),[Oe.read]),Je=hm(u||null,He,i&&A===!0,{branches:w,remoteNames:Rs,primaryRemote:Oe.contexts[0]?.primaryRemote,readContext:Oe.contexts[0]??null}),Ft=Gf(He,Je.base),qt=A===!1||Kf(He,Je.base,g!==null,Je.resolved),os=Oe.read?.binding?.remotes[0]?.name??Oe.read?.repository.remotes.find(x=>x.name==="origin")?.name??Oe.read?.repository.remotes[0]?.name??"",At=Oe.read?Oe.read.binding?.providers.find(x=>x.readiness==="ready")?.accountId??null:void 0,Is=d.useMemo(()=>wd(C,N,j,x=>({id:"local-config",name:x.userName,...x,color:"info",icon:"user"}),At),[At,j,C,N]),zn=d.useMemo(()=>{const x=Oe.read;return!x?.binding||Oe.status!=="ready"||x.binding.state==="bound"?null:jd(x.binding)?o("gitView.identity.configChanged"):o("gitView.context.needsAttention")},[Oe.read,Oe.status,o]),Ye=lr(x=>n?x.diffRequests.get(n):void 0);d.useEffect(()=>{Ye&&q({ownerKey:re,mode:"pr",route:Vt})},[re,Ye]);const We=gm(u||null,He,Oe.contexts[0]??null,i&&G==="pr"&&A===!0,Ye),St=We.selectedSource;d.useEffect(()=>{!n||!Ye||!g||St!==Ye||lr.getState().settleDiffRequest(n,Ye)},[Ye,n,St,g]);const xt=$e(x=>x.currentSessionId),nn=Ea(G==="turn"?xt??"":"",n||void 0),Ht=nn.length>0?nn[nn.length-1].id:"",[Tt,Bn]=d.useState([]),[Ir,Ge]=d.useState(!1),[Ln,Es]=d.useState(null),[Er,rn]=d.useReducer(x=>x+1,0),[Fn,$t]=d.useState(!1),$n=d.useCallback(()=>{$t(!1),l?.()},[l]),as=kd(xt,n,$n),Xt=d.useMemo(()=>G==="pr"?St:G==="branch"&&He&&Je.base?{kind:"branch",baseRef:Je.base,headRef:He}:G==="commit"&&Lt?{kind:"commit",hash:Lt}:null,[Je.base,He,G,Lt,St]),ls=G==="branch"?Je.revision:"",_e=qf(u||null,Xt,i&&A===!0,ls,We.readContext,We.provider),{fetchDiff:As,fetchFullFile:Ts}=_e,_t=d.useMemo(()=>_e.files?[..._e.files].sort((x,$)=>x.path.localeCompare($.path)):null,[_e.files]),ot=Z.type==="comparison"&&Z.sourceKey===_e.key?Z.path:null,[Ar,on]=d.useState(0),Wn=d.useCallback(async x=>{try{const{diff:$}=await As(x),ae={original:"",modified:"",isBinary:Eo($)};return ae.isBinary||(ae.fileDiff=Yr(x,$)),{status:"ready",diff:ae}}catch($){return{status:"error",message:$ instanceof Error?$.message:o("diffView.state.failedToLoadDiff")}}},[As,o]),Ot=d.useMemo(()=>G==="branch"?Hf(_e.files,ls):void 0,[_e.files,ls,G]),Vn=Xf(_e.files?G==="pr"?JSON.stringify([_e.key,_e.revision]):_e.key:null,i&&ot?ot:"",i?Wn:null,ca,JSON.stringify([G==="pr"?_e.revision:0,Ar]),Ot),pt=ot?Vn.get(ot)??ca:null,[Ps,Un]=d.useState(null),[cs,Gn]=d.useState(null),Ds=Ps&&Ps.source===pt?Ps.request:null,ds=cs&&cs.source===pt?cs.diff:null;d.useEffect(()=>{const x=pt;if(!Ds||!ot||x?.status!=="ready"||ds)return;let $=!1;const ae=ot,Re=async()=>{if(G==="pr"){const{original:Nt,modified:Ue}=await Ts(ae);return{original:Nt,modified:Ue,fileDiff:vm({name:ae,contents:Nt},{name:ae,contents:Ue})}}const{diff:ze}=await As(ae,Hh);return{original:"",modified:"",fileDiff:Yr(ae,ze)}};return(async()=>{try{const ze=await Re();$||Gn({source:x,diff:ze})}catch(ze){if($)return;pe.error(ze instanceof Error?ze.message:o("diffView.state.failedToLoadDiff")),Un(null)}})(),()=>{$=!0}},[pt,ot,ds,As,Ts,G,Ds,o]),d.useEffect(()=>{G==="branch"&&qt&&X("working")},[qt,X,G]),d.useEffect(()=>{q(x=>x.ownerKey===re&&x.route.type==="comparison"&&x.route.sourceKey!==_e.key?{...x,route:Vt}:x)},[_e.key,re]),d.useEffect(()=>{Bn([]),Ge(!1),Es(null)},[xt]),d.useEffect(()=>{if(G!=="turn"||!xt||!i)return;let x=!1;return fi.getSessionTurnDiff(xt,{directory:n||void 0}).then($=>{x||(Bn($.map(ae=>({file:ae.file,patch:ae.patch,status:ae.status,additions:ae.additions,deletions:ae.deletions}))),Ge(!0),Es(null))}).catch($=>{x||(console.warn("[mobile-changes] turn diff unavailable:",$ instanceof Error?$.message:$),Es($ instanceof Error?$.message:o("diffView.state.failedToLoadDiff")))}),()=>{x=!0}},[xt,Ht,G,n,o,Er,i]);const Ms=d.useMemo(()=>Tt.map(x=>({path:x.file??"",status:Jf(x.status),insertions:x.additions??0,deletions:x.deletions??0})).filter(x=>x.path).sort((x,$)=>x.path.localeCompare($.path)),[Tt]),Kn=d.useMemo(()=>{const x=new Map;for(const $ of Tt)if($.file){if(typeof $.patch=="string"){const ae=Eo($.patch);x.set($.file,{original:"",modified:"",isBinary:ae,fileDiff:ae?void 0:Yr($.file,$.patch)});continue}x.set($.file,{original:$.before??"",modified:$.after??""})}return x},[Tt]),at=d.useMemo(()=>{const x=g?.files??[],$=new Map;for(const ae of x)$.set(ae.path,ae);return Array.from($.values()).sort((ae,Re)=>ae.path.localeCompare(Re.path))},[g?.files]),us=d.useMemo(()=>G==="working"?at.length>0?{source:{kind:"working-tree",scope:"all"}}:null:!Xt||!_t?.length?null:Xt.kind==="pr"?We.readContext?{source:Xt,context:We.readContext}:null:{source:Xt},[at.length,_t,Xt,G,We.readContext]),Pt=d.useMemo(()=>at.filter(Jh),[at]),an=d.useMemo(()=>at.filter(Yh),[at]),Tr=et,Pr=gt(d.useCallback(x=>!u||Z.type!=="diff"?null:x.directories.get(u)?.diffCache.get(da(Z.path,Z.staged))??null,[u,Z])),Dr=d.useMemo(()=>Z.type!=="diff"?null:at.find(x=>x.path===Z.path)??null,[at,Z]),rt=d.useCallback(async(x=!0)=>{if(u)try{await Promise.all([F(u,a),U(u,a)])}catch($){x&&pe.error($ instanceof Error?$.message:o("gitView.toast.refreshRepositoryFailed"))}},[u,U,F,a,o]),Mr=d.useMemo(()=>(w?.all??[]).filter(x=>!x.startsWith("remotes/")).sort(),[w]),Jt=d.useMemo(()=>(w?.all??[]).filter(x=>x.startsWith("remotes/")).map(x=>x.replace(/^remotes\//,"")).sort(),[w]),_s=d.useCallback(async x=>{if(!u)return;const $=x.replace(/^remotes\//,"");try{const ae=await a.checkoutBranch(u,$);pe.success(o("gitView.toast.checkedOut",{name:ae.branch||$})),await rt()}catch(ae){pe.error(ae instanceof Error?ae.message:o("gitView.toast.checkoutFailed",{name:$}))}},[u,a,rt,o]),_r=d.useCallback(x=>{const $=x.replace(/^remotes\//,"");if((g?.files?.length??0)>0){is($);return}_s($)},[_s,g?.files]),Or=d.useCallback(async x=>{if(u)try{await a.createBranch(u,x,He??"HEAD"),await a.checkoutBranch(u,x),await rt()}catch($){throw pe.error($ instanceof Error?$.message:o("gitView.toast.createBranchFailed")),$}},[He,u,a,rt,o]),Os=d.useCallback(async()=>{if(!u){Fe([]);return}try{const x=await a.getRemotes(u);Fe(x)}catch{Fe([])}},[u,a]),zt=d.useCallback(async()=>{u&&(Promise.allSettled([U(u,a),Os()]),await F(u,a).catch(()=>{}))},[u,U,F,a,Os]);d.useEffect(()=>{!u||!i||(D(u),V(u,a))},[u,V,a,D,i]),d.useEffect(()=>{i&&Os()},[Os,i]),d.useEffect(()=>{if(!i||G!=="working"||!u||at.length===0)return;const x=Array.from(new Set([...Pt.map(ae=>ae.path),...Be,...at.slice(0,20).map(ae=>ae.path)])).filter(Boolean);if(x.length===0)return;const $=window.setTimeout(()=>{Q(u,a,x,{maxFiles:40})},120);return()=>window.clearTimeout($)},[at,u,a,G,Q,Pt,Be,i]),d.useEffect(()=>{if(!i)return;if(Z.type!=="diff"){qe(null);return}const x=da(Z.path,Z.staged);if(It(null),!u||le(u,x)){qe(null);return}let $=!1;const ae=Mn();return qe(null),a.getGitFileDiff(u,{path:Z.path,staged:Z.staged||void 0}).then(Re=>{$||ce(u,x,{original:Re.original??"",modified:Re.modified??"",isBinary:Re.isBinary,submodule:Re.submodule},ae)}).catch(Re=>{if(!$){if(Re instanceof xo&&Re.reason!=="path_not_found"){It({key:`${u}\0${Z.path}`,reason:Re.reason});return}Re instanceof xo&&F(u,a,{force:!0,silent:!0}),qe(Re instanceof Error?Re.message:String(Re))}}),()=>{$=!0}},[u,Nr,F,le,a,Z,ce,i]);const zs=async(x,$,ae=!1)=>{if(!u)return;const Re=Et.start();if(!Re)return;Se(x);const ze=o(x==="fetch"?"gitView.sync.fetch":x==="pull"?"gitView.sync.pull":x==="publish"?"gitView.publish.title":"gitView.sync.syncChanges");let Nt=null;try{if(x==="sync"||x==="publish"){const Ue=await ft.prepare(x==="publish"?"push":"sync",{forceChoose:ae,onOperation:Re.onOperation});Nt=_d(await Ue())}else if($&&g)await Od({action:x,directory:u,remoteName:$.name,status:g,sourceControl:f,git:a,onOperation:Re.onOperation});else throw new ns("tracking-required");if(!Re.isCurrent())return;x==="fetch"&&$?pe.success(o("gitView.toast.fetchedFromRemote",{name:$.name})):x==="pull"&&$?pe.success(o("gitView.toast.pulledFromRemote",{name:$.name})):x==="sync"?pe.success(Nt?.kind==="up-to-date"?o("gitView.toast.alreadyUpToDate"):Nt?.kind==="pulled"?o("gitView.toast.pulledFromRemote",{name:Nt.remoteName}):Nt?.kind==="pushed"?o("gitView.toast.pushedToUpstream",{name:Nt.remoteName}):o("gitView.toast.syncedChanges")):x==="publish"&&pe.success(o("gitView.publish.succeeded")),await zt()}catch(Ue){if(Ue instanceof ar||Ue instanceof mi){if(Re.isCurrent()&&await zt(),Re.isCurrent()&&Ue instanceof ar&&Ue.read.availability==="available"&&Ue.read.operation.state==="conflicted"&&Ue.read.operation.error.code==="CONFLICT"){const fn=((await a.getGitStatus(u).catch(()=>null))?.files??[]).filter(Jr).map(c=>c.path);fn.length>0&&kt(fn,"merge")}return}if(Ue instanceof ns&&Ue.code==="stale-runtime")return;if(Ue instanceof ns&&ft.errorMessage(Ue)){pe.info(ft.errorMessage(Ue));return}await zt(),pe.error(Ue instanceof ns?Ue.code==="contributor-publish-cancelled-after-update"?o("gitView.toast.contributorPublishCancelledAfterUpdate"):Ue.code==="contributor-publish-cancelled"?o("gitView.toast.contributorPublishCancelled"):o("gitView.toast.syncActionFailed",{action:ze}):Ue instanceof Error?Ue.message:o("gitView.toast.syncActionFailed",{action:ze}))}finally{Re.finish(),Re.isCurrent()&&Se(null)}},fs=d.useCallback(async(x,$)=>{if(!(!u||x.length===0))try{$==="stage"?x.length>1?await Sd(u,x):await Nd(u,x[0]):x.length>1?await Cd(u,x):await Rd(u,x[0]),await rt(!1)}catch(ae){pe.error(ae instanceof Error?ae.message:o($==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed"))}},[u,rt,o]),Yt=d.useCallback((x,$=!1)=>{de({type:"diff",path:x,staged:$})},[de]),Qt=d.useCallback(async x=>{if(u){je($=>new Set($).add(x));try{await a.revertGitFile(u,x),pe.success(o("gitView.toast.revertedFile",{path:x})),await rt(!1)}catch($){pe.error($ instanceof Error?$.message:o("gitView.toast.revertFailed"))}finally{je($=>{const ae=new Set($);return ae.delete(x),ae})}}},[u,a,rt,o]),Zt=d.useCallback(async x=>{if(!u||x.length===0||Ne)return;const $=Array.from(new Set(x));H(!0),je(new Set($));try{const ae=await Kh($,Re=>a.revertGitFile(u,Re),Xh);if(await rt(!1),ae.failures.length===0)pe.success($.length===1?o("gitView.toast.revertedFilesSingle",{count:$.length}):o("gitView.toast.revertedFilesPlural",{count:$.length}));else if(ae.failures.length===$.length)pe.error(ae.failures[0]?.error?.message??o("gitView.toast.revertFailed"));else{const Re=$.length-ae.failures.length;pe.warning(Re===1?o("gitView.toast.revertedSomeSingle",{success:Re,failed:ae.failures.length}):o("gitView.toast.revertedSomePlural",{success:Re,failed:ae.failures.length}))}}catch(ae){pe.error(ae instanceof Error?ae.message:o("gitView.toast.revertFailed"))}finally{je(new Set),H(!1)}},[u,a,Ne,rt,o]),es=d.useCallback(x=>{const $=x.map(ae=>ae.trim()).filter(Boolean);if($.length===0){Ce([]);return}Ee(ae=>`${ae.trim()}${ae.trim()?`
|
|
23
23
|
|
|
24
24
|
`:""}${$.join(`
|
|
25
|
-
`)}`.trim()),Ce([])},[]),ms=d.useCallback(async()=>{if(!u)return;const x=Pt.map($=>$.path).sort();if(x.length===0){pe.error(o("gitView.toast.selectFileToDescribe"));return}ve(!0);try{const{message:$}=await So(u,x);Ee($.subject?.trim()??""),Ce(Array.isArray($.highlights)?$.highlights:[])}catch($){pe.error($ instanceof Error?$.message:o("gitView.toast.generateCommitMessageFailed"))}finally{ve(!1)}},[u,Pt,o]),qn=async(x={})=>{if(!u)return;if(!Te.trim()){pe.error(o("gitView.toast.enterCommitMessage"));return}const $=Pt.map(ze=>ze.path).sort();if($.length===0){pe.error(o("gitView.toast.selectFileToCommit"));return}ye(x.pushAfter?"commitAndPush":"commit");let ae=null,Re="pending";try{if(await a.createGitCommit(u,Te.trim(),{files:$}),Re="local",pe.success(o("gitView.toast.commitCreated")),Ee(""),Ce([]),x.pushAfter){if(ae=Et.start(),!ae){pe.warning(o("gitView.publish.commitKept")),await zt();return}const ze=await ft.prepare("push",{onOperation:ae.onOperation});Se("publish"),await ze(),Re="published",pe.success(o("gitView.publish.succeeded"))}await zt()}catch(ze){if(x.pushAfter&&Re==="local"&&pe.warning(o("gitView.publish.commitKept")),ze instanceof ar||ze instanceof mi){await zt();return}if(ze instanceof ns&&ze.code==="stale-runtime")return;if(ze instanceof ns&&ft.errorMessage(ze)){pe.info(ft.errorMessage(ze));return}x.pushAfter&&await zt(),pe.error(ze instanceof ns?ze.code==="contributor-publish-cancelled-after-update"?o("gitView.toast.contributorPublishCancelledAfterUpdate"):ze.code==="contributor-publish-cancelled"?o("gitView.toast.contributorPublishCancelled"):o("gitView.toast.syncActionFailed",{action:o("gitView.sync.syncChanges")}):ze instanceof Error?ze.message:o("gitView.toast.createCommitFailed"))}finally{ae?.finish(),ye(null),x.pushAfter&&Se(null)}},ln=d.useMemo(()=>(g?.files??[]).filter(Jr).length,[g?.files]),ts=!!g?.mergeInProgress?.head,ss=d.useCallback(async()=>{if(u)try{if(ts){const x=await a.continueMerge(u);x.conflict?(kt(x.conflictFiles??[],"merge"),pe.error(o("gitView.toast.mergeConflictsDetected"))):pe.success(o("gitView.toast.mergeCompleted"))}else{const x=await a.continueRebase(u);x.conflict?(kt(x.conflictFiles??[],"rebase"),pe.error(o("gitView.toast.rebaseConflictsDetected"))):pe.success(o("gitView.toast.rebaseStepCompleted"))}await rt(!1)}catch(x){pe.error(x instanceof Error?x.message:o("gitView.toast.continueOperationFailed"))}},[u,a,ts,kt,rt,o]),Dt=d.useCallback(async x=>{if(u)try{x==="merge"?(await a.abortMerge(u),pe.success(o("gitView.toast.mergeAborted"))):(await a.abortRebase(u),pe.success(o("gitView.toast.rebaseAborted"))),await rt(!1)}catch($){pe.error($ instanceof Error?$.message:o("gitView.toast.abortOperationFailed"))}},[u,a,rt,o]),zr=d.useCallback(()=>{const x=(g?.files??[]).filter(Jr).map($=>$.path);kt(x,ts?"merge":"rebase")},[ts,kt,g?.files]),Bs=d.useMemo(()=>{const x=[];return Pt.length>0&&x.push({id:"staged",title:o("gitView.changes.stagedTitle"),entries:Pt,statsScope:"staged",actionSymbol:"-",actionAllLabel:o("gitView.changes.unstageAllAria"),getActionLabel:$=>o("gitView.changes.unstageFileAria",{path:$}),onActionFile:$=>{fs([$],"unstage")},onActionAll:$=>{fs($,"unstage")},onViewDiff:$=>Yt($,!0),onRevertFile:Qt,showRevertActions:!1,accent:!0}),an.length>0&&x.push({id:"unstaged",title:o("gitView.changes.title"),entries:an,statsScope:"working",actionSymbol:"+",actionAllLabel:o("gitView.changes.stageAllAria"),getActionLabel:$=>o("gitView.changes.stageFileAria",{path:$}),onActionFile:$=>{fs([$],"stage")},onActionAll:$=>{fs($,"stage")},onViewDiff:$=>Yt($,!1),onRevertFile:Qt}),x},[Qt,Yt,fs,Pt,o,an]),Hn=t.jsxs(t.Fragment,{children:[ft.context?t.jsx(zu,{context:ft.context,onSelect:ft.settle}):null,ft.confirmDialog,t.jsx(Bu,{candidates:Ss.candidates,onSelect:Ss.settle})]}),cn=x=>t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[Hn,t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[s?t.jsx("button",{type:"button",className:"-ms-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-ring","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"close",className:"size-5"})}):null,t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[t.jsx("h2",{className:"typography-ui-label text-foreground",children:o("mobile.nav.changes")}),t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:g?.current||u||""})]}),b?t.jsx(Ku,{repositories:b,selectedRepository:m??null,onSelectRepository:$=>{n&&(lr.getState().clearChangesRepository(n),K(n,$))},repositoryRoot:n??void 0}):null]}),t.jsx("div",{className:"min-h-0 flex-1",children:x})]});if(!u)return cn(t.jsx(dt,{message:o("gitView.empty.selectSessionOrDirectory")}));if(p===!1&&A!==!0)return cn(t.jsx(Hu,{root:n,rootIsGitRepo:p,resolvedIsGitRepo:A,nestedRepos:h,onRetryDiscovery:()=>{n&&L(n,{force:!0})}}));if(R&&A===null)return cn(t.jsx(dt,{loading:!0,message:o("gitView.loading.checkingRepository")}));if(Z.type==="diff")return t.jsx(di,{path:Z.path,diff:Pr,staged:Z.staged,fileExists:!!Dr,unavailableReason:it?.key===`${u}\0${Z.path}`?it.reason:null,error:jt,onBack:()=>de({type:"list"}),onRetry:()=>On(x=>x+1)});if(Z.type==="turn")return t.jsx(di,{path:Z.path,subtitle:o("diffView.scope.lastTurn"),diff:Kn.get(Z.path)??null,fileExists:Ms.some(x=>x.path===Z.path),onBack:()=>de(Vt)});const Ls=o(G==="pr"?sr("session.githubIntegration.tabs.pullRequests",We.provider):G==="branch"?"diffView.scope.branch":G==="commit"?"commitComparison.mode":G==="turn"?"diffView.scope.lastTurn":"mobile.nav.changes"),dn=G==="branch"&&Je.base?Lu(Je.base):G==="commit"?Lt?.slice(0,8):G==="pr"&&St?`#${St.number}`:null;if(Z.type==="walkthrough"&&us&&u)return t.jsx(Gh,{directory:u,target:us,subtitle:[Ls,dn].filter(Boolean).join(" · "),revision:JSON.stringify([ls,G==="pr"?_e.revision:0]),visible:i,onBack:()=>de(Vt)});if(ot&&pt)return t.jsx(di,{path:ot,subtitle:[Ls,dn].filter(Boolean).join(" · "),diff:ds??(pt.status==="ready"?pt.diff:null),fileExists:!_e.files||_e.files.some(x=>x.path===ot),error:_e.error??(pt.status==="error"?pt.message:null),onBack:()=>de(Vt),onRetry:()=>{_e.error&&_e.refresh(),on(x=>x+1)},onExpandContextRequest:pt.status==="ready"?x=>Un({source:pt,request:x}):void 0,pendingContextExpansion:Ds,contextLoading:Ds!==null&&!ds});const Xn=()=>G==="pr"&&!St?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(dt,{loading:We.loading,message:We.error??(We.loading?o(sr("session.githubPrPicker.loading.pullRequests",We.provider)):o(sr("pullRequestComparison.select",We.provider)))}),!We.loading&&t.jsx(Ao,{mobile:!0,comparison:We})]}):G==="branch"&&!Je.base?t.jsx(dt,{loading:!Je.resolved,message:Je.resolved?o("gitView.pr.toast.baseBranchRequired"):o("diffView.branch.resolvingBase")}):G==="commit"&&!Lt?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[Xe.loading&&t.jsx(Y,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:Xe.loading?o("diffView.state.loadingChanges"):Xe.error??o("commitComparison.noCommits")}),Xe.error&&t.jsx(Ie,{variant:"outline",size:"lg",onClick:()=>{Xe.refresh()},children:o("diffView.actions.retry")})]}):_e.error?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx("p",{className:"typography-ui-label font-semibold",children:o("diffView.state.failedToLoadDiff")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:_e.error}),t.jsx(Ie,{variant:"outline",size:"lg",onClick:()=>{_e.refresh()},children:o("diffView.actions.retry")})]}):_t?_t.length===0?t.jsx(dt,{icon:G==="branch",message:G==="pr"?o("walkthrough.blocked.emptyDiff.description"):G==="commit"?o("commitComparison.emptyDiff"):o("diffView.branch.empty",{base:dn??""})}):t.jsx(ua,{files:_t,onSelect:x=>{_e.key&&de({type:"comparison",path:x,sourceKey:_e.key})}}):t.jsx(dt,{loading:!0,message:o("diffView.state.loadingChanges")}),Br=()=>Ln?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx("p",{className:"typography-ui-label font-semibold",children:o("diffView.state.failedToLoadDiff")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:Ln}),t.jsx(Ie,{variant:"outline",size:"lg",onClick:()=>{Es(null),rn()},children:o("diffView.actions.retry")})]}):!Ir&&xt?t.jsx(dt,{loading:!0,message:o("diffView.state.loadingChanges")}):Ms.length===0?t.jsx(dt,{message:o("diffView.state.noLastTurnChanges")}):t.jsx(ua,{files:Ms,onSelect:x=>de({type:"turn",path:x})});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[Hn,t.jsxs("header",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b border-border/60 px-3 py-2",children:[s?t.jsx("button",{type:"button",className:"-ms-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-ring","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"close",className:"size-5"})}):null,t.jsxs(pi,{open:me,onOpenChange:ue,children:[t.jsx(hi,{asChild:!0,children:t.jsxs(Ie,{variant:"ghost",className:Id({size:"mobile"}),"data-mobile-comparison-trigger":!0,"aria-label":o("diffView.scope.selectorAria"),children:[t.jsx("span",{children:Ls}),t.jsx(Y,{name:"arrow-down-s",className:"size-4"})]})}),t.jsx(gi,{align:"start",children:t.jsxs(Ed,{value:G,onValueChange:x=>{(x==="working"||x==="turn"||x==="branch"||x==="commit"||x==="pr")&&X(x)},children:[t.jsx(gn,{value:"working",className:"min-h-8 items-center",children:o("mobile.nav.changes")}),t.jsx(gn,{value:"turn",className:"min-h-8 items-center",children:o("diffView.scope.lastTurn")}),Ft&&t.jsx(gn,{value:"branch",className:"min-h-8 items-center",children:o("diffView.scope.branch")}),t.jsx(gn,{value:"commit",className:"min-h-8 items-center",children:o("commitComparison.mode")}),t.jsx(gn,{value:"pr",className:"min-h-8 items-center",children:o(sr("session.githubIntegration.tabs.pullRequests",We.provider))})]})})]}),i&&G==="branch"&&t.jsx(bm,{mobile:!0,branches:w?.all??[],currentBranch:He,base:Je.base,automatic:Je.source!=="chosen",onSelect:x=>{He&&Me(u,He,x)},onSelectAutomatic:()=>{He&&tt(u,He)}},JSON.stringify([re,He])),i&&G==="commit"&&t.jsx(xm,{mobile:!0,commits:Xe.commits,selectedHash:Lt,loading:Xe.loading,error:Xe.error,onSelect:Xe.select,onRefresh:()=>{Xe.refresh()}},JSON.stringify([re,He])),i&&G==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(Ao,{mobile:!0,comparison:We},JSON.stringify([re,He])),St&&t.jsx(Ie,{variant:"ghost",size:"sm",disabled:_e.loading,"aria-label":o("session.githubIssuePicker.actions.refresh"),onClick:()=>{_e.refresh()},children:t.jsx(Y,{name:"refresh",className:"size-4"})})]}),us&&t.jsx(Ie,{variant:"ghost",size:"icon",className:"ms-auto shrink-0",onClick:()=>de({type:"walkthrough"}),"aria-label":o("walkthrough.action.open"),title:o("walkthrough.action.open"),style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"route",className:"size-5"})}),G==="working"&&xt&&(g?.files?.length??0)>0?t.jsxs(Ie,{variant:"default",className:se("shrink-0",!us&&"ms-auto"),disabled:as.submitting,onClick:()=>$t(!0),"aria-label":o("diffView.actions.reviewAria"),style:{touchAction:"manipulation"},children:[t.jsx(Y,{name:as.submitting?"loader-4":"search-eye",className:se("size-4",as.submitting&&"animate-spin")}),o("diffView.actions.review")]}):null]}),t.jsx(Ad,{open:Fn,onOpenChange:$t,projectDirectory:n||null,submitting:as.submitting,onConfirm:as.start}),G==="working"&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 px-3 py-2",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(Fu,{currentBranch:g?.current,localBranches:Mr,remoteBranches:Jt,branchInfo:w?.branches,currentBranchAhead:g?.ahead,onCheckout:x=>{_r(x)},onCreate:Or,disabled:R,directory:u,switchBlockedNotice:(g?.files?.length??0)>0?o("gitView.branch.switchBlockedNotice"):null})}),t.jsx($u,{activeProfile:Is,identities:z,attention:zn,triggerClassName:"max-w-[10rem] shrink [&_.git-identity-label]:hidden sm:[&_.git-identity-label]:inline",onOpen:()=>{B(f,C.map(x=>x.account))},onSelect:x=>{_(x)},isApplying:I,onConfigure:()=>M(!0),applicability:x=>{const $=Oe.read?.repository.remotes.find(ae=>ae.name===os);return $?Wu(x,Td($.fetch.displayUrl)):{applicable:!0}}}),t.jsx(Vu,{syncAction:Et.entry?.executing?we:null,remotes:Tr,onFetch:x=>{zs("fetch",x)},onPull:x=>{zs("pull",x)},onSync:x=>{zs("sync",x)},onPublish:()=>{zs("publish")},onChooseSyncTargets:()=>{zs("sync",void 0,!0)},currentBranch:g?.current,hasTracking:!!g?.tracking,disabled:R||Et.blocked,aheadCount:g?.ahead??0,behindCount:g?.behind??0,trackingRemoteName:g?.tracking?.split("/")[0],trackingBranch:g?.tracking,hasUncommittedChanges:Uu(at),choosesPushDestination:y})]}),t.jsx(Zf,{open:S,onOpenChange:M,directory:u}),t.jsx(Gu,{className:"mx-3 mt-3",entry:Et.entry,onRefresh:()=>{Et.refresh()},onCancel:()=>{Et.cancel()}}),G==="working"&&t.jsx(em,{mergeInProgress:g?.mergeInProgress,rebaseInProgress:g?.rebaseInProgress,onContinue:ss,onAbort:()=>Dt(ts?"merge":"rebase"),onResolveWithAI:zr,conflictCount:ln,isLoading:we!==null||be!==null}),G==="turn"?t.jsx("div",{className:"min-h-0 flex-1",children:Br()}):G!=="working"?t.jsx("div",{className:"min-h-0 flex-1",children:Xn()}):at.length>0?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden px-4 pt-4",children:t.jsx(tm,{groups:Bs,diffStats:g?.diffStats,revertingPaths:De,onRevertAll:Zt,isRevertingAll:Ne,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:Le})}),t.jsx("div",{className:"shrink-0 border-t border-border/70 px-4 pb-4 pt-3",children:t.jsx(sm,{stagedCount:Pt.length,commitMessage:Te,onCommitMessageChange:Ee,generatedHighlights:ge,onInsertHighlights:es,onGenerateMessage:ms,isGeneratingMessage:ee,onCommit:()=>{qn({pushAfter:!1})},onCommitAndPush:()=>{qn({pushAfter:!0})},commitAction:be,networkOperationBlocked:Et.blocked,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(dt,{icon:!0,message:o("gitView.empty.cleanTitle"),description:o("mobile.changes.cleanDescription")})}),u&&t.jsx(nm,{open:Cr,onOpenChange:mt,conflictFiles:Kt,directory:u,operation:Cs,onAbort:()=>{Dt(Cs)},onNavigatedToChat:l}),t.jsx(rm,{open:Ns!==null,onOpenChange:x=>{x||is(null)},targetBranch:Ns??"",changedFileCount:g?.files?.length??0,onCommitAndSwitch:(x,$)=>qh(x,$,{targetBranch:Ns,directory:u,sourceBranch:g?.current??null,git:a,publishChooser:ft,toast:pe,t:o,refreshStatusAndBranches:rt,closeDialog:()=>is(null),performCheckout:_s}),onGenerateMessage:async()=>{if(!u)return"";const x=(g?.files??[]).map(ae=>ae.path).sort(),{message:$}=await So(u,x);return $.subject?.trim()??""},onRevertAndSwitch:async()=>{const x=Ns;if(!x||!u)return;await Zt((g?.files??[]).map(ae=>ae.path));const $=await a.getGitStatus(u);if(!$.isClean&&($.files?.length??0)>0){pe.error(o("gitView.dirtySwitch.revertIncomplete"));return}is(null),await _s(x)}})]})},dt=n=>{const e=fe.c(13),{message:s,description:r,loading:i,icon:l}=n,o=i===void 0?!1:i,a=l===void 0?!1:l;let f;e[0]!==o?(f=o?t.jsx(Y,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,e[0]=o,e[1]=f):f=e[1];let p;e[2]!==a?(p=a?t.jsx(Y,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e[2]=a,e[3]=p):p=e[3];let m;e[4]!==s?(m=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[4]=s,e[5]=m):m=e[5];let h;e[6]!==r?(h=r?t.jsx("p",{className:"typography-meta text-muted-foreground",children:r}):null,e[6]=r,e[7]=h):h=e[7];let b;return e[8]!==f||e[9]!==p||e[10]!==m||e[11]!==h?(b=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[f,p,m,h]})}),e[8]=f,e[9]=p,e[10]=m,e[11]=h,e[12]=b):b=e[12],b},di=n=>{const e=fe.c(55),{path:s,subtitle:r,diff:i,staged:l,fileExists:o,unavailableReason:a,error:f,onBack:p,onRetry:m,onExpandContextRequest:h,pendingContextExpansion:b,contextLoading:u}=n,g=l===void 0?!1:l,y=a===void 0?null:a,w=f===void 0?null:f,{t:j}=xe();let S;e[0]!==s?(S=Pd(s)||"text",e[0]=s,e[1]=S):S=e[1];const M=S,I=Ve(eg),E=Ve(tg);let C;e[2]!==I||e[3]!==j?(C=j(I?"diffView.whitespace.hidden":"diffView.whitespace.shown"),e[2]=I,e[3]=j,e[4]=C):C=e[4];const N=C;let v;e[5]!==j?(v=j("header.actions.backAria"),e[5]=j,e[6]=v):v=e[6];let T;e[7]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(Y,{name:"arrow-left",className:"size-5"}),e[7]=T):T=e[7];let O;e[8]!==p||e[9]!==v?(O=t.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-ring","aria-label":v,onClick:p,children:T}),e[8]=p,e[9]=v,e[10]=O):O=e[10];let B;e[11]!==s?(B=t.jsx("h2",{className:"typography-ui-header",children:t.jsx(ol,{path:s})}),e[11]=s,e[12]=B):B=e[12];let z;e[13]!==r?(z=r&&t.jsx("p",{className:"truncate typography-meta text-muted-foreground",children:r}),e[13]=r,e[14]=z):z=e[14];let _;e[15]!==z||e[16]!==B?(_=t.jsxs("div",{className:"min-w-0 flex-1 px-2",children:[B,z]}),e[15]=z,e[16]=B,e[17]=_):_=e[17];const A=I?"text-foreground":"text-muted-foreground";let R;e[18]!==A?(R=se("flex size-9 shrink-0 items-center justify-center rounded-lg hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",A),e[18]=A,e[19]=R):R=e[19];let D;e[20]!==j?(D=j("diffView.actions.hideWhitespace"),e[20]=j,e[21]=D):D=e[21];let V;e[22]!==I||e[23]!==E?(V=()=>E(!I),e[22]=I,e[23]=E,e[24]=V):V=e[24];let L;e[25]!==I?(L=t.jsx(Qf,{hidden:I,className:"size-5"}),e[25]=I,e[26]=L):L=e[26];let K;e[27]!==I||e[28]!==R||e[29]!==D||e[30]!==V||e[31]!==L||e[32]!==N?(K=t.jsx("button",{type:"button",className:R,"aria-label":D,"aria-pressed":I,title:N,onClick:V,children:L}),e[27]=I,e[28]=R,e[29]=D,e[30]=V,e[31]=L,e[32]=N,e[33]=K):K=e[33];let F;e[34]!==_||e[35]!==K||e[36]!==O?(F=t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/70 px-3 text-foreground",children:[O,_,K]}),e[34]=_,e[35]=K,e[36]=O,e[37]=F):F=e[37];let U;e[38]!==u||e[39]!==i||e[40]!==w||e[41]!==o||e[42]!==I||e[43]!==M||e[44]!==h||e[45]!==m||e[46]!==s||e[47]!==b||e[48]!==g||e[49]!==j||e[50]!==y?(U=t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:o?y==="nested_repository"?t.jsx(dt,{icon:!0,message:j("diffView.unavailable.nestedRepositoryTitle"),description:j("diffView.unavailable.nestedRepositoryDescription")}):y==="untracked_directory"?t.jsx(dt,{icon:!0,message:j("diffView.unavailable.untrackedDirectoryTitle"),description:j("diffView.unavailable.untrackedDirectoryDescription")}):w?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:j("mobile.changes.diffDetail.loadFailed")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:w}),t.jsx(Ie,{type:"button",size:"sm",variant:"outline",onClick:()=>m?.(),children:j("diffView.actions.retry")})]})}):i?i.submodule?t.jsx("div",{className:"p-3",children:t.jsx(Yf,{state:i.submodule,staged:g})}):i.isBinary?t.jsx(dt,{icon:!0,message:j("diffView.binary.unavailable")}):Dd(s)&&!i.fileDiff?t.jsx(dt,{icon:!0,message:j("mobile.changes.diffDetail.imageUnavailable")}):t.jsx(wr,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:t.jsx(ym,{original:i.original,modified:i.modified,fileDiff:i.fileDiff,language:M,fileName:s,renderSideBySide:!1,wrapLines:!0,hideWhitespace:I,layout:"inline",onExpandContextRequest:h,pendingContextExpansion:b,contextLoading:u})}):t.jsx(dt,{loading:!0,message:j("diffView.state.loadingDiff")}):t.jsx(dt,{icon:!0,message:j("mobile.changes.diffDetail.missingTitle"),description:j("mobile.changes.diffDetail.missingDescription")})}),e[38]=u,e[39]=i,e[40]=w,e[41]=o,e[42]=I,e[43]=M,e[44]=h,e[45]=m,e[46]=s,e[47]=b,e[48]=g,e[49]=j,e[50]=y,e[51]=U):U=e[51];let Q;return e[52]!==F||e[53]!==U?(Q=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[F,U]}),e[52]=F,e[53]=U,e[54]=Q):Q=e[54],Q},ua=n=>{const e=fe.c(12),{files:s,onSelect:r}=n,{t:i}=xe();let l;e[0]!==i?(l=i("gitView.changes.changedFilesAria"),e[0]=i,e[1]=l):l=e[1];let o;if(e[2]!==s||e[3]!==r||e[4]!==i){let f;e[6]!==r||e[7]!==i?(f=p=>{const m=p.status==="A"?i("diffView.change.new"):p.status==="D"?i("diffView.change.deleted"):p.status==="R"?i("diffView.change.renamed"):p.status==="C"?i("diffView.change.copied"):i("diffView.change.modified"),h=p.status==="A"?"var(--status-success)":p.status==="D"?"var(--status-error)":p.status==="R"||p.status==="C"?"var(--status-info)":"var(--status-warning)";return t.jsx("li",{children:t.jsxs(Ie,{variant:"ghost",size:"lg",className:"w-full justify-start gap-2.5 text-start normal-case",onClick:()=>r(p.path),children:[t.jsx("span",{className:"w-4 shrink-0 text-center typography-meta font-semibold uppercase",style:{color:h},"aria-label":m,children:p.status}),t.jsx(Ja,{filePath:p.path,className:"size-4 shrink-0"}),t.jsx(ol,{path:p.path,className:"flex-1 typography-ui-label"}),(p.insertions>0||p.deletions>0)&&t.jsxs("span",{className:"shrink-0 typography-meta text-muted-foreground",children:["+",p.insertions," -",p.deletions]}),t.jsx(Y,{name:"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground"})]})},p.path)},e[6]=r,e[7]=i,e[8]=f):f=e[8],o=s.map(f),e[2]=s,e[3]=r,e[4]=i,e[5]=o}else o=e[5];let a;return e[9]!==l||e[10]!==o?(a=t.jsx(wr,{className:"h-full overflow-y-auto overflow-x-hidden px-3 py-2",children:t.jsx("ul",{"aria-label":l,className:"flex flex-col gap-1",children:o})}),e[9]=l,e[10]=o,e[11]=a):a=e[11],a};function eg(n){return n.diffHideWhitespace}function tg(n){return n.setDiffHideWhitespace}const sg=d.lazy(()=>Xs(()=>import("./FilesView-BFi9HBg1.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,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129])).then(n=>({default:n.FilesView}))),Bt=n=>_n(n)??"",Cn=n=>{const e=Bt(n);return!e||e==="/"?e||"/":e.split("/").filter(Boolean).at(-1)??e},ng=n=>{const e=Bt(n);if(!e||e==="/")return null;const s=e.lastIndexOf("/");return s<=0?e.startsWith("/")?"/":null:e.slice(0,s)},rg=(n,e)=>{const s=Bt(n),r=Bt(e);return!r||s===r?Cn(s):s.startsWith(`${r}/`)?s.slice(r.length+1):s},ig=n=>{if(typeof n!="number"||!Number.isFinite(n)||n<0)return"";if(n<1024)return`${n} B`;const e=["KB","MB","GB"];let s=n/1024;for(const r of e){if(s<1024||r===e[e.length-1])return`${s.toFixed(s>=10?0:1)} ${r}`;s/=1024}return""},og=n=>{const e=fe.c(5),{onClose:s,visible:r}=n,i=r===void 0?!0:r,l=el(),o=Bt(qa(l,Ha()));if(l?.kind==="preparing"){let f;return e[0]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx(tl,{}),e[0]=f):f=e[0],f}let a;return e[1]!==s||e[2]!==o||e[3]!==i?(a=t.jsx(ag,{root:o,onClose:s,visible:i},o),e[1]=s,e[2]=o,e[3]=i,e[4]=a):a=e[4],a},ag=({root:n,onClose:e,visible:s})=>{const{t:r}=xe(),{files:i}=vr(),l=fc(),o=mc(k=>k.setSelectedPath),[a,f]=d.useState(()=>({type:"browser",directory:n})),[p,m]=d.useState([]),[h,b]=d.useState(!1),[u,g]=d.useState(null),[y,w]=d.useState(""),[j,S]=d.useState([]),[M,I]=d.useState(!1),E=d.useRef(0),C=a.type==="browser"?a.directory:a.returnDirectory,N=d.useRef(C);N.current=C;const v=d.useCallback(async(k,q)=>{if(!k)return;const G=!l,Z=E.current+1;E.current=Z,b(!0),q?.background||g(null);try{const me=await i.listDirectory(k,{respectGitignore:G});if(E.current!==Z)return;g(null),m(me.entries.slice().sort((ue,X)=>ue.isDirectory!==X.isDirectory?ue.isDirectory?-1:1:ue.name.localeCompare(X.name)))}catch(me){if(E.current!==Z)return;if(q?.background){console.error("Failed to reload mobile directory:",me);return}m([]),g(me instanceof Error?me.message:r("mobile.files.error.listFailed"))}finally{E.current===Z&&b(!1)}},[i,l,r]);d.useEffect(()=>{a.type==="browser"&&v(a.directory)},[v,a]);const T=d.useRef(a);T.current=a;const O=d.useRef(p);O.current=p;const B=d.useCallback(({directories:k})=>{const q=T.current;q.type==="browser"&&(k&&!k.some(G=>Bt(G)===Bt(q.directory))||O.current.length>Xu||v(q.directory,{background:!0}))},[v]);Ju({root:n,active:s,whileInactive:"hold",onChanges:B});const z=d.useCallback(async k=>{Bt(k)===Bt(N.current)&&await v(N.current)},[v]),{canUpload:_,uploadingDirectory:A,pickFiles:R,uploadElements:D}=Yu({root:n,refreshDirectory:z}),V=A!==null;d.useEffect(()=>{if(a.type!=="browser")return;const k=y.trim();if(!k){S([]),I(!1);return}let q=!1;const G=window.setTimeout(()=>{I(!0),i.search({directory:a.directory,query:k,maxResults:40}).then(Z=>{q||S(Z)}).catch(()=>{q||S([])}).finally(()=>{q||I(!1)})},250);return()=>{q=!0,window.clearTimeout(G)}},[i,y,a]);const L=k=>{w(""),f({type:"browser",directory:k})},K=k=>{o(n,k),f({type:"file",path:k,returnDirectory:C||n})},F=Ve(k=>k.pendingFileFocusPath),U=Ve(k=>k.pendingFileNavigation);if(d.useEffect(()=>{const k=Bt(U?.path??F??"");!k||!n||(o(n,k,{allowOutsideRoot:!0}),f(q=>({type:"file",path:k,returnDirectory:q.type==="file"?q.returnDirectory:n})),F&&Ve.getState().setPendingFileFocusPath(null))},[F,U,n,o]),!n)return t.jsx(Rn,{message:r("mobile.files.empty.noDirectory")});if(a.type==="file")return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/70 px-3 text-foreground",children:[t.jsx("button",{type:"button",className:"-ms-1 flex size-10 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-ring","aria-label":r("header.actions.backAria"),onClick:()=>f({type:"browser",directory:a.returnDirectory}),style:{touchAction:"manipulation"},children:t.jsx(Ro,{className:"size-5"})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:Cn(a.path)})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(st,{children:t.jsx(d.Suspense,{fallback:t.jsx(Rn,{loading:!0,message:r("filesView.state.loading")}),children:t.jsx(sg,{mode:"editor-only"})})})})]});const Q=a.directory===n?r("mobile.files.rootDirectory"):Cn(a.directory),le=y.trim()?j:[],ce=ng(a.directory),oe=a.directory!==n&&ce!==null&&(ce===n||ce.startsWith(`${n}/`)),re=oe&&!y.trim(),ie=oe?ce:null;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[D,t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[e?t.jsx("button",{type:"button",className:"-ms-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-ring","aria-label":r("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(Pf,{className:"size-5"})}):null,re&&ie?t.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-ring","aria-label":r("mobile.files.backToParentAria",{name:Cn(ie)}),onClick:()=>L(ie),style:{touchAction:"manipulation"},children:t.jsx(Ro,{className:"size-5"})}):null,t.jsx("div",{className:"min-w-0 flex-1 px-1",children:t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:Q})}),t.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-ring","aria-label":r("mobile.files.refreshAria"),onClick:()=>{v(a.directory)},style:{touchAction:"manipulation"},children:t.jsx(Df,{className:se("size-5",h&&"animate-spin")})}),_?t.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-ring disabled:opacity-50","aria-label":r("sidebarFilesTree.actions.uploadFilesTitle"),onClick:()=>R(a.directory),disabled:V,style:{touchAction:"manipulation"},children:t.jsx(Y,{name:V?"loader-4":"upload-2",className:se("size-5",V&&"animate-spin")})}):null]}),t.jsx("div",{className:"shrink-0 px-4 pb-2 pt-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(Mf,{className:"pointer-events-none absolute inset-s-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx($a,{value:y,onChange:k=>w(k.target.value),placeholder:r("mobile.files.search.placeholder"),className:"h-11 ps-9"})]})}),t.jsx(wr,{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-3",children:u?t.jsx(Rn,{message:u}):y.trim()?t.jsx(lg,{root:n,results:le,isSearching:M,onOpenFile:K}):t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:[p.length===0&&!h?t.jsx("div",{className:"px-4 py-8 text-center typography-ui-label text-muted-foreground",children:r("mobile.files.empty.directory")}):null,p.map(k=>t.jsx(ql,{name:k.name,path:k.path,directory:k.isDirectory,meta:k.isDirectory?void 0:ig(k.size),onClick:()=>k.isDirectory?L(k.path):K(k.path)},k.path))]})})]})},ql=n=>{const e=fe.c(16),{name:s,path:r,directory:i,meta:l,onClick:o}=n;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={touchAction:"manipulation"},e[0]=a):a=e[0];let f;e[1]!==i||e[2]!==r?(f=i?t.jsx(zf,{className:"size-5 shrink-0 text-primary/80"}):t.jsx(Ja,{filePath:r,className:"size-5 shrink-0"}),e[1]=i,e[2]=r,e[3]=f):f=e[3];let p;e[4]!==s?(p=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:s}),e[4]=s,e[5]=p):p=e[5];let m;e[6]!==l?(m=l?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:l}):null,e[6]=l,e[7]=m):m=e[7];let h;e[8]!==i?(h=i?t.jsx(Bf,{className:"size-4 shrink-0 text-muted-foreground/60"}):null,e[8]=i,e[9]=h):h=e[9];let b;return e[10]!==o||e[11]!==f||e[12]!==p||e[13]!==m||e[14]!==h?(b=t.jsxs("button",{type:"button",className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3 py-2.5 text-start transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:o,style:a,children:[f,p,m,h]}),e[10]=o,e[11]=f,e[12]=p,e[13]=m,e[14]=h,e[15]=b):b=e[15],b},lg=n=>{const e=fe.c(17),{root:s,results:r,isSearching:i,onOpenFile:l}=n,{t:o}=xe();if(i){let p;e[0]!==o?(p=o("common.loading"),e[0]=o,e[1]=p):p=e[1];let m;return e[2]!==p?(m=t.jsx(Rn,{loading:!0,message:p}),e[2]=p,e[3]=m):m=e[3],m}if(r.length===0){let p;e[4]!==o?(p=o("mobile.files.search.empty"),e[4]=o,e[5]=p):p=e[5];let m;return e[6]!==p?(m=t.jsx(Rn,{message:p}),e[6]=p,e[7]=m):m=e[7],m}let a;if(e[8]!==l||e[9]!==r||e[10]!==s){let p;e[12]!==l||e[13]!==s?(p=m=>t.jsx(ql,{name:Cn(m.path),path:m.path,directory:!1,meta:rg(m.path,s),onClick:()=>l(m.path)},m.path),e[12]=l,e[13]=s,e[14]=p):p=e[14],a=r.map(p),e[8]=l,e[9]=r,e[10]=s,e[11]=a}else a=e[11];let f;return e[15]!==a?(f=t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:a}),e[15]=a,e[16]=f):f=e[16],f},Rn=n=>{const e=fe.c(7),{message:s,loading:r}=n,i=r===void 0?!1:r;let l;e[0]!==i?(l=i?t.jsx(_f,{className:"size-5 animate-spin text-muted-foreground"}):t.jsx(Of,{className:"size-6 text-muted-foreground"}),e[0]=i,e[1]=l):l=e[1];let o;e[2]!==s?(o=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==l||e[5]!==o?(a=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[l,o]})}),e[4]=l,e[5]=o,e[6]=a):a=e[6],a},fa="mobile-surface-root",cg=16,ma=320,dg="cubic-bezier(0.22, 1, 0.36, 1)",ug=n=>{const e=fe.c(38),{onOpenMcpSettings:s,active:r}=n,{t:i}=xe(),[l,o]=d.useState(!1),a=Ka(!1),f=$s(mg),p=Ks(pg);let m;e[0]!==a||e[1]!==l||e[2]!==p||e[3]!==f?(m=()=>{if(l||!a)return;o(!0);const z=new Promise(hg);Promise.all([f({directory:a,silent:!0}),p({force:!0,directory:a}),z]).finally(()=>o(!1))},e[0]=a,e[1]=l,e[2]=p,e[3]=f,e[4]=m):m=e[4];const h=m;let b;e[5]!==i?(b=i("settings.mcp.sidebar.actions.addServerTitle"),e[5]=i,e[6]=b):b=e[6];let u;e[7]!==i?(u=i("settings.mcp.sidebar.actions.addServerTitle"),e[7]=i,e[8]=u):u=e[8];let g,y;e[9]===Symbol.for("react.memo_cache_sentinel")?(g={touchAction:"manipulation"},y=t.jsx(Y,{name:"add",className:"size-5"}),e[9]=g,e[10]=y):(g=e[9],y=e[10]);let w;e[11]!==s||e[12]!==b||e[13]!==u?(w=t.jsx("button",{type:"button",className:"flex size-10 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-ring",onClick:s,"aria-label":b,title:u,style:g,children:y}),e[11]=s,e[12]=b,e[13]=u,e[14]=w):w=e[14];const j=l||!a;let S;e[15]!==i?(S=i("mcpDropdown.actions.refreshAria"),e[15]=i,e[16]=S):S=e[16];let M;e[17]!==i?(M=i("mcpDropdown.actions.refreshAria"),e[17]=i,e[18]=M):M=e[18];let I;e[19]===Symbol.for("react.memo_cache_sentinel")?(I={touchAction:"manipulation"},e[19]=I):I=e[19];const E=l&&"animate-spin";let C;e[20]!==E?(C=se("size-5",E),e[20]=E,e[21]=C):C=e[21];let N;e[22]!==C?(N=t.jsx(Y,{name:"refresh",className:C}),e[22]=C,e[23]=N):N=e[23];let v;e[24]!==h||e[25]!==N||e[26]!==j||e[27]!==S||e[28]!==M?(v=t.jsx("button",{type:"button",className:"flex size-10 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:h,disabled:j,"aria-label":S,title:M,style:I,children:N}),e[24]=h,e[25]=N,e[26]=j,e[27]=S,e[28]=M,e[29]=v):v=e[29];let T;e[30]!==v||e[31]!==w?(T=t.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-1 px-2 pt-1",children:[w,v]}),e[30]=v,e[31]=w,e[32]=T):T=e[32];let O;e[33]!==r?(O=t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(Uh,{active:r,className:"h-full",listClassName:"max-h-none",hideHeader:!0,mobileListDensity:!0})}),e[33]=r,e[34]=O):O=e[34];let B;return e[35]!==T||e[36]!==O?(B=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[T,O]}),e[35]=T,e[36]=O,e[37]=B):B=e[37],B},fg=({open:n,onClose:e,tab:s,onTabChange:r,pendingChangesDiff:i,onOpenPlan:l,onOpenMcpSettings:o,variant:a="drawer"})=>{const{t:f,direction:p}=xe(),m=d.useRef(null),h=d.useRef(null),[b,u]=d.useState(!1),[g,y]=d.useState(n),w=d.useRef(e);d.useEffect(()=>{w.current=e},[e]);const j=Ve(A=>A.mobileWorkspaceTabOrder),S=Ve(A=>A.mobileWorkspaceHiddenTabs),M=Ve(A=>A.setMobileWorkspaceTabOrder),I=d.useRef(s);d.useEffect(()=>{I.current=s},[s]);const E=()=>w.current();ro(h,{enabled:a==="drawer"&&n,...p==="rtl"?{onRightEdgeSwipe:E}:{onLeftEdgeSwipe:E}});const[C,N]=d.useState(()=>new Set);if(d.useEffect(()=>{n&&N(A=>{if(A.has(s))return A;const R=new Set(A);return R.add(s),R})},[n,s]),typeof document<"u"&&!m.current){let A=document.getElementById(fa);A||(A=document.createElement("div"),A.id=fa,document.body.appendChild(A)),m.current=A}if(d.useEffect(()=>{if(n){y(!0);const R=window.setTimeout(()=>u(!0),cg);return()=>window.clearTimeout(R)}u(!1);const A=window.setTimeout(()=>y(!1),ma+40);return()=>window.clearTimeout(A)},[n]),d.useEffect(()=>{if(!n)return;const A=document.body.style.overflow;a==="drawer"&&(document.body.style.overflow="hidden");const R=D=>{D.key!=="Escape"||I.current==="terminal"||Bd(D.target)||Mi(D)||w.current()};return document.addEventListener("keydown",R),()=>{a==="drawer"&&(document.body.style.overflow=A),document.removeEventListener("keydown",R)}},[n,a]),a==="drawer"&&!m.current)return null;const v={changes:{id:"changes",label:f("mobile.menu.git"),icon:t.jsx(Y,{name:"git-branch",className:"h-3.5 w-3.5"})},files:{id:"files",label:f("mobile.menu.files"),icon:t.jsx(Y,{name:"file-text",className:"h-3.5 w-3.5"})},terminal:{id:"terminal",label:f("mobile.menu.terminal"),icon:t.jsx(Y,{name:"terminal",className:"h-3.5 w-3.5"})},notes:{id:"notes",label:f("contextRail.surface.notes"),icon:t.jsx(Y,{name:"sticky-note",className:"h-3.5 w-3.5"})},mcp:{id:"mcp",label:f("mobile.menu.mcp"),icon:t.jsx(Ld,{className:"h-3.5 w-3.5"})}},T=pc(j,S,s),O=T.map(A=>v[A]),B=O.length===1?O[0]:null,z=(A,R)=>{const D=hc(j),V=D.findIndex(K=>K===A),L=D.findIndex(K=>K===R);V<0||L<0||M(Lf(D,V,L))},_=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",children:[t.jsx("div",{className:"flex h-9 min-w-0 flex-1 items-center",children:B?t.jsxs("h2",{className:"flex min-w-0 items-center gap-2 px-1 typography-ui-header font-semibold text-foreground",children:[t.jsx("span",{className:"flex shrink-0 text-muted-foreground",children:B.icon}),t.jsx("span",{className:"truncate",children:B.label})]}):g?t.jsx(zd,{items:O,activeId:s,onSelect:A=>{const R=T.find(D=>D===A);R&&r(R)},onReorder:z,layoutMode:"fit",variant:"active-pill",nonCompositedIndicator:!0,inactiveTabsIconOnly:O.length>3,className:"h-full"}):null}),t.jsx("button",{type:"button",className:"-me-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-ring","aria-label":f("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"close",className:"size-5"})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[C.has("changes")?t.jsx("div",{className:se("h-full",s!=="changes"&&"hidden"),children:t.jsx(st,{children:t.jsx(Qh,{visible:n&&s==="changes",initialDiff:i,onNavigatedToChat:e})})},i?`changes:${i.path}:${i.staged}`:"changes"):null,C.has("files")?t.jsx("div",{className:se("h-full",s!=="files"&&"hidden"),children:t.jsx(st,{children:t.jsx(og,{visible:n&&s==="files"})})}):null,C.has("terminal")?t.jsx("div",{className:se("h-full",s!=="terminal"&&"hidden"),children:t.jsx(st,{children:t.jsx(Qu,{visible:n&&s==="terminal"})})}):null,C.has("notes")?t.jsx("div",{className:se("h-full",s!=="notes"&&"hidden"),children:t.jsx(st,{children:t.jsx(Zu,{visible:n&&s==="notes",onActionComplete:e,onOpenPlan:l})})}):null,C.has("mcp")?t.jsx("div",{className:se("h-full",s!=="mcp"&&"hidden"),children:t.jsx(st,{children:t.jsx(ug,{active:n&&s==="mcp",onOpenMcpSettings:o})})}):null]})]});return a==="panel"?t.jsx("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:_}):Hs.createPortal(t.jsx("section",{ref:h,role:"dialog","aria-modal":"true","aria-label":f("mobile.header.openWorkspaceAria"),"aria-hidden":!n,className:"oc-keyboard-inset-surface oc-bottom-safe-surface fixed inset-0 z-50 flex flex-col bg-background text-foreground",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:b?"none":p==="rtl"?"translateX(-100%)":"translateX(100%)",transition:`transform ${ma}ms ${dg}`,visibility:g?"visible":"hidden",pointerEvents:n?"auto":"none"},children:_}),m.current)};function mg(n){return n.refresh}function pg(n){return n.loadMcpConfigs}function hg(n){return window.setTimeout(n,500)}function gg(n){const e=fe.c(4),s=2500,{uiFont:r}=Fd(),[i,l]=d.useState(!1);let o,a;return e[0]!==s||e[1]!==r?(o=()=>{let f=!1;const p=()=>{f||l(!0)},m=()=>{requestAnimationFrame(()=>requestAnimationFrame(p))},h=Promise.all([$d(r).catch(wg),document.fonts?.ready?.then(vg).catch(yg)??Promise.resolve(),wm.catch(xg)]).then(bg),b=new Promise(u=>{window.setTimeout(u,s)});return Promise.race([h,b]).then(m),()=>{f=!0}},a=[r,s],e[0]=s,e[1]=r,e[2]=o,e[3]=a):(o=e[2],a=e[3]),d.useEffect(o,a),i}function bg(){}function xg(){}function yg(){}function vg(){}function wg(){}const jg=al({projectId:To().trim().min(1).optional(),text:To().optional()}),kg=al({request:jg.nullish()}),Hl=sl("ShortcutRequests"),Sg=async()=>{const n=kg.safeParse(await Hl.takePending());return n.success?n.data.request??null:null},Ng=n=>{if(Ii()!=="ios")return()=>{};let e=!1,s=null;const r=()=>{Sg().then(i=>{i&&n(i)}).catch(()=>{})};return Hl.addListener("pending",r).then(i=>{if(e){i.remove();return}s=i}).catch(()=>{}),r(),()=>{e=!0,s?.remove()}},Cg="openchamber",Rg=n=>n.replace(/^\/+|\/+$/g,""),Ig=n=>{const e=Rg(n.pathname).split("/").filter(Boolean);return n.host?[n.host,...e]:e};function Eg(n){if(typeof n!="string"||n.length===0)return null;let e;try{e=new URL(n)}catch{return null}if(e.protocol!==`${Cg}:`)return null;const s=Ig(e),r=(s[0]??"").toLowerCase(),i=s.slice(1),l=e.searchParams;switch(r){case"session":{const o=i[0]||l.get("id")||"";if(!o)return null;const a=l.get("message")?.trim()??"";return{type:"session",sessionId:o,directory:l.get("dir")??void 0,...Wd(a)?{messageId:a}:{}}}case"new":case"new-session":return{type:"new-session",directory:l.get("dir")??void 0,projectId:l.get("project")??void 0,agent:l.get("agent")??void 0,model:l.get("model")??void 0};case"sessions":{const o=l.get("filter");return{type:"sessions",filter:o==="attention"||o==="recent"||o==="all"?o:void 0}}case"status":return{type:"status"};case"settings":return{type:"settings",section:i[0]||l.get("section")||void 0};case"changes":return{type:"changes",path:i.join("/")||l.get("path")||void 0,staged:l.get("staged")==="true"};case"view":{const o=(i[0]||"").toLowerCase();return o==="changes"?{type:"changes"}:o==="files"||o==="mcp"||o==="instances"||o==="update"?{type:"view",target:o}:null}default:return null}}let vt={},Xl=!1,Sn=null;const Ag=n=>{const e=$e.getState(),s=n.projectId?ut.getState().projects.find(i=>i.id===n.projectId)??null:null;e.openNewSessionDraft(s?{selectedProjectId:s.id}:void 0);const r=n.text?.trim();if(r){if(n.projectId&&!s){No.getState().setPendingInputText(r,"append");return}No.getState().requestDraftSubmit($e.getState().newSessionDraft.draftId,r)}},Tg=n=>{switch(n.type){case"shortcut-new-session":return Ag(n),!0;case"session":return n.messageId&&!n.directory?(Vd(n.sessionId,n.messageId),!0):(n.messageId&&Ud(n.sessionId,n.messageId),$e.getState().setCurrentSession(n.sessionId,n.directory??null),!0);case"new-session":{const e=$e.getState();return e.openNewSessionDraft(),(n.directory||n.projectId)&&e.setNewSessionDraftTarget({directoryOverride:n.directory??null,projectId:n.projectId??null,selectedProjectId:n.projectId??null}),!0}case"sessions":return vt.openSessions?(vt.openSessions(n.filter),!0):!1;case"status":return vt.openSessions?(vt.openSessions(),!0):!1;case"view":return vt.openView?(vt.openView(n.target),!0):!1;case"changes":return vt.openChanges?(vt.openChanges({path:n.path,staged:n.staged}),!0):!1;case"settings":return vt.openSettings?(vt.openSettings(n.section),!0):!1}},io=()=>{if(!Xl||!Sn)return;const n=Sn;Sn=null,Tg(n)||(Sn=n)},Ri=n=>{Sn=n,io()},pa=n=>{const e=Eg(n);e&&Ri(e)},Pg=n=>{Xl=n,io()},Dg=n=>{const e=fe.c(3);let s,r;e[0]!==n?(s=()=>(vt=n,io(),()=>{vt===n&&(vt={})}),r=[n],e[0]=n,e[1]=s,e[2]=r):(s=e[1],r=e[2]),d.useEffect(s,r)},Mg=n=>{const{ready:e}=n;d.useEffect(()=>{Pg(e)},[e]),d.useEffect(()=>{if(!nt())return;let s=!1;const r=[];return Xs(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([130,5,55])).then(async({App:i})=>{if(s)return;const l=await i.addListener("appUrlOpen",o=>{pa(o?.url)});if(s){l.remove();return}r.push(()=>{l.remove()})}).catch(()=>{}),r.push(Ng(i=>{Ri({type:"shortcut-new-session",projectId:i.projectId,text:i.text})})),Xs(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([131,55])).then(async({PushNotifications:i})=>{if(s)return;const l=await i.addListener("pushNotificationActionPerformed",o=>{const a=o?.notification?.data,f=typeof a?.url=="string"?a.url:typeof a?.deeplink=="string"?a.deeplink:void 0;if(f){pa(f);return}const p=typeof a?.sessionId=="string"?a.sessionId:void 0;p&&Ri({type:"session",sessionId:p})});if(s){l.remove();return}r.push(()=>{l.remove()})}).catch(()=>{}),()=>{s=!0,r.forEach(i=>i())}},[])},_g=()=>{if(typeof window>"u")return;const n=window.__OPENCHAMBER_APNS_ENV__;if(n==="development")return"sandbox";if(n==="production")return"production"},ha=/^[A-Za-z0-9+/]{43}=$/,Og=sl("PushKey"),zg=async()=>{const n=window.__OPENCHAMBER_PUSH_KEY__;if(n&&ha.test(n))return n;const e=await Og.get().then(s=>s.key).catch(()=>{});return e&&ha.test(e)?e:void 0},Bg=()=>{if(typeof window>"u")return!1;const e=window.Capacitor?.getPlatform?.();return e==="ios"||e==="android"},Lg=n=>{const{enabled:e}=n,s=Ve(i=>i.nativeNotificationsEnabled),r=d.useRef(null);d.useEffect(()=>{if(!e||!s||!Bg())return;let i=!1;const l=[];return Xs(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([131,55])).then(async({PushNotifications:o})=>{if(i)return;let a=await o.checkPermissions().catch(()=>null);if(a?.receive!=="granted"&&(a=await o.requestPermissions().catch(()=>null)),a?.receive!=="granted")return;const f=await o.addListener("registration",m=>{r.current=m.value,zg().then(h=>{const b=yo(),u={token:m.value,platform:Ii(),environment:_g()};h&&(u.pushKey=h),b?.push?.registerApnsToken?.(u)})}),p=await o.addListener("registrationError",m=>{console.warn("[Push] APNs registration error:",m)});if(await o.register().catch(()=>{}),i){f.remove(),p.remove();return}l.push(()=>{f.remove()},()=>{p.remove()})}).catch(()=>{}),()=>{i=!0,l.forEach(o=>o())}},[e,s]),d.useEffect(()=>{if(s)return;const i=r.current;if(!i)return;r.current=null,yo()?.push?.unregisterApnsToken?.({token:i})},[s])},ga=n=>{const e=fe.c(12),{side:s,isResizing:r,ariaLabel:i,handleProps:l}=n,o=s==="left"?"inset-e-0":"inset-s-0";let a;e[0]!==o?(a=se("absolute inset-y-0 z-50 w-6 cursor-col-resize touch-none",o),e[0]=o,e[1]=a):a=e[1];const f=s==="left"?"inset-e-0":"inset-s-0",p=r&&"bg-[var(--interactive-border)]";let m;e[2]!==f||e[3]!==p?(m=se("absolute inset-y-0 w-[3px] transition-colors",f,p),e[2]=f,e[3]=p,e[4]=m):m=e[4];let h;e[5]!==m?(h=t.jsx("div",{className:m}),e[5]=m,e[6]=h):h=e[6];let b;return e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==h?(b=t.jsx("div",{className:a,role:"separator","aria-orientation":"vertical","aria-label":i,...l,children:h}),e[7]=i,e[8]=l,e[9]=a,e[10]=h,e[11]=b):b=e[11],b},Fg=320,$g=380,ba=280,Wg=560,Vg=900;function xa(n,e,s,r){const i=fe.c(23),l=r===void 0?Wg:r,o=d.useRef(null);let a;i[0]!==s||i[1]!==l||i[2]!==e?(a=()=>{if(typeof window>"u")return s;const _=Number.parseInt(window.localStorage.getItem(e)??"",10);return Number.isFinite(_)?Math.min(l,Math.max(ba,_)):s},i[0]=s,i[1]=l,i[2]=e,i[3]=a):a=i[3];const[f,p]=d.useState(a),[m,h]=d.useState(!1),b=d.useRef(0),u=d.useRef(f),g=d.useRef(null),y=d.useRef(null);let w;i[4]!==l?(w=_=>Math.min(l,Math.max(ba,Math.round(_))),i[4]=l,i[5]=w):w=i[5];const j=w;let S;i[6]===Symbol.for("react.memo_cache_sentinel")?(S=_=>{const A=o.current;A&&(A.style.width=`${_}px`,A.style.minWidth=`${_}px`,A.style.maxWidth=`${_}px`,A.style.setProperty("--oc-ipad-sidebar-width",`${_}px`))},i[6]=S):S=i[6];const M=S;let I;i[7]!==f?(I=_=>{try{_.currentTarget.setPointerCapture(_.pointerId)}catch{}y.current=_.pointerId,b.current=_.clientX,u.current=f,g.current=f,h(!0),_.preventDefault()},i[7]=f,i[8]=I):I=i[8];const E=I;let C;i[9]!==j||i[10]!==n?(C=_=>{if(y.current!==_.pointerId)return;const A=(n==="left"?1:-1)*(gc(_.currentTarget)?-1:1),R=j(u.current+(_.clientX-b.current)*A);g.current!==R&&(g.current=R,M(R))},i[9]=j,i[10]=n,i[11]=C):C=i[11];const N=C;let v;i[12]!==j||i[13]!==e?(v=_=>{if(y.current!==_.pointerId)return;try{_.currentTarget.releasePointerCapture(_.pointerId)}catch{}const A=j(g.current??u.current);y.current=null,g.current=null,h(!1),p(A);try{window.localStorage.setItem(e,String(A))}catch{}},i[12]=j,i[13]=e,i[14]=v):v=i[14];const T=v;let O;i[15]!==E||i[16]!==T||i[17]!==N?(O={onPointerDown:E,onPointerMove:N,onPointerUp:T,onPointerCancel:T},i[15]=E,i[16]=T,i[17]=N,i[18]=O):O=i[18];const B=O;let z;return i[19]!==B||i[20]!==m||i[21]!==f?(z={asideRef:o,width:f,isResizing:m,handleProps:B},i[19]=B,i[20]=m,i[21]=f,i[22]=z):z=i[22],z}const Ug=["general","isolated-spaces","appearance","chat","notifications","sessions","routing","git","magic-prompts","snippets","behavior","agents","commands","mcp","plugins","skills.installed","skills.catalog","providers","web-search","usage","voice","integrations","about"],Gg=1e3,Kg=({onActiveConnectionDeleted:n})=>{const{t:e,direction:s}=xe();pf();const[r,i]=d.useState(!1);d.useEffect(()=>$e.subscribe((H,ee)=>{H.currentSessionId&&H.currentSessionId!==ee.currentSessionId&&Ve.getState().setRunOverviewKey(null)}),[]);const l=Ve(H=>H.runOverviewKey!==null);d.useEffect(()=>{l&&i(!1)},[l]);const[o,a]=d.useState(null),[f,p]=d.useState(!1),[m,h]=d.useState("changes"),b=d.useCallback(()=>{const{mobileWorkspaceTabOrder:H,mobileWorkspaceHiddenTabs:ee}=Ve.getState(),ve=xc(H,ee);h(ge=>ve.includes(ge)?ge:ve[0]),p(!0)},[]),[u,g]=d.useState(null),[y,w]=d.useState("nav"),[j,S]=d.useState(null),M=Ve(H=>H.setSettingsPage),I=Ve(H=>H.wideChatLayoutEnabled),E=Us(H=>H.available),C=Us(H=>H.runtimeType),N=d.useMemo(()=>_i(),[]),v=Ks(H=>H.mcpServers),T=Ks(H=>H.setMcpDraft),O=Ks(H=>H.setSelectedMcp),B=d.useCallback(()=>{a(null),g(null)},[]),z=d.useCallback(H=>{a(H)},[]),_=d.useCallback(()=>{p(!1)},[]),A=d.useCallback(H=>{w(H),z("settings")},[z]),{enabled:R,roomyForPanels:D}=Ei(),L=au()==="portrait",K=lu(),[F,U]=d.useState(()=>cu().roomyForPanels),Q=d.useCallback(()=>{U(H=>!H)},[]);d.useEffect(()=>{R||U(!1)},[R]);const le=d.useCallback(()=>{S(null),h("files"),p(!0)},[]);d.useEffect(()=>xi(H=>{if(H.type!=="file-open-request")return;const ee=H.directory??ws.getState().currentDirectory;ee&&(Ve.getState().openContextFile(ee,H.path),le())}),[le]),d.useEffect(()=>xi(H=>{if(H.type!=="plan-open-request")return;const ee=hf(H.directory??ws.getState().currentDirectory,H.projectId);ee&&g({id:H.planId,title:H.title,projectRef:ee})}),[]);const ce=d.useCallback((H=null)=>{S(H),h("changes"),p(!0)},[]),oe=xa("left","openchamber.ipad.leftSidebarWidth",Fg),re=xa("right","openchamber.ipad.rightSidebarWidth",$g,Vg),ie=D,k=ie&&f?re.width:0,q=R&&F?oe.width:0;d.useEffect(()=>{if(typeof document>"u")return;const H=document.documentElement;return H.style.setProperty("--oc-chat-inset-left",`${q}px`),H.style.setProperty("--oc-chat-inset-right",`${k}px`),()=>{H.style.removeProperty("--oc-chat-inset-left"),H.style.removeProperty("--oc-chat-inset-right")}},[q,k]),d.useEffect(()=>{if(typeof document>"u")return;const H=document.documentElement;return H.classList.toggle("wide-chat-layout",I),()=>H.classList.remove("wide-chat-layout")},[I]),d.useEffect(()=>{if(typeof document>"u")return;const H=R&&(L||K),ee=document.documentElement;return ee.classList.toggle("oc-keep-draft-starters",H),()=>ee.classList.remove("oc-keep-draft-starters")},[K,R,L]);const G=d.useMemo(()=>({openChanges:({diffPath:H,staged:ee}={})=>{ce(H?{path:H,staged:ee===!0}:null)},openFiles:()=>le(),openSettings:()=>A("nav"),openSourceBoard:()=>z("board")}),[ce,le,A,z]),Z=d.useMemo(()=>({openSessions:()=>{R?U(!0):i(!0)},openView:H=>{if(H==="files"){le();return}if(H==="mcp"){h("mcp"),p(!0);return}z(H)},openChanges:({path:H,staged:ee}={})=>{ce(H?{path:H,staged:ee===!0}:null)},openSettings:H=>{H&&M(H),A(H?"page-content":"nav")}}),[R,ce,le,A,z,M]);Dg(Z);const me=d.useRef(null),ue=()=>{R?U(!0):i(!0)},X=()=>b();ro(me,{onLeftEdgeSwipe:s==="rtl"?X:ue,onRightEdgeSwipe:s==="rtl"?ue:X});const de=d.useRef(null),we=d.useCallback(H=>{de.current=H},[]),Se=d.useCallback(()=>du()?!0:u?(g(null),!0):o==="settings"&&de.current?.()?!0:o?(B(),!0):f?(_(),!0):r?(i(!1),!0):!1,[o,B,_,u,r,f]);uu(Se);const be=!N&&E&&(C==="desktop"||C==="web"),ye=R?"dialog":"fullscreen",Te=d.useMemo(()=>({instanceLabel:N?bs():null,onOpenInstances:N?()=>z("instances"):void 0,onOpenSettings:()=>A("nav"),onOpenUsage:()=>z("usage"),onOpenScheduled:()=>z("scheduled"),onOpenArchive:()=>z("archive"),onOpenSourceBoard:()=>z("board"),onOpenUpdate:be?()=>z("update"):void 0}),[A,z,N,be]),Ee=d.useCallback(H=>{B(),i(!1),H==="file"&&le()},[B,le]),De=d.useCallback(()=>{B(),i(!1)},[B]),je=d.useCallback(()=>{B(),i(!1),R&&!D&&U(!1)},[B,R,D]),Ne=d.useCallback(()=>{const H="new-mcp-server";let ee=H,ve=1;for(;v.some(Ce=>Ce.name===ee);)ee=`${H}-${ve}`,ve+=1;T({name:ee,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",oauthCallbackPort:"",oauthAuthServerMetadataUrl:"",protocol:"legacy",timeoutStartup:"",timeoutCatalog:"",timeoutExecution:"",codemode:"default",disabled:!1}),O(ee),M("mcp"),A("page-content")},[v,A,T,O,M]);return t.jsx(fu,{actions:G,children:t.jsxs("div",{className:"oc-mobile-app-shell main-content-safe-area flex h-[100dvh] flex-row bg-background text-foreground","data-page-scroll-lock":"true",children:[R?t.jsxs("aside",{ref:oe.asideRef,className:se("relative flex h-full shrink-0 flex-col overflow-hidden border-e border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!F&&"border-e-0"),style:{width:F?oe.width:0,minWidth:F?oe.width:0,maxWidth:F?oe.width:0,"--oc-ipad-sidebar-width":`${oe.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:oe.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!F,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:se("flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",oe.isResizing&&"pointer-events-none",!F&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(st,{children:t.jsx(ia,{open:!0,variant:"sidebar",onOpenChange:H=>{!H&&!D&&U(!1)},footer:Te})})}),F?t.jsx(ga,{side:"left",isResizing:oe.isResizing,ariaLabel:e("sidebar.resize.leftPanelAria"),handleProps:oe.handleProps}):null]}):null,t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col","data-page-scroll-lock":"true",children:[t.jsx(zp,{onOpenSessions:()=>R?Q():i(!0),onOpenWorkspace:b,compactTitle:R}),t.jsxs("main",{ref:me,className:"relative min-h-0 flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[t.jsx("div",{className:"h-full w-full",children:t.jsx(st,{children:t.jsx(gf,{})})}),t.jsx(st,{children:t.jsx(Cf,{})})]})]}),R?null:t.jsx(ia,{open:r,onOpenChange:i,footer:Te}),t.jsxs("aside",{ref:re.asideRef,className:se("relative flex h-full shrink-0 flex-col overflow-hidden border-s border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!k&&"border-s-0"),style:{width:k,minWidth:k,maxWidth:k,"--oc-ipad-sidebar-width":`${re.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:re.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!k,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:se("flex h-full min-h-0 shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",re.isResizing&&"pointer-events-none",!k&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(st,{children:t.jsx(fg,{open:f,onClose:_,tab:m,onTabChange:h,pendingChangesDiff:j,onOpenPlan:g,onOpenMcpSettings:Ne,variant:ie?"panel":"drawer"})})}),k?t.jsx(ga,{side:"right",isResizing:re.isResizing,ariaLabel:e("sidebar.resize.rightPanelAria"),handleProps:re.handleProps}):null]}),u?t.jsx(Ut,{open:!0,variant:ye,onClose:()=>g(null),ariaLabel:u.title,title:u.title,children:t.jsx(st,{children:t.jsx(jf,{savedProjectPlan:{projectRef:u.projectRef,planId:u.id},onNavigatedToChat:()=>{B(),_()}})})}):null,o==="instances"&&N?t.jsx(Ut,{open:!0,variant:ye,dialogAlign:"app",onClose:B,ariaLabel:e("mobile.menu.instances"),title:e("mobile.menu.instances"),children:t.jsx(Wp,{onConnect:B,onActiveConnectionDeleted:n})}):null,o==="settings"?t.jsx(Ut,{open:!0,variant:ye,dialogAlign:"app",onClose:B,ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(st,{children:t.jsx(vf,{forceMobile:!0,isWindowed:!0,initialMobileStage:y,registerBackHandler:we,visiblePageSlugs:[...Ug],onClose:B})})}):null,o==="usage"?t.jsx(Ut,{open:!0,variant:ye,dialogAlign:"app",onClose:B,ariaLabel:e("usageStats.title"),title:e("usageStats.title"),children:t.jsx(st,{children:t.jsx($f,{})})}):null,o==="scheduled"?t.jsx(Ut,{open:!0,variant:ye,dialogAlign:"app",onClose:B,ariaLabel:e("sessions.scheduledTasks.dialog.title"),title:e("sessions.scheduledTasks.dialog.title"),children:t.jsx(st,{children:t.jsx(Uf,{layout:"mobile",onLeave:Ee})})}):null,o==="board"?t.jsx(Ut,{open:!0,variant:ye,dialogAlign:"app",onClose:B,ariaLabel:e("sourceBoard.title"),headerless:!0,children:t.jsx(st,{children:t.jsx(Vf,{onLeave:De,onClose:B})})}):null,o==="archive"?t.jsx(Ut,{open:!0,variant:ye,dialogAlign:"app",onClose:B,ariaLabel:e("sessions.archivePage.title"),title:e("sessions.archivePage.title"),children:t.jsx(st,{children:t.jsx(Wf,{layout:"mobile",onLeave:je})})}):null,o==="update"?t.jsx(Ut,{open:!0,variant:ye,dialogAlign:"app",onClose:B,ariaLabel:e("mobile.menu.update"),title:e("mobile.menu.update"),children:t.jsx(st,{children:t.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:t.jsx(wf,{initialUpdateDialogOpen:!0})})})}):null]})})};function qg({apis:n}){const e=Ve(k=>k.isolatedSpacesEnabled),{t:s}=xe(),r=wt(k=>k.initializeApp),i=wt(k=>k.isInitialized),l=wt(k=>k.isConnected),o=wt(k=>k.connectionPhase),a=wt(k=>k.providers.length),f=wt(k=>k.agents.length),p=wt(k=>k.loadProviders),m=wt(k=>k.loadAgents),h=ws(k=>k.currentDirectory),b=$e(k=>k.error),u=$e(k=>k.clearError),g=Ve(k=>k.setIsMobile),y=Xa(k=>k.refreshAll),w=Gd(k=>k.refreshStatus),j=ut(k=>k.projects),S=vs(k=>k.activeSessions),M=vs(k=>k.archivedSessions),I=vs(k=>k.status==="ready"),E=d.useMemo(()=>[...S,...M],[S,M]);ef({hasAuthoritativeGlobalSessions:I,sessions:E});const[C,N]=d.useState(0),[v,T]=d.useState(0),[O,B]=d.useState(!1),[z,_]=d.useState("pending"),[A,R]=d.useState(null),D=d.useMemo(()=>bs(),[]),[,V]=d.useReducer(k=>k+1,0),L=d.useMemo(()=>_i(),[]),K=d.useRef(0),F=d.useRef(0),U=d.useCallback(()=>{const k=Mt(),q=F.current+1;if(F.current=q,!k){bn("resume:auto-connect",{}),xn();return}bn("resume:reprobe",{});const G=()=>{r(),y(n.sourceControl,{force:!0}),w(n.linear,{force:!0}),a===0&&p({source:"mobileApp:nativeResume"}),f===0&&m({source:"mobileApp:nativeResume"})},Z=ue=>{bn("resume:disconnect",{reason:ue}),Ws({apiBaseUrl:"",clientToken:null,runtimeKey:Zn}),N(X=>X+1)};dr().then(ue=>{if(F.current===q){if(ue==="no-connection"){Z("no-connection");return}if(ue==="needs-login"){R({kind:"auth-expired",label:bs()??""}),Z("needs-login");return}if(ue==="relay-limit"){R({kind:"relay-limit",label:bs()??""}),Z("relay-limit");return}if(ue==="unreachable"){const X=[4e3,1e4],de=we=>{window.setTimeout(()=>{if(F.current!==q)return;const Se=we===X.length-1;dr({fast:!Se}).then(be=>{if(F.current===q&&be!=="switched"){if(be==="unchanged"){G();return}if(be==="needs-login"){R({kind:"auth-expired",label:bs()??""}),Z("retry-needs-login");return}if(be==="relay-limit"){R({kind:"relay-limit",label:bs()??""}),Z("retry-relay-limit");return}if(!Se){de(we+1);return}Z(`retry-${be}`)}})},X[we])};de(0);return}ue!=="switched"&&G()}});const me=Date.now();me-K.current>=Gg&&(K.current=me,window.dispatchEvent(new Event("openchamber:system-resume")))},[f,n.sourceControl,n.linear,r,m,p,a,y,w]);Kd(),qd(U),d.useEffect(()=>{if(!L)return;let k;const q=()=>{window.clearTimeout(k),k=window.setTimeout(()=>U(),1500)};return window.addEventListener("online",q),()=>{window.removeEventListener("online",q),window.clearTimeout(k)}},[L,U]),d.useEffect(()=>{if(L)return vo.subscribe((k,q)=>{k.state==="expired"&&q.state!=="expired"&&(U(),vo.getState().markAuthenticated())})},[L,U]),d.useEffect(()=>{if(L)return bc(k=>{yr(k)&&U()})},[L,U]),d.useEffect(()=>(wo(n),()=>wo(null)),[n]),d.useEffect(()=>ja(k=>{if(bn("endpoint:changed",{runtimeKey:k.runtimeKey||"none",previousRuntimeKey:k.previousRuntimeKey||"none",connected:!!k.apiBaseUrl}),!!k.runtimeKey&&k.runtimeKey===k.previousRuntimeKey){tf(),V();return}sf(k),T(G=>G+1),N(G=>G+1)}),[]),d.useEffect(()=>{if(!L||l||Mt()){_("done");return}let k=!1;return _("attempting"),(async()=>{const q=await xn().catch(()=>({status:"no-candidate"}));k||(q.status==="unreachable"||q.status==="relay-limit"?R({kind:q.status,label:q.label}):q.status==="needs-login"&&R({kind:"auth-expired",label:q.label}),_("done"),q.status==="unreachable"&&xn({fast:!1,skipIfConnected:!0}).catch(()=>null))})(),()=>{k=!0}},[]),d.useEffect(()=>{if(!L||!Mt())return;let k=!1;const q=G=>{bn("cold-launch:drop",{kind:G?.kind??"unknown"}),G&&R(G),Ws({apiBaseUrl:"",clientToken:null,runtimeKey:Zn}),N(Z=>Z+1)};return dr().then(async G=>{if(k||G==="switched"||G==="unchanged")return;const Z=bs();if(G==="needs-login"){q({kind:"auth-expired",label:Z??""});return}if(G==="unreachable"){q(Z?{kind:"unreachable",label:Z}:null),xn({fast:!1,skipIfConnected:!0}).catch(()=>null);return}if(G==="relay-limit"){q({kind:"relay-limit",label:Z??""});return}const me=await xn().catch(()=>({status:"no-candidate"}));k||me.status==="connected"||(me.status==="needs-login"?q({kind:"auth-expired",label:me.label}):me.status==="unreachable"||me.status==="relay-limit"?q({kind:me.status,label:me.label}):q(null))}),()=>{k=!0}},[]),d.useEffect(()=>{g(!0)},[g]),d.useEffect(()=>{L&&!Mt()||r()},[C,r,L]),d.useEffect(()=>{l&&(a===0&&p({source:"mobileApp:recovery"}),f===0&&m({source:"mobileApp:recovery"}))},[f,l,m,p,a]);const Q=d.useRef(!1),[le,ce]=d.useState(L);d.useEffect(()=>{if(!L||!l||Q.current)return;let k=!1;const q=window.setTimeout(()=>ce(!1),6e3);return(async()=>{const G=await nf({refresh:!0});k||(G!=="failed"&&(Q.current=!0),ce(!1))})(),()=>{k=!0,window.clearTimeout(q)}},[C,l,L]),d.useEffect(()=>{l&&fi.setDirectory(h)},[h,l]),d.useEffect(()=>{l&&(y(n.sourceControl,{force:!0}),w(n.linear,{force:!0}))},[n.sourceControl,n.linear,l,y,w]),d.useEffect(()=>{if(!l||j.length===0)return;let k=!1;return(async()=>{const G=new Map($e.getState().availableWorktreesByProject);if(await Promise.all(j.map(async ue=>{const X=ue.path.replace(/\\/g,"/").replace(/\/+$/,"");if(X)try{if(!(gt.getState().directories.get(X)?.isGitRepo??await Xs(()=>import("./useAppFontEffects-DAUhSLPu.js").then(be=>be.oP),__vite__mapDeps([9,1,2,3,4,5,6,7,8,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,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83])).then(be=>be.checkIsGitRepository(X))))return;const Se=await Ua({id:ue.id,path:X});if(k)return;G.set(X,Se)}catch{}})),k)return;const Z=Ga(j,G),me=$e.getState().availableWorktreesByProject;iu(Z,me)||$e.setState({availableWorktrees:[...Z.values()].flat(),availableWorktreesByProject:Z})})(),()=>{k=!0}},[l,j]),d.useEffect(()=>{if(!l)return;let k=!1;const q=xi(G=>{G.type==="worktree-changed"&&ou(j,G.directories,()=>k)});return()=>{k=!0,q()}},[l,j]),d.useEffect(()=>{if(!b)return;const k=window.setTimeout(()=>u(),5e3);return()=>window.clearTimeout(k)},[u,b]),d.useEffect(()=>{if(!(!l&&(L?!!Mt():!0))){B(!1);return}const q=window.setTimeout(()=>{B(!0)},L?4e3:8e3);return()=>window.clearTimeout(q)},[l,L,C,v]),Hd(),Xd({enabled:!0}),rf(),Jd(),Yd(),of(),af(h||null),lf(),Lg({enabled:L&&l}),Mg({ready:L&&l&&i});const oe=gg(),re=!l&&o==="reconnecting";if(!oe)return t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-[var(--splash-background,var(--surface-background))] text-foreground",children:t.jsx(Vs,{width:120,height:120,isAnimated:!0,variant:"splash"})});const ie=!!Mt();return L&&(!ie||!l&&!re)?ie?t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-[var(--splash-background,var(--surface-background))] px-6 text-center text-foreground",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-4",children:[t.jsx(Vs,{width:120,height:120,isAnimated:!O,variant:"splash"}),O?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:s("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-markdown text-muted-foreground",children:s("mobile.connect.recovery.description")})]}),t.jsx(Ie,{type:"button",variant:"outline",onClick:()=>{Ws({apiBaseUrl:"",clientToken:null,runtimeKey:Zn}),N(k=>k+1)},children:s("mobile.connect.cancelPassword")})]}):null]})}):z!=="done"?t.jsxs("main",{className:"relative flex min-h-dvh items-center justify-center bg-[var(--splash-background,var(--surface-background))] text-foreground",children:[t.jsx(Vs,{width:120,height:120,isAnimated:!0,variant:"splash"}),D?t.jsxs("div",{className:"absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center",children:[t.jsx("p",{className:"typography-small text-muted-foreground",children:s("mobile.connect.splash.connectingTo")}),t.jsxs("p",{className:"typography-small text-foreground",children:[D,t.jsx(Qd,{})]})]}):null]}):t.jsx(t.Fragment,{children:t.jsx(wp,{onConnected:()=>N(k=>k+1),notice:A})}):!l&&!re?O?t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground",children:t.jsxs("div",{className:"max-w-sm space-y-3",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:s("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-markdown text-muted-foreground",children:s("sessionAuth.error.networkDescription")})]})}):t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-[var(--splash-background,var(--surface-background))] text-foreground",children:t.jsx(Vs,{width:120,height:120,isAnimated:!0,variant:"splash"})}):t.jsx(st,{children:t.jsx(Zd,{sdk:fi.getSdkClient(),directory:h||"",children:t.jsx(eu,{apis:n,children:t.jsx(tu,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[t.jsx(cf,{ready:!L||!le,animated:!0}),t.jsx(su,{backgroundWorkEnabled:i}),t.jsx(df,{}),t.jsx(Am,{}),t.jsx(Kg,{onActiveConnectionDeleted:()=>{dp(),Ws({apiBaseUrl:"",clientToken:null,runtimeKey:Zn}),N(k=>k+1)}}),t.jsx(nu,{}),t.jsx(ru,{}),e?t.jsxs(t.Fragment,{children:[t.jsx(kf,{}),t.jsx(uf,{}),t.jsx(Sf,{}),t.jsx(ff,{}),t.jsx(Nf,{})]}):null,t.jsx(Om,{}),i?t.jsx(mf,{}):null]})})})},v)})}function Hg(n){const e=fe.c(7),s=d.useSyncExternalStore(Xg,Mt,Mt);let r;e[0]!==s?(r=!_i()||!!s,e[0]=s,e[1]=r):r=e[1];let i;e[2]!==n?(i=t.jsx(qg,{...n}),e[2]=n,e[3]=i):i=e[3];let l;return e[4]!==r||e[5]!==i?(l=t.jsx(bf,{enabled:r,children:i}),e[4]=r,e[5]=i,e[6]=l):l=e[6],l}function Xg(n){return ja(()=>n())}function Vy(n){window.__OPENCHAMBER_SURFACE__="mobile",mu(),yf({logLabel:"[mobile-main]",onAppearanceSettled:jm}),Em(),pu();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");const r=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",i=r?{...n,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:n,l=t.jsx(Hg,{apis:i});sc.createRoot(e).render(t.jsx(ui.StrictMode,{children:t.jsx(hu,{children:t.jsx(gu,{children:t.jsx(bu,{children:t.jsx(xf,{children:r?l:t.jsx(xu,{children:l})})})})})}))}export{Vy as renderMobileApp};
|
|
25
|
+
`)}`.trim()),Ce([])},[]),ms=d.useCallback(async()=>{if(!u)return;const x=Pt.map($=>$.path).sort();if(x.length===0){pe.error(o("gitView.toast.selectFileToDescribe"));return}ve(!0);try{const{message:$}=await So(u,x);Ee($.subject?.trim()??""),Ce(Array.isArray($.highlights)?$.highlights:[])}catch($){pe.error($ instanceof Error?$.message:o("gitView.toast.generateCommitMessageFailed"))}finally{ve(!1)}},[u,Pt,o]),qn=async(x={})=>{if(!u)return;if(!Te.trim()){pe.error(o("gitView.toast.enterCommitMessage"));return}const $=Pt.map(ze=>ze.path).sort();if($.length===0){pe.error(o("gitView.toast.selectFileToCommit"));return}ye(x.pushAfter?"commitAndPush":"commit");let ae=null,Re="pending";try{if(await a.createGitCommit(u,Te.trim(),{files:$}),Re="local",pe.success(o("gitView.toast.commitCreated")),Ee(""),Ce([]),x.pushAfter){if(ae=Et.start(),!ae){pe.warning(o("gitView.publish.commitKept")),await zt();return}const ze=await ft.prepare("push",{onOperation:ae.onOperation});Se("publish"),await ze(),Re="published",pe.success(o("gitView.publish.succeeded"))}await zt()}catch(ze){if(x.pushAfter&&Re==="local"&&pe.warning(o("gitView.publish.commitKept")),ze instanceof ar||ze instanceof mi){await zt();return}if(ze instanceof ns&&ze.code==="stale-runtime")return;if(ze instanceof ns&&ft.errorMessage(ze)){pe.info(ft.errorMessage(ze));return}x.pushAfter&&await zt(),pe.error(ze instanceof ns?ze.code==="contributor-publish-cancelled-after-update"?o("gitView.toast.contributorPublishCancelledAfterUpdate"):ze.code==="contributor-publish-cancelled"?o("gitView.toast.contributorPublishCancelled"):o("gitView.toast.syncActionFailed",{action:o("gitView.sync.syncChanges")}):ze instanceof Error?ze.message:o("gitView.toast.createCommitFailed"))}finally{ae?.finish(),ye(null),x.pushAfter&&Se(null)}},ln=d.useMemo(()=>(g?.files??[]).filter(Jr).length,[g?.files]),ts=!!g?.mergeInProgress?.head,ss=d.useCallback(async()=>{if(u)try{if(ts){const x=await a.continueMerge(u);x.conflict?(kt(x.conflictFiles??[],"merge"),pe.error(o("gitView.toast.mergeConflictsDetected"))):pe.success(o("gitView.toast.mergeCompleted"))}else{const x=await a.continueRebase(u);x.conflict?(kt(x.conflictFiles??[],"rebase"),pe.error(o("gitView.toast.rebaseConflictsDetected"))):pe.success(o("gitView.toast.rebaseStepCompleted"))}await rt(!1)}catch(x){pe.error(x instanceof Error?x.message:o("gitView.toast.continueOperationFailed"))}},[u,a,ts,kt,rt,o]),Dt=d.useCallback(async x=>{if(u)try{x==="merge"?(await a.abortMerge(u),pe.success(o("gitView.toast.mergeAborted"))):(await a.abortRebase(u),pe.success(o("gitView.toast.rebaseAborted"))),await rt(!1)}catch($){pe.error($ instanceof Error?$.message:o("gitView.toast.abortOperationFailed"))}},[u,a,rt,o]),zr=d.useCallback(()=>{const x=(g?.files??[]).filter(Jr).map($=>$.path);kt(x,ts?"merge":"rebase")},[ts,kt,g?.files]),Bs=d.useMemo(()=>{const x=[];return Pt.length>0&&x.push({id:"staged",title:o("gitView.changes.stagedTitle"),entries:Pt,statsScope:"staged",actionSymbol:"-",actionAllLabel:o("gitView.changes.unstageAllAria"),getActionLabel:$=>o("gitView.changes.unstageFileAria",{path:$}),onActionFile:$=>{fs([$],"unstage")},onActionAll:$=>{fs($,"unstage")},onViewDiff:$=>Yt($,!0),onRevertFile:Qt,showRevertActions:!1,accent:!0}),an.length>0&&x.push({id:"unstaged",title:o("gitView.changes.title"),entries:an,statsScope:"working",actionSymbol:"+",actionAllLabel:o("gitView.changes.stageAllAria"),getActionLabel:$=>o("gitView.changes.stageFileAria",{path:$}),onActionFile:$=>{fs([$],"stage")},onActionAll:$=>{fs($,"stage")},onViewDiff:$=>Yt($,!1),onRevertFile:Qt}),x},[Qt,Yt,fs,Pt,o,an]),Hn=t.jsxs(t.Fragment,{children:[ft.context?t.jsx(zu,{context:ft.context,onSelect:ft.settle}):null,ft.confirmDialog,t.jsx(Bu,{candidates:Ss.candidates,onSelect:Ss.settle})]}),cn=x=>t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[Hn,t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[s?t.jsx("button",{type:"button",className:"-ms-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-ring","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"close",className:"size-5"})}):null,t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[t.jsx("h2",{className:"typography-ui-label text-foreground",children:o("mobile.nav.changes")}),t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:g?.current||u||""})]}),b?t.jsx(Ku,{repositories:b,selectedRepository:m??null,onSelectRepository:$=>{n&&(lr.getState().clearChangesRepository(n),K(n,$))},repositoryRoot:n??void 0}):null]}),t.jsx("div",{className:"min-h-0 flex-1",children:x})]});if(!u)return cn(t.jsx(dt,{message:o("gitView.empty.selectSessionOrDirectory")}));if(p===!1&&A!==!0)return cn(t.jsx(Hu,{root:n,rootIsGitRepo:p,resolvedIsGitRepo:A,nestedRepos:h,onRetryDiscovery:()=>{n&&L(n,{force:!0})}}));if(R&&A===null)return cn(t.jsx(dt,{loading:!0,message:o("gitView.loading.checkingRepository")}));if(Z.type==="diff")return t.jsx(di,{path:Z.path,diff:Pr,staged:Z.staged,fileExists:!!Dr,unavailableReason:it?.key===`${u}\0${Z.path}`?it.reason:null,error:jt,onBack:()=>de({type:"list"}),onRetry:()=>On(x=>x+1)});if(Z.type==="turn")return t.jsx(di,{path:Z.path,subtitle:o("diffView.scope.lastTurn"),diff:Kn.get(Z.path)??null,fileExists:Ms.some(x=>x.path===Z.path),onBack:()=>de(Vt)});const Ls=o(G==="pr"?sr("session.githubIntegration.tabs.pullRequests",We.provider):G==="branch"?"diffView.scope.branch":G==="commit"?"commitComparison.mode":G==="turn"?"diffView.scope.lastTurn":"mobile.nav.changes"),dn=G==="branch"&&Je.base?Lu(Je.base):G==="commit"?Lt?.slice(0,8):G==="pr"&&St?`#${St.number}`:null;if(Z.type==="walkthrough"&&us&&u)return t.jsx(Gh,{directory:u,target:us,subtitle:[Ls,dn].filter(Boolean).join(" · "),revision:JSON.stringify([ls,G==="pr"?_e.revision:0]),visible:i,onBack:()=>de(Vt)});if(ot&&pt)return t.jsx(di,{path:ot,subtitle:[Ls,dn].filter(Boolean).join(" · "),diff:ds??(pt.status==="ready"?pt.diff:null),fileExists:!_e.files||_e.files.some(x=>x.path===ot),error:_e.error??(pt.status==="error"?pt.message:null),onBack:()=>de(Vt),onRetry:()=>{_e.error&&_e.refresh(),on(x=>x+1)},onExpandContextRequest:pt.status==="ready"?x=>Un({source:pt,request:x}):void 0,pendingContextExpansion:Ds,contextLoading:Ds!==null&&!ds});const Xn=()=>G==="pr"&&!St?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(dt,{loading:We.loading,message:We.error??(We.loading?o(sr("session.githubPrPicker.loading.pullRequests",We.provider)):o(sr("pullRequestComparison.select",We.provider)))}),!We.loading&&t.jsx(Ao,{mobile:!0,comparison:We})]}):G==="branch"&&!Je.base?t.jsx(dt,{loading:!Je.resolved,message:Je.resolved?o("gitView.pr.toast.baseBranchRequired"):o("diffView.branch.resolvingBase")}):G==="commit"&&!Lt?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[Xe.loading&&t.jsx(Y,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:Xe.loading?o("diffView.state.loadingChanges"):Xe.error??o("commitComparison.noCommits")}),Xe.error&&t.jsx(Ie,{variant:"outline",size:"lg",onClick:()=>{Xe.refresh()},children:o("diffView.actions.retry")})]}):_e.error?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx("p",{className:"typography-ui-label font-semibold",children:o("diffView.state.failedToLoadDiff")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:_e.error}),t.jsx(Ie,{variant:"outline",size:"lg",onClick:()=>{_e.refresh()},children:o("diffView.actions.retry")})]}):_t?_t.length===0?t.jsx(dt,{icon:G==="branch",message:G==="pr"?o("walkthrough.blocked.emptyDiff.description"):G==="commit"?o("commitComparison.emptyDiff"):o("diffView.branch.empty",{base:dn??""})}):t.jsx(ua,{files:_t,onSelect:x=>{_e.key&&de({type:"comparison",path:x,sourceKey:_e.key})}}):t.jsx(dt,{loading:!0,message:o("diffView.state.loadingChanges")}),Br=()=>Ln?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx("p",{className:"typography-ui-label font-semibold",children:o("diffView.state.failedToLoadDiff")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:Ln}),t.jsx(Ie,{variant:"outline",size:"lg",onClick:()=>{Es(null),rn()},children:o("diffView.actions.retry")})]}):!Ir&&xt?t.jsx(dt,{loading:!0,message:o("diffView.state.loadingChanges")}):Ms.length===0?t.jsx(dt,{message:o("diffView.state.noLastTurnChanges")}):t.jsx(ua,{files:Ms,onSelect:x=>de({type:"turn",path:x})});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[Hn,t.jsxs("header",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b border-border/60 px-3 py-2",children:[s?t.jsx("button",{type:"button",className:"-ms-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-ring","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"close",className:"size-5"})}):null,t.jsxs(pi,{open:me,onOpenChange:ue,children:[t.jsx(hi,{asChild:!0,children:t.jsxs(Ie,{variant:"ghost",className:Id({size:"mobile"}),"data-mobile-comparison-trigger":!0,"aria-label":o("diffView.scope.selectorAria"),children:[t.jsx("span",{children:Ls}),t.jsx(Y,{name:"arrow-down-s",className:"size-4"})]})}),t.jsx(gi,{align:"start",children:t.jsxs(Ed,{value:G,onValueChange:x=>{(x==="working"||x==="turn"||x==="branch"||x==="commit"||x==="pr")&&X(x)},children:[t.jsx(gn,{value:"working",className:"min-h-8 items-center",children:o("mobile.nav.changes")}),t.jsx(gn,{value:"turn",className:"min-h-8 items-center",children:o("diffView.scope.lastTurn")}),Ft&&t.jsx(gn,{value:"branch",className:"min-h-8 items-center",children:o("diffView.scope.branch")}),t.jsx(gn,{value:"commit",className:"min-h-8 items-center",children:o("commitComparison.mode")}),t.jsx(gn,{value:"pr",className:"min-h-8 items-center",children:o(sr("session.githubIntegration.tabs.pullRequests",We.provider))})]})})]}),i&&G==="branch"&&t.jsx(bm,{mobile:!0,branches:w?.all??[],currentBranch:He,base:Je.base,automatic:Je.source!=="chosen",onSelect:x=>{He&&Me(u,He,x)},onSelectAutomatic:()=>{He&&tt(u,He)}},JSON.stringify([re,He])),i&&G==="commit"&&t.jsx(xm,{mobile:!0,commits:Xe.commits,selectedHash:Lt,loading:Xe.loading,error:Xe.error,onSelect:Xe.select,onRefresh:()=>{Xe.refresh()}},JSON.stringify([re,He])),i&&G==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(Ao,{mobile:!0,comparison:We},JSON.stringify([re,He])),St&&t.jsx(Ie,{variant:"ghost",size:"sm",disabled:_e.loading,"aria-label":o("session.githubIssuePicker.actions.refresh"),onClick:()=>{_e.refresh()},children:t.jsx(Y,{name:"refresh",className:"size-4"})})]}),us&&t.jsx(Ie,{variant:"ghost",size:"icon",className:"ms-auto shrink-0",onClick:()=>de({type:"walkthrough"}),"aria-label":o("walkthrough.action.open"),title:o("walkthrough.action.open"),style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"route",className:"size-5"})}),G==="working"&&xt&&(g?.files?.length??0)>0?t.jsxs(Ie,{variant:"default",className:se("shrink-0",!us&&"ms-auto"),disabled:as.submitting,onClick:()=>$t(!0),"aria-label":o("diffView.actions.reviewAria"),style:{touchAction:"manipulation"},children:[t.jsx(Y,{name:as.submitting?"loader-4":"search-eye",className:se("size-4",as.submitting&&"animate-spin")}),o("diffView.actions.review")]}):null]}),t.jsx(Ad,{open:Fn,onOpenChange:$t,projectDirectory:n||null,submitting:as.submitting,onConfirm:as.start}),G==="working"&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 px-3 py-2",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(Fu,{currentBranch:g?.current,localBranches:Mr,remoteBranches:Jt,branchInfo:w?.branches,currentBranchAhead:g?.ahead,onCheckout:x=>{_r(x)},onCreate:Or,disabled:R,directory:u,switchBlockedNotice:(g?.files?.length??0)>0?o("gitView.branch.switchBlockedNotice"):null})}),t.jsx($u,{activeProfile:Is,identities:z,attention:zn,triggerClassName:"max-w-[10rem] shrink [&_.git-identity-label]:hidden sm:[&_.git-identity-label]:inline",onOpen:()=>{B(f,C.map(x=>x.account))},onSelect:x=>{_(x)},isApplying:I,onConfigure:()=>M(!0),applicability:x=>{const $=Oe.read?.repository.remotes.find(ae=>ae.name===os);return $?Wu(x,Td($.fetch.displayUrl)):{applicable:!0}}}),t.jsx(Vu,{syncAction:Et.entry?.executing?we:null,remotes:Tr,onFetch:x=>{zs("fetch",x)},onPull:x=>{zs("pull",x)},onSync:x=>{zs("sync",x)},onPublish:()=>{zs("publish")},onChooseSyncTargets:()=>{zs("sync",void 0,!0)},currentBranch:g?.current,hasTracking:!!g?.tracking,disabled:R||Et.blocked,aheadCount:g?.ahead??0,behindCount:g?.behind??0,trackingRemoteName:g?.tracking?.split("/")[0],trackingBranch:g?.tracking,hasUncommittedChanges:Uu(at),choosesPushDestination:y})]}),t.jsx(Zf,{open:S,onOpenChange:M,directory:u}),t.jsx(Gu,{className:"mx-3 mt-3",entry:Et.entry,onRefresh:()=>{Et.refresh()},onCancel:()=>{Et.cancel()}}),G==="working"&&t.jsx(em,{mergeInProgress:g?.mergeInProgress,rebaseInProgress:g?.rebaseInProgress,onContinue:ss,onAbort:()=>Dt(ts?"merge":"rebase"),onResolveWithAI:zr,conflictCount:ln,isLoading:we!==null||be!==null}),G==="turn"?t.jsx("div",{className:"min-h-0 flex-1",children:Br()}):G!=="working"?t.jsx("div",{className:"min-h-0 flex-1",children:Xn()}):at.length>0?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden px-4 pt-4",children:t.jsx(tm,{groups:Bs,diffStats:g?.diffStats,revertingPaths:De,onRevertAll:Zt,isRevertingAll:Ne,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:Le})}),t.jsx("div",{className:"shrink-0 border-t border-border/70 px-4 pb-4 pt-3",children:t.jsx(sm,{stagedCount:Pt.length,commitMessage:Te,onCommitMessageChange:Ee,generatedHighlights:ge,onInsertHighlights:es,onGenerateMessage:ms,isGeneratingMessage:ee,onCommit:()=>{qn({pushAfter:!1})},onCommitAndPush:()=>{qn({pushAfter:!0})},commitAction:be,networkOperationBlocked:Et.blocked,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(dt,{icon:!0,message:o("gitView.empty.cleanTitle"),description:o("mobile.changes.cleanDescription")})}),u&&t.jsx(nm,{open:Cr,onOpenChange:mt,conflictFiles:Kt,directory:u,operation:Cs,onAbort:()=>{Dt(Cs)},onNavigatedToChat:l}),t.jsx(rm,{open:Ns!==null,onOpenChange:x=>{x||is(null)},targetBranch:Ns??"",changedFileCount:g?.files?.length??0,onCommitAndSwitch:(x,$)=>qh(x,$,{targetBranch:Ns,directory:u,sourceBranch:g?.current??null,git:a,publishChooser:ft,toast:pe,t:o,refreshStatusAndBranches:rt,closeDialog:()=>is(null),performCheckout:_s}),onGenerateMessage:async()=>{if(!u)return"";const x=(g?.files??[]).map(ae=>ae.path).sort(),{message:$}=await So(u,x);return $.subject?.trim()??""},onRevertAndSwitch:async()=>{const x=Ns;if(!x||!u)return;await Zt((g?.files??[]).map(ae=>ae.path));const $=await a.getGitStatus(u);if(!$.isClean&&($.files?.length??0)>0){pe.error(o("gitView.dirtySwitch.revertIncomplete"));return}is(null),await _s(x)}})]})},dt=n=>{const e=fe.c(13),{message:s,description:r,loading:i,icon:l}=n,o=i===void 0?!1:i,a=l===void 0?!1:l;let f;e[0]!==o?(f=o?t.jsx(Y,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,e[0]=o,e[1]=f):f=e[1];let p;e[2]!==a?(p=a?t.jsx(Y,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e[2]=a,e[3]=p):p=e[3];let m;e[4]!==s?(m=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[4]=s,e[5]=m):m=e[5];let h;e[6]!==r?(h=r?t.jsx("p",{className:"typography-meta text-muted-foreground",children:r}):null,e[6]=r,e[7]=h):h=e[7];let b;return e[8]!==f||e[9]!==p||e[10]!==m||e[11]!==h?(b=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[f,p,m,h]})}),e[8]=f,e[9]=p,e[10]=m,e[11]=h,e[12]=b):b=e[12],b},di=n=>{const e=fe.c(55),{path:s,subtitle:r,diff:i,staged:l,fileExists:o,unavailableReason:a,error:f,onBack:p,onRetry:m,onExpandContextRequest:h,pendingContextExpansion:b,contextLoading:u}=n,g=l===void 0?!1:l,y=a===void 0?null:a,w=f===void 0?null:f,{t:j}=xe();let S;e[0]!==s?(S=Pd(s)||"text",e[0]=s,e[1]=S):S=e[1];const M=S,I=Ve(eg),E=Ve(tg);let C;e[2]!==I||e[3]!==j?(C=j(I?"diffView.whitespace.hidden":"diffView.whitespace.shown"),e[2]=I,e[3]=j,e[4]=C):C=e[4];const N=C;let v;e[5]!==j?(v=j("header.actions.backAria"),e[5]=j,e[6]=v):v=e[6];let T;e[7]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(Y,{name:"arrow-left",className:"size-5"}),e[7]=T):T=e[7];let O;e[8]!==p||e[9]!==v?(O=t.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-ring","aria-label":v,onClick:p,children:T}),e[8]=p,e[9]=v,e[10]=O):O=e[10];let B;e[11]!==s?(B=t.jsx("h2",{className:"typography-ui-header",children:t.jsx(ol,{path:s})}),e[11]=s,e[12]=B):B=e[12];let z;e[13]!==r?(z=r&&t.jsx("p",{className:"truncate typography-meta text-muted-foreground",children:r}),e[13]=r,e[14]=z):z=e[14];let _;e[15]!==z||e[16]!==B?(_=t.jsxs("div",{className:"min-w-0 flex-1 px-2",children:[B,z]}),e[15]=z,e[16]=B,e[17]=_):_=e[17];const A=I?"text-foreground":"text-muted-foreground";let R;e[18]!==A?(R=se("flex size-9 shrink-0 items-center justify-center rounded-lg hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",A),e[18]=A,e[19]=R):R=e[19];let D;e[20]!==j?(D=j("diffView.actions.hideWhitespace"),e[20]=j,e[21]=D):D=e[21];let V;e[22]!==I||e[23]!==E?(V=()=>E(!I),e[22]=I,e[23]=E,e[24]=V):V=e[24];let L;e[25]!==I?(L=t.jsx(Qf,{hidden:I,className:"size-5"}),e[25]=I,e[26]=L):L=e[26];let K;e[27]!==I||e[28]!==R||e[29]!==D||e[30]!==V||e[31]!==L||e[32]!==N?(K=t.jsx("button",{type:"button",className:R,"aria-label":D,"aria-pressed":I,title:N,onClick:V,children:L}),e[27]=I,e[28]=R,e[29]=D,e[30]=V,e[31]=L,e[32]=N,e[33]=K):K=e[33];let F;e[34]!==_||e[35]!==K||e[36]!==O?(F=t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/70 px-3 text-foreground",children:[O,_,K]}),e[34]=_,e[35]=K,e[36]=O,e[37]=F):F=e[37];let U;e[38]!==u||e[39]!==i||e[40]!==w||e[41]!==o||e[42]!==I||e[43]!==M||e[44]!==h||e[45]!==m||e[46]!==s||e[47]!==b||e[48]!==g||e[49]!==j||e[50]!==y?(U=t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:o?y==="nested_repository"?t.jsx(dt,{icon:!0,message:j("diffView.unavailable.nestedRepositoryTitle"),description:j("diffView.unavailable.nestedRepositoryDescription")}):y==="untracked_directory"?t.jsx(dt,{icon:!0,message:j("diffView.unavailable.untrackedDirectoryTitle"),description:j("diffView.unavailable.untrackedDirectoryDescription")}):w?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:j("mobile.changes.diffDetail.loadFailed")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:w}),t.jsx(Ie,{type:"button",size:"sm",variant:"outline",onClick:()=>m?.(),children:j("diffView.actions.retry")})]})}):i?i.submodule?t.jsx("div",{className:"p-3",children:t.jsx(Yf,{state:i.submodule,staged:g})}):i.isBinary?t.jsx(dt,{icon:!0,message:j("diffView.binary.unavailable")}):Dd(s)&&!i.fileDiff?t.jsx(dt,{icon:!0,message:j("mobile.changes.diffDetail.imageUnavailable")}):t.jsx(wr,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:t.jsx(ym,{original:i.original,modified:i.modified,fileDiff:i.fileDiff,language:M,fileName:s,renderSideBySide:!1,wrapLines:!0,hideWhitespace:I,layout:"inline",onExpandContextRequest:h,pendingContextExpansion:b,contextLoading:u})}):t.jsx(dt,{loading:!0,message:j("diffView.state.loadingDiff")}):t.jsx(dt,{icon:!0,message:j("mobile.changes.diffDetail.missingTitle"),description:j("mobile.changes.diffDetail.missingDescription")})}),e[38]=u,e[39]=i,e[40]=w,e[41]=o,e[42]=I,e[43]=M,e[44]=h,e[45]=m,e[46]=s,e[47]=b,e[48]=g,e[49]=j,e[50]=y,e[51]=U):U=e[51];let Q;return e[52]!==F||e[53]!==U?(Q=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[F,U]}),e[52]=F,e[53]=U,e[54]=Q):Q=e[54],Q},ua=n=>{const e=fe.c(12),{files:s,onSelect:r}=n,{t:i}=xe();let l;e[0]!==i?(l=i("gitView.changes.changedFilesAria"),e[0]=i,e[1]=l):l=e[1];let o;if(e[2]!==s||e[3]!==r||e[4]!==i){let f;e[6]!==r||e[7]!==i?(f=p=>{const m=p.status==="A"?i("diffView.change.new"):p.status==="D"?i("diffView.change.deleted"):p.status==="R"?i("diffView.change.renamed"):p.status==="C"?i("diffView.change.copied"):i("diffView.change.modified"),h=p.status==="A"?"var(--status-success)":p.status==="D"?"var(--status-error)":p.status==="R"||p.status==="C"?"var(--status-info)":"var(--status-warning)";return t.jsx("li",{children:t.jsxs(Ie,{variant:"ghost",size:"lg",className:"w-full justify-start gap-2.5 text-start normal-case",onClick:()=>r(p.path),children:[t.jsx("span",{className:"w-4 shrink-0 text-center typography-meta font-semibold uppercase",style:{color:h},"aria-label":m,children:p.status}),t.jsx(Ja,{filePath:p.path,className:"size-4 shrink-0"}),t.jsx(ol,{path:p.path,className:"flex-1 typography-ui-label"}),(p.insertions>0||p.deletions>0)&&t.jsxs("span",{className:"shrink-0 typography-meta text-muted-foreground",children:["+",p.insertions," -",p.deletions]}),t.jsx(Y,{name:"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground"})]})},p.path)},e[6]=r,e[7]=i,e[8]=f):f=e[8],o=s.map(f),e[2]=s,e[3]=r,e[4]=i,e[5]=o}else o=e[5];let a;return e[9]!==l||e[10]!==o?(a=t.jsx(wr,{className:"h-full overflow-y-auto overflow-x-hidden px-3 py-2",children:t.jsx("ul",{"aria-label":l,className:"flex flex-col gap-1",children:o})}),e[9]=l,e[10]=o,e[11]=a):a=e[11],a};function eg(n){return n.diffHideWhitespace}function tg(n){return n.setDiffHideWhitespace}const sg=d.lazy(()=>Xs(()=>import("./FilesView-Csrs_BGv.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,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129])).then(n=>({default:n.FilesView}))),Bt=n=>_n(n)??"",Cn=n=>{const e=Bt(n);return!e||e==="/"?e||"/":e.split("/").filter(Boolean).at(-1)??e},ng=n=>{const e=Bt(n);if(!e||e==="/")return null;const s=e.lastIndexOf("/");return s<=0?e.startsWith("/")?"/":null:e.slice(0,s)},rg=(n,e)=>{const s=Bt(n),r=Bt(e);return!r||s===r?Cn(s):s.startsWith(`${r}/`)?s.slice(r.length+1):s},ig=n=>{if(typeof n!="number"||!Number.isFinite(n)||n<0)return"";if(n<1024)return`${n} B`;const e=["KB","MB","GB"];let s=n/1024;for(const r of e){if(s<1024||r===e[e.length-1])return`${s.toFixed(s>=10?0:1)} ${r}`;s/=1024}return""},og=n=>{const e=fe.c(5),{onClose:s,visible:r}=n,i=r===void 0?!0:r,l=el(),o=Bt(qa(l,Ha()));if(l?.kind==="preparing"){let f;return e[0]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx(tl,{}),e[0]=f):f=e[0],f}let a;return e[1]!==s||e[2]!==o||e[3]!==i?(a=t.jsx(ag,{root:o,onClose:s,visible:i},o),e[1]=s,e[2]=o,e[3]=i,e[4]=a):a=e[4],a},ag=({root:n,onClose:e,visible:s})=>{const{t:r}=xe(),{files:i}=vr(),l=fc(),o=mc(k=>k.setSelectedPath),[a,f]=d.useState(()=>({type:"browser",directory:n})),[p,m]=d.useState([]),[h,b]=d.useState(!1),[u,g]=d.useState(null),[y,w]=d.useState(""),[j,S]=d.useState([]),[M,I]=d.useState(!1),E=d.useRef(0),C=a.type==="browser"?a.directory:a.returnDirectory,N=d.useRef(C);N.current=C;const v=d.useCallback(async(k,q)=>{if(!k)return;const G=!l,Z=E.current+1;E.current=Z,b(!0),q?.background||g(null);try{const me=await i.listDirectory(k,{respectGitignore:G});if(E.current!==Z)return;g(null),m(me.entries.slice().sort((ue,X)=>ue.isDirectory!==X.isDirectory?ue.isDirectory?-1:1:ue.name.localeCompare(X.name)))}catch(me){if(E.current!==Z)return;if(q?.background){console.error("Failed to reload mobile directory:",me);return}m([]),g(me instanceof Error?me.message:r("mobile.files.error.listFailed"))}finally{E.current===Z&&b(!1)}},[i,l,r]);d.useEffect(()=>{a.type==="browser"&&v(a.directory)},[v,a]);const T=d.useRef(a);T.current=a;const O=d.useRef(p);O.current=p;const B=d.useCallback(({directories:k})=>{const q=T.current;q.type==="browser"&&(k&&!k.some(G=>Bt(G)===Bt(q.directory))||O.current.length>Xu||v(q.directory,{background:!0}))},[v]);Ju({root:n,active:s,whileInactive:"hold",onChanges:B});const z=d.useCallback(async k=>{Bt(k)===Bt(N.current)&&await v(N.current)},[v]),{canUpload:_,uploadingDirectory:A,pickFiles:R,uploadElements:D}=Yu({root:n,refreshDirectory:z}),V=A!==null;d.useEffect(()=>{if(a.type!=="browser")return;const k=y.trim();if(!k){S([]),I(!1);return}let q=!1;const G=window.setTimeout(()=>{I(!0),i.search({directory:a.directory,query:k,maxResults:40}).then(Z=>{q||S(Z)}).catch(()=>{q||S([])}).finally(()=>{q||I(!1)})},250);return()=>{q=!0,window.clearTimeout(G)}},[i,y,a]);const L=k=>{w(""),f({type:"browser",directory:k})},K=k=>{o(n,k),f({type:"file",path:k,returnDirectory:C||n})},F=Ve(k=>k.pendingFileFocusPath),U=Ve(k=>k.pendingFileNavigation);if(d.useEffect(()=>{const k=Bt(U?.path??F??"");!k||!n||(o(n,k,{allowOutsideRoot:!0}),f(q=>({type:"file",path:k,returnDirectory:q.type==="file"?q.returnDirectory:n})),F&&Ve.getState().setPendingFileFocusPath(null))},[F,U,n,o]),!n)return t.jsx(Rn,{message:r("mobile.files.empty.noDirectory")});if(a.type==="file")return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/70 px-3 text-foreground",children:[t.jsx("button",{type:"button",className:"-ms-1 flex size-10 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-ring","aria-label":r("header.actions.backAria"),onClick:()=>f({type:"browser",directory:a.returnDirectory}),style:{touchAction:"manipulation"},children:t.jsx(Ro,{className:"size-5"})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:Cn(a.path)})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(st,{children:t.jsx(d.Suspense,{fallback:t.jsx(Rn,{loading:!0,message:r("filesView.state.loading")}),children:t.jsx(sg,{mode:"editor-only"})})})})]});const Q=a.directory===n?r("mobile.files.rootDirectory"):Cn(a.directory),le=y.trim()?j:[],ce=ng(a.directory),oe=a.directory!==n&&ce!==null&&(ce===n||ce.startsWith(`${n}/`)),re=oe&&!y.trim(),ie=oe?ce:null;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[D,t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[e?t.jsx("button",{type:"button",className:"-ms-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-ring","aria-label":r("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(Pf,{className:"size-5"})}):null,re&&ie?t.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-ring","aria-label":r("mobile.files.backToParentAria",{name:Cn(ie)}),onClick:()=>L(ie),style:{touchAction:"manipulation"},children:t.jsx(Ro,{className:"size-5"})}):null,t.jsx("div",{className:"min-w-0 flex-1 px-1",children:t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:Q})}),t.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-ring","aria-label":r("mobile.files.refreshAria"),onClick:()=>{v(a.directory)},style:{touchAction:"manipulation"},children:t.jsx(Df,{className:se("size-5",h&&"animate-spin")})}),_?t.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-ring disabled:opacity-50","aria-label":r("sidebarFilesTree.actions.uploadFilesTitle"),onClick:()=>R(a.directory),disabled:V,style:{touchAction:"manipulation"},children:t.jsx(Y,{name:V?"loader-4":"upload-2",className:se("size-5",V&&"animate-spin")})}):null]}),t.jsx("div",{className:"shrink-0 px-4 pb-2 pt-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(Mf,{className:"pointer-events-none absolute inset-s-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx($a,{value:y,onChange:k=>w(k.target.value),placeholder:r("mobile.files.search.placeholder"),className:"h-11 ps-9"})]})}),t.jsx(wr,{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-3",children:u?t.jsx(Rn,{message:u}):y.trim()?t.jsx(lg,{root:n,results:le,isSearching:M,onOpenFile:K}):t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:[p.length===0&&!h?t.jsx("div",{className:"px-4 py-8 text-center typography-ui-label text-muted-foreground",children:r("mobile.files.empty.directory")}):null,p.map(k=>t.jsx(ql,{name:k.name,path:k.path,directory:k.isDirectory,meta:k.isDirectory?void 0:ig(k.size),onClick:()=>k.isDirectory?L(k.path):K(k.path)},k.path))]})})]})},ql=n=>{const e=fe.c(16),{name:s,path:r,directory:i,meta:l,onClick:o}=n;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={touchAction:"manipulation"},e[0]=a):a=e[0];let f;e[1]!==i||e[2]!==r?(f=i?t.jsx(zf,{className:"size-5 shrink-0 text-primary/80"}):t.jsx(Ja,{filePath:r,className:"size-5 shrink-0"}),e[1]=i,e[2]=r,e[3]=f):f=e[3];let p;e[4]!==s?(p=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:s}),e[4]=s,e[5]=p):p=e[5];let m;e[6]!==l?(m=l?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:l}):null,e[6]=l,e[7]=m):m=e[7];let h;e[8]!==i?(h=i?t.jsx(Bf,{className:"size-4 shrink-0 text-muted-foreground/60"}):null,e[8]=i,e[9]=h):h=e[9];let b;return e[10]!==o||e[11]!==f||e[12]!==p||e[13]!==m||e[14]!==h?(b=t.jsxs("button",{type:"button",className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3 py-2.5 text-start transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:o,style:a,children:[f,p,m,h]}),e[10]=o,e[11]=f,e[12]=p,e[13]=m,e[14]=h,e[15]=b):b=e[15],b},lg=n=>{const e=fe.c(17),{root:s,results:r,isSearching:i,onOpenFile:l}=n,{t:o}=xe();if(i){let p;e[0]!==o?(p=o("common.loading"),e[0]=o,e[1]=p):p=e[1];let m;return e[2]!==p?(m=t.jsx(Rn,{loading:!0,message:p}),e[2]=p,e[3]=m):m=e[3],m}if(r.length===0){let p;e[4]!==o?(p=o("mobile.files.search.empty"),e[4]=o,e[5]=p):p=e[5];let m;return e[6]!==p?(m=t.jsx(Rn,{message:p}),e[6]=p,e[7]=m):m=e[7],m}let a;if(e[8]!==l||e[9]!==r||e[10]!==s){let p;e[12]!==l||e[13]!==s?(p=m=>t.jsx(ql,{name:Cn(m.path),path:m.path,directory:!1,meta:rg(m.path,s),onClick:()=>l(m.path)},m.path),e[12]=l,e[13]=s,e[14]=p):p=e[14],a=r.map(p),e[8]=l,e[9]=r,e[10]=s,e[11]=a}else a=e[11];let f;return e[15]!==a?(f=t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:a}),e[15]=a,e[16]=f):f=e[16],f},Rn=n=>{const e=fe.c(7),{message:s,loading:r}=n,i=r===void 0?!1:r;let l;e[0]!==i?(l=i?t.jsx(_f,{className:"size-5 animate-spin text-muted-foreground"}):t.jsx(Of,{className:"size-6 text-muted-foreground"}),e[0]=i,e[1]=l):l=e[1];let o;e[2]!==s?(o=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==l||e[5]!==o?(a=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[l,o]})}),e[4]=l,e[5]=o,e[6]=a):a=e[6],a},fa="mobile-surface-root",cg=16,ma=320,dg="cubic-bezier(0.22, 1, 0.36, 1)",ug=n=>{const e=fe.c(38),{onOpenMcpSettings:s,active:r}=n,{t:i}=xe(),[l,o]=d.useState(!1),a=Ka(!1),f=$s(mg),p=Ks(pg);let m;e[0]!==a||e[1]!==l||e[2]!==p||e[3]!==f?(m=()=>{if(l||!a)return;o(!0);const z=new Promise(hg);Promise.all([f({directory:a,silent:!0}),p({force:!0,directory:a}),z]).finally(()=>o(!1))},e[0]=a,e[1]=l,e[2]=p,e[3]=f,e[4]=m):m=e[4];const h=m;let b;e[5]!==i?(b=i("settings.mcp.sidebar.actions.addServerTitle"),e[5]=i,e[6]=b):b=e[6];let u;e[7]!==i?(u=i("settings.mcp.sidebar.actions.addServerTitle"),e[7]=i,e[8]=u):u=e[8];let g,y;e[9]===Symbol.for("react.memo_cache_sentinel")?(g={touchAction:"manipulation"},y=t.jsx(Y,{name:"add",className:"size-5"}),e[9]=g,e[10]=y):(g=e[9],y=e[10]);let w;e[11]!==s||e[12]!==b||e[13]!==u?(w=t.jsx("button",{type:"button",className:"flex size-10 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-ring",onClick:s,"aria-label":b,title:u,style:g,children:y}),e[11]=s,e[12]=b,e[13]=u,e[14]=w):w=e[14];const j=l||!a;let S;e[15]!==i?(S=i("mcpDropdown.actions.refreshAria"),e[15]=i,e[16]=S):S=e[16];let M;e[17]!==i?(M=i("mcpDropdown.actions.refreshAria"),e[17]=i,e[18]=M):M=e[18];let I;e[19]===Symbol.for("react.memo_cache_sentinel")?(I={touchAction:"manipulation"},e[19]=I):I=e[19];const E=l&&"animate-spin";let C;e[20]!==E?(C=se("size-5",E),e[20]=E,e[21]=C):C=e[21];let N;e[22]!==C?(N=t.jsx(Y,{name:"refresh",className:C}),e[22]=C,e[23]=N):N=e[23];let v;e[24]!==h||e[25]!==N||e[26]!==j||e[27]!==S||e[28]!==M?(v=t.jsx("button",{type:"button",className:"flex size-10 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:h,disabled:j,"aria-label":S,title:M,style:I,children:N}),e[24]=h,e[25]=N,e[26]=j,e[27]=S,e[28]=M,e[29]=v):v=e[29];let T;e[30]!==v||e[31]!==w?(T=t.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-1 px-2 pt-1",children:[w,v]}),e[30]=v,e[31]=w,e[32]=T):T=e[32];let O;e[33]!==r?(O=t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(Uh,{active:r,className:"h-full",listClassName:"max-h-none",hideHeader:!0,mobileListDensity:!0})}),e[33]=r,e[34]=O):O=e[34];let B;return e[35]!==T||e[36]!==O?(B=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[T,O]}),e[35]=T,e[36]=O,e[37]=B):B=e[37],B},fg=({open:n,onClose:e,tab:s,onTabChange:r,pendingChangesDiff:i,onOpenPlan:l,onOpenMcpSettings:o,variant:a="drawer"})=>{const{t:f,direction:p}=xe(),m=d.useRef(null),h=d.useRef(null),[b,u]=d.useState(!1),[g,y]=d.useState(n),w=d.useRef(e);d.useEffect(()=>{w.current=e},[e]);const j=Ve(A=>A.mobileWorkspaceTabOrder),S=Ve(A=>A.mobileWorkspaceHiddenTabs),M=Ve(A=>A.setMobileWorkspaceTabOrder),I=d.useRef(s);d.useEffect(()=>{I.current=s},[s]);const E=()=>w.current();ro(h,{enabled:a==="drawer"&&n,...p==="rtl"?{onRightEdgeSwipe:E}:{onLeftEdgeSwipe:E}});const[C,N]=d.useState(()=>new Set);if(d.useEffect(()=>{n&&N(A=>{if(A.has(s))return A;const R=new Set(A);return R.add(s),R})},[n,s]),typeof document<"u"&&!m.current){let A=document.getElementById(fa);A||(A=document.createElement("div"),A.id=fa,document.body.appendChild(A)),m.current=A}if(d.useEffect(()=>{if(n){y(!0);const R=window.setTimeout(()=>u(!0),cg);return()=>window.clearTimeout(R)}u(!1);const A=window.setTimeout(()=>y(!1),ma+40);return()=>window.clearTimeout(A)},[n]),d.useEffect(()=>{if(!n)return;const A=document.body.style.overflow;a==="drawer"&&(document.body.style.overflow="hidden");const R=D=>{D.key!=="Escape"||I.current==="terminal"||Bd(D.target)||Mi(D)||w.current()};return document.addEventListener("keydown",R),()=>{a==="drawer"&&(document.body.style.overflow=A),document.removeEventListener("keydown",R)}},[n,a]),a==="drawer"&&!m.current)return null;const v={changes:{id:"changes",label:f("mobile.menu.git"),icon:t.jsx(Y,{name:"git-branch",className:"h-3.5 w-3.5"})},files:{id:"files",label:f("mobile.menu.files"),icon:t.jsx(Y,{name:"file-text",className:"h-3.5 w-3.5"})},terminal:{id:"terminal",label:f("mobile.menu.terminal"),icon:t.jsx(Y,{name:"terminal",className:"h-3.5 w-3.5"})},notes:{id:"notes",label:f("contextRail.surface.notes"),icon:t.jsx(Y,{name:"sticky-note",className:"h-3.5 w-3.5"})},mcp:{id:"mcp",label:f("mobile.menu.mcp"),icon:t.jsx(Ld,{className:"h-3.5 w-3.5"})}},T=pc(j,S,s),O=T.map(A=>v[A]),B=O.length===1?O[0]:null,z=(A,R)=>{const D=hc(j),V=D.findIndex(K=>K===A),L=D.findIndex(K=>K===R);V<0||L<0||M(Lf(D,V,L))},_=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",children:[t.jsx("div",{className:"flex h-9 min-w-0 flex-1 items-center",children:B?t.jsxs("h2",{className:"flex min-w-0 items-center gap-2 px-1 typography-ui-header font-semibold text-foreground",children:[t.jsx("span",{className:"flex shrink-0 text-muted-foreground",children:B.icon}),t.jsx("span",{className:"truncate",children:B.label})]}):g?t.jsx(zd,{items:O,activeId:s,onSelect:A=>{const R=T.find(D=>D===A);R&&r(R)},onReorder:z,layoutMode:"fit",variant:"active-pill",nonCompositedIndicator:!0,inactiveTabsIconOnly:O.length>3,className:"h-full"}):null}),t.jsx("button",{type:"button",className:"-me-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-ring","aria-label":f("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"close",className:"size-5"})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[C.has("changes")?t.jsx("div",{className:se("h-full",s!=="changes"&&"hidden"),children:t.jsx(st,{children:t.jsx(Qh,{visible:n&&s==="changes",initialDiff:i,onNavigatedToChat:e})})},i?`changes:${i.path}:${i.staged}`:"changes"):null,C.has("files")?t.jsx("div",{className:se("h-full",s!=="files"&&"hidden"),children:t.jsx(st,{children:t.jsx(og,{visible:n&&s==="files"})})}):null,C.has("terminal")?t.jsx("div",{className:se("h-full",s!=="terminal"&&"hidden"),children:t.jsx(st,{children:t.jsx(Qu,{visible:n&&s==="terminal"})})}):null,C.has("notes")?t.jsx("div",{className:se("h-full",s!=="notes"&&"hidden"),children:t.jsx(st,{children:t.jsx(Zu,{visible:n&&s==="notes",onActionComplete:e,onOpenPlan:l})})}):null,C.has("mcp")?t.jsx("div",{className:se("h-full",s!=="mcp"&&"hidden"),children:t.jsx(st,{children:t.jsx(ug,{active:n&&s==="mcp",onOpenMcpSettings:o})})}):null]})]});return a==="panel"?t.jsx("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:_}):Hs.createPortal(t.jsx("section",{ref:h,role:"dialog","aria-modal":"true","aria-label":f("mobile.header.openWorkspaceAria"),"aria-hidden":!n,className:"oc-keyboard-inset-surface oc-bottom-safe-surface fixed inset-0 z-50 flex flex-col bg-background text-foreground",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:b?"none":p==="rtl"?"translateX(-100%)":"translateX(100%)",transition:`transform ${ma}ms ${dg}`,visibility:g?"visible":"hidden",pointerEvents:n?"auto":"none"},children:_}),m.current)};function mg(n){return n.refresh}function pg(n){return n.loadMcpConfigs}function hg(n){return window.setTimeout(n,500)}function gg(n){const e=fe.c(4),s=2500,{uiFont:r}=Fd(),[i,l]=d.useState(!1);let o,a;return e[0]!==s||e[1]!==r?(o=()=>{let f=!1;const p=()=>{f||l(!0)},m=()=>{requestAnimationFrame(()=>requestAnimationFrame(p))},h=Promise.all([$d(r).catch(wg),document.fonts?.ready?.then(vg).catch(yg)??Promise.resolve(),wm.catch(xg)]).then(bg),b=new Promise(u=>{window.setTimeout(u,s)});return Promise.race([h,b]).then(m),()=>{f=!0}},a=[r,s],e[0]=s,e[1]=r,e[2]=o,e[3]=a):(o=e[2],a=e[3]),d.useEffect(o,a),i}function bg(){}function xg(){}function yg(){}function vg(){}function wg(){}const jg=al({projectId:To().trim().min(1).optional(),text:To().optional()}),kg=al({request:jg.nullish()}),Hl=sl("ShortcutRequests"),Sg=async()=>{const n=kg.safeParse(await Hl.takePending());return n.success?n.data.request??null:null},Ng=n=>{if(Ii()!=="ios")return()=>{};let e=!1,s=null;const r=()=>{Sg().then(i=>{i&&n(i)}).catch(()=>{})};return Hl.addListener("pending",r).then(i=>{if(e){i.remove();return}s=i}).catch(()=>{}),r(),()=>{e=!0,s?.remove()}},Cg="openchamber",Rg=n=>n.replace(/^\/+|\/+$/g,""),Ig=n=>{const e=Rg(n.pathname).split("/").filter(Boolean);return n.host?[n.host,...e]:e};function Eg(n){if(typeof n!="string"||n.length===0)return null;let e;try{e=new URL(n)}catch{return null}if(e.protocol!==`${Cg}:`)return null;const s=Ig(e),r=(s[0]??"").toLowerCase(),i=s.slice(1),l=e.searchParams;switch(r){case"session":{const o=i[0]||l.get("id")||"";if(!o)return null;const a=l.get("message")?.trim()??"";return{type:"session",sessionId:o,directory:l.get("dir")??void 0,...Wd(a)?{messageId:a}:{}}}case"new":case"new-session":return{type:"new-session",directory:l.get("dir")??void 0,projectId:l.get("project")??void 0,agent:l.get("agent")??void 0,model:l.get("model")??void 0};case"sessions":{const o=l.get("filter");return{type:"sessions",filter:o==="attention"||o==="recent"||o==="all"?o:void 0}}case"status":return{type:"status"};case"settings":return{type:"settings",section:i[0]||l.get("section")||void 0};case"changes":return{type:"changes",path:i.join("/")||l.get("path")||void 0,staged:l.get("staged")==="true"};case"view":{const o=(i[0]||"").toLowerCase();return o==="changes"?{type:"changes"}:o==="files"||o==="mcp"||o==="instances"||o==="update"?{type:"view",target:o}:null}default:return null}}let vt={},Xl=!1,Sn=null;const Ag=n=>{const e=$e.getState(),s=n.projectId?ut.getState().projects.find(i=>i.id===n.projectId)??null:null;e.openNewSessionDraft(s?{selectedProjectId:s.id}:void 0);const r=n.text?.trim();if(r){if(n.projectId&&!s){No.getState().setPendingInputText(r,"append");return}No.getState().requestDraftSubmit($e.getState().newSessionDraft.draftId,r)}},Tg=n=>{switch(n.type){case"shortcut-new-session":return Ag(n),!0;case"session":return n.messageId&&!n.directory?(Vd(n.sessionId,n.messageId),!0):(n.messageId&&Ud(n.sessionId,n.messageId),$e.getState().setCurrentSession(n.sessionId,n.directory??null),!0);case"new-session":{const e=$e.getState();return e.openNewSessionDraft(),(n.directory||n.projectId)&&e.setNewSessionDraftTarget({directoryOverride:n.directory??null,projectId:n.projectId??null,selectedProjectId:n.projectId??null}),!0}case"sessions":return vt.openSessions?(vt.openSessions(n.filter),!0):!1;case"status":return vt.openSessions?(vt.openSessions(),!0):!1;case"view":return vt.openView?(vt.openView(n.target),!0):!1;case"changes":return vt.openChanges?(vt.openChanges({path:n.path,staged:n.staged}),!0):!1;case"settings":return vt.openSettings?(vt.openSettings(n.section),!0):!1}},io=()=>{if(!Xl||!Sn)return;const n=Sn;Sn=null,Tg(n)||(Sn=n)},Ri=n=>{Sn=n,io()},pa=n=>{const e=Eg(n);e&&Ri(e)},Pg=n=>{Xl=n,io()},Dg=n=>{const e=fe.c(3);let s,r;e[0]!==n?(s=()=>(vt=n,io(),()=>{vt===n&&(vt={})}),r=[n],e[0]=n,e[1]=s,e[2]=r):(s=e[1],r=e[2]),d.useEffect(s,r)},Mg=n=>{const{ready:e}=n;d.useEffect(()=>{Pg(e)},[e]),d.useEffect(()=>{if(!nt())return;let s=!1;const r=[];return Xs(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([130,5,55])).then(async({App:i})=>{if(s)return;const l=await i.addListener("appUrlOpen",o=>{pa(o?.url)});if(s){l.remove();return}r.push(()=>{l.remove()})}).catch(()=>{}),r.push(Ng(i=>{Ri({type:"shortcut-new-session",projectId:i.projectId,text:i.text})})),Xs(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([131,55])).then(async({PushNotifications:i})=>{if(s)return;const l=await i.addListener("pushNotificationActionPerformed",o=>{const a=o?.notification?.data,f=typeof a?.url=="string"?a.url:typeof a?.deeplink=="string"?a.deeplink:void 0;if(f){pa(f);return}const p=typeof a?.sessionId=="string"?a.sessionId:void 0;p&&Ri({type:"session",sessionId:p})});if(s){l.remove();return}r.push(()=>{l.remove()})}).catch(()=>{}),()=>{s=!0,r.forEach(i=>i())}},[])},_g=()=>{if(typeof window>"u")return;const n=window.__OPENCHAMBER_APNS_ENV__;if(n==="development")return"sandbox";if(n==="production")return"production"},ha=/^[A-Za-z0-9+/]{43}=$/,Og=sl("PushKey"),zg=async()=>{const n=window.__OPENCHAMBER_PUSH_KEY__;if(n&&ha.test(n))return n;const e=await Og.get().then(s=>s.key).catch(()=>{});return e&&ha.test(e)?e:void 0},Bg=()=>{if(typeof window>"u")return!1;const e=window.Capacitor?.getPlatform?.();return e==="ios"||e==="android"},Lg=n=>{const{enabled:e}=n,s=Ve(i=>i.nativeNotificationsEnabled),r=d.useRef(null);d.useEffect(()=>{if(!e||!s||!Bg())return;let i=!1;const l=[];return Xs(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([131,55])).then(async({PushNotifications:o})=>{if(i)return;let a=await o.checkPermissions().catch(()=>null);if(a?.receive!=="granted"&&(a=await o.requestPermissions().catch(()=>null)),a?.receive!=="granted")return;const f=await o.addListener("registration",m=>{r.current=m.value,zg().then(h=>{const b=yo(),u={token:m.value,platform:Ii(),environment:_g()};h&&(u.pushKey=h),b?.push?.registerApnsToken?.(u)})}),p=await o.addListener("registrationError",m=>{console.warn("[Push] APNs registration error:",m)});if(await o.register().catch(()=>{}),i){f.remove(),p.remove();return}l.push(()=>{f.remove()},()=>{p.remove()})}).catch(()=>{}),()=>{i=!0,l.forEach(o=>o())}},[e,s]),d.useEffect(()=>{if(s)return;const i=r.current;if(!i)return;r.current=null,yo()?.push?.unregisterApnsToken?.({token:i})},[s])},ga=n=>{const e=fe.c(12),{side:s,isResizing:r,ariaLabel:i,handleProps:l}=n,o=s==="left"?"inset-e-0":"inset-s-0";let a;e[0]!==o?(a=se("absolute inset-y-0 z-50 w-6 cursor-col-resize touch-none",o),e[0]=o,e[1]=a):a=e[1];const f=s==="left"?"inset-e-0":"inset-s-0",p=r&&"bg-[var(--interactive-border)]";let m;e[2]!==f||e[3]!==p?(m=se("absolute inset-y-0 w-[3px] transition-colors",f,p),e[2]=f,e[3]=p,e[4]=m):m=e[4];let h;e[5]!==m?(h=t.jsx("div",{className:m}),e[5]=m,e[6]=h):h=e[6];let b;return e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==h?(b=t.jsx("div",{className:a,role:"separator","aria-orientation":"vertical","aria-label":i,...l,children:h}),e[7]=i,e[8]=l,e[9]=a,e[10]=h,e[11]=b):b=e[11],b},Fg=320,$g=380,ba=280,Wg=560,Vg=900;function xa(n,e,s,r){const i=fe.c(23),l=r===void 0?Wg:r,o=d.useRef(null);let a;i[0]!==s||i[1]!==l||i[2]!==e?(a=()=>{if(typeof window>"u")return s;const _=Number.parseInt(window.localStorage.getItem(e)??"",10);return Number.isFinite(_)?Math.min(l,Math.max(ba,_)):s},i[0]=s,i[1]=l,i[2]=e,i[3]=a):a=i[3];const[f,p]=d.useState(a),[m,h]=d.useState(!1),b=d.useRef(0),u=d.useRef(f),g=d.useRef(null),y=d.useRef(null);let w;i[4]!==l?(w=_=>Math.min(l,Math.max(ba,Math.round(_))),i[4]=l,i[5]=w):w=i[5];const j=w;let S;i[6]===Symbol.for("react.memo_cache_sentinel")?(S=_=>{const A=o.current;A&&(A.style.width=`${_}px`,A.style.minWidth=`${_}px`,A.style.maxWidth=`${_}px`,A.style.setProperty("--oc-ipad-sidebar-width",`${_}px`))},i[6]=S):S=i[6];const M=S;let I;i[7]!==f?(I=_=>{try{_.currentTarget.setPointerCapture(_.pointerId)}catch{}y.current=_.pointerId,b.current=_.clientX,u.current=f,g.current=f,h(!0),_.preventDefault()},i[7]=f,i[8]=I):I=i[8];const E=I;let C;i[9]!==j||i[10]!==n?(C=_=>{if(y.current!==_.pointerId)return;const A=(n==="left"?1:-1)*(gc(_.currentTarget)?-1:1),R=j(u.current+(_.clientX-b.current)*A);g.current!==R&&(g.current=R,M(R))},i[9]=j,i[10]=n,i[11]=C):C=i[11];const N=C;let v;i[12]!==j||i[13]!==e?(v=_=>{if(y.current!==_.pointerId)return;try{_.currentTarget.releasePointerCapture(_.pointerId)}catch{}const A=j(g.current??u.current);y.current=null,g.current=null,h(!1),p(A);try{window.localStorage.setItem(e,String(A))}catch{}},i[12]=j,i[13]=e,i[14]=v):v=i[14];const T=v;let O;i[15]!==E||i[16]!==T||i[17]!==N?(O={onPointerDown:E,onPointerMove:N,onPointerUp:T,onPointerCancel:T},i[15]=E,i[16]=T,i[17]=N,i[18]=O):O=i[18];const B=O;let z;return i[19]!==B||i[20]!==m||i[21]!==f?(z={asideRef:o,width:f,isResizing:m,handleProps:B},i[19]=B,i[20]=m,i[21]=f,i[22]=z):z=i[22],z}const Ug=["general","isolated-spaces","appearance","chat","notifications","sessions","routing","git","magic-prompts","snippets","behavior","agents","commands","mcp","plugins","skills.installed","skills.catalog","providers","web-search","usage","voice","integrations","about"],Gg=1e3,Kg=({onActiveConnectionDeleted:n})=>{const{t:e,direction:s}=xe();pf();const[r,i]=d.useState(!1);d.useEffect(()=>$e.subscribe((H,ee)=>{H.currentSessionId&&H.currentSessionId!==ee.currentSessionId&&Ve.getState().setRunOverviewKey(null)}),[]);const l=Ve(H=>H.runOverviewKey!==null);d.useEffect(()=>{l&&i(!1)},[l]);const[o,a]=d.useState(null),[f,p]=d.useState(!1),[m,h]=d.useState("changes"),b=d.useCallback(()=>{const{mobileWorkspaceTabOrder:H,mobileWorkspaceHiddenTabs:ee}=Ve.getState(),ve=xc(H,ee);h(ge=>ve.includes(ge)?ge:ve[0]),p(!0)},[]),[u,g]=d.useState(null),[y,w]=d.useState("nav"),[j,S]=d.useState(null),M=Ve(H=>H.setSettingsPage),I=Ve(H=>H.wideChatLayoutEnabled),E=Us(H=>H.available),C=Us(H=>H.runtimeType),N=d.useMemo(()=>_i(),[]),v=Ks(H=>H.mcpServers),T=Ks(H=>H.setMcpDraft),O=Ks(H=>H.setSelectedMcp),B=d.useCallback(()=>{a(null),g(null)},[]),z=d.useCallback(H=>{a(H)},[]),_=d.useCallback(()=>{p(!1)},[]),A=d.useCallback(H=>{w(H),z("settings")},[z]),{enabled:R,roomyForPanels:D}=Ei(),L=au()==="portrait",K=lu(),[F,U]=d.useState(()=>cu().roomyForPanels),Q=d.useCallback(()=>{U(H=>!H)},[]);d.useEffect(()=>{R||U(!1)},[R]);const le=d.useCallback(()=>{S(null),h("files"),p(!0)},[]);d.useEffect(()=>xi(H=>{if(H.type!=="file-open-request")return;const ee=H.directory??ws.getState().currentDirectory;ee&&(Ve.getState().openContextFile(ee,H.path),le())}),[le]),d.useEffect(()=>xi(H=>{if(H.type!=="plan-open-request")return;const ee=hf(H.directory??ws.getState().currentDirectory,H.projectId);ee&&g({id:H.planId,title:H.title,projectRef:ee})}),[]);const ce=d.useCallback((H=null)=>{S(H),h("changes"),p(!0)},[]),oe=xa("left","openchamber.ipad.leftSidebarWidth",Fg),re=xa("right","openchamber.ipad.rightSidebarWidth",$g,Vg),ie=D,k=ie&&f?re.width:0,q=R&&F?oe.width:0;d.useEffect(()=>{if(typeof document>"u")return;const H=document.documentElement;return H.style.setProperty("--oc-chat-inset-left",`${q}px`),H.style.setProperty("--oc-chat-inset-right",`${k}px`),()=>{H.style.removeProperty("--oc-chat-inset-left"),H.style.removeProperty("--oc-chat-inset-right")}},[q,k]),d.useEffect(()=>{if(typeof document>"u")return;const H=document.documentElement;return H.classList.toggle("wide-chat-layout",I),()=>H.classList.remove("wide-chat-layout")},[I]),d.useEffect(()=>{if(typeof document>"u")return;const H=R&&(L||K),ee=document.documentElement;return ee.classList.toggle("oc-keep-draft-starters",H),()=>ee.classList.remove("oc-keep-draft-starters")},[K,R,L]);const G=d.useMemo(()=>({openChanges:({diffPath:H,staged:ee}={})=>{ce(H?{path:H,staged:ee===!0}:null)},openFiles:()=>le(),openSettings:()=>A("nav"),openSourceBoard:()=>z("board")}),[ce,le,A,z]),Z=d.useMemo(()=>({openSessions:()=>{R?U(!0):i(!0)},openView:H=>{if(H==="files"){le();return}if(H==="mcp"){h("mcp"),p(!0);return}z(H)},openChanges:({path:H,staged:ee}={})=>{ce(H?{path:H,staged:ee===!0}:null)},openSettings:H=>{H&&M(H),A(H?"page-content":"nav")}}),[R,ce,le,A,z,M]);Dg(Z);const me=d.useRef(null),ue=()=>{R?U(!0):i(!0)},X=()=>b();ro(me,{onLeftEdgeSwipe:s==="rtl"?X:ue,onRightEdgeSwipe:s==="rtl"?ue:X});const de=d.useRef(null),we=d.useCallback(H=>{de.current=H},[]),Se=d.useCallback(()=>du()?!0:u?(g(null),!0):o==="settings"&&de.current?.()?!0:o?(B(),!0):f?(_(),!0):r?(i(!1),!0):!1,[o,B,_,u,r,f]);uu(Se);const be=!N&&E&&(C==="desktop"||C==="web"),ye=R?"dialog":"fullscreen",Te=d.useMemo(()=>({instanceLabel:N?bs():null,onOpenInstances:N?()=>z("instances"):void 0,onOpenSettings:()=>A("nav"),onOpenUsage:()=>z("usage"),onOpenScheduled:()=>z("scheduled"),onOpenArchive:()=>z("archive"),onOpenSourceBoard:()=>z("board"),onOpenUpdate:be?()=>z("update"):void 0}),[A,z,N,be]),Ee=d.useCallback(H=>{B(),i(!1),H==="file"&&le()},[B,le]),De=d.useCallback(()=>{B(),i(!1)},[B]),je=d.useCallback(()=>{B(),i(!1),R&&!D&&U(!1)},[B,R,D]),Ne=d.useCallback(()=>{const H="new-mcp-server";let ee=H,ve=1;for(;v.some(Ce=>Ce.name===ee);)ee=`${H}-${ve}`,ve+=1;T({name:ee,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",oauthCallbackPort:"",oauthAuthServerMetadataUrl:"",protocol:"legacy",timeoutStartup:"",timeoutCatalog:"",timeoutExecution:"",codemode:"default",disabled:!1}),O(ee),M("mcp"),A("page-content")},[v,A,T,O,M]);return t.jsx(fu,{actions:G,children:t.jsxs("div",{className:"oc-mobile-app-shell main-content-safe-area flex h-[100dvh] flex-row bg-background text-foreground","data-page-scroll-lock":"true",children:[R?t.jsxs("aside",{ref:oe.asideRef,className:se("relative flex h-full shrink-0 flex-col overflow-hidden border-e border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!F&&"border-e-0"),style:{width:F?oe.width:0,minWidth:F?oe.width:0,maxWidth:F?oe.width:0,"--oc-ipad-sidebar-width":`${oe.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:oe.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!F,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:se("flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",oe.isResizing&&"pointer-events-none",!F&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(st,{children:t.jsx(ia,{open:!0,variant:"sidebar",onOpenChange:H=>{!H&&!D&&U(!1)},footer:Te})})}),F?t.jsx(ga,{side:"left",isResizing:oe.isResizing,ariaLabel:e("sidebar.resize.leftPanelAria"),handleProps:oe.handleProps}):null]}):null,t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col","data-page-scroll-lock":"true",children:[t.jsx(zp,{onOpenSessions:()=>R?Q():i(!0),onOpenWorkspace:b,compactTitle:R}),t.jsxs("main",{ref:me,className:"relative min-h-0 flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[t.jsx("div",{className:"h-full w-full",children:t.jsx(st,{children:t.jsx(gf,{})})}),t.jsx(st,{children:t.jsx(Cf,{})})]})]}),R?null:t.jsx(ia,{open:r,onOpenChange:i,footer:Te}),t.jsxs("aside",{ref:re.asideRef,className:se("relative flex h-full shrink-0 flex-col overflow-hidden border-s border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!k&&"border-s-0"),style:{width:k,minWidth:k,maxWidth:k,"--oc-ipad-sidebar-width":`${re.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:re.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!k,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:se("flex h-full min-h-0 shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",re.isResizing&&"pointer-events-none",!k&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(st,{children:t.jsx(fg,{open:f,onClose:_,tab:m,onTabChange:h,pendingChangesDiff:j,onOpenPlan:g,onOpenMcpSettings:Ne,variant:ie?"panel":"drawer"})})}),k?t.jsx(ga,{side:"right",isResizing:re.isResizing,ariaLabel:e("sidebar.resize.rightPanelAria"),handleProps:re.handleProps}):null]}),u?t.jsx(Ut,{open:!0,variant:ye,onClose:()=>g(null),ariaLabel:u.title,title:u.title,children:t.jsx(st,{children:t.jsx(jf,{savedProjectPlan:{projectRef:u.projectRef,planId:u.id},onNavigatedToChat:()=>{B(),_()}})})}):null,o==="instances"&&N?t.jsx(Ut,{open:!0,variant:ye,dialogAlign:"app",onClose:B,ariaLabel:e("mobile.menu.instances"),title:e("mobile.menu.instances"),children:t.jsx(Wp,{onConnect:B,onActiveConnectionDeleted:n})}):null,o==="settings"?t.jsx(Ut,{open:!0,variant:ye,dialogAlign:"app",onClose:B,ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(st,{children:t.jsx(vf,{forceMobile:!0,isWindowed:!0,initialMobileStage:y,registerBackHandler:we,visiblePageSlugs:[...Ug],onClose:B})})}):null,o==="usage"?t.jsx(Ut,{open:!0,variant:ye,dialogAlign:"app",onClose:B,ariaLabel:e("usageStats.title"),title:e("usageStats.title"),children:t.jsx(st,{children:t.jsx($f,{})})}):null,o==="scheduled"?t.jsx(Ut,{open:!0,variant:ye,dialogAlign:"app",onClose:B,ariaLabel:e("sessions.scheduledTasks.dialog.title"),title:e("sessions.scheduledTasks.dialog.title"),children:t.jsx(st,{children:t.jsx(Uf,{layout:"mobile",onLeave:Ee})})}):null,o==="board"?t.jsx(Ut,{open:!0,variant:ye,dialogAlign:"app",onClose:B,ariaLabel:e("sourceBoard.title"),headerless:!0,children:t.jsx(st,{children:t.jsx(Vf,{onLeave:De,onClose:B})})}):null,o==="archive"?t.jsx(Ut,{open:!0,variant:ye,dialogAlign:"app",onClose:B,ariaLabel:e("sessions.archivePage.title"),title:e("sessions.archivePage.title"),children:t.jsx(st,{children:t.jsx(Wf,{layout:"mobile",onLeave:je})})}):null,o==="update"?t.jsx(Ut,{open:!0,variant:ye,dialogAlign:"app",onClose:B,ariaLabel:e("mobile.menu.update"),title:e("mobile.menu.update"),children:t.jsx(st,{children:t.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:t.jsx(wf,{initialUpdateDialogOpen:!0})})})}):null]})})};function qg({apis:n}){const e=Ve(k=>k.isolatedSpacesEnabled),{t:s}=xe(),r=wt(k=>k.initializeApp),i=wt(k=>k.isInitialized),l=wt(k=>k.isConnected),o=wt(k=>k.connectionPhase),a=wt(k=>k.providers.length),f=wt(k=>k.agents.length),p=wt(k=>k.loadProviders),m=wt(k=>k.loadAgents),h=ws(k=>k.currentDirectory),b=$e(k=>k.error),u=$e(k=>k.clearError),g=Ve(k=>k.setIsMobile),y=Xa(k=>k.refreshAll),w=Gd(k=>k.refreshStatus),j=ut(k=>k.projects),S=vs(k=>k.activeSessions),M=vs(k=>k.archivedSessions),I=vs(k=>k.status==="ready"),E=d.useMemo(()=>[...S,...M],[S,M]);ef({hasAuthoritativeGlobalSessions:I,sessions:E});const[C,N]=d.useState(0),[v,T]=d.useState(0),[O,B]=d.useState(!1),[z,_]=d.useState("pending"),[A,R]=d.useState(null),D=d.useMemo(()=>bs(),[]),[,V]=d.useReducer(k=>k+1,0),L=d.useMemo(()=>_i(),[]),K=d.useRef(0),F=d.useRef(0),U=d.useCallback(()=>{const k=Mt(),q=F.current+1;if(F.current=q,!k){bn("resume:auto-connect",{}),xn();return}bn("resume:reprobe",{});const G=()=>{r(),y(n.sourceControl,{force:!0}),w(n.linear,{force:!0}),a===0&&p({source:"mobileApp:nativeResume"}),f===0&&m({source:"mobileApp:nativeResume"})},Z=ue=>{bn("resume:disconnect",{reason:ue}),Ws({apiBaseUrl:"",clientToken:null,runtimeKey:Zn}),N(X=>X+1)};dr().then(ue=>{if(F.current===q){if(ue==="no-connection"){Z("no-connection");return}if(ue==="needs-login"){R({kind:"auth-expired",label:bs()??""}),Z("needs-login");return}if(ue==="relay-limit"){R({kind:"relay-limit",label:bs()??""}),Z("relay-limit");return}if(ue==="unreachable"){const X=[4e3,1e4],de=we=>{window.setTimeout(()=>{if(F.current!==q)return;const Se=we===X.length-1;dr({fast:!Se}).then(be=>{if(F.current===q&&be!=="switched"){if(be==="unchanged"){G();return}if(be==="needs-login"){R({kind:"auth-expired",label:bs()??""}),Z("retry-needs-login");return}if(be==="relay-limit"){R({kind:"relay-limit",label:bs()??""}),Z("retry-relay-limit");return}if(!Se){de(we+1);return}Z(`retry-${be}`)}})},X[we])};de(0);return}ue!=="switched"&&G()}});const me=Date.now();me-K.current>=Gg&&(K.current=me,window.dispatchEvent(new Event("openchamber:system-resume")))},[f,n.sourceControl,n.linear,r,m,p,a,y,w]);Kd(),qd(U),d.useEffect(()=>{if(!L)return;let k;const q=()=>{window.clearTimeout(k),k=window.setTimeout(()=>U(),1500)};return window.addEventListener("online",q),()=>{window.removeEventListener("online",q),window.clearTimeout(k)}},[L,U]),d.useEffect(()=>{if(L)return vo.subscribe((k,q)=>{k.state==="expired"&&q.state!=="expired"&&(U(),vo.getState().markAuthenticated())})},[L,U]),d.useEffect(()=>{if(L)return bc(k=>{yr(k)&&U()})},[L,U]),d.useEffect(()=>(wo(n),()=>wo(null)),[n]),d.useEffect(()=>ja(k=>{if(bn("endpoint:changed",{runtimeKey:k.runtimeKey||"none",previousRuntimeKey:k.previousRuntimeKey||"none",connected:!!k.apiBaseUrl}),!!k.runtimeKey&&k.runtimeKey===k.previousRuntimeKey){tf(),V();return}sf(k),T(G=>G+1),N(G=>G+1)}),[]),d.useEffect(()=>{if(!L||l||Mt()){_("done");return}let k=!1;return _("attempting"),(async()=>{const q=await xn().catch(()=>({status:"no-candidate"}));k||(q.status==="unreachable"||q.status==="relay-limit"?R({kind:q.status,label:q.label}):q.status==="needs-login"&&R({kind:"auth-expired",label:q.label}),_("done"),q.status==="unreachable"&&xn({fast:!1,skipIfConnected:!0}).catch(()=>null))})(),()=>{k=!0}},[]),d.useEffect(()=>{if(!L||!Mt())return;let k=!1;const q=G=>{bn("cold-launch:drop",{kind:G?.kind??"unknown"}),G&&R(G),Ws({apiBaseUrl:"",clientToken:null,runtimeKey:Zn}),N(Z=>Z+1)};return dr().then(async G=>{if(k||G==="switched"||G==="unchanged")return;const Z=bs();if(G==="needs-login"){q({kind:"auth-expired",label:Z??""});return}if(G==="unreachable"){q(Z?{kind:"unreachable",label:Z}:null),xn({fast:!1,skipIfConnected:!0}).catch(()=>null);return}if(G==="relay-limit"){q({kind:"relay-limit",label:Z??""});return}const me=await xn().catch(()=>({status:"no-candidate"}));k||me.status==="connected"||(me.status==="needs-login"?q({kind:"auth-expired",label:me.label}):me.status==="unreachable"||me.status==="relay-limit"?q({kind:me.status,label:me.label}):q(null))}),()=>{k=!0}},[]),d.useEffect(()=>{g(!0)},[g]),d.useEffect(()=>{L&&!Mt()||r()},[C,r,L]),d.useEffect(()=>{l&&(a===0&&p({source:"mobileApp:recovery"}),f===0&&m({source:"mobileApp:recovery"}))},[f,l,m,p,a]);const Q=d.useRef(!1),[le,ce]=d.useState(L);d.useEffect(()=>{if(!L||!l||Q.current)return;let k=!1;const q=window.setTimeout(()=>ce(!1),6e3);return(async()=>{const G=await nf({refresh:!0});k||(G!=="failed"&&(Q.current=!0),ce(!1))})(),()=>{k=!0,window.clearTimeout(q)}},[C,l,L]),d.useEffect(()=>{l&&fi.setDirectory(h)},[h,l]),d.useEffect(()=>{l&&(y(n.sourceControl,{force:!0}),w(n.linear,{force:!0}))},[n.sourceControl,n.linear,l,y,w]),d.useEffect(()=>{if(!l||j.length===0)return;let k=!1;return(async()=>{const G=new Map($e.getState().availableWorktreesByProject);if(await Promise.all(j.map(async ue=>{const X=ue.path.replace(/\\/g,"/").replace(/\/+$/,"");if(X)try{if(!(gt.getState().directories.get(X)?.isGitRepo??await Xs(()=>import("./useAppFontEffects-Dm6zEvrf.js").then(be=>be.oQ),__vite__mapDeps([9,1,2,3,4,5,6,7,8,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,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83])).then(be=>be.checkIsGitRepository(X))))return;const Se=await Ua({id:ue.id,path:X});if(k)return;G.set(X,Se)}catch{}})),k)return;const Z=Ga(j,G),me=$e.getState().availableWorktreesByProject;iu(Z,me)||$e.setState({availableWorktrees:[...Z.values()].flat(),availableWorktreesByProject:Z})})(),()=>{k=!0}},[l,j]),d.useEffect(()=>{if(!l)return;let k=!1;const q=xi(G=>{G.type==="worktree-changed"&&ou(j,G.directories,()=>k)});return()=>{k=!0,q()}},[l,j]),d.useEffect(()=>{if(!b)return;const k=window.setTimeout(()=>u(),5e3);return()=>window.clearTimeout(k)},[u,b]),d.useEffect(()=>{if(!(!l&&(L?!!Mt():!0))){B(!1);return}const q=window.setTimeout(()=>{B(!0)},L?4e3:8e3);return()=>window.clearTimeout(q)},[l,L,C,v]),Hd(),Xd({enabled:!0}),rf(),Jd(),Yd(),of(),af(h||null),lf(),Lg({enabled:L&&l}),Mg({ready:L&&l&&i});const oe=gg(),re=!l&&o==="reconnecting";if(!oe)return t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-[var(--splash-background,var(--surface-background))] text-foreground",children:t.jsx(Vs,{width:120,height:120,isAnimated:!0,variant:"splash"})});const ie=!!Mt();return L&&(!ie||!l&&!re)?ie?t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-[var(--splash-background,var(--surface-background))] px-6 text-center text-foreground",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-4",children:[t.jsx(Vs,{width:120,height:120,isAnimated:!O,variant:"splash"}),O?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:s("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-markdown text-muted-foreground",children:s("mobile.connect.recovery.description")})]}),t.jsx(Ie,{type:"button",variant:"outline",onClick:()=>{Ws({apiBaseUrl:"",clientToken:null,runtimeKey:Zn}),N(k=>k+1)},children:s("mobile.connect.cancelPassword")})]}):null]})}):z!=="done"?t.jsxs("main",{className:"relative flex min-h-dvh items-center justify-center bg-[var(--splash-background,var(--surface-background))] text-foreground",children:[t.jsx(Vs,{width:120,height:120,isAnimated:!0,variant:"splash"}),D?t.jsxs("div",{className:"absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center",children:[t.jsx("p",{className:"typography-small text-muted-foreground",children:s("mobile.connect.splash.connectingTo")}),t.jsxs("p",{className:"typography-small text-foreground",children:[D,t.jsx(Qd,{})]})]}):null]}):t.jsx(t.Fragment,{children:t.jsx(wp,{onConnected:()=>N(k=>k+1),notice:A})}):!l&&!re?O?t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground",children:t.jsxs("div",{className:"max-w-sm space-y-3",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:s("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-markdown text-muted-foreground",children:s("sessionAuth.error.networkDescription")})]})}):t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-[var(--splash-background,var(--surface-background))] text-foreground",children:t.jsx(Vs,{width:120,height:120,isAnimated:!0,variant:"splash"})}):t.jsx(st,{children:t.jsx(Zd,{sdk:fi.getSdkClient(),directory:h||"",children:t.jsx(eu,{apis:n,children:t.jsx(tu,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[t.jsx(cf,{ready:!L||!le,animated:!0}),t.jsx(su,{backgroundWorkEnabled:i}),t.jsx(df,{}),t.jsx(Am,{}),t.jsx(Kg,{onActiveConnectionDeleted:()=>{dp(),Ws({apiBaseUrl:"",clientToken:null,runtimeKey:Zn}),N(k=>k+1)}}),t.jsx(nu,{}),t.jsx(ru,{}),e?t.jsxs(t.Fragment,{children:[t.jsx(kf,{}),t.jsx(uf,{}),t.jsx(Sf,{}),t.jsx(ff,{}),t.jsx(Nf,{})]}):null,t.jsx(Om,{}),i?t.jsx(mf,{}):null]})})})},v)})}function Hg(n){const e=fe.c(7),s=d.useSyncExternalStore(Xg,Mt,Mt);let r;e[0]!==s?(r=!_i()||!!s,e[0]=s,e[1]=r):r=e[1];let i;e[2]!==n?(i=t.jsx(qg,{...n}),e[2]=n,e[3]=i):i=e[3];let l;return e[4]!==r||e[5]!==i?(l=t.jsx(bf,{enabled:r,children:i}),e[4]=r,e[5]=i,e[6]=l):l=e[6],l}function Xg(n){return ja(()=>n())}function Vy(n){window.__OPENCHAMBER_SURFACE__="mobile",mu(),yf({logLabel:"[mobile-main]",onAppearanceSettled:jm}),Em(),pu();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");const r=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",i=r?{...n,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:n,l=t.jsx(Hg,{apis:i});sc.createRoot(e).render(t.jsx(ui.StrictMode,{children:t.jsx(hu,{children:t.jsx(gu,{children:t.jsx(bu,{children:t.jsx(xf,{children:r?l:t.jsx(xu,{children:l})})})})})}))}export{Vy as renderMobileApp};
|