@vantran-se/openchamber-web 2.1.1 → 2.2.0
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.
- package/README.md +32 -24
- package/bin/cli.js +1 -3
- package/bin/cli.test.js +40 -16
- package/bin/lib/DOCUMENTATION.md +6 -5
- package/bin/lib/cli-args.js +6 -1
- package/bin/lib/cli-args.test.js +34 -0
- package/bin/lib/cli-lifecycle.js +0 -1
- package/bin/lib/cli-network.js +8 -2
- package/bin/lib/cli-process.js +1 -1
- package/bin/lib/cli-settings-accessors.test.js +21 -13
- package/bin/lib/cli-startup.js +17 -11
- package/bin/lib/cli-startup.test.js +92 -2
- package/bin/lib/commands-connect-url.js +8 -1
- package/bin/lib/commands-schedule.js +8 -2
- package/bin/lib/commands-serve.js +15 -21
- package/bin/lib/commands-update.js +12 -24
- package/bin/lib/commands-update.test.js +14 -46
- package/dist/assets/DiffView-Cv9MSXl1.js +4 -0
- package/dist/assets/FilePreviewCommentMenu-D4kLseHj.js +4 -0
- package/dist/assets/FilesView-BVoD8I2x.js +14 -0
- package/dist/assets/{GitView-DzuzhIPx.js → GitView-Bzb8p-ew.js} +4 -4
- package/dist/assets/GuestSurfacePane-Crdbvsxo.js +1 -0
- package/dist/assets/InProgressOperationBanner-CwMjNQgk.js +2 -0
- package/dist/assets/{JsonTreeView-B_EPRjzy.js → JsonTreeView-DRKHZfsn.js} +1 -1
- package/dist/assets/MarkdownImageGallery-DZtqT1Zn.js +1 -0
- package/dist/assets/MarkdownRendererImpl-CqG7HCNd.js +10 -0
- package/dist/assets/OnboardingScreen-DMIxwYK5.js +1 -0
- package/dist/assets/{PatchDiff-6yh1csza.js → PatchDiff-CUcCg1jk.js} +1 -1
- package/dist/assets/PierreDiffViewer-CnnR-dnD.js +228 -0
- package/dist/assets/PlanView-RCBadcY7.js +5 -0
- package/dist/assets/SettingsView-CjBjZFRO.js +30 -0
- package/dist/assets/SettingsWindow-DyM7QuhI.js +1 -0
- package/dist/assets/SubmoduleDiffSummary-BWIfgMED.js +1 -0
- package/dist/assets/ToolOutputDialog-Q0P3FuAi.js +15 -0
- package/dist/assets/ToolPartDiffPreview-p7qR9FpU.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-BTJVRkyo.js → VirtualizedFileDiff-CFpjL8Ns.js} +3 -3
- package/dist/assets/{Virtualizer-xCEYz34p.js → Virtualizer-C0IsclZn.js} +1 -1
- package/dist/assets/WalkthroughView-DI31zD02.js +4 -0
- package/dist/assets/appThemeRegistry-B9gkFq9i.js +1 -0
- package/dist/assets/{computeVirtualFileMetrics-CmPe29DM.js → computeVirtualFileMetrics-C2WM6JC2.js} +2 -2
- package/dist/assets/de-YKfk5MmC.js +14 -0
- package/dist/assets/es-_gwT0kr-.js +20 -0
- package/dist/assets/fileTreeStatus-D438yi8M.js +1 -0
- package/dist/assets/fr-DqzvXmIm.js +18 -0
- package/dist/assets/index-BLaHKdtx.js +1 -0
- package/dist/assets/index-BkMXRrVQ.css +1 -0
- package/dist/assets/index-DxNa7xYB.js +65 -0
- package/dist/assets/initializeSharedPreferences-Bck5EAWP.js +1 -0
- package/dist/assets/{isDiffPlainText-CQmDCnEv.js → isDiffPlainText-Dgbw8VKk.js} +1 -1
- package/dist/assets/{isFilePlainText-CYBUzW4I.js → isFilePlainText-_ZS5UYRj.js} +1 -1
- package/dist/assets/ja-B-GFYhQE.js +20 -0
- package/dist/assets/ko-mzksfqDC.js +20 -0
- package/dist/assets/main-C5Xx8dn_.js +2 -0
- package/dist/assets/main-CfBSQM1H.js +990 -0
- package/dist/assets/markdownCore-BmWwW1ll.js +7 -0
- package/dist/assets/miniChat-mnKwy4vQ.js +2 -0
- package/dist/assets/mobile-DeEQd0wZ.js +2 -0
- package/dist/assets/nl-CWQr6NSq.js +20 -0
- package/dist/assets/{parseDiffFromFile-Cy0PNxun.js → parseDiffFromFile-BUgn-T9p.js} +2 -2
- package/dist/assets/patchFileDiff-Dt8LhgBh.js +13 -0
- package/dist/assets/pl-UmRcDUX2.js +20 -0
- package/dist/assets/pt-BR-BSLybvVF.js +20 -0
- package/dist/assets/relocateRestoredSession-B5E9xb3T.js +1 -0
- package/dist/assets/renderElectronMiniChatApp-C0a9A5_J.js +2 -0
- package/dist/assets/renderMobileApp-BNncg3Pk.js +25 -0
- package/dist/assets/runtimeEndpointReset-CZ5aafpl.js +62 -0
- package/dist/assets/{selectionMarkdown-TkYk5h9l.js → selectionMarkdown-CUN3wUld.js} +9 -9
- package/dist/assets/{sessionOwnership-Bs1xbRfB.js → sessionOwnership-BSuxCEhb.js} +1 -1
- package/dist/assets/shikiHighlight-DHDx-6eM.js +1 -0
- package/dist/assets/space-apply-DM_2pRW7.js +1 -0
- package/dist/assets/space-close-Bpomt8z0.js +1 -0
- package/dist/assets/{surface-B6n7wJtt.js → surface-C-jQaGnL.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-CDlKffWz.js → textMateThemeFromAppTheme-DlsTphbY.js} +1 -1
- package/dist/assets/tr-gaTrX_HK.js +11 -0
- package/dist/assets/uk-CnJF6ykl.js +20 -0
- package/dist/assets/{useAppFontEffects-DCqCVGlT.js → useAppFontEffects-DGlvOqP_.js} +194 -233
- package/dist/assets/useInlineCommentController-kMN4Wg_D.js +2 -0
- package/dist/assets/{useRootScrollLock-BowwS8kq.js → useRootScrollLock-DMPpvpNP.js} +2 -2
- package/dist/assets/{vendor-base-ui-DX96QhTP.js → vendor-base-ui-Det7U81h.js} +1 -1
- package/dist/assets/{vendor-codemirror-autocomplete-DW1FQz9_.js → vendor-codemirror-autocomplete-BSHQHbKu.js} +1 -1
- package/dist/assets/{vendor-codemirror-commands-DpmhalwN.js → vendor-codemirror-commands-C4G_dPWe.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-angular-BqExbN1M.js → vendor-codemirror-lang-angular-B6LbBGHB.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-cpp-DZA36HfS.js → vendor-codemirror-lang-cpp-BWWXBx7W.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-css-B07blnnZ.js → vendor-codemirror-lang-css-Cayfb29q.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-go-BM8K9D1-.js → vendor-codemirror-lang-go-BoKlCNKw.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-html-DaH9adfE.js → vendor-codemirror-lang-html-BQWerHsJ.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-java-CsdC0viz.js → vendor-codemirror-lang-java-DWX7Fq_K.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-javascript-CpGYXGuo.js → vendor-codemirror-lang-javascript-DbpEcZM0.js} +2 -2
- package/dist/assets/{vendor-codemirror-lang-jinja-BBeGzXw5.js → vendor-codemirror-lang-jinja-D1JIJRA7.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-json-58T70Hqs.js → vendor-codemirror-lang-json-BzgckzmB.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-BI-xCA59.js → vendor-codemirror-lang-less-B9EpDXFi.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-liquid-zEcMa-zy.js → vendor-codemirror-lang-liquid-9U7kRbSf.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-markdown-BLKnlLP4.js → vendor-codemirror-lang-markdown-D2TEBIvZ.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-php-9f35M83-.js → vendor-codemirror-lang-php-BT6sDVzE.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-python-jAMtYiA9.js +3 -0
- package/dist/assets/{vendor-codemirror-lang-rust-MNDL_jZQ.js → vendor-codemirror-lang-rust-CVO56EiL.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sass-p9epsSNm.js → vendor-codemirror-lang-sass-DZlOoUWu.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sql-Bqzh0EXX.js → vendor-codemirror-lang-sql-fZ6t1DPw.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-vue-BnNUWV-p.js → vendor-codemirror-lang-vue-DxbqrLiE.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-C2a-oLmk.js → vendor-codemirror-lang-wast-DyU1Gt-I.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-xml-C9a_K5_p.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-yaml-C0sjswB0.js → vendor-codemirror-lang-yaml-Cptq8l0e.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-ByBn5zIW.js → vendor-codemirror-language-DufXoQvE.js} +2 -2
- package/dist/assets/vendor-codemirror-language-data-CtwSWKtX.js +2 -0
- package/dist/assets/{vendor-codemirror-search-ib-sHD5W.js → vendor-codemirror-search-CvXM_pZg.js} +1 -1
- package/dist/assets/{vendor-codemirror-state-G3UuR-be.js → vendor-codemirror-state-Dek9sMtw.js} +1 -1
- package/dist/assets/{vendor-codemirror-view-Bniqp7p5.js → vendor-codemirror-view-1e0FQ6Wn.js} +1 -1
- package/dist/assets/vendor-framer-motion-DxDVhOLc.js +9 -0
- package/dist/assets/vendor-katex-CuQvj9-L.js +257 -0
- package/dist/assets/vendor-katex-DdZNUVNG.css +1 -0
- package/dist/assets/{vendor-motion-dom-DcCgeG69.js → vendor-motion-dom-HXPOMxb7.js} +1 -1
- package/dist/assets/{vendor-opencode-client-DHzhmLwV.js → vendor-opencode-client-BmFcUkbQ.js} +1 -1
- package/dist/assets/{vendor-replit-codemirror-vim-DkzqxN2H.js → vendor-replit-codemirror-vim-BlJRn-cW.js} +2 -2
- package/dist/assets/{vendor-tanstack-react-virtual-H_JmXOFV.js → vendor-tanstack-react-virtual-CvuLsk7D.js} +1 -1
- package/dist/assets/{vendor-tanstack-virtual-core-Dxc8hSTB.js → vendor-tanstack-virtual-core-DPaNcJcT.js} +1 -1
- package/dist/assets/zh-CN-t2vigSB1.js +20 -0
- package/dist/assets/zh-TW-jAgqBokB.js +20 -0
- package/dist/index.html +6 -6
- package/dist/mini-chat.html +6 -6
- package/dist/mobile.html +6 -6
- package/package.json +8 -5
- package/server/index.js +80 -36
- package/server/lib/agent-memory/actions.js +1 -6
- package/server/lib/agent-memory/routes.js +1 -2
- package/server/lib/agent-memory/runtime.js +1 -8
- package/server/lib/agent-tool/DOCUMENTATION.md +7 -3
- package/server/lib/agent-tool/runtime.js +3 -6
- package/server/lib/agent-tool/runtime.test.js +0 -2
- package/server/lib/browser-control/DOCUMENTATION.md +6 -0
- package/server/lib/changelog/update-notes.js +1 -1
- package/server/lib/context-obligatory/runtime.js +1 -2
- package/server/lib/dev-tunnel/DOCUMENTATION.md +8 -0
- package/server/lib/dev-tunnel/client.js +21 -10
- package/server/lib/dev-tunnel/tunnel.test.js +34 -0
- package/server/lib/dispatch-results/runtime.js +1 -1
- package/server/lib/enterprise-mode.d.ts +1 -0
- package/server/lib/enterprise-mode.js +13 -2
- package/server/lib/enterprise-mode.test.js +21 -0
- package/server/lib/event-stream/DOCUMENTATION.md +2 -2
- package/server/lib/event-stream/index.js +1 -3
- package/server/lib/event-stream/translate-v2.js +1 -9
- package/server/lib/event-stream/translate-v2.test.js +0 -11
- package/server/lib/fs/DOCUMENTATION.md +5 -2
- package/server/lib/fs/routes.js +62 -15
- package/server/lib/fs/routes.test.js +278 -48
- package/server/lib/fs/workspace-file-names.js +104 -0
- package/server/lib/fs/workspace-file-names.test.js +62 -0
- package/server/lib/git/DOCUMENTATION.md +17 -5
- package/server/lib/git/contributor-provenance-storage.js +9 -6
- package/server/lib/git/contributor-provenance-storage.test.js +29 -0
- package/server/lib/git/credential-broker.js +1 -1
- package/server/lib/git/credential-resolver.js +1 -4
- package/server/lib/git/credentials.js +1 -0
- package/server/lib/git/discovery-endpoint.js +1 -1
- package/server/lib/git/identity-provisioning.js +2 -1
- package/server/lib/git/identity-storage.js +3 -4
- package/server/lib/git/lfs-discovery.js +14 -14
- package/server/lib/git/lfs-discovery.test.js +16 -6
- package/server/lib/git/network-operation-plan.js +50 -62
- package/server/lib/git/network-operation-plan.test.js +103 -1
- package/server/lib/git/network-operation-registry.js +4 -6
- package/server/lib/git/network-operation-storage.js +4 -6
- package/server/lib/git/network-operations.js +12 -4
- package/server/lib/git/network-operations.test.js +19 -6
- package/server/lib/git/redaction.js +2 -1
- package/server/lib/git/repository-credential-runtime.js +5 -3
- package/server/lib/git/repository-credential-runtime.test.js +22 -0
- package/server/lib/git/routes.js +31 -137
- package/server/lib/git/routes.test.js +2 -2
- package/server/lib/git/service.js +143 -27
- package/server/lib/git/service.test.js +215 -1
- package/server/lib/git/ssh-credential-storage.js +1 -4
- package/server/lib/git/submodule-discovery.js +1 -1
- package/server/lib/git/worktree-bootstrap-storage.js +3 -4
- package/server/lib/git/worktree-bootstrap-storage.test.js +15 -0
- package/server/lib/git/worktree-creation.js +194 -0
- package/server/lib/git/worktree-creation.test.js +155 -0
- package/server/lib/github/DOCUMENTATION.md +11 -6
- package/server/lib/github/auth.js +2 -4
- package/server/lib/github/device-flow.js +2 -2
- package/server/lib/github/gh-cli-credential.js +1 -0
- package/server/lib/github/octokit.js +31 -0
- package/server/lib/github/pr-status.js +35 -18
- package/server/lib/github/pr-status.test.js +271 -3
- package/server/lib/github/reference-search.js +102 -13
- package/server/lib/github/reference-search.test.js +48 -7
- package/server/lib/github/routes.auth.test.js +18 -0
- package/server/lib/github/routes.js +360 -6
- package/server/lib/github/routes.mutations.test.js +239 -0
- package/server/lib/github/routes.test.js +134 -2
- package/server/lib/gitlab/DOCUMENTATION.md +5 -1
- package/server/lib/gitlab/auth-storage.test.js +1 -0
- package/server/lib/gitlab/mappers.js +30 -1
- package/server/lib/gitlab/resources.js +230 -6
- package/server/lib/gitlab/resources.test.js +179 -0
- package/server/lib/gitlab/routes.js +200 -6
- package/server/lib/gitlab/routes.test.js +186 -2
- package/server/lib/gitlab/validation.js +1 -5
- package/server/lib/guests/DOCUMENTATION.md +1 -1
- package/server/lib/guests/oauth.js +2 -2
- package/server/lib/guests/service.js +1 -1
- package/server/lib/guests/sockets.js +1 -1
- package/server/lib/injected-env.d.ts +8 -0
- package/server/lib/injected-env.js +50 -0
- package/server/lib/injected-env.test.js +56 -0
- package/server/lib/linear/DOCUMENTATION.md +5 -6
- package/server/lib/linear/issues.js +62 -4
- package/server/lib/linear/issues.test.js +68 -0
- package/server/lib/linear/oauth.js +5 -5
- package/server/lib/linear/parse.js +2 -9
- package/server/lib/message-queue/DOCUMENTATION.md +23 -1
- package/server/lib/message-queue/runtime.js +85 -12
- package/server/lib/message-queue/runtime.test.js +172 -2
- package/server/lib/notifications/apns-runtime.js +5 -6
- package/server/lib/notifications/apns-runtime.test.js +20 -4
- package/server/lib/openchamber-control/DOCUMENTATION.md +19 -1
- package/server/lib/openchamber-control/actions.js +2 -1
- package/server/lib/openchamber-control/service.js +119 -20
- package/server/lib/openchamber-control/service.test.js +166 -0
- package/server/lib/openchamber-sessions/archive-store.js +1 -6
- package/server/lib/openchamber-sessions/routes.js +47 -12
- package/server/lib/openchamber-sessions/routes.test.js +65 -2
- package/server/lib/openchamber-sessions/session-metadata-store.js +1 -6
- package/server/lib/opencode/DOCUMENTATION.md +22 -8
- package/server/lib/opencode/agents.js +62 -0
- package/server/lib/opencode/auth-state-runtime.js +3 -1
- package/server/lib/opencode/auth.d.ts +1 -1
- package/server/lib/opencode/auth.js +8 -0
- package/server/lib/opencode/auth.test.js +31 -0
- package/server/lib/opencode/config-entity-routes.js +16 -0
- package/server/lib/opencode/config-entity-v2.test.js +16 -1
- package/server/lib/opencode/config-paths.test.js +2 -2
- package/server/lib/opencode/config-v2.js +2 -4
- package/server/lib/opencode/feature-routes-runtime.js +89 -49
- package/server/lib/opencode/lifecycle.js +41 -21
- package/server/lib/opencode/lifecycle.test.js +50 -2
- package/server/lib/opencode/model-discovery.js +1 -1
- package/server/lib/opencode/model-discovery.test.js +17 -0
- package/server/lib/opencode/models-metadata.js +0 -2
- package/server/lib/opencode/openchamber-routes.test.js +3 -3
- package/server/lib/opencode/plugins.js +6 -9
- package/server/lib/opencode/provider-source-route.test.js +101 -3
- package/server/lib/opencode/providers-disabled.test.js +59 -0
- package/server/lib/opencode/providers.js +34 -0
- package/server/lib/opencode/proxy.js +11 -3
- package/server/lib/opencode/routes.js +40 -2
- package/server/lib/opencode/settings-helpers.js +27 -1
- package/server/lib/opencode/settings-helpers.test.js +19 -7
- package/server/lib/opencode/settings-registry.json +27 -16
- package/server/lib/opencode/settings-runtime.test.js +18 -0
- package/server/lib/opencode/shared-service-runtime.js +23 -104
- package/server/lib/opencode/shared.js +77 -46
- package/server/lib/opencode/shared.test.js +12 -12
- package/server/lib/opencode/shutdown-runtime.test.js +2 -3
- package/server/lib/opencode/skill-routes.js +123 -38
- package/server/lib/opencode/skill-routes.test.js +201 -0
- package/server/lib/opencode/skills.js +81 -34
- package/server/lib/opencode/skills.test.js +176 -21
- package/server/lib/opencode/startup-pipeline-runtime.js +6 -3
- package/server/lib/opencode/startup-pipeline-runtime.test.js +2 -1
- package/server/lib/opencode/watcher.test.js +0 -54
- package/server/lib/outbound-proxy.js +52 -0
- package/server/lib/outbound-proxy.test.js +55 -0
- package/server/lib/package-manager.js +23 -17
- package/server/lib/package-manager.test.js +5 -18
- package/server/lib/permission-auto-accept/DOCUMENTATION.md +1 -1
- package/server/lib/permission-auto-accept/runtime.js +19 -47
- package/server/lib/permission-auto-accept/runtime.test.js +2 -2
- package/server/lib/project-context/DOCUMENTATION.md +7 -1
- package/server/lib/project-context/routes.js +1 -2
- package/server/lib/project-context/runtime.js +12 -14
- package/server/lib/project-context/runtime.test.js +78 -2
- package/server/lib/projects/project-config.js +30 -15
- package/server/lib/projects/project-config.test.js +30 -0
- package/server/lib/projects/project-setup.js +1 -2
- package/server/lib/projects/routes.js +1 -2
- package/server/lib/quota/DOCUMENTATION.md +35 -7
- package/server/lib/quota/index.js +1 -0
- package/server/lib/quota/providers/claude/index.js +1 -1
- package/server/lib/quota/providers/cline-pass.js +1 -1
- package/server/lib/quota/providers/exe-dev.js +1 -1
- package/server/lib/quota/providers/google/index.js +1 -1
- package/server/lib/quota/providers/hyper.js +1 -1
- package/server/lib/quota/providers/kimi.js +116 -36
- package/server/lib/quota/providers/kimi.test.js +128 -3
- package/server/lib/quota/providers/opencode-go.js +144 -21
- package/server/lib/quota/providers/opencode-go.test.js +229 -6
- package/server/lib/quota/providers/openrouter.js +1 -1
- package/server/lib/quota/providers/zenmux.js +1 -1
- package/server/lib/quota/utils/auth.js +1 -0
- package/server/lib/quota/utils/transformers.js +2 -6
- package/server/lib/relay/DOCUMENTATION.md +18 -3
- package/server/lib/relay/e2ee.js +7 -7
- package/server/lib/relay/host-client.js +84 -13
- package/server/lib/relay/host-client.test.js +201 -1
- package/server/lib/relay/identity.js +6 -29
- package/server/lib/relay/identity.test.js +18 -28
- package/server/lib/relay/key-store.js +141 -0
- package/server/lib/relay/key-store.test.js +138 -0
- package/server/lib/relay/service.js +8 -8
- package/server/lib/relay/service.test.js +10 -5
- package/server/lib/relay/signing-key.js +13 -36
- package/server/lib/relay/tunnel-codec.js +10 -10
- package/server/lib/route-module-exports.test.js +22 -0
- package/server/lib/routing/DOCUMENTATION.md +23 -3
- package/server/lib/routing/cache.js +87 -0
- package/server/lib/routing/defaults.js +11 -0
- package/server/lib/routing/history.js +12 -4
- package/server/lib/routing/runtime.js +39 -3
- package/server/lib/routing/runtime.test.js +81 -2
- package/server/lib/routing/store.js +12 -1
- package/server/lib/routing/store.test.js +13 -0
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +59 -1
- package/server/lib/scheduled-tasks/existing-session.js +119 -0
- package/server/lib/scheduled-tasks/existing-session.test.js +350 -0
- package/server/lib/scheduled-tasks/loops.js +1 -8
- package/server/lib/scheduled-tasks/routes.js +8 -8
- package/server/lib/scheduled-tasks/runtime.js +103 -13
- package/server/lib/scheduled-tasks/runtime.test.js +48 -0
- package/server/lib/scheduled-tasks/service.js +33 -11
- package/server/lib/scheduled-tasks/service.test.js +128 -2
- package/server/lib/scheduled-tasks/session-defaults.js +27 -0
- package/server/lib/scheduled-tasks/session-defaults.test.js +19 -0
- package/server/lib/session-assist/context.js +1 -0
- package/server/lib/session-folders/routes.js +2 -2
- package/server/lib/session-goal/objectives.js +1 -1
- package/server/lib/session-knowledge/routes.js +2 -2
- package/server/lib/session-knowledge/runtime.js +1 -2
- package/server/lib/session-work/DOCUMENTATION.md +39 -14
- package/server/lib/session-work/questions.js +31 -2
- package/server/lib/session-work/runtime.js +22 -13
- package/server/lib/session-work/runtime.test.js +43 -26
- package/server/lib/session-work/state.js +10 -4
- package/server/lib/session-work/state.test.js +8 -1
- package/server/lib/shared/DOCUMENTATION.md +89 -0
- package/server/lib/shared/guards.js +53 -0
- package/server/lib/shared/guards.test.js +112 -0
- package/server/lib/skills-catalog/DOCUMENTATION.md +10 -8
- package/server/lib/skills-catalog/cache.js +3 -2
- package/server/lib/skills-catalog/curated-sources.js +5 -1
- package/server/lib/skills-catalog/git.js +107 -20
- package/server/lib/skills-catalog/git.test.js +78 -0
- package/server/lib/skills-catalog/install.js +21 -12
- package/server/lib/skills-catalog/scan.js +25 -15
- package/server/lib/skills-catalog/source.js +26 -1
- package/server/lib/skills-catalog/source.test.js +27 -0
- package/server/lib/source-control/DOCUMENTATION.md +2 -1
- package/server/lib/source-control/audit-storage.js +7 -6
- package/server/lib/source-control/audit-storage.test.js +11 -0
- package/server/lib/source-control/binding-service.js +2 -5
- package/server/lib/source-control/change-request-worktree.js +90 -0
- package/server/lib/source-control/change-request-worktree.test.js +121 -0
- package/server/lib/source-control/mutation-executor.js +1 -1
- package/server/lib/source-control/mutation-storage.js +11 -5
- package/server/lib/source-control/provider-instance.js +1 -2
- package/server/lib/source-control/repository-identity.js +1 -1
- package/server/lib/source-control/routes.js +14 -2
- package/server/lib/spaces/DOCUMENTATION.md +42 -17
- package/server/lib/spaces/command-stream.test.js +15 -0
- package/server/lib/spaces/dispatcher.js +7 -0
- package/server/lib/spaces/dispatcher.test.js +17 -0
- package/server/lib/spaces/hardening.js +2 -2
- package/server/lib/spaces/hardening.test.js +1 -1
- package/server/lib/spaces/host.js +2 -0
- package/server/lib/spaces/journey.js +66 -5
- package/server/lib/spaces/journey.test.js +95 -4
- package/server/lib/spaces/layout.js +1 -1
- package/server/lib/spaces/places/docker-disk.js +38 -14
- package/server/lib/spaces/places/docker-disk.test.js +80 -1
- package/server/lib/spaces/places/docker.js +35 -11
- package/server/lib/spaces/places/fake-docker.js +22 -3
- package/server/lib/spaces/places/memory-place.js +3 -0
- package/server/lib/spaces/places/packed.docker.live.test.js +1 -1
- package/server/lib/spaces/routes.js +5 -0
- package/server/lib/spaces/routes.test.js +4 -2
- package/server/lib/spaces/run-command.js +9 -2
- package/server/lib/spaces/tools.js +4 -5
- package/server/lib/spaces/tools.test.js +2 -2
- package/server/lib/terminal/runtime.js +18 -6
- package/server/lib/terminal/runtime.test.js +66 -0
- package/server/lib/tts/index.js +3 -0
- package/server/lib/tts/service.js +4 -2
- package/server/lib/walkthrough/DOCUMENTATION.md +3 -1
- package/server/lib/walkthrough/index.js +2 -3
- package/server/lib/walkthrough/pr-source.test.js +22 -0
- package/server/lib/walkthrough/sources.js +6 -1
- package/server/opencode-proxy.test.js +127 -0
- package/bin/lib/commands-startup.test.js +0 -15
- package/dist/assets/CodeMirrorCommentWidgets-CVDSjcrP.js +0 -1
- package/dist/assets/DiffView-Ct7vL3fD.js +0 -4
- package/dist/assets/FilesView-DT0uEYgT.js +0 -17
- package/dist/assets/GuestSurfacePane-DVvk1VPu.js +0 -1
- package/dist/assets/LinearIssuesView-C10MwA9h.js +0 -1
- package/dist/assets/MarkdownImageGallery-BbN_K_3d.js +0 -1
- package/dist/assets/MarkdownRendererImpl-BLt2Tkk9.js +0 -10
- package/dist/assets/OnboardingScreen-Bgp5A3WB.js +0 -1
- package/dist/assets/PierreDiffViewer-CWJLj-S-.js +0 -210
- package/dist/assets/PlanView-DsRWnsOI.js +0 -5
- package/dist/assets/PublishDialog-CCeKloRu.js +0 -2
- package/dist/assets/SettingsView-BuPPsNPp.js +0 -30
- package/dist/assets/SettingsWindow-CM5fL8Ot.js +0 -1
- package/dist/assets/SubmoduleDiffSummary-CfsMcfiQ.js +0 -1
- package/dist/assets/ToolOutputDialog-mZrfSofz.js +0 -15
- package/dist/assets/ToolPartDiffPreview-BUGCRYEL.js +0 -8
- package/dist/assets/WalkthroughView-ClBo7PPd.js +0 -4
- package/dist/assets/appThemeRegistry-CxzMxR-H.js +0 -1
- package/dist/assets/de-CBla4hjd.js +0 -14
- package/dist/assets/es-BmnZtxTD.js +0 -20
- package/dist/assets/fileTreeStatus-BSHFIGEg.js +0 -1
- package/dist/assets/fr-OVKIBUZO.js +0 -18
- package/dist/assets/index-CKCFKmjF.js +0 -1
- package/dist/assets/index-Dbx4V4GN.css +0 -1
- package/dist/assets/index-vQ1Pg1cr.js +0 -61
- package/dist/assets/ja-6v-yr-gE.js +0 -20
- package/dist/assets/ko-I_ZLvgQ9.js +0 -20
- package/dist/assets/main-CmO4dRtR.js +0 -2
- package/dist/assets/main-b9vqhlYM.js +0 -999
- package/dist/assets/markdownCore-BPEZRQfP.js +0 -7
- package/dist/assets/miniChat-B5Oi7B-6.js +0 -2
- package/dist/assets/mobile-CVtShif9.js +0 -2
- package/dist/assets/nl-DcvIJf46.js +0 -20
- package/dist/assets/patchFileDiff-CW3wCH1O.js +0 -13
- package/dist/assets/pl-JxCUl0sd.js +0 -20
- package/dist/assets/pt-BR-L89mjja2.js +0 -20
- package/dist/assets/relocateRestoredSession-DYh_9oBa.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-BD-1JHSg.js +0 -2
- package/dist/assets/renderMobileApp-7s5InXt1.js +0 -25
- package/dist/assets/runtimeEndpointReset-DqLJC6L1.js +0 -53
- package/dist/assets/shikiHighlight-CXgZnvHh.js +0 -1
- package/dist/assets/space-apply-1trGVIl8.js +0 -1
- package/dist/assets/space-close-y7j-NuBv.js +0 -1
- package/dist/assets/tr-ka5J1flt.js +0 -11
- package/dist/assets/uk-PyGe6Q_u.js +0 -20
- package/dist/assets/useInlineCommentController-CrjSGCpi.js +0 -2
- package/dist/assets/vendor-codemirror-lang-python-B7ClrMIT.js +0 -3
- package/dist/assets/vendor-codemirror-lang-xml-C8tGnS64.js +0 -1
- package/dist/assets/vendor-codemirror-language-data-q2bKO1EM.js +0 -2
- package/dist/assets/vendor-framer-motion-Bq3iTZ6r.js +0 -1
- package/dist/assets/vendor-katex-CHD9BdDO.js +0 -257
- package/dist/assets/vendor-katex-Cp579UoJ.css +0 -1
- package/dist/assets/zh-CN-B0P2tybJ.js +0 -20
- package/dist/assets/zh-TW-Bs9C5cN8.js +0 -20
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesView-BVoD8I2x.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-DxNa7xYB.js","assets/vendor-zod-CxRSdNoV.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-BmFcUkbQ.js","assets/index-BkMXRrVQ.css","assets/useAppFontEffects-DGlvOqP_.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-base-ui-Det7U81h.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-tanstack-react-virtual-CvuLsk7D.js","assets/vendor-tanstack-virtual-core-DPaNcJcT.js","assets/vendor-framer-motion-DxDVhOLc.js","assets/vendor-motion-dom-HXPOMxb7.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-codemirror-commands-C4G_dPWe.js","assets/vendor-codemirror-state-Dek9sMtw.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-1e0FQ6Wn.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-codemirror-language-DufXoQvE.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-DbpEcZM0.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-BSHQHbKu.js","assets/vendor-codemirror-lang-json-BzgckzmB.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-Cayfb29q.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-BQWerHsJ.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-D2TEBIvZ.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-CtwSWKtX.js","assets/vendor-codemirror-lang-python-jAMtYiA9.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-legendapp-list-DViGR95I.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/shikiHighlight-DHDx-6eM.js","assets/vendor-codemirror-search-CvXM_pZg.js","assets/vendor-replit-codemirror-vim-BlJRn-cW.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/fileTreeStatus-D438yi8M.js","assets/JsonTreeView-DRKHZfsn.js","assets/parseDiffFromFile-BUgn-T9p.js","assets/computeVirtualFileMetrics-C2WM6JC2.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/vendor-diff-C3JhlQdm.js","assets/Virtualizer-CGNyscoc.js","assets/isFilePlainText-_ZS5UYRj.js","assets/appThemeRegistry-B9gkFq9i.js","assets/textMateThemeFromAppTheme-DlsTphbY.js","assets/runtimeEndpointReset-CZ5aafpl.js","assets/space-apply-DM_2pRW7.js","assets/vendor-cron-parser-CjvYVigk.js","assets/vendor-luxon-BZ0puJYg.js","assets/Virtualizer-C0IsclZn.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/useInlineCommentController-kMN4Wg_D.js","assets/FilePreviewCommentMenu-D4kLseHj.js","assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-capacitor-push-notifications-KNe1zSBF.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{f as me,r as vr,j as t,R as u,c as ys,h as Ma}from"./vendor-react-BUCujlKS.js";import"./vendor-katex-CuQvj9-L.js";import{u as Me,a as Qs,b as go,d as xi,i as He,e as St,s as fs,f as Hs,h as Pr,j as Oa,k as bo,l as za,m as Ba,n as La,p as Fa,o as $a,q as Wt,t as Zs,v as Wa,x as Va,y as as,z as cr,A as Ua,C as zs,B as yi,D as ur,E as Ga,G as vi,F as Ka,H as qa,I as wi,J as xo,K as ji,L as ki,M as Si,N as Sn}from"./index-DxNa7xYB.js";import{u as gs,a as Ha,b as ot,c as wr,d as yo,r as vo,e as Ja,f as ye,t as ce,o as Ya,I as q,B as ke,g as wo,O as ms,h as Q,P as jo,i as Xa,j as Qa,k as Za,l as ft,m as el,n as Jt,p as tl,q as Ni,s as sl,v as nl,w as Tr,x as rl,y as il,z as _e,A as ol,C as Dr,D as _r,E as Mr,F as al,S as Or,G as Mn,H as ko,J as ll,K as So,L as it,M as No,N as Un,Q as cl,R as ul,T as dl,U as fl,V as Pn,W as jr,X as $t,Y as ml,Z as Co,_ as Ro,$ as Eo,a0 as Io,a1 as Ao,a2 as Po,a3 as pl,a4 as hl,a5 as Ci,a6 as To,a7 as Do,a8 as _o,a9 as gl,aa as bl,ab as Mo,ac as xl,ad as yl,ae as vl,af as wl,ag as ls,ah as Ri,ai as Oo,aj as jl,ak as kl,al as Gn,am as Sl,an as zo,ao as Bo,ap as Nl,aq as Cl,ar as ds,as as bs,at as Rl,au as El,av as Il,aw as Al,ax as Pl,ay as zr,az as Tl,aA as Dl,aB as _l,aC as Ml,aD as Ol,aE as Lo,aF as zl,aG as Bl,aH as Ll,aI as Fl,aJ as $l,aK as Wl,aL as Vl,aM as Ul,aN as Gl,aO as Kl,aP as Ei,aQ as Nn,aR as ql,aS as Hl,aT as Jl,aU as Yl,aV as Xl,aW as Cn,aX as Ql,aY as Zl,aZ as ec,a_ as tc,a$ as sc,b0 as nc,b1 as Fo,b2 as qe,b3 as rc,b4 as ic,b5 as oc,b6 as ac,b7 as lc,b8 as cc,b9 as uc,ba as dc,bb as Br,bc as fc,bd as mc,be as pc,bf as hc,bg as $o,bh as gc,bi as bc,bj as xc,bk as yc,bl as vc,bm as wc,bn as jc,bo as kc,bp as Sc,bq as Nc,br as Cc,bs as Rc,bt as Ec,bu as Ic,bv as Ac,bw as Pc,bx as Tc,by as Dc,bz as _c,bA as Mc,bB as Oc,bC as zc,bD as Bc,bE as Lc,bF as Fc,bG as $c}from"./useAppFontEffects-DGlvOqP_.js";import{u as ps,a as Wc,S as Vc,r as Uc,h as Gc,b as Wo,c as Vo,C as Uo,d as Kc,s as qc,g as Rn,p as Hc,e as Jc,f as Ii,i as Yc,j as Xc,k as Qc,D as Zc,l as eu,m as tu,n as En,o as su,q as nu,t as ru,v as dr,P as iu,w as ou,x as au,B as lu,I as cu,y as uu,z as du,A as fu,G as mu,N as pu,E as hu,F as gu,H as bu,J as xu,K as yu,T as vu,L as wu,O as ju,M as ku,Q as Su,R as Nu,U as Cu,V as Ru,W as Eu,X as Iu,Y as Au,Z as Pu,_ as Tu,$ as Du,a0 as _u,a1 as Mu,a2 as Ou,a3 as zu,a4 as Bu,a5 as Lu,a6 as Fu,a7 as $u,a8 as Wu,a9 as Vu,aa as Uu,ab as Gu}from"./runtimeEndpointReset-CZ5aafpl.js";import{i as Ku}from"./initializeSharedPreferences-Bck5EAWP.js";import{_ as vs}from"./vendor-vite-runtime-DD1OZmLC.js";import{S as qu,A as Hu}from"./SettingsView-CjBjZFRO.js";import{PlanView as Ju}from"./PlanView-RCBadcY7.js";import{p as Yu}from"./vendor-aparajita-capacitor-secure-storage-5IShChL0.js";import{Capacitor as Xu,registerPlugin as Qu}from"./vendor-capacitor-core-B4EWRrHz.js";import{k as kr,d as Zu,M as On,J as Sr,s as Go,a as Lr,p as ed,_ as Ai,f as Fr,V as td,K as Pi,P as sd,b as nd,c as rd,U as id,Z as od,Q as ad,r as ld}from"./vendor-remixicon-react-D6dZ0UwF.js";import{f as $r,h as ws,i as Wr,P as Vr,D as Ur,j as Gr}from"./vendor-dnd-kit-core-BZknOX2w.js";import{s as Kr,S as qr,v as Hr,u as Jr}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Yr}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{c as cd}from"./sessionOwnership-BSuxCEhb.js";import{c as Xr,p as Ko}from"./vendor-zustand-BAGL70zf.js";import{toast as Nr}from"./vendor-sonner-DFyL3AvE.js";import{R as ud,I as dd,C as fd,a as md,b as pd,D as hd}from"./InProgressOperationBanner-CwMjNQgk.js";import{u as gd,a as bd,b as xd,c as yd,i as vd,f as Ti,B as wd,C as jd,P as Di}from"./patchFileDiff-Dt8LhgBh.js";import{u as kd,a as Sd,i as Nd,S as Cd,b as Rd}from"./SubmoduleDiffSummary-BWIfgMED.js";import{P as Ed}from"./PierreDiffViewer-CnnR-dnD.js";import{p as Id}from"./parseDiffFromFile-BUgn-T9p.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-CxRSdNoV.js";import"./vendor-opencode-client-BmFcUkbQ.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-base-ui-Det7U81h.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-tanstack-react-virtual-CvuLsk7D.js";import"./vendor-tanstack-virtual-core-DPaNcJcT.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-C4G_dPWe.js";import"./vendor-codemirror-state-Dek9sMtw.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-1e0FQ6Wn.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-language-DufXoQvE.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-DbpEcZM0.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BSHQHbKu.js";import"./vendor-codemirror-lang-json-BzgckzmB.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-Cayfb29q.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-BQWerHsJ.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-D2TEBIvZ.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CtwSWKtX.js";import"./vendor-codemirror-lang-python-jAMtYiA9.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-legendapp-list-DViGR95I.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./space-apply-DM_2pRW7.js";import"./vendor-cron-parser-CjvYVigk.js";import"./vendor-luxon-BZ0puJYg.js";import"./vendor-yaml-3778uTud.js";import"./shikiHighlight-DHDx-6eM.js";import"./vendor-codemirror-search-CvXM_pZg.js";import"./vendor-replit-codemirror-vim-BlJRn-cW.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./appThemeRegistry-B9gkFq9i.js";import"./textMateThemeFromAppTheme-DlsTphbY.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-qrcode-DTJ12-WC.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./vendor-strip-json-comments-5dJlOkP1.js";import"./useInlineCommentController-kMN4Wg_D.js";import"./FilePreviewCommentMenu-D4kLseHj.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./changesTree-CePHbFcj.js";import"./computeVirtualFileMetrics-C2WM6JC2.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-Dgbw8VKk.js";import"./vendor-diff-C3JhlQdm.js";import"./VirtualizedFileDiff-CFpjL8Ns.js";import"./Virtualizer-C0IsclZn.js";let qo=null,_i=!1;const Ad=new Promise(n=>{qo=n});function Pd(){_i||(_i=!0,qo?.())}const Td=6,Dd=n=>n.parentID??null,Mi=n=>{const e=n.replace(/\/+$/,"");return e.slice(e.lastIndexOf("/")+1)||e},_d=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),Md=(n,e)=>{if(!n)return"";let s=null,i=-1;for(const r of e){const o=_d(r.path);(n===o||n.startsWith(`${o}/`))&&o.length>i&&(s=r,i=o.length)}return s?s.label?.trim()||Mi(s.path):Mi(n)},Od=()=>{const n=gs.getState().activeSessions,e=Ha.getState().index.session.unseenCount,s=Me.getState().notifyOnSubtasks,i=ot.getState().projects,r=wr.getState().ids,o=yo.getState().rankById;let a=0;const l=[];for(const c of n){const m=Dd(c)!==null,p=(e[c.id]??0)>0&&(!m||s);p&&(a+=1),m||l.push({session:c,unread:p,project:Md(vo(c),i)})}l.sort((c,m)=>Ja(c.session,m.session,r,o));const f=l.slice(0,Td).map(({session:c,unread:m,project:g})=>({id:c.id,title:c.title??"",unread:m,project:g}));return{runtimeKey:Qs(),attentionCount:a,recentSessions:f}},zd="__OPENCHAMBER_WIDGET_SNAPSHOT__",Bd=()=>{typeof window>"u"||(window[zd]=()=>{try{return JSON.stringify(Od())}catch{return null}})},fr="mobile-app-update-available",Oi="mobile-app-update-toast-dismissed-version",Ld=()=>{const n=me.c(8),{t:e}=ye(),s=ps(Fd),i=ps($d),r=ps(Wd),o=ps(Vd);let a;n[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Set,n[0]=a):a=n[0];const l=vr.useRef(a);let f,c;return n[1]!==s||n[2]!==o||n[3]!==i||n[4]!==e||n[5]!==r?(f=()=>{if(go()!=="android"||i!=="mobile"||!s||!r||!o){ce.dismiss(fr);return}xi().getItem(Oi)!==r&&(l.current.has(r)||(l.current.add(r),ce.info(e("mobileUpdate.toast.available.title"),{id:fr,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:()=>{Ya(o)}},cancel:{label:e("mobileUpdate.toast.actions.dismiss"),onClick:()=>{xi().setItem(Oi,r),ce.dismiss(fr)}}})))},c=[s,o,i,e,r],n[1]=s,n[2]=o,n[3]=i,n[4]=e,n[5]=r,n[6]=f,n[7]=c):(f=n[6],c=n[7]),vr.useEffect(f,c),null};function Fd(n){return n.available}function $d(n){return n.runtimeType}function Wd(n){return n.info?.version}function Vd(n){return n.info?.downloadUrl}const zi=300,Ud="openchamber.mobile.connectLog.v1",hs=[];if(typeof window<"u")try{window.localStorage.removeItem(Ud)}catch{}const Qr=(n,e)=>{hs.push({at:Date.now(),step:n,detail:e}),hs.length>zi&&hs.splice(0,hs.length-zi)};typeof window<"u"&&Qr("app:launch","{}");const Gd=()=>[...hs],Kd=n=>{const e=new Date(n),s=(i,r=2)=>String(i).padStart(r,"0");return`${s(e.getHours())}:${s(e.getMinutes())}:${s(e.getSeconds())}.${s(e.getMilliseconds(),3)}`},Ho=n=>`${Kd(n.at)} ${n.step}${n.detail&&n.detail!=="{}"?` ${n.detail}`:""}`,qd=()=>hs.map(Ho).join(`
|
|
3
|
+
`),Jo=(n,e)=>{const s=me.c(10),i=700,r=u.useRef(null),o=u.useRef(null),a=u.useRef(!1);let l;s[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{r.current!==null&&window.clearTimeout(r.current),r.current=null,o.current=null},s[0]=l):l=s[0];const f=l;let c,m;s[1]===Symbol.for("react.memo_cache_sentinel")?(c=()=>f,m=[f],s[1]=c,s[2]=m):(c=s[1],m=s[2]),u.useEffect(c,m);let g;s[3]!==i||s[4]!==n?(g=N=>{a.current=!1,o.current={x:N.clientX,y:N.clientY},r.current!==null&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{r.current=null,a.current=!0,n()},i)},s[3]=i,s[4]=n,s[5]=g):g=s[5];const p=g;let h;s[6]===Symbol.for("react.memo_cache_sentinel")?(h=N=>{const A=o.current;A&&(Math.abs(N.clientX-A.x)>10||Math.abs(N.clientY-A.y)>10)&&f()},s[6]=h):h=s[6];const b=h;let k;s[7]===Symbol.for("react.memo_cache_sentinel")?(k=N=>{a.current&&(a.current=!1,N.preventDefault(),N.stopPropagation())},s[7]=k):k=s[7];const x=k;let R;return s[8]!==p?(R={onPointerDown:p,onPointerMove:b,onPointerUp:f,onPointerCancel:f,onClickCapture:x},s[8]=p,s[9]=R):R=s[9],R},Hd=async(n,e)=>{let s;const i=new Promise(r=>{s=setTimeout(()=>r({response:null,failure:"timeout"}),n)});try{return await Promise.race([e.then(r=>({response:r,failure:null}),r=>({response:null,failure:r instanceof Error?r.message:String(r)})),i])}finally{s!==void 0&&clearTimeout(s)}},Jd=(n,e)=>new Promise(s=>{const i=l=>{clearTimeout(o),a(),s(l)},r=l=>{l.state==="connected"?i(!0):(l.state==="idle"||l.terminal)&&i(!1)},o=setTimeout(()=>i(!1),e),a=n.subscribeStatus(r);r(n.getStatus())}),js=(n,e,s,i)=>Hd(i,n.fetch(e,s)),Yo=async(n,e,s,i)=>{const r=Date.now()+i;let o=await js(n,e,s,i);for(;!o.response&&o.failure!=="timeout"&&n.getStatus().state!=="connected";){const a=r-Date.now();if(a<=0||!await Jd(n,a))return o;const l=r-Date.now();if(l<=0)return o;o=await js(n,e,s,l)}return o},zn="openchamber.mobile.connections.v1",Yd="openchamber.mobile.",Bi="openchamber.mobile.deviceId",Xd=()=>{try{const n=window.localStorage.getItem(Bi);if(n&&n.trim())return n.trim();const e=crypto.randomUUID();return window.localStorage.setItem(Bi,e),e}catch{return crypto.randomUUID()}},Li=()=>`mobile:${Xd()}`,Fi=()=>{try{const n=Xu.getPlatform();return n==="ios"||n==="android"?n:void 0}catch{return}},Xo=12,Zr=8e3,Qd=2500,Zd=3e3,Bn=2500,ef=()=>{let n=0;return{begin:()=>(n+=1,n),cancel:()=>{n+=1},isCurrent:e=>e===n}},Cs=n=>{const e=n.trim();if(!e)return"";const s=/^https?:\/\//i.test(e)?e:`http://${e}`,i=new URL(s);return i.hash="",i.search="",i.pathname=i.pathname.replace(/\/+$/,""),i.toString().replace(/\/+$/,"")},Tn=n=>{try{return new URL(n).host}catch{return n}},ks=n=>{try{return Cs(n)}catch{return n.trim().replace(/\/+$/g,"")}},Qo=(n,e)=>ks(n)===ks(e),Zo=n=>`relay:${n.serverId}@${n.relayUrl.trim()}`,tf=n=>`relay://${n.serverId}`,Kn=n=>n.candidates.filter(e=>e.kind==="direct"),Qt=n=>{const e=n.candidates.find(s=>s.kind==="relay");return e&&e.kind==="relay"?e.relay:null},Dt=n=>{const e=Kn(n)[0];if(e)return e.url;const s=Qt(n);return s?tf(s):""},Ve=n=>{const e=Qt(n);if(e)return Zo(e);const s=Kn(n)[0];return s?ks(s.url):""},Ln=(n,e)=>{const s=n.find(o=>o.kind==="relay"),i=s&&s.kind==="relay"?s.relay.serverId:null,r=new Set(n.filter(o=>o.kind==="direct").map(o=>ks(o.url)));return e.some(o=>o.kind==="relay"?i!==null&&o.relay.serverId===i:r.has(ks(o.url)))},ei=n=>{const e=(()=>{try{return Cs(n)}catch{return""}})();return e?[{kind:"direct",url:e}]:[]},$i=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(...ei(n.url)),n.relay&&e.push({kind:"relay",relay:n.relay}),e},ti=n=>{if(!n||typeof n!="object"||Array.isArray(n))return null;const e=n;if(typeof e.relayUrl!="string"||!e.relayUrl.trim()||typeof e.serverId!="string"||!e.serverId.trim())return null;const s=e.hostEncPubJwk;if(!s||typeof s!="object"||Array.isArray(s))return null;const i=s;return i.kty!=="EC"||i.crv!=="P-256"||typeof i.x!="string"||!i.x||typeof i.y!="string"||!i.y?null:{relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:{kty:"EC",crv:"P-256",x:i.x,y:i.y}}},ea=n=>{try{return JSON.stringify(n)}catch{return String(n)}},Ne=(n,e={})=>{const s=ea(e);console.info("[mobile-connect]",n,s),Qr(n,s)},Bs=(n,e={})=>{Ne(n,e)},Ss=(n,e={})=>{const s=ea(e);console.info("[mobile-storage]",n,s),Qr(n,s)},sf=n=>{if(typeof n!="string")return n;try{return JSON.parse(n)}catch{return n}},nf=n=>{if(typeof n!="string")return n??void 0;try{return JSON.parse(n)}catch{return n}},rf=async(n,e)=>{if(!He())return null;try{const{CapacitorHttp:s}=await vs(async()=>{const{CapacitorHttp:o}=await import("./vendor-capacitor-core-B4EWRrHz.js");return{CapacitorHttp:o}},[]),i=Ba(n,new Headers(e?.headers)),r=await s.request({url:n,method:e?.method||"GET",headers:Object.fromEntries(i.entries()),data:nf(e?.body)});return{ok:r.status>=200&&r.status<300,status:r.status,source:"native-http",json:async()=>sf(r.data)}}catch(s){return Ne("native-http:failed",{url:n,error:s instanceof Error?s.message:String(s)}),null}},of=async(n,e)=>{const s=await fetch(n,e).catch(i=>(Ne("browser-fetch:failed",{url:n,error:i instanceof Error?i.message:String(i)}),null));return s?{ok:s.ok,status:s.status,source:"browser-fetch",json:()=>s.json()}:null},Fn=async(n,e,s)=>{let i;const r=new Promise(o=>{i=window.setTimeout(()=>{s?.(),o(null)},n)});try{return await Promise.race([e,r])}catch{return null}finally{i!==void 0&&window.clearTimeout(i)}},Zt=async(n,e,s)=>{const i=s?.totalTimeoutMs??Zr,r=Date.now(),o=await Fn(Math.min(Qd,i),rf(n,e));if(o)return o;const a=new AbortController,l=Math.max(500,i-(Date.now()-r));return Fn(l,of(n,{...e,signal:a.signal}),()=>a.abort())},qn=async n=>{if(!n)return null;const e=await n.json().catch(()=>null);if(!e||typeof e!="object")return null;const s=e;return{authenticated:typeof s.authenticated=="boolean"?s.authenticated:void 0,disabled:typeof s.disabled=="boolean"?s.disabled:void 0,scope:typeof s.scope=="string"?s.scope:void 0}},Ns=15e3,ta=n=>{n?.owned&&n.client.close()},Wi=async(n,e)=>{if(n.status===401)return e?"auth-failed":"needs-login";if(!n.ok&&n.status!==404)return"auth-failed";const s=await qn(n);return s&&s.disabled!==!0&&s.authenticated===!1?e?"auth-failed":"needs-login":"ok"},af=async(n,e,s,i=Ns,r)=>{const o=e?{Authorization:`Bearer ${e}`}:void 0,a=ra(n);if(a){const{response:f,failure:c}=await js(a,"/auth/session",{headers:o},i);if(Ne("relay:session",{shared:!0,ok:f?.ok===!0,status:f?.status??null,hasToken:!!e,error:c}),f){const m=await Wi(f,e);return m==="ok"&&r?.keepTunnel?{outcome:m,tunnel:{client:a,owned:!1}}:{outcome:m}}}const l=bo({relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk});try{const{response:f,failure:c}=await Yo(l,"/auth/session",{headers:o},i);Ne("relay:session",{shared:!1,ok:f?.ok===!0,status:f?.status??null,hasToken:!!e,error:c});const m=f?await Wi(f,e):"unreachable";return m==="ok"&&r?.keepTunnel?{outcome:m,tunnel:{client:l,owned:!0}}:(l.close(),{outcome:m})}catch(f){throw l.close(),f}},lf=(n,e,s,i,r)=>{const o=typeof window<"u"?window.location.origin:"",a={relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk,...s?{grant:s}:{}};r&&Oa(a,r),fs({apiBaseUrl:o,clientToken:e,runtimeKey:i??Zo(n),relay:a})},cf=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=ti(e.relay);return s?{kind:"relay",relay:s}:null}return null},uf=n=>{if(n.mode==="relay"){const e=ti(n.relay);return e?[{kind:"relay",relay:e}]:[]}return typeof n.url=="string"?ei(n.url):[]},es=()=>{if(typeof window>"u")return[];let n;try{n=JSON.parse(window.localStorage.getItem(zn)||"[]")}catch{return[]}if(!Array.isArray(n))return[];const e=He();return n.flatMap(s=>{if(!s||typeof s!="object")return[];const i=s;if(typeof i.id!="string")return[];const r=Array.isArray(i.candidates)?i.candidates.map(cf).filter(f=>!!f):uf(i);if(r.length===0)return[];const o=typeof i.clientToken=="string"&&i.clientToken.trim()?i.clientToken:void 0,a=typeof i.label=="string"&&i.label.trim()?i.label:Tn(Dt({candidates:r})),l={id:i.id,label:a,candidates:r,lastUsedAt:typeof i.lastUsedAt=="number"?i.lastUsedAt:0};return e?[{...l,hasToken:!!i.hasToken||!!o}]:[{...l,clientToken:o,hasToken:!!o}]}).sort((s,i)=>i.lastUsedAt-s.lastUsedAt)},Cr=n=>n.kind==="relay"?{kind:"relay",relay:{relayUrl:n.relay.relayUrl,serverId:n.relay.serverId,hostEncPubJwk:n.relay.hostEncPubJwk}}:{kind:"direct",url:n.url},si=n=>{if(typeof window>"u")return;const e=He(),s=n.slice(0,Xo).map(i=>{const r={id:i.id,label:i.label,candidates:i.candidates.map(Cr),lastUsedAt:i.lastUsedAt};return e?{...r,hasToken:!!(i.hasToken||i.clientToken)}:{...r,clientToken:i.clientToken}});try{window.localStorage.setItem(zn,JSON.stringify(s))}catch(i){console.warn("[mobile-storage] failed to persist connection metadata",i)}},sa=(n,e)=>{const s=n.find(o=>e.id&&o.id===e.id||Ln(o.candidates,e.candidates)),i=He(),r={id:e.id||s?.id||crypto.randomUUID(),label:e.label,candidates:e.candidates,lastUsedAt:Date.now(),...i?{hasToken:e.hasToken??(!!e.clientToken||s?.hasToken||!1)}:{clientToken:e.clientToken??s?.clientToken,hasToken:!!(e.clientToken??s?.clientToken)}};return[r,...n.filter(o=>o.id!==r.id&&!Ln(o.candidates,e.candidates))].slice(0,Xo)},ni=Yu,df=0,ri=n=>`${Yd}token.${encodeURIComponent(n)}`,ff=async(n,e)=>{let s;const i=new Promise(r=>{s=window.setTimeout(()=>r(e),Zd)});try{return await Promise.race([n.catch(()=>e),i])}finally{s!==void 0&&window.clearTimeout(s)}},ii=async(n,e,s)=>He()?ff(e().catch(i=>(console.warn(`[mobile-storage] ${n} failed`,i),s)),s):s,Js=async n=>{Ss("secure:read-start",{key:n});const e=await ii("secure:read",async()=>(await ni.internalGetItem({prefixedKey:ri(n),sync:!1})).data,null),s=typeof e=="string"&&e.trim()?e:void 0;return Ss("secure:read",{key:n,hasToken:!!s}),s},Yt=async(n,e)=>{Ss("secure:write-start",{key:n});const s=await ii("secure:write",async()=>(await ni.internalSetItem({prefixedKey:ri(n),data:e,sync:!1,access:df}),!0),!1);return Ss("secure:write",{key:n,ok:s}),s},mf=async n=>{await ii("secure:delete",async()=>(await ni.internalRemoveItem({prefixedKey:ri(n),sync:!1}),!0),!1)},pf=async(n,e)=>{let s=0,i=0;return{records:await Promise.all(n.map(async o=>{if(!o||typeof o!="object")return o;const a=o,l=typeof a.url=="string"?a.url:null,f=typeof a.clientToken=="string"?a.clientToken.trim():"";if(!l||!f)return o;if(!await e(l,f))return i+=1,o;s+=1;const{clientToken:c,...m}=a;return{...m,hasToken:!0}})),migrated:s,failed:i}},na=async()=>{if(typeof window>"u"||!He())return;let n;try{n=JSON.parse(window.localStorage.getItem(zn)||"[]")}catch{return}if(!Array.isArray(n))return;const e=n.filter(i=>!!i&&typeof i=="object"&&typeof i.url=="string"&&typeof i.clientToken=="string"&&!!i.clientToken.trim());if(e.length===0)return;Ss("secure:migrate-start",{count:e.length});const s=await pf(n,async(i,r)=>{const o=ks(i);return await Yt(o,r)?await Js(o)===r:!1});if(s.migrated>0)try{window.localStorage.setItem(zn,JSON.stringify(s.records))}catch(i){console.warn("[mobile-storage] failed to finalize secure token migration",i);return}Ss("secure:migrate-done",{migrated:s.migrated,failed:s.failed})},hf=async()=>(await na(),es()),$n=async n=>{const e=sa(es(),n);return si(e),He()&&n.clientToken&&await Yt(Ve({candidates:n.candidates}),n.clientToken),e},gf=async n=>{const e=es(),s=e.find(r=>r.id===n)??null,i=e.filter(r=>r.id!==n);return si(i),s&&He()&&await mf(Ve(s)),i},bf=1500,Wn=async(n,e,s)=>{const i=s?.fast?{totalTimeoutMs:Bn}:void 0,r=Qt({candidates:n})?.serverId??null,o=n.find(c=>c.kind==="relay")??null,a=n.filter(c=>c.kind==="direct"),l=async()=>{for(const c of a){const m=Cs(c.url)||c.url,g=e?{Authorization:`Bearer ${e}`}:void 0,p=await Zt(`${m}/health`,{method:"GET"},i);if(Ne("probe:direct:health",{url:m,ok:p?.ok===!0,status:p?.status??null,source:p?.source??null}),!p?.ok)continue;if(r){const x=await p.json().catch(()=>null),R=x&&typeof x=="object"?x.serverId:null;if(typeof R=="string"&&R&&R!==r){Ne("probe:server-id-mismatch",{url:m});continue}}const h=await Zt(`${m}/auth/session`,{method:"GET",credentials:e?"omit":"include",headers:g},i);if(Ne("probe:direct:session",{url:m,ok:h?.ok===!0,status:h?.status??null,source:h?.source??null,hasToken:!!e}),h?.status===401)return{status:"needs-login"};if(!h||!h.ok&&h.status!==404)continue;const b=await qn(h);if(b&&b.disabled!==!0&&b.authenticated===!1)return{status:"needs-login"};const k=b?.disabled===!0;return!e&&He()&&!k&&b?.scope!=="client"?{status:"needs-login"}:{status:"ok",transport:{kind:"direct",url:m}}}return{status:"unreachable"}},f=async()=>{if(!o)return{status:"unreachable"};const{outcome:c,tunnel:m}=await af(o.relay,e,void 0,s?.fast?Bn:Zr,{keepTunnel:!0});return c==="ok"?{status:"ok",transport:{kind:"relay",relay:o.relay,tunnel:m}}:c==="needs-login"||c==="auth-failed"?{status:"needs-login"}:{status:"unreachable"}};return o?a.length===0?f():new Promise(c=>{let m=!1,g=!1,p,h=null,b=null;const k=N=>{N?.status==="ok"&&N.transport.kind==="relay"&&ta(N.transport.tunnel)},x=N=>{m||(m=!0,c(N))},R=()=>{g||m||(p!==void 0&&(window.clearTimeout(p),p=void 0),f().then(N=>{if(b=N,m||g){k(N);return}if(N.status==="ok"||N.status==="needs-login"){x(N);return}h&&x(h)}))};l().then(N=>{if(h=N,!m){if(N.status==="ok"||N.status==="needs-login"){g=!0,p!==void 0&&window.clearTimeout(p),k(b),x(N);return}if(b){x(b);return}R()}}),p=window.setTimeout(R,bf)}):l()},Xt=(n,e,s)=>{oi=!1,n.kind==="relay"?lf(n.relay,e,s?.grant,s?.runtimeKey,n.tunnel?.client):fs({apiBaseUrl:n.url,clientToken:e,runtimeKey:s?.runtimeKey}),oa()},Ws=()=>{const n=es()[0];return n?.label?.trim()?n.label:null};let oi=!1;const xf=()=>{oi=!0},Ls=async n=>{if(oi)return Ne("auto-connect:suppressed",{}),{status:"no-candidate"};const e=n?.fast!==!1;await na();const s=es()[0];if(Ne("auto-connect:start",{hasCandidate:!!s,fast:e}),!s)return{status:"no-candidate"};let i;if(He()){if(s.hasToken&&(i=await Js(Ve(s)),!i))return{status:"no-candidate"}}else if(i=s.clientToken,!i&&s.hasToken)return{status:"no-candidate"};const r=await Wn(s.candidates,i,{fast:e});return Ne("auto-connect:probe",{status:r.status,candidates:s.candidates.map(o=>o.kind)}),r.status==="needs-login"?{status:"needs-login",label:s.label}:r.status!=="ok"?{status:"unreachable",label:s.label}:n?.skipIfConnected&&St()?(r.transport.kind==="relay"&&ta(r.transport.tunnel),Ne("auto-connect:superseded",{}),{status:"no-candidate"}):(await $n({id:s.id,label:s.label,candidates:s.candidates}),Xt(r.transport,i??null,{runtimeKey:Ve(s)}),{status:"connected"})},yf=async(n,e)=>{let s="";try{s=Cs(n.url)}catch{return!1}if(!s)return!1;const i=n.clientToken?.trim()||void 0,r=i?{Authorization:`Bearer ${i}`}:void 0,o=e?.fast?{totalTimeoutMs:Bn}:void 0;if(!(await Zt(`${s}/health`,{method:"GET",headers:r},o))?.ok)return!1;const l=await Zt(`${s}/auth/session`,{method:"GET",credentials:i?"omit":"include",headers:r},o);if(!l||!l.ok&&l.status!==404)return!1;const f=await qn(l);return!(f&&f.disabled!==!0&&f.authenticated===!1)},Vi=(n,e)=>{n?.kind==="relay"&&n.owned&&!e&&n.tunnel.close()},vf=(n,e)=>n.kty===e.kty&&n.crv===e.crv&&n.x===e.x&&n.y===e.y,ra=n=>{const e=La(),s=za();return!e||!s||e.getStatus().state!=="connected"?null:s.relayUrl===n.relayUrl&&s.serverId===n.serverId&&vf(s.hostEncPubJwk,n.hostEncPubJwk)?e:null},wf=n=>[...n].sort((e,s)=>{const i=(e.priority??100)-(s.priority??100);if(i!==0)return i;const r=o=>o.type==="relay"?2:o.url.startsWith("https://")?0:1;return r(e)-r(s)}).flatMap(e=>{if(e.type==="relay"){const s=ti({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk});return s?[{kind:"relay",relay:s}]:[]}return ei(e.url)}),Ui=async n=>{const e=Qt({candidates:n})?.serverId??null;for(const s of n){if(s.kind==="relay"){const o=ra(s.relay);if(o){const c=await js(o,"/health",void 0,Zr);if(Ne("establish:relay:health",{shared:!0,ok:c.response?.ok===!0,status:c.response?.status??null,error:c.failure}),c.response?.ok)return{kind:"relay",relay:s.relay,tunnel:o,owned:!1}}const a=bo(s.relay),{response:l,failure:f}=await Yo(a,"/health",void 0,Ns);if(Ne("establish:relay:health",{shared:!1,ok:l?.ok===!0,status:l?.status??null,error:f}),l?.ok)return{kind:"relay",relay:s.relay,tunnel:a,owned:!0};a.close();continue}const i=Cs(s.url)||s.url,r=await Zt(`${i}/health`,{method:"GET"});if(Ne("establish:direct:health",{ok:r?.ok===!0,status:r?.status??null}),!!r?.ok){if(e){const o=await r.json().catch(()=>null),a=o&&typeof o=="object"?o.serverId:null;if(typeof a=="string"&&a&&a!==e){Ne("establish:server-id-mismatch",{url:i});continue}}return{kind:"direct",url:i}}}return null},jf=async(n,e)=>{if(!Hs())return yf(n,e);const s=await Fn(e?.fast?Bn:Ns,Pr("/auth/session").then(r=>r).catch(()=>null));if(!s)return!0;if(s.status===401)return!1;if(!s.ok&&s.status!==404)return!0;const i=await qn(s);return!(i&&i.disabled!==!0&&i.authenticated===!1)},kf=n=>n.kind==="relay"?Hs():!Hs()&&Qo(n.url,St()),ia=()=>{const n=Qs();return n?es().find(e=>Ve(e)===n)??null:null},Gi=n=>{const e=Qs();return!!e&&Ve(n)===e},Dn=async n=>{const e=n?.fast!==!1,s=ia();if(!s)return Ne("reprobe:no-connection",{runtimeKey:!!Qs()}),"no-connection";let i;if(He()?i=s.hasToken?await Js(Ve(s)):void 0:i=s.clientToken,!i&&s.hasToken)return Ne("reprobe:no-token",{hasToken:!0}),"unreachable";Ne("reprobe:start",{candidates:s.candidates.map(c=>c.kind),fast:e,hasToken:!!i});const r=s.candidates.findIndex(c=>kf(c.kind==="relay"?{kind:"relay",relay:c.relay}:{kind:"direct",url:c.url})),o=r>=0?s.candidates.slice(0,r):s.candidates,a=await Wn(o,i,{fast:e});if(Ne("reprobe:better",{status:a.status,probed:o.length}),a.status==="ok")return await $n({id:s.id,label:s.label,candidates:s.candidates}),Xt(a.transport,i??null,{runtimeKey:Ve(s)}),"switched";if(a.status==="needs-login")return"needs-login";if(r>=0){const c=await jf({url:St(),clientToken:i},{fast:e});if(Ne("reprobe:current",{stillValid:c}),c)return oa(),"unchanged"}const l=r>=0?s.candidates.slice(r+1):[],f=await Wn(l,i,{fast:e});return Ne("reprobe:fallback",{status:f.status,probed:l.length}),f.status==="ok"?(await $n({id:s.id,label:s.label,candidates:s.candidates}),Xt(f.transport,i??null,{runtimeKey:Ve(s)}),"switched"):f.status==="needs-login"?"needs-login":"unreachable"},Sf=5e3;let mr=!1;const Nf=async()=>{if(mr)return"skipped";const n=ia();if(!n)return Ne("candidates:refresh-skip",{reason:"no-active-connection"}),"skipped";const e=Qt(n);if(!e)return Ne("candidates:refresh-skip",{reason:"no-relay-candidate"}),"skipped";mr=!0;try{const s=await Fn(Ns,Pr("/api/client-auth/connection/candidates").then(c=>c).catch(()=>null));if(!s?.ok)return Ne("candidates:refresh-skip",{reason:"fetch-failed",status:s?.status??null}),"skipped";const i=await s.json().catch(()=>null);if(!i||i.serverId!==e.serverId)return Ne("candidates:refresh-skip",{reason:"server-id-mismatch"}),"skipped";const r=Array.isArray(i.candidates)?i.candidates:[],o=[];for(const c of r){if(!c||typeof c!="object")continue;const m=c;if(!(m.type!=="lan"||typeof m.url!="string"))try{const g=Cs(m.url);g&&!o.includes(g)&&o.push(g)}catch{}}if(o.length===0)return Ne("candidates:refresh-skip",{reason:"no-lan-reported"}),"skipped";const a=Kn(n).filter(c=>c.url.startsWith("https://")),l=[...o.map(c=>({kind:"direct",url:c})),...a,{kind:"relay",relay:e}];return JSON.stringify(n.candidates.map(Cr))===JSON.stringify(l.map(Cr))?"unchanged":(Ne("candidates:refreshed",{lanCount:o.length}),await $n({id:n.id,label:n.label,candidates:l}),"updated")}finally{mr=!1}},oa=()=>{typeof window>"u"||window.setTimeout(()=>{(async()=>{const n=await Nf().catch(()=>"skipped");Ne("candidates:refresh-result",{result:n}),n==="updated"&&Hs()&&await Dn().catch(()=>null)})()},Sf)},aa=n=>{const{t:e}=ye(),[s,i]=u.useState(()=>es()),[r,o]=u.useState(null),[a,l]=u.useState(null),[f,c]=u.useState(null),m=u.useRef(s),g=u.useRef(null),p=u.useRef(ef()),h=u.useCallback(S=>{m.current=S,i(S)},[]),b=u.useCallback(S=>{g.current=S,o(S)},[]),k=u.useCallback(S=>{g.current===S&&(g.current=null,o(null))},[]);u.useEffect(()=>{let S=!1;return hf().then(w=>{S||h(w)}),()=>{S=!0}},[h]);const x=u.useCallback(S=>{const w=sa(m.current,S);return h(w),si(w),w},[h]),R=u.useCallback(async S=>{l(null),b("connect");try{const w=$i(S);if(w.length===0){l(e("mobile.connect.error.urlRequired"));return}const C=S.id?m.current.find(W=>W.id===S.id):m.current.find(W=>Ln(W.candidates,w)),O=S.label?.trim()||C?.label||Tn(Dt({candidates:w})),z=S.relayGrant;let B=S.clientToken?.trim()||void 0;const T=!!B;B||(He()?C?.hasToken&&(B=await Js(Ve({candidates:w}))):B=C?.clientToken),Ne("connect:start",{candidates:w.map(W=>W.kind),hasToken:!!B});const P=await Wn(w,B);if(Ne("connect:probe",{status:P.status}),P.status==="unreachable"){l(e("mobile.connect.error.unreachable"));return}if(P.status==="needs-login"){x({id:C?.id,label:O,candidates:w}),c({id:C?.id??crypto.randomUUID(),label:O,candidates:w,relay:Qt({candidates:w})??void 0,relayGrant:z});return}B&&T&&He()&&await Yt(Ve({candidates:w}),B),x({id:C?.id,label:O,candidates:w,clientToken:B}),Xt(P.transport,B??null,{runtimeKey:Ve({candidates:w}),grant:z}),n()}catch(w){console.warn("[mobile-connect] connect threw",w),l(e("mobile.connect.error.invalidUrl"))}finally{k("connect")}},[b,k,n,x,e]),N=u.useCallback(async S=>{if(g.current==="pairing")return;l(null),b("pairing");const w=wf(S.candidates);let C=null,O=!1;try{if(C=await Ui(w),!C){l(e("mobile.connect.error.unreachable"));return}const z=JSON.stringify({pairingId:S.pairingId,secret:S.secret,clientLabel:"OpenChamber Mobile",clientKind:"mobile",deviceName:"OpenChamber Mobile",devicePlatform:Fi(),dedupeKey:Li()}),B={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:z},T=C.kind==="relay"?await js(C.tunnel,"/api/client-auth/pairing/redeem",B,Ns):{response:await Zt(`${C.url}/api/client-auth/pairing/redeem`,B),failure:null},P=T.response;if(Ne("pairing:redeem",{transport:C.kind,ok:P?.ok===!0,status:P?.status??null,error:T.failure}),!P?.ok){l(e("mobile.connect.error.authRequired"));return}const W=await P.json().catch(()=>null),I=typeof W?.clientToken=="string"?W.clientToken.trim():"";if(!I){l(e("mobile.connect.error.authRequired"));return}const _=typeof W?.server?.label=="string"?W.server.label:"",F=S.label||_||Tn(Dt({candidates:w}));if(He()&&!await Yt(Ve({candidates:w}),I)){l(e("mobile.connect.error.authRequired"));return}x({label:F,candidates:w,clientToken:I}),Xt(C.kind==="relay"?{kind:"relay",relay:C.relay,tunnel:{client:C.tunnel,owned:C.owned}}:{kind:"direct",url:C.url},I,{runtimeKey:Ve({candidates:w})}),O=C.kind==="relay",n()}catch(z){console.warn("[mobile-connect] pairing threw",z),l(e("mobile.connect.error.authRequired"))}finally{Vi(C,O),k("pairing")}},[b,k,n,x,e]),A=u.useCallback(async S=>{if(!f||!S.trim()||g.current==="password")return;l(null),b("password");const w=p.current.begin(),C=()=>p.current.isCurrent(w),{id:O,label:z,candidates:B}=f;let T=null,P=!1;try{if(T=await Ui(B),!C())return;if(!T){l(e("mobile.connect.error.unreachable"));return}const W={method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({password:S,trustDevice:!0,issueClientToken:!0,clientLabel:"OpenChamber Mobile",clientKind:"mobile",devicePlatform:Fi(),dedupeKey:Li()})};Ne("password:start",{transport:T.kind});const I=T.kind==="relay"?await js(T.tunnel,"/auth/session",W,Ns):{response:await Zt(`${T.url}/auth/session`,W),failure:null},_=I.response;if(!C())return;if(Ne("password:done",{ok:_?.ok===!0,status:_?.status??null,error:I.failure}),!_?.ok){l(e("mobile.connect.error.passwordFailed"));return}const F=await _.json().catch(()=>null);if(!C())return;const M=typeof F?.clientToken=="string"?F.clientToken.trim():"";if(Ne("password:token",{issued:!!M}),!M){if(T.kind==="direct"&&!He()){x({id:O,label:z,candidates:B}),c(null),Xt({kind:"direct",url:T.url},null,{runtimeKey:Ve({candidates:B})}),n();return}l(e("mobile.connect.error.authRequired"));return}if(He()&&(!C()||(await Yt(Ve({candidates:B}),M),!C()))||!C()||(x({id:O,label:z,candidates:B,clientToken:M}),c(null),Xt(T.kind==="relay"?{kind:"relay",relay:T.relay,tunnel:{client:T.tunnel,owned:T.owned}}:{kind:"direct",url:T.url},M,{runtimeKey:Ve({candidates:B})}),P=T.kind==="relay",!C()))return;n()}catch(W){if(!C())return;console.warn("[mobile-connect] password threw",W),l(e("mobile.connect.error.passwordFailed"))}finally{Vi(T,P),C()&&k("password")}},[b,k,n,f,x,e]),E=u.useCallback(()=>{p.current.cancel(),k("password"),c(null),l(null)},[k]),j=u.useCallback(async S=>{l(null);let w=$i(S);const C=S.id?m.current.find(T=>T.id===S.id)??null:null;if(C){const T=w.filter(I=>I.kind==="direct"),P=Kn(C).filter(I=>I.url.startsWith("https://")&&!T.some(_=>Qo(_.url,I.url))),W=Qt(C);w=[...T,...P,...W?[{kind:"relay",relay:W}]:[]]}if(w.length===0)return l(e("mobile.connect.error.urlRequired")),null;const O=S.clientToken?.trim()||void 0,z=S.label?.trim()||Tn(Dt({candidates:w}));if(He()){const T=Ve({candidates:w});if(O)await Yt(T,O);else if(C?.hasToken){const P=Ve(C);if(P&&T&&P!==T){const W=await Js(P);W&&await Yt(T,W)}}}return x({id:S.id,label:z,candidates:w,clientToken:O}).find(T=>Ln(T.candidates,w))??null},[x,e]),v=u.useCallback(async S=>{const w=m.current.find(O=>O.id===S)??null,C=await gf(S);return h(C),w},[h]);return{connections:s,isBusy:r!==null,isPasswordBusy:r==="password",error:a,pendingConnection:f,connect:R,redeemPairingConnection:N,submitPassword:A,cancelPassword:E,saveConnection:j,removeConnection:v,setError:l}},la=n=>{const e=me.c(31),{onClose:s}=n,{t:i}=ye(),[r,o]=u.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=Gd(),e[0]=a):a=e[0];const l=a;let f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{wo(qd()).then(S=>{S.ok&&(o(!0),window.setTimeout(()=>o(!1),2e3))})},e[1]=f):f=e[1];const c=f;let m;e[2]!==i?(m=i("mobile.connectionDebug.title"),e[2]=i,e[3]=m):m=e[3];let g;e[4]!==m?(g=t.jsx("h2",{className:"min-w-0 truncate typography-ui-label text-foreground",children:m}),e[4]=m,e[5]=g):g=e[5];const p=r?"check":"file-copy";let h;e[6]!==p?(h=t.jsx(q,{name:p,className:"size-4"}),e[6]=p,e[7]=h):h=e[7];let b;e[8]!==r||e[9]!==i?(b=i(r?"mobile.connectionDebug.copied":"mobile.connectionDebug.copy"),e[8]=r,e[9]=i,e[10]=b):b=e[10];let k;e[11]!==h||e[12]!==b?(k=t.jsxs(ke,{type:"button",variant:"outline",size:"sm",onClick:c,disabled:l.length===0,children:[h,b]}),e[11]=h,e[12]=b,e[13]=k):k=e[13];let x;e[14]!==i?(x=i("mobile.connectionDebug.close"),e[14]=i,e[15]=x):x=e[15];let R;e[16]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx(q,{name:"close",className:"size-[18px]"}),e[16]=R):R=e[16];let N;e[17]!==s||e[18]!==x?(N=t.jsx(ke,{type:"button",variant:"ghost",size:"icon","aria-label":x,onClick:s,children:R}),e[17]=s,e[18]=x,e[19]=N):N=e[19];let A;e[20]!==N||e[21]!==k?(A=t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[k,N]}),e[20]=N,e[21]=k,e[22]=A):A=e[22];let E;e[23]!==A||e[24]!==g?(E=t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border/70 px-4 py-2.5",children:[g,A]}),e[23]=A,e[24]=g,e[25]=E):E=e[25];let j;e[26]!==i?(j=t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 py-3",children:l.length===0?t.jsx("p",{className:"typography-small text-muted-foreground",children:i("mobile.connectionDebug.empty")}):t.jsx("pre",{className:"whitespace-pre-wrap break-words typography-code text-muted-foreground",children:l.map(Ho).join(`
|
|
4
|
+
`)})}),e[26]=i,e[27]=j):j=e[27];let v;return e[28]!==E||e[29]!==j?(v=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:[E,j]}),e[28]=E,e[29]=j,e[30]=v):v=e[30],v},ca=()=>{if(typeof window>"u")return null;const e=window.Capacitor?.Plugins?.BarcodeScanner;return e&&(typeof e.scan=="function"||typeof e.startScan=="function")?e:null},Cf=()=>window.Capacitor?.getPlatform?.()==="android",ua=n=>{const e=n.trim();if(!e)return null;if(/^openchamber:\/\//i.test(e)){const s=Fa(e);return s?{pairing:s}:null}return/^https?:\/\//i.test(e)?{url:e}:null},da=(n,e)=>{const s=ua(n);if(!s&&e?.pairingStringFallback){const i=$a(n);if(i)return{status:"pairing",pairing:i}}return s?"pairing"in s?{status:"pairing",...s}:{status:"ok",...s}:{status:"invalid"}},Rf=async(n,e)=>{if(!n.startScan||!n.stopScan||!n.addListener)return{status:"unsupported"};if(e?.aborted)return{status:"cancelled"};let s,i,r=!1,o=()=>{};const a=new Promise(c=>{o=c}),l=c=>{r||(r=!0,o(c))},f=()=>l({status:"cancelled"});e?.addEventListener("abort",f,{once:!0});try{return(await Promise.allSettled([Promise.resolve(n.addListener("barcodesScanned",({barcodes:m})=>{const g=m?.[0],p=(g?.rawValue??g?.displayValue??"").trim();p&&l(da(p,{pairingStringFallback:!0}))})).then(m=>{s=m}),Promise.resolve(n.addListener("scanError",()=>l({status:"failed"}))).then(m=>{i=m})])).some(({status:m})=>m==="rejected")?l({status:"failed"}):r||n.startScan({formats:["QR_CODE"]}).catch(()=>l({status:"failed"})),await a}finally{e?.removeEventListener("abort",f),await Promise.allSettled([Promise.resolve(s?.remove()),Promise.resolve(i?.remove()),n.stopScan()])}},Rr=()=>ca()!==null,fa=async n=>{const e=ca();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(Cf())return Rf(e,n?.signal);if(!e.scan)return{status:"unsupported"};const i=(await e.scan({formats:["QR_CODE"]}))?.barcodes?.[0],r=(i?.rawValue??i?.displayValue??"").trim();return r?da(r):{status:"cancelled"}}catch{return{status:"failed"}}},xs={autoComplete:"off",autoCorrect:"off",spellCheck:!1},Vs="oc-surface-elevated h-12 w-full rounded-[16px] border border-border/70 bg-surface-elevated px-4 text-[16px] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-interactive-border-focus focus:ring-2 focus:ring-ring",ma=n=>{const e=me.c(22),{onCancel:s}=n,{t:i}=ye(),r=u.useRef(null);let o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{const R={value:document.documentElement.style.getPropertyValue("background-color"),priority:document.documentElement.style.getPropertyPriority("background-color")},N={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 A=new Map,E=v=>{!(v instanceof HTMLElement)||v===r.current||A.has(v)||(A.set(v,{opacity:v.style.opacity,pointerEvents:v.style.pointerEvents}),v.style.setProperty("opacity","0"),v.style.setProperty("pointer-events","none"))};Array.from(document.body.children).forEach(E);const j=new MutationObserver(v=>{v.forEach(S=>S.addedNodes.forEach(E))});return j.observe(document.body,{childList:!0}),()=>{j.disconnect(),A.forEach(Ef),R.value?document.documentElement.style.setProperty("background-color",R.value,R.priority):document.documentElement.style.removeProperty("background-color"),N.value?document.body.style.setProperty("background-color",N.value,N.priority):document.body.style.removeProperty("background-color")}},a=[],e[0]=o,e[1]=a):(o=e[0],a=e[1]),u.useLayoutEffect(o,a);let l,f;e[2]!==s?(l=()=>{const R=()=>{document.visibilityState==="hidden"&&s()};return document.addEventListener("visibilitychange",R),()=>document.removeEventListener("visibilitychange",R)},f=[s],e[2]=s,e[3]=l,e[4]=f):(l=e[3],f=e[4]),u.useEffect(l,f);let c;e[5]!==i?(c=i("mobile.connect.scanQr"),e[5]=i,e[6]=c):c=e[6];let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=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]=m):m=e[7];let g;e[8]!==i?(g=i("mobile.connect.welcome.scanHint"),e[8]=i,e[9]=g):g=e[9];let p;e[10]!==g?(p=t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-6",children:[m,t.jsx("p",{className:"max-w-sm rounded-[16px] border border-border/60 bg-background px-4 py-3 text-center typography-body text-foreground shadow-sm",children:g})]}),e[10]=g,e[11]=p):p=e[11];let h;e[12]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(q,{name:"close",className:"size-[18px]"}),e[12]=h):h=e[12];let b;e[13]!==i?(b=i("mobile.instances.cancelEdit"),e[13]=i,e[14]=b):b=e[14];let k;e[15]!==s||e[16]!==b?(k=t.jsxs(ke,{type:"button",variant:"outline",size:"lg",className:"mx-auto min-h-12 w-full max-w-sm bg-background",onClick:s,children:[h,b]}),e[15]=s,e[16]=b,e[17]=k):k=e[17];let x;return e[18]!==k||e[19]!==c||e[20]!==p?(x=ys.createPortal(t.jsxs("div",{ref:r,role:"dialog","aria-modal":"true","aria-label":c,className:"fixed inset-0 z-[1000] flex flex-col bg-transparent px-6 pb-[calc(var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))+24px)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+24px)] text-foreground",children:[p,k]}),document.body),e[18]=k,e[19]=c,e[20]=p,e[21]=x):x=e[21],x},pa=()=>{const n=me.c(6),{t:e}=ye();let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx(ms,{width:96,height:96,isAnimated:!0}),n[0]=s):s=n[0];let i;n[1]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(q,{name:"loader-4",className:"size-[18px] animate-spin"}),n[1]=i):i=n[1];let r;n[2]!==e?(r=e("mobile.connect.connecting"),n[2]=e,n[3]=r):r=n[3];let o;return n[4]!==r?(o=ys.createPortal(t.jsxs("div",{role:"status",className:"fixed inset-0 z-[1000] flex flex-col items-center justify-center gap-5 bg-background px-6 text-foreground",children:[s,t.jsxs("div",{className:"flex items-center gap-2 typography-ui-label text-muted-foreground",children:[i,t.jsx("span",{children:r})]})]}),document.body),n[4]=r,n[5]=o):o=n[5],o};function Ef(n,e){e.style.opacity=n.opacity,e.style.pointerEvents=n.pointerEvents}const If=({onConnected:n,notice:e=null})=>{const{t:s}=ye(),i=aa(n),{connections:r,isBusy:o,isPasswordBusy:a,error:l,pendingConnection:f}=i,[c,m]=u.useState(""),[g,p]=u.useState(""),[h,b]=u.useState(""),[k,x]=u.useState(!1),[R,N]=u.useState(!1),A=u.useRef(null),E=u.useMemo(()=>Rr(),[]),[j,v]=u.useState(()=>!Rr()),[S,w]=u.useState(null),[C,O]=u.useState(""),[z,B]=u.useState(!1),T=Jo(u.useCallback(()=>B(!0),[])),P=u.useCallback(M=>{M.preventDefault(),i.connect({url:c,clientToken:h,label:g})},[h,i,g,c]),W=u.useCallback(M=>{if(/^openchamber:\/\//i.test(M.trim())){const K=ua(M);if(K){if("pairing"in K){i.redeemPairingConnection(K.pairing);return}m(K.url),K.label&&p(K.label),K.clientToken&&b(K.clientToken);return}}m(M)},[i]),I=u.useCallback(async()=>{if(A.current||o)return;i.setError(null),x(!0);const M=new AbortController;A.current=M;try{const K=await fa({signal:M.signal});switch(A.current===M&&(A.current=null,x(!1)),K.status){case"ok":N(!0),m(K.url),K.label&&p(K.label),K.clientToken&&b(K.clientToken),await i.connect({url:K.url,clientToken:K.clientToken,label:K.label});break;case"pairing":N(!0),await i.redeemPairingConnection(K.pairing);break;case"permission-denied":i.setError(s("mobile.connect.scan.permissionDenied"));break;case"invalid":i.setError(s("mobile.connect.scan.invalid"));break;case"unsupported":i.setError(s("mobile.connect.scan.unsupported"));break;case"failed":i.setError(s("mobile.connect.scan.failed"));break;default:break}}finally{N(!1),A.current===M&&(A.current=null,x(!1))}},[i,o,s]);u.useEffect(()=>()=>A.current?.abort(),[]);const _=u.useCallback(M=>{M.preventDefault(),i.submitPassword(C)},[i,C]),F=u.useCallback(()=>{O(""),i.cancelPassword()},[i]);return t.jsxs(t.Fragment,{children:[k?t.jsx(ma,{onCancel:()=>A.current?.abort()}):null,R?t.jsx(pa,{}):null,z?t.jsx(la,{onClose:()=>B(!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",{...T,className:"select-none",style:{touchAction:"manipulation"},children:t.jsx(ms,{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:_,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(M=>M.kind==="direct")?Dt(f):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...xs,value:C,onChange:M=>O(M.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:Vs}),l?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):null,t.jsx(ke,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:a||!C.trim(),children:s(a?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(ke,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:F,children:s("mobile.connect.cancelPassword")})]}):t.jsxs("div",{className:"flex w-full flex-col gap-6",children:[E?t.jsxs("div",{className:"flex w-full flex-col gap-2",children:[t.jsxs(ke,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{I()},disabled:k||o,children:[t.jsx(q,{name:"scan-2",className:Q("size-[18px]",k&&"animate-pulse")}),s(o?"mobile.connect.connecting":"mobile.connect.scanQr")]}),t.jsx("p",{className:"px-2 text-center typography-small text-muted-foreground",children:s("mobile.connect.welcome.scanHint")})]}):null,l&&!j?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):null,r.length>0?t.jsxs("section",{className:"flex w-full flex-col gap-2.5",children:[t.jsx("h2",{className:"text-center typography-micro uppercase tracking-[0.14em] text-muted-foreground",children:s("mobile.connect.saved.title")}),t.jsx("div",{className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map(M=>{const K=S===M.id;return t.jsxs("button",{type:"button",disabled:o,className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3.5 py-2.5 text-left last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:opacity-70",onClick:()=>{w(M.id),i.connect({id:M.id,candidates:M.candidates,clientToken:M.clientToken,label:M.label}).finally(()=>w(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:M.label}),t.jsx("span",{className:Q("block truncate typography-small",K?"text-foreground":"text-muted-foreground"),children:K?s("mobile.connect.connecting"):M.candidates.some(X=>X.kind==="direct")?Dt(M):s("mobile.connect.relay.badge")})]}),K?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"})]},M.id)})})]}):null,t.jsxs("div",{className:"flex w-full flex-col",children:[E?t.jsxs("button",{type:"button",onClick:()=>v(M=>!M),"aria-expanded":j,className:"mx-auto flex items-center gap-1 rounded-full px-2 py-1 typography-small text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[t.jsx("span",{children:s("mobile.connect.manual.toggle")}),t.jsx(q,{name:"arrow-down-s",className:Q("size-4 transition-transform duration-200",j&&"rotate-180")})]}):null,t.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:j?"1fr":"0fr"},children:t.jsx("div",{className:"min-h-0 overflow-hidden",children:t.jsxs("form",{className:"flex w-full flex-col gap-3 pt-3",onSubmit:P,children:[t.jsx("input",{...xs,value:c,onChange:M=>W(M.target.value),placeholder:s("mobile.connect.url.placeholder"),"aria-label":s("mobile.connect.url.label"),type:"url",inputMode:"url",autoCapitalize:"none",tabIndex:j?void 0:-1,className:Q(Vs,"text-center")}),t.jsx("input",{value:g,onChange:M=>p(M.target.value),placeholder:s("mobile.instances.label.placeholder"),"aria-label":s("mobile.instances.label.label"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,tabIndex:j?void 0:-1,className:Q(Vs,"text-center")}),t.jsx("input",{...xs,value:h,onChange:M=>b(M.target.value),placeholder:s("mobile.connect.token.placeholder"),"aria-label":s("mobile.connect.token.label"),tabIndex:j?void 0:-1,autoCapitalize:"none",className:Q(Vs,"text-center")}),t.jsx("p",{className:"px-1 text-center typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")}),l?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):null,t.jsx(ke,{type:"submit",variant:E?"outline":"default",size:"lg",className:"h-12 w-full",disabled:o||k||!c.trim(),children:s(o?"mobile.connect.connecting":"mobile.connect.connectButton")})]})})})]})]})]})})]})},Af=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"},Pf=n=>{const e=me.c(12),{groups:s,displayMode:i,timeFormatPreference:r,className:o}=n;let a;e[0]!==o?(a=Q("space-y-1.5",o),e[0]=o,e[1]=a):a=e[1];let l;if(e[2]!==i||e[3]!==s||e[4]!==r){let c;e[6]!==i||e[7]!==r?(c=m=>t.jsxs("div",{className:"min-w-0 rounded-xl bg-foreground/[0.03] p-2.5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(jo,{providerId:m.providerId,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground",children:m.providerName}),m.planLabel?t.jsx("span",{className:"shrink-0 typography-micro capitalize text-muted-foreground",children:m.planLabel}):null,m.status&&m.rows.length===0?t.jsx("span",{className:"shrink-0 truncate typography-micro text-muted-foreground",children:m.status}):null]}),m.rows.length>0?t.jsx("div",{className:"mt-1.5 space-y-1",children:m.rows.map(g=>{const p=i==="remaining"?g.window.remainingPercent:g.window.usedPercent,h=Xa(g.window.valueLabel,p),b=Qa(g.window.resetAt,g.window.resetAfterFormatted??g.window.resetAtFormatted,r);return t.jsxs("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"shrink-0 truncate typography-ui-label text-muted-foreground",children:g.subtitle?`${g.subtitle} · ${g.label}`:g.label}),b?t.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/70",children:b}):null]}),t.jsx("span",{className:Q("shrink-0 typography-ui-label font-semibold tabular-nums",Af(g.window)),children:h==="-"?"":h})]},g.key)})}):null,m.status&&m.rows.length>0?t.jsx("div",{className:"mt-1.5 typography-micro text-muted-foreground",children:m.status}):null]},m.providerId),e[6]=i,e[7]=r,e[8]=c):c=e[8],l=s.map(c),e[2]=i,e[3]=s,e[4]=r,e[5]=l}else l=e[5];let f;return e[9]!==a||e[10]!==l?(f=t.jsx("div",{className:a,children:l}),e[9]=a,e[10]=l,e[11]=f):f=e[11],f},Ki=380,Tf=(n,e)=>{if(!n||typeof n!="object")return;const s=n[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0},pr=n=>n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:String(n),Df="—",ha=n=>{const e=me.c(20),{percentage:s}=n;let i,r,o,a,l,f,c;if(e[0]!==s){o=rl(s??0)??0;const h=il(s??0);r=h==="critical"?"var(--status-error)":h==="warn"?"var(--status-warning)":"var(--status-success)",i=2*Math.PI*7.5,a="0 0 18 18",l="size-[18px] -rotate-90",f="progressbar",c=s===null?void 0:Math.round(o),e[0]=s,e[1]=i,e[2]=r,e[3]=o,e[4]=a,e[5]=l,e[6]=f,e[7]=c}else i=e[1],r=e[2],o=e[3],a=e[4],l=e[5],f=e[6],c=e[7];let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),e[8]=m):m=e[8];let g;e[9]!==i||e[10]!==s||e[11]!==r||e[12]!==o?(g=s===null?null:t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:r,strokeWidth:3,strokeLinecap:"round",strokeDasharray:i,strokeDashoffset:i*(1-o/100),className:"transition-[stroke-dashoffset,stroke] duration-300"}),e[9]=i,e[10]=s,e[11]=r,e[12]=o,e[13]=g):g=e[13];let p;return e[14]!==a||e[15]!==l||e[16]!==f||e[17]!==c||e[18]!==g?(p=t.jsxs("svg",{viewBox:a,className:l,role:f,"aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":100,children:[m,g]}),e[14]=a,e[15]=l,e[16]=f,e[17]=c,e[18]=g,e[19]=p):p=e[19],p},_f=n=>{const e=me.c(13),{icon:s,iconNode:i,label:r,children:o}=n;let a;e[0]!==s||e[1]!==i?(a=i??(s?t.jsx(q,{name:s,className:"size-[18px]"}):null),e[0]=s,e[1]=i,e[2]=a):a=e[2];let l;e[3]!==a?(l=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:a}),e[3]=a,e[4]=l):l=e[4];let 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 c;e[7]!==o?(c=t.jsx("span",{className:"min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground",children:o}),e[7]=o,e[8]=c):c=e[8];let m;return e[9]!==l||e[10]!==f||e[11]!==c?(m=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5",children:[l,f,c]}),e[9]=l,e[10]=f,e[11]=c,e[12]=m):m=e[12],m},Mf=n=>{const e=me.c(57),{open:s,onClose:i,anchorRef:r,contextDisplay:o,usageGroups:a,usageDisplayMode:l,isUsageLoading:f,timeFormatPreference:c}=n,{t:m}=ye(),g=u.useRef(null),[p,h]=u.useState(s),[b,k]=u.useState(!1),{enabled:x}=Tr(),R=u.useRef(null),[N,A]=u.useState(null);let E,j;e[0]!==r||e[1]!==x||e[2]!==s||e[3]!==p?(E=()=>{if(!s||!x||!p)return;const $=()=>{const te=r.current?.getBoundingClientRect(),ie=R.current?.getBoundingClientRect();if(!te||!ie){A(null);return}const G=te.left-ie.left,oe=Math.min(Math.max(G,8),Math.max(8,ie.width-Ki-8));A(oe)};$();const D=R.current;if(typeof ResizeObserver>"u"||!D)return;const se=new ResizeObserver($);return se.observe(D),()=>se.disconnect()},j=[r,x,s,p],e[0]=r,e[1]=x,e[2]=s,e[3]=p,e[4]=E,e[5]=j):(E=e[4],j=e[5]),u.useLayoutEffect(E,j);const v=x&&N!==null;let S,w;e[6]!==s||e[7]!==p?(S=()=>{if(s){h(!0),k(!1);return}if(!p)return;k(!0);const $=window.setTimeout(()=>{h(!1),k(!1)},140);return()=>window.clearTimeout($)},w=[s,p],e[6]=s,e[7]=p,e[8]=S,e[9]=w):(S=e[8],w=e[9]),u.useEffect(S,w);let C,O;e[10]!==i||e[11]!==s?(C=()=>{if(!s)return;const $=D=>{D.key==="Escape"&&i()};return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},O=[i,s],e[10]=i,e[11]=s,e[12]=C,e[13]=O):(C=e[12],O=e[13]),u.useEffect(C,O);let z,B;if(e[14]!==r||e[15]!==i||e[16]!==s?(z=()=>{if(!s)return;const $=D=>{const se=D.target;if(!(se instanceof Node)){i();return}g.current?.contains(se)||r.current?.contains(se)||i()};return document.addEventListener("pointerdown",$,!0),document.addEventListener("wheel",$,!0),()=>{document.removeEventListener("pointerdown",$,!0),document.removeEventListener("wheel",$,!0)}},B=[r,i,s],e[14]=r,e[15]=i,e[16]=s,e[17]=z,e[18]=B):(z=e[17],B=e[18]),u.useEffect(z,B),!p)return null;let T;e[19]!==m?(T=m("mobile.header.openMetadataAria"),e[19]=m,e[20]=T):T=e[20];const P=v?"absolute origin-top-left":"mx-3 mt-2",W=b?"pointer-events-none":"pointer-events-auto";let I;e[21]!==P||e[22]!==W?(I=Q("oc-surface-elevated overflow-y-auto overscroll-contain rounded-[20px] border border-border/70 bg-surface-elevated p-2 shadow-[0_12px_32px_rgb(0_0_0_/_0.2)] will-change-transform",P,W),e[21]=P,e[22]=W,e[23]=I):I=e[23];const _=`${b?"session-metadata-out":"session-metadata-in"} ${b?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let F;e[24]!==N||e[25]!==v?(F=v?{top:8,left:N??8,width:`min(${Ki}px, calc(100% - 16px))`}:null,e[24]=N,e[25]=v,e[26]=F):F=e[26];let M;e[27]!==_||e[28]!==F?(M={animation:_,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...F},e[27]=_,e[28]=F,e[29]=M):M=e[29];let K;e[30]!==o||e[31]!==m?(K=o?t.jsx(_f,{iconNode:t.jsx(ha,{percentage:o.state==="measured"?o.percentage:null}),label:m("mobile.header.metadata.context"),children:o.state==="pending"?null:t.jsxs("span",{className:"inline-flex items-baseline gap-1.5 tabular-nums",children:[o.state==="measured"?t.jsxs("span",{className:Q("font-semibold",o.colorClass),children:[o.percentage.toFixed(1),"%"]}):null,t.jsx("span",{className:"text-muted-foreground",children:o.tokens})]})}):null,e[30]=o,e[31]=m,e[32]=K):K=e[32];let X;e[33]!==o?.state||e[34]!==m?(X=o?.state==="compacted"?t.jsx("p",{className:"px-2.5 pb-1 typography-meta text-muted-foreground",children:m("contextUsage.compacted.description")}):null,e[33]=o?.state,e[34]=m,e[35]=X):X=e[35];let Z;e[36]!==o?.state||e[37]!==m?(Z=o?.state==="pending"?t.jsx("p",{className:"px-2.5 pb-1 typography-meta text-muted-foreground",children:m("mobile.header.metadata.contextPending")}):null,e[36]=o?.state,e[37]=m,e[38]=Z):Z=e[38];let ee;e[39]!==f||e[40]!==c||e[41]!==l||e[42]!==a?(ee=t.jsx(Of,{groups:a,displayMode:l,isLoading:f,timeFormatPreference:c}),e[39]=f,e[40]=c,e[41]=l,e[42]=a,e[43]=ee):ee=e[43];let Y;e[44]!==K||e[45]!==X||e[46]!==Z||e[47]!==ee?(Y=t.jsxs("div",{className:"space-y-1",children:[K,X,Z,ee]}),e[44]=K,e[45]=X,e[46]=Z,e[47]=ee,e[48]=Y):Y=e[48];let pe;e[49]!==I||e[50]!==M||e[51]!==Y||e[52]!==T?(pe=t.jsx("div",{ref:g,role:"dialog","aria-label":T,className:I,style:M,children:Y}),e[49]=I,e[50]=M,e[51]=Y,e[52]=T,e[53]=pe):pe=e[53];let fe;e[54]===Symbol.for("react.memo_cache_sentinel")?(fe=t.jsx("style",{children:`
|
|
5
|
+
@keyframes session-metadata-in {
|
|
6
|
+
from { opacity: 0; transform: translateY(-8px) scale(0.985); }
|
|
7
|
+
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
8
|
+
}
|
|
9
|
+
@keyframes session-metadata-out {
|
|
10
|
+
from { opacity: 1; transform: translateY(0) scale(1); }
|
|
11
|
+
to { opacity: 0; transform: translateY(-6px) scale(0.985); }
|
|
12
|
+
}
|
|
13
|
+
`}),e[54]=fe):fe=e[54];let re;return e[55]!==pe?(re=t.jsxs("div",{ref:R,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:[pe,fe]}),e[55]=pe,e[56]=re):re=e[56],re},Of=n=>{const e=me.c(30),{groups:s,displayMode:i,isLoading:r,timeFormatPreference:o}=n,{t:a}=ye();let l;e[0]!==i||e[1]!==a?(l=a(i==="remaining"?"header.services.remaining":"header.services.used"),e[0]=i,e[1]=a,e[2]=l):l=e[2];const f=l;if(s.length===0){if(!r)return null;let N;e[3]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx(q,{name:"loader-4",className:"size-4 animate-spin","aria-hidden":!0}),e[3]=N):N=e[3];let A;e[4]!==a?(A=a("common.loading"),e[4]=a,e[5]=A):A=e[5];let E;return e[6]!==A?(E=t.jsxs("div",{className:"flex items-center justify-center gap-2 px-2.5 py-6 text-muted-foreground",children:[N,t.jsx("span",{className:"typography-ui-label",children:A})]}),e[6]=A,e[7]=E):E=e[7],E}let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=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]=c):c=e[8];let m;e[9]!==a?(m=a("mobile.header.metadata.usage"),e[9]=a,e[10]=m):m=e[10];let g;e[11]!==m?(g=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:m}),e[11]=m,e[12]=g):g=e[12];let p;e[13]!==r?(p=r?t.jsx(q,{name:"refresh",className:"size-3.5 animate-spin"}):null,e[13]=r,e[14]=p):p=e[14];let h;e[15]!==f?(h=t.jsx("span",{className:"truncate",children:f}),e[15]=f,e[16]=h):h=e[16];let b;e[17]!==p||e[18]!==h?(b=t.jsxs("span",{className:"inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground",children:[p,h]}),e[17]=p,e[18]=h,e[19]=b):b=e[19];let k;e[20]!==g||e[21]!==b?(k=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 px-2.5 pb-1.5",children:[c,g,b]}),e[20]=g,e[21]=b,e[22]=k):k=e[22];let x;e[23]!==i||e[24]!==s||e[25]!==o?(x=t.jsx(Pf,{groups:s,displayMode:i,timeFormatPreference:o}),e[23]=i,e[24]=s,e[25]=o,e[26]=x):x=e[26];let R;return e[27]!==k||e[28]!==x?(R=t.jsxs("div",{className:"pt-2.5",children:[k,x]}),e[27]=k,e[28]=x,e[29]=R):R=e[29],R},zf=u.memo(function({open:e,onOpenChange:s,currentSessionId:i,effectiveDirectory:r,isNewSessionDraftOpen:o}){const{t:a}=ye(),l=u.useRef(null),f=Za(i??"",r||void 0),c=ft(I=>I.providers),m=ft(I=>I.currentProviderId),g=ft(I=>I.currentModelId),p=ft(I=>I.getModelMetadata);ft(I=>I.modelsMetadata.size);const h=el(u.useCallback(I=>i?I.sessionModelSelections.get(i)??null:null,[i])),b=Jt(I=>I.results),k=Jt(I=>I.refreshErrors),x=u.useRef(!1),R=Jt(I=>I.loadSettings),N=Jt(I=>I.fetchAllQuotas),A=Jt(I=>I.isLoading),E=Jt(I=>I.displayMode),j=Jt(I=>I.dropdownProviderIds),v=Me(I=>I.timeFormatPreference);tl(),u.useEffect(()=>{R()},[R]),u.useEffect(()=>{Ni(j)},[j]),u.useEffect(()=>{if(!e){x.current=!1;return}x.current||A||!j.some(_=>!b.some(F=>F.providerId===_)||k[_])||(x.current=!0,N())},[j,N,A,e,b,k]);const w=u.useMemo(()=>{for(let I=f.length-1;I>=0;I-=1){const _=f[I];if(_.role!=="assistant")continue;const F=_.providerID.trim(),M=_.modelID.trim();if(F&&M)return{providerID:F,modelID:M}}return null},[f])??(h?{providerID:h.providerId,modelID:h.modelId}:null)??(m&&g?{providerID:m,modelID:g}:null),O=(w?c.find(I=>I.id===w.providerID):void 0)?.models.find(I=>I.id===w?.modelID),z=w?p(w.providerID,w.modelID):void 0,B=Tf(O?.limit,"context")??z?.limit?.context??0,T=u.useMemo(()=>sl(f),[f]),P=u.useMemo(()=>{if(B<=0)return null;if(o||!T)return{state:"pending"};if(T.state==="compacted")return{state:"compacted",tokens:`${Df}/${pr(B)}`};const I=Math.min(T.totalTokens/B*100,999),_=I>=90?"text-[var(--status-error)]":I>=75?"text-[var(--status-warning)]":"text-[var(--status-success)]";return{state:"measured",percentage:I,tokens:`${pr(T.totalTokens)}/${pr(B)}`,colorClass:_}},[T,B,o]),W=nl();return u.useEffect(()=>{!e||W.length===0||Ni(W.map(I=>I.providerId))},[e,W]),t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:l,type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":a("mobile.header.openMetadataAria"),"aria-expanded":e,onClick:()=>s(I=>!I),style:{touchAction:"manipulation"},children:t.jsx(ha,{percentage:P?.state==="measured"?P.percentage:P?.state==="compacted"?null:0})}),t.jsx(Mf,{open:e,onClose:()=>s(!1),anchorRef:l,contextDisplay:P,usageGroups:W,usageDisplayMode:E,isUsageLoading:A,timeFormatPreference:v})]})}),Bf=10,qi=380,Lf=(n,e)=>n.title?.trim()||e,Ff=n=>{const e=me.c(33),{session:s,meta:i,active:r,onSelect:o}=n,{t:a}=ye(),l=Dr(s.id),f=_r(s.id),c=f!==null,m=!c&&l>0&&!r,g=Mr(s.id,c),p=(c||m)&&g,h=s.time?.updated??s.time?.created??0;let b;e[0]!==h?(b=al(h),e[0]=h,e[1]=b):b=e[1];const k=b,x=r&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let R;e[2]!==x?(R=Q("flex w-full items-center gap-3 rounded-xl px-2.5 py-2 text-left transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",x),e[2]=x,e[3]=R):R=e[3];let N;e[4]===Symbol.for("react.memo_cache_sentinel")?(N={touchAction:"manipulation"},e[4]=N):N=e[4];const A=r?"text-primary":"text-foreground";let E;e[5]!==A?(E=Q("block truncate text-left typography-ui-label",A),e[5]=A,e[6]=E):E=e[6];let j;e[7]!==s||e[8]!==a?(j=Lf(s,a("sessions.sidebar.session.untitled")),e[7]=s,e[8]=a,e[9]=j):j=e[9];let v;e[10]!==E||e[11]!==j?(v=t.jsx("span",{dir:"auto",className:E,children:j}),e[10]=E,e[11]=j,e[12]=v):v=e[12];let S;e[13]!==i?(S=i?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:i}):null,e[13]=i,e[14]=S):S=e[14];let w;e[15]!==S||e[16]!==v?(w=t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[v,S]}),e[15]=S,e[16]=v,e[17]=w):w=e[17];let C;e[18]!==c||e[19]!==m||e[20]!==f?(C=c||m?t.jsx(Mn,{state:f??"unread"}):null,e[18]=c,e[19]=m,e[20]=f,e[21]=C):C=e[21];let O;e[22]!==c||e[23]!==s.id||e[24]!==p||e[25]!==k?(O=p?t.jsx(Or,{sessionId:s.id,running:c,className:"typography-micro"}):k?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:k}):null,e[22]=c,e[23]=s.id,e[24]=p,e[25]=k,e[26]=O):O=e[26];let z;return e[27]!==o||e[28]!==w||e[29]!==C||e[30]!==O||e[31]!==R?(z=t.jsxs("button",{type:"button",className:R,onClick:o,style:N,children:[w,C,O]}),e[27]=o,e[28]=w,e[29]=C,e[30]=O,e[31]=R,e[32]=z):z=e[32],z},$f=n=>{const e=me.c(50),{open:s,onClose:i,anchorRef:r}=n,{t:o}=ye(),a=u.useRef(null),[l,f]=u.useState(s),[c,m]=u.useState(!1),{enabled:g}=Tr(),p=u.useRef(null),[h,b]=u.useState(null);let k,x;e[0]!==r||e[1]!==g||e[2]!==s||e[3]!==l?(k=()=>{if(!s||!g||!l)return;const re=()=>{const se=r.current?.getBoundingClientRect(),te=p.current?.getBoundingClientRect();if(!se||!te){b(null);return}const ie=se.left-te.left;b(Math.min(Math.max(ie,8),Math.max(8,te.width-qi-8)))};re();const $=p.current;if(typeof ResizeObserver>"u"||!$)return;const D=new ResizeObserver(re);return D.observe($),()=>D.disconnect()},x=[r,g,s,l],e[0]=r,e[1]=g,e[2]=s,e[3]=l,e[4]=k,e[5]=x):(k=e[4],x=e[5]),u.useLayoutEffect(k,x);const R=g&&h!==null,N=_e(Wf),A=_e(Vf),E=ot(Uf);let j;e[6]===Symbol.for("react.memo_cache_sentinel")?(j={maxParents:Bf},e[6]=j):j=e[6];const v=ol(s||l,j);let S,w;e[7]!==s||e[8]!==l?(S=()=>{if(s){ko(),f(!0),m(!1);return}if(!l)return;m(!0);const re=window.setTimeout(()=>{f(!1),m(!1)},140);return()=>window.clearTimeout(re)},w=[s,l],e[7]=s,e[8]=l,e[9]=S,e[10]=w):(S=e[9],w=e[10]),u.useEffect(S,w);let C,O;e[11]!==i||e[12]!==s?(C=()=>{if(!s)return;const re=$=>{$.key==="Escape"&&i()};return document.addEventListener("keydown",re),()=>document.removeEventListener("keydown",re)},O=[i,s],e[11]=i,e[12]=s,e[13]=C,e[14]=O):(C=e[13],O=e[14]),u.useEffect(C,O);let z,B;e[15]!==r||e[16]!==i||e[17]!==s?(z=()=>{if(!s)return;const re=$=>{const D=$.target;if(!(D instanceof Node)){i();return}a.current?.contains(D)||r.current?.contains(D)||i()};return document.addEventListener("pointerdown",re,!0),()=>document.removeEventListener("pointerdown",re,!0)},B=[r,i,s],e[15]=r,e[16]=i,e[17]=s,e[18]=z,e[19]=B):(z=e[18],B=e[19]),u.useEffect(z,B);let T;e[20]!==i||e[21]!==A?(T=re=>{A(re.id,vo(re)),i()},e[20]=i,e[21]=A,e[22]=T):T=e[22];const P=T;if(!l)return null;let W;e[23]!==o?(W=o("sessions.switcher.openAria"),e[23]=o,e[24]=W):W=e[24];const I=R?"absolute origin-top-left":"mx-3 mt-2",_=c?"pointer-events-none":"pointer-events-auto";let F;e[25]!==I||e[26]!==_?(F=Q("oc-surface-elevated flex flex-col overflow-hidden rounded-[20px] border border-border/70 bg-surface-elevated p-2 shadow-[0_12px_32px_rgb(0_0_0_/_0.2)] will-change-transform",I,_),e[25]=I,e[26]=_,e[27]=F):F=e[27];const M=`${c?"session-switcher-out":"session-switcher-in"} ${c?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let K;e[28]!==h||e[29]!==R?(K=R?{top:8,left:h??8,width:`min(${qi}px, calc(100% - 16px))`}:null,e[28]=h,e[29]=R,e[30]=K):K=e[30];let X;e[31]!==M||e[32]!==K?(X={animation:M,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...K},e[31]=M,e[32]=K,e[33]=X):X=e[33];let Z;e[34]!==N||e[35]!==P||e[36]!==v||e[37]!==E||e[38]!==o?(Z=v.length===0?t.jsx("p",{className:"px-3 py-6 text-center typography-small text-muted-foreground",children:o("sessions.switcher.empty")}):v.map(re=>{const $=re.node.session,D=[re.secondaryMeta?.projectLabel,re.secondaryMeta?.branchLabel].filter(Boolean).join(" · ");return t.jsx(Ff,{session:$,meta:D,active:$.id===N,onSelect:()=>{re.projectId&&E(re.projectId),P($)}},$.id)}),e[34]=N,e[35]=P,e[36]=v,e[37]=E,e[38]=o,e[39]=Z):Z=e[39];let ee;e[40]!==Z?(ee=t.jsx("div",{className:"oc-hide-scrollbar min-h-0 flex-1 space-y-0.5 overflow-y-auto overscroll-contain",children:Z}),e[40]=Z,e[41]=ee):ee=e[41];let Y;e[42]!==W||e[43]!==F||e[44]!==X||e[45]!==ee?(Y=t.jsx("div",{ref:a,role:"dialog","aria-label":W,className:F,style:X,children:ee}),e[42]=W,e[43]=F,e[44]=X,e[45]=ee,e[46]=Y):Y=e[46];let pe;e[47]===Symbol.for("react.memo_cache_sentinel")?(pe=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]=pe):pe=e[47];let fe;return e[48]!==Y?(fe=t.jsxs("div",{ref:p,className:"fixed inset-x-0 bottom-0 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-header-height,56px))] z-20 pointer-events-none",children:[Y,pe]}),e[48]=Y,e[49]=fe):fe=e[49],fe};function Wf(n){return n.currentSessionId}function Vf(n){return n.setCurrentSession}function Uf(n){return n.setActiveProjectIdOnly}const Gf=n=>{const e=me.c(84),{onOpenSessions:s,onOpenWorkspace:i,compactTitle:r}=n,o=r===void 0?!1:r,{t:a}=ye(),[l,f]=u.useState(!1),[c,m]=u.useState(!1),g=u.useRef(null),p=Wt(Kf),h=_e(qf);let b;e[0]!==h?(b=Le=>h?Le.getDirectoryForSession(h):null,e[0]=h,e[1]=b):b=e[1];const x=_e(b)||p,R=ll(h,x||void 0),N=_e(Hf),A=So(x||null);let E;e[2]!==x||e[3]!==A?(E=Le=>{if(!x||A!==!0)return!1;const Fe=Le.directories.get(x)?.status;return!!(Fe&&!Fe.isClean)},e[2]=x,e[3]=A,e[4]=E):E=e[4];const j=it(E),v=Me(Jf),S=Wc(v);let w;e[5]!==R?.title?(w=R?.title?.trim(),e[5]=R?.title,e[6]=w):w=e[6];const C=w;let O;e[7]!==h||e[8]!==v||e[9]!==S||e[10]!==C||e[11]!==a?(O=(v?S:null)||C||a(h?"mobile.sessions.untitled":"sessions.switcher.draftTitle"),e[7]=h,e[8]=v,e[9]=S,e[10]=C,e[11]=a,e[12]=O):O=e[12];const z=O;let B;e[13]===Symbol.for("react.memo_cache_sentinel")?(B=()=>{f(!1),m(!1)},e[13]=B):B=e[13];let T;e[14]!==h||e[15]!==x?(T=[h,x],e[14]=h,e[15]=x,e[16]=T):T=e[16],u.useEffect(B,T);let P;e[17]!==s?(P=()=>{f(!1),m(!1),s()},e[17]=s,e[18]=P):P=e[18];const W=P;let I;e[19]===Symbol.for("react.memo_cache_sentinel")?(I=Le=>{f(Fe=>{const bt=typeof Le=="function"?Le(Fe):Le;return bt&&m(!1),bt})},e[19]=I):I=e[19];const _=I;let F;e[20]===Symbol.for("react.memo_cache_sentinel")?(F=()=>{m(Le=>{const Fe=!Le;return Fe&&f(!1),Fe})},e[20]=F):F=e[20];const M=F;let K;e[21]===Symbol.for("react.memo_cache_sentinel")?(K={paddingTop:"var(--oc-safe-area-top, 0px)"},e[21]=K):K=e[21];let X;e[22]!==a?(X=a("mobile.sessions.openSheetAria"),e[22]=a,e[23]=X):X=e[23];let Z,ee;e[24]===Symbol.for("react.memo_cache_sentinel")?(Z={touchAction:"manipulation"},ee=t.jsx(q,{name:"list-unordered",className:"size-5"}),e[24]=Z,e[25]=ee):(Z=e[24],ee=e[25]);let Y;e[26]!==W||e[27]!==X?(Y=t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":X,onClick:W,style:Z,children:ee}),e[26]=W,e[27]=X,e[28]=Y):Y=e[28];const pe=o?"shrink":"flex-1";let fe;e[29]!==pe?(fe=Q("flex min-w-0 items-center rounded-lg px-2 py-1.5 text-left transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",pe),e[29]=pe,e[30]=fe):fe=e[30];let re;e[31]!==a?(re=a("sessions.switcher.openAria"),e[31]=a,e[32]=re):re=e[32];let $;e[33]===Symbol.for("react.memo_cache_sentinel")?($={touchAction:"manipulation"},e[33]=$):$=e[33];let D;e[34]!==z?(D=t.jsx("span",{dir:"auto",className:"block min-w-0 truncate text-left typography-ui-label text-foreground",children:z}),e[34]=z,e[35]=D):D=e[35];const se=c&&"rotate-180";let te;e[36]!==se?(te=Q("size-4 shrink-0 text-muted-foreground transition-transform duration-150",se),e[36]=se,e[37]=te):te=e[37];let ie;e[38]!==te?(ie=t.jsx(q,{name:"arrow-down-s",className:te}),e[38]=te,e[39]=ie):ie=e[39];let G;e[40]!==D||e[41]!==ie?(G=t.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[D,ie]}),e[40]=D,e[41]=ie,e[42]=G):G=e[42];let oe;e[43]!==c||e[44]!==fe||e[45]!==re||e[46]!==G?(oe=t.jsx("button",{ref:g,type:"button",className:fe,"aria-label":re,"aria-haspopup":"dialog","aria-expanded":c,onClick:M,style:$,children:G}),e[43]=c,e[44]=fe,e[45]=re,e[46]=G,e[47]=oe):oe=e[47];let ue;e[48]!==o?(ue=o?t.jsx("div",{className:"min-w-0 flex-1"}):null,e[48]=o,e[49]=ue):ue=e[49];let Ce;e[50]!==h||e[51]!==x||e[52]!==N||e[53]!==l||e[54]!==v?(Ce=v?null:t.jsx(zf,{open:l,onOpenChange:_,currentSessionId:h,effectiveDirectory:x,isNewSessionDraftOpen:N}),e[50]=h,e[51]=x,e[52]=N,e[53]=l,e[54]=v,e[55]=Ce):Ce=e[55];let be;e[56]!==x?(be=t.jsx(Vc,{directory:x,className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",iconClassName:"size-5"}),e[56]=x,e[57]=be):be=e[57];let Se;e[58]!==j||e[59]!==a?(Se=a(j?"mobile.header.openWorkspaceWithChangesAria":"mobile.header.openWorkspaceAria"),e[58]=j,e[59]=a,e[60]=Se):Se=e[60];let he;e[61]!==i?(he=()=>{f(!1),m(!1),i()},e[61]=i,e[62]=he):he=e[62];let Pe,H;e[63]===Symbol.for("react.memo_cache_sentinel")?(Pe={touchAction:"manipulation"},H=t.jsx(q,{name:"pencil-ruler-2",className:"size-5"}),e[63]=Pe,e[64]=H):(Pe=e[63],H=e[64]);let ae;e[65]!==j?(ae=j?t.jsx("span",{className:"absolute right-1.5 top-1.5 size-2.5 rounded-full border-2 border-[var(--background)] bg-[var(--status-warning)]","aria-hidden":!0}):null,e[65]=j,e[66]=ae):ae=e[66];let Re;e[67]!==Se||e[68]!==he||e[69]!==ae?(Re=t.jsxs("button",{type:"button",className:"relative flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":Se,onClick:he,style:Pe,children:[H,ae]}),e[67]=Se,e[68]=he,e[69]=ae,e[70]=Re):Re=e[70];let Ae;e[71]!==Y||e[72]!==oe||e[73]!==ue||e[74]!==Ce||e[75]!==be||e[76]!==Re?(Ae=t.jsx("header",{className:"oc-mobile-header relative z-30 flex shrink-0 items-center gap-1 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",style:K,children:t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[Y,oe,ue,Ce,be,Re]})}),e[71]=Y,e[72]=oe,e[73]=ue,e[74]=Ce,e[75]=be,e[76]=Re,e[77]=Ae):Ae=e[77];let Ee;e[78]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>m(!1),e[78]=Ee):Ee=e[78];let Te;e[79]!==c?(Te=t.jsx($f,{open:c,onClose:Ee,anchorRef:g}),e[79]=c,e[80]=Te):Te=e[80];let Je;return e[81]!==Ae||e[82]!==Te?(Je=t.jsxs(t.Fragment,{children:[Ae,Te]}),e[81]=Ae,e[82]=Te,e[83]=Je):Je=e[83],Je};function Kf(n){return n.currentDirectory}function qf(n){return n.currentSessionId}function Hf(n){return!!n.newSessionDraft?.open}function Jf(n){return n.runOverviewKey}const Yf=({onActiveConnectionDeleted:n,onConnect:e})=>{const{t:s}=ye(),i=aa(e),{connections:r,isBusy:o,isPasswordBusy:a,error:l,pendingConnection:f,connect:c,submitPassword:m,cancelPassword:g,saveConnection:p,removeConnection:h,setError:b}=i,[k,x]=u.useState(null),R=k?r.find(G=>G.id===k)??null:null,[N,A]=u.useState(null),[E,j]=u.useState(""),[v,S]=u.useState(""),[w,C]=u.useState(""),[O,z]=u.useState(""),[B,T]=u.useState(!1),[P,W]=u.useState(!1),I=u.useRef(null),_=u.useMemo(()=>Rr(),[]),[F,M]=u.useState(!1),[K,X]=u.useState(null),[Z,ee]=u.useState(!1),Y=Jo(u.useCallback(()=>ee(!0),[])),pe=u.useCallback(()=>{x(null),j(""),S(""),C(""),b(null),M(!1)},[b]),fe=u.useCallback(G=>{G.preventDefault(),p({id:k??void 0,url:E,label:v,clientToken:w}).then(oe=>{oe&&pe()})},[w,k,v,pe,p,E]),re=u.useCallback(async()=>{if(I.current)return;b(null),T(!0);const G=new AbortController;I.current=G;try{const oe=await fa({signal:G.signal});switch(I.current===G&&(I.current=null,T(!1)),oe.status){case"ok":j(oe.url),oe.label&&S(oe.label),oe.clientToken&&C(oe.clientToken),M(!0);break;case"pairing":W(!0),await i.redeemPairingConnection(oe.pairing);break;case"permission-denied":b(s("mobile.connect.scan.permissionDenied"));break;case"invalid":b(s("mobile.connect.scan.invalid"));break;case"unsupported":b(s("mobile.connect.scan.unsupported"));break;case"failed":b(s("mobile.connect.scan.failed"));break;default:break}}finally{W(!1),I.current===G&&(I.current=null,T(!1))}},[i,b,s]);u.useEffect(()=>()=>I.current?.abort(),[]);const $=u.useCallback(G=>{G.preventDefault(),m(O)},[O,m]),D=u.useCallback(()=>{z(""),g()},[g]),se=u.useCallback(G=>{A(oe=>oe===G?null:G)},[]),te=u.useCallback(G=>{A(null),k===G&&pe();const oe=r.length===1;h(G).then(ue=>{ue&&(oe||Gi(ue))&&n()})},[r.length,k,n,h,pe]),ie=Vs;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:$,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(G=>G.kind==="direct")?Dt(f):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...xs,value:O,onChange:G=>z(G.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:ie}),l?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:l}):null,t.jsx(ke,{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(ke,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:D,children:s("mobile.connect.cancelPassword")})]})})}):t.jsxs(t.Fragment,{children:[B?t.jsx(ma,{onCancel:()=>I.current?.abort()}):null,P?t.jsx(pa,{}):null,Z?t.jsx(la,{onClose:()=>ee(!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",{...Y,className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map(G=>{const oe=N===G.id,ue=Gi(G),Ce=K===G.id,be=Ce?s("mobile.connect.connecting"):ue?Hs()?s("mobile.instances.status.connectedRelay"):s("mobile.instances.status.connectedDirect"):G.candidates.some(Se=>Se.kind==="direct")?Dt(G):s("mobile.connect.relay.badge");return t.jsxs("div",{className:Q("flex items-center border-b border-border/70 transition-colors last:border-b-0",oe&&"bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]"),children:[t.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-3 px-3.5 py-3 text-left transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:opacity-60",onClick:()=>{ue||(X(G.id),c({id:G.id,candidates:G.candidates,clientToken:G.clientToken,label:G.label}).finally(()=>X(null)))},disabled:o&&!Ce||oe,children:[t.jsxs("span",{className:"relative flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:[t.jsx(q,{name:"server",className:"size-[18px]"}),ue?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:G.label}),t.jsx("span",{className:Q("block truncate typography-small",ue&&!Ce?"text-[var(--status-success)]":"text-muted-foreground"),children:be})]}),Ce?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:[oe?t.jsxs("button",{type:"button","aria-label":s("mobile.instances.confirmDeleteAria",{label:G.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:()=>te(G.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")})]}):G.candidates.some(Se=>Se.kind==="direct")?t.jsx("button",{type:"button","aria-label":s("mobile.instances.edit"),className:"flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>{x(G.id),j(Dt(G)),S(G.label),C(G.clientToken||""),b(null)},style:{touchAction:"manipulation"},children:t.jsx(q,{name:"edit",className:"size-[18px]"})}):null,t.jsx("button",{type:"button","aria-label":oe?s("mobile.instances.cancelDeleteAria",{label:G.label}):s("mobile.instances.deleteAria",{label:G.label}),className:"flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>se(G.id),style:{touchAction:"manipulation"},children:t.jsx(q,{name:oe?"close":"delete-bin",className:"size-[18px]"})})]})]},G.id)})}):t.jsx("p",{...Y,className:"rounded-[18px] border border-dashed border-border/70 px-4 py-6 text-center typography-small text-muted-foreground",children:s("mobile.connect.saved.empty")}),!F&&!R?t.jsxs("div",{className:"space-y-2",children:[_?t.jsxs(ke,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{re()},disabled:B,children:[t.jsx(q,{name:"scan-2",className:Q("size-[18px]",B&&"animate-pulse")}),s("mobile.connect.scanQr")]}):null,t.jsxs(ke,{type:"button",variant:_?"ghost":"outline",size:"lg",className:"h-12 w-full",onClick:()=>{b(null),M(!0)},children:[t.jsx(q,{name:"add",className:"size-[18px]"}),s("mobile.instances.addManual")]}),l?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):null]}):t.jsxs("form",{className:"space-y-3",onSubmit:fe,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(R?"mobile.instances.editTitle":"mobile.instances.addTitle")}),t.jsx(ke,{type:"button",variant:"ghost",size:"xs",onClick:pe,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",{...xs,value:E,onChange:G=>j(G.target.value),placeholder:s("mobile.connect.url.placeholder"),type:"url",inputMode:"url",autoCapitalize:"none",className:ie})]}),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:v,onChange:G=>S(G.target.value),placeholder:s("mobile.instances.label.placeholder"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,className:ie})]}),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",{...xs,value:w,onChange:G=>C(G.target.value),placeholder:s("mobile.connect.token.placeholder"),autoCapitalize:"none",className:ie}),t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")})]}),l?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:l}):null,t.jsx(ke,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",children:s(R?"mobile.instances.saveEdit":"mobile.instances.saveNew")})]})]})})})]})},Be=n=>Zs(n)??"",hr=n=>{const e=Be(n);if(!e)return"";const s=e.split("/").filter(Boolean);return s[s.length-1]?.replace(/[-_]/g," ")||e},Hi=Xr(n=>({expandedParents:{},toggleParent:e=>n(s=>{const i={...s.expandedParents};return i[e]?delete i[e]:i[e]=!0,{expandedParents:i}})})),In=Xr()(Ko(n=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(e,s)=>n(i=>({projectExpanded:{...i.projectExpanded,[e]:s}})),setWorktreeExpanded:(e,s)=>n(i=>({worktreeExpanded:{...i.worktreeExpanded,[e]:s}}))}),{name:"mobile-session-tree"})),Er=Xr()(Ko(n=>({orderByProject:{},setWorktreeOrder:(e,s)=>n(i=>({orderByProject:{...i.orderByProject,[e]:s}}))}),{name:"mobile-worktree-order"})),Ji=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),Xf=(n,e)=>{if(!n||n.length===0)return e;const s=new Map(n.map((r,o)=>[Ji(r),o])),i=r=>s.get(Ji(r.path))??Number.MAX_SAFE_INTEGER;return e.map((r,o)=>({worktree:r,index:o})).sort((r,o)=>{const a=i(r.worktree)-i(o.worktree);return a!==0?a:r.index-o.index}).map(r=>r.worktree)},Us=n=>Zs(n)??"",Qf=n=>{const e=n;return Us(e.directory??e.project?.worktree??null)},ga=({open:n,project:e,worktree:s,onClose:i,onDeleted:r})=>{const{t:o}=ye(),a=No(),l=gs(P=>P.activeSessions),f=_e(P=>P.archiveSessions),c=Wt(P=>P.currentDirectory),{git:m,sourceControl:g}=Un(),[p,h]=u.useState(!1),[b,k]=u.useState(!1),[x,R]=u.useState(!1),[N,A]=u.useState(null),[E,j]=u.useState(!1),v=Us(s?.path),S=typeof s?.branch=="string"&&s.branch.trim().length>0,w=u.useMemo(()=>{if(!v)return[];const P=new Map;for(const W of[...l,...a])Qf(W)===v&&P.set(W.id,W);return Array.from(P.values())},[l,a,v]);u.useEffect(()=>{if(!n){h(!1),k(!1),R(!1),A(null),j(!1);return}if(!s?.path)return;let P=!1;return cl(s.path).then(W=>{P||(R(!!W?.isDirty),A(W?.upstream?.split("/")[0]?.trim()||null))}).catch(()=>{P||R(!!s.status?.isDirty)}),()=>{P=!0}},[n,s?.path,s?.status?.isDirty]);const C=u.useCallback(async P=>(await ul(e,P,{deleteRemoteBranch:S&&b,deleteLocalBranch:S&&p,remoteName:N??void 0,network:{git:m,sourceControl:g}}),Us(c)===v&&Us(e.path)&&Wt.getState().setDirectory(Us(e.path),{showOverlay:!1}),!0),[c,p,b,m,S,e,N,g,v]),O=u.useCallback((P,W)=>{const I=dl(P),_=ce.loading(o("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:I}));fl(P.path),(async()=>{try{const F=await Uc({sessionIds:W,removeWorktree:()=>C(P),archiveSessions:f});if(!F.removed){ce.dismiss(_);return}const{failedIds:M}=F.archive;if(M.length>0){ce.error(M.length===1?o("sessions.sidebar.bulkActions.failedArchiveSingle",{count:M.length}):o("sessions.sidebar.bulkActions.failedArchivePlural",{count:M.length}),{id:_,description:o("sessions.sidebar.dialogs.deleteResult.tryAgain")});return}ce.success(o("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:I}),{id:_,description:o(S&&b?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed")}),r?.()}catch(F){const M=F instanceof Pn?F.message||o("sessions.sidebar.dialogs.deleteResult.tryAgain"):F instanceof jr||F instanceof $t&&!F.message.includes(" ")?o("gitView.publish.remoteNotGranted"):F instanceof Error?F.message:o("sessions.sidebar.dialogs.deleteResult.tryAgain");ce.error(o("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:I}),{id:_,description:M})}finally{ml(P.path)}})()},[f,b,S,r,C,o]),z=()=>{!s||E||(O(s,w.map(P=>P.id)),i())};if(!s)return null;const B=s.branch||s.label||s.path,T=(P,W,I,_)=>t.jsxs("button",{type:"button",role:"switch","aria-checked":P,disabled:_,onClick:()=>W(!P),className:Q("flex w-full items-center justify-between gap-3 rounded-xl border border-border/70 px-3.5 py-3 text-left transition-colors","hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",_&&"pointer-events-none opacity-40"),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:I}),t.jsx("span",{className:Q("relative h-6 w-10 shrink-0 rounded-full transition-colors",P?"bg-primary":"bg-muted-foreground/30"),children:t.jsx("span",{className:Q("absolute top-0.5 size-5 rounded-full bg-white transition-transform",P?"translate-x-[1.125rem]":"translate-x-0.5")})})]});return t.jsx(Co,{open:n,onClose:i,title:o("mobile.projectEdit.deleteWorktreeTitle"),footer:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(ke,{variant:"ghost",className:"flex-1",onClick:i,disabled:E,children:o("projectEditDialog.actions.cancel")}),t.jsx(ke,{variant:"destructive",className:"flex-1",onClick:()=>{z()},disabled:E,children:o("mobile.projectEdit.deleteWorktreeConfirmButton")})]}),children:t.jsxs("div",{className:"flex flex-col gap-4 px-1 py-1",children:[t.jsx("p",{className:"typography-ui-body text-foreground",children:o("mobile.projectEdit.deleteWorktreeConfirm",{name:B})}),x?t.jsx("p",{className:"rounded-xl border border-[var(--warning)]/40 bg-[color-mix(in_srgb,var(--warning)_10%,transparent)] px-3.5 py-3 typography-meta text-foreground",children:o("mobile.projectEdit.deleteWorktreeDirty")}):null,w.length>0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("mobile.projectEdit.deleteWorktreeArchiveNote",{count:w.length})}):null,S?t.jsxs("div",{className:"flex flex-col gap-2",children:[T(p,h,o("mobile.projectEdit.deleteLocalBranch"),E),T(b,k,o("mobile.projectEdit.deleteRemoteBranch"),E||!N)]}):null]})})},Ys=n=>{const e=me.c(18),{project:s,size:i}=n,r=i===void 0?"md":i,{currentTheme:o}=Ro(),a=s.icon?Eo[s.icon]:null,l=s.color?Io[s.color]??null:null,f=r==="sm"?"size-6 rounded-md":"size-8 rounded-lg",c=r==="sm"?"size-3.5":"size-4";let m;e[0]!==a||e[1]!==l||e[2]!==c?(m=a?t.jsx(q,{name:a,className:c,style:l?{color:l}:void 0}):t.jsx(kr,{className:c,style:l?{color:l}:void 0}),e[0]=a,e[1]=l,e[2]=c,e[3]=m):m=e[3];const g=m,p=r==="md"&&"bg-[var(--surface-muted)]";let h;e[4]!==f||e[5]!==p?(h=Q("flex shrink-0 items-center justify-center overflow-hidden text-muted-foreground",p,f),e[4]=f,e[5]=p,e[6]=h):h=e[6];let b;e[7]!==s.iconBackground?(b=s.iconBackground?{backgroundColor:s.iconBackground}:void 0,e[7]=s.iconBackground,e[8]=b):b=e[8];let k;e[9]!==o||e[10]!==g||e[11]!==s.iconImage||e[12]!==s.id?(k=s.iconImage?t.jsx(Ao,{project:{id:s.id,iconImage:s.iconImage??null},options:{themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},className:"size-full object-contain",fallback:g}):g,e[9]=o,e[10]=g,e[11]=s.iconImage,e[12]=s.id,e[13]=k):k=e[13];let x;return e[14]!==h||e[15]!==b||e[16]!==k?(x=t.jsx("span",{className:h,style:b,children:k}),e[14]=h,e[15]=b,e[16]=k,e[17]=x):x=e[17],x},ba=n=>{const e=me.c(57),{initialTitle:s,indent:i,className:r,aiRename:o,onSubmit:a,onCancel:l}=n,{t:f}=ye(),[c,m]=u.useState(s),g=Zf;let p;e[0]!==s||e[1]!==l||e[2]!==a||e[3]!==c?(p=()=>{const Z=c.trim();if(!Z||Z===s.trim()){l();return}a(Z)},e[0]=s,e[1]=l,e[2]=a,e[3]=c,e[4]=p):p=e[4];const h=p;let b;e[5]!==r?(b=Q("flex h-9 min-w-0 flex-1 items-center gap-2 pr-2",r),e[5]=r,e[6]=b):b=e[6];let k;e[7]!==i?(k={paddingLeft:i},e[7]=i,e[8]=k):k=e[8];let x;e[9]!==h?(x=Z=>{Z.preventDefault(),h()},e[9]=h,e[10]=x):x=e[10];let R;e[11]===Symbol.for("react.memo_cache_sentinel")?(R=Z=>m(Z.target.value),e[11]=R):R=e[11];let N;e[12]!==l?(N=Z=>Gc(Z,l),e[12]=l,e[13]=N):N=e[13];let A;e[14]!==f?(A=f("sessions.sidebar.session.rename.save"),e[14]=f,e[15]=A):A=e[15];let E;e[16]!==f?(E=f("sessions.sidebar.session.menu.rename"),e[16]=f,e[17]=E):E=e[17];let j;e[18]===Symbol.for("react.memo_cache_sentinel")?(j={minHeight:0},e[18]=j):j=e[18];let v;e[19]!==N||e[20]!==A||e[21]!==E||e[22]!==c?(v=t.jsx("input",{ref:g,value:c,onChange:R,onKeyDown:N,"aria-label":A,placeholder:E,className:"min-w-0 flex-1 bg-transparent text-[16px] typography-ui-label text-foreground outline-none placeholder:text-muted-foreground",style:j,enterKeyHint:"done"}),e[19]=N,e[20]=A,e[21]=E,e[22]=c,e[23]=v):v=e[23];const S=o.disabled;let w;e[24]!==o||e[25]!==l?(w=()=>{o.run(),l()},e[24]=o,e[25]=l,e[26]=w):w=e[26];let C;e[27]!==f?(C=f("sessions.aiRename.action"),e[27]=f,e[28]=C):C=e[28];let O,z;e[29]===Symbol.for("react.memo_cache_sentinel")?(O={touchAction:"manipulation",minHeight:0,minWidth:0},z=t.jsx(q,{name:"ai-generate-2",className:"size-4"}),e[29]=O,e[30]=z):(O=e[29],z=e[30]);let B;e[31]!==o.disabled||e[32]!==o.hint||e[33]!==w||e[34]!==C?(B=t.jsx("button",{type:"button",disabled:S,onClick:w,"aria-label":C,"aria-description":o.hint,title:o.hint,className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground disabled:opacity-40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:O,children:z}),e[31]=o.disabled,e[32]=o.hint,e[33]=w,e[34]=C,e[35]=B):B=e[35];let T;e[36]!==f?(T=f("sessions.sidebar.session.rename.save"),e[36]=f,e[37]=T):T=e[37];let P,W;e[38]===Symbol.for("react.memo_cache_sentinel")?(P={touchAction:"manipulation",minHeight:0,minWidth:0},W=t.jsx(q,{name:"check",className:"size-4"}),e[38]=P,e[39]=W):(P=e[38],W=e[39]);let I;e[40]!==T?(I=t.jsx("button",{type:"submit","aria-label":T,className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:P,children:W}),e[40]=T,e[41]=I):I=e[41];let _;e[42]!==f?(_=f("sessions.sidebar.session.rename.cancel"),e[42]=f,e[43]=_):_=e[43];let F,M;e[44]===Symbol.for("react.memo_cache_sentinel")?(F={touchAction:"manipulation",minHeight:0,minWidth:0},M=t.jsx(q,{name:"close",className:"size-4"}),e[44]=F,e[45]=M):(F=e[44],M=e[45]);let K;e[46]!==l||e[47]!==_?(K=t.jsx("button",{type:"button",onClick:l,"aria-label":_,className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:F,children:M}),e[46]=l,e[47]=_,e[48]=K):K=e[48];let X;return e[49]!==v||e[50]!==B||e[51]!==b||e[52]!==I||e[53]!==K||e[54]!==k||e[55]!==x?(X=t.jsxs("form",{className:b,style:k,onSubmit:x,children:[v,B,I,K]}),e[49]=v,e[50]=B,e[51]=b,e[52]=I,e[53]=K,e[54]=k,e[55]=x,e[56]=X):X=e[56],X};function Zf(n){n&&(n.focus(),n.select())}const Xs=48,xa=4*Xs,em=180,Vn=n=>{const e=me.c(27),{actionsWidth:s,actions:i,revealed:r,onRevealedChange:o,dataActiveSession:a,contentClassName:l,children:f}=n,c=l===void 0?"relative flex w-full items-center bg-background":l,m=u.useRef(null),g=u.useRef(null),p=u.useRef(!1),h=u.useRef(0),b=u.useRef(r);let k;e[0]===Symbol.for("react.memo_cache_sentinel")?(k=(I,_)=>{const F=m.current;F&&(F.style.transition=_?`transform ${em}ms ease-out`:"none",F.style.transform=I===0?"none":`translateX(${I}px)`,h.current=I)},e[0]=k):k=e[0];const x=k;let R,N;e[1]!==s||e[2]!==r?(R=()=>{b.current=r,x(r?s:0,!0)},N=[s,x,r],e[1]=s,e[2]=r,e[3]=R,e[4]=N):(R=e[3],N=e[4]),u.useEffect(R,N);let A;e[5]===Symbol.for("react.memo_cache_sentinel")?(A=I=>{if(I.touches.length!==1)return;const _=I.touches[0];g.current={x:_.clientX,y:_.clientY},p.current=!1},e[5]=A):A=e[5];const E=A;let j;e[6]!==s?(j=I=>{if(!g.current)return;const _=I.touches[0],F=_.clientX-g.current.x,M=_.clientY-g.current.y;if(!p.current){if(Math.abs(F)<8||Math.abs(F)<=Math.abs(M))return;p.current=!0}const K=b.current?s:0;x(Math.max(0,Math.min(s,K+F)),!1)},e[6]=s,e[7]=j):j=e[7];const v=j;let S;e[8]!==s||e[9]!==o?(S=()=>{if(g.current=null,!p.current)return;p.current=!1;const I=h.current>s/2;x(I?s:0,!0),I!==b.current&&o(I)},e[8]=s,e[9]=o,e[10]=S):S=e[10];const w=S,C=a||void 0;let O;e[11]===Symbol.for("react.memo_cache_sentinel")?(O={touchAction:"pan-y"},e[11]=O):O=e[11];let z;e[12]!==s?(z={width:s},e[12]=s,e[13]=z):z=e[13];const B=!r;let T;e[14]!==i||e[15]!==z||e[16]!==B?(T=t.jsx("div",{className:"absolute inset-y-0 left-0 flex items-stretch",style:z,"aria-hidden":B,children:i}),e[14]=i,e[15]=z,e[16]=B,e[17]=T):T=e[17];let P;e[18]!==f||e[19]!==c?(P=t.jsx("div",{ref:m,className:c,children:f}),e[18]=f,e[19]=c,e[20]=P):P=e[20];let W;return e[21]!==w||e[22]!==v||e[23]!==T||e[24]!==P||e[25]!==C?(W=t.jsxs("div",{"data-active-session":C,className:"relative overflow-hidden",onTouchStart:E,onTouchMove:v,onTouchEnd:w,onTouchCancel:w,style:O,children:[T,P]}),e[21]=w,e[22]=v,e[23]=T,e[24]=P,e[25]=C,e[26]=W):W=e[26],W},ya=n=>{const e=me.c(62),{sessionId:s,title:i,revealed:r,confirmingDelete:o,onArchive:a,onRequestDelete:l,onConfirmDelete:f,onRequestRename:c,onRevealedChange:m,work:g,pin:p}=n,{t:h}=ye(),b=r?0:-1;let k;e[0]!==m||e[1]!==s||e[2]!==h?(k=async()=>{if(!(await wo(s).catch(tm))?.ok){Nr.error(h("sessions.sidebar.session.copyId.error"));return}m?.(!1),Nr.success(h("sessions.sidebar.session.copyId.success"))},e[0]=m,e[1]=s,e[2]=h,e[3]=k):k=e[3];const x=k;let R;e[4]!==h||e[5]!==i?(R=h("mobile.sessions.archiveSessionAria",{title:i}),e[4]=h,e[5]=i,e[6]=R):R=e[6];let N,A;e[7]===Symbol.for("react.memo_cache_sentinel")?(N={touchAction:"manipulation"},A=t.jsx(Zu,{className:"size-[18px]"}),e[7]=N,e[8]=A):(N=e[7],A=e[8]);let E;e[9]!==a||e[10]!==R||e[11]!==b?(E=t.jsx("button",{type:"button",tabIndex:b,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":R,onClick:a,style:N,children:A}),e[9]=a,e[10]=R,e[11]=b,e[12]=E):E=e[12];let j;e[13]!==m||e[14]!==p||e[15]!==h||e[16]!==b?(j=p?t.jsx("button",{type:"button",tabIndex:b,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":p.pinned?h("sessions.sidebar.session.menu.unpin"):h("sessions.sidebar.session.menu.pin"),onClick:()=>{p.onToggle(),m?.(!1)},style:{touchAction:"manipulation"},children:t.jsx(q,{name:p.pinned?"unpin":"pushpin",className:"size-[18px]"})}):null,e[13]=m,e[14]=p,e[15]=h,e[16]=b,e[17]=j):j=e[17];let v;e[18]!==m||e[19]!==h||e[20]!==b||e[21]!==g?(v=g?t.jsx("button",{type:"button",tabIndex:b,className:Q("flex flex-1 items-center justify-center transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",g.inWork?"text-status-success":"text-muted-foreground active:text-foreground"),"aria-label":g.inWork?h("sessions.sidebar.session.work.markDone"):h("sessions.sidebar.session.work.track"),onClick:()=>{g.onToggle(),m?.(!1)},style:{touchAction:"manipulation"},children:t.jsx(q,{name:g.inWork?"check":"eye",className:g.inWork?"size-5":"size-[18px]"})}):null,e[18]=m,e[19]=h,e[20]=b,e[21]=g,e[22]=v):v=e[22];const S=o?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80";let w;e[23]!==S?(w=Q("flex flex-1 items-center justify-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive",S),e[23]=S,e[24]=w):w=e[24];let C;e[25]!==o||e[26]!==h||e[27]!==i?(C=o?h("mobile.sessions.confirmDeleteSessionAria",{title:i}):h("mobile.sessions.deleteSessionAria",{title:i}),e[25]=o,e[26]=h,e[27]=i,e[28]=C):C=e[28];const O=o?f:l;let z,B;e[29]===Symbol.for("react.memo_cache_sentinel")?(z={touchAction:"manipulation"},B=t.jsx(On,{className:"size-[18px]"}),e[29]=z,e[30]=B):(z=e[29],B=e[30]);let T;e[31]!==C||e[32]!==O||e[33]!==w||e[34]!==b?(T=t.jsx("button",{type:"button",tabIndex:b,className:w,"aria-label":C,onClick:O,style:z,children:B}),e[31]=C,e[32]=O,e[33]=w,e[34]=b,e[35]=T):T=e[35];let P;e[36]!==h||e[37]!==i?(P=h("mobile.sessions.renameSessionAria",{title:i}),e[36]=h,e[37]=i,e[38]=P):P=e[38];let W,I;e[39]===Symbol.for("react.memo_cache_sentinel")?(W={touchAction:"manipulation"},I=t.jsx(Sr,{className:"size-[18px]"}),e[39]=W,e[40]=I):(W=e[39],I=e[40]);let _;e[41]!==c||e[42]!==P||e[43]!==b?(_=t.jsx("button",{type:"button",tabIndex:b,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":P,onClick:c,style:W,children:I}),e[41]=c,e[42]=P,e[43]=b,e[44]=_):_=e[44];let F;e[45]!==h?(F=h("sessions.sidebar.session.menu.copyId"),e[45]=h,e[46]=F):F=e[46];let M;e[47]!==x?(M=()=>{x()},e[47]=x,e[48]=M):M=e[48];let K,X;e[49]===Symbol.for("react.memo_cache_sentinel")?(K={touchAction:"manipulation"},X=t.jsx(q,{name:"file-copy",className:"size-[18px]"}),e[49]=K,e[50]=X):(K=e[49],X=e[50]);let Z;e[51]!==F||e[52]!==M||e[53]!==b?(Z=t.jsx("button",{type:"button",tabIndex:b,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":F,onClick:M,style:K,children:X}),e[51]=F,e[52]=M,e[53]=b,e[54]=Z):Z=e[54];let ee;return e[55]!==T||e[56]!==_||e[57]!==Z||e[58]!==E||e[59]!==j||e[60]!==v?(ee=t.jsxs(t.Fragment,{children:[E,j,v,T,_,Z]}),e[55]=T,e[56]=_,e[57]=Z,e[58]=E,e[59]=j,e[60]=v,e[61]=ee):ee=e[61],ee};function tm(){return null}const jt=n=>n.parentID??null,kt=n=>{const e=n;return Be(e.directory??e.project?.worktree??null)},va=n=>{const e=n.time?.updated??n.time?.created,s=typeof e=="number"?e:Number(e);return Number.isFinite(s)&&s>0?s:0},Hn=n=>{if(n<=0)return"";const e=Date.now()-n;if(e<6e4)return"now";const s=Math.floor(e/6e4);if(s<60)return`${s}m`;const i=Math.floor(s/60);if(i<24)return`${i}h`;const r=Math.floor(i/24);return r<7?`${r}d`:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(n))},sm=4,wa=n=>{const e=me.c(4),{providerIDs:s}=n;let i;e[0]!==s?(i=s.slice(0,sm).map(nm),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=t.jsx("span",{className:"inline-flex shrink-0 items-center -space-x-1",children:i}),e[2]=i,e[3]=r):r=e[3],r};function nm(n){return t.jsx("span",{className:"inline-flex size-4 items-center justify-center rounded-full bg-background ring-1 ring-background",children:t.jsx(jo,{providerId:n,className:"size-3 opacity-80"})},n)}const ja=n=>{const e=me.c(8),{session:s}=n,{t:i}=ye(),r=Po(s);if(!r)return null;const o=pl[r.status];let a;e[0]!==i||e[1]!==o?(a=i(o),e[0]=i,e[1]=o,e[2]=a):a=e[2];const l=a,f=hl[r.status];let c;e[3]!==f?(c={color:f},e[3]=f,e[4]=c):c=e[4];let m;return e[5]!==l||e[6]!==c?(m=t.jsx(q,{name:"target",className:"size-3.5 shrink-0",style:c,"aria-label":l}),e[5]=l,e[6]=c,e[7]=m):m=e[7],m},ka=n=>{const e=me.c(12),{permissionCount:s,formCount:i}=n,{t:r}=ye();if(s===0&&i===0)return null;let o;e[0]!==i||e[1]!==r?(o=i===1?r("sessions.sidebar.session.status.questionPendingSingle"):r("sessions.sidebar.session.status.questionPendingMany",{count:i}),e[0]=i,e[1]=r,e[2]=o):o=e[2];const a=o;let l;e[3]!==s||e[4]!==r?(l=s>0?t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive","aria-label":r("sessions.sidebar.session.status.permissionRequired"),children:[t.jsx(q,{name:"shield",className:"size-3"}),t.jsx("span",{className:"leading-none tabular-nums",children:s})]}):null,e[3]=s,e[4]=r,e[5]=l):l=e[5];let f;e[6]!==i||e[7]!==a?(f=i>0?t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded bg-status-info/10 px-1 py-0.5 text-[0.7rem] text-status-info","aria-label":a,children:[t.jsx(q,{name:"question",className:"size-3"}),t.jsx("span",{className:"leading-none tabular-nums",children:i})]}):null,e[6]=i,e[7]=a,e[8]=f):f=e[8];let c;return e[9]!==l||e[10]!==f?(c=t.jsxs(t.Fragment,{children:[l,f]}),e[9]=l,e[10]=f,e[11]=c):c=e[11],c},Sa=n=>{const e=me.c(7);let s;e[0]!==n?(s=l=>{let f=0;for(const c of n)f=f+(l.bySession.get(c)?.permissions.length??0);return f},e[0]=n,e[1]=s):s=e[1];const i=Ci(s);let r;e[2]!==n?(r=l=>{let f=0;for(const c of n)f=f+(l.bySession.get(c)?.forms.length??0);return f},e[2]=n,e[3]=r):r=e[3];const o=Ci(r);let a;return e[4]!==o||e[5]!==i?(a={permissionCount:i,formCount:o},e[4]=o,e[5]=i,e[6]=a):a=e[6],a},Ir=12,Ar="flex min-w-0 flex-1 flex-col gap-1 py-2.5 pr-3 text-left",rm=n=>{const e=me.c(54),{entry:s}=n,{t:i}=ye(),{run:r,project:o}=s;let a;e[0]!==r.key?(a=M=>M.runOverviewKey===r.key,e[0]=r.key,e[1]=a):a=e[1];const l=Me(a);let f;e[2]!==s.laneNodes?(f={nodes:s.laneNodes,includeUnreadSubtasks:!1},e[2]=s.laneNodes,e[3]=f):f=e[3];const c=Wo(f);let m;e[4]!==r.lastActivity?(m=Hn(r.lastActivity),e[4]=r.lastActivity,e[5]=m):m=e[5];const g=m,p=r.lanes.length,h=l||void 0,b=l&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let k;e[6]!==b?(k=Q("relative bg-background transition-colors",b),e[6]=b,e[7]=k):k=e[7];let x,R;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=Q(Ar,"w-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"),R={paddingLeft:Ir,touchAction:"manipulation"},e[8]=x,e[9]=R):(x=e[8],R=e[9]);let N;e[10]!==r.key?(N=()=>Me.getState().setRunOverviewKey(r.key),e[10]=r.key,e[11]=N):N=e[11];let A;e[12]!==r.title||e[13]!==i?(A=i("sessions.sidebar.run.openOverviewAria",{title:r.title}),e[12]=r.title,e[13]=i,e[14]=A):A=e[14];let E;e[15]!==o?(E=t.jsx(Ys,{project:o,size:"sm"}),e[15]=o,e[16]=E):E=e[16];let j;e[17]!==o.label?(j=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-micro text-muted-foreground",children:o.label}),e[17]=o.label,e[18]=j):j=e[18];let v;e[19]!==c?(v=c?t.jsx(Uo,{state:c}):null,e[19]=c,e[20]=v):v=e[20];let S;e[21]!==g?(S=g?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:g}):null,e[21]=g,e[22]=S):S=e[22];let w;e[23]!==E||e[24]!==j||e[25]!==v||e[26]!==S?(w=t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[E,j,v,S]}),e[23]=E,e[24]=j,e[25]=v,e[26]=S,e[27]=w):w=e[27];const C=l?"text-primary":"text-foreground";let O;e[28]!==C?(O=Q("block min-w-0 truncate text-left typography-ui-label",C),e[28]=C,e[29]=O):O=e[29];let z;e[30]!==r.title||e[31]!==O?(z=t.jsx("span",{dir:"auto",className:O,children:r.title}),e[30]=r.title,e[31]=O,e[32]=z):z=e[32];let B;e[33]===Symbol.for("react.memo_cache_sentinel")?(B=t.jsx(Do,{className:"size-3.5 shrink-0","aria-hidden":"true"}),e[33]=B):B=e[33];let T;e[34]!==p||e[35]!==i?(T=p===1?i("sessions.sidebar.run.laneCountSingle",{count:p}):i("sessions.sidebar.run.laneCountPlural",{count:p}),e[34]=p,e[35]=i,e[36]=T):T=e[36];let P;e[37]!==T?(P=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-micro",children:T}),e[37]=T,e[38]=P):P=e[38];let W;e[39]!==r.providerIDs?(W=t.jsx(wa,{providerIDs:r.providerIDs}),e[39]=r.providerIDs,e[40]=W):W=e[40];let I;e[41]!==P||e[42]!==W?(I=t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[B,P,W]}),e[41]=P,e[42]=W,e[43]=I):I=e[43];let _;e[44]!==A||e[45]!==w||e[46]!==z||e[47]!==I||e[48]!==N?(_=t.jsxs("button",{type:"button",className:x,style:R,onClick:N,"aria-label":A,children:[w,z,I]}),e[44]=A,e[45]=w,e[46]=z,e[47]=I,e[48]=N,e[49]=_):_=e[49];let F;return e[50]!==_||e[51]!==h||e[52]!==k?(F=t.jsx("div",{"data-active-session":h,className:k,children:_}),e[50]=_,e[51]=h,e[52]=k,e[53]=F):F=e[53],F},im=n=>{const e=me.c(118),{entry:s,active:i,revealed:r,confirmingDelete:o,renaming:a,handlers:l}=n,{t:f}=ye(),{session:c,project:m,branch:g,inSpace:p}=s;let h;e[0]!==c.title||e[1]!==f?(h=c.title?.trim()||f("mobile.sessions.untitled"),e[0]=c.title,e[1]=f,e[2]=h):h=e[2];const b=h;let k;e[3]!==c?(k=Hn(va(c)),e[3]=c,e[4]=k):k=e[4];const x=k,R=Vo(c.id,c.directory,r||a),N=Dr(c.id),A=_r(c.id),E=A!==null,j=!E&&N>0&&!i,v=Mr(c.id,E),S=(E||j)&&v,w=l.onToggleWork;let C;e[5]!==c?(C=To(c),e[5]=c,e[6]=C):C=e[6];const O=C;let z;e[7]!==O||e[8]!==w||e[9]!==c?(z=w?{inWork:O,onToggle:()=>w(c,O)}:void 0,e[7]=O,e[8]=w,e[9]=c,e[10]=z):z=e[10];const B=z;let T;e[11]!==l||e[12]!==c?(T=l.isPinned(c),e[11]=l,e[12]=c,e[13]=T):T=e[13];const P=T;let W;e[14]!==l||e[15]!==c?(W=()=>l.onTogglePin(c),e[14]=l,e[15]=c,e[16]=W):W=e[16];let I;e[17]!==P||e[18]!==W?(I={pinned:P,onToggle:W},e[17]=P,e[18]=W,e[19]=I):I=e[19];const _=I,{descendantIdsOf:F}=l;let M;e[20]!==F||e[21]!==c.id?(M=[c.id,...F(c.id)],e[20]=F,e[21]=c.id,e[22]=M):M=e[22];const X=Sa(M),Z=X.permissionCount>0||X.formCount>0;let ee;e[23]!==c?(ee=Po(c),e[23]=c,e[24]=ee):ee=e[24];const Y=ee!==null,pe=xa+Xs+(B?Xs:0);let fe;e[25]!==l||e[26]!==c.id?(fe=be=>l.onRevealedChange(c.id,be),e[25]=l,e[26]=c.id,e[27]=fe):fe=e[27];const re=i&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let $;e[28]!==re?($=Q("relative flex w-full items-center bg-background transition-colors",re),e[28]=re,e[29]=$):$=e[29];let D;e[30]!==l||e[31]!==c?(D=()=>l.onArchive(c),e[30]=l,e[31]=c,e[32]=D):D=e[32];let se;e[33]!==l||e[34]!==c.id?(se=()=>l.onRequestDelete(c.id),e[33]=l,e[34]=c.id,e[35]=se):se=e[35];let te;e[36]!==l||e[37]!==c?(te=()=>l.onConfirmDelete(c),e[36]=l,e[37]=c,e[38]=te):te=e[38];let ie,G;e[39]!==l||e[40]!==c.id?(ie=()=>l.onRequestRename(c.id),G=be=>l.onRevealedChange(c.id,be),e[39]=l,e[40]=c.id,e[41]=ie,e[42]=G):(ie=e[41],G=e[42]);let oe;e[43]!==o||e[44]!==_||e[45]!==r||e[46]!==c.id||e[47]!==D||e[48]!==se||e[49]!==te||e[50]!==ie||e[51]!==G||e[52]!==b||e[53]!==B?(oe=t.jsx(ya,{sessionId:c.id,title:b,revealed:r,confirmingDelete:o,onArchive:D,onRequestDelete:se,onConfirmDelete:te,onRequestRename:ie,onRevealedChange:G,work:B,pin:_}),e[43]=o,e[44]=_,e[45]=r,e[46]=c.id,e[47]=D,e[48]=se,e[49]=te,e[50]=ie,e[51]=G,e[52]=b,e[53]=B,e[54]=oe):oe=e[54];let ue;e:{let be;e[55]!==m?(be=t.jsx(Ys,{project:m,size:"sm"}),e[55]=m,e[56]=be):be=e[56];let Se;e[57]!==m.label?(Se=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-micro text-muted-foreground",children:m.label}),e[57]=m.label,e[58]=Se):Se=e[58];let he;e[59]!==P||e[60]!==f?(he=P?t.jsx(q,{name:"pushpin",className:"size-3 shrink-0 text-muted-foreground","aria-label":f("sessions.sidebar.session.status.pinned")}):null,e[59]=P,e[60]=f,e[61]=he):he=e[61];let Pe;e[62]!==R.pending||e[63]!==E||e[64]!==j||e[65]!==f||e[66]!==A?(Pe=R.pending?t.jsx(q,{name:"loader-4",className:"size-3 shrink-0 animate-spin text-primary","aria-label":f("sessions.aiRename.generating")}):E||j?t.jsx(Mn,{state:A??"unread"}):null,e[62]=R.pending,e[63]=E,e[64]=j,e[65]=f,e[66]=A,e[67]=Pe):Pe=e[67];let H;e[68]!==E||e[69]!==c.id||e[70]!==S||e[71]!==x?(H=S?t.jsx(Or,{sessionId:c.id,running:E,className:"shrink-0 typography-micro"}):x?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:x}):null,e[68]=E,e[69]=c.id,e[70]=S,e[71]=x,e[72]=H):H=e[72];let ae;e[73]!==be||e[74]!==Se||e[75]!==he||e[76]!==Pe||e[77]!==H?(ae=t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[be,Se,he,Pe,H]}),e[73]=be,e[74]=Se,e[75]=he,e[76]=Pe,e[77]=H,e[78]=ae):ae=e[78];let Re;e[79]!==i||e[80]!==R||e[81]!==l||e[82]!==a||e[83]!==c.id||e[84]!==b?(Re=a?t.jsx(ba,{initialTitle:b,indent:0,aiRename:R,className:"h-[1lh] pr-0 typography-ui-label [&_button]:size-6 [&_button>svg]:size-3.5",onSubmit:Xe=>l.onSubmitRename(c.id,Xe),onCancel:l.onCancelRename}):t.jsx("span",{dir:"auto",className:Q("block min-w-0 truncate text-left typography-ui-label",i?"text-primary":"text-foreground"),children:b}),e[79]=i,e[80]=R,e[81]=l,e[82]=a,e[83]=c.id,e[84]=b,e[85]=Re):Re=e[85];let Ae;e[86]!==g||e[87]!==Y||e[88]!==Z||e[89]!==p||e[90]!==X||e[91]!==c||e[92]!==f?(Ae=g||Y||Z?t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[g?t.jsxs(t.Fragment,{children:[p?t.jsx(q,{name:"box-3",className:"size-3.5 shrink-0","aria-hidden":!1,role:"img","aria-label":f("sessions.sidebar.group.space")}):t.jsx(q,{name:"git-branch",className:"size-3.5 shrink-0"}),t.jsx("span",{className:"block min-w-0 truncate typography-micro",children:g})]}):null,t.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[t.jsx(ja,{session:c}),t.jsx(ka,{...X})]})]}):null,e[86]=g,e[87]=Y,e[88]=Z,e[89]=p,e[90]=X,e[91]=c,e[92]=f,e[93]=Ae):Ae=e[93];let Ee;e[94]!==ae||e[95]!==Re||e[96]!==Ae?(Ee=t.jsxs(t.Fragment,{children:[ae,Re,Ae]}),e[94]=ae,e[95]=Re,e[96]=Ae,e[97]=Ee):Ee=e[97];const Te=Ee;if(a){let Xe;e[98]===Symbol.for("react.memo_cache_sentinel")?(Xe={paddingLeft:Ir},e[98]=Xe):Xe=e[98];let _t;e[99]!==Te?(_t=t.jsx("div",{className:Ar,style:Xe,children:Te}),e[99]=Te,e[100]=_t):_t=e[100],ue=_t;break e}let Je,Le;e[101]===Symbol.for("react.memo_cache_sentinel")?(Je=Q(Ar,"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"),Le={paddingLeft:Ir,touchAction:"manipulation"},e[101]=Je,e[102]=Le):(Je=e[101],Le=e[102]);let Fe;e[103]!==l||e[104]!==r||e[105]!==c?(Fe=()=>{if(r){l.onRevealedChange(c.id,!1);return}l.onSelect(c)},e[103]=l,e[104]=r,e[105]=c,e[106]=Fe):Fe=e[106];let bt;e[107]!==Te||e[108]!==Fe?(bt=t.jsx("button",{type:"button",className:Je,style:Le,onClick:Fe,children:Te}),e[107]=Te,e[108]=Fe,e[109]=bt):bt=e[109],ue=bt}let Ce;return e[110]!==i||e[111]!==r||e[112]!==pe||e[113]!==fe||e[114]!==$||e[115]!==oe||e[116]!==ue?(Ce=t.jsx(Vn,{actionsWidth:pe,revealed:r,onRevealedChange:fe,dataActiveSession:i,contentClassName:$,actions:oe,children:ue}),e[110]=i,e[111]=r,e[112]=pe,e[113]=fe,e[114]=$,e[115]=oe,e[116]=ue,e[117]=Ce):Ce=e[117],Ce},om=n=>{const e=me.c(9),{scrollRootRef:s,visibleCount:i,onReachEnd:r}=n,o=u.useRef(null),a=u.useRef(r);let l,f;e[0]!==r?(l=()=>{a.current=r},f=[r],e[0]=r,e[1]=l,e[2]=f):(l=e[1],f=e[2]),u.useEffect(l,f);let c;e[3]!==s?(c=()=>{const p=o.current;if(!p)return;const h=new IntersectionObserver(b=>{b.some(lm)&&a.current()},{root:s.current??null,rootMargin:"400px 0px"});return h.observe(p),()=>h.disconnect()},e[3]=s,e[4]=c):c=e[4];let m;e[5]!==s||e[6]!==i?(m=[s,i],e[5]=s,e[6]=i,e[7]=m):m=e[7],u.useEffect(c,m);let g;return e[8]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx("div",{ref:o,"aria-hidden":!0,className:"h-px w-full"}),e[8]=g):g=e[8],g},am=n=>{const e=me.c(35),{entries:s,visibleCount:i,onRevealMore:r,scrollRootRef:o,handlers:a}=n,{t:l}=ye();let f,c,m,g,p;if(e[0]!==s||e[1]!==a||e[2]!==l||e[3]!==i){p=s.slice(0,i),m="border-t border-border/70";let x;e[9]===Symbol.for("react.memo_cache_sentinel")?(x=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:"folder-6",className:"size-4"})}),e[9]=x):x=e[9];let R;e[10]!==l?(R=l("mobile.sessions.section.projects"),e[10]=l,e[11]=R):R=e[11];let N;e[12]!==R?(N=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:R}),e[12]=R,e[13]=N):N=e[13];let A;e[14]!==s.length?(A=t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:s.length}),e[14]=s.length,e[15]=A):A=e[15],e[16]!==N||e[17]!==A?(g=t.jsxs("div",{className:"flex min-h-12 w-full items-center gap-2 px-3 py-1.5",children:[x,N,A]}),e[16]=N,e[17]=A,e[18]=g):g=e[18],f="pb-2";let E;e[19]!==a?(E=j=>j.kind==="run"?t.jsx(rm,{entry:j},`run:${j.run.key}`):t.jsx(im,{entry:j,active:a.currentSessionId===j.session.id,revealed:a.revealedSessionId===j.session.id,confirmingDelete:a.confirmingDeleteSessionId===j.session.id,renaming:a.renamingSessionId===j.session.id,handlers:a},j.session.id),e[19]=a,e[20]=E):E=e[20],c=p.map(E),e[0]=s,e[1]=a,e[2]=l,e[3]=i,e[4]=f,e[5]=c,e[6]=m,e[7]=g,e[8]=p}else f=e[4],c=e[5],m=e[6],g=e[7],p=e[8];let h;e[21]!==s.length||e[22]!==r||e[23]!==o||e[24]!==i||e[25]!==p.length?(h=p.length<s.length?t.jsx(om,{scrollRootRef:o,visibleCount:i,onReachEnd:r}):null,e[21]=s.length,e[22]=r,e[23]=o,e[24]=i,e[25]=p.length,e[26]=h):h=e[26];let b;e[27]!==f||e[28]!==c||e[29]!==h?(b=t.jsxs("div",{className:f,children:[c,h]}),e[27]=f,e[28]=c,e[29]=h,e[30]=b):b=e[30];let k;return e[31]!==m||e[32]!==g||e[33]!==b?(k=t.jsxs("section",{className:m,children:[g,b]}),e[31]=m,e[32]=g,e[33]=b,e[34]=k):k=e[34],k};function lm(n){return n.isIntersecting}const _n=40,cm=(n,e)=>Math.min(e,Math.max(n,0)+_n),Yi="mobile-surface-root",gr=16,An=200,um=()=>{if(typeof document>"u")return null;let n=document.getElementById(Yi);return n||(n=document.createElement("div"),n.id=Yi,document.body.appendChild(n)),n},Tt=({open:n,onClose:e,title:s,subtitle:i,trailing:r,disableEscapeDismiss:o=!1,headerless:a=!1,noHeaderBorder:l=!1,ariaLabel:f,variant:c="fullscreen",dialogAlign:m="chat",children:g})=>{const{t:p}=ye(),h=u.useRef(null),[b,k]=u.useState(!1),[x,R]=u.useState(!1),N=u.useRef(null),A=u.useRef(null),E=u.useRef(e);if(u.useEffect(()=>{E.current=e},[e]),typeof document<"u"&&!h.current&&(h.current=um()),u.useEffect(()=>{if(!n){k(!1);return}const S=window.setTimeout(()=>k(!0),gr);return()=>window.clearTimeout(S)},[n]),u.useEffect(()=>{if(!n){R(!1);return}const S=window.setTimeout(()=>R(!0),gr+An+80);return()=>window.clearTimeout(S)},[n]),u.useEffect(()=>{if(!n)return;const S=document.body.style.overflow;A.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow="hidden";const w=()=>{const z=N.current;if(!z)return;(z.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??z).focus({preventScroll:!0})},C=window.setTimeout(w,gr),O=z=>{if(z.key==="Escape"&&!o){E.current();return}if(z.key!=="Tab")return;const B=N.current;if(!B)return;const T=Array.from(B.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(_=>!_.hasAttribute("disabled")&&_.getAttribute("aria-hidden")!=="true");if(T.length===0){z.preventDefault(),B.focus({preventScroll:!0});return}const P=T[0],W=T[T.length-1],I=document.activeElement;z.shiftKey&&I===P?(z.preventDefault(),W.focus({preventScroll:!0})):!z.shiftKey&&I===W&&(z.preventDefault(),P.focus({preventScroll:!0}))};return document.addEventListener("keydown",O),()=>{window.clearTimeout(C),document.body.style.overflow=S,document.removeEventListener("keydown",O),A.current?.focus?.({preventScroll:!0}),A.current=null}},[o,n]),!n||!h.current)return null;const j=c==="dialog",v=t.jsxs("section",{ref:N,role:"dialog","aria-modal":"true","aria-label":f,tabIndex:-1,className:Q("flex flex-col bg-background text-foreground",j?"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:j?{opacity:b?1:0,transform:b?"none":"scale(0.97)",transition:`opacity ${An}ms ease-out, transform ${An}ms cubic-bezier(0.32, 0.72, 0, 1)`}:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:b?"none":"translateX(100%)",transition:`transform ${An}ms cubic-bezier(0.32, 0.72, 0, 1)`},onTransitionEnd:S=>{b&&S.target===S.currentTarget&&S.propertyName==="transform"&&R(!0)},children:[a?null:t.jsxs("header",{className:Q("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",!l&&"border-b border-border/70"),children:[t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":p("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(q,{name:"close",className:"size-5"})}),t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[s?typeof s=="string"?t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:s}):s:null,i?typeof i=="string"?t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:i}):i:null]}),r?t.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:r}):null]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:x?t.jsx("div",{className:"h-full",style:{animation:"oc-surface-content-in 200ms ease-out"},children:g}):null}),t.jsx("style",{children:"@keyframes oc-surface-content-in { from { opacity: 0 } to { opacity: 1 } }"})]});return j?ys.createPortal(t.jsx("div",{className:"oc-keyboard-inset-surface oc-bottom-safe-surface fixed inset-0 z-50 flex items-center justify-center p-4 transition-opacity duration-200 ease-out",style:{background:"rgb(0 0 0 / 0.45)",opacity:b?1:0,paddingLeft:m==="chat"?"max(1rem, var(--oc-chat-inset-left, 0px))":"1rem",paddingRight:m==="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:S=>S.stopPropagation(),children:v})}),h.current):ys.createPortal(v,h.current)},dm=n=>{const e=me.c(8),{projectPath:s}=n,{t:i}=ye(),{journey:r}=Wa();let o;if(e[0]!==r||e[1]!==s||e[2]!==i){const a=r?Va(r,s):[];let l;e[4]!==i?(l=i("mobile.projectEdit.spacesTitle"),e[4]=i,e[5]=l):l=e[5];let f;e[6]!==l?(f=t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:l}),e[6]=l,e[7]=f):f=e[7],o=t.jsxs("div",{className:"flex flex-col gap-2",children:[f,r!==null&&a.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i("spaces.page.empty")}):null,a.map(hm)]}),e[0]=r,e[1]=s,e[2]=i,e[3]=o}else o=e[3];return o},fm=n=>Zs(n)??"",mm=n=>{const e=me.c(38),{worktree:s,onDelete:i}=n,{t:r}=ye();let o;e[0]!==s.path?(o={id:s.path},e[0]=s.path,e[1]=o):o=e[1];const{attributes:a,listeners:l,setNodeRef:f,transform:c,transition:m,isDragging:g}=Jr(o);let p;e[2]!==c?(p=Yr.Transform.toString(c),e[2]=c,e[3]=p):p=e[3];const h=g?10:1;let b;e[4]!==p||e[5]!==h||e[6]!==m?(b={transform:p,transition:m,zIndex:h},e[4]=p,e[5]=h,e[6]=m,e[7]=b):b=e[7];const k=b,x=s.branch||s.label||s.path,R=Mo(s.path),N=g&&"shadow-lg shadow-black/20",A=R&&"opacity-60";let E;e[8]!==N||e[9]!==A?(E=Q("flex items-center gap-1 rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",N,A),e[8]=N,e[9]=A,e[10]=E):E=e[10];const j=R||void 0;let v;e[11]!==x||e[12]!==r?(v=r("mobile.projectEdit.dragWorktreeAria",{label:x}),e[11]=x,e[12]=r,e[13]=v):v=e[13];let S;e[14]===Symbol.for("react.memo_cache_sentinel")?(S=t.jsx(Lr,{className:"size-4"}),e[14]=S):S=e[14];let w;e[15]!==a||e[16]!==l||e[17]!==v?(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":v,...a,...l,children:S}),e[15]=a,e[16]=l,e[17]=v,e[18]=w):w=e[18];let C;e[19]!==R||e[20]!==r?(C=R?t.jsx("span",{className:"inline-flex shrink-0 text-muted-foreground",role:"status","aria-label":r("sessions.sidebar.group.worktreeRemoving"),children:t.jsx(q,{name:"loader-4",className:"size-4 animate-spin"})}):t.jsx(q,{name:"node-tree",className:"size-4 shrink-0 text-muted-foreground"}),e[19]=R,e[20]=r,e[21]=C):C=e[21];let O;e[22]!==x?(O=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:x}),e[22]=x,e[23]=O):O=e[23];let z;e[24]!==x||e[25]!==i||e[26]!==R||e[27]!==r?(z=R?null:t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive","aria-label":r("mobile.projectEdit.deleteWorktreeAria",{label:x}),onClick:i,style:{touchAction:"manipulation"},children:t.jsx(On,{className:"size-4"})}),e[24]=x,e[25]=i,e[26]=R,e[27]=r,e[28]=z):z=e[28];let B;return e[29]!==f||e[30]!==k||e[31]!==w||e[32]!==C||e[33]!==O||e[34]!==z||e[35]!==E||e[36]!==j?(B=t.jsxs("div",{ref:f,style:k,className:E,"aria-busy":j,children:[w,C,O,z]}),e[29]=f,e[30]=k,e[31]=w,e[32]=C,e[33]=O,e[34]=z,e[35]=E,e[36]=j,e[37]=B):B=e[37],B},pm=({open:n,project:e,onClose:s,onWorktreesChanged:i})=>{const{t:r}=ye(),{currentTheme:o}=Ro(),a=Me(_=>_.isolatedSpacesEnabled),l=ot(_=>_.updateProjectMeta),f=ot(_=>_.discoverProjectIcon),c=ot(_=>_.removeProjectIcon),m=Er(_=>_.setWorktreeOrder),g=ot(_=>e?_.projects.find(F=>F.id===e.id)?.iconImage??null:null),[p,h]=u.useState(""),[b,k]=u.useState(null),[x,R]=u.useState(null),[N,A]=u.useState(!1),[E,j]=u.useState([]),[v,S]=u.useState(null),w=e?.id??null;u.useEffect(()=>{!n||!e||(h(e.label),k(e.icon??null),R(e.color??null),j(e.worktrees))},[n,w]),u.useEffect(()=>{!n||!e||j(_=>{const F=e.worktrees.map(X=>X.path),M=_.map(X=>X.path);return F.length===M.length&&F.every(X=>M.includes(X))?_:e.worktrees})},[e?.worktrees]);const C=$r(ws(Vr,{activationConstraint:{distance:8}}),ws(Wr,{coordinateGetter:Kr})),O=()=>{if(!e)return;const _=p.trim();l(e.id,{label:_||e.label,icon:b,color:x}),s()},z=()=>{!e||N||(A(!0),f(e.id).then(_=>{if(!_.ok){ce.error(_.error||r("projectEditDialog.toast.failedToDiscoverIcon"));return}if(_.skipped){ce.success(r("projectEditDialog.toast.customIconAlreadySet"));return}ce.success(r("projectEditDialog.toast.iconDiscovered"))}).finally(()=>A(!1)))},B=()=>{e&&c(e.id).then(_=>{if(!_.ok){ce.error(_.error||r("projectEditDialog.toast.failedToRemoveIcon"));return}ce.success(r("projectEditDialog.toast.iconRemoved"))})},T=_=>{const{active:F,over:M}=_;if(!M||F.id===M.id||!e)return;const K=E.findIndex(Y=>Y.path===F.id),X=E.findIndex(Y=>Y.path===M.id);if(K<0||X<0)return;const Z=[...E],[ee]=Z.splice(K,1);Z.splice(X,0,ee),j(Z),m(e.id,Z.map(Y=>fm(Y.path)))},P=x?Io[x]??null:null,W=b?Eo[b]:null,I=!!g;return t.jsxs(t.Fragment,{children:[t.jsx(Tt,{open:n,onClose:s,title:r("projectEditDialog.title"),ariaLabel:r("projectEditDialog.title"),noHeaderBorder:!0,trailing:t.jsxs(ke,{type:"button",variant:"default",size:"sm","aria-label":r("projectEditDialog.actions.save"),onClick:O,disabled:!p.trim(),style:{touchAction:"manipulation"},children:[t.jsx(Go,{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:I?t.jsx(Ao,{project:{id:e.id,iconImage:g},options:{themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},className:"size-full object-contain",fallback:t.jsx(kr,{className:"size-7"})}):W?t.jsx(q,{name:W,className:"size-7",style:P?{color:P}:void 0}):t.jsx(kr,{className:"size-7",style:P?{color:P}: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(_o,{value:p,onChange:_=>h(_.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:()=>R(null),"aria-label":r("projectEditDialog.option.none"),className:Q("flex size-9 items-center justify-center rounded-xl border-2 transition-all",x===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"})}),gl.map(_=>t.jsx("button",{type:"button",onClick:()=>R(_.key),"aria-label":_.label,title:_.label,className:Q("size-9 rounded-xl border-2 transition-all",x===_.key?"border-foreground":"border-transparent hover:border-border/70"),style:{backgroundColor:_.cssVar,touchAction:"manipulation"}},_.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:()=>k(null),"aria-label":r("projectEditDialog.option.none"),className:Q("flex size-9 items-center justify-center rounded-xl border-2 transition-all",b===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"})}),bl.map(_=>t.jsx("button",{type:"button",onClick:()=>k(_.key),"aria-label":_.label,title:_.label,className:Q("flex size-9 items-center justify-center rounded-xl border-2 transition-all",b===_.key?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx(q,{name:_.Icon,className:"size-4",style:P?{color:P}:void 0})},_.key))]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[t.jsx(ke,{size:"sm",variant:"outline",onClick:z,disabled:N,children:r(N?"projectEditDialog.actions.discovering":"projectEditDialog.actions.discoverFavicon")}),I?t.jsx(ke,{size:"sm",variant:"outline",onClick:B,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(Ur,{sensors:C,collisionDetection:Gr,onDragEnd:T,children:t.jsx(qr,{items:E.map(_=>_.path),strategy:Hr,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:E.map(_=>t.jsx(mm,{worktree:_,onDelete:()=>S(_)},_.path))})})})]})]}):null,e.isGitRepo&&a?t.jsx(dm,{projectPath:e.path}):null]}):null}),e?t.jsx(ga,{open:!!v,project:{id:e.id,path:e.path},worktree:v,onClose:()=>S(null),onDeleted:()=>{j(_=>_.filter(F=>F.path!==v?.path)),i?.()}}):null]})};function hm(n){return t.jsx(Kc,{entry:n,actions:"sheet"},n.id)}const gm=32,bm=80,xm=64,ym=.7,vm=140,wm=.4,jm=(n,e,s)=>{const i=e.ownerDocument.defaultView;if(!i)return"drawer";let r=!1;for(let o=n instanceof i.Element?n:null;o&&o!==e;o=o.parentElement){const a=o.scrollWidth-o.clientWidth;if(a<=1)continue;const l=i.getComputedStyle(o);if(l.overflowX!=="auto"&&l.overflowX!=="scroll")continue;const f=l.direction==="rtl"?-a:0,c=f+a;if(s?o.scrollLeft>f+1:o.scrollLeft<c-1)return"content";r=!0}return r?"content-end":"drawer"},ai=(n,e)=>{const s=u.useRef(e);s.current=e;const i=e.enabled??!0;u.useEffect(()=>{if(!i)return;const r=n.current;if(!r)return;const a=window.Capacitor?.getPlatform?.()==="android"?bm:gm,l=r.ownerDocument;let f=!1,c=!1,m="drawer",g=0,p=0;const h=()=>l.getSelection()?.isCollapsed===!1,b=()=>{f=!1},k=()=>{f&&h()&&b()},x=N=>{if(N.touches.length!==1||h()){f=!1;return}const A=N.touches[0],E=r.clientWidth,j=A.clientX<=a,v=A.clientX>=E-a;c=j,m=j||v?jm(N.target,r,c):"drawer",f=(j||v)&&m!=="content",g=A.clientX,p=A.clientY},R=N=>{if(!f||(f=!1,h()))return;const A=N.changedTouches[0];if(!A)return;const E=A.clientX-g,j=A.clientY-p,v=m==="content-end"?vm:xm,S=m==="content-end"?wm:ym;Math.abs(E)<v||Math.abs(j)>Math.abs(E)*S||c&&E<=0||!c&&E>=0||(c?s.current.onLeftEdgeSwipe?.():s.current.onRightEdgeSwipe?.())};return r.addEventListener("touchstart",x,{passive:!0}),r.addEventListener("touchend",R,{passive:!0}),r.addEventListener("touchcancel",b,{passive:!0}),r.addEventListener("selectstart",b),l.addEventListener("selectionchange",k),()=>{r.removeEventListener("touchstart",x),r.removeEventListener("touchend",R),r.removeEventListener("touchcancel",b),r.removeEventListener("selectstart",b),l.removeEventListener("selectionchange",k)}},[i,n])},km=new Set,Sm=[["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"]],Nm=[["projects","mobile.sessions.viewMode.projects"],["timeline","mobile.sessions.viewMode.timeline"]],Cm=7,Rm=3,cs=40,Fs="openchamber:work",$s="openchamber:recent",Em=12,Im=16,Am=(n,e)=>{const s=Be(n),i=Be(e),r=i.endsWith("/")?i:`${i}/`;return!!(s&&i&&(s===i||s.startsWith(r)))},br=(n,e)=>n.worktrees.find(s=>Be(s.path)===e)??null,xr=(n,e,s)=>Oo([n.title,n.id,kt(n),e],s),Pm=n=>{const e=me.c(3),{path:s,children:i}=n,r=Mo(s);let o;return e[0]!==i||e[1]!==r?(o=i(r),e[0]=i,e[1]=r,e[2]=o):o=e[2],o},Tm=n=>{const e=me.c(2),{ariaLabel:s}=n;let i;return e[0]!==s?(i=t.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-primary","aria-label":s}),e[0]=s,e[1]=i):i=e[1],i},Xi=n=>{const e=me.c(12),{onClick:s,className:i}=n,{t:r}=ye();let o;e[0]!==r?(o=r("sessions.sidebar.project.actions.newWorktree"),e[0]=r,e[1]=o):o=e[1];const a=o;let l;e[2]!==i?(l=Q("flex size-9 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",i),e[2]=i,e[3]=l):l=e[3];let f;e[4]!==s?(f=p=>{p.stopPropagation(),s()},e[4]=s,e[5]=f):f=e[5];let c,m;e[6]===Symbol.for("react.memo_cache_sentinel")?(c={touchAction:"manipulation"},m=t.jsx(q,{name:"node-tree",className:"size-4"}),e[6]=c,e[7]=m):(c=e[6],m=e[7]);let g;return e[8]!==a||e[9]!==l||e[10]!==f?(g=t.jsx("button",{type:"button",className:l,"aria-label":a,title:a,onClick:f,style:c,children:m}),e[8]=a,e[9]=l,e[10]=f,e[11]=g):g=e[11],g},yr=n=>{const e=me.c(10),{label:s,onClick:i,className:r}=n;let o;e[0]!==r?(o=Q("flex size-9 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",r),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==i?(a=m=>{m.stopPropagation(),i()},e[2]=i,e[3]=a):a=e[3];let l,f;e[4]===Symbol.for("react.memo_cache_sentinel")?(l={touchAction:"manipulation"},f=t.jsx(q,{name:"add",className:"size-4"}),e[4]=l,e[5]=f):(l=e[4],f=e[5]);let c;return e[6]!==s||e[7]!==o||e[8]!==a?(c=t.jsx("button",{type:"button",className:o,"aria-label":s,title:s,onClick:a,style:l,children:f}),e[6]=s,e[7]=o,e[8]=a,e[9]=c):c=e[9],c},Qi=n=>{const e=me.c(83),{session:s,active:i,indent:r,contextLabel:o,statusOnRight:a,hasChildren:l,expanded:f,onToggleChildren:c,onSelect:m,revealed:g,onRevealedChange:p,confirmingDelete:h,onArchive:b,onRequestDelete:k,onConfirmDelete:x,renaming:R,onRequestRename:N,onSubmitRename:A,onCancelRename:E,work:j,pin:v,descendantIdsOf:S}=n,w=a===void 0?!1:a,C=l===void 0?!1:l,O=f===void 0?!1:f,z=g===void 0?!1:g,B=h===void 0?!1:h,T=R===void 0?!1:R,{t:P}=ye();let W;e[0]!==s?(W=Hn(va(s)),e[0]=s,e[1]=W):W=e[1];const I=W;let _;e[2]!==s.title||e[3]!==P?(_=s.title?.trim()||P("mobile.sessions.untitled"),e[2]=s.title,e[3]=P,e[4]=_):_=e[4];const F=_,M=!!(p&&b),K=Vo(s.id,s.directory,M&&(z||T)),X=Dr(s.id),Z=_r(s.id),ee=Z!==null,Y=!ee&&X>0&&!i,pe=Mr(s.id,ee),fe=(ee||Y)&&pe;let re;e[5]!==ee||e[6]!==s||e[7]!==j?.inWork?(re=!!j?.inWork&&!ee&&Nl(s),e[5]=ee,e[6]=s,e[7]=j?.inWork,e[8]=re):re=e[8];const $=re;let D;e[9]!==S||e[10]!==O||e[11]!==C||e[12]!==s.id?(D=S&&!(C&&O)?[s.id,...S(s.id)]:[s.id],e[9]=S,e[10]=O,e[11]=C,e[12]=s.id,e[13]=D):D=e[13];const te=Sa(D);let ie;e[14]!==K||e[15]!==O||e[16]!==C||e[17]!==r||e[18]!==ee||e[19]!==c||e[20]!==Y||e[21]!==w||e[22]!==P||e[23]!==Z?(ie=!w&&(K.pending||ee||Y||C&&c)?t.jsx("button",{type:"button",className:"absolute z-10 flex w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:{left:Math.max(r-32,2),top:0,bottom:0,touchAction:"manipulation"},"aria-label":K.pending?P("sessions.aiRename.generating"):P(O?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),disabled:!C||!c,onClick:ae=>{ae.stopPropagation(),c?.()},children:K.pending?t.jsx(q,{name:"loader-4",className:"size-3 animate-spin text-primary","aria-label":P("sessions.aiRename.generating")}):ee||Y?t.jsx(Mn,{state:Z??"unread"}):t.jsx(Fr,{className:Q("size-[18px] transition-transform duration-150",O?"rotate-0":"-rotate-90")})}):null,e[14]=K,e[15]=O,e[16]=C,e[17]=r,e[18]=ee,e[19]=c,e[20]=Y,e[21]=w,e[22]=P,e[23]=Z,e[24]=ie):ie=e[24];let G;e[25]!==i||e[26]!==K||e[27]!==o||e[28]!==r||e[29]!==ee||e[30]!==E||e[31]!==p||e[32]!==m||e[33]!==A||e[34]!==te||e[35]!==v?.pinned||e[36]!==T||e[37]!==z||e[38]!==s||e[39]!==fe||e[40]!==$||e[41]!==Y||e[42]!==w||e[43]!==P||e[44]!==I||e[45]!==F||e[46]!==Z?(G=T&&A&&E?t.jsx(ba,{initialTitle:F,indent:r,aiRename:K,onSubmit:A,onCancel:E}):t.jsx("button",{type:"button",className:Q("flex min-w-0 flex-1 items-center gap-2.5 pr-3.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",o?"min-h-10 py-1":"h-9"),style:{paddingLeft:r,touchAction:"manipulation"},onClick:()=>{if(z){p?.(!1);return}m()},children:t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[t.jsxs("span",{className:"flex items-center gap-2.5",children:[t.jsx("span",{dir:"auto",className:Q("block min-w-0 flex-1 truncate text-left typography-ui-label",i?"text-primary":"text-foreground"),children:F}),v?.pinned?t.jsx(q,{name:"pushpin",className:"size-3 shrink-0 text-muted-foreground","aria-label":P("sessions.sidebar.session.status.pinned")}):null,w&&(K.pending||ee||Y)?K.pending?t.jsx(q,{name:"loader-4",className:"size-3 shrink-0 animate-spin text-primary","aria-label":P("sessions.aiRename.generating")}):t.jsx(Mn,{state:Z??"unread"}):null,$?t.jsx(q,{name:"check",className:"size-3.5 shrink-0 text-muted-foreground","aria-label":P("sessions.sidebar.session.work.doneSuggested")}):null,t.jsx(ja,{session:s}),t.jsx(ka,{...te}),fe?t.jsx(Or,{sessionId:s.id,running:ee,className:"typography-micro"}):I?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:I}):null]}),o?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:o}):null]})}),e[25]=i,e[26]=K,e[27]=o,e[28]=r,e[29]=ee,e[30]=E,e[31]=p,e[32]=m,e[33]=A,e[34]=te,e[35]=v?.pinned,e[36]=T,e[37]=z,e[38]=s,e[39]=fe,e[40]=$,e[41]=Y,e[42]=w,e[43]=P,e[44]=I,e[45]=F,e[46]=Z,e[47]=G):G=e[47];let oe;e[48]!==ie||e[49]!==G?(oe=t.jsxs(t.Fragment,{children:[ie,G]}),e[48]=ie,e[49]=G,e[50]=oe):oe=e[50];const ue=oe;if(!M){const ae=i||void 0,Re=i&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let Ae;e[51]!==Re?(Ae=Q("relative flex items-center gap-1 transition-colors",Re),e[51]=Re,e[52]=Ae):Ae=e[52];let Ee;e[53]!==ue||e[54]!==Ae?(Ee=t.jsx("div",{className:Ae,children:ue}),e[53]=ue,e[54]=Ae,e[55]=Ee):Ee=e[55];let Te;return e[56]!==ae||e[57]!==Ee?(Te=t.jsx("div",{"data-active-session":ae,className:"relative overflow-hidden",children:Ee}),e[56]=ae,e[57]=Ee,e[58]=Te):Te=e[58],Te}const Ce=xa+(j?Xs:0)+(v?Xs:0);let be;e[59]!==p?(be=ae=>p?.(ae),e[59]=p,e[60]=be):be=e[60];const Se=i&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let he;e[61]!==Se?(he=Q("relative flex w-full items-center gap-1 bg-background transition-colors",Se),e[61]=Se,e[62]=he):he=e[62];let Pe;e[63]!==B||e[64]!==b||e[65]!==x||e[66]!==k||e[67]!==N||e[68]!==p||e[69]!==v||e[70]!==z||e[71]!==s.id||e[72]!==F||e[73]!==j?(Pe=t.jsx(ya,{sessionId:s.id,title:F,revealed:z,confirmingDelete:B,onArchive:b,onRequestDelete:k,onConfirmDelete:x,onRequestRename:N,onRevealedChange:p,work:j,pin:v}),e[63]=B,e[64]=b,e[65]=x,e[66]=k,e[67]=N,e[68]=p,e[69]=v,e[70]=z,e[71]=s.id,e[72]=F,e[73]=j,e[74]=Pe):Pe=e[74];let H;return e[75]!==i||e[76]!==z||e[77]!==ue||e[78]!==Ce||e[79]!==be||e[80]!==he||e[81]!==Pe?(H=t.jsx(Vn,{actionsWidth:Ce,revealed:z,onRevealedChange:be,dataActiveSession:i,contentClassName:he,actions:Pe,children:ue}),e[75]=i,e[76]=z,e[77]=ue,e[78]=Ce,e[79]=be,e[80]=he,e[81]=Pe,e[82]=H):H=e[82],H},Zi=[],Dm=n=>{const e=me.c(40),{run:s,laneNodes:i,indent:r}=n,{t:o}=ye();let a;e[0]!==s.key?(a=z=>z.runOverviewKey===s.key,e[0]=s.key,e[1]=a):a=e[1];const l=Me(a);let f;e[2]!==i?(f={nodes:i,includeUnreadSubtasks:!1},e[2]=i,e[3]=f):f=e[3];const c=Wo(f);let m;e[4]!==s.lastActivity?(m=Hn(s.lastActivity),e[4]=s.lastActivity,e[5]=m):m=e[5];const g=m,p=l||void 0,h=l&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let b;e[6]!==h?(b=Q("relative flex items-center overflow-hidden transition-colors",h),e[6]=h,e[7]=b):b=e[7];let k;e[8]!==c||e[9]!==r?(k=c?t.jsx("span",{className:"absolute flex w-6 items-center justify-center",style:{left:Math.max(r-32,2),top:0,bottom:0},children:t.jsx(Uo,{state:c})}):null,e[8]=c,e[9]=r,e[10]=k):k=e[10];let x;e[11]!==r?(x={paddingLeft:r,touchAction:"manipulation"},e[11]=r,e[12]=x):x=e[12];let R;e[13]!==s.key?(R=()=>Me.getState().setRunOverviewKey(s.key),e[13]=s.key,e[14]=R):R=e[14];let N;e[15]!==s.title||e[16]!==o?(N=o("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[15]=s.title,e[16]=o,e[17]=N):N=e[17];let A;e[18]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx(Do,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[18]=A):A=e[18];const E=l?"text-primary":"text-foreground";let j;e[19]!==E?(j=Q("block min-w-0 flex-1 truncate text-left typography-ui-label",E),e[19]=E,e[20]=j):j=e[20];let v;e[21]!==s.title||e[22]!==j?(v=t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[A,t.jsx("span",{dir:"auto",className:j,children:s.title})]}),e[21]=s.title,e[22]=j,e[23]=v):v=e[23];let S;e[24]!==s.providerIDs?(S=t.jsx(wa,{providerIDs:s.providerIDs}),e[24]=s.providerIDs,e[25]=S):S=e[25];let w;e[26]!==g?(w=g?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:g}):null,e[26]=g,e[27]=w):w=e[27];let C;e[28]!==N||e[29]!==v||e[30]!==S||e[31]!==w||e[32]!==x||e[33]!==R?(C=t.jsxs("button",{type:"button",className:"flex h-9 w-full min-w-0 items-center gap-2.5 pr-3.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:x,onClick:R,"aria-label":N,children:[v,S,w]}),e[28]=N,e[29]=v,e[30]=S,e[31]=w,e[32]=x,e[33]=R,e[34]=C):C=e[34];let O;return e[35]!==C||e[36]!==p||e[37]!==b||e[38]!==k?(O=t.jsxs("div",{"data-active-session":p,className:b,children:[k,C]}),e[35]=C,e[36]=p,e[37]=b,e[38]=k,e[39]=O):O=e[39],O},_m=n=>{const e=me.c(11),{indent:s,onClick:i}=n,{t:r}=ye();let o;e[0]!==s?(o={paddingLeft:s,touchAction:"manipulation"},e[0]=s,e[1]=o):o=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(Fr,{className:"size-4"}),e[2]=a):a=e[2];let l;e[3]!==r?(l=r("sessions.sidebar.group.showMore"),e[3]=r,e[4]=l):l=e[4];let f;e[5]!==l?(f=t.jsx("span",{className:"typography-micro",children:l}),e[5]=l,e[6]=f):f=e[6];let c;return e[7]!==i||e[8]!==o||e[9]!==f?(c=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pr-3 text-left text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:o,onClick:i,children:[a,f]}),e[7]=i,e[8]=o,e[9]=f,e[10]=c):c=e[10],c},Mm=n=>{const e=me.c(11),{indent:s,onClick:i}=n,{t:r}=ye();let o;e[0]!==s?(o={paddingLeft:s,touchAction:"manipulation"},e[0]=s,e[1]=o):o=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(td,{className:"size-4"}),e[2]=a):a=e[2];let l;e[3]!==r?(l=r("sessions.sidebar.group.showFewer"),e[3]=r,e[4]=l):l=e[4];let f;e[5]!==l?(f=t.jsx("span",{className:"typography-micro",children:l}),e[5]=l,e[6]=f):f=e[6];let c;return e[7]!==i||e[8]!==o||e[9]!==f?(c=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pr-3 text-left text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:o,onClick:i,children:[a,f]}),e[7]=i,e[8]=o,e[9]=f,e[10]=c):c=e[10],c},Om=n=>{const e=me.c(29),{worktree:s}=n,{t:i}=ye();let r;e[0]!==s.path?(r=Be(s.path),e[0]=s.path,e[1]=r):r=e[1];const o=r;let a;e[2]!==o?(a={id:o},e[2]=o,e[3]=a):a=e[3];const{attributes:l,listeners:f,setNodeRef:c,transform:m,transition:g,isDragging:p}=Jr(a),h=s.branch||s.label||s.path;let b;e[4]!==m?(b=Yr.Transform.toString(m),e[4]=m,e[5]=b):b=e[5];const k=p?10:1;let x;e[6]!==b||e[7]!==k||e[8]!==g?(x={transform:b,transition:g,zIndex:k},e[6]=b,e[7]=k,e[8]=g,e[9]=x):x=e[9];const R=p&&"shadow-lg shadow-black/20";let N;e[10]!==R?(N=Q("flex items-center gap-1 rounded-xl bg-background px-1 py-1",R),e[10]=R,e[11]=N):N=e[11];let A;e[12]!==h||e[13]!==i?(A=i("mobile.sessions.dragHandleAria",{label:h}),e[12]=h,e[13]=i,e[14]=A):A=e[14];let E;e[15]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx(Lr,{className:"size-4"}),e[15]=E):E=e[15];let j;e[16]!==l||e[17]!==f||e[18]!==A?(j=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":A,...l,...f,children:E}),e[16]=l,e[17]=f,e[18]=A,e[19]=j):j=e[19];let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(q,{name:"git-branch",className:"size-4 shrink-0 text-muted-foreground"}),e[20]=v):v=e[20];let S;e[21]!==h?(S=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-bold text-muted-foreground",children:h}),e[21]=h,e[22]=S):S=e[22];let w;return e[23]!==c||e[24]!==j||e[25]!==S||e[26]!==x||e[27]!==N?(w=t.jsxs("div",{ref:c,style:x,className:N,children:[j,v,S]}),e[23]=c,e[24]=j,e[25]=S,e[26]=x,e[27]=N,e[28]=w):w=e[28],w},zm=n=>{const e=me.c(58),{project:s,expanded:i,onToggleExpanded:r,onReorderWorktrees:o}=n,{t:a}=ye();let l;e[0]!==s.id?(l={id:s.id},e[0]=s.id,e[1]=l):l=e[1];const{attributes:f,listeners:c,setNodeRef:m,transform:g,transition:p,isDragging:h}=Jr(l);let b;e[2]===Symbol.for("react.memo_cache_sentinel")?(b={activationConstraint:{distance:8}},e[2]=b):b=e[2];let k;e[3]===Symbol.for("react.memo_cache_sentinel")?(k={coordinateGetter:Kr},e[3]=k):k=e[3];const x=$r(ws(Vr,b),ws(Wr,k)),R=s.worktrees.length>0;let N;e[4]!==o||e[5]!==s.worktrees?(N=Z=>{const{active:ee,over:Y}=Z;if(!Y||ee.id===Y.id)return;const pe=s.worktrees.map($m),fe=pe.indexOf(String(ee.id)),re=pe.indexOf(String(Y.id));if(fe<0||re<0)return;const $=[...pe],[D]=$.splice(fe,1);$.splice(re,0,D),o($)},e[4]=o,e[5]=s.worktrees,e[6]=N):N=e[6];const A=N;let E;e[7]!==g?(E=Yr.Transform.toString(g),e[7]=g,e[8]=E):E=e[8];const j=h?10:1;let v;e[9]!==E||e[10]!==j||e[11]!==p?(v={transform:E,transition:p,zIndex:j},e[9]=E,e[10]=j,e[11]=p,e[12]=v):v=e[12];const S=h&&"shadow-lg shadow-black/20";let w;e[13]!==S?(w=Q("rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",S),e[13]=S,e[14]=w):w=e[14];let C;e[15]!==s.label||e[16]!==a?(C=a("mobile.sessions.dragHandleAria",{label:s.label}),e[15]=s.label,e[16]=a,e[17]=C):C=e[17];let O;e[18]===Symbol.for("react.memo_cache_sentinel")?(O=t.jsx(Lr,{className:"size-4"}),e[18]=O):O=e[18];let z;e[19]!==f||e[20]!==c||e[21]!==C?(z=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":C,...f,...c,children:O}),e[19]=f,e[20]=c,e[21]=C,e[22]=z):z=e[22];let B;e[23]!==i||e[24]!==s.label||e[25]!==a?(B=i?a("sessions.sidebar.group.collapseAria",{label:s.label}):a("sessions.sidebar.group.expandAria",{label:s.label}),e[23]=i,e[24]=s.label,e[25]=a,e[26]=B):B=e[26];const T=!R;let P;e[27]===Symbol.for("react.memo_cache_sentinel")?(P={touchAction:"manipulation"},e[27]=P):P=e[27];let W;e[28]!==s?(W=t.jsx(Ys,{project:s}),e[28]=s,e[29]=W):W=e[29];let I;e[30]!==s.label?(I=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]=I):I=e[31];let _;e[32]!==i||e[33]!==R?(_=R?t.jsx(Fr,{className:Q("size-4 shrink-0 text-muted-foreground transition-transform",i&&"rotate-180")}):null,e[32]=i,e[33]=R,e[34]=_):_=e[34];let F;e[35]!==i||e[36]!==r||e[37]!==B||e[38]!==T||e[39]!==W||e[40]!==I||e[41]!==_?(F=t.jsxs("button",{type:"button",className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 rounded-xl px-1 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:r,"aria-expanded":i,"aria-label":B,disabled:T,style:P,children:[W,I,_]}),e[35]=i,e[36]=r,e[37]=B,e[38]=T,e[39]=W,e[40]=I,e[41]=_,e[42]=F):F=e[42];let M;e[43]!==z||e[44]!==F?(M=t.jsxs("div",{className:"flex items-center gap-1",children:[z,F]}),e[43]=z,e[44]=F,e[45]=M):M=e[45];let K;e[46]!==i||e[47]!==A||e[48]!==R||e[49]!==s.worktrees||e[50]!==x?(K=i&&R?t.jsx(Ur,{sensors:x,collisionDetection:Gr,onDragEnd:A,children:t.jsx(qr,{items:s.worktrees.map(Wm),strategy:Hr,children:t.jsx("div",{className:"mt-1 flex flex-col gap-0.5 pl-3",children:s.worktrees.map(Vm)})})}):null,e[46]=i,e[47]=A,e[48]=R,e[49]=s.worktrees,e[50]=x,e[51]=K):K=e[51];let X;return e[52]!==m||e[53]!==M||e[54]!==K||e[55]!==v||e[56]!==w?(X=t.jsxs("div",{ref:m,style:v,className:w,children:[M,K]}),e[52]=m,e[53]=M,e[54]=K,e[55]=v,e[56]=w,e[57]=X):X=e[57],X},eo=({open:n,onOpenChange:e,variant:s="drawer",footer:i})=>{const{t:r}=ye(),{git:o}=Un(),a=it(d=>d.ensureStatus),l=No(),f=gs(d=>d.activeSessions),c=n||s==="sidebar",m=u.useRef(km),g=wr(u.useCallback(d=>(c&&(m.current=d.ids),m.current),[c])),p=u.useRef(xl),h=yo(u.useCallback(d=>(c&&(p.current=d.rankById),p.current),[c])),b=ot(d=>d.projects),k=yl(d=>d.projects),x=ot(d=>d.activeProjectId),R=Wt(d=>d.currentDirectory),N=_e(d=>d.currentSessionId),A=_e(d=>d.setCurrentSession),E=_e(d=>d.archiveSession),j=_e(d=>d.archiveSessions),v=_e(d=>d.deleteSession),S=_e(d=>d.deleteSessions),w=_e(d=>d.updateSessionTitle),C=_e(d=>d.openNewSessionDraft),O=ot(d=>d.setActiveProject),z=ot(d=>d.setActiveProjectIdOnly),B=ot(d=>d.reorderProjects),T=ot(d=>d.manualProjectOrder),P=as(d=>d.projectSortOrder),W=as(d=>d.setProjectSortOrder),I=as(d=>d.sidebarViewMode),_=as(d=>d.setSidebarViewMode),F=as(d=>d.showRecentSection),M=as(d=>d.setShowRecentSection),K=wr(d=>d.toggle),X=I==="projects"&&F,Z=vl(c&&(I==="timeline"||X)),ee=ot(d=>d.removeProject),Y=In(d=>d.projectExpanded),pe=In(d=>d.worktreeExpanded),fe=In(d=>d.setProjectExpanded),re=In(d=>d.setWorktreeExpanded),$=Er(d=>d.orderByProject),D=Er(d=>d.setWorktreeOrder),se=Hi(d=>d.expandedParents),te=Hi(d=>d.toggleParent),[ie,G]=u.useState(""),[oe,ue]=u.useState(null),[Ce,be]=u.useState(null),[Se,he]=u.useState(null),[Pe,H]=u.useState(null),[ae,Re]=u.useState(null),[Ae,Ee]=u.useState(null),[Te,Je]=u.useState(null),[Le,Fe]=u.useState(0),[bt,Xe]=u.useState(!1),[_t,Mt]=u.useState(!1),[en,Rs]=u.useState(!1),[tn,sn]=u.useState(null),[ts,at]=u.useState(()=>new Map(_e.getState().availableWorktreesByProject)),[xt,ss]=u.useState(()=>{const d=new Set;for(const[L,V]of _e.getState().availableWorktreesByProject)V.length>0&&d.add(L);return d}),[$e,ns]=u.useState(!1),[nn,Es]=u.useState(new Set),[Jn,Vt]=u.useState(new Map),[Yn,Ct]=u.useState(_n),We=u.useRef(null);u.useEffect(()=>{if(!n){G(""),ns(!1),Es(new Set),Vt(new Map),Ct(_n),ue(null),be(null),he(null),H(null),Re(null),Ee(null);return}ko(l)},[n]),u.useEffect(()=>{$e||Es(new Set)},[$e]),u.useEffect(()=>{Ct(_n)},[I]),u.useEffect(()=>{if(!n||b.length===0)return;let d=!1;return(async()=>{const V=await Promise.all(b.map(async J=>{const le=Be(J.path);if(!le)return null;const ge=await o.checkIsGitRepository(le).catch(()=>null),de=ge?await zo({id:J.id,path:le}).catch(()=>null):[];return[le,de,ge]}));d||(at(J=>{const le=new Map;for(const ge of V){if(!ge)continue;const[de,Ke,nt]=ge,wt=nt===null||Ke===null;le.set(de,wt?J.get(de)??[]:Ke)}return Bo(b,le)}),ss(J=>{const le=new Set;for(const ge of V){if(!ge)continue;const[de,,Ke]=ge;(Ke===null?J.has(de):Ke)&&le.add(de)}return le}))})(),()=>{d=!0}},[o,n,b,Le]);const je=u.useMemo(()=>qc(b.map(d=>({id:d.id,label:d.label?.trim()||hr(d.path),path:Be(d.path),icon:d.icon,color:d.color,iconImage:d.iconImage,iconBackground:d.iconBackground,isGitRepo:xt.has(Be(d.path)),worktrees:Xf($[d.id],ts.get(Be(d.path))??[]),addedAt:d.addedAt,lastOpenedAt:d.lastOpenedAt})),P,T),[xt,T,P,b,$,ts]),et=u.useMemo(()=>{const d=[...f],L=new Set(d.map(V=>V.id));for(const V of l)L.has(V.id)||(L.add(V.id),d.push(V));return d.filter(V=>!V.time?.archived)},[f,l]),pt=u.useMemo(()=>{const d=new Map;for(const L of et){const V=jt(L);if(!V)continue;const J=d.get(V)??[];J.push(L),d.set(V,J)}return d},[et]),Is=u.useCallback(d=>Rn(pt,d),[pt]),{projectSessions:lt,chatSessions:tt}=u.useMemo(()=>Hc(et,!1),[et]),Qe=Me(d=>d.sessionWorkEnabled),Ye=u.useMemo(()=>{const d=new Set;if(!Qe)return d;for(const L of et)if(!(jt(L)||cr(kt(L))||!To(L))){d.add(L.id);for(const V of Rn(pt,L.id))d.add(V)}return d},[pt,Qe,et]),Ue=u.useMemo(()=>Ye.size>0?lt.filter(d=>!Ye.has(d.id)):lt,[lt,Ye]),Ut=u.useMemo(()=>Ye.size>0?tt.filter(d=>!Ye.has(d.id)):tt,[tt,Ye]),rn=Me(d=>d.sessionWorkKeepInGroup)?lt:Ue,Rt=Ua(),Ge=u.useMemo(()=>new Map(Rt.map(d=>[d.id,d])),[Rt]),yt=u.useMemo(()=>new Map(Rt.map(d=>[d.id,d.name||r("sessions.sidebar.grouping.spaceUnnamed")])),[Rt,r]),Ze=u.useMemo(()=>cd(lt,je.map(d=>({id:d.id,normalizedPath:d.path})),new Map(je.map(d=>[d.path,d.worktrees])),!1,[],k,Rt),[k,lt,je,Rt]),ht=u.useMemo(()=>wl(lt,d=>{const L=Ze.bySessionId.get(d.id);return(L?je.find(J=>J.id===L.projectId):void 0)?.path||Be(kt(d))||null}),[lt,je,Ze]),Ie=u.useMemo(()=>{const d=new Map(et.map(J=>[J.id,J])),L=J=>({session:J,children:(pt.get(J.id)??[]).map(L),worktree:null}),V=new Map;for(const J of ht.runs.values())V.set(J.key,J.memberIds.flatMap(le=>{const ge=d.get(le);return ge?[L(ge)]:[]}));return V},[pt,ht,et]),At=u.useMemo(()=>({key:zs,label:"",path:"",worktree:null,space:null,sessions:ls(Ut,g,h)}),[g,Ut,h]),on=u.useMemo(()=>new Set(At.sessions.filter(d=>Ri(g,kt(d)||null,d.id)).map(d=>d.id)),[At,g]),Gt=u.useMemo(()=>({key:Fs,label:"",path:"",worktree:null,space:null,sessions:Ye.size>0?ls(et.filter(d=>Ye.has(d.id)),g,h):[]}),[g,h,et,Ye]),st=Jc({enabled:c&&X,isVSCode:!1,pinnedSessionIds:g,sessionOrderRanks:h,sessions:Ue}),[an,Qn]=u.useState(st);c&&an!==st&&Qn(st);const Ot=c?st:an,ln=u.useMemo(()=>{const d=new Set;for(const L of Ot){d.add(L.id);for(const V of Rn(pt,L.id))d.add(V)}return{key:$s,label:"",path:"",worktree:null,space:null,sessions:d.size>0?ls(Ue.filter(L=>d.has(L.id)),g,h):[]}},[pt,g,Ot,Ue,h]),ct=u.useMemo(()=>{const d=new Map;if(Ot.length===0)return d;const L=Ii({sessions:Ot,projects:je.map(V=>({id:V.id,normalizedPath:V.path,label:V.label})),ownerBySessionId:Ze.bySessionId,availableWorktreesByProject:new Map(je.map(V=>[V.path,V.worktrees])),gitBranches:Z,homeDirectory:null,hideBranchMatchingProjectLabel:!0,spaceLabelById:yt});for(const[V,J]of L)J.projectLabel&&d.set(V,J.branchLabel?`${J.projectLabel} · ${J.branchLabel}`:J.projectLabel);return d},[Z,je,Ot,Ze,yt]),As=`${zs}::${zs}`,cn=u.useMemo(()=>Ut.filter(d=>!jt(d)).length,[Ut]),ze=ie.trim().toLowerCase(),un=u.useRef(null);u.useEffect(()=>{if(!n)return;const d=window.requestAnimationFrame(()=>{const L=un.current;if(!L)return;(L.querySelector('[data-active-session="true"]')??L.querySelector('[data-active-project="true"]'))?.scrollIntoView({block:"center"})});return()=>window.cancelAnimationFrame(d)},[n]);const zt=u.useMemo(()=>{const d=Yc(je,P,V=>V.id,Ze.sessionsByProject).map(V=>({project:V,buckets:[],isActive:V.id===x})),L=(V,J,le,ge=null)=>{const de=Be(J)||V.project.path,Ke=de||"__root__";let nt=V.buckets.find(wt=>wt.key===Ke);return nt||(nt={key:Ke,label:(ge?ge.name||r("sessions.sidebar.grouping.spaceUnnamed"):null)||le?.branch||hr(de),path:de,worktree:le,space:ge,sessions:[]},V.buckets.push(nt)),nt};for(const V of d){L(V,V.project.path,null);for(const J of V.project.worktrees)L(V,J.path,J);for(const J of Rt)J.directory&&Be(J.projectDirectory)===Be(V.project.path)&&L(V,J.directory,null,J)}for(const V of rn){const J=Ze.bySessionId.get(V.id);if(!J)continue;const le=d.find(nt=>nt.project.id===J.projectId);if(!le)continue;const ge=br(le.project,J.scopeDirectory),de=J.kind==="space"&&J.spaceId?Ge.get(J.spaceId)??null:null;(de?L(le,J.scopeDirectory,null,de):ge&&!ht.runKeyBySessionId.has(V.id)?L(le,ge.path,ge):L(le,le.project.path,null)).sessions.push(V)}for(const V of d)for(const J of V.buckets)J.sessions=ls(J.sessions,g,h);return d},[x,g,P,je,ht,rn,h,Ze,Rt,Ge,r]),Kt=Be(R),ut=d=>d.isActive?Kt===d.project.path?d.project.path:d.project.worktrees.find(V=>Am(Kt,V.path))?.path??d.project.path:null,vt=d=>Y[d.project.id]??!0,Ps=(d,L)=>pe[`${d.project.id}::${L.key}`]??!0,dn=d=>{Vt(L=>{if(!L.has(d))return L;const V=new Map(L);return V.delete(d),V})},Zn=d=>{Vt(L=>{let V=!1;const J=new Map(L),le=`${d}::`;for(const ge of J.keys())ge.startsWith(le)&&(J.delete(ge),V=!0);return V?J:L})},er=(d,L,V)=>{Vt(J=>{const le=new Map(J);return le.set(d,L+V),le})},Oe=(d,L,V,J)=>{const le=J?.pageSize??Cm,ge=J?.alwaysVisibleIds,de=new Set(L.sessions.map(ve=>ve.id)),Ke=new Map;for(const ve of L.sessions){const rt=jt(ve);if(rt&&de.has(rt)){const It=Ke.get(rt)??[];It.push(ve),Ke.set(rt,It)}}const nt=L.sessions.filter(ve=>{const rt=jt(ve);return!rt||!de.has(rt)}),wt=new Set,Ms=nt.flatMap(ve=>{const rt=ht.runKeyBySessionId.get(ve.id),It=rt?ht.runs.get(rt):void 0;return It?wt.has(It.key)?[]:(wt.add(It.key),[{kind:"run",run:It}]):[{kind:"session",session:ve}]}),pi=ve=>ve.kind==="session"&&!!ge?.has(ve.session.id),Aa=ge?Ms.filter(pi):[],or=ge?Ms.filter(ve=>!pi(ve)):Ms,Pa=Jn.get(d)??le,ar=or.slice(0,Pa),Ta=[...Aa,...ar],hi=or.length-ar.length,Da=or.length>le&&hi===0,gi=(ve,rt)=>{const It=Ke.get(ve.id)??[],lr=It.length>0,bi=!!se[ve.id],_a=rt===V;return t.jsxs(u.Fragment,{children:[t.jsx(Qi,{session:ve,active:N===ve.id,indent:rt,contextLabel:_a?J?.rootContextLabel?.(ve):void 0,hasChildren:lr,expanded:bi,onToggleChildren:lr?()=>te(ve.id):void 0,onSelect:()=>Bt(ve),statusOnRight:J?.statusOnRight,revealed:Ce===ve.id,onRevealedChange:Os=>fn(ve.id,Os),confirmingDelete:Se===ve.id,onArchive:()=>{Et(ve)},onRequestDelete:()=>he(ve.id),onConfirmDelete:()=>{pn(ve)},renaming:Pe===ve.id,onRequestRename:()=>hn(ve.id),onSubmitRename:Os=>{Ts(ve.id,Os)},onCancelRename:()=>H(null),work:Ht(ve),pin:mn(ve),descendantIdsOf:Is}),lr&&bi?It.map(Os=>gi(Os,rt+Im)):null]},ve.id)};return t.jsxs("div",{children:[Ta.map(ve=>ve.kind==="run"?t.jsx(Dm,{run:ve.run,laneNodes:Ie.get(ve.run.key)??Zi,indent:V},`run:${ve.run.key}`):gi(ve.session,V)),hi>0?t.jsx(_m,{indent:V,onClick:()=>er(d,ar.length,le)}):null,Da?t.jsx(Mm,{indent:V,onClick:()=>dn(d)}):null]})},rs=(d,L)=>{fe(d,!L),Zn(d)},tr=(d,L,V)=>{re(`${d}::${L}`,!V),dn(`${d}::${L}`)},Bt=d=>{const L=kt(d)||null,V=Ze.bySessionId.get(d.id),J=V?je.find(le=>le.id===V.projectId)??null:null;if(J){z(J.id),fe(J.id,!0);const le=br(J,V?.scopeDirectory??"");le&&re(`${J.id}::${Be(le.path)}`,!0)}A(d.id,L),e(!1)},fn=(d,L)=>{be(L?d:null),he(null),Re(null),Ee(null)},Pt=(d,L)=>{Re(L?d:null),Ee(null),be(null),he(null)},qt=(d,L)=>(be(null),he(null),eu(d,L,tu(L.id,Rn(pt,L.id),d==="delete"),{archiveSession:E,archiveSessions:j,deleteSession:v,deleteSessions:S},r)),Et=d=>qt("archive",d),Lt=async(d,L)=>{try{await Cl(d.id,kt(d)||null,L?"done":"open")}catch{ce.error(r("sessions.sidebar.session.work.updateFailed"))}},Ht=d=>{if(!Qe||jt(d)||cr(kt(d)))return;const L=Ye.has(d.id);return{inWork:L,onToggle:()=>{Lt(d,L)}}},is=d=>Ri(g,kt(d)||null,d.id),os=d=>{const L=kt(d);L&&K({directory:L,sessionId:d.id})},mn=d=>{if(!(jt(d)||!kt(d)))return{pinned:is(d),onToggle:()=>os(d)}},pn=d=>qt("delete",d),hn=d=>{be(null),he(null),H(d)},Ts=async(d,L)=>{H(null);try{await w(d,L)}catch{ce.error(r("mobile.sessions.renameError"))}},gn=()=>{C(),e(!1)},Ft=d=>{sn(d),z(d),Rs(!0)},sr=$r(ws(Vr,{activationConstraint:{distance:8}}),ws(Wr,{coordinateGetter:Kr})),bn=d=>{W(d),ur({sidebarProjectSortOrder:d}),d!=="manual"&&ns(!1)},nr=d=>{_(d),ur({sidebarViewMode:d}),d==="timeline"&&ns(!1)},rr=()=>{const d=!F;M(d),ur({sidebarShowRecentSection:d})},xn=d=>{const{active:L,over:V}=d;if(!V||L.id===V.id)return;const J=je.findIndex(ge=>ge.id===L.id),le=je.findIndex(ge=>ge.id===V.id);J<0||le<0||B(J,le)},Ds=d=>{Es(L=>{const V=new Set(L);return V.has(d)?V.delete(d):V.add(d),V})},_s=u.useCallback(d=>{const L=kt(d);if(cr(L))return r("mobile.sessions.section.chats");const V=Ze.bySessionId.get(d.id),J=V?je.find(de=>de.id===V.projectId)??null:null;if(!J)return hr(L)||L;const le=V?.kind==="space"&&V.spaceId?Ge.get(V.spaceId):void 0;if(le)return`${J.label} · ${le.name||r("sessions.sidebar.grouping.spaceUnnamed")}`;const ge=br(J,V?.scopeDirectory??"");return ge?.branch?`${J.label} · ${ge.branch}`:J.label},[je,Ze,Ge,r]),yn=d=>{O(d.id),e(!1)},vn=d=>{z(d.id),C({selectedProjectId:d.id,directoryOverride:d.path}),e(!1)},U=u.useMemo(()=>ze?zt.filter(d=>Oo([d.project.label,d.project.path],ze)?!0:d.buckets.some(L=>L.sessions.some(V=>xr(V,d.project.label,ze)))):zt,[ze,zt]),ne=u.useMemo(()=>ze?ls(et.filter(d=>{if(jt(d))return!1;const L=Ze.bySessionId.get(d.id),V=L?je.find(J=>J.id===L.projectId)??null:null;return xr(d,V?.label??"",ze)}),g,h):[],[ze,g,je,h,Ze,et]),xe=u.useMemo(()=>ze?jl(je,ze,d=>[d.label,d.path]):[],[ze,je]),we=I==="timeline"&&!ze&&!$e,gt=we||X;u.useEffect(()=>{if(!(!gt||!o))for(const d of je){const L=Be(d.path);L&&kl(()=>a(L,o))}},[a,o,gt,je]);const De=u.useMemo(()=>{const d=new Map;if(!we)return d;const L=Ii({sessions:lt,projects:je.map(V=>({id:V.id,normalizedPath:V.path,label:V.label})),ownerBySessionId:Ze.bySessionId,availableWorktreesByProject:new Map(je.map(V=>[V.path,V.worktrees])),gitBranches:Z,homeDirectory:null,hideBranchMatchingProjectLabel:!1,spaceLabelById:yt});for(const V of lt){if(jt(V))continue;const J=L.get(V.id),le=J?je.find(ge=>ge.id===J.projectId):null;!le||!J||d.set(V.id,{project:le,branch:J.branchLabel,inSpace:J.inSpace})}return d},[Z,lt,je,Ze,yt,we]),wn=u.useMemo(()=>{if(!we)return[];const d=Ue.filter(V=>!jt(V)&&De.has(V.id)),L=new Set;return ls(d,g,h).flatMap(V=>{const J=De.get(V.id);if(!J)return[];const le=ht.runKeyBySessionId.get(V.id),ge=le?ht.runs.get(le):void 0;return ge?L.has(ge.key)?[]:(L.add(ge.key),[{kind:"run",run:ge,laneNodes:Ie.get(ge.key)??Zi,project:J.project}]):[{kind:"session",session:V,project:J.project,branch:J.branch,inSpace:J.inSpace}]})},[g,ht,Ie,Ue,h,we,De]),jn=u.useCallback(()=>{Ct(d=>cm(d,wn.length))},[wn.length]),ir={currentSessionId:N,revealedSessionId:Ce,confirmingDeleteSessionId:Se,renamingSessionId:Pe,onSelect:Bt,onRevealedChange:fn,onArchive:d=>{Et(d)},onRequestDelete:he,onConfirmDelete:d=>{pn(d)},onRequestRename:hn,onSubmitRename:(d,L)=>{Ts(d,L)},onCancelRename:()=>H(null),onToggleWork:Qe?(d,L)=>{Lt(d,L)}:void 0,isPinned:is,onTogglePin:os,descendantIdsOf:Is},Ea=ze&&ne.length===0&&xe.length===0,Ia=!ze&&!we&&je.length>1&&P==="manual",ci=!$e&&!ze&&je.length>0?t.jsx(ke,{type:"button",variant:"chip",size:"sm","aria-label":r("sessions.sidebar.header.displayMode.label"),title:r("sessions.sidebar.header.displayMode.label"),onClick:()=>Xe(!0),style:{touchAction:"manipulation"},children:t.jsx(q,{name:"equalizer-2",className:"size-4"})}):null,ui=Ia?t.jsx(ke,{type:"button",variant:"chip",size:"sm","aria-label":r($e?"mobile.sessions.doneEditing":"mobile.sessions.editOrder"),"aria-pressed":$e,onClick:()=>ns(d=>!d),style:{touchAction:"manipulation"},children:$e?t.jsx(Go,{className:"size-4"}):t.jsx(Sr,{className:"size-4"})}):null,di=!$e&&je.length>0?t.jsxs(ke,{type:"button",variant:"default",size:"sm","aria-label":r("mobile.sessions.newChat"),onClick:gn,style:{touchAction:"manipulation"},children:[t.jsx(ed,{className:"size-4"}),r("mobile.sessions.newChat")]}):null,fi=$e?null:t.jsx(ke,{type:"button",variant:"chip",size:"sm","aria-label":r("sessions.sidebar.header.actions.addProject"),title:r("sessions.sidebar.header.actions.addProject"),onClick:()=>Mt(!0),style:{touchAction:"manipulation"},children:t.jsx(Ai,{className:"size-4"})}),kn=di||fi||ci||ui?t.jsxs(t.Fragment,{children:[fi,ci,ui,di]}):null,mi=t.jsxs("div",{ref:un,className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs(Gn,{ref:We,className:"min-h-0 flex-1 overflow-y-auto pb-4",children:[t.jsx("div",{className:Q("px-4 pb-2 pt-1",$e&&"hidden"),children:t.jsx(Xc,{value:ie,onSearch:G,active:n||s==="sidebar",mobile:!0,placeholder:r("mobile.sessions.search.placeholder"),clearLabel:r("mobile.sessions.clearSearchAria")})}),je.length===0&&tt.length===0?t.jsx(no,{title:r("mobile.sessions.empty.noProjectsTitle"),description:r("mobile.sessions.empty.noProjectsDescription"),action:t.jsxs("button",{type:"button",className:"flex items-center justify-center gap-2 rounded-2xl bg-primary px-5 py-3 typography-ui-label text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>Mt(!0),children:[t.jsx(Ai,{className:"size-4"}),r("sessions.sidebar.header.actions.addProject")]})}):Ea?t.jsx(no,{title:r("mobile.sessions.empty.searchTitle"),description:r("mobile.sessions.empty.searchDescription")}):ze&&!$e?t.jsxs("div",{className:"flex flex-col gap-3 px-3 pt-2",children:[ne.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:ne.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:ne.map((d,L)=>t.jsx("div",{className:Q(L>0&&"border-t border-border/70"),children:t.jsx(Qi,{session:d,active:N===d.id,indent:12,contextLabel:_s(d),onSelect:()=>Bt(d)})},d.id))})]}):null,xe.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:xe.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:xe.map((d,L)=>t.jsxs("div",{className:Q("flex items-center",L>0&&"border-t border-border/70"),children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-3 px-3 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>yn(d),style:{touchAction:"manipulation"},children:[t.jsx(Ys,{project:d}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:d.label})]}),d.isGitRepo?t.jsx(Xi,{onClick:()=>Ft(d.id)}):null,t.jsx(yr,{className:"mr-2",label:r("mobile.sessions.newSessionInProjectAria",{label:d.label}),onClick:()=>vn(d)})]},d.id))})]}):null]}):$e?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(Ur,{sensors:sr,collisionDetection:Gr,onDragEnd:xn,children:t.jsx(qr,{items:je.map(d=>d.id),strategy:Hr,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:je.map(d=>t.jsx(zm,{project:d,expanded:nn.has(d.id),onToggleExpanded:()=>Ds(d.id),onReorderWorktrees:L=>D(d.id,L)},d.id))})})})]}):t.jsxs("div",{className:"flex flex-col",children:[(()=>{const d=Y[zs]??!0,L=r("mobile.sessions.section.chats");return t.jsxs("section",{children:[t.jsxs("div",{className:"flex min-h-12 w-full items-center",children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ae){Pt(ae,!1);return}rs(zs,d)},"aria-expanded":d,"aria-label":d?r("sessions.sidebar.group.collapseAria",{label:L}):r("sessions.sidebar.group.expandAria",{label:L}),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:L}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:cn})]}),$e?null:t.jsx(yr,{className:"mr-2",label:r("mobile.sessions.newChat"),onClick:gn})]}),d?t.jsx("div",{className:"pb-2",children:At.sessions.length>0?Oe(As,At,we?Em:cs,we?{pageSize:Rm,alwaysVisibleIds:on,statusOnRight:!0}:void 0):t.jsx("p",{className:"px-3 pb-1 typography-micro text-muted-foreground",style:{paddingLeft:cs},children:r("sessions.sidebar.activity.chatsEmpty")})}):null]})})(),Gt.sessions.length>0?(()=>{const d=Y[Fs]??!0,L=r("sessions.sidebar.work.title");return t.jsxs("section",{children:[t.jsxs("button",{type:"button",className:"flex min-h-12 w-full min-w-0 items-center gap-2 px-3 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ae){Pt(ae,!1);return}rs(Fs,d)},"aria-expanded":d,"aria-label":d?r("sessions.sidebar.group.collapseAria",{label:L}):r("sessions.sidebar.group.expandAria",{label:L}),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:"eye",className:"size-4"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:L}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:Gt.sessions.filter(V=>!jt(V)).length})]}),d?t.jsx("div",{className:"pb-2",children:Oe(`${Fs}::${Fs}`,Gt,cs,{pageSize:Number.MAX_SAFE_INTEGER})}):null]})})():null,!we&&ln.sessions.length>0?(()=>{const d=Y[$s]??!0,L=r("mobile.sessions.section.recent");return t.jsxs("section",{children:[t.jsxs("button",{type:"button",className:"flex min-h-12 w-full min-w-0 items-center gap-2 px-3 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ae){Pt(ae,!1);return}rs($s,d)},"aria-expanded":d,"aria-label":d?r("sessions.sidebar.group.collapseAria",{label:L}):r("sessions.sidebar.group.expandAria",{label:L}),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:"history",className:"size-4"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:L}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:Ot.length})]}),d?t.jsx("div",{className:"pb-2",children:Oe(`${$s}::${$s}`,ln,cs,{rootContextLabel:V=>ct.get(V.id)??_s(V)})}):null]})})():null,we?t.jsx(am,{entries:wn,visibleCount:Yn,onRevealMore:jn,scrollRootRef:We,handlers:ir}):null,we?null:U.map(d=>{const L=vt(d),V=ze?d.buckets.filter(le=>le.sessions.some(ge=>xr(ge,d.project.label,ze))):d.buckets,J=ut(d);return t.jsxs("section",{className:"border-t border-border/70",children:[t.jsx(Vn,{actionsWidth:96,revealed:ae===`project:${d.project.id}`,onRevealedChange:le=>Pt(`project:${d.project.id}`,le),actions:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:ae===`project:${d.project.id}`?0:-1,className:Q("flex flex-1 items-center justify-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive",Ae===d.project.id?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80"),"aria-label":Ae===d.project.id?r("mobile.sessions.confirmRemoveProjectAria",{label:d.project.label}):r("mobile.sessions.removeProjectAria",{label:d.project.label}),onClick:()=>{if(Ae===d.project.id){Re(null),Ee(null),ee(d.project.id),ce.success(r("mobile.sessions.toast.projectRemoved",{label:d.project.label}));return}Ee(d.project.id)},style:{touchAction:"manipulation"},children:t.jsx(On,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:ae===`project:${d.project.id}`?0:-1,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":r("mobile.sessions.editProjectAria",{label:d.project.label}),onClick:()=>{Re(null),ue(d.project.id)},style:{touchAction:"manipulation"},children:t.jsx(Sr,{className:"size-[18px]"})})]}),children:t.jsxs("div",{"data-active-project":d.isActive||void 0,className:"flex min-h-12 w-full items-center",children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ae){Pt(ae,!1);return}rs(d.project.id,L)},"aria-expanded":L,"aria-label":L?r("sessions.sidebar.group.collapseAria",{label:d.project.label}):r("sessions.sidebar.group.expandAria",{label:d.project.label}),style:{touchAction:"manipulation"},children:[t.jsx(Ys,{project:d.project}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:d.project.label})]}),d.project.isGitRepo?t.jsx(Xi,{onClick:()=>Ft(d.project.id)}):null,t.jsx(yr,{className:"mr-2",label:r("mobile.sessions.newSessionInProjectAria",{label:d.project.label}),onClick:()=>vn(d.project)})]})}),L?t.jsx("div",{className:"pb-2",children:(()=>{const le=V.find(de=>de.worktree===null&&de.space===null),ge=V.filter(de=>de!==le);return t.jsxs(t.Fragment,{children:[le&&le.sessions.length>0?Oe(`${d.project.id}::${le.key}`,le,cs):null,ge.map(de=>{const Ke=Ps(d,de),nt=J===de.path;return t.jsx(Pm,{path:de.worktree?.path??null,children:wt=>t.jsxs("div",{className:Q(wt&&"opacity-60"),"aria-busy":wt||void 0,children:[t.jsx(Vn,{actionsWidth:de.space?96:48,revealed:ae===`wt:${de.key}`,onRevealedChange:Ms=>Pt(`wt:${de.key}`,Ms),actions:de.space?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:ae===`wt:${de.key}`?0:-1,className:"flex flex-1 items-center justify-center text-foreground transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":r("spaces.group.access.giveAria",{label:de.label}),onClick:()=>{Re(null),de.space&&yi.getState().openAccessDialog(de.space.id)},style:{touchAction:"manipulation"},children:t.jsx(q,{name:"key",className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:ae===`wt:${de.key}`?0:-1,className:"flex flex-1 items-center justify-center text-foreground transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":r("spaces.actions.menuAria",{label:de.label}),onClick:()=>{Re(null),de.space&&yi.getState().openActionsSheet(de.space.id)},style:{touchAction:"manipulation"},children:t.jsx(q,{name:"more-2",className:"size-[18px]"})})]}):de.worktree&&!wt?t.jsx("button",{type:"button",tabIndex:ae===`wt:${de.key}`?0:-1,className:"flex flex-1 items-center justify-center text-[var(--status-error)] transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive","aria-label":r("mobile.projectEdit.deleteWorktreeAria",{label:de.label}),onClick:()=>{Re(null),de.worktree&&Je({project:d.project,worktree:de.worktree})},style:{touchAction:"manipulation"},children:t.jsx(On,{className:"size-[18px]"})}):null,children:t.jsxs("button",{type:"button",className:"flex min-h-10 w-full items-center gap-2 px-3 py-1 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(ae){Pt(ae,!1);return}tr(d.project.id,de.key,Ke)},"aria-expanded":Ke,"aria-label":Ke?r("sessions.sidebar.group.collapseAria",{label:de.label}):r("sessions.sidebar.group.expandAria",{label:de.label}),style:{touchAction:"manipulation"},children:[wt?t.jsx("span",{className:"inline-flex shrink-0 text-muted-foreground",role:"status","aria-label":r("sessions.sidebar.group.worktreeRemoving"),children:t.jsx(q,{name:"loader-4",className:"size-4 animate-spin"})}):t.jsx(q,{name:de.space?"box-3":"git-branch",className:Q("size-4 shrink-0",nt?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:Q("block min-w-0 flex-1 truncate typography-ui-label font-bold",nt?"text-foreground":"text-muted-foreground"),children:de.label}),nt?t.jsx(Tm,{ariaLabel:r("mobile.sessions.activeWorktreeAria")}):null]})}),de.space?t.jsx(Qc,{spaceId:de.space.id,className:"px-3 pb-1 pl-9"}):null,Ke?Oe(`${d.project.id}::${de.key}`,de,cs):null]})},de.key)})]})})()}):null]},d.project.id)})]})]}),i?t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-border/70 px-2 pt-1.5",style:{paddingBottom:"calc(0.375rem + var(--oc-safe-area-bottom, 0px))"},children:[i.instanceLabel&&i.onOpenInstances?t.jsxs(ke,{type:"button",variant:"info",size:"lg",className:"min-w-0 shrink justify-start",onClick:i.onOpenInstances,"aria-label":r("mobile.menu.instances"),style:{touchAction:"manipulation"},children:[t.jsx(q,{name:"server",className:"size-[18px]"}),t.jsx("span",{className:"block min-w-0 truncate",children:i.instanceLabel})]}):t.jsx("div",{className:"min-w-0 flex-1"}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[i.onOpenUpdate?t.jsxs(ke,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:i.onOpenUpdate,"aria-label":r("mobile.menu.update"),title:r("mobile.menu.update"),style:{touchAction:"manipulation"},children:[t.jsx(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(ke,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:i.onOpenScheduled,"aria-label":r("sessions.sidebar.header.actions.scheduledTasks"),title:r("sessions.sidebar.header.actions.scheduledTasks"),style:{touchAction:"manipulation"},children:t.jsx(q,{name:"calendar-schedule",className:"size-5"})}),t.jsx(ke,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:i.onOpenSourceBoard,"aria-label":r("sourceBoard.title"),title:r("sourceBoard.title"),style:{touchAction:"manipulation"},children:t.jsx(q,{name:"todo",className:"size-5"})}),t.jsx(ke,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:i.onOpenArchive,"aria-label":r("sessions.sidebar.nav.archive"),title:r("sessions.sidebar.nav.archive"),style:{touchAction:"manipulation"},children:t.jsx(q,{name:"archive",className:"size-5"})}),t.jsx(ke,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:i.onOpenUsage,"aria-label":r("usageStats.openAction"),title:r("usageStats.openAction"),style:{touchAction:"manipulation"},children:t.jsx(q,{name:"bar-chart",className:"size-5"})}),t.jsx(ke,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:i.onOpenSettings,"aria-label":r("mobile.menu.settings"),title:r("mobile.menu.settings"),style:{touchAction:"manipulation"},children:t.jsx(q,{name:"settings-3",className:"size-5"})})]})]}):null,t.jsx(Zc,{open:_t,onOpenChange:Mt}),t.jsx(Sl,{open:en,onOpenChange:d=>{Rs(d),d||sn(null)},project:(()=>{const d=je.find(L=>L.id===tn);return d?{id:d.id,path:d.path}:void 0})(),onWorktreeCreated:d=>{C({selectedProjectId:tn,directoryOverride:d,preserveDirectoryOverride:!0}),e(!1)}}),t.jsx(pm,{open:oe!==null,project:je.find(d=>d.id===oe)??null,onClose:()=>ue(null),onWorktreesChanged:()=>Fe(d=>d+1)}),t.jsx(Co,{open:bt,onClose:()=>Xe(!1),title:r("sessions.sidebar.header.displayMode.label"),children:t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"px-3 pb-1 pt-1 typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:r("mobile.sessions.viewMode.label")}),Nm.map(([d,L])=>t.jsxs("button",{type:"button",className:Q("flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-left transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",I===d?"text-primary":"text-foreground"),onClick:()=>{nr(d),Xe(!1)},style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label",children:r(L)}),I===d?t.jsx(q,{name:"check",className:"size-4"}):null]},d)),I==="timeline"?null:t.jsx("span",{className:"px-3 pb-1 pt-3 typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:r("sessions.sidebar.header.actions.sortProjects")}),I==="timeline"?null:Sm.map(([d,L])=>t.jsxs("button",{type:"button",className:Q("flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-left transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",P===d?"text-primary":"text-foreground"),onClick:()=>{bn(d),Xe(!1)},style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label",children:r(L)}),P===d?t.jsx(q,{name:"check",className:"size-4"}):null]},d)),I==="timeline"?null:t.jsxs("button",{type:"button","aria-pressed":F,className:Q("mt-2 flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-left transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",F?"text-primary":"text-foreground"),onClick:()=>{rr(),Xe(!1)},style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label",children:r("sessions.sidebar.header.displayMode.showRecent")}),F?t.jsx(q,{name:"check",className:"size-4"}):null]})]})}),Te?t.jsx(ga,{open:!0,project:{id:Te.project.id,path:Te.project.path},worktree:Te.worktree,onClose:()=>Je(null),onDeleted:()=>Fe(d=>d+1)}):null]});return s==="sidebar"?n?t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center justify-between gap-2 border-b border-border/70 px-4",children:[t.jsx("h2",{className:"truncate typography-ui-label font-semibold text-foreground",children:r("mobile.sessions.sheet.title")}),kn?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:kn}):null]}),mi]}):null:t.jsxs(Fm,{open:n,onClose:()=>e(!1),onSwipeClose:()=>{if(Ce||ae){be(null),Re(null),he(null),Ee(null);return}e(!1)},ariaLabel:r("mobile.sessions.sheet.title"),children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",children:[t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":r("mobile.surface.closeAria"),onClick:()=>e(!1),style:{touchAction:"manipulation"},children:t.jsx(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")}),kn?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:kn}):null]}),mi]})},to="mobile-surface-root",Bm=16,so=320,Lm="cubic-bezier(0.22, 1, 0.36, 1)",Fm=({open:n,onClose:e,onSwipeClose:s,ariaLabel:i,children:r})=>{const o=u.useRef(null),a=u.useRef(null),[l,f]=u.useState(!1),[c,m]=u.useState(n),g=u.useRef(e);u.useEffect(()=>{g.current=e},[e]);const p=u.useRef(s);if(u.useEffect(()=>{p.current=s},[s]),ai(a,{enabled:n,onRightEdgeSwipe:()=>(p.current??g.current)()}),typeof document<"u"&&!o.current){let h=document.getElementById(to);h||(h=document.createElement("div"),h.id=to,document.body.appendChild(h)),o.current=h}return u.useEffect(()=>{if(n){m(!0);const b=window.setTimeout(()=>f(!0),Bm);return()=>window.clearTimeout(b)}f(!1);const h=window.setTimeout(()=>m(!1),so+40);return()=>window.clearTimeout(h)},[n]),u.useEffect(()=>{if(!n)return;const h=document.body.style.overflow;document.body.style.overflow="hidden";const b=k=>{k.key==="Escape"&&g.current()};return document.addEventListener("keydown",b),()=>{document.body.style.overflow=h,document.removeEventListener("keydown",b)}},[n]),o.current?ys.createPortal(t.jsx("section",{ref:a,role:"dialog","aria-modal":"true","aria-label":i,"aria-hidden":!n,className:"oc-keyboard-inset-surface fixed inset-0 z-50 flex flex-col bg-background text-foreground",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:l?"none":"translateX(-100%)",transition:`transform ${so}ms ${Lm}`,visibility:c?"visible":"hidden",pointerEvents:n?"auto":"none"},children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:r})}),o.current):null},no=n=>{const e=me.c(10),{title:s,description:i,action:r}=n;let o;e[0]!==s?(o=t.jsx("p",{className:"typography-ui-label text-foreground",children:s}),e[0]=s,e[1]=o):o=e[1];let a;e[2]!==i?(a=i?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i}):null,e[2]=i,e[3]=a):a=e[3];let l;e[4]!==r?(l=r?t.jsx("div",{className:"pt-2",children:r}):null,e[4]=r,e[5]=l):l=e[5];let f;return e[6]!==o||e[7]!==a||e[8]!==l?(f=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[o,a,l]}),e[6]=o,e[7]=a,e[8]=l,e[9]=f):f=e[9],f};function $m(n){return Be(n.path)}function Wm(n){return Be(n.path)}function Vm(n){return t.jsx(Om,{worktree:n},Be(n.path))}const Um=6e4,Gm=(n,e)=>{if(!n)return e("mcpDropdown.status.unknown");const s=n.status;switch(s.status){case"connected":return e("mcpDropdown.status.connected");case"failed":return e("mcpDropdown.status.failed",{error:s.error||e("mcpDropdown.status.unknownError")});case"needs_auth":return e("mcpDropdown.status.needsAuth");default:return s.status}},Km=n=>{switch(n?.status.status){case"connected":return"success";case"failed":return"error";case"needs_auth":return"warning";default:return"default"}},qm=({active:n,className:e,headerAction:s,listClassName:i,hideHeader:r=!1,mobileListDensity:o=!1})=>{const{t:a}=ye(),f=Wt(v=>v.currentDirectory)??null,c=ds(v=>v.getStatusForDirectory(f)),m=ds(v=>v.refresh),g=ds(v=>v.ensureFresh),p=ds(v=>v.connect),h=ds(v=>v.disconnect),b=bs(v=>v.mcpServers),k=bs(v=>v.loadMcpConfigs),[x,R]=u.useState(!1),[N,A]=u.useState(null);u.useEffect(()=>{k({force:!0})},[k]),u.useEffect(()=>{n&&Promise.all([g({directory:f,silent:!0,maxAgeMs:Um}),k({force:!0})])},[n,g,f,k]);const E=u.useMemo(()=>{const v=new Set(Object.keys(c));for(const S of b)S?.name&&v.add(S.name);return Array.from(v).sort((S,w)=>S.localeCompare(w))},[b,c]),j=u.useCallback(v=>{if(v?.preventDefault(),x)return;R(!0);const S=new Promise(w=>setTimeout(w,500));Promise.all([m({directory:f}),S]).finally(()=>{R(!1)})},[x,m,f]);return t.jsxs("div",{className:Q("w-full",e),children:[r?null:t.jsx("div",{className:"border-b border-[var(--interactive-border)]",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5",children:[t.jsxs("div",{className:"min-w-0 flex items-baseline gap-2",children:[t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:a("mcpDropdown.title")}),f&&t.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:f.split("/").pop()||f})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s,t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",disabled:x,onClick:j,"aria-label":a("mcpDropdown.actions.refreshAria"),children:t.jsx(q,{name:"refresh",className:Q("h-4 w-4",x&&"animate-spin")})})]})]})}),t.jsx("div",{className:Q("max-h-64 overflow-y-auto",o?"space-y-1 py-3":"px-3 py-2.5",i),children:t.jsxs("div",{className:Q(!o&&E.length>0&&"p-1.5"),children:[E.map(v=>{const S=c[v],w=Km(S),C=S?.status.status==="connected",O=N===v,z=Gm(S,a);return t.jsxs("div",{className:Q("flex items-center justify-between rounded-lg hover:bg-interactive-hover",o?"gap-3 px-4 py-3":"gap-2 px-2.5 py-2"),children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsxs(Rl,{children:[t.jsx(El,{asChild:!0,children:t.jsx("span",{className:Q("rounded-full flex-shrink-0",o?"h-2.5 w-2.5":"h-2 w-2",w==="success"&&"bg-status-success",w==="error"&&"bg-status-error",w==="warning"&&"bg-status-warning",w==="default"&&"bg-muted-foreground/40"),"aria-label":z})}),t.jsx(Il,{side:"left",children:t.jsx("p",{children:z})})]}),t.jsx("span",{className:Q("truncate",o?"text-[17px] leading-6 font-medium":"typography-ui-label"),children:v})]})}),t.jsx(Al,{checked:C,disabled:O,className:"data-[checked]:bg-status-info",onCheckedChange:async B=>{A(v);try{B?await p(v,f):await h(v,f)}catch(T){Nr.error(T instanceof Error?T.message:a("mcpDropdown.status.unknownError"))}finally{A(null)}}})]},v)}),E.length===0&&t.jsx("div",{className:"px-4 py-5 typography-ui-label text-muted-foreground text-center",children:a("mcpDropdown.empty.configureInConfig")})]})})]})};async function Hm(n,e,s=Number.POSITIVE_INFINITY){const i=Array.from(new Set(n)),r=[];return await Pl(i,s,async o=>{try{await e(o)}catch(a){r.push({path:o,error:a instanceof Error?a:null})}}),{paths:i,failures:r}}const ro={status:"loading"},Jm=1e6,us={type:"list"},Ym=2,Xm=n=>{const e=n.index?.trim();return!!(e&&e!=="?")},Qm=n=>{const e=n.working_dir?.trim(),s=n.index?.trim();return!!(e||s==="?")},io=(n,e)=>e?`${n}\0staged`:n,Zm=n=>{const e=me.c(6),s=Zs(zr()??null)??"",i=n.visible??!0;let r;e[0]!==i?(r={enabled:i,recheckOnOpen:!0},e[0]=i,e[1]=r):r=e[1];const o=Tl(s||null,r);let a;return e[2]!==n||e[3]!==o||e[4]!==s?(a=t.jsx(ep,{...n,rootDirectory:s,repository:o}),e[2]=n,e[3]=o,e[4]=s,e[5]=a):a=e[5],a},ep=({rootDirectory:n,repository:e,onClose:s,initialDiff:i,visible:r=!0,onNavigatedToChat:o})=>{const{t:a}=ye(),{git:l,sourceControl:f}=Un(),{rootIsGitRepo:c,gitDirectory:m,nestedRepos:g}=e,p=m??n,h=Dl(p||null),b=_l(p||null),k=Ml(p||null),[x,R]=u.useState(!1),[N,A]=u.useState(!1),E=En(y=>y.profiles),j=En(y=>y.globalIdentity),v=En(y=>y.loadProfiles),S=En(y=>y.loadGlobalIdentity);u.useEffect(()=>{v(),S()},[v,S]);const w=Ol(),C=Lo(y=>y.refreshIdentityAccounts),O=u.useMemo(()=>zl(E,j,y=>Ga(y)&&Bl(y,w)),[E,j,w]),z=async y=>{if(!(!p||N)){A(!0);try{(await hu({directory:p,identity:y,remoteName:Ut||null},{git:l,sourceControl:f})).status==="failed"?ce.error(a("gitView.toast.applyIdentityFailed")):ce.success(a("gitView.toast.appliedIdentity",{name:tc(y,a)}))}finally{A(!1)}}},B=So(p||null),T=Ll(p||null),P=it(y=>y.setActiveDirectory),W=it(y=>y.ensureAll),I=it(y=>y.ensureNestedRepos),_=it(y=>y.selectNestedRepo),F=it(y=>y.fetchStatus),M=it(y=>y.fetchBranches),K=it(y=>y.prefetchDiffs),X=it(y=>y.getDiff),Z=it(y=>y.setDiff),ee=it(y=>y.runtimeKey),Y=JSON.stringify([ee,p]),pe=u.useRef(Y);pe.current=Y;const[fe,re]=u.useState(()=>({ownerKey:Y,mode:"working",route:i?.path?{type:"diff",path:i.path,staged:i.staged}:us})),$=fe.ownerKey===Y?fe.mode:"working",D=fe.ownerKey===Y?fe.route:us,[se,te]=u.useState(!1),ie=u.useCallback(y=>{re({ownerKey:Y,mode:y,route:us}),te(!1)},[Y]),G=u.useCallback(y=>{re(U=>({ownerKey:Y,mode:U.ownerKey===Y?U.mode:"working",route:y}))},[Y]);u.useEffect(()=>{re(y=>y.ownerKey===Y?y:{ownerKey:Y,mode:"working",route:us}),te(!1)},[Y]),u.useEffect(()=>{r||te(!1)},[r]),u.useEffect(()=>{i?.path&&re({ownerKey:pe.current,mode:"working",route:{type:"diff",path:i.path,staged:i.staged}})},[i]);const[oe,ue]=u.useState(null),[Ce,be]=u.useState(null),[Se,he]=u.useState(""),[Pe,H]=u.useState(new Set),[ae,Re]=u.useState(!1),[Ae,Ee]=u.useState(!1),[Te,Je]=u.useState([]),[Le,Fe]=u.useState([]),[bt,Xe]=u.useState([]),[_t,Mt]=u.useState(null),[en,Rs]=u.useState(null),[tn,sn]=u.useState(0),ts=su(),at=nu({directory:p,branch:h?.current,chooseContributor:ts.choose}),xt=ru(p,l,f),[ss,$e]=u.useState(null),[ns,nn]=u.useState(!1),[Es,Jn]=u.useState([]),[Vt,Yn]=u.useState("rebase"),Ct=u.useCallback((y,U)=>{Jn(y),Yn(U),nn(!0)},[]),We=h?.current??null,je=h?.tracking?.trim().split("/")[0],et=(je&&b?.defaultBranches?.[je])??b?.defaultBranches?.origin??null,pt=Rd(We,et),Is=B===!1||Nd(We,et,h!==null,b!==null),lt=gd(y=>y.setOverride),tt=bd(p||null,We,r&&$==="branch"&&pt),Qe=xd(p||null,We,r&&$==="commit"&&B===!0),Ye=Qe.selectedCommit?.hash??null,Ue=Fl(p||null,f),Ut=Ue.read?.binding?.remotes[0]?.name??Ue.read?.repository.remotes.find(y=>y.name==="origin")?.name??Ue.read?.repository.remotes[0]?.name??"",Xn=Ue.read?Ue.read.binding?.providers.find(y=>y.readiness==="ready")?.accountId??null:void 0,rn=u.useMemo(()=>$l(E,j,k,y=>({id:"local-config",name:y.userName,...y,color:"info",icon:"user"}),Xn),[Xn,k,E,j]),Rt=u.useMemo(()=>{const y=Ue.read;return!y?.binding||Ue.status!=="ready"||y.binding.state==="bound"?null:Wl(y.binding)?a("gitView.identity.configChanged"):a("gitView.context.needsAttention")},[Ue.read,Ue.status,a]),Ge=yd(p||null,We,Ue.contexts[0]??null,r&&$==="pr"&&B===!0),yt=Ge.selectedSource,Ze=u.useMemo(()=>$==="pr"?yt:$==="branch"&&We&&tt.base?{kind:"branch",baseRef:tt.base,headRef:We}:$==="commit"&&Ye?{kind:"commit",hash:Ye}:null,[tt.base,We,$,Ye,yt]),ht=$==="branch"?tt.revision:"",Ie=kd(p||null,Ze,r&&B===!0,ht,Ge.readContext,Ge.provider),{fetchDiff:At,fetchFullFile:on}=Ie,Gt=u.useMemo(()=>Ie.files?[...Ie.files].sort((y,U)=>y.path.localeCompare(U.path)):null,[Ie.files]),st=D.type==="comparison"&&D.sourceKey===Ie.key?D.path:null,[an,Qn]=u.useState(0),Ot=u.useCallback(async y=>{try{const{diff:U}=await At(y),ne={original:"",modified:"",isBinary:vd(U)};return ne.isBinary||(ne.fileDiff=Ti(y,U)),{status:"ready",diff:ne}}catch(U){return{status:"error",message:U instanceof Error?U.message:a("diffView.state.failedToLoadDiff")}}},[At,a]),ln=Sd(Ie.files?$==="pr"?JSON.stringify([Ie.key,Ie.revision]):Ie.key:null,r&&st?st:"",r?Ot:null,ro,JSON.stringify([ht,$==="pr"?Ie.revision:0,an])),ct=st?ln.get(st)??ro:null,[As,cn]=u.useState(null),[ze,un]=u.useState(null),zt=As&&As.source===ct?As.request:null,Kt=ze&&ze.source===ct?ze.diff:null;u.useEffect(()=>{const y=ct;if(!zt||!st||y?.status!=="ready"||Kt)return;let U=!1;const ne=st,xe=async()=>{if($==="pr"){const{original:gt,modified:De}=await on(ne);return{original:gt,modified:De,fileDiff:Id({name:ne,contents:gt},{name:ne,contents:De})}}const{diff:we}=await At(ne,Jm);return{original:"",modified:"",fileDiff:Ti(ne,we)}};return(async()=>{try{const we=await xe();U||un({source:y,diff:we})}catch(we){if(U)return;ce.error(we instanceof Error?we.message:a("diffView.state.failedToLoadDiff")),cn(null)}})(),()=>{U=!0}},[ct,st,Kt,At,on,$,zt,a]),u.useEffect(()=>{$==="branch"&&Is&&ie("working")},[Is,ie,$]),u.useEffect(()=>{re(y=>y.ownerKey===Y&&y.route.type==="comparison"&&y.route.sourceKey!==Ie.key?{...y,route:us}:y)},[Ie.key,Y]);const ut=u.useMemo(()=>{const y=h?.files??[],U=new Map;for(const ne of y)U.set(ne.path,ne);return Array.from(U.values()).sort((ne,xe)=>ne.path.localeCompare(xe.path))},[h?.files]),vt=u.useMemo(()=>ut.filter(Xm),[ut]),Ps=u.useMemo(()=>ut.filter(Qm),[ut]),dn=bt,Zn=it(u.useCallback(y=>!p||D.type!=="diff"?null:y.directories.get(p)?.diffCache.get(io(D.path,D.staged))??null,[p,D])),er=u.useMemo(()=>D.type!=="diff"?null:ut.find(y=>y.path===D.path)??null,[ut,D]),Oe=u.useCallback(async(y=!0)=>{if(p)try{await Promise.all([F(p,l),M(p,l)])}catch(U){y&&ce.error(U instanceof Error?U.message:a("gitView.toast.refreshRepositoryFailed"))}},[p,M,F,l,a]),rs=u.useMemo(()=>(b?.all??[]).filter(y=>!y.startsWith("remotes/")).sort(),[b]),tr=u.useMemo(()=>(b?.all??[]).filter(y=>y.startsWith("remotes/")).map(y=>y.replace(/^remotes\//,"")).sort(),[b]),Bt=u.useCallback(async y=>{if(!p)return;const U=y.replace(/^remotes\//,"");try{const ne=await l.checkoutBranch(p,U);ce.success(a("gitView.toast.checkedOut",{name:ne.branch||U})),await Oe()}catch(ne){ce.error(ne instanceof Error?ne.message:a("gitView.toast.checkoutFailed",{name:U}))}},[p,l,Oe,a]),fn=u.useCallback(y=>{const U=y.replace(/^remotes\//,"");if((h?.files?.length??0)>0){$e(U);return}Bt(U)},[Bt,h?.files]),Pt=u.useCallback(async y=>{if(p)try{await l.createBranch(p,y,We??"HEAD"),await l.checkoutBranch(p,y),await Oe()}catch(U){throw ce.error(U instanceof Error?U.message:a("gitView.toast.createBranchFailed")),U}},[We,p,l,Oe,a]),qt=u.useCallback(async()=>{if(!p){Xe([]);return}try{const y=await l.getRemotes(p);Xe(y)}catch{Xe([])}},[p,l]),Et=u.useCallback(async()=>{p&&(Promise.allSettled([M(p,l),qt()]),await F(p,l).catch(()=>{}))},[p,M,F,l,qt]);u.useEffect(()=>{!p||!r||(P(p),W(p,l))},[p,W,l,P,r]),u.useEffect(()=>{r&&qt()},[qt,r]),u.useEffect(()=>{if(!r||$!=="working"||!p||ut.length===0)return;const y=Array.from(new Set([...vt.map(ne=>ne.path),...Le,...ut.slice(0,20).map(ne=>ne.path)])).filter(Boolean);if(y.length===0)return;const U=window.setTimeout(()=>{K(p,l,y,{maxFiles:40})},120);return()=>window.clearTimeout(U)},[ut,p,l,$,K,vt,Le,r]),u.useEffect(()=>{if(!r)return;if(D.type!=="diff"){Mt(null);return}const y=io(D.path,D.staged);if(Rs(null),!p||X(p,y)){Mt(null);return}let U=!1;const ne=Qs();return Mt(null),l.getGitFileDiff(p,{path:D.path,staged:D.staged||void 0}).then(xe=>{U||Z(p,y,{original:xe.original??"",modified:xe.modified??"",isBinary:xe.isBinary,submodule:xe.submodule},ne)}).catch(xe=>{if(!U){if(xe instanceof vi&&xe.reason!=="path_not_found"){Rs({key:`${p}\0${D.path}`,reason:xe.reason});return}xe instanceof vi&&F(p,l,{force:!0,silent:!0}),Mt(xe instanceof Error?xe.message:String(xe))}}),()=>{U=!0}},[p,tn,F,X,l,D,Z,r]);const Lt=async(y,U,ne=!1)=>{if(!p)return;const xe=xt.start();if(!xe)return;ue(y);const we=a(y==="fetch"?"gitView.sync.fetch":y==="pull"?"gitView.sync.pull":y==="publish"?"gitView.publish.title":"gitView.sync.syncChanges");let gt=null;try{if(y==="sync"||y==="publish"){const De=await at.prepare(y==="publish"?"push":"sync",{forceChoose:ne,onOperation:xe.onOperation});gt=sc(await De())}else if(U&&h)await nc({action:y,directory:p,remoteName:U.name,status:h,sourceControl:f,git:l,onOperation:xe.onOperation});else throw new $t("tracking-required");if(!xe.isCurrent())return;y==="fetch"&&U?ce.success(a("gitView.toast.fetchedFromRemote",{name:U.name})):y==="pull"&&U?ce.success(a("gitView.toast.pulledFromRemote",{name:U.name})):y==="sync"?ce.success(gt?.kind==="up-to-date"?a("gitView.toast.alreadyUpToDate"):gt?.kind==="pulled"?a("gitView.toast.pulledFromRemote",{name:gt.remoteName}):gt?.kind==="pushed"?a("gitView.toast.pushedToUpstream",{name:gt.remoteName}):a("gitView.toast.syncedChanges")):y==="publish"&&ce.success(a("gitView.publish.succeeded")),await Et()}catch(De){if(De instanceof Pn||De instanceof jr){if(xe.isCurrent()&&await Et(),xe.isCurrent()&&De instanceof Pn&&De.read.availability==="available"&&De.read.operation.state==="conflicted"&&De.read.operation.error.code==="CONFLICT"){const jn=((await l.getGitStatus(p).catch(()=>null))?.files??[]).filter(dr).map(ir=>ir.path);jn.length>0&&Ct(jn,"merge")}return}if(De instanceof $t&&De.code==="stale-runtime")return;if(De instanceof $t&&at.errorMessage(De)){ce.info(at.errorMessage(De));return}await Et(),ce.error(De instanceof $t?De.code==="contributor-publish-cancelled-after-update"?a("gitView.toast.contributorPublishCancelledAfterUpdate"):De.code==="contributor-publish-cancelled"?a("gitView.toast.contributorPublishCancelled"):a("gitView.toast.syncActionFailed",{action:we}):De instanceof Error?De.message:a("gitView.toast.syncActionFailed",{action:we}))}finally{xe.finish(),xe.isCurrent()&&ue(null)}},Ht=u.useCallback(async(y,U)=>{if(!(!p||y.length===0))try{U==="stage"?y.length>1?await Vl(p,y):await Ul(p,y[0]):y.length>1?await Gl(p,y):await Kl(p,y[0]),await Oe(!1)}catch(ne){ce.error(ne instanceof Error?ne.message:a(U==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed"))}},[p,Oe,a]),is=u.useCallback((y,U=!1)=>{G({type:"diff",path:y,staged:U})},[G]),os=u.useCallback(async y=>{if(p){H(U=>new Set(U).add(y));try{await l.revertGitFile(p,y),ce.success(a("gitView.toast.revertedFile",{path:y})),await Oe(!1)}catch(U){ce.error(U instanceof Error?U.message:a("gitView.toast.revertFailed"))}finally{H(U=>{const ne=new Set(U);return ne.delete(y),ne})}}},[p,l,Oe,a]),mn=u.useCallback(async y=>{if(!p||y.length===0||ae)return;const U=Array.from(new Set(y));Re(!0),H(new Set(U));try{const ne=await Hm(U,xe=>l.revertGitFile(p,xe),Ym);if(await Oe(!1),ne.failures.length===0)ce.success(U.length===1?a("gitView.toast.revertedFilesSingle",{count:U.length}):a("gitView.toast.revertedFilesPlural",{count:U.length}));else if(ne.failures.length===U.length)ce.error(ne.failures[0]?.error?.message??a("gitView.toast.revertFailed"));else{const xe=U.length-ne.failures.length;ce.warning(xe===1?a("gitView.toast.revertedSomeSingle",{success:xe,failed:ne.failures.length}):a("gitView.toast.revertedSomePlural",{success:xe,failed:ne.failures.length}))}}catch(ne){ce.error(ne instanceof Error?ne.message:a("gitView.toast.revertFailed"))}finally{H(new Set),Re(!1)}},[p,l,ae,Oe,a]),pn=u.useCallback(y=>{const U=y.map(ne=>ne.trim()).filter(Boolean);if(U.length===0){Je([]);return}he(ne=>`${ne.trim()}${ne.trim()?`
|
|
23
|
+
|
|
24
|
+
`:""}${U.join(`
|
|
25
|
+
`)}`.trim()),Je([])},[]),hn=u.useCallback(async()=>{if(!p)return;const y=vt.map(U=>U.path).sort();if(y.length===0){ce.error(a("gitView.toast.selectFileToDescribe"));return}Ee(!0);try{const{message:U}=await Ei(p,y);he(U.subject?.trim()??""),Je(Array.isArray(U.highlights)?U.highlights:[])}catch(U){ce.error(U instanceof Error?U.message:a("gitView.toast.generateCommitMessageFailed"))}finally{Ee(!1)}},[p,vt,a]),Ts=async(y={})=>{if(!p)return;if(!Se.trim()){ce.error(a("gitView.toast.enterCommitMessage"));return}const U=vt.map(we=>we.path).sort();if(U.length===0){ce.error(a("gitView.toast.selectFileToCommit"));return}be(y.pushAfter?"commitAndPush":"commit");let ne=null,xe="pending";try{if(await l.createGitCommit(p,Se.trim(),{files:U}),xe="local",ce.success(a("gitView.toast.commitCreated")),he(""),Je([]),y.pushAfter){if(ne=xt.start(),!ne){ce.warning(a("gitView.publish.commitKept")),await Et();return}const we=await at.prepare("push",{onOperation:ne.onOperation});ue("publish"),await we(),xe="published",ce.success(a("gitView.publish.succeeded"))}await Et()}catch(we){if(y.pushAfter&&xe==="local"&&ce.warning(a("gitView.publish.commitKept")),we instanceof Pn||we instanceof jr){await Et();return}if(we instanceof $t&&we.code==="stale-runtime")return;if(we instanceof $t&&at.errorMessage(we)){ce.info(at.errorMessage(we));return}y.pushAfter&&await Et(),ce.error(we instanceof $t?we.code==="contributor-publish-cancelled-after-update"?a("gitView.toast.contributorPublishCancelledAfterUpdate"):we.code==="contributor-publish-cancelled"?a("gitView.toast.contributorPublishCancelled"):a("gitView.toast.syncActionFailed",{action:a("gitView.sync.syncChanges")}):we instanceof Error?we.message:a("gitView.toast.createCommitFailed"))}finally{ne?.finish(),be(null),y.pushAfter&&ue(null)}},gn=u.useMemo(()=>(h?.files??[]).filter(dr).length,[h?.files]),Ft=!!h?.mergeInProgress?.head,sr=u.useCallback(async()=>{if(p)try{if(Ft){const y=await l.continueMerge(p);y.conflict?(Ct(y.conflictFiles??[],"merge"),ce.error(a("gitView.toast.mergeConflictsDetected"))):ce.success(a("gitView.toast.mergeCompleted"))}else{const y=await l.continueRebase(p);y.conflict?(Ct(y.conflictFiles??[],"rebase"),ce.error(a("gitView.toast.rebaseConflictsDetected"))):ce.success(a("gitView.toast.rebaseStepCompleted"))}await Oe(!1)}catch(y){ce.error(y instanceof Error?y.message:a("gitView.toast.continueOperationFailed"))}},[p,l,Ft,Ct,Oe,a]),bn=u.useCallback(async y=>{if(p)try{y==="merge"?(await l.abortMerge(p),ce.success(a("gitView.toast.mergeAborted"))):(await l.abortRebase(p),ce.success(a("gitView.toast.rebaseAborted"))),await Oe(!1)}catch(U){ce.error(U instanceof Error?U.message:a("gitView.toast.abortOperationFailed"))}},[p,l,Oe,a]),nr=u.useCallback(()=>{const y=(h?.files??[]).filter(dr).map(U=>U.path);Ct(y,Ft?"merge":"rebase")},[Ft,Ct,h?.files]),rr=u.useMemo(()=>{const y=[];return vt.length>0&&y.push({id:"staged",title:a("gitView.changes.stagedTitle"),entries:vt,statsScope:"staged",actionSymbol:"-",actionAllLabel:a("gitView.changes.unstageAllAria"),getActionLabel:U=>a("gitView.changes.unstageFileAria",{path:U}),onActionFile:U=>{Ht([U],"unstage")},onActionAll:U=>{Ht(U,"unstage")},onViewDiff:U=>is(U,!0),onRevertFile:os,showRevertActions:!1,accent:!0}),Ps.length>0&&y.push({id:"unstaged",title:a("gitView.changes.title"),entries:Ps,statsScope:"working",actionSymbol:"+",actionAllLabel:a("gitView.changes.stageAllAria"),getActionLabel:U=>a("gitView.changes.stageFileAria",{path:U}),onActionFile:U=>{Ht([U],"stage")},onActionAll:U=>{Ht(U,"stage")},onViewDiff:U=>is(U,!1),onRevertFile:os}),y},[os,is,Ht,vt,a,Ps]),xn=t.jsxs(t.Fragment,{children:[at.context?t.jsx(iu,{context:at.context,onSelect:at.settle}):null,at.confirmDialog,t.jsx(ou,{candidates:ts.candidates,onSelect:ts.settle})]}),Ds=y=>t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[xn,t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[s?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":a("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(q,{name:"close",className:"size-5"})}):null,t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[t.jsx("h2",{className:"typography-ui-label text-foreground",children:a("mobile.nav.changes")}),t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:h?.current||p||""})]}),c===!1&&Array.isArray(g)&&g.length>0?t.jsx(pu,{repositories:g,selectedRepository:m??null,onSelectRepository:U=>{n&&_(n,U)},repositoryRoot:n??void 0}):null]}),t.jsx("div",{className:"min-h-0 flex-1",children:y})]});if(!p)return Ds(t.jsx(mt,{message:a("gitView.empty.selectSessionOrDirectory")}));if(c===!1&&B!==!0)return Ds(t.jsx(gu,{root:n,rootIsGitRepo:c,resolvedIsGitRepo:B,nestedRepos:g,onRetryDiscovery:()=>{n&&I(n,{force:!0})}}));if(T&&B===null)return Ds(t.jsx(mt,{loading:!0,message:a("gitView.loading.checkingRepository")}));if(D.type==="diff")return t.jsx(oo,{path:D.path,diff:Zn,staged:D.staged,fileExists:!!er,unavailableReason:en?.key===`${p}\0${D.path}`?en.reason:null,error:_t,onBack:()=>G({type:"list"}),onRetry:()=>sn(y=>y+1)});const _s=a($==="pr"?Nn("session.githubIntegration.tabs.pullRequests",Ge.provider):$==="branch"?"diffView.scope.branch":$==="commit"?"commitComparison.mode":"mobile.nav.changes"),yn=$==="branch"&&tt.base?au(tt.base):$==="commit"?Ye?.slice(0,8):$==="pr"&&yt?`#${yt.number}`:null;if(st&&ct)return t.jsx(oo,{path:st,subtitle:[_s,yn].filter(Boolean).join(" · "),diff:Kt??(ct.status==="ready"?ct.diff:null),fileExists:!Ie.files||Ie.files.some(y=>y.path===st),error:Ie.error??(ct.status==="error"?ct.message:null),onBack:()=>G(us),onRetry:()=>{Ie.error&&Ie.refresh(),Qn(y=>y+1)},onExpandContextRequest:ct.status==="ready"?y=>cn({source:ct,request:y}):void 0,pendingContextExpansion:zt,contextLoading:zt!==null&&!Kt});const vn=()=>$==="pr"&&!yt?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(mt,{loading:Ge.loading,message:Ge.error??(Ge.loading?a(Nn("session.githubPrPicker.loading.pullRequests",Ge.provider)):a(Nn("pullRequestComparison.select",Ge.provider)))}),!Ge.loading&&t.jsx(Di,{mobile:!0,comparison:Ge})]}):$==="branch"&&!tt.base?t.jsx(mt,{loading:!tt.resolved,message:tt.resolved?a("gitView.pr.toast.baseBranchRequired"):a("diffView.branch.resolvingBase")}):$==="commit"&&!Ye?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[Qe.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:Qe.loading?a("diffView.state.loadingChanges"):Qe.error??a("commitComparison.noCommits")}),Qe.error&&t.jsx(ke,{variant:"outline",size:"lg",onClick:()=>{Qe.refresh()},children:a("diffView.actions.retry")})]}):Ie.error?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx("p",{className:"typography-ui-label font-semibold",children:a("diffView.state.failedToLoadDiff")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:Ie.error}),t.jsx(ke,{variant:"outline",size:"lg",onClick:()=>{Ie.refresh()},children:a("diffView.actions.retry")})]}):Gt?Gt.length===0?t.jsx(mt,{icon:$==="branch",message:$==="pr"?a("walkthrough.blocked.emptyDiff.description"):$==="commit"?a("commitComparison.emptyDiff"):a("diffView.branch.empty",{base:yn??""})}):t.jsx(tp,{files:Gt,onSelect:y=>{Ie.key&&G({type:"comparison",path:y,sourceKey:Ie.key})}}):t.jsx(mt,{loading:!0,message:a("diffView.state.loadingChanges")});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[xn,t.jsxs("header",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b border-border/60 px-3 py-2",children:[s?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":a("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(q,{name:"close",className:"size-5"})}):null,t.jsxs(ql,{open:se,onOpenChange:te,children:[t.jsx(Hl,{asChild:!0,children:t.jsxs(ke,{variant:"outline",className:Jl({size:"default"}),"data-mobile-comparison-trigger":!0,"aria-label":a("diffView.scope.selectorAria"),children:[t.jsx("span",{children:_s}),t.jsx(q,{name:"arrow-down-s",className:"size-4"})]})}),t.jsx(Yl,{align:"start",children:t.jsxs(Xl,{value:$,onValueChange:y=>{(y==="working"||y==="branch"||y==="commit"||y==="pr")&&ie(y)},children:[t.jsx(Cn,{value:"working",className:"min-h-8 items-center",children:a("mobile.nav.changes")}),pt&&t.jsx(Cn,{value:"branch",className:"min-h-8 items-center",children:a("diffView.scope.branch")}),t.jsx(Cn,{value:"commit",className:"min-h-8 items-center",children:a("commitComparison.mode")}),t.jsx(Cn,{value:"pr",className:"min-h-8 items-center",children:a(Nn("session.githubIntegration.tabs.pullRequests",Ge.provider))})]})})]}),r&&$==="branch"&&t.jsx(wd,{mobile:!0,branches:b?.all??[],currentBranch:We,base:tt.base,onSelect:y=>{We&<(p,We,y)}},JSON.stringify([Y,We])),r&&$==="commit"&&t.jsx(jd,{mobile:!0,commits:Qe.commits,selectedHash:Ye,loading:Qe.loading,error:Qe.error,onSelect:Qe.select,onRefresh:()=>{Qe.refresh()}},JSON.stringify([Y,We])),r&&$==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(Di,{mobile:!0,comparison:Ge},JSON.stringify([Y,We])),yt&&t.jsx(ke,{variant:"ghost",size:"sm",disabled:Ie.loading,"aria-label":a("session.githubIssuePicker.actions.refresh"),onClick:()=>{Ie.refresh()},children:t.jsx(q,{name:"refresh",className:"size-4"})})]})]}),$==="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(lu,{currentBranch:h?.current,localBranches:rs,remoteBranches:tr,branchInfo:b?.branches,currentBranchAhead:h?.ahead,onCheckout:y=>{fn(y)},onCreate:Pt,disabled:T,directory:p,switchBlockedNotice:(h?.files?.length??0)>0?a("gitView.branch.switchBlockedNotice"):null})}),t.jsx(cu,{activeProfile:rn,identities:O,attention:Rt,triggerClassName:"max-w-[10rem] shrink [&_.git-identity-label]:hidden sm:[&_.git-identity-label]:inline",onOpen:()=>{C(f,E.map(y=>y.account))},onSelect:y=>{z(y)},isApplying:N,onConfigure:()=>R(!0),applicability:y=>{const U=Ue.read?.repository.remotes.find(ne=>ne.name===Ut);return U?uu(y,Ql(U.fetch.displayUrl)):{applicable:!0}}}),t.jsx(du,{syncAction:xt.entry?.executing?oe:null,remotes:dn,onFetch:y=>{Lt("fetch",y)},onPull:y=>{Lt("pull",y)},onSync:y=>{Lt("sync",y)},onPublish:()=>{Lt("publish")},onChooseSyncTargets:()=>{Lt("sync",void 0,!0)},currentBranch:h?.current,hasTracking:!!h?.tracking,disabled:T||xt.blocked,aheadCount:h?.ahead??0,behindCount:h?.behind??0,trackingRemoteName:h?.tracking?.split("/")[0],trackingBranch:h?.tracking,hasUncommittedChanges:fu(ut)})]}),t.jsx(ud,{open:x,onOpenChange:R,directory:p}),t.jsx(mu,{className:"mx-3 mt-3",entry:xt.entry,onRefresh:()=>{xt.refresh()},onCancel:()=>{xt.cancel()}}),$==="working"&&t.jsx(dd,{mergeInProgress:h?.mergeInProgress,rebaseInProgress:h?.rebaseInProgress,onContinue:sr,onAbort:()=>bn(Ft?"merge":"rebase"),onResolveWithAI:nr,conflictCount:gn,isLoading:oe!==null||Ce!==null}),$!=="working"?t.jsx("div",{className:"min-h-0 flex-1",children:vn()}):ut.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(fd,{groups:rr,diffStats:h?.diffStats,revertingPaths:Pe,onRevertAll:mn,isRevertingAll:ae,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:Fe})}),t.jsx("div",{className:"shrink-0 border-t border-border/70 px-4 pb-4 pt-3",children:t.jsx(md,{stagedCount:vt.length,commitMessage:Se,onCommitMessageChange:he,generatedHighlights:Te,onInsertHighlights:pn,onGenerateMessage:hn,isGeneratingMessage:Ae,onCommit:()=>{Ts({pushAfter:!1})},onCommitAndPush:()=>{Ts({pushAfter:!0})},commitAction:Ce,networkOperationBlocked:xt.blocked,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(mt,{icon:!0,message:a("gitView.empty.cleanTitle"),description:a("mobile.changes.cleanDescription")})}),p&&t.jsx(pd,{open:ns,onOpenChange:nn,conflictFiles:Es,directory:p,operation:Vt,onAbort:()=>{bn(Vt)},onNavigatedToChat:o}),t.jsx(hd,{open:ss!==null,onOpenChange:y=>{y||$e(null)},targetBranch:ss??"",changedFileCount:h?.files?.length??0,onCommitAndSwitch:async(y,U)=>{const ne=ss;if(!ne||!p)return;const xe=h?.current??null;if(await l.createGitCommit(p,y,{addAll:!0}),U)try{await(await at.prepare("push"))()}catch{ce.error(a("gitView.dirtySwitch.pushFailed")),await Oe(),$e(null);return}ce.success(xe?U?a("gitView.publish.succeeded"):a("gitView.dirtySwitch.committedNotPushed",{branch:xe}):a("gitView.toast.commitCreated")),await Oe(),$e(null),await Bt(ne)},onGenerateMessage:async()=>{if(!p)return"";const y=(h?.files??[]).map(ne=>ne.path).sort(),{message:U}=await Ei(p,y);return U.subject?.trim()??""},onRevertAndSwitch:async()=>{const y=ss;if(!y||!p)return;await mn((h?.files??[]).map(ne=>ne.path));const U=await l.getGitStatus(p);if(!U.isClean&&(U.files?.length??0)>0){ce.error(a("gitView.dirtySwitch.revertIncomplete"));return}$e(null),await Bt(y)}})]})},mt=n=>{const e=me.c(13),{message:s,description:i,loading:r,icon:o}=n,a=r===void 0?!1:r,l=o===void 0?!1:o;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 c;e[2]!==l?(c=l?t.jsx(q,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e[2]=l,e[3]=c):c=e[3];let m;e[4]!==s?(m=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[4]=s,e[5]=m):m=e[5];let g;e[6]!==i?(g=i?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i}):null,e[6]=i,e[7]=g):g=e[7];let p;return e[8]!==f||e[9]!==c||e[10]!==m||e[11]!==g?(p=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[f,c,m,g]})}),e[8]=f,e[9]=c,e[10]=m,e[11]=g,e[12]=p):p=e[12],p},oo=n=>{const e=me.c(50),{path:s,subtitle:i,diff:r,staged:o,fileExists:a,unavailableReason:l,error:f,onBack:c,onRetry:m,onExpandContextRequest:g,pendingContextExpansion:p,contextLoading:h}=n,b=o===void 0?!1:o,k=l===void 0?null:l,{t:x}=ye();let R;e[0]!==s?(R=Zl(s)||"text",e[0]=s,e[1]=R):R=e[1];const N=R,A=Me(sp),E=Me(np);let j;e[2]!==A||e[3]!==x?(j=x(A?"diffView.actions.showWhitespace":"diffView.actions.hideWhitespace"),e[2]=A,e[3]=x,e[4]=j):j=e[4];const v=j;let S;e[5]!==x?(S=x("header.actions.backAria"),e[5]=x,e[6]=S):S=e[6];let w;e[7]===Symbol.for("react.memo_cache_sentinel")?(w=t.jsx(q,{name:"arrow-left",className:"size-5"}),e[7]=w):w=e[7];let C;e[8]!==c||e[9]!==S?(C=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":S,onClick:c,children:w}),e[8]=c,e[9]=S,e[10]=C):C=e[10];let O;e[11]!==s?(O=t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:s}),e[11]=s,e[12]=O):O=e[12];let z;e[13]!==i?(z=i&&t.jsx("p",{className:"truncate typography-meta text-muted-foreground",children:i}),e[13]=i,e[14]=z):z=e[14];let B;e[15]!==O||e[16]!==z?(B=t.jsxs("div",{className:"min-w-0 flex-1 px-2",children:[O,z]}),e[15]=O,e[16]=z,e[17]=B):B=e[17];const T=A?"text-foreground":"text-muted-foreground";let P;e[18]!==T?(P=Q("flex size-9 shrink-0 items-center justify-center rounded-lg hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",T),e[18]=T,e[19]=P):P=e[19];let W;e[20]!==A||e[21]!==E?(W=()=>E(!A),e[20]=A,e[21]=E,e[22]=W):W=e[22];let I;e[23]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(q,{name:"space",className:"size-5"}),e[23]=I):I=e[23];let _;e[24]!==A||e[25]!==P||e[26]!==W||e[27]!==v?(_=t.jsx("button",{type:"button",className:P,"aria-label":v,"aria-pressed":A,title:v,onClick:W,children:I}),e[24]=A,e[25]=P,e[26]=W,e[27]=v,e[28]=_):_=e[28];let F;e[29]!==B||e[30]!==_||e[31]!==C?(F=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:[C,B,_]}),e[29]=B,e[30]=_,e[31]=C,e[32]=F):F=e[32];let M;e[33]!==h||e[34]!==r||e[35]!==f||e[36]!==a||e[37]!==A||e[38]!==N||e[39]!==g||e[40]!==m||e[41]!==s||e[42]!==p||e[43]!==b||e[44]!==x||e[45]!==k?(M=t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:a?k==="nested_repository"?t.jsx(mt,{icon:!0,message:x("diffView.unavailable.nestedRepositoryTitle"),description:x("diffView.unavailable.nestedRepositoryDescription")}):k==="untracked_directory"?t.jsx(mt,{icon:!0,message:x("diffView.unavailable.untrackedDirectoryTitle"),description:x("diffView.unavailable.untrackedDirectoryDescription")}):f?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:x("mobile.changes.diffDetail.loadFailed")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:f}),t.jsx(ke,{type:"button",size:"sm",variant:"outline",onClick:m,children:x("diffView.actions.retry")})]})}):r?r.submodule?t.jsx("div",{className:"p-3",children:t.jsx(Cd,{state:r.submodule,staged:b})}):r.isBinary?t.jsx(mt,{icon:!0,message:x("diffView.binary.unavailable")}):ec(s)&&!r.fileDiff?t.jsx(mt,{icon:!0,message:x("mobile.changes.diffDetail.imageUnavailable")}):t.jsx(Gn,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:t.jsx(Ed,{original:r.original,modified:r.modified,fileDiff:r.fileDiff,language:N,fileName:s,renderSideBySide:!1,wrapLines:!0,hideWhitespace:A,layout:"inline",onExpandContextRequest:g,pendingContextExpansion:p,contextLoading:h})}):t.jsx(mt,{loading:!0,message:x("diffView.state.loadingDiff")}):t.jsx(mt,{icon:!0,message:x("mobile.changes.diffDetail.missingTitle"),description:x("mobile.changes.diffDetail.missingDescription")})}),e[33]=h,e[34]=r,e[35]=f,e[36]=a,e[37]=A,e[38]=N,e[39]=g,e[40]=m,e[41]=s,e[42]=p,e[43]=b,e[44]=x,e[45]=k,e[46]=M):M=e[46];let K;return e[47]!==F||e[48]!==M?(K=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[F,M]}),e[47]=F,e[48]=M,e[49]=K):K=e[49],K},tp=n=>{const e=me.c(12),{files:s,onSelect:i}=n,{t:r}=ye();let o;e[0]!==r?(o=r("gitView.changes.changedFilesAria"),e[0]=r,e[1]=o):o=e[1];let a;if(e[2]!==s||e[3]!==i||e[4]!==r){let f;e[6]!==i||e[7]!==r?(f=c=>{const m=c.status==="A"?r("diffView.change.new"):c.status==="D"?r("diffView.change.deleted"):c.status==="R"?r("diffView.change.renamed"):c.status==="C"?r("diffView.change.copied"):r("diffView.change.modified"),g=c.status==="A"?"var(--status-success)":c.status==="D"?"var(--status-error)":c.status==="R"||c.status==="C"?"var(--status-info)":"var(--status-warning)";return t.jsx("li",{children:t.jsxs(ke,{variant:"ghost",size:"lg",className:"w-full justify-start gap-2.5 text-left normal-case",onClick:()=>i(c.path),children:[t.jsx("span",{className:"w-4 shrink-0 text-center typography-meta font-semibold uppercase",style:{color:g},"aria-label":m,children:c.status}),t.jsx(Fo,{filePath:c.path,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label",title:c.path,children:c.path}),(c.insertions>0||c.deletions>0)&&t.jsxs("span",{className:"shrink-0 typography-meta text-muted-foreground",children:["+",c.insertions," -",c.deletions]}),t.jsx(q,{name:"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground"})]})},c.path)},e[6]=i,e[7]=r,e[8]=f):f=e[8],a=s.map(f),e[2]=s,e[3]=i,e[4]=r,e[5]=a}else a=e[5];let l;return e[9]!==o||e[10]!==a?(l=t.jsx(Gn,{className:"h-full overflow-y-auto overflow-x-hidden px-3 py-2",children:t.jsx("ul",{"aria-label":o,className:"flex flex-col gap-1",children:a})}),e[9]=o,e[10]=a,e[11]=l):l=e[11],l};function sp(n){return n.diffHideWhitespace}function np(n){return n.setDiffHideWhitespace}const rp=u.lazy(()=>vs(()=>import("./FilesView-BVoD8I2x.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128])).then(n=>({default:n.FilesView}))),Nt=n=>Zs(n)??"",Ks=n=>{const e=Nt(n);return!e||e==="/"?e||"/":e.split("/").filter(Boolean).at(-1)??e},ip=n=>{const e=Nt(n);if(!e||e==="/")return null;const s=e.lastIndexOf("/");return s<=0?e.startsWith("/")?"/":null:e.slice(0,s)},op=(n,e)=>{const s=Nt(n),i=Nt(e);return!i||s===i?Ks(s):s.startsWith(`${i}/`)?s.slice(i.length+1):s},ap=n=>{if(typeof n!="number"||!Number.isFinite(n)||n<0)return"";if(n<1024)return`${n} B`;const e=["KB","MB","GB"];let s=n/1024;for(const i of e){if(s<1024||i===e[e.length-1])return`${s.toFixed(s>=10?0:1)} ${i}`;s/=1024}return""},lp=n=>{const e=me.c(6),{onClose:s,visible:i}=n,r=i===void 0?!0:i,o=zr()??null;let a;e[0]!==o?(a=Nt(o),e[0]=o,e[1]=a):a=e[1];const l=a;let f;return e[2]!==s||e[3]!==l||e[4]!==r?(f=t.jsx(cp,{root:l,onClose:s,visible:r},l),e[2]=s,e[3]=l,e[4]=r,e[5]=f):f=e[5],f},cp=({root:n,onClose:e,visible:s})=>{const{t:i}=ye(),{files:r}=Un(),o=Ka(),a=qa($=>$.setSelectedPath),[l,f]=u.useState(()=>({type:"browser",directory:n})),[c,m]=u.useState([]),[g,p]=u.useState(!1),[h,b]=u.useState(null),[k,x]=u.useState(""),[R,N]=u.useState([]),[A,E]=u.useState(!1),j=u.useRef(0),v=l.type==="browser"?l.directory:l.returnDirectory,S=u.useRef(v);S.current=v;const w=u.useCallback(async($,D)=>{if(!$)return;const se=!o,te=j.current+1;j.current=te,p(!0),D?.background||b(null);try{const ie=await r.listDirectory($,{respectGitignore:se});if(j.current!==te)return;b(null),m(ie.entries.slice().sort((G,oe)=>G.isDirectory!==oe.isDirectory?G.isDirectory?-1:1:G.name.localeCompare(oe.name)))}catch(ie){if(j.current!==te)return;if(D?.background){console.error("Failed to reload mobile directory:",ie);return}m([]),b(ie instanceof Error?ie.message:i("mobile.files.error.listFailed"))}finally{j.current===te&&p(!1)}},[r,o,i]);u.useEffect(()=>{l.type==="browser"&&w(l.directory)},[w,l]);const C=u.useRef(l);C.current=l;const O=u.useRef(c);O.current=c;const z=u.useCallback(({directories:$})=>{const D=C.current;D.type==="browser"&&($&&!$.some(se=>Nt(se)===Nt(D.directory))||O.current.length>bu||w(D.directory,{background:!0}))},[w]);xu({root:n,active:s,whileInactive:"hold",onChanges:z});const B=u.useCallback(async $=>{Nt($)===Nt(S.current)&&await w(S.current)},[w]),{canUpload:T,uploadingDirectory:P,pickFiles:W,uploadElements:I}=yu({root:n,refreshDirectory:B}),_=P!==null;u.useEffect(()=>{if(l.type!=="browser")return;const $=k.trim();if(!$){N([]),E(!1);return}let D=!1;const se=window.setTimeout(()=>{E(!0),r.search({directory:l.directory,query:$,maxResults:40}).then(te=>{D||N(te)}).catch(()=>{D||N([])}).finally(()=>{D||E(!1)})},250);return()=>{D=!0,window.clearTimeout(se)}},[r,k,l]);const F=$=>{x(""),f({type:"browser",directory:$})},M=$=>{a(n,$),f({type:"file",path:$,returnDirectory:v||n})},K=Me($=>$.pendingFileFocusPath),X=Me($=>$.pendingFileNavigation);if(u.useEffect(()=>{const $=Nt(X?.path??K??"");!$||!n||(a(n,$,{allowOutsideRoot:!0}),f({type:"file",path:$,returnDirectory:n}),K&&Me.getState().setPendingFileFocusPath(null))},[K,X,n,a]),!n)return t.jsx(qs,{message:i("mobile.files.empty.noDirectory")});if(l.type==="file")return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/70 px-3 text-foreground",children:[t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":i("header.actions.backAria"),onClick:()=>f({type:"browser",directory:l.returnDirectory}),style:{touchAction:"manipulation"},children:t.jsx(Pi,{className:"size-5"})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:Ks(l.path)})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(qe,{children:t.jsx(u.Suspense,{fallback:t.jsx(qs,{loading:!0,message:i("filesView.state.loading")}),children:t.jsx(rp,{mode:"editor-only"})})})})]});const Z=l.directory===n?i("mobile.files.rootDirectory"):Ks(l.directory),ee=k.trim()?R:[],Y=ip(l.directory),pe=l.directory!==n&&Y!==null&&(Y===n||Y.startsWith(`${n}/`)),fe=pe&&!k.trim(),re=pe?Y:null;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[I,t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[e?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":i("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(sd,{className:"size-5"})}):null,fe&&re?t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":i("mobile.files.backToParentAria",{name:Ks(re)}),onClick:()=>F(re),style:{touchAction:"manipulation"},children:t.jsx(Pi,{className:"size-5"})}):null,t.jsx("div",{className:"min-w-0 flex-1 px-1",children:t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:Z})}),t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":i("mobile.files.refreshAria"),onClick:()=>{w(l.directory)},style:{touchAction:"manipulation"},children:t.jsx(nd,{className:Q("size-5",g&&"animate-spin")})}),T?t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50","aria-label":i("sidebarFilesTree.actions.uploadFilesTitle"),onClick:()=>W(l.directory),disabled:_,style:{touchAction:"manipulation"},children:t.jsx(q,{name:_?"loader-4":"upload-2",className:Q("size-5",_&&"animate-spin")})}):null]}),t.jsx("div",{className:"shrink-0 px-4 pb-2 pt-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(rd,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(_o,{value:k,onChange:$=>x($.target.value),placeholder:i("mobile.files.search.placeholder"),className:"h-11 pl-9"})]})}),t.jsx(Gn,{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-3",children:h?t.jsx(qs,{message:h}):k.trim()?t.jsx(up,{results:ee,isSearching:A,onOpenFile:M}):t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:[c.length===0&&!g?t.jsx("div",{className:"px-4 py-8 text-center typography-body text-muted-foreground",children:i("mobile.files.empty.directory")}):null,c.map($=>t.jsx(Na,{name:$.name,path:$.path,directory:$.isDirectory,meta:$.isDirectory?void 0:ap($.size),onClick:()=>$.isDirectory?F($.path):M($.path)},$.path))]})})]})},Na=n=>{const e=me.c(16),{name:s,path:i,directory:r,meta:o,onClick:a}=n;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={touchAction:"manipulation"},e[0]=l):l=e[0];let f;e[1]!==r||e[2]!==i?(f=r?t.jsx(ad,{className:"size-5 shrink-0 text-primary/80"}):t.jsx(Fo,{filePath:i,className:"size-5 shrink-0"}),e[1]=r,e[2]=i,e[3]=f):f=e[3];let c;e[4]!==s?(c=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:s}),e[4]=s,e[5]=c):c=e[5];let m;e[6]!==o?(m=o?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:o}):null,e[6]=o,e[7]=m):m=e[7];let g;e[8]!==r?(g=r?t.jsx(ld,{className:"size-4 shrink-0 text-muted-foreground/60"}):null,e[8]=r,e[9]=g):g=e[9];let p;return e[10]!==a||e[11]!==f||e[12]!==c||e[13]!==m||e[14]!==g?(p=t.jsxs("button",{type:"button",className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3 py-2.5 text-left transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:a,style:l,children:[f,c,m,g]}),e[10]=a,e[11]=f,e[12]=c,e[13]=m,e[14]=g,e[15]=p):p=e[15],p},up=n=>{const e=me.c(10),{results:s,isSearching:i,onOpenFile:r}=n,{t:o}=ye(),a=Nt(zr()??null);if(i){let m;e[0]!==o?(m=o("common.loading"),e[0]=o,e[1]=m):m=e[1];let g;return e[2]!==m?(g=t.jsx(qs,{loading:!0,message:m}),e[2]=m,e[3]=g):g=e[3],g}if(s.length===0){let m;e[4]!==o?(m=o("mobile.files.search.empty"),e[4]=o,e[5]=m):m=e[5];let g;return e[6]!==m?(g=t.jsx(qs,{message:m}),e[6]=m,e[7]=g):g=e[7],g}const l="overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",f=s.map(m=>t.jsx(Na,{name:Ks(m.path),path:m.path,directory:!1,meta:op(m.path,a),onClick:()=>r(m.path)},m.path));let c;return e[8]!==f?(c=t.jsx("div",{className:l,children:f}),e[8]=f,e[9]=c):c=e[9],c},qs=n=>{const e=me.c(7),{message:s,loading:i}=n,r=i===void 0?!1:i;let o;e[0]!==r?(o=r?t.jsx(id,{className:"size-5 animate-spin text-muted-foreground"}):t.jsx(od,{className:"size-6 text-muted-foreground"}),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==s?(a=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==o||e[5]!==a?(l=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[o,a]})}),e[4]=o,e[5]=a,e[6]=l):l=e[6],l},ao="mobile-surface-root",dp=16,lo=320,fp="cubic-bezier(0.22, 1, 0.36, 1)",mp=n=>{const e=me.c(38),{onOpenMcpSettings:s,active:i}=n,{t:r}=ye(),[o,a]=u.useState(!1),l=Wt(hp),f=ds(gp),c=bs(bp);let m;e[0]!==l||e[1]!==o||e[2]!==c||e[3]!==f?(m=()=>{if(o)return;a(!0);const z=new Promise(xp);Promise.all([f({directory:l||null,silent:!0}),c({force:!0}),z]).finally(()=>a(!1))},e[0]=l,e[1]=o,e[2]=c,e[3]=f,e[4]=m):m=e[4];const g=m;let p;e[5]!==r?(p=r("settings.mcp.sidebar.actions.addServerTitle"),e[5]=r,e[6]=p):p=e[6];let h;e[7]!==r?(h=r("settings.mcp.sidebar.actions.addServerTitle"),e[7]=r,e[8]=h):h=e[8];let b,k;e[9]===Symbol.for("react.memo_cache_sentinel")?(b={touchAction:"manipulation"},k=t.jsx(q,{name:"add",className:"size-5"}),e[9]=b,e[10]=k):(b=e[9],k=e[10]);let x;e[11]!==s||e[12]!==p||e[13]!==h?(x=t.jsx("button",{type:"button",className:"flex size-10 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:s,"aria-label":p,title:h,style:b,children:k}),e[11]=s,e[12]=p,e[13]=h,e[14]=x):x=e[14];let R;e[15]!==r?(R=r("mcpDropdown.actions.refreshAria"),e[15]=r,e[16]=R):R=e[16];let N;e[17]!==r?(N=r("mcpDropdown.actions.refreshAria"),e[17]=r,e[18]=N):N=e[18];let A;e[19]===Symbol.for("react.memo_cache_sentinel")?(A={touchAction:"manipulation"},e[19]=A):A=e[19];const E=o&&"animate-spin";let j;e[20]!==E?(j=Q("size-5",E),e[20]=E,e[21]=j):j=e[21];let v;e[22]!==j?(v=t.jsx(q,{name:"refresh",className:j}),e[22]=j,e[23]=v):v=e[23];let S;e[24]!==o||e[25]!==g||e[26]!==v||e[27]!==R||e[28]!==N?(S=t.jsx("button",{type:"button",className:"flex size-10 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:g,disabled:o,"aria-label":R,title:N,style:A,children:v}),e[24]=o,e[25]=g,e[26]=v,e[27]=R,e[28]=N,e[29]=S):S=e[29];let w;e[30]!==S||e[31]!==x?(w=t.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-1 px-2 pt-1",children:[x,S]}),e[30]=S,e[31]=x,e[32]=w):w=e[32];let C;e[33]!==i?(C=t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(qm,{active:i,className:"h-full",listClassName:"max-h-none",hideHeader:!0,mobileListDensity:!0})}),e[33]=i,e[34]=C):C=e[34];let O;return e[35]!==w||e[36]!==C?(O=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[w,C]}),e[35]=w,e[36]=C,e[37]=O):O=e[37],O},pp=({open:n,onClose:e,tab:s,onTabChange:i,pendingChangesDiff:r,onOpenPlan:o,onOpenMcpSettings:a,variant:l="drawer"})=>{const{t:f}=ye(),c=u.useRef(null),m=u.useRef(null),[g,p]=u.useState(!1),[h,b]=u.useState(n),k=u.useRef(e);u.useEffect(()=>{k.current=e},[e]);const x=u.useRef(s);u.useEffect(()=>{x.current=s},[s]),ai(m,{enabled:l==="drawer"&&n,onLeftEdgeSwipe:()=>k.current()});const[R,N]=u.useState(()=>new Set);if(u.useEffect(()=>{n&&N(j=>{if(j.has(s))return j;const v=new Set(j);return v.add(s),v})},[n,s]),typeof document<"u"&&!c.current){let j=document.getElementById(ao);j||(j=document.createElement("div"),j.id=ao,document.body.appendChild(j)),c.current=j}if(u.useEffect(()=>{if(n){b(!0);const v=window.setTimeout(()=>p(!0),dp);return()=>window.clearTimeout(v)}p(!1);const j=window.setTimeout(()=>b(!1),lo+40);return()=>window.clearTimeout(j)},[n]),u.useEffect(()=>{if(!n)return;const j=document.body.style.overflow;l==="drawer"&&(document.body.style.overflow="hidden");const v=S=>{S.key!=="Escape"||x.current==="terminal"||oc(S.target)||k.current()};return document.addEventListener("keydown",v),()=>{l==="drawer"&&(document.body.style.overflow=j),document.removeEventListener("keydown",v)}},[n,l]),l==="drawer"&&!c.current)return null;const A=[{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(rc,{className:"h-3.5 w-3.5"})}],E=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(ic,{items:A,activeId:s,onSelect:j=>i(j),layoutMode:"fit",variant:"active-pill",nonCompositedIndicator:!0,inactiveTabsIconOnly:!0,className:"h-full"}):null}),t.jsx("button",{type:"button",className:"-mr-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":f("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(q,{name:"close",className:"size-5"})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[R.has("changes")?t.jsx("div",{className:Q("h-full",s!=="changes"&&"hidden"),children:t.jsx(qe,{children:t.jsx(Zm,{visible:n&&s==="changes",initialDiff:r,onNavigatedToChat:e})})},r?`changes:${r.path}:${r.staged}`:"changes"):null,R.has("files")?t.jsx("div",{className:Q("h-full",s!=="files"&&"hidden"),children:t.jsx(qe,{children:t.jsx(lp,{visible:n&&s==="files"})})}):null,R.has("terminal")?t.jsx("div",{className:Q("h-full",s!=="terminal"&&"hidden"),children:t.jsx(qe,{children:t.jsx(vu,{visible:n&&s==="terminal"})})}):null,R.has("notes")?t.jsx("div",{className:Q("h-full",s!=="notes"&&"hidden"),children:t.jsx(qe,{children:t.jsx(wu,{visible:n&&s==="notes",onActionComplete:e,onOpenPlan:o})})}):null,R.has("mcp")?t.jsx("div",{className:Q("h-full",s!=="mcp"&&"hidden"),children:t.jsx(qe,{children:t.jsx(mp,{active:n&&s==="mcp",onOpenMcpSettings:a})})}):null]})]});return l==="panel"?t.jsx("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:E}):ys.createPortal(t.jsx("section",{ref:m,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:g?"none":"translateX(100%)",transition:`transform ${lo}ms ${fp}`,visibility:h?"visible":"hidden",pointerEvents:n?"auto":"none"},children:E}),c.current)};function hp(n){return n.currentDirectory}function gp(n){return n.refresh}function bp(n){return n.loadMcpConfigs}function xp(n){return window.setTimeout(n,500)}function yp(n){const e=me.c(4),s=2500,{uiFont:i}=ac(),[r,o]=u.useState(!1);let a,l;return e[0]!==s||e[1]!==i?(a=()=>{let f=!1;const c=()=>{f||o(!0)},m=()=>{requestAnimationFrame(()=>requestAnimationFrame(c))},g=Promise.all([lc(i).catch(Sp),document.fonts?.ready?.then(kp).catch(jp)??Promise.resolve(),Ad.catch(wp)]).then(vp),p=new Promise(h=>{window.setTimeout(h,s)});return Promise.race([g,p]).then(m),()=>{f=!0}},l=[i,s],e[0]=s,e[1]=i,e[2]=a,e[3]=l):(a=e[2],l=e[3]),u.useEffect(a,l),r}function vp(){}function wp(){}function jp(){}function kp(){}function Sp(){}const Np="openchamber",Cp=n=>n.replace(/^\/+|\/+$/g,""),Rp=n=>{const e=Cp(n.pathname).split("/").filter(Boolean);return n.host?[n.host,...e]:e};function Ep(n){if(typeof n!="string"||n.length===0)return null;let e;try{e=new URL(n)}catch{return null}if(e.protocol!==`${Np}:`)return null;const s=Rp(e),i=(s[0]??"").toLowerCase(),r=s.slice(1),o=e.searchParams;switch(i){case"session":{const a=r[0]||o.get("id")||"";if(!a)return null;const l=o.get("message")?.trim()??"";return{type:"session",sessionId:a,directory:o.get("dir")??void 0,...cc(l)?{messageId:l}:{}}}case"new":case"new-session":return{type:"new-session",directory:o.get("dir")??void 0,projectId:o.get("project")??void 0,agent:o.get("agent")??void 0,model:o.get("model")??void 0};case"sessions":{const a=o.get("filter");return{type:"sessions",filter:a==="attention"||a==="recent"||a==="all"?a:void 0}}case"status":return{type:"status"};case"settings":return{type:"settings",section:r[0]||o.get("section")||void 0};case"changes":return{type:"changes",path:r.join("/")||o.get("path")||void 0,staged:o.get("staged")==="true"};case"view":{const a=(r[0]||"").toLowerCase();return a==="changes"?{type:"changes"}:a==="files"||a==="mcp"||a==="instances"||a==="update"?{type:"view",target:a}:null}default:return null}}let dt={},Ca=!1,Gs=null;const Ip=n=>{switch(n.type){case"session":return n.messageId&&!n.directory?(uc(n.sessionId,n.messageId),!0):(n.messageId&&dc(n.sessionId,n.messageId),_e.getState().setCurrentSession(n.sessionId,n.directory??null),!0);case"new-session":{const e=_e.getState();return e.openNewSessionDraft(),(n.directory||n.projectId)&&e.setNewSessionDraftTarget({directoryOverride:n.directory??null,projectId:n.projectId??null,selectedProjectId:n.projectId??null}),!0}case"sessions":return dt.openSessions?(dt.openSessions(n.filter),!0):!1;case"status":return dt.openSessions?(dt.openSessions(),!0):!1;case"view":return dt.openView?(dt.openView(n.target),!0):!1;case"changes":return dt.openChanges?(dt.openChanges({path:n.path,staged:n.staged}),!0):!1;case"settings":return dt.openSettings?(dt.openSettings(n.section),!0):!1}},li=()=>{if(!Ca||!Gs)return;const n=Gs;Gs=null,Ip(n)||(Gs=n)},Ra=n=>{Gs=n,li()},co=n=>{const e=Ep(n);e&&Ra(e)},Ap=n=>{Ca=n,li()},Pp=n=>{const e=me.c(3);let s,i;e[0]!==n?(s=()=>(dt=n,li(),()=>{dt===n&&(dt={})}),i=[n],e[0]=n,e[1]=s,e[2]=i):(s=e[1],i=e[2]),u.useEffect(s,i)},Tp=n=>{const{ready:e}=n;u.useEffect(()=>{Ap(e)},[e]),u.useEffect(()=>{if(!He())return;let s=!1;const i=[];return vs(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([129,5,54])).then(async({App:r})=>{if(s)return;const o=await r.addListener("appUrlOpen",a=>{co(a?.url)});if(s){o.remove();return}i.push(()=>{o.remove()})}).catch(()=>{}),vs(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([130,54])).then(async({PushNotifications:r})=>{if(s)return;const o=await r.addListener("pushNotificationActionPerformed",a=>{const l=a?.notification?.data,f=typeof l?.url=="string"?l.url:typeof l?.deeplink=="string"?l.deeplink:void 0;if(f){co(f);return}const c=typeof l?.sessionId=="string"?l.sessionId:void 0;c&&Ra({type:"session",sessionId:c})});if(s){o.remove();return}i.push(()=>{o.remove()})}).catch(()=>{}),()=>{s=!0,i.forEach(r=>r())}},[])},Dp=()=>{if(typeof window>"u")return;const n=window.__OPENCHAMBER_APNS_ENV__;if(n==="development")return"sandbox";if(n==="production")return"production"},uo=/^[A-Za-z0-9+/]{43}=$/,_p=Qu("PushKey"),Mp=async()=>{const n=window.__OPENCHAMBER_PUSH_KEY__;if(n&&uo.test(n))return n;const e=await _p.get().then(s=>s.key).catch(()=>{});return e&&uo.test(e)?e:void 0},Op=()=>{if(typeof window>"u")return!1;const e=window.Capacitor?.getPlatform?.();return e==="ios"||e==="android"},zp=n=>{const{enabled:e}=n,s=Me(r=>r.nativeNotificationsEnabled),i=u.useRef(null);u.useEffect(()=>{if(!e||!s||!Op())return;let r=!1;const o=[];return vs(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([130,54])).then(async({PushNotifications:a})=>{if(r)return;let l=await a.checkPermissions().catch(()=>null);if(l?.receive!=="granted"&&(l=await a.requestPermissions().catch(()=>null)),l?.receive!=="granted")return;const f=await a.addListener("registration",m=>{i.current=m.value,Mp().then(g=>{const p=wi(),h={token:m.value,platform:go(),environment:Dp()};g&&(h.pushKey=g),p?.push?.registerApnsToken?.(h)})}),c=await a.addListener("registrationError",m=>{console.warn("[Push] APNs registration error:",m)});if(await a.register().catch(()=>{}),r){f.remove(),c.remove();return}o.push(()=>{f.remove()},()=>{c.remove()})}).catch(()=>{}),()=>{r=!0,o.forEach(a=>a())}},[e,s]),u.useEffect(()=>{if(s)return;const r=i.current;if(!r)return;i.current=null,wi()?.push?.unregisterApnsToken?.({token:r})},[s])},fo=n=>{const e=me.c(12),{side:s,isResizing:i,ariaLabel:r,handleProps:o}=n,a=s==="left"?"right-0":"left-0";let l;e[0]!==a?(l=Q("absolute inset-y-0 z-50 w-6 cursor-col-resize touch-none",a),e[0]=a,e[1]=l):l=e[1];const f=s==="left"?"right-0":"left-0",c=i&&"bg-[var(--interactive-border)]";let m;e[2]!==f||e[3]!==c?(m=Q("absolute inset-y-0 w-[3px] transition-colors",f,c),e[2]=f,e[3]=c,e[4]=m):m=e[4];let g;e[5]!==m?(g=t.jsx("div",{className:m}),e[5]=m,e[6]=g):g=e[6];let p;return e[7]!==r||e[8]!==o||e[9]!==l||e[10]!==g?(p=t.jsx("div",{className:l,role:"separator","aria-orientation":"vertical","aria-label":r,...o,children:g}),e[7]=r,e[8]=o,e[9]=l,e[10]=g,e[11]=p):p=e[11],p},Bp=320,Lp=380,mo=280,Fp=560,$p=900;function po(n,e,s,i){const r=me.c(23),o=i===void 0?Fp:i,a=u.useRef(null);let l;r[0]!==s||r[1]!==o||r[2]!==e?(l=()=>{if(typeof window>"u")return s;const T=Number.parseInt(window.localStorage.getItem(e)??"",10);return Number.isFinite(T)?Math.min(o,Math.max(mo,T)):s},r[0]=s,r[1]=o,r[2]=e,r[3]=l):l=r[3];const[f,c]=u.useState(l),[m,g]=u.useState(!1),p=u.useRef(0),h=u.useRef(f),b=u.useRef(null),k=u.useRef(null);let x;r[4]!==o?(x=T=>Math.min(o,Math.max(mo,Math.round(T))),r[4]=o,r[5]=x):x=r[5];const R=x;let N;r[6]===Symbol.for("react.memo_cache_sentinel")?(N=T=>{const P=a.current;P&&(P.style.width=`${T}px`,P.style.minWidth=`${T}px`,P.style.maxWidth=`${T}px`,P.style.setProperty("--oc-ipad-sidebar-width",`${T}px`))},r[6]=N):N=r[6];const A=N;let E;r[7]!==f?(E=T=>{try{T.currentTarget.setPointerCapture(T.pointerId)}catch{}k.current=T.pointerId,p.current=T.clientX,h.current=f,b.current=f,g(!0),T.preventDefault()},r[7]=f,r[8]=E):E=r[8];const j=E;let v;r[9]!==R||r[10]!==n?(v=T=>{if(k.current!==T.pointerId)return;const P=T.clientX-p.current,W=R(h.current+(n==="left"?P:-P));b.current!==W&&(b.current=W,A(W))},r[9]=R,r[10]=n,r[11]=v):v=r[11];const S=v;let w;r[12]!==R||r[13]!==e?(w=T=>{if(k.current!==T.pointerId)return;try{T.currentTarget.releasePointerCapture(T.pointerId)}catch{}const P=R(b.current??h.current);k.current=null,b.current=null,g(!1),c(P);try{window.localStorage.setItem(e,String(P))}catch{}},r[12]=R,r[13]=e,r[14]=w):w=r[14];const C=w;let O;r[15]!==j||r[16]!==C||r[17]!==S?(O={onPointerDown:j,onPointerMove:S,onPointerUp:C,onPointerCancel:C},r[15]=j,r[16]=C,r[17]=S,r[18]=O):O=r[18];const z=O;let B;return r[19]!==z||r[20]!==m||r[21]!==f?(B={asideRef:a,width:f,isResizing:m,handleProps:z},r[19]=z,r[20]=m,r[21]=f,r[22]=B):B=r[22],B}const Wp=["general","isolated-spaces","appearance","chat","notifications","sessions","routing","git","magic-prompts","snippets","behavior","agents","commands","mcp","plugins","skills.installed","skills.catalog","providers","web-search","usage","voice","integrations","about"],Vp=1e3,Up=({onActiveConnectionDeleted:n})=>{const{t:e}=ye();Bu();const[s,i]=u.useState(!1);u.useEffect(()=>_e.subscribe((H,ae)=>{H.currentSessionId&&H.currentSessionId!==ae.currentSessionId&&Me.getState().setRunOverviewKey(null)}),[]);const r=Me(H=>H.runOverviewKey!==null);u.useEffect(()=>{r&&i(!1)},[r]);const[o,a]=u.useState(null),[l,f]=u.useState(!1),[c,m]=u.useState("changes"),[g,p]=u.useState(null),[h,b]=u.useState("nav"),[k,x]=u.useState(null),R=Me(H=>H.setSettingsPage),N=Me(H=>H.wideChatLayoutEnabled),A=ps(H=>H.available),E=ps(H=>H.runtimeType),j=u.useMemo(()=>Br(),[]),v=bs(H=>H.mcpServers),S=bs(H=>H.setMcpDraft),w=bs(H=>H.setSelectedMcp),C=u.useCallback(()=>{a(null),p(null)},[]),O=u.useCallback(H=>{a(H)},[]),z=u.useCallback(()=>{f(!1)},[]),B=u.useCallback(H=>{b(H),O("settings")},[O]),{enabled:T,roomyForPanels:P}=Tr(),I=Ac()==="portrait",_=Pc(),[F,M]=u.useState(()=>Tc().roomyForPanels),K=u.useCallback(()=>{M(H=>!H)},[]);u.useEffect(()=>{T||M(!1)},[T]);const X=u.useCallback(()=>{x(null),m("files"),f(!0)},[]);u.useEffect(()=>$o(H=>{if(H.type!=="file-open-request")return;const ae=H.directory??Wt.getState().currentDirectory;ae&&(Me.getState().openContextFile(ae,H.path),X())}),[X]);const Z=u.useCallback((H=null)=>{x(H),m("changes"),f(!0)},[]),ee=po("left","openchamber.ipad.leftSidebarWidth",Bp),Y=po("right","openchamber.ipad.rightSidebarWidth",Lp,$p),pe=P,fe=pe&&l?Y.width:0,re=T&&F?ee.width:0;u.useEffect(()=>{if(typeof document>"u")return;const H=document.documentElement;return H.style.setProperty("--oc-chat-inset-left",`${re}px`),H.style.setProperty("--oc-chat-inset-right",`${fe}px`),()=>{H.style.removeProperty("--oc-chat-inset-left"),H.style.removeProperty("--oc-chat-inset-right")}},[re,fe]),u.useEffect(()=>{if(typeof document>"u")return;const H=document.documentElement;return H.classList.toggle("wide-chat-layout",N),()=>H.classList.remove("wide-chat-layout")},[N]),u.useEffect(()=>{if(typeof document>"u")return;const H=T&&(I||_),ae=document.documentElement;return ae.classList.toggle("oc-keep-draft-starters",H),()=>ae.classList.remove("oc-keep-draft-starters")},[_,T,I]);const $=u.useMemo(()=>({openChanges:({diffPath:H,staged:ae}={})=>{Z(H?{path:H,staged:ae===!0}:null)},openFiles:()=>X(),openSettings:()=>B("nav"),openSourceBoard:()=>O("board")}),[Z,X,B,O]),D=u.useMemo(()=>({openSessions:()=>{T?M(!0):i(!0)},openView:H=>{if(H==="files"){X();return}if(H==="mcp"){m("mcp"),f(!0);return}O(H)},openChanges:({path:H,staged:ae}={})=>{Z(H?{path:H,staged:ae===!0}:null)},openSettings:H=>{H&&R(H),B(H?"page-content":"nav")}}),[T,Z,X,B,O,R]);Pp(D);const se=u.useRef(null);ai(se,{onLeftEdgeSwipe:()=>{T?M(!0):i(!0)},onRightEdgeSwipe:()=>f(!0)});const te=u.useRef(null),ie=u.useCallback(H=>{te.current=H},[]),G=u.useCallback(()=>Dc()?!0:g?(p(null),!0):o==="settings"&&te.current?.()?!0:o?(C(),!0):l?(z(),!0):s?(i(!1),!0):!1,[o,C,z,g,s,l]);_c(G);const oe=!j&&A&&(E==="desktop"||E==="web"),ue=T?"dialog":"fullscreen",Ce=u.useMemo(()=>({instanceLabel:j?Ws():null,onOpenInstances:j?()=>O("instances"):void 0,onOpenSettings:()=>B("nav"),onOpenUsage:()=>O("usage"),onOpenScheduled:()=>O("scheduled"),onOpenArchive:()=>O("archive"),onOpenSourceBoard:()=>O("board"),onOpenUpdate:oe?()=>O("update"):void 0}),[B,O,j,oe]),be=u.useCallback(H=>{C(),i(!1),H==="file"&&X()},[C,X]),Se=u.useCallback(()=>{C(),i(!1)},[C]),he=u.useCallback(()=>{C(),i(!1),T&&!P&&M(!1)},[C,T,P]),Pe=u.useCallback(()=>{const H="new-mcp-server";let ae=H,Re=1;for(;v.some(Ee=>Ee.name===ae);)ae=`${H}-${Re}`,Re+=1;S({name:ae,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",oauthCallbackPort:"",oauthAuthServerMetadataUrl:"",protocol:"legacy",timeoutStartup:"",timeoutCatalog:"",timeoutExecution:"",codemode:"default",disabled:!1}),w(ae),R("mcp"),B("page-content")},[v,B,S,w,R]);return t.jsx(Mc,{actions:$,children:t.jsxs("div",{className:"oc-mobile-app-shell main-content-safe-area flex h-[100dvh] flex-row bg-background text-foreground","data-page-scroll-lock":"true",children:[T?t.jsxs("aside",{ref:ee.asideRef,className:Q("relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!F&&"border-r-0"),style:{width:F?ee.width:0,minWidth:F?ee.width:0,maxWidth:F?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":!F,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:Q("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",!F&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(qe,{children:t.jsx(eo,{open:!0,variant:"sidebar",onOpenChange:H=>{!H&&!P&&M(!1)},footer:Ce})})}),F?t.jsx(fo,{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(Gf,{onOpenSessions:()=>T?K():i(!0),onOpenWorkspace:()=>f(!0),compactTitle:T}),t.jsxs("main",{ref:se,className:"relative min-h-0 flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[t.jsx("div",{className:"h-full w-full",children:t.jsx(qe,{children:t.jsx(Lu,{})})}),t.jsx(qe,{children:t.jsx(Fu,{})})]})]}),T?null:t.jsx(eo,{open:s,onOpenChange:i,footer:Ce}),t.jsxs("aside",{ref:Y.asideRef,className:Q("relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!fe&&"border-l-0"),style:{width:fe,minWidth:fe,maxWidth:fe,"--oc-ipad-sidebar-width":`${Y.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:Y.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!fe,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:Q("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",Y.isResizing&&"pointer-events-none",!fe&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(qe,{children:t.jsx(pp,{open:l,onClose:z,tab:c,onTabChange:m,pendingChangesDiff:k,onOpenPlan:p,onOpenMcpSettings:Pe,variant:pe?"panel":"drawer"})})}),fe?t.jsx(fo,{side:"right",isResizing:Y.isResizing,ariaLabel:e("sidebar.resize.rightPanelAria"),handleProps:Y.handleProps}):null]}),g?t.jsx(Tt,{open:!0,variant:ue,onClose:()=>p(null),ariaLabel:g.title,title:g.title,children:t.jsx(qe,{children:t.jsx(Ju,{savedProjectPlan:{projectRef:g.projectRef,planId:g.id},onNavigatedToChat:()=>{C(),z()}})})}):null,o==="instances"&&j?t.jsx(Tt,{open:!0,variant:ue,dialogAlign:"app",onClose:C,ariaLabel:e("mobile.menu.instances"),title:e("mobile.menu.instances"),children:t.jsx(Yf,{onConnect:C,onActiveConnectionDeleted:n})}):null,o==="settings"?t.jsx(Tt,{open:!0,variant:ue,dialogAlign:"app",onClose:C,ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(qe,{children:t.jsx(qu,{forceMobile:!0,isWindowed:!0,initialMobileStage:h,registerBackHandler:ie,visiblePageSlugs:[...Wp],onClose:C})})}):null,o==="usage"?t.jsx(Tt,{open:!0,variant:ue,dialogAlign:"app",onClose:C,ariaLabel:e("usageStats.title"),title:e("usageStats.title"),children:t.jsx(qe,{children:t.jsx($u,{})})}):null,o==="scheduled"?t.jsx(Tt,{open:!0,variant:ue,dialogAlign:"app",onClose:C,ariaLabel:e("sessions.scheduledTasks.dialog.title"),title:e("sessions.scheduledTasks.dialog.title"),children:t.jsx(qe,{children:t.jsx(Wu,{layout:"mobile",onLeave:be})})}):null,o==="board"?t.jsx(Tt,{open:!0,variant:ue,dialogAlign:"app",onClose:C,ariaLabel:e("sourceBoard.title"),title:e("sourceBoard.title"),children:t.jsx(qe,{children:t.jsx(Vu,{onLeave:Se})})}):null,o==="archive"?t.jsx(Tt,{open:!0,variant:ue,dialogAlign:"app",onClose:C,ariaLabel:e("sessions.archivePage.title"),title:e("sessions.archivePage.title"),children:t.jsx(qe,{children:t.jsx(Uu,{layout:"mobile",onLeave:he})})}):null,o==="update"?t.jsx(Tt,{open:!0,variant:ue,dialogAlign:"app",onClose:C,ariaLabel:e("mobile.menu.update"),title:e("mobile.menu.update"),children:t.jsx(qe,{children:t.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:t.jsx(Hu,{initialUpdateDialogOpen:!0})})})}):null]})})};function ho({apis:n}){const e=Me(D=>D.isolatedSpacesEnabled),{t:s}=ye(),i=ft(D=>D.initializeApp),r=ft(D=>D.isInitialized),o=ft(D=>D.isConnected),a=ft(D=>D.connectionPhase),l=ft(D=>D.providers.length),f=ft(D=>D.agents.length),c=ft(D=>D.loadProviders),m=ft(D=>D.loadAgents),g=Wt(D=>D.currentDirectory),p=_e(D=>D.error),h=_e(D=>D.clearError),b=Me(D=>D.setIsMobile),k=Lo(D=>D.refreshAll),x=fc(D=>D.refreshStatus),R=mc(D=>D.setPlanModeEnabled),N=ot(D=>D.projects),A=gs(D=>D.activeSessions),E=gs(D=>D.archivedSessions),j=gs(D=>D.status==="ready"),v=u.useMemo(()=>[...A,...E],[A,E]);ku({hasAuthoritativeGlobalSessions:j,sessions:v});const[S,w]=u.useState(0),[C,O]=u.useState(0),[z,B]=u.useState(!1),[T,P]=u.useState("pending"),[W,I]=u.useState(null),_=u.useMemo(()=>Ws(),[]),[,F]=u.useReducer(D=>D+1,0),M=u.useMemo(()=>Br(),[]),K=u.useRef(0),X=u.useRef(0),Z=u.useCallback(()=>{const D=St(),se=X.current+1;if(X.current=se,!D){Bs("resume:auto-connect",{}),Ls();return}Bs("resume:reprobe",{});const te=()=>{i(),k(n.sourceControl,{force:!0}),x(n.linear,{force:!0}),l===0&&c({source:"mobileApp:nativeResume"}),f===0&&m({source:"mobileApp:nativeResume"})},ie=oe=>{Bs("resume:disconnect",{reason:oe}),fs({apiBaseUrl:"",clientToken:null,runtimeKey:Sn}),w(ue=>ue+1)};Dn().then(oe=>{if(X.current===se){if(oe==="no-connection"){ie("no-connection");return}if(oe==="needs-login"){I({kind:"auth-expired",label:Ws()??""}),ie("needs-login");return}if(oe==="unreachable"){const ue=[4e3,1e4],Ce=be=>{window.setTimeout(()=>{if(X.current!==se)return;const Se=be===ue.length-1;Dn({fast:!Se}).then(he=>{if(X.current===se&&he!=="switched"){if(he==="unchanged"){te();return}if(he==="needs-login"){I({kind:"auth-expired",label:Ws()??""}),ie("retry-needs-login");return}if(!Se){Ce(be+1);return}ie(`retry-${he}`)}})},ue[be])};Ce(0);return}oe!=="switched"&&te()}});const G=Date.now();G-K.current>=Vp&&(K.current=G,window.dispatchEvent(new Event("openchamber:system-resume")))},[f,n.sourceControl,n.linear,i,m,c,l,k,x]);pc(),hc(Z),u.useEffect(()=>{if(!M)return;let D;const se=()=>{window.clearTimeout(D),D=window.setTimeout(()=>Z(),1500)};return window.addEventListener("online",se),()=>{window.removeEventListener("online",se),window.clearTimeout(D)}},[M,Z]),u.useEffect(()=>{if(M)return ji.subscribe((D,se)=>{D.state==="expired"&&se.state!=="expired"&&(Z(),ji.getState().markAuthenticated())})},[M,Z]),u.useEffect(()=>(ki(n),()=>ki(null)),[n]),u.useEffect(()=>xo(D=>{if(Bs("endpoint:changed",{runtimeKey:D.runtimeKey||"none",previousRuntimeKey:D.previousRuntimeKey||"none",connected:!!D.apiBaseUrl}),!!D.runtimeKey&&D.runtimeKey===D.previousRuntimeKey){Su(),F();return}Nu(D),O(te=>te+1),w(te=>te+1)}),[]),u.useEffect(()=>{if(!M||o||St()){P("done");return}let D=!1;return P("attempting"),(async()=>{const se=await Ls().catch(()=>({status:"no-candidate"}));D||(se.status==="unreachable"?I({kind:"unreachable",label:se.label}):se.status==="needs-login"&&I({kind:"auth-expired",label:se.label}),P("done"),se.status==="unreachable"&&Ls({fast:!1,skipIfConnected:!0}).catch(()=>null))})(),()=>{D=!0}},[]),u.useEffect(()=>{if(!M||!St())return;let D=!1;const se=te=>{Bs("cold-launch:drop",{kind:te?.kind??"unknown"}),te&&I(te),fs({apiBaseUrl:"",clientToken:null,runtimeKey:Sn}),w(ie=>ie+1)};return Dn().then(async te=>{if(D||te==="switched"||te==="unchanged")return;const ie=Ws();if(te==="needs-login"){se({kind:"auth-expired",label:ie??""});return}if(te==="unreachable"){se(ie?{kind:"unreachable",label:ie}:null),Ls({fast:!1,skipIfConnected:!0}).catch(()=>null);return}const G=await Ls().catch(()=>({status:"no-candidate"}));D||G.status==="connected"||(G.status==="needs-login"?se({kind:"auth-expired",label:G.label}):G.status==="unreachable"?se({kind:"unreachable",label:G.label}):se(null))}),()=>{D=!0}},[]),u.useEffect(()=>{b(!0)},[b]),u.useEffect(()=>{M&&!St()||i()},[S,i,M]),u.useEffect(()=>{o&&(l===0&&c({source:"mobileApp:recovery"}),f===0&&m({source:"mobileApp:recovery"}))},[f,o,m,c,l]);const ee=u.useRef(!1),[Y,pe]=u.useState(M);u.useEffect(()=>{if(!M||!o||ee.current)return;let D=!1;const se=window.setTimeout(()=>pe(!1),6e3);return(async()=>{const te=await Cu({refresh:!0});D||(te!=="failed"&&(ee.current=!0),pe(!1))})(),()=>{D=!0,window.clearTimeout(se)}},[S,o,M]),u.useEffect(()=>{o&&Si.setDirectory(g)},[g,o]),u.useEffect(()=>{o&&(k(n.sourceControl,{force:!0}),x(n.linear,{force:!0}))},[n.sourceControl,n.linear,o,k,x]),u.useEffect(()=>{if(!o||N.length===0)return;let D=!1;return(async()=>{const te=new Map(_e.getState().availableWorktreesByProject);if(await Promise.all(N.map(async oe=>{const ue=oe.path.replace(/\\/g,"/").replace(/\/+$/,"");if(ue)try{if(!(it.getState().directories.get(ue)?.isGitRepo??await vs(()=>import("./useAppFontEffects-DGlvOqP_.js").then(he=>he.mR),__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(he=>he.checkIsGitRepository(ue))))return;const Se=await zo({id:oe.id,path:ue});if(D)return;te.set(ue,Se)}catch{}})),D)return;const ie=Bo(N,te),G=_e.getState().availableWorktreesByProject;Ec(ie,G)||_e.setState({availableWorktrees:[...ie.values()].flat(),availableWorktreesByProject:ie})})(),()=>{D=!0}},[o,N]),u.useEffect(()=>{if(!o)return;let D=!1;const se=$o(te=>{te.type==="worktree-changed"&&Ic(N,te.directories,()=>D)});return()=>{D=!0,se()}},[o,N]),u.useEffect(()=>{let D=!1;return(async()=>{const te=await Pr("/health",{method:"GET"}).catch(()=>null);if(!te||!te.ok||D)return;const ie=await te.json().catch(()=>null);if(!ie||D)return;const G=ie.planModeExperimentalEnabled;R(G===!0||G===1||G==="1"||G==="true")})(),()=>{D=!0}},[R]),u.useEffect(()=>{if(!p)return;const D=window.setTimeout(()=>h(),5e3);return()=>window.clearTimeout(D)},[h,p]),u.useEffect(()=>{if(!(!o&&(M?!!St():!0))){B(!1);return}const se=window.setTimeout(()=>{B(!0)},M?4e3:8e3);return()=>window.clearTimeout(se)},[o,M,S,C]),gc(),bc({enabled:!0}),Ru(),xc(),yc(),Eu(),Iu(),zp({enabled:M&&o}),Tp({ready:M&&o&&r});const fe=yp(),re=!o&&a==="reconnecting";if(!fe)return t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-[var(--splash-background,var(--surface-background))] text-foreground",children:t.jsx(ms,{width:120,height:120,isAnimated:!0,variant:"splash"})});const $=!!St();return M&&(!$||!o&&!re)?$?t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-[var(--splash-background,var(--surface-background))] px-6 text-center text-foreground",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-4",children:[t.jsx(ms,{width:120,height:120,isAnimated:!z,variant:"splash"}),z?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:s("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:s("mobile.connect.recovery.description")})]}),t.jsx(ke,{type:"button",variant:"outline",onClick:()=>{fs({apiBaseUrl:"",clientToken:null,runtimeKey:Sn}),w(D=>D+1)},children:s("mobile.connect.cancelPassword")})]}):null]})}):T!=="done"?t.jsxs("main",{className:"relative flex min-h-dvh items-center justify-center bg-[var(--splash-background,var(--surface-background))] text-foreground",children:[t.jsx(ms,{width:120,height:120,isAnimated:!0,variant:"splash"}),_?t.jsxs("div",{className:"absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center",children:[t.jsx("p",{className:"typography-small text-muted-foreground",children:s("mobile.connect.splash.connectingTo")}),t.jsxs("p",{className:"typography-small text-foreground",children:[_,t.jsx(vc,{})]})]}):null]}):t.jsx(t.Fragment,{children:t.jsx(If,{onConnected:()=>w(D=>D+1),notice:W})}):!o&&!re?z?t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground",children:t.jsxs("div",{className:"max-w-sm space-y-3",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:s("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:s("sessionAuth.error.networkDescription")})]})}):t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-[var(--splash-background,var(--surface-background))] text-foreground",children:t.jsx(ms,{width:120,height:120,isAnimated:!0,variant:"splash"})}):t.jsx(qe,{children:t.jsx(wc,{sdk:Si.getSdkClient(),directory:g||"",children:t.jsx(jc,{apis:n,children:t.jsx(kc,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[t.jsx(Au,{ready:!M||!Y,animated:!0}),t.jsx(Sc,{backgroundWorkEnabled:r}),t.jsx(Pu,{}),t.jsx(Ld,{}),t.jsx(Up,{onActiveConnectionDeleted:()=>{xf(),fs({apiBaseUrl:"",clientToken:null,runtimeKey:Sn}),w(D=>D+1)}}),t.jsx(Nc,{}),t.jsx(Cc,{}),e?t.jsxs(t.Fragment,{children:[t.jsx(Tu,{}),t.jsx(Du,{}),t.jsx(_u,{}),t.jsx(Mu,{}),t.jsx(Ou,{})]}):null,t.jsx(Rc,{position:"top-center",offset:"calc(var(--oc-safe-area-top, 0px) + 16px)"}),r?t.jsx(zu,{}):null]})})})},C)})}function Gp(n){const e=me.c(4),s=u.useSyncExternalStore(Kp,St,St);if(Br()&&!s){let r;return e[0]!==n?(r=t.jsx(ho,{...n}),e[0]=n,e[1]=r):r=e[1],r}let i;return e[2]!==n?(i=t.jsx(ju,{children:t.jsx(ho,{...n})}),e[2]=n,e[3]=i):i=e[3],i}function Kp(n){return xo(()=>n())}function Nb(n){window.__OPENCHAMBER_SURFACE__="mobile",Oc(),Ku({logLabel:"[mobile-main]",onAppearanceSettled:Pd}),Bd(),zc();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");const i=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",r=i?{...n,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:n,o=t.jsx(Gp,{apis:r});Ma.createRoot(e).render(t.jsx(vr.StrictMode,{children:t.jsx(Bc,{children:t.jsx(Lc,{children:t.jsx(Fc,{children:t.jsx(Gu,{children:i?o:t.jsx($c,{children:o})})})})})}))}export{Nb as renderMobileApp};
|