@openchamber/web 2.3.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/dist/assets/AboutDialog-C1ulAXh5.js +1 -0
  2. package/dist/assets/ArchiveView-DJo1Bpw_.js +1 -0
  3. package/dist/assets/{CommandPalette-1VlA7PbL.js → CommandPalette-B6r6DPF9.js} +2 -2
  4. package/dist/assets/{DiffView-SHdJJ6tl.js → DiffView-mJuVm7Z4.js} +2 -2
  5. package/dist/assets/{FilePreviewCommentMenu-DlVgwRsr.js → FilePreviewCommentMenu-Ca4ziuof.js} +1 -1
  6. package/dist/assets/{FilesView-BeMtsSlV.js → FilesView-BBFbfDp9.js} +3 -3
  7. package/dist/assets/{GitView-npRGKKx8.js → GitView-WL1wkRFF.js} +3 -3
  8. package/dist/assets/GuestSurfacePane-peVDY5gW.js +1 -0
  9. package/dist/assets/HelpDialog-Dxc2yneu.js +1 -0
  10. package/dist/assets/{InProgressOperationBanner-B6iO22_7.js → InProgressOperationBanner-Dy0RiPsD.js} +1 -1
  11. package/dist/assets/JsonTreeView-BKUmh7Iw.js +1 -0
  12. package/dist/assets/MarkdownImageGallery-Cd6hLNmi.js +1 -0
  13. package/dist/assets/MarkdownRendererImpl-C-3B3mBt.js +1 -0
  14. package/dist/assets/MemoryDebugPanel-b116r1SF.js +1 -0
  15. package/dist/assets/OnboardingScreen-vBEhpU3q.js +1 -0
  16. package/dist/assets/OpenCodeStatusDialog-DH7dJ6MH.js +1 -0
  17. package/dist/assets/{PatchDiff-Du2s7T3U.js → PatchDiff-yM7vgQgi.js} +1 -1
  18. package/dist/assets/{PierreDiffViewer-B9K0gBvV.js → PierreDiffViewer-DnHKbYGl.js} +1 -1
  19. package/dist/assets/{PlanView-IkTcPrbw.js → PlanView-j0hLJmto.js} +2 -2
  20. package/dist/assets/RunOverview-ZuFZvDcu.js +2 -0
  21. package/dist/assets/ScheduledTasksDialog-UKXFFI91.js +5 -0
  22. package/dist/assets/{SettingsView-DIy5ZL4-.js → SettingsView-gB_NvyX4.js} +8 -8
  23. package/dist/assets/SettingsWindow-Dfb_RFpD.js +1 -0
  24. package/dist/assets/SourceBoardView-BjaL0nKs.js +1 -0
  25. package/dist/assets/SpaceAccessDialog-XzHRmIdT.js +1 -0
  26. package/dist/assets/SpaceApplyDialog-CxX9mrzT.js +1 -0
  27. package/dist/assets/{SpaceRow-YPmKQKeD.js → SpaceRow-vCpOCANO.js} +1 -1
  28. package/dist/assets/SpaceSetupOutput-CDZvJCf_.js +1 -0
  29. package/dist/assets/SpacesView-D3a9bCzn.js +1 -0
  30. package/dist/assets/{SubmoduleDiffSummary-RDY5md3p.js → SubmoduleDiffSummary-CQyRcvDZ.js} +1 -1
  31. package/dist/assets/{ToolOutputDialog-Dx85XZJs.js → ToolOutputDialog-judR_5mS.js} +2 -2
  32. package/dist/assets/{ToolPartDiffPreview-Dtv0xF9O.js → ToolPartDiffPreview-Ca9ISxfg.js} +1 -1
  33. package/dist/assets/UsageStatsView-C63Emjfj.js +1 -0
  34. package/dist/assets/{Virtualizer-DL535kyR.js → Virtualizer-DNgIEKcx.js} +1 -1
  35. package/dist/assets/{WalkthroughView-DcxbT5tc.js → WalkthroughView-D74b_7sC.js} +2 -2
  36. package/dist/assets/WorktreesView-hcm8Eb_C.js +1 -0
  37. package/dist/assets/appThemeRegistry-COeayQaQ.js +1 -0
  38. package/dist/assets/{ar-lP51qqz9.js → ar-1_zdYVV5.js} +2 -2
  39. package/dist/assets/computeVirtualFileMetrics-MZqvCQy0.js +3 -0
  40. package/dist/assets/{de-CpROAvTV.js → de-Ci7SGEQP.js} +3 -3
  41. package/dist/assets/{decorate-BNB7jeKg.js → decorate-CZeRRVC7.js} +1 -1
  42. package/dist/assets/{es-Bb8LKRhE.js → es-ZJii-6Tt.js} +2 -2
  43. package/dist/assets/{fr-BlNN9FC2.js → fr-C-hK8mvI.js} +2 -2
  44. package/dist/assets/{he-r546pCuc.js → he-t07CylP8.js} +2 -2
  45. package/dist/assets/index-D2tPUss-.js +1 -0
  46. package/dist/assets/{initializeSharedPreferences-dCHO04bl.js → initializeSharedPreferences-FxFkTjgn.js} +1 -1
  47. package/dist/assets/{isDiffPlainText-BwicHPpI.js → isDiffPlainText-C1F9opE5.js} +1 -1
  48. package/dist/assets/{isFilePlainText-Dk2R7BJo.js → isFilePlainText-B4SyJ-ni.js} +1 -1
  49. package/dist/assets/{ja-evNvJAHz.js → ja-iJr8aONy.js} +2 -2
  50. package/dist/assets/{katex-CMY-1eWf.css → katex-BEX7X_K8.css} +1 -1
  51. package/dist/assets/{katex.min-Iw9WSgM9.js → katex.min-C-51hS9A.js} +18 -18
  52. package/dist/assets/{ko-BPQP7lXe.js → ko-D5ow_yz-.js} +2 -2
  53. package/dist/assets/main-BtGnuno4.js +1048 -0
  54. package/dist/assets/main-uj5954n5.js +2 -0
  55. package/dist/assets/markdownCore-rBXCnAJp.js +9 -0
  56. package/dist/assets/miniChat-yWQmT2OS.js +2 -0
  57. package/dist/assets/mobile-NDAeGtzL.js +2 -0
  58. package/dist/assets/{moveWorkspacePath-B31RGdgu.js → moveWorkspacePath-BINgpJ9S.js} +1 -1
  59. package/dist/assets/{nl-CkQXd1nU.js → nl-CfqYrSVe.js} +2 -2
  60. package/dist/assets/{parseDiffFromFile-DcsKSY0J.js → parseDiffFromFile--DE4eHIp.js} +2 -2
  61. package/dist/assets/{patchFileDiff-Cx-HpjyI.js → patchFileDiff-BfFUmWgS.js} +1 -1
  62. package/dist/assets/pierreDiffTint-D9K6_CVD.js +29 -0
  63. package/dist/assets/{pl-C4i9Aizi.js → pl-Bn2_jAhL.js} +4 -4
  64. package/dist/assets/{pt-BR-CoYnG1CH.js → pt-BR-ZSDgn6cI.js} +2 -2
  65. package/dist/assets/relocateRestoredSession-C85Tk2y9.js +1 -0
  66. package/dist/assets/renderElectronMiniChatApp-BvAEmWhZ.js +2 -0
  67. package/dist/assets/{renderMobileApp-gDKxRJQi.js → renderMobileApp-T20l8ise.js} +7 -7
  68. package/dist/assets/{restartOpenCode-dq-SGun3.js → restartOpenCode-VEmIrLer.js} +1 -1
  69. package/dist/assets/runtimeEndpointReset-ExJsaWzA.js +55 -0
  70. package/dist/assets/scheduledTasksApi-NSyxVfHu.js +1 -0
  71. package/dist/assets/{selectionMarkdown-sDTBbKLh.js → selectionMarkdown-BJ2RhTXc.js} +2 -2
  72. package/dist/assets/{sessionOwnership-kZAtwMQd.js → sessionOwnership-BAX1xEJC.js} +1 -1
  73. package/dist/assets/{shikiHighlight-BRNXPlF-.js → shikiHighlight-DOzrE7BE.js} +1 -1
  74. package/dist/assets/{space-apply-CCOKLfrX.js → space-apply-DB_ZfJBW.js} +1 -1
  75. package/dist/assets/space-close-1kNlTkW1.js +1 -0
  76. package/dist/assets/{spaceNetwork-DUxJClu3.js → spaceNetwork-DA16ov_y.js} +1 -1
  77. package/dist/assets/{textMateThemeFromAppTheme-B6UJwdZz.js → textMateThemeFromAppTheme-BfIrjFAU.js} +1 -1
  78. package/dist/assets/{tr-D-_lz-lC.js → tr-C89uz1hs.js} +2 -2
  79. package/dist/assets/{uk-B49PGMYB.js → uk-uTYVPFrO.js} +2 -2
  80. package/dist/assets/{useAppFontEffects-3EN8Ava3.js → useAppFontEffects-C1ceAD51.js} +185 -185
  81. package/dist/assets/useCallableModelProviders-BkLsgs6y.js +1 -0
  82. package/dist/assets/{useInlineCommentController-l9cWyfuR.js → useInlineCommentController-ynkUsoVA.js} +1 -1
  83. package/dist/assets/{useRootScrollLock-UAQn24Y8.js → useRootScrollLock-DnoKH1HE.js} +2 -2
  84. package/dist/assets/{vendor-codemirror-autocomplete-C8FBSI9t.js → vendor-codemirror-autocomplete-BRKmCSiY.js} +1 -1
  85. package/dist/assets/{vendor-codemirror-commands-BhRb6jns.js → vendor-codemirror-commands-MmBpgSOc.js} +1 -1
  86. package/dist/assets/vendor-codemirror-lang-angular-Bj5Pk8sp.js +1 -0
  87. package/dist/assets/vendor-codemirror-lang-cpp-tZt-BOgi.js +1 -0
  88. package/dist/assets/vendor-codemirror-lang-css-DfdrZ848.js +1 -0
  89. package/dist/assets/{vendor-codemirror-lang-go-BHJEONih.js → vendor-codemirror-lang-go-C9OcoXdP.js} +2 -2
  90. package/dist/assets/vendor-codemirror-lang-html-C5kFuJzc.js +1 -0
  91. package/dist/assets/vendor-codemirror-lang-java-Divn2dnj.js +1 -0
  92. package/dist/assets/{vendor-codemirror-lang-javascript-CUmSxayT.js → vendor-codemirror-lang-javascript-DmPuKUEa.js} +2 -2
  93. package/dist/assets/vendor-codemirror-lang-jinja-B-8miA-Q.js +1 -0
  94. package/dist/assets/vendor-codemirror-lang-json-L0wsFFxi.js +1 -0
  95. package/dist/assets/vendor-codemirror-lang-less-CWlCIxCI.js +1 -0
  96. package/dist/assets/vendor-codemirror-lang-liquid-Dm8xthAW.js +1 -0
  97. package/dist/assets/vendor-codemirror-lang-markdown-CPn-qinN.js +1 -0
  98. package/dist/assets/vendor-codemirror-lang-php-DKIOifjN.js +1 -0
  99. package/dist/assets/vendor-codemirror-lang-python-BAVa3Hg5.js +3 -0
  100. package/dist/assets/vendor-codemirror-lang-rust-Dab90hdg.js +1 -0
  101. package/dist/assets/vendor-codemirror-lang-sass-eezaHFBZ.js +1 -0
  102. package/dist/assets/{vendor-codemirror-lang-sql-C1Jj9uuJ.js → vendor-codemirror-lang-sql-Vu-PR7cv.js} +2 -2
  103. package/dist/assets/vendor-codemirror-lang-vue-BthRGZHy.js +1 -0
  104. package/dist/assets/vendor-codemirror-lang-wast-Db6KSic0.js +1 -0
  105. package/dist/assets/vendor-codemirror-lang-xml-DQkh4sc1.js +1 -0
  106. package/dist/assets/vendor-codemirror-lang-yaml-Bt2N__AW.js +1 -0
  107. package/dist/assets/vendor-codemirror-language-DkBxRck3.js +3 -0
  108. package/dist/assets/vendor-codemirror-language-data-CTYHXywt.js +2 -0
  109. package/dist/assets/{vendor-codemirror-search-CvXM_pZg.js → vendor-codemirror-search-BKAwkhkm.js} +1 -1
  110. package/dist/assets/vendor-codemirror-streamparser-CmlTsbN2.js +1 -0
  111. package/dist/assets/vendor-codemirror-view-B66jUSmE.js +4 -0
  112. package/dist/assets/{vendor-replit-codemirror-vim-Ck2X_WZC.js → vendor-replit-codemirror-vim-D0bqFa1D.js} +5 -5
  113. package/dist/assets/{worker-DdhrXE7g.js → worker-BbEdJ2Oi.js} +18 -18
  114. package/dist/assets/workerFactory-Bw5qLmrM.js +1 -0
  115. package/dist/assets/{zh-CN-CS-9Os9n.js → zh-CN-DdTNG52a.js} +2 -2
  116. package/dist/assets/{zh-TW-D0XYVdcl.js → zh-TW-DPm_33Fi.js} +2 -2
  117. package/dist/index.html +3 -3
  118. package/dist/mini-chat.html +3 -3
  119. package/dist/mobile.html +3 -3
  120. package/package.json +2 -2
  121. package/server/index.js +4 -0
  122. package/server/lib/environment/store.js +3 -4
  123. package/server/lib/environment/store.test.js +17 -0
  124. package/server/lib/fs/DOCUMENTATION.md +4 -2
  125. package/server/lib/fs/routes.js +48 -13
  126. package/server/lib/fs/routes.test.js +118 -5
  127. package/server/lib/git/DOCUMENTATION.md +3 -1
  128. package/server/lib/git/contributor-remote.js +4 -0
  129. package/server/lib/git/contributor-remote.test.js +21 -0
  130. package/server/lib/git/service.js +20 -25
  131. package/server/lib/git/service.test.js +99 -0
  132. package/server/lib/git/worktree-creation.js +4 -5
  133. package/server/lib/github/DOCUMENTATION.md +1 -1
  134. package/server/lib/github/routes.auth.test.js +14 -0
  135. package/server/lib/github/routes.js +13 -5
  136. package/server/lib/github/routes.mutations.test.js +18 -2
  137. package/server/lib/message-queue/DOCUMENTATION.md +8 -2
  138. package/server/lib/message-queue/runtime.js +3 -2
  139. package/server/lib/message-queue/runtime.test.js +64 -2
  140. package/server/lib/openchamber-control/service.js +48 -13
  141. package/server/lib/openchamber-control/service.test.js +42 -0
  142. package/server/lib/opencode/DOCUMENTATION.md +3 -1
  143. package/server/lib/opencode/project-start-command.d.ts +11 -0
  144. package/server/lib/opencode/project-start-command.js +56 -0
  145. package/server/lib/opencode/project-start-command.test.js +80 -0
  146. package/server/lib/opencode/session-activity.js +43 -3
  147. package/server/lib/opencode/session-activity.test.js +97 -0
  148. package/server/lib/opencode/settings-runtime.js +19 -1
  149. package/server/lib/opencode/settings-runtime.test.js +23 -0
  150. package/server/lib/opencode/skill-routes.js +34 -1
  151. package/server/lib/opencode/skill-routes.test.js +99 -0
  152. package/server/lib/quota/DOCUMENTATION.md +13 -1
  153. package/server/lib/quota/providers/antigravity/api.js +104 -0
  154. package/server/lib/quota/providers/antigravity/auth.js +45 -0
  155. package/server/lib/quota/providers/antigravity/index.js +76 -0
  156. package/server/lib/quota/providers/antigravity/transforms.js +168 -0
  157. package/server/lib/quota/providers/antigravity/transforms.test.js +162 -0
  158. package/server/lib/quota/providers/codex.js +28 -4
  159. package/server/lib/quota/providers/codex.test.js +29 -0
  160. package/server/lib/quota/providers/google/auth.js +4 -49
  161. package/server/lib/quota/providers/google/transforms.js +3 -22
  162. package/server/lib/quota/providers/index.js +8 -0
  163. package/server/lib/quota/providers/opencode-go.js +3 -1
  164. package/server/lib/quota/providers/opencode-go.test.js +12 -0
  165. package/server/lib/routing/DOCUMENTATION.md +3 -1
  166. package/server/lib/routing/runtime.js +34 -1
  167. package/server/lib/routing/runtime.test.js +43 -1
  168. package/server/lib/scheduled-tasks/DOCUMENTATION.md +11 -0
  169. package/server/lib/scheduled-tasks/existing-session.js +52 -8
  170. package/server/lib/scheduled-tasks/existing-session.test.js +121 -0
  171. package/server/lib/scheduled-tasks/routes.js +26 -0
  172. package/server/lib/scheduled-tasks/runtime.js +1 -0
  173. package/server/lib/session-assist/runtime.js +3 -0
  174. package/server/lib/session-assist/runtime.test.js +47 -0
  175. package/server/lib/skills-catalog/DOCUMENTATION.md +10 -1
  176. package/server/lib/skills-catalog/install.js +1 -1
  177. package/server/lib/skills-catalog/installed-sources.d.ts +17 -0
  178. package/server/lib/skills-catalog/installed-sources.js +112 -0
  179. package/server/lib/skills-catalog/installed-sources.test.js +94 -0
  180. package/server/lib/small-model/DOCUMENTATION.md +12 -5
  181. package/server/lib/small-model/index.js +6 -4
  182. package/server/lib/small-model/index.test.js +40 -0
  183. package/server/lib/small-model/routes.js +3 -2
  184. package/server/lib/source-control/change-request-worktree.js +2 -6
  185. package/server/lib/source-control/mutation-storage.js +4 -1
  186. package/server/lib/source-control/mutation-storage.test.js +21 -0
  187. package/server/lib/spaces/DOCUMENTATION.md +1 -1
  188. package/server/lib/spaces/journey.js +10 -3
  189. package/server/lib/spaces/journey.test.js +13 -1
  190. package/server/lib/terminal/history.js +22 -2
  191. package/server/lib/terminal/history.test.js +23 -0
  192. package/server/lib/terminal/theme-response.js +14 -0
  193. package/server/lib/terminal/theme-response.test.js +10 -0
  194. package/dist/assets/AboutDialog-e8ek_kPI.js +0 -1
  195. package/dist/assets/ArchiveView-CjF4_TFg.js +0 -1
  196. package/dist/assets/GuestSurfacePane-4kmEXPLD.js +0 -1
  197. package/dist/assets/HelpDialog-CITMqPDK.js +0 -1
  198. package/dist/assets/JsonTreeView-xGikhCtL.js +0 -1
  199. package/dist/assets/MarkdownImageGallery-D0FJyr7C.js +0 -1
  200. package/dist/assets/MarkdownRendererImpl-BIM7Pjwk.js +0 -1
  201. package/dist/assets/MemoryDebugPanel-CBk8QW-M.js +0 -1
  202. package/dist/assets/OnboardingScreen-Cy6ARiMS.js +0 -1
  203. package/dist/assets/OpenCodeStatusDialog-YMHuJzwt.js +0 -1
  204. package/dist/assets/RunOverview-CHkGSW1x.js +0 -2
  205. package/dist/assets/ScheduledTasksDialog-77SO8zdJ.js +0 -4
  206. package/dist/assets/SettingsWindow-X74FIkdo.js +0 -1
  207. package/dist/assets/SourceBoardView-Cff2ejOW.js +0 -1
  208. package/dist/assets/SpaceAccessDialog-BXMZNRei.js +0 -1
  209. package/dist/assets/SpaceApplyDialog-BEJd2ryu.js +0 -1
  210. package/dist/assets/SpaceSetupOutput-Cb3XcIII.js +0 -1
  211. package/dist/assets/SpacesView-I3HaRKtW.js +0 -1
  212. package/dist/assets/UsageStatsView-DwTt9zIz.js +0 -1
  213. package/dist/assets/WorktreesView-Bh7GLvrR.js +0 -1
  214. package/dist/assets/appThemeRegistry-Bzb67M9O.js +0 -1
  215. package/dist/assets/computeVirtualFileMetrics-WAp98Bb7.js +0 -3
  216. package/dist/assets/index-BsupKM40.js +0 -1
  217. package/dist/assets/main-C_QGhDBL.js +0 -1048
  218. package/dist/assets/main-pWZ7F_hy.js +0 -2
  219. package/dist/assets/markdownCore-6gz4uJDQ.js +0 -9
  220. package/dist/assets/miniChat-DnaTfdYh.js +0 -2
  221. package/dist/assets/mobile-C7DIJqP8.js +0 -2
  222. package/dist/assets/pierreDiffTint-B297eqF0.js +0 -28
  223. package/dist/assets/relocateRestoredSession-D3lujODj.js +0 -1
  224. package/dist/assets/renderElectronMiniChatApp-BF4hNe69.js +0 -2
  225. package/dist/assets/runtimeEndpointReset-D6Lxhk0S.js +0 -55
  226. package/dist/assets/scheduledTasksApi-DUbAMrjW.js +0 -1
  227. package/dist/assets/space-close-CWcWwH4_.js +0 -1
  228. package/dist/assets/useCallableModelProviders-BB9xkUzM.js +0 -1
  229. package/dist/assets/vendor-codemirror-lang-angular-BpYCRJSk.js +0 -1
  230. package/dist/assets/vendor-codemirror-lang-cpp-BI3uPyjT.js +0 -1
  231. package/dist/assets/vendor-codemirror-lang-css-B2_PZTBl.js +0 -1
  232. package/dist/assets/vendor-codemirror-lang-html-BpvvTxbZ.js +0 -1
  233. package/dist/assets/vendor-codemirror-lang-java-BM5LQZ4u.js +0 -1
  234. package/dist/assets/vendor-codemirror-lang-jinja-D8nLZQPK.js +0 -1
  235. package/dist/assets/vendor-codemirror-lang-json-VDxF27mO.js +0 -1
  236. package/dist/assets/vendor-codemirror-lang-less-BecU2BJP.js +0 -1
  237. package/dist/assets/vendor-codemirror-lang-liquid-DCw83Anh.js +0 -1
  238. package/dist/assets/vendor-codemirror-lang-markdown-CimQAQbQ.js +0 -1
  239. package/dist/assets/vendor-codemirror-lang-php-C5Kpnpyb.js +0 -1
  240. package/dist/assets/vendor-codemirror-lang-python-BFE1OJNx.js +0 -3
  241. package/dist/assets/vendor-codemirror-lang-rust-hqZDyGIJ.js +0 -1
  242. package/dist/assets/vendor-codemirror-lang-sass-CAZML-Jl.js +0 -1
  243. package/dist/assets/vendor-codemirror-lang-vue-BHOTXcKp.js +0 -1
  244. package/dist/assets/vendor-codemirror-lang-wast-DcCHfPUI.js +0 -1
  245. package/dist/assets/vendor-codemirror-lang-xml-BO_V-1wZ.js +0 -1
  246. package/dist/assets/vendor-codemirror-lang-yaml-CPimap_N.js +0 -1
  247. package/dist/assets/vendor-codemirror-language-BBADuAkg.js +0 -3
  248. package/dist/assets/vendor-codemirror-language-data-Cu5ZbrPm.js +0 -2
  249. package/dist/assets/vendor-codemirror-view-1e0FQ6Wn.js +0 -4
  250. package/dist/assets/workerFactory-De9YXIdE.js +0 -1
@@ -1,7 +1,7 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesView-BeMtsSlV.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/katex.min-Iw9WSgM9.js","assets/vendor-zod-CVhJ1Zpv.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-DgOf1DP0.js","assets/katex-CMY-1eWf.css","assets/useAppFontEffects-3EN8Ava3.js","assets/vendor-base-ui-CXFyogip.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-tanstack-react-virtual-CvuLsk7D.js","assets/vendor-tanstack-virtual-core-DPaNcJcT.js","assets/vendor-framer-motion-DxDVhOLc.js","assets/vendor-motion-dom-HXPOMxb7.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-codemirror-commands-BhRb6jns.js","assets/vendor-codemirror-state-Dek9sMtw.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-1e0FQ6Wn.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-codemirror-language-BBADuAkg.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-CUmSxayT.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-C8FBSI9t.js","assets/vendor-codemirror-lang-json-VDxF27mO.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-B2_PZTBl.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-BpvvTxbZ.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-CimQAQbQ.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-Cu5ZbrPm.js","assets/vendor-codemirror-lang-python-BFE1OJNx.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-legendapp-list-BCBzRcfK.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/shikiHighlight-BRNXPlF-.js","assets/vendor-codemirror-search-CvXM_pZg.js","assets/vendor-replit-codemirror-vim-Ck2X_WZC.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/moveWorkspacePath-B31RGdgu.js","assets/JsonTreeView-xGikhCtL.js","assets/parseDiffFromFile-DcsKSY0J.js","assets/computeVirtualFileMetrics-WAp98Bb7.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-yJ9XpNMI.js","assets/vendor-pierre-theming-Dgp7B_O4.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/vendor-diff-C3JhlQdm.js","assets/Virtualizer-BP6uuKe_.js","assets/isFilePlainText-Dk2R7BJo.js","assets/appThemeRegistry-Bzb67M9O.js","assets/textMateThemeFromAppTheme-B6UJwdZz.js","assets/runtimeEndpointReset-D6Lxhk0S.js","assets/Virtualizer-DL535kyR.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/useInlineCommentController-l9cWyfuR.js","assets/FilePreviewCommentMenu-DlVgwRsr.js","assets/scheduledTasksApi-DUbAMrjW.js","assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-capacitor-push-notifications-KNe1zSBF.js"])))=>i.map(i=>d[i]);
2
- import{f as de,r as kr,j as t,R as c,c as vs,h as za}from"./vendor-react-BUCujlKS.js";import{u as Fe,Y as rn,ba as xo,bb as gi,bc as Xe,a2 as St,bd as ms,be as en,l as Dr,bf as Ba,bg as yo,bh as La,bi as Fa,bj as $a,bk as Wa,bl as Va,e as zt,n as on,z as Ua,A as Ga,bm as us,ai as cr,bn as Ka,Z as Vs,b as bi,aI as ur,a_ as Ha,ay as xi,ak as qa,aj as Ya,_ as yi,ah as Ja,$ as vo,bo as vi,av as wi,v as ji,bp as kn}from"./katex.min-Iw9WSgM9.js";import{G as bs,dA as Xa,a2 as lt,cF as Sr,cG as wo,J as jo,gf as Qa,u as he,z as ce,cb as Za,I as H,dh as el,B as Ce,ak as ko,a7 as ps,L as Z,bF as So,gg as tl,gh as sl,d1 as nl,_ as dt,aC as rl,gi as Yt,gj as il,gk as ki,gl as ol,gm as al,er as _r,cZ as ll,c_ as cl,F as Oe,ec as ul,ee as Mr,ef as Or,gn as zr,eh as dl,eg as No,go as Br,dy as Dn,ci as Co,gp as fl,d$ as Ro,ao as at,ch as Eo,aq as Un,gq as ml,gr as pl,gs as hl,gt as gl,f6 as An,fF as Nr,fp as Ot,gu as bl,k as Io,as as Ao,cu as Po,cv as To,cw as Do,gv as xl,gw as yl,gx as vl,dz as Si,gy as _o,gz as Mo,y as Oo,gA as wl,gB as jl,gC as zo,gD as kl,cH as Sl,a3 as Nl,cS as Cl,gE as Rl,cR as Us,gF as Ni,gG as Bo,K as El,gH as Il,ct as Gn,cf as Al,bA as Lo,dn as Fo,gI as Pl,gJ as Tl,gK as fs,gL as xs,T as Dl,U as _l,V as Ml,gM as Ol,fy as zl,ap as Lr,dY as Bl,e0 as Ll,eK as Fl,e$ as $l,eW as Wl,ex as $o,eX as Vl,f0 as Ul,e1 as Gl,dZ as Kl,fx as Hl,ft as ql,gN as Yl,gO as Jl,gP as Xl,gQ as Ql,fw as Ci,dQ as Sn,aE as Zl,aF as ec,c9 as tc,aG as sc,bM as nc,bO as Nn,eZ as rc,aw as ic,e3 as oc,fC as ac,fE as lc,fz as cc,cY as Wo,aI as Je,cP as uc,cg as dc,gR as fc,gS as mc,gT as pc,gU as hc,cU as gc,gV as bc,gW as Fr,bR as xc,an as yc,gX as vc,gY as wc,cx as Vo,da as jc,db as kc,dc as Sc,dd as Nc,gZ as Cc,dj as Rc,di as Ec,de as Ic,g_ as Ac,df as Pc,dg as Tc,dp as Dc,dm as _c,g$ as Mc,h0 as Oc,h1 as zc,h2 as Bc,h3 as Lc,h4 as Fc,h5 as $c,h6 as Wc,dq as Vc,dr as Uc,ds as Gc,dt as Kc}from"./useAppFontEffects-3EN8Ava3.js";import{a1 as hs,a2 as Hc,a3 as qc,a4 as Yc,a5 as Jc,a6 as Uo,a7 as Go,a8 as Ko,a9 as Xc,aa as Qc,ab as Zc,ac as dr,ad as eu,ae as tu,af as su,S as nu,A as Ho,a as ru,ag as iu,ah as ou,ai as au,aj as lu,H as Cn,P as cu,Q as uu,K as du,U as fr,W as fu,X as mu,y as pu,ak as hu,I as gu,J as bu,al as xu,am as yu,L as vu,w as wu,Y as ju,G as ku,an as Su,ao as Nu,Z as Cu,ap as Ru,aq as Eu,ar as Iu,as as Au,at as Pu,au as Tu,av as Du,aw as _u,ax as Mu,ay as Ou,az as zu,aA as Bu,aB as Lu,aC as Fu,aD as $u,aE as Wu,aF as Vu,aG as Uu}from"./runtimeEndpointReset-D6Lxhk0S.js";import{i as Gu}from"./initializeSharedPreferences-dCHO04bl.js";import{_ as ws}from"./vendor-vite-runtime-DD1OZmLC.js";import{S as Ku,A as Hu}from"./SettingsView-DIy5ZL4-.js";import{PlanView as qu}from"./PlanView-IkTcPrbw.js";import{SpaceAccessDialog as Yu}from"./SpaceAccessDialog-BXMZNRei.js";import{SpaceApplyDialog as Ju}from"./SpaceApplyDialog-BEJd2ryu.js";import{SpaceSetupOutputDialog as Xu}from"./SpaceSetupOutput-Cb3XcIII.js";import{RunOverview as Qu}from"./RunOverview-CHkGSW1x.js";import{p as Zu}from"./vendor-aparajita-capacitor-secure-storage-5IShChL0.js";import{Capacitor as ed,registerPlugin as td}from"./vendor-capacitor-core-B4EWRrHz.js";import{k as Cr,d as sd,M as _n,J as Rr,s as qo,a as $r,p as nd,_ as Ri,f as Wr,V as rd,K as Ei,P as id,b as od,c as ad,U as ld,Z as cd,Q as ud,r as dd}from"./vendor-remixicon-react-D6dZ0UwF.js";import{f as Vr,h as js,i as Ur,P as Gr,D as Kr,j as Hr}from"./vendor-dnd-kit-core-BZknOX2w.js";import{s as qr,S as Yr,v as Jr,u as Xr}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Qr}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{c as fd}from"./sessionOwnership-kZAtwMQd.js";import{c as Zr,p as Yo}from"./vendor-zustand-BAGL70zf.js";import{toast as Er}from"./vendor-sonner-DFyL3AvE.js";import{S as md}from"./SpaceRow-YPmKQKeD.js";import{UsageStatsView as pd}from"./UsageStatsView-DwTt9zIz.js";import{ArchiveSessionsView as hd}from"./ArchiveView-CjF4_TFg.js";import{MobileSourceBoard as gd}from"./SourceBoardView-Cff2ejOW.js";import{ScheduledTasksView as bd}from"./ScheduledTasksDialog-77SO8zdJ.js";import{i as xd,a as yd,b as vd,c as wd,S as jd,W as kd}from"./SubmoduleDiffSummary-RDY5md3p.js";import{R as Sd,I as Nd,C as Cd,a as Rd,b as Ed,D as Id}from"./InProgressOperationBanner-B6iO22_7.js";import{b as Ii,a as Ad,c as Pd,u as Td,i as Dd,f as Ai,B as _d,C as Md,P as Pi}from"./patchFileDiff-Cx-HpjyI.js";import{P as Od}from"./PierreDiffViewer-B9K0gBvV.js";import{p as zd}from"./parseDiffFromFile-DcsKSY0J.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-CVhJ1Zpv.js";import"./vendor-opencode-client-DgOf1DP0.js";import"./vendor-base-ui-CXFyogip.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tanstack-react-virtual-CvuLsk7D.js";import"./vendor-tanstack-virtual-core-DPaNcJcT.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-BhRb6jns.js";import"./vendor-codemirror-state-Dek9sMtw.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-1e0FQ6Wn.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-language-BBADuAkg.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-CUmSxayT.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-C8FBSI9t.js";import"./vendor-codemirror-lang-json-VDxF27mO.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-B2_PZTBl.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-BpvvTxbZ.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-CimQAQbQ.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-Cu5ZbrPm.js";import"./vendor-codemirror-lang-python-BFE1OJNx.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-legendapp-list-BCBzRcfK.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-yaml-3778uTud.js";import"./shikiHighlight-BRNXPlF-.js";import"./vendor-codemirror-search-CvXM_pZg.js";import"./vendor-replit-codemirror-vim-Ck2X_WZC.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./appThemeRegistry-Bzb67M9O.js";import"./textMateThemeFromAppTheme-B6UJwdZz.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-qrcode-DTJ12-WC.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./vendor-strip-json-comments-5dJlOkP1.js";import"./useCallableModelProviders-BB9xkUzM.js";import"./restartOpenCode-dq-SGun3.js";import"./useInlineCommentController-l9cWyfuR.js";import"./FilePreviewCommentMenu-DlVgwRsr.js";import"./spaceNetwork-DUxJClu3.js";import"./space-apply-CCOKLfrX.js";import"./scheduledTasksApi-DUbAMrjW.js";import"./vendor-cron-parser-CjvYVigk.js";import"./vendor-luxon-BZ0puJYg.js";import"./changesTree-CePHbFcj.js";import"./computeVirtualFileMetrics-WAp98Bb7.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-BwicHPpI.js";import"./vendor-diff-C3JhlQdm.js";import"./pierreDiffTint-B297eqF0.js";import"./Virtualizer-DL535kyR.js";let Jo=null,Ti=!1;const Bd=new Promise(n=>{Jo=n});function Ld(){Ti||(Ti=!0,Jo?.())}const Fd=6,$d=n=>n.parentID??null,Di=n=>{const e=n.replace(/\/+$/,"");return e.slice(e.lastIndexOf("/")+1)||e},Wd=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),Vd=(n,e)=>{if(!n)return"";let s=null,i=-1;for(const r of e){const o=Wd(r.path);(n===o||n.startsWith(`${o}/`))&&o.length>i&&(s=r,i=o.length)}return s?s.label?.trim()||Di(s.path):Di(n)},Ud=()=>{const n=bs.getState().activeSessions,e=Xa.getState().index.session.unseenCount,s=Fe.getState().notifyOnSubtasks,i=lt.getState().projects,r=Sr.getState().ids,o=wo.getState().rankById;let a=0;const l=[];for(const m of n){const f=$d(m)!==null,p=(e[m.id]??0)>0&&(!f||s);p&&(a+=1),f||l.push({session:m,unread:p,project:Vd(jo(m),i)})}l.sort((m,f)=>Qa(m.session,f.session,r,o));const u=l.slice(0,Fd).map(({session:m,unread:f,project:g})=>({id:m.id,title:m.title??"",unread:f,project:g}));return{runtimeKey:rn(),attentionCount:a,recentSessions:u}},Gd="__OPENCHAMBER_WIDGET_SNAPSHOT__",Kd=()=>{typeof window>"u"||(window[Gd]=()=>{try{return JSON.stringify(Ud())}catch{return null}})},mr="mobile-app-update-available",_i="mobile-app-update-toast-dismissed-version",Hd=()=>{const n=de.c(8),{t:e}=he(),s=hs(qd),i=hs(Yd),r=hs(Jd),o=hs(Xd);let a;n[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Set,n[0]=a):a=n[0];const l=kr.useRef(a);let u,m;return n[1]!==s||n[2]!==o||n[3]!==i||n[4]!==e||n[5]!==r?(u=()=>{if(xo()!=="android"||i!=="mobile"||!s||!r||!o){ce.dismiss(mr);return}gi().getItem(_i)!==r&&(l.current.has(r)||(l.current.add(r),ce.info(e("mobileUpdate.toast.available.title"),{id:mr,description:e("mobileUpdate.toast.available.description",{version:r}),duration:1/0,icon:t.jsx(H,{name:"download",className:"h-4 w-4 text-muted-foreground"}),action:{label:e("mobileUpdate.toast.actions.download"),onClick:()=>{Za(o)}},cancel:{label:e("mobileUpdate.toast.actions.dismiss"),onClick:()=>{gi().setItem(_i,r),ce.dismiss(mr)}}})))},m=[s,o,i,e,r],n[1]=s,n[2]=o,n[3]=i,n[4]=e,n[5]=r,n[6]=u,n[7]=m):(u=n[6],m=n[7]),kr.useEffect(u,m),null};function qd(n){return n.available}function Yd(n){return n.runtimeType}function Jd(n){return n.info?.version}function Xd(n){return n.info?.downloadUrl}const Mi="calc(var(--oc-safe-area-top, 0px) + var(--oc-visual-viewport-offset-top, 0px) + 16px)";function Qd(n){const e=de.c(3);let s,i;e[0]!==n?(s=()=>{const r=window.visualViewport,o=n.current;if(!r||!o)return;let a="";const l=()=>{const u=`${Math.max(0,Math.round(r.offsetTop))}px`;u!==a&&(a=u,o.style.setProperty("--oc-visual-viewport-offset-top",u))};return l(),r.addEventListener("scroll",l),r.addEventListener("resize",l),()=>{r.removeEventListener("scroll",l),r.removeEventListener("resize",l)}},i=[n],e[0]=n,e[1]=s,e[2]=i):(s=e[1],i=e[2]),c.useEffect(s,i)}function Zd(){const n=de.c(1),e=c.useRef(null);Qd(e);let s;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx("div",{ref:e,className:"contents",children:t.jsx(el,{position:"top-center",offset:Mi,mobileOffset:{top:Mi}})}),n[0]=s):s=n[0],s}const Oi=300,ef="openchamber.mobile.connectLog.v1",gs=[];if(typeof window<"u")try{window.localStorage.removeItem(ef)}catch{}const ei=(n,e)=>{gs.push({at:Date.now(),step:n,detail:e}),gs.length>Oi&&gs.splice(0,gs.length-Oi)};typeof window<"u"&&ei("app:launch","{}");const tf=()=>[...gs],sf=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)}`},Xo=n=>`${sf(n.at)} ${n.step}${n.detail&&n.detail!=="{}"?` ${n.detail}`:""}`,nf=()=>gs.map(Xo).join(`
3
- `),Qo=(n,e)=>{const s=de.c(10),i=700,r=c.useRef(null),o=c.useRef(null),a=c.useRef(!1);let l;s[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{r.current!==null&&window.clearTimeout(r.current),r.current=null,o.current=null},s[0]=l):l=s[0];const u=l;let m,f;s[1]===Symbol.for("react.memo_cache_sentinel")?(m=()=>u,f=[u],s[1]=m,s[2]=f):(m=s[1],f=s[2]),c.useEffect(m,f);let g;s[3]!==i||s[4]!==n?(g=j=>{a.current=!1,o.current={x:j.clientX,y:j.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]=g):g=s[5];const p=g;let h;s[6]===Symbol.for("react.memo_cache_sentinel")?(h=j=>{const R=o.current;R&&(Math.abs(j.clientX-R.x)>10||Math.abs(j.clientY-R.y)>10)&&u()},s[6]=h):h=s[6];const x=h;let v;s[7]===Symbol.for("react.memo_cache_sentinel")?(v=j=>{a.current&&(a.current=!1,j.preventDefault(),j.stopPropagation())},s[7]=v):v=s[7];const b=v;let C;return s[8]!==p?(C={onPointerDown:p,onPointerMove:x,onPointerUp:u,onPointerCancel:u,onClickCapture:b},s[8]=p,s[9]=C):C=s[9],C},rf=async(n,e)=>{let s;const i=new Promise(r=>{s=setTimeout(()=>r({response:null,failure:"timeout"}),n)});try{return await Promise.race([e.then(r=>({response:r,failure:null}),r=>({response:null,failure:r instanceof Error?r.message:String(r)})),i])}finally{s!==void 0&&clearTimeout(s)}},of=(n,e)=>new Promise(s=>{const i=l=>{clearTimeout(o),a(),s(l)},r=l=>{l.state==="connected"?i(!0):(l.state==="idle"||l.terminal)&&i(!1)},o=setTimeout(()=>i(!1),e),a=n.subscribeStatus(r);r(n.getStatus())}),ks=(n,e,s,i)=>rf(i,n.fetch(e,s)),Zo=async(n,e,s,i)=>{const r=Date.now()+i;let o=await ks(n,e,s,i);for(;!o.response&&o.failure!=="timeout"&&n.getStatus().state!=="connected";){const a=r-Date.now();if(a<=0||!await of(n,a))return o;const l=r-Date.now();if(l<=0)return o;o=await ks(n,e,s,l)}return o},Mn="openchamber.mobile.connections.v1",af="openchamber.mobile.",zi="openchamber.mobile.deviceId",lf=()=>{try{const n=window.localStorage.getItem(zi);if(n&&n.trim())return n.trim();const e=crypto.randomUUID();return window.localStorage.setItem(zi,e),e}catch{return crypto.randomUUID()}},Bi=()=>`mobile:${lf()}`,Li=()=>{try{const n=ed.getPlatform();return n==="ios"||n==="android"?n:void 0}catch{return}},ea=12,ti=8e3,cf=2500,uf=3e3,On=2500,df=()=>{let n=0;return{begin:()=>(n+=1,n),cancel:()=>{n+=1},isCurrent:e=>e===n}},Rs=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(/\/+$/,"")},Pn=n=>{try{return new URL(n).host}catch{return n}},Ss=n=>{try{return Rs(n)}catch{return n.trim().replace(/\/+$/g,"")}},ta=(n,e)=>Ss(n)===Ss(e),sa=n=>`relay:${n.serverId}@${n.relayUrl.trim()}`,ff=n=>`relay://${n.serverId}`,Kn=n=>n.candidates.filter(e=>e.kind==="direct"),Qt=n=>{const e=n.candidates.find(s=>s.kind==="relay");return e&&e.kind==="relay"?e.relay:null},Tt=n=>{const e=Kn(n)[0];if(e)return e.url;const s=Qt(n);return s?ff(s):""},Ke=n=>{const e=Qt(n);if(e)return sa(e);const s=Kn(n)[0];return s?Ss(s.url):""},zn=(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=>Ss(o.url)));return e.some(o=>o.kind==="relay"?i!==null&&o.relay.serverId===i:r.has(Ss(o.url)))},si=n=>{const e=(()=>{try{return Rs(n)}catch{return""}})();return e?[{kind:"direct",url:e}]:[]},Fi=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(...si(n.url)),n.relay&&e.push({kind:"relay",relay:n.relay}),e},ni=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}}},na=n=>{try{return JSON.stringify(n)}catch{return String(n)}},Ee=(n,e={})=>{const s=na(e);console.info("[mobile-connect]",n,s),ei(n,s)},Gs=(n,e={})=>{Ee(n,e)},Ns=(n,e={})=>{const s=na(e);console.info("[mobile-storage]",n,s),ei(n,s)},mf=n=>{if(typeof n!="string")return n;try{return JSON.parse(n)}catch{return n}},pf=n=>{if(typeof n!="string")return n??void 0;try{return JSON.parse(n)}catch{return n}},hf=async(n,e)=>{if(!Xe())return null;try{const{CapacitorHttp:s}=await ws(async()=>{const{CapacitorHttp:o}=await import("./vendor-capacitor-core-B4EWRrHz.js");return{CapacitorHttp:o}},[]),i=Fa(n,new Headers(e?.headers)),r=await s.request({url:n,method:e?.method||"GET",headers:Object.fromEntries(i.entries()),data:pf(e?.body)});return{ok:r.status>=200&&r.status<300,status:r.status,source:"native-http",json:async()=>mf(r.data)}}catch(s){return Ee("native-http:failed",{url:n,error:s instanceof Error?s.message:String(s)}),null}},gf=async(n,e)=>{const s=await fetch(n,e).catch(i=>(Ee("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},Bn=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)}},Zt=async(n,e,s)=>{const i=s?.totalTimeoutMs??ti,r=Date.now(),o=await Bn(Math.min(cf,i),hf(n,e));if(o)return o;const a=new AbortController,l=Math.max(500,i-(Date.now()-r));return Bn(l,gf(n,{...e,signal:a.signal}),()=>a.abort())},Hn=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}},Cs=15e3,ra=n=>{n?.owned&&n.client.close()},$i=async(n,e)=>{if(n.status===401)return e?"auth-failed":"needs-login";if(!n.ok&&n.status!==404)return"auth-failed";const s=await Hn(n);return s&&s.disabled!==!0&&s.authenticated===!1?e?"auth-failed":"needs-login":"ok"},bf=async(n,e,s,i=Cs,r)=>{const o=e?{Authorization:`Bearer ${e}`}:void 0,a=aa(n);if(a){const{response:u,failure:m}=await ks(a,"/auth/session",{headers:o},i);if(Ee("relay:session",{shared:!0,ok:u?.ok===!0,status:u?.status??null,hasToken:!!e,error:m}),u){const f=await $i(u,e);return f==="ok"&&r?.keepTunnel?{outcome:f,tunnel:{client:a,owned:!1}}:{outcome:f}}}const l=yo({relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk});try{const{response:u,failure:m}=await Zo(l,"/auth/session",{headers:o},i);Ee("relay:session",{shared:!1,ok:u?.ok===!0,status:u?.status??null,hasToken:!!e,error:m});const f=u?await $i(u,e):"unreachable";return f==="ok"&&r?.keepTunnel?{outcome:f,tunnel:{client:l,owned:!0}}:(l.close(),{outcome:f})}catch(u){throw l.close(),u}},xf=(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&&Ba(a,r),ms({apiBaseUrl:o,clientToken:e,runtimeKey:i??sa(n),relay:a})},yf=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=ni(e.relay);return s?{kind:"relay",relay:s}:null}return null},vf=n=>{if(n.mode==="relay"){const e=ni(n.relay);return e?[{kind:"relay",relay:e}]:[]}return typeof n.url=="string"?si(n.url):[]},es=()=>{if(typeof window>"u")return[];let n;try{n=JSON.parse(window.localStorage.getItem(Mn)||"[]")}catch{return[]}if(!Array.isArray(n))return[];const e=Xe();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(yf).filter(u=>!!u):vf(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:Pn(Tt({candidates:r})),l={id:i.id,label:a,candidates:r,lastUsedAt:typeof i.lastUsedAt=="number"?i.lastUsedAt:0};return e?[{...l,hasToken:!!i.hasToken||!!o}]:[{...l,clientToken:o,hasToken:!!o}]}).sort((s,i)=>i.lastUsedAt-s.lastUsedAt)},Ir=n=>n.kind==="relay"?{kind:"relay",relay:{relayUrl:n.relay.relayUrl,serverId:n.relay.serverId,hostEncPubJwk:n.relay.hostEncPubJwk}}:{kind:"direct",url:n.url},ri=n=>{if(typeof window>"u")return;const e=Xe(),s=n.slice(0,ea).map(i=>{const r={id:i.id,label:i.label,candidates:i.candidates.map(Ir),lastUsedAt:i.lastUsedAt};return e?{...r,hasToken:!!(i.hasToken||i.clientToken)}:{...r,clientToken:i.clientToken}});try{window.localStorage.setItem(Mn,JSON.stringify(s))}catch(i){console.warn("[mobile-storage] failed to persist connection metadata",i)}},ia=(n,e)=>{const s=n.find(o=>e.id&&o.id===e.id||zn(o.candidates,e.candidates)),i=Xe(),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&&!zn(o.candidates,e.candidates))].slice(0,ea)},ii=Zu,wf=0,oi=n=>`${af}token.${encodeURIComponent(n)}`,jf=async(n,e)=>{let s;const i=new Promise(r=>{s=window.setTimeout(()=>r(e),uf)});try{return await Promise.race([n.catch(()=>e),i])}finally{s!==void 0&&window.clearTimeout(s)}},ai=async(n,e,s)=>Xe()?jf(e().catch(i=>(console.warn(`[mobile-storage] ${n} failed`,i),s)),s):s,tn=async n=>{Ns("secure:read-start",{key:n});const e=await ai("secure:read",async()=>(await ii.internalGetItem({prefixedKey:oi(n),sync:!1})).data,null),s=typeof e=="string"&&e.trim()?e:void 0;return Ns("secure:read",{key:n,hasToken:!!s}),s},Jt=async(n,e)=>{Ns("secure:write-start",{key:n});const s=await ai("secure:write",async()=>(await ii.internalSetItem({prefixedKey:oi(n),data:e,sync:!1,access:wf}),!0),!1);return Ns("secure:write",{key:n,ok:s}),s},kf=async n=>{await ai("secure:delete",async()=>(await ii.internalRemoveItem({prefixedKey:oi(n),sync:!1}),!0),!1)},Sf=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,l=typeof a.url=="string"?a.url:null,u=typeof a.clientToken=="string"?a.clientToken.trim():"";if(!l||!u)return o;if(!await e(l,u))return i+=1,o;s+=1;const{clientToken:m,...f}=a;return{...f,hasToken:!0}})),migrated:s,failed:i}},oa=async()=>{if(typeof window>"u"||!Xe())return;let n;try{n=JSON.parse(window.localStorage.getItem(Mn)||"[]")}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;Ns("secure:migrate-start",{count:e.length});const s=await Sf(n,async(i,r)=>{const o=Ss(i);return await Jt(o,r)?await tn(o)===r:!1});if(s.migrated>0)try{window.localStorage.setItem(Mn,JSON.stringify(s.records))}catch(i){console.warn("[mobile-storage] failed to finalize secure token migration",i);return}Ns("secure:migrate-done",{migrated:s.migrated,failed:s.failed})},Nf=async()=>(await oa(),es()),Ln=async n=>{const e=ia(es(),n);return ri(e),Xe()&&n.clientToken&&await Jt(Ke({candidates:n.candidates}),n.clientToken),e},Cf=async n=>{const e=es(),s=e.find(r=>r.id===n)??null,i=e.filter(r=>r.id!==n);return ri(i),s&&Xe()&&await kf(Ke(s)),i},Rf=1500,Fn=async(n,e,s)=>{const i=s?.fast?{totalTimeoutMs:On}:void 0,r=Qt({candidates:n})?.serverId??null,o=n.find(m=>m.kind==="relay")??null,a=n.filter(m=>m.kind==="direct"),l=async()=>{for(const m of a){const f=Rs(m.url)||m.url,g=e?{Authorization:`Bearer ${e}`}:void 0,p=await Zt(`${f}/health`,{method:"GET"},i);if(Ee("probe:direct:health",{url:f,ok:p?.ok===!0,status:p?.status??null,source:p?.source??null}),!p?.ok)continue;if(r){const b=await p.json().catch(()=>null),C=b&&typeof b=="object"?b.serverId:null;if(typeof C=="string"&&C&&C!==r){Ee("probe:server-id-mismatch",{url:f});continue}}const h=await Zt(`${f}/auth/session`,{method:"GET",credentials:e?"omit":"include",headers:g},i);if(Ee("probe:direct:session",{url:f,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 Hn(h);if(x&&x.disabled!==!0&&x.authenticated===!1)return{status:"needs-login"};const v=x?.disabled===!0;return!e&&Xe()&&!v&&x?.scope!=="client"?{status:"needs-login"}:{status:"ok",transport:{kind:"direct",url:f}}}return{status:"unreachable"}},u=async()=>{if(!o)return{status:"unreachable"};const{outcome:m,tunnel:f}=await bf(o.relay,e,void 0,s?.fast?On:ti,{keepTunnel:!0});return m==="ok"?{status:"ok",transport:{kind:"relay",relay:o.relay,tunnel:f}}:m==="needs-login"||m==="auth-failed"?{status:"needs-login"}:{status:"unreachable"}};return o?a.length===0?u():new Promise(m=>{let f=!1,g=!1,p,h=null,x=null;const v=j=>{j?.status==="ok"&&j.transport.kind==="relay"&&ra(j.transport.tunnel)},b=j=>{f||(f=!0,m(j))},C=()=>{g||f||(p!==void 0&&(window.clearTimeout(p),p=void 0),u().then(j=>{if(x=j,f||g){v(j);return}if(j.status==="ok"||j.status==="needs-login"){b(j);return}h&&b(h)}))};l().then(j=>{if(h=j,!f){if(j.status==="ok"||j.status==="needs-login"){g=!0,p!==void 0&&window.clearTimeout(p),v(x),b(j);return}if(x){b(x);return}C()}}),p=window.setTimeout(C,Rf)}):l()},Xt=(n,e,s)=>{li=!1,n.kind==="relay"?xf(n.relay,e,s?.grant,s?.runtimeKey,n.tunnel?.client):ms({apiBaseUrl:n.url,clientToken:e,runtimeKey:s?.runtimeKey}),ca()},qs=()=>{const n=es()[0];return n?.label?.trim()?n.label:null};let li=!1;const Ef=()=>{li=!0},Ks=async n=>{if(li)return Ee("auto-connect:suppressed",{}),{status:"no-candidate"};const e=n?.fast!==!1;await oa();const s=es()[0];if(Ee("auto-connect:start",{hasCandidate:!!s,fast:e}),!s)return{status:"no-candidate"};let i;if(Xe()){if(s.hasToken&&(i=await tn(Ke(s)),!i))return{status:"no-candidate"}}else if(i=s.clientToken,!i&&s.hasToken)return{status:"no-candidate"};const r=await Fn(s.candidates,i,{fast:e});return Ee("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"&&ra(r.transport.tunnel),Ee("auto-connect:superseded",{}),{status:"no-candidate"}):(await Ln({id:s.id,label:s.label,candidates:s.candidates}),Xt(r.transport,i??null,{runtimeKey:Ke(s)}),{status:"connected"})},If=async(n,e)=>{let s="";try{s=Rs(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:On}:void 0;if(!(await Zt(`${s}/health`,{method:"GET",headers:r},o))?.ok)return!1;const l=await Zt(`${s}/auth/session`,{method:"GET",credentials:i?"omit":"include",headers:r},o);if(!l||!l.ok&&l.status!==404)return!1;const u=await Hn(l);return!(u&&u.disabled!==!0&&u.authenticated===!1)},Wi=(n,e)=>{n?.kind==="relay"&&n.owned&&!e&&n.tunnel.close()},Af=(n,e)=>n.kty===e.kty&&n.crv===e.crv&&n.x===e.x&&n.y===e.y,aa=n=>{const e=$a(),s=La();return!e||!s||e.getStatus().state!=="connected"?null:s.relayUrl===n.relayUrl&&s.serverId===n.serverId&&Af(s.hostEncPubJwk,n.hostEncPubJwk)?e:null},Pf=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=ni({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk});return s?[{kind:"relay",relay:s}]:[]}return si(e.url)}),Vi=async n=>{const e=Qt({candidates:n})?.serverId??null;for(const s of n){if(s.kind==="relay"){const o=aa(s.relay);if(o){const m=await ks(o,"/health",void 0,ti);if(Ee("establish:relay:health",{shared:!0,ok:m.response?.ok===!0,status:m.response?.status??null,error:m.failure}),m.response?.ok)return{kind:"relay",relay:s.relay,tunnel:o,owned:!1}}const a=yo(s.relay),{response:l,failure:u}=await Zo(a,"/health",void 0,Cs);if(Ee("establish:relay:health",{shared:!1,ok:l?.ok===!0,status:l?.status??null,error:u}),l?.ok)return{kind:"relay",relay:s.relay,tunnel:a,owned:!0};a.close();continue}const i=Rs(s.url)||s.url,r=await Zt(`${i}/health`,{method:"GET"});if(Ee("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){Ee("establish:server-id-mismatch",{url:i});continue}}return{kind:"direct",url:i}}}return null},Tf=async(n,e)=>{if(!en())return If(n,e);const s=await Bn(e?.fast?On:Cs,Dr("/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 Hn(s);return!(i&&i.disabled!==!0&&i.authenticated===!1)},Df=n=>n.kind==="relay"?en():!en()&&ta(n.url,St()),la=()=>{const n=rn();return n?es().find(e=>Ke(e)===n)??null:null},Ui=n=>{const e=rn();return!!e&&Ke(n)===e},Tn=async n=>{const e=n?.fast!==!1,s=la();if(!s)return Ee("reprobe:no-connection",{runtimeKey:!!rn()}),"no-connection";let i;if(Xe()?i=s.hasToken?await tn(Ke(s)):void 0:i=s.clientToken,!i&&s.hasToken)return Ee("reprobe:no-token",{hasToken:!0}),"unreachable";Ee("reprobe:start",{candidates:s.candidates.map(m=>m.kind),fast:e,hasToken:!!i});const r=s.candidates.findIndex(m=>Df(m.kind==="relay"?{kind:"relay",relay:m.relay}:{kind:"direct",url:m.url})),o=r>=0?s.candidates.slice(0,r):s.candidates,a=await Fn(o,i,{fast:e});if(Ee("reprobe:better",{status:a.status,probed:o.length}),a.status==="ok")return await Ln({id:s.id,label:s.label,candidates:s.candidates}),Xt(a.transport,i??null,{runtimeKey:Ke(s)}),"switched";if(a.status==="needs-login")return"needs-login";if(r>=0){const m=await Tf({url:St(),clientToken:i},{fast:e});if(Ee("reprobe:current",{stillValid:m}),m)return ca(),"unchanged"}const l=r>=0?s.candidates.slice(r+1):[],u=await Fn(l,i,{fast:e});return Ee("reprobe:fallback",{status:u.status,probed:l.length}),u.status==="ok"?(await Ln({id:s.id,label:s.label,candidates:s.candidates}),Xt(u.transport,i??null,{runtimeKey:Ke(s)}),"switched"):u.status==="needs-login"?"needs-login":"unreachable"},_f=5e3;let pr=!1;const Mf=async()=>{if(pr)return"skipped";const n=la();if(!n)return Ee("candidates:refresh-skip",{reason:"no-active-connection"}),"skipped";const e=Qt(n);if(!e)return Ee("candidates:refresh-skip",{reason:"no-relay-candidate"}),"skipped";pr=!0;try{const s=await Bn(Cs,Dr("/api/client-auth/connection/candidates").then(m=>m).catch(()=>null));if(!s?.ok)return Ee("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 Ee("candidates:refresh-skip",{reason:"server-id-mismatch"}),"skipped";const r=Array.isArray(i.candidates)?i.candidates:[],o=[];for(const m of r){if(!m||typeof m!="object")continue;const f=m;if(!(f.type!=="lan"||typeof f.url!="string"))try{const g=Rs(f.url);g&&!o.includes(g)&&o.push(g)}catch{}}if(o.length===0)return Ee("candidates:refresh-skip",{reason:"no-lan-reported"}),"skipped";const a=Kn(n).filter(m=>m.url.startsWith("https://")),l=[...o.map(m=>({kind:"direct",url:m})),...a,{kind:"relay",relay:e}];return JSON.stringify(n.candidates.map(Ir))===JSON.stringify(l.map(Ir))?"unchanged":(Ee("candidates:refreshed",{lanCount:o.length}),await Ln({id:n.id,label:n.label,candidates:l}),"updated")}finally{pr=!1}},ca=()=>{typeof window>"u"||window.setTimeout(()=>{(async()=>{const n=await Mf().catch(()=>"skipped");Ee("candidates:refresh-result",{result:n}),n==="updated"&&en()&&await Tn().catch(()=>null)})()},_f)},ua=n=>{const{t:e}=he(),[s,i]=c.useState(()=>es()),[r,o]=c.useState(null),[a,l]=c.useState(null),[u,m]=c.useState(null),f=c.useRef(s),g=c.useRef(null),p=c.useRef(df()),h=c.useCallback(S=>{f.current=S,i(S)},[]),x=c.useCallback(S=>{g.current=S,o(S)},[]),v=c.useCallback(S=>{g.current===S&&(g.current=null,o(null))},[]);c.useEffect(()=>{let S=!1;return Nf().then(y=>{S||h(y)}),()=>{S=!0}},[h]);const b=c.useCallback(S=>{const y=ia(f.current,S);return h(y),ri(y),y},[h]),C=c.useCallback(async S=>{l(null),x("connect");try{const y=Fi(S);if(y.length===0){l(e("mobile.connect.error.urlRequired"));return}const E=S.id?f.current.find(B=>B.id===S.id):f.current.find(B=>zn(B.candidates,y)),O=S.label?.trim()||E?.label||Pn(Tt({candidates:y})),L=S.relayGrant;let z=S.clientToken?.trim()||void 0;const A=!!z;z||(Xe()?E?.hasToken&&(z=await tn(Ke({candidates:y}))):z=E?.clientToken),Ee("connect:start",{candidates:y.map(B=>B.kind),hasToken:!!z});const _=await Fn(y,z);if(Ee("connect:probe",{status:_.status}),_.status==="unreachable"){l(e("mobile.connect.error.unreachable"));return}if(_.status==="needs-login"){b({id:E?.id,label:O,candidates:y}),m({id:E?.id??crypto.randomUUID(),label:O,candidates:y,relay:Qt({candidates:y})??void 0,relayGrant:L});return}z&&A&&Xe()&&await Jt(Ke({candidates:y}),z),b({id:E?.id,label:O,candidates:y,clientToken:z}),Xt(_.transport,z??null,{runtimeKey:Ke({candidates:y}),grant:L}),n()}catch(y){console.warn("[mobile-connect] connect threw",y),l(e("mobile.connect.error.invalidUrl"))}finally{v("connect")}},[x,v,n,b,e]),j=c.useCallback(async S=>{if(g.current==="pairing")return;l(null),x("pairing");const y=Pf(S.candidates);let E=null,O=!1;try{if(E=await Vi(y),!E){l(e("mobile.connect.error.unreachable"));return}const L=JSON.stringify({pairingId:S.pairingId,secret:S.secret,clientLabel:"OpenChamber Mobile",clientKind:"mobile",deviceName:"OpenChamber Mobile",devicePlatform:Li(),dedupeKey:Bi()}),z={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:L},A=E.kind==="relay"?await ks(E.tunnel,"/api/client-auth/pairing/redeem",z,Cs):{response:await Zt(`${E.url}/api/client-auth/pairing/redeem`,z),failure:null},_=A.response;if(Ee("pairing:redeem",{transport:E.kind,ok:_?.ok===!0,status:_?.status??null,error:A.failure}),!_?.ok){l(e("mobile.connect.error.authRequired"));return}const B=await _.json().catch(()=>null),P=typeof B?.clientToken=="string"?B.clientToken.trim():"";if(!P){l(e("mobile.connect.error.authRequired"));return}const M=typeof B?.server?.label=="string"?B.server.label:"",$=S.label||M||Pn(Tt({candidates:y}));if(Xe()&&!await Jt(Ke({candidates:y}),P)){l(e("mobile.connect.error.authRequired"));return}b({label:$,candidates:y,clientToken:P}),Xt(E.kind==="relay"?{kind:"relay",relay:E.relay,tunnel:{client:E.tunnel,owned:E.owned}}:{kind:"direct",url:E.url},P,{runtimeKey:Ke({candidates:y})}),O=E.kind==="relay",n()}catch(L){console.warn("[mobile-connect] pairing threw",L),l(e("mobile.connect.error.authRequired"))}finally{Wi(E,O),v("pairing")}},[x,v,n,b,e]),R=c.useCallback(async S=>{if(!u||!S.trim()||g.current==="password")return;l(null),x("password");const y=p.current.begin(),E=()=>p.current.isCurrent(y),{id:O,label:L,candidates:z}=u;let A=null,_=!1;try{if(A=await Vi(z),!E())return;if(!A){l(e("mobile.connect.error.unreachable"));return}const B={method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({password:S,trustDevice:!0,issueClientToken:!0,clientLabel:"OpenChamber Mobile",clientKind:"mobile",devicePlatform:Li(),dedupeKey:Bi()})};Ee("password:start",{transport:A.kind});const P=A.kind==="relay"?await ks(A.tunnel,"/auth/session",B,Cs):{response:await Zt(`${A.url}/auth/session`,B),failure:null},M=P.response;if(!E())return;if(Ee("password:done",{ok:M?.ok===!0,status:M?.status??null,error:P.failure}),!M?.ok){l(e("mobile.connect.error.passwordFailed"));return}const $=await M.json().catch(()=>null);if(!E())return;const I=typeof $?.clientToken=="string"?$.clientToken.trim():"";if(Ee("password:token",{issued:!!I}),!I){if(A.kind==="direct"&&!Xe()){b({id:O,label:L,candidates:z}),m(null),Xt({kind:"direct",url:A.url},null,{runtimeKey:Ke({candidates:z})}),n();return}l(e("mobile.connect.error.authRequired"));return}if(Xe()&&(!E()||(await Jt(Ke({candidates:z}),I),!E()))||!E()||(b({id:O,label:L,candidates:z,clientToken:I}),m(null),Xt(A.kind==="relay"?{kind:"relay",relay:A.relay,tunnel:{client:A.tunnel,owned:A.owned}}:{kind:"direct",url:A.url},I,{runtimeKey:Ke({candidates:z})}),_=A.kind==="relay",!E()))return;n()}catch(B){if(!E())return;console.warn("[mobile-connect] password threw",B),l(e("mobile.connect.error.passwordFailed"))}finally{Wi(A,_),E()&&v("password")}},[x,v,n,u,b,e]),T=c.useCallback(()=>{p.current.cancel(),v("password"),m(null),l(null)},[v]),D=c.useCallback(async S=>{l(null);let y=Fi(S);const E=S.id?f.current.find(A=>A.id===S.id)??null:null;if(E){const A=y.filter(P=>P.kind==="direct"),_=Kn(E).filter(P=>P.url.startsWith("https://")&&!A.some(M=>ta(M.url,P.url))),B=Qt(E);y=[...A,..._,...B?[{kind:"relay",relay:B}]:[]]}if(y.length===0)return l(e("mobile.connect.error.urlRequired")),null;const O=S.clientToken?.trim()||void 0,L=S.label?.trim()||Pn(Tt({candidates:y}));if(Xe()){const A=Ke({candidates:y});if(O)await Jt(A,O);else if(E?.hasToken){const _=Ke(E);if(_&&A&&_!==A){const B=await tn(_);B&&await Jt(A,B)}}}return b({id:S.id,label:L,candidates:y,clientToken:O}).find(A=>zn(A.candidates,y))??null},[b,e]),k=c.useCallback(async S=>{const y=f.current.find(O=>O.id===S)??null,E=await Cf(S);return h(E),y},[h]);return{connections:s,isBusy:r!==null,isPasswordBusy:r==="password",error:a,pendingConnection:u,connect:C,redeemPairingConnection:j,submitPassword:R,cancelPassword:T,saveConnection:D,removeConnection:k,setError:l}},da=n=>{const e=de.c(31),{onClose:s}=n,{t:i}=he(),[r,o]=c.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=tf(),e[0]=a):a=e[0];const l=a;let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{ko(nf()).then(S=>{S.ok&&(o(!0),window.setTimeout(()=>o(!1),2e3))})},e[1]=u):u=e[1];const m=u;let f;e[2]!==i?(f=i("mobile.connectionDebug.title"),e[2]=i,e[3]=f):f=e[3];let g;e[4]!==f?(g=t.jsx("h2",{className:"min-w-0 truncate typography-ui-label text-foreground",children:f}),e[4]=f,e[5]=g):g=e[5];const p=r?"check":"file-copy";let h;e[6]!==p?(h=t.jsx(H,{name:p,className:"size-4"}),e[6]=p,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 v;e[11]!==h||e[12]!==x?(v=t.jsxs(Ce,{type:"button",variant:"outline",size:"sm",onClick:m,disabled:l.length===0,children:[h,x]}),e[11]=h,e[12]=x,e[13]=v):v=e[13];let b;e[14]!==i?(b=i("mobile.connectionDebug.close"),e[14]=i,e[15]=b):b=e[15];let C;e[16]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx(H,{name:"close",className:"size-[18px]"}),e[16]=C):C=e[16];let j;e[17]!==s||e[18]!==b?(j=t.jsx(Ce,{type:"button",variant:"ghost",size:"icon","aria-label":b,onClick:s,children:C}),e[17]=s,e[18]=b,e[19]=j):j=e[19];let R;e[20]!==j||e[21]!==v?(R=t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[v,j]}),e[20]=j,e[21]=v,e[22]=R):R=e[22];let T;e[23]!==R||e[24]!==g?(T=t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border/70 px-4 py-2.5",children:[g,R]}),e[23]=R,e[24]=g,e[25]=T):T=e[25];let D;e[26]!==i?(D=t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 py-3",children:l.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:l.map(Xo).join(`
4
- `)})}),e[26]=i,e[27]=D):D=e[27];let k;return e[28]!==T||e[29]!==D?(k=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:[T,D]}),e[28]=T,e[29]=D,e[30]=k):k=e[30],k},fa=()=>{if(typeof window>"u")return null;const e=window.Capacitor?.Plugins?.BarcodeScanner;return e&&(typeof e.scan=="function"||typeof e.startScan=="function")?e:null},Of=()=>window.Capacitor?.getPlatform?.()==="android",ma=n=>{const e=n.trim();if(!e)return null;if(/^openchamber:\/\//i.test(e)){const s=Wa(e);return s?{pairing:s}:null}return/^https?:\/\//i.test(e)?{url:e}:null},pa=(n,e)=>{const s=ma(n);if(!s&&e?.pairingStringFallback){const i=Va(n);if(i)return{status:"pairing",pairing:i}}return s?"pairing"in s?{status:"pairing",...s}:{status:"ok",...s}:{status:"invalid"}},zf=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(m=>{o=m}),l=m=>{r||(r=!0,o(m))},u=()=>l({status:"cancelled"});e?.addEventListener("abort",u,{once:!0});try{return(await Promise.allSettled([Promise.resolve(n.addListener("barcodesScanned",({barcodes:f})=>{const g=f?.[0],p=(g?.rawValue??g?.displayValue??"").trim();p&&l(pa(p,{pairingStringFallback:!0}))})).then(f=>{s=f}),Promise.resolve(n.addListener("scanError",()=>l({status:"failed"}))).then(f=>{i=f})])).some(({status:f})=>f==="rejected")?l({status:"failed"}):r||n.startScan({formats:["QR_CODE"]}).catch(()=>l({status:"failed"})),await a}finally{e?.removeEventListener("abort",u),await Promise.allSettled([Promise.resolve(s?.remove()),Promise.resolve(i?.remove()),n.stopScan()])}},Ar=()=>fa()!==null,ha=async n=>{const e=fa();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(Of())return zf(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?pa(r):{status:"cancelled"}}catch{return{status:"failed"}}},ys={autoComplete:"off",autoCorrect:"off",spellCheck:!1},Ys="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",ga=n=>{const e=de.c(22),{onCancel:s}=n,{t:i}=he(),r=c.useRef(null);let o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{const C={value:document.documentElement.style.getPropertyValue("background-color"),priority:document.documentElement.style.getPropertyPriority("background-color")},j={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 R=new Map,T=k=>{!(k instanceof HTMLElement)||k===r.current||R.has(k)||(R.set(k,{opacity:k.style.opacity,pointerEvents:k.style.pointerEvents}),k.style.setProperty("opacity","0"),k.style.setProperty("pointer-events","none"))};Array.from(document.body.children).forEach(T);const D=new MutationObserver(k=>{k.forEach(S=>S.addedNodes.forEach(T))});return D.observe(document.body,{childList:!0}),()=>{D.disconnect(),R.forEach(Bf),C.value?document.documentElement.style.setProperty("background-color",C.value,C.priority):document.documentElement.style.removeProperty("background-color"),j.value?document.body.style.setProperty("background-color",j.value,j.priority):document.body.style.removeProperty("background-color")}},a=[],e[0]=o,e[1]=a):(o=e[0],a=e[1]),c.useLayoutEffect(o,a);let l,u;e[2]!==s?(l=()=>{const C=()=>{document.visibilityState==="hidden"&&s()};return document.addEventListener("visibilitychange",C),()=>document.removeEventListener("visibilitychange",C)},u=[s],e[2]=s,e[3]=l,e[4]=u):(l=e[3],u=e[4]),c.useEffect(l,u);let m;e[5]!==i?(m=i("mobile.connect.scanQr"),e[5]=i,e[6]=m):m=e[6];let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=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]=f):f=e[7];let g;e[8]!==i?(g=i("mobile.connect.welcome.scanHint"),e[8]=i,e[9]=g):g=e[9];let p;e[10]!==g?(p=t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-6",children:[f,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:g})]}),e[10]=g,e[11]=p):p=e[11];let h;e[12]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(H,{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 v;e[15]!==s||e[16]!==x?(v=t.jsxs(Ce,{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]=v):v=e[17];let b;return e[18]!==v||e[19]!==m||e[20]!==p?(b=vs.createPortal(t.jsxs("div",{ref:r,role:"dialog","aria-modal":"true","aria-label":m,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:[p,v]}),document.body),e[18]=v,e[19]=m,e[20]=p,e[21]=b):b=e[21],b},ba=()=>{const n=de.c(6),{t:e}=he();let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx(ps,{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(H,{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=vs.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 Bf(n,e){e.style.opacity=n.opacity,e.style.pointerEvents=n.pointerEvents}const Lf=({onConnected:n,notice:e=null})=>{const{t:s}=he(),i=ua(n),{connections:r,isBusy:o,isPasswordBusy:a,error:l,pendingConnection:u}=i,[m,f]=c.useState(""),[g,p]=c.useState(""),[h,x]=c.useState(""),[v,b]=c.useState(!1),[C,j]=c.useState(!1),R=c.useRef(null),T=c.useMemo(()=>Ar(),[]),[D,k]=c.useState(()=>!Ar()),[S,y]=c.useState(null),[E,O]=c.useState(""),[L,z]=c.useState(!1),A=Qo(c.useCallback(()=>z(!0),[])),_=c.useCallback(I=>{I.preventDefault(),i.connect({url:m,clientToken:h,label:g})},[h,i,g,m]),B=c.useCallback(I=>{if(/^openchamber:\/\//i.test(I.trim())){const U=ma(I);if(U){if("pairing"in U){i.redeemPairingConnection(U.pairing);return}f(U.url),U.label&&p(U.label),U.clientToken&&x(U.clientToken);return}}f(I)},[i]),P=c.useCallback(async()=>{if(R.current||o)return;i.setError(null),b(!0);const I=new AbortController;R.current=I;try{const U=await ha({signal:I.signal});switch(R.current===I&&(R.current=null,b(!1)),U.status){case"ok":j(!0),f(U.url),U.label&&p(U.label),U.clientToken&&x(U.clientToken),await i.connect({url:U.url,clientToken:U.clientToken,label:U.label});break;case"pairing":j(!0),await i.redeemPairingConnection(U.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{j(!1),R.current===I&&(R.current=null,b(!1))}},[i,o,s]);c.useEffect(()=>()=>R.current?.abort(),[]);const M=c.useCallback(I=>{I.preventDefault(),i.submitPassword(E)},[i,E]),$=c.useCallback(()=>{O(""),i.cancelPassword()},[i]);return t.jsxs(t.Fragment,{children:[v?t.jsx(ga,{onCancel:()=>R.current?.abort()}):null,C?t.jsx(ba,{}):null,L?t.jsx(da,{onClose:()=>z(!1)}):null,t.jsx("main",{className:"oc-keyboard-fill-screen flex min-h-dvh flex-col overflow-y-auto bg-background px-6 pb-[calc(var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))+28px)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+28px)] text-foreground",children:t.jsxs("div",{className:"m-auto flex w-full max-w-[360px] shrink-0 flex-col items-center gap-9 py-8",children:[t.jsxs("div",{className:"flex flex-col items-center gap-5 text-center",children:[t.jsx("span",{...A,className:"select-none",style:{touchAction:"manipulation"},children:t.jsx(ps,{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(H,{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,u?t.jsxs("form",{className:"flex w-full flex-col gap-3",onSubmit:M,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(H,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0 text-start",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:u.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:u.candidates.some(I=>I.kind==="direct")?Tt(u):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...ys,value:E,onChange:I=>O(I.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:Ys}),l?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):null,t.jsx(Ce,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:a||!E.trim(),children:s(a?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(Ce,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:$,children:s("mobile.connect.cancelPassword")})]}):t.jsxs("div",{className:"flex w-full flex-col gap-6",children:[T?t.jsxs("div",{className:"flex w-full flex-col gap-2",children:[t.jsxs(Ce,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{P()},disabled:v||o,children:[t.jsx(H,{name:"scan-2",className:Z("size-[18px]",v&&"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,l&&!D?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):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(I=>{const U=S===I.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-start last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:opacity-70",onClick:()=>{y(I.id),i.connect({id:I.id,candidates:I.candidates,clientToken:I.clientToken,label:I.label}).finally(()=>y(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(H,{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:I.label}),t.jsx("span",{className:Z("block truncate typography-small",U?"text-foreground":"text-muted-foreground"),children:U?s("mobile.connect.connecting"):I.candidates.some(X=>X.kind==="direct")?Tt(I):s("mobile.connect.relay.badge")})]}),U?t.jsx(H,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):t.jsx(H,{name:"arrow-right-s",className:"size-5 text-muted-foreground"})]},I.id)})})]}):null,t.jsxs("div",{className:"flex w-full flex-col",children:[T?t.jsxs("button",{type:"button",onClick:()=>k(I=>!I),"aria-expanded":D,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(H,{name:"arrow-down-s",className:Z("size-4 transition-transform duration-200",D&&"rotate-180")})]}):null,t.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:D?"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:_,children:[t.jsx("input",{...ys,value:m,onChange:I=>B(I.target.value),placeholder:s("mobile.connect.url.placeholder"),"aria-label":s("mobile.connect.url.label"),type:"url",inputMode:"url",autoCapitalize:"none",tabIndex:D?void 0:-1,className:Z(Ys,"text-center")}),t.jsx("input",{value:g,onChange:I=>p(I.target.value),placeholder:s("mobile.instances.label.placeholder"),"aria-label":s("mobile.instances.label.label"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,tabIndex:D?void 0:-1,className:Z(Ys,"text-center")}),t.jsx("input",{...ys,value:h,onChange:I=>x(I.target.value),placeholder:s("mobile.connect.token.placeholder"),"aria-label":s("mobile.connect.token.label"),tabIndex:D?void 0:-1,autoCapitalize:"none",className:Z(Ys,"text-center")}),t.jsx("p",{className:"px-1 text-center typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")}),l?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):null,t.jsx(Ce,{type:"submit",variant:T?"outline":"default",size:"lg",className:"h-12 w-full",disabled:o||v||!m.trim(),children:s(o?"mobile.connect.connecting":"mobile.connect.connectButton")})]})})})]})]})]})})]})},Ff=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"},$f=n=>{const e=de.c(12),{groups:s,displayMode:i,timeFormatPreference:r,className:o}=n;let a;e[0]!==o?(a=Z("space-y-1.5",o),e[0]=o,e[1]=a):a=e[1];let l;if(e[2]!==i||e[3]!==s||e[4]!==r){let m;e[6]!==i||e[7]!==r?(m=f=>t.jsxs("div",{className:"min-w-0 rounded-xl bg-foreground/[0.03] p-2.5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(So,{providerId:f.providerId,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground",children:f.providerName}),f.planLabel?t.jsx("span",{className:"shrink-0 typography-micro capitalize text-muted-foreground",children:f.planLabel}):null,f.status&&f.rows.length===0?t.jsx("span",{className:"shrink-0 truncate typography-micro text-muted-foreground",children:f.status}):null]}),f.rows.length>0?t.jsx("div",{className:"mt-1.5 space-y-1",children:f.rows.map(g=>{const p=i==="remaining"?g.window.remainingPercent:g.window.usedPercent,h=tl(g.window.valueLabel,p),x=sl(g.window.resetAt,g.window.resetAfterFormatted??g.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:g.subtitle?`${g.subtitle} · ${g.label}`:g.label}),x?t.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/70",children:x}):null]}),t.jsx("span",{className:Z("shrink-0 typography-ui-label font-semibold tabular-nums",Ff(g.window)),children:h==="-"?"":h})]},g.key)})}):null,f.status&&f.rows.length>0?t.jsx("div",{className:"mt-1.5 typography-micro text-muted-foreground",children:f.status}):null]},f.providerId),e[6]=i,e[7]=r,e[8]=m):m=e[8],l=s.map(m),e[2]=i,e[3]=s,e[4]=r,e[5]=l}else l=e[5];let u;return e[9]!==a||e[10]!==l?(u=t.jsx("div",{className:a,children:l}),e[9]=a,e[10]=l,e[11]=u):u=e[11],u},Gi=380,Wf=(n,e)=>{if(!n||typeof n!="object")return;const s=n[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0},hr=n=>n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:String(n),Vf="—",xa=n=>{const e=de.c(20),{percentage:s}=n;let i,r,o,a,l,u,m;if(e[0]!==s){o=ll(s??0)??0;const h=cl(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",l="size-[18px] -rotate-90",u="progressbar",m=s===null?void 0:Math.round(o),e[0]=s,e[1]=i,e[2]=r,e[3]=o,e[4]=a,e[5]=l,e[6]=u,e[7]=m}else i=e[1],r=e[2],o=e[3],a=e[4],l=e[5],u=e[6],m=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),e[8]=f):f=e[8];let g;e[9]!==i||e[10]!==s||e[11]!==r||e[12]!==o?(g=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]=g):g=e[13];let p;return e[14]!==a||e[15]!==l||e[16]!==u||e[17]!==m||e[18]!==g?(p=t.jsxs("svg",{viewBox:a,className:l,role:u,"aria-valuenow":m,"aria-valuemin":0,"aria-valuemax":100,children:[f,g]}),e[14]=a,e[15]=l,e[16]=u,e[17]=m,e[18]=g,e[19]=p):p=e[19],p},Uf=n=>{const e=de.c(13),{icon:s,iconNode:i,label:r,children:o}=n;let a;e[0]!==s||e[1]!==i?(a=i??(s?t.jsx(H,{name:s,className:"size-[18px]"}):null),e[0]=s,e[1]=i,e[2]=a):a=e[2];let l;e[3]!==a?(l=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:a}),e[3]=a,e[4]=l):l=e[4];let u;e[5]!==r?(u=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:r}),e[5]=r,e[6]=u):u=e[6];let m;e[7]!==o?(m=t.jsx("span",{className:"min-w-0 flex-1 truncate text-end typography-ui-label font-medium text-foreground",children:o}),e[7]=o,e[8]=m):m=e[8];let f;return e[9]!==l||e[10]!==u||e[11]!==m?(f=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5",children:[l,u,m]}),e[9]=l,e[10]=u,e[11]=m,e[12]=f):f=e[12],f},Gf=n=>{const e=de.c(57),{open:s,onClose:i,anchorRef:r,contextDisplay:o,usageGroups:a,usageDisplayMode:l,isUsageLoading:u,timeFormatPreference:m}=n,{t:f}=he(),g=c.useRef(null),[p,h]=c.useState(s),[x,v]=c.useState(!1),{enabled:b}=_r(),C=c.useRef(null),[j,R]=c.useState(null);let T,D;e[0]!==r||e[1]!==b||e[2]!==s||e[3]!==p?(T=()=>{if(!s||!b||!p)return;const G=()=>{const ne=r.current?.getBoundingClientRect(),re=C.current?.getBoundingClientRect();if(!ne||!re){R(null);return}const K=ne.left-re.left,oe=Math.min(Math.max(K,8),Math.max(8,re.width-Gi-8));R(oe)};G();const N=C.current;if(typeof ResizeObserver>"u"||!N)return;const Y=new ResizeObserver(G);return Y.observe(N),()=>Y.disconnect()},D=[r,b,s,p],e[0]=r,e[1]=b,e[2]=s,e[3]=p,e[4]=T,e[5]=D):(T=e[4],D=e[5]),c.useLayoutEffect(T,D);const k=b&&j!==null;let S,y;e[6]!==s||e[7]!==p?(S=()=>{if(s){h(!0),v(!1);return}if(!p)return;v(!0);const G=window.setTimeout(()=>{h(!1),v(!1)},140);return()=>window.clearTimeout(G)},y=[s,p],e[6]=s,e[7]=p,e[8]=S,e[9]=y):(S=e[8],y=e[9]),c.useEffect(S,y);let E,O;e[10]!==i||e[11]!==s?(E=()=>{if(!s)return;const G=N=>{N.key==="Escape"&&i()};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},O=[i,s],e[10]=i,e[11]=s,e[12]=E,e[13]=O):(E=e[12],O=e[13]),c.useEffect(E,O);let L,z;if(e[14]!==r||e[15]!==i||e[16]!==s?(L=()=>{if(!s)return;const G=N=>{const Y=N.target;if(!(Y instanceof Node)){i();return}g.current?.contains(Y)||r.current?.contains(Y)||i()};return document.addEventListener("pointerdown",G,!0),document.addEventListener("wheel",G,!0),()=>{document.removeEventListener("pointerdown",G,!0),document.removeEventListener("wheel",G,!0)}},z=[r,i,s],e[14]=r,e[15]=i,e[16]=s,e[17]=L,e[18]=z):(L=e[17],z=e[18]),c.useEffect(L,z),!p)return null;let A;e[19]!==f?(A=f("mobile.header.openMetadataAria"),e[19]=f,e[20]=A):A=e[20];const _=k?"absolute origin-top-left":"mx-3 mt-2",B=x?"pointer-events-none":"pointer-events-auto";let P;e[21]!==_||e[22]!==B?(P=Z("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",_,B),e[21]=_,e[22]=B,e[23]=P):P=e[23];const M=`${x?"session-metadata-out":"session-metadata-in"} ${x?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let $;e[24]!==j||e[25]!==k?($=k?{top:8,left:j??8,width:`min(${Gi}px, calc(100% - 16px))`}:null,e[24]=j,e[25]=k,e[26]=$):$=e[26];let I;e[27]!==M||e[28]!==$?(I={animation:M,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...$},e[27]=M,e[28]=$,e[29]=I):I=e[29];let U;e[30]!==o||e[31]!==f?(U=o?t.jsx(Uf,{iconNode:t.jsx(xa,{percentage:o.state==="measured"?o.percentage:null}),label:f("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:Z("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]=f,e[32]=U):U=e[32];let X;e[33]!==o?.state||e[34]!==f?(X=o?.state==="compacted"?t.jsx("p",{className:"px-2.5 pb-1 typography-meta text-muted-foreground",children:f("contextUsage.compacted.description")}):null,e[33]=o?.state,e[34]=f,e[35]=X):X=e[35];let Q;e[36]!==o?.state||e[37]!==f?(Q=o?.state==="pending"?t.jsx("p",{className:"px-2.5 pb-1 typography-meta text-muted-foreground",children:f("mobile.header.metadata.contextPending")}):null,e[36]=o?.state,e[37]=f,e[38]=Q):Q=e[38];let ue;e[39]!==u||e[40]!==m||e[41]!==l||e[42]!==a?(ue=t.jsx(Kf,{groups:a,displayMode:l,isLoading:u,timeFormatPreference:m}),e[39]=u,e[40]=m,e[41]=l,e[42]=a,e[43]=ue):ue=e[43];let se;e[44]!==U||e[45]!==X||e[46]!==Q||e[47]!==ue?(se=t.jsxs("div",{className:"space-y-1",children:[U,X,Q,ue]}),e[44]=U,e[45]=X,e[46]=Q,e[47]=ue,e[48]=se):se=e[48];let te;e[49]!==P||e[50]!==I||e[51]!==se||e[52]!==A?(te=t.jsx("div",{ref:g,role:"dialog","aria-label":A,className:P,style:I,children:se}),e[49]=P,e[50]=I,e[51]=se,e[52]=A,e[53]=te):te=e[53];let ge;e[54]===Symbol.for("react.memo_cache_sentinel")?(ge=t.jsx("style",{children:`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesView-BBFbfDp9.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/katex.min-C-51hS9A.js","assets/vendor-zod-CVhJ1Zpv.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-DgOf1DP0.js","assets/katex-BEX7X_K8.css","assets/useAppFontEffects-C1ceAD51.js","assets/vendor-base-ui-CXFyogip.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-tanstack-react-virtual-CvuLsk7D.js","assets/vendor-tanstack-virtual-core-DPaNcJcT.js","assets/vendor-framer-motion-DxDVhOLc.js","assets/vendor-motion-dom-HXPOMxb7.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-codemirror-commands-MmBpgSOc.js","assets/vendor-codemirror-state-Dek9sMtw.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-B66jUSmE.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-codemirror-language-DkBxRck3.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-streamparser-CmlTsbN2.js","assets/vendor-codemirror-lang-javascript-DmPuKUEa.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-BRKmCSiY.js","assets/vendor-codemirror-lang-json-L0wsFFxi.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-DfdrZ848.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-C5kFuJzc.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-CPn-qinN.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-CTYHXywt.js","assets/vendor-codemirror-lang-python-BAVa3Hg5.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-legendapp-list-BCBzRcfK.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/shikiHighlight-DOzrE7BE.js","assets/vendor-codemirror-search-BKAwkhkm.js","assets/vendor-replit-codemirror-vim-D0bqFa1D.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/moveWorkspacePath-BINgpJ9S.js","assets/JsonTreeView-BKUmh7Iw.js","assets/parseDiffFromFile--DE4eHIp.js","assets/computeVirtualFileMetrics-MZqvCQy0.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-yJ9XpNMI.js","assets/vendor-pierre-theming-Dgp7B_O4.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/vendor-diff-C3JhlQdm.js","assets/Virtualizer-BP6uuKe_.js","assets/isFilePlainText-B4SyJ-ni.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/appThemeRegistry-COeayQaQ.js","assets/textMateThemeFromAppTheme-BfIrjFAU.js","assets/runtimeEndpointReset-ExJsaWzA.js","assets/Virtualizer-DNgIEKcx.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/useInlineCommentController-ynkUsoVA.js","assets/FilePreviewCommentMenu-Ca4ziuof.js","assets/scheduledTasksApi-NSyxVfHu.js","assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-capacitor-push-notifications-KNe1zSBF.js"])))=>i.map(i=>d[i]);
2
+ import{f as de,r as kr,j as t,R as c,c as vs,h as $a}from"./vendor-react-BUCujlKS.js";import{u as Fe,Y as rn,ba as Mr,bb as yi,bc as Xe,a2 as St,bd as ms,be as en,l as Or,bf as Wa,bg as wo,bh as Va,bi as Ua,bj as Ga,bk as Ka,bl as qa,e as zt,n as on,z as Ha,A as Ya,bm as us,as as cr,bn as Ja,Z as Vs,b as vi,aI as ur,a_ as Xa,ay as wi,aj as Qa,ai as Za,_ as ji,ah as el,$ as jo,bo as ki,av as Si,v as Ni,bp as kn}from"./katex.min-C-51hS9A.js";import{G as bs,dA as tl,a2 as rt,cF as Sr,cG as ko,J as So,gf as sl,u as he,z as ce,cb as nl,I as q,dh as rl,B as Ce,ak as No,a7 as ps,L as Z,bF as Co,gg as il,gh as ol,d1 as al,_ as dt,aC as ll,gi as Yt,gj as cl,gk as Ci,gl as ul,gm as dl,er as zr,cZ as fl,c_ as ml,F as Me,ec as pl,ee as Br,ef as Lr,gn as Fr,eh as hl,eg as Ro,go as $r,dy as Dn,ci as Eo,gp as gl,d$ as Io,ao as lt,ch as Ao,aq as Un,gq as bl,gr as xl,gs as yl,gt as vl,f6 as An,fF as Nr,fp as Ot,gu as wl,k as Po,as as To,cu as Do,cv as _o,cw as Mo,gv as jl,gw as kl,gx as Sl,dz as Ri,gy as Oo,gz as zo,y as Bo,gA as Nl,gB as Cl,gC as Lo,gD as Rl,cH as El,a3 as Il,cS as Al,gE as Pl,cR as Us,gF as Ei,gG as Fo,K as Tl,gH as Dl,ct as Gn,cf as _l,bA as $o,dn as Wo,gI as Ml,gJ as Ol,gK as fs,gL as xs,T as zl,U as Bl,V as Ll,gM as Fl,fy as $l,ap as Wr,dY as Wl,e0 as Vl,eK as Ul,e$ as Gl,eW as Kl,ex as Vo,eX as ql,f0 as Hl,e1 as Yl,dZ as Jl,fx as Xl,ft as Ql,gN as Zl,gO as ec,gP as tc,gQ as sc,fw as Ii,dQ as Sn,aE as nc,aF as rc,c9 as ic,aG as oc,bM as ac,bO as Nn,eZ as lc,aw as cc,e3 as uc,fC as dc,fE as fc,fz as mc,cY as Uo,aI as Je,cP as pc,cg as hc,gR as gc,gS as bc,gT as xc,gU as yc,cU as vc,gV as wc,eU as Ai,gW as Vr,bR as jc,an as kc,gX as Sc,gY as Nc,cx as Go,da as Cc,db as Rc,dc as Ec,dd as Ic,gZ as Ac,dj as Pc,di as Tc,de as Dc,g_ as _c,df as Mc,dg as Oc,dp as zc,dm as Bc,g$ as Lc,h0 as Fc,h1 as $c,h2 as Wc,h3 as Vc,h4 as Uc,h5 as Gc,h6 as Kc,dq as qc,dr as Hc,ds as Yc,dt as Jc}from"./useAppFontEffects-C1ceAD51.js";import{a1 as hs,a2 as Xc,a3 as Qc,a4 as Zc,a5 as eu,a6 as Ko,a7 as qo,a8 as Ho,a9 as tu,aa as su,ab as nu,ac as dr,ad as ru,ae as iu,af as ou,S as au,A as Yo,a as lu,ag as cu,ah as uu,ai as du,aj as fu,H as Cn,P as mu,Q as pu,K as hu,U as fr,W as gu,X as bu,y as xu,ak as yu,I as vu,J as wu,al as ju,am as ku,L as Su,w as Nu,Y as Cu,G as Ru,an as Eu,ao as Iu,Z as Au,ap as Pu,aq as Tu,ar as Du,as as _u,at as Mu,au as Ou,av as zu,aw as Bu,ax as Lu,ay as Fu,az as $u,aA as Wu,aB as Vu,aC as Uu,aD as Gu,aE as Ku,aF as qu,aG as Hu}from"./runtimeEndpointReset-ExJsaWzA.js";import{i as Yu}from"./initializeSharedPreferences-FxFkTjgn.js";import{_ as ws}from"./vendor-vite-runtime-DD1OZmLC.js";import{S as Ju,A as Xu}from"./SettingsView-gB_NvyX4.js";import{PlanView as Qu}from"./PlanView-j0hLJmto.js";import{SpaceAccessDialog as Zu}from"./SpaceAccessDialog-XzHRmIdT.js";import{SpaceApplyDialog as ed}from"./SpaceApplyDialog-CxX9mrzT.js";import{SpaceSetupOutputDialog as td}from"./SpaceSetupOutput-CDZvJCf_.js";import{RunOverview as sd}from"./RunOverview-ZuFZvDcu.js";import{p as nd}from"./vendor-aparajita-capacitor-secure-storage-5IShChL0.js";import{Capacitor as rd,registerPlugin as Jo}from"./vendor-capacitor-core-B4EWRrHz.js";import{k as Cr,d as id,M as _n,J as Rr,s as Xo,a as Ur,p as od,_ as Pi,f as Gr,V as ad,K as Ti,P as ld,b as cd,c as ud,U as dd,Z as fd,Q as md,r as pd}from"./vendor-remixicon-react-D6dZ0UwF.js";import{f as Kr,h as js,i as qr,P as Hr,D as Yr,j as Jr}from"./vendor-dnd-kit-core-BZknOX2w.js";import{s as Xr,S as Qr,v as Zr,u as ei}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as ti}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{c as hd}from"./sessionOwnership-BAX1xEJC.js";import{c as si,p as Qo}from"./vendor-zustand-BAGL70zf.js";import{toast as Er}from"./vendor-sonner-DFyL3AvE.js";import{S as gd}from"./SpaceRow-vCpOCANO.js";import{UsageStatsView as bd}from"./UsageStatsView-C63Emjfj.js";import{ArchiveSessionsView as xd}from"./ArchiveView-DJo1Bpw_.js";import{MobileSourceBoard as yd}from"./SourceBoardView-BjaL0nKs.js";import{ScheduledTasksView as vd}from"./ScheduledTasksDialog-UKXFFI91.js";import{i as wd,a as jd,b as kd,c as Sd,S as Nd,W as Cd}from"./SubmoduleDiffSummary-CQyRcvDZ.js";import{R as Rd,I as Ed,C as Id,a as Ad,b as Pd,D as Td}from"./InProgressOperationBanner-Dy0RiPsD.js";import{b as Di,a as Dd,c as _d,u as Md,i as Od,f as _i,B as zd,C as Bd,P as Mi}from"./patchFileDiff-BfFUmWgS.js";import{P as Ld}from"./PierreDiffViewer-DnHKbYGl.js";import{p as Fd}from"./parseDiffFromFile--DE4eHIp.js";import{o as Zo,s as Oi}from"./vendor-zod-CVhJ1Zpv.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-opencode-client-DgOf1DP0.js";import"./vendor-base-ui-CXFyogip.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tanstack-react-virtual-CvuLsk7D.js";import"./vendor-tanstack-virtual-core-DPaNcJcT.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-MmBpgSOc.js";import"./vendor-codemirror-state-Dek9sMtw.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-B66jUSmE.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-language-DkBxRck3.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-streamparser-CmlTsbN2.js";import"./vendor-codemirror-lang-javascript-DmPuKUEa.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BRKmCSiY.js";import"./vendor-codemirror-lang-json-L0wsFFxi.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-DfdrZ848.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-C5kFuJzc.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-CPn-qinN.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CTYHXywt.js";import"./vendor-codemirror-lang-python-BAVa3Hg5.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-legendapp-list-BCBzRcfK.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-yaml-3778uTud.js";import"./shikiHighlight-DOzrE7BE.js";import"./vendor-codemirror-search-BKAwkhkm.js";import"./vendor-replit-codemirror-vim-D0bqFa1D.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./appThemeRegistry-COeayQaQ.js";import"./textMateThemeFromAppTheme-BfIrjFAU.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-qrcode-DTJ12-WC.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./vendor-strip-json-comments-5dJlOkP1.js";import"./useCallableModelProviders-BkLsgs6y.js";import"./restartOpenCode-VEmIrLer.js";import"./useInlineCommentController-ynkUsoVA.js";import"./FilePreviewCommentMenu-Ca4ziuof.js";import"./spaceNetwork-DA16ov_y.js";import"./space-apply-DB_ZfJBW.js";import"./scheduledTasksApi-NSyxVfHu.js";import"./vendor-cron-parser-CjvYVigk.js";import"./vendor-luxon-BZ0puJYg.js";import"./changesTree-CePHbFcj.js";import"./computeVirtualFileMetrics-MZqvCQy0.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-C1F9opE5.js";import"./vendor-diff-C3JhlQdm.js";import"./pierreDiffTint-D9K6_CVD.js";import"./Virtualizer-DNgIEKcx.js";let ea=null,zi=!1;const $d=new Promise(n=>{ea=n});function Wd(){zi||(zi=!0,ea?.())}const Vd=6,Ud=n=>n.parentID??null,Ir=n=>{const e=n.replace(/\/+$/,"");return e.slice(e.lastIndexOf("/")+1)||e},Gd=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),Kd=(n,e)=>{if(!n)return"";let s=null,i=-1;for(const r of e){const o=Gd(r.path);(n===o||n.startsWith(`${o}/`))&&o.length>i&&(s=r,i=o.length)}return s?s.label?.trim()||Ir(s.path):Ir(n)},qd=()=>{const n=bs.getState().activeSessions,e=tl.getState().index.session.unseenCount,s=Fe.getState().notifyOnSubtasks,i=rt.getState().projects,r=Sr.getState().ids,o=ko.getState().rankById;let a=0;const l=[];for(const m of n){const f=Ud(m)!==null,p=(e[m.id]??0)>0&&(!f||s);p&&(a+=1),f||l.push({session:m,unread:p,project:Kd(So(m),i)})}l.sort((m,f)=>sl(m.session,f.session,r,o));const u=l.slice(0,Vd).map(({session:m,unread:f,project:g})=>({id:m.id,title:m.title??"",unread:f,project:g}));return{runtimeKey:rn(),attentionCount:a,recentSessions:u,projects:i.map(m=>({id:m.id,label:m.label?.trim()||Ir(m.path)}))}},Hd="__OPENCHAMBER_WIDGET_SNAPSHOT__",Yd=()=>{typeof window>"u"||(window[Hd]=()=>{try{return JSON.stringify(qd())}catch{return null}})},mr="mobile-app-update-available",Bi="mobile-app-update-toast-dismissed-version",Jd=()=>{const n=de.c(8),{t:e}=he(),s=hs(Xd),i=hs(Qd),r=hs(Zd),o=hs(ef);let a;n[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Set,n[0]=a):a=n[0];const l=kr.useRef(a);let u,m;return n[1]!==s||n[2]!==o||n[3]!==i||n[4]!==e||n[5]!==r?(u=()=>{if(Mr()!=="android"||i!=="mobile"||!s||!r||!o){ce.dismiss(mr);return}yi().getItem(Bi)!==r&&(l.current.has(r)||(l.current.add(r),ce.info(e("mobileUpdate.toast.available.title"),{id:mr,description:e("mobileUpdate.toast.available.description",{version:r}),duration:1/0,icon:t.jsx(q,{name:"download",className:"h-4 w-4 text-muted-foreground"}),action:{label:e("mobileUpdate.toast.actions.download"),onClick:()=>{nl(o)}},cancel:{label:e("mobileUpdate.toast.actions.dismiss"),onClick:()=>{yi().setItem(Bi,r),ce.dismiss(mr)}}})))},m=[s,o,i,e,r],n[1]=s,n[2]=o,n[3]=i,n[4]=e,n[5]=r,n[6]=u,n[7]=m):(u=n[6],m=n[7]),kr.useEffect(u,m),null};function Xd(n){return n.available}function Qd(n){return n.runtimeType}function Zd(n){return n.info?.version}function ef(n){return n.info?.downloadUrl}const Li="calc(var(--oc-safe-area-top, 0px) + var(--oc-visual-viewport-offset-top, 0px) + 16px)";function tf(n){const e=de.c(3);let s,i;e[0]!==n?(s=()=>{const r=window.visualViewport,o=n.current;if(!r||!o)return;let a="";const l=()=>{const u=`${Math.max(0,Math.round(r.offsetTop))}px`;u!==a&&(a=u,o.style.setProperty("--oc-visual-viewport-offset-top",u))};return l(),r.addEventListener("scroll",l),r.addEventListener("resize",l),()=>{r.removeEventListener("scroll",l),r.removeEventListener("resize",l)}},i=[n],e[0]=n,e[1]=s,e[2]=i):(s=e[1],i=e[2]),c.useEffect(s,i)}function sf(){const n=de.c(1),e=c.useRef(null);tf(e);let s;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx("div",{ref:e,className:"contents",children:t.jsx(rl,{position:"top-center",offset:Li,mobileOffset:{top:Li}})}),n[0]=s):s=n[0],s}const Fi=300,nf="openchamber.mobile.connectLog.v1",gs=[];if(typeof window<"u")try{window.localStorage.removeItem(nf)}catch{}const ni=(n,e)=>{gs.push({at:Date.now(),step:n,detail:e}),gs.length>Fi&&gs.splice(0,gs.length-Fi)};typeof window<"u"&&ni("app:launch","{}");const rf=()=>[...gs],of=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)}`},ta=n=>`${of(n.at)} ${n.step}${n.detail&&n.detail!=="{}"?` ${n.detail}`:""}`,af=()=>gs.map(ta).join(`
3
+ `),sa=(n,e)=>{const s=de.c(10),i=700,r=c.useRef(null),o=c.useRef(null),a=c.useRef(!1);let l;s[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{r.current!==null&&window.clearTimeout(r.current),r.current=null,o.current=null},s[0]=l):l=s[0];const u=l;let m,f;s[1]===Symbol.for("react.memo_cache_sentinel")?(m=()=>u,f=[u],s[1]=m,s[2]=f):(m=s[1],f=s[2]),c.useEffect(m,f);let g;s[3]!==i||s[4]!==n?(g=j=>{a.current=!1,o.current={x:j.clientX,y:j.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]=g):g=s[5];const p=g;let h;s[6]===Symbol.for("react.memo_cache_sentinel")?(h=j=>{const R=o.current;R&&(Math.abs(j.clientX-R.x)>10||Math.abs(j.clientY-R.y)>10)&&u()},s[6]=h):h=s[6];const x=h;let v;s[7]===Symbol.for("react.memo_cache_sentinel")?(v=j=>{a.current&&(a.current=!1,j.preventDefault(),j.stopPropagation())},s[7]=v):v=s[7];const b=v;let C;return s[8]!==p?(C={onPointerDown:p,onPointerMove:x,onPointerUp:u,onPointerCancel:u,onClickCapture:b},s[8]=p,s[9]=C):C=s[9],C},lf=async(n,e)=>{let s;const i=new Promise(r=>{s=setTimeout(()=>r({response:null,failure:"timeout"}),n)});try{return await Promise.race([e.then(r=>({response:r,failure:null}),r=>({response:null,failure:r instanceof Error?r.message:String(r)})),i])}finally{s!==void 0&&clearTimeout(s)}},cf=(n,e)=>new Promise(s=>{const i=l=>{clearTimeout(o),a(),s(l)},r=l=>{l.state==="connected"?i(!0):(l.state==="idle"||l.terminal)&&i(!1)},o=setTimeout(()=>i(!1),e),a=n.subscribeStatus(r);r(n.getStatus())}),ks=(n,e,s,i)=>lf(i,n.fetch(e,s)),na=async(n,e,s,i)=>{const r=Date.now()+i;let o=await ks(n,e,s,i);for(;!o.response&&o.failure!=="timeout"&&n.getStatus().state!=="connected";){const a=r-Date.now();if(a<=0||!await cf(n,a))return o;const l=r-Date.now();if(l<=0)return o;o=await ks(n,e,s,l)}return o},Mn="openchamber.mobile.connections.v1",uf="openchamber.mobile.",$i="openchamber.mobile.deviceId",df=()=>{try{const n=window.localStorage.getItem($i);if(n&&n.trim())return n.trim();const e=crypto.randomUUID();return window.localStorage.setItem($i,e),e}catch{return crypto.randomUUID()}},Wi=()=>`mobile:${df()}`,Vi=()=>{try{const n=rd.getPlatform();return n==="ios"||n==="android"?n:void 0}catch{return}},ra=12,ri=8e3,ff=2500,mf=3e3,On=2500,pf=()=>{let n=0;return{begin:()=>(n+=1,n),cancel:()=>{n+=1},isCurrent:e=>e===n}},Rs=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(/\/+$/,"")},Pn=n=>{try{return new URL(n).host}catch{return n}},Ss=n=>{try{return Rs(n)}catch{return n.trim().replace(/\/+$/g,"")}},ia=(n,e)=>Ss(n)===Ss(e),oa=n=>`relay:${n.serverId}@${n.relayUrl.trim()}`,hf=n=>`relay://${n.serverId}`,Kn=n=>n.candidates.filter(e=>e.kind==="direct"),Qt=n=>{const e=n.candidates.find(s=>s.kind==="relay");return e&&e.kind==="relay"?e.relay:null},Tt=n=>{const e=Kn(n)[0];if(e)return e.url;const s=Qt(n);return s?hf(s):""},Ke=n=>{const e=Qt(n);if(e)return oa(e);const s=Kn(n)[0];return s?Ss(s.url):""},zn=(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=>Ss(o.url)));return e.some(o=>o.kind==="relay"?i!==null&&o.relay.serverId===i:r.has(Ss(o.url)))},ii=n=>{const e=(()=>{try{return Rs(n)}catch{return""}})();return e?[{kind:"direct",url:e}]:[]},Ui=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(...ii(n.url)),n.relay&&e.push({kind:"relay",relay:n.relay}),e},oi=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}}},aa=n=>{try{return JSON.stringify(n)}catch{return String(n)}},Ee=(n,e={})=>{const s=aa(e);console.info("[mobile-connect]",n,s),ni(n,s)},Gs=(n,e={})=>{Ee(n,e)},Ns=(n,e={})=>{const s=aa(e);console.info("[mobile-storage]",n,s),ni(n,s)},gf=n=>{if(typeof n!="string")return n;try{return JSON.parse(n)}catch{return n}},bf=n=>{if(typeof n!="string")return n??void 0;try{return JSON.parse(n)}catch{return n}},xf=async(n,e)=>{if(!Xe())return null;try{const{CapacitorHttp:s}=await ws(async()=>{const{CapacitorHttp:o}=await import("./vendor-capacitor-core-B4EWRrHz.js");return{CapacitorHttp:o}},[]),i=Ua(n,new Headers(e?.headers)),r=await s.request({url:n,method:e?.method||"GET",headers:Object.fromEntries(i.entries()),data:bf(e?.body)});return{ok:r.status>=200&&r.status<300,status:r.status,source:"native-http",json:async()=>gf(r.data)}}catch(s){return Ee("native-http:failed",{url:n,error:s instanceof Error?s.message:String(s)}),null}},yf=async(n,e)=>{const s=await fetch(n,e).catch(i=>(Ee("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},Bn=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)}},Zt=async(n,e,s)=>{const i=s?.totalTimeoutMs??ri,r=Date.now(),o=await Bn(Math.min(ff,i),xf(n,e));if(o)return o;const a=new AbortController,l=Math.max(500,i-(Date.now()-r));return Bn(l,yf(n,{...e,signal:a.signal}),()=>a.abort())},qn=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}},Cs=15e3,la=n=>{n?.owned&&n.client.close()},Gi=async(n,e)=>{if(n.status===401)return e?"auth-failed":"needs-login";if(!n.ok&&n.status!==404)return"auth-failed";const s=await qn(n);return s&&s.disabled!==!0&&s.authenticated===!1?e?"auth-failed":"needs-login":"ok"},vf=async(n,e,s,i=Cs,r)=>{const o=e?{Authorization:`Bearer ${e}`}:void 0,a=da(n);if(a){const{response:u,failure:m}=await ks(a,"/auth/session",{headers:o},i);if(Ee("relay:session",{shared:!0,ok:u?.ok===!0,status:u?.status??null,hasToken:!!e,error:m}),u){const f=await Gi(u,e);return f==="ok"&&r?.keepTunnel?{outcome:f,tunnel:{client:a,owned:!1}}:{outcome:f}}}const l=wo({relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk});try{const{response:u,failure:m}=await na(l,"/auth/session",{headers:o},i);Ee("relay:session",{shared:!1,ok:u?.ok===!0,status:u?.status??null,hasToken:!!e,error:m});const f=u?await Gi(u,e):"unreachable";return f==="ok"&&r?.keepTunnel?{outcome:f,tunnel:{client:l,owned:!0}}:(l.close(),{outcome:f})}catch(u){throw l.close(),u}},wf=(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&&Wa(a,r),ms({apiBaseUrl:o,clientToken:e,runtimeKey:i??oa(n),relay:a})},jf=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=oi(e.relay);return s?{kind:"relay",relay:s}:null}return null},kf=n=>{if(n.mode==="relay"){const e=oi(n.relay);return e?[{kind:"relay",relay:e}]:[]}return typeof n.url=="string"?ii(n.url):[]},es=()=>{if(typeof window>"u")return[];let n;try{n=JSON.parse(window.localStorage.getItem(Mn)||"[]")}catch{return[]}if(!Array.isArray(n))return[];const e=Xe();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(jf).filter(u=>!!u):kf(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:Pn(Tt({candidates:r})),l={id:i.id,label:a,candidates:r,lastUsedAt:typeof i.lastUsedAt=="number"?i.lastUsedAt:0};return e?[{...l,hasToken:!!i.hasToken||!!o}]:[{...l,clientToken:o,hasToken:!!o}]}).sort((s,i)=>i.lastUsedAt-s.lastUsedAt)},Ar=n=>n.kind==="relay"?{kind:"relay",relay:{relayUrl:n.relay.relayUrl,serverId:n.relay.serverId,hostEncPubJwk:n.relay.hostEncPubJwk}}:{kind:"direct",url:n.url},ai=n=>{if(typeof window>"u")return;const e=Xe(),s=n.slice(0,ra).map(i=>{const r={id:i.id,label:i.label,candidates:i.candidates.map(Ar),lastUsedAt:i.lastUsedAt};return e?{...r,hasToken:!!(i.hasToken||i.clientToken)}:{...r,clientToken:i.clientToken}});try{window.localStorage.setItem(Mn,JSON.stringify(s))}catch(i){console.warn("[mobile-storage] failed to persist connection metadata",i)}},ca=(n,e)=>{const s=n.find(o=>e.id&&o.id===e.id||zn(o.candidates,e.candidates)),i=Xe(),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&&!zn(o.candidates,e.candidates))].slice(0,ra)},li=nd,Sf=0,ci=n=>`${uf}token.${encodeURIComponent(n)}`,Nf=async(n,e)=>{let s;const i=new Promise(r=>{s=window.setTimeout(()=>r(e),mf)});try{return await Promise.race([n.catch(()=>e),i])}finally{s!==void 0&&window.clearTimeout(s)}},ui=async(n,e,s)=>Xe()?Nf(e().catch(i=>(console.warn(`[mobile-storage] ${n} failed`,i),s)),s):s,tn=async n=>{Ns("secure:read-start",{key:n});const e=await ui("secure:read",async()=>(await li.internalGetItem({prefixedKey:ci(n),sync:!1})).data,null),s=typeof e=="string"&&e.trim()?e:void 0;return Ns("secure:read",{key:n,hasToken:!!s}),s},Jt=async(n,e)=>{Ns("secure:write-start",{key:n});const s=await ui("secure:write",async()=>(await li.internalSetItem({prefixedKey:ci(n),data:e,sync:!1,access:Sf}),!0),!1);return Ns("secure:write",{key:n,ok:s}),s},Cf=async n=>{await ui("secure:delete",async()=>(await li.internalRemoveItem({prefixedKey:ci(n),sync:!1}),!0),!1)},Rf=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,l=typeof a.url=="string"?a.url:null,u=typeof a.clientToken=="string"?a.clientToken.trim():"";if(!l||!u)return o;if(!await e(l,u))return i+=1,o;s+=1;const{clientToken:m,...f}=a;return{...f,hasToken:!0}})),migrated:s,failed:i}},ua=async()=>{if(typeof window>"u"||!Xe())return;let n;try{n=JSON.parse(window.localStorage.getItem(Mn)||"[]")}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;Ns("secure:migrate-start",{count:e.length});const s=await Rf(n,async(i,r)=>{const o=Ss(i);return await Jt(o,r)?await tn(o)===r:!1});if(s.migrated>0)try{window.localStorage.setItem(Mn,JSON.stringify(s.records))}catch(i){console.warn("[mobile-storage] failed to finalize secure token migration",i);return}Ns("secure:migrate-done",{migrated:s.migrated,failed:s.failed})},Ef=async()=>(await ua(),es()),Ln=async n=>{const e=ca(es(),n);return ai(e),Xe()&&n.clientToken&&await Jt(Ke({candidates:n.candidates}),n.clientToken),e},If=async n=>{const e=es(),s=e.find(r=>r.id===n)??null,i=e.filter(r=>r.id!==n);return ai(i),s&&Xe()&&await Cf(Ke(s)),i},Af=1500,Fn=async(n,e,s)=>{const i=s?.fast?{totalTimeoutMs:On}:void 0,r=Qt({candidates:n})?.serverId??null,o=n.find(m=>m.kind==="relay")??null,a=n.filter(m=>m.kind==="direct"),l=async()=>{for(const m of a){const f=Rs(m.url)||m.url,g=e?{Authorization:`Bearer ${e}`}:void 0,p=await Zt(`${f}/health`,{method:"GET"},i);if(Ee("probe:direct:health",{url:f,ok:p?.ok===!0,status:p?.status??null,source:p?.source??null}),!p?.ok)continue;if(r){const b=await p.json().catch(()=>null),C=b&&typeof b=="object"?b.serverId:null;if(typeof C=="string"&&C&&C!==r){Ee("probe:server-id-mismatch",{url:f});continue}}const h=await Zt(`${f}/auth/session`,{method:"GET",credentials:e?"omit":"include",headers:g},i);if(Ee("probe:direct:session",{url:f,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 qn(h);if(x&&x.disabled!==!0&&x.authenticated===!1)return{status:"needs-login"};const v=x?.disabled===!0;return!e&&Xe()&&!v&&x?.scope!=="client"?{status:"needs-login"}:{status:"ok",transport:{kind:"direct",url:f}}}return{status:"unreachable"}},u=async()=>{if(!o)return{status:"unreachable"};const{outcome:m,tunnel:f}=await vf(o.relay,e,void 0,s?.fast?On:ri,{keepTunnel:!0});return m==="ok"?{status:"ok",transport:{kind:"relay",relay:o.relay,tunnel:f}}:m==="needs-login"||m==="auth-failed"?{status:"needs-login"}:{status:"unreachable"}};return o?a.length===0?u():new Promise(m=>{let f=!1,g=!1,p,h=null,x=null;const v=j=>{j?.status==="ok"&&j.transport.kind==="relay"&&la(j.transport.tunnel)},b=j=>{f||(f=!0,m(j))},C=()=>{g||f||(p!==void 0&&(window.clearTimeout(p),p=void 0),u().then(j=>{if(x=j,f||g){v(j);return}if(j.status==="ok"||j.status==="needs-login"){b(j);return}h&&b(h)}))};l().then(j=>{if(h=j,!f){if(j.status==="ok"||j.status==="needs-login"){g=!0,p!==void 0&&window.clearTimeout(p),v(x),b(j);return}if(x){b(x);return}C()}}),p=window.setTimeout(C,Af)}):l()},Xt=(n,e,s)=>{di=!1,n.kind==="relay"?wf(n.relay,e,s?.grant,s?.runtimeKey,n.tunnel?.client):ms({apiBaseUrl:n.url,clientToken:e,runtimeKey:s?.runtimeKey}),ma()},Hs=()=>{const n=es()[0];return n?.label?.trim()?n.label:null};let di=!1;const Pf=()=>{di=!0},Ks=async n=>{if(di)return Ee("auto-connect:suppressed",{}),{status:"no-candidate"};const e=n?.fast!==!1;await ua();const s=es()[0];if(Ee("auto-connect:start",{hasCandidate:!!s,fast:e}),!s)return{status:"no-candidate"};let i;if(Xe()){if(s.hasToken&&(i=await tn(Ke(s)),!i))return{status:"no-candidate"}}else if(i=s.clientToken,!i&&s.hasToken)return{status:"no-candidate"};const r=await Fn(s.candidates,i,{fast:e});return Ee("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"&&la(r.transport.tunnel),Ee("auto-connect:superseded",{}),{status:"no-candidate"}):(await Ln({id:s.id,label:s.label,candidates:s.candidates}),Xt(r.transport,i??null,{runtimeKey:Ke(s)}),{status:"connected"})},Tf=async(n,e)=>{let s="";try{s=Rs(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:On}:void 0;if(!(await Zt(`${s}/health`,{method:"GET",headers:r},o))?.ok)return!1;const l=await Zt(`${s}/auth/session`,{method:"GET",credentials:i?"omit":"include",headers:r},o);if(!l||!l.ok&&l.status!==404)return!1;const u=await qn(l);return!(u&&u.disabled!==!0&&u.authenticated===!1)},Ki=(n,e)=>{n?.kind==="relay"&&n.owned&&!e&&n.tunnel.close()},Df=(n,e)=>n.kty===e.kty&&n.crv===e.crv&&n.x===e.x&&n.y===e.y,da=n=>{const e=Ga(),s=Va();return!e||!s||e.getStatus().state!=="connected"?null:s.relayUrl===n.relayUrl&&s.serverId===n.serverId&&Df(s.hostEncPubJwk,n.hostEncPubJwk)?e:null},_f=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=oi({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk});return s?[{kind:"relay",relay:s}]:[]}return ii(e.url)}),qi=async n=>{const e=Qt({candidates:n})?.serverId??null;for(const s of n){if(s.kind==="relay"){const o=da(s.relay);if(o){const m=await ks(o,"/health",void 0,ri);if(Ee("establish:relay:health",{shared:!0,ok:m.response?.ok===!0,status:m.response?.status??null,error:m.failure}),m.response?.ok)return{kind:"relay",relay:s.relay,tunnel:o,owned:!1}}const a=wo(s.relay),{response:l,failure:u}=await na(a,"/health",void 0,Cs);if(Ee("establish:relay:health",{shared:!1,ok:l?.ok===!0,status:l?.status??null,error:u}),l?.ok)return{kind:"relay",relay:s.relay,tunnel:a,owned:!0};a.close();continue}const i=Rs(s.url)||s.url,r=await Zt(`${i}/health`,{method:"GET"});if(Ee("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){Ee("establish:server-id-mismatch",{url:i});continue}}return{kind:"direct",url:i}}}return null},Mf=async(n,e)=>{if(!en())return Tf(n,e);const s=await Bn(e?.fast?On:Cs,Or("/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 qn(s);return!(i&&i.disabled!==!0&&i.authenticated===!1)},Of=n=>n.kind==="relay"?en():!en()&&ia(n.url,St()),fa=()=>{const n=rn();return n?es().find(e=>Ke(e)===n)??null:null},Hi=n=>{const e=rn();return!!e&&Ke(n)===e},Tn=async n=>{const e=n?.fast!==!1,s=fa();if(!s)return Ee("reprobe:no-connection",{runtimeKey:!!rn()}),"no-connection";let i;if(Xe()?i=s.hasToken?await tn(Ke(s)):void 0:i=s.clientToken,!i&&s.hasToken)return Ee("reprobe:no-token",{hasToken:!0}),"unreachable";Ee("reprobe:start",{candidates:s.candidates.map(m=>m.kind),fast:e,hasToken:!!i});const r=s.candidates.findIndex(m=>Of(m.kind==="relay"?{kind:"relay",relay:m.relay}:{kind:"direct",url:m.url})),o=r>=0?s.candidates.slice(0,r):s.candidates,a=await Fn(o,i,{fast:e});if(Ee("reprobe:better",{status:a.status,probed:o.length}),a.status==="ok")return await Ln({id:s.id,label:s.label,candidates:s.candidates}),Xt(a.transport,i??null,{runtimeKey:Ke(s)}),"switched";if(a.status==="needs-login")return"needs-login";if(r>=0){const m=await Mf({url:St(),clientToken:i},{fast:e});if(Ee("reprobe:current",{stillValid:m}),m)return ma(),"unchanged"}const l=r>=0?s.candidates.slice(r+1):[],u=await Fn(l,i,{fast:e});return Ee("reprobe:fallback",{status:u.status,probed:l.length}),u.status==="ok"?(await Ln({id:s.id,label:s.label,candidates:s.candidates}),Xt(u.transport,i??null,{runtimeKey:Ke(s)}),"switched"):u.status==="needs-login"?"needs-login":"unreachable"},zf=5e3;let pr=!1;const Bf=async()=>{if(pr)return"skipped";const n=fa();if(!n)return Ee("candidates:refresh-skip",{reason:"no-active-connection"}),"skipped";const e=Qt(n);if(!e)return Ee("candidates:refresh-skip",{reason:"no-relay-candidate"}),"skipped";pr=!0;try{const s=await Bn(Cs,Or("/api/client-auth/connection/candidates").then(m=>m).catch(()=>null));if(!s?.ok)return Ee("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 Ee("candidates:refresh-skip",{reason:"server-id-mismatch"}),"skipped";const r=Array.isArray(i.candidates)?i.candidates:[],o=[];for(const m of r){if(!m||typeof m!="object")continue;const f=m;if(!(f.type!=="lan"||typeof f.url!="string"))try{const g=Rs(f.url);g&&!o.includes(g)&&o.push(g)}catch{}}if(o.length===0)return Ee("candidates:refresh-skip",{reason:"no-lan-reported"}),"skipped";const a=Kn(n).filter(m=>m.url.startsWith("https://")),l=[...o.map(m=>({kind:"direct",url:m})),...a,{kind:"relay",relay:e}];return JSON.stringify(n.candidates.map(Ar))===JSON.stringify(l.map(Ar))?"unchanged":(Ee("candidates:refreshed",{lanCount:o.length}),await Ln({id:n.id,label:n.label,candidates:l}),"updated")}finally{pr=!1}},ma=()=>{typeof window>"u"||window.setTimeout(()=>{(async()=>{const n=await Bf().catch(()=>"skipped");Ee("candidates:refresh-result",{result:n}),n==="updated"&&en()&&await Tn().catch(()=>null)})()},zf)},pa=n=>{const{t:e}=he(),[s,i]=c.useState(()=>es()),[r,o]=c.useState(null),[a,l]=c.useState(null),[u,m]=c.useState(null),f=c.useRef(s),g=c.useRef(null),p=c.useRef(pf()),h=c.useCallback(S=>{f.current=S,i(S)},[]),x=c.useCallback(S=>{g.current=S,o(S)},[]),v=c.useCallback(S=>{g.current===S&&(g.current=null,o(null))},[]);c.useEffect(()=>{let S=!1;return Ef().then(y=>{S||h(y)}),()=>{S=!0}},[h]);const b=c.useCallback(S=>{const y=ca(f.current,S);return h(y),ai(y),y},[h]),C=c.useCallback(async S=>{l(null),x("connect");try{const y=Ui(S);if(y.length===0){l(e("mobile.connect.error.urlRequired"));return}const E=S.id?f.current.find(B=>B.id===S.id):f.current.find(B=>zn(B.candidates,y)),O=S.label?.trim()||E?.label||Pn(Tt({candidates:y})),L=S.relayGrant;let z=S.clientToken?.trim()||void 0;const A=!!z;z||(Xe()?E?.hasToken&&(z=await tn(Ke({candidates:y}))):z=E?.clientToken),Ee("connect:start",{candidates:y.map(B=>B.kind),hasToken:!!z});const _=await Fn(y,z);if(Ee("connect:probe",{status:_.status}),_.status==="unreachable"){l(e("mobile.connect.error.unreachable"));return}if(_.status==="needs-login"){b({id:E?.id,label:O,candidates:y}),m({id:E?.id??crypto.randomUUID(),label:O,candidates:y,relay:Qt({candidates:y})??void 0,relayGrant:L});return}z&&A&&Xe()&&await Jt(Ke({candidates:y}),z),b({id:E?.id,label:O,candidates:y,clientToken:z}),Xt(_.transport,z??null,{runtimeKey:Ke({candidates:y}),grant:L}),n()}catch(y){console.warn("[mobile-connect] connect threw",y),l(e("mobile.connect.error.invalidUrl"))}finally{v("connect")}},[x,v,n,b,e]),j=c.useCallback(async S=>{if(g.current==="pairing")return;l(null),x("pairing");const y=_f(S.candidates);let E=null,O=!1;try{if(E=await qi(y),!E){l(e("mobile.connect.error.unreachable"));return}const L=JSON.stringify({pairingId:S.pairingId,secret:S.secret,clientLabel:"OpenChamber Mobile",clientKind:"mobile",deviceName:"OpenChamber Mobile",devicePlatform:Vi(),dedupeKey:Wi()}),z={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:L},A=E.kind==="relay"?await ks(E.tunnel,"/api/client-auth/pairing/redeem",z,Cs):{response:await Zt(`${E.url}/api/client-auth/pairing/redeem`,z),failure:null},_=A.response;if(Ee("pairing:redeem",{transport:E.kind,ok:_?.ok===!0,status:_?.status??null,error:A.failure}),!_?.ok){l(e("mobile.connect.error.authRequired"));return}const B=await _.json().catch(()=>null),P=typeof B?.clientToken=="string"?B.clientToken.trim():"";if(!P){l(e("mobile.connect.error.authRequired"));return}const M=typeof B?.server?.label=="string"?B.server.label:"",$=S.label||M||Pn(Tt({candidates:y}));if(Xe()&&!await Jt(Ke({candidates:y}),P)){l(e("mobile.connect.error.authRequired"));return}b({label:$,candidates:y,clientToken:P}),Xt(E.kind==="relay"?{kind:"relay",relay:E.relay,tunnel:{client:E.tunnel,owned:E.owned}}:{kind:"direct",url:E.url},P,{runtimeKey:Ke({candidates:y})}),O=E.kind==="relay",n()}catch(L){console.warn("[mobile-connect] pairing threw",L),l(e("mobile.connect.error.authRequired"))}finally{Ki(E,O),v("pairing")}},[x,v,n,b,e]),R=c.useCallback(async S=>{if(!u||!S.trim()||g.current==="password")return;l(null),x("password");const y=p.current.begin(),E=()=>p.current.isCurrent(y),{id:O,label:L,candidates:z}=u;let A=null,_=!1;try{if(A=await qi(z),!E())return;if(!A){l(e("mobile.connect.error.unreachable"));return}const B={method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({password:S,trustDevice:!0,issueClientToken:!0,clientLabel:"OpenChamber Mobile",clientKind:"mobile",devicePlatform:Vi(),dedupeKey:Wi()})};Ee("password:start",{transport:A.kind});const P=A.kind==="relay"?await ks(A.tunnel,"/auth/session",B,Cs):{response:await Zt(`${A.url}/auth/session`,B),failure:null},M=P.response;if(!E())return;if(Ee("password:done",{ok:M?.ok===!0,status:M?.status??null,error:P.failure}),!M?.ok){l(e("mobile.connect.error.passwordFailed"));return}const $=await M.json().catch(()=>null);if(!E())return;const I=typeof $?.clientToken=="string"?$.clientToken.trim():"";if(Ee("password:token",{issued:!!I}),!I){if(A.kind==="direct"&&!Xe()){b({id:O,label:L,candidates:z}),m(null),Xt({kind:"direct",url:A.url},null,{runtimeKey:Ke({candidates:z})}),n();return}l(e("mobile.connect.error.authRequired"));return}if(Xe()&&(!E()||(await Jt(Ke({candidates:z}),I),!E()))||!E()||(b({id:O,label:L,candidates:z,clientToken:I}),m(null),Xt(A.kind==="relay"?{kind:"relay",relay:A.relay,tunnel:{client:A.tunnel,owned:A.owned}}:{kind:"direct",url:A.url},I,{runtimeKey:Ke({candidates:z})}),_=A.kind==="relay",!E()))return;n()}catch(B){if(!E())return;console.warn("[mobile-connect] password threw",B),l(e("mobile.connect.error.passwordFailed"))}finally{Ki(A,_),E()&&v("password")}},[x,v,n,u,b,e]),T=c.useCallback(()=>{p.current.cancel(),v("password"),m(null),l(null)},[v]),D=c.useCallback(async S=>{l(null);let y=Ui(S);const E=S.id?f.current.find(A=>A.id===S.id)??null:null;if(E){const A=y.filter(P=>P.kind==="direct"),_=Kn(E).filter(P=>P.url.startsWith("https://")&&!A.some(M=>ia(M.url,P.url))),B=Qt(E);y=[...A,..._,...B?[{kind:"relay",relay:B}]:[]]}if(y.length===0)return l(e("mobile.connect.error.urlRequired")),null;const O=S.clientToken?.trim()||void 0,L=S.label?.trim()||Pn(Tt({candidates:y}));if(Xe()){const A=Ke({candidates:y});if(O)await Jt(A,O);else if(E?.hasToken){const _=Ke(E);if(_&&A&&_!==A){const B=await tn(_);B&&await Jt(A,B)}}}return b({id:S.id,label:L,candidates:y,clientToken:O}).find(A=>zn(A.candidates,y))??null},[b,e]),k=c.useCallback(async S=>{const y=f.current.find(O=>O.id===S)??null,E=await If(S);return h(E),y},[h]);return{connections:s,isBusy:r!==null,isPasswordBusy:r==="password",error:a,pendingConnection:u,connect:C,redeemPairingConnection:j,submitPassword:R,cancelPassword:T,saveConnection:D,removeConnection:k,setError:l}},ha=n=>{const e=de.c(31),{onClose:s}=n,{t:i}=he(),[r,o]=c.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=rf(),e[0]=a):a=e[0];const l=a;let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{No(af()).then(S=>{S.ok&&(o(!0),window.setTimeout(()=>o(!1),2e3))})},e[1]=u):u=e[1];const m=u;let f;e[2]!==i?(f=i("mobile.connectionDebug.title"),e[2]=i,e[3]=f):f=e[3];let g;e[4]!==f?(g=t.jsx("h2",{className:"min-w-0 truncate typography-ui-label text-foreground",children:f}),e[4]=f,e[5]=g):g=e[5];const p=r?"check":"file-copy";let h;e[6]!==p?(h=t.jsx(q,{name:p,className:"size-4"}),e[6]=p,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 v;e[11]!==h||e[12]!==x?(v=t.jsxs(Ce,{type:"button",variant:"outline",size:"sm",onClick:m,disabled:l.length===0,children:[h,x]}),e[11]=h,e[12]=x,e[13]=v):v=e[13];let b;e[14]!==i?(b=i("mobile.connectionDebug.close"),e[14]=i,e[15]=b):b=e[15];let C;e[16]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx(q,{name:"close",className:"size-[18px]"}),e[16]=C):C=e[16];let j;e[17]!==s||e[18]!==b?(j=t.jsx(Ce,{type:"button",variant:"ghost",size:"icon","aria-label":b,onClick:s,children:C}),e[17]=s,e[18]=b,e[19]=j):j=e[19];let R;e[20]!==j||e[21]!==v?(R=t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[v,j]}),e[20]=j,e[21]=v,e[22]=R):R=e[22];let T;e[23]!==R||e[24]!==g?(T=t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border/70 px-4 py-2.5",children:[g,R]}),e[23]=R,e[24]=g,e[25]=T):T=e[25];let D;e[26]!==i?(D=t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 py-3",children:l.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:l.map(ta).join(`
4
+ `)})}),e[26]=i,e[27]=D):D=e[27];let k;return e[28]!==T||e[29]!==D?(k=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:[T,D]}),e[28]=T,e[29]=D,e[30]=k):k=e[30],k},ga=()=>{if(typeof window>"u")return null;const e=window.Capacitor?.Plugins?.BarcodeScanner;return e&&(typeof e.scan=="function"||typeof e.startScan=="function")?e:null},Lf=()=>window.Capacitor?.getPlatform?.()==="android",ba=n=>{const e=n.trim();if(!e)return null;if(/^openchamber:\/\//i.test(e)){const s=Ka(e);return s?{pairing:s}:null}return/^https?:\/\//i.test(e)?{url:e}:null},xa=(n,e)=>{const s=ba(n);if(!s&&e?.pairingStringFallback){const i=qa(n);if(i)return{status:"pairing",pairing:i}}return s?"pairing"in s?{status:"pairing",...s}:{status:"ok",...s}:{status:"invalid"}},Ff=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(m=>{o=m}),l=m=>{r||(r=!0,o(m))},u=()=>l({status:"cancelled"});e?.addEventListener("abort",u,{once:!0});try{return(await Promise.allSettled([Promise.resolve(n.addListener("barcodesScanned",({barcodes:f})=>{const g=f?.[0],p=(g?.rawValue??g?.displayValue??"").trim();p&&l(xa(p,{pairingStringFallback:!0}))})).then(f=>{s=f}),Promise.resolve(n.addListener("scanError",()=>l({status:"failed"}))).then(f=>{i=f})])).some(({status:f})=>f==="rejected")?l({status:"failed"}):r||n.startScan({formats:["QR_CODE"]}).catch(()=>l({status:"failed"})),await a}finally{e?.removeEventListener("abort",u),await Promise.allSettled([Promise.resolve(s?.remove()),Promise.resolve(i?.remove()),n.stopScan()])}},Pr=()=>ga()!==null,ya=async n=>{const e=ga();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(Lf())return Ff(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?xa(r):{status:"cancelled"}}catch{return{status:"failed"}}},ys={autoComplete:"off",autoCorrect:"off",spellCheck:!1},Ys="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",va=n=>{const e=de.c(22),{onCancel:s}=n,{t:i}=he(),r=c.useRef(null);let o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{const C={value:document.documentElement.style.getPropertyValue("background-color"),priority:document.documentElement.style.getPropertyPriority("background-color")},j={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 R=new Map,T=k=>{!(k instanceof HTMLElement)||k===r.current||R.has(k)||(R.set(k,{opacity:k.style.opacity,pointerEvents:k.style.pointerEvents}),k.style.setProperty("opacity","0"),k.style.setProperty("pointer-events","none"))};Array.from(document.body.children).forEach(T);const D=new MutationObserver(k=>{k.forEach(S=>S.addedNodes.forEach(T))});return D.observe(document.body,{childList:!0}),()=>{D.disconnect(),R.forEach($f),C.value?document.documentElement.style.setProperty("background-color",C.value,C.priority):document.documentElement.style.removeProperty("background-color"),j.value?document.body.style.setProperty("background-color",j.value,j.priority):document.body.style.removeProperty("background-color")}},a=[],e[0]=o,e[1]=a):(o=e[0],a=e[1]),c.useLayoutEffect(o,a);let l,u;e[2]!==s?(l=()=>{const C=()=>{document.visibilityState==="hidden"&&s()};return document.addEventListener("visibilitychange",C),()=>document.removeEventListener("visibilitychange",C)},u=[s],e[2]=s,e[3]=l,e[4]=u):(l=e[3],u=e[4]),c.useEffect(l,u);let m;e[5]!==i?(m=i("mobile.connect.scanQr"),e[5]=i,e[6]=m):m=e[6];let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=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]=f):f=e[7];let g;e[8]!==i?(g=i("mobile.connect.welcome.scanHint"),e[8]=i,e[9]=g):g=e[9];let p;e[10]!==g?(p=t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-6",children:[f,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:g})]}),e[10]=g,e[11]=p):p=e[11];let h;e[12]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(q,{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 v;e[15]!==s||e[16]!==x?(v=t.jsxs(Ce,{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]=v):v=e[17];let b;return e[18]!==v||e[19]!==m||e[20]!==p?(b=vs.createPortal(t.jsxs("div",{ref:r,role:"dialog","aria-modal":"true","aria-label":m,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:[p,v]}),document.body),e[18]=v,e[19]=m,e[20]=p,e[21]=b):b=e[21],b},wa=()=>{const n=de.c(6),{t:e}=he();let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx(ps,{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(q,{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=vs.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 $f(n,e){e.style.opacity=n.opacity,e.style.pointerEvents=n.pointerEvents}const Wf=({onConnected:n,notice:e=null})=>{const{t:s}=he(),i=pa(n),{connections:r,isBusy:o,isPasswordBusy:a,error:l,pendingConnection:u}=i,[m,f]=c.useState(""),[g,p]=c.useState(""),[h,x]=c.useState(""),[v,b]=c.useState(!1),[C,j]=c.useState(!1),R=c.useRef(null),T=c.useMemo(()=>Pr(),[]),[D,k]=c.useState(()=>!Pr()),[S,y]=c.useState(null),[E,O]=c.useState(""),[L,z]=c.useState(!1),A=sa(c.useCallback(()=>z(!0),[])),_=c.useCallback(I=>{I.preventDefault(),i.connect({url:m,clientToken:h,label:g})},[h,i,g,m]),B=c.useCallback(I=>{if(/^openchamber:\/\//i.test(I.trim())){const U=ba(I);if(U){if("pairing"in U){i.redeemPairingConnection(U.pairing);return}f(U.url),U.label&&p(U.label),U.clientToken&&x(U.clientToken);return}}f(I)},[i]),P=c.useCallback(async()=>{if(R.current||o)return;i.setError(null),b(!0);const I=new AbortController;R.current=I;try{const U=await ya({signal:I.signal});switch(R.current===I&&(R.current=null,b(!1)),U.status){case"ok":j(!0),f(U.url),U.label&&p(U.label),U.clientToken&&x(U.clientToken),await i.connect({url:U.url,clientToken:U.clientToken,label:U.label});break;case"pairing":j(!0),await i.redeemPairingConnection(U.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{j(!1),R.current===I&&(R.current=null,b(!1))}},[i,o,s]);c.useEffect(()=>()=>R.current?.abort(),[]);const M=c.useCallback(I=>{I.preventDefault(),i.submitPassword(E)},[i,E]),$=c.useCallback(()=>{O(""),i.cancelPassword()},[i]);return t.jsxs(t.Fragment,{children:[v?t.jsx(va,{onCancel:()=>R.current?.abort()}):null,C?t.jsx(wa,{}):null,L?t.jsx(ha,{onClose:()=>z(!1)}):null,t.jsx("main",{className:"oc-keyboard-fill-screen flex min-h-dvh flex-col overflow-y-auto bg-background px-6 pb-[calc(var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))+28px)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+28px)] text-foreground",children:t.jsxs("div",{className:"m-auto flex w-full max-w-[360px] shrink-0 flex-col items-center gap-9 py-8",children:[t.jsxs("div",{className:"flex flex-col items-center gap-5 text-center",children:[t.jsx("span",{...A,className:"select-none",style:{touchAction:"manipulation"},children:t.jsx(ps,{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(q,{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,u?t.jsxs("form",{className:"flex w-full flex-col gap-3",onSubmit:M,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(q,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0 text-start",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:u.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:u.candidates.some(I=>I.kind==="direct")?Tt(u):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...ys,value:E,onChange:I=>O(I.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:Ys}),l?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):null,t.jsx(Ce,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:a||!E.trim(),children:s(a?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(Ce,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:$,children:s("mobile.connect.cancelPassword")})]}):t.jsxs("div",{className:"flex w-full flex-col gap-6",children:[T?t.jsxs("div",{className:"flex w-full flex-col gap-2",children:[t.jsxs(Ce,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{P()},disabled:v||o,children:[t.jsx(q,{name:"scan-2",className:Z("size-[18px]",v&&"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,l&&!D?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):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(I=>{const U=S===I.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-start last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:opacity-70",onClick:()=>{y(I.id),i.connect({id:I.id,candidates:I.candidates,clientToken:I.clientToken,label:I.label}).finally(()=>y(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(q,{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:I.label}),t.jsx("span",{className:Z("block truncate typography-small",U?"text-foreground":"text-muted-foreground"),children:U?s("mobile.connect.connecting"):I.candidates.some(X=>X.kind==="direct")?Tt(I):s("mobile.connect.relay.badge")})]}),U?t.jsx(q,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):t.jsx(q,{name:"arrow-right-s",className:"size-5 text-muted-foreground"})]},I.id)})})]}):null,t.jsxs("div",{className:"flex w-full flex-col",children:[T?t.jsxs("button",{type:"button",onClick:()=>k(I=>!I),"aria-expanded":D,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(q,{name:"arrow-down-s",className:Z("size-4 transition-transform duration-200",D&&"rotate-180")})]}):null,t.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:D?"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:_,children:[t.jsx("input",{...ys,value:m,onChange:I=>B(I.target.value),placeholder:s("mobile.connect.url.placeholder"),"aria-label":s("mobile.connect.url.label"),type:"url",inputMode:"url",autoCapitalize:"none",tabIndex:D?void 0:-1,className:Z(Ys,"text-center")}),t.jsx("input",{value:g,onChange:I=>p(I.target.value),placeholder:s("mobile.instances.label.placeholder"),"aria-label":s("mobile.instances.label.label"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,tabIndex:D?void 0:-1,className:Z(Ys,"text-center")}),t.jsx("input",{...ys,value:h,onChange:I=>x(I.target.value),placeholder:s("mobile.connect.token.placeholder"),"aria-label":s("mobile.connect.token.label"),tabIndex:D?void 0:-1,autoCapitalize:"none",className:Z(Ys,"text-center")}),t.jsx("p",{className:"px-1 text-center typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")}),l?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):null,t.jsx(Ce,{type:"submit",variant:T?"outline":"default",size:"lg",className:"h-12 w-full",disabled:o||v||!m.trim(),children:s(o?"mobile.connect.connecting":"mobile.connect.connectButton")})]})})})]})]})]})})]})},Vf=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"},Uf=n=>{const e=de.c(12),{groups:s,displayMode:i,timeFormatPreference:r,className:o}=n;let a;e[0]!==o?(a=Z("space-y-1.5",o),e[0]=o,e[1]=a):a=e[1];let l;if(e[2]!==i||e[3]!==s||e[4]!==r){let m;e[6]!==i||e[7]!==r?(m=f=>t.jsxs("div",{className:"min-w-0 rounded-xl bg-foreground/[0.03] p-2.5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Co,{providerId:f.providerId,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground",children:f.providerName}),f.planLabel?t.jsx("span",{className:"shrink-0 typography-micro capitalize text-muted-foreground",children:f.planLabel}):null,f.status&&f.rows.length===0?t.jsx("span",{className:"shrink-0 truncate typography-micro text-muted-foreground",children:f.status}):null]}),f.rows.length>0?t.jsx("div",{className:"mt-1.5 space-y-1",children:f.rows.map(g=>{const p=i==="remaining"?g.window.remainingPercent:g.window.usedPercent,h=il(g.window.valueLabel,p),x=ol(g.window.resetAt,g.window.resetAfterFormatted??g.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:g.subtitle?`${g.subtitle} · ${g.label}`:g.label}),x?t.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/70",children:x}):null]}),t.jsx("span",{className:Z("shrink-0 typography-ui-label font-semibold tabular-nums",Vf(g.window)),children:h==="-"?"":h})]},g.key)})}):null,f.status&&f.rows.length>0?t.jsx("div",{className:"mt-1.5 typography-micro text-muted-foreground",children:f.status}):null]},f.providerId),e[6]=i,e[7]=r,e[8]=m):m=e[8],l=s.map(m),e[2]=i,e[3]=s,e[4]=r,e[5]=l}else l=e[5];let u;return e[9]!==a||e[10]!==l?(u=t.jsx("div",{className:a,children:l}),e[9]=a,e[10]=l,e[11]=u):u=e[11],u},Yi=380,Gf=(n,e)=>{if(!n||typeof n!="object")return;const s=n[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0},hr=n=>n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:String(n),Kf="—",ja=n=>{const e=de.c(20),{percentage:s}=n;let i,r,o,a,l,u,m;if(e[0]!==s){o=fl(s??0)??0;const h=ml(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",l="size-[18px] -rotate-90",u="progressbar",m=s===null?void 0:Math.round(o),e[0]=s,e[1]=i,e[2]=r,e[3]=o,e[4]=a,e[5]=l,e[6]=u,e[7]=m}else i=e[1],r=e[2],o=e[3],a=e[4],l=e[5],u=e[6],m=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),e[8]=f):f=e[8];let g;e[9]!==i||e[10]!==s||e[11]!==r||e[12]!==o?(g=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]=g):g=e[13];let p;return e[14]!==a||e[15]!==l||e[16]!==u||e[17]!==m||e[18]!==g?(p=t.jsxs("svg",{viewBox:a,className:l,role:u,"aria-valuenow":m,"aria-valuemin":0,"aria-valuemax":100,children:[f,g]}),e[14]=a,e[15]=l,e[16]=u,e[17]=m,e[18]=g,e[19]=p):p=e[19],p},qf=n=>{const e=de.c(13),{icon:s,iconNode:i,label:r,children:o}=n;let a;e[0]!==s||e[1]!==i?(a=i??(s?t.jsx(q,{name:s,className:"size-[18px]"}):null),e[0]=s,e[1]=i,e[2]=a):a=e[2];let l;e[3]!==a?(l=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:a}),e[3]=a,e[4]=l):l=e[4];let u;e[5]!==r?(u=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:r}),e[5]=r,e[6]=u):u=e[6];let m;e[7]!==o?(m=t.jsx("span",{className:"min-w-0 flex-1 truncate text-end typography-ui-label font-medium text-foreground",children:o}),e[7]=o,e[8]=m):m=e[8];let f;return e[9]!==l||e[10]!==u||e[11]!==m?(f=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5",children:[l,u,m]}),e[9]=l,e[10]=u,e[11]=m,e[12]=f):f=e[12],f},Hf=n=>{const e=de.c(57),{open:s,onClose:i,anchorRef:r,contextDisplay:o,usageGroups:a,usageDisplayMode:l,isUsageLoading:u,timeFormatPreference:m}=n,{t:f}=he(),g=c.useRef(null),[p,h]=c.useState(s),[x,v]=c.useState(!1),{enabled:b}=zr(),C=c.useRef(null),[j,R]=c.useState(null);let T,D;e[0]!==r||e[1]!==b||e[2]!==s||e[3]!==p?(T=()=>{if(!s||!b||!p)return;const G=()=>{const ne=r.current?.getBoundingClientRect(),re=C.current?.getBoundingClientRect();if(!ne||!re){R(null);return}const K=ne.left-re.left,oe=Math.min(Math.max(K,8),Math.max(8,re.width-Yi-8));R(oe)};G();const N=C.current;if(typeof ResizeObserver>"u"||!N)return;const Y=new ResizeObserver(G);return Y.observe(N),()=>Y.disconnect()},D=[r,b,s,p],e[0]=r,e[1]=b,e[2]=s,e[3]=p,e[4]=T,e[5]=D):(T=e[4],D=e[5]),c.useLayoutEffect(T,D);const k=b&&j!==null;let S,y;e[6]!==s||e[7]!==p?(S=()=>{if(s){h(!0),v(!1);return}if(!p)return;v(!0);const G=window.setTimeout(()=>{h(!1),v(!1)},140);return()=>window.clearTimeout(G)},y=[s,p],e[6]=s,e[7]=p,e[8]=S,e[9]=y):(S=e[8],y=e[9]),c.useEffect(S,y);let E,O;e[10]!==i||e[11]!==s?(E=()=>{if(!s)return;const G=N=>{N.key==="Escape"&&i()};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},O=[i,s],e[10]=i,e[11]=s,e[12]=E,e[13]=O):(E=e[12],O=e[13]),c.useEffect(E,O);let L,z;if(e[14]!==r||e[15]!==i||e[16]!==s?(L=()=>{if(!s)return;const G=N=>{const Y=N.target;if(!(Y instanceof Node)){i();return}g.current?.contains(Y)||r.current?.contains(Y)||i()};return document.addEventListener("pointerdown",G,!0),document.addEventListener("wheel",G,!0),()=>{document.removeEventListener("pointerdown",G,!0),document.removeEventListener("wheel",G,!0)}},z=[r,i,s],e[14]=r,e[15]=i,e[16]=s,e[17]=L,e[18]=z):(L=e[17],z=e[18]),c.useEffect(L,z),!p)return null;let A;e[19]!==f?(A=f("mobile.header.openMetadataAria"),e[19]=f,e[20]=A):A=e[20];const _=k?"absolute origin-top-left":"mx-3 mt-2",B=x?"pointer-events-none":"pointer-events-auto";let P;e[21]!==_||e[22]!==B?(P=Z("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",_,B),e[21]=_,e[22]=B,e[23]=P):P=e[23];const M=`${x?"session-metadata-out":"session-metadata-in"} ${x?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let $;e[24]!==j||e[25]!==k?($=k?{top:8,left:j??8,width:`min(${Yi}px, calc(100% - 16px))`}:null,e[24]=j,e[25]=k,e[26]=$):$=e[26];let I;e[27]!==M||e[28]!==$?(I={animation:M,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...$},e[27]=M,e[28]=$,e[29]=I):I=e[29];let U;e[30]!==o||e[31]!==f?(U=o?t.jsx(qf,{iconNode:t.jsx(ja,{percentage:o.state==="measured"?o.percentage:null}),label:f("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:Z("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]=f,e[32]=U):U=e[32];let X;e[33]!==o?.state||e[34]!==f?(X=o?.state==="compacted"?t.jsx("p",{className:"px-2.5 pb-1 typography-meta text-muted-foreground",children:f("contextUsage.compacted.description")}):null,e[33]=o?.state,e[34]=f,e[35]=X):X=e[35];let Q;e[36]!==o?.state||e[37]!==f?(Q=o?.state==="pending"?t.jsx("p",{className:"px-2.5 pb-1 typography-meta text-muted-foreground",children:f("mobile.header.metadata.contextPending")}):null,e[36]=o?.state,e[37]=f,e[38]=Q):Q=e[38];let ue;e[39]!==u||e[40]!==m||e[41]!==l||e[42]!==a?(ue=t.jsx(Yf,{groups:a,displayMode:l,isLoading:u,timeFormatPreference:m}),e[39]=u,e[40]=m,e[41]=l,e[42]=a,e[43]=ue):ue=e[43];let se;e[44]!==U||e[45]!==X||e[46]!==Q||e[47]!==ue?(se=t.jsxs("div",{className:"space-y-1",children:[U,X,Q,ue]}),e[44]=U,e[45]=X,e[46]=Q,e[47]=ue,e[48]=se):se=e[48];let te;e[49]!==P||e[50]!==I||e[51]!==se||e[52]!==A?(te=t.jsx("div",{ref:g,role:"dialog","aria-label":A,className:P,style:I,children:se}),e[49]=P,e[50]=I,e[51]=se,e[52]=A,e[53]=te):te=e[53];let ge;e[54]===Symbol.for("react.memo_cache_sentinel")?(ge=t.jsx("style",{children:`
5
5
  @keyframes session-metadata-in {
6
6
  from { opacity: 0; transform: translateY(-8px) scale(0.985); }
7
7
  to { opacity: 1; transform: translateY(0) scale(1); }
@@ -10,7 +10,7 @@ import{f as de,r as kr,j as t,R as c,c as vs,h as za}from"./vendor-react-BUCujlK
10
10
  from { opacity: 1; transform: translateY(0) scale(1); }
11
11
  to { opacity: 0; transform: translateY(-6px) scale(0.985); }
12
12
  }
13
- `}),e[54]=ge):ge=e[54];let ee;return e[55]!==te?(ee=t.jsxs("div",{ref:C,className:"fixed inset-x-0 bottom-0 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-header-height,56px))] z-20 pointer-events-none",children:[te,ge]}),e[55]=te,e[56]=ee):ee=e[56],ee},Kf=n=>{const e=de.c(30),{groups:s,displayMode:i,isLoading:r,timeFormatPreference:o}=n,{t:a}=he();let l;e[0]!==i||e[1]!==a?(l=a(i==="remaining"?"header.services.remaining":"header.services.used"),e[0]=i,e[1]=a,e[2]=l):l=e[2];const u=l;if(s.length===0){if(!r)return null;let j;e[3]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx(H,{name:"loader-4",className:"size-4 animate-spin","aria-hidden":!0}),e[3]=j):j=e[3];let R;e[4]!==a?(R=a("common.loading"),e[4]=a,e[5]=R):R=e[5];let T;return e[6]!==R?(T=t.jsxs("div",{className:"flex items-center justify-center gap-2 px-2.5 py-6 text-muted-foreground",children:[j,t.jsx("span",{className:"typography-ui-label",children:R})]}),e[6]=R,e[7]=T):T=e[7],T}let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(H,{name:"timer",className:"size-[18px]"})}),e[8]=m):m=e[8];let f;e[9]!==a?(f=a("mobile.header.metadata.usage"),e[9]=a,e[10]=f):f=e[10];let g;e[11]!==f?(g=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:f}),e[11]=f,e[12]=g):g=e[12];let p;e[13]!==r?(p=r?t.jsx(H,{name:"refresh",className:"size-3.5 animate-spin"}):null,e[13]=r,e[14]=p):p=e[14];let h;e[15]!==u?(h=t.jsx("span",{className:"truncate",children:u}),e[15]=u,e[16]=h):h=e[16];let x;e[17]!==p||e[18]!==h?(x=t.jsxs("span",{className:"inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground",children:[p,h]}),e[17]=p,e[18]=h,e[19]=x):x=e[19];let v;e[20]!==g||e[21]!==x?(v=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 px-2.5 pb-1.5",children:[m,g,x]}),e[20]=g,e[21]=x,e[22]=v):v=e[22];let b;e[23]!==i||e[24]!==s||e[25]!==o?(b=t.jsx($f,{groups:s,displayMode:i,timeFormatPreference:o}),e[23]=i,e[24]=s,e[25]=o,e[26]=b):b=e[26];let C;return e[27]!==v||e[28]!==b?(C=t.jsxs("div",{className:"pt-2.5",children:[v,b]}),e[27]=v,e[28]=b,e[29]=C):C=e[29],C},Hf=c.memo(function({open:e,onOpenChange:s,currentSessionId:i,effectiveDirectory:r,isNewSessionDraftOpen:o}){const{t:a}=he(),l=c.useRef(null),u=nl(i??"",r||void 0),m=dt(P=>P.providers),f=dt(P=>P.currentProviderId),g=dt(P=>P.currentModelId),p=dt(P=>P.getModelMetadata);dt(P=>P.modelsMetadata.size);const h=rl(c.useCallback(P=>i?P.sessionModelSelections.get(i)??null:null,[i])),x=Yt(P=>P.results),v=Yt(P=>P.refreshErrors),b=c.useRef(!1),C=Yt(P=>P.loadSettings),j=Yt(P=>P.fetchAllQuotas),R=Yt(P=>P.isLoading),T=Yt(P=>P.displayMode),D=Yt(P=>P.dropdownProviderIds),k=Fe(P=>P.timeFormatPreference);il(),c.useEffect(()=>{C()},[C]),c.useEffect(()=>{ki(D)},[D]),c.useEffect(()=>{if(!e){b.current=!1;return}b.current||R||!D.some(M=>!x.some($=>$.providerId===M)||v[M])||(b.current=!0,j())},[D,j,R,e,x,v]);const y=c.useMemo(()=>{for(let P=u.length-1;P>=0;P-=1){const M=u[P];if(M.role!=="assistant")continue;const $=M.providerID.trim(),I=M.modelID.trim();if($&&I)return{providerID:$,modelID:I}}return null},[u])??(h?{providerID:h.providerId,modelID:h.modelId}:null)??(f&&g?{providerID:f,modelID:g}:null),O=(y?m.find(P=>P.id===y.providerID):void 0)?.models.find(P=>P.id===y?.modelID),L=y?p(y.providerID,y.modelID):void 0,z=Wf(O?.limit,"context")??L?.limit?.context??0,A=c.useMemo(()=>ol(u),[u]),_=c.useMemo(()=>{if(z<=0)return null;if(o||!A)return{state:"pending"};if(A.state==="compacted")return{state:"compacted",tokens:`${Vf}/${hr(z)}`};const P=Math.min(A.totalTokens/z*100,999),M=P>=90?"text-[var(--status-error)]":P>=75?"text-[var(--status-warning)]":"text-[var(--status-success)]";return{state:"measured",percentage:P,tokens:`${hr(A.totalTokens)}/${hr(z)}`,colorClass:M}},[A,z,o]),B=al();return c.useEffect(()=>{!e||B.length===0||ki(B.map(P=>P.providerId))},[e,B]),t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:l,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":a("mobile.header.openMetadataAria"),"aria-expanded":e,onClick:()=>s(P=>!P),style:{touchAction:"manipulation"},children:t.jsx(xa,{percentage:_?.state==="measured"?_.percentage:_?.state==="compacted"?null:0})}),t.jsx(Gf,{open:e,onClose:()=>s(!1),anchorRef:l,contextDisplay:_,usageGroups:B,usageDisplayMode:T,isUsageLoading:R,timeFormatPreference:k})]})}),qf=10,Ki=380,Yf=(n,e)=>n.title?.trim()||e,Jf=n=>{const e=de.c(33),{session:s,meta:i,active:r,onSelect:o}=n,{t:a}=he(),l=Mr(s.id),u=Or(s.id),m=u!==null,f=!m&&l>0&&!r,g=zr(s.id,m),p=(m||f)&&g;let h;e[0]!==s?(h=dl(No(s)),e[0]=s,e[1]=h):h=e[1];const x=h,v=r&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let b;e[2]!==v?(b=Z("flex w-full items-center gap-3 rounded-xl px-2.5 py-2 text-start transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",v),e[2]=v,e[3]=b):b=e[3];let C;e[4]===Symbol.for("react.memo_cache_sentinel")?(C={touchAction:"manipulation"},e[4]=C):C=e[4];const j=r?"text-primary":"text-foreground";let R;e[5]!==j?(R=Z("block truncate oc-ui-start-align typography-ui-label",j),e[5]=j,e[6]=R):R=e[6];let T;e[7]!==s||e[8]!==a?(T=Yf(s,a("sessions.sidebar.session.untitled")),e[7]=s,e[8]=a,e[9]=T):T=e[9];let D;e[10]!==R||e[11]!==T?(D=t.jsx("span",{dir:"auto",className:R,children:T}),e[10]=R,e[11]=T,e[12]=D):D=e[12];let k;e[13]!==i?(k=i?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:i}):null,e[13]=i,e[14]=k):k=e[14];let S;e[15]!==D||e[16]!==k?(S=t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[D,k]}),e[15]=D,e[16]=k,e[17]=S):S=e[17];let y;e[18]!==m||e[19]!==f||e[20]!==u?(y=m||f?t.jsx(Dn,{state:u??"unread"}):null,e[18]=m,e[19]=f,e[20]=u,e[21]=y):y=e[21];let E;e[22]!==m||e[23]!==s.id||e[24]!==p||e[25]!==x?(E=p?t.jsx(Br,{sessionId:s.id,running:m,className:"typography-micro"}):x?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:x}):null,e[22]=m,e[23]=s.id,e[24]=p,e[25]=x,e[26]=E):E=e[26];let O;return e[27]!==o||e[28]!==S||e[29]!==y||e[30]!==E||e[31]!==b?(O=t.jsxs("button",{type:"button",className:b,onClick:o,style:C,children:[S,y,E]}),e[27]=o,e[28]=S,e[29]=y,e[30]=E,e[31]=b,e[32]=O):O=e[32],O},Xf=n=>{const e=de.c(50),{open:s,onClose:i,anchorRef:r}=n,{t:o}=he(),a=c.useRef(null),[l,u]=c.useState(s),[m,f]=c.useState(!1),{enabled:g}=_r(),p=c.useRef(null),[h,x]=c.useState(null);let v,b;e[0]!==r||e[1]!==g||e[2]!==s||e[3]!==l?(v=()=>{if(!s||!g||!l)return;const ee=()=>{const Y=r.current?.getBoundingClientRect(),ne=p.current?.getBoundingClientRect();if(!Y||!ne){x(null);return}const re=Y.left-ne.left;x(Math.min(Math.max(re,8),Math.max(8,ne.width-Ki-8)))};ee();const G=p.current;if(typeof ResizeObserver>"u"||!G)return;const N=new ResizeObserver(ee);return N.observe(G),()=>N.disconnect()},b=[r,g,s,l],e[0]=r,e[1]=g,e[2]=s,e[3]=l,e[4]=v,e[5]=b):(v=e[4],b=e[5]),c.useLayoutEffect(v,b);const C=g&&h!==null,j=Oe(Qf),R=Oe(Zf),T=lt(em);let D;e[6]===Symbol.for("react.memo_cache_sentinel")?(D={maxParents:qf},e[6]=D):D=e[6];const k=ul(s||l,D);let S,y;e[7]!==s||e[8]!==l?(S=()=>{if(s){Co(),u(!0),f(!1);return}if(!l)return;f(!0);const ee=window.setTimeout(()=>{u(!1),f(!1)},140);return()=>window.clearTimeout(ee)},y=[s,l],e[7]=s,e[8]=l,e[9]=S,e[10]=y):(S=e[9],y=e[10]),c.useEffect(S,y);let E,O;e[11]!==i||e[12]!==s?(E=()=>{if(!s)return;const ee=G=>{G.key==="Escape"&&i()};return document.addEventListener("keydown",ee),()=>document.removeEventListener("keydown",ee)},O=[i,s],e[11]=i,e[12]=s,e[13]=E,e[14]=O):(E=e[13],O=e[14]),c.useEffect(E,O);let L,z;e[15]!==r||e[16]!==i||e[17]!==s?(L=()=>{if(!s)return;const ee=G=>{const N=G.target;if(!(N instanceof Node)){i();return}a.current?.contains(N)||r.current?.contains(N)||i()};return document.addEventListener("pointerdown",ee,!0),()=>document.removeEventListener("pointerdown",ee,!0)},z=[r,i,s],e[15]=r,e[16]=i,e[17]=s,e[18]=L,e[19]=z):(L=e[18],z=e[19]),c.useEffect(L,z);let A;e[20]!==i||e[21]!==R?(A=ee=>{R(ee.id,jo(ee)),i()},e[20]=i,e[21]=R,e[22]=A):A=e[22];const _=A;if(!l)return null;let B;e[23]!==o?(B=o("sessions.switcher.openAria"),e[23]=o,e[24]=B):B=e[24];const P=C?"absolute origin-top-left":"mx-3 mt-2",M=m?"pointer-events-none":"pointer-events-auto";let $;e[25]!==P||e[26]!==M?($=Z("oc-surface-elevated flex flex-col overflow-hidden rounded-[20px] border border-border/70 bg-surface-elevated p-2 shadow-[0_12px_32px_rgb(0_0_0_/_0.2)] will-change-transform",P,M),e[25]=P,e[26]=M,e[27]=$):$=e[27];const I=`${m?"session-switcher-out":"session-switcher-in"} ${m?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let U;e[28]!==h||e[29]!==C?(U=C?{top:8,left:h??8,width:`min(${Ki}px, calc(100% - 16px))`}:null,e[28]=h,e[29]=C,e[30]=U):U=e[30];let X;e[31]!==I||e[32]!==U?(X={animation:I,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...U},e[31]=I,e[32]=U,e[33]=X):X=e[33];let Q;e[34]!==j||e[35]!==_||e[36]!==k||e[37]!==T||e[38]!==o?(Q=k.length===0?t.jsx("p",{className:"px-3 py-6 text-center typography-small text-muted-foreground",children:o("sessions.switcher.empty")}):k.map(ee=>{const G=ee.node.session,N=[ee.secondaryMeta?.projectLabel,ee.secondaryMeta?.branchLabel].filter(Boolean).join(" · ");return t.jsx(Jf,{session:G,meta:N,active:G.id===j,onSelect:()=>{ee.projectId&&T(ee.projectId),_(G)}},G.id)}),e[34]=j,e[35]=_,e[36]=k,e[37]=T,e[38]=o,e[39]=Q):Q=e[39];let ue;e[40]!==Q?(ue=t.jsx("div",{className:"oc-hide-scrollbar min-h-0 flex-1 space-y-0.5 overflow-y-auto overscroll-contain",children:Q}),e[40]=Q,e[41]=ue):ue=e[41];let se;e[42]!==B||e[43]!==$||e[44]!==X||e[45]!==ue?(se=t.jsx("div",{ref:a,role:"dialog","aria-label":B,className:$,style:X,children:ue}),e[42]=B,e[43]=$,e[44]=X,e[45]=ue,e[46]=se):se=e[46];let te;e[47]===Symbol.for("react.memo_cache_sentinel")?(te=t.jsx("style",{children:`
13
+ `}),e[54]=ge):ge=e[54];let ee;return e[55]!==te?(ee=t.jsxs("div",{ref:C,className:"fixed inset-x-0 bottom-0 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-header-height,56px))] z-20 pointer-events-none",children:[te,ge]}),e[55]=te,e[56]=ee):ee=e[56],ee},Yf=n=>{const e=de.c(30),{groups:s,displayMode:i,isLoading:r,timeFormatPreference:o}=n,{t:a}=he();let l;e[0]!==i||e[1]!==a?(l=a(i==="remaining"?"header.services.remaining":"header.services.used"),e[0]=i,e[1]=a,e[2]=l):l=e[2];const u=l;if(s.length===0){if(!r)return null;let j;e[3]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx(q,{name:"loader-4",className:"size-4 animate-spin","aria-hidden":!0}),e[3]=j):j=e[3];let R;e[4]!==a?(R=a("common.loading"),e[4]=a,e[5]=R):R=e[5];let T;return e[6]!==R?(T=t.jsxs("div",{className:"flex items-center justify-center gap-2 px-2.5 py-6 text-muted-foreground",children:[j,t.jsx("span",{className:"typography-ui-label",children:R})]}),e[6]=R,e[7]=T):T=e[7],T}let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(q,{name:"timer",className:"size-[18px]"})}),e[8]=m):m=e[8];let f;e[9]!==a?(f=a("mobile.header.metadata.usage"),e[9]=a,e[10]=f):f=e[10];let g;e[11]!==f?(g=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:f}),e[11]=f,e[12]=g):g=e[12];let p;e[13]!==r?(p=r?t.jsx(q,{name:"refresh",className:"size-3.5 animate-spin"}):null,e[13]=r,e[14]=p):p=e[14];let h;e[15]!==u?(h=t.jsx("span",{className:"truncate",children:u}),e[15]=u,e[16]=h):h=e[16];let x;e[17]!==p||e[18]!==h?(x=t.jsxs("span",{className:"inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground",children:[p,h]}),e[17]=p,e[18]=h,e[19]=x):x=e[19];let v;e[20]!==g||e[21]!==x?(v=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 px-2.5 pb-1.5",children:[m,g,x]}),e[20]=g,e[21]=x,e[22]=v):v=e[22];let b;e[23]!==i||e[24]!==s||e[25]!==o?(b=t.jsx(Uf,{groups:s,displayMode:i,timeFormatPreference:o}),e[23]=i,e[24]=s,e[25]=o,e[26]=b):b=e[26];let C;return e[27]!==v||e[28]!==b?(C=t.jsxs("div",{className:"pt-2.5",children:[v,b]}),e[27]=v,e[28]=b,e[29]=C):C=e[29],C},Jf=c.memo(function({open:e,onOpenChange:s,currentSessionId:i,effectiveDirectory:r,isNewSessionDraftOpen:o}){const{t:a}=he(),l=c.useRef(null),u=al(i??"",r||void 0),m=dt(P=>P.providers),f=dt(P=>P.currentProviderId),g=dt(P=>P.currentModelId),p=dt(P=>P.getModelMetadata);dt(P=>P.modelsMetadata.size);const h=ll(c.useCallback(P=>i?P.sessionModelSelections.get(i)??null:null,[i])),x=Yt(P=>P.results),v=Yt(P=>P.refreshErrors),b=c.useRef(!1),C=Yt(P=>P.loadSettings),j=Yt(P=>P.fetchAllQuotas),R=Yt(P=>P.isLoading),T=Yt(P=>P.displayMode),D=Yt(P=>P.dropdownProviderIds),k=Fe(P=>P.timeFormatPreference);cl(),c.useEffect(()=>{C()},[C]),c.useEffect(()=>{Ci(D)},[D]),c.useEffect(()=>{if(!e){b.current=!1;return}b.current||R||!D.some(M=>!x.some($=>$.providerId===M)||v[M])||(b.current=!0,j())},[D,j,R,e,x,v]);const y=c.useMemo(()=>{for(let P=u.length-1;P>=0;P-=1){const M=u[P];if(M.role!=="assistant")continue;const $=M.providerID.trim(),I=M.modelID.trim();if($&&I)return{providerID:$,modelID:I}}return null},[u])??(h?{providerID:h.providerId,modelID:h.modelId}:null)??(f&&g?{providerID:f,modelID:g}:null),O=(y?m.find(P=>P.id===y.providerID):void 0)?.models.find(P=>P.id===y?.modelID),L=y?p(y.providerID,y.modelID):void 0,z=Gf(O?.limit,"context")??L?.limit?.context??0,A=c.useMemo(()=>ul(u),[u]),_=c.useMemo(()=>{if(z<=0)return null;if(o||!A)return{state:"pending"};if(A.state==="compacted")return{state:"compacted",tokens:`${Kf}/${hr(z)}`};const P=Math.min(A.totalTokens/z*100,999),M=P>=90?"text-[var(--status-error)]":P>=75?"text-[var(--status-warning)]":"text-[var(--status-success)]";return{state:"measured",percentage:P,tokens:`${hr(A.totalTokens)}/${hr(z)}`,colorClass:M}},[A,z,o]),B=dl();return c.useEffect(()=>{!e||B.length===0||Ci(B.map(P=>P.providerId))},[e,B]),t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:l,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":a("mobile.header.openMetadataAria"),"aria-expanded":e,onClick:()=>s(P=>!P),style:{touchAction:"manipulation"},children:t.jsx(ja,{percentage:_?.state==="measured"?_.percentage:_?.state==="compacted"?null:0})}),t.jsx(Hf,{open:e,onClose:()=>s(!1),anchorRef:l,contextDisplay:_,usageGroups:B,usageDisplayMode:T,isUsageLoading:R,timeFormatPreference:k})]})}),Xf=10,Ji=380,Qf=(n,e)=>n.title?.trim()||e,Zf=n=>{const e=de.c(33),{session:s,meta:i,active:r,onSelect:o}=n,{t:a}=he(),l=Br(s.id),u=Lr(s.id),m=u!==null,f=!m&&l>0&&!r,g=Fr(s.id,m),p=(m||f)&&g;let h;e[0]!==s?(h=hl(Ro(s)),e[0]=s,e[1]=h):h=e[1];const x=h,v=r&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let b;e[2]!==v?(b=Z("flex w-full items-center gap-3 rounded-xl px-2.5 py-2 text-start transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",v),e[2]=v,e[3]=b):b=e[3];let C;e[4]===Symbol.for("react.memo_cache_sentinel")?(C={touchAction:"manipulation"},e[4]=C):C=e[4];const j=r?"text-primary":"text-foreground";let R;e[5]!==j?(R=Z("block truncate oc-ui-start-align typography-ui-label",j),e[5]=j,e[6]=R):R=e[6];let T;e[7]!==s||e[8]!==a?(T=Qf(s,a("sessions.sidebar.session.untitled")),e[7]=s,e[8]=a,e[9]=T):T=e[9];let D;e[10]!==R||e[11]!==T?(D=t.jsx("span",{dir:"auto",className:R,children:T}),e[10]=R,e[11]=T,e[12]=D):D=e[12];let k;e[13]!==i?(k=i?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:i}):null,e[13]=i,e[14]=k):k=e[14];let S;e[15]!==D||e[16]!==k?(S=t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[D,k]}),e[15]=D,e[16]=k,e[17]=S):S=e[17];let y;e[18]!==m||e[19]!==f||e[20]!==u?(y=m||f?t.jsx(Dn,{state:u??"unread"}):null,e[18]=m,e[19]=f,e[20]=u,e[21]=y):y=e[21];let E;e[22]!==m||e[23]!==s.id||e[24]!==p||e[25]!==x?(E=p?t.jsx($r,{sessionId:s.id,running:m,className:"typography-micro"}):x?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:x}):null,e[22]=m,e[23]=s.id,e[24]=p,e[25]=x,e[26]=E):E=e[26];let O;return e[27]!==o||e[28]!==S||e[29]!==y||e[30]!==E||e[31]!==b?(O=t.jsxs("button",{type:"button",className:b,onClick:o,style:C,children:[S,y,E]}),e[27]=o,e[28]=S,e[29]=y,e[30]=E,e[31]=b,e[32]=O):O=e[32],O},em=n=>{const e=de.c(50),{open:s,onClose:i,anchorRef:r}=n,{t:o}=he(),a=c.useRef(null),[l,u]=c.useState(s),[m,f]=c.useState(!1),{enabled:g}=zr(),p=c.useRef(null),[h,x]=c.useState(null);let v,b;e[0]!==r||e[1]!==g||e[2]!==s||e[3]!==l?(v=()=>{if(!s||!g||!l)return;const ee=()=>{const Y=r.current?.getBoundingClientRect(),ne=p.current?.getBoundingClientRect();if(!Y||!ne){x(null);return}const re=Y.left-ne.left;x(Math.min(Math.max(re,8),Math.max(8,ne.width-Ji-8)))};ee();const G=p.current;if(typeof ResizeObserver>"u"||!G)return;const N=new ResizeObserver(ee);return N.observe(G),()=>N.disconnect()},b=[r,g,s,l],e[0]=r,e[1]=g,e[2]=s,e[3]=l,e[4]=v,e[5]=b):(v=e[4],b=e[5]),c.useLayoutEffect(v,b);const C=g&&h!==null,j=Me(tm),R=Me(sm),T=rt(nm);let D;e[6]===Symbol.for("react.memo_cache_sentinel")?(D={maxParents:Xf},e[6]=D):D=e[6];const k=pl(s||l,D);let S,y;e[7]!==s||e[8]!==l?(S=()=>{if(s){Eo(),u(!0),f(!1);return}if(!l)return;f(!0);const ee=window.setTimeout(()=>{u(!1),f(!1)},140);return()=>window.clearTimeout(ee)},y=[s,l],e[7]=s,e[8]=l,e[9]=S,e[10]=y):(S=e[9],y=e[10]),c.useEffect(S,y);let E,O;e[11]!==i||e[12]!==s?(E=()=>{if(!s)return;const ee=G=>{G.key==="Escape"&&i()};return document.addEventListener("keydown",ee),()=>document.removeEventListener("keydown",ee)},O=[i,s],e[11]=i,e[12]=s,e[13]=E,e[14]=O):(E=e[13],O=e[14]),c.useEffect(E,O);let L,z;e[15]!==r||e[16]!==i||e[17]!==s?(L=()=>{if(!s)return;const ee=G=>{const N=G.target;if(!(N instanceof Node)){i();return}a.current?.contains(N)||r.current?.contains(N)||i()};return document.addEventListener("pointerdown",ee,!0),()=>document.removeEventListener("pointerdown",ee,!0)},z=[r,i,s],e[15]=r,e[16]=i,e[17]=s,e[18]=L,e[19]=z):(L=e[18],z=e[19]),c.useEffect(L,z);let A;e[20]!==i||e[21]!==R?(A=ee=>{R(ee.id,So(ee)),i()},e[20]=i,e[21]=R,e[22]=A):A=e[22];const _=A;if(!l)return null;let B;e[23]!==o?(B=o("sessions.switcher.openAria"),e[23]=o,e[24]=B):B=e[24];const P=C?"absolute origin-top-left":"mx-3 mt-2",M=m?"pointer-events-none":"pointer-events-auto";let $;e[25]!==P||e[26]!==M?($=Z("oc-surface-elevated flex flex-col overflow-hidden rounded-[20px] border border-border/70 bg-surface-elevated p-2 shadow-[0_12px_32px_rgb(0_0_0_/_0.2)] will-change-transform",P,M),e[25]=P,e[26]=M,e[27]=$):$=e[27];const I=`${m?"session-switcher-out":"session-switcher-in"} ${m?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let U;e[28]!==h||e[29]!==C?(U=C?{top:8,left:h??8,width:`min(${Ji}px, calc(100% - 16px))`}:null,e[28]=h,e[29]=C,e[30]=U):U=e[30];let X;e[31]!==I||e[32]!==U?(X={animation:I,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...U},e[31]=I,e[32]=U,e[33]=X):X=e[33];let Q;e[34]!==j||e[35]!==_||e[36]!==k||e[37]!==T||e[38]!==o?(Q=k.length===0?t.jsx("p",{className:"px-3 py-6 text-center typography-small text-muted-foreground",children:o("sessions.switcher.empty")}):k.map(ee=>{const G=ee.node.session,N=[ee.secondaryMeta?.projectLabel,ee.secondaryMeta?.branchLabel].filter(Boolean).join(" · ");return t.jsx(Zf,{session:G,meta:N,active:G.id===j,onSelect:()=>{ee.projectId&&T(ee.projectId),_(G)}},G.id)}),e[34]=j,e[35]=_,e[36]=k,e[37]=T,e[38]=o,e[39]=Q):Q=e[39];let ue;e[40]!==Q?(ue=t.jsx("div",{className:"oc-hide-scrollbar min-h-0 flex-1 space-y-0.5 overflow-y-auto overscroll-contain",children:Q}),e[40]=Q,e[41]=ue):ue=e[41];let se;e[42]!==B||e[43]!==$||e[44]!==X||e[45]!==ue?(se=t.jsx("div",{ref:a,role:"dialog","aria-label":B,className:$,style:X,children:ue}),e[42]=B,e[43]=$,e[44]=X,e[45]=ue,e[46]=se):se=e[46];let te;e[47]===Symbol.for("react.memo_cache_sentinel")?(te=t.jsx("style",{children:`
14
14
  @keyframes session-switcher-in {
15
15
  from { opacity: 0; transform: translateY(-8px) scale(0.985); }
16
16
  to { opacity: 1; transform: translateY(0) scale(1); }
@@ -19,7 +19,7 @@ import{f as de,r as kr,j as t,R as c,c as vs,h as za}from"./vendor-react-BUCujlK
19
19
  from { opacity: 1; transform: translateY(0) scale(1); }
20
20
  to { opacity: 0; transform: translateY(-6px) scale(0.985); }
21
21
  }
22
- `}),e[47]=te):te=e[47];let ge;return e[48]!==se?(ge=t.jsxs("div",{ref:p,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:[se,te]}),e[48]=se,e[49]=ge):ge=e[49],ge};function Qf(n){return n.currentSessionId}function Zf(n){return n.setCurrentSession}function em(n){return n.setActiveProjectIdOnly}const tm=n=>{const e=de.c(84),{onOpenSessions:s,onOpenWorkspace:i,compactTitle:r}=n,o=r===void 0?!1:r,{t:a}=he(),[l,u]=c.useState(!1),[m,f]=c.useState(!1),g=c.useRef(null),p=zt(sm),h=Oe(nm);let x;e[0]!==h?(x=Re=>h?Re.getDirectoryForSession(h):null,e[0]=h,e[1]=x):x=e[1];const b=Oe(x)||p,C=fl(h,b||void 0),j=Oe(rm),R=Ro(b||null);let T;e[2]!==b||e[3]!==R?(T=Re=>{if(!b||R!==!0)return!1;const Le=Re.directories.get(b)?.status;return!!(Le&&!Le.isClean)},e[2]=b,e[3]=R,e[4]=T):T=e[4];const D=at(T),k=Fe(im),S=Hc(k);let y;e[5]!==C?.title?(y=C?.title?.trim(),e[5]=C?.title,e[6]=y):y=e[6];const E=y;let O;e[7]!==h||e[8]!==k||e[9]!==S||e[10]!==E||e[11]!==a?(O=(k?S:null)||E||a(h?"mobile.sessions.untitled":"sessions.switcher.draftTitle"),e[7]=h,e[8]=k,e[9]=S,e[10]=E,e[11]=a,e[12]=O):O=e[12];const L=O;let z;e[13]===Symbol.for("react.memo_cache_sentinel")?(z=()=>{u(!1),f(!1)},e[13]=z):z=e[13];let A;e[14]!==h||e[15]!==b?(A=[h,b],e[14]=h,e[15]=b,e[16]=A):A=e[16],c.useEffect(z,A);let _;e[17]!==s?(_=()=>{u(!1),f(!1),s()},e[17]=s,e[18]=_):_=e[18];const B=_;let P;e[19]===Symbol.for("react.memo_cache_sentinel")?(P=Re=>{u(Le=>{const He=typeof Re=="function"?Re(Le):Re;return He&&f(!1),He})},e[19]=P):P=e[19];const M=P;let $;e[20]===Symbol.for("react.memo_cache_sentinel")?($=()=>{f(Re=>{const Le=!Re;return Le&&u(!1),Le})},e[20]=$):$=e[20];const I=$;let U;e[21]===Symbol.for("react.memo_cache_sentinel")?(U={paddingTop:"var(--oc-safe-area-top, 0px)"},e[21]=U):U=e[21];let X;e[22]!==a?(X=a("mobile.sessions.openSheetAria"),e[22]=a,e[23]=X):X=e[23];let Q,ue;e[24]===Symbol.for("react.memo_cache_sentinel")?(Q={touchAction:"manipulation"},ue=t.jsx(H,{name:"list-unordered",className:"size-5"}),e[24]=Q,e[25]=ue):(Q=e[24],ue=e[25]);let se;e[26]!==B||e[27]!==X?(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":X,onClick:B,style:Q,children:ue}),e[26]=B,e[27]=X,e[28]=se):se=e[28];const te=o?"shrink":"flex-1";let ge;e[29]!==te?(ge=Z("flex min-w-0 items-center rounded-lg px-2 py-1.5 text-start transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",te),e[29]=te,e[30]=ge):ge=e[30];let ee;e[31]!==a?(ee=a("sessions.switcher.openAria"),e[31]=a,e[32]=ee):ee=e[32];let G;e[33]===Symbol.for("react.memo_cache_sentinel")?(G={touchAction:"manipulation"},e[33]=G):G=e[33];let N;e[34]!==L?(N=t.jsx("span",{dir:"auto",className:"block min-w-0 truncate oc-ui-start-align typography-ui-label text-foreground",children:L}),e[34]=L,e[35]=N):N=e[35];const Y=m&&"rotate-180";let ne;e[36]!==Y?(ne=Z("size-4 shrink-0 text-muted-foreground transition-transform duration-150",Y),e[36]=Y,e[37]=ne):ne=e[37];let re;e[38]!==ne?(re=t.jsx(H,{name:"arrow-down-s",className:ne}),e[38]=ne,e[39]=re):re=e[39];let K;e[40]!==N||e[41]!==re?(K=t.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[N,re]}),e[40]=N,e[41]=re,e[42]=K):K=e[42];let oe;e[43]!==m||e[44]!==ge||e[45]!==ee||e[46]!==K?(oe=t.jsx("button",{ref:g,type:"button",className:ge,"aria-label":ee,"aria-haspopup":"dialog","aria-expanded":m,onClick:I,style:G,children:K}),e[43]=m,e[44]=ge,e[45]=ee,e[46]=K,e[47]=oe):oe=e[47];let fe;e[48]!==o?(fe=o?t.jsx("div",{className:"min-w-0 flex-1"}):null,e[48]=o,e[49]=fe):fe=e[49];let Se;e[50]!==h||e[51]!==b||e[52]!==j||e[53]!==l||e[54]!==k?(Se=k?null:t.jsx(Hf,{open:l,onOpenChange:M,currentSessionId:h,effectiveDirectory:b,isNewSessionDraftOpen:j}),e[50]=h,e[51]=b,e[52]=j,e[53]=l,e[54]=k,e[55]=Se):Se=e[55];let we;e[56]!==b?(we=t.jsx(qc,{directory:b,className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",iconClassName:"size-5"}),e[56]=b,e[57]=we):we=e[57];let xe;e[58]!==D||e[59]!==a?(xe=a(D?"mobile.header.openWorkspaceWithChangesAria":"mobile.header.openWorkspaceAria"),e[58]=D,e[59]=a,e[60]=xe):xe=e[60];let ye;e[61]!==i?(ye=()=>{u(!1),f(!1),i()},e[61]=i,e[62]=ye):ye=e[62];let De,Te;e[63]===Symbol.for("react.memo_cache_sentinel")?(De={touchAction:"manipulation"},Te=t.jsx(H,{name:"pencil-ruler-2",className:"size-5"}),e[63]=De,e[64]=Te):(De=e[63],Te=e[64]);let ve;e[65]!==D?(ve=D?t.jsx("span",{className:"absolute inset-e-1.5 top-1.5 size-2.5 rounded-full border-2 border-[var(--background)] bg-[var(--status-warning)]","aria-hidden":!0}):null,e[65]=D,e[66]=ve):ve=e[66];let Ne;e[67]!==xe||e[68]!==ye||e[69]!==ve?(Ne=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":xe,onClick:ye,style:De,children:[Te,ve]}),e[67]=xe,e[68]=ye,e[69]=ve,e[70]=Ne):Ne=e[70];let q;e[71]!==se||e[72]!==oe||e[73]!==fe||e[74]!==Se||e[75]!==we||e[76]!==Ne?(q=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:U,children:t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[se,oe,fe,Se,we,Ne]})}),e[71]=se,e[72]=oe,e[73]=fe,e[74]=Se,e[75]=we,e[76]=Ne,e[77]=q):q=e[77];let pe;e[78]===Symbol.for("react.memo_cache_sentinel")?(pe=()=>f(!1),e[78]=pe):pe=e[78];let Ae;e[79]!==m?(Ae=t.jsx(Xf,{open:m,onClose:pe,anchorRef:g}),e[79]=m,e[80]=Ae):Ae=e[80];let We;return e[81]!==q||e[82]!==Ae?(We=t.jsxs(t.Fragment,{children:[q,Ae]}),e[81]=q,e[82]=Ae,e[83]=We):We=e[83],We};function sm(n){return n.currentDirectory}function nm(n){return n.currentSessionId}function rm(n){return!!n.newSessionDraft?.open}function im(n){return n.runOverviewKey}const om=({onActiveConnectionDeleted:n,onConnect:e})=>{const{t:s}=he(),i=ua(e),{connections:r,isBusy:o,isPasswordBusy:a,error:l,pendingConnection:u,connect:m,submitPassword:f,cancelPassword:g,saveConnection:p,removeConnection:h,setError:x}=i,[v,b]=c.useState(null),C=v?r.find(K=>K.id===v)??null:null,[j,R]=c.useState(null),[T,D]=c.useState(""),[k,S]=c.useState(""),[y,E]=c.useState(""),[O,L]=c.useState(""),[z,A]=c.useState(!1),[_,B]=c.useState(!1),P=c.useRef(null),M=c.useMemo(()=>Ar(),[]),[$,I]=c.useState(!1),[U,X]=c.useState(null),[Q,ue]=c.useState(!1),se=Qo(c.useCallback(()=>ue(!0),[])),te=c.useCallback(()=>{b(null),D(""),S(""),E(""),x(null),I(!1)},[x]),ge=c.useCallback(K=>{K.preventDefault(),p({id:v??void 0,url:T,label:k,clientToken:y}).then(oe=>{oe&&te()})},[y,v,k,te,p,T]),ee=c.useCallback(async()=>{if(P.current)return;x(null),A(!0);const K=new AbortController;P.current=K;try{const oe=await ha({signal:K.signal});switch(P.current===K&&(P.current=null,A(!1)),oe.status){case"ok":D(oe.url),oe.label&&S(oe.label),oe.clientToken&&E(oe.clientToken),I(!0);break;case"pairing":B(!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{B(!1),P.current===K&&(P.current=null,A(!1))}},[i,x,s]);c.useEffect(()=>()=>P.current?.abort(),[]);const G=c.useCallback(K=>{K.preventDefault(),f(O)},[O,f]),N=c.useCallback(()=>{L(""),g()},[g]),Y=c.useCallback(K=>{R(oe=>oe===K?null:K)},[]),ne=c.useCallback(K=>{R(null),v===K&&te();const oe=r.length===1;h(K).then(fe=>{fe&&(oe||Ui(fe))&&n()})},[r.length,v,n,h,te]),re=Ys;return u?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:G,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(H,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:u.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:u.candidates.some(K=>K.kind==="direct")?Tt(u):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...ys,value:O,onChange:K=>L(K.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:re}),l?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:l}):null,t.jsx(Ce,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:a||!O.trim(),children:s(a?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(Ce,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:N,children:s("mobile.connect.cancelPassword")})]})})}):t.jsxs(t.Fragment,{children:[z?t.jsx(ga,{onCancel:()=>P.current?.abort()}):null,_?t.jsx(ba,{}):null,Q?t.jsx(da,{onClose:()=>ue(!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",{...se,className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map(K=>{const oe=j===K.id,fe=Ui(K),Se=U===K.id,we=Se?s("mobile.connect.connecting"):fe?en()?s("mobile.instances.status.connectedRelay"):s("mobile.instances.status.connectedDirect"):K.candidates.some(xe=>xe.kind==="direct")?Tt(K):s("mobile.connect.relay.badge");return t.jsxs("div",{className:Z("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-start transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:opacity-60",onClick:()=>{fe||(X(K.id),m({id:K.id,candidates:K.candidates,clientToken:K.clientToken,label:K.label}).finally(()=>X(null)))},disabled:o&&!Se||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(H,{name:"server",className:"size-[18px]"}),fe?t.jsx("span",{className:"absolute -inset-e-0.5 -top-0.5 size-2.5 rounded-full border-2 border-[var(--surface-elevated)] bg-[var(--status-success)]","aria-hidden":!0}):null]}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:K.label}),t.jsx("span",{className:Z("block truncate typography-small",fe&&!Se?"text-[var(--status-success)]":"text-muted-foreground"),children:we})]}),Se?t.jsx(H,{name:"loader-4",className:"size-5 shrink-0 animate-spin text-muted-foreground"}):null]}),t.jsxs("div",{className:"flex items-center gap-0.5 pe-2",children:[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:()=>ne(K.id),style:{touchAction:"manipulation"},children:[t.jsx(H,{name:"delete-bin",className:"size-[18px]"}),t.jsx("span",{className:"typography-ui-label",children:s("mobile.instances.delete")})]}):K.candidates.some(xe=>xe.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:()=>{b(K.id),D(Tt(K)),S(K.label),E(K.clientToken||""),x(null)},style:{touchAction:"manipulation"},children:t.jsx(H,{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:()=>Y(K.id),style:{touchAction:"manipulation"},children:t.jsx(H,{name:oe?"close":"delete-bin",className:"size-[18px]"})})]})]},K.id)})}):t.jsx("p",{...se,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")}),!$&&!C?t.jsxs("div",{className:"space-y-2",children:[M?t.jsxs(Ce,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{ee()},disabled:z,children:[t.jsx(H,{name:"scan-2",className:Z("size-[18px]",z&&"animate-pulse")}),s("mobile.connect.scanQr")]}):null,t.jsxs(Ce,{type:"button",variant:M?"ghost":"outline",size:"lg",className:"h-12 w-full",onClick:()=>{x(null),I(!0)},children:[t.jsx(H,{name:"add",className:"size-[18px]"}),s("mobile.instances.addManual")]}),l?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):null]}):t.jsxs("form",{className:"space-y-3",onSubmit:ge,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(C?"mobile.instances.editTitle":"mobile.instances.addTitle")}),t.jsx(Ce,{type:"button",variant:"ghost",size:"xs",onClick:te,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",{...ys,value:T,onChange:K=>D(K.target.value),placeholder:s("mobile.connect.url.placeholder"),type:"url",inputMode:"url",autoCapitalize:"none",className:re})]}),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:k,onChange:K=>S(K.target.value),placeholder:s("mobile.instances.label.placeholder"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,className:re})]}),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",{...ys,value:y,onChange:K=>E(K.target.value),placeholder:s("mobile.connect.token.placeholder"),autoCapitalize:"none",className:re}),t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")})]}),l?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:l}):null,t.jsx(Ce,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",children:s(C?"mobile.instances.saveEdit":"mobile.instances.saveNew")})]})]})})})]})},Ve=n=>on(n)??"",gr=n=>{const e=Ve(n);if(!e)return"";const s=e.split("/").filter(Boolean);return s[s.length-1]?.replace(/[-_]/g," ")||e},Hi=Zr(n=>({expandedParents:{},toggleParent:e=>n(s=>{const i={...s.expandedParents};return i[e]?delete i[e]:i[e]=!0,{expandedParents:i}})})),Rn=Zr()(Yo(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"})),Pr=Zr()(Yo(n=>({orderByProject:{},setWorktreeOrder:(e,s)=>n(i=>({orderByProject:{...i.orderByProject,[e]:s}}))}),{name:"mobile-worktree-order"})),qi=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),am=(n,e)=>{if(!n||n.length===0)return e;const s=new Map(n.map((r,o)=>[qi(r),o])),i=r=>s.get(qi(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)},Js=n=>on(n)??"",lm=n=>{const e=n;return Js(e.directory??e.project?.worktree??null)},ya=({open:n,project:e,worktree:s,onClose:i,onDeleted:r})=>{const{t:o}=he(),a=Eo(),l=bs(_=>_.activeSessions),u=Oe(_=>_.archiveSessions),m=zt(_=>_.currentDirectory),{git:f,sourceControl:g}=Un(),[p,h]=c.useState(!1),[x,v]=c.useState(!1),[b,C]=c.useState(!1),[j,R]=c.useState(null),[T,D]=c.useState(!1),k=Js(s?.path),S=typeof s?.branch=="string"&&s.branch.trim().length>0,y=c.useMemo(()=>{if(!k)return[];const _=new Map;for(const B of[...l,...a])lm(B)===k&&_.set(B.id,B);return Array.from(_.values())},[l,a,k]);c.useEffect(()=>{if(!n){h(!1),v(!1),C(!1),R(null),D(!1);return}if(!s?.path)return;let _=!1;return ml(s.path).then(B=>{_||(C(!!B?.isDirty),R(B?.upstream?.split("/")[0]?.trim()||null))}).catch(()=>{_||C(!!s.status?.isDirty)}),()=>{_=!0}},[n,s?.path,s?.status?.isDirty]);const E=c.useCallback(async _=>(await pl(e,_,{deleteRemoteBranch:S&&x,deleteLocalBranch:S&&p,remoteName:j??void 0,network:{git:f,sourceControl:g}}),Js(m)===k&&Js(e.path)&&zt.getState().setDirectory(Js(e.path),{showOverlay:!1}),!0),[m,p,x,f,S,e,j,g,k]),O=c.useCallback((_,B)=>{const P=hl(_),M=ce.loading(o("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:P}));gl(_.path),(async()=>{try{const $=await Yc({sessionIds:B,removeWorktree:()=>E(_),archiveSessions:u});if(!$.removed){ce.dismiss(M);return}const{failedIds:I}=$.archive;if(I.length>0){ce.error(I.length===1?o("sessions.sidebar.bulkActions.failedArchiveSingle",{count:I.length}):o("sessions.sidebar.bulkActions.failedArchivePlural",{count:I.length}),{id:M,description:o("sessions.sidebar.dialogs.deleteResult.tryAgain")});return}ce.success(o("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:P}),{id:M,description:o(S&&x?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed")}),r?.()}catch($){const I=$ instanceof An?$.message||o("sessions.sidebar.dialogs.deleteResult.tryAgain"):$ instanceof Nr||$ instanceof Ot&&!$.message.includes(" ")?o("gitView.publish.remoteNotGranted"):$ instanceof Error?$.message:o("sessions.sidebar.dialogs.deleteResult.tryAgain");ce.error(o("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:P}),{id:M,description:I})}finally{bl(_.path)}})()},[u,x,S,r,E,o]),L=()=>{!s||T||(O(s,y.map(_=>_.id)),i())};if(!s)return null;const z=s.branch||s.label||s.path,A=(_,B,P,M)=>t.jsxs("button",{type:"button",role:"switch","aria-checked":_,disabled:M,onClick:()=>B(!_),className:Z("flex w-full items-center justify-between gap-3 rounded-xl border border-border/70 px-3.5 py-3 text-start transition-colors","hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",M&&"pointer-events-none opacity-40"),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:P}),t.jsx("span",{className:Z("relative h-6 w-10 shrink-0 rounded-full transition-colors",_?"bg-primary":"bg-muted-foreground/30"),children:t.jsx("span",{className:Z("absolute top-0.5 size-5 rounded-full bg-white transition-transform",_?"translate-x-[1.125rem] rtl:-translate-x-[1.125rem]":"translate-x-0.5 rtl:-translate-x-0.5")})})]});return t.jsx(Io,{open:n,onClose:i,title:o("mobile.projectEdit.deleteWorktreeTitle"),footer:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Ce,{variant:"ghost",className:"flex-1",onClick:i,disabled:T,children:o("projectEditDialog.actions.cancel")}),t.jsx(Ce,{variant:"destructive",className:"flex-1",onClick:()=>{L()},disabled:T,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:z})}),b?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,y.length>0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("mobile.projectEdit.deleteWorktreeArchiveNote",{count:y.length})}):null,S?t.jsxs("div",{className:"flex flex-col gap-2",children:[A(p,h,o("mobile.projectEdit.deleteLocalBranch"),T),A(x,v,o("mobile.projectEdit.deleteRemoteBranch"),T||!j)]}):null]})})},$n=n=>{const e=de.c(20),{project:s,size:i}=n,r=i===void 0?"md":i,{currentTheme:o}=Ao(),a=s.icon?Po[s.icon]:null;let l;e[0]!==s.color?(l=To(s.color),e[0]=s.color,e[1]=l):l=e[1];const u=l,m=r==="md"?"size-5":"size-3.5";let f;e[2]!==a||e[3]!==m||e[4]!==u?(f=a?t.jsx(H,{name:a,className:m,style:u?{color:u}:void 0}):t.jsx(Cr,{className:m,style:u?{color:u}:void 0}),e[2]=a,e[3]=m,e[4]=u,e[5]=f):f=e[5];const g=f;let p;e[6]!==o||e[7]!==g||e[8]!==s.iconImage||e[9]!==s.id?(p=s.iconImage?t.jsx(Do,{project:{id:s.id,iconImage:s.iconImage??null},options:{themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},className:"size-full object-contain",fallback:g}):null,e[6]=o,e[7]=g,e[8]=s.iconImage,e[9]=s.id,e[10]=p):p=e[10];const h=p;let x;e[11]!==s.iconBackground?(x=s.iconBackground?{backgroundColor:s.iconBackground}:void 0,e[11]=s.iconBackground,e[12]=x):x=e[12];const v=x;if(r==="md"){let j;return e[13]!==g||e[14]!==h||e[15]!==v?(j=t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground",children:h?t.jsx("span",{className:"flex size-6 items-center justify-center overflow-hidden rounded-md",style:v,children:h}):g}),e[13]=g,e[14]=h,e[15]=v,e[16]=j):j=e[16],j}const b=h??g;let C;return e[17]!==v||e[18]!==b?(C=t.jsx("span",{className:"flex size-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px] text-muted-foreground",style:v,children:b}),e[17]=v,e[18]=b,e[19]=C):C=e[19],C},va=n=>{const e=de.c(57),{initialTitle:s,indent:i,className:r,aiRename:o,onSubmit:a,onCancel:l}=n,{t:u}=he(),[m,f]=c.useState(s),g=cm;let p;e[0]!==s||e[1]!==l||e[2]!==a||e[3]!==m?(p=()=>{const Q=m.trim();if(!Q||Q===s.trim()){l();return}a(Q)},e[0]=s,e[1]=l,e[2]=a,e[3]=m,e[4]=p):p=e[4];const h=p;let x;e[5]!==r?(x=Z("flex h-9 min-w-0 flex-1 items-center gap-2 pe-2",r),e[5]=r,e[6]=x):x=e[6];let v;e[7]!==i?(v={paddingInlineStart:i},e[7]=i,e[8]=v):v=e[8];let b;e[9]!==h?(b=Q=>{Q.preventDefault(),h()},e[9]=h,e[10]=b):b=e[10];let C;e[11]===Symbol.for("react.memo_cache_sentinel")?(C=Q=>f(Q.target.value),e[11]=C):C=e[11];let j;e[12]!==l?(j=Q=>Jc(Q,l),e[12]=l,e[13]=j):j=e[13];let R;e[14]!==u?(R=u("sessions.sidebar.session.rename.save"),e[14]=u,e[15]=R):R=e[15];let T;e[16]!==u?(T=u("sessions.sidebar.session.menu.rename"),e[16]=u,e[17]=T):T=e[17];let D;e[18]===Symbol.for("react.memo_cache_sentinel")?(D={minHeight:0},e[18]=D):D=e[18];let k;e[19]!==j||e[20]!==R||e[21]!==T||e[22]!==m?(k=t.jsx("input",{ref:g,value:m,onChange:C,onKeyDown:j,"aria-label":R,placeholder:T,className:"min-w-0 flex-1 bg-transparent text-[16px] typography-ui-label text-foreground outline-none placeholder:text-muted-foreground",style:D,enterKeyHint:"done"}),e[19]=j,e[20]=R,e[21]=T,e[22]=m,e[23]=k):k=e[23];const S=o.disabled;let y;e[24]!==o||e[25]!==l?(y=()=>{o.run(),l()},e[24]=o,e[25]=l,e[26]=y):y=e[26];let E;e[27]!==u?(E=u("sessions.aiRename.action"),e[27]=u,e[28]=E):E=e[28];let O,L;e[29]===Symbol.for("react.memo_cache_sentinel")?(O={touchAction:"manipulation",minHeight:0,minWidth:0},L=t.jsx(H,{name:"ai-generate-2",className:"size-4"}),e[29]=O,e[30]=L):(O=e[29],L=e[30]);let z;e[31]!==o.disabled||e[32]!==o.hint||e[33]!==y||e[34]!==E?(z=t.jsx("button",{type:"button",disabled:S,onClick:y,"aria-label":E,"aria-description":o.hint,title:o.hint,className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground disabled:opacity-40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:O,children:L}),e[31]=o.disabled,e[32]=o.hint,e[33]=y,e[34]=E,e[35]=z):z=e[35];let A;e[36]!==u?(A=u("sessions.sidebar.session.rename.save"),e[36]=u,e[37]=A):A=e[37];let _,B;e[38]===Symbol.for("react.memo_cache_sentinel")?(_={touchAction:"manipulation",minHeight:0,minWidth:0},B=t.jsx(H,{name:"check",className:"size-4"}),e[38]=_,e[39]=B):(_=e[38],B=e[39]);let P;e[40]!==A?(P=t.jsx("button",{type:"submit","aria-label":A,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:_,children:B}),e[40]=A,e[41]=P):P=e[41];let M;e[42]!==u?(M=u("sessions.sidebar.session.rename.cancel"),e[42]=u,e[43]=M):M=e[43];let $,I;e[44]===Symbol.for("react.memo_cache_sentinel")?($={touchAction:"manipulation",minHeight:0,minWidth:0},I=t.jsx(H,{name:"close",className:"size-4"}),e[44]=$,e[45]=I):($=e[44],I=e[45]);let U;e[46]!==l||e[47]!==M?(U=t.jsx("button",{type:"button",onClick:l,"aria-label":M,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:$,children:I}),e[46]=l,e[47]=M,e[48]=U):U=e[48];let X;return e[49]!==k||e[50]!==z||e[51]!==x||e[52]!==P||e[53]!==U||e[54]!==v||e[55]!==b?(X=t.jsxs("form",{className:x,style:v,onSubmit:b,children:[k,z,P,U]}),e[49]=k,e[50]=z,e[51]=x,e[52]=P,e[53]=U,e[54]=v,e[55]=b,e[56]=X):X=e[56],X};function cm(n){n&&(n.focus(),n.select())}const sn=48,wa=4*sn,um=180,Wn=n=>{const e=de.c(32),{actionsWidth:s,actions:i,revealed:r,onRevealedChange:o,dataActiveSession:a,contentClassName:l,children:u}=n,m=l===void 0?"relative flex w-full items-center bg-background":l,{direction:f}=he(),g=f==="rtl"?-1:1,p=c.useRef(null),h=c.useRef(null),x=c.useRef(!1),v=c.useRef(0),b=c.useRef(r);let C;e[0]!==g?(C=($,I)=>{const U=p.current;U&&(U.style.transition=I?`transform ${um}ms ease-out`:"none",U.style.transform=$===0?"none":`translateX(${$*g}px)`,v.current=$)},e[0]=g,e[1]=C):C=e[1];const j=C;let R,T;e[2]!==s||e[3]!==j||e[4]!==r?(R=()=>{b.current=r,j(r?s:0,!0)},T=[s,j,r],e[2]=s,e[3]=j,e[4]=r,e[5]=R,e[6]=T):(R=e[5],T=e[6]),c.useEffect(R,T);let D;e[7]===Symbol.for("react.memo_cache_sentinel")?(D=$=>{if($.touches.length!==1)return;const I=$.touches[0];h.current={x:I.clientX,y:I.clientY},x.current=!1},e[7]=D):D=e[7];const k=D;let S;e[8]!==s||e[9]!==j||e[10]!==g?(S=$=>{if(!h.current)return;const I=$.touches[0],U=(I.clientX-h.current.x)*g,X=I.clientY-h.current.y;if(!x.current){if(Math.abs(U)<8||Math.abs(U)<=Math.abs(X))return;x.current=!0}const Q=b.current?s:0;j(Math.max(0,Math.min(s,Q+U)),!1)},e[8]=s,e[9]=j,e[10]=g,e[11]=S):S=e[11];const y=S;let E;e[12]!==s||e[13]!==j||e[14]!==o?(E=()=>{if(h.current=null,!x.current)return;x.current=!1;const $=v.current>s/2;j($?s:0,!0),$!==b.current&&o($)},e[12]=s,e[13]=j,e[14]=o,e[15]=E):E=e[15];const O=E,L=a||void 0;let z;e[16]===Symbol.for("react.memo_cache_sentinel")?(z={touchAction:"pan-y"},e[16]=z):z=e[16];let A;e[17]!==s?(A={width:s},e[17]=s,e[18]=A):A=e[18];const _=!r;let B;e[19]!==i||e[20]!==A||e[21]!==_?(B=t.jsx("div",{className:"absolute inset-y-0 inset-s-0 flex items-stretch",style:A,"aria-hidden":_,children:i}),e[19]=i,e[20]=A,e[21]=_,e[22]=B):B=e[22];let P;e[23]!==u||e[24]!==m?(P=t.jsx("div",{ref:p,className:m,children:u}),e[23]=u,e[24]=m,e[25]=P):P=e[25];let M;return e[26]!==O||e[27]!==y||e[28]!==B||e[29]!==P||e[30]!==L?(M=t.jsxs("div",{"data-active-session":L,className:"relative overflow-hidden",onTouchStart:k,onTouchMove:y,onTouchEnd:O,onTouchCancel:O,style:z,children:[B,P]}),e[26]=O,e[27]=y,e[28]=B,e[29]=P,e[30]=L,e[31]=M):M=e[31],M},ja=n=>{const e=de.c(62),{sessionId:s,title:i,revealed:r,confirmingDelete:o,onArchive:a,onRequestDelete:l,onConfirmDelete:u,onRequestRename:m,onRevealedChange:f,work:g,pin:p}=n,{t:h}=he(),x=r?0:-1;let v;e[0]!==f||e[1]!==s||e[2]!==h?(v=async()=>{if(!(await ko(s).catch(dm))?.ok){Er.error(h("sessions.sidebar.session.copyId.error"));return}f?.(!1),Er.success(h("sessions.sidebar.session.copyId.success"))},e[0]=f,e[1]=s,e[2]=h,e[3]=v):v=e[3];const b=v;let C;e[4]!==h||e[5]!==i?(C=h("mobile.sessions.archiveSessionAria",{title:i}),e[4]=h,e[5]=i,e[6]=C):C=e[6];let j,R;e[7]===Symbol.for("react.memo_cache_sentinel")?(j={touchAction:"manipulation"},R=t.jsx(sd,{className:"size-[18px]"}),e[7]=j,e[8]=R):(j=e[7],R=e[8]);let T;e[9]!==a||e[10]!==C||e[11]!==x?(T=t.jsx("button",{type:"button",tabIndex:x,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":C,onClick:a,style:j,children:R}),e[9]=a,e[10]=C,e[11]=x,e[12]=T):T=e[12];let D;e[13]!==f||e[14]!==p||e[15]!==h||e[16]!==x?(D=p?t.jsx("button",{type:"button",tabIndex:x,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":p.pinned?h("sessions.sidebar.session.menu.unpin"):h("sessions.sidebar.session.menu.pin"),onClick:()=>{p.onToggle(),f?.(!1)},style:{touchAction:"manipulation"},children:t.jsx(H,{name:p.pinned?"unpin":"pushpin",className:"size-[18px]"})}):null,e[13]=f,e[14]=p,e[15]=h,e[16]=x,e[17]=D):D=e[17];let k;e[18]!==f||e[19]!==h||e[20]!==x||e[21]!==g?(k=g?t.jsx("button",{type:"button",tabIndex:x,className:Z("flex flex-1 items-center justify-center transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",g.inWork?"text-status-success":"text-muted-foreground active:text-foreground"),"aria-label":g.inWork?h("sessions.sidebar.session.work.markDone"):h("sessions.sidebar.session.work.track"),onClick:()=>{g.onToggle(),f?.(!1)},style:{touchAction:"manipulation"},children:t.jsx(H,{name:g.inWork?"check":"eye",className:g.inWork?"size-5":"size-[18px]"})}):null,e[18]=f,e[19]=h,e[20]=x,e[21]=g,e[22]=k):k=e[22];const S=o?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80";let y;e[23]!==S?(y=Z("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",S),e[23]=S,e[24]=y):y=e[24];let E;e[25]!==o||e[26]!==h||e[27]!==i?(E=o?h("mobile.sessions.confirmDeleteSessionAria",{title:i}):h("mobile.sessions.deleteSessionAria",{title:i}),e[25]=o,e[26]=h,e[27]=i,e[28]=E):E=e[28];const O=o?u:l;let L,z;e[29]===Symbol.for("react.memo_cache_sentinel")?(L={touchAction:"manipulation"},z=t.jsx(_n,{className:"size-[18px]"}),e[29]=L,e[30]=z):(L=e[29],z=e[30]);let A;e[31]!==E||e[32]!==O||e[33]!==y||e[34]!==x?(A=t.jsx("button",{type:"button",tabIndex:x,className:y,"aria-label":E,onClick:O,style:L,children:z}),e[31]=E,e[32]=O,e[33]=y,e[34]=x,e[35]=A):A=e[35];let _;e[36]!==h||e[37]!==i?(_=h("mobile.sessions.renameSessionAria",{title:i}),e[36]=h,e[37]=i,e[38]=_):_=e[38];let B,P;e[39]===Symbol.for("react.memo_cache_sentinel")?(B={touchAction:"manipulation"},P=t.jsx(Rr,{className:"size-[18px]"}),e[39]=B,e[40]=P):(B=e[39],P=e[40]);let M;e[41]!==m||e[42]!==_||e[43]!==x?(M=t.jsx("button",{type:"button",tabIndex:x,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":_,onClick:m,style:B,children:P}),e[41]=m,e[42]=_,e[43]=x,e[44]=M):M=e[44];let $;e[45]!==h?($=h("sessions.sidebar.session.menu.copyId"),e[45]=h,e[46]=$):$=e[46];let I;e[47]!==b?(I=()=>{b()},e[47]=b,e[48]=I):I=e[48];let U,X;e[49]===Symbol.for("react.memo_cache_sentinel")?(U={touchAction:"manipulation"},X=t.jsx(H,{name:"file-copy",className:"size-[18px]"}),e[49]=U,e[50]=X):(U=e[49],X=e[50]);let Q;e[51]!==$||e[52]!==I||e[53]!==x?(Q=t.jsx("button",{type:"button",tabIndex:x,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":$,onClick:I,style:U,children:X}),e[51]=$,e[52]=I,e[53]=x,e[54]=Q):Q=e[54];let ue;return e[55]!==A||e[56]!==M||e[57]!==Q||e[58]!==T||e[59]!==D||e[60]!==k?(ue=t.jsxs(t.Fragment,{children:[T,D,k,A,M,Q]}),e[55]=A,e[56]=M,e[57]=Q,e[58]=T,e[59]=D,e[60]=k,e[61]=ue):ue=e[61],ue};function dm(){return null}const vt=n=>n.parentID??null,kt=n=>{const e=n;return Ve(e.directory??e.project?.worktree??null)},ka=n=>No(n),qn=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))},fm=4,Sa=n=>{const e=de.c(4),{providerIDs:s}=n;let i;e[0]!==s?(i=s.slice(0,fm).map(mm),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=t.jsx("span",{className:"inline-flex shrink-0 items-center -space-x-1",children:i}),e[2]=i,e[3]=r):r=e[3],r};function mm(n){return t.jsx("span",{className:"inline-flex size-4 items-center justify-center rounded-full bg-background ring-1 ring-background",children:t.jsx(So,{providerId:n,className:"size-3 opacity-80"})},n)}const Na=n=>{const e=de.c(8),{session:s}=n,{t:i}=he(),r=xl(s);if(!r)return null;const o=yl[r.status];let a;e[0]!==i||e[1]!==o?(a=i(o),e[0]=i,e[1]=o,e[2]=a):a=e[2];const l=a,u=vl[r.status];let m;e[3]!==u?(m={color:u},e[3]=u,e[4]=m):m=e[4];let f;return e[5]!==l||e[6]!==m?(f=t.jsx(H,{name:"target",className:"size-3.5 shrink-0",style:m,"aria-label":l}),e[5]=l,e[6]=m,e[7]=f):f=e[7],f},Ca=n=>{const e=de.c(9),{hasPermission:s,hasForm:i}=n,{t:r}=he();if(!s&&!i)return null;let o;e[0]!==s||e[1]!==r?(o=s?t.jsx("span",{className:"inline-flex shrink-0 items-center rounded bg-destructive/10 px-1 py-0.5 text-destructive","aria-label":r("sessions.sidebar.session.status.permissionRequired"),children:t.jsx(H,{name:"shield",className:"size-3"})}):null,e[0]=s,e[1]=r,e[2]=o):o=e[2];let a;e[3]!==i||e[4]!==r?(a=i?t.jsx("span",{className:"inline-flex shrink-0 items-center rounded bg-status-info/10 px-1 py-0.5 text-status-info","aria-label":r("sessions.sidebar.session.status.questionPending"),children:t.jsx(H,{name:"question",className:"size-3"})}):null,e[3]=i,e[4]=r,e[5]=a):a=e[5];let l;return e[6]!==o||e[7]!==a?(l=t.jsxs(t.Fragment,{children:[o,a]}),e[6]=o,e[7]=a,e[8]=l):l=e[8],l},Ra=n=>{const e=de.c(7);let s;e[0]!==n?(s=l=>n.some(u=>!!l.bySession.get(u)?.permissions.length),e[0]=n,e[1]=s):s=e[1];const i=Si(s);let r;e[2]!==n?(r=l=>n.some(u=>!!l.bySession.get(u)?.forms.length),e[2]=n,e[3]=r):r=e[3];const o=Si(r);let a;return e[4]!==o||e[5]!==i?(a={hasPermission:i,hasForm:o},e[4]=o,e[5]=i,e[6]=a):a=e[6],a},nn=12,Tr="flex min-w-0 flex-1 flex-col gap-1 py-2.5 pe-3 text-start",Ea="flex h-4 min-w-0 items-center gap-1.5 text-muted-foreground",Ia=n=>{const e=de.c(5),{project:s}=n;let i;e[0]!==s?(i=t.jsx($n,{project:s,size:"xs"}),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==s.label||e[3]!==i?(r=t.jsx("span",{role:"img","aria-label":s.label,className:"inline-flex shrink-0",children:i}),e[2]=s.label,e[3]=i,e[4]=r):r=e[4],r},pm=n=>{const e=de.c(52),{entry:s,showProject:i}=n,{t:r}=he(),{run:o,project:a}=s;let l;e[0]!==o.key?(l=I=>I.runOverviewKey===o.key,e[0]=o.key,e[1]=l):l=e[1];const u=Fe(l);let m;e[2]!==s.laneNodes?(m={nodes:s.laneNodes,includeUnreadSubtasks:!1},e[2]=s.laneNodes,e[3]=m):m=e[3];const f=Uo(m);let g;e[4]!==o.lastActivity?(g=qn(o.lastActivity),e[4]=o.lastActivity,e[5]=g):g=e[5];const p=g,h=o.lanes.length,x=u||void 0,v=u&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let b;e[6]!==v?(b=Z("relative bg-background transition-colors",v),e[6]=v,e[7]=b):b=e[7];let C,j;e[8]===Symbol.for("react.memo_cache_sentinel")?(C=Z(Tr,"w-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"),j={paddingInlineStart:nn,touchAction:"manipulation"},e[8]=C,e[9]=j):(C=e[8],j=e[9]);let R;e[10]!==o.key?(R=()=>Fe.getState().setRunOverviewKey(o.key),e[10]=o.key,e[11]=R):R=e[11];let T;e[12]!==o.title||e[13]!==r?(T=r("sessions.sidebar.run.openOverviewAria",{title:o.title}),e[12]=o.title,e[13]=r,e[14]=T):T=e[14];const D=u?"text-primary":"text-foreground";let k;e[15]!==D?(k=Z("block min-w-0 flex-1 truncate oc-ui-start-align typography-ui-label",D),e[15]=D,e[16]=k):k=e[16];let S;e[17]!==o.title||e[18]!==k?(S=t.jsx("span",{dir:"auto",className:k,children:o.title}),e[17]=o.title,e[18]=k,e[19]=S):S=e[19];let y;e[20]!==f?(y=f?t.jsx(Ko,{state:f}):null,e[20]=f,e[21]=y):y=e[21];let E;e[22]!==p?(E=p?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:p}):null,e[22]=p,e[23]=E):E=e[23];let O;e[24]!==S||e[25]!==y||e[26]!==E?(O=t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[S,y,E]}),e[24]=S,e[25]=y,e[26]=E,e[27]=O):O=e[27];let L;e[28]!==a||e[29]!==i?(L=i?t.jsx(Ia,{project:a}):null,e[28]=a,e[29]=i,e[30]=L):L=e[30];let z;e[31]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx(Mo,{className:"size-3.5 shrink-0","aria-hidden":"true"}),e[31]=z):z=e[31];let A;e[32]!==h||e[33]!==r?(A=h===1?r("sessions.sidebar.run.laneCountSingle",{count:h}):r("sessions.sidebar.run.laneCountPlural",{count:h}),e[32]=h,e[33]=r,e[34]=A):A=e[34];let _;e[35]!==A?(_=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-micro",children:A}),e[35]=A,e[36]=_):_=e[36];let B;e[37]!==o.providerIDs?(B=t.jsx(Sa,{providerIDs:o.providerIDs}),e[37]=o.providerIDs,e[38]=B):B=e[38];let P;e[39]!==L||e[40]!==_||e[41]!==B?(P=t.jsxs("span",{className:Ea,children:[L,z,_,B]}),e[39]=L,e[40]=_,e[41]=B,e[42]=P):P=e[42];let M;e[43]!==T||e[44]!==O||e[45]!==P||e[46]!==R?(M=t.jsxs("button",{type:"button",className:C,style:j,onClick:R,"aria-label":T,children:[O,P]}),e[43]=T,e[44]=O,e[45]=P,e[46]=R,e[47]=M):M=e[47];let $;return e[48]!==M||e[49]!==x||e[50]!==b?($=t.jsx("div",{"data-active-session":x,className:b,children:M}),e[48]=M,e[49]=x,e[50]=b,e[51]=$):$=e[51],$},hm=n=>{const e=de.c(120),{entry:s,showProject:i,active:r,revealed:o,confirmingDelete:a,renaming:l,handlers:u}=n,{t:m}=he(),{session:f,project:g,branch:p,inSpace:h}=s;let x;e[0]!==f.title||e[1]!==m?(x=f.title?.trim()||m("mobile.sessions.untitled"),e[0]=f.title,e[1]=m,e[2]=x):x=e[2];const v=x;let b;e[3]!==f?(b=qn(ka(f)),e[3]=f,e[4]=b):b=e[4];const C=b,j=Go(f.id,f.directory,o||l),R=Mr(f.id),T=Or(f.id),D=T!==null,k=!D&&R>0&&!r,S=zr(f.id,D),y=(D||k)&&S,E=u.onToggleWork;let O;e[5]!==f?(O=_o(f),e[5]=f,e[6]=O):O=e[6];const L=O;let z;e[7]!==L||e[8]!==E||e[9]!==f?(z=E?{inWork:L,onToggle:()=>E(f,L)}:void 0,e[7]=L,e[8]=E,e[9]=f,e[10]=z):z=e[10];const A=z;let _;e[11]!==u||e[12]!==f?(_=u.isPinned(f),e[11]=u,e[12]=f,e[13]=_):_=e[13];const B=_;let P;e[14]!==u||e[15]!==f?(P=()=>u.onTogglePin(f),e[14]=u,e[15]=f,e[16]=P):P=e[16];let M;e[17]!==B||e[18]!==P?(M={pinned:B,onToggle:P},e[17]=B,e[18]=P,e[19]=M):M=e[19];const $=M,{descendantIdsOf:I}=u;let U;e[20]!==I||e[21]!==f.id?(U=[f.id,...I(f.id)],e[20]=I,e[21]=f.id,e[22]=U):U=e[22];const Q=Ra(U),ue=wa+sn+(A?sn:0);let se;e[23]!==u||e[24]!==f.id?(se=fe=>u.onRevealedChange(f.id,fe),e[23]=u,e[24]=f.id,e[25]=se):se=e[25];const te=r&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let ge;e[26]!==te?(ge=Z("relative flex w-full items-center bg-background transition-colors",te),e[26]=te,e[27]=ge):ge=e[27];let ee;e[28]!==u||e[29]!==f?(ee=()=>u.onArchive(f),e[28]=u,e[29]=f,e[30]=ee):ee=e[30];let G;e[31]!==u||e[32]!==f.id?(G=()=>u.onRequestDelete(f.id),e[31]=u,e[32]=f.id,e[33]=G):G=e[33];let N;e[34]!==u||e[35]!==f?(N=()=>u.onConfirmDelete(f),e[34]=u,e[35]=f,e[36]=N):N=e[36];let Y,ne;e[37]!==u||e[38]!==f.id?(Y=()=>u.onRequestRename(f.id),ne=fe=>u.onRevealedChange(f.id,fe),e[37]=u,e[38]=f.id,e[39]=Y,e[40]=ne):(Y=e[39],ne=e[40]);let re;e[41]!==a||e[42]!==$||e[43]!==o||e[44]!==f.id||e[45]!==ee||e[46]!==G||e[47]!==N||e[48]!==Y||e[49]!==ne||e[50]!==v||e[51]!==A?(re=t.jsx(ja,{sessionId:f.id,title:v,revealed:o,confirmingDelete:a,onArchive:ee,onRequestDelete:G,onConfirmDelete:N,onRequestRename:Y,onRevealedChange:ne,work:A,pin:$}),e[41]=a,e[42]=$,e[43]=o,e[44]=f.id,e[45]=ee,e[46]=G,e[47]=N,e[48]=Y,e[49]=ne,e[50]=v,e[51]=A,e[52]=re):re=e[52];let K;e:{let fe;e[53]!==B||e[54]!==m?(fe=B?t.jsx(H,{name:"pushpin",className:"size-3 shrink-0 text-muted-foreground","aria-label":m("sessions.sidebar.session.status.pinned")}):null,e[53]=B,e[54]=m,e[55]=fe):fe=e[55];let Se;e[56]!==j.pending||e[57]!==D||e[58]!==k||e[59]!==m||e[60]!==T?(Se=j.pending?t.jsx(H,{name:"loader-4",className:"size-3 shrink-0 animate-spin text-primary","aria-label":m("sessions.aiRename.generating")}):D||k?t.jsx(Dn,{state:T??"unread"}):null,e[56]=j.pending,e[57]=D,e[58]=k,e[59]=m,e[60]=T,e[61]=Se):Se=e[61];let we;e[62]!==D||e[63]!==f.id||e[64]!==y||e[65]!==C?(we=y?t.jsx(Br,{sessionId:f.id,running:D,className:"shrink-0 typography-micro"}):C?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:C}):null,e[62]=D,e[63]=f.id,e[64]=y,e[65]=C,e[66]=we):we=e[66];let xe;e[67]!==fe||e[68]!==Se||e[69]!==we?(xe=t.jsxs(t.Fragment,{children:[fe,Se,we]}),e[67]=fe,e[68]=Se,e[69]=we,e[70]=xe):xe=e[70];const ye=xe;let De;e[71]!==r||e[72]!==j||e[73]!==u||e[74]!==l||e[75]!==f.id||e[76]!==ye||e[77]!==v?(De=l?t.jsx(va,{initialTitle:v,indent:0,aiRename:j,className:"h-[1lh] pe-0 typography-ui-label [&_button]:size-6 [&_button>svg]:size-3.5",onSubmit:mt=>u.onSubmitRename(f.id,mt),onCancel:u.onCancelRename}):t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{dir:"auto",className:Z("block min-w-0 flex-1 truncate oc-ui-start-align typography-ui-label",r?"text-primary":"text-foreground"),children:v}),ye]}),e[71]=r,e[72]=j,e[73]=u,e[74]=l,e[75]=f.id,e[76]=ye,e[77]=v,e[78]=De):De=e[78];let Te;e[79]!==g||e[80]!==i?(Te=i?t.jsx(Ia,{project:g}):null,e[79]=g,e[80]=i,e[81]=Te):Te=e[81];let ve;e[82]!==p||e[83]!==h||e[84]!==m?(ve=p?t.jsxs(t.Fragment,{children:[h?t.jsx(H,{name:"box-3",className:"size-3.5 shrink-0","aria-hidden":!1,role:"img","aria-label":m("sessions.sidebar.group.space")}):t.jsx(H,{name:"git-branch",className:"size-3.5 shrink-0"}),t.jsx("span",{className:"block min-w-0 truncate typography-micro",children:p})]}):null,e[82]=p,e[83]=h,e[84]=m,e[85]=ve):ve=e[85];let Ne;e[86]!==f?(Ne=t.jsx(Na,{session:f}),e[86]=f,e[87]=Ne):Ne=e[87];let q;e[88]!==Q?(q=t.jsx(Ca,{...Q}),e[88]=Q,e[89]=q):q=e[89];let pe;e[90]!==Ne||e[91]!==q?(pe=t.jsxs("span",{className:"ms-auto flex shrink-0 items-center gap-1.5",children:[Ne,q]}),e[90]=Ne,e[91]=q,e[92]=pe):pe=e[92];let Ae;e[93]!==Te||e[94]!==ve||e[95]!==pe?(Ae=t.jsxs("span",{className:Ea,children:[Te,ve,pe]}),e[93]=Te,e[94]=ve,e[95]=pe,e[96]=Ae):Ae=e[96];let We;e[97]!==De||e[98]!==Ae?(We=t.jsxs(t.Fragment,{children:[De,Ae]}),e[97]=De,e[98]=Ae,e[99]=We):We=e[99];const Re=We;if(l){let mt;e[100]===Symbol.for("react.memo_cache_sentinel")?(mt={paddingInlineStart:nn},e[100]=mt):mt=e[100];let wt;e[101]!==Re?(wt=t.jsx("div",{className:Tr,style:mt,children:Re}),e[101]=Re,e[102]=wt):wt=e[102],K=wt;break e}let Le,He;e[103]===Symbol.for("react.memo_cache_sentinel")?(Le=Z(Tr,"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"),He={paddingInlineStart:nn,touchAction:"manipulation"},e[103]=Le,e[104]=He):(Le=e[103],He=e[104]);let $e;e[105]!==u||e[106]!==o||e[107]!==f?($e=()=>{if(o){u.onRevealedChange(f.id,!1);return}u.onSelect(f)},e[105]=u,e[106]=o,e[107]=f,e[108]=$e):$e=e[108];let tt;e[109]!==Re||e[110]!==$e?(tt=t.jsx("button",{type:"button",className:Le,style:He,onClick:$e,children:Re}),e[109]=Re,e[110]=$e,e[111]=tt):tt=e[111],K=tt}let oe;return e[112]!==r||e[113]!==o||e[114]!==se||e[115]!==ge||e[116]!==re||e[117]!==K||e[118]!==ue?(oe=t.jsx(Wn,{actionsWidth:ue,revealed:o,onRevealedChange:se,dataActiveSession:r,contentClassName:ge,actions:re,children:K}),e[112]=r,e[113]=o,e[114]=se,e[115]=ge,e[116]=re,e[117]=K,e[118]=ue,e[119]=oe):oe=e[119],oe},Yi=n=>{const e=de.c(9),{entries:s,showProject:i,handlers:r}=n;let o;if(e[0]!==s||e[1]!==r||e[2]!==i){let l;e[4]!==r||e[5]!==i?(l=u=>u.kind==="run"?t.jsx(pm,{entry:u,showProject:i},`run:${u.run.key}`):t.jsx(hm,{entry:u,showProject:i,active:r.currentSessionId===u.session.id,revealed:r.revealedSessionId===u.session.id,confirmingDelete:r.confirmingDeleteSessionId===u.session.id,renaming:r.renamingSessionId===u.session.id,handlers:r},u.session.id),e[4]=r,e[5]=i,e[6]=l):l=e[6],o=s.map(l),e[0]=s,e[1]=r,e[2]=i,e[3]=o}else o=e[3];let a;return e[7]!==o?(a=t.jsx(t.Fragment,{children:o}),e[7]=o,e[8]=a):a=e[8],a},Ji="mobile-surface-root",br=16,En=200,gm=()=>{if(typeof document>"u")return null;let n=document.getElementById(Ji);return n||(n=document.createElement("div"),n.id=Ji,document.body.appendChild(n)),n},Pt=({open:n,onClose:e,title:s,subtitle:i,trailing:r,disableEscapeDismiss:o=!1,headerless:a=!1,noHeaderBorder:l=!1,ariaLabel:u,variant:m="fullscreen",dialogAlign:f="chat",children:g})=>{const{t:p,direction:h}=he(),x=c.useRef(null),[v,b]=c.useState(!1),[C,j]=c.useState(!1),R=c.useRef(null),T=c.useRef(null),D=c.useRef(e);if(c.useEffect(()=>{D.current=e},[e]),typeof document<"u"&&!x.current&&(x.current=gm()),c.useEffect(()=>{if(!n){b(!1);return}const y=window.setTimeout(()=>b(!0),br);return()=>window.clearTimeout(y)},[n]),c.useEffect(()=>{if(!n){j(!1);return}const y=window.setTimeout(()=>j(!0),br+En+80);return()=>window.clearTimeout(y)},[n]),c.useEffect(()=>{if(!n)return;const y=document.body.style.overflow;T.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow="hidden";const E=()=>{const z=R.current;if(!z)return;(z.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??z).focus({preventScroll:!0})},O=window.setTimeout(E,br),L=z=>{if(z.key==="Escape"&&!o){D.current();return}if(z.key!=="Tab")return;const A=R.current;if(!A)return;const _=Array.from(A.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter($=>!$.hasAttribute("disabled")&&$.getAttribute("aria-hidden")!=="true");if(_.length===0){z.preventDefault(),A.focus({preventScroll:!0});return}const B=_[0],P=_[_.length-1],M=document.activeElement;z.shiftKey&&M===B?(z.preventDefault(),P.focus({preventScroll:!0})):!z.shiftKey&&M===P&&(z.preventDefault(),B.focus({preventScroll:!0}))};return document.addEventListener("keydown",L),()=>{window.clearTimeout(O),document.body.style.overflow=y,document.removeEventListener("keydown",L),T.current?.focus?.({preventScroll:!0}),T.current=null}},[o,n]),!n||!x.current)return null;const k=m==="dialog",S=t.jsxs("section",{ref:R,role:"dialog","aria-modal":"true","aria-label":u,tabIndex:-1,className:Z("flex flex-col bg-background text-foreground",k?"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:k?{opacity:v?1:0,transform:v?"none":"scale(0.97)",transition:`opacity ${En}ms ease-out, transform ${En}ms cubic-bezier(0.32, 0.72, 0, 1)`}:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:v?"none":h==="rtl"?"translateX(-100%)":"translateX(100%)",transition:`transform ${En}ms cubic-bezier(0.32, 0.72, 0, 1)`},onTransitionEnd:y=>{v&&y.target===y.currentTarget&&y.propertyName==="transform"&&j(!0)},children:[a?null:t.jsxs("header",{className:Z("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",!l&&"border-b border-border/70"),children:[t.jsx("button",{type:"button",className:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":p("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(H,{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:C?t.jsx("div",{className:"h-full",style:{animation:"oc-surface-content-in 200ms ease-out"},children:g}):null}),t.jsx("style",{children:"@keyframes oc-surface-content-in { from { opacity: 0 } to { opacity: 1 } }"})]});return k?vs.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:v?1:0,paddingLeft:f==="chat"?"max(1rem, var(--oc-chat-inset-left, 0px))":"1rem",paddingRight:f==="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:y=>y.stopPropagation(),children:S})}),x.current):vs.createPortal(S,x.current)},bm=n=>{const e=de.c(8),{projectPath:s}=n,{t:i}=he(),{journey:r}=Ua();let o;if(e[0]!==r||e[1]!==s||e[2]!==i){const a=r?Ga(r,s):[];let l;e[4]!==i?(l=i("mobile.projectEdit.spacesTitle"),e[4]=i,e[5]=l):l=e[5];let u;e[6]!==l?(u=t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:l}),e[6]=l,e[7]=u):u=e[7],o=t.jsxs("div",{className:"flex flex-col gap-2",children:[u,r!==null&&a.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i("spaces.page.empty")}):null,a.map(wm)]}),e[0]=r,e[1]=s,e[2]=i,e[3]=o}else o=e[3];return o},xm=n=>on(n)??"",ym=n=>{const e=de.c(38),{worktree:s,onDelete:i}=n,{t:r}=he();let o;e[0]!==s.path?(o={id:s.path},e[0]=s.path,e[1]=o):o=e[1];const{attributes:a,listeners:l,setNodeRef:u,transform:m,transition:f,isDragging:g}=Xr(o);let p;e[2]!==m?(p=Qr.Transform.toString(m),e[2]=m,e[3]=p):p=e[3];const h=g?10:1;let x;e[4]!==p||e[5]!==h||e[6]!==f?(x={transform:p,transition:f,zIndex:h},e[4]=p,e[5]=h,e[6]=f,e[7]=x):x=e[7];const v=x,b=s.branch||s.label||s.path,C=zo(s.path),j=g&&"shadow-lg shadow-black/20",R=C&&"opacity-60";let T;e[8]!==j||e[9]!==R?(T=Z("flex items-center gap-1 rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",j,R),e[8]=j,e[9]=R,e[10]=T):T=e[10];const D=C||void 0;let k;e[11]!==b||e[12]!==r?(k=r("mobile.projectEdit.dragWorktreeAria",{label:b}),e[11]=b,e[12]=r,e[13]=k):k=e[13];let S;e[14]===Symbol.for("react.memo_cache_sentinel")?(S=t.jsx($r,{className:"size-4"}),e[14]=S):S=e[14];let y;e[15]!==a||e[16]!==l||e[17]!==k?(y=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":k,...a,...l,children:S}),e[15]=a,e[16]=l,e[17]=k,e[18]=y):y=e[18];let E;e[19]!==C||e[20]!==r?(E=C?t.jsx("span",{className:"inline-flex shrink-0 text-muted-foreground",role:"status","aria-label":r("sessions.sidebar.group.worktreeRemoving"),children:t.jsx(H,{name:"loader-4",className:"size-4 animate-spin"})}):t.jsx(H,{name:"node-tree",className:"size-4 shrink-0 text-muted-foreground"}),e[19]=C,e[20]=r,e[21]=E):E=e[21];let O;e[22]!==b?(O=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:b}),e[22]=b,e[23]=O):O=e[23];let L;e[24]!==b||e[25]!==i||e[26]!==C||e[27]!==r?(L=C?null:t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive","aria-label":r("mobile.projectEdit.deleteWorktreeAria",{label:b}),onClick:i,style:{touchAction:"manipulation"},children:t.jsx(_n,{className:"size-4"})}),e[24]=b,e[25]=i,e[26]=C,e[27]=r,e[28]=L):L=e[28];let z;return e[29]!==u||e[30]!==v||e[31]!==y||e[32]!==E||e[33]!==O||e[34]!==L||e[35]!==T||e[36]!==D?(z=t.jsxs("div",{ref:u,style:v,className:T,"aria-busy":D,children:[y,E,O,L]}),e[29]=u,e[30]=v,e[31]=y,e[32]=E,e[33]=O,e[34]=L,e[35]=T,e[36]=D,e[37]=z):z=e[37],z},vm=({open:n,project:e,onClose:s,onWorktreesChanged:i})=>{const{t:r}=he(),{currentTheme:o}=Ao(),a=Fe(M=>M.isolatedSpacesEnabled),l=lt(M=>M.updateProjectMeta),u=lt(M=>M.discoverProjectIcon),m=lt(M=>M.removeProjectIcon),f=Pr(M=>M.setWorktreeOrder),g=lt(M=>e?M.projects.find($=>$.id===e.id)?.iconImage??null:null),[p,h]=c.useState(""),[x,v]=c.useState(null),[b,C]=c.useState(null),[j,R]=c.useState(!1),[T,D]=c.useState([]),[k,S]=c.useState(null),y=e?.id??null;c.useEffect(()=>{!n||!e||(h(e.label),v(e.icon??null),C(e.color??null),D(e.worktrees))},[n,y]),c.useEffect(()=>{!n||!e||D(M=>{const $=e.worktrees.map(X=>X.path),I=M.map(X=>X.path);return $.length===I.length&&$.every(X=>I.includes(X))?M:e.worktrees})},[e?.worktrees]);const E=Vr(js(Gr,{activationConstraint:{distance:8}}),js(Ur,{coordinateGetter:qr})),O=()=>{if(!e)return;const $={label:p.trim()||e.label,icon:x,color:b};b!==(e.color??null)&&($.iconBackground=kl(b)),l(e.id,$),s()},L=()=>{!e||j||(R(!0),u(e.id).then(M=>{if(!M.ok){ce.error(M.error||r("projectEditDialog.toast.failedToDiscoverIcon"));return}if(M.skipped){ce.success(r("projectEditDialog.toast.customIconAlreadySet"));return}ce.success(r("projectEditDialog.toast.iconDiscovered"))}).finally(()=>R(!1)))},z=()=>{e&&m(e.id).then(M=>{if(!M.ok){ce.error(M.error||r("projectEditDialog.toast.failedToRemoveIcon"));return}ce.success(r("projectEditDialog.toast.iconRemoved"))})},A=M=>{const{active:$,over:I}=M;if(!I||$.id===I.id||!e)return;const U=T.findIndex(se=>se.path===$.id),X=T.findIndex(se=>se.path===I.id);if(U<0||X<0)return;const Q=[...T],[ue]=Q.splice(U,1);Q.splice(X,0,ue),D(Q),f(e.id,Q.map(se=>xm(se.path)))},_=To(b),B=x?Po[x]:null,P=!!g;return t.jsxs(t.Fragment,{children:[t.jsx(Pt,{open:n,onClose:s,title:r("projectEditDialog.title"),ariaLabel:r("projectEditDialog.title"),noHeaderBorder:!0,trailing:t.jsxs(Ce,{type:"button",variant:"default",size:"sm","aria-label":r("projectEditDialog.actions.save"),onClick:O,disabled:!p.trim(),style:{touchAction:"manipulation"},children:[t.jsx(qo,{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:P?t.jsx(Do,{project:{id:e.id,iconImage:g},options:{themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},className:"size-full object-contain",fallback:t.jsx(Cr,{className:"size-7"})}):B?t.jsx(H,{name:B,className:"size-7",style:_?{color:_}:void 0}):t.jsx(Cr,{className:"size-7",style:_?{color:_}: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(Oo,{value:p,onChange:M=>h(M.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:()=>C(null),"aria-label":r("projectEditDialog.option.none"),className:Z("flex size-9 items-center justify-center rounded-xl border-2 transition-all",b===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"})}),wl.map(M=>t.jsx("button",{type:"button",onClick:()=>C(M),"aria-label":r("settings.projects.appearance.colorSwatchAria",{color:M}),title:M,className:Z("size-9 rounded-xl border-2 transition-all",b===M?"border-foreground":"border-transparent hover:border-border/70"),style:{backgroundColor:M,touchAction:"manipulation"}},M))]})]}),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:()=>v(null),"aria-label":r("projectEditDialog.option.none"),className:Z("flex size-9 items-center justify-center rounded-xl border-2 transition-all",x===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"})}),jl.map(M=>t.jsx("button",{type:"button",onClick:()=>v(M.key),"aria-label":M.label,title:M.label,className:Z("flex size-9 items-center justify-center rounded-xl border-2 transition-all",x===M.key?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx(H,{name:M.Icon,className:"size-4",style:_?{color:_}:void 0})},M.key))]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[t.jsx(Ce,{size:"sm",variant:"outline",onClick:L,disabled:j,children:r(j?"projectEditDialog.actions.discovering":"projectEditDialog.actions.discoverFavicon")}),P?t.jsx(Ce,{size:"sm",variant:"outline",onClick:z,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")}),T.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(Kr,{sensors:E,collisionDetection:Hr,onDragEnd:A,children:t.jsx(Yr,{items:T.map(M=>M.path),strategy:Jr,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:T.map(M=>t.jsx(ym,{worktree:M,onDelete:()=>S(M)},M.path))})})})]})]}):null,e.isGitRepo&&a?t.jsx(bm,{projectPath:e.path}):null]}):null}),e?t.jsx(ya,{open:!!k,project:{id:e.id,path:e.path},worktree:k,onClose:()=>S(null),onDeleted:()=>{D(M=>M.filter($=>$.path!==k?.path)),i?.()}}):null]})};function wm(n){return t.jsx(md,{entry:n,actions:"sheet"},n.id)}const jm=32,km=80,Sm=64,Nm=.7,Cm=140,Rm=.4,Em=(n,e,s)=>{const i=e.ownerDocument.defaultView;if(!i)return"drawer";let r=!1;for(let o=n instanceof i.Element?n:null;o&&o!==e;o=o.parentElement){const a=o.scrollWidth-o.clientWidth;if(a<=1)continue;const l=i.getComputedStyle(o);if(l.overflowX!=="auto"&&l.overflowX!=="scroll")continue;const u=l.direction==="rtl"?-a:0,m=u+a;if(s?o.scrollLeft>u+1:o.scrollLeft<m-1)return"content";r=!0}return r?"content-end":"drawer"},ci=(n,e)=>{const s=c.useRef(e);s.current=e;const i=e.enabled??!0;c.useEffect(()=>{if(!i)return;const r=n.current;if(!r)return;const a=window.Capacitor?.getPlatform?.()==="android"?km:jm,l=r.ownerDocument;let u=!1,m=!1,f="drawer",g=0,p=0;const h=()=>l.getSelection()?.isCollapsed===!1,x=()=>{u=!1},v=()=>{u&&h()&&x()},b=j=>{if(j.touches.length!==1||h()){u=!1;return}const R=j.touches[0],T=r.clientWidth,D=R.clientX<=a,k=R.clientX>=T-a;m=D,f=D||k?Em(j.target,r,m):"drawer",u=(D||k)&&f!=="content",g=R.clientX,p=R.clientY},C=j=>{if(!u||(u=!1,h()))return;const R=j.changedTouches[0];if(!R)return;const T=R.clientX-g,D=R.clientY-p,k=f==="content-end"?Cm:Sm,S=f==="content-end"?Rm:Nm;Math.abs(T)<k||Math.abs(D)>Math.abs(T)*S||m&&T<=0||!m&&T>=0||(m?s.current.onLeftEdgeSwipe?.():s.current.onRightEdgeSwipe?.())};return r.addEventListener("touchstart",b,{passive:!0}),r.addEventListener("touchend",C,{passive:!0}),r.addEventListener("touchcancel",x,{passive:!0}),r.addEventListener("selectstart",x),l.addEventListener("selectionchange",v),()=>{r.removeEventListener("touchstart",b),r.removeEventListener("touchend",C),r.removeEventListener("touchcancel",x),r.removeEventListener("selectstart",x),l.removeEventListener("selectionchange",v)}},[i,n])},Im=()=>globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0;function In(n){const e=de.c(11),{open:s,children:i}=n,[r,o]=c.useState(s);s&&!r&&o(!0);const a=c.useRef(null),l=c.useRef(null),u=c.useRef(s);let m,f;e[0]!==s?(m=()=>{const C=a.current;if(u.current===s||!C)return;if(u.current=s,Im()){s||o(!1);return}const j=l.current||!s?C.getBoundingClientRect().height:0;l.current?.cancel();const R=s?C.scrollHeight:0;C.style.overflow="hidden";const T=C.animate([{height:`${j}px`,opacity:s?0:1},{height:`${R}px`,opacity:s?1:0}],{duration:Qc,easing:Xc,fill:s?"none":"forwards"});l.current=T,T.finished.then(()=>{l.current===T&&(l.current=null,s?C.style.overflow="":o(!1))},Am)},f=[s],e[0]=s,e[1]=m,e[2]=f):(m=e[1],f=e[2]),c.useLayoutEffect(m,f);let g,p;if(e[3]===Symbol.for("react.memo_cache_sentinel")?(g=()=>()=>l.current?.cancel(),p=[],e[3]=g,e[4]=p):(g=e[3],p=e[4]),c.useEffect(g,p),!r)return null;const h=!s||void 0,x=!s;let v;e[5]!==i?(v=i(),e[5]=i,e[6]=v):v=e[6];let b;return e[7]!==h||e[8]!==x||e[9]!==v?(b=t.jsx("div",{ref:a,"aria-hidden":h,inert:x,children:v}),e[7]=h,e[8]=x,e[9]=v,e[10]=b):b=e[10],b}function Am(){}const Pm=new Set,Tm=[["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"]],Dm=[["projects","mobile.sessions.viewMode.projects"],["timeline","mobile.sessions.viewMode.timeline"]],Hs=7,_m=3,Mm=32,ui=n=>Mm+n*12,Vn=n=>ui(n)+20,xr="openchamber:work",yr=12,Om=(n,e)=>{const s=Ve(n),i=Ve(e),r=i.endsWith("/")?i:`${i}/`;return!!(s&&i&&(s===i||s.startsWith(r)))},vr=(n,e)=>n.worktrees.find(s=>Ve(s.path)===e)??null,wr=(n,e,s)=>Bo([n.title,n.id,kt(n),e],s),zm=n=>{const e=de.c(3),{path:s,children:i}=n,r=zo(s);let o;return e[0]!==i||e[1]!==r?(o=i(r),e[0]=i,e[1]=r,e[2]=o):o=e[2],o},Bm=n=>{const e=de.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},Xi=n=>{const e=de.c(12),{onClick:s,className:i}=n,{t:r}=he();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 l;e[2]!==i?(l=Z("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]=l):l=e[3];let u;e[4]!==s?(u=p=>{p.stopPropagation(),s()},e[4]=s,e[5]=u):u=e[5];let m,f;e[6]===Symbol.for("react.memo_cache_sentinel")?(m={touchAction:"manipulation"},f=t.jsx(H,{name:"node-tree",className:"size-3.5"}),e[6]=m,e[7]=f):(m=e[6],f=e[7]);let g;return e[8]!==a||e[9]!==l||e[10]!==u?(g=t.jsx("button",{type:"button",className:l,"aria-label":a,title:a,onClick:u,style:m,children:f}),e[8]=a,e[9]=l,e[10]=u,e[11]=g):g=e[11],g},jr=n=>{const e=de.c(10),{label:s,onClick:i,className:r}=n;let o;e[0]!==r?(o=Z("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=f=>{f.stopPropagation(),i()},e[2]=i,e[3]=a):a=e[3];let l,u;e[4]===Symbol.for("react.memo_cache_sentinel")?(l={touchAction:"manipulation"},u=t.jsx(H,{name:"add",className:"size-4"}),e[4]=l,e[5]=u):(l=e[4],u=e[5]);let m;return e[6]!==s||e[7]!==o||e[8]!==a?(m=t.jsx("button",{type:"button",className:o,"aria-label":s,title:s,onClick:a,style:l,children:u}),e[6]=s,e[7]=o,e[8]=a,e[9]=m):m=e[9],m},Qi=n=>{const e=de.c(95),{session:s,active:i,indent:r,contextLabel:o,statusOnRight:a,treeDepth:l,hasChildren:u,expanded:m,onToggleChildren:f,onSelect:g,revealed:p,onRevealedChange:h,confirmingDelete:x,onArchive:v,onRequestDelete:b,onConfirmDelete:C,renaming:j,onRequestRename:R,onSubmitRename:T,onCancelRename:D,work:k,pin:S,descendantIdsOf:y}=n,E=a===void 0?!1:a,O=u===void 0?!1:u,L=m===void 0?!1:m,z=p===void 0?!1:p,A=x===void 0?!1:x,_=j===void 0?!1:j,{t:B}=he();let P;e[0]!==s?(P=qn(ka(s)),e[0]=s,e[1]=P):P=e[1];const M=P;let $;e[2]!==s.title||e[3]!==B?($=s.title?.trim()||B("mobile.sessions.untitled"),e[2]=s.title,e[3]=B,e[4]=$):$=e[4];const I=$,U=!!(h&&v),X=l!==void 0,Q=E||X;let ue;e[5]!==r||e[6]!==X||e[7]!==l?(ue=X?Vn(l):r,e[5]=r,e[6]=X,e[7]=l,e[8]=ue):ue=e[8];const se=ue,te=Go(s.id,s.directory,U&&(z||_)),ge=Mr(s.id),ee=Or(s.id),G=ee!==null,N=!G&&ge>0&&!i,Y=zr(s.id,G),ne=(G||N)&&Y;let re;e[9]!==G||e[10]!==s||e[11]!==k?.inWork?(re=!!k?.inWork&&!G&&Pl(s),e[9]=G,e[10]=s,e[11]=k?.inWork,e[12]=re):re=e[12];const K=re;let oe;e[13]!==y||e[14]!==L||e[15]!==O||e[16]!==s.id?(oe=y&&!(O&&L)?[s.id,...y(s.id)]:[s.id],e[13]=y,e[14]=L,e[15]=O,e[16]=s.id,e[17]=oe):oe=e[17];const Se=Ra(oe);let we;e[18]!==L||e[19]!==O||e[20]!==X||e[21]!==f||e[22]!==B||e[23]!==l?(we=X&&O&&f?t.jsx("button",{type:"button",className:"absolute z-10 flex w-[30px] items-center justify-center text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:{insetInlineStart:ui(l)-8,top:0,bottom:0,touchAction:"manipulation"},"aria-label":B(L?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),"aria-expanded":L,onClick:Re=>{Re.stopPropagation(),f()},children:t.jsx(Ho,{expanded:L})}):null,e[18]=L,e[19]=O,e[20]=X,e[21]=f,e[22]=B,e[23]=l,e[24]=we):we=e[24];let xe;e[25]!==te||e[26]!==L||e[27]!==O||e[28]!==r||e[29]!==G||e[30]!==f||e[31]!==N||e[32]!==Q||e[33]!==B||e[34]!==ee?(xe=!Q&&(te.pending||G||N||O&&f)?t.jsx("button",{type:"button",className:"absolute z-10 flex w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:{insetInlineStart:Math.max(r-32,2),top:0,bottom:0,touchAction:"manipulation"},"aria-label":te.pending?B("sessions.aiRename.generating"):B(L?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),disabled:!O||!f,onClick:Re=>{Re.stopPropagation(),f?.()},children:te.pending?t.jsx(H,{name:"loader-4",className:"size-3 animate-spin text-primary","aria-label":B("sessions.aiRename.generating")}):G||N?t.jsx(Dn,{state:ee??"unread"}):t.jsx(Wr,{className:Z("size-[18px] transition-transform duration-150",L?"rotate-0":"-rotate-90 rtl:rotate-90")})}):null,e[25]=te,e[26]=L,e[27]=O,e[28]=r,e[29]=G,e[30]=f,e[31]=N,e[32]=Q,e[33]=B,e[34]=ee,e[35]=xe):xe=e[35];let ye;e[36]!==i||e[37]!==te||e[38]!==o||e[39]!==G||e[40]!==D||e[41]!==h||e[42]!==g||e[43]!==T||e[44]!==Se||e[45]!==S?.pinned||e[46]!==_||e[47]!==z||e[48]!==s||e[49]!==ne||e[50]!==K||e[51]!==N||e[52]!==Q||e[53]!==B||e[54]!==se||e[55]!==M||e[56]!==I||e[57]!==ee?(ye=_&&T&&D?t.jsx(va,{initialTitle:I,indent:se,aiRename:te,onSubmit:T,onCancel:D}):t.jsx("button",{type:"button",className:Z("flex min-w-0 flex-1 items-center gap-2.5 pe-3.5 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",o?"min-h-10 py-1":"h-9"),style:{paddingInlineStart:se,touchAction:"manipulation"},onClick:()=>{if(z){h?.(!1);return}g()},children:t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[t.jsxs("span",{className:"flex items-center gap-2.5",children:[t.jsx("span",{dir:"auto",className:Z("block min-w-0 flex-1 truncate oc-ui-start-align typography-ui-label",i?"text-primary":"text-foreground"),children:I}),S?.pinned?t.jsx(H,{name:"pushpin",className:"size-3 shrink-0 text-muted-foreground","aria-label":B("sessions.sidebar.session.status.pinned")}):null,Q&&(te.pending||G||N)?te.pending?t.jsx(H,{name:"loader-4",className:"size-3 shrink-0 animate-spin text-primary","aria-label":B("sessions.aiRename.generating")}):t.jsx(Dn,{state:ee??"unread"}):null,K?t.jsx(H,{name:"check",className:"size-3.5 shrink-0 text-muted-foreground","aria-label":B("sessions.sidebar.session.work.doneSuggested")}):null,t.jsx(Na,{session:s}),t.jsx(Ca,{...Se}),ne?t.jsx(Br,{sessionId:s.id,running:G,className:"typography-micro"}):M?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:M}):null]}),o?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:o}):null]})}),e[36]=i,e[37]=te,e[38]=o,e[39]=G,e[40]=D,e[41]=h,e[42]=g,e[43]=T,e[44]=Se,e[45]=S?.pinned,e[46]=_,e[47]=z,e[48]=s,e[49]=ne,e[50]=K,e[51]=N,e[52]=Q,e[53]=B,e[54]=se,e[55]=M,e[56]=I,e[57]=ee,e[58]=ye):ye=e[58];let De;e[59]!==we||e[60]!==xe||e[61]!==ye?(De=t.jsxs(t.Fragment,{children:[we,xe,ye]}),e[59]=we,e[60]=xe,e[61]=ye,e[62]=De):De=e[62];const Te=De;if(!U){const Re=i||void 0,Le=i&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let He;e[63]!==Le?(He=Z("relative flex items-center gap-1 transition-colors",Le),e[63]=Le,e[64]=He):He=e[64];let $e;e[65]!==Te||e[66]!==He?($e=t.jsx("div",{className:He,children:Te}),e[65]=Te,e[66]=He,e[67]=$e):$e=e[67];let tt;return e[68]!==Re||e[69]!==$e?(tt=t.jsx("div",{"data-active-session":Re,className:"relative overflow-hidden",children:$e}),e[68]=Re,e[69]=$e,e[70]=tt):tt=e[70],tt}const ve=wa+(k?sn:0)+(S?sn:0);let Ne;e[71]!==h?(Ne=Re=>h?.(Re),e[71]=h,e[72]=Ne):Ne=e[72];const q=i&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let pe;e[73]!==q?(pe=Z("relative flex w-full items-center gap-1 bg-background transition-colors",q),e[73]=q,e[74]=pe):pe=e[74];let Ae;e[75]!==A||e[76]!==v||e[77]!==C||e[78]!==b||e[79]!==R||e[80]!==h||e[81]!==S||e[82]!==z||e[83]!==s.id||e[84]!==I||e[85]!==k?(Ae=t.jsx(ja,{sessionId:s.id,title:I,revealed:z,confirmingDelete:A,onArchive:v,onRequestDelete:b,onConfirmDelete:C,onRequestRename:R,onRevealedChange:h,work:k,pin:S}),e[75]=A,e[76]=v,e[77]=C,e[78]=b,e[79]=R,e[80]=h,e[81]=S,e[82]=z,e[83]=s.id,e[84]=I,e[85]=k,e[86]=Ae):Ae=e[86];let We;return e[87]!==i||e[88]!==z||e[89]!==Te||e[90]!==ve||e[91]!==Ne||e[92]!==pe||e[93]!==Ae?(We=t.jsx(Wn,{actionsWidth:ve,revealed:z,onRevealedChange:Ne,dataActiveSession:i,contentClassName:pe,actions:Ae,children:Te}),e[87]=i,e[88]=z,e[89]=Te,e[90]=ve,e[91]=Ne,e[92]=pe,e[93]=Ae,e[94]=We):We=e[94],We},Zi=[],Lm=n=>{const e=de.c(41),{run:s,laneNodes:i,depth:r}=n,{t:o}=he();let a;e[0]!==s.key?(a=z=>z.runOverviewKey===s.key,e[0]=s.key,e[1]=a):a=e[1];const l=Fe(a);let u;e[2]!==i?(u={nodes:i,includeUnreadSubtasks:!1},e[2]=i,e[3]=u):u=e[3];const m=Uo(u);let f;e[4]!==s.lastActivity?(f=qn(s.lastActivity),e[4]=s.lastActivity,e[5]=f):f=e[5];const g=f,p=l||void 0,h=l&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let x;e[6]!==h?(x=Z("relative flex items-center overflow-hidden transition-colors",h),e[6]=h,e[7]=x):x=e[7];let v;e[8]!==r?(v=Vn(r),e[8]=r,e[9]=v):v=e[9];let b;e[10]!==v?(b={paddingInlineStart:v,touchAction:"manipulation"},e[10]=v,e[11]=b):b=e[11];let C;e[12]!==s.key?(C=()=>Fe.getState().setRunOverviewKey(s.key),e[12]=s.key,e[13]=C):C=e[13];let j;e[14]!==s.title||e[15]!==o?(j=o("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[14]=s.title,e[15]=o,e[16]=j):j=e[16];let R;e[17]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx(Mo,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[17]=R):R=e[17];const T=l?"text-primary":"text-foreground";let D;e[18]!==T?(D=Z("block min-w-0 flex-1 truncate oc-ui-start-align typography-ui-label",T),e[18]=T,e[19]=D):D=e[19];let k;e[20]!==s.title||e[21]!==D?(k=t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[R,t.jsx("span",{dir:"auto",className:D,children:s.title})]}),e[20]=s.title,e[21]=D,e[22]=k):k=e[22];let S;e[23]!==s.providerIDs?(S=t.jsx(Sa,{providerIDs:s.providerIDs}),e[23]=s.providerIDs,e[24]=S):S=e[24];let y;e[25]!==m?(y=m?t.jsx(Ko,{state:m}):null,e[25]=m,e[26]=y):y=e[26];let E;e[27]!==g?(E=g?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:g}):null,e[27]=g,e[28]=E):E=e[28];let O;e[29]!==j||e[30]!==k||e[31]!==S||e[32]!==y||e[33]!==E||e[34]!==b||e[35]!==C?(O=t.jsxs("button",{type:"button",className:"flex h-9 w-full min-w-0 items-center gap-2.5 pe-3.5 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:b,onClick:C,"aria-label":j,children:[k,S,y,E]}),e[29]=j,e[30]=k,e[31]=S,e[32]=y,e[33]=E,e[34]=b,e[35]=C,e[36]=O):O=e[36];let L;return e[37]!==O||e[38]!==p||e[39]!==x?(L=t.jsx("div",{"data-active-session":p,className:x,children:O}),e[37]=O,e[38]=p,e[39]=x,e[40]=L):L=e[40],L},eo=n=>{const e=de.c(11),{indent:s,onClick:i}=n,{t:r}=he();let o;e[0]!==s?(o={paddingInlineStart: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(Wr,{className:"size-4"}),e[2]=a):a=e[2];let l;e[3]!==r?(l=r("sessions.sidebar.group.showMore"),e[3]=r,e[4]=l):l=e[4];let u;e[5]!==l?(u=t.jsx("span",{className:"typography-micro",children:l}),e[5]=l,e[6]=u):u=e[6];let m;return e[7]!==i||e[8]!==o||e[9]!==u?(m=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pe-3 text-start text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:o,onClick:i,children:[a,u]}),e[7]=i,e[8]=o,e[9]=u,e[10]=m):m=e[10],m},to=n=>{const e=de.c(11),{indent:s,onClick:i}=n,{t:r}=he();let o;e[0]!==s?(o={paddingInlineStart: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(rd,{className:"size-4"}),e[2]=a):a=e[2];let l;e[3]!==r?(l=r("sessions.sidebar.group.showFewer"),e[3]=r,e[4]=l):l=e[4];let u;e[5]!==l?(u=t.jsx("span",{className:"typography-micro",children:l}),e[5]=l,e[6]=u):u=e[6];let m;return e[7]!==i||e[8]!==o||e[9]!==u?(m=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pe-3 text-start text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:o,onClick:i,children:[a,u]}),e[7]=i,e[8]=o,e[9]=u,e[10]=m):m=e[10],m},Fm=n=>{const e=de.c(29),{worktree:s}=n,{t:i}=he();let r;e[0]!==s.path?(r=Ve(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:l,listeners:u,setNodeRef:m,transform:f,transition:g,isDragging:p}=Xr(a),h=s.branch||s.label||s.path;let x;e[4]!==f?(x=Qr.Transform.toString(f),e[4]=f,e[5]=x):x=e[5];const v=p?10:1;let b;e[6]!==x||e[7]!==v||e[8]!==g?(b={transform:x,transition:g,zIndex:v},e[6]=x,e[7]=v,e[8]=g,e[9]=b):b=e[9];const C=p&&"shadow-lg shadow-black/20";let j;e[10]!==C?(j=Z("flex items-center gap-1 rounded-xl bg-background px-1 py-1",C),e[10]=C,e[11]=j):j=e[11];let R;e[12]!==h||e[13]!==i?(R=i("mobile.sessions.dragHandleAria",{label:h}),e[12]=h,e[13]=i,e[14]=R):R=e[14];let T;e[15]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx($r,{className:"size-4"}),e[15]=T):T=e[15];let D;e[16]!==l||e[17]!==u||e[18]!==R?(D=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":R,...l,...u,children:T}),e[16]=l,e[17]=u,e[18]=R,e[19]=D):D=e[19];let k;e[20]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx(H,{name:"git-branch",className:"size-4 shrink-0 text-muted-foreground"}),e[20]=k):k=e[20];let S;e[21]!==h?(S=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]=S):S=e[22];let y;return e[23]!==m||e[24]!==D||e[25]!==S||e[26]!==b||e[27]!==j?(y=t.jsxs("div",{ref:m,style:b,className:j,children:[D,k,S]}),e[23]=m,e[24]=D,e[25]=S,e[26]=b,e[27]=j,e[28]=y):y=e[28],y},$m=n=>{const e=de.c(58),{project:s,expanded:i,onToggleExpanded:r,onReorderWorktrees:o}=n,{t:a}=he();let l;e[0]!==s.id?(l={id:s.id},e[0]=s.id,e[1]=l):l=e[1];const{attributes:u,listeners:m,setNodeRef:f,transform:g,transition:p,isDragging:h}=Xr(l);let x;e[2]===Symbol.for("react.memo_cache_sentinel")?(x={activationConstraint:{distance:8}},e[2]=x):x=e[2];let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v={coordinateGetter:qr},e[3]=v):v=e[3];const b=Vr(js(Gr,x),js(Ur,v)),C=s.worktrees.length>0;let j;e[4]!==o||e[5]!==s.worktrees?(j=Q=>{const{active:ue,over:se}=Q;if(!se||ue.id===se.id)return;const te=s.worktrees.map(Gm),ge=te.indexOf(String(ue.id)),ee=te.indexOf(String(se.id));if(ge<0||ee<0)return;const G=[...te],[N]=G.splice(ge,1);G.splice(ee,0,N),o(G)},e[4]=o,e[5]=s.worktrees,e[6]=j):j=e[6];const R=j;let T;e[7]!==g?(T=Qr.Transform.toString(g),e[7]=g,e[8]=T):T=e[8];const D=h?10:1;let k;e[9]!==T||e[10]!==D||e[11]!==p?(k={transform:T,transition:p,zIndex:D},e[9]=T,e[10]=D,e[11]=p,e[12]=k):k=e[12];const S=h&&"shadow-lg shadow-black/20";let y;e[13]!==S?(y=Z("rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",S),e[13]=S,e[14]=y):y=e[14];let E;e[15]!==s.label||e[16]!==a?(E=a("mobile.sessions.dragHandleAria",{label:s.label}),e[15]=s.label,e[16]=a,e[17]=E):E=e[17];let O;e[18]===Symbol.for("react.memo_cache_sentinel")?(O=t.jsx($r,{className:"size-4"}),e[18]=O):O=e[18];let L;e[19]!==u||e[20]!==m||e[21]!==E?(L=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":E,...u,...m,children:O}),e[19]=u,e[20]=m,e[21]=E,e[22]=L):L=e[22];let z;e[23]!==i||e[24]!==s.label||e[25]!==a?(z=i?a("sessions.sidebar.group.collapseAria",{label:s.label}):a("sessions.sidebar.group.expandAria",{label:s.label}),e[23]=i,e[24]=s.label,e[25]=a,e[26]=z):z=e[26];const A=!C;let _;e[27]===Symbol.for("react.memo_cache_sentinel")?(_={touchAction:"manipulation"},e[27]=_):_=e[27];let B;e[28]!==s?(B=t.jsx($n,{project:s}),e[28]=s,e[29]=B):B=e[29];let P;e[30]!==s.label?(P=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]=P):P=e[31];let M;e[32]!==i||e[33]!==C?(M=C?t.jsx(Wr,{className:Z("size-4 shrink-0 text-muted-foreground transition-transform",i&&"rotate-180")}):null,e[32]=i,e[33]=C,e[34]=M):M=e[34];let $;e[35]!==i||e[36]!==r||e[37]!==z||e[38]!==A||e[39]!==B||e[40]!==P||e[41]!==M?($=t.jsxs("button",{type:"button",className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 rounded-xl px-1 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:r,"aria-expanded":i,"aria-label":z,disabled:A,style:_,children:[B,P,M]}),e[35]=i,e[36]=r,e[37]=z,e[38]=A,e[39]=B,e[40]=P,e[41]=M,e[42]=$):$=e[42];let I;e[43]!==L||e[44]!==$?(I=t.jsxs("div",{className:"flex items-center gap-1",children:[L,$]}),e[43]=L,e[44]=$,e[45]=I):I=e[45];let U;e[46]!==i||e[47]!==R||e[48]!==C||e[49]!==s.worktrees||e[50]!==b?(U=i&&C?t.jsx(Kr,{sensors:b,collisionDetection:Hr,onDragEnd:R,children:t.jsx(Yr,{items:s.worktrees.map(Km),strategy:Jr,children:t.jsx("div",{className:"mt-1 flex flex-col gap-0.5 ps-3",children:s.worktrees.map(Hm)})})}):null,e[46]=i,e[47]=R,e[48]=C,e[49]=s.worktrees,e[50]=b,e[51]=U):U=e[51];let X;return e[52]!==f||e[53]!==I||e[54]!==U||e[55]!==k||e[56]!==y?(X=t.jsxs("div",{ref:f,style:k,className:y,children:[I,U]}),e[52]=f,e[53]=I,e[54]=U,e[55]=k,e[56]=y,e[57]=X):X=e[57],X},so=({open:n,onOpenChange:e,variant:s="drawer",footer:i})=>{const{t:r}=he(),{git:o}=Un(),a=at(d=>d.ensureStatus),l=Eo(),u=bs(d=>d.activeSessions),m=n||s==="sidebar",f=c.useRef(Pm),g=Sr(c.useCallback(d=>(m&&(f.current=d.ids),f.current),[m])),p=c.useRef(Sl),h=wo(c.useCallback(d=>(m&&(p.current=d.rankById),p.current),[m])),x=lt(d=>d.projects),v=Nl(d=>d.projects),b=lt(d=>d.activeProjectId),C=zt(d=>d.currentDirectory),j=Oe(d=>d.currentSessionId),R=Oe(d=>d.setCurrentSession),T=Oe(d=>d.archiveSession),D=Oe(d=>d.archiveSessions),k=Oe(d=>d.deleteSession),S=Oe(d=>d.deleteSessions),y=Oe(d=>d.updateSessionTitle),E=Oe(d=>d.openNewSessionDraft),O=lt(d=>d.setActiveProject),L=lt(d=>d.setActiveProjectIdOnly),z=lt(d=>d.reorderProjects),A=lt(d=>d.manualProjectOrder),_=us(d=>d.projectSortOrder),B=us(d=>d.setProjectSortOrder),P=us(d=>d.sidebarViewMode),M=P==="timeline"?"manual":_,$=us(d=>d.setSidebarViewMode),I=us(d=>d.showWorkSection),U=us(d=>d.setShowWorkSection),X=Sr(d=>d.toggle),Q=Cl(m),ue=lt(d=>d.removeProject),se=Rn(d=>d.projectExpanded),te=Rn(d=>d.worktreeExpanded),ge=Rn(d=>d.setProjectExpanded),ee=Rn(d=>d.setWorktreeExpanded),G=Pr(d=>d.orderByProject),N=Pr(d=>d.setWorktreeOrder),Y=Hi(d=>d.expandedParents),ne=Hi(d=>d.toggleParent),[re,K]=c.useState(""),[oe,fe]=c.useState(null),[Se,we]=c.useState(null),[xe,ye]=c.useState(null),[De,Te]=c.useState(null),[ve,Ne]=c.useState(null),[q,pe]=c.useState(null),[Ae,We]=c.useState(null),[Re,Le]=c.useState(0),[He,$e]=c.useState(!1),[tt,mt]=c.useState(!1),[wt,Es]=c.useState(!1),[Is,an]=c.useState(null),[ln,As]=c.useState(()=>new Map(Oe.getState().availableWorktreesByProject)),[rt,Ct]=c.useState(()=>{const d=new Set;for(const[F,V]of Oe.getState().availableWorktreesByProject)V.length>0&&d.add(F);return d}),[Ue,Rt]=c.useState(!1),[Yn,ts]=c.useState(new Set),[cn,Bt]=c.useState(new Map),un=c.useRef(null);c.useEffect(()=>{if(!n){K(""),Rt(!1),ts(new Set),Bt(new Map),fe(null),we(null),ye(null),Te(null),Ne(null),pe(null);return}Co(l)},[n]),c.useEffect(()=>{Ue||ts(new Set)},[Ue]),c.useEffect(()=>{Bt(new Map)},[P]),c.useEffect(()=>{if(!n||x.length===0)return;let d=!1;return(async()=>{const V=await Promise.all(x.map(async J=>{const ae=Ve(J.path);if(!ae)return null;const me=await o.checkIsGitRepository(ae).catch(()=>null),le=me?await Lo({id:J.id,path:ae}).catch(()=>null):[];return[ae,le,me]}));d||(As(J=>{const ae=new Map;for(const me of V){if(!me)continue;const[le,Ye,Qe]=me,Mt=Qe===null||Ye===null;ae.set(le,Mt?J.get(le)??[]:Ye)}return Fo(x,ae)}),Ct(J=>{const ae=new Set;for(const me of V){if(!me)continue;const[le,,Ye]=me;(Ye===null?J.has(le):Ye)&&ae.add(le)}return ae}))})(),()=>{d=!0}},[o,n,x,Re]);const Ie=c.useMemo(()=>Zc(x.map(d=>({id:d.id,label:d.label?.trim()||gr(d.path),path:Ve(d.path),icon:d.icon,color:d.color,iconImage:d.iconImage,iconBackground:d.iconBackground,isGitRepo:rt.has(Ve(d.path)),worktrees:am(G[d.id],ln.get(Ve(d.path))??[]),addedAt:d.addedAt,lastOpenedAt:d.lastOpenedAt})),M,A),[rt,A,M,x,G,ln]),Ge=c.useMemo(()=>{const d=[...u],F=new Set(d.map(V=>V.id));for(const V of l)F.has(V.id)||(F.add(V.id),d.push(V));return d.filter(V=>!V.time?.archived)},[u,l]),_e=c.useMemo(()=>{const d=new Map;for(const F of Ge){const V=vt(F);if(!V)continue;const J=d.get(V)??[];J.push(F),d.set(V,J)}return d},[Ge]),dn=c.useCallback(d=>dr(_e,d),[_e]),{projectSessions:ct,chatSessions:Ze}=c.useMemo(()=>eu(Ge,!1),[Ge]),pt=Fe(d=>d.sessionWorkEnabled),ze=c.useMemo(()=>{const d=new Set;if(!pt||!I)return d;for(const F of Ge)if(!(vt(F)||cr(kt(F))||!_o(F))){d.add(F.id);for(const V of dr(_e,F.id))d.add(V)}return d},[_e,pt,Ge,I]),ss=c.useMemo(()=>ze.size>0?Ze.filter(d=>!ze.has(d.id)):Ze,[Ze,ze]),Be=Ka(),ns=c.useMemo(()=>new Map(Be.map(d=>[d.id,d])),[Be]),Ps=c.useMemo(()=>new Map(Be.map(d=>[d.id,d.name||r("sessions.sidebar.grouping.spaceUnnamed")])),[Be,r]),st=c.useMemo(()=>fd(ct,Ie.map(d=>({id:d.id,normalizedPath:d.path})),new Map(Ie.map(d=>[d.path,d.worktrees])),!1,[],v,Be),[v,ct,Ie,Be]),ht=c.useMemo(()=>Rl(ct,d=>{const F=st.bySessionId.get(d.id);return(F?Ie.find(J=>J.id===F.projectId):void 0)?.path||Ve(kt(d))||null}),[ct,Ie,st]),Ts=c.useMemo(()=>{const d=new Map(Ge.map(J=>[J.id,J])),F=J=>({session:J,children:(_e.get(J.id)??[]).map(F),worktree:null}),V=new Map;for(const J of ht.runs.values())V.set(J.key,J.memberIds.flatMap(ae=>{const me=d.get(ae);return me?[F(me)]:[]}));return V},[_e,ht,Ge]),rs=c.useMemo(()=>({key:Vs,label:"",path:"",worktree:null,space:null,sessions:Us(ss,g,h)}),[g,ss,h]),nt=c.useMemo(()=>new Set(rs.sessions.filter(d=>Ni(g,kt(d)||null,d.id)).map(d=>d.id)),[rs,g]),gt=c.useMemo(()=>({key:xr,label:"",path:"",worktree:null,space:null,sessions:ze.size>0?Us(Ge.filter(d=>ze.has(d.id)),g,h):[]}),[g,h,Ge,ze]),Jn=`${Vs}::${Vs}`,fn=c.useMemo(()=>ss.filter(d=>!vt(d)).length,[ss]),be=re.trim().toLowerCase(),Lt=c.useRef(null);c.useEffect(()=>{if(!n)return;const d=window.requestAnimationFrame(()=>{const F=Lt.current;if(!F)return;(F.querySelector('[data-active-session="true"]')??F.querySelector('[data-active-project="true"]'))?.scrollIntoView({block:"center"})});return()=>window.cancelAnimationFrame(d)},[n]);const Dt=c.useMemo(()=>{const d=tu(Ie,M,V=>V.id,st.sessionsByProject).map(V=>({project:V,buckets:[],isActive:V.id===b})),F=(V,J,ae,me=null)=>{const le=Ve(J)||V.project.path,Ye=le||"__root__";let Qe=V.buckets.find(Mt=>Mt.key===Ye);return Qe||(Qe={key:Ye,label:(me?me.name||r("sessions.sidebar.grouping.spaceUnnamed"):null)||ae?.branch||gr(le),path:le,worktree:ae,space:me,sessions:[]},V.buckets.push(Qe)),Qe};for(const V of d){F(V,V.project.path,null);for(const J of V.project.worktrees)F(V,J.path,J);for(const J of Be)J.directory&&Ve(J.projectDirectory)===Ve(V.project.path)&&F(V,J.directory,null,J)}for(const V of ct){const J=st.bySessionId.get(V.id);if(!J)continue;const ae=d.find(Qe=>Qe.project.id===J.projectId);if(!ae)continue;const me=vr(ae.project,J.scopeDirectory),le=J.kind==="space"&&J.spaceId?ns.get(J.spaceId)??null:null;(le?F(ae,J.scopeDirectory,null,le):me&&!ht.runKeyBySessionId.has(V.id)?F(ae,me.path,me):F(ae,ae.project.path,null)).sessions.push(V)}for(const V of d)for(const J of V.buckets)J.sessions=Us(J.sessions,g,h);return d},[b,g,M,Ie,ht,ct,h,st,Be,ns,r]),is=Ve(C),bt=d=>d.isActive?is===d.project.path?d.project.path:d.project.worktrees.find(V=>Om(is,V.path))?.path??d.project.path:null,Xn=d=>se[d.project.id]??!0,Qn=(d,F)=>F.sessions.length===0||(te[`${d.project.id}::${F.key}`]??!0);c.useEffect(()=>{if(m)for(const d of Dt)for(const F of d.buckets){const V=`${d.project.id}::${F.key}`;F.sessions.length===0&&te[V]===!1&&ee(V,!0)}},[m,Dt,ee,te]);const Ds=d=>{Bt(F=>{if(!F.has(d))return F;const V=new Map(F);return V.delete(d),V})},Zn=d=>{Bt(F=>{let V=!1;const J=new Map(F),ae=`${d}::`;for(const me of J.keys())me.startsWith(ae)&&(J.delete(me),V=!0);return V?J:F})},it=(d,F,V)=>{Bt(J=>{const ae=new Map(J);return ae.set(d,F+V),ae})},Ft=(d,F,V,J)=>{const ae=J?.pageSize??Hs,me=V===null?yr:Vn(V),le=J?.alwaysVisibleIds,Ye=new Set(F.sessions.map(ke=>ke.id)),Qe=new Map;for(const ke of F.sessions){const et=vt(ke);if(et&&Ye.has(et)){const It=Qe.get(et)??[];It.push(ke),Qe.set(et,It)}}const Mt=F.sessions.filter(ke=>{const et=vt(ke);return!et||!Ye.has(et)}),qt=new Set,$s=Mt.flatMap(ke=>{const et=ht.runKeyBySessionId.get(ke.id),It=et?ht.runs.get(et):void 0;return It?qt.has(It.key)?[]:(qt.add(It.key),[{kind:"run",run:It}]):[{kind:"session",session:ke}]}),fi=ke=>ke.kind==="session"&&!!le?.has(ke.session.id),Da=le?$s.filter(fi):[],or=le?$s.filter(ke=>!fi(ke)):$s,_a=cn.get(d)??ae,ar=or.slice(0,_a),Ma=[...Da,...ar],mi=or.length-ar.length,Oa=or.length>ae&&mi===0,pi=(ke,et)=>{const It=Qe.get(ke.id)??[],lr=It.length>0,hi=et!==null&&!!Y[ke.id];return t.jsxs(c.Fragment,{children:[t.jsx(Qi,{session:ke,active:j===ke.id,indent:yr,treeDepth:et??void 0,statusOnRight:et===null,hasChildren:lr,expanded:hi,onToggleChildren:lr?()=>ne(ke.id):void 0,onSelect:()=>Ms(ke),revealed:Se===ke.id,onRevealedChange:Ws=>$t(ke.id,Ws),confirmingDelete:xe===ke.id,onArchive:()=>{xt(ke)},onRequestDelete:()=>ye(ke.id),onConfirmDelete:()=>{hn(ke)},renaming:De===ke.id,onRequestRename:()=>gn(ke.id),onSubmitRename:Ws=>{Wt(ke.id,Ws)},onCancelRename:()=>Te(null),work:er(ke),pin:qe(ke),descendantIdsOf:dn}),lr&&hi&&et!==null?It.map(Ws=>pi(Ws,et+1)):null]},ke.id)};return t.jsxs("div",{children:[Ma.map(ke=>ke.kind==="run"?t.jsx(Lm,{run:ke.run,laneNodes:Ts.get(ke.run.key)??Zi,depth:V??0},`run:${ke.run.key}`):pi(ke.session,V)),mi>0?t.jsx(eo,{indent:me,onClick:()=>it(d,ar.length,Hs)}):null,Oa?t.jsx(to,{indent:me,onClick:()=>Ds(d)}):null]})},os=(d,F)=>{ge(d,!F),Zn(d)},_s=(d,F,V)=>{ee(`${d}::${F}`,!V),Ds(`${d}::${F}`)},Ms=d=>{const F=kt(d)||null,V=st.bySessionId.get(d.id),J=V?Ie.find(ae=>ae.id===V.projectId)??null:null;if(J){L(J.id),ge(J.id,!0);const ae=vr(J,V?.scopeDirectory??"");ae&&ee(`${J.id}::${Ve(ae.path)}`,!0)}R(d.id,F),e(!1)},$t=(d,F)=>{we(F?d:null),ye(null),Ne(null),pe(null)},jt=(d,F)=>{Ne(F?d:null),pe(null),we(null),ye(null)},ot=(d,F)=>(we(null),ye(null),ou(d,F,au(F.id,dr(_e,F.id),d==="delete"),{archiveSession:T,archiveSessions:D,deleteSession:k,deleteSessions:S},r)),xt=d=>ot("archive",d),as=async(d,F)=>{try{await Tl(d.id,kt(d)||null,F?"done":"open")}catch{ce.error(r("sessions.sidebar.session.work.updateFailed"))}},er=d=>{if(!pt||vt(d)||cr(kt(d)))return;const F=ze.has(d.id);return{inWork:F,onToggle:()=>{as(d,F)}}},mn=d=>Ni(g,kt(d)||null,d.id),pn=d=>{const F=kt(d);F&&X({directory:F,sessionId:d.id})},qe=d=>{if(!(vt(d)||!kt(d)))return{pinned:mn(d),onToggle:()=>pn(d)}},hn=d=>ot("delete",d),gn=d=>{we(null),ye(null),Te(d)},Wt=async(d,F)=>{Te(null);try{await y(d,F)}catch{ce.error(r("mobile.sessions.renameError"))}},bn=()=>{E(),e(!1)},xn=d=>{an(d),L(d),Es(!0)},ls=Vr(js(Gr,{activationConstraint:{distance:8}}),js(Ur,{coordinateGetter:qr})),At=d=>{B(d),ur({sidebarProjectSortOrder:d}),d!=="manual"&&Rt(!1)},Vt=d=>{$(d),ur({sidebarViewMode:d}),d==="timeline"&&Rt(!1)},Ut=()=>{const d=!I;U(d),ur({sidebarShowWorkSection:d})},Os=d=>{const{active:F,over:V}=d;if(!V||F.id===V.id)return;const J=Ie.findIndex(me=>me.id===F.id),ae=Ie.findIndex(me=>me.id===V.id);J<0||ae<0||z(J,ae)},zs=d=>{ts(F=>{const V=new Set(F);return V.has(d)?V.delete(d):V.add(d),V})},yn=c.useCallback(d=>{const F=kt(d);if(cr(F))return r("mobile.sessions.section.chats");const V=st.bySessionId.get(d.id),J=V?Ie.find(le=>le.id===V.projectId)??null:null;if(!J)return gr(F)||F;const ae=V?.kind==="space"&&V.spaceId?ns.get(V.spaceId):void 0;if(ae)return`${J.label} · ${ae.name||r("sessions.sidebar.grouping.spaceUnnamed")}`;const me=vr(J,V?.scopeDirectory??"");return me?.branch?`${J.label} · ${me.branch}`:J.label},[Ie,st,ns,r]),tr=d=>{O(d.id),e(!1)},vn=d=>{L(d.id),E({selectedProjectId:d.id,directoryOverride:d.path}),e(!1)},nr=c.useMemo(()=>be?Dt.filter(d=>Bo([d.project.label,d.project.path],be)?!0:d.buckets.some(F=>F.sessions.some(V=>wr(V,d.project.label,be)))):Dt,[be,Dt]),Et=c.useMemo(()=>be?Us(Ge.filter(d=>{if(vt(d))return!1;const F=st.bySessionId.get(d.id),V=F?Ie.find(J=>J.id===F.projectId)??null:null;return wr(d,V?.label??"",be)}),g,h):[],[be,g,Ie,h,st,Ge]),cs=c.useMemo(()=>be?El(Ie,be,d=>[d.label,d.path]):[],[be,Ie]),Gt=P==="timeline"&&!be&&!Ue,Bs=!be&&!Ue,Ls=Gt||Bs&&gt.sessions.length>0,Fs=Ls;c.useEffect(()=>{if(!(!Fs||!o))for(const d of Ie){const F=Ve(d.path);F&&Il(()=>a(F,o))}},[a,o,Fs,Ie]);const _t=c.useMemo(()=>{const d=new Map;if(!Ls)return d;const F=su({sessions:ct,projects:Ie.map(V=>({id:V.id,normalizedPath:V.path,label:V.label})),ownerBySessionId:st.bySessionId,availableWorktreesByProject:new Map(Ie.map(V=>[V.path,V.worktrees])),gitBranches:Q,homeDirectory:null,hideBranchMatchingProjectLabel:!1,spaceLabelById:Ps});for(const V of ct){if(vt(V))continue;const J=F.get(V.id),ae=J?Ie.find(me=>me.id===J.projectId):null;!ae||!J||d.set(V.id,{project:ae,branch:J.branchLabel,inSpace:J.inSpace})}return d},[Q,Ls,ct,Ie,st,Ps]),Kt=c.useCallback(d=>{const F=new Set;return d.flatMap(V=>{const J=_t.get(V.id);if(!J)return[];const ae=ht.runKeyBySessionId.get(V.id),me=ae?ht.runs.get(ae):void 0;return me?F.has(me.key)?[]:(F.add(me.key),[{kind:"run",run:me,laneNodes:Ts.get(me.key)??Zi,project:J.project}]):[{kind:"session",session:V,project:J.project,branch:J.branch,inSpace:J.inSpace}]})},[ht,Ts,_t]),wn=c.useMemo(()=>{const d=new Map;if(!Gt)return d;const F=Us(ct.filter(V=>!vt(V)&&_t.has(V.id)),g,h);for(const V of Kt(F)){const J=d.get(V.project.id);J?J.push(V):d.set(V.project.id,[V])}return d},[g,ct,h,Gt,_t,Kt]),rr=c.useMemo(()=>Bs?Kt(gt.sessions.filter(d=>!vt(d))):[],[Bs,Kt,gt]),w=(d,F,V)=>{const J=cn.get(d)??Hs,ae=F.slice(0,J),me=F.length-ae.length;return t.jsxs(t.Fragment,{children:[t.jsx(Yi,{entries:ae,showProject:V,handlers:W}),me>0?t.jsx(eo,{indent:nn,onClick:()=>it(d,ae.length,Hs)}):F.length>Hs?t.jsx(to,{indent:nn,onClick:()=>Ds(d)}):null]})},W={currentSessionId:j,revealedSessionId:Se,confirmingDeleteSessionId:xe,renamingSessionId:De,onSelect:Ms,onRevealedChange:$t,onArchive:d=>{xt(d)},onRequestDelete:ye,onConfirmDelete:d=>{hn(d)},onRequestRename:gn,onSubmitRename:(d,F)=>{Wt(d,F)},onCancelRename:()=>Te(null),onToggleWork:pt?(d,F)=>{as(d,F)}:void 0,isPinned:mn,onTogglePin:pn,descendantIdsOf:dn},ie=be&&Et.length===0&&cs.length===0,je=!be&&Ie.length>1&&M==="manual",Pe=!Ue&&!be&&Ie.length>0?t.jsx(Ce,{type:"button",variant:"chip",size:"sm","aria-label":r("sessions.sidebar.header.displayMode.label"),title:r("sessions.sidebar.header.displayMode.label"),onClick:()=>$e(!0),style:{touchAction:"manipulation"},children:t.jsx(H,{name:"equalizer-2",className:"size-4"})}):null,yt=je?t.jsx(Ce,{type:"button",variant:"chip",size:"sm","aria-label":r(Ue?"mobile.sessions.doneEditing":"mobile.sessions.editOrder"),"aria-pressed":Ue,onClick:()=>Rt(d=>!d),style:{touchAction:"manipulation"},children:Ue?t.jsx(qo,{className:"size-4"}):t.jsx(Rr,{className:"size-4"})}):null,Me=!Ue&&Ie.length>0?t.jsxs(Ce,{type:"button",variant:"default",size:"sm","aria-label":r("mobile.sessions.newChat"),onClick:bn,style:{touchAction:"manipulation"},children:[t.jsx(nd,{className:"size-4"}),r("mobile.sessions.newChat")]}):null,ir=Ue?null:t.jsx(Ce,{type:"button",variant:"chip",size:"sm","aria-label":r("sessions.sidebar.header.actions.addProject"),title:r("sessions.sidebar.header.actions.addProject"),onClick:()=>mt(!0),style:{touchAction:"manipulation"},children:t.jsx(Ri,{className:"size-4"})}),Ht=Me||ir||Pe||yt?t.jsxs(t.Fragment,{children:[ir,Pe,yt,Me]}):null,jn=t.jsxs("div",{ref:Lt,className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs(Gn,{ref:un,className:"min-h-0 flex-1 overflow-y-auto pb-4",children:[t.jsx("div",{className:Z("px-4 pb-2 pt-1",Ue&&"hidden"),children:t.jsx(nu,{value:re,onSearch:K,active:n||s==="sidebar",mobile:!0,placeholder:r("mobile.sessions.search.placeholder"),clearLabel:r("mobile.sessions.clearSearchAria")})}),Ie.length===0&&Ze.length===0?t.jsx(io,{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:()=>mt(!0),children:[t.jsx(Ri,{className:"size-4"}),r("sessions.sidebar.header.actions.addProject")]})}):ie?t.jsx(io,{title:r("mobile.sessions.empty.searchTitle"),description:r("mobile.sessions.empty.searchDescription")}):be&&!Ue?t.jsxs("div",{className:"flex flex-col gap-3 px-3 pt-2",children:[Et.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:Et.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:Et.map((d,F)=>t.jsx("div",{className:Z(F>0&&"border-t border-border/70"),children:t.jsx(Qi,{session:d,active:j===d.id,indent:12,contextLabel:yn(d),onSelect:()=>Ms(d)})},d.id))})]}):null,cs.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:cs.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:cs.map((d,F)=>t.jsxs("div",{className:Z("flex items-center",F>0&&"border-t border-border/70"),children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-3 px-3 py-1.5 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>tr(d),style:{touchAction:"manipulation"},children:[t.jsx($n,{project:d}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:d.label})]}),d.isGitRepo?t.jsx(Xi,{onClick:()=>xn(d.id)}):null,t.jsx(jr,{className:"me-2",label:r("mobile.sessions.newSessionInProjectAria",{label:d.label}),onClick:()=>vn(d)})]},d.id))})]}):null]}):Ue?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(Kr,{sensors:ls,collisionDetection:Hr,onDragEnd:Os,children:t.jsx(Yr,{items:Ie.map(d=>d.id),strategy:Jr,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:Ie.map(d=>t.jsx($m,{project:d,expanded:Yn.has(d.id),onToggleExpanded:()=>zs(d.id),onReorderWorktrees:F=>N(d.id,F)},d.id))})})})]}):t.jsxs("div",{className:"flex flex-col",children:[(()=>{const d=se[Vs]??!0,F=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-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ve){jt(ve,!1);return}os(Vs,d)},"aria-expanded":d,"aria-label":d?r("sessions.sidebar.group.collapseAria",{label:F}):r("sessions.sidebar.group.expandAria",{label:F}),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(H,{name:"chat-4",className:"size-5"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-header font-semibold text-foreground",children:F}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:fn})]}),Ue?null:t.jsx(jr,{className:"me-2",label:r("mobile.sessions.newChat"),onClick:bn})]}),t.jsx(In,{open:d,children:()=>t.jsx("div",{className:"pb-2",children:rs.sessions.length>0?Ft(Jn,rs,null,{pageSize:_m,alwaysVisibleIds:nt}):t.jsx("p",{className:"px-3 pb-1 typography-micro text-muted-foreground",style:{paddingInlineStart:yr},children:r("sessions.sidebar.activity.chatsEmpty")})})})]})})(),gt.sessions.length>0?(()=>{const d=se[xr]??!0,F=r("sessions.sidebar.work.title");return t.jsxs("section",{children:[t.jsxs("button",{type:"button",className:"flex min-h-12 w-full min-w-0 items-center gap-2 px-3 py-1.5 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ve){jt(ve,!1);return}os(xr,d)},"aria-expanded":d,"aria-label":d?r("sessions.sidebar.group.collapseAria",{label:F}):r("sessions.sidebar.group.expandAria",{label:F}),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(H,{name:"eye",className:"size-5"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-header font-semibold text-foreground",children:F}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:gt.sessions.filter(V=>!vt(V)).length})]}),t.jsx(In,{open:d,children:()=>t.jsx("div",{className:"pb-2",children:t.jsx(Yi,{entries:rr,showProject:!0,handlers:W})})})]})})():null,nr.map(d=>{const F=Xn(d),V=be?d.buckets.filter(ae=>ae.sessions.some(me=>wr(me,d.project.label,be))):d.buckets,J=bt(d);return t.jsxs("section",{children:[t.jsx(Wn,{actionsWidth:96,revealed:ve===`project:${d.project.id}`,onRevealedChange:ae=>jt(`project:${d.project.id}`,ae),actions:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:ve===`project:${d.project.id}`?0:-1,className:Z("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",q===d.project.id?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80"),"aria-label":q===d.project.id?r("mobile.sessions.confirmRemoveProjectAria",{label:d.project.label}):r("mobile.sessions.removeProjectAria",{label:d.project.label}),onClick:()=>{if(q===d.project.id){Ne(null),pe(null),ue(d.project.id),ce.success(r("mobile.sessions.toast.projectRemoved",{label:d.project.label}));return}pe(d.project.id)},style:{touchAction:"manipulation"},children:t.jsx(_n,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:ve===`project:${d.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:d.project.label}),onClick:()=>{Ne(null),fe(d.project.id)},style:{touchAction:"manipulation"},children:t.jsx(Rr,{className:"size-[18px]"})})]}),children:t.jsxs("div",{"data-active-project":d.isActive||void 0,className:"flex min-h-12 w-full items-center",children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ve){jt(ve,!1);return}os(d.project.id,F)},"aria-expanded":F,"aria-label":F?r("sessions.sidebar.group.collapseAria",{label:d.project.label}):r("sessions.sidebar.group.expandAria",{label:d.project.label}),style:{touchAction:"manipulation"},children:[t.jsx($n,{project:d.project}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-header font-semibold text-foreground",children:d.project.label})]}),d.project.isGitRepo?t.jsx(Xi,{onClick:()=>xn(d.project.id)}):null,t.jsx(jr,{className:"me-2",label:r("mobile.sessions.newSessionInProjectAria",{label:d.project.label}),onClick:()=>vn(d.project)})]})}),t.jsx(In,{open:F,children:()=>Gt?t.jsx("div",{className:"pb-2",children:w(`${d.project.id}::timeline`,wn.get(d.project.id)??[],!1)}):t.jsx("div",{className:"pb-2",children:(()=>{const ae=V.find(le=>le.worktree===null&&le.space===null),me=V.filter(le=>le!==ae);return t.jsxs(t.Fragment,{children:[ae&&ae.sessions.length>0?Ft(`${d.project.id}::${ae.key}`,ae,0):null,me.map(le=>{const Ye=Qn(d,le),Qe=le.sessions.length===0,Mt=J===le.path;return t.jsx(zm,{path:le.worktree?.path??null,children:qt=>t.jsxs("div",{className:Z("mt-1.5",qt&&"opacity-60"),"aria-busy":qt||void 0,children:[t.jsx(Wn,{actionsWidth:le.space?96:48,revealed:ve===`wt:${le.key}`,onRevealedChange:$s=>jt(`wt:${le.key}`,$s),actions:le.space?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:ve===`wt:${le.key}`?0:-1,className:"flex flex-1 items-center justify-center text-foreground transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":r("spaces.group.access.giveAria",{label:le.label}),onClick:()=>{Ne(null),le.space&&bi.getState().openAccessDialog(le.space.id)},style:{touchAction:"manipulation"},children:t.jsx(H,{name:"key",className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:ve===`wt:${le.key}`?0:-1,className:"flex flex-1 items-center justify-center text-foreground transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":r("spaces.actions.menuAria",{label:le.label}),onClick:()=>{Ne(null),le.space&&bi.getState().openActionsSheet(le.space.id)},style:{touchAction:"manipulation"},children:t.jsx(H,{name:"more-2",className:"size-[18px]"})})]}):le.worktree&&!qt?t.jsx("button",{type:"button",tabIndex:ve===`wt:${le.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:le.label}),onClick:()=>{Ne(null),le.worktree&&We({project:d.project,worktree:le.worktree})},style:{touchAction:"manipulation"},children:t.jsx(_n,{className:"size-[18px]"})}):null,children:t.jsxs("button",{type:"button",className:"flex min-h-10 w-full items-center gap-0.5 py-1 pe-3 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ve){jt(ve,!1);return}Qe||_s(d.project.id,le.key,Ye)},"aria-expanded":Qe?void 0:Ye,"aria-label":Qe?le.label:Ye?r("sessions.sidebar.group.collapseAria",{label:le.label}):r("sessions.sidebar.group.expandAria",{label:le.label}),style:{paddingInlineStart:ui(0),touchAction:"manipulation"},children:[Qe?t.jsx("span",{"aria-hidden":!0,className:"size-3.5 shrink-0"}):t.jsx(Ho,{expanded:Ye}),qt?t.jsx("span",{className:"inline-flex size-3.5 shrink-0 items-center justify-center text-muted-foreground",role:"status","aria-label":r("sessions.sidebar.group.worktreeRemoving"),children:t.jsx(H,{name:"loader-4",className:"size-3.5 animate-spin"})}):t.jsx(H,{name:le.space?"box-3":"git-branch",className:Z("mx-px size-3 shrink-0",Mt?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground",children:le.label}),Mt?t.jsx(Bm,{ariaLabel:r("mobile.sessions.activeWorktreeAria")}):null]})}),le.space?t.jsx("div",{className:"pb-1 pe-3",style:{paddingInlineStart:Vn(1)},children:t.jsx(ru,{spaceId:le.space.id})}):null,t.jsx(In,{open:Ye,children:()=>Ft(`${d.project.id}::${le.key}`,le,1)})]})},le.key)})]})})()})})]},d.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(Ce,{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(H,{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(Ce,{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(H,{name:"download",className:"size-5"}),t.jsx("span",{className:"absolute inset-e-2 top-2 inline-flex size-2 rounded-full bg-primary","aria-hidden":!0})]}):null,t.jsx(Ce,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:i.onOpenScheduled,"aria-label":r("sessions.sidebar.header.actions.scheduledTasks"),title:r("sessions.sidebar.header.actions.scheduledTasks"),style:{touchAction:"manipulation"},children:t.jsx(H,{name:"calendar-schedule",className:"size-5"})}),t.jsx(Ce,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:i.onOpenSourceBoard,"aria-label":r("sourceBoard.title"),title:r("sourceBoard.title"),style:{touchAction:"manipulation"},children:t.jsx(H,{name:"todo",className:"size-5"})}),t.jsx(Ce,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:i.onOpenArchive,"aria-label":r("sessions.sidebar.nav.archive"),title:r("sessions.sidebar.nav.archive"),style:{touchAction:"manipulation"},children:t.jsx(H,{name:"archive",className:"size-5"})}),t.jsx(Ce,{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(H,{name:"bar-chart",className:"size-5"})}),t.jsx(Ce,{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(H,{name:"settings-3",className:"size-5"})})]})]}):null,t.jsx(iu,{open:tt,onOpenChange:mt}),t.jsx(Al,{open:wt,onOpenChange:d=>{Es(d),d||an(null)},project:(()=>{const d=Ie.find(F=>F.id===Is);return d?{id:d.id,path:d.path}:void 0})(),onWorktreeCreated:d=>{E({selectedProjectId:Is,directoryOverride:d,preserveDirectoryOverride:!0}),e(!1)}}),t.jsx(vm,{open:oe!==null,project:Ie.find(d=>d.id===oe)??null,onClose:()=>fe(null),onWorktreesChanged:()=>Le(d=>d+1)}),t.jsx(Io,{open:He,onClose:()=>$e(!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")}),Dm.map(([d,F])=>t.jsxs("button",{type:"button",className:Z("flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-start transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",P===d?"text-primary":"text-foreground"),onClick:()=>{Vt(d),$e(!1)},style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label",children:r(F)}),P===d?t.jsx(H,{name:"check",className:"size-4"}):null]},d)),P==="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")}),P==="timeline"?null:Tm.map(([d,F])=>t.jsxs("button",{type:"button",className:Z("flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-start transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",M===d?"text-primary":"text-foreground"),onClick:()=>{At(d),$e(!1)},style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label",children:r(F)}),M===d?t.jsx(H,{name:"check",className:"size-4"}):null]},d)),pt?t.jsxs("button",{type:"button","aria-pressed":I,className:Z("mt-2 flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-start transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",I?"text-primary":"text-foreground"),onClick:()=>{Ut(),$e(!1)},style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label",children:r("sessions.sidebar.header.displayMode.showWork")}),I?t.jsx(H,{name:"check",className:"size-4"}):null]}):null]})}),Ae?t.jsx(ya,{open:!0,project:{id:Ae.project.id,path:Ae.project.path},worktree:Ae.worktree,onClose:()=>We(null),onDeleted:()=>Le(d=>d+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")}),Ht?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:Ht}):null]}),jn]}):null:t.jsxs(Um,{open:n,onClose:()=>e(!1),onSwipeClose:()=>{if(Se||ve){we(null),Ne(null),ye(null),pe(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:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":r("mobile.surface.closeAria"),onClick:()=>e(!1),style:{touchAction:"manipulation"},children:t.jsx(H,{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")}),Ht?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:Ht}):null]}),jn]})},no="mobile-surface-root",Wm=16,ro=320,Vm="cubic-bezier(0.22, 1, 0.36, 1)",Um=({open:n,onClose:e,onSwipeClose:s,ariaLabel:i,children:r})=>{const{direction:o}=he(),a=c.useRef(null),l=c.useRef(null),[u,m]=c.useState(!1),[f,g]=c.useState(n),p=c.useRef(e);c.useEffect(()=>{p.current=e},[e]);const h=c.useRef(s);c.useEffect(()=>{h.current=s},[s]);const x=()=>(h.current??p.current)();if(ci(l,{enabled:n,...o==="rtl"?{onLeftEdgeSwipe:x}:{onRightEdgeSwipe:x}}),typeof document<"u"&&!a.current){let v=document.getElementById(no);v||(v=document.createElement("div"),v.id=no,document.body.appendChild(v)),a.current=v}return c.useEffect(()=>{if(n){g(!0);const b=window.setTimeout(()=>m(!0),Wm);return()=>window.clearTimeout(b)}m(!1);const v=window.setTimeout(()=>g(!1),ro+40);return()=>window.clearTimeout(v)},[n]),c.useEffect(()=>{if(!n)return;const v=document.body.style.overflow;document.body.style.overflow="hidden";const b=C=>{C.key==="Escape"&&p.current()};return document.addEventListener("keydown",b),()=>{document.body.style.overflow=v,document.removeEventListener("keydown",b)}},[n]),a.current?vs.createPortal(t.jsx("section",{ref:l,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:u?"none":o==="rtl"?"translateX(100%)":"translateX(-100%)",transition:`transform ${ro}ms ${Vm}`,visibility:f?"visible":"hidden",pointerEvents:n?"auto":"none"},children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:r})}),a.current):null},io=n=>{const e=de.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 l;e[4]!==r?(l=r?t.jsx("div",{className:"pt-2",children:r}):null,e[4]=r,e[5]=l):l=e[5];let u;return e[6]!==o||e[7]!==a||e[8]!==l?(u=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[o,a,l]}),e[6]=o,e[7]=a,e[8]=l,e[9]=u):u=e[9],u};function Gm(n){return Ve(n.path)}function Km(n){return Ve(n.path)}function Hm(n){return t.jsx(Fm,{worktree:n},Ve(n.path))}const qm=6e4,Ym=(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}},Jm=n=>{switch(n?.status.status){case"connected":return"success";case"failed":return"error";case"needs_auth":return"warning";default:return"default"}},Xm=({active:n,className:e,headerAction:s,listClassName:i,hideHeader:r=!1,mobileListDensity:o=!1})=>{const{t:a}=he(),u=zt(k=>k.currentDirectory)??null,m=fs(k=>k.getStatusForDirectory(u)),f=fs(k=>k.refresh),g=fs(k=>k.ensureFresh),p=fs(k=>k.connect),h=fs(k=>k.disconnect),x=xs(k=>k.mcpServers),v=xs(k=>k.loadMcpConfigs),[b,C]=c.useState(!1),[j,R]=c.useState(null);c.useEffect(()=>{v({force:!0})},[v]),c.useEffect(()=>{n&&Promise.all([g({directory:u,silent:!0,maxAgeMs:qm}),v({force:!0})])},[n,g,u,v]);const T=c.useMemo(()=>{const k=new Set(Object.keys(m));for(const S of x)S?.name&&k.add(S.name);return Array.from(k).sort((S,y)=>S.localeCompare(y))},[x,m]),D=c.useCallback(k=>{if(k?.preventDefault(),b)return;C(!0);const S=new Promise(y=>setTimeout(y,500));Promise.all([f({directory:u}),S]).finally(()=>{C(!1)})},[b,f,u]);return t.jsxs("div",{className:Z("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")}),u&&t.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:u.split("/").pop()||u})]}),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:b,onClick:D,"aria-label":a("mcpDropdown.actions.refreshAria"),children:t.jsx(H,{name:"refresh",className:Z("h-4 w-4",b&&"animate-spin")})})]})]})}),t.jsx("div",{className:Z("max-h-64 overflow-y-auto",o?"space-y-1 py-3":"px-3 py-2.5",i),children:t.jsxs("div",{className:Z(!o&&T.length>0&&"p-1.5"),children:[T.map(k=>{const S=m[k],y=Jm(S),E=S?.status.status==="connected",O=j===k,L=Ym(S,a);return t.jsxs("div",{className:Z("flex items-center justify-between rounded-lg hover:bg-interactive-hover",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(Dl,{children:[t.jsx(_l,{asChild:!0,children:t.jsx("span",{className:Z("rounded-full flex-shrink-0",o?"h-2.5 w-2.5":"h-2 w-2",y==="success"&&"bg-status-success",y==="error"&&"bg-status-error",y==="warning"&&"bg-status-warning",y==="default"&&"bg-muted-foreground/40"),"aria-label":L})}),t.jsx(Ml,{side:"left",children:t.jsx("p",{children:L})})]}),t.jsx("span",{className:Z("truncate",o?"text-[17px] leading-6 font-medium":"typography-ui-label"),children:k})]})}),t.jsx(Ol,{checked:E,disabled:O,className:"data-[checked]:bg-status-info",onCheckedChange:async z=>{R(k);try{z?await p(k,u):await h(k,u)}catch(A){Er.error(A instanceof Error?A.message:a("mcpDropdown.status.unknownError"))}finally{R(null)}}})]},k)}),T.length===0&&t.jsx("div",{className:"px-4 py-5 typography-ui-label text-muted-foreground text-center",children:a("mcpDropdown.empty.configureInConfig")})]})})]})};async function Qm(n,e,s=Number.POSITIVE_INFINITY){const i=Array.from(new Set(n)),r=[];return await zl(i,s,async o=>{try{await e(o)}catch(a){r.push({path:o,error:a instanceof Error?a:null})}}),{paths:i,failures:r}}const oo={status:"loading"},Zm=1e6,ds={type:"list"},ep=2,tp=n=>{const e=n.index?.trim();return!!(e&&e!=="?")},sp=n=>{const e=n.working_dir?.trim(),s=n.index?.trim();return!!(e||s==="?")},ao=(n,e)=>e?`${n}\0staged`:n,np=n=>{const e=de.c(6),s=on(Lr()??null)??"",i=n.visible??!0;let r;e[0]!==i?(r={enabled:i,recheckOnOpen:!0},e[0]=i,e[1]=r):r=e[1];const o=Bl(s||null,r);let a;return e[2]!==n||e[3]!==o||e[4]!==s?(a=t.jsx(rp,{...n,rootDirectory:s,repository:o}),e[2]=n,e[3]=o,e[4]=s,e[5]=a):a=e[5],a},rp=({rootDirectory:n,repository:e,onClose:s,initialDiff:i,visible:r=!0,onNavigatedToChat:o})=>{const{t:a}=he(),{git:l,sourceControl:u}=Un(),{rootIsGitRepo:m,gitDirectory:f,nestedRepos:g}=e,p=f??n,h=Ll(p||null),x=lu(p),v=Fl(p||null),b=$l(p||null),[C,j]=c.useState(!1),[R,T]=c.useState(!1),D=Cn(w=>w.profiles),k=Cn(w=>w.globalIdentity),S=Cn(w=>w.loadProfiles),y=Cn(w=>w.loadGlobalIdentity);c.useEffect(()=>{S(),y()},[S,y]);const E=Wl(),O=$o(w=>w.refreshIdentityAccounts),L=c.useMemo(()=>Vl(D,k,w=>Ha(w)&&Ul(w,E)),[D,k,E]),z=async w=>{if(!(!p||R)){T(!0);try{(await ju({directory:p,identity:w,remoteName:st||null},{git:l,sourceControl:u})).status==="failed"?ce.error(a("gitView.toast.applyIdentityFailed")):ce.success(a("gitView.toast.appliedIdentity",{name:ac(w,a)}))}finally{T(!1)}}},A=Ro(p||null),_=Gl(p||null),B=at(w=>w.setActiveDirectory),P=at(w=>w.ensureAll),M=at(w=>w.ensureNestedRepos),$=at(w=>w.selectNestedRepo),I=at(w=>w.fetchStatus),U=at(w=>w.fetchBranches),X=at(w=>w.prefetchDiffs),Q=at(w=>w.getDiff),ue=at(w=>w.setDiff),se=at(w=>w.runtimeKey),te=JSON.stringify([se,p]),ge=c.useRef(te);ge.current=te;const[ee,G]=c.useState(()=>({ownerKey:te,mode:"working",route:i?.path?{type:"diff",path:i.path,staged:i.staged}:ds})),N=ee.ownerKey===te?ee.mode:"working",Y=ee.ownerKey===te?ee.route:ds,[ne,re]=c.useState(!1),K=c.useCallback(w=>{G({ownerKey:te,mode:w,route:ds}),re(!1)},[te]),oe=c.useCallback(w=>{G(W=>({ownerKey:te,mode:W.ownerKey===te?W.mode:"working",route:w}))},[te]);c.useEffect(()=>{G(w=>w.ownerKey===te?w:{ownerKey:te,mode:"working",route:ds}),re(!1)},[te]),c.useEffect(()=>{r||re(!1)},[r]),c.useEffect(()=>{i?.path&&G({ownerKey:ge.current,mode:"working",route:{type:"diff",path:i.path,staged:i.staged}})},[i]);const[fe,Se]=c.useState(null),[we,xe]=c.useState(null),[ye,De]=c.useState(""),[Te,ve]=c.useState(new Set),[Ne,q]=c.useState(!1),[pe,Ae]=c.useState(!1),[We,Re]=c.useState([]),[Le,He]=c.useState([]),[$e,tt]=c.useState([]),[mt,wt]=c.useState(null),[Es,Is]=c.useState(null),[an,ln]=c.useState(0),As=cu(),rt=uu({directory:p,branch:h?.current,chooseContributor:As.choose}),Ct=du(p,l,u),[Ue,Rt]=c.useState(null),[Yn,ts]=c.useState(!1),[cn,Bt]=c.useState([]),[un,Ie]=c.useState("rebase"),Ge=c.useCallback((w,W)=>{Bt(w),Ie(W),ts(!0)},[]),_e=h?.current??null,dn=Ii(w=>w.setOverride),ct=Ii(w=>w.clearOverride),Ze=Ad(p||null,_e,r&&N==="commit"&&A===!0),pt=Ze.selectedCommit?.hash??null,ze=Kl(p||null,u),ss=c.useMemo(()=>new Set(ze.read?.repository.remotes.map(w=>w.name)??[]),[ze.read]),Be=Pd(p||null,_e,r&&A===!0,{branches:v,remoteNames:ss,primaryRemote:ze.contexts[0]?.primaryRemote,readContext:ze.contexts[0]??null}),ns=xd(_e,Be.base),Ps=A===!1||yd(_e,Be.base,h!==null,Be.resolved),st=ze.read?.binding?.remotes[0]?.name??ze.read?.repository.remotes.find(w=>w.name==="origin")?.name??ze.read?.repository.remotes[0]?.name??"",ht=ze.read?ze.read.binding?.providers.find(w=>w.readiness==="ready")?.accountId??null:void 0,Ts=c.useMemo(()=>Hl(D,k,b,w=>({id:"local-config",name:w.userName,...w,color:"info",icon:"user"}),ht),[ht,b,D,k]),rs=c.useMemo(()=>{const w=ze.read;return!w?.binding||ze.status!=="ready"||w.binding.state==="bound"?null:ql(w.binding)?a("gitView.identity.configChanged"):a("gitView.context.needsAttention")},[ze.read,ze.status,a]),nt=Td(p||null,_e,ze.contexts[0]??null,r&&N==="pr"&&A===!0),gt=nt.selectedSource,Jn=c.useMemo(()=>N==="pr"?gt:N==="branch"&&_e&&Be.base?{kind:"branch",baseRef:Be.base,headRef:_e}:N==="commit"&&pt?{kind:"commit",hash:pt}:null,[Be.base,_e,N,pt,gt]),fn=N==="branch"?Be.revision:"",be=vd(p||null,Jn,r&&A===!0,fn,nt.readContext,nt.provider),{fetchDiff:Lt,fetchFullFile:Dt}=be,is=c.useMemo(()=>be.files?[...be.files].sort((w,W)=>w.path.localeCompare(W.path)):null,[be.files]),bt=Y.type==="comparison"&&Y.sourceKey===be.key?Y.path:null,[Xn,Qn]=c.useState(0),Ds=c.useCallback(async w=>{try{const{diff:W}=await Lt(w),ie={original:"",modified:"",isBinary:Dd(W)};return ie.isBinary||(ie.fileDiff=Ai(w,W)),{status:"ready",diff:ie}}catch(W){return{status:"error",message:W instanceof Error?W.message:a("diffView.state.failedToLoadDiff")}}},[Lt,a]),Zn=wd(be.files?N==="pr"?JSON.stringify([be.key,be.revision]):be.key:null,r&&bt?bt:"",r?Ds:null,oo,JSON.stringify([fn,N==="pr"?be.revision:0,Xn])),it=bt?Zn.get(bt)??oo:null,[Ft,os]=c.useState(null),[_s,Ms]=c.useState(null),$t=Ft&&Ft.source===it?Ft.request:null,jt=_s&&_s.source===it?_s.diff:null;c.useEffect(()=>{const w=it;if(!$t||!bt||w?.status!=="ready"||jt)return;let W=!1;const ie=bt,je=async()=>{if(N==="pr"){const{original:yt,modified:Me}=await Dt(ie);return{original:yt,modified:Me,fileDiff:zd({name:ie,contents:yt},{name:ie,contents:Me})}}const{diff:Pe}=await Lt(ie,Zm);return{original:"",modified:"",fileDiff:Ai(ie,Pe)}};return(async()=>{try{const Pe=await je();W||Ms({source:w,diff:Pe})}catch(Pe){if(W)return;ce.error(Pe instanceof Error?Pe.message:a("diffView.state.failedToLoadDiff")),os(null)}})(),()=>{W=!0}},[it,bt,jt,Lt,Dt,N,$t,a]),c.useEffect(()=>{N==="branch"&&Ps&&K("working")},[Ps,K,N]),c.useEffect(()=>{G(w=>w.ownerKey===te&&w.route.type==="comparison"&&w.route.sourceKey!==be.key?{...w,route:ds}:w)},[be.key,te]);const ot=c.useMemo(()=>{const w=h?.files??[],W=new Map;for(const ie of w)W.set(ie.path,ie);return Array.from(W.values()).sort((ie,je)=>ie.path.localeCompare(je.path))},[h?.files]),xt=c.useMemo(()=>ot.filter(tp),[ot]),as=c.useMemo(()=>ot.filter(sp),[ot]),er=$e,mn=at(c.useCallback(w=>!p||Y.type!=="diff"?null:w.directories.get(p)?.diffCache.get(ao(Y.path,Y.staged))??null,[p,Y])),pn=c.useMemo(()=>Y.type!=="diff"?null:ot.find(w=>w.path===Y.path)??null,[ot,Y]),qe=c.useCallback(async(w=!0)=>{if(p)try{await Promise.all([I(p,l),U(p,l)])}catch(W){w&&ce.error(W instanceof Error?W.message:a("gitView.toast.refreshRepositoryFailed"))}},[p,U,I,l,a]),hn=c.useMemo(()=>(v?.all??[]).filter(w=>!w.startsWith("remotes/")).sort(),[v]),gn=c.useMemo(()=>(v?.all??[]).filter(w=>w.startsWith("remotes/")).map(w=>w.replace(/^remotes\//,"")).sort(),[v]),Wt=c.useCallback(async w=>{if(!p)return;const W=w.replace(/^remotes\//,"");try{const ie=await l.checkoutBranch(p,W);ce.success(a("gitView.toast.checkedOut",{name:ie.branch||W})),await qe()}catch(ie){ce.error(ie instanceof Error?ie.message:a("gitView.toast.checkoutFailed",{name:W}))}},[p,l,qe,a]),bn=c.useCallback(w=>{const W=w.replace(/^remotes\//,"");if((h?.files?.length??0)>0){Rt(W);return}Wt(W)},[Wt,h?.files]),xn=c.useCallback(async w=>{if(p)try{await l.createBranch(p,w,_e??"HEAD"),await l.checkoutBranch(p,w),await qe()}catch(W){throw ce.error(W instanceof Error?W.message:a("gitView.toast.createBranchFailed")),W}},[_e,p,l,qe,a]),ls=c.useCallback(async()=>{if(!p){tt([]);return}try{const w=await l.getRemotes(p);tt(w)}catch{tt([])}},[p,l]),At=c.useCallback(async()=>{p&&(Promise.allSettled([U(p,l),ls()]),await I(p,l).catch(()=>{}))},[p,U,I,l,ls]);c.useEffect(()=>{!p||!r||(B(p),P(p,l))},[p,P,l,B,r]),c.useEffect(()=>{r&&ls()},[ls,r]),c.useEffect(()=>{if(!r||N!=="working"||!p||ot.length===0)return;const w=Array.from(new Set([...xt.map(ie=>ie.path),...Le,...ot.slice(0,20).map(ie=>ie.path)])).filter(Boolean);if(w.length===0)return;const W=window.setTimeout(()=>{X(p,l,w,{maxFiles:40})},120);return()=>window.clearTimeout(W)},[ot,p,l,N,X,xt,Le,r]),c.useEffect(()=>{if(!r)return;if(Y.type!=="diff"){wt(null);return}const w=ao(Y.path,Y.staged);if(Is(null),!p||Q(p,w)){wt(null);return}let W=!1;const ie=rn();return wt(null),l.getGitFileDiff(p,{path:Y.path,staged:Y.staged||void 0}).then(je=>{W||ue(p,w,{original:je.original??"",modified:je.modified??"",isBinary:je.isBinary,submodule:je.submodule},ie)}).catch(je=>{if(!W){if(je instanceof xi&&je.reason!=="path_not_found"){Is({key:`${p}\0${Y.path}`,reason:je.reason});return}je instanceof xi&&I(p,l,{force:!0,silent:!0}),wt(je instanceof Error?je.message:String(je))}}),()=>{W=!0}},[p,an,I,Q,l,Y,ue,r]);const Vt=async(w,W,ie=!1)=>{if(!p)return;const je=Ct.start();if(!je)return;Se(w);const Pe=a(w==="fetch"?"gitView.sync.fetch":w==="pull"?"gitView.sync.pull":w==="publish"?"gitView.publish.title":"gitView.sync.syncChanges");let yt=null;try{if(w==="sync"||w==="publish"){const Me=await rt.prepare(w==="publish"?"push":"sync",{forceChoose:ie,onOperation:je.onOperation});yt=lc(await Me())}else if(W&&h)await cc({action:w,directory:p,remoteName:W.name,status:h,sourceControl:u,git:l,onOperation:je.onOperation});else throw new Ot("tracking-required");if(!je.isCurrent())return;w==="fetch"&&W?ce.success(a("gitView.toast.fetchedFromRemote",{name:W.name})):w==="pull"&&W?ce.success(a("gitView.toast.pulledFromRemote",{name:W.name})):w==="sync"?ce.success(yt?.kind==="up-to-date"?a("gitView.toast.alreadyUpToDate"):yt?.kind==="pulled"?a("gitView.toast.pulledFromRemote",{name:yt.remoteName}):yt?.kind==="pushed"?a("gitView.toast.pushedToUpstream",{name:yt.remoteName}):a("gitView.toast.syncedChanges")):w==="publish"&&ce.success(a("gitView.publish.succeeded")),await At()}catch(Me){if(Me instanceof An||Me instanceof Nr){if(je.isCurrent()&&await At(),je.isCurrent()&&Me instanceof An&&Me.read.availability==="available"&&Me.read.operation.state==="conflicted"&&Me.read.operation.error.code==="CONFLICT"){const Ht=((await l.getGitStatus(p).catch(()=>null))?.files??[]).filter(fr).map(jn=>jn.path);Ht.length>0&&Ge(Ht,"merge")}return}if(Me instanceof Ot&&Me.code==="stale-runtime")return;if(Me instanceof Ot&&rt.errorMessage(Me)){ce.info(rt.errorMessage(Me));return}await At(),ce.error(Me instanceof Ot?Me.code==="contributor-publish-cancelled-after-update"?a("gitView.toast.contributorPublishCancelledAfterUpdate"):Me.code==="contributor-publish-cancelled"?a("gitView.toast.contributorPublishCancelled"):a("gitView.toast.syncActionFailed",{action:Pe}):Me instanceof Error?Me.message:a("gitView.toast.syncActionFailed",{action:Pe}))}finally{je.finish(),je.isCurrent()&&Se(null)}},Ut=c.useCallback(async(w,W)=>{if(!(!p||w.length===0))try{W==="stage"?w.length>1?await Yl(p,w):await Jl(p,w[0]):w.length>1?await Xl(p,w):await Ql(p,w[0]),await qe(!1)}catch(ie){ce.error(ie instanceof Error?ie.message:a(W==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed"))}},[p,qe,a]),Os=c.useCallback((w,W=!1)=>{oe({type:"diff",path:w,staged:W})},[oe]),zs=c.useCallback(async w=>{if(p){ve(W=>new Set(W).add(w));try{await l.revertGitFile(p,w),ce.success(a("gitView.toast.revertedFile",{path:w})),await qe(!1)}catch(W){ce.error(W instanceof Error?W.message:a("gitView.toast.revertFailed"))}finally{ve(W=>{const ie=new Set(W);return ie.delete(w),ie})}}},[p,l,qe,a]),yn=c.useCallback(async w=>{if(!p||w.length===0||Ne)return;const W=Array.from(new Set(w));q(!0),ve(new Set(W));try{const ie=await Qm(W,je=>l.revertGitFile(p,je),ep);if(await qe(!1),ie.failures.length===0)ce.success(W.length===1?a("gitView.toast.revertedFilesSingle",{count:W.length}):a("gitView.toast.revertedFilesPlural",{count:W.length}));else if(ie.failures.length===W.length)ce.error(ie.failures[0]?.error?.message??a("gitView.toast.revertFailed"));else{const je=W.length-ie.failures.length;ce.warning(je===1?a("gitView.toast.revertedSomeSingle",{success:je,failed:ie.failures.length}):a("gitView.toast.revertedSomePlural",{success:je,failed:ie.failures.length}))}}catch(ie){ce.error(ie instanceof Error?ie.message:a("gitView.toast.revertFailed"))}finally{ve(new Set),q(!1)}},[p,l,Ne,qe,a]),tr=c.useCallback(w=>{const W=w.map(ie=>ie.trim()).filter(Boolean);if(W.length===0){Re([]);return}De(ie=>`${ie.trim()}${ie.trim()?`
22
+ `}),e[47]=te):te=e[47];let ge;return e[48]!==se?(ge=t.jsxs("div",{ref:p,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:[se,te]}),e[48]=se,e[49]=ge):ge=e[49],ge};function tm(n){return n.currentSessionId}function sm(n){return n.setCurrentSession}function nm(n){return n.setActiveProjectIdOnly}const rm=n=>{const e=de.c(84),{onOpenSessions:s,onOpenWorkspace:i,compactTitle:r}=n,o=r===void 0?!1:r,{t:a}=he(),[l,u]=c.useState(!1),[m,f]=c.useState(!1),g=c.useRef(null),p=zt(im),h=Me(om);let x;e[0]!==h?(x=Re=>h?Re.getDirectoryForSession(h):null,e[0]=h,e[1]=x):x=e[1];const b=Me(x)||p,C=gl(h,b||void 0),j=Me(am),R=Io(b||null);let T;e[2]!==b||e[3]!==R?(T=Re=>{if(!b||R!==!0)return!1;const Le=Re.directories.get(b)?.status;return!!(Le&&!Le.isClean)},e[2]=b,e[3]=R,e[4]=T):T=e[4];const D=lt(T),k=Fe(lm),S=Xc(k);let y;e[5]!==C?.title?(y=C?.title?.trim(),e[5]=C?.title,e[6]=y):y=e[6];const E=y;let O;e[7]!==h||e[8]!==k||e[9]!==S||e[10]!==E||e[11]!==a?(O=(k?S:null)||E||a(h?"mobile.sessions.untitled":"sessions.switcher.draftTitle"),e[7]=h,e[8]=k,e[9]=S,e[10]=E,e[11]=a,e[12]=O):O=e[12];const L=O;let z;e[13]===Symbol.for("react.memo_cache_sentinel")?(z=()=>{u(!1),f(!1)},e[13]=z):z=e[13];let A;e[14]!==h||e[15]!==b?(A=[h,b],e[14]=h,e[15]=b,e[16]=A):A=e[16],c.useEffect(z,A);let _;e[17]!==s?(_=()=>{u(!1),f(!1),s()},e[17]=s,e[18]=_):_=e[18];const B=_;let P;e[19]===Symbol.for("react.memo_cache_sentinel")?(P=Re=>{u(Le=>{const qe=typeof Re=="function"?Re(Le):Re;return qe&&f(!1),qe})},e[19]=P):P=e[19];const M=P;let $;e[20]===Symbol.for("react.memo_cache_sentinel")?($=()=>{f(Re=>{const Le=!Re;return Le&&u(!1),Le})},e[20]=$):$=e[20];const I=$;let U;e[21]===Symbol.for("react.memo_cache_sentinel")?(U={paddingTop:"var(--oc-safe-area-top, 0px)"},e[21]=U):U=e[21];let X;e[22]!==a?(X=a("mobile.sessions.openSheetAria"),e[22]=a,e[23]=X):X=e[23];let Q,ue;e[24]===Symbol.for("react.memo_cache_sentinel")?(Q={touchAction:"manipulation"},ue=t.jsx(q,{name:"list-unordered",className:"size-5"}),e[24]=Q,e[25]=ue):(Q=e[24],ue=e[25]);let se;e[26]!==B||e[27]!==X?(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":X,onClick:B,style:Q,children:ue}),e[26]=B,e[27]=X,e[28]=se):se=e[28];const te=o?"shrink":"flex-1";let ge;e[29]!==te?(ge=Z("flex min-w-0 items-center rounded-lg px-2 py-1.5 text-start transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",te),e[29]=te,e[30]=ge):ge=e[30];let ee;e[31]!==a?(ee=a("sessions.switcher.openAria"),e[31]=a,e[32]=ee):ee=e[32];let G;e[33]===Symbol.for("react.memo_cache_sentinel")?(G={touchAction:"manipulation"},e[33]=G):G=e[33];let N;e[34]!==L?(N=t.jsx("span",{dir:"auto",className:"block min-w-0 truncate oc-ui-start-align typography-ui-label text-foreground",children:L}),e[34]=L,e[35]=N):N=e[35];const Y=m&&"rotate-180";let ne;e[36]!==Y?(ne=Z("size-4 shrink-0 text-muted-foreground transition-transform duration-150",Y),e[36]=Y,e[37]=ne):ne=e[37];let re;e[38]!==ne?(re=t.jsx(q,{name:"arrow-down-s",className:ne}),e[38]=ne,e[39]=re):re=e[39];let K;e[40]!==N||e[41]!==re?(K=t.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[N,re]}),e[40]=N,e[41]=re,e[42]=K):K=e[42];let oe;e[43]!==m||e[44]!==ge||e[45]!==ee||e[46]!==K?(oe=t.jsx("button",{ref:g,type:"button",className:ge,"aria-label":ee,"aria-haspopup":"dialog","aria-expanded":m,onClick:I,style:G,children:K}),e[43]=m,e[44]=ge,e[45]=ee,e[46]=K,e[47]=oe):oe=e[47];let fe;e[48]!==o?(fe=o?t.jsx("div",{className:"min-w-0 flex-1"}):null,e[48]=o,e[49]=fe):fe=e[49];let Se;e[50]!==h||e[51]!==b||e[52]!==j||e[53]!==l||e[54]!==k?(Se=k?null:t.jsx(Jf,{open:l,onOpenChange:M,currentSessionId:h,effectiveDirectory:b,isNewSessionDraftOpen:j}),e[50]=h,e[51]=b,e[52]=j,e[53]=l,e[54]=k,e[55]=Se):Se=e[55];let we;e[56]!==b?(we=t.jsx(Qc,{directory:b,className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",iconClassName:"size-5"}),e[56]=b,e[57]=we):we=e[57];let xe;e[58]!==D||e[59]!==a?(xe=a(D?"mobile.header.openWorkspaceWithChangesAria":"mobile.header.openWorkspaceAria"),e[58]=D,e[59]=a,e[60]=xe):xe=e[60];let ye;e[61]!==i?(ye=()=>{u(!1),f(!1),i()},e[61]=i,e[62]=ye):ye=e[62];let De,Te;e[63]===Symbol.for("react.memo_cache_sentinel")?(De={touchAction:"manipulation"},Te=t.jsx(q,{name:"pencil-ruler-2",className:"size-5"}),e[63]=De,e[64]=Te):(De=e[63],Te=e[64]);let ve;e[65]!==D?(ve=D?t.jsx("span",{className:"absolute inset-e-1.5 top-1.5 size-2.5 rounded-full border-2 border-[var(--background)] bg-[var(--status-warning)]","aria-hidden":!0}):null,e[65]=D,e[66]=ve):ve=e[66];let Ne;e[67]!==xe||e[68]!==ye||e[69]!==ve?(Ne=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":xe,onClick:ye,style:De,children:[Te,ve]}),e[67]=xe,e[68]=ye,e[69]=ve,e[70]=Ne):Ne=e[70];let H;e[71]!==se||e[72]!==oe||e[73]!==fe||e[74]!==Se||e[75]!==we||e[76]!==Ne?(H=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:U,children:t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[se,oe,fe,Se,we,Ne]})}),e[71]=se,e[72]=oe,e[73]=fe,e[74]=Se,e[75]=we,e[76]=Ne,e[77]=H):H=e[77];let pe;e[78]===Symbol.for("react.memo_cache_sentinel")?(pe=()=>f(!1),e[78]=pe):pe=e[78];let Ae;e[79]!==m?(Ae=t.jsx(em,{open:m,onClose:pe,anchorRef:g}),e[79]=m,e[80]=Ae):Ae=e[80];let We;return e[81]!==H||e[82]!==Ae?(We=t.jsxs(t.Fragment,{children:[H,Ae]}),e[81]=H,e[82]=Ae,e[83]=We):We=e[83],We};function im(n){return n.currentDirectory}function om(n){return n.currentSessionId}function am(n){return!!n.newSessionDraft?.open}function lm(n){return n.runOverviewKey}const cm=({onActiveConnectionDeleted:n,onConnect:e})=>{const{t:s}=he(),i=pa(e),{connections:r,isBusy:o,isPasswordBusy:a,error:l,pendingConnection:u,connect:m,submitPassword:f,cancelPassword:g,saveConnection:p,removeConnection:h,setError:x}=i,[v,b]=c.useState(null),C=v?r.find(K=>K.id===v)??null:null,[j,R]=c.useState(null),[T,D]=c.useState(""),[k,S]=c.useState(""),[y,E]=c.useState(""),[O,L]=c.useState(""),[z,A]=c.useState(!1),[_,B]=c.useState(!1),P=c.useRef(null),M=c.useMemo(()=>Pr(),[]),[$,I]=c.useState(!1),[U,X]=c.useState(null),[Q,ue]=c.useState(!1),se=sa(c.useCallback(()=>ue(!0),[])),te=c.useCallback(()=>{b(null),D(""),S(""),E(""),x(null),I(!1)},[x]),ge=c.useCallback(K=>{K.preventDefault(),p({id:v??void 0,url:T,label:k,clientToken:y}).then(oe=>{oe&&te()})},[y,v,k,te,p,T]),ee=c.useCallback(async()=>{if(P.current)return;x(null),A(!0);const K=new AbortController;P.current=K;try{const oe=await ya({signal:K.signal});switch(P.current===K&&(P.current=null,A(!1)),oe.status){case"ok":D(oe.url),oe.label&&S(oe.label),oe.clientToken&&E(oe.clientToken),I(!0);break;case"pairing":B(!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{B(!1),P.current===K&&(P.current=null,A(!1))}},[i,x,s]);c.useEffect(()=>()=>P.current?.abort(),[]);const G=c.useCallback(K=>{K.preventDefault(),f(O)},[O,f]),N=c.useCallback(()=>{L(""),g()},[g]),Y=c.useCallback(K=>{R(oe=>oe===K?null:K)},[]),ne=c.useCallback(K=>{R(null),v===K&&te();const oe=r.length===1;h(K).then(fe=>{fe&&(oe||Hi(fe))&&n()})},[r.length,v,n,h,te]),re=Ys;return u?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:G,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(q,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:u.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:u.candidates.some(K=>K.kind==="direct")?Tt(u):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...ys,value:O,onChange:K=>L(K.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:re}),l?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:l}):null,t.jsx(Ce,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:a||!O.trim(),children:s(a?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(Ce,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:N,children:s("mobile.connect.cancelPassword")})]})})}):t.jsxs(t.Fragment,{children:[z?t.jsx(va,{onCancel:()=>P.current?.abort()}):null,_?t.jsx(wa,{}):null,Q?t.jsx(ha,{onClose:()=>ue(!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",{...se,className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map(K=>{const oe=j===K.id,fe=Hi(K),Se=U===K.id,we=Se?s("mobile.connect.connecting"):fe?en()?s("mobile.instances.status.connectedRelay"):s("mobile.instances.status.connectedDirect"):K.candidates.some(xe=>xe.kind==="direct")?Tt(K):s("mobile.connect.relay.badge");return t.jsxs("div",{className:Z("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-start transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:opacity-60",onClick:()=>{fe||(X(K.id),m({id:K.id,candidates:K.candidates,clientToken:K.clientToken,label:K.label}).finally(()=>X(null)))},disabled:o&&!Se||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(q,{name:"server",className:"size-[18px]"}),fe?t.jsx("span",{className:"absolute -inset-e-0.5 -top-0.5 size-2.5 rounded-full border-2 border-[var(--surface-elevated)] bg-[var(--status-success)]","aria-hidden":!0}):null]}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:K.label}),t.jsx("span",{className:Z("block truncate typography-small",fe&&!Se?"text-[var(--status-success)]":"text-muted-foreground"),children:we})]}),Se?t.jsx(q,{name:"loader-4",className:"size-5 shrink-0 animate-spin text-muted-foreground"}):null]}),t.jsxs("div",{className:"flex items-center gap-0.5 pe-2",children:[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:()=>ne(K.id),style:{touchAction:"manipulation"},children:[t.jsx(q,{name:"delete-bin",className:"size-[18px]"}),t.jsx("span",{className:"typography-ui-label",children:s("mobile.instances.delete")})]}):K.candidates.some(xe=>xe.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:()=>{b(K.id),D(Tt(K)),S(K.label),E(K.clientToken||""),x(null)},style:{touchAction:"manipulation"},children:t.jsx(q,{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:()=>Y(K.id),style:{touchAction:"manipulation"},children:t.jsx(q,{name:oe?"close":"delete-bin",className:"size-[18px]"})})]})]},K.id)})}):t.jsx("p",{...se,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")}),!$&&!C?t.jsxs("div",{className:"space-y-2",children:[M?t.jsxs(Ce,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{ee()},disabled:z,children:[t.jsx(q,{name:"scan-2",className:Z("size-[18px]",z&&"animate-pulse")}),s("mobile.connect.scanQr")]}):null,t.jsxs(Ce,{type:"button",variant:M?"ghost":"outline",size:"lg",className:"h-12 w-full",onClick:()=>{x(null),I(!0)},children:[t.jsx(q,{name:"add",className:"size-[18px]"}),s("mobile.instances.addManual")]}),l?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):null]}):t.jsxs("form",{className:"space-y-3",onSubmit:ge,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(C?"mobile.instances.editTitle":"mobile.instances.addTitle")}),t.jsx(Ce,{type:"button",variant:"ghost",size:"xs",onClick:te,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",{...ys,value:T,onChange:K=>D(K.target.value),placeholder:s("mobile.connect.url.placeholder"),type:"url",inputMode:"url",autoCapitalize:"none",className:re})]}),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:k,onChange:K=>S(K.target.value),placeholder:s("mobile.instances.label.placeholder"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,className:re})]}),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",{...ys,value:y,onChange:K=>E(K.target.value),placeholder:s("mobile.connect.token.placeholder"),autoCapitalize:"none",className:re}),t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")})]}),l?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:l}):null,t.jsx(Ce,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",children:s(C?"mobile.instances.saveEdit":"mobile.instances.saveNew")})]})]})})})]})},Ve=n=>on(n)??"",gr=n=>{const e=Ve(n);if(!e)return"";const s=e.split("/").filter(Boolean);return s[s.length-1]?.replace(/[-_]/g," ")||e},Xi=si(n=>({expandedParents:{},toggleParent:e=>n(s=>{const i={...s.expandedParents};return i[e]?delete i[e]:i[e]=!0,{expandedParents:i}})})),Rn=si()(Qo(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"})),Tr=si()(Qo(n=>({orderByProject:{},setWorktreeOrder:(e,s)=>n(i=>({orderByProject:{...i.orderByProject,[e]:s}}))}),{name:"mobile-worktree-order"})),Qi=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),um=(n,e)=>{if(!n||n.length===0)return e;const s=new Map(n.map((r,o)=>[Qi(r),o])),i=r=>s.get(Qi(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)},Js=n=>on(n)??"",dm=n=>{const e=n;return Js(e.directory??e.project?.worktree??null)},ka=({open:n,project:e,worktree:s,onClose:i,onDeleted:r})=>{const{t:o}=he(),a=Ao(),l=bs(_=>_.activeSessions),u=Me(_=>_.archiveSessions),m=zt(_=>_.currentDirectory),{git:f,sourceControl:g}=Un(),[p,h]=c.useState(!1),[x,v]=c.useState(!1),[b,C]=c.useState(!1),[j,R]=c.useState(null),[T,D]=c.useState(!1),k=Js(s?.path),S=typeof s?.branch=="string"&&s.branch.trim().length>0,y=c.useMemo(()=>{if(!k)return[];const _=new Map;for(const B of[...l,...a])dm(B)===k&&_.set(B.id,B);return Array.from(_.values())},[l,a,k]);c.useEffect(()=>{if(!n){h(!1),v(!1),C(!1),R(null),D(!1);return}if(!s?.path)return;let _=!1;return bl(s.path).then(B=>{_||(C(!!B?.isDirty),R(B?.upstream?.split("/")[0]?.trim()||null))}).catch(()=>{_||C(!!s.status?.isDirty)}),()=>{_=!0}},[n,s?.path,s?.status?.isDirty]);const E=c.useCallback(async _=>(await xl(e,_,{deleteRemoteBranch:S&&x,deleteLocalBranch:S&&p,remoteName:j??void 0,network:{git:f,sourceControl:g}}),Js(m)===k&&Js(e.path)&&zt.getState().setDirectory(Js(e.path),{showOverlay:!1}),!0),[m,p,x,f,S,e,j,g,k]),O=c.useCallback((_,B)=>{const P=yl(_),M=ce.loading(o("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:P}));vl(_.path),(async()=>{try{const $=await Zc({sessionIds:B,removeWorktree:()=>E(_),archiveSessions:u});if(!$.removed){ce.dismiss(M);return}const{failedIds:I}=$.archive;if(I.length>0){ce.error(I.length===1?o("sessions.sidebar.bulkActions.failedArchiveSingle",{count:I.length}):o("sessions.sidebar.bulkActions.failedArchivePlural",{count:I.length}),{id:M,description:o("sessions.sidebar.dialogs.deleteResult.tryAgain")});return}ce.success(o("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:P}),{id:M,description:o(S&&x?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed")}),r?.()}catch($){const I=$ instanceof An?$.message||o("sessions.sidebar.dialogs.deleteResult.tryAgain"):$ instanceof Nr||$ instanceof Ot&&!$.message.includes(" ")?o("gitView.publish.remoteNotGranted"):$ instanceof Error?$.message:o("sessions.sidebar.dialogs.deleteResult.tryAgain");ce.error(o("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:P}),{id:M,description:I})}finally{wl(_.path)}})()},[u,x,S,r,E,o]),L=()=>{!s||T||(O(s,y.map(_=>_.id)),i())};if(!s)return null;const z=s.branch||s.label||s.path,A=(_,B,P,M)=>t.jsxs("button",{type:"button",role:"switch","aria-checked":_,disabled:M,onClick:()=>B(!_),className:Z("flex w-full items-center justify-between gap-3 rounded-xl border border-border/70 px-3.5 py-3 text-start transition-colors","hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",M&&"pointer-events-none opacity-40"),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:P}),t.jsx("span",{className:Z("relative h-6 w-10 shrink-0 rounded-full transition-colors",_?"bg-primary":"bg-muted-foreground/30"),children:t.jsx("span",{className:Z("absolute top-0.5 size-5 rounded-full bg-white transition-transform",_?"translate-x-[1.125rem] rtl:-translate-x-[1.125rem]":"translate-x-0.5 rtl:-translate-x-0.5")})})]});return t.jsx(Po,{open:n,onClose:i,title:o("mobile.projectEdit.deleteWorktreeTitle"),footer:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Ce,{variant:"ghost",className:"flex-1",onClick:i,disabled:T,children:o("projectEditDialog.actions.cancel")}),t.jsx(Ce,{variant:"destructive",className:"flex-1",onClick:()=>{L()},disabled:T,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:z})}),b?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,y.length>0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("mobile.projectEdit.deleteWorktreeArchiveNote",{count:y.length})}):null,S?t.jsxs("div",{className:"flex flex-col gap-2",children:[A(p,h,o("mobile.projectEdit.deleteLocalBranch"),T),A(x,v,o("mobile.projectEdit.deleteRemoteBranch"),T||!j)]}):null]})})},$n=n=>{const e=de.c(20),{project:s,size:i}=n,r=i===void 0?"md":i,{currentTheme:o}=To(),a=s.icon?Do[s.icon]:null;let l;e[0]!==s.color?(l=_o(s.color),e[0]=s.color,e[1]=l):l=e[1];const u=l,m=r==="md"?"size-5":"size-3.5";let f;e[2]!==a||e[3]!==m||e[4]!==u?(f=a?t.jsx(q,{name:a,className:m,style:u?{color:u}:void 0}):t.jsx(Cr,{className:m,style:u?{color:u}:void 0}),e[2]=a,e[3]=m,e[4]=u,e[5]=f):f=e[5];const g=f;let p;e[6]!==o||e[7]!==g||e[8]!==s.iconImage||e[9]!==s.id?(p=s.iconImage?t.jsx(Mo,{project:{id:s.id,iconImage:s.iconImage??null},options:{themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},className:"size-full object-contain",fallback:g}):null,e[6]=o,e[7]=g,e[8]=s.iconImage,e[9]=s.id,e[10]=p):p=e[10];const h=p;let x;e[11]!==s.iconBackground?(x=s.iconBackground?{backgroundColor:s.iconBackground}:void 0,e[11]=s.iconBackground,e[12]=x):x=e[12];const v=x;if(r==="md"){let j;return e[13]!==g||e[14]!==h||e[15]!==v?(j=t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground",children:h?t.jsx("span",{className:"flex size-6 items-center justify-center overflow-hidden rounded-md",style:v,children:h}):g}),e[13]=g,e[14]=h,e[15]=v,e[16]=j):j=e[16],j}const b=h??g;let C;return e[17]!==v||e[18]!==b?(C=t.jsx("span",{className:"flex size-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px] text-muted-foreground",style:v,children:b}),e[17]=v,e[18]=b,e[19]=C):C=e[19],C},Sa=n=>{const e=de.c(57),{initialTitle:s,indent:i,className:r,aiRename:o,onSubmit:a,onCancel:l}=n,{t:u}=he(),[m,f]=c.useState(s),g=fm;let p;e[0]!==s||e[1]!==l||e[2]!==a||e[3]!==m?(p=()=>{const Q=m.trim();if(!Q||Q===s.trim()){l();return}a(Q)},e[0]=s,e[1]=l,e[2]=a,e[3]=m,e[4]=p):p=e[4];const h=p;let x;e[5]!==r?(x=Z("flex h-9 min-w-0 flex-1 items-center gap-2 pe-2",r),e[5]=r,e[6]=x):x=e[6];let v;e[7]!==i?(v={paddingInlineStart:i},e[7]=i,e[8]=v):v=e[8];let b;e[9]!==h?(b=Q=>{Q.preventDefault(),h()},e[9]=h,e[10]=b):b=e[10];let C;e[11]===Symbol.for("react.memo_cache_sentinel")?(C=Q=>f(Q.target.value),e[11]=C):C=e[11];let j;e[12]!==l?(j=Q=>eu(Q,l),e[12]=l,e[13]=j):j=e[13];let R;e[14]!==u?(R=u("sessions.sidebar.session.rename.save"),e[14]=u,e[15]=R):R=e[15];let T;e[16]!==u?(T=u("sessions.sidebar.session.menu.rename"),e[16]=u,e[17]=T):T=e[17];let D;e[18]===Symbol.for("react.memo_cache_sentinel")?(D={minHeight:0},e[18]=D):D=e[18];let k;e[19]!==j||e[20]!==R||e[21]!==T||e[22]!==m?(k=t.jsx("input",{ref:g,value:m,onChange:C,onKeyDown:j,"aria-label":R,placeholder:T,className:"min-w-0 flex-1 bg-transparent text-[16px] typography-ui-label text-foreground outline-none placeholder:text-muted-foreground",style:D,enterKeyHint:"done"}),e[19]=j,e[20]=R,e[21]=T,e[22]=m,e[23]=k):k=e[23];const S=o.disabled;let y;e[24]!==o||e[25]!==l?(y=()=>{o.run(),l()},e[24]=o,e[25]=l,e[26]=y):y=e[26];let E;e[27]!==u?(E=u("sessions.aiRename.action"),e[27]=u,e[28]=E):E=e[28];let O,L;e[29]===Symbol.for("react.memo_cache_sentinel")?(O={touchAction:"manipulation",minHeight:0,minWidth:0},L=t.jsx(q,{name:"ai-generate-2",className:"size-4"}),e[29]=O,e[30]=L):(O=e[29],L=e[30]);let z;e[31]!==o.disabled||e[32]!==o.hint||e[33]!==y||e[34]!==E?(z=t.jsx("button",{type:"button",disabled:S,onClick:y,"aria-label":E,"aria-description":o.hint,title:o.hint,className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground disabled:opacity-40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:O,children:L}),e[31]=o.disabled,e[32]=o.hint,e[33]=y,e[34]=E,e[35]=z):z=e[35];let A;e[36]!==u?(A=u("sessions.sidebar.session.rename.save"),e[36]=u,e[37]=A):A=e[37];let _,B;e[38]===Symbol.for("react.memo_cache_sentinel")?(_={touchAction:"manipulation",minHeight:0,minWidth:0},B=t.jsx(q,{name:"check",className:"size-4"}),e[38]=_,e[39]=B):(_=e[38],B=e[39]);let P;e[40]!==A?(P=t.jsx("button",{type:"submit","aria-label":A,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:_,children:B}),e[40]=A,e[41]=P):P=e[41];let M;e[42]!==u?(M=u("sessions.sidebar.session.rename.cancel"),e[42]=u,e[43]=M):M=e[43];let $,I;e[44]===Symbol.for("react.memo_cache_sentinel")?($={touchAction:"manipulation",minHeight:0,minWidth:0},I=t.jsx(q,{name:"close",className:"size-4"}),e[44]=$,e[45]=I):($=e[44],I=e[45]);let U;e[46]!==l||e[47]!==M?(U=t.jsx("button",{type:"button",onClick:l,"aria-label":M,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:$,children:I}),e[46]=l,e[47]=M,e[48]=U):U=e[48];let X;return e[49]!==k||e[50]!==z||e[51]!==x||e[52]!==P||e[53]!==U||e[54]!==v||e[55]!==b?(X=t.jsxs("form",{className:x,style:v,onSubmit:b,children:[k,z,P,U]}),e[49]=k,e[50]=z,e[51]=x,e[52]=P,e[53]=U,e[54]=v,e[55]=b,e[56]=X):X=e[56],X};function fm(n){n&&(n.focus(),n.select())}const sn=48,Na=4*sn,mm=180,Wn=n=>{const e=de.c(32),{actionsWidth:s,actions:i,revealed:r,onRevealedChange:o,dataActiveSession:a,contentClassName:l,children:u}=n,m=l===void 0?"relative flex w-full items-center bg-background":l,{direction:f}=he(),g=f==="rtl"?-1:1,p=c.useRef(null),h=c.useRef(null),x=c.useRef(!1),v=c.useRef(0),b=c.useRef(r);let C;e[0]!==g?(C=($,I)=>{const U=p.current;U&&(U.style.transition=I?`transform ${mm}ms ease-out`:"none",U.style.transform=$===0?"none":`translateX(${$*g}px)`,v.current=$)},e[0]=g,e[1]=C):C=e[1];const j=C;let R,T;e[2]!==s||e[3]!==j||e[4]!==r?(R=()=>{b.current=r,j(r?s:0,!0)},T=[s,j,r],e[2]=s,e[3]=j,e[4]=r,e[5]=R,e[6]=T):(R=e[5],T=e[6]),c.useEffect(R,T);let D;e[7]===Symbol.for("react.memo_cache_sentinel")?(D=$=>{if($.touches.length!==1)return;const I=$.touches[0];h.current={x:I.clientX,y:I.clientY},x.current=!1},e[7]=D):D=e[7];const k=D;let S;e[8]!==s||e[9]!==j||e[10]!==g?(S=$=>{if(!h.current)return;const I=$.touches[0],U=(I.clientX-h.current.x)*g,X=I.clientY-h.current.y;if(!x.current){if(Math.abs(U)<8||Math.abs(U)<=Math.abs(X))return;x.current=!0}const Q=b.current?s:0;j(Math.max(0,Math.min(s,Q+U)),!1)},e[8]=s,e[9]=j,e[10]=g,e[11]=S):S=e[11];const y=S;let E;e[12]!==s||e[13]!==j||e[14]!==o?(E=()=>{if(h.current=null,!x.current)return;x.current=!1;const $=v.current>s/2;j($?s:0,!0),$!==b.current&&o($)},e[12]=s,e[13]=j,e[14]=o,e[15]=E):E=e[15];const O=E,L=a||void 0;let z;e[16]===Symbol.for("react.memo_cache_sentinel")?(z={touchAction:"pan-y"},e[16]=z):z=e[16];let A;e[17]!==s?(A={width:s},e[17]=s,e[18]=A):A=e[18];const _=!r;let B;e[19]!==i||e[20]!==A||e[21]!==_?(B=t.jsx("div",{className:"absolute inset-y-0 inset-s-0 flex items-stretch",style:A,"aria-hidden":_,children:i}),e[19]=i,e[20]=A,e[21]=_,e[22]=B):B=e[22];let P;e[23]!==u||e[24]!==m?(P=t.jsx("div",{ref:p,className:m,children:u}),e[23]=u,e[24]=m,e[25]=P):P=e[25];let M;return e[26]!==O||e[27]!==y||e[28]!==B||e[29]!==P||e[30]!==L?(M=t.jsxs("div",{"data-active-session":L,className:"relative overflow-hidden",onTouchStart:k,onTouchMove:y,onTouchEnd:O,onTouchCancel:O,style:z,children:[B,P]}),e[26]=O,e[27]=y,e[28]=B,e[29]=P,e[30]=L,e[31]=M):M=e[31],M},Ca=n=>{const e=de.c(62),{sessionId:s,title:i,revealed:r,confirmingDelete:o,onArchive:a,onRequestDelete:l,onConfirmDelete:u,onRequestRename:m,onRevealedChange:f,work:g,pin:p}=n,{t:h}=he(),x=r?0:-1;let v;e[0]!==f||e[1]!==s||e[2]!==h?(v=async()=>{if(!(await No(s).catch(pm))?.ok){Er.error(h("sessions.sidebar.session.copyId.error"));return}f?.(!1),Er.success(h("sessions.sidebar.session.copyId.success"))},e[0]=f,e[1]=s,e[2]=h,e[3]=v):v=e[3];const b=v;let C;e[4]!==h||e[5]!==i?(C=h("mobile.sessions.archiveSessionAria",{title:i}),e[4]=h,e[5]=i,e[6]=C):C=e[6];let j,R;e[7]===Symbol.for("react.memo_cache_sentinel")?(j={touchAction:"manipulation"},R=t.jsx(id,{className:"size-[18px]"}),e[7]=j,e[8]=R):(j=e[7],R=e[8]);let T;e[9]!==a||e[10]!==C||e[11]!==x?(T=t.jsx("button",{type:"button",tabIndex:x,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":C,onClick:a,style:j,children:R}),e[9]=a,e[10]=C,e[11]=x,e[12]=T):T=e[12];let D;e[13]!==f||e[14]!==p||e[15]!==h||e[16]!==x?(D=p?t.jsx("button",{type:"button",tabIndex:x,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":p.pinned?h("sessions.sidebar.session.menu.unpin"):h("sessions.sidebar.session.menu.pin"),onClick:()=>{p.onToggle(),f?.(!1)},style:{touchAction:"manipulation"},children:t.jsx(q,{name:p.pinned?"unpin":"pushpin",className:"size-[18px]"})}):null,e[13]=f,e[14]=p,e[15]=h,e[16]=x,e[17]=D):D=e[17];let k;e[18]!==f||e[19]!==h||e[20]!==x||e[21]!==g?(k=g?t.jsx("button",{type:"button",tabIndex:x,className:Z("flex flex-1 items-center justify-center transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",g.inWork?"text-status-success":"text-muted-foreground active:text-foreground"),"aria-label":g.inWork?h("sessions.sidebar.session.work.markDone"):h("sessions.sidebar.session.work.track"),onClick:()=>{g.onToggle(),f?.(!1)},style:{touchAction:"manipulation"},children:t.jsx(q,{name:g.inWork?"check":"eye",className:g.inWork?"size-5":"size-[18px]"})}):null,e[18]=f,e[19]=h,e[20]=x,e[21]=g,e[22]=k):k=e[22];const S=o?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80";let y;e[23]!==S?(y=Z("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",S),e[23]=S,e[24]=y):y=e[24];let E;e[25]!==o||e[26]!==h||e[27]!==i?(E=o?h("mobile.sessions.confirmDeleteSessionAria",{title:i}):h("mobile.sessions.deleteSessionAria",{title:i}),e[25]=o,e[26]=h,e[27]=i,e[28]=E):E=e[28];const O=o?u:l;let L,z;e[29]===Symbol.for("react.memo_cache_sentinel")?(L={touchAction:"manipulation"},z=t.jsx(_n,{className:"size-[18px]"}),e[29]=L,e[30]=z):(L=e[29],z=e[30]);let A;e[31]!==E||e[32]!==O||e[33]!==y||e[34]!==x?(A=t.jsx("button",{type:"button",tabIndex:x,className:y,"aria-label":E,onClick:O,style:L,children:z}),e[31]=E,e[32]=O,e[33]=y,e[34]=x,e[35]=A):A=e[35];let _;e[36]!==h||e[37]!==i?(_=h("mobile.sessions.renameSessionAria",{title:i}),e[36]=h,e[37]=i,e[38]=_):_=e[38];let B,P;e[39]===Symbol.for("react.memo_cache_sentinel")?(B={touchAction:"manipulation"},P=t.jsx(Rr,{className:"size-[18px]"}),e[39]=B,e[40]=P):(B=e[39],P=e[40]);let M;e[41]!==m||e[42]!==_||e[43]!==x?(M=t.jsx("button",{type:"button",tabIndex:x,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":_,onClick:m,style:B,children:P}),e[41]=m,e[42]=_,e[43]=x,e[44]=M):M=e[44];let $;e[45]!==h?($=h("sessions.sidebar.session.menu.copyId"),e[45]=h,e[46]=$):$=e[46];let I;e[47]!==b?(I=()=>{b()},e[47]=b,e[48]=I):I=e[48];let U,X;e[49]===Symbol.for("react.memo_cache_sentinel")?(U={touchAction:"manipulation"},X=t.jsx(q,{name:"file-copy",className:"size-[18px]"}),e[49]=U,e[50]=X):(U=e[49],X=e[50]);let Q;e[51]!==$||e[52]!==I||e[53]!==x?(Q=t.jsx("button",{type:"button",tabIndex:x,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":$,onClick:I,style:U,children:X}),e[51]=$,e[52]=I,e[53]=x,e[54]=Q):Q=e[54];let ue;return e[55]!==A||e[56]!==M||e[57]!==Q||e[58]!==T||e[59]!==D||e[60]!==k?(ue=t.jsxs(t.Fragment,{children:[T,D,k,A,M,Q]}),e[55]=A,e[56]=M,e[57]=Q,e[58]=T,e[59]=D,e[60]=k,e[61]=ue):ue=e[61],ue};function pm(){return null}const vt=n=>n.parentID??null,kt=n=>{const e=n;return Ve(e.directory??e.project?.worktree??null)},Ra=n=>Ro(n),Hn=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))},hm=4,Ea=n=>{const e=de.c(4),{providerIDs:s}=n;let i;e[0]!==s?(i=s.slice(0,hm).map(gm),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=t.jsx("span",{className:"inline-flex shrink-0 items-center -space-x-1",children:i}),e[2]=i,e[3]=r):r=e[3],r};function gm(n){return t.jsx("span",{className:"inline-flex size-4 items-center justify-center rounded-full bg-background ring-1 ring-background",children:t.jsx(Co,{providerId:n,className:"size-3 opacity-80"})},n)}const Ia=n=>{const e=de.c(8),{session:s}=n,{t:i}=he(),r=jl(s);if(!r)return null;const o=kl[r.status];let a;e[0]!==i||e[1]!==o?(a=i(o),e[0]=i,e[1]=o,e[2]=a):a=e[2];const l=a,u=Sl[r.status];let m;e[3]!==u?(m={color:u},e[3]=u,e[4]=m):m=e[4];let f;return e[5]!==l||e[6]!==m?(f=t.jsx(q,{name:"target",className:"size-3.5 shrink-0",style:m,"aria-label":l}),e[5]=l,e[6]=m,e[7]=f):f=e[7],f},Aa=n=>{const e=de.c(9),{hasPermission:s,hasForm:i}=n,{t:r}=he();if(!s&&!i)return null;let o;e[0]!==s||e[1]!==r?(o=s?t.jsx("span",{className:"inline-flex shrink-0 items-center rounded bg-destructive/10 px-1 py-0.5 text-destructive","aria-label":r("sessions.sidebar.session.status.permissionRequired"),children:t.jsx(q,{name:"shield",className:"size-3"})}):null,e[0]=s,e[1]=r,e[2]=o):o=e[2];let a;e[3]!==i||e[4]!==r?(a=i?t.jsx("span",{className:"inline-flex shrink-0 items-center rounded bg-status-info/10 px-1 py-0.5 text-status-info","aria-label":r("sessions.sidebar.session.status.questionPending"),children:t.jsx(q,{name:"question",className:"size-3"})}):null,e[3]=i,e[4]=r,e[5]=a):a=e[5];let l;return e[6]!==o||e[7]!==a?(l=t.jsxs(t.Fragment,{children:[o,a]}),e[6]=o,e[7]=a,e[8]=l):l=e[8],l},Pa=n=>{const e=de.c(7);let s;e[0]!==n?(s=l=>n.some(u=>!!l.bySession.get(u)?.permissions.length),e[0]=n,e[1]=s):s=e[1];const i=Ri(s);let r;e[2]!==n?(r=l=>n.some(u=>!!l.bySession.get(u)?.forms.length),e[2]=n,e[3]=r):r=e[3];const o=Ri(r);let a;return e[4]!==o||e[5]!==i?(a={hasPermission:i,hasForm:o},e[4]=o,e[5]=i,e[6]=a):a=e[6],a},nn=12,Dr="flex min-w-0 flex-1 flex-col gap-1 py-2.5 pe-3 text-start",Ta="flex h-4 min-w-0 items-center gap-1.5 text-muted-foreground",Da=n=>{const e=de.c(5),{project:s}=n;let i;e[0]!==s?(i=t.jsx($n,{project:s,size:"xs"}),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==s.label||e[3]!==i?(r=t.jsx("span",{role:"img","aria-label":s.label,className:"inline-flex shrink-0",children:i}),e[2]=s.label,e[3]=i,e[4]=r):r=e[4],r},bm=n=>{const e=de.c(52),{entry:s,showProject:i}=n,{t:r}=he(),{run:o,project:a}=s;let l;e[0]!==o.key?(l=I=>I.runOverviewKey===o.key,e[0]=o.key,e[1]=l):l=e[1];const u=Fe(l);let m;e[2]!==s.laneNodes?(m={nodes:s.laneNodes,includeUnreadSubtasks:!1},e[2]=s.laneNodes,e[3]=m):m=e[3];const f=Ko(m);let g;e[4]!==o.lastActivity?(g=Hn(o.lastActivity),e[4]=o.lastActivity,e[5]=g):g=e[5];const p=g,h=o.lanes.length,x=u||void 0,v=u&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let b;e[6]!==v?(b=Z("relative bg-background transition-colors",v),e[6]=v,e[7]=b):b=e[7];let C,j;e[8]===Symbol.for("react.memo_cache_sentinel")?(C=Z(Dr,"w-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"),j={paddingInlineStart:nn,touchAction:"manipulation"},e[8]=C,e[9]=j):(C=e[8],j=e[9]);let R;e[10]!==o.key?(R=()=>Fe.getState().setRunOverviewKey(o.key),e[10]=o.key,e[11]=R):R=e[11];let T;e[12]!==o.title||e[13]!==r?(T=r("sessions.sidebar.run.openOverviewAria",{title:o.title}),e[12]=o.title,e[13]=r,e[14]=T):T=e[14];const D=u?"text-primary":"text-foreground";let k;e[15]!==D?(k=Z("block min-w-0 flex-1 truncate oc-ui-start-align typography-ui-label",D),e[15]=D,e[16]=k):k=e[16];let S;e[17]!==o.title||e[18]!==k?(S=t.jsx("span",{dir:"auto",className:k,children:o.title}),e[17]=o.title,e[18]=k,e[19]=S):S=e[19];let y;e[20]!==f?(y=f?t.jsx(Ho,{state:f}):null,e[20]=f,e[21]=y):y=e[21];let E;e[22]!==p?(E=p?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:p}):null,e[22]=p,e[23]=E):E=e[23];let O;e[24]!==S||e[25]!==y||e[26]!==E?(O=t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[S,y,E]}),e[24]=S,e[25]=y,e[26]=E,e[27]=O):O=e[27];let L;e[28]!==a||e[29]!==i?(L=i?t.jsx(Da,{project:a}):null,e[28]=a,e[29]=i,e[30]=L):L=e[30];let z;e[31]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx(zo,{className:"size-3.5 shrink-0","aria-hidden":"true"}),e[31]=z):z=e[31];let A;e[32]!==h||e[33]!==r?(A=h===1?r("sessions.sidebar.run.laneCountSingle",{count:h}):r("sessions.sidebar.run.laneCountPlural",{count:h}),e[32]=h,e[33]=r,e[34]=A):A=e[34];let _;e[35]!==A?(_=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-micro",children:A}),e[35]=A,e[36]=_):_=e[36];let B;e[37]!==o.providerIDs?(B=t.jsx(Ea,{providerIDs:o.providerIDs}),e[37]=o.providerIDs,e[38]=B):B=e[38];let P;e[39]!==L||e[40]!==_||e[41]!==B?(P=t.jsxs("span",{className:Ta,children:[L,z,_,B]}),e[39]=L,e[40]=_,e[41]=B,e[42]=P):P=e[42];let M;e[43]!==T||e[44]!==O||e[45]!==P||e[46]!==R?(M=t.jsxs("button",{type:"button",className:C,style:j,onClick:R,"aria-label":T,children:[O,P]}),e[43]=T,e[44]=O,e[45]=P,e[46]=R,e[47]=M):M=e[47];let $;return e[48]!==M||e[49]!==x||e[50]!==b?($=t.jsx("div",{"data-active-session":x,className:b,children:M}),e[48]=M,e[49]=x,e[50]=b,e[51]=$):$=e[51],$},xm=n=>{const e=de.c(120),{entry:s,showProject:i,active:r,revealed:o,confirmingDelete:a,renaming:l,handlers:u}=n,{t:m}=he(),{session:f,project:g,branch:p,inSpace:h}=s;let x;e[0]!==f.title||e[1]!==m?(x=f.title?.trim()||m("mobile.sessions.untitled"),e[0]=f.title,e[1]=m,e[2]=x):x=e[2];const v=x;let b;e[3]!==f?(b=Hn(Ra(f)),e[3]=f,e[4]=b):b=e[4];const C=b,j=qo(f.id,f.directory,o||l),R=Br(f.id),T=Lr(f.id),D=T!==null,k=!D&&R>0&&!r,S=Fr(f.id,D),y=(D||k)&&S,E=u.onToggleWork;let O;e[5]!==f?(O=Oo(f),e[5]=f,e[6]=O):O=e[6];const L=O;let z;e[7]!==L||e[8]!==E||e[9]!==f?(z=E?{inWork:L,onToggle:()=>E(f,L)}:void 0,e[7]=L,e[8]=E,e[9]=f,e[10]=z):z=e[10];const A=z;let _;e[11]!==u||e[12]!==f?(_=u.isPinned(f),e[11]=u,e[12]=f,e[13]=_):_=e[13];const B=_;let P;e[14]!==u||e[15]!==f?(P=()=>u.onTogglePin(f),e[14]=u,e[15]=f,e[16]=P):P=e[16];let M;e[17]!==B||e[18]!==P?(M={pinned:B,onToggle:P},e[17]=B,e[18]=P,e[19]=M):M=e[19];const $=M,{descendantIdsOf:I}=u;let U;e[20]!==I||e[21]!==f.id?(U=[f.id,...I(f.id)],e[20]=I,e[21]=f.id,e[22]=U):U=e[22];const Q=Pa(U),ue=Na+sn+(A?sn:0);let se;e[23]!==u||e[24]!==f.id?(se=fe=>u.onRevealedChange(f.id,fe),e[23]=u,e[24]=f.id,e[25]=se):se=e[25];const te=r&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let ge;e[26]!==te?(ge=Z("relative flex w-full items-center bg-background transition-colors",te),e[26]=te,e[27]=ge):ge=e[27];let ee;e[28]!==u||e[29]!==f?(ee=()=>u.onArchive(f),e[28]=u,e[29]=f,e[30]=ee):ee=e[30];let G;e[31]!==u||e[32]!==f.id?(G=()=>u.onRequestDelete(f.id),e[31]=u,e[32]=f.id,e[33]=G):G=e[33];let N;e[34]!==u||e[35]!==f?(N=()=>u.onConfirmDelete(f),e[34]=u,e[35]=f,e[36]=N):N=e[36];let Y,ne;e[37]!==u||e[38]!==f.id?(Y=()=>u.onRequestRename(f.id),ne=fe=>u.onRevealedChange(f.id,fe),e[37]=u,e[38]=f.id,e[39]=Y,e[40]=ne):(Y=e[39],ne=e[40]);let re;e[41]!==a||e[42]!==$||e[43]!==o||e[44]!==f.id||e[45]!==ee||e[46]!==G||e[47]!==N||e[48]!==Y||e[49]!==ne||e[50]!==v||e[51]!==A?(re=t.jsx(Ca,{sessionId:f.id,title:v,revealed:o,confirmingDelete:a,onArchive:ee,onRequestDelete:G,onConfirmDelete:N,onRequestRename:Y,onRevealedChange:ne,work:A,pin:$}),e[41]=a,e[42]=$,e[43]=o,e[44]=f.id,e[45]=ee,e[46]=G,e[47]=N,e[48]=Y,e[49]=ne,e[50]=v,e[51]=A,e[52]=re):re=e[52];let K;e:{let fe;e[53]!==B||e[54]!==m?(fe=B?t.jsx(q,{name:"pushpin",className:"size-3 shrink-0 text-muted-foreground","aria-label":m("sessions.sidebar.session.status.pinned")}):null,e[53]=B,e[54]=m,e[55]=fe):fe=e[55];let Se;e[56]!==j.pending||e[57]!==D||e[58]!==k||e[59]!==m||e[60]!==T?(Se=j.pending?t.jsx(q,{name:"loader-4",className:"size-3 shrink-0 animate-spin text-primary","aria-label":m("sessions.aiRename.generating")}):D||k?t.jsx(Dn,{state:T??"unread"}):null,e[56]=j.pending,e[57]=D,e[58]=k,e[59]=m,e[60]=T,e[61]=Se):Se=e[61];let we;e[62]!==D||e[63]!==f.id||e[64]!==y||e[65]!==C?(we=y?t.jsx($r,{sessionId:f.id,running:D,className:"shrink-0 typography-micro"}):C?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:C}):null,e[62]=D,e[63]=f.id,e[64]=y,e[65]=C,e[66]=we):we=e[66];let xe;e[67]!==fe||e[68]!==Se||e[69]!==we?(xe=t.jsxs(t.Fragment,{children:[fe,Se,we]}),e[67]=fe,e[68]=Se,e[69]=we,e[70]=xe):xe=e[70];const ye=xe;let De;e[71]!==r||e[72]!==j||e[73]!==u||e[74]!==l||e[75]!==f.id||e[76]!==ye||e[77]!==v?(De=l?t.jsx(Sa,{initialTitle:v,indent:0,aiRename:j,className:"h-[1lh] pe-0 typography-ui-label [&_button]:size-6 [&_button>svg]:size-3.5",onSubmit:mt=>u.onSubmitRename(f.id,mt),onCancel:u.onCancelRename}):t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{dir:"auto",className:Z("block min-w-0 flex-1 truncate oc-ui-start-align typography-ui-label",r?"text-primary":"text-foreground"),children:v}),ye]}),e[71]=r,e[72]=j,e[73]=u,e[74]=l,e[75]=f.id,e[76]=ye,e[77]=v,e[78]=De):De=e[78];let Te;e[79]!==g||e[80]!==i?(Te=i?t.jsx(Da,{project:g}):null,e[79]=g,e[80]=i,e[81]=Te):Te=e[81];let ve;e[82]!==p||e[83]!==h||e[84]!==m?(ve=p?t.jsxs(t.Fragment,{children:[h?t.jsx(q,{name:"box-3",className:"size-3.5 shrink-0","aria-hidden":!1,role:"img","aria-label":m("sessions.sidebar.group.space")}):t.jsx(q,{name:"git-branch",className:"size-3.5 shrink-0"}),t.jsx("span",{className:"block min-w-0 truncate typography-micro",children:p})]}):null,e[82]=p,e[83]=h,e[84]=m,e[85]=ve):ve=e[85];let Ne;e[86]!==f?(Ne=t.jsx(Ia,{session:f}),e[86]=f,e[87]=Ne):Ne=e[87];let H;e[88]!==Q?(H=t.jsx(Aa,{...Q}),e[88]=Q,e[89]=H):H=e[89];let pe;e[90]!==Ne||e[91]!==H?(pe=t.jsxs("span",{className:"ms-auto flex shrink-0 items-center gap-1.5",children:[Ne,H]}),e[90]=Ne,e[91]=H,e[92]=pe):pe=e[92];let Ae;e[93]!==Te||e[94]!==ve||e[95]!==pe?(Ae=t.jsxs("span",{className:Ta,children:[Te,ve,pe]}),e[93]=Te,e[94]=ve,e[95]=pe,e[96]=Ae):Ae=e[96];let We;e[97]!==De||e[98]!==Ae?(We=t.jsxs(t.Fragment,{children:[De,Ae]}),e[97]=De,e[98]=Ae,e[99]=We):We=e[99];const Re=We;if(l){let mt;e[100]===Symbol.for("react.memo_cache_sentinel")?(mt={paddingInlineStart:nn},e[100]=mt):mt=e[100];let wt;e[101]!==Re?(wt=t.jsx("div",{className:Dr,style:mt,children:Re}),e[101]=Re,e[102]=wt):wt=e[102],K=wt;break e}let Le,qe;e[103]===Symbol.for("react.memo_cache_sentinel")?(Le=Z(Dr,"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"),qe={paddingInlineStart:nn,touchAction:"manipulation"},e[103]=Le,e[104]=qe):(Le=e[103],qe=e[104]);let $e;e[105]!==u||e[106]!==o||e[107]!==f?($e=()=>{if(o){u.onRevealedChange(f.id,!1);return}u.onSelect(f)},e[105]=u,e[106]=o,e[107]=f,e[108]=$e):$e=e[108];let tt;e[109]!==Re||e[110]!==$e?(tt=t.jsx("button",{type:"button",className:Le,style:qe,onClick:$e,children:Re}),e[109]=Re,e[110]=$e,e[111]=tt):tt=e[111],K=tt}let oe;return e[112]!==r||e[113]!==o||e[114]!==se||e[115]!==ge||e[116]!==re||e[117]!==K||e[118]!==ue?(oe=t.jsx(Wn,{actionsWidth:ue,revealed:o,onRevealedChange:se,dataActiveSession:r,contentClassName:ge,actions:re,children:K}),e[112]=r,e[113]=o,e[114]=se,e[115]=ge,e[116]=re,e[117]=K,e[118]=ue,e[119]=oe):oe=e[119],oe},Zi=n=>{const e=de.c(9),{entries:s,showProject:i,handlers:r}=n;let o;if(e[0]!==s||e[1]!==r||e[2]!==i){let l;e[4]!==r||e[5]!==i?(l=u=>u.kind==="run"?t.jsx(bm,{entry:u,showProject:i},`run:${u.run.key}`):t.jsx(xm,{entry:u,showProject:i,active:r.currentSessionId===u.session.id,revealed:r.revealedSessionId===u.session.id,confirmingDelete:r.confirmingDeleteSessionId===u.session.id,renaming:r.renamingSessionId===u.session.id,handlers:r},u.session.id),e[4]=r,e[5]=i,e[6]=l):l=e[6],o=s.map(l),e[0]=s,e[1]=r,e[2]=i,e[3]=o}else o=e[3];let a;return e[7]!==o?(a=t.jsx(t.Fragment,{children:o}),e[7]=o,e[8]=a):a=e[8],a},eo="mobile-surface-root",br=16,En=200,ym=()=>{if(typeof document>"u")return null;let n=document.getElementById(eo);return n||(n=document.createElement("div"),n.id=eo,document.body.appendChild(n)),n},Pt=({open:n,onClose:e,title:s,subtitle:i,trailing:r,disableEscapeDismiss:o=!1,headerless:a=!1,noHeaderBorder:l=!1,ariaLabel:u,variant:m="fullscreen",dialogAlign:f="chat",children:g})=>{const{t:p,direction:h}=he(),x=c.useRef(null),[v,b]=c.useState(!1),[C,j]=c.useState(!1),R=c.useRef(null),T=c.useRef(null),D=c.useRef(e);if(c.useEffect(()=>{D.current=e},[e]),typeof document<"u"&&!x.current&&(x.current=ym()),c.useEffect(()=>{if(!n){b(!1);return}const y=window.setTimeout(()=>b(!0),br);return()=>window.clearTimeout(y)},[n]),c.useEffect(()=>{if(!n){j(!1);return}const y=window.setTimeout(()=>j(!0),br+En+80);return()=>window.clearTimeout(y)},[n]),c.useEffect(()=>{if(!n)return;const y=document.body.style.overflow;T.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow="hidden";const E=()=>{const z=R.current;if(!z)return;(z.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??z).focus({preventScroll:!0})},O=window.setTimeout(E,br),L=z=>{if(z.key==="Escape"&&!o){D.current();return}if(z.key!=="Tab")return;const A=R.current;if(!A)return;const _=Array.from(A.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter($=>!$.hasAttribute("disabled")&&$.getAttribute("aria-hidden")!=="true");if(_.length===0){z.preventDefault(),A.focus({preventScroll:!0});return}const B=_[0],P=_[_.length-1],M=document.activeElement;z.shiftKey&&M===B?(z.preventDefault(),P.focus({preventScroll:!0})):!z.shiftKey&&M===P&&(z.preventDefault(),B.focus({preventScroll:!0}))};return document.addEventListener("keydown",L),()=>{window.clearTimeout(O),document.body.style.overflow=y,document.removeEventListener("keydown",L),T.current?.focus?.({preventScroll:!0}),T.current=null}},[o,n]),!n||!x.current)return null;const k=m==="dialog",S=t.jsxs("section",{ref:R,role:"dialog","aria-modal":"true","aria-label":u,tabIndex:-1,className:Z("flex flex-col bg-background text-foreground",k?"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:k?{opacity:v?1:0,transform:v?"none":"scale(0.97)",transition:`opacity ${En}ms ease-out, transform ${En}ms cubic-bezier(0.32, 0.72, 0, 1)`}:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:v?"none":h==="rtl"?"translateX(-100%)":"translateX(100%)",transition:`transform ${En}ms cubic-bezier(0.32, 0.72, 0, 1)`},onTransitionEnd:y=>{v&&y.target===y.currentTarget&&y.propertyName==="transform"&&j(!0)},children:[a?null:t.jsxs("header",{className:Z("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",!l&&"border-b border-border/70"),children:[t.jsx("button",{type:"button",className:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":p("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(q,{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:C?t.jsx("div",{className:"h-full",style:{animation:"oc-surface-content-in 200ms ease-out"},children:g}):null}),t.jsx("style",{children:"@keyframes oc-surface-content-in { from { opacity: 0 } to { opacity: 1 } }"})]});return k?vs.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:v?1:0,paddingLeft:f==="chat"?"max(1rem, var(--oc-chat-inset-left, 0px))":"1rem",paddingRight:f==="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:y=>y.stopPropagation(),children:S})}),x.current):vs.createPortal(S,x.current)},vm=n=>{const e=de.c(8),{projectPath:s}=n,{t:i}=he(),{journey:r}=Ha();let o;if(e[0]!==r||e[1]!==s||e[2]!==i){const a=r?Ya(r,s):[];let l;e[4]!==i?(l=i("mobile.projectEdit.spacesTitle"),e[4]=i,e[5]=l):l=e[5];let u;e[6]!==l?(u=t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:l}),e[6]=l,e[7]=u):u=e[7],o=t.jsxs("div",{className:"flex flex-col gap-2",children:[u,r!==null&&a.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i("spaces.page.empty")}):null,a.map(Sm)]}),e[0]=r,e[1]=s,e[2]=i,e[3]=o}else o=e[3];return o},wm=n=>on(n)??"",jm=n=>{const e=de.c(38),{worktree:s,onDelete:i}=n,{t:r}=he();let o;e[0]!==s.path?(o={id:s.path},e[0]=s.path,e[1]=o):o=e[1];const{attributes:a,listeners:l,setNodeRef:u,transform:m,transition:f,isDragging:g}=ei(o);let p;e[2]!==m?(p=ti.Transform.toString(m),e[2]=m,e[3]=p):p=e[3];const h=g?10:1;let x;e[4]!==p||e[5]!==h||e[6]!==f?(x={transform:p,transition:f,zIndex:h},e[4]=p,e[5]=h,e[6]=f,e[7]=x):x=e[7];const v=x,b=s.branch||s.label||s.path,C=Lo(s.path),j=g&&"shadow-lg shadow-black/20",R=C&&"opacity-60";let T;e[8]!==j||e[9]!==R?(T=Z("flex items-center gap-1 rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",j,R),e[8]=j,e[9]=R,e[10]=T):T=e[10];const D=C||void 0;let k;e[11]!==b||e[12]!==r?(k=r("mobile.projectEdit.dragWorktreeAria",{label:b}),e[11]=b,e[12]=r,e[13]=k):k=e[13];let S;e[14]===Symbol.for("react.memo_cache_sentinel")?(S=t.jsx(Ur,{className:"size-4"}),e[14]=S):S=e[14];let y;e[15]!==a||e[16]!==l||e[17]!==k?(y=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":k,...a,...l,children:S}),e[15]=a,e[16]=l,e[17]=k,e[18]=y):y=e[18];let E;e[19]!==C||e[20]!==r?(E=C?t.jsx("span",{className:"inline-flex shrink-0 text-muted-foreground",role:"status","aria-label":r("sessions.sidebar.group.worktreeRemoving"),children:t.jsx(q,{name:"loader-4",className:"size-4 animate-spin"})}):t.jsx(q,{name:"node-tree",className:"size-4 shrink-0 text-muted-foreground"}),e[19]=C,e[20]=r,e[21]=E):E=e[21];let O;e[22]!==b?(O=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:b}),e[22]=b,e[23]=O):O=e[23];let L;e[24]!==b||e[25]!==i||e[26]!==C||e[27]!==r?(L=C?null:t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive","aria-label":r("mobile.projectEdit.deleteWorktreeAria",{label:b}),onClick:i,style:{touchAction:"manipulation"},children:t.jsx(_n,{className:"size-4"})}),e[24]=b,e[25]=i,e[26]=C,e[27]=r,e[28]=L):L=e[28];let z;return e[29]!==u||e[30]!==v||e[31]!==y||e[32]!==E||e[33]!==O||e[34]!==L||e[35]!==T||e[36]!==D?(z=t.jsxs("div",{ref:u,style:v,className:T,"aria-busy":D,children:[y,E,O,L]}),e[29]=u,e[30]=v,e[31]=y,e[32]=E,e[33]=O,e[34]=L,e[35]=T,e[36]=D,e[37]=z):z=e[37],z},km=({open:n,project:e,onClose:s,onWorktreesChanged:i})=>{const{t:r}=he(),{currentTheme:o}=To(),a=Fe(M=>M.isolatedSpacesEnabled),l=rt(M=>M.updateProjectMeta),u=rt(M=>M.discoverProjectIcon),m=rt(M=>M.removeProjectIcon),f=Tr(M=>M.setWorktreeOrder),g=rt(M=>e?M.projects.find($=>$.id===e.id)?.iconImage??null:null),[p,h]=c.useState(""),[x,v]=c.useState(null),[b,C]=c.useState(null),[j,R]=c.useState(!1),[T,D]=c.useState([]),[k,S]=c.useState(null),y=e?.id??null;c.useEffect(()=>{!n||!e||(h(e.label),v(e.icon??null),C(e.color??null),D(e.worktrees))},[n,y]),c.useEffect(()=>{!n||!e||D(M=>{const $=e.worktrees.map(X=>X.path),I=M.map(X=>X.path);return $.length===I.length&&$.every(X=>I.includes(X))?M:e.worktrees})},[e?.worktrees]);const E=Kr(js(Hr,{activationConstraint:{distance:8}}),js(qr,{coordinateGetter:Xr})),O=()=>{if(!e)return;const $={label:p.trim()||e.label,icon:x,color:b};b!==(e.color??null)&&($.iconBackground=Rl(b)),l(e.id,$),s()},L=()=>{!e||j||(R(!0),u(e.id).then(M=>{if(!M.ok){ce.error(M.error||r("projectEditDialog.toast.failedToDiscoverIcon"));return}if(M.skipped){ce.success(r("projectEditDialog.toast.customIconAlreadySet"));return}ce.success(r("projectEditDialog.toast.iconDiscovered"))}).finally(()=>R(!1)))},z=()=>{e&&m(e.id).then(M=>{if(!M.ok){ce.error(M.error||r("projectEditDialog.toast.failedToRemoveIcon"));return}ce.success(r("projectEditDialog.toast.iconRemoved"))})},A=M=>{const{active:$,over:I}=M;if(!I||$.id===I.id||!e)return;const U=T.findIndex(se=>se.path===$.id),X=T.findIndex(se=>se.path===I.id);if(U<0||X<0)return;const Q=[...T],[ue]=Q.splice(U,1);Q.splice(X,0,ue),D(Q),f(e.id,Q.map(se=>wm(se.path)))},_=_o(b),B=x?Do[x]:null,P=!!g;return t.jsxs(t.Fragment,{children:[t.jsx(Pt,{open:n,onClose:s,title:r("projectEditDialog.title"),ariaLabel:r("projectEditDialog.title"),noHeaderBorder:!0,trailing:t.jsxs(Ce,{type:"button",variant:"default",size:"sm","aria-label":r("projectEditDialog.actions.save"),onClick:O,disabled:!p.trim(),style:{touchAction:"manipulation"},children:[t.jsx(Xo,{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:P?t.jsx(Mo,{project:{id:e.id,iconImage:g},options:{themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},className:"size-full object-contain",fallback:t.jsx(Cr,{className:"size-7"})}):B?t.jsx(q,{name:B,className:"size-7",style:_?{color:_}:void 0}):t.jsx(Cr,{className:"size-7",style:_?{color:_}: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(Bo,{value:p,onChange:M=>h(M.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:()=>C(null),"aria-label":r("projectEditDialog.option.none"),className:Z("flex size-9 items-center justify-center rounded-xl border-2 transition-all",b===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"})}),Nl.map(M=>t.jsx("button",{type:"button",onClick:()=>C(M),"aria-label":r("settings.projects.appearance.colorSwatchAria",{color:M}),title:M,className:Z("size-9 rounded-xl border-2 transition-all",b===M?"border-foreground":"border-transparent hover:border-border/70"),style:{backgroundColor:M,touchAction:"manipulation"}},M))]})]}),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:()=>v(null),"aria-label":r("projectEditDialog.option.none"),className:Z("flex size-9 items-center justify-center rounded-xl border-2 transition-all",x===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"})}),Cl.map(M=>t.jsx("button",{type:"button",onClick:()=>v(M.key),"aria-label":M.label,title:M.label,className:Z("flex size-9 items-center justify-center rounded-xl border-2 transition-all",x===M.key?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx(q,{name:M.Icon,className:"size-4",style:_?{color:_}:void 0})},M.key))]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[t.jsx(Ce,{size:"sm",variant:"outline",onClick:L,disabled:j,children:r(j?"projectEditDialog.actions.discovering":"projectEditDialog.actions.discoverFavicon")}),P?t.jsx(Ce,{size:"sm",variant:"outline",onClick:z,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")}),T.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(Yr,{sensors:E,collisionDetection:Jr,onDragEnd:A,children:t.jsx(Qr,{items:T.map(M=>M.path),strategy:Zr,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:T.map(M=>t.jsx(jm,{worktree:M,onDelete:()=>S(M)},M.path))})})})]})]}):null,e.isGitRepo&&a?t.jsx(vm,{projectPath:e.path}):null]}):null}),e?t.jsx(ka,{open:!!k,project:{id:e.id,path:e.path},worktree:k,onClose:()=>S(null),onDeleted:()=>{D(M=>M.filter($=>$.path!==k?.path)),i?.()}}):null]})};function Sm(n){return t.jsx(gd,{entry:n,actions:"sheet"},n.id)}const Nm=32,Cm=80,Rm=64,Em=.7,Im=140,Am=.4,Pm=(n,e,s)=>{const i=e.ownerDocument.defaultView;if(!i)return"drawer";let r=!1;for(let o=n instanceof i.Element?n:null;o&&o!==e;o=o.parentElement){const a=o.scrollWidth-o.clientWidth;if(a<=1)continue;const l=i.getComputedStyle(o);if(l.overflowX!=="auto"&&l.overflowX!=="scroll")continue;const u=l.direction==="rtl"?-a:0,m=u+a;if(s?o.scrollLeft>u+1:o.scrollLeft<m-1)return"content";r=!0}return r?"content-end":"drawer"},fi=(n,e)=>{const s=c.useRef(e);s.current=e;const i=e.enabled??!0;c.useEffect(()=>{if(!i)return;const r=n.current;if(!r)return;const a=window.Capacitor?.getPlatform?.()==="android"?Cm:Nm,l=r.ownerDocument;let u=!1,m=!1,f="drawer",g=0,p=0;const h=()=>l.getSelection()?.isCollapsed===!1,x=()=>{u=!1},v=()=>{u&&h()&&x()},b=j=>{if(j.touches.length!==1||h()){u=!1;return}const R=j.touches[0],T=r.clientWidth,D=R.clientX<=a,k=R.clientX>=T-a;m=D,f=D||k?Pm(j.target,r,m):"drawer",u=(D||k)&&f!=="content",g=R.clientX,p=R.clientY},C=j=>{if(!u||(u=!1,h()))return;const R=j.changedTouches[0];if(!R)return;const T=R.clientX-g,D=R.clientY-p,k=f==="content-end"?Im:Rm,S=f==="content-end"?Am:Em;Math.abs(T)<k||Math.abs(D)>Math.abs(T)*S||m&&T<=0||!m&&T>=0||(m?s.current.onLeftEdgeSwipe?.():s.current.onRightEdgeSwipe?.())};return r.addEventListener("touchstart",b,{passive:!0}),r.addEventListener("touchend",C,{passive:!0}),r.addEventListener("touchcancel",x,{passive:!0}),r.addEventListener("selectstart",x),l.addEventListener("selectionchange",v),()=>{r.removeEventListener("touchstart",b),r.removeEventListener("touchend",C),r.removeEventListener("touchcancel",x),r.removeEventListener("selectstart",x),l.removeEventListener("selectionchange",v)}},[i,n])},Tm=()=>globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0;function In(n){const e=de.c(11),{open:s,children:i}=n,[r,o]=c.useState(s);s&&!r&&o(!0);const a=c.useRef(null),l=c.useRef(null),u=c.useRef(s);let m,f;e[0]!==s?(m=()=>{const C=a.current;if(u.current===s||!C)return;if(u.current=s,Tm()){s||o(!1);return}const j=l.current||!s?C.getBoundingClientRect().height:0;l.current?.cancel();const R=s?C.scrollHeight:0;C.style.overflow="hidden";const T=C.animate([{height:`${j}px`,opacity:s?0:1},{height:`${R}px`,opacity:s?1:0}],{duration:su,easing:tu,fill:s?"none":"forwards"});l.current=T,T.finished.then(()=>{l.current===T&&(l.current=null,s?C.style.overflow="":o(!1))},Dm)},f=[s],e[0]=s,e[1]=m,e[2]=f):(m=e[1],f=e[2]),c.useLayoutEffect(m,f);let g,p;if(e[3]===Symbol.for("react.memo_cache_sentinel")?(g=()=>()=>l.current?.cancel(),p=[],e[3]=g,e[4]=p):(g=e[3],p=e[4]),c.useEffect(g,p),!r)return null;const h=!s||void 0,x=!s;let v;e[5]!==i?(v=i(),e[5]=i,e[6]=v):v=e[6];let b;return e[7]!==h||e[8]!==x||e[9]!==v?(b=t.jsx("div",{ref:a,"aria-hidden":h,inert:x,children:v}),e[7]=h,e[8]=x,e[9]=v,e[10]=b):b=e[10],b}function Dm(){}const _m=new Set,Mm=[["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"]],Om=[["projects","mobile.sessions.viewMode.projects"],["timeline","mobile.sessions.viewMode.timeline"]],qs=7,zm=3,Bm=32,mi=n=>Bm+n*12,Vn=n=>mi(n)+20,xr="openchamber:work",yr=12,Lm=(n,e)=>{const s=Ve(n),i=Ve(e),r=i.endsWith("/")?i:`${i}/`;return!!(s&&i&&(s===i||s.startsWith(r)))},vr=(n,e)=>n.worktrees.find(s=>Ve(s.path)===e)??null,wr=(n,e,s)=>Fo([n.title,n.id,kt(n),e],s),Fm=n=>{const e=de.c(3),{path:s,children:i}=n,r=Lo(s);let o;return e[0]!==i||e[1]!==r?(o=i(r),e[0]=i,e[1]=r,e[2]=o):o=e[2],o},$m=n=>{const e=de.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},to=n=>{const e=de.c(12),{onClick:s,className:i}=n,{t:r}=he();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 l;e[2]!==i?(l=Z("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]=l):l=e[3];let u;e[4]!==s?(u=p=>{p.stopPropagation(),s()},e[4]=s,e[5]=u):u=e[5];let m,f;e[6]===Symbol.for("react.memo_cache_sentinel")?(m={touchAction:"manipulation"},f=t.jsx(q,{name:"node-tree",className:"size-3.5"}),e[6]=m,e[7]=f):(m=e[6],f=e[7]);let g;return e[8]!==a||e[9]!==l||e[10]!==u?(g=t.jsx("button",{type:"button",className:l,"aria-label":a,title:a,onClick:u,style:m,children:f}),e[8]=a,e[9]=l,e[10]=u,e[11]=g):g=e[11],g},jr=n=>{const e=de.c(10),{label:s,onClick:i,className:r}=n;let o;e[0]!==r?(o=Z("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=f=>{f.stopPropagation(),i()},e[2]=i,e[3]=a):a=e[3];let l,u;e[4]===Symbol.for("react.memo_cache_sentinel")?(l={touchAction:"manipulation"},u=t.jsx(q,{name:"add",className:"size-4"}),e[4]=l,e[5]=u):(l=e[4],u=e[5]);let m;return e[6]!==s||e[7]!==o||e[8]!==a?(m=t.jsx("button",{type:"button",className:o,"aria-label":s,title:s,onClick:a,style:l,children:u}),e[6]=s,e[7]=o,e[8]=a,e[9]=m):m=e[9],m},so=n=>{const e=de.c(95),{session:s,active:i,indent:r,contextLabel:o,statusOnRight:a,treeDepth:l,hasChildren:u,expanded:m,onToggleChildren:f,onSelect:g,revealed:p,onRevealedChange:h,confirmingDelete:x,onArchive:v,onRequestDelete:b,onConfirmDelete:C,renaming:j,onRequestRename:R,onSubmitRename:T,onCancelRename:D,work:k,pin:S,descendantIdsOf:y}=n,E=a===void 0?!1:a,O=u===void 0?!1:u,L=m===void 0?!1:m,z=p===void 0?!1:p,A=x===void 0?!1:x,_=j===void 0?!1:j,{t:B}=he();let P;e[0]!==s?(P=Hn(Ra(s)),e[0]=s,e[1]=P):P=e[1];const M=P;let $;e[2]!==s.title||e[3]!==B?($=s.title?.trim()||B("mobile.sessions.untitled"),e[2]=s.title,e[3]=B,e[4]=$):$=e[4];const I=$,U=!!(h&&v),X=l!==void 0,Q=E||X;let ue;e[5]!==r||e[6]!==X||e[7]!==l?(ue=X?Vn(l):r,e[5]=r,e[6]=X,e[7]=l,e[8]=ue):ue=e[8];const se=ue,te=qo(s.id,s.directory,U&&(z||_)),ge=Br(s.id),ee=Lr(s.id),G=ee!==null,N=!G&&ge>0&&!i,Y=Fr(s.id,G),ne=(G||N)&&Y;let re;e[9]!==G||e[10]!==s||e[11]!==k?.inWork?(re=!!k?.inWork&&!G&&Ml(s),e[9]=G,e[10]=s,e[11]=k?.inWork,e[12]=re):re=e[12];const K=re;let oe;e[13]!==y||e[14]!==L||e[15]!==O||e[16]!==s.id?(oe=y&&!(O&&L)?[s.id,...y(s.id)]:[s.id],e[13]=y,e[14]=L,e[15]=O,e[16]=s.id,e[17]=oe):oe=e[17];const Se=Pa(oe);let we;e[18]!==L||e[19]!==O||e[20]!==X||e[21]!==f||e[22]!==B||e[23]!==l?(we=X&&O&&f?t.jsx("button",{type:"button",className:"absolute z-10 flex w-[30px] items-center justify-center text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:{insetInlineStart:mi(l)-8,top:0,bottom:0,touchAction:"manipulation"},"aria-label":B(L?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),"aria-expanded":L,onClick:Re=>{Re.stopPropagation(),f()},children:t.jsx(Yo,{expanded:L})}):null,e[18]=L,e[19]=O,e[20]=X,e[21]=f,e[22]=B,e[23]=l,e[24]=we):we=e[24];let xe;e[25]!==te||e[26]!==L||e[27]!==O||e[28]!==r||e[29]!==G||e[30]!==f||e[31]!==N||e[32]!==Q||e[33]!==B||e[34]!==ee?(xe=!Q&&(te.pending||G||N||O&&f)?t.jsx("button",{type:"button",className:"absolute z-10 flex w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:{insetInlineStart:Math.max(r-32,2),top:0,bottom:0,touchAction:"manipulation"},"aria-label":te.pending?B("sessions.aiRename.generating"):B(L?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),disabled:!O||!f,onClick:Re=>{Re.stopPropagation(),f?.()},children:te.pending?t.jsx(q,{name:"loader-4",className:"size-3 animate-spin text-primary","aria-label":B("sessions.aiRename.generating")}):G||N?t.jsx(Dn,{state:ee??"unread"}):t.jsx(Gr,{className:Z("size-[18px] transition-transform duration-150",L?"rotate-0":"-rotate-90 rtl:rotate-90")})}):null,e[25]=te,e[26]=L,e[27]=O,e[28]=r,e[29]=G,e[30]=f,e[31]=N,e[32]=Q,e[33]=B,e[34]=ee,e[35]=xe):xe=e[35];let ye;e[36]!==i||e[37]!==te||e[38]!==o||e[39]!==G||e[40]!==D||e[41]!==h||e[42]!==g||e[43]!==T||e[44]!==Se||e[45]!==S?.pinned||e[46]!==_||e[47]!==z||e[48]!==s||e[49]!==ne||e[50]!==K||e[51]!==N||e[52]!==Q||e[53]!==B||e[54]!==se||e[55]!==M||e[56]!==I||e[57]!==ee?(ye=_&&T&&D?t.jsx(Sa,{initialTitle:I,indent:se,aiRename:te,onSubmit:T,onCancel:D}):t.jsx("button",{type:"button",className:Z("flex min-w-0 flex-1 items-center gap-2.5 pe-3.5 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",o?"min-h-10 py-1":"h-9"),style:{paddingInlineStart:se,touchAction:"manipulation"},onClick:()=>{if(z){h?.(!1);return}g()},children:t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[t.jsxs("span",{className:"flex items-center gap-2.5",children:[t.jsx("span",{dir:"auto",className:Z("block min-w-0 flex-1 truncate oc-ui-start-align typography-ui-label",i?"text-primary":"text-foreground"),children:I}),S?.pinned?t.jsx(q,{name:"pushpin",className:"size-3 shrink-0 text-muted-foreground","aria-label":B("sessions.sidebar.session.status.pinned")}):null,Q&&(te.pending||G||N)?te.pending?t.jsx(q,{name:"loader-4",className:"size-3 shrink-0 animate-spin text-primary","aria-label":B("sessions.aiRename.generating")}):t.jsx(Dn,{state:ee??"unread"}):null,K?t.jsx(q,{name:"check",className:"size-3.5 shrink-0 text-muted-foreground","aria-label":B("sessions.sidebar.session.work.doneSuggested")}):null,t.jsx(Ia,{session:s}),t.jsx(Aa,{...Se}),ne?t.jsx($r,{sessionId:s.id,running:G,className:"typography-micro"}):M?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:M}):null]}),o?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:o}):null]})}),e[36]=i,e[37]=te,e[38]=o,e[39]=G,e[40]=D,e[41]=h,e[42]=g,e[43]=T,e[44]=Se,e[45]=S?.pinned,e[46]=_,e[47]=z,e[48]=s,e[49]=ne,e[50]=K,e[51]=N,e[52]=Q,e[53]=B,e[54]=se,e[55]=M,e[56]=I,e[57]=ee,e[58]=ye):ye=e[58];let De;e[59]!==we||e[60]!==xe||e[61]!==ye?(De=t.jsxs(t.Fragment,{children:[we,xe,ye]}),e[59]=we,e[60]=xe,e[61]=ye,e[62]=De):De=e[62];const Te=De;if(!U){const Re=i||void 0,Le=i&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let qe;e[63]!==Le?(qe=Z("relative flex items-center gap-1 transition-colors",Le),e[63]=Le,e[64]=qe):qe=e[64];let $e;e[65]!==Te||e[66]!==qe?($e=t.jsx("div",{className:qe,children:Te}),e[65]=Te,e[66]=qe,e[67]=$e):$e=e[67];let tt;return e[68]!==Re||e[69]!==$e?(tt=t.jsx("div",{"data-active-session":Re,className:"relative overflow-hidden",children:$e}),e[68]=Re,e[69]=$e,e[70]=tt):tt=e[70],tt}const ve=Na+(k?sn:0)+(S?sn:0);let Ne;e[71]!==h?(Ne=Re=>h?.(Re),e[71]=h,e[72]=Ne):Ne=e[72];const H=i&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let pe;e[73]!==H?(pe=Z("relative flex w-full items-center gap-1 bg-background transition-colors",H),e[73]=H,e[74]=pe):pe=e[74];let Ae;e[75]!==A||e[76]!==v||e[77]!==C||e[78]!==b||e[79]!==R||e[80]!==h||e[81]!==S||e[82]!==z||e[83]!==s.id||e[84]!==I||e[85]!==k?(Ae=t.jsx(Ca,{sessionId:s.id,title:I,revealed:z,confirmingDelete:A,onArchive:v,onRequestDelete:b,onConfirmDelete:C,onRequestRename:R,onRevealedChange:h,work:k,pin:S}),e[75]=A,e[76]=v,e[77]=C,e[78]=b,e[79]=R,e[80]=h,e[81]=S,e[82]=z,e[83]=s.id,e[84]=I,e[85]=k,e[86]=Ae):Ae=e[86];let We;return e[87]!==i||e[88]!==z||e[89]!==Te||e[90]!==ve||e[91]!==Ne||e[92]!==pe||e[93]!==Ae?(We=t.jsx(Wn,{actionsWidth:ve,revealed:z,onRevealedChange:Ne,dataActiveSession:i,contentClassName:pe,actions:Ae,children:Te}),e[87]=i,e[88]=z,e[89]=Te,e[90]=ve,e[91]=Ne,e[92]=pe,e[93]=Ae,e[94]=We):We=e[94],We},no=[],Wm=n=>{const e=de.c(41),{run:s,laneNodes:i,depth:r}=n,{t:o}=he();let a;e[0]!==s.key?(a=z=>z.runOverviewKey===s.key,e[0]=s.key,e[1]=a):a=e[1];const l=Fe(a);let u;e[2]!==i?(u={nodes:i,includeUnreadSubtasks:!1},e[2]=i,e[3]=u):u=e[3];const m=Ko(u);let f;e[4]!==s.lastActivity?(f=Hn(s.lastActivity),e[4]=s.lastActivity,e[5]=f):f=e[5];const g=f,p=l||void 0,h=l&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let x;e[6]!==h?(x=Z("relative flex items-center overflow-hidden transition-colors",h),e[6]=h,e[7]=x):x=e[7];let v;e[8]!==r?(v=Vn(r),e[8]=r,e[9]=v):v=e[9];let b;e[10]!==v?(b={paddingInlineStart:v,touchAction:"manipulation"},e[10]=v,e[11]=b):b=e[11];let C;e[12]!==s.key?(C=()=>Fe.getState().setRunOverviewKey(s.key),e[12]=s.key,e[13]=C):C=e[13];let j;e[14]!==s.title||e[15]!==o?(j=o("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[14]=s.title,e[15]=o,e[16]=j):j=e[16];let R;e[17]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx(zo,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[17]=R):R=e[17];const T=l?"text-primary":"text-foreground";let D;e[18]!==T?(D=Z("block min-w-0 flex-1 truncate oc-ui-start-align typography-ui-label",T),e[18]=T,e[19]=D):D=e[19];let k;e[20]!==s.title||e[21]!==D?(k=t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[R,t.jsx("span",{dir:"auto",className:D,children:s.title})]}),e[20]=s.title,e[21]=D,e[22]=k):k=e[22];let S;e[23]!==s.providerIDs?(S=t.jsx(Ea,{providerIDs:s.providerIDs}),e[23]=s.providerIDs,e[24]=S):S=e[24];let y;e[25]!==m?(y=m?t.jsx(Ho,{state:m}):null,e[25]=m,e[26]=y):y=e[26];let E;e[27]!==g?(E=g?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:g}):null,e[27]=g,e[28]=E):E=e[28];let O;e[29]!==j||e[30]!==k||e[31]!==S||e[32]!==y||e[33]!==E||e[34]!==b||e[35]!==C?(O=t.jsxs("button",{type:"button",className:"flex h-9 w-full min-w-0 items-center gap-2.5 pe-3.5 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:b,onClick:C,"aria-label":j,children:[k,S,y,E]}),e[29]=j,e[30]=k,e[31]=S,e[32]=y,e[33]=E,e[34]=b,e[35]=C,e[36]=O):O=e[36];let L;return e[37]!==O||e[38]!==p||e[39]!==x?(L=t.jsx("div",{"data-active-session":p,className:x,children:O}),e[37]=O,e[38]=p,e[39]=x,e[40]=L):L=e[40],L},ro=n=>{const e=de.c(11),{indent:s,onClick:i}=n,{t:r}=he();let o;e[0]!==s?(o={paddingInlineStart: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(Gr,{className:"size-4"}),e[2]=a):a=e[2];let l;e[3]!==r?(l=r("sessions.sidebar.group.showMore"),e[3]=r,e[4]=l):l=e[4];let u;e[5]!==l?(u=t.jsx("span",{className:"typography-micro",children:l}),e[5]=l,e[6]=u):u=e[6];let m;return e[7]!==i||e[8]!==o||e[9]!==u?(m=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pe-3 text-start text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:o,onClick:i,children:[a,u]}),e[7]=i,e[8]=o,e[9]=u,e[10]=m):m=e[10],m},io=n=>{const e=de.c(11),{indent:s,onClick:i}=n,{t:r}=he();let o;e[0]!==s?(o={paddingInlineStart: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(ad,{className:"size-4"}),e[2]=a):a=e[2];let l;e[3]!==r?(l=r("sessions.sidebar.group.showFewer"),e[3]=r,e[4]=l):l=e[4];let u;e[5]!==l?(u=t.jsx("span",{className:"typography-micro",children:l}),e[5]=l,e[6]=u):u=e[6];let m;return e[7]!==i||e[8]!==o||e[9]!==u?(m=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pe-3 text-start text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:o,onClick:i,children:[a,u]}),e[7]=i,e[8]=o,e[9]=u,e[10]=m):m=e[10],m},Vm=n=>{const e=de.c(29),{worktree:s}=n,{t:i}=he();let r;e[0]!==s.path?(r=Ve(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:l,listeners:u,setNodeRef:m,transform:f,transition:g,isDragging:p}=ei(a),h=s.branch||s.label||s.path;let x;e[4]!==f?(x=ti.Transform.toString(f),e[4]=f,e[5]=x):x=e[5];const v=p?10:1;let b;e[6]!==x||e[7]!==v||e[8]!==g?(b={transform:x,transition:g,zIndex:v},e[6]=x,e[7]=v,e[8]=g,e[9]=b):b=e[9];const C=p&&"shadow-lg shadow-black/20";let j;e[10]!==C?(j=Z("flex items-center gap-1 rounded-xl bg-background px-1 py-1",C),e[10]=C,e[11]=j):j=e[11];let R;e[12]!==h||e[13]!==i?(R=i("mobile.sessions.dragHandleAria",{label:h}),e[12]=h,e[13]=i,e[14]=R):R=e[14];let T;e[15]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(Ur,{className:"size-4"}),e[15]=T):T=e[15];let D;e[16]!==l||e[17]!==u||e[18]!==R?(D=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":R,...l,...u,children:T}),e[16]=l,e[17]=u,e[18]=R,e[19]=D):D=e[19];let k;e[20]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx(q,{name:"git-branch",className:"size-4 shrink-0 text-muted-foreground"}),e[20]=k):k=e[20];let S;e[21]!==h?(S=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]=S):S=e[22];let y;return e[23]!==m||e[24]!==D||e[25]!==S||e[26]!==b||e[27]!==j?(y=t.jsxs("div",{ref:m,style:b,className:j,children:[D,k,S]}),e[23]=m,e[24]=D,e[25]=S,e[26]=b,e[27]=j,e[28]=y):y=e[28],y},Um=n=>{const e=de.c(58),{project:s,expanded:i,onToggleExpanded:r,onReorderWorktrees:o}=n,{t:a}=he();let l;e[0]!==s.id?(l={id:s.id},e[0]=s.id,e[1]=l):l=e[1];const{attributes:u,listeners:m,setNodeRef:f,transform:g,transition:p,isDragging:h}=ei(l);let x;e[2]===Symbol.for("react.memo_cache_sentinel")?(x={activationConstraint:{distance:8}},e[2]=x):x=e[2];let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v={coordinateGetter:Xr},e[3]=v):v=e[3];const b=Kr(js(Hr,x),js(qr,v)),C=s.worktrees.length>0;let j;e[4]!==o||e[5]!==s.worktrees?(j=Q=>{const{active:ue,over:se}=Q;if(!se||ue.id===se.id)return;const te=s.worktrees.map(Hm),ge=te.indexOf(String(ue.id)),ee=te.indexOf(String(se.id));if(ge<0||ee<0)return;const G=[...te],[N]=G.splice(ge,1);G.splice(ee,0,N),o(G)},e[4]=o,e[5]=s.worktrees,e[6]=j):j=e[6];const R=j;let T;e[7]!==g?(T=ti.Transform.toString(g),e[7]=g,e[8]=T):T=e[8];const D=h?10:1;let k;e[9]!==T||e[10]!==D||e[11]!==p?(k={transform:T,transition:p,zIndex:D},e[9]=T,e[10]=D,e[11]=p,e[12]=k):k=e[12];const S=h&&"shadow-lg shadow-black/20";let y;e[13]!==S?(y=Z("rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",S),e[13]=S,e[14]=y):y=e[14];let E;e[15]!==s.label||e[16]!==a?(E=a("mobile.sessions.dragHandleAria",{label:s.label}),e[15]=s.label,e[16]=a,e[17]=E):E=e[17];let O;e[18]===Symbol.for("react.memo_cache_sentinel")?(O=t.jsx(Ur,{className:"size-4"}),e[18]=O):O=e[18];let L;e[19]!==u||e[20]!==m||e[21]!==E?(L=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":E,...u,...m,children:O}),e[19]=u,e[20]=m,e[21]=E,e[22]=L):L=e[22];let z;e[23]!==i||e[24]!==s.label||e[25]!==a?(z=i?a("sessions.sidebar.group.collapseAria",{label:s.label}):a("sessions.sidebar.group.expandAria",{label:s.label}),e[23]=i,e[24]=s.label,e[25]=a,e[26]=z):z=e[26];const A=!C;let _;e[27]===Symbol.for("react.memo_cache_sentinel")?(_={touchAction:"manipulation"},e[27]=_):_=e[27];let B;e[28]!==s?(B=t.jsx($n,{project:s}),e[28]=s,e[29]=B):B=e[29];let P;e[30]!==s.label?(P=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]=P):P=e[31];let M;e[32]!==i||e[33]!==C?(M=C?t.jsx(Gr,{className:Z("size-4 shrink-0 text-muted-foreground transition-transform",i&&"rotate-180")}):null,e[32]=i,e[33]=C,e[34]=M):M=e[34];let $;e[35]!==i||e[36]!==r||e[37]!==z||e[38]!==A||e[39]!==B||e[40]!==P||e[41]!==M?($=t.jsxs("button",{type:"button",className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 rounded-xl px-1 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:r,"aria-expanded":i,"aria-label":z,disabled:A,style:_,children:[B,P,M]}),e[35]=i,e[36]=r,e[37]=z,e[38]=A,e[39]=B,e[40]=P,e[41]=M,e[42]=$):$=e[42];let I;e[43]!==L||e[44]!==$?(I=t.jsxs("div",{className:"flex items-center gap-1",children:[L,$]}),e[43]=L,e[44]=$,e[45]=I):I=e[45];let U;e[46]!==i||e[47]!==R||e[48]!==C||e[49]!==s.worktrees||e[50]!==b?(U=i&&C?t.jsx(Yr,{sensors:b,collisionDetection:Jr,onDragEnd:R,children:t.jsx(Qr,{items:s.worktrees.map(Ym),strategy:Zr,children:t.jsx("div",{className:"mt-1 flex flex-col gap-0.5 ps-3",children:s.worktrees.map(Jm)})})}):null,e[46]=i,e[47]=R,e[48]=C,e[49]=s.worktrees,e[50]=b,e[51]=U):U=e[51];let X;return e[52]!==f||e[53]!==I||e[54]!==U||e[55]!==k||e[56]!==y?(X=t.jsxs("div",{ref:f,style:k,className:y,children:[I,U]}),e[52]=f,e[53]=I,e[54]=U,e[55]=k,e[56]=y,e[57]=X):X=e[57],X},oo=({open:n,onOpenChange:e,variant:s="drawer",footer:i})=>{const{t:r}=he(),{git:o}=Un(),a=lt(d=>d.ensureStatus),l=Ao(),u=bs(d=>d.activeSessions),m=n||s==="sidebar",f=c.useRef(_m),g=Sr(c.useCallback(d=>(m&&(f.current=d.ids),f.current),[m])),p=c.useRef(El),h=ko(c.useCallback(d=>(m&&(p.current=d.rankById),p.current),[m])),x=rt(d=>d.projects),v=Il(d=>d.projects),b=rt(d=>d.activeProjectId),C=zt(d=>d.currentDirectory),j=Me(d=>d.currentSessionId),R=Me(d=>d.setCurrentSession),T=Me(d=>d.archiveSession),D=Me(d=>d.archiveSessions),k=Me(d=>d.deleteSession),S=Me(d=>d.deleteSessions),y=Me(d=>d.updateSessionTitle),E=Me(d=>d.openNewSessionDraft),O=rt(d=>d.setActiveProject),L=rt(d=>d.setActiveProjectIdOnly),z=rt(d=>d.reorderProjects),A=rt(d=>d.manualProjectOrder),_=us(d=>d.projectSortOrder),B=us(d=>d.setProjectSortOrder),P=us(d=>d.sidebarViewMode),M=P==="timeline"?"manual":_,$=us(d=>d.setSidebarViewMode),I=us(d=>d.showWorkSection),U=us(d=>d.setShowWorkSection),X=Sr(d=>d.toggle),Q=Al(m),ue=rt(d=>d.removeProject),se=Rn(d=>d.projectExpanded),te=Rn(d=>d.worktreeExpanded),ge=Rn(d=>d.setProjectExpanded),ee=Rn(d=>d.setWorktreeExpanded),G=Tr(d=>d.orderByProject),N=Tr(d=>d.setWorktreeOrder),Y=Xi(d=>d.expandedParents),ne=Xi(d=>d.toggleParent),[re,K]=c.useState(""),[oe,fe]=c.useState(null),[Se,we]=c.useState(null),[xe,ye]=c.useState(null),[De,Te]=c.useState(null),[ve,Ne]=c.useState(null),[H,pe]=c.useState(null),[Ae,We]=c.useState(null),[Re,Le]=c.useState(0),[qe,$e]=c.useState(!1),[tt,mt]=c.useState(!1),[wt,Es]=c.useState(!1),[Is,an]=c.useState(null),[ln,As]=c.useState(()=>new Map(Me.getState().availableWorktreesByProject)),[it,Ct]=c.useState(()=>{const d=new Set;for(const[F,V]of Me.getState().availableWorktreesByProject)V.length>0&&d.add(F);return d}),[Ue,Rt]=c.useState(!1),[Yn,ts]=c.useState(new Set),[cn,Bt]=c.useState(new Map),un=c.useRef(null);c.useEffect(()=>{if(!n){K(""),Rt(!1),ts(new Set),Bt(new Map),fe(null),we(null),ye(null),Te(null),Ne(null),pe(null);return}Eo(l)},[n]),c.useEffect(()=>{Ue||ts(new Set)},[Ue]),c.useEffect(()=>{Bt(new Map)},[P]),c.useEffect(()=>{if(!n||x.length===0)return;let d=!1;return(async()=>{const V=await Promise.all(x.map(async J=>{const ae=Ve(J.path);if(!ae)return null;const me=await o.checkIsGitRepository(ae).catch(()=>null),le=me?await $o({id:J.id,path:ae}).catch(()=>null):[];return[ae,le,me]}));d||(As(J=>{const ae=new Map;for(const me of V){if(!me)continue;const[le,Ye,Qe]=me,Mt=Qe===null||Ye===null;ae.set(le,Mt?J.get(le)??[]:Ye)}return Wo(x,ae)}),Ct(J=>{const ae=new Set;for(const me of V){if(!me)continue;const[le,,Ye]=me;(Ye===null?J.has(le):Ye)&&ae.add(le)}return ae}))})(),()=>{d=!0}},[o,n,x,Re]);const Ie=c.useMemo(()=>nu(x.map(d=>({id:d.id,label:d.label?.trim()||gr(d.path),path:Ve(d.path),icon:d.icon,color:d.color,iconImage:d.iconImage,iconBackground:d.iconBackground,isGitRepo:it.has(Ve(d.path)),worktrees:um(G[d.id],ln.get(Ve(d.path))??[]),addedAt:d.addedAt,lastOpenedAt:d.lastOpenedAt})),M,A),[it,A,M,x,G,ln]),Ge=c.useMemo(()=>{const d=[...u],F=new Set(d.map(V=>V.id));for(const V of l)F.has(V.id)||(F.add(V.id),d.push(V));return d.filter(V=>!V.time?.archived)},[u,l]),_e=c.useMemo(()=>{const d=new Map;for(const F of Ge){const V=vt(F);if(!V)continue;const J=d.get(V)??[];J.push(F),d.set(V,J)}return d},[Ge]),dn=c.useCallback(d=>dr(_e,d),[_e]),{projectSessions:ct,chatSessions:Ze}=c.useMemo(()=>ru(Ge,!1),[Ge]),pt=Fe(d=>d.sessionWorkEnabled),ze=c.useMemo(()=>{const d=new Set;if(!pt||!I)return d;for(const F of Ge)if(!(vt(F)||cr(kt(F))||!Oo(F))){d.add(F.id);for(const V of dr(_e,F.id))d.add(V)}return d},[_e,pt,Ge,I]),ss=c.useMemo(()=>ze.size>0?Ze.filter(d=>!ze.has(d.id)):Ze,[Ze,ze]),Be=Ja(),ns=c.useMemo(()=>new Map(Be.map(d=>[d.id,d])),[Be]),Ps=c.useMemo(()=>new Map(Be.map(d=>[d.id,d.name||r("sessions.sidebar.grouping.spaceUnnamed")])),[Be,r]),st=c.useMemo(()=>hd(ct,Ie.map(d=>({id:d.id,normalizedPath:d.path})),new Map(Ie.map(d=>[d.path,d.worktrees])),!1,[],v,Be),[v,ct,Ie,Be]),ht=c.useMemo(()=>Pl(ct,d=>{const F=st.bySessionId.get(d.id);return(F?Ie.find(J=>J.id===F.projectId):void 0)?.path||Ve(kt(d))||null}),[ct,Ie,st]),Ts=c.useMemo(()=>{const d=new Map(Ge.map(J=>[J.id,J])),F=J=>({session:J,children:(_e.get(J.id)??[]).map(F),worktree:null}),V=new Map;for(const J of ht.runs.values())V.set(J.key,J.memberIds.flatMap(ae=>{const me=d.get(ae);return me?[F(me)]:[]}));return V},[_e,ht,Ge]),rs=c.useMemo(()=>({key:Vs,label:"",path:"",worktree:null,space:null,sessions:Us(ss,g,h)}),[g,ss,h]),nt=c.useMemo(()=>new Set(rs.sessions.filter(d=>Ei(g,kt(d)||null,d.id)).map(d=>d.id)),[rs,g]),gt=c.useMemo(()=>({key:xr,label:"",path:"",worktree:null,space:null,sessions:ze.size>0?Us(Ge.filter(d=>ze.has(d.id)),g,h):[]}),[g,h,Ge,ze]),Jn=`${Vs}::${Vs}`,fn=c.useMemo(()=>ss.filter(d=>!vt(d)).length,[ss]),be=re.trim().toLowerCase(),Lt=c.useRef(null);c.useEffect(()=>{if(!n)return;const d=window.requestAnimationFrame(()=>{const F=Lt.current;if(!F)return;(F.querySelector('[data-active-session="true"]')??F.querySelector('[data-active-project="true"]'))?.scrollIntoView({block:"center"})});return()=>window.cancelAnimationFrame(d)},[n]);const Dt=c.useMemo(()=>{const d=iu(Ie,M,V=>V.id,st.sessionsByProject).map(V=>({project:V,buckets:[],isActive:V.id===b})),F=(V,J,ae,me=null)=>{const le=Ve(J)||V.project.path,Ye=le||"__root__";let Qe=V.buckets.find(Mt=>Mt.key===Ye);return Qe||(Qe={key:Ye,label:(me?me.name||r("sessions.sidebar.grouping.spaceUnnamed"):null)||ae?.branch||gr(le),path:le,worktree:ae,space:me,sessions:[]},V.buckets.push(Qe)),Qe};for(const V of d){F(V,V.project.path,null);for(const J of V.project.worktrees)F(V,J.path,J);for(const J of Be)J.directory&&Ve(J.projectDirectory)===Ve(V.project.path)&&F(V,J.directory,null,J)}for(const V of ct){const J=st.bySessionId.get(V.id);if(!J)continue;const ae=d.find(Qe=>Qe.project.id===J.projectId);if(!ae)continue;const me=vr(ae.project,J.scopeDirectory),le=J.kind==="space"&&J.spaceId?ns.get(J.spaceId)??null:null;(le?F(ae,J.scopeDirectory,null,le):me&&!ht.runKeyBySessionId.has(V.id)?F(ae,me.path,me):F(ae,ae.project.path,null)).sessions.push(V)}for(const V of d)for(const J of V.buckets)J.sessions=Us(J.sessions,g,h);return d},[b,g,M,Ie,ht,ct,h,st,Be,ns,r]),is=Ve(C),bt=d=>d.isActive?is===d.project.path?d.project.path:d.project.worktrees.find(V=>Lm(is,V.path))?.path??d.project.path:null,Xn=d=>se[d.project.id]??!0,Qn=(d,F)=>F.sessions.length===0||(te[`${d.project.id}::${F.key}`]??!0);c.useEffect(()=>{if(m)for(const d of Dt)for(const F of d.buckets){const V=`${d.project.id}::${F.key}`;F.sessions.length===0&&te[V]===!1&&ee(V,!0)}},[m,Dt,ee,te]);const Ds=d=>{Bt(F=>{if(!F.has(d))return F;const V=new Map(F);return V.delete(d),V})},Zn=d=>{Bt(F=>{let V=!1;const J=new Map(F),ae=`${d}::`;for(const me of J.keys())me.startsWith(ae)&&(J.delete(me),V=!0);return V?J:F})},ot=(d,F,V)=>{Bt(J=>{const ae=new Map(J);return ae.set(d,F+V),ae})},Ft=(d,F,V,J)=>{const ae=J?.pageSize??qs,me=V===null?yr:Vn(V),le=J?.alwaysVisibleIds,Ye=new Set(F.sessions.map(ke=>ke.id)),Qe=new Map;for(const ke of F.sessions){const et=vt(ke);if(et&&Ye.has(et)){const It=Qe.get(et)??[];It.push(ke),Qe.set(et,It)}}const Mt=F.sessions.filter(ke=>{const et=vt(ke);return!et||!Ye.has(et)}),Ht=new Set,$s=Mt.flatMap(ke=>{const et=ht.runKeyBySessionId.get(ke.id),It=et?ht.runs.get(et):void 0;return It?Ht.has(It.key)?[]:(Ht.add(It.key),[{kind:"run",run:It}]):[{kind:"session",session:ke}]}),hi=ke=>ke.kind==="session"&&!!le?.has(ke.session.id),za=le?$s.filter(hi):[],or=le?$s.filter(ke=>!hi(ke)):$s,Ba=cn.get(d)??ae,ar=or.slice(0,Ba),La=[...za,...ar],gi=or.length-ar.length,Fa=or.length>ae&&gi===0,bi=(ke,et)=>{const It=Qe.get(ke.id)??[],lr=It.length>0,xi=et!==null&&!!Y[ke.id];return t.jsxs(c.Fragment,{children:[t.jsx(so,{session:ke,active:j===ke.id,indent:yr,treeDepth:et??void 0,statusOnRight:et===null,hasChildren:lr,expanded:xi,onToggleChildren:lr?()=>ne(ke.id):void 0,onSelect:()=>Ms(ke),revealed:Se===ke.id,onRevealedChange:Ws=>$t(ke.id,Ws),confirmingDelete:xe===ke.id,onArchive:()=>{xt(ke)},onRequestDelete:()=>ye(ke.id),onConfirmDelete:()=>{hn(ke)},renaming:De===ke.id,onRequestRename:()=>gn(ke.id),onSubmitRename:Ws=>{Wt(ke.id,Ws)},onCancelRename:()=>Te(null),work:er(ke),pin:He(ke),descendantIdsOf:dn}),lr&&xi&&et!==null?It.map(Ws=>bi(Ws,et+1)):null]},ke.id)};return t.jsxs("div",{children:[La.map(ke=>ke.kind==="run"?t.jsx(Wm,{run:ke.run,laneNodes:Ts.get(ke.run.key)??no,depth:V??0},`run:${ke.run.key}`):bi(ke.session,V)),gi>0?t.jsx(ro,{indent:me,onClick:()=>ot(d,ar.length,qs)}):null,Fa?t.jsx(io,{indent:me,onClick:()=>Ds(d)}):null]})},os=(d,F)=>{ge(d,!F),Zn(d)},_s=(d,F,V)=>{ee(`${d}::${F}`,!V),Ds(`${d}::${F}`)},Ms=d=>{const F=kt(d)||null,V=st.bySessionId.get(d.id),J=V?Ie.find(ae=>ae.id===V.projectId)??null:null;if(J){L(J.id),ge(J.id,!0);const ae=vr(J,V?.scopeDirectory??"");ae&&ee(`${J.id}::${Ve(ae.path)}`,!0)}R(d.id,F),e(!1)},$t=(d,F)=>{we(F?d:null),ye(null),Ne(null),pe(null)},jt=(d,F)=>{Ne(F?d:null),pe(null),we(null),ye(null)},at=(d,F)=>(we(null),ye(null),uu(d,F,du(F.id,dr(_e,F.id),d==="delete"),{archiveSession:T,archiveSessions:D,deleteSession:k,deleteSessions:S},r)),xt=d=>at("archive",d),as=async(d,F)=>{try{await Ol(d.id,kt(d)||null,F?"done":"open")}catch{ce.error(r("sessions.sidebar.session.work.updateFailed"))}},er=d=>{if(!pt||vt(d)||cr(kt(d)))return;const F=ze.has(d.id);return{inWork:F,onToggle:()=>{as(d,F)}}},mn=d=>Ei(g,kt(d)||null,d.id),pn=d=>{const F=kt(d);F&&X({directory:F,sessionId:d.id})},He=d=>{if(!(vt(d)||!kt(d)))return{pinned:mn(d),onToggle:()=>pn(d)}},hn=d=>at("delete",d),gn=d=>{we(null),ye(null),Te(d)},Wt=async(d,F)=>{Te(null);try{await y(d,F)}catch{ce.error(r("mobile.sessions.renameError"))}},bn=()=>{E(),e(!1)},xn=d=>{an(d),L(d),Es(!0)},ls=Kr(js(Hr,{activationConstraint:{distance:8}}),js(qr,{coordinateGetter:Xr})),At=d=>{B(d),ur({sidebarProjectSortOrder:d}),d!=="manual"&&Rt(!1)},Vt=d=>{$(d),ur({sidebarViewMode:d}),d==="timeline"&&Rt(!1)},Ut=()=>{const d=!I;U(d),ur({sidebarShowWorkSection:d})},Os=d=>{const{active:F,over:V}=d;if(!V||F.id===V.id)return;const J=Ie.findIndex(me=>me.id===F.id),ae=Ie.findIndex(me=>me.id===V.id);J<0||ae<0||z(J,ae)},zs=d=>{ts(F=>{const V=new Set(F);return V.has(d)?V.delete(d):V.add(d),V})},yn=c.useCallback(d=>{const F=kt(d);if(cr(F))return r("mobile.sessions.section.chats");const V=st.bySessionId.get(d.id),J=V?Ie.find(le=>le.id===V.projectId)??null:null;if(!J)return gr(F)||F;const ae=V?.kind==="space"&&V.spaceId?ns.get(V.spaceId):void 0;if(ae)return`${J.label} · ${ae.name||r("sessions.sidebar.grouping.spaceUnnamed")}`;const me=vr(J,V?.scopeDirectory??"");return me?.branch?`${J.label} · ${me.branch}`:J.label},[Ie,st,ns,r]),tr=d=>{O(d.id),e(!1)},vn=d=>{L(d.id),E({selectedProjectId:d.id,directoryOverride:d.path}),e(!1)},nr=c.useMemo(()=>be?Dt.filter(d=>Fo([d.project.label,d.project.path],be)?!0:d.buckets.some(F=>F.sessions.some(V=>wr(V,d.project.label,be)))):Dt,[be,Dt]),Et=c.useMemo(()=>be?Us(Ge.filter(d=>{if(vt(d))return!1;const F=st.bySessionId.get(d.id),V=F?Ie.find(J=>J.id===F.projectId)??null:null;return wr(d,V?.label??"",be)}),g,h):[],[be,g,Ie,h,st,Ge]),cs=c.useMemo(()=>be?Tl(Ie,be,d=>[d.label,d.path]):[],[be,Ie]),Gt=P==="timeline"&&!be&&!Ue,Bs=!be&&!Ue,Ls=Gt||Bs&&gt.sessions.length>0,Fs=Ls;c.useEffect(()=>{if(!(!Fs||!o))for(const d of Ie){const F=Ve(d.path);F&&Dl(()=>a(F,o))}},[a,o,Fs,Ie]);const _t=c.useMemo(()=>{const d=new Map;if(!Ls)return d;const F=ou({sessions:ct,projects:Ie.map(V=>({id:V.id,normalizedPath:V.path,label:V.label})),ownerBySessionId:st.bySessionId,availableWorktreesByProject:new Map(Ie.map(V=>[V.path,V.worktrees])),gitBranches:Q,homeDirectory:null,hideBranchMatchingProjectLabel:!1,spaceLabelById:Ps});for(const V of ct){if(vt(V))continue;const J=F.get(V.id),ae=J?Ie.find(me=>me.id===J.projectId):null;!ae||!J||d.set(V.id,{project:ae,branch:J.branchLabel,inSpace:J.inSpace})}return d},[Q,Ls,ct,Ie,st,Ps]),Kt=c.useCallback(d=>{const F=new Set;return d.flatMap(V=>{const J=_t.get(V.id);if(!J)return[];const ae=ht.runKeyBySessionId.get(V.id),me=ae?ht.runs.get(ae):void 0;return me?F.has(me.key)?[]:(F.add(me.key),[{kind:"run",run:me,laneNodes:Ts.get(me.key)??no,project:J.project}]):[{kind:"session",session:V,project:J.project,branch:J.branch,inSpace:J.inSpace}]})},[ht,Ts,_t]),wn=c.useMemo(()=>{const d=new Map;if(!Gt)return d;const F=Us(ct.filter(V=>!vt(V)&&_t.has(V.id)),g,h);for(const V of Kt(F)){const J=d.get(V.project.id);J?J.push(V):d.set(V.project.id,[V])}return d},[g,ct,h,Gt,_t,Kt]),rr=c.useMemo(()=>Bs?Kt(gt.sessions.filter(d=>!vt(d))):[],[Bs,Kt,gt]),w=(d,F,V)=>{const J=cn.get(d)??qs,ae=F.slice(0,J),me=F.length-ae.length;return t.jsxs(t.Fragment,{children:[t.jsx(Zi,{entries:ae,showProject:V,handlers:W}),me>0?t.jsx(ro,{indent:nn,onClick:()=>ot(d,ae.length,qs)}):F.length>qs?t.jsx(io,{indent:nn,onClick:()=>Ds(d)}):null]})},W={currentSessionId:j,revealedSessionId:Se,confirmingDeleteSessionId:xe,renamingSessionId:De,onSelect:Ms,onRevealedChange:$t,onArchive:d=>{xt(d)},onRequestDelete:ye,onConfirmDelete:d=>{hn(d)},onRequestRename:gn,onSubmitRename:(d,F)=>{Wt(d,F)},onCancelRename:()=>Te(null),onToggleWork:pt?(d,F)=>{as(d,F)}:void 0,isPinned:mn,onTogglePin:pn,descendantIdsOf:dn},ie=be&&Et.length===0&&cs.length===0,je=!be&&Ie.length>1&&M==="manual",Pe=!Ue&&!be&&Ie.length>0?t.jsx(Ce,{type:"button",variant:"chip",size:"sm","aria-label":r("sessions.sidebar.header.displayMode.label"),title:r("sessions.sidebar.header.displayMode.label"),onClick:()=>$e(!0),style:{touchAction:"manipulation"},children:t.jsx(q,{name:"equalizer-2",className:"size-4"})}):null,yt=je?t.jsx(Ce,{type:"button",variant:"chip",size:"sm","aria-label":r(Ue?"mobile.sessions.doneEditing":"mobile.sessions.editOrder"),"aria-pressed":Ue,onClick:()=>Rt(d=>!d),style:{touchAction:"manipulation"},children:Ue?t.jsx(Xo,{className:"size-4"}):t.jsx(Rr,{className:"size-4"})}):null,Oe=!Ue&&Ie.length>0?t.jsxs(Ce,{type:"button",variant:"default",size:"sm","aria-label":r("mobile.sessions.newChat"),onClick:bn,style:{touchAction:"manipulation"},children:[t.jsx(od,{className:"size-4"}),r("mobile.sessions.newChat")]}):null,ir=Ue?null:t.jsx(Ce,{type:"button",variant:"chip",size:"sm","aria-label":r("sessions.sidebar.header.actions.addProject"),title:r("sessions.sidebar.header.actions.addProject"),onClick:()=>mt(!0),style:{touchAction:"manipulation"},children:t.jsx(Pi,{className:"size-4"})}),qt=Oe||ir||Pe||yt?t.jsxs(t.Fragment,{children:[ir,Pe,yt,Oe]}):null,jn=t.jsxs("div",{ref:Lt,className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs(Gn,{ref:un,className:"min-h-0 flex-1 overflow-y-auto pb-4",children:[t.jsx("div",{className:Z("px-4 pb-2 pt-1",Ue&&"hidden"),children:t.jsx(au,{value:re,onSearch:K,active:n||s==="sidebar",mobile:!0,placeholder:r("mobile.sessions.search.placeholder"),clearLabel:r("mobile.sessions.clearSearchAria")})}),Ie.length===0&&Ze.length===0?t.jsx(co,{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:()=>mt(!0),children:[t.jsx(Pi,{className:"size-4"}),r("sessions.sidebar.header.actions.addProject")]})}):ie?t.jsx(co,{title:r("mobile.sessions.empty.searchTitle"),description:r("mobile.sessions.empty.searchDescription")}):be&&!Ue?t.jsxs("div",{className:"flex flex-col gap-3 px-3 pt-2",children:[Et.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:Et.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:Et.map((d,F)=>t.jsx("div",{className:Z(F>0&&"border-t border-border/70"),children:t.jsx(so,{session:d,active:j===d.id,indent:12,contextLabel:yn(d),onSelect:()=>Ms(d)})},d.id))})]}):null,cs.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:cs.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:cs.map((d,F)=>t.jsxs("div",{className:Z("flex items-center",F>0&&"border-t border-border/70"),children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-3 px-3 py-1.5 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>tr(d),style:{touchAction:"manipulation"},children:[t.jsx($n,{project:d}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:d.label})]}),d.isGitRepo?t.jsx(to,{onClick:()=>xn(d.id)}):null,t.jsx(jr,{className:"me-2",label:r("mobile.sessions.newSessionInProjectAria",{label:d.label}),onClick:()=>vn(d)})]},d.id))})]}):null]}):Ue?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(Yr,{sensors:ls,collisionDetection:Jr,onDragEnd:Os,children:t.jsx(Qr,{items:Ie.map(d=>d.id),strategy:Zr,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:Ie.map(d=>t.jsx(Um,{project:d,expanded:Yn.has(d.id),onToggleExpanded:()=>zs(d.id),onReorderWorktrees:F=>N(d.id,F)},d.id))})})})]}):t.jsxs("div",{className:"flex flex-col",children:[(()=>{const d=se[Vs]??!0,F=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-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ve){jt(ve,!1);return}os(Vs,d)},"aria-expanded":d,"aria-label":d?r("sessions.sidebar.group.collapseAria",{label:F}):r("sessions.sidebar.group.expandAria",{label:F}),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(q,{name:"chat-4",className:"size-5"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-header font-semibold text-foreground",children:F}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:fn})]}),Ue?null:t.jsx(jr,{className:"me-2",label:r("mobile.sessions.newChat"),onClick:bn})]}),t.jsx(In,{open:d,children:()=>t.jsx("div",{className:"pb-2",children:rs.sessions.length>0?Ft(Jn,rs,null,{pageSize:zm,alwaysVisibleIds:nt}):t.jsx("p",{className:"px-3 pb-1 typography-micro text-muted-foreground",style:{paddingInlineStart:yr},children:r("sessions.sidebar.activity.chatsEmpty")})})})]})})(),gt.sessions.length>0?(()=>{const d=se[xr]??!0,F=r("sessions.sidebar.work.title");return t.jsxs("section",{children:[t.jsxs("button",{type:"button",className:"flex min-h-12 w-full min-w-0 items-center gap-2 px-3 py-1.5 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ve){jt(ve,!1);return}os(xr,d)},"aria-expanded":d,"aria-label":d?r("sessions.sidebar.group.collapseAria",{label:F}):r("sessions.sidebar.group.expandAria",{label:F}),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(q,{name:"eye",className:"size-5"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-header font-semibold text-foreground",children:F}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:gt.sessions.filter(V=>!vt(V)).length})]}),t.jsx(In,{open:d,children:()=>t.jsx("div",{className:"pb-2",children:t.jsx(Zi,{entries:rr,showProject:!0,handlers:W})})})]})})():null,nr.map(d=>{const F=Xn(d),V=be?d.buckets.filter(ae=>ae.sessions.some(me=>wr(me,d.project.label,be))):d.buckets,J=bt(d);return t.jsxs("section",{children:[t.jsx(Wn,{actionsWidth:96,revealed:ve===`project:${d.project.id}`,onRevealedChange:ae=>jt(`project:${d.project.id}`,ae),actions:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:ve===`project:${d.project.id}`?0:-1,className:Z("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===d.project.id?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80"),"aria-label":H===d.project.id?r("mobile.sessions.confirmRemoveProjectAria",{label:d.project.label}):r("mobile.sessions.removeProjectAria",{label:d.project.label}),onClick:()=>{if(H===d.project.id){Ne(null),pe(null),ue(d.project.id),ce.success(r("mobile.sessions.toast.projectRemoved",{label:d.project.label}));return}pe(d.project.id)},style:{touchAction:"manipulation"},children:t.jsx(_n,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:ve===`project:${d.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:d.project.label}),onClick:()=>{Ne(null),fe(d.project.id)},style:{touchAction:"manipulation"},children:t.jsx(Rr,{className:"size-[18px]"})})]}),children:t.jsxs("div",{"data-active-project":d.isActive||void 0,className:"flex min-h-12 w-full items-center",children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ve){jt(ve,!1);return}os(d.project.id,F)},"aria-expanded":F,"aria-label":F?r("sessions.sidebar.group.collapseAria",{label:d.project.label}):r("sessions.sidebar.group.expandAria",{label:d.project.label}),style:{touchAction:"manipulation"},children:[t.jsx($n,{project:d.project}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-header font-semibold text-foreground",children:d.project.label})]}),d.project.isGitRepo?t.jsx(to,{onClick:()=>xn(d.project.id)}):null,t.jsx(jr,{className:"me-2",label:r("mobile.sessions.newSessionInProjectAria",{label:d.project.label}),onClick:()=>vn(d.project)})]})}),t.jsx(In,{open:F,children:()=>Gt?t.jsx("div",{className:"pb-2",children:w(`${d.project.id}::timeline`,wn.get(d.project.id)??[],!1)}):t.jsx("div",{className:"pb-2",children:(()=>{const ae=V.find(le=>le.worktree===null&&le.space===null),me=V.filter(le=>le!==ae);return t.jsxs(t.Fragment,{children:[ae&&ae.sessions.length>0?Ft(`${d.project.id}::${ae.key}`,ae,0):null,me.map(le=>{const Ye=Qn(d,le),Qe=le.sessions.length===0,Mt=J===le.path;return t.jsx(Fm,{path:le.worktree?.path??null,children:Ht=>t.jsxs("div",{className:Z("mt-1.5",Ht&&"opacity-60"),"aria-busy":Ht||void 0,children:[t.jsx(Wn,{actionsWidth:le.space?96:48,revealed:ve===`wt:${le.key}`,onRevealedChange:$s=>jt(`wt:${le.key}`,$s),actions:le.space?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:ve===`wt:${le.key}`?0:-1,className:"flex flex-1 items-center justify-center text-foreground transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":r("spaces.group.access.giveAria",{label:le.label}),onClick:()=>{Ne(null),le.space&&vi.getState().openAccessDialog(le.space.id)},style:{touchAction:"manipulation"},children:t.jsx(q,{name:"key",className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:ve===`wt:${le.key}`?0:-1,className:"flex flex-1 items-center justify-center text-foreground transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":r("spaces.actions.menuAria",{label:le.label}),onClick:()=>{Ne(null),le.space&&vi.getState().openActionsSheet(le.space.id)},style:{touchAction:"manipulation"},children:t.jsx(q,{name:"more-2",className:"size-[18px]"})})]}):le.worktree&&!Ht?t.jsx("button",{type:"button",tabIndex:ve===`wt:${le.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:le.label}),onClick:()=>{Ne(null),le.worktree&&We({project:d.project,worktree:le.worktree})},style:{touchAction:"manipulation"},children:t.jsx(_n,{className:"size-[18px]"})}):null,children:t.jsxs("button",{type:"button",className:"flex min-h-10 w-full items-center gap-0.5 py-1 pe-3 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ve){jt(ve,!1);return}Qe||_s(d.project.id,le.key,Ye)},"aria-expanded":Qe?void 0:Ye,"aria-label":Qe?le.label:Ye?r("sessions.sidebar.group.collapseAria",{label:le.label}):r("sessions.sidebar.group.expandAria",{label:le.label}),style:{paddingInlineStart:mi(0),touchAction:"manipulation"},children:[Qe?t.jsx("span",{"aria-hidden":!0,className:"size-3.5 shrink-0"}):t.jsx(Yo,{expanded:Ye}),Ht?t.jsx("span",{className:"inline-flex size-3.5 shrink-0 items-center justify-center text-muted-foreground",role:"status","aria-label":r("sessions.sidebar.group.worktreeRemoving"),children:t.jsx(q,{name:"loader-4",className:"size-3.5 animate-spin"})}):t.jsx(q,{name:le.space?"box-3":"git-branch",className:Z("mx-px size-3 shrink-0",Mt?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground",children:le.label}),Mt?t.jsx($m,{ariaLabel:r("mobile.sessions.activeWorktreeAria")}):null]})}),le.space?t.jsx("div",{className:"pb-1 pe-3",style:{paddingInlineStart:Vn(1)},children:t.jsx(lu,{spaceId:le.space.id})}):null,t.jsx(In,{open:Ye,children:()=>Ft(`${d.project.id}::${le.key}`,le,1)})]})},le.key)})]})})()})})]},d.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(Ce,{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(q,{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(Ce,{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(q,{name:"download",className:"size-5"}),t.jsx("span",{className:"absolute inset-e-2 top-2 inline-flex size-2 rounded-full bg-primary","aria-hidden":!0})]}):null,t.jsx(Ce,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:i.onOpenScheduled,"aria-label":r("sessions.sidebar.header.actions.scheduledTasks"),title:r("sessions.sidebar.header.actions.scheduledTasks"),style:{touchAction:"manipulation"},children:t.jsx(q,{name:"calendar-schedule",className:"size-5"})}),t.jsx(Ce,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:i.onOpenSourceBoard,"aria-label":r("sourceBoard.title"),title:r("sourceBoard.title"),style:{touchAction:"manipulation"},children:t.jsx(q,{name:"todo",className:"size-5"})}),t.jsx(Ce,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:i.onOpenArchive,"aria-label":r("sessions.sidebar.nav.archive"),title:r("sessions.sidebar.nav.archive"),style:{touchAction:"manipulation"},children:t.jsx(q,{name:"archive",className:"size-5"})}),t.jsx(Ce,{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(q,{name:"bar-chart",className:"size-5"})}),t.jsx(Ce,{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(q,{name:"settings-3",className:"size-5"})})]})]}):null,t.jsx(cu,{open:tt,onOpenChange:mt}),t.jsx(_l,{open:wt,onOpenChange:d=>{Es(d),d||an(null)},project:(()=>{const d=Ie.find(F=>F.id===Is);return d?{id:d.id,path:d.path}:void 0})(),onWorktreeCreated:d=>{E({selectedProjectId:Is,directoryOverride:d,preserveDirectoryOverride:!0}),e(!1)}}),t.jsx(km,{open:oe!==null,project:Ie.find(d=>d.id===oe)??null,onClose:()=>fe(null),onWorktreesChanged:()=>Le(d=>d+1)}),t.jsx(Po,{open:qe,onClose:()=>$e(!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")}),Om.map(([d,F])=>t.jsxs("button",{type:"button",className:Z("flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-start transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",P===d?"text-primary":"text-foreground"),onClick:()=>{Vt(d),$e(!1)},style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label",children:r(F)}),P===d?t.jsx(q,{name:"check",className:"size-4"}):null]},d)),P==="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")}),P==="timeline"?null:Mm.map(([d,F])=>t.jsxs("button",{type:"button",className:Z("flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-start transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",M===d?"text-primary":"text-foreground"),onClick:()=>{At(d),$e(!1)},style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label",children:r(F)}),M===d?t.jsx(q,{name:"check",className:"size-4"}):null]},d)),pt?t.jsxs("button",{type:"button","aria-pressed":I,className:Z("mt-2 flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-start transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",I?"text-primary":"text-foreground"),onClick:()=>{Ut(),$e(!1)},style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label",children:r("sessions.sidebar.header.displayMode.showWork")}),I?t.jsx(q,{name:"check",className:"size-4"}):null]}):null]})}),Ae?t.jsx(ka,{open:!0,project:{id:Ae.project.id,path:Ae.project.path},worktree:Ae.worktree,onClose:()=>We(null),onDeleted:()=>Le(d=>d+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")}),qt?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:qt}):null]}),jn]}):null:t.jsxs(qm,{open:n,onClose:()=>e(!1),onSwipeClose:()=>{if(Se||ve){we(null),Ne(null),ye(null),pe(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:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":r("mobile.surface.closeAria"),onClick:()=>e(!1),style:{touchAction:"manipulation"},children:t.jsx(q,{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")}),qt?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:qt}):null]}),jn]})},ao="mobile-surface-root",Gm=16,lo=320,Km="cubic-bezier(0.22, 1, 0.36, 1)",qm=({open:n,onClose:e,onSwipeClose:s,ariaLabel:i,children:r})=>{const{direction:o}=he(),a=c.useRef(null),l=c.useRef(null),[u,m]=c.useState(!1),[f,g]=c.useState(n),p=c.useRef(e);c.useEffect(()=>{p.current=e},[e]);const h=c.useRef(s);c.useEffect(()=>{h.current=s},[s]);const x=()=>(h.current??p.current)();if(fi(l,{enabled:n,...o==="rtl"?{onLeftEdgeSwipe:x}:{onRightEdgeSwipe:x}}),typeof document<"u"&&!a.current){let v=document.getElementById(ao);v||(v=document.createElement("div"),v.id=ao,document.body.appendChild(v)),a.current=v}return c.useEffect(()=>{if(n){g(!0);const b=window.setTimeout(()=>m(!0),Gm);return()=>window.clearTimeout(b)}m(!1);const v=window.setTimeout(()=>g(!1),lo+40);return()=>window.clearTimeout(v)},[n]),c.useEffect(()=>{if(!n)return;const v=document.body.style.overflow;document.body.style.overflow="hidden";const b=C=>{C.key==="Escape"&&p.current()};return document.addEventListener("keydown",b),()=>{document.body.style.overflow=v,document.removeEventListener("keydown",b)}},[n]),a.current?vs.createPortal(t.jsx("section",{ref:l,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:u?"none":o==="rtl"?"translateX(100%)":"translateX(-100%)",transition:`transform ${lo}ms ${Km}`,visibility:f?"visible":"hidden",pointerEvents:n?"auto":"none"},children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:r})}),a.current):null},co=n=>{const e=de.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 l;e[4]!==r?(l=r?t.jsx("div",{className:"pt-2",children:r}):null,e[4]=r,e[5]=l):l=e[5];let u;return e[6]!==o||e[7]!==a||e[8]!==l?(u=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[o,a,l]}),e[6]=o,e[7]=a,e[8]=l,e[9]=u):u=e[9],u};function Hm(n){return Ve(n.path)}function Ym(n){return Ve(n.path)}function Jm(n){return t.jsx(Vm,{worktree:n},Ve(n.path))}const Xm=6e4,Qm=(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}},Zm=n=>{switch(n?.status.status){case"connected":return"success";case"failed":return"error";case"needs_auth":return"warning";default:return"default"}},ep=({active:n,className:e,headerAction:s,listClassName:i,hideHeader:r=!1,mobileListDensity:o=!1})=>{const{t:a}=he(),u=zt(k=>k.currentDirectory)??null,m=fs(k=>k.getStatusForDirectory(u)),f=fs(k=>k.refresh),g=fs(k=>k.ensureFresh),p=fs(k=>k.connect),h=fs(k=>k.disconnect),x=xs(k=>k.mcpServers),v=xs(k=>k.loadMcpConfigs),[b,C]=c.useState(!1),[j,R]=c.useState(null);c.useEffect(()=>{v({force:!0})},[v]),c.useEffect(()=>{n&&Promise.all([g({directory:u,silent:!0,maxAgeMs:Xm}),v({force:!0})])},[n,g,u,v]);const T=c.useMemo(()=>{const k=new Set(Object.keys(m));for(const S of x)S?.name&&k.add(S.name);return Array.from(k).sort((S,y)=>S.localeCompare(y))},[x,m]),D=c.useCallback(k=>{if(k?.preventDefault(),b)return;C(!0);const S=new Promise(y=>setTimeout(y,500));Promise.all([f({directory:u}),S]).finally(()=>{C(!1)})},[b,f,u]);return t.jsxs("div",{className:Z("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")}),u&&t.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:u.split("/").pop()||u})]}),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:b,onClick:D,"aria-label":a("mcpDropdown.actions.refreshAria"),children:t.jsx(q,{name:"refresh",className:Z("h-4 w-4",b&&"animate-spin")})})]})]})}),t.jsx("div",{className:Z("max-h-64 overflow-y-auto",o?"space-y-1 py-3":"px-3 py-2.5",i),children:t.jsxs("div",{className:Z(!o&&T.length>0&&"p-1.5"),children:[T.map(k=>{const S=m[k],y=Zm(S),E=S?.status.status==="connected",O=j===k,L=Qm(S,a);return t.jsxs("div",{className:Z("flex items-center justify-between rounded-lg hover:bg-interactive-hover",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(zl,{children:[t.jsx(Bl,{asChild:!0,children:t.jsx("span",{className:Z("rounded-full flex-shrink-0",o?"h-2.5 w-2.5":"h-2 w-2",y==="success"&&"bg-status-success",y==="error"&&"bg-status-error",y==="warning"&&"bg-status-warning",y==="default"&&"bg-muted-foreground/40"),"aria-label":L})}),t.jsx(Ll,{side:"left",children:t.jsx("p",{children:L})})]}),t.jsx("span",{className:Z("truncate",o?"text-[17px] leading-6 font-medium":"typography-ui-label"),children:k})]})}),t.jsx(Fl,{checked:E,disabled:O,className:"data-[checked]:bg-status-info",onCheckedChange:async z=>{R(k);try{z?await p(k,u):await h(k,u)}catch(A){Er.error(A instanceof Error?A.message:a("mcpDropdown.status.unknownError"))}finally{R(null)}}})]},k)}),T.length===0&&t.jsx("div",{className:"px-4 py-5 typography-ui-label text-muted-foreground text-center",children:a("mcpDropdown.empty.configureInConfig")})]})})]})};async function tp(n,e,s=Number.POSITIVE_INFINITY){const i=Array.from(new Set(n)),r=[];return await $l(i,s,async o=>{try{await e(o)}catch(a){r.push({path:o,error:a instanceof Error?a:null})}}),{paths:i,failures:r}}const uo={status:"loading"},sp=1e6,ds={type:"list"},np=2,rp=n=>{const e=n.index?.trim();return!!(e&&e!=="?")},ip=n=>{const e=n.working_dir?.trim(),s=n.index?.trim();return!!(e||s==="?")},fo=(n,e)=>e?`${n}\0staged`:n,op=n=>{const e=de.c(6),s=on(Wr()??null)??"",i=n.visible??!0;let r;e[0]!==i?(r={enabled:i,recheckOnOpen:!0},e[0]=i,e[1]=r):r=e[1];const o=Wl(s||null,r);let a;return e[2]!==n||e[3]!==o||e[4]!==s?(a=t.jsx(ap,{...n,rootDirectory:s,repository:o}),e[2]=n,e[3]=o,e[4]=s,e[5]=a):a=e[5],a},ap=({rootDirectory:n,repository:e,onClose:s,initialDiff:i,visible:r=!0,onNavigatedToChat:o})=>{const{t:a}=he(),{git:l,sourceControl:u}=Un(),{rootIsGitRepo:m,gitDirectory:f,nestedRepos:g}=e,p=f??n,h=Vl(p||null),x=fu(p),v=Ul(p||null),b=Gl(p||null),[C,j]=c.useState(!1),[R,T]=c.useState(!1),D=Cn(w=>w.profiles),k=Cn(w=>w.globalIdentity),S=Cn(w=>w.loadProfiles),y=Cn(w=>w.loadGlobalIdentity);c.useEffect(()=>{S(),y()},[S,y]);const E=Kl(),O=Vo(w=>w.refreshIdentityAccounts),L=c.useMemo(()=>ql(D,k,w=>Xa(w)&&Hl(w,E)),[D,k,E]),z=async w=>{if(!(!p||R)){T(!0);try{(await Cu({directory:p,identity:w,remoteName:st||null},{git:l,sourceControl:u})).status==="failed"?ce.error(a("gitView.toast.applyIdentityFailed")):ce.success(a("gitView.toast.appliedIdentity",{name:dc(w,a)}))}finally{T(!1)}}},A=Io(p||null),_=Yl(p||null),B=lt(w=>w.setActiveDirectory),P=lt(w=>w.ensureAll),M=lt(w=>w.ensureNestedRepos),$=lt(w=>w.selectNestedRepo),I=lt(w=>w.fetchStatus),U=lt(w=>w.fetchBranches),X=lt(w=>w.prefetchDiffs),Q=lt(w=>w.getDiff),ue=lt(w=>w.setDiff),se=lt(w=>w.runtimeKey),te=JSON.stringify([se,p]),ge=c.useRef(te);ge.current=te;const[ee,G]=c.useState(()=>({ownerKey:te,mode:"working",route:i?.path?{type:"diff",path:i.path,staged:i.staged}:ds})),N=ee.ownerKey===te?ee.mode:"working",Y=ee.ownerKey===te?ee.route:ds,[ne,re]=c.useState(!1),K=c.useCallback(w=>{G({ownerKey:te,mode:w,route:ds}),re(!1)},[te]),oe=c.useCallback(w=>{G(W=>({ownerKey:te,mode:W.ownerKey===te?W.mode:"working",route:w}))},[te]);c.useEffect(()=>{G(w=>w.ownerKey===te?w:{ownerKey:te,mode:"working",route:ds}),re(!1)},[te]),c.useEffect(()=>{r||re(!1)},[r]),c.useEffect(()=>{i?.path&&G({ownerKey:ge.current,mode:"working",route:{type:"diff",path:i.path,staged:i.staged}})},[i]);const[fe,Se]=c.useState(null),[we,xe]=c.useState(null),[ye,De]=c.useState(""),[Te,ve]=c.useState(new Set),[Ne,H]=c.useState(!1),[pe,Ae]=c.useState(!1),[We,Re]=c.useState([]),[Le,qe]=c.useState([]),[$e,tt]=c.useState([]),[mt,wt]=c.useState(null),[Es,Is]=c.useState(null),[an,ln]=c.useState(0),As=mu(),it=pu({directory:p,branch:h?.current,chooseContributor:As.choose}),Ct=hu(p,l,u),[Ue,Rt]=c.useState(null),[Yn,ts]=c.useState(!1),[cn,Bt]=c.useState([]),[un,Ie]=c.useState("rebase"),Ge=c.useCallback((w,W)=>{Bt(w),Ie(W),ts(!0)},[]),_e=h?.current??null,dn=Di(w=>w.setOverride),ct=Di(w=>w.clearOverride),Ze=Dd(p||null,_e,r&&N==="commit"&&A===!0),pt=Ze.selectedCommit?.hash??null,ze=Jl(p||null,u),ss=c.useMemo(()=>new Set(ze.read?.repository.remotes.map(w=>w.name)??[]),[ze.read]),Be=_d(p||null,_e,r&&A===!0,{branches:v,remoteNames:ss,primaryRemote:ze.contexts[0]?.primaryRemote,readContext:ze.contexts[0]??null}),ns=wd(_e,Be.base),Ps=A===!1||jd(_e,Be.base,h!==null,Be.resolved),st=ze.read?.binding?.remotes[0]?.name??ze.read?.repository.remotes.find(w=>w.name==="origin")?.name??ze.read?.repository.remotes[0]?.name??"",ht=ze.read?ze.read.binding?.providers.find(w=>w.readiness==="ready")?.accountId??null:void 0,Ts=c.useMemo(()=>Xl(D,k,b,w=>({id:"local-config",name:w.userName,...w,color:"info",icon:"user"}),ht),[ht,b,D,k]),rs=c.useMemo(()=>{const w=ze.read;return!w?.binding||ze.status!=="ready"||w.binding.state==="bound"?null:Ql(w.binding)?a("gitView.identity.configChanged"):a("gitView.context.needsAttention")},[ze.read,ze.status,a]),nt=Md(p||null,_e,ze.contexts[0]??null,r&&N==="pr"&&A===!0),gt=nt.selectedSource,Jn=c.useMemo(()=>N==="pr"?gt:N==="branch"&&_e&&Be.base?{kind:"branch",baseRef:Be.base,headRef:_e}:N==="commit"&&pt?{kind:"commit",hash:pt}:null,[Be.base,_e,N,pt,gt]),fn=N==="branch"?Be.revision:"",be=kd(p||null,Jn,r&&A===!0,fn,nt.readContext,nt.provider),{fetchDiff:Lt,fetchFullFile:Dt}=be,is=c.useMemo(()=>be.files?[...be.files].sort((w,W)=>w.path.localeCompare(W.path)):null,[be.files]),bt=Y.type==="comparison"&&Y.sourceKey===be.key?Y.path:null,[Xn,Qn]=c.useState(0),Ds=c.useCallback(async w=>{try{const{diff:W}=await Lt(w),ie={original:"",modified:"",isBinary:Od(W)};return ie.isBinary||(ie.fileDiff=_i(w,W)),{status:"ready",diff:ie}}catch(W){return{status:"error",message:W instanceof Error?W.message:a("diffView.state.failedToLoadDiff")}}},[Lt,a]),Zn=Sd(be.files?N==="pr"?JSON.stringify([be.key,be.revision]):be.key:null,r&&bt?bt:"",r?Ds:null,uo,JSON.stringify([fn,N==="pr"?be.revision:0,Xn])),ot=bt?Zn.get(bt)??uo:null,[Ft,os]=c.useState(null),[_s,Ms]=c.useState(null),$t=Ft&&Ft.source===ot?Ft.request:null,jt=_s&&_s.source===ot?_s.diff:null;c.useEffect(()=>{const w=ot;if(!$t||!bt||w?.status!=="ready"||jt)return;let W=!1;const ie=bt,je=async()=>{if(N==="pr"){const{original:yt,modified:Oe}=await Dt(ie);return{original:yt,modified:Oe,fileDiff:Fd({name:ie,contents:yt},{name:ie,contents:Oe})}}const{diff:Pe}=await Lt(ie,sp);return{original:"",modified:"",fileDiff:_i(ie,Pe)}};return(async()=>{try{const Pe=await je();W||Ms({source:w,diff:Pe})}catch(Pe){if(W)return;ce.error(Pe instanceof Error?Pe.message:a("diffView.state.failedToLoadDiff")),os(null)}})(),()=>{W=!0}},[ot,bt,jt,Lt,Dt,N,$t,a]),c.useEffect(()=>{N==="branch"&&Ps&&K("working")},[Ps,K,N]),c.useEffect(()=>{G(w=>w.ownerKey===te&&w.route.type==="comparison"&&w.route.sourceKey!==be.key?{...w,route:ds}:w)},[be.key,te]);const at=c.useMemo(()=>{const w=h?.files??[],W=new Map;for(const ie of w)W.set(ie.path,ie);return Array.from(W.values()).sort((ie,je)=>ie.path.localeCompare(je.path))},[h?.files]),xt=c.useMemo(()=>at.filter(rp),[at]),as=c.useMemo(()=>at.filter(ip),[at]),er=$e,mn=lt(c.useCallback(w=>!p||Y.type!=="diff"?null:w.directories.get(p)?.diffCache.get(fo(Y.path,Y.staged))??null,[p,Y])),pn=c.useMemo(()=>Y.type!=="diff"?null:at.find(w=>w.path===Y.path)??null,[at,Y]),He=c.useCallback(async(w=!0)=>{if(p)try{await Promise.all([I(p,l),U(p,l)])}catch(W){w&&ce.error(W instanceof Error?W.message:a("gitView.toast.refreshRepositoryFailed"))}},[p,U,I,l,a]),hn=c.useMemo(()=>(v?.all??[]).filter(w=>!w.startsWith("remotes/")).sort(),[v]),gn=c.useMemo(()=>(v?.all??[]).filter(w=>w.startsWith("remotes/")).map(w=>w.replace(/^remotes\//,"")).sort(),[v]),Wt=c.useCallback(async w=>{if(!p)return;const W=w.replace(/^remotes\//,"");try{const ie=await l.checkoutBranch(p,W);ce.success(a("gitView.toast.checkedOut",{name:ie.branch||W})),await He()}catch(ie){ce.error(ie instanceof Error?ie.message:a("gitView.toast.checkoutFailed",{name:W}))}},[p,l,He,a]),bn=c.useCallback(w=>{const W=w.replace(/^remotes\//,"");if((h?.files?.length??0)>0){Rt(W);return}Wt(W)},[Wt,h?.files]),xn=c.useCallback(async w=>{if(p)try{await l.createBranch(p,w,_e??"HEAD"),await l.checkoutBranch(p,w),await He()}catch(W){throw ce.error(W instanceof Error?W.message:a("gitView.toast.createBranchFailed")),W}},[_e,p,l,He,a]),ls=c.useCallback(async()=>{if(!p){tt([]);return}try{const w=await l.getRemotes(p);tt(w)}catch{tt([])}},[p,l]),At=c.useCallback(async()=>{p&&(Promise.allSettled([U(p,l),ls()]),await I(p,l).catch(()=>{}))},[p,U,I,l,ls]);c.useEffect(()=>{!p||!r||(B(p),P(p,l))},[p,P,l,B,r]),c.useEffect(()=>{r&&ls()},[ls,r]),c.useEffect(()=>{if(!r||N!=="working"||!p||at.length===0)return;const w=Array.from(new Set([...xt.map(ie=>ie.path),...Le,...at.slice(0,20).map(ie=>ie.path)])).filter(Boolean);if(w.length===0)return;const W=window.setTimeout(()=>{X(p,l,w,{maxFiles:40})},120);return()=>window.clearTimeout(W)},[at,p,l,N,X,xt,Le,r]),c.useEffect(()=>{if(!r)return;if(Y.type!=="diff"){wt(null);return}const w=fo(Y.path,Y.staged);if(Is(null),!p||Q(p,w)){wt(null);return}let W=!1;const ie=rn();return wt(null),l.getGitFileDiff(p,{path:Y.path,staged:Y.staged||void 0}).then(je=>{W||ue(p,w,{original:je.original??"",modified:je.modified??"",isBinary:je.isBinary,submodule:je.submodule},ie)}).catch(je=>{if(!W){if(je instanceof wi&&je.reason!=="path_not_found"){Is({key:`${p}\0${Y.path}`,reason:je.reason});return}je instanceof wi&&I(p,l,{force:!0,silent:!0}),wt(je instanceof Error?je.message:String(je))}}),()=>{W=!0}},[p,an,I,Q,l,Y,ue,r]);const Vt=async(w,W,ie=!1)=>{if(!p)return;const je=Ct.start();if(!je)return;Se(w);const Pe=a(w==="fetch"?"gitView.sync.fetch":w==="pull"?"gitView.sync.pull":w==="publish"?"gitView.publish.title":"gitView.sync.syncChanges");let yt=null;try{if(w==="sync"||w==="publish"){const Oe=await it.prepare(w==="publish"?"push":"sync",{forceChoose:ie,onOperation:je.onOperation});yt=fc(await Oe())}else if(W&&h)await mc({action:w,directory:p,remoteName:W.name,status:h,sourceControl:u,git:l,onOperation:je.onOperation});else throw new Ot("tracking-required");if(!je.isCurrent())return;w==="fetch"&&W?ce.success(a("gitView.toast.fetchedFromRemote",{name:W.name})):w==="pull"&&W?ce.success(a("gitView.toast.pulledFromRemote",{name:W.name})):w==="sync"?ce.success(yt?.kind==="up-to-date"?a("gitView.toast.alreadyUpToDate"):yt?.kind==="pulled"?a("gitView.toast.pulledFromRemote",{name:yt.remoteName}):yt?.kind==="pushed"?a("gitView.toast.pushedToUpstream",{name:yt.remoteName}):a("gitView.toast.syncedChanges")):w==="publish"&&ce.success(a("gitView.publish.succeeded")),await At()}catch(Oe){if(Oe instanceof An||Oe instanceof Nr){if(je.isCurrent()&&await At(),je.isCurrent()&&Oe instanceof An&&Oe.read.availability==="available"&&Oe.read.operation.state==="conflicted"&&Oe.read.operation.error.code==="CONFLICT"){const qt=((await l.getGitStatus(p).catch(()=>null))?.files??[]).filter(fr).map(jn=>jn.path);qt.length>0&&Ge(qt,"merge")}return}if(Oe instanceof Ot&&Oe.code==="stale-runtime")return;if(Oe instanceof Ot&&it.errorMessage(Oe)){ce.info(it.errorMessage(Oe));return}await At(),ce.error(Oe instanceof Ot?Oe.code==="contributor-publish-cancelled-after-update"?a("gitView.toast.contributorPublishCancelledAfterUpdate"):Oe.code==="contributor-publish-cancelled"?a("gitView.toast.contributorPublishCancelled"):a("gitView.toast.syncActionFailed",{action:Pe}):Oe instanceof Error?Oe.message:a("gitView.toast.syncActionFailed",{action:Pe}))}finally{je.finish(),je.isCurrent()&&Se(null)}},Ut=c.useCallback(async(w,W)=>{if(!(!p||w.length===0))try{W==="stage"?w.length>1?await Zl(p,w):await ec(p,w[0]):w.length>1?await tc(p,w):await sc(p,w[0]),await He(!1)}catch(ie){ce.error(ie instanceof Error?ie.message:a(W==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed"))}},[p,He,a]),Os=c.useCallback((w,W=!1)=>{oe({type:"diff",path:w,staged:W})},[oe]),zs=c.useCallback(async w=>{if(p){ve(W=>new Set(W).add(w));try{await l.revertGitFile(p,w),ce.success(a("gitView.toast.revertedFile",{path:w})),await He(!1)}catch(W){ce.error(W instanceof Error?W.message:a("gitView.toast.revertFailed"))}finally{ve(W=>{const ie=new Set(W);return ie.delete(w),ie})}}},[p,l,He,a]),yn=c.useCallback(async w=>{if(!p||w.length===0||Ne)return;const W=Array.from(new Set(w));H(!0),ve(new Set(W));try{const ie=await tp(W,je=>l.revertGitFile(p,je),np);if(await He(!1),ie.failures.length===0)ce.success(W.length===1?a("gitView.toast.revertedFilesSingle",{count:W.length}):a("gitView.toast.revertedFilesPlural",{count:W.length}));else if(ie.failures.length===W.length)ce.error(ie.failures[0]?.error?.message??a("gitView.toast.revertFailed"));else{const je=W.length-ie.failures.length;ce.warning(je===1?a("gitView.toast.revertedSomeSingle",{success:je,failed:ie.failures.length}):a("gitView.toast.revertedSomePlural",{success:je,failed:ie.failures.length}))}}catch(ie){ce.error(ie instanceof Error?ie.message:a("gitView.toast.revertFailed"))}finally{ve(new Set),H(!1)}},[p,l,Ne,He,a]),tr=c.useCallback(w=>{const W=w.map(ie=>ie.trim()).filter(Boolean);if(W.length===0){Re([]);return}De(ie=>`${ie.trim()}${ie.trim()?`
23
23
 
24
24
  `:""}${W.join(`
25
- `)}`.trim()),Re([])},[]),vn=c.useCallback(async()=>{if(!p)return;const w=xt.map(W=>W.path).sort();if(w.length===0){ce.error(a("gitView.toast.selectFileToDescribe"));return}Ae(!0);try{const{message:W}=await Ci(p,w);De(W.subject?.trim()??""),Re(Array.isArray(W.highlights)?W.highlights:[])}catch(W){ce.error(W instanceof Error?W.message:a("gitView.toast.generateCommitMessageFailed"))}finally{Ae(!1)}},[p,xt,a]),sr=async(w={})=>{if(!p)return;if(!ye.trim()){ce.error(a("gitView.toast.enterCommitMessage"));return}const W=xt.map(Pe=>Pe.path).sort();if(W.length===0){ce.error(a("gitView.toast.selectFileToCommit"));return}xe(w.pushAfter?"commitAndPush":"commit");let ie=null,je="pending";try{if(await l.createGitCommit(p,ye.trim(),{files:W}),je="local",ce.success(a("gitView.toast.commitCreated")),De(""),Re([]),w.pushAfter){if(ie=Ct.start(),!ie){ce.warning(a("gitView.publish.commitKept")),await At();return}const Pe=await rt.prepare("push",{onOperation:ie.onOperation});Se("publish"),await Pe(),je="published",ce.success(a("gitView.publish.succeeded"))}await At()}catch(Pe){if(w.pushAfter&&je==="local"&&ce.warning(a("gitView.publish.commitKept")),Pe instanceof An||Pe instanceof Nr){await At();return}if(Pe instanceof Ot&&Pe.code==="stale-runtime")return;if(Pe instanceof Ot&&rt.errorMessage(Pe)){ce.info(rt.errorMessage(Pe));return}w.pushAfter&&await At(),ce.error(Pe instanceof Ot?Pe.code==="contributor-publish-cancelled-after-update"?a("gitView.toast.contributorPublishCancelledAfterUpdate"):Pe.code==="contributor-publish-cancelled"?a("gitView.toast.contributorPublishCancelled"):a("gitView.toast.syncActionFailed",{action:a("gitView.sync.syncChanges")}):Pe instanceof Error?Pe.message:a("gitView.toast.createCommitFailed"))}finally{ie?.finish(),xe(null),w.pushAfter&&Se(null)}},nr=c.useMemo(()=>(h?.files??[]).filter(fr).length,[h?.files]),Et=!!h?.mergeInProgress?.head,cs=c.useCallback(async()=>{if(p)try{if(Et){const w=await l.continueMerge(p);w.conflict?(Ge(w.conflictFiles??[],"merge"),ce.error(a("gitView.toast.mergeConflictsDetected"))):ce.success(a("gitView.toast.mergeCompleted"))}else{const w=await l.continueRebase(p);w.conflict?(Ge(w.conflictFiles??[],"rebase"),ce.error(a("gitView.toast.rebaseConflictsDetected"))):ce.success(a("gitView.toast.rebaseStepCompleted"))}await qe(!1)}catch(w){ce.error(w instanceof Error?w.message:a("gitView.toast.continueOperationFailed"))}},[p,l,Et,Ge,qe,a]),Gt=c.useCallback(async w=>{if(p)try{w==="merge"?(await l.abortMerge(p),ce.success(a("gitView.toast.mergeAborted"))):(await l.abortRebase(p),ce.success(a("gitView.toast.rebaseAborted"))),await qe(!1)}catch(W){ce.error(W instanceof Error?W.message:a("gitView.toast.abortOperationFailed"))}},[p,l,qe,a]),Bs=c.useCallback(()=>{const w=(h?.files??[]).filter(fr).map(W=>W.path);Ge(w,Et?"merge":"rebase")},[Et,Ge,h?.files]),Ls=c.useMemo(()=>{const w=[];return xt.length>0&&w.push({id:"staged",title:a("gitView.changes.stagedTitle"),entries:xt,statsScope:"staged",actionSymbol:"-",actionAllLabel:a("gitView.changes.unstageAllAria"),getActionLabel:W=>a("gitView.changes.unstageFileAria",{path:W}),onActionFile:W=>{Ut([W],"unstage")},onActionAll:W=>{Ut(W,"unstage")},onViewDiff:W=>Os(W,!0),onRevertFile:zs,showRevertActions:!1,accent:!0}),as.length>0&&w.push({id:"unstaged",title:a("gitView.changes.title"),entries:as,statsScope:"working",actionSymbol:"+",actionAllLabel:a("gitView.changes.stageAllAria"),getActionLabel:W=>a("gitView.changes.stageFileAria",{path:W}),onActionFile:W=>{Ut([W],"stage")},onActionAll:W=>{Ut(W,"stage")},onViewDiff:W=>Os(W,!1),onRevertFile:zs}),w},[zs,Os,Ut,xt,a,as]),Fs=t.jsxs(t.Fragment,{children:[rt.context?t.jsx(fu,{context:rt.context,onSelect:rt.settle}):null,rt.confirmDialog,t.jsx(mu,{candidates:As.candidates,onSelect:As.settle})]}),_t=w=>t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[Fs,t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[s?t.jsx("button",{type:"button",className:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":a("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(H,{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:a("mobile.nav.changes")}),t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:h?.current||p||""})]}),m===!1&&Array.isArray(g)&&g.length>0?t.jsx(wu,{repositories:g,selectedRepository:f??null,onSelectRepository:W=>{n&&$(n,W)},repositoryRoot:n??void 0}):null]}),t.jsx("div",{className:"min-h-0 flex-1",children:w})]});if(!p)return _t(t.jsx(ft,{message:a("gitView.empty.selectSessionOrDirectory")}));if(m===!1&&A!==!0)return _t(t.jsx(ku,{root:n,rootIsGitRepo:m,resolvedIsGitRepo:A,nestedRepos:g,onRetryDiscovery:()=>{n&&M(n,{force:!0})}}));if(_&&A===null)return _t(t.jsx(ft,{loading:!0,message:a("gitView.loading.checkingRepository")}));if(Y.type==="diff")return t.jsx(lo,{path:Y.path,diff:mn,staged:Y.staged,fileExists:!!pn,unavailableReason:Es?.key===`${p}\0${Y.path}`?Es.reason:null,error:mt,onBack:()=>oe({type:"list"}),onRetry:()=>ln(w=>w+1)});const Kt=a(N==="pr"?Sn("session.githubIntegration.tabs.pullRequests",nt.provider):N==="branch"?"diffView.scope.branch":N==="commit"?"commitComparison.mode":"mobile.nav.changes"),wn=N==="branch"&&Be.base?pu(Be.base):N==="commit"?pt?.slice(0,8):N==="pr"&&gt?`#${gt.number}`:null;if(bt&&it)return t.jsx(lo,{path:bt,subtitle:[Kt,wn].filter(Boolean).join(" · "),diff:jt??(it.status==="ready"?it.diff:null),fileExists:!be.files||be.files.some(w=>w.path===bt),error:be.error??(it.status==="error"?it.message:null),onBack:()=>oe(ds),onRetry:()=>{be.error&&be.refresh(),Qn(w=>w+1)},onExpandContextRequest:it.status==="ready"?w=>os({source:it,request:w}):void 0,pendingContextExpansion:$t,contextLoading:$t!==null&&!jt});const rr=()=>N==="pr"&&!gt?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(ft,{loading:nt.loading,message:nt.error??(nt.loading?a(Sn("session.githubPrPicker.loading.pullRequests",nt.provider)):a(Sn("pullRequestComparison.select",nt.provider)))}),!nt.loading&&t.jsx(Pi,{mobile:!0,comparison:nt})]}):N==="branch"&&!Be.base?t.jsx(ft,{loading:!Be.resolved,message:Be.resolved?a("gitView.pr.toast.baseBranchRequired"):a("diffView.branch.resolvingBase")}):N==="commit"&&!pt?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[Ze.loading&&t.jsx(H,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:Ze.loading?a("diffView.state.loadingChanges"):Ze.error??a("commitComparison.noCommits")}),Ze.error&&t.jsx(Ce,{variant:"outline",size:"lg",onClick:()=>{Ze.refresh()},children:a("diffView.actions.retry")})]}):be.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:a("diffView.state.failedToLoadDiff")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:be.error}),t.jsx(Ce,{variant:"outline",size:"lg",onClick:()=>{be.refresh()},children:a("diffView.actions.retry")})]}):is?is.length===0?t.jsx(ft,{icon:N==="branch",message:N==="pr"?a("walkthrough.blocked.emptyDiff.description"):N==="commit"?a("commitComparison.emptyDiff"):a("diffView.branch.empty",{base:wn??""})}):t.jsx(ip,{files:is,onSelect:w=>{be.key&&oe({type:"comparison",path:w,sourceKey:be.key})}}):t.jsx(ft,{loading:!0,message:a("diffView.state.loadingChanges")});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[Fs,t.jsxs("header",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b border-border/60 px-3 py-2",children:[s?t.jsx("button",{type:"button",className:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":a("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(H,{name:"close",className:"size-5"})}):null,t.jsxs(Zl,{open:ne,onOpenChange:re,children:[t.jsx(ec,{asChild:!0,children:t.jsxs(Ce,{variant:"outline",className:tc({size:"mobile"}),"data-mobile-comparison-trigger":!0,"aria-label":a("diffView.scope.selectorAria"),children:[t.jsx("span",{children:Kt}),t.jsx(H,{name:"arrow-down-s",className:"size-4"})]})}),t.jsx(sc,{align:"start",children:t.jsxs(nc,{value:N,onValueChange:w=>{(w==="working"||w==="branch"||w==="commit"||w==="pr")&&K(w)},children:[t.jsx(Nn,{value:"working",className:"min-h-8 items-center",children:a("mobile.nav.changes")}),ns&&t.jsx(Nn,{value:"branch",className:"min-h-8 items-center",children:a("diffView.scope.branch")}),t.jsx(Nn,{value:"commit",className:"min-h-8 items-center",children:a("commitComparison.mode")}),t.jsx(Nn,{value:"pr",className:"min-h-8 items-center",children:a(Sn("session.githubIntegration.tabs.pullRequests",nt.provider))})]})})]}),r&&N==="branch"&&t.jsx(_d,{mobile:!0,branches:v?.all??[],currentBranch:_e,base:Be.base,automatic:Be.source!=="chosen",onSelect:w=>{_e&&dn(p,_e,w)},onSelectAutomatic:()=>{_e&&ct(p,_e)}},JSON.stringify([te,_e])),r&&N==="commit"&&t.jsx(Md,{mobile:!0,commits:Ze.commits,selectedHash:pt,loading:Ze.loading,error:Ze.error,onSelect:Ze.select,onRefresh:()=>{Ze.refresh()}},JSON.stringify([te,_e])),r&&N==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(Pi,{mobile:!0,comparison:nt},JSON.stringify([te,_e])),gt&&t.jsx(Ce,{variant:"ghost",size:"sm",disabled:be.loading,"aria-label":a("session.githubIssuePicker.actions.refresh"),onClick:()=>{be.refresh()},children:t.jsx(H,{name:"refresh",className:"size-4"})})]})]}),N==="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(hu,{currentBranch:h?.current,localBranches:hn,remoteBranches:gn,branchInfo:v?.branches,currentBranchAhead:h?.ahead,onCheckout:w=>{bn(w)},onCreate:xn,disabled:_,directory:p,switchBlockedNotice:(h?.files?.length??0)>0?a("gitView.branch.switchBlockedNotice"):null})}),t.jsx(gu,{activeProfile:Ts,identities:L,attention:rs,triggerClassName:"max-w-[10rem] shrink [&_.git-identity-label]:hidden sm:[&_.git-identity-label]:inline",onOpen:()=>{O(u,D.map(w=>w.account))},onSelect:w=>{z(w)},isApplying:R,onConfigure:()=>j(!0),applicability:w=>{const W=ze.read?.repository.remotes.find(ie=>ie.name===st);return W?bu(w,rc(W.fetch.displayUrl)):{applicable:!0}}}),t.jsx(xu,{syncAction:Ct.entry?.executing?fe:null,remotes:er,onFetch:w=>{Vt("fetch",w)},onPull:w=>{Vt("pull",w)},onSync:w=>{Vt("sync",w)},onPublish:()=>{Vt("publish")},onChooseSyncTargets:()=>{Vt("sync",void 0,!0)},currentBranch:h?.current,hasTracking:!!h?.tracking,disabled:_||Ct.blocked,aheadCount:h?.ahead??0,behindCount:h?.behind??0,trackingRemoteName:h?.tracking?.split("/")[0],trackingBranch:h?.tracking,hasUncommittedChanges:yu(ot),choosesPushDestination:x})]}),t.jsx(Sd,{open:C,onOpenChange:j,directory:p}),t.jsx(vu,{className:"mx-3 mt-3",entry:Ct.entry,onRefresh:()=>{Ct.refresh()},onCancel:()=>{Ct.cancel()}}),N==="working"&&t.jsx(Nd,{mergeInProgress:h?.mergeInProgress,rebaseInProgress:h?.rebaseInProgress,onContinue:cs,onAbort:()=>Gt(Et?"merge":"rebase"),onResolveWithAI:Bs,conflictCount:nr,isLoading:fe!==null||we!==null}),N!=="working"?t.jsx("div",{className:"min-h-0 flex-1",children:rr()}):ot.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(Cd,{groups:Ls,diffStats:h?.diffStats,revertingPaths:Te,onRevertAll:yn,isRevertingAll:Ne,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:He})}),t.jsx("div",{className:"shrink-0 border-t border-border/70 px-4 pb-4 pt-3",children:t.jsx(Rd,{stagedCount:xt.length,commitMessage:ye,onCommitMessageChange:De,generatedHighlights:We,onInsertHighlights:tr,onGenerateMessage:vn,isGeneratingMessage:pe,onCommit:()=>{sr({pushAfter:!1})},onCommitAndPush:()=>{sr({pushAfter:!0})},commitAction:we,networkOperationBlocked:Ct.blocked,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(ft,{icon:!0,message:a("gitView.empty.cleanTitle"),description:a("mobile.changes.cleanDescription")})}),p&&t.jsx(Ed,{open:Yn,onOpenChange:ts,conflictFiles:cn,directory:p,operation:un,onAbort:()=>{Gt(un)},onNavigatedToChat:o}),t.jsx(Id,{open:Ue!==null,onOpenChange:w=>{w||Rt(null)},targetBranch:Ue??"",changedFileCount:h?.files?.length??0,onCommitAndSwitch:async(w,W)=>{const ie=Ue;if(!ie||!p)return;const je=h?.current??null;if(await l.createGitCommit(p,w,{addAll:!0}),W)try{await(await rt.prepare("push"))()}catch{ce.error(a("gitView.dirtySwitch.pushFailed")),await qe(),Rt(null);return}ce.success(je?W?a("gitView.publish.succeeded"):a("gitView.dirtySwitch.committedNotPushed",{branch:je}):a("gitView.toast.commitCreated")),await qe(),Rt(null),await Wt(ie)},onGenerateMessage:async()=>{if(!p)return"";const w=(h?.files??[]).map(ie=>ie.path).sort(),{message:W}=await Ci(p,w);return W.subject?.trim()??""},onRevertAndSwitch:async()=>{const w=Ue;if(!w||!p)return;await yn((h?.files??[]).map(ie=>ie.path));const W=await l.getGitStatus(p);if(!W.isClean&&(W.files?.length??0)>0){ce.error(a("gitView.dirtySwitch.revertIncomplete"));return}Rt(null),await Wt(w)}})]})},ft=n=>{const e=de.c(13),{message:s,description:i,loading:r,icon:o}=n,a=r===void 0?!1:r,l=o===void 0?!1:o;let u;e[0]!==a?(u=a?t.jsx(H,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,e[0]=a,e[1]=u):u=e[1];let m;e[2]!==l?(m=l?t.jsx(H,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e[2]=l,e[3]=m):m=e[3];let f;e[4]!==s?(f=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[4]=s,e[5]=f):f=e[5];let g;e[6]!==i?(g=i?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i}):null,e[6]=i,e[7]=g):g=e[7];let p;return e[8]!==u||e[9]!==m||e[10]!==f||e[11]!==g?(p=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:[u,m,f,g]})}),e[8]=u,e[9]=m,e[10]=f,e[11]=g,e[12]=p):p=e[12],p},lo=n=>{const e=de.c(55),{path:s,subtitle:i,diff:r,staged:o,fileExists:a,unavailableReason:l,error:u,onBack:m,onRetry:f,onExpandContextRequest:g,pendingContextExpansion:p,contextLoading:h}=n,x=o===void 0?!1:o,v=l===void 0?null:l,{t:b}=he();let C;e[0]!==s?(C=ic(s)||"text",e[0]=s,e[1]=C):C=e[1];const j=C,R=Fe(op),T=Fe(ap);let D;e[2]!==R||e[3]!==b?(D=b(R?"diffView.whitespace.hidden":"diffView.whitespace.shown"),e[2]=R,e[3]=b,e[4]=D):D=e[4];const k=D;let S;e[5]!==b?(S=b("header.actions.backAria"),e[5]=b,e[6]=S):S=e[6];let y;e[7]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx(H,{name:"arrow-left",className:"size-5"}),e[7]=y):y=e[7];let E;e[8]!==m||e[9]!==S?(E=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":S,onClick:m,children:y}),e[8]=m,e[9]=S,e[10]=E):E=e[10];let O;e[11]!==s?(O=t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:s}),e[11]=s,e[12]=O):O=e[12];let L;e[13]!==i?(L=i&&t.jsx("p",{className:"truncate typography-meta text-muted-foreground",children:i}),e[13]=i,e[14]=L):L=e[14];let z;e[15]!==O||e[16]!==L?(z=t.jsxs("div",{className:"min-w-0 flex-1 px-2",children:[O,L]}),e[15]=O,e[16]=L,e[17]=z):z=e[17];const A=R?"text-foreground":"text-muted-foreground";let _;e[18]!==A?(_=Z("flex size-9 shrink-0 items-center justify-center rounded-lg hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",A),e[18]=A,e[19]=_):_=e[19];let B;e[20]!==b?(B=b("diffView.actions.hideWhitespace"),e[20]=b,e[21]=B):B=e[21];let P;e[22]!==R||e[23]!==T?(P=()=>T(!R),e[22]=R,e[23]=T,e[24]=P):P=e[24];let M;e[25]!==R?(M=t.jsx(kd,{hidden:R,className:"size-5"}),e[25]=R,e[26]=M):M=e[26];let $;e[27]!==R||e[28]!==_||e[29]!==B||e[30]!==P||e[31]!==M||e[32]!==k?($=t.jsx("button",{type:"button",className:_,"aria-label":B,"aria-pressed":R,title:k,onClick:P,children:M}),e[27]=R,e[28]=_,e[29]=B,e[30]=P,e[31]=M,e[32]=k,e[33]=$):$=e[33];let I;e[34]!==z||e[35]!==$||e[36]!==E?(I=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:[E,z,$]}),e[34]=z,e[35]=$,e[36]=E,e[37]=I):I=e[37];let U;e[38]!==h||e[39]!==r||e[40]!==u||e[41]!==a||e[42]!==R||e[43]!==j||e[44]!==g||e[45]!==f||e[46]!==s||e[47]!==p||e[48]!==x||e[49]!==b||e[50]!==v?(U=t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:a?v==="nested_repository"?t.jsx(ft,{icon:!0,message:b("diffView.unavailable.nestedRepositoryTitle"),description:b("diffView.unavailable.nestedRepositoryDescription")}):v==="untracked_directory"?t.jsx(ft,{icon:!0,message:b("diffView.unavailable.untrackedDirectoryTitle"),description:b("diffView.unavailable.untrackedDirectoryDescription")}):u?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:b("mobile.changes.diffDetail.loadFailed")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:u}),t.jsx(Ce,{type:"button",size:"sm",variant:"outline",onClick:f,children:b("diffView.actions.retry")})]})}):r?r.submodule?t.jsx("div",{className:"p-3",children:t.jsx(jd,{state:r.submodule,staged:x})}):r.isBinary?t.jsx(ft,{icon:!0,message:b("diffView.binary.unavailable")}):oc(s)&&!r.fileDiff?t.jsx(ft,{icon:!0,message:b("mobile.changes.diffDetail.imageUnavailable")}):t.jsx(Gn,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:t.jsx(Od,{original:r.original,modified:r.modified,fileDiff:r.fileDiff,language:j,fileName:s,renderSideBySide:!1,wrapLines:!0,hideWhitespace:R,layout:"inline",onExpandContextRequest:g,pendingContextExpansion:p,contextLoading:h})}):t.jsx(ft,{loading:!0,message:b("diffView.state.loadingDiff")}):t.jsx(ft,{icon:!0,message:b("mobile.changes.diffDetail.missingTitle"),description:b("mobile.changes.diffDetail.missingDescription")})}),e[38]=h,e[39]=r,e[40]=u,e[41]=a,e[42]=R,e[43]=j,e[44]=g,e[45]=f,e[46]=s,e[47]=p,e[48]=x,e[49]=b,e[50]=v,e[51]=U):U=e[51];let X;return e[52]!==I||e[53]!==U?(X=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[I,U]}),e[52]=I,e[53]=U,e[54]=X):X=e[54],X},ip=n=>{const e=de.c(12),{files:s,onSelect:i}=n,{t:r}=he();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 u;e[6]!==i||e[7]!==r?(u=m=>{const f=m.status==="A"?r("diffView.change.new"):m.status==="D"?r("diffView.change.deleted"):m.status==="R"?r("diffView.change.renamed"):m.status==="C"?r("diffView.change.copied"):r("diffView.change.modified"),g=m.status==="A"?"var(--status-success)":m.status==="D"?"var(--status-error)":m.status==="R"||m.status==="C"?"var(--status-info)":"var(--status-warning)";return t.jsx("li",{children:t.jsxs(Ce,{variant:"ghost",size:"lg",className:"w-full justify-start gap-2.5 text-start normal-case",onClick:()=>i(m.path),children:[t.jsx("span",{className:"w-4 shrink-0 text-center typography-meta font-semibold uppercase",style:{color:g},"aria-label":f,children:m.status}),t.jsx(Wo,{filePath:m.path,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label",title:m.path,children:m.path}),(m.insertions>0||m.deletions>0)&&t.jsxs("span",{className:"shrink-0 typography-meta text-muted-foreground",children:["+",m.insertions," -",m.deletions]}),t.jsx(H,{name:"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground"})]})},m.path)},e[6]=i,e[7]=r,e[8]=u):u=e[8],a=s.map(u),e[2]=s,e[3]=i,e[4]=r,e[5]=a}else a=e[5];let l;return e[9]!==o||e[10]!==a?(l=t.jsx(Gn,{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]=l):l=e[11],l};function op(n){return n.diffHideWhitespace}function ap(n){return n.setDiffHideWhitespace}const lp=c.lazy(()=>ws(()=>import("./FilesView-BeMtsSlV.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}))),Nt=n=>on(n)??"",Qs=n=>{const e=Nt(n);return!e||e==="/"?e||"/":e.split("/").filter(Boolean).at(-1)??e},cp=n=>{const e=Nt(n);if(!e||e==="/")return null;const s=e.lastIndexOf("/");return s<=0?e.startsWith("/")?"/":null:e.slice(0,s)},up=(n,e)=>{const s=Nt(n),i=Nt(e);return!i||s===i?Qs(s):s.startsWith(`${i}/`)?s.slice(i.length+1):s},dp=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""},fp=n=>{const e=de.c(6),{onClose:s,visible:i}=n,r=i===void 0?!0:i,o=Lr()??null;let a;e[0]!==o?(a=Nt(o),e[0]=o,e[1]=a):a=e[1];const l=a;let u;return e[2]!==s||e[3]!==l||e[4]!==r?(u=t.jsx(mp,{root:l,onClose:s,visible:r},l),e[2]=s,e[3]=l,e[4]=r,e[5]=u):u=e[5],u},mp=({root:n,onClose:e,visible:s})=>{const{t:i}=he(),{files:r}=Un(),o=qa(),a=Ya(G=>G.setSelectedPath),[l,u]=c.useState(()=>({type:"browser",directory:n})),[m,f]=c.useState([]),[g,p]=c.useState(!1),[h,x]=c.useState(null),[v,b]=c.useState(""),[C,j]=c.useState([]),[R,T]=c.useState(!1),D=c.useRef(0),k=l.type==="browser"?l.directory:l.returnDirectory,S=c.useRef(k);S.current=k;const y=c.useCallback(async(G,N)=>{if(!G)return;const Y=!o,ne=D.current+1;D.current=ne,p(!0),N?.background||x(null);try{const re=await r.listDirectory(G,{respectGitignore:Y});if(D.current!==ne)return;x(null),f(re.entries.slice().sort((K,oe)=>K.isDirectory!==oe.isDirectory?K.isDirectory?-1:1:K.name.localeCompare(oe.name)))}catch(re){if(D.current!==ne)return;if(N?.background){console.error("Failed to reload mobile directory:",re);return}f([]),x(re instanceof Error?re.message:i("mobile.files.error.listFailed"))}finally{D.current===ne&&p(!1)}},[r,o,i]);c.useEffect(()=>{l.type==="browser"&&y(l.directory)},[y,l]);const E=c.useRef(l);E.current=l;const O=c.useRef(m);O.current=m;const L=c.useCallback(({directories:G})=>{const N=E.current;N.type==="browser"&&(G&&!G.some(Y=>Nt(Y)===Nt(N.directory))||O.current.length>Su||y(N.directory,{background:!0}))},[y]);Nu({root:n,active:s,whileInactive:"hold",onChanges:L});const z=c.useCallback(async G=>{Nt(G)===Nt(S.current)&&await y(S.current)},[y]),{canUpload:A,uploadingDirectory:_,pickFiles:B,uploadElements:P}=Cu({root:n,refreshDirectory:z}),M=_!==null;c.useEffect(()=>{if(l.type!=="browser")return;const G=v.trim();if(!G){j([]),T(!1);return}let N=!1;const Y=window.setTimeout(()=>{T(!0),r.search({directory:l.directory,query:G,maxResults:40}).then(ne=>{N||j(ne)}).catch(()=>{N||j([])}).finally(()=>{N||T(!1)})},250);return()=>{N=!0,window.clearTimeout(Y)}},[r,v,l]);const $=G=>{b(""),u({type:"browser",directory:G})},I=G=>{a(n,G),u({type:"file",path:G,returnDirectory:k||n})},U=Fe(G=>G.pendingFileFocusPath),X=Fe(G=>G.pendingFileNavigation);if(c.useEffect(()=>{const G=Nt(X?.path??U??"");!G||!n||(a(n,G,{allowOutsideRoot:!0}),u({type:"file",path:G,returnDirectory:n}),U&&Fe.getState().setPendingFileFocusPath(null))},[U,X,n,a]),!n)return t.jsx(Zs,{message:i("mobile.files.empty.noDirectory")});if(l.type==="file")return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/70 px-3 text-foreground",children:[t.jsx("button",{type:"button",className:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":i("header.actions.backAria"),onClick:()=>u({type:"browser",directory:l.returnDirectory}),style:{touchAction:"manipulation"},children:t.jsx(Ei,{className:"size-5"})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:Qs(l.path)})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(Je,{children:t.jsx(c.Suspense,{fallback:t.jsx(Zs,{loading:!0,message:i("filesView.state.loading")}),children:t.jsx(lp,{mode:"editor-only"})})})})]});const Q=l.directory===n?i("mobile.files.rootDirectory"):Qs(l.directory),ue=v.trim()?C:[],se=cp(l.directory),te=l.directory!==n&&se!==null&&(se===n||se.startsWith(`${n}/`)),ge=te&&!v.trim(),ee=te?se:null;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[P,t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[e?t.jsx("button",{type:"button",className:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":i("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(id,{className:"size-5"})}):null,ge&&ee?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":i("mobile.files.backToParentAria",{name:Qs(ee)}),onClick:()=>$(ee),style:{touchAction:"manipulation"},children:t.jsx(Ei,{className:"size-5"})}):null,t.jsx("div",{className:"min-w-0 flex-1 px-1",children:t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:Q})}),t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":i("mobile.files.refreshAria"),onClick:()=>{y(l.directory)},style:{touchAction:"manipulation"},children:t.jsx(od,{className:Z("size-5",g&&"animate-spin")})}),A?t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50","aria-label":i("sidebarFilesTree.actions.uploadFilesTitle"),onClick:()=>B(l.directory),disabled:M,style:{touchAction:"manipulation"},children:t.jsx(H,{name:M?"loader-4":"upload-2",className:Z("size-5",M&&"animate-spin")})}):null]}),t.jsx("div",{className:"shrink-0 px-4 pb-2 pt-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(ad,{className:"pointer-events-none absolute inset-s-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(Oo,{value:v,onChange:G=>b(G.target.value),placeholder:i("mobile.files.search.placeholder"),className:"h-11 ps-9"})]})}),t.jsx(Gn,{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-3",children:h?t.jsx(Zs,{message:h}):v.trim()?t.jsx(pp,{results:ue,isSearching:R,onOpenFile:I}):t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:[m.length===0&&!g?t.jsx("div",{className:"px-4 py-8 text-center typography-body text-muted-foreground",children:i("mobile.files.empty.directory")}):null,m.map(G=>t.jsx(Aa,{name:G.name,path:G.path,directory:G.isDirectory,meta:G.isDirectory?void 0:dp(G.size),onClick:()=>G.isDirectory?$(G.path):I(G.path)},G.path))]})})]})},Aa=n=>{const e=de.c(16),{name:s,path:i,directory:r,meta:o,onClick:a}=n;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={touchAction:"manipulation"},e[0]=l):l=e[0];let u;e[1]!==r||e[2]!==i?(u=r?t.jsx(ud,{className:"size-5 shrink-0 text-primary/80"}):t.jsx(Wo,{filePath:i,className:"size-5 shrink-0"}),e[1]=r,e[2]=i,e[3]=u):u=e[3];let m;e[4]!==s?(m=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:s}),e[4]=s,e[5]=m):m=e[5];let f;e[6]!==o?(f=o?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:o}):null,e[6]=o,e[7]=f):f=e[7];let g;e[8]!==r?(g=r?t.jsx(dd,{className:"size-4 shrink-0 text-muted-foreground/60"}):null,e[8]=r,e[9]=g):g=e[9];let p;return e[10]!==a||e[11]!==u||e[12]!==m||e[13]!==f||e[14]!==g?(p=t.jsxs("button",{type:"button",className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3 py-2.5 text-start transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:a,style:l,children:[u,m,f,g]}),e[10]=a,e[11]=u,e[12]=m,e[13]=f,e[14]=g,e[15]=p):p=e[15],p},pp=n=>{const e=de.c(10),{results:s,isSearching:i,onOpenFile:r}=n,{t:o}=he(),a=Nt(Lr()??null);if(i){let f;e[0]!==o?(f=o("common.loading"),e[0]=o,e[1]=f):f=e[1];let g;return e[2]!==f?(g=t.jsx(Zs,{loading:!0,message:f}),e[2]=f,e[3]=g):g=e[3],g}if(s.length===0){let f;e[4]!==o?(f=o("mobile.files.search.empty"),e[4]=o,e[5]=f):f=e[5];let g;return e[6]!==f?(g=t.jsx(Zs,{message:f}),e[6]=f,e[7]=g):g=e[7],g}const l="overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",u=s.map(f=>t.jsx(Aa,{name:Qs(f.path),path:f.path,directory:!1,meta:up(f.path,a),onClick:()=>r(f.path)},f.path));let m;return e[8]!==u?(m=t.jsx("div",{className:l,children:u}),e[8]=u,e[9]=m):m=e[9],m},Zs=n=>{const e=de.c(7),{message:s,loading:i}=n,r=i===void 0?!1:i;let o;e[0]!==r?(o=r?t.jsx(ld,{className:"size-5 animate-spin text-muted-foreground"}):t.jsx(cd,{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 l;return e[4]!==o||e[5]!==a?(l=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]=l):l=e[6],l},co="mobile-surface-root",hp=16,uo=320,gp="cubic-bezier(0.22, 1, 0.36, 1)",bp=n=>{const e=de.c(38),{onOpenMcpSettings:s,active:i}=n,{t:r}=he(),[o,a]=c.useState(!1),l=zt(yp),u=fs(vp),m=xs(wp);let f;e[0]!==l||e[1]!==o||e[2]!==m||e[3]!==u?(f=()=>{if(o)return;a(!0);const L=new Promise(jp);Promise.all([u({directory:l||null,silent:!0}),m({force:!0}),L]).finally(()=>a(!1))},e[0]=l,e[1]=o,e[2]=m,e[3]=u,e[4]=f):f=e[4];const g=f;let p;e[5]!==r?(p=r("settings.mcp.sidebar.actions.addServerTitle"),e[5]=r,e[6]=p):p=e[6];let h;e[7]!==r?(h=r("settings.mcp.sidebar.actions.addServerTitle"),e[7]=r,e[8]=h):h=e[8];let x,v;e[9]===Symbol.for("react.memo_cache_sentinel")?(x={touchAction:"manipulation"},v=t.jsx(H,{name:"add",className:"size-5"}),e[9]=x,e[10]=v):(x=e[9],v=e[10]);let b;e[11]!==s||e[12]!==p||e[13]!==h?(b=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:h,style:x,children:v}),e[11]=s,e[12]=p,e[13]=h,e[14]=b):b=e[14];let C;e[15]!==r?(C=r("mcpDropdown.actions.refreshAria"),e[15]=r,e[16]=C):C=e[16];let j;e[17]!==r?(j=r("mcpDropdown.actions.refreshAria"),e[17]=r,e[18]=j):j=e[18];let R;e[19]===Symbol.for("react.memo_cache_sentinel")?(R={touchAction:"manipulation"},e[19]=R):R=e[19];const T=o&&"animate-spin";let D;e[20]!==T?(D=Z("size-5",T),e[20]=T,e[21]=D):D=e[21];let k;e[22]!==D?(k=t.jsx(H,{name:"refresh",className:D}),e[22]=D,e[23]=k):k=e[23];let S;e[24]!==o||e[25]!==g||e[26]!==k||e[27]!==C||e[28]!==j?(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 disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:g,disabled:o,"aria-label":C,title:j,style:R,children:k}),e[24]=o,e[25]=g,e[26]=k,e[27]=C,e[28]=j,e[29]=S):S=e[29];let y;e[30]!==S||e[31]!==b?(y=t.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-1 px-2 pt-1",children:[b,S]}),e[30]=S,e[31]=b,e[32]=y):y=e[32];let E;e[33]!==i?(E=t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(Xm,{active:i,className:"h-full",listClassName:"max-h-none",hideHeader:!0,mobileListDensity:!0})}),e[33]=i,e[34]=E):E=e[34];let O;return e[35]!==y||e[36]!==E?(O=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[y,E]}),e[35]=y,e[36]=E,e[37]=O):O=e[37],O},xp=({open:n,onClose:e,tab:s,onTabChange:i,pendingChangesDiff:r,onOpenPlan:o,onOpenMcpSettings:a,variant:l="drawer"})=>{const{t:u,direction:m}=he(),f=c.useRef(null),g=c.useRef(null),[p,h]=c.useState(!1),[x,v]=c.useState(n),b=c.useRef(e);c.useEffect(()=>{b.current=e},[e]);const C=c.useRef(s);c.useEffect(()=>{C.current=s},[s]);const j=()=>b.current();ci(g,{enabled:l==="drawer"&&n,...m==="rtl"?{onRightEdgeSwipe:j}:{onLeftEdgeSwipe:j}});const[R,T]=c.useState(()=>new Set);if(c.useEffect(()=>{n&&T(S=>{if(S.has(s))return S;const y=new Set(S);return y.add(s),y})},[n,s]),typeof document<"u"&&!f.current){let S=document.getElementById(co);S||(S=document.createElement("div"),S.id=co,document.body.appendChild(S)),f.current=S}if(c.useEffect(()=>{if(n){v(!0);const y=window.setTimeout(()=>h(!0),hp);return()=>window.clearTimeout(y)}h(!1);const S=window.setTimeout(()=>v(!1),uo+40);return()=>window.clearTimeout(S)},[n]),c.useEffect(()=>{if(!n)return;const S=document.body.style.overflow;l==="drawer"&&(document.body.style.overflow="hidden");const y=E=>{E.key!=="Escape"||C.current==="terminal"||fc(E.target)||b.current()};return document.addEventListener("keydown",y),()=>{l==="drawer"&&(document.body.style.overflow=S),document.removeEventListener("keydown",y)}},[n,l]),l==="drawer"&&!f.current)return null;const D=[{id:"changes",label:u("mobile.menu.changes"),icon:t.jsx(H,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"files",label:u("mobile.menu.files"),icon:t.jsx(H,{name:"file-text",className:"h-3.5 w-3.5"})},{id:"terminal",label:u("mobile.menu.terminal"),icon:t.jsx(H,{name:"terminal",className:"h-3.5 w-3.5"})},{id:"notes",label:u("contextRail.surface.notes"),icon:t.jsx(H,{name:"sticky-note",className:"h-3.5 w-3.5"})},{id:"mcp",label:u("mobile.menu.mcp"),icon:t.jsx(uc,{className:"h-3.5 w-3.5"})}],k=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:x?t.jsx(dc,{items:D,activeId:s,onSelect:S=>i(S),layoutMode:"fit",variant:"active-pill",nonCompositedIndicator:!0,inactiveTabsIconOnly:!0,className:"h-full"}):null}),t.jsx("button",{type:"button",className:"-me-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":u("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(H,{name:"close",className:"size-5"})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[R.has("changes")?t.jsx("div",{className:Z("h-full",s!=="changes"&&"hidden"),children:t.jsx(Je,{children:t.jsx(np,{visible:n&&s==="changes",initialDiff:r,onNavigatedToChat:e})})},r?`changes:${r.path}:${r.staged}`:"changes"):null,R.has("files")?t.jsx("div",{className:Z("h-full",s!=="files"&&"hidden"),children:t.jsx(Je,{children:t.jsx(fp,{visible:n&&s==="files"})})}):null,R.has("terminal")?t.jsx("div",{className:Z("h-full",s!=="terminal"&&"hidden"),children:t.jsx(Je,{children:t.jsx(Ru,{visible:n&&s==="terminal"})})}):null,R.has("notes")?t.jsx("div",{className:Z("h-full",s!=="notes"&&"hidden"),children:t.jsx(Je,{children:t.jsx(Eu,{visible:n&&s==="notes",onActionComplete:e,onOpenPlan:o})})}):null,R.has("mcp")?t.jsx("div",{className:Z("h-full",s!=="mcp"&&"hidden"),children:t.jsx(Je,{children:t.jsx(bp,{active:n&&s==="mcp",onOpenMcpSettings:a})})}):null]})]});return l==="panel"?t.jsx("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:k}):vs.createPortal(t.jsx("section",{ref:g,role:"dialog","aria-modal":"true","aria-label":u("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":m==="rtl"?"translateX(-100%)":"translateX(100%)",transition:`transform ${uo}ms ${gp}`,visibility:x?"visible":"hidden",pointerEvents:n?"auto":"none"},children:k}),f.current)};function yp(n){return n.currentDirectory}function vp(n){return n.refresh}function wp(n){return n.loadMcpConfigs}function jp(n){return window.setTimeout(n,500)}function kp(n){const e=de.c(4),s=2500,{uiFont:i}=mc(),[r,o]=c.useState(!1);let a,l;return e[0]!==s||e[1]!==i?(a=()=>{let u=!1;const m=()=>{u||o(!0)},f=()=>{requestAnimationFrame(()=>requestAnimationFrame(m))},g=Promise.all([pc(i).catch(Ep),document.fonts?.ready?.then(Rp).catch(Cp)??Promise.resolve(),Bd.catch(Np)]).then(Sp),p=new Promise(h=>{window.setTimeout(h,s)});return Promise.race([g,p]).then(f),()=>{u=!0}},l=[i,s],e[0]=s,e[1]=i,e[2]=a,e[3]=l):(a=e[2],l=e[3]),c.useEffect(a,l),r}function Sp(){}function Np(){}function Cp(){}function Rp(){}function Ep(){}const Ip="openchamber",Ap=n=>n.replace(/^\/+|\/+$/g,""),Pp=n=>{const e=Ap(n.pathname).split("/").filter(Boolean);return n.host?[n.host,...e]:e};function Tp(n){if(typeof n!="string"||n.length===0)return null;let e;try{e=new URL(n)}catch{return null}if(e.protocol!==`${Ip}:`)return null;const s=Pp(e),i=(s[0]??"").toLowerCase(),r=s.slice(1),o=e.searchParams;switch(i){case"session":{const a=r[0]||o.get("id")||"";if(!a)return null;const l=o.get("message")?.trim()??"";return{type:"session",sessionId:a,directory:o.get("dir")??void 0,...hc(l)?{messageId:l}:{}}}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 ut={},Pa=!1,Xs=null;const Dp=n=>{switch(n.type){case"session":return n.messageId&&!n.directory?(gc(n.sessionId,n.messageId),!0):(n.messageId&&bc(n.sessionId,n.messageId),Oe.getState().setCurrentSession(n.sessionId,n.directory??null),!0);case"new-session":{const e=Oe.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 ut.openSessions?(ut.openSessions(n.filter),!0):!1;case"status":return ut.openSessions?(ut.openSessions(),!0):!1;case"view":return ut.openView?(ut.openView(n.target),!0):!1;case"changes":return ut.openChanges?(ut.openChanges({path:n.path,staged:n.staged}),!0):!1;case"settings":return ut.openSettings?(ut.openSettings(n.section),!0):!1}},di=()=>{if(!Pa||!Xs)return;const n=Xs;Xs=null,Dp(n)||(Xs=n)},Ta=n=>{Xs=n,di()},fo=n=>{const e=Tp(n);e&&Ta(e)},_p=n=>{Pa=n,di()},Mp=n=>{const e=de.c(3);let s,i;e[0]!==n?(s=()=>(ut=n,di(),()=>{ut===n&&(ut={})}),i=[n],e[0]=n,e[1]=s,e[2]=i):(s=e[1],i=e[2]),c.useEffect(s,i)},Op=n=>{const{ready:e}=n;c.useEffect(()=>{_p(e)},[e]),c.useEffect(()=>{if(!Xe())return;let s=!1;const i=[];return ws(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([127,5,54])).then(async({App:r})=>{if(s)return;const o=await r.addListener("appUrlOpen",a=>{fo(a?.url)});if(s){o.remove();return}i.push(()=>{o.remove()})}).catch(()=>{}),ws(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([128,54])).then(async({PushNotifications:r})=>{if(s)return;const o=await r.addListener("pushNotificationActionPerformed",a=>{const l=a?.notification?.data,u=typeof l?.url=="string"?l.url:typeof l?.deeplink=="string"?l.deeplink:void 0;if(u){fo(u);return}const m=typeof l?.sessionId=="string"?l.sessionId:void 0;m&&Ta({type:"session",sessionId:m})});if(s){o.remove();return}i.push(()=>{o.remove()})}).catch(()=>{}),()=>{s=!0,i.forEach(r=>r())}},[])},zp=()=>{if(typeof window>"u")return;const n=window.__OPENCHAMBER_APNS_ENV__;if(n==="development")return"sandbox";if(n==="production")return"production"},mo=/^[A-Za-z0-9+/]{43}=$/,Bp=td("PushKey"),Lp=async()=>{const n=window.__OPENCHAMBER_PUSH_KEY__;if(n&&mo.test(n))return n;const e=await Bp.get().then(s=>s.key).catch(()=>{});return e&&mo.test(e)?e:void 0},Fp=()=>{if(typeof window>"u")return!1;const e=window.Capacitor?.getPlatform?.();return e==="ios"||e==="android"},$p=n=>{const{enabled:e}=n,s=Fe(r=>r.nativeNotificationsEnabled),i=c.useRef(null);c.useEffect(()=>{if(!e||!s||!Fp())return;let r=!1;const o=[];return ws(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([128,54])).then(async({PushNotifications:a})=>{if(r)return;let l=await a.checkPermissions().catch(()=>null);if(l?.receive!=="granted"&&(l=await a.requestPermissions().catch(()=>null)),l?.receive!=="granted")return;const u=await a.addListener("registration",f=>{i.current=f.value,Lp().then(g=>{const p=yi(),h={token:f.value,platform:xo(),environment:zp()};g&&(h.pushKey=g),p?.push?.registerApnsToken?.(h)})}),m=await a.addListener("registrationError",f=>{console.warn("[Push] APNs registration error:",f)});if(await a.register().catch(()=>{}),r){u.remove(),m.remove();return}o.push(()=>{u.remove()},()=>{m.remove()})}).catch(()=>{}),()=>{r=!0,o.forEach(a=>a())}},[e,s]),c.useEffect(()=>{if(s)return;const r=i.current;if(!r)return;i.current=null,yi()?.push?.unregisterApnsToken?.({token:r})},[s])},po=n=>{const e=de.c(12),{side:s,isResizing:i,ariaLabel:r,handleProps:o}=n,a=s==="left"?"inset-e-0":"inset-s-0";let l;e[0]!==a?(l=Z("absolute inset-y-0 z-50 w-6 cursor-col-resize touch-none",a),e[0]=a,e[1]=l):l=e[1];const u=s==="left"?"inset-e-0":"inset-s-0",m=i&&"bg-[var(--interactive-border)]";let f;e[2]!==u||e[3]!==m?(f=Z("absolute inset-y-0 w-[3px] transition-colors",u,m),e[2]=u,e[3]=m,e[4]=f):f=e[4];let g;e[5]!==f?(g=t.jsx("div",{className:f}),e[5]=f,e[6]=g):g=e[6];let p;return e[7]!==r||e[8]!==o||e[9]!==l||e[10]!==g?(p=t.jsx("div",{className:l,role:"separator","aria-orientation":"vertical","aria-label":r,...o,children:g}),e[7]=r,e[8]=o,e[9]=l,e[10]=g,e[11]=p):p=e[11],p},Wp=320,Vp=380,ho=280,Up=560,Gp=900;function go(n,e,s,i){const r=de.c(23),o=i===void 0?Up:i,a=c.useRef(null);let l;r[0]!==s||r[1]!==o||r[2]!==e?(l=()=>{if(typeof window>"u")return s;const A=Number.parseInt(window.localStorage.getItem(e)??"",10);return Number.isFinite(A)?Math.min(o,Math.max(ho,A)):s},r[0]=s,r[1]=o,r[2]=e,r[3]=l):l=r[3];const[u,m]=c.useState(l),[f,g]=c.useState(!1),p=c.useRef(0),h=c.useRef(u),x=c.useRef(null),v=c.useRef(null);let b;r[4]!==o?(b=A=>Math.min(o,Math.max(ho,Math.round(A))),r[4]=o,r[5]=b):b=r[5];const C=b;let j;r[6]===Symbol.for("react.memo_cache_sentinel")?(j=A=>{const _=a.current;_&&(_.style.width=`${A}px`,_.style.minWidth=`${A}px`,_.style.maxWidth=`${A}px`,_.style.setProperty("--oc-ipad-sidebar-width",`${A}px`))},r[6]=j):j=r[6];const R=j;let T;r[7]!==u?(T=A=>{try{A.currentTarget.setPointerCapture(A.pointerId)}catch{}v.current=A.pointerId,p.current=A.clientX,h.current=u,x.current=u,g(!0),A.preventDefault()},r[7]=u,r[8]=T):T=r[8];const D=T;let k;r[9]!==C||r[10]!==n?(k=A=>{if(v.current!==A.pointerId)return;const _=(n==="left"?1:-1)*(Ja(A.currentTarget)?-1:1),B=C(h.current+(A.clientX-p.current)*_);x.current!==B&&(x.current=B,R(B))},r[9]=C,r[10]=n,r[11]=k):k=r[11];const S=k;let y;r[12]!==C||r[13]!==e?(y=A=>{if(v.current!==A.pointerId)return;try{A.currentTarget.releasePointerCapture(A.pointerId)}catch{}const _=C(x.current??h.current);v.current=null,x.current=null,g(!1),m(_);try{window.localStorage.setItem(e,String(_))}catch{}},r[12]=C,r[13]=e,r[14]=y):y=r[14];const E=y;let O;r[15]!==D||r[16]!==E||r[17]!==S?(O={onPointerDown:D,onPointerMove:S,onPointerUp:E,onPointerCancel:E},r[15]=D,r[16]=E,r[17]=S,r[18]=O):O=r[18];const L=O;let z;return r[19]!==L||r[20]!==f||r[21]!==u?(z={asideRef:a,width:u,isResizing:f,handleProps:L},r[19]=L,r[20]=f,r[21]=u,r[22]=z):z=r[22],z}const Kp=["general","isolated-spaces","appearance","chat","notifications","sessions","routing","git","magic-prompts","snippets","behavior","agents","commands","mcp","plugins","skills.installed","skills.catalog","providers","web-search","usage","voice","integrations","about"],Hp=1e3,qp=({onActiveConnectionDeleted:n})=>{const{t:e,direction:s}=he();Wu();const[i,r]=c.useState(!1);c.useEffect(()=>Oe.subscribe((q,pe)=>{q.currentSessionId&&q.currentSessionId!==pe.currentSessionId&&Fe.getState().setRunOverviewKey(null)}),[]);const o=Fe(q=>q.runOverviewKey!==null);c.useEffect(()=>{o&&r(!1)},[o]);const[a,l]=c.useState(null),[u,m]=c.useState(!1),[f,g]=c.useState("changes"),[p,h]=c.useState(null),[x,v]=c.useState("nav"),[b,C]=c.useState(null),j=Fe(q=>q.setSettingsPage),R=Fe(q=>q.wideChatLayoutEnabled),T=hs(q=>q.available),D=hs(q=>q.runtimeType),k=c.useMemo(()=>Fr(),[]),S=xs(q=>q.mcpServers),y=xs(q=>q.setMcpDraft),E=xs(q=>q.setSelectedMcp),O=c.useCallback(()=>{l(null),h(null)},[]),L=c.useCallback(q=>{l(q)},[]),z=c.useCallback(()=>{m(!1)},[]),A=c.useCallback(q=>{v(q),L("settings")},[L]),{enabled:_,roomyForPanels:B}=_r(),M=Mc()==="portrait",$=Oc(),[I,U]=c.useState(()=>zc().roomyForPanels),X=c.useCallback(()=>{U(q=>!q)},[]);c.useEffect(()=>{_||U(!1)},[_]);const Q=c.useCallback(()=>{C(null),g("files"),m(!0)},[]);c.useEffect(()=>Vo(q=>{if(q.type!=="file-open-request")return;const pe=q.directory??zt.getState().currentDirectory;pe&&(Fe.getState().openContextFile(pe,q.path),Q())}),[Q]);const ue=c.useCallback((q=null)=>{C(q),g("changes"),m(!0)},[]),se=go("left","openchamber.ipad.leftSidebarWidth",Wp),te=go("right","openchamber.ipad.rightSidebarWidth",Vp,Gp),ge=B,ee=ge&&u?te.width:0,G=_&&I?se.width:0;c.useEffect(()=>{if(typeof document>"u")return;const q=document.documentElement;return q.style.setProperty("--oc-chat-inset-left",`${G}px`),q.style.setProperty("--oc-chat-inset-right",`${ee}px`),()=>{q.style.removeProperty("--oc-chat-inset-left"),q.style.removeProperty("--oc-chat-inset-right")}},[G,ee]),c.useEffect(()=>{if(typeof document>"u")return;const q=document.documentElement;return q.classList.toggle("wide-chat-layout",R),()=>q.classList.remove("wide-chat-layout")},[R]),c.useEffect(()=>{if(typeof document>"u")return;const q=_&&(M||$),pe=document.documentElement;return pe.classList.toggle("oc-keep-draft-starters",q),()=>pe.classList.remove("oc-keep-draft-starters")},[$,_,M]);const N=c.useMemo(()=>({openChanges:({diffPath:q,staged:pe}={})=>{ue(q?{path:q,staged:pe===!0}:null)},openFiles:()=>Q(),openSettings:()=>A("nav"),openSourceBoard:()=>L("board")}),[ue,Q,A,L]),Y=c.useMemo(()=>({openSessions:()=>{_?U(!0):r(!0)},openView:q=>{if(q==="files"){Q();return}if(q==="mcp"){g("mcp"),m(!0);return}L(q)},openChanges:({path:q,staged:pe}={})=>{ue(q?{path:q,staged:pe===!0}:null)},openSettings:q=>{q&&j(q),A(q?"page-content":"nav")}}),[_,ue,Q,A,L,j]);Mp(Y);const ne=c.useRef(null),re=()=>{_?U(!0):r(!0)},K=()=>m(!0);ci(ne,{onLeftEdgeSwipe:s==="rtl"?K:re,onRightEdgeSwipe:s==="rtl"?re:K});const oe=c.useRef(null),fe=c.useCallback(q=>{oe.current=q},[]),Se=c.useCallback(()=>Bc()?!0:p?(h(null),!0):a==="settings"&&oe.current?.()?!0:a?(O(),!0):u?(z(),!0):i?(r(!1),!0):!1,[a,O,z,p,i,u]);Lc(Se);const we=!k&&T&&(D==="desktop"||D==="web"),xe=_?"dialog":"fullscreen",ye=c.useMemo(()=>({instanceLabel:k?qs():null,onOpenInstances:k?()=>L("instances"):void 0,onOpenSettings:()=>A("nav"),onOpenUsage:()=>L("usage"),onOpenScheduled:()=>L("scheduled"),onOpenArchive:()=>L("archive"),onOpenSourceBoard:()=>L("board"),onOpenUpdate:we?()=>L("update"):void 0}),[A,L,k,we]),De=c.useCallback(q=>{O(),r(!1),q==="file"&&Q()},[O,Q]),Te=c.useCallback(()=>{O(),r(!1)},[O]),ve=c.useCallback(()=>{O(),r(!1),_&&!B&&U(!1)},[O,_,B]),Ne=c.useCallback(()=>{const q="new-mcp-server";let pe=q,Ae=1;for(;S.some(Re=>Re.name===pe);)pe=`${q}-${Ae}`,Ae+=1;y({name:pe,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",oauthCallbackPort:"",oauthAuthServerMetadataUrl:"",protocol:"legacy",timeoutStartup:"",timeoutCatalog:"",timeoutExecution:"",codemode:"default",disabled:!1}),E(pe),j("mcp"),A("page-content")},[S,A,y,E,j]);return t.jsx(Fc,{actions:N,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:Z("relative flex h-full shrink-0 flex-col overflow-hidden border-e border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!I&&"border-e-0"),style:{width:I?se.width:0,minWidth:I?se.width:0,maxWidth:I?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":!I,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:Z("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",!I&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Je,{children:t.jsx(so,{open:!0,variant:"sidebar",onOpenChange:q=>{!q&&!B&&U(!1)},footer:ye})})}),I?t.jsx(po,{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(tm,{onOpenSessions:()=>_?X():r(!0),onOpenWorkspace:()=>m(!0),compactTitle:_}),t.jsxs("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(Je,{children:t.jsx(Vu,{})})}),t.jsx(Je,{children:t.jsx(Qu,{})})]})]}),_?null:t.jsx(so,{open:i,onOpenChange:r,footer:ye}),t.jsxs("aside",{ref:te.asideRef,className:Z("relative flex h-full shrink-0 flex-col overflow-hidden border-s border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!ee&&"border-s-0"),style:{width:ee,minWidth:ee,maxWidth:ee,"--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":!ee,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:Z("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",!ee&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Je,{children:t.jsx(xp,{open:u,onClose:z,tab:f,onTabChange:g,pendingChangesDiff:b,onOpenPlan:h,onOpenMcpSettings:Ne,variant:ge?"panel":"drawer"})})}),ee?t.jsx(po,{side:"right",isResizing:te.isResizing,ariaLabel:e("sidebar.resize.rightPanelAria"),handleProps:te.handleProps}):null]}),p?t.jsx(Pt,{open:!0,variant:xe,onClose:()=>h(null),ariaLabel:p.title,title:p.title,children:t.jsx(Je,{children:t.jsx(qu,{savedProjectPlan:{projectRef:p.projectRef,planId:p.id},onNavigatedToChat:()=>{O(),z()}})})}):null,a==="instances"&&k?t.jsx(Pt,{open:!0,variant:xe,dialogAlign:"app",onClose:O,ariaLabel:e("mobile.menu.instances"),title:e("mobile.menu.instances"),children:t.jsx(om,{onConnect:O,onActiveConnectionDeleted:n})}):null,a==="settings"?t.jsx(Pt,{open:!0,variant:xe,dialogAlign:"app",onClose:O,ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(Je,{children:t.jsx(Ku,{forceMobile:!0,isWindowed:!0,initialMobileStage:x,registerBackHandler:fe,visiblePageSlugs:[...Kp],onClose:O})})}):null,a==="usage"?t.jsx(Pt,{open:!0,variant:xe,dialogAlign:"app",onClose:O,ariaLabel:e("usageStats.title"),title:e("usageStats.title"),children:t.jsx(Je,{children:t.jsx(pd,{})})}):null,a==="scheduled"?t.jsx(Pt,{open:!0,variant:xe,dialogAlign:"app",onClose:O,ariaLabel:e("sessions.scheduledTasks.dialog.title"),title:e("sessions.scheduledTasks.dialog.title"),children:t.jsx(Je,{children:t.jsx(bd,{layout:"mobile",onLeave:De})})}):null,a==="board"?t.jsx(Pt,{open:!0,variant:xe,dialogAlign:"app",onClose:O,ariaLabel:e("sourceBoard.title"),title:e("sourceBoard.title"),children:t.jsx(Je,{children:t.jsx(gd,{onLeave:Te})})}):null,a==="archive"?t.jsx(Pt,{open:!0,variant:xe,dialogAlign:"app",onClose:O,ariaLabel:e("sessions.archivePage.title"),title:e("sessions.archivePage.title"),children:t.jsx(Je,{children:t.jsx(hd,{layout:"mobile",onLeave:ve})})}):null,a==="update"?t.jsx(Pt,{open:!0,variant:xe,dialogAlign:"app",onClose:O,ariaLabel:e("mobile.menu.update"),title:e("mobile.menu.update"),children:t.jsx(Je,{children:t.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:t.jsx(Hu,{initialUpdateDialogOpen:!0})})})}):null]})})};function bo({apis:n}){const e=Fe(N=>N.isolatedSpacesEnabled),{t:s}=he(),i=dt(N=>N.initializeApp),r=dt(N=>N.isInitialized),o=dt(N=>N.isConnected),a=dt(N=>N.connectionPhase),l=dt(N=>N.providers.length),u=dt(N=>N.agents.length),m=dt(N=>N.loadProviders),f=dt(N=>N.loadAgents),g=zt(N=>N.currentDirectory),p=Oe(N=>N.error),h=Oe(N=>N.clearError),x=Fe(N=>N.setIsMobile),v=$o(N=>N.refreshAll),b=xc(N=>N.refreshStatus),C=yc(N=>N.setPlanModeEnabled),j=lt(N=>N.projects),R=bs(N=>N.activeSessions),T=bs(N=>N.archivedSessions),D=bs(N=>N.status==="ready"),k=c.useMemo(()=>[...R,...T],[R,T]);Au({hasAuthoritativeGlobalSessions:D,sessions:k});const[S,y]=c.useState(0),[E,O]=c.useState(0),[L,z]=c.useState(!1),[A,_]=c.useState("pending"),[B,P]=c.useState(null),M=c.useMemo(()=>qs(),[]),[,$]=c.useReducer(N=>N+1,0),I=c.useMemo(()=>Fr(),[]),U=c.useRef(0),X=c.useRef(0),Q=c.useCallback(()=>{const N=St(),Y=X.current+1;if(X.current=Y,!N){Gs("resume:auto-connect",{}),Ks();return}Gs("resume:reprobe",{});const ne=()=>{i(),v(n.sourceControl,{force:!0}),b(n.linear,{force:!0}),l===0&&m({source:"mobileApp:nativeResume"}),u===0&&f({source:"mobileApp:nativeResume"})},re=oe=>{Gs("resume:disconnect",{reason:oe}),ms({apiBaseUrl:"",clientToken:null,runtimeKey:kn}),y(fe=>fe+1)};Tn().then(oe=>{if(X.current===Y){if(oe==="no-connection"){re("no-connection");return}if(oe==="needs-login"){P({kind:"auth-expired",label:qs()??""}),re("needs-login");return}if(oe==="unreachable"){const fe=[4e3,1e4],Se=we=>{window.setTimeout(()=>{if(X.current!==Y)return;const xe=we===fe.length-1;Tn({fast:!xe}).then(ye=>{if(X.current===Y&&ye!=="switched"){if(ye==="unchanged"){ne();return}if(ye==="needs-login"){P({kind:"auth-expired",label:qs()??""}),re("retry-needs-login");return}if(!xe){Se(we+1);return}re(`retry-${ye}`)}})},fe[we])};Se(0);return}oe!=="switched"&&ne()}});const K=Date.now();K-U.current>=Hp&&(U.current=K,window.dispatchEvent(new Event("openchamber:system-resume")))},[u,n.sourceControl,n.linear,i,f,m,l,v,b]);vc(),wc(Q),c.useEffect(()=>{if(!I)return;let N;const Y=()=>{window.clearTimeout(N),N=window.setTimeout(()=>Q(),1500)};return window.addEventListener("online",Y),()=>{window.removeEventListener("online",Y),window.clearTimeout(N)}},[I,Q]),c.useEffect(()=>{if(I)return vi.subscribe((N,Y)=>{N.state==="expired"&&Y.state!=="expired"&&(Q(),vi.getState().markAuthenticated())})},[I,Q]),c.useEffect(()=>(wi(n),()=>wi(null)),[n]),c.useEffect(()=>vo(N=>{if(Gs("endpoint:changed",{runtimeKey:N.runtimeKey||"none",previousRuntimeKey:N.previousRuntimeKey||"none",connected:!!N.apiBaseUrl}),!!N.runtimeKey&&N.runtimeKey===N.previousRuntimeKey){Pu(),$();return}Tu(N),O(ne=>ne+1),y(ne=>ne+1)}),[]),c.useEffect(()=>{if(!I||o||St()){_("done");return}let N=!1;return _("attempting"),(async()=>{const Y=await Ks().catch(()=>({status:"no-candidate"}));N||(Y.status==="unreachable"?P({kind:"unreachable",label:Y.label}):Y.status==="needs-login"&&P({kind:"auth-expired",label:Y.label}),_("done"),Y.status==="unreachable"&&Ks({fast:!1,skipIfConnected:!0}).catch(()=>null))})(),()=>{N=!0}},[]),c.useEffect(()=>{if(!I||!St())return;let N=!1;const Y=ne=>{Gs("cold-launch:drop",{kind:ne?.kind??"unknown"}),ne&&P(ne),ms({apiBaseUrl:"",clientToken:null,runtimeKey:kn}),y(re=>re+1)};return Tn().then(async ne=>{if(N||ne==="switched"||ne==="unchanged")return;const re=qs();if(ne==="needs-login"){Y({kind:"auth-expired",label:re??""});return}if(ne==="unreachable"){Y(re?{kind:"unreachable",label:re}:null),Ks({fast:!1,skipIfConnected:!0}).catch(()=>null);return}const K=await Ks().catch(()=>({status:"no-candidate"}));N||K.status==="connected"||(K.status==="needs-login"?Y({kind:"auth-expired",label:K.label}):K.status==="unreachable"?Y({kind:"unreachable",label:K.label}):Y(null))}),()=>{N=!0}},[]),c.useEffect(()=>{x(!0)},[x]),c.useEffect(()=>{I&&!St()||i()},[S,i,I]),c.useEffect(()=>{o&&(l===0&&m({source:"mobileApp:recovery"}),u===0&&f({source:"mobileApp:recovery"}))},[u,o,f,m,l]);const ue=c.useRef(!1),[se,te]=c.useState(I);c.useEffect(()=>{if(!I||!o||ue.current)return;let N=!1;const Y=window.setTimeout(()=>te(!1),6e3);return(async()=>{const ne=await Du({refresh:!0});N||(ne!=="failed"&&(ue.current=!0),te(!1))})(),()=>{N=!0,window.clearTimeout(Y)}},[S,o,I]),c.useEffect(()=>{o&&ji.setDirectory(g)},[g,o]),c.useEffect(()=>{o&&(v(n.sourceControl,{force:!0}),b(n.linear,{force:!0}))},[n.sourceControl,n.linear,o,v,b]),c.useEffect(()=>{if(!o||j.length===0)return;let N=!1;return(async()=>{const ne=new Map(Oe.getState().availableWorktreesByProject);if(await Promise.all(j.map(async oe=>{const fe=oe.path.replace(/\\/g,"/").replace(/\/+$/,"");if(fe)try{if(!(at.getState().directories.get(fe)?.isGitRepo??await ws(()=>import("./useAppFontEffects-3EN8Ava3.js").then(ye=>ye.nk),__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(ye=>ye.checkIsGitRepository(fe))))return;const xe=await Lo({id:oe.id,path:fe});if(N)return;ne.set(fe,xe)}catch{}})),N)return;const re=Fo(j,ne),K=Oe.getState().availableWorktreesByProject;Dc(re,K)||Oe.setState({availableWorktrees:[...re.values()].flat(),availableWorktreesByProject:re})})(),()=>{N=!0}},[o,j]),c.useEffect(()=>{if(!o)return;let N=!1;const Y=Vo(ne=>{ne.type==="worktree-changed"&&_c(j,ne.directories,()=>N)});return()=>{N=!0,Y()}},[o,j]),c.useEffect(()=>{let N=!1;return(async()=>{const ne=await Dr("/health",{method:"GET"}).catch(()=>null);if(!ne||!ne.ok||N)return;const re=await ne.json().catch(()=>null);if(!re||N)return;const K=re.planModeExperimentalEnabled;C(K===!0||K===1||K==="1"||K==="true")})(),()=>{N=!0}},[C]),c.useEffect(()=>{if(!p)return;const N=window.setTimeout(()=>h(),5e3);return()=>window.clearTimeout(N)},[h,p]),c.useEffect(()=>{if(!(!o&&(I?!!St():!0))){z(!1);return}const Y=window.setTimeout(()=>{z(!0)},I?4e3:8e3);return()=>window.clearTimeout(Y)},[o,I,S,E]),jc(),kc({enabled:!0}),_u(),Sc(),Nc(),Mu(),Ou(),$p({enabled:I&&o}),Op({ready:I&&o&&r});const ge=kp(),ee=!o&&a==="reconnecting";if(!ge)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(ps,{width:120,height:120,isAnimated:!0,variant:"splash"})});const G=!!St();return I&&(!G||!o&&!ee)?G?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(ps,{width:120,height:120,isAnimated:!L,variant:"splash"}),L?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:s("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:s("mobile.connect.recovery.description")})]}),t.jsx(Ce,{type:"button",variant:"outline",onClick:()=>{ms({apiBaseUrl:"",clientToken:null,runtimeKey:kn}),y(N=>N+1)},children:s("mobile.connect.cancelPassword")})]}):null]})}):A!=="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(ps,{width:120,height:120,isAnimated:!0,variant:"splash"}),M?t.jsxs("div",{className:"absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center",children:[t.jsx("p",{className:"typography-small text-muted-foreground",children:s("mobile.connect.splash.connectingTo")}),t.jsxs("p",{className:"typography-small text-foreground",children:[M,t.jsx(Cc,{})]})]}):null]}):t.jsx(t.Fragment,{children:t.jsx(Lf,{onConnected:()=>y(N=>N+1),notice:B})}):!o&&!ee?L?t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground",children:t.jsxs("div",{className:"max-w-sm space-y-3",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:s("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:s("sessionAuth.error.networkDescription")})]})}):t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-[var(--splash-background,var(--surface-background))] text-foreground",children:t.jsx(ps,{width:120,height:120,isAnimated:!0,variant:"splash"})}):t.jsx(Je,{children:t.jsx(Rc,{sdk:ji.getSdkClient(),directory:g||"",children:t.jsx(Ec,{apis:n,children:t.jsx(Ic,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[t.jsx(zu,{ready:!I||!se,animated:!0}),t.jsx(Ac,{backgroundWorkEnabled:r}),t.jsx(Bu,{}),t.jsx(Hd,{}),t.jsx(qp,{onActiveConnectionDeleted:()=>{Ef(),ms({apiBaseUrl:"",clientToken:null,runtimeKey:kn}),y(N=>N+1)}}),t.jsx(Pc,{}),t.jsx(Tc,{}),e?t.jsxs(t.Fragment,{children:[t.jsx(Yu,{}),t.jsx(Lu,{}),t.jsx(Ju,{}),t.jsx(Fu,{}),t.jsx(Xu,{})]}):null,t.jsx(Zd,{}),r?t.jsx($u,{}):null]})})})},E)})}function Yp(n){const e=de.c(4),s=c.useSyncExternalStore(Jp,St,St);if(Fr()&&!s){let r;return e[0]!==n?(r=t.jsx(bo,{...n}),e[0]=n,e[1]=r):r=e[1],r}let i;return e[2]!==n?(i=t.jsx(Iu,{children:t.jsx(bo,{...n})}),e[2]=n,e[3]=i):i=e[3],i}function Jp(n){return vo(()=>n())}function $b(n){window.__OPENCHAMBER_SURFACE__="mobile",$c(),Gu({logLabel:"[mobile-main]",onAppearanceSettled:Ld}),Kd(),Wc();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(Yp,{apis:r});za.createRoot(e).render(t.jsx(kr.StrictMode,{children:t.jsx(Vc,{children:t.jsx(Uc,{children:t.jsx(Gc,{children:t.jsx(Uu,{children:i?o:t.jsx(Kc,{children:o})})})})})}))}export{$b as renderMobileApp};
25
+ `)}`.trim()),Re([])},[]),vn=c.useCallback(async()=>{if(!p)return;const w=xt.map(W=>W.path).sort();if(w.length===0){ce.error(a("gitView.toast.selectFileToDescribe"));return}Ae(!0);try{const{message:W}=await Ii(p,w);De(W.subject?.trim()??""),Re(Array.isArray(W.highlights)?W.highlights:[])}catch(W){ce.error(W instanceof Error?W.message:a("gitView.toast.generateCommitMessageFailed"))}finally{Ae(!1)}},[p,xt,a]),sr=async(w={})=>{if(!p)return;if(!ye.trim()){ce.error(a("gitView.toast.enterCommitMessage"));return}const W=xt.map(Pe=>Pe.path).sort();if(W.length===0){ce.error(a("gitView.toast.selectFileToCommit"));return}xe(w.pushAfter?"commitAndPush":"commit");let ie=null,je="pending";try{if(await l.createGitCommit(p,ye.trim(),{files:W}),je="local",ce.success(a("gitView.toast.commitCreated")),De(""),Re([]),w.pushAfter){if(ie=Ct.start(),!ie){ce.warning(a("gitView.publish.commitKept")),await At();return}const Pe=await it.prepare("push",{onOperation:ie.onOperation});Se("publish"),await Pe(),je="published",ce.success(a("gitView.publish.succeeded"))}await At()}catch(Pe){if(w.pushAfter&&je==="local"&&ce.warning(a("gitView.publish.commitKept")),Pe instanceof An||Pe instanceof Nr){await At();return}if(Pe instanceof Ot&&Pe.code==="stale-runtime")return;if(Pe instanceof Ot&&it.errorMessage(Pe)){ce.info(it.errorMessage(Pe));return}w.pushAfter&&await At(),ce.error(Pe instanceof Ot?Pe.code==="contributor-publish-cancelled-after-update"?a("gitView.toast.contributorPublishCancelledAfterUpdate"):Pe.code==="contributor-publish-cancelled"?a("gitView.toast.contributorPublishCancelled"):a("gitView.toast.syncActionFailed",{action:a("gitView.sync.syncChanges")}):Pe instanceof Error?Pe.message:a("gitView.toast.createCommitFailed"))}finally{ie?.finish(),xe(null),w.pushAfter&&Se(null)}},nr=c.useMemo(()=>(h?.files??[]).filter(fr).length,[h?.files]),Et=!!h?.mergeInProgress?.head,cs=c.useCallback(async()=>{if(p)try{if(Et){const w=await l.continueMerge(p);w.conflict?(Ge(w.conflictFiles??[],"merge"),ce.error(a("gitView.toast.mergeConflictsDetected"))):ce.success(a("gitView.toast.mergeCompleted"))}else{const w=await l.continueRebase(p);w.conflict?(Ge(w.conflictFiles??[],"rebase"),ce.error(a("gitView.toast.rebaseConflictsDetected"))):ce.success(a("gitView.toast.rebaseStepCompleted"))}await He(!1)}catch(w){ce.error(w instanceof Error?w.message:a("gitView.toast.continueOperationFailed"))}},[p,l,Et,Ge,He,a]),Gt=c.useCallback(async w=>{if(p)try{w==="merge"?(await l.abortMerge(p),ce.success(a("gitView.toast.mergeAborted"))):(await l.abortRebase(p),ce.success(a("gitView.toast.rebaseAborted"))),await He(!1)}catch(W){ce.error(W instanceof Error?W.message:a("gitView.toast.abortOperationFailed"))}},[p,l,He,a]),Bs=c.useCallback(()=>{const w=(h?.files??[]).filter(fr).map(W=>W.path);Ge(w,Et?"merge":"rebase")},[Et,Ge,h?.files]),Ls=c.useMemo(()=>{const w=[];return xt.length>0&&w.push({id:"staged",title:a("gitView.changes.stagedTitle"),entries:xt,statsScope:"staged",actionSymbol:"-",actionAllLabel:a("gitView.changes.unstageAllAria"),getActionLabel:W=>a("gitView.changes.unstageFileAria",{path:W}),onActionFile:W=>{Ut([W],"unstage")},onActionAll:W=>{Ut(W,"unstage")},onViewDiff:W=>Os(W,!0),onRevertFile:zs,showRevertActions:!1,accent:!0}),as.length>0&&w.push({id:"unstaged",title:a("gitView.changes.title"),entries:as,statsScope:"working",actionSymbol:"+",actionAllLabel:a("gitView.changes.stageAllAria"),getActionLabel:W=>a("gitView.changes.stageFileAria",{path:W}),onActionFile:W=>{Ut([W],"stage")},onActionAll:W=>{Ut(W,"stage")},onViewDiff:W=>Os(W,!1),onRevertFile:zs}),w},[zs,Os,Ut,xt,a,as]),Fs=t.jsxs(t.Fragment,{children:[it.context?t.jsx(gu,{context:it.context,onSelect:it.settle}):null,it.confirmDialog,t.jsx(bu,{candidates:As.candidates,onSelect:As.settle})]}),_t=w=>t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[Fs,t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[s?t.jsx("button",{type:"button",className:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":a("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(q,{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:a("mobile.nav.changes")}),t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:h?.current||p||""})]}),m===!1&&Array.isArray(g)&&g.length>0?t.jsx(Nu,{repositories:g,selectedRepository:f??null,onSelectRepository:W=>{n&&$(n,W)},repositoryRoot:n??void 0}):null]}),t.jsx("div",{className:"min-h-0 flex-1",children:w})]});if(!p)return _t(t.jsx(ft,{message:a("gitView.empty.selectSessionOrDirectory")}));if(m===!1&&A!==!0)return _t(t.jsx(Ru,{root:n,rootIsGitRepo:m,resolvedIsGitRepo:A,nestedRepos:g,onRetryDiscovery:()=>{n&&M(n,{force:!0})}}));if(_&&A===null)return _t(t.jsx(ft,{loading:!0,message:a("gitView.loading.checkingRepository")}));if(Y.type==="diff")return t.jsx(mo,{path:Y.path,diff:mn,staged:Y.staged,fileExists:!!pn,unavailableReason:Es?.key===`${p}\0${Y.path}`?Es.reason:null,error:mt,onBack:()=>oe({type:"list"}),onRetry:()=>ln(w=>w+1)});const Kt=a(N==="pr"?Sn("session.githubIntegration.tabs.pullRequests",nt.provider):N==="branch"?"diffView.scope.branch":N==="commit"?"commitComparison.mode":"mobile.nav.changes"),wn=N==="branch"&&Be.base?xu(Be.base):N==="commit"?pt?.slice(0,8):N==="pr"&&gt?`#${gt.number}`:null;if(bt&&ot)return t.jsx(mo,{path:bt,subtitle:[Kt,wn].filter(Boolean).join(" · "),diff:jt??(ot.status==="ready"?ot.diff:null),fileExists:!be.files||be.files.some(w=>w.path===bt),error:be.error??(ot.status==="error"?ot.message:null),onBack:()=>oe(ds),onRetry:()=>{be.error&&be.refresh(),Qn(w=>w+1)},onExpandContextRequest:ot.status==="ready"?w=>os({source:ot,request:w}):void 0,pendingContextExpansion:$t,contextLoading:$t!==null&&!jt});const rr=()=>N==="pr"&&!gt?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(ft,{loading:nt.loading,message:nt.error??(nt.loading?a(Sn("session.githubPrPicker.loading.pullRequests",nt.provider)):a(Sn("pullRequestComparison.select",nt.provider)))}),!nt.loading&&t.jsx(Mi,{mobile:!0,comparison:nt})]}):N==="branch"&&!Be.base?t.jsx(ft,{loading:!Be.resolved,message:Be.resolved?a("gitView.pr.toast.baseBranchRequired"):a("diffView.branch.resolvingBase")}):N==="commit"&&!pt?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[Ze.loading&&t.jsx(q,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:Ze.loading?a("diffView.state.loadingChanges"):Ze.error??a("commitComparison.noCommits")}),Ze.error&&t.jsx(Ce,{variant:"outline",size:"lg",onClick:()=>{Ze.refresh()},children:a("diffView.actions.retry")})]}):be.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:a("diffView.state.failedToLoadDiff")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:be.error}),t.jsx(Ce,{variant:"outline",size:"lg",onClick:()=>{be.refresh()},children:a("diffView.actions.retry")})]}):is?is.length===0?t.jsx(ft,{icon:N==="branch",message:N==="pr"?a("walkthrough.blocked.emptyDiff.description"):N==="commit"?a("commitComparison.emptyDiff"):a("diffView.branch.empty",{base:wn??""})}):t.jsx(lp,{files:is,onSelect:w=>{be.key&&oe({type:"comparison",path:w,sourceKey:be.key})}}):t.jsx(ft,{loading:!0,message:a("diffView.state.loadingChanges")});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[Fs,t.jsxs("header",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b border-border/60 px-3 py-2",children:[s?t.jsx("button",{type:"button",className:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":a("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(q,{name:"close",className:"size-5"})}):null,t.jsxs(nc,{open:ne,onOpenChange:re,children:[t.jsx(rc,{asChild:!0,children:t.jsxs(Ce,{variant:"outline",className:ic({size:"mobile"}),"data-mobile-comparison-trigger":!0,"aria-label":a("diffView.scope.selectorAria"),children:[t.jsx("span",{children:Kt}),t.jsx(q,{name:"arrow-down-s",className:"size-4"})]})}),t.jsx(oc,{align:"start",children:t.jsxs(ac,{value:N,onValueChange:w=>{(w==="working"||w==="branch"||w==="commit"||w==="pr")&&K(w)},children:[t.jsx(Nn,{value:"working",className:"min-h-8 items-center",children:a("mobile.nav.changes")}),ns&&t.jsx(Nn,{value:"branch",className:"min-h-8 items-center",children:a("diffView.scope.branch")}),t.jsx(Nn,{value:"commit",className:"min-h-8 items-center",children:a("commitComparison.mode")}),t.jsx(Nn,{value:"pr",className:"min-h-8 items-center",children:a(Sn("session.githubIntegration.tabs.pullRequests",nt.provider))})]})})]}),r&&N==="branch"&&t.jsx(zd,{mobile:!0,branches:v?.all??[],currentBranch:_e,base:Be.base,automatic:Be.source!=="chosen",onSelect:w=>{_e&&dn(p,_e,w)},onSelectAutomatic:()=>{_e&&ct(p,_e)}},JSON.stringify([te,_e])),r&&N==="commit"&&t.jsx(Bd,{mobile:!0,commits:Ze.commits,selectedHash:pt,loading:Ze.loading,error:Ze.error,onSelect:Ze.select,onRefresh:()=>{Ze.refresh()}},JSON.stringify([te,_e])),r&&N==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(Mi,{mobile:!0,comparison:nt},JSON.stringify([te,_e])),gt&&t.jsx(Ce,{variant:"ghost",size:"sm",disabled:be.loading,"aria-label":a("session.githubIssuePicker.actions.refresh"),onClick:()=>{be.refresh()},children:t.jsx(q,{name:"refresh",className:"size-4"})})]})]}),N==="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(yu,{currentBranch:h?.current,localBranches:hn,remoteBranches:gn,branchInfo:v?.branches,currentBranchAhead:h?.ahead,onCheckout:w=>{bn(w)},onCreate:xn,disabled:_,directory:p,switchBlockedNotice:(h?.files?.length??0)>0?a("gitView.branch.switchBlockedNotice"):null})}),t.jsx(vu,{activeProfile:Ts,identities:L,attention:rs,triggerClassName:"max-w-[10rem] shrink [&_.git-identity-label]:hidden sm:[&_.git-identity-label]:inline",onOpen:()=>{O(u,D.map(w=>w.account))},onSelect:w=>{z(w)},isApplying:R,onConfigure:()=>j(!0),applicability:w=>{const W=ze.read?.repository.remotes.find(ie=>ie.name===st);return W?wu(w,lc(W.fetch.displayUrl)):{applicable:!0}}}),t.jsx(ju,{syncAction:Ct.entry?.executing?fe:null,remotes:er,onFetch:w=>{Vt("fetch",w)},onPull:w=>{Vt("pull",w)},onSync:w=>{Vt("sync",w)},onPublish:()=>{Vt("publish")},onChooseSyncTargets:()=>{Vt("sync",void 0,!0)},currentBranch:h?.current,hasTracking:!!h?.tracking,disabled:_||Ct.blocked,aheadCount:h?.ahead??0,behindCount:h?.behind??0,trackingRemoteName:h?.tracking?.split("/")[0],trackingBranch:h?.tracking,hasUncommittedChanges:ku(at),choosesPushDestination:x})]}),t.jsx(Rd,{open:C,onOpenChange:j,directory:p}),t.jsx(Su,{className:"mx-3 mt-3",entry:Ct.entry,onRefresh:()=>{Ct.refresh()},onCancel:()=>{Ct.cancel()}}),N==="working"&&t.jsx(Ed,{mergeInProgress:h?.mergeInProgress,rebaseInProgress:h?.rebaseInProgress,onContinue:cs,onAbort:()=>Gt(Et?"merge":"rebase"),onResolveWithAI:Bs,conflictCount:nr,isLoading:fe!==null||we!==null}),N!=="working"?t.jsx("div",{className:"min-h-0 flex-1",children:rr()}):at.length>0?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden px-4 pt-4",children:t.jsx(Id,{groups:Ls,diffStats:h?.diffStats,revertingPaths:Te,onRevertAll:yn,isRevertingAll:Ne,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:qe})}),t.jsx("div",{className:"shrink-0 border-t border-border/70 px-4 pb-4 pt-3",children:t.jsx(Ad,{stagedCount:xt.length,commitMessage:ye,onCommitMessageChange:De,generatedHighlights:We,onInsertHighlights:tr,onGenerateMessage:vn,isGeneratingMessage:pe,onCommit:()=>{sr({pushAfter:!1})},onCommitAndPush:()=>{sr({pushAfter:!0})},commitAction:we,networkOperationBlocked:Ct.blocked,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(ft,{icon:!0,message:a("gitView.empty.cleanTitle"),description:a("mobile.changes.cleanDescription")})}),p&&t.jsx(Pd,{open:Yn,onOpenChange:ts,conflictFiles:cn,directory:p,operation:un,onAbort:()=>{Gt(un)},onNavigatedToChat:o}),t.jsx(Td,{open:Ue!==null,onOpenChange:w=>{w||Rt(null)},targetBranch:Ue??"",changedFileCount:h?.files?.length??0,onCommitAndSwitch:async(w,W)=>{const ie=Ue;if(!ie||!p)return;const je=h?.current??null;if(await l.createGitCommit(p,w,{addAll:!0}),W)try{await(await it.prepare("push"))()}catch{ce.error(a("gitView.dirtySwitch.pushFailed")),await He(),Rt(null);return}ce.success(je?W?a("gitView.publish.succeeded"):a("gitView.dirtySwitch.committedNotPushed",{branch:je}):a("gitView.toast.commitCreated")),await He(),Rt(null),await Wt(ie)},onGenerateMessage:async()=>{if(!p)return"";const w=(h?.files??[]).map(ie=>ie.path).sort(),{message:W}=await Ii(p,w);return W.subject?.trim()??""},onRevertAndSwitch:async()=>{const w=Ue;if(!w||!p)return;await yn((h?.files??[]).map(ie=>ie.path));const W=await l.getGitStatus(p);if(!W.isClean&&(W.files?.length??0)>0){ce.error(a("gitView.dirtySwitch.revertIncomplete"));return}Rt(null),await Wt(w)}})]})},ft=n=>{const e=de.c(13),{message:s,description:i,loading:r,icon:o}=n,a=r===void 0?!1:r,l=o===void 0?!1:o;let u;e[0]!==a?(u=a?t.jsx(q,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,e[0]=a,e[1]=u):u=e[1];let m;e[2]!==l?(m=l?t.jsx(q,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e[2]=l,e[3]=m):m=e[3];let f;e[4]!==s?(f=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[4]=s,e[5]=f):f=e[5];let g;e[6]!==i?(g=i?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i}):null,e[6]=i,e[7]=g):g=e[7];let p;return e[8]!==u||e[9]!==m||e[10]!==f||e[11]!==g?(p=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:[u,m,f,g]})}),e[8]=u,e[9]=m,e[10]=f,e[11]=g,e[12]=p):p=e[12],p},mo=n=>{const e=de.c(55),{path:s,subtitle:i,diff:r,staged:o,fileExists:a,unavailableReason:l,error:u,onBack:m,onRetry:f,onExpandContextRequest:g,pendingContextExpansion:p,contextLoading:h}=n,x=o===void 0?!1:o,v=l===void 0?null:l,{t:b}=he();let C;e[0]!==s?(C=cc(s)||"text",e[0]=s,e[1]=C):C=e[1];const j=C,R=Fe(cp),T=Fe(up);let D;e[2]!==R||e[3]!==b?(D=b(R?"diffView.whitespace.hidden":"diffView.whitespace.shown"),e[2]=R,e[3]=b,e[4]=D):D=e[4];const k=D;let S;e[5]!==b?(S=b("header.actions.backAria"),e[5]=b,e[6]=S):S=e[6];let y;e[7]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx(q,{name:"arrow-left",className:"size-5"}),e[7]=y):y=e[7];let E;e[8]!==m||e[9]!==S?(E=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":S,onClick:m,children:y}),e[8]=m,e[9]=S,e[10]=E):E=e[10];let O;e[11]!==s?(O=t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:s}),e[11]=s,e[12]=O):O=e[12];let L;e[13]!==i?(L=i&&t.jsx("p",{className:"truncate typography-meta text-muted-foreground",children:i}),e[13]=i,e[14]=L):L=e[14];let z;e[15]!==O||e[16]!==L?(z=t.jsxs("div",{className:"min-w-0 flex-1 px-2",children:[O,L]}),e[15]=O,e[16]=L,e[17]=z):z=e[17];const A=R?"text-foreground":"text-muted-foreground";let _;e[18]!==A?(_=Z("flex size-9 shrink-0 items-center justify-center rounded-lg hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",A),e[18]=A,e[19]=_):_=e[19];let B;e[20]!==b?(B=b("diffView.actions.hideWhitespace"),e[20]=b,e[21]=B):B=e[21];let P;e[22]!==R||e[23]!==T?(P=()=>T(!R),e[22]=R,e[23]=T,e[24]=P):P=e[24];let M;e[25]!==R?(M=t.jsx(Cd,{hidden:R,className:"size-5"}),e[25]=R,e[26]=M):M=e[26];let $;e[27]!==R||e[28]!==_||e[29]!==B||e[30]!==P||e[31]!==M||e[32]!==k?($=t.jsx("button",{type:"button",className:_,"aria-label":B,"aria-pressed":R,title:k,onClick:P,children:M}),e[27]=R,e[28]=_,e[29]=B,e[30]=P,e[31]=M,e[32]=k,e[33]=$):$=e[33];let I;e[34]!==z||e[35]!==$||e[36]!==E?(I=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:[E,z,$]}),e[34]=z,e[35]=$,e[36]=E,e[37]=I):I=e[37];let U;e[38]!==h||e[39]!==r||e[40]!==u||e[41]!==a||e[42]!==R||e[43]!==j||e[44]!==g||e[45]!==f||e[46]!==s||e[47]!==p||e[48]!==x||e[49]!==b||e[50]!==v?(U=t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:a?v==="nested_repository"?t.jsx(ft,{icon:!0,message:b("diffView.unavailable.nestedRepositoryTitle"),description:b("diffView.unavailable.nestedRepositoryDescription")}):v==="untracked_directory"?t.jsx(ft,{icon:!0,message:b("diffView.unavailable.untrackedDirectoryTitle"),description:b("diffView.unavailable.untrackedDirectoryDescription")}):u?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:b("mobile.changes.diffDetail.loadFailed")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:u}),t.jsx(Ce,{type:"button",size:"sm",variant:"outline",onClick:f,children:b("diffView.actions.retry")})]})}):r?r.submodule?t.jsx("div",{className:"p-3",children:t.jsx(Nd,{state:r.submodule,staged:x})}):r.isBinary?t.jsx(ft,{icon:!0,message:b("diffView.binary.unavailable")}):uc(s)&&!r.fileDiff?t.jsx(ft,{icon:!0,message:b("mobile.changes.diffDetail.imageUnavailable")}):t.jsx(Gn,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:t.jsx(Ld,{original:r.original,modified:r.modified,fileDiff:r.fileDiff,language:j,fileName:s,renderSideBySide:!1,wrapLines:!0,hideWhitespace:R,layout:"inline",onExpandContextRequest:g,pendingContextExpansion:p,contextLoading:h})}):t.jsx(ft,{loading:!0,message:b("diffView.state.loadingDiff")}):t.jsx(ft,{icon:!0,message:b("mobile.changes.diffDetail.missingTitle"),description:b("mobile.changes.diffDetail.missingDescription")})}),e[38]=h,e[39]=r,e[40]=u,e[41]=a,e[42]=R,e[43]=j,e[44]=g,e[45]=f,e[46]=s,e[47]=p,e[48]=x,e[49]=b,e[50]=v,e[51]=U):U=e[51];let X;return e[52]!==I||e[53]!==U?(X=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[I,U]}),e[52]=I,e[53]=U,e[54]=X):X=e[54],X},lp=n=>{const e=de.c(12),{files:s,onSelect:i}=n,{t:r}=he();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 u;e[6]!==i||e[7]!==r?(u=m=>{const f=m.status==="A"?r("diffView.change.new"):m.status==="D"?r("diffView.change.deleted"):m.status==="R"?r("diffView.change.renamed"):m.status==="C"?r("diffView.change.copied"):r("diffView.change.modified"),g=m.status==="A"?"var(--status-success)":m.status==="D"?"var(--status-error)":m.status==="R"||m.status==="C"?"var(--status-info)":"var(--status-warning)";return t.jsx("li",{children:t.jsxs(Ce,{variant:"ghost",size:"lg",className:"w-full justify-start gap-2.5 text-start normal-case",onClick:()=>i(m.path),children:[t.jsx("span",{className:"w-4 shrink-0 text-center typography-meta font-semibold uppercase",style:{color:g},"aria-label":f,children:m.status}),t.jsx(Uo,{filePath:m.path,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label",title:m.path,children:m.path}),(m.insertions>0||m.deletions>0)&&t.jsxs("span",{className:"shrink-0 typography-meta text-muted-foreground",children:["+",m.insertions," -",m.deletions]}),t.jsx(q,{name:"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground"})]})},m.path)},e[6]=i,e[7]=r,e[8]=u):u=e[8],a=s.map(u),e[2]=s,e[3]=i,e[4]=r,e[5]=a}else a=e[5];let l;return e[9]!==o||e[10]!==a?(l=t.jsx(Gn,{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]=l):l=e[11],l};function cp(n){return n.diffHideWhitespace}function up(n){return n.setDiffHideWhitespace}const dp=c.lazy(()=>ws(()=>import("./FilesView-BBFbfDp9.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128])).then(n=>({default:n.FilesView}))),Nt=n=>on(n)??"",Qs=n=>{const e=Nt(n);return!e||e==="/"?e||"/":e.split("/").filter(Boolean).at(-1)??e},fp=n=>{const e=Nt(n);if(!e||e==="/")return null;const s=e.lastIndexOf("/");return s<=0?e.startsWith("/")?"/":null:e.slice(0,s)},mp=(n,e)=>{const s=Nt(n),i=Nt(e);return!i||s===i?Qs(s):s.startsWith(`${i}/`)?s.slice(i.length+1):s},pp=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""},hp=n=>{const e=de.c(6),{onClose:s,visible:i}=n,r=i===void 0?!0:i,o=Wr()??null;let a;e[0]!==o?(a=Nt(o),e[0]=o,e[1]=a):a=e[1];const l=a;let u;return e[2]!==s||e[3]!==l||e[4]!==r?(u=t.jsx(gp,{root:l,onClose:s,visible:r},l),e[2]=s,e[3]=l,e[4]=r,e[5]=u):u=e[5],u},gp=({root:n,onClose:e,visible:s})=>{const{t:i}=he(),{files:r}=Un(),o=Qa(),a=Za(G=>G.setSelectedPath),[l,u]=c.useState(()=>({type:"browser",directory:n})),[m,f]=c.useState([]),[g,p]=c.useState(!1),[h,x]=c.useState(null),[v,b]=c.useState(""),[C,j]=c.useState([]),[R,T]=c.useState(!1),D=c.useRef(0),k=l.type==="browser"?l.directory:l.returnDirectory,S=c.useRef(k);S.current=k;const y=c.useCallback(async(G,N)=>{if(!G)return;const Y=!o,ne=D.current+1;D.current=ne,p(!0),N?.background||x(null);try{const re=await r.listDirectory(G,{respectGitignore:Y});if(D.current!==ne)return;x(null),f(re.entries.slice().sort((K,oe)=>K.isDirectory!==oe.isDirectory?K.isDirectory?-1:1:K.name.localeCompare(oe.name)))}catch(re){if(D.current!==ne)return;if(N?.background){console.error("Failed to reload mobile directory:",re);return}f([]),x(re instanceof Error?re.message:i("mobile.files.error.listFailed"))}finally{D.current===ne&&p(!1)}},[r,o,i]);c.useEffect(()=>{l.type==="browser"&&y(l.directory)},[y,l]);const E=c.useRef(l);E.current=l;const O=c.useRef(m);O.current=m;const L=c.useCallback(({directories:G})=>{const N=E.current;N.type==="browser"&&(G&&!G.some(Y=>Nt(Y)===Nt(N.directory))||O.current.length>Eu||y(N.directory,{background:!0}))},[y]);Iu({root:n,active:s,whileInactive:"hold",onChanges:L});const z=c.useCallback(async G=>{Nt(G)===Nt(S.current)&&await y(S.current)},[y]),{canUpload:A,uploadingDirectory:_,pickFiles:B,uploadElements:P}=Au({root:n,refreshDirectory:z}),M=_!==null;c.useEffect(()=>{if(l.type!=="browser")return;const G=v.trim();if(!G){j([]),T(!1);return}let N=!1;const Y=window.setTimeout(()=>{T(!0),r.search({directory:l.directory,query:G,maxResults:40}).then(ne=>{N||j(ne)}).catch(()=>{N||j([])}).finally(()=>{N||T(!1)})},250);return()=>{N=!0,window.clearTimeout(Y)}},[r,v,l]);const $=G=>{b(""),u({type:"browser",directory:G})},I=G=>{a(n,G),u({type:"file",path:G,returnDirectory:k||n})},U=Fe(G=>G.pendingFileFocusPath),X=Fe(G=>G.pendingFileNavigation);if(c.useEffect(()=>{const G=Nt(X?.path??U??"");!G||!n||(a(n,G,{allowOutsideRoot:!0}),u({type:"file",path:G,returnDirectory:n}),U&&Fe.getState().setPendingFileFocusPath(null))},[U,X,n,a]),!n)return t.jsx(Zs,{message:i("mobile.files.empty.noDirectory")});if(l.type==="file")return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/70 px-3 text-foreground",children:[t.jsx("button",{type:"button",className:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":i("header.actions.backAria"),onClick:()=>u({type:"browser",directory:l.returnDirectory}),style:{touchAction:"manipulation"},children:t.jsx(Ti,{className:"size-5"})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:Qs(l.path)})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(Je,{children:t.jsx(c.Suspense,{fallback:t.jsx(Zs,{loading:!0,message:i("filesView.state.loading")}),children:t.jsx(dp,{mode:"editor-only"})})})})]});const Q=l.directory===n?i("mobile.files.rootDirectory"):Qs(l.directory),ue=v.trim()?C:[],se=fp(l.directory),te=l.directory!==n&&se!==null&&(se===n||se.startsWith(`${n}/`)),ge=te&&!v.trim(),ee=te?se:null;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[P,t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[e?t.jsx("button",{type:"button",className:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":i("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(ld,{className:"size-5"})}):null,ge&&ee?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":i("mobile.files.backToParentAria",{name:Qs(ee)}),onClick:()=>$(ee),style:{touchAction:"manipulation"},children:t.jsx(Ti,{className:"size-5"})}):null,t.jsx("div",{className:"min-w-0 flex-1 px-1",children:t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:Q})}),t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":i("mobile.files.refreshAria"),onClick:()=>{y(l.directory)},style:{touchAction:"manipulation"},children:t.jsx(cd,{className:Z("size-5",g&&"animate-spin")})}),A?t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50","aria-label":i("sidebarFilesTree.actions.uploadFilesTitle"),onClick:()=>B(l.directory),disabled:M,style:{touchAction:"manipulation"},children:t.jsx(q,{name:M?"loader-4":"upload-2",className:Z("size-5",M&&"animate-spin")})}):null]}),t.jsx("div",{className:"shrink-0 px-4 pb-2 pt-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(ud,{className:"pointer-events-none absolute inset-s-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(Bo,{value:v,onChange:G=>b(G.target.value),placeholder:i("mobile.files.search.placeholder"),className:"h-11 ps-9"})]})}),t.jsx(Gn,{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-3",children:h?t.jsx(Zs,{message:h}):v.trim()?t.jsx(bp,{results:ue,isSearching:R,onOpenFile:I}):t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:[m.length===0&&!g?t.jsx("div",{className:"px-4 py-8 text-center typography-body text-muted-foreground",children:i("mobile.files.empty.directory")}):null,m.map(G=>t.jsx(_a,{name:G.name,path:G.path,directory:G.isDirectory,meta:G.isDirectory?void 0:pp(G.size),onClick:()=>G.isDirectory?$(G.path):I(G.path)},G.path))]})})]})},_a=n=>{const e=de.c(16),{name:s,path:i,directory:r,meta:o,onClick:a}=n;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={touchAction:"manipulation"},e[0]=l):l=e[0];let u;e[1]!==r||e[2]!==i?(u=r?t.jsx(md,{className:"size-5 shrink-0 text-primary/80"}):t.jsx(Uo,{filePath:i,className:"size-5 shrink-0"}),e[1]=r,e[2]=i,e[3]=u):u=e[3];let m;e[4]!==s?(m=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:s}),e[4]=s,e[5]=m):m=e[5];let f;e[6]!==o?(f=o?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:o}):null,e[6]=o,e[7]=f):f=e[7];let g;e[8]!==r?(g=r?t.jsx(pd,{className:"size-4 shrink-0 text-muted-foreground/60"}):null,e[8]=r,e[9]=g):g=e[9];let p;return e[10]!==a||e[11]!==u||e[12]!==m||e[13]!==f||e[14]!==g?(p=t.jsxs("button",{type:"button",className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3 py-2.5 text-start transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:a,style:l,children:[u,m,f,g]}),e[10]=a,e[11]=u,e[12]=m,e[13]=f,e[14]=g,e[15]=p):p=e[15],p},bp=n=>{const e=de.c(10),{results:s,isSearching:i,onOpenFile:r}=n,{t:o}=he(),a=Nt(Wr()??null);if(i){let f;e[0]!==o?(f=o("common.loading"),e[0]=o,e[1]=f):f=e[1];let g;return e[2]!==f?(g=t.jsx(Zs,{loading:!0,message:f}),e[2]=f,e[3]=g):g=e[3],g}if(s.length===0){let f;e[4]!==o?(f=o("mobile.files.search.empty"),e[4]=o,e[5]=f):f=e[5];let g;return e[6]!==f?(g=t.jsx(Zs,{message:f}),e[6]=f,e[7]=g):g=e[7],g}const l="overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",u=s.map(f=>t.jsx(_a,{name:Qs(f.path),path:f.path,directory:!1,meta:mp(f.path,a),onClick:()=>r(f.path)},f.path));let m;return e[8]!==u?(m=t.jsx("div",{className:l,children:u}),e[8]=u,e[9]=m):m=e[9],m},Zs=n=>{const e=de.c(7),{message:s,loading:i}=n,r=i===void 0?!1:i;let o;e[0]!==r?(o=r?t.jsx(dd,{className:"size-5 animate-spin text-muted-foreground"}):t.jsx(fd,{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 l;return e[4]!==o||e[5]!==a?(l=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]=l):l=e[6],l},po="mobile-surface-root",xp=16,ho=320,yp="cubic-bezier(0.22, 1, 0.36, 1)",vp=n=>{const e=de.c(38),{onOpenMcpSettings:s,active:i}=n,{t:r}=he(),[o,a]=c.useState(!1),l=zt(jp),u=fs(kp),m=xs(Sp);let f;e[0]!==l||e[1]!==o||e[2]!==m||e[3]!==u?(f=()=>{if(o)return;a(!0);const L=new Promise(Np);Promise.all([u({directory:l||null,silent:!0}),m({force:!0}),L]).finally(()=>a(!1))},e[0]=l,e[1]=o,e[2]=m,e[3]=u,e[4]=f):f=e[4];const g=f;let p;e[5]!==r?(p=r("settings.mcp.sidebar.actions.addServerTitle"),e[5]=r,e[6]=p):p=e[6];let h;e[7]!==r?(h=r("settings.mcp.sidebar.actions.addServerTitle"),e[7]=r,e[8]=h):h=e[8];let x,v;e[9]===Symbol.for("react.memo_cache_sentinel")?(x={touchAction:"manipulation"},v=t.jsx(q,{name:"add",className:"size-5"}),e[9]=x,e[10]=v):(x=e[9],v=e[10]);let b;e[11]!==s||e[12]!==p||e[13]!==h?(b=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:h,style:x,children:v}),e[11]=s,e[12]=p,e[13]=h,e[14]=b):b=e[14];let C;e[15]!==r?(C=r("mcpDropdown.actions.refreshAria"),e[15]=r,e[16]=C):C=e[16];let j;e[17]!==r?(j=r("mcpDropdown.actions.refreshAria"),e[17]=r,e[18]=j):j=e[18];let R;e[19]===Symbol.for("react.memo_cache_sentinel")?(R={touchAction:"manipulation"},e[19]=R):R=e[19];const T=o&&"animate-spin";let D;e[20]!==T?(D=Z("size-5",T),e[20]=T,e[21]=D):D=e[21];let k;e[22]!==D?(k=t.jsx(q,{name:"refresh",className:D}),e[22]=D,e[23]=k):k=e[23];let S;e[24]!==o||e[25]!==g||e[26]!==k||e[27]!==C||e[28]!==j?(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 disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:g,disabled:o,"aria-label":C,title:j,style:R,children:k}),e[24]=o,e[25]=g,e[26]=k,e[27]=C,e[28]=j,e[29]=S):S=e[29];let y;e[30]!==S||e[31]!==b?(y=t.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-1 px-2 pt-1",children:[b,S]}),e[30]=S,e[31]=b,e[32]=y):y=e[32];let E;e[33]!==i?(E=t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(ep,{active:i,className:"h-full",listClassName:"max-h-none",hideHeader:!0,mobileListDensity:!0})}),e[33]=i,e[34]=E):E=e[34];let O;return e[35]!==y||e[36]!==E?(O=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[y,E]}),e[35]=y,e[36]=E,e[37]=O):O=e[37],O},wp=({open:n,onClose:e,tab:s,onTabChange:i,pendingChangesDiff:r,onOpenPlan:o,onOpenMcpSettings:a,variant:l="drawer"})=>{const{t:u,direction:m}=he(),f=c.useRef(null),g=c.useRef(null),[p,h]=c.useState(!1),[x,v]=c.useState(n),b=c.useRef(e);c.useEffect(()=>{b.current=e},[e]);const C=c.useRef(s);c.useEffect(()=>{C.current=s},[s]);const j=()=>b.current();fi(g,{enabled:l==="drawer"&&n,...m==="rtl"?{onRightEdgeSwipe:j}:{onLeftEdgeSwipe:j}});const[R,T]=c.useState(()=>new Set);if(c.useEffect(()=>{n&&T(S=>{if(S.has(s))return S;const y=new Set(S);return y.add(s),y})},[n,s]),typeof document<"u"&&!f.current){let S=document.getElementById(po);S||(S=document.createElement("div"),S.id=po,document.body.appendChild(S)),f.current=S}if(c.useEffect(()=>{if(n){v(!0);const y=window.setTimeout(()=>h(!0),xp);return()=>window.clearTimeout(y)}h(!1);const S=window.setTimeout(()=>v(!1),ho+40);return()=>window.clearTimeout(S)},[n]),c.useEffect(()=>{if(!n)return;const S=document.body.style.overflow;l==="drawer"&&(document.body.style.overflow="hidden");const y=E=>{E.key!=="Escape"||C.current==="terminal"||gc(E.target)||b.current()};return document.addEventListener("keydown",y),()=>{l==="drawer"&&(document.body.style.overflow=S),document.removeEventListener("keydown",y)}},[n,l]),l==="drawer"&&!f.current)return null;const D=[{id:"changes",label:u("mobile.menu.changes"),icon:t.jsx(q,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"files",label:u("mobile.menu.files"),icon:t.jsx(q,{name:"file-text",className:"h-3.5 w-3.5"})},{id:"terminal",label:u("mobile.menu.terminal"),icon:t.jsx(q,{name:"terminal",className:"h-3.5 w-3.5"})},{id:"notes",label:u("contextRail.surface.notes"),icon:t.jsx(q,{name:"sticky-note",className:"h-3.5 w-3.5"})},{id:"mcp",label:u("mobile.menu.mcp"),icon:t.jsx(pc,{className:"h-3.5 w-3.5"})}],k=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:x?t.jsx(hc,{items:D,activeId:s,onSelect:S=>i(S),layoutMode:"fit",variant:"active-pill",nonCompositedIndicator:!0,inactiveTabsIconOnly:!0,className:"h-full"}):null}),t.jsx("button",{type:"button",className:"-me-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":u("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(q,{name:"close",className:"size-5"})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[R.has("changes")?t.jsx("div",{className:Z("h-full",s!=="changes"&&"hidden"),children:t.jsx(Je,{children:t.jsx(op,{visible:n&&s==="changes",initialDiff:r,onNavigatedToChat:e})})},r?`changes:${r.path}:${r.staged}`:"changes"):null,R.has("files")?t.jsx("div",{className:Z("h-full",s!=="files"&&"hidden"),children:t.jsx(Je,{children:t.jsx(hp,{visible:n&&s==="files"})})}):null,R.has("terminal")?t.jsx("div",{className:Z("h-full",s!=="terminal"&&"hidden"),children:t.jsx(Je,{children:t.jsx(Pu,{visible:n&&s==="terminal"})})}):null,R.has("notes")?t.jsx("div",{className:Z("h-full",s!=="notes"&&"hidden"),children:t.jsx(Je,{children:t.jsx(Tu,{visible:n&&s==="notes",onActionComplete:e,onOpenPlan:o})})}):null,R.has("mcp")?t.jsx("div",{className:Z("h-full",s!=="mcp"&&"hidden"),children:t.jsx(Je,{children:t.jsx(vp,{active:n&&s==="mcp",onOpenMcpSettings:a})})}):null]})]});return l==="panel"?t.jsx("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:k}):vs.createPortal(t.jsx("section",{ref:g,role:"dialog","aria-modal":"true","aria-label":u("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":m==="rtl"?"translateX(-100%)":"translateX(100%)",transition:`transform ${ho}ms ${yp}`,visibility:x?"visible":"hidden",pointerEvents:n?"auto":"none"},children:k}),f.current)};function jp(n){return n.currentDirectory}function kp(n){return n.refresh}function Sp(n){return n.loadMcpConfigs}function Np(n){return window.setTimeout(n,500)}function Cp(n){const e=de.c(4),s=2500,{uiFont:i}=bc(),[r,o]=c.useState(!1);let a,l;return e[0]!==s||e[1]!==i?(a=()=>{let u=!1;const m=()=>{u||o(!0)},f=()=>{requestAnimationFrame(()=>requestAnimationFrame(m))},g=Promise.all([xc(i).catch(Pp),document.fonts?.ready?.then(Ap).catch(Ip)??Promise.resolve(),$d.catch(Ep)]).then(Rp),p=new Promise(h=>{window.setTimeout(h,s)});return Promise.race([g,p]).then(f),()=>{u=!0}},l=[i,s],e[0]=s,e[1]=i,e[2]=a,e[3]=l):(a=e[2],l=e[3]),c.useEffect(a,l),r}function Rp(){}function Ep(){}function Ip(){}function Ap(){}function Pp(){}const Tp=Zo({projectId:Oi().trim().min(1).optional(),text:Oi().optional()}),Dp=Zo({request:Tp.nullish()}),Ma=Jo("ShortcutRequests"),_p=async()=>{const n=Dp.safeParse(await Ma.takePending());return n.success?n.data.request??null:null},Mp=n=>{if(Mr()!=="ios")return()=>{};let e=!1,s=null;const i=()=>{_p().then(r=>{r&&n(r)}).catch(()=>{})};return Ma.addListener("pending",i).then(r=>{if(e){r.remove();return}s=r}).catch(()=>{}),i(),()=>{e=!0,s?.remove()}},Op="openchamber",zp=n=>n.replace(/^\/+|\/+$/g,""),Bp=n=>{const e=zp(n.pathname).split("/").filter(Boolean);return n.host?[n.host,...e]:e};function Lp(n){if(typeof n!="string"||n.length===0)return null;let e;try{e=new URL(n)}catch{return null}if(e.protocol!==`${Op}:`)return null;const s=Bp(e),i=(s[0]??"").toLowerCase(),r=s.slice(1),o=e.searchParams;switch(i){case"session":{const a=r[0]||o.get("id")||"";if(!a)return null;const l=o.get("message")?.trim()??"";return{type:"session",sessionId:a,directory:o.get("dir")??void 0,...yc(l)?{messageId:l}:{}}}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 ut={},Oa=!1,Xs=null;const Fp=n=>{const e=Me.getState(),s=n.projectId?rt.getState().projects.find(r=>r.id===n.projectId)??null:null;e.openNewSessionDraft(s?{selectedProjectId:s.id}:void 0);const i=n.text?.trim();if(i){if(n.projectId&&!s){Ai.getState().setPendingInputText(i,"append");return}Ai.getState().requestDraftSubmit(Me.getState().newSessionDraft.draftId,i)}},$p=n=>{switch(n.type){case"shortcut-new-session":return Fp(n),!0;case"session":return n.messageId&&!n.directory?(vc(n.sessionId,n.messageId),!0):(n.messageId&&wc(n.sessionId,n.messageId),Me.getState().setCurrentSession(n.sessionId,n.directory??null),!0);case"new-session":{const e=Me.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 ut.openSessions?(ut.openSessions(n.filter),!0):!1;case"status":return ut.openSessions?(ut.openSessions(),!0):!1;case"view":return ut.openView?(ut.openView(n.target),!0):!1;case"changes":return ut.openChanges?(ut.openChanges({path:n.path,staged:n.staged}),!0):!1;case"settings":return ut.openSettings?(ut.openSettings(n.section),!0):!1}},pi=()=>{if(!Oa||!Xs)return;const n=Xs;Xs=null,$p(n)||(Xs=n)},_r=n=>{Xs=n,pi()},go=n=>{const e=Lp(n);e&&_r(e)},Wp=n=>{Oa=n,pi()},Vp=n=>{const e=de.c(3);let s,i;e[0]!==n?(s=()=>(ut=n,pi(),()=>{ut===n&&(ut={})}),i=[n],e[0]=n,e[1]=s,e[2]=i):(s=e[1],i=e[2]),c.useEffect(s,i)},Up=n=>{const{ready:e}=n;c.useEffect(()=>{Wp(e)},[e]),c.useEffect(()=>{if(!Xe())return;let s=!1;const i=[];return ws(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([129,5,55])).then(async({App:r})=>{if(s)return;const o=await r.addListener("appUrlOpen",a=>{go(a?.url)});if(s){o.remove();return}i.push(()=>{o.remove()})}).catch(()=>{}),i.push(Mp(r=>{_r({type:"shortcut-new-session",projectId:r.projectId,text:r.text})})),ws(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([130,55])).then(async({PushNotifications:r})=>{if(s)return;const o=await r.addListener("pushNotificationActionPerformed",a=>{const l=a?.notification?.data,u=typeof l?.url=="string"?l.url:typeof l?.deeplink=="string"?l.deeplink:void 0;if(u){go(u);return}const m=typeof l?.sessionId=="string"?l.sessionId:void 0;m&&_r({type:"session",sessionId:m})});if(s){o.remove();return}i.push(()=>{o.remove()})}).catch(()=>{}),()=>{s=!0,i.forEach(r=>r())}},[])},Gp=()=>{if(typeof window>"u")return;const n=window.__OPENCHAMBER_APNS_ENV__;if(n==="development")return"sandbox";if(n==="production")return"production"},bo=/^[A-Za-z0-9+/]{43}=$/,Kp=Jo("PushKey"),qp=async()=>{const n=window.__OPENCHAMBER_PUSH_KEY__;if(n&&bo.test(n))return n;const e=await Kp.get().then(s=>s.key).catch(()=>{});return e&&bo.test(e)?e:void 0},Hp=()=>{if(typeof window>"u")return!1;const e=window.Capacitor?.getPlatform?.();return e==="ios"||e==="android"},Yp=n=>{const{enabled:e}=n,s=Fe(r=>r.nativeNotificationsEnabled),i=c.useRef(null);c.useEffect(()=>{if(!e||!s||!Hp())return;let r=!1;const o=[];return ws(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([130,55])).then(async({PushNotifications:a})=>{if(r)return;let l=await a.checkPermissions().catch(()=>null);if(l?.receive!=="granted"&&(l=await a.requestPermissions().catch(()=>null)),l?.receive!=="granted")return;const u=await a.addListener("registration",f=>{i.current=f.value,qp().then(g=>{const p=ji(),h={token:f.value,platform:Mr(),environment:Gp()};g&&(h.pushKey=g),p?.push?.registerApnsToken?.(h)})}),m=await a.addListener("registrationError",f=>{console.warn("[Push] APNs registration error:",f)});if(await a.register().catch(()=>{}),r){u.remove(),m.remove();return}o.push(()=>{u.remove()},()=>{m.remove()})}).catch(()=>{}),()=>{r=!0,o.forEach(a=>a())}},[e,s]),c.useEffect(()=>{if(s)return;const r=i.current;if(!r)return;i.current=null,ji()?.push?.unregisterApnsToken?.({token:r})},[s])},xo=n=>{const e=de.c(12),{side:s,isResizing:i,ariaLabel:r,handleProps:o}=n,a=s==="left"?"inset-e-0":"inset-s-0";let l;e[0]!==a?(l=Z("absolute inset-y-0 z-50 w-6 cursor-col-resize touch-none",a),e[0]=a,e[1]=l):l=e[1];const u=s==="left"?"inset-e-0":"inset-s-0",m=i&&"bg-[var(--interactive-border)]";let f;e[2]!==u||e[3]!==m?(f=Z("absolute inset-y-0 w-[3px] transition-colors",u,m),e[2]=u,e[3]=m,e[4]=f):f=e[4];let g;e[5]!==f?(g=t.jsx("div",{className:f}),e[5]=f,e[6]=g):g=e[6];let p;return e[7]!==r||e[8]!==o||e[9]!==l||e[10]!==g?(p=t.jsx("div",{className:l,role:"separator","aria-orientation":"vertical","aria-label":r,...o,children:g}),e[7]=r,e[8]=o,e[9]=l,e[10]=g,e[11]=p):p=e[11],p},Jp=320,Xp=380,yo=280,Qp=560,Zp=900;function vo(n,e,s,i){const r=de.c(23),o=i===void 0?Qp:i,a=c.useRef(null);let l;r[0]!==s||r[1]!==o||r[2]!==e?(l=()=>{if(typeof window>"u")return s;const A=Number.parseInt(window.localStorage.getItem(e)??"",10);return Number.isFinite(A)?Math.min(o,Math.max(yo,A)):s},r[0]=s,r[1]=o,r[2]=e,r[3]=l):l=r[3];const[u,m]=c.useState(l),[f,g]=c.useState(!1),p=c.useRef(0),h=c.useRef(u),x=c.useRef(null),v=c.useRef(null);let b;r[4]!==o?(b=A=>Math.min(o,Math.max(yo,Math.round(A))),r[4]=o,r[5]=b):b=r[5];const C=b;let j;r[6]===Symbol.for("react.memo_cache_sentinel")?(j=A=>{const _=a.current;_&&(_.style.width=`${A}px`,_.style.minWidth=`${A}px`,_.style.maxWidth=`${A}px`,_.style.setProperty("--oc-ipad-sidebar-width",`${A}px`))},r[6]=j):j=r[6];const R=j;let T;r[7]!==u?(T=A=>{try{A.currentTarget.setPointerCapture(A.pointerId)}catch{}v.current=A.pointerId,p.current=A.clientX,h.current=u,x.current=u,g(!0),A.preventDefault()},r[7]=u,r[8]=T):T=r[8];const D=T;let k;r[9]!==C||r[10]!==n?(k=A=>{if(v.current!==A.pointerId)return;const _=(n==="left"?1:-1)*(el(A.currentTarget)?-1:1),B=C(h.current+(A.clientX-p.current)*_);x.current!==B&&(x.current=B,R(B))},r[9]=C,r[10]=n,r[11]=k):k=r[11];const S=k;let y;r[12]!==C||r[13]!==e?(y=A=>{if(v.current!==A.pointerId)return;try{A.currentTarget.releasePointerCapture(A.pointerId)}catch{}const _=C(x.current??h.current);v.current=null,x.current=null,g(!1),m(_);try{window.localStorage.setItem(e,String(_))}catch{}},r[12]=C,r[13]=e,r[14]=y):y=r[14];const E=y;let O;r[15]!==D||r[16]!==E||r[17]!==S?(O={onPointerDown:D,onPointerMove:S,onPointerUp:E,onPointerCancel:E},r[15]=D,r[16]=E,r[17]=S,r[18]=O):O=r[18];const L=O;let z;return r[19]!==L||r[20]!==f||r[21]!==u?(z={asideRef:a,width:u,isResizing:f,handleProps:L},r[19]=L,r[20]=f,r[21]=u,r[22]=z):z=r[22],z}const eh=["general","isolated-spaces","appearance","chat","notifications","sessions","routing","git","magic-prompts","snippets","behavior","agents","commands","mcp","plugins","skills.installed","skills.catalog","providers","web-search","usage","voice","integrations","about"],th=1e3,sh=({onActiveConnectionDeleted:n})=>{const{t:e,direction:s}=he();Gu();const[i,r]=c.useState(!1);c.useEffect(()=>Me.subscribe((H,pe)=>{H.currentSessionId&&H.currentSessionId!==pe.currentSessionId&&Fe.getState().setRunOverviewKey(null)}),[]);const o=Fe(H=>H.runOverviewKey!==null);c.useEffect(()=>{o&&r(!1)},[o]);const[a,l]=c.useState(null),[u,m]=c.useState(!1),[f,g]=c.useState("changes"),[p,h]=c.useState(null),[x,v]=c.useState("nav"),[b,C]=c.useState(null),j=Fe(H=>H.setSettingsPage),R=Fe(H=>H.wideChatLayoutEnabled),T=hs(H=>H.available),D=hs(H=>H.runtimeType),k=c.useMemo(()=>Vr(),[]),S=xs(H=>H.mcpServers),y=xs(H=>H.setMcpDraft),E=xs(H=>H.setSelectedMcp),O=c.useCallback(()=>{l(null),h(null)},[]),L=c.useCallback(H=>{l(H)},[]),z=c.useCallback(()=>{m(!1)},[]),A=c.useCallback(H=>{v(H),L("settings")},[L]),{enabled:_,roomyForPanels:B}=zr(),M=Lc()==="portrait",$=Fc(),[I,U]=c.useState(()=>$c().roomyForPanels),X=c.useCallback(()=>{U(H=>!H)},[]);c.useEffect(()=>{_||U(!1)},[_]);const Q=c.useCallback(()=>{C(null),g("files"),m(!0)},[]);c.useEffect(()=>Go(H=>{if(H.type!=="file-open-request")return;const pe=H.directory??zt.getState().currentDirectory;pe&&(Fe.getState().openContextFile(pe,H.path),Q())}),[Q]);const ue=c.useCallback((H=null)=>{C(H),g("changes"),m(!0)},[]),se=vo("left","openchamber.ipad.leftSidebarWidth",Jp),te=vo("right","openchamber.ipad.rightSidebarWidth",Xp,Zp),ge=B,ee=ge&&u?te.width:0,G=_&&I?se.width:0;c.useEffect(()=>{if(typeof document>"u")return;const H=document.documentElement;return H.style.setProperty("--oc-chat-inset-left",`${G}px`),H.style.setProperty("--oc-chat-inset-right",`${ee}px`),()=>{H.style.removeProperty("--oc-chat-inset-left"),H.style.removeProperty("--oc-chat-inset-right")}},[G,ee]),c.useEffect(()=>{if(typeof document>"u")return;const H=document.documentElement;return H.classList.toggle("wide-chat-layout",R),()=>H.classList.remove("wide-chat-layout")},[R]),c.useEffect(()=>{if(typeof document>"u")return;const H=_&&(M||$),pe=document.documentElement;return pe.classList.toggle("oc-keep-draft-starters",H),()=>pe.classList.remove("oc-keep-draft-starters")},[$,_,M]);const N=c.useMemo(()=>({openChanges:({diffPath:H,staged:pe}={})=>{ue(H?{path:H,staged:pe===!0}:null)},openFiles:()=>Q(),openSettings:()=>A("nav"),openSourceBoard:()=>L("board")}),[ue,Q,A,L]),Y=c.useMemo(()=>({openSessions:()=>{_?U(!0):r(!0)},openView:H=>{if(H==="files"){Q();return}if(H==="mcp"){g("mcp"),m(!0);return}L(H)},openChanges:({path:H,staged:pe}={})=>{ue(H?{path:H,staged:pe===!0}:null)},openSettings:H=>{H&&j(H),A(H?"page-content":"nav")}}),[_,ue,Q,A,L,j]);Vp(Y);const ne=c.useRef(null),re=()=>{_?U(!0):r(!0)},K=()=>m(!0);fi(ne,{onLeftEdgeSwipe:s==="rtl"?K:re,onRightEdgeSwipe:s==="rtl"?re:K});const oe=c.useRef(null),fe=c.useCallback(H=>{oe.current=H},[]),Se=c.useCallback(()=>Wc()?!0:p?(h(null),!0):a==="settings"&&oe.current?.()?!0:a?(O(),!0):u?(z(),!0):i?(r(!1),!0):!1,[a,O,z,p,i,u]);Vc(Se);const we=!k&&T&&(D==="desktop"||D==="web"),xe=_?"dialog":"fullscreen",ye=c.useMemo(()=>({instanceLabel:k?Hs():null,onOpenInstances:k?()=>L("instances"):void 0,onOpenSettings:()=>A("nav"),onOpenUsage:()=>L("usage"),onOpenScheduled:()=>L("scheduled"),onOpenArchive:()=>L("archive"),onOpenSourceBoard:()=>L("board"),onOpenUpdate:we?()=>L("update"):void 0}),[A,L,k,we]),De=c.useCallback(H=>{O(),r(!1),H==="file"&&Q()},[O,Q]),Te=c.useCallback(()=>{O(),r(!1)},[O]),ve=c.useCallback(()=>{O(),r(!1),_&&!B&&U(!1)},[O,_,B]),Ne=c.useCallback(()=>{const H="new-mcp-server";let pe=H,Ae=1;for(;S.some(Re=>Re.name===pe);)pe=`${H}-${Ae}`,Ae+=1;y({name:pe,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",oauthCallbackPort:"",oauthAuthServerMetadataUrl:"",protocol:"legacy",timeoutStartup:"",timeoutCatalog:"",timeoutExecution:"",codemode:"default",disabled:!1}),E(pe),j("mcp"),A("page-content")},[S,A,y,E,j]);return t.jsx(Uc,{actions:N,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:Z("relative flex h-full shrink-0 flex-col overflow-hidden border-e border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!I&&"border-e-0"),style:{width:I?se.width:0,minWidth:I?se.width:0,maxWidth:I?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":!I,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:Z("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",!I&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Je,{children:t.jsx(oo,{open:!0,variant:"sidebar",onOpenChange:H=>{!H&&!B&&U(!1)},footer:ye})})}),I?t.jsx(xo,{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(rm,{onOpenSessions:()=>_?X():r(!0),onOpenWorkspace:()=>m(!0),compactTitle:_}),t.jsxs("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(Je,{children:t.jsx(Ku,{})})}),t.jsx(Je,{children:t.jsx(sd,{})})]})]}),_?null:t.jsx(oo,{open:i,onOpenChange:r,footer:ye}),t.jsxs("aside",{ref:te.asideRef,className:Z("relative flex h-full shrink-0 flex-col overflow-hidden border-s border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!ee&&"border-s-0"),style:{width:ee,minWidth:ee,maxWidth:ee,"--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":!ee,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:Z("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",!ee&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Je,{children:t.jsx(wp,{open:u,onClose:z,tab:f,onTabChange:g,pendingChangesDiff:b,onOpenPlan:h,onOpenMcpSettings:Ne,variant:ge?"panel":"drawer"})})}),ee?t.jsx(xo,{side:"right",isResizing:te.isResizing,ariaLabel:e("sidebar.resize.rightPanelAria"),handleProps:te.handleProps}):null]}),p?t.jsx(Pt,{open:!0,variant:xe,onClose:()=>h(null),ariaLabel:p.title,title:p.title,children:t.jsx(Je,{children:t.jsx(Qu,{savedProjectPlan:{projectRef:p.projectRef,planId:p.id},onNavigatedToChat:()=>{O(),z()}})})}):null,a==="instances"&&k?t.jsx(Pt,{open:!0,variant:xe,dialogAlign:"app",onClose:O,ariaLabel:e("mobile.menu.instances"),title:e("mobile.menu.instances"),children:t.jsx(cm,{onConnect:O,onActiveConnectionDeleted:n})}):null,a==="settings"?t.jsx(Pt,{open:!0,variant:xe,dialogAlign:"app",onClose:O,ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(Je,{children:t.jsx(Ju,{forceMobile:!0,isWindowed:!0,initialMobileStage:x,registerBackHandler:fe,visiblePageSlugs:[...eh],onClose:O})})}):null,a==="usage"?t.jsx(Pt,{open:!0,variant:xe,dialogAlign:"app",onClose:O,ariaLabel:e("usageStats.title"),title:e("usageStats.title"),children:t.jsx(Je,{children:t.jsx(bd,{})})}):null,a==="scheduled"?t.jsx(Pt,{open:!0,variant:xe,dialogAlign:"app",onClose:O,ariaLabel:e("sessions.scheduledTasks.dialog.title"),title:e("sessions.scheduledTasks.dialog.title"),children:t.jsx(Je,{children:t.jsx(vd,{layout:"mobile",onLeave:De})})}):null,a==="board"?t.jsx(Pt,{open:!0,variant:xe,dialogAlign:"app",onClose:O,ariaLabel:e("sourceBoard.title"),title:e("sourceBoard.title"),children:t.jsx(Je,{children:t.jsx(yd,{onLeave:Te})})}):null,a==="archive"?t.jsx(Pt,{open:!0,variant:xe,dialogAlign:"app",onClose:O,ariaLabel:e("sessions.archivePage.title"),title:e("sessions.archivePage.title"),children:t.jsx(Je,{children:t.jsx(xd,{layout:"mobile",onLeave:ve})})}):null,a==="update"?t.jsx(Pt,{open:!0,variant:xe,dialogAlign:"app",onClose:O,ariaLabel:e("mobile.menu.update"),title:e("mobile.menu.update"),children:t.jsx(Je,{children:t.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:t.jsx(Xu,{initialUpdateDialogOpen:!0})})})}):null]})})};function nh({apis:n}){const e=Fe(N=>N.isolatedSpacesEnabled),{t:s}=he(),i=dt(N=>N.initializeApp),r=dt(N=>N.isInitialized),o=dt(N=>N.isConnected),a=dt(N=>N.connectionPhase),l=dt(N=>N.providers.length),u=dt(N=>N.agents.length),m=dt(N=>N.loadProviders),f=dt(N=>N.loadAgents),g=zt(N=>N.currentDirectory),p=Me(N=>N.error),h=Me(N=>N.clearError),x=Fe(N=>N.setIsMobile),v=Vo(N=>N.refreshAll),b=jc(N=>N.refreshStatus),C=kc(N=>N.setPlanModeEnabled),j=rt(N=>N.projects),R=bs(N=>N.activeSessions),T=bs(N=>N.archivedSessions),D=bs(N=>N.status==="ready"),k=c.useMemo(()=>[...R,...T],[R,T]);Du({hasAuthoritativeGlobalSessions:D,sessions:k});const[S,y]=c.useState(0),[E,O]=c.useState(0),[L,z]=c.useState(!1),[A,_]=c.useState("pending"),[B,P]=c.useState(null),M=c.useMemo(()=>Hs(),[]),[,$]=c.useReducer(N=>N+1,0),I=c.useMemo(()=>Vr(),[]),U=c.useRef(0),X=c.useRef(0),Q=c.useCallback(()=>{const N=St(),Y=X.current+1;if(X.current=Y,!N){Gs("resume:auto-connect",{}),Ks();return}Gs("resume:reprobe",{});const ne=()=>{i(),v(n.sourceControl,{force:!0}),b(n.linear,{force:!0}),l===0&&m({source:"mobileApp:nativeResume"}),u===0&&f({source:"mobileApp:nativeResume"})},re=oe=>{Gs("resume:disconnect",{reason:oe}),ms({apiBaseUrl:"",clientToken:null,runtimeKey:kn}),y(fe=>fe+1)};Tn().then(oe=>{if(X.current===Y){if(oe==="no-connection"){re("no-connection");return}if(oe==="needs-login"){P({kind:"auth-expired",label:Hs()??""}),re("needs-login");return}if(oe==="unreachable"){const fe=[4e3,1e4],Se=we=>{window.setTimeout(()=>{if(X.current!==Y)return;const xe=we===fe.length-1;Tn({fast:!xe}).then(ye=>{if(X.current===Y&&ye!=="switched"){if(ye==="unchanged"){ne();return}if(ye==="needs-login"){P({kind:"auth-expired",label:Hs()??""}),re("retry-needs-login");return}if(!xe){Se(we+1);return}re(`retry-${ye}`)}})},fe[we])};Se(0);return}oe!=="switched"&&ne()}});const K=Date.now();K-U.current>=th&&(U.current=K,window.dispatchEvent(new Event("openchamber:system-resume")))},[u,n.sourceControl,n.linear,i,f,m,l,v,b]);Sc(),Nc(Q),c.useEffect(()=>{if(!I)return;let N;const Y=()=>{window.clearTimeout(N),N=window.setTimeout(()=>Q(),1500)};return window.addEventListener("online",Y),()=>{window.removeEventListener("online",Y),window.clearTimeout(N)}},[I,Q]),c.useEffect(()=>{if(I)return ki.subscribe((N,Y)=>{N.state==="expired"&&Y.state!=="expired"&&(Q(),ki.getState().markAuthenticated())})},[I,Q]),c.useEffect(()=>(Si(n),()=>Si(null)),[n]),c.useEffect(()=>jo(N=>{if(Gs("endpoint:changed",{runtimeKey:N.runtimeKey||"none",previousRuntimeKey:N.previousRuntimeKey||"none",connected:!!N.apiBaseUrl}),!!N.runtimeKey&&N.runtimeKey===N.previousRuntimeKey){_u(),$();return}Mu(N),O(ne=>ne+1),y(ne=>ne+1)}),[]),c.useEffect(()=>{if(!I||o||St()){_("done");return}let N=!1;return _("attempting"),(async()=>{const Y=await Ks().catch(()=>({status:"no-candidate"}));N||(Y.status==="unreachable"?P({kind:"unreachable",label:Y.label}):Y.status==="needs-login"&&P({kind:"auth-expired",label:Y.label}),_("done"),Y.status==="unreachable"&&Ks({fast:!1,skipIfConnected:!0}).catch(()=>null))})(),()=>{N=!0}},[]),c.useEffect(()=>{if(!I||!St())return;let N=!1;const Y=ne=>{Gs("cold-launch:drop",{kind:ne?.kind??"unknown"}),ne&&P(ne),ms({apiBaseUrl:"",clientToken:null,runtimeKey:kn}),y(re=>re+1)};return Tn().then(async ne=>{if(N||ne==="switched"||ne==="unchanged")return;const re=Hs();if(ne==="needs-login"){Y({kind:"auth-expired",label:re??""});return}if(ne==="unreachable"){Y(re?{kind:"unreachable",label:re}:null),Ks({fast:!1,skipIfConnected:!0}).catch(()=>null);return}const K=await Ks().catch(()=>({status:"no-candidate"}));N||K.status==="connected"||(K.status==="needs-login"?Y({kind:"auth-expired",label:K.label}):K.status==="unreachable"?Y({kind:"unreachable",label:K.label}):Y(null))}),()=>{N=!0}},[]),c.useEffect(()=>{x(!0)},[x]),c.useEffect(()=>{I&&!St()||i()},[S,i,I]),c.useEffect(()=>{o&&(l===0&&m({source:"mobileApp:recovery"}),u===0&&f({source:"mobileApp:recovery"}))},[u,o,f,m,l]);const ue=c.useRef(!1),[se,te]=c.useState(I);c.useEffect(()=>{if(!I||!o||ue.current)return;let N=!1;const Y=window.setTimeout(()=>te(!1),6e3);return(async()=>{const ne=await Ou({refresh:!0});N||(ne!=="failed"&&(ue.current=!0),te(!1))})(),()=>{N=!0,window.clearTimeout(Y)}},[S,o,I]),c.useEffect(()=>{o&&Ni.setDirectory(g)},[g,o]),c.useEffect(()=>{o&&(v(n.sourceControl,{force:!0}),b(n.linear,{force:!0}))},[n.sourceControl,n.linear,o,v,b]),c.useEffect(()=>{if(!o||j.length===0)return;let N=!1;return(async()=>{const ne=new Map(Me.getState().availableWorktreesByProject);if(await Promise.all(j.map(async oe=>{const fe=oe.path.replace(/\\/g,"/").replace(/\/+$/,"");if(fe)try{if(!(lt.getState().directories.get(fe)?.isGitRepo??await ws(()=>import("./useAppFontEffects-C1ceAD51.js").then(ye=>ye.nn),__vite__mapDeps([9,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83])).then(ye=>ye.checkIsGitRepository(fe))))return;const xe=await $o({id:oe.id,path:fe});if(N)return;ne.set(fe,xe)}catch{}})),N)return;const re=Wo(j,ne),K=Me.getState().availableWorktreesByProject;zc(re,K)||Me.setState({availableWorktrees:[...re.values()].flat(),availableWorktreesByProject:re})})(),()=>{N=!0}},[o,j]),c.useEffect(()=>{if(!o)return;let N=!1;const Y=Go(ne=>{ne.type==="worktree-changed"&&Bc(j,ne.directories,()=>N)});return()=>{N=!0,Y()}},[o,j]),c.useEffect(()=>{let N=!1;return(async()=>{const ne=await Or("/health",{method:"GET"}).catch(()=>null);if(!ne||!ne.ok||N)return;const re=await ne.json().catch(()=>null);if(!re||N)return;const K=re.planModeExperimentalEnabled;C(K===!0||K===1||K==="1"||K==="true")})(),()=>{N=!0}},[C]),c.useEffect(()=>{if(!p)return;const N=window.setTimeout(()=>h(),5e3);return()=>window.clearTimeout(N)},[h,p]),c.useEffect(()=>{if(!(!o&&(I?!!St():!0))){z(!1);return}const Y=window.setTimeout(()=>{z(!0)},I?4e3:8e3);return()=>window.clearTimeout(Y)},[o,I,S,E]),Cc(),Rc({enabled:!0}),zu(),Ec(),Ic(),Bu(),Lu(),Yp({enabled:I&&o}),Up({ready:I&&o&&r});const ge=Cp(),ee=!o&&a==="reconnecting";if(!ge)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(ps,{width:120,height:120,isAnimated:!0,variant:"splash"})});const G=!!St();return I&&(!G||!o&&!ee)?G?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(ps,{width:120,height:120,isAnimated:!L,variant:"splash"}),L?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:s("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:s("mobile.connect.recovery.description")})]}),t.jsx(Ce,{type:"button",variant:"outline",onClick:()=>{ms({apiBaseUrl:"",clientToken:null,runtimeKey:kn}),y(N=>N+1)},children:s("mobile.connect.cancelPassword")})]}):null]})}):A!=="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(ps,{width:120,height:120,isAnimated:!0,variant:"splash"}),M?t.jsxs("div",{className:"absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center",children:[t.jsx("p",{className:"typography-small text-muted-foreground",children:s("mobile.connect.splash.connectingTo")}),t.jsxs("p",{className:"typography-small text-foreground",children:[M,t.jsx(Ac,{})]})]}):null]}):t.jsx(t.Fragment,{children:t.jsx(Wf,{onConnected:()=>y(N=>N+1),notice:B})}):!o&&!ee?L?t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground",children:t.jsxs("div",{className:"max-w-sm space-y-3",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:s("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:s("sessionAuth.error.networkDescription")})]})}):t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-[var(--splash-background,var(--surface-background))] text-foreground",children:t.jsx(ps,{width:120,height:120,isAnimated:!0,variant:"splash"})}):t.jsx(Je,{children:t.jsx(Pc,{sdk:Ni.getSdkClient(),directory:g||"",children:t.jsx(Tc,{apis:n,children:t.jsx(Dc,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[t.jsx(Fu,{ready:!I||!se,animated:!0}),t.jsx(_c,{backgroundWorkEnabled:r}),t.jsx($u,{}),t.jsx(Jd,{}),t.jsx(sh,{onActiveConnectionDeleted:()=>{Pf(),ms({apiBaseUrl:"",clientToken:null,runtimeKey:kn}),y(N=>N+1)}}),t.jsx(Mc,{}),t.jsx(Oc,{}),e?t.jsxs(t.Fragment,{children:[t.jsx(Zu,{}),t.jsx(Wu,{}),t.jsx(ed,{}),t.jsx(Vu,{}),t.jsx(td,{})]}):null,t.jsx(sf,{}),r?t.jsx(Uu,{}):null]})})})},E)})}function rh(n){const e=de.c(7),s=c.useSyncExternalStore(ih,St,St);let i;e[0]!==s?(i=!Vr()||!!s,e[0]=s,e[1]=i):i=e[1];let r;e[2]!==n?(r=t.jsx(nh,{...n}),e[2]=n,e[3]=r):r=e[3];let o;return e[4]!==i||e[5]!==r?(o=t.jsx(qu,{enabled:i,children:r}),e[4]=i,e[5]=r,e[6]=o):o=e[6],o}function ih(n){return jo(()=>n())}function Xb(n){window.__OPENCHAMBER_SURFACE__="mobile",Gc(),Yu({logLabel:"[mobile-main]",onAppearanceSettled:Wd}),Yd(),Kc();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(rh,{apis:r});$a.createRoot(e).render(t.jsx(kr.StrictMode,{children:t.jsx(qc,{children:t.jsx(Hc,{children:t.jsx(Yc,{children:t.jsx(Hu,{children:i?o:t.jsx(Jc,{children:o})})})})})}))}export{Xb as renderMobileApp};