@vantran-se/openchamber-web 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/assets/{CodeMirrorCommentWidgets-B82Oye3V.js → CodeMirrorCommentWidgets-CWhdh0wf.js} +1 -1
  2. package/dist/assets/{DiffView-DJLmWn6Z.js → DiffView-CX3wAX2S.js} +1 -1
  3. package/dist/assets/{FilesView-DjksmZRo.js → FilesView-OL3CON3r.js} +1 -1
  4. package/dist/assets/{GitView-DiUsUIgr.js → GitView-DKIjpnu4.js} +1 -1
  5. package/dist/assets/{GuestAttachDialog-CYwWYLr3.js → GuestAttachDialog-BIa9jCfL.js} +1 -1
  6. package/dist/assets/{GuestSurfacePane-CmctyRI4.js → GuestSurfacePane-B_cqX5I5.js} +1 -1
  7. package/dist/assets/{JsonTreeView-DOHHcbgJ.js → JsonTreeView-CtI1Mqwo.js} +1 -1
  8. package/dist/assets/{LinearIssuesView-DaqnylcV.js → LinearIssuesView-BD2zLu-r.js} +1 -1
  9. package/dist/assets/{MarkdownImageGallery-HJNvWt7L.js → MarkdownImageGallery-DFiTFZgj.js} +1 -1
  10. package/dist/assets/{MarkdownRendererImpl-nDZRGg2I.js → MarkdownRendererImpl-DZm5sf1W.js} +1 -1
  11. package/dist/assets/{OnboardingScreen-C2B5Bsof.js → OnboardingScreen-B8TxloXZ.js} +1 -1
  12. package/dist/assets/{PatchDiff-C4FLBjpt.js → PatchDiff--Civs1xY.js} +1 -1
  13. package/dist/assets/{PierreDiffViewer-C_1S9c9n.js → PierreDiffViewer-BlDmw3-A.js} +1 -1
  14. package/dist/assets/{PlanView-_eZvb-G5.js → PlanView-DyH2SyCP.js} +1 -1
  15. package/dist/assets/{PluginPane-sM8fcZIV.js → PluginPane-BibJit86.js} +1 -1
  16. package/dist/assets/{SettingsView-BRfr46hb.js → SettingsView-h-VpVO47.js} +1 -1
  17. package/dist/assets/{SettingsWindow-CcUDwQHg.js → SettingsWindow-y9WpZqK6.js} +1 -1
  18. package/dist/assets/{SubmoduleDiffSummary-CrN1ZGwl.js → SubmoduleDiffSummary-DeFmhPFZ.js} +1 -1
  19. package/dist/assets/{ToolOutputDialog-Cij4jI09.js → ToolOutputDialog-8DmF7_PZ.js} +1 -1
  20. package/dist/assets/{ToolPartDiffPreview-BXzwQ-JY.js → ToolPartDiffPreview-Ca15DKE1.js} +1 -1
  21. package/dist/assets/{VirtualizedFileDiff-DSWTLJNH.js → VirtualizedFileDiff-BfEBad09.js} +1 -1
  22. package/dist/assets/{WalkthroughView-CpUUgY8H.js → WalkthroughView-Cj3K8Xz6.js} +1 -1
  23. package/dist/assets/{appThemeRegistry-B5tHTkR8.js → appThemeRegistry-DAdawJZn.js} +1 -1
  24. package/dist/assets/{commitAndPush-D7D8qV8p.js → commitAndPush-BIPfOMXY.js} +1 -1
  25. package/dist/assets/{computeVirtualFileMetrics-cq9uQ30i.js → computeVirtualFileMetrics-RF-KjfUH.js} +1 -1
  26. package/dist/assets/{de-CUO1-KqF.js → de-BqCNGROu.js} +1 -1
  27. package/dist/assets/{es-BlbC6sGJ.js → es-BTPpTRgN.js} +1 -1
  28. package/dist/assets/{fr-D2nwe_0W.js → fr-hxbzMdAg.js} +1 -1
  29. package/dist/assets/{index-BQOoYIOu.js → index-CL7ZQ94-.js} +1 -1
  30. package/dist/assets/{isDiffPlainText-D0obJ2p8.js → isDiffPlainText-D2yJ9fO6.js} +1 -1
  31. package/dist/assets/{isFilePlainText-DB3_rjyW.js → isFilePlainText-BwMEq1Ey.js} +1 -1
  32. package/dist/assets/{ja-CA7vnDsZ.js → ja-_zLwwYiy.js} +1 -1
  33. package/dist/assets/{ko-Chy6a9l-.js → ko-CFn3Dzhc.js} +1 -1
  34. package/dist/assets/{main-B9JFK3vF.js → main-BLJaug9I.js} +4 -4
  35. package/dist/assets/{main-Bhiqnrhd.js → main-quLSA7jc.js} +2 -2
  36. package/dist/assets/{markdownCore-tfqOFaBd.js → markdownCore-DS9FdwrI.js} +1 -1
  37. package/dist/assets/{miniChat-B0UOL5zA.js → miniChat-D-lJJibr.js} +2 -2
  38. package/dist/assets/{mobile-BJppFIEo.js → mobile-VTtphbW6.js} +2 -2
  39. package/dist/assets/{patchFileDiff-Db6KuwCP.js → patchFileDiff-D9iBcTEi.js} +1 -1
  40. package/dist/assets/{pl-CTR5A_1P.js → pl-DFHE7xac.js} +1 -1
  41. package/dist/assets/{pt-BR-BE1O1KEx.js → pt-BR-CUjZF179.js} +1 -1
  42. package/dist/assets/{renderElectronMiniChatApp-Yz5sfoFh.js → renderElectronMiniChatApp-DF7ch5eM.js} +2 -2
  43. package/dist/assets/{renderMobileApp-QQ-yB8aY.js → renderMobileApp-CNQhdXsi.js} +3 -3
  44. package/dist/assets/{runtimeEndpointReset-DKDdzRzm.js → runtimeEndpointReset-DeaERc0M.js} +3 -3
  45. package/dist/assets/{scheduledTasksApi-C5sCuNqf.js → scheduledTasksApi-BD6Vx9pu.js} +1 -1
  46. package/dist/assets/{shikiHighlight-xURoo5t_.js → shikiHighlight-_HeCCHx1.js} +1 -1
  47. package/dist/assets/{textMateThemeFromAppTheme-BZLGuYTU.js → textMateThemeFromAppTheme-C95XdFGj.js} +1 -1
  48. package/dist/assets/{tr-Bh5vK6cW.js → tr-BB6sA_zH.js} +1 -1
  49. package/dist/assets/{uk-CLDkZFy_.js → uk-CB4o8g-o.js} +1 -1
  50. package/dist/assets/{useAppFontEffects-BxrtCnfR.js → useAppFontEffects-ZM9ij19-.js} +48 -48
  51. package/dist/assets/{useInlineCommentController-CeXuR-SR.js → useInlineCommentController-CkfxMJPy.js} +1 -1
  52. package/dist/assets/{useRootScrollLock-DgWxezc1.js → useRootScrollLock-BtiAC1fj.js} +2 -2
  53. package/dist/assets/{vendor-codemirror-language-data-DOuaQUZ0.js → vendor-codemirror-language-data-U-lXzXNK.js} +2 -2
  54. package/dist/assets/{web-components-63H1h21j.js → web-components-C583Pmfm.js} +1 -1
  55. package/dist/assets/{zh-CN-DODgcmYj.js → zh-CN-BRyDuWhc.js} +1 -1
  56. package/dist/assets/{zh-TW-ByNfIwLA.js → zh-TW-BDGbWA1Q.js} +1 -1
  57. package/dist/index.html +1 -1
  58. package/dist/mini-chat.html +1 -1
  59. package/dist/mobile.html +1 -1
  60. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesView-DjksmZRo.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-CvLgnuNI.js","assets/vendor-zod-Gea9uBlY.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-_BAHQo4R.js","assets/index-CLcM8HKx.css","assets/useAppFontEffects-BxrtCnfR.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-CsXYnR5c.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-use-sync-external-store-D6wYuSt-.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-framer-motion-Bq3iTZ6r.js","assets/vendor-motion-dom-DcCgeG69.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-ClYN8CzB.js","assets/vendor-tanstack-virtual-core-BewVQryB.js","assets/contextPanelEmbeddedChat-CirXEPJq.js","assets/vendor-sonner-DFyL3AvE.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-codemirror-language-BgPj_McA.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-DzPz9Wgq.js","assets/vendor-codemirror-lang-json-CMBS2tG9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-O0cZX78y.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CfgK872x.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-BPGOH9ye.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-DOuaQUZ0.js","assets/vendor-codemirror-lang-python-HahnQaAS.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-B7H_j0iU.js","assets/vendor-legendapp-list-BuBPBC3R.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/runtimeEndpointReset-DKDdzRzm.js","assets/GuestAttachDialog-CYwWYLr3.js","assets/PluginPane-sM8fcZIV.js","assets/shikiHighlight-xURoo5t_.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-DOHHcbgJ.js","assets/web-components-63H1h21j.js","assets/computeVirtualFileMetrics-cq9uQ30i.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-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.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/Virtualizer-CZlLSacm.js","assets/isFilePlainText-DB3_rjyW.js","assets/appThemeRegistry-B5tHTkR8.js","assets/textMateThemeFromAppTheme-BZLGuYTU.js","assets/Virtualizer-D_a8gKmg.js","assets/scheduledTasksApi-C5sCuNqf.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/useInlineCommentController-CeXuR-SR.js","assets/CodeMirrorCommentWidgets-B82Oye3V.js","assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/vendor-capacitor-push-notifications-KNe1zSBF.js"])))=>i.map(i=>d[i]);
2
- import{f as le,r as bn,j as t,R as u,c as Lt,h as mo}from"./vendor-react-BUCujlKS.js";import"./vendor-katex-CHD9BdDO.js";import{u as it,a as Gt,b as ri,d as mr,i as Te,e as st,s as Dt,f as fs,h as Sn,j as po,k as ii,l as ho,p as go,m as bo,n as ht,o as xo,q as Rs,t as pr,G as hr,v as yo,x as gr,y as oi,z as br,A as xr,B as yr,M as Es,C as vo,D as wo}from"./index-CvLgnuNI.js";import{u as Nn,a as jo,b as We,c as ai,d as li,r as Cn,e as ko,f as me,t as fe,o as So,I as X,B as ge,g as No,O as _t,h as J,P as Co,i as Ro,j as Eo,k as Po,l as He,m as Ao,n as xt,p as Io,q as vr,s as To,v as Do,w as Rn,x as _o,y as Mo,z as Se,A as zo,C as En,D as Pn,E as An,F as Oo,S as Os,G as In,H as Bo,J as ci,K as Fe,L as ui,M as Lo,N as $o,Q as Fo,R as di,T as fi,U as mi,V as pi,W as hi,X as gi,Y as Wo,Z as Vo,_ as Tn,$ as Uo,a0 as Go,a1 as Ko,a2 as Ho,a3 as ss,a4 as Ps,a5 as qo,a6 as bi,a7 as Jo,a8 as Yo,a9 as Ks,aa as xi,ab as yi,ac as is,ad as Ot,ae as Qo,af as Xo,ag as Zo,ah as ea,ai as Dn,aj as ta,ak as sa,al as na,am as ra,an as ia,ao as oa,ap as aa,aq as la,ar as wr,as as ca,at as ua,au as da,av as fa,aw as ma,ax as As,ay as pa,az as ha,aA as vi,aB as Ve,aC as ga,aD as ba,aE as xa,aF as ya,aG as _n,aH as va,aI as wa,aJ as ja,aK as ka,aL as Sa,aM as Na,aN as Ca,aO as wi,aP as Ra,aQ as Ea,aR as Pa,aS as Aa,aT as Ia,aU as Ta,aV as Da,aW as _a,aX as Ma,aY as za,aZ as Oa,a_ as Ba,a$ as La,b0 as $a,b1 as Fa,b2 as Wa,b3 as Va,b4 as Ua,b5 as Ga,b6 as Ka,b7 as Ha,b8 as qa,b9 as Ja,ba as Ya,bb as Qa,bc as Xa,bd as Za,be as el,bf as tl,bg as sl}from"./useAppFontEffects-BxrtCnfR.js";import{u as Mt,S as Mn,h as nl,a as ji,s as rl,p as il,c as ol,r as al,b as ll,D as cl,N as ul,d as dl,e as fl,g as ml,f as pl,B as hl,i as gl,j as bl,k as xl,l as yl,T as vl,P as wl,O as jl,m as kl,n as Sl,o as Nl,q as Cl,A as Rl,t as El,C as Pl,v as Al,w as Il,U as Tl,x as Dl}from"./runtimeEndpointReset-DKDdzRzm.js";import{_ as $t}from"./vendor-vite-runtime-DD1OZmLC.js";import{S as _l,A as Ml}from"./SettingsView-BRfr46hb.js";import{PlanView as zl}from"./PlanView-_eZvb-G5.js";import{p as Ol}from"./vendor-aparajita-capacitor-secure-storage-5IShChL0.js";import{Capacitor as Bl}from"./vendor-capacitor-core-B4EWRrHz.js";import{k as xn,M as Bs,d as Ll,J as yn,s as ki,a as zn,p as $l,_ as jr,f as On,V as Fl,K as kr,P as Wl,b as Vl,c as Ul,Q as Gl,r as Kl,U as Hl,Z as ql}from"./vendor-remixicon-react-D6dZ0UwF.js";import{f as Bn,h as Ft,i as Ln,P as $n,D as Fn,j as Wn}from"./vendor-dnd-kit-core-BZknOX2w.js";import{s as Vn,S as Un,v as Gn,u as Kn}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Hn}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{c as qn,p as Si}from"./vendor-zustand-BAGL70zf.js";import{toast as Jl}from"./vendor-sonner-DFyL3AvE.js";import{C as Yl,a as Ql,D as Xl,p as Sr}from"./commitAndPush-D7D8qV8p.js";import{u as Zl,a as ec,b as tc,c as sc,i as nc,f as rc,B as ic,C as oc,P as Nr}from"./patchFileDiff-Db6KuwCP.js";import{u as ac,a as lc,i as cc,S as uc,b as dc}from"./SubmoduleDiffSummary-CrN1ZGwl.js";import{P as fc}from"./PierreDiffViewer-C_1S9c9n.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-Gea9uBlY.js";import"./vendor-opencode-client-_BAHQo4R.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.js";import"./contextPanelEmbeddedChat-CirXEPJq.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-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-DOuaQUZ0.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./GuestAttachDialog-CYwWYLr3.js";import"./PluginPane-sM8fcZIV.js";import"./vendor-yaml-3778uTud.js";import"./shikiHighlight-xURoo5t_.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./appThemeRegistry-B5tHTkR8.js";import"./textMateThemeFromAppTheme-BZLGuYTU.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.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-qrcode-DTJ12-WC.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./vendor-strip-json-comments-5dJlOkP1.js";import"./useInlineCommentController-CeXuR-SR.js";import"./CodeMirrorCommentWidgets-B82Oye3V.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./VirtualizedFileDiff-DSWTLJNH.js";import"./web-components-63H1h21j.js";import"./computeVirtualFileMetrics-cq9uQ30i.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-D0obJ2p8.js";import"./vendor-diff-C3JhlQdm.js";import"./Virtualizer-D_a8gKmg.js";let Ni=null,Cr=!1;const mc=new Promise(n=>{Ni=n});function pc(){Cr||(Cr=!0,Ni?.())}const hc=6,gc=n=>n.parentID??null,Rr=n=>{const e=n.replace(/\/+$/,"");return e.slice(e.lastIndexOf("/")+1)||e},bc=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),xc=(n,e)=>{if(!n)return"";let s=null,i=-1;for(const r of e){const o=bc(r.path);(n===o||n.startsWith(`${o}/`))&&o.length>i&&(s=r,i=o.length)}return s?s.label?.trim()||Rr(s.path):Rr(n)},yc=()=>{const n=Nn.getState().activeSessions,e=jo.getState().index.session.unseenCount,s=it.getState().notifyOnSubtasks,i=We.getState().projects,r=ai.getState().ids,o=li.getState().rankById;let a=0;const c=[];for(const d of n){const l=gc(d)!==null,b=(e[d.id]??0)>0&&(!l||s);b&&(a+=1),l||c.push({session:d,unread:b,project:xc(Cn(d),i)})}c.sort((d,l)=>ko(d.session,l.session,r,o));const f=c.slice(0,hc).map(({session:d,unread:l,project:p})=>({id:d.id,title:d.title??"",unread:l,project:p}));return{runtimeKey:Gt(),attentionCount:a,recentSessions:f}},vc="__OPENCHAMBER_WIDGET_SNAPSHOT__",wc=()=>{typeof window>"u"||(window[vc]=()=>{try{return JSON.stringify(yc())}catch{return null}})},cn="mobile-app-update-available",Er="mobile-app-update-toast-dismissed-version",jc=()=>{const n=le.c(8),{t:e}=me(),s=Mt(kc),i=Mt(Sc),r=Mt(Nc),o=Mt(Cc);let a;n[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Set,n[0]=a):a=n[0];const c=bn.useRef(a);let f,d;return n[1]!==s||n[2]!==o||n[3]!==i||n[4]!==e||n[5]!==r?(f=()=>{if(ri()!=="android"||i!=="mobile"||!s||!r||!o){fe.dismiss(cn);return}mr().getItem(Er)!==r&&(c.current.has(r)||(c.current.add(r),fe.info(e("mobileUpdate.toast.available.title"),{id:cn,description:e("mobileUpdate.toast.available.description",{version:r}),duration:1/0,icon:t.jsx(X,{name:"download",className:"h-4 w-4 text-muted-foreground"}),action:{label:e("mobileUpdate.toast.actions.download"),onClick:()=>{So(o)}},cancel:{label:e("mobileUpdate.toast.actions.dismiss"),onClick:()=>{mr().setItem(Er,r),fe.dismiss(cn)}}})))},d=[s,o,i,e,r],n[1]=s,n[2]=o,n[3]=i,n[4]=e,n[5]=r,n[6]=f,n[7]=d):(f=n[6],d=n[7]),bn.useEffect(f,d),null};function kc(n){return n.available}function Sc(n){return n.runtimeType}function Nc(n){return n.info?.version}function Cc(n){return n.info?.downloadUrl}const Pr=300,Rc="openchamber.mobile.connectLog.v1",zt=[];if(typeof window<"u")try{window.localStorage.removeItem(Rc)}catch{}const Jn=(n,e)=>{zt.push({at:Date.now(),step:n,detail:e}),zt.length>Pr&&zt.splice(0,zt.length-Pr)};typeof window<"u"&&Jn("app:launch","{}");const Ec=()=>[...zt],Pc=n=>{const e=new Date(n),s=(i,r=2)=>String(i).padStart(r,"0");return`${s(e.getHours())}:${s(e.getMinutes())}:${s(e.getSeconds())}.${s(e.getMilliseconds(),3)}`},Ci=n=>`${Pc(n.at)} ${n.step}${n.detail&&n.detail!=="{}"?` ${n.detail}`:""}`,Ac=()=>zt.map(Ci).join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesView-OL3CON3r.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-CvLgnuNI.js","assets/vendor-zod-Gea9uBlY.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-_BAHQo4R.js","assets/index-CLcM8HKx.css","assets/useAppFontEffects-ZM9ij19-.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-CsXYnR5c.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-use-sync-external-store-D6wYuSt-.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-framer-motion-Bq3iTZ6r.js","assets/vendor-motion-dom-DcCgeG69.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-ClYN8CzB.js","assets/vendor-tanstack-virtual-core-BewVQryB.js","assets/contextPanelEmbeddedChat-CirXEPJq.js","assets/vendor-sonner-DFyL3AvE.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-codemirror-language-BgPj_McA.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-DzPz9Wgq.js","assets/vendor-codemirror-lang-json-CMBS2tG9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-O0cZX78y.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CfgK872x.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-BPGOH9ye.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-U-lXzXNK.js","assets/vendor-codemirror-lang-python-HahnQaAS.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-B7H_j0iU.js","assets/vendor-legendapp-list-BuBPBC3R.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/runtimeEndpointReset-DeaERc0M.js","assets/GuestAttachDialog-BIa9jCfL.js","assets/PluginPane-BibJit86.js","assets/shikiHighlight-_HeCCHx1.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-CtI1Mqwo.js","assets/web-components-C583Pmfm.js","assets/computeVirtualFileMetrics-RF-KjfUH.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-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.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/Virtualizer-CZlLSacm.js","assets/isFilePlainText-BwMEq1Ey.js","assets/appThemeRegistry-DAdawJZn.js","assets/textMateThemeFromAppTheme-C95XdFGj.js","assets/Virtualizer-D_a8gKmg.js","assets/scheduledTasksApi-BD6Vx9pu.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/useInlineCommentController-CkfxMJPy.js","assets/CodeMirrorCommentWidgets-CWhdh0wf.js","assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/vendor-capacitor-push-notifications-KNe1zSBF.js"])))=>i.map(i=>d[i]);
2
+ import{f as le,r as bn,j as t,R as u,c as Lt,h as mo}from"./vendor-react-BUCujlKS.js";import"./vendor-katex-CHD9BdDO.js";import{u as it,a as Gt,b as ri,d as mr,i as Te,e as st,s as Dt,f as fs,h as Sn,j as po,k as ii,l as ho,p as go,m as bo,n as ht,o as xo,q as Rs,t as pr,G as hr,v as yo,x as gr,y as oi,z as br,A as xr,B as yr,M as Es,C as vo,D as wo}from"./index-CvLgnuNI.js";import{u as Nn,a as jo,b as We,c as ai,d as li,r as Cn,e as ko,f as me,t as fe,o as So,I as X,B as ge,g as No,O as _t,h as J,P as Co,i as Ro,j as Eo,k as Po,l as He,m as Ao,n as xt,p as Io,q as vr,s as To,v as Do,w as Rn,x as _o,y as Mo,z as Se,A as zo,C as En,D as Pn,E as An,F as Oo,S as Os,G as In,H as Bo,J as ci,K as Fe,L as ui,M as Lo,N as $o,Q as Fo,R as di,T as fi,U as mi,V as pi,W as hi,X as gi,Y as Wo,Z as Vo,_ as Tn,$ as Uo,a0 as Go,a1 as Ko,a2 as Ho,a3 as ss,a4 as Ps,a5 as qo,a6 as bi,a7 as Jo,a8 as Yo,a9 as Ks,aa as xi,ab as yi,ac as is,ad as Ot,ae as Qo,af as Xo,ag as Zo,ah as ea,ai as Dn,aj as ta,ak as sa,al as na,am as ra,an as ia,ao as oa,ap as aa,aq as la,ar as wr,as as ca,at as ua,au as da,av as fa,aw as ma,ax as As,ay as pa,az as ha,aA as vi,aB as Ve,aC as ga,aD as ba,aE as xa,aF as ya,aG as _n,aH as va,aI as wa,aJ as ja,aK as ka,aL as Sa,aM as Na,aN as Ca,aO as wi,aP as Ra,aQ as Ea,aR as Pa,aS as Aa,aT as Ia,aU as Ta,aV as Da,aW as _a,aX as Ma,aY as za,aZ as Oa,a_ as Ba,a$ as La,b0 as $a,b1 as Fa,b2 as Wa,b3 as Va,b4 as Ua,b5 as Ga,b6 as Ka,b7 as Ha,b8 as qa,b9 as Ja,ba as Ya,bb as Qa,bc as Xa,bd as Za,be as el,bf as tl,bg as sl}from"./useAppFontEffects-ZM9ij19-.js";import{u as Mt,S as Mn,h as nl,a as ji,s as rl,p as il,c as ol,r as al,b as ll,D as cl,N as ul,d as dl,e as fl,g as ml,f as pl,B as hl,i as gl,j as bl,k as xl,l as yl,T as vl,P as wl,O as jl,m as kl,n as Sl,o as Nl,q as Cl,A as Rl,t as El,C as Pl,v as Al,w as Il,U as Tl,x as Dl}from"./runtimeEndpointReset-DeaERc0M.js";import{_ as $t}from"./vendor-vite-runtime-DD1OZmLC.js";import{S as _l,A as Ml}from"./SettingsView-h-VpVO47.js";import{PlanView as zl}from"./PlanView-DyH2SyCP.js";import{p as Ol}from"./vendor-aparajita-capacitor-secure-storage-5IShChL0.js";import{Capacitor as Bl}from"./vendor-capacitor-core-B4EWRrHz.js";import{k as xn,M as Bs,d as Ll,J as yn,s as ki,a as zn,p as $l,_ as jr,f as On,V as Fl,K as kr,P as Wl,b as Vl,c as Ul,Q as Gl,r as Kl,U as Hl,Z as ql}from"./vendor-remixicon-react-D6dZ0UwF.js";import{f as Bn,h as Ft,i as Ln,P as $n,D as Fn,j as Wn}from"./vendor-dnd-kit-core-BZknOX2w.js";import{s as Vn,S as Un,v as Gn,u as Kn}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Hn}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{c as qn,p as Si}from"./vendor-zustand-BAGL70zf.js";import{toast as Jl}from"./vendor-sonner-DFyL3AvE.js";import{C as Yl,a as Ql,D as Xl,p as Sr}from"./commitAndPush-BIPfOMXY.js";import{u as Zl,a as ec,b as tc,c as sc,i as nc,f as rc,B as ic,C as oc,P as Nr}from"./patchFileDiff-D9iBcTEi.js";import{u as ac,a as lc,i as cc,S as uc,b as dc}from"./SubmoduleDiffSummary-DeFmhPFZ.js";import{P as fc}from"./PierreDiffViewer-BlDmw3-A.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-Gea9uBlY.js";import"./vendor-opencode-client-_BAHQo4R.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.js";import"./contextPanelEmbeddedChat-CirXEPJq.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-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-U-lXzXNK.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./GuestAttachDialog-BIa9jCfL.js";import"./PluginPane-BibJit86.js";import"./vendor-yaml-3778uTud.js";import"./shikiHighlight-_HeCCHx1.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./appThemeRegistry-DAdawJZn.js";import"./textMateThemeFromAppTheme-C95XdFGj.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.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-qrcode-DTJ12-WC.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./vendor-strip-json-comments-5dJlOkP1.js";import"./useInlineCommentController-CkfxMJPy.js";import"./CodeMirrorCommentWidgets-CWhdh0wf.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./VirtualizedFileDiff-BfEBad09.js";import"./web-components-C583Pmfm.js";import"./computeVirtualFileMetrics-RF-KjfUH.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-D2yJ9fO6.js";import"./vendor-diff-C3JhlQdm.js";import"./Virtualizer-D_a8gKmg.js";let Ni=null,Cr=!1;const mc=new Promise(n=>{Ni=n});function pc(){Cr||(Cr=!0,Ni?.())}const hc=6,gc=n=>n.parentID??null,Rr=n=>{const e=n.replace(/\/+$/,"");return e.slice(e.lastIndexOf("/")+1)||e},bc=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),xc=(n,e)=>{if(!n)return"";let s=null,i=-1;for(const r of e){const o=bc(r.path);(n===o||n.startsWith(`${o}/`))&&o.length>i&&(s=r,i=o.length)}return s?s.label?.trim()||Rr(s.path):Rr(n)},yc=()=>{const n=Nn.getState().activeSessions,e=jo.getState().index.session.unseenCount,s=it.getState().notifyOnSubtasks,i=We.getState().projects,r=ai.getState().ids,o=li.getState().rankById;let a=0;const c=[];for(const d of n){const l=gc(d)!==null,b=(e[d.id]??0)>0&&(!l||s);b&&(a+=1),l||c.push({session:d,unread:b,project:xc(Cn(d),i)})}c.sort((d,l)=>ko(d.session,l.session,r,o));const f=c.slice(0,hc).map(({session:d,unread:l,project:p})=>({id:d.id,title:d.title??"",unread:l,project:p}));return{runtimeKey:Gt(),attentionCount:a,recentSessions:f}},vc="__OPENCHAMBER_WIDGET_SNAPSHOT__",wc=()=>{typeof window>"u"||(window[vc]=()=>{try{return JSON.stringify(yc())}catch{return null}})},cn="mobile-app-update-available",Er="mobile-app-update-toast-dismissed-version",jc=()=>{const n=le.c(8),{t:e}=me(),s=Mt(kc),i=Mt(Sc),r=Mt(Nc),o=Mt(Cc);let a;n[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Set,n[0]=a):a=n[0];const c=bn.useRef(a);let f,d;return n[1]!==s||n[2]!==o||n[3]!==i||n[4]!==e||n[5]!==r?(f=()=>{if(ri()!=="android"||i!=="mobile"||!s||!r||!o){fe.dismiss(cn);return}mr().getItem(Er)!==r&&(c.current.has(r)||(c.current.add(r),fe.info(e("mobileUpdate.toast.available.title"),{id:cn,description:e("mobileUpdate.toast.available.description",{version:r}),duration:1/0,icon:t.jsx(X,{name:"download",className:"h-4 w-4 text-muted-foreground"}),action:{label:e("mobileUpdate.toast.actions.download"),onClick:()=>{So(o)}},cancel:{label:e("mobileUpdate.toast.actions.dismiss"),onClick:()=>{mr().setItem(Er,r),fe.dismiss(cn)}}})))},d=[s,o,i,e,r],n[1]=s,n[2]=o,n[3]=i,n[4]=e,n[5]=r,n[6]=f,n[7]=d):(f=n[6],d=n[7]),bn.useEffect(f,d),null};function kc(n){return n.available}function Sc(n){return n.runtimeType}function Nc(n){return n.info?.version}function Cc(n){return n.info?.downloadUrl}const Pr=300,Rc="openchamber.mobile.connectLog.v1",zt=[];if(typeof window<"u")try{window.localStorage.removeItem(Rc)}catch{}const Jn=(n,e)=>{zt.push({at:Date.now(),step:n,detail:e}),zt.length>Pr&&zt.splice(0,zt.length-Pr)};typeof window<"u"&&Jn("app:launch","{}");const Ec=()=>[...zt],Pc=n=>{const e=new Date(n),s=(i,r=2)=>String(i).padStart(r,"0");return`${s(e.getHours())}:${s(e.getMinutes())}:${s(e.getSeconds())}.${s(e.getMilliseconds(),3)}`},Ci=n=>`${Pc(n.at)} ${n.step}${n.detail&&n.detail!=="{}"?` ${n.detail}`:""}`,Ac=()=>zt.map(Ci).join(`
3
3
  `),Ri=(n,e)=>{const s=le.c(10),i=700,r=u.useRef(null),o=u.useRef(null),a=u.useRef(!1);let c;s[0]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{r.current!==null&&window.clearTimeout(r.current),r.current=null,o.current=null},s[0]=c):c=s[0];const f=c;let d,l;s[1]===Symbol.for("react.memo_cache_sentinel")?(d=()=>f,l=[f],s[1]=d,s[2]=l):(d=s[1],l=s[2]),u.useEffect(d,l);let p;s[3]!==i||s[4]!==n?(p=w=>{a.current=!1,o.current={x:w.clientX,y:w.clientY},r.current!==null&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{r.current=null,a.current=!0,n()},i)},s[3]=i,s[4]=n,s[5]=p):p=s[5];const b=p;let h;s[6]===Symbol.for("react.memo_cache_sentinel")?(h=w=>{const N=o.current;N&&(Math.abs(w.clientX-N.x)>10||Math.abs(w.clientY-N.y)>10)&&f()},s[6]=h):h=s[6];const x=h;let S;s[7]===Symbol.for("react.memo_cache_sentinel")?(S=w=>{a.current&&(a.current=!1,w.preventDefault(),w.stopPropagation())},s[7]=S):S=s[7];const y=S;let E;return s[8]!==b?(E={onPointerDown:b,onPointerMove:x,onPointerUp:f,onPointerCancel:f,onClickCapture:y},s[8]=b,s[9]=E):E=s[9],E},Ls="openchamber.mobile.connections.v1",Ic="openchamber.mobile.",Ar="openchamber.mobile.deviceId",Tc=()=>{try{const n=window.localStorage.getItem(Ar);if(n&&n.trim())return n.trim();const e=crypto.randomUUID();return window.localStorage.setItem(Ar,e),e}catch{return crypto.randomUUID()}},Ir=()=>`mobile:${Tc()}`,Tr=()=>{try{const n=Bl.getPlatform();return n==="ios"||n==="android"?n:void 0}catch{return}},Ei=12,Pi=8e3,Dc=2500,_c=3e3,$s=2500,Mc=()=>{let n=0;return{begin:()=>(n+=1,n),cancel:()=>{n+=1},isCurrent:e=>e===n}},Kt=n=>{const e=n.trim();if(!e)return"";const s=/^https?:\/\//i.test(e)?e:`http://${e}`,i=new URL(s);return i.hash="",i.search="",i.pathname=i.pathname.replace(/\/+$/,""),i.toString().replace(/\/+$/,"")},_s=n=>{try{return new URL(n).host}catch{return n}},Wt=n=>{try{return Kt(n)}catch{return n.trim().replace(/\/+$/g,"")}},Ai=(n,e)=>Wt(n)===Wt(e),Ii=n=>`relay:${n.serverId}@${n.relayUrl.trim()}`,zc=n=>`relay://${n.serverId}`,Hs=n=>n.candidates.filter(e=>e.kind==="direct"),wt=n=>{const e=n.candidates.find(s=>s.kind==="relay");return e&&e.kind==="relay"?e.relay:null},ct=n=>{const e=Hs(n)[0];if(e)return e.url;const s=wt(n);return s?zc(s):""},Pe=n=>{const e=wt(n);if(e)return Ii(e);const s=Hs(n)[0];return s?Wt(s.url):""},Fs=(n,e)=>{const s=n.find(o=>o.kind==="relay"),i=s&&s.kind==="relay"?s.relay.serverId:null,r=new Set(n.filter(o=>o.kind==="direct").map(o=>Wt(o.url)));return e.some(o=>o.kind==="relay"?i!==null&&o.relay.serverId===i:r.has(Wt(o.url)))},Yn=n=>{const e=(()=>{try{return Kt(n)}catch{return""}})();return e?[{kind:"direct",url:e}]:[]},Dr=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(...Yn(n.url)),n.relay&&e.push({kind:"relay",relay:n.relay}),e},Qn=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 i=s;return i.kty!=="EC"||i.crv!=="P-256"||typeof i.x!="string"||!i.x||typeof i.y!="string"||!i.y?null:{relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:{kty:"EC",crv:"P-256",x:i.x,y:i.y}}},Ti=n=>{try{return JSON.stringify(n)}catch{return String(n)}},xe=(n,e={})=>{const s=Ti(e);console.info("[mobile-connect]",n,s),Jn(n,s)},ns=(n,e={})=>{xe(n,e)},Vt=(n,e={})=>{const s=Ti(e);console.info("[mobile-storage]",n,s),Jn(n,s)},Oc=n=>{if(typeof n!="string")return n;try{return JSON.parse(n)}catch{return n}},Bc=n=>{if(typeof n!="string")return n??void 0;try{return JSON.parse(n)}catch{return n}},Lc=async(n,e)=>{if(!Te())return null;try{const{CapacitorHttp:s}=await $t(async()=>{const{CapacitorHttp:o}=await import("./vendor-capacitor-core-B4EWRrHz.js");return{CapacitorHttp:o}},[]),i=ho(n,new Headers(e?.headers)),r=await s.request({url:n,method:e?.method||"GET",headers:Object.fromEntries(i.entries()),data:Bc(e?.body)});return{ok:r.status>=200&&r.status<300,status:r.status,source:"native-http",json:async()=>Oc(r.data)}}catch(s){return xe("native-http:failed",{url:n,error:s instanceof Error?s.message:String(s)}),null}},$c=async(n,e)=>{const s=await fetch(n,e).catch(i=>(xe("browser-fetch:failed",{url:n,error:i instanceof Error?i.message:String(i)}),null));return s?{ok:s.ok,status:s.status,source:"browser-fetch",json:()=>s.json()}:null},gt=async(n,e,s)=>{let i;const r=new Promise(o=>{i=window.setTimeout(()=>{s?.(),o(null)},n)});try{return await Promise.race([e,r])}catch{return null}finally{i!==void 0&&window.clearTimeout(i)}},jt=async(n,e,s)=>{const i=s?.totalTimeoutMs??Pi,r=Date.now(),o=await gt(Math.min(Dc,i),Lc(n,e));if(o)return o;const a=new AbortController,c=Math.max(500,i-(Date.now()-r));return gt(c,$c(n,{...e,signal:a.signal}),()=>a.abort())},qs=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}},Ut=15e3,Fc=async(n,e,s,i=Ut,r)=>{const o=ii({relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk}),a=c=>c==="ok"&&r?.keepTunnel?{outcome:c,tunnel:o}:(o.close(),{outcome:c});try{const c=e?{Authorization:`Bearer ${e}`}:void 0,f=await gt(i,o.fetch("/auth/session",{headers:c}).catch(()=>null));if(xe("relay:session",{ok:f?.ok===!0,status:f?.status??null,hasToken:!!e}),!f)return a("unreachable");if(f.status===401)return a(e?"auth-failed":"needs-login");if(!f.ok&&f.status!==404)return a("auth-failed");const d=await qs(f);return d&&d.disabled!==!0&&d.authenticated===!1?a(e?"auth-failed":"needs-login"):a("ok")}catch(c){throw o.close(),c}},Wc=(n,e,s,i,r)=>{const o=typeof window<"u"?window.location.origin:"",a={relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk,...s?{grant:s}:{}};r&&po(a,r),Dt({apiBaseUrl:o,clientToken:e,runtimeKey:i??Ii(n),relay:a})},Vc=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=Qn(e.relay);return s?{kind:"relay",relay:s}:null}return null},Uc=n=>{if(n.mode==="relay"){const e=Qn(n.relay);return e?[{kind:"relay",relay:e}]:[]}return typeof n.url=="string"?Yn(n.url):[]},St=()=>{if(typeof window>"u")return[];let n;try{n=JSON.parse(window.localStorage.getItem(Ls)||"[]")}catch{return[]}if(!Array.isArray(n))return[];const e=Te();return n.flatMap(s=>{if(!s||typeof s!="object")return[];const i=s;if(typeof i.id!="string")return[];const r=Array.isArray(i.candidates)?i.candidates.map(Vc).filter(f=>!!f):Uc(i);if(r.length===0)return[];const o=typeof i.clientToken=="string"&&i.clientToken.trim()?i.clientToken:void 0,a=typeof i.label=="string"&&i.label.trim()?i.label:_s(ct({candidates:r})),c={id:i.id,label:a,candidates:r,lastUsedAt:typeof i.lastUsedAt=="number"?i.lastUsedAt:0};return e?[{...c,hasToken:!!i.hasToken||!!o}]:[{...c,clientToken:o,hasToken:!!o}]}).sort((s,i)=>i.lastUsedAt-s.lastUsedAt)},vn=n=>n.kind==="relay"?{kind:"relay",relay:{relayUrl:n.relay.relayUrl,serverId:n.relay.serverId,hostEncPubJwk:n.relay.hostEncPubJwk}}:{kind:"direct",url:n.url},Xn=n=>{if(typeof window>"u")return;const e=Te(),s=n.slice(0,Ei).map(i=>{const r={id:i.id,label:i.label,candidates:i.candidates.map(vn),lastUsedAt:i.lastUsedAt};return e?{...r,hasToken:!!(i.hasToken||i.clientToken)}:{...r,clientToken:i.clientToken}});try{window.localStorage.setItem(Ls,JSON.stringify(s))}catch(i){console.warn("[mobile-storage] failed to persist connection metadata",i)}},Di=(n,e)=>{const s=n.find(o=>e.id&&o.id===e.id||Fs(o.candidates,e.candidates)),i=Te(),r={id:e.id||s?.id||crypto.randomUUID(),label:e.label,candidates:e.candidates,lastUsedAt:Date.now(),...i?{hasToken:e.hasToken??(!!e.clientToken||s?.hasToken||!1)}:{clientToken:e.clientToken??s?.clientToken,hasToken:!!(e.clientToken??s?.clientToken)}};return[r,...n.filter(o=>o.id!==r.id&&!Fs(o.candidates,e.candidates))].slice(0,Ei)},Zn=Ol,Gc=0,er=n=>`${Ic}token.${encodeURIComponent(n)}`,Kc=async(n,e)=>{let s;const i=new Promise(r=>{s=window.setTimeout(()=>r(e),_c)});try{return await Promise.race([n.catch(()=>e),i])}finally{s!==void 0&&window.clearTimeout(s)}},tr=async(n,e,s)=>Te()?Kc(e().catch(i=>(console.warn(`[mobile-storage] ${n} failed`,i),s)),s):s,ms=async n=>{Vt("secure:read-start",{key:n});const e=await tr("secure:read",async()=>(await Zn.internalGetItem({prefixedKey:er(n),sync:!1})).data,null),s=typeof e=="string"&&e.trim()?e:void 0;return Vt("secure:read",{key:n,hasToken:!!s}),s},yt=async(n,e)=>{Vt("secure:write-start",{key:n});const s=await tr("secure:write",async()=>(await Zn.internalSetItem({prefixedKey:er(n),data:e,sync:!1,access:Gc}),!0),!1);return Vt("secure:write",{key:n,ok:s}),s},Hc=async n=>{await tr("secure:delete",async()=>(await Zn.internalRemoveItem({prefixedKey:er(n),sync:!1}),!0),!1)},qc=async(n,e)=>{let s=0,i=0;return{records:await Promise.all(n.map(async o=>{if(!o||typeof o!="object")return o;const a=o,c=typeof a.url=="string"?a.url:null,f=typeof a.clientToken=="string"?a.clientToken.trim():"";if(!c||!f)return o;if(!await e(c,f))return i+=1,o;s+=1;const{clientToken:d,...l}=a;return{...l,hasToken:!0}})),migrated:s,failed:i}},_i=async()=>{if(typeof window>"u"||!Te())return;let n;try{n=JSON.parse(window.localStorage.getItem(Ls)||"[]")}catch{return}if(!Array.isArray(n))return;const e=n.filter(i=>!!i&&typeof i=="object"&&typeof i.url=="string"&&typeof i.clientToken=="string"&&!!i.clientToken.trim());if(e.length===0)return;Vt("secure:migrate-start",{count:e.length});const s=await qc(n,async(i,r)=>{const o=Wt(i);return await yt(o,r)?await ms(o)===r:!1});if(s.migrated>0)try{window.localStorage.setItem(Ls,JSON.stringify(s.records))}catch(i){console.warn("[mobile-storage] failed to finalize secure token migration",i);return}Vt("secure:migrate-done",{migrated:s.migrated,failed:s.failed})},Jc=async()=>(await _i(),St()),Ws=async n=>{const e=Di(St(),n);return Xn(e),Te()&&n.clientToken&&await yt(Pe({candidates:n.candidates}),n.clientToken),e},Yc=async n=>{const e=St(),s=e.find(r=>r.id===n)??null,i=e.filter(r=>r.id!==n);return Xn(i),s&&Te()&&await Hc(Pe(s)),i},Qc=1500,Vs=async(n,e,s)=>{const i=s?.fast?{totalTimeoutMs:$s}:void 0,r=wt({candidates:n})?.serverId??null,o=n.find(d=>d.kind==="relay")??null,a=n.filter(d=>d.kind==="direct"),c=async()=>{for(const d of a){const l=Kt(d.url)||d.url,p=e?{Authorization:`Bearer ${e}`}:void 0,b=await jt(`${l}/health`,{method:"GET"},i);if(xe("probe:direct:health",{url:l,ok:b?.ok===!0,status:b?.status??null,source:b?.source??null}),!b?.ok)continue;if(r){const y=await b.json().catch(()=>null),E=y&&typeof y=="object"?y.serverId:null;if(typeof E=="string"&&E&&E!==r){xe("probe:server-id-mismatch",{url:l});continue}}const h=await jt(`${l}/auth/session`,{method:"GET",credentials:e?"omit":"include",headers:p},i);if(xe("probe:direct:session",{url:l,ok:h?.ok===!0,status:h?.status??null,source:h?.source??null,hasToken:!!e}),h?.status===401)return{status:"needs-login"};if(!h||!h.ok&&h.status!==404)continue;const x=await qs(h);if(x&&x.disabled!==!0&&x.authenticated===!1)return{status:"needs-login"};const S=x?.disabled===!0;return!e&&Te()&&!S&&x?.scope!=="client"?{status:"needs-login"}:{status:"ok",transport:{kind:"direct",url:l}}}return{status:"unreachable"}},f=async()=>{if(!o)return{status:"unreachable"};const{outcome:d,tunnel:l}=await Fc(o.relay,e,void 0,s?.fast?$s:Pi,{keepTunnel:!0});return d==="ok"?{status:"ok",transport:{kind:"relay",relay:o.relay,tunnel:l}}:d==="needs-login"||d==="auth-failed"?{status:"needs-login"}:{status:"unreachable"}};return o?a.length===0?f():new Promise(d=>{let l=!1,p=!1,b,h=null,x=null;const S=w=>{w?.status==="ok"&&w.transport.kind==="relay"&&w.transport.tunnel?.close()},y=w=>{l||(l=!0,d(w))},E=()=>{p||l||(b!==void 0&&(window.clearTimeout(b),b=void 0),f().then(w=>{if(x=w,l||p){S(w);return}if(w.status==="ok"||w.status==="needs-login"){y(w);return}h&&y(h)}))};c().then(w=>{if(h=w,!l){if(w.status==="ok"||w.status==="needs-login"){p=!0,b!==void 0&&window.clearTimeout(b),S(x),y(w);return}if(x){y(x);return}E()}}),b=window.setTimeout(E,Qc)}):c()},vt=(n,e,s)=>{n.kind==="relay"?Wc(n.relay,e,s?.grant,s?.runtimeKey,n.tunnel):Dt({apiBaseUrl:n.url,clientToken:e,runtimeKey:s?.runtimeKey}),zi()},os=()=>{const n=St()[0];return n?.label?.trim()?n.label:null},rs=async n=>{const e=n?.fast!==!1;await _i();const s=St()[0];if(xe("auto-connect:start",{hasCandidate:!!s,fast:e}),!s)return{status:"no-candidate"};let i;if(Te()){if(s.hasToken&&(i=await ms(Pe(s)),!i))return{status:"no-candidate"}}else if(i=s.clientToken,!i&&s.hasToken)return{status:"no-candidate"};const r=await Vs(s.candidates,i,{fast:e});return xe("auto-connect:probe",{status:r.status,candidates:s.candidates.map(o=>o.kind)}),r.status==="needs-login"?{status:"needs-login",label:s.label}:r.status!=="ok"?{status:"unreachable",label:s.label}:n?.skipIfConnected&&st()?(r.transport.kind==="relay"&&r.transport.tunnel?.close(),xe("auto-connect:superseded",{}),{status:"no-candidate"}):(await Ws({id:s.id,label:s.label,candidates:s.candidates}),vt(r.transport,i??null,{runtimeKey:Pe(s)}),{status:"connected"})},Xc=async(n,e)=>{let s="";try{s=Kt(n.url)}catch{return!1}if(!s)return!1;const i=n.clientToken?.trim()||void 0,r=i?{Authorization:`Bearer ${i}`}:void 0,o=e?.fast?{totalTimeoutMs:$s}:void 0;if(!(await jt(`${s}/health`,{method:"GET",headers:r},o))?.ok)return!1;const c=await jt(`${s}/auth/session`,{method:"GET",credentials:i?"omit":"include",headers:r},o);if(!c||!c.ok&&c.status!==404)return!1;const f=await qs(c);return!(f&&f.disabled!==!0&&f.authenticated===!1)},Zc=n=>[...n].sort((e,s)=>{const i=(e.priority??100)-(s.priority??100);if(i!==0)return i;const r=o=>o.type==="relay"?2:o.url.startsWith("https://")?0:1;return r(e)-r(s)}).flatMap(e=>{if(e.type==="relay"){const s=Qn({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk});return s?[{kind:"relay",relay:s}]:[]}return Yn(e.url)}),_r=async n=>{const e=wt({candidates:n})?.serverId??null;for(const s of n){if(s.kind==="relay"){const o=ii(s.relay),a=await gt(Ut,o.fetch("/health").catch(()=>null));if(xe("establish:relay:health",{ok:a?.ok===!0,status:a?.status??null}),a?.ok)return{kind:"relay",relay:s.relay,tunnel:o};o.close();continue}const i=Kt(s.url)||s.url,r=await jt(`${i}/health`,{method:"GET"});if(xe("establish:direct:health",{ok:r?.ok===!0,status:r?.status??null}),!!r?.ok){if(e){const o=await r.json().catch(()=>null),a=o&&typeof o=="object"?o.serverId:null;if(typeof a=="string"&&a&&a!==e){xe("establish:server-id-mismatch",{url:i});continue}}return{kind:"direct",url:i}}}return null},eu=async(n,e)=>{if(!fs())return Xc(n,e);const s=await gt(e?.fast?$s:Ut,Sn("/auth/session").then(r=>r).catch(()=>null));if(!s)return!0;if(s.status===401)return!1;if(!s.ok&&s.status!==404)return!0;const i=await qs(s);return!(i&&i.disabled!==!0&&i.authenticated===!1)},tu=n=>n.kind==="relay"?fs():!fs()&&Ai(n.url,st()),Mi=()=>{const n=Gt();return n?St().find(e=>Pe(e)===n)??null:null},Mr=n=>{const e=Gt();return!!e&&Pe(n)===e},Ms=async n=>{const e=n?.fast!==!1,s=Mi();if(!s)return xe("reprobe:no-connection",{runtimeKey:!!Gt()}),"no-connection";let i;if(Te()?i=s.hasToken?await ms(Pe(s)):void 0:i=s.clientToken,!i&&s.hasToken)return xe("reprobe:no-token",{hasToken:!0}),"unreachable";xe("reprobe:start",{candidates:s.candidates.map(d=>d.kind),fast:e,hasToken:!!i});const r=s.candidates.findIndex(d=>tu(d.kind==="relay"?{kind:"relay",relay:d.relay}:{kind:"direct",url:d.url})),o=r>=0?s.candidates.slice(0,r):s.candidates,a=await Vs(o,i,{fast:e});if(xe("reprobe:better",{status:a.status,probed:o.length}),a.status==="ok")return await Ws({id:s.id,label:s.label,candidates:s.candidates}),vt(a.transport,i??null,{runtimeKey:Pe(s)}),"switched";if(a.status==="needs-login")return"needs-login";if(r>=0){const d=await eu({url:st(),clientToken:i},{fast:e});if(xe("reprobe:current",{stillValid:d}),d)return zi(),"unchanged"}const c=r>=0?s.candidates.slice(r+1):[],f=await Vs(c,i,{fast:e});return xe("reprobe:fallback",{status:f.status,probed:c.length}),f.status==="ok"?(await Ws({id:s.id,label:s.label,candidates:s.candidates}),vt(f.transport,i??null,{runtimeKey:Pe(s)}),"switched"):f.status==="needs-login"?"needs-login":"unreachable"},su=5e3;let un=!1;const nu=async()=>{if(un)return"skipped";const n=Mi();if(!n)return xe("candidates:refresh-skip",{reason:"no-active-connection"}),"skipped";const e=wt(n);if(!e)return xe("candidates:refresh-skip",{reason:"no-relay-candidate"}),"skipped";un=!0;try{const s=await gt(Ut,Sn("/api/client-auth/connection/candidates").then(d=>d).catch(()=>null));if(!s?.ok)return xe("candidates:refresh-skip",{reason:"fetch-failed",status:s?.status??null}),"skipped";const i=await s.json().catch(()=>null);if(!i||i.serverId!==e.serverId)return xe("candidates:refresh-skip",{reason:"server-id-mismatch"}),"skipped";const r=Array.isArray(i.candidates)?i.candidates:[],o=[];for(const d of r){if(!d||typeof d!="object")continue;const l=d;if(!(l.type!=="lan"||typeof l.url!="string"))try{const p=Kt(l.url);p&&!o.includes(p)&&o.push(p)}catch{}}if(o.length===0)return xe("candidates:refresh-skip",{reason:"no-lan-reported"}),"skipped";const a=Hs(n).filter(d=>d.url.startsWith("https://")),c=[...o.map(d=>({kind:"direct",url:d})),...a,{kind:"relay",relay:e}];return JSON.stringify(n.candidates.map(vn))===JSON.stringify(c.map(vn))?"unchanged":(xe("candidates:refreshed",{lanCount:o.length}),await Ws({id:n.id,label:n.label,candidates:c}),"updated")}finally{un=!1}},zi=()=>{typeof window>"u"||window.setTimeout(()=>{(async()=>{const n=await nu().catch(()=>"skipped");xe("candidates:refresh-result",{result:n}),n==="updated"&&fs()&&await Ms().catch(()=>null)})()},su)},Oi=n=>{const{t:e}=me(),[s,i]=u.useState(()=>St()),[r,o]=u.useState(null),[a,c]=u.useState(null),[f,d]=u.useState(null),l=u.useRef(s),p=u.useRef(null),b=u.useRef(Mc()),h=u.useCallback(C=>{l.current=C,i(C)},[]),x=u.useCallback(C=>{p.current=C,o(C)},[]),S=u.useCallback(C=>{p.current===C&&(p.current=null,o(null))},[]);u.useEffect(()=>{let C=!1;return Jc().then(R=>{C||h(R)}),()=>{C=!0}},[h]);const y=u.useCallback(C=>{const R=Di(l.current,C);return h(R),Xn(R),R},[h]),E=u.useCallback(async C=>{c(null),x("connect");try{const R=Dr(C);if(R.length===0){c(e("mobile.connect.error.urlRequired"));return}const k=C.id?l.current.find($=>$.id===C.id):l.current.find($=>Fs($.candidates,R)),z=C.label?.trim()||k?.label||_s(ct({candidates:R})),D=C.relayGrant;let _=C.clientToken?.trim()||void 0;const j=!!_;_||(Te()?k?.hasToken&&(_=await ms(Pe({candidates:R}))):_=k?.clientToken),xe("connect:start",{candidates:R.map($=>$.kind),hasToken:!!_});const I=await Vs(R,_);if(xe("connect:probe",{status:I.status}),I.status==="unreachable"){c(e("mobile.connect.error.unreachable"));return}if(I.status==="needs-login"){y({id:k?.id,label:z,candidates:R}),d({id:k?.id??crypto.randomUUID(),label:z,candidates:R,relay:wt({candidates:R})??void 0,relayGrant:D});return}_&&j&&Te()&&await yt(Pe({candidates:R}),_),y({id:k?.id,label:z,candidates:R,clientToken:_}),vt(I.transport,_??null,{runtimeKey:Pe({candidates:R}),grant:D}),n()}catch(R){console.warn("[mobile-connect] connect threw",R),c(e("mobile.connect.error.invalidUrl"))}finally{S("connect")}},[x,S,n,y,e]),w=u.useCallback(async C=>{if(p.current==="pairing")return;c(null),x("pairing");const R=Zc(C.candidates);let k=null,z=!1;try{if(k=await _r(R),!k){c(e("mobile.connect.error.unreachable"));return}const D=JSON.stringify({pairingId:C.pairingId,secret:C.secret,clientLabel:"OpenChamber Mobile",clientKind:"mobile",deviceName:"OpenChamber Mobile",devicePlatform:Tr(),dedupeKey:Ir()}),_={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:D},j=k.kind==="relay"?await gt(Ut,k.tunnel.fetch("/api/client-auth/pairing/redeem",_).catch(()=>null)):await jt(`${k.url}/api/client-auth/pairing/redeem`,_);if(!j?.ok){c(e("mobile.connect.error.authRequired"));return}const I=await j.json().catch(()=>null),$=typeof I?.clientToken=="string"?I.clientToken.trim():"";if(!$){c(e("mobile.connect.error.authRequired"));return}const g=typeof I?.server?.label=="string"?I.server.label:"",O=C.label||g||_s(ct({candidates:R}));if(Te()&&!await yt(Pe({candidates:R}),$)){c(e("mobile.connect.error.authRequired"));return}y({label:O,candidates:R,clientToken:$}),vt(k.kind==="relay"?{kind:"relay",relay:k.relay,tunnel:k.tunnel}:{kind:"direct",url:k.url},$,{runtimeKey:Pe({candidates:R})}),z=k.kind==="relay",n()}catch(D){console.warn("[mobile-connect] pairing threw",D),c(e("mobile.connect.error.authRequired"))}finally{!z&&k?.kind==="relay"&&k.tunnel.close(),S("pairing")}},[x,S,n,y,e]),N=u.useCallback(async C=>{if(!f||!C.trim()||p.current==="password")return;c(null),x("password");const R=b.current.begin(),k=()=>b.current.isCurrent(R),{id:z,label:D,candidates:_}=f;let j=null,I=!1;try{if(j=await _r(_),!k())return;if(!j){c(e("mobile.connect.error.unreachable"));return}const $={method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({password:C,trustDevice:!0,issueClientToken:!0,clientLabel:"OpenChamber Mobile",clientKind:"mobile",devicePlatform:Tr(),dedupeKey:Ir()})};xe("password:start",{transport:j.kind});const g=j.kind==="relay"?await gt(Ut,j.tunnel.fetch("/auth/session",$).catch(()=>null)):await jt(`${j.url}/auth/session`,$);if(!k())return;if(xe("password:done",{ok:g?.ok===!0,status:g?.status??null}),!g?.ok){c(e("mobile.connect.error.passwordFailed"));return}const O=await g.json().catch(()=>null);if(!k())return;const V=typeof O?.clientToken=="string"?O.clientToken.trim():"";if(xe("password:token",{issued:!!V}),!V){if(j.kind==="direct"&&!Te()){y({id:z,label:D,candidates:_}),d(null),vt({kind:"direct",url:j.url},null,{runtimeKey:Pe({candidates:_})}),n();return}c(e("mobile.connect.error.authRequired"));return}if(Te()&&(!k()||(await yt(Pe({candidates:_}),V),!k()))||!k()||(y({id:z,label:D,candidates:_,clientToken:V}),d(null),vt(j.kind==="relay"?{kind:"relay",relay:j.relay,tunnel:j.tunnel}:{kind:"direct",url:j.url},V,{runtimeKey:Pe({candidates:_})}),I=j.kind==="relay",!k()))return;n()}catch($){if(!k())return;console.warn("[mobile-connect] password threw",$),c(e("mobile.connect.error.passwordFailed"))}finally{!I&&j?.kind==="relay"&&j.tunnel.close(),k()&&S("password")}},[x,S,n,f,y,e]),A=u.useCallback(()=>{b.current.cancel(),S("password"),d(null),c(null)},[S]),v=u.useCallback(async C=>{c(null);let R=Dr(C);const k=C.id?l.current.find(j=>j.id===C.id)??null:null;if(k){const j=R.filter(g=>g.kind==="direct"),I=Hs(k).filter(g=>g.url.startsWith("https://")&&!j.some(O=>Ai(O.url,g.url))),$=wt(k);R=[...j,...I,...$?[{kind:"relay",relay:$}]:[]]}if(R.length===0)return c(e("mobile.connect.error.urlRequired")),null;const z=C.clientToken?.trim()||void 0,D=C.label?.trim()||_s(ct({candidates:R}));if(Te()){const j=Pe({candidates:R});if(z)await yt(j,z);else if(k?.hasToken){const I=Pe(k);if(I&&j&&I!==j){const $=await ms(I);$&&await yt(j,$)}}}return y({id:C.id,label:D,candidates:R,clientToken:z}).find(j=>Fs(j.candidates,R))??null},[y,e]),P=u.useCallback(async C=>{const R=l.current.find(z=>z.id===C)??null,k=await Yc(C);return h(k),R},[h]);return{connections:s,isBusy:r!==null,isPasswordBusy:r==="password",error:a,pendingConnection:f,connect:E,redeemPairingConnection:w,submitPassword:N,cancelPassword:A,saveConnection:v,removeConnection:P,setError:c}},Bi=n=>{const e=le.c(31),{onClose:s}=n,{t:i}=me(),[r,o]=u.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=Ec(),e[0]=a):a=e[0];const c=a;let f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{No(Ac()).then(C=>{C.ok&&(o(!0),window.setTimeout(()=>o(!1),2e3))})},e[1]=f):f=e[1];const d=f;let l;e[2]!==i?(l=i("mobile.connectionDebug.title"),e[2]=i,e[3]=l):l=e[3];let p;e[4]!==l?(p=t.jsx("h2",{className:"min-w-0 truncate typography-ui-label text-foreground",children:l}),e[4]=l,e[5]=p):p=e[5];const b=r?"check":"file-copy";let h;e[6]!==b?(h=t.jsx(X,{name:b,className:"size-4"}),e[6]=b,e[7]=h):h=e[7];let x;e[8]!==r||e[9]!==i?(x=i(r?"mobile.connectionDebug.copied":"mobile.connectionDebug.copy"),e[8]=r,e[9]=i,e[10]=x):x=e[10];let S;e[11]!==h||e[12]!==x?(S=t.jsxs(ge,{type:"button",variant:"outline",size:"sm",onClick:d,disabled:c.length===0,children:[h,x]}),e[11]=h,e[12]=x,e[13]=S):S=e[13];let y;e[14]!==i?(y=i("mobile.connectionDebug.close"),e[14]=i,e[15]=y):y=e[15];let E;e[16]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx(X,{name:"close",className:"size-[18px]"}),e[16]=E):E=e[16];let w;e[17]!==s||e[18]!==y?(w=t.jsx(ge,{type:"button",variant:"ghost",size:"icon","aria-label":y,onClick:s,children:E}),e[17]=s,e[18]=y,e[19]=w):w=e[19];let N;e[20]!==w||e[21]!==S?(N=t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[S,w]}),e[20]=w,e[21]=S,e[22]=N):N=e[22];let A;e[23]!==N||e[24]!==p?(A=t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border/70 px-4 py-2.5",children:[p,N]}),e[23]=N,e[24]=p,e[25]=A):A=e[25];let v;e[26]!==i?(v=t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 py-3",children:c.length===0?t.jsx("p",{className:"typography-small text-muted-foreground",children:i("mobile.connectionDebug.empty")}):t.jsx("pre",{className:"whitespace-pre-wrap break-words typography-code text-muted-foreground",children:c.map(Ci).join(`
4
4
  `)})}),e[26]=i,e[27]=v):v=e[27];let P;return e[28]!==A||e[29]!==v?(P=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:[A,v]}),e[28]=A,e[29]=v,e[30]=P):P=e[30],P},Li=()=>{if(typeof window>"u")return null;const e=window.Capacitor?.Plugins?.BarcodeScanner;return e&&(typeof e.scan=="function"||typeof e.startScan=="function")?e:null},ru=()=>window.Capacitor?.getPlatform?.()==="android",$i=n=>{const e=n.trim();if(!e)return null;if(/^openchamber:\/\//i.test(e)){const s=go(e);return s?{pairing:s}:null}return/^https?:\/\//i.test(e)?{url:e}:null},Fi=(n,e)=>{const s=$i(n);if(!s&&e?.pairingStringFallback){const i=bo(n);if(i)return{status:"pairing",pairing:i}}return s?"pairing"in s?{status:"pairing",...s}:{status:"ok",...s}:{status:"invalid"}},iu=async(n,e)=>{if(!n.startScan||!n.stopScan||!n.addListener)return{status:"unsupported"};if(e?.aborted)return{status:"cancelled"};let s,i,r=!1,o=()=>{};const a=new Promise(d=>{o=d}),c=d=>{r||(r=!0,o(d))},f=()=>c({status:"cancelled"});e?.addEventListener("abort",f,{once:!0});try{return(await Promise.allSettled([Promise.resolve(n.addListener("barcodesScanned",({barcodes:l})=>{const p=l?.[0],b=(p?.rawValue??p?.displayValue??"").trim();b&&c(Fi(b,{pairingStringFallback:!0}))})).then(l=>{s=l}),Promise.resolve(n.addListener("scanError",()=>c({status:"failed"}))).then(l=>{i=l})])).some(({status:l})=>l==="rejected")?c({status:"failed"}):r||n.startScan({formats:["QR_CODE"]}).catch(()=>c({status:"failed"})),await a}finally{e?.removeEventListener("abort",f),await Promise.allSettled([Promise.resolve(s?.remove()),Promise.resolve(i?.remove()),n.stopScan()])}},wn=()=>Li()!==null,Wi=async n=>{const e=Li();if(!e)return{status:"unsupported"};try{if(e.requestPermissions){const a=(await e.requestPermissions())?.camera;if(a&&a!=="granted"&&a!=="limited")return{status:"permission-denied"}}if(n?.signal?.aborted)return{status:"cancelled"};if(ru())return iu(e,n?.signal);if(!e.scan)return{status:"unsupported"};const i=(await e.scan({formats:["QR_CODE"]}))?.barcodes?.[0],r=(i?.rawValue??i?.displayValue??"").trim();return r?Fi(r):{status:"cancelled"}}catch{return{status:"failed"}}},Bt={autoComplete:"off",autoCorrect:"off",spellCheck:!1},as="oc-surface-elevated h-12 w-full rounded-[16px] border border-border/70 bg-surface-elevated px-4 text-[16px] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-interactive-border-focus focus:ring-2 focus:ring-ring",Vi=n=>{const e=le.c(22),{onCancel:s}=n,{t:i}=me(),r=u.useRef(null);let o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{const E={value:document.documentElement.style.getPropertyValue("background-color"),priority:document.documentElement.style.getPropertyPriority("background-color")},w={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 N=new Map,A=P=>{!(P instanceof HTMLElement)||P===r.current||N.has(P)||(N.set(P,{opacity:P.style.opacity,pointerEvents:P.style.pointerEvents}),P.style.setProperty("opacity","0"),P.style.setProperty("pointer-events","none"))};Array.from(document.body.children).forEach(A);const v=new MutationObserver(P=>{P.forEach(C=>C.addedNodes.forEach(A))});return v.observe(document.body,{childList:!0}),()=>{v.disconnect(),N.forEach(ou),E.value?document.documentElement.style.setProperty("background-color",E.value,E.priority):document.documentElement.style.removeProperty("background-color"),w.value?document.body.style.setProperty("background-color",w.value,w.priority):document.body.style.removeProperty("background-color")}},a=[],e[0]=o,e[1]=a):(o=e[0],a=e[1]),u.useLayoutEffect(o,a);let c,f;e[2]!==s?(c=()=>{const E=()=>{document.visibilityState==="hidden"&&s()};return document.addEventListener("visibilitychange",E),()=>document.removeEventListener("visibilitychange",E)},f=[s],e[2]=s,e[3]=c,e[4]=f):(c=e[3],f=e[4]),u.useEffect(c,f);let d;e[5]!==i?(d=i("mobile.connect.scanQr"),e[5]=i,e[6]=d):d=e[6];let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=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]=l):l=e[7];let p;e[8]!==i?(p=i("mobile.connect.welcome.scanHint"),e[8]=i,e[9]=p):p=e[9];let b;e[10]!==p?(b=t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-6",children:[l,t.jsx("p",{className:"max-w-sm rounded-[16px] border border-border/60 bg-background px-4 py-3 text-center typography-body text-foreground shadow-sm",children:p})]}),e[10]=p,e[11]=b):b=e[11];let h;e[12]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(X,{name:"close",className:"size-[18px]"}),e[12]=h):h=e[12];let x;e[13]!==i?(x=i("mobile.instances.cancelEdit"),e[13]=i,e[14]=x):x=e[14];let S;e[15]!==s||e[16]!==x?(S=t.jsxs(ge,{type:"button",variant:"outline",size:"lg",className:"mx-auto min-h-12 w-full max-w-sm bg-background",onClick:s,children:[h,x]}),e[15]=s,e[16]=x,e[17]=S):S=e[17];let y;return e[18]!==S||e[19]!==d||e[20]!==b?(y=Lt.createPortal(t.jsxs("div",{ref:r,role:"dialog","aria-modal":"true","aria-label":d,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,S]}),document.body),e[18]=S,e[19]=d,e[20]=b,e[21]=y):y=e[21],y},Ui=()=>{const n=le.c(6),{t:e}=me();let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx(_t,{width:96,height:96,isAnimated:!0}),n[0]=s):s=n[0];let i;n[1]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(X,{name:"loader-4",className:"size-[18px] animate-spin"}),n[1]=i):i=n[1];let r;n[2]!==e?(r=e("mobile.connect.connecting"),n[2]=e,n[3]=r):r=n[3];let o;return n[4]!==r?(o=Lt.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:[i,t.jsx("span",{children:r})]})]}),document.body),n[4]=r,n[5]=o):o=n[5],o};function ou(n,e){e.style.opacity=n.opacity,e.style.pointerEvents=n.pointerEvents}const au=({onConnected:n,notice:e=null})=>{const{t:s}=me(),i=Oi(n),{connections:r,isBusy:o,isPasswordBusy:a,error:c,pendingConnection:f}=i,[d,l]=u.useState(""),[p,b]=u.useState(""),[h,x]=u.useState(""),[S,y]=u.useState(!1),[E,w]=u.useState(!1),N=u.useRef(null),A=u.useMemo(()=>wn(),[]),[v,P]=u.useState(()=>!wn()),[C,R]=u.useState(null),[k,z]=u.useState(""),[D,_]=u.useState(!1),j=Ri(u.useCallback(()=>_(!0),[])),I=u.useCallback(B=>{B.preventDefault(),i.connect({url:d,clientToken:h,label:p})},[h,i,p,d]),$=u.useCallback(B=>{if(/^openchamber:\/\//i.test(B.trim())){const L=$i(B);if(L){if("pairing"in L){i.redeemPairingConnection(L.pairing);return}l(L.url),L.label&&b(L.label),L.clientToken&&x(L.clientToken);return}}l(B)},[i]),g=u.useCallback(async()=>{if(N.current||o)return;i.setError(null),y(!0);const B=new AbortController;N.current=B;try{const L=await Wi({signal:B.signal});switch(N.current===B&&(N.current=null,y(!1)),L.status){case"ok":w(!0),l(L.url),L.label&&b(L.label),L.clientToken&&x(L.clientToken),await i.connect({url:L.url,clientToken:L.clientToken,label:L.label});break;case"pairing":w(!0),await i.redeemPairingConnection(L.pairing);break;case"permission-denied":i.setError(s("mobile.connect.scan.permissionDenied"));break;case"invalid":i.setError(s("mobile.connect.scan.invalid"));break;case"unsupported":i.setError(s("mobile.connect.scan.unsupported"));break;case"failed":i.setError(s("mobile.connect.scan.failed"));break;default:break}}finally{w(!1),N.current===B&&(N.current=null,y(!1))}},[i,o,s]);u.useEffect(()=>()=>N.current?.abort(),[]);const O=u.useCallback(B=>{B.preventDefault(),i.submitPassword(k)},[i,k]),V=u.useCallback(()=>{z(""),i.cancelPassword()},[i]);return t.jsxs(t.Fragment,{children:[S?t.jsx(Vi,{onCancel:()=>N.current?.abort()}):null,E?t.jsx(Ui,{}):null,D?t.jsx(Bi,{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",{...j,className:"select-none",style:{touchAction:"manipulation"},children:t.jsx(_t,{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(X,{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}):s("mobile.connect.notice.unreachable",{label:e.label})})]}):null,f?t.jsxs("form",{className:"flex w-full flex-col gap-3",onSubmit:O,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(X,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0 text-left",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(B=>B.kind==="direct")?ct(f):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...Bt,value:k,onChange:B=>z(B.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:as}),c?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:c}):null,t.jsx(ge,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:a||!k.trim(),children:s(a?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:V,children:s("mobile.connect.cancelPassword")})]}):t.jsxs("div",{className:"flex w-full flex-col gap-6",children:[A?t.jsxs("div",{className:"flex w-full flex-col gap-2",children:[t.jsxs(ge,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{g()},disabled:S||o,children:[t.jsx(X,{name:"scan-2",className:J("size-[18px]",S&&"animate-pulse")}),s(o?"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,c&&!v?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:c}):null,r.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:r.map(B=>{const L=C===B.id;return t.jsxs("button",{type:"button",disabled:o,className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3.5 py-2.5 text-left last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:opacity-70",onClick:()=>{R(B.id),i.connect({id:B.id,candidates:B.candidates,clientToken:B.clientToken,label:B.label}).finally(()=>R(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(X,{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:B.label}),t.jsx("span",{className:J("block truncate typography-small",L?"text-foreground":"text-muted-foreground"),children:L?s("mobile.connect.connecting"):B.candidates.some(ie=>ie.kind==="direct")?ct(B):s("mobile.connect.relay.badge")})]}),L?t.jsx(X,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):t.jsx(X,{name:"arrow-right-s",className:"size-5 text-muted-foreground"})]},B.id)})})]}):null,t.jsxs("div",{className:"flex w-full flex-col",children:[A?t.jsxs("button",{type:"button",onClick:()=>P(B=>!B),"aria-expanded":v,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(X,{name:"arrow-down-s",className:J("size-4 transition-transform duration-200",v&&"rotate-180")})]}):null,t.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:v?"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:I,children:[t.jsx("input",{...Bt,value:d,onChange:B=>$(B.target.value),placeholder:s("mobile.connect.url.placeholder"),"aria-label":s("mobile.connect.url.label"),type:"url",inputMode:"url",autoCapitalize:"none",tabIndex:v?void 0:-1,className:J(as,"text-center")}),t.jsx("input",{value:p,onChange:B=>b(B.target.value),placeholder:s("mobile.instances.label.placeholder"),"aria-label":s("mobile.instances.label.label"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,tabIndex:v?void 0:-1,className:J(as,"text-center")}),t.jsx("input",{...Bt,value:h,onChange:B=>x(B.target.value),placeholder:s("mobile.connect.token.placeholder"),"aria-label":s("mobile.connect.token.label"),tabIndex:v?void 0:-1,autoCapitalize:"none",className:J(as,"text-center")}),t.jsx("p",{className:"px-1 text-center typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")}),c?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:c}):null,t.jsx(ge,{type:"submit",variant:A?"outline":"default",size:"lg",className:"h-12 w-full",disabled:o||S||!d.trim(),children:s(o?"mobile.connect.connecting":"mobile.connect.connectButton")})]})})})]})]})]})})]})},lu=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"},cu=n=>{const e=le.c(12),{groups:s,displayMode:i,timeFormatPreference:r,className:o}=n;let a;e[0]!==o?(a=J("space-y-1.5",o),e[0]=o,e[1]=a):a=e[1];let c;if(e[2]!==i||e[3]!==s||e[4]!==r){let d;e[6]!==i||e[7]!==r?(d=l=>t.jsxs("div",{className:"min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Co,{providerId:l.providerId,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground",children:l.providerName}),l.planLabel?t.jsx("span",{className:"shrink-0 typography-micro capitalize text-muted-foreground",children:l.planLabel}):null,l.status&&l.rows.length===0?t.jsx("span",{className:"shrink-0 truncate typography-micro text-muted-foreground",children:l.status}):null]}),l.rows.length>0?t.jsx("div",{className:"mt-1.5 space-y-1",children:l.rows.map(p=>{const b=i==="remaining"?p.window.remainingPercent:p.window.usedPercent,h=Ro(p.window.valueLabel,b),x=Eo(p.window.resetAt,p.window.resetAfterFormatted??p.window.resetAtFormatted,r);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:p.subtitle?`${p.subtitle} · ${p.label}`:p.label}),x?t.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/70",children:x}):null]}),t.jsx("span",{className:J("shrink-0 typography-ui-label font-semibold tabular-nums",lu(p.window)),children:h==="-"?"":h})]},p.key)})}):null,l.status&&l.rows.length>0?t.jsx("div",{className:"mt-1.5 typography-micro text-muted-foreground",children:l.status}):null]},l.providerId),e[6]=i,e[7]=r,e[8]=d):d=e[8],c=s.map(d),e[2]=i,e[3]=s,e[4]=r,e[5]=c}else c=e[5];let f;return e[9]!==a||e[10]!==c?(f=t.jsx("div",{className:a,children:c}),e[9]=a,e[10]=c,e[11]=f):f=e[11],f},zr=380,uu=(n,e)=>{if(!n||typeof n!="object")return;const s=n[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0},dn=n=>n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:String(n),du="—",Gi=n=>{const e=le.c(20),{percentage:s}=n;let i,r,o,a,c,f,d;if(e[0]!==s){o=_o(s??0)??0;const h=Mo(s??0);r=h==="critical"?"var(--status-error)":h==="warn"?"var(--status-warning)":"var(--status-success)",i=2*Math.PI*7.5,a="0 0 18 18",c="size-[18px] -rotate-90",f="progressbar",d=s===null?void 0:Math.round(o),e[0]=s,e[1]=i,e[2]=r,e[3]=o,e[4]=a,e[5]=c,e[6]=f,e[7]=d}else i=e[1],r=e[2],o=e[3],a=e[4],c=e[5],f=e[6],d=e[7];let l;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),e[8]=l):l=e[8];let p;e[9]!==i||e[10]!==s||e[11]!==r||e[12]!==o?(p=s===null?null:t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:r,strokeWidth:3,strokeLinecap:"round",strokeDasharray:i,strokeDashoffset:i*(1-o/100),className:"transition-[stroke-dashoffset,stroke] duration-300"}),e[9]=i,e[10]=s,e[11]=r,e[12]=o,e[13]=p):p=e[13];let b;return e[14]!==a||e[15]!==c||e[16]!==f||e[17]!==d||e[18]!==p?(b=t.jsxs("svg",{viewBox:a,className:c,role:f,"aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":100,children:[l,p]}),e[14]=a,e[15]=c,e[16]=f,e[17]=d,e[18]=p,e[19]=b):b=e[19],b},fu=n=>{const e=le.c(13),{icon:s,iconNode:i,label:r,children:o}=n;let a;e[0]!==s||e[1]!==i?(a=i??(s?t.jsx(X,{name:s,className:"size-[18px]"}):null),e[0]=s,e[1]=i,e[2]=a):a=e[2];let c;e[3]!==a?(c=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:a}),e[3]=a,e[4]=c):c=e[4];let f;e[5]!==r?(f=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:r}),e[5]=r,e[6]=f):f=e[6];let d;e[7]!==o?(d=t.jsx("span",{className:"min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground",children:o}),e[7]=o,e[8]=d):d=e[8];let l;return e[9]!==c||e[10]!==f||e[11]!==d?(l=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5",children:[c,f,d]}),e[9]=c,e[10]=f,e[11]=d,e[12]=l):l=e[12],l},mu=n=>{const e=le.c(57),{open:s,onClose:i,anchorRef:r,contextDisplay:o,usageGroups:a,usageDisplayMode:c,isUsageLoading:f,timeFormatPreference:d}=n,{t:l}=me(),p=u.useRef(null),[b,h]=u.useState(s),[x,S]=u.useState(!1),{enabled:y}=Rn(),E=u.useRef(null),[w,N]=u.useState(null);let A,v;e[0]!==r||e[1]!==y||e[2]!==s||e[3]!==b?(A=()=>{if(!s||!y||!b)return;const Q=()=>{const ce=r.current?.getBoundingClientRect(),ue=E.current?.getBoundingClientRect();if(!ce||!ue){N(null);return}const K=ce.left-ue.left,oe=Math.min(Math.max(K,8),Math.max(8,ue.width-zr-8));N(oe)};Q();const ne=E.current;if(typeof ResizeObserver>"u"||!ne)return;const re=new ResizeObserver(Q);return re.observe(ne),()=>re.disconnect()},v=[r,y,s,b],e[0]=r,e[1]=y,e[2]=s,e[3]=b,e[4]=A,e[5]=v):(A=e[4],v=e[5]),u.useLayoutEffect(A,v);const P=y&&w!==null;let C,R;e[6]!==s||e[7]!==b?(C=()=>{if(s){h(!0),S(!1);return}if(!b)return;S(!0);const Q=window.setTimeout(()=>{h(!1),S(!1)},140);return()=>window.clearTimeout(Q)},R=[s,b],e[6]=s,e[7]=b,e[8]=C,e[9]=R):(C=e[8],R=e[9]),u.useEffect(C,R);let k,z;e[10]!==i||e[11]!==s?(k=()=>{if(!s)return;const Q=ne=>{ne.key==="Escape"&&i()};return document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)},z=[i,s],e[10]=i,e[11]=s,e[12]=k,e[13]=z):(k=e[12],z=e[13]),u.useEffect(k,z);let D,_;if(e[14]!==r||e[15]!==i||e[16]!==s?(D=()=>{if(!s)return;const Q=ne=>{const re=ne.target;if(!(re instanceof Node)){i();return}p.current?.contains(re)||r.current?.contains(re)||i()};return document.addEventListener("pointerdown",Q,!0),document.addEventListener("wheel",Q,!0),()=>{document.removeEventListener("pointerdown",Q,!0),document.removeEventListener("wheel",Q,!0)}},_=[r,i,s],e[14]=r,e[15]=i,e[16]=s,e[17]=D,e[18]=_):(D=e[17],_=e[18]),u.useEffect(D,_),!b)return null;let j;e[19]!==l?(j=l("mobile.header.openMetadataAria"),e[19]=l,e[20]=j):j=e[20];const I=P?"absolute origin-top-left":"mx-3 mt-2",$=x?"pointer-events-none":"pointer-events-auto";let g;e[21]!==I||e[22]!==$?(g=J("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",I,$),e[21]=I,e[22]=$,e[23]=g):g=e[23];const O=`${x?"session-metadata-out":"session-metadata-in"} ${x?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let V;e[24]!==w||e[25]!==P?(V=P?{top:8,left:w??8,width:`min(${zr}px, calc(100% - 16px))`}:null,e[24]=w,e[25]=P,e[26]=V):V=e[26];let B;e[27]!==O||e[28]!==V?(B={animation:O,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...V},e[27]=O,e[28]=V,e[29]=B):B=e[29];let L;e[30]!==o||e[31]!==l?(L=o?t.jsx(fu,{iconNode:t.jsx(Gi,{percentage:o.state==="measured"?o.percentage:null}),label:l("mobile.header.metadata.context"),children:o.state==="pending"?null:t.jsxs("span",{className:"inline-flex items-baseline gap-1.5 tabular-nums",children:[o.state==="measured"?t.jsxs("span",{className:J("font-semibold",o.colorClass),children:[o.percentage.toFixed(1),"%"]}):null,t.jsx("span",{className:"text-muted-foreground",children:o.tokens})]})}):null,e[30]=o,e[31]=l,e[32]=L):L=e[32];let ie;e[33]!==o?.state||e[34]!==l?(ie=o?.state==="compacted"?t.jsx("p",{className:"px-2.5 pb-1 typography-meta text-muted-foreground",children:l("contextUsage.compacted.description")}):null,e[33]=o?.state,e[34]=l,e[35]=ie):ie=e[35];let se;e[36]!==o?.state||e[37]!==l?(se=o?.state==="pending"?t.jsx("p",{className:"px-2.5 pb-1 typography-meta text-muted-foreground",children:l("mobile.header.metadata.contextPending")}):null,e[36]=o?.state,e[37]=l,e[38]=se):se=e[38];let te;e[39]!==f||e[40]!==d||e[41]!==c||e[42]!==a?(te=t.jsx(pu,{groups:a,displayMode:c,isLoading:f,timeFormatPreference:d}),e[39]=f,e[40]=d,e[41]=c,e[42]=a,e[43]=te):te=e[43];let M;e[44]!==L||e[45]!==ie||e[46]!==se||e[47]!==te?(M=t.jsxs("div",{className:"space-y-1",children:[L,ie,se,te]}),e[44]=L,e[45]=ie,e[46]=se,e[47]=te,e[48]=M):M=e[48];let G;e[49]!==g||e[50]!==B||e[51]!==M||e[52]!==j?(G=t.jsx("div",{ref:p,role:"dialog","aria-label":j,className:g,style:B,children:M}),e[49]=g,e[50]=B,e[51]=M,e[52]=j,e[53]=G):G=e[53];let Y;e[54]===Symbol.for("react.memo_cache_sentinel")?(Y=t.jsx("style",{children:`
5
5
  @keyframes session-metadata-in {
@@ -22,4 +22,4 @@ import{f as le,r as bn,j as t,R as u,c as Lt,h as mo}from"./vendor-react-BUCujlK
22
22
  `}),e[47]=G):G=e[47];let Y;return e[48]!==M?(Y=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:[M,G]}),e[48]=M,e[49]=Y):Y=e[49],Y};function vu(n){return n.currentSessionId}function wu(n){return n.setCurrentSession}function ju(n){return n.setActiveProjectIdOnly}const ku=n=>{const e=le.c(78),{onOpenSessions:s,onOpenWorkspace:i,compactTitle:r}=n,o=r===void 0?!1:r,{t:a}=me(),[c,f]=u.useState(!1),[d,l]=u.useState(!1),p=u.useRef(null),b=ht(Su),h=Se(Nu);let x;e[0]!==h?(x=De=>h?De.getDirectoryForSession(h):null,e[0]=h,e[1]=x):x=e[1];const y=Se(x)||b,E=Bo(h,y||void 0),w=Se(Cu),N=ci(y||null);let A;e[2]!==y||e[3]!==N?(A=De=>{if(!y||N!==!0)return!1;const Be=De.directories.get(y)?.status;return!!(Be&&!Be.isClean)},e[2]=y,e[3]=N,e[4]=A):A=e[4];const v=Fe(A);let P;e[5]!==E?.title?(P=E?.title?.trim(),e[5]=E?.title,e[6]=P):P=e[6];const C=P;let R;e[7]!==h||e[8]!==C||e[9]!==a?(R=C||a(h?"mobile.sessions.untitled":"sessions.switcher.draftTitle"),e[7]=h,e[8]=C,e[9]=a,e[10]=R):R=e[10];const k=R;let z;e[11]===Symbol.for("react.memo_cache_sentinel")?(z=()=>{f(!1),l(!1)},e[11]=z):z=e[11];let D;e[12]!==h||e[13]!==y?(D=[h,y],e[12]=h,e[13]=y,e[14]=D):D=e[14],u.useEffect(z,D);let _;e[15]!==s?(_=()=>{f(!1),l(!1),s()},e[15]=s,e[16]=_):_=e[16];const j=_;let I;e[17]===Symbol.for("react.memo_cache_sentinel")?(I=De=>{f(Be=>{const Ne=typeof De=="function"?De(Be):De;return Ne&&l(!1),Ne})},e[17]=I):I=e[17];const $=I;let g;e[18]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{l(De=>{const Be=!De;return Be&&f(!1),Be})},e[18]=g):g=e[18];const O=g;let V;e[19]===Symbol.for("react.memo_cache_sentinel")?(V={paddingTop:"var(--oc-safe-area-top, 0px)"},e[19]=V):V=e[19];let B;e[20]!==a?(B=a("mobile.sessions.openSheetAria"),e[20]=a,e[21]=B):B=e[21];let L,ie;e[22]===Symbol.for("react.memo_cache_sentinel")?(L={touchAction:"manipulation"},ie=t.jsx(X,{name:"list-unordered",className:"size-5"}),e[22]=L,e[23]=ie):(L=e[22],ie=e[23]);let se;e[24]!==j||e[25]!==B?(se=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":B,onClick:j,style:L,children:ie}),e[24]=j,e[25]=B,e[26]=se):se=e[26];const te=o?"shrink":"flex-1";let M;e[27]!==te?(M=J("flex min-w-0 items-center rounded-lg px-2 py-1.5 text-left transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",te),e[27]=te,e[28]=M):M=e[28];let G;e[29]!==a?(G=a("sessions.switcher.openAria"),e[29]=a,e[30]=G):G=e[30];let Y;e[31]===Symbol.for("react.memo_cache_sentinel")?(Y={touchAction:"manipulation"},e[31]=Y):Y=e[31];let H;e[32]!==k?(H=t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",children:k}),e[32]=k,e[33]=H):H=e[33];const Q=d&&"rotate-180";let ne;e[34]!==Q?(ne=J("size-4 shrink-0 text-muted-foreground transition-transform duration-150",Q),e[34]=Q,e[35]=ne):ne=e[35];let re;e[36]!==ne?(re=t.jsx(X,{name:"arrow-down-s",className:ne}),e[36]=ne,e[37]=re):re=e[37];let ce;e[38]!==H||e[39]!==re?(ce=t.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[H,re]}),e[38]=H,e[39]=re,e[40]=ce):ce=e[40];let ue;e[41]!==d||e[42]!==M||e[43]!==G||e[44]!==ce?(ue=t.jsx("button",{ref:p,type:"button",className:M,"aria-label":G,"aria-haspopup":"dialog","aria-expanded":d,onClick:O,style:Y,children:ce}),e[41]=d,e[42]=M,e[43]=G,e[44]=ce,e[45]=ue):ue=e[45];let K;e[46]!==o?(K=o?t.jsx("div",{className:"min-w-0 flex-1"}):null,e[46]=o,e[47]=K):K=e[47];let oe;e[48]!==h||e[49]!==y||e[50]!==w||e[51]!==c?(oe=t.jsx(hu,{open:c,onOpenChange:$,currentSessionId:h,effectiveDirectory:y,isNewSessionDraftOpen:w}),e[48]=h,e[49]=y,e[50]=w,e[51]=c,e[52]=oe):oe=e[52];let pe;e[53]!==v||e[54]!==a?(pe=a(v?"mobile.header.openWorkspaceWithChangesAria":"mobile.header.openWorkspaceAria"),e[53]=v,e[54]=a,e[55]=pe):pe=e[55];let ke;e[56]!==i?(ke=()=>{f(!1),l(!1),i()},e[56]=i,e[57]=ke):ke=e[57];let q,de;e[58]===Symbol.for("react.memo_cache_sentinel")?(q={touchAction:"manipulation"},de=t.jsx(X,{name:"pencil-ruler-2",className:"size-5"}),e[58]=q,e[59]=de):(q=e[58],de=e[59]);let Ce;e[60]!==v?(Ce=v?t.jsx("span",{className:"absolute right-1.5 top-1.5 size-2.5 rounded-full border-2 border-[var(--background)] bg-[var(--status-warning)]","aria-hidden":!0}):null,e[60]=v,e[61]=Ce):Ce=e[61];let ze;e[62]!==pe||e[63]!==ke||e[64]!==Ce?(ze=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":pe,onClick:ke,style:q,children:[de,Ce]}),e[62]=pe,e[63]=ke,e[64]=Ce,e[65]=ze):ze=e[65];let Ae;e[66]!==se||e[67]!==ue||e[68]!==K||e[69]!==oe||e[70]!==ze?(Ae=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:V,children:t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[se,ue,K,oe,ze]})}),e[66]=se,e[67]=ue,e[68]=K,e[69]=oe,e[70]=ze,e[71]=Ae):Ae=e[71];let Je;e[72]===Symbol.for("react.memo_cache_sentinel")?(Je=()=>l(!1),e[72]=Je):Je=e[72];let Xe;e[73]!==d?(Xe=t.jsx(yu,{open:d,onClose:Je,anchorRef:p}),e[73]=d,e[74]=Xe):Xe=e[74];let ut;return e[75]!==Ae||e[76]!==Xe?(ut=t.jsxs(t.Fragment,{children:[Ae,Xe]}),e[75]=Ae,e[76]=Xe,e[77]=ut):ut=e[77],ut};function Su(n){return n.currentDirectory}function Nu(n){return n.currentSessionId}function Cu(n){return!!n.newSessionDraft?.open}const Ru=({onActiveConnectionDeleted:n,onConnect:e})=>{const{t:s}=me(),i=Oi(e),{connections:r,isBusy:o,isPasswordBusy:a,error:c,pendingConnection:f,connect:d,submitPassword:l,cancelPassword:p,saveConnection:b,removeConnection:h,setError:x}=i,[S,y]=u.useState(null),E=S?r.find(K=>K.id===S)??null:null,[w,N]=u.useState(null),[A,v]=u.useState(""),[P,C]=u.useState(""),[R,k]=u.useState(""),[z,D]=u.useState(""),[_,j]=u.useState(!1),[I,$]=u.useState(!1),g=u.useRef(null),O=u.useMemo(()=>wn(),[]),[V,B]=u.useState(!1),[L,ie]=u.useState(null),[se,te]=u.useState(!1),M=Ri(u.useCallback(()=>te(!0),[])),G=u.useCallback(()=>{y(null),v(""),C(""),k(""),x(null),B(!1)},[x]),Y=u.useCallback(K=>{K.preventDefault(),b({id:S??void 0,url:A,label:P,clientToken:R}).then(oe=>{oe&&G()})},[R,S,P,G,b,A]),H=u.useCallback(async()=>{if(g.current)return;x(null),j(!0);const K=new AbortController;g.current=K;try{const oe=await Wi({signal:K.signal});switch(g.current===K&&(g.current=null,j(!1)),oe.status){case"ok":v(oe.url),oe.label&&C(oe.label),oe.clientToken&&k(oe.clientToken),B(!0);break;case"pairing":$(!0),await i.redeemPairingConnection(oe.pairing);break;case"permission-denied":x(s("mobile.connect.scan.permissionDenied"));break;case"invalid":x(s("mobile.connect.scan.invalid"));break;case"unsupported":x(s("mobile.connect.scan.unsupported"));break;case"failed":x(s("mobile.connect.scan.failed"));break;default:break}}finally{$(!1),g.current===K&&(g.current=null,j(!1))}},[i,x,s]);u.useEffect(()=>()=>g.current?.abort(),[]);const Q=u.useCallback(K=>{K.preventDefault(),l(z)},[z,l]),ne=u.useCallback(()=>{D(""),p()},[p]),re=u.useCallback(K=>{N(oe=>oe===K?null:K)},[]),ce=u.useCallback(K=>{N(null),S===K&&G();const oe=r.length===1;h(K).then(pe=>{pe&&(oe||Mr(pe))&&n()})},[r.length,S,n,h,G]),ue=as;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(X,{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(K=>K.kind==="direct")?ct(f):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...Bt,value:z,onChange:K=>D(K.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:ue}),c?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:c}):null,t.jsx(ge,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:a||!z.trim(),children:s(a?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(ge,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:ne,children:s("mobile.connect.cancelPassword")})]})})}):t.jsxs(t.Fragment,{children:[_?t.jsx(Vi,{onCancel:()=>g.current?.abort()}):null,I?t.jsx(Ui,{}):null,se?t.jsx(Bi,{onClose:()=>te(!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:[r.length>0?t.jsx("div",{...M,className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map(K=>{const oe=w===K.id,pe=Mr(K),ke=L===K.id,q=ke?s("mobile.connect.connecting"):pe?fs()?s("mobile.instances.status.connectedRelay"):s("mobile.instances.status.connectedDirect"):K.candidates.some(de=>de.kind==="direct")?ct(K):s("mobile.connect.relay.badge");return t.jsxs("div",{className:J("flex items-center border-b border-border/70 transition-colors last:border-b-0",oe&&"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-left 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:()=>{pe||(ie(K.id),d({id:K.id,candidates:K.candidates,clientToken:K.clientToken,label:K.label}).finally(()=>ie(null)))},disabled:o&&!ke||oe,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(X,{name:"server",className:"size-[18px]"}),pe?t.jsx("span",{className:"absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-[var(--surface-elevated)] bg-[var(--status-success)]","aria-hidden":!0}):null]}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:K.label}),t.jsx("span",{className:J("block truncate typography-small",pe&&!ke?"text-[var(--status-success)]":"text-muted-foreground"),children:q})]}),ke?t.jsx(X,{name:"loader-4",className:"size-5 shrink-0 animate-spin text-muted-foreground"}):null]}),t.jsxs("div",{className:"flex items-center gap-0.5 pr-2",children:[oe?t.jsxs("button",{type:"button","aria-label":s("mobile.instances.confirmDeleteAria",{label:K.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:()=>ce(K.id),style:{touchAction:"manipulation"},children:[t.jsx(X,{name:"delete-bin",className:"size-[18px]"}),t.jsx("span",{className:"typography-ui-label",children:s("mobile.instances.delete")})]}):K.candidates.some(de=>de.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:()=>{y(K.id),v(ct(K)),C(K.label),k(K.clientToken||""),x(null)},style:{touchAction:"manipulation"},children:t.jsx(X,{name:"edit",className:"size-[18px]"})}):null,t.jsx("button",{type:"button","aria-label":oe?s("mobile.instances.cancelDeleteAria",{label:K.label}):s("mobile.instances.deleteAria",{label:K.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:()=>re(K.id),style:{touchAction:"manipulation"},children:t.jsx(X,{name:oe?"close":"delete-bin",className:"size-[18px]"})})]})]},K.id)})}):t.jsx("p",{...M,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")}),!V&&!E?t.jsxs("div",{className:"space-y-2",children:[O?t.jsxs(ge,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{H()},disabled:_,children:[t.jsx(X,{name:"scan-2",className:J("size-[18px]",_&&"animate-pulse")}),s("mobile.connect.scanQr")]}):null,t.jsxs(ge,{type:"button",variant:O?"ghost":"outline",size:"lg",className:"h-12 w-full",onClick:()=>{x(null),B(!0)},children:[t.jsx(X,{name:"add",className:"size-[18px]"}),s("mobile.instances.addManual")]}),c?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:c}):null]}):t.jsxs("form",{className:"space-y-3",onSubmit:Y,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(E?"mobile.instances.editTitle":"mobile.instances.addTitle")}),t.jsx(ge,{type:"button",variant:"ghost",size:"xs",onClick:G,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",{...Bt,value:A,onChange:K=>v(K.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:P,onChange:K=>C(K.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",{...Bt,value:R,onChange:K=>k(K.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")})]}),c?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:c}):null,t.jsx(ge,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",children:s(E?"mobile.instances.saveEdit":"mobile.instances.saveNew")})]})]})})})]})},Me=n=>xo(n)??"",fn=n=>{const e=Me(n);if(!e)return"";const s=e.split("/").filter(Boolean);return s[s.length-1]?.replace(/[-_]/g," ")||e},Br=qn(n=>({expandedParents:{},toggleParent:e=>n(s=>{const i={...s.expandedParents};return i[e]?delete i[e]:i[e]=!0,{expandedParents:i}})})),Is=qn()(Si(n=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(e,s)=>n(i=>({projectExpanded:{...i.projectExpanded,[e]:s}})),setWorktreeExpanded:(e,s)=>n(i=>({worktreeExpanded:{...i.worktreeExpanded,[e]:s}}))}),{name:"mobile-session-tree"})),jn=qn()(Si(n=>({orderByProject:{},setWorktreeOrder:(e,s)=>n(i=>({orderByProject:{...i.orderByProject,[e]:s}}))}),{name:"mobile-worktree-order"})),Lr=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),Eu=(n,e)=>{if(!n||n.length===0)return e;const s=new Map(n.map((r,o)=>[Lr(r),o])),i=r=>s.get(Lr(r.path))??Number.MAX_SAFE_INTEGER;return e.map((r,o)=>({worktree:r,index:o})).sort((r,o)=>{const a=i(r.worktree)-i(o.worktree);return a!==0?a:r.index-o.index}).map(r=>r.worktree)},ls=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/,""),Pu=n=>{const e=n;return ls(e.directory??e.project?.worktree??null)},Ki=({open:n,project:e,worktree:s,onClose:i,onDeleted:r})=>{const{t:o}=me(),a=ui(),c=Nn(k=>k.activeSessions),f=Se(k=>k.archiveSessions),d=ht(k=>k.currentDirectory),[l,p]=u.useState(!1),[b,h]=u.useState(!1),[x,S]=u.useState(!1),[y,E]=u.useState(!1),w=ls(s?.path),N=typeof s?.branch=="string"&&s.branch.trim().length>0,A=u.useMemo(()=>{if(!w)return[];const k=new Map;for(const z of[...c,...a])Pu(z)===w&&k.set(z.id,z);return Array.from(k.values())},[c,a,w]);u.useEffect(()=>{if(!n){p(!1),h(!1),S(!1),E(!1);return}if(!s?.path)return;let k=!1;return Lo(s.path).then(z=>{k||S(!!z?.isDirty)}).catch(()=>{k||S(!!s.status?.isDirty)}),()=>{k=!0}},[n,s?.path,s?.status?.isDirty]);const v=u.useCallback((k,z)=>{const D=$o(k),_=fe.loading(o("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:D}));(async()=>{try{if(z.length>0){const{failedIds:j}=await f(z);if(j.length>0){fe.error(j.length===1?o("sessions.sidebar.bulkActions.failedArchiveSingle",{count:j.length}):o("sessions.sidebar.bulkActions.failedArchivePlural",{count:j.length}),{id:_,description:o("sessions.sidebar.dialogs.deleteResult.tryAgain")});return}}await Fo(e,k,{deleteRemoteBranch:N&&b,deleteLocalBranch:N&&l}),ls(d)===w&&ls(e.path)&&ht.getState().setDirectory(ls(e.path),{showOverlay:!1}),fe.success(o("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:D}),{id:_,description:o(N&&b?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed")}),r?.()}catch(j){fe.error(o("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:D}),{id:_,description:j instanceof Error?j.message:o("sessions.sidebar.dialogs.deleteResult.tryAgain")})}})()},[f,d,l,b,N,r,e,o,w]),P=()=>{!s||y||(E(!0),v(s,A.map(k=>k.id)),i())};if(!s)return null;const C=s.branch||s.label||s.path,R=(k,z,D,_)=>t.jsxs("button",{type:"button",role:"switch","aria-checked":k,disabled:_,onClick:()=>z(!k),className:J("flex w-full items-center justify-between gap-3 rounded-xl border border-border/70 px-3.5 py-3 text-left transition-colors","hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",_&&"pointer-events-none opacity-40"),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:D}),t.jsx("span",{className:J("relative h-6 w-10 shrink-0 rounded-full transition-colors",k?"bg-primary":"bg-muted-foreground/30"),children:t.jsx("span",{className:J("absolute top-0.5 size-5 rounded-full bg-white transition-transform",k?"translate-x-[1.125rem]":"translate-x-0.5")})})]});return t.jsx(di,{open:n,onClose:i,title:o("mobile.projectEdit.deleteWorktreeTitle"),footer:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(ge,{variant:"ghost",className:"flex-1",onClick:i,disabled:y,children:o("projectEditDialog.actions.cancel")}),t.jsx(ge,{variant:"destructive",className:"flex-1",onClick:()=>{P()},disabled:y,children:o("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:o("mobile.projectEdit.deleteWorktreeConfirm",{name:C})}),x?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:o("mobile.projectEdit.deleteWorktreeDirty")}):null,A.length>0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("mobile.projectEdit.deleteWorktreeArchiveNote",{count:A.length})}):null,N?t.jsxs("div",{className:"flex flex-col gap-2",children:[R(l,p,o("mobile.projectEdit.deleteLocalBranch"),y),R(b,h,o("mobile.projectEdit.deleteRemoteBranch"),y)]}):null]})})},Us=n=>{const e=le.c(18),{project:s,size:i}=n,r=i===void 0?"md":i,{currentTheme:o}=fi(),a=s.icon?mi[s.icon]:null,c=s.color?pi[s.color]??null:null,f=r==="sm"?"size-6 rounded-md":"size-8 rounded-lg",d=r==="sm"?"size-3.5":"size-4";let l;e[0]!==a||e[1]!==c||e[2]!==d?(l=a?t.jsx(X,{name:a,className:d,style:c?{color:c}:void 0}):t.jsx(xn,{className:d,style:c?{color:c}:void 0}),e[0]=a,e[1]=c,e[2]=d,e[3]=l):l=e[3];const p=l,b=r==="md"&&"bg-[var(--surface-muted)]";let h;e[4]!==f||e[5]!==b?(h=J("flex shrink-0 items-center justify-center overflow-hidden text-muted-foreground",b,f),e[4]=f,e[5]=b,e[6]=h):h=e[6];let x;e[7]!==s.iconBackground?(x=s.iconBackground?{backgroundColor:s.iconBackground}:void 0,e[7]=s.iconBackground,e[8]=x):x=e[8];let S;e[9]!==o||e[10]!==p||e[11]!==s.iconImage||e[12]!==s.id?(S=s.iconImage?t.jsx(hi,{project:{id:s.id,iconImage:s.iconImage??null},options:{themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},className:"size-full object-contain",fallback:p}):p,e[9]=o,e[10]=p,e[11]=s.iconImage,e[12]=s.id,e[13]=S):S=e[13];let y;return e[14]!==h||e[15]!==x||e[16]!==S?(y=t.jsx("span",{className:h,style:x,children:S}),e[14]=h,e[15]=x,e[16]=S,e[17]=y):y=e[17],y},Hi=n=>{const e=le.c(44),{initialTitle:s,indent:i,className:r,onSubmit:o,onCancel:a}=n,{t:c}=me(),[f,d]=u.useState(s),l=Au;let p;e[0]!==s||e[1]!==a||e[2]!==o||e[3]!==f?(p=()=>{const $=f.trim();if(!$||$===s.trim()){a();return}o($)},e[0]=s,e[1]=a,e[2]=o,e[3]=f,e[4]=p):p=e[4];const b=p;let h;e[5]!==r?(h=J("flex h-9 min-w-0 flex-1 items-center gap-2 pr-2",r),e[5]=r,e[6]=h):h=e[6];let x;e[7]!==i?(x={paddingLeft:i},e[7]=i,e[8]=x):x=e[8];let S;e[9]!==b?(S=$=>{$.preventDefault(),b()},e[9]=b,e[10]=S):S=e[10];let y;e[11]===Symbol.for("react.memo_cache_sentinel")?(y=$=>d($.target.value),e[11]=y):y=e[11];let E;e[12]!==a?(E=$=>nl($,a),e[12]=a,e[13]=E):E=e[13];let w;e[14]!==c?(w=c("sessions.sidebar.session.rename.save"),e[14]=c,e[15]=w):w=e[15];let N;e[16]!==c?(N=c("sessions.sidebar.session.menu.rename"),e[16]=c,e[17]=N):N=e[17];let A;e[18]===Symbol.for("react.memo_cache_sentinel")?(A={minHeight:0},e[18]=A):A=e[18];let v;e[19]!==E||e[20]!==w||e[21]!==N||e[22]!==f?(v=t.jsx("input",{ref:l,value:f,onChange:y,onKeyDown:E,"aria-label":w,placeholder:N,className:"min-w-0 flex-1 bg-transparent text-[16px] typography-ui-label text-foreground outline-none placeholder:text-muted-foreground",style:A,enterKeyHint:"done"}),e[19]=E,e[20]=w,e[21]=N,e[22]=f,e[23]=v):v=e[23];let P;e[24]!==c?(P=c("sessions.sidebar.session.rename.save"),e[24]=c,e[25]=P):P=e[25];let C,R;e[26]===Symbol.for("react.memo_cache_sentinel")?(C={touchAction:"manipulation",minHeight:0,minWidth:0},R=t.jsx(X,{name:"check",className:"size-4"}),e[26]=C,e[27]=R):(C=e[26],R=e[27]);let k;e[28]!==P?(k=t.jsx("button",{type:"submit","aria-label":P,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:C,children:R}),e[28]=P,e[29]=k):k=e[29];let z;e[30]!==c?(z=c("sessions.sidebar.session.rename.cancel"),e[30]=c,e[31]=z):z=e[31];let D,_;e[32]===Symbol.for("react.memo_cache_sentinel")?(D={touchAction:"manipulation",minHeight:0,minWidth:0},_=t.jsx(X,{name:"close",className:"size-4"}),e[32]=D,e[33]=_):(D=e[32],_=e[33]);let j;e[34]!==a||e[35]!==z?(j=t.jsx("button",{type:"button",onClick:a,"aria-label":z,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:D,children:_}),e[34]=a,e[35]=z,e[36]=j):j=e[36];let I;return e[37]!==v||e[38]!==k||e[39]!==j||e[40]!==h||e[41]!==x||e[42]!==S?(I=t.jsxs("form",{className:h,style:x,onSubmit:S,children:[v,k,j]}),e[37]=v,e[38]=k,e[39]=j,e[40]=h,e[41]=x,e[42]=S,e[43]=I):I=e[43],I};function Au(n){n&&(n.focus(),n.select())}const qi=192,Iu=180,Gs=n=>{const e=le.c(27),{actionsWidth:s,actions:i,revealed:r,onRevealedChange:o,dataActiveSession:a,contentClassName:c,children:f}=n,d=c===void 0?"relative flex w-full items-center bg-background":c,l=u.useRef(null),p=u.useRef(null),b=u.useRef(!1),h=u.useRef(0),x=u.useRef(r);let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S=(g,O)=>{const V=l.current;V&&(V.style.transition=O?`transform ${Iu}ms ease-out`:"none",V.style.transform=g===0?"none":`translateX(${g}px)`,h.current=g)},e[0]=S):S=e[0];const y=S;let E,w;e[1]!==s||e[2]!==r?(E=()=>{x.current=r,y(r?s:0,!0)},w=[s,y,r],e[1]=s,e[2]=r,e[3]=E,e[4]=w):(E=e[3],w=e[4]),u.useEffect(E,w);let N;e[5]===Symbol.for("react.memo_cache_sentinel")?(N=g=>{if(g.touches.length!==1)return;const O=g.touches[0];p.current={x:O.clientX,y:O.clientY},b.current=!1},e[5]=N):N=e[5];const A=N;let v;e[6]!==s?(v=g=>{if(!p.current)return;const O=g.touches[0],V=O.clientX-p.current.x,B=O.clientY-p.current.y;if(!b.current){if(Math.abs(V)<8||Math.abs(V)<=Math.abs(B))return;b.current=!0}const L=x.current?s:0;y(Math.max(0,Math.min(s,L+V)),!1)},e[6]=s,e[7]=v):v=e[7];const P=v;let C;e[8]!==s||e[9]!==o?(C=()=>{if(p.current=null,!b.current)return;b.current=!1;const g=h.current>s/2;y(g?s:0,!0),g!==x.current&&o(g)},e[8]=s,e[9]=o,e[10]=C):C=e[10];const R=C,k=a||void 0;let z;e[11]===Symbol.for("react.memo_cache_sentinel")?(z={touchAction:"pan-y"},e[11]=z):z=e[11];let D;e[12]!==s?(D={width:s},e[12]=s,e[13]=D):D=e[13];const _=!r;let j;e[14]!==i||e[15]!==D||e[16]!==_?(j=t.jsx("div",{className:"absolute inset-y-0 left-0 flex items-stretch",style:D,"aria-hidden":_,children:i}),e[14]=i,e[15]=D,e[16]=_,e[17]=j):j=e[17];let I;e[18]!==f||e[19]!==d?(I=t.jsx("div",{ref:l,className:d,children:f}),e[18]=f,e[19]=d,e[20]=I):I=e[20];let $;return e[21]!==R||e[22]!==P||e[23]!==j||e[24]!==I||e[25]!==k?($=t.jsxs("div",{"data-active-session":k,className:"relative overflow-hidden",onTouchStart:A,onTouchMove:P,onTouchEnd:R,onTouchCancel:R,style:z,children:[j,I]}),e[21]=R,e[22]=P,e[23]=j,e[24]=I,e[25]=k,e[26]=$):$=e[26],$},Ji=n=>{const e=le.c(52),{title:s,revealed:i,confirmingDelete:r,aiRename:o,onArchive:a,onRequestDelete:c,onConfirmDelete:f,onRequestRename:d,onRevealedChange:l}=n,{t:p}=me(),b=i?0:-1,h=r?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80";let x;e[0]!==h?(x=J("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",h),e[0]=h,e[1]=x):x=e[1];let S;e[2]!==r||e[3]!==p||e[4]!==s?(S=r?p("mobile.sessions.confirmDeleteSessionAria",{title:s}):p("mobile.sessions.deleteSessionAria",{title:s}),e[2]=r,e[3]=p,e[4]=s,e[5]=S):S=e[5];const y=r?f:c;let E,w;e[6]===Symbol.for("react.memo_cache_sentinel")?(E={touchAction:"manipulation"},w=t.jsx(Bs,{className:"size-[18px]"}),e[6]=E,e[7]=w):(E=e[6],w=e[7]);let N;e[8]!==x||e[9]!==S||e[10]!==y||e[11]!==b?(N=t.jsx("button",{type:"button",tabIndex:b,className:x,"aria-label":S,onClick:y,style:E,children:w}),e[8]=x,e[9]=S,e[10]=y,e[11]=b,e[12]=N):N=e[12];let A;e[13]!==p||e[14]!==s?(A=p("mobile.sessions.archiveSessionAria",{title:s}),e[13]=p,e[14]=s,e[15]=A):A=e[15];let v,P;e[16]===Symbol.for("react.memo_cache_sentinel")?(P={touchAction:"manipulation"},v=t.jsx(Ll,{className:"size-[18px]"}),e[16]=v,e[17]=P):(v=e[16],P=e[17]);let C;e[18]!==a||e[19]!==A||e[20]!==b?(C=t.jsx("button",{type:"button",tabIndex:b,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:a,style:P,children:v}),e[18]=a,e[19]=A,e[20]=b,e[21]=C):C=e[21];let R;e[22]!==p||e[23]!==s?(R=p("mobile.sessions.renameSessionAria",{title:s}),e[22]=p,e[23]=s,e[24]=R):R=e[24];let k,z;e[25]===Symbol.for("react.memo_cache_sentinel")?(k={touchAction:"manipulation"},z=t.jsx(yn,{className:"size-[18px]"}),e[25]=k,e[26]=z):(k=e[25],z=e[26]);let D;e[27]!==d||e[28]!==R||e[29]!==b?(D=t.jsx("button",{type:"button",tabIndex:b,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":R,onClick:d,style:k,children:z}),e[27]=d,e[28]=R,e[29]=b,e[30]=D):D=e[30];const _=o.disabled;let j;e[31]!==p?(j=p("sessions.aiRename.action"),e[31]=p,e[32]=j):j=e[32];let I;e[33]!==o||e[34]!==l?(I=()=>{o.run(),l?.(!1)},e[33]=o,e[34]=l,e[35]=I):I=e[35];let $;e[36]===Symbol.for("react.memo_cache_sentinel")?($={touchAction:"manipulation"},e[36]=$):$=e[36];const g=o.pending?"loader-4":"ai-generate-2",O=o.pending?"size-[18px] animate-spin":"size-[18px]";let V;e[37]!==g||e[38]!==O?(V=t.jsx(X,{name:g,className:O}),e[37]=g,e[38]=O,e[39]=V):V=e[39];let B;e[40]!==o.disabled||e[41]!==o.hint||e[42]!==j||e[43]!==I||e[44]!==V||e[45]!==b?(B=t.jsx(ge,{variant:"ghost",size:"icon",tabIndex:b,className:"flex-1 self-center text-muted-foreground",disabled:_,"aria-label":j,"aria-description":o.hint,title:o.hint,onClick:I,style:$,children:V}),e[40]=o.disabled,e[41]=o.hint,e[42]=j,e[43]=I,e[44]=V,e[45]=b,e[46]=B):B=e[46];let L;return e[47]!==C||e[48]!==D||e[49]!==B||e[50]!==N?(L=t.jsxs(t.Fragment,{children:[N,C,D,B]}),e[47]=C,e[48]=D,e[49]=B,e[50]=N,e[51]=L):L=e[51],L},pt=n=>n.parentID??null,kn=n=>{const e=n;return Me(e.directory??e.project?.worktree??null)},Yi=n=>{const e=n.time?.updated??n.time?.created,s=typeof e=="number"?e:Number(e);return Number.isFinite(s)&&s>0?s:0},Qi=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 i=Math.floor(s/60);if(i<24)return`${i}h`;const r=Math.floor(i/24);return r<7?`${r}d`:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(n))},$r=12,Tu=n=>{const e=le.c(83),{entry:s,active:i,revealed:r,confirmingDelete:o,renaming:a,handlers:c}=n,{t:f}=me(),{session:d,project:l,branch:p}=s;let b;e[0]!==d.title||e[1]!==f?(b=d.title?.trim()||f("mobile.sessions.untitled"),e[0]=d.title,e[1]=f,e[2]=b):b=e[2];const h=b;let x;e[3]!==d?(x=Qi(Yi(d)),e[3]=d,e[4]=x):x=e[4];const S=x,y=ji(d.id,d.directory,r),E=En(d.id),w=Pn(d.id),N=!w&&E>0&&!i,A=An(d.id,w),v=(w||N)&&A;let P;e[5]!==c||e[6]!==d.id?(P=O=>c.onRevealedChange(d.id,O),e[5]=c,e[6]=d.id,e[7]=P):P=e[7];const C=i&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let R;e[8]!==C?(R=J("relative flex w-full items-center bg-background transition-colors",C),e[8]=C,e[9]=R):R=e[9];let k;e[10]!==c||e[11]!==d?(k=()=>c.onArchive(d),e[10]=c,e[11]=d,e[12]=k):k=e[12];let z;e[13]!==c||e[14]!==d.id?(z=()=>c.onRequestDelete(d.id),e[13]=c,e[14]=d.id,e[15]=z):z=e[15];let D;e[16]!==c||e[17]!==d?(D=()=>c.onConfirmDelete(d),e[16]=c,e[17]=d,e[18]=D):D=e[18];let _,j;e[19]!==c||e[20]!==d.id?(j=()=>c.onRequestRename(d.id),_=O=>c.onRevealedChange(d.id,O),e[19]=c,e[20]=d.id,e[21]=_,e[22]=j):(_=e[21],j=e[22]);let I;e[23]!==y||e[24]!==o||e[25]!==r||e[26]!==_||e[27]!==k||e[28]!==z||e[29]!==D||e[30]!==j||e[31]!==h?(I=t.jsx(Ji,{title:h,revealed:r,confirmingDelete:o,aiRename:y,onArchive:k,onRequestDelete:z,onConfirmDelete:D,onRequestRename:j,onRevealedChange:_}),e[23]=y,e[24]=o,e[25]=r,e[26]=_,e[27]=k,e[28]=z,e[29]=D,e[30]=j,e[31]=h,e[32]=I):I=e[32];let $;e:{let O;e[33]!==l?(O=t.jsx(Us,{project:l,size:"sm"}),e[33]=l,e[34]=O):O=e[34];let V;e[35]!==l.label?(V=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-micro text-muted-foreground",children:l.label}),e[35]=l.label,e[36]=V):V=e[36];let B;e[37]!==y.pending||e[38]!==w||e[39]!==N||e[40]!==f?(B=y.pending?t.jsx(X,{name:"loader-4",className:"size-3 shrink-0 animate-spin text-primary","aria-label":f("sessions.aiRename.generating")}):w||N?t.jsx(Os,{state:w?"running":"unread",label:f(w?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread")}):null,e[37]=y.pending,e[38]=w,e[39]=N,e[40]=f,e[41]=B):B=e[41];let L;e[42]!==w||e[43]!==d.id||e[44]!==v||e[45]!==S?(L=v?t.jsx(Mn,{sessionId:d.id,running:w,className:"shrink-0 typography-micro"}):S?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:S}):null,e[42]=w,e[43]=d.id,e[44]=v,e[45]=S,e[46]=L):L=e[46];let ie;e[47]!==O||e[48]!==V||e[49]!==B||e[50]!==L?(ie=t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[O,V,B,L]}),e[47]=O,e[48]=V,e[49]=B,e[50]=L,e[51]=ie):ie=e[51];let se;e[52]!==i||e[53]!==c||e[54]!==a||e[55]!==d.id||e[56]!==h?(se=a?t.jsx(Hi,{initialTitle:h,indent:0,className:"h-[1lh] pr-0 typography-ui-label [&_button]:size-6 [&_button>svg]:size-3.5",onSubmit:re=>c.onSubmitRename(d.id,re),onCancel:c.onCancelRename}):t.jsx("span",{className:J("block min-w-0 truncate typography-ui-label",i?"text-primary":"text-foreground"),children:h}),e[52]=i,e[53]=c,e[54]=a,e[55]=d.id,e[56]=h,e[57]=se):se=e[57];let te;e[58]!==p?(te=p?t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[t.jsx(X,{name:"git-branch",className:"size-3.5 shrink-0"}),t.jsx("span",{className:"block min-w-0 truncate typography-micro",children:p})]}):null,e[58]=p,e[59]=te):te=e[59];let M;e[60]!==ie||e[61]!==se||e[62]!==te?(M=t.jsxs(t.Fragment,{children:[ie,se,te]}),e[60]=ie,e[61]=se,e[62]=te,e[63]=M):M=e[63];const G=M;if(a){let re;e[64]===Symbol.for("react.memo_cache_sentinel")?(re={paddingLeft:$r},e[64]=re):re=e[64];let ce;e[65]!==G?(ce=t.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-1 py-2.5 pr-3 text-left",style:re,children:G}),e[65]=G,e[66]=ce):ce=e[66],$=ce;break e}let Y,H;e[67]===Symbol.for("react.memo_cache_sentinel")?(Y=J("flex min-w-0 flex-1 flex-col gap-1 py-2.5 pr-3 text-left","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"),H={paddingLeft:$r,touchAction:"manipulation"},e[67]=Y,e[68]=H):(Y=e[67],H=e[68]);let Q;e[69]!==c||e[70]!==r||e[71]!==d?(Q=()=>{if(r){c.onRevealedChange(d.id,!1);return}c.onSelect(d)},e[69]=c,e[70]=r,e[71]=d,e[72]=Q):Q=e[72];let ne;e[73]!==G||e[74]!==Q?(ne=t.jsx("button",{type:"button",className:Y,style:H,onClick:Q,children:G}),e[73]=G,e[74]=Q,e[75]=ne):ne=e[75],$=ne}let g;return e[76]!==i||e[77]!==r||e[78]!==I||e[79]!==$||e[80]!==P||e[81]!==R?(g=t.jsx(Gs,{actionsWidth:qi,revealed:r,onRevealedChange:P,dataActiveSession:i,contentClassName:R,actions:I,children:$}),e[76]=i,e[77]=r,e[78]=I,e[79]=$,e[80]=P,e[81]=R,e[82]=g):g=e[82],g},Du=n=>{const e=le.c(9),{scrollRootRef:s,visibleCount:i,onReachEnd:r}=n,o=u.useRef(null),a=u.useRef(r);let c,f;e[0]!==r?(c=()=>{a.current=r},f=[r],e[0]=r,e[1]=c,e[2]=f):(c=e[1],f=e[2]),u.useEffect(c,f);let d;e[3]!==s?(d=()=>{const b=o.current;if(!b)return;const h=new IntersectionObserver(x=>{x.some(Mu)&&a.current()},{root:s.current??null,rootMargin:"400px 0px"});return h.observe(b),()=>h.disconnect()},e[3]=s,e[4]=d):d=e[4];let l;e[5]!==s||e[6]!==i?(l=[s,i],e[5]=s,e[6]=i,e[7]=l):l=e[7],u.useEffect(d,l);let p;return e[8]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx("div",{ref:o,"aria-hidden":!0,className:"h-px w-full"}),e[8]=p):p=e[8],p},_u=n=>{const e=le.c(35),{entries:s,visibleCount:i,onRevealMore:r,scrollRootRef:o,handlers:a}=n,{t:c}=me();let f,d,l,p,b;if(e[0]!==s||e[1]!==a||e[2]!==c||e[3]!==i){b=s.slice(0,i),l="border-t border-border/70";let y;e[9]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-[var(--surface-muted)] text-muted-foreground",children:t.jsx(X,{name:"folder-6",className:"size-4"})}),e[9]=y):y=e[9];let E;e[10]!==c?(E=c("mobile.sessions.section.projects"),e[10]=c,e[11]=E):E=e[11];let w;e[12]!==E?(w=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:E}),e[12]=E,e[13]=w):w=e[13];let N;e[14]!==s.length?(N=t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:s.length}),e[14]=s.length,e[15]=N):N=e[15],e[16]!==w||e[17]!==N?(p=t.jsxs("div",{className:"flex min-h-12 w-full items-center gap-2 px-3 py-1.5",children:[y,w,N]}),e[16]=w,e[17]=N,e[18]=p):p=e[18],f="pb-2";let A;e[19]!==a?(A=v=>t.jsx(Tu,{entry:v,active:a.currentSessionId===v.session.id,revealed:a.revealedSessionId===v.session.id,confirmingDelete:a.confirmingDeleteSessionId===v.session.id,renaming:a.renamingSessionId===v.session.id,handlers:a},v.session.id),e[19]=a,e[20]=A):A=e[20],d=b.map(A),e[0]=s,e[1]=a,e[2]=c,e[3]=i,e[4]=f,e[5]=d,e[6]=l,e[7]=p,e[8]=b}else f=e[4],d=e[5],l=e[6],p=e[7],b=e[8];let h;e[21]!==s.length||e[22]!==r||e[23]!==o||e[24]!==i||e[25]!==b.length?(h=b.length<s.length?t.jsx(Du,{scrollRootRef:o,visibleCount:i,onReachEnd:r}):null,e[21]=s.length,e[22]=r,e[23]=o,e[24]=i,e[25]=b.length,e[26]=h):h=e[26];let x;e[27]!==f||e[28]!==d||e[29]!==h?(x=t.jsxs("div",{className:f,children:[d,h]}),e[27]=f,e[28]=d,e[29]=h,e[30]=x):x=e[30];let S;return e[31]!==l||e[32]!==p||e[33]!==x?(S=t.jsxs("section",{className:l,children:[p,x]}),e[31]=l,e[32]=p,e[33]=x,e[34]=S):S=e[34],S};function Mu(n){return n.isIntersecting}const zs=40,zu=(n,e)=>Math.min(e,Math.max(n,0)+zs),Fr="mobile-surface-root",mn=16,Ts=200,Ou=()=>{if(typeof document>"u")return null;let n=document.getElementById(Fr);return n||(n=document.createElement("div"),n.id=Fr,document.body.appendChild(n)),n},Tt=({open:n,onClose:e,title:s,subtitle:i,trailing:r,disableEscapeDismiss:o=!1,headerless:a=!1,noHeaderBorder:c=!1,ariaLabel:f,variant:d="fullscreen",dialogAlign:l="chat",children:p})=>{const{t:b}=me(),h=u.useRef(null),[x,S]=u.useState(!1),[y,E]=u.useState(!1),w=u.useRef(null),N=u.useRef(null),A=u.useRef(e);if(u.useEffect(()=>{A.current=e},[e]),typeof document<"u"&&!h.current&&(h.current=Ou()),u.useEffect(()=>{if(!n){S(!1);return}const C=window.setTimeout(()=>S(!0),mn);return()=>window.clearTimeout(C)},[n]),u.useEffect(()=>{if(!n){E(!1);return}const C=window.setTimeout(()=>E(!0),mn+Ts+80);return()=>window.clearTimeout(C)},[n]),u.useEffect(()=>{if(!n)return;const C=document.body.style.overflow;N.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow="hidden";const R=()=>{const D=w.current;if(!D)return;(D.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??D).focus({preventScroll:!0})},k=window.setTimeout(R,mn),z=D=>{if(D.key==="Escape"&&!o){A.current();return}if(D.key!=="Tab")return;const _=w.current;if(!_)return;const j=Array.from(_.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(O=>!O.hasAttribute("disabled")&&O.getAttribute("aria-hidden")!=="true");if(j.length===0){D.preventDefault(),_.focus({preventScroll:!0});return}const I=j[0],$=j[j.length-1],g=document.activeElement;D.shiftKey&&g===I?(D.preventDefault(),$.focus({preventScroll:!0})):!D.shiftKey&&g===$&&(D.preventDefault(),I.focus({preventScroll:!0}))};return document.addEventListener("keydown",z),()=>{window.clearTimeout(k),document.body.style.overflow=C,document.removeEventListener("keydown",z),N.current?.focus?.({preventScroll:!0}),N.current=null}},[o,n]),!n||!h.current)return null;const v=d==="dialog",P=t.jsxs("section",{ref:w,role:"dialog","aria-modal":"true","aria-label":f,tabIndex:-1,className:J("flex flex-col bg-background text-foreground",v?"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:v?{opacity:x?1:0,transform:x?"none":"scale(0.97)",transition:`opacity ${Ts}ms ease-out, transform ${Ts}ms cubic-bezier(0.32, 0.72, 0, 1)`}:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:x?"none":"translateX(100%)",transition:`transform ${Ts}ms cubic-bezier(0.32, 0.72, 0, 1)`},onTransitionEnd:C=>{x&&C.target===C.currentTarget&&C.propertyName==="transform"&&E(!0)},children:[a?null:t.jsxs("header",{className:J("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",!c&&"border-b border-border/70"),children:[t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":b("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(X,{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,i?typeof i=="string"?t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:i}):i:null]}),r?t.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:r}):null]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:y?t.jsx("div",{className:"h-full",style:{animation:"oc-surface-content-in 200ms ease-out"},children:p}):null}),t.jsx("style",{children:"@keyframes oc-surface-content-in { from { opacity: 0 } to { opacity: 1 } }"})]});return v?Lt.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:x?1:0,paddingLeft:l==="chat"?"max(1rem, var(--oc-chat-inset-left, 0px))":"1rem",paddingRight:l==="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:C=>C.stopPropagation(),children:P})}),h.current):Lt.createPortal(P,h.current)},Bu=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/,""),Lu=n=>{const e=le.c(36),{worktree:s,onDelete:i}=n,{t:r}=me();let o;e[0]!==s.path?(o={id:s.path},e[0]=s.path,e[1]=o):o=e[1];const{attributes:a,listeners:c,setNodeRef:f,transform:d,transition:l,isDragging:p}=Kn(o);let b;e[2]!==d?(b=Hn.Transform.toString(d),e[2]=d,e[3]=b):b=e[3];const h=p?10:1;let x;e[4]!==b||e[5]!==h||e[6]!==l?(x={transform:b,transition:l,zIndex:h},e[4]=b,e[5]=h,e[6]=l,e[7]=x):x=e[7];const S=x,y=s.branch||s.label||s.path,E=p&&"shadow-lg shadow-black/20";let w;e[8]!==E?(w=J("flex items-center gap-1 rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",E),e[8]=E,e[9]=w):w=e[9];let N;e[10]!==y||e[11]!==r?(N=r("mobile.projectEdit.dragWorktreeAria",{label:y}),e[10]=y,e[11]=r,e[12]=N):N=e[12];let A;e[13]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx(zn,{className:"size-4"}),e[13]=A):A=e[13];let v;e[14]!==a||e[15]!==c||e[16]!==N?(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":N,...a,...c,children:A}),e[14]=a,e[15]=c,e[16]=N,e[17]=v):v=e[17];let P;e[18]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx(X,{name:"node-tree",className:"size-4 shrink-0 text-muted-foreground"}),e[18]=P):P=e[18];let C;e[19]!==y?(C=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:y}),e[19]=y,e[20]=C):C=e[20];let R;e[21]!==y||e[22]!==r?(R=r("mobile.projectEdit.deleteWorktreeAria",{label:y}),e[21]=y,e[22]=r,e[23]=R):R=e[23];let k,z;e[24]===Symbol.for("react.memo_cache_sentinel")?(k={touchAction:"manipulation"},z=t.jsx(Bs,{className:"size-4"}),e[24]=k,e[25]=z):(k=e[24],z=e[25]);let D;e[26]!==i||e[27]!==R?(D=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":R,onClick:i,style:k,children:z}),e[26]=i,e[27]=R,e[28]=D):D=e[28];let _;return e[29]!==f||e[30]!==S||e[31]!==C||e[32]!==D||e[33]!==w||e[34]!==v?(_=t.jsxs("div",{ref:f,style:S,className:w,children:[v,P,C,D]}),e[29]=f,e[30]=S,e[31]=C,e[32]=D,e[33]=w,e[34]=v,e[35]=_):_=e[35],_},$u=({open:n,project:e,onClose:s,onWorktreesChanged:i})=>{const{t:r}=me(),{currentTheme:o}=fi(),a=We(g=>g.updateProjectMeta),c=We(g=>g.discoverProjectIcon),f=We(g=>g.removeProjectIcon),d=jn(g=>g.setWorktreeOrder),l=We(g=>e?g.projects.find(O=>O.id===e.id)?.iconImage??null:null),[p,b]=u.useState(""),[h,x]=u.useState(null),[S,y]=u.useState(null),[E,w]=u.useState(!1),[N,A]=u.useState([]),[v,P]=u.useState(null),C=e?.id??null;u.useEffect(()=>{!n||!e||(b(e.label),x(e.icon??null),y(e.color??null),A(e.worktrees))},[n,C]),u.useEffect(()=>{!n||!e||A(g=>{const O=e.worktrees.map(L=>L.path),V=g.map(L=>L.path);return O.length===V.length&&O.every(L=>V.includes(L))?g:e.worktrees})},[e?.worktrees]);const R=Bn(Ft($n,{activationConstraint:{distance:8}}),Ft(Ln,{coordinateGetter:Vn})),k=()=>{if(!e)return;const g=p.trim();a(e.id,{label:g||e.label,icon:h,color:S}),s()},z=()=>{!e||E||(w(!0),c(e.id).then(g=>{if(!g.ok){fe.error(g.error||r("projectEditDialog.toast.failedToDiscoverIcon"));return}if(g.skipped){fe.success(r("projectEditDialog.toast.customIconAlreadySet"));return}fe.success(r("projectEditDialog.toast.iconDiscovered"))}).finally(()=>w(!1)))},D=()=>{e&&f(e.id).then(g=>{if(!g.ok){fe.error(g.error||r("projectEditDialog.toast.failedToRemoveIcon"));return}fe.success(r("projectEditDialog.toast.iconRemoved"))})},_=g=>{const{active:O,over:V}=g;if(!V||O.id===V.id||!e)return;const B=N.findIndex(te=>te.path===O.id),L=N.findIndex(te=>te.path===V.id);if(B<0||L<0)return;const ie=[...N],[se]=ie.splice(B,1);ie.splice(L,0,se),A(ie),d(e.id,ie.map(te=>Bu(te.path)))},j=S?pi[S]??null:null,I=h?mi[h]:null,$=!!l;return t.jsxs(t.Fragment,{children:[t.jsx(Tt,{open:n,onClose:s,title:r("projectEditDialog.title"),ariaLabel:r("projectEditDialog.title"),noHeaderBorder:!0,trailing:t.jsxs(ge,{type:"button",variant:"default",size:"sm","aria-label":r("projectEditDialog.actions.save"),onClick:k,disabled:!p.trim(),style:{touchAction:"manipulation"},children:[t.jsx(ki,{className:"size-4"}),r("projectEditDialog.actions.save")]}),children:e?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:e.iconBackground?{backgroundColor:e.iconBackground}:void 0,children:$?t.jsx(hi,{project:{id:e.id,iconImage:l},options:{themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},className:"size-full object-contain",fallback:t.jsx(xn,{className:"size-7"})}):I?t.jsx(X,{name:I,className:"size-7",style:j?{color:j}:void 0}):t.jsx(xn,{className:"size-7",style:j?{color:j}: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:r("projectEditDialog.field.name")}),t.jsx(gi,{value:p,onChange:g=>b(g.target.value),placeholder:r("projectEditDialog.field.namePlaceholder"),className:"h-11"}),t.jsx("p",{className:"truncate typography-meta text-muted-foreground",title:e.path,children:e.path})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("projectEditDialog.field.color")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>y(null),"aria-label":r("projectEditDialog.option.none"),className:J("flex size-9 items-center justify-center rounded-xl border-2 transition-all",S===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"})}),Wo.map(g=>t.jsx("button",{type:"button",onClick:()=>y(g.key),"aria-label":g.label,title:g.label,className:J("size-9 rounded-xl border-2 transition-all",S===g.key?"border-foreground":"border-transparent hover:border-border/70"),style:{backgroundColor:g.cssVar,touchAction:"manipulation"}},g.key))]})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("projectEditDialog.field.icon")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>x(null),"aria-label":r("projectEditDialog.option.none"),className:J("flex size-9 items-center justify-center rounded-xl border-2 transition-all",h===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"})}),Vo.map(g=>t.jsx("button",{type:"button",onClick:()=>x(g.key),"aria-label":g.label,title:g.label,className:J("flex size-9 items-center justify-center rounded-xl border-2 transition-all",h===g.key?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx(X,{name:g.Icon,className:"size-4",style:j?{color:j}:void 0})},g.key))]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[t.jsx(ge,{size:"sm",variant:"outline",onClick:z,disabled:E,children:r(E?"projectEditDialog.actions.discovering":"projectEditDialog.actions.discoverFavicon")}),$?t.jsx(ge,{size:"sm",variant:"outline",onClick:D,children:r("projectEditDialog.actions.removeProjectIcon")}):null]})]}),e.isGitRepo?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("mobile.projectEdit.worktreesTitle")}),N.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:r("mobile.projectEdit.worktreesEmpty")}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:r("mobile.projectEdit.reorderHint")}),t.jsx(Fn,{sensors:R,collisionDetection:Wn,onDragEnd:_,children:t.jsx(Un,{items:N.map(g=>g.path),strategy:Gn,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:N.map(g=>t.jsx(Lu,{worktree:g,onDelete:()=>P(g)},g.path))})})})]})]}):null]}):null}),e?t.jsx(Ki,{open:!!v,project:{id:e.id,path:e.path},worktree:v,onClose:()=>P(null),onDeleted:()=>{A(g=>g.filter(O=>O.path!==v?.path)),i?.()}}):null]})},Fu=32,Wu=80,Vu=64,Uu=.7,sr=(n,e)=>{const s=u.useRef(e);s.current=e;const i=e.enabled??!0;u.useEffect(()=>{if(!i)return;const r=n.current;if(!r)return;const a=window.Capacitor?.getPlatform?.()==="android"?Wu:Fu,c=r.ownerDocument;let f=!1,d=!1,l=0,p=0;const b=()=>c.getSelection()?.isCollapsed===!1,h=()=>{f=!1},x=()=>{f&&b()&&h()},S=E=>{if(E.touches.length!==1||b()){f=!1;return}const w=E.touches[0],N=r.clientWidth,A=w.clientX<=a,v=w.clientX>=N-a;f=A||v,d=A,l=w.clientX,p=w.clientY},y=E=>{if(!f||(f=!1,b()))return;const w=E.changedTouches[0];if(!w)return;const N=w.clientX-l,A=w.clientY-p;Math.abs(N)<Vu||Math.abs(A)>Math.abs(N)*Uu||d&&N<=0||!d&&N>=0||(d?s.current.onLeftEdgeSwipe?.():s.current.onRightEdgeSwipe?.())};return r.addEventListener("touchstart",S,{passive:!0}),r.addEventListener("touchend",y,{passive:!0}),r.addEventListener("touchcancel",h,{passive:!0}),r.addEventListener("selectstart",h),c.addEventListener("selectionchange",x),()=>{r.removeEventListener("touchstart",S),r.removeEventListener("touchend",y),r.removeEventListener("touchcancel",h),r.removeEventListener("selectstart",h),c.removeEventListener("selectionchange",x)}},[i,n])},Gu=new Set,Ku=[["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"]],Hu=[["projects","mobile.sessions.viewMode.projects"],["timeline","mobile.sessions.viewMode.timeline"]],qu=7,Ju=3,Ds=40,Yu=12,Qu=16,Xu=(n,e)=>{const s=Me(n),i=Me(e),r=i.endsWith("/")?i:`${i}/`;return!!(s&&i&&(s===i||s.startsWith(r)))},pn=(n,e)=>n.worktrees.find(s=>Me(s.path)===e)??null,hn=(n,e,s)=>bi([n.title,n.id,kn(n),e],s),Zu=n=>{const e=le.c(2),{ariaLabel:s}=n;let i;return e[0]!==s?(i=t.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-primary","aria-label":s}),e[0]=s,e[1]=i):i=e[1],i},Wr=n=>{const e=le.c(12),{onClick:s,className:i}=n,{t:r}=me();let o;e[0]!==r?(o=r("sessions.sidebar.project.actions.newWorktree"),e[0]=r,e[1]=o):o=e[1];const a=o;let c;e[2]!==i?(c=J("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[2]=i,e[3]=c):c=e[3];let f;e[4]!==s?(f=b=>{b.stopPropagation(),s()},e[4]=s,e[5]=f):f=e[5];let d,l;e[6]===Symbol.for("react.memo_cache_sentinel")?(d={touchAction:"manipulation"},l=t.jsx(X,{name:"node-tree",className:"size-4"}),e[6]=d,e[7]=l):(d=e[6],l=e[7]);let p;return e[8]!==a||e[9]!==c||e[10]!==f?(p=t.jsx("button",{type:"button",className:c,"aria-label":a,title:a,onClick:f,style:d,children:l}),e[8]=a,e[9]=c,e[10]=f,e[11]=p):p=e[11],p},gn=n=>{const e=le.c(10),{label:s,onClick:i,className:r}=n;let o;e[0]!==r?(o=J("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[0]=r,e[1]=o):o=e[1];let a;e[2]!==i?(a=l=>{l.stopPropagation(),i()},e[2]=i,e[3]=a):a=e[3];let c,f;e[4]===Symbol.for("react.memo_cache_sentinel")?(c={touchAction:"manipulation"},f=t.jsx(X,{name:"add",className:"size-4"}),e[4]=c,e[5]=f):(c=e[4],f=e[5]);let d;return e[6]!==s||e[7]!==o||e[8]!==a?(d=t.jsx("button",{type:"button",className:o,"aria-label":s,title:s,onClick:a,style:c,children:f}),e[6]=s,e[7]=o,e[8]=a,e[9]=d):d=e[9],d},Vr=n=>{const e=le.c(66),{session:s,active:i,indent:r,contextLabel:o,statusOnRight:a,hasChildren:c,expanded:f,onToggleChildren:d,onSelect:l,revealed:p,onRevealedChange:b,confirmingDelete:h,onArchive:x,onRequestDelete:S,onConfirmDelete:y,renaming:E,onRequestRename:w,onSubmitRename:N,onCancelRename:A}=n,v=a===void 0?!1:a,P=c===void 0?!1:c,C=f===void 0?!1:f,R=p===void 0?!1:p,k=h===void 0?!1:h,z=E===void 0?!1:E,{t:D}=me();let _;e[0]!==s?(_=Qi(Yi(s)),e[0]=s,e[1]=_):_=e[1];const j=_;let I;e[2]!==s.title||e[3]!==D?(I=s.title?.trim()||D("mobile.sessions.untitled"),e[2]=s.title,e[3]=D,e[4]=I):I=e[4];const $=I,g=!!(b&&x),O=ji(s.id,s.directory,g&&R),V=En(s.id),B=Pn(s.id),L=!B&&V>0&&!i,ie=An(s.id,B),se=(B||L)&&ie;let te;e[5]!==O||e[6]!==C||e[7]!==P||e[8]!==r||e[9]!==B||e[10]!==d||e[11]!==L||e[12]!==v||e[13]!==D?(te=!v&&(O.pending||B||L||P&&d)?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:{left:Math.max(r-32,2),top:0,bottom:0,touchAction:"manipulation"},"aria-label":O.pending?D("sessions.aiRename.generating"):D(C?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),disabled:!P||!d,onClick:ue=>{ue.stopPropagation(),d?.()},children:O.pending?t.jsx(X,{name:"loader-4",className:"size-3 animate-spin text-primary","aria-label":D("sessions.aiRename.generating")}):B||L?t.jsx(Os,{state:B?"running":"unread",label:D(B?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread")}):t.jsx(On,{className:J("size-[18px] transition-transform duration-150",C?"rotate-0":"-rotate-90")})}):null,e[5]=O,e[6]=C,e[7]=P,e[8]=r,e[9]=B,e[10]=d,e[11]=L,e[12]=v,e[13]=D,e[14]=te):te=e[14];let M;e[15]!==i||e[16]!==O||e[17]!==o||e[18]!==r||e[19]!==B||e[20]!==A||e[21]!==b||e[22]!==l||e[23]!==N||e[24]!==z||e[25]!==R||e[26]!==s.id||e[27]!==se||e[28]!==L||e[29]!==v||e[30]!==D||e[31]!==j||e[32]!==$?(M=z&&N&&A?t.jsx(Hi,{initialTitle:$,indent:r,onSubmit:N,onCancel:A}):t.jsx("button",{type:"button",className:J("flex min-w-0 flex-1 items-center gap-2.5 pr-3.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",o?"min-h-10 py-1":"h-9"),style:{paddingLeft:r,touchAction:"manipulation"},onClick:()=>{if(R){b?.(!1);return}l()},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",{className:J("block min-w-0 flex-1 truncate typography-ui-label",i?"text-primary":"text-foreground"),children:$}),v&&(O.pending||B||L)?O.pending?t.jsx(X,{name:"loader-4",className:"size-3 shrink-0 animate-spin text-primary","aria-label":D("sessions.aiRename.generating")}):t.jsx(Os,{state:B?"running":"unread",label:D(B?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread")}):null,se?t.jsx(Mn,{sessionId:s.id,running:B,className:"typography-micro"}):j?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:j}):null]}),o?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:o}):null]})}),e[15]=i,e[16]=O,e[17]=o,e[18]=r,e[19]=B,e[20]=A,e[21]=b,e[22]=l,e[23]=N,e[24]=z,e[25]=R,e[26]=s.id,e[27]=se,e[28]=L,e[29]=v,e[30]=D,e[31]=j,e[32]=$,e[33]=M):M=e[33];let G;e[34]!==M||e[35]!==te?(G=t.jsxs(t.Fragment,{children:[te,M]}),e[34]=M,e[35]=te,e[36]=G):G=e[36];const Y=G;if(!g){const ue=i||void 0,K=i&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let oe;e[37]!==K?(oe=J("relative flex items-center gap-1 transition-colors",K),e[37]=K,e[38]=oe):oe=e[38];let pe;e[39]!==Y||e[40]!==oe?(pe=t.jsx("div",{className:oe,children:Y}),e[39]=Y,e[40]=oe,e[41]=pe):pe=e[41];let ke;return e[42]!==ue||e[43]!==pe?(ke=t.jsx("div",{"data-active-session":ue,className:"relative overflow-hidden",children:pe}),e[42]=ue,e[43]=pe,e[44]=ke):ke=e[44],ke}let H;e[45]!==b?(H=ue=>b?.(ue),e[45]=b,e[46]=H):H=e[46];const Q=i&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let ne;e[47]!==Q?(ne=J("relative flex w-full items-center gap-1 bg-background transition-colors",Q),e[47]=Q,e[48]=ne):ne=e[48];let re;e[49]!==O||e[50]!==k||e[51]!==x||e[52]!==y||e[53]!==S||e[54]!==w||e[55]!==b||e[56]!==R||e[57]!==$?(re=t.jsx(Ji,{title:$,revealed:R,confirmingDelete:k,aiRename:O,onArchive:x,onRequestDelete:S,onConfirmDelete:y,onRequestRename:w,onRevealedChange:b}),e[49]=O,e[50]=k,e[51]=x,e[52]=y,e[53]=S,e[54]=w,e[55]=b,e[56]=R,e[57]=$,e[58]=re):re=e[58];let ce;return e[59]!==i||e[60]!==R||e[61]!==Y||e[62]!==H||e[63]!==ne||e[64]!==re?(ce=t.jsx(Gs,{actionsWidth:qi,revealed:R,onRevealedChange:H,dataActiveSession:i,contentClassName:ne,actions:re,children:Y}),e[59]=i,e[60]=R,e[61]=Y,e[62]=H,e[63]=ne,e[64]=re,e[65]=ce):ce=e[65],ce},ed=n=>{const e=le.c(11),{indent:s,onClick:i}=n,{t:r}=me();let o;e[0]!==s?(o={paddingLeft:s,touchAction:"manipulation"},e[0]=s,e[1]=o):o=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(On,{className:"size-4"}),e[2]=a):a=e[2];let c;e[3]!==r?(c=r("sessions.sidebar.group.showMore"),e[3]=r,e[4]=c):c=e[4];let f;e[5]!==c?(f=t.jsx("span",{className:"typography-micro",children:c}),e[5]=c,e[6]=f):f=e[6];let d;return e[7]!==i||e[8]!==o||e[9]!==f?(d=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pr-3 text-left 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:o,onClick:i,children:[a,f]}),e[7]=i,e[8]=o,e[9]=f,e[10]=d):d=e[10],d},td=n=>{const e=le.c(11),{indent:s,onClick:i}=n,{t:r}=me();let o;e[0]!==s?(o={paddingLeft:s,touchAction:"manipulation"},e[0]=s,e[1]=o):o=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(Fl,{className:"size-4"}),e[2]=a):a=e[2];let c;e[3]!==r?(c=r("sessions.sidebar.group.showFewer"),e[3]=r,e[4]=c):c=e[4];let f;e[5]!==c?(f=t.jsx("span",{className:"typography-micro",children:c}),e[5]=c,e[6]=f):f=e[6];let d;return e[7]!==i||e[8]!==o||e[9]!==f?(d=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pr-3 text-left 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:o,onClick:i,children:[a,f]}),e[7]=i,e[8]=o,e[9]=f,e[10]=d):d=e[10],d},sd=n=>{const e=le.c(29),{worktree:s}=n,{t:i}=me();let r;e[0]!==s.path?(r=Me(s.path),e[0]=s.path,e[1]=r):r=e[1];const o=r;let a;e[2]!==o?(a={id:o},e[2]=o,e[3]=a):a=e[3];const{attributes:c,listeners:f,setNodeRef:d,transform:l,transition:p,isDragging:b}=Kn(a),h=s.branch||s.label||s.path;let x;e[4]!==l?(x=Hn.Transform.toString(l),e[4]=l,e[5]=x):x=e[5];const S=b?10:1;let y;e[6]!==x||e[7]!==S||e[8]!==p?(y={transform:x,transition:p,zIndex:S},e[6]=x,e[7]=S,e[8]=p,e[9]=y):y=e[9];const E=b&&"shadow-lg shadow-black/20";let w;e[10]!==E?(w=J("flex items-center gap-1 rounded-xl bg-background px-1 py-1",E),e[10]=E,e[11]=w):w=e[11];let N;e[12]!==h||e[13]!==i?(N=i("mobile.sessions.dragHandleAria",{label:h}),e[12]=h,e[13]=i,e[14]=N):N=e[14];let A;e[15]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx(zn,{className:"size-4"}),e[15]=A):A=e[15];let v;e[16]!==c||e[17]!==f||e[18]!==N?(v=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":N,...c,...f,children:A}),e[16]=c,e[17]=f,e[18]=N,e[19]=v):v=e[19];let P;e[20]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx(X,{name:"git-branch",className:"size-4 shrink-0 text-muted-foreground"}),e[20]=P):P=e[20];let C;e[21]!==h?(C=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-bold text-muted-foreground",children:h}),e[21]=h,e[22]=C):C=e[22];let R;return e[23]!==d||e[24]!==v||e[25]!==C||e[26]!==y||e[27]!==w?(R=t.jsxs("div",{ref:d,style:y,className:w,children:[v,P,C]}),e[23]=d,e[24]=v,e[25]=C,e[26]=y,e[27]=w,e[28]=R):R=e[28],R},nd=n=>{const e=le.c(61),{project:s,totalSessions:i,expanded:r,onToggleExpanded:o,onReorderWorktrees:a}=n,{t:c}=me();let f;e[0]!==s.id?(f={id:s.id},e[0]=s.id,e[1]=f):f=e[1];const{attributes:d,listeners:l,setNodeRef:p,transform:b,transition:h,isDragging:x}=Kn(f);let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S={activationConstraint:{distance:8}},e[2]=S):S=e[2];let y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y={coordinateGetter:Vn},e[3]=y):y=e[3];const E=Bn(Ft($n,S),Ft(Ln,y)),w=s.worktrees.length>0;let N;e[4]!==a||e[5]!==s.worktrees?(N=M=>{const{active:G,over:Y}=M;if(!Y||G.id===Y.id)return;const H=s.worktrees.map(ad),Q=H.indexOf(String(G.id)),ne=H.indexOf(String(Y.id));if(Q<0||ne<0)return;const re=[...H],[ce]=re.splice(Q,1);re.splice(ne,0,ce),a(re)},e[4]=a,e[5]=s.worktrees,e[6]=N):N=e[6];const A=N;let v;e[7]!==b?(v=Hn.Transform.toString(b),e[7]=b,e[8]=v):v=e[8];const P=x?10:1;let C;e[9]!==v||e[10]!==P||e[11]!==h?(C={transform:v,transition:h,zIndex:P},e[9]=v,e[10]=P,e[11]=h,e[12]=C):C=e[12];const R=x&&"shadow-lg shadow-black/20";let k;e[13]!==R?(k=J("rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",R),e[13]=R,e[14]=k):k=e[14];let z;e[15]!==s.label||e[16]!==c?(z=c("mobile.sessions.dragHandleAria",{label:s.label}),e[15]=s.label,e[16]=c,e[17]=z):z=e[17];let D;e[18]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx(zn,{className:"size-4"}),e[18]=D):D=e[18];let _;e[19]!==d||e[20]!==l||e[21]!==z?(_=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":z,...d,...l,children:D}),e[19]=d,e[20]=l,e[21]=z,e[22]=_):_=e[22];let j;e[23]!==r||e[24]!==s.label||e[25]!==c?(j=r?c("sessions.sidebar.group.collapseAria",{label:s.label}):c("sessions.sidebar.group.expandAria",{label:s.label}),e[23]=r,e[24]=s.label,e[25]=c,e[26]=j):j=e[26];const I=!w;let $;e[27]===Symbol.for("react.memo_cache_sentinel")?($={touchAction:"manipulation"},e[27]=$):$=e[27];let g;e[28]!==s?(g=t.jsx(Us,{project:s}),e[28]=s,e[29]=g):g=e[29];let O;e[30]!==s.label?(O=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]=O):O=e[31];let V;e[32]!==i?(V=t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:i}),e[32]=i,e[33]=V):V=e[33];let B;e[34]!==r||e[35]!==w?(B=w?t.jsx(On,{className:J("size-4 shrink-0 text-muted-foreground transition-transform",r&&"rotate-180")}):null,e[34]=r,e[35]=w,e[36]=B):B=e[36];let L;e[37]!==r||e[38]!==o||e[39]!==j||e[40]!==I||e[41]!==g||e[42]!==O||e[43]!==V||e[44]!==B?(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-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:o,"aria-expanded":r,"aria-label":j,disabled:I,style:$,children:[g,O,V,B]}),e[37]=r,e[38]=o,e[39]=j,e[40]=I,e[41]=g,e[42]=O,e[43]=V,e[44]=B,e[45]=L):L=e[45];let ie;e[46]!==_||e[47]!==L?(ie=t.jsxs("div",{className:"flex items-center gap-1",children:[_,L]}),e[46]=_,e[47]=L,e[48]=ie):ie=e[48];let se;e[49]!==r||e[50]!==A||e[51]!==w||e[52]!==s.worktrees||e[53]!==E?(se=r&&w?t.jsx(Fn,{sensors:E,collisionDetection:Wn,onDragEnd:A,children:t.jsx(Un,{items:s.worktrees.map(ld),strategy:Gn,children:t.jsx("div",{className:"mt-1 flex flex-col gap-0.5 pl-3",children:s.worktrees.map(cd)})})}):null,e[49]=r,e[50]=A,e[51]=w,e[52]=s.worktrees,e[53]=E,e[54]=se):se=e[54];let te;return e[55]!==p||e[56]!==ie||e[57]!==se||e[58]!==C||e[59]!==k?(te=t.jsxs("div",{ref:p,style:C,className:k,children:[ie,se]}),e[55]=p,e[56]=ie,e[57]=se,e[58]=C,e[59]=k,e[60]=te):te=e[60],te},Ur=({open:n,onOpenChange:e,variant:s="drawer",footer:i})=>{const{t:r}=me(),{git:o}=Tn(),a=Fe(m=>m.ensureStatus),c=ui(),f=Nn(m=>m.activeSessions),d=n||s==="sidebar",l=u.useRef(Gu),p=ai(u.useCallback(m=>(d&&(l.current=m.ids),l.current),[d])),b=u.useRef(Uo),h=li(u.useCallback(m=>(d&&(b.current=m.rankById),b.current),[d])),x=We(m=>m.projects),S=Go(m=>m.projects),y=We(m=>m.activeProjectId),E=ht(m=>m.currentDirectory),w=Se(m=>m.currentSessionId),N=Se(m=>m.setCurrentSession),A=Se(m=>m.archiveSession),v=Se(m=>m.archiveSessions),P=Se(m=>m.deleteSession),C=Se(m=>m.deleteSessions),R=Se(m=>m.updateSessionTitle),k=Se(m=>m.openNewSessionDraft),z=We(m=>m.setActiveProject),D=We(m=>m.setActiveProjectIdOnly),_=We(m=>m.reorderProjects),j=We(m=>m.manualProjectOrder),I=Rs(m=>m.projectSortOrder),$=Rs(m=>m.setProjectSortOrder),g=Rs(m=>m.sidebarViewMode),O=Rs(m=>m.setSidebarViewMode),V=Ko(d&&g==="timeline"),B=We(m=>m.removeProject),L=Is(m=>m.projectExpanded),ie=Is(m=>m.worktreeExpanded),se=Is(m=>m.setProjectExpanded),te=Is(m=>m.setWorktreeExpanded),M=jn(m=>m.orderByProject),G=jn(m=>m.setWorktreeOrder),Y=Br(m=>m.expandedParents),H=Br(m=>m.toggleParent),[Q,ne]=u.useState(""),[re,ce]=u.useState(null),[ue,K]=u.useState(null),[oe,pe]=u.useState(null),[ke,q]=u.useState(null),[de,Ce]=u.useState(null),[ze,Ae]=u.useState(null),[Je,Xe]=u.useState(null),[ut,De]=u.useState(0),[Be,Ne]=u.useState(!1),[ps,Nt]=u.useState(!1),[hs,Ht]=u.useState(!1),[Js,Ue]=u.useState(null),[$e,dt]=u.useState(()=>new Map(Se.getState().availableWorktreesByProject)),[nt,ft]=u.useState(()=>{const m=new Set;for(const[W,U]of Se.getState().availableWorktreesByProject)U.length>0&&m.add(W);return m}),[Le,bt]=u.useState(!1),[je,Ct]=u.useState(new Set),[qt,Ye]=u.useState(new Map),[Ys,Jt]=u.useState(zs),gs=u.useRef(null);u.useEffect(()=>{if(!n){ne(""),bt(!1),Ct(new Set),Ye(new Map),Jt(zs),ce(null),K(null),pe(null),q(null),Ce(null),Ae(null);return}In(c)},[n]),u.useEffect(()=>{Le||Ct(new Set)},[Le]),u.useEffect(()=>{Jt(zs)},[g]),u.useEffect(()=>{if(!n||x.length===0)return;let m=!1;return(async()=>{const U=await Promise.all(x.map(async he=>{const be=Me(he.path);if(!be)return null;const Ie=await o.checkIsGitRepository(be).catch(()=>!1),tt=Ie?await xi({id:he.id,path:be}).catch(()=>[]):[];return[be,tt,Ie]}));if(m)return;const ee=new Map,ae=new Set;for(const he of U)he&&(ee.set(he[0],he[1]),he[2]&&ae.add(he[0]));dt(yi(x,ee)),ft(ae)})(),()=>{m=!0}},[o,n,x,ut]);const ye=u.useMemo(()=>rl(x.map(m=>({id:m.id,label:m.label?.trim()||fn(m.path),path:Me(m.path),icon:m.icon,color:m.color,iconImage:m.iconImage,iconBackground:m.iconBackground,isGitRepo:nt.has(Me(m.path)),worktrees:Eu(M[m.id],$e.get(Me(m.path))??[]),addedAt:m.addedAt,lastOpenedAt:m.lastOpenedAt})),I,j),[nt,j,I,x,M,$e]),Qe=u.useMemo(()=>{const m=new Map(c.map(ee=>[ee.id,ee])),W=f.map(ee=>{const ae=m.get(ee.id);return ae?Ho(ae,ee):ee}),U=new Set(W.map(ee=>ee.id));for(const ee of c)U.has(ee.id)||W.push(ee);return W.filter(ee=>!ee.time?.archived)},[f,c]),Ge=u.useMemo(()=>{const m=new Map;for(const W of Qe){const U=pt(W);if(!U)continue;const ee=m.get(U)??[];ee.push(W),m.set(U,ee)}return m},[Qe]),{projectSessions:Re,chatSessions:ot}=u.useMemo(()=>il(Qe,!1),[Qe]),Oe=u.useMemo(()=>ol(Re,ye.map(m=>({id:m.id,normalizedPath:m.path})),new Map(ye.map(m=>[m.path,m.worktrees])),!1,[],S),[S,Re,ye]),bs=u.useMemo(()=>({key:ss,label:"",path:"",worktree:null,sessions:Ps(ot,p,h)}),[ot,p,h]),Qs=`${ss}::${ss}`,_e=u.useMemo(()=>ot.filter(m=>!pt(m)).length,[ot]),Ee=Q.trim().toLowerCase(),xs=u.useRef(null);u.useEffect(()=>{if(!n)return;const m=window.requestAnimationFrame(()=>{const W=xs.current;if(!W)return;(W.querySelector('[data-active-session="true"]')??W.querySelector('[data-active-project="true"]'))?.scrollIntoView({block:"center"})});return()=>window.cancelAnimationFrame(m)},[n]);const at=u.useMemo(()=>{const m=ye.map(U=>({project:U,buckets:[],totalSessions:0,isActive:U.id===y})),W=(U,ee,ae)=>{const he=Me(ee)||U.project.path,be=he||"__root__";let Ie=U.buckets.find(tt=>tt.key===be);return Ie||(Ie={key:be,label:ae?.branch||fn(he),path:he,worktree:ae,sessions:[]},U.buckets.push(Ie)),Ie};for(const U of m){W(U,U.project.path,null);for(const ee of U.project.worktrees)W(U,ee.path,ee)}for(const U of Re){const ee=Oe.bySessionId.get(U.id);if(!ee)continue;const ae=m.find(Ie=>Ie.project.id===ee.projectId);if(!ae)continue;const he=pn(ae.project,ee.scopeDirectory);(he?W(ae,he.path,he):W(ae,ae.project.path,null)).sessions.push(U)}for(const U of m)for(const ee of U.buckets){ee.sessions=Ps(ee.sessions,p,h);for(const ae of ee.sessions)pt(ae)||(U.totalSessions+=1)}return m},[y,p,Re,ye,h,Oe]),ys=Me(E),Xs=m=>m.isActive?ys===m.project.path?m.project.path:m.project.worktrees.find(U=>Xu(ys,U.path))?.path??m.project.path:null,Rt=m=>L[m.project.id]??!0,vs=(m,W)=>ie[`${m.project.id}::${W.key}`]??!0,mt=m=>{Ye(W=>{if(!W.has(m))return W;const U=new Map(W);return U.delete(m),U})},Yt=m=>{Ye(W=>{let U=!1;const ee=new Map(W),ae=`${m}::`;for(const he of ee.keys())he.startsWith(ae)&&(ee.delete(he),U=!0);return U?ee:W})},Qt=(m,W,U)=>{Ye(ee=>{const ae=new Map(ee);return ae.set(m,W+U),ae})},Et=(m,W,U,ee)=>{const ae=ee?.pageSize??qu,he=ee?.alwaysVisibleIds,be=new Set(W.sessions.map(ve=>ve.id)),Ie=new Map;for(const ve of W.sessions){const rt=pt(ve);if(rt&&be.has(rt)){const es=Ie.get(rt)??[];es.push(ve),Ie.set(rt,es)}}const tt=W.sessions.filter(ve=>{const rt=pt(ve);return!rt||!be.has(rt)}),rn=he?tt.filter(ve=>he.has(ve.id)):[],on=he?tt.filter(ve=>!he.has(ve.id)):tt,co=qt.get(m)??ae,an=on.slice(0,co),uo=[...rn,...an],ur=on.length-an.length,fo=on.length>ae&&ur===0,dr=(ve,rt)=>{const es=Ie.get(ve.id)??[],ln=es.length>0,fr=!!Y[ve.id];return t.jsxs(u.Fragment,{children:[t.jsx(Vr,{session:ve,active:w===ve.id,indent:rt,hasChildren:ln,expanded:fr,onToggleChildren:ln?()=>H(ve.id):void 0,onSelect:()=>Pt(ve),statusOnRight:ee?.statusOnRight,revealed:ue===ve.id,onRevealedChange:ts=>js(ve.id,ts),confirmingDelete:oe===ve.id,onArchive:()=>{Zt(ve)},onRequestDelete:()=>pe(ve.id),onConfirmDelete:()=>{ks(ve)},renaming:ke===ve.id,onRequestRename:()=>T(ve.id),onSubmitRename:ts=>{F(ve.id,ts)},onCancelRename:()=>q(null)}),ln&&fr?es.map(ts=>dr(ts,rt+Qu)):null]},ve.id)};return t.jsxs("div",{children:[uo.map(ve=>dr(ve,U)),ur>0?t.jsx(ed,{indent:U,onClick:()=>Qt(m,an.length,ae)}):null,fo?t.jsx(td,{indent:U,onClick:()=>mt(m)}):null]})},ws=(m,W)=>{se(m,!W),Yt(m)},Zs=(m,W,U)=>{te(`${m}::${W}`,!U),mt(`${m}::${W}`)},Pt=m=>{const W=kn(m)||null,U=Oe.bySessionId.get(m.id),ee=U?ye.find(ae=>ae.id===U.projectId)??null:null;if(ee){D(ee.id),se(ee.id,!0);const ae=pn(ee,U?.scopeDirectory??"");ae&&te(`${ee.id}::${Me(ae.path)}`,!0)}N(m.id,W),e(!1)},js=(m,W)=>{K(W?m:null),pe(null),Ce(null),Ae(null)},lt=(m,W)=>{Ce(W?m:null),Ae(null),K(null),pe(null)},Xt=(m,W)=>(K(null),pe(null),dl(m,W,fl(W.id,ml(Ge,W.id),m==="delete"),{archiveSession:A,archiveSessions:v,deleteSession:P,deleteSessions:C},r)),Zt=m=>Xt("archive",m),ks=m=>Xt("delete",m),T=m=>{K(null),pe(null),q(m)},F=async(m,W)=>{q(null);try{await R(m,W)}catch{fe.error(r("mobile.sessions.renameError"))}},Z=()=>{k(),e(!1)},we=m=>{Ue(m),D(m),Ht(!0)},Ze=Bn(Ft($n,{activationConstraint:{distance:8}}),Ft(Ln,{coordinateGetter:Vn})),en=m=>{$(m),pr({sidebarProjectSortOrder:m}),m!=="manual"&&bt(!1)},At=m=>{O(m),pr({sidebarViewMode:m}),m==="timeline"&&bt(!1)},tn=m=>{const{active:W,over:U}=m;if(!U||W.id===U.id)return;const ee=ye.findIndex(he=>he.id===W.id),ae=ye.findIndex(he=>he.id===U.id);ee<0||ae<0||_(ee,ae)},to=m=>{Ct(W=>{const U=new Set(W);return U.has(m)?U.delete(m):U.add(m),U})},so=u.useCallback(m=>{const W=kn(m);if(qo(W))return r("mobile.sessions.section.chats");const U=Oe.bySessionId.get(m.id),ee=U?ye.find(he=>he.id===U.projectId)??null:null;if(!ee)return fn(W)||W;const ae=pn(ee,U?.scopeDirectory??"");return ae?.branch?`${ee.label} · ${ae.branch}`:ee.label},[ye,Oe,r]),no=m=>{z(m.id),e(!1)},rr=m=>{D(m.id),k({selectedProjectId:m.id,directoryOverride:m.path}),e(!1)},ro=u.useMemo(()=>Ee?at.filter(m=>bi([m.project.label,m.project.path],Ee)?!0:m.buckets.some(W=>W.sessions.some(U=>hn(U,m.project.label,Ee)))):at,[Ee,at]),Ss=u.useMemo(()=>Ee?Ps(Qe.filter(m=>{if(pt(m))return!1;const W=Oe.bySessionId.get(m.id),U=W?ye.find(ee=>ee.id===W.projectId)??null:null;return hn(m,U?.label??"",Ee)}),p,h):[],[Ee,p,ye,h,Oe,Qe]),Ns=u.useMemo(()=>Ee?Jo(ye,Ee,m=>[m.label,m.path]):[],[Ee,ye]),et=g==="timeline"&&!Ee&&!Le;u.useEffect(()=>{if(!(!et||!o))for(const m of ye){const W=Me(m.path);W&&Yo(()=>a(W,o))}},[a,o,ye,et]);const sn=u.useMemo(()=>{const m=new Map;if(!et)return m;const W=al({sessions:Re,projects:ye.map(U=>({id:U.id,normalizedPath:U.path,label:U.label})),ownerBySessionId:Oe.bySessionId,availableWorktreesByProject:new Map(ye.map(U=>[U.path,U.worktrees])),gitBranches:V,homeDirectory:null,hideBranchMatchingProjectLabel:!1});for(const U of Re){if(pt(U))continue;const ee=W.get(U.id),ae=ee?ye.find(he=>he.id===ee.projectId):null;!ae||!ee||m.set(U.id,{project:ae,branch:ee.branchLabel})}return m},[V,Re,ye,Oe,et]),nn=u.useMemo(()=>{if(!et)return[];const m=Re.filter(W=>!pt(W)&&sn.has(W.id));return Ps(m,p,h).flatMap(W=>{const U=sn.get(W.id);return U?[{session:W,project:U.project,branch:U.branch}]:[]})},[p,Re,h,et,sn]),io=u.useCallback(()=>{Jt(m=>zu(m,nn.length))},[nn.length]),oo={currentSessionId:w,revealedSessionId:ue,confirmingDeleteSessionId:oe,renamingSessionId:ke,onSelect:Pt,onRevealedChange:js,onArchive:m=>{Zt(m)},onRequestDelete:pe,onConfirmDelete:m=>{ks(m)},onRequestRename:T,onSubmitRename:(m,W)=>{F(m,W)},onCancelRename:()=>q(null)},ao=Ee&&Ss.length===0&&Ns.length===0,lo=!Ee&&!et&&ye.length>1&&I==="manual",ir=!Le&&!Ee&&ye.length>0?t.jsx(ge,{type:"button",variant:"chip",size:"sm","aria-label":r("sessions.sidebar.header.displayMode.label"),title:r("sessions.sidebar.header.displayMode.label"),onClick:()=>Ne(!0),style:{touchAction:"manipulation"},children:t.jsx(X,{name:"equalizer-2",className:"size-4"})}):null,or=lo?t.jsx(ge,{type:"button",variant:"chip",size:"sm","aria-label":r(Le?"mobile.sessions.doneEditing":"mobile.sessions.editOrder"),"aria-pressed":Le,onClick:()=>bt(m=>!m),style:{touchAction:"manipulation"},children:Le?t.jsx(ki,{className:"size-4"}):t.jsx(yn,{className:"size-4"})}):null,ar=!Le&&ye.length>0?t.jsxs(ge,{type:"button",variant:"default",size:"sm","aria-label":r("mobile.sessions.newChat"),onClick:Z,style:{touchAction:"manipulation"},children:[t.jsx($l,{className:"size-4"}),r("mobile.sessions.newChat")]}):null,lr=Le?null:t.jsx(ge,{type:"button",variant:"chip",size:"sm","aria-label":r("sessions.sidebar.header.actions.addProject"),title:r("sessions.sidebar.header.actions.addProject"),onClick:()=>Nt(!0),style:{touchAction:"manipulation"},children:t.jsx(jr,{className:"size-4"})}),Cs=ar||lr||ir||or?t.jsxs(t.Fragment,{children:[lr,ir,or,ar]}):null,cr=t.jsxs("div",{ref:xs,className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs(Ks,{ref:gs,className:"min-h-0 flex-1 overflow-y-auto pb-4",children:[t.jsx("div",{className:J("px-4 pb-2 pt-1",Le&&"hidden"),children:t.jsx(ll,{value:Q,onSearch:ne,active:n||s==="sidebar",mobile:!0,placeholder:r("mobile.sessions.search.placeholder"),clearLabel:r("mobile.sessions.clearSearchAria")})}),ye.length===0&&ot.length===0?t.jsx(Hr,{title:r("mobile.sessions.empty.noProjectsTitle"),description:r("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:()=>Nt(!0),children:[t.jsx(jr,{className:"size-4"}),r("sessions.sidebar.header.actions.addProject")]})}):ao?t.jsx(Hr,{title:r("mobile.sessions.empty.searchTitle"),description:r("mobile.sessions.empty.searchDescription")}):Ee&&!Le?t.jsxs("div",{className:"flex flex-col gap-3 px-3 pt-2",children:[Ss.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:r("mobile.sessions.search.section.sessions")}),t.jsx("span",{className:"typography-micro text-muted-foreground tabular-nums",children:Ss.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:Ss.map((m,W)=>t.jsx("div",{className:J(W>0&&"border-t border-border/70"),children:t.jsx(Vr,{session:m,active:w===m.id,indent:12,contextLabel:so(m),onSelect:()=>Pt(m)})},m.id))})]}):null,Ns.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:r("mobile.sessions.search.section.projects")}),t.jsx("span",{className:"typography-micro text-muted-foreground tabular-nums",children:Ns.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:Ns.map((m,W)=>t.jsxs("div",{className:J("flex items-center",W>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-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>no(m),style:{touchAction:"manipulation"},children:[t.jsx(Us,{project:m}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:m.label})]}),m.isGitRepo?t.jsx(Wr,{onClick:()=>we(m.id)}):null,t.jsx(gn,{className:"mr-2",label:r("mobile.sessions.newSessionInProjectAria",{label:m.label}),onClick:()=>rr(m)})]},m.id))})]}):null]}):Le?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:r("mobile.sessions.editOrderHint")}),t.jsx(Fn,{sensors:Ze,collisionDetection:Wn,onDragEnd:tn,children:t.jsx(Un,{items:ye.map(m=>m.id),strategy:Gn,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:ye.map(m=>{const W=at.find(U=>U.project.id===m.id);return t.jsx(nd,{project:m,totalSessions:W?.totalSessions??0,expanded:je.has(m.id),onToggleExpanded:()=>to(m.id),onReorderWorktrees:U=>G(m.id,U)},m.id)})})})})]}):t.jsxs("div",{className:"flex flex-col",children:[(()=>{const m=L[ss]??!0,W=r("mobile.sessions.section.chats");return t.jsxs("section",{children:[t.jsxs("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-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(de){lt(de,!1);return}ws(ss,m)},"aria-expanded":m,"aria-label":m?r("sessions.sidebar.group.collapseAria",{label:W}):r("sessions.sidebar.group.expandAria",{label:W}),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-[var(--surface-muted)] text-muted-foreground",children:t.jsx(X,{name:"chat-4",className:"size-4"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:W}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:_e})]}),Le?null:t.jsx(gn,{className:"mr-2",label:r("mobile.sessions.newChat"),onClick:Z})]}),m?t.jsx("div",{className:"pb-2",children:bs.sessions.length>0?Et(Qs,bs,et?Yu:Ds,et?{pageSize:Ju,alwaysVisibleIds:p,statusOnRight:!0}:void 0):t.jsx("p",{className:"px-3 pb-1 typography-micro text-muted-foreground",style:{paddingLeft:Ds},children:r("sessions.sidebar.activity.chatsEmpty")})}):null]})})(),et?t.jsx(_u,{entries:nn,visibleCount:Ys,onRevealMore:io,scrollRootRef:gs,handlers:oo}):null,et?null:ro.map(m=>{const W=Rt(m),U=Ee?m.buckets.filter(ae=>ae.sessions.some(he=>hn(he,m.project.label,Ee))):m.buckets,ee=Xs(m);return t.jsxs("section",{className:"border-t border-border/70",children:[t.jsx(Gs,{actionsWidth:96,revealed:de===`project:${m.project.id}`,onRevealedChange:ae=>lt(`project:${m.project.id}`,ae),actions:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:de===`project:${m.project.id}`?0:-1,className:J("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",ze===m.project.id?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80"),"aria-label":ze===m.project.id?r("mobile.sessions.confirmRemoveProjectAria",{label:m.project.label}):r("mobile.sessions.removeProjectAria",{label:m.project.label}),onClick:()=>{if(ze===m.project.id){Ce(null),Ae(null),B(m.project.id),fe.success(r("mobile.sessions.toast.projectRemoved",{label:m.project.label}));return}Ae(m.project.id)},style:{touchAction:"manipulation"},children:t.jsx(Bs,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:de===`project:${m.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":r("mobile.sessions.editProjectAria",{label:m.project.label}),onClick:()=>{Ce(null),ce(m.project.id)},style:{touchAction:"manipulation"},children:t.jsx(yn,{className:"size-[18px]"})})]}),children:t.jsxs("div",{"data-active-project":m.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-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(de){lt(de,!1);return}ws(m.project.id,W)},"aria-expanded":W,"aria-label":W?r("sessions.sidebar.group.collapseAria",{label:m.project.label}):r("sessions.sidebar.group.expandAria",{label:m.project.label}),style:{touchAction:"manipulation"},children:[t.jsx(Us,{project:m.project}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:m.project.label})]}),m.project.isGitRepo?t.jsx(Wr,{onClick:()=>we(m.project.id)}):null,t.jsx(gn,{className:"mr-2",label:r("mobile.sessions.newSessionInProjectAria",{label:m.project.label}),onClick:()=>rr(m.project)})]})}),W?t.jsx("div",{className:"pb-2",children:(()=>{const ae=U.find(be=>be.worktree===null),he=U.filter(be=>be.worktree!==null);return t.jsxs(t.Fragment,{children:[ae&&ae.sessions.length>0?Et(`${m.project.id}::${ae.key}`,ae,Ds):null,he.map(be=>{const Ie=vs(m,be),tt=ee===be.path;return t.jsxs("div",{children:[t.jsx(Gs,{actionsWidth:48,revealed:de===`wt:${be.key}`,onRevealedChange:rn=>lt(`wt:${be.key}`,rn),actions:t.jsx("button",{type:"button",tabIndex:de===`wt:${be.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":r("mobile.projectEdit.deleteWorktreeAria",{label:be.label}),onClick:()=>{Ce(null),be.worktree&&Xe({project:m.project,worktree:be.worktree})},style:{touchAction:"manipulation"},children:t.jsx(Bs,{className:"size-[18px]"})}),children:t.jsxs("button",{type:"button",className:"flex min-h-10 w-full items-center gap-2 px-3 py-1 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(de){lt(de,!1);return}Zs(m.project.id,be.key,Ie)},"aria-expanded":Ie,"aria-label":Ie?r("sessions.sidebar.group.collapseAria",{label:be.label}):r("sessions.sidebar.group.expandAria",{label:be.label}),style:{touchAction:"manipulation"},children:[t.jsx(X,{name:"git-branch",className:J("size-4 shrink-0",tt?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:J("block min-w-0 flex-1 truncate typography-ui-label font-bold",tt?"text-foreground":"text-muted-foreground"),children:be.label}),tt?t.jsx(Zu,{ariaLabel:r("mobile.sessions.activeWorktreeAria")}):null,t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:be.sessions.length})]})}),Ie?Et(`${m.project.id}::${be.key}`,be,Ds):null]},be.key)})]})})()}):null]},m.project.id)})]})]}),i?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:[i.instanceLabel&&i.onOpenInstances?t.jsxs(ge,{type:"button",variant:"info",size:"lg",className:"min-w-0 shrink justify-start",onClick:i.onOpenInstances,"aria-label":r("mobile.menu.instances"),style:{touchAction:"manipulation"},children:[t.jsx(X,{name:"server",className:"size-[18px]"}),t.jsx("span",{className:"block min-w-0 truncate",children:i.instanceLabel})]}):t.jsx("div",{className:"min-w-0 flex-1"}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[i.onOpenUpdate?t.jsxs(ge,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:i.onOpenUpdate,"aria-label":r("mobile.menu.update"),title:r("mobile.menu.update"),style:{touchAction:"manipulation"},children:[t.jsx(X,{name:"download",className:"size-5"}),t.jsx("span",{className:"absolute right-2 top-2 inline-flex size-2 rounded-full bg-primary","aria-hidden":!0})]}):null,t.jsx(ge,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:i.onOpenUsage,"aria-label":r("usageStats.openAction"),title:r("usageStats.openAction"),style:{touchAction:"manipulation"},children:t.jsx(X,{name:"bar-chart",className:"size-5"})}),t.jsx(ge,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:i.onOpenSettings,"aria-label":r("mobile.menu.settings"),title:r("mobile.menu.settings"),style:{touchAction:"manipulation"},children:t.jsx(X,{name:"settings-3",className:"size-5"})})]})]}):null,t.jsx(cl,{open:ps,onOpenChange:Nt}),t.jsx(ul,{open:hs,onOpenChange:m=>{Ht(m),m||Ue(null)},onWorktreeCreated:(m,W)=>{W?.sessionId?N(W.sessionId,m):k({selectedProjectId:Js,directoryOverride:m,preserveDirectoryOverride:!0}),e(!1)}}),t.jsx($u,{open:re!==null,project:ye.find(m=>m.id===re)??null,onClose:()=>ce(null),onWorktreesChanged:()=>De(m=>m+1)}),t.jsx(di,{open:Be,onClose:()=>Ne(!1),title:r("sessions.sidebar.header.displayMode.label"),children:t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"px-3 pb-1 pt-1 typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:r("mobile.sessions.viewMode.label")}),Hu.map(([m,W])=>t.jsxs("button",{type:"button",className:J("flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-left transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",g===m?"text-primary":"text-foreground"),onClick:()=>{At(m),Ne(!1)},style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label",children:r(W)}),g===m?t.jsx(X,{name:"check",className:"size-4"}):null]},m)),g==="timeline"?null:t.jsx("span",{className:"px-3 pb-1 pt-3 typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:r("sessions.sidebar.header.actions.sortProjects")}),g==="timeline"?null:Ku.map(([m,W])=>t.jsxs("button",{type:"button",className:J("flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-left transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",I===m?"text-primary":"text-foreground"),onClick:()=>{en(m),Ne(!1)},style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label",children:r(W)}),I===m?t.jsx(X,{name:"check",className:"size-4"}):null]},m))]})}),Je?t.jsx(Ki,{open:!0,project:{id:Je.project.id,path:Je.project.path},worktree:Je.worktree,onClose:()=>Xe(null),onDeleted:()=>De(m=>m+1)}):null]});return s==="sidebar"?n?t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center justify-between gap-2 border-b border-border/70 px-4",children:[t.jsx("h2",{className:"truncate typography-ui-label font-semibold text-foreground",children:r("mobile.sessions.sheet.title")}),Cs?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:Cs}):null]}),cr]}):null:t.jsxs(od,{open:n,onClose:()=>e(!1),onSwipeClose:()=>{if(ue||de){K(null),Ce(null),pe(null),Ae(null);return}e(!1)},ariaLabel:r("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:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":r("mobile.surface.closeAria"),onClick:()=>e(!1),style:{touchAction:"manipulation"},children:t.jsx(X,{name:"close",className:"size-5"})}),t.jsx("h2",{className:"min-w-0 flex-1 truncate px-1 typography-ui-label font-semibold text-foreground",children:r("mobile.sessions.sheet.title")}),Cs?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:Cs}):null]}),cr]})},Gr="mobile-surface-root",rd=16,Kr=320,id="cubic-bezier(0.22, 1, 0.36, 1)",od=({open:n,onClose:e,onSwipeClose:s,ariaLabel:i,children:r})=>{const o=u.useRef(null),a=u.useRef(null),[c,f]=u.useState(!1),[d,l]=u.useState(n),p=u.useRef(e);u.useEffect(()=>{p.current=e},[e]);const b=u.useRef(s);if(u.useEffect(()=>{b.current=s},[s]),sr(a,{enabled:n,onRightEdgeSwipe:()=>(b.current??p.current)()}),typeof document<"u"&&!o.current){let h=document.getElementById(Gr);h||(h=document.createElement("div"),h.id=Gr,document.body.appendChild(h)),o.current=h}return u.useEffect(()=>{if(n){l(!0);const x=window.setTimeout(()=>f(!0),rd);return()=>window.clearTimeout(x)}f(!1);const h=window.setTimeout(()=>l(!1),Kr+40);return()=>window.clearTimeout(h)},[n]),u.useEffect(()=>{if(!n)return;const h=document.body.style.overflow;document.body.style.overflow="hidden";const x=S=>{S.key==="Escape"&&p.current()};return document.addEventListener("keydown",x),()=>{document.body.style.overflow=h,document.removeEventListener("keydown",x)}},[n]),o.current?Lt.createPortal(t.jsx("section",{ref:a,role:"dialog","aria-modal":"true","aria-label":i,"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:c?"none":"translateX(-100%)",transition:`transform ${Kr}ms ${id}`,visibility:d?"visible":"hidden",pointerEvents:n?"auto":"none"},children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:r})}),o.current):null},Hr=n=>{const e=le.c(10),{title:s,description:i,action:r}=n;let o;e[0]!==s?(o=t.jsx("p",{className:"typography-ui-label text-foreground",children:s}),e[0]=s,e[1]=o):o=e[1];let a;e[2]!==i?(a=i?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i}):null,e[2]=i,e[3]=a):a=e[3];let c;e[4]!==r?(c=r?t.jsx("div",{className:"pt-2",children:r}):null,e[4]=r,e[5]=c):c=e[5];let f;return e[6]!==o||e[7]!==a||e[8]!==c?(f=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[o,a,c]}),e[6]=o,e[7]=a,e[8]=c,e[9]=f):f=e[9],f};function ad(n){return Me(n.path)}function ld(n){return Me(n.path)}function cd(n){return t.jsx(sd,{worktree:n},Me(n.path))}const ud=(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}},dd=n=>{switch(n?.status.status){case"connected":return"success";case"failed":return"error";case"needs_auth":return"warning";default:return"default"}},fd=({active:n,className:e,headerAction:s,listClassName:i,hideHeader:r=!1,mobileListDensity:o=!1})=>{const{t:a}=me(),f=ht(v=>v.currentDirectory)??null,d=is(v=>v.getStatusForDirectory(f)),l=is(v=>v.refresh),p=is(v=>v.connect),b=is(v=>v.disconnect),h=Ot(v=>v.mcpServers),x=Ot(v=>v.loadMcpConfigs),[S,y]=u.useState(!1),[E,w]=u.useState(null);u.useEffect(()=>{l({directory:f,silent:!0})},[l,f]),u.useEffect(()=>{x({force:!0})},[x]),u.useEffect(()=>{n&&Promise.all([l({directory:f,silent:!0}),x({force:!0})])},[n,l,f,x]);const N=u.useMemo(()=>{const v=new Set(Object.keys(d));for(const P of h)P?.name&&v.add(P.name);return Array.from(v).sort((P,C)=>P.localeCompare(C))},[h,d]),A=u.useCallback(v=>{if(v?.preventDefault(),S)return;y(!0);const P=new Promise(C=>setTimeout(C,500));Promise.all([l({directory:f}),P]).finally(()=>{y(!1)})},[S,l,f]);return t.jsxs("div",{className:J("w-full",e),children:[r?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:a("mcpDropdown.title")}),f&&t.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:f.split("/").pop()||f})]}),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:S,onClick:A,"aria-label":a("mcpDropdown.actions.refreshAria"),children:t.jsx(X,{name:"refresh",className:J("h-4 w-4",S&&"animate-spin")})})]})]})}),t.jsx("div",{className:J("max-h-64 overflow-y-auto",o?"space-y-1 py-3":"px-3 py-2.5",i),children:t.jsxs("div",{className:J(!o&&N.length>0&&"rounded-xl bg-[var(--surface-muted)] p-1.5"),children:[N.map(v=>{const P=d[v],C=dd(P),R=P?.status.status==="connected",k=E===v,z=ud(P,a);return t.jsxs("div",{className:J("flex items-center justify-between rounded-lg hover:bg-interactive-hover/50",o?"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(Qo,{children:[t.jsx(Xo,{asChild:!0,children:t.jsx("span",{className:J("rounded-full flex-shrink-0",o?"h-2.5 w-2.5":"h-2 w-2",C==="success"&&"bg-status-success",C==="error"&&"bg-status-error",C==="warning"&&"bg-status-warning",C==="default"&&"bg-muted-foreground/40"),"aria-label":z})}),t.jsx(Zo,{side:"left",children:t.jsx("p",{children:z})})]}),t.jsx("span",{className:J("truncate",o?"text-[17px] leading-6 font-medium":"typography-ui-label"),children:v})]})}),t.jsx(ea,{checked:R,disabled:k,className:"data-[checked]:bg-status-info",onCheckedChange:async D=>{w(v);try{D?await p(v,f):await b(v,f)}catch(_){Jl.error(_ instanceof Error?_.message:a("mcpDropdown.status.unknownError"))}finally{w(null)}}})]},v)}),N.length===0&&t.jsx("div",{className:"px-4 py-5 typography-ui-label text-muted-foreground text-center",children:a("mcpDropdown.empty.configureInConfig")})]})})]})},qr={status:"loading"},It={type:"list"},md=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),pd=n=>{const e=n.index?.trim();return!!(e&&e!=="?")},hd=n=>{const e=n.working_dir?.trim(),s=n.index?.trim();return!!(e||s==="?")},Jr=(n,e)=>e?`${n}\0staged`:n,gd=n=>{const e=le.c(8),s=Dn()??null;let i;e[0]!==s?(i=md(s),e[0]=s,e[1]=i):i=e[1];const r=i,o=n.visible??!0;let a;e[2]!==o?(a={enabled:o},e[2]=o,e[3]=a):a=e[3];const c=ta(r||null,a);let f;return e[4]!==n||e[5]!==c||e[6]!==r?(f=t.jsx(bd,{...n,rootDirectory:r,repository:c}),e[4]=n,e[5]=c,e[6]=r,e[7]=f):f=e[7],f},bd=({rootDirectory:n,repository:e,onClose:s,initialDiff:i,visible:r=!0})=>{const{t:o}=me(),{git:a}=Tn(),{rootIsGitRepo:c,gitDirectory:f,nestedRepos:d}=e,l=f??n,p=sa(l||null),b=na(l||null),h=ci(l||null),x=ra(l||null),S=Fe(T=>T.setActiveDirectory),y=Fe(T=>T.ensureAll),E=Fe(T=>T.ensureNestedRepos),w=Fe(T=>T.selectNestedRepo),N=Fe(T=>T.fetchStatus),A=Fe(T=>T.fetchBranches),v=Fe(T=>T.prefetchDiffs),P=Fe(T=>T.getDiff),C=Fe(T=>T.setDiff),R=Fe(T=>T.runtimeKey),k=JSON.stringify([R,l]),z=u.useRef(k);z.current=k;const[D,_]=u.useState(()=>({ownerKey:k,mode:"working",route:i?.path?{type:"diff",path:i.path,staged:i.staged}:It})),j=D.ownerKey===k?D.mode:"working",I=D.ownerKey===k?D.route:It,[$,g]=u.useState(!1),O=u.useCallback(T=>{_({ownerKey:k,mode:T,route:It}),g(!1)},[k]),V=u.useCallback(T=>{_(F=>({ownerKey:k,mode:F.ownerKey===k?F.mode:"working",route:T}))},[k]);u.useEffect(()=>{_(T=>T.ownerKey===k?T:{ownerKey:k,mode:"working",route:It}),g(!1)},[k]),u.useEffect(()=>{r||g(!1)},[r]),u.useEffect(()=>{i?.path&&_({ownerKey:z.current,mode:"working",route:{type:"diff",path:i.path,staged:i.staged}})},[i]);const[B,L]=u.useState(null),[ie,se]=u.useState(null),[te,M]=u.useState(""),[G,Y]=u.useState(new Set),[H,Q]=u.useState(!1),[ne,re]=u.useState(!1),[ce,ue]=u.useState([]),[K,oe]=u.useState([]),[pe,ke]=u.useState([]),[q,de]=u.useState(null),[Ce,ze]=u.useState(null),[Ae,Je]=u.useState(null),[Xe,ut]=u.useState(0),[De,Be]=u.useState(null),Ne=p?.current??null,ps=p?.tracking?.trim().split("/")[0],Nt=(ps&&b?.defaultBranches?.[ps])??b?.defaultBranches?.origin??null,hs=dc(Ne,Nt),Ht=h===!1||cc(Ne,Nt,p!==null,b!==null),Js=Zl(T=>T.setOverride),Ue=ec(l||null,Ne,r&&j==="branch"&&hs),$e=tc(l||null,Ne,r&&j==="commit"&&h===!0),dt=$e.selectedCommit?.hash??null,nt=sc(l||null,Ne,r&&j==="pr"&&h===!0),ft=nt.selectedSource,Le=u.useMemo(()=>j==="pr"?ft:j==="branch"&&Ne&&Ue.base?{kind:"branch",baseRef:Ue.base,headRef:Ne}:j==="commit"&&dt?{kind:"commit",hash:dt}:null,[Ue.base,Ne,j,dt,ft]),bt=j==="branch"?Ue.revision:"",je=ac(l||null,Le,r&&h===!0,bt),{fetchDiff:Ct}=je,qt=u.useMemo(()=>je.files?[...je.files].sort((T,F)=>T.path.localeCompare(F.path)):null,[je.files]),Ye=I.type==="comparison"&&I.sourceKey===je.key?I.path:null,[Ys,Jt]=u.useState(0),gs=u.useCallback(async T=>{try{const{diff:F}=await Ct(T),Z={original:"",modified:"",isBinary:nc(F)};return Z.isBinary||(Z.fileDiff=rc(T,F)),{status:"ready",diff:Z}}catch(F){return{status:"error",message:F instanceof Error?F.message:o("diffView.state.failedToLoadDiff")}}},[Ct,o]),ye=lc(je.files?j==="pr"?JSON.stringify([je.key,je.revision]):je.key:null,r&&Ye?Ye:"",r?gs:null,qr,JSON.stringify([bt,j==="pr"?je.revision:0,Ys])),Qe=Ye?ye.get(Ye)??qr:null;u.useEffect(()=>{j==="branch"&&Ht&&O("working")},[Ht,O,j]),u.useEffect(()=>{_(T=>T.ownerKey===k&&T.route.type==="comparison"&&T.route.sourceKey!==je.key?{...T,route:It}:T)},[je.key,k]);const Ge=u.useMemo(()=>{const T=p?.files??[],F=new Map;for(const Z of T)F.set(Z.path,Z);return Array.from(F.values()).sort((Z,we)=>Z.path.localeCompare(we.path))},[p?.files]),Re=u.useMemo(()=>Ge.filter(pd),[Ge]),ot=u.useMemo(()=>Ge.filter(hd),[Ge]),Oe=u.useMemo(()=>{if(pe.length>0)return pe;const T=p?.tracking?.includes("/")?p.tracking.split("/")[0]:null;return T||q?[{name:T||"origin",fetchUrl:q??"",pushUrl:q??""}]:[]},[q,pe,p?.tracking]),bs=Fe(u.useCallback(T=>!l||I.type!=="diff"?null:T.directories.get(l)?.diffCache.get(Jr(I.path,I.staged))??null,[l,I])),Qs=u.useMemo(()=>I.type!=="diff"?null:Ge.find(T=>T.path===I.path)??null,[Ge,I]),_e=u.useCallback(async(T=!0)=>{if(l)try{await Promise.all([N(l,a),A(l,a)])}catch(F){T&&fe.error(F instanceof Error?F.message:o("gitView.toast.refreshRepositoryFailed"))}},[l,A,N,a,o]),Ee=u.useMemo(()=>(b?.all??[]).filter(T=>!T.startsWith("remotes/")).sort(),[b]),xs=u.useMemo(()=>(b?.all??[]).filter(T=>T.startsWith("remotes/")).map(T=>T.replace(/^remotes\//,"")).sort(),[b]),at=u.useCallback(async T=>{if(!l)return;const F=T.replace(/^remotes\//,"");try{const Z=await a.checkoutBranch(l,F);fe.success(o("gitView.toast.checkedOut",{name:Z.branch||F})),await _e()}catch(Z){fe.error(Z instanceof Error?Z.message:o("gitView.toast.checkoutFailed",{name:F}))}},[l,a,_e,o]),ys=u.useCallback(T=>{const F=T.replace(/^remotes\//,"");if((p?.files?.length??0)>0){Be(F);return}at(F)},[at,p?.files]),Xs=u.useCallback(async(T,F)=>{if(l)try{await a.createBranch(l,T,Ne??"HEAD"),await a.checkoutBranch(l,T),F&&await a.gitPush(l,{remote:F.name,branch:T,options:["--set-upstream"]}),await _e()}catch(Z){throw fe.error(Z instanceof Error?Z.message:o("gitView.toast.createBranchFailed")),Z}},[Ne,l,a,_e,o]),Rt=u.useCallback(async()=>{if(!l){ke([]),de(null);return}try{const[T,F]=await Promise.all([a.getRemotes(l).catch(()=>[]),a.getRemoteUrl?a.getRemoteUrl(l).catch(()=>null):Promise.resolve(null)]);ke(T),de(F)}catch{ke([]),de(null)}},[l,a]);u.useEffect(()=>{!l||!r||(S(l),y(l,a))},[l,y,a,S,r]),u.useEffect(()=>{r&&Rt()},[Rt,r]),u.useEffect(()=>{if(!r||j!=="working"||!l||Ge.length===0)return;const T=Array.from(new Set([...Re.map(Z=>Z.path),...K,...Ge.slice(0,20).map(Z=>Z.path)])).filter(Boolean);if(T.length===0)return;const F=window.setTimeout(()=>{v(l,a,T,{maxFiles:40})},120);return()=>window.clearTimeout(F)},[Ge,l,a,j,v,Re,K,r]),u.useEffect(()=>{if(!r)return;if(I.type!=="diff"){ze(null);return}const T=Jr(I.path,I.staged);if(Je(null),!l||P(l,T)){ze(null);return}let F=!1;const Z=Gt();return ze(null),a.getGitFileDiff(l,{path:I.path,staged:I.staged||void 0}).then(we=>{F||C(l,T,{original:we.original??"",modified:we.modified??"",isBinary:we.isBinary,submodule:we.submodule},Z)}).catch(we=>{if(!F){if(we instanceof hr&&we.reason!=="path_not_found"){Je({key:`${l}\0${I.path}`,reason:we.reason});return}we instanceof hr&&N(l,a,{force:!0,silent:!0}),ze(we instanceof Error?we.message:String(we))}}),()=>{F=!0}},[l,Xe,N,P,a,I,C,r]);const vs=async(T,F)=>{if(l){L(T);try{if(T==="fetch"){if(!F)throw new Error(o("mobile.changes.noRemote"));await a.gitFetch(l,{remote:F.name}),fe.success(o("gitView.toast.fetchedFromRemote",{name:F.name}))}else if(T==="sync"){if(!F)throw new Error(o("mobile.changes.noRemote"));let Z=0;const we=await Sr({git:a,directory:l,remote:F,dirtyWorktreeError:o("gitView.toast.commitOrStashBeforeSync"),onPulled:Ze=>{Z=Ze.files.length}});Z>0&&fe.success(Z===1?o("gitView.toast.pulledFilesSingle",{count:Z,name:F.name}):o("gitView.toast.pulledFilesPlural",{count:Z,name:F.name})),we.pushed.length>0?fe.success(o("gitView.toast.pushedToUpstream",{name:we.pushed[0].remote})):Z===0&&fe.success(o("gitView.toast.alreadyUpToDate"))}await _e(!1),await Rt()}catch(Z){fe.error(Z instanceof Error?Z.message:o("gitView.toast.syncActionFailed",{action:o("gitView.sync.syncChanges")}))}finally{L(null)}}},mt=u.useCallback(async(T,F)=>{if(!(!l||T.length===0))try{F==="stage"?T.length>1?await ia(l,T):await oa(l,T[0]):T.length>1?await aa(l,T):await la(l,T[0]),await _e(!1)}catch(Z){fe.error(Z instanceof Error?Z.message:o(F==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed"))}},[l,_e,o]),Yt=u.useCallback((T,F=!1)=>{V({type:"diff",path:T,staged:F})},[V]),Qt=u.useCallback(async T=>{if(l){Y(F=>new Set(F).add(T));try{await a.revertGitFile(l,T),fe.success(o("gitView.toast.revertedFile",{path:T})),await _e(!1)}catch(F){fe.error(F instanceof Error?F.message:o("gitView.toast.revertFailed"))}finally{Y(F=>{const Z=new Set(F);return Z.delete(T),Z})}}},[l,a,_e,o]),Et=u.useCallback(async T=>{if(!l||T.length===0||H)return;const F=Array.from(new Set(T));Q(!0),Y(new Set(F));try{await Promise.all(F.map(Z=>a.revertGitFile(l,Z))),await _e(!1),fe.success(F.length===1?o("gitView.toast.revertedFilesSingle",{count:F.length}):o("gitView.toast.revertedFilesPlural",{count:F.length}))}catch(Z){fe.error(Z instanceof Error?Z.message:o("gitView.toast.revertFailed"))}finally{Y(new Set),Q(!1)}},[l,a,H,_e,o]),ws=u.useCallback(T=>{const F=T.map(Z=>Z.trim()).filter(Boolean);if(F.length===0){ue([]);return}M(Z=>`${Z.trim()}${Z.trim()?`
23
23
 
24
24
  `:""}${F.join(`
25
- `)}`.trim()),ue([])},[]),Zs=u.useCallback(async()=>{if(!l)return;const T=Re.map(F=>F.path).sort();if(T.length===0){fe.error(o("gitView.toast.selectFileToDescribe"));return}re(!0);try{const{message:F}=await wr(l,T);M(F.subject?.trim()??""),ue(Array.isArray(F.highlights)?F.highlights:[])}catch(F){fe.error(F instanceof Error?F.message:o("gitView.toast.generateCommitMessageFailed"))}finally{re(!1)}},[l,Re,o]),Pt=async(T={})=>{if(!l)return;if(!te.trim()){fe.error(o("gitView.toast.enterCommitMessage"));return}const F=Re.map(Z=>Z.path).sort();if(F.length===0){fe.error(o("gitView.toast.selectFileToCommit"));return}se(T.pushAfter?"commitAndPush":"commit");try{if(await a.createGitCommit(l,te.trim(),{files:F}),fe.success(o("gitView.toast.commitCreated")),M(""),ue([]),T.pushAfter){const Z=p?.tracking?.split("/")[0],we=Oe.find(Ze=>Ze.name===Z)??Oe[0];if(!we)throw new Error(o("mobile.changes.noRemote"));L("sync"),await Sr({git:a,directory:l,remote:we,dirtyWorktreeError:o("gitView.toast.commitOrStashBeforeSync"),onPushed:Ze=>{fe.success(o("gitView.toast.pushedToUpstream",{name:Ze.pushed[0].remote}))}}),await _e(!1),await Rt()}else await _e(!1)}catch(Z){fe.error(Z instanceof Error?Z.message:o("gitView.toast.createCommitFailed"))}finally{se(null),T.pushAfter&&L(null)}},js=u.useMemo(()=>{const T=[];return Re.length>0&&T.push({id:"staged",title:o("gitView.changes.stagedTitle"),entries:Re,statsScope:"staged",actionSymbol:"-",actionAllLabel:o("gitView.changes.unstageAllAria"),getActionLabel:F=>o("gitView.changes.unstageFileAria",{path:F}),onActionFile:F=>{mt([F],"unstage")},onActionAll:F=>{mt(F,"unstage")},onViewDiff:F=>Yt(F,!0),onRevertFile:Qt,showRevertActions:!1,accent:!0}),ot.length>0&&T.push({id:"unstaged",title:o("gitView.changes.title"),entries:ot,statsScope:"working",actionSymbol:"+",actionAllLabel:o("gitView.changes.stageAllAria"),getActionLabel:F=>o("gitView.changes.stageFileAria",{path:F}),onActionFile:F=>{mt([F],"stage")},onActionAll:F=>{mt(F,"stage")},onViewDiff:F=>Yt(F,!1),onRevertFile:Qt}),T},[Qt,Yt,mt,Re,o,ot]),lt=T=>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 px-3 text-foreground",children:[s?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(X,{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:p?.current||l||""})]}),c===!1&&Array.isArray(d)&&d.length>0?t.jsx(bl,{repositories:d,selectedRepository:f??null,onSelectRepository:F=>{n&&w(n,F)},repositoryRoot:n??void 0}):null]}),t.jsx("div",{className:"min-h-0 flex-1",children:T})]});if(!l)return lt(t.jsx(qe,{message:o("gitView.empty.selectSessionOrDirectory")}));if(c===!1&&h!==!0)return lt(t.jsx(xl,{rootIsGitRepo:c,resolvedIsGitRepo:h,nestedRepos:d,onRetryDiscovery:()=>{n&&E(n,{force:!0})}}));if(x&&h===null)return lt(t.jsx(qe,{loading:!0,message:o("gitView.loading.checkingRepository")}));if(I.type==="diff")return t.jsx(Yr,{path:I.path,diff:bs,staged:I.staged,fileExists:!!Qs,unavailableReason:Ae?.key===`${l}\0${I.path}`?Ae.reason:null,error:Ce,onBack:()=>V({type:"list"}),onRetry:()=>ut(T=>T+1)});const Xt=o(j==="pr"?"session.githubIntegration.tabs.pullRequests":j==="branch"?"diffView.scope.branch":j==="commit"?"commitComparison.mode":"mobile.nav.changes"),Zt=j==="branch"&&Ue.base?pl(Ue.base):j==="commit"?dt?.slice(0,8):j==="pr"&&ft?`#${ft.number}`:null;if(Ye&&Qe)return t.jsx(Yr,{path:Ye,subtitle:[Xt,Zt].filter(Boolean).join(" · "),diff:Qe.status==="ready"?Qe.diff:null,fileExists:!je.files||je.files.some(T=>T.path===Ye),error:je.error??(Qe.status==="error"?Qe.message:null),onBack:()=>V(It),onRetry:()=>{je.error&&je.refresh(),Jt(T=>T+1)}});const ks=()=>j==="pr"&&!ft?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(qe,{loading:nt.loading,message:nt.error??(nt.loading?o("session.githubPrPicker.loading.pullRequests"):o("pullRequestComparison.select"))}),!nt.loading&&t.jsx(Nr,{mobile:!0,comparison:nt})]}):j==="branch"&&!Ue.base?t.jsx(qe,{loading:!Ue.resolved,message:Ue.resolved?o("gitView.pr.toast.baseBranchRequired"):o("diffView.branch.resolvingBase")}):j==="commit"&&!dt?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[$e.loading&&t.jsx(X,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:$e.loading?o("diffView.state.loadingChanges"):$e.error??o("commitComparison.noCommits")}),$e.error&&t.jsx(ge,{variant:"outline",size:"lg",onClick:()=>{$e.refresh()},children:o("diffView.actions.retry")})]}):je.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:je.error}),t.jsx(ge,{variant:"outline",size:"lg",onClick:()=>{je.refresh()},children:o("diffView.actions.retry")})]}):qt?qt.length===0?t.jsx(qe,{icon:j==="branch",message:j==="pr"?o("walkthrough.blocked.emptyDiff.description"):j==="commit"?o("commitComparison.emptyDiff"):o("diffView.branch.empty",{base:Zt??""})}):t.jsx(xd,{files:qt,onSelect:T=>{je.key&&V({type:"comparison",path:T,sourceKey:je.key})}}):t.jsx(qe,{loading:!0,message:o("diffView.state.loadingChanges")});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[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:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(X,{name:"close",className:"size-5"})}):null,t.jsxs(ca,{open:$,onOpenChange:g,children:[t.jsx(ua,{asChild:!0,children:t.jsxs(ge,{variant:"outline",className:da({size:"default"}),"data-mobile-comparison-trigger":!0,"aria-label":o("diffView.scope.selectorAria"),children:[t.jsx("span",{children:Xt}),t.jsx(X,{name:"arrow-down-s",className:"size-4"})]})}),t.jsx(fa,{align:"start",children:t.jsxs(ma,{value:j,onValueChange:T=>{(T==="working"||T==="branch"||T==="commit"||T==="pr")&&O(T)},children:[t.jsx(As,{value:"working",className:"min-h-8 items-center",children:o("mobile.nav.changes")}),hs&&t.jsx(As,{value:"branch",className:"min-h-8 items-center",children:o("diffView.scope.branch")}),t.jsx(As,{value:"commit",className:"min-h-8 items-center",children:o("commitComparison.mode")}),t.jsx(As,{value:"pr",className:"min-h-8 items-center",children:o("session.githubIntegration.tabs.pullRequests")})]})})]}),r&&j==="branch"&&t.jsx(ic,{mobile:!0,branches:b?.all??[],currentBranch:Ne,base:Ue.base,onSelect:T=>{Ne&&Js(l,Ne,T)}},JSON.stringify([k,Ne])),r&&j==="commit"&&t.jsx(oc,{mobile:!0,commits:$e.commits,selectedHash:dt,loading:$e.loading,error:$e.error,onSelect:$e.select,onRefresh:()=>{$e.refresh()}},JSON.stringify([k,Ne])),r&&j==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(Nr,{mobile:!0,comparison:nt},JSON.stringify([k,Ne])),ft&&t.jsx(ge,{variant:"ghost",size:"sm",disabled:je.loading,"aria-label":o("session.githubIssuePicker.actions.refresh"),onClick:()=>{je.refresh()},children:t.jsx(X,{name:"refresh",className:"size-4"})})]})]}),j==="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(hl,{currentBranch:p?.current,localBranches:Ee,remoteBranches:xs,branchInfo:b?.branches,currentBranchAhead:p?.ahead,onCheckout:T=>{ys(T)},onCreate:Xs,remotes:Oe,disabled:x,directory:l,switchBlockedNotice:(p?.files?.length??0)>0?o("gitView.branch.switchBlockedNotice"):null})}),t.jsx(gl,{syncAction:B,remotes:Oe,onFetch:T=>{vs("fetch",T)},onSync:T=>{vs("sync",T)},disabled:ie!==null||x,aheadCount:p?.ahead??0,behindCount:p?.behind??0,trackingRemoteName:p?.tracking?.split("/")[0],hasUncommittedChanges:Ge.length>0})]}),j!=="working"?t.jsx("div",{className:"min-h-0 flex-1",children:ks()}):Ge.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(Yl,{groups:js,diffStats:p?.diffStats,revertingPaths:G,onRevertAll:Et,isRevertingAll:H,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:oe})}),t.jsx("div",{className:"shrink-0 border-t border-border/70 px-4 pb-4 pt-3",children:t.jsx(Ql,{stagedCount:Re.length,commitMessage:te,onCommitMessageChange:M,generatedHighlights:ce,onInsertHighlights:ws,onGenerateMessage:Zs,isGeneratingMessage:ne,onCommit:()=>{Pt({pushAfter:!1})},onCommitAndPush:()=>{Pt({pushAfter:!0})},commitAction:ie,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(qe,{icon:!0,message:o("gitView.empty.cleanTitle"),description:o("mobile.changes.cleanDescription")})}),t.jsx(Xl,{open:De!==null,onOpenChange:T=>{T||Be(null)},targetBranch:De??"",changedFileCount:p?.files?.length??0,onCommitAndSwitch:async(T,F)=>{const Z=De;if(!Z||!l)return;const we=p?.current??null;await a.createGitCommit(l,T,{addAll:!0});let Ze=null;if(F){const en=p?.tracking?.split("/")[0],At=Oe.find(tn=>tn.name===en)??Oe[0];try{if(!At)throw new Error(o("mobile.changes.noRemote"));await a.gitPush(l,p?.tracking?{remote:At.name}:{remote:At.name,branch:we??void 0,options:["--set-upstream"]}),Ze=At.name}catch{fe.error(o("gitView.dirtySwitch.pushFailed")),await _e(),Be(null);return}}fe.success(we?Ze?o("gitView.toast.pushedToUpstream",{name:Ze}):o("gitView.dirtySwitch.committedNotPushed",{branch:we}):o("gitView.toast.commitCreated")),await _e(),Be(null),await at(Z)},onGenerateMessage:async()=>{if(!l)return"";const T=(p?.files??[]).map(Z=>Z.path).sort(),{message:F}=await wr(l,T);return F.subject?.trim()??""},onRevertAndSwitch:async()=>{const T=De;if(!T||!l)return;await Et((p?.files??[]).map(Z=>Z.path));const F=await a.getGitStatus(l);if(!F.isClean&&(F.files?.length??0)>0){fe.error(o("gitView.dirtySwitch.revertIncomplete"));return}Be(null),await at(T)}})]})},qe=n=>{const e=le.c(13),{message:s,description:i,loading:r,icon:o}=n,a=r===void 0?!1:r,c=o===void 0?!1:o;let f;e[0]!==a?(f=a?t.jsx(X,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,e[0]=a,e[1]=f):f=e[1];let d;e[2]!==c?(d=c?t.jsx(X,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e[2]=c,e[3]=d):d=e[3];let l;e[4]!==s?(l=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[4]=s,e[5]=l):l=e[5];let p;e[6]!==i?(p=i?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i}):null,e[6]=i,e[7]=p):p=e[7];let b;return e[8]!==f||e[9]!==d||e[10]!==l||e[11]!==p?(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,d,l,p]})}),e[8]=f,e[9]=d,e[10]=l,e[11]=p,e[12]=b):b=e[12],b},Yr=n=>{const e=le.c(31),{path:s,subtitle:i,diff:r,staged:o,fileExists:a,unavailableReason:c,error:f,onBack:d,onRetry:l}=n,p=o===void 0?!1:o,b=c===void 0?null:c,{t:h}=me();let x;e[0]!==s?(x=pa(s)||"text",e[0]=s,e[1]=x):x=e[1];const S=x;let y;e[2]!==h?(y=h("header.actions.backAria"),e[2]=h,e[3]=y):y=e[3];let E;e[4]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx(X,{name:"arrow-left",className:"size-5"}),e[4]=E):E=e[4];let w;e[5]!==d||e[6]!==y?(w=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":y,onClick:d,children:E}),e[5]=d,e[6]=y,e[7]=w):w=e[7];let N;e[8]!==s?(N=t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:s}),e[8]=s,e[9]=N):N=e[9];let A;e[10]!==i?(A=i&&t.jsx("p",{className:"truncate typography-meta text-muted-foreground",children:i}),e[10]=i,e[11]=A):A=e[11];let v;e[12]!==N||e[13]!==A?(v=t.jsxs("div",{className:"min-w-0 flex-1 px-2",children:[N,A]}),e[12]=N,e[13]=A,e[14]=v):v=e[14];let P;e[15]!==w||e[16]!==v?(P=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:[w,v]}),e[15]=w,e[16]=v,e[17]=P):P=e[17];let C;e[18]!==r||e[19]!==f||e[20]!==a||e[21]!==S||e[22]!==l||e[23]!==s||e[24]!==p||e[25]!==h||e[26]!==b?(C=t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:a?b==="nested_repository"?t.jsx(qe,{icon:!0,message:h("diffView.unavailable.nestedRepositoryTitle"),description:h("diffView.unavailable.nestedRepositoryDescription")}):b==="untracked_directory"?t.jsx(qe,{icon:!0,message:h("diffView.unavailable.untrackedDirectoryTitle"),description:h("diffView.unavailable.untrackedDirectoryDescription")}):f?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:h("mobile.changes.diffDetail.loadFailed")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:f}),t.jsx(ge,{type:"button",size:"sm",variant:"outline",onClick:l,children:h("diffView.actions.retry")})]})}):r?r.submodule?t.jsx("div",{className:"p-3",children:t.jsx(uc,{state:r.submodule,staged:p})}):r.isBinary?t.jsx(qe,{icon:!0,message:h("diffView.binary.unavailable")}):ha(s)&&!r.fileDiff?t.jsx(qe,{icon:!0,message:h("mobile.changes.diffDetail.imageUnavailable")}):t.jsx(Ks,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:t.jsx(fc,{original:r.original,modified:r.modified,fileDiff:r.fileDiff,language:S,fileName:s,renderSideBySide:!1,wrapLines:!0,layout:"inline"})}):t.jsx(qe,{loading:!0,message:h("diffView.state.loadingDiff")}):t.jsx(qe,{icon:!0,message:h("mobile.changes.diffDetail.missingTitle"),description:h("mobile.changes.diffDetail.missingDescription")})}),e[18]=r,e[19]=f,e[20]=a,e[21]=S,e[22]=l,e[23]=s,e[24]=p,e[25]=h,e[26]=b,e[27]=C):C=e[27];let R;return e[28]!==P||e[29]!==C?(R=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[P,C]}),e[28]=P,e[29]=C,e[30]=R):R=e[30],R},xd=n=>{const e=le.c(12),{files:s,onSelect:i}=n,{t:r}=me();let o;e[0]!==r?(o=r("gitView.changes.changedFilesAria"),e[0]=r,e[1]=o):o=e[1];let a;if(e[2]!==s||e[3]!==i||e[4]!==r){let f;e[6]!==i||e[7]!==r?(f=d=>{const l=d.status==="A"?r("diffView.change.new"):d.status==="D"?r("diffView.change.deleted"):d.status==="R"?r("diffView.change.renamed"):d.status==="C"?r("diffView.change.copied"):r("diffView.change.modified"),p=d.status==="A"?"var(--status-success)":d.status==="D"?"var(--status-error)":d.status==="R"||d.status==="C"?"var(--status-info)":"var(--status-warning)";return t.jsx("li",{children:t.jsxs(ge,{variant:"ghost",size:"lg",className:"w-full justify-start gap-2.5 text-left normal-case",onClick:()=>i(d.path),children:[t.jsx("span",{className:"w-4 shrink-0 text-center typography-meta font-semibold uppercase",style:{color:p},"aria-label":l,children:d.status}),t.jsx(vi,{filePath:d.path,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label",title:d.path,children:d.path}),(d.insertions>0||d.deletions>0)&&t.jsxs("span",{className:"shrink-0 typography-meta text-muted-foreground",children:["+",d.insertions," -",d.deletions]}),t.jsx(X,{name:"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground"})]})},d.path)},e[6]=i,e[7]=r,e[8]=f):f=e[8],a=s.map(f),e[2]=s,e[3]=i,e[4]=r,e[5]=a}else a=e[5];let c;return e[9]!==o||e[10]!==a?(c=t.jsx(Ks,{className:"h-full overflow-y-auto overflow-x-hidden px-3 py-2",children:t.jsx("ul",{"aria-label":o,className:"flex flex-col gap-1",children:a})}),e[9]=o,e[10]=a,e[11]=c):c=e[11],c},yd=u.lazy(()=>$t(()=>import("./FilesView-DjksmZRo.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])).then(n=>({default:n.FilesView}))),kt=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),us=n=>{const e=kt(n);return!e||e==="/"?e||"/":e.split("/").filter(Boolean).at(-1)??e},vd=n=>{const e=kt(n);if(!e||e==="/")return null;const s=e.lastIndexOf("/");return s<=0?e.startsWith("/")?"/":null:e.slice(0,s)},wd=(n,e)=>{const s=kt(n),i=kt(e);return!i||s===i?us(s):s.startsWith(`${i}/`)?s.slice(i.length+1):s},jd=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 i of e){if(s<1024||i===e[e.length-1])return`${s.toFixed(s>=10?0:1)} ${i}`;s/=1024}return""},kd=({onClose:n})=>{const{t:e}=me(),{files:s}=Tn(),i=yo(g=>g.setSelectedPath),r=kt(Dn()??null),[o,a]=u.useState(()=>({type:"browser",directory:r})),[c,f]=u.useState([]),[d,l]=u.useState(!1),[p,b]=u.useState(null),[h,x]=u.useState(""),[S,y]=u.useState([]),[E,w]=u.useState(!1),N=u.useRef(0);u.useEffect(()=>{r&&a(g=>g.type==="browser"&&g.directory?g:{type:"browser",directory:r})},[r]);const A=o.type==="browser"?o.directory:o.returnDirectory,v=u.useCallback(async g=>{if(!g)return;const O=N.current+1;N.current=O,l(!0),b(null);try{const V=await s.listDirectory(g);if(N.current!==O)return;f(V.entries.slice().sort((B,L)=>B.isDirectory!==L.isDirectory?B.isDirectory?-1:1:B.name.localeCompare(L.name)))}catch(V){if(N.current!==O)return;f([]),b(V instanceof Error?V.message:e("mobile.files.error.listFailed"))}finally{N.current===O&&l(!1)}},[s,e]);u.useEffect(()=>{o.type==="browser"&&v(o.directory)},[v,o]),u.useEffect(()=>{if(o.type!=="browser")return;const g=h.trim();if(!g){y([]),w(!1);return}let O=!1;const V=window.setTimeout(()=>{w(!0),s.search({directory:o.directory,query:g,maxResults:40}).then(B=>{O||y(B)}).catch(()=>{O||y([])}).finally(()=>{O||w(!1)})},250);return()=>{O=!0,window.clearTimeout(V)}},[s,h,o]);const P=g=>{x(""),a({type:"browser",directory:g})},C=g=>{i(r,g),a({type:"file",path:g,returnDirectory:A||r})},R=it(g=>g.pendingFileFocusPath),k=it(g=>g.pendingFileNavigation);if(u.useEffect(()=>{const g=kt(k?.path??R??"");!g||!r||g!==r&&!g.startsWith(`${r}/`)||(i(r,g),a({type:"file",path:g,returnDirectory:r}),R&&it.getState().setPendingFileFocusPath(null))},[R,k,r,i]),!r)return t.jsx(ds,{message:e("mobile.files.empty.noDirectory")});if(o.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:"-ml-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":e("header.actions.backAria"),onClick:()=>a({type:"browser",directory:o.returnDirectory}),style:{touchAction:"manipulation"},children:t.jsx(kr,{className:"size-5"})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:us(o.path)})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(Ve,{children:t.jsx(u.Suspense,{fallback:t.jsx(ds,{loading:!0,message:e("filesView.state.loading")}),children:t.jsx(yd,{mode:"editor-only"})})})})]});const z=o.directory===r?e("mobile.files.rootDirectory"):us(o.directory),D=h.trim()?S:[],_=vd(o.directory),j=o.directory!==r&&_!==null&&(_===r||_.startsWith(`${r}/`)),I=j&&!h.trim(),$=j?_:null;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 px-3 text-foreground",children:[n?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("mobile.surface.closeAria"),onClick:n,style:{touchAction:"manipulation"},children:t.jsx(Wl,{className:"size-5"})}):null,I&&$?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":e("mobile.files.backToParentAria",{name:us($)}),onClick:()=>P($),style:{touchAction:"manipulation"},children:t.jsx(kr,{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:z})}),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":e("mobile.files.refreshAria"),onClick:()=>{v(o.directory)},style:{touchAction:"manipulation"},children:t.jsx(Vl,{className:J("size-5",d&&"animate-spin")})})]}),t.jsx("div",{className:"shrink-0 px-4 pb-2 pt-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(Ul,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(gi,{value:h,onChange:g=>x(g.target.value),placeholder:e("mobile.files.search.placeholder"),className:"h-11 pl-9"})]})}),t.jsx(Ks,{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-3",children:p?t.jsx(ds,{message:p}):h.trim()?t.jsx(Sd,{results:D,isSearching:E,onOpenFile:C}):t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:[c.length===0&&!d?t.jsx("div",{className:"px-4 py-8 text-center typography-body text-muted-foreground",children:e("mobile.files.empty.directory")}):null,c.map(g=>t.jsx(Xi,{name:g.name,path:g.path,directory:g.isDirectory,meta:g.isDirectory?void 0:jd(g.size),onClick:()=>g.isDirectory?P(g.path):C(g.path)},g.path))]})})]})},Xi=n=>{const e=le.c(16),{name:s,path:i,directory:r,meta:o,onClick:a}=n;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={touchAction:"manipulation"},e[0]=c):c=e[0];let f;e[1]!==r||e[2]!==i?(f=r?t.jsx(Gl,{className:"size-5 shrink-0 text-primary/80"}):t.jsx(vi,{filePath:i,className:"size-5 shrink-0"}),e[1]=r,e[2]=i,e[3]=f):f=e[3];let d;e[4]!==s?(d=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:s}),e[4]=s,e[5]=d):d=e[5];let l;e[6]!==o?(l=o?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:o}):null,e[6]=o,e[7]=l):l=e[7];let p;e[8]!==r?(p=r?t.jsx(Kl,{className:"size-4 shrink-0 text-muted-foreground/60"}):null,e[8]=r,e[9]=p):p=e[9];let b;return e[10]!==a||e[11]!==f||e[12]!==d||e[13]!==l||e[14]!==p?(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-left 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:a,style:c,children:[f,d,l,p]}),e[10]=a,e[11]=f,e[12]=d,e[13]=l,e[14]=p,e[15]=b):b=e[15],b},Sd=n=>{const e=le.c(10),{results:s,isSearching:i,onOpenFile:r}=n,{t:o}=me(),a=kt(Dn()??null);if(i){let l;e[0]!==o?(l=o("common.loading"),e[0]=o,e[1]=l):l=e[1];let p;return e[2]!==l?(p=t.jsx(ds,{loading:!0,message:l}),e[2]=l,e[3]=p):p=e[3],p}if(s.length===0){let l;e[4]!==o?(l=o("mobile.files.search.empty"),e[4]=o,e[5]=l):l=e[5];let p;return e[6]!==l?(p=t.jsx(ds,{message:l}),e[6]=l,e[7]=p):p=e[7],p}const c="overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",f=s.map(l=>t.jsx(Xi,{name:us(l.path),path:l.path,directory:!1,meta:wd(l.path,a),onClick:()=>r(l.path)},l.path));let d;return e[8]!==f?(d=t.jsx("div",{className:c,children:f}),e[8]=f,e[9]=d):d=e[9],d},ds=n=>{const e=le.c(7),{message:s,loading:i}=n,r=i===void 0?!1:i;let o;e[0]!==r?(o=r?t.jsx(Hl,{className:"size-5 animate-spin text-muted-foreground"}):t.jsx(ql,{className:"size-6 text-muted-foreground"}),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==s?(a=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[2]=s,e[3]=a):a=e[3];let c;return e[4]!==o||e[5]!==a?(c=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:[o,a]})}),e[4]=o,e[5]=a,e[6]=c):c=e[6],c},Qr="mobile-surface-root",Nd=16,Xr=320,Cd="cubic-bezier(0.22, 1, 0.36, 1)",Rd=n=>{const e=le.c(36),{onOpenMcpSettings:s}=n,{t:i}=me(),[r,o]=u.useState(!1),a=ht(Pd),c=is(Ad),f=Ot(Id);let d;e[0]!==a||e[1]!==r||e[2]!==f||e[3]!==c?(d=()=>{if(r)return;o(!0);const z=new Promise(Td);Promise.all([c({directory:a||null,silent:!0}),f({force:!0}),z]).finally(()=>o(!1))},e[0]=a,e[1]=r,e[2]=f,e[3]=c,e[4]=d):d=e[4];const l=d;let p;e[5]!==i?(p=i("settings.mcp.sidebar.actions.addServerTitle"),e[5]=i,e[6]=p):p=e[6];let b;e[7]!==i?(b=i("settings.mcp.sidebar.actions.addServerTitle"),e[7]=i,e[8]=b):b=e[8];let h,x;e[9]===Symbol.for("react.memo_cache_sentinel")?(h={touchAction:"manipulation"},x=t.jsx(X,{name:"add",className:"size-5"}),e[9]=h,e[10]=x):(h=e[9],x=e[10]);let S;e[11]!==s||e[12]!==p||e[13]!==b?(S=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":p,title:b,style:h,children:x}),e[11]=s,e[12]=p,e[13]=b,e[14]=S):S=e[14];let y;e[15]!==i?(y=i("mcpDropdown.actions.refreshAria"),e[15]=i,e[16]=y):y=e[16];let E;e[17]!==i?(E=i("mcpDropdown.actions.refreshAria"),e[17]=i,e[18]=E):E=e[18];let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w={touchAction:"manipulation"},e[19]=w):w=e[19];const N=r&&"animate-spin";let A;e[20]!==N?(A=J("size-5",N),e[20]=N,e[21]=A):A=e[21];let v;e[22]!==A?(v=t.jsx(X,{name:"refresh",className:A}),e[22]=A,e[23]=v):v=e[23];let P;e[24]!==r||e[25]!==l||e[26]!==v||e[27]!==y||e[28]!==E?(P=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:l,disabled:r,"aria-label":y,title:E,style:w,children:v}),e[24]=r,e[25]=l,e[26]=v,e[27]=y,e[28]=E,e[29]=P):P=e[29];let C;e[30]!==P||e[31]!==S?(C=t.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-1 px-2 pt-1",children:[S,P]}),e[30]=P,e[31]=S,e[32]=C):C=e[32];let R;e[33]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(fd,{active:!0,className:"h-full",listClassName:"max-h-none",hideHeader:!0,mobileListDensity:!0})}),e[33]=R):R=e[33];let k;return e[34]!==C?(k=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[C,R]}),e[34]=C,e[35]=k):k=e[35],k},Ed=({open:n,onClose:e,tab:s,onTabChange:i,pendingChangesDiff:r,onOpenPlan:o,onOpenMcpSettings:a,variant:c="drawer"})=>{const{t:f}=me(),d=u.useRef(null),l=u.useRef(null),[p,b]=u.useState(!1),[h,x]=u.useState(n),S=u.useRef(e);u.useEffect(()=>{S.current=e},[e]);const y=u.useRef(s);u.useEffect(()=>{y.current=s},[s]),sr(l,{enabled:c==="drawer"&&n,onLeftEdgeSwipe:()=>S.current()});const[E,w]=u.useState(()=>new Set);if(u.useEffect(()=>{n&&w(v=>{if(v.has(s))return v;const P=new Set(v);return P.add(s),P})},[n,s]),typeof document<"u"&&!d.current){let v=document.getElementById(Qr);v||(v=document.createElement("div"),v.id=Qr,document.body.appendChild(v)),d.current=v}if(u.useEffect(()=>{if(n){x(!0);const P=window.setTimeout(()=>b(!0),Nd);return()=>window.clearTimeout(P)}b(!1);const v=window.setTimeout(()=>x(!1),Xr+40);return()=>window.clearTimeout(v)},[n]),u.useEffect(()=>{if(!n)return;const v=document.body.style.overflow;c==="drawer"&&(document.body.style.overflow="hidden");const P=C=>{C.key!=="Escape"||y.current==="terminal"||ba(C.target)||S.current()};return document.addEventListener("keydown",P),()=>{c==="drawer"&&(document.body.style.overflow=v),document.removeEventListener("keydown",P)}},[n,c]),c==="drawer"&&!d.current)return null;const N=[{id:"changes",label:f("mobile.menu.changes"),icon:t.jsx(X,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"files",label:f("mobile.menu.files"),icon:t.jsx(X,{name:"file-text",className:"h-3.5 w-3.5"})},{id:"terminal",label:f("mobile.menu.terminal"),icon:t.jsx(X,{name:"terminal",className:"h-3.5 w-3.5"})},{id:"notes",label:f("contextRail.surface.notes"),icon:t.jsx(X,{name:"sticky-note",className:"h-3.5 w-3.5"})},{id:"mcp",label:f("mobile.menu.mcp"),icon:t.jsx(ga,{className:"h-3.5 w-3.5"})}],A=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:h?t.jsx(yl,{items:N,activeId:s,onSelect:v=>i(v),layoutMode:"fit",variant:"active-pill",nonCompositedIndicator:!0,inactiveTabsIconOnly:!0,className:"h-full"}):null}),t.jsx("button",{type:"button",className:"-mr-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(X,{name:"close",className:"size-5"})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[E.has("changes")?t.jsx("div",{className:J("h-full",s!=="changes"&&"hidden"),children:t.jsx(Ve,{children:t.jsx(gd,{visible:n&&s==="changes",initialDiff:r})})},r?`changes:${r.path}:${r.staged}`:"changes"):null,E.has("files")?t.jsx("div",{className:J("h-full",s!=="files"&&"hidden"),children:t.jsx(Ve,{children:t.jsx(kd,{})})}):null,E.has("terminal")?t.jsx("div",{className:J("h-full",s!=="terminal"&&"hidden"),children:t.jsx(Ve,{children:t.jsx(vl,{visible:n&&s==="terminal"})})}):null,E.has("notes")?t.jsx("div",{className:J("h-full",s!=="notes"&&"hidden"),children:t.jsx(Ve,{children:t.jsx(wl,{onActionComplete:e,onOpenPlan:o})})}):null,E.has("mcp")?t.jsx("div",{className:J("h-full",s!=="mcp"&&"hidden"),children:t.jsx(Ve,{children:t.jsx(Rd,{onOpenMcpSettings:a})})}):null]})]});return c==="panel"?t.jsx("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:A}):Lt.createPortal(t.jsx("section",{ref:l,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:p?"none":"translateX(100%)",transition:`transform ${Xr}ms ${Cd}`,visibility:h?"visible":"hidden",pointerEvents:n?"auto":"none"},children:A}),d.current)};function Pd(n){return n.currentDirectory}function Ad(n){return n.refresh}function Id(n){return n.loadMcpConfigs}function Td(n){return window.setTimeout(n,500)}function Dd(n){const e=le.c(4),s=2500,{uiFont:i}=xa(),[r,o]=u.useState(!1);let a,c;return e[0]!==s||e[1]!==i?(a=()=>{let f=!1;const d=()=>{f||o(!0)},l=()=>{requestAnimationFrame(()=>requestAnimationFrame(d))},p=Promise.all([ya(i).catch(Bd),document.fonts?.ready?.then(Od).catch(zd)??Promise.resolve(),mc.catch(Md)]).then(_d),b=new Promise(h=>{window.setTimeout(h,s)});return Promise.race([p,b]).then(l),()=>{f=!0}},c=[i,s],e[0]=s,e[1]=i,e[2]=a,e[3]=c):(a=e[2],c=e[3]),u.useEffect(a,c),r}function _d(){}function Md(){}function zd(){}function Od(){}function Bd(){}const Ld="openchamber",$d=n=>n.replace(/^\/+|\/+$/g,""),Fd=n=>{const e=$d(n.pathname).split("/").filter(Boolean);return n.host?[n.host,...e]:e};function Wd(n){if(typeof n!="string"||n.length===0)return null;let e;try{e=new URL(n)}catch{return null}if(e.protocol!==`${Ld}:`)return null;const s=Fd(e),i=(s[0]??"").toLowerCase(),r=s.slice(1),o=e.searchParams;switch(i){case"session":{const a=r[0]||o.get("id")||"";return a?{type:"session",sessionId:a,directory:o.get("dir")??void 0}:null}case"new":case"new-session":return{type:"new-session",directory:o.get("dir")??void 0,projectId:o.get("project")??void 0,agent:o.get("agent")??void 0,model:o.get("model")??void 0};case"sessions":{const a=o.get("filter");return{type:"sessions",filter:a==="attention"||a==="recent"||a==="all"?a:void 0}}case"status":return{type:"status"};case"settings":return{type:"settings",section:r[0]||o.get("section")||void 0};case"changes":return{type:"changes",path:r.join("/")||o.get("path")||void 0,staged:o.get("staged")==="true"};case"view":{const a=(r[0]||"").toLowerCase();return a==="changes"?{type:"changes"}:a==="files"||a==="mcp"||a==="instances"||a==="update"?{type:"view",target:a}:null}default:return null}}let Ke={},Zi=!1,cs=null;const Vd=n=>{switch(n.type){case"session":return Se.getState().setCurrentSession(n.sessionId,n.directory??null),!0;case"new-session":{const e=Se.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 Ke.openSessions?(Ke.openSessions(n.filter),!0):!1;case"status":return Ke.openSessions?(Ke.openSessions(),!0):!1;case"view":return Ke.openView?(Ke.openView(n.target),!0):!1;case"changes":return Ke.openChanges?(Ke.openChanges({path:n.path,staged:n.staged}),!0):!1;case"settings":return Ke.openSettings?(Ke.openSettings(n.section),!0):!1}},nr=()=>{if(!Zi||!cs)return;const n=cs;cs=null,Vd(n)||(cs=n)},eo=n=>{cs=n,nr()},Zr=n=>{const e=Wd(n);e&&eo(e)},Ud=n=>{Zi=n,nr()},Gd=n=>{const e=le.c(3);let s,i;e[0]!==n?(s=()=>(Ke=n,nr(),()=>{Ke===n&&(Ke={})}),i=[n],e[0]=n,e[1]=s,e[2]=i):(s=e[1],i=e[2]),u.useEffect(s,i)},Kd=n=>{const{ready:e}=n;u.useEffect(()=>{Ud(e)},[e]),u.useEffect(()=>{if(!Te())return;let s=!1;const i=[];return $t(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([127,5,128])).then(async({App:r})=>{if(s)return;const o=await r.addListener("appUrlOpen",a=>{Zr(a?.url)});if(s){o.remove();return}i.push(()=>{o.remove()})}).catch(()=>{}),$t(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([129,128])).then(async({PushNotifications:r})=>{if(s)return;const o=await r.addListener("pushNotificationActionPerformed",a=>{const c=a?.notification?.data,f=typeof c?.url=="string"?c.url:typeof c?.deeplink=="string"?c.deeplink:void 0;if(f){Zr(f);return}const d=typeof c?.sessionId=="string"?c.sessionId:void 0;d&&eo({type:"session",sessionId:d})});if(s){o.remove();return}i.push(()=>{o.remove()})}).catch(()=>{}),()=>{s=!0,i.forEach(r=>r())}},[])},Hd=()=>{if(typeof window>"u")return;const n=window.__OPENCHAMBER_APNS_ENV__;if(n==="development")return"sandbox";if(n==="production")return"production"},qd=()=>{if(typeof window>"u")return!1;const e=window.Capacitor?.getPlatform?.();return e==="ios"||e==="android"},Jd=n=>{const{enabled:e}=n,s=it(r=>r.nativeNotificationsEnabled),i=u.useRef(null);u.useEffect(()=>{if(!e||!s||!qd())return;let r=!1;const o=[];return $t(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([129,128])).then(async({PushNotifications:a})=>{if(r)return;let c=await a.checkPermissions().catch(()=>null);if(c?.receive!=="granted"&&(c=await a.requestPermissions().catch(()=>null)),c?.receive!=="granted")return;const f=await a.addListener("registration",l=>{i.current=l.value,gr()?.push?.registerApnsToken?.({token:l.value,platform:ri(),environment:Hd()})}),d=await a.addListener("registrationError",l=>{console.warn("[Push] APNs registration error:",l)});if(await a.register().catch(()=>{}),r){f.remove(),d.remove();return}o.push(()=>{f.remove()},()=>{d.remove()})}).catch(()=>{}),()=>{r=!0,o.forEach(a=>a())}},[e,s]),u.useEffect(()=>{if(s)return;const r=i.current;if(!r)return;i.current=null,gr()?.push?.unregisterApnsToken?.({token:r})},[s])},ei=n=>{const e=le.c(12),{side:s,isResizing:i,ariaLabel:r,handleProps:o}=n,a=s==="left"?"right-0":"left-0";let c;e[0]!==a?(c=J("absolute inset-y-0 z-50 w-6 cursor-col-resize touch-none",a),e[0]=a,e[1]=c):c=e[1];const f=s==="left"?"right-0":"left-0",d=i&&"bg-[var(--interactive-border)]";let l;e[2]!==f||e[3]!==d?(l=J("absolute inset-y-0 w-[3px] transition-colors",f,d),e[2]=f,e[3]=d,e[4]=l):l=e[4];let p;e[5]!==l?(p=t.jsx("div",{className:l}),e[5]=l,e[6]=p):p=e[6];let b;return e[7]!==r||e[8]!==o||e[9]!==c||e[10]!==p?(b=t.jsx("div",{className:c,role:"separator","aria-orientation":"vertical","aria-label":r,...o,children:p}),e[7]=r,e[8]=o,e[9]=c,e[10]=p,e[11]=b):b=e[11],b},Yd=320,Qd=380,ti=280,Xd=560,Zd=900;function si(n,e,s,i){const r=le.c(23),o=i===void 0?Xd:i,a=u.useRef(null);let c;r[0]!==s||r[1]!==o||r[2]!==e?(c=()=>{if(typeof window>"u")return s;const j=Number.parseInt(window.localStorage.getItem(e)??"",10);return Number.isFinite(j)?Math.min(o,Math.max(ti,j)):s},r[0]=s,r[1]=o,r[2]=e,r[3]=c):c=r[3];const[f,d]=u.useState(c),[l,p]=u.useState(!1),b=u.useRef(0),h=u.useRef(f),x=u.useRef(null),S=u.useRef(null);let y;r[4]!==o?(y=j=>Math.min(o,Math.max(ti,Math.round(j))),r[4]=o,r[5]=y):y=r[5];const E=y;let w;r[6]===Symbol.for("react.memo_cache_sentinel")?(w=j=>{const I=a.current;I&&(I.style.width=`${j}px`,I.style.minWidth=`${j}px`,I.style.maxWidth=`${j}px`,I.style.setProperty("--oc-ipad-sidebar-width",`${j}px`))},r[6]=w):w=r[6];const N=w;let A;r[7]!==f?(A=j=>{try{j.currentTarget.setPointerCapture(j.pointerId)}catch{}S.current=j.pointerId,b.current=j.clientX,h.current=f,x.current=f,p(!0),j.preventDefault()},r[7]=f,r[8]=A):A=r[8];const v=A;let P;r[9]!==E||r[10]!==n?(P=j=>{if(S.current!==j.pointerId)return;const I=j.clientX-b.current,$=E(h.current+(n==="left"?I:-I));x.current!==$&&(x.current=$,N($))},r[9]=E,r[10]=n,r[11]=P):P=r[11];const C=P;let R;r[12]!==E||r[13]!==e?(R=j=>{if(S.current!==j.pointerId)return;try{j.currentTarget.releasePointerCapture(j.pointerId)}catch{}const I=E(x.current??h.current);S.current=null,x.current=null,p(!1),d(I);try{window.localStorage.setItem(e,String(I))}catch{}},r[12]=E,r[13]=e,r[14]=R):R=r[14];const k=R;let z;r[15]!==v||r[16]!==k||r[17]!==C?(z={onPointerDown:v,onPointerMove:C,onPointerUp:k,onPointerCancel:k},r[15]=v,r[16]=k,r[17]=C,r[18]=z):z=r[18];const D=z;let _;return r[19]!==D||r[20]!==l||r[21]!==f?(_={asideRef:a,width:f,isResizing:l,handleProps:D},r[19]=D,r[20]=l,r[21]=f,r[22]=_):_=r[22],_}const ef=["general","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"],tf=1e3,sf=({onActiveConnectionDeleted:n})=>{const{t:e}=me();Al();const[s,i]=u.useState(!1),[r,o]=u.useState(null),[a,c]=u.useState(!1),[f,d]=u.useState("changes"),[l,p]=u.useState(null),[b,h]=u.useState("nav"),[x,S]=u.useState(null),y=it(q=>q.setSettingsPage),E=it(q=>q.wideChatLayoutEnabled),w=Mt(q=>q.available),N=Mt(q=>q.runtimeType),A=u.useMemo(()=>_n(),[]),v=Ot(q=>q.mcpServers),P=Ot(q=>q.setMcpDraft),C=Ot(q=>q.setSelectedMcp),R=u.useCallback(()=>{o(null),p(null)},[]),k=u.useCallback(q=>{o(q)},[]),z=u.useCallback(()=>{c(!1)},[]),D=u.useCallback(q=>{h(q),k("settings")},[k]),{enabled:_,roomyForPanels:j}=Rn(),$=Fa()==="portrait",g=Wa(),[O,V]=u.useState(()=>Va().roomyForPanels),B=u.useCallback(()=>{V(q=>!q)},[]);u.useEffect(()=>{_||V(!1)},[_]);const L=u.useCallback(()=>{S(null),d("files"),c(!0)},[]);u.useEffect(()=>wi(q=>{if(q.type!=="file-open-request")return;const de=q.directory??ht.getState().currentDirectory;de&&(it.getState().openContextFile(de,q.path),L())}),[L]);const ie=u.useCallback((q=null)=>{S(q),d("changes"),c(!0)},[]),se=si("left","openchamber.ipad.leftSidebarWidth",Yd),te=si("right","openchamber.ipad.rightSidebarWidth",Qd,Zd),M=j,G=M&&a?te.width:0,Y=_&&O?se.width:0;u.useEffect(()=>{if(typeof document>"u")return;const q=document.documentElement;return q.style.setProperty("--oc-chat-inset-left",`${Y}px`),q.style.setProperty("--oc-chat-inset-right",`${G}px`),()=>{q.style.removeProperty("--oc-chat-inset-left"),q.style.removeProperty("--oc-chat-inset-right")}},[Y,G]),u.useEffect(()=>{if(typeof document>"u")return;const q=document.documentElement;return q.classList.toggle("wide-chat-layout",E),()=>q.classList.remove("wide-chat-layout")},[E]),u.useEffect(()=>{if(typeof document>"u")return;const q=_&&($||g),de=document.documentElement;return de.classList.toggle("oc-keep-draft-starters",q),()=>de.classList.remove("oc-keep-draft-starters")},[g,_,$]);const H=u.useMemo(()=>({openChanges:({diffPath:q,staged:de}={})=>{ie(q?{path:q,staged:de===!0}:null)},openFiles:()=>L(),openSettings:()=>D("nav")}),[ie,L,D]),Q=u.useMemo(()=>({openSessions:()=>{_?V(!0):i(!0)},openView:q=>{if(q==="files"){L();return}if(q==="mcp"){d("mcp"),c(!0);return}k(q)},openChanges:({path:q,staged:de}={})=>{ie(q?{path:q,staged:de===!0}:null)},openSettings:q=>{q&&y(q),D(q?"page-content":"nav")}}),[_,ie,L,D,k,y]);Gd(Q);const ne=u.useRef(null);sr(ne,{onLeftEdgeSwipe:()=>{_?V(!0):i(!0)},onRightEdgeSwipe:()=>c(!0)});const re=u.useRef(null),ce=u.useCallback(q=>{re.current=q},[]),ue=u.useCallback(()=>l?(p(null),!0):r==="settings"&&re.current?.()?!0:r?(R(),!0):a?(z(),!0):s?(i(!1),!0):!1,[r,R,z,l,s,a]);Ua(ue);const K=!A&&w&&(N==="desktop"||N==="web"),oe=_?"dialog":"fullscreen",pe=u.useMemo(()=>({instanceLabel:A?os():null,onOpenInstances:A?()=>k("instances"):void 0,onOpenSettings:()=>D("nav"),onOpenUsage:()=>k("usage"),onOpenUpdate:K?()=>k("update"):void 0}),[D,k,A,K]),ke=u.useCallback(()=>{const q="new-mcp-server";let de=q,Ce=1;for(;v.some(Ae=>Ae.name===de);)de=`${q}-${Ce}`,Ce+=1;P({name:de,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",oauthCallbackPort:"",oauthAuthServerMetadataUrl:"",protocol:"legacy",timeoutStartup:"",timeoutCatalog:"",timeoutExecution:"",codemode:!0,disabled:!1}),C(de),y("mcp"),D("page-content")},[v,D,P,C,y]);return t.jsx(Ga,{actions:H,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:[_?t.jsxs("aside",{ref:se.asideRef,className:J("relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!O&&"border-r-0"),style:{width:O?se.width:0,minWidth:O?se.width:0,maxWidth:O?se.width:0,"--oc-ipad-sidebar-width":`${se.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:se.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!O,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:J("flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",se.isResizing&&"pointer-events-none",!O&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Ve,{children:t.jsx(Ur,{open:!0,variant:"sidebar",onOpenChange:q=>{!q&&!j&&V(!1)},footer:pe})})}),O?t.jsx(ei,{side:"left",isResizing:se.isResizing,ariaLabel:e("sidebar.resize.leftPanelAria"),handleProps:se.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(ku,{onOpenSessions:()=>_?B():i(!0),onOpenWorkspace:()=>c(!0),compactTitle:_}),t.jsx("main",{ref:ne,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(Ve,{children:t.jsx(Il,{})})})})]}),_?null:t.jsx(Ur,{open:s,onOpenChange:i,footer:pe}),t.jsxs("aside",{ref:te.asideRef,className:J("relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!G&&"border-l-0"),style:{width:G,minWidth:G,maxWidth:G,"--oc-ipad-sidebar-width":`${te.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:te.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!G,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:J("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",te.isResizing&&"pointer-events-none",!G&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Ve,{children:t.jsx(Ed,{open:a,onClose:z,tab:f,onTabChange:d,pendingChangesDiff:x,onOpenPlan:p,onOpenMcpSettings:ke,variant:M?"panel":"drawer"})})}),G?t.jsx(ei,{side:"right",isResizing:te.isResizing,ariaLabel:e("sidebar.resize.rightPanelAria"),handleProps:te.handleProps}):null]}),l?t.jsx(Tt,{open:!0,variant:oe,onClose:()=>p(null),ariaLabel:l.title,title:l.title,children:t.jsx(Ve,{children:t.jsx(zl,{savedProjectPlan:{projectRef:l.projectRef,planId:l.id},onNavigatedToChat:()=>{R(),z()}})})}):null,r==="instances"&&A?t.jsx(Tt,{open:!0,variant:oe,dialogAlign:"app",onClose:R,ariaLabel:e("mobile.menu.instances"),title:e("mobile.menu.instances"),children:t.jsx(Ru,{onConnect:R,onActiveConnectionDeleted:n})}):null,r==="settings"?t.jsx(Tt,{open:!0,variant:oe,dialogAlign:"app",onClose:R,ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(Ve,{children:t.jsx(_l,{forceMobile:!0,isWindowed:!0,initialMobileStage:b,registerBackHandler:ce,visiblePageSlugs:ef.filter(q=>!(A&&q==="about")),onClose:R})})}):null,r==="usage"?t.jsx(Tt,{open:!0,variant:oe,dialogAlign:"app",onClose:R,ariaLabel:e("usageStats.title"),title:e("usageStats.title"),children:t.jsx(Ve,{children:t.jsx(Tl,{})})}):null,r==="update"?t.jsx(Tt,{open:!0,variant:oe,dialogAlign:"app",onClose:R,ariaLabel:e("mobile.menu.update"),title:e("mobile.menu.update"),children:t.jsx(Ve,{children:t.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:t.jsx(Ml,{initialUpdateDialogOpen:!0})})})}):null]})})};function ni({apis:n}){const{t:e}=me(),s=He(M=>M.initializeApp),i=He(M=>M.isInitialized),r=He(M=>M.isConnected),o=He(M=>M.connectionPhase),a=He(M=>M.providers.length),c=He(M=>M.agents.length),f=He(M=>M.loadProviders),d=He(M=>M.loadAgents),l=ht(M=>M.currentDirectory),p=Se(M=>M.error),b=Se(M=>M.clearError),h=it(M=>M.setIsMobile),x=va(M=>M.refreshStatus),S=wa(M=>M.refreshStatus),y=ja(M=>M.setPlanModeEnabled),E=We(M=>M.projects),[w,N]=u.useState(0),[A,v]=u.useState(0),[P,C]=u.useState(!1),[R,k]=u.useState("pending"),[z,D]=u.useState(null),_=u.useMemo(()=>os(),[]),[,j]=u.useReducer(M=>M+1,0),I=u.useMemo(()=>_n(),[]),$=u.useRef(0),g=u.useRef(0),O=u.useCallback(()=>{const M=st(),G=g.current+1;if(g.current=G,!M){ns("resume:auto-connect",{}),rs();return}ns("resume:reprobe",{});const Y=()=>{s(),x(n.github,{force:!0}),S(n.linear,{force:!0}),a===0&&f({source:"mobileApp:nativeResume"}),c===0&&d({source:"mobileApp:nativeResume"})},H=ne=>{ns("resume:disconnect",{reason:ne}),Dt({apiBaseUrl:"",clientToken:null,runtimeKey:Es}),N(re=>re+1)};Ms().then(ne=>{if(g.current===G){if(ne==="no-connection"){H("no-connection");return}if(ne==="needs-login"){D({kind:"auth-expired",label:os()??""}),H("needs-login");return}if(ne==="unreachable"){const re=[4e3,1e4],ce=ue=>{window.setTimeout(()=>{if(g.current!==G)return;const K=ue===re.length-1;Ms({fast:!K}).then(oe=>{if(g.current===G&&oe!=="switched"){if(oe==="unchanged"){Y();return}if(oe==="needs-login"){D({kind:"auth-expired",label:os()??""}),H("retry-needs-login");return}if(!K){ce(ue+1);return}H(`retry-${oe}`)}})},re[ue])};ce(0);return}ne!=="switched"&&Y()}});const Q=Date.now();Q-$.current>=tf&&($.current=Q,window.dispatchEvent(new Event("openchamber:system-resume")))},[c,n.github,n.linear,s,d,f,a,x,S]);ka(),Sa(O),u.useEffect(()=>{if(!I)return;let M;const G=()=>{window.clearTimeout(M),M=window.setTimeout(()=>O(),1500)};return window.addEventListener("online",G),()=>{window.removeEventListener("online",G),window.clearTimeout(M)}},[I,O]),u.useEffect(()=>{if(I)return br.subscribe((M,G)=>{M.state==="expired"&&G.state!=="expired"&&(O(),br.getState().markAuthenticated())})},[I,O]),u.useEffect(()=>(xr(n),()=>xr(null)),[n]),u.useEffect(()=>oi(M=>{if(ns("endpoint:changed",{runtimeKey:M.runtimeKey||"none",previousRuntimeKey:M.previousRuntimeKey||"none",connected:!!M.apiBaseUrl}),!!M.runtimeKey&&M.runtimeKey===M.previousRuntimeKey){kl(),j();return}Sl(M),v(Y=>Y+1),N(Y=>Y+1)}),[]),u.useEffect(()=>{if(!I||r||st()){k("done");return}let M=!1;return k("attempting"),(async()=>{const G=await rs().catch(()=>({status:"no-candidate"}));M||(G.status==="unreachable"?D({kind:"unreachable",label:G.label}):G.status==="needs-login"&&D({kind:"auth-expired",label:G.label}),k("done"),G.status==="unreachable"&&rs({fast:!1,skipIfConnected:!0}).catch(()=>null))})(),()=>{M=!0}},[]),u.useEffect(()=>{if(!I||!st())return;let M=!1;const G=Y=>{ns("cold-launch:drop",{kind:Y?.kind??"unknown"}),Y&&D(Y),Dt({apiBaseUrl:"",clientToken:null,runtimeKey:Es}),N(H=>H+1)};return Ms().then(async Y=>{if(M||Y==="switched"||Y==="unchanged")return;const H=os();if(Y==="needs-login"){G({kind:"auth-expired",label:H??""});return}if(Y==="unreachable"){G(H?{kind:"unreachable",label:H}:null),rs({fast:!1,skipIfConnected:!0}).catch(()=>null);return}const Q=await rs().catch(()=>({status:"no-candidate"}));M||Q.status==="connected"||(Q.status==="needs-login"?G({kind:"auth-expired",label:Q.label}):Q.status==="unreachable"?G({kind:"unreachable",label:Q.label}):G(null))}),()=>{M=!0}},[]),u.useEffect(()=>{h(!0)},[h]),u.useEffect(()=>{I&&!st()||s()},[w,s,I]),u.useEffect(()=>{r&&(a===0&&f({source:"mobileApp:recovery"}),c===0&&d({source:"mobileApp:recovery"}))},[c,r,d,f,a]);const V=u.useRef(!1),[B,L]=u.useState(I);u.useEffect(()=>{if(!I||!r||V.current)return;if(Se.getState().currentSessionId){V.current=!0,L(!1);return}const M=Gt(),G=Na(M);if(!G){V.current=!0,L(!1);return}let Y=!1;const H=window.setTimeout(()=>L(!1),6e3);return(async()=>{const Q=await In().catch(()=>null);if(Y)return;if(!Q){L(!1);return}V.current=!0;const ne=Q.activeSessions.find(ce=>ce.id===G.sessionId);if(!ne){Ca(M),L(!1);return}const re=Se.getState();re.currentSessionId||re.setCurrentSession(ne.id,Cn(ne)??G.directory??void 0),L(!1)})(),()=>{Y=!0,window.clearTimeout(H)}},[w,r,I]),u.useEffect(()=>{r&&yr.setDirectory(l)},[l,r]),u.useEffect(()=>{r&&(x(n.github,{force:!0}),S(n.linear,{force:!0}))},[n.github,n.linear,r,x,S]),u.useEffect(()=>{if(!r||E.length===0)return;let M=!1;return(async()=>{const Y=new Map(Se.getState().availableWorktreesByProject);if(await Promise.all(E.map(async ne=>{const re=ne.path.replace(/\\/g,"/").replace(/\/+$/,"");if(re)try{if(!(Fe.getState().directories.get(re)?.isGitRepo??await $t(()=>import("./useAppFontEffects-BxrtCnfR.js").then(oe=>oe.ll),__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])).then(oe=>oe.checkIsGitRepository(re))))return;const K=await xi({id:ne.id,path:re});if(M)return;Y.set(re,K)}catch{}})),M)return;const H=yi(E,Y),Q=Se.getState().availableWorktreesByProject;La(H,Q)||Se.setState({availableWorktrees:[...H.values()].flat(),availableWorktreesByProject:H})})(),()=>{M=!0}},[r,E]),u.useEffect(()=>{if(!r)return;let M=!1;const G=wi(Y=>{Y.type==="worktree-changed"&&$a(E,Y.directories,()=>M)});return()=>{M=!0,G()}},[r,E]),u.useEffect(()=>{let M=!1;return(async()=>{const Y=await Sn("/health",{method:"GET"}).catch(()=>null);if(!Y||!Y.ok||M)return;const H=await Y.json().catch(()=>null);if(!H||M)return;const Q=H.planModeExperimentalEnabled;y(Q===!0||Q===1||Q==="1"||Q==="true")})(),()=>{M=!0}},[y]),u.useEffect(()=>{if(!p)return;const M=window.setTimeout(()=>b(),5e3);return()=>window.clearTimeout(M)},[b,p]),u.useEffect(()=>{if(!(!r&&(I?!!st():!0))){C(!1);return}const G=window.setTimeout(()=>{C(!0)},I?4e3:8e3);return()=>window.clearTimeout(G)},[r,I,w,A]),Ra(),Ea({enabled:!0}),Nl(),Pa(),Aa(),Cl(),Jd({enabled:I&&r}),Kd({ready:I&&r&&i});const ie=Dd(),se=!r&&o==="reconnecting";if(!ie)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(_t,{width:120,height:120,isAnimated:!0,variant:"splash"})});const te=!!st();return I&&(!te||!r&&!se)?te?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(_t,{width:120,height:120,isAnimated:!P,variant:"splash"}),P?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:e("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:e("mobile.connect.recovery.description")})]}),t.jsx(ge,{type:"button",variant:"outline",onClick:()=>{Dt({apiBaseUrl:"",clientToken:null,runtimeKey:Es}),N(M=>M+1)},children:e("mobile.connect.cancelPassword")})]}):null]})}):R!=="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(_t,{width:120,height:120,isAnimated:!0,variant:"splash"}),_?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:e("mobile.connect.splash.connectingTo")}),t.jsxs("p",{className:"typography-small text-foreground",children:[_,t.jsx(Ia,{})]})]}):null]}):t.jsx(t.Fragment,{children:t.jsx(au,{onConnected:()=>N(M=>M+1),notice:z})}):!r&&!se?P?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:e("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:e("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(_t,{width:120,height:120,isAnimated:!0,variant:"splash"})}):t.jsx(Ve,{children:t.jsx(Ta,{sdk:yr.getSdkClient(),directory:l||"",children:t.jsx(Da,{apis:n,children:t.jsx(_a,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[t.jsx(Rl,{ready:!I||!B,animated:!0}),t.jsx(Ma,{embeddedBackgroundWorkEnabled:i}),t.jsx(El,{}),t.jsx(jc,{}),t.jsx(sf,{onActiveConnectionDeleted:()=>{Dt({apiBaseUrl:"",clientToken:null,runtimeKey:Es}),N(M=>M+1)}}),t.jsx(za,{}),t.jsx(Oa,{}),t.jsx(Ba,{position:"top-center",offset:"calc(var(--oc-safe-area-top, 0px) + 16px)"}),i?t.jsx(Pl,{}):null]})})})},A)})}function nf(n){const e=le.c(4),s=u.useSyncExternalStore(rf,st,st);if(_n()&&!s){let r;return e[0]!==n?(r=t.jsx(ni,{...n}),e[0]=n,e[1]=r):r=e[1],r}let i;return e[2]!==n?(i=t.jsx(jl,{children:t.jsx(ni,{...n})}),e[2]=n,e[3]=i):i=e[3],i}function rf(n){return oi(()=>n())}const of=()=>{Xa(),vo().then(()=>{Promise.all([wo(),Za()]).catch(n=>{console.error("[mobile-main] settings init failed:",n)}),el(),tl(),sl()}).catch(n=>{console.error("[mobile-main] appearance init failed:",n)}).finally(()=>{pc()})};function Op(n){window.__OPENCHAMBER_SURFACE__="mobile",Ka(),of(),wc(),Ha();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");const i=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",r=i?{...n,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:n,o=t.jsx(nf,{apis:r});mo.createRoot(e).render(t.jsx(bn.StrictMode,{children:t.jsx(qa,{children:t.jsx(Ja,{children:t.jsx(Ya,{children:t.jsx(Dl,{children:i?o:t.jsx(Qa,{children:o})})})})})}))}export{Op as renderMobileApp};
25
+ `)}`.trim()),ue([])},[]),Zs=u.useCallback(async()=>{if(!l)return;const T=Re.map(F=>F.path).sort();if(T.length===0){fe.error(o("gitView.toast.selectFileToDescribe"));return}re(!0);try{const{message:F}=await wr(l,T);M(F.subject?.trim()??""),ue(Array.isArray(F.highlights)?F.highlights:[])}catch(F){fe.error(F instanceof Error?F.message:o("gitView.toast.generateCommitMessageFailed"))}finally{re(!1)}},[l,Re,o]),Pt=async(T={})=>{if(!l)return;if(!te.trim()){fe.error(o("gitView.toast.enterCommitMessage"));return}const F=Re.map(Z=>Z.path).sort();if(F.length===0){fe.error(o("gitView.toast.selectFileToCommit"));return}se(T.pushAfter?"commitAndPush":"commit");try{if(await a.createGitCommit(l,te.trim(),{files:F}),fe.success(o("gitView.toast.commitCreated")),M(""),ue([]),T.pushAfter){const Z=p?.tracking?.split("/")[0],we=Oe.find(Ze=>Ze.name===Z)??Oe[0];if(!we)throw new Error(o("mobile.changes.noRemote"));L("sync"),await Sr({git:a,directory:l,remote:we,dirtyWorktreeError:o("gitView.toast.commitOrStashBeforeSync"),onPushed:Ze=>{fe.success(o("gitView.toast.pushedToUpstream",{name:Ze.pushed[0].remote}))}}),await _e(!1),await Rt()}else await _e(!1)}catch(Z){fe.error(Z instanceof Error?Z.message:o("gitView.toast.createCommitFailed"))}finally{se(null),T.pushAfter&&L(null)}},js=u.useMemo(()=>{const T=[];return Re.length>0&&T.push({id:"staged",title:o("gitView.changes.stagedTitle"),entries:Re,statsScope:"staged",actionSymbol:"-",actionAllLabel:o("gitView.changes.unstageAllAria"),getActionLabel:F=>o("gitView.changes.unstageFileAria",{path:F}),onActionFile:F=>{mt([F],"unstage")},onActionAll:F=>{mt(F,"unstage")},onViewDiff:F=>Yt(F,!0),onRevertFile:Qt,showRevertActions:!1,accent:!0}),ot.length>0&&T.push({id:"unstaged",title:o("gitView.changes.title"),entries:ot,statsScope:"working",actionSymbol:"+",actionAllLabel:o("gitView.changes.stageAllAria"),getActionLabel:F=>o("gitView.changes.stageFileAria",{path:F}),onActionFile:F=>{mt([F],"stage")},onActionAll:F=>{mt(F,"stage")},onViewDiff:F=>Yt(F,!1),onRevertFile:Qt}),T},[Qt,Yt,mt,Re,o,ot]),lt=T=>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 px-3 text-foreground",children:[s?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(X,{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:p?.current||l||""})]}),c===!1&&Array.isArray(d)&&d.length>0?t.jsx(bl,{repositories:d,selectedRepository:f??null,onSelectRepository:F=>{n&&w(n,F)},repositoryRoot:n??void 0}):null]}),t.jsx("div",{className:"min-h-0 flex-1",children:T})]});if(!l)return lt(t.jsx(qe,{message:o("gitView.empty.selectSessionOrDirectory")}));if(c===!1&&h!==!0)return lt(t.jsx(xl,{rootIsGitRepo:c,resolvedIsGitRepo:h,nestedRepos:d,onRetryDiscovery:()=>{n&&E(n,{force:!0})}}));if(x&&h===null)return lt(t.jsx(qe,{loading:!0,message:o("gitView.loading.checkingRepository")}));if(I.type==="diff")return t.jsx(Yr,{path:I.path,diff:bs,staged:I.staged,fileExists:!!Qs,unavailableReason:Ae?.key===`${l}\0${I.path}`?Ae.reason:null,error:Ce,onBack:()=>V({type:"list"}),onRetry:()=>ut(T=>T+1)});const Xt=o(j==="pr"?"session.githubIntegration.tabs.pullRequests":j==="branch"?"diffView.scope.branch":j==="commit"?"commitComparison.mode":"mobile.nav.changes"),Zt=j==="branch"&&Ue.base?pl(Ue.base):j==="commit"?dt?.slice(0,8):j==="pr"&&ft?`#${ft.number}`:null;if(Ye&&Qe)return t.jsx(Yr,{path:Ye,subtitle:[Xt,Zt].filter(Boolean).join(" · "),diff:Qe.status==="ready"?Qe.diff:null,fileExists:!je.files||je.files.some(T=>T.path===Ye),error:je.error??(Qe.status==="error"?Qe.message:null),onBack:()=>V(It),onRetry:()=>{je.error&&je.refresh(),Jt(T=>T+1)}});const ks=()=>j==="pr"&&!ft?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(qe,{loading:nt.loading,message:nt.error??(nt.loading?o("session.githubPrPicker.loading.pullRequests"):o("pullRequestComparison.select"))}),!nt.loading&&t.jsx(Nr,{mobile:!0,comparison:nt})]}):j==="branch"&&!Ue.base?t.jsx(qe,{loading:!Ue.resolved,message:Ue.resolved?o("gitView.pr.toast.baseBranchRequired"):o("diffView.branch.resolvingBase")}):j==="commit"&&!dt?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[$e.loading&&t.jsx(X,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:$e.loading?o("diffView.state.loadingChanges"):$e.error??o("commitComparison.noCommits")}),$e.error&&t.jsx(ge,{variant:"outline",size:"lg",onClick:()=>{$e.refresh()},children:o("diffView.actions.retry")})]}):je.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:je.error}),t.jsx(ge,{variant:"outline",size:"lg",onClick:()=>{je.refresh()},children:o("diffView.actions.retry")})]}):qt?qt.length===0?t.jsx(qe,{icon:j==="branch",message:j==="pr"?o("walkthrough.blocked.emptyDiff.description"):j==="commit"?o("commitComparison.emptyDiff"):o("diffView.branch.empty",{base:Zt??""})}):t.jsx(xd,{files:qt,onSelect:T=>{je.key&&V({type:"comparison",path:T,sourceKey:je.key})}}):t.jsx(qe,{loading:!0,message:o("diffView.state.loadingChanges")});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[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:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(X,{name:"close",className:"size-5"})}):null,t.jsxs(ca,{open:$,onOpenChange:g,children:[t.jsx(ua,{asChild:!0,children:t.jsxs(ge,{variant:"outline",className:da({size:"default"}),"data-mobile-comparison-trigger":!0,"aria-label":o("diffView.scope.selectorAria"),children:[t.jsx("span",{children:Xt}),t.jsx(X,{name:"arrow-down-s",className:"size-4"})]})}),t.jsx(fa,{align:"start",children:t.jsxs(ma,{value:j,onValueChange:T=>{(T==="working"||T==="branch"||T==="commit"||T==="pr")&&O(T)},children:[t.jsx(As,{value:"working",className:"min-h-8 items-center",children:o("mobile.nav.changes")}),hs&&t.jsx(As,{value:"branch",className:"min-h-8 items-center",children:o("diffView.scope.branch")}),t.jsx(As,{value:"commit",className:"min-h-8 items-center",children:o("commitComparison.mode")}),t.jsx(As,{value:"pr",className:"min-h-8 items-center",children:o("session.githubIntegration.tabs.pullRequests")})]})})]}),r&&j==="branch"&&t.jsx(ic,{mobile:!0,branches:b?.all??[],currentBranch:Ne,base:Ue.base,onSelect:T=>{Ne&&Js(l,Ne,T)}},JSON.stringify([k,Ne])),r&&j==="commit"&&t.jsx(oc,{mobile:!0,commits:$e.commits,selectedHash:dt,loading:$e.loading,error:$e.error,onSelect:$e.select,onRefresh:()=>{$e.refresh()}},JSON.stringify([k,Ne])),r&&j==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(Nr,{mobile:!0,comparison:nt},JSON.stringify([k,Ne])),ft&&t.jsx(ge,{variant:"ghost",size:"sm",disabled:je.loading,"aria-label":o("session.githubIssuePicker.actions.refresh"),onClick:()=>{je.refresh()},children:t.jsx(X,{name:"refresh",className:"size-4"})})]})]}),j==="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(hl,{currentBranch:p?.current,localBranches:Ee,remoteBranches:xs,branchInfo:b?.branches,currentBranchAhead:p?.ahead,onCheckout:T=>{ys(T)},onCreate:Xs,remotes:Oe,disabled:x,directory:l,switchBlockedNotice:(p?.files?.length??0)>0?o("gitView.branch.switchBlockedNotice"):null})}),t.jsx(gl,{syncAction:B,remotes:Oe,onFetch:T=>{vs("fetch",T)},onSync:T=>{vs("sync",T)},disabled:ie!==null||x,aheadCount:p?.ahead??0,behindCount:p?.behind??0,trackingRemoteName:p?.tracking?.split("/")[0],hasUncommittedChanges:Ge.length>0})]}),j!=="working"?t.jsx("div",{className:"min-h-0 flex-1",children:ks()}):Ge.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(Yl,{groups:js,diffStats:p?.diffStats,revertingPaths:G,onRevertAll:Et,isRevertingAll:H,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:oe})}),t.jsx("div",{className:"shrink-0 border-t border-border/70 px-4 pb-4 pt-3",children:t.jsx(Ql,{stagedCount:Re.length,commitMessage:te,onCommitMessageChange:M,generatedHighlights:ce,onInsertHighlights:ws,onGenerateMessage:Zs,isGeneratingMessage:ne,onCommit:()=>{Pt({pushAfter:!1})},onCommitAndPush:()=>{Pt({pushAfter:!0})},commitAction:ie,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(qe,{icon:!0,message:o("gitView.empty.cleanTitle"),description:o("mobile.changes.cleanDescription")})}),t.jsx(Xl,{open:De!==null,onOpenChange:T=>{T||Be(null)},targetBranch:De??"",changedFileCount:p?.files?.length??0,onCommitAndSwitch:async(T,F)=>{const Z=De;if(!Z||!l)return;const we=p?.current??null;await a.createGitCommit(l,T,{addAll:!0});let Ze=null;if(F){const en=p?.tracking?.split("/")[0],At=Oe.find(tn=>tn.name===en)??Oe[0];try{if(!At)throw new Error(o("mobile.changes.noRemote"));await a.gitPush(l,p?.tracking?{remote:At.name}:{remote:At.name,branch:we??void 0,options:["--set-upstream"]}),Ze=At.name}catch{fe.error(o("gitView.dirtySwitch.pushFailed")),await _e(),Be(null);return}}fe.success(we?Ze?o("gitView.toast.pushedToUpstream",{name:Ze}):o("gitView.dirtySwitch.committedNotPushed",{branch:we}):o("gitView.toast.commitCreated")),await _e(),Be(null),await at(Z)},onGenerateMessage:async()=>{if(!l)return"";const T=(p?.files??[]).map(Z=>Z.path).sort(),{message:F}=await wr(l,T);return F.subject?.trim()??""},onRevertAndSwitch:async()=>{const T=De;if(!T||!l)return;await Et((p?.files??[]).map(Z=>Z.path));const F=await a.getGitStatus(l);if(!F.isClean&&(F.files?.length??0)>0){fe.error(o("gitView.dirtySwitch.revertIncomplete"));return}Be(null),await at(T)}})]})},qe=n=>{const e=le.c(13),{message:s,description:i,loading:r,icon:o}=n,a=r===void 0?!1:r,c=o===void 0?!1:o;let f;e[0]!==a?(f=a?t.jsx(X,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,e[0]=a,e[1]=f):f=e[1];let d;e[2]!==c?(d=c?t.jsx(X,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e[2]=c,e[3]=d):d=e[3];let l;e[4]!==s?(l=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[4]=s,e[5]=l):l=e[5];let p;e[6]!==i?(p=i?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i}):null,e[6]=i,e[7]=p):p=e[7];let b;return e[8]!==f||e[9]!==d||e[10]!==l||e[11]!==p?(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,d,l,p]})}),e[8]=f,e[9]=d,e[10]=l,e[11]=p,e[12]=b):b=e[12],b},Yr=n=>{const e=le.c(31),{path:s,subtitle:i,diff:r,staged:o,fileExists:a,unavailableReason:c,error:f,onBack:d,onRetry:l}=n,p=o===void 0?!1:o,b=c===void 0?null:c,{t:h}=me();let x;e[0]!==s?(x=pa(s)||"text",e[0]=s,e[1]=x):x=e[1];const S=x;let y;e[2]!==h?(y=h("header.actions.backAria"),e[2]=h,e[3]=y):y=e[3];let E;e[4]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx(X,{name:"arrow-left",className:"size-5"}),e[4]=E):E=e[4];let w;e[5]!==d||e[6]!==y?(w=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":y,onClick:d,children:E}),e[5]=d,e[6]=y,e[7]=w):w=e[7];let N;e[8]!==s?(N=t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:s}),e[8]=s,e[9]=N):N=e[9];let A;e[10]!==i?(A=i&&t.jsx("p",{className:"truncate typography-meta text-muted-foreground",children:i}),e[10]=i,e[11]=A):A=e[11];let v;e[12]!==N||e[13]!==A?(v=t.jsxs("div",{className:"min-w-0 flex-1 px-2",children:[N,A]}),e[12]=N,e[13]=A,e[14]=v):v=e[14];let P;e[15]!==w||e[16]!==v?(P=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:[w,v]}),e[15]=w,e[16]=v,e[17]=P):P=e[17];let C;e[18]!==r||e[19]!==f||e[20]!==a||e[21]!==S||e[22]!==l||e[23]!==s||e[24]!==p||e[25]!==h||e[26]!==b?(C=t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:a?b==="nested_repository"?t.jsx(qe,{icon:!0,message:h("diffView.unavailable.nestedRepositoryTitle"),description:h("diffView.unavailable.nestedRepositoryDescription")}):b==="untracked_directory"?t.jsx(qe,{icon:!0,message:h("diffView.unavailable.untrackedDirectoryTitle"),description:h("diffView.unavailable.untrackedDirectoryDescription")}):f?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:h("mobile.changes.diffDetail.loadFailed")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:f}),t.jsx(ge,{type:"button",size:"sm",variant:"outline",onClick:l,children:h("diffView.actions.retry")})]})}):r?r.submodule?t.jsx("div",{className:"p-3",children:t.jsx(uc,{state:r.submodule,staged:p})}):r.isBinary?t.jsx(qe,{icon:!0,message:h("diffView.binary.unavailable")}):ha(s)&&!r.fileDiff?t.jsx(qe,{icon:!0,message:h("mobile.changes.diffDetail.imageUnavailable")}):t.jsx(Ks,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:t.jsx(fc,{original:r.original,modified:r.modified,fileDiff:r.fileDiff,language:S,fileName:s,renderSideBySide:!1,wrapLines:!0,layout:"inline"})}):t.jsx(qe,{loading:!0,message:h("diffView.state.loadingDiff")}):t.jsx(qe,{icon:!0,message:h("mobile.changes.diffDetail.missingTitle"),description:h("mobile.changes.diffDetail.missingDescription")})}),e[18]=r,e[19]=f,e[20]=a,e[21]=S,e[22]=l,e[23]=s,e[24]=p,e[25]=h,e[26]=b,e[27]=C):C=e[27];let R;return e[28]!==P||e[29]!==C?(R=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[P,C]}),e[28]=P,e[29]=C,e[30]=R):R=e[30],R},xd=n=>{const e=le.c(12),{files:s,onSelect:i}=n,{t:r}=me();let o;e[0]!==r?(o=r("gitView.changes.changedFilesAria"),e[0]=r,e[1]=o):o=e[1];let a;if(e[2]!==s||e[3]!==i||e[4]!==r){let f;e[6]!==i||e[7]!==r?(f=d=>{const l=d.status==="A"?r("diffView.change.new"):d.status==="D"?r("diffView.change.deleted"):d.status==="R"?r("diffView.change.renamed"):d.status==="C"?r("diffView.change.copied"):r("diffView.change.modified"),p=d.status==="A"?"var(--status-success)":d.status==="D"?"var(--status-error)":d.status==="R"||d.status==="C"?"var(--status-info)":"var(--status-warning)";return t.jsx("li",{children:t.jsxs(ge,{variant:"ghost",size:"lg",className:"w-full justify-start gap-2.5 text-left normal-case",onClick:()=>i(d.path),children:[t.jsx("span",{className:"w-4 shrink-0 text-center typography-meta font-semibold uppercase",style:{color:p},"aria-label":l,children:d.status}),t.jsx(vi,{filePath:d.path,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label",title:d.path,children:d.path}),(d.insertions>0||d.deletions>0)&&t.jsxs("span",{className:"shrink-0 typography-meta text-muted-foreground",children:["+",d.insertions," -",d.deletions]}),t.jsx(X,{name:"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground"})]})},d.path)},e[6]=i,e[7]=r,e[8]=f):f=e[8],a=s.map(f),e[2]=s,e[3]=i,e[4]=r,e[5]=a}else a=e[5];let c;return e[9]!==o||e[10]!==a?(c=t.jsx(Ks,{className:"h-full overflow-y-auto overflow-x-hidden px-3 py-2",children:t.jsx("ul",{"aria-label":o,className:"flex flex-col gap-1",children:a})}),e[9]=o,e[10]=a,e[11]=c):c=e[11],c},yd=u.lazy(()=>$t(()=>import("./FilesView-OL3CON3r.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])).then(n=>({default:n.FilesView}))),kt=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),us=n=>{const e=kt(n);return!e||e==="/"?e||"/":e.split("/").filter(Boolean).at(-1)??e},vd=n=>{const e=kt(n);if(!e||e==="/")return null;const s=e.lastIndexOf("/");return s<=0?e.startsWith("/")?"/":null:e.slice(0,s)},wd=(n,e)=>{const s=kt(n),i=kt(e);return!i||s===i?us(s):s.startsWith(`${i}/`)?s.slice(i.length+1):s},jd=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 i of e){if(s<1024||i===e[e.length-1])return`${s.toFixed(s>=10?0:1)} ${i}`;s/=1024}return""},kd=({onClose:n})=>{const{t:e}=me(),{files:s}=Tn(),i=yo(g=>g.setSelectedPath),r=kt(Dn()??null),[o,a]=u.useState(()=>({type:"browser",directory:r})),[c,f]=u.useState([]),[d,l]=u.useState(!1),[p,b]=u.useState(null),[h,x]=u.useState(""),[S,y]=u.useState([]),[E,w]=u.useState(!1),N=u.useRef(0);u.useEffect(()=>{r&&a(g=>g.type==="browser"&&g.directory?g:{type:"browser",directory:r})},[r]);const A=o.type==="browser"?o.directory:o.returnDirectory,v=u.useCallback(async g=>{if(!g)return;const O=N.current+1;N.current=O,l(!0),b(null);try{const V=await s.listDirectory(g);if(N.current!==O)return;f(V.entries.slice().sort((B,L)=>B.isDirectory!==L.isDirectory?B.isDirectory?-1:1:B.name.localeCompare(L.name)))}catch(V){if(N.current!==O)return;f([]),b(V instanceof Error?V.message:e("mobile.files.error.listFailed"))}finally{N.current===O&&l(!1)}},[s,e]);u.useEffect(()=>{o.type==="browser"&&v(o.directory)},[v,o]),u.useEffect(()=>{if(o.type!=="browser")return;const g=h.trim();if(!g){y([]),w(!1);return}let O=!1;const V=window.setTimeout(()=>{w(!0),s.search({directory:o.directory,query:g,maxResults:40}).then(B=>{O||y(B)}).catch(()=>{O||y([])}).finally(()=>{O||w(!1)})},250);return()=>{O=!0,window.clearTimeout(V)}},[s,h,o]);const P=g=>{x(""),a({type:"browser",directory:g})},C=g=>{i(r,g),a({type:"file",path:g,returnDirectory:A||r})},R=it(g=>g.pendingFileFocusPath),k=it(g=>g.pendingFileNavigation);if(u.useEffect(()=>{const g=kt(k?.path??R??"");!g||!r||g!==r&&!g.startsWith(`${r}/`)||(i(r,g),a({type:"file",path:g,returnDirectory:r}),R&&it.getState().setPendingFileFocusPath(null))},[R,k,r,i]),!r)return t.jsx(ds,{message:e("mobile.files.empty.noDirectory")});if(o.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:"-ml-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":e("header.actions.backAria"),onClick:()=>a({type:"browser",directory:o.returnDirectory}),style:{touchAction:"manipulation"},children:t.jsx(kr,{className:"size-5"})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:us(o.path)})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(Ve,{children:t.jsx(u.Suspense,{fallback:t.jsx(ds,{loading:!0,message:e("filesView.state.loading")}),children:t.jsx(yd,{mode:"editor-only"})})})})]});const z=o.directory===r?e("mobile.files.rootDirectory"):us(o.directory),D=h.trim()?S:[],_=vd(o.directory),j=o.directory!==r&&_!==null&&(_===r||_.startsWith(`${r}/`)),I=j&&!h.trim(),$=j?_:null;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 px-3 text-foreground",children:[n?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("mobile.surface.closeAria"),onClick:n,style:{touchAction:"manipulation"},children:t.jsx(Wl,{className:"size-5"})}):null,I&&$?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":e("mobile.files.backToParentAria",{name:us($)}),onClick:()=>P($),style:{touchAction:"manipulation"},children:t.jsx(kr,{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:z})}),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":e("mobile.files.refreshAria"),onClick:()=>{v(o.directory)},style:{touchAction:"manipulation"},children:t.jsx(Vl,{className:J("size-5",d&&"animate-spin")})})]}),t.jsx("div",{className:"shrink-0 px-4 pb-2 pt-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(Ul,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(gi,{value:h,onChange:g=>x(g.target.value),placeholder:e("mobile.files.search.placeholder"),className:"h-11 pl-9"})]})}),t.jsx(Ks,{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-3",children:p?t.jsx(ds,{message:p}):h.trim()?t.jsx(Sd,{results:D,isSearching:E,onOpenFile:C}):t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:[c.length===0&&!d?t.jsx("div",{className:"px-4 py-8 text-center typography-body text-muted-foreground",children:e("mobile.files.empty.directory")}):null,c.map(g=>t.jsx(Xi,{name:g.name,path:g.path,directory:g.isDirectory,meta:g.isDirectory?void 0:jd(g.size),onClick:()=>g.isDirectory?P(g.path):C(g.path)},g.path))]})})]})},Xi=n=>{const e=le.c(16),{name:s,path:i,directory:r,meta:o,onClick:a}=n;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={touchAction:"manipulation"},e[0]=c):c=e[0];let f;e[1]!==r||e[2]!==i?(f=r?t.jsx(Gl,{className:"size-5 shrink-0 text-primary/80"}):t.jsx(vi,{filePath:i,className:"size-5 shrink-0"}),e[1]=r,e[2]=i,e[3]=f):f=e[3];let d;e[4]!==s?(d=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:s}),e[4]=s,e[5]=d):d=e[5];let l;e[6]!==o?(l=o?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:o}):null,e[6]=o,e[7]=l):l=e[7];let p;e[8]!==r?(p=r?t.jsx(Kl,{className:"size-4 shrink-0 text-muted-foreground/60"}):null,e[8]=r,e[9]=p):p=e[9];let b;return e[10]!==a||e[11]!==f||e[12]!==d||e[13]!==l||e[14]!==p?(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-left 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:a,style:c,children:[f,d,l,p]}),e[10]=a,e[11]=f,e[12]=d,e[13]=l,e[14]=p,e[15]=b):b=e[15],b},Sd=n=>{const e=le.c(10),{results:s,isSearching:i,onOpenFile:r}=n,{t:o}=me(),a=kt(Dn()??null);if(i){let l;e[0]!==o?(l=o("common.loading"),e[0]=o,e[1]=l):l=e[1];let p;return e[2]!==l?(p=t.jsx(ds,{loading:!0,message:l}),e[2]=l,e[3]=p):p=e[3],p}if(s.length===0){let l;e[4]!==o?(l=o("mobile.files.search.empty"),e[4]=o,e[5]=l):l=e[5];let p;return e[6]!==l?(p=t.jsx(ds,{message:l}),e[6]=l,e[7]=p):p=e[7],p}const c="overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",f=s.map(l=>t.jsx(Xi,{name:us(l.path),path:l.path,directory:!1,meta:wd(l.path,a),onClick:()=>r(l.path)},l.path));let d;return e[8]!==f?(d=t.jsx("div",{className:c,children:f}),e[8]=f,e[9]=d):d=e[9],d},ds=n=>{const e=le.c(7),{message:s,loading:i}=n,r=i===void 0?!1:i;let o;e[0]!==r?(o=r?t.jsx(Hl,{className:"size-5 animate-spin text-muted-foreground"}):t.jsx(ql,{className:"size-6 text-muted-foreground"}),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==s?(a=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[2]=s,e[3]=a):a=e[3];let c;return e[4]!==o||e[5]!==a?(c=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:[o,a]})}),e[4]=o,e[5]=a,e[6]=c):c=e[6],c},Qr="mobile-surface-root",Nd=16,Xr=320,Cd="cubic-bezier(0.22, 1, 0.36, 1)",Rd=n=>{const e=le.c(36),{onOpenMcpSettings:s}=n,{t:i}=me(),[r,o]=u.useState(!1),a=ht(Pd),c=is(Ad),f=Ot(Id);let d;e[0]!==a||e[1]!==r||e[2]!==f||e[3]!==c?(d=()=>{if(r)return;o(!0);const z=new Promise(Td);Promise.all([c({directory:a||null,silent:!0}),f({force:!0}),z]).finally(()=>o(!1))},e[0]=a,e[1]=r,e[2]=f,e[3]=c,e[4]=d):d=e[4];const l=d;let p;e[5]!==i?(p=i("settings.mcp.sidebar.actions.addServerTitle"),e[5]=i,e[6]=p):p=e[6];let b;e[7]!==i?(b=i("settings.mcp.sidebar.actions.addServerTitle"),e[7]=i,e[8]=b):b=e[8];let h,x;e[9]===Symbol.for("react.memo_cache_sentinel")?(h={touchAction:"manipulation"},x=t.jsx(X,{name:"add",className:"size-5"}),e[9]=h,e[10]=x):(h=e[9],x=e[10]);let S;e[11]!==s||e[12]!==p||e[13]!==b?(S=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":p,title:b,style:h,children:x}),e[11]=s,e[12]=p,e[13]=b,e[14]=S):S=e[14];let y;e[15]!==i?(y=i("mcpDropdown.actions.refreshAria"),e[15]=i,e[16]=y):y=e[16];let E;e[17]!==i?(E=i("mcpDropdown.actions.refreshAria"),e[17]=i,e[18]=E):E=e[18];let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w={touchAction:"manipulation"},e[19]=w):w=e[19];const N=r&&"animate-spin";let A;e[20]!==N?(A=J("size-5",N),e[20]=N,e[21]=A):A=e[21];let v;e[22]!==A?(v=t.jsx(X,{name:"refresh",className:A}),e[22]=A,e[23]=v):v=e[23];let P;e[24]!==r||e[25]!==l||e[26]!==v||e[27]!==y||e[28]!==E?(P=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:l,disabled:r,"aria-label":y,title:E,style:w,children:v}),e[24]=r,e[25]=l,e[26]=v,e[27]=y,e[28]=E,e[29]=P):P=e[29];let C;e[30]!==P||e[31]!==S?(C=t.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-1 px-2 pt-1",children:[S,P]}),e[30]=P,e[31]=S,e[32]=C):C=e[32];let R;e[33]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(fd,{active:!0,className:"h-full",listClassName:"max-h-none",hideHeader:!0,mobileListDensity:!0})}),e[33]=R):R=e[33];let k;return e[34]!==C?(k=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[C,R]}),e[34]=C,e[35]=k):k=e[35],k},Ed=({open:n,onClose:e,tab:s,onTabChange:i,pendingChangesDiff:r,onOpenPlan:o,onOpenMcpSettings:a,variant:c="drawer"})=>{const{t:f}=me(),d=u.useRef(null),l=u.useRef(null),[p,b]=u.useState(!1),[h,x]=u.useState(n),S=u.useRef(e);u.useEffect(()=>{S.current=e},[e]);const y=u.useRef(s);u.useEffect(()=>{y.current=s},[s]),sr(l,{enabled:c==="drawer"&&n,onLeftEdgeSwipe:()=>S.current()});const[E,w]=u.useState(()=>new Set);if(u.useEffect(()=>{n&&w(v=>{if(v.has(s))return v;const P=new Set(v);return P.add(s),P})},[n,s]),typeof document<"u"&&!d.current){let v=document.getElementById(Qr);v||(v=document.createElement("div"),v.id=Qr,document.body.appendChild(v)),d.current=v}if(u.useEffect(()=>{if(n){x(!0);const P=window.setTimeout(()=>b(!0),Nd);return()=>window.clearTimeout(P)}b(!1);const v=window.setTimeout(()=>x(!1),Xr+40);return()=>window.clearTimeout(v)},[n]),u.useEffect(()=>{if(!n)return;const v=document.body.style.overflow;c==="drawer"&&(document.body.style.overflow="hidden");const P=C=>{C.key!=="Escape"||y.current==="terminal"||ba(C.target)||S.current()};return document.addEventListener("keydown",P),()=>{c==="drawer"&&(document.body.style.overflow=v),document.removeEventListener("keydown",P)}},[n,c]),c==="drawer"&&!d.current)return null;const N=[{id:"changes",label:f("mobile.menu.changes"),icon:t.jsx(X,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"files",label:f("mobile.menu.files"),icon:t.jsx(X,{name:"file-text",className:"h-3.5 w-3.5"})},{id:"terminal",label:f("mobile.menu.terminal"),icon:t.jsx(X,{name:"terminal",className:"h-3.5 w-3.5"})},{id:"notes",label:f("contextRail.surface.notes"),icon:t.jsx(X,{name:"sticky-note",className:"h-3.5 w-3.5"})},{id:"mcp",label:f("mobile.menu.mcp"),icon:t.jsx(ga,{className:"h-3.5 w-3.5"})}],A=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:h?t.jsx(yl,{items:N,activeId:s,onSelect:v=>i(v),layoutMode:"fit",variant:"active-pill",nonCompositedIndicator:!0,inactiveTabsIconOnly:!0,className:"h-full"}):null}),t.jsx("button",{type:"button",className:"-mr-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(X,{name:"close",className:"size-5"})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[E.has("changes")?t.jsx("div",{className:J("h-full",s!=="changes"&&"hidden"),children:t.jsx(Ve,{children:t.jsx(gd,{visible:n&&s==="changes",initialDiff:r})})},r?`changes:${r.path}:${r.staged}`:"changes"):null,E.has("files")?t.jsx("div",{className:J("h-full",s!=="files"&&"hidden"),children:t.jsx(Ve,{children:t.jsx(kd,{})})}):null,E.has("terminal")?t.jsx("div",{className:J("h-full",s!=="terminal"&&"hidden"),children:t.jsx(Ve,{children:t.jsx(vl,{visible:n&&s==="terminal"})})}):null,E.has("notes")?t.jsx("div",{className:J("h-full",s!=="notes"&&"hidden"),children:t.jsx(Ve,{children:t.jsx(wl,{onActionComplete:e,onOpenPlan:o})})}):null,E.has("mcp")?t.jsx("div",{className:J("h-full",s!=="mcp"&&"hidden"),children:t.jsx(Ve,{children:t.jsx(Rd,{onOpenMcpSettings:a})})}):null]})]});return c==="panel"?t.jsx("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:A}):Lt.createPortal(t.jsx("section",{ref:l,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:p?"none":"translateX(100%)",transition:`transform ${Xr}ms ${Cd}`,visibility:h?"visible":"hidden",pointerEvents:n?"auto":"none"},children:A}),d.current)};function Pd(n){return n.currentDirectory}function Ad(n){return n.refresh}function Id(n){return n.loadMcpConfigs}function Td(n){return window.setTimeout(n,500)}function Dd(n){const e=le.c(4),s=2500,{uiFont:i}=xa(),[r,o]=u.useState(!1);let a,c;return e[0]!==s||e[1]!==i?(a=()=>{let f=!1;const d=()=>{f||o(!0)},l=()=>{requestAnimationFrame(()=>requestAnimationFrame(d))},p=Promise.all([ya(i).catch(Bd),document.fonts?.ready?.then(Od).catch(zd)??Promise.resolve(),mc.catch(Md)]).then(_d),b=new Promise(h=>{window.setTimeout(h,s)});return Promise.race([p,b]).then(l),()=>{f=!0}},c=[i,s],e[0]=s,e[1]=i,e[2]=a,e[3]=c):(a=e[2],c=e[3]),u.useEffect(a,c),r}function _d(){}function Md(){}function zd(){}function Od(){}function Bd(){}const Ld="openchamber",$d=n=>n.replace(/^\/+|\/+$/g,""),Fd=n=>{const e=$d(n.pathname).split("/").filter(Boolean);return n.host?[n.host,...e]:e};function Wd(n){if(typeof n!="string"||n.length===0)return null;let e;try{e=new URL(n)}catch{return null}if(e.protocol!==`${Ld}:`)return null;const s=Fd(e),i=(s[0]??"").toLowerCase(),r=s.slice(1),o=e.searchParams;switch(i){case"session":{const a=r[0]||o.get("id")||"";return a?{type:"session",sessionId:a,directory:o.get("dir")??void 0}:null}case"new":case"new-session":return{type:"new-session",directory:o.get("dir")??void 0,projectId:o.get("project")??void 0,agent:o.get("agent")??void 0,model:o.get("model")??void 0};case"sessions":{const a=o.get("filter");return{type:"sessions",filter:a==="attention"||a==="recent"||a==="all"?a:void 0}}case"status":return{type:"status"};case"settings":return{type:"settings",section:r[0]||o.get("section")||void 0};case"changes":return{type:"changes",path:r.join("/")||o.get("path")||void 0,staged:o.get("staged")==="true"};case"view":{const a=(r[0]||"").toLowerCase();return a==="changes"?{type:"changes"}:a==="files"||a==="mcp"||a==="instances"||a==="update"?{type:"view",target:a}:null}default:return null}}let Ke={},Zi=!1,cs=null;const Vd=n=>{switch(n.type){case"session":return Se.getState().setCurrentSession(n.sessionId,n.directory??null),!0;case"new-session":{const e=Se.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 Ke.openSessions?(Ke.openSessions(n.filter),!0):!1;case"status":return Ke.openSessions?(Ke.openSessions(),!0):!1;case"view":return Ke.openView?(Ke.openView(n.target),!0):!1;case"changes":return Ke.openChanges?(Ke.openChanges({path:n.path,staged:n.staged}),!0):!1;case"settings":return Ke.openSettings?(Ke.openSettings(n.section),!0):!1}},nr=()=>{if(!Zi||!cs)return;const n=cs;cs=null,Vd(n)||(cs=n)},eo=n=>{cs=n,nr()},Zr=n=>{const e=Wd(n);e&&eo(e)},Ud=n=>{Zi=n,nr()},Gd=n=>{const e=le.c(3);let s,i;e[0]!==n?(s=()=>(Ke=n,nr(),()=>{Ke===n&&(Ke={})}),i=[n],e[0]=n,e[1]=s,e[2]=i):(s=e[1],i=e[2]),u.useEffect(s,i)},Kd=n=>{const{ready:e}=n;u.useEffect(()=>{Ud(e)},[e]),u.useEffect(()=>{if(!Te())return;let s=!1;const i=[];return $t(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([127,5,128])).then(async({App:r})=>{if(s)return;const o=await r.addListener("appUrlOpen",a=>{Zr(a?.url)});if(s){o.remove();return}i.push(()=>{o.remove()})}).catch(()=>{}),$t(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([129,128])).then(async({PushNotifications:r})=>{if(s)return;const o=await r.addListener("pushNotificationActionPerformed",a=>{const c=a?.notification?.data,f=typeof c?.url=="string"?c.url:typeof c?.deeplink=="string"?c.deeplink:void 0;if(f){Zr(f);return}const d=typeof c?.sessionId=="string"?c.sessionId:void 0;d&&eo({type:"session",sessionId:d})});if(s){o.remove();return}i.push(()=>{o.remove()})}).catch(()=>{}),()=>{s=!0,i.forEach(r=>r())}},[])},Hd=()=>{if(typeof window>"u")return;const n=window.__OPENCHAMBER_APNS_ENV__;if(n==="development")return"sandbox";if(n==="production")return"production"},qd=()=>{if(typeof window>"u")return!1;const e=window.Capacitor?.getPlatform?.();return e==="ios"||e==="android"},Jd=n=>{const{enabled:e}=n,s=it(r=>r.nativeNotificationsEnabled),i=u.useRef(null);u.useEffect(()=>{if(!e||!s||!qd())return;let r=!1;const o=[];return $t(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([129,128])).then(async({PushNotifications:a})=>{if(r)return;let c=await a.checkPermissions().catch(()=>null);if(c?.receive!=="granted"&&(c=await a.requestPermissions().catch(()=>null)),c?.receive!=="granted")return;const f=await a.addListener("registration",l=>{i.current=l.value,gr()?.push?.registerApnsToken?.({token:l.value,platform:ri(),environment:Hd()})}),d=await a.addListener("registrationError",l=>{console.warn("[Push] APNs registration error:",l)});if(await a.register().catch(()=>{}),r){f.remove(),d.remove();return}o.push(()=>{f.remove()},()=>{d.remove()})}).catch(()=>{}),()=>{r=!0,o.forEach(a=>a())}},[e,s]),u.useEffect(()=>{if(s)return;const r=i.current;if(!r)return;i.current=null,gr()?.push?.unregisterApnsToken?.({token:r})},[s])},ei=n=>{const e=le.c(12),{side:s,isResizing:i,ariaLabel:r,handleProps:o}=n,a=s==="left"?"right-0":"left-0";let c;e[0]!==a?(c=J("absolute inset-y-0 z-50 w-6 cursor-col-resize touch-none",a),e[0]=a,e[1]=c):c=e[1];const f=s==="left"?"right-0":"left-0",d=i&&"bg-[var(--interactive-border)]";let l;e[2]!==f||e[3]!==d?(l=J("absolute inset-y-0 w-[3px] transition-colors",f,d),e[2]=f,e[3]=d,e[4]=l):l=e[4];let p;e[5]!==l?(p=t.jsx("div",{className:l}),e[5]=l,e[6]=p):p=e[6];let b;return e[7]!==r||e[8]!==o||e[9]!==c||e[10]!==p?(b=t.jsx("div",{className:c,role:"separator","aria-orientation":"vertical","aria-label":r,...o,children:p}),e[7]=r,e[8]=o,e[9]=c,e[10]=p,e[11]=b):b=e[11],b},Yd=320,Qd=380,ti=280,Xd=560,Zd=900;function si(n,e,s,i){const r=le.c(23),o=i===void 0?Xd:i,a=u.useRef(null);let c;r[0]!==s||r[1]!==o||r[2]!==e?(c=()=>{if(typeof window>"u")return s;const j=Number.parseInt(window.localStorage.getItem(e)??"",10);return Number.isFinite(j)?Math.min(o,Math.max(ti,j)):s},r[0]=s,r[1]=o,r[2]=e,r[3]=c):c=r[3];const[f,d]=u.useState(c),[l,p]=u.useState(!1),b=u.useRef(0),h=u.useRef(f),x=u.useRef(null),S=u.useRef(null);let y;r[4]!==o?(y=j=>Math.min(o,Math.max(ti,Math.round(j))),r[4]=o,r[5]=y):y=r[5];const E=y;let w;r[6]===Symbol.for("react.memo_cache_sentinel")?(w=j=>{const I=a.current;I&&(I.style.width=`${j}px`,I.style.minWidth=`${j}px`,I.style.maxWidth=`${j}px`,I.style.setProperty("--oc-ipad-sidebar-width",`${j}px`))},r[6]=w):w=r[6];const N=w;let A;r[7]!==f?(A=j=>{try{j.currentTarget.setPointerCapture(j.pointerId)}catch{}S.current=j.pointerId,b.current=j.clientX,h.current=f,x.current=f,p(!0),j.preventDefault()},r[7]=f,r[8]=A):A=r[8];const v=A;let P;r[9]!==E||r[10]!==n?(P=j=>{if(S.current!==j.pointerId)return;const I=j.clientX-b.current,$=E(h.current+(n==="left"?I:-I));x.current!==$&&(x.current=$,N($))},r[9]=E,r[10]=n,r[11]=P):P=r[11];const C=P;let R;r[12]!==E||r[13]!==e?(R=j=>{if(S.current!==j.pointerId)return;try{j.currentTarget.releasePointerCapture(j.pointerId)}catch{}const I=E(x.current??h.current);S.current=null,x.current=null,p(!1),d(I);try{window.localStorage.setItem(e,String(I))}catch{}},r[12]=E,r[13]=e,r[14]=R):R=r[14];const k=R;let z;r[15]!==v||r[16]!==k||r[17]!==C?(z={onPointerDown:v,onPointerMove:C,onPointerUp:k,onPointerCancel:k},r[15]=v,r[16]=k,r[17]=C,r[18]=z):z=r[18];const D=z;let _;return r[19]!==D||r[20]!==l||r[21]!==f?(_={asideRef:a,width:f,isResizing:l,handleProps:D},r[19]=D,r[20]=l,r[21]=f,r[22]=_):_=r[22],_}const ef=["general","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"],tf=1e3,sf=({onActiveConnectionDeleted:n})=>{const{t:e}=me();Al();const[s,i]=u.useState(!1),[r,o]=u.useState(null),[a,c]=u.useState(!1),[f,d]=u.useState("changes"),[l,p]=u.useState(null),[b,h]=u.useState("nav"),[x,S]=u.useState(null),y=it(q=>q.setSettingsPage),E=it(q=>q.wideChatLayoutEnabled),w=Mt(q=>q.available),N=Mt(q=>q.runtimeType),A=u.useMemo(()=>_n(),[]),v=Ot(q=>q.mcpServers),P=Ot(q=>q.setMcpDraft),C=Ot(q=>q.setSelectedMcp),R=u.useCallback(()=>{o(null),p(null)},[]),k=u.useCallback(q=>{o(q)},[]),z=u.useCallback(()=>{c(!1)},[]),D=u.useCallback(q=>{h(q),k("settings")},[k]),{enabled:_,roomyForPanels:j}=Rn(),$=Fa()==="portrait",g=Wa(),[O,V]=u.useState(()=>Va().roomyForPanels),B=u.useCallback(()=>{V(q=>!q)},[]);u.useEffect(()=>{_||V(!1)},[_]);const L=u.useCallback(()=>{S(null),d("files"),c(!0)},[]);u.useEffect(()=>wi(q=>{if(q.type!=="file-open-request")return;const de=q.directory??ht.getState().currentDirectory;de&&(it.getState().openContextFile(de,q.path),L())}),[L]);const ie=u.useCallback((q=null)=>{S(q),d("changes"),c(!0)},[]),se=si("left","openchamber.ipad.leftSidebarWidth",Yd),te=si("right","openchamber.ipad.rightSidebarWidth",Qd,Zd),M=j,G=M&&a?te.width:0,Y=_&&O?se.width:0;u.useEffect(()=>{if(typeof document>"u")return;const q=document.documentElement;return q.style.setProperty("--oc-chat-inset-left",`${Y}px`),q.style.setProperty("--oc-chat-inset-right",`${G}px`),()=>{q.style.removeProperty("--oc-chat-inset-left"),q.style.removeProperty("--oc-chat-inset-right")}},[Y,G]),u.useEffect(()=>{if(typeof document>"u")return;const q=document.documentElement;return q.classList.toggle("wide-chat-layout",E),()=>q.classList.remove("wide-chat-layout")},[E]),u.useEffect(()=>{if(typeof document>"u")return;const q=_&&($||g),de=document.documentElement;return de.classList.toggle("oc-keep-draft-starters",q),()=>de.classList.remove("oc-keep-draft-starters")},[g,_,$]);const H=u.useMemo(()=>({openChanges:({diffPath:q,staged:de}={})=>{ie(q?{path:q,staged:de===!0}:null)},openFiles:()=>L(),openSettings:()=>D("nav")}),[ie,L,D]),Q=u.useMemo(()=>({openSessions:()=>{_?V(!0):i(!0)},openView:q=>{if(q==="files"){L();return}if(q==="mcp"){d("mcp"),c(!0);return}k(q)},openChanges:({path:q,staged:de}={})=>{ie(q?{path:q,staged:de===!0}:null)},openSettings:q=>{q&&y(q),D(q?"page-content":"nav")}}),[_,ie,L,D,k,y]);Gd(Q);const ne=u.useRef(null);sr(ne,{onLeftEdgeSwipe:()=>{_?V(!0):i(!0)},onRightEdgeSwipe:()=>c(!0)});const re=u.useRef(null),ce=u.useCallback(q=>{re.current=q},[]),ue=u.useCallback(()=>l?(p(null),!0):r==="settings"&&re.current?.()?!0:r?(R(),!0):a?(z(),!0):s?(i(!1),!0):!1,[r,R,z,l,s,a]);Ua(ue);const K=!A&&w&&(N==="desktop"||N==="web"),oe=_?"dialog":"fullscreen",pe=u.useMemo(()=>({instanceLabel:A?os():null,onOpenInstances:A?()=>k("instances"):void 0,onOpenSettings:()=>D("nav"),onOpenUsage:()=>k("usage"),onOpenUpdate:K?()=>k("update"):void 0}),[D,k,A,K]),ke=u.useCallback(()=>{const q="new-mcp-server";let de=q,Ce=1;for(;v.some(Ae=>Ae.name===de);)de=`${q}-${Ce}`,Ce+=1;P({name:de,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",oauthCallbackPort:"",oauthAuthServerMetadataUrl:"",protocol:"legacy",timeoutStartup:"",timeoutCatalog:"",timeoutExecution:"",codemode:!0,disabled:!1}),C(de),y("mcp"),D("page-content")},[v,D,P,C,y]);return t.jsx(Ga,{actions:H,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:[_?t.jsxs("aside",{ref:se.asideRef,className:J("relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!O&&"border-r-0"),style:{width:O?se.width:0,minWidth:O?se.width:0,maxWidth:O?se.width:0,"--oc-ipad-sidebar-width":`${se.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:se.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!O,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:J("flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",se.isResizing&&"pointer-events-none",!O&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Ve,{children:t.jsx(Ur,{open:!0,variant:"sidebar",onOpenChange:q=>{!q&&!j&&V(!1)},footer:pe})})}),O?t.jsx(ei,{side:"left",isResizing:se.isResizing,ariaLabel:e("sidebar.resize.leftPanelAria"),handleProps:se.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(ku,{onOpenSessions:()=>_?B():i(!0),onOpenWorkspace:()=>c(!0),compactTitle:_}),t.jsx("main",{ref:ne,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(Ve,{children:t.jsx(Il,{})})})})]}),_?null:t.jsx(Ur,{open:s,onOpenChange:i,footer:pe}),t.jsxs("aside",{ref:te.asideRef,className:J("relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!G&&"border-l-0"),style:{width:G,minWidth:G,maxWidth:G,"--oc-ipad-sidebar-width":`${te.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:te.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!G,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:J("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",te.isResizing&&"pointer-events-none",!G&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Ve,{children:t.jsx(Ed,{open:a,onClose:z,tab:f,onTabChange:d,pendingChangesDiff:x,onOpenPlan:p,onOpenMcpSettings:ke,variant:M?"panel":"drawer"})})}),G?t.jsx(ei,{side:"right",isResizing:te.isResizing,ariaLabel:e("sidebar.resize.rightPanelAria"),handleProps:te.handleProps}):null]}),l?t.jsx(Tt,{open:!0,variant:oe,onClose:()=>p(null),ariaLabel:l.title,title:l.title,children:t.jsx(Ve,{children:t.jsx(zl,{savedProjectPlan:{projectRef:l.projectRef,planId:l.id},onNavigatedToChat:()=>{R(),z()}})})}):null,r==="instances"&&A?t.jsx(Tt,{open:!0,variant:oe,dialogAlign:"app",onClose:R,ariaLabel:e("mobile.menu.instances"),title:e("mobile.menu.instances"),children:t.jsx(Ru,{onConnect:R,onActiveConnectionDeleted:n})}):null,r==="settings"?t.jsx(Tt,{open:!0,variant:oe,dialogAlign:"app",onClose:R,ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(Ve,{children:t.jsx(_l,{forceMobile:!0,isWindowed:!0,initialMobileStage:b,registerBackHandler:ce,visiblePageSlugs:ef.filter(q=>!(A&&q==="about")),onClose:R})})}):null,r==="usage"?t.jsx(Tt,{open:!0,variant:oe,dialogAlign:"app",onClose:R,ariaLabel:e("usageStats.title"),title:e("usageStats.title"),children:t.jsx(Ve,{children:t.jsx(Tl,{})})}):null,r==="update"?t.jsx(Tt,{open:!0,variant:oe,dialogAlign:"app",onClose:R,ariaLabel:e("mobile.menu.update"),title:e("mobile.menu.update"),children:t.jsx(Ve,{children:t.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:t.jsx(Ml,{initialUpdateDialogOpen:!0})})})}):null]})})};function ni({apis:n}){const{t:e}=me(),s=He(M=>M.initializeApp),i=He(M=>M.isInitialized),r=He(M=>M.isConnected),o=He(M=>M.connectionPhase),a=He(M=>M.providers.length),c=He(M=>M.agents.length),f=He(M=>M.loadProviders),d=He(M=>M.loadAgents),l=ht(M=>M.currentDirectory),p=Se(M=>M.error),b=Se(M=>M.clearError),h=it(M=>M.setIsMobile),x=va(M=>M.refreshStatus),S=wa(M=>M.refreshStatus),y=ja(M=>M.setPlanModeEnabled),E=We(M=>M.projects),[w,N]=u.useState(0),[A,v]=u.useState(0),[P,C]=u.useState(!1),[R,k]=u.useState("pending"),[z,D]=u.useState(null),_=u.useMemo(()=>os(),[]),[,j]=u.useReducer(M=>M+1,0),I=u.useMemo(()=>_n(),[]),$=u.useRef(0),g=u.useRef(0),O=u.useCallback(()=>{const M=st(),G=g.current+1;if(g.current=G,!M){ns("resume:auto-connect",{}),rs();return}ns("resume:reprobe",{});const Y=()=>{s(),x(n.github,{force:!0}),S(n.linear,{force:!0}),a===0&&f({source:"mobileApp:nativeResume"}),c===0&&d({source:"mobileApp:nativeResume"})},H=ne=>{ns("resume:disconnect",{reason:ne}),Dt({apiBaseUrl:"",clientToken:null,runtimeKey:Es}),N(re=>re+1)};Ms().then(ne=>{if(g.current===G){if(ne==="no-connection"){H("no-connection");return}if(ne==="needs-login"){D({kind:"auth-expired",label:os()??""}),H("needs-login");return}if(ne==="unreachable"){const re=[4e3,1e4],ce=ue=>{window.setTimeout(()=>{if(g.current!==G)return;const K=ue===re.length-1;Ms({fast:!K}).then(oe=>{if(g.current===G&&oe!=="switched"){if(oe==="unchanged"){Y();return}if(oe==="needs-login"){D({kind:"auth-expired",label:os()??""}),H("retry-needs-login");return}if(!K){ce(ue+1);return}H(`retry-${oe}`)}})},re[ue])};ce(0);return}ne!=="switched"&&Y()}});const Q=Date.now();Q-$.current>=tf&&($.current=Q,window.dispatchEvent(new Event("openchamber:system-resume")))},[c,n.github,n.linear,s,d,f,a,x,S]);ka(),Sa(O),u.useEffect(()=>{if(!I)return;let M;const G=()=>{window.clearTimeout(M),M=window.setTimeout(()=>O(),1500)};return window.addEventListener("online",G),()=>{window.removeEventListener("online",G),window.clearTimeout(M)}},[I,O]),u.useEffect(()=>{if(I)return br.subscribe((M,G)=>{M.state==="expired"&&G.state!=="expired"&&(O(),br.getState().markAuthenticated())})},[I,O]),u.useEffect(()=>(xr(n),()=>xr(null)),[n]),u.useEffect(()=>oi(M=>{if(ns("endpoint:changed",{runtimeKey:M.runtimeKey||"none",previousRuntimeKey:M.previousRuntimeKey||"none",connected:!!M.apiBaseUrl}),!!M.runtimeKey&&M.runtimeKey===M.previousRuntimeKey){kl(),j();return}Sl(M),v(Y=>Y+1),N(Y=>Y+1)}),[]),u.useEffect(()=>{if(!I||r||st()){k("done");return}let M=!1;return k("attempting"),(async()=>{const G=await rs().catch(()=>({status:"no-candidate"}));M||(G.status==="unreachable"?D({kind:"unreachable",label:G.label}):G.status==="needs-login"&&D({kind:"auth-expired",label:G.label}),k("done"),G.status==="unreachable"&&rs({fast:!1,skipIfConnected:!0}).catch(()=>null))})(),()=>{M=!0}},[]),u.useEffect(()=>{if(!I||!st())return;let M=!1;const G=Y=>{ns("cold-launch:drop",{kind:Y?.kind??"unknown"}),Y&&D(Y),Dt({apiBaseUrl:"",clientToken:null,runtimeKey:Es}),N(H=>H+1)};return Ms().then(async Y=>{if(M||Y==="switched"||Y==="unchanged")return;const H=os();if(Y==="needs-login"){G({kind:"auth-expired",label:H??""});return}if(Y==="unreachable"){G(H?{kind:"unreachable",label:H}:null),rs({fast:!1,skipIfConnected:!0}).catch(()=>null);return}const Q=await rs().catch(()=>({status:"no-candidate"}));M||Q.status==="connected"||(Q.status==="needs-login"?G({kind:"auth-expired",label:Q.label}):Q.status==="unreachable"?G({kind:"unreachable",label:Q.label}):G(null))}),()=>{M=!0}},[]),u.useEffect(()=>{h(!0)},[h]),u.useEffect(()=>{I&&!st()||s()},[w,s,I]),u.useEffect(()=>{r&&(a===0&&f({source:"mobileApp:recovery"}),c===0&&d({source:"mobileApp:recovery"}))},[c,r,d,f,a]);const V=u.useRef(!1),[B,L]=u.useState(I);u.useEffect(()=>{if(!I||!r||V.current)return;if(Se.getState().currentSessionId){V.current=!0,L(!1);return}const M=Gt(),G=Na(M);if(!G){V.current=!0,L(!1);return}let Y=!1;const H=window.setTimeout(()=>L(!1),6e3);return(async()=>{const Q=await In().catch(()=>null);if(Y)return;if(!Q){L(!1);return}V.current=!0;const ne=Q.activeSessions.find(ce=>ce.id===G.sessionId);if(!ne){Ca(M),L(!1);return}const re=Se.getState();re.currentSessionId||re.setCurrentSession(ne.id,Cn(ne)??G.directory??void 0),L(!1)})(),()=>{Y=!0,window.clearTimeout(H)}},[w,r,I]),u.useEffect(()=>{r&&yr.setDirectory(l)},[l,r]),u.useEffect(()=>{r&&(x(n.github,{force:!0}),S(n.linear,{force:!0}))},[n.github,n.linear,r,x,S]),u.useEffect(()=>{if(!r||E.length===0)return;let M=!1;return(async()=>{const Y=new Map(Se.getState().availableWorktreesByProject);if(await Promise.all(E.map(async ne=>{const re=ne.path.replace(/\\/g,"/").replace(/\/+$/,"");if(re)try{if(!(Fe.getState().directories.get(re)?.isGitRepo??await $t(()=>import("./useAppFontEffects-ZM9ij19-.js").then(oe=>oe.ll),__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])).then(oe=>oe.checkIsGitRepository(re))))return;const K=await xi({id:ne.id,path:re});if(M)return;Y.set(re,K)}catch{}})),M)return;const H=yi(E,Y),Q=Se.getState().availableWorktreesByProject;La(H,Q)||Se.setState({availableWorktrees:[...H.values()].flat(),availableWorktreesByProject:H})})(),()=>{M=!0}},[r,E]),u.useEffect(()=>{if(!r)return;let M=!1;const G=wi(Y=>{Y.type==="worktree-changed"&&$a(E,Y.directories,()=>M)});return()=>{M=!0,G()}},[r,E]),u.useEffect(()=>{let M=!1;return(async()=>{const Y=await Sn("/health",{method:"GET"}).catch(()=>null);if(!Y||!Y.ok||M)return;const H=await Y.json().catch(()=>null);if(!H||M)return;const Q=H.planModeExperimentalEnabled;y(Q===!0||Q===1||Q==="1"||Q==="true")})(),()=>{M=!0}},[y]),u.useEffect(()=>{if(!p)return;const M=window.setTimeout(()=>b(),5e3);return()=>window.clearTimeout(M)},[b,p]),u.useEffect(()=>{if(!(!r&&(I?!!st():!0))){C(!1);return}const G=window.setTimeout(()=>{C(!0)},I?4e3:8e3);return()=>window.clearTimeout(G)},[r,I,w,A]),Ra(),Ea({enabled:!0}),Nl(),Pa(),Aa(),Cl(),Jd({enabled:I&&r}),Kd({ready:I&&r&&i});const ie=Dd(),se=!r&&o==="reconnecting";if(!ie)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(_t,{width:120,height:120,isAnimated:!0,variant:"splash"})});const te=!!st();return I&&(!te||!r&&!se)?te?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(_t,{width:120,height:120,isAnimated:!P,variant:"splash"}),P?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:e("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:e("mobile.connect.recovery.description")})]}),t.jsx(ge,{type:"button",variant:"outline",onClick:()=>{Dt({apiBaseUrl:"",clientToken:null,runtimeKey:Es}),N(M=>M+1)},children:e("mobile.connect.cancelPassword")})]}):null]})}):R!=="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(_t,{width:120,height:120,isAnimated:!0,variant:"splash"}),_?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:e("mobile.connect.splash.connectingTo")}),t.jsxs("p",{className:"typography-small text-foreground",children:[_,t.jsx(Ia,{})]})]}):null]}):t.jsx(t.Fragment,{children:t.jsx(au,{onConnected:()=>N(M=>M+1),notice:z})}):!r&&!se?P?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:e("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:e("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(_t,{width:120,height:120,isAnimated:!0,variant:"splash"})}):t.jsx(Ve,{children:t.jsx(Ta,{sdk:yr.getSdkClient(),directory:l||"",children:t.jsx(Da,{apis:n,children:t.jsx(_a,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[t.jsx(Rl,{ready:!I||!B,animated:!0}),t.jsx(Ma,{embeddedBackgroundWorkEnabled:i}),t.jsx(El,{}),t.jsx(jc,{}),t.jsx(sf,{onActiveConnectionDeleted:()=>{Dt({apiBaseUrl:"",clientToken:null,runtimeKey:Es}),N(M=>M+1)}}),t.jsx(za,{}),t.jsx(Oa,{}),t.jsx(Ba,{position:"top-center",offset:"calc(var(--oc-safe-area-top, 0px) + 16px)"}),i?t.jsx(Pl,{}):null]})})})},A)})}function nf(n){const e=le.c(4),s=u.useSyncExternalStore(rf,st,st);if(_n()&&!s){let r;return e[0]!==n?(r=t.jsx(ni,{...n}),e[0]=n,e[1]=r):r=e[1],r}let i;return e[2]!==n?(i=t.jsx(jl,{children:t.jsx(ni,{...n})}),e[2]=n,e[3]=i):i=e[3],i}function rf(n){return oi(()=>n())}const of=()=>{Xa(),vo().then(()=>{Promise.all([wo(),Za()]).catch(n=>{console.error("[mobile-main] settings init failed:",n)}),el(),tl(),sl()}).catch(n=>{console.error("[mobile-main] appearance init failed:",n)}).finally(()=>{pc()})};function Op(n){window.__OPENCHAMBER_SURFACE__="mobile",Ka(),of(),wc(),Ha();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");const i=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",r=i?{...n,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:n,o=t.jsx(nf,{apis:r});mo.createRoot(e).render(t.jsx(bn.StrictMode,{children:t.jsx(qa,{children:t.jsx(Ja,{children:t.jsx(Ya,{children:t.jsx(Dl,{children:i?o:t.jsx(Qa,{children:o})})})})})}))}export{Op as renderMobileApp};