@openchamber/web 2.0.2 → 2.0.4

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 (257) hide show
  1. package/bin/lib/DOCUMENTATION.md +1 -1
  2. package/bin/lib/commands-connect-url.js +6 -5
  3. package/bin/lib/commands-tunnel.js +24 -5
  4. package/dist/assets/{CodeMirrorCommentWidgets-CmKmyb9T.js → CodeMirrorCommentWidgets-C_zL-eri.js} +1 -1
  5. package/dist/assets/{DiffView-8-PFpZ2p.js → DiffView-BeN2_YYF.js} +3 -3
  6. package/dist/assets/FilesView-CN34wm_N.js +17 -0
  7. package/dist/assets/{GitView-DNUSu00w.js → GitView-DLDazOo1.js} +4 -4
  8. package/dist/assets/{GuestAttachDialog-Cv6QzjHC.js → GuestAttachDialog-C0xe_Lyy.js} +1 -1
  9. package/dist/assets/{GuestSurfacePane-Bt3jB_Ye.js → GuestSurfacePane-BdaurnDr.js} +1 -1
  10. package/dist/assets/{JsonTreeView-BlyHTRhM.js → JsonTreeView-B1Xq-k2t.js} +1 -1
  11. package/dist/assets/LinearIssuesView-BryoAHow.js +1 -0
  12. package/dist/assets/{MarkdownImageGallery-2UXJF-5B.js → MarkdownImageGallery-DfuEoaGq.js} +1 -1
  13. package/dist/assets/MarkdownRendererImpl-B_ZcWOvX.js +12 -0
  14. package/dist/assets/OnboardingScreen-C22bGmnP.js +1 -0
  15. package/dist/assets/{PatchDiff-ByvnbG5T.js → PatchDiff-0xd6UeFB.js} +1 -1
  16. package/dist/assets/{PierreDiffViewer-BXieg0mH.js → PierreDiffViewer-BC950e3F.js} +3 -3
  17. package/dist/assets/PlanView-B7Xgihqk.js +5 -0
  18. package/dist/assets/PluginPane-2C71F8uF.js +3 -0
  19. package/dist/assets/SettingsView-m_zoFiaT.js +30 -0
  20. package/dist/assets/{SettingsWindow-BIz224xs.js → SettingsWindow-CofS020b.js} +1 -1
  21. package/dist/assets/{SubmoduleDiffSummary-CXKmlps9.js → SubmoduleDiffSummary-BSA9gnIO.js} +1 -1
  22. package/dist/assets/{ToolOutputDialog-BsgAK8xu.js → ToolOutputDialog-DprkVKcj.js} +7 -7
  23. package/dist/assets/{ToolPartDiffPreview-vdPObXOf.js → ToolPartDiffPreview-Dq0go_fX.js} +2 -2
  24. package/dist/assets/{VirtualizedFileDiff-BkFNKWS5.js → VirtualizedFileDiff-Kp8hKJdT.js} +1 -1
  25. package/dist/assets/WalkthroughView-DGnTzqIU.js +4 -0
  26. package/dist/assets/{appThemeRegistry-aHUNHoqP.js → appThemeRegistry-BdEHBA4s.js} +1 -1
  27. package/dist/assets/{commitAndPush-Bon9r94r.js → commitAndPush-LwtVa2Oc.js} +1 -1
  28. package/dist/assets/{computeVirtualFileMetrics-DKqr_1AQ.js → computeVirtualFileMetrics-6V1xNpO9.js} +2 -2
  29. package/dist/assets/de-DlgBHUAI.js +10 -0
  30. package/dist/assets/es-BC8G41U8.js +16 -0
  31. package/dist/assets/fr-I0z3vVjy.js +14 -0
  32. package/dist/assets/index-CgR5rJq_.js +41 -0
  33. package/dist/assets/{index-DpFttslC.js → index-CmNPYddV.js} +1 -1
  34. package/dist/assets/index-adyy_sEk.css +1 -0
  35. package/dist/assets/{isDiffPlainText-kzAgpIgi.js → isDiffPlainText-1bXcWCrw.js} +1 -1
  36. package/dist/assets/{isFilePlainText-Uj6y-jzz.js → isFilePlainText-CBAppvy1.js} +1 -1
  37. package/dist/assets/ja-BIElEsY8.js +16 -0
  38. package/dist/assets/ko-DRnnHetA.js +16 -0
  39. package/dist/assets/{main-CbfMxn-I.js → main-CzjTMTfW.js} +2 -2
  40. package/dist/assets/main-DVX34beR.js +886 -0
  41. package/dist/assets/markdownCore-Cxbkn5NR.js +7 -0
  42. package/dist/assets/{miniChat-CiAKBC10.js → miniChat-CP68IL8Q.js} +2 -2
  43. package/dist/assets/{mobile-CsT4sJwC.js → mobile-BrlBrNfZ.js} +2 -2
  44. package/dist/assets/nl-DzUV-kwp.js +16 -0
  45. package/dist/assets/{patchFileDiff-DeaE08W0.js → patchFileDiff-pqRSHLHI.js} +2 -2
  46. package/dist/assets/pl-Bb-cb7k7.js +16 -0
  47. package/dist/assets/pt-BR-CyIWrTcE.js +16 -0
  48. package/dist/assets/renderElectronMiniChatApp-DKIilR7N.js +2 -0
  49. package/dist/assets/renderMobileApp-B0z6-x58.js +25 -0
  50. package/dist/assets/runtimeEndpointReset-uu1DBwLL.js +52 -0
  51. package/dist/assets/{scheduledTasksApi-BZCNJ588.js → scheduledTasksApi-BuzWT445.js} +1 -1
  52. package/dist/assets/{shikiHighlight-BSUEa3yF.js → shikiHighlight-BWGrY5YU.js} +1 -1
  53. package/dist/assets/{textMateThemeFromAppTheme-CsATFZIV.js → textMateThemeFromAppTheme-BSUFChBY.js} +1 -1
  54. package/dist/assets/tr-DXEDSoYO.js +7 -0
  55. package/dist/assets/uk-C8hN--q_.js +16 -0
  56. package/dist/assets/useAppFontEffects-Dsl_sLrj.js +7366 -0
  57. package/dist/assets/useInlineCommentController-d5vntsQ_.js +2 -0
  58. package/dist/assets/{useRootScrollLock-Cp1eFoM2.js → useRootScrollLock-2rd5Y6gR.js} +2 -2
  59. package/dist/assets/{vendor-base-ui-CsXYnR5c.js → vendor-base-ui-DnNniUWp.js} +1 -1
  60. package/dist/assets/{vendor-codemirror-language-data-BwwommM0.js → vendor-codemirror-language-data-B1EetJur.js} +2 -2
  61. package/dist/assets/vendor-opencode-client-DSZl7jSi.js +12 -0
  62. package/dist/assets/{vendor-tanstack-react-virtual-ClYN8CzB.js → vendor-tanstack-react-virtual--0sBrLRh.js} +1 -1
  63. package/dist/assets/{vendor-tanstack-virtual-core-BewVQryB.js → vendor-tanstack-virtual-core-BoA4iGMw.js} +1 -1
  64. package/dist/assets/{vendor-zod-BSoePkpP.js → vendor-zod-CxRSdNoV.js} +4 -4
  65. package/dist/assets/{web-components-D3Yjr4Zx.js → web-components-ngpHPEDU.js} +1 -1
  66. package/dist/assets/zh-CN-CtzXdjMZ.js +16 -0
  67. package/dist/assets/zh-TW-Ds0CADSz.js +16 -0
  68. package/dist/index.html +5 -5
  69. package/dist/mini-chat.html +5 -5
  70. package/dist/mobile.html +5 -5
  71. package/package.json +5 -5
  72. package/server/index.js +82 -4
  73. package/server/lib/agent-tool/DOCUMENTATION.md +8 -1
  74. package/server/lib/agent-tool/runtime.js +13 -4
  75. package/server/lib/agent-tool/runtime.test.js +15 -0
  76. package/server/lib/context-obligatory/DOCUMENTATION.md +10 -7
  77. package/server/lib/context-obligatory/runtime.js +2 -1
  78. package/server/lib/context-obligatory/runtime.test.js +76 -30
  79. package/server/lib/dictation/DOCUMENTATION.md +4 -1
  80. package/server/lib/dictation/openai-compatible-session.js +7 -0
  81. package/server/lib/enterprise-mode.d.ts +30 -0
  82. package/server/lib/enterprise-mode.js +253 -0
  83. package/server/lib/enterprise-mode.test.js +247 -0
  84. package/server/lib/event-stream/translate-v2.js +6 -0
  85. package/server/lib/event-stream/translate-v2.test.js +6 -0
  86. package/server/lib/git/DOCUMENTATION.md +2 -1
  87. package/server/lib/git/routes.js +44 -1
  88. package/server/lib/git/routes.test.js +98 -1
  89. package/server/lib/git/service.js +146 -11
  90. package/server/lib/git/service.test.js +195 -0
  91. package/server/lib/github/routes.js +9 -19
  92. package/server/lib/github/routes.test.js +112 -0
  93. package/server/lib/guests/DOCUMENTATION.md +4 -2
  94. package/server/lib/guests/background.test.js +1 -1
  95. package/server/lib/guests/catalog.js +56 -2
  96. package/server/lib/guests/catalog.test.js +24 -1
  97. package/server/lib/guests/clone-network.test.js +52 -0
  98. package/server/lib/guests/clone.js +30 -4
  99. package/server/lib/guests/enterprise.js +68 -0
  100. package/server/lib/guests/enterprise.test.js +106 -0
  101. package/server/lib/guests/grant-scope.js +8 -2
  102. package/server/lib/guests/grant-scope.test.js +9 -0
  103. package/server/lib/guests/html-styles.js +16 -2
  104. package/server/lib/guests/html-styles.test.js +53 -4
  105. package/server/lib/guests/install.js +10 -0
  106. package/server/lib/guests/persist.js +1 -0
  107. package/server/lib/guests/routes.js +40 -5
  108. package/server/lib/guests/updates.js +9 -2
  109. package/server/lib/notifications/DOCUMENTATION.md +1 -1
  110. package/server/lib/notifications/runtime.js +22 -8
  111. package/server/lib/notifications/trigger-runtime.test.js +45 -0
  112. package/server/lib/openchamber-sessions/session-metadata-store.js +27 -0
  113. package/server/lib/openchamber-sessions/session-metadata-store.test.js +18 -0
  114. package/server/lib/opencode/DOCUMENTATION.md +13 -9
  115. package/server/lib/opencode/auth-state-runtime.js +2 -2
  116. package/server/lib/opencode/config-paths.test.js +1 -0
  117. package/server/lib/opencode/env-runtime.js +26 -3
  118. package/server/lib/opencode/env-runtime.test.js +57 -0
  119. package/server/lib/opencode/feature-routes-runtime.js +2 -0
  120. package/server/lib/opencode/hmr-state-runtime.js +4 -3
  121. package/server/lib/opencode/lifecycle.js +10 -5
  122. package/server/lib/opencode/lifecycle.test.js +6 -2
  123. package/server/lib/opencode/managed-config-file.js +2 -1
  124. package/server/lib/opencode/managed-config-file.test.js +18 -0
  125. package/server/lib/opencode/npm-registry-config.d.ts +1 -0
  126. package/server/lib/opencode/npm-registry-config.js +123 -0
  127. package/server/lib/opencode/npm-registry-config.test.js +167 -0
  128. package/server/lib/opencode/npm-registry.js +5 -6
  129. package/server/lib/opencode/npm-registry.test.js +30 -0
  130. package/server/lib/opencode/openchamber-routes.js +8 -0
  131. package/server/lib/opencode/project-icon-routes.js +2 -2
  132. package/server/lib/opencode/project-icon-routes.test.js +44 -0
  133. package/server/lib/opencode/provider-source-route.test.js +32 -0
  134. package/server/lib/opencode/routes.js +17 -2
  135. package/server/lib/opencode/settings-helpers.js +26 -3
  136. package/server/lib/opencode/settings-helpers.test.js +12 -5
  137. package/server/lib/opencode/settings-registry.json +35 -1
  138. package/server/lib/opencode/settings-runtime.js +1 -0
  139. package/server/lib/opencode/shutdown-runtime.js +2 -0
  140. package/server/lib/opencode/static-routes-runtime.js +9 -1
  141. package/server/lib/opencode/static-routes-runtime.test.js +58 -1
  142. package/server/lib/package-manager.js +4 -1
  143. package/server/lib/package-manager.test.js +24 -0
  144. package/server/lib/permission-auto-accept/DOCUMENTATION.md +23 -15
  145. package/server/lib/permission-auto-accept/modes.js +26 -0
  146. package/server/lib/permission-auto-accept/runtime.js +146 -40
  147. package/server/lib/permission-auto-accept/runtime.test.js +93 -9
  148. package/server/lib/quota/DOCUMENTATION.md +6 -0
  149. package/server/lib/quota/providers/zhipuai-coding-plan.js +74 -30
  150. package/server/lib/quota/providers/zhipuai-coding-plan.test.js +124 -0
  151. package/server/lib/relay/DOCUMENTATION.md +1 -1
  152. package/server/lib/relay/service.js +32 -12
  153. package/server/lib/relay/service.test.js +30 -0
  154. package/server/lib/routing/DOCUMENTATION.md +150 -41
  155. package/server/lib/routing/classifier.js +156 -0
  156. package/server/lib/routing/defaults.js +27 -0
  157. package/server/lib/routing/jev.js +5 -17
  158. package/server/lib/routing/routes.http.test.js +9 -0
  159. package/server/lib/routing/routes.js +27 -1
  160. package/server/lib/routing/runtime.js +199 -33
  161. package/server/lib/routing/runtime.test.js +299 -15
  162. package/server/lib/routing/store.js +57 -0
  163. package/server/lib/routing/store.test.js +37 -0
  164. package/server/lib/session-assist/DOCUMENTATION.md +17 -7
  165. package/server/lib/session-assist/context.js +42 -2
  166. package/server/lib/session-assist/context.test.js +38 -1
  167. package/server/lib/session-assist/runtime.js +57 -13
  168. package/server/lib/session-assist/runtime.test.js +45 -0
  169. package/server/lib/session-goal/DOCUMENTATION.md +47 -22
  170. package/server/lib/session-goal/audit.js +112 -0
  171. package/server/lib/session-goal/audit.test.js +58 -0
  172. package/server/lib/session-goal/runtime.js +113 -134
  173. package/server/lib/session-goal/runtime.test.js +146 -13
  174. package/server/lib/session-lineage.js +52 -0
  175. package/server/lib/session-lineage.test.js +45 -0
  176. package/server/lib/session-work/DOCUMENTATION.md +108 -0
  177. package/server/lib/session-work/questions.js +126 -0
  178. package/server/lib/session-work/runtime.js +278 -0
  179. package/server/lib/session-work/runtime.test.js +255 -0
  180. package/server/lib/session-work/state.js +48 -0
  181. package/server/lib/session-work/state.test.js +34 -0
  182. package/server/lib/small-model/DOCUMENTATION.md +14 -7
  183. package/server/lib/small-model/client.js +7 -4
  184. package/server/lib/small-model/index.js +11 -21
  185. package/server/lib/small-model/index.test.js +13 -26
  186. package/server/lib/spaces/DOCUMENTATION.md +79 -25
  187. package/server/lib/spaces/gatekeeper-channel.js +63 -11
  188. package/server/lib/spaces/gatekeeper-channel.test.js +34 -4
  189. package/server/lib/spaces/gatekeeper-program.cjs +64 -13
  190. package/server/lib/spaces/gatekeeper-program.test.js +115 -3
  191. package/server/lib/spaces/host.js +58 -13
  192. package/server/lib/spaces/host.test.js +34 -1
  193. package/server/lib/spaces/idle-stop.js +98 -0
  194. package/server/lib/spaces/idle-stop.test.js +130 -0
  195. package/server/lib/spaces/journey.js +427 -17
  196. package/server/lib/spaces/journey.test.js +592 -5
  197. package/server/lib/spaces/layout.js +27 -6
  198. package/server/lib/spaces/manager.test.js +1 -1
  199. package/server/lib/spaces/places/contract-suite.js +4 -2
  200. package/server/lib/spaces/places/docker-live-support.js +27 -4
  201. package/server/lib/spaces/places/docker.js +32 -5
  202. package/server/lib/spaces/places/docker.test.js +38 -8
  203. package/server/lib/spaces/places/escape-suite.js +32 -0
  204. package/server/lib/spaces/places/fake-docker.js +3 -1
  205. package/server/lib/spaces/places/grants.docker.live.test.js +197 -0
  206. package/server/lib/spaces/places/memory-place.js +3 -3
  207. package/server/lib/spaces/places/sessions.docker.live.test.js +4 -2
  208. package/server/lib/spaces/routes.js +49 -1
  209. package/server/lib/spaces/routes.test.js +31 -3
  210. package/server/lib/spaces/space-opencode.js +52 -0
  211. package/server/lib/spaces/space-opencode.test.js +41 -0
  212. package/server/lib/spaces/space-records.js +90 -2
  213. package/server/lib/spaces/space-records.test.js +58 -1
  214. package/server/lib/spaces/space-server.js +13 -1
  215. package/server/lib/spaces/space-server.test.js +13 -0
  216. package/server/lib/spaces/space-setup.js +173 -0
  217. package/server/lib/spaces/space-setup.test.js +174 -0
  218. package/server/lib/tts/DOCUMENTATION.md +3 -0
  219. package/server/lib/tts/base-url.js +8 -0
  220. package/server/lib/tts/routes.js +13 -1
  221. package/server/lib/tts/routes.test.js +26 -0
  222. package/server/lib/tunnels/DOCUMENTATION.md +2 -0
  223. package/server/lib/tunnels/routes.js +14 -0
  224. package/server/lib/tunnels/routes.test.js +26 -0
  225. package/server/lib/walkthrough/index.js +11 -7
  226. package/server/lib/walkthrough/jobs.test.js +8 -0
  227. package/server/lib/walkthrough/languages.js +1 -0
  228. package/server/lib/walkthrough/routes.js +7 -1
  229. package/dist/assets/FilesView-0Ie20mEk.js +0 -17
  230. package/dist/assets/LinearIssuesView-CSl2MUfA.js +0 -1
  231. package/dist/assets/MarkdownRendererImpl-DVHqZoug.js +0 -12
  232. package/dist/assets/OnboardingScreen-CIdXJpfc.js +0 -1
  233. package/dist/assets/PlanView-DEIi3Q7M.js +0 -5
  234. package/dist/assets/PluginPane-BEPUWVho.js +0 -3
  235. package/dist/assets/SettingsView-CiNh-RbW.js +0 -30
  236. package/dist/assets/WalkthroughView-6oE-MuDL.js +0 -4
  237. package/dist/assets/de-CgAJ51z7.js +0 -10
  238. package/dist/assets/es-zGi_ravM.js +0 -16
  239. package/dist/assets/fr-CPfogrWx.js +0 -14
  240. package/dist/assets/index-CHfphYL3.js +0 -41
  241. package/dist/assets/index-DvMJ3w6V.css +0 -1
  242. package/dist/assets/ja-DMk6wd-U.js +0 -16
  243. package/dist/assets/ko-BFpzJ8jc.js +0 -16
  244. package/dist/assets/main-anyZFMIs.js +0 -896
  245. package/dist/assets/markdownCore-CmM47cAE.js +0 -7
  246. package/dist/assets/pl-VdRPcZrB.js +0 -16
  247. package/dist/assets/pt-BR-BRys_lOW.js +0 -16
  248. package/dist/assets/renderElectronMiniChatApp-C5677jy0.js +0 -2
  249. package/dist/assets/renderMobileApp-D4dBBAqQ.js +0 -25
  250. package/dist/assets/runtimeEndpointReset-5r0hkd-2.js +0 -27
  251. package/dist/assets/tr-CA9ckNnm.js +0 -7
  252. package/dist/assets/uk-byjR-y8D.js +0 -16
  253. package/dist/assets/useAppFontEffects-BWQZ5DeI.js +0 -7341
  254. package/dist/assets/useInlineCommentController-DlFyVfBu.js +0 -2
  255. package/dist/assets/vendor-opencode-client-DYdsLbCM.js +0 -12
  256. package/dist/assets/zh-CN-DRabgxdG.js +0 -16
  257. package/dist/assets/zh-TW-rbY5c9UK.js +0 -16
@@ -0,0 +1,25 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesView-CN34wm_N.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-CgR5rJq_.js","assets/vendor-zod-CxRSdNoV.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-DSZl7jSi.js","assets/index-adyy_sEk.css","assets/useAppFontEffects-Dsl_sLrj.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-base-ui-DnNniUWp.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-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--0sBrLRh.js","assets/vendor-tanstack-virtual-core-BoA4iGMw.js","assets/vendor-framer-motion-Bq3iTZ6r.js","assets/vendor-motion-dom-DcCgeG69.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/contextPanelEmbeddedChat-CirXEPJq.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BgPj_McA.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-DzPz9Wgq.js","assets/vendor-codemirror-lang-json-CMBS2tG9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-O0cZX78y.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CfgK872x.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-BPGOH9ye.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-B1EetJur.js","assets/vendor-codemirror-lang-python-HahnQaAS.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-B7H_j0iU.js","assets/vendor-legendapp-list-BuBPBC3R.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/runtimeEndpointReset-uu1DBwLL.js","assets/GuestAttachDialog-C0xe_Lyy.js","assets/PluginPane-2C71F8uF.js","assets/shikiHighlight-BWGrY5YU.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-B1Xq-k2t.js","assets/web-components-ngpHPEDU.js","assets/computeVirtualFileMetrics-6V1xNpO9.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-CBAppvy1.js","assets/appThemeRegistry-BdEHBA4s.js","assets/textMateThemeFromAppTheme-BSUFChBY.js","assets/Virtualizer-D_a8gKmg.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/scheduledTasksApi-BuzWT445.js","assets/useInlineCommentController-d5vntsQ_.js","assets/CodeMirrorCommentWidgets-C_zL-eri.js","assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/vendor-capacitor-push-notifications-KNe1zSBF.js"])))=>i.map(i=>d[i]);
2
+ import{f as me,r as Pn,j as t,R as f,c as is,h as ha}from"./vendor-react-BUCujlKS.js";import"./vendor-katex-CHD9BdDO.js";import{u as $e,a as ds,b as Bi,d as Ur,i as We,e as mt,s as Qt,f as Es,h as Fn,j as ga,k as Li,l as ba,p as xa,m as ya,n as Nt,o as va,q as qt,t as wa,v as Gr,x as wn,G as Kr,y as ja,z as qr,A as $i,B as Hr,C as Jr,D as Yr,M as Ws,E as ka,F as Sa}from"./index-CgR5rJq_.js";import{u as ss,a as Na,b as Qe,c as Tn,d as Fi,r as Wn,e as Ca,f as be,t as ve,o as Ra,I as Y,B as ke,g as Wi,O as Zt,h as X,P as Vi,i as Ea,j as Ia,k as Aa,l as nt,m as Pa,n as Pt,p as Ta,q as Xr,s as Da,v as _a,w as Vn,x as Ma,y as za,z as De,A as Oa,C as Un,D as Gn,E as Kn,F as Ba,S as Ys,G as qn,H as La,J as Ui,K as Xe,L as Gi,M as $a,N as Fa,Q as Wa,R as Ki,T as qi,U as Hi,V as Ji,W as Yi,X as Xi,Y as Va,Z as Ua,_ as Qr,$ as Qi,a0 as Zi,a1 as eo,a2 as Ga,a3 as Ka,a4 as Hn,a5 as qa,a6 as Ha,a7 as Ja,a8 as Ya,a9 as jn,aa as Xa,ab as gs,ac as Ht,ad as Zr,ae as to,af as Qa,ag as Za,ah as rn,ai as so,aj as no,ak as el,al as tl,am as ws,an as ns,ao as sl,ap as nl,aq as rl,ar as il,as as Jn,at as ol,au as al,av as ll,aw as cl,ax as ul,ay as dl,az as fl,aA as ml,aB as ei,aC as pl,aD as hl,aE as gl,aF as bl,aG as xl,aH as Vs,aI as yl,aJ as vl,aK as ro,aL as qe,aM as wl,aN as jl,aO as kl,aP as Sl,aQ as Yn,aR as Nl,aS as Cl,aT as Rl,aU as El,aV as Il,aW as Al,aX as Pl,aY as io,aZ as Tl,a_ as Dl,a$ as _l,b0 as Ml,b1 as zl,b2 as Ol,b3 as Bl,b4 as Ll,b5 as $l,b6 as Fl,b7 as Wl,b8 as Vl,b9 as Ul,ba as Gl,bb as Kl,bc as ql,bd as Hl,be as Jl,bf as Yl,bg as Xl,bh as Ql,bi as Zl,bj as ec,bk as tc,bl as sc,bm as nc,bn as rc,bo as ic,bp as oc,bq as ac}from"./useAppFontEffects-Dsl_sLrj.js";import{u as es,S as Xn,a as lc,b as cc,h as uc,c as oo,d as ao,C as lo,s as dc,g as Us,p as fc,e as mc,f as pc,r as ti,i as hc,j as gc,D as bc,N as xc,k as yc,l as vc,m as wc,B as jc,n as kc,o as Sc,q as Nc,t as Cc,v as Rc,T as Ec,P as Ic,O as Ac,w as Pc,x as Tc,y as Dc,z as _c,A as Mc,E as zc,F as Oc,G as Bc,H as Lc,I as $c,J as Fc,K as Wc,L as Vc,M as Uc,Q as Gc,R as Kc,U as qc,V as Hc}from"./runtimeEndpointReset-uu1DBwLL.js";import{_ as os}from"./vendor-vite-runtime-DD1OZmLC.js";import{S as Jc,A as Yc}from"./SettingsView-m_zoFiaT.js";import{PlanView as Xc}from"./PlanView-B7Xgihqk.js";import{p as Qc}from"./vendor-aparajita-capacitor-secure-storage-5IShChL0.js";import{Capacitor as Zc}from"./vendor-capacitor-core-B4EWRrHz.js";import{k as Dn,d as eu,M as Xs,J as _n,s as co,a as Qn,p as tu,_ as si,f as Zn,V as su,K as ni,P as nu,b as ru,c as iu,U as ou,Z as au,Q as lu,r as cu}from"./vendor-remixicon-react-D6dZ0UwF.js";import{f as er,h as as,i as tr,P as sr,D as nr,j as rr}from"./vendor-dnd-kit-core-BZknOX2w.js";import{s as ir,S as or,v as ar,u as lr}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as cr}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{c as ur,p as uo}from"./vendor-zustand-BAGL70zf.js";import{toast as Mn}from"./vendor-sonner-DFyL3AvE.js";import{C as uu,a as du,D as fu,p as ri}from"./commitAndPush-LwtVa2Oc.js";import{u as mu,a as pu,b as hu,c as gu,i as bu,f as xu,B as yu,C as vu,P as ii}from"./patchFileDiff-pqRSHLHI.js";import{u as wu,a as ju,i as ku,S as Su,b as Nu}from"./SubmoduleDiffSummary-BSA9gnIO.js";import{P as Cu}from"./PierreDiffViewer-BC950e3F.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-CxRSdNoV.js";import"./vendor-opencode-client-DSZl7jSi.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-base-ui-DnNniUWp.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-tanstack-react-virtual--0sBrLRh.js";import"./vendor-tanstack-virtual-core-BoA4iGMw.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-B1EetJur.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./GuestAttachDialog-C0xe_Lyy.js";import"./PluginPane-2C71F8uF.js";import"./vendor-yaml-3778uTud.js";import"./shikiHighlight-BWGrY5YU.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./appThemeRegistry-BdEHBA4s.js";import"./textMateThemeFromAppTheme-BSUFChBY.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-qrcode-DTJ12-WC.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./vendor-strip-json-comments-5dJlOkP1.js";import"./useInlineCommentController-d5vntsQ_.js";import"./CodeMirrorCommentWidgets-C_zL-eri.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./changesTree-CePHbFcj.js";import"./VirtualizedFileDiff-Kp8hKJdT.js";import"./web-components-ngpHPEDU.js";import"./computeVirtualFileMetrics-6V1xNpO9.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-1bXcWCrw.js";import"./vendor-diff-C3JhlQdm.js";import"./Virtualizer-D_a8gKmg.js";let fo=null,oi=!1;const Ru=new Promise(n=>{fo=n});function Eu(){oi||(oi=!0,fo?.())}const Iu=6,Au=n=>n.parentID??null,ai=n=>{const e=n.replace(/\/+$/,"");return e.slice(e.lastIndexOf("/")+1)||e},Pu=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),Tu=(n,e)=>{if(!n)return"";let s=null,i=-1;for(const r of e){const o=Pu(r.path);(n===o||n.startsWith(`${o}/`))&&o.length>i&&(s=r,i=o.length)}return s?s.label?.trim()||ai(s.path):ai(n)},Du=()=>{const n=ss.getState().activeSessions,e=Na.getState().index.session.unseenCount,s=$e.getState().notifyOnSubtasks,i=Qe.getState().projects,r=Tn.getState().ids,o=Fi.getState().rankById;let l=0;const c=[];for(const a of n){const u=Au(a)!==null,g=(e[a.id]??0)>0&&(!u||s);g&&(l+=1),u||c.push({session:a,unread:g,project:Tu(Wn(a),i)})}c.sort((a,u)=>Ca(a.session,u.session,r,o));const m=c.slice(0,Iu).map(({session:a,unread:u,project:p})=>({id:a.id,title:a.title??"",unread:u,project:p}));return{runtimeKey:ds(),attentionCount:l,recentSessions:m}},_u="__OPENCHAMBER_WIDGET_SNAPSHOT__",Mu=()=>{typeof window>"u"||(window[_u]=()=>{try{return JSON.stringify(Du())}catch{return null}})},kn="mobile-app-update-available",li="mobile-app-update-toast-dismissed-version",zu=()=>{const n=me.c(8),{t:e}=be(),s=es(Ou),i=es(Bu),r=es(Lu),o=es($u);let l;n[0]===Symbol.for("react.memo_cache_sentinel")?(l=new Set,n[0]=l):l=n[0];const c=Pn.useRef(l);let m,a;return n[1]!==s||n[2]!==o||n[3]!==i||n[4]!==e||n[5]!==r?(m=()=>{if(Bi()!=="android"||i!=="mobile"||!s||!r||!o){ve.dismiss(kn);return}Ur().getItem(li)!==r&&(c.current.has(r)||(c.current.add(r),ve.info(e("mobileUpdate.toast.available.title"),{id:kn,description:e("mobileUpdate.toast.available.description",{version:r}),duration:1/0,icon:t.jsx(Y,{name:"download",className:"h-4 w-4 text-muted-foreground"}),action:{label:e("mobileUpdate.toast.actions.download"),onClick:()=>{Ra(o)}},cancel:{label:e("mobileUpdate.toast.actions.dismiss"),onClick:()=>{Ur().setItem(li,r),ve.dismiss(kn)}}})))},a=[s,o,i,e,r],n[1]=s,n[2]=o,n[3]=i,n[4]=e,n[5]=r,n[6]=m,n[7]=a):(m=n[6],a=n[7]),Pn.useEffect(m,a),null};function Ou(n){return n.available}function Bu(n){return n.runtimeType}function Lu(n){return n.info?.version}function $u(n){return n.info?.downloadUrl}const ci=300,Fu="openchamber.mobile.connectLog.v1",ts=[];if(typeof window<"u")try{window.localStorage.removeItem(Fu)}catch{}const dr=(n,e)=>{ts.push({at:Date.now(),step:n,detail:e}),ts.length>ci&&ts.splice(0,ts.length-ci)};typeof window<"u"&&dr("app:launch","{}");const Wu=()=>[...ts],Vu=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)}`},mo=n=>`${Vu(n.at)} ${n.step}${n.detail&&n.detail!=="{}"?` ${n.detail}`:""}`,Uu=()=>ts.map(mo).join(`
3
+ `),po=(n,e)=>{const s=me.c(10),i=700,r=f.useRef(null),o=f.useRef(null),l=f.useRef(!1);let c;s[0]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{r.current!==null&&window.clearTimeout(r.current),r.current=null,o.current=null},s[0]=c):c=s[0];const m=c;let a,u;s[1]===Symbol.for("react.memo_cache_sentinel")?(a=()=>m,u=[m],s[1]=a,s[2]=u):(a=s[1],u=s[2]),f.useEffect(a,u);let p;s[3]!==i||s[4]!==n?(p=v=>{l.current=!1,o.current={x:v.clientX,y:v.clientY},r.current!==null&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{r.current=null,l.current=!0,n()},i)},s[3]=i,s[4]=n,s[5]=p):p=s[5];const g=p;let h;s[6]===Symbol.for("react.memo_cache_sentinel")?(h=v=>{const C=o.current;C&&(Math.abs(v.clientX-C.x)>10||Math.abs(v.clientY-C.y)>10)&&m()},s[6]=h):h=s[6];const b=h;let S;s[7]===Symbol.for("react.memo_cache_sentinel")?(S=v=>{l.current&&(l.current=!1,v.preventDefault(),v.stopPropagation())},s[7]=S):S=s[7];const y=S;let I;return s[8]!==g?(I={onPointerDown:g,onPointerMove:b,onPointerUp:m,onPointerCancel:m,onClickCapture:y},s[8]=g,s[9]=I):I=s[9],I},Qs="openchamber.mobile.connections.v1",Gu="openchamber.mobile.",ui="openchamber.mobile.deviceId",Ku=()=>{try{const n=window.localStorage.getItem(ui);if(n&&n.trim())return n.trim();const e=crypto.randomUUID();return window.localStorage.setItem(ui,e),e}catch{return crypto.randomUUID()}},di=()=>`mobile:${Ku()}`,fi=()=>{try{const n=Zc.getPlatform();return n==="ios"||n==="android"?n:void 0}catch{return}},ho=12,go=8e3,qu=2500,Hu=3e3,Zs=2500,Ju=()=>{let n=0;return{begin:()=>(n+=1,n),cancel:()=>{n+=1},isCurrent:e=>e===n}},fs=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(/\/+$/,"")},qs=n=>{try{return new URL(n).host}catch{return n}},ls=n=>{try{return fs(n)}catch{return n.trim().replace(/\/+$/g,"")}},bo=(n,e)=>ls(n)===ls(e),xo=n=>`relay:${n.serverId}@${n.relayUrl.trim()}`,Yu=n=>`relay://${n.serverId}`,on=n=>n.candidates.filter(e=>e.kind==="direct"),_t=n=>{const e=n.candidates.find(s=>s.kind==="relay");return e&&e.kind==="relay"?e.relay:null},wt=n=>{const e=on(n)[0];if(e)return e.url;const s=_t(n);return s?Yu(s):""},Le=n=>{const e=_t(n);if(e)return xo(e);const s=on(n)[0];return s?ls(s.url):""},en=(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=>ls(o.url)));return e.some(o=>o.kind==="relay"?i!==null&&o.relay.serverId===i:r.has(ls(o.url)))},fr=n=>{const e=(()=>{try{return fs(n)}catch{return""}})();return e?[{kind:"direct",url:e}]:[]},mi=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(...fr(n.url)),n.relay&&e.push({kind:"relay",relay:n.relay}),e},mr=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}}},yo=n=>{try{return JSON.stringify(n)}catch{return String(n)}},Ne=(n,e={})=>{const s=yo(e);console.info("[mobile-connect]",n,s),dr(n,s)},bs=(n,e={})=>{Ne(n,e)},cs=(n,e={})=>{const s=yo(e);console.info("[mobile-storage]",n,s),dr(n,s)},Xu=n=>{if(typeof n!="string")return n;try{return JSON.parse(n)}catch{return n}},Qu=n=>{if(typeof n!="string")return n??void 0;try{return JSON.parse(n)}catch{return n}},Zu=async(n,e)=>{if(!We())return null;try{const{CapacitorHttp:s}=await os(async()=>{const{CapacitorHttp:o}=await import("./vendor-capacitor-core-B4EWRrHz.js");return{CapacitorHttp:o}},[]),i=ba(n,new Headers(e?.headers)),r=await s.request({url:n,method:e?.method||"GET",headers:Object.fromEntries(i.entries()),data:Qu(e?.body)});return{ok:r.status>=200&&r.status<300,status:r.status,source:"native-http",json:async()=>Xu(r.data)}}catch(s){return Ne("native-http:failed",{url:n,error:s instanceof Error?s.message:String(s)}),null}},ed=async(n,e)=>{const s=await fetch(n,e).catch(i=>(Ne("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},Ct=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)}},Mt=async(n,e,s)=>{const i=s?.totalTimeoutMs??go,r=Date.now(),o=await Ct(Math.min(qu,i),Zu(n,e));if(o)return o;const l=new AbortController,c=Math.max(500,i-(Date.now()-r));return Ct(c,ed(n,{...e,signal:l.signal}),()=>l.abort())},an=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}},us=15e3,td=async(n,e,s,i=us,r)=>{const o=Li({relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk}),l=c=>c==="ok"&&r?.keepTunnel?{outcome:c,tunnel:o}:(o.close(),{outcome:c});try{const c=e?{Authorization:`Bearer ${e}`}:void 0,m=await Ct(i,o.fetch("/auth/session",{headers:c}).catch(()=>null));if(Ne("relay:session",{ok:m?.ok===!0,status:m?.status??null,hasToken:!!e}),!m)return l("unreachable");if(m.status===401)return l(e?"auth-failed":"needs-login");if(!m.ok&&m.status!==404)return l("auth-failed");const a=await an(m);return a&&a.disabled!==!0&&a.authenticated===!1?l(e?"auth-failed":"needs-login"):l("ok")}catch(c){throw o.close(),c}},sd=(n,e,s,i,r)=>{const o=typeof window<"u"?window.location.origin:"",l={relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk,...s?{grant:s}:{}};r&&ga(l,r),Qt({apiBaseUrl:o,clientToken:e,runtimeKey:i??xo(n),relay:l})},nd=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=mr(e.relay);return s?{kind:"relay",relay:s}:null}return null},rd=n=>{if(n.mode==="relay"){const e=mr(n.relay);return e?[{kind:"relay",relay:e}]:[]}return typeof n.url=="string"?fr(n.url):[]},zt=()=>{if(typeof window>"u")return[];let n;try{n=JSON.parse(window.localStorage.getItem(Qs)||"[]")}catch{return[]}if(!Array.isArray(n))return[];const e=We();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(nd).filter(m=>!!m):rd(i);if(r.length===0)return[];const o=typeof i.clientToken=="string"&&i.clientToken.trim()?i.clientToken:void 0,l=typeof i.label=="string"&&i.label.trim()?i.label:qs(wt({candidates:r})),c={id:i.id,label:l,candidates:r,lastUsedAt:typeof i.lastUsedAt=="number"?i.lastUsedAt:0};return e?[{...c,hasToken:!!i.hasToken||!!o}]:[{...c,clientToken:o,hasToken:!!o}]}).sort((s,i)=>i.lastUsedAt-s.lastUsedAt)},zn=n=>n.kind==="relay"?{kind:"relay",relay:{relayUrl:n.relay.relayUrl,serverId:n.relay.serverId,hostEncPubJwk:n.relay.hostEncPubJwk}}:{kind:"direct",url:n.url},pr=n=>{if(typeof window>"u")return;const e=We(),s=n.slice(0,ho).map(i=>{const r={id:i.id,label:i.label,candidates:i.candidates.map(zn),lastUsedAt:i.lastUsedAt};return e?{...r,hasToken:!!(i.hasToken||i.clientToken)}:{...r,clientToken:i.clientToken}});try{window.localStorage.setItem(Qs,JSON.stringify(s))}catch(i){console.warn("[mobile-storage] failed to persist connection metadata",i)}},vo=(n,e)=>{const s=n.find(o=>e.id&&o.id===e.id||en(o.candidates,e.candidates)),i=We(),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&&!en(o.candidates,e.candidates))].slice(0,ho)},hr=Qc,id=0,gr=n=>`${Gu}token.${encodeURIComponent(n)}`,od=async(n,e)=>{let s;const i=new Promise(r=>{s=window.setTimeout(()=>r(e),Hu)});try{return await Promise.race([n.catch(()=>e),i])}finally{s!==void 0&&window.clearTimeout(s)}},br=async(n,e,s)=>We()?od(e().catch(i=>(console.warn(`[mobile-storage] ${n} failed`,i),s)),s):s,Is=async n=>{cs("secure:read-start",{key:n});const e=await br("secure:read",async()=>(await hr.internalGetItem({prefixedKey:gr(n),sync:!1})).data,null),s=typeof e=="string"&&e.trim()?e:void 0;return cs("secure:read",{key:n,hasToken:!!s}),s},Tt=async(n,e)=>{cs("secure:write-start",{key:n});const s=await br("secure:write",async()=>(await hr.internalSetItem({prefixedKey:gr(n),data:e,sync:!1,access:id}),!0),!1);return cs("secure:write",{key:n,ok:s}),s},ad=async n=>{await br("secure:delete",async()=>(await hr.internalRemoveItem({prefixedKey:gr(n),sync:!1}),!0),!1)},ld=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 l=o,c=typeof l.url=="string"?l.url:null,m=typeof l.clientToken=="string"?l.clientToken.trim():"";if(!c||!m)return o;if(!await e(c,m))return i+=1,o;s+=1;const{clientToken:a,...u}=l;return{...u,hasToken:!0}})),migrated:s,failed:i}},wo=async()=>{if(typeof window>"u"||!We())return;let n;try{n=JSON.parse(window.localStorage.getItem(Qs)||"[]")}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;cs("secure:migrate-start",{count:e.length});const s=await ld(n,async(i,r)=>{const o=ls(i);return await Tt(o,r)?await Is(o)===r:!1});if(s.migrated>0)try{window.localStorage.setItem(Qs,JSON.stringify(s.records))}catch(i){console.warn("[mobile-storage] failed to finalize secure token migration",i);return}cs("secure:migrate-done",{migrated:s.migrated,failed:s.failed})},cd=async()=>(await wo(),zt()),tn=async n=>{const e=vo(zt(),n);return pr(e),We()&&n.clientToken&&await Tt(Le({candidates:n.candidates}),n.clientToken),e},ud=async n=>{const e=zt(),s=e.find(r=>r.id===n)??null,i=e.filter(r=>r.id!==n);return pr(i),s&&We()&&await ad(Le(s)),i},dd=1500,sn=async(n,e,s)=>{const i=s?.fast?{totalTimeoutMs:Zs}:void 0,r=_t({candidates:n})?.serverId??null,o=n.find(a=>a.kind==="relay")??null,l=n.filter(a=>a.kind==="direct"),c=async()=>{for(const a of l){const u=fs(a.url)||a.url,p=e?{Authorization:`Bearer ${e}`}:void 0,g=await Mt(`${u}/health`,{method:"GET"},i);if(Ne("probe:direct:health",{url:u,ok:g?.ok===!0,status:g?.status??null,source:g?.source??null}),!g?.ok)continue;if(r){const y=await g.json().catch(()=>null),I=y&&typeof y=="object"?y.serverId:null;if(typeof I=="string"&&I&&I!==r){Ne("probe:server-id-mismatch",{url:u});continue}}const h=await Mt(`${u}/auth/session`,{method:"GET",credentials:e?"omit":"include",headers:p},i);if(Ne("probe:direct:session",{url:u,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 b=await an(h);if(b&&b.disabled!==!0&&b.authenticated===!1)return{status:"needs-login"};const S=b?.disabled===!0;return!e&&We()&&!S&&b?.scope!=="client"?{status:"needs-login"}:{status:"ok",transport:{kind:"direct",url:u}}}return{status:"unreachable"}},m=async()=>{if(!o)return{status:"unreachable"};const{outcome:a,tunnel:u}=await td(o.relay,e,void 0,s?.fast?Zs:go,{keepTunnel:!0});return a==="ok"?{status:"ok",transport:{kind:"relay",relay:o.relay,tunnel:u}}:a==="needs-login"||a==="auth-failed"?{status:"needs-login"}:{status:"unreachable"}};return o?l.length===0?m():new Promise(a=>{let u=!1,p=!1,g,h=null,b=null;const S=v=>{v?.status==="ok"&&v.transport.kind==="relay"&&v.transport.tunnel?.close()},y=v=>{u||(u=!0,a(v))},I=()=>{p||u||(g!==void 0&&(window.clearTimeout(g),g=void 0),m().then(v=>{if(b=v,u||p){S(v);return}if(v.status==="ok"||v.status==="needs-login"){y(v);return}h&&y(h)}))};c().then(v=>{if(h=v,!u){if(v.status==="ok"||v.status==="needs-login"){p=!0,g!==void 0&&window.clearTimeout(g),S(b),y(v);return}if(b){y(b);return}I()}}),g=window.setTimeout(I,dd)}):c()},Dt=(n,e,s)=>{n.kind==="relay"?sd(n.relay,e,s?.grant,s?.runtimeKey,n.tunnel):Qt({apiBaseUrl:n.url,clientToken:e,runtimeKey:s?.runtimeKey}),ko()},js=()=>{const n=zt()[0];return n?.label?.trim()?n.label:null},xs=async n=>{const e=n?.fast!==!1;await wo();const s=zt()[0];if(Ne("auto-connect:start",{hasCandidate:!!s,fast:e}),!s)return{status:"no-candidate"};let i;if(We()){if(s.hasToken&&(i=await Is(Le(s)),!i))return{status:"no-candidate"}}else if(i=s.clientToken,!i&&s.hasToken)return{status:"no-candidate"};const r=await sn(s.candidates,i,{fast:e});return Ne("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&&mt()?(r.transport.kind==="relay"&&r.transport.tunnel?.close(),Ne("auto-connect:superseded",{}),{status:"no-candidate"}):(await tn({id:s.id,label:s.label,candidates:s.candidates}),Dt(r.transport,i??null,{runtimeKey:Le(s)}),{status:"connected"})},fd=async(n,e)=>{let s="";try{s=fs(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:Zs}:void 0;if(!(await Mt(`${s}/health`,{method:"GET",headers:r},o))?.ok)return!1;const c=await Mt(`${s}/auth/session`,{method:"GET",credentials:i?"omit":"include",headers:r},o);if(!c||!c.ok&&c.status!==404)return!1;const m=await an(c);return!(m&&m.disabled!==!0&&m.authenticated===!1)},md=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=mr({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk});return s?[{kind:"relay",relay:s}]:[]}return fr(e.url)}),pi=async n=>{const e=_t({candidates:n})?.serverId??null;for(const s of n){if(s.kind==="relay"){const o=Li(s.relay),l=await Ct(us,o.fetch("/health").catch(()=>null));if(Ne("establish:relay:health",{ok:l?.ok===!0,status:l?.status??null}),l?.ok)return{kind:"relay",relay:s.relay,tunnel:o};o.close();continue}const i=fs(s.url)||s.url,r=await Mt(`${i}/health`,{method:"GET"});if(Ne("establish:direct:health",{ok:r?.ok===!0,status:r?.status??null}),!!r?.ok){if(e){const o=await r.json().catch(()=>null),l=o&&typeof o=="object"?o.serverId:null;if(typeof l=="string"&&l&&l!==e){Ne("establish:server-id-mismatch",{url:i});continue}}return{kind:"direct",url:i}}}return null},pd=async(n,e)=>{if(!Es())return fd(n,e);const s=await Ct(e?.fast?Zs:us,Fn("/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 an(s);return!(i&&i.disabled!==!0&&i.authenticated===!1)},hd=n=>n.kind==="relay"?Es():!Es()&&bo(n.url,mt()),jo=()=>{const n=ds();return n?zt().find(e=>Le(e)===n)??null:null},hi=n=>{const e=ds();return!!e&&Le(n)===e},Hs=async n=>{const e=n?.fast!==!1,s=jo();if(!s)return Ne("reprobe:no-connection",{runtimeKey:!!ds()}),"no-connection";let i;if(We()?i=s.hasToken?await Is(Le(s)):void 0:i=s.clientToken,!i&&s.hasToken)return Ne("reprobe:no-token",{hasToken:!0}),"unreachable";Ne("reprobe:start",{candidates:s.candidates.map(a=>a.kind),fast:e,hasToken:!!i});const r=s.candidates.findIndex(a=>hd(a.kind==="relay"?{kind:"relay",relay:a.relay}:{kind:"direct",url:a.url})),o=r>=0?s.candidates.slice(0,r):s.candidates,l=await sn(o,i,{fast:e});if(Ne("reprobe:better",{status:l.status,probed:o.length}),l.status==="ok")return await tn({id:s.id,label:s.label,candidates:s.candidates}),Dt(l.transport,i??null,{runtimeKey:Le(s)}),"switched";if(l.status==="needs-login")return"needs-login";if(r>=0){const a=await pd({url:mt(),clientToken:i},{fast:e});if(Ne("reprobe:current",{stillValid:a}),a)return ko(),"unchanged"}const c=r>=0?s.candidates.slice(r+1):[],m=await sn(c,i,{fast:e});return Ne("reprobe:fallback",{status:m.status,probed:c.length}),m.status==="ok"?(await tn({id:s.id,label:s.label,candidates:s.candidates}),Dt(m.transport,i??null,{runtimeKey:Le(s)}),"switched"):m.status==="needs-login"?"needs-login":"unreachable"},gd=5e3;let Sn=!1;const bd=async()=>{if(Sn)return"skipped";const n=jo();if(!n)return Ne("candidates:refresh-skip",{reason:"no-active-connection"}),"skipped";const e=_t(n);if(!e)return Ne("candidates:refresh-skip",{reason:"no-relay-candidate"}),"skipped";Sn=!0;try{const s=await Ct(us,Fn("/api/client-auth/connection/candidates").then(a=>a).catch(()=>null));if(!s?.ok)return Ne("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 Ne("candidates:refresh-skip",{reason:"server-id-mismatch"}),"skipped";const r=Array.isArray(i.candidates)?i.candidates:[],o=[];for(const a of r){if(!a||typeof a!="object")continue;const u=a;if(!(u.type!=="lan"||typeof u.url!="string"))try{const p=fs(u.url);p&&!o.includes(p)&&o.push(p)}catch{}}if(o.length===0)return Ne("candidates:refresh-skip",{reason:"no-lan-reported"}),"skipped";const l=on(n).filter(a=>a.url.startsWith("https://")),c=[...o.map(a=>({kind:"direct",url:a})),...l,{kind:"relay",relay:e}];return JSON.stringify(n.candidates.map(zn))===JSON.stringify(c.map(zn))?"unchanged":(Ne("candidates:refreshed",{lanCount:o.length}),await tn({id:n.id,label:n.label,candidates:c}),"updated")}finally{Sn=!1}},ko=()=>{typeof window>"u"||window.setTimeout(()=>{(async()=>{const n=await bd().catch(()=>"skipped");Ne("candidates:refresh-result",{result:n}),n==="updated"&&Es()&&await Hs().catch(()=>null)})()},gd)},So=n=>{const{t:e}=be(),[s,i]=f.useState(()=>zt()),[r,o]=f.useState(null),[l,c]=f.useState(null),[m,a]=f.useState(null),u=f.useRef(s),p=f.useRef(null),g=f.useRef(Ju()),h=f.useCallback(N=>{u.current=N,i(N)},[]),b=f.useCallback(N=>{p.current=N,o(N)},[]),S=f.useCallback(N=>{p.current===N&&(p.current=null,o(null))},[]);f.useEffect(()=>{let N=!1;return cd().then(R=>{N||h(R)}),()=>{N=!0}},[h]);const y=f.useCallback(N=>{const R=vo(u.current,N);return h(R),pr(R),R},[h]),I=f.useCallback(async N=>{c(null),b("connect");try{const R=mi(N);if(R.length===0){c(e("mobile.connect.error.urlRequired"));return}const k=N.id?u.current.find(V=>V.id===N.id):u.current.find(V=>en(V.candidates,R)),D=N.label?.trim()||k?.label||qs(wt({candidates:R})),z=N.relayGrant;let _=N.clientToken?.trim()||void 0;const j=!!_;_||(We()?k?.hasToken&&(_=await Is(Le({candidates:R}))):_=k?.clientToken),Ne("connect:start",{candidates:R.map(V=>V.kind),hasToken:!!_});const P=await sn(R,_);if(Ne("connect:probe",{status:P.status}),P.status==="unreachable"){c(e("mobile.connect.error.unreachable"));return}if(P.status==="needs-login"){y({id:k?.id,label:D,candidates:R}),a({id:k?.id??crypto.randomUUID(),label:D,candidates:R,relay:_t({candidates:R})??void 0,relayGrant:z});return}_&&j&&We()&&await Tt(Le({candidates:R}),_),y({id:k?.id,label:D,candidates:R,clientToken:_}),Dt(P.transport,_??null,{runtimeKey:Le({candidates:R}),grant:z}),n()}catch(R){console.warn("[mobile-connect] connect threw",R),c(e("mobile.connect.error.invalidUrl"))}finally{S("connect")}},[b,S,n,y,e]),v=f.useCallback(async N=>{if(p.current==="pairing")return;c(null),b("pairing");const R=md(N.candidates);let k=null,D=!1;try{if(k=await pi(R),!k){c(e("mobile.connect.error.unreachable"));return}const z=JSON.stringify({pairingId:N.pairingId,secret:N.secret,clientLabel:"OpenChamber Mobile",clientKind:"mobile",deviceName:"OpenChamber Mobile",devicePlatform:fi(),dedupeKey:di()}),_={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:z},j=k.kind==="relay"?await Ct(us,k.tunnel.fetch("/api/client-auth/pairing/redeem",_).catch(()=>null)):await Mt(`${k.url}/api/client-auth/pairing/redeem`,_);if(!j?.ok){c(e("mobile.connect.error.authRequired"));return}const P=await j.json().catch(()=>null),V=typeof P?.clientToken=="string"?P.clientToken.trim():"";if(!V){c(e("mobile.connect.error.authRequired"));return}const w=typeof P?.server?.label=="string"?P.server.label:"",U=N.label||w||qs(wt({candidates:R}));if(We()&&!await Tt(Le({candidates:R}),V)){c(e("mobile.connect.error.authRequired"));return}y({label:U,candidates:R,clientToken:V}),Dt(k.kind==="relay"?{kind:"relay",relay:k.relay,tunnel:k.tunnel}:{kind:"direct",url:k.url},V,{runtimeKey:Le({candidates:R})}),D=k.kind==="relay",n()}catch(z){console.warn("[mobile-connect] pairing threw",z),c(e("mobile.connect.error.authRequired"))}finally{!D&&k?.kind==="relay"&&k.tunnel.close(),S("pairing")}},[b,S,n,y,e]),C=f.useCallback(async N=>{if(!m||!N.trim()||p.current==="password")return;c(null),b("password");const R=g.current.begin(),k=()=>g.current.isCurrent(R),{id:D,label:z,candidates:_}=m;let j=null,P=!1;try{if(j=await pi(_),!k())return;if(!j){c(e("mobile.connect.error.unreachable"));return}const V={method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({password:N,trustDevice:!0,issueClientToken:!0,clientLabel:"OpenChamber Mobile",clientKind:"mobile",devicePlatform:fi(),dedupeKey:di()})};Ne("password:start",{transport:j.kind});const w=j.kind==="relay"?await Ct(us,j.tunnel.fetch("/auth/session",V).catch(()=>null)):await Mt(`${j.url}/auth/session`,V);if(!k())return;if(Ne("password:done",{ok:w?.ok===!0,status:w?.status??null}),!w?.ok){c(e("mobile.connect.error.passwordFailed"));return}const U=await w.json().catch(()=>null);if(!k())return;const F=typeof U?.clientToken=="string"?U.clientToken.trim():"";if(Ne("password:token",{issued:!!F}),!F){if(j.kind==="direct"&&!We()){y({id:D,label:z,candidates:_}),a(null),Dt({kind:"direct",url:j.url},null,{runtimeKey:Le({candidates:_})}),n();return}c(e("mobile.connect.error.authRequired"));return}if(We()&&(!k()||(await Tt(Le({candidates:_}),F),!k()))||!k()||(y({id:D,label:z,candidates:_,clientToken:F}),a(null),Dt(j.kind==="relay"?{kind:"relay",relay:j.relay,tunnel:j.tunnel}:{kind:"direct",url:j.url},F,{runtimeKey:Le({candidates:_})}),P=j.kind==="relay",!k()))return;n()}catch(V){if(!k())return;console.warn("[mobile-connect] password threw",V),c(e("mobile.connect.error.passwordFailed"))}finally{!P&&j?.kind==="relay"&&j.tunnel.close(),k()&&S("password")}},[b,S,n,m,y,e]),A=f.useCallback(()=>{g.current.cancel(),S("password"),a(null),c(null)},[S]),x=f.useCallback(async N=>{c(null);let R=mi(N);const k=N.id?u.current.find(j=>j.id===N.id)??null:null;if(k){const j=R.filter(w=>w.kind==="direct"),P=on(k).filter(w=>w.url.startsWith("https://")&&!j.some(U=>bo(U.url,w.url))),V=_t(k);R=[...j,...P,...V?[{kind:"relay",relay:V}]:[]]}if(R.length===0)return c(e("mobile.connect.error.urlRequired")),null;const D=N.clientToken?.trim()||void 0,z=N.label?.trim()||qs(wt({candidates:R}));if(We()){const j=Le({candidates:R});if(D)await Tt(j,D);else if(k?.hasToken){const P=Le(k);if(P&&j&&P!==j){const V=await Is(P);V&&await Tt(j,V)}}}return y({id:N.id,label:z,candidates:R,clientToken:D}).find(j=>en(j.candidates,R))??null},[y,e]),E=f.useCallback(async N=>{const R=u.current.find(D=>D.id===N)??null,k=await ud(N);return h(k),R},[h]);return{connections:s,isBusy:r!==null,isPasswordBusy:r==="password",error:l,pendingConnection:m,connect:I,redeemPairingConnection:v,submitPassword:C,cancelPassword:A,saveConnection:x,removeConnection:E,setError:c}},No=n=>{const e=me.c(31),{onClose:s}=n,{t:i}=be(),[r,o]=f.useState(!1);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=Wu(),e[0]=l):l=e[0];const c=l;let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{Wi(Uu()).then(N=>{N.ok&&(o(!0),window.setTimeout(()=>o(!1),2e3))})},e[1]=m):m=e[1];const a=m;let u;e[2]!==i?(u=i("mobile.connectionDebug.title"),e[2]=i,e[3]=u):u=e[3];let p;e[4]!==u?(p=t.jsx("h2",{className:"min-w-0 truncate typography-ui-label text-foreground",children:u}),e[4]=u,e[5]=p):p=e[5];const g=r?"check":"file-copy";let h;e[6]!==g?(h=t.jsx(Y,{name:g,className:"size-4"}),e[6]=g,e[7]=h):h=e[7];let b;e[8]!==r||e[9]!==i?(b=i(r?"mobile.connectionDebug.copied":"mobile.connectionDebug.copy"),e[8]=r,e[9]=i,e[10]=b):b=e[10];let S;e[11]!==h||e[12]!==b?(S=t.jsxs(ke,{type:"button",variant:"outline",size:"sm",onClick:a,disabled:c.length===0,children:[h,b]}),e[11]=h,e[12]=b,e[13]=S):S=e[13];let y;e[14]!==i?(y=i("mobile.connectionDebug.close"),e[14]=i,e[15]=y):y=e[15];let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(Y,{name:"close",className:"size-[18px]"}),e[16]=I):I=e[16];let v;e[17]!==s||e[18]!==y?(v=t.jsx(ke,{type:"button",variant:"ghost",size:"icon","aria-label":y,onClick:s,children:I}),e[17]=s,e[18]=y,e[19]=v):v=e[19];let C;e[20]!==v||e[21]!==S?(C=t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[S,v]}),e[20]=v,e[21]=S,e[22]=C):C=e[22];let A;e[23]!==C||e[24]!==p?(A=t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border/70 px-4 py-2.5",children:[p,C]}),e[23]=C,e[24]=p,e[25]=A):A=e[25];let x;e[26]!==i?(x=t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 py-3",children:c.length===0?t.jsx("p",{className:"typography-small text-muted-foreground",children:i("mobile.connectionDebug.empty")}):t.jsx("pre",{className:"whitespace-pre-wrap break-words typography-code text-muted-foreground",children:c.map(mo).join(`
4
+ `)})}),e[26]=i,e[27]=x):x=e[27];let E;return e[28]!==A||e[29]!==x?(E=t.jsxs("div",{className:"fixed inset-0 z-[70] flex flex-col bg-background pb-[var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))] pt-[var(--safe-area-inset-top,env(safe-area-inset-top,0px))] text-foreground",children:[A,x]}),e[28]=A,e[29]=x,e[30]=E):E=e[30],E},Co=()=>{if(typeof window>"u")return null;const e=window.Capacitor?.Plugins?.BarcodeScanner;return e&&(typeof e.scan=="function"||typeof e.startScan=="function")?e:null},xd=()=>window.Capacitor?.getPlatform?.()==="android",Ro=n=>{const e=n.trim();if(!e)return null;if(/^openchamber:\/\//i.test(e)){const s=xa(e);return s?{pairing:s}:null}return/^https?:\/\//i.test(e)?{url:e}:null},Eo=(n,e)=>{const s=Ro(n);if(!s&&e?.pairingStringFallback){const i=ya(n);if(i)return{status:"pairing",pairing:i}}return s?"pairing"in s?{status:"pairing",...s}:{status:"ok",...s}:{status:"invalid"}},yd=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 l=new Promise(a=>{o=a}),c=a=>{r||(r=!0,o(a))},m=()=>c({status:"cancelled"});e?.addEventListener("abort",m,{once:!0});try{return(await Promise.allSettled([Promise.resolve(n.addListener("barcodesScanned",({barcodes:u})=>{const p=u?.[0],g=(p?.rawValue??p?.displayValue??"").trim();g&&c(Eo(g,{pairingStringFallback:!0}))})).then(u=>{s=u}),Promise.resolve(n.addListener("scanError",()=>c({status:"failed"}))).then(u=>{i=u})])).some(({status:u})=>u==="rejected")?c({status:"failed"}):r||n.startScan({formats:["QR_CODE"]}).catch(()=>c({status:"failed"})),await l}finally{e?.removeEventListener("abort",m),await Promise.allSettled([Promise.resolve(s?.remove()),Promise.resolve(i?.remove()),n.stopScan()])}},On=()=>Co()!==null,Io=async n=>{const e=Co();if(!e)return{status:"unsupported"};try{if(e.requestPermissions){const l=(await e.requestPermissions())?.camera;if(l&&l!=="granted"&&l!=="limited")return{status:"permission-denied"}}if(n?.signal?.aborted)return{status:"cancelled"};if(xd())return yd(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?Eo(r):{status:"cancelled"}}catch{return{status:"failed"}}},rs={autoComplete:"off",autoCorrect:"off",spellCheck:!1},ks="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",Ao=n=>{const e=me.c(22),{onCancel:s}=n,{t:i}=be(),r=f.useRef(null);let o,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{const I={value:document.documentElement.style.getPropertyValue("background-color"),priority:document.documentElement.style.getPropertyPriority("background-color")},v={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 C=new Map,A=E=>{!(E instanceof HTMLElement)||E===r.current||C.has(E)||(C.set(E,{opacity:E.style.opacity,pointerEvents:E.style.pointerEvents}),E.style.setProperty("opacity","0"),E.style.setProperty("pointer-events","none"))};Array.from(document.body.children).forEach(A);const x=new MutationObserver(E=>{E.forEach(N=>N.addedNodes.forEach(A))});return x.observe(document.body,{childList:!0}),()=>{x.disconnect(),C.forEach(vd),I.value?document.documentElement.style.setProperty("background-color",I.value,I.priority):document.documentElement.style.removeProperty("background-color"),v.value?document.body.style.setProperty("background-color",v.value,v.priority):document.body.style.removeProperty("background-color")}},l=[],e[0]=o,e[1]=l):(o=e[0],l=e[1]),f.useLayoutEffect(o,l);let c,m;e[2]!==s?(c=()=>{const I=()=>{document.visibilityState==="hidden"&&s()};return document.addEventListener("visibilitychange",I),()=>document.removeEventListener("visibilitychange",I)},m=[s],e[2]=s,e[3]=c,e[4]=m):(c=e[3],m=e[4]),f.useEffect(c,m);let a;e[5]!==i?(a=i("mobile.connect.scanQr"),e[5]=i,e[6]=a):a=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=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]=u):u=e[7];let p;e[8]!==i?(p=i("mobile.connect.welcome.scanHint"),e[8]=i,e[9]=p):p=e[9];let g;e[10]!==p?(g=t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-6",children:[u,t.jsx("p",{className:"max-w-sm rounded-[16px] border border-border/60 bg-background px-4 py-3 text-center typography-body text-foreground shadow-sm",children:p})]}),e[10]=p,e[11]=g):g=e[11];let h;e[12]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(Y,{name:"close",className:"size-[18px]"}),e[12]=h):h=e[12];let b;e[13]!==i?(b=i("mobile.instances.cancelEdit"),e[13]=i,e[14]=b):b=e[14];let S;e[15]!==s||e[16]!==b?(S=t.jsxs(ke,{type:"button",variant:"outline",size:"lg",className:"mx-auto min-h-12 w-full max-w-sm bg-background",onClick:s,children:[h,b]}),e[15]=s,e[16]=b,e[17]=S):S=e[17];let y;return e[18]!==S||e[19]!==a||e[20]!==g?(y=is.createPortal(t.jsxs("div",{ref:r,role:"dialog","aria-modal":"true","aria-label":a,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:[g,S]}),document.body),e[18]=S,e[19]=a,e[20]=g,e[21]=y):y=e[21],y},Po=()=>{const n=me.c(6),{t:e}=be();let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx(Zt,{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(Y,{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=is.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 vd(n,e){e.style.opacity=n.opacity,e.style.pointerEvents=n.pointerEvents}const wd=({onConnected:n,notice:e=null})=>{const{t:s}=be(),i=So(n),{connections:r,isBusy:o,isPasswordBusy:l,error:c,pendingConnection:m}=i,[a,u]=f.useState(""),[p,g]=f.useState(""),[h,b]=f.useState(""),[S,y]=f.useState(!1),[I,v]=f.useState(!1),C=f.useRef(null),A=f.useMemo(()=>On(),[]),[x,E]=f.useState(()=>!On()),[N,R]=f.useState(null),[k,D]=f.useState(""),[z,_]=f.useState(!1),j=po(f.useCallback(()=>_(!0),[])),P=f.useCallback(B=>{B.preventDefault(),i.connect({url:a,clientToken:h,label:p})},[h,i,p,a]),V=f.useCallback(B=>{if(/^openchamber:\/\//i.test(B.trim())){const W=Ro(B);if(W){if("pairing"in W){i.redeemPairingConnection(W.pairing);return}u(W.url),W.label&&g(W.label),W.clientToken&&b(W.clientToken);return}}u(B)},[i]),w=f.useCallback(async()=>{if(C.current||o)return;i.setError(null),y(!0);const B=new AbortController;C.current=B;try{const W=await Io({signal:B.signal});switch(C.current===B&&(C.current=null,y(!1)),W.status){case"ok":v(!0),u(W.url),W.label&&g(W.label),W.clientToken&&b(W.clientToken),await i.connect({url:W.url,clientToken:W.clientToken,label:W.label});break;case"pairing":v(!0),await i.redeemPairingConnection(W.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{v(!1),C.current===B&&(C.current=null,y(!1))}},[i,o,s]);f.useEffect(()=>()=>C.current?.abort(),[]);const U=f.useCallback(B=>{B.preventDefault(),i.submitPassword(k)},[i,k]),F=f.useCallback(()=>{D(""),i.cancelPassword()},[i]);return t.jsxs(t.Fragment,{children:[S?t.jsx(Ao,{onCancel:()=>C.current?.abort()}):null,I?t.jsx(Po,{}):null,z?t.jsx(No,{onClose:()=>_(!1)}):null,t.jsx("main",{className:"oc-keyboard-fill-screen flex min-h-dvh flex-col overflow-y-auto bg-background px-6 pb-[calc(var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))+28px)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+28px)] text-foreground",children:t.jsxs("div",{className:"m-auto flex w-full max-w-[360px] shrink-0 flex-col items-center gap-9 py-8",children:[t.jsxs("div",{className:"flex flex-col items-center gap-5 text-center",children:[t.jsx("span",{...j,className:"select-none",style:{touchAction:"manipulation"},children:t.jsx(Zt,{width:72,height:72,className:"size-[72px]"})}),t.jsx("h1",{className:"typography-h2 text-foreground",children:s("mobile.connect.welcome.title")})]}),e?t.jsxs("div",{role:"status",className:"flex w-full items-center gap-3 rounded-[18px] border border-[color-mix(in_srgb,var(--status-warning)_35%,transparent)] bg-[color-mix(in_srgb,var(--status-warning)_10%,transparent)] px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-[color-mix(in_srgb,var(--status-warning)_16%,transparent)] text-[var(--status-warning)]",children:t.jsx(Y,{name:e.kind==="auth-expired"?"lock":"cloud-off",className:"size-[18px]"})}),t.jsx("p",{className:"min-w-0 flex-1 typography-small text-foreground",children:e.kind==="auth-expired"?s("mobile.connect.notice.authExpired",{label:e.label}):s("mobile.connect.notice.unreachable",{label:e.label})})]}):null,m?t.jsxs("form",{className:"flex w-full flex-col gap-3",onSubmit:U,children:[t.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(Y,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0 text-left",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:m.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:m.candidates.some(B=>B.kind==="direct")?wt(m):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...rs,value:k,onChange:B=>D(B.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:ks}),c?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:c}):null,t.jsx(ke,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:l||!k.trim(),children:s(l?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(ke,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:F,children:s("mobile.connect.cancelPassword")})]}):t.jsxs("div",{className:"flex w-full flex-col gap-6",children:[A?t.jsxs("div",{className:"flex w-full flex-col gap-2",children:[t.jsxs(ke,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{w()},disabled:S||o,children:[t.jsx(Y,{name:"scan-2",className:X("size-[18px]",S&&"animate-pulse")}),s(o?"mobile.connect.connecting":"mobile.connect.scanQr")]}),t.jsx("p",{className:"px-2 text-center typography-small text-muted-foreground",children:s("mobile.connect.welcome.scanHint")})]}):null,c&&!x?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:c}):null,r.length>0?t.jsxs("section",{className:"flex w-full flex-col gap-2.5",children:[t.jsx("h2",{className:"text-center typography-micro uppercase tracking-[0.14em] text-muted-foreground",children:s("mobile.connect.saved.title")}),t.jsx("div",{className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map(B=>{const W=N===B.id;return t.jsxs("button",{type:"button",disabled:o,className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3.5 py-2.5 text-left last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:opacity-70",onClick:()=>{R(B.id),i.connect({id:B.id,candidates:B.candidates,clientToken:B.clientToken,label:B.label}).finally(()=>R(null))},children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(Y,{name:"server",className:"size-[18px]"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:B.label}),t.jsx("span",{className:X("block truncate typography-small",W?"text-foreground":"text-muted-foreground"),children:W?s("mobile.connect.connecting"):B.candidates.some(Q=>Q.kind==="direct")?wt(B):s("mobile.connect.relay.badge")})]}),W?t.jsx(Y,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):t.jsx(Y,{name:"arrow-right-s",className:"size-5 text-muted-foreground"})]},B.id)})})]}):null,t.jsxs("div",{className:"flex w-full flex-col",children:[A?t.jsxs("button",{type:"button",onClick:()=>E(B=>!B),"aria-expanded":x,className:"mx-auto flex items-center gap-1 rounded-full px-2 py-1 typography-small text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[t.jsx("span",{children:s("mobile.connect.manual.toggle")}),t.jsx(Y,{name:"arrow-down-s",className:X("size-4 transition-transform duration-200",x&&"rotate-180")})]}):null,t.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:x?"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:P,children:[t.jsx("input",{...rs,value:a,onChange:B=>V(B.target.value),placeholder:s("mobile.connect.url.placeholder"),"aria-label":s("mobile.connect.url.label"),type:"url",inputMode:"url",autoCapitalize:"none",tabIndex:x?void 0:-1,className:X(ks,"text-center")}),t.jsx("input",{value:p,onChange:B=>g(B.target.value),placeholder:s("mobile.instances.label.placeholder"),"aria-label":s("mobile.instances.label.label"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,tabIndex:x?void 0:-1,className:X(ks,"text-center")}),t.jsx("input",{...rs,value:h,onChange:B=>b(B.target.value),placeholder:s("mobile.connect.token.placeholder"),"aria-label":s("mobile.connect.token.label"),tabIndex:x?void 0:-1,autoCapitalize:"none",className:X(ks,"text-center")}),t.jsx("p",{className:"px-1 text-center typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")}),c?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:c}):null,t.jsx(ke,{type:"submit",variant:A?"outline":"default",size:"lg",className:"h-12 w-full",disabled:o||S||!a.trim(),children:s(o?"mobile.connect.connecting":"mobile.connect.connectButton")})]})})})]})]})]})})]})},jd=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"},kd=n=>{const e=me.c(12),{groups:s,displayMode:i,timeFormatPreference:r,className:o}=n;let l;e[0]!==o?(l=X("space-y-1.5",o),e[0]=o,e[1]=l):l=e[1];let c;if(e[2]!==i||e[3]!==s||e[4]!==r){let a;e[6]!==i||e[7]!==r?(a=u=>t.jsxs("div",{className:"min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Vi,{providerId:u.providerId,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground",children:u.providerName}),u.planLabel?t.jsx("span",{className:"shrink-0 typography-micro capitalize text-muted-foreground",children:u.planLabel}):null,u.status&&u.rows.length===0?t.jsx("span",{className:"shrink-0 truncate typography-micro text-muted-foreground",children:u.status}):null]}),u.rows.length>0?t.jsx("div",{className:"mt-1.5 space-y-1",children:u.rows.map(p=>{const g=i==="remaining"?p.window.remainingPercent:p.window.usedPercent,h=Ea(p.window.valueLabel,g),b=Ia(p.window.resetAt,p.window.resetAfterFormatted??p.window.resetAtFormatted,r);return t.jsxs("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"shrink-0 truncate typography-ui-label text-muted-foreground",children:p.subtitle?`${p.subtitle} · ${p.label}`:p.label}),b?t.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/70",children:b}):null]}),t.jsx("span",{className:X("shrink-0 typography-ui-label font-semibold tabular-nums",jd(p.window)),children:h==="-"?"":h})]},p.key)})}):null,u.status&&u.rows.length>0?t.jsx("div",{className:"mt-1.5 typography-micro text-muted-foreground",children:u.status}):null]},u.providerId),e[6]=i,e[7]=r,e[8]=a):a=e[8],c=s.map(a),e[2]=i,e[3]=s,e[4]=r,e[5]=c}else c=e[5];let m;return e[9]!==l||e[10]!==c?(m=t.jsx("div",{className:l,children:c}),e[9]=l,e[10]=c,e[11]=m):m=e[11],m},gi=380,Sd=(n,e)=>{if(!n||typeof n!="object")return;const s=n[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0},Nn=n=>n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:String(n),Nd="—",To=n=>{const e=me.c(20),{percentage:s}=n;let i,r,o,l,c,m,a;if(e[0]!==s){o=Ma(s??0)??0;const h=za(s??0);r=h==="critical"?"var(--status-error)":h==="warn"?"var(--status-warning)":"var(--status-success)",i=2*Math.PI*7.5,l="0 0 18 18",c="size-[18px] -rotate-90",m="progressbar",a=s===null?void 0:Math.round(o),e[0]=s,e[1]=i,e[2]=r,e[3]=o,e[4]=l,e[5]=c,e[6]=m,e[7]=a}else i=e[1],r=e[2],o=e[3],l=e[4],c=e[5],m=e[6],a=e[7];let u;e[8]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),e[8]=u):u=e[8];let p;e[9]!==i||e[10]!==s||e[11]!==r||e[12]!==o?(p=s===null?null:t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:r,strokeWidth:3,strokeLinecap:"round",strokeDasharray:i,strokeDashoffset:i*(1-o/100),className:"transition-[stroke-dashoffset,stroke] duration-300"}),e[9]=i,e[10]=s,e[11]=r,e[12]=o,e[13]=p):p=e[13];let g;return e[14]!==l||e[15]!==c||e[16]!==m||e[17]!==a||e[18]!==p?(g=t.jsxs("svg",{viewBox:l,className:c,role:m,"aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":100,children:[u,p]}),e[14]=l,e[15]=c,e[16]=m,e[17]=a,e[18]=p,e[19]=g):g=e[19],g},Cd=n=>{const e=me.c(13),{icon:s,iconNode:i,label:r,children:o}=n;let l;e[0]!==s||e[1]!==i?(l=i??(s?t.jsx(Y,{name:s,className:"size-[18px]"}):null),e[0]=s,e[1]=i,e[2]=l):l=e[2];let c;e[3]!==l?(c=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:l}),e[3]=l,e[4]=c):c=e[4];let m;e[5]!==r?(m=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:r}),e[5]=r,e[6]=m):m=e[6];let a;e[7]!==o?(a=t.jsx("span",{className:"min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground",children:o}),e[7]=o,e[8]=a):a=e[8];let u;return e[9]!==c||e[10]!==m||e[11]!==a?(u=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5",children:[c,m,a]}),e[9]=c,e[10]=m,e[11]=a,e[12]=u):u=e[12],u},Rd=n=>{const e=me.c(57),{open:s,onClose:i,anchorRef:r,contextDisplay:o,usageGroups:l,usageDisplayMode:c,isUsageLoading:m,timeFormatPreference:a}=n,{t:u}=be(),p=f.useRef(null),[g,h]=f.useState(s),[b,S]=f.useState(!1),{enabled:y}=Vn(),I=f.useRef(null),[v,C]=f.useState(null);let A,x;e[0]!==r||e[1]!==y||e[2]!==s||e[3]!==g?(A=()=>{if(!s||!y||!g)return;const le=()=>{const ee=r.current?.getBoundingClientRect(),oe=I.current?.getBoundingClientRect();if(!ee||!oe){C(null);return}const H=ee.left-oe.left,ie=Math.min(Math.max(H,8),Math.max(8,oe.width-gi-8));C(ie)};le();const O=I.current;if(typeof ResizeObserver>"u"||!O)return;const Z=new ResizeObserver(le);return Z.observe(O),()=>Z.disconnect()},x=[r,y,s,g],e[0]=r,e[1]=y,e[2]=s,e[3]=g,e[4]=A,e[5]=x):(A=e[4],x=e[5]),f.useLayoutEffect(A,x);const E=y&&v!==null;let N,R;e[6]!==s||e[7]!==g?(N=()=>{if(s){h(!0),S(!1);return}if(!g)return;S(!0);const le=window.setTimeout(()=>{h(!1),S(!1)},140);return()=>window.clearTimeout(le)},R=[s,g],e[6]=s,e[7]=g,e[8]=N,e[9]=R):(N=e[8],R=e[9]),f.useEffect(N,R);let k,D;e[10]!==i||e[11]!==s?(k=()=>{if(!s)return;const le=O=>{O.key==="Escape"&&i()};return document.addEventListener("keydown",le),()=>document.removeEventListener("keydown",le)},D=[i,s],e[10]=i,e[11]=s,e[12]=k,e[13]=D):(k=e[12],D=e[13]),f.useEffect(k,D);let z,_;if(e[14]!==r||e[15]!==i||e[16]!==s?(z=()=>{if(!s)return;const le=O=>{const Z=O.target;if(!(Z instanceof Node)){i();return}p.current?.contains(Z)||r.current?.contains(Z)||i()};return document.addEventListener("pointerdown",le,!0),document.addEventListener("wheel",le,!0),()=>{document.removeEventListener("pointerdown",le,!0),document.removeEventListener("wheel",le,!0)}},_=[r,i,s],e[14]=r,e[15]=i,e[16]=s,e[17]=z,e[18]=_):(z=e[17],_=e[18]),f.useEffect(z,_),!g)return null;let j;e[19]!==u?(j=u("mobile.header.openMetadataAria"),e[19]=u,e[20]=j):j=e[20];const P=E?"absolute origin-top-left":"mx-3 mt-2",V=b?"pointer-events-none":"pointer-events-auto";let w;e[21]!==P||e[22]!==V?(w=X("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",P,V),e[21]=P,e[22]=V,e[23]=w):w=e[23];const U=`${b?"session-metadata-out":"session-metadata-in"} ${b?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let F;e[24]!==v||e[25]!==E?(F=E?{top:8,left:v??8,width:`min(${gi}px, calc(100% - 16px))`}:null,e[24]=v,e[25]=E,e[26]=F):F=e[26];let B;e[27]!==U||e[28]!==F?(B={animation:U,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...F},e[27]=U,e[28]=F,e[29]=B):B=e[29];let W;e[30]!==o||e[31]!==u?(W=o?t.jsx(Cd,{iconNode:t.jsx(To,{percentage:o.state==="measured"?o.percentage:null}),label:u("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:X("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]=u,e[32]=W):W=e[32];let Q;e[33]!==o?.state||e[34]!==u?(Q=o?.state==="compacted"?t.jsx("p",{className:"px-2.5 pb-1 typography-meta text-muted-foreground",children:u("contextUsage.compacted.description")}):null,e[33]=o?.state,e[34]=u,e[35]=Q):Q=e[35];let J;e[36]!==o?.state||e[37]!==u?(J=o?.state==="pending"?t.jsx("p",{className:"px-2.5 pb-1 typography-meta text-muted-foreground",children:u("mobile.header.metadata.contextPending")}):null,e[36]=o?.state,e[37]=u,e[38]=J):J=e[38];let $;e[39]!==m||e[40]!==a||e[41]!==c||e[42]!==l?($=t.jsx(Ed,{groups:l,displayMode:c,isLoading:m,timeFormatPreference:a}),e[39]=m,e[40]=a,e[41]=c,e[42]=l,e[43]=$):$=e[43];let te;e[44]!==W||e[45]!==Q||e[46]!==J||e[47]!==$?(te=t.jsxs("div",{className:"space-y-1",children:[W,Q,J,$]}),e[44]=W,e[45]=Q,e[46]=J,e[47]=$,e[48]=te):te=e[48];let fe;e[49]!==w||e[50]!==B||e[51]!==te||e[52]!==j?(fe=t.jsx("div",{ref:p,role:"dialog","aria-label":j,className:w,style:B,children:te}),e[49]=w,e[50]=B,e[51]=te,e[52]=j,e[53]=fe):fe=e[53];let ae;e[54]===Symbol.for("react.memo_cache_sentinel")?(ae=t.jsx("style",{children:`
5
+ @keyframes session-metadata-in {
6
+ from { opacity: 0; transform: translateY(-8px) scale(0.985); }
7
+ to { opacity: 1; transform: translateY(0) scale(1); }
8
+ }
9
+ @keyframes session-metadata-out {
10
+ from { opacity: 1; transform: translateY(0) scale(1); }
11
+ to { opacity: 0; transform: translateY(-6px) scale(0.985); }
12
+ }
13
+ `}),e[54]=ae):ae=e[54];let ne;return e[55]!==fe?(ne=t.jsxs("div",{ref:I,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:[fe,ae]}),e[55]=fe,e[56]=ne):ne=e[56],ne},Ed=n=>{const e=me.c(30),{groups:s,displayMode:i,isLoading:r,timeFormatPreference:o}=n,{t:l}=be();let c;e[0]!==i||e[1]!==l?(c=l(i==="remaining"?"header.services.remaining":"header.services.used"),e[0]=i,e[1]=l,e[2]=c):c=e[2];const m=c;if(s.length===0){if(!r)return null;let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(Y,{name:"loader-4",className:"size-4 animate-spin","aria-hidden":!0}),e[3]=v):v=e[3];let C;e[4]!==l?(C=l("common.loading"),e[4]=l,e[5]=C):C=e[5];let A;return e[6]!==C?(A=t.jsxs("div",{className:"flex items-center justify-center gap-2 px-2.5 py-6 text-muted-foreground",children:[v,t.jsx("span",{className:"typography-ui-label",children:C})]}),e[6]=C,e[7]=A):A=e[7],A}let a;e[8]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(Y,{name:"timer",className:"size-[18px]"})}),e[8]=a):a=e[8];let u;e[9]!==l?(u=l("mobile.header.metadata.usage"),e[9]=l,e[10]=u):u=e[10];let p;e[11]!==u?(p=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:u}),e[11]=u,e[12]=p):p=e[12];let g;e[13]!==r?(g=r?t.jsx(Y,{name:"refresh",className:"size-3.5 animate-spin"}):null,e[13]=r,e[14]=g):g=e[14];let h;e[15]!==m?(h=t.jsx("span",{className:"truncate",children:m}),e[15]=m,e[16]=h):h=e[16];let b;e[17]!==g||e[18]!==h?(b=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:[g,h]}),e[17]=g,e[18]=h,e[19]=b):b=e[19];let S;e[20]!==p||e[21]!==b?(S=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 px-2.5 pb-1.5",children:[a,p,b]}),e[20]=p,e[21]=b,e[22]=S):S=e[22];let y;e[23]!==i||e[24]!==s||e[25]!==o?(y=t.jsx(kd,{groups:s,displayMode:i,timeFormatPreference:o}),e[23]=i,e[24]=s,e[25]=o,e[26]=y):y=e[26];let I;return e[27]!==S||e[28]!==y?(I=t.jsxs("div",{className:"pt-2.5",children:[S,y]}),e[27]=S,e[28]=y,e[29]=I):I=e[29],I},Id=f.memo(function({open:e,onOpenChange:s,currentSessionId:i,effectiveDirectory:r,isNewSessionDraftOpen:o}){const{t:l}=be(),c=f.useRef(null),m=Aa(i??"",r||void 0),a=nt(w=>w.providers),u=nt(w=>w.currentProviderId),p=nt(w=>w.currentModelId),g=nt(w=>w.getModelMetadata);nt(w=>w.modelsMetadata.size);const h=Pa(f.useCallback(w=>i?w.sessionModelSelections.get(i)??null:null,[i])),b=Pt(w=>w.results),S=Pt(w=>w.refreshErrors),y=f.useRef(!1),I=Pt(w=>w.loadSettings),v=Pt(w=>w.fetchAllQuotas),C=Pt(w=>w.isLoading),A=Pt(w=>w.displayMode),x=Pt(w=>w.dropdownProviderIds),E=$e(w=>w.timeFormatPreference);Ta(),f.useEffect(()=>{I()},[I]),f.useEffect(()=>{Xr(x)},[x]),f.useEffect(()=>{if(!e){y.current=!1;return}y.current||C||!x.some(U=>!b.some(F=>F.providerId===U)||S[U])||(y.current=!0,v())},[x,v,C,e,b,S]);const R=f.useMemo(()=>{for(let w=m.length-1;w>=0;w-=1){const U=m[w];if(U.role!=="assistant")continue;const F=U.providerID.trim(),B=U.modelID.trim();if(F&&B)return{providerID:F,modelID:B}}return null},[m])??(h?{providerID:h.providerId,modelID:h.modelId}:null)??(u&&p?{providerID:u,modelID:p}:null),D=(R?a.find(w=>w.id===R.providerID):void 0)?.models.find(w=>w.id===R?.modelID),z=R?g(R.providerID,R.modelID):void 0,_=Sd(D?.limit,"context")??z?.limit?.context??0,j=f.useMemo(()=>Da(m),[m]),P=f.useMemo(()=>{if(_<=0)return null;if(o||!j)return{state:"pending"};if(j.state==="compacted")return{state:"compacted",tokens:`${Nd}/${Nn(_)}`};const w=Math.min(j.totalTokens/_*100,999),U=w>=90?"text-[var(--status-error)]":w>=75?"text-[var(--status-warning)]":"text-[var(--status-success)]";return{state:"measured",percentage:w,tokens:`${Nn(j.totalTokens)}/${Nn(_)}`,colorClass:U}},[j,_,o]),V=_a();return f.useEffect(()=>{!e||V.length===0||Xr(V.map(w=>w.providerId))},[e,V]),t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:c,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":l("mobile.header.openMetadataAria"),"aria-expanded":e,onClick:()=>s(w=>!w),style:{touchAction:"manipulation"},children:t.jsx(To,{percentage:P?.state==="measured"?P.percentage:P?.state==="compacted"?null:0})}),t.jsx(Rd,{open:e,onClose:()=>s(!1),anchorRef:c,contextDisplay:P,usageGroups:V,usageDisplayMode:A,isUsageLoading:C,timeFormatPreference:E})]})}),Ad=10,bi=380,Pd=(n,e)=>n.title?.trim()||e,Td=n=>{const e=me.c(33),{session:s,meta:i,active:r,onSelect:o}=n,{t:l}=be(),c=Un(s.id),m=Gn(s.id),a=!m&&c>0&&!r,u=Kn(s.id,m),p=(m||a)&&u,g=s.time?.updated??s.time?.created??0;let h;e[0]!==g?(h=Ba(g),e[0]=g,e[1]=h):h=e[1];const b=h,S=r&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let y;e[2]!==S?(y=X("flex w-full items-center gap-3 rounded-xl px-2.5 py-2 text-left transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",S),e[2]=S,e[3]=y):y=e[3];let I;e[4]===Symbol.for("react.memo_cache_sentinel")?(I={touchAction:"manipulation"},e[4]=I):I=e[4];const v=r?"text-primary":"text-foreground";let C;e[5]!==v?(C=X("block truncate typography-ui-label",v),e[5]=v,e[6]=C):C=e[6];let A;e[7]!==s||e[8]!==l?(A=Pd(s,l("sessions.sidebar.session.untitled")),e[7]=s,e[8]=l,e[9]=A):A=e[9];let x;e[10]!==C||e[11]!==A?(x=t.jsx("span",{className:C,children:A}),e[10]=C,e[11]=A,e[12]=x):x=e[12];let E;e[13]!==i?(E=i?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:i}):null,e[13]=i,e[14]=E):E=e[14];let N;e[15]!==E||e[16]!==x?(N=t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[x,E]}),e[15]=E,e[16]=x,e[17]=N):N=e[17];let R;e[18]!==m||e[19]!==a||e[20]!==l?(R=m||a?t.jsx(Ys,{state:m?"running":"unread",label:l(m?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread")}):null,e[18]=m,e[19]=a,e[20]=l,e[21]=R):R=e[21];let k;e[22]!==m||e[23]!==s.id||e[24]!==p||e[25]!==b?(k=p?t.jsx(Xn,{sessionId:s.id,running:m,className:"typography-micro"}):b?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:b}):null,e[22]=m,e[23]=s.id,e[24]=p,e[25]=b,e[26]=k):k=e[26];let D;return e[27]!==o||e[28]!==N||e[29]!==R||e[30]!==k||e[31]!==y?(D=t.jsxs("button",{type:"button",className:y,onClick:o,style:I,children:[N,R,k]}),e[27]=o,e[28]=N,e[29]=R,e[30]=k,e[31]=y,e[32]=D):D=e[32],D},Dd=n=>{const e=me.c(50),{open:s,onClose:i,anchorRef:r}=n,{t:o}=be(),l=f.useRef(null),[c,m]=f.useState(s),[a,u]=f.useState(!1),{enabled:p}=Vn(),g=f.useRef(null),[h,b]=f.useState(null);let S,y;e[0]!==r||e[1]!==p||e[2]!==s||e[3]!==c?(S=()=>{if(!s||!p||!c)return;const ne=()=>{const Z=r.current?.getBoundingClientRect(),ee=g.current?.getBoundingClientRect();if(!Z||!ee){b(null);return}const oe=Z.left-ee.left;b(Math.min(Math.max(oe,8),Math.max(8,ee.width-bi-8)))};ne();const le=g.current;if(typeof ResizeObserver>"u"||!le)return;const O=new ResizeObserver(ne);return O.observe(le),()=>O.disconnect()},y=[r,p,s,c],e[0]=r,e[1]=p,e[2]=s,e[3]=c,e[4]=S,e[5]=y):(S=e[4],y=e[5]),f.useLayoutEffect(S,y);const I=p&&h!==null,v=De(_d),C=De(Md),A=Qe(zd);let x;e[6]===Symbol.for("react.memo_cache_sentinel")?(x={maxParents:Ad},e[6]=x):x=e[6];const E=Oa(s||c,x);let N,R;e[7]!==s||e[8]!==c?(N=()=>{if(s){qn(),m(!0),u(!1);return}if(!c)return;u(!0);const ne=window.setTimeout(()=>{m(!1),u(!1)},140);return()=>window.clearTimeout(ne)},R=[s,c],e[7]=s,e[8]=c,e[9]=N,e[10]=R):(N=e[9],R=e[10]),f.useEffect(N,R);let k,D;e[11]!==i||e[12]!==s?(k=()=>{if(!s)return;const ne=le=>{le.key==="Escape"&&i()};return document.addEventListener("keydown",ne),()=>document.removeEventListener("keydown",ne)},D=[i,s],e[11]=i,e[12]=s,e[13]=k,e[14]=D):(k=e[13],D=e[14]),f.useEffect(k,D);let z,_;e[15]!==r||e[16]!==i||e[17]!==s?(z=()=>{if(!s)return;const ne=le=>{const O=le.target;if(!(O instanceof Node)){i();return}l.current?.contains(O)||r.current?.contains(O)||i()};return document.addEventListener("pointerdown",ne,!0),()=>document.removeEventListener("pointerdown",ne,!0)},_=[r,i,s],e[15]=r,e[16]=i,e[17]=s,e[18]=z,e[19]=_):(z=e[18],_=e[19]),f.useEffect(z,_);let j;e[20]!==i||e[21]!==C?(j=ne=>{C(ne.id,Wn(ne)),i()},e[20]=i,e[21]=C,e[22]=j):j=e[22];const P=j;if(!c)return null;let V;e[23]!==o?(V=o("sessions.switcher.openAria"),e[23]=o,e[24]=V):V=e[24];const w=I?"absolute origin-top-left":"mx-3 mt-2",U=a?"pointer-events-none":"pointer-events-auto";let F;e[25]!==w||e[26]!==U?(F=X("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",w,U),e[25]=w,e[26]=U,e[27]=F):F=e[27];const B=`${a?"session-switcher-out":"session-switcher-in"} ${a?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let W;e[28]!==h||e[29]!==I?(W=I?{top:8,left:h??8,width:`min(${bi}px, calc(100% - 16px))`}:null,e[28]=h,e[29]=I,e[30]=W):W=e[30];let Q;e[31]!==B||e[32]!==W?(Q={animation:B,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...W},e[31]=B,e[32]=W,e[33]=Q):Q=e[33];let J;e[34]!==v||e[35]!==P||e[36]!==E||e[37]!==A||e[38]!==o?(J=E.length===0?t.jsx("p",{className:"px-3 py-6 text-center typography-small text-muted-foreground",children:o("sessions.switcher.empty")}):E.map(ne=>{const le=ne.node.session,O=[ne.secondaryMeta?.projectLabel,ne.secondaryMeta?.branchLabel].filter(Boolean).join(" · ");return t.jsx(Td,{session:le,meta:O,active:le.id===v,onSelect:()=>{ne.projectId&&A(ne.projectId),P(le)}},le.id)}),e[34]=v,e[35]=P,e[36]=E,e[37]=A,e[38]=o,e[39]=J):J=e[39];let $;e[40]!==J?($=t.jsx("div",{className:"oc-hide-scrollbar min-h-0 flex-1 space-y-0.5 overflow-y-auto overscroll-contain",children:J}),e[40]=J,e[41]=$):$=e[41];let te;e[42]!==V||e[43]!==F||e[44]!==Q||e[45]!==$?(te=t.jsx("div",{ref:l,role:"dialog","aria-label":V,className:F,style:Q,children:$}),e[42]=V,e[43]=F,e[44]=Q,e[45]=$,e[46]=te):te=e[46];let fe;e[47]===Symbol.for("react.memo_cache_sentinel")?(fe=t.jsx("style",{children:`
14
+ @keyframes session-switcher-in {
15
+ from { opacity: 0; transform: translateY(-8px) scale(0.985); }
16
+ to { opacity: 1; transform: translateY(0) scale(1); }
17
+ }
18
+ @keyframes session-switcher-out {
19
+ from { opacity: 1; transform: translateY(0) scale(1); }
20
+ to { opacity: 0; transform: translateY(-6px) scale(0.985); }
21
+ }
22
+ `}),e[47]=fe):fe=e[47];let ae;return e[48]!==te?(ae=t.jsxs("div",{ref:g,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,fe]}),e[48]=te,e[49]=ae):ae=e[49],ae};function _d(n){return n.currentSessionId}function Md(n){return n.setCurrentSession}function zd(n){return n.setActiveProjectIdOnly}const Od=n=>{const e=me.c(84),{onOpenSessions:s,onOpenWorkspace:i,compactTitle:r}=n,o=r===void 0?!1:r,{t:l}=be(),[c,m]=f.useState(!1),[a,u]=f.useState(!1),p=f.useRef(null),g=Nt(Bd),h=De(Ld);let b;e[0]!==h?(b=Oe=>h?Oe.getDirectoryForSession(h):null,e[0]=h,e[1]=b):b=e[1];const y=De(b)||g,I=La(h,y||void 0),v=De($d),C=Ui(y||null);let A;e[2]!==y||e[3]!==C?(A=Oe=>{if(!y||C!==!0)return!1;const Me=Oe.directories.get(y)?.status;return!!(Me&&!Me.isClean)},e[2]=y,e[3]=C,e[4]=A):A=e[4];const x=Xe(A),E=$e(Fd),N=lc(E);let R;e[5]!==I?.title?(R=I?.title?.trim(),e[5]=I?.title,e[6]=R):R=e[6];const k=R;let D;e[7]!==h||e[8]!==E||e[9]!==N||e[10]!==k||e[11]!==l?(D=(E?N:null)||k||l(h?"mobile.sessions.untitled":"sessions.switcher.draftTitle"),e[7]=h,e[8]=E,e[9]=N,e[10]=k,e[11]=l,e[12]=D):D=e[12];const z=D;let _;e[13]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{m(!1),u(!1)},e[13]=_):_=e[13];let j;e[14]!==h||e[15]!==y?(j=[h,y],e[14]=h,e[15]=y,e[16]=j):j=e[16],f.useEffect(_,j);let P;e[17]!==s?(P=()=>{m(!1),u(!1),s()},e[17]=s,e[18]=P):P=e[18];const V=P;let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=Oe=>{m(Me=>{const it=typeof Oe=="function"?Oe(Me):Oe;return it&&u(!1),it})},e[19]=w):w=e[19];const U=w;let F;e[20]===Symbol.for("react.memo_cache_sentinel")?(F=()=>{u(Oe=>{const Me=!Oe;return Me&&m(!1),Me})},e[20]=F):F=e[20];const B=F;let W;e[21]===Symbol.for("react.memo_cache_sentinel")?(W={paddingTop:"var(--oc-safe-area-top, 0px)"},e[21]=W):W=e[21];let Q;e[22]!==l?(Q=l("mobile.sessions.openSheetAria"),e[22]=l,e[23]=Q):Q=e[23];let J,$;e[24]===Symbol.for("react.memo_cache_sentinel")?(J={touchAction:"manipulation"},$=t.jsx(Y,{name:"list-unordered",className:"size-5"}),e[24]=J,e[25]=$):(J=e[24],$=e[25]);let te;e[26]!==V||e[27]!==Q?(te=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":Q,onClick:V,style:J,children:$}),e[26]=V,e[27]=Q,e[28]=te):te=e[28];const fe=o?"shrink":"flex-1";let ae;e[29]!==fe?(ae=X("flex min-w-0 items-center rounded-lg px-2 py-1.5 text-left transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",fe),e[29]=fe,e[30]=ae):ae=e[30];let ne;e[31]!==l?(ne=l("sessions.switcher.openAria"),e[31]=l,e[32]=ne):ne=e[32];let le;e[33]===Symbol.for("react.memo_cache_sentinel")?(le={touchAction:"manipulation"},e[33]=le):le=e[33];let O;e[34]!==z?(O=t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",children:z}),e[34]=z,e[35]=O):O=e[35];const Z=a&&"rotate-180";let ee;e[36]!==Z?(ee=X("size-4 shrink-0 text-muted-foreground transition-transform duration-150",Z),e[36]=Z,e[37]=ee):ee=e[37];let oe;e[38]!==ee?(oe=t.jsx(Y,{name:"arrow-down-s",className:ee}),e[38]=ee,e[39]=oe):oe=e[39];let H;e[40]!==O||e[41]!==oe?(H=t.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[O,oe]}),e[40]=O,e[41]=oe,e[42]=H):H=e[42];let ie;e[43]!==a||e[44]!==ae||e[45]!==ne||e[46]!==H?(ie=t.jsx("button",{ref:p,type:"button",className:ae,"aria-label":ne,"aria-haspopup":"dialog","aria-expanded":a,onClick:B,style:le,children:H}),e[43]=a,e[44]=ae,e[45]=ne,e[46]=H,e[47]=ie):ie=e[47];let ce;e[48]!==o?(ce=o?t.jsx("div",{className:"min-w-0 flex-1"}):null,e[48]=o,e[49]=ce):ce=e[49];let he;e[50]!==h||e[51]!==y||e[52]!==v||e[53]!==c||e[54]!==E?(he=E?null:t.jsx(Id,{open:c,onOpenChange:U,currentSessionId:h,effectiveDirectory:y,isNewSessionDraftOpen:v}),e[50]=h,e[51]=y,e[52]=v,e[53]=c,e[54]=E,e[55]=he):he=e[55];let we;e[56]!==y?(we=t.jsx(cc,{directory:y,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]=y,e[57]=we):we=e[57];let q;e[58]!==x||e[59]!==l?(q=l(x?"mobile.header.openWorkspaceWithChangesAria":"mobile.header.openWorkspaceAria"),e[58]=x,e[59]=l,e[60]=q):q=e[60];let ue;e[61]!==i?(ue=()=>{m(!1),u(!1),i()},e[61]=i,e[62]=ue):ue=e[62];let Ee,Re;e[63]===Symbol.for("react.memo_cache_sentinel")?(Ee={touchAction:"manipulation"},Re=t.jsx(Y,{name:"pencil-ruler-2",className:"size-5"}),e[63]=Ee,e[64]=Re):(Ee=e[63],Re=e[64]);let xe;e[65]!==x?(xe=x?t.jsx("span",{className:"absolute right-1.5 top-1.5 size-2.5 rounded-full border-2 border-[var(--background)] bg-[var(--status-warning)]","aria-hidden":!0}):null,e[65]=x,e[66]=xe):xe=e[66];let Ce;e[67]!==q||e[68]!==ue||e[69]!==xe?(Ce=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":q,onClick:ue,style:Ee,children:[Re,xe]}),e[67]=q,e[68]=ue,e[69]=xe,e[70]=Ce):Ce=e[70];let Ae;e[71]!==te||e[72]!==ie||e[73]!==ce||e[74]!==he||e[75]!==we||e[76]!==Ce?(Ae=t.jsx("header",{className:"oc-mobile-header relative z-30 flex shrink-0 items-center gap-1 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",style:W,children:t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[te,ie,ce,he,we,Ce]})}),e[71]=te,e[72]=ie,e[73]=ce,e[74]=he,e[75]=we,e[76]=Ce,e[77]=Ae):Ae=e[77];let Pe;e[78]===Symbol.for("react.memo_cache_sentinel")?(Pe=()=>u(!1),e[78]=Pe):Pe=e[78];let _e;e[79]!==a?(_e=t.jsx(Dd,{open:a,onClose:Pe,anchorRef:p}),e[79]=a,e[80]=_e):_e=e[80];let Se;return e[81]!==Ae||e[82]!==_e?(Se=t.jsxs(t.Fragment,{children:[Ae,_e]}),e[81]=Ae,e[82]=_e,e[83]=Se):Se=e[83],Se};function Bd(n){return n.currentDirectory}function Ld(n){return n.currentSessionId}function $d(n){return!!n.newSessionDraft?.open}function Fd(n){return n.runOverviewKey}const Wd=({onActiveConnectionDeleted:n,onConnect:e})=>{const{t:s}=be(),i=So(e),{connections:r,isBusy:o,isPasswordBusy:l,error:c,pendingConnection:m,connect:a,submitPassword:u,cancelPassword:p,saveConnection:g,removeConnection:h,setError:b}=i,[S,y]=f.useState(null),I=S?r.find(H=>H.id===S)??null:null,[v,C]=f.useState(null),[A,x]=f.useState(""),[E,N]=f.useState(""),[R,k]=f.useState(""),[D,z]=f.useState(""),[_,j]=f.useState(!1),[P,V]=f.useState(!1),w=f.useRef(null),U=f.useMemo(()=>On(),[]),[F,B]=f.useState(!1),[W,Q]=f.useState(null),[J,$]=f.useState(!1),te=po(f.useCallback(()=>$(!0),[])),fe=f.useCallback(()=>{y(null),x(""),N(""),k(""),b(null),B(!1)},[b]),ae=f.useCallback(H=>{H.preventDefault(),g({id:S??void 0,url:A,label:E,clientToken:R}).then(ie=>{ie&&fe()})},[R,S,E,fe,g,A]),ne=f.useCallback(async()=>{if(w.current)return;b(null),j(!0);const H=new AbortController;w.current=H;try{const ie=await Io({signal:H.signal});switch(w.current===H&&(w.current=null,j(!1)),ie.status){case"ok":x(ie.url),ie.label&&N(ie.label),ie.clientToken&&k(ie.clientToken),B(!0);break;case"pairing":V(!0),await i.redeemPairingConnection(ie.pairing);break;case"permission-denied":b(s("mobile.connect.scan.permissionDenied"));break;case"invalid":b(s("mobile.connect.scan.invalid"));break;case"unsupported":b(s("mobile.connect.scan.unsupported"));break;case"failed":b(s("mobile.connect.scan.failed"));break;default:break}}finally{V(!1),w.current===H&&(w.current=null,j(!1))}},[i,b,s]);f.useEffect(()=>()=>w.current?.abort(),[]);const le=f.useCallback(H=>{H.preventDefault(),u(D)},[D,u]),O=f.useCallback(()=>{z(""),p()},[p]),Z=f.useCallback(H=>{C(ie=>ie===H?null:H)},[]),ee=f.useCallback(H=>{C(null),S===H&&fe();const ie=r.length===1;h(H).then(ce=>{ce&&(ie||hi(ce))&&n()})},[r.length,S,n,h,fe]),oe=ks;return m?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:le,children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(Y,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:m.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:m.candidates.some(H=>H.kind==="direct")?wt(m):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...rs,value:D,onChange:H=>z(H.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:oe}),c?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:c}):null,t.jsx(ke,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:l||!D.trim(),children:s(l?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(ke,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:O,children:s("mobile.connect.cancelPassword")})]})})}):t.jsxs(t.Fragment,{children:[_?t.jsx(Ao,{onCancel:()=>w.current?.abort()}):null,P?t.jsx(Po,{}):null,J?t.jsx(No,{onClose:()=>$(!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",{...te,className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map(H=>{const ie=v===H.id,ce=hi(H),he=W===H.id,we=he?s("mobile.connect.connecting"):ce?Es()?s("mobile.instances.status.connectedRelay"):s("mobile.instances.status.connectedDirect"):H.candidates.some(q=>q.kind==="direct")?wt(H):s("mobile.connect.relay.badge");return t.jsxs("div",{className:X("flex items-center border-b border-border/70 transition-colors last:border-b-0",ie&&"bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]"),children:[t.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-3 px-3.5 py-3 text-left transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:opacity-60",onClick:()=>{ce||(Q(H.id),a({id:H.id,candidates:H.candidates,clientToken:H.clientToken,label:H.label}).finally(()=>Q(null)))},disabled:o&&!he||ie,children:[t.jsxs("span",{className:"relative flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:[t.jsx(Y,{name:"server",className:"size-[18px]"}),ce?t.jsx("span",{className:"absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-[var(--surface-elevated)] bg-[var(--status-success)]","aria-hidden":!0}):null]}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:H.label}),t.jsx("span",{className:X("block truncate typography-small",ce&&!he?"text-[var(--status-success)]":"text-muted-foreground"),children:we})]}),he?t.jsx(Y,{name:"loader-4",className:"size-5 shrink-0 animate-spin text-muted-foreground"}):null]}),t.jsxs("div",{className:"flex items-center gap-0.5 pr-2",children:[ie?t.jsxs("button",{type:"button","aria-label":s("mobile.instances.confirmDeleteAria",{label:H.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:()=>ee(H.id),style:{touchAction:"manipulation"},children:[t.jsx(Y,{name:"delete-bin",className:"size-[18px]"}),t.jsx("span",{className:"typography-ui-label",children:s("mobile.instances.delete")})]}):H.candidates.some(q=>q.kind==="direct")?t.jsx("button",{type:"button","aria-label":s("mobile.instances.edit"),className:"flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>{y(H.id),x(wt(H)),N(H.label),k(H.clientToken||""),b(null)},style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"edit",className:"size-[18px]"})}):null,t.jsx("button",{type:"button","aria-label":ie?s("mobile.instances.cancelDeleteAria",{label:H.label}):s("mobile.instances.deleteAria",{label:H.label}),className:"flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>Z(H.id),style:{touchAction:"manipulation"},children:t.jsx(Y,{name:ie?"close":"delete-bin",className:"size-[18px]"})})]})]},H.id)})}):t.jsx("p",{...te,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")}),!F&&!I?t.jsxs("div",{className:"space-y-2",children:[U?t.jsxs(ke,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{ne()},disabled:_,children:[t.jsx(Y,{name:"scan-2",className:X("size-[18px]",_&&"animate-pulse")}),s("mobile.connect.scanQr")]}):null,t.jsxs(ke,{type:"button",variant:U?"ghost":"outline",size:"lg",className:"h-12 w-full",onClick:()=>{b(null),B(!0)},children:[t.jsx(Y,{name:"add",className:"size-[18px]"}),s("mobile.instances.addManual")]}),c?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:c}):null]}):t.jsxs("form",{className:"space-y-3",onSubmit:ae,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(I?"mobile.instances.editTitle":"mobile.instances.addTitle")}),t.jsx(ke,{type:"button",variant:"ghost",size:"xs",onClick:fe,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",{...rs,value:A,onChange:H=>x(H.target.value),placeholder:s("mobile.connect.url.placeholder"),type:"url",inputMode:"url",autoCapitalize:"none",className:oe})]}),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:E,onChange:H=>N(H.target.value),placeholder:s("mobile.instances.label.placeholder"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,className:oe})]}),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",{...rs,value:R,onChange:H=>k(H.target.value),placeholder:s("mobile.connect.token.placeholder"),autoCapitalize:"none",className:oe}),t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")})]}),c?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:c}):null,t.jsx(ke,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",children:s(I?"mobile.instances.saveEdit":"mobile.instances.saveNew")})]})]})})})]})},ze=n=>va(n)??"",Cn=n=>{const e=ze(n);if(!e)return"";const s=e.split("/").filter(Boolean);return s[s.length-1]?.replace(/[-_]/g," ")||e},xi=ur(n=>({expandedParents:{},toggleParent:e=>n(s=>{const i={...s.expandedParents};return i[e]?delete i[e]:i[e]=!0,{expandedParents:i}})})),Gs=ur()(uo(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"})),Bn=ur()(uo(n=>({orderByProject:{},setWorktreeOrder:(e,s)=>n(i=>({orderByProject:{...i.orderByProject,[e]:s}}))}),{name:"mobile-worktree-order"})),yi=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),Vd=(n,e)=>{if(!n||n.length===0)return e;const s=new Map(n.map((r,o)=>[yi(r),o])),i=r=>s.get(yi(r.path))??Number.MAX_SAFE_INTEGER;return e.map((r,o)=>({worktree:r,index:o})).sort((r,o)=>{const l=i(r.worktree)-i(o.worktree);return l!==0?l:r.index-o.index}).map(r=>r.worktree)},Ss=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/,""),Ud=n=>{const e=n;return Ss(e.directory??e.project?.worktree??null)},Do=({open:n,project:e,worktree:s,onClose:i,onDeleted:r})=>{const{t:o}=be(),l=Gi(),c=ss(k=>k.activeSessions),m=De(k=>k.archiveSessions),a=Nt(k=>k.currentDirectory),[u,p]=f.useState(!1),[g,h]=f.useState(!1),[b,S]=f.useState(!1),[y,I]=f.useState(!1),v=Ss(s?.path),C=typeof s?.branch=="string"&&s.branch.trim().length>0,A=f.useMemo(()=>{if(!v)return[];const k=new Map;for(const D of[...c,...l])Ud(D)===v&&k.set(D.id,D);return Array.from(k.values())},[c,l,v]);f.useEffect(()=>{if(!n){p(!1),h(!1),S(!1),I(!1);return}if(!s?.path)return;let k=!1;return $a(s.path).then(D=>{k||S(!!D?.isDirty)}).catch(()=>{k||S(!!s.status?.isDirty)}),()=>{k=!0}},[n,s?.path,s?.status?.isDirty]);const x=f.useCallback((k,D)=>{const z=Fa(k),_=ve.loading(o("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:z}));(async()=>{try{if(D.length>0){const{failedIds:j}=await m(D);if(j.length>0){ve.error(j.length===1?o("sessions.sidebar.bulkActions.failedArchiveSingle",{count:j.length}):o("sessions.sidebar.bulkActions.failedArchivePlural",{count:j.length}),{id:_,description:o("sessions.sidebar.dialogs.deleteResult.tryAgain")});return}}await Wa(e,k,{deleteRemoteBranch:C&&g,deleteLocalBranch:C&&u}),Ss(a)===v&&Ss(e.path)&&Nt.getState().setDirectory(Ss(e.path),{showOverlay:!1}),ve.success(o("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:z}),{id:_,description:o(C&&g?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed")}),r?.()}catch(j){ve.error(o("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:z}),{id:_,description:j instanceof Error?j.message:o("sessions.sidebar.dialogs.deleteResult.tryAgain")})}})()},[m,a,u,g,C,r,e,o,v]),E=()=>{!s||y||(I(!0),x(s,A.map(k=>k.id)),i())};if(!s)return null;const N=s.branch||s.label||s.path,R=(k,D,z,_)=>t.jsxs("button",{type:"button",role:"switch","aria-checked":k,disabled:_,onClick:()=>D(!k),className:X("flex w-full items-center justify-between gap-3 rounded-xl border border-border/70 px-3.5 py-3 text-left transition-colors","hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",_&&"pointer-events-none opacity-40"),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:z}),t.jsx("span",{className:X("relative h-6 w-10 shrink-0 rounded-full transition-colors",k?"bg-primary":"bg-muted-foreground/30"),children:t.jsx("span",{className:X("absolute top-0.5 size-5 rounded-full bg-white transition-transform",k?"translate-x-[1.125rem]":"translate-x-0.5")})})]});return t.jsx(Ki,{open:n,onClose:i,title:o("mobile.projectEdit.deleteWorktreeTitle"),footer:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(ke,{variant:"ghost",className:"flex-1",onClick:i,disabled:y,children:o("projectEditDialog.actions.cancel")}),t.jsx(ke,{variant:"destructive",className:"flex-1",onClick:()=>{E()},disabled:y,children:o("mobile.projectEdit.deleteWorktreeConfirmButton")})]}),children:t.jsxs("div",{className:"flex flex-col gap-4 px-1 py-1",children:[t.jsx("p",{className:"typography-ui-body text-foreground",children:o("mobile.projectEdit.deleteWorktreeConfirm",{name:N})}),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,A.length>0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("mobile.projectEdit.deleteWorktreeArchiveNote",{count:A.length})}):null,C?t.jsxs("div",{className:"flex flex-col gap-2",children:[R(u,p,o("mobile.projectEdit.deleteLocalBranch"),y),R(g,h,o("mobile.projectEdit.deleteRemoteBranch"),y)]}):null]})})},As=n=>{const e=me.c(18),{project:s,size:i}=n,r=i===void 0?"md":i,{currentTheme:o}=qi(),l=s.icon?Hi[s.icon]:null,c=s.color?Ji[s.color]??null:null,m=r==="sm"?"size-6 rounded-md":"size-8 rounded-lg",a=r==="sm"?"size-3.5":"size-4";let u;e[0]!==l||e[1]!==c||e[2]!==a?(u=l?t.jsx(Y,{name:l,className:a,style:c?{color:c}:void 0}):t.jsx(Dn,{className:a,style:c?{color:c}:void 0}),e[0]=l,e[1]=c,e[2]=a,e[3]=u):u=e[3];const p=u,g=r==="md"&&"bg-[var(--surface-muted)]";let h;e[4]!==m||e[5]!==g?(h=X("flex shrink-0 items-center justify-center overflow-hidden text-muted-foreground",g,m),e[4]=m,e[5]=g,e[6]=h):h=e[6];let b;e[7]!==s.iconBackground?(b=s.iconBackground?{backgroundColor:s.iconBackground}:void 0,e[7]=s.iconBackground,e[8]=b):b=e[8];let S;e[9]!==o||e[10]!==p||e[11]!==s.iconImage||e[12]!==s.id?(S=s.iconImage?t.jsx(Yi,{project:{id:s.id,iconImage:s.iconImage??null},options:{themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},className:"size-full object-contain",fallback:p}):p,e[9]=o,e[10]=p,e[11]=s.iconImage,e[12]=s.id,e[13]=S):S=e[13];let y;return e[14]!==h||e[15]!==b||e[16]!==S?(y=t.jsx("span",{className:h,style:b,children:S}),e[14]=h,e[15]=b,e[16]=S,e[17]=y):y=e[17],y},_o=n=>{const e=me.c(57),{initialTitle:s,indent:i,className:r,aiRename:o,onSubmit:l,onCancel:c}=n,{t:m}=be(),[a,u]=f.useState(s),p=Gd;let g;e[0]!==s||e[1]!==c||e[2]!==l||e[3]!==a?(g=()=>{const J=a.trim();if(!J||J===s.trim()){c();return}l(J)},e[0]=s,e[1]=c,e[2]=l,e[3]=a,e[4]=g):g=e[4];const h=g;let b;e[5]!==r?(b=X("flex h-9 min-w-0 flex-1 items-center gap-2 pr-2",r),e[5]=r,e[6]=b):b=e[6];let S;e[7]!==i?(S={paddingLeft:i},e[7]=i,e[8]=S):S=e[8];let y;e[9]!==h?(y=J=>{J.preventDefault(),h()},e[9]=h,e[10]=y):y=e[10];let I;e[11]===Symbol.for("react.memo_cache_sentinel")?(I=J=>u(J.target.value),e[11]=I):I=e[11];let v;e[12]!==c?(v=J=>uc(J,c),e[12]=c,e[13]=v):v=e[13];let C;e[14]!==m?(C=m("sessions.sidebar.session.rename.save"),e[14]=m,e[15]=C):C=e[15];let A;e[16]!==m?(A=m("sessions.sidebar.session.menu.rename"),e[16]=m,e[17]=A):A=e[17];let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x={minHeight:0},e[18]=x):x=e[18];let E;e[19]!==v||e[20]!==C||e[21]!==A||e[22]!==a?(E=t.jsx("input",{ref:p,value:a,onChange:I,onKeyDown:v,"aria-label":C,placeholder:A,className:"min-w-0 flex-1 bg-transparent text-[16px] typography-ui-label text-foreground outline-none placeholder:text-muted-foreground",style:x,enterKeyHint:"done"}),e[19]=v,e[20]=C,e[21]=A,e[22]=a,e[23]=E):E=e[23];const N=o.disabled;let R;e[24]!==o||e[25]!==c?(R=()=>{o.run(),c()},e[24]=o,e[25]=c,e[26]=R):R=e[26];let k;e[27]!==m?(k=m("sessions.aiRename.action"),e[27]=m,e[28]=k):k=e[28];let D,z;e[29]===Symbol.for("react.memo_cache_sentinel")?(D={touchAction:"manipulation",minHeight:0,minWidth:0},z=t.jsx(Y,{name:"ai-generate-2",className:"size-4"}),e[29]=D,e[30]=z):(D=e[29],z=e[30]);let _;e[31]!==o.disabled||e[32]!==o.hint||e[33]!==R||e[34]!==k?(_=t.jsx("button",{type:"button",disabled:N,onClick:R,"aria-label":k,"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:D,children:z}),e[31]=o.disabled,e[32]=o.hint,e[33]=R,e[34]=k,e[35]=_):_=e[35];let j;e[36]!==m?(j=m("sessions.sidebar.session.rename.save"),e[36]=m,e[37]=j):j=e[37];let P,V;e[38]===Symbol.for("react.memo_cache_sentinel")?(P={touchAction:"manipulation",minHeight:0,minWidth:0},V=t.jsx(Y,{name:"check",className:"size-4"}),e[38]=P,e[39]=V):(P=e[38],V=e[39]);let w;e[40]!==j?(w=t.jsx("button",{type:"submit","aria-label":j,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:P,children:V}),e[40]=j,e[41]=w):w=e[41];let U;e[42]!==m?(U=m("sessions.sidebar.session.rename.cancel"),e[42]=m,e[43]=U):U=e[43];let F,B;e[44]===Symbol.for("react.memo_cache_sentinel")?(F={touchAction:"manipulation",minHeight:0,minWidth:0},B=t.jsx(Y,{name:"close",className:"size-4"}),e[44]=F,e[45]=B):(F=e[44],B=e[45]);let W;e[46]!==c||e[47]!==U?(W=t.jsx("button",{type:"button",onClick:c,"aria-label":U,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:F,children:B}),e[46]=c,e[47]=U,e[48]=W):W=e[48];let Q;return e[49]!==E||e[50]!==_||e[51]!==b||e[52]!==w||e[53]!==W||e[54]!==S||e[55]!==y?(Q=t.jsxs("form",{className:b,style:S,onSubmit:y,children:[E,_,w,W]}),e[49]=E,e[50]=_,e[51]=b,e[52]=w,e[53]=W,e[54]=S,e[55]=y,e[56]=Q):Q=e[56],Q};function Gd(n){n&&(n.focus(),n.select())}const Ps=48,Mo=4*Ps,Kd=180,nn=n=>{const e=me.c(27),{actionsWidth:s,actions:i,revealed:r,onRevealedChange:o,dataActiveSession:l,contentClassName:c,children:m}=n,a=c===void 0?"relative flex w-full items-center bg-background":c,u=f.useRef(null),p=f.useRef(null),g=f.useRef(!1),h=f.useRef(0),b=f.useRef(r);let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S=(w,U)=>{const F=u.current;F&&(F.style.transition=U?`transform ${Kd}ms ease-out`:"none",F.style.transform=w===0?"none":`translateX(${w}px)`,h.current=w)},e[0]=S):S=e[0];const y=S;let I,v;e[1]!==s||e[2]!==r?(I=()=>{b.current=r,y(r?s:0,!0)},v=[s,y,r],e[1]=s,e[2]=r,e[3]=I,e[4]=v):(I=e[3],v=e[4]),f.useEffect(I,v);let C;e[5]===Symbol.for("react.memo_cache_sentinel")?(C=w=>{if(w.touches.length!==1)return;const U=w.touches[0];p.current={x:U.clientX,y:U.clientY},g.current=!1},e[5]=C):C=e[5];const A=C;let x;e[6]!==s?(x=w=>{if(!p.current)return;const U=w.touches[0],F=U.clientX-p.current.x,B=U.clientY-p.current.y;if(!g.current){if(Math.abs(F)<8||Math.abs(F)<=Math.abs(B))return;g.current=!0}const W=b.current?s:0;y(Math.max(0,Math.min(s,W+F)),!1)},e[6]=s,e[7]=x):x=e[7];const E=x;let N;e[8]!==s||e[9]!==o?(N=()=>{if(p.current=null,!g.current)return;g.current=!1;const w=h.current>s/2;y(w?s:0,!0),w!==b.current&&o(w)},e[8]=s,e[9]=o,e[10]=N):N=e[10];const R=N,k=l||void 0;let D;e[11]===Symbol.for("react.memo_cache_sentinel")?(D={touchAction:"pan-y"},e[11]=D):D=e[11];let z;e[12]!==s?(z={width:s},e[12]=s,e[13]=z):z=e[13];const _=!r;let j;e[14]!==i||e[15]!==z||e[16]!==_?(j=t.jsx("div",{className:"absolute inset-y-0 left-0 flex items-stretch",style:z,"aria-hidden":_,children:i}),e[14]=i,e[15]=z,e[16]=_,e[17]=j):j=e[17];let P;e[18]!==m||e[19]!==a?(P=t.jsx("div",{ref:u,className:a,children:m}),e[18]=m,e[19]=a,e[20]=P):P=e[20];let V;return e[21]!==R||e[22]!==E||e[23]!==j||e[24]!==P||e[25]!==k?(V=t.jsxs("div",{"data-active-session":k,className:"relative overflow-hidden",onTouchStart:A,onTouchMove:E,onTouchEnd:R,onTouchCancel:R,style:D,children:[j,P]}),e[21]=R,e[22]=E,e[23]=j,e[24]=P,e[25]=k,e[26]=V):V=e[26],V},zo=n=>{const e=me.c(62),{sessionId:s,title:i,revealed:r,confirmingDelete:o,onArchive:l,onRequestDelete:c,onConfirmDelete:m,onRequestRename:a,onRevealedChange:u,work:p,pin:g}=n,{t:h}=be(),b=r?0:-1;let S;e[0]!==u||e[1]!==s||e[2]!==h?(S=async()=>{if(!(await Wi(s).catch(qd))?.ok){Mn.error(h("sessions.sidebar.session.copyId.error"));return}u?.(!1),Mn.success(h("sessions.sidebar.session.copyId.success"))},e[0]=u,e[1]=s,e[2]=h,e[3]=S):S=e[3];const y=S;let I;e[4]!==h||e[5]!==i?(I=h("mobile.sessions.archiveSessionAria",{title:i}),e[4]=h,e[5]=i,e[6]=I):I=e[6];let v,C;e[7]===Symbol.for("react.memo_cache_sentinel")?(v={touchAction:"manipulation"},C=t.jsx(eu,{className:"size-[18px]"}),e[7]=v,e[8]=C):(v=e[7],C=e[8]);let A;e[9]!==l||e[10]!==I||e[11]!==b?(A=t.jsx("button",{type:"button",tabIndex:b,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":I,onClick:l,style:v,children:C}),e[9]=l,e[10]=I,e[11]=b,e[12]=A):A=e[12];let x;e[13]!==u||e[14]!==g||e[15]!==h||e[16]!==b?(x=g?t.jsx("button",{type:"button",tabIndex:b,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":g.pinned?h("sessions.sidebar.session.menu.unpin"):h("sessions.sidebar.session.menu.pin"),onClick:()=>{g.onToggle(),u?.(!1)},style:{touchAction:"manipulation"},children:t.jsx(Y,{name:g.pinned?"unpin":"pushpin",className:"size-[18px]"})}):null,e[13]=u,e[14]=g,e[15]=h,e[16]=b,e[17]=x):x=e[17];let E;e[18]!==u||e[19]!==h||e[20]!==b||e[21]!==p?(E=p?t.jsx("button",{type:"button",tabIndex:b,className:X("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",p.inWork?"text-status-success":"text-muted-foreground active:text-foreground"),"aria-label":p.inWork?h("sessions.sidebar.session.work.markDone"):h("sessions.sidebar.session.work.track"),onClick:()=>{p.onToggle(),u?.(!1)},style:{touchAction:"manipulation"},children:t.jsx(Y,{name:p.inWork?"check":"eye",className:p.inWork?"size-5":"size-[18px]"})}):null,e[18]=u,e[19]=h,e[20]=b,e[21]=p,e[22]=E):E=e[22];const N=o?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80";let R;e[23]!==N?(R=X("flex flex-1 items-center justify-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive",N),e[23]=N,e[24]=R):R=e[24];let k;e[25]!==o||e[26]!==h||e[27]!==i?(k=o?h("mobile.sessions.confirmDeleteSessionAria",{title:i}):h("mobile.sessions.deleteSessionAria",{title:i}),e[25]=o,e[26]=h,e[27]=i,e[28]=k):k=e[28];const D=o?m:c;let z,_;e[29]===Symbol.for("react.memo_cache_sentinel")?(z={touchAction:"manipulation"},_=t.jsx(Xs,{className:"size-[18px]"}),e[29]=z,e[30]=_):(z=e[29],_=e[30]);let j;e[31]!==k||e[32]!==D||e[33]!==R||e[34]!==b?(j=t.jsx("button",{type:"button",tabIndex:b,className:R,"aria-label":k,onClick:D,style:z,children:_}),e[31]=k,e[32]=D,e[33]=R,e[34]=b,e[35]=j):j=e[35];let P;e[36]!==h||e[37]!==i?(P=h("mobile.sessions.renameSessionAria",{title:i}),e[36]=h,e[37]=i,e[38]=P):P=e[38];let V,w;e[39]===Symbol.for("react.memo_cache_sentinel")?(V={touchAction:"manipulation"},w=t.jsx(_n,{className:"size-[18px]"}),e[39]=V,e[40]=w):(V=e[39],w=e[40]);let U;e[41]!==a||e[42]!==P||e[43]!==b?(U=t.jsx("button",{type:"button",tabIndex:b,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":P,onClick:a,style:V,children:w}),e[41]=a,e[42]=P,e[43]=b,e[44]=U):U=e[44];let F;e[45]!==h?(F=h("sessions.sidebar.session.menu.copyId"),e[45]=h,e[46]=F):F=e[46];let B;e[47]!==y?(B=()=>{y()},e[47]=y,e[48]=B):B=e[48];let W,Q;e[49]===Symbol.for("react.memo_cache_sentinel")?(W={touchAction:"manipulation"},Q=t.jsx(Y,{name:"file-copy",className:"size-[18px]"}),e[49]=W,e[50]=Q):(W=e[49],Q=e[50]);let J;e[51]!==F||e[52]!==B||e[53]!==b?(J=t.jsx("button",{type:"button",tabIndex:b,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":F,onClick:B,style:W,children:Q}),e[51]=F,e[52]=B,e[53]=b,e[54]=J):J=e[54];let $;return e[55]!==j||e[56]!==U||e[57]!==J||e[58]!==A||e[59]!==x||e[60]!==E?($=t.jsxs(t.Fragment,{children:[A,x,E,j,U,J]}),e[55]=j,e[56]=U,e[57]=J,e[58]=A,e[59]=x,e[60]=E,e[61]=$):$=e[61],$};function qd(){return null}const ct=n=>n.parentID??null,ft=n=>{const e=n;return ze(e.directory??e.project?.worktree??null)},Oo=n=>{const e=n.time?.updated??n.time?.created,s=typeof e=="number"?e:Number(e);return Number.isFinite(s)&&s>0?s:0},ln=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))},Hd=4,Bo=n=>{const e=me.c(4),{providerIDs:s}=n;let i;e[0]!==s?(i=s.slice(0,Hd).map(Jd),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 Jd(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(Vi,{providerId:n,className:"size-3 opacity-80"})},n)}const Lo=n=>{const e=me.c(8),{session:s}=n,{t:i}=be(),r=Xi(s);if(!r)return null;const o=Va[r.status];let l;e[0]!==i||e[1]!==o?(l=i(o),e[0]=i,e[1]=o,e[2]=l):l=e[2];const c=l,m=Ua[r.status];let a;e[3]!==m?(a={color:m},e[3]=m,e[4]=a):a=e[4];let u;return e[5]!==c||e[6]!==a?(u=t.jsx(Y,{name:"target",className:"size-3.5 shrink-0",style:a,"aria-label":c}),e[5]=c,e[6]=a,e[7]=u):u=e[7],u},$o=n=>{const e=me.c(12),{permissionCount:s,formCount:i}=n,{t:r}=be();if(s===0&&i===0)return null;let o;e[0]!==i||e[1]!==r?(o=i===1?r("sessions.sidebar.session.status.questionPendingSingle"):r("sessions.sidebar.session.status.questionPendingMany",{count:i}),e[0]=i,e[1]=r,e[2]=o):o=e[2];const l=o;let c;e[3]!==s||e[4]!==r?(c=s>0?t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive","aria-label":r("sessions.sidebar.session.status.permissionRequired"),children:[t.jsx(Y,{name:"shield",className:"size-3"}),t.jsx("span",{className:"leading-none tabular-nums",children:s})]}):null,e[3]=s,e[4]=r,e[5]=c):c=e[5];let m;e[6]!==i||e[7]!==l?(m=i>0?t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded bg-status-info/10 px-1 py-0.5 text-[0.7rem] text-status-info","aria-label":l,children:[t.jsx(Y,{name:"question",className:"size-3"}),t.jsx("span",{className:"leading-none tabular-nums",children:i})]}):null,e[6]=i,e[7]=l,e[8]=m):m=e[8];let a;return e[9]!==c||e[10]!==m?(a=t.jsxs(t.Fragment,{children:[c,m]}),e[9]=c,e[10]=m,e[11]=a):a=e[11],a},Fo=n=>{const e=me.c(7);let s;e[0]!==n?(s=c=>{let m=0;for(const a of n)m=m+(c.bySession.get(a)?.permissions.length??0);return m},e[0]=n,e[1]=s):s=e[1];const i=Qr(s);let r;e[2]!==n?(r=c=>{let m=0;for(const a of n)m=m+(c.bySession.get(a)?.forms.length??0);return m},e[2]=n,e[3]=r):r=e[3];const o=Qr(r);let l;return e[4]!==o||e[5]!==i?(l={permissionCount:i,formCount:o},e[4]=o,e[5]=i,e[6]=l):l=e[6],l},Ln=12,$n="flex min-w-0 flex-1 flex-col gap-1 py-2.5 pr-3 text-left",Yd=n=>{const e=me.c(54),{entry:s}=n,{t:i}=be(),{run:r,project:o}=s;let l;e[0]!==r.key?(l=B=>B.runOverviewKey===r.key,e[0]=r.key,e[1]=l):l=e[1];const c=$e(l);let m;e[2]!==s.laneNodes?(m={nodes:s.laneNodes,includeUnreadSubtasks:!1},e[2]=s.laneNodes,e[3]=m):m=e[3];const a=oo(m);let u;e[4]!==r.lastActivity?(u=ln(r.lastActivity),e[4]=r.lastActivity,e[5]=u):u=e[5];const p=u,g=r.lanes.length,h=c||void 0,b=c&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let S;e[6]!==b?(S=X("relative bg-background transition-colors",b),e[6]=b,e[7]=S):S=e[7];let y,I;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=X($n,"w-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"),I={paddingLeft:Ln,touchAction:"manipulation"},e[8]=y,e[9]=I):(y=e[8],I=e[9]);let v;e[10]!==r.key?(v=()=>$e.getState().setRunOverviewKey(r.key),e[10]=r.key,e[11]=v):v=e[11];let C;e[12]!==r.title||e[13]!==i?(C=i("sessions.sidebar.run.openOverviewAria",{title:r.title}),e[12]=r.title,e[13]=i,e[14]=C):C=e[14];let A;e[15]!==o?(A=t.jsx(As,{project:o,size:"sm"}),e[15]=o,e[16]=A):A=e[16];let x;e[17]!==o.label?(x=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-micro text-muted-foreground",children:o.label}),e[17]=o.label,e[18]=x):x=e[18];let E;e[19]!==a?(E=a?t.jsx(lo,{state:a}):null,e[19]=a,e[20]=E):E=e[20];let N;e[21]!==p?(N=p?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:p}):null,e[21]=p,e[22]=N):N=e[22];let R;e[23]!==A||e[24]!==x||e[25]!==E||e[26]!==N?(R=t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[A,x,E,N]}),e[23]=A,e[24]=x,e[25]=E,e[26]=N,e[27]=R):R=e[27];const k=c?"text-primary":"text-foreground";let D;e[28]!==k?(D=X("block min-w-0 truncate typography-ui-label",k),e[28]=k,e[29]=D):D=e[29];let z;e[30]!==r.title||e[31]!==D?(z=t.jsx("span",{className:D,children:r.title}),e[30]=r.title,e[31]=D,e[32]=z):z=e[32];let _;e[33]===Symbol.for("react.memo_cache_sentinel")?(_=t.jsx(Zi,{className:"size-3.5 shrink-0","aria-hidden":"true"}),e[33]=_):_=e[33];let j;e[34]!==g||e[35]!==i?(j=g===1?i("sessions.sidebar.run.laneCountSingle",{count:g}):i("sessions.sidebar.run.laneCountPlural",{count:g}),e[34]=g,e[35]=i,e[36]=j):j=e[36];let P;e[37]!==j?(P=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-micro",children:j}),e[37]=j,e[38]=P):P=e[38];let V;e[39]!==r.providerIDs?(V=t.jsx(Bo,{providerIDs:r.providerIDs}),e[39]=r.providerIDs,e[40]=V):V=e[40];let w;e[41]!==P||e[42]!==V?(w=t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[_,P,V]}),e[41]=P,e[42]=V,e[43]=w):w=e[43];let U;e[44]!==C||e[45]!==R||e[46]!==z||e[47]!==w||e[48]!==v?(U=t.jsxs("button",{type:"button",className:y,style:I,onClick:v,"aria-label":C,children:[R,z,w]}),e[44]=C,e[45]=R,e[46]=z,e[47]=w,e[48]=v,e[49]=U):U=e[49];let F;return e[50]!==U||e[51]!==h||e[52]!==S?(F=t.jsx("div",{"data-active-session":h,className:S,children:U}),e[50]=U,e[51]=h,e[52]=S,e[53]=F):F=e[53],F},Xd=n=>{const e=me.c(115),{entry:s,active:i,revealed:r,confirmingDelete:o,renaming:l,handlers:c}=n,{t:m}=be(),{session:a,project:u,branch:p}=s;let g;e[0]!==a.title||e[1]!==m?(g=a.title?.trim()||m("mobile.sessions.untitled"),e[0]=a.title,e[1]=m,e[2]=g):g=e[2];const h=g;let b;e[3]!==a?(b=ln(Oo(a)),e[3]=a,e[4]=b):b=e[4];const S=b,y=ao(a.id,a.directory,r||l),I=Un(a.id),v=Gn(a.id),C=!v&&I>0&&!i,A=Kn(a.id,v),x=(v||C)&&A,E=c.onToggleWork;let N;e[5]!==a?(N=Qi(a),e[5]=a,e[6]=N):N=e[6];const R=N;let k;e[7]!==R||e[8]!==E||e[9]!==a?(k=E?{inWork:R,onToggle:()=>E(a,R)}:void 0,e[7]=R,e[8]=E,e[9]=a,e[10]=k):k=e[10];const D=k;let z;e[11]!==c||e[12]!==a?(z=c.isPinned(a),e[11]=c,e[12]=a,e[13]=z):z=e[13];const _=z;let j;e[14]!==c||e[15]!==a?(j=()=>c.onTogglePin(a),e[14]=c,e[15]=a,e[16]=j):j=e[16];let P;e[17]!==_||e[18]!==j?(P={pinned:_,onToggle:j},e[17]=_,e[18]=j,e[19]=P):P=e[19];const V=P,{descendantIdsOf:w}=c;let U;e[20]!==w||e[21]!==a.id?(U=[a.id,...w(a.id)],e[20]=w,e[21]=a.id,e[22]=U):U=e[22];const B=Fo(U),W=B.permissionCount>0||B.formCount>0;let Q;e[23]!==a?(Q=Xi(a),e[23]=a,e[24]=Q):Q=e[24];const J=Q!==null,$=Mo+Ps+(D?Ps:0);let te;e[25]!==c||e[26]!==a.id?(te=ce=>c.onRevealedChange(a.id,ce),e[25]=c,e[26]=a.id,e[27]=te):te=e[27];const fe=i&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let ae;e[28]!==fe?(ae=X("relative flex w-full items-center bg-background transition-colors",fe),e[28]=fe,e[29]=ae):ae=e[29];let ne;e[30]!==c||e[31]!==a?(ne=()=>c.onArchive(a),e[30]=c,e[31]=a,e[32]=ne):ne=e[32];let le;e[33]!==c||e[34]!==a.id?(le=()=>c.onRequestDelete(a.id),e[33]=c,e[34]=a.id,e[35]=le):le=e[35];let O;e[36]!==c||e[37]!==a?(O=()=>c.onConfirmDelete(a),e[36]=c,e[37]=a,e[38]=O):O=e[38];let Z,ee;e[39]!==c||e[40]!==a.id?(Z=()=>c.onRequestRename(a.id),ee=ce=>c.onRevealedChange(a.id,ce),e[39]=c,e[40]=a.id,e[41]=Z,e[42]=ee):(Z=e[41],ee=e[42]);let oe;e[43]!==o||e[44]!==V||e[45]!==r||e[46]!==a.id||e[47]!==ne||e[48]!==le||e[49]!==O||e[50]!==Z||e[51]!==ee||e[52]!==h||e[53]!==D?(oe=t.jsx(zo,{sessionId:a.id,title:h,revealed:r,confirmingDelete:o,onArchive:ne,onRequestDelete:le,onConfirmDelete:O,onRequestRename:Z,onRevealedChange:ee,work:D,pin:V}),e[43]=o,e[44]=V,e[45]=r,e[46]=a.id,e[47]=ne,e[48]=le,e[49]=O,e[50]=Z,e[51]=ee,e[52]=h,e[53]=D,e[54]=oe):oe=e[54];let H;e:{let ce;e[55]!==u?(ce=t.jsx(As,{project:u,size:"sm"}),e[55]=u,e[56]=ce):ce=e[56];let he;e[57]!==u.label?(he=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-micro text-muted-foreground",children:u.label}),e[57]=u.label,e[58]=he):he=e[58];let we;e[59]!==_||e[60]!==m?(we=_?t.jsx(Y,{name:"pushpin",className:"size-3 shrink-0 text-muted-foreground","aria-label":m("sessions.sidebar.session.status.pinned")}):null,e[59]=_,e[60]=m,e[61]=we):we=e[61];let q;e[62]!==y.pending||e[63]!==v||e[64]!==C||e[65]!==m?(q=y.pending?t.jsx(Y,{name:"loader-4",className:"size-3 shrink-0 animate-spin text-primary","aria-label":m("sessions.aiRename.generating")}):v||C?t.jsx(Ys,{state:v?"running":"unread",label:m(v?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread")}):null,e[62]=y.pending,e[63]=v,e[64]=C,e[65]=m,e[66]=q):q=e[66];let ue;e[67]!==v||e[68]!==a.id||e[69]!==x||e[70]!==S?(ue=x?t.jsx(Xn,{sessionId:a.id,running:v,className:"shrink-0 typography-micro"}):S?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:S}):null,e[67]=v,e[68]=a.id,e[69]=x,e[70]=S,e[71]=ue):ue=e[71];let Ee;e[72]!==ce||e[73]!==he||e[74]!==we||e[75]!==q||e[76]!==ue?(Ee=t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[ce,he,we,q,ue]}),e[72]=ce,e[73]=he,e[74]=we,e[75]=q,e[76]=ue,e[77]=Ee):Ee=e[77];let Re;e[78]!==i||e[79]!==y||e[80]!==c||e[81]!==l||e[82]!==a.id||e[83]!==h?(Re=l?t.jsx(_o,{initialTitle:h,indent:0,aiRename:y,className:"h-[1lh] pr-0 typography-ui-label [&_button]:size-6 [&_button>svg]:size-3.5",onSubmit:Me=>c.onSubmitRename(a.id,Me),onCancel:c.onCancelRename}):t.jsx("span",{className:X("block min-w-0 truncate typography-ui-label",i?"text-primary":"text-foreground"),children:h}),e[78]=i,e[79]=y,e[80]=c,e[81]=l,e[82]=a.id,e[83]=h,e[84]=Re):Re=e[84];let xe;e[85]!==p||e[86]!==J||e[87]!==W||e[88]!==B||e[89]!==a?(xe=p||J||W?t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[p?t.jsxs(t.Fragment,{children:[t.jsx(Y,{name:"git-branch",className:"size-3.5 shrink-0"}),t.jsx("span",{className:"block min-w-0 truncate typography-micro",children:p})]}):null,t.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[t.jsx(Lo,{session:a}),t.jsx($o,{...B})]})]}):null,e[85]=p,e[86]=J,e[87]=W,e[88]=B,e[89]=a,e[90]=xe):xe=e[90];let Ce;e[91]!==Ee||e[92]!==Re||e[93]!==xe?(Ce=t.jsxs(t.Fragment,{children:[Ee,Re,xe]}),e[91]=Ee,e[92]=Re,e[93]=xe,e[94]=Ce):Ce=e[94];const Ae=Ce;if(l){let Me;e[95]===Symbol.for("react.memo_cache_sentinel")?(Me={paddingLeft:Ln},e[95]=Me):Me=e[95];let it;e[96]!==Ae?(it=t.jsx("div",{className:$n,style:Me,children:Ae}),e[96]=Ae,e[97]=it):it=e[97],H=it;break e}let Pe,_e;e[98]===Symbol.for("react.memo_cache_sentinel")?(Pe=X($n,"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"),_e={paddingLeft:Ln,touchAction:"manipulation"},e[98]=Pe,e[99]=_e):(Pe=e[98],_e=e[99]);let Se;e[100]!==c||e[101]!==r||e[102]!==a?(Se=()=>{if(r){c.onRevealedChange(a.id,!1);return}c.onSelect(a)},e[100]=c,e[101]=r,e[102]=a,e[103]=Se):Se=e[103];let Oe;e[104]!==Ae||e[105]!==Se?(Oe=t.jsx("button",{type:"button",className:Pe,style:_e,onClick:Se,children:Ae}),e[104]=Ae,e[105]=Se,e[106]=Oe):Oe=e[106],H=Oe}let ie;return e[107]!==i||e[108]!==r||e[109]!==$||e[110]!==te||e[111]!==ae||e[112]!==oe||e[113]!==H?(ie=t.jsx(nn,{actionsWidth:$,revealed:r,onRevealedChange:te,dataActiveSession:i,contentClassName:ae,actions:oe,children:H}),e[107]=i,e[108]=r,e[109]=$,e[110]=te,e[111]=ae,e[112]=oe,e[113]=H,e[114]=ie):ie=e[114],ie},Qd=n=>{const e=me.c(9),{scrollRootRef:s,visibleCount:i,onReachEnd:r}=n,o=f.useRef(null),l=f.useRef(r);let c,m;e[0]!==r?(c=()=>{l.current=r},m=[r],e[0]=r,e[1]=c,e[2]=m):(c=e[1],m=e[2]),f.useEffect(c,m);let a;e[3]!==s?(a=()=>{const g=o.current;if(!g)return;const h=new IntersectionObserver(b=>{b.some(ef)&&l.current()},{root:s.current??null,rootMargin:"400px 0px"});return h.observe(g),()=>h.disconnect()},e[3]=s,e[4]=a):a=e[4];let u;e[5]!==s||e[6]!==i?(u=[s,i],e[5]=s,e[6]=i,e[7]=u):u=e[7],f.useEffect(a,u);let p;return e[8]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx("div",{ref:o,"aria-hidden":!0,className:"h-px w-full"}),e[8]=p):p=e[8],p},Zd=n=>{const e=me.c(35),{entries:s,visibleCount:i,onRevealMore:r,scrollRootRef:o,handlers:l}=n,{t:c}=be();let m,a,u,p,g;if(e[0]!==s||e[1]!==l||e[2]!==c||e[3]!==i){g=s.slice(0,i),u="border-t border-border/70";let y;e[9]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-[var(--surface-muted)] text-muted-foreground",children:t.jsx(Y,{name:"folder-6",className:"size-4"})}),e[9]=y):y=e[9];let I;e[10]!==c?(I=c("mobile.sessions.section.projects"),e[10]=c,e[11]=I):I=e[11];let v;e[12]!==I?(v=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:I}),e[12]=I,e[13]=v):v=e[13];let C;e[14]!==s.length?(C=t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:s.length}),e[14]=s.length,e[15]=C):C=e[15],e[16]!==v||e[17]!==C?(p=t.jsxs("div",{className:"flex min-h-12 w-full items-center gap-2 px-3 py-1.5",children:[y,v,C]}),e[16]=v,e[17]=C,e[18]=p):p=e[18],m="pb-2";let A;e[19]!==l?(A=x=>x.kind==="run"?t.jsx(Yd,{entry:x},`run:${x.run.key}`):t.jsx(Xd,{entry:x,active:l.currentSessionId===x.session.id,revealed:l.revealedSessionId===x.session.id,confirmingDelete:l.confirmingDeleteSessionId===x.session.id,renaming:l.renamingSessionId===x.session.id,handlers:l},x.session.id),e[19]=l,e[20]=A):A=e[20],a=g.map(A),e[0]=s,e[1]=l,e[2]=c,e[3]=i,e[4]=m,e[5]=a,e[6]=u,e[7]=p,e[8]=g}else m=e[4],a=e[5],u=e[6],p=e[7],g=e[8];let h;e[21]!==s.length||e[22]!==r||e[23]!==o||e[24]!==i||e[25]!==g.length?(h=g.length<s.length?t.jsx(Qd,{scrollRootRef:o,visibleCount:i,onReachEnd:r}):null,e[21]=s.length,e[22]=r,e[23]=o,e[24]=i,e[25]=g.length,e[26]=h):h=e[26];let b;e[27]!==m||e[28]!==a||e[29]!==h?(b=t.jsxs("div",{className:m,children:[a,h]}),e[27]=m,e[28]=a,e[29]=h,e[30]=b):b=e[30];let S;return e[31]!==u||e[32]!==p||e[33]!==b?(S=t.jsxs("section",{className:u,children:[p,b]}),e[31]=u,e[32]=p,e[33]=b,e[34]=S):S=e[34],S};function ef(n){return n.isIntersecting}const Js=40,tf=(n,e)=>Math.min(e,Math.max(n,0)+Js),vi="mobile-surface-root",Rn=16,Ks=200,sf=()=>{if(typeof document>"u")return null;let n=document.getElementById(vi);return n||(n=document.createElement("div"),n.id=vi,document.body.appendChild(n)),n},Xt=({open:n,onClose:e,title:s,subtitle:i,trailing:r,disableEscapeDismiss:o=!1,headerless:l=!1,noHeaderBorder:c=!1,ariaLabel:m,variant:a="fullscreen",dialogAlign:u="chat",children:p})=>{const{t:g}=be(),h=f.useRef(null),[b,S]=f.useState(!1),[y,I]=f.useState(!1),v=f.useRef(null),C=f.useRef(null),A=f.useRef(e);if(f.useEffect(()=>{A.current=e},[e]),typeof document<"u"&&!h.current&&(h.current=sf()),f.useEffect(()=>{if(!n){S(!1);return}const N=window.setTimeout(()=>S(!0),Rn);return()=>window.clearTimeout(N)},[n]),f.useEffect(()=>{if(!n){I(!1);return}const N=window.setTimeout(()=>I(!0),Rn+Ks+80);return()=>window.clearTimeout(N)},[n]),f.useEffect(()=>{if(!n)return;const N=document.body.style.overflow;C.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow="hidden";const R=()=>{const z=v.current;if(!z)return;(z.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??z).focus({preventScroll:!0})},k=window.setTimeout(R,Rn),D=z=>{if(z.key==="Escape"&&!o){A.current();return}if(z.key!=="Tab")return;const _=v.current;if(!_)return;const j=Array.from(_.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(U=>!U.hasAttribute("disabled")&&U.getAttribute("aria-hidden")!=="true");if(j.length===0){z.preventDefault(),_.focus({preventScroll:!0});return}const P=j[0],V=j[j.length-1],w=document.activeElement;z.shiftKey&&w===P?(z.preventDefault(),V.focus({preventScroll:!0})):!z.shiftKey&&w===V&&(z.preventDefault(),P.focus({preventScroll:!0}))};return document.addEventListener("keydown",D),()=>{window.clearTimeout(k),document.body.style.overflow=N,document.removeEventListener("keydown",D),C.current?.focus?.({preventScroll:!0}),C.current=null}},[o,n]),!n||!h.current)return null;const x=a==="dialog",E=t.jsxs("section",{ref:v,role:"dialog","aria-modal":"true","aria-label":m,tabIndex:-1,className:X("flex flex-col bg-background text-foreground",x?"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:x?{opacity:b?1:0,transform:b?"none":"scale(0.97)",transition:`opacity ${Ks}ms ease-out, transform ${Ks}ms cubic-bezier(0.32, 0.72, 0, 1)`}:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:b?"none":"translateX(100%)",transition:`transform ${Ks}ms cubic-bezier(0.32, 0.72, 0, 1)`},onTransitionEnd:N=>{b&&N.target===N.currentTarget&&N.propertyName==="transform"&&I(!0)},children:[l?null:t.jsxs("header",{className:X("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",!c&&"border-b border-border/70"),children:[t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":g("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"close",className:"size-5"})}),t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[s?typeof s=="string"?t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:s}):s:null,i?typeof i=="string"?t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:i}):i:null]}),r?t.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:r}):null]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:y?t.jsx("div",{className:"h-full",style:{animation:"oc-surface-content-in 200ms ease-out"},children:p}):null}),t.jsx("style",{children:"@keyframes oc-surface-content-in { from { opacity: 0 } to { opacity: 1 } }"})]});return x?is.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:b?1:0,paddingLeft:u==="chat"?"max(1rem, var(--oc-chat-inset-left, 0px))":"1rem",paddingRight:u==="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:N=>N.stopPropagation(),children:E})}),h.current):is.createPortal(E,h.current)},nf=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/,""),rf=n=>{const e=me.c(36),{worktree:s,onDelete:i}=n,{t:r}=be();let o;e[0]!==s.path?(o={id:s.path},e[0]=s.path,e[1]=o):o=e[1];const{attributes:l,listeners:c,setNodeRef:m,transform:a,transition:u,isDragging:p}=lr(o);let g;e[2]!==a?(g=cr.Transform.toString(a),e[2]=a,e[3]=g):g=e[3];const h=p?10:1;let b;e[4]!==g||e[5]!==h||e[6]!==u?(b={transform:g,transition:u,zIndex:h},e[4]=g,e[5]=h,e[6]=u,e[7]=b):b=e[7];const S=b,y=s.branch||s.label||s.path,I=p&&"shadow-lg shadow-black/20";let v;e[8]!==I?(v=X("flex items-center gap-1 rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",I),e[8]=I,e[9]=v):v=e[9];let C;e[10]!==y||e[11]!==r?(C=r("mobile.projectEdit.dragWorktreeAria",{label:y}),e[10]=y,e[11]=r,e[12]=C):C=e[12];let A;e[13]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx(Qn,{className:"size-4"}),e[13]=A):A=e[13];let x;e[14]!==l||e[15]!==c||e[16]!==C?(x=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":C,...l,...c,children:A}),e[14]=l,e[15]=c,e[16]=C,e[17]=x):x=e[17];let E;e[18]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx(Y,{name:"node-tree",className:"size-4 shrink-0 text-muted-foreground"}),e[18]=E):E=e[18];let N;e[19]!==y?(N=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:y}),e[19]=y,e[20]=N):N=e[20];let R;e[21]!==y||e[22]!==r?(R=r("mobile.projectEdit.deleteWorktreeAria",{label:y}),e[21]=y,e[22]=r,e[23]=R):R=e[23];let k,D;e[24]===Symbol.for("react.memo_cache_sentinel")?(k={touchAction:"manipulation"},D=t.jsx(Xs,{className:"size-4"}),e[24]=k,e[25]=D):(k=e[24],D=e[25]);let z;e[26]!==i||e[27]!==R?(z=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive","aria-label":R,onClick:i,style:k,children:D}),e[26]=i,e[27]=R,e[28]=z):z=e[28];let _;return e[29]!==m||e[30]!==S||e[31]!==N||e[32]!==z||e[33]!==v||e[34]!==x?(_=t.jsxs("div",{ref:m,style:S,className:v,children:[x,E,N,z]}),e[29]=m,e[30]=S,e[31]=N,e[32]=z,e[33]=v,e[34]=x,e[35]=_):_=e[35],_},of=({open:n,project:e,onClose:s,onWorktreesChanged:i})=>{const{t:r}=be(),{currentTheme:o}=qi(),l=Qe(w=>w.updateProjectMeta),c=Qe(w=>w.discoverProjectIcon),m=Qe(w=>w.removeProjectIcon),a=Bn(w=>w.setWorktreeOrder),u=Qe(w=>e?w.projects.find(U=>U.id===e.id)?.iconImage??null:null),[p,g]=f.useState(""),[h,b]=f.useState(null),[S,y]=f.useState(null),[I,v]=f.useState(!1),[C,A]=f.useState([]),[x,E]=f.useState(null),N=e?.id??null;f.useEffect(()=>{!n||!e||(g(e.label),b(e.icon??null),y(e.color??null),A(e.worktrees))},[n,N]),f.useEffect(()=>{!n||!e||A(w=>{const U=e.worktrees.map(W=>W.path),F=w.map(W=>W.path);return U.length===F.length&&U.every(W=>F.includes(W))?w:e.worktrees})},[e?.worktrees]);const R=er(as(sr,{activationConstraint:{distance:8}}),as(tr,{coordinateGetter:ir})),k=()=>{if(!e)return;const w=p.trim();l(e.id,{label:w||e.label,icon:h,color:S}),s()},D=()=>{!e||I||(v(!0),c(e.id).then(w=>{if(!w.ok){ve.error(w.error||r("projectEditDialog.toast.failedToDiscoverIcon"));return}if(w.skipped){ve.success(r("projectEditDialog.toast.customIconAlreadySet"));return}ve.success(r("projectEditDialog.toast.iconDiscovered"))}).finally(()=>v(!1)))},z=()=>{e&&m(e.id).then(w=>{if(!w.ok){ve.error(w.error||r("projectEditDialog.toast.failedToRemoveIcon"));return}ve.success(r("projectEditDialog.toast.iconRemoved"))})},_=w=>{const{active:U,over:F}=w;if(!F||U.id===F.id||!e)return;const B=C.findIndex($=>$.path===U.id),W=C.findIndex($=>$.path===F.id);if(B<0||W<0)return;const Q=[...C],[J]=Q.splice(B,1);Q.splice(W,0,J),A(Q),a(e.id,Q.map($=>nf($.path)))},j=S?Ji[S]??null:null,P=h?Hi[h]:null,V=!!u;return t.jsxs(t.Fragment,{children:[t.jsx(Xt,{open:n,onClose:s,title:r("projectEditDialog.title"),ariaLabel:r("projectEditDialog.title"),noHeaderBorder:!0,trailing:t.jsxs(ke,{type:"button",variant:"default",size:"sm","aria-label":r("projectEditDialog.actions.save"),onClick:k,disabled:!p.trim(),style:{touchAction:"manipulation"},children:[t.jsx(co,{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:V?t.jsx(Yi,{project:{id:e.id,iconImage:u},options:{themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},className:"size-full object-contain",fallback:t.jsx(Dn,{className:"size-7"})}):P?t.jsx(Y,{name:P,className:"size-7",style:j?{color:j}:void 0}):t.jsx(Dn,{className:"size-7",style:j?{color:j}:void 0})})}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("projectEditDialog.field.name")}),t.jsx(eo,{value:p,onChange:w=>g(w.target.value),placeholder:r("projectEditDialog.field.namePlaceholder"),className:"h-11"}),t.jsx("p",{className:"truncate typography-meta text-muted-foreground",title:e.path,children:e.path})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("projectEditDialog.field.color")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>y(null),"aria-label":r("projectEditDialog.option.none"),className:X("flex size-9 items-center justify-center rounded-xl border-2 transition-all",S===null?"border-foreground":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx("span",{className:"h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40"})}),Ga.map(w=>t.jsx("button",{type:"button",onClick:()=>y(w.key),"aria-label":w.label,title:w.label,className:X("size-9 rounded-xl border-2 transition-all",S===w.key?"border-foreground":"border-transparent hover:border-border/70"),style:{backgroundColor:w.cssVar,touchAction:"manipulation"}},w.key))]})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("projectEditDialog.field.icon")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>b(null),"aria-label":r("projectEditDialog.option.none"),className:X("flex size-9 items-center justify-center rounded-xl border-2 transition-all",h===null?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx("span",{className:"h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40"})}),Ka.map(w=>t.jsx("button",{type:"button",onClick:()=>b(w.key),"aria-label":w.label,title:w.label,className:X("flex size-9 items-center justify-center rounded-xl border-2 transition-all",h===w.key?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx(Y,{name:w.Icon,className:"size-4",style:j?{color:j}:void 0})},w.key))]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[t.jsx(ke,{size:"sm",variant:"outline",onClick:D,disabled:I,children:r(I?"projectEditDialog.actions.discovering":"projectEditDialog.actions.discoverFavicon")}),V?t.jsx(ke,{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")}),C.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(nr,{sensors:R,collisionDetection:rr,onDragEnd:_,children:t.jsx(or,{items:C.map(w=>w.path),strategy:ar,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:C.map(w=>t.jsx(rf,{worktree:w,onDelete:()=>E(w)},w.path))})})})]})]}):null]}):null}),e?t.jsx(Do,{open:!!x,project:{id:e.id,path:e.path},worktree:x,onClose:()=>E(null),onDeleted:()=>{A(w=>w.filter(U=>U.path!==x?.path)),i?.()}}):null]})},af=32,lf=80,cf=64,uf=.7,xr=(n,e)=>{const s=f.useRef(e);s.current=e;const i=e.enabled??!0;f.useEffect(()=>{if(!i)return;const r=n.current;if(!r)return;const l=window.Capacitor?.getPlatform?.()==="android"?lf:af,c=r.ownerDocument;let m=!1,a=!1,u=0,p=0;const g=()=>c.getSelection()?.isCollapsed===!1,h=()=>{m=!1},b=()=>{m&&g()&&h()},S=I=>{if(I.touches.length!==1||g()){m=!1;return}const v=I.touches[0],C=r.clientWidth,A=v.clientX<=l,x=v.clientX>=C-l;m=A||x,a=A,u=v.clientX,p=v.clientY},y=I=>{if(!m||(m=!1,g()))return;const v=I.changedTouches[0];if(!v)return;const C=v.clientX-u,A=v.clientY-p;Math.abs(C)<cf||Math.abs(A)>Math.abs(C)*uf||a&&C<=0||!a&&C>=0||(a?s.current.onLeftEdgeSwipe?.():s.current.onRightEdgeSwipe?.())};return r.addEventListener("touchstart",S,{passive:!0}),r.addEventListener("touchend",y,{passive:!0}),r.addEventListener("touchcancel",h,{passive:!0}),r.addEventListener("selectstart",h),c.addEventListener("selectionchange",b),()=>{r.removeEventListener("touchstart",S),r.removeEventListener("touchend",y),r.removeEventListener("touchcancel",h),r.removeEventListener("selectstart",h),c.removeEventListener("selectionchange",b)}},[i,n])},df=new Set,ff=[["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"]],mf=[["projects","mobile.sessions.viewMode.projects"],["timeline","mobile.sessions.viewMode.timeline"]],pf=7,hf=3,Jt=40,ys="openchamber:work",vs="openchamber:recent",gf=12,bf=16,xf=(n,e)=>{const s=ze(n),i=ze(e),r=i.endsWith("/")?i:`${i}/`;return!!(s&&i&&(s===i||s.startsWith(r)))},En=(n,e)=>n.worktrees.find(s=>ze(s.path)===e)??null,In=(n,e,s)=>to([n.title,n.id,ft(n),e],s),yf=n=>{const e=me.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},wi=n=>{const e=me.c(12),{onClick:s,className:i}=n,{t:r}=be();let o;e[0]!==r?(o=r("sessions.sidebar.project.actions.newWorktree"),e[0]=r,e[1]=o):o=e[1];const l=o;let c;e[2]!==i?(c=X("flex size-9 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",i),e[2]=i,e[3]=c):c=e[3];let m;e[4]!==s?(m=g=>{g.stopPropagation(),s()},e[4]=s,e[5]=m):m=e[5];let a,u;e[6]===Symbol.for("react.memo_cache_sentinel")?(a={touchAction:"manipulation"},u=t.jsx(Y,{name:"node-tree",className:"size-4"}),e[6]=a,e[7]=u):(a=e[6],u=e[7]);let p;return e[8]!==l||e[9]!==c||e[10]!==m?(p=t.jsx("button",{type:"button",className:c,"aria-label":l,title:l,onClick:m,style:a,children:u}),e[8]=l,e[9]=c,e[10]=m,e[11]=p):p=e[11],p},An=n=>{const e=me.c(10),{label:s,onClick:i,className:r}=n;let o;e[0]!==r?(o=X("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 l;e[2]!==i?(l=u=>{u.stopPropagation(),i()},e[2]=i,e[3]=l):l=e[3];let c,m;e[4]===Symbol.for("react.memo_cache_sentinel")?(c={touchAction:"manipulation"},m=t.jsx(Y,{name:"add",className:"size-4"}),e[4]=c,e[5]=m):(c=e[4],m=e[5]);let a;return e[6]!==s||e[7]!==o||e[8]!==l?(a=t.jsx("button",{type:"button",className:o,"aria-label":s,title:s,onClick:l,style:c,children:m}),e[6]=s,e[7]=o,e[8]=l,e[9]=a):a=e[9],a},ji=n=>{const e=me.c(81),{session:s,active:i,indent:r,contextLabel:o,statusOnRight:l,hasChildren:c,expanded:m,onToggleChildren:a,onSelect:u,revealed:p,onRevealedChange:g,confirmingDelete:h,onArchive:b,onRequestDelete:S,onConfirmDelete:y,renaming:I,onRequestRename:v,onSubmitRename:C,onCancelRename:A,work:x,pin:E,descendantIdsOf:N}=n,R=l===void 0?!1:l,k=c===void 0?!1:c,D=m===void 0?!1:m,z=p===void 0?!1:p,_=h===void 0?!1:h,j=I===void 0?!1:I,{t:P}=be();let V;e[0]!==s?(V=ln(Oo(s)),e[0]=s,e[1]=V):V=e[1];const w=V;let U;e[2]!==s.title||e[3]!==P?(U=s.title?.trim()||P("mobile.sessions.untitled"),e[2]=s.title,e[3]=P,e[4]=U):U=e[4];const F=U,B=!!(g&&b),W=ao(s.id,s.directory,B&&(z||j)),Q=Un(s.id),J=Gn(s.id),$=!J&&Q>0&&!i,te=Kn(s.id,J),fe=(J||$)&&te;let ae;e[5]!==J||e[6]!==s||e[7]!==x?.inWork?(ae=!!x?.inWork&&!J&&el(s),e[5]=J,e[6]=s,e[7]=x?.inWork,e[8]=ae):ae=e[8];const ne=ae;let le;e[9]!==N||e[10]!==D||e[11]!==k||e[12]!==s.id?(le=N&&!(k&&D)?[s.id,...N(s.id)]:[s.id],e[9]=N,e[10]=D,e[11]=k,e[12]=s.id,e[13]=le):le=e[13];const Z=Fo(le);let ee;e[14]!==W||e[15]!==D||e[16]!==k||e[17]!==r||e[18]!==J||e[19]!==a||e[20]!==$||e[21]!==R||e[22]!==P?(ee=!R&&(W.pending||J||$||k&&a)?t.jsx("button",{type:"button",className:"absolute z-10 flex w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:{left:Math.max(r-32,2),top:0,bottom:0,touchAction:"manipulation"},"aria-label":W.pending?P("sessions.aiRename.generating"):P(D?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),disabled:!k||!a,onClick:Re=>{Re.stopPropagation(),a?.()},children:W.pending?t.jsx(Y,{name:"loader-4",className:"size-3 animate-spin text-primary","aria-label":P("sessions.aiRename.generating")}):J||$?t.jsx(Ys,{state:J?"running":"unread",label:P(J?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread")}):t.jsx(Zn,{className:X("size-[18px] transition-transform duration-150",D?"rotate-0":"-rotate-90")})}):null,e[14]=W,e[15]=D,e[16]=k,e[17]=r,e[18]=J,e[19]=a,e[20]=$,e[21]=R,e[22]=P,e[23]=ee):ee=e[23];let oe;e[24]!==i||e[25]!==W||e[26]!==o||e[27]!==r||e[28]!==J||e[29]!==A||e[30]!==g||e[31]!==u||e[32]!==C||e[33]!==Z||e[34]!==E?.pinned||e[35]!==j||e[36]!==z||e[37]!==s||e[38]!==fe||e[39]!==ne||e[40]!==$||e[41]!==R||e[42]!==P||e[43]!==w||e[44]!==F?(oe=j&&C&&A?t.jsx(_o,{initialTitle:F,indent:r,aiRename:W,onSubmit:C,onCancel:A}):t.jsx("button",{type:"button",className:X("flex min-w-0 flex-1 items-center gap-2.5 pr-3.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",o?"min-h-10 py-1":"h-9"),style:{paddingLeft:r,touchAction:"manipulation"},onClick:()=>{if(z){g?.(!1);return}u()},children:t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[t.jsxs("span",{className:"flex items-center gap-2.5",children:[t.jsx("span",{className:X("block min-w-0 flex-1 truncate typography-ui-label",i?"text-primary":"text-foreground"),children:F}),E?.pinned?t.jsx(Y,{name:"pushpin",className:"size-3 shrink-0 text-muted-foreground","aria-label":P("sessions.sidebar.session.status.pinned")}):null,R&&(W.pending||J||$)?W.pending?t.jsx(Y,{name:"loader-4",className:"size-3 shrink-0 animate-spin text-primary","aria-label":P("sessions.aiRename.generating")}):t.jsx(Ys,{state:J?"running":"unread",label:P(J?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread")}):null,ne?t.jsx(Y,{name:"check",className:"size-3.5 shrink-0 text-muted-foreground","aria-label":P("sessions.sidebar.session.work.doneSuggested")}):null,t.jsx(Lo,{session:s}),t.jsx($o,{...Z}),fe?t.jsx(Xn,{sessionId:s.id,running:J,className:"typography-micro"}):w?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:w}):null]}),o?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:o}):null]})}),e[24]=i,e[25]=W,e[26]=o,e[27]=r,e[28]=J,e[29]=A,e[30]=g,e[31]=u,e[32]=C,e[33]=Z,e[34]=E?.pinned,e[35]=j,e[36]=z,e[37]=s,e[38]=fe,e[39]=ne,e[40]=$,e[41]=R,e[42]=P,e[43]=w,e[44]=F,e[45]=oe):oe=e[45];let H;e[46]!==ee||e[47]!==oe?(H=t.jsxs(t.Fragment,{children:[ee,oe]}),e[46]=ee,e[47]=oe,e[48]=H):H=e[48];const ie=H;if(!B){const Re=i||void 0,xe=i&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let Ce;e[49]!==xe?(Ce=X("relative flex items-center gap-1 transition-colors",xe),e[49]=xe,e[50]=Ce):Ce=e[50];let Ae;e[51]!==ie||e[52]!==Ce?(Ae=t.jsx("div",{className:Ce,children:ie}),e[51]=ie,e[52]=Ce,e[53]=Ae):Ae=e[53];let Pe;return e[54]!==Re||e[55]!==Ae?(Pe=t.jsx("div",{"data-active-session":Re,className:"relative overflow-hidden",children:Ae}),e[54]=Re,e[55]=Ae,e[56]=Pe):Pe=e[56],Pe}const ce=Mo+(x?Ps:0)+(E?Ps:0);let he;e[57]!==g?(he=Re=>g?.(Re),e[57]=g,e[58]=he):he=e[58];const we=i&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let q;e[59]!==we?(q=X("relative flex w-full items-center gap-1 bg-background transition-colors",we),e[59]=we,e[60]=q):q=e[60];let ue;e[61]!==_||e[62]!==b||e[63]!==y||e[64]!==S||e[65]!==v||e[66]!==g||e[67]!==E||e[68]!==z||e[69]!==s.id||e[70]!==F||e[71]!==x?(ue=t.jsx(zo,{sessionId:s.id,title:F,revealed:z,confirmingDelete:_,onArchive:b,onRequestDelete:S,onConfirmDelete:y,onRequestRename:v,onRevealedChange:g,work:x,pin:E}),e[61]=_,e[62]=b,e[63]=y,e[64]=S,e[65]=v,e[66]=g,e[67]=E,e[68]=z,e[69]=s.id,e[70]=F,e[71]=x,e[72]=ue):ue=e[72];let Ee;return e[73]!==i||e[74]!==z||e[75]!==ie||e[76]!==ce||e[77]!==he||e[78]!==q||e[79]!==ue?(Ee=t.jsx(nn,{actionsWidth:ce,revealed:z,onRevealedChange:he,dataActiveSession:i,contentClassName:q,actions:ue,children:ie}),e[73]=i,e[74]=z,e[75]=ie,e[76]=ce,e[77]=he,e[78]=q,e[79]=ue,e[80]=Ee):Ee=e[80],Ee},ki=[],vf=n=>{const e=me.c(40),{run:s,laneNodes:i,indent:r}=n,{t:o}=be();let l;e[0]!==s.key?(l=z=>z.runOverviewKey===s.key,e[0]=s.key,e[1]=l):l=e[1];const c=$e(l);let m;e[2]!==i?(m={nodes:i,includeUnreadSubtasks:!1},e[2]=i,e[3]=m):m=e[3];const a=oo(m);let u;e[4]!==s.lastActivity?(u=ln(s.lastActivity),e[4]=s.lastActivity,e[5]=u):u=e[5];const p=u,g=c||void 0,h=c&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let b;e[6]!==h?(b=X("relative flex items-center overflow-hidden transition-colors",h),e[6]=h,e[7]=b):b=e[7];let S;e[8]!==a||e[9]!==r?(S=a?t.jsx("span",{className:"absolute flex w-6 items-center justify-center",style:{left:Math.max(r-32,2),top:0,bottom:0},children:t.jsx(lo,{state:a})}):null,e[8]=a,e[9]=r,e[10]=S):S=e[10];let y;e[11]!==r?(y={paddingLeft:r,touchAction:"manipulation"},e[11]=r,e[12]=y):y=e[12];let I;e[13]!==s.key?(I=()=>$e.getState().setRunOverviewKey(s.key),e[13]=s.key,e[14]=I):I=e[14];let v;e[15]!==s.title||e[16]!==o?(v=o("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[15]=s.title,e[16]=o,e[17]=v):v=e[17];let C;e[18]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx(Zi,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[18]=C):C=e[18];const A=c?"text-primary":"text-foreground";let x;e[19]!==A?(x=X("block min-w-0 flex-1 truncate typography-ui-label",A),e[19]=A,e[20]=x):x=e[20];let E;e[21]!==s.title||e[22]!==x?(E=t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[C,t.jsx("span",{className:x,children:s.title})]}),e[21]=s.title,e[22]=x,e[23]=E):E=e[23];let N;e[24]!==s.providerIDs?(N=t.jsx(Bo,{providerIDs:s.providerIDs}),e[24]=s.providerIDs,e[25]=N):N=e[25];let R;e[26]!==p?(R=p?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:p}):null,e[26]=p,e[27]=R):R=e[27];let k;e[28]!==v||e[29]!==E||e[30]!==N||e[31]!==R||e[32]!==y||e[33]!==I?(k=t.jsxs("button",{type:"button",className:"flex h-9 w-full min-w-0 items-center gap-2.5 pr-3.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:y,onClick:I,"aria-label":v,children:[E,N,R]}),e[28]=v,e[29]=E,e[30]=N,e[31]=R,e[32]=y,e[33]=I,e[34]=k):k=e[34];let D;return e[35]!==k||e[36]!==g||e[37]!==b||e[38]!==S?(D=t.jsxs("div",{"data-active-session":g,className:b,children:[S,k]}),e[35]=k,e[36]=g,e[37]=b,e[38]=S,e[39]=D):D=e[39],D},wf=n=>{const e=me.c(11),{indent:s,onClick:i}=n,{t:r}=be();let o;e[0]!==s?(o={paddingLeft:s,touchAction:"manipulation"},e[0]=s,e[1]=o):o=e[1];let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx(Zn,{className:"size-4"}),e[2]=l):l=e[2];let c;e[3]!==r?(c=r("sessions.sidebar.group.showMore"),e[3]=r,e[4]=c):c=e[4];let m;e[5]!==c?(m=t.jsx("span",{className:"typography-micro",children:c}),e[5]=c,e[6]=m):m=e[6];let a;return e[7]!==i||e[8]!==o||e[9]!==m?(a=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pr-3 text-left text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:o,onClick:i,children:[l,m]}),e[7]=i,e[8]=o,e[9]=m,e[10]=a):a=e[10],a},jf=n=>{const e=me.c(11),{indent:s,onClick:i}=n,{t:r}=be();let o;e[0]!==s?(o={paddingLeft:s,touchAction:"manipulation"},e[0]=s,e[1]=o):o=e[1];let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx(su,{className:"size-4"}),e[2]=l):l=e[2];let c;e[3]!==r?(c=r("sessions.sidebar.group.showFewer"),e[3]=r,e[4]=c):c=e[4];let m;e[5]!==c?(m=t.jsx("span",{className:"typography-micro",children:c}),e[5]=c,e[6]=m):m=e[6];let a;return e[7]!==i||e[8]!==o||e[9]!==m?(a=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pr-3 text-left text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:o,onClick:i,children:[l,m]}),e[7]=i,e[8]=o,e[9]=m,e[10]=a):a=e[10],a},kf=n=>{const e=me.c(29),{worktree:s}=n,{t:i}=be();let r;e[0]!==s.path?(r=ze(s.path),e[0]=s.path,e[1]=r):r=e[1];const o=r;let l;e[2]!==o?(l={id:o},e[2]=o,e[3]=l):l=e[3];const{attributes:c,listeners:m,setNodeRef:a,transform:u,transition:p,isDragging:g}=lr(l),h=s.branch||s.label||s.path;let b;e[4]!==u?(b=cr.Transform.toString(u),e[4]=u,e[5]=b):b=e[5];const S=g?10:1;let y;e[6]!==b||e[7]!==S||e[8]!==p?(y={transform:b,transition:p,zIndex:S},e[6]=b,e[7]=S,e[8]=p,e[9]=y):y=e[9];const I=g&&"shadow-lg shadow-black/20";let v;e[10]!==I?(v=X("flex items-center gap-1 rounded-xl bg-background px-1 py-1",I),e[10]=I,e[11]=v):v=e[11];let C;e[12]!==h||e[13]!==i?(C=i("mobile.sessions.dragHandleAria",{label:h}),e[12]=h,e[13]=i,e[14]=C):C=e[14];let A;e[15]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx(Qn,{className:"size-4"}),e[15]=A):A=e[15];let x;e[16]!==c||e[17]!==m||e[18]!==C?(x=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":C,...c,...m,children:A}),e[16]=c,e[17]=m,e[18]=C,e[19]=x):x=e[19];let E;e[20]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx(Y,{name:"git-branch",className:"size-4 shrink-0 text-muted-foreground"}),e[20]=E):E=e[20];let N;e[21]!==h?(N=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]=N):N=e[22];let R;return e[23]!==a||e[24]!==x||e[25]!==N||e[26]!==y||e[27]!==v?(R=t.jsxs("div",{ref:a,style:y,className:v,children:[x,E,N]}),e[23]=a,e[24]=x,e[25]=N,e[26]=y,e[27]=v,e[28]=R):R=e[28],R},Sf=n=>{const e=me.c(61),{project:s,totalSessions:i,expanded:r,onToggleExpanded:o,onReorderWorktrees:l}=n,{t:c}=be();let m;e[0]!==s.id?(m={id:s.id},e[0]=s.id,e[1]=m):m=e[1];const{attributes:a,listeners:u,setNodeRef:p,transform:g,transition:h,isDragging:b}=lr(m);let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S={activationConstraint:{distance:8}},e[2]=S):S=e[2];let y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y={coordinateGetter:ir},e[3]=y):y=e[3];const I=er(as(sr,S),as(tr,y)),v=s.worktrees.length>0;let C;e[4]!==l||e[5]!==s.worktrees?(C=te=>{const{active:fe,over:ae}=te;if(!ae||fe.id===ae.id)return;const ne=s.worktrees.map(Ef),le=ne.indexOf(String(fe.id)),O=ne.indexOf(String(ae.id));if(le<0||O<0)return;const Z=[...ne],[ee]=Z.splice(le,1);Z.splice(O,0,ee),l(Z)},e[4]=l,e[5]=s.worktrees,e[6]=C):C=e[6];const A=C;let x;e[7]!==g?(x=cr.Transform.toString(g),e[7]=g,e[8]=x):x=e[8];const E=b?10:1;let N;e[9]!==x||e[10]!==E||e[11]!==h?(N={transform:x,transition:h,zIndex:E},e[9]=x,e[10]=E,e[11]=h,e[12]=N):N=e[12];const R=b&&"shadow-lg shadow-black/20";let k;e[13]!==R?(k=X("rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",R),e[13]=R,e[14]=k):k=e[14];let D;e[15]!==s.label||e[16]!==c?(D=c("mobile.sessions.dragHandleAria",{label:s.label}),e[15]=s.label,e[16]=c,e[17]=D):D=e[17];let z;e[18]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx(Qn,{className:"size-4"}),e[18]=z):z=e[18];let _;e[19]!==a||e[20]!==u||e[21]!==D?(_=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":D,...a,...u,children:z}),e[19]=a,e[20]=u,e[21]=D,e[22]=_):_=e[22];let j;e[23]!==r||e[24]!==s.label||e[25]!==c?(j=r?c("sessions.sidebar.group.collapseAria",{label:s.label}):c("sessions.sidebar.group.expandAria",{label:s.label}),e[23]=r,e[24]=s.label,e[25]=c,e[26]=j):j=e[26];const P=!v;let V;e[27]===Symbol.for("react.memo_cache_sentinel")?(V={touchAction:"manipulation"},e[27]=V):V=e[27];let w;e[28]!==s?(w=t.jsx(As,{project:s}),e[28]=s,e[29]=w):w=e[29];let U;e[30]!==s.label?(U=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]=U):U=e[31];let F;e[32]!==i?(F=t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:i}),e[32]=i,e[33]=F):F=e[33];let B;e[34]!==r||e[35]!==v?(B=v?t.jsx(Zn,{className:X("size-4 shrink-0 text-muted-foreground transition-transform",r&&"rotate-180")}):null,e[34]=r,e[35]=v,e[36]=B):B=e[36];let W;e[37]!==r||e[38]!==o||e[39]!==j||e[40]!==P||e[41]!==w||e[42]!==U||e[43]!==F||e[44]!==B?(W=t.jsxs("button",{type:"button",className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 rounded-xl px-1 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:o,"aria-expanded":r,"aria-label":j,disabled:P,style:V,children:[w,U,F,B]}),e[37]=r,e[38]=o,e[39]=j,e[40]=P,e[41]=w,e[42]=U,e[43]=F,e[44]=B,e[45]=W):W=e[45];let Q;e[46]!==_||e[47]!==W?(Q=t.jsxs("div",{className:"flex items-center gap-1",children:[_,W]}),e[46]=_,e[47]=W,e[48]=Q):Q=e[48];let J;e[49]!==r||e[50]!==A||e[51]!==v||e[52]!==s.worktrees||e[53]!==I?(J=r&&v?t.jsx(nr,{sensors:I,collisionDetection:rr,onDragEnd:A,children:t.jsx(or,{items:s.worktrees.map(If),strategy:ar,children:t.jsx("div",{className:"mt-1 flex flex-col gap-0.5 pl-3",children:s.worktrees.map(Af)})})}):null,e[49]=r,e[50]=A,e[51]=v,e[52]=s.worktrees,e[53]=I,e[54]=J):J=e[54];let $;return e[55]!==p||e[56]!==Q||e[57]!==J||e[58]!==N||e[59]!==k?($=t.jsxs("div",{ref:p,style:N,className:k,children:[Q,J]}),e[55]=p,e[56]=Q,e[57]=J,e[58]=N,e[59]=k,e[60]=$):$=e[60],$},Si=({open:n,onOpenChange:e,variant:s="drawer",footer:i})=>{const{t:r}=be(),{git:o}=Hn(),l=Xe(d=>d.ensureStatus),c=Gi(),m=ss(d=>d.activeSessions),a=n||s==="sidebar",u=f.useRef(df),p=Tn(f.useCallback(d=>(a&&(u.current=d.ids),u.current),[a])),g=f.useRef(qa),h=Fi(f.useCallback(d=>(a&&(g.current=d.rankById),g.current),[a])),b=Qe(d=>d.projects),S=Ha(d=>d.projects),y=Qe(d=>d.activeProjectId),I=Nt(d=>d.currentDirectory),v=De(d=>d.currentSessionId),C=De(d=>d.setCurrentSession),A=De(d=>d.archiveSession),x=De(d=>d.archiveSessions),E=De(d=>d.deleteSession),N=De(d=>d.deleteSessions),R=De(d=>d.updateSessionTitle),k=De(d=>d.openNewSessionDraft),D=Qe(d=>d.setActiveProject),z=Qe(d=>d.setActiveProjectIdOnly),_=Qe(d=>d.reorderProjects),j=Qe(d=>d.manualProjectOrder),P=qt(d=>d.projectSortOrder),V=qt(d=>d.setProjectSortOrder),w=qt(d=>d.sidebarViewMode),U=qt(d=>d.setSidebarViewMode),F=qt(d=>d.showRecentSection),B=qt(d=>d.setShowRecentSection),W=Tn(d=>d.toggle),Q=w==="projects"&&F,J=Ja(a&&(w==="timeline"||Q)),$=Qe(d=>d.removeProject),te=Gs(d=>d.projectExpanded),fe=Gs(d=>d.worktreeExpanded),ae=Gs(d=>d.setProjectExpanded),ne=Gs(d=>d.setWorktreeExpanded),le=Bn(d=>d.orderByProject),O=Bn(d=>d.setWorktreeOrder),Z=xi(d=>d.expandedParents),ee=xi(d=>d.toggleParent),[oe,H]=f.useState(""),[ie,ce]=f.useState(null),[he,we]=f.useState(null),[q,ue]=f.useState(null),[Ee,Re]=f.useState(null),[xe,Ce]=f.useState(null),[Ae,Pe]=f.useState(null),[_e,Se]=f.useState(null),[Oe,Me]=f.useState(0),[it,kt]=f.useState(!1),[cn,He]=f.useState(!1),[Ze,gt]=f.useState(!1),[bt,xt]=f.useState(null),[Ts,Ds]=f.useState(()=>new Map(De.getState().availableWorktreesByProject)),[Ie,_s]=f.useState(()=>{const d=new Set;for(const[M,L]of De.getState().availableWorktreesByProject)L.length>0&&d.add(M);return d}),[Ve,ot]=f.useState(!1),[un,ms]=f.useState(new Set),[dn,Ot]=f.useState(new Map),[Rt,Ge]=f.useState(Js),at=f.useRef(null);f.useEffect(()=>{if(!n){H(""),ot(!1),ms(new Set),Ot(new Map),Ge(Js),ce(null),we(null),ue(null),Re(null),Ce(null),Pe(null);return}qn(c)},[n]),f.useEffect(()=>{Ve||ms(new Set)},[Ve]),f.useEffect(()=>{Ge(Js)},[w]),f.useEffect(()=>{if(!n||b.length===0)return;let d=!1;return(async()=>{const L=await Promise.all(b.map(async K=>{const re=ze(K.path);if(!re)return null;const pe=await o.checkIsGitRepository(re).catch(()=>null),de=pe?await so({id:K.id,path:re}).catch(()=>null):[];return[re,de,pe]}));d||(Ds(K=>{const re=new Map;for(const pe of L){if(!pe)continue;const[de,Fe,Je]=pe,St=Je===null||Fe===null;re.set(de,St?K.get(de)??[]:Fe)}return no(b,re)}),_s(K=>{const re=new Set;for(const pe of L){if(!pe)continue;const[de,,Fe]=pe;(Fe===null?K.has(de):Fe)&&re.add(de)}return re}))})(),()=>{d=!0}},[o,n,b,Oe]);const je=f.useMemo(()=>dc(b.map(d=>({id:d.id,label:d.label?.trim()||Cn(d.path),path:ze(d.path),icon:d.icon,color:d.color,iconImage:d.iconImage,iconBackground:d.iconBackground,isGitRepo:Ie.has(ze(d.path)),worktrees:Vd(le[d.id],Ts.get(ze(d.path))??[]),addedAt:d.addedAt,lastOpenedAt:d.lastOpenedAt})),P,j),[Ie,j,P,b,le,Ts]),Be=f.useMemo(()=>{const d=new Map(c.map(K=>[K.id,K])),M=m.map(K=>{const re=d.get(K.id);return re?Ya(re,K):K}),L=new Set(M.map(K=>K.id));for(const K of c)L.has(K.id)||M.push(K);return M.filter(K=>!K.time?.archived)},[m,c]),ut=f.useMemo(()=>{const d=new Map;for(const M of Be){const L=ct(M);if(!L)continue;const K=d.get(L)??[];K.push(M),d.set(L,K)}return d},[Be]),Ms=f.useCallback(d=>Us(ut,d),[ut]),{projectSessions:Te,chatSessions:Bt}=f.useMemo(()=>fc(Be,!1),[Be]),Lt=$e(d=>d.sessionWorkEnabled),Ke=f.useMemo(()=>{const d=new Set;if(!Lt)return d;for(const M of Be)if(!(ct(M)||jn(ft(M))||!Qi(M))){d.add(M.id);for(const L of Us(ut,M.id))d.add(L)}return d},[ut,Lt,Be]),yt=f.useMemo(()=>Ke.size>0?Te.filter(d=>!Ke.has(d.id)):Te,[Te,Ke]),$t=f.useMemo(()=>Ke.size>0?Bt.filter(d=>!Ke.has(d.id)):Bt,[Bt,Ke]),et=wa(),Et=f.useMemo(()=>new Map(et.map(d=>[d.id,d])),[et]),pt=f.useMemo(()=>new Map(et.map(d=>[d.id,d.name||r("sessions.sidebar.grouping.spaceUnnamed")])),[et,r]),Ue=f.useMemo(()=>mc(Te,je.map(d=>({id:d.id,normalizedPath:d.path})),new Map(je.map(d=>[d.path,d.worktrees])),!1,[],S,et),[S,Te,je,et]),tt=f.useMemo(()=>Xa(Te,d=>{const M=Ue.bySessionId.get(d.id);return(M?je.find(K=>K.id===M.projectId):void 0)?.path||ze(ft(d))||null}),[Te,je,Ue]),Ft=f.useMemo(()=>{const d=new Map(Be.map(K=>[K.id,K])),M=K=>({session:K,children:(ut.get(K.id)??[]).map(M),worktree:null}),L=new Map;for(const K of tt.runs.values())L.set(K.key,K.memberIds.flatMap(re=>{const pe=d.get(re);return pe?[M(pe)]:[]}));return L},[ut,tt,Be]),Wt=f.useMemo(()=>({key:gs,label:"",path:"",worktree:null,space:null,sessions:Ht($t,p,h)}),[p,$t,h]),fn=f.useMemo(()=>new Set(Wt.sessions.filter(d=>Zr(p,ft(d)||null,d.id)).map(d=>d.id)),[Wt,p]),Vt=f.useMemo(()=>({key:ys,label:"",path:"",worktree:null,space:null,sessions:Ke.size>0?Ht(Be.filter(d=>Ke.has(d.id)),p,h):[]}),[p,h,Be,Ke]),Ut=pc({enabled:a&&Q,isVSCode:!1,pinnedSessionIds:p,sessionOrderRanks:h,sessions:yt}),[Gt,zs]=f.useState(Ut);a&&Gt!==Ut&&zs(Ut);const vt=a?Ut:Gt,Os=f.useMemo(()=>{const d=new Set;for(const M of vt){d.add(M.id);for(const L of Us(ut,M.id))d.add(L)}return{key:vs,label:"",path:"",worktree:null,space:null,sessions:d.size>0?Ht(yt.filter(M=>d.has(M.id)),p,h):[]}},[ut,p,vt,yt,h]),T=f.useMemo(()=>{const d=new Map;if(vt.length===0)return d;const M=ti({sessions:vt,projects:je.map(L=>({id:L.id,normalizedPath:L.path,label:L.label})),ownerBySessionId:Ue.bySessionId,availableWorktreesByProject:new Map(je.map(L=>[L.path,L.worktrees])),gitBranches:J,homeDirectory:null,hideBranchMatchingProjectLabel:!0,spaceLabelById:pt});for(const[L,K]of M)K.projectLabel&&d.set(L,K.branchLabel?`${K.projectLabel} · ${K.branchLabel}`:K.projectLabel);return d},[J,je,vt,Ue,pt]),G=`${gs}::${gs}`,se=f.useMemo(()=>$t.filter(d=>!ct(d)).length,[$t]),ge=oe.trim().toLowerCase(),lt=f.useRef(null);f.useEffect(()=>{if(!n)return;const d=window.requestAnimationFrame(()=>{const M=lt.current;if(!M)return;(M.querySelector('[data-active-session="true"]')??M.querySelector('[data-active-project="true"]'))?.scrollIntoView({block:"center"})});return()=>window.cancelAnimationFrame(d)},[n]);const Kt=f.useMemo(()=>{const d=je.map(L=>({project:L,buckets:[],totalSessions:0,isActive:L.id===y})),M=(L,K,re,pe=null)=>{const de=ze(K)||L.project.path,Fe=de||"__root__";let Je=L.buckets.find(St=>St.key===Fe);return Je||(Je={key:Fe,label:(pe?pe.name||r("sessions.sidebar.grouping.spaceUnnamed"):null)||re?.branch||Cn(de),path:de,worktree:re,space:pe,sessions:[]},L.buckets.push(Je)),Je};for(const L of d){M(L,L.project.path,null);for(const K of L.project.worktrees)M(L,K.path,K);for(const K of et)K.directory&&ze(K.projectDirectory)===ze(L.project.path)&&M(L,K.directory,null,K)}for(const L of yt){const K=Ue.bySessionId.get(L.id);if(!K)continue;const re=d.find(Je=>Je.project.id===K.projectId);if(!re)continue;const pe=En(re.project,K.scopeDirectory),de=K.kind==="space"&&K.spaceId?Et.get(K.spaceId)??null:null;(de?M(re,K.scopeDirectory,null,de):pe&&!tt.runKeyBySessionId.has(L.id)?M(re,pe.path,pe):M(re,re.project.path,null)).sessions.push(L)}for(const L of d)for(const K of L.buckets){K.sessions=Ht(K.sessions,p,h);for(const re of K.sessions)ct(re)||(L.totalSessions+=1)}return d},[y,p,je,tt,yt,h,Ue,et,Et,r]),It=ze(I),mn=d=>d.isActive?It===d.project.path?d.project.path:d.project.worktrees.find(L=>xf(It,L.path))?.path??d.project.path:null,Go=d=>te[d.project.id]??!0,Ko=(d,M)=>fe[`${d.project.id}::${M.key}`]??!0,vr=d=>{Ot(M=>{if(!M.has(d))return M;const L=new Map(M);return L.delete(d),L})},qo=d=>{Ot(M=>{let L=!1;const K=new Map(M),re=`${d}::`;for(const pe of K.keys())pe.startsWith(re)&&(K.delete(pe),L=!0);return L?K:M})},Ho=(d,M,L)=>{Ot(K=>{const re=new Map(K);return re.set(d,M+L),re})},ps=(d,M,L,K)=>{const re=K?.pageSize??pf,pe=K?.alwaysVisibleIds,de=new Set(M.sessions.map(ye=>ye.id)),Fe=new Map;for(const ye of M.sessions){const Ye=ct(ye);if(Ye&&de.has(Ye)){const ht=Fe.get(Ye)??[];ht.push(ye),Fe.set(Ye,ht)}}const Je=M.sessions.filter(ye=>{const Ye=ct(ye);return!Ye||!de.has(Ye)}),St=new Set,bn=Je.flatMap(ye=>{const Ye=tt.runKeyBySessionId.get(ye.id),ht=Ye?tt.runs.get(Ye):void 0;return ht?St.has(ht.key)?[]:(St.add(ht.key),[{kind:"run",run:ht}]):[{kind:"session",session:ye}]}),$r=ye=>ye.kind==="session"&&!!pe?.has(ye.session.id),ua=pe?bn.filter($r):[],xn=pe?bn.filter(ye=>!$r(ye)):bn,da=dn.get(d)??re,yn=xn.slice(0,da),fa=[...ua,...yn],Fr=xn.length-yn.length,ma=xn.length>re&&Fr===0,Wr=(ye,Ye)=>{const ht=Fe.get(ye.id)??[],vn=ht.length>0,Vr=!!Z[ye.id],pa=Ye===L;return t.jsxs(f.Fragment,{children:[t.jsx(ji,{session:ye,active:v===ye.id,indent:Ye,contextLabel:pa?K?.rootContextLabel?.(ye):void 0,hasChildren:vn,expanded:Vr,onToggleChildren:vn?()=>ee(ye.id):void 0,onSelect:()=>pn(ye),statusOnRight:K?.statusOnRight,revealed:he===ye.id,onRevealedChange:hs=>wr(ye.id,hs),confirmingDelete:q===ye.id,onArchive:()=>{kr(ye)},onRequestDelete:()=>ue(ye.id),onConfirmDelete:()=>{Rr(ye)},renaming:Ee===ye.id,onRequestRename:()=>Er(ye.id),onSubmitRename:hs=>{Ir(ye.id,hs)},onCancelRename:()=>Re(null),work:Yo(ye),pin:Xo(ye),descendantIdsOf:Ms}),vn&&Vr?ht.map(hs=>Wr(hs,Ye+bf)):null]},ye.id)};return t.jsxs("div",{children:[fa.map(ye=>ye.kind==="run"?t.jsx(vf,{run:ye.run,laneNodes:Ft.get(ye.run.key)??ki,indent:L},`run:${ye.run.key}`):Wr(ye.session,L)),Fr>0?t.jsx(wf,{indent:L,onClick:()=>Ho(d,yn.length,re)}):null,ma?t.jsx(jf,{indent:L,onClick:()=>vr(d)}):null]})},Bs=(d,M)=>{ae(d,!M),qo(d)},Jo=(d,M,L)=>{ne(`${d}::${M}`,!L),vr(`${d}::${M}`)},pn=d=>{const M=ft(d)||null,L=Ue.bySessionId.get(d.id),K=L?je.find(re=>re.id===L.projectId)??null:null;if(K){z(K.id),ae(K.id,!0);const re=En(K,L?.scopeDirectory??"");re&&ne(`${K.id}::${ze(re.path)}`,!0)}C(d.id,M),e(!1)},wr=(d,M)=>{we(M?d:null),ue(null),Ce(null),Pe(null)},At=(d,M)=>{Ce(M?d:null),Pe(null),we(null),ue(null)},jr=(d,M)=>(we(null),ue(null),yc(d,M,vc(M.id,Us(ut,M.id),d==="delete"),{archiveSession:A,archiveSessions:x,deleteSession:E,deleteSessions:N},r)),kr=d=>jr("archive",d),Sr=async(d,M)=>{try{await tl(d.id,ft(d)||null,M?"done":"open")}catch{ve.error(r("sessions.sidebar.session.work.updateFailed"))}},Yo=d=>{if(!Lt||ct(d)||jn(ft(d)))return;const M=Ke.has(d.id);return{inWork:M,onToggle:()=>{Sr(d,M)}}},Nr=d=>Zr(p,ft(d)||null,d.id),Cr=d=>{const M=ft(d);M&&W({directory:M,sessionId:d.id})},Xo=d=>{if(!(ct(d)||!ft(d)))return{pinned:Nr(d),onToggle:()=>Cr(d)}},Rr=d=>jr("delete",d),Er=d=>{we(null),ue(null),Re(d)},Ir=async(d,M)=>{Re(null);try{await R(d,M)}catch{ve.error(r("mobile.sessions.renameError"))}},Ar=()=>{k(),e(!1)},Pr=d=>{xt(d),z(d),gt(!0)},Qo=er(as(sr,{activationConstraint:{distance:8}}),as(tr,{coordinateGetter:ir})),Zo=d=>{V(d),wn({sidebarProjectSortOrder:d}),d!=="manual"&&ot(!1)},ea=d=>{U(d),wn({sidebarViewMode:d}),d==="timeline"&&ot(!1)},ta=()=>{const d=!F;B(d),wn({sidebarShowRecentSection:d})},sa=d=>{const{active:M,over:L}=d;if(!L||M.id===L.id)return;const K=je.findIndex(pe=>pe.id===M.id),re=je.findIndex(pe=>pe.id===L.id);K<0||re<0||_(K,re)},na=d=>{ms(M=>{const L=new Set(M);return L.has(d)?L.delete(d):L.add(d),L})},Tr=f.useCallback(d=>{const M=ft(d);if(jn(M))return r("mobile.sessions.section.chats");const L=Ue.bySessionId.get(d.id),K=L?je.find(de=>de.id===L.projectId)??null:null;if(!K)return Cn(M)||M;const re=L?.kind==="space"&&L.spaceId?Et.get(L.spaceId):void 0;if(re)return`${K.label} · ${re.name||r("sessions.sidebar.grouping.spaceUnnamed")}`;const pe=En(K,L?.scopeDirectory??"");return pe?.branch?`${K.label} · ${pe.branch}`:K.label},[je,Ue,Et,r]),ra=d=>{D(d.id),e(!1)},Dr=d=>{z(d.id),k({selectedProjectId:d.id,directoryOverride:d.path}),e(!1)},ia=f.useMemo(()=>ge?Kt.filter(d=>to([d.project.label,d.project.path],ge)?!0:d.buckets.some(M=>M.sessions.some(L=>In(L,d.project.label,ge)))):Kt,[ge,Kt]),Ls=f.useMemo(()=>ge?Ht(Be.filter(d=>{if(ct(d))return!1;const M=Ue.bySessionId.get(d.id),L=M?je.find(K=>K.id===M.projectId)??null:null;return In(d,L?.label??"",ge)}),p,h):[],[ge,p,je,h,Ue,Be]),$s=f.useMemo(()=>ge?Qa(je,ge,d=>[d.label,d.path]):[],[ge,je]),dt=w==="timeline"&&!ge&&!Ve,_r=dt||Q;f.useEffect(()=>{if(!(!_r||!o))for(const d of je){const M=ze(d.path);M&&Za(()=>l(M,o))}},[l,o,_r,je]);const hn=f.useMemo(()=>{const d=new Map;if(!dt)return d;const M=ti({sessions:Te,projects:je.map(L=>({id:L.id,normalizedPath:L.path,label:L.label})),ownerBySessionId:Ue.bySessionId,availableWorktreesByProject:new Map(je.map(L=>[L.path,L.worktrees])),gitBranches:J,homeDirectory:null,hideBranchMatchingProjectLabel:!1,spaceLabelById:pt});for(const L of Te){if(ct(L))continue;const K=M.get(L.id),re=K?je.find(pe=>pe.id===K.projectId):null;!re||!K||d.set(L.id,{project:re,branch:K.branchLabel})}return d},[J,Te,je,Ue,pt,dt]),gn=f.useMemo(()=>{if(!dt)return[];const d=yt.filter(L=>!ct(L)&&hn.has(L.id)),M=new Set;return Ht(d,p,h).flatMap(L=>{const K=hn.get(L.id);if(!K)return[];const re=tt.runKeyBySessionId.get(L.id),pe=re?tt.runs.get(re):void 0;return pe?M.has(pe.key)?[]:(M.add(pe.key),[{kind:"run",run:pe,laneNodes:Ft.get(pe.key)??ki,project:K.project}]):[{kind:"session",session:L,project:K.project,branch:K.branch}]})},[p,tt,Ft,yt,h,dt,hn]),oa=f.useCallback(()=>{Ge(d=>tf(d,gn.length))},[gn.length]),aa={currentSessionId:v,revealedSessionId:he,confirmingDeleteSessionId:q,renamingSessionId:Ee,onSelect:pn,onRevealedChange:wr,onArchive:d=>{kr(d)},onRequestDelete:ue,onConfirmDelete:d=>{Rr(d)},onRequestRename:Er,onSubmitRename:(d,M)=>{Ir(d,M)},onCancelRename:()=>Re(null),onToggleWork:Lt?(d,M)=>{Sr(d,M)}:void 0,isPinned:Nr,onTogglePin:Cr,descendantIdsOf:Ms},la=ge&&Ls.length===0&&$s.length===0,ca=!ge&&!dt&&je.length>1&&P==="manual",Mr=!Ve&&!ge&&je.length>0?t.jsx(ke,{type:"button",variant:"chip",size:"sm","aria-label":r("sessions.sidebar.header.displayMode.label"),title:r("sessions.sidebar.header.displayMode.label"),onClick:()=>kt(!0),style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"equalizer-2",className:"size-4"})}):null,zr=ca?t.jsx(ke,{type:"button",variant:"chip",size:"sm","aria-label":r(Ve?"mobile.sessions.doneEditing":"mobile.sessions.editOrder"),"aria-pressed":Ve,onClick:()=>ot(d=>!d),style:{touchAction:"manipulation"},children:Ve?t.jsx(co,{className:"size-4"}):t.jsx(_n,{className:"size-4"})}):null,Or=!Ve&&je.length>0?t.jsxs(ke,{type:"button",variant:"default",size:"sm","aria-label":r("mobile.sessions.newChat"),onClick:Ar,style:{touchAction:"manipulation"},children:[t.jsx(tu,{className:"size-4"}),r("mobile.sessions.newChat")]}):null,Br=Ve?null:t.jsx(ke,{type:"button",variant:"chip",size:"sm","aria-label":r("sessions.sidebar.header.actions.addProject"),title:r("sessions.sidebar.header.actions.addProject"),onClick:()=>He(!0),style:{touchAction:"manipulation"},children:t.jsx(si,{className:"size-4"})}),Fs=Or||Br||Mr||zr?t.jsxs(t.Fragment,{children:[Br,Mr,zr,Or]}):null,Lr=t.jsxs("div",{ref:lt,className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs(rn,{ref:at,className:"min-h-0 flex-1 overflow-y-auto pb-4",children:[t.jsx("div",{className:X("px-4 pb-2 pt-1",Ve&&"hidden"),children:t.jsx(hc,{value:oe,onSearch:H,active:n||s==="sidebar",mobile:!0,placeholder:r("mobile.sessions.search.placeholder"),clearLabel:r("mobile.sessions.clearSearchAria")})}),je.length===0&&Bt.length===0?t.jsx(Ri,{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:()=>He(!0),children:[t.jsx(si,{className:"size-4"}),r("sessions.sidebar.header.actions.addProject")]})}):la?t.jsx(Ri,{title:r("mobile.sessions.empty.searchTitle"),description:r("mobile.sessions.empty.searchDescription")}):ge&&!Ve?t.jsxs("div",{className:"flex flex-col gap-3 px-3 pt-2",children:[Ls.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:Ls.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:Ls.map((d,M)=>t.jsx("div",{className:X(M>0&&"border-t border-border/70"),children:t.jsx(ji,{session:d,active:v===d.id,indent:12,contextLabel:Tr(d),onSelect:()=>pn(d)})},d.id))})]}):null,$s.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:$s.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:$s.map((d,M)=>t.jsxs("div",{className:X("flex items-center",M>0&&"border-t border-border/70"),children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-3 px-3 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>ra(d),style:{touchAction:"manipulation"},children:[t.jsx(As,{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(wi,{onClick:()=>Pr(d.id)}):null,t.jsx(An,{className:"mr-2",label:r("mobile.sessions.newSessionInProjectAria",{label:d.label}),onClick:()=>Dr(d)})]},d.id))})]}):null]}):Ve?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(nr,{sensors:Qo,collisionDetection:rr,onDragEnd:sa,children:t.jsx(or,{items:je.map(d=>d.id),strategy:ar,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:je.map(d=>{const M=Kt.find(L=>L.project.id===d.id);return t.jsx(Sf,{project:d,totalSessions:M?.totalSessions??0,expanded:un.has(d.id),onToggleExpanded:()=>na(d.id),onReorderWorktrees:L=>O(d.id,L)},d.id)})})})})]}):t.jsxs("div",{className:"flex flex-col",children:[(()=>{const d=te[gs]??!0,M=r("mobile.sessions.section.chats");return t.jsxs("section",{children:[t.jsxs("div",{className:"flex min-h-12 w-full items-center",children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(xe){At(xe,!1);return}Bs(gs,d)},"aria-expanded":d,"aria-label":d?r("sessions.sidebar.group.collapseAria",{label:M}):r("sessions.sidebar.group.expandAria",{label:M}),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-[var(--surface-muted)] text-muted-foreground",children:t.jsx(Y,{name:"chat-4",className:"size-4"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:M}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:se})]}),Ve?null:t.jsx(An,{className:"mr-2",label:r("mobile.sessions.newChat"),onClick:Ar})]}),d?t.jsx("div",{className:"pb-2",children:Wt.sessions.length>0?ps(G,Wt,dt?gf:Jt,dt?{pageSize:hf,alwaysVisibleIds:fn,statusOnRight:!0}:void 0):t.jsx("p",{className:"px-3 pb-1 typography-micro text-muted-foreground",style:{paddingLeft:Jt},children:r("sessions.sidebar.activity.chatsEmpty")})}):null]})})(),Vt.sessions.length>0?(()=>{const d=te[ys]??!0,M=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-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(xe){At(xe,!1);return}Bs(ys,d)},"aria-expanded":d,"aria-label":d?r("sessions.sidebar.group.collapseAria",{label:M}):r("sessions.sidebar.group.expandAria",{label:M}),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-[var(--surface-muted)] text-muted-foreground",children:t.jsx(Y,{name:"eye",className:"size-4"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:M}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:Vt.sessions.filter(L=>!ct(L)).length})]}),d?t.jsx("div",{className:"pb-2",children:ps(`${ys}::${ys}`,Vt,Jt,{pageSize:Number.MAX_SAFE_INTEGER})}):null]})})():null,!dt&&Os.sessions.length>0?(()=>{const d=te[vs]??!0,M=r("mobile.sessions.section.recent");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-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(xe){At(xe,!1);return}Bs(vs,d)},"aria-expanded":d,"aria-label":d?r("sessions.sidebar.group.collapseAria",{label:M}):r("sessions.sidebar.group.expandAria",{label:M}),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-[var(--surface-muted)] text-muted-foreground",children:t.jsx(Y,{name:"history",className:"size-4"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:M}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:vt.length})]}),d?t.jsx("div",{className:"pb-2",children:ps(`${vs}::${vs}`,Os,Jt,{rootContextLabel:L=>T.get(L.id)??Tr(L)})}):null]})})():null,dt?t.jsx(Zd,{entries:gn,visibleCount:Rt,onRevealMore:oa,scrollRootRef:at,handlers:aa}):null,dt?null:ia.map(d=>{const M=Go(d),L=ge?d.buckets.filter(re=>re.sessions.some(pe=>In(pe,d.project.label,ge))):d.buckets,K=mn(d);return t.jsxs("section",{className:"border-t border-border/70",children:[t.jsx(nn,{actionsWidth:96,revealed:xe===`project:${d.project.id}`,onRevealedChange:re=>At(`project:${d.project.id}`,re),actions:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:xe===`project:${d.project.id}`?0:-1,className:X("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",Ae===d.project.id?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80"),"aria-label":Ae===d.project.id?r("mobile.sessions.confirmRemoveProjectAria",{label:d.project.label}):r("mobile.sessions.removeProjectAria",{label:d.project.label}),onClick:()=>{if(Ae===d.project.id){Ce(null),Pe(null),$(d.project.id),ve.success(r("mobile.sessions.toast.projectRemoved",{label:d.project.label}));return}Pe(d.project.id)},style:{touchAction:"manipulation"},children:t.jsx(Xs,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:xe===`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:()=>{Ce(null),ce(d.project.id)},style:{touchAction:"manipulation"},children:t.jsx(_n,{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-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(xe){At(xe,!1);return}Bs(d.project.id,M)},"aria-expanded":M,"aria-label":M?r("sessions.sidebar.group.collapseAria",{label:d.project.label}):r("sessions.sidebar.group.expandAria",{label:d.project.label}),style:{touchAction:"manipulation"},children:[t.jsx(As,{project:d.project}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:d.project.label})]}),d.project.isGitRepo?t.jsx(wi,{onClick:()=>Pr(d.project.id)}):null,t.jsx(An,{className:"mr-2",label:r("mobile.sessions.newSessionInProjectAria",{label:d.project.label}),onClick:()=>Dr(d.project)})]})}),M?t.jsx("div",{className:"pb-2",children:(()=>{const re=L.find(de=>de.worktree===null&&de.space===null),pe=L.filter(de=>de!==re);return t.jsxs(t.Fragment,{children:[re&&re.sessions.length>0?ps(`${d.project.id}::${re.key}`,re,Jt):null,pe.map(de=>{const Fe=Ko(d,de),Je=K===de.path;return t.jsxs("div",{children:[t.jsx(nn,{actionsWidth:de.space?96:48,revealed:xe===`wt:${de.key}`,onRevealedChange:St=>At(`wt:${de.key}`,St),actions:de.space?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:xe===`wt:${de.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:de.label}),onClick:()=>{Ce(null),de.space&&Gr.getState().openAccessDialog(de.space.id)},style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"key",className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:xe===`wt:${de.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:de.label}),onClick:()=>{Ce(null),de.space&&Gr.getState().openActionsSheet(de.space.id)},style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"more-2",className:"size-[18px]"})})]}):de.worktree?t.jsx("button",{type:"button",tabIndex:xe===`wt:${de.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:de.label}),onClick:()=>{Ce(null),de.worktree&&Se({project:d.project,worktree:de.worktree})},style:{touchAction:"manipulation"},children:t.jsx(Xs,{className:"size-[18px]"})}):null,children:t.jsxs("button",{type:"button",className:"flex min-h-10 w-full items-center gap-2 px-3 py-1 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(xe){At(xe,!1);return}Jo(d.project.id,de.key,Fe)},"aria-expanded":Fe,"aria-label":Fe?r("sessions.sidebar.group.collapseAria",{label:de.label}):r("sessions.sidebar.group.expandAria",{label:de.label}),style:{touchAction:"manipulation"},children:[t.jsx(Y,{name:de.space?"box-3":"git-branch",className:X("size-4 shrink-0",Je?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:X("block min-w-0 flex-1 truncate typography-ui-label font-bold",Je?"text-foreground":"text-muted-foreground"),children:de.label}),Je?t.jsx(yf,{ariaLabel:r("mobile.sessions.activeWorktreeAria")}):null,t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:de.sessions.length})]})}),de.space?t.jsx(gc,{spaceId:de.space.id,className:"px-3 pb-1 pl-9"}):null,Fe?ps(`${d.project.id}::${de.key}`,de,Jt):null]},de.key)})]})})()}):null]},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(ke,{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(Y,{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(ke,{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(Y,{name:"download",className:"size-5"}),t.jsx("span",{className:"absolute right-2 top-2 inline-flex size-2 rounded-full bg-primary","aria-hidden":!0})]}):null,t.jsx(ke,{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(Y,{name:"bar-chart",className:"size-5"})}),t.jsx(ke,{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(Y,{name:"settings-3",className:"size-5"})})]})]}):null,t.jsx(bc,{open:cn,onOpenChange:He}),t.jsx(xc,{open:Ze,onOpenChange:d=>{gt(d),d||xt(null)},onWorktreeCreated:(d,M)=>{M?.sessionId?C(M.sessionId,d):k({selectedProjectId:bt,directoryOverride:d,preserveDirectoryOverride:!0}),e(!1)}}),t.jsx(of,{open:ie!==null,project:je.find(d=>d.id===ie)??null,onClose:()=>ce(null),onWorktreesChanged:()=>Me(d=>d+1)}),t.jsx(Ki,{open:it,onClose:()=>kt(!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")}),mf.map(([d,M])=>t.jsxs("button",{type:"button",className:X("flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-left transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",w===d?"text-primary":"text-foreground"),onClick:()=>{ea(d),kt(!1)},style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label",children:r(M)}),w===d?t.jsx(Y,{name:"check",className:"size-4"}):null]},d)),w==="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")}),w==="timeline"?null:ff.map(([d,M])=>t.jsxs("button",{type:"button",className:X("flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-left transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",P===d?"text-primary":"text-foreground"),onClick:()=>{Zo(d),kt(!1)},style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label",children:r(M)}),P===d?t.jsx(Y,{name:"check",className:"size-4"}):null]},d)),w==="timeline"?null:t.jsxs("button",{type:"button","aria-pressed":F,className:X("mt-2 flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-left transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",F?"text-primary":"text-foreground"),onClick:()=>{ta(),kt(!1)},style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label",children:r("sessions.sidebar.header.displayMode.showRecent")}),F?t.jsx(Y,{name:"check",className:"size-4"}):null]})]})}),_e?t.jsx(Do,{open:!0,project:{id:_e.project.id,path:_e.project.path},worktree:_e.worktree,onClose:()=>Se(null),onDeleted:()=>Me(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")}),Fs?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:Fs}):null]}),Lr]}):null:t.jsxs(Rf,{open:n,onClose:()=>e(!1),onSwipeClose:()=>{if(he||xe){we(null),Ce(null),ue(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:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":r("mobile.surface.closeAria"),onClick:()=>e(!1),style:{touchAction:"manipulation"},children:t.jsx(Y,{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")}),Fs?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:Fs}):null]}),Lr]})},Ni="mobile-surface-root",Nf=16,Ci=320,Cf="cubic-bezier(0.22, 1, 0.36, 1)",Rf=({open:n,onClose:e,onSwipeClose:s,ariaLabel:i,children:r})=>{const o=f.useRef(null),l=f.useRef(null),[c,m]=f.useState(!1),[a,u]=f.useState(n),p=f.useRef(e);f.useEffect(()=>{p.current=e},[e]);const g=f.useRef(s);if(f.useEffect(()=>{g.current=s},[s]),xr(l,{enabled:n,onRightEdgeSwipe:()=>(g.current??p.current)()}),typeof document<"u"&&!o.current){let h=document.getElementById(Ni);h||(h=document.createElement("div"),h.id=Ni,document.body.appendChild(h)),o.current=h}return f.useEffect(()=>{if(n){u(!0);const b=window.setTimeout(()=>m(!0),Nf);return()=>window.clearTimeout(b)}m(!1);const h=window.setTimeout(()=>u(!1),Ci+40);return()=>window.clearTimeout(h)},[n]),f.useEffect(()=>{if(!n)return;const h=document.body.style.overflow;document.body.style.overflow="hidden";const b=S=>{S.key==="Escape"&&p.current()};return document.addEventListener("keydown",b),()=>{document.body.style.overflow=h,document.removeEventListener("keydown",b)}},[n]),o.current?is.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:c?"none":"translateX(-100%)",transition:`transform ${Ci}ms ${Cf}`,visibility:a?"visible":"hidden",pointerEvents:n?"auto":"none"},children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:r})}),o.current):null},Ri=n=>{const e=me.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 l;e[2]!==i?(l=i?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i}):null,e[2]=i,e[3]=l):l=e[3];let c;e[4]!==r?(c=r?t.jsx("div",{className:"pt-2",children:r}):null,e[4]=r,e[5]=c):c=e[5];let m;return e[6]!==o||e[7]!==l||e[8]!==c?(m=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[o,l,c]}),e[6]=o,e[7]=l,e[8]=c,e[9]=m):m=e[9],m};function Ef(n){return ze(n.path)}function If(n){return ze(n.path)}function Af(n){return t.jsx(kf,{worktree:n},ze(n.path))}const Pf=(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}},Tf=n=>{switch(n?.status.status){case"connected":return"success";case"failed":return"error";case"needs_auth":return"warning";default:return"default"}},Df=({active:n,className:e,headerAction:s,listClassName:i,hideHeader:r=!1,mobileListDensity:o=!1})=>{const{t:l}=be(),m=Nt(x=>x.currentDirectory)??null,a=ws(x=>x.getStatusForDirectory(m)),u=ws(x=>x.refresh),p=ws(x=>x.connect),g=ws(x=>x.disconnect),h=ns(x=>x.mcpServers),b=ns(x=>x.loadMcpConfigs),[S,y]=f.useState(!1),[I,v]=f.useState(null);f.useEffect(()=>{u({directory:m,silent:!0})},[u,m]),f.useEffect(()=>{b({force:!0})},[b]),f.useEffect(()=>{n&&Promise.all([u({directory:m,silent:!0}),b({force:!0})])},[n,u,m,b]);const C=f.useMemo(()=>{const x=new Set(Object.keys(a));for(const E of h)E?.name&&x.add(E.name);return Array.from(x).sort((E,N)=>E.localeCompare(N))},[h,a]),A=f.useCallback(x=>{if(x?.preventDefault(),S)return;y(!0);const E=new Promise(N=>setTimeout(N,500));Promise.all([u({directory:m}),E]).finally(()=>{y(!1)})},[S,u,m]);return t.jsxs("div",{className:X("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:l("mcpDropdown.title")}),m&&t.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:m.split("/").pop()||m})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s,t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",disabled:S,onClick:A,"aria-label":l("mcpDropdown.actions.refreshAria"),children:t.jsx(Y,{name:"refresh",className:X("h-4 w-4",S&&"animate-spin")})})]})]})}),t.jsx("div",{className:X("max-h-64 overflow-y-auto",o?"space-y-1 py-3":"px-3 py-2.5",i),children:t.jsxs("div",{className:X(!o&&C.length>0&&"rounded-xl bg-[var(--surface-muted)] p-1.5"),children:[C.map(x=>{const E=a[x],N=Tf(E),R=E?.status.status==="connected",k=I===x,D=Pf(E,l);return t.jsxs("div",{className:X("flex items-center justify-between rounded-lg hover:bg-interactive-hover/50",o?"gap-3 px-4 py-3":"gap-2 px-2.5 py-2"),children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsxs(sl,{children:[t.jsx(nl,{asChild:!0,children:t.jsx("span",{className:X("rounded-full flex-shrink-0",o?"h-2.5 w-2.5":"h-2 w-2",N==="success"&&"bg-status-success",N==="error"&&"bg-status-error",N==="warning"&&"bg-status-warning",N==="default"&&"bg-muted-foreground/40"),"aria-label":D})}),t.jsx(rl,{side:"left",children:t.jsx("p",{children:D})})]}),t.jsx("span",{className:X("truncate",o?"text-[17px] leading-6 font-medium":"typography-ui-label"),children:x})]})}),t.jsx(il,{checked:R,disabled:k,className:"data-[checked]:bg-status-info",onCheckedChange:async z=>{v(x);try{z?await p(x,m):await g(x,m)}catch(_){Mn.error(_ instanceof Error?_.message:l("mcpDropdown.status.unknownError"))}finally{v(null)}}})]},x)}),C.length===0&&t.jsx("div",{className:"px-4 py-5 typography-ui-label text-muted-foreground text-center",children:l("mcpDropdown.empty.configureInConfig")})]})})]})},Ei={status:"loading"},Yt={type:"list"},_f=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),Mf=n=>{const e=n.index?.trim();return!!(e&&e!=="?")},zf=n=>{const e=n.working_dir?.trim(),s=n.index?.trim();return!!(e||s==="?")},Ii=(n,e)=>e?`${n}\0staged`:n,Of=n=>{const e=me.c(8),s=Jn()??null;let i;e[0]!==s?(i=_f(s),e[0]=s,e[1]=i):i=e[1];const r=i,o=n.visible??!0;let l;e[2]!==o?(l={enabled:o},e[2]=o,e[3]=l):l=e[3];const c=ol(r||null,l);let m;return e[4]!==n||e[5]!==c||e[6]!==r?(m=t.jsx(Bf,{...n,rootDirectory:r,repository:c}),e[4]=n,e[5]=c,e[6]=r,e[7]=m):m=e[7],m},Bf=({rootDirectory:n,repository:e,onClose:s,initialDiff:i,visible:r=!0})=>{const{t:o}=be(),{git:l}=Hn(),{rootIsGitRepo:c,gitDirectory:m,nestedRepos:a}=e,u=m??n,p=al(u||null),g=ll(u||null),h=Ui(u||null),b=cl(u||null),S=Xe(T=>T.setActiveDirectory),y=Xe(T=>T.ensureAll),I=Xe(T=>T.ensureNestedRepos),v=Xe(T=>T.selectNestedRepo),C=Xe(T=>T.fetchStatus),A=Xe(T=>T.fetchBranches),x=Xe(T=>T.prefetchDiffs),E=Xe(T=>T.getDiff),N=Xe(T=>T.setDiff),R=Xe(T=>T.runtimeKey),k=JSON.stringify([R,u]),D=f.useRef(k);D.current=k;const[z,_]=f.useState(()=>({ownerKey:k,mode:"working",route:i?.path?{type:"diff",path:i.path,staged:i.staged}:Yt})),j=z.ownerKey===k?z.mode:"working",P=z.ownerKey===k?z.route:Yt,[V,w]=f.useState(!1),U=f.useCallback(T=>{_({ownerKey:k,mode:T,route:Yt}),w(!1)},[k]),F=f.useCallback(T=>{_(G=>({ownerKey:k,mode:G.ownerKey===k?G.mode:"working",route:T}))},[k]);f.useEffect(()=>{_(T=>T.ownerKey===k?T:{ownerKey:k,mode:"working",route:Yt}),w(!1)},[k]),f.useEffect(()=>{r||w(!1)},[r]),f.useEffect(()=>{i?.path&&_({ownerKey:D.current,mode:"working",route:{type:"diff",path:i.path,staged:i.staged}})},[i]);const[B,W]=f.useState(null),[Q,J]=f.useState(null),[$,te]=f.useState(""),[fe,ae]=f.useState(new Set),[ne,le]=f.useState(!1),[O,Z]=f.useState(!1),[ee,oe]=f.useState([]),[H,ie]=f.useState([]),[ce,he]=f.useState([]),[we,q]=f.useState(null),[ue,Ee]=f.useState(null),[Re,xe]=f.useState(null),[Ce,Ae]=f.useState(0),[Pe,_e]=f.useState(null),Se=p?.current??null,Oe=p?.tracking?.trim().split("/")[0],Me=(Oe&&g?.defaultBranches?.[Oe])??g?.defaultBranches?.origin??null,it=Nu(Se,Me),kt=h===!1||ku(Se,Me,p!==null,g!==null),cn=mu(T=>T.setOverride),He=pu(u||null,Se,r&&j==="branch"&&it),Ze=hu(u||null,Se,r&&j==="commit"&&h===!0),gt=Ze.selectedCommit?.hash??null,bt=gu(u||null,Se,r&&j==="pr"&&h===!0),xt=bt.selectedSource,Ts=f.useMemo(()=>j==="pr"?xt:j==="branch"&&Se&&He.base?{kind:"branch",baseRef:He.base,headRef:Se}:j==="commit"&&gt?{kind:"commit",hash:gt}:null,[He.base,Se,j,gt,xt]),Ds=j==="branch"?He.revision:"",Ie=wu(u||null,Ts,r&&h===!0,Ds),{fetchDiff:_s}=Ie,Ve=f.useMemo(()=>Ie.files?[...Ie.files].sort((T,G)=>T.path.localeCompare(G.path)):null,[Ie.files]),ot=P.type==="comparison"&&P.sourceKey===Ie.key?P.path:null,[un,ms]=f.useState(0),dn=f.useCallback(async T=>{try{const{diff:G}=await _s(T),se={original:"",modified:"",isBinary:bu(G)};return se.isBinary||(se.fileDiff=xu(T,G)),{status:"ready",diff:se}}catch(G){return{status:"error",message:G instanceof Error?G.message:o("diffView.state.failedToLoadDiff")}}},[_s,o]),Ot=ju(Ie.files?j==="pr"?JSON.stringify([Ie.key,Ie.revision]):Ie.key:null,r&&ot?ot:"",r?dn:null,Ei,JSON.stringify([Ds,j==="pr"?Ie.revision:0,un])),Rt=ot?Ot.get(ot)??Ei:null;f.useEffect(()=>{j==="branch"&&kt&&U("working")},[kt,U,j]),f.useEffect(()=>{_(T=>T.ownerKey===k&&T.route.type==="comparison"&&T.route.sourceKey!==Ie.key?{...T,route:Yt}:T)},[Ie.key,k]);const Ge=f.useMemo(()=>{const T=p?.files??[],G=new Map;for(const se of T)G.set(se.path,se);return Array.from(G.values()).sort((se,ge)=>se.path.localeCompare(ge.path))},[p?.files]),at=f.useMemo(()=>Ge.filter(Mf),[Ge]),je=f.useMemo(()=>Ge.filter(zf),[Ge]),Be=f.useMemo(()=>{if(ce.length>0)return ce;const T=p?.tracking?.includes("/")?p.tracking.split("/")[0]:null;return T||we?[{name:T||"origin",fetchUrl:we??"",pushUrl:we??""}]:[]},[we,ce,p?.tracking]),ut=Xe(f.useCallback(T=>!u||P.type!=="diff"?null:T.directories.get(u)?.diffCache.get(Ii(P.path,P.staged))??null,[u,P])),Ms=f.useMemo(()=>P.type!=="diff"?null:Ge.find(T=>T.path===P.path)??null,[Ge,P]),Te=f.useCallback(async(T=!0)=>{if(u)try{await Promise.all([C(u,l),A(u,l)])}catch(G){T&&ve.error(G instanceof Error?G.message:o("gitView.toast.refreshRepositoryFailed"))}},[u,A,C,l,o]),Bt=f.useMemo(()=>(g?.all??[]).filter(T=>!T.startsWith("remotes/")).sort(),[g]),Lt=f.useMemo(()=>(g?.all??[]).filter(T=>T.startsWith("remotes/")).map(T=>T.replace(/^remotes\//,"")).sort(),[g]),Ke=f.useCallback(async T=>{if(!u)return;const G=T.replace(/^remotes\//,"");try{const se=await l.checkoutBranch(u,G);ve.success(o("gitView.toast.checkedOut",{name:se.branch||G})),await Te()}catch(se){ve.error(se instanceof Error?se.message:o("gitView.toast.checkoutFailed",{name:G}))}},[u,l,Te,o]),yt=f.useCallback(T=>{const G=T.replace(/^remotes\//,"");if((p?.files?.length??0)>0){_e(G);return}Ke(G)},[Ke,p?.files]),$t=f.useCallback(async(T,G)=>{if(u)try{await l.createBranch(u,T,Se??"HEAD"),await l.checkoutBranch(u,T),G&&await l.gitPush(u,{remote:G.name,branch:T,options:["--set-upstream"]}),await Te()}catch(se){throw ve.error(se instanceof Error?se.message:o("gitView.toast.createBranchFailed")),se}},[Se,u,l,Te,o]),et=f.useCallback(async()=>{if(!u){he([]),q(null);return}try{const[T,G]=await Promise.all([l.getRemotes(u).catch(()=>[]),l.getRemoteUrl?l.getRemoteUrl(u).catch(()=>null):Promise.resolve(null)]);he(T),q(G)}catch{he([]),q(null)}},[u,l]);f.useEffect(()=>{!u||!r||(S(u),y(u,l))},[u,y,l,S,r]),f.useEffect(()=>{r&&et()},[et,r]),f.useEffect(()=>{if(!r||j!=="working"||!u||Ge.length===0)return;const T=Array.from(new Set([...at.map(se=>se.path),...H,...Ge.slice(0,20).map(se=>se.path)])).filter(Boolean);if(T.length===0)return;const G=window.setTimeout(()=>{x(u,l,T,{maxFiles:40})},120);return()=>window.clearTimeout(G)},[Ge,u,l,j,x,at,H,r]),f.useEffect(()=>{if(!r)return;if(P.type!=="diff"){Ee(null);return}const T=Ii(P.path,P.staged);if(xe(null),!u||E(u,T)){Ee(null);return}let G=!1;const se=ds();return Ee(null),l.getGitFileDiff(u,{path:P.path,staged:P.staged||void 0}).then(ge=>{G||N(u,T,{original:ge.original??"",modified:ge.modified??"",isBinary:ge.isBinary,submodule:ge.submodule},se)}).catch(ge=>{if(!G){if(ge instanceof Kr&&ge.reason!=="path_not_found"){xe({key:`${u}\0${P.path}`,reason:ge.reason});return}ge instanceof Kr&&C(u,l,{force:!0,silent:!0}),Ee(ge instanceof Error?ge.message:String(ge))}}),()=>{G=!0}},[u,Ce,C,E,l,P,N,r]);const Et=async(T,G)=>{if(u){W(T);try{if(T==="fetch"){if(!G)throw new Error(o("mobile.changes.noRemote"));await l.gitFetch(u,{remote:G.name}),ve.success(o("gitView.toast.fetchedFromRemote",{name:G.name}))}else if(T==="sync"){if(!G)throw new Error(o("mobile.changes.noRemote"));let se=0;const ge=await ri({git:l,directory:u,remote:G,dirtyWorktreeError:o("gitView.toast.commitOrStashBeforeSync"),onPulled:lt=>{se=lt.files.length}});se>0&&ve.success(se===1?o("gitView.toast.pulledFilesSingle",{count:se,name:G.name}):o("gitView.toast.pulledFilesPlural",{count:se,name:G.name})),ge.pushed.length>0?ve.success(o("gitView.toast.pushedToUpstream",{name:ge.pushed[0].remote})):se===0&&ve.success(o("gitView.toast.alreadyUpToDate"))}await Te(!1),await et()}catch(se){ve.error(se instanceof Error?se.message:o("gitView.toast.syncActionFailed",{action:o("gitView.sync.syncChanges")}))}finally{W(null)}}},pt=f.useCallback(async(T,G)=>{if(!(!u||T.length===0))try{G==="stage"?T.length>1?await ul(u,T):await dl(u,T[0]):T.length>1?await fl(u,T):await ml(u,T[0]),await Te(!1)}catch(se){ve.error(se instanceof Error?se.message:o(G==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed"))}},[u,Te,o]),Ue=f.useCallback((T,G=!1)=>{F({type:"diff",path:T,staged:G})},[F]),tt=f.useCallback(async T=>{if(u){ae(G=>new Set(G).add(T));try{await l.revertGitFile(u,T),ve.success(o("gitView.toast.revertedFile",{path:T})),await Te(!1)}catch(G){ve.error(G instanceof Error?G.message:o("gitView.toast.revertFailed"))}finally{ae(G=>{const se=new Set(G);return se.delete(T),se})}}},[u,l,Te,o]),Ft=f.useCallback(async T=>{if(!u||T.length===0||ne)return;const G=Array.from(new Set(T));le(!0),ae(new Set(G));try{await Promise.all(G.map(se=>l.revertGitFile(u,se))),await Te(!1),ve.success(G.length===1?o("gitView.toast.revertedFilesSingle",{count:G.length}):o("gitView.toast.revertedFilesPlural",{count:G.length}))}catch(se){ve.error(se instanceof Error?se.message:o("gitView.toast.revertFailed"))}finally{ae(new Set),le(!1)}},[u,l,ne,Te,o]),Wt=f.useCallback(T=>{const G=T.map(se=>se.trim()).filter(Boolean);if(G.length===0){oe([]);return}te(se=>`${se.trim()}${se.trim()?`
23
+
24
+ `:""}${G.join(`
25
+ `)}`.trim()),oe([])},[]),fn=f.useCallback(async()=>{if(!u)return;const T=at.map(G=>G.path).sort();if(T.length===0){ve.error(o("gitView.toast.selectFileToDescribe"));return}Z(!0);try{const{message:G}=await ei(u,T);te(G.subject?.trim()??""),oe(Array.isArray(G.highlights)?G.highlights:[])}catch(G){ve.error(G instanceof Error?G.message:o("gitView.toast.generateCommitMessageFailed"))}finally{Z(!1)}},[u,at,o]),Vt=async(T={})=>{if(!u)return;if(!$.trim()){ve.error(o("gitView.toast.enterCommitMessage"));return}const G=at.map(se=>se.path).sort();if(G.length===0){ve.error(o("gitView.toast.selectFileToCommit"));return}J(T.pushAfter?"commitAndPush":"commit");try{if(await l.createGitCommit(u,$.trim(),{files:G}),ve.success(o("gitView.toast.commitCreated")),te(""),oe([]),T.pushAfter){const se=p?.tracking?.split("/")[0],ge=Be.find(lt=>lt.name===se)??Be[0];if(!ge)throw new Error(o("mobile.changes.noRemote"));W("sync"),await ri({git:l,directory:u,remote:ge,dirtyWorktreeError:o("gitView.toast.commitOrStashBeforeSync"),onPushed:lt=>{ve.success(o("gitView.toast.pushedToUpstream",{name:lt.pushed[0].remote}))}}),await Te(!1),await et()}else await Te(!1)}catch(se){ve.error(se instanceof Error?se.message:o("gitView.toast.createCommitFailed"))}finally{J(null),T.pushAfter&&W(null)}},Ut=f.useMemo(()=>{const T=[];return at.length>0&&T.push({id:"staged",title:o("gitView.changes.stagedTitle"),entries:at,statsScope:"staged",actionSymbol:"-",actionAllLabel:o("gitView.changes.unstageAllAria"),getActionLabel:G=>o("gitView.changes.unstageFileAria",{path:G}),onActionFile:G=>{pt([G],"unstage")},onActionAll:G=>{pt(G,"unstage")},onViewDiff:G=>Ue(G,!0),onRevertFile:tt,showRevertActions:!1,accent:!0}),je.length>0&&T.push({id:"unstaged",title:o("gitView.changes.title"),entries:je,statsScope:"working",actionSymbol:"+",actionAllLabel:o("gitView.changes.stageAllAria"),getActionLabel:G=>o("gitView.changes.stageFileAria",{path:G}),onActionFile:G=>{pt([G],"stage")},onActionAll:G=>{pt(G,"stage")},onViewDiff:G=>Ue(G,!1),onRevertFile:tt}),T},[tt,Ue,pt,at,o,je]),Gt=T=>t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[s?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"close",className:"size-5"})}):null,t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[t.jsx("h2",{className:"typography-ui-label text-foreground",children:o("mobile.nav.changes")}),t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:p?.current||u||""})]}),c===!1&&Array.isArray(a)&&a.length>0?t.jsx(Sc,{repositories:a,selectedRepository:m??null,onSelectRepository:G=>{n&&v(n,G)},repositoryRoot:n??void 0}):null]}),t.jsx("div",{className:"min-h-0 flex-1",children:T})]});if(!u)return Gt(t.jsx(rt,{message:o("gitView.empty.selectSessionOrDirectory")}));if(c===!1&&h!==!0)return Gt(t.jsx(Nc,{rootIsGitRepo:c,resolvedIsGitRepo:h,nestedRepos:a,onRetryDiscovery:()=>{n&&I(n,{force:!0})}}));if(b&&h===null)return Gt(t.jsx(rt,{loading:!0,message:o("gitView.loading.checkingRepository")}));if(P.type==="diff")return t.jsx(Ai,{path:P.path,diff:ut,staged:P.staged,fileExists:!!Ms,unavailableReason:Re?.key===`${u}\0${P.path}`?Re.reason:null,error:ue,onBack:()=>F({type:"list"}),onRetry:()=>Ae(T=>T+1)});const zs=o(j==="pr"?"session.githubIntegration.tabs.pullRequests":j==="branch"?"diffView.scope.branch":j==="commit"?"commitComparison.mode":"mobile.nav.changes"),vt=j==="branch"&&He.base?wc(He.base):j==="commit"?gt?.slice(0,8):j==="pr"&&xt?`#${xt.number}`:null;if(ot&&Rt)return t.jsx(Ai,{path:ot,subtitle:[zs,vt].filter(Boolean).join(" · "),diff:Rt.status==="ready"?Rt.diff:null,fileExists:!Ie.files||Ie.files.some(T=>T.path===ot),error:Ie.error??(Rt.status==="error"?Rt.message:null),onBack:()=>F(Yt),onRetry:()=>{Ie.error&&Ie.refresh(),ms(T=>T+1)}});const Os=()=>j==="pr"&&!xt?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(rt,{loading:bt.loading,message:bt.error??(bt.loading?o("session.githubPrPicker.loading.pullRequests"):o("pullRequestComparison.select"))}),!bt.loading&&t.jsx(ii,{mobile:!0,comparison:bt})]}):j==="branch"&&!He.base?t.jsx(rt,{loading:!He.resolved,message:He.resolved?o("gitView.pr.toast.baseBranchRequired"):o("diffView.branch.resolvingBase")}):j==="commit"&&!gt?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[Ze.loading&&t.jsx(Y,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:Ze.loading?o("diffView.state.loadingChanges"):Ze.error??o("commitComparison.noCommits")}),Ze.error&&t.jsx(ke,{variant:"outline",size:"lg",onClick:()=>{Ze.refresh()},children:o("diffView.actions.retry")})]}):Ie.error?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx("p",{className:"typography-ui-label font-semibold",children:o("diffView.state.failedToLoadDiff")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:Ie.error}),t.jsx(ke,{variant:"outline",size:"lg",onClick:()=>{Ie.refresh()},children:o("diffView.actions.retry")})]}):Ve?Ve.length===0?t.jsx(rt,{icon:j==="branch",message:j==="pr"?o("walkthrough.blocked.emptyDiff.description"):j==="commit"?o("commitComparison.emptyDiff"):o("diffView.branch.empty",{base:vt??""})}):t.jsx(Lf,{files:Ve,onSelect:T=>{Ie.key&&F({type:"comparison",path:T,sourceKey:Ie.key})}}):t.jsx(rt,{loading:!0,message:o("diffView.state.loadingChanges")});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b border-border/60 px-3 py-2",children:[s?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"close",className:"size-5"})}):null,t.jsxs(pl,{open:V,onOpenChange:w,children:[t.jsx(hl,{asChild:!0,children:t.jsxs(ke,{variant:"outline",className:gl({size:"default"}),"data-mobile-comparison-trigger":!0,"aria-label":o("diffView.scope.selectorAria"),children:[t.jsx("span",{children:zs}),t.jsx(Y,{name:"arrow-down-s",className:"size-4"})]})}),t.jsx(bl,{align:"start",children:t.jsxs(xl,{value:j,onValueChange:T=>{(T==="working"||T==="branch"||T==="commit"||T==="pr")&&U(T)},children:[t.jsx(Vs,{value:"working",className:"min-h-8 items-center",children:o("mobile.nav.changes")}),it&&t.jsx(Vs,{value:"branch",className:"min-h-8 items-center",children:o("diffView.scope.branch")}),t.jsx(Vs,{value:"commit",className:"min-h-8 items-center",children:o("commitComparison.mode")}),t.jsx(Vs,{value:"pr",className:"min-h-8 items-center",children:o("session.githubIntegration.tabs.pullRequests")})]})})]}),r&&j==="branch"&&t.jsx(yu,{mobile:!0,branches:g?.all??[],currentBranch:Se,base:He.base,onSelect:T=>{Se&&cn(u,Se,T)}},JSON.stringify([k,Se])),r&&j==="commit"&&t.jsx(vu,{mobile:!0,commits:Ze.commits,selectedHash:gt,loading:Ze.loading,error:Ze.error,onSelect:Ze.select,onRefresh:()=>{Ze.refresh()}},JSON.stringify([k,Se])),r&&j==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(ii,{mobile:!0,comparison:bt},JSON.stringify([k,Se])),xt&&t.jsx(ke,{variant:"ghost",size:"sm",disabled:Ie.loading,"aria-label":o("session.githubIssuePicker.actions.refresh"),onClick:()=>{Ie.refresh()},children:t.jsx(Y,{name:"refresh",className:"size-4"})})]})]}),j==="working"&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 px-3 py-2",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(jc,{currentBranch:p?.current,localBranches:Bt,remoteBranches:Lt,branchInfo:g?.branches,currentBranchAhead:p?.ahead,onCheckout:T=>{yt(T)},onCreate:$t,remotes:Be,disabled:b,directory:u,switchBlockedNotice:(p?.files?.length??0)>0?o("gitView.branch.switchBlockedNotice"):null})}),t.jsx(kc,{syncAction:B,remotes:Be,onFetch:T=>{Et("fetch",T)},onSync:T=>{Et("sync",T)},disabled:Q!==null||b,aheadCount:p?.ahead??0,behindCount:p?.behind??0,trackingRemoteName:p?.tracking?.split("/")[0],hasUncommittedChanges:Ge.length>0})]}),j!=="working"?t.jsx("div",{className:"min-h-0 flex-1",children:Os()}):Ge.length>0?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden px-4 pt-4",children:t.jsx(uu,{groups:Ut,diffStats:p?.diffStats,revertingPaths:fe,onRevertAll:Ft,isRevertingAll:ne,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:ie})}),t.jsx("div",{className:"shrink-0 border-t border-border/70 px-4 pb-4 pt-3",children:t.jsx(du,{stagedCount:at.length,commitMessage:$,onCommitMessageChange:te,generatedHighlights:ee,onInsertHighlights:Wt,onGenerateMessage:fn,isGeneratingMessage:O,onCommit:()=>{Vt({pushAfter:!1})},onCommitAndPush:()=>{Vt({pushAfter:!0})},commitAction:Q,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(rt,{icon:!0,message:o("gitView.empty.cleanTitle"),description:o("mobile.changes.cleanDescription")})}),t.jsx(fu,{open:Pe!==null,onOpenChange:T=>{T||_e(null)},targetBranch:Pe??"",changedFileCount:p?.files?.length??0,onCommitAndSwitch:async(T,G)=>{const se=Pe;if(!se||!u)return;const ge=p?.current??null;await l.createGitCommit(u,T,{addAll:!0});let lt=null;if(G){const Kt=p?.tracking?.split("/")[0],It=Be.find(mn=>mn.name===Kt)??Be[0];try{if(!It)throw new Error(o("mobile.changes.noRemote"));await l.gitPush(u,p?.tracking?{remote:It.name}:{remote:It.name,branch:ge??void 0,options:["--set-upstream"]}),lt=It.name}catch{ve.error(o("gitView.dirtySwitch.pushFailed")),await Te(),_e(null);return}}ve.success(ge?lt?o("gitView.toast.pushedToUpstream",{name:lt}):o("gitView.dirtySwitch.committedNotPushed",{branch:ge}):o("gitView.toast.commitCreated")),await Te(),_e(null),await Ke(se)},onGenerateMessage:async()=>{if(!u)return"";const T=(p?.files??[]).map(se=>se.path).sort(),{message:G}=await ei(u,T);return G.subject?.trim()??""},onRevertAndSwitch:async()=>{const T=Pe;if(!T||!u)return;await Ft((p?.files??[]).map(se=>se.path));const G=await l.getGitStatus(u);if(!G.isClean&&(G.files?.length??0)>0){ve.error(o("gitView.dirtySwitch.revertIncomplete"));return}_e(null),await Ke(T)}})]})},rt=n=>{const e=me.c(13),{message:s,description:i,loading:r,icon:o}=n,l=r===void 0?!1:r,c=o===void 0?!1:o;let m;e[0]!==l?(m=l?t.jsx(Y,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,e[0]=l,e[1]=m):m=e[1];let a;e[2]!==c?(a=c?t.jsx(Y,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e[2]=c,e[3]=a):a=e[3];let u;e[4]!==s?(u=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[4]=s,e[5]=u):u=e[5];let p;e[6]!==i?(p=i?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i}):null,e[6]=i,e[7]=p):p=e[7];let g;return e[8]!==m||e[9]!==a||e[10]!==u||e[11]!==p?(g=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:[m,a,u,p]})}),e[8]=m,e[9]=a,e[10]=u,e[11]=p,e[12]=g):g=e[12],g},Ai=n=>{const e=me.c(31),{path:s,subtitle:i,diff:r,staged:o,fileExists:l,unavailableReason:c,error:m,onBack:a,onRetry:u}=n,p=o===void 0?!1:o,g=c===void 0?null:c,{t:h}=be();let b;e[0]!==s?(b=yl(s)||"text",e[0]=s,e[1]=b):b=e[1];const S=b;let y;e[2]!==h?(y=h("header.actions.backAria"),e[2]=h,e[3]=y):y=e[3];let I;e[4]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(Y,{name:"arrow-left",className:"size-5"}),e[4]=I):I=e[4];let v;e[5]!==a||e[6]!==y?(v=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":y,onClick:a,children:I}),e[5]=a,e[6]=y,e[7]=v):v=e[7];let C;e[8]!==s?(C=t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:s}),e[8]=s,e[9]=C):C=e[9];let A;e[10]!==i?(A=i&&t.jsx("p",{className:"truncate typography-meta text-muted-foreground",children:i}),e[10]=i,e[11]=A):A=e[11];let x;e[12]!==C||e[13]!==A?(x=t.jsxs("div",{className:"min-w-0 flex-1 px-2",children:[C,A]}),e[12]=C,e[13]=A,e[14]=x):x=e[14];let E;e[15]!==v||e[16]!==x?(E=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:[v,x]}),e[15]=v,e[16]=x,e[17]=E):E=e[17];let N;e[18]!==r||e[19]!==m||e[20]!==l||e[21]!==S||e[22]!==u||e[23]!==s||e[24]!==p||e[25]!==h||e[26]!==g?(N=t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:l?g==="nested_repository"?t.jsx(rt,{icon:!0,message:h("diffView.unavailable.nestedRepositoryTitle"),description:h("diffView.unavailable.nestedRepositoryDescription")}):g==="untracked_directory"?t.jsx(rt,{icon:!0,message:h("diffView.unavailable.untrackedDirectoryTitle"),description:h("diffView.unavailable.untrackedDirectoryDescription")}):m?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:h("mobile.changes.diffDetail.loadFailed")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:m}),t.jsx(ke,{type:"button",size:"sm",variant:"outline",onClick:u,children:h("diffView.actions.retry")})]})}):r?r.submodule?t.jsx("div",{className:"p-3",children:t.jsx(Su,{state:r.submodule,staged:p})}):r.isBinary?t.jsx(rt,{icon:!0,message:h("diffView.binary.unavailable")}):vl(s)&&!r.fileDiff?t.jsx(rt,{icon:!0,message:h("mobile.changes.diffDetail.imageUnavailable")}):t.jsx(rn,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:t.jsx(Cu,{original:r.original,modified:r.modified,fileDiff:r.fileDiff,language:S,fileName:s,renderSideBySide:!1,wrapLines:!0,layout:"inline"})}):t.jsx(rt,{loading:!0,message:h("diffView.state.loadingDiff")}):t.jsx(rt,{icon:!0,message:h("mobile.changes.diffDetail.missingTitle"),description:h("mobile.changes.diffDetail.missingDescription")})}),e[18]=r,e[19]=m,e[20]=l,e[21]=S,e[22]=u,e[23]=s,e[24]=p,e[25]=h,e[26]=g,e[27]=N):N=e[27];let R;return e[28]!==E||e[29]!==N?(R=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[E,N]}),e[28]=E,e[29]=N,e[30]=R):R=e[30],R},Lf=n=>{const e=me.c(12),{files:s,onSelect:i}=n,{t:r}=be();let o;e[0]!==r?(o=r("gitView.changes.changedFilesAria"),e[0]=r,e[1]=o):o=e[1];let l;if(e[2]!==s||e[3]!==i||e[4]!==r){let m;e[6]!==i||e[7]!==r?(m=a=>{const u=a.status==="A"?r("diffView.change.new"):a.status==="D"?r("diffView.change.deleted"):a.status==="R"?r("diffView.change.renamed"):a.status==="C"?r("diffView.change.copied"):r("diffView.change.modified"),p=a.status==="A"?"var(--status-success)":a.status==="D"?"var(--status-error)":a.status==="R"||a.status==="C"?"var(--status-info)":"var(--status-warning)";return t.jsx("li",{children:t.jsxs(ke,{variant:"ghost",size:"lg",className:"w-full justify-start gap-2.5 text-left normal-case",onClick:()=>i(a.path),children:[t.jsx("span",{className:"w-4 shrink-0 text-center typography-meta font-semibold uppercase",style:{color:p},"aria-label":u,children:a.status}),t.jsx(ro,{filePath:a.path,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label",title:a.path,children:a.path}),(a.insertions>0||a.deletions>0)&&t.jsxs("span",{className:"shrink-0 typography-meta text-muted-foreground",children:["+",a.insertions," -",a.deletions]}),t.jsx(Y,{name:"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground"})]})},a.path)},e[6]=i,e[7]=r,e[8]=m):m=e[8],l=s.map(m),e[2]=s,e[3]=i,e[4]=r,e[5]=l}else l=e[5];let c;return e[9]!==o||e[10]!==l?(c=t.jsx(rn,{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:l})}),e[9]=o,e[10]=l,e[11]=c):c=e[11],c},$f=f.lazy(()=>os(()=>import("./FilesView-CN34wm_N.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}))),jt=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),Cs=n=>{const e=jt(n);return!e||e==="/"?e||"/":e.split("/").filter(Boolean).at(-1)??e},Ff=n=>{const e=jt(n);if(!e||e==="/")return null;const s=e.lastIndexOf("/");return s<=0?e.startsWith("/")?"/":null:e.slice(0,s)},Wf=(n,e)=>{const s=jt(n),i=jt(e);return!i||s===i?Cs(s):s.startsWith(`${i}/`)?s.slice(i.length+1):s},Vf=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""},Uf=n=>{const e=me.c(5),{onClose:s}=n,i=Jn()??null;let r;e[0]!==i?(r=jt(i),e[0]=i,e[1]=r):r=e[1];const o=r;let l;return e[2]!==s||e[3]!==o?(l=t.jsx(Gf,{root:o,onClose:s},o),e[2]=s,e[3]=o,e[4]=l):l=e[4],l},Gf=({root:n,onClose:e})=>{const{t:s}=be(),{files:i}=Hn(),r=ja($=>$.setSelectedPath),[o,l]=f.useState(()=>({type:"browser",directory:n})),[c,m]=f.useState([]),[a,u]=f.useState(!1),[p,g]=f.useState(null),[h,b]=f.useState(""),[S,y]=f.useState([]),[I,v]=f.useState(!1),C=f.useRef(0),A=o.type==="browser"?o.directory:o.returnDirectory,x=f.useRef(A);x.current=A;const E=f.useCallback(async $=>{if(!$)return;const te=C.current+1;C.current=te,u(!0),g(null);try{const fe=await i.listDirectory($);if(C.current!==te)return;m(fe.entries.slice().sort((ae,ne)=>ae.isDirectory!==ne.isDirectory?ae.isDirectory?-1:1:ae.name.localeCompare(ne.name)))}catch(fe){if(C.current!==te)return;m([]),g(fe instanceof Error?fe.message:s("mobile.files.error.listFailed"))}finally{C.current===te&&u(!1)}},[i,s]);f.useEffect(()=>{o.type==="browser"&&E(o.directory)},[E,o]);const N=f.useCallback(async $=>{jt($)===jt(x.current)&&await E(x.current)},[E]),{canUpload:R,uploadingDirectory:k,pickFiles:D,uploadElements:z}=Cc({root:n,refreshDirectory:N}),_=k!==null;f.useEffect(()=>{if(o.type!=="browser")return;const $=h.trim();if(!$){y([]),v(!1);return}let te=!1;const fe=window.setTimeout(()=>{v(!0),i.search({directory:o.directory,query:$,maxResults:40}).then(ae=>{te||y(ae)}).catch(()=>{te||y([])}).finally(()=>{te||v(!1)})},250);return()=>{te=!0,window.clearTimeout(fe)}},[i,h,o]);const j=$=>{b(""),l({type:"browser",directory:$})},P=$=>{r(n,$),l({type:"file",path:$,returnDirectory:A||n})},V=$e($=>$.pendingFileFocusPath),w=$e($=>$.pendingFileNavigation);if(f.useEffect(()=>{const $=jt(w?.path??V??"");!$||!n||$!==n&&!$.startsWith(`${n}/`)||(r(n,$),l({type:"file",path:$,returnDirectory:n}),V&&$e.getState().setPendingFileFocusPath(null))},[V,w,n,r]),!n)return t.jsx(Rs,{message:s("mobile.files.empty.noDirectory")});if(o.type==="file")return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/70 px-3 text-foreground",children:[t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":s("header.actions.backAria"),onClick:()=>l({type:"browser",directory:o.returnDirectory}),style:{touchAction:"manipulation"},children:t.jsx(ni,{className:"size-5"})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:Cs(o.path)})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(qe,{children:t.jsx(f.Suspense,{fallback:t.jsx(Rs,{loading:!0,message:s("filesView.state.loading")}),children:t.jsx($f,{mode:"editor-only"})})})})]});const U=o.directory===n?s("mobile.files.rootDirectory"):Cs(o.directory),F=h.trim()?S:[],B=Ff(o.directory),W=o.directory!==n&&B!==null&&(B===n||B.startsWith(`${n}/`)),Q=W&&!h.trim(),J=W?B:null;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[z,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:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":s("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(nu,{className:"size-5"})}):null,Q&&J?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":s("mobile.files.backToParentAria",{name:Cs(J)}),onClick:()=>j(J),style:{touchAction:"manipulation"},children:t.jsx(ni,{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:U})}),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":s("mobile.files.refreshAria"),onClick:()=>{E(o.directory)},style:{touchAction:"manipulation"},children:t.jsx(ru,{className:X("size-5",a&&"animate-spin")})}),R?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":s("sidebarFilesTree.actions.uploadFilesTitle"),onClick:()=>D(o.directory),disabled:_,style:{touchAction:"manipulation"},children:t.jsx(Y,{name:_?"loader-4":"upload-2",className:X("size-5",_&&"animate-spin")})}):null]}),t.jsx("div",{className:"shrink-0 px-4 pb-2 pt-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(iu,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(eo,{value:h,onChange:$=>b($.target.value),placeholder:s("mobile.files.search.placeholder"),className:"h-11 pl-9"})]})}),t.jsx(rn,{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-3",children:p?t.jsx(Rs,{message:p}):h.trim()?t.jsx(Kf,{results:F,isSearching:I,onOpenFile:P}):t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:[c.length===0&&!a?t.jsx("div",{className:"px-4 py-8 text-center typography-body text-muted-foreground",children:s("mobile.files.empty.directory")}):null,c.map($=>t.jsx(Wo,{name:$.name,path:$.path,directory:$.isDirectory,meta:$.isDirectory?void 0:Vf($.size),onClick:()=>$.isDirectory?j($.path):P($.path)},$.path))]})})]})},Wo=n=>{const e=me.c(16),{name:s,path:i,directory:r,meta:o,onClick:l}=n;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={touchAction:"manipulation"},e[0]=c):c=e[0];let m;e[1]!==r||e[2]!==i?(m=r?t.jsx(lu,{className:"size-5 shrink-0 text-primary/80"}):t.jsx(ro,{filePath:i,className:"size-5 shrink-0"}),e[1]=r,e[2]=i,e[3]=m):m=e[3];let a;e[4]!==s?(a=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:s}),e[4]=s,e[5]=a):a=e[5];let u;e[6]!==o?(u=o?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:o}):null,e[6]=o,e[7]=u):u=e[7];let p;e[8]!==r?(p=r?t.jsx(cu,{className:"size-4 shrink-0 text-muted-foreground/60"}):null,e[8]=r,e[9]=p):p=e[9];let g;return e[10]!==l||e[11]!==m||e[12]!==a||e[13]!==u||e[14]!==p?(g=t.jsxs("button",{type:"button",className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3 py-2.5 text-left transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:l,style:c,children:[m,a,u,p]}),e[10]=l,e[11]=m,e[12]=a,e[13]=u,e[14]=p,e[15]=g):g=e[15],g},Kf=n=>{const e=me.c(10),{results:s,isSearching:i,onOpenFile:r}=n,{t:o}=be(),l=jt(Jn()??null);if(i){let u;e[0]!==o?(u=o("common.loading"),e[0]=o,e[1]=u):u=e[1];let p;return e[2]!==u?(p=t.jsx(Rs,{loading:!0,message:u}),e[2]=u,e[3]=p):p=e[3],p}if(s.length===0){let u;e[4]!==o?(u=o("mobile.files.search.empty"),e[4]=o,e[5]=u):u=e[5];let p;return e[6]!==u?(p=t.jsx(Rs,{message:u}),e[6]=u,e[7]=p):p=e[7],p}const c="overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",m=s.map(u=>t.jsx(Wo,{name:Cs(u.path),path:u.path,directory:!1,meta:Wf(u.path,l),onClick:()=>r(u.path)},u.path));let a;return e[8]!==m?(a=t.jsx("div",{className:c,children:m}),e[8]=m,e[9]=a):a=e[9],a},Rs=n=>{const e=me.c(7),{message:s,loading:i}=n,r=i===void 0?!1:i;let o;e[0]!==r?(o=r?t.jsx(ou,{className:"size-5 animate-spin text-muted-foreground"}):t.jsx(au,{className:"size-6 text-muted-foreground"}),e[0]=r,e[1]=o):o=e[1];let l;e[2]!==s?(l=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[2]=s,e[3]=l):l=e[3];let c;return e[4]!==o||e[5]!==l?(c=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[o,l]})}),e[4]=o,e[5]=l,e[6]=c):c=e[6],c},Pi="mobile-surface-root",qf=16,Ti=320,Hf="cubic-bezier(0.22, 1, 0.36, 1)",Jf=n=>{const e=me.c(36),{onOpenMcpSettings:s}=n,{t:i}=be(),[r,o]=f.useState(!1),l=Nt(Xf),c=ws(Qf),m=ns(Zf);let a;e[0]!==l||e[1]!==r||e[2]!==m||e[3]!==c?(a=()=>{if(r)return;o(!0);const D=new Promise(em);Promise.all([c({directory:l||null,silent:!0}),m({force:!0}),D]).finally(()=>o(!1))},e[0]=l,e[1]=r,e[2]=m,e[3]=c,e[4]=a):a=e[4];const u=a;let p;e[5]!==i?(p=i("settings.mcp.sidebar.actions.addServerTitle"),e[5]=i,e[6]=p):p=e[6];let g;e[7]!==i?(g=i("settings.mcp.sidebar.actions.addServerTitle"),e[7]=i,e[8]=g):g=e[8];let h,b;e[9]===Symbol.for("react.memo_cache_sentinel")?(h={touchAction:"manipulation"},b=t.jsx(Y,{name:"add",className:"size-5"}),e[9]=h,e[10]=b):(h=e[9],b=e[10]);let S;e[11]!==s||e[12]!==p||e[13]!==g?(S=t.jsx("button",{type:"button",className:"flex size-10 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:s,"aria-label":p,title:g,style:h,children:b}),e[11]=s,e[12]=p,e[13]=g,e[14]=S):S=e[14];let y;e[15]!==i?(y=i("mcpDropdown.actions.refreshAria"),e[15]=i,e[16]=y):y=e[16];let I;e[17]!==i?(I=i("mcpDropdown.actions.refreshAria"),e[17]=i,e[18]=I):I=e[18];let v;e[19]===Symbol.for("react.memo_cache_sentinel")?(v={touchAction:"manipulation"},e[19]=v):v=e[19];const C=r&&"animate-spin";let A;e[20]!==C?(A=X("size-5",C),e[20]=C,e[21]=A):A=e[21];let x;e[22]!==A?(x=t.jsx(Y,{name:"refresh",className:A}),e[22]=A,e[23]=x):x=e[23];let E;e[24]!==r||e[25]!==u||e[26]!==x||e[27]!==y||e[28]!==I?(E=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:u,disabled:r,"aria-label":y,title:I,style:v,children:x}),e[24]=r,e[25]=u,e[26]=x,e[27]=y,e[28]=I,e[29]=E):E=e[29];let N;e[30]!==E||e[31]!==S?(N=t.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-1 px-2 pt-1",children:[S,E]}),e[30]=E,e[31]=S,e[32]=N):N=e[32];let R;e[33]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(Df,{active:!0,className:"h-full",listClassName:"max-h-none",hideHeader:!0,mobileListDensity:!0})}),e[33]=R):R=e[33];let k;return e[34]!==N?(k=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[N,R]}),e[34]=N,e[35]=k):k=e[35],k},Yf=({open:n,onClose:e,tab:s,onTabChange:i,pendingChangesDiff:r,onOpenPlan:o,onOpenMcpSettings:l,variant:c="drawer"})=>{const{t:m}=be(),a=f.useRef(null),u=f.useRef(null),[p,g]=f.useState(!1),[h,b]=f.useState(n),S=f.useRef(e);f.useEffect(()=>{S.current=e},[e]);const y=f.useRef(s);f.useEffect(()=>{y.current=s},[s]),xr(u,{enabled:c==="drawer"&&n,onLeftEdgeSwipe:()=>S.current()});const[I,v]=f.useState(()=>new Set);if(f.useEffect(()=>{n&&v(x=>{if(x.has(s))return x;const E=new Set(x);return E.add(s),E})},[n,s]),typeof document<"u"&&!a.current){let x=document.getElementById(Pi);x||(x=document.createElement("div"),x.id=Pi,document.body.appendChild(x)),a.current=x}if(f.useEffect(()=>{if(n){b(!0);const E=window.setTimeout(()=>g(!0),qf);return()=>window.clearTimeout(E)}g(!1);const x=window.setTimeout(()=>b(!1),Ti+40);return()=>window.clearTimeout(x)},[n]),f.useEffect(()=>{if(!n)return;const x=document.body.style.overflow;c==="drawer"&&(document.body.style.overflow="hidden");const E=N=>{N.key!=="Escape"||y.current==="terminal"||jl(N.target)||S.current()};return document.addEventListener("keydown",E),()=>{c==="drawer"&&(document.body.style.overflow=x),document.removeEventListener("keydown",E)}},[n,c]),c==="drawer"&&!a.current)return null;const C=[{id:"changes",label:m("mobile.menu.changes"),icon:t.jsx(Y,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"files",label:m("mobile.menu.files"),icon:t.jsx(Y,{name:"file-text",className:"h-3.5 w-3.5"})},{id:"terminal",label:m("mobile.menu.terminal"),icon:t.jsx(Y,{name:"terminal",className:"h-3.5 w-3.5"})},{id:"notes",label:m("contextRail.surface.notes"),icon:t.jsx(Y,{name:"sticky-note",className:"h-3.5 w-3.5"})},{id:"mcp",label:m("mobile.menu.mcp"),icon:t.jsx(wl,{className:"h-3.5 w-3.5"})}],A=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",children:[t.jsx("div",{className:"flex h-9 min-w-0 flex-1 items-center",children:h?t.jsx(Rc,{items:C,activeId:s,onSelect:x=>i(x),layoutMode:"fit",variant:"active-pill",nonCompositedIndicator:!0,inactiveTabsIconOnly:!0,className:"h-full"}):null}),t.jsx("button",{type:"button",className:"-mr-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":m("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"close",className:"size-5"})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[I.has("changes")?t.jsx("div",{className:X("h-full",s!=="changes"&&"hidden"),children:t.jsx(qe,{children:t.jsx(Of,{visible:n&&s==="changes",initialDiff:r})})},r?`changes:${r.path}:${r.staged}`:"changes"):null,I.has("files")?t.jsx("div",{className:X("h-full",s!=="files"&&"hidden"),children:t.jsx(qe,{children:t.jsx(Uf,{})})}):null,I.has("terminal")?t.jsx("div",{className:X("h-full",s!=="terminal"&&"hidden"),children:t.jsx(qe,{children:t.jsx(Ec,{visible:n&&s==="terminal"})})}):null,I.has("notes")?t.jsx("div",{className:X("h-full",s!=="notes"&&"hidden"),children:t.jsx(qe,{children:t.jsx(Ic,{onActionComplete:e,onOpenPlan:o})})}):null,I.has("mcp")?t.jsx("div",{className:X("h-full",s!=="mcp"&&"hidden"),children:t.jsx(qe,{children:t.jsx(Jf,{onOpenMcpSettings:l})})}):null]})]});return c==="panel"?t.jsx("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:A}):is.createPortal(t.jsx("section",{ref:u,role:"dialog","aria-modal":"true","aria-label":m("mobile.header.openWorkspaceAria"),"aria-hidden":!n,className:"oc-keyboard-inset-surface oc-bottom-safe-surface fixed inset-0 z-50 flex flex-col bg-background text-foreground",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:p?"none":"translateX(100%)",transition:`transform ${Ti}ms ${Hf}`,visibility:h?"visible":"hidden",pointerEvents:n?"auto":"none"},children:A}),a.current)};function Xf(n){return n.currentDirectory}function Qf(n){return n.refresh}function Zf(n){return n.loadMcpConfigs}function em(n){return window.setTimeout(n,500)}function tm(n){const e=me.c(4),s=2500,{uiFont:i}=kl(),[r,o]=f.useState(!1);let l,c;return e[0]!==s||e[1]!==i?(l=()=>{let m=!1;const a=()=>{m||o(!0)},u=()=>{requestAnimationFrame(()=>requestAnimationFrame(a))},p=Promise.all([Sl(i).catch(om),document.fonts?.ready?.then(im).catch(rm)??Promise.resolve(),Ru.catch(nm)]).then(sm),g=new Promise(h=>{window.setTimeout(h,s)});return Promise.race([p,g]).then(u),()=>{m=!0}},c=[i,s],e[0]=s,e[1]=i,e[2]=l,e[3]=c):(l=e[2],c=e[3]),f.useEffect(l,c),r}function sm(){}function nm(){}function rm(){}function im(){}function om(){}const am="openchamber",lm=n=>n.replace(/^\/+|\/+$/g,""),cm=n=>{const e=lm(n.pathname).split("/").filter(Boolean);return n.host?[n.host,...e]:e};function um(n){if(typeof n!="string"||n.length===0)return null;let e;try{e=new URL(n)}catch{return null}if(e.protocol!==`${am}:`)return null;const s=cm(e),i=(s[0]??"").toLowerCase(),r=s.slice(1),o=e.searchParams;switch(i){case"session":{const l=r[0]||o.get("id")||"";return l?{type:"session",sessionId:l,directory:o.get("dir")??void 0}:null}case"new":case"new-session":return{type:"new-session",directory:o.get("dir")??void 0,projectId:o.get("project")??void 0,agent:o.get("agent")??void 0,model:o.get("model")??void 0};case"sessions":{const l=o.get("filter");return{type:"sessions",filter:l==="attention"||l==="recent"||l==="all"?l: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 l=(r[0]||"").toLowerCase();return l==="changes"?{type:"changes"}:l==="files"||l==="mcp"||l==="instances"||l==="update"?{type:"view",target:l}:null}default:return null}}let st={},Vo=!1,Ns=null;const dm=n=>{switch(n.type){case"session":return De.getState().setCurrentSession(n.sessionId,n.directory??null),!0;case"new-session":{const e=De.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 st.openSessions?(st.openSessions(n.filter),!0):!1;case"status":return st.openSessions?(st.openSessions(),!0):!1;case"view":return st.openView?(st.openView(n.target),!0):!1;case"changes":return st.openChanges?(st.openChanges({path:n.path,staged:n.staged}),!0):!1;case"settings":return st.openSettings?(st.openSettings(n.section),!0):!1}},yr=()=>{if(!Vo||!Ns)return;const n=Ns;Ns=null,dm(n)||(Ns=n)},Uo=n=>{Ns=n,yr()},Di=n=>{const e=um(n);e&&Uo(e)},fm=n=>{Vo=n,yr()},mm=n=>{const e=me.c(3);let s,i;e[0]!==n?(s=()=>(st=n,yr(),()=>{st===n&&(st={})}),i=[n],e[0]=n,e[1]=s,e[2]=i):(s=e[1],i=e[2]),f.useEffect(s,i)},pm=n=>{const{ready:e}=n;f.useEffect(()=>{fm(e)},[e]),f.useEffect(()=>{if(!We())return;let s=!1;const i=[];return os(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([127,5,128])).then(async({App:r})=>{if(s)return;const o=await r.addListener("appUrlOpen",l=>{Di(l?.url)});if(s){o.remove();return}i.push(()=>{o.remove()})}).catch(()=>{}),os(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([129,128])).then(async({PushNotifications:r})=>{if(s)return;const o=await r.addListener("pushNotificationActionPerformed",l=>{const c=l?.notification?.data,m=typeof c?.url=="string"?c.url:typeof c?.deeplink=="string"?c.deeplink:void 0;if(m){Di(m);return}const a=typeof c?.sessionId=="string"?c.sessionId:void 0;a&&Uo({type:"session",sessionId:a})});if(s){o.remove();return}i.push(()=>{o.remove()})}).catch(()=>{}),()=>{s=!0,i.forEach(r=>r())}},[])},hm=()=>{if(typeof window>"u")return;const n=window.__OPENCHAMBER_APNS_ENV__;if(n==="development")return"sandbox";if(n==="production")return"production"},gm=()=>{if(typeof window>"u")return!1;const e=window.Capacitor?.getPlatform?.();return e==="ios"||e==="android"},bm=n=>{const{enabled:e}=n,s=$e(r=>r.nativeNotificationsEnabled),i=f.useRef(null);f.useEffect(()=>{if(!e||!s||!gm())return;let r=!1;const o=[];return os(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([129,128])).then(async({PushNotifications:l})=>{if(r)return;let c=await l.checkPermissions().catch(()=>null);if(c?.receive!=="granted"&&(c=await l.requestPermissions().catch(()=>null)),c?.receive!=="granted")return;const m=await l.addListener("registration",u=>{i.current=u.value,qr()?.push?.registerApnsToken?.({token:u.value,platform:Bi(),environment:hm()})}),a=await l.addListener("registrationError",u=>{console.warn("[Push] APNs registration error:",u)});if(await l.register().catch(()=>{}),r){m.remove(),a.remove();return}o.push(()=>{m.remove()},()=>{a.remove()})}).catch(()=>{}),()=>{r=!0,o.forEach(l=>l())}},[e,s]),f.useEffect(()=>{if(s)return;const r=i.current;if(!r)return;i.current=null,qr()?.push?.unregisterApnsToken?.({token:r})},[s])},_i=n=>{const e=me.c(12),{side:s,isResizing:i,ariaLabel:r,handleProps:o}=n,l=s==="left"?"right-0":"left-0";let c;e[0]!==l?(c=X("absolute inset-y-0 z-50 w-6 cursor-col-resize touch-none",l),e[0]=l,e[1]=c):c=e[1];const m=s==="left"?"right-0":"left-0",a=i&&"bg-[var(--interactive-border)]";let u;e[2]!==m||e[3]!==a?(u=X("absolute inset-y-0 w-[3px] transition-colors",m,a),e[2]=m,e[3]=a,e[4]=u):u=e[4];let p;e[5]!==u?(p=t.jsx("div",{className:u}),e[5]=u,e[6]=p):p=e[6];let g;return e[7]!==r||e[8]!==o||e[9]!==c||e[10]!==p?(g=t.jsx("div",{className:c,role:"separator","aria-orientation":"vertical","aria-label":r,...o,children:p}),e[7]=r,e[8]=o,e[9]=c,e[10]=p,e[11]=g):g=e[11],g},xm=320,ym=380,Mi=280,vm=560,wm=900;function zi(n,e,s,i){const r=me.c(23),o=i===void 0?vm:i,l=f.useRef(null);let c;r[0]!==s||r[1]!==o||r[2]!==e?(c=()=>{if(typeof window>"u")return s;const j=Number.parseInt(window.localStorage.getItem(e)??"",10);return Number.isFinite(j)?Math.min(o,Math.max(Mi,j)):s},r[0]=s,r[1]=o,r[2]=e,r[3]=c):c=r[3];const[m,a]=f.useState(c),[u,p]=f.useState(!1),g=f.useRef(0),h=f.useRef(m),b=f.useRef(null),S=f.useRef(null);let y;r[4]!==o?(y=j=>Math.min(o,Math.max(Mi,Math.round(j))),r[4]=o,r[5]=y):y=r[5];const I=y;let v;r[6]===Symbol.for("react.memo_cache_sentinel")?(v=j=>{const P=l.current;P&&(P.style.width=`${j}px`,P.style.minWidth=`${j}px`,P.style.maxWidth=`${j}px`,P.style.setProperty("--oc-ipad-sidebar-width",`${j}px`))},r[6]=v):v=r[6];const C=v;let A;r[7]!==m?(A=j=>{try{j.currentTarget.setPointerCapture(j.pointerId)}catch{}S.current=j.pointerId,g.current=j.clientX,h.current=m,b.current=m,p(!0),j.preventDefault()},r[7]=m,r[8]=A):A=r[8];const x=A;let E;r[9]!==I||r[10]!==n?(E=j=>{if(S.current!==j.pointerId)return;const P=j.clientX-g.current,V=I(h.current+(n==="left"?P:-P));b.current!==V&&(b.current=V,C(V))},r[9]=I,r[10]=n,r[11]=E):E=r[11];const N=E;let R;r[12]!==I||r[13]!==e?(R=j=>{if(S.current!==j.pointerId)return;try{j.currentTarget.releasePointerCapture(j.pointerId)}catch{}const P=I(b.current??h.current);S.current=null,b.current=null,p(!1),a(P);try{window.localStorage.setItem(e,String(P))}catch{}},r[12]=I,r[13]=e,r[14]=R):R=r[14];const k=R;let D;r[15]!==x||r[16]!==k||r[17]!==N?(D={onPointerDown:x,onPointerMove:N,onPointerUp:k,onPointerCancel:k},r[15]=x,r[16]=k,r[17]=N,r[18]=D):D=r[18];const z=D;let _;return r[19]!==z||r[20]!==u||r[21]!==m?(_={asideRef:l,width:m,isResizing:u,handleProps:z},r[19]=z,r[20]=u,r[21]=m,r[22]=_):_=r[22],_}const jm=["general","appearance","chat","notifications","sessions","routing","git","magic-prompts","snippets","behavior","agents","commands","mcp","plugins","skills.installed","skills.catalog","providers","web-search","usage","voice","integrations","about"],km=1e3,Sm=({onActiveConnectionDeleted:n})=>{const{t:e}=be();Uc();const[s,i]=f.useState(!1);f.useEffect(()=>De.subscribe((q,ue)=>{q.currentSessionId&&q.currentSessionId!==ue.currentSessionId&&$e.getState().setRunOverviewKey(null)}),[]);const r=$e(q=>q.runOverviewKey!==null);f.useEffect(()=>{r&&i(!1)},[r]);const[o,l]=f.useState(null),[c,m]=f.useState(!1),[a,u]=f.useState("changes"),[p,g]=f.useState(null),[h,b]=f.useState("nav"),[S,y]=f.useState(null),I=$e(q=>q.setSettingsPage),v=$e(q=>q.wideChatLayoutEnabled),C=es(q=>q.available),A=es(q=>q.runtimeType),x=f.useMemo(()=>Yn(),[]),E=ns(q=>q.mcpServers),N=ns(q=>q.setMcpDraft),R=ns(q=>q.setSelectedMcp),k=f.useCallback(()=>{l(null),g(null)},[]),D=f.useCallback(q=>{l(q)},[]),z=f.useCallback(()=>{m(!1)},[]),_=f.useCallback(q=>{b(q),D("settings")},[D]),{enabled:j,roomyForPanels:P}=Vn(),w=Kl()==="portrait",U=ql(),[F,B]=f.useState(()=>Hl().roomyForPanels),W=f.useCallback(()=>{B(q=>!q)},[]);f.useEffect(()=>{j||B(!1)},[j]);const Q=f.useCallback(()=>{y(null),u("files"),m(!0)},[]);f.useEffect(()=>io(q=>{if(q.type!=="file-open-request")return;const ue=q.directory??Nt.getState().currentDirectory;ue&&($e.getState().openContextFile(ue,q.path),Q())}),[Q]);const J=f.useCallback((q=null)=>{y(q),u("changes"),m(!0)},[]),$=zi("left","openchamber.ipad.leftSidebarWidth",xm),te=zi("right","openchamber.ipad.rightSidebarWidth",ym,wm),fe=P,ae=fe&&c?te.width:0,ne=j&&F?$.width:0;f.useEffect(()=>{if(typeof document>"u")return;const q=document.documentElement;return q.style.setProperty("--oc-chat-inset-left",`${ne}px`),q.style.setProperty("--oc-chat-inset-right",`${ae}px`),()=>{q.style.removeProperty("--oc-chat-inset-left"),q.style.removeProperty("--oc-chat-inset-right")}},[ne,ae]),f.useEffect(()=>{if(typeof document>"u")return;const q=document.documentElement;return q.classList.toggle("wide-chat-layout",v),()=>q.classList.remove("wide-chat-layout")},[v]),f.useEffect(()=>{if(typeof document>"u")return;const q=j&&(w||U),ue=document.documentElement;return ue.classList.toggle("oc-keep-draft-starters",q),()=>ue.classList.remove("oc-keep-draft-starters")},[U,j,w]);const le=f.useMemo(()=>({openChanges:({diffPath:q,staged:ue}={})=>{J(q?{path:q,staged:ue===!0}:null)},openFiles:()=>Q(),openSettings:()=>_("nav")}),[J,Q,_]),O=f.useMemo(()=>({openSessions:()=>{j?B(!0):i(!0)},openView:q=>{if(q==="files"){Q();return}if(q==="mcp"){u("mcp"),m(!0);return}D(q)},openChanges:({path:q,staged:ue}={})=>{J(q?{path:q,staged:ue===!0}:null)},openSettings:q=>{q&&I(q),_(q?"page-content":"nav")}}),[j,J,Q,_,D,I]);mm(O);const Z=f.useRef(null);xr(Z,{onLeftEdgeSwipe:()=>{j?B(!0):i(!0)},onRightEdgeSwipe:()=>m(!0)});const ee=f.useRef(null),oe=f.useCallback(q=>{ee.current=q},[]),H=f.useCallback(()=>p?(g(null),!0):o==="settings"&&ee.current?.()?!0:o?(k(),!0):c?(z(),!0):s?(i(!1),!0):!1,[o,k,z,p,s,c]);Jl(H);const ie=!x&&C&&(A==="desktop"||A==="web"),ce=j?"dialog":"fullscreen",he=f.useMemo(()=>({instanceLabel:x?js():null,onOpenInstances:x?()=>D("instances"):void 0,onOpenSettings:()=>_("nav"),onOpenUsage:()=>D("usage"),onOpenUpdate:ie?()=>D("update"):void 0}),[_,D,x,ie]),we=f.useCallback(()=>{const q="new-mcp-server";let ue=q,Ee=1;for(;E.some(xe=>xe.name===ue);)ue=`${q}-${Ee}`,Ee+=1;N({name:ue,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}),R(ue),I("mcp"),_("page-content")},[E,_,N,R,I]);return t.jsx(Yl,{actions:le,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:[j?t.jsxs("aside",{ref:$.asideRef,className:X("relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!F&&"border-r-0"),style:{width:F?$.width:0,minWidth:F?$.width:0,maxWidth:F?$.width:0,"--oc-ipad-sidebar-width":`${$.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:$.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!F,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:X("flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",$.isResizing&&"pointer-events-none",!F&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(qe,{children:t.jsx(Si,{open:!0,variant:"sidebar",onOpenChange:q=>{!q&&!P&&B(!1)},footer:he})})}),F?t.jsx(_i,{side:"left",isResizing:$.isResizing,ariaLabel:e("sidebar.resize.leftPanelAria"),handleProps:$.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(Od,{onOpenSessions:()=>j?W():i(!0),onOpenWorkspace:()=>m(!0),compactTitle:j}),t.jsxs("main",{ref:Z,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(qe,{children:t.jsx(Gc,{})})}),t.jsx(qe,{children:t.jsx(Kc,{})})]})]}),j?null:t.jsx(Si,{open:s,onOpenChange:i,footer:he}),t.jsxs("aside",{ref:te.asideRef,className:X("relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!ae&&"border-l-0"),style:{width:ae,minWidth:ae,maxWidth:ae,"--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":!ae,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:X("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",!ae&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(qe,{children:t.jsx(Yf,{open:c,onClose:z,tab:a,onTabChange:u,pendingChangesDiff:S,onOpenPlan:g,onOpenMcpSettings:we,variant:fe?"panel":"drawer"})})}),ae?t.jsx(_i,{side:"right",isResizing:te.isResizing,ariaLabel:e("sidebar.resize.rightPanelAria"),handleProps:te.handleProps}):null]}),p?t.jsx(Xt,{open:!0,variant:ce,onClose:()=>g(null),ariaLabel:p.title,title:p.title,children:t.jsx(qe,{children:t.jsx(Xc,{savedProjectPlan:{projectRef:p.projectRef,planId:p.id},onNavigatedToChat:()=>{k(),z()}})})}):null,o==="instances"&&x?t.jsx(Xt,{open:!0,variant:ce,dialogAlign:"app",onClose:k,ariaLabel:e("mobile.menu.instances"),title:e("mobile.menu.instances"),children:t.jsx(Wd,{onConnect:k,onActiveConnectionDeleted:n})}):null,o==="settings"?t.jsx(Xt,{open:!0,variant:ce,dialogAlign:"app",onClose:k,ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(qe,{children:t.jsx(Jc,{forceMobile:!0,isWindowed:!0,initialMobileStage:h,registerBackHandler:oe,visiblePageSlugs:[...jm],onClose:k})})}):null,o==="usage"?t.jsx(Xt,{open:!0,variant:ce,dialogAlign:"app",onClose:k,ariaLabel:e("usageStats.title"),title:e("usageStats.title"),children:t.jsx(qe,{children:t.jsx(qc,{})})}):null,o==="update"?t.jsx(Xt,{open:!0,variant:ce,dialogAlign:"app",onClose:k,ariaLabel:e("mobile.menu.update"),title:e("mobile.menu.update"),children:t.jsx(qe,{children:t.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:t.jsx(Yc,{initialUpdateDialogOpen:!0})})})}):null]})})};function Oi({apis:n}){const e=$e(O=>O.isolatedSpacesEnabled),{t:s}=be(),i=nt(O=>O.initializeApp),r=nt(O=>O.isInitialized),o=nt(O=>O.isConnected),l=nt(O=>O.connectionPhase),c=nt(O=>O.providers.length),m=nt(O=>O.agents.length),a=nt(O=>O.loadProviders),u=nt(O=>O.loadAgents),p=Nt(O=>O.currentDirectory),g=De(O=>O.error),h=De(O=>O.clearError),b=$e(O=>O.setIsMobile),S=Nl(O=>O.refreshStatus),y=Cl(O=>O.refreshStatus),I=Rl(O=>O.setPlanModeEnabled),v=Qe(O=>O.projects),C=ss(O=>O.activeSessions),A=ss(O=>O.archivedSessions),x=ss(O=>O.status==="ready"),E=f.useMemo(()=>[...C,...A],[C,A]);Pc({hasAuthoritativeGlobalSessions:x,sessions:E});const[N,R]=f.useState(0),[k,D]=f.useState(0),[z,_]=f.useState(!1),[j,P]=f.useState("pending"),[V,w]=f.useState(null),U=f.useMemo(()=>js(),[]),[,F]=f.useReducer(O=>O+1,0),B=f.useMemo(()=>Yn(),[]),W=f.useRef(0),Q=f.useRef(0),J=f.useCallback(()=>{const O=mt(),Z=Q.current+1;if(Q.current=Z,!O){bs("resume:auto-connect",{}),xs();return}bs("resume:reprobe",{});const ee=()=>{i(),S(n.github,{force:!0}),y(n.linear,{force:!0}),c===0&&a({source:"mobileApp:nativeResume"}),m===0&&u({source:"mobileApp:nativeResume"})},oe=ie=>{bs("resume:disconnect",{reason:ie}),Qt({apiBaseUrl:"",clientToken:null,runtimeKey:Ws}),R(ce=>ce+1)};Hs().then(ie=>{if(Q.current===Z){if(ie==="no-connection"){oe("no-connection");return}if(ie==="needs-login"){w({kind:"auth-expired",label:js()??""}),oe("needs-login");return}if(ie==="unreachable"){const ce=[4e3,1e4],he=we=>{window.setTimeout(()=>{if(Q.current!==Z)return;const q=we===ce.length-1;Hs({fast:!q}).then(ue=>{if(Q.current===Z&&ue!=="switched"){if(ue==="unchanged"){ee();return}if(ue==="needs-login"){w({kind:"auth-expired",label:js()??""}),oe("retry-needs-login");return}if(!q){he(we+1);return}oe(`retry-${ue}`)}})},ce[we])};he(0);return}ie!=="switched"&&ee()}});const H=Date.now();H-W.current>=km&&(W.current=H,window.dispatchEvent(new Event("openchamber:system-resume")))},[m,n.github,n.linear,i,u,a,c,S,y]);El(),Il(J),f.useEffect(()=>{if(!B)return;let O;const Z=()=>{window.clearTimeout(O),O=window.setTimeout(()=>J(),1500)};return window.addEventListener("online",Z),()=>{window.removeEventListener("online",Z),window.clearTimeout(O)}},[B,J]),f.useEffect(()=>{if(B)return Hr.subscribe((O,Z)=>{O.state==="expired"&&Z.state!=="expired"&&(J(),Hr.getState().markAuthenticated())})},[B,J]),f.useEffect(()=>(Jr(n),()=>Jr(null)),[n]),f.useEffect(()=>$i(O=>{if(bs("endpoint:changed",{runtimeKey:O.runtimeKey||"none",previousRuntimeKey:O.previousRuntimeKey||"none",connected:!!O.apiBaseUrl}),!!O.runtimeKey&&O.runtimeKey===O.previousRuntimeKey){Tc(),F();return}Dc(O),D(ee=>ee+1),R(ee=>ee+1)}),[]),f.useEffect(()=>{if(!B||o||mt()){P("done");return}let O=!1;return P("attempting"),(async()=>{const Z=await xs().catch(()=>({status:"no-candidate"}));O||(Z.status==="unreachable"?w({kind:"unreachable",label:Z.label}):Z.status==="needs-login"&&w({kind:"auth-expired",label:Z.label}),P("done"),Z.status==="unreachable"&&xs({fast:!1,skipIfConnected:!0}).catch(()=>null))})(),()=>{O=!0}},[]),f.useEffect(()=>{if(!B||!mt())return;let O=!1;const Z=ee=>{bs("cold-launch:drop",{kind:ee?.kind??"unknown"}),ee&&w(ee),Qt({apiBaseUrl:"",clientToken:null,runtimeKey:Ws}),R(oe=>oe+1)};return Hs().then(async ee=>{if(O||ee==="switched"||ee==="unchanged")return;const oe=js();if(ee==="needs-login"){Z({kind:"auth-expired",label:oe??""});return}if(ee==="unreachable"){Z(oe?{kind:"unreachable",label:oe}:null),xs({fast:!1,skipIfConnected:!0}).catch(()=>null);return}const H=await xs().catch(()=>({status:"no-candidate"}));O||H.status==="connected"||(H.status==="needs-login"?Z({kind:"auth-expired",label:H.label}):H.status==="unreachable"?Z({kind:"unreachable",label:H.label}):Z(null))}),()=>{O=!0}},[]),f.useEffect(()=>{b(!0)},[b]),f.useEffect(()=>{B&&!mt()||i()},[N,i,B]),f.useEffect(()=>{o&&(c===0&&a({source:"mobileApp:recovery"}),m===0&&u({source:"mobileApp:recovery"}))},[m,o,u,a,c]);const $=f.useRef(!1),[te,fe]=f.useState(B);f.useEffect(()=>{if(!B||!o||$.current)return;if(De.getState().currentSessionId){$.current=!0,fe(!1);return}const O=ds(),Z=Al(O);if(!Z){$.current=!0,fe(!1);return}let ee=!1;const oe=window.setTimeout(()=>fe(!1),6e3);return(async()=>{const H=await qn().catch(()=>null);if(ee)return;if(!H){fe(!1);return}$.current=!0;const ie=H.activeSessions.find(he=>he.id===Z.sessionId);if(!ie){Pl(O),fe(!1);return}const ce=De.getState();ce.currentSessionId||ce.setCurrentSession(ie.id,Wn(ie)??Z.directory??void 0),fe(!1)})(),()=>{ee=!0,window.clearTimeout(oe)}},[N,o,B]),f.useEffect(()=>{o&&Yr.setDirectory(p)},[p,o]),f.useEffect(()=>{o&&(S(n.github,{force:!0}),y(n.linear,{force:!0}))},[n.github,n.linear,o,S,y]),f.useEffect(()=>{if(!o||v.length===0)return;let O=!1;return(async()=>{const ee=new Map(De.getState().availableWorktreesByProject);if(await Promise.all(v.map(async ie=>{const ce=ie.path.replace(/\\/g,"/").replace(/\/+$/,"");if(ce)try{if(!(Xe.getState().directories.get(ce)?.isGitRepo??await os(()=>import("./useAppFontEffects-Dsl_sLrj.js").then(ue=>ue.mj),__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(ue=>ue.checkIsGitRepository(ce))))return;const q=await so({id:ie.id,path:ce});if(O)return;ee.set(ce,q)}catch{}})),O)return;const oe=no(v,ee),H=De.getState().availableWorktreesByProject;Ul(oe,H)||De.setState({availableWorktrees:[...oe.values()].flat(),availableWorktreesByProject:oe})})(),()=>{O=!0}},[o,v]),f.useEffect(()=>{if(!o)return;let O=!1;const Z=io(ee=>{ee.type==="worktree-changed"&&Gl(v,ee.directories,()=>O)});return()=>{O=!0,Z()}},[o,v]),f.useEffect(()=>{let O=!1;return(async()=>{const ee=await Fn("/health",{method:"GET"}).catch(()=>null);if(!ee||!ee.ok||O)return;const oe=await ee.json().catch(()=>null);if(!oe||O)return;const H=oe.planModeExperimentalEnabled;I(H===!0||H===1||H==="1"||H==="true")})(),()=>{O=!0}},[I]),f.useEffect(()=>{if(!g)return;const O=window.setTimeout(()=>h(),5e3);return()=>window.clearTimeout(O)},[h,g]),f.useEffect(()=>{if(!(!o&&(B?!!mt():!0))){_(!1);return}const Z=window.setTimeout(()=>{_(!0)},B?4e3:8e3);return()=>window.clearTimeout(Z)},[o,B,N,k]),Tl(),Dl({enabled:!0}),_c(),_l(),Ml(),Mc(),zc(),bm({enabled:B&&o}),pm({ready:B&&o&&r});const ae=tm(),ne=!o&&l==="reconnecting";if(!ae)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(Zt,{width:120,height:120,isAnimated:!0,variant:"splash"})});const le=!!mt();return B&&(!le||!o&&!ne)?le?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(Zt,{width:120,height:120,isAnimated:!z,variant:"splash"}),z?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(ke,{type:"button",variant:"outline",onClick:()=>{Qt({apiBaseUrl:"",clientToken:null,runtimeKey:Ws}),R(O=>O+1)},children:s("mobile.connect.cancelPassword")})]}):null]})}):j!=="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(Zt,{width:120,height:120,isAnimated:!0,variant:"splash"}),U?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:[U,t.jsx(zl,{})]})]}):null]}):t.jsx(t.Fragment,{children:t.jsx(wd,{onConnected:()=>R(O=>O+1),notice:V})}):!o&&!ne?z?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(Zt,{width:120,height:120,isAnimated:!0,variant:"splash"})}):t.jsx(qe,{children:t.jsx(Ol,{sdk:Yr.getSdkClient(),directory:p||"",children:t.jsx(Bl,{apis:n,children:t.jsx(Ll,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[t.jsx(Oc,{ready:!B||!te,animated:!0}),t.jsx($l,{embeddedBackgroundWorkEnabled:r}),t.jsx(Bc,{}),t.jsx(zu,{}),t.jsx(Sm,{onActiveConnectionDeleted:()=>{Qt({apiBaseUrl:"",clientToken:null,runtimeKey:Ws}),R(O=>O+1)}}),t.jsx(Fl,{}),t.jsx(Wl,{}),e?t.jsxs(t.Fragment,{children:[t.jsx(Lc,{}),t.jsx($c,{}),t.jsx(Fc,{}),t.jsx(Wc,{})]}):null,t.jsx(Vl,{position:"top-center",offset:"calc(var(--oc-safe-area-top, 0px) + 16px)"}),r?t.jsx(Vc,{}):null]})})})},k)})}function Nm(n){const e=me.c(4),s=f.useSyncExternalStore(Cm,mt,mt);if(Yn()&&!s){let r;return e[0]!==n?(r=t.jsx(Oi,{...n}),e[0]=n,e[1]=r):r=e[1],r}let i;return e[2]!==n?(i=t.jsx(Ac,{children:t.jsx(Oi,{...n})}),e[2]=n,e[3]=i):i=e[3],i}function Cm(n){return $i(()=>n())}const Rm=()=>{nc(),ka().then(()=>{Promise.all([Sa(),rc()]).catch(n=>{console.error("[mobile-main] settings init failed:",n)}),ic(),oc(),ac()}).catch(n=>{console.error("[mobile-main] appearance init failed:",n)}).finally(()=>{Eu()})};function ig(n){window.__OPENCHAMBER_SURFACE__="mobile",Xl(),Rm(),Mu(),Ql();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(Nm,{apis:r});ha.createRoot(e).render(t.jsx(Pn.StrictMode,{children:t.jsx(Zl,{children:t.jsx(ec,{children:t.jsx(tc,{children:t.jsx(Hc,{children:i?o:t.jsx(sc,{children:o})})})})})}))}export{ig as renderMobileApp};