@aiworker/web 1.22.2 → 1.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/bin/cli.js +7 -0
  2. package/dist/assets/{CodeMirrorCommentWidgets-CSICpWQD.js → CodeMirrorCommentWidgets-teB3HmBT.js} +1 -1
  3. package/dist/assets/DiffView-DC9RX3MF.js +4 -0
  4. package/dist/assets/{DirtyBranchSwitchDialog-C22HdWj4.js → DirtyBranchSwitchDialog-DwPkzXsS.js} +1 -1
  5. package/dist/assets/FilesView-BFZkuu4O.js +13 -0
  6. package/dist/assets/{GitView-VQQkYuUw.js → GitView-B_x52MHY.js} +4 -4
  7. package/dist/assets/{JsonTreeView-6lrhwD3q.js → JsonTreeView-cmAzUTiw.js} +1 -1
  8. package/dist/assets/{LinearIssuesView-Ba6Q9569.js → LinearIssuesView-Dehh5afm.js} +1 -1
  9. package/dist/assets/MarkdownImageGallery-DgNOqqhE.js +1 -0
  10. package/dist/assets/MarkdownRendererImpl-DusmMZ_p.js +12 -0
  11. package/dist/assets/OnboardingScreen-B8fm1H4m.js +1 -0
  12. package/dist/assets/{PatchDiff-BzcZPlOq.js → PatchDiff-BVr7gJU0.js} +1 -1
  13. package/dist/assets/PierreDiffViewer-DzLt-nel.js +161 -0
  14. package/dist/assets/PlanView-BmQUYT_z.js +5 -0
  15. package/dist/assets/SettingsView-ChWmAcZT.js +28 -0
  16. package/dist/assets/{SettingsWindow-DDQYaKWQ.js → SettingsWindow-Dy3M6ZB9.js} +1 -1
  17. package/dist/assets/SymbolsNerdFontMono-Regular-aK5vsLov.woff2 +0 -0
  18. package/dist/assets/{ToolOutputDialog-iYF8Y2bz.js → ToolOutputDialog-cTl_eLIH.js} +5 -5
  19. package/dist/assets/{ToolPartDiffPreview-CdjbOVMM.js → ToolPartDiffPreview-C_3iYNJQ.js} +1 -1
  20. package/dist/assets/{VirtualizedFileDiff-fFFm2QgH.js → VirtualizedFileDiff-CAWthkoy.js} +4 -4
  21. package/dist/assets/WalkthroughView-C7AHOpCA.js +4 -0
  22. package/dist/assets/{computeVirtualFileMetrics-CzgLum_K.js → computeVirtualFileMetrics-BkiDSlTW.js} +2 -2
  23. package/dist/assets/contextPanelEmbeddedChat-BdA6bdky.js +1 -0
  24. package/dist/assets/de-DJsQr-p7.js +10 -0
  25. package/dist/assets/es-BuYMlA9g.js +16 -0
  26. package/dist/assets/fr-ePDay33C.js +14 -0
  27. package/dist/assets/ghostty-vt-DdA0Zryv.wasm +0 -0
  28. package/dist/assets/index-BD8ILbxF.js +40 -0
  29. package/dist/assets/{index-Bl3LSbjn.js → index-n6O3hklM.js} +1 -1
  30. package/dist/assets/index-zhgg-SDz.css +1 -0
  31. package/dist/assets/{isDiffPlainText-Dx-dB_8l.js → isDiffPlainText-GMdPz-71.js} +1 -1
  32. package/dist/assets/{isFilePlainText-CWFPwmnU.js → isFilePlainText-BVuH1zH9.js} +1 -1
  33. package/dist/assets/ja-BzR9xOY_.js +16 -0
  34. package/dist/assets/ko-BEjHAm14.js +16 -0
  35. package/dist/assets/main-BydQ1tr_.js +930 -0
  36. package/dist/assets/{main-DnBAoktx.js → main-D3ZDQglc.js} +2 -2
  37. package/dist/assets/markdownCore-Cb2MdZnV.js +5 -0
  38. package/dist/assets/{miniChat-BKyvLseN.js → miniChat-d01k801U.js} +2 -2
  39. package/dist/assets/{mobile-DKjeFgMN.js → mobile-D7VV-Ufz.js} +2 -2
  40. package/dist/assets/patchFileDiff-CdztVMz0.js +13 -0
  41. package/dist/assets/pl-rQmpxNIF.js +16 -0
  42. package/dist/assets/pt-BR-CorbsSW-.js +16 -0
  43. package/dist/assets/renderElectronMiniChatApp-BGG9UIlh.js +2 -0
  44. package/dist/assets/renderMobileApp-BRP3J1iv.js +25 -0
  45. package/dist/assets/runtimeEndpointReset-BhT_-c52.js +41 -0
  46. package/dist/assets/scheduledTasksApi-BEuUF_cj.js +1 -0
  47. package/dist/assets/{shikiHighlight-TEQCmzW8.js → shikiHighlight-BzXUjlby.js} +1 -1
  48. package/dist/assets/surface-COKb77Ua.js +1 -0
  49. package/dist/assets/tr-CoAMXPtI.js +7 -0
  50. package/dist/assets/uk-YlAX0rRU.js +16 -0
  51. package/dist/assets/{useAppFontEffects-D7sNpuL2.js → useAppFontEffects-Cwyhjfl5.js} +141 -140
  52. package/dist/assets/useGitComparison-BCZVefdE.js +1 -0
  53. package/dist/assets/useInlineCommentController-DDkpBEU8.js +2 -0
  54. package/dist/assets/useRootScrollLock-CwjoWuC4.js +1 -0
  55. package/dist/assets/{vendor-base-ui-BeMD8X_w.js → vendor-base-ui-BY_5qla_.js} +1 -1
  56. package/dist/assets/{vendor-codemirror-language-data-Dp3KMRQG.js → vendor-codemirror-language-data-Cb1YnICj.js} +2 -2
  57. package/dist/assets/vendor-legendapp-list-BuBPBC3R.js +1 -0
  58. package/dist/assets/vendor-zod-B6551dwG.js +39 -0
  59. package/dist/assets/{web-components-_mNEMjFY.js → web-components-LV3vjTxy.js} +1 -1
  60. package/dist/assets/zh-CN-DDYg0Jl7.js +16 -0
  61. package/dist/assets/zh-TW-CQKaCayr.js +16 -0
  62. package/dist/index.html +5 -43
  63. package/dist/mini-chat.html +4 -4
  64. package/dist/mobile.html +4 -4
  65. package/package.json +2 -3
  66. package/server/index.d.ts +15 -0
  67. package/server/index.js +48 -22
  68. package/server/lib/agent-memory/runtime.js +7 -2
  69. package/server/lib/agent-memory/runtime.test.js +22 -0
  70. package/server/lib/data-dir-migration.js +40 -0
  71. package/server/lib/data-dir-migration.test.js +59 -0
  72. package/server/lib/event-stream/DOCUMENTATION.md +3 -0
  73. package/server/lib/event-stream/global-hub.js +29 -4
  74. package/server/lib/event-stream/global-hub.test.js +22 -0
  75. package/server/lib/event-stream/global-ws-bridge.js +15 -18
  76. package/server/lib/event-stream/protocol.js +21 -7
  77. package/server/lib/event-stream/runtime.js +9 -6
  78. package/server/lib/event-stream/runtime.test.js +72 -12
  79. package/server/lib/fs/DOCUMENTATION.md +3 -0
  80. package/server/lib/fs/routes.js +31 -0
  81. package/server/lib/fs/routes.test.js +110 -1
  82. package/server/lib/git/DOCUMENTATION.md +39 -6
  83. package/server/lib/git/routes.js +45 -12
  84. package/server/lib/git/routes.test.js +78 -0
  85. package/server/lib/git/service.js +343 -202
  86. package/server/lib/git/service.test.js +496 -25
  87. package/server/lib/github/DOCUMENTATION.md +5 -0
  88. package/server/lib/github/routes.js +2 -2
  89. package/server/lib/inherited-env.js +16 -9
  90. package/server/lib/inherited-env.test.js +8 -9
  91. package/server/lib/message-queue/DOCUMENTATION.md +11 -1
  92. package/server/lib/message-queue/runtime.js +13 -0
  93. package/server/lib/message-queue/runtime.test.js +31 -1
  94. package/server/lib/network-defaults.js +23 -0
  95. package/server/lib/network-defaults.test.js +52 -0
  96. package/server/lib/notifications/DOCUMENTATION.md +1 -1
  97. package/server/lib/notifications/emitter-runtime.js +4 -3
  98. package/server/lib/opencode/DOCUMENTATION.md +35 -5
  99. package/server/lib/opencode/bootstrap-runtime.js +2 -0
  100. package/server/lib/opencode/env-runtime.js +5 -1
  101. package/server/lib/opencode/env-runtime.test.js +72 -0
  102. package/server/lib/opencode/feature-routes-runtime.js +17 -1
  103. package/server/lib/opencode/lifecycle.js +4 -3
  104. package/server/lib/opencode/lifecycle.test.js +29 -0
  105. package/server/lib/opencode/managed-plugin-config.js +1 -1
  106. package/server/lib/opencode/openchamber-routes.js +64 -4
  107. package/server/lib/opencode/openchamber-routes.test.js +128 -1
  108. package/server/lib/opencode/proxy.js +33 -0
  109. package/server/lib/opencode/routes.js +5 -3
  110. package/server/lib/opencode/settings-files.js +214 -0
  111. package/server/lib/opencode/settings-helpers.js +88 -41
  112. package/server/lib/opencode/settings-helpers.test.js +176 -1
  113. package/server/lib/opencode/settings-registry.json +750 -0
  114. package/server/lib/opencode/settings-runtime.js +175 -27
  115. package/server/lib/opencode/settings-runtime.test.js +321 -7
  116. package/server/lib/project-context/DOCUMENTATION.md +38 -4
  117. package/server/lib/project-context/routes.http.test.js +18 -0
  118. package/server/lib/project-context/routes.js +15 -0
  119. package/server/lib/project-context/runtime.js +256 -25
  120. package/server/lib/project-context/runtime.test.js +160 -3
  121. package/server/lib/projects/DOCUMENTATION.md +77 -0
  122. package/server/lib/projects/project-config.js +179 -17
  123. package/server/lib/projects/project-config.test.js +97 -0
  124. package/server/lib/projects/project-id.js +43 -0
  125. package/server/lib/projects/project-setup.js +409 -0
  126. package/server/lib/projects/project-setup.test.js +557 -0
  127. package/server/lib/projects/routes.js +59 -0
  128. package/server/lib/quota/DOCUMENTATION.md +31 -1
  129. package/server/lib/quota/providers/cline-pass.js +125 -0
  130. package/server/lib/quota/providers/cline-pass.test.js +103 -0
  131. package/server/lib/quota/providers/index.js +7 -0
  132. package/server/lib/quota/providers/neuralwatt.js +3 -6
  133. package/server/lib/quota/providers/neuralwatt.test.js +7 -7
  134. package/server/lib/quota/providers/ollama-cloud.js +31 -0
  135. package/server/lib/quota/providers/ollama-cloud.test.js +33 -1
  136. package/server/lib/quota/providers/opencode-go.js +1 -1
  137. package/server/lib/quota/providers/opencode-go.test.js +26 -1
  138. package/server/lib/quota/providers/openrouter.js +119 -24
  139. package/server/lib/quota/providers/openrouter.test.js +330 -0
  140. package/server/lib/relay/DOCUMENTATION.md +75 -0
  141. package/server/lib/relay/cross-compat.test.js +26 -0
  142. package/server/lib/relay/downstream-scheduler.js +154 -0
  143. package/server/lib/relay/downstream-scheduler.test.js +162 -0
  144. package/server/lib/relay/e2ee.js +10 -8
  145. package/server/lib/relay/flow-control.test.js +177 -0
  146. package/server/lib/relay/host-client.js +44 -8
  147. package/server/lib/relay/host-client.test.js +14 -0
  148. package/server/lib/relay/tunnel-codec.js +9 -0
  149. package/server/lib/relay/tunnel-host.js +66 -17
  150. package/server/lib/scheduled-tasks/DOCUMENTATION.md +9 -1
  151. package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +28 -0
  152. package/server/lib/scheduled-tasks/runtime.js +12 -2
  153. package/server/lib/scheduled-tasks/runtime.test.js +53 -0
  154. package/server/lib/session-assist/DOCUMENTATION.md +131 -66
  155. package/server/lib/session-assist/context.js +127 -0
  156. package/server/lib/session-assist/context.test.js +132 -0
  157. package/server/lib/session-assist/prompt.js +54 -0
  158. package/server/lib/session-assist/runtime.js +117 -267
  159. package/server/lib/session-assist/runtime.test.js +203 -0
  160. package/server/lib/session-goal/runtime.js +4 -9
  161. package/server/lib/small-model/DOCUMENTATION.md +3 -2
  162. package/server/lib/small-model/call.js +9 -4
  163. package/server/lib/small-model/call.test.js +29 -0
  164. package/server/lib/small-model/index.js +5 -10
  165. package/server/lib/small-model/runtime-providers.js +15 -7
  166. package/server/lib/small-model/runtime-providers.test.js +7 -1
  167. package/server/lib/terminal/DOCUMENTATION.md +4 -4
  168. package/server/lib/terminal/runtime.js +11 -6
  169. package/server/lib/terminal/runtime.test.js +20 -13
  170. package/server/lib/walkthrough/DOCUMENTATION.md +49 -20
  171. package/server/lib/walkthrough/model-settings.js +8 -12
  172. package/server/lib/walkthrough/pr-source.test.js +21 -0
  173. package/server/lib/walkthrough/prompt.js +3 -1
  174. package/server/lib/walkthrough/pull-request.js +7 -4
  175. package/server/lib/walkthrough/pull-request.test.js +16 -0
  176. package/server/lib/walkthrough/routes.js +19 -0
  177. package/server/lib/walkthrough/routes.test.js +26 -0
  178. package/server/lib/walkthrough/sources.js +36 -4
  179. package/server/opencode-worktree-readiness.test.js +130 -0
  180. package/dist/assets/DiffView-hDBKesA_.js +0 -4
  181. package/dist/assets/FilesView-CdWzeOp9.js +0 -17
  182. package/dist/assets/MarkdownImageGallery-Czv_mhvS.js +0 -1
  183. package/dist/assets/MarkdownRendererImpl-BrMcswiy.js +0 -12
  184. package/dist/assets/OnboardingScreen-ChxQoAkx.js +0 -1
  185. package/dist/assets/PierreDiffViewer-BchBtZlp.js +0 -157
  186. package/dist/assets/PlanView-DyDt_nZ_.js +0 -5
  187. package/dist/assets/SettingsView-BKf5xBsP.js +0 -28
  188. package/dist/assets/WalkthroughView-DOeCsMju.js +0 -4
  189. package/dist/assets/contextPanelEmbeddedChat-C0ZLAepL.js +0 -1
  190. package/dist/assets/de-B5JaA3SA.js +0 -10
  191. package/dist/assets/es-EPIH88ii.js +0 -16
  192. package/dist/assets/fr-CAMfxUdZ.js +0 -14
  193. package/dist/assets/index-DF5kMP-i.js +0 -39
  194. package/dist/assets/index-Dl3xbAB_.css +0 -1
  195. package/dist/assets/ja-CifOE1VN.js +0 -16
  196. package/dist/assets/ko-BBDyAyYQ.js +0 -16
  197. package/dist/assets/main-MhSaOZoB.js +0 -930
  198. package/dist/assets/markdownCore-BrBwOOMn.js +0 -3
  199. package/dist/assets/patchFileDiff-o8ms1me8.js +0 -10
  200. package/dist/assets/pl-DgEHYfFM.js +0 -16
  201. package/dist/assets/pt-BR-DuWHojUw.js +0 -16
  202. package/dist/assets/renderElectronMiniChatApp-CDgBwwCS.js +0 -2
  203. package/dist/assets/renderMobileApp-DJIKIK1r.js +0 -25
  204. package/dist/assets/runtimeEndpointReset-CYJ9O_xX.js +0 -17
  205. package/dist/assets/scheduledTasksApi-D8yamh1b.js +0 -1
  206. package/dist/assets/tr-D5m2yIWL.js +0 -7
  207. package/dist/assets/uk-D_q60oog.js +0 -16
  208. package/dist/assets/useInlineCommentController-Brz_cLcQ.js +0 -2
  209. package/dist/assets/useRootScrollLock-lXEnWlaU.js +0 -1
  210. package/dist/assets/vendor-ghostty-web-CrxinGGH.js +0 -13
  211. package/dist/assets/vendor-legendapp-list-gg7YLRW7.js +0 -1
  212. package/dist/assets/vendor-zod-CK21ihK-.js +0 -39
  213. package/dist/assets/zh-CN-D8QvsVeg.js +0 -16
  214. package/dist/assets/zh-TW-B9t7rQQO.js +0 -16
  215. package/server/lib/mcp-reconnect/DOCUMENTATION.md +0 -55
  216. package/server/lib/mcp-reconnect/runtime.js +0 -122
  217. package/server/lib/mcp-reconnect/runtime.test.js +0 -140
@@ -0,0 +1,25 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesView-BFZkuu4O.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-BD8ILbxF.js","assets/vendor-zod-B6551dwG.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/index-zhgg-SDz.css","assets/useAppFontEffects-Cwyhjfl5.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-BY_5qla_.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-framer-motion-livSKyyV.js","assets/vendor-motion-dom-D_o3BTI3.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-g05Cx3z9.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/contextPanelEmbeddedChat-BdA6bdky.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BgPj_McA.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-DzPz9Wgq.js","assets/vendor-codemirror-lang-json-CMBS2tG9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-O0cZX78y.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CfgK872x.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-BPGOH9ye.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-Cb1YnICj.js","assets/vendor-codemirror-lang-python-HahnQaAS.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-B7H_j0iU.js","assets/vendor-legendapp-list-BuBPBC3R.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/runtimeEndpointReset-BhT_-c52.js","assets/shikiHighlight-BzXUjlby.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-cmAzUTiw.js","assets/web-components-LV3vjTxy.js","assets/computeVirtualFileMetrics-BkiDSlTW.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-BVuH1zH9.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/Virtualizer-D_a8gKmg.js","assets/scheduledTasksApi-BEuUF_cj.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/useInlineCommentController-DDkpBEU8.js","assets/CodeMirrorCommentWidgets-teB3HmBT.js","assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/vendor-capacitor-push-notifications-KNe1zSBF.js"])))=>i.map(i=>d[i]);
2
+ import{f as ce,r as on,j as t,R as c,c as Bt,h as Mo}from"./vendor-react-BUCujlKS.js";import{u as it,a as Vt,b as Or,d as Gn,i as Me,e as ot,s as Dt,f as ds,h as mn,j as zo,k as Br,l as Oo,p as Bo,m as Lo,n as vt,o as Kn,q as $o,t as Fo,v as Hn,x as qn,y as Jn,z as Wo,A as Yn,M as Ss,B as Uo,C as Vo}from"./index-BD8ILbxF.js";import{u as pn,a as Go,b as We,c as Lr,d as $r,r as hn,e as Ko,f as fe,t as ae,o as Ho,I as Q,B as he,g as qo,O as bt,h as X,P as Jo,i as Yo,j as Xo,k as Qo,l as qe,m as Zo,n as gt,p as ei,q as Xn,s as ti,v as gn,w as si,x as ni,y as Ee,z as ri,A as Fr,C as Wr,D as Ur,E as oi,F as bn,G as ii,H as Vr,J as Ke,K as Gr,L as ai,M as li,N as ci,Q as Kr,R as Hr,S as qr,T as Jr,U as Yr,V as xn,W as ui,X as di,Y as yn,Z as fi,_ as mi,$ as Qt,a0 as Xs,a1 as pi,a2 as Xr,a3 as hi,a4 as Bs,a5 as Qr,a6 as Zr,a7 as ss,a8 as zt,a9 as gi,aa as bi,ab as xi,ac as yi,ad as vi,ae as vn,af as wi,ag as ji,ah as ki,ai as Si,aj as Ni,ak as Ci,al as Ei,am as Ri,an as Qn,ao as Pi,ap as Ai,aq as Ti,ar as Ii,as as Di,at as Ns,au as _i,av as Mi,aw as eo,ax as Je,ay as zi,az as Oi,aA as Bi,aB as Li,aC as $i,aD as Fi,aE as to,aF as Wi,aG as Ui,aH as Vi,aI as Gi,aJ as Ki,aK as Hi,aL as qi,aM as Ji,aN as Yi,aO as Xi,aP as Qi,aQ as Zi,aR as ea,aS as ta,aT as sa,aU as na,aV as ra,aW as oa,aX as ia,aY as aa,aZ as la,a_ as ca,a$ as ua,b0 as da,b1 as fa,b2 as ma,b3 as pa,b4 as ha,b5 as ga,b6 as ba,b7 as xa,b8 as ya,b9 as va,ba as wa}from"./useAppFontEffects-Cwyhjfl5.js";import{u as _t,S as so,s as ja,p as ka,D as Sa,N as Na,a as Ca,h as Ea,b as Ra,B as Pa,c as Aa,d as Ta,e as Ia,f as Da,T as _a,P as Ma,r as za,g as Oa,i as Ba,j as La,O as $a,C as Fa,k as Wa,l as Ua,m as Va}from"./runtimeEndpointReset-BhT_-c52.js";import{_ as Lt}from"./vendor-vite-runtime-DD1OZmLC.js";import{S as Ga,A as Ka}from"./SettingsView-ChWmAcZT.js";import{PlanView as Ha}from"./PlanView-BmQUYT_z.js";import{p as qa}from"./vendor-aparajita-capacitor-secure-storage-5IShChL0.js";import{Capacitor as Ja}from"./vendor-capacitor-core-B4EWRrHz.js";import{k as an,s as no,M as wn,a as Is,J as ln,p as Ya,_ as Zn,b as ro,P as oo,d as Xa,f as jn,V as Qa,K as er,c as Za,Q as el,r as tl,U as sl,Z as nl}from"./vendor-remixicon-react-Dil0zKKT.js";import{f as kn,h as $t,i as Sn,P as Nn,D as Cn,j as En}from"./vendor-dnd-kit-core-BZknOX2w.js";import{s as Rn,S as Pn,v as An,u as Tn}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as In}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{c as Dn,p as io}from"./vendor-zustand-BAGL70zf.js";import{toast as tr}from"./vendor-sonner-DFyL3AvE.js";import{C as rl,a as ol,D as il}from"./DirtyBranchSwitchDialog-DwPkzXsS.js";import{u as al,a as ll,b as cl,c as ul,i as dl,f as fl,B as ml,C as pl,P as sr}from"./patchFileDiff-CdztVMz0.js";import{u as hl,a as gl,i as bl,b as xl}from"./useGitComparison-BCZVefdE.js";import{P as yl}from"./PierreDiffViewer-DzLt-nel.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-B6551dwG.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-BY_5qla_.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-framer-motion-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./contextPanelEmbeddedChat-BdA6bdky.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-Cb1YnICj.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-yaml-3778uTud.js";import"./shikiHighlight-BzXUjlby.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-qrcode-DTJ12-WC.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./useInlineCommentController-DDkpBEU8.js";import"./CodeMirrorCommentWidgets-teB3HmBT.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./VirtualizedFileDiff-CAWthkoy.js";import"./web-components-LV3vjTxy.js";import"./computeVirtualFileMetrics-BkiDSlTW.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-GMdPz-71.js";import"./vendor-diff-C3JhlQdm.js";import"./Virtualizer-D_a8gKmg.js";let ao=null,nr=!1;const vl=new Promise(n=>{ao=n});function wl(){nr||(nr=!0,ao?.())}const jl=6,kl=n=>n.parentID??null,rr=n=>{const e=n.replace(/\/+$/,"");return e.slice(e.lastIndexOf("/")+1)||e},Sl=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),Nl=(n,e)=>{if(!n)return"";let s=null,o=-1;for(const r of e){const i=Sl(r.path);(n===i||n.startsWith(`${i}/`))&&i.length>o&&(s=r,o=i.length)}return s?s.label?.trim()||rr(s.path):rr(n)},Cl=()=>{const n=pn.getState().activeSessions,e=Go.getState().index.session.unseenCount,s=it.getState().notifyOnSubtasks,o=We.getState().projects,r=Lr.getState().ids,i=$r.getState().rankById;let a=0;const u=[];for(const d of n){const l=kl(d)!==null,g=(e[d.id]??0)>0&&(!l||s);g&&(a+=1),l||u.push({session:d,unread:g,project:Nl(hn(d),o)})}u.sort((d,l)=>Ko(d.session,l.session,r,i));const f=u.slice(0,jl).map(({session:d,unread:l,project:p})=>({id:d.id,title:d.title??"",unread:l,project:p}));return{runtimeKey:Vt(),attentionCount:a,recentSessions:f}},El="__AIWORKER_WIDGET_SNAPSHOT__",Rl=()=>{typeof window>"u"||(window[El]=()=>{try{return JSON.stringify(Cl())}catch{return null}})},Qs="mobile-app-update-available",or="mobile-app-update-toast-dismissed-version",Pl=()=>{const n=ce.c(8),{t:e}=fe(),s=_t(Al),o=_t(Tl),r=_t(Il),i=_t(Dl);let a;n[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Set,n[0]=a):a=n[0];const u=on.useRef(a);let f,d;return n[1]!==s||n[2]!==i||n[3]!==o||n[4]!==e||n[5]!==r?(f=()=>{if(Or()!=="android"||o!=="mobile"||!s||!r||!i){ae.dismiss(Qs);return}Gn().getItem(or)!==r&&(u.current.has(r)||(u.current.add(r),ae.info(e("mobileUpdate.toast.available.title"),{id:Qs,description:e("mobileUpdate.toast.available.description",{version:r}),duration:1/0,icon:t.jsx(Q,{name:"download",className:"h-4 w-4 text-muted-foreground"}),action:{label:e("mobileUpdate.toast.actions.download"),onClick:()=>{Ho(i)}},cancel:{label:e("mobileUpdate.toast.actions.dismiss"),onClick:()=>{Gn().setItem(or,r),ae.dismiss(Qs)}}})))},d=[s,i,o,e,r],n[1]=s,n[2]=i,n[3]=o,n[4]=e,n[5]=r,n[6]=f,n[7]=d):(f=n[6],d=n[7]),on.useEffect(f,d),null};function Al(n){return n.available}function Tl(n){return n.runtimeType}function Il(n){return n.info?.version}function Dl(n){return n.info?.downloadUrl}const ir=300,_l="aiworker.mobile.connectLog.v1",Mt=[];if(typeof window<"u")try{window.localStorage.removeItem(_l)}catch{}const _n=(n,e)=>{Mt.push({at:Date.now(),step:n,detail:e}),Mt.length>ir&&Mt.splice(0,Mt.length-ir)};typeof window<"u"&&_n("app:launch","{}");const Ml=()=>[...Mt],zl=n=>{const e=new Date(n),s=(o,r=2)=>String(o).padStart(r,"0");return`${s(e.getHours())}:${s(e.getMinutes())}:${s(e.getSeconds())}.${s(e.getMilliseconds(),3)}`},lo=n=>`${zl(n.at)} ${n.step}${n.detail&&n.detail!=="{}"?` ${n.detail}`:""}`,Ol=()=>Mt.map(lo).join(`
3
+ `),co=(n,e)=>{const s=ce.c(10),o=700,r=c.useRef(null),i=c.useRef(null),a=c.useRef(!1);let u;s[0]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{r.current!==null&&window.clearTimeout(r.current),r.current=null,i.current=null},s[0]=u):u=s[0];const f=u;let d,l;s[1]===Symbol.for("react.memo_cache_sentinel")?(d=()=>f,l=[f],s[1]=d,s[2]=l):(d=s[1],l=s[2]),c.useEffect(d,l);let p;s[3]!==o||s[4]!==n?(p=S=>{a.current=!1,i.current={x:S.clientX,y:S.clientY},r.current!==null&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{r.current=null,a.current=!0,n()},o)},s[3]=o,s[4]=n,s[5]=p):p=s[5];const g=p;let h;s[6]===Symbol.for("react.memo_cache_sentinel")?(h=S=>{const E=i.current;E&&(Math.abs(S.clientX-E.x)>10||Math.abs(S.clientY-E.y)>10)&&f()},s[6]=h):h=s[6];const x=h;let j;s[7]===Symbol.for("react.memo_cache_sentinel")?(j=S=>{a.current&&(a.current=!1,S.preventDefault(),S.stopPropagation())},s[7]=j):j=s[7];const v=j;let T;return s[8]!==g?(T={onPointerDown:g,onPointerMove:x,onPointerUp:f,onPointerCancel:f,onClickCapture:v},s[8]=g,s[9]=T):T=s[9],T},Ds="aiworker.mobile.connections.v1",Bl="aiworker.mobile.",ar="aiworker.mobile.deviceId",Ll=()=>{try{const n=window.localStorage.getItem(ar);if(n&&n.trim())return n.trim();const e=crypto.randomUUID();return window.localStorage.setItem(ar,e),e}catch{return crypto.randomUUID()}},lr=()=>`mobile:${Ll()}`,cr=()=>{try{const n=Ja.getPlatform();return n==="ios"||n==="android"?n:void 0}catch{return}},uo=12,fo=8e3,$l=2500,Fl=3e3,_s=2500,Wl=()=>{let n=0;return{begin:()=>(n+=1,n),cancel:()=>{n+=1},isCurrent:e=>e===n}},Gt=n=>{const e=n.trim();if(!e)return"";const s=/^https?:\/\//i.test(e)?e:`http://${e}`,o=new URL(s);return o.hash="",o.search="",o.pathname=o.pathname.replace(/\/+$/,""),o.toString().replace(/\/+$/,"")},Ps=n=>{try{return new URL(n).host}catch{return n}},Ft=n=>{try{return Gt(n)}catch{return n.trim().replace(/\/+$/g,"")}},mo=(n,e)=>Ft(n)===Ft(e),po=n=>`relay:${n.serverId}@${n.relayUrl.trim()}`,Ul=n=>`relay://${n.serverId}`,Ls=n=>n.candidates.filter(e=>e.kind==="direct"),wt=n=>{const e=n.candidates.find(s=>s.kind==="relay");return e&&e.kind==="relay"?e.relay:null},at=n=>{const e=Ls(n)[0];if(e)return e.url;const s=wt(n);return s?Ul(s):""},De=n=>{const e=wt(n);if(e)return po(e);const s=Ls(n)[0];return s?Ft(s.url):""},Ms=(n,e)=>{const s=n.find(i=>i.kind==="relay"),o=s&&s.kind==="relay"?s.relay.serverId:null,r=new Set(n.filter(i=>i.kind==="direct").map(i=>Ft(i.url)));return e.some(i=>i.kind==="relay"?o!==null&&i.relay.serverId===o:r.has(Ft(i.url)))},Mn=n=>{const e=(()=>{try{return Gt(n)}catch{return""}})();return e?[{kind:"direct",url:e}]:[]},ur=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(...Mn(n.url)),n.relay&&e.push({kind:"relay",relay:n.relay}),e},zn=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 o=s;return o.kty!=="EC"||o.crv!=="P-256"||typeof o.x!="string"||!o.x||typeof o.y!="string"||!o.y?null:{relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:{kty:"EC",crv:"P-256",x:o.x,y:o.y}}},ho=n=>{try{return JSON.stringify(n)}catch{return String(n)}},be=(n,e={})=>{const s=ho(e);console.info("[mobile-connect]",n,s),_n(n,s)},Zt=(n,e={})=>{be(n,e)},Wt=(n,e={})=>{const s=ho(e);console.info("[mobile-storage]",n,s),_n(n,s)},Vl=n=>{if(typeof n!="string")return n;try{return JSON.parse(n)}catch{return n}},Gl=n=>{if(typeof n!="string")return n??void 0;try{return JSON.parse(n)}catch{return n}},Kl=async(n,e)=>{if(!Me())return null;try{const{CapacitorHttp:s}=await Lt(async()=>{const{CapacitorHttp:i}=await import("./vendor-capacitor-core-B4EWRrHz.js");return{CapacitorHttp:i}},[]),o=Oo(n,new Headers(e?.headers)),r=await s.request({url:n,method:e?.method||"GET",headers:Object.fromEntries(o.entries()),data:Gl(e?.body)});return{ok:r.status>=200&&r.status<300,status:r.status,source:"native-http",json:async()=>Vl(r.data)}}catch(s){return be("native-http:failed",{url:n,error:s instanceof Error?s.message:String(s)}),null}},Hl=async(n,e)=>{const s=await fetch(n,e).catch(o=>(be("browser-fetch:failed",{url:n,error:o instanceof Error?o.message:String(o)}),null));return s?{ok:s.ok,status:s.status,source:"browser-fetch",json:()=>s.json()}:null},ft=async(n,e,s)=>{let o;const r=new Promise(i=>{o=window.setTimeout(()=>{s?.(),i(null)},n)});try{return await Promise.race([e,r])}catch{return null}finally{o!==void 0&&window.clearTimeout(o)}},jt=async(n,e,s)=>{const o=s?.totalTimeoutMs??fo,r=Date.now(),i=await ft(Math.min($l,o),Kl(n,e));if(i)return i;const a=new AbortController,u=Math.max(500,o-(Date.now()-r));return ft(u,Hl(n,{...e,signal:a.signal}),()=>a.abort())},$s=async n=>{if(!n)return null;const e=await n.json().catch(()=>null);if(!e||typeof e!="object")return null;const s=e;return{authenticated:typeof s.authenticated=="boolean"?s.authenticated:void 0,disabled:typeof s.disabled=="boolean"?s.disabled:void 0,scope:typeof s.scope=="string"?s.scope:void 0}},Ut=15e3,ql=async(n,e,s,o=Ut,r)=>{const i=Br({relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk}),a=u=>u==="ok"&&r?.keepTunnel?{outcome:u,tunnel:i}:(i.close(),{outcome:u});try{const u=e?{Authorization:`Bearer ${e}`}:void 0,f=await ft(o,i.fetch("/auth/session",{headers:u}).catch(()=>null));if(be("relay:session",{ok:f?.ok===!0,status:f?.status??null,hasToken:!!e}),!f)return a("unreachable");if(f.status===401)return a(e?"auth-failed":"needs-login");if(!f.ok&&f.status!==404)return a("auth-failed");const d=await $s(f);return d&&d.disabled!==!0&&d.authenticated===!1?a(e?"auth-failed":"needs-login"):a("ok")}catch(u){throw i.close(),u}},Jl=(n,e,s,o,r)=>{const i=typeof window<"u"?window.location.origin:"",a={relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk,...s?{grant:s}:{}};r&&zo(a,r),Dt({apiBaseUrl:i,clientToken:e,runtimeKey:o??po(n),relay:a})},Yl=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=zn(e.relay);return s?{kind:"relay",relay:s}:null}return null},Xl=n=>{if(n.mode==="relay"){const e=zn(n.relay);return e?[{kind:"relay",relay:e}]:[]}return typeof n.url=="string"?Mn(n.url):[]},St=()=>{if(typeof window>"u")return[];let n;try{n=JSON.parse(window.localStorage.getItem(Ds)||"[]")}catch{return[]}if(!Array.isArray(n))return[];const e=Me();return n.flatMap(s=>{if(!s||typeof s!="object")return[];const o=s;if(typeof o.id!="string")return[];const r=Array.isArray(o.candidates)?o.candidates.map(Yl).filter(f=>!!f):Xl(o);if(r.length===0)return[];const i=typeof o.clientToken=="string"&&o.clientToken.trim()?o.clientToken:void 0,a=typeof o.label=="string"&&o.label.trim()?o.label:Ps(at({candidates:r})),u={id:o.id,label:a,candidates:r,lastUsedAt:typeof o.lastUsedAt=="number"?o.lastUsedAt:0};return e?[{...u,hasToken:!!o.hasToken||!!i}]:[{...u,clientToken:i,hasToken:!!i}]}).sort((s,o)=>o.lastUsedAt-s.lastUsedAt)},cn=n=>n.kind==="relay"?{kind:"relay",relay:{relayUrl:n.relay.relayUrl,serverId:n.relay.serverId,hostEncPubJwk:n.relay.hostEncPubJwk}}:{kind:"direct",url:n.url},On=n=>{if(typeof window>"u")return;const e=Me(),s=n.slice(0,uo).map(o=>{const r={id:o.id,label:o.label,candidates:o.candidates.map(cn),lastUsedAt:o.lastUsedAt};return e?{...r,hasToken:!!(o.hasToken||o.clientToken)}:{...r,clientToken:o.clientToken}});try{window.localStorage.setItem(Ds,JSON.stringify(s))}catch(o){console.warn("[mobile-storage] failed to persist connection metadata",o)}},go=(n,e)=>{const s=n.find(i=>e.id&&i.id===e.id||Ms(i.candidates,e.candidates)),o=Me(),r={id:e.id||s?.id||crypto.randomUUID(),label:e.label,candidates:e.candidates,lastUsedAt:Date.now(),...o?{hasToken:e.hasToken??(!!e.clientToken||s?.hasToken||!1)}:{clientToken:e.clientToken??s?.clientToken,hasToken:!!(e.clientToken??s?.clientToken)}};return[r,...n.filter(i=>i.id!==r.id&&!Ms(i.candidates,e.candidates))].slice(0,uo)},Bn=qa,Ql=0,Ln=n=>`${Bl}token.${encodeURIComponent(n)}`,Zl=async(n,e)=>{let s;const o=new Promise(r=>{s=window.setTimeout(()=>r(e),Fl)});try{return await Promise.race([n.catch(()=>e),o])}finally{s!==void 0&&window.clearTimeout(s)}},$n=async(n,e,s)=>Me()?Zl(e().catch(o=>(console.warn(`[mobile-storage] ${n} failed`,o),s)),s):s,fs=async n=>{Wt("secure:read-start",{key:n});const e=await $n("secure:read",async()=>(await Bn.internalGetItem({prefixedKey:Ln(n),sync:!1})).data,null),s=typeof e=="string"&&e.trim()?e:void 0;return Wt("secure:read",{key:n,hasToken:!!s}),s},xt=async(n,e)=>{Wt("secure:write-start",{key:n});const s=await $n("secure:write",async()=>(await Bn.internalSetItem({prefixedKey:Ln(n),data:e,sync:!1,access:Ql}),!0),!1);return Wt("secure:write",{key:n,ok:s}),s},ec=async n=>{await $n("secure:delete",async()=>(await Bn.internalRemoveItem({prefixedKey:Ln(n),sync:!1}),!0),!1)},tc=async(n,e)=>{let s=0,o=0;return{records:await Promise.all(n.map(async i=>{if(!i||typeof i!="object")return i;const a=i,u=typeof a.url=="string"?a.url:null,f=typeof a.clientToken=="string"?a.clientToken.trim():"";if(!u||!f)return i;if(!await e(u,f))return o+=1,i;s+=1;const{clientToken:d,...l}=a;return{...l,hasToken:!0}})),migrated:s,failed:o}},bo=async()=>{if(typeof window>"u"||!Me())return;let n;try{n=JSON.parse(window.localStorage.getItem(Ds)||"[]")}catch{return}if(!Array.isArray(n))return;const e=n.filter(o=>!!o&&typeof o=="object"&&typeof o.url=="string"&&typeof o.clientToken=="string"&&!!o.clientToken.trim());if(e.length===0)return;Wt("secure:migrate-start",{count:e.length});const s=await tc(n,async(o,r)=>{const i=Ft(o);return await xt(i,r)?await fs(i)===r:!1});if(s.migrated>0)try{window.localStorage.setItem(Ds,JSON.stringify(s.records))}catch(o){console.warn("[mobile-storage] failed to finalize secure token migration",o);return}Wt("secure:migrate-done",{migrated:s.migrated,failed:s.failed})},sc=async()=>(await bo(),St()),zs=async n=>{const e=go(St(),n);return On(e),Me()&&n.clientToken&&await xt(De({candidates:n.candidates}),n.clientToken),e},nc=async n=>{const e=St(),s=e.find(r=>r.id===n)??null,o=e.filter(r=>r.id!==n);return On(o),s&&Me()&&await ec(De(s)),o},rc=1500,Os=async(n,e,s)=>{const o=s?.fast?{totalTimeoutMs:_s}:void 0,r=wt({candidates:n})?.serverId??null,i=n.find(d=>d.kind==="relay")??null,a=n.filter(d=>d.kind==="direct"),u=async()=>{for(const d of a){const l=Gt(d.url)||d.url,p=e?{Authorization:`Bearer ${e}`}:void 0,g=await jt(`${l}/health`,{method:"GET"},o);if(be("probe:direct:health",{url:l,ok:g?.ok===!0,status:g?.status??null,source:g?.source??null}),!g?.ok)continue;if(r){const v=await g.json().catch(()=>null),T=v&&typeof v=="object"?v.serverId:null;if(typeof T=="string"&&T&&T!==r){be("probe:server-id-mismatch",{url:l});continue}}const h=await jt(`${l}/auth/session`,{method:"GET",credentials:e?"omit":"include",headers:p},o);if(be("probe:direct:session",{url:l,ok:h?.ok===!0,status:h?.status??null,source:h?.source??null,hasToken:!!e}),h?.status===401)return{status:"needs-login"};if(!h||!h.ok&&h.status!==404)continue;const x=await $s(h);if(x&&x.disabled!==!0&&x.authenticated===!1)return{status:"needs-login"};const j=x?.disabled===!0;return!e&&Me()&&!j&&x?.scope!=="client"?{status:"needs-login"}:{status:"ok",transport:{kind:"direct",url:l}}}return{status:"unreachable"}},f=async()=>{if(!i)return{status:"unreachable"};const{outcome:d,tunnel:l}=await ql(i.relay,e,void 0,s?.fast?_s:fo,{keepTunnel:!0});return d==="ok"?{status:"ok",transport:{kind:"relay",relay:i.relay,tunnel:l}}:d==="needs-login"||d==="auth-failed"?{status:"needs-login"}:{status:"unreachable"}};return i?a.length===0?f():new Promise(d=>{let l=!1,p=!1,g,h=null,x=null;const j=S=>{S?.status==="ok"&&S.transport.kind==="relay"&&S.transport.tunnel?.close()},v=S=>{l||(l=!0,d(S))},T=()=>{p||l||(g!==void 0&&(window.clearTimeout(g),g=void 0),f().then(S=>{if(x=S,l||p){j(S);return}if(S.status==="ok"||S.status==="needs-login"){v(S);return}h&&v(h)}))};u().then(S=>{if(h=S,!l){if(S.status==="ok"||S.status==="needs-login"){p=!0,g!==void 0&&window.clearTimeout(g),j(x),v(S);return}if(x){v(x);return}T()}}),g=window.setTimeout(T,rc)}):u()},yt=(n,e,s)=>{n.kind==="relay"?Jl(n.relay,e,s?.grant,s?.runtimeKey,n.tunnel):Dt({apiBaseUrl:n.url,clientToken:e,runtimeKey:s?.runtimeKey}),yo()},ns=()=>{const n=St()[0];return n?.label?.trim()?n.label:null},es=async n=>{const e=n?.fast!==!1;await bo();const s=St()[0];if(be("auto-connect:start",{hasCandidate:!!s,fast:e}),!s)return{status:"no-candidate"};let o;if(Me()){if(s.hasToken&&(o=await fs(De(s)),!o))return{status:"no-candidate"}}else if(o=s.clientToken,!o&&s.hasToken)return{status:"no-candidate"};const r=await Os(s.candidates,o,{fast:e});return be("auto-connect:probe",{status:r.status,candidates:s.candidates.map(i=>i.kind)}),r.status==="needs-login"?{status:"needs-login",label:s.label}:r.status!=="ok"?{status:"unreachable",label:s.label}:n?.skipIfConnected&&ot()?(r.transport.kind==="relay"&&r.transport.tunnel?.close(),be("auto-connect:superseded",{}),{status:"no-candidate"}):(await zs({id:s.id,label:s.label,candidates:s.candidates}),yt(r.transport,o??null,{runtimeKey:De(s)}),{status:"connected"})},oc=async(n,e)=>{let s="";try{s=Gt(n.url)}catch{return!1}if(!s)return!1;const o=n.clientToken?.trim()||void 0,r=o?{Authorization:`Bearer ${o}`}:void 0,i=e?.fast?{totalTimeoutMs:_s}:void 0;if(!(await jt(`${s}/health`,{method:"GET",headers:r},i))?.ok)return!1;const u=await jt(`${s}/auth/session`,{method:"GET",credentials:o?"omit":"include",headers:r},i);if(!u||!u.ok&&u.status!==404)return!1;const f=await $s(u);return!(f&&f.disabled!==!0&&f.authenticated===!1)},ic=n=>[...n].sort((e,s)=>{const o=(e.priority??100)-(s.priority??100);if(o!==0)return o;const r=i=>i.type==="relay"?2:i.url.startsWith("https://")?0:1;return r(e)-r(s)}).flatMap(e=>{if(e.type==="relay"){const s=zn({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk});return s?[{kind:"relay",relay:s}]:[]}return Mn(e.url)}),dr=async n=>{const e=wt({candidates:n})?.serverId??null;for(const s of n){if(s.kind==="relay"){const i=Br(s.relay),a=await ft(Ut,i.fetch("/health").catch(()=>null));if(be("establish:relay:health",{ok:a?.ok===!0,status:a?.status??null}),a?.ok)return{kind:"relay",relay:s.relay,tunnel:i};i.close();continue}const o=Gt(s.url)||s.url,r=await jt(`${o}/health`,{method:"GET"});if(be("establish:direct:health",{ok:r?.ok===!0,status:r?.status??null}),!!r?.ok){if(e){const i=await r.json().catch(()=>null),a=i&&typeof i=="object"?i.serverId:null;if(typeof a=="string"&&a&&a!==e){be("establish:server-id-mismatch",{url:o});continue}}return{kind:"direct",url:o}}}return null},ac=async(n,e)=>{if(!ds())return oc(n,e);const s=await ft(e?.fast?_s:Ut,mn("/auth/session").then(r=>r).catch(()=>null));if(!s)return!0;if(s.status===401)return!1;if(!s.ok&&s.status!==404)return!0;const o=await $s(s);return!(o&&o.disabled!==!0&&o.authenticated===!1)},lc=n=>n.kind==="relay"?ds():!ds()&&mo(n.url,ot()),xo=()=>{const n=Vt();return n?St().find(e=>De(e)===n)??null:null},fr=n=>{const e=Vt();return!!e&&De(n)===e},As=async n=>{const e=n?.fast!==!1,s=xo();if(!s)return be("reprobe:no-connection",{runtimeKey:!!Vt()}),"no-connection";let o;if(Me()?o=s.hasToken?await fs(De(s)):void 0:o=s.clientToken,!o&&s.hasToken)return be("reprobe:no-token",{hasToken:!0}),"unreachable";be("reprobe:start",{candidates:s.candidates.map(d=>d.kind),fast:e,hasToken:!!o});const r=s.candidates.findIndex(d=>lc(d.kind==="relay"?{kind:"relay",relay:d.relay}:{kind:"direct",url:d.url})),i=r>=0?s.candidates.slice(0,r):s.candidates,a=await Os(i,o,{fast:e});if(be("reprobe:better",{status:a.status,probed:i.length}),a.status==="ok")return await zs({id:s.id,label:s.label,candidates:s.candidates}),yt(a.transport,o??null,{runtimeKey:De(s)}),"switched";if(a.status==="needs-login")return"needs-login";if(r>=0){const d=await ac({url:ot(),clientToken:o},{fast:e});if(be("reprobe:current",{stillValid:d}),d)return yo(),"unchanged"}const u=r>=0?s.candidates.slice(r+1):[],f=await Os(u,o,{fast:e});return be("reprobe:fallback",{status:f.status,probed:u.length}),f.status==="ok"?(await zs({id:s.id,label:s.label,candidates:s.candidates}),yt(f.transport,o??null,{runtimeKey:De(s)}),"switched"):f.status==="needs-login"?"needs-login":"unreachable"},cc=5e3;let Zs=!1;const uc=async()=>{if(Zs)return"skipped";const n=xo();if(!n)return be("candidates:refresh-skip",{reason:"no-active-connection"}),"skipped";const e=wt(n);if(!e)return be("candidates:refresh-skip",{reason:"no-relay-candidate"}),"skipped";Zs=!0;try{const s=await ft(Ut,mn("/api/client-auth/connection/candidates").then(d=>d).catch(()=>null));if(!s?.ok)return be("candidates:refresh-skip",{reason:"fetch-failed",status:s?.status??null}),"skipped";const o=await s.json().catch(()=>null);if(!o||o.serverId!==e.serverId)return be("candidates:refresh-skip",{reason:"server-id-mismatch"}),"skipped";const r=Array.isArray(o.candidates)?o.candidates:[],i=[];for(const d of r){if(!d||typeof d!="object")continue;const l=d;if(!(l.type!=="lan"||typeof l.url!="string"))try{const p=Gt(l.url);p&&!i.includes(p)&&i.push(p)}catch{}}if(i.length===0)return be("candidates:refresh-skip",{reason:"no-lan-reported"}),"skipped";const a=Ls(n).filter(d=>d.url.startsWith("https://")),u=[...i.map(d=>({kind:"direct",url:d})),...a,{kind:"relay",relay:e}];return JSON.stringify(n.candidates.map(cn))===JSON.stringify(u.map(cn))?"unchanged":(be("candidates:refreshed",{lanCount:i.length}),await zs({id:n.id,label:n.label,candidates:u}),"updated")}finally{Zs=!1}},yo=()=>{typeof window>"u"||window.setTimeout(()=>{(async()=>{const n=await uc().catch(()=>"skipped");be("candidates:refresh-result",{result:n}),n==="updated"&&ds()&&await As().catch(()=>null)})()},cc)},vo=n=>{const{t:e}=fe(),[s,o]=c.useState(()=>St()),[r,i]=c.useState(null),[a,u]=c.useState(null),[f,d]=c.useState(null),l=c.useRef(s),p=c.useRef(null),g=c.useRef(Wl()),h=c.useCallback(k=>{l.current=k,o(k)},[]),x=c.useCallback(k=>{p.current=k,i(k)},[]),j=c.useCallback(k=>{p.current===k&&(p.current=null,i(null))},[]);c.useEffect(()=>{let k=!1;return sc().then(P=>{k||h(P)}),()=>{k=!0}},[h]);const v=c.useCallback(k=>{const P=go(l.current,k);return h(P),On(P),P},[h]),T=c.useCallback(async k=>{u(null),x("connect");try{const P=ur(k);if(P.length===0){u(e("mobile.connect.error.urlRequired"));return}const y=k.id?l.current.find(V=>V.id===k.id):l.current.find(V=>Ms(V.candidates,P)),O=k.label?.trim()||y?.label||Ps(at({candidates:P})),M=k.relayGrant;let C=k.clientToken?.trim()||void 0;const b=!!C;C||(Me()?y?.hasToken&&(C=await fs(De({candidates:P}))):C=y?.clientToken),be("connect:start",{candidates:P.map(V=>V.kind),hasToken:!!C});const _=await Os(P,C);if(be("connect:probe",{status:_.status}),_.status==="unreachable"){u(e("mobile.connect.error.unreachable"));return}if(_.status==="needs-login"){v({id:y?.id,label:O,candidates:P}),d({id:y?.id??crypto.randomUUID(),label:O,candidates:P,relay:wt({candidates:P})??void 0,relayGrant:M});return}C&&b&&Me()&&await xt(De({candidates:P}),C),v({id:y?.id,label:O,candidates:P,clientToken:C}),yt(_.transport,C??null,{runtimeKey:De({candidates:P}),grant:M}),n()}catch(P){console.warn("[mobile-connect] connect threw",P),u(e("mobile.connect.error.invalidUrl"))}finally{j("connect")}},[x,j,n,v,e]),S=c.useCallback(async k=>{if(p.current==="pairing")return;u(null),x("pairing");const P=ic(k.candidates);let y=null,O=!1;try{if(y=await dr(P),!y){u(e("mobile.connect.error.unreachable"));return}const M=JSON.stringify({pairingId:k.pairingId,secret:k.secret,clientLabel:"AiWorker Mobile",clientKind:"mobile",deviceName:"AiWorker Mobile",devicePlatform:cr(),dedupeKey:lr()}),C={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:M},b=y.kind==="relay"?await ft(Ut,y.tunnel.fetch("/api/client-auth/pairing/redeem",C).catch(()=>null)):await jt(`${y.url}/api/client-auth/pairing/redeem`,C);if(!b?.ok){u(e("mobile.connect.error.authRequired"));return}const _=await b.json().catch(()=>null),V=typeof _?.clientToken=="string"?_.clientToken.trim():"";if(!V){u(e("mobile.connect.error.authRequired"));return}const N=typeof _?.server?.label=="string"?_.server.label:"",U=k.label||N||Ps(at({candidates:P}));if(Me()&&!await xt(De({candidates:P}),V)){u(e("mobile.connect.error.authRequired"));return}v({label:U,candidates:P,clientToken:V}),yt(y.kind==="relay"?{kind:"relay",relay:y.relay,tunnel:y.tunnel}:{kind:"direct",url:y.url},V,{runtimeKey:De({candidates:P})}),O=y.kind==="relay",n()}catch(M){console.warn("[mobile-connect] pairing threw",M),u(e("mobile.connect.error.authRequired"))}finally{!O&&y?.kind==="relay"&&y.tunnel.close(),j("pairing")}},[x,j,n,v,e]),E=c.useCallback(async k=>{if(!f||!k.trim()||p.current==="password")return;u(null),x("password");const P=g.current.begin(),y=()=>g.current.isCurrent(P),{id:O,label:M,candidates:C}=f;let b=null,_=!1;try{if(b=await dr(C),!y())return;if(!b){u(e("mobile.connect.error.unreachable"));return}const V={method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({password:k,trustDevice:!0,issueClientToken:!0,clientLabel:"AiWorker Mobile",clientKind:"mobile",devicePlatform:cr(),dedupeKey:lr()})};be("password:start",{transport:b.kind});const N=b.kind==="relay"?await ft(Ut,b.tunnel.fetch("/auth/session",V).catch(()=>null)):await jt(`${b.url}/auth/session`,V);if(!y())return;if(be("password:done",{ok:N?.ok===!0,status:N?.status??null}),!N?.ok){u(e("mobile.connect.error.passwordFailed"));return}const U=await N.json().catch(()=>null);if(!y())return;const $=typeof U?.clientToken=="string"?U.clientToken.trim():"";if(be("password:token",{issued:!!$}),!$){if(b.kind==="direct"&&!Me()){v({id:O,label:M,candidates:C}),d(null),yt({kind:"direct",url:b.url},null,{runtimeKey:De({candidates:C})}),n();return}u(e("mobile.connect.error.authRequired"));return}if(Me()&&(!y()||(await xt(De({candidates:C}),$),!y()))||!y()||(v({id:O,label:M,candidates:C,clientToken:$}),d(null),yt(b.kind==="relay"?{kind:"relay",relay:b.relay,tunnel:b.tunnel}:{kind:"direct",url:b.url},$,{runtimeKey:De({candidates:C})}),_=b.kind==="relay",!y()))return;n()}catch(V){if(!y())return;console.warn("[mobile-connect] password threw",V),u(e("mobile.connect.error.passwordFailed"))}finally{!_&&b?.kind==="relay"&&b.tunnel.close(),y()&&j("password")}},[x,j,n,f,v,e]),D=c.useCallback(()=>{g.current.cancel(),j("password"),d(null),u(null)},[j]),w=c.useCallback(async k=>{u(null);let P=ur(k);const y=k.id?l.current.find(b=>b.id===k.id)??null:null;if(y){const b=P.filter(N=>N.kind==="direct"),_=Ls(y).filter(N=>N.url.startsWith("https://")&&!b.some(U=>mo(U.url,N.url))),V=wt(y);P=[...b,..._,...V?[{kind:"relay",relay:V}]:[]]}if(P.length===0)return u(e("mobile.connect.error.urlRequired")),null;const O=k.clientToken?.trim()||void 0,M=k.label?.trim()||Ps(at({candidates:P}));if(Me()){const b=De({candidates:P});if(O)await xt(b,O);else if(y?.hasToken){const _=De(y);if(_&&b&&_!==b){const V=await fs(_);V&&await xt(b,V)}}}return v({id:k.id,label:M,candidates:P,clientToken:O}).find(b=>Ms(b.candidates,P))??null},[v,e]),A=c.useCallback(async k=>{const P=l.current.find(O=>O.id===k)??null,y=await nc(k);return h(y),P},[h]);return{connections:s,isBusy:r!==null,isPasswordBusy:r==="password",error:a,pendingConnection:f,connect:T,redeemPairingConnection:S,submitPassword:E,cancelPassword:D,saveConnection:w,removeConnection:A,setError:u}},wo=n=>{const e=ce.c(31),{onClose:s}=n,{t:o}=fe(),[r,i]=c.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=Ml(),e[0]=a):a=e[0];const u=a;let f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{qo(Ol()).then(k=>{k.ok&&(i(!0),window.setTimeout(()=>i(!1),2e3))})},e[1]=f):f=e[1];const d=f;let l;e[2]!==o?(l=o("mobile.connectionDebug.title"),e[2]=o,e[3]=l):l=e[3];let p;e[4]!==l?(p=t.jsx("h2",{className:"min-w-0 truncate typography-ui-label text-foreground",children:l}),e[4]=l,e[5]=p):p=e[5];const g=r?"check":"file-copy";let h;e[6]!==g?(h=t.jsx(Q,{name:g,className:"size-4"}),e[6]=g,e[7]=h):h=e[7];let x;e[8]!==r||e[9]!==o?(x=o(r?"mobile.connectionDebug.copied":"mobile.connectionDebug.copy"),e[8]=r,e[9]=o,e[10]=x):x=e[10];let j;e[11]!==h||e[12]!==x?(j=t.jsxs(he,{type:"button",variant:"outline",size:"sm",onClick:d,disabled:u.length===0,children:[h,x]}),e[11]=h,e[12]=x,e[13]=j):j=e[13];let v;e[14]!==o?(v=o("mobile.connectionDebug.close"),e[14]=o,e[15]=v):v=e[15];let T;e[16]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(Q,{name:"close",className:"size-[18px]"}),e[16]=T):T=e[16];let S;e[17]!==s||e[18]!==v?(S=t.jsx(he,{type:"button",variant:"ghost",size:"icon","aria-label":v,onClick:s,children:T}),e[17]=s,e[18]=v,e[19]=S):S=e[19];let E;e[20]!==S||e[21]!==j?(E=t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[j,S]}),e[20]=S,e[21]=j,e[22]=E):E=e[22];let D;e[23]!==E||e[24]!==p?(D=t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border/70 px-4 py-2.5",children:[p,E]}),e[23]=E,e[24]=p,e[25]=D):D=e[25];let w;e[26]!==o?(w=t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 py-3",children:u.length===0?t.jsx("p",{className:"typography-small text-muted-foreground",children:o("mobile.connectionDebug.empty")}):t.jsx("pre",{className:"whitespace-pre-wrap break-words typography-code text-muted-foreground",children:u.map(lo).join(`
4
+ `)})}),e[26]=o,e[27]=w):w=e[27];let A;return e[28]!==D||e[29]!==w?(A=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:[D,w]}),e[28]=D,e[29]=w,e[30]=A):A=e[30],A},jo=()=>{if(typeof window>"u")return null;const e=window.Capacitor?.Plugins?.BarcodeScanner;return e&&(typeof e.scan=="function"||typeof e.startScan=="function")?e:null},dc=()=>window.Capacitor?.getPlatform?.()==="android",ko=n=>{const e=n.trim();if(!e)return null;if(/^aiworker:\/\//i.test(e)){const s=Bo(e);return s?{pairing:s}:null}return/^https?:\/\//i.test(e)?{url:e}:null},So=(n,e)=>{const s=ko(n);if(!s&&e?.pairingStringFallback){const o=Lo(n);if(o)return{status:"pairing",pairing:o}}return s?"pairing"in s?{status:"pairing",...s}:{status:"ok",...s}:{status:"invalid"}},fc=async(n,e)=>{if(!n.startScan||!n.stopScan||!n.addListener)return{status:"unsupported"};if(e?.aborted)return{status:"cancelled"};let s,o,r=!1,i=()=>{};const a=new Promise(d=>{i=d}),u=d=>{r||(r=!0,i(d))},f=()=>u({status:"cancelled"});e?.addEventListener("abort",f,{once:!0});try{return(await Promise.allSettled([Promise.resolve(n.addListener("barcodesScanned",({barcodes:l})=>{const p=l?.[0],g=(p?.rawValue??p?.displayValue??"").trim();g&&u(So(g,{pairingStringFallback:!0}))})).then(l=>{s=l}),Promise.resolve(n.addListener("scanError",()=>u({status:"failed"}))).then(l=>{o=l})])).some(({status:l})=>l==="rejected")?u({status:"failed"}):r||n.startScan({formats:["QR_CODE"]}).catch(()=>u({status:"failed"})),await a}finally{e?.removeEventListener("abort",f),await Promise.allSettled([Promise.resolve(s?.remove()),Promise.resolve(o?.remove()),n.stopScan()])}},un=()=>jo()!==null,No=async n=>{const e=jo();if(!e)return{status:"unsupported"};try{if(e.requestPermissions){const a=(await e.requestPermissions())?.camera;if(a&&a!=="granted"&&a!=="limited")return{status:"permission-denied"}}if(n?.signal?.aborted)return{status:"cancelled"};if(dc())return fc(e,n?.signal);if(!e.scan)return{status:"unsupported"};const o=(await e.scan({formats:["QR_CODE"]}))?.barcodes?.[0],r=(o?.rawValue??o?.displayValue??"").trim();return r?So(r):{status:"cancelled"}}catch{return{status:"failed"}}},Ot={autoComplete:"off",autoCorrect:"off",spellCheck:!1},rs="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-primary focus:ring-2 focus:ring-primary/20",Co=n=>{const e=ce.c(22),{onCancel:s}=n,{t:o}=fe(),r=c.useRef(null);let i,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{const T={value:document.documentElement.style.getPropertyValue("background-color"),priority:document.documentElement.style.getPropertyPriority("background-color")},S={value:document.body.style.getPropertyValue("background-color"),priority:document.body.style.getPropertyPriority("background-color")};document.documentElement.style.setProperty("background-color","rgba(0, 0, 0, 0)","important"),document.body.style.setProperty("background-color","rgba(0, 0, 0, 0)","important");const E=new Map,D=A=>{!(A instanceof HTMLElement)||A===r.current||E.has(A)||(E.set(A,{opacity:A.style.opacity,pointerEvents:A.style.pointerEvents}),A.style.setProperty("opacity","0"),A.style.setProperty("pointer-events","none"))};Array.from(document.body.children).forEach(D);const w=new MutationObserver(A=>{A.forEach(k=>k.addedNodes.forEach(D))});return w.observe(document.body,{childList:!0}),()=>{w.disconnect(),E.forEach(mc),T.value?document.documentElement.style.setProperty("background-color",T.value,T.priority):document.documentElement.style.removeProperty("background-color"),S.value?document.body.style.setProperty("background-color",S.value,S.priority):document.body.style.removeProperty("background-color")}},a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),c.useLayoutEffect(i,a);let u,f;e[2]!==s?(u=()=>{const T=()=>{document.visibilityState==="hidden"&&s()};return document.addEventListener("visibilitychange",T),()=>document.removeEventListener("visibilitychange",T)},f=[s],e[2]=s,e[3]=u,e[4]=f):(u=e[3],f=e[4]),c.useEffect(u,f);let d;e[5]!==o?(d=o("mobile.connect.scanQr"),e[5]=o,e[6]=d):d=e[6];let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx("div",{className:"aspect-square w-full max-w-72 rounded-[28px] border-2 border-foreground/90 shadow-[0_0_0_9999px_color-mix(in_srgb,var(--surface-background)_18%,transparent)]","aria-hidden":!0}),e[7]=l):l=e[7];let p;e[8]!==o?(p=o("mobile.connect.welcome.scanHint"),e[8]=o,e[9]=p):p=e[9];let g;e[10]!==p?(g=t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-6",children:[l,t.jsx("p",{className:"max-w-sm rounded-[16px] border border-border/60 bg-background px-4 py-3 text-center typography-body text-foreground shadow-sm",children:p})]}),e[10]=p,e[11]=g):g=e[11];let h;e[12]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(Q,{name:"close",className:"size-[18px]"}),e[12]=h):h=e[12];let x;e[13]!==o?(x=o("mobile.instances.cancelEdit"),e[13]=o,e[14]=x):x=e[14];let j;e[15]!==s||e[16]!==x?(j=t.jsxs(he,{type:"button",variant:"outline",size:"lg",className:"mx-auto min-h-12 w-full max-w-sm bg-background",onClick:s,children:[h,x]}),e[15]=s,e[16]=x,e[17]=j):j=e[17];let v;return e[18]!==j||e[19]!==d||e[20]!==g?(v=Bt.createPortal(t.jsxs("div",{ref:r,role:"dialog","aria-modal":"true","aria-label":d,className:"fixed inset-0 z-[1000] flex flex-col bg-transparent px-6 pb-[calc(var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))+24px)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+24px)] text-foreground",children:[g,j]}),document.body),e[18]=j,e[19]=d,e[20]=g,e[21]=v):v=e[21],v},Eo=()=>{const n=ce.c(6),{t:e}=fe();let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx(bt,{width:96,height:96,isAnimated:!0}),n[0]=s):s=n[0];let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx(Q,{name:"loader-4",className:"size-[18px] animate-spin"}),n[1]=o):o=n[1];let r;n[2]!==e?(r=e("mobile.connect.connecting"),n[2]=e,n[3]=r):r=n[3];let i;return n[4]!==r?(i=Bt.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:[o,t.jsx("span",{children:r})]})]}),document.body),n[4]=r,n[5]=i):i=n[5],i};function mc(n,e){e.style.opacity=n.opacity,e.style.pointerEvents=n.pointerEvents}const pc=({onConnected:n,notice:e=null})=>{const{t:s}=fe(),o=vo(n),{connections:r,isBusy:i,isPasswordBusy:a,error:u,pendingConnection:f}=o,[d,l]=c.useState(""),[p,g]=c.useState(""),[h,x]=c.useState(""),[j,v]=c.useState(!1),[T,S]=c.useState(!1),E=c.useRef(null),D=c.useMemo(()=>un(),[]),[w,A]=c.useState(()=>!un()),[k,P]=c.useState(null),[y,O]=c.useState(""),[M,C]=c.useState(!1),b=co(c.useCallback(()=>C(!0),[])),_=c.useCallback(I=>{I.preventDefault(),o.connect({url:d,clientToken:h,label:p})},[h,o,p,d]),V=c.useCallback(I=>{if(/^aiworker:\/\//i.test(I.trim())){const B=ko(I);if(B){if("pairing"in B){o.redeemPairingConnection(B.pairing);return}l(B.url),B.label&&g(B.label),B.clientToken&&x(B.clientToken);return}}l(I)},[o]),N=c.useCallback(async()=>{if(E.current||i)return;o.setError(null),v(!0);const I=new AbortController;E.current=I;try{const B=await No({signal:I.signal});switch(E.current===I&&(E.current=null,v(!1)),B.status){case"ok":S(!0),l(B.url),B.label&&g(B.label),B.clientToken&&x(B.clientToken),await o.connect({url:B.url,clientToken:B.clientToken,label:B.label});break;case"pairing":S(!0),await o.redeemPairingConnection(B.pairing);break;case"permission-denied":o.setError(s("mobile.connect.scan.permissionDenied"));break;case"invalid":o.setError(s("mobile.connect.scan.invalid"));break;case"unsupported":o.setError(s("mobile.connect.scan.unsupported"));break;case"failed":o.setError(s("mobile.connect.scan.failed"));break;default:break}}finally{S(!1),E.current===I&&(E.current=null,v(!1))}},[o,i,s]);c.useEffect(()=>()=>E.current?.abort(),[]);const U=c.useCallback(I=>{I.preventDefault(),o.submitPassword(y)},[o,y]),$=c.useCallback(()=>{O(""),o.cancelPassword()},[o]);return t.jsxs(t.Fragment,{children:[j?t.jsx(Co,{onCancel:()=>E.current?.abort()}):null,T?t.jsx(Eo,{}):null,M?t.jsx(wo,{onClose:()=>C(!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",{...b,className:"select-none",style:{touchAction:"manipulation"},children:t.jsx(bt,{width:72,height:72,className:"size-[72px]"})}),t.jsx("h1",{className:"typography-h2 text-foreground",children:s("mobile.connect.welcome.title")})]}),e?t.jsxs("div",{role:"status",className:"flex w-full items-center gap-3 rounded-[18px] border border-[color-mix(in_srgb,var(--status-warning)_35%,transparent)] bg-[color-mix(in_srgb,var(--status-warning)_10%,transparent)] px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-[color-mix(in_srgb,var(--status-warning)_16%,transparent)] text-[var(--status-warning)]",children:t.jsx(Q,{name:e.kind==="auth-expired"?"lock":"cloud-off",className:"size-[18px]"})}),t.jsx("p",{className:"min-w-0 flex-1 typography-small text-foreground",children:e.kind==="auth-expired"?s("mobile.connect.notice.authExpired",{label:e.label}):s("mobile.connect.notice.unreachable",{label:e.label})})]}):null,f?t.jsxs("form",{className:"flex w-full flex-col gap-3",onSubmit:U,children:[t.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(Q,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0 text-left",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:f.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:f.candidates.some(I=>I.kind==="direct")?at(f):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...Ot,value:y,onChange:I=>O(I.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:rs}),u?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:u}):null,t.jsx(he,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:a||!y.trim(),children:s(a?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(he,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:$,children:s("mobile.connect.cancelPassword")})]}):t.jsxs("div",{className:"flex w-full flex-col gap-6",children:[D?t.jsxs("div",{className:"flex w-full flex-col gap-2",children:[t.jsxs(he,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{N()},disabled:j||i,children:[t.jsx(Q,{name:"scan-2",className:X("size-[18px]",j&&"animate-pulse")}),s(i?"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,u&&!w?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:u}):null,r.length>0?t.jsxs("section",{className:"flex w-full flex-col gap-2.5",children:[t.jsx("h2",{className:"text-center typography-micro uppercase tracking-[0.14em] text-muted-foreground",children:s("mobile.connect.saved.title")}),t.jsx("div",{className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map(I=>{const B=k===I.id;return t.jsxs("button",{type:"button",disabled:i,className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3.5 py-2.5 text-left last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:opacity-70",onClick:()=>{P(I.id),o.connect({id:I.id,candidates:I.candidates,clientToken:I.clientToken,label:I.label}).finally(()=>P(null))},children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(Q,{name:"server",className:"size-[18px]"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:I.label}),t.jsx("span",{className:X("block truncate typography-small",B?"text-foreground":"text-muted-foreground"),children:B?s("mobile.connect.connecting"):I.candidates.some(Z=>Z.kind==="direct")?at(I):s("mobile.connect.relay.badge")})]}),B?t.jsx(Q,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):t.jsx(Q,{name:"arrow-right-s",className:"size-5 text-muted-foreground"})]},I.id)})})]}):null,t.jsxs("div",{className:"flex w-full flex-col",children:[D?t.jsxs("button",{type:"button",onClick:()=>A(I=>!I),"aria-expanded":w,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-primary",children:[t.jsx("span",{children:s("mobile.connect.manual.toggle")}),t.jsx(Q,{name:"arrow-down-s",className:X("size-4 transition-transform duration-200",w&&"rotate-180")})]}):null,t.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:w?"1fr":"0fr"},children:t.jsx("div",{className:"min-h-0 overflow-hidden",children:t.jsxs("form",{className:"flex w-full flex-col gap-3 pt-3",onSubmit:_,children:[t.jsx("input",{...Ot,value:d,onChange:I=>V(I.target.value),placeholder:s("mobile.connect.url.placeholder"),"aria-label":s("mobile.connect.url.label"),type:"url",inputMode:"url",autoCapitalize:"none",tabIndex:w?void 0:-1,className:X(rs,"text-center")}),t.jsx("input",{value:p,onChange:I=>g(I.target.value),placeholder:s("mobile.instances.label.placeholder"),"aria-label":s("mobile.instances.label.label"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,tabIndex:w?void 0:-1,className:X(rs,"text-center")}),t.jsx("input",{...Ot,value:h,onChange:I=>x(I.target.value),placeholder:s("mobile.connect.token.placeholder"),"aria-label":s("mobile.connect.token.label"),tabIndex:w?void 0:-1,autoCapitalize:"none",className:X(rs,"text-center")}),t.jsx("p",{className:"px-1 text-center typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")}),u?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:u}):null,t.jsx(he,{type:"submit",variant:D?"outline":"default",size:"lg",className:"h-12 w-full",disabled:i||j||!d.trim(),children:s(i?"mobile.connect.connecting":"mobile.connect.connectButton")})]})})})]})]})]})})]})},hc=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"},gc=n=>{const e=ce.c(12),{groups:s,displayMode:o,timeFormatPreference:r,className:i}=n;let a;e[0]!==i?(a=X("space-y-1.5",i),e[0]=i,e[1]=a):a=e[1];let u;if(e[2]!==o||e[3]!==s||e[4]!==r){let d;e[6]!==o||e[7]!==r?(d=l=>t.jsxs("div",{className:"min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Jo,{providerId:l.providerId,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground",children:l.providerName}),l.planLabel?t.jsx("span",{className:"shrink-0 typography-micro capitalize text-muted-foreground",children:l.planLabel}):null,l.status&&l.rows.length===0?t.jsx("span",{className:"shrink-0 truncate typography-micro text-muted-foreground",children:l.status}):null]}),l.rows.length>0?t.jsx("div",{className:"mt-1.5 space-y-1",children:l.rows.map(p=>{const g=o==="remaining"?p.window.remainingPercent:p.window.usedPercent,h=Yo(p.window.valueLabel,g),x=Xo(p.window.resetAt,p.window.resetAfterFormatted??p.window.resetAtFormatted,r);return t.jsxs("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"shrink-0 truncate typography-ui-label text-muted-foreground",children:p.subtitle?`${p.subtitle} · ${p.label}`:p.label}),x?t.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/70",children:x}):null]}),t.jsx("span",{className:X("shrink-0 typography-ui-label font-semibold tabular-nums",hc(p.window)),children:h==="-"?"":h})]},p.key)})}):null,l.status&&l.rows.length>0?t.jsx("div",{className:"mt-1.5 typography-micro text-muted-foreground",children:l.status}):null]},l.providerId),e[6]=o,e[7]=r,e[8]=d):d=e[8],u=s.map(d),e[2]=o,e[3]=s,e[4]=r,e[5]=u}else u=e[5];let f;return e[9]!==a||e[10]!==u?(f=t.jsx("div",{className:a,children:u}),e[9]=a,e[10]=u,e[11]=f):f=e[11],f},mr=380,bc=(n,e)=>{if(!n||typeof n!="object")return;const s=n[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0},At=n=>typeof n=="number"&&Number.isFinite(n)?n:0,pr=n=>n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:String(n),Ro=n=>{const e=ce.c(19),{percentage:s}=n;let o,r,i,a,u,f,d;if(e[0]!==s){i=si(s)??0;const x=ni(s);r=x==="critical"?"var(--status-error)":x==="warn"?"var(--status-warning)":"var(--status-success)",o=2*Math.PI*7.5,a="0 0 18 18",u="size-[18px] -rotate-90",f="progressbar",d=Math.round(i),e[0]=s,e[1]=o,e[2]=r,e[3]=i,e[4]=a,e[5]=u,e[6]=f,e[7]=d}else o=e[1],r=e[2],i=e[3],a=e[4],u=e[5],f=e[6],d=e[7];let l;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),e[8]=l):l=e[8];const p=o*(1-i/100);let g;e[9]!==o||e[10]!==r||e[11]!==p?(g=t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:r,strokeWidth:3,strokeLinecap:"round",strokeDasharray:o,strokeDashoffset:p,className:"transition-[stroke-dashoffset,stroke] duration-300"}),e[9]=o,e[10]=r,e[11]=p,e[12]=g):g=e[12];let h;return e[13]!==a||e[14]!==u||e[15]!==f||e[16]!==d||e[17]!==g?(h=t.jsxs("svg",{viewBox:a,className:u,role:f,"aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":100,children:[l,g]}),e[13]=a,e[14]=u,e[15]=f,e[16]=d,e[17]=g,e[18]=h):h=e[18],h},xc=n=>{const e=ce.c(13),{icon:s,iconNode:o,label:r,children:i}=n;let a;e[0]!==s||e[1]!==o?(a=o??(s?t.jsx(Q,{name:s,className:"size-[18px]"}):null),e[0]=s,e[1]=o,e[2]=a):a=e[2];let u;e[3]!==a?(u=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:a}),e[3]=a,e[4]=u):u=e[4];let f;e[5]!==r?(f=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:r}),e[5]=r,e[6]=f):f=e[6];let d;e[7]!==i?(d=t.jsx("span",{className:"min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground",children:i}),e[7]=i,e[8]=d):d=e[8];let l;return e[9]!==u||e[10]!==f||e[11]!==d?(l=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5",children:[u,f,d]}),e[9]=u,e[10]=f,e[11]=d,e[12]=l):l=e[12],l},yc=n=>{const e=ce.c(49),{open:s,onClose:o,anchorRef:r,contextDisplay:i,usageGroups:a,usageDisplayMode:u,isUsageLoading:f,timeFormatPreference:d}=n,{t:l}=fe(),p=c.useRef(null),[g,h]=c.useState(s),[x,j]=c.useState(!1),{enabled:v}=gn(),T=c.useRef(null),[S,E]=c.useState(null);let D,w;e[0]!==r||e[1]!==v||e[2]!==s||e[3]!==g?(D=()=>{if(!s||!v||!g)return;const q=()=>{const ne=r.current?.getBoundingClientRect(),oe=T.current?.getBoundingClientRect();if(!ne||!oe){E(null);return}const le=ne.left-oe.left,ue=Math.min(Math.max(le,8),Math.max(8,oe.width-mr-8));E(ue)};q();const G=T.current;if(typeof ResizeObserver>"u"||!G)return;const Y=new ResizeObserver(q);return Y.observe(G),()=>Y.disconnect()},w=[r,v,s,g],e[0]=r,e[1]=v,e[2]=s,e[3]=g,e[4]=D,e[5]=w):(D=e[4],w=e[5]),c.useLayoutEffect(D,w);const A=v&&S!==null;let k,P;e[6]!==s||e[7]!==g?(k=()=>{if(s){h(!0),j(!1);return}if(!g)return;j(!0);const q=window.setTimeout(()=>{h(!1),j(!1)},140);return()=>window.clearTimeout(q)},P=[s,g],e[6]=s,e[7]=g,e[8]=k,e[9]=P):(k=e[8],P=e[9]),c.useEffect(k,P);let y,O;e[10]!==o||e[11]!==s?(y=()=>{if(!s)return;const q=G=>{G.key==="Escape"&&o()};return document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)},O=[o,s],e[10]=o,e[11]=s,e[12]=y,e[13]=O):(y=e[12],O=e[13]),c.useEffect(y,O);let M,C;if(e[14]!==r||e[15]!==o||e[16]!==s?(M=()=>{if(!s)return;const q=G=>{const Y=G.target;if(!(Y instanceof Node)){o();return}p.current?.contains(Y)||r.current?.contains(Y)||o()};return document.addEventListener("pointerdown",q,!0),document.addEventListener("wheel",q,!0),()=>{document.removeEventListener("pointerdown",q,!0),document.removeEventListener("wheel",q,!0)}},C=[r,o,s],e[14]=r,e[15]=o,e[16]=s,e[17]=M,e[18]=C):(M=e[17],C=e[18]),c.useEffect(M,C),!g)return null;let b;e[19]!==l?(b=l("mobile.header.openMetadataAria"),e[19]=l,e[20]=b):b=e[20];const _=A?"absolute origin-top-left":"mx-3 mt-2",V=x?"pointer-events-none":"pointer-events-auto";let N;e[21]!==_||e[22]!==V?(N=X("overflow-y-auto overscroll-contain rounded-[20px] border border-border/70 bg-[var(--surface-elevated)] p-2 shadow-[0_12px_32px_rgb(0_0_0_/_0.2)] will-change-transform",_,V),e[21]=_,e[22]=V,e[23]=N):N=e[23];const U=`${x?"session-metadata-out":"session-metadata-in"} ${x?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let $;e[24]!==S||e[25]!==A?($=A?{top:8,left:S??8,width:`min(${mr}px, calc(100% - 16px))`}:null,e[24]=S,e[25]=A,e[26]=$):$=e[26];let I;e[27]!==U||e[28]!==$?(I={animation:U,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...$},e[27]=U,e[28]=$,e[29]=I):I=e[29];let B;e[30]!==i||e[31]!==l?(B=i?t.jsx(xc,{iconNode:t.jsx(Ro,{percentage:i.percentage}),label:l("mobile.header.metadata.context"),children:t.jsxs("span",{className:"inline-flex items-baseline gap-1.5 tabular-nums",children:[t.jsxs("span",{className:X("font-semibold",i.colorClass),children:[i.percentage.toFixed(1),"%"]}),t.jsx("span",{className:"text-muted-foreground",children:i.tokens})]})}):null,e[30]=i,e[31]=l,e[32]=B):B=e[32];let Z;e[33]!==f||e[34]!==d||e[35]!==u||e[36]!==a?(Z=t.jsx(vc,{groups:a,displayMode:u,isLoading:f,timeFormatPreference:d}),e[33]=f,e[34]=d,e[35]=u,e[36]=a,e[37]=Z):Z=e[37];let ee;e[38]!==B||e[39]!==Z?(ee=t.jsxs("div",{className:"space-y-1",children:[B,Z]}),e[38]=B,e[39]=Z,e[40]=ee):ee=e[40];let te;e[41]!==N||e[42]!==I||e[43]!==ee||e[44]!==b?(te=t.jsx("div",{ref:p,role:"dialog","aria-label":b,className:N,style:I,children:ee}),e[41]=N,e[42]=I,e[43]=ee,e[44]=b,e[45]=te):te=e[45];let z;e[46]===Symbol.for("react.memo_cache_sentinel")?(z=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[46]=z):z=e[46];let W;return e[47]!==te?(W=t.jsxs("div",{ref:T,className:"fixed inset-x-0 bottom-0 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-header-height,56px))] z-20 pointer-events-none",children:[te,z]}),e[47]=te,e[48]=W):W=e[48],W},vc=n=>{const e=ce.c(30),{groups:s,displayMode:o,isLoading:r,timeFormatPreference:i}=n,{t:a}=fe();let u;e[0]!==o||e[1]!==a?(u=a(o==="remaining"?"header.services.remaining":"header.services.used"),e[0]=o,e[1]=a,e[2]=u):u=e[2];const f=u;if(s.length===0){if(!r)return null;let S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S=t.jsx(Q,{name:"loader-4",className:"size-4 animate-spin","aria-hidden":!0}),e[3]=S):S=e[3];let E;e[4]!==a?(E=a("common.loading"),e[4]=a,e[5]=E):E=e[5];let D;return e[6]!==E?(D=t.jsxs("div",{className:"flex items-center justify-center gap-2 px-2.5 py-6 text-muted-foreground",children:[S,t.jsx("span",{className:"typography-ui-label",children:E})]}),e[6]=E,e[7]=D):D=e[7],D}let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(Q,{name:"timer",className:"size-[18px]"})}),e[8]=d):d=e[8];let l;e[9]!==a?(l=a("mobile.header.metadata.usage"),e[9]=a,e[10]=l):l=e[10];let p;e[11]!==l?(p=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:l}),e[11]=l,e[12]=p):p=e[12];let g;e[13]!==r?(g=r?t.jsx(Q,{name:"refresh",className:"size-3.5 animate-spin"}):null,e[13]=r,e[14]=g):g=e[14];let h;e[15]!==f?(h=t.jsx("span",{className:"truncate",children:f}),e[15]=f,e[16]=h):h=e[16];let x;e[17]!==g||e[18]!==h?(x=t.jsxs("span",{className:"inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground",children:[g,h]}),e[17]=g,e[18]=h,e[19]=x):x=e[19];let j;e[20]!==p||e[21]!==x?(j=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 px-2.5 pb-1.5",children:[d,p,x]}),e[20]=p,e[21]=x,e[22]=j):j=e[22];let v;e[23]!==o||e[24]!==s||e[25]!==i?(v=t.jsx(gc,{groups:s,displayMode:o,timeFormatPreference:i}),e[23]=o,e[24]=s,e[25]=i,e[26]=v):v=e[26];let T;return e[27]!==j||e[28]!==v?(T=t.jsxs("div",{className:"pt-2.5",children:[j,v]}),e[27]=j,e[28]=v,e[29]=T):T=e[29],T},wc=c.memo(function({open:e,onOpenChange:s,currentSessionId:o,effectiveDirectory:r,isNewSessionDraftOpen:i}){const{t:a}=fe(),u=c.useRef(null),f=Qo(o??"",r||void 0),d=qe(I=>I.providers),l=qe(I=>I.currentProviderId),p=qe(I=>I.currentModelId),g=qe(I=>I.getModelMetadata);qe(I=>I.modelsMetadata.size);const h=Zo(c.useCallback(I=>o?I.sessionModelSelections.get(o)??null:null,[o])),x=gt(I=>I.results),j=gt(I=>I.refreshErrors),v=c.useRef(!1),T=gt(I=>I.loadSettings),S=gt(I=>I.fetchAllQuotas),E=gt(I=>I.isLoading),D=gt(I=>I.displayMode),w=gt(I=>I.dropdownProviderIds),A=it(I=>I.timeFormatPreference);ei(),c.useEffect(()=>{T()},[T]),c.useEffect(()=>{Xn(w)},[w]),c.useEffect(()=>{if(!e){v.current=!1;return}v.current||E||!w.some(B=>!x.some(Z=>Z.providerId===B)||j[B])||(v.current=!0,S())},[w,S,E,e,x,j]);const P=c.useMemo(()=>{for(let I=f.length-1;I>=0;I-=1){const B=f[I];if(B.role!=="user")continue;const Z=typeof B.model?.providerID=="string"&&B.model.providerID.trim().length>0?B.model.providerID:void 0,ee=typeof B.model?.modelID=="string"&&B.model.modelID.trim().length>0?B.model.modelID:void 0;if(Z&&ee)return{providerID:Z,modelID:ee}}return null},[f])??(h?{providerID:h.providerId,modelID:h.modelId}:null)??(l&&p?{providerID:l,modelID:p}:null),O=(P?d.find(I=>I.id===P.providerID):void 0)?.models.find(I=>I.id===P?.modelID),M=P?g(P.providerID,P.modelID):void 0,C=bc(O?.limit,"context")??M?.limit?.context??0,b=c.useMemo(()=>{for(let I=f.length-1;I>=0;I-=1){const B=f[I];if(B.role!=="assistant"||!B.tokens)continue;const Z=At(B.tokens.total);if(Z>0)return Z;const ee=At(B.tokens.input)+At(B.tokens.output)+At(B.tokens.reasoning)+At(B.tokens.cache?.read)+At(B.tokens.cache?.write);if(ee>0)return ee}return 0},[f]),_=!i&&b>0&&C>0?Math.min(b/C*100,999):null,V=_!==null?`${pr(b)}/${pr(C)}`:null,N=_===null?"":_>=90?"text-[var(--status-error)]":_>=75?"text-[var(--status-warning)]":"text-[var(--status-success)]",U=_!==null&&V?{percentage:_,tokens:V,colorClass:N}:null,$=ti();return c.useEffect(()=>{!e||$.length===0||Xn($.map(I=>I.providerId))},[e,$]),t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:u,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-primary","aria-label":a("mobile.header.openMetadataAria"),"aria-expanded":e,onClick:()=>s(I=>!I),style:{touchAction:"manipulation"},children:t.jsx(Ro,{percentage:U?.percentage??0})}),t.jsx(yc,{open:e,onClose:()=>s(!1),anchorRef:u,contextDisplay:U,usageGroups:$,usageDisplayMode:D,isUsageLoading:E,timeFormatPreference:A})]})}),jc=10,hr=380,kc=(n,e)=>n.title?.trim()||e,Sc=n=>{const e=ce.c(32),{session:s,meta:o,active:r,onSelect:i}=n,{t:a}=fe(),u=Fr(s.id),f=Wr(s.id),d=u?.type??"idle",l=d==="busy"||d==="retry",p=!l&&f>0&&!r,g=Ur(s.id,l),h=(l||p)&&g,x=s.time?.updated??s.time?.created??0;let j;e[0]!==x?(j=oi(x),e[0]=x,e[1]=j):j=e[1];const v=j,T=r&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let S;e[2]!==T?(S=X("flex w-full items-center gap-3 rounded-xl px-2.5 py-2 text-left transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary",T),e[2]=T,e[3]=S):S=e[3];let E;e[4]===Symbol.for("react.memo_cache_sentinel")?(E={touchAction:"manipulation"},e[4]=E):E=e[4];const D=r?"text-primary":"text-foreground";let w;e[5]!==D?(w=X("block truncate typography-ui-label",D),e[5]=D,e[6]=w):w=e[6];let A;e[7]!==s||e[8]!==a?(A=kc(s,a("sessions.sidebar.session.untitled")),e[7]=s,e[8]=a,e[9]=A):A=e[9];let k;e[10]!==w||e[11]!==A?(k=t.jsx("span",{className:w,children:A}),e[10]=w,e[11]=A,e[12]=k):k=e[12];let P;e[13]!==o?(P=o?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:o}):null,e[13]=o,e[14]=P):P=e[14];let y;e[15]!==P||e[16]!==k?(y=t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[k,P]}),e[15]=P,e[16]=k,e[17]=y):y=e[17];let O;e[18]!==l||e[19]!==p?(O=l||p?t.jsx("span",{className:X("size-1.5 shrink-0 rounded-full",l?"bg-primary":"bg-[var(--status-info)]"),"aria-hidden":!0}):null,e[18]=l,e[19]=p,e[20]=O):O=e[20];let M;e[21]!==l||e[22]!==s.id||e[23]!==h||e[24]!==v?(M=h?t.jsx(so,{sessionId:s.id,running:l,className:"typography-micro"}):v?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:v}):null,e[21]=l,e[22]=s.id,e[23]=h,e[24]=v,e[25]=M):M=e[25];let C;return e[26]!==i||e[27]!==y||e[28]!==O||e[29]!==M||e[30]!==S?(C=t.jsxs("button",{type:"button",className:S,onClick:i,style:E,children:[y,O,M]}),e[26]=i,e[27]=y,e[28]=O,e[29]=M,e[30]=S,e[31]=C):C=e[31],C},Nc=n=>{const e=ce.c(50),{open:s,onClose:o,anchorRef:r}=n,{t:i}=fe(),a=c.useRef(null),[u,f]=c.useState(s),[d,l]=c.useState(!1),{enabled:p}=gn(),g=c.useRef(null),[h,x]=c.useState(null);let j,v;e[0]!==r||e[1]!==p||e[2]!==s||e[3]!==u?(j=()=>{if(!s||!p||!u)return;const G=()=>{const oe=r.current?.getBoundingClientRect(),le=g.current?.getBoundingClientRect();if(!oe||!le){x(null);return}const ue=oe.left-le.left;x(Math.min(Math.max(ue,8),Math.max(8,le.width-hr-8)))};G();const Y=g.current;if(typeof ResizeObserver>"u"||!Y)return;const ne=new ResizeObserver(G);return ne.observe(Y),()=>ne.disconnect()},v=[r,p,s,u],e[0]=r,e[1]=p,e[2]=s,e[3]=u,e[4]=j,e[5]=v):(j=e[4],v=e[5]),c.useLayoutEffect(j,v);const T=p&&h!==null,S=Ee(Cc),E=Ee(Ec),D=We(Rc);let w;e[6]===Symbol.for("react.memo_cache_sentinel")?(w={maxParents:jc},e[6]=w):w=e[6];const A=ri(s||u,w);let k,P;e[7]!==s||e[8]!==u?(k=()=>{if(s){bn(),f(!0),l(!1);return}if(!u)return;l(!0);const G=window.setTimeout(()=>{f(!1),l(!1)},140);return()=>window.clearTimeout(G)},P=[s,u],e[7]=s,e[8]=u,e[9]=k,e[10]=P):(k=e[9],P=e[10]),c.useEffect(k,P);let y,O;e[11]!==o||e[12]!==s?(y=()=>{if(!s)return;const G=Y=>{Y.key==="Escape"&&o()};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},O=[o,s],e[11]=o,e[12]=s,e[13]=y,e[14]=O):(y=e[13],O=e[14]),c.useEffect(y,O);let M,C;e[15]!==r||e[16]!==o||e[17]!==s?(M=()=>{if(!s)return;const G=Y=>{const ne=Y.target;if(!(ne instanceof Node)){o();return}a.current?.contains(ne)||r.current?.contains(ne)||o()};return document.addEventListener("pointerdown",G,!0),()=>document.removeEventListener("pointerdown",G,!0)},C=[r,o,s],e[15]=r,e[16]=o,e[17]=s,e[18]=M,e[19]=C):(M=e[18],C=e[19]),c.useEffect(M,C);let b;e[20]!==o||e[21]!==E?(b=G=>{E(G.id,hn(G)),o()},e[20]=o,e[21]=E,e[22]=b):b=e[22];const _=b;if(!u)return null;let V;e[23]!==i?(V=i("sessions.switcher.openAria"),e[23]=i,e[24]=V):V=e[24];const N=T?"absolute origin-top-left":"mx-3 mt-2",U=d?"pointer-events-none":"pointer-events-auto";let $;e[25]!==N||e[26]!==U?($=X("flex flex-col overflow-hidden rounded-[20px] border border-border/70 bg-[var(--surface-elevated)] p-2 shadow-[0_12px_32px_rgb(0_0_0_/_0.2)] will-change-transform",N,U),e[25]=N,e[26]=U,e[27]=$):$=e[27];const I=`${d?"session-switcher-out":"session-switcher-in"} ${d?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let B;e[28]!==h||e[29]!==T?(B=T?{top:8,left:h??8,width:`min(${hr}px, calc(100% - 16px))`}:null,e[28]=h,e[29]=T,e[30]=B):B=e[30];let Z;e[31]!==I||e[32]!==B?(Z={animation:I,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...B},e[31]=I,e[32]=B,e[33]=Z):Z=e[33];let ee;e[34]!==S||e[35]!==_||e[36]!==A||e[37]!==D||e[38]!==i?(ee=A.length===0?t.jsx("p",{className:"px-3 py-6 text-center typography-small text-muted-foreground",children:i("sessions.switcher.empty")}):A.map(G=>{const Y=G.node.session,ne=[G.secondaryMeta?.projectLabel,G.secondaryMeta?.branchLabel].filter(Boolean).join(" · ");return t.jsx(Sc,{session:Y,meta:ne,active:Y.id===S,onSelect:()=>{G.projectId&&D(G.projectId),_(Y)}},Y.id)}),e[34]=S,e[35]=_,e[36]=A,e[37]=D,e[38]=i,e[39]=ee):ee=e[39];let te;e[40]!==ee?(te=t.jsx("div",{className:"oc-hide-scrollbar min-h-0 flex-1 space-y-0.5 overflow-y-auto overscroll-contain",children:ee}),e[40]=ee,e[41]=te):te=e[41];let z;e[42]!==V||e[43]!==$||e[44]!==Z||e[45]!==te?(z=t.jsx("div",{ref:a,role:"dialog","aria-label":V,className:$,style:Z,children:te}),e[42]=V,e[43]=$,e[44]=Z,e[45]=te,e[46]=z):z=e[46];let W;e[47]===Symbol.for("react.memo_cache_sentinel")?(W=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]=W):W=e[47];let q;return e[48]!==z?(q=t.jsxs("div",{ref:g,className:"fixed inset-x-0 bottom-0 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-header-height,56px))] z-20 pointer-events-none",children:[z,W]}),e[48]=z,e[49]=q):q=e[49],q};function Cc(n){return n.currentSessionId}function Ec(n){return n.setCurrentSession}function Rc(n){return n.setActiveProjectIdOnly}const Pc=n=>{const e=ce.c(78),{onOpenSessions:s,onOpenWorkspace:o,compactTitle:r}=n,i=r===void 0?!1:r,{t:a}=fe(),[u,f]=c.useState(!1),[d,l]=c.useState(!1),p=c.useRef(null),g=vt(Ac),h=Ee(Tc);let x;e[0]!==h?(x=de=>h?de.getDirectoryForSession(h):null,e[0]=h,e[1]=x):x=e[1];const v=Ee(x)||g,T=ii(h,v||void 0),S=Ee(Ic),E=Vr(v||null);let D;e[2]!==v||e[3]!==E?(D=de=>{if(!v||E!==!0)return!1;const Te=de.directories.get(v)?.status;return!!(Te&&!Te.isClean)},e[2]=v,e[3]=E,e[4]=D):D=e[4];const w=Ke(D);let A;e[5]!==T?.title?(A=T?.title?.trim(),e[5]=T?.title,e[6]=A):A=e[6];const k=A;let P;e[7]!==h||e[8]!==k||e[9]!==a?(P=k||a(h?"mobile.sessions.untitled":"sessions.switcher.draftTitle"),e[7]=h,e[8]=k,e[9]=a,e[10]=P):P=e[10];const y=P;let O;e[11]===Symbol.for("react.memo_cache_sentinel")?(O=()=>{f(!1),l(!1)},e[11]=O):O=e[11];let M;e[12]!==h||e[13]!==v?(M=[h,v],e[12]=h,e[13]=v,e[14]=M):M=e[14],c.useEffect(O,M);let C;e[15]!==s?(C=()=>{f(!1),l(!1),s()},e[15]=s,e[16]=C):C=e[16];const b=C;let _;e[17]===Symbol.for("react.memo_cache_sentinel")?(_=de=>{f(Te=>{const Xe=typeof de=="function"?de(Te):de;return Xe&&l(!1),Xe})},e[17]=_):_=e[17];const V=_;let N;e[18]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{l(de=>{const Te=!de;return Te&&f(!1),Te})},e[18]=N):N=e[18];const U=N;let $;e[19]===Symbol.for("react.memo_cache_sentinel")?($={paddingTop:"var(--oc-safe-area-top, 0px)"},e[19]=$):$=e[19];let I;e[20]!==a?(I=a("mobile.sessions.openSheetAria"),e[20]=a,e[21]=I):I=e[21];let B,Z;e[22]===Symbol.for("react.memo_cache_sentinel")?(B={touchAction:"manipulation"},Z=t.jsx(Q,{name:"list-unordered",className:"size-5"}),e[22]=B,e[23]=Z):(B=e[22],Z=e[23]);let ee;e[24]!==b||e[25]!==I?(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-primary","aria-label":I,onClick:b,style:B,children:Z}),e[24]=b,e[25]=I,e[26]=ee):ee=e[26];const te=i?"shrink":"flex-1";let z;e[27]!==te?(z=X("flex min-w-0 items-center rounded-lg px-2 py-1.5 text-left transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",te),e[27]=te,e[28]=z):z=e[28];let W;e[29]!==a?(W=a("sessions.switcher.openAria"),e[29]=a,e[30]=W):W=e[30];let q;e[31]===Symbol.for("react.memo_cache_sentinel")?(q={touchAction:"manipulation"},e[31]=q):q=e[31];let G;e[32]!==y?(G=t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",children:y}),e[32]=y,e[33]=G):G=e[33];const Y=d&&"rotate-180";let ne;e[34]!==Y?(ne=X("size-4 shrink-0 text-muted-foreground transition-transform duration-150",Y),e[34]=Y,e[35]=ne):ne=e[35];let oe;e[36]!==ne?(oe=t.jsx(Q,{name:"arrow-down-s",className:ne}),e[36]=ne,e[37]=oe):oe=e[37];let le;e[38]!==G||e[39]!==oe?(le=t.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[G,oe]}),e[38]=G,e[39]=oe,e[40]=le):le=e[40];let ue;e[41]!==d||e[42]!==z||e[43]!==W||e[44]!==le?(ue=t.jsx("button",{ref:p,type:"button",className:z,"aria-label":W,"aria-haspopup":"dialog","aria-expanded":d,onClick:U,style:q,children:le}),e[41]=d,e[42]=z,e[43]=W,e[44]=le,e[45]=ue):ue=e[45];let K;e[46]!==i?(K=i?t.jsx("div",{className:"min-w-0 flex-1"}):null,e[46]=i,e[47]=K):K=e[47];let ie;e[48]!==h||e[49]!==v||e[50]!==S||e[51]!==u?(ie=t.jsx(wc,{open:u,onOpenChange:V,currentSessionId:h,effectiveDirectory:v,isNewSessionDraftOpen:S}),e[48]=h,e[49]=v,e[50]=S,e[51]=u,e[52]=ie):ie=e[52];let xe;e[53]!==w||e[54]!==a?(xe=a(w?"mobile.header.openWorkspaceWithChangesAria":"mobile.header.openWorkspaceAria"),e[53]=w,e[54]=a,e[55]=xe):xe=e[55];let Se;e[56]!==o?(Se=()=>{f(!1),l(!1),o()},e[56]=o,e[57]=Se):Se=e[57];let H,ve;e[58]===Symbol.for("react.memo_cache_sentinel")?(H={touchAction:"manipulation"},ve=t.jsx(Q,{name:"pencil-ruler-2",className:"size-5"}),e[58]=H,e[59]=ve):(H=e[58],ve=e[59]);let Re;e[60]!==w?(Re=w?t.jsx("span",{className:"absolute right-1.5 top-1.5 size-2.5 rounded-full border-2 border-[var(--background)] bg-[var(--status-warning)]","aria-hidden":!0}):null,e[60]=w,e[61]=Re):Re=e[61];let _e;e[62]!==xe||e[63]!==Se||e[64]!==Re?(_e=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-primary","aria-label":xe,onClick:Se,style:H,children:[ve,Re]}),e[62]=xe,e[63]=Se,e[64]=Re,e[65]=_e):_e=e[65];let ze;e[66]!==ee||e[67]!==ue||e[68]!==K||e[69]!==ie||e[70]!==_e?(ze=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:$,children:t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[ee,ue,K,ie,_e]})}),e[66]=ee,e[67]=ue,e[68]=K,e[69]=ie,e[70]=_e,e[71]=ze):ze=e[71];let Ye;e[72]===Symbol.for("react.memo_cache_sentinel")?(Ye=()=>l(!1),e[72]=Ye):Ye=e[72];let Pe;e[73]!==d?(Pe=t.jsx(Nc,{open:d,onClose:Ye,anchorRef:p}),e[73]=d,e[74]=Pe):Pe=e[74];let Ae;return e[75]!==ze||e[76]!==Pe?(Ae=t.jsxs(t.Fragment,{children:[ze,Pe]}),e[75]=ze,e[76]=Pe,e[77]=Ae):Ae=e[77],Ae};function Ac(n){return n.currentDirectory}function Tc(n){return n.currentSessionId}function Ic(n){return!!n.newSessionDraft?.open}const Dc=({onActiveConnectionDeleted:n,onConnect:e})=>{const{t:s}=fe(),o=vo(e),{connections:r,isBusy:i,isPasswordBusy:a,error:u,pendingConnection:f,connect:d,submitPassword:l,cancelPassword:p,saveConnection:g,removeConnection:h,setError:x}=o,[j,v]=c.useState(null),T=j?r.find(K=>K.id===j)??null:null,[S,E]=c.useState(null),[D,w]=c.useState(""),[A,k]=c.useState(""),[P,y]=c.useState(""),[O,M]=c.useState(""),[C,b]=c.useState(!1),[_,V]=c.useState(!1),N=c.useRef(null),U=c.useMemo(()=>un(),[]),[$,I]=c.useState(!1),[B,Z]=c.useState(null),[ee,te]=c.useState(!1),z=co(c.useCallback(()=>te(!0),[])),W=c.useCallback(()=>{v(null),w(""),k(""),y(""),x(null),I(!1)},[x]),q=c.useCallback(K=>{K.preventDefault(),g({id:j??void 0,url:D,label:A,clientToken:P}).then(ie=>{ie&&W()})},[P,j,A,W,g,D]),G=c.useCallback(async()=>{if(N.current)return;x(null),b(!0);const K=new AbortController;N.current=K;try{const ie=await No({signal:K.signal});switch(N.current===K&&(N.current=null,b(!1)),ie.status){case"ok":w(ie.url),ie.label&&k(ie.label),ie.clientToken&&y(ie.clientToken),I(!0);break;case"pairing":V(!0),await o.redeemPairingConnection(ie.pairing);break;case"permission-denied":x(s("mobile.connect.scan.permissionDenied"));break;case"invalid":x(s("mobile.connect.scan.invalid"));break;case"unsupported":x(s("mobile.connect.scan.unsupported"));break;case"failed":x(s("mobile.connect.scan.failed"));break;default:break}}finally{V(!1),N.current===K&&(N.current=null,b(!1))}},[o,x,s]);c.useEffect(()=>()=>N.current?.abort(),[]);const Y=c.useCallback(K=>{K.preventDefault(),l(O)},[O,l]),ne=c.useCallback(()=>{M(""),p()},[p]),oe=c.useCallback(K=>{E(ie=>ie===K?null:K)},[]),le=c.useCallback(K=>{E(null),j===K&&W();const ie=r.length===1;h(K).then(xe=>{xe&&(ie||fr(xe))&&n()})},[r.length,j,n,h,W]),ue=rs;return f?t.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:t.jsx("form",{className:"flex-1 overflow-y-auto px-5 py-4",onSubmit:Y,children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(Q,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:f.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:f.candidates.some(K=>K.kind==="direct")?at(f):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...Ot,value:O,onChange:K=>M(K.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:ue}),u?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:u}):null,t.jsx(he,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:a||!O.trim(),children:s(a?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(he,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:ne,children:s("mobile.connect.cancelPassword")})]})})}):t.jsxs(t.Fragment,{children:[C?t.jsx(Co,{onCancel:()=>N.current?.abort()}):null,_?t.jsx(Eo,{}):null,ee?t.jsx(wo,{onClose:()=>te(!1)}):null,t.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:t.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:t.jsxs("div",{className:"space-y-6",children:[r.length>0?t.jsx("div",{...z,className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map(K=>{const ie=S===K.id,xe=fr(K),Se=B===K.id,H=Se?s("mobile.connect.connecting"):xe?ds()?s("mobile.instances.status.connectedRelay"):s("mobile.instances.status.connectedDirect"):K.candidates.some(ve=>ve.kind==="direct")?at(K):s("mobile.connect.relay.badge");return t.jsxs("div",{className:X("flex items-center border-b border-border/70 transition-colors last:border-b-0",ie&&"bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]"),children:[t.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-3 px-3.5 py-3 text-left transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:opacity-60",onClick:()=>{xe||(Z(K.id),d({id:K.id,candidates:K.candidates,clientToken:K.clientToken,label:K.label}).finally(()=>Z(null)))},disabled:i&&!Se||ie,children:[t.jsxs("span",{className:"relative flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:[t.jsx(Q,{name:"server",className:"size-[18px]"}),xe?t.jsx("span",{className:"absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-[var(--surface-elevated)] bg-[var(--status-success)]","aria-hidden":!0}):null]}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:K.label}),t.jsx("span",{className:X("block truncate typography-small",xe&&!Se?"text-[var(--status-success)]":"text-muted-foreground"),children:H})]}),Se?t.jsx(Q,{name:"loader-4",className:"size-5 shrink-0 animate-spin text-muted-foreground"}):null]}),t.jsxs("div",{className:"flex items-center gap-0.5 pr-2",children:[ie?t.jsxs("button",{type:"button","aria-label":s("mobile.instances.confirmDeleteAria",{label:K.label}),className:"flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-destructive px-3 text-destructive-foreground transition-opacity active:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive",onClick:()=>le(K.id),style:{touchAction:"manipulation"},children:[t.jsx(Q,{name:"delete-bin",className:"size-[18px]"}),t.jsx("span",{className:"typography-ui-label",children:s("mobile.instances.delete")})]}):K.candidates.some(ve=>ve.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-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:()=>{v(K.id),w(at(K)),k(K.label),y(K.clientToken||""),x(null)},style:{touchAction:"manipulation"},children:t.jsx(Q,{name:"edit",className:"size-[18px]"})}):null,t.jsx("button",{type:"button","aria-label":ie?s("mobile.instances.cancelDeleteAria",{label:K.label}):s("mobile.instances.deleteAria",{label:K.label}),className:"flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:()=>oe(K.id),style:{touchAction:"manipulation"},children:t.jsx(Q,{name:ie?"close":"delete-bin",className:"size-[18px]"})})]})]},K.id)})}):t.jsx("p",{...z,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")}),!$&&!T?t.jsxs("div",{className:"space-y-2",children:[U?t.jsxs(he,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{G()},disabled:C,children:[t.jsx(Q,{name:"scan-2",className:X("size-[18px]",C&&"animate-pulse")}),s("mobile.connect.scanQr")]}):null,t.jsxs(he,{type:"button",variant:U?"ghost":"outline",size:"lg",className:"h-12 w-full",onClick:()=>{x(null),I(!0)},children:[t.jsx(Q,{name:"add",className:"size-[18px]"}),s("mobile.instances.addManual")]}),u?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:u}):null]}):t.jsxs("form",{className:"space-y-3",onSubmit:q,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(T?"mobile.instances.editTitle":"mobile.instances.addTitle")}),t.jsx(he,{type:"button",variant:"ghost",size:"xs",onClick:W,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",{...Ot,value:D,onChange:K=>w(K.target.value),placeholder:s("mobile.connect.url.placeholder"),type:"url",inputMode:"url",autoCapitalize:"none",className:ue})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"block px-1 typography-ui-label text-foreground",children:s("mobile.instances.label.label")}),t.jsx("input",{value:A,onChange:K=>k(K.target.value),placeholder:s("mobile.instances.label.placeholder"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,className:ue})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"block px-1 typography-ui-label text-foreground",children:s("mobile.connect.token.label")}),t.jsx("input",{...Ot,value:P,onChange:K=>y(K.target.value),placeholder:s("mobile.connect.token.placeholder"),autoCapitalize:"none",className:ue}),t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")})]}),u?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:u}):null,t.jsx(he,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",children:s(T?"mobile.instances.saveEdit":"mobile.instances.saveNew")})]})]})})})]})},Ie=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),en=n=>{const e=Ie(n);if(!e)return"";const s=e.split("/").filter(Boolean);return s[s.length-1]?.replace(/[-_]/g," ")||e},gr=Dn(n=>({expandedParents:{},toggleParent:e=>n(s=>{const o={...s.expandedParents};return o[e]?delete o[e]:o[e]=!0,{expandedParents:o}})})),Cs=Dn()(io(n=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(e,s)=>n(o=>({projectExpanded:{...o.projectExpanded,[e]:s}})),setWorktreeExpanded:(e,s)=>n(o=>({worktreeExpanded:{...o.worktreeExpanded,[e]:s}}))}),{name:"mobile-session-tree"})),dn=Dn()(io(n=>({orderByProject:{},setWorktreeOrder:(e,s)=>n(o=>({orderByProject:{...o.orderByProject,[e]:s}}))}),{name:"mobile-worktree-order"})),br=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),_c=(n,e)=>{if(!n||n.length===0)return e;const s=new Map(n.map((r,i)=>[br(r),i])),o=r=>s.get(br(r.path))??Number.MAX_SAFE_INTEGER;return e.map((r,i)=>({worktree:r,index:i})).sort((r,i)=>{const a=o(r.worktree)-o(i.worktree);return a!==0?a:r.index-i.index}).map(r=>r.worktree)},os=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/,""),Mc=n=>{const e=n;return os(e.directory??e.project?.worktree??null)},Po=({open:n,project:e,worktree:s,onClose:o,onDeleted:r})=>{const{t:i}=fe(),a=Gr(),u=pn(y=>y.activeSessions),f=Ee(y=>y.archiveSessions),d=vt(y=>y.currentDirectory),[l,p]=c.useState(!1),[g,h]=c.useState(!1),[x,j]=c.useState(!1),[v,T]=c.useState(!1),S=os(s?.path),E=typeof s?.branch=="string"&&s.branch.trim().length>0,D=c.useMemo(()=>{if(!S)return[];const y=new Map;for(const O of[...u,...a])Mc(O)===S&&y.set(O.id,O);return Array.from(y.values())},[u,a,S]);c.useEffect(()=>{if(!n){p(!1),h(!1),j(!1),T(!1);return}if(!s?.path)return;let y=!1;return ai(s.path).then(O=>{y||j(!!O?.isDirty)}).catch(()=>{y||j(!!s.status?.isDirty)}),()=>{y=!0}},[n,s?.path,s?.status?.isDirty]);const w=c.useCallback((y,O)=>{const M=li(y),C=ae.loading(i("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:M}));(async()=>{try{if(O.length>0){const{failedIds:b}=await f(O);if(b.length>0){ae.error(b.length===1?i("sessions.sidebar.bulkActions.failedArchiveSingle",{count:b.length}):i("sessions.sidebar.bulkActions.failedArchivePlural",{count:b.length}),{id:C,description:i("sessions.sidebar.dialogs.deleteResult.tryAgain")});return}}await ci(e,y,{deleteRemoteBranch:E&&g,deleteLocalBranch:E&&l}),os(d)===S&&os(e.path)&&vt.getState().setDirectory(os(e.path),{showOverlay:!1}),ae.success(i("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:M}),{id:C,description:i(E&&g?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed")}),r?.()}catch(b){ae.error(i("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:M}),{id:C,description:b instanceof Error?b.message:i("sessions.sidebar.dialogs.deleteResult.tryAgain")})}})()},[f,d,l,g,E,r,e,i,S]),A=()=>{!s||v||(T(!0),w(s,D.map(y=>y.id)),o())};if(!s)return null;const k=s.branch||s.label||s.path,P=(y,O,M,C)=>t.jsxs("button",{type:"button",role:"switch","aria-checked":y,disabled:C,onClick:()=>O(!y),className:X("flex w-full items-center justify-between gap-3 rounded-xl border border-border/70 px-3.5 py-3 text-left transition-colors","hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",C&&"pointer-events-none opacity-40"),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:M}),t.jsx("span",{className:X("relative h-6 w-10 shrink-0 rounded-full transition-colors",y?"bg-primary":"bg-muted-foreground/30"),children:t.jsx("span",{className:X("absolute top-0.5 size-5 rounded-full bg-white transition-transform",y?"translate-x-[1.125rem]":"translate-x-0.5")})})]});return t.jsx(Kr,{open:n,onClose:o,title:i("mobile.projectEdit.deleteWorktreeTitle"),footer:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(he,{variant:"ghost",className:"flex-1",onClick:o,disabled:v,children:i("projectEditDialog.actions.cancel")}),t.jsx(he,{variant:"destructive",className:"flex-1",onClick:()=>{A()},disabled:v,children:i("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:i("mobile.projectEdit.deleteWorktreeConfirm",{name:k})}),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:i("mobile.projectEdit.deleteWorktreeDirty")}):null,D.length>0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i("mobile.projectEdit.deleteWorktreeArchiveNote",{count:D.length})}):null,E?t.jsxs("div",{className:"flex flex-col gap-2",children:[P(l,p,i("mobile.projectEdit.deleteLocalBranch"),v),P(g,h,i("mobile.projectEdit.deleteRemoteBranch"),v)]}):null]})})},xr="mobile-surface-root",tn=16,Es=200,zc=()=>{if(typeof document>"u")return null;let n=document.getElementById(xr);return n||(n=document.createElement("div"),n.id=xr,document.body.appendChild(n)),n},is=({open:n,onClose:e,title:s,subtitle:o,trailing:r,disableEscapeDismiss:i=!1,headerless:a=!1,noHeaderBorder:u=!1,ariaLabel:f,variant:d="fullscreen",dialogAlign:l="chat",children:p})=>{const{t:g}=fe(),h=c.useRef(null),[x,j]=c.useState(!1),[v,T]=c.useState(!1),S=c.useRef(null),E=c.useRef(null),D=c.useRef(e);if(c.useEffect(()=>{D.current=e},[e]),typeof document<"u"&&!h.current&&(h.current=zc()),c.useEffect(()=>{if(!n){j(!1);return}const k=window.setTimeout(()=>j(!0),tn);return()=>window.clearTimeout(k)},[n]),c.useEffect(()=>{if(!n){T(!1);return}const k=window.setTimeout(()=>T(!0),tn+Es+80);return()=>window.clearTimeout(k)},[n]),c.useEffect(()=>{if(!n)return;const k=document.body.style.overflow;E.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow="hidden";const P=()=>{const M=S.current;if(!M)return;(M.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??M).focus({preventScroll:!0})},y=window.setTimeout(P,tn),O=M=>{if(M.key==="Escape"&&!i){D.current();return}if(M.key!=="Tab")return;const C=S.current;if(!C)return;const b=Array.from(C.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(U=>!U.hasAttribute("disabled")&&U.getAttribute("aria-hidden")!=="true");if(b.length===0){M.preventDefault(),C.focus({preventScroll:!0});return}const _=b[0],V=b[b.length-1],N=document.activeElement;M.shiftKey&&N===_?(M.preventDefault(),V.focus({preventScroll:!0})):!M.shiftKey&&N===V&&(M.preventDefault(),_.focus({preventScroll:!0}))};return document.addEventListener("keydown",O),()=>{window.clearTimeout(y),document.body.style.overflow=k,document.removeEventListener("keydown",O),E.current?.focus?.({preventScroll:!0}),E.current=null}},[i,n]),!n||!h.current)return null;const w=d==="dialog",A=t.jsxs("section",{ref:S,role:"dialog","aria-modal":"true","aria-label":f,tabIndex:-1,className:X("flex flex-col bg-background text-foreground",w?"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:w?{opacity:x?1:0,transform:x?"none":"scale(0.97)",transition:`opacity ${Es}ms ease-out, transform ${Es}ms cubic-bezier(0.32, 0.72, 0, 1)`}:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:x?"none":"translateX(100%)",transition:`transform ${Es}ms cubic-bezier(0.32, 0.72, 0, 1)`},onTransitionEnd:k=>{x&&k.target===k.currentTarget&&k.propertyName==="transform"&&T(!0)},children:[a?null:t.jsxs("header",{className:X("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",!u&&"border-b border-border/70"),children:[t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":g("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(Q,{name:"close",className:"size-5"})}),t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[s?typeof s=="string"?t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:s}):s:null,o?typeof o=="string"?t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:o}):o:null]}),r?t.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:r}):null]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:v?t.jsx("div",{className:"h-full",style:{animation:"oc-surface-content-in 200ms ease-out"},children:p}):null}),t.jsx("style",{children:"@keyframes oc-surface-content-in { from { opacity: 0 } to { opacity: 1 } }"})]});return w?Bt.createPortal(t.jsx("div",{className:"oc-keyboard-inset-surface oc-bottom-safe-surface fixed inset-0 z-50 flex items-center justify-center p-4 transition-opacity duration-200 ease-out",style:{background:"rgb(0 0 0 / 0.45)",opacity:x?1:0,paddingLeft:l==="chat"?"max(1rem, var(--oc-chat-inset-left, 0px))":"1rem",paddingRight:l==="chat"?"max(1rem, var(--oc-chat-inset-right, 0px))":"1rem",paddingTop:"max(1rem, var(--oc-safe-area-top, 0px))"},onClick:e,children:t.jsx("div",{className:"flex w-full max-w-[720px] justify-center",onClick:k=>k.stopPropagation(),children:A})}),h.current):Bt.createPortal(A,h.current)},Oc=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/,""),Bc=n=>{const e=ce.c(36),{worktree:s,onDelete:o}=n,{t:r}=fe();let i;e[0]!==s.path?(i={id:s.path},e[0]=s.path,e[1]=i):i=e[1];const{attributes:a,listeners:u,setNodeRef:f,transform:d,transition:l,isDragging:p}=Tn(i);let g;e[2]!==d?(g=In.Transform.toString(d),e[2]=d,e[3]=g):g=e[3];const h=p?10:1;let x;e[4]!==g||e[5]!==h||e[6]!==l?(x={transform:g,transition:l,zIndex:h},e[4]=g,e[5]=h,e[6]=l,e[7]=x):x=e[7];const j=x,v=s.branch||s.label||s.path,T=p&&"shadow-lg shadow-black/20";let S;e[8]!==T?(S=X("flex items-center gap-1 rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",T),e[8]=T,e[9]=S):S=e[9];let E;e[10]!==v||e[11]!==r?(E=r("mobile.projectEdit.dragWorktreeAria",{label:v}),e[10]=v,e[11]=r,e[12]=E):E=e[12];let D;e[13]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx(wn,{className:"size-4"}),e[13]=D):D=e[13];let w;e[14]!==a||e[15]!==u||e[16]!==E?(w=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":E,...a,...u,children:D}),e[14]=a,e[15]=u,e[16]=E,e[17]=w):w=e[17];let A;e[18]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx(Q,{name:"node-tree",className:"size-4 shrink-0 text-muted-foreground"}),e[18]=A):A=e[18];let k;e[19]!==v?(k=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:v}),e[19]=v,e[20]=k):k=e[20];let P;e[21]!==v||e[22]!==r?(P=r("mobile.projectEdit.deleteWorktreeAria",{label:v}),e[21]=v,e[22]=r,e[23]=P):P=e[23];let y,O;e[24]===Symbol.for("react.memo_cache_sentinel")?(y={touchAction:"manipulation"},O=t.jsx(Is,{className:"size-4"}),e[24]=y,e[25]=O):(y=e[24],O=e[25]);let M;e[26]!==o||e[27]!==P?(M=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":P,onClick:o,style:y,children:O}),e[26]=o,e[27]=P,e[28]=M):M=e[28];let C;return e[29]!==f||e[30]!==j||e[31]!==k||e[32]!==M||e[33]!==S||e[34]!==w?(C=t.jsxs("div",{ref:f,style:j,className:S,children:[w,A,k,M]}),e[29]=f,e[30]=j,e[31]=k,e[32]=M,e[33]=S,e[34]=w,e[35]=C):C=e[35],C},Lc=({open:n,project:e,onClose:s,onWorktreesChanged:o})=>{const{t:r}=fe(),{currentTheme:i}=Hr(),a=We(N=>N.updateProjectMeta),u=We(N=>N.discoverProjectIcon),f=We(N=>N.removeProjectIcon),d=dn(N=>N.setWorktreeOrder),l=We(N=>e?N.projects.find(U=>U.id===e.id)?.iconImage??null:null),[p,g]=c.useState(""),[h,x]=c.useState(null),[j,v]=c.useState(null),[T,S]=c.useState(!1),[E,D]=c.useState([]),[w,A]=c.useState(null),k=e?.id??null;c.useEffect(()=>{!n||!e||(g(e.label),x(e.icon??null),v(e.color??null),D(e.worktrees))},[n,k]),c.useEffect(()=>{!n||!e||D(N=>{const U=e.worktrees.map(B=>B.path),$=N.map(B=>B.path);return U.length===$.length&&U.every(B=>$.includes(B))?N:e.worktrees})},[e?.worktrees]);const P=kn($t(Nn,{activationConstraint:{distance:8}}),$t(Sn,{coordinateGetter:Rn})),y=()=>{if(!e)return;const N=p.trim();a(e.id,{label:N||e.label,icon:h,color:j}),s()},O=()=>{!e||T||(S(!0),u(e.id).then(N=>{if(!N.ok){ae.error(N.error||r("projectEditDialog.toast.failedToDiscoverIcon"));return}if(N.skipped){ae.success(r("projectEditDialog.toast.customIconAlreadySet"));return}ae.success(r("projectEditDialog.toast.iconDiscovered"))}).finally(()=>S(!1)))},M=()=>{e&&f(e.id).then(N=>{if(!N.ok){ae.error(N.error||r("projectEditDialog.toast.failedToRemoveIcon"));return}ae.success(r("projectEditDialog.toast.iconRemoved"))})},C=N=>{const{active:U,over:$}=N;if(!$||U.id===$.id||!e)return;const I=E.findIndex(te=>te.path===U.id),B=E.findIndex(te=>te.path===$.id);if(I<0||B<0)return;const Z=[...E],[ee]=Z.splice(I,1);Z.splice(B,0,ee),D(Z),d(e.id,Z.map(te=>Oc(te.path)))},b=j?qr[j]??null:null,_=h?Jr[h]:null,V=!!l;return t.jsxs(t.Fragment,{children:[t.jsx(is,{open:n,onClose:s,title:r("projectEditDialog.title"),ariaLabel:r("projectEditDialog.title"),noHeaderBorder:!0,trailing:t.jsxs(he,{type:"button",variant:"default",size:"sm","aria-label":r("projectEditDialog.actions.save"),onClick:y,disabled:!p.trim(),style:{touchAction:"manipulation"},children:[t.jsx(no,{className:"size-4"}),r("projectEditDialog.actions.save")]}),children:e?t.jsxs("div",{className:"h-full space-y-6 overflow-y-auto px-4 pb-8 pt-2",children:[t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx("span",{className:"flex size-16 items-center justify-center overflow-hidden rounded-2xl bg-[var(--surface-muted)] text-muted-foreground",style:e.iconBackground?{backgroundColor:e.iconBackground}:void 0,children:V?t.jsx(Yr,{project:{id:e.id,iconImage:l},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:"size-full object-contain",fallback:t.jsx(an,{className:"size-7"})}):_?t.jsx(Q,{name:_,className:"size-7",style:b?{color:b}:void 0}):t.jsx(an,{className:"size-7",style:b?{color:b}:void 0})})}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("projectEditDialog.field.name")}),t.jsx(xn,{value:p,onChange:N=>g(N.target.value),placeholder:r("projectEditDialog.field.namePlaceholder"),className:"h-11"}),t.jsx("p",{className:"truncate typography-meta text-muted-foreground",title:e.path,children:e.path})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("projectEditDialog.field.color")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>v(null),"aria-label":r("projectEditDialog.option.none"),className:X("flex size-9 items-center justify-center rounded-xl border-2 transition-all",j===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"})}),ui.map(N=>t.jsx("button",{type:"button",onClick:()=>v(N.key),"aria-label":N.label,title:N.label,className:X("size-9 rounded-xl border-2 transition-all",j===N.key?"border-foreground":"border-transparent hover:border-border/70"),style:{backgroundColor:N.cssVar,touchAction:"manipulation"}},N.key))]})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("projectEditDialog.field.icon")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>x(null),"aria-label":r("projectEditDialog.option.none"),className:X("flex size-9 items-center justify-center rounded-xl border-2 transition-all",h===null?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx("span",{className:"h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40"})}),di.map(N=>t.jsx("button",{type:"button",onClick:()=>x(N.key),"aria-label":N.label,title:N.label,className:X("flex size-9 items-center justify-center rounded-xl border-2 transition-all",h===N.key?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx(Q,{name:N.Icon,className:"size-4",style:b?{color:b}:void 0})},N.key))]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[t.jsx(he,{size:"sm",variant:"outline",onClick:O,disabled:T,children:r(T?"projectEditDialog.actions.discovering":"projectEditDialog.actions.discoverFavicon")}),V?t.jsx(he,{size:"sm",variant:"outline",onClick:M,children:r("projectEditDialog.actions.removeProjectIcon")}):null]})]}),e.isGitRepo?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("mobile.projectEdit.worktreesTitle")}),E.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:r("mobile.projectEdit.worktreesEmpty")}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:r("mobile.projectEdit.reorderHint")}),t.jsx(Cn,{sensors:P,collisionDetection:En,onDragEnd:C,children:t.jsx(Pn,{items:E.map(N=>N.path),strategy:An,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:E.map(N=>t.jsx(Bc,{worktree:N,onDelete:()=>A(N)},N.path))})})})]})]}):null]}):null}),e?t.jsx(Po,{open:!!w,project:{id:e.id,path:e.path},worktree:w,onClose:()=>A(null),onDeleted:()=>{D(N=>N.filter(U=>U.path!==w?.path)),o?.()}}):null]})},$c=32,Fc=80,Wc=64,Uc=.7,Fn=(n,e)=>{const s=c.useRef(e);s.current=e;const o=e.enabled??!0;c.useEffect(()=>{if(!o)return;const r=n.current;if(!r)return;const a=window.Capacitor?.getPlatform?.()==="android"?Fc:$c;let u=!1,f=!1,d=0,l=0;const p=h=>{if(h.touches.length!==1){u=!1;return}const x=h.touches[0],j=r.clientWidth,v=x.clientX<=a,T=x.clientX>=j-a;u=v||T,f=v,d=x.clientX,l=x.clientY},g=h=>{if(!u)return;u=!1;const x=h.changedTouches[0];if(!x)return;const j=x.clientX-d,v=x.clientY-l;Math.abs(j)<Wc||Math.abs(v)>Math.abs(j)*Uc||f&&j<=0||!f&&j>=0||(f?s.current.onLeftEdgeSwipe?.():s.current.onRightEdgeSwipe?.())};return r.addEventListener("touchstart",p,{passive:!0}),r.addEventListener("touchend",g,{passive:!0}),()=>{r.removeEventListener("touchstart",p),r.removeEventListener("touchend",g)}},[o,n])},Vc=new Set,Gc=[["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"]],sn=7,Rs=40,Kc=16,ts=n=>n.parentID??null,as=n=>{const e=n;return Ie(e.directory??e.project?.worktree??null)},Hc=n=>{const e=n.time?.updated??n.time?.created,s=typeof e=="number"?e:Number(e);return Number.isFinite(s)&&s>0?s:0},qc=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 o=Math.floor(s/60);if(o<24)return`${o}h`;const r=Math.floor(o/24);return r<7?`${r}d`:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(n))},Jc=(n,e)=>{const s=Ie(n),o=Ie(e);return!!(s&&o&&(s===o||s.startsWith(`${o}/`)))},Ts=(n,e)=>n.worktrees.find(s=>Ie(s.path)===e)??null,Ao=(n,e)=>e===n.path||!!Ts(n,e),nn=(n,e)=>{const s=Ie(e);return s?n.find(o=>Ao(o,s))??null:null},rn=(n,e,s)=>Xr([n.title,n.id,as(n),e],s),fn=n=>{const e=ce.c(17),{project:s,size:o}=n,r=o===void 0?"md":o,{currentTheme:i}=Hr(),a=s.icon?Jr[s.icon]:null,u=s.color?qr[s.color]??null:null,f=r==="sm"?"size-6 rounded-md":"size-8 rounded-lg",d=r==="sm"?"size-3.5":"size-4";let l;e[0]!==a||e[1]!==u||e[2]!==d?(l=a?t.jsx(Q,{name:a,className:d,style:u?{color:u}:void 0}):t.jsx(an,{className:d,style:u?{color:u}:void 0}),e[0]=a,e[1]=u,e[2]=d,e[3]=l):l=e[3];const p=l;let g;e[4]!==f?(g=X("flex shrink-0 items-center justify-center overflow-hidden bg-[var(--surface-muted)] text-muted-foreground",f),e[4]=f,e[5]=g):g=e[5];let h;e[6]!==s.iconBackground?(h=s.iconBackground?{backgroundColor:s.iconBackground}:void 0,e[6]=s.iconBackground,e[7]=h):h=e[7];let x;e[8]!==i||e[9]!==p||e[10]!==s.iconImage||e[11]!==s.id?(x=s.iconImage?t.jsx(Yr,{project:{id:s.id,iconImage:s.iconImage??null},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:"size-full object-contain",fallback:p}):p,e[8]=i,e[9]=p,e[10]=s.iconImage,e[11]=s.id,e[12]=x):x=e[12];let j;return e[13]!==g||e[14]!==h||e[15]!==x?(j=t.jsx("span",{className:g,style:h,children:x}),e[13]=g,e[14]=h,e[15]=x,e[16]=j):j=e[16],j},Yc=n=>{const e=ce.c(2),{ariaLabel:s}=n;let o;return e[0]!==s?(o=t.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-primary","aria-label":s}),e[0]=s,e[1]=o):o=e[1],o},yr=n=>{const e=ce.c(12),{onClick:s,className:o}=n,{t:r}=fe();let i;e[0]!==r?(i=r("sessions.sidebar.project.actions.newWorktree"),e[0]=r,e[1]=i):i=e[1];const a=i;let u;e[2]!==o?(u=X("flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] 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)]",o),e[2]=o,e[3]=u):u=e[3];let f;e[4]!==s?(f=g=>{g.stopPropagation(),s()},e[4]=s,e[5]=f):f=e[5];let d,l;e[6]===Symbol.for("react.memo_cache_sentinel")?(d={touchAction:"manipulation"},l=t.jsx(Q,{name:"node-tree",className:"size-4"}),e[6]=d,e[7]=l):(d=e[6],l=e[7]);let p;return e[8]!==a||e[9]!==u||e[10]!==f?(p=t.jsx("button",{type:"button",className:u,"aria-label":a,title:a,onClick:f,style:d,children:l}),e[8]=a,e[9]=u,e[10]=f,e[11]=p):p=e[11],p},vr=n=>{const e=ce.c(10),{label:s,onClick:o,className:r}=n;let i;e[0]!==r?(i=X("flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",r),e[0]=r,e[1]=i):i=e[1];let a;e[2]!==o?(a=l=>{l.stopPropagation(),o()},e[2]=o,e[3]=a):a=e[3];let u,f;e[4]===Symbol.for("react.memo_cache_sentinel")?(u={touchAction:"manipulation"},f=t.jsx(Q,{name:"add",className:"size-4"}),e[4]=u,e[5]=f):(u=e[4],f=e[5]);let d;return e[6]!==s||e[7]!==i||e[8]!==a?(d=t.jsx("button",{type:"button",className:i,"aria-label":s,title:s,onClick:a,style:u,children:f}),e[6]=s,e[7]=i,e[8]=a,e[9]=d):d=e[9],d},Tt=192,To=180,wr=n=>{const e=ce.c(25),{actionsWidth:s,actions:o,revealed:r,onRevealedChange:i,children:a}=n,u=c.useRef(null),f=c.useRef(null),d=c.useRef(!1),l=c.useRef(0),p=c.useRef(r);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=(C,b)=>{const _=u.current;_&&(_.style.transition=b?`transform ${To}ms ease-out`:"none",_.style.transform=C===0?"none":`translateX(${C}px)`,l.current=C)},e[0]=g):g=e[0];const h=g;let x,j;e[1]!==s||e[2]!==r?(x=()=>{p.current=r,h(r?s:0,!0)},j=[s,h,r],e[1]=s,e[2]=r,e[3]=x,e[4]=j):(x=e[3],j=e[4]),c.useEffect(x,j);let v;e[5]===Symbol.for("react.memo_cache_sentinel")?(v=C=>{if(C.touches.length!==1)return;const b=C.touches[0];f.current={x:b.clientX,y:b.clientY},d.current=!1},e[5]=v):v=e[5];const T=v;let S;e[6]!==s?(S=C=>{if(!f.current)return;const b=C.touches[0],_=b.clientX-f.current.x,V=b.clientY-f.current.y;if(!d.current){if(Math.abs(_)<8||Math.abs(_)<=Math.abs(V))return;d.current=!0}const N=p.current?s:0;h(Math.max(0,Math.min(s,N+_)),!1)},e[6]=s,e[7]=S):S=e[7];const E=S;let D;e[8]!==s||e[9]!==i?(D=()=>{if(f.current=null,!d.current)return;d.current=!1;const C=l.current>s/2;h(C?s:0,!0),C!==p.current&&i(C)},e[8]=s,e[9]=i,e[10]=D):D=e[10];const w=D;let A;e[11]===Symbol.for("react.memo_cache_sentinel")?(A={touchAction:"pan-y"},e[11]=A):A=e[11];let k;e[12]!==s?(k={width:s},e[12]=s,e[13]=k):k=e[13];const P=!r;let y;e[14]!==o||e[15]!==k||e[16]!==P?(y=t.jsx("div",{className:"absolute inset-y-0 left-0 flex items-stretch",style:k,"aria-hidden":P,children:o}),e[14]=o,e[15]=k,e[16]=P,e[17]=y):y=e[17];let O;e[18]!==a?(O=t.jsx("div",{ref:u,className:"relative flex w-full items-center bg-background",children:a}),e[18]=a,e[19]=O):O=e[19];let M;return e[20]!==w||e[21]!==E||e[22]!==y||e[23]!==O?(M=t.jsxs("div",{className:"relative overflow-hidden",onTouchStart:T,onTouchMove:E,onTouchEnd:w,onTouchCancel:w,style:A,children:[y,O]}),e[20]=w,e[21]=E,e[22]=y,e[23]=O,e[24]=M):M=e[24],M},Xc=n=>{const e=ce.c(41),{initialTitle:s,indent:o,onSubmit:r,onCancel:i}=n,{t:a}=fe(),[u,f]=c.useState(s),d=ou;let l;e[0]!==s||e[1]!==i||e[2]!==r||e[3]!==u?(l=()=>{const b=u.trim();if(!b||b===s.trim()){i();return}r(b)},e[0]=s,e[1]=i,e[2]=r,e[3]=u,e[4]=l):l=e[4];const p=l;let g;e[5]!==o?(g={paddingLeft:o},e[5]=o,e[6]=g):g=e[6];let h;e[7]!==p?(h=b=>{b.preventDefault(),p()},e[7]=p,e[8]=h):h=e[8];let x;e[9]===Symbol.for("react.memo_cache_sentinel")?(x=b=>f(b.target.value),e[9]=x):x=e[9];let j;e[10]!==i?(j=b=>Ea(b,i),e[10]=i,e[11]=j):j=e[11];let v;e[12]!==a?(v=a("sessions.sidebar.session.rename.save"),e[12]=a,e[13]=v):v=e[13];let T;e[14]!==a?(T=a("sessions.sidebar.session.menu.rename"),e[14]=a,e[15]=T):T=e[15];let S;e[16]===Symbol.for("react.memo_cache_sentinel")?(S={minHeight:0},e[16]=S):S=e[16];let E;e[17]!==j||e[18]!==v||e[19]!==T||e[20]!==u?(E=t.jsx("input",{ref:d,value:u,onChange:x,onKeyDown:j,"aria-label":v,placeholder:T,className:"min-w-0 flex-1 bg-transparent text-[16px] typography-ui-label text-foreground outline-none placeholder:text-muted-foreground",style:S,enterKeyHint:"done"}),e[17]=j,e[18]=v,e[19]=T,e[20]=u,e[21]=E):E=e[21];let D;e[22]!==a?(D=a("sessions.sidebar.session.rename.save"),e[22]=a,e[23]=D):D=e[23];let w,A;e[24]===Symbol.for("react.memo_cache_sentinel")?(w={touchAction:"manipulation",minHeight:0,minWidth:0},A=t.jsx(Q,{name:"check",className:"size-4"}),e[24]=w,e[25]=A):(w=e[24],A=e[25]);let k;e[26]!==D?(k=t.jsx("button",{type:"submit","aria-label":D,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-primary",style:w,children:A}),e[26]=D,e[27]=k):k=e[27];let P;e[28]!==a?(P=a("sessions.sidebar.session.rename.cancel"),e[28]=a,e[29]=P):P=e[29];let y,O;e[30]===Symbol.for("react.memo_cache_sentinel")?(y={touchAction:"manipulation",minHeight:0,minWidth:0},O=t.jsx(Q,{name:"close",className:"size-4"}),e[30]=y,e[31]=O):(y=e[30],O=e[31]);let M;e[32]!==i||e[33]!==P?(M=t.jsx("button",{type:"button",onClick:i,"aria-label":P,className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",style:y,children:O}),e[32]=i,e[33]=P,e[34]=M):M=e[34];let C;return e[35]!==k||e[36]!==M||e[37]!==g||e[38]!==h||e[39]!==E?(C=t.jsxs("form",{className:"flex h-9 min-w-0 flex-1 items-center gap-2 pr-2",style:g,onSubmit:h,children:[E,k,M]}),e[35]=k,e[36]=M,e[37]=g,e[38]=h,e[39]=E,e[40]=C):C=e[40],C},jr=n=>{const e=ce.c(52),{session:s,active:o,indent:r,contextLabel:i,hasChildren:a,expanded:u,onToggleChildren:f,onSelect:d,revealed:l,onRevealedChange:p,confirmingDelete:g,onArchive:h,onRequestDelete:x,onConfirmDelete:j,renaming:v,onRequestRename:T,onSubmitRename:S,onCancelRename:E}=n,D=a===void 0?!1:a,w=u===void 0?!1:u,A=l===void 0?!1:l,k=g===void 0?!1:g,P=v===void 0?!1:v,{t:y}=fe();let O;e[0]!==s?(O=qc(Hc(s)),e[0]=s,e[1]=O):O=e[1];const M=O,C=s.title?.trim()||y("mobile.sessions.untitled"),b=!!(p&&h),_=Ca(s.id,s.directory,b&&A),V=Fr(s.id),N=Wr(s.id),U=V?.type??"idle",$=U==="busy"||U==="retry",I=!$&&N>0&&!o,B=Ur(s.id,$),Z=($||I)&&B,ee=c.useRef(null),te=c.useRef(null),z=c.useRef(!1),W=c.useRef(0),q=c.useRef(A);let G;e[2]===Symbol.for("react.memo_cache_sentinel")?(G=(ye,Fe)=>{const et=ee.current;et&&(et.style.transition=Fe?`transform ${To}ms ease-out`:"none",et.style.transform=ye===0?"none":`translateX(${ye}px)`,W.current=ye)},e[2]=G):G=e[2];const Y=G;let ne,oe;e[3]!==A?(ne=()=>{q.current=A,Y(A?Tt:0,!0)},oe=[Y,A],e[3]=A,e[4]=ne,e[5]=oe):(ne=e[4],oe=e[5]),c.useEffect(ne,oe);let le;e[6]!==b?(le=ye=>{if(!b||ye.touches.length!==1)return;const Fe=ye.touches[0];te.current={x:Fe.clientX,y:Fe.clientY},z.current=!1},e[6]=b,e[7]=le):le=e[7];const ue=le;let K;e[8]!==b?(K=ye=>{if(!b||!te.current)return;const Fe=ye.touches[0],et=Fe.clientX-te.current.x,Le=Fe.clientY-te.current.y;if(!z.current){if(Math.abs(et)<8||Math.abs(et)<=Math.abs(Le))return;z.current=!0}const $e=q.current?Tt:0,Ue=Math.max(0,Math.min(Tt,$e+et));Y(Ue,!1)},e[8]=b,e[9]=K):K=e[9];const ie=K;let xe;e[10]!==p?(xe=()=>{if(te.current=null,!z.current)return;z.current=!1;const ye=W.current>Tt/2;Y(ye?Tt:0,!0),ye!==q.current&&p?.(ye)},e[10]=p,e[11]=xe):xe=e[11];const Se=xe,H=o||void 0,ve="relative overflow-hidden";let Re;e[12]!==b?(Re=b?{touchAction:"pan-y"}:void 0,e[12]=b,e[13]=Re):Re=e[13];const _e=b?t.jsxs("div",{className:"absolute inset-y-0 left-0 flex items-stretch",style:{width:Tt},"aria-hidden":!A,children:[t.jsx("button",{type:"button",tabIndex:A?0:-1,className:X("flex flex-1 items-center justify-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive",k?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80"),"aria-label":k?y("mobile.sessions.confirmDeleteSessionAria",{title:C}):y("mobile.sessions.deleteSessionAria",{title:C}),onClick:k?j:x,style:{touchAction:"manipulation"},children:t.jsx(Is,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:A?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-primary","aria-label":y("mobile.sessions.archiveSessionAria",{title:C}),onClick:h,style:{touchAction:"manipulation"},children:t.jsx(Xa,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:A?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-primary","aria-label":y("mobile.sessions.renameSessionAria",{title:C}),onClick:T,style:{touchAction:"manipulation"},children:t.jsx(ln,{className:"size-[18px]"})}),t.jsx(he,{variant:"ghost",size:"icon",tabIndex:A?0:-1,className:"flex-1 self-center text-muted-foreground",disabled:_.disabled,"aria-label":y("sessions.aiRename.action"),"aria-description":_.hint,title:_.hint,onClick:()=>{_.run(),p?.(!1)},style:{touchAction:"manipulation"},children:t.jsx(Q,{name:_.pending?"loader-4":"ai-generate-2",className:_.pending?"size-[18px] animate-spin":"size-[18px]"})})]}):null,ze=b&&"bg-background",Ye=o&&(b?"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]":"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]");let Pe;e[14]!==ze||e[15]!==Ye?(Pe=X("relative flex items-center gap-1 transition-colors",ze,Ye),e[14]=ze,e[15]=Ye,e[16]=Pe):Pe=e[16];let Ae;e[17]!==_.pending||e[18]!==w||e[19]!==D||e[20]!==r||e[21]!==$||e[22]!==f||e[23]!==I||e[24]!==y?(Ae=_.pending||$||I||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-primary",style:{left:Math.max(r-32,2),top:0,bottom:0,touchAction:"manipulation"},"aria-label":_.pending?y("sessions.aiRename.generating"):y(w?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),disabled:!D||!f,onClick:ye=>{ye.stopPropagation(),f?.()},children:_.pending?t.jsx(Q,{name:"loader-4",className:"size-3 animate-spin text-primary","aria-label":y("sessions.aiRename.generating")}):$||I?t.jsx("span",{className:X("size-1.5 rounded-full",$?"bg-primary":"bg-[var(--status-info)]"),"aria-hidden":!0}):t.jsx(jn,{className:X("size-[18px] transition-transform duration-150",w?"rotate-0":"-rotate-90")})}):null,e[17]=_.pending,e[18]=w,e[19]=D,e[20]=r,e[21]=$,e[22]=f,e[23]=I,e[24]=y,e[25]=Ae):Ae=e[25];let de;e[26]!==o||e[27]!==i||e[28]!==r||e[29]!==$||e[30]!==E||e[31]!==p||e[32]!==d||e[33]!==S||e[34]!==P||e[35]!==s.id||e[36]!==Z||e[37]!==M||e[38]!==C?(de=P&&S&&E?t.jsx(Xc,{initialTitle:C,indent:r,onSubmit:S,onCancel:E}):t.jsx("button",{type:"button",className:X("flex min-w-0 flex-1 items-center gap-2.5 pr-3.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",i?"min-h-10 py-1":"h-9"),style:{paddingLeft:r,touchAction:"manipulation"},onClick:()=>{if(q.current){p?.(!1);return}d()},children:t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[t.jsxs("span",{className:"flex items-center gap-2.5",children:[t.jsx("span",{className:X("block min-w-0 flex-1 truncate typography-ui-label",o?"text-primary":"text-foreground"),children:C}),Z?t.jsx(so,{sessionId:s.id,running:$,className:"typography-micro"}):M?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:M}):null]}),i?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:i}):null]})}),e[26]=o,e[27]=i,e[28]=r,e[29]=$,e[30]=E,e[31]=p,e[32]=d,e[33]=S,e[34]=P,e[35]=s.id,e[36]=Z,e[37]=M,e[38]=C,e[39]=de):de=e[39];let Te;e[40]!==Pe||e[41]!==Ae||e[42]!==de?(Te=t.jsxs("div",{ref:ee,className:Pe,children:[Ae,de]}),e[40]=Pe,e[41]=Ae,e[42]=de,e[43]=Te):Te=e[43];let Xe;return e[44]!==Se||e[45]!==ie||e[46]!==ue||e[47]!==H||e[48]!==Re||e[49]!==_e||e[50]!==Te?(Xe=t.jsxs("div",{"data-active-session":H,className:ve,onTouchStart:ue,onTouchMove:ie,onTouchEnd:Se,onTouchCancel:Se,style:Re,children:[_e,Te]}),e[44]=Se,e[45]=ie,e[46]=ue,e[47]=H,e[48]=Re,e[49]=_e,e[50]=Te,e[51]=Xe):Xe=e[51],Xe},Qc=n=>{const e=ce.c(11),{indent:s,onClick:o}=n,{t:r}=fe();let i;e[0]!==s?(i={paddingLeft:s,touchAction:"manipulation"},e[0]=s,e[1]=i):i=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(jn,{className:"size-4"}),e[2]=a):a=e[2];let u;e[3]!==r?(u=r("sessions.sidebar.group.showMore"),e[3]=r,e[4]=u):u=e[4];let f;e[5]!==u?(f=t.jsx("span",{className:"typography-micro",children:u}),e[5]=u,e[6]=f):f=e[6];let d;return e[7]!==o||e[8]!==i||e[9]!==f?(d=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pr-3 text-left text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",style:i,onClick:o,children:[a,f]}),e[7]=o,e[8]=i,e[9]=f,e[10]=d):d=e[10],d},Zc=n=>{const e=ce.c(11),{indent:s,onClick:o}=n,{t:r}=fe();let i;e[0]!==s?(i={paddingLeft:s,touchAction:"manipulation"},e[0]=s,e[1]=i):i=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(Qa,{className:"size-4"}),e[2]=a):a=e[2];let u;e[3]!==r?(u=r("sessions.sidebar.group.showFewer"),e[3]=r,e[4]=u):u=e[4];let f;e[5]!==u?(f=t.jsx("span",{className:"typography-micro",children:u}),e[5]=u,e[6]=f):f=e[6];let d;return e[7]!==o||e[8]!==i||e[9]!==f?(d=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pr-3 text-left text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",style:i,onClick:o,children:[a,f]}),e[7]=o,e[8]=i,e[9]=f,e[10]=d):d=e[10],d},eu=n=>{const e=ce.c(29),{worktree:s}=n,{t:o}=fe();let r;e[0]!==s.path?(r=Ie(s.path),e[0]=s.path,e[1]=r):r=e[1];const i=r;let a;e[2]!==i?(a={id:i},e[2]=i,e[3]=a):a=e[3];const{attributes:u,listeners:f,setNodeRef:d,transform:l,transition:p,isDragging:g}=Tn(a),h=s.branch||s.label||s.path;let x;e[4]!==l?(x=In.Transform.toString(l),e[4]=l,e[5]=x):x=e[5];const j=g?10:1;let v;e[6]!==x||e[7]!==j||e[8]!==p?(v={transform:x,transition:p,zIndex:j},e[6]=x,e[7]=j,e[8]=p,e[9]=v):v=e[9];const T=g&&"shadow-lg shadow-black/20";let S;e[10]!==T?(S=X("flex items-center gap-1 rounded-xl bg-background px-1 py-1",T),e[10]=T,e[11]=S):S=e[11];let E;e[12]!==h||e[13]!==o?(E=o("mobile.sessions.dragHandleAria",{label:h}),e[12]=h,e[13]=o,e[14]=E):E=e[14];let D;e[15]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx(wn,{className:"size-4"}),e[15]=D):D=e[15];let w;e[16]!==u||e[17]!==f||e[18]!==E?(w=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":E,...u,...f,children:D}),e[16]=u,e[17]=f,e[18]=E,e[19]=w):w=e[19];let A;e[20]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx(Q,{name:"git-branch",className:"size-4 shrink-0 text-muted-foreground"}),e[20]=A):A=e[20];let k;e[21]!==h?(k=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]=k):k=e[22];let P;return e[23]!==d||e[24]!==w||e[25]!==k||e[26]!==v||e[27]!==S?(P=t.jsxs("div",{ref:d,style:v,className:S,children:[w,A,k]}),e[23]=d,e[24]=w,e[25]=k,e[26]=v,e[27]=S,e[28]=P):P=e[28],P},tu=n=>{const e=ce.c(61),{project:s,totalSessions:o,expanded:r,onToggleExpanded:i,onReorderWorktrees:a}=n,{t:u}=fe();let f;e[0]!==s.id?(f={id:s.id},e[0]=s.id,e[1]=f):f=e[1];const{attributes:d,listeners:l,setNodeRef:p,transform:g,transition:h,isDragging:x}=Tn(f);let j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j={activationConstraint:{distance:8}},e[2]=j):j=e[2];let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v={coordinateGetter:Rn},e[3]=v):v=e[3];const T=kn($t(Nn,j),$t(Sn,v)),S=s.worktrees.length>0;let E;e[4]!==a||e[5]!==s.worktrees?(E=z=>{const{active:W,over:q}=z;if(!q||W.id===q.id)return;const G=s.worktrees.map(iu),Y=G.indexOf(String(W.id)),ne=G.indexOf(String(q.id));if(Y<0||ne<0)return;const oe=[...G],[le]=oe.splice(Y,1);oe.splice(ne,0,le),a(oe)},e[4]=a,e[5]=s.worktrees,e[6]=E):E=e[6];const D=E;let w;e[7]!==g?(w=In.Transform.toString(g),e[7]=g,e[8]=w):w=e[8];const A=x?10:1;let k;e[9]!==w||e[10]!==A||e[11]!==h?(k={transform:w,transition:h,zIndex:A},e[9]=w,e[10]=A,e[11]=h,e[12]=k):k=e[12];const P=x&&"shadow-lg shadow-black/20";let y;e[13]!==P?(y=X("rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",P),e[13]=P,e[14]=y):y=e[14];let O;e[15]!==s.label||e[16]!==u?(O=u("mobile.sessions.dragHandleAria",{label:s.label}),e[15]=s.label,e[16]=u,e[17]=O):O=e[17];let M;e[18]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx(wn,{className:"size-4"}),e[18]=M):M=e[18];let C;e[19]!==d||e[20]!==l||e[21]!==O?(C=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":O,...d,...l,children:M}),e[19]=d,e[20]=l,e[21]=O,e[22]=C):C=e[22];let b;e[23]!==r||e[24]!==s.label||e[25]!==u?(b=r?u("sessions.sidebar.group.collapseAria",{label:s.label}):u("sessions.sidebar.group.expandAria",{label:s.label}),e[23]=r,e[24]=s.label,e[25]=u,e[26]=b):b=e[26];const _=!S;let V;e[27]===Symbol.for("react.memo_cache_sentinel")?(V={touchAction:"manipulation"},e[27]=V):V=e[27];let N;e[28]!==s?(N=t.jsx(fn,{project:s}),e[28]=s,e[29]=N):N=e[29];let U;e[30]!==s.label?(U=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:s.label}),e[30]=s.label,e[31]=U):U=e[31];let $;e[32]!==o?($=t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:o}),e[32]=o,e[33]=$):$=e[33];let I;e[34]!==r||e[35]!==S?(I=S?t.jsx(jn,{className:X("size-4 shrink-0 text-muted-foreground transition-transform",r&&"rotate-180")}):null,e[34]=r,e[35]=S,e[36]=I):I=e[36];let B;e[37]!==r||e[38]!==i||e[39]!==b||e[40]!==_||e[41]!==N||e[42]!==U||e[43]!==$||e[44]!==I?(B=t.jsxs("button",{type:"button",className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 rounded-xl px-1 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary",onClick:i,"aria-expanded":r,"aria-label":b,disabled:_,style:V,children:[N,U,$,I]}),e[37]=r,e[38]=i,e[39]=b,e[40]=_,e[41]=N,e[42]=U,e[43]=$,e[44]=I,e[45]=B):B=e[45];let Z;e[46]!==C||e[47]!==B?(Z=t.jsxs("div",{className:"flex items-center gap-1",children:[C,B]}),e[46]=C,e[47]=B,e[48]=Z):Z=e[48];let ee;e[49]!==r||e[50]!==D||e[51]!==S||e[52]!==s.worktrees||e[53]!==T?(ee=r&&S?t.jsx(Cn,{sensors:T,collisionDetection:En,onDragEnd:D,children:t.jsx(Pn,{items:s.worktrees.map(au),strategy:An,children:t.jsx("div",{className:"mt-1 flex flex-col gap-0.5 pl-3",children:s.worktrees.map(lu)})})}):null,e[49]=r,e[50]=D,e[51]=S,e[52]=s.worktrees,e[53]=T,e[54]=ee):ee=e[54];let te;return e[55]!==p||e[56]!==Z||e[57]!==ee||e[58]!==k||e[59]!==y?(te=t.jsxs("div",{ref:p,style:k,className:y,children:[Z,ee]}),e[55]=p,e[56]=Z,e[57]=ee,e[58]=k,e[59]=y,e[60]=te):te=e[60],te},kr=({open:n,onOpenChange:e,variant:s="drawer",footer:o})=>{const{t:r}=fe(),{git:i}=yn(),a=Gr(),u=pn(m=>m.activeSessions),f=Lr(c.useCallback(m=>n||s==="sidebar"?m.ids:Vc,[n,s])),d=$r(c.useCallback(m=>n||s==="sidebar"?m.rankById:fi,[n,s])),l=We(m=>m.projects),p=We(m=>m.activeProjectId),g=vt(m=>m.currentDirectory),h=Ee(m=>m.currentSessionId),x=Ee(m=>m.setCurrentSession),j=Ee(m=>m.archiveSession),v=Ee(m=>m.deleteSession),T=Ee(m=>m.updateSessionTitle),S=Ee(m=>m.openNewSessionDraft),E=We(m=>m.setActiveProject),D=We(m=>m.setActiveProjectIdOnly),w=We(m=>m.reorderProjects),A=We(m=>m.manualProjectOrder),k=Kn(m=>m.projectSortOrder),P=Kn(m=>m.setProjectSortOrder),y=We(m=>m.removeProject),O=Cs(m=>m.projectExpanded),M=Cs(m=>m.worktreeExpanded),C=Cs(m=>m.setProjectExpanded),b=Cs(m=>m.setWorktreeExpanded),_=dn(m=>m.orderByProject),V=dn(m=>m.setWorktreeOrder),N=gr(m=>m.expandedParents),U=gr(m=>m.toggleParent),[$,I]=c.useState(""),[B,Z]=c.useState(null),[ee,te]=c.useState(null),[z,W]=c.useState(null),[q,G]=c.useState(null),[Y,ne]=c.useState(null),[oe,le]=c.useState(null),[ue,K]=c.useState(null),[ie,xe]=c.useState(0),[Se,H]=c.useState(!1),[ve,Re]=c.useState(!1),[_e,ze]=c.useState(!1),[Ye,Pe]=c.useState(null),[Ae,de]=c.useState(()=>new Map(Ee.getState().availableWorktreesByProject)),[Te,Xe]=c.useState(()=>{const m=new Set;for(const[F,J]of Ee.getState().availableWorktreesByProject)J.length>0&&m.add(F);return m}),[ye,Fe]=c.useState(!1),[et,Le]=c.useState(new Set),[$e,Ue]=c.useState(new Map);c.useEffect(()=>{if(!n){I(""),Fe(!1),Le(new Set),Ue(new Map),Z(null),te(null),W(null),G(null),ne(null),le(null);return}bn(a)},[n]),c.useEffect(()=>{ye||Le(new Set)},[ye]),c.useEffect(()=>{if(!n||l.length===0)return;let m=!1;return(async()=>{const J=await Promise.all(l.map(async pe=>{const me=Ie(pe.path);if(!me)return null;const Be=await i.checkIsGitRepository(me).catch(()=>!1),Ze=Be?await Qr({id:pe.id,path:me}).catch(()=>[]):[];return[me,Ze,Be]}));if(m)return;const re=new Map,ge=new Set;for(const pe of J)pe&&(re.set(pe[0],pe[1]),pe[2]&&ge.add(pe[0]));de(Zr(l,re)),Xe(ge)})(),()=>{m=!0}},[i,n,l,ie]);const ke=c.useMemo(()=>ja(l.map(m=>({id:m.id,label:m.label?.trim()||en(m.path),path:Ie(m.path),icon:m.icon,color:m.color,iconImage:m.iconImage,iconBackground:m.iconBackground,isGitRepo:Te.has(Ie(m.path)),worktrees:_c(_[m.id],Ae.get(Ie(m.path))??[]),addedAt:m.addedAt,lastOpenedAt:m.lastOpenedAt})),k,A),[Te,A,k,l,_,Ae]),tt=c.useMemo(()=>{const m=new Map(a.map(re=>[re.id,re])),F=u.map(re=>{const ge=m.get(re.id);return ge?mi(ge,re):re}),J=new Set(F.map(re=>re.id));for(const re of a)J.has(re.id)||F.push(re);return F.filter(re=>!re.time?.archived)},[u,a]),{projectSessions:ms,chatSessions:lt}=c.useMemo(()=>ka(tt,!1),[tt]),we=c.useMemo(()=>({key:Qt,label:"",path:"",worktree:null,sessions:Xs(lt,f,d)}),[lt,f,d]),ps=`${Qt}::${Qt}`,Kt=c.useMemo(()=>lt.filter(m=>!ts(m)).length,[lt]),Ce=$.trim().toLowerCase(),hs=c.useRef(null);c.useEffect(()=>{if(!n)return;const m=window.requestAnimationFrame(()=>{const F=hs.current;if(!F)return;(F.querySelector('[data-active-session="true"]')??F.querySelector('[data-active-project="true"]'))?.scrollIntoView({block:"center"})});return()=>window.cancelAnimationFrame(m)},[n]);const Nt=c.useMemo(()=>{const m=ke.map(J=>({project:J,buckets:[],totalSessions:0,isActive:J.id===p})),F=(J,re,ge)=>{const pe=Ie(re)||J.project.path,me=pe||"__root__";let Be=J.buckets.find(Ze=>Ze.key===me);return Be||(Be={key:me,label:ge?.branch||en(pe),path:pe,worktree:ge,sessions:[]},J.buckets.push(Be)),Be};for(const J of m){F(J,J.project.path,null);for(const re of J.project.worktrees)F(J,re.path,re)}for(const J of ms){const re=as(J);if(!re)continue;const ge=Ie(re),pe=m.find(Ze=>Ao(Ze.project,ge));if(!pe)continue;const me=Ts(pe.project,ge);(me?F(pe,me.path,me):F(pe,pe.project.path,null)).sessions.push(J)}for(const J of m)for(const re of J.buckets){re.sessions=Xs(re.sessions,f,d);for(const ge of re.sessions)ts(ge)||(J.totalSessions+=1)}return m},[p,f,ms,ke,d]),gs=Ie(g),Fs=m=>m.isActive?gs===m.project.path?m.project.path:m.project.worktrees.find(J=>Jc(gs,J.path))?.path??m.project.path:null,mt=m=>O[m.project.id]??!0,Ve=(m,F)=>M[`${m.project.id}::${F.key}`]??!0,Qe=m=>{Ue(F=>{if(!F.has(m))return F;const J=new Map(F);return J.delete(m),J})},Ht=m=>{Ue(F=>{let J=!1;const re=new Map(F),ge=`${m}::`;for(const pe of re.keys())pe.startsWith(ge)&&(re.delete(pe),J=!0);return J?re:F})},ct=(m,F)=>{Ue(J=>{const re=new Map(J);return re.set(m,F+sn),re})},qt=(m,F,J)=>{const re=new Set(F.sessions.map(Ne=>Ne.id)),ge=new Map;for(const Ne of F.sessions){const rt=ts(Ne);if(rt&&re.has(rt)){const Yt=ge.get(rt)??[];Yt.push(Ne),ge.set(rt,Yt)}}const pe=F.sessions.filter(Ne=>{const rt=ts(Ne);return!rt||!re.has(rt)}),me=$e.get(m)??sn,Be=pe.slice(0,me),Ze=pe.length-Be.length,Js=pe.length>sn&&Ze===0,Un=(Ne,rt)=>{const Yt=ge.get(Ne.id)??[],Ys=Yt.length>0,Vn=!!N[Ne.id];return t.jsxs(c.Fragment,{children:[t.jsx(jr,{session:Ne,active:h===Ne.id,indent:rt,hasChildren:Ys,expanded:Vn,onToggleChildren:Ys?()=>U(Ne.id):void 0,onSelect:()=>xs(Ne),revealed:ee===Ne.id,onRevealedChange:Xt=>Ws(Ne.id,Xt),confirmingDelete:z===Ne.id,onArchive:()=>{Us(Ne)},onRequestDelete:()=>W(Ne.id),onConfirmDelete:()=>{Vs(Ne)},renaming:q===Ne.id,onRequestRename:()=>Ct(Ne.id),onSubmitRename:Xt=>{ys(Ne.id,Xt)},onCancelRename:()=>G(null)}),Ys&&Vn?Yt.map(Xt=>Un(Xt,rt+Kc)):null]},Ne.id)};return t.jsxs("div",{children:[Be.map(Ne=>Un(Ne,J)),Ze>0?t.jsx(Qc,{indent:J,onClick:()=>ct(m,Be.length)}):null,Js?t.jsx(Zc,{indent:J,onClick:()=>Qe(m)}):null]})},bs=(m,F)=>{C(m,!F),Ht(m)},Oe=(m,F,J)=>{b(`${m}::${F}`,!J),Qe(`${m}::${F}`)},xs=m=>{const F=as(m)||null,J=nn(ke,F??"");if(J){D(J.id),C(J.id,!0);const re=Ts(J,Ie(F??""));re&&b(`${J.id}::${Ie(re.path)}`,!0)}x(m.id,F),e(!1)},Ws=(m,F)=>{te(F?m:null),W(null),ne(null),le(null)},nt=(m,F)=>{ne(F?m:null),le(null),te(null),W(null)},Us=async m=>{te(null),W(null),await j(m.id)?ae.success(r("sessions.sidebar.session.archive.success")):ae.error(r("sessions.sidebar.session.archive.error"))},Vs=async m=>{te(null),W(null),await v(m.id)?ae.success(r("sessions.sidebar.session.delete.success")):ae.error(r("sessions.sidebar.session.delete.error"))},Ct=m=>{te(null),W(null),G(m)},ys=async(m,F)=>{G(null);try{await T(m,F)}catch{ae.error(r("mobile.sessions.renameError"))}},pt=()=>{S(),e(!1)},Et=m=>{Pe(m),D(m),ze(!0)},Jt=kn($t(Nn,{activationConstraint:{distance:8}}),$t(Sn,{coordinateGetter:Rn})),vs=m=>{P(m),$o({sidebarProjectSortOrder:m}),m!=="manual"&&Fe(!1)},Gs=m=>{const{active:F,over:J}=m;if(!J||F.id===J.id)return;const re=ke.findIndex(pe=>pe.id===F.id),ge=ke.findIndex(pe=>pe.id===J.id);re<0||ge<0||w(re,ge)},Ks=m=>{Le(F=>{const J=new Set(F);return J.has(m)?J.delete(m):J.add(m),J})},ws=c.useCallback(m=>{const F=as(m);if(pi(F))return r("mobile.sessions.section.chats");const J=nn(ke,F);if(!J)return en(F)||F;const re=Ts(J,Ie(F));return re?.branch?`${J.label} · ${re.branch}`:J.label},[ke,r]),Hs=m=>{E(m.id),e(!1)},Rt=m=>{D(m.id),S({selectedProjectId:m.id,directoryOverride:m.path}),e(!1)},js=c.useMemo(()=>Ce?Nt.filter(m=>Xr([m.project.label,m.project.path],Ce)?!0:m.buckets.some(F=>F.sessions.some(J=>rn(J,m.project.label,Ce)))):Nt,[Ce,Nt]),Pt=c.useMemo(()=>Ce?Xs(tt.filter(m=>{if(ts(m))return!1;const F=as(m),J=nn(ke,F);return rn(m,J?.label??"",Ce)}),f,d):[],[Ce,f,ke,d,tt]),R=c.useMemo(()=>Ce?hi(ke,Ce,m=>[m.label,m.path]):[],[Ce,ke]),L=Ce&&Pt.length===0&&R.length===0,se=!Ce&&ke.length>1&&k==="manual",je=!ye&&!Ce&&ke.length>1?t.jsx(he,{type:"button",variant:"chip",size:"sm","aria-label":r("sessions.sidebar.header.actions.sortProjects"),title:r("sessions.sidebar.header.actions.sortProjects"),onClick:()=>H(!0),style:{touchAction:"manipulation"},children:t.jsx(Q,{name:"equalizer-2",className:"size-4"})}):null,Ge=se?t.jsx(he,{type:"button",variant:"chip",size:"sm","aria-label":r(ye?"mobile.sessions.doneEditing":"mobile.sessions.editOrder"),"aria-pressed":ye,onClick:()=>Fe(m=>!m),style:{touchAction:"manipulation"},children:ye?t.jsx(no,{className:"size-4"}):t.jsx(ln,{className:"size-4"})}):null,ut=!ye&&ke.length>0?t.jsxs(he,{type:"button",variant:"default",size:"sm","aria-label":r("mobile.sessions.newChat"),onClick:pt,style:{touchAction:"manipulation"},children:[t.jsx(Ya,{className:"size-4"}),r("mobile.sessions.newChat")]}):null,dt=ye?null:t.jsx(he,{type:"button",variant:"chip",size:"sm","aria-label":r("sessions.sidebar.header.actions.addProject"),title:r("sessions.sidebar.header.actions.addProject"),onClick:()=>Re(!0),style:{touchAction:"manipulation"},children:t.jsx(Zn,{className:"size-4"})}),ht=ut||dt||je||Ge?t.jsxs(t.Fragment,{children:[dt,je,Ge,ut]}):null,ks=t.jsxs("div",{ref:hs,className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs(Bs,{className:"min-h-0 flex-1 overflow-y-auto pb-4",children:[t.jsx("div",{className:X("px-4 pb-2 pt-1",ye&&"hidden"),children:t.jsxs("div",{className:"relative",children:[t.jsx(ro,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(xn,{value:$,onChange:m=>I(m.target.value),placeholder:r("mobile.sessions.search.placeholder"),className:X("h-11 pl-9",$&&"pr-10")}),$?t.jsx("button",{type:"button",className:"absolute right-1.5 top-1/2 flex size-8 -translate-y-1/2 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-primary","aria-label":r("mobile.sessions.clearSearchAria"),onClick:()=>I(""),style:{touchAction:"manipulation"},children:t.jsx(oo,{className:"size-4"})}):null]})}),ke.length===0&&lt.length===0?t.jsx(Cr,{title:r("mobile.sessions.empty.noProjectsTitle"),description:r("mobile.sessions.empty.noProjectsDescription"),action:t.jsxs("button",{type:"button",className:"flex items-center justify-center gap-2 rounded-2xl bg-primary px-5 py-3 typography-ui-label text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:()=>Re(!0),children:[t.jsx(Zn,{className:"size-4"}),r("sessions.sidebar.header.actions.addProject")]})}):L?t.jsx(Cr,{title:r("mobile.sessions.empty.searchTitle"),description:r("mobile.sessions.empty.searchDescription")}):Ce&&!ye?t.jsxs("div",{className:"flex flex-col gap-3 px-3 pt-2",children:[Pt.length>0?t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center justify-between px-1 pb-1.5",children:[t.jsx("span",{className:"typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:r("mobile.sessions.search.section.sessions")}),t.jsx("span",{className:"typography-micro text-muted-foreground tabular-nums",children:Pt.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:Pt.map((m,F)=>t.jsx("div",{className:X(F>0&&"border-t border-border/70"),children:t.jsx(jr,{session:m,active:h===m.id,indent:12,contextLabel:ws(m),onSelect:()=>xs(m)})},m.id))})]}):null,R.length>0?t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center justify-between px-1 pb-1.5",children:[t.jsx("span",{className:"typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:r("mobile.sessions.search.section.projects")}),t.jsx("span",{className:"typography-micro text-muted-foreground tabular-nums",children:R.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:R.map((m,F)=>t.jsxs("div",{className:X("flex items-center",F>0&&"border-t border-border/70"),children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-3 px-3 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",onClick:()=>Hs(m),style:{touchAction:"manipulation"},children:[t.jsx(fn,{project:m}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:m.label})]}),m.isGitRepo?t.jsx(yr,{onClick:()=>Et(m.id)}):null,t.jsx(vr,{className:"mr-2",label:r("mobile.sessions.newSessionInProjectAria",{label:m.label}),onClick:()=>Rt(m)})]},m.id))})]}):null]}):ye?t.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2",children:[t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:r("mobile.sessions.editOrderHint")}),t.jsx(Cn,{sensors:Jt,collisionDetection:En,onDragEnd:Gs,children:t.jsx(Pn,{items:ke.map(m=>m.id),strategy:An,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:ke.map(m=>{const F=Nt.find(J=>J.project.id===m.id);return t.jsx(tu,{project:m,totalSessions:F?.totalSessions??0,expanded:et.has(m.id),onToggleExpanded:()=>Ks(m.id),onReorderWorktrees:J=>V(m.id,J)},m.id)})})})})]}):t.jsxs("div",{className:"flex flex-col",children:[(()=>{const m=O[Qt]??!0,F=r("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-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",onClick:()=>{if(Y){nt(Y,!1);return}bs(Qt,m)},"aria-expanded":m,"aria-label":m?r("sessions.sidebar.group.collapseAria",{label:F}):r("sessions.sidebar.group.expandAria",{label:F}),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-[var(--surface-muted)] text-muted-foreground",children:t.jsx(Q,{name:"chat-4",className:"size-4"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:F}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:Kt})]})}),m?t.jsx("div",{className:"pb-2",children:we.sessions.length>0?qt(ps,we,Rs):t.jsx("p",{className:"px-3 pb-1 typography-micro text-muted-foreground",style:{paddingLeft:Rs},children:r("sessions.sidebar.activity.chatsEmpty")})}):null]})})(),js.map(m=>{const F=mt(m),J=Ce?m.buckets.filter(ge=>ge.sessions.some(pe=>rn(pe,m.project.label,Ce))):m.buckets,re=Fs(m);return t.jsxs("section",{className:"border-t border-border/70",children:[t.jsx(wr,{actionsWidth:96,revealed:Y===`project:${m.project.id}`,onRevealedChange:ge=>nt(`project:${m.project.id}`,ge),actions:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:Y===`project:${m.project.id}`?0:-1,className:X("flex flex-1 items-center justify-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive",oe===m.project.id?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80"),"aria-label":oe===m.project.id?r("mobile.sessions.confirmRemoveProjectAria",{label:m.project.label}):r("mobile.sessions.removeProjectAria",{label:m.project.label}),onClick:()=>{if(oe===m.project.id){ne(null),le(null),y(m.project.id),ae.success(r("mobile.sessions.toast.projectRemoved",{label:m.project.label}));return}le(m.project.id)},style:{touchAction:"manipulation"},children:t.jsx(Is,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:Y===`project:${m.project.id}`?0:-1,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary","aria-label":r("mobile.sessions.editProjectAria",{label:m.project.label}),onClick:()=>{ne(null),Z(m.project.id)},style:{touchAction:"manipulation"},children:t.jsx(ln,{className:"size-[18px]"})})]}),children:t.jsxs("div",{"data-active-project":m.isActive||void 0,className:"flex min-h-12 w-full items-center",children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",onClick:()=>{if(Y){nt(Y,!1);return}bs(m.project.id,F)},"aria-expanded":F,"aria-label":F?r("sessions.sidebar.group.collapseAria",{label:m.project.label}):r("sessions.sidebar.group.expandAria",{label:m.project.label}),style:{touchAction:"manipulation"},children:[t.jsx(fn,{project:m.project}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:m.project.label})]}),m.project.isGitRepo?t.jsx(yr,{onClick:()=>Et(m.project.id)}):null,t.jsx(vr,{className:"mr-2",label:r("mobile.sessions.newSessionInProjectAria",{label:m.project.label}),onClick:()=>Rt(m.project)})]})}),F?t.jsx("div",{className:"pb-2",children:(()=>{const ge=J.find(me=>me.worktree===null),pe=J.filter(me=>me.worktree!==null);return t.jsxs(t.Fragment,{children:[ge&&ge.sessions.length>0?qt(`${m.project.id}::${ge.key}`,ge,Rs):null,pe.map(me=>{const Be=Ve(m,me),Ze=re===me.path;return t.jsxs("div",{children:[t.jsx(wr,{actionsWidth:48,revealed:Y===`wt:${me.key}`,onRevealedChange:Js=>nt(`wt:${me.key}`,Js),actions:t.jsx("button",{type:"button",tabIndex:Y===`wt:${me.key}`?0:-1,className:"flex flex-1 items-center justify-center text-[var(--status-error)] transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive","aria-label":r("mobile.projectEdit.deleteWorktreeAria",{label:me.label}),onClick:()=>{ne(null),me.worktree&&K({project:m.project,worktree:me.worktree})},style:{touchAction:"manipulation"},children:t.jsx(Is,{className:"size-[18px]"})}),children:t.jsxs("button",{type:"button",className:"flex min-h-10 w-full items-center gap-2 px-3 py-1 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",onClick:()=>{if(Y){nt(Y,!1);return}Oe(m.project.id,me.key,Be)},"aria-expanded":Be,"aria-label":Be?r("sessions.sidebar.group.collapseAria",{label:me.label}):r("sessions.sidebar.group.expandAria",{label:me.label}),style:{touchAction:"manipulation"},children:[t.jsx(Q,{name:"git-branch",className:X("size-4 shrink-0",Ze?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:X("block min-w-0 flex-1 truncate typography-ui-label font-bold",Ze?"text-foreground":"text-muted-foreground"),children:me.label}),Ze?t.jsx(Yc,{ariaLabel:r("mobile.sessions.activeWorktreeAria")}):null,t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:me.sessions.length})]})}),Be?qt(`${m.project.id}::${me.key}`,me,Rs):null]},me.key)})]})})()}):null]},m.project.id)})]})]}),o?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:[o.instanceLabel&&o.onOpenInstances?t.jsxs(he,{type:"button",variant:"info",size:"lg",className:"min-w-0 shrink justify-start",onClick:o.onOpenInstances,"aria-label":r("mobile.menu.instances"),style:{touchAction:"manipulation"},children:[t.jsx(Q,{name:"server",className:"size-[18px]"}),t.jsx("span",{className:"block min-w-0 truncate",children:o.instanceLabel})]}):t.jsx("div",{className:"min-w-0 flex-1"}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[o.onOpenUpdate?t.jsxs(he,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:o.onOpenUpdate,"aria-label":r("mobile.menu.update"),title:r("mobile.menu.update"),style:{touchAction:"manipulation"},children:[t.jsx(Q,{name:"download",className:"size-5"}),t.jsx("span",{className:"absolute right-2 top-2 inline-flex size-2 rounded-full bg-primary","aria-hidden":!0})]}):null,t.jsx(he,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:o.onOpenSettings,"aria-label":r("mobile.menu.settings"),title:r("mobile.menu.settings"),style:{touchAction:"manipulation"},children:t.jsx(Q,{name:"settings-3",className:"size-5"})})]})]}):null,t.jsx(Sa,{open:ve,onOpenChange:Re}),t.jsx(Na,{open:_e,onOpenChange:m=>{ze(m),m||Pe(null)},onWorktreeCreated:(m,F)=>{F?.sessionId?x(F.sessionId,m):S({selectedProjectId:Ye,directoryOverride:m,preserveDirectoryOverride:!0}),e(!1)}}),t.jsx(Lc,{open:B!==null,project:ke.find(m=>m.id===B)??null,onClose:()=>Z(null),onWorktreesChanged:()=>xe(m=>m+1)}),t.jsx(Kr,{open:Se,onClose:()=>H(!1),title:r("sessions.sidebar.header.actions.sortProjects"),children:t.jsx("div",{className:"flex flex-col",children:Gc.map(([m,F])=>t.jsxs("button",{type:"button",className:X("flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-left transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary",k===m?"text-primary":"text-foreground"),onClick:()=>{vs(m),H(!1)},style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label",children:r(F)}),k===m?t.jsx(Q,{name:"check",className:"size-4"}):null]},m))})}),ue?t.jsx(Po,{open:!0,project:{id:ue.project.id,path:ue.project.path},worktree:ue.worktree,onClose:()=>K(null),onDeleted:()=>xe(m=>m+1)}):null]});return s==="sidebar"?n?t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center justify-between gap-2 border-b border-border/70 px-4",children:[t.jsx("h2",{className:"truncate typography-ui-label font-semibold text-foreground",children:r("mobile.sessions.sheet.title")}),ht?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:ht}):null]}),ks]}):null:t.jsxs(ru,{open:n,onClose:()=>e(!1),onSwipeClose:()=>{if(ee||Y){te(null),ne(null),W(null),le(null);return}e(!1)},ariaLabel:r("mobile.sessions.sheet.title"),children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",children:[t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":r("mobile.surface.closeAria"),onClick:()=>e(!1),style:{touchAction:"manipulation"},children:t.jsx(Q,{name:"close",className:"size-5"})}),t.jsx("h2",{className:"min-w-0 flex-1 truncate px-1 typography-ui-label font-semibold text-foreground",children:r("mobile.sessions.sheet.title")}),ht?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:ht}):null]}),ks]})},Sr="mobile-surface-root",su=16,Nr=320,nu="cubic-bezier(0.22, 1, 0.36, 1)",ru=({open:n,onClose:e,onSwipeClose:s,ariaLabel:o,children:r})=>{const i=c.useRef(null),a=c.useRef(null),[u,f]=c.useState(!1),[d,l]=c.useState(n),p=c.useRef(e);c.useEffect(()=>{p.current=e},[e]);const g=c.useRef(s);if(c.useEffect(()=>{g.current=s},[s]),Fn(a,{enabled:n,onRightEdgeSwipe:()=>(g.current??p.current)()}),typeof document<"u"&&!i.current){let h=document.getElementById(Sr);h||(h=document.createElement("div"),h.id=Sr,document.body.appendChild(h)),i.current=h}return c.useEffect(()=>{if(n){l(!0);const x=window.setTimeout(()=>f(!0),su);return()=>window.clearTimeout(x)}f(!1);const h=window.setTimeout(()=>l(!1),Nr+40);return()=>window.clearTimeout(h)},[n]),c.useEffect(()=>{if(!n)return;const h=document.body.style.overflow;document.body.style.overflow="hidden";const x=j=>{j.key==="Escape"&&p.current()};return document.addEventListener("keydown",x),()=>{document.body.style.overflow=h,document.removeEventListener("keydown",x)}},[n]),i.current?Bt.createPortal(t.jsx("section",{ref:a,role:"dialog","aria-modal":"true","aria-label":o,"aria-hidden":!n,className:"oc-keyboard-inset-surface fixed inset-0 z-50 flex flex-col bg-background text-foreground",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:u?"none":"translateX(-100%)",transition:`transform ${Nr}ms ${nu}`,visibility:d?"visible":"hidden",pointerEvents:n?"auto":"none"},children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:r})}),i.current):null},Cr=n=>{const e=ce.c(10),{title:s,description:o,action:r}=n;let i;e[0]!==s?(i=t.jsx("p",{className:"typography-ui-label text-foreground",children:s}),e[0]=s,e[1]=i):i=e[1];let a;e[2]!==o?(a=o?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o}):null,e[2]=o,e[3]=a):a=e[3];let u;e[4]!==r?(u=r?t.jsx("div",{className:"pt-2",children:r}):null,e[4]=r,e[5]=u):u=e[5];let f;return e[6]!==i||e[7]!==a||e[8]!==u?(f=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[i,a,u]}),e[6]=i,e[7]=a,e[8]=u,e[9]=f):f=e[9],f};function ou(n){n&&(n.focus(),n.select())}function iu(n){return Ie(n.path)}function au(n){return Ie(n.path)}function lu(n){return t.jsx(eu,{worktree:n},Ie(n.path))}const cu=(n,e)=>{if(!n)return e("mcpDropdown.status.unknown");switch(n.status){case"connected":return e("mcpDropdown.status.connected");case"failed":return e("mcpDropdown.status.failed",{error:n.error||e("mcpDropdown.status.unknownError")});case"needs_auth":return e("mcpDropdown.status.needsAuth");case"needs_client_registration":return e("mcpDropdown.status.needsRegistration",{error:n.error||""});default:return n.status}},uu=n=>{switch(n?.status){case"connected":return"success";case"failed":return"error";case"needs_auth":case"needs_client_registration":return"warning";default:return"default"}},du=({active:n,className:e,headerAction:s,listClassName:o,hideHeader:r=!1,mobileListDensity:i=!1})=>{const{t:a}=fe(),f=vt(w=>w.currentDirectory)??null,d=ss(w=>w.getStatusForDirectory(f)),l=ss(w=>w.refresh),p=ss(w=>w.connect),g=ss(w=>w.disconnect),h=zt(w=>w.mcpServers),x=zt(w=>w.loadMcpConfigs),[j,v]=c.useState(!1),[T,S]=c.useState(null);c.useEffect(()=>{l({directory:f,silent:!0})},[l,f]),c.useEffect(()=>{x({force:!0})},[x]),c.useEffect(()=>{n&&Promise.all([l({directory:f,silent:!0}),x({force:!0})])},[n,l,f,x]);const E=c.useMemo(()=>{const w=new Set(Object.keys(d));for(const A of h)A?.name&&w.add(A.name);return Array.from(w).sort((A,k)=>A.localeCompare(k))},[h,d]),D=c.useCallback(w=>{if(w?.preventDefault(),j)return;v(!0);const A=new Promise(k=>setTimeout(k,500));Promise.all([l({directory:f}),A]).finally(()=>{v(!1)})},[j,l,f]);return t.jsxs("div",{className:X("w-full",e),children:[r?null:t.jsx("div",{className:"border-b border-[var(--interactive-border)]",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5",children:[t.jsxs("div",{className:"min-w-0 flex items-baseline gap-2",children:[t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:a("mcpDropdown.title")}),f&&t.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:f.split("/").pop()||f})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s,t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",disabled:j,onClick:D,"aria-label":a("mcpDropdown.actions.refreshAria"),children:t.jsx(Q,{name:"refresh",className:X("h-4 w-4",j&&"animate-spin")})})]})]})}),t.jsx("div",{className:X("max-h-64 overflow-y-auto",i?"space-y-1 py-3":"px-3 py-2.5",o),children:t.jsxs("div",{className:X(!i&&E.length>0&&"rounded-xl bg-[var(--surface-muted)] p-1.5"),children:[E.map(w=>{const A=d[w],k=uu(A),P=A?.status==="connected",y=T===w,O=cu(A,a);return t.jsxs("div",{className:X("flex items-center justify-between rounded-lg hover:bg-interactive-hover/50",i?"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(gi,{children:[t.jsx(bi,{asChild:!0,children:t.jsx("span",{className:X("rounded-full flex-shrink-0",i?"h-2.5 w-2.5":"h-2 w-2",k==="success"&&"bg-status-success",k==="error"&&"bg-status-error",k==="warning"&&"bg-status-warning",k==="default"&&"bg-muted-foreground/40"),"aria-label":O})}),t.jsx(xi,{side:"left",children:t.jsx("p",{children:O})})]}),t.jsx("span",{className:X("truncate",i?"text-[17px] leading-6 font-medium":"typography-ui-label"),children:w})]})}),t.jsx(yi,{checked:P,disabled:y,className:"data-[checked]:bg-status-info",onCheckedChange:async M=>{S(w);try{if(!M){await g(w,f);return}const C=d?.[w]?.status;if(C==="needs_auth"||C==="needs_client_registration"){const{opened:b}=await vi({name:w,directory:f});b||tr.error(a("mcpDropdown.toast.authorizeOpenFailed"));return}await p(w,f)}catch(C){tr.error(C instanceof Error?C.message:a("mcpDropdown.toast.authorizeFailed"))}finally{S(null)}}})]},w)}),E.length===0&&t.jsx("div",{className:"px-4 py-5 typography-ui-label text-muted-foreground text-center",children:a("mcpDropdown.empty.configureInConfig")})]})})]})},Er={status:"loading"},It={type:"list"},fu=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),mu=n=>{const e=n.index?.trim();return!!(e&&e!=="?")},pu=n=>{const e=n.working_dir?.trim(),s=n.index?.trim();return!!(e||s==="?")},Rr=(n,e)=>e?`${n}\0staged`:n,hu=n=>{const e=ce.c(8),s=vn()??null;let o;e[0]!==s?(o=fu(s),e[0]=s,e[1]=o):o=e[1];const r=o,i=n.visible??!0;let a;e[2]!==i?(a={enabled:i},e[2]=i,e[3]=a):a=e[3];const u=wi(r||null,a);let f;return e[4]!==n||e[5]!==u||e[6]!==r?(f=t.jsx(gu,{...n,rootDirectory:r,repository:u}),e[4]=n,e[5]=u,e[6]=r,e[7]=f):f=e[7],f},gu=({rootDirectory:n,repository:e,onClose:s,initialDiff:o,visible:r=!0})=>{const{t:i}=fe(),{git:a}=yn(),{rootIsGitRepo:u,gitDirectory:f,nestedRepos:d}=e,l=f??n,p=ji(l||null),g=ki(l||null),h=Vr(l||null),x=Si(l||null),j=Ke(R=>R.setActiveDirectory),v=Ke(R=>R.ensureAll),T=Ke(R=>R.ensureNestedRepos),S=Ke(R=>R.selectNestedRepo),E=Ke(R=>R.fetchStatus),D=Ke(R=>R.fetchBranches),w=Ke(R=>R.prefetchDiffs),A=Ke(R=>R.getDiff),k=Ke(R=>R.setDiff),P=Ke(R=>R.runtimeKey),y=JSON.stringify([P,l]),O=c.useRef(y);O.current=y;const[M,C]=c.useState(()=>({ownerKey:y,mode:"working",route:o?.path?{type:"diff",path:o.path,staged:o.staged}:It})),b=M.ownerKey===y?M.mode:"working",_=M.ownerKey===y?M.route:It,[V,N]=c.useState(!1),U=c.useCallback(R=>{C({ownerKey:y,mode:R,route:It}),N(!1)},[y]),$=c.useCallback(R=>{C(L=>({ownerKey:y,mode:L.ownerKey===y?L.mode:"working",route:R}))},[y]);c.useEffect(()=>{C(R=>R.ownerKey===y?R:{ownerKey:y,mode:"working",route:It}),N(!1)},[y]),c.useEffect(()=>{r||N(!1)},[r]),c.useEffect(()=>{o?.path&&C({ownerKey:O.current,mode:"working",route:{type:"diff",path:o.path,staged:o.staged}})},[o]);const[I,B]=c.useState(null),[Z,ee]=c.useState(null),[te,z]=c.useState(""),[W,q]=c.useState(new Set),[G,Y]=c.useState(!1),[ne,oe]=c.useState(!1),[le,ue]=c.useState([]),[K,ie]=c.useState([]),[xe,Se]=c.useState([]),[H,ve]=c.useState(null),[Re,_e]=c.useState(null),[ze,Ye]=c.useState(0),[Pe,Ae]=c.useState(null),de=p?.current??null,Te=p?.tracking?.trim().split("/")[0],Xe=(Te&&g?.defaultBranches?.[Te])??g?.defaultBranches?.origin??null,ye=xl(de,Xe),Fe=h===!1||bl(de,Xe,p!==null,g!==null),et=al(R=>R.setOverride),Le=ll(l||null,de,r&&b==="branch"&&ye),$e=cl(l||null,de,r&&b==="commit"&&h===!0),Ue=$e.selectedCommit?.hash??null,ke=ul(l||null,de,r&&b==="pr"&&h===!0),tt=ke.selectedSource,ms=c.useMemo(()=>b==="pr"?tt:b==="branch"&&de&&Le.base?{kind:"branch",baseRef:Le.base,headRef:de}:b==="commit"&&Ue?{kind:"commit",hash:Ue}:null,[Le.base,de,b,Ue,tt]),lt=b==="branch"?Le.revision:"",we=hl(l||null,ms,r&&h===!0,lt),{fetchDiff:ps}=we,Kt=c.useMemo(()=>we.files?[...we.files].sort((R,L)=>R.path.localeCompare(L.path)):null,[we.files]),Ce=_.type==="comparison"&&_.sourceKey===we.key?_.path:null,[hs,Nt]=c.useState(0),gs=c.useCallback(async R=>{try{const{diff:L}=await ps(R),se={original:"",modified:"",isBinary:dl(L)};return se.isBinary||(se.fileDiff=fl(R,L)),{status:"ready",diff:se}}catch(L){return{status:"error",message:L instanceof Error?L.message:i("diffView.state.failedToLoadDiff")}}},[ps,i]),Fs=gl(we.files?b==="pr"?JSON.stringify([we.key,we.revision]):we.key:null,r&&Ce?Ce:"",r?gs:null,Er,JSON.stringify([lt,b==="pr"?we.revision:0,hs])),mt=Ce?Fs.get(Ce)??Er:null;c.useEffect(()=>{b==="branch"&&Fe&&U("working")},[Fe,U,b]),c.useEffect(()=>{C(R=>R.ownerKey===y&&R.route.type==="comparison"&&R.route.sourceKey!==we.key?{...R,route:It}:R)},[we.key,y]);const Ve=c.useMemo(()=>{const R=p?.files??[],L=new Map;for(const se of R)L.set(se.path,se);return Array.from(L.values()).sort((se,je)=>se.path.localeCompare(je.path))},[p?.files]),Qe=c.useMemo(()=>Ve.filter(mu),[Ve]),Ht=c.useMemo(()=>Ve.filter(pu),[Ve]),ct=c.useMemo(()=>{if(xe.length>0)return xe;const R=p?.tracking?.includes("/")?p.tracking.split("/")[0]:null;return R||H?[{name:R||"origin",fetchUrl:H??"",pushUrl:H??""}]:[]},[H,xe,p?.tracking]),qt=Ke(c.useCallback(R=>!l||_.type!=="diff"?null:R.directories.get(l)?.diffCache.get(Rr(_.path,_.staged))??null,[l,_])),bs=c.useMemo(()=>_.type!=="diff"?null:Ve.find(R=>R.path===_.path)??null,[Ve,_]),Oe=c.useCallback(async(R=!0)=>{if(l)try{await Promise.all([E(l,a),D(l,a)])}catch(L){R&&ae.error(L instanceof Error?L.message:i("gitView.toast.refreshRepositoryFailed"))}},[l,D,E,a,i]),xs=c.useMemo(()=>(g?.all??[]).filter(R=>!R.startsWith("remotes/")).sort(),[g]),Ws=c.useMemo(()=>(g?.all??[]).filter(R=>R.startsWith("remotes/")).map(R=>R.replace(/^remotes\//,"")).sort(),[g]),nt=c.useCallback(async R=>{if(!l)return;const L=R.replace(/^remotes\//,"");try{const se=await a.checkoutBranch(l,L);ae.success(i("gitView.toast.checkedOut",{name:se.branch||L})),await Oe()}catch(se){ae.error(se instanceof Error?se.message:i("gitView.toast.checkoutFailed",{name:L}))}},[l,a,Oe,i]),Us=c.useCallback(R=>{const L=R.replace(/^remotes\//,"");if((p?.files?.length??0)>0){Ae(L);return}nt(L)},[nt,p?.files]),Vs=c.useCallback(async(R,L)=>{if(l)try{await a.createBranch(l,R,de??"HEAD"),await a.checkoutBranch(l,R),L&&await a.gitPush(l,{remote:L.name,branch:R,options:["--set-upstream"]}),await Oe()}catch(se){throw ae.error(se instanceof Error?se.message:i("gitView.toast.createBranchFailed")),se}},[de,l,a,Oe,i]),Ct=c.useCallback(async()=>{if(!l){Se([]),ve(null);return}try{const[R,L]=await Promise.all([a.getRemotes(l).catch(()=>[]),a.getRemoteUrl?a.getRemoteUrl(l).catch(()=>null):Promise.resolve(null)]);Se(R),ve(L)}catch{Se([]),ve(null)}},[l,a]);c.useEffect(()=>{!l||!r||(j(l),v(l,a))},[l,v,a,j,r]),c.useEffect(()=>{r&&Ct()},[Ct,r]),c.useEffect(()=>{if(!r||b!=="working"||!l||Ve.length===0)return;const R=Array.from(new Set([...Qe.map(se=>se.path),...K,...Ve.slice(0,20).map(se=>se.path)])).filter(Boolean);if(R.length===0)return;const L=window.setTimeout(()=>{w(l,a,R,{maxFiles:40})},120);return()=>window.clearTimeout(L)},[Ve,l,a,b,w,Qe,K,r]),c.useEffect(()=>{if(!r)return;if(_.type!=="diff"){_e(null);return}const R=Rr(_.path,_.staged);if(!l||A(l,R)){_e(null);return}let L=!1;const se=Vt();return _e(null),a.getGitFileDiff(l,{path:_.path,staged:_.staged||void 0}).then(je=>{L||k(l,R,{original:je.original??"",modified:je.modified??"",isBinary:je.isBinary},se)}).catch(je=>{L||_e(je instanceof Error?je.message:String(je))}),()=>{L=!0}},[l,ze,A,a,_,k,r]);const ys=async(R,L)=>{if(l){B(R);try{const se=je=>{const Ge=`${je.name}/`,ut=p?.tracking?.startsWith(Ge)?p.tracking.slice(Ge.length):void 0;return{remote:je.name,branch:ut,rebase:!0}};if(R==="fetch"){if(!L)throw new Error(i("mobile.changes.noRemote"));await a.gitFetch(l,{remote:L.name}),ae.success(i("gitView.toast.fetchedFromRemote",{name:L.name}))}else if(R==="sync"){if(!L)throw new Error(i("mobile.changes.noRemote"));await a.gitFetch(l,{remote:L.name});const je=await a.getGitStatus(l);if((je.behind??0)>0){if((je.files?.length??0)>0){ae.error(i("gitView.toast.commitOrStashBeforeSync"));return}await a.gitPull(l,se(L))}((await a.getGitStatus(l)).ahead??0)>0&&await a.gitPush(l),ae.success(i("gitView.toast.alreadyUpToDate"))}await Oe(!1),await Ct()}catch(se){ae.error(se instanceof Error?se.message:i("gitView.toast.syncActionFailed",{action:i("gitView.sync.syncChanges")}))}finally{B(null)}}},pt=c.useCallback(async(R,L)=>{if(!(!l||R.length===0))try{L==="stage"?R.length>1?await Ni(l,R):await Ci(l,R[0]):R.length>1?await Ei(l,R):await Ri(l,R[0]),await Oe(!1)}catch(se){ae.error(se instanceof Error?se.message:i(L==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed"))}},[l,Oe,i]),Et=c.useCallback((R,L=!1)=>{$({type:"diff",path:R,staged:L})},[$]),Jt=c.useCallback(async R=>{if(l){q(L=>new Set(L).add(R));try{await a.revertGitFile(l,R),ae.success(i("gitView.toast.revertedFile",{path:R})),await Oe(!1)}catch(L){ae.error(L instanceof Error?L.message:i("gitView.toast.revertFailed"))}finally{q(L=>{const se=new Set(L);return se.delete(R),se})}}},[l,a,Oe,i]),vs=c.useCallback(async R=>{if(!l||R.length===0||G)return;const L=Array.from(new Set(R));Y(!0),q(new Set(L));try{await Promise.all(L.map(se=>a.revertGitFile(l,se))),await Oe(!1),ae.success(L.length===1?i("gitView.toast.revertedFilesSingle",{count:L.length}):i("gitView.toast.revertedFilesPlural",{count:L.length}))}catch(se){ae.error(se instanceof Error?se.message:i("gitView.toast.revertFailed"))}finally{q(new Set),Y(!1)}},[l,a,G,Oe,i]),Gs=c.useCallback(R=>{const L=R.map(se=>se.trim()).filter(Boolean);if(L.length===0){ue([]);return}z(se=>`${se.trim()}${se.trim()?`
23
+
24
+ `:""}${L.join(`
25
+ `)}`.trim()),ue([])},[]),Ks=c.useCallback(async()=>{if(!l)return;const R=Qe.map(L=>L.path).sort();if(R.length===0){ae.error(i("gitView.toast.selectFileToDescribe"));return}oe(!0);try{const{message:L}=await Qn(l,R);z(L.subject?.trim()??""),ue(Array.isArray(L.highlights)?L.highlights:[])}catch(L){ae.error(L instanceof Error?L.message:i("gitView.toast.generateCommitMessageFailed"))}finally{oe(!1)}},[l,Qe,i]),ws=async(R={})=>{if(!l)return;if(!te.trim()){ae.error(i("gitView.toast.enterCommitMessage"));return}const L=Qe.map(se=>se.path).sort();if(L.length===0){ae.error(i("gitView.toast.selectFileToCommit"));return}ee(R.pushAfter?"commitAndPush":"commit");try{if(await a.createGitCommit(l,te.trim(),{files:L}),ae.success(i("gitView.toast.commitCreated")),z(""),ue([]),R.pushAfter){const se=p?.tracking?.split("/")[0],je=ct.find(ks=>ks.name===se)??ct[0];if(!je)throw new Error(i("mobile.changes.noRemote"));B("sync");const Ge=`${je.name}/`,ut=p?.tracking?.startsWith(Ge)?p.tracking.slice(Ge.length):void 0;await a.gitFetch(l,{remote:je.name}),((await a.getGitStatus(l)).behind??0)>0&&await a.gitPull(l,{remote:je.name,branch:ut,rebase:!0}),((await a.getGitStatus(l)).ahead??0)>0&&await a.gitPush(l),await Oe(!1),await Ct()}else await Oe(!1)}catch(se){ae.error(se instanceof Error?se.message:i("gitView.toast.createCommitFailed"))}finally{ee(null),R.pushAfter&&B(null)}},Hs=c.useMemo(()=>{const R=[];return Qe.length>0&&R.push({id:"staged",title:i("gitView.changes.stagedTitle"),entries:Qe,actionSymbol:"-",actionAllLabel:i("gitView.changes.unstageAllAria"),getActionLabel:L=>i("gitView.changes.unstageFileAria",{path:L}),onActionFile:L=>{pt([L],"unstage")},onActionAll:L=>{pt(L,"unstage")},onViewDiff:L=>Et(L,!0),onRevertFile:Jt,showRevertActions:!1,accent:!0}),Ht.length>0&&R.push({id:"unstaged",title:i("gitView.changes.title"),entries:Ht,actionSymbol:"+",actionAllLabel:i("gitView.changes.stageAllAria"),getActionLabel:L=>i("gitView.changes.stageFileAria",{path:L}),onActionFile:L=>{pt([L],"stage")},onActionAll:L=>{pt(L,"stage")},onViewDiff:L=>Et(L,!1),onRevertFile:Jt}),R},[Jt,Et,pt,Qe,i,Ht]),Rt=R=>t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[s?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":i("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(Q,{name:"close",className:"size-5"})}):null,t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[t.jsx("h2",{className:"typography-ui-label text-foreground",children:i("mobile.nav.changes")}),t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:p?.current||l||""})]}),u===!1&&Array.isArray(d)&&d.length>0?t.jsx(Ta,{repositories:d,selectedRepository:f??null,onSelectRepository:L=>{n&&S(n,L)},repositoryRoot:n??void 0}):null]}),t.jsx("div",{className:"min-h-0 flex-1",children:R})]});if(!l)return Rt(t.jsx(st,{message:i("gitView.empty.selectSessionOrDirectory")}));if(u===!1&&h!==!0)return Rt(t.jsx(Ia,{rootIsGitRepo:u,resolvedIsGitRepo:h,nestedRepos:d,onRetryDiscovery:()=>{n&&T(n,{force:!0})}}));if(x&&h===null)return Rt(t.jsx(st,{loading:!0,message:i("gitView.loading.checkingRepository")}));if(_.type==="diff")return t.jsx(Pr,{path:_.path,diff:qt,fileExists:!!bs,error:Re,onBack:()=>$({type:"list"}),onRetry:()=>Ye(R=>R+1)});const qs=i(b==="pr"?"session.githubIntegration.tabs.pullRequests":b==="branch"?"diffView.scope.branch":b==="commit"?"commitComparison.mode":"mobile.nav.changes"),js=b==="branch"&&Le.base?Ra(Le.base):b==="commit"?Ue?.slice(0,8):b==="pr"&&tt?`#${tt.number}`:null;if(Ce&&mt)return t.jsx(Pr,{path:Ce,subtitle:[qs,js].filter(Boolean).join(" · "),diff:mt.status==="ready"?mt.diff:null,fileExists:!we.files||we.files.some(R=>R.path===Ce),error:we.error??(mt.status==="error"?mt.message:null),onBack:()=>$(It),onRetry:()=>{we.error&&we.refresh(),Nt(R=>R+1)}});const Pt=()=>b==="pr"&&!tt?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(st,{loading:ke.loading,message:ke.error??(ke.loading?i("session.githubPrPicker.loading.pullRequests"):i("pullRequestComparison.select"))}),!ke.loading&&t.jsx(sr,{mobile:!0,comparison:ke})]}):b==="branch"&&!Le.base?t.jsx(st,{loading:!Le.resolved,message:Le.resolved?i("gitView.pr.toast.baseBranchRequired"):i("diffView.branch.resolvingBase")}):b==="commit"&&!Ue?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[$e.loading&&t.jsx(Q,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:$e.loading?i("diffView.state.loadingChanges"):$e.error??i("commitComparison.noCommits")}),$e.error&&t.jsx(he,{variant:"outline",size:"lg",onClick:()=>{$e.refresh()},children:i("diffView.actions.retry")})]}):we.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:i("diffView.state.failedToLoadDiff")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:we.error}),t.jsx(he,{variant:"outline",size:"lg",onClick:()=>{we.refresh()},children:i("diffView.actions.retry")})]}):Kt?Kt.length===0?t.jsx(st,{icon:b==="branch",message:b==="pr"?i("walkthrough.blocked.emptyDiff.description"):b==="commit"?i("commitComparison.emptyDiff"):i("diffView.branch.empty",{base:js??""})}):t.jsx(bu,{files:Kt,onSelect:R=>{we.key&&$({type:"comparison",path:R,sourceKey:we.key})}}):t.jsx(st,{loading:!0,message:i("diffView.state.loadingChanges")});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b border-border/60 px-3 py-2",children:[s?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":i("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(Q,{name:"close",className:"size-5"})}):null,t.jsxs(Pi,{open:V,onOpenChange:N,children:[t.jsx(Ai,{asChild:!0,children:t.jsxs(he,{variant:"outline",className:Ti({size:"default"}),"data-mobile-comparison-trigger":!0,"aria-label":i("diffView.scope.selectorAria"),children:[t.jsx("span",{children:qs}),t.jsx(Q,{name:"arrow-down-s",className:"size-4"})]})}),t.jsx(Ii,{align:"start",children:t.jsxs(Di,{value:b,onValueChange:R=>{(R==="working"||R==="branch"||R==="commit"||R==="pr")&&U(R)},children:[t.jsx(Ns,{value:"working",className:"min-h-8 items-center",children:i("mobile.nav.changes")}),ye&&t.jsx(Ns,{value:"branch",className:"min-h-8 items-center",children:i("diffView.scope.branch")}),t.jsx(Ns,{value:"commit",className:"min-h-8 items-center",children:i("commitComparison.mode")}),t.jsx(Ns,{value:"pr",className:"min-h-8 items-center",children:i("session.githubIntegration.tabs.pullRequests")})]})})]}),r&&b==="branch"&&t.jsx(ml,{mobile:!0,branches:g?.all??[],currentBranch:de,base:Le.base,onSelect:R=>{de&&et(l,de,R)}},JSON.stringify([y,de])),r&&b==="commit"&&t.jsx(pl,{mobile:!0,commits:$e.commits,selectedHash:Ue,loading:$e.loading,error:$e.error,onSelect:$e.select,onRefresh:()=>{$e.refresh()}},JSON.stringify([y,de])),r&&b==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(sr,{mobile:!0,comparison:ke},JSON.stringify([y,de])),tt&&t.jsx(he,{variant:"ghost",size:"sm",disabled:we.loading,"aria-label":i("session.githubIssuePicker.actions.refresh"),onClick:()=>{we.refresh()},children:t.jsx(Q,{name:"refresh",className:"size-4"})})]})]}),b==="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(Pa,{currentBranch:p?.current,localBranches:xs,remoteBranches:Ws,branchInfo:g?.branches,currentBranchAhead:p?.ahead,onCheckout:R=>{Us(R)},onCreate:Vs,remotes:ct,disabled:x,directory:l,switchBlockedNotice:(p?.files?.length??0)>0?i("gitView.branch.switchBlockedNotice"):null})}),t.jsx(Aa,{syncAction:I,remotes:ct,onFetch:R=>{ys("fetch",R)},onSync:R=>{ys("sync",R)},disabled:Z!==null||x,aheadCount:p?.ahead??0,behindCount:p?.behind??0,trackingRemoteName:p?.tracking?.split("/")[0],hasUncommittedChanges:Ve.length>0})]}),b!=="working"?t.jsx("div",{className:"min-h-0 flex-1",children:Pt()}):Ve.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(rl,{groups:Hs,diffStats:p?.diffStats,revertingPaths:W,onRevertAll:vs,isRevertingAll:G,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:ie})}),t.jsx("div",{className:"shrink-0 border-t border-border/70 px-4 pb-4 pt-3",children:t.jsx(ol,{stagedCount:Qe.length,commitMessage:te,onCommitMessageChange:z,generatedHighlights:le,onInsertHighlights:Gs,onGenerateMessage:Ks,isGeneratingMessage:ne,onCommit:()=>{ws({pushAfter:!1})},onCommitAndPush:()=>{ws({pushAfter:!0})},commitAction:Z,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(st,{icon:!0,message:i("gitView.empty.cleanTitle"),description:i("mobile.changes.cleanDescription")})}),t.jsx(il,{open:Pe!==null,onOpenChange:R=>{R||Ae(null)},targetBranch:Pe??"",changedFileCount:p?.files?.length??0,onCommitAndSwitch:async(R,L)=>{const se=Pe;if(!se||!l)return;const je=p?.current??null;await a.createGitCommit(l,R,{addAll:!0});let Ge=null;if(L){const ut=p?.tracking?.split("/")[0],dt=ct.find(ht=>ht.name===ut)??ct[0];try{if(!dt)throw new Error(i("mobile.changes.noRemote"));await a.gitPush(l,p?.tracking?{remote:dt.name}:{remote:dt.name,branch:je??void 0,options:["--set-upstream"]}),Ge=dt.name}catch{ae.error(i("gitView.dirtySwitch.pushFailed")),await Oe(),Ae(null);return}}ae.success(je?Ge?i("gitView.toast.pushedToUpstream",{name:Ge}):i("gitView.dirtySwitch.committedNotPushed",{branch:je}):i("gitView.toast.commitCreated")),await Oe(),Ae(null),await nt(se)},onGenerateMessage:async()=>{if(!l)return"";const R=(p?.files??[]).map(se=>se.path).sort(),{message:L}=await Qn(l,R);return L.subject?.trim()??""},onRevertAndSwitch:async()=>{const R=Pe;if(!R||!l)return;await vs((p?.files??[]).map(se=>se.path));const L=await a.getGitStatus(l);if(!L.isClean&&(L.files?.length??0)>0){ae.error(i("gitView.dirtySwitch.revertIncomplete"));return}Ae(null),await nt(R)}})]})},st=n=>{const e=ce.c(13),{message:s,description:o,loading:r,icon:i}=n,a=r===void 0?!1:r,u=i===void 0?!1:i;let f;e[0]!==a?(f=a?t.jsx(Q,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,e[0]=a,e[1]=f):f=e[1];let d;e[2]!==u?(d=u?t.jsx(Q,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e[2]=u,e[3]=d):d=e[3];let l;e[4]!==s?(l=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[4]=s,e[5]=l):l=e[5];let p;e[6]!==o?(p=o?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o}):null,e[6]=o,e[7]=p):p=e[7];let g;return e[8]!==f||e[9]!==d||e[10]!==l||e[11]!==p?(g=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[f,d,l,p]})}),e[8]=f,e[9]=d,e[10]=l,e[11]=p,e[12]=g):g=e[12],g},Pr=n=>{const e=ce.c(29),{path:s,subtitle:o,diff:r,fileExists:i,error:a,onBack:u,onRetry:f}=n,{t:d}=fe();let l;e[0]!==s?(l=_i(s)||"text",e[0]=s,e[1]=l):l=e[1];const p=l;let g;e[2]!==d?(g=d("header.actions.backAria"),e[2]=d,e[3]=g):g=e[3];let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(Q,{name:"arrow-left",className:"size-5"}),e[4]=h):h=e[4];let x;e[5]!==u||e[6]!==g?(x=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-primary","aria-label":g,onClick:u,children:h}),e[5]=u,e[6]=g,e[7]=x):x=e[7];let j;e[8]!==s?(j=t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:s}),e[8]=s,e[9]=j):j=e[9];let v;e[10]!==o?(v=o&&t.jsx("p",{className:"truncate typography-meta text-muted-foreground",children:o}),e[10]=o,e[11]=v):v=e[11];let T;e[12]!==j||e[13]!==v?(T=t.jsxs("div",{className:"min-w-0 flex-1 px-2",children:[j,v]}),e[12]=j,e[13]=v,e[14]=T):T=e[14];let S;e[15]!==x||e[16]!==T?(S=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:[x,T]}),e[15]=x,e[16]=T,e[17]=S):S=e[17];let E;e[18]!==r||e[19]!==a||e[20]!==i||e[21]!==p||e[22]!==f||e[23]!==s||e[24]!==d?(E=t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:i?a?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:d("mobile.changes.diffDetail.loadFailed")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:a}),t.jsx(he,{type:"button",size:"sm",variant:"outline",onClick:f,children:d("diffView.actions.retry")})]})}):r?r.isBinary?t.jsx(st,{icon:!0,message:d("diffView.binary.unavailable")}):Mi(s)&&!r.fileDiff?t.jsx(st,{icon:!0,message:d("mobile.changes.diffDetail.imageUnavailable")}):t.jsx(Bs,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:t.jsx(yl,{original:r.original,modified:r.modified,fileDiff:r.fileDiff,language:p,fileName:s,renderSideBySide:!1,wrapLines:!0,layout:"inline"})}):t.jsx(st,{loading:!0,message:d("diffView.state.loadingDiff")}):t.jsx(st,{icon:!0,message:d("mobile.changes.diffDetail.missingTitle"),description:d("mobile.changes.diffDetail.missingDescription")})}),e[18]=r,e[19]=a,e[20]=i,e[21]=p,e[22]=f,e[23]=s,e[24]=d,e[25]=E):E=e[25];let D;return e[26]!==S||e[27]!==E?(D=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[S,E]}),e[26]=S,e[27]=E,e[28]=D):D=e[28],D},bu=n=>{const e=ce.c(12),{files:s,onSelect:o}=n,{t:r}=fe();let i;e[0]!==r?(i=r("gitView.changes.changedFilesAria"),e[0]=r,e[1]=i):i=e[1];let a;if(e[2]!==s||e[3]!==o||e[4]!==r){let f;e[6]!==o||e[7]!==r?(f=d=>{const l=d.status==="A"?r("diffView.change.new"):d.status==="D"?r("diffView.change.deleted"):d.status==="R"?r("diffView.change.renamed"):d.status==="C"?r("diffView.change.copied"):r("diffView.change.modified"),p=d.status==="A"?"var(--status-success)":d.status==="D"?"var(--status-error)":d.status==="R"||d.status==="C"?"var(--status-info)":"var(--status-warning)";return t.jsx("li",{children:t.jsxs(he,{variant:"ghost",size:"lg",className:"w-full justify-start gap-2.5 text-left normal-case",onClick:()=>o(d.path),children:[t.jsx("span",{className:"w-4 shrink-0 text-center typography-meta font-semibold uppercase",style:{color:p},"aria-label":l,children:d.status}),t.jsx(eo,{filePath:d.path,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label",title:d.path,children:d.path}),(d.insertions>0||d.deletions>0)&&t.jsxs("span",{className:"shrink-0 typography-meta text-muted-foreground",children:["+",d.insertions," -",d.deletions]}),t.jsx(Q,{name:"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground"})]})},d.path)},e[6]=o,e[7]=r,e[8]=f):f=e[8],a=s.map(f),e[2]=s,e[3]=o,e[4]=r,e[5]=a}else a=e[5];let u;return e[9]!==i||e[10]!==a?(u=t.jsx(Bs,{className:"h-full overflow-y-auto overflow-x-hidden px-3 py-2",children:t.jsx("ul",{"aria-label":i,className:"flex flex-col gap-1",children:a})}),e[9]=i,e[10]=a,e[11]=u):u=e[11],u},xu=c.lazy(()=>Lt(()=>import("./FilesView-BFZkuu4O.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])).then(n=>({default:n.FilesView}))),kt=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),cs=n=>{const e=kt(n);return!e||e==="/"?e||"/":e.split("/").filter(Boolean).at(-1)??e},yu=n=>{const e=kt(n);if(!e||e==="/")return null;const s=e.lastIndexOf("/");return s<=0?e.startsWith("/")?"/":null:e.slice(0,s)},vu=(n,e)=>{const s=kt(n),o=kt(e);return!o||s===o?cs(s):s.startsWith(`${o}/`)?s.slice(o.length+1):s},wu=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 o of e){if(s<1024||o===e[e.length-1])return`${s.toFixed(s>=10?0:1)} ${o}`;s/=1024}return""},ju=({onClose:n})=>{const{t:e}=fe(),{files:s}=yn(),o=Fo(N=>N.setSelectedPath),r=kt(vn()??null),[i,a]=c.useState(()=>({type:"browser",directory:r})),[u,f]=c.useState([]),[d,l]=c.useState(!1),[p,g]=c.useState(null),[h,x]=c.useState(""),[j,v]=c.useState([]),[T,S]=c.useState(!1),E=c.useRef(0);c.useEffect(()=>{r&&a(N=>N.type==="browser"&&N.directory?N:{type:"browser",directory:r})},[r]);const D=i.type==="browser"?i.directory:i.returnDirectory,w=c.useCallback(async N=>{if(!N)return;const U=E.current+1;E.current=U,l(!0),g(null);try{const $=await s.listDirectory(N);if(E.current!==U)return;f($.entries.slice().sort((I,B)=>I.isDirectory!==B.isDirectory?I.isDirectory?-1:1:I.name.localeCompare(B.name)))}catch($){if(E.current!==U)return;f([]),g($ instanceof Error?$.message:e("mobile.files.error.listFailed"))}finally{E.current===U&&l(!1)}},[s,e]);c.useEffect(()=>{i.type==="browser"&&w(i.directory)},[w,i]),c.useEffect(()=>{if(i.type!=="browser")return;const N=h.trim();if(!N){v([]),S(!1);return}let U=!1;const $=window.setTimeout(()=>{S(!0),s.search({directory:i.directory,query:N,maxResults:40}).then(I=>{U||v(I)}).catch(()=>{U||v([])}).finally(()=>{U||S(!1)})},250);return()=>{U=!0,window.clearTimeout($)}},[s,h,i]);const A=N=>{x(""),a({type:"browser",directory:N})},k=N=>{o(r,N),a({type:"file",path:N,returnDirectory:D||r})},P=it(N=>N.pendingFileFocusPath),y=it(N=>N.pendingFileNavigation);if(c.useEffect(()=>{const N=kt(y?.path??P??"");!N||!r||N!==r&&!N.startsWith(`${r}/`)||(o(r,N),a({type:"file",path:N,returnDirectory:r}),P&&it.getState().setPendingFileFocusPath(null))},[P,y,r,o]),!r)return t.jsx(us,{message:e("mobile.files.empty.noDirectory")});if(i.type==="file")return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/70 px-3 text-foreground",children:[t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":e("header.actions.backAria"),onClick:()=>a({type:"browser",directory:i.returnDirectory}),style:{touchAction:"manipulation"},children:t.jsx(er,{className:"size-5"})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:cs(i.path)})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(Je,{children:t.jsx(c.Suspense,{fallback:t.jsx(us,{loading:!0,message:e("filesView.state.loading")}),children:t.jsx(xu,{mode:"editor-only"})})})})]});const O=i.directory===r?e("mobile.files.rootDirectory"):cs(i.directory),M=h.trim()?j:[],C=yu(i.directory),b=i.directory!==r&&C!==null&&(C===r||C.startsWith(`${r}/`)),_=b&&!h.trim(),V=b?C:null;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[n?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":e("mobile.surface.closeAria"),onClick:n,style:{touchAction:"manipulation"},children:t.jsx(oo,{className:"size-5"})}):null,_&&V?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-primary","aria-label":e("mobile.files.backToParentAria",{name:cs(V)}),onClick:()=>A(V),style:{touchAction:"manipulation"},children:t.jsx(er,{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:O})}),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-primary","aria-label":e("mobile.files.refreshAria"),onClick:()=>{w(i.directory)},style:{touchAction:"manipulation"},children:t.jsx(Za,{className:X("size-5",d&&"animate-spin")})})]}),t.jsx("div",{className:"shrink-0 px-4 pb-2 pt-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(ro,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(xn,{value:h,onChange:N=>x(N.target.value),placeholder:e("mobile.files.search.placeholder"),className:"h-11 pl-9"})]})}),t.jsx(Bs,{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-3",children:p?t.jsx(us,{message:p}):h.trim()?t.jsx(ku,{results:M,isSearching:T,onOpenFile:k}):t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:[u.length===0&&!d?t.jsx("div",{className:"px-4 py-8 text-center typography-body text-muted-foreground",children:e("mobile.files.empty.directory")}):null,u.map(N=>t.jsx(Io,{name:N.name,path:N.path,directory:N.isDirectory,meta:N.isDirectory?void 0:wu(N.size),onClick:()=>N.isDirectory?A(N.path):k(N.path)},N.path))]})})]})},Io=n=>{const e=ce.c(16),{name:s,path:o,directory:r,meta:i,onClick:a}=n;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={touchAction:"manipulation"},e[0]=u):u=e[0];let f;e[1]!==r||e[2]!==o?(f=r?t.jsx(el,{className:"size-5 shrink-0 text-primary/80"}):t.jsx(eo,{filePath:o,className:"size-5 shrink-0"}),e[1]=r,e[2]=o,e[3]=f):f=e[3];let d;e[4]!==s?(d=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:s}),e[4]=s,e[5]=d):d=e[5];let l;e[6]!==i?(l=i?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:i}):null,e[6]=i,e[7]=l):l=e[7];let p;e[8]!==r?(p=r?t.jsx(tl,{className:"size-4 shrink-0 text-muted-foreground/60"}):null,e[8]=r,e[9]=p):p=e[9];let g;return e[10]!==a||e[11]!==f||e[12]!==d||e[13]!==l||e[14]!==p?(g=t.jsxs("button",{type:"button",className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3 py-2.5 text-left transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",onClick:a,style:u,children:[f,d,l,p]}),e[10]=a,e[11]=f,e[12]=d,e[13]=l,e[14]=p,e[15]=g):g=e[15],g},ku=n=>{const e=ce.c(10),{results:s,isSearching:o,onOpenFile:r}=n,{t:i}=fe(),a=kt(vn()??null);if(o){let l;e[0]!==i?(l=i("common.loading"),e[0]=i,e[1]=l):l=e[1];let p;return e[2]!==l?(p=t.jsx(us,{loading:!0,message:l}),e[2]=l,e[3]=p):p=e[3],p}if(s.length===0){let l;e[4]!==i?(l=i("mobile.files.search.empty"),e[4]=i,e[5]=l):l=e[5];let p;return e[6]!==l?(p=t.jsx(us,{message:l}),e[6]=l,e[7]=p):p=e[7],p}const u="overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",f=s.map(l=>t.jsx(Io,{name:cs(l.path),path:l.path,directory:!1,meta:vu(l.path,a),onClick:()=>r(l.path)},l.path));let d;return e[8]!==f?(d=t.jsx("div",{className:u,children:f}),e[8]=f,e[9]=d):d=e[9],d},us=n=>{const e=ce.c(7),{message:s,loading:o}=n,r=o===void 0?!1:o;let i;e[0]!==r?(i=r?t.jsx(sl,{className:"size-5 animate-spin text-muted-foreground"}):t.jsx(nl,{className:"size-6 text-muted-foreground"}),e[0]=r,e[1]=i):i=e[1];let a;e[2]!==s?(a=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[2]=s,e[3]=a):a=e[3];let u;return e[4]!==i||e[5]!==a?(u=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[i,a]})}),e[4]=i,e[5]=a,e[6]=u):u=e[6],u},Ar="mobile-surface-root",Su=16,Tr=320,Nu="cubic-bezier(0.22, 1, 0.36, 1)",Cu=n=>{const e=ce.c(36),{onOpenMcpSettings:s}=n,{t:o}=fe(),[r,i]=c.useState(!1),a=vt(Eu),u=ss(Ru),f=zt(Pu);let d;e[0]!==a||e[1]!==r||e[2]!==f||e[3]!==u?(d=()=>{if(r)return;i(!0);const O=new Promise(Au);Promise.all([u({directory:a||null,silent:!0}),f({force:!0}),O]).finally(()=>i(!1))},e[0]=a,e[1]=r,e[2]=f,e[3]=u,e[4]=d):d=e[4];const l=d;let p;e[5]!==o?(p=o("settings.mcp.sidebar.actions.addServerTitle"),e[5]=o,e[6]=p):p=e[6];let g;e[7]!==o?(g=o("settings.mcp.sidebar.actions.addServerTitle"),e[7]=o,e[8]=g):g=e[8];let h,x;e[9]===Symbol.for("react.memo_cache_sentinel")?(h={touchAction:"manipulation"},x=t.jsx(Q,{name:"add",className:"size-5"}),e[9]=h,e[10]=x):(h=e[9],x=e[10]);let j;e[11]!==s||e[12]!==p||e[13]!==g?(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 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:s,"aria-label":p,title:g,style:h,children:x}),e[11]=s,e[12]=p,e[13]=g,e[14]=j):j=e[14];let v;e[15]!==o?(v=o("mcpDropdown.actions.refreshAria"),e[15]=o,e[16]=v):v=e[16];let T;e[17]!==o?(T=o("mcpDropdown.actions.refreshAria"),e[17]=o,e[18]=T):T=e[18];let S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S={touchAction:"manipulation"},e[19]=S):S=e[19];const E=r&&"animate-spin";let D;e[20]!==E?(D=X("size-5",E),e[20]=E,e[21]=D):D=e[21];let w;e[22]!==D?(w=t.jsx(Q,{name:"refresh",className:D}),e[22]=D,e[23]=w):w=e[23];let A;e[24]!==r||e[25]!==l||e[26]!==w||e[27]!==v||e[28]!==T?(A=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-primary",onClick:l,disabled:r,"aria-label":v,title:T,style:S,children:w}),e[24]=r,e[25]=l,e[26]=w,e[27]=v,e[28]=T,e[29]=A):A=e[29];let k;e[30]!==A||e[31]!==j?(k=t.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-1 px-2 pt-1",children:[j,A]}),e[30]=A,e[31]=j,e[32]=k):k=e[32];let P;e[33]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(du,{active:!0,className:"h-full",listClassName:"max-h-none",hideHeader:!0,mobileListDensity:!0})}),e[33]=P):P=e[33];let y;return e[34]!==k?(y=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[k,P]}),e[34]=k,e[35]=y):y=e[35],y},Ir=({open:n,onClose:e,tab:s,onTabChange:o,pendingChangesDiff:r,onOpenPlan:i,onOpenMcpSettings:a,variant:u="drawer"})=>{const{t:f}=fe(),d=c.useRef(null),l=c.useRef(null),[p,g]=c.useState(!1),[h,x]=c.useState(n),j=c.useRef(e);c.useEffect(()=>{j.current=e},[e]);const v=c.useRef(s);c.useEffect(()=>{v.current=s},[s]),Fn(l,{enabled:u==="drawer"&&n,onLeftEdgeSwipe:()=>j.current()});const[T,S]=c.useState(()=>new Set);if(c.useEffect(()=>{n&&S(w=>{if(w.has(s))return w;const A=new Set(w);return A.add(s),A})},[n,s]),typeof document<"u"&&!d.current){let w=document.getElementById(Ar);w||(w=document.createElement("div"),w.id=Ar,document.body.appendChild(w)),d.current=w}if(c.useEffect(()=>{if(n){x(!0);const A=window.setTimeout(()=>g(!0),Su);return()=>window.clearTimeout(A)}g(!1);const w=window.setTimeout(()=>x(!1),Tr+40);return()=>window.clearTimeout(w)},[n]),c.useEffect(()=>{if(!n)return;const w=document.body.style.overflow;u==="drawer"&&(document.body.style.overflow="hidden");const A=k=>{k.key==="Escape"&&v.current!=="terminal"&&j.current()};return document.addEventListener("keydown",A),()=>{u==="drawer"&&(document.body.style.overflow=w),document.removeEventListener("keydown",A)}},[n,u]),u==="drawer"&&!d.current)return null;const E=[{id:"changes",label:f("mobile.menu.changes"),icon:t.jsx(Q,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"files",label:f("mobile.menu.files"),icon:t.jsx(Q,{name:"file-text",className:"h-3.5 w-3.5"})},{id:"terminal",label:f("mobile.menu.terminal"),icon:t.jsx(Q,{name:"terminal",className:"h-3.5 w-3.5"})},{id:"notes",label:f("contextRail.surface.notes"),icon:t.jsx(Q,{name:"sticky-note",className:"h-3.5 w-3.5"})},{id:"mcp",label:f("mobile.menu.mcp"),icon:t.jsx(zi,{className:"h-3.5 w-3.5"})}],D=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",children:[t.jsx("div",{className:"flex h-9 min-w-0 flex-1 items-center",children:h?t.jsx(Da,{items:E,activeId:s,onSelect:w=>o(w),layoutMode:"fit",variant:"active-pill",nonCompositedIndicator:!0,inactiveTabsIconOnly:!0,className:"h-full"}):null}),t.jsx("button",{type:"button",className:"-mr-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":f("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(Q,{name:"close",className:"size-5"})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[T.has("changes")?t.jsx("div",{className:X("h-full",s!=="changes"&&"hidden"),children:t.jsx(Je,{children:t.jsx(hu,{visible:n&&s==="changes",initialDiff:r})})},r?`changes:${r.path}:${r.staged}`:"changes"):null,T.has("files")?t.jsx("div",{className:X("h-full",s!=="files"&&"hidden"),children:t.jsx(Je,{children:t.jsx(ju,{})})}):null,T.has("terminal")?t.jsx("div",{className:X("h-full",s!=="terminal"&&"hidden"),children:t.jsx(Je,{children:t.jsx(_a,{visible:n&&s==="terminal"})})}):null,T.has("notes")?t.jsx("div",{className:X("h-full",s!=="notes"&&"hidden"),children:t.jsx(Je,{children:t.jsx(Ma,{onActionComplete:e,onOpenPlan:i})})}):null,T.has("mcp")?t.jsx("div",{className:X("h-full",s!=="mcp"&&"hidden"),children:t.jsx(Je,{children:t.jsx(Cu,{onOpenMcpSettings:a})})}):null]})]});return u==="panel"?t.jsx("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:D}):Bt.createPortal(t.jsx("section",{ref:l,role:"dialog","aria-modal":"true","aria-label":f("mobile.header.openWorkspaceAria"),"aria-hidden":!n,className:"oc-keyboard-inset-surface oc-bottom-safe-surface fixed inset-0 z-50 flex flex-col bg-background text-foreground",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:p?"none":"translateX(100%)",transition:`transform ${Tr}ms ${Nu}`,visibility:h?"visible":"hidden",pointerEvents:n?"auto":"none"},children:D}),d.current)};function Eu(n){return n.currentDirectory}function Ru(n){return n.refresh}function Pu(n){return n.loadMcpConfigs}function Au(n){return window.setTimeout(n,500)}function Tu(n){const e=ce.c(4),s=2500,{uiFont:o}=Oi(),[r,i]=c.useState(!1);let a,u;return e[0]!==s||e[1]!==o?(a=()=>{let f=!1;const d=()=>{f||i(!0)},l=()=>{requestAnimationFrame(()=>requestAnimationFrame(d))},p=Promise.all([Bi(o).catch(zu),document.fonts?.ready?.then(Mu).catch(_u)??Promise.resolve(),vl.catch(Du)]).then(Iu),g=new Promise(h=>{window.setTimeout(h,s)});return Promise.race([p,g]).then(l),()=>{f=!0}},u=[o,s],e[0]=s,e[1]=o,e[2]=a,e[3]=u):(a=e[2],u=e[3]),c.useEffect(a,u),r}function Iu(){}function Du(){}function _u(){}function Mu(){}function zu(){}const Ou="aiworker",Bu=n=>n.replace(/^\/+|\/+$/g,""),Lu=n=>{const e=Bu(n.pathname).split("/").filter(Boolean);return n.host?[n.host,...e]:e};function $u(n){if(typeof n!="string"||n.length===0)return null;let e;try{e=new URL(n)}catch{return null}if(e.protocol!==`${Ou}:`)return null;const s=Lu(e),o=(s[0]??"").toLowerCase(),r=s.slice(1),i=e.searchParams;switch(o){case"session":{const a=r[0]||i.get("id")||"";return a?{type:"session",sessionId:a,directory:i.get("dir")??void 0}:null}case"new":case"new-session":return{type:"new-session",directory:i.get("dir")??void 0,projectId:i.get("project")??void 0,agent:i.get("agent")??void 0,model:i.get("model")??void 0};case"sessions":{const a=i.get("filter");return{type:"sessions",filter:a==="attention"||a==="recent"||a==="all"?a:void 0}}case"status":return{type:"status"};case"settings":return{type:"settings",section:r[0]||i.get("section")||void 0};case"changes":return{type:"changes",path:r.join("/")||i.get("path")||void 0,staged:i.get("staged")==="true"};case"view":{const a=(r[0]||"").toLowerCase();return a==="changes"?{type:"changes"}:a==="files"||a==="mcp"||a==="instances"||a==="update"?{type:"view",target:a}:null}default:return null}}let He={},Do=!1,ls=null;const Fu=n=>{switch(n.type){case"session":return Ee.getState().setCurrentSession(n.sessionId,n.directory??null),!0;case"new-session":{const e=Ee.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 He.openSessions?(He.openSessions(n.filter),!0):!1;case"status":return He.openSessions?(He.openSessions(),!0):!1;case"view":return He.openView?(He.openView(n.target),!0):!1;case"changes":return He.openChanges?(He.openChanges({path:n.path,staged:n.staged}),!0):!1;case"settings":return He.openSettings?(He.openSettings(n.section),!0):!1}},Wn=()=>{if(!Do||!ls)return;const n=ls;ls=null,Fu(n)||(ls=n)},_o=n=>{ls=n,Wn()},Dr=n=>{const e=$u(n);e&&_o(e)},Wu=n=>{Do=n,Wn()},Uu=n=>{const e=ce.c(3);let s,o;e[0]!==n?(s=()=>(He=n,Wn(),()=>{He===n&&(He={})}),o=[n],e[0]=n,e[1]=s,e[2]=o):(s=e[1],o=e[2]),c.useEffect(s,o)},Vu=n=>{const{ready:e}=n;c.useEffect(()=>{Wu(e)},[e]),c.useEffect(()=>{if(!Me())return;let s=!1;const o=[];return Lt(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([125,5,126])).then(async({App:r})=>{if(s)return;const i=await r.addListener("appUrlOpen",a=>{Dr(a?.url)});if(s){i.remove();return}o.push(()=>{i.remove()})}).catch(()=>{}),Lt(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([127,126])).then(async({PushNotifications:r})=>{if(s)return;const i=await r.addListener("pushNotificationActionPerformed",a=>{const u=a?.notification?.data,f=typeof u?.url=="string"?u.url:typeof u?.deeplink=="string"?u.deeplink:void 0;if(f){Dr(f);return}const d=typeof u?.sessionId=="string"?u.sessionId:void 0;d&&_o({type:"session",sessionId:d})});if(s){i.remove();return}o.push(()=>{i.remove()})}).catch(()=>{}),()=>{s=!0,o.forEach(r=>r())}},[])},Gu=()=>{if(typeof window>"u")return;const n=window.__AIWORKER_APNS_ENV__;if(n==="development")return"sandbox";if(n==="production")return"production"},Ku=()=>{if(typeof window>"u")return!1;const e=window.Capacitor?.getPlatform?.();return e==="ios"||e==="android"},Hu=n=>{const{enabled:e}=n,s=it(r=>r.nativeNotificationsEnabled),o=c.useRef(null);c.useEffect(()=>{if(!e||!s||!Ku())return;let r=!1;const i=[];return Lt(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([127,126])).then(async({PushNotifications:a})=>{if(r)return;let u=await a.checkPermissions().catch(()=>null);if(u?.receive!=="granted"&&(u=await a.requestPermissions().catch(()=>null)),u?.receive!=="granted")return;const f=await a.addListener("registration",l=>{o.current=l.value,Hn()?.push?.registerApnsToken?.({token:l.value,platform:Or(),environment:Gu()})}),d=await a.addListener("registrationError",l=>{console.warn("[Push] APNs registration error:",l)});if(await a.register().catch(()=>{}),r){f.remove(),d.remove();return}i.push(()=>{f.remove()},()=>{d.remove()})}).catch(()=>{}),()=>{r=!0,i.forEach(a=>a())}},[e,s]),c.useEffect(()=>{if(s)return;const r=o.current;if(!r)return;o.current=null,Hn()?.push?.unregisterApnsToken?.({token:r})},[s])},_r=n=>{const e=ce.c(12),{side:s,isResizing:o,ariaLabel:r,handleProps:i}=n,a=s==="left"?"right-0":"left-0";let u;e[0]!==a?(u=X("absolute inset-y-0 z-50 w-6 cursor-col-resize touch-none",a),e[0]=a,e[1]=u):u=e[1];const f=s==="left"?"right-0":"left-0",d=o&&"bg-[var(--interactive-border)]";let l;e[2]!==f||e[3]!==d?(l=X("absolute inset-y-0 w-[3px] transition-colors",f,d),e[2]=f,e[3]=d,e[4]=l):l=e[4];let p;e[5]!==l?(p=t.jsx("div",{className:l}),e[5]=l,e[6]=p):p=e[6];let g;return e[7]!==r||e[8]!==i||e[9]!==u||e[10]!==p?(g=t.jsx("div",{className:u,role:"separator","aria-orientation":"vertical","aria-label":r,...i,children:p}),e[7]=r,e[8]=i,e[9]=u,e[10]=p,e[11]=g):g=e[11],g},qu=320,Ju=380,Mr=280,Yu=560,Xu=900;function zr(n,e,s,o){const r=ce.c(23),i=o===void 0?Yu:o,a=c.useRef(null);let u;r[0]!==s||r[1]!==i||r[2]!==e?(u=()=>{if(typeof window>"u")return s;const b=Number.parseInt(window.localStorage.getItem(e)??"",10);return Number.isFinite(b)?Math.min(i,Math.max(Mr,b)):s},r[0]=s,r[1]=i,r[2]=e,r[3]=u):u=r[3];const[f,d]=c.useState(u),[l,p]=c.useState(!1),g=c.useRef(0),h=c.useRef(f),x=c.useRef(null),j=c.useRef(null);let v;r[4]!==i?(v=b=>Math.min(i,Math.max(Mr,Math.round(b))),r[4]=i,r[5]=v):v=r[5];const T=v;let S;r[6]===Symbol.for("react.memo_cache_sentinel")?(S=b=>{const _=a.current;_&&(_.style.width=`${b}px`,_.style.minWidth=`${b}px`,_.style.maxWidth=`${b}px`,_.style.setProperty("--oc-ipad-sidebar-width",`${b}px`))},r[6]=S):S=r[6];const E=S;let D;r[7]!==f?(D=b=>{try{b.currentTarget.setPointerCapture(b.pointerId)}catch{}j.current=b.pointerId,g.current=b.clientX,h.current=f,x.current=f,p(!0),b.preventDefault()},r[7]=f,r[8]=D):D=r[8];const w=D;let A;r[9]!==T||r[10]!==n?(A=b=>{if(j.current!==b.pointerId)return;const _=b.clientX-g.current,V=T(h.current+(n==="left"?_:-_));x.current!==V&&(x.current=V,E(V))},r[9]=T,r[10]=n,r[11]=A):A=r[11];const k=A;let P;r[12]!==T||r[13]!==e?(P=b=>{if(j.current!==b.pointerId)return;try{b.currentTarget.releasePointerCapture(b.pointerId)}catch{}const _=T(x.current??h.current);j.current=null,x.current=null,p(!1),d(_);try{window.localStorage.setItem(e,String(_))}catch{}},r[12]=T,r[13]=e,r[14]=P):P=r[14];const y=P;let O;r[15]!==w||r[16]!==y||r[17]!==k?(O={onPointerDown:w,onPointerMove:k,onPointerUp:y,onPointerCancel:y},r[15]=w,r[16]=y,r[17]=k,r[18]=O):O=r[18];const M=O;let C;return r[19]!==M||r[20]!==l||r[21]!==f?(C={asideRef:a,width:f,isResizing:l,handleProps:M},r[19]=M,r[20]=l,r[21]=f,r[22]=C):C=r[22],C}const Qu=["general","appearance","chat","notifications","sessions","git","magic-prompts","snippets","behavior","agents","commands","mcp","plugins","skills.installed","skills.catalog","providers","usage","voice","integrations","about"],Zu=1e3,ed=({onActiveConnectionDeleted:n})=>{const{t:e}=fe();Wa();const[s,o]=c.useState(!1),[r,i]=c.useState(null),[a,u]=c.useState(!1),[f,d]=c.useState("changes"),[l,p]=c.useState(null),[g,h]=c.useState("nav"),[x,j]=c.useState(null),v=it(H=>H.setSettingsPage),T=it(H=>H.wideChatLayoutEnabled),S=_t(H=>H.available),E=_t(H=>H.runtimeType),D=c.useMemo(()=>to(),[]),w=zt(H=>H.mcpServers),A=zt(H=>H.setMcpDraft),k=zt(H=>H.setSelectedMcp),P=c.useCallback(()=>{i(null),p(null)},[]),y=c.useCallback(H=>{i(H)},[]),O=c.useCallback(()=>{u(!1)},[]),M=c.useCallback(H=>{h(H),y("settings")},[y]),{enabled:C,roomyForPanels:b}=gn(),V=ia()==="portrait",N=aa(),[U,$]=c.useState(()=>la().roomyForPanels),I=c.useCallback(()=>{$(H=>!H)},[]);c.useEffect(()=>{C||$(!1)},[C]);const B=c.useCallback(()=>{j(null),d("files"),u(!0)},[]),Z=c.useCallback((H=null)=>{j(H),d("changes"),u(!0)},[]),ee=zr("left","aiworker.ipad.leftSidebarWidth",qu),te=zr("right","aiworker.ipad.rightSidebarWidth",Ju,Xu),z=b,W=z&&a?te.width:0,q=C&&U?ee.width:0;c.useEffect(()=>{if(typeof document>"u")return;const H=document.documentElement;return H.style.setProperty("--oc-chat-inset-left",`${q}px`),H.style.setProperty("--oc-chat-inset-right",`${W}px`),()=>{H.style.removeProperty("--oc-chat-inset-left"),H.style.removeProperty("--oc-chat-inset-right")}},[q,W]),c.useEffect(()=>{if(typeof document>"u")return;const H=document.documentElement;return H.classList.toggle("wide-chat-layout",T),()=>H.classList.remove("wide-chat-layout")},[T]),c.useEffect(()=>{if(typeof document>"u")return;const H=C&&(V||N),ve=document.documentElement;return ve.classList.toggle("oc-keep-draft-starters",H),()=>ve.classList.remove("oc-keep-draft-starters")},[N,C,V]);const G=c.useMemo(()=>({openChanges:({diffPath:H,staged:ve}={})=>{Z(H?{path:H,staged:ve===!0}:null)},openFiles:()=>B(),openSettings:()=>M("nav")}),[Z,B,M]),Y=c.useMemo(()=>({openSessions:()=>{C?$(!0):o(!0)},openView:H=>{if(H==="files"){B();return}if(H==="mcp"){d("mcp"),u(!0);return}y(H)},openChanges:({path:H,staged:ve}={})=>{Z(H?{path:H,staged:ve===!0}:null)},openSettings:H=>{H&&v(H),M(H?"page-content":"nav")}}),[C,Z,B,M,y,v]);Uu(Y);const ne=c.useRef(null);Fn(ne,{onLeftEdgeSwipe:()=>{C?$(!0):o(!0)},onRightEdgeSwipe:()=>u(!0)});const oe=c.useRef(null),le=c.useCallback(H=>{oe.current=H},[]),ue=c.useCallback(()=>l?(p(null),!0):r==="settings"&&oe.current?.()?!0:r?(P(),!0):a?(O(),!0):s?(o(!1),!0):!1,[r,P,O,l,s,a]);ca(ue);const K=!D&&S&&(E==="desktop"||E==="web"),ie=C?"dialog":"fullscreen",xe=c.useMemo(()=>({instanceLabel:D?ns():null,onOpenInstances:D?()=>y("instances"):void 0,onOpenSettings:()=>M("nav"),onOpenUpdate:K?()=>y("update"):void 0}),[M,y,D,K]),Se=c.useCallback(()=>{const H="new-mcp-server";let ve=H,Re=1;for(;w.some(ze=>ze.name===ve);)ve=`${H}-${Re}`,Re+=1;A({name:ve,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",timeout:"",enabled:!0}),k(ve),v("mcp"),M("page-content")},[w,M,A,k,v]);return t.jsx(ua,{actions:G,children:t.jsxs("div",{className:"oc-mobile-app-shell main-content-safe-area flex h-[100dvh] flex-row bg-background text-foreground","data-page-scroll-lock":"true",children:[C?t.jsxs("aside",{ref:ee.asideRef,className:X("relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!U&&"border-r-0"),style:{width:U?ee.width:0,minWidth:U?ee.width:0,maxWidth:U?ee.width:0,"--oc-ipad-sidebar-width":`${ee.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:ee.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!U,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:X("flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",ee.isResizing&&"pointer-events-none",!U&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Je,{children:t.jsx(kr,{open:!0,variant:"sidebar",onOpenChange:H=>{!H&&!b&&$(!1)},footer:xe})})}),U?t.jsx(_r,{side:"left",isResizing:ee.isResizing,ariaLabel:e("sidebar.resize.leftPanelAria"),handleProps:ee.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(Pc,{onOpenSessions:()=>C?I():o(!0),onOpenWorkspace:()=>u(!0),compactTitle:C}),t.jsx("main",{ref:ne,className:"relative min-h-0 flex-1 overflow-hidden","data-page-scroll-lock":"true",children:t.jsx("div",{className:"h-full w-full",children:t.jsx(Je,{children:t.jsx(Ua,{})})})})]}),C?null:t.jsx(kr,{open:s,onOpenChange:o,footer:xe}),C?t.jsxs("aside",{ref:te.asideRef,className:X("relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!W&&"border-l-0"),style:{width:W,minWidth:W,maxWidth:W,"--oc-ipad-sidebar-width":`${te.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:te.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!W,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:X("flex h-full min-h-0 shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",te.isResizing&&"pointer-events-none",!W&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Je,{children:t.jsx(Ir,{open:a,onClose:O,tab:f,onTabChange:d,pendingChangesDiff:x,onOpenPlan:p,onOpenMcpSettings:Se,variant:z?"panel":"drawer"})})}),W?t.jsx(_r,{side:"right",isResizing:te.isResizing,ariaLabel:e("sidebar.resize.rightPanelAria"),handleProps:te.handleProps}):null]}):t.jsx(Ir,{open:a,onClose:O,tab:f,onTabChange:d,pendingChangesDiff:x,onOpenPlan:p,onOpenMcpSettings:Se}),l?t.jsx(is,{open:!0,variant:ie,onClose:()=>p(null),ariaLabel:l.title,title:l.title,children:t.jsx(Je,{children:t.jsx(Ha,{savedProjectPlan:{projectRef:l.projectRef,planId:l.id},onNavigatedToChat:()=>{P(),O()}})})}):null,r==="instances"&&D?t.jsx(is,{open:!0,variant:ie,dialogAlign:"app",onClose:P,ariaLabel:e("mobile.menu.instances"),title:e("mobile.menu.instances"),children:t.jsx(Dc,{onConnect:P,onActiveConnectionDeleted:n})}):null,r==="settings"?t.jsx(is,{open:!0,variant:ie,dialogAlign:"app",onClose:P,ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(Je,{children:t.jsx(Ga,{forceMobile:!0,isWindowed:!0,initialMobileStage:g,registerBackHandler:le,visiblePageSlugs:Qu.filter(H=>!(D&&H==="about")),onClose:P})})}):null,r==="update"?t.jsx(is,{open:!0,variant:ie,dialogAlign:"app",onClose:P,ariaLabel:e("mobile.menu.update"),title:e("mobile.menu.update"),children:t.jsx(Je,{children:t.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:t.jsx(Ka,{initialUpdateDialogOpen:!0})})})}):null]})})};function td({apis:n}){const{t:e}=fe(),s=qe(z=>z.initializeApp),o=qe(z=>z.isInitialized),r=qe(z=>z.isConnected),i=qe(z=>z.connectionPhase),a=qe(z=>z.providers.length),u=qe(z=>z.agents.length),f=qe(z=>z.loadProviders),d=qe(z=>z.loadAgents),l=vt(z=>z.currentDirectory),p=Ee(z=>z.error),g=Ee(z=>z.clearError),h=it(z=>z.setIsMobile),x=Li(z=>z.refreshStatus),j=$i(z=>z.refreshStatus),v=Fi(z=>z.setPlanModeEnabled),T=We(z=>z.projects),[S,E]=c.useState(0),[D,w]=c.useState(0),[A,k]=c.useState(!1),[P,y]=c.useState("pending"),[O,M]=c.useState(null),C=c.useMemo(()=>ns(),[]),[,b]=c.useReducer(z=>z+1,0),_=c.useMemo(()=>to(),[]),V=c.useRef(0),N=c.useRef(0),U=c.useCallback(()=>{const z=ot(),W=N.current+1;if(N.current=W,!z){Zt("resume:auto-connect",{}),es();return}Zt("resume:reprobe",{});const q=()=>{s(),x(n.github,{force:!0}),j(n.linear,{force:!0}),a===0&&f({source:"mobileApp:nativeResume"}),u===0&&d({source:"mobileApp:nativeResume"})},G=ne=>{Zt("resume:disconnect",{reason:ne}),Dt({apiBaseUrl:"",clientToken:null,runtimeKey:Ss}),E(oe=>oe+1)};As().then(ne=>{if(N.current===W){if(ne==="no-connection"){G("no-connection");return}if(ne==="needs-login"){M({kind:"auth-expired",label:ns()??""}),G("needs-login");return}if(ne==="unreachable"){const oe=[4e3,1e4],le=ue=>{window.setTimeout(()=>{if(N.current!==W)return;const K=ue===oe.length-1;As({fast:!K}).then(ie=>{if(N.current===W&&ie!=="switched"){if(ie==="unchanged"){q();return}if(ie==="needs-login"){M({kind:"auth-expired",label:ns()??""}),G("retry-needs-login");return}if(!K){le(ue+1);return}G(`retry-${ie}`)}})},oe[ue])};le(0);return}ne!=="switched"&&q()}});const Y=Date.now();Y-V.current>=Zu&&(V.current=Y,window.dispatchEvent(new Event("aiworker:system-resume")))},[u,n.github,n.linear,s,d,f,a,x,j]);Wi(),Ui(U),c.useEffect(()=>{if(!_)return;let z;const W=()=>{window.clearTimeout(z),z=window.setTimeout(()=>U(),1500)};return window.addEventListener("online",W),()=>{window.removeEventListener("online",W),window.clearTimeout(z)}},[_,U]),c.useEffect(()=>{if(_)return qn.subscribe((z,W)=>{z.state==="expired"&&W.state!=="expired"&&(U(),qn.getState().markAuthenticated())})},[_,U]),c.useEffect(()=>(Jn(n),()=>Jn(null)),[n]),c.useEffect(()=>Wo(z=>{if(Zt("endpoint:changed",{runtimeKey:z.runtimeKey||"none",previousRuntimeKey:z.previousRuntimeKey||"none",connected:!!z.apiBaseUrl}),!!z.runtimeKey&&z.runtimeKey===z.previousRuntimeKey){za(),b();return}Oa(z),w(q=>q+1),E(q=>q+1)}),[]),c.useEffect(()=>{if(!_||r||ot()){y("done");return}let z=!1;return y("attempting"),(async()=>{const W=await es().catch(()=>({status:"no-candidate"}));z||(W.status==="unreachable"?M({kind:"unreachable",label:W.label}):W.status==="needs-login"&&M({kind:"auth-expired",label:W.label}),y("done"),W.status==="unreachable"&&es({fast:!1,skipIfConnected:!0}).catch(()=>null))})(),()=>{z=!0}},[]),c.useEffect(()=>{if(!_||!ot())return;let z=!1;const W=q=>{Zt("cold-launch:drop",{kind:q?.kind??"unknown"}),q&&M(q),Dt({apiBaseUrl:"",clientToken:null,runtimeKey:Ss}),E(G=>G+1)};return As().then(async q=>{if(z||q==="switched"||q==="unchanged")return;const G=ns();if(q==="needs-login"){W({kind:"auth-expired",label:G??""});return}if(q==="unreachable"){W(G?{kind:"unreachable",label:G}:null),es({fast:!1,skipIfConnected:!0}).catch(()=>null);return}const Y=await es().catch(()=>({status:"no-candidate"}));z||Y.status==="connected"||(Y.status==="needs-login"?W({kind:"auth-expired",label:Y.label}):Y.status==="unreachable"?W({kind:"unreachable",label:Y.label}):W(null))}),()=>{z=!0}},[]),c.useEffect(()=>{h(!0)},[h]),c.useEffect(()=>{_&&!ot()||s()},[S,s,_]),c.useEffect(()=>{r&&(a===0&&f({source:"mobileApp:recovery"}),u===0&&d({source:"mobileApp:recovery"}))},[u,r,d,f,a]);const $=c.useRef(!1),[I,B]=c.useState(_);c.useEffect(()=>{if(!_||!r||$.current)return;if(Ee.getState().currentSessionId){$.current=!0,B(!1);return}const z=Vt(),W=Vi(z);if(!W){$.current=!0,B(!1);return}let q=!1;const G=window.setTimeout(()=>B(!1),6e3);return(async()=>{const Y=await bn().catch(()=>null);if(q)return;if(!Y){B(!1);return}$.current=!0;const ne=Y.activeSessions.find(le=>le.id===W.sessionId);if(!ne){Gi(z),B(!1);return}const oe=Ee.getState();oe.currentSessionId||oe.setCurrentSession(ne.id,hn(ne)??W.directory??void 0),B(!1)})(),()=>{q=!0,window.clearTimeout(G)}},[S,r,_]),c.useEffect(()=>{r&&Yn.setDirectory(l)},[l,r]),c.useEffect(()=>{r&&(x(n.github,{force:!0}),j(n.linear,{force:!0}))},[n.github,n.linear,r,x,j]),c.useEffect(()=>{if(!r||T.length===0)return;let z=!1;return(async()=>{const q=new Map(Ee.getState().availableWorktreesByProject);if(await Promise.all(T.map(async ne=>{const oe=ne.path.replace(/\\/g,"/").replace(/\/+$/,"");if(oe)try{if(!(Ke.getState().directories.get(oe)?.isGitRepo??await Lt(()=>import("./useAppFontEffects-Cwyhjfl5.js").then(ie=>ie.iE),__vite__mapDeps([9,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(ie=>ie.checkIsGitRepository(oe))))return;const K=await Qr({id:ne.id,path:oe});if(z)return;q.set(oe,K)}catch{}})),z)return;const G=Zr(T,q),Y=Ee.getState().availableWorktreesByProject;ra(G,Y)||Ee.setState({availableWorktrees:[...G.values()].flat(),availableWorktreesByProject:G})})(),()=>{z=!0}},[r,T]),c.useEffect(()=>{if(!r)return;let z=!1;const W=Ki(q=>{q.type==="worktree-changed"&&oa(T,q.directories,()=>z)});return()=>{z=!0,W()}},[r,T]),c.useEffect(()=>{let z=!1;return(async()=>{const q=await mn("/health",{method:"GET"}).catch(()=>null);if(!q||!q.ok||z)return;const G=await q.json().catch(()=>null);if(!G||z)return;const Y=G.planModeExperimentalEnabled;v(Y===!0||Y===1||Y==="1"||Y==="true")})(),()=>{z=!0}},[v]),c.useEffect(()=>{if(!p)return;const z=window.setTimeout(()=>g(),5e3);return()=>window.clearTimeout(z)},[g,p]),c.useEffect(()=>{if(!(!r&&(_?!!ot():!0))){k(!1);return}const W=window.setTimeout(()=>{k(!0)},_?4e3:8e3);return()=>window.clearTimeout(W)},[r,_,S,D]),Hi(),qi({enabled:!0}),Ba(),Ji(),La(),Hu({enabled:_&&r}),Vu({ready:_&&r&&o});const Z=Tu(),ee=!r&&i==="reconnecting";if(!Z)return t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background text-foreground",children:t.jsx(bt,{width:120,height:120,isAnimated:!0})});const te=!!ot();return _&&(!te||!r&&!ee)?te?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:"flex max-w-sm flex-col items-center gap-4",children:[t.jsx(bt,{width:120,height:120,isAnimated:!A}),A?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:e("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:e("mobile.connect.recovery.description")})]}),t.jsx(he,{type:"button",variant:"outline",onClick:()=>{Dt({apiBaseUrl:"",clientToken:null,runtimeKey:Ss}),E(z=>z+1)},children:e("mobile.connect.cancelPassword")})]}):null]})}):P!=="done"?t.jsxs("main",{className:"relative flex min-h-dvh items-center justify-center bg-background text-foreground",children:[t.jsx(bt,{width:120,height:120,isAnimated:!0}),C?t.jsxs("div",{className:"absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center",children:[t.jsx("p",{className:"typography-small text-muted-foreground",children:e("mobile.connect.splash.connectingTo")}),t.jsxs("p",{className:"typography-small text-foreground",children:[C,t.jsx(Yi,{})]})]}):null]}):t.jsx(t.Fragment,{children:t.jsx(pc,{onConnected:()=>E(z=>z+1),notice:O})}):!r&&!ee?A?t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground",children:t.jsxs("div",{className:"max-w-sm space-y-3",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:e("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:e("sessionAuth.error.networkDescription")})]})}):t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background text-foreground",children:t.jsx(bt,{width:120,height:120,isAnimated:!0})}):t.jsx(Je,{children:t.jsx(Xi,{sdk:Yn.getSdkClient(),directory:l||"",children:t.jsx(Qi,{apis:n,children:t.jsx(Zi,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[_&&I?t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background",children:t.jsx(bt,{width:120,height:120,isAnimated:!0})}):null,t.jsx(ea,{embeddedBackgroundWorkEnabled:o}),t.jsx($a,{}),t.jsx(Pl,{}),t.jsx(ed,{onActiveConnectionDeleted:()=>{Dt({apiBaseUrl:"",clientToken:null,runtimeKey:Ss}),E(z=>z+1)}}),t.jsx(ta,{}),t.jsx(sa,{}),t.jsx(na,{position:"top-center",offset:"calc(var(--oc-safe-area-top, 0px) + 16px)"}),o?t.jsx(Fa,{}):null]})})})},D)})}const sd=()=>{ba(),Uo().then(()=>{Promise.all([Vo(),xa()]).catch(n=>{console.error("[mobile-main] settings init failed:",n)}),ya(),va(),wa()}).catch(n=>{console.error("[mobile-main] appearance init failed:",n)}).finally(()=>{wl()})};function Pm(n){window.__AIWORKER_SURFACE__="mobile",da(),sd(),Rl(),fa();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");const o=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",r=o?{...n,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:n,i=t.jsx(td,{apis:r});Mo.createRoot(e).render(t.jsx(on.StrictMode,{children:t.jsx(ma,{children:t.jsx(pa,{children:t.jsx(ha,{children:t.jsx(Va,{children:o?i:t.jsx(ga,{children:i})})})})})}))}export{Pm as renderMobileApp};