@openchamber/web 2.3.2 → 2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/dist/assets/{AboutDialog-MZbHWRua.js → AboutDialog-Ctk2zvrv.js} +1 -1
  2. package/dist/assets/{ArchiveView-CkeSWPcI.js → ArchiveView-sbNreasJ.js} +1 -1
  3. package/dist/assets/{CommandPalette-CtKzNzwW.js → CommandPalette-BICwnwAZ.js} +2 -2
  4. package/dist/assets/{DiffView-DaXjHTAq.js → DiffView-B5yeuxv8.js} +1 -1
  5. package/dist/assets/{FilesView-DMNYEydF.js → FilesView-ni2zfAwL.js} +7 -7
  6. package/dist/assets/{GitView-HXttTpUw.js → GitView-C0QgeC9O.js} +3 -3
  7. package/dist/assets/{GuestSurfacePane-KzguENQG.js → GuestSurfacePane-D1gLktSj.js} +1 -1
  8. package/dist/assets/{HelpDialog-9YZGhBgT.js → HelpDialog-CxC6qTaS.js} +1 -1
  9. package/dist/assets/{InProgressOperationBanner-DzGIwGH2.js → InProgressOperationBanner-JFV70YFh.js} +1 -1
  10. package/dist/assets/{JsonTreeView-D9rP8jM8.js → JsonTreeView-RsbV4Usa.js} +1 -1
  11. package/dist/assets/MarkdownRendererImpl-CZK5DoOX.js +1 -0
  12. package/dist/assets/{MemoryDebugPanel-Ct0h3RWh.js → MemoryDebugPanel-caUWOKiz.js} +1 -1
  13. package/dist/assets/{OnboardingScreen-B5Zzb1Mp.js → OnboardingScreen-BDT-J2JP.js} +1 -1
  14. package/dist/assets/{OpenCodeStatusDialog-CXBWWRh8.js → OpenCodeStatusDialog-Cxa2yqOB.js} +1 -1
  15. package/dist/assets/{PatchDiff-DhDAQ5em.js → PatchDiff-C1pnbAsJ.js} +1 -1
  16. package/dist/assets/{PierreDiffViewer-DPa08AmN.js → PierreDiffViewer-D0zX2Msu.js} +1 -1
  17. package/dist/assets/PlanView-BxRCMuGe.js +5 -0
  18. package/dist/assets/{ProjectActionsDialog-DATu0aBc.js → ProjectActionsDialog-D660By4K.js} +1 -1
  19. package/dist/assets/{RunOverview-D6xy_vME.js → RunOverview-C1uTMnQS.js} +2 -2
  20. package/dist/assets/{ScheduledTasksDialog-BWXVnfrf.js → ScheduledTasksDialog-S-gAgo7Z.js} +5 -5
  21. package/dist/assets/SettingsView-CVpfbdob.js +30 -0
  22. package/dist/assets/{SettingsWindow-Cx6TrtY0.js → SettingsWindow-Dd1hHvgh.js} +1 -1
  23. package/dist/assets/SourceBoardView-DbGWAxtS.js +1 -0
  24. package/dist/assets/SpaceAccessDialog-muTSsEJ9.js +1 -0
  25. package/dist/assets/{SpaceApplyDialog-BtuwtlaG.js → SpaceApplyDialog-Dsf6MNGm.js} +1 -1
  26. package/dist/assets/{SpaceRow-MXqvd-dr.js → SpaceRow-7Z6ebRtm.js} +1 -1
  27. package/dist/assets/{SpaceSetupOutput-Uo5LS7Jy.js → SpaceSetupOutput-BytPfCOC.js} +1 -1
  28. package/dist/assets/{SpacesView-DvoOh4sM.js → SpacesView-CYCrlp0D.js} +1 -1
  29. package/dist/assets/{SubmoduleDiffSummary-CyMwDeoP.js → SubmoduleDiffSummary-VrNUbIqF.js} +1 -1
  30. package/dist/assets/{ToolOutputDialog-BaUZIVzc.js → ToolOutputDialog-DHORjBND.js} +7 -7
  31. package/dist/assets/{ToolPartDiffPreview-DmMwdcF4.js → ToolPartDiffPreview-BLAXe7C5.js} +1 -1
  32. package/dist/assets/{UsageStatsView-D7WrDBTC.js → UsageStatsView-BxtYEAa0.js} +1 -1
  33. package/dist/assets/{Virtualizer-CnU8pYMb.js → Virtualizer-Bl4Cf-H-.js} +1 -1
  34. package/dist/assets/{WalkthroughView-r0Ho9F4Z.js → WalkthroughView-B2BJJ4u5.js} +2 -2
  35. package/dist/assets/{WorktreesView-C-t7uxq1.js → WorktreesView-Dv0AO9dF.js} +1 -1
  36. package/dist/assets/{appThemeRegistry-BUY7Ge9i.js → appThemeRegistry-xm_W0svA.js} +1 -1
  37. package/dist/assets/{ar-HauNhDvN.js → ar-Cj8UF12m.js} +4 -4
  38. package/dist/assets/{computeVirtualFileMetrics-CUof18z3.js → computeVirtualFileMetrics-Cx05cmWI.js} +2 -2
  39. package/dist/assets/{de-fEoJ_Yyp.js → de-fSQ1ho01.js} +4 -4
  40. package/dist/assets/{decorate-BkTSGAlD.js → decorate-jpF7GA6t.js} +2 -2
  41. package/dist/assets/{es-CKNTBsZW.js → es-DrdzhSlK.js} +5 -5
  42. package/dist/assets/{fileContentPoller-BJWgy1fX.js → fileContentPoller-C0f20jNG.js} +3 -3
  43. package/dist/assets/{flexokiTheme-BArobfXV.js → flexokiTheme-DKNCYSqL.js} +1 -1
  44. package/dist/assets/{fr-C23655Pi.js → fr-Cmz6Da4q.js} +4 -4
  45. package/dist/assets/{he-CphXS_Fv.js → he-COJRUNy4.js} +4 -4
  46. package/dist/assets/{index-B27cSA9V.js → index-C8Mw8uvl.js} +1 -1
  47. package/dist/assets/{initializeSharedPreferences-CucsmDMw.js → initializeSharedPreferences-U9-v9mfq.js} +1 -1
  48. package/dist/assets/{isDiffPlainText-DSCjvV0m.js → isDiffPlainText-DW43IghW.js} +1 -1
  49. package/dist/assets/{isFilePlainText-C7g4UPox.js → isFilePlainText-Duq5CiuG.js} +1 -1
  50. package/dist/assets/{ja-BmsU2iQe.js → ja-Ce0NvDHZ.js} +4 -4
  51. package/dist/assets/katex-BZNCT55U.css +1 -0
  52. package/dist/assets/katex.min-EZjpSwGK.js +65 -0
  53. package/dist/assets/{ko-CxISpkje.js → ko-BGFcCLLq.js} +4 -4
  54. package/dist/assets/main-BUetg9hg.js +1048 -0
  55. package/dist/assets/{main-CGPiw9fS.js → main-Be_jmIlF.js} +2 -2
  56. package/dist/assets/markdownCore-BkTeS4gA.js +10 -0
  57. package/dist/assets/{miniChat-DVEKVYKe.js → miniChat-g1RgiLLS.js} +2 -2
  58. package/dist/assets/{mobile-Q_FVBe4I.js → mobile-DBli3U-T.js} +2 -2
  59. package/dist/assets/{moveWorkspacePath-CyZJ-2aD.js → moveWorkspacePath-CnYc96Xo.js} +1 -1
  60. package/dist/assets/{nl-jnTBQ_gU.js → nl-Cu1nxo5t.js} +4 -4
  61. package/dist/assets/{parseDiffFromFile-OHXXXyzL.js → parseDiffFromFile-DEjkjYod.js} +3 -3
  62. package/dist/assets/{patchFileDiff-BZrb6h2u.js → patchFileDiff-D__42sau.js} +5 -5
  63. package/dist/assets/{pierreDiffTint-DHf2xvyt.js → pierreDiffTint-3oatL635.js} +4 -4
  64. package/dist/assets/pl-4LdEMgWI.js +20 -0
  65. package/dist/assets/{pt-BR-BfpsFrHv.js → pt-BR-2UbEBNgC.js} +5 -5
  66. package/dist/assets/{relocateRestoredSession-DInneXVI.js → relocateRestoredSession-pkxyd_lV.js} +1 -1
  67. package/dist/assets/renderElectronMiniChatApp-D0tKJFBB.js +2 -0
  68. package/dist/assets/renderMobileApp-D6bOYHuP.js +25 -0
  69. package/dist/assets/{restartOpenCode-DwBaMPJK.js → restartOpenCode-FYqjpaWc.js} +1 -1
  70. package/dist/assets/runtimeEndpointReset-6CNNzem4.js +74 -0
  71. package/dist/assets/{scheduledTasksApi-ClJplEhR.js → scheduledTasksApi-BbnQ4W-W.js} +1 -1
  72. package/dist/assets/{selectionMarkdown-BuveYuup.js → selectionMarkdown-D8QAxC44.js} +1 -1
  73. package/dist/assets/sessionOwnership-BBuf0UCB.js +1 -0
  74. package/dist/assets/{shikiHighlight-DJAESrna.js → shikiHighlight-CweIj1cL.js} +1 -1
  75. package/dist/assets/{space-apply-DWFLwXbI.js → space-apply-CEi013sa.js} +1 -1
  76. package/dist/assets/{space-close-BYDbwdWc.js → space-close-BuStkLrZ.js} +1 -1
  77. package/dist/assets/{spaceNetwork-DHrhfbKM.js → spaceNetwork-tH2d5Mgs.js} +1 -1
  78. package/dist/assets/{textMateThemeFromAppTheme-DcAZmUlv.js → textMateThemeFromAppTheme-DLJBL6al.js} +1 -1
  79. package/dist/assets/tr-Bg0Qt-mG.js +11 -0
  80. package/dist/assets/{uk-C82aEtvs.js → uk-vcnOugr0.js} +5 -5
  81. package/dist/assets/useAppFontEffects-Cs6k0JKv.js +773 -0
  82. package/dist/assets/{useCallableModelProviders-BU_455MN.js → useCallableModelProviders-BsGEzsl2.js} +1 -1
  83. package/dist/assets/{useInlineCommentController-AuUrVz9U.js → useInlineCommentController-CVYaPzfO.js} +2 -2
  84. package/dist/assets/{useRootScrollLock-Cpk7NmBa.js → useRootScrollLock-Dov-44ov.js} +2 -2
  85. package/dist/assets/{vendor-codemirror-language-data-BYGweLoh.js → vendor-codemirror-language-data-DBekkZIx.js} +2 -2
  86. package/dist/assets/vendor-tanstack-react-virtual-Dozz-7fb.js +1 -0
  87. package/dist/assets/vendor-tanstack-virtual-core-DKBj55Em.js +1 -0
  88. package/dist/assets/{vendor-yaml-3778uTud.js → vendor-yaml-CE-D_49-.js} +1 -1
  89. package/dist/assets/{zh-CN-DEq7j9I5.js → zh-CN-C3UhwFsk.js} +5 -5
  90. package/dist/assets/{zh-TW-DgCN99T-.js → zh-TW-D0CmmMvp.js} +5 -5
  91. package/dist/index.html +3 -3
  92. package/dist/mini-chat.html +3 -3
  93. package/dist/mobile.html +3 -3
  94. package/package.json +5 -5
  95. package/server/index.js +13 -1
  96. package/server/lib/agent-memory/actions.js +22 -9
  97. package/server/lib/agent-memory/actions.test.js +57 -0
  98. package/server/lib/agent-memory/runtime.js +8 -5
  99. package/server/lib/agent-tool/DOCUMENTATION.md +17 -1
  100. package/server/lib/agent-tool/runtime.js +41 -7
  101. package/server/lib/agent-tool/runtime.test.js +11 -0
  102. package/server/lib/git/DOCUMENTATION.md +17 -5
  103. package/server/lib/git/lfs-discovery.js +7 -4
  104. package/server/lib/git/lfs-discovery.test.js +60 -0
  105. package/server/lib/git/network-operations.js +9 -3
  106. package/server/lib/git/network-operations.test.js +31 -2
  107. package/server/lib/git/service.js +72 -12
  108. package/server/lib/git/service.test.js +65 -0
  109. package/server/lib/github/DOCUMENTATION.md +1 -0
  110. package/server/lib/github/reference-search.js +49 -18
  111. package/server/lib/github/reference-search.test.js +28 -6
  112. package/server/lib/github/routes.js +87 -1
  113. package/server/lib/github/routes.mutations.test.js +38 -0
  114. package/server/lib/github/routes.test.js +1 -0
  115. package/server/lib/gitlab/DOCUMENTATION.md +4 -0
  116. package/server/lib/gitlab/client.js +23 -0
  117. package/server/lib/gitlab/client.test.js +28 -1
  118. package/server/lib/gitlab/mappers.js +9 -0
  119. package/server/lib/gitlab/resources.js +153 -4
  120. package/server/lib/gitlab/resources.test.js +107 -0
  121. package/server/lib/gitlab/routes.js +120 -1
  122. package/server/lib/gitlab/routes.test.js +59 -0
  123. package/server/lib/markdown-image-grants/DOCUMENTATION.md +4 -0
  124. package/server/lib/markdown-image-grants/routes.js +14 -2
  125. package/server/lib/markdown-image-grants/routes.test.js +23 -0
  126. package/server/lib/notifications/APNS.md +24 -23
  127. package/server/lib/notifications/DOCUMENTATION.md +2 -2
  128. package/server/lib/notifications/apns-runtime.js +8 -5
  129. package/server/lib/notifications/apns-runtime.test.js +26 -0
  130. package/server/lib/notifications/message.js +5 -3
  131. package/server/lib/notifications/message.test.js +9 -0
  132. package/server/lib/notifications/runtime.js +44 -9
  133. package/server/lib/notifications/trigger-runtime.test.js +84 -0
  134. package/server/lib/openchamber-control/DOCUMENTATION.md +6 -1
  135. package/server/lib/openchamber-control/actions.js +18 -2
  136. package/server/lib/openchamber-control/project-knowledge.js +17 -3
  137. package/server/lib/openchamber-control/project-knowledge.test.js +14 -0
  138. package/server/lib/openchamber-control/render-page.js +58 -0
  139. package/server/lib/openchamber-control/service.js +9 -0
  140. package/server/lib/openchamber-control/service.test.js +43 -0
  141. package/server/lib/openchamber-sessions/routes.js +1 -0
  142. package/server/lib/openchamber-sessions/worktree-move.js +26 -10
  143. package/server/lib/openchamber-sessions/worktree-move.test.js +36 -0
  144. package/server/lib/opencode/DOCUMENTATION.md +1 -1
  145. package/server/lib/opencode/managed-config-file.js +3 -2
  146. package/server/lib/opencode/managed-config-file.test.js +20 -6
  147. package/server/lib/opencode/settings-helpers.js +3 -0
  148. package/server/lib/opencode/settings-helpers.test.js +1 -1
  149. package/server/lib/opencode/settings-registry.json +3 -0
  150. package/server/lib/opencode/settings-runtime.js +1 -0
  151. package/server/lib/project-context/DOCUMENTATION.md +25 -1
  152. package/server/lib/project-context/plan-progress.js +69 -0
  153. package/server/lib/project-context/plan-progress.test.js +58 -0
  154. package/server/lib/project-context/routes.http.test.js +22 -0
  155. package/server/lib/project-context/routes.js +20 -0
  156. package/server/lib/project-context/runtime.js +132 -18
  157. package/server/lib/project-context/runtime.test.js +58 -0
  158. package/server/lib/provider-read-cache/index.js +7 -1
  159. package/server/lib/provider-read-cache/index.test.js +12 -0
  160. package/server/lib/relay/DOCUMENTATION.md +17 -1
  161. package/server/lib/session-knowledge/DOCUMENTATION.md +17 -0
  162. package/server/lib/session-knowledge/runtime.js +29 -6
  163. package/server/lib/session-knowledge/runtime.test.js +26 -1
  164. package/server/lib/source-control/audit-storage.js +1 -0
  165. package/server/lib/source-control/mutation-storage.js +3 -0
  166. package/server/lib/spaces/DOCUMENTATION.md +14 -9
  167. package/server/lib/spaces/code-out.js +13 -4
  168. package/server/lib/spaces/code-out.test.js +5 -3
  169. package/server/lib/spaces/dispatcher.js +12 -5
  170. package/server/lib/spaces/dispatcher.test.js +19 -1
  171. package/server/lib/spaces/gatekeeper-channel.js +8 -7
  172. package/server/lib/spaces/gatekeeper-channel.test.js +10 -0
  173. package/server/lib/spaces/gatekeeper-program.cjs +38 -3
  174. package/server/lib/spaces/gatekeeper-program.test.js +20 -0
  175. package/server/lib/spaces/hardening.js +14 -1
  176. package/server/lib/spaces/hardening.test.js +5 -0
  177. package/server/lib/spaces/host-providers.js +165 -0
  178. package/server/lib/spaces/host-providers.test.js +100 -0
  179. package/server/lib/spaces/host.js +16 -4
  180. package/server/lib/spaces/journey.js +87 -17
  181. package/server/lib/spaces/journey.test.js +90 -2
  182. package/server/lib/spaces/layout.js +15 -5
  183. package/server/lib/spaces/places/docker-live-support.js +2 -0
  184. package/server/lib/spaces/places/docker.test.js +2 -0
  185. package/server/lib/spaces/places/fake-docker.js +3 -0
  186. package/server/lib/spaces/places/grants.docker.live.test.js +71 -7
  187. package/server/lib/spaces/routes.js +9 -0
  188. package/server/lib/spaces/routes.test.js +4 -2
  189. package/server/lib/spaces/space-opencode.js +31 -14
  190. package/server/lib/spaces/space-opencode.test.js +15 -2
  191. package/server/lib/spaces/space-records.js +8 -0
  192. package/server/lib/spaces/space-records.test.js +7 -3
  193. package/server/lib/spaces/websocket.test.js +13 -1
  194. package/server/lib/ui-auth/ui-auth.js +28 -3
  195. package/server/lib/ui-auth/ui-auth.test.js +31 -0
  196. package/dist/assets/MarkdownRendererImpl-B2LsA09C.js +0 -1
  197. package/dist/assets/PlanView-Dt5EN_JK.js +0 -5
  198. package/dist/assets/SettingsView-BolP_tuu.js +0 -30
  199. package/dist/assets/SourceBoardView-yca1qvgB.js +0 -1
  200. package/dist/assets/SpaceAccessDialog-CZ-u75py.js +0 -1
  201. package/dist/assets/katex-rNcbfUj4.css +0 -1
  202. package/dist/assets/katex.min-DQ8qF6NR.js +0 -65
  203. package/dist/assets/main-CVHM3_8W.js +0 -1048
  204. package/dist/assets/markdownCore-D5ZOJXeO.js +0 -9
  205. package/dist/assets/pl-Bj-Hy0X5.js +0 -20
  206. package/dist/assets/renderElectronMiniChatApp-B_5BeSF6.js +0 -2
  207. package/dist/assets/renderMobileApp-DGEXUTk-.js +0 -25
  208. package/dist/assets/runtimeEndpointReset-CIpvn8QG.js +0 -59
  209. package/dist/assets/sessionOwnership-BZoGed9N.js +0 -1
  210. package/dist/assets/tr-qMRMBQ8r.js +0 -11
  211. package/dist/assets/useAppFontEffects-Bih1DxXi.js +0 -745
  212. package/dist/assets/vendor-tanstack-react-virtual-CvuLsk7D.js +0 -1
  213. package/dist/assets/vendor-tanstack-virtual-core-DPaNcJcT.js +0 -1
@@ -0,0 +1,25 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesView-ni2zfAwL.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/katex.min-EZjpSwGK.js","assets/vendor-zod-CVhJ1Zpv.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-DgOf1DP0.js","assets/katex-BZNCT55U.css","assets/useAppFontEffects-Cs6k0JKv.js","assets/vendor-base-ui-CXFyogip.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-tanstack-react-virtual-Dozz-7fb.js","assets/vendor-tanstack-virtual-core-DKBj55Em.js","assets/vendor-framer-motion-DxDVhOLc.js","assets/vendor-motion-dom-HXPOMxb7.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-codemirror-commands-dar6chwA.js","assets/vendor-codemirror-state-Dek9sMtw.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-B66jUSmE.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-codemirror-language-DyL0aCoH.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-streamparser-CmlTsbN2.js","assets/vendor-codemirror-lang-javascript-Cem6LjJ8.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-CIqXJolH.js","assets/vendor-codemirror-lang-json-C9rLLO0q.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-9qjxcVkg.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-D7VQUxeE.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-Cikh4w2I.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-DBekkZIx.js","assets/vendor-codemirror-lang-python-DVl8-2Op.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-legendapp-list-BCBzRcfK.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/flexokiTheme-DKNCYSqL.js","assets/vendor-codemirror-search-BKAwkhkm.js","assets/vendor-replit-codemirror-vim-CKWqK1yR.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/moveWorkspacePath-CnYc96Xo.js","assets/fileContentPoller-C0f20jNG.js","assets/useInlineCommentController-CVYaPzfO.js","assets/runtimeEndpointReset-6CNNzem4.js","assets/JsonTreeView-RsbV4Usa.js","assets/parseDiffFromFile-DEjkjYod.js","assets/computeVirtualFileMetrics-Cx05cmWI.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-yJ9XpNMI.js","assets/vendor-pierre-theming-Dgp7B_O4.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/vendor-diff-C3JhlQdm.js","assets/Virtualizer-BP6uuKe_.js","assets/isFilePlainText-Duq5CiuG.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/shikiHighlight-CweIj1cL.js","assets/appThemeRegistry-xm_W0svA.js","assets/textMateThemeFromAppTheme-DLJBL6al.js","assets/Virtualizer-Bl4Cf-H-.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/scheduledTasksApi-BbnQ4W-W.js","assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-capacitor-push-notifications-KNe1zSBF.js"])))=>i.map(i=>d[i]);
2
+ import{f as ue,r as Tr,j as t,R as c,c as Ps,h as dl}from"./vendor-react-BUCujlKS.js";import{u as Ve,$ as mn,bd as Hr,be as Li,bf as et,a_ as kt,bg as Ns,bh as cn,l as Uo,bi as Qn,bj as Go,bk as fl,bl as Ko,bm as ml,bn as pl,bo as hl,bp as gl,e as Mt,n as pn,z as bl,A as xl,bq as Rt,ar as In,br as yl,a0 as Ys,b as Fi,aH as Xs,aU as vl,ax as $i,ag as wl,af as jl,bs as Wi,aq as kl,a1 as qo,bt as Vi,bu as Sl,au as Ui,v as Gi,bv as An}from"./katex.min-EZjpSwGK.js";import{G as as,dG as Nl,a3 as it,cf as Dr,cg as Ho,J as Jo,gn as Cl,u as ye,z as ce,cY as Rl,I as Y,dn as El,B as Ee,av as Yo,a8 as Cs,L as te,bN as Xo,go as Il,gp as Al,d7 as Pl,$ as ft,aJ as Tl,gq as ss,gr as Dl,gs as Ki,gt as Ml,gu as _l,ex as Jr,d3 as Ol,d4 as zl,F as Be,ei as Bl,ek as Yr,el as Xr,gv as Qr,en as Ll,em as Qo,gw as Zr,dE as $n,bT as Zo,gx as Fl,e5 as ea,ay as ct,bS as ta,ci as Zn,gy as $l,gz as Wl,gA as Vl,gB as Ul,f4 as Bn,fN as Mr,fx as Bt,gC as Gl,k as Kl,aB as sa,c4 as na,c5 as ra,c6 as ia,gD as ql,gE as Hl,gF as Jl,dF as qi,gG as oa,gH as aa,b5 as ei,y as la,gI as Yl,gJ as Xl,gK as ca,gL as Ql,ch as Zl,a4 as ec,ct as tc,gM as vr,gN as sc,cs as ks,gO as ua,K as nc,gP as rc,aM as _r,aN as Or,aO as zr,cF as Hi,cG as wr,aP as Qs,c3 as er,d1 as ic,bI as da,du as fa,gQ as oc,gR as ac,gS as Ss,gT as Is,T as lc,U as cc,V as uc,gU as dc,fG as fc,az as ti,e2 as mc,e6 as pc,eQ as hc,eZ as gc,eU as bc,eD as ma,eV as xc,e_ as yc,e7 as vc,e3 as wc,fy as jc,fC as kc,e8 as Sc,gV as Nc,gW as Cc,gX as Rc,gY as Ec,fF as Ji,dW as Pn,bW as Ic,cA as Ac,cC as Tn,ea as Pc,eX as Tc,bz as Dc,e9 as Mc,fK as _c,fM as Oc,fH as zc,cx as pa,aQ as Ze,cq as Bc,d2 as Lc,gZ as Fc,g_ as $c,g$ as Wc,h0 as Vc,cv as Uc,h1 as Gc,eS as Yi,h2 as si,cE as Kc,h3 as qc,h4 as Hc,c7 as Br,dg as Jc,dh as Yc,di as Xc,dj as Qc,h5 as Zc,dq as eu,dp as tu,dk as su,h6 as nu,dl as ru,dm as iu,dv as ou,dt as au,h7 as lu,h8 as cu,h9 as uu,ha as du,hb as fu,hc as mu,hd as pu,he as hu,dw as gu,dx as bu,dy as xu,dz as yu}from"./useAppFontEffects-Cs6k0JKv.js";import{a3 as Rs,a4 as vu,a5 as wu,a6 as ju,a7 as ku,a8 as ha,a9 as ga,aa as ba,ab as Su,ac as Nu,ad as Cu,ae as Dn,af as Ru,ag as Eu,ah as Iu,S as Au,ai as Pu,D as xa,a as Tu,aj as Du,ak as Mu,al as _u,J as Mn,R as Ou,U as zu,M as Bu,x as Xi,W as jr,Y as Lu,Z as Fu,A as $u,am as Wu,K as Vu,L as Uu,an as Gu,ao as Ku,O as qu,y as Hu,_ as Ju,I as Yu,ap as Xu,aq as Qu,$ as Zu,ar as ed,as as td,at as sd,au as nd,av as rd,aw as id,ax as od,ay as ad,az as ld,aA as cd,aB as ud,aC as dd,aD as fd,aE as md,aF as pd,aG as hd,aH as gd,aI as bd,aJ as xd,aK as yd}from"./runtimeEndpointReset-6CNNzem4.js";import{i as vd}from"./initializeSharedPreferences-U9-v9mfq.js";import{_ as Ts}from"./vendor-vite-runtime-DD1OZmLC.js";import{S as wd,A as jd}from"./SettingsView-CVpfbdob.js";import{PlanView as kd}from"./PlanView-BxRCMuGe.js";import{SpaceAccessDialog as Sd}from"./SpaceAccessDialog-muTSsEJ9.js";import{SpaceApplyDialog as Nd}from"./SpaceApplyDialog-Dsf6MNGm.js";import{SpaceSetupOutputDialog as Cd}from"./SpaceSetupOutput-BytPfCOC.js";import{RunOverview as Rd}from"./RunOverview-C1uTMnQS.js";import{p as Ed}from"./vendor-aparajita-capacitor-secure-storage-5IShChL0.js";import{Capacitor as Id,registerPlugin as ya}from"./vendor-capacitor-core-B4EWRrHz.js";import{k as Lr,d as Ad,M as Wn,J as va,a as ni,s as wa,p as Pd,_ as Qi,f as ri,V as Td,K as Zi,P as Dd,b as Md,c as _d,U as Od,Z as zd,Q as Bd,r as Ld}from"./vendor-remixicon-react-D6dZ0UwF.js";import{f as ii,h as Ds,i as oi,P as ai,D as li,j as ci}from"./vendor-dnd-kit-core-BZknOX2w.js";import{S as ui,v as di,u as fi,s as mi}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as pi}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{c as Fd}from"./sessionOwnership-BBuf0UCB.js";import{c as hi,p as ja}from"./vendor-zustand-BAGL70zf.js";import{toast as Fr}from"./vendor-sonner-DFyL3AvE.js";import{S as $d}from"./SpaceRow-7Z6ebRtm.js";import{UsageStatsView as Wd}from"./UsageStatsView-BxtYEAa0.js";import{ArchiveSessionsView as Vd}from"./ArchiveView-sbNreasJ.js";import{MobileSourceBoard as Ud}from"./SourceBoardView-DbGWAxtS.js";import{ScheduledTasksView as Gd}from"./ScheduledTasksDialog-S-gAgo7Z.js";import{i as Kd,a as qd,b as Hd,c as Jd,d as Yd,S as Xd,W as Qd}from"./SubmoduleDiffSummary-VrNUbIqF.js";import{R as Zd,I as ef,C as tf,a as sf,b as nf,D as rf}from"./InProgressOperationBanner-JFV70YFh.js";import{b as eo,a as of,c as af,u as lf,i as cf,f as to,B as uf,C as df,P as so}from"./patchFileDiff-D__42sau.js";import{P as ff}from"./PierreDiffViewer-D0zX2Msu.js";import{p as mf}from"./parseDiffFromFile-DEjkjYod.js";import{o as ka,s as no}from"./vendor-zod-CVhJ1Zpv.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-opencode-client-DgOf1DP0.js";import"./vendor-base-ui-CXFyogip.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tanstack-react-virtual-Dozz-7fb.js";import"./vendor-tanstack-virtual-core-DKBj55Em.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-dar6chwA.js";import"./vendor-codemirror-state-Dek9sMtw.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-B66jUSmE.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-language-DyL0aCoH.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-streamparser-CmlTsbN2.js";import"./vendor-codemirror-lang-javascript-Cem6LjJ8.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-CIqXJolH.js";import"./vendor-codemirror-lang-json-C9rLLO0q.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-9qjxcVkg.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-D7VQUxeE.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-Cikh4w2I.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-DBekkZIx.js";import"./vendor-codemirror-lang-python-DVl8-2Op.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-legendapp-list-BCBzRcfK.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-yaml-CE-D_49-.js";import"./flexokiTheme-DKNCYSqL.js";import"./vendor-codemirror-search-BKAwkhkm.js";import"./vendor-replit-codemirror-vim-CKWqK1yR.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./shikiHighlight-CweIj1cL.js";import"./appThemeRegistry-xm_W0svA.js";import"./textMateThemeFromAppTheme-DLJBL6al.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-qrcode-DTJ12-WC.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./vendor-strip-json-comments-5dJlOkP1.js";import"./useCallableModelProviders-BsGEzsl2.js";import"./restartOpenCode-FYqjpaWc.js";import"./useInlineCommentController-CVYaPzfO.js";import"./fileContentPoller-C0f20jNG.js";import"./spaceNetwork-tH2d5Mgs.js";import"./space-apply-CEi013sa.js";import"./scheduledTasksApi-BbnQ4W-W.js";import"./vendor-cron-parser-CjvYVigk.js";import"./vendor-luxon-BZ0puJYg.js";import"./changesTree-CePHbFcj.js";import"./computeVirtualFileMetrics-Cx05cmWI.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-DW43IghW.js";import"./vendor-diff-C3JhlQdm.js";import"./pierreDiffTint-3oatL635.js";import"./Virtualizer-Bl4Cf-H-.js";let Sa=null,ro=!1;const pf=new Promise(n=>{Sa=n});function hf(){ro||(ro=!0,Sa?.())}const gf=6,bf=n=>n.parentID??null,$r=n=>{const e=n.replace(/\/+$/,"");return e.slice(e.lastIndexOf("/")+1)||e},xf=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),yf=(n,e)=>{if(!n)return"";let s=null,r=-1;for(const i of e){const a=xf(i.path);(n===a||n.startsWith(`${a}/`))&&a.length>r&&(s=i,r=a.length)}return s?s.label?.trim()||$r(s.path):$r(n)},vf=()=>{const n=as.getState().activeSessions,e=Nl.getState().index.session.unseenCount,s=Ve.getState().notifyOnSubtasks,r=it.getState().projects,i=Dr.getState().ids,a=Ho.getState().rankById;let o=0;const l=[];for(const p of n){const f=bf(p)!==null,d=(e[p.id]??0)>0&&(!f||s);d&&(o+=1),f||l.push({session:p,unread:d,project:yf(Jo(p),r)})}l.sort((p,f)=>Cl(p.session,f.session,i,a));const m=l.slice(0,gf).map(({session:p,unread:f,project:g})=>({id:p.id,title:p.title??"",unread:f,project:g}));return{runtimeKey:mn(),attentionCount:o,recentSessions:m,projects:r.map(p=>({id:p.id,label:p.label?.trim()||$r(p.path)}))}},wf="__OPENCHAMBER_WIDGET_SNAPSHOT__",jf=()=>{typeof window>"u"||(window[wf]=()=>{try{return JSON.stringify(vf())}catch{return null}})},kr="mobile-app-update-available",io="mobile-app-update-toast-dismissed-version",kf=()=>{const n=ue.c(8),{t:e}=ye(),s=Rs(Sf),r=Rs(Nf),i=Rs(Cf),a=Rs(Rf);let o;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=new Set,n[0]=o):o=n[0];const l=Tr.useRef(o);let m,p;return n[1]!==s||n[2]!==a||n[3]!==r||n[4]!==e||n[5]!==i?(m=()=>{if(Hr()!=="android"||r!=="mobile"||!s||!i||!a){ce.dismiss(kr);return}Li().getItem(io)!==i&&(l.current.has(i)||(l.current.add(i),ce.info(e("mobileUpdate.toast.available.title"),{id:kr,description:e("mobileUpdate.toast.available.description",{version:i}),duration:1/0,icon:t.jsx(Y,{name:"download",className:"h-4 w-4 text-muted-foreground"}),action:{label:e("mobileUpdate.toast.actions.download"),onClick:()=>{Rl(a)}},cancel:{label:e("mobileUpdate.toast.actions.dismiss"),onClick:()=>{Li().setItem(io,i),ce.dismiss(kr)}}})))},p=[s,a,r,e,i],n[1]=s,n[2]=a,n[3]=r,n[4]=e,n[5]=i,n[6]=m,n[7]=p):(m=n[6],p=n[7]),Tr.useEffect(m,p),null};function Sf(n){return n.available}function Nf(n){return n.runtimeType}function Cf(n){return n.info?.version}function Rf(n){return n.info?.downloadUrl}const oo="calc(var(--oc-safe-area-top, 0px) + var(--oc-visual-viewport-offset-top, 0px) + 16px)";function Ef(n){const e=ue.c(3);let s,r;e[0]!==n?(s=()=>{const i=window.visualViewport,a=n.current;if(!i||!a)return;let o="";const l=()=>{const m=`${Math.max(0,Math.round(i.offsetTop))}px`;m!==o&&(o=m,a.style.setProperty("--oc-visual-viewport-offset-top",m))};return l(),i.addEventListener("scroll",l),i.addEventListener("resize",l),()=>{i.removeEventListener("scroll",l),i.removeEventListener("resize",l)}},r=[n],e[0]=n,e[1]=s,e[2]=r):(s=e[1],r=e[2]),c.useEffect(s,r)}function If(){const n=ue.c(1),e=c.useRef(null);Ef(e);let s;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx("div",{ref:e,className:"contents",children:t.jsx(El,{position:"top-center",offset:oo,mobileOffset:{top:oo}})}),n[0]=s):s=n[0],s}const ao=300,Af="openchamber.mobile.connectLog.v1",Es=[];if(typeof window<"u")try{window.localStorage.removeItem(Af)}catch{}const gi=(n,e)=>{Es.push({at:Date.now(),step:n,detail:e}),Es.length>ao&&Es.splice(0,Es.length-ao)};typeof window<"u"&&gi("app:launch","{}");const Pf=()=>[...Es],Tf=n=>{const e=new Date(n),s=(r,i=2)=>String(r).padStart(i,"0");return`${s(e.getHours())}:${s(e.getMinutes())}:${s(e.getSeconds())}.${s(e.getMilliseconds(),3)}`},Na=n=>`${Tf(n.at)} ${n.step}${n.detail&&n.detail!=="{}"?` ${n.detail}`:""}`,Df=()=>Es.map(Na).join(`
3
+ `),Ca=(n,e)=>{const s=ue.c(10),r=700,i=c.useRef(null),a=c.useRef(null),o=c.useRef(!1);let l;s[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{i.current!==null&&window.clearTimeout(i.current),i.current=null,a.current=null},s[0]=l):l=s[0];const m=l;let p,f;s[1]===Symbol.for("react.memo_cache_sentinel")?(p=()=>m,f=[m],s[1]=p,s[2]=f):(p=s[1],f=s[2]),c.useEffect(p,f);let g;s[3]!==r||s[4]!==n?(g=C=>{o.current=!1,a.current={x:C.clientX,y:C.clientY},i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>{i.current=null,o.current=!0,n()},r)},s[3]=r,s[4]=n,s[5]=g):g=s[5];const d=g;let h;s[6]===Symbol.for("react.memo_cache_sentinel")?(h=C=>{const R=a.current;R&&(Math.abs(C.clientX-R.x)>10||Math.abs(C.clientY-R.y)>10)&&m()},s[6]=h):h=s[6];const b=h;let v;s[7]===Symbol.for("react.memo_cache_sentinel")?(v=C=>{o.current&&(o.current=!1,C.preventDefault(),C.stopPropagation())},s[7]=v):v=s[7];const x=v;let S;return s[8]!==d?(S={onPointerDown:d,onPointerMove:b,onPointerUp:m,onPointerCancel:m,onClickCapture:x},s[8]=d,s[9]=S):S=s[9],S},Mf=async(n,e)=>{let s;const r=new Promise(i=>{s=setTimeout(()=>i({response:null,failure:"timeout"}),n)});try{return await Promise.race([e.then(i=>({response:i,failure:null}),i=>({response:null,failure:i instanceof Error?i.message:String(i)})),r])}finally{s!==void 0&&clearTimeout(s)}},_f=(n,e)=>new Promise(s=>{const r=l=>{clearTimeout(a),o(),s(l)},i=l=>{l.state==="connected"?r(!0):(l.state==="idle"||l.terminal)&&r(!1)},a=setTimeout(()=>r(!1),e),o=n.subscribeStatus(i);i(n.getStatus())}),Ms=(n,e,s,r)=>Mf(r,n.fetch(e,s)),Ra=async(n,e,s,r)=>{const i=Date.now()+r;let a=await Ms(n,e,s,r);for(;!a.response&&a.failure!=="timeout"&&n.getStatus().state!=="connected";){const o=i-Date.now();if(o<=0||!await _f(n,o))return a;const l=i-Date.now();if(l<=0)return a;a=await Ms(n,e,s,l)}return a},Vn="openchamber.mobile.connections.v1",Of="openchamber.mobile.",lo="openchamber.mobile.deviceId",zf=()=>{try{const n=window.localStorage.getItem(lo);if(n&&n.trim())return n.trim();const e=crypto.randomUUID();return window.localStorage.setItem(lo,e),e}catch{return crypto.randomUUID()}},co=()=>`mobile:${zf()}`,uo=()=>{try{const n=Id.getPlatform();return n==="ios"||n==="android"?n:void 0}catch{return}},Ea=12,bi=8e3,Bf=2500,Lf=3e3,Un=2500,Ff=()=>{let n=0;return{begin:()=>(n+=1,n),cancel:()=>{n+=1},isCurrent:e=>e===n}},Bs=n=>{const e=n.trim();if(!e)return"";const s=/^https?:\/\//i.test(e)?e:`http://${e}`,r=new URL(s);return r.hash="",r.search="",r.pathname=r.pathname.replace(/\/+$/,""),r.toString().replace(/\/+$/,"")},Ln=n=>{try{return new URL(n).host}catch{return n}},_s=n=>{try{return Bs(n)}catch{return n.trim().replace(/\/+$/g,"")}},Ia=(n,e)=>_s(n)===_s(e),Aa=n=>`relay:${n.serverId}@${n.relayUrl.trim()}`,$f=n=>`relay://${n.serverId}`,tr=n=>n.candidates.filter(e=>e.kind==="direct"),ls=n=>{const e=n.candidates.find(s=>s.kind==="relay");return e&&e.kind==="relay"?e.relay:null},Dt=n=>{const e=tr(n)[0];if(e)return e.url;const s=ls(n);return s?$f(s):""},Ye=n=>{const e=ls(n);if(e)return Aa(e);const s=tr(n)[0];return s?_s(s.url):""},Gn=(n,e)=>{const s=n.find(a=>a.kind==="relay"),r=s&&s.kind==="relay"?s.relay.serverId:null,i=new Set(n.filter(a=>a.kind==="direct").map(a=>_s(a.url)));return e.some(a=>a.kind==="relay"?r!==null&&a.relay.serverId===r:i.has(_s(a.url)))},xi=n=>{const e=(()=>{try{return Bs(n)}catch{return""}})();return e?[{kind:"direct",url:e}]:[]},fo=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(...xi(n.url)),n.relay&&e.push({kind:"relay",relay:n.relay}),e},yi=n=>{if(!n||typeof n!="object"||Array.isArray(n))return null;const e=n;if(typeof e.relayUrl!="string"||!e.relayUrl.trim()||typeof e.serverId!="string"||!e.serverId.trim())return null;const s=e.hostEncPubJwk;if(!s||typeof s!="object"||Array.isArray(s))return null;const r=s;return r.kty!=="EC"||r.crv!=="P-256"||typeof r.x!="string"||!r.x||typeof r.y!="string"||!r.y?null:{relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:{kty:"EC",crv:"P-256",x:r.x,y:r.y}}},Pa=n=>{try{return JSON.stringify(n)}catch{return String(n)}},Ie=(n,e={})=>{const s=Pa(e);console.info("[mobile-connect]",n,s),gi(n,s)},Zs=(n,e={})=>{Ie(n,e)},Os=(n,e={})=>{const s=Pa(e);console.info("[mobile-storage]",n,s),gi(n,s)},Wf=n=>{if(typeof n!="string")return n;try{return JSON.parse(n)}catch{return n}},Vf=n=>{if(typeof n!="string")return n??void 0;try{return JSON.parse(n)}catch{return n}},Uf=async(n,e)=>{if(!et())return null;try{const{CapacitorHttp:s}=await Ts(async()=>{const{CapacitorHttp:a}=await import("./vendor-capacitor-core-B4EWRrHz.js");return{CapacitorHttp:a}},[]),r=pl(n,new Headers(e?.headers)),i=await s.request({url:n,method:e?.method||"GET",headers:Object.fromEntries(r.entries()),data:Vf(e?.body)});return{ok:i.status>=200&&i.status<300,status:i.status,source:"native-http",json:async()=>Wf(i.data)}}catch(s){return Ie("native-http:failed",{url:n,error:s instanceof Error?s.message:String(s)}),null}},Gf=async(n,e)=>{const s=await fetch(n,e).catch(r=>(Ie("browser-fetch:failed",{url:n,error:r instanceof Error?r.message:String(r)}),null));return s?{ok:s.ok,status:s.status,source:"browser-fetch",json:()=>s.json()}:null},Kn=async(n,e,s)=>{let r;const i=new Promise(a=>{r=window.setTimeout(()=>{s?.(),a(null)},n)});try{return await Promise.race([e,i])}catch{return null}finally{r!==void 0&&window.clearTimeout(r)}},cs=async(n,e,s)=>{const r=s?.totalTimeoutMs??bi,i=Date.now(),a=await Kn(Math.min(Bf,r),Uf(n,e));if(a)return a;const o=new AbortController,l=Math.max(500,r-(Date.now()-i));return Kn(l,Gf(n,{...e,signal:o.signal}),()=>o.abort())},sr=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}},zs=15e3,Ta=n=>{n?.owned&&n.client.close()},mo=async(n,e)=>{if(n.status===401)return e?"auth-failed":"needs-login";if(!n.ok&&n.status!==404)return"auth-failed";const s=await sr(n);return s&&s.disabled!==!0&&s.authenticated===!1?e?"auth-failed":"needs-login":"ok"},Kf=async(n,e,s,r=zs,i)=>{const a=e?{Authorization:`Bearer ${e}`}:void 0,o=_a(n);if(o){const{response:m,failure:p}=await Ms(o,"/auth/session",{headers:a},r);if(Ie("relay:session",{shared:!0,ok:m?.ok===!0,status:m?.status??null,hasToken:!!e,error:p}),m){const f=await mo(m,e);return f==="ok"&&i?.keepTunnel?{outcome:f,tunnel:{client:o,owned:!1}}:{outcome:f}}}const l=Ko({relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk});try{const{response:m,failure:p}=await Ra(l,"/auth/session",{headers:a},r);Ie("relay:session",{shared:!1,ok:m?.ok===!0,status:m?.status??null,hasToken:!!e,error:p});const f=m?await mo(m,e):Qn(l.getStatus())?"relay-limit":"unreachable";return f==="ok"&&i?.keepTunnel?{outcome:f,tunnel:{client:l,owned:!0}}:(l.close(),{outcome:f})}catch(m){throw l.close(),m}},qf=(n,e,s,r,i)=>{const a=typeof window<"u"?window.location.origin:"",o={relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk,...s?{grant:s}:{}};i&&fl(o,i),Ns({apiBaseUrl:a,clientToken:e,runtimeKey:r??Aa(n),relay:o})},Hf=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=yi(e.relay);return s?{kind:"relay",relay:s}:null}return null},Jf=n=>{if(n.mode==="relay"){const e=yi(n.relay);return e?[{kind:"relay",relay:e}]:[]}return typeof n.url=="string"?xi(n.url):[]},us=()=>{if(typeof window>"u")return[];let n;try{n=JSON.parse(window.localStorage.getItem(Vn)||"[]")}catch{return[]}if(!Array.isArray(n))return[];const e=et();return n.flatMap(s=>{if(!s||typeof s!="object")return[];const r=s;if(typeof r.id!="string")return[];const i=Array.isArray(r.candidates)?r.candidates.map(Hf).filter(m=>!!m):Jf(r);if(i.length===0)return[];const a=typeof r.clientToken=="string"&&r.clientToken.trim()?r.clientToken:void 0,o=typeof r.label=="string"&&r.label.trim()?r.label:Ln(Dt({candidates:i})),l={id:r.id,label:o,candidates:i,lastUsedAt:typeof r.lastUsedAt=="number"?r.lastUsedAt:0};return e?[{...l,hasToken:!!r.hasToken||!!a}]:[{...l,clientToken:a,hasToken:!!a}]}).sort((s,r)=>r.lastUsedAt-s.lastUsedAt)},Wr=n=>n.kind==="relay"?{kind:"relay",relay:{relayUrl:n.relay.relayUrl,serverId:n.relay.serverId,hostEncPubJwk:n.relay.hostEncPubJwk}}:{kind:"direct",url:n.url},vi=n=>{if(typeof window>"u")return;const e=et(),s=n.slice(0,Ea).map(r=>{const i={id:r.id,label:r.label,candidates:r.candidates.map(Wr),lastUsedAt:r.lastUsedAt};return e?{...i,hasToken:!!(r.hasToken||r.clientToken)}:{...i,clientToken:r.clientToken}});try{window.localStorage.setItem(Vn,JSON.stringify(s))}catch(r){console.warn("[mobile-storage] failed to persist connection metadata",r)}},Da=(n,e)=>{const s=n.find(a=>e.id&&a.id===e.id||Gn(a.candidates,e.candidates)),r=et(),i={id:e.id||s?.id||crypto.randomUUID(),label:e.label,candidates:e.candidates,lastUsedAt:Date.now(),...r?{hasToken:e.hasToken??(!!e.clientToken||s?.hasToken||!1)}:{clientToken:e.clientToken??s?.clientToken,hasToken:!!(e.clientToken??s?.clientToken)}};return[i,...n.filter(a=>a.id!==i.id&&!Gn(a.candidates,e.candidates))].slice(0,Ea)},wi=Ed,Yf=0,ji=n=>`${Of}token.${encodeURIComponent(n)}`,Xf=async(n,e)=>{let s;const r=new Promise(i=>{s=window.setTimeout(()=>i(e),Lf)});try{return await Promise.race([n.catch(()=>e),r])}finally{s!==void 0&&window.clearTimeout(s)}},ki=async(n,e,s)=>et()?Xf(e().catch(r=>(console.warn(`[mobile-storage] ${n} failed`,r),s)),s):s,un=async n=>{Os("secure:read-start",{key:n});const e=await ki("secure:read",async()=>(await wi.internalGetItem({prefixedKey:ji(n),sync:!1})).data,null),s=typeof e=="string"&&e.trim()?e:void 0;return Os("secure:read",{key:n,hasToken:!!s}),s},is=async(n,e)=>{Os("secure:write-start",{key:n});const s=await ki("secure:write",async()=>(await wi.internalSetItem({prefixedKey:ji(n),data:e,sync:!1,access:Yf}),!0),!1);return Os("secure:write",{key:n,ok:s}),s},Qf=async n=>{await ki("secure:delete",async()=>(await wi.internalRemoveItem({prefixedKey:ji(n),sync:!1}),!0),!1)},Zf=async(n,e)=>{let s=0,r=0;return{records:await Promise.all(n.map(async a=>{if(!a||typeof a!="object")return a;const o=a,l=typeof o.url=="string"?o.url:null,m=typeof o.clientToken=="string"?o.clientToken.trim():"";if(!l||!m)return a;if(!await e(l,m))return r+=1,a;s+=1;const{clientToken:p,...f}=o;return{...f,hasToken:!0}})),migrated:s,failed:r}},Ma=async()=>{if(typeof window>"u"||!et())return;let n;try{n=JSON.parse(window.localStorage.getItem(Vn)||"[]")}catch{return}if(!Array.isArray(n))return;const e=n.filter(r=>!!r&&typeof r=="object"&&typeof r.url=="string"&&typeof r.clientToken=="string"&&!!r.clientToken.trim());if(e.length===0)return;Os("secure:migrate-start",{count:e.length});const s=await Zf(n,async(r,i)=>{const a=_s(r);return await is(a,i)?await un(a)===i:!1});if(s.migrated>0)try{window.localStorage.setItem(Vn,JSON.stringify(s.records))}catch(r){console.warn("[mobile-storage] failed to finalize secure token migration",r);return}Os("secure:migrate-done",{migrated:s.migrated,failed:s.failed})},em=async()=>(await Ma(),us()),qn=async n=>{const e=Da(us(),n);return vi(e),et()&&n.clientToken&&await is(Ye({candidates:n.candidates}),n.clientToken),e},tm=async n=>{const e=us(),s=e.find(i=>i.id===n)??null,r=e.filter(i=>i.id!==n);return vi(r),s&&et()&&await Qf(Ye(s)),r},sm=1500,Hn=async(n,e,s)=>{const r=s?.fast?{totalTimeoutMs:Un}:void 0,i=ls({candidates:n})?.serverId??null,a=n.find(p=>p.kind==="relay")??null,o=n.filter(p=>p.kind==="direct"),l=async()=>{for(const p of o){const f=Bs(p.url)||p.url,g=e?{Authorization:`Bearer ${e}`}:void 0,d=await cs(`${f}/health`,{method:"GET"},r);if(Ie("probe:direct:health",{url:f,ok:d?.ok===!0,status:d?.status??null,source:d?.source??null}),!d?.ok)continue;if(i){const x=await d.json().catch(()=>null),S=x&&typeof x=="object"?x.serverId:null;if(typeof S=="string"&&S&&S!==i){Ie("probe:server-id-mismatch",{url:f});continue}}const h=await cs(`${f}/auth/session`,{method:"GET",credentials:e?"omit":"include",headers:g},r);if(Ie("probe:direct:session",{url:f,ok:h?.ok===!0,status:h?.status??null,source:h?.source??null,hasToken:!!e}),h?.status===401)return{status:"needs-login"};if(!h||!h.ok&&h.status!==404)continue;const b=await sr(h);if(b&&b.disabled!==!0&&b.authenticated===!1)return{status:"needs-login"};const v=b?.disabled===!0;return!e&&et()&&!v&&b?.scope!=="client"?{status:"needs-login"}:{status:"ok",transport:{kind:"direct",url:f}}}return{status:"unreachable"}},m=async()=>{if(!a)return{status:"unreachable"};const{outcome:p,tunnel:f}=await Kf(a.relay,e,void 0,s?.fast?Un:bi,{keepTunnel:!0});return p==="ok"?{status:"ok",transport:{kind:"relay",relay:a.relay,tunnel:f}}:p==="needs-login"||p==="auth-failed"?{status:"needs-login"}:p==="relay-limit"?{status:"relay-limit"}:{status:"unreachable"}};return a?o.length===0?m():new Promise(p=>{let f=!1,g=!1,d,h=null,b=null;const v=C=>{C?.status==="ok"&&C.transport.kind==="relay"&&Ta(C.transport.tunnel)},x=C=>{f||(f=!0,p(C))},S=()=>{g||f||(d!==void 0&&(window.clearTimeout(d),d=void 0),m().then(C=>{if(b=C,f||g){v(C);return}if(C.status==="ok"||C.status==="needs-login"){x(C);return}h&&x(C)}))};l().then(C=>{if(h=C,!f){if(C.status==="ok"||C.status==="needs-login"){g=!0,d!==void 0&&window.clearTimeout(d),v(b),x(C);return}if(b){x(b);return}S()}}),d=window.setTimeout(S,sm)}):l()},os=(n,e,s)=>{Si=!1,n.kind==="relay"?qf(n.relay,e,s?.grant,s?.runtimeKey,n.tunnel?.client):Ns({apiBaseUrl:n.url,clientToken:e,runtimeKey:s?.runtimeKey}),za()},rs=()=>{const n=us()[0];return n?.label?.trim()?n.label:null};let Si=!1;const nm=()=>{Si=!0},en=async n=>{if(Si)return Ie("auto-connect:suppressed",{}),{status:"no-candidate"};const e=n?.fast!==!1;await Ma();const s=us()[0];if(Ie("auto-connect:start",{hasCandidate:!!s,fast:e}),!s)return{status:"no-candidate"};let r;if(et()){if(s.hasToken&&(r=await un(Ye(s)),!r))return{status:"no-candidate"}}else if(r=s.clientToken,!r&&s.hasToken)return{status:"no-candidate"};const i=await Hn(s.candidates,r,{fast:e});return Ie("auto-connect:probe",{status:i.status,candidates:s.candidates.map(a=>a.kind)}),i.status==="needs-login"?{status:"needs-login",label:s.label}:i.status==="relay-limit"?{status:"relay-limit",label:s.label}:i.status!=="ok"?{status:"unreachable",label:s.label}:n?.skipIfConnected&&kt()?(i.transport.kind==="relay"&&Ta(i.transport.tunnel),Ie("auto-connect:superseded",{}),{status:"no-candidate"}):(await qn({id:s.id,label:s.label,candidates:s.candidates}),os(i.transport,r??null,{runtimeKey:Ye(s)}),{status:"connected"})},rm=async(n,e)=>{let s="";try{s=Bs(n.url)}catch{return!1}if(!s)return!1;const r=n.clientToken?.trim()||void 0,i=r?{Authorization:`Bearer ${r}`}:void 0,a=e?.fast?{totalTimeoutMs:Un}:void 0;if(!(await cs(`${s}/health`,{method:"GET",headers:i},a))?.ok)return!1;const l=await cs(`${s}/auth/session`,{method:"GET",credentials:r?"omit":"include",headers:i},a);if(!l||!l.ok&&l.status!==404)return!1;const m=await sr(l);return!(m&&m.disabled!==!0&&m.authenticated===!1)},po=(n,e)=>{n?.kind==="relay"&&n.owned&&!e&&n.tunnel.close()},im=(n,e)=>n.kty===e.kty&&n.crv===e.crv&&n.x===e.x&&n.y===e.y,_a=n=>{const e=Go(),s=ml();return!e||!s||e.getStatus().state!=="connected"?null:s.relayUrl===n.relayUrl&&s.serverId===n.serverId&&im(s.hostEncPubJwk,n.hostEncPubJwk)?e:null},om=n=>[...n].sort((e,s)=>{const r=(e.priority??100)-(s.priority??100);if(r!==0)return r;const i=a=>a.type==="relay"?2:a.url.startsWith("https://")?0:1;return i(e)-i(s)}).flatMap(e=>{if(e.type==="relay"){const s=yi({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk});return s?[{kind:"relay",relay:s}]:[]}return xi(e.url)}),ho=async n=>{let e=!1;const s=ls({candidates:n})?.serverId??null;for(const r of n){if(r.kind==="relay"){const o=_a(r.relay);if(o){const f=await Ms(o,"/health",void 0,bi);if(Ie("establish:relay:health",{shared:!0,ok:f.response?.ok===!0,status:f.response?.status??null,error:f.failure}),f.response?.ok)return{kind:"relay",relay:r.relay,tunnel:o,owned:!1}}const l=Ko(r.relay),{response:m,failure:p}=await Ra(l,"/health",void 0,zs);if(Ie("establish:relay:health",{shared:!1,ok:m?.ok===!0,status:m?.status??null,error:p}),m?.ok)return{kind:"relay",relay:r.relay,tunnel:l,owned:!0};e||=Qn(l.getStatus()),l.close();continue}const i=Bs(r.url)||r.url,a=await cs(`${i}/health`,{method:"GET"});if(Ie("establish:direct:health",{ok:a?.ok===!0,status:a?.status??null}),!!a?.ok){if(s){const o=await a.json().catch(()=>null),l=o&&typeof o=="object"?o.serverId:null;if(typeof l=="string"&&l&&l!==s){Ie("establish:server-id-mismatch",{url:i});continue}}return{kind:"direct",url:i}}}return e?"relay-limit":null},am=async(n,e)=>{if(!cn())return await rm(n,e)?"valid":"invalid";const s=await Kn(e?.fast?Un:zs,Uo("/auth/session").then(i=>i).catch(()=>null));if(!s)return Qn(Go()?.getStatus())?"relay-limit":"valid";if(s.status===401)return"invalid";if(!s.ok&&s.status!==404)return"valid";const r=await sr(s);return r&&r.disabled!==!0&&r.authenticated===!1?"invalid":"valid"},lm=n=>n.kind==="relay"?cn():!cn()&&Ia(n.url,kt()),Oa=()=>{const n=mn();return n?us().find(e=>Ye(e)===n)??null:null},go=n=>{const e=mn();return!!e&&Ye(n)===e},Fn=async n=>{const e=n?.fast!==!1,s=Oa();if(!s)return Ie("reprobe:no-connection",{runtimeKey:!!mn()}),"no-connection";let r;if(et()?r=s.hasToken?await un(Ye(s)):void 0:r=s.clientToken,!r&&s.hasToken)return Ie("reprobe:no-token",{hasToken:!0}),"unreachable";Ie("reprobe:start",{candidates:s.candidates.map(f=>f.kind),fast:e,hasToken:!!r});const i=s.candidates.findIndex(f=>lm(f.kind==="relay"?{kind:"relay",relay:f.relay}:{kind:"direct",url:f.url})),a=i>=0?s.candidates.slice(0,i):s.candidates,o=await Hn(a,r,{fast:e});if(Ie("reprobe:better",{status:o.status,probed:a.length}),o.status==="ok")return await qn({id:s.id,label:s.label,candidates:s.candidates}),os(o.transport,r??null,{runtimeKey:Ye(s)}),"switched";if(o.status==="needs-login")return"needs-login";let l=null;if(i>=0&&(l=await am({url:kt(),clientToken:r},{fast:e}),Ie("reprobe:current",{current:l}),l==="valid"))return za(),"unchanged";const m=i>=0?s.candidates.slice(i+1):[],p=await Hn(m,r,{fast:e});return Ie("reprobe:fallback",{status:p.status,probed:m.length}),p.status==="ok"?(await qn({id:s.id,label:s.label,candidates:s.candidates}),os(p.transport,r??null,{runtimeKey:Ye(s)}),"switched"):p.status==="needs-login"?"needs-login":[o.status,p.status,l].includes("relay-limit")?"relay-limit":"unreachable"},cm=5e3;let Sr=!1;const um=async()=>{if(Sr)return"skipped";const n=Oa();if(!n)return Ie("candidates:refresh-skip",{reason:"no-active-connection"}),"skipped";const e=ls(n);if(!e)return Ie("candidates:refresh-skip",{reason:"no-relay-candidate"}),"skipped";Sr=!0;try{const s=await Kn(zs,Uo("/api/client-auth/connection/candidates").then(p=>p).catch(()=>null));if(!s?.ok)return Ie("candidates:refresh-skip",{reason:"fetch-failed",status:s?.status??null}),"skipped";const r=await s.json().catch(()=>null);if(!r||r.serverId!==e.serverId)return Ie("candidates:refresh-skip",{reason:"server-id-mismatch"}),"skipped";const i=Array.isArray(r.candidates)?r.candidates:[],a=[];for(const p of i){if(!p||typeof p!="object")continue;const f=p;if(!(f.type!=="lan"||typeof f.url!="string"))try{const g=Bs(f.url);g&&!a.includes(g)&&a.push(g)}catch{}}if(a.length===0)return Ie("candidates:refresh-skip",{reason:"no-lan-reported"}),"skipped";const o=tr(n).filter(p=>p.url.startsWith("https://")),l=[...a.map(p=>({kind:"direct",url:p})),...o,{kind:"relay",relay:e}];return JSON.stringify(n.candidates.map(Wr))===JSON.stringify(l.map(Wr))?"unchanged":(Ie("candidates:refreshed",{lanCount:a.length}),await qn({id:n.id,label:n.label,candidates:l}),"updated")}finally{Sr=!1}},za=()=>{typeof window>"u"||window.setTimeout(()=>{(async()=>{const n=await um().catch(()=>"skipped");Ie("candidates:refresh-result",{result:n}),n==="updated"&&cn()&&await Fn().catch(()=>null)})()},cm)},Ba=n=>{const{t:e}=ye(),[s,r]=c.useState(()=>us()),[i,a]=c.useState(null),[o,l]=c.useState(null),[m,p]=c.useState(null),f=c.useRef(s),g=c.useRef(null),d=c.useRef(Ff()),h=c.useCallback(j=>{f.current=j,r(j)},[]),b=c.useCallback(j=>{g.current=j,a(j)},[]),v=c.useCallback(j=>{g.current===j&&(g.current=null,a(null))},[]);c.useEffect(()=>{let j=!1;return em().then(y=>{j||h(y)}),()=>{j=!0}},[h]);const x=c.useCallback(j=>{const y=Da(f.current,j);return h(y),vi(y),y},[h]),S=c.useCallback(async j=>{l(null),b("connect");try{const y=fo(j);if(y.length===0){l(e("mobile.connect.error.urlRequired"));return}const I=j.id?f.current.find(z=>z.id===j.id):f.current.find(z=>Gn(z.candidates,y)),D=j.label?.trim()||I?.label||Ln(Dt({candidates:y})),L=j.relayGrant;let O=j.clientToken?.trim()||void 0;const E=!!O;O||(et()?I?.hasToken&&(O=await un(Ye({candidates:y}))):O=I?.clientToken),Ie("connect:start",{candidates:y.map(z=>z.kind),hasToken:!!O});const M=await Hn(y,O);if(Ie("connect:probe",{status:M.status}),M.status==="unreachable"){l(e("mobile.connect.error.unreachable"));return}if(M.status==="relay-limit"){l(e("mobile.connect.error.relayLimit"));return}if(M.status==="needs-login"){x({id:I?.id,label:D,candidates:y}),p({id:I?.id??crypto.randomUUID(),label:D,candidates:y,relay:ls({candidates:y})??void 0,relayGrant:L});return}O&&E&&et()&&await is(Ye({candidates:y}),O),x({id:I?.id,label:D,candidates:y,clientToken:O}),os(M.transport,O??null,{runtimeKey:Ye({candidates:y}),grant:L}),n()}catch(y){console.warn("[mobile-connect] connect threw",y),l(e("mobile.connect.error.invalidUrl"))}finally{v("connect")}},[b,v,n,x,e]),C=c.useCallback(async j=>{if(g.current==="pairing")return;l(null),b("pairing");const y=om(j.candidates);let I=null,D=!1;try{const L=await ho(y);if(!L||L==="relay-limit"){l(e(L?"mobile.connect.error.relayLimit":"mobile.connect.error.unreachable"));return}I=L;const O=JSON.stringify({pairingId:j.pairingId,secret:j.secret,clientLabel:"OpenChamber Mobile",clientKind:"mobile",deviceName:"OpenChamber Mobile",devicePlatform:uo(),dedupeKey:co()}),E={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:O},M=I.kind==="relay"?await Ms(I.tunnel,"/api/client-auth/pairing/redeem",E,zs):{response:await cs(`${I.url}/api/client-auth/pairing/redeem`,E),failure:null},z=M.response;if(Ie("pairing:redeem",{transport:I.kind,ok:z?.ok===!0,status:z?.status??null,error:M.failure}),!z?.ok){l(e("mobile.connect.error.authRequired"));return}const _=await z.json().catch(()=>null),G=typeof _?.clientToken=="string"?_.clientToken.trim():"";if(!G){l(e("mobile.connect.error.authRequired"));return}const F=typeof _?.server?.label=="string"?_.server.label:"",B=j.label||F||Ln(Dt({candidates:y}));if(et()&&!await is(Ye({candidates:y}),G)){l(e("mobile.connect.error.authRequired"));return}x({label:B,candidates:y,clientToken:G}),os(I.kind==="relay"?{kind:"relay",relay:I.relay,tunnel:{client:I.tunnel,owned:I.owned}}:{kind:"direct",url:I.url},G,{runtimeKey:Ye({candidates:y})}),D=I.kind==="relay",n()}catch(L){console.warn("[mobile-connect] pairing threw",L),l(e("mobile.connect.error.authRequired"))}finally{po(I,D),v("pairing")}},[b,v,n,x,e]),R=c.useCallback(async j=>{if(!m||!j.trim()||g.current==="password")return;l(null),b("password");const y=d.current.begin(),I=()=>d.current.isCurrent(y),{id:D,label:L,candidates:O}=m;let E=null,M=!1;try{const z=await ho(O);if(z!=="relay-limit"&&(E=z),!I())return;if(!E){l(e(z==="relay-limit"?"mobile.connect.error.relayLimit":"mobile.connect.error.unreachable"));return}const _={method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({password:j,trustDevice:!0,issueClientToken:!0,clientLabel:"OpenChamber Mobile",clientKind:"mobile",devicePlatform:uo(),dedupeKey:co()})};Ie("password:start",{transport:E.kind});const G=E.kind==="relay"?await Ms(E.tunnel,"/auth/session",_,zs):{response:await cs(`${E.url}/auth/session`,_),failure:null},F=G.response;if(!I())return;if(Ie("password:done",{ok:F?.ok===!0,status:F?.status??null,error:G.failure}),!F?.ok){l(e("mobile.connect.error.passwordFailed"));return}const B=await F.json().catch(()=>null);if(!I())return;const V=typeof B?.clientToken=="string"?B.clientToken.trim():"";if(Ie("password:token",{issued:!!V}),!V){if(E.kind==="direct"&&!et()){x({id:D,label:L,candidates:O}),p(null),os({kind:"direct",url:E.url},null,{runtimeKey:Ye({candidates:O})}),n();return}l(e("mobile.connect.error.authRequired"));return}if(et()&&(!I()||(await is(Ye({candidates:O}),V),!I()))||!I()||(x({id:D,label:L,candidates:O,clientToken:V}),p(null),os(E.kind==="relay"?{kind:"relay",relay:E.relay,tunnel:{client:E.tunnel,owned:E.owned}}:{kind:"direct",url:E.url},V,{runtimeKey:Ye({candidates:O})}),M=E.kind==="relay",!I()))return;n()}catch(z){if(!I())return;console.warn("[mobile-connect] password threw",z),l(e("mobile.connect.error.passwordFailed"))}finally{po(E,M),I()&&v("password")}},[b,v,n,m,x,e]),T=c.useCallback(()=>{d.current.cancel(),v("password"),p(null),l(null)},[v]),P=c.useCallback(async j=>{l(null);let y=fo(j);const I=j.id?f.current.find(E=>E.id===j.id)??null:null;if(I){const E=y.filter(_=>_.kind==="direct"),M=tr(I).filter(_=>_.url.startsWith("https://")&&!E.some(G=>Ia(G.url,_.url))),z=ls(I);y=[...E,...M,...z?[{kind:"relay",relay:z}]:[]]}if(y.length===0)return l(e("mobile.connect.error.urlRequired")),null;const D=j.clientToken?.trim()||void 0,L=j.label?.trim()||Ln(Dt({candidates:y}));if(et()){const E=Ye({candidates:y});if(D)await is(E,D);else if(I?.hasToken){const M=Ye(I);if(M&&E&&M!==E){const z=await un(M);z&&await is(E,z)}}}return x({id:j.id,label:L,candidates:y,clientToken:D}).find(E=>Gn(E.candidates,y))??null},[x,e]),k=c.useCallback(async j=>{const y=f.current.find(D=>D.id===j)??null,I=await tm(j);return h(I),y},[h]);return{connections:s,isBusy:i!==null,isPasswordBusy:i==="password",error:o,pendingConnection:m,connect:S,redeemPairingConnection:C,submitPassword:R,cancelPassword:T,saveConnection:P,removeConnection:k,setError:l}},La=n=>{const e=ue.c(31),{onClose:s}=n,{t:r}=ye(),[i,a]=c.useState(!1);let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=Pf(),e[0]=o):o=e[0];const l=o;let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{Yo(Df()).then(j=>{j.ok&&(a(!0),window.setTimeout(()=>a(!1),2e3))})},e[1]=m):m=e[1];const p=m;let f;e[2]!==r?(f=r("mobile.connectionDebug.title"),e[2]=r,e[3]=f):f=e[3];let g;e[4]!==f?(g=t.jsx("h2",{className:"min-w-0 truncate typography-ui-label text-foreground",children:f}),e[4]=f,e[5]=g):g=e[5];const d=i?"check":"file-copy";let h;e[6]!==d?(h=t.jsx(Y,{name:d,className:"size-4"}),e[6]=d,e[7]=h):h=e[7];let b;e[8]!==i||e[9]!==r?(b=r(i?"mobile.connectionDebug.copied":"mobile.connectionDebug.copy"),e[8]=i,e[9]=r,e[10]=b):b=e[10];let v;e[11]!==h||e[12]!==b?(v=t.jsxs(Ee,{type:"button",variant:"outline",size:"sm",onClick:p,disabled:l.length===0,children:[h,b]}),e[11]=h,e[12]=b,e[13]=v):v=e[13];let x;e[14]!==r?(x=r("mobile.connectionDebug.close"),e[14]=r,e[15]=x):x=e[15];let S;e[16]===Symbol.for("react.memo_cache_sentinel")?(S=t.jsx(Y,{name:"close",className:"size-[18px]"}),e[16]=S):S=e[16];let C;e[17]!==s||e[18]!==x?(C=t.jsx(Ee,{type:"button",variant:"ghost",size:"icon","aria-label":x,onClick:s,children:S}),e[17]=s,e[18]=x,e[19]=C):C=e[19];let R;e[20]!==C||e[21]!==v?(R=t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[v,C]}),e[20]=C,e[21]=v,e[22]=R):R=e[22];let T;e[23]!==R||e[24]!==g?(T=t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border/70 px-4 py-2.5",children:[g,R]}),e[23]=R,e[24]=g,e[25]=T):T=e[25];let P;e[26]!==r?(P=t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 py-3",children:l.length===0?t.jsx("p",{className:"typography-small text-muted-foreground",children:r("mobile.connectionDebug.empty")}):t.jsx("pre",{className:"whitespace-pre-wrap break-words typography-code text-muted-foreground",children:l.map(Na).join(`
4
+ `)})}),e[26]=r,e[27]=P):P=e[27];let k;return e[28]!==T||e[29]!==P?(k=t.jsxs("div",{className:"fixed inset-0 z-[70] flex flex-col bg-background pb-[var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))] pt-[var(--safe-area-inset-top,env(safe-area-inset-top,0px))] text-foreground",children:[T,P]}),e[28]=T,e[29]=P,e[30]=k):k=e[30],k},Fa=()=>{if(typeof window>"u")return null;const e=window.Capacitor?.Plugins?.BarcodeScanner;return e&&(typeof e.scan=="function"||typeof e.startScan=="function")?e:null},dm=()=>window.Capacitor?.getPlatform?.()==="android",$a=n=>{const e=n.trim();if(!e)return null;if(/^openchamber:\/\//i.test(e)){const s=hl(e);return s?{pairing:s}:null}return/^https?:\/\//i.test(e)?{url:e}:null},Wa=(n,e)=>{const s=$a(n);if(!s&&e?.pairingStringFallback){const r=gl(n);if(r)return{status:"pairing",pairing:r}}return s?"pairing"in s?{status:"pairing",...s}:{status:"ok",...s}:{status:"invalid"}},fm=async(n,e)=>{if(!n.startScan||!n.stopScan||!n.addListener)return{status:"unsupported"};if(e?.aborted)return{status:"cancelled"};let s,r,i=!1,a=()=>{};const o=new Promise(p=>{a=p}),l=p=>{i||(i=!0,a(p))},m=()=>l({status:"cancelled"});e?.addEventListener("abort",m,{once:!0});try{return(await Promise.allSettled([Promise.resolve(n.addListener("barcodesScanned",({barcodes:f})=>{const g=f?.[0],d=(g?.rawValue??g?.displayValue??"").trim();d&&l(Wa(d,{pairingStringFallback:!0}))})).then(f=>{s=f}),Promise.resolve(n.addListener("scanError",()=>l({status:"failed"}))).then(f=>{r=f})])).some(({status:f})=>f==="rejected")?l({status:"failed"}):i||n.startScan({formats:["QR_CODE"]}).catch(()=>l({status:"failed"})),await o}finally{e?.removeEventListener("abort",m),await Promise.allSettled([Promise.resolve(s?.remove()),Promise.resolve(r?.remove()),n.stopScan()])}},Vr=()=>Fa()!==null,Va=async n=>{const e=Fa();if(!e)return{status:"unsupported"};try{if(e.requestPermissions){const o=(await e.requestPermissions())?.camera;if(o&&o!=="granted"&&o!=="limited")return{status:"permission-denied"}}if(n?.signal?.aborted)return{status:"cancelled"};if(dm())return fm(e,n?.signal);if(!e.scan)return{status:"unsupported"};const r=(await e.scan({formats:["QR_CODE"]}))?.barcodes?.[0],i=(r?.rawValue??r?.displayValue??"").trim();return i?Wa(i):{status:"cancelled"}}catch{return{status:"failed"}}},As={autoComplete:"off",autoCorrect:"off",spellCheck:!1},nn="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",Ua=n=>{const e=ue.c(22),{onCancel:s}=n,{t:r}=ye(),i=c.useRef(null);let a,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const S={value:document.documentElement.style.getPropertyValue("background-color"),priority:document.documentElement.style.getPropertyPriority("background-color")},C={value:document.body.style.getPropertyValue("background-color"),priority:document.body.style.getPropertyPriority("background-color")};document.documentElement.style.setProperty("background-color","rgba(0, 0, 0, 0)","important"),document.body.style.setProperty("background-color","rgba(0, 0, 0, 0)","important");const R=new Map,T=k=>{!(k instanceof HTMLElement)||k===i.current||R.has(k)||(R.set(k,{opacity:k.style.opacity,pointerEvents:k.style.pointerEvents}),k.style.setProperty("opacity","0"),k.style.setProperty("pointer-events","none"))};Array.from(document.body.children).forEach(T);const P=new MutationObserver(k=>{k.forEach(j=>j.addedNodes.forEach(T))});return P.observe(document.body,{childList:!0}),()=>{P.disconnect(),R.forEach(mm),S.value?document.documentElement.style.setProperty("background-color",S.value,S.priority):document.documentElement.style.removeProperty("background-color"),C.value?document.body.style.setProperty("background-color",C.value,C.priority):document.body.style.removeProperty("background-color")}},o=[],e[0]=a,e[1]=o):(a=e[0],o=e[1]),c.useLayoutEffect(a,o);let l,m;e[2]!==s?(l=()=>{const S=()=>{document.visibilityState==="hidden"&&s()};return document.addEventListener("visibilitychange",S),()=>document.removeEventListener("visibilitychange",S)},m=[s],e[2]=s,e[3]=l,e[4]=m):(l=e[3],m=e[4]),c.useEffect(l,m);let p;e[5]!==r?(p=r("mobile.connect.scanQr"),e[5]=r,e[6]=p):p=e[6];let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx("div",{className:"aspect-square w-full max-w-72 rounded-[28px] border-2 border-foreground/90 shadow-[0_0_0_9999px_color-mix(in_srgb,var(--surface-background)_18%,transparent)]","aria-hidden":!0}),e[7]=f):f=e[7];let g;e[8]!==r?(g=r("mobile.connect.welcome.scanHint"),e[8]=r,e[9]=g):g=e[9];let d;e[10]!==g?(d=t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-6",children:[f,t.jsx("p",{className:"max-w-sm rounded-[16px] border border-border/60 bg-background px-4 py-3 text-center typography-body text-foreground shadow-sm",children:g})]}),e[10]=g,e[11]=d):d=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]!==r?(b=r("mobile.instances.cancelEdit"),e[13]=r,e[14]=b):b=e[14];let v;e[15]!==s||e[16]!==b?(v=t.jsxs(Ee,{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]=v):v=e[17];let x;return e[18]!==v||e[19]!==p||e[20]!==d?(x=Ps.createPortal(t.jsxs("div",{ref:i,role:"dialog","aria-modal":"true","aria-label":p,className:"fixed inset-0 z-[1000] flex flex-col bg-transparent px-6 pb-[calc(var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))+24px)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+24px)] text-foreground",children:[d,v]}),document.body),e[18]=v,e[19]=p,e[20]=d,e[21]=x):x=e[21],x},Ga=()=>{const n=ue.c(6),{t:e}=ye();let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx(Cs,{width:96,height:96,isAnimated:!0}),n[0]=s):s=n[0];let r;n[1]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(Y,{name:"loader-4",className:"size-[18px] animate-spin"}),n[1]=r):r=n[1];let i;n[2]!==e?(i=e("mobile.connect.connecting"),n[2]=e,n[3]=i):i=n[3];let a;return n[4]!==i?(a=Ps.createPortal(t.jsxs("div",{role:"status",className:"fixed inset-0 z-[1000] flex flex-col items-center justify-center gap-5 bg-background px-6 text-foreground",children:[s,t.jsxs("div",{className:"flex items-center gap-2 typography-ui-label text-muted-foreground",children:[r,t.jsx("span",{children:i})]})]}),document.body),n[4]=i,n[5]=a):a=n[5],a};function mm(n,e){e.style.opacity=n.opacity,e.style.pointerEvents=n.pointerEvents}const pm=({onConnected:n,notice:e=null})=>{const{t:s}=ye(),r=Ba(n),{connections:i,isBusy:a,isPasswordBusy:o,error:l,pendingConnection:m}=r,[p,f]=c.useState(""),[g,d]=c.useState(""),[h,b]=c.useState(""),[v,x]=c.useState(!1),[S,C]=c.useState(!1),R=c.useRef(null),T=c.useMemo(()=>Vr(),[]),[P,k]=c.useState(()=>!Vr()),[j,y]=c.useState(null),[I,D]=c.useState(""),[L,O]=c.useState(!1),E=Ca(c.useCallback(()=>O(!0),[])),M=c.useCallback(B=>{B.preventDefault(),r.connect({url:p,clientToken:h,label:g})},[h,r,g,p]),z=c.useCallback(B=>{if(/^openchamber:\/\//i.test(B.trim())){const V=$a(B);if(V){if("pairing"in V){r.redeemPairingConnection(V.pairing);return}f(V.url),V.label&&d(V.label),V.clientToken&&b(V.clientToken);return}}f(B)},[r]),_=c.useCallback(async()=>{if(R.current||a)return;r.setError(null),x(!0);const B=new AbortController;R.current=B;try{const V=await Va({signal:B.signal});switch(R.current===B&&(R.current=null,x(!1)),V.status){case"ok":C(!0),f(V.url),V.label&&d(V.label),V.clientToken&&b(V.clientToken),await r.connect({url:V.url,clientToken:V.clientToken,label:V.label});break;case"pairing":C(!0),await r.redeemPairingConnection(V.pairing);break;case"permission-denied":r.setError(s("mobile.connect.scan.permissionDenied"));break;case"invalid":r.setError(s("mobile.connect.scan.invalid"));break;case"unsupported":r.setError(s("mobile.connect.scan.unsupported"));break;case"failed":r.setError(s("mobile.connect.scan.failed"));break;default:break}}finally{C(!1),R.current===B&&(R.current=null,x(!1))}},[r,a,s]);c.useEffect(()=>()=>R.current?.abort(),[]);const G=c.useCallback(B=>{B.preventDefault(),r.submitPassword(I)},[r,I]),F=c.useCallback(()=>{D(""),r.cancelPassword()},[r]);return t.jsxs(t.Fragment,{children:[v?t.jsx(Ua,{onCancel:()=>R.current?.abort()}):null,S?t.jsx(Ga,{}):null,L?t.jsx(La,{onClose:()=>O(!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",{...E,className:"select-none",style:{touchAction:"manipulation"},children:t.jsx(Cs,{width:72,height:72,className:"size-[72px]"})}),t.jsx("h1",{className:"typography-h2 text-foreground",children:s("mobile.connect.welcome.title")})]}),e?t.jsxs("div",{role:"status",className:"flex w-full items-center gap-3 rounded-[18px] border border-[color-mix(in_srgb,var(--status-warning)_35%,transparent)] bg-[color-mix(in_srgb,var(--status-warning)_10%,transparent)] px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-[color-mix(in_srgb,var(--status-warning)_16%,transparent)] text-[var(--status-warning)]",children:t.jsx(Y,{name:e.kind==="auth-expired"?"lock":"cloud-off",className:"size-[18px]"})}),t.jsx("p",{className:"min-w-0 flex-1 typography-small text-foreground",children:e.kind==="auth-expired"?s("mobile.connect.notice.authExpired",{label:e.label}):e.kind==="relay-limit"?s("mobile.connect.notice.relayLimit",{label:e.label}):s("mobile.connect.notice.unreachable",{label:e.label})})]}):null,m?t.jsxs("form",{className:"flex w-full flex-col gap-3",onSubmit:G,children:[t.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(Y,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0 text-start",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:m.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:m.candidates.some(B=>B.kind==="direct")?Dt(m):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...As,value:I,onChange:B=>D(B.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:nn}),l?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):null,t.jsx(Ee,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:o||!I.trim(),children:s(o?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(Ee,{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:[T?t.jsxs("div",{className:"flex w-full flex-col gap-2",children:[t.jsxs(Ee,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{_()},disabled:v||a,children:[t.jsx(Y,{name:"scan-2",className:te("size-[18px]",v&&"animate-pulse")}),s(a?"mobile.connect.connecting":"mobile.connect.scanQr")]}),t.jsx("p",{className:"px-2 text-center typography-small text-muted-foreground",children:s("mobile.connect.welcome.scanHint")})]}):null,l&&!P?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):null,i.length>0?t.jsxs("section",{className:"flex w-full flex-col gap-2.5",children:[t.jsx("h2",{className:"text-center typography-micro uppercase tracking-[0.14em] text-muted-foreground",children:s("mobile.connect.saved.title")}),t.jsx("div",{className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:i.map(B=>{const V=j===B.id;return t.jsxs("button",{type:"button",disabled:a,className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3.5 py-2.5 text-start last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:opacity-70",onClick:()=>{y(B.id),r.connect({id:B.id,candidates:B.candidates,clientToken:B.clientToken,label:B.label}).finally(()=>y(null))},children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(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:te("block truncate typography-small",V?"text-foreground":"text-muted-foreground"),children:V?s("mobile.connect.connecting"):B.candidates.some(X=>X.kind==="direct")?Dt(B):s("mobile.connect.relay.badge")})]}),V?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:[T?t.jsxs("button",{type:"button",onClick:()=>k(B=>!B),"aria-expanded":P,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:te("size-4 transition-transform duration-200",P&&"rotate-180")})]}):null,t.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:P?"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:M,children:[t.jsx("input",{...As,value:p,onChange:B=>z(B.target.value),placeholder:s("mobile.connect.url.placeholder"),"aria-label":s("mobile.connect.url.label"),type:"url",inputMode:"url",autoCapitalize:"none",tabIndex:P?void 0:-1,className:te(nn,"text-center")}),t.jsx("input",{value:g,onChange:B=>d(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:P?void 0:-1,className:te(nn,"text-center")}),t.jsx("input",{...As,value:h,onChange:B=>b(B.target.value),placeholder:s("mobile.connect.token.placeholder"),"aria-label":s("mobile.connect.token.label"),tabIndex:P?void 0:-1,autoCapitalize:"none",className:te(nn,"text-center")}),t.jsx("p",{className:"px-1 text-center typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")}),l?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):null,t.jsx(Ee,{type:"submit",variant:T?"outline":"default",size:"lg",className:"h-12 w-full",disabled:a||v||!p.trim(),children:s(a?"mobile.connect.connecting":"mobile.connect.connectButton")})]})})})]})]})]})})]})},hm=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"},gm=n=>{const e=ue.c(12),{groups:s,displayMode:r,timeFormatPreference:i,className:a}=n;let o;e[0]!==a?(o=te("space-y-1.5",a),e[0]=a,e[1]=o):o=e[1];let l;if(e[2]!==r||e[3]!==s||e[4]!==i){let p;e[6]!==r||e[7]!==i?(p=f=>t.jsxs("div",{className:"min-w-0 rounded-xl bg-foreground/[0.03] p-2.5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Xo,{providerId:f.providerId,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground",children:f.providerName}),f.planLabel?t.jsx("span",{className:"shrink-0 typography-micro capitalize text-muted-foreground",children:f.planLabel}):null,f.status&&f.rows.length===0?t.jsx("span",{className:"shrink-0 truncate typography-micro text-muted-foreground",children:f.status}):null]}),f.rows.length>0?t.jsx("div",{className:"mt-1.5 space-y-1",children:f.rows.map(g=>{const d=r==="remaining"?g.window.remainingPercent:g.window.usedPercent,h=Il(g.window.valueLabel,d),b=Al(g.window.resetAt,g.window.resetAfterFormatted??g.window.resetAtFormatted,i);return t.jsxs("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"shrink-0 truncate typography-ui-label text-muted-foreground",children:g.subtitle?`${g.subtitle} · ${g.label}`:g.label}),b?t.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/70",children:b}):null]}),t.jsx("span",{className:te("shrink-0 typography-ui-label font-semibold tabular-nums",hm(g.window)),children:h==="-"?"":h})]},g.key)})}):null,f.status&&f.rows.length>0?t.jsx("div",{className:"mt-1.5 typography-micro text-muted-foreground",children:f.status}):null]},f.providerId),e[6]=r,e[7]=i,e[8]=p):p=e[8],l=s.map(p),e[2]=r,e[3]=s,e[4]=i,e[5]=l}else l=e[5];let m;return e[9]!==o||e[10]!==l?(m=t.jsx("div",{className:o,children:l}),e[9]=o,e[10]=l,e[11]=m):m=e[11],m},bo=380,bm=(n,e)=>{if(!n||typeof n!="object")return;const s=n[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0},Nr=n=>n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:String(n),xm="—",Ka=n=>{const e=ue.c(20),{percentage:s}=n;let r,i,a,o,l,m,p;if(e[0]!==s){a=Ol(s??0)??0;const h=zl(s??0);i=h==="critical"?"var(--status-error)":h==="warn"?"var(--status-warning)":"var(--status-success)",r=2*Math.PI*7.5,o="0 0 18 18",l="size-[18px] -rotate-90",m="progressbar",p=s===null?void 0:Math.round(a),e[0]=s,e[1]=r,e[2]=i,e[3]=a,e[4]=o,e[5]=l,e[6]=m,e[7]=p}else r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],m=e[6],p=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),e[8]=f):f=e[8];let g;e[9]!==r||e[10]!==s||e[11]!==i||e[12]!==a?(g=s===null?null:t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:i,strokeWidth:3,strokeLinecap:"round",strokeDasharray:r,strokeDashoffset:r*(1-a/100),className:"transition-[stroke-dashoffset,stroke] duration-300"}),e[9]=r,e[10]=s,e[11]=i,e[12]=a,e[13]=g):g=e[13];let d;return e[14]!==o||e[15]!==l||e[16]!==m||e[17]!==p||e[18]!==g?(d=t.jsxs("svg",{viewBox:o,className:l,role:m,"aria-valuenow":p,"aria-valuemin":0,"aria-valuemax":100,children:[f,g]}),e[14]=o,e[15]=l,e[16]=m,e[17]=p,e[18]=g,e[19]=d):d=e[19],d},ym=n=>{const e=ue.c(13),{icon:s,iconNode:r,label:i,children:a}=n;let o;e[0]!==s||e[1]!==r?(o=r??(s?t.jsx(Y,{name:s,className:"size-[18px]"}):null),e[0]=s,e[1]=r,e[2]=o):o=e[2];let l;e[3]!==o?(l=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:o}),e[3]=o,e[4]=l):l=e[4];let m;e[5]!==i?(m=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:i}),e[5]=i,e[6]=m):m=e[6];let p;e[7]!==a?(p=t.jsx("span",{className:"min-w-0 flex-1 truncate text-end typography-ui-label font-medium text-foreground",children:a}),e[7]=a,e[8]=p):p=e[8];let f;return e[9]!==l||e[10]!==m||e[11]!==p?(f=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5",children:[l,m,p]}),e[9]=l,e[10]=m,e[11]=p,e[12]=f):f=e[12],f},vm=n=>{const e=ue.c(57),{open:s,onClose:r,anchorRef:i,contextDisplay:a,usageGroups:o,usageDisplayMode:l,isUsageLoading:m,timeFormatPreference:p}=n,{t:f}=ye(),g=c.useRef(null),[d,h]=c.useState(s),[b,v]=c.useState(!1),{enabled:x}=Jr(),S=c.useRef(null),[C,R]=c.useState(null);let T,P;e[0]!==i||e[1]!==x||e[2]!==s||e[3]!==d?(T=()=>{if(!s||!x||!d)return;const N=()=>{const ae=i.current?.getBoundingClientRect(),oe=S.current?.getBoundingClientRect();if(!ae||!oe){R(null);return}const q=ae.left-oe.left,ne=Math.min(Math.max(q,8),Math.max(8,oe.width-bo-8));R(ne)};N();const $=S.current;if(typeof ResizeObserver>"u"||!$)return;const J=new ResizeObserver(N);return J.observe($),()=>J.disconnect()},P=[i,x,s,d],e[0]=i,e[1]=x,e[2]=s,e[3]=d,e[4]=T,e[5]=P):(T=e[4],P=e[5]),c.useLayoutEffect(T,P);const k=x&&C!==null;let j,y;e[6]!==s||e[7]!==d?(j=()=>{if(s){h(!0),v(!1);return}if(!d)return;v(!0);const N=window.setTimeout(()=>{h(!1),v(!1)},140);return()=>window.clearTimeout(N)},y=[s,d],e[6]=s,e[7]=d,e[8]=j,e[9]=y):(j=e[8],y=e[9]),c.useEffect(j,y);let I,D;e[10]!==r||e[11]!==s?(I=()=>{if(!s)return;const N=$=>{$.key==="Escape"&&r()};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},D=[r,s],e[10]=r,e[11]=s,e[12]=I,e[13]=D):(I=e[12],D=e[13]),c.useEffect(I,D);let L,O;if(e[14]!==i||e[15]!==r||e[16]!==s?(L=()=>{if(!s)return;const N=$=>{const J=$.target;if(!(J instanceof Node)){r();return}g.current?.contains(J)||i.current?.contains(J)||r()};return document.addEventListener("pointerdown",N,!0),document.addEventListener("wheel",N,!0),()=>{document.removeEventListener("pointerdown",N,!0),document.removeEventListener("wheel",N,!0)}},O=[i,r,s],e[14]=i,e[15]=r,e[16]=s,e[17]=L,e[18]=O):(L=e[17],O=e[18]),c.useEffect(L,O),!d)return null;let E;e[19]!==f?(E=f("mobile.header.openMetadataAria"),e[19]=f,e[20]=E):E=e[20];const M=k?"absolute origin-top-left":"mx-3 mt-2",z=b?"pointer-events-none":"pointer-events-auto";let _;e[21]!==M||e[22]!==z?(_=te("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",M,z),e[21]=M,e[22]=z,e[23]=_):_=e[23];const G=`${b?"session-metadata-out":"session-metadata-in"} ${b?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let F;e[24]!==C||e[25]!==k?(F=k?{top:8,left:C??8,width:`min(${bo}px, calc(100% - 16px))`}:null,e[24]=C,e[25]=k,e[26]=F):F=e[26];let B;e[27]!==G||e[28]!==F?(B={animation:G,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...F},e[27]=G,e[28]=F,e[29]=B):B=e[29];let V;e[30]!==a||e[31]!==f?(V=a?t.jsx(ym,{iconNode:t.jsx(Ka,{percentage:a.state==="measured"?a.percentage:null}),label:f("mobile.header.metadata.context"),children:a.state==="pending"?null:t.jsxs("span",{className:"inline-flex items-baseline gap-1.5 tabular-nums",children:[a.state==="measured"?t.jsxs("span",{className:te("font-semibold",a.colorClass),children:[a.percentage.toFixed(1),"%"]}):null,t.jsx("span",{className:"text-muted-foreground",children:a.tokens})]})}):null,e[30]=a,e[31]=f,e[32]=V):V=e[32];let X;e[33]!==a?.state||e[34]!==f?(X=a?.state==="compacted"?t.jsx("p",{className:"px-2.5 pb-1 typography-meta text-muted-foreground",children:f("contextUsage.compacted.description")}):null,e[33]=a?.state,e[34]=f,e[35]=X):X=e[35];let Z;e[36]!==a?.state||e[37]!==f?(Z=a?.state==="pending"?t.jsx("p",{className:"px-2.5 pb-1 typography-meta text-muted-foreground",children:f("mobile.header.metadata.contextPending")}):null,e[36]=a?.state,e[37]=f,e[38]=Z):Z=e[38];let de;e[39]!==m||e[40]!==p||e[41]!==l||e[42]!==o?(de=t.jsx(wm,{groups:o,displayMode:l,isLoading:m,timeFormatPreference:p}),e[39]=m,e[40]=p,e[41]=l,e[42]=o,e[43]=de):de=e[43];let re;e[44]!==V||e[45]!==X||e[46]!==Z||e[47]!==de?(re=t.jsxs("div",{className:"space-y-1",children:[V,X,Z,de]}),e[44]=V,e[45]=X,e[46]=Z,e[47]=de,e[48]=re):re=e[48];let Q;e[49]!==_||e[50]!==B||e[51]!==re||e[52]!==E?(Q=t.jsx("div",{ref:g,role:"dialog","aria-label":E,className:_,style:B,children:re}),e[49]=_,e[50]=B,e[51]=re,e[52]=E,e[53]=Q):Q=e[53];let ge;e[54]===Symbol.for("react.memo_cache_sentinel")?(ge=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]=ge):ge=e[54];let ee;return e[55]!==Q?(ee=t.jsxs("div",{ref:S,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:[Q,ge]}),e[55]=Q,e[56]=ee):ee=e[56],ee},wm=n=>{const e=ue.c(30),{groups:s,displayMode:r,isLoading:i,timeFormatPreference:a}=n,{t:o}=ye();let l;e[0]!==r||e[1]!==o?(l=o(r==="remaining"?"header.services.remaining":"header.services.used"),e[0]=r,e[1]=o,e[2]=l):l=e[2];const m=l;if(s.length===0){if(!i)return null;let C;e[3]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx(Y,{name:"loader-4",className:"size-4 animate-spin","aria-hidden":!0}),e[3]=C):C=e[3];let R;e[4]!==o?(R=o("common.loading"),e[4]=o,e[5]=R):R=e[5];let T;return e[6]!==R?(T=t.jsxs("div",{className:"flex items-center justify-center gap-2 px-2.5 py-6 text-muted-foreground",children:[C,t.jsx("span",{className:"typography-ui-label",children:R})]}),e[6]=R,e[7]=T):T=e[7],T}let p;e[8]===Symbol.for("react.memo_cache_sentinel")?(p=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]=p):p=e[8];let f;e[9]!==o?(f=o("mobile.header.metadata.usage"),e[9]=o,e[10]=f):f=e[10];let g;e[11]!==f?(g=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:f}),e[11]=f,e[12]=g):g=e[12];let d;e[13]!==i?(d=i?t.jsx(Y,{name:"refresh",className:"size-3.5 animate-spin"}):null,e[13]=i,e[14]=d):d=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]!==d||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:[d,h]}),e[17]=d,e[18]=h,e[19]=b):b=e[19];let v;e[20]!==g||e[21]!==b?(v=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 px-2.5 pb-1.5",children:[p,g,b]}),e[20]=g,e[21]=b,e[22]=v):v=e[22];let x;e[23]!==r||e[24]!==s||e[25]!==a?(x=t.jsx(gm,{groups:s,displayMode:r,timeFormatPreference:a}),e[23]=r,e[24]=s,e[25]=a,e[26]=x):x=e[26];let S;return e[27]!==v||e[28]!==x?(S=t.jsxs("div",{className:"pt-2.5",children:[v,x]}),e[27]=v,e[28]=x,e[29]=S):S=e[29],S},jm=c.memo(function({open:e,onOpenChange:s,currentSessionId:r,effectiveDirectory:i,isNewSessionDraftOpen:a}){const{t:o}=ye(),l=c.useRef(null),m=Pl(r??"",i||void 0),p=ft(_=>_.providers),f=ft(_=>_.currentProviderId),g=ft(_=>_.currentModelId),d=ft(_=>_.getModelMetadata);ft(_=>_.modelsMetadata.size);const h=Tl(c.useCallback(_=>r?_.sessionModelSelections.get(r)??null:null,[r])),b=ss(_=>_.results),v=ss(_=>_.refreshErrors),x=c.useRef(!1),S=ss(_=>_.loadSettings),C=ss(_=>_.fetchAllQuotas),R=ss(_=>_.isLoading),T=ss(_=>_.displayMode),P=ss(_=>_.dropdownProviderIds),k=Ve(_=>_.timeFormatPreference);Dl(),c.useEffect(()=>{S()},[S]),c.useEffect(()=>{Ki(P)},[P]),c.useEffect(()=>{if(!e){x.current=!1;return}x.current||R||!P.some(G=>!b.some(F=>F.providerId===G)||v[G])||(x.current=!0,C())},[P,C,R,e,b,v]);const y=c.useMemo(()=>{for(let _=m.length-1;_>=0;_-=1){const G=m[_];if(G.role!=="assistant")continue;const F=G.providerID.trim(),B=G.modelID.trim();if(F&&B)return{providerID:F,modelID:B}}return null},[m])??(h?{providerID:h.providerId,modelID:h.modelId}:null)??(f&&g?{providerID:f,modelID:g}:null),D=(y?p.find(_=>_.id===y.providerID):void 0)?.models.find(_=>_.id===y?.modelID),L=y?d(y.providerID,y.modelID):void 0,O=bm(D?.limit,"context")??L?.limit?.context??0,E=c.useMemo(()=>Ml(m),[m]),M=c.useMemo(()=>{if(O<=0)return null;if(a||!E)return{state:"pending"};if(E.state==="compacted")return{state:"compacted",tokens:`${xm}/${Nr(O)}`};const _=Math.min(E.totalTokens/O*100,999),G=_>=90?"text-[var(--status-error)]":_>=75?"text-[var(--status-warning)]":"text-[var(--status-success)]";return{state:"measured",percentage:_,tokens:`${Nr(E.totalTokens)}/${Nr(O)}`,colorClass:G}},[E,O,a]),z=_l();return c.useEffect(()=>{!e||z.length===0||Ki(z.map(_=>_.providerId))},[e,z]),t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:l,type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("mobile.header.openMetadataAria"),"aria-expanded":e,onClick:()=>s(_=>!_),style:{touchAction:"manipulation"},children:t.jsx(Ka,{percentage:M?.state==="measured"?M.percentage:M?.state==="compacted"?null:0})}),t.jsx(vm,{open:e,onClose:()=>s(!1),anchorRef:l,contextDisplay:M,usageGroups:z,usageDisplayMode:T,isUsageLoading:R,timeFormatPreference:k})]})}),km=10,xo=380,Sm=(n,e)=>n.title?.trim()||e,Nm=n=>{const e=ue.c(33),{session:s,meta:r,active:i,onSelect:a}=n,{t:o}=ye(),l=Yr(s.id),m=Xr(s.id),p=m!==null,f=!p&&l>0&&!i,g=Qr(s.id,p),d=(p||f)&&g;let h;e[0]!==s?(h=Ll(Qo(s)),e[0]=s,e[1]=h):h=e[1];const b=h,v=i&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let x;e[2]!==v?(x=te("flex w-full items-center gap-3 rounded-xl px-2.5 py-2 text-start transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",v),e[2]=v,e[3]=x):x=e[3];let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S={touchAction:"manipulation"},e[4]=S):S=e[4];const C=i?"text-primary":"text-foreground";let R;e[5]!==C?(R=te("block truncate oc-ui-start-align typography-ui-label",C),e[5]=C,e[6]=R):R=e[6];let T;e[7]!==s||e[8]!==o?(T=Sm(s,o("sessions.sidebar.session.untitled")),e[7]=s,e[8]=o,e[9]=T):T=e[9];let P;e[10]!==R||e[11]!==T?(P=t.jsx("span",{dir:"auto",className:R,children:T}),e[10]=R,e[11]=T,e[12]=P):P=e[12];let k;e[13]!==r?(k=r?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:r}):null,e[13]=r,e[14]=k):k=e[14];let j;e[15]!==P||e[16]!==k?(j=t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[P,k]}),e[15]=P,e[16]=k,e[17]=j):j=e[17];let y;e[18]!==p||e[19]!==f||e[20]!==m?(y=p||f?t.jsx($n,{state:m??"unread"}):null,e[18]=p,e[19]=f,e[20]=m,e[21]=y):y=e[21];let I;e[22]!==p||e[23]!==s.id||e[24]!==d||e[25]!==b?(I=d?t.jsx(Zr,{sessionId:s.id,running:p,className:"typography-micro"}):b?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:b}):null,e[22]=p,e[23]=s.id,e[24]=d,e[25]=b,e[26]=I):I=e[26];let D;return e[27]!==a||e[28]!==j||e[29]!==y||e[30]!==I||e[31]!==x?(D=t.jsxs("button",{type:"button",className:x,onClick:a,style:S,children:[j,y,I]}),e[27]=a,e[28]=j,e[29]=y,e[30]=I,e[31]=x,e[32]=D):D=e[32],D},Cm=n=>{const e=ue.c(50),{open:s,onClose:r,anchorRef:i}=n,{t:a}=ye(),o=c.useRef(null),[l,m]=c.useState(s),[p,f]=c.useState(!1),{enabled:g}=Jr(),d=c.useRef(null),[h,b]=c.useState(null);let v,x;e[0]!==i||e[1]!==g||e[2]!==s||e[3]!==l?(v=()=>{if(!s||!g||!l)return;const ee=()=>{const J=i.current?.getBoundingClientRect(),ae=d.current?.getBoundingClientRect();if(!J||!ae){b(null);return}const oe=J.left-ae.left;b(Math.min(Math.max(oe,8),Math.max(8,ae.width-xo-8)))};ee();const N=d.current;if(typeof ResizeObserver>"u"||!N)return;const $=new ResizeObserver(ee);return $.observe(N),()=>$.disconnect()},x=[i,g,s,l],e[0]=i,e[1]=g,e[2]=s,e[3]=l,e[4]=v,e[5]=x):(v=e[4],x=e[5]),c.useLayoutEffect(v,x);const S=g&&h!==null,C=Be(Rm),R=Be(Em),T=it(Im);let P;e[6]===Symbol.for("react.memo_cache_sentinel")?(P={maxParents:km},e[6]=P):P=e[6];const k=Bl(s||l,P);let j,y;e[7]!==s||e[8]!==l?(j=()=>{if(s){Zo(),m(!0),f(!1);return}if(!l)return;f(!0);const ee=window.setTimeout(()=>{m(!1),f(!1)},140);return()=>window.clearTimeout(ee)},y=[s,l],e[7]=s,e[8]=l,e[9]=j,e[10]=y):(j=e[9],y=e[10]),c.useEffect(j,y);let I,D;e[11]!==r||e[12]!==s?(I=()=>{if(!s)return;const ee=N=>{N.key==="Escape"&&r()};return document.addEventListener("keydown",ee),()=>document.removeEventListener("keydown",ee)},D=[r,s],e[11]=r,e[12]=s,e[13]=I,e[14]=D):(I=e[13],D=e[14]),c.useEffect(I,D);let L,O;e[15]!==i||e[16]!==r||e[17]!==s?(L=()=>{if(!s)return;const ee=N=>{const $=N.target;if(!($ instanceof Node)){r();return}o.current?.contains($)||i.current?.contains($)||r()};return document.addEventListener("pointerdown",ee,!0),()=>document.removeEventListener("pointerdown",ee,!0)},O=[i,r,s],e[15]=i,e[16]=r,e[17]=s,e[18]=L,e[19]=O):(L=e[18],O=e[19]),c.useEffect(L,O);let E;e[20]!==r||e[21]!==R?(E=ee=>{R(ee.id,Jo(ee)),r()},e[20]=r,e[21]=R,e[22]=E):E=e[22];const M=E;if(!l)return null;let z;e[23]!==a?(z=a("sessions.switcher.openAria"),e[23]=a,e[24]=z):z=e[24];const _=S?"absolute origin-top-left":"mx-3 mt-2",G=p?"pointer-events-none":"pointer-events-auto";let F;e[25]!==_||e[26]!==G?(F=te("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",_,G),e[25]=_,e[26]=G,e[27]=F):F=e[27];const B=`${p?"session-switcher-out":"session-switcher-in"} ${p?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let V;e[28]!==h||e[29]!==S?(V=S?{top:8,left:h??8,width:`min(${xo}px, calc(100% - 16px))`}:null,e[28]=h,e[29]=S,e[30]=V):V=e[30];let X;e[31]!==B||e[32]!==V?(X={animation:B,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...V},e[31]=B,e[32]=V,e[33]=X):X=e[33];let Z;e[34]!==C||e[35]!==M||e[36]!==k||e[37]!==T||e[38]!==a?(Z=k.length===0?t.jsx("p",{className:"px-3 py-6 text-center typography-small text-muted-foreground",children:a("sessions.switcher.empty")}):k.map(ee=>{const N=ee.node.session,$=[ee.secondaryMeta?.projectLabel,ee.secondaryMeta?.branchLabel].filter(Boolean).join(" · ");return t.jsx(Nm,{session:N,meta:$,active:N.id===C,onSelect:()=>{ee.projectId&&T(ee.projectId),M(N)}},N.id)}),e[34]=C,e[35]=M,e[36]=k,e[37]=T,e[38]=a,e[39]=Z):Z=e[39];let de;e[40]!==Z?(de=t.jsx("div",{className:"oc-hide-scrollbar min-h-0 flex-1 space-y-0.5 overflow-y-auto overscroll-contain",children:Z}),e[40]=Z,e[41]=de):de=e[41];let re;e[42]!==z||e[43]!==F||e[44]!==X||e[45]!==de?(re=t.jsx("div",{ref:o,role:"dialog","aria-label":z,className:F,style:X,children:de}),e[42]=z,e[43]=F,e[44]=X,e[45]=de,e[46]=re):re=e[46];let Q;e[47]===Symbol.for("react.memo_cache_sentinel")?(Q=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]=Q):Q=e[47];let ge;return e[48]!==re?(ge=t.jsxs("div",{ref:d,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:[re,Q]}),e[48]=re,e[49]=ge):ge=e[49],ge};function Rm(n){return n.currentSessionId}function Em(n){return n.setCurrentSession}function Im(n){return n.setActiveProjectIdOnly}const Am=n=>{const e=ue.c(84),{onOpenSessions:s,onOpenWorkspace:r,compactTitle:i}=n,a=i===void 0?!1:i,{t:o}=ye(),[l,m]=c.useState(!1),[p,f]=c.useState(!1),g=c.useRef(null),d=Mt(Pm),h=Be(Tm);let b;e[0]!==h?(b=pe=>h?pe.getDirectoryForSession(h):null,e[0]=h,e[1]=b):b=e[1];const x=Be(b)||d,S=Fl(h,x||void 0),C=Be(Dm),R=ea(x||null);let T;e[2]!==x||e[3]!==R?(T=pe=>{if(!x||R!==!0)return!1;const Oe=pe.directories.get(x)?.status;return!!(Oe&&!Oe.isClean)},e[2]=x,e[3]=R,e[4]=T):T=e[4];const P=ct(T),k=Ve(Mm),j=vu(k);let y;e[5]!==S?.title?(y=S?.title?.trim(),e[5]=S?.title,e[6]=y):y=e[6];const I=y;let D;e[7]!==h||e[8]!==k||e[9]!==j||e[10]!==I||e[11]!==o?(D=(k?j:null)||I||o(h?"mobile.sessions.untitled":"sessions.switcher.draftTitle"),e[7]=h,e[8]=k,e[9]=j,e[10]=I,e[11]=o,e[12]=D):D=e[12];const L=D;let O;e[13]===Symbol.for("react.memo_cache_sentinel")?(O=()=>{m(!1),f(!1)},e[13]=O):O=e[13];let E;e[14]!==h||e[15]!==x?(E=[h,x],e[14]=h,e[15]=x,e[16]=E):E=e[16],c.useEffect(O,E);let M;e[17]!==s?(M=()=>{m(!1),f(!1),s()},e[17]=s,e[18]=M):M=e[18];const z=M;let _;e[19]===Symbol.for("react.memo_cache_sentinel")?(_=pe=>{m(Oe=>{const De=typeof pe=="function"?pe(Oe):pe;return De&&f(!1),De})},e[19]=_):_=e[19];const G=_;let F;e[20]===Symbol.for("react.memo_cache_sentinel")?(F=()=>{f(pe=>{const Oe=!pe;return Oe&&m(!1),Oe})},e[20]=F):F=e[20];const B=F;let V;e[21]===Symbol.for("react.memo_cache_sentinel")?(V={paddingTop:"var(--oc-safe-area-top, 0px)"},e[21]=V):V=e[21];let X;e[22]!==o?(X=o("mobile.sessions.openSheetAria"),e[22]=o,e[23]=X):X=e[23];let Z,de;e[24]===Symbol.for("react.memo_cache_sentinel")?(Z={touchAction:"manipulation"},de=t.jsx(Y,{name:"list-unordered",className:"size-5"}),e[24]=Z,e[25]=de):(Z=e[24],de=e[25]);let re;e[26]!==z||e[27]!==X?(re=t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":X,onClick:z,style:Z,children:de}),e[26]=z,e[27]=X,e[28]=re):re=e[28];const Q=a?"shrink":"flex-1";let ge;e[29]!==Q?(ge=te("flex min-w-0 items-center rounded-lg px-2 py-1.5 text-start transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",Q),e[29]=Q,e[30]=ge):ge=e[30];let ee;e[31]!==o?(ee=o("sessions.switcher.openAria"),e[31]=o,e[32]=ee):ee=e[32];let N;e[33]===Symbol.for("react.memo_cache_sentinel")?(N={touchAction:"manipulation"},e[33]=N):N=e[33];let $;e[34]!==L?($=t.jsx("span",{dir:"auto",className:"block min-w-0 truncate oc-ui-start-align typography-ui-label text-foreground",children:L}),e[34]=L,e[35]=$):$=e[35];const J=p&&"rotate-180";let ae;e[36]!==J?(ae=te("size-4 shrink-0 text-muted-foreground transition-transform duration-150",J),e[36]=J,e[37]=ae):ae=e[37];let oe;e[38]!==ae?(oe=t.jsx(Y,{name:"arrow-down-s",className:ae}),e[38]=ae,e[39]=oe):oe=e[39];let q;e[40]!==$||e[41]!==oe?(q=t.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[$,oe]}),e[40]=$,e[41]=oe,e[42]=q):q=e[42];let ne;e[43]!==p||e[44]!==ge||e[45]!==ee||e[46]!==q?(ne=t.jsx("button",{ref:g,type:"button",className:ge,"aria-label":ee,"aria-haspopup":"dialog","aria-expanded":p,onClick:B,style:N,children:q}),e[43]=p,e[44]=ge,e[45]=ee,e[46]=q,e[47]=ne):ne=e[47];let ve;e[48]!==a?(ve=a?t.jsx("div",{className:"min-w-0 flex-1"}):null,e[48]=a,e[49]=ve):ve=e[49];let we;e[50]!==h||e[51]!==x||e[52]!==C||e[53]!==l||e[54]!==k?(we=k?null:t.jsx(jm,{open:l,onOpenChange:G,currentSessionId:h,effectiveDirectory:x,isNewSessionDraftOpen:C}),e[50]=h,e[51]=x,e[52]=C,e[53]=l,e[54]=k,e[55]=we):we=e[55];let xe;e[56]!==x?(xe=t.jsx(wu,{directory:x,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]=x,e[57]=xe):xe=e[57];let fe;e[58]!==P||e[59]!==o?(fe=o(P?"mobile.header.openWorkspaceWithChangesAria":"mobile.header.openWorkspaceAria"),e[58]=P,e[59]=o,e[60]=fe):fe=e[60];let Ne;e[61]!==r?(Ne=()=>{m(!1),f(!1),r()},e[61]=r,e[62]=Ne):Ne=e[62];let Ae,Te;e[63]===Symbol.for("react.memo_cache_sentinel")?(Ae={touchAction:"manipulation"},Te=t.jsx(Y,{name:"pencil-ruler-2",className:"size-5"}),e[63]=Ae,e[64]=Te):(Ae=e[63],Te=e[64]);let Ce;e[65]!==P?(Ce=P?t.jsx("span",{className:"absolute inset-e-1.5 top-1.5 size-2.5 rounded-full border-2 border-[var(--background)] bg-[var(--status-warning)]","aria-hidden":!0}):null,e[65]=P,e[66]=Ce):Ce=e[66];let Se;e[67]!==fe||e[68]!==Ne||e[69]!==Ce?(Se=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":fe,onClick:Ne,style:Ae,children:[Te,Ce]}),e[67]=fe,e[68]=Ne,e[69]=Ce,e[70]=Se):Se=e[70];let K;e[71]!==re||e[72]!==ne||e[73]!==ve||e[74]!==we||e[75]!==xe||e[76]!==Se?(K=t.jsx("header",{className:"oc-mobile-header relative z-30 flex shrink-0 items-center gap-1 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",style:V,children:t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[re,ne,ve,we,xe,Se]})}),e[71]=re,e[72]=ne,e[73]=ve,e[74]=we,e[75]=xe,e[76]=Se,e[77]=K):K=e[77];let be;e[78]===Symbol.for("react.memo_cache_sentinel")?(be=()=>f(!1),e[78]=be):be=e[78];let ie;e[79]!==p?(ie=t.jsx(Cm,{open:p,onClose:be,anchorRef:g}),e[79]=p,e[80]=ie):ie=e[80];let he;return e[81]!==K||e[82]!==ie?(he=t.jsxs(t.Fragment,{children:[K,ie]}),e[81]=K,e[82]=ie,e[83]=he):he=e[83],he};function Pm(n){return n.currentDirectory}function Tm(n){return n.currentSessionId}function Dm(n){return!!n.newSessionDraft?.open}function Mm(n){return n.runOverviewKey}const _m=({onActiveConnectionDeleted:n,onConnect:e})=>{const{t:s}=ye(),r=Ba(e),{connections:i,isBusy:a,isPasswordBusy:o,error:l,pendingConnection:m,connect:p,submitPassword:f,cancelPassword:g,saveConnection:d,removeConnection:h,setError:b}=r,[v,x]=c.useState(null),S=v?i.find(q=>q.id===v)??null:null,[C,R]=c.useState(null),[T,P]=c.useState(""),[k,j]=c.useState(""),[y,I]=c.useState(""),[D,L]=c.useState(""),[O,E]=c.useState(!1),[M,z]=c.useState(!1),_=c.useRef(null),G=c.useMemo(()=>Vr(),[]),[F,B]=c.useState(!1),[V,X]=c.useState(null),[Z,de]=c.useState(!1),re=Ca(c.useCallback(()=>de(!0),[])),Q=c.useCallback(()=>{x(null),P(""),j(""),I(""),b(null),B(!1)},[b]),ge=c.useCallback(q=>{q.preventDefault(),d({id:v??void 0,url:T,label:k,clientToken:y}).then(ne=>{ne&&Q()})},[y,v,k,Q,d,T]),ee=c.useCallback(async()=>{if(_.current)return;b(null),E(!0);const q=new AbortController;_.current=q;try{const ne=await Va({signal:q.signal});switch(_.current===q&&(_.current=null,E(!1)),ne.status){case"ok":P(ne.url),ne.label&&j(ne.label),ne.clientToken&&I(ne.clientToken),B(!0);break;case"pairing":z(!0),await r.redeemPairingConnection(ne.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{z(!1),_.current===q&&(_.current=null,E(!1))}},[r,b,s]);c.useEffect(()=>()=>_.current?.abort(),[]);const N=c.useCallback(q=>{q.preventDefault(),f(D)},[D,f]),$=c.useCallback(()=>{L(""),g()},[g]),J=c.useCallback(q=>{R(ne=>ne===q?null:q)},[]),ae=c.useCallback(q=>{R(null),v===q&&Q();const ne=i.length===1;h(q).then(ve=>{ve&&(ne||go(ve))&&n()})},[i.length,v,n,h,Q]),oe=nn;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:N,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(q=>q.kind==="direct")?Dt(m):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...As,value:D,onChange:q=>L(q.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:oe}),l?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:l}):null,t.jsx(Ee,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:o||!D.trim(),children:s(o?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(Ee,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:$,children:s("mobile.connect.cancelPassword")})]})})}):t.jsxs(t.Fragment,{children:[O?t.jsx(Ua,{onCancel:()=>_.current?.abort()}):null,M?t.jsx(Ga,{}):null,Z?t.jsx(La,{onClose:()=>de(!1)}):null,t.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:t.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:t.jsxs("div",{className:"space-y-6",children:[i.length>0?t.jsx("div",{...re,className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:i.map(q=>{const ne=C===q.id,ve=go(q),we=V===q.id,xe=we?s("mobile.connect.connecting"):ve?cn()?s("mobile.instances.status.connectedRelay"):s("mobile.instances.status.connectedDirect"):q.candidates.some(fe=>fe.kind==="direct")?Dt(q):s("mobile.connect.relay.badge");return t.jsxs("div",{className:te("flex items-center border-b border-border/70 transition-colors last:border-b-0",ne&&"bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]"),children:[t.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-3 px-3.5 py-3 text-start transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:opacity-60",onClick:()=>{ve||(X(q.id),p({id:q.id,candidates:q.candidates,clientToken:q.clientToken,label:q.label}).finally(()=>X(null)))},disabled:a&&!we||ne,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]"}),ve?t.jsx("span",{className:"absolute -inset-e-0.5 -top-0.5 size-2.5 rounded-full border-2 border-[var(--surface-elevated)] bg-[var(--status-success)]","aria-hidden":!0}):null]}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:q.label}),t.jsx("span",{className:te("block truncate typography-small",ve&&!we?"text-[var(--status-success)]":"text-muted-foreground"),children:xe})]}),we?t.jsx(Y,{name:"loader-4",className:"size-5 shrink-0 animate-spin text-muted-foreground"}):null]}),t.jsxs("div",{className:"flex items-center gap-0.5 pe-2",children:[ne?t.jsxs("button",{type:"button","aria-label":s("mobile.instances.confirmDeleteAria",{label:q.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:()=>ae(q.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")})]}):q.candidates.some(fe=>fe.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:()=>{x(q.id),P(Dt(q)),j(q.label),I(q.clientToken||""),b(null)},style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"edit",className:"size-[18px]"})}):null,t.jsx("button",{type:"button","aria-label":ne?s("mobile.instances.cancelDeleteAria",{label:q.label}):s("mobile.instances.deleteAria",{label:q.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:()=>J(q.id),style:{touchAction:"manipulation"},children:t.jsx(Y,{name:ne?"close":"delete-bin",className:"size-[18px]"})})]})]},q.id)})}):t.jsx("p",{...re,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&&!S?t.jsxs("div",{className:"space-y-2",children:[G?t.jsxs(Ee,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{ee()},disabled:O,children:[t.jsx(Y,{name:"scan-2",className:te("size-[18px]",O&&"animate-pulse")}),s("mobile.connect.scanQr")]}):null,t.jsxs(Ee,{type:"button",variant:G?"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")]}),l?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):null]}):t.jsxs("form",{className:"space-y-3",onSubmit:ge,children:[t.jsxs("div",{className:"flex h-8 items-center justify-between gap-3 px-1",children:[t.jsx("h3",{className:"typography-ui-label text-foreground",children:s(S?"mobile.instances.editTitle":"mobile.instances.addTitle")}),t.jsx(Ee,{type:"button",variant:"ghost",size:"xs",onClick:Q,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",{...As,value:T,onChange:q=>P(q.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:k,onChange:q=>j(q.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",{...As,value:y,onChange:q=>I(q.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")})]}),l?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:l}):null,t.jsx(Ee,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",children:s(S?"mobile.instances.saveEdit":"mobile.instances.saveNew")})]})]})})})]})},Je=n=>pn(n)??"",Cr=n=>{const e=Je(n);if(!e)return"";const s=e.split("/").filter(Boolean);return s[s.length-1]?.replace(/[-_]/g," ")||e},yo=hi(n=>({expandedParents:{},toggleParent:e=>n(s=>{const r={...s.expandedParents};return r[e]?delete r[e]:r[e]=!0,{expandedParents:r}})})),_n=hi()(ja(n=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(e,s)=>n(r=>({projectExpanded:{...r.projectExpanded,[e]:s}})),setWorktreeExpanded:(e,s)=>n(r=>({worktreeExpanded:{...r.worktreeExpanded,[e]:s}}))}),{name:"mobile-session-tree"})),Ur=hi()(ja(n=>({orderByProject:{},setWorktreeOrder:(e,s)=>n(r=>({orderByProject:{...r.orderByProject,[e]:s}}))}),{name:"mobile-worktree-order"})),vo=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),Om=(n,e)=>{if(!n||n.length===0)return e;const s=new Map(n.map((i,a)=>[vo(i),a])),r=i=>s.get(vo(i.path))??Number.MAX_SAFE_INTEGER;return e.map((i,a)=>({worktree:i,index:a})).sort((i,a)=>{const o=r(i.worktree)-r(a.worktree);return o!==0?o:i.index-a.index}).map(i=>i.worktree)},rn=n=>pn(n)??"",zm=n=>{const e=n;return rn(e.directory??e.project?.worktree??null)},qa=({open:n,project:e,worktree:s,onClose:r,onDeleted:i})=>{const{t:a}=ye(),o=ta(),l=as(M=>M.activeSessions),m=Be(M=>M.archiveSessions),p=Mt(M=>M.currentDirectory),{git:f,sourceControl:g}=Zn(),[d,h]=c.useState(!1),[b,v]=c.useState(!1),[x,S]=c.useState(!1),[C,R]=c.useState(null),[T,P]=c.useState(!1),k=rn(s?.path),j=typeof s?.branch=="string"&&s.branch.trim().length>0,y=c.useMemo(()=>{if(!k)return[];const M=new Map;for(const z of[...l,...o])zm(z)===k&&M.set(z.id,z);return Array.from(M.values())},[l,o,k]);c.useEffect(()=>{if(!n){h(!1),v(!1),S(!1),R(null),P(!1);return}if(!s?.path)return;let M=!1;return $l(s.path).then(z=>{M||(S(!!z?.isDirty),R(z?.upstream?.split("/")[0]?.trim()||null))}).catch(()=>{M||S(!!s.status?.isDirty)}),()=>{M=!0}},[n,s?.path,s?.status?.isDirty]);const I=c.useCallback(async M=>(await Wl(e,M,{deleteRemoteBranch:j&&b,deleteLocalBranch:j&&d,remoteName:C??void 0,network:{git:f,sourceControl:g}}),rn(p)===k&&rn(e.path)&&Mt.getState().setDirectory(rn(e.path),{showOverlay:!1}),!0),[p,d,b,f,j,e,C,g,k]),D=c.useCallback((M,z)=>{const _=Vl(M),G=ce.loading(a("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:_}));Ul(M.path),(async()=>{try{const F=await ju({sessionIds:z,removeWorktree:()=>I(M),archiveSessions:m});if(!F.removed){ce.dismiss(G);return}const{failedIds:B}=F.archive;if(B.length>0){ce.error(B.length===1?a("sessions.sidebar.bulkActions.failedArchiveSingle",{count:B.length}):a("sessions.sidebar.bulkActions.failedArchivePlural",{count:B.length}),{id:G,description:a("sessions.sidebar.dialogs.deleteResult.tryAgain")});return}ce.success(a("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:_}),{id:G,description:a(j&&b?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed")}),i?.()}catch(F){const B=F instanceof Bn?F.message||a("sessions.sidebar.dialogs.deleteResult.tryAgain"):F instanceof Mr||F instanceof Bt&&!F.message.includes(" ")?a("gitView.publish.remoteNotGranted"):F instanceof Error?F.message:a("sessions.sidebar.dialogs.deleteResult.tryAgain");ce.error(a("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:_}),{id:G,description:B})}finally{Gl(M.path)}})()},[m,b,j,i,I,a]),L=()=>{!s||T||(D(s,y.map(M=>M.id)),r())};if(!s)return null;const O=s.branch||s.label||s.path,E=(M,z,_,G)=>t.jsxs("button",{type:"button",role:"switch","aria-checked":M,disabled:G,onClick:()=>z(!M),className:te("flex w-full items-center justify-between gap-3 rounded-xl border border-border/70 px-3.5 py-3 text-start transition-colors","hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",G&&"pointer-events-none opacity-40"),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:_}),t.jsx("span",{className:te("relative h-6 w-10 shrink-0 rounded-full transition-colors",M?"bg-primary":"bg-muted-foreground/30"),children:t.jsx("span",{className:te("absolute top-0.5 size-5 rounded-full bg-white transition-transform",M?"translate-x-[1.125rem] rtl:-translate-x-[1.125rem]":"translate-x-0.5 rtl:-translate-x-0.5")})})]});return t.jsx(Kl,{open:n,onClose:r,title:a("mobile.projectEdit.deleteWorktreeTitle"),footer:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Ee,{variant:"ghost",className:"flex-1",onClick:r,disabled:T,children:a("projectEditDialog.actions.cancel")}),t.jsx(Ee,{variant:"destructive",className:"flex-1",onClick:()=>{L()},disabled:T,children:a("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:a("mobile.projectEdit.deleteWorktreeConfirm",{name:O})}),x?t.jsx("p",{className:"rounded-xl border border-[var(--warning)]/40 bg-[color-mix(in_srgb,var(--warning)_10%,transparent)] px-3.5 py-3 typography-meta text-foreground",children:a("mobile.projectEdit.deleteWorktreeDirty")}):null,y.length>0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:a("mobile.projectEdit.deleteWorktreeArchiveNote",{count:y.length})}):null,j?t.jsxs("div",{className:"flex flex-col gap-2",children:[E(d,h,a("mobile.projectEdit.deleteLocalBranch"),T),E(b,v,a("mobile.projectEdit.deleteRemoteBranch"),T||!C)]}):null]})})},Jn=n=>{const e=ue.c(20),{project:s,size:r}=n,i=r===void 0?"md":r,{currentTheme:a}=sa(),o=s.icon?na[s.icon]:null;let l;e[0]!==s.color?(l=ra(s.color),e[0]=s.color,e[1]=l):l=e[1];const m=l,p=i==="md"?"size-5":"size-3.5";let f;e[2]!==o||e[3]!==p||e[4]!==m?(f=o?t.jsx(Y,{name:o,className:p,style:m?{color:m}:void 0}):t.jsx(Lr,{className:p,style:m?{color:m}:void 0}),e[2]=o,e[3]=p,e[4]=m,e[5]=f):f=e[5];const g=f;let d;e[6]!==a||e[7]!==g||e[8]!==s.iconImage||e[9]!==s.id?(d=s.iconImage?t.jsx(ia,{project:{id:s.id,iconImage:s.iconImage??null},options:{themeVariant:a.metadata.variant,iconColor:a.colors.surface.foreground},className:"size-full object-contain",fallback:g}):null,e[6]=a,e[7]=g,e[8]=s.iconImage,e[9]=s.id,e[10]=d):d=e[10];const h=d;let b;e[11]!==s.iconBackground?(b=s.iconBackground?{backgroundColor:s.iconBackground}:void 0,e[11]=s.iconBackground,e[12]=b):b=e[12];const v=b;if(i==="md"){let C;return e[13]!==g||e[14]!==h||e[15]!==v?(C=t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground",children:h?t.jsx("span",{className:"flex size-6 items-center justify-center overflow-hidden rounded-md",style:v,children:h}):g}),e[13]=g,e[14]=h,e[15]=v,e[16]=C):C=e[16],C}const x=h??g;let S;return e[17]!==v||e[18]!==x?(S=t.jsx("span",{className:"flex size-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px] text-muted-foreground",style:v,children:x}),e[17]=v,e[18]=x,e[19]=S):S=e[19],S},Ha=n=>{const e=ue.c(57),{initialTitle:s,indent:r,className:i,aiRename:a,onSubmit:o,onCancel:l}=n,{t:m}=ye(),[p,f]=c.useState(s),g=Bm;let d;e[0]!==s||e[1]!==l||e[2]!==o||e[3]!==p?(d=()=>{const Z=p.trim();if(!Z||Z===s.trim()){l();return}o(Z)},e[0]=s,e[1]=l,e[2]=o,e[3]=p,e[4]=d):d=e[4];const h=d;let b;e[5]!==i?(b=te("flex h-9 min-w-0 flex-1 items-center gap-2 pe-2",i),e[5]=i,e[6]=b):b=e[6];let v;e[7]!==r?(v={paddingInlineStart:r},e[7]=r,e[8]=v):v=e[8];let x;e[9]!==h?(x=Z=>{Z.preventDefault(),h()},e[9]=h,e[10]=x):x=e[10];let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=Z=>f(Z.target.value),e[11]=S):S=e[11];let C;e[12]!==l?(C=Z=>ku(Z,l),e[12]=l,e[13]=C):C=e[13];let R;e[14]!==m?(R=m("sessions.sidebar.session.rename.save"),e[14]=m,e[15]=R):R=e[15];let T;e[16]!==m?(T=m("sessions.sidebar.session.menu.rename"),e[16]=m,e[17]=T):T=e[17];let P;e[18]===Symbol.for("react.memo_cache_sentinel")?(P={minHeight:0},e[18]=P):P=e[18];let k;e[19]!==C||e[20]!==R||e[21]!==T||e[22]!==p?(k=t.jsx("input",{ref:g,value:p,onChange:S,onKeyDown:C,"aria-label":R,placeholder:T,className:"min-w-0 flex-1 bg-transparent text-[16px] typography-ui-label text-foreground outline-none placeholder:text-muted-foreground",style:P,enterKeyHint:"done"}),e[19]=C,e[20]=R,e[21]=T,e[22]=p,e[23]=k):k=e[23];const j=a.disabled;let y;e[24]!==a||e[25]!==l?(y=()=>{a.run(),l()},e[24]=a,e[25]=l,e[26]=y):y=e[26];let I;e[27]!==m?(I=m("sessions.aiRename.action"),e[27]=m,e[28]=I):I=e[28];let D,L;e[29]===Symbol.for("react.memo_cache_sentinel")?(D={touchAction:"manipulation",minHeight:0,minWidth:0},L=t.jsx(Y,{name:"ai-generate-2",className:"size-4"}),e[29]=D,e[30]=L):(D=e[29],L=e[30]);let O;e[31]!==a.disabled||e[32]!==a.hint||e[33]!==y||e[34]!==I?(O=t.jsx("button",{type:"button",disabled:j,onClick:y,"aria-label":I,"aria-description":a.hint,title:a.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:L}),e[31]=a.disabled,e[32]=a.hint,e[33]=y,e[34]=I,e[35]=O):O=e[35];let E;e[36]!==m?(E=m("sessions.sidebar.session.rename.save"),e[36]=m,e[37]=E):E=e[37];let M,z;e[38]===Symbol.for("react.memo_cache_sentinel")?(M={touchAction:"manipulation",minHeight:0,minWidth:0},z=t.jsx(Y,{name:"check",className:"size-4"}),e[38]=M,e[39]=z):(M=e[38],z=e[39]);let _;e[40]!==E?(_=t.jsx("button",{type:"submit","aria-label":E,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:M,children:z}),e[40]=E,e[41]=_):_=e[41];let G;e[42]!==m?(G=m("sessions.sidebar.session.rename.cancel"),e[42]=m,e[43]=G):G=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 V;e[46]!==l||e[47]!==G?(V=t.jsx("button",{type:"button",onClick:l,"aria-label":G,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]=l,e[47]=G,e[48]=V):V=e[48];let X;return e[49]!==k||e[50]!==O||e[51]!==b||e[52]!==_||e[53]!==V||e[54]!==v||e[55]!==x?(X=t.jsxs("form",{className:b,style:v,onSubmit:x,children:[k,O,_,V]}),e[49]=k,e[50]=O,e[51]=b,e[52]=_,e[53]=V,e[54]=v,e[55]=x,e[56]=X):X=e[56],X};function Bm(n){n&&(n.focus(),n.select())}const dn=48,Ja=4*dn,Lm=180,Yn=n=>{const e=ue.c(32),{actionsWidth:s,actions:r,revealed:i,onRevealedChange:a,dataActiveSession:o,contentClassName:l,children:m}=n,p=l===void 0?"relative flex w-full items-center bg-background":l,{direction:f}=ye(),g=f==="rtl"?-1:1,d=c.useRef(null),h=c.useRef(null),b=c.useRef(!1),v=c.useRef(0),x=c.useRef(i);let S;e[0]!==g?(S=(F,B)=>{const V=d.current;V&&(V.style.transition=B?`transform ${Lm}ms ease-out`:"none",V.style.transform=F===0?"none":`translateX(${F*g}px)`,v.current=F)},e[0]=g,e[1]=S):S=e[1];const C=S;let R,T;e[2]!==s||e[3]!==C||e[4]!==i?(R=()=>{x.current=i,C(i?s:0,!0)},T=[s,C,i],e[2]=s,e[3]=C,e[4]=i,e[5]=R,e[6]=T):(R=e[5],T=e[6]),c.useEffect(R,T);let P;e[7]===Symbol.for("react.memo_cache_sentinel")?(P=F=>{if(F.touches.length!==1)return;const B=F.touches[0];h.current={x:B.clientX,y:B.clientY},b.current=!1},e[7]=P):P=e[7];const k=P;let j;e[8]!==s||e[9]!==C||e[10]!==g?(j=F=>{if(!h.current)return;const B=F.touches[0],V=(B.clientX-h.current.x)*g,X=B.clientY-h.current.y;if(!b.current){if(Math.abs(V)<8||Math.abs(V)<=Math.abs(X))return;b.current=!0}const Z=x.current?s:0;C(Math.max(0,Math.min(s,Z+V)),!1)},e[8]=s,e[9]=C,e[10]=g,e[11]=j):j=e[11];const y=j;let I;e[12]!==s||e[13]!==C||e[14]!==a?(I=()=>{if(h.current=null,!b.current)return;b.current=!1;const F=v.current>s/2;C(F?s:0,!0),F!==x.current&&a(F)},e[12]=s,e[13]=C,e[14]=a,e[15]=I):I=e[15];const D=I,L=o||void 0;let O;e[16]===Symbol.for("react.memo_cache_sentinel")?(O={touchAction:"pan-y"},e[16]=O):O=e[16];let E;e[17]!==s?(E={width:s},e[17]=s,e[18]=E):E=e[18];const M=!i;let z;e[19]!==r||e[20]!==E||e[21]!==M?(z=t.jsx("div",{className:"absolute inset-y-0 inset-s-0 flex items-stretch",style:E,"aria-hidden":M,children:r}),e[19]=r,e[20]=E,e[21]=M,e[22]=z):z=e[22];let _;e[23]!==m||e[24]!==p?(_=t.jsx("div",{ref:d,className:p,children:m}),e[23]=m,e[24]=p,e[25]=_):_=e[25];let G;return e[26]!==D||e[27]!==y||e[28]!==z||e[29]!==_||e[30]!==L?(G=t.jsxs("div",{"data-active-session":L,className:"relative overflow-hidden",onTouchStart:k,onTouchMove:y,onTouchEnd:D,onTouchCancel:D,style:O,children:[z,_]}),e[26]=D,e[27]=y,e[28]=z,e[29]=_,e[30]=L,e[31]=G):G=e[31],G},Ya=n=>{const e=ue.c(62),{sessionId:s,title:r,revealed:i,confirmingDelete:a,onArchive:o,onRequestDelete:l,onConfirmDelete:m,onRequestRename:p,onRevealedChange:f,work:g,pin:d}=n,{t:h}=ye(),b=i?0:-1;let v;e[0]!==f||e[1]!==s||e[2]!==h?(v=async()=>{if(!(await Yo(s).catch(Fm))?.ok){Fr.error(h("sessions.sidebar.session.copyId.error"));return}f?.(!1),Fr.success(h("sessions.sidebar.session.copyId.success"))},e[0]=f,e[1]=s,e[2]=h,e[3]=v):v=e[3];const x=v;let S;e[4]!==h||e[5]!==r?(S=h("mobile.sessions.archiveSessionAria",{title:r}),e[4]=h,e[5]=r,e[6]=S):S=e[6];let C,R;e[7]===Symbol.for("react.memo_cache_sentinel")?(C={touchAction:"manipulation"},R=t.jsx(Ad,{className:"size-[18px]"}),e[7]=C,e[8]=R):(C=e[7],R=e[8]);let T;e[9]!==o||e[10]!==S||e[11]!==b?(T=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":S,onClick:o,style:C,children:R}),e[9]=o,e[10]=S,e[11]=b,e[12]=T):T=e[12];let P;e[13]!==f||e[14]!==d||e[15]!==h||e[16]!==b?(P=d?t.jsx("button",{type:"button",tabIndex:b,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":d.pinned?h("sessions.sidebar.session.menu.unpin"):h("sessions.sidebar.session.menu.pin"),onClick:()=>{d.onToggle(),f?.(!1)},style:{touchAction:"manipulation"},children:t.jsx(Y,{name:d.pinned?"unpin":"pushpin",className:"size-[18px]"})}):null,e[13]=f,e[14]=d,e[15]=h,e[16]=b,e[17]=P):P=e[17];let k;e[18]!==f||e[19]!==h||e[20]!==b||e[21]!==g?(k=g?t.jsx("button",{type:"button",tabIndex:b,className:te("flex flex-1 items-center justify-center transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",g.inWork?"text-status-success":"text-muted-foreground active:text-foreground"),"aria-label":g.inWork?h("sessions.sidebar.session.work.markDone"):h("sessions.sidebar.session.work.track"),onClick:()=>{g.onToggle(),f?.(!1)},style:{touchAction:"manipulation"},children:t.jsx(Y,{name:g.inWork?"check":"eye",className:g.inWork?"size-5":"size-[18px]"})}):null,e[18]=f,e[19]=h,e[20]=b,e[21]=g,e[22]=k):k=e[22];const j=a?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80";let y;e[23]!==j?(y=te("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",j),e[23]=j,e[24]=y):y=e[24];let I;e[25]!==a||e[26]!==h||e[27]!==r?(I=a?h("mobile.sessions.confirmDeleteSessionAria",{title:r}):h("mobile.sessions.deleteSessionAria",{title:r}),e[25]=a,e[26]=h,e[27]=r,e[28]=I):I=e[28];const D=a?m:l;let L,O;e[29]===Symbol.for("react.memo_cache_sentinel")?(L={touchAction:"manipulation"},O=t.jsx(Wn,{className:"size-[18px]"}),e[29]=L,e[30]=O):(L=e[29],O=e[30]);let E;e[31]!==I||e[32]!==D||e[33]!==y||e[34]!==b?(E=t.jsx("button",{type:"button",tabIndex:b,className:y,"aria-label":I,onClick:D,style:L,children:O}),e[31]=I,e[32]=D,e[33]=y,e[34]=b,e[35]=E):E=e[35];let M;e[36]!==h||e[37]!==r?(M=h("mobile.sessions.renameSessionAria",{title:r}),e[36]=h,e[37]=r,e[38]=M):M=e[38];let z,_;e[39]===Symbol.for("react.memo_cache_sentinel")?(z={touchAction:"manipulation"},_=t.jsx(va,{className:"size-[18px]"}),e[39]=z,e[40]=_):(z=e[39],_=e[40]);let G;e[41]!==p||e[42]!==M||e[43]!==b?(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":M,onClick:p,style:z,children:_}),e[41]=p,e[42]=M,e[43]=b,e[44]=G):G=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]!==x?(B=()=>{x()},e[47]=x,e[48]=B):B=e[48];let V,X;e[49]===Symbol.for("react.memo_cache_sentinel")?(V={touchAction:"manipulation"},X=t.jsx(Y,{name:"file-copy",className:"size-[18px]"}),e[49]=V,e[50]=X):(V=e[49],X=e[50]);let Z;e[51]!==F||e[52]!==B||e[53]!==b?(Z=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:V,children:X}),e[51]=F,e[52]=B,e[53]=b,e[54]=Z):Z=e[54];let de;return e[55]!==E||e[56]!==G||e[57]!==Z||e[58]!==T||e[59]!==P||e[60]!==k?(de=t.jsxs(t.Fragment,{children:[T,P,k,E,G,Z]}),e[55]=E,e[56]=G,e[57]=Z,e[58]=T,e[59]=P,e[60]=k,e[61]=de):de=e[61],de};function Fm(){return null}const ut=n=>n.parentID??null,yt=n=>{const e=n;return Je(e.directory??e.project?.worktree??null)},Xa=n=>Qo(n),nr=n=>{if(n<=0)return"";const e=Date.now()-n;if(e<6e4)return"now";const s=Math.floor(e/6e4);if(s<60)return`${s}m`;const r=Math.floor(s/60);if(r<24)return`${r}h`;const i=Math.floor(r/24);return i<7?`${i}d`:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(n))},$m=4,Qa=n=>{const e=ue.c(4),{providerIDs:s}=n;let r;e[0]!==s?(r=s.slice(0,$m).map(Wm),e[0]=s,e[1]=r):r=e[1];let i;return e[2]!==r?(i=t.jsx("span",{className:"inline-flex shrink-0 items-center -space-x-1",children:r}),e[2]=r,e[3]=i):i=e[3],i};function Wm(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(Xo,{providerId:n,className:"size-3 opacity-80"})},n)}const Gr=n=>{const e=ue.c(8),{session:s}=n,{t:r}=ye(),i=ql(s);if(!i)return null;const a=Hl[i.status];let o;e[0]!==r||e[1]!==a?(o=r(a),e[0]=r,e[1]=a,e[2]=o):o=e[2];const l=o,m=Jl[i.status];let p;e[3]!==m?(p={color:m},e[3]=m,e[4]=p):p=e[4];let f;return e[5]!==l||e[6]!==p?(f=t.jsx(Y,{name:"target",className:"size-3.5 shrink-0",style:p,"aria-label":l}),e[5]=l,e[6]=p,e[7]=f):f=e[7],f},Kr=n=>{const e=ue.c(9),{hasPermission:s,hasForm:r}=n,{t:i}=ye();if(!s&&!r)return null;let a;e[0]!==s||e[1]!==i?(a=s?t.jsx("span",{className:"inline-flex shrink-0 items-center rounded bg-destructive/10 px-1 py-0.5 text-destructive","aria-label":i("sessions.sidebar.session.status.permissionRequired"),children:t.jsx(Y,{name:"shield",className:"size-3"})}):null,e[0]=s,e[1]=i,e[2]=a):a=e[2];let o;e[3]!==r||e[4]!==i?(o=r?t.jsx("span",{className:"inline-flex shrink-0 items-center rounded bg-status-info/10 px-1 py-0.5 text-status-info","aria-label":i("sessions.sidebar.session.status.questionPending"),children:t.jsx(Y,{name:"question",className:"size-3"})}):null,e[3]=r,e[4]=i,e[5]=o):o=e[5];let l;return e[6]!==a||e[7]!==o?(l=t.jsxs(t.Fragment,{children:[a,o]}),e[6]=a,e[7]=o,e[8]=l):l=e[8],l},Za=n=>{const e=ue.c(7);let s;e[0]!==n?(s=l=>n.some(m=>!!l.bySession.get(m)?.permissions.length),e[0]=n,e[1]=s):s=e[1];const r=qi(s);let i;e[2]!==n?(i=l=>n.some(m=>!!l.bySession.get(m)?.forms.length),e[2]=n,e[3]=i):i=e[3];const a=qi(i);let o;return e[4]!==a||e[5]!==r?(o={hasPermission:r,hasForm:a},e[4]=a,e[5]=r,e[6]=o):o=e[6],o},fn=12,el="flex min-w-0 flex-1 flex-col gap-1 py-2.5 pe-3 text-start",tl="flex h-4 min-w-0 items-center gap-1.5 text-muted-foreground",sl="flex min-w-0 flex-1 flex-col justify-center py-2.5 pe-3 text-start",nl=n=>{const e=ue.c(5),{project:s}=n;let r;e[0]!==s?(r=t.jsx(Jn,{project:s,size:"xs"}),e[0]=s,e[1]=r):r=e[1];let i;return e[2]!==s.label||e[3]!==r?(i=t.jsx("span",{role:"img","aria-label":s.label,className:"inline-flex shrink-0",children:r}),e[2]=s.label,e[3]=r,e[4]=i):i=e[4],i},Vm=n=>{const e=ue.c(46),{entry:s,showProject:r,compact:i}=n,{t:a}=ye(),{run:o,project:l}=s;let m;e[0]!==o.key?(m=_=>_.runOverviewKey===o.key,e[0]=o.key,e[1]=m):m=e[1];const p=Ve(m);let f;e[2]!==s.laneNodes?(f={nodes:s.laneNodes,includeUnreadSubtasks:!1},e[2]=s.laneNodes,e[3]=f):f=e[3];const g=ha(f);let d;e[4]!==o.lastActivity?(d=nr(o.lastActivity),e[4]=o.lastActivity,e[5]=d):d=e[5];const h=d,b=o.lanes.length,v=p||void 0,x=p&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let S;e[6]!==x?(S=te("relative bg-background transition-colors",x),e[6]=x,e[7]=S):S=e[7];const C=i?sl:el;let R;e[8]!==C?(R=te(C,"w-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"),e[8]=C,e[9]=R):R=e[9];let T;e[10]===Symbol.for("react.memo_cache_sentinel")?(T={paddingInlineStart:fn,touchAction:"manipulation"},e[10]=T):T=e[10];let P;e[11]!==o.key?(P=()=>Ve.getState().setRunOverviewKey(o.key),e[11]=o.key,e[12]=P):P=e[12];let k;e[13]!==o.title||e[14]!==a?(k=a("sessions.sidebar.run.openOverviewAria",{title:o.title}),e[13]=o.title,e[14]=a,e[15]=k):k=e[15];const j=p?"text-primary":"text-foreground";let y;e[16]!==j?(y=te("block min-w-0 flex-1 truncate oc-ui-start-align typography-ui-label",j),e[16]=j,e[17]=y):y=e[17];let I;e[18]!==o.title||e[19]!==y?(I=t.jsx("span",{dir:"auto",className:y,children:o.title}),e[18]=o.title,e[19]=y,e[20]=I):I=e[20];let D;e[21]!==g?(D=g?t.jsx(ba,{state:g}):null,e[21]=g,e[22]=D):D=e[22];let L;e[23]!==h?(L=h?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:h}):null,e[23]=h,e[24]=L):L=e[24];let O;e[25]!==I||e[26]!==D||e[27]!==L?(O=t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[I,D,L]}),e[25]=I,e[26]=D,e[27]=L,e[28]=O):O=e[28];let E;e[29]!==i||e[30]!==b||e[31]!==l||e[32]!==o.providerIDs||e[33]!==r||e[34]!==a?(E=i?null:t.jsxs("span",{className:tl,children:[r?t.jsx(nl,{project:l}):null,t.jsx(oa,{className:"size-3.5 shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-micro",children:b===1?a("sessions.sidebar.run.laneCountSingle",{count:b}):a("sessions.sidebar.run.laneCountPlural",{count:b})}),t.jsx(Qa,{providerIDs:o.providerIDs})]}),e[29]=i,e[30]=b,e[31]=l,e[32]=o.providerIDs,e[33]=r,e[34]=a,e[35]=E):E=e[35];let M;e[36]!==P||e[37]!==k||e[38]!==O||e[39]!==E||e[40]!==R?(M=t.jsxs("button",{type:"button",className:R,style:T,onClick:P,"aria-label":k,children:[O,E]}),e[36]=P,e[37]=k,e[38]=O,e[39]=E,e[40]=R,e[41]=M):M=e[41];let z;return e[42]!==M||e[43]!==v||e[44]!==S?(z=t.jsx("div",{"data-active-session":v,className:S,children:M}),e[42]=M,e[43]=v,e[44]=S,e[45]=z):z=e[45],z},Um=n=>{const e=ue.c(120),{entry:s,showProject:r,compact:i,pinMarker:a,active:o,revealed:l,confirmingDelete:m,renaming:p,handlers:f}=n,{t:g}=ye(),{session:d,project:h,branch:b,inSpace:v}=s;let x;e[0]!==d.title||e[1]!==g?(x=d.title?.trim()||g("mobile.sessions.untitled"),e[0]=d.title,e[1]=g,e[2]=x):x=e[2];const S=x;let C;e[3]!==d?(C=nr(Xa(d)),e[3]=d,e[4]=C):C=e[4];const R=C,T=ga(d.id,d.directory,l||p),P=Yr(d.id),k=Xr(d.id),j=k!==null,y=!j&&P>0&&!o,I=Qr(d.id,j),D=(j||y)&&I,L=f.onToggleWork;let O;e[5]!==d?(O=aa(d),e[5]=d,e[6]=O):O=e[6];const E=O;let M;e[7]!==E||e[8]!==L||e[9]!==d?(M=L?{inWork:E,onToggle:()=>L(d,E)}:void 0,e[7]=E,e[8]=L,e[9]=d,e[10]=M):M=e[10];const z=M;let _;e[11]!==f||e[12]!==d?(_=f.isPinned(d),e[11]=f,e[12]=d,e[13]=_):_=e[13];const G=_;let F;e[14]!==f||e[15]!==d?(F=()=>f.onTogglePin(d),e[14]=f,e[15]=d,e[16]=F):F=e[16];let B;e[17]!==G||e[18]!==F?(B={pinned:G,onToggle:F},e[17]=G,e[18]=F,e[19]=B):B=e[19];const V=B,{descendantIdsOf:X}=f;let Z;e[20]!==X||e[21]!==d.id?(Z=[d.id,...X(d.id)],e[20]=X,e[21]=d.id,e[22]=Z):Z=e[22];const re=Za(Z),Q=Ja+dn+(z?dn:0);let ge;e[23]!==f||e[24]!==d.id?(ge=xe=>f.onRevealedChange(d.id,xe),e[23]=f,e[24]=d.id,e[25]=ge):ge=e[25];const ee=o&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let N;e[26]!==ee?(N=te("relative flex w-full items-center bg-background transition-colors",ee),e[26]=ee,e[27]=N):N=e[27];let $;e[28]!==f||e[29]!==d?($=()=>f.onArchive(d),e[28]=f,e[29]=d,e[30]=$):$=e[30];let J;e[31]!==f||e[32]!==d.id?(J=()=>f.onRequestDelete(d.id),e[31]=f,e[32]=d.id,e[33]=J):J=e[33];let ae;e[34]!==f||e[35]!==d?(ae=()=>f.onConfirmDelete(d),e[34]=f,e[35]=d,e[36]=ae):ae=e[36];let oe,q;e[37]!==f||e[38]!==d.id?(oe=()=>f.onRequestRename(d.id),q=xe=>f.onRevealedChange(d.id,xe),e[37]=f,e[38]=d.id,e[39]=oe,e[40]=q):(oe=e[39],q=e[40]);let ne;e[41]!==m||e[42]!==V||e[43]!==l||e[44]!==d.id||e[45]!==$||e[46]!==J||e[47]!==ae||e[48]!==oe||e[49]!==q||e[50]!==S||e[51]!==z?(ne=t.jsx(Ya,{sessionId:d.id,title:S,revealed:l,confirmingDelete:m,onArchive:$,onRequestDelete:J,onConfirmDelete:ae,onRequestRename:oe,onRevealedChange:q,work:z,pin:V}),e[41]=m,e[42]=V,e[43]=l,e[44]=d.id,e[45]=$,e[46]=J,e[47]=ae,e[48]=oe,e[49]=q,e[50]=S,e[51]=z,e[52]=ne):ne=e[52];let ve;e:{let xe;e[53]!==i||e[54]!==re||e[55]!==d?(xe=i?t.jsxs(t.Fragment,{children:[t.jsx(Gr,{session:d}),t.jsx(Kr,{...re})]}):null,e[53]=i,e[54]=re,e[55]=d,e[56]=xe):xe=e[56];let fe;e[57]!==a||e[58]!==G||e[59]!==g?(fe=G&&a?t.jsx(Y,{name:"pushpin",className:"size-3 shrink-0 text-muted-foreground","aria-label":g("sessions.sidebar.session.status.pinned")}):null,e[57]=a,e[58]=G,e[59]=g,e[60]=fe):fe=e[60];let Ne;e[61]!==T.pending||e[62]!==j||e[63]!==y||e[64]!==g||e[65]!==k?(Ne=T.pending?t.jsx(Y,{name:"loader-4",className:"size-3 shrink-0 animate-spin text-primary","aria-label":g("sessions.aiRename.generating")}):j||y?t.jsx($n,{state:k??"unread"}):null,e[61]=T.pending,e[62]=j,e[63]=y,e[64]=g,e[65]=k,e[66]=Ne):Ne=e[66];let Ae;e[67]!==j||e[68]!==d.id||e[69]!==D||e[70]!==R?(Ae=D?t.jsx(Zr,{sessionId:d.id,running:j,className:"shrink-0 typography-micro"}):R?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:R}):null,e[67]=j,e[68]=d.id,e[69]=D,e[70]=R,e[71]=Ae):Ae=e[71];let Te;e[72]!==xe||e[73]!==fe||e[74]!==Ne||e[75]!==Ae?(Te=t.jsxs(t.Fragment,{children:[xe,fe,Ne,Ae]}),e[72]=xe,e[73]=fe,e[74]=Ne,e[75]=Ae,e[76]=Te):Te=e[76];const Ce=Te;let Se;e[77]!==o||e[78]!==T||e[79]!==f||e[80]!==p||e[81]!==d.id||e[82]!==Ce||e[83]!==S?(Se=p?t.jsx(Ha,{initialTitle:S,indent:0,aiRename:T,className:"h-[1lh] pe-0 typography-ui-label [&_button]:size-6 [&_button>svg]:size-3.5",onSubmit:Ge=>f.onSubmitRename(d.id,Ge),onCancel:f.onCancelRename}):t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{dir:"auto",className:te("block min-w-0 flex-1 truncate oc-ui-start-align typography-ui-label",o?"text-primary":"text-foreground"),children:S}),Ce]}),e[77]=o,e[78]=T,e[79]=f,e[80]=p,e[81]=d.id,e[82]=Ce,e[83]=S,e[84]=Se):Se=e[84];let K;e[85]!==b||e[86]!==i||e[87]!==v||e[88]!==re||e[89]!==h||e[90]!==d||e[91]!==r||e[92]!==g?(K=i?null:t.jsxs("span",{className:tl,children:[r?t.jsx(nl,{project:h}):null,b?t.jsxs(t.Fragment,{children:[v?t.jsx(Y,{name:"box-3",className:"size-3.5 shrink-0","aria-hidden":!1,role:"img","aria-label":g("sessions.sidebar.group.space")}):t.jsx(Y,{name:"git-branch",className:"size-3.5 shrink-0"}),t.jsx("span",{className:"block min-w-0 truncate typography-micro",children:b})]}):null,t.jsxs("span",{className:"ms-auto flex shrink-0 items-center gap-1.5",children:[t.jsx(Gr,{session:d}),t.jsx(Kr,{...re})]})]}),e[85]=b,e[86]=i,e[87]=v,e[88]=re,e[89]=h,e[90]=d,e[91]=r,e[92]=g,e[93]=K):K=e[93];let be;e[94]!==Se||e[95]!==K?(be=t.jsxs(t.Fragment,{children:[Se,K]}),e[94]=Se,e[95]=K,e[96]=be):be=e[96];const ie=be,he=i?sl:el;if(p){let Ge;e[97]===Symbol.for("react.memo_cache_sentinel")?(Ge={paddingInlineStart:fn},e[97]=Ge):Ge=e[97];let pt;e[98]!==he||e[99]!==ie?(pt=t.jsx("div",{className:he,style:Ge,children:ie}),e[98]=he,e[99]=ie,e[100]=pt):pt=e[100],ve=pt;break e}let pe;e[101]!==he?(pe=te(he,"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"),e[101]=he,e[102]=pe):pe=e[102];let Oe;e[103]===Symbol.for("react.memo_cache_sentinel")?(Oe={paddingInlineStart:fn,touchAction:"manipulation"},e[103]=Oe):Oe=e[103];let De;e[104]!==f||e[105]!==l||e[106]!==d?(De=()=>{if(l){f.onRevealedChange(d.id,!1);return}f.onSelect(d)},e[104]=f,e[105]=l,e[106]=d,e[107]=De):De=e[107];let Fe;e[108]!==ie||e[109]!==pe||e[110]!==De?(Fe=t.jsx("button",{type:"button",className:pe,style:Oe,onClick:De,children:ie}),e[108]=ie,e[109]=pe,e[110]=De,e[111]=Fe):Fe=e[111],ve=Fe}let we;return e[112]!==o||e[113]!==l||e[114]!==ge||e[115]!==N||e[116]!==ne||e[117]!==ve||e[118]!==Q?(we=t.jsx(Yn,{actionsWidth:Q,revealed:l,onRevealedChange:ge,dataActiveSession:o,contentClassName:N,actions:ne,children:ve}),e[112]=o,e[113]=l,e[114]=ge,e[115]=N,e[116]=ne,e[117]=ve,e[118]=Q,e[119]=we):we=e[119],we},wo=n=>{const e=ue.c(13),{entries:s,showProject:r,compact:i,pinMarker:a,handlers:o}=n,l=i===void 0?!1:i,m=a===void 0?!0:a;let p;if(e[0]!==l||e[1]!==s||e[2]!==o||e[3]!==m||e[4]!==r){let g;e[6]!==l||e[7]!==o||e[8]!==m||e[9]!==r?(g=d=>d.kind==="run"?t.jsx(Vm,{entry:d,showProject:r,compact:l},`run:${d.run.key}`):t.jsx(Um,{entry:d,showProject:r,compact:l,pinMarker:m,active:o.currentSessionId===d.session.id,revealed:o.revealedSessionId===d.session.id,confirmingDelete:o.confirmingDeleteSessionId===d.session.id,renaming:o.renamingSessionId===d.session.id,handlers:o},d.session.id),e[6]=l,e[7]=o,e[8]=m,e[9]=r,e[10]=g):g=e[10],p=s.map(g),e[0]=l,e[1]=s,e[2]=o,e[3]=m,e[4]=r,e[5]=p}else p=e[5];let f;return e[11]!==p?(f=t.jsx(t.Fragment,{children:p}),e[11]=p,e[12]=f):f=e[12],f},jo="mobile-surface-root",Rr=16,On=200,Gm=()=>{if(typeof document>"u")return null;let n=document.getElementById(jo);return n||(n=document.createElement("div"),n.id=jo,document.body.appendChild(n)),n},Tt=({open:n,onClose:e,title:s,subtitle:r,trailing:i,disableEscapeDismiss:a=!1,headerless:o=!1,noHeaderBorder:l=!1,ariaLabel:m,variant:p="fullscreen",dialogAlign:f="chat",children:g})=>{const{t:d,direction:h}=ye(),b=c.useRef(null),[v,x]=c.useState(!1),[S,C]=c.useState(!1),R=c.useRef(null),T=c.useRef(null),P=c.useRef(e);if(c.useEffect(()=>{P.current=e},[e]),typeof document<"u"&&!b.current&&(b.current=Gm()),c.useEffect(()=>{if(!n){x(!1);return}const y=window.setTimeout(()=>x(!0),Rr);return()=>window.clearTimeout(y)},[n]),c.useEffect(()=>{if(!n){C(!1);return}const y=window.setTimeout(()=>C(!0),Rr+On+80);return()=>window.clearTimeout(y)},[n]),c.useEffect(()=>{if(!n)return;const y=document.body.style.overflow;T.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow="hidden";const I=()=>{const O=R.current;if(!O)return;(O.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??O).focus({preventScroll:!0})},D=window.setTimeout(I,Rr),L=O=>{if(O.key==="Escape"&&!a){if(ei(O))return;P.current();return}if(O.key!=="Tab")return;const E=R.current;if(!E)return;const M=Array.from(E.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(F=>!F.hasAttribute("disabled")&&F.getAttribute("aria-hidden")!=="true");if(M.length===0){O.preventDefault(),E.focus({preventScroll:!0});return}const z=M[0],_=M[M.length-1],G=document.activeElement;O.shiftKey&&G===z?(O.preventDefault(),_.focus({preventScroll:!0})):!O.shiftKey&&G===_&&(O.preventDefault(),z.focus({preventScroll:!0}))};return document.addEventListener("keydown",L),()=>{window.clearTimeout(D),document.body.style.overflow=y,document.removeEventListener("keydown",L),T.current?.focus?.({preventScroll:!0}),T.current=null}},[a,n]),!n||!b.current)return null;const k=p==="dialog",j=t.jsxs("section",{ref:R,role:"dialog","aria-modal":"true","aria-label":m,tabIndex:-1,className:te("flex flex-col bg-background text-foreground",k?"h-[min(88dvh,860px)] w-full max-w-[720px] overflow-hidden rounded-2xl border border-border/70 shadow-[0_24px_64px_rgb(0_0_0_/_0.32)]":"oc-keyboard-inset-surface oc-bottom-safe-surface fixed inset-0 z-50"),style:k?{opacity:v?1:0,transform:v?"none":"scale(0.97)",transition:`opacity ${On}ms ease-out, transform ${On}ms cubic-bezier(0.32, 0.72, 0, 1)`}:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:v?"none":h==="rtl"?"translateX(-100%)":"translateX(100%)",transition:`transform ${On}ms cubic-bezier(0.32, 0.72, 0, 1)`},onTransitionEnd:y=>{v&&y.target===y.currentTarget&&y.propertyName==="transform"&&C(!0)},children:[o?null:t.jsxs("header",{className:te("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",!l&&"border-b border-border/70"),children:[t.jsx("button",{type:"button",className:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":d("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"close",className:"size-5"})}),t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[s?typeof s=="string"?t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:s}):s:null,r?typeof r=="string"?t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:r}):r:null]}),i?t.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:i}):null]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:S?t.jsx("div",{className:"h-full",style:{animation:"oc-surface-content-in 200ms ease-out"},children:g}):null}),t.jsx("style",{children:"@keyframes oc-surface-content-in { from { opacity: 0 } to { opacity: 1 } }"})]});return k?Ps.createPortal(t.jsx("div",{className:"oc-keyboard-inset-surface oc-bottom-safe-surface fixed inset-0 z-50 flex items-center justify-center p-4 transition-opacity duration-200 ease-out",style:{background:"rgb(0 0 0 / 0.45)",opacity:v?1:0,paddingLeft:f==="chat"?"max(1rem, var(--oc-chat-inset-left, 0px))":"1rem",paddingRight:f==="chat"?"max(1rem, var(--oc-chat-inset-right, 0px))":"1rem",paddingTop:"max(1rem, var(--oc-safe-area-top, 0px))"},onClick:e,children:t.jsx("div",{className:"flex w-full max-w-[720px] justify-center",onClick:y=>y.stopPropagation(),children:j})}),b.current):Ps.createPortal(j,b.current)},Km=n=>{const e=ue.c(8),{projectPath:s}=n,{t:r}=ye(),{journey:i}=bl();let a;if(e[0]!==i||e[1]!==s||e[2]!==r){const o=i?xl(i,s):[];let l;e[4]!==r?(l=r("mobile.projectEdit.spacesTitle"),e[4]=r,e[5]=l):l=e[5];let m;e[6]!==l?(m=t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:l}),e[6]=l,e[7]=m):m=e[7],a=t.jsxs("div",{className:"flex flex-col gap-2",children:[m,i!==null&&o.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:r("spaces.page.empty")}):null,o.map(Ym)]}),e[0]=i,e[1]=s,e[2]=r,e[3]=a}else a=e[3];return a},qm=n=>pn(n)??"",Hm=n=>{const e=ue.c(38),{worktree:s,onDelete:r}=n,{t:i}=ye();let a;e[0]!==s.path?(a={id:s.path},e[0]=s.path,e[1]=a):a=e[1];const{attributes:o,listeners:l,setNodeRef:m,transform:p,transition:f,isDragging:g}=fi(a);let d;e[2]!==p?(d=pi.Transform.toString(p),e[2]=p,e[3]=d):d=e[3];const h=g?10:1;let b;e[4]!==d||e[5]!==h||e[6]!==f?(b={transform:d,transition:f,zIndex:h},e[4]=d,e[5]=h,e[6]=f,e[7]=b):b=e[7];const v=b,x=s.branch||s.label||s.path,S=ca(s.path),C=g&&"shadow-lg shadow-black/20",R=S&&"opacity-60";let T;e[8]!==C||e[9]!==R?(T=te("flex items-center gap-1 rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",C,R),e[8]=C,e[9]=R,e[10]=T):T=e[10];const P=S||void 0;let k;e[11]!==x||e[12]!==i?(k=i("mobile.projectEdit.dragWorktreeAria",{label:x}),e[11]=x,e[12]=i,e[13]=k):k=e[13];let j;e[14]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx(ni,{className:"size-4"}),e[14]=j):j=e[14];let y;e[15]!==o||e[16]!==l||e[17]!==k?(y=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":k,...o,...l,children:j}),e[15]=o,e[16]=l,e[17]=k,e[18]=y):y=e[18];let I;e[19]!==S||e[20]!==i?(I=S?t.jsx("span",{className:"inline-flex shrink-0 text-muted-foreground",role:"status","aria-label":i("sessions.sidebar.group.worktreeRemoving"),children:t.jsx(Y,{name:"loader-4",className:"size-4 animate-spin"})}):t.jsx(Y,{name:"node-tree",className:"size-4 shrink-0 text-muted-foreground"}),e[19]=S,e[20]=i,e[21]=I):I=e[21];let D;e[22]!==x?(D=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:x}),e[22]=x,e[23]=D):D=e[23];let L;e[24]!==x||e[25]!==r||e[26]!==S||e[27]!==i?(L=S?null:t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive","aria-label":i("mobile.projectEdit.deleteWorktreeAria",{label:x}),onClick:r,style:{touchAction:"manipulation"},children:t.jsx(Wn,{className:"size-4"})}),e[24]=x,e[25]=r,e[26]=S,e[27]=i,e[28]=L):L=e[28];let O;return e[29]!==m||e[30]!==v||e[31]!==y||e[32]!==I||e[33]!==D||e[34]!==L||e[35]!==T||e[36]!==P?(O=t.jsxs("div",{ref:m,style:v,className:T,"aria-busy":P,children:[y,I,D,L]}),e[29]=m,e[30]=v,e[31]=y,e[32]=I,e[33]=D,e[34]=L,e[35]=T,e[36]=P,e[37]=O):O=e[37],O},Jm=n=>{const e=ue.c(87),{open:s,project:r,onClose:i,onWorktreesChanged:a}=n,{t:o}=ye(),{currentTheme:l}=sa(),m=Ve(Xm),p=it(Qm),f=it(Zm),g=it(ep),d=Ur(tp);let h;e[0]!==r?(h=ie=>r?ie.projects.find(he=>he.id===r.id)?.iconImage??null:null,e[0]=r,e[1]=h):h=e[1];const b=it(h),[v,x]=c.useState(""),[S,C]=c.useState(null),[R,T]=c.useState(null),[P,k]=c.useState(!1);let j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[2]=j):j=e[2];const[y,I]=c.useState(j),[D,L]=c.useState(null),O=r?.id??null;let E;e[3]!==s||e[4]!==r?(E=()=>{!s||!r||(x(r.label),C(r.icon??null),T(r.color??null),I(r.worktrees))},e[3]=s,e[4]=r,e[5]=E):E=e[5];let M;e[6]!==s||e[7]!==O?(M=[s,O],e[6]=s,e[7]=O,e[8]=M):M=e[8],c.useEffect(E,M);let z;e[9]!==s||e[10]!==r?(z=()=>{!s||!r||I(ie=>{const he=r.worktrees.map(sp),pe=ie.map(np);return he.length===pe.length&&he.every(De=>pe.includes(De))?ie:r.worktrees})},e[9]=s,e[10]=r,e[11]=z):z=e[11];const _=r?.worktrees;let G;e[12]!==_?(G=[_],e[12]=_,e[13]=G):G=e[13],c.useEffect(z,G);let F;e[14]===Symbol.for("react.memo_cache_sentinel")?(F={activationConstraint:{distance:8}},e[14]=F):F=e[14];let B;e[15]===Symbol.for("react.memo_cache_sentinel")?(B={coordinateGetter:mi},e[15]=B):B=e[15];const V=ii(Ds(ai,F),Ds(oi,B));let X;e[16]!==R||e[17]!==S||e[18]!==v||e[19]!==i||e[20]!==r||e[21]!==p?(X=()=>{if(!r)return;const he={label:v.trim()||r.label,icon:S,color:R};R!==(r.color??null)&&(he.iconBackground=Ql(R)),p(r.id,he),i()},e[16]=R,e[17]=S,e[18]=v,e[19]=i,e[20]=r,e[21]=p,e[22]=X):X=e[22];const Z=X;let de;e[23]!==f||e[24]!==P||e[25]!==r||e[26]!==o?(de=()=>{!r||P||(k(!0),f(r.id).then(ie=>{if(!ie.ok){ce.error(ie.error||o("projectEditDialog.toast.failedToDiscoverIcon"));return}if(ie.skipped){ce.success(o("projectEditDialog.toast.customIconAlreadySet"));return}ce.success(o("projectEditDialog.toast.iconDiscovered"))}).finally(()=>k(!1)))},e[23]=f,e[24]=P,e[25]=r,e[26]=o,e[27]=de):de=e[27];const re=de;let Q;e[28]!==r||e[29]!==g||e[30]!==o?(Q=()=>{r&&g(r.id).then(ie=>{if(!ie.ok){ce.error(ie.error||o("projectEditDialog.toast.failedToRemoveIcon"));return}ce.success(o("projectEditDialog.toast.iconRemoved"))})},e[28]=r,e[29]=g,e[30]=o,e[31]=Q):Q=e[31];const ge=Q;let ee;e[32]!==y||e[33]!==r||e[34]!==d?(ee=ie=>{const{active:he,over:pe}=ie;if(!pe||he.id===pe.id||!r)return;const Oe=y.findIndex(pt=>pt.path===he.id),De=y.findIndex(pt=>pt.path===pe.id);if(Oe<0||De<0)return;const Fe=[...y],[Ge]=Fe.splice(Oe,1);Fe.splice(De,0,Ge),I(Fe),d(r.id,Fe.map(rp))},e[32]=y,e[33]=r,e[34]=d,e[35]=ee):ee=e[35];const N=ee;let $;e[36]!==R?($=ra(R),e[36]=R,e[37]=$):$=e[37];const J=$,ae=S?na[S]:null,oe=!!b;let q;e[38]!==o?(q=o("projectEditDialog.title"),e[38]=o,e[39]=q):q=e[39];let ne;e[40]!==o?(ne=o("projectEditDialog.title"),e[40]=o,e[41]=ne):ne=e[41];let ve;e[42]!==o?(ve=o("projectEditDialog.actions.save"),e[42]=o,e[43]=ve):ve=e[43];let we;e[44]!==v?(we=v.trim(),e[44]=v,e[45]=we):we=e[45];const xe=!we;let fe,Ne;e[46]===Symbol.for("react.memo_cache_sentinel")?(fe={touchAction:"manipulation"},Ne=t.jsx(wa,{className:"size-4"}),e[46]=fe,e[47]=Ne):(fe=e[46],Ne=e[47]);let Ae;e[48]!==o?(Ae=o("projectEditDialog.actions.save"),e[48]=o,e[49]=Ae):Ae=e[49];let Te;e[50]!==Z||e[51]!==ve||e[52]!==xe||e[53]!==Ae?(Te=t.jsxs(Ee,{type:"button",variant:"default",size:"sm","aria-label":ve,onClick:Z,disabled:xe,style:fe,children:[Ne,Ae]}),e[50]=Z,e[51]=ve,e[52]=xe,e[53]=Ae,e[54]=Te):Te=e[54];let Ce;e[55]!==R||e[56]!==J||e[57]!==b||e[58]!==l||e[59]!==V||e[60]!==re||e[61]!==ge||e[62]!==N||e[63]!==oe||e[64]!==S||e[65]!==P||e[66]!==m||e[67]!==v||e[68]!==y||e[69]!==ae||e[70]!==r||e[71]!==o?(Ce=r?t.jsxs("div",{className:"h-full space-y-6 overflow-y-auto px-4 pb-8 pt-2",children:[t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx("span",{className:"flex size-16 items-center justify-center overflow-hidden rounded-2xl bg-[var(--surface-muted)] text-muted-foreground",style:r.iconBackground?{backgroundColor:r.iconBackground}:void 0,children:oe?t.jsx(ia,{project:{id:r.id,iconImage:b},options:{themeVariant:l.metadata.variant,iconColor:l.colors.surface.foreground},className:"size-full object-contain",fallback:t.jsx(Lr,{className:"size-7"})}):ae?t.jsx(Y,{name:ae,className:"size-7",style:J?{color:J}:void 0}):t.jsx(Lr,{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:o("projectEditDialog.field.name")}),t.jsx(la,{value:v,onChange:ie=>x(ie.target.value),placeholder:o("projectEditDialog.field.namePlaceholder"),className:"h-11"}),t.jsx("p",{className:"truncate typography-meta text-muted-foreground",title:r.path,children:r.path})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:o("projectEditDialog.field.color")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>T(null),"aria-label":o("projectEditDialog.option.none"),className:te("flex size-9 items-center justify-center rounded-xl border-2 transition-all",R===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"})}),Yl.map(ie=>t.jsx("button",{type:"button",onClick:()=>T(ie),"aria-label":o("settings.projects.appearance.colorSwatchAria",{color:ie}),title:ie,className:te("size-9 rounded-xl border-2 transition-all",R===ie?"border-foreground":"border-transparent hover:border-border/70"),style:{backgroundColor:ie,touchAction:"manipulation"}},ie))]})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:o("projectEditDialog.field.icon")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>C(null),"aria-label":o("projectEditDialog.option.none"),className:te("flex size-9 items-center justify-center rounded-xl border-2 transition-all",S===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"})}),Xl.map(ie=>t.jsx("button",{type:"button",onClick:()=>C(ie.key),"aria-label":ie.label,title:ie.label,className:te("flex size-9 items-center justify-center rounded-xl border-2 transition-all",S===ie.key?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx(Y,{name:ie.Icon,className:"size-4",style:J?{color:J}:void 0})},ie.key))]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[t.jsx(Ee,{size:"sm",variant:"outline",onClick:re,disabled:P,children:o(P?"projectEditDialog.actions.discovering":"projectEditDialog.actions.discoverFavicon")}),oe?t.jsx(Ee,{size:"sm",variant:"outline",onClick:ge,children:o("projectEditDialog.actions.removeProjectIcon")}):null]})]}),r.isGitRepo?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:o("mobile.projectEdit.worktreesTitle")}),y.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("mobile.projectEdit.worktreesEmpty")}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("mobile.projectEdit.reorderHint")}),t.jsx(li,{sensors:V,collisionDetection:ci,onDragEnd:N,children:t.jsx(ui,{items:y.map(ip),strategy:di,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:y.map(ie=>t.jsx(Hm,{worktree:ie,onDelete:()=>L(ie)},ie.path))})})})]})]}):null,r.isGitRepo&&m?t.jsx(Km,{projectPath:r.path}):null]}):null,e[55]=R,e[56]=J,e[57]=b,e[58]=l,e[59]=V,e[60]=re,e[61]=ge,e[62]=N,e[63]=oe,e[64]=S,e[65]=P,e[66]=m,e[67]=v,e[68]=y,e[69]=ae,e[70]=r,e[71]=o,e[72]=Ce):Ce=e[72];let Se;e[73]!==i||e[74]!==s||e[75]!==q||e[76]!==ne||e[77]!==Te||e[78]!==Ce?(Se=t.jsx(Tt,{open:s,onClose:i,title:q,ariaLabel:ne,noHeaderBorder:!0,trailing:Te,children:Ce}),e[73]=i,e[74]=s,e[75]=q,e[76]=ne,e[77]=Te,e[78]=Ce,e[79]=Se):Se=e[79];let K;e[80]!==a||e[81]!==r||e[82]!==D?(K=r?t.jsx(qa,{open:!!D,project:{id:r.id,path:r.path},worktree:D,onClose:()=>L(null),onDeleted:()=>{I(ie=>ie.filter(he=>he.path!==D?.path)),a?.()}}):null,e[80]=a,e[81]=r,e[82]=D,e[83]=K):K=e[83];let be;return e[84]!==Se||e[85]!==K?(be=t.jsxs(t.Fragment,{children:[Se,K]}),e[84]=Se,e[85]=K,e[86]=be):be=e[86],be};function Ym(n){return t.jsx($d,{entry:n,actions:"sheet"},n.id)}function Xm(n){return n.isolatedSpacesEnabled}function Qm(n){return n.updateProjectMeta}function Zm(n){return n.discoverProjectIcon}function ep(n){return n.removeProjectIcon}function tp(n){return n.setWorktreeOrder}function sp(n){return n.path}function np(n){return n.path}function rp(n){return qm(n.path)}function ip(n){return n.path}const op=32,ap=80,lp=64,cp=.7,up=140,dp=.4,fp=(n,e,s)=>{const r=e.ownerDocument.defaultView;if(!r)return"drawer";let i=!1;for(let a=n instanceof r.Element?n:null;a&&a!==e;a=a.parentElement){const o=a.scrollWidth-a.clientWidth;if(o<=1)continue;const l=r.getComputedStyle(a);if(l.overflowX!=="auto"&&l.overflowX!=="scroll")continue;const m=l.direction==="rtl"?-o:0,p=m+o;if(s?a.scrollLeft>m+1:a.scrollLeft<p-1)return"content";i=!0}return i?"content-end":"drawer"},Ni=(n,e)=>{const s=c.useRef(e);s.current=e;const r=e.enabled??!0;c.useEffect(()=>{if(!r)return;const i=n.current;if(!i)return;const o=window.Capacitor?.getPlatform?.()==="android"?ap:op,l=i.ownerDocument;let m=!1,p=!1,f="drawer",g=0,d=0;const h=()=>l.getSelection()?.isCollapsed===!1,b=()=>{m=!1},v=()=>{m&&h()&&b()},x=C=>{if(C.touches.length!==1||h()){m=!1;return}const R=C.touches[0],T=i.clientWidth,P=R.clientX<=o,k=R.clientX>=T-o;p=P,f=P||k?fp(C.target,i,p):"drawer",m=(P||k)&&f!=="content",g=R.clientX,d=R.clientY},S=C=>{if(!m||(m=!1,h()))return;const R=C.changedTouches[0];if(!R)return;const T=R.clientX-g,P=R.clientY-d,k=f==="content-end"?up:lp,j=f==="content-end"?dp:cp;Math.abs(T)<k||Math.abs(P)>Math.abs(T)*j||p&&T<=0||!p&&T>=0||(p?s.current.onLeftEdgeSwipe?.():s.current.onRightEdgeSwipe?.())};return i.addEventListener("touchstart",x,{passive:!0}),i.addEventListener("touchend",S,{passive:!0}),i.addEventListener("touchcancel",b,{passive:!0}),i.addEventListener("selectstart",b),l.addEventListener("selectionchange",v),()=>{i.removeEventListener("touchstart",x),i.removeEventListener("touchend",S),i.removeEventListener("touchcancel",b),i.removeEventListener("selectstart",b),l.removeEventListener("selectionchange",v)}},[r,n])},mp=()=>globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0;function zn(n){const e=ue.c(11),{open:s,children:r}=n,[i,a]=c.useState(s);s&&!i&&a(!0);const o=c.useRef(null),l=c.useRef(null),m=c.useRef(s);let p,f;e[0]!==s?(p=()=>{const S=o.current;if(m.current===s||!S)return;if(m.current=s,mp()){s||a(!1);return}const C=l.current||!s?S.getBoundingClientRect().height:0;l.current?.cancel();const R=s?S.scrollHeight:0;S.style.overflow="hidden";const T=S.animate([{height:`${C}px`,opacity:s?0:1},{height:`${R}px`,opacity:s?1:0}],{duration:Nu,easing:Su,fill:s?"none":"forwards"});l.current=T,T.finished.then(()=>{l.current===T&&(l.current=null,s?S.style.overflow="":a(!1))},pp)},f=[s],e[0]=s,e[1]=p,e[2]=f):(p=e[1],f=e[2]),c.useLayoutEffect(p,f);let g,d;if(e[3]===Symbol.for("react.memo_cache_sentinel")?(g=()=>()=>l.current?.cancel(),d=[],e[3]=g,e[4]=d):(g=e[3],d=e[4]),c.useEffect(g,d),!i)return null;const h=!s||void 0,b=!s;let v;e[5]!==r?(v=r(),e[5]=r,e[6]=v):v=e[6];let x;return e[7]!==h||e[8]!==b||e[9]!==v?(x=t.jsx("div",{ref:o,"aria-hidden":h,inert:b,children:v}),e[7]=h,e[8]=b,e[9]=v,e[10]=x):x=e[10],x}function pp(){}const hp=new Set,gp=[["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"]],bp=[["projects","mobile.sessions.viewMode.projects"],["timeline","mobile.sessions.viewMode.timeline"]],tn="min-h-10 items-center justify-between",sn=7,xp=3,yp=32,Ci=n=>yp+n*12,Xn=n=>Ci(n)+20,Er="openchamber:pinned",ko="openchamber:work",Ir=12,vp=(n,e)=>{const s=Je(n),r=Je(e),i=r.endsWith("/")?r:`${r}/`;return!!(s&&r&&(s===r||s.startsWith(i)))},Ar=(n,e)=>n.worktrees.find(s=>Je(s.path)===e)??null,Pr=(n,e,s)=>ua([n.title,n.id,yt(n),e],s),wp=n=>{const e=ue.c(3),{path:s,children:r}=n,i=ca(s);let a;return e[0]!==r||e[1]!==i?(a=r(i),e[0]=r,e[1]=i,e[2]=a):a=e[2],a},jp=n=>{const e=ue.c(2),{ariaLabel:s}=n;let r;return e[0]!==s?(r=t.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-primary","aria-label":s}),e[0]=s,e[1]=r):r=e[1],r},So=n=>{const e=ue.c(12),{onClick:s,className:r}=n,{t:i}=ye();let a;e[0]!==i?(a=i("sessions.sidebar.project.actions.newWorktree"),e[0]=i,e[1]=a):a=e[1];const o=a;let l;e[2]!==r?(l=te("flex size-9 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",r),e[2]=r,e[3]=l):l=e[3];let m;e[4]!==s?(m=d=>{d.stopPropagation(),s()},e[4]=s,e[5]=m):m=e[5];let p,f;e[6]===Symbol.for("react.memo_cache_sentinel")?(p={touchAction:"manipulation"},f=t.jsx(Y,{name:"node-tree",className:"size-3.5"}),e[6]=p,e[7]=f):(p=e[6],f=e[7]);let g;return e[8]!==o||e[9]!==l||e[10]!==m?(g=t.jsx("button",{type:"button",className:l,"aria-label":o,title:o,onClick:m,style:p,children:f}),e[8]=o,e[9]=l,e[10]=m,e[11]=g):g=e[11],g},No=n=>{const e=ue.c(10),{label:s,onClick:r,className:i}=n;let a;e[0]!==i?(a=te("flex size-9 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",i),e[0]=i,e[1]=a):a=e[1];let o;e[2]!==r?(o=f=>{f.stopPropagation(),r()},e[2]=r,e[3]=o):o=e[3];let l,m;e[4]===Symbol.for("react.memo_cache_sentinel")?(l={touchAction:"manipulation"},m=t.jsx(Y,{name:"add",className:"size-4"}),e[4]=l,e[5]=m):(l=e[4],m=e[5]);let p;return e[6]!==s||e[7]!==a||e[8]!==o?(p=t.jsx("button",{type:"button",className:a,"aria-label":s,title:s,onClick:o,style:l,children:m}),e[6]=s,e[7]=a,e[8]=o,e[9]=p):p=e[9],p},Co=n=>{const e=ue.c(95),{session:s,active:r,indent:i,contextLabel:a,statusOnRight:o,treeDepth:l,hasChildren:m,expanded:p,onToggleChildren:f,onSelect:g,revealed:d,onRevealedChange:h,confirmingDelete:b,onArchive:v,onRequestDelete:x,onConfirmDelete:S,renaming:C,onRequestRename:R,onSubmitRename:T,onCancelRename:P,work:k,pin:j,descendantIdsOf:y}=n,I=o===void 0?!1:o,D=m===void 0?!1:m,L=p===void 0?!1:p,O=d===void 0?!1:d,E=b===void 0?!1:b,M=C===void 0?!1:C,{t:z}=ye();let _;e[0]!==s?(_=nr(Xa(s)),e[0]=s,e[1]=_):_=e[1];const G=_;let F;e[2]!==s.title||e[3]!==z?(F=s.title?.trim()||z("mobile.sessions.untitled"),e[2]=s.title,e[3]=z,e[4]=F):F=e[4];const B=F,V=!!(h&&v),X=l!==void 0,Z=I||X;let de;e[5]!==i||e[6]!==X||e[7]!==l?(de=X?Xn(l):i,e[5]=i,e[6]=X,e[7]=l,e[8]=de):de=e[8];const re=de,Q=ga(s.id,s.directory,V&&(O||M)),ge=Yr(s.id),ee=Xr(s.id),N=ee!==null,$=!N&&ge>0&&!r,J=Qr(s.id,N),ae=(N||$)&&J;let oe;e[9]!==N||e[10]!==s||e[11]!==k?.inWork?(oe=!!k?.inWork&&!N&&oc(s),e[9]=N,e[10]=s,e[11]=k?.inWork,e[12]=oe):oe=e[12];const q=oe;let ne;e[13]!==y||e[14]!==L||e[15]!==D||e[16]!==s.id?(ne=y&&!(D&&L)?[s.id,...y(s.id)]:[s.id],e[13]=y,e[14]=L,e[15]=D,e[16]=s.id,e[17]=ne):ne=e[17];const we=Za(ne);let xe;e[18]!==L||e[19]!==D||e[20]!==X||e[21]!==f||e[22]!==z||e[23]!==l?(xe=X&&D&&f?t.jsx("button",{type:"button",className:"absolute z-10 flex w-[30px] items-center justify-center text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:{insetInlineStart:Ci(l)-8,top:0,bottom:0,touchAction:"manipulation"},"aria-label":z(L?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),"aria-expanded":L,onClick:pe=>{pe.stopPropagation(),f()},children:t.jsx(xa,{expanded:L})}):null,e[18]=L,e[19]=D,e[20]=X,e[21]=f,e[22]=z,e[23]=l,e[24]=xe):xe=e[24];let fe;e[25]!==Q||e[26]!==L||e[27]!==D||e[28]!==i||e[29]!==N||e[30]!==f||e[31]!==$||e[32]!==Z||e[33]!==z||e[34]!==ee?(fe=!Z&&(Q.pending||N||$||D&&f)?t.jsx("button",{type:"button",className:"absolute z-10 flex w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:{insetInlineStart:Math.max(i-32,2),top:0,bottom:0,touchAction:"manipulation"},"aria-label":Q.pending?z("sessions.aiRename.generating"):z(L?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),disabled:!D||!f,onClick:pe=>{pe.stopPropagation(),f?.()},children:Q.pending?t.jsx(Y,{name:"loader-4",className:"size-3 animate-spin text-primary","aria-label":z("sessions.aiRename.generating")}):N||$?t.jsx($n,{state:ee??"unread"}):t.jsx(ri,{className:te("size-[18px] transition-transform duration-150",L?"rotate-0":"-rotate-90 rtl:rotate-90")})}):null,e[25]=Q,e[26]=L,e[27]=D,e[28]=i,e[29]=N,e[30]=f,e[31]=$,e[32]=Z,e[33]=z,e[34]=ee,e[35]=fe):fe=e[35];let Ne;e[36]!==r||e[37]!==Q||e[38]!==a||e[39]!==N||e[40]!==P||e[41]!==h||e[42]!==g||e[43]!==T||e[44]!==we||e[45]!==j?.pinned||e[46]!==M||e[47]!==O||e[48]!==s||e[49]!==ae||e[50]!==q||e[51]!==$||e[52]!==Z||e[53]!==z||e[54]!==re||e[55]!==G||e[56]!==B||e[57]!==ee?(Ne=M&&T&&P?t.jsx(Ha,{initialTitle:B,indent:re,aiRename:Q,onSubmit:T,onCancel:P}):t.jsx("button",{type:"button",className:te("flex min-w-0 flex-1 items-center gap-2.5 pe-3.5 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",a?"min-h-10 py-1":"h-9"),style:{paddingInlineStart:re,touchAction:"manipulation"},onClick:()=>{if(O){h?.(!1);return}g()},children:t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[t.jsxs("span",{className:"flex items-center gap-2.5",children:[t.jsx("span",{dir:"auto",className:te("block min-w-0 flex-1 truncate oc-ui-start-align typography-ui-label",r?"text-primary":"text-foreground"),children:B}),j?.pinned?t.jsx(Y,{name:"pushpin",className:"size-3 shrink-0 text-muted-foreground","aria-label":z("sessions.sidebar.session.status.pinned")}):null,Z&&(Q.pending||N||$)?Q.pending?t.jsx(Y,{name:"loader-4",className:"size-3 shrink-0 animate-spin text-primary","aria-label":z("sessions.aiRename.generating")}):t.jsx($n,{state:ee??"unread"}):null,q?t.jsx(Y,{name:"check",className:"size-3.5 shrink-0 text-muted-foreground","aria-label":z("sessions.sidebar.session.work.doneSuggested")}):null,t.jsx(Gr,{session:s}),t.jsx(Kr,{...we}),ae?t.jsx(Zr,{sessionId:s.id,running:N,className:"typography-micro"}):G?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:G}):null]}),a?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:a}):null]})}),e[36]=r,e[37]=Q,e[38]=a,e[39]=N,e[40]=P,e[41]=h,e[42]=g,e[43]=T,e[44]=we,e[45]=j?.pinned,e[46]=M,e[47]=O,e[48]=s,e[49]=ae,e[50]=q,e[51]=$,e[52]=Z,e[53]=z,e[54]=re,e[55]=G,e[56]=B,e[57]=ee,e[58]=Ne):Ne=e[58];let Ae;e[59]!==xe||e[60]!==fe||e[61]!==Ne?(Ae=t.jsxs(t.Fragment,{children:[xe,fe,Ne]}),e[59]=xe,e[60]=fe,e[61]=Ne,e[62]=Ae):Ae=e[62];const Te=Ae;if(!V){const pe=r||void 0,Oe=r&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let De;e[63]!==Oe?(De=te("relative flex items-center gap-1 transition-colors",Oe),e[63]=Oe,e[64]=De):De=e[64];let Fe;e[65]!==Te||e[66]!==De?(Fe=t.jsx("div",{className:De,children:Te}),e[65]=Te,e[66]=De,e[67]=Fe):Fe=e[67];let Ge;return e[68]!==pe||e[69]!==Fe?(Ge=t.jsx("div",{"data-active-session":pe,className:"relative overflow-hidden",children:Fe}),e[68]=pe,e[69]=Fe,e[70]=Ge):Ge=e[70],Ge}const Ce=Ja+(k?dn:0)+(j?dn:0);let Se;e[71]!==h?(Se=pe=>h?.(pe),e[71]=h,e[72]=Se):Se=e[72];const K=r&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let be;e[73]!==K?(be=te("relative flex w-full items-center gap-1 bg-background transition-colors",K),e[73]=K,e[74]=be):be=e[74];let ie;e[75]!==E||e[76]!==v||e[77]!==S||e[78]!==x||e[79]!==R||e[80]!==h||e[81]!==j||e[82]!==O||e[83]!==s.id||e[84]!==B||e[85]!==k?(ie=t.jsx(Ya,{sessionId:s.id,title:B,revealed:O,confirmingDelete:E,onArchive:v,onRequestDelete:x,onConfirmDelete:S,onRequestRename:R,onRevealedChange:h,work:k,pin:j}),e[75]=E,e[76]=v,e[77]=S,e[78]=x,e[79]=R,e[80]=h,e[81]=j,e[82]=O,e[83]=s.id,e[84]=B,e[85]=k,e[86]=ie):ie=e[86];let he;return e[87]!==r||e[88]!==O||e[89]!==Te||e[90]!==Ce||e[91]!==Se||e[92]!==be||e[93]!==ie?(he=t.jsx(Yn,{actionsWidth:Ce,revealed:O,onRevealedChange:Se,dataActiveSession:r,contentClassName:be,actions:ie,children:Te}),e[87]=r,e[88]=O,e[89]=Te,e[90]=Ce,e[91]=Se,e[92]=be,e[93]=ie,e[94]=he):he=e[94],he},Ro=[],kp=n=>{const e=ue.c(41),{run:s,laneNodes:r,depth:i}=n,{t:a}=ye();let o;e[0]!==s.key?(o=O=>O.runOverviewKey===s.key,e[0]=s.key,e[1]=o):o=e[1];const l=Ve(o);let m;e[2]!==r?(m={nodes:r,includeUnreadSubtasks:!1},e[2]=r,e[3]=m):m=e[3];const p=ha(m);let f;e[4]!==s.lastActivity?(f=nr(s.lastActivity),e[4]=s.lastActivity,e[5]=f):f=e[5];const g=f,d=l||void 0,h=l&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let b;e[6]!==h?(b=te("relative flex items-center overflow-hidden transition-colors",h),e[6]=h,e[7]=b):b=e[7];let v;e[8]!==i?(v=Xn(i),e[8]=i,e[9]=v):v=e[9];let x;e[10]!==v?(x={paddingInlineStart:v,touchAction:"manipulation"},e[10]=v,e[11]=x):x=e[11];let S;e[12]!==s.key?(S=()=>Ve.getState().setRunOverviewKey(s.key),e[12]=s.key,e[13]=S):S=e[13];let C;e[14]!==s.title||e[15]!==a?(C=a("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[14]=s.title,e[15]=a,e[16]=C):C=e[16];let R;e[17]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx(oa,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[17]=R):R=e[17];const T=l?"text-primary":"text-foreground";let P;e[18]!==T?(P=te("block min-w-0 flex-1 truncate oc-ui-start-align typography-ui-label",T),e[18]=T,e[19]=P):P=e[19];let k;e[20]!==s.title||e[21]!==P?(k=t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[R,t.jsx("span",{dir:"auto",className:P,children:s.title})]}),e[20]=s.title,e[21]=P,e[22]=k):k=e[22];let j;e[23]!==s.providerIDs?(j=t.jsx(Qa,{providerIDs:s.providerIDs}),e[23]=s.providerIDs,e[24]=j):j=e[24];let y;e[25]!==p?(y=p?t.jsx(ba,{state:p}):null,e[25]=p,e[26]=y):y=e[26];let I;e[27]!==g?(I=g?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:g}):null,e[27]=g,e[28]=I):I=e[28];let D;e[29]!==C||e[30]!==k||e[31]!==j||e[32]!==y||e[33]!==I||e[34]!==x||e[35]!==S?(D=t.jsxs("button",{type:"button",className:"flex h-9 w-full min-w-0 items-center gap-2.5 pe-3.5 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:x,onClick:S,"aria-label":C,children:[k,j,y,I]}),e[29]=C,e[30]=k,e[31]=j,e[32]=y,e[33]=I,e[34]=x,e[35]=S,e[36]=D):D=e[36];let L;return e[37]!==D||e[38]!==d||e[39]!==b?(L=t.jsx("div",{"data-active-session":d,className:b,children:D}),e[37]=D,e[38]=d,e[39]=b,e[40]=L):L=e[40],L},Eo=n=>{const e=ue.c(11),{indent:s,onClick:r}=n,{t:i}=ye();let a;e[0]!==s?(a={paddingInlineStart:s,touchAction:"manipulation"},e[0]=s,e[1]=a):a=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx(ri,{className:"size-4"}),e[2]=o):o=e[2];let l;e[3]!==i?(l=i("sessions.sidebar.group.showMore"),e[3]=i,e[4]=l):l=e[4];let m;e[5]!==l?(m=t.jsx("span",{className:"typography-micro",children:l}),e[5]=l,e[6]=m):m=e[6];let p;return e[7]!==r||e[8]!==a||e[9]!==m?(p=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pe-3 text-start text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:a,onClick:r,children:[o,m]}),e[7]=r,e[8]=a,e[9]=m,e[10]=p):p=e[10],p},Io=n=>{const e=ue.c(11),{indent:s,onClick:r}=n,{t:i}=ye();let a;e[0]!==s?(a={paddingInlineStart:s,touchAction:"manipulation"},e[0]=s,e[1]=a):a=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx(Td,{className:"size-4"}),e[2]=o):o=e[2];let l;e[3]!==i?(l=i("sessions.sidebar.group.showFewer"),e[3]=i,e[4]=l):l=e[4];let m;e[5]!==l?(m=t.jsx("span",{className:"typography-micro",children:l}),e[5]=l,e[6]=m):m=e[6];let p;return e[7]!==r||e[8]!==a||e[9]!==m?(p=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pe-3 text-start text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:a,onClick:r,children:[o,m]}),e[7]=r,e[8]=a,e[9]=m,e[10]=p):p=e[10],p},Sp=n=>{const e=ue.c(29),{worktree:s}=n,{t:r}=ye();let i;e[0]!==s.path?(i=Je(s.path),e[0]=s.path,e[1]=i):i=e[1];const a=i;let o;e[2]!==a?(o={id:a},e[2]=a,e[3]=o):o=e[3];const{attributes:l,listeners:m,setNodeRef:p,transform:f,transition:g,isDragging:d}=fi(o),h=s.branch||s.label||s.path;let b;e[4]!==f?(b=pi.Transform.toString(f),e[4]=f,e[5]=b):b=e[5];const v=d?10:1;let x;e[6]!==b||e[7]!==v||e[8]!==g?(x={transform:b,transition:g,zIndex:v},e[6]=b,e[7]=v,e[8]=g,e[9]=x):x=e[9];const S=d&&"shadow-lg shadow-black/20";let C;e[10]!==S?(C=te("flex items-center gap-1 rounded-xl bg-background px-1 py-1",S),e[10]=S,e[11]=C):C=e[11];let R;e[12]!==h||e[13]!==r?(R=r("mobile.sessions.dragHandleAria",{label:h}),e[12]=h,e[13]=r,e[14]=R):R=e[14];let T;e[15]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(ni,{className:"size-4"}),e[15]=T):T=e[15];let P;e[16]!==l||e[17]!==m||e[18]!==R?(P=t.jsx("button",{type:"button",className:"flex size-8 shrink-0 cursor-grab touch-none items-center justify-center rounded-lg text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":R,...l,...m,children:T}),e[16]=l,e[17]=m,e[18]=R,e[19]=P):P=e[19];let k;e[20]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx(Y,{name:"git-branch",className:"size-4 shrink-0 text-muted-foreground"}),e[20]=k):k=e[20];let j;e[21]!==h?(j=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]=j):j=e[22];let y;return e[23]!==p||e[24]!==P||e[25]!==j||e[26]!==x||e[27]!==C?(y=t.jsxs("div",{ref:p,style:x,className:C,children:[P,k,j]}),e[23]=p,e[24]=P,e[25]=j,e[26]=x,e[27]=C,e[28]=y):y=e[28],y},Np=n=>{const e=ue.c(58),{project:s,expanded:r,onToggleExpanded:i,onReorderWorktrees:a}=n,{t:o}=ye();let l;e[0]!==s.id?(l={id:s.id},e[0]=s.id,e[1]=l):l=e[1];const{attributes:m,listeners:p,setNodeRef:f,transform:g,transition:d,isDragging:h}=fi(l);let b;e[2]===Symbol.for("react.memo_cache_sentinel")?(b={activationConstraint:{distance:8}},e[2]=b):b=e[2];let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v={coordinateGetter:mi},e[3]=v):v=e[3];const x=ii(Ds(ai,b),Ds(oi,v)),S=s.worktrees.length>0;let C;e[4]!==a||e[5]!==s.worktrees?(C=Z=>{const{active:de,over:re}=Z;if(!re||de.id===re.id)return;const Q=s.worktrees.map(Ip),ge=Q.indexOf(String(de.id)),ee=Q.indexOf(String(re.id));if(ge<0||ee<0)return;const N=[...Q],[$]=N.splice(ge,1);N.splice(ee,0,$),a(N)},e[4]=a,e[5]=s.worktrees,e[6]=C):C=e[6];const R=C;let T;e[7]!==g?(T=pi.Transform.toString(g),e[7]=g,e[8]=T):T=e[8];const P=h?10:1;let k;e[9]!==T||e[10]!==P||e[11]!==d?(k={transform:T,transition:d,zIndex:P},e[9]=T,e[10]=P,e[11]=d,e[12]=k):k=e[12];const j=h&&"shadow-lg shadow-black/20";let y;e[13]!==j?(y=te("rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",j),e[13]=j,e[14]=y):y=e[14];let I;e[15]!==s.label||e[16]!==o?(I=o("mobile.sessions.dragHandleAria",{label:s.label}),e[15]=s.label,e[16]=o,e[17]=I):I=e[17];let D;e[18]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx(ni,{className:"size-4"}),e[18]=D):D=e[18];let L;e[19]!==m||e[20]!==p||e[21]!==I?(L=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":I,...m,...p,children:D}),e[19]=m,e[20]=p,e[21]=I,e[22]=L):L=e[22];let O;e[23]!==r||e[24]!==s.label||e[25]!==o?(O=r?o("sessions.sidebar.group.collapseAria",{label:s.label}):o("sessions.sidebar.group.expandAria",{label:s.label}),e[23]=r,e[24]=s.label,e[25]=o,e[26]=O):O=e[26];const E=!S;let M;e[27]===Symbol.for("react.memo_cache_sentinel")?(M={touchAction:"manipulation"},e[27]=M):M=e[27];let z;e[28]!==s?(z=t.jsx(Jn,{project:s}),e[28]=s,e[29]=z):z=e[29];let _;e[30]!==s.label?(_=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]=_):_=e[31];let G;e[32]!==r||e[33]!==S?(G=S?t.jsx(ri,{className:te("size-4 shrink-0 text-muted-foreground transition-transform",r&&"rotate-180")}):null,e[32]=r,e[33]=S,e[34]=G):G=e[34];let F;e[35]!==r||e[36]!==i||e[37]!==O||e[38]!==E||e[39]!==z||e[40]!==_||e[41]!==G?(F=t.jsxs("button",{type:"button",className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 rounded-xl px-1 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:i,"aria-expanded":r,"aria-label":O,disabled:E,style:M,children:[z,_,G]}),e[35]=r,e[36]=i,e[37]=O,e[38]=E,e[39]=z,e[40]=_,e[41]=G,e[42]=F):F=e[42];let B;e[43]!==L||e[44]!==F?(B=t.jsxs("div",{className:"flex items-center gap-1",children:[L,F]}),e[43]=L,e[44]=F,e[45]=B):B=e[45];let V;e[46]!==r||e[47]!==R||e[48]!==S||e[49]!==s.worktrees||e[50]!==x?(V=r&&S?t.jsx(li,{sensors:x,collisionDetection:ci,onDragEnd:R,children:t.jsx(ui,{items:s.worktrees.map(Ap),strategy:di,children:t.jsx("div",{className:"mt-1 flex flex-col gap-0.5 ps-3",children:s.worktrees.map(Pp)})})}):null,e[46]=r,e[47]=R,e[48]=S,e[49]=s.worktrees,e[50]=x,e[51]=V):V=e[51];let X;return e[52]!==f||e[53]!==B||e[54]!==V||e[55]!==k||e[56]!==y?(X=t.jsxs("div",{ref:f,style:k,className:y,children:[B,V]}),e[52]=f,e[53]=B,e[54]=V,e[55]=k,e[56]=y,e[57]=X):X=e[57],X},Ao=({open:n,onOpenChange:e,variant:s="drawer",footer:r})=>{const{t:i}=ye(),{git:a}=Zn(),o=ct(u=>u.ensureStatus),l=ta(),m=as(u=>u.activeSessions),p=as(u=>u.hasLoaded),f=n||s==="sidebar",g=c.useRef(hp),d=Dr(c.useCallback(u=>(f&&(g.current=u.ids),g.current),[f])),h=c.useRef(Zl),b=Ho(c.useCallback(u=>(f&&(h.current=u.rankById),h.current),[f])),v=it(u=>u.projects),x=ec(u=>u.projects),S=it(u=>u.activeProjectId),C=Mt(u=>u.currentDirectory),R=Be(u=>u.currentSessionId),T=Be(u=>u.setCurrentSession),P=Be(u=>u.archiveSession),k=Be(u=>u.archiveSessions),j=Be(u=>u.deleteSession),y=Be(u=>u.deleteSessions),I=Be(u=>u.updateSessionTitle),D=Be(u=>u.openNewSessionDraft),L=it(u=>u.setActiveProject),O=it(u=>u.setActiveProjectIdOnly),E=it(u=>u.reorderProjects),M=it(u=>u.manualProjectOrder),z=Rt(u=>u.projectSortOrder),_=Rt(u=>u.setProjectSortOrder),G=Rt(u=>u.sidebarViewMode),F=G==="timeline"?"manual":z,B=Rt(u=>u.setSidebarViewMode),V=Rt(u=>u.showWorkSection),X=Rt(u=>u.setShowWorkSection),Z=Rt(u=>u.showPinnedSection),de=Rt(u=>u.setShowPinnedSection),re=Rt(u=>u.detailedZoneRows),Q=Rt(u=>u.setDetailedZoneRows),ge=Dr(u=>u.toggle),ee=tc(f),N=it(u=>u.removeProject),$=_n(u=>u.projectExpanded),J=_n(u=>u.worktreeExpanded),ae=_n(u=>u.setProjectExpanded),oe=_n(u=>u.setWorktreeExpanded),q=Ur(u=>u.orderByProject),ne=Ur(u=>u.setWorktreeOrder),ve=yo(u=>u.expandedParents),we=yo(u=>u.toggleParent),[xe,fe]=c.useState(""),[Ne,Ae]=c.useState(null),[Te,Ce]=c.useState(null),[Se,K]=c.useState(null),[be,ie]=c.useState(null),[he,pe]=c.useState(null),[Oe,De]=c.useState(null),[Fe,Ge]=c.useState(null),[pt,Lt]=c.useState(0),[hn,ds]=c.useState(!1),[rr,gn]=c.useState(!1),[fs,ot]=c.useState(null),[vt,ms]=c.useState(()=>new Map(Be.getState().availableWorktreesByProject)),[Ft,ir]=c.useState(()=>{const u=new Set;for(const[A,W]of Be.getState().availableWorktreesByProject)W.length>0&&u.add(A);return u}),[at,$t]=c.useState(!1),[or,ps]=c.useState(new Set),[bn,ht]=c.useState(new Map),Ke=c.useRef(null);c.useEffect(()=>{if(!n){fe(""),$t(!1),ps(new Set),ht(new Map),Ae(null),Ce(null),K(null),ie(null),pe(null),De(null);return}Zo(l)},[n]),c.useEffect(()=>{at||ps(new Set)},[at]),c.useEffect(()=>{ht(new Map)},[G]),c.useEffect(()=>{if(!n||v.length===0)return;let u=!1;return(async()=>{const W=await Promise.all(v.map(async H=>{const se=Je(H.path);if(!se)return null;const me=await a.checkIsGitRepository(se).catch(()=>null),Re=me?await da({id:H.id,path:se}).catch(()=>null):[];return[se,Re,me]}));u||(ms(H=>{const se=new Map;for(const me of W){if(!me)continue;const[Re,tt,st]=me,Hs=st===null||tt===null;se.set(Re,Hs?H.get(Re)??[]:tt)}return fa(v,se)}),ir(H=>{const se=new Set;for(const me of W){if(!me)continue;const[Re,,tt]=me;(tt===null?H.has(Re):tt)&&se.add(Re)}return se}))})(),()=>{u=!0}},[a,n,v,pt]);const Pe=c.useMemo(()=>Cu(v.map(u=>({id:u.id,label:u.label?.trim()||Cr(u.path),path:Je(u.path),icon:u.icon,color:u.color,iconImage:u.iconImage,iconBackground:u.iconBackground,isGitRepo:Ft.has(Je(u.path)),worktrees:Om(q[u.id],vt.get(Je(u.path))??[]),addedAt:u.addedAt,lastOpenedAt:u.lastOpenedAt})),F,M),[Ft,M,F,v,q,vt]),Xe=c.useMemo(()=>{const u=[...m],A=new Set(u.map(W=>W.id));for(const W of l)A.has(W.id)||(A.add(W.id),u.push(W));return u.filter(W=>!W.time?.archived)},[m,l]),Ue=c.useMemo(()=>{const u=new Map;for(const A of Xe){const W=ut(A);if(!W)continue;const H=u.get(W)??[];H.push(A),u.set(W,H)}return u},[Xe]),Et=c.useCallback(u=>Dn(Ue,u),[Ue]),{projectSessions:ze,chatSessions:hs}=c.useMemo(()=>Ru(Xe,!1),[Xe]),qe=Ve(u=>u.sessionWorkEnabled),It=c.useMemo(()=>{const u=new Set;if(!qe||!V)return u;for(const A of Xe)if(!(ut(A)||In(yt(A))||!aa(A))){u.add(A.id);for(const W of Dn(Ue,A.id))u.add(W)}return u},[Ue,qe,Xe,V]),_t=c.useMemo(()=>{const u=new Set;if(!Z)return u;for(const A of Xe){const W=yt(A);if(!(ut(A)||In(W)||!vr(d,W||null,A.id))){u.add(A.id);for(const H of Dn(Ue,A.id))u.add(H)}}return u},[Ue,d,Xe,Z]),Wt=c.useMemo(()=>It.size>0?hs.filter(u=>!It.has(u.id)):hs,[hs,It]),wt=yl(),gs=c.useMemo(()=>new Map(wt.map(u=>[u.id,u])),[wt]),xn=c.useMemo(()=>new Map(wt.map(u=>[u.id,u.name||i("sessions.sidebar.grouping.spaceUnnamed")])),[wt,i]),He=c.useMemo(()=>Fd(ze,Pe.map(u=>({id:u.id,normalizedPath:u.path})),new Map(Pe.map(u=>[u.path,u.worktrees])),!1,[],x,wt),[x,ze,Pe,wt]),$e=c.useMemo(()=>sc(ze,u=>{const A=He.bySessionId.get(u.id);return(A?Pe.find(H=>H.id===A.projectId):void 0)?.path||Je(yt(u))||null}),[ze,Pe,He]),gt=c.useMemo(()=>{const u=new Map(Xe.map(H=>[H.id,H])),A=H=>({session:H,children:(Ue.get(H.id)??[]).map(A),worktree:null}),W=new Map;for(const H of $e.runs.values())W.set(H.key,H.memberIds.flatMap(se=>{const me=u.get(se);return me?[A(me)]:[]}));return W},[Ue,$e,Xe]),Vt=c.useMemo(()=>({key:Ys,label:"",path:"",worktree:null,space:null,sessions:ks(Wt,d,b)}),[d,Wt,b]),ar=c.useMemo(()=>new Set(Vt.sessions.filter(u=>vr(d,yt(u)||null,u.id)).map(u=>u.id)),[Vt,d]),Ut=c.useMemo(()=>({key:Er,label:"",path:"",worktree:null,space:null,sessions:_t.size>0?ks(Xe.filter(u=>_t.has(u.id)),d,b):[]}),[d,_t,b,Xe]),Ls=c.useMemo(()=>({key:ko,label:"",path:"",worktree:null,space:null,sessions:It.size>0?ks(Xe.filter(u=>It.has(u.id)&&!_t.has(u.id)),d,b):[]}),[d,_t,b,Xe,It]),Gt=`${Ys}::${Ys}`,lr=c.useMemo(()=>Wt.filter(u=>!ut(u)).length,[Wt]),We=xe.trim().toLowerCase(),Me=c.useRef(null);c.useEffect(()=>{if(!n)return;const u=window.requestAnimationFrame(()=>{const A=Me.current;if(!A)return;(A.querySelector('[data-active-session="true"]')??A.querySelector('[data-active-project="true"]'))?.scrollIntoView({block:"center"})});return()=>window.cancelAnimationFrame(u)},[n]);const Nt=c.useMemo(()=>{const u=Eu(Pe,F,W=>W.id,He.sessionsByProject).map(W=>({project:W,buckets:[],isActive:W.id===S})),A=(W,H,se,me=null)=>{const Re=Je(H)||W.project.path,tt=Re||"__root__";let st=W.buckets.find(Hs=>Hs.key===tt);return st||(st={key:tt,label:(me?me.name||i("sessions.sidebar.grouping.spaceUnnamed"):null)||se?.branch||Cr(Re),path:Re,worktree:se,space:me,sessions:[]},W.buckets.push(st)),st};for(const W of u){A(W,W.project.path,null);for(const H of W.project.worktrees)A(W,H.path,H);for(const H of wt)H.directory&&Je(H.projectDirectory)===Je(W.project.path)&&A(W,H.directory,null,H)}for(const W of ze){const H=He.bySessionId.get(W.id);if(!H)continue;const se=u.find(st=>st.project.id===H.projectId);if(!se)continue;const me=Ar(se.project,H.scopeDirectory),Re=H.kind==="space"&&H.spaceId?gs.get(H.spaceId)??null:null;(Re?A(se,H.scopeDirectory,null,Re):me&&!$e.runKeyBySessionId.has(W.id)?A(se,me.path,me):A(se,se.project.path,null)).sessions.push(W)}for(const W of u)for(const H of W.buckets)H.sessions=ks(H.sessions,d,b);return u},[S,d,F,Pe,$e,ze,b,He,wt,gs,i]),Fs=Je(C),$s=u=>u.isActive?Fs===u.project.path?u.project.path:u.project.worktrees.find(W=>vp(Fs,W.path))?.path??u.project.path:null,bt=u=>$[u.project.id]??!0,yn=(u,A)=>A.sessions.length===0||(J[`${u.project.id}::${A.key}`]??!0);c.useEffect(()=>{if(!(!f||!p))for(const u of Nt)for(const A of u.buckets){const W=`${u.project.id}::${A.key}`;A.sessions.length===0&&J[W]===!1&&oe(W,!0)}},[p,f,Nt,oe,J]);const Ws=u=>{ht(A=>{if(!A.has(u))return A;const W=new Map(A);return W.delete(u),W})},cr=u=>{ht(A=>{let W=!1;const H=new Map(A),se=`${u}::`;for(const me of H.keys())me.startsWith(se)&&(H.delete(me),W=!0);return W?H:A})},vn=(u,A,W)=>{ht(H=>{const se=new Map(H);return se.set(u,A+W),se})},Vs=(u,A,W,H)=>{const se=H?.pageSize??sn,me=W===null?Ir:Xn(W),Re=H?.alwaysVisibleIds,tt=new Set(A.sessions.map(je=>je.id)),st=new Map;for(const je of A.sessions){const nt=ut(je);if(nt&&tt.has(nt)){const Ct=st.get(nt)??[];Ct.push(je),st.set(nt,Ct)}}const Hs=A.sessions.filter(je=>{const nt=ut(je);return!nt||!tt.has(nt)}),Mi=new Set,gr=Hs.flatMap(je=>{const nt=$e.runKeyBySessionId.get(je.id),Ct=nt?$e.runs.get(nt):void 0;return Ct?Mi.has(Ct.key)?[]:(Mi.add(Ct.key),[{kind:"run",run:Ct}]):[{kind:"session",session:je}]}),_i=je=>je.kind==="session"&&!!Re?.has(je.session.id),al=Re?gr.filter(_i):[],br=Re?gr.filter(je=>!_i(je)):gr,ll=bn.get(u)??se,xr=br.slice(0,ll),cl=[...al,...xr],Oi=br.length-xr.length,ul=br.length>se&&Oi===0,zi=(je,nt)=>{const Ct=st.get(je.id)??[],yr=Ct.length>0,Bi=nt!==null&&!!ve[je.id];return t.jsxs(c.Fragment,{children:[t.jsx(Co,{session:je,active:R===je.id,indent:Ir,treeDepth:nt??void 0,statusOnRight:nt===null,hasChildren:yr,expanded:Bi,onToggleChildren:yr?()=>we(je.id):void 0,onSelect:()=>bs(je),revealed:Te===je.id,onRevealedChange:Js=>xs(je.id,Js),confirmingDelete:Se===je.id,onArchive:()=>{qt(je)},onRequestDelete:()=>K(je.id),onConfirmDelete:()=>{jn(je)},renaming:be===je.id,onRequestRename:()=>Qe(je.id),onSubmitRename:Js=>{kn(je.id,Js)},onCancelRename:()=>ie(null),work:jt(je),pin:ur(je),descendantIdsOf:Et}),yr&&Bi&&nt!==null?Ct.map(Js=>zi(Js,nt+1)):null]},je.id)};return t.jsxs("div",{children:[cl.map(je=>je.kind==="run"?t.jsx(kp,{run:je.run,laneNodes:gt.get(je.run.key)??Ro,depth:W??0},`run:${je.run.key}`):zi(je.session,W)),Oi>0?t.jsx(Eo,{indent:me,onClick:()=>vn(u,xr.length,sn)}):null,ul?t.jsx(Io,{indent:me,onClick:()=>Ws(u)}):null]})},rt=(u,A)=>{ae(u,!A),cr(u)},Us=(u,A,W)=>{oe(`${u}::${A}`,!W),Ws(`${u}::${A}`)},bs=u=>{const A=yt(u)||null,W=He.bySessionId.get(u.id),H=W?Pe.find(se=>se.id===W.projectId)??null:null;if(H){O(H.id),ae(H.id,!0);const se=Ar(H,W?.scopeDirectory??"");se&&oe(`${H.id}::${Je(se.path)}`,!0)}T(u.id,A),e(!1)},xs=(u,A)=>{Ce(A?u:null),K(null),pe(null),De(null)},Ot=(u,A)=>{pe(A?u:null),De(null),Ce(null),K(null)},Kt=(u,A)=>(Ce(null),K(null),Du(u,A,Mu(A.id,Dn(Ue,A.id),u==="delete"),{archiveSession:P,archiveSessions:k,deleteSession:j,deleteSessions:y},i)),qt=u=>Kt("archive",u),lt=async(u,A)=>{try{await ac(u.id,yt(u)||null,A?"done":"open")}catch{ce.error(i("sessions.sidebar.session.work.updateFailed"))}},jt=u=>{if(!qe||ut(u)||In(yt(u)))return;const A=It.has(u.id);return{inWork:A,onToggle:()=>{lt(u,A)}}},ys=u=>vr(d,yt(u)||null,u.id),wn=u=>{const A=yt(u);A&&ge({directory:A,sessionId:u.id})},ur=u=>{if(!(ut(u)||!yt(u)))return{pinned:ys(u),onToggle:()=>wn(u)}},jn=u=>Kt("delete",u),Qe=u=>{Ce(null),K(null),ie(u)},kn=async(u,A)=>{ie(null);try{await I(u,A)}catch{ce.error(i("mobile.sessions.renameError"))}},dr=()=>{D(),e(!1)},Ht=u=>{ot(u),O(u),gn(!0)},fr=ii(Ds(ai,{activationConstraint:{distance:8}}),Ds(oi,{coordinateGetter:mi})),mr=u=>{_(u),Xs({sidebarProjectSortOrder:u}),u!=="manual"&&$t(!1)},vs=u=>{B(u),Xs({sidebarViewMode:u}),u==="timeline"&&$t(!1)},At=()=>{const u=!V;X(u),Xs({sidebarShowWorkSection:u})},Jt=()=>{const u=!Z;de(u),Xs({sidebarShowPinnedSection:u})},Yt=()=>{const u=!re;Q(u),Xs({sidebarDetailedZoneRows:u})},Pt=(u,A,W,H)=>t.jsxs(Qs,{onClick:H,className:tn,children:[t.jsx("span",{children:i(A)}),W?t.jsx(Y,{name:"check",className:"size-4 text-primary"}):null]},u),Gs=u=>{const{active:A,over:W}=u;if(!W||A.id===W.id)return;const H=Pe.findIndex(me=>me.id===A.id),se=Pe.findIndex(me=>me.id===W.id);H<0||se<0||E(H,se)},Sn=u=>{ps(A=>{const W=new Set(A);return W.has(u)?W.delete(u):W.add(u),W})},pr=c.useCallback(u=>{const A=yt(u);if(In(A))return i("mobile.sessions.section.chats");const W=He.bySessionId.get(u.id),H=W?Pe.find(Re=>Re.id===W.projectId)??null:null;if(!H)return Cr(A)||A;const se=W?.kind==="space"&&W.spaceId?gs.get(W.spaceId):void 0;if(se)return`${H.label} · ${se.name||i("sessions.sidebar.grouping.spaceUnnamed")}`;const me=Ar(H,W?.scopeDirectory??"");return me?.branch?`${H.label} · ${me.branch}`:H.label},[Pe,He,gs,i]),hr=u=>{L(u.id),e(!1)},Ks=u=>{O(u.id),D({selectedProjectId:u.id,directoryOverride:u.path}),e(!1)},Xt=c.useMemo(()=>We?Nt.filter(u=>ua([u.project.label,u.project.path],We)?!0:u.buckets.some(A=>A.sessions.some(W=>Pr(W,u.project.label,We)))):Nt,[We,Nt]),ws=c.useMemo(()=>We?ks(Xe.filter(u=>{if(ut(u))return!1;const A=He.bySessionId.get(u.id),W=A?Pe.find(H=>H.id===A.projectId)??null:null;return Pr(u,W?.label??"",We)}),d,b):[],[We,d,Pe,b,He,Xe]),Qt=c.useMemo(()=>We?nc(Pe,We,u=>[u.label,u.path]):[],[We,Pe]),js=G==="timeline"&&!We&&!at,Zt=!We&&!at,Nn=G!=="timeline"&&!re,es=js||Zt&&(Ls.sessions.length>0||Ut.sessions.length>0),qs=es;c.useEffect(()=>{if(!(!qs||!a))for(const u of Pe){const A=Je(u.path);A&&rc(()=>o(A,a))}},[o,a,qs,Pe]);const ts=c.useMemo(()=>{const u=new Map;if(!es)return u;const A=Iu({sessions:ze,projects:Pe.map(W=>({id:W.id,normalizedPath:W.path,label:W.label})),ownerBySessionId:He.bySessionId,availableWorktreesByProject:new Map(Pe.map(W=>[W.path,W.worktrees])),gitBranches:ee,homeDirectory:null,hideBranchMatchingProjectLabel:!1,spaceLabelById:xn});for(const W of ze){if(ut(W))continue;const H=A.get(W.id),se=H?Pe.find(me=>me.id===H.projectId):null;!se||!H||u.set(W.id,{project:se,branch:H.branchLabel,inSpace:H.inSpace})}return u},[ee,es,ze,Pe,He,xn]),zt=c.useCallback(u=>{const A=new Set;return u.flatMap(W=>{const H=ts.get(W.id);if(!H)return[];const se=$e.runKeyBySessionId.get(W.id),me=se?$e.runs.get(se):void 0;return me?A.has(me.key)?[]:(A.add(me.key),[{kind:"run",run:me,laneNodes:gt.get(me.key)??Ro,project:H.project}]):[{kind:"session",session:W,project:H.project,branch:H.branch,inSpace:H.inSpace}]})},[$e,gt,ts]),w=c.useMemo(()=>{const u=new Map;if(!js)return u;const A=ks(ze.filter(W=>!ut(W)&&ts.has(W.id)),d,b);for(const W of zt(A)){const H=u.get(W.project.id);H?H.push(W):u.set(W.project.id,[W])}return u},[d,ze,b,js,ts,zt]),U=c.useMemo(()=>Zt?zt(Ls.sessions.filter(u=>!ut(u))):[],[Zt,zt,Ls]),le=c.useMemo(()=>Zt?zt(Ut.sessions.filter(u=>!ut(u))):[],[Zt,zt,Ut]),ke=(u,A,W,H)=>{const se=yn(u,A),me=A.sessions.length===0,Re=H===A.path;return t.jsxs(t.Fragment,{children:[t.jsx(Yn,{actionsWidth:A.space?96:48,revealed:he===`wt:${A.key}`,onRevealedChange:tt=>Ot(`wt:${A.key}`,tt),actions:A.space?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:he===`wt:${A.key}`?0:-1,className:"flex flex-1 items-center justify-center text-foreground transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":i("spaces.group.access.giveAria",{label:A.label}),onClick:()=>{pe(null),A.space&&Fi.getState().openAccessDialog(A.space.id)},style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"key",className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:he===`wt:${A.key}`?0:-1,className:"flex flex-1 items-center justify-center text-foreground transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":i("spaces.actions.menuAria",{label:A.label}),onClick:()=>{pe(null),A.space&&Fi.getState().openActionsSheet(A.space.id)},style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"more-2",className:"size-[18px]"})})]}):A.worktree&&!W?t.jsx("button",{type:"button",tabIndex:he===`wt:${A.key}`?0:-1,className:"flex flex-1 items-center justify-center text-[var(--status-error)] transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive","aria-label":i("mobile.projectEdit.deleteWorktreeAria",{label:A.label}),onClick:()=>{pe(null),A.worktree&&Ge({project:u.project,worktree:A.worktree})},style:{touchAction:"manipulation"},children:t.jsx(Wn,{className:"size-[18px]"})}):null,children:t.jsxs("button",{type:"button",className:"flex min-h-10 w-full items-center gap-0.5 py-1 pe-3 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(he){Ot(he,!1);return}me||Us(u.project.id,A.key,se)},"aria-expanded":me?void 0:se,"aria-label":me?A.label:se?i("sessions.sidebar.group.collapseAria",{label:A.label}):i("sessions.sidebar.group.expandAria",{label:A.label}),style:{paddingInlineStart:Ci(0),touchAction:"manipulation"},children:[me?t.jsx("span",{"aria-hidden":!0,className:"size-3.5 shrink-0"}):t.jsx(xa,{expanded:se}),W?t.jsx("span",{className:"inline-flex size-3.5 shrink-0 items-center justify-center text-muted-foreground",role:"status","aria-label":i("sessions.sidebar.group.worktreeRemoving"),children:t.jsx(Y,{name:"loader-4",className:"size-3.5 animate-spin"})}):t.jsx(Y,{name:A.space?"box-3":"git-branch",className:te("mx-px size-3 shrink-0",Re?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground",children:A.label}),Re?t.jsx(jp,{ariaLabel:i("mobile.sessions.activeWorktreeAria")}):null]})}),A.space?t.jsx("div",{className:"pb-1 pe-3",style:{paddingInlineStart:Xn(1)},children:t.jsx(Tu,{spaceId:A.space.id})}):null]})},_e=(u,A,W)=>{const H=bn.get(u)??sn,se=A.slice(0,H),me=A.length-se.length;return t.jsxs(t.Fragment,{children:[t.jsx(wo,{entries:se,showProject:W,handlers:Le}),me>0?t.jsx(Eo,{indent:fn,onClick:()=>vn(u,se.length,sn)}):A.length>sn?t.jsx(Io,{indent:fn,onClick:()=>Ws(u)}):null]})},xt=(u,A,W,H)=>{if(H.length===0)return null;const se=$[u]??!0;return t.jsxs("section",{children:[t.jsxs("button",{type:"button",className:"flex min-h-12 w-full min-w-0 items-center gap-2 px-3 py-1.5 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(he){Ot(he,!1);return}rt(u,se)},"aria-expanded":se,"aria-label":se?i("sessions.sidebar.group.collapseAria",{label:W}):i("sessions.sidebar.group.expandAria",{label:W}),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(Y,{name:A,className:"size-5"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-header font-semibold text-foreground",children:W}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:H.length})]}),t.jsx(zn,{open:se,children:()=>t.jsx("div",{className:"pb-2",children:t.jsx(wo,{entries:H,showProject:!0,compact:Nn,pinMarker:u!==Er,handlers:Le})})})]})},Le={currentSessionId:R,revealedSessionId:Te,confirmingDeleteSessionId:Se,renamingSessionId:be,onSelect:bs,onRevealedChange:xs,onArchive:u=>{qt(u)},onRequestDelete:K,onConfirmDelete:u=>{jn(u)},onRequestRename:Qe,onSubmitRename:(u,A)=>{kn(u,A)},onCancelRename:()=>ie(null),onToggleWork:qe?(u,A)=>{lt(u,A)}:void 0,isPinned:ys,onTogglePin:wn,descendantIdsOf:Et},Ii=We&&ws.length===0&&Qt.length===0,Cn=!We&&Pe.length>1&&F==="manual",Rn=!at&&!We&&Pe.length>0?t.jsxs(_r,{children:[t.jsx(Or,{asChild:!0,children:t.jsx(Ee,{type:"button",variant:"chip",size:"sm","aria-label":i("sessions.sidebar.header.displayMode.label"),title:i("sessions.sidebar.header.displayMode.label"),style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"equalizer-2",className:"size-4"})})}),t.jsxs(zr,{align:"end",className:"w-64",children:[t.jsx(Hi,{children:i("mobile.sessions.viewMode.label")}),bp.map(([u,A])=>Pt(u,A,G===u,()=>vs(u))),G==="timeline"?null:t.jsxs(t.Fragment,{children:[t.jsx(wr,{}),t.jsx(Hi,{children:i("sessions.sidebar.header.actions.sortProjects")}),gp.map(([u,A])=>Pt(u,A,F===u,()=>mr(u)))]}),t.jsx(wr,{}),Pt("pinned","sessions.sidebar.header.displayMode.showPinned",Z,Jt),qe?Pt("work","sessions.sidebar.header.displayMode.showWork",V,At):null,G==="timeline"?null:Pt("detailed","sessions.sidebar.header.displayMode.detailedZoneRows",re,Yt),Cn?t.jsxs(t.Fragment,{children:[t.jsx(wr,{}),t.jsx(Qs,{onClick:()=>$t(!0),className:tn,children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Y,{name:"drag-move-2",className:"size-4"}),i("mobile.sessions.editOrder")]})})]}):null]})]}):null,Ai=at?t.jsx(Ee,{type:"button",variant:"chip",size:"sm","aria-label":i("mobile.sessions.doneEditing"),"aria-pressed":!0,onClick:()=>$t(!1),style:{touchAction:"manipulation"},children:t.jsx(wa,{className:"size-4"})}):null,Pi=!at&&Pe.length>0?t.jsxs(Ee,{type:"button",variant:"default",size:"sm","aria-label":i("mobile.sessions.newChat"),onClick:dr,style:{touchAction:"manipulation"},children:[t.jsx(Pd,{className:"size-4"}),i("mobile.sessions.newChat")]}):null,Ti=at?null:t.jsx(Ee,{type:"button",variant:"chip",size:"sm","aria-label":i("sessions.sidebar.header.actions.addProject"),title:i("sessions.sidebar.header.actions.addProject"),onClick:()=>ds(!0),style:{touchAction:"manipulation"},children:t.jsx(Qi,{className:"size-4"})}),En=Pi||Ti||Rn||Ai?t.jsxs(t.Fragment,{children:[Ti,Rn,Ai,Pi]}):null,Di=t.jsxs("div",{ref:Me,className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs(er,{ref:Ke,className:"min-h-0 flex-1 overflow-y-auto pb-4",children:[t.jsx("div",{className:te("px-4 pb-2 pt-1",at&&"hidden"),children:t.jsx(Au,{value:xe,onSearch:fe,active:n||s==="sidebar",mobile:!0,placeholder:i("mobile.sessions.search.placeholder"),clearLabel:i("mobile.sessions.clearSearchAria")})}),Pe.length===0&&hs.length===0?t.jsx(Do,{title:i("mobile.sessions.empty.noProjectsTitle"),description:i("mobile.sessions.empty.noProjectsDescription"),action:t.jsxs("button",{type:"button",className:"flex items-center justify-center gap-2 rounded-2xl bg-primary px-5 py-3 typography-ui-label text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>ds(!0),children:[t.jsx(Qi,{className:"size-4"}),i("sessions.sidebar.header.actions.addProject")]})}):Ii?t.jsx(Do,{title:i("mobile.sessions.empty.searchTitle"),description:i("mobile.sessions.empty.searchDescription")}):We&&!at?t.jsxs("div",{className:"flex flex-col gap-3 px-3 pt-2",children:[ws.length>0?t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center justify-between px-1 pb-1.5",children:[t.jsx("span",{className:"typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:i("mobile.sessions.search.section.sessions")}),t.jsx("span",{className:"typography-micro text-muted-foreground tabular-nums",children:ws.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:ws.map((u,A)=>t.jsx("div",{className:te(A>0&&"border-t border-border/70"),children:t.jsx(Co,{session:u,active:R===u.id,indent:12,contextLabel:pr(u),onSelect:()=>bs(u)})},u.id))})]}):null,Qt.length>0?t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center justify-between px-1 pb-1.5",children:[t.jsx("span",{className:"typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:i("mobile.sessions.search.section.projects")}),t.jsx("span",{className:"typography-micro text-muted-foreground tabular-nums",children:Qt.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:Qt.map((u,A)=>t.jsxs("div",{className:te("flex items-center",A>0&&"border-t border-border/70"),children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-3 px-3 py-1.5 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>hr(u),style:{touchAction:"manipulation"},children:[t.jsx(Jn,{project:u}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:u.label})]}),u.isGitRepo?t.jsx(So,{onClick:()=>Ht(u.id)}):null,t.jsx(No,{className:"me-2",label:i("mobile.sessions.newSessionInProjectAria",{label:u.label}),onClick:()=>Ks(u)})]},u.id))})]}):null]}):at?t.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2",children:[t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:i("mobile.sessions.editOrderHint")}),t.jsx(li,{sensors:fr,collisionDetection:ci,onDragEnd:Gs,children:t.jsx(ui,{items:Pe.map(u=>u.id),strategy:di,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:Pe.map(u=>t.jsx(Np,{project:u,expanded:or.has(u.id),onToggleExpanded:()=>Sn(u.id),onReorderWorktrees:A=>ne(u.id,A)},u.id))})})})]}):t.jsxs("div",{className:"flex flex-col",children:[(()=>{const u=$[Ys]??!0,A=i("mobile.sessions.section.chats");return t.jsxs("section",{children:[t.jsx("div",{className:"flex min-h-12 w-full items-center",children:t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(he){Ot(he,!1);return}rt(Ys,u)},"aria-expanded":u,"aria-label":u?i("sessions.sidebar.group.collapseAria",{label:A}):i("sessions.sidebar.group.expandAria",{label:A}),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(Y,{name:"chat-4",className:"size-5"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-header font-semibold text-foreground",children:A}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:lr})]})}),t.jsx(zn,{open:u,children:()=>t.jsx("div",{className:"pb-2",children:Vt.sessions.length>0?Vs(Gt,Vt,null,{pageSize:xp,alwaysVisibleIds:ar}):t.jsx("p",{className:"px-3 pb-1 typography-micro text-muted-foreground",style:{paddingInlineStart:Ir},children:i("sessions.sidebar.activity.chatsEmpty")})})})]})})(),xt(Er,"pushpin",i("sessions.sidebar.activity.pinnedTitle"),le),xt(ko,"eye",i("sessions.sidebar.work.title"),U),Xt.map(u=>{const A=bt(u),W=We?u.buckets.filter(se=>se.sessions.some(me=>Pr(me,u.project.label,We))):u.buckets,H=$s(u);return t.jsxs("section",{children:[t.jsx(Yn,{actionsWidth:96,revealed:he===`project:${u.project.id}`,onRevealedChange:se=>Ot(`project:${u.project.id}`,se),actions:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:he===`project:${u.project.id}`?0:-1,className:te("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",Oe===u.project.id?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80"),"aria-label":Oe===u.project.id?i("mobile.sessions.confirmRemoveProjectAria",{label:u.project.label}):i("mobile.sessions.removeProjectAria",{label:u.project.label}),onClick:()=>{if(Oe===u.project.id){pe(null),De(null),N(u.project.id),ce.success(i("mobile.sessions.toast.projectRemoved",{label:u.project.label}));return}De(u.project.id)},style:{touchAction:"manipulation"},children:t.jsx(Wn,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:he===`project:${u.project.id}`?0:-1,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":i("mobile.sessions.editProjectAria",{label:u.project.label}),onClick:()=>{pe(null),Ae(u.project.id)},style:{touchAction:"manipulation"},children:t.jsx(va,{className:"size-[18px]"})})]}),children:t.jsxs("div",{"data-active-project":u.isActive||void 0,className:"flex min-h-12 w-full items-center",children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(he){Ot(he,!1);return}rt(u.project.id,A)},"aria-expanded":A,"aria-label":A?i("sessions.sidebar.group.collapseAria",{label:u.project.label}):i("sessions.sidebar.group.expandAria",{label:u.project.label}),style:{touchAction:"manipulation"},children:[t.jsx(Jn,{project:u.project}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-header font-semibold text-foreground",children:u.project.label})]}),u.project.isGitRepo?t.jsx(So,{onClick:()=>Ht(u.project.id)}):null,t.jsx(No,{className:"me-2",label:i("mobile.sessions.newSessionInProjectAria",{label:u.project.label}),onClick:()=>Ks(u.project)})]})}),t.jsx(zn,{open:A,children:()=>js?t.jsxs("div",{className:"pb-2",children:[(p?W:[]).filter(se=>se.space&&se.sessions.length===0).map(se=>t.jsx("div",{className:"mt-1.5",children:ke(u,se,!1,H)},se.key)),_e(`${u.project.id}::timeline`,w.get(u.project.id)??[],!1)]}):t.jsx("div",{className:"pb-2",children:(()=>{const se=W.find(Re=>Re.worktree===null&&Re.space===null),me=W.filter(Re=>Re!==se);return t.jsxs(t.Fragment,{children:[se&&se.sessions.length>0?Vs(`${u.project.id}::${se.key}`,se,0):null,me.map(Re=>{const tt=yn(u,Re);return t.jsx(wp,{path:Re.worktree?.path??null,children:st=>t.jsxs("div",{className:te("mt-1.5",st&&"opacity-60"),"aria-busy":st||void 0,children:[ke(u,Re,st,H),t.jsx(zn,{open:tt,children:()=>Vs(`${u.project.id}::${Re.key}`,Re,1)})]})},Re.key)})]})})()})})]},u.project.id)})]})]}),r?t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-border/70 px-2 pt-1.5",style:{paddingBottom:"calc(0.375rem + var(--oc-safe-area-bottom, 0px))"},children:[r.instanceLabel&&r.onOpenInstances?t.jsxs(Ee,{type:"button",variant:"info",size:"lg",className:"min-w-0 shrink justify-start",onClick:r.onOpenInstances,"aria-label":i("mobile.menu.instances"),style:{touchAction:"manipulation"},children:[t.jsx(Y,{name:"server",className:"size-[18px]"}),t.jsx("span",{className:"block min-w-0 truncate",children:r.instanceLabel})]}):t.jsx("div",{className:"min-w-0 flex-1"}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[r.onOpenUpdate?t.jsxs(Ee,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:r.onOpenUpdate,"aria-label":i("mobile.menu.update"),title:i("mobile.menu.update"),style:{touchAction:"manipulation"},children:[t.jsx(Y,{name:"download",className:"size-5"}),t.jsx("span",{className:"absolute inset-e-2 top-2 inline-flex size-2 rounded-full bg-primary","aria-hidden":!0})]}):null,t.jsx(Ee,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:r.onOpenSourceBoard,"aria-label":i("sourceBoard.title"),title:i("sourceBoard.title"),style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"todo",className:"size-5"})}),t.jsx(Ee,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:r.onOpenSettings,"aria-label":i("mobile.menu.settings"),title:i("mobile.menu.settings"),style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"settings-3",className:"size-5"})}),t.jsxs(_r,{children:[t.jsx(Or,{asChild:!0,children:t.jsx(Ee,{type:"button",variant:"default",size:"lg",className:"w-10 px-0","aria-label":i("mobile.sessions.footer.more"),title:i("mobile.sessions.footer.more"),style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"more",className:"size-5"})})}),t.jsxs(zr,{side:"top",align:"end",className:"w-56",children:[t.jsx(Qs,{onClick:r.onOpenScheduled,className:tn,children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Y,{name:"calendar-schedule",className:"size-4"}),i("sessions.sidebar.header.actions.scheduledTasks")]})}),t.jsx(Qs,{onClick:r.onOpenArchive,className:tn,children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Y,{name:"archive",className:"size-4"}),i("sessions.sidebar.nav.archive")]})}),t.jsx(Qs,{onClick:r.onOpenUsage,className:tn,children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Y,{name:"bar-chart",className:"size-4"}),i("usageStats.openAction")]})})]})]})]})]}):null,t.jsx(Pu,{open:hn,onOpenChange:ds}),t.jsx(ic,{open:rr,onOpenChange:u=>{gn(u),u||ot(null)},project:(()=>{const u=Pe.find(A=>A.id===fs);return u?{id:u.id,path:u.path}:void 0})(),onWorktreeCreated:u=>{D({selectedProjectId:fs,directoryOverride:u,preserveDirectoryOverride:!0}),e(!1)}}),t.jsx(Jm,{open:Ne!==null,project:Pe.find(u=>u.id===Ne)??null,onClose:()=>Ae(null),onWorktreesChanged:()=>Lt(u=>u+1)}),Fe?t.jsx(qa,{open:!0,project:{id:Fe.project.id,path:Fe.project.path},worktree:Fe.worktree,onClose:()=>Ge(null),onDeleted:()=>Lt(u=>u+1)}):null]});return s==="sidebar"?n?t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsx("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center justify-end gap-2 border-b border-border/70 px-4",children:En?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:En}):null}),Di]}):null:t.jsxs(Ep,{open:n,onClose:()=>e(!1),onSwipeClose:()=>{if(Te||he){Ce(null),pe(null),K(null),De(null);return}e(!1)},ariaLabel:i("mobile.sessions.sheet.title"),children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",children:[t.jsx("button",{type:"button",className:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":i("mobile.surface.closeAria"),onClick:()=>e(!1),style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"close",className:"size-5"})}),En?t.jsx("div",{className:"ms-auto flex shrink-0 items-center gap-2",children:En}):null]}),Di]})},Po="mobile-surface-root",Cp=16,To=320,Rp="cubic-bezier(0.22, 1, 0.36, 1)",Ep=({open:n,onClose:e,onSwipeClose:s,ariaLabel:r,children:i})=>{const{direction:a}=ye(),o=c.useRef(null),l=c.useRef(null),[m,p]=c.useState(!1),[f,g]=c.useState(n),d=c.useRef(e);c.useEffect(()=>{d.current=e},[e]);const h=c.useRef(s);c.useEffect(()=>{h.current=s},[s]);const b=()=>(h.current??d.current)();if(Ni(l,{enabled:n,...a==="rtl"?{onLeftEdgeSwipe:b}:{onRightEdgeSwipe:b}}),typeof document<"u"&&!o.current){let v=document.getElementById(Po);v||(v=document.createElement("div"),v.id=Po,document.body.appendChild(v)),o.current=v}return c.useEffect(()=>{if(n){g(!0);const x=window.setTimeout(()=>p(!0),Cp);return()=>window.clearTimeout(x)}p(!1);const v=window.setTimeout(()=>g(!1),To+40);return()=>window.clearTimeout(v)},[n]),c.useEffect(()=>{if(!n)return;const v=document.body.style.overflow;document.body.style.overflow="hidden";const x=S=>{S.key==="Escape"&&!ei(S)&&d.current()};return document.addEventListener("keydown",x),()=>{document.body.style.overflow=v,document.removeEventListener("keydown",x)}},[n]),o.current?Ps.createPortal(t.jsx("section",{ref:l,role:"dialog","aria-modal":"true","aria-label":r,"aria-hidden":!n,className:"oc-keyboard-inset-surface fixed inset-0 z-50 flex flex-col bg-background text-foreground",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:m?"none":a==="rtl"?"translateX(100%)":"translateX(-100%)",transition:`transform ${To}ms ${Rp}`,visibility:f?"visible":"hidden",pointerEvents:n?"auto":"none"},children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:i})}),o.current):null},Do=n=>{const e=ue.c(10),{title:s,description:r,action:i}=n;let a;e[0]!==s?(a=t.jsx("p",{className:"typography-ui-label text-foreground",children:s}),e[0]=s,e[1]=a):a=e[1];let o;e[2]!==r?(o=r?t.jsx("p",{className:"typography-meta text-muted-foreground",children:r}):null,e[2]=r,e[3]=o):o=e[3];let l;e[4]!==i?(l=i?t.jsx("div",{className:"pt-2",children:i}):null,e[4]=i,e[5]=l):l=e[5];let m;return e[6]!==a||e[7]!==o||e[8]!==l?(m=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[a,o,l]}),e[6]=a,e[7]=o,e[8]=l,e[9]=m):m=e[9],m};function Ip(n){return Je(n.path)}function Ap(n){return Je(n.path)}function Pp(n){return t.jsx(Sp,{worktree:n},Je(n.path))}const Tp=6e4,Dp=(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}},Mp=n=>{switch(n?.status.status){case"connected":return"success";case"failed":return"error";case"needs_auth":return"warning";default:return"default"}},_p=({active:n,className:e,headerAction:s,listClassName:r,hideHeader:i=!1,mobileListDensity:a=!1})=>{const{t:o}=ye(),m=Mt(k=>k.currentDirectory)??null,p=Ss(k=>k.getStatusForDirectory(m)),f=Ss(k=>k.refresh),g=Ss(k=>k.ensureFresh),d=Ss(k=>k.connect),h=Ss(k=>k.disconnect),b=Is(k=>k.mcpServers),v=Is(k=>k.loadMcpConfigs),[x,S]=c.useState(!1),[C,R]=c.useState(null);c.useEffect(()=>{v({force:!0})},[v]),c.useEffect(()=>{n&&Promise.all([g({directory:m,silent:!0,maxAgeMs:Tp}),v({force:!0})])},[n,g,m,v]);const T=c.useMemo(()=>{const k=new Set(Object.keys(p));for(const j of b)j?.name&&k.add(j.name);return Array.from(k).sort((j,y)=>j.localeCompare(y))},[b,p]),P=c.useCallback(k=>{if(k?.preventDefault(),x)return;S(!0);const j=new Promise(y=>setTimeout(y,500));Promise.all([f({directory:m}),j]).finally(()=>{S(!1)})},[x,f,m]);return t.jsxs("div",{className:te("w-full",e),children:[i?null:t.jsx("div",{className:"border-b border-[var(--interactive-border)]",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5",children:[t.jsxs("div",{className:"min-w-0 flex items-baseline gap-2",children:[t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:o("mcpDropdown.title")}),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:x,onClick:P,"aria-label":o("mcpDropdown.actions.refreshAria"),children:t.jsx(Y,{name:"refresh",className:te("h-4 w-4",x&&"animate-spin")})})]})]})}),t.jsx("div",{className:te("max-h-64 overflow-y-auto",a?"space-y-1 py-3":"px-3 py-2.5",r),children:t.jsxs("div",{className:te(!a&&T.length>0&&"p-1.5"),children:[T.map(k=>{const j=p[k],y=Mp(j),I=j?.status.status==="connected",D=C===k,L=Dp(j,o);return t.jsxs("div",{className:te("flex items-center justify-between rounded-lg hover:bg-interactive-hover",a?"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(lc,{children:[t.jsx(cc,{asChild:!0,children:t.jsx("span",{className:te("rounded-full flex-shrink-0",a?"h-2.5 w-2.5":"h-2 w-2",y==="success"&&"bg-status-success",y==="error"&&"bg-status-error",y==="warning"&&"bg-status-warning",y==="default"&&"bg-muted-foreground/40"),"aria-label":L})}),t.jsx(uc,{side:"left",children:t.jsx("p",{children:L})})]}),t.jsx("span",{className:te("truncate",a?"text-[17px] leading-6 font-medium":"typography-ui-label"),children:k})]})}),t.jsx(dc,{checked:I,disabled:D,className:"data-[checked]:bg-status-info",onCheckedChange:async O=>{R(k);try{O?await d(k,m):await h(k,m)}catch(E){Fr.error(E instanceof Error?E.message:o("mcpDropdown.status.unknownError"))}finally{R(null)}}})]},k)}),T.length===0&&t.jsx("div",{className:"px-4 py-5 typography-ui-label text-muted-foreground text-center",children:o("mcpDropdown.empty.configureInConfig")})]})})]})};async function Op(n,e,s=Number.POSITIVE_INFINITY){const r=Array.from(new Set(n)),i=[];return await fc(r,s,async a=>{try{await e(a)}catch(o){i.push({path:a,error:o instanceof Error?o:null})}}),{paths:r,failures:i}}const zp=async(n,e,s)=>{const{targetBranch:r,directory:i,sourceBranch:a,git:o,publishChooser:l,toast:m,t:p}=s;if(!(!r||!i)){if(await o.createGitCommit(i,n,{addAll:!0}),e)try{await(await l.prepare("push"))()}catch{m.error(p("gitView.dirtySwitch.pushFailed")),await s.refreshStatusAndBranches(),s.closeDialog();return}m.success(a?e?p("gitView.publish.succeeded"):p("gitView.dirtySwitch.committedNotPushed",{branch:a}):p("gitView.toast.commitCreated")),await s.refreshStatusAndBranches(),s.closeDialog(),await s.performCheckout(r)}},Mo={status:"loading"},Bp=1e6,ns={type:"list"},Lp=2,Fp=n=>{const e=n.index?.trim();return!!(e&&e!=="?")},$p=n=>{const e=n.working_dir?.trim(),s=n.index?.trim();return!!(e||s==="?")},_o=(n,e)=>e?`${n}\0staged`:n,Wp=n=>{const e=ue.c(6),s=pn(ti()??null)??"",r=n.visible??!0;let i;e[0]!==r?(i={enabled:r,recheckOnOpen:!0},e[0]=r,e[1]=i):i=e[1];const a=mc(s||null,i);let o;return e[2]!==n||e[3]!==a||e[4]!==s?(o=t.jsx(Vp,{...n,rootDirectory:s,repository:a}),e[2]=n,e[3]=a,e[4]=s,e[5]=o):o=e[5],o},Vp=({rootDirectory:n,repository:e,onClose:s,initialDiff:r,visible:i=!0,onNavigatedToChat:a})=>{const{t:o}=ye(),{git:l,sourceControl:m}=Zn(),{rootIsGitRepo:p,gitDirectory:f,nestedRepos:g}=e,d=f??n,h=pc(d||null),b=_u(d),v=hc(d||null),x=gc(d||null),[S,C]=c.useState(!1),[R,T]=c.useState(!1),P=Mn(w=>w.profiles),k=Mn(w=>w.globalIdentity),j=Mn(w=>w.loadProfiles),y=Mn(w=>w.loadGlobalIdentity);c.useEffect(()=>{j(),y()},[j,y]);const I=bc(),D=ma(w=>w.refreshIdentityAccounts),L=c.useMemo(()=>xc(P,k,w=>vl(w)&&yc(w,I)),[P,k,I]),O=async w=>{if(!(!d||R)){T(!0);try{(await Ju({directory:d,identity:w,remoteName:Wt||null},{git:l,sourceControl:m})).status==="failed"?ce.error(o("gitView.toast.applyIdentityFailed")):ce.success(o("gitView.toast.appliedIdentity",{name:_c(w,o)}))}finally{T(!1)}}},E=ea(d||null),M=vc(d||null),z=ct(w=>w.setActiveDirectory),_=ct(w=>w.ensureAll),G=ct(w=>w.ensureNestedRepos),F=ct(w=>w.selectNestedRepo),B=ct(w=>w.fetchStatus),V=ct(w=>w.fetchBranches),X=ct(w=>w.prefetchDiffs),Z=ct(w=>w.getDiff),de=ct(w=>w.setDiff),re=ct(w=>w.runtimeKey),Q=JSON.stringify([re,d]),ge=c.useRef(Q);ge.current=Q;const[ee,N]=c.useState(()=>({ownerKey:Q,mode:"working",route:r?.path?{type:"diff",path:r.path,staged:r.staged}:ns})),$=ee.ownerKey===Q?ee.mode:"working",J=ee.ownerKey===Q?ee.route:ns,[ae,oe]=c.useState(!1),q=c.useCallback(w=>{N({ownerKey:Q,mode:w,route:ns}),oe(!1)},[Q]),ne=c.useCallback(w=>{N(U=>({ownerKey:Q,mode:U.ownerKey===Q?U.mode:"working",route:w}))},[Q]);c.useEffect(()=>{N(w=>w.ownerKey===Q?w:{ownerKey:Q,mode:"working",route:ns}),oe(!1)},[Q]),c.useEffect(()=>{i||oe(!1)},[i]),c.useEffect(()=>{r?.path&&N({ownerKey:ge.current,mode:"working",route:{type:"diff",path:r.path,staged:r.staged}})},[r]);const[ve,we]=c.useState(null),[xe,fe]=c.useState(null),[Ne,Ae]=c.useState(""),[Te,Ce]=c.useState(new Set),[Se,K]=c.useState(!1),[be,ie]=c.useState(!1),[he,pe]=c.useState([]),[Oe,De]=c.useState([]),[Fe,Ge]=c.useState([]),[pt,Lt]=c.useState(null),[hn,ds]=c.useState(null),[rr,gn]=c.useState(0),fs=Ou(),ot=zu({directory:d,branch:h?.current,chooseContributor:fs.choose}),vt=Bu(d,l,m),[ms,Ft]=c.useState(null),[ir,at]=c.useState(!1),[$t,or]=c.useState([]),[ps,bn]=c.useState("rebase"),ht=c.useCallback((w,U)=>{or(w),bn(U),at(!0)},[]),Ke=h?.current??null,Pe=eo(w=>w.setOverride),Xe=eo(w=>w.clearOverride),Ue=of(d||null,Ke,i&&$==="commit"&&E===!0),Et=Ue.selectedCommit?.hash??null,ze=wc(d||null,m),hs=c.useMemo(()=>new Set(ze.read?.repository.remotes.map(w=>w.name)??[]),[ze.read]),qe=af(d||null,Ke,i&&E===!0,{branches:v,remoteNames:hs,primaryRemote:ze.contexts[0]?.primaryRemote,readContext:ze.contexts[0]??null}),It=Kd(Ke,qe.base),_t=E===!1||qd(Ke,qe.base,h!==null,qe.resolved),Wt=ze.read?.binding?.remotes[0]?.name??ze.read?.repository.remotes.find(w=>w.name==="origin")?.name??ze.read?.repository.remotes[0]?.name??"",wt=ze.read?ze.read.binding?.providers.find(w=>w.readiness==="ready")?.accountId??null:void 0,gs=c.useMemo(()=>jc(P,k,x,w=>({id:"local-config",name:w.userName,...w,color:"info",icon:"user"}),wt),[wt,x,P,k]),xn=c.useMemo(()=>{const w=ze.read;return!w?.binding||ze.status!=="ready"||w.binding.state==="bound"?null:kc(w.binding)?o("gitView.identity.configChanged"):o("gitView.context.needsAttention")},[ze.read,ze.status,o]),He=Xi(w=>n?w.diffRequests.get(n):void 0);c.useEffect(()=>{He&&N({ownerKey:Q,mode:"pr",route:ns})},[Q,He]);const $e=lf(d||null,Ke,ze.contexts[0]??null,i&&$==="pr"&&E===!0,He),gt=$e.selectedSource;c.useEffect(()=>{!n||!He||!h||gt!==He||Xi.getState().settleDiffRequest(n,He)},[He,n,gt,h]);const Vt=Be(w=>w.currentSessionId),[ar,Ut]=c.useState(!1),Ls=c.useCallback(()=>{Ut(!1),a?.()},[a]),Gt=Sc(Vt,n,Ls),lr=c.useMemo(()=>$==="pr"?gt:$==="branch"&&Ke&&qe.base?{kind:"branch",baseRef:qe.base,headRef:Ke}:$==="commit"&&Et?{kind:"commit",hash:Et}:null,[qe.base,Ke,$,Et,gt]),We=$==="branch"?qe.revision:"",Me=Hd(d||null,lr,i&&E===!0,We,$e.readContext,$e.provider),{fetchDiff:Nt,fetchFullFile:Fs}=Me,$s=c.useMemo(()=>Me.files?[...Me.files].sort((w,U)=>w.path.localeCompare(U.path)):null,[Me.files]),bt=J.type==="comparison"&&J.sourceKey===Me.key?J.path:null,[yn,Ws]=c.useState(0),cr=c.useCallback(async w=>{try{const{diff:U}=await Nt(w),le={original:"",modified:"",isBinary:cf(U)};return le.isBinary||(le.fileDiff=to(w,U)),{status:"ready",diff:le}}catch(U){return{status:"error",message:U instanceof Error?U.message:o("diffView.state.failedToLoadDiff")}}},[Nt,o]),vn=c.useMemo(()=>$==="branch"?Jd(Me.files,We):void 0,[Me.files,We,$]),Vs=Yd(Me.files?$==="pr"?JSON.stringify([Me.key,Me.revision]):Me.key:null,i&&bt?bt:"",i?cr:null,Mo,JSON.stringify([$==="pr"?Me.revision:0,yn]),vn),rt=bt?Vs.get(bt)??Mo:null,[Us,bs]=c.useState(null),[xs,Ot]=c.useState(null),Kt=Us&&Us.source===rt?Us.request:null,qt=xs&&xs.source===rt?xs.diff:null;c.useEffect(()=>{const w=rt;if(!Kt||!bt||w?.status!=="ready"||qt)return;let U=!1;const le=bt,ke=async()=>{if($==="pr"){const{original:xt,modified:Le}=await Fs(le);return{original:xt,modified:Le,fileDiff:mf({name:le,contents:xt},{name:le,contents:Le})}}const{diff:_e}=await Nt(le,Bp);return{original:"",modified:"",fileDiff:to(le,_e)}};return(async()=>{try{const _e=await ke();U||Ot({source:w,diff:_e})}catch(_e){if(U)return;ce.error(_e instanceof Error?_e.message:o("diffView.state.failedToLoadDiff")),bs(null)}})(),()=>{U=!0}},[rt,bt,qt,Nt,Fs,$,Kt,o]),c.useEffect(()=>{$==="branch"&&_t&&q("working")},[_t,q,$]),c.useEffect(()=>{N(w=>w.ownerKey===Q&&w.route.type==="comparison"&&w.route.sourceKey!==Me.key?{...w,route:ns}:w)},[Me.key,Q]);const lt=c.useMemo(()=>{const w=h?.files??[],U=new Map;for(const le of w)U.set(le.path,le);return Array.from(U.values()).sort((le,ke)=>le.path.localeCompare(ke.path))},[h?.files]),jt=c.useMemo(()=>lt.filter(Fp),[lt]),ys=c.useMemo(()=>lt.filter($p),[lt]),wn=Fe,ur=ct(c.useCallback(w=>!d||J.type!=="diff"?null:w.directories.get(d)?.diffCache.get(_o(J.path,J.staged))??null,[d,J])),jn=c.useMemo(()=>J.type!=="diff"?null:lt.find(w=>w.path===J.path)??null,[lt,J]),Qe=c.useCallback(async(w=!0)=>{if(d)try{await Promise.all([B(d,l),V(d,l)])}catch(U){w&&ce.error(U instanceof Error?U.message:o("gitView.toast.refreshRepositoryFailed"))}},[d,V,B,l,o]),kn=c.useMemo(()=>(v?.all??[]).filter(w=>!w.startsWith("remotes/")).sort(),[v]),dr=c.useMemo(()=>(v?.all??[]).filter(w=>w.startsWith("remotes/")).map(w=>w.replace(/^remotes\//,"")).sort(),[v]),Ht=c.useCallback(async w=>{if(!d)return;const U=w.replace(/^remotes\//,"");try{const le=await l.checkoutBranch(d,U);ce.success(o("gitView.toast.checkedOut",{name:le.branch||U})),await Qe()}catch(le){ce.error(le instanceof Error?le.message:o("gitView.toast.checkoutFailed",{name:U}))}},[d,l,Qe,o]),fr=c.useCallback(w=>{const U=w.replace(/^remotes\//,"");if((h?.files?.length??0)>0){Ft(U);return}Ht(U)},[Ht,h?.files]),mr=c.useCallback(async w=>{if(d)try{await l.createBranch(d,w,Ke??"HEAD"),await l.checkoutBranch(d,w),await Qe()}catch(U){throw ce.error(U instanceof Error?U.message:o("gitView.toast.createBranchFailed")),U}},[Ke,d,l,Qe,o]),vs=c.useCallback(async()=>{if(!d){Ge([]);return}try{const w=await l.getRemotes(d);Ge(w)}catch{Ge([])}},[d,l]),At=c.useCallback(async()=>{d&&(Promise.allSettled([V(d,l),vs()]),await B(d,l).catch(()=>{}))},[d,V,B,l,vs]);c.useEffect(()=>{!d||!i||(z(d),_(d,l))},[d,_,l,z,i]),c.useEffect(()=>{i&&vs()},[vs,i]),c.useEffect(()=>{if(!i||$!=="working"||!d||lt.length===0)return;const w=Array.from(new Set([...jt.map(le=>le.path),...Oe,...lt.slice(0,20).map(le=>le.path)])).filter(Boolean);if(w.length===0)return;const U=window.setTimeout(()=>{X(d,l,w,{maxFiles:40})},120);return()=>window.clearTimeout(U)},[lt,d,l,$,X,jt,Oe,i]),c.useEffect(()=>{if(!i)return;if(J.type!=="diff"){Lt(null);return}const w=_o(J.path,J.staged);if(ds(null),!d||Z(d,w)){Lt(null);return}let U=!1;const le=mn();return Lt(null),l.getGitFileDiff(d,{path:J.path,staged:J.staged||void 0}).then(ke=>{U||de(d,w,{original:ke.original??"",modified:ke.modified??"",isBinary:ke.isBinary,submodule:ke.submodule},le)}).catch(ke=>{if(!U){if(ke instanceof $i&&ke.reason!=="path_not_found"){ds({key:`${d}\0${J.path}`,reason:ke.reason});return}ke instanceof $i&&B(d,l,{force:!0,silent:!0}),Lt(ke instanceof Error?ke.message:String(ke))}}),()=>{U=!0}},[d,rr,B,Z,l,J,de,i]);const Jt=async(w,U,le=!1)=>{if(!d)return;const ke=vt.start();if(!ke)return;we(w);const _e=o(w==="fetch"?"gitView.sync.fetch":w==="pull"?"gitView.sync.pull":w==="publish"?"gitView.publish.title":"gitView.sync.syncChanges");let xt=null;try{if(w==="sync"||w==="publish"){const Le=await ot.prepare(w==="publish"?"push":"sync",{forceChoose:le,onOperation:ke.onOperation});xt=Oc(await Le())}else if(U&&h)await zc({action:w,directory:d,remoteName:U.name,status:h,sourceControl:m,git:l,onOperation:ke.onOperation});else throw new Bt("tracking-required");if(!ke.isCurrent())return;w==="fetch"&&U?ce.success(o("gitView.toast.fetchedFromRemote",{name:U.name})):w==="pull"&&U?ce.success(o("gitView.toast.pulledFromRemote",{name:U.name})):w==="sync"?ce.success(xt?.kind==="up-to-date"?o("gitView.toast.alreadyUpToDate"):xt?.kind==="pulled"?o("gitView.toast.pulledFromRemote",{name:xt.remoteName}):xt?.kind==="pushed"?o("gitView.toast.pushedToUpstream",{name:xt.remoteName}):o("gitView.toast.syncedChanges")):w==="publish"&&ce.success(o("gitView.publish.succeeded")),await At()}catch(Le){if(Le instanceof Bn||Le instanceof Mr){if(ke.isCurrent()&&await At(),ke.isCurrent()&&Le instanceof Bn&&Le.read.availability==="available"&&Le.read.operation.state==="conflicted"&&Le.read.operation.error.code==="CONFLICT"){const Cn=((await l.getGitStatus(d).catch(()=>null))?.files??[]).filter(jr).map(Rn=>Rn.path);Cn.length>0&&ht(Cn,"merge")}return}if(Le instanceof Bt&&Le.code==="stale-runtime")return;if(Le instanceof Bt&&ot.errorMessage(Le)){ce.info(ot.errorMessage(Le));return}await At(),ce.error(Le instanceof Bt?Le.code==="contributor-publish-cancelled-after-update"?o("gitView.toast.contributorPublishCancelledAfterUpdate"):Le.code==="contributor-publish-cancelled"?o("gitView.toast.contributorPublishCancelled"):o("gitView.toast.syncActionFailed",{action:_e}):Le instanceof Error?Le.message:o("gitView.toast.syncActionFailed",{action:_e}))}finally{ke.finish(),ke.isCurrent()&&we(null)}},Yt=c.useCallback(async(w,U)=>{if(!(!d||w.length===0))try{U==="stage"?w.length>1?await Nc(d,w):await Cc(d,w[0]):w.length>1?await Rc(d,w):await Ec(d,w[0]),await Qe(!1)}catch(le){ce.error(le instanceof Error?le.message:o(U==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed"))}},[d,Qe,o]),Pt=c.useCallback((w,U=!1)=>{ne({type:"diff",path:w,staged:U})},[ne]),Gs=c.useCallback(async w=>{if(d){Ce(U=>new Set(U).add(w));try{await l.revertGitFile(d,w),ce.success(o("gitView.toast.revertedFile",{path:w})),await Qe(!1)}catch(U){ce.error(U instanceof Error?U.message:o("gitView.toast.revertFailed"))}finally{Ce(U=>{const le=new Set(U);return le.delete(w),le})}}},[d,l,Qe,o]),Sn=c.useCallback(async w=>{if(!d||w.length===0||Se)return;const U=Array.from(new Set(w));K(!0),Ce(new Set(U));try{const le=await Op(U,ke=>l.revertGitFile(d,ke),Lp);if(await Qe(!1),le.failures.length===0)ce.success(U.length===1?o("gitView.toast.revertedFilesSingle",{count:U.length}):o("gitView.toast.revertedFilesPlural",{count:U.length}));else if(le.failures.length===U.length)ce.error(le.failures[0]?.error?.message??o("gitView.toast.revertFailed"));else{const ke=U.length-le.failures.length;ce.warning(ke===1?o("gitView.toast.revertedSomeSingle",{success:ke,failed:le.failures.length}):o("gitView.toast.revertedSomePlural",{success:ke,failed:le.failures.length}))}}catch(le){ce.error(le instanceof Error?le.message:o("gitView.toast.revertFailed"))}finally{Ce(new Set),K(!1)}},[d,l,Se,Qe,o]),pr=c.useCallback(w=>{const U=w.map(le=>le.trim()).filter(Boolean);if(U.length===0){pe([]);return}Ae(le=>`${le.trim()}${le.trim()?`
23
+
24
+ `:""}${U.join(`
25
+ `)}`.trim()),pe([])},[]),hr=c.useCallback(async()=>{if(!d)return;const w=jt.map(U=>U.path).sort();if(w.length===0){ce.error(o("gitView.toast.selectFileToDescribe"));return}ie(!0);try{const{message:U}=await Ji(d,w);Ae(U.subject?.trim()??""),pe(Array.isArray(U.highlights)?U.highlights:[])}catch(U){ce.error(U instanceof Error?U.message:o("gitView.toast.generateCommitMessageFailed"))}finally{ie(!1)}},[d,jt,o]),Ks=async(w={})=>{if(!d)return;if(!Ne.trim()){ce.error(o("gitView.toast.enterCommitMessage"));return}const U=jt.map(_e=>_e.path).sort();if(U.length===0){ce.error(o("gitView.toast.selectFileToCommit"));return}fe(w.pushAfter?"commitAndPush":"commit");let le=null,ke="pending";try{if(await l.createGitCommit(d,Ne.trim(),{files:U}),ke="local",ce.success(o("gitView.toast.commitCreated")),Ae(""),pe([]),w.pushAfter){if(le=vt.start(),!le){ce.warning(o("gitView.publish.commitKept")),await At();return}const _e=await ot.prepare("push",{onOperation:le.onOperation});we("publish"),await _e(),ke="published",ce.success(o("gitView.publish.succeeded"))}await At()}catch(_e){if(w.pushAfter&&ke==="local"&&ce.warning(o("gitView.publish.commitKept")),_e instanceof Bn||_e instanceof Mr){await At();return}if(_e instanceof Bt&&_e.code==="stale-runtime")return;if(_e instanceof Bt&&ot.errorMessage(_e)){ce.info(ot.errorMessage(_e));return}w.pushAfter&&await At(),ce.error(_e instanceof Bt?_e.code==="contributor-publish-cancelled-after-update"?o("gitView.toast.contributorPublishCancelledAfterUpdate"):_e.code==="contributor-publish-cancelled"?o("gitView.toast.contributorPublishCancelled"):o("gitView.toast.syncActionFailed",{action:o("gitView.sync.syncChanges")}):_e instanceof Error?_e.message:o("gitView.toast.createCommitFailed"))}finally{le?.finish(),fe(null),w.pushAfter&&we(null)}},Ei=c.useMemo(()=>(h?.files??[]).filter(jr).length,[h?.files]),Xt=!!h?.mergeInProgress?.head,ws=c.useCallback(async()=>{if(d)try{if(Xt){const w=await l.continueMerge(d);w.conflict?(ht(w.conflictFiles??[],"merge"),ce.error(o("gitView.toast.mergeConflictsDetected"))):ce.success(o("gitView.toast.mergeCompleted"))}else{const w=await l.continueRebase(d);w.conflict?(ht(w.conflictFiles??[],"rebase"),ce.error(o("gitView.toast.rebaseConflictsDetected"))):ce.success(o("gitView.toast.rebaseStepCompleted"))}await Qe(!1)}catch(w){ce.error(w instanceof Error?w.message:o("gitView.toast.continueOperationFailed"))}},[d,l,Xt,ht,Qe,o]),Qt=c.useCallback(async w=>{if(d)try{w==="merge"?(await l.abortMerge(d),ce.success(o("gitView.toast.mergeAborted"))):(await l.abortRebase(d),ce.success(o("gitView.toast.rebaseAborted"))),await Qe(!1)}catch(U){ce.error(U instanceof Error?U.message:o("gitView.toast.abortOperationFailed"))}},[d,l,Qe,o]),js=c.useCallback(()=>{const w=(h?.files??[]).filter(jr).map(U=>U.path);ht(w,Xt?"merge":"rebase")},[Xt,ht,h?.files]),Zt=c.useMemo(()=>{const w=[];return jt.length>0&&w.push({id:"staged",title:o("gitView.changes.stagedTitle"),entries:jt,statsScope:"staged",actionSymbol:"-",actionAllLabel:o("gitView.changes.unstageAllAria"),getActionLabel:U=>o("gitView.changes.unstageFileAria",{path:U}),onActionFile:U=>{Yt([U],"unstage")},onActionAll:U=>{Yt(U,"unstage")},onViewDiff:U=>Pt(U,!0),onRevertFile:Gs,showRevertActions:!1,accent:!0}),ys.length>0&&w.push({id:"unstaged",title:o("gitView.changes.title"),entries:ys,statsScope:"working",actionSymbol:"+",actionAllLabel:o("gitView.changes.stageAllAria"),getActionLabel:U=>o("gitView.changes.stageFileAria",{path:U}),onActionFile:U=>{Yt([U],"stage")},onActionAll:U=>{Yt(U,"stage")},onViewDiff:U=>Pt(U,!1),onRevertFile:Gs}),w},[Gs,Pt,Yt,jt,o,ys]),Nn=t.jsxs(t.Fragment,{children:[ot.context?t.jsx(Lu,{context:ot.context,onSelect:ot.settle}):null,ot.confirmDialog,t.jsx(Fu,{candidates:fs.candidates,onSelect:fs.settle})]}),es=w=>t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[Nn,t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[s?t.jsx("button",{type:"button",className:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"close",className:"size-5"})}):null,t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[t.jsx("h2",{className:"typography-ui-label text-foreground",children:o("mobile.nav.changes")}),t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:h?.current||d||""})]}),p===!1&&Array.isArray(g)&&g.length>0?t.jsx(Hu,{repositories:g,selectedRepository:f??null,onSelectRepository:U=>{n&&F(n,U)},repositoryRoot:n??void 0}):null]}),t.jsx("div",{className:"min-h-0 flex-1",children:w})]});if(!d)return es(t.jsx(mt,{message:o("gitView.empty.selectSessionOrDirectory")}));if(p===!1&&E!==!0)return es(t.jsx(Yu,{root:n,rootIsGitRepo:p,resolvedIsGitRepo:E,nestedRepos:g,onRetryDiscovery:()=>{n&&G(n,{force:!0})}}));if(M&&E===null)return es(t.jsx(mt,{loading:!0,message:o("gitView.loading.checkingRepository")}));if(J.type==="diff")return t.jsx(Oo,{path:J.path,diff:ur,staged:J.staged,fileExists:!!jn,unavailableReason:hn?.key===`${d}\0${J.path}`?hn.reason:null,error:pt,onBack:()=>ne({type:"list"}),onRetry:()=>gn(w=>w+1)});const qs=o($==="pr"?Pn("session.githubIntegration.tabs.pullRequests",$e.provider):$==="branch"?"diffView.scope.branch":$==="commit"?"commitComparison.mode":"mobile.nav.changes"),ts=$==="branch"&&qe.base?$u(qe.base):$==="commit"?Et?.slice(0,8):$==="pr"&&gt?`#${gt.number}`:null;if(bt&&rt)return t.jsx(Oo,{path:bt,subtitle:[qs,ts].filter(Boolean).join(" · "),diff:qt??(rt.status==="ready"?rt.diff:null),fileExists:!Me.files||Me.files.some(w=>w.path===bt),error:Me.error??(rt.status==="error"?rt.message:null),onBack:()=>ne(ns),onRetry:()=>{Me.error&&Me.refresh(),Ws(w=>w+1)},onExpandContextRequest:rt.status==="ready"?w=>bs({source:rt,request:w}):void 0,pendingContextExpansion:Kt,contextLoading:Kt!==null&&!qt});const zt=()=>$==="pr"&&!gt?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(mt,{loading:$e.loading,message:$e.error??($e.loading?o(Pn("session.githubPrPicker.loading.pullRequests",$e.provider)):o(Pn("pullRequestComparison.select",$e.provider)))}),!$e.loading&&t.jsx(so,{mobile:!0,comparison:$e})]}):$==="branch"&&!qe.base?t.jsx(mt,{loading:!qe.resolved,message:qe.resolved?o("gitView.pr.toast.baseBranchRequired"):o("diffView.branch.resolvingBase")}):$==="commit"&&!Et?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[Ue.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:Ue.loading?o("diffView.state.loadingChanges"):Ue.error??o("commitComparison.noCommits")}),Ue.error&&t.jsx(Ee,{variant:"outline",size:"lg",onClick:()=>{Ue.refresh()},children:o("diffView.actions.retry")})]}):Me.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:Me.error}),t.jsx(Ee,{variant:"outline",size:"lg",onClick:()=>{Me.refresh()},children:o("diffView.actions.retry")})]}):$s?$s.length===0?t.jsx(mt,{icon:$==="branch",message:$==="pr"?o("walkthrough.blocked.emptyDiff.description"):$==="commit"?o("commitComparison.emptyDiff"):o("diffView.branch.empty",{base:ts??""})}):t.jsx(Up,{files:$s,onSelect:w=>{Me.key&&ne({type:"comparison",path:w,sourceKey:Me.key})}}):t.jsx(mt,{loading:!0,message:o("diffView.state.loadingChanges")});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[Nn,t.jsxs("header",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b border-border/60 px-3 py-2",children:[s?t.jsx("button",{type:"button",className:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(Y,{name:"close",className:"size-5"})}):null,t.jsxs(_r,{open:ae,onOpenChange:oe,children:[t.jsx(Or,{asChild:!0,children:t.jsxs(Ee,{variant:"outline",className:Ic({size:"mobile"}),"data-mobile-comparison-trigger":!0,"aria-label":o("diffView.scope.selectorAria"),children:[t.jsx("span",{children:qs}),t.jsx(Y,{name:"arrow-down-s",className:"size-4"})]})}),t.jsx(zr,{align:"start",children:t.jsxs(Ac,{value:$,onValueChange:w=>{(w==="working"||w==="branch"||w==="commit"||w==="pr")&&q(w)},children:[t.jsx(Tn,{value:"working",className:"min-h-8 items-center",children:o("mobile.nav.changes")}),It&&t.jsx(Tn,{value:"branch",className:"min-h-8 items-center",children:o("diffView.scope.branch")}),t.jsx(Tn,{value:"commit",className:"min-h-8 items-center",children:o("commitComparison.mode")}),t.jsx(Tn,{value:"pr",className:"min-h-8 items-center",children:o(Pn("session.githubIntegration.tabs.pullRequests",$e.provider))})]})})]}),i&&$==="branch"&&t.jsx(uf,{mobile:!0,branches:v?.all??[],currentBranch:Ke,base:qe.base,automatic:qe.source!=="chosen",onSelect:w=>{Ke&&Pe(d,Ke,w)},onSelectAutomatic:()=>{Ke&&Xe(d,Ke)}},JSON.stringify([Q,Ke])),i&&$==="commit"&&t.jsx(df,{mobile:!0,commits:Ue.commits,selectedHash:Et,loading:Ue.loading,error:Ue.error,onSelect:Ue.select,onRefresh:()=>{Ue.refresh()}},JSON.stringify([Q,Ke])),i&&$==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(so,{mobile:!0,comparison:$e},JSON.stringify([Q,Ke])),gt&&t.jsx(Ee,{variant:"ghost",size:"sm",disabled:Me.loading,"aria-label":o("session.githubIssuePicker.actions.refresh"),onClick:()=>{Me.refresh()},children:t.jsx(Y,{name:"refresh",className:"size-4"})})]}),$==="working"&&Vt&&(h?.files?.length??0)>0?t.jsxs(Ee,{variant:"default",className:"ms-auto shrink-0",disabled:Gt.submitting,onClick:()=>Ut(!0),"aria-label":o("diffView.actions.reviewAria"),style:{touchAction:"manipulation"},children:[t.jsx(Y,{name:Gt.submitting?"loader-4":"search-eye",className:te("size-4",Gt.submitting&&"animate-spin")}),o("diffView.actions.review")]}):null]}),t.jsx(Pc,{open:ar,onOpenChange:Ut,projectDirectory:n||null,submitting:Gt.submitting,onConfirm:Gt.start}),$==="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(Wu,{currentBranch:h?.current,localBranches:kn,remoteBranches:dr,branchInfo:v?.branches,currentBranchAhead:h?.ahead,onCheckout:w=>{fr(w)},onCreate:mr,disabled:M,directory:d,switchBlockedNotice:(h?.files?.length??0)>0?o("gitView.branch.switchBlockedNotice"):null})}),t.jsx(Vu,{activeProfile:gs,identities:L,attention:xn,triggerClassName:"max-w-[10rem] shrink [&_.git-identity-label]:hidden sm:[&_.git-identity-label]:inline",onOpen:()=>{D(m,P.map(w=>w.account))},onSelect:w=>{O(w)},isApplying:R,onConfigure:()=>C(!0),applicability:w=>{const U=ze.read?.repository.remotes.find(le=>le.name===Wt);return U?Uu(w,Tc(U.fetch.displayUrl)):{applicable:!0}}}),t.jsx(Gu,{syncAction:vt.entry?.executing?ve:null,remotes:wn,onFetch:w=>{Jt("fetch",w)},onPull:w=>{Jt("pull",w)},onSync:w=>{Jt("sync",w)},onPublish:()=>{Jt("publish")},onChooseSyncTargets:()=>{Jt("sync",void 0,!0)},currentBranch:h?.current,hasTracking:!!h?.tracking,disabled:M||vt.blocked,aheadCount:h?.ahead??0,behindCount:h?.behind??0,trackingRemoteName:h?.tracking?.split("/")[0],trackingBranch:h?.tracking,hasUncommittedChanges:Ku(lt),choosesPushDestination:b})]}),t.jsx(Zd,{open:S,onOpenChange:C,directory:d}),t.jsx(qu,{className:"mx-3 mt-3",entry:vt.entry,onRefresh:()=>{vt.refresh()},onCancel:()=>{vt.cancel()}}),$==="working"&&t.jsx(ef,{mergeInProgress:h?.mergeInProgress,rebaseInProgress:h?.rebaseInProgress,onContinue:ws,onAbort:()=>Qt(Xt?"merge":"rebase"),onResolveWithAI:js,conflictCount:Ei,isLoading:ve!==null||xe!==null}),$!=="working"?t.jsx("div",{className:"min-h-0 flex-1",children:zt()}):lt.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(tf,{groups:Zt,diffStats:h?.diffStats,revertingPaths:Te,onRevertAll:Sn,isRevertingAll:Se,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:De})}),t.jsx("div",{className:"shrink-0 border-t border-border/70 px-4 pb-4 pt-3",children:t.jsx(sf,{stagedCount:jt.length,commitMessage:Ne,onCommitMessageChange:Ae,generatedHighlights:he,onInsertHighlights:pr,onGenerateMessage:hr,isGeneratingMessage:be,onCommit:()=>{Ks({pushAfter:!1})},onCommitAndPush:()=>{Ks({pushAfter:!0})},commitAction:xe,networkOperationBlocked:vt.blocked,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(mt,{icon:!0,message:o("gitView.empty.cleanTitle"),description:o("mobile.changes.cleanDescription")})}),d&&t.jsx(nf,{open:ir,onOpenChange:at,conflictFiles:$t,directory:d,operation:ps,onAbort:()=>{Qt(ps)},onNavigatedToChat:a}),t.jsx(rf,{open:ms!==null,onOpenChange:w=>{w||Ft(null)},targetBranch:ms??"",changedFileCount:h?.files?.length??0,onCommitAndSwitch:(w,U)=>zp(w,U,{targetBranch:ms,directory:d,sourceBranch:h?.current??null,git:l,publishChooser:ot,toast:ce,t:o,refreshStatusAndBranches:Qe,closeDialog:()=>Ft(null),performCheckout:Ht}),onGenerateMessage:async()=>{if(!d)return"";const w=(h?.files??[]).map(le=>le.path).sort(),{message:U}=await Ji(d,w);return U.subject?.trim()??""},onRevertAndSwitch:async()=>{const w=ms;if(!w||!d)return;await Sn((h?.files??[]).map(le=>le.path));const U=await l.getGitStatus(d);if(!U.isClean&&(U.files?.length??0)>0){ce.error(o("gitView.dirtySwitch.revertIncomplete"));return}Ft(null),await Ht(w)}})]})},mt=n=>{const e=ue.c(13),{message:s,description:r,loading:i,icon:a}=n,o=i===void 0?!1:i,l=a===void 0?!1:a;let m;e[0]!==o?(m=o?t.jsx(Y,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,e[0]=o,e[1]=m):m=e[1];let p;e[2]!==l?(p=l?t.jsx(Y,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e[2]=l,e[3]=p):p=e[3];let f;e[4]!==s?(f=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[4]=s,e[5]=f):f=e[5];let g;e[6]!==r?(g=r?t.jsx("p",{className:"typography-meta text-muted-foreground",children:r}):null,e[6]=r,e[7]=g):g=e[7];let d;return e[8]!==m||e[9]!==p||e[10]!==f||e[11]!==g?(d=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,p,f,g]})}),e[8]=m,e[9]=p,e[10]=f,e[11]=g,e[12]=d):d=e[12],d},Oo=n=>{const e=ue.c(55),{path:s,subtitle:r,diff:i,staged:a,fileExists:o,unavailableReason:l,error:m,onBack:p,onRetry:f,onExpandContextRequest:g,pendingContextExpansion:d,contextLoading:h}=n,b=a===void 0?!1:a,v=l===void 0?null:l,{t:x}=ye();let S;e[0]!==s?(S=Dc(s)||"text",e[0]=s,e[1]=S):S=e[1];const C=S,R=Ve(Gp),T=Ve(Kp);let P;e[2]!==R||e[3]!==x?(P=x(R?"diffView.whitespace.hidden":"diffView.whitespace.shown"),e[2]=R,e[3]=x,e[4]=P):P=e[4];const k=P;let j;e[5]!==x?(j=x("header.actions.backAria"),e[5]=x,e[6]=j):j=e[6];let y;e[7]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx(Y,{name:"arrow-left",className:"size-5"}),e[7]=y):y=e[7];let I;e[8]!==p||e[9]!==j?(I=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":j,onClick:p,children:y}),e[8]=p,e[9]=j,e[10]=I):I=e[10];let D;e[11]!==s?(D=t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:s}),e[11]=s,e[12]=D):D=e[12];let L;e[13]!==r?(L=r&&t.jsx("p",{className:"truncate typography-meta text-muted-foreground",children:r}),e[13]=r,e[14]=L):L=e[14];let O;e[15]!==D||e[16]!==L?(O=t.jsxs("div",{className:"min-w-0 flex-1 px-2",children:[D,L]}),e[15]=D,e[16]=L,e[17]=O):O=e[17];const E=R?"text-foreground":"text-muted-foreground";let M;e[18]!==E?(M=te("flex size-9 shrink-0 items-center justify-center rounded-lg hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",E),e[18]=E,e[19]=M):M=e[19];let z;e[20]!==x?(z=x("diffView.actions.hideWhitespace"),e[20]=x,e[21]=z):z=e[21];let _;e[22]!==R||e[23]!==T?(_=()=>T(!R),e[22]=R,e[23]=T,e[24]=_):_=e[24];let G;e[25]!==R?(G=t.jsx(Qd,{hidden:R,className:"size-5"}),e[25]=R,e[26]=G):G=e[26];let F;e[27]!==R||e[28]!==M||e[29]!==z||e[30]!==_||e[31]!==G||e[32]!==k?(F=t.jsx("button",{type:"button",className:M,"aria-label":z,"aria-pressed":R,title:k,onClick:_,children:G}),e[27]=R,e[28]=M,e[29]=z,e[30]=_,e[31]=G,e[32]=k,e[33]=F):F=e[33];let B;e[34]!==O||e[35]!==F||e[36]!==I?(B=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:[I,O,F]}),e[34]=O,e[35]=F,e[36]=I,e[37]=B):B=e[37];let V;e[38]!==h||e[39]!==i||e[40]!==m||e[41]!==o||e[42]!==R||e[43]!==C||e[44]!==g||e[45]!==f||e[46]!==s||e[47]!==d||e[48]!==b||e[49]!==x||e[50]!==v?(V=t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:o?v==="nested_repository"?t.jsx(mt,{icon:!0,message:x("diffView.unavailable.nestedRepositoryTitle"),description:x("diffView.unavailable.nestedRepositoryDescription")}):v==="untracked_directory"?t.jsx(mt,{icon:!0,message:x("diffView.unavailable.untrackedDirectoryTitle"),description:x("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:x("mobile.changes.diffDetail.loadFailed")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:m}),t.jsx(Ee,{type:"button",size:"sm",variant:"outline",onClick:f,children:x("diffView.actions.retry")})]})}):i?i.submodule?t.jsx("div",{className:"p-3",children:t.jsx(Xd,{state:i.submodule,staged:b})}):i.isBinary?t.jsx(mt,{icon:!0,message:x("diffView.binary.unavailable")}):Mc(s)&&!i.fileDiff?t.jsx(mt,{icon:!0,message:x("mobile.changes.diffDetail.imageUnavailable")}):t.jsx(er,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:t.jsx(ff,{original:i.original,modified:i.modified,fileDiff:i.fileDiff,language:C,fileName:s,renderSideBySide:!1,wrapLines:!0,hideWhitespace:R,layout:"inline",onExpandContextRequest:g,pendingContextExpansion:d,contextLoading:h})}):t.jsx(mt,{loading:!0,message:x("diffView.state.loadingDiff")}):t.jsx(mt,{icon:!0,message:x("mobile.changes.diffDetail.missingTitle"),description:x("mobile.changes.diffDetail.missingDescription")})}),e[38]=h,e[39]=i,e[40]=m,e[41]=o,e[42]=R,e[43]=C,e[44]=g,e[45]=f,e[46]=s,e[47]=d,e[48]=b,e[49]=x,e[50]=v,e[51]=V):V=e[51];let X;return e[52]!==B||e[53]!==V?(X=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[B,V]}),e[52]=B,e[53]=V,e[54]=X):X=e[54],X},Up=n=>{const e=ue.c(12),{files:s,onSelect:r}=n,{t:i}=ye();let a;e[0]!==i?(a=i("gitView.changes.changedFilesAria"),e[0]=i,e[1]=a):a=e[1];let o;if(e[2]!==s||e[3]!==r||e[4]!==i){let m;e[6]!==r||e[7]!==i?(m=p=>{const f=p.status==="A"?i("diffView.change.new"):p.status==="D"?i("diffView.change.deleted"):p.status==="R"?i("diffView.change.renamed"):p.status==="C"?i("diffView.change.copied"):i("diffView.change.modified"),g=p.status==="A"?"var(--status-success)":p.status==="D"?"var(--status-error)":p.status==="R"||p.status==="C"?"var(--status-info)":"var(--status-warning)";return t.jsx("li",{children:t.jsxs(Ee,{variant:"ghost",size:"lg",className:"w-full justify-start gap-2.5 text-start normal-case",onClick:()=>r(p.path),children:[t.jsx("span",{className:"w-4 shrink-0 text-center typography-meta font-semibold uppercase",style:{color:g},"aria-label":f,children:p.status}),t.jsx(pa,{filePath:p.path,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label",title:p.path,children:p.path}),(p.insertions>0||p.deletions>0)&&t.jsxs("span",{className:"shrink-0 typography-meta text-muted-foreground",children:["+",p.insertions," -",p.deletions]}),t.jsx(Y,{name:"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground"})]})},p.path)},e[6]=r,e[7]=i,e[8]=m):m=e[8],o=s.map(m),e[2]=s,e[3]=r,e[4]=i,e[5]=o}else o=e[5];let l;return e[9]!==a||e[10]!==o?(l=t.jsx(er,{className:"h-full overflow-y-auto overflow-x-hidden px-3 py-2",children:t.jsx("ul",{"aria-label":a,className:"flex flex-col gap-1",children:o})}),e[9]=a,e[10]=o,e[11]=l):l=e[11],l};function Gp(n){return n.diffHideWhitespace}function Kp(n){return n.setDiffHideWhitespace}const qp=c.lazy(()=>Ts(()=>import("./FilesView-ni2zfAwL.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129])).then(n=>({default:n.FilesView}))),St=n=>pn(n)??"",an=n=>{const e=St(n);return!e||e==="/"?e||"/":e.split("/").filter(Boolean).at(-1)??e},Hp=n=>{const e=St(n);if(!e||e==="/")return null;const s=e.lastIndexOf("/");return s<=0?e.startsWith("/")?"/":null:e.slice(0,s)},Jp=(n,e)=>{const s=St(n),r=St(e);return!r||s===r?an(s):s.startsWith(`${r}/`)?s.slice(r.length+1):s},Yp=n=>{if(typeof n!="number"||!Number.isFinite(n)||n<0)return"";if(n<1024)return`${n} B`;const e=["KB","MB","GB"];let s=n/1024;for(const r of e){if(s<1024||r===e[e.length-1])return`${s.toFixed(s>=10?0:1)} ${r}`;s/=1024}return""},Xp=n=>{const e=ue.c(6),{onClose:s,visible:r}=n,i=r===void 0?!0:r,a=ti()??null;let o;e[0]!==a?(o=St(a),e[0]=a,e[1]=o):o=e[1];const l=o;let m;return e[2]!==s||e[3]!==l||e[4]!==i?(m=t.jsx(Qp,{root:l,onClose:s,visible:i},l),e[2]=s,e[3]=l,e[4]=i,e[5]=m):m=e[5],m},Qp=({root:n,onClose:e,visible:s})=>{const{t:r}=ye(),{files:i}=Zn(),a=wl(),o=jl(N=>N.setSelectedPath),[l,m]=c.useState(()=>({type:"browser",directory:n})),[p,f]=c.useState([]),[g,d]=c.useState(!1),[h,b]=c.useState(null),[v,x]=c.useState(""),[S,C]=c.useState([]),[R,T]=c.useState(!1),P=c.useRef(0),k=l.type==="browser"?l.directory:l.returnDirectory,j=c.useRef(k);j.current=k;const y=c.useCallback(async(N,$)=>{if(!N)return;const J=!a,ae=P.current+1;P.current=ae,d(!0),$?.background||b(null);try{const oe=await i.listDirectory(N,{respectGitignore:J});if(P.current!==ae)return;b(null),f(oe.entries.slice().sort((q,ne)=>q.isDirectory!==ne.isDirectory?q.isDirectory?-1:1:q.name.localeCompare(ne.name)))}catch(oe){if(P.current!==ae)return;if($?.background){console.error("Failed to reload mobile directory:",oe);return}f([]),b(oe instanceof Error?oe.message:r("mobile.files.error.listFailed"))}finally{P.current===ae&&d(!1)}},[i,a,r]);c.useEffect(()=>{l.type==="browser"&&y(l.directory)},[y,l]);const I=c.useRef(l);I.current=l;const D=c.useRef(p);D.current=p;const L=c.useCallback(({directories:N})=>{const $=I.current;$.type==="browser"&&(N&&!N.some(J=>St(J)===St($.directory))||D.current.length>Xu||y($.directory,{background:!0}))},[y]);Qu({root:n,active:s,whileInactive:"hold",onChanges:L});const O=c.useCallback(async N=>{St(N)===St(j.current)&&await y(j.current)},[y]),{canUpload:E,uploadingDirectory:M,pickFiles:z,uploadElements:_}=Zu({root:n,refreshDirectory:O}),G=M!==null;c.useEffect(()=>{if(l.type!=="browser")return;const N=v.trim();if(!N){C([]),T(!1);return}let $=!1;const J=window.setTimeout(()=>{T(!0),i.search({directory:l.directory,query:N,maxResults:40}).then(ae=>{$||C(ae)}).catch(()=>{$||C([])}).finally(()=>{$||T(!1)})},250);return()=>{$=!0,window.clearTimeout(J)}},[i,v,l]);const F=N=>{x(""),m({type:"browser",directory:N})},B=N=>{o(n,N),m({type:"file",path:N,returnDirectory:k||n})},V=Ve(N=>N.pendingFileFocusPath),X=Ve(N=>N.pendingFileNavigation);if(c.useEffect(()=>{const N=St(X?.path??V??"");!N||!n||(o(n,N,{allowOutsideRoot:!0}),m({type:"file",path:N,returnDirectory:n}),V&&Ve.getState().setPendingFileFocusPath(null))},[V,X,n,o]),!n)return t.jsx(ln,{message:r("mobile.files.empty.noDirectory")});if(l.type==="file")return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/70 px-3 text-foreground",children:[t.jsx("button",{type:"button",className:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":r("header.actions.backAria"),onClick:()=>m({type:"browser",directory:l.returnDirectory}),style:{touchAction:"manipulation"},children:t.jsx(Zi,{className:"size-5"})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:an(l.path)})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(Ze,{children:t.jsx(c.Suspense,{fallback:t.jsx(ln,{loading:!0,message:r("filesView.state.loading")}),children:t.jsx(qp,{mode:"editor-only"})})})})]});const Z=l.directory===n?r("mobile.files.rootDirectory"):an(l.directory),de=v.trim()?S:[],re=Hp(l.directory),Q=l.directory!==n&&re!==null&&(re===n||re.startsWith(`${n}/`)),ge=Q&&!v.trim(),ee=Q?re:null;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[_,t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[e?t.jsx("button",{type:"button",className:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":r("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(Dd,{className:"size-5"})}):null,ge&&ee?t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":r("mobile.files.backToParentAria",{name:an(ee)}),onClick:()=>F(ee),style:{touchAction:"manipulation"},children:t.jsx(Zi,{className:"size-5"})}):null,t.jsx("div",{className:"min-w-0 flex-1 px-1",children:t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:Z})}),t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":r("mobile.files.refreshAria"),onClick:()=>{y(l.directory)},style:{touchAction:"manipulation"},children:t.jsx(Md,{className:te("size-5",g&&"animate-spin")})}),E?t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50","aria-label":r("sidebarFilesTree.actions.uploadFilesTitle"),onClick:()=>z(l.directory),disabled:G,style:{touchAction:"manipulation"},children:t.jsx(Y,{name:G?"loader-4":"upload-2",className:te("size-5",G&&"animate-spin")})}):null]}),t.jsx("div",{className:"shrink-0 px-4 pb-2 pt-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(_d,{className:"pointer-events-none absolute inset-s-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(la,{value:v,onChange:N=>x(N.target.value),placeholder:r("mobile.files.search.placeholder"),className:"h-11 ps-9"})]})}),t.jsx(er,{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-3",children:h?t.jsx(ln,{message:h}):v.trim()?t.jsx(Zp,{results:de,isSearching:R,onOpenFile:B}):t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:[p.length===0&&!g?t.jsx("div",{className:"px-4 py-8 text-center typography-body text-muted-foreground",children:r("mobile.files.empty.directory")}):null,p.map(N=>t.jsx(rl,{name:N.name,path:N.path,directory:N.isDirectory,meta:N.isDirectory?void 0:Yp(N.size),onClick:()=>N.isDirectory?F(N.path):B(N.path)},N.path))]})})]})},rl=n=>{const e=ue.c(16),{name:s,path:r,directory:i,meta:a,onClick:o}=n;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={touchAction:"manipulation"},e[0]=l):l=e[0];let m;e[1]!==i||e[2]!==r?(m=i?t.jsx(Bd,{className:"size-5 shrink-0 text-primary/80"}):t.jsx(pa,{filePath:r,className:"size-5 shrink-0"}),e[1]=i,e[2]=r,e[3]=m):m=e[3];let p;e[4]!==s?(p=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:s}),e[4]=s,e[5]=p):p=e[5];let f;e[6]!==a?(f=a?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:a}):null,e[6]=a,e[7]=f):f=e[7];let g;e[8]!==i?(g=i?t.jsx(Ld,{className:"size-4 shrink-0 text-muted-foreground/60"}):null,e[8]=i,e[9]=g):g=e[9];let d;return e[10]!==o||e[11]!==m||e[12]!==p||e[13]!==f||e[14]!==g?(d=t.jsxs("button",{type:"button",className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3 py-2.5 text-start transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:o,style:l,children:[m,p,f,g]}),e[10]=o,e[11]=m,e[12]=p,e[13]=f,e[14]=g,e[15]=d):d=e[15],d},Zp=n=>{const e=ue.c(10),{results:s,isSearching:r,onOpenFile:i}=n,{t:a}=ye(),o=St(ti()??null);if(r){let f;e[0]!==a?(f=a("common.loading"),e[0]=a,e[1]=f):f=e[1];let g;return e[2]!==f?(g=t.jsx(ln,{loading:!0,message:f}),e[2]=f,e[3]=g):g=e[3],g}if(s.length===0){let f;e[4]!==a?(f=a("mobile.files.search.empty"),e[4]=a,e[5]=f):f=e[5];let g;return e[6]!==f?(g=t.jsx(ln,{message:f}),e[6]=f,e[7]=g):g=e[7],g}const l="overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",m=s.map(f=>t.jsx(rl,{name:an(f.path),path:f.path,directory:!1,meta:Jp(f.path,o),onClick:()=>i(f.path)},f.path));let p;return e[8]!==m?(p=t.jsx("div",{className:l,children:m}),e[8]=m,e[9]=p):p=e[9],p},ln=n=>{const e=ue.c(7),{message:s,loading:r}=n,i=r===void 0?!1:r;let a;e[0]!==i?(a=i?t.jsx(Od,{className:"size-5 animate-spin text-muted-foreground"}):t.jsx(zd,{className:"size-6 text-muted-foreground"}),e[0]=i,e[1]=a):a=e[1];let o;e[2]!==s?(o=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[2]=s,e[3]=o):o=e[3];let l;return e[4]!==a||e[5]!==o?(l=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[a,o]})}),e[4]=a,e[5]=o,e[6]=l):l=e[6],l},zo="mobile-surface-root",eh=16,Bo=320,th="cubic-bezier(0.22, 1, 0.36, 1)",sh=n=>{const e=ue.c(38),{onOpenMcpSettings:s,active:r}=n,{t:i}=ye(),[a,o]=c.useState(!1),l=Mt(rh),m=Ss(ih),p=Is(oh);let f;e[0]!==l||e[1]!==a||e[2]!==p||e[3]!==m?(f=()=>{if(a)return;o(!0);const L=new Promise(ah);Promise.all([m({directory:l||null,silent:!0}),p({force:!0}),L]).finally(()=>o(!1))},e[0]=l,e[1]=a,e[2]=p,e[3]=m,e[4]=f):f=e[4];const g=f;let d;e[5]!==i?(d=i("settings.mcp.sidebar.actions.addServerTitle"),e[5]=i,e[6]=d):d=e[6];let h;e[7]!==i?(h=i("settings.mcp.sidebar.actions.addServerTitle"),e[7]=i,e[8]=h):h=e[8];let b,v;e[9]===Symbol.for("react.memo_cache_sentinel")?(b={touchAction:"manipulation"},v=t.jsx(Y,{name:"add",className:"size-5"}),e[9]=b,e[10]=v):(b=e[9],v=e[10]);let x;e[11]!==s||e[12]!==d||e[13]!==h?(x=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":d,title:h,style:b,children:v}),e[11]=s,e[12]=d,e[13]=h,e[14]=x):x=e[14];let S;e[15]!==i?(S=i("mcpDropdown.actions.refreshAria"),e[15]=i,e[16]=S):S=e[16];let C;e[17]!==i?(C=i("mcpDropdown.actions.refreshAria"),e[17]=i,e[18]=C):C=e[18];let R;e[19]===Symbol.for("react.memo_cache_sentinel")?(R={touchAction:"manipulation"},e[19]=R):R=e[19];const T=a&&"animate-spin";let P;e[20]!==T?(P=te("size-5",T),e[20]=T,e[21]=P):P=e[21];let k;e[22]!==P?(k=t.jsx(Y,{name:"refresh",className:P}),e[22]=P,e[23]=k):k=e[23];let j;e[24]!==a||e[25]!==g||e[26]!==k||e[27]!==S||e[28]!==C?(j=t.jsx("button",{type:"button",className:"flex size-10 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:g,disabled:a,"aria-label":S,title:C,style:R,children:k}),e[24]=a,e[25]=g,e[26]=k,e[27]=S,e[28]=C,e[29]=j):j=e[29];let y;e[30]!==j||e[31]!==x?(y=t.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-1 px-2 pt-1",children:[x,j]}),e[30]=j,e[31]=x,e[32]=y):y=e[32];let I;e[33]!==r?(I=t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(_p,{active:r,className:"h-full",listClassName:"max-h-none",hideHeader:!0,mobileListDensity:!0})}),e[33]=r,e[34]=I):I=e[34];let D;return e[35]!==y||e[36]!==I?(D=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[y,I]}),e[35]=y,e[36]=I,e[37]=D):D=e[37],D},nh=({open:n,onClose:e,tab:s,onTabChange:r,pendingChangesDiff:i,onOpenPlan:a,onOpenMcpSettings:o,variant:l="drawer"})=>{const{t:m,direction:p}=ye(),f=c.useRef(null),g=c.useRef(null),[d,h]=c.useState(!1),[b,v]=c.useState(n),x=c.useRef(e);c.useEffect(()=>{x.current=e},[e]);const S=c.useRef(s);c.useEffect(()=>{S.current=s},[s]);const C=()=>x.current();Ni(g,{enabled:l==="drawer"&&n,...p==="rtl"?{onRightEdgeSwipe:C}:{onLeftEdgeSwipe:C}});const[R,T]=c.useState(()=>new Set);if(c.useEffect(()=>{n&&T(j=>{if(j.has(s))return j;const y=new Set(j);return y.add(s),y})},[n,s]),typeof document<"u"&&!f.current){let j=document.getElementById(zo);j||(j=document.createElement("div"),j.id=zo,document.body.appendChild(j)),f.current=j}if(c.useEffect(()=>{if(n){v(!0);const y=window.setTimeout(()=>h(!0),eh);return()=>window.clearTimeout(y)}h(!1);const j=window.setTimeout(()=>v(!1),Bo+40);return()=>window.clearTimeout(j)},[n]),c.useEffect(()=>{if(!n)return;const j=document.body.style.overflow;l==="drawer"&&(document.body.style.overflow="hidden");const y=I=>{I.key!=="Escape"||S.current==="terminal"||Fc(I.target)||ei(I)||x.current()};return document.addEventListener("keydown",y),()=>{l==="drawer"&&(document.body.style.overflow=j),document.removeEventListener("keydown",y)}},[n,l]),l==="drawer"&&!f.current)return null;const P=[{id:"changes",label:m("mobile.menu.git"),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(Bc,{className:"h-3.5 w-3.5"})}],k=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",children:[t.jsx("div",{className:"flex h-9 min-w-0 flex-1 items-center",children:b?t.jsx(Lc,{items:P,activeId:s,onSelect:j=>r(j),layoutMode:"fit",variant:"active-pill",nonCompositedIndicator:!0,inactiveTabsIconOnly:!0,className:"h-full"}):null}),t.jsx("button",{type:"button",className:"-me-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":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:[R.has("changes")?t.jsx("div",{className:te("h-full",s!=="changes"&&"hidden"),children:t.jsx(Ze,{children:t.jsx(Wp,{visible:n&&s==="changes",initialDiff:i,onNavigatedToChat:e})})},i?`changes:${i.path}:${i.staged}`:"changes"):null,R.has("files")?t.jsx("div",{className:te("h-full",s!=="files"&&"hidden"),children:t.jsx(Ze,{children:t.jsx(Xp,{visible:n&&s==="files"})})}):null,R.has("terminal")?t.jsx("div",{className:te("h-full",s!=="terminal"&&"hidden"),children:t.jsx(Ze,{children:t.jsx(ed,{visible:n&&s==="terminal"})})}):null,R.has("notes")?t.jsx("div",{className:te("h-full",s!=="notes"&&"hidden"),children:t.jsx(Ze,{children:t.jsx(td,{visible:n&&s==="notes",onActionComplete:e,onOpenPlan:a})})}):null,R.has("mcp")?t.jsx("div",{className:te("h-full",s!=="mcp"&&"hidden"),children:t.jsx(Ze,{children:t.jsx(sh,{active:n&&s==="mcp",onOpenMcpSettings:o})})}):null]})]});return l==="panel"?t.jsx("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:k}):Ps.createPortal(t.jsx("section",{ref:g,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:d?"none":p==="rtl"?"translateX(-100%)":"translateX(100%)",transition:`transform ${Bo}ms ${th}`,visibility:b?"visible":"hidden",pointerEvents:n?"auto":"none"},children:k}),f.current)};function rh(n){return n.currentDirectory}function ih(n){return n.refresh}function oh(n){return n.loadMcpConfigs}function ah(n){return window.setTimeout(n,500)}function lh(n){const e=ue.c(4),s=2500,{uiFont:r}=$c(),[i,a]=c.useState(!1);let o,l;return e[0]!==s||e[1]!==r?(o=()=>{let m=!1;const p=()=>{m||a(!0)},f=()=>{requestAnimationFrame(()=>requestAnimationFrame(p))},g=Promise.all([Wc(r).catch(mh),document.fonts?.ready?.then(fh).catch(dh)??Promise.resolve(),pf.catch(uh)]).then(ch),d=new Promise(h=>{window.setTimeout(h,s)});return Promise.race([g,d]).then(f),()=>{m=!0}},l=[r,s],e[0]=s,e[1]=r,e[2]=o,e[3]=l):(o=e[2],l=e[3]),c.useEffect(o,l),i}function ch(){}function uh(){}function dh(){}function fh(){}function mh(){}const ph=ka({projectId:no().trim().min(1).optional(),text:no().optional()}),hh=ka({request:ph.nullish()}),il=ya("ShortcutRequests"),gh=async()=>{const n=hh.safeParse(await il.takePending());return n.success?n.data.request??null:null},bh=n=>{if(Hr()!=="ios")return()=>{};let e=!1,s=null;const r=()=>{gh().then(i=>{i&&n(i)}).catch(()=>{})};return il.addListener("pending",r).then(i=>{if(e){i.remove();return}s=i}).catch(()=>{}),r(),()=>{e=!0,s?.remove()}},xh="openchamber",yh=n=>n.replace(/^\/+|\/+$/g,""),vh=n=>{const e=yh(n.pathname).split("/").filter(Boolean);return n.host?[n.host,...e]:e};function wh(n){if(typeof n!="string"||n.length===0)return null;let e;try{e=new URL(n)}catch{return null}if(e.protocol!==`${xh}:`)return null;const s=vh(e),r=(s[0]??"").toLowerCase(),i=s.slice(1),a=e.searchParams;switch(r){case"session":{const o=i[0]||a.get("id")||"";if(!o)return null;const l=a.get("message")?.trim()??"";return{type:"session",sessionId:o,directory:a.get("dir")??void 0,...Vc(l)?{messageId:l}:{}}}case"new":case"new-session":return{type:"new-session",directory:a.get("dir")??void 0,projectId:a.get("project")??void 0,agent:a.get("agent")??void 0,model:a.get("model")??void 0};case"sessions":{const o=a.get("filter");return{type:"sessions",filter:o==="attention"||o==="recent"||o==="all"?o:void 0}}case"status":return{type:"status"};case"settings":return{type:"settings",section:i[0]||a.get("section")||void 0};case"changes":return{type:"changes",path:i.join("/")||a.get("path")||void 0,staged:a.get("staged")==="true"};case"view":{const o=(i[0]||"").toLowerCase();return o==="changes"?{type:"changes"}:o==="files"||o==="mcp"||o==="instances"||o==="update"?{type:"view",target:o}:null}default:return null}}let dt={},ol=!1,on=null;const jh=n=>{const e=Be.getState(),s=n.projectId?it.getState().projects.find(i=>i.id===n.projectId)??null:null;e.openNewSessionDraft(s?{selectedProjectId:s.id}:void 0);const r=n.text?.trim();if(r){if(n.projectId&&!s){Yi.getState().setPendingInputText(r,"append");return}Yi.getState().requestDraftSubmit(Be.getState().newSessionDraft.draftId,r)}},kh=n=>{switch(n.type){case"shortcut-new-session":return jh(n),!0;case"session":return n.messageId&&!n.directory?(Uc(n.sessionId,n.messageId),!0):(n.messageId&&Gc(n.sessionId,n.messageId),Be.getState().setCurrentSession(n.sessionId,n.directory??null),!0);case"new-session":{const e=Be.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 dt.openSessions?(dt.openSessions(n.filter),!0):!1;case"status":return dt.openSessions?(dt.openSessions(),!0):!1;case"view":return dt.openView?(dt.openView(n.target),!0):!1;case"changes":return dt.openChanges?(dt.openChanges({path:n.path,staged:n.staged}),!0):!1;case"settings":return dt.openSettings?(dt.openSettings(n.section),!0):!1}},Ri=()=>{if(!ol||!on)return;const n=on;on=null,kh(n)||(on=n)},qr=n=>{on=n,Ri()},Lo=n=>{const e=wh(n);e&&qr(e)},Sh=n=>{ol=n,Ri()},Nh=n=>{const e=ue.c(3);let s,r;e[0]!==n?(s=()=>(dt=n,Ri(),()=>{dt===n&&(dt={})}),r=[n],e[0]=n,e[1]=s,e[2]=r):(s=e[1],r=e[2]),c.useEffect(s,r)},Ch=n=>{const{ready:e}=n;c.useEffect(()=>{Sh(e)},[e]),c.useEffect(()=>{if(!et())return;let s=!1;const r=[];return Ts(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([130,5,55])).then(async({App:i})=>{if(s)return;const a=await i.addListener("appUrlOpen",o=>{Lo(o?.url)});if(s){a.remove();return}r.push(()=>{a.remove()})}).catch(()=>{}),r.push(bh(i=>{qr({type:"shortcut-new-session",projectId:i.projectId,text:i.text})})),Ts(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([131,55])).then(async({PushNotifications:i})=>{if(s)return;const a=await i.addListener("pushNotificationActionPerformed",o=>{const l=o?.notification?.data,m=typeof l?.url=="string"?l.url:typeof l?.deeplink=="string"?l.deeplink:void 0;if(m){Lo(m);return}const p=typeof l?.sessionId=="string"?l.sessionId:void 0;p&&qr({type:"session",sessionId:p})});if(s){a.remove();return}r.push(()=>{a.remove()})}).catch(()=>{}),()=>{s=!0,r.forEach(i=>i())}},[])},Rh=()=>{if(typeof window>"u")return;const n=window.__OPENCHAMBER_APNS_ENV__;if(n==="development")return"sandbox";if(n==="production")return"production"},Fo=/^[A-Za-z0-9+/]{43}=$/,Eh=ya("PushKey"),Ih=async()=>{const n=window.__OPENCHAMBER_PUSH_KEY__;if(n&&Fo.test(n))return n;const e=await Eh.get().then(s=>s.key).catch(()=>{});return e&&Fo.test(e)?e:void 0},Ah=()=>{if(typeof window>"u")return!1;const e=window.Capacitor?.getPlatform?.();return e==="ios"||e==="android"},Ph=n=>{const{enabled:e}=n,s=Ve(i=>i.nativeNotificationsEnabled),r=c.useRef(null);c.useEffect(()=>{if(!e||!s||!Ah())return;let i=!1;const a=[];return Ts(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([131,55])).then(async({PushNotifications:o})=>{if(i)return;let l=await o.checkPermissions().catch(()=>null);if(l?.receive!=="granted"&&(l=await o.requestPermissions().catch(()=>null)),l?.receive!=="granted")return;const m=await o.addListener("registration",f=>{r.current=f.value,Ih().then(g=>{const d=Wi(),h={token:f.value,platform:Hr(),environment:Rh()};g&&(h.pushKey=g),d?.push?.registerApnsToken?.(h)})}),p=await o.addListener("registrationError",f=>{console.warn("[Push] APNs registration error:",f)});if(await o.register().catch(()=>{}),i){m.remove(),p.remove();return}a.push(()=>{m.remove()},()=>{p.remove()})}).catch(()=>{}),()=>{i=!0,a.forEach(o=>o())}},[e,s]),c.useEffect(()=>{if(s)return;const i=r.current;if(!i)return;r.current=null,Wi()?.push?.unregisterApnsToken?.({token:i})},[s])},$o=n=>{const e=ue.c(12),{side:s,isResizing:r,ariaLabel:i,handleProps:a}=n,o=s==="left"?"inset-e-0":"inset-s-0";let l;e[0]!==o?(l=te("absolute inset-y-0 z-50 w-6 cursor-col-resize touch-none",o),e[0]=o,e[1]=l):l=e[1];const m=s==="left"?"inset-e-0":"inset-s-0",p=r&&"bg-[var(--interactive-border)]";let f;e[2]!==m||e[3]!==p?(f=te("absolute inset-y-0 w-[3px] transition-colors",m,p),e[2]=m,e[3]=p,e[4]=f):f=e[4];let g;e[5]!==f?(g=t.jsx("div",{className:f}),e[5]=f,e[6]=g):g=e[6];let d;return e[7]!==i||e[8]!==a||e[9]!==l||e[10]!==g?(d=t.jsx("div",{className:l,role:"separator","aria-orientation":"vertical","aria-label":i,...a,children:g}),e[7]=i,e[8]=a,e[9]=l,e[10]=g,e[11]=d):d=e[11],d},Th=320,Dh=380,Wo=280,Mh=560,_h=900;function Vo(n,e,s,r){const i=ue.c(23),a=r===void 0?Mh:r,o=c.useRef(null);let l;i[0]!==s||i[1]!==a||i[2]!==e?(l=()=>{if(typeof window>"u")return s;const E=Number.parseInt(window.localStorage.getItem(e)??"",10);return Number.isFinite(E)?Math.min(a,Math.max(Wo,E)):s},i[0]=s,i[1]=a,i[2]=e,i[3]=l):l=i[3];const[m,p]=c.useState(l),[f,g]=c.useState(!1),d=c.useRef(0),h=c.useRef(m),b=c.useRef(null),v=c.useRef(null);let x;i[4]!==a?(x=E=>Math.min(a,Math.max(Wo,Math.round(E))),i[4]=a,i[5]=x):x=i[5];const S=x;let C;i[6]===Symbol.for("react.memo_cache_sentinel")?(C=E=>{const M=o.current;M&&(M.style.width=`${E}px`,M.style.minWidth=`${E}px`,M.style.maxWidth=`${E}px`,M.style.setProperty("--oc-ipad-sidebar-width",`${E}px`))},i[6]=C):C=i[6];const R=C;let T;i[7]!==m?(T=E=>{try{E.currentTarget.setPointerCapture(E.pointerId)}catch{}v.current=E.pointerId,d.current=E.clientX,h.current=m,b.current=m,g(!0),E.preventDefault()},i[7]=m,i[8]=T):T=i[8];const P=T;let k;i[9]!==S||i[10]!==n?(k=E=>{if(v.current!==E.pointerId)return;const M=(n==="left"?1:-1)*(kl(E.currentTarget)?-1:1),z=S(h.current+(E.clientX-d.current)*M);b.current!==z&&(b.current=z,R(z))},i[9]=S,i[10]=n,i[11]=k):k=i[11];const j=k;let y;i[12]!==S||i[13]!==e?(y=E=>{if(v.current!==E.pointerId)return;try{E.currentTarget.releasePointerCapture(E.pointerId)}catch{}const M=S(b.current??h.current);v.current=null,b.current=null,g(!1),p(M);try{window.localStorage.setItem(e,String(M))}catch{}},i[12]=S,i[13]=e,i[14]=y):y=i[14];const I=y;let D;i[15]!==P||i[16]!==I||i[17]!==j?(D={onPointerDown:P,onPointerMove:j,onPointerUp:I,onPointerCancel:I},i[15]=P,i[16]=I,i[17]=j,i[18]=D):D=i[18];const L=D;let O;return i[19]!==L||i[20]!==f||i[21]!==m?(O={asideRef:o,width:m,isResizing:f,handleProps:L},i[19]=L,i[20]=f,i[21]=m,i[22]=O):O=i[22],O}const Oh=["general","isolated-spaces","appearance","chat","notifications","sessions","routing","git","magic-prompts","snippets","behavior","agents","commands","mcp","plugins","skills.installed","skills.catalog","providers","web-search","usage","voice","integrations","about"],zh=1e3,Bh=({onActiveConnectionDeleted:n})=>{const{t:e,direction:s}=ye();hd();const[r,i]=c.useState(!1);c.useEffect(()=>Be.subscribe((K,be)=>{K.currentSessionId&&K.currentSessionId!==be.currentSessionId&&Ve.getState().setRunOverviewKey(null)}),[]);const a=Ve(K=>K.runOverviewKey!==null);c.useEffect(()=>{a&&i(!1)},[a]);const[o,l]=c.useState(null),[m,p]=c.useState(!1),[f,g]=c.useState("changes"),[d,h]=c.useState(null),[b,v]=c.useState("nav"),[x,S]=c.useState(null),C=Ve(K=>K.setSettingsPage),R=Ve(K=>K.wideChatLayoutEnabled),T=Rs(K=>K.available),P=Rs(K=>K.runtimeType),k=c.useMemo(()=>si(),[]),j=Is(K=>K.mcpServers),y=Is(K=>K.setMcpDraft),I=Is(K=>K.setSelectedMcp),D=c.useCallback(()=>{l(null),h(null)},[]),L=c.useCallback(K=>{l(K)},[]),O=c.useCallback(()=>{p(!1)},[]),E=c.useCallback(K=>{v(K),L("settings")},[L]),{enabled:M,roomyForPanels:z}=Jr(),G=lu()==="portrait",F=cu(),[B,V]=c.useState(()=>uu().roomyForPanels),X=c.useCallback(()=>{V(K=>!K)},[]);c.useEffect(()=>{M||V(!1)},[M]);const Z=c.useCallback(()=>{S(null),g("files"),p(!0)},[]);c.useEffect(()=>Br(K=>{if(K.type!=="file-open-request")return;const be=K.directory??Mt.getState().currentDirectory;be&&(Ve.getState().openContextFile(be,K.path),Z())}),[Z]),c.useEffect(()=>Br(K=>{if(K.type!=="plan-open-request")return;const be=gd(K.directory??Mt.getState().currentDirectory,K.projectId);be&&h({id:K.planId,title:K.title,projectRef:be})}),[]);const de=c.useCallback((K=null)=>{S(K),g("changes"),p(!0)},[]),re=Vo("left","openchamber.ipad.leftSidebarWidth",Th),Q=Vo("right","openchamber.ipad.rightSidebarWidth",Dh,_h),ge=z,ee=ge&&m?Q.width:0,N=M&&B?re.width:0;c.useEffect(()=>{if(typeof document>"u")return;const K=document.documentElement;return K.style.setProperty("--oc-chat-inset-left",`${N}px`),K.style.setProperty("--oc-chat-inset-right",`${ee}px`),()=>{K.style.removeProperty("--oc-chat-inset-left"),K.style.removeProperty("--oc-chat-inset-right")}},[N,ee]),c.useEffect(()=>{if(typeof document>"u")return;const K=document.documentElement;return K.classList.toggle("wide-chat-layout",R),()=>K.classList.remove("wide-chat-layout")},[R]),c.useEffect(()=>{if(typeof document>"u")return;const K=M&&(G||F),be=document.documentElement;return be.classList.toggle("oc-keep-draft-starters",K),()=>be.classList.remove("oc-keep-draft-starters")},[F,M,G]);const $=c.useMemo(()=>({openChanges:({diffPath:K,staged:be}={})=>{de(K?{path:K,staged:be===!0}:null)},openFiles:()=>Z(),openSettings:()=>E("nav"),openSourceBoard:()=>L("board")}),[de,Z,E,L]),J=c.useMemo(()=>({openSessions:()=>{M?V(!0):i(!0)},openView:K=>{if(K==="files"){Z();return}if(K==="mcp"){g("mcp"),p(!0);return}L(K)},openChanges:({path:K,staged:be}={})=>{de(K?{path:K,staged:be===!0}:null)},openSettings:K=>{K&&C(K),E(K?"page-content":"nav")}}),[M,de,Z,E,L,C]);Nh(J);const ae=c.useRef(null),oe=()=>{M?V(!0):i(!0)},q=()=>p(!0);Ni(ae,{onLeftEdgeSwipe:s==="rtl"?q:oe,onRightEdgeSwipe:s==="rtl"?oe:q});const ne=c.useRef(null),ve=c.useCallback(K=>{ne.current=K},[]),we=c.useCallback(()=>du()?!0:d?(h(null),!0):o==="settings"&&ne.current?.()?!0:o?(D(),!0):m?(O(),!0):r?(i(!1),!0):!1,[o,D,O,d,r,m]);fu(we);const xe=!k&&T&&(P==="desktop"||P==="web"),fe=M?"dialog":"fullscreen",Ne=c.useMemo(()=>({instanceLabel:k?rs():null,onOpenInstances:k?()=>L("instances"):void 0,onOpenSettings:()=>E("nav"),onOpenUsage:()=>L("usage"),onOpenScheduled:()=>L("scheduled"),onOpenArchive:()=>L("archive"),onOpenSourceBoard:()=>L("board"),onOpenUpdate:xe?()=>L("update"):void 0}),[E,L,k,xe]),Ae=c.useCallback(K=>{D(),i(!1),K==="file"&&Z()},[D,Z]),Te=c.useCallback(()=>{D(),i(!1)},[D]),Ce=c.useCallback(()=>{D(),i(!1),M&&!z&&V(!1)},[D,M,z]),Se=c.useCallback(()=>{const K="new-mcp-server";let be=K,ie=1;for(;j.some(pe=>pe.name===be);)be=`${K}-${ie}`,ie+=1;y({name:be,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}),I(be),C("mcp"),E("page-content")},[j,E,y,I,C]);return t.jsx(mu,{actions:$,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:[M?t.jsxs("aside",{ref:re.asideRef,className:te("relative flex h-full shrink-0 flex-col overflow-hidden border-e border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!B&&"border-e-0"),style:{width:B?re.width:0,minWidth:B?re.width:0,maxWidth:B?re.width:0,"--oc-ipad-sidebar-width":`${re.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:re.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!B,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:te("flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",re.isResizing&&"pointer-events-none",!B&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Ze,{children:t.jsx(Ao,{open:!0,variant:"sidebar",onOpenChange:K=>{!K&&!z&&V(!1)},footer:Ne})})}),B?t.jsx($o,{side:"left",isResizing:re.isResizing,ariaLabel:e("sidebar.resize.leftPanelAria"),handleProps:re.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(Am,{onOpenSessions:()=>M?X():i(!0),onOpenWorkspace:()=>p(!0),compactTitle:M}),t.jsxs("main",{ref:ae,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(Ze,{children:t.jsx(bd,{})})}),t.jsx(Ze,{children:t.jsx(Rd,{})})]})]}),M?null:t.jsx(Ao,{open:r,onOpenChange:i,footer:Ne}),t.jsxs("aside",{ref:Q.asideRef,className:te("relative flex h-full shrink-0 flex-col overflow-hidden border-s border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!ee&&"border-s-0"),style:{width:ee,minWidth:ee,maxWidth:ee,"--oc-ipad-sidebar-width":`${Q.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:Q.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!ee,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:te("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",Q.isResizing&&"pointer-events-none",!ee&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Ze,{children:t.jsx(nh,{open:m,onClose:O,tab:f,onTabChange:g,pendingChangesDiff:x,onOpenPlan:h,onOpenMcpSettings:Se,variant:ge?"panel":"drawer"})})}),ee?t.jsx($o,{side:"right",isResizing:Q.isResizing,ariaLabel:e("sidebar.resize.rightPanelAria"),handleProps:Q.handleProps}):null]}),d?t.jsx(Tt,{open:!0,variant:fe,onClose:()=>h(null),ariaLabel:d.title,title:d.title,children:t.jsx(Ze,{children:t.jsx(kd,{savedProjectPlan:{projectRef:d.projectRef,planId:d.id},onNavigatedToChat:()=>{D(),O()}})})}):null,o==="instances"&&k?t.jsx(Tt,{open:!0,variant:fe,dialogAlign:"app",onClose:D,ariaLabel:e("mobile.menu.instances"),title:e("mobile.menu.instances"),children:t.jsx(_m,{onConnect:D,onActiveConnectionDeleted:n})}):null,o==="settings"?t.jsx(Tt,{open:!0,variant:fe,dialogAlign:"app",onClose:D,ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(Ze,{children:t.jsx(wd,{forceMobile:!0,isWindowed:!0,initialMobileStage:b,registerBackHandler:ve,visiblePageSlugs:[...Oh],onClose:D})})}):null,o==="usage"?t.jsx(Tt,{open:!0,variant:fe,dialogAlign:"app",onClose:D,ariaLabel:e("usageStats.title"),title:e("usageStats.title"),children:t.jsx(Ze,{children:t.jsx(Wd,{})})}):null,o==="scheduled"?t.jsx(Tt,{open:!0,variant:fe,dialogAlign:"app",onClose:D,ariaLabel:e("sessions.scheduledTasks.dialog.title"),title:e("sessions.scheduledTasks.dialog.title"),children:t.jsx(Ze,{children:t.jsx(Gd,{layout:"mobile",onLeave:Ae})})}):null,o==="board"?t.jsx(Tt,{open:!0,variant:fe,dialogAlign:"app",onClose:D,ariaLabel:e("sourceBoard.title"),headerless:!0,children:t.jsx(Ze,{children:t.jsx(Ud,{onLeave:Te,onClose:D})})}):null,o==="archive"?t.jsx(Tt,{open:!0,variant:fe,dialogAlign:"app",onClose:D,ariaLabel:e("sessions.archivePage.title"),title:e("sessions.archivePage.title"),children:t.jsx(Ze,{children:t.jsx(Vd,{layout:"mobile",onLeave:Ce})})}):null,o==="update"?t.jsx(Tt,{open:!0,variant:fe,dialogAlign:"app",onClose:D,ariaLabel:e("mobile.menu.update"),title:e("mobile.menu.update"),children:t.jsx(Ze,{children:t.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:t.jsx(jd,{initialUpdateDialogOpen:!0})})})}):null]})})};function Lh({apis:n}){const e=Ve(N=>N.isolatedSpacesEnabled),{t:s}=ye(),r=ft(N=>N.initializeApp),i=ft(N=>N.isInitialized),a=ft(N=>N.isConnected),o=ft(N=>N.connectionPhase),l=ft(N=>N.providers.length),m=ft(N=>N.agents.length),p=ft(N=>N.loadProviders),f=ft(N=>N.loadAgents),g=Mt(N=>N.currentDirectory),d=Be(N=>N.error),h=Be(N=>N.clearError),b=Ve(N=>N.setIsMobile),v=ma(N=>N.refreshAll),x=Kc(N=>N.refreshStatus),S=it(N=>N.projects),C=as(N=>N.activeSessions),R=as(N=>N.archivedSessions),T=as(N=>N.status==="ready"),P=c.useMemo(()=>[...C,...R],[C,R]);sd({hasAuthoritativeGlobalSessions:T,sessions:P});const[k,j]=c.useState(0),[y,I]=c.useState(0),[D,L]=c.useState(!1),[O,E]=c.useState("pending"),[M,z]=c.useState(null),_=c.useMemo(()=>rs(),[]),[,G]=c.useReducer(N=>N+1,0),F=c.useMemo(()=>si(),[]),B=c.useRef(0),V=c.useRef(0),X=c.useCallback(()=>{const N=kt(),$=V.current+1;if(V.current=$,!N){Zs("resume:auto-connect",{}),en();return}Zs("resume:reprobe",{});const J=()=>{r(),v(n.sourceControl,{force:!0}),x(n.linear,{force:!0}),l===0&&p({source:"mobileApp:nativeResume"}),m===0&&f({source:"mobileApp:nativeResume"})},ae=q=>{Zs("resume:disconnect",{reason:q}),Ns({apiBaseUrl:"",clientToken:null,runtimeKey:An}),j(ne=>ne+1)};Fn().then(q=>{if(V.current===$){if(q==="no-connection"){ae("no-connection");return}if(q==="needs-login"){z({kind:"auth-expired",label:rs()??""}),ae("needs-login");return}if(q==="relay-limit"){z({kind:"relay-limit",label:rs()??""}),ae("relay-limit");return}if(q==="unreachable"){const ne=[4e3,1e4],ve=we=>{window.setTimeout(()=>{if(V.current!==$)return;const xe=we===ne.length-1;Fn({fast:!xe}).then(fe=>{if(V.current===$&&fe!=="switched"){if(fe==="unchanged"){J();return}if(fe==="needs-login"){z({kind:"auth-expired",label:rs()??""}),ae("retry-needs-login");return}if(fe==="relay-limit"){z({kind:"relay-limit",label:rs()??""}),ae("retry-relay-limit");return}if(!xe){ve(we+1);return}ae(`retry-${fe}`)}})},ne[we])};ve(0);return}q!=="switched"&&J()}});const oe=Date.now();oe-B.current>=zh&&(B.current=oe,window.dispatchEvent(new Event("openchamber:system-resume")))},[m,n.sourceControl,n.linear,r,f,p,l,v,x]);qc(),Hc(X),c.useEffect(()=>{if(!F)return;let N;const $=()=>{window.clearTimeout(N),N=window.setTimeout(()=>X(),1500)};return window.addEventListener("online",$),()=>{window.removeEventListener("online",$),window.clearTimeout(N)}},[F,X]),c.useEffect(()=>{if(F)return Vi.subscribe((N,$)=>{N.state==="expired"&&$.state!=="expired"&&(X(),Vi.getState().markAuthenticated())})},[F,X]),c.useEffect(()=>{if(F)return Sl(N=>{Qn(N)&&X()})},[F,X]),c.useEffect(()=>(Ui(n),()=>Ui(null)),[n]),c.useEffect(()=>qo(N=>{if(Zs("endpoint:changed",{runtimeKey:N.runtimeKey||"none",previousRuntimeKey:N.previousRuntimeKey||"none",connected:!!N.apiBaseUrl}),!!N.runtimeKey&&N.runtimeKey===N.previousRuntimeKey){nd(),G();return}rd(N),I(J=>J+1),j(J=>J+1)}),[]),c.useEffect(()=>{if(!F||a||kt()){E("done");return}let N=!1;return E("attempting"),(async()=>{const $=await en().catch(()=>({status:"no-candidate"}));N||($.status==="unreachable"||$.status==="relay-limit"?z({kind:$.status,label:$.label}):$.status==="needs-login"&&z({kind:"auth-expired",label:$.label}),E("done"),$.status==="unreachable"&&en({fast:!1,skipIfConnected:!0}).catch(()=>null))})(),()=>{N=!0}},[]),c.useEffect(()=>{if(!F||!kt())return;let N=!1;const $=J=>{Zs("cold-launch:drop",{kind:J?.kind??"unknown"}),J&&z(J),Ns({apiBaseUrl:"",clientToken:null,runtimeKey:An}),j(ae=>ae+1)};return Fn().then(async J=>{if(N||J==="switched"||J==="unchanged")return;const ae=rs();if(J==="needs-login"){$({kind:"auth-expired",label:ae??""});return}if(J==="unreachable"){$(ae?{kind:"unreachable",label:ae}:null),en({fast:!1,skipIfConnected:!0}).catch(()=>null);return}if(J==="relay-limit"){$({kind:"relay-limit",label:ae??""});return}const oe=await en().catch(()=>({status:"no-candidate"}));N||oe.status==="connected"||(oe.status==="needs-login"?$({kind:"auth-expired",label:oe.label}):oe.status==="unreachable"||oe.status==="relay-limit"?$({kind:oe.status,label:oe.label}):$(null))}),()=>{N=!0}},[]),c.useEffect(()=>{b(!0)},[b]),c.useEffect(()=>{F&&!kt()||r()},[k,r,F]),c.useEffect(()=>{a&&(l===0&&p({source:"mobileApp:recovery"}),m===0&&f({source:"mobileApp:recovery"}))},[m,a,f,p,l]);const Z=c.useRef(!1),[de,re]=c.useState(F);c.useEffect(()=>{if(!F||!a||Z.current)return;let N=!1;const $=window.setTimeout(()=>re(!1),6e3);return(async()=>{const J=await id({refresh:!0});N||(J!=="failed"&&(Z.current=!0),re(!1))})(),()=>{N=!0,window.clearTimeout($)}},[k,a,F]),c.useEffect(()=>{a&&Gi.setDirectory(g)},[g,a]),c.useEffect(()=>{a&&(v(n.sourceControl,{force:!0}),x(n.linear,{force:!0}))},[n.sourceControl,n.linear,a,v,x]),c.useEffect(()=>{if(!a||S.length===0)return;let N=!1;return(async()=>{const J=new Map(Be.getState().availableWorktreesByProject);if(await Promise.all(S.map(async q=>{const ne=q.path.replace(/\\/g,"/").replace(/\/+$/,"");if(ne)try{if(!(ct.getState().directories.get(ne)?.isGitRepo??await Ts(()=>import("./useAppFontEffects-Cs6k0JKv.js").then(fe=>fe.nB),__vite__mapDeps([9,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83])).then(fe=>fe.checkIsGitRepository(ne))))return;const xe=await da({id:q.id,path:ne});if(N)return;J.set(ne,xe)}catch{}})),N)return;const ae=fa(S,J),oe=Be.getState().availableWorktreesByProject;ou(ae,oe)||Be.setState({availableWorktrees:[...ae.values()].flat(),availableWorktreesByProject:ae})})(),()=>{N=!0}},[a,S]),c.useEffect(()=>{if(!a)return;let N=!1;const $=Br(J=>{J.type==="worktree-changed"&&au(S,J.directories,()=>N)});return()=>{N=!0,$()}},[a,S]),c.useEffect(()=>{if(!d)return;const N=window.setTimeout(()=>h(),5e3);return()=>window.clearTimeout(N)},[h,d]),c.useEffect(()=>{if(!(!a&&(F?!!kt():!0))){L(!1);return}const $=window.setTimeout(()=>{L(!0)},F?4e3:8e3);return()=>window.clearTimeout($)},[a,F,k,y]),Jc(),Yc({enabled:!0}),od(),Xc(),Qc(),ad(),ld(g||null),cd(),Ph({enabled:F&&a}),Ch({ready:F&&a&&i});const Q=lh(),ge=!a&&o==="reconnecting";if(!Q)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(Cs,{width:120,height:120,isAnimated:!0,variant:"splash"})});const ee=!!kt();return F&&(!ee||!a&&!ge)?ee?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(Cs,{width:120,height:120,isAnimated:!D,variant:"splash"}),D?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(Ee,{type:"button",variant:"outline",onClick:()=>{Ns({apiBaseUrl:"",clientToken:null,runtimeKey:An}),j(N=>N+1)},children:s("mobile.connect.cancelPassword")})]}):null]})}):O!=="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(Cs,{width:120,height:120,isAnimated:!0,variant:"splash"}),_?t.jsxs("div",{className:"absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center",children:[t.jsx("p",{className:"typography-small text-muted-foreground",children:s("mobile.connect.splash.connectingTo")}),t.jsxs("p",{className:"typography-small text-foreground",children:[_,t.jsx(Zc,{})]})]}):null]}):t.jsx(t.Fragment,{children:t.jsx(pm,{onConnected:()=>j(N=>N+1),notice:M})}):!a&&!ge?D?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(Cs,{width:120,height:120,isAnimated:!0,variant:"splash"})}):t.jsx(Ze,{children:t.jsx(eu,{sdk:Gi.getSdkClient(),directory:g||"",children:t.jsx(tu,{apis:n,children:t.jsx(su,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[t.jsx(ud,{ready:!F||!de,animated:!0}),t.jsx(nu,{backgroundWorkEnabled:i}),t.jsx(dd,{}),t.jsx(kf,{}),t.jsx(Bh,{onActiveConnectionDeleted:()=>{nm(),Ns({apiBaseUrl:"",clientToken:null,runtimeKey:An}),j(N=>N+1)}}),t.jsx(ru,{}),t.jsx(iu,{}),e?t.jsxs(t.Fragment,{children:[t.jsx(Sd,{}),t.jsx(fd,{}),t.jsx(Nd,{}),t.jsx(md,{}),t.jsx(Cd,{})]}):null,t.jsx(If,{}),i?t.jsx(pd,{}):null]})})})},y)})}function Fh(n){const e=ue.c(7),s=c.useSyncExternalStore($h,kt,kt);let r;e[0]!==s?(r=!si()||!!s,e[0]=s,e[1]=r):r=e[1];let i;e[2]!==n?(i=t.jsx(Lh,{...n}),e[2]=n,e[3]=i):i=e[3];let a;return e[4]!==r||e[5]!==i?(a=t.jsx(xd,{enabled:r,children:i}),e[4]=r,e[5]=i,e[6]=a):a=e[6],a}function $h(n){return qo(()=>n())}function Mx(n){window.__OPENCHAMBER_SURFACE__="mobile",pu(),vd({logLabel:"[mobile-main]",onAppearanceSettled:hf}),jf(),hu();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");const r=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",i=r?{...n,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:n,a=t.jsx(Fh,{apis:i});dl.createRoot(e).render(t.jsx(Tr.StrictMode,{children:t.jsx(gu,{children:t.jsx(bu,{children:t.jsx(xu,{children:t.jsx(yd,{children:r?a:t.jsx(yu,{children:a})})})})})}))}export{Mx as renderMobileApp};