@openchamber/web 2.3.2 → 2.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AboutDialog-MZbHWRua.js → AboutDialog-Ctk2zvrv.js} +1 -1
- package/dist/assets/{ArchiveView-CkeSWPcI.js → ArchiveView-sbNreasJ.js} +1 -1
- package/dist/assets/{CommandPalette-CtKzNzwW.js → CommandPalette-BICwnwAZ.js} +2 -2
- package/dist/assets/{DiffView-DaXjHTAq.js → DiffView-B5yeuxv8.js} +1 -1
- package/dist/assets/{FilesView-DMNYEydF.js → FilesView-ni2zfAwL.js} +7 -7
- package/dist/assets/{GitView-HXttTpUw.js → GitView-C0QgeC9O.js} +3 -3
- package/dist/assets/{GuestSurfacePane-KzguENQG.js → GuestSurfacePane-D1gLktSj.js} +1 -1
- package/dist/assets/{HelpDialog-9YZGhBgT.js → HelpDialog-CxC6qTaS.js} +1 -1
- package/dist/assets/{InProgressOperationBanner-DzGIwGH2.js → InProgressOperationBanner-JFV70YFh.js} +1 -1
- package/dist/assets/{JsonTreeView-D9rP8jM8.js → JsonTreeView-RsbV4Usa.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-CZK5DoOX.js +1 -0
- package/dist/assets/{MemoryDebugPanel-Ct0h3RWh.js → MemoryDebugPanel-caUWOKiz.js} +1 -1
- package/dist/assets/{OnboardingScreen-B5Zzb1Mp.js → OnboardingScreen-BDT-J2JP.js} +1 -1
- package/dist/assets/{OpenCodeStatusDialog-CXBWWRh8.js → OpenCodeStatusDialog-Cxa2yqOB.js} +1 -1
- package/dist/assets/{PatchDiff-DhDAQ5em.js → PatchDiff-C1pnbAsJ.js} +1 -1
- package/dist/assets/{PierreDiffViewer-DPa08AmN.js → PierreDiffViewer-D0zX2Msu.js} +1 -1
- package/dist/assets/PlanView-BxRCMuGe.js +5 -0
- package/dist/assets/{ProjectActionsDialog-DATu0aBc.js → ProjectActionsDialog-D660By4K.js} +1 -1
- package/dist/assets/{RunOverview-D6xy_vME.js → RunOverview-C1uTMnQS.js} +2 -2
- package/dist/assets/{ScheduledTasksDialog-BWXVnfrf.js → ScheduledTasksDialog-S-gAgo7Z.js} +5 -5
- package/dist/assets/SettingsView-CVpfbdob.js +30 -0
- package/dist/assets/{SettingsWindow-Cx6TrtY0.js → SettingsWindow-Dd1hHvgh.js} +1 -1
- package/dist/assets/SourceBoardView-DbGWAxtS.js +1 -0
- package/dist/assets/SpaceAccessDialog-muTSsEJ9.js +1 -0
- package/dist/assets/{SpaceApplyDialog-BtuwtlaG.js → SpaceApplyDialog-Dsf6MNGm.js} +1 -1
- package/dist/assets/{SpaceRow-MXqvd-dr.js → SpaceRow-7Z6ebRtm.js} +1 -1
- package/dist/assets/{SpaceSetupOutput-Uo5LS7Jy.js → SpaceSetupOutput-BytPfCOC.js} +1 -1
- package/dist/assets/{SpacesView-DvoOh4sM.js → SpacesView-CYCrlp0D.js} +1 -1
- package/dist/assets/{SubmoduleDiffSummary-CyMwDeoP.js → SubmoduleDiffSummary-VrNUbIqF.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BaUZIVzc.js → ToolOutputDialog-DHORjBND.js} +7 -7
- package/dist/assets/{ToolPartDiffPreview-DmMwdcF4.js → ToolPartDiffPreview-BLAXe7C5.js} +1 -1
- package/dist/assets/{UsageStatsView-D7WrDBTC.js → UsageStatsView-BxtYEAa0.js} +1 -1
- package/dist/assets/{Virtualizer-CnU8pYMb.js → Virtualizer-Bl4Cf-H-.js} +1 -1
- package/dist/assets/{WalkthroughView-r0Ho9F4Z.js → WalkthroughView-B2BJJ4u5.js} +2 -2
- package/dist/assets/{WorktreesView-C-t7uxq1.js → WorktreesView-Dv0AO9dF.js} +1 -1
- package/dist/assets/{appThemeRegistry-BUY7Ge9i.js → appThemeRegistry-xm_W0svA.js} +1 -1
- package/dist/assets/{ar-HauNhDvN.js → ar-Cj8UF12m.js} +4 -4
- package/dist/assets/{computeVirtualFileMetrics-CUof18z3.js → computeVirtualFileMetrics-Cx05cmWI.js} +2 -2
- package/dist/assets/{de-fEoJ_Yyp.js → de-fSQ1ho01.js} +4 -4
- package/dist/assets/{decorate-BkTSGAlD.js → decorate-jpF7GA6t.js} +2 -2
- package/dist/assets/{es-CKNTBsZW.js → es-DrdzhSlK.js} +5 -5
- package/dist/assets/{fileContentPoller-BJWgy1fX.js → fileContentPoller-C0f20jNG.js} +3 -3
- package/dist/assets/{flexokiTheme-BArobfXV.js → flexokiTheme-DKNCYSqL.js} +1 -1
- package/dist/assets/{fr-C23655Pi.js → fr-Cmz6Da4q.js} +4 -4
- package/dist/assets/{he-CphXS_Fv.js → he-COJRUNy4.js} +4 -4
- package/dist/assets/{index-B27cSA9V.js → index-C8Mw8uvl.js} +1 -1
- package/dist/assets/{initializeSharedPreferences-CucsmDMw.js → initializeSharedPreferences-U9-v9mfq.js} +1 -1
- package/dist/assets/{isDiffPlainText-DSCjvV0m.js → isDiffPlainText-DW43IghW.js} +1 -1
- package/dist/assets/{isFilePlainText-C7g4UPox.js → isFilePlainText-Duq5CiuG.js} +1 -1
- package/dist/assets/{ja-BmsU2iQe.js → ja-Ce0NvDHZ.js} +4 -4
- package/dist/assets/katex-BZNCT55U.css +1 -0
- package/dist/assets/katex.min-EZjpSwGK.js +65 -0
- package/dist/assets/{ko-CxISpkje.js → ko-BGFcCLLq.js} +4 -4
- package/dist/assets/main-BUetg9hg.js +1048 -0
- package/dist/assets/{main-CGPiw9fS.js → main-Be_jmIlF.js} +2 -2
- package/dist/assets/markdownCore-BkTeS4gA.js +10 -0
- package/dist/assets/{miniChat-DVEKVYKe.js → miniChat-g1RgiLLS.js} +2 -2
- package/dist/assets/{mobile-Q_FVBe4I.js → mobile-DBli3U-T.js} +2 -2
- package/dist/assets/{moveWorkspacePath-CyZJ-2aD.js → moveWorkspacePath-CnYc96Xo.js} +1 -1
- package/dist/assets/{nl-jnTBQ_gU.js → nl-Cu1nxo5t.js} +4 -4
- package/dist/assets/{parseDiffFromFile-OHXXXyzL.js → parseDiffFromFile-DEjkjYod.js} +3 -3
- package/dist/assets/{patchFileDiff-BZrb6h2u.js → patchFileDiff-D__42sau.js} +5 -5
- package/dist/assets/{pierreDiffTint-DHf2xvyt.js → pierreDiffTint-3oatL635.js} +4 -4
- package/dist/assets/pl-4LdEMgWI.js +20 -0
- package/dist/assets/{pt-BR-BfpsFrHv.js → pt-BR-2UbEBNgC.js} +5 -5
- package/dist/assets/{relocateRestoredSession-DInneXVI.js → relocateRestoredSession-pkxyd_lV.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-D0tKJFBB.js +2 -0
- package/dist/assets/renderMobileApp-D6bOYHuP.js +25 -0
- package/dist/assets/{restartOpenCode-DwBaMPJK.js → restartOpenCode-FYqjpaWc.js} +1 -1
- package/dist/assets/runtimeEndpointReset-6CNNzem4.js +74 -0
- package/dist/assets/{scheduledTasksApi-ClJplEhR.js → scheduledTasksApi-BbnQ4W-W.js} +1 -1
- package/dist/assets/{selectionMarkdown-BuveYuup.js → selectionMarkdown-D8QAxC44.js} +1 -1
- package/dist/assets/sessionOwnership-BBuf0UCB.js +1 -0
- package/dist/assets/{shikiHighlight-DJAESrna.js → shikiHighlight-CweIj1cL.js} +1 -1
- package/dist/assets/{space-apply-DWFLwXbI.js → space-apply-CEi013sa.js} +1 -1
- package/dist/assets/{space-close-BYDbwdWc.js → space-close-BuStkLrZ.js} +1 -1
- package/dist/assets/{spaceNetwork-DHrhfbKM.js → spaceNetwork-tH2d5Mgs.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-DcAZmUlv.js → textMateThemeFromAppTheme-DLJBL6al.js} +1 -1
- package/dist/assets/tr-Bg0Qt-mG.js +11 -0
- package/dist/assets/{uk-C82aEtvs.js → uk-vcnOugr0.js} +5 -5
- package/dist/assets/useAppFontEffects-Cs6k0JKv.js +773 -0
- package/dist/assets/{useCallableModelProviders-BU_455MN.js → useCallableModelProviders-BsGEzsl2.js} +1 -1
- package/dist/assets/{useInlineCommentController-AuUrVz9U.js → useInlineCommentController-CVYaPzfO.js} +2 -2
- package/dist/assets/{useRootScrollLock-Cpk7NmBa.js → useRootScrollLock-Dov-44ov.js} +2 -2
- package/dist/assets/{vendor-codemirror-language-data-BYGweLoh.js → vendor-codemirror-language-data-DBekkZIx.js} +2 -2
- package/dist/assets/vendor-tanstack-react-virtual-Dozz-7fb.js +1 -0
- package/dist/assets/vendor-tanstack-virtual-core-DKBj55Em.js +1 -0
- package/dist/assets/{vendor-yaml-3778uTud.js → vendor-yaml-CE-D_49-.js} +1 -1
- package/dist/assets/{zh-CN-DEq7j9I5.js → zh-CN-C3UhwFsk.js} +5 -5
- package/dist/assets/{zh-TW-DgCN99T-.js → zh-TW-D0CmmMvp.js} +5 -5
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +5 -5
- package/server/index.js +13 -1
- package/server/lib/agent-memory/actions.js +22 -9
- package/server/lib/agent-memory/actions.test.js +57 -0
- package/server/lib/agent-memory/runtime.js +8 -5
- package/server/lib/agent-tool/DOCUMENTATION.md +17 -1
- package/server/lib/agent-tool/runtime.js +41 -7
- package/server/lib/agent-tool/runtime.test.js +11 -0
- package/server/lib/git/DOCUMENTATION.md +17 -5
- package/server/lib/git/lfs-discovery.js +7 -4
- package/server/lib/git/lfs-discovery.test.js +60 -0
- package/server/lib/git/network-operations.js +9 -3
- package/server/lib/git/network-operations.test.js +31 -2
- package/server/lib/git/service.js +72 -12
- package/server/lib/git/service.test.js +65 -0
- package/server/lib/github/DOCUMENTATION.md +1 -0
- package/server/lib/github/reference-search.js +49 -18
- package/server/lib/github/reference-search.test.js +28 -6
- package/server/lib/github/routes.js +87 -1
- package/server/lib/github/routes.mutations.test.js +38 -0
- package/server/lib/github/routes.test.js +1 -0
- package/server/lib/gitlab/DOCUMENTATION.md +4 -0
- package/server/lib/gitlab/client.js +23 -0
- package/server/lib/gitlab/client.test.js +28 -1
- package/server/lib/gitlab/mappers.js +9 -0
- package/server/lib/gitlab/resources.js +153 -4
- package/server/lib/gitlab/resources.test.js +107 -0
- package/server/lib/gitlab/routes.js +120 -1
- package/server/lib/gitlab/routes.test.js +59 -0
- package/server/lib/markdown-image-grants/DOCUMENTATION.md +4 -0
- package/server/lib/markdown-image-grants/routes.js +14 -2
- package/server/lib/markdown-image-grants/routes.test.js +23 -0
- package/server/lib/notifications/APNS.md +24 -23
- package/server/lib/notifications/DOCUMENTATION.md +2 -2
- package/server/lib/notifications/apns-runtime.js +8 -5
- package/server/lib/notifications/apns-runtime.test.js +26 -0
- package/server/lib/notifications/message.js +5 -3
- package/server/lib/notifications/message.test.js +9 -0
- package/server/lib/notifications/runtime.js +44 -9
- package/server/lib/notifications/trigger-runtime.test.js +84 -0
- package/server/lib/openchamber-control/DOCUMENTATION.md +6 -1
- package/server/lib/openchamber-control/actions.js +18 -2
- package/server/lib/openchamber-control/project-knowledge.js +17 -3
- package/server/lib/openchamber-control/project-knowledge.test.js +14 -0
- package/server/lib/openchamber-control/render-page.js +58 -0
- package/server/lib/openchamber-control/service.js +9 -0
- package/server/lib/openchamber-control/service.test.js +43 -0
- package/server/lib/openchamber-sessions/routes.js +1 -0
- package/server/lib/openchamber-sessions/worktree-move.js +26 -10
- package/server/lib/openchamber-sessions/worktree-move.test.js +36 -0
- package/server/lib/opencode/DOCUMENTATION.md +1 -1
- package/server/lib/opencode/managed-config-file.js +3 -2
- package/server/lib/opencode/managed-config-file.test.js +20 -6
- package/server/lib/opencode/settings-helpers.js +3 -0
- package/server/lib/opencode/settings-helpers.test.js +1 -1
- package/server/lib/opencode/settings-registry.json +3 -0
- package/server/lib/opencode/settings-runtime.js +1 -0
- package/server/lib/project-context/DOCUMENTATION.md +25 -1
- package/server/lib/project-context/plan-progress.js +69 -0
- package/server/lib/project-context/plan-progress.test.js +58 -0
- package/server/lib/project-context/routes.http.test.js +22 -0
- package/server/lib/project-context/routes.js +20 -0
- package/server/lib/project-context/runtime.js +132 -18
- package/server/lib/project-context/runtime.test.js +58 -0
- package/server/lib/provider-read-cache/index.js +7 -1
- package/server/lib/provider-read-cache/index.test.js +12 -0
- package/server/lib/relay/DOCUMENTATION.md +17 -1
- package/server/lib/session-knowledge/DOCUMENTATION.md +17 -0
- package/server/lib/session-knowledge/runtime.js +29 -6
- package/server/lib/session-knowledge/runtime.test.js +26 -1
- package/server/lib/source-control/audit-storage.js +1 -0
- package/server/lib/source-control/mutation-storage.js +3 -0
- package/server/lib/spaces/DOCUMENTATION.md +14 -9
- package/server/lib/spaces/code-out.js +13 -4
- package/server/lib/spaces/code-out.test.js +5 -3
- package/server/lib/spaces/dispatcher.js +12 -5
- package/server/lib/spaces/dispatcher.test.js +19 -1
- package/server/lib/spaces/gatekeeper-channel.js +8 -7
- package/server/lib/spaces/gatekeeper-channel.test.js +10 -0
- package/server/lib/spaces/gatekeeper-program.cjs +38 -3
- package/server/lib/spaces/gatekeeper-program.test.js +20 -0
- package/server/lib/spaces/hardening.js +14 -1
- package/server/lib/spaces/hardening.test.js +5 -0
- package/server/lib/spaces/host-providers.js +165 -0
- package/server/lib/spaces/host-providers.test.js +100 -0
- package/server/lib/spaces/host.js +16 -4
- package/server/lib/spaces/journey.js +87 -17
- package/server/lib/spaces/journey.test.js +90 -2
- package/server/lib/spaces/layout.js +15 -5
- package/server/lib/spaces/places/docker-live-support.js +2 -0
- package/server/lib/spaces/places/docker.test.js +2 -0
- package/server/lib/spaces/places/fake-docker.js +3 -0
- package/server/lib/spaces/places/grants.docker.live.test.js +71 -7
- package/server/lib/spaces/routes.js +9 -0
- package/server/lib/spaces/routes.test.js +4 -2
- package/server/lib/spaces/space-opencode.js +31 -14
- package/server/lib/spaces/space-opencode.test.js +15 -2
- package/server/lib/spaces/space-records.js +8 -0
- package/server/lib/spaces/space-records.test.js +7 -3
- package/server/lib/spaces/websocket.test.js +13 -1
- package/server/lib/ui-auth/ui-auth.js +28 -3
- package/server/lib/ui-auth/ui-auth.test.js +31 -0
- package/dist/assets/MarkdownRendererImpl-B2LsA09C.js +0 -1
- package/dist/assets/PlanView-Dt5EN_JK.js +0 -5
- package/dist/assets/SettingsView-BolP_tuu.js +0 -30
- package/dist/assets/SourceBoardView-yca1qvgB.js +0 -1
- package/dist/assets/SpaceAccessDialog-CZ-u75py.js +0 -1
- package/dist/assets/katex-rNcbfUj4.css +0 -1
- package/dist/assets/katex.min-DQ8qF6NR.js +0 -65
- package/dist/assets/main-CVHM3_8W.js +0 -1048
- package/dist/assets/markdownCore-D5ZOJXeO.js +0 -9
- package/dist/assets/pl-Bj-Hy0X5.js +0 -20
- package/dist/assets/renderElectronMiniChatApp-B_5BeSF6.js +0 -2
- package/dist/assets/renderMobileApp-DGEXUTk-.js +0 -25
- package/dist/assets/runtimeEndpointReset-CIpvn8QG.js +0 -59
- package/dist/assets/sessionOwnership-BZoGed9N.js +0 -1
- package/dist/assets/tr-qMRMBQ8r.js +0 -11
- package/dist/assets/useAppFontEffects-Bih1DxXi.js +0 -745
- package/dist/assets/vendor-tanstack-react-virtual-CvuLsk7D.js +0 -1
- package/dist/assets/vendor-tanstack-virtual-core-DPaNcJcT.js +0 -1
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesView-DMNYEydF.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/katex.min-DQ8qF6NR.js","assets/vendor-zod-CVhJ1Zpv.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-DgOf1DP0.js","assets/katex-rNcbfUj4.css","assets/useAppFontEffects-Bih1DxXi.js","assets/vendor-base-ui-CXFyogip.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-tanstack-react-virtual-CvuLsk7D.js","assets/vendor-tanstack-virtual-core-DPaNcJcT.js","assets/vendor-framer-motion-DxDVhOLc.js","assets/vendor-motion-dom-HXPOMxb7.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-codemirror-commands-dar6chwA.js","assets/vendor-codemirror-state-Dek9sMtw.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-B66jUSmE.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-codemirror-language-DyL0aCoH.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-streamparser-CmlTsbN2.js","assets/vendor-codemirror-lang-javascript-Cem6LjJ8.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-CIqXJolH.js","assets/vendor-codemirror-lang-json-C9rLLO0q.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-9qjxcVkg.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-D7VQUxeE.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-Cikh4w2I.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-BYGweLoh.js","assets/vendor-codemirror-lang-python-DVl8-2Op.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-legendapp-list-BCBzRcfK.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/flexokiTheme-BArobfXV.js","assets/vendor-codemirror-search-BKAwkhkm.js","assets/vendor-replit-codemirror-vim-CKWqK1yR.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/moveWorkspacePath-CyZJ-2aD.js","assets/fileContentPoller-BJWgy1fX.js","assets/useInlineCommentController-AuUrVz9U.js","assets/runtimeEndpointReset-CIpvn8QG.js","assets/JsonTreeView-D9rP8jM8.js","assets/parseDiffFromFile-OHXXXyzL.js","assets/computeVirtualFileMetrics-CUof18z3.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-yJ9XpNMI.js","assets/vendor-pierre-theming-Dgp7B_O4.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/vendor-diff-C3JhlQdm.js","assets/Virtualizer-BP6uuKe_.js","assets/isFilePlainText-C7g4UPox.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/shikiHighlight-DJAESrna.js","assets/appThemeRegistry-BUY7Ge9i.js","assets/textMateThemeFromAppTheme-DcAZmUlv.js","assets/Virtualizer-CnU8pYMb.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/scheduledTasksApi-ClJplEhR.js","assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-capacitor-push-notifications-KNe1zSBF.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{f as fe,r as Pr,j as t,R as c,c as Ds,h as al}from"./vendor-react-BUCujlKS.js";import{u as Ve,_ as gn,bc as qr,bd as _i,be as tt,aZ as jt,bf as Rs,bg as fn,l as $o,bh as ll,bi as Wo,bj as cl,bk as ul,bl as dl,bm as fl,bn as ml,e as Dt,n as bn,z as pl,A as hl,bo as Ct,aq as An,bp as gl,$ as Qs,b as Oi,aG as Zs,aT as bl,aw as zi,ag as xl,af as yl,bq as Bi,ae as vl,a0 as Vo,br as Li,at as Fi,v as $i,bs as Pn}from"./katex.min-DQ8qF6NR.js";import{G as ls,dD as wl,a3 as it,cK as Tr,cL as Uo,J as Go,gk as jl,u as ve,z as de,cg as kl,I as X,dk as Sl,B as Ee,av as Ko,a8 as Es,L as ee,bN as qo,gl as Nl,gm as Cl,d4 as Rl,$ as ft,aJ as El,gn as rs,go as Il,gp as Wi,gq as Al,gr as Pl,eu as Hr,d0 as Tl,d1 as Dl,F as Be,ef as Ml,eh as Jr,ei as Xr,gs as Yr,ek as _l,ej as Ho,gt as Qr,dB as Wn,cn as Jo,gu as Ol,e2 as Xo,ay as ut,cm as Yo,bS as Zn,gv as zl,gw as Bl,gx as Ll,gy as Fl,f1 as Ln,fK as Dr,fu as Lt,gz as $l,k as Wl,aB as Qo,cz as Zo,cA as ea,cB as ta,gA as Vl,gB as Ul,gC as Gl,dC as Vi,gD as sa,gE as na,y as ra,gF as Kl,gG as ql,gH as ia,gI as Hl,cM as Jl,a4 as Xl,cX as Yl,gJ as vr,gK as Ql,cW as Ns,gL as oa,K as Zl,gM as ec,aL as Mr,aM as _r,aN as Or,b_ as Ui,b$ as wr,aO as en,cy as er,ck as tc,bI as aa,dr as la,gN as sc,gO as nc,gP as Cs,gQ as Ps,T as rc,U as ic,V as oc,gR as ac,fD as lc,az as Zr,d$ as cc,e3 as uc,eN as dc,eW as fc,eR as mc,eA as ca,eS as pc,eX as hc,e4 as gc,e0 as bc,fv as xc,fz as yc,e5 as vc,gS as wc,gT as jc,gU as kc,gV as Sc,fC as Gi,dT as Tn,ce as Nc,bV as Cc,bX as Dn,e7 as Rc,eU as Ec,bz as Ic,e6 as Ac,fH as Pc,fJ as Tc,fE as Dc,c$ as ua,aP as et,cU as Mc,cl as _c,gW as Oc,gX as zc,gY as Bc,gZ as Lc,cZ as Fc,g_ as $c,eP as Ki,g$ as ei,bZ as Wc,h0 as Vc,h1 as Uc,cC as zr,dd as Gc,de as Kc,df as qc,dg as Hc,h2 as Jc,dm as Xc,dl as Yc,dh as Qc,h3 as Zc,di as eu,dj as tu,ds as su,dq as nu,h4 as ru,h5 as iu,h6 as ou,h7 as au,h8 as lu,h9 as cu,ha as uu,hb as du,dt as fu,du as mu,dv as pu,dw as hu}from"./useAppFontEffects-Bih1DxXi.js";import{a2 as Is,a3 as gu,a4 as bu,a5 as xu,a6 as yu,a7 as da,a8 as fa,a9 as ma,aa as vu,ab as wu,ac as ju,ad as Mn,ae as ku,af as Su,ag as Nu,S as Cu,B as pa,a as Ru,ah as Eu,ai as Iu,aj as Au,ak as Pu,I as _n,Q as Tu,R as Du,L as Mu,w as qi,V as jr,X as _u,Y as Ou,z as zu,al as Bu,J as Lu,K as Fu,am as $u,an as Wu,M as Vu,x as Uu,Z as Gu,H as Ku,ao as qu,ap as Hu,_ as Ju,aq as Xu,ar as Yu,as as Qu,at as Zu,au as ed,av as td,aw as sd,ax as nd,ay as rd,az as id,aA as od,aB as ad,aC as ld,aD as cd,aE as ud,aF as dd,aG as fd,aH as md,aI as pd,aJ as hd}from"./runtimeEndpointReset-CIpvn8QG.js";import{i as gd}from"./initializeSharedPreferences-CucsmDMw.js";import{_ as Ms}from"./vendor-vite-runtime-DD1OZmLC.js";import{S as bd,A as xd}from"./SettingsView-BolP_tuu.js";import{PlanView as yd}from"./PlanView-Dt5EN_JK.js";import{SpaceAccessDialog as vd}from"./SpaceAccessDialog-CZ-u75py.js";import{SpaceApplyDialog as wd}from"./SpaceApplyDialog-BtuwtlaG.js";import{SpaceSetupOutputDialog as jd}from"./SpaceSetupOutput-Uo5LS7Jy.js";import{RunOverview as kd}from"./RunOverview-D6xy_vME.js";import{p as Sd}from"./vendor-aparajita-capacitor-secure-storage-5IShChL0.js";import{Capacitor as Nd,registerPlugin as ha}from"./vendor-capacitor-core-B4EWRrHz.js";import{k as Br,d as Cd,M as Vn,J as ga,a as ti,s as ba,p as Rd,_ as Hi,f as si,V as Ed,K as Ji,P as Id,b as Ad,c as Pd,U as Td,Z as Dd,Q as Md,r as _d}from"./vendor-remixicon-react-D6dZ0UwF.js";import{f as ni,h as _s,i as ri,P as ii,D as oi,j as ai}from"./vendor-dnd-kit-core-BZknOX2w.js";import{S as li,v as ci,u as ui,s as di}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as fi}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{c as Od}from"./sessionOwnership-BZoGed9N.js";import{c as mi,p as xa}from"./vendor-zustand-BAGL70zf.js";import{toast as Lr}from"./vendor-sonner-DFyL3AvE.js";import{S as zd}from"./SpaceRow-MXqvd-dr.js";import{UsageStatsView as Bd}from"./UsageStatsView-D7WrDBTC.js";import{ArchiveSessionsView as Ld}from"./ArchiveView-CkeSWPcI.js";import{MobileSourceBoard as Fd}from"./SourceBoardView-yca1qvgB.js";import{ScheduledTasksView as $d}from"./ScheduledTasksDialog-BWXVnfrf.js";import{i as Wd,a as Vd,b as Ud,c as Gd,d as Kd,S as qd,W as Hd}from"./SubmoduleDiffSummary-CyMwDeoP.js";import{R as Jd,I as Xd,C as Yd,a as Qd,b as Zd,D as ef}from"./InProgressOperationBanner-DzGIwGH2.js";import{b as Xi,a as tf,c as sf,u as nf,i as rf,f as Yi,B as of,C as af,P as Qi}from"./patchFileDiff-BZrb6h2u.js";import{P as lf}from"./PierreDiffViewer-DPa08AmN.js";import{p as cf}from"./parseDiffFromFile-OHXXXyzL.js";import{o as ya,s as Zi}from"./vendor-zod-CVhJ1Zpv.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-opencode-client-DgOf1DP0.js";import"./vendor-base-ui-CXFyogip.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tanstack-react-virtual-CvuLsk7D.js";import"./vendor-tanstack-virtual-core-DPaNcJcT.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-dar6chwA.js";import"./vendor-codemirror-state-Dek9sMtw.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-B66jUSmE.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-language-DyL0aCoH.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-streamparser-CmlTsbN2.js";import"./vendor-codemirror-lang-javascript-Cem6LjJ8.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-CIqXJolH.js";import"./vendor-codemirror-lang-json-C9rLLO0q.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-9qjxcVkg.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-D7VQUxeE.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-Cikh4w2I.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-BYGweLoh.js";import"./vendor-codemirror-lang-python-DVl8-2Op.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-legendapp-list-BCBzRcfK.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-yaml-3778uTud.js";import"./flexokiTheme-BArobfXV.js";import"./vendor-codemirror-search-BKAwkhkm.js";import"./vendor-replit-codemirror-vim-CKWqK1yR.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./shikiHighlight-DJAESrna.js";import"./appThemeRegistry-BUY7Ge9i.js";import"./textMateThemeFromAppTheme-DcAZmUlv.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-qrcode-DTJ12-WC.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./vendor-strip-json-comments-5dJlOkP1.js";import"./useCallableModelProviders-BU_455MN.js";import"./restartOpenCode-DwBaMPJK.js";import"./useInlineCommentController-AuUrVz9U.js";import"./fileContentPoller-BJWgy1fX.js";import"./spaceNetwork-DHrhfbKM.js";import"./space-apply-DWFLwXbI.js";import"./scheduledTasksApi-ClJplEhR.js";import"./vendor-cron-parser-CjvYVigk.js";import"./vendor-luxon-BZ0puJYg.js";import"./changesTree-CePHbFcj.js";import"./computeVirtualFileMetrics-CUof18z3.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-DSCjvV0m.js";import"./vendor-diff-C3JhlQdm.js";import"./pierreDiffTint-DHf2xvyt.js";import"./Virtualizer-CnU8pYMb.js";let va=null,eo=!1;const uf=new Promise(n=>{va=n});function df(){eo||(eo=!0,va?.())}const ff=6,mf=n=>n.parentID??null,Fr=n=>{const e=n.replace(/\/+$/,"");return e.slice(e.lastIndexOf("/")+1)||e},pf=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),hf=(n,e)=>{if(!n)return"";let s=null,r=-1;for(const i of e){const a=pf(i.path);(n===a||n.startsWith(`${a}/`))&&a.length>r&&(s=i,r=a.length)}return s?s.label?.trim()||Fr(s.path):Fr(n)},gf=()=>{const n=ls.getState().activeSessions,e=wl.getState().index.session.unseenCount,s=Ve.getState().notifyOnSubtasks,r=it.getState().projects,i=Tr.getState().ids,a=Uo.getState().rankById;let o=0;const l=[];for(const d of n){const m=mf(d)!==null,p=(e[d.id]??0)>0&&(!m||s);p&&(o+=1),m||l.push({session:d,unread:p,project:hf(Go(d),r)})}l.sort((d,m)=>jl(d.session,m.session,i,a));const f=l.slice(0,ff).map(({session:d,unread:m,project:h})=>({id:d.id,title:d.title??"",unread:m,project:h}));return{runtimeKey:gn(),attentionCount:o,recentSessions:f,projects:r.map(d=>({id:d.id,label:d.label?.trim()||Fr(d.path)}))}},bf="__OPENCHAMBER_WIDGET_SNAPSHOT__",xf=()=>{typeof window>"u"||(window[bf]=()=>{try{return JSON.stringify(gf())}catch{return null}})},kr="mobile-app-update-available",to="mobile-app-update-toast-dismissed-version",yf=()=>{const n=fe.c(8),{t:e}=ve(),s=Is(vf),r=Is(wf),i=Is(jf),a=Is(kf);let o;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=new Set,n[0]=o):o=n[0];const l=Pr.useRef(o);let f,d;return n[1]!==s||n[2]!==a||n[3]!==r||n[4]!==e||n[5]!==i?(f=()=>{if(qr()!=="android"||r!=="mobile"||!s||!i||!a){de.dismiss(kr);return}_i().getItem(to)!==i&&(l.current.has(i)||(l.current.add(i),de.info(e("mobileUpdate.toast.available.title"),{id:kr,description:e("mobileUpdate.toast.available.description",{version:i}),duration:1/0,icon:t.jsx(X,{name:"download",className:"h-4 w-4 text-muted-foreground"}),action:{label:e("mobileUpdate.toast.actions.download"),onClick:()=>{kl(a)}},cancel:{label:e("mobileUpdate.toast.actions.dismiss"),onClick:()=>{_i().setItem(to,i),de.dismiss(kr)}}})))},d=[s,a,r,e,i],n[1]=s,n[2]=a,n[3]=r,n[4]=e,n[5]=i,n[6]=f,n[7]=d):(f=n[6],d=n[7]),Pr.useEffect(f,d),null};function vf(n){return n.available}function wf(n){return n.runtimeType}function jf(n){return n.info?.version}function kf(n){return n.info?.downloadUrl}const so="calc(var(--oc-safe-area-top, 0px) + var(--oc-visual-viewport-offset-top, 0px) + 16px)";function Sf(n){const e=fe.c(3);let s,r;e[0]!==n?(s=()=>{const i=window.visualViewport,a=n.current;if(!i||!a)return;let o="";const l=()=>{const f=`${Math.max(0,Math.round(i.offsetTop))}px`;f!==o&&(o=f,a.style.setProperty("--oc-visual-viewport-offset-top",f))};return l(),i.addEventListener("scroll",l),i.addEventListener("resize",l),()=>{i.removeEventListener("scroll",l),i.removeEventListener("resize",l)}},r=[n],e[0]=n,e[1]=s,e[2]=r):(s=e[1],r=e[2]),c.useEffect(s,r)}function Nf(){const n=fe.c(1),e=c.useRef(null);Sf(e);let s;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx("div",{ref:e,className:"contents",children:t.jsx(Sl,{position:"top-center",offset:so,mobileOffset:{top:so}})}),n[0]=s):s=n[0],s}const no=300,Cf="openchamber.mobile.connectLog.v1",As=[];if(typeof window<"u")try{window.localStorage.removeItem(Cf)}catch{}const pi=(n,e)=>{As.push({at:Date.now(),step:n,detail:e}),As.length>no&&As.splice(0,As.length-no)};typeof window<"u"&&pi("app:launch","{}");const Rf=()=>[...As],Ef=n=>{const e=new Date(n),s=(r,i=2)=>String(r).padStart(i,"0");return`${s(e.getHours())}:${s(e.getMinutes())}:${s(e.getSeconds())}.${s(e.getMilliseconds(),3)}`},wa=n=>`${Ef(n.at)} ${n.step}${n.detail&&n.detail!=="{}"?` ${n.detail}`:""}`,If=()=>As.map(wa).join(`
|
|
3
|
-
`),ja=(n,e)=>{const s=fe.c(10),r=700,i=c.useRef(null),a=c.useRef(null),o=c.useRef(!1);let l;s[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{i.current!==null&&window.clearTimeout(i.current),i.current=null,a.current=null},s[0]=l):l=s[0];const f=l;let d,m;s[1]===Symbol.for("react.memo_cache_sentinel")?(d=()=>f,m=[f],s[1]=d,s[2]=m):(d=s[1],m=s[2]),c.useEffect(d,m);let h;s[3]!==r||s[4]!==n?(h=R=>{o.current=!1,a.current={x:R.clientX,y:R.clientY},i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>{i.current=null,o.current=!0,n()},r)},s[3]=r,s[4]=n,s[5]=h):h=s[5];const p=h;let g;s[6]===Symbol.for("react.memo_cache_sentinel")?(g=R=>{const C=a.current;C&&(Math.abs(R.clientX-C.x)>10||Math.abs(R.clientY-C.y)>10)&&f()},s[6]=g):g=s[6];const x=g;let y;s[7]===Symbol.for("react.memo_cache_sentinel")?(y=R=>{o.current&&(o.current=!1,R.preventDefault(),R.stopPropagation())},s[7]=y):y=s[7];const b=y;let S;return s[8]!==p?(S={onPointerDown:p,onPointerMove:x,onPointerUp:f,onPointerCancel:f,onClickCapture:b},s[8]=p,s[9]=S):S=s[9],S},Af=async(n,e)=>{let s;const r=new Promise(i=>{s=setTimeout(()=>i({response:null,failure:"timeout"}),n)});try{return await Promise.race([e.then(i=>({response:i,failure:null}),i=>({response:null,failure:i instanceof Error?i.message:String(i)})),r])}finally{s!==void 0&&clearTimeout(s)}},Pf=(n,e)=>new Promise(s=>{const r=l=>{clearTimeout(a),o(),s(l)},i=l=>{l.state==="connected"?r(!0):(l.state==="idle"||l.terminal)&&r(!1)},a=setTimeout(()=>r(!1),e),o=n.subscribeStatus(i);i(n.getStatus())}),Os=(n,e,s,r)=>Af(r,n.fetch(e,s)),ka=async(n,e,s,r)=>{const i=Date.now()+r;let a=await Os(n,e,s,r);for(;!a.response&&a.failure!=="timeout"&&n.getStatus().state!=="connected";){const o=i-Date.now();if(o<=0||!await Pf(n,o))return a;const l=i-Date.now();if(l<=0)return a;a=await Os(n,e,s,l)}return a},Un="openchamber.mobile.connections.v1",Tf="openchamber.mobile.",ro="openchamber.mobile.deviceId",Df=()=>{try{const n=window.localStorage.getItem(ro);if(n&&n.trim())return n.trim();const e=crypto.randomUUID();return window.localStorage.setItem(ro,e),e}catch{return crypto.randomUUID()}},io=()=>`mobile:${Df()}`,oo=()=>{try{const n=Nd.getPlatform();return n==="ios"||n==="android"?n:void 0}catch{return}},Sa=12,hi=8e3,Mf=2500,_f=3e3,Gn=2500,Of=()=>{let n=0;return{begin:()=>(n+=1,n),cancel:()=>{n+=1},isCurrent:e=>e===n}},Fs=n=>{const e=n.trim();if(!e)return"";const s=/^https?:\/\//i.test(e)?e:`http://${e}`,r=new URL(s);return r.hash="",r.search="",r.pathname=r.pathname.replace(/\/+$/,""),r.toString().replace(/\/+$/,"")},Fn=n=>{try{return new URL(n).host}catch{return n}},zs=n=>{try{return Fs(n)}catch{return n.trim().replace(/\/+$/g,"")}},Na=(n,e)=>zs(n)===zs(e),Ca=n=>`relay:${n.serverId}@${n.relayUrl.trim()}`,zf=n=>`relay://${n.serverId}`,tr=n=>n.candidates.filter(e=>e.kind==="direct"),cs=n=>{const e=n.candidates.find(s=>s.kind==="relay");return e&&e.kind==="relay"?e.relay:null},Tt=n=>{const e=tr(n)[0];if(e)return e.url;const s=cs(n);return s?zf(s):""},Je=n=>{const e=cs(n);if(e)return Ca(e);const s=tr(n)[0];return s?zs(s.url):""},Kn=(n,e)=>{const s=n.find(a=>a.kind==="relay"),r=s&&s.kind==="relay"?s.relay.serverId:null,i=new Set(n.filter(a=>a.kind==="direct").map(a=>zs(a.url)));return e.some(a=>a.kind==="relay"?r!==null&&a.relay.serverId===r:i.has(zs(a.url)))},gi=n=>{const e=(()=>{try{return Fs(n)}catch{return""}})();return e?[{kind:"direct",url:e}]:[]},ao=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(...gi(n.url)),n.relay&&e.push({kind:"relay",relay:n.relay}),e},bi=n=>{if(!n||typeof n!="object"||Array.isArray(n))return null;const e=n;if(typeof e.relayUrl!="string"||!e.relayUrl.trim()||typeof e.serverId!="string"||!e.serverId.trim())return null;const s=e.hostEncPubJwk;if(!s||typeof s!="object"||Array.isArray(s))return null;const r=s;return r.kty!=="EC"||r.crv!=="P-256"||typeof r.x!="string"||!r.x||typeof r.y!="string"||!r.y?null:{relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:{kty:"EC",crv:"P-256",x:r.x,y:r.y}}},Ra=n=>{try{return JSON.stringify(n)}catch{return String(n)}},Ie=(n,e={})=>{const s=Ra(e);console.info("[mobile-connect]",n,s),pi(n,s)},tn=(n,e={})=>{Ie(n,e)},Bs=(n,e={})=>{const s=Ra(e);console.info("[mobile-storage]",n,s),pi(n,s)},Bf=n=>{if(typeof n!="string")return n;try{return JSON.parse(n)}catch{return n}},Lf=n=>{if(typeof n!="string")return n??void 0;try{return JSON.parse(n)}catch{return n}},Ff=async(n,e)=>{if(!tt())return null;try{const{CapacitorHttp:s}=await Ms(async()=>{const{CapacitorHttp:a}=await import("./vendor-capacitor-core-B4EWRrHz.js");return{CapacitorHttp:a}},[]),r=ul(n,new Headers(e?.headers)),i=await s.request({url:n,method:e?.method||"GET",headers:Object.fromEntries(r.entries()),data:Lf(e?.body)});return{ok:i.status>=200&&i.status<300,status:i.status,source:"native-http",json:async()=>Bf(i.data)}}catch(s){return Ie("native-http:failed",{url:n,error:s instanceof Error?s.message:String(s)}),null}},$f=async(n,e)=>{const s=await fetch(n,e).catch(r=>(Ie("browser-fetch:failed",{url:n,error:r instanceof Error?r.message:String(r)}),null));return s?{ok:s.ok,status:s.status,source:"browser-fetch",json:()=>s.json()}:null},qn=async(n,e,s)=>{let r;const i=new Promise(a=>{r=window.setTimeout(()=>{s?.(),a(null)},n)});try{return await Promise.race([e,i])}catch{return null}finally{r!==void 0&&window.clearTimeout(r)}},us=async(n,e,s)=>{const r=s?.totalTimeoutMs??hi,i=Date.now(),a=await qn(Math.min(Mf,r),Ff(n,e));if(a)return a;const o=new AbortController,l=Math.max(500,r-(Date.now()-i));return qn(l,$f(n,{...e,signal:o.signal}),()=>o.abort())},sr=async n=>{if(!n)return null;const e=await n.json().catch(()=>null);if(!e||typeof e!="object")return null;const s=e;return{authenticated:typeof s.authenticated=="boolean"?s.authenticated:void 0,disabled:typeof s.disabled=="boolean"?s.disabled:void 0,scope:typeof s.scope=="string"?s.scope:void 0}},Ls=15e3,Ea=n=>{n?.owned&&n.client.close()},lo=async(n,e)=>{if(n.status===401)return e?"auth-failed":"needs-login";if(!n.ok&&n.status!==404)return"auth-failed";const s=await sr(n);return s&&s.disabled!==!0&&s.authenticated===!1?e?"auth-failed":"needs-login":"ok"},Wf=async(n,e,s,r=Ls,i)=>{const a=e?{Authorization:`Bearer ${e}`}:void 0,o=Pa(n);if(o){const{response:f,failure:d}=await Os(o,"/auth/session",{headers:a},r);if(Ie("relay:session",{shared:!0,ok:f?.ok===!0,status:f?.status??null,hasToken:!!e,error:d}),f){const m=await lo(f,e);return m==="ok"&&i?.keepTunnel?{outcome:m,tunnel:{client:o,owned:!1}}:{outcome:m}}}const l=Wo({relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk});try{const{response:f,failure:d}=await ka(l,"/auth/session",{headers:a},r);Ie("relay:session",{shared:!1,ok:f?.ok===!0,status:f?.status??null,hasToken:!!e,error:d});const m=f?await lo(f,e):"unreachable";return m==="ok"&&i?.keepTunnel?{outcome:m,tunnel:{client:l,owned:!0}}:(l.close(),{outcome:m})}catch(f){throw l.close(),f}},Vf=(n,e,s,r,i)=>{const a=typeof window<"u"?window.location.origin:"",o={relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk,...s?{grant:s}:{}};i&&ll(o,i),Rs({apiBaseUrl:a,clientToken:e,runtimeKey:r??Ca(n),relay:o})},Uf=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=bi(e.relay);return s?{kind:"relay",relay:s}:null}return null},Gf=n=>{if(n.mode==="relay"){const e=bi(n.relay);return e?[{kind:"relay",relay:e}]:[]}return typeof n.url=="string"?gi(n.url):[]},ds=()=>{if(typeof window>"u")return[];let n;try{n=JSON.parse(window.localStorage.getItem(Un)||"[]")}catch{return[]}if(!Array.isArray(n))return[];const e=tt();return n.flatMap(s=>{if(!s||typeof s!="object")return[];const r=s;if(typeof r.id!="string")return[];const i=Array.isArray(r.candidates)?r.candidates.map(Uf).filter(f=>!!f):Gf(r);if(i.length===0)return[];const a=typeof r.clientToken=="string"&&r.clientToken.trim()?r.clientToken:void 0,o=typeof r.label=="string"&&r.label.trim()?r.label:Fn(Tt({candidates:i})),l={id:r.id,label:o,candidates:i,lastUsedAt:typeof r.lastUsedAt=="number"?r.lastUsedAt:0};return e?[{...l,hasToken:!!r.hasToken||!!a}]:[{...l,clientToken:a,hasToken:!!a}]}).sort((s,r)=>r.lastUsedAt-s.lastUsedAt)},$r=n=>n.kind==="relay"?{kind:"relay",relay:{relayUrl:n.relay.relayUrl,serverId:n.relay.serverId,hostEncPubJwk:n.relay.hostEncPubJwk}}:{kind:"direct",url:n.url},xi=n=>{if(typeof window>"u")return;const e=tt(),s=n.slice(0,Sa).map(r=>{const i={id:r.id,label:r.label,candidates:r.candidates.map($r),lastUsedAt:r.lastUsedAt};return e?{...i,hasToken:!!(r.hasToken||r.clientToken)}:{...i,clientToken:r.clientToken}});try{window.localStorage.setItem(Un,JSON.stringify(s))}catch(r){console.warn("[mobile-storage] failed to persist connection metadata",r)}},Ia=(n,e)=>{const s=n.find(a=>e.id&&a.id===e.id||Kn(a.candidates,e.candidates)),r=tt(),i={id:e.id||s?.id||crypto.randomUUID(),label:e.label,candidates:e.candidates,lastUsedAt:Date.now(),...r?{hasToken:e.hasToken??(!!e.clientToken||s?.hasToken||!1)}:{clientToken:e.clientToken??s?.clientToken,hasToken:!!(e.clientToken??s?.clientToken)}};return[i,...n.filter(a=>a.id!==i.id&&!Kn(a.candidates,e.candidates))].slice(0,Sa)},yi=Sd,Kf=0,vi=n=>`${Tf}token.${encodeURIComponent(n)}`,qf=async(n,e)=>{let s;const r=new Promise(i=>{s=window.setTimeout(()=>i(e),_f)});try{return await Promise.race([n.catch(()=>e),r])}finally{s!==void 0&&window.clearTimeout(s)}},wi=async(n,e,s)=>tt()?qf(e().catch(r=>(console.warn(`[mobile-storage] ${n} failed`,r),s)),s):s,mn=async n=>{Bs("secure:read-start",{key:n});const e=await wi("secure:read",async()=>(await yi.internalGetItem({prefixedKey:vi(n),sync:!1})).data,null),s=typeof e=="string"&&e.trim()?e:void 0;return Bs("secure:read",{key:n,hasToken:!!s}),s},os=async(n,e)=>{Bs("secure:write-start",{key:n});const s=await wi("secure:write",async()=>(await yi.internalSetItem({prefixedKey:vi(n),data:e,sync:!1,access:Kf}),!0),!1);return Bs("secure:write",{key:n,ok:s}),s},Hf=async n=>{await wi("secure:delete",async()=>(await yi.internalRemoveItem({prefixedKey:vi(n),sync:!1}),!0),!1)},Jf=async(n,e)=>{let s=0,r=0;return{records:await Promise.all(n.map(async a=>{if(!a||typeof a!="object")return a;const o=a,l=typeof o.url=="string"?o.url:null,f=typeof o.clientToken=="string"?o.clientToken.trim():"";if(!l||!f)return a;if(!await e(l,f))return r+=1,a;s+=1;const{clientToken:d,...m}=o;return{...m,hasToken:!0}})),migrated:s,failed:r}},Aa=async()=>{if(typeof window>"u"||!tt())return;let n;try{n=JSON.parse(window.localStorage.getItem(Un)||"[]")}catch{return}if(!Array.isArray(n))return;const e=n.filter(r=>!!r&&typeof r=="object"&&typeof r.url=="string"&&typeof r.clientToken=="string"&&!!r.clientToken.trim());if(e.length===0)return;Bs("secure:migrate-start",{count:e.length});const s=await Jf(n,async(r,i)=>{const a=zs(r);return await os(a,i)?await mn(a)===i:!1});if(s.migrated>0)try{window.localStorage.setItem(Un,JSON.stringify(s.records))}catch(r){console.warn("[mobile-storage] failed to finalize secure token migration",r);return}Bs("secure:migrate-done",{migrated:s.migrated,failed:s.failed})},Xf=async()=>(await Aa(),ds()),Hn=async n=>{const e=Ia(ds(),n);return xi(e),tt()&&n.clientToken&&await os(Je({candidates:n.candidates}),n.clientToken),e},Yf=async n=>{const e=ds(),s=e.find(i=>i.id===n)??null,r=e.filter(i=>i.id!==n);return xi(r),s&&tt()&&await Hf(Je(s)),r},Qf=1500,Jn=async(n,e,s)=>{const r=s?.fast?{totalTimeoutMs:Gn}:void 0,i=cs({candidates:n})?.serverId??null,a=n.find(d=>d.kind==="relay")??null,o=n.filter(d=>d.kind==="direct"),l=async()=>{for(const d of o){const m=Fs(d.url)||d.url,h=e?{Authorization:`Bearer ${e}`}:void 0,p=await us(`${m}/health`,{method:"GET"},r);if(Ie("probe:direct:health",{url:m,ok:p?.ok===!0,status:p?.status??null,source:p?.source??null}),!p?.ok)continue;if(i){const b=await p.json().catch(()=>null),S=b&&typeof b=="object"?b.serverId:null;if(typeof S=="string"&&S&&S!==i){Ie("probe:server-id-mismatch",{url:m});continue}}const g=await us(`${m}/auth/session`,{method:"GET",credentials:e?"omit":"include",headers:h},r);if(Ie("probe:direct:session",{url:m,ok:g?.ok===!0,status:g?.status??null,source:g?.source??null,hasToken:!!e}),g?.status===401)return{status:"needs-login"};if(!g||!g.ok&&g.status!==404)continue;const x=await sr(g);if(x&&x.disabled!==!0&&x.authenticated===!1)return{status:"needs-login"};const y=x?.disabled===!0;return!e&&tt()&&!y&&x?.scope!=="client"?{status:"needs-login"}:{status:"ok",transport:{kind:"direct",url:m}}}return{status:"unreachable"}},f=async()=>{if(!a)return{status:"unreachable"};const{outcome:d,tunnel:m}=await Wf(a.relay,e,void 0,s?.fast?Gn:hi,{keepTunnel:!0});return d==="ok"?{status:"ok",transport:{kind:"relay",relay:a.relay,tunnel:m}}:d==="needs-login"||d==="auth-failed"?{status:"needs-login"}:{status:"unreachable"}};return a?o.length===0?f():new Promise(d=>{let m=!1,h=!1,p,g=null,x=null;const y=R=>{R?.status==="ok"&&R.transport.kind==="relay"&&Ea(R.transport.tunnel)},b=R=>{m||(m=!0,d(R))},S=()=>{h||m||(p!==void 0&&(window.clearTimeout(p),p=void 0),f().then(R=>{if(x=R,m||h){y(R);return}if(R.status==="ok"||R.status==="needs-login"){b(R);return}g&&b(g)}))};l().then(R=>{if(g=R,!m){if(R.status==="ok"||R.status==="needs-login"){h=!0,p!==void 0&&window.clearTimeout(p),y(x),b(R);return}if(x){b(x);return}S()}}),p=window.setTimeout(S,Qf)}):l()},as=(n,e,s)=>{ji=!1,n.kind==="relay"?Vf(n.relay,e,s?.grant,s?.runtimeKey,n.tunnel?.client):Rs({apiBaseUrl:n.url,clientToken:e,runtimeKey:s?.runtimeKey}),Da()},on=()=>{const n=ds()[0];return n?.label?.trim()?n.label:null};let ji=!1;const Zf=()=>{ji=!0},sn=async n=>{if(ji)return Ie("auto-connect:suppressed",{}),{status:"no-candidate"};const e=n?.fast!==!1;await Aa();const s=ds()[0];if(Ie("auto-connect:start",{hasCandidate:!!s,fast:e}),!s)return{status:"no-candidate"};let r;if(tt()){if(s.hasToken&&(r=await mn(Je(s)),!r))return{status:"no-candidate"}}else if(r=s.clientToken,!r&&s.hasToken)return{status:"no-candidate"};const i=await Jn(s.candidates,r,{fast:e});return Ie("auto-connect:probe",{status:i.status,candidates:s.candidates.map(a=>a.kind)}),i.status==="needs-login"?{status:"needs-login",label:s.label}:i.status!=="ok"?{status:"unreachable",label:s.label}:n?.skipIfConnected&&jt()?(i.transport.kind==="relay"&&Ea(i.transport.tunnel),Ie("auto-connect:superseded",{}),{status:"no-candidate"}):(await Hn({id:s.id,label:s.label,candidates:s.candidates}),as(i.transport,r??null,{runtimeKey:Je(s)}),{status:"connected"})},em=async(n,e)=>{let s="";try{s=Fs(n.url)}catch{return!1}if(!s)return!1;const r=n.clientToken?.trim()||void 0,i=r?{Authorization:`Bearer ${r}`}:void 0,a=e?.fast?{totalTimeoutMs:Gn}:void 0;if(!(await us(`${s}/health`,{method:"GET",headers:i},a))?.ok)return!1;const l=await us(`${s}/auth/session`,{method:"GET",credentials:r?"omit":"include",headers:i},a);if(!l||!l.ok&&l.status!==404)return!1;const f=await sr(l);return!(f&&f.disabled!==!0&&f.authenticated===!1)},co=(n,e)=>{n?.kind==="relay"&&n.owned&&!e&&n.tunnel.close()},tm=(n,e)=>n.kty===e.kty&&n.crv===e.crv&&n.x===e.x&&n.y===e.y,Pa=n=>{const e=dl(),s=cl();return!e||!s||e.getStatus().state!=="connected"?null:s.relayUrl===n.relayUrl&&s.serverId===n.serverId&&tm(s.hostEncPubJwk,n.hostEncPubJwk)?e:null},sm=n=>[...n].sort((e,s)=>{const r=(e.priority??100)-(s.priority??100);if(r!==0)return r;const i=a=>a.type==="relay"?2:a.url.startsWith("https://")?0:1;return i(e)-i(s)}).flatMap(e=>{if(e.type==="relay"){const s=bi({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk});return s?[{kind:"relay",relay:s}]:[]}return gi(e.url)}),uo=async n=>{const e=cs({candidates:n})?.serverId??null;for(const s of n){if(s.kind==="relay"){const a=Pa(s.relay);if(a){const d=await Os(a,"/health",void 0,hi);if(Ie("establish:relay:health",{shared:!0,ok:d.response?.ok===!0,status:d.response?.status??null,error:d.failure}),d.response?.ok)return{kind:"relay",relay:s.relay,tunnel:a,owned:!1}}const o=Wo(s.relay),{response:l,failure:f}=await ka(o,"/health",void 0,Ls);if(Ie("establish:relay:health",{shared:!1,ok:l?.ok===!0,status:l?.status??null,error:f}),l?.ok)return{kind:"relay",relay:s.relay,tunnel:o,owned:!0};o.close();continue}const r=Fs(s.url)||s.url,i=await us(`${r}/health`,{method:"GET"});if(Ie("establish:direct:health",{ok:i?.ok===!0,status:i?.status??null}),!!i?.ok){if(e){const a=await i.json().catch(()=>null),o=a&&typeof a=="object"?a.serverId:null;if(typeof o=="string"&&o&&o!==e){Ie("establish:server-id-mismatch",{url:r});continue}}return{kind:"direct",url:r}}}return null},nm=async(n,e)=>{if(!fn())return em(n,e);const s=await qn(e?.fast?Gn:Ls,$o("/auth/session").then(i=>i).catch(()=>null));if(!s)return!0;if(s.status===401)return!1;if(!s.ok&&s.status!==404)return!0;const r=await sr(s);return!(r&&r.disabled!==!0&&r.authenticated===!1)},rm=n=>n.kind==="relay"?fn():!fn()&&Na(n.url,jt()),Ta=()=>{const n=gn();return n?ds().find(e=>Je(e)===n)??null:null},fo=n=>{const e=gn();return!!e&&Je(n)===e},$n=async n=>{const e=n?.fast!==!1,s=Ta();if(!s)return Ie("reprobe:no-connection",{runtimeKey:!!gn()}),"no-connection";let r;if(tt()?r=s.hasToken?await mn(Je(s)):void 0:r=s.clientToken,!r&&s.hasToken)return Ie("reprobe:no-token",{hasToken:!0}),"unreachable";Ie("reprobe:start",{candidates:s.candidates.map(d=>d.kind),fast:e,hasToken:!!r});const i=s.candidates.findIndex(d=>rm(d.kind==="relay"?{kind:"relay",relay:d.relay}:{kind:"direct",url:d.url})),a=i>=0?s.candidates.slice(0,i):s.candidates,o=await Jn(a,r,{fast:e});if(Ie("reprobe:better",{status:o.status,probed:a.length}),o.status==="ok")return await Hn({id:s.id,label:s.label,candidates:s.candidates}),as(o.transport,r??null,{runtimeKey:Je(s)}),"switched";if(o.status==="needs-login")return"needs-login";if(i>=0){const d=await nm({url:jt(),clientToken:r},{fast:e});if(Ie("reprobe:current",{stillValid:d}),d)return Da(),"unchanged"}const l=i>=0?s.candidates.slice(i+1):[],f=await Jn(l,r,{fast:e});return Ie("reprobe:fallback",{status:f.status,probed:l.length}),f.status==="ok"?(await Hn({id:s.id,label:s.label,candidates:s.candidates}),as(f.transport,r??null,{runtimeKey:Je(s)}),"switched"):f.status==="needs-login"?"needs-login":"unreachable"},im=5e3;let Sr=!1;const om=async()=>{if(Sr)return"skipped";const n=Ta();if(!n)return Ie("candidates:refresh-skip",{reason:"no-active-connection"}),"skipped";const e=cs(n);if(!e)return Ie("candidates:refresh-skip",{reason:"no-relay-candidate"}),"skipped";Sr=!0;try{const s=await qn(Ls,$o("/api/client-auth/connection/candidates").then(d=>d).catch(()=>null));if(!s?.ok)return Ie("candidates:refresh-skip",{reason:"fetch-failed",status:s?.status??null}),"skipped";const r=await s.json().catch(()=>null);if(!r||r.serverId!==e.serverId)return Ie("candidates:refresh-skip",{reason:"server-id-mismatch"}),"skipped";const i=Array.isArray(r.candidates)?r.candidates:[],a=[];for(const d of i){if(!d||typeof d!="object")continue;const m=d;if(!(m.type!=="lan"||typeof m.url!="string"))try{const h=Fs(m.url);h&&!a.includes(h)&&a.push(h)}catch{}}if(a.length===0)return Ie("candidates:refresh-skip",{reason:"no-lan-reported"}),"skipped";const o=tr(n).filter(d=>d.url.startsWith("https://")),l=[...a.map(d=>({kind:"direct",url:d})),...o,{kind:"relay",relay:e}];return JSON.stringify(n.candidates.map($r))===JSON.stringify(l.map($r))?"unchanged":(Ie("candidates:refreshed",{lanCount:a.length}),await Hn({id:n.id,label:n.label,candidates:l}),"updated")}finally{Sr=!1}},Da=()=>{typeof window>"u"||window.setTimeout(()=>{(async()=>{const n=await om().catch(()=>"skipped");Ie("candidates:refresh-result",{result:n}),n==="updated"&&fn()&&await $n().catch(()=>null)})()},im)},Ma=n=>{const{t:e}=ve(),[s,r]=c.useState(()=>ds()),[i,a]=c.useState(null),[o,l]=c.useState(null),[f,d]=c.useState(null),m=c.useRef(s),h=c.useRef(null),p=c.useRef(Of()),g=c.useCallback(k=>{m.current=k,r(k)},[]),x=c.useCallback(k=>{h.current=k,a(k)},[]),y=c.useCallback(k=>{h.current===k&&(h.current=null,a(null))},[]);c.useEffect(()=>{let k=!1;return Xf().then(v=>{k||g(v)}),()=>{k=!0}},[g]);const b=c.useCallback(k=>{const v=Ia(m.current,k);return g(v),xi(v),v},[g]),S=c.useCallback(async k=>{l(null),x("connect");try{const v=ao(k);if(v.length===0){l(e("mobile.connect.error.urlRequired"));return}const I=k.id?m.current.find(O=>O.id===k.id):m.current.find(O=>Kn(O.candidates,v)),P=k.label?.trim()||I?.label||Fn(Tt({candidates:v})),L=k.relayGrant;let _=k.clientToken?.trim()||void 0;const E=!!_;_||(tt()?I?.hasToken&&(_=await mn(Je({candidates:v}))):_=I?.clientToken),Ie("connect:start",{candidates:v.map(O=>O.kind),hasToken:!!_});const T=await Jn(v,_);if(Ie("connect:probe",{status:T.status}),T.status==="unreachable"){l(e("mobile.connect.error.unreachable"));return}if(T.status==="needs-login"){b({id:I?.id,label:P,candidates:v}),d({id:I?.id??crypto.randomUUID(),label:P,candidates:v,relay:cs({candidates:v})??void 0,relayGrant:L});return}_&&E&&tt()&&await os(Je({candidates:v}),_),b({id:I?.id,label:P,candidates:v,clientToken:_}),as(T.transport,_??null,{runtimeKey:Je({candidates:v}),grant:L}),n()}catch(v){console.warn("[mobile-connect] connect threw",v),l(e("mobile.connect.error.invalidUrl"))}finally{y("connect")}},[x,y,n,b,e]),R=c.useCallback(async k=>{if(h.current==="pairing")return;l(null),x("pairing");const v=sm(k.candidates);let I=null,P=!1;try{if(I=await uo(v),!I){l(e("mobile.connect.error.unreachable"));return}const L=JSON.stringify({pairingId:k.pairingId,secret:k.secret,clientLabel:"OpenChamber Mobile",clientKind:"mobile",deviceName:"OpenChamber Mobile",devicePlatform:oo(),dedupeKey:io()}),_={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:L},E=I.kind==="relay"?await Os(I.tunnel,"/api/client-auth/pairing/redeem",_,Ls):{response:await us(`${I.url}/api/client-auth/pairing/redeem`,_),failure:null},T=E.response;if(Ie("pairing:redeem",{transport:I.kind,ok:T?.ok===!0,status:T?.status??null,error:E.failure}),!T?.ok){l(e("mobile.connect.error.authRequired"));return}const O=await T.json().catch(()=>null),M=typeof O?.clientToken=="string"?O.clientToken.trim():"";if(!M){l(e("mobile.connect.error.authRequired"));return}const G=typeof O?.server?.label=="string"?O.server.label:"",F=k.label||G||Fn(Tt({candidates:v}));if(tt()&&!await os(Je({candidates:v}),M)){l(e("mobile.connect.error.authRequired"));return}b({label:F,candidates:v,clientToken:M}),as(I.kind==="relay"?{kind:"relay",relay:I.relay,tunnel:{client:I.tunnel,owned:I.owned}}:{kind:"direct",url:I.url},M,{runtimeKey:Je({candidates:v})}),P=I.kind==="relay",n()}catch(L){console.warn("[mobile-connect] pairing threw",L),l(e("mobile.connect.error.authRequired"))}finally{co(I,P),y("pairing")}},[x,y,n,b,e]),C=c.useCallback(async k=>{if(!f||!k.trim()||h.current==="password")return;l(null),x("password");const v=p.current.begin(),I=()=>p.current.isCurrent(v),{id:P,label:L,candidates:_}=f;let E=null,T=!1;try{if(E=await uo(_),!I())return;if(!E){l(e("mobile.connect.error.unreachable"));return}const O={method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({password:k,trustDevice:!0,issueClientToken:!0,clientLabel:"OpenChamber Mobile",clientKind:"mobile",devicePlatform:oo(),dedupeKey:io()})};Ie("password:start",{transport:E.kind});const M=E.kind==="relay"?await Os(E.tunnel,"/auth/session",O,Ls):{response:await us(`${E.url}/auth/session`,O),failure:null},G=M.response;if(!I())return;if(Ie("password:done",{ok:G?.ok===!0,status:G?.status??null,error:M.failure}),!G?.ok){l(e("mobile.connect.error.passwordFailed"));return}const F=await G.json().catch(()=>null);if(!I())return;const z=typeof F?.clientToken=="string"?F.clientToken.trim():"";if(Ie("password:token",{issued:!!z}),!z){if(E.kind==="direct"&&!tt()){b({id:P,label:L,candidates:_}),d(null),as({kind:"direct",url:E.url},null,{runtimeKey:Je({candidates:_})}),n();return}l(e("mobile.connect.error.authRequired"));return}if(tt()&&(!I()||(await os(Je({candidates:_}),z),!I()))||!I()||(b({id:P,label:L,candidates:_,clientToken:z}),d(null),as(E.kind==="relay"?{kind:"relay",relay:E.relay,tunnel:{client:E.tunnel,owned:E.owned}}:{kind:"direct",url:E.url},z,{runtimeKey:Je({candidates:_})}),T=E.kind==="relay",!I()))return;n()}catch(O){if(!I())return;console.warn("[mobile-connect] password threw",O),l(e("mobile.connect.error.passwordFailed"))}finally{co(E,T),I()&&y("password")}},[x,y,n,f,b,e]),D=c.useCallback(()=>{p.current.cancel(),y("password"),d(null),l(null)},[y]),A=c.useCallback(async k=>{l(null);let v=ao(k);const I=k.id?m.current.find(E=>E.id===k.id)??null:null;if(I){const E=v.filter(M=>M.kind==="direct"),T=tr(I).filter(M=>M.url.startsWith("https://")&&!E.some(G=>Na(G.url,M.url))),O=cs(I);v=[...E,...T,...O?[{kind:"relay",relay:O}]:[]]}if(v.length===0)return l(e("mobile.connect.error.urlRequired")),null;const P=k.clientToken?.trim()||void 0,L=k.label?.trim()||Fn(Tt({candidates:v}));if(tt()){const E=Je({candidates:v});if(P)await os(E,P);else if(I?.hasToken){const T=Je(I);if(T&&E&&T!==E){const O=await mn(T);O&&await os(E,O)}}}return b({id:k.id,label:L,candidates:v,clientToken:P}).find(E=>Kn(E.candidates,v))??null},[b,e]),j=c.useCallback(async k=>{const v=m.current.find(P=>P.id===k)??null,I=await Yf(k);return g(I),v},[g]);return{connections:s,isBusy:i!==null,isPasswordBusy:i==="password",error:o,pendingConnection:f,connect:S,redeemPairingConnection:R,submitPassword:C,cancelPassword:D,saveConnection:A,removeConnection:j,setError:l}},_a=n=>{const e=fe.c(31),{onClose:s}=n,{t:r}=ve(),[i,a]=c.useState(!1);let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=Rf(),e[0]=o):o=e[0];const l=o;let f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{Ko(If()).then(k=>{k.ok&&(a(!0),window.setTimeout(()=>a(!1),2e3))})},e[1]=f):f=e[1];const d=f;let m;e[2]!==r?(m=r("mobile.connectionDebug.title"),e[2]=r,e[3]=m):m=e[3];let h;e[4]!==m?(h=t.jsx("h2",{className:"min-w-0 truncate typography-ui-label text-foreground",children:m}),e[4]=m,e[5]=h):h=e[5];const p=i?"check":"file-copy";let g;e[6]!==p?(g=t.jsx(X,{name:p,className:"size-4"}),e[6]=p,e[7]=g):g=e[7];let x;e[8]!==i||e[9]!==r?(x=r(i?"mobile.connectionDebug.copied":"mobile.connectionDebug.copy"),e[8]=i,e[9]=r,e[10]=x):x=e[10];let y;e[11]!==g||e[12]!==x?(y=t.jsxs(Ee,{type:"button",variant:"outline",size:"sm",onClick:d,disabled:l.length===0,children:[g,x]}),e[11]=g,e[12]=x,e[13]=y):y=e[13];let b;e[14]!==r?(b=r("mobile.connectionDebug.close"),e[14]=r,e[15]=b):b=e[15];let S;e[16]===Symbol.for("react.memo_cache_sentinel")?(S=t.jsx(X,{name:"close",className:"size-[18px]"}),e[16]=S):S=e[16];let R;e[17]!==s||e[18]!==b?(R=t.jsx(Ee,{type:"button",variant:"ghost",size:"icon","aria-label":b,onClick:s,children:S}),e[17]=s,e[18]=b,e[19]=R):R=e[19];let C;e[20]!==R||e[21]!==y?(C=t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[y,R]}),e[20]=R,e[21]=y,e[22]=C):C=e[22];let D;e[23]!==C||e[24]!==h?(D=t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border/70 px-4 py-2.5",children:[h,C]}),e[23]=C,e[24]=h,e[25]=D):D=e[25];let A;e[26]!==r?(A=t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 py-3",children:l.length===0?t.jsx("p",{className:"typography-small text-muted-foreground",children:r("mobile.connectionDebug.empty")}):t.jsx("pre",{className:"whitespace-pre-wrap break-words typography-code text-muted-foreground",children:l.map(wa).join(`
|
|
4
|
-
`)})}),e[26]=r,e[27]=A):A=e[27];let j;return e[28]!==D||e[29]!==A?(j=t.jsxs("div",{className:"fixed inset-0 z-[70] flex flex-col bg-background pb-[var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))] pt-[var(--safe-area-inset-top,env(safe-area-inset-top,0px))] text-foreground",children:[D,A]}),e[28]=D,e[29]=A,e[30]=j):j=e[30],j},Oa=()=>{if(typeof window>"u")return null;const e=window.Capacitor?.Plugins?.BarcodeScanner;return e&&(typeof e.scan=="function"||typeof e.startScan=="function")?e:null},am=()=>window.Capacitor?.getPlatform?.()==="android",za=n=>{const e=n.trim();if(!e)return null;if(/^openchamber:\/\//i.test(e)){const s=fl(e);return s?{pairing:s}:null}return/^https?:\/\//i.test(e)?{url:e}:null},Ba=(n,e)=>{const s=za(n);if(!s&&e?.pairingStringFallback){const r=ml(n);if(r)return{status:"pairing",pairing:r}}return s?"pairing"in s?{status:"pairing",...s}:{status:"ok",...s}:{status:"invalid"}},lm=async(n,e)=>{if(!n.startScan||!n.stopScan||!n.addListener)return{status:"unsupported"};if(e?.aborted)return{status:"cancelled"};let s,r,i=!1,a=()=>{};const o=new Promise(d=>{a=d}),l=d=>{i||(i=!0,a(d))},f=()=>l({status:"cancelled"});e?.addEventListener("abort",f,{once:!0});try{return(await Promise.allSettled([Promise.resolve(n.addListener("barcodesScanned",({barcodes:m})=>{const h=m?.[0],p=(h?.rawValue??h?.displayValue??"").trim();p&&l(Ba(p,{pairingStringFallback:!0}))})).then(m=>{s=m}),Promise.resolve(n.addListener("scanError",()=>l({status:"failed"}))).then(m=>{r=m})])).some(({status:m})=>m==="rejected")?l({status:"failed"}):i||n.startScan({formats:["QR_CODE"]}).catch(()=>l({status:"failed"})),await o}finally{e?.removeEventListener("abort",f),await Promise.allSettled([Promise.resolve(s?.remove()),Promise.resolve(r?.remove()),n.stopScan()])}},Wr=()=>Oa()!==null,La=async n=>{const e=Oa();if(!e)return{status:"unsupported"};try{if(e.requestPermissions){const o=(await e.requestPermissions())?.camera;if(o&&o!=="granted"&&o!=="limited")return{status:"permission-denied"}}if(n?.signal?.aborted)return{status:"cancelled"};if(am())return lm(e,n?.signal);if(!e.scan)return{status:"unsupported"};const r=(await e.scan({formats:["QR_CODE"]}))?.barcodes?.[0],i=(r?.rawValue??r?.displayValue??"").trim();return i?Ba(i):{status:"cancelled"}}catch{return{status:"failed"}}},Ts={autoComplete:"off",autoCorrect:"off",spellCheck:!1},an="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",Fa=n=>{const e=fe.c(22),{onCancel:s}=n,{t:r}=ve(),i=c.useRef(null);let a,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const S={value:document.documentElement.style.getPropertyValue("background-color"),priority:document.documentElement.style.getPropertyPriority("background-color")},R={value:document.body.style.getPropertyValue("background-color"),priority:document.body.style.getPropertyPriority("background-color")};document.documentElement.style.setProperty("background-color","rgba(0, 0, 0, 0)","important"),document.body.style.setProperty("background-color","rgba(0, 0, 0, 0)","important");const C=new Map,D=j=>{!(j instanceof HTMLElement)||j===i.current||C.has(j)||(C.set(j,{opacity:j.style.opacity,pointerEvents:j.style.pointerEvents}),j.style.setProperty("opacity","0"),j.style.setProperty("pointer-events","none"))};Array.from(document.body.children).forEach(D);const A=new MutationObserver(j=>{j.forEach(k=>k.addedNodes.forEach(D))});return A.observe(document.body,{childList:!0}),()=>{A.disconnect(),C.forEach(cm),S.value?document.documentElement.style.setProperty("background-color",S.value,S.priority):document.documentElement.style.removeProperty("background-color"),R.value?document.body.style.setProperty("background-color",R.value,R.priority):document.body.style.removeProperty("background-color")}},o=[],e[0]=a,e[1]=o):(a=e[0],o=e[1]),c.useLayoutEffect(a,o);let l,f;e[2]!==s?(l=()=>{const S=()=>{document.visibilityState==="hidden"&&s()};return document.addEventListener("visibilitychange",S),()=>document.removeEventListener("visibilitychange",S)},f=[s],e[2]=s,e[3]=l,e[4]=f):(l=e[3],f=e[4]),c.useEffect(l,f);let d;e[5]!==r?(d=r("mobile.connect.scanQr"),e[5]=r,e[6]=d):d=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 h;e[8]!==r?(h=r("mobile.connect.welcome.scanHint"),e[8]=r,e[9]=h):h=e[9];let p;e[10]!==h?(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:h})]}),e[10]=h,e[11]=p):p=e[11];let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(X,{name:"close",className:"size-[18px]"}),e[12]=g):g=e[12];let x;e[13]!==r?(x=r("mobile.instances.cancelEdit"),e[13]=r,e[14]=x):x=e[14];let y;e[15]!==s||e[16]!==x?(y=t.jsxs(Ee,{type:"button",variant:"outline",size:"lg",className:"mx-auto min-h-12 w-full max-w-sm bg-background",onClick:s,children:[g,x]}),e[15]=s,e[16]=x,e[17]=y):y=e[17];let b;return e[18]!==y||e[19]!==d||e[20]!==p?(b=Ds.createPortal(t.jsxs("div",{ref:i,role:"dialog","aria-modal":"true","aria-label":d,className:"fixed inset-0 z-[1000] flex flex-col bg-transparent px-6 pb-[calc(var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))+24px)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+24px)] text-foreground",children:[p,y]}),document.body),e[18]=y,e[19]=d,e[20]=p,e[21]=b):b=e[21],b},$a=()=>{const n=fe.c(6),{t:e}=ve();let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx(Es,{width:96,height:96,isAnimated:!0}),n[0]=s):s=n[0];let r;n[1]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(X,{name:"loader-4",className:"size-[18px] animate-spin"}),n[1]=r):r=n[1];let i;n[2]!==e?(i=e("mobile.connect.connecting"),n[2]=e,n[3]=i):i=n[3];let a;return n[4]!==i?(a=Ds.createPortal(t.jsxs("div",{role:"status",className:"fixed inset-0 z-[1000] flex flex-col items-center justify-center gap-5 bg-background px-6 text-foreground",children:[s,t.jsxs("div",{className:"flex items-center gap-2 typography-ui-label text-muted-foreground",children:[r,t.jsx("span",{children:i})]})]}),document.body),n[4]=i,n[5]=a):a=n[5],a};function cm(n,e){e.style.opacity=n.opacity,e.style.pointerEvents=n.pointerEvents}const um=({onConnected:n,notice:e=null})=>{const{t:s}=ve(),r=Ma(n),{connections:i,isBusy:a,isPasswordBusy:o,error:l,pendingConnection:f}=r,[d,m]=c.useState(""),[h,p]=c.useState(""),[g,x]=c.useState(""),[y,b]=c.useState(!1),[S,R]=c.useState(!1),C=c.useRef(null),D=c.useMemo(()=>Wr(),[]),[A,j]=c.useState(()=>!Wr()),[k,v]=c.useState(null),[I,P]=c.useState(""),[L,_]=c.useState(!1),E=ja(c.useCallback(()=>_(!0),[])),T=c.useCallback(z=>{z.preventDefault(),r.connect({url:d,clientToken:g,label:h})},[g,r,h,d]),O=c.useCallback(z=>{if(/^openchamber:\/\//i.test(z.trim())){const U=za(z);if(U){if("pairing"in U){r.redeemPairingConnection(U.pairing);return}m(U.url),U.label&&p(U.label),U.clientToken&&x(U.clientToken);return}}m(z)},[r]),M=c.useCallback(async()=>{if(C.current||a)return;r.setError(null),b(!0);const z=new AbortController;C.current=z;try{const U=await La({signal:z.signal});switch(C.current===z&&(C.current=null,b(!1)),U.status){case"ok":R(!0),m(U.url),U.label&&p(U.label),U.clientToken&&x(U.clientToken),await r.connect({url:U.url,clientToken:U.clientToken,label:U.label});break;case"pairing":R(!0),await r.redeemPairingConnection(U.pairing);break;case"permission-denied":r.setError(s("mobile.connect.scan.permissionDenied"));break;case"invalid":r.setError(s("mobile.connect.scan.invalid"));break;case"unsupported":r.setError(s("mobile.connect.scan.unsupported"));break;case"failed":r.setError(s("mobile.connect.scan.failed"));break;default:break}}finally{R(!1),C.current===z&&(C.current=null,b(!1))}},[r,a,s]);c.useEffect(()=>()=>C.current?.abort(),[]);const G=c.useCallback(z=>{z.preventDefault(),r.submitPassword(I)},[r,I]),F=c.useCallback(()=>{P(""),r.cancelPassword()},[r]);return t.jsxs(t.Fragment,{children:[y?t.jsx(Fa,{onCancel:()=>C.current?.abort()}):null,S?t.jsx($a,{}):null,L?t.jsx(_a,{onClose:()=>_(!1)}):null,t.jsx("main",{className:"oc-keyboard-fill-screen flex min-h-dvh flex-col overflow-y-auto bg-background px-6 pb-[calc(var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))+28px)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+28px)] text-foreground",children:t.jsxs("div",{className:"m-auto flex w-full max-w-[360px] shrink-0 flex-col items-center gap-9 py-8",children:[t.jsxs("div",{className:"flex flex-col items-center gap-5 text-center",children:[t.jsx("span",{...E,className:"select-none",style:{touchAction:"manipulation"},children:t.jsx(Es,{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(X,{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:G,children:[t.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(X,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0 text-start",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:f.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:f.candidates.some(z=>z.kind==="direct")?Tt(f):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...Ts,value:I,onChange:z=>P(z.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:an}),l?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):null,t.jsx(Ee,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:o||!I.trim(),children:s(o?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(Ee,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:F,children:s("mobile.connect.cancelPassword")})]}):t.jsxs("div",{className:"flex w-full flex-col gap-6",children:[D?t.jsxs("div",{className:"flex w-full flex-col gap-2",children:[t.jsxs(Ee,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{M()},disabled:y||a,children:[t.jsx(X,{name:"scan-2",className:ee("size-[18px]",y&&"animate-pulse")}),s(a?"mobile.connect.connecting":"mobile.connect.scanQr")]}),t.jsx("p",{className:"px-2 text-center typography-small text-muted-foreground",children:s("mobile.connect.welcome.scanHint")})]}):null,l&&!A?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):null,i.length>0?t.jsxs("section",{className:"flex w-full flex-col gap-2.5",children:[t.jsx("h2",{className:"text-center typography-micro uppercase tracking-[0.14em] text-muted-foreground",children:s("mobile.connect.saved.title")}),t.jsx("div",{className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:i.map(z=>{const U=k===z.id;return t.jsxs("button",{type:"button",disabled:a,className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3.5 py-2.5 text-start last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:opacity-70",onClick:()=>{v(z.id),r.connect({id:z.id,candidates:z.candidates,clientToken:z.clientToken,label:z.label}).finally(()=>v(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(X,{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:z.label}),t.jsx("span",{className:ee("block truncate typography-small",U?"text-foreground":"text-muted-foreground"),children:U?s("mobile.connect.connecting"):z.candidates.some(Q=>Q.kind==="direct")?Tt(z):s("mobile.connect.relay.badge")})]}),U?t.jsx(X,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):t.jsx(X,{name:"arrow-right-s",className:"size-5 text-muted-foreground"})]},z.id)})})]}):null,t.jsxs("div",{className:"flex w-full flex-col",children:[D?t.jsxs("button",{type:"button",onClick:()=>j(z=>!z),"aria-expanded":A,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(X,{name:"arrow-down-s",className:ee("size-4 transition-transform duration-200",A&&"rotate-180")})]}):null,t.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:A?"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:T,children:[t.jsx("input",{...Ts,value:d,onChange:z=>O(z.target.value),placeholder:s("mobile.connect.url.placeholder"),"aria-label":s("mobile.connect.url.label"),type:"url",inputMode:"url",autoCapitalize:"none",tabIndex:A?void 0:-1,className:ee(an,"text-center")}),t.jsx("input",{value:h,onChange:z=>p(z.target.value),placeholder:s("mobile.instances.label.placeholder"),"aria-label":s("mobile.instances.label.label"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,tabIndex:A?void 0:-1,className:ee(an,"text-center")}),t.jsx("input",{...Ts,value:g,onChange:z=>x(z.target.value),placeholder:s("mobile.connect.token.placeholder"),"aria-label":s("mobile.connect.token.label"),tabIndex:A?void 0:-1,autoCapitalize:"none",className:ee(an,"text-center")}),t.jsx("p",{className:"px-1 text-center typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")}),l?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):null,t.jsx(Ee,{type:"submit",variant:D?"outline":"default",size:"lg",className:"h-12 w-full",disabled:a||y||!d.trim(),children:s(a?"mobile.connect.connecting":"mobile.connect.connectButton")})]})})})]})]})]})})]})},dm=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"},fm=n=>{const e=fe.c(12),{groups:s,displayMode:r,timeFormatPreference:i,className:a}=n;let o;e[0]!==a?(o=ee("space-y-1.5",a),e[0]=a,e[1]=o):o=e[1];let l;if(e[2]!==r||e[3]!==s||e[4]!==i){let d;e[6]!==r||e[7]!==i?(d=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(qo,{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(h=>{const p=r==="remaining"?h.window.remainingPercent:h.window.usedPercent,g=Nl(h.window.valueLabel,p),x=Cl(h.window.resetAt,h.window.resetAfterFormatted??h.window.resetAtFormatted,i);return t.jsxs("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"shrink-0 truncate typography-ui-label text-muted-foreground",children:h.subtitle?`${h.subtitle} · ${h.label}`:h.label}),x?t.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/70",children:x}):null]}),t.jsx("span",{className:ee("shrink-0 typography-ui-label font-semibold tabular-nums",dm(h.window)),children:g==="-"?"":g})]},h.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]=r,e[7]=i,e[8]=d):d=e[8],l=s.map(d),e[2]=r,e[3]=s,e[4]=i,e[5]=l}else l=e[5];let f;return e[9]!==o||e[10]!==l?(f=t.jsx("div",{className:o,children:l}),e[9]=o,e[10]=l,e[11]=f):f=e[11],f},mo=380,mm=(n,e)=>{if(!n||typeof n!="object")return;const s=n[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0},Nr=n=>n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:String(n),pm="—",Wa=n=>{const e=fe.c(20),{percentage:s}=n;let r,i,a,o,l,f,d;if(e[0]!==s){a=Tl(s??0)??0;const g=Dl(s??0);i=g==="critical"?"var(--status-error)":g==="warn"?"var(--status-warning)":"var(--status-success)",r=2*Math.PI*7.5,o="0 0 18 18",l="size-[18px] -rotate-90",f="progressbar",d=s===null?void 0:Math.round(a),e[0]=s,e[1]=r,e[2]=i,e[3]=a,e[4]=o,e[5]=l,e[6]=f,e[7]=d}else r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],f=e[6],d=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 h;e[9]!==r||e[10]!==s||e[11]!==i||e[12]!==a?(h=s===null?null:t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:i,strokeWidth:3,strokeLinecap:"round",strokeDasharray:r,strokeDashoffset:r*(1-a/100),className:"transition-[stroke-dashoffset,stroke] duration-300"}),e[9]=r,e[10]=s,e[11]=i,e[12]=a,e[13]=h):h=e[13];let p;return e[14]!==o||e[15]!==l||e[16]!==f||e[17]!==d||e[18]!==h?(p=t.jsxs("svg",{viewBox:o,className:l,role:f,"aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":100,children:[m,h]}),e[14]=o,e[15]=l,e[16]=f,e[17]=d,e[18]=h,e[19]=p):p=e[19],p},hm=n=>{const e=fe.c(13),{icon:s,iconNode:r,label:i,children:a}=n;let o;e[0]!==s||e[1]!==r?(o=r??(s?t.jsx(X,{name:s,className:"size-[18px]"}):null),e[0]=s,e[1]=r,e[2]=o):o=e[2];let l;e[3]!==o?(l=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:o}),e[3]=o,e[4]=l):l=e[4];let f;e[5]!==i?(f=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:i}),e[5]=i,e[6]=f):f=e[6];let d;e[7]!==a?(d=t.jsx("span",{className:"min-w-0 flex-1 truncate text-end typography-ui-label font-medium text-foreground",children:a}),e[7]=a,e[8]=d):d=e[8];let m;return e[9]!==l||e[10]!==f||e[11]!==d?(m=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5",children:[l,f,d]}),e[9]=l,e[10]=f,e[11]=d,e[12]=m):m=e[12],m},gm=n=>{const e=fe.c(57),{open:s,onClose:r,anchorRef:i,contextDisplay:a,usageGroups:o,usageDisplayMode:l,isUsageLoading:f,timeFormatPreference:d}=n,{t:m}=ve(),h=c.useRef(null),[p,g]=c.useState(s),[x,y]=c.useState(!1),{enabled:b}=Hr(),S=c.useRef(null),[R,C]=c.useState(null);let D,A;e[0]!==i||e[1]!==b||e[2]!==s||e[3]!==p?(D=()=>{if(!s||!b||!p)return;const N=()=>{const ae=i.current?.getBoundingClientRect(),ie=S.current?.getBoundingClientRect();if(!ae||!ie){C(null);return}const q=ae.left-ie.left,se=Math.min(Math.max(q,8),Math.max(8,ie.width-mo-8));C(se)};N();const $=S.current;if(typeof ResizeObserver>"u"||!$)return;const J=new ResizeObserver(N);return J.observe($),()=>J.disconnect()},A=[i,b,s,p],e[0]=i,e[1]=b,e[2]=s,e[3]=p,e[4]=D,e[5]=A):(D=e[4],A=e[5]),c.useLayoutEffect(D,A);const j=b&&R!==null;let k,v;e[6]!==s||e[7]!==p?(k=()=>{if(s){g(!0),y(!1);return}if(!p)return;y(!0);const N=window.setTimeout(()=>{g(!1),y(!1)},140);return()=>window.clearTimeout(N)},v=[s,p],e[6]=s,e[7]=p,e[8]=k,e[9]=v):(k=e[8],v=e[9]),c.useEffect(k,v);let I,P;e[10]!==r||e[11]!==s?(I=()=>{if(!s)return;const N=$=>{$.key==="Escape"&&r()};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},P=[r,s],e[10]=r,e[11]=s,e[12]=I,e[13]=P):(I=e[12],P=e[13]),c.useEffect(I,P);let L,_;if(e[14]!==i||e[15]!==r||e[16]!==s?(L=()=>{if(!s)return;const N=$=>{const J=$.target;if(!(J instanceof Node)){r();return}h.current?.contains(J)||i.current?.contains(J)||r()};return document.addEventListener("pointerdown",N,!0),document.addEventListener("wheel",N,!0),()=>{document.removeEventListener("pointerdown",N,!0),document.removeEventListener("wheel",N,!0)}},_=[i,r,s],e[14]=i,e[15]=r,e[16]=s,e[17]=L,e[18]=_):(L=e[17],_=e[18]),c.useEffect(L,_),!p)return null;let E;e[19]!==m?(E=m("mobile.header.openMetadataAria"),e[19]=m,e[20]=E):E=e[20];const T=j?"absolute origin-top-left":"mx-3 mt-2",O=x?"pointer-events-none":"pointer-events-auto";let M;e[21]!==T||e[22]!==O?(M=ee("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",T,O),e[21]=T,e[22]=O,e[23]=M):M=e[23];const G=`${x?"session-metadata-out":"session-metadata-in"} ${x?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let F;e[24]!==R||e[25]!==j?(F=j?{top:8,left:R??8,width:`min(${mo}px, calc(100% - 16px))`}:null,e[24]=R,e[25]=j,e[26]=F):F=e[26];let z;e[27]!==G||e[28]!==F?(z={animation:G,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...F},e[27]=G,e[28]=F,e[29]=z):z=e[29];let U;e[30]!==a||e[31]!==m?(U=a?t.jsx(hm,{iconNode:t.jsx(Wa,{percentage:a.state==="measured"?a.percentage:null}),label:m("mobile.header.metadata.context"),children:a.state==="pending"?null:t.jsxs("span",{className:"inline-flex items-baseline gap-1.5 tabular-nums",children:[a.state==="measured"?t.jsxs("span",{className:ee("font-semibold",a.colorClass),children:[a.percentage.toFixed(1),"%"]}):null,t.jsx("span",{className:"text-muted-foreground",children:a.tokens})]})}):null,e[30]=a,e[31]=m,e[32]=U):U=e[32];let Q;e[33]!==a?.state||e[34]!==m?(Q=a?.state==="compacted"?t.jsx("p",{className:"px-2.5 pb-1 typography-meta text-muted-foreground",children:m("contextUsage.compacted.description")}):null,e[33]=a?.state,e[34]=m,e[35]=Q):Q=e[35];let te;e[36]!==a?.state||e[37]!==m?(te=a?.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]=a?.state,e[37]=m,e[38]=te):te=e[38];let ce;e[39]!==f||e[40]!==d||e[41]!==l||e[42]!==o?(ce=t.jsx(bm,{groups:o,displayMode:l,isLoading:f,timeFormatPreference:d}),e[39]=f,e[40]=d,e[41]=l,e[42]=o,e[43]=ce):ce=e[43];let re;e[44]!==U||e[45]!==Q||e[46]!==te||e[47]!==ce?(re=t.jsxs("div",{className:"space-y-1",children:[U,Q,te,ce]}),e[44]=U,e[45]=Q,e[46]=te,e[47]=ce,e[48]=re):re=e[48];let Y;e[49]!==M||e[50]!==z||e[51]!==re||e[52]!==E?(Y=t.jsx("div",{ref:h,role:"dialog","aria-label":E,className:M,style:z,children:re}),e[49]=M,e[50]=z,e[51]=re,e[52]=E,e[53]=Y):Y=e[53];let ye;e[54]===Symbol.for("react.memo_cache_sentinel")?(ye=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]=ye):ye=e[54];let Z;return e[55]!==Y?(Z=t.jsxs("div",{ref:S,className:"fixed inset-x-0 bottom-0 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-header-height,56px))] z-20 pointer-events-none",children:[Y,ye]}),e[55]=Y,e[56]=Z):Z=e[56],Z},bm=n=>{const e=fe.c(30),{groups:s,displayMode:r,isLoading:i,timeFormatPreference:a}=n,{t:o}=ve();let l;e[0]!==r||e[1]!==o?(l=o(r==="remaining"?"header.services.remaining":"header.services.used"),e[0]=r,e[1]=o,e[2]=l):l=e[2];const f=l;if(s.length===0){if(!i)return null;let R;e[3]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx(X,{name:"loader-4",className:"size-4 animate-spin","aria-hidden":!0}),e[3]=R):R=e[3];let C;e[4]!==o?(C=o("common.loading"),e[4]=o,e[5]=C):C=e[5];let D;return e[6]!==C?(D=t.jsxs("div",{className:"flex items-center justify-center gap-2 px-2.5 py-6 text-muted-foreground",children:[R,t.jsx("span",{className:"typography-ui-label",children:C})]}),e[6]=C,e[7]=D):D=e[7],D}let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(X,{name:"timer",className:"size-[18px]"})}),e[8]=d):d=e[8];let m;e[9]!==o?(m=o("mobile.header.metadata.usage"),e[9]=o,e[10]=m):m=e[10];let h;e[11]!==m?(h=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:m}),e[11]=m,e[12]=h):h=e[12];let p;e[13]!==i?(p=i?t.jsx(X,{name:"refresh",className:"size-3.5 animate-spin"}):null,e[13]=i,e[14]=p):p=e[14];let g;e[15]!==f?(g=t.jsx("span",{className:"truncate",children:f}),e[15]=f,e[16]=g):g=e[16];let x;e[17]!==p||e[18]!==g?(x=t.jsxs("span",{className:"inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground",children:[p,g]}),e[17]=p,e[18]=g,e[19]=x):x=e[19];let y;e[20]!==h||e[21]!==x?(y=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 px-2.5 pb-1.5",children:[d,h,x]}),e[20]=h,e[21]=x,e[22]=y):y=e[22];let b;e[23]!==r||e[24]!==s||e[25]!==a?(b=t.jsx(fm,{groups:s,displayMode:r,timeFormatPreference:a}),e[23]=r,e[24]=s,e[25]=a,e[26]=b):b=e[26];let S;return e[27]!==y||e[28]!==b?(S=t.jsxs("div",{className:"pt-2.5",children:[y,b]}),e[27]=y,e[28]=b,e[29]=S):S=e[29],S},xm=c.memo(function({open:e,onOpenChange:s,currentSessionId:r,effectiveDirectory:i,isNewSessionDraftOpen:a}){const{t:o}=ve(),l=c.useRef(null),f=Rl(r??"",i||void 0),d=ft(M=>M.providers),m=ft(M=>M.currentProviderId),h=ft(M=>M.currentModelId),p=ft(M=>M.getModelMetadata);ft(M=>M.modelsMetadata.size);const g=El(c.useCallback(M=>r?M.sessionModelSelections.get(r)??null:null,[r])),x=rs(M=>M.results),y=rs(M=>M.refreshErrors),b=c.useRef(!1),S=rs(M=>M.loadSettings),R=rs(M=>M.fetchAllQuotas),C=rs(M=>M.isLoading),D=rs(M=>M.displayMode),A=rs(M=>M.dropdownProviderIds),j=Ve(M=>M.timeFormatPreference);Il(),c.useEffect(()=>{S()},[S]),c.useEffect(()=>{Wi(A)},[A]),c.useEffect(()=>{if(!e){b.current=!1;return}b.current||C||!A.some(G=>!x.some(F=>F.providerId===G)||y[G])||(b.current=!0,R())},[A,R,C,e,x,y]);const v=c.useMemo(()=>{for(let M=f.length-1;M>=0;M-=1){const G=f[M];if(G.role!=="assistant")continue;const F=G.providerID.trim(),z=G.modelID.trim();if(F&&z)return{providerID:F,modelID:z}}return null},[f])??(g?{providerID:g.providerId,modelID:g.modelId}:null)??(m&&h?{providerID:m,modelID:h}:null),P=(v?d.find(M=>M.id===v.providerID):void 0)?.models.find(M=>M.id===v?.modelID),L=v?p(v.providerID,v.modelID):void 0,_=mm(P?.limit,"context")??L?.limit?.context??0,E=c.useMemo(()=>Al(f),[f]),T=c.useMemo(()=>{if(_<=0)return null;if(a||!E)return{state:"pending"};if(E.state==="compacted")return{state:"compacted",tokens:`${pm}/${Nr(_)}`};const M=Math.min(E.totalTokens/_*100,999),G=M>=90?"text-[var(--status-error)]":M>=75?"text-[var(--status-warning)]":"text-[var(--status-success)]";return{state:"measured",percentage:M,tokens:`${Nr(E.totalTokens)}/${Nr(_)}`,colorClass:G}},[E,_,a]),O=Pl();return c.useEffect(()=>{!e||O.length===0||Wi(O.map(M=>M.providerId))},[e,O]),t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:l,type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("mobile.header.openMetadataAria"),"aria-expanded":e,onClick:()=>s(M=>!M),style:{touchAction:"manipulation"},children:t.jsx(Wa,{percentage:T?.state==="measured"?T.percentage:T?.state==="compacted"?null:0})}),t.jsx(gm,{open:e,onClose:()=>s(!1),anchorRef:l,contextDisplay:T,usageGroups:O,usageDisplayMode:D,isUsageLoading:C,timeFormatPreference:j})]})}),ym=10,po=380,vm=(n,e)=>n.title?.trim()||e,wm=n=>{const e=fe.c(33),{session:s,meta:r,active:i,onSelect:a}=n,{t:o}=ve(),l=Jr(s.id),f=Xr(s.id),d=f!==null,m=!d&&l>0&&!i,h=Yr(s.id,d),p=(d||m)&&h;let g;e[0]!==s?(g=_l(Ho(s)),e[0]=s,e[1]=g):g=e[1];const x=g,y=i&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let b;e[2]!==y?(b=ee("flex w-full items-center gap-3 rounded-xl px-2.5 py-2 text-start transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",y),e[2]=y,e[3]=b):b=e[3];let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S={touchAction:"manipulation"},e[4]=S):S=e[4];const R=i?"text-primary":"text-foreground";let C;e[5]!==R?(C=ee("block truncate oc-ui-start-align typography-ui-label",R),e[5]=R,e[6]=C):C=e[6];let D;e[7]!==s||e[8]!==o?(D=vm(s,o("sessions.sidebar.session.untitled")),e[7]=s,e[8]=o,e[9]=D):D=e[9];let A;e[10]!==C||e[11]!==D?(A=t.jsx("span",{dir:"auto",className:C,children:D}),e[10]=C,e[11]=D,e[12]=A):A=e[12];let j;e[13]!==r?(j=r?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:r}):null,e[13]=r,e[14]=j):j=e[14];let k;e[15]!==A||e[16]!==j?(k=t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[A,j]}),e[15]=A,e[16]=j,e[17]=k):k=e[17];let v;e[18]!==d||e[19]!==m||e[20]!==f?(v=d||m?t.jsx(Wn,{state:f??"unread"}):null,e[18]=d,e[19]=m,e[20]=f,e[21]=v):v=e[21];let I;e[22]!==d||e[23]!==s.id||e[24]!==p||e[25]!==x?(I=p?t.jsx(Qr,{sessionId:s.id,running:d,className:"typography-micro"}):x?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:x}):null,e[22]=d,e[23]=s.id,e[24]=p,e[25]=x,e[26]=I):I=e[26];let P;return e[27]!==a||e[28]!==k||e[29]!==v||e[30]!==I||e[31]!==b?(P=t.jsxs("button",{type:"button",className:b,onClick:a,style:S,children:[k,v,I]}),e[27]=a,e[28]=k,e[29]=v,e[30]=I,e[31]=b,e[32]=P):P=e[32],P},jm=n=>{const e=fe.c(50),{open:s,onClose:r,anchorRef:i}=n,{t:a}=ve(),o=c.useRef(null),[l,f]=c.useState(s),[d,m]=c.useState(!1),{enabled:h}=Hr(),p=c.useRef(null),[g,x]=c.useState(null);let y,b;e[0]!==i||e[1]!==h||e[2]!==s||e[3]!==l?(y=()=>{if(!s||!h||!l)return;const Z=()=>{const J=i.current?.getBoundingClientRect(),ae=p.current?.getBoundingClientRect();if(!J||!ae){x(null);return}const ie=J.left-ae.left;x(Math.min(Math.max(ie,8),Math.max(8,ae.width-po-8)))};Z();const N=p.current;if(typeof ResizeObserver>"u"||!N)return;const $=new ResizeObserver(Z);return $.observe(N),()=>$.disconnect()},b=[i,h,s,l],e[0]=i,e[1]=h,e[2]=s,e[3]=l,e[4]=y,e[5]=b):(y=e[4],b=e[5]),c.useLayoutEffect(y,b);const S=h&&g!==null,R=Be(km),C=Be(Sm),D=it(Nm);let A;e[6]===Symbol.for("react.memo_cache_sentinel")?(A={maxParents:ym},e[6]=A):A=e[6];const j=Ml(s||l,A);let k,v;e[7]!==s||e[8]!==l?(k=()=>{if(s){Jo(),f(!0),m(!1);return}if(!l)return;m(!0);const Z=window.setTimeout(()=>{f(!1),m(!1)},140);return()=>window.clearTimeout(Z)},v=[s,l],e[7]=s,e[8]=l,e[9]=k,e[10]=v):(k=e[9],v=e[10]),c.useEffect(k,v);let I,P;e[11]!==r||e[12]!==s?(I=()=>{if(!s)return;const Z=N=>{N.key==="Escape"&&r()};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},P=[r,s],e[11]=r,e[12]=s,e[13]=I,e[14]=P):(I=e[13],P=e[14]),c.useEffect(I,P);let L,_;e[15]!==i||e[16]!==r||e[17]!==s?(L=()=>{if(!s)return;const Z=N=>{const $=N.target;if(!($ instanceof Node)){r();return}o.current?.contains($)||i.current?.contains($)||r()};return document.addEventListener("pointerdown",Z,!0),()=>document.removeEventListener("pointerdown",Z,!0)},_=[i,r,s],e[15]=i,e[16]=r,e[17]=s,e[18]=L,e[19]=_):(L=e[18],_=e[19]),c.useEffect(L,_);let E;e[20]!==r||e[21]!==C?(E=Z=>{C(Z.id,Go(Z)),r()},e[20]=r,e[21]=C,e[22]=E):E=e[22];const T=E;if(!l)return null;let O;e[23]!==a?(O=a("sessions.switcher.openAria"),e[23]=a,e[24]=O):O=e[24];const M=S?"absolute origin-top-left":"mx-3 mt-2",G=d?"pointer-events-none":"pointer-events-auto";let F;e[25]!==M||e[26]!==G?(F=ee("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",M,G),e[25]=M,e[26]=G,e[27]=F):F=e[27];const z=`${d?"session-switcher-out":"session-switcher-in"} ${d?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let U;e[28]!==g||e[29]!==S?(U=S?{top:8,left:g??8,width:`min(${po}px, calc(100% - 16px))`}:null,e[28]=g,e[29]=S,e[30]=U):U=e[30];let Q;e[31]!==z||e[32]!==U?(Q={animation:z,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...U},e[31]=z,e[32]=U,e[33]=Q):Q=e[33];let te;e[34]!==R||e[35]!==T||e[36]!==j||e[37]!==D||e[38]!==a?(te=j.length===0?t.jsx("p",{className:"px-3 py-6 text-center typography-small text-muted-foreground",children:a("sessions.switcher.empty")}):j.map(Z=>{const N=Z.node.session,$=[Z.secondaryMeta?.projectLabel,Z.secondaryMeta?.branchLabel].filter(Boolean).join(" · ");return t.jsx(wm,{session:N,meta:$,active:N.id===R,onSelect:()=>{Z.projectId&&D(Z.projectId),T(N)}},N.id)}),e[34]=R,e[35]=T,e[36]=j,e[37]=D,e[38]=a,e[39]=te):te=e[39];let ce;e[40]!==te?(ce=t.jsx("div",{className:"oc-hide-scrollbar min-h-0 flex-1 space-y-0.5 overflow-y-auto overscroll-contain",children:te}),e[40]=te,e[41]=ce):ce=e[41];let re;e[42]!==O||e[43]!==F||e[44]!==Q||e[45]!==ce?(re=t.jsx("div",{ref:o,role:"dialog","aria-label":O,className:F,style:Q,children:ce}),e[42]=O,e[43]=F,e[44]=Q,e[45]=ce,e[46]=re):re=e[46];let Y;e[47]===Symbol.for("react.memo_cache_sentinel")?(Y=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]=Y):Y=e[47];let ye;return e[48]!==re?(ye=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:[re,Y]}),e[48]=re,e[49]=ye):ye=e[49],ye};function km(n){return n.currentSessionId}function Sm(n){return n.setCurrentSession}function Nm(n){return n.setActiveProjectIdOnly}const Cm=n=>{const e=fe.c(84),{onOpenSessions:s,onOpenWorkspace:r,compactTitle:i}=n,a=i===void 0?!1:i,{t:o}=ve(),[l,f]=c.useState(!1),[d,m]=c.useState(!1),h=c.useRef(null),p=Dt(Rm),g=Be(Em);let x;e[0]!==g?(x=be=>g?be.getDirectoryForSession(g):null,e[0]=g,e[1]=x):x=e[1];const b=Be(x)||p,S=Ol(g,b||void 0),R=Be(Im),C=Xo(b||null);let D;e[2]!==b||e[3]!==C?(D=be=>{if(!b||C!==!0)return!1;const De=be.directories.get(b)?.status;return!!(De&&!De.isClean)},e[2]=b,e[3]=C,e[4]=D):D=e[4];const A=ut(D),j=Ve(Am),k=gu(j);let v;e[5]!==S?.title?(v=S?.title?.trim(),e[5]=S?.title,e[6]=v):v=e[6];const I=v;let P;e[7]!==g||e[8]!==j||e[9]!==k||e[10]!==I||e[11]!==o?(P=(j?k:null)||I||o(g?"mobile.sessions.untitled":"sessions.switcher.draftTitle"),e[7]=g,e[8]=j,e[9]=k,e[10]=I,e[11]=o,e[12]=P):P=e[12];const L=P;let _;e[13]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{f(!1),m(!1)},e[13]=_):_=e[13];let E;e[14]!==g||e[15]!==b?(E=[g,b],e[14]=g,e[15]=b,e[16]=E):E=e[16],c.useEffect(_,E);let T;e[17]!==s?(T=()=>{f(!1),m(!1),s()},e[17]=s,e[18]=T):T=e[18];const O=T;let M;e[19]===Symbol.for("react.memo_cache_sentinel")?(M=be=>{f(De=>{const Oe=typeof be=="function"?be(De):be;return Oe&&m(!1),Oe})},e[19]=M):M=e[19];const G=M;let F;e[20]===Symbol.for("react.memo_cache_sentinel")?(F=()=>{m(be=>{const De=!be;return De&&f(!1),De})},e[20]=F):F=e[20];const z=F;let U;e[21]===Symbol.for("react.memo_cache_sentinel")?(U={paddingTop:"var(--oc-safe-area-top, 0px)"},e[21]=U):U=e[21];let Q;e[22]!==o?(Q=o("mobile.sessions.openSheetAria"),e[22]=o,e[23]=Q):Q=e[23];let te,ce;e[24]===Symbol.for("react.memo_cache_sentinel")?(te={touchAction:"manipulation"},ce=t.jsx(X,{name:"list-unordered",className:"size-5"}),e[24]=te,e[25]=ce):(te=e[24],ce=e[25]);let re;e[26]!==O||e[27]!==Q?(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":Q,onClick:O,style:te,children:ce}),e[26]=O,e[27]=Q,e[28]=re):re=e[28];const Y=a?"shrink":"flex-1";let ye;e[29]!==Y?(ye=ee("flex min-w-0 items-center rounded-lg px-2 py-1.5 text-start transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",Y),e[29]=Y,e[30]=ye):ye=e[30];let Z;e[31]!==o?(Z=o("sessions.switcher.openAria"),e[31]=o,e[32]=Z):Z=e[32];let N;e[33]===Symbol.for("react.memo_cache_sentinel")?(N={touchAction:"manipulation"},e[33]=N):N=e[33];let $;e[34]!==L?($=t.jsx("span",{dir:"auto",className:"block min-w-0 truncate oc-ui-start-align typography-ui-label text-foreground",children:L}),e[34]=L,e[35]=$):$=e[35];const J=d&&"rotate-180";let ae;e[36]!==J?(ae=ee("size-4 shrink-0 text-muted-foreground transition-transform duration-150",J),e[36]=J,e[37]=ae):ae=e[37];let ie;e[38]!==ae?(ie=t.jsx(X,{name:"arrow-down-s",className:ae}),e[38]=ae,e[39]=ie):ie=e[39];let q;e[40]!==$||e[41]!==ie?(q=t.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[$,ie]}),e[40]=$,e[41]=ie,e[42]=q):q=e[42];let se;e[43]!==d||e[44]!==ye||e[45]!==Z||e[46]!==q?(se=t.jsx("button",{ref:h,type:"button",className:ye,"aria-label":Z,"aria-haspopup":"dialog","aria-expanded":d,onClick:z,style:N,children:q}),e[43]=d,e[44]=ye,e[45]=Z,e[46]=q,e[47]=se):se=e[47];let ke;e[48]!==a?(ke=a?t.jsx("div",{className:"min-w-0 flex-1"}):null,e[48]=a,e[49]=ke):ke=e[49];let xe;e[50]!==g||e[51]!==b||e[52]!==R||e[53]!==l||e[54]!==j?(xe=j?null:t.jsx(xm,{open:l,onOpenChange:G,currentSessionId:g,effectiveDirectory:b,isNewSessionDraftOpen:R}),e[50]=g,e[51]=b,e[52]=R,e[53]=l,e[54]=j,e[55]=xe):xe=e[55];let we;e[56]!==b?(we=t.jsx(bu,{directory:b,className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",iconClassName:"size-5"}),e[56]=b,e[57]=we):we=e[57];let me;e[58]!==A||e[59]!==o?(me=o(A?"mobile.header.openWorkspaceWithChangesAria":"mobile.header.openWorkspaceAria"),e[58]=A,e[59]=o,e[60]=me):me=e[60];let Re;e[61]!==r?(Re=()=>{f(!1),m(!1),r()},e[61]=r,e[62]=Re):Re=e[62];let Ae,Te;e[63]===Symbol.for("react.memo_cache_sentinel")?(Ae={touchAction:"manipulation"},Te=t.jsx(X,{name:"pencil-ruler-2",className:"size-5"}),e[63]=Ae,e[64]=Te):(Ae=e[63],Te=e[64]);let Se;e[65]!==A?(Se=A?t.jsx("span",{className:"absolute inset-e-1.5 top-1.5 size-2.5 rounded-full border-2 border-[var(--background)] bg-[var(--status-warning)]","aria-hidden":!0}):null,e[65]=A,e[66]=Se):Se=e[66];let Ce;e[67]!==me||e[68]!==Re||e[69]!==Se?(Ce=t.jsxs("button",{type:"button",className:"relative flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":me,onClick:Re,style:Ae,children:[Te,Se]}),e[67]=me,e[68]=Re,e[69]=Se,e[70]=Ce):Ce=e[70];let K;e[71]!==re||e[72]!==se||e[73]!==ke||e[74]!==xe||e[75]!==we||e[76]!==Ce?(K=t.jsx("header",{className:"oc-mobile-header relative z-30 flex shrink-0 items-center gap-1 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",style:U,children:t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[re,se,ke,xe,we,Ce]})}),e[71]=re,e[72]=se,e[73]=ke,e[74]=xe,e[75]=we,e[76]=Ce,e[77]=K):K=e[77];let ge;e[78]===Symbol.for("react.memo_cache_sentinel")?(ge=()=>m(!1),e[78]=ge):ge=e[78];let ne;e[79]!==d?(ne=t.jsx(jm,{open:d,onClose:ge,anchorRef:h}),e[79]=d,e[80]=ne):ne=e[80];let he;return e[81]!==K||e[82]!==ne?(he=t.jsxs(t.Fragment,{children:[K,ne]}),e[81]=K,e[82]=ne,e[83]=he):he=e[83],he};function Rm(n){return n.currentDirectory}function Em(n){return n.currentSessionId}function Im(n){return!!n.newSessionDraft?.open}function Am(n){return n.runOverviewKey}const Pm=({onActiveConnectionDeleted:n,onConnect:e})=>{const{t:s}=ve(),r=Ma(e),{connections:i,isBusy:a,isPasswordBusy:o,error:l,pendingConnection:f,connect:d,submitPassword:m,cancelPassword:h,saveConnection:p,removeConnection:g,setError:x}=r,[y,b]=c.useState(null),S=y?i.find(q=>q.id===y)??null:null,[R,C]=c.useState(null),[D,A]=c.useState(""),[j,k]=c.useState(""),[v,I]=c.useState(""),[P,L]=c.useState(""),[_,E]=c.useState(!1),[T,O]=c.useState(!1),M=c.useRef(null),G=c.useMemo(()=>Wr(),[]),[F,z]=c.useState(!1),[U,Q]=c.useState(null),[te,ce]=c.useState(!1),re=ja(c.useCallback(()=>ce(!0),[])),Y=c.useCallback(()=>{b(null),A(""),k(""),I(""),x(null),z(!1)},[x]),ye=c.useCallback(q=>{q.preventDefault(),p({id:y??void 0,url:D,label:j,clientToken:v}).then(se=>{se&&Y()})},[v,y,j,Y,p,D]),Z=c.useCallback(async()=>{if(M.current)return;x(null),E(!0);const q=new AbortController;M.current=q;try{const se=await La({signal:q.signal});switch(M.current===q&&(M.current=null,E(!1)),se.status){case"ok":A(se.url),se.label&&k(se.label),se.clientToken&&I(se.clientToken),z(!0);break;case"pairing":O(!0),await r.redeemPairingConnection(se.pairing);break;case"permission-denied":x(s("mobile.connect.scan.permissionDenied"));break;case"invalid":x(s("mobile.connect.scan.invalid"));break;case"unsupported":x(s("mobile.connect.scan.unsupported"));break;case"failed":x(s("mobile.connect.scan.failed"));break;default:break}}finally{O(!1),M.current===q&&(M.current=null,E(!1))}},[r,x,s]);c.useEffect(()=>()=>M.current?.abort(),[]);const N=c.useCallback(q=>{q.preventDefault(),m(P)},[P,m]),$=c.useCallback(()=>{L(""),h()},[h]),J=c.useCallback(q=>{C(se=>se===q?null:q)},[]),ae=c.useCallback(q=>{C(null),y===q&&Y();const se=i.length===1;g(q).then(ke=>{ke&&(se||fo(ke))&&n()})},[i.length,y,n,g,Y]),ie=an;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:N,children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(X,{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(q=>q.kind==="direct")?Tt(f):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...Ts,value:P,onChange:q=>L(q.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(Ee,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:o||!P.trim(),children:s(o?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(Ee,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:$,children:s("mobile.connect.cancelPassword")})]})})}):t.jsxs(t.Fragment,{children:[_?t.jsx(Fa,{onCancel:()=>M.current?.abort()}):null,T?t.jsx($a,{}):null,te?t.jsx(_a,{onClose:()=>ce(!1)}):null,t.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:t.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:t.jsxs("div",{className:"space-y-6",children:[i.length>0?t.jsx("div",{...re,className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:i.map(q=>{const se=R===q.id,ke=fo(q),xe=U===q.id,we=xe?s("mobile.connect.connecting"):ke?fn()?s("mobile.instances.status.connectedRelay"):s("mobile.instances.status.connectedDirect"):q.candidates.some(me=>me.kind==="direct")?Tt(q):s("mobile.connect.relay.badge");return t.jsxs("div",{className:ee("flex items-center border-b border-border/70 transition-colors last:border-b-0",se&&"bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]"),children:[t.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-3 px-3.5 py-3 text-start transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:opacity-60",onClick:()=>{ke||(Q(q.id),d({id:q.id,candidates:q.candidates,clientToken:q.clientToken,label:q.label}).finally(()=>Q(null)))},disabled:a&&!xe||se,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(X,{name:"server",className:"size-[18px]"}),ke?t.jsx("span",{className:"absolute -inset-e-0.5 -top-0.5 size-2.5 rounded-full border-2 border-[var(--surface-elevated)] bg-[var(--status-success)]","aria-hidden":!0}):null]}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:q.label}),t.jsx("span",{className:ee("block truncate typography-small",ke&&!xe?"text-[var(--status-success)]":"text-muted-foreground"),children:we})]}),xe?t.jsx(X,{name:"loader-4",className:"size-5 shrink-0 animate-spin text-muted-foreground"}):null]}),t.jsxs("div",{className:"flex items-center gap-0.5 pe-2",children:[se?t.jsxs("button",{type:"button","aria-label":s("mobile.instances.confirmDeleteAria",{label:q.label}),className:"flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-destructive px-3 text-destructive-foreground transition-opacity active:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive",onClick:()=>ae(q.id),style:{touchAction:"manipulation"},children:[t.jsx(X,{name:"delete-bin",className:"size-[18px]"}),t.jsx("span",{className:"typography-ui-label",children:s("mobile.instances.delete")})]}):q.candidates.some(me=>me.kind==="direct")?t.jsx("button",{type:"button","aria-label":s("mobile.instances.edit"),className:"flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>{b(q.id),A(Tt(q)),k(q.label),I(q.clientToken||""),x(null)},style:{touchAction:"manipulation"},children:t.jsx(X,{name:"edit",className:"size-[18px]"})}):null,t.jsx("button",{type:"button","aria-label":se?s("mobile.instances.cancelDeleteAria",{label:q.label}):s("mobile.instances.deleteAria",{label:q.label}),className:"flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>J(q.id),style:{touchAction:"manipulation"},children:t.jsx(X,{name:se?"close":"delete-bin",className:"size-[18px]"})})]})]},q.id)})}):t.jsx("p",{...re,className:"rounded-[18px] border border-dashed border-border/70 px-4 py-6 text-center typography-small text-muted-foreground",children:s("mobile.connect.saved.empty")}),!F&&!S?t.jsxs("div",{className:"space-y-2",children:[G?t.jsxs(Ee,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{Z()},disabled:_,children:[t.jsx(X,{name:"scan-2",className:ee("size-[18px]",_&&"animate-pulse")}),s("mobile.connect.scanQr")]}):null,t.jsxs(Ee,{type:"button",variant:G?"ghost":"outline",size:"lg",className:"h-12 w-full",onClick:()=>{x(null),z(!0)},children:[t.jsx(X,{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:ye,children:[t.jsxs("div",{className:"flex h-8 items-center justify-between gap-3 px-1",children:[t.jsx("h3",{className:"typography-ui-label text-foreground",children:s(S?"mobile.instances.editTitle":"mobile.instances.addTitle")}),t.jsx(Ee,{type:"button",variant:"ghost",size:"xs",onClick:Y,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",{...Ts,value:D,onChange:q=>A(q.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:j,onChange:q=>k(q.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",{...Ts,value:v,onChange:q=>I(q.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(Ee,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",children:s(S?"mobile.instances.saveEdit":"mobile.instances.saveNew")})]})]})})})]})},He=n=>bn(n)??"",Cr=n=>{const e=He(n);if(!e)return"";const s=e.split("/").filter(Boolean);return s[s.length-1]?.replace(/[-_]/g," ")||e},ho=mi(n=>({expandedParents:{},toggleParent:e=>n(s=>{const r={...s.expandedParents};return r[e]?delete r[e]:r[e]=!0,{expandedParents:r}})})),On=mi()(xa(n=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(e,s)=>n(r=>({projectExpanded:{...r.projectExpanded,[e]:s}})),setWorktreeExpanded:(e,s)=>n(r=>({worktreeExpanded:{...r.worktreeExpanded,[e]:s}}))}),{name:"mobile-session-tree"})),Vr=mi()(xa(n=>({orderByProject:{},setWorktreeOrder:(e,s)=>n(r=>({orderByProject:{...r.orderByProject,[e]:s}}))}),{name:"mobile-worktree-order"})),go=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),Tm=(n,e)=>{if(!n||n.length===0)return e;const s=new Map(n.map((i,a)=>[go(i),a])),r=i=>s.get(go(i.path))??Number.MAX_SAFE_INTEGER;return e.map((i,a)=>({worktree:i,index:a})).sort((i,a)=>{const o=r(i.worktree)-r(a.worktree);return o!==0?o:i.index-a.index}).map(i=>i.worktree)},ln=n=>bn(n)??"",Dm=n=>{const e=n;return ln(e.directory??e.project?.worktree??null)},Va=({open:n,project:e,worktree:s,onClose:r,onDeleted:i})=>{const{t:a}=ve(),o=Yo(),l=ls(T=>T.activeSessions),f=Be(T=>T.archiveSessions),d=Dt(T=>T.currentDirectory),{git:m,sourceControl:h}=Zn(),[p,g]=c.useState(!1),[x,y]=c.useState(!1),[b,S]=c.useState(!1),[R,C]=c.useState(null),[D,A]=c.useState(!1),j=ln(s?.path),k=typeof s?.branch=="string"&&s.branch.trim().length>0,v=c.useMemo(()=>{if(!j)return[];const T=new Map;for(const O of[...l,...o])Dm(O)===j&&T.set(O.id,O);return Array.from(T.values())},[l,o,j]);c.useEffect(()=>{if(!n){g(!1),y(!1),S(!1),C(null),A(!1);return}if(!s?.path)return;let T=!1;return zl(s.path).then(O=>{T||(S(!!O?.isDirty),C(O?.upstream?.split("/")[0]?.trim()||null))}).catch(()=>{T||S(!!s.status?.isDirty)}),()=>{T=!0}},[n,s?.path,s?.status?.isDirty]);const I=c.useCallback(async T=>(await Bl(e,T,{deleteRemoteBranch:k&&x,deleteLocalBranch:k&&p,remoteName:R??void 0,network:{git:m,sourceControl:h}}),ln(d)===j&&ln(e.path)&&Dt.getState().setDirectory(ln(e.path),{showOverlay:!1}),!0),[d,p,x,m,k,e,R,h,j]),P=c.useCallback((T,O)=>{const M=Ll(T),G=de.loading(a("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:M}));Fl(T.path),(async()=>{try{const F=await xu({sessionIds:O,removeWorktree:()=>I(T),archiveSessions:f});if(!F.removed){de.dismiss(G);return}const{failedIds:z}=F.archive;if(z.length>0){de.error(z.length===1?a("sessions.sidebar.bulkActions.failedArchiveSingle",{count:z.length}):a("sessions.sidebar.bulkActions.failedArchivePlural",{count:z.length}),{id:G,description:a("sessions.sidebar.dialogs.deleteResult.tryAgain")});return}de.success(a("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:M}),{id:G,description:a(k&&x?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed")}),i?.()}catch(F){const z=F instanceof Ln?F.message||a("sessions.sidebar.dialogs.deleteResult.tryAgain"):F instanceof Dr||F instanceof Lt&&!F.message.includes(" ")?a("gitView.publish.remoteNotGranted"):F instanceof Error?F.message:a("sessions.sidebar.dialogs.deleteResult.tryAgain");de.error(a("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:M}),{id:G,description:z})}finally{$l(T.path)}})()},[f,x,k,i,I,a]),L=()=>{!s||D||(P(s,v.map(T=>T.id)),r())};if(!s)return null;const _=s.branch||s.label||s.path,E=(T,O,M,G)=>t.jsxs("button",{type:"button",role:"switch","aria-checked":T,disabled:G,onClick:()=>O(!T),className:ee("flex w-full items-center justify-between gap-3 rounded-xl border border-border/70 px-3.5 py-3 text-start transition-colors","hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",G&&"pointer-events-none opacity-40"),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:M}),t.jsx("span",{className:ee("relative h-6 w-10 shrink-0 rounded-full transition-colors",T?"bg-primary":"bg-muted-foreground/30"),children:t.jsx("span",{className:ee("absolute top-0.5 size-5 rounded-full bg-white transition-transform",T?"translate-x-[1.125rem] rtl:-translate-x-[1.125rem]":"translate-x-0.5 rtl:-translate-x-0.5")})})]});return t.jsx(Wl,{open:n,onClose:r,title:a("mobile.projectEdit.deleteWorktreeTitle"),footer:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Ee,{variant:"ghost",className:"flex-1",onClick:r,disabled:D,children:a("projectEditDialog.actions.cancel")}),t.jsx(Ee,{variant:"destructive",className:"flex-1",onClick:()=>{L()},disabled:D,children:a("mobile.projectEdit.deleteWorktreeConfirmButton")})]}),children:t.jsxs("div",{className:"flex flex-col gap-4 px-1 py-1",children:[t.jsx("p",{className:"typography-ui-body text-foreground",children:a("mobile.projectEdit.deleteWorktreeConfirm",{name:_})}),b?t.jsx("p",{className:"rounded-xl border border-[var(--warning)]/40 bg-[color-mix(in_srgb,var(--warning)_10%,transparent)] px-3.5 py-3 typography-meta text-foreground",children:a("mobile.projectEdit.deleteWorktreeDirty")}):null,v.length>0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:a("mobile.projectEdit.deleteWorktreeArchiveNote",{count:v.length})}):null,k?t.jsxs("div",{className:"flex flex-col gap-2",children:[E(p,g,a("mobile.projectEdit.deleteLocalBranch"),D),E(x,y,a("mobile.projectEdit.deleteRemoteBranch"),D||!R)]}):null]})})},Xn=n=>{const e=fe.c(20),{project:s,size:r}=n,i=r===void 0?"md":r,{currentTheme:a}=Qo(),o=s.icon?Zo[s.icon]:null;let l;e[0]!==s.color?(l=ea(s.color),e[0]=s.color,e[1]=l):l=e[1];const f=l,d=i==="md"?"size-5":"size-3.5";let m;e[2]!==o||e[3]!==d||e[4]!==f?(m=o?t.jsx(X,{name:o,className:d,style:f?{color:f}:void 0}):t.jsx(Br,{className:d,style:f?{color:f}:void 0}),e[2]=o,e[3]=d,e[4]=f,e[5]=m):m=e[5];const h=m;let p;e[6]!==a||e[7]!==h||e[8]!==s.iconImage||e[9]!==s.id?(p=s.iconImage?t.jsx(ta,{project:{id:s.id,iconImage:s.iconImage??null},options:{themeVariant:a.metadata.variant,iconColor:a.colors.surface.foreground},className:"size-full object-contain",fallback:h}):null,e[6]=a,e[7]=h,e[8]=s.iconImage,e[9]=s.id,e[10]=p):p=e[10];const g=p;let x;e[11]!==s.iconBackground?(x=s.iconBackground?{backgroundColor:s.iconBackground}:void 0,e[11]=s.iconBackground,e[12]=x):x=e[12];const y=x;if(i==="md"){let R;return e[13]!==h||e[14]!==g||e[15]!==y?(R=t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground",children:g?t.jsx("span",{className:"flex size-6 items-center justify-center overflow-hidden rounded-md",style:y,children:g}):h}),e[13]=h,e[14]=g,e[15]=y,e[16]=R):R=e[16],R}const b=g??h;let S;return e[17]!==y||e[18]!==b?(S=t.jsx("span",{className:"flex size-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px] text-muted-foreground",style:y,children:b}),e[17]=y,e[18]=b,e[19]=S):S=e[19],S},Ua=n=>{const e=fe.c(57),{initialTitle:s,indent:r,className:i,aiRename:a,onSubmit:o,onCancel:l}=n,{t:f}=ve(),[d,m]=c.useState(s),h=Mm;let p;e[0]!==s||e[1]!==l||e[2]!==o||e[3]!==d?(p=()=>{const te=d.trim();if(!te||te===s.trim()){l();return}o(te)},e[0]=s,e[1]=l,e[2]=o,e[3]=d,e[4]=p):p=e[4];const g=p;let x;e[5]!==i?(x=ee("flex h-9 min-w-0 flex-1 items-center gap-2 pe-2",i),e[5]=i,e[6]=x):x=e[6];let y;e[7]!==r?(y={paddingInlineStart:r},e[7]=r,e[8]=y):y=e[8];let b;e[9]!==g?(b=te=>{te.preventDefault(),g()},e[9]=g,e[10]=b):b=e[10];let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=te=>m(te.target.value),e[11]=S):S=e[11];let R;e[12]!==l?(R=te=>yu(te,l),e[12]=l,e[13]=R):R=e[13];let C;e[14]!==f?(C=f("sessions.sidebar.session.rename.save"),e[14]=f,e[15]=C):C=e[15];let D;e[16]!==f?(D=f("sessions.sidebar.session.menu.rename"),e[16]=f,e[17]=D):D=e[17];let A;e[18]===Symbol.for("react.memo_cache_sentinel")?(A={minHeight:0},e[18]=A):A=e[18];let j;e[19]!==R||e[20]!==C||e[21]!==D||e[22]!==d?(j=t.jsx("input",{ref:h,value:d,onChange:S,onKeyDown:R,"aria-label":C,placeholder:D,className:"min-w-0 flex-1 bg-transparent text-[16px] typography-ui-label text-foreground outline-none placeholder:text-muted-foreground",style:A,enterKeyHint:"done"}),e[19]=R,e[20]=C,e[21]=D,e[22]=d,e[23]=j):j=e[23];const k=a.disabled;let v;e[24]!==a||e[25]!==l?(v=()=>{a.run(),l()},e[24]=a,e[25]=l,e[26]=v):v=e[26];let I;e[27]!==f?(I=f("sessions.aiRename.action"),e[27]=f,e[28]=I):I=e[28];let P,L;e[29]===Symbol.for("react.memo_cache_sentinel")?(P={touchAction:"manipulation",minHeight:0,minWidth:0},L=t.jsx(X,{name:"ai-generate-2",className:"size-4"}),e[29]=P,e[30]=L):(P=e[29],L=e[30]);let _;e[31]!==a.disabled||e[32]!==a.hint||e[33]!==v||e[34]!==I?(_=t.jsx("button",{type:"button",disabled:k,onClick:v,"aria-label":I,"aria-description":a.hint,title:a.hint,className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground disabled:opacity-40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:P,children:L}),e[31]=a.disabled,e[32]=a.hint,e[33]=v,e[34]=I,e[35]=_):_=e[35];let E;e[36]!==f?(E=f("sessions.sidebar.session.rename.save"),e[36]=f,e[37]=E):E=e[37];let T,O;e[38]===Symbol.for("react.memo_cache_sentinel")?(T={touchAction:"manipulation",minHeight:0,minWidth:0},O=t.jsx(X,{name:"check",className:"size-4"}),e[38]=T,e[39]=O):(T=e[38],O=e[39]);let M;e[40]!==E?(M=t.jsx("button",{type:"submit","aria-label":E,className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:T,children:O}),e[40]=E,e[41]=M):M=e[41];let G;e[42]!==f?(G=f("sessions.sidebar.session.rename.cancel"),e[42]=f,e[43]=G):G=e[43];let F,z;e[44]===Symbol.for("react.memo_cache_sentinel")?(F={touchAction:"manipulation",minHeight:0,minWidth:0},z=t.jsx(X,{name:"close",className:"size-4"}),e[44]=F,e[45]=z):(F=e[44],z=e[45]);let U;e[46]!==l||e[47]!==G?(U=t.jsx("button",{type:"button",onClick:l,"aria-label":G,className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:F,children:z}),e[46]=l,e[47]=G,e[48]=U):U=e[48];let Q;return e[49]!==j||e[50]!==_||e[51]!==x||e[52]!==M||e[53]!==U||e[54]!==y||e[55]!==b?(Q=t.jsxs("form",{className:x,style:y,onSubmit:b,children:[j,_,M,U]}),e[49]=j,e[50]=_,e[51]=x,e[52]=M,e[53]=U,e[54]=y,e[55]=b,e[56]=Q):Q=e[56],Q};function Mm(n){n&&(n.focus(),n.select())}const pn=48,Ga=4*pn,_m=180,Yn=n=>{const e=fe.c(32),{actionsWidth:s,actions:r,revealed:i,onRevealedChange:a,dataActiveSession:o,contentClassName:l,children:f}=n,d=l===void 0?"relative flex w-full items-center bg-background":l,{direction:m}=ve(),h=m==="rtl"?-1:1,p=c.useRef(null),g=c.useRef(null),x=c.useRef(!1),y=c.useRef(0),b=c.useRef(i);let S;e[0]!==h?(S=(F,z)=>{const U=p.current;U&&(U.style.transition=z?`transform ${_m}ms ease-out`:"none",U.style.transform=F===0?"none":`translateX(${F*h}px)`,y.current=F)},e[0]=h,e[1]=S):S=e[1];const R=S;let C,D;e[2]!==s||e[3]!==R||e[4]!==i?(C=()=>{b.current=i,R(i?s:0,!0)},D=[s,R,i],e[2]=s,e[3]=R,e[4]=i,e[5]=C,e[6]=D):(C=e[5],D=e[6]),c.useEffect(C,D);let A;e[7]===Symbol.for("react.memo_cache_sentinel")?(A=F=>{if(F.touches.length!==1)return;const z=F.touches[0];g.current={x:z.clientX,y:z.clientY},x.current=!1},e[7]=A):A=e[7];const j=A;let k;e[8]!==s||e[9]!==R||e[10]!==h?(k=F=>{if(!g.current)return;const z=F.touches[0],U=(z.clientX-g.current.x)*h,Q=z.clientY-g.current.y;if(!x.current){if(Math.abs(U)<8||Math.abs(U)<=Math.abs(Q))return;x.current=!0}const te=b.current?s:0;R(Math.max(0,Math.min(s,te+U)),!1)},e[8]=s,e[9]=R,e[10]=h,e[11]=k):k=e[11];const v=k;let I;e[12]!==s||e[13]!==R||e[14]!==a?(I=()=>{if(g.current=null,!x.current)return;x.current=!1;const F=y.current>s/2;R(F?s:0,!0),F!==b.current&&a(F)},e[12]=s,e[13]=R,e[14]=a,e[15]=I):I=e[15];const P=I,L=o||void 0;let _;e[16]===Symbol.for("react.memo_cache_sentinel")?(_={touchAction:"pan-y"},e[16]=_):_=e[16];let E;e[17]!==s?(E={width:s},e[17]=s,e[18]=E):E=e[18];const T=!i;let O;e[19]!==r||e[20]!==E||e[21]!==T?(O=t.jsx("div",{className:"absolute inset-y-0 inset-s-0 flex items-stretch",style:E,"aria-hidden":T,children:r}),e[19]=r,e[20]=E,e[21]=T,e[22]=O):O=e[22];let M;e[23]!==f||e[24]!==d?(M=t.jsx("div",{ref:p,className:d,children:f}),e[23]=f,e[24]=d,e[25]=M):M=e[25];let G;return e[26]!==P||e[27]!==v||e[28]!==O||e[29]!==M||e[30]!==L?(G=t.jsxs("div",{"data-active-session":L,className:"relative overflow-hidden",onTouchStart:j,onTouchMove:v,onTouchEnd:P,onTouchCancel:P,style:_,children:[O,M]}),e[26]=P,e[27]=v,e[28]=O,e[29]=M,e[30]=L,e[31]=G):G=e[31],G},Ka=n=>{const e=fe.c(62),{sessionId:s,title:r,revealed:i,confirmingDelete:a,onArchive:o,onRequestDelete:l,onConfirmDelete:f,onRequestRename:d,onRevealedChange:m,work:h,pin:p}=n,{t:g}=ve(),x=i?0:-1;let y;e[0]!==m||e[1]!==s||e[2]!==g?(y=async()=>{if(!(await Ko(s).catch(Om))?.ok){Lr.error(g("sessions.sidebar.session.copyId.error"));return}m?.(!1),Lr.success(g("sessions.sidebar.session.copyId.success"))},e[0]=m,e[1]=s,e[2]=g,e[3]=y):y=e[3];const b=y;let S;e[4]!==g||e[5]!==r?(S=g("mobile.sessions.archiveSessionAria",{title:r}),e[4]=g,e[5]=r,e[6]=S):S=e[6];let R,C;e[7]===Symbol.for("react.memo_cache_sentinel")?(R={touchAction:"manipulation"},C=t.jsx(Cd,{className:"size-[18px]"}),e[7]=R,e[8]=C):(R=e[7],C=e[8]);let D;e[9]!==o||e[10]!==S||e[11]!==x?(D=t.jsx("button",{type:"button",tabIndex:x,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":S,onClick:o,style:R,children:C}),e[9]=o,e[10]=S,e[11]=x,e[12]=D):D=e[12];let A;e[13]!==m||e[14]!==p||e[15]!==g||e[16]!==x?(A=p?t.jsx("button",{type:"button",tabIndex:x,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":p.pinned?g("sessions.sidebar.session.menu.unpin"):g("sessions.sidebar.session.menu.pin"),onClick:()=>{p.onToggle(),m?.(!1)},style:{touchAction:"manipulation"},children:t.jsx(X,{name:p.pinned?"unpin":"pushpin",className:"size-[18px]"})}):null,e[13]=m,e[14]=p,e[15]=g,e[16]=x,e[17]=A):A=e[17];let j;e[18]!==m||e[19]!==g||e[20]!==x||e[21]!==h?(j=h?t.jsx("button",{type:"button",tabIndex:x,className:ee("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",h.inWork?"text-status-success":"text-muted-foreground active:text-foreground"),"aria-label":h.inWork?g("sessions.sidebar.session.work.markDone"):g("sessions.sidebar.session.work.track"),onClick:()=>{h.onToggle(),m?.(!1)},style:{touchAction:"manipulation"},children:t.jsx(X,{name:h.inWork?"check":"eye",className:h.inWork?"size-5":"size-[18px]"})}):null,e[18]=m,e[19]=g,e[20]=x,e[21]=h,e[22]=j):j=e[22];const k=a?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80";let v;e[23]!==k?(v=ee("flex flex-1 items-center justify-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive",k),e[23]=k,e[24]=v):v=e[24];let I;e[25]!==a||e[26]!==g||e[27]!==r?(I=a?g("mobile.sessions.confirmDeleteSessionAria",{title:r}):g("mobile.sessions.deleteSessionAria",{title:r}),e[25]=a,e[26]=g,e[27]=r,e[28]=I):I=e[28];const P=a?f:l;let L,_;e[29]===Symbol.for("react.memo_cache_sentinel")?(L={touchAction:"manipulation"},_=t.jsx(Vn,{className:"size-[18px]"}),e[29]=L,e[30]=_):(L=e[29],_=e[30]);let E;e[31]!==I||e[32]!==P||e[33]!==v||e[34]!==x?(E=t.jsx("button",{type:"button",tabIndex:x,className:v,"aria-label":I,onClick:P,style:L,children:_}),e[31]=I,e[32]=P,e[33]=v,e[34]=x,e[35]=E):E=e[35];let T;e[36]!==g||e[37]!==r?(T=g("mobile.sessions.renameSessionAria",{title:r}),e[36]=g,e[37]=r,e[38]=T):T=e[38];let O,M;e[39]===Symbol.for("react.memo_cache_sentinel")?(O={touchAction:"manipulation"},M=t.jsx(ga,{className:"size-[18px]"}),e[39]=O,e[40]=M):(O=e[39],M=e[40]);let G;e[41]!==d||e[42]!==T||e[43]!==x?(G=t.jsx("button",{type:"button",tabIndex:x,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":T,onClick:d,style:O,children:M}),e[41]=d,e[42]=T,e[43]=x,e[44]=G):G=e[44];let F;e[45]!==g?(F=g("sessions.sidebar.session.menu.copyId"),e[45]=g,e[46]=F):F=e[46];let z;e[47]!==b?(z=()=>{b()},e[47]=b,e[48]=z):z=e[48];let U,Q;e[49]===Symbol.for("react.memo_cache_sentinel")?(U={touchAction:"manipulation"},Q=t.jsx(X,{name:"file-copy",className:"size-[18px]"}),e[49]=U,e[50]=Q):(U=e[49],Q=e[50]);let te;e[51]!==F||e[52]!==z||e[53]!==x?(te=t.jsx("button",{type:"button",tabIndex:x,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":F,onClick:z,style:U,children:Q}),e[51]=F,e[52]=z,e[53]=x,e[54]=te):te=e[54];let ce;return e[55]!==E||e[56]!==G||e[57]!==te||e[58]!==D||e[59]!==A||e[60]!==j?(ce=t.jsxs(t.Fragment,{children:[D,A,j,E,G,te]}),e[55]=E,e[56]=G,e[57]=te,e[58]=D,e[59]=A,e[60]=j,e[61]=ce):ce=e[61],ce};function Om(){return null}const ct=n=>n.parentID??null,xt=n=>{const e=n;return He(e.directory??e.project?.worktree??null)},qa=n=>Ho(n),nr=n=>{if(n<=0)return"";const e=Date.now()-n;if(e<6e4)return"now";const s=Math.floor(e/6e4);if(s<60)return`${s}m`;const r=Math.floor(s/60);if(r<24)return`${r}h`;const i=Math.floor(r/24);return i<7?`${i}d`:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(n))},zm=4,Ha=n=>{const e=fe.c(4),{providerIDs:s}=n;let r;e[0]!==s?(r=s.slice(0,zm).map(Bm),e[0]=s,e[1]=r):r=e[1];let i;return e[2]!==r?(i=t.jsx("span",{className:"inline-flex shrink-0 items-center -space-x-1",children:r}),e[2]=r,e[3]=i):i=e[3],i};function Bm(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(qo,{providerId:n,className:"size-3 opacity-80"})},n)}const Ur=n=>{const e=fe.c(8),{session:s}=n,{t:r}=ve(),i=Vl(s);if(!i)return null;const a=Ul[i.status];let o;e[0]!==r||e[1]!==a?(o=r(a),e[0]=r,e[1]=a,e[2]=o):o=e[2];const l=o,f=Gl[i.status];let d;e[3]!==f?(d={color:f},e[3]=f,e[4]=d):d=e[4];let m;return e[5]!==l||e[6]!==d?(m=t.jsx(X,{name:"target",className:"size-3.5 shrink-0",style:d,"aria-label":l}),e[5]=l,e[6]=d,e[7]=m):m=e[7],m},Gr=n=>{const e=fe.c(9),{hasPermission:s,hasForm:r}=n,{t:i}=ve();if(!s&&!r)return null;let a;e[0]!==s||e[1]!==i?(a=s?t.jsx("span",{className:"inline-flex shrink-0 items-center rounded bg-destructive/10 px-1 py-0.5 text-destructive","aria-label":i("sessions.sidebar.session.status.permissionRequired"),children:t.jsx(X,{name:"shield",className:"size-3"})}):null,e[0]=s,e[1]=i,e[2]=a):a=e[2];let o;e[3]!==r||e[4]!==i?(o=r?t.jsx("span",{className:"inline-flex shrink-0 items-center rounded bg-status-info/10 px-1 py-0.5 text-status-info","aria-label":i("sessions.sidebar.session.status.questionPending"),children:t.jsx(X,{name:"question",className:"size-3"})}):null,e[3]=r,e[4]=i,e[5]=o):o=e[5];let l;return e[6]!==a||e[7]!==o?(l=t.jsxs(t.Fragment,{children:[a,o]}),e[6]=a,e[7]=o,e[8]=l):l=e[8],l},Ja=n=>{const e=fe.c(7);let s;e[0]!==n?(s=l=>n.some(f=>!!l.bySession.get(f)?.permissions.length),e[0]=n,e[1]=s):s=e[1];const r=Vi(s);let i;e[2]!==n?(i=l=>n.some(f=>!!l.bySession.get(f)?.forms.length),e[2]=n,e[3]=i):i=e[3];const a=Vi(i);let o;return e[4]!==a||e[5]!==r?(o={hasPermission:r,hasForm:a},e[4]=a,e[5]=r,e[6]=o):o=e[6],o},hn=12,Xa="flex min-w-0 flex-1 flex-col gap-1 py-2.5 pe-3 text-start",Ya="flex h-4 min-w-0 items-center gap-1.5 text-muted-foreground",Qa="flex min-w-0 flex-1 flex-col justify-center py-2.5 pe-3 text-start",Za=n=>{const e=fe.c(5),{project:s}=n;let r;e[0]!==s?(r=t.jsx(Xn,{project:s,size:"xs"}),e[0]=s,e[1]=r):r=e[1];let i;return e[2]!==s.label||e[3]!==r?(i=t.jsx("span",{role:"img","aria-label":s.label,className:"inline-flex shrink-0",children:r}),e[2]=s.label,e[3]=r,e[4]=i):i=e[4],i},Lm=n=>{const e=fe.c(46),{entry:s,showProject:r,compact:i}=n,{t:a}=ve(),{run:o,project:l}=s;let f;e[0]!==o.key?(f=M=>M.runOverviewKey===o.key,e[0]=o.key,e[1]=f):f=e[1];const d=Ve(f);let m;e[2]!==s.laneNodes?(m={nodes:s.laneNodes,includeUnreadSubtasks:!1},e[2]=s.laneNodes,e[3]=m):m=e[3];const h=da(m);let p;e[4]!==o.lastActivity?(p=nr(o.lastActivity),e[4]=o.lastActivity,e[5]=p):p=e[5];const g=p,x=o.lanes.length,y=d||void 0,b=d&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let S;e[6]!==b?(S=ee("relative bg-background transition-colors",b),e[6]=b,e[7]=S):S=e[7];const R=i?Qa:Xa;let C;e[8]!==R?(C=ee(R,"w-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"),e[8]=R,e[9]=C):C=e[9];let D;e[10]===Symbol.for("react.memo_cache_sentinel")?(D={paddingInlineStart:hn,touchAction:"manipulation"},e[10]=D):D=e[10];let A;e[11]!==o.key?(A=()=>Ve.getState().setRunOverviewKey(o.key),e[11]=o.key,e[12]=A):A=e[12];let j;e[13]!==o.title||e[14]!==a?(j=a("sessions.sidebar.run.openOverviewAria",{title:o.title}),e[13]=o.title,e[14]=a,e[15]=j):j=e[15];const k=d?"text-primary":"text-foreground";let v;e[16]!==k?(v=ee("block min-w-0 flex-1 truncate oc-ui-start-align typography-ui-label",k),e[16]=k,e[17]=v):v=e[17];let I;e[18]!==o.title||e[19]!==v?(I=t.jsx("span",{dir:"auto",className:v,children:o.title}),e[18]=o.title,e[19]=v,e[20]=I):I=e[20];let P;e[21]!==h?(P=h?t.jsx(ma,{state:h}):null,e[21]=h,e[22]=P):P=e[22];let L;e[23]!==g?(L=g?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:g}):null,e[23]=g,e[24]=L):L=e[24];let _;e[25]!==I||e[26]!==P||e[27]!==L?(_=t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[I,P,L]}),e[25]=I,e[26]=P,e[27]=L,e[28]=_):_=e[28];let E;e[29]!==i||e[30]!==x||e[31]!==l||e[32]!==o.providerIDs||e[33]!==r||e[34]!==a?(E=i?null:t.jsxs("span",{className:Ya,children:[r?t.jsx(Za,{project:l}):null,t.jsx(sa,{className:"size-3.5 shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-micro",children:x===1?a("sessions.sidebar.run.laneCountSingle",{count:x}):a("sessions.sidebar.run.laneCountPlural",{count:x})}),t.jsx(Ha,{providerIDs:o.providerIDs})]}),e[29]=i,e[30]=x,e[31]=l,e[32]=o.providerIDs,e[33]=r,e[34]=a,e[35]=E):E=e[35];let T;e[36]!==A||e[37]!==j||e[38]!==_||e[39]!==E||e[40]!==C?(T=t.jsxs("button",{type:"button",className:C,style:D,onClick:A,"aria-label":j,children:[_,E]}),e[36]=A,e[37]=j,e[38]=_,e[39]=E,e[40]=C,e[41]=T):T=e[41];let O;return e[42]!==T||e[43]!==y||e[44]!==S?(O=t.jsx("div",{"data-active-session":y,className:S,children:T}),e[42]=T,e[43]=y,e[44]=S,e[45]=O):O=e[45],O},Fm=n=>{const e=fe.c(119),{entry:s,showProject:r,compact:i,active:a,revealed:o,confirmingDelete:l,renaming:f,handlers:d}=n,{t:m}=ve(),{session:h,project:p,branch:g,inSpace:x}=s;let y;e[0]!==h.title||e[1]!==m?(y=h.title?.trim()||m("mobile.sessions.untitled"),e[0]=h.title,e[1]=m,e[2]=y):y=e[2];const b=y;let S;e[3]!==h?(S=nr(qa(h)),e[3]=h,e[4]=S):S=e[4];const R=S,C=fa(h.id,h.directory,o||f),D=Jr(h.id),A=Xr(h.id),j=A!==null,k=!j&&D>0&&!a,v=Yr(h.id,j),I=(j||k)&&v,P=d.onToggleWork;let L;e[5]!==h?(L=na(h),e[5]=h,e[6]=L):L=e[6];const _=L;let E;e[7]!==_||e[8]!==P||e[9]!==h?(E=P?{inWork:_,onToggle:()=>P(h,_)}:void 0,e[7]=_,e[8]=P,e[9]=h,e[10]=E):E=e[10];const T=E;let O;e[11]!==d||e[12]!==h?(O=d.isPinned(h),e[11]=d,e[12]=h,e[13]=O):O=e[13];const M=O;let G;e[14]!==d||e[15]!==h?(G=()=>d.onTogglePin(h),e[14]=d,e[15]=h,e[16]=G):G=e[16];let F;e[17]!==M||e[18]!==G?(F={pinned:M,onToggle:G},e[17]=M,e[18]=G,e[19]=F):F=e[19];const z=F,{descendantIdsOf:U}=d;let Q;e[20]!==U||e[21]!==h.id?(Q=[h.id,...U(h.id)],e[20]=U,e[21]=h.id,e[22]=Q):Q=e[22];const ce=Ja(Q),re=Ga+pn+(T?pn:0);let Y;e[23]!==d||e[24]!==h.id?(Y=xe=>d.onRevealedChange(h.id,xe),e[23]=d,e[24]=h.id,e[25]=Y):Y=e[25];const ye=a&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let Z;e[26]!==ye?(Z=ee("relative flex w-full items-center bg-background transition-colors",ye),e[26]=ye,e[27]=Z):Z=e[27];let N;e[28]!==d||e[29]!==h?(N=()=>d.onArchive(h),e[28]=d,e[29]=h,e[30]=N):N=e[30];let $;e[31]!==d||e[32]!==h.id?($=()=>d.onRequestDelete(h.id),e[31]=d,e[32]=h.id,e[33]=$):$=e[33];let J;e[34]!==d||e[35]!==h?(J=()=>d.onConfirmDelete(h),e[34]=d,e[35]=h,e[36]=J):J=e[36];let ae,ie;e[37]!==d||e[38]!==h.id?(ae=()=>d.onRequestRename(h.id),ie=xe=>d.onRevealedChange(h.id,xe),e[37]=d,e[38]=h.id,e[39]=ae,e[40]=ie):(ae=e[39],ie=e[40]);let q;e[41]!==l||e[42]!==z||e[43]!==o||e[44]!==h.id||e[45]!==N||e[46]!==$||e[47]!==J||e[48]!==ae||e[49]!==ie||e[50]!==b||e[51]!==T?(q=t.jsx(Ka,{sessionId:h.id,title:b,revealed:o,confirmingDelete:l,onArchive:N,onRequestDelete:$,onConfirmDelete:J,onRequestRename:ae,onRevealedChange:ie,work:T,pin:z}),e[41]=l,e[42]=z,e[43]=o,e[44]=h.id,e[45]=N,e[46]=$,e[47]=J,e[48]=ae,e[49]=ie,e[50]=b,e[51]=T,e[52]=q):q=e[52];let se;e:{let xe;e[53]!==i||e[54]!==ce||e[55]!==h?(xe=i?t.jsxs(t.Fragment,{children:[t.jsx(Ur,{session:h}),t.jsx(Gr,{...ce})]}):null,e[53]=i,e[54]=ce,e[55]=h,e[56]=xe):xe=e[56];let we;e[57]!==M||e[58]!==m?(we=M?t.jsx(X,{name:"pushpin",className:"size-3 shrink-0 text-muted-foreground","aria-label":m("sessions.sidebar.session.status.pinned")}):null,e[57]=M,e[58]=m,e[59]=we):we=e[59];let me;e[60]!==C.pending||e[61]!==j||e[62]!==k||e[63]!==m||e[64]!==A?(me=C.pending?t.jsx(X,{name:"loader-4",className:"size-3 shrink-0 animate-spin text-primary","aria-label":m("sessions.aiRename.generating")}):j||k?t.jsx(Wn,{state:A??"unread"}):null,e[60]=C.pending,e[61]=j,e[62]=k,e[63]=m,e[64]=A,e[65]=me):me=e[65];let Re;e[66]!==j||e[67]!==h.id||e[68]!==I||e[69]!==R?(Re=I?t.jsx(Qr,{sessionId:h.id,running:j,className:"shrink-0 typography-micro"}):R?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:R}):null,e[66]=j,e[67]=h.id,e[68]=I,e[69]=R,e[70]=Re):Re=e[70];let Ae;e[71]!==xe||e[72]!==we||e[73]!==me||e[74]!==Re?(Ae=t.jsxs(t.Fragment,{children:[xe,we,me,Re]}),e[71]=xe,e[72]=we,e[73]=me,e[74]=Re,e[75]=Ae):Ae=e[75];const Te=Ae;let Se;e[76]!==a||e[77]!==C||e[78]!==d||e[79]!==f||e[80]!==h.id||e[81]!==Te||e[82]!==b?(Se=f?t.jsx(Ua,{initialTitle:b,indent:0,aiRename:C,className:"h-[1lh] pe-0 typography-ui-label [&_button]:size-6 [&_button>svg]:size-3.5",onSubmit:Le=>d.onSubmitRename(h.id,Le),onCancel:d.onCancelRename}):t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{dir:"auto",className:ee("block min-w-0 flex-1 truncate oc-ui-start-align typography-ui-label",a?"text-primary":"text-foreground"),children:b}),Te]}),e[76]=a,e[77]=C,e[78]=d,e[79]=f,e[80]=h.id,e[81]=Te,e[82]=b,e[83]=Se):Se=e[83];let Ce;e[84]!==g||e[85]!==i||e[86]!==x||e[87]!==ce||e[88]!==p||e[89]!==h||e[90]!==r||e[91]!==m?(Ce=i?null:t.jsxs("span",{className:Ya,children:[r?t.jsx(Za,{project:p}):null,g?t.jsxs(t.Fragment,{children:[x?t.jsx(X,{name:"box-3",className:"size-3.5 shrink-0","aria-hidden":!1,role:"img","aria-label":m("sessions.sidebar.group.space")}):t.jsx(X,{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:"ms-auto flex shrink-0 items-center gap-1.5",children:[t.jsx(Ur,{session:h}),t.jsx(Gr,{...ce})]})]}),e[84]=g,e[85]=i,e[86]=x,e[87]=ce,e[88]=p,e[89]=h,e[90]=r,e[91]=m,e[92]=Ce):Ce=e[92];let K;e[93]!==Se||e[94]!==Ce?(K=t.jsxs(t.Fragment,{children:[Se,Ce]}),e[93]=Se,e[94]=Ce,e[95]=K):K=e[95];const ge=K,ne=i?Qa:Xa;if(f){let Le;e[96]===Symbol.for("react.memo_cache_sentinel")?(Le={paddingInlineStart:hn},e[96]=Le):Le=e[96];let Xe;e[97]!==ne||e[98]!==ge?(Xe=t.jsx("div",{className:ne,style:Le,children:ge}),e[97]=ne,e[98]=ge,e[99]=Xe):Xe=e[99],se=Xe;break e}let he;e[100]!==ne?(he=ee(ne,"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"),e[100]=ne,e[101]=he):he=e[101];let be;e[102]===Symbol.for("react.memo_cache_sentinel")?(be={paddingInlineStart:hn,touchAction:"manipulation"},e[102]=be):be=e[102];let De;e[103]!==d||e[104]!==o||e[105]!==h?(De=()=>{if(o){d.onRevealedChange(h.id,!1);return}d.onSelect(h)},e[103]=d,e[104]=o,e[105]=h,e[106]=De):De=e[106];let Oe;e[107]!==ge||e[108]!==he||e[109]!==De?(Oe=t.jsx("button",{type:"button",className:he,style:be,onClick:De,children:ge}),e[107]=ge,e[108]=he,e[109]=De,e[110]=Oe):Oe=e[110],se=Oe}let ke;return e[111]!==a||e[112]!==o||e[113]!==Y||e[114]!==Z||e[115]!==q||e[116]!==se||e[117]!==re?(ke=t.jsx(Yn,{actionsWidth:re,revealed:o,onRevealedChange:Y,dataActiveSession:a,contentClassName:Z,actions:q,children:se}),e[111]=a,e[112]=o,e[113]=Y,e[114]=Z,e[115]=q,e[116]=se,e[117]=re,e[118]=ke):ke=e[118],ke},bo=n=>{const e=fe.c(11),{entries:s,showProject:r,compact:i,handlers:a}=n,o=i===void 0?!1:i;let l;if(e[0]!==o||e[1]!==s||e[2]!==a||e[3]!==r){let d;e[5]!==o||e[6]!==a||e[7]!==r?(d=m=>m.kind==="run"?t.jsx(Lm,{entry:m,showProject:r,compact:o},`run:${m.run.key}`):t.jsx(Fm,{entry:m,showProject:r,compact:o,active:a.currentSessionId===m.session.id,revealed:a.revealedSessionId===m.session.id,confirmingDelete:a.confirmingDeleteSessionId===m.session.id,renaming:a.renamingSessionId===m.session.id,handlers:a},m.session.id),e[5]=o,e[6]=a,e[7]=r,e[8]=d):d=e[8],l=s.map(d),e[0]=o,e[1]=s,e[2]=a,e[3]=r,e[4]=l}else l=e[4];let f;return e[9]!==l?(f=t.jsx(t.Fragment,{children:l}),e[9]=l,e[10]=f):f=e[10],f},xo="mobile-surface-root",Rr=16,zn=200,$m=()=>{if(typeof document>"u")return null;let n=document.getElementById(xo);return n||(n=document.createElement("div"),n.id=xo,document.body.appendChild(n)),n},Pt=({open:n,onClose:e,title:s,subtitle:r,trailing:i,disableEscapeDismiss:a=!1,headerless:o=!1,noHeaderBorder:l=!1,ariaLabel:f,variant:d="fullscreen",dialogAlign:m="chat",children:h})=>{const{t:p,direction:g}=ve(),x=c.useRef(null),[y,b]=c.useState(!1),[S,R]=c.useState(!1),C=c.useRef(null),D=c.useRef(null),A=c.useRef(e);if(c.useEffect(()=>{A.current=e},[e]),typeof document<"u"&&!x.current&&(x.current=$m()),c.useEffect(()=>{if(!n){b(!1);return}const v=window.setTimeout(()=>b(!0),Rr);return()=>window.clearTimeout(v)},[n]),c.useEffect(()=>{if(!n){R(!1);return}const v=window.setTimeout(()=>R(!0),Rr+zn+80);return()=>window.clearTimeout(v)},[n]),c.useEffect(()=>{if(!n)return;const v=document.body.style.overflow;D.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow="hidden";const I=()=>{const _=C.current;if(!_)return;(_.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??_).focus({preventScroll:!0})},P=window.setTimeout(I,Rr),L=_=>{if(_.key==="Escape"&&!a){A.current();return}if(_.key!=="Tab")return;const E=C.current;if(!E)return;const T=Array.from(E.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(F=>!F.hasAttribute("disabled")&&F.getAttribute("aria-hidden")!=="true");if(T.length===0){_.preventDefault(),E.focus({preventScroll:!0});return}const O=T[0],M=T[T.length-1],G=document.activeElement;_.shiftKey&&G===O?(_.preventDefault(),M.focus({preventScroll:!0})):!_.shiftKey&&G===M&&(_.preventDefault(),O.focus({preventScroll:!0}))};return document.addEventListener("keydown",L),()=>{window.clearTimeout(P),document.body.style.overflow=v,document.removeEventListener("keydown",L),D.current?.focus?.({preventScroll:!0}),D.current=null}},[a,n]),!n||!x.current)return null;const j=d==="dialog",k=t.jsxs("section",{ref:C,role:"dialog","aria-modal":"true","aria-label":f,tabIndex:-1,className:ee("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:y?1:0,transform:y?"none":"scale(0.97)",transition:`opacity ${zn}ms ease-out, transform ${zn}ms cubic-bezier(0.32, 0.72, 0, 1)`}:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:y?"none":g==="rtl"?"translateX(-100%)":"translateX(100%)",transition:`transform ${zn}ms cubic-bezier(0.32, 0.72, 0, 1)`},onTransitionEnd:v=>{y&&v.target===v.currentTarget&&v.propertyName==="transform"&&R(!0)},children:[o?null:t.jsxs("header",{className:ee("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",!l&&"border-b border-border/70"),children:[t.jsx("button",{type:"button",className:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":p("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(X,{name:"close",className:"size-5"})}),t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[s?typeof s=="string"?t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:s}):s:null,r?typeof r=="string"?t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:r}):r:null]}),i?t.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:i}):null]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:S?t.jsx("div",{className:"h-full",style:{animation:"oc-surface-content-in 200ms ease-out"},children:h}):null}),t.jsx("style",{children:"@keyframes oc-surface-content-in { from { opacity: 0 } to { opacity: 1 } }"})]});return j?Ds.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:y?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:v=>v.stopPropagation(),children:k})}),x.current):Ds.createPortal(k,x.current)},Wm=n=>{const e=fe.c(8),{projectPath:s}=n,{t:r}=ve(),{journey:i}=pl();let a;if(e[0]!==i||e[1]!==s||e[2]!==r){const o=i?hl(i,s):[];let l;e[4]!==r?(l=r("mobile.projectEdit.spacesTitle"),e[4]=r,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],a=t.jsxs("div",{className:"flex flex-col gap-2",children:[f,i!==null&&o.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:r("spaces.page.empty")}):null,o.map(Km)]}),e[0]=i,e[1]=s,e[2]=r,e[3]=a}else a=e[3];return a},Vm=n=>bn(n)??"",Um=n=>{const e=fe.c(38),{worktree:s,onDelete:r}=n,{t:i}=ve();let a;e[0]!==s.path?(a={id:s.path},e[0]=s.path,e[1]=a):a=e[1];const{attributes:o,listeners:l,setNodeRef:f,transform:d,transition:m,isDragging:h}=ui(a);let p;e[2]!==d?(p=fi.Transform.toString(d),e[2]=d,e[3]=p):p=e[3];const g=h?10:1;let x;e[4]!==p||e[5]!==g||e[6]!==m?(x={transform:p,transition:m,zIndex:g},e[4]=p,e[5]=g,e[6]=m,e[7]=x):x=e[7];const y=x,b=s.branch||s.label||s.path,S=ia(s.path),R=h&&"shadow-lg shadow-black/20",C=S&&"opacity-60";let D;e[8]!==R||e[9]!==C?(D=ee("flex items-center gap-1 rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",R,C),e[8]=R,e[9]=C,e[10]=D):D=e[10];const A=S||void 0;let j;e[11]!==b||e[12]!==i?(j=i("mobile.projectEdit.dragWorktreeAria",{label:b}),e[11]=b,e[12]=i,e[13]=j):j=e[13];let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx(ti,{className:"size-4"}),e[14]=k):k=e[14];let v;e[15]!==o||e[16]!==l||e[17]!==j?(v=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":j,...o,...l,children:k}),e[15]=o,e[16]=l,e[17]=j,e[18]=v):v=e[18];let I;e[19]!==S||e[20]!==i?(I=S?t.jsx("span",{className:"inline-flex shrink-0 text-muted-foreground",role:"status","aria-label":i("sessions.sidebar.group.worktreeRemoving"),children:t.jsx(X,{name:"loader-4",className:"size-4 animate-spin"})}):t.jsx(X,{name:"node-tree",className:"size-4 shrink-0 text-muted-foreground"}),e[19]=S,e[20]=i,e[21]=I):I=e[21];let P;e[22]!==b?(P=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:b}),e[22]=b,e[23]=P):P=e[23];let L;e[24]!==b||e[25]!==r||e[26]!==S||e[27]!==i?(L=S?null:t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive","aria-label":i("mobile.projectEdit.deleteWorktreeAria",{label:b}),onClick:r,style:{touchAction:"manipulation"},children:t.jsx(Vn,{className:"size-4"})}),e[24]=b,e[25]=r,e[26]=S,e[27]=i,e[28]=L):L=e[28];let _;return e[29]!==f||e[30]!==y||e[31]!==v||e[32]!==I||e[33]!==P||e[34]!==L||e[35]!==D||e[36]!==A?(_=t.jsxs("div",{ref:f,style:y,className:D,"aria-busy":A,children:[v,I,P,L]}),e[29]=f,e[30]=y,e[31]=v,e[32]=I,e[33]=P,e[34]=L,e[35]=D,e[36]=A,e[37]=_):_=e[37],_},Gm=n=>{const e=fe.c(87),{open:s,project:r,onClose:i,onWorktreesChanged:a}=n,{t:o}=ve(),{currentTheme:l}=Qo(),f=Ve(qm),d=it(Hm),m=it(Jm),h=it(Xm),p=Vr(Ym);let g;e[0]!==r?(g=ne=>r?ne.projects.find(he=>he.id===r.id)?.iconImage??null:null,e[0]=r,e[1]=g):g=e[1];const x=it(g),[y,b]=c.useState(""),[S,R]=c.useState(null),[C,D]=c.useState(null),[A,j]=c.useState(!1);let k;e[2]===Symbol.for("react.memo_cache_sentinel")?(k=[],e[2]=k):k=e[2];const[v,I]=c.useState(k),[P,L]=c.useState(null),_=r?.id??null;let E;e[3]!==s||e[4]!==r?(E=()=>{!s||!r||(b(r.label),R(r.icon??null),D(r.color??null),I(r.worktrees))},e[3]=s,e[4]=r,e[5]=E):E=e[5];let T;e[6]!==s||e[7]!==_?(T=[s,_],e[6]=s,e[7]=_,e[8]=T):T=e[8],c.useEffect(E,T);let O;e[9]!==s||e[10]!==r?(O=()=>{!s||!r||I(ne=>{const he=r.worktrees.map(Qm),be=ne.map(Zm);return he.length===be.length&&he.every(Oe=>be.includes(Oe))?ne:r.worktrees})},e[9]=s,e[10]=r,e[11]=O):O=e[11];const M=r?.worktrees;let G;e[12]!==M?(G=[M],e[12]=M,e[13]=G):G=e[13],c.useEffect(O,G);let F;e[14]===Symbol.for("react.memo_cache_sentinel")?(F={activationConstraint:{distance:8}},e[14]=F):F=e[14];let z;e[15]===Symbol.for("react.memo_cache_sentinel")?(z={coordinateGetter:di},e[15]=z):z=e[15];const U=ni(_s(ii,F),_s(ri,z));let Q;e[16]!==C||e[17]!==S||e[18]!==y||e[19]!==i||e[20]!==r||e[21]!==d?(Q=()=>{if(!r)return;const he={label:y.trim()||r.label,icon:S,color:C};C!==(r.color??null)&&(he.iconBackground=Hl(C)),d(r.id,he),i()},e[16]=C,e[17]=S,e[18]=y,e[19]=i,e[20]=r,e[21]=d,e[22]=Q):Q=e[22];const te=Q;let ce;e[23]!==m||e[24]!==A||e[25]!==r||e[26]!==o?(ce=()=>{!r||A||(j(!0),m(r.id).then(ne=>{if(!ne.ok){de.error(ne.error||o("projectEditDialog.toast.failedToDiscoverIcon"));return}if(ne.skipped){de.success(o("projectEditDialog.toast.customIconAlreadySet"));return}de.success(o("projectEditDialog.toast.iconDiscovered"))}).finally(()=>j(!1)))},e[23]=m,e[24]=A,e[25]=r,e[26]=o,e[27]=ce):ce=e[27];const re=ce;let Y;e[28]!==r||e[29]!==h||e[30]!==o?(Y=()=>{r&&h(r.id).then(ne=>{if(!ne.ok){de.error(ne.error||o("projectEditDialog.toast.failedToRemoveIcon"));return}de.success(o("projectEditDialog.toast.iconRemoved"))})},e[28]=r,e[29]=h,e[30]=o,e[31]=Y):Y=e[31];const ye=Y;let Z;e[32]!==v||e[33]!==r||e[34]!==p?(Z=ne=>{const{active:he,over:be}=ne;if(!be||he.id===be.id||!r)return;const De=v.findIndex(Ft=>Ft.path===he.id),Oe=v.findIndex(Ft=>Ft.path===be.id);if(De<0||Oe<0)return;const Le=[...v],[Xe]=Le.splice(De,1);Le.splice(Oe,0,Xe),I(Le),p(r.id,Le.map(ep))},e[32]=v,e[33]=r,e[34]=p,e[35]=Z):Z=e[35];const N=Z;let $;e[36]!==C?($=ea(C),e[36]=C,e[37]=$):$=e[37];const J=$,ae=S?Zo[S]:null,ie=!!x;let q;e[38]!==o?(q=o("projectEditDialog.title"),e[38]=o,e[39]=q):q=e[39];let se;e[40]!==o?(se=o("projectEditDialog.title"),e[40]=o,e[41]=se):se=e[41];let ke;e[42]!==o?(ke=o("projectEditDialog.actions.save"),e[42]=o,e[43]=ke):ke=e[43];let xe;e[44]!==y?(xe=y.trim(),e[44]=y,e[45]=xe):xe=e[45];const we=!xe;let me,Re;e[46]===Symbol.for("react.memo_cache_sentinel")?(me={touchAction:"manipulation"},Re=t.jsx(ba,{className:"size-4"}),e[46]=me,e[47]=Re):(me=e[46],Re=e[47]);let Ae;e[48]!==o?(Ae=o("projectEditDialog.actions.save"),e[48]=o,e[49]=Ae):Ae=e[49];let Te;e[50]!==te||e[51]!==ke||e[52]!==we||e[53]!==Ae?(Te=t.jsxs(Ee,{type:"button",variant:"default",size:"sm","aria-label":ke,onClick:te,disabled:we,style:me,children:[Re,Ae]}),e[50]=te,e[51]=ke,e[52]=we,e[53]=Ae,e[54]=Te):Te=e[54];let Se;e[55]!==C||e[56]!==J||e[57]!==x||e[58]!==l||e[59]!==U||e[60]!==re||e[61]!==ye||e[62]!==N||e[63]!==ie||e[64]!==S||e[65]!==A||e[66]!==f||e[67]!==y||e[68]!==v||e[69]!==ae||e[70]!==r||e[71]!==o?(Se=r?t.jsxs("div",{className:"h-full space-y-6 overflow-y-auto px-4 pb-8 pt-2",children:[t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx("span",{className:"flex size-16 items-center justify-center overflow-hidden rounded-2xl bg-[var(--surface-muted)] text-muted-foreground",style:r.iconBackground?{backgroundColor:r.iconBackground}:void 0,children:ie?t.jsx(ta,{project:{id:r.id,iconImage:x},options:{themeVariant:l.metadata.variant,iconColor:l.colors.surface.foreground},className:"size-full object-contain",fallback:t.jsx(Br,{className:"size-7"})}):ae?t.jsx(X,{name:ae,className:"size-7",style:J?{color:J}:void 0}):t.jsx(Br,{className:"size-7",style:J?{color:J}:void 0})})}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:o("projectEditDialog.field.name")}),t.jsx(ra,{value:y,onChange:ne=>b(ne.target.value),placeholder:o("projectEditDialog.field.namePlaceholder"),className:"h-11"}),t.jsx("p",{className:"truncate typography-meta text-muted-foreground",title:r.path,children:r.path})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:o("projectEditDialog.field.color")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>D(null),"aria-label":o("projectEditDialog.option.none"),className:ee("flex size-9 items-center justify-center rounded-xl border-2 transition-all",C===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"})}),Kl.map(ne=>t.jsx("button",{type:"button",onClick:()=>D(ne),"aria-label":o("settings.projects.appearance.colorSwatchAria",{color:ne}),title:ne,className:ee("size-9 rounded-xl border-2 transition-all",C===ne?"border-foreground":"border-transparent hover:border-border/70"),style:{backgroundColor:ne,touchAction:"manipulation"}},ne))]})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:o("projectEditDialog.field.icon")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>R(null),"aria-label":o("projectEditDialog.option.none"),className:ee("flex size-9 items-center justify-center rounded-xl border-2 transition-all",S===null?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx("span",{className:"h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40"})}),ql.map(ne=>t.jsx("button",{type:"button",onClick:()=>R(ne.key),"aria-label":ne.label,title:ne.label,className:ee("flex size-9 items-center justify-center rounded-xl border-2 transition-all",S===ne.key?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx(X,{name:ne.Icon,className:"size-4",style:J?{color:J}:void 0})},ne.key))]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[t.jsx(Ee,{size:"sm",variant:"outline",onClick:re,disabled:A,children:o(A?"projectEditDialog.actions.discovering":"projectEditDialog.actions.discoverFavicon")}),ie?t.jsx(Ee,{size:"sm",variant:"outline",onClick:ye,children:o("projectEditDialog.actions.removeProjectIcon")}):null]})]}),r.isGitRepo?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:o("mobile.projectEdit.worktreesTitle")}),v.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("mobile.projectEdit.worktreesEmpty")}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("mobile.projectEdit.reorderHint")}),t.jsx(oi,{sensors:U,collisionDetection:ai,onDragEnd:N,children:t.jsx(li,{items:v.map(tp),strategy:ci,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:v.map(ne=>t.jsx(Um,{worktree:ne,onDelete:()=>L(ne)},ne.path))})})})]})]}):null,r.isGitRepo&&f?t.jsx(Wm,{projectPath:r.path}):null]}):null,e[55]=C,e[56]=J,e[57]=x,e[58]=l,e[59]=U,e[60]=re,e[61]=ye,e[62]=N,e[63]=ie,e[64]=S,e[65]=A,e[66]=f,e[67]=y,e[68]=v,e[69]=ae,e[70]=r,e[71]=o,e[72]=Se):Se=e[72];let Ce;e[73]!==i||e[74]!==s||e[75]!==q||e[76]!==se||e[77]!==Te||e[78]!==Se?(Ce=t.jsx(Pt,{open:s,onClose:i,title:q,ariaLabel:se,noHeaderBorder:!0,trailing:Te,children:Se}),e[73]=i,e[74]=s,e[75]=q,e[76]=se,e[77]=Te,e[78]=Se,e[79]=Ce):Ce=e[79];let K;e[80]!==a||e[81]!==r||e[82]!==P?(K=r?t.jsx(Va,{open:!!P,project:{id:r.id,path:r.path},worktree:P,onClose:()=>L(null),onDeleted:()=>{I(ne=>ne.filter(he=>he.path!==P?.path)),a?.()}}):null,e[80]=a,e[81]=r,e[82]=P,e[83]=K):K=e[83];let ge;return e[84]!==Ce||e[85]!==K?(ge=t.jsxs(t.Fragment,{children:[Ce,K]}),e[84]=Ce,e[85]=K,e[86]=ge):ge=e[86],ge};function Km(n){return t.jsx(zd,{entry:n,actions:"sheet"},n.id)}function qm(n){return n.isolatedSpacesEnabled}function Hm(n){return n.updateProjectMeta}function Jm(n){return n.discoverProjectIcon}function Xm(n){return n.removeProjectIcon}function Ym(n){return n.setWorktreeOrder}function Qm(n){return n.path}function Zm(n){return n.path}function ep(n){return Vm(n.path)}function tp(n){return n.path}const sp=32,np=80,rp=64,ip=.7,op=140,ap=.4,lp=(n,e,s)=>{const r=e.ownerDocument.defaultView;if(!r)return"drawer";let i=!1;for(let a=n instanceof r.Element?n:null;a&&a!==e;a=a.parentElement){const o=a.scrollWidth-a.clientWidth;if(o<=1)continue;const l=r.getComputedStyle(a);if(l.overflowX!=="auto"&&l.overflowX!=="scroll")continue;const f=l.direction==="rtl"?-o:0,d=f+o;if(s?a.scrollLeft>f+1:a.scrollLeft<d-1)return"content";i=!0}return i?"content-end":"drawer"},ki=(n,e)=>{const s=c.useRef(e);s.current=e;const r=e.enabled??!0;c.useEffect(()=>{if(!r)return;const i=n.current;if(!i)return;const o=window.Capacitor?.getPlatform?.()==="android"?np:sp,l=i.ownerDocument;let f=!1,d=!1,m="drawer",h=0,p=0;const g=()=>l.getSelection()?.isCollapsed===!1,x=()=>{f=!1},y=()=>{f&&g()&&x()},b=R=>{if(R.touches.length!==1||g()){f=!1;return}const C=R.touches[0],D=i.clientWidth,A=C.clientX<=o,j=C.clientX>=D-o;d=A,m=A||j?lp(R.target,i,d):"drawer",f=(A||j)&&m!=="content",h=C.clientX,p=C.clientY},S=R=>{if(!f||(f=!1,g()))return;const C=R.changedTouches[0];if(!C)return;const D=C.clientX-h,A=C.clientY-p,j=m==="content-end"?op:rp,k=m==="content-end"?ap:ip;Math.abs(D)<j||Math.abs(A)>Math.abs(D)*k||d&&D<=0||!d&&D>=0||(d?s.current.onLeftEdgeSwipe?.():s.current.onRightEdgeSwipe?.())};return i.addEventListener("touchstart",b,{passive:!0}),i.addEventListener("touchend",S,{passive:!0}),i.addEventListener("touchcancel",x,{passive:!0}),i.addEventListener("selectstart",x),l.addEventListener("selectionchange",y),()=>{i.removeEventListener("touchstart",b),i.removeEventListener("touchend",S),i.removeEventListener("touchcancel",x),i.removeEventListener("selectstart",x),l.removeEventListener("selectionchange",y)}},[r,n])},cp=()=>globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0;function Bn(n){const e=fe.c(11),{open:s,children:r}=n,[i,a]=c.useState(s);s&&!i&&a(!0);const o=c.useRef(null),l=c.useRef(null),f=c.useRef(s);let d,m;e[0]!==s?(d=()=>{const S=o.current;if(f.current===s||!S)return;if(f.current=s,cp()){s||a(!1);return}const R=l.current||!s?S.getBoundingClientRect().height:0;l.current?.cancel();const C=s?S.scrollHeight:0;S.style.overflow="hidden";const D=S.animate([{height:`${R}px`,opacity:s?0:1},{height:`${C}px`,opacity:s?1:0}],{duration:wu,easing:vu,fill:s?"none":"forwards"});l.current=D,D.finished.then(()=>{l.current===D&&(l.current=null,s?S.style.overflow="":a(!1))},up)},m=[s],e[0]=s,e[1]=d,e[2]=m):(d=e[1],m=e[2]),c.useLayoutEffect(d,m);let h,p;if(e[3]===Symbol.for("react.memo_cache_sentinel")?(h=()=>()=>l.current?.cancel(),p=[],e[3]=h,e[4]=p):(h=e[3],p=e[4]),c.useEffect(h,p),!i)return null;const g=!s||void 0,x=!s;let y;e[5]!==r?(y=r(),e[5]=r,e[6]=y):y=e[6];let b;return e[7]!==g||e[8]!==x||e[9]!==y?(b=t.jsx("div",{ref:o,"aria-hidden":g,inert:x,children:y}),e[7]=g,e[8]=x,e[9]=y,e[10]=b):b=e[10],b}function up(){}const dp=new Set,fp=[["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"]],mp=[["projects","mobile.sessions.viewMode.projects"],["timeline","mobile.sessions.viewMode.timeline"]],nn="min-h-10 items-center justify-between",rn=7,pp=3,hp=32,Si=n=>hp+n*12,Qn=n=>Si(n)+20,yo="openchamber:pinned",vo="openchamber:work",Er=12,gp=(n,e)=>{const s=He(n),r=He(e),i=r.endsWith("/")?r:`${r}/`;return!!(s&&r&&(s===r||s.startsWith(i)))},Ir=(n,e)=>n.worktrees.find(s=>He(s.path)===e)??null,Ar=(n,e,s)=>oa([n.title,n.id,xt(n),e],s),bp=n=>{const e=fe.c(3),{path:s,children:r}=n,i=ia(s);let a;return e[0]!==r||e[1]!==i?(a=r(i),e[0]=r,e[1]=i,e[2]=a):a=e[2],a},xp=n=>{const e=fe.c(2),{ariaLabel:s}=n;let r;return e[0]!==s?(r=t.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-primary","aria-label":s}),e[0]=s,e[1]=r):r=e[1],r},wo=n=>{const e=fe.c(12),{onClick:s,className:r}=n,{t:i}=ve();let a;e[0]!==i?(a=i("sessions.sidebar.project.actions.newWorktree"),e[0]=i,e[1]=a):a=e[1];const o=a;let l;e[2]!==r?(l=ee("flex size-9 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",r),e[2]=r,e[3]=l):l=e[3];let f;e[4]!==s?(f=p=>{p.stopPropagation(),s()},e[4]=s,e[5]=f):f=e[5];let d,m;e[6]===Symbol.for("react.memo_cache_sentinel")?(d={touchAction:"manipulation"},m=t.jsx(X,{name:"node-tree",className:"size-3.5"}),e[6]=d,e[7]=m):(d=e[6],m=e[7]);let h;return e[8]!==o||e[9]!==l||e[10]!==f?(h=t.jsx("button",{type:"button",className:l,"aria-label":o,title:o,onClick:f,style:d,children:m}),e[8]=o,e[9]=l,e[10]=f,e[11]=h):h=e[11],h},jo=n=>{const e=fe.c(10),{label:s,onClick:r,className:i}=n;let a;e[0]!==i?(a=ee("flex size-9 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",i),e[0]=i,e[1]=a):a=e[1];let o;e[2]!==r?(o=m=>{m.stopPropagation(),r()},e[2]=r,e[3]=o):o=e[3];let l,f;e[4]===Symbol.for("react.memo_cache_sentinel")?(l={touchAction:"manipulation"},f=t.jsx(X,{name:"add",className:"size-4"}),e[4]=l,e[5]=f):(l=e[4],f=e[5]);let d;return e[6]!==s||e[7]!==a||e[8]!==o?(d=t.jsx("button",{type:"button",className:a,"aria-label":s,title:s,onClick:o,style:l,children:f}),e[6]=s,e[7]=a,e[8]=o,e[9]=d):d=e[9],d},ko=n=>{const e=fe.c(95),{session:s,active:r,indent:i,contextLabel:a,statusOnRight:o,treeDepth:l,hasChildren:f,expanded:d,onToggleChildren:m,onSelect:h,revealed:p,onRevealedChange:g,confirmingDelete:x,onArchive:y,onRequestDelete:b,onConfirmDelete:S,renaming:R,onRequestRename:C,onSubmitRename:D,onCancelRename:A,work:j,pin:k,descendantIdsOf:v}=n,I=o===void 0?!1:o,P=f===void 0?!1:f,L=d===void 0?!1:d,_=p===void 0?!1:p,E=x===void 0?!1:x,T=R===void 0?!1:R,{t:O}=ve();let M;e[0]!==s?(M=nr(qa(s)),e[0]=s,e[1]=M):M=e[1];const G=M;let F;e[2]!==s.title||e[3]!==O?(F=s.title?.trim()||O("mobile.sessions.untitled"),e[2]=s.title,e[3]=O,e[4]=F):F=e[4];const z=F,U=!!(g&&y),Q=l!==void 0,te=I||Q;let ce;e[5]!==i||e[6]!==Q||e[7]!==l?(ce=Q?Qn(l):i,e[5]=i,e[6]=Q,e[7]=l,e[8]=ce):ce=e[8];const re=ce,Y=fa(s.id,s.directory,U&&(_||T)),ye=Jr(s.id),Z=Xr(s.id),N=Z!==null,$=!N&&ye>0&&!r,J=Yr(s.id,N),ae=(N||$)&&J;let ie;e[9]!==N||e[10]!==s||e[11]!==j?.inWork?(ie=!!j?.inWork&&!N&&sc(s),e[9]=N,e[10]=s,e[11]=j?.inWork,e[12]=ie):ie=e[12];const q=ie;let se;e[13]!==v||e[14]!==L||e[15]!==P||e[16]!==s.id?(se=v&&!(P&&L)?[s.id,...v(s.id)]:[s.id],e[13]=v,e[14]=L,e[15]=P,e[16]=s.id,e[17]=se):se=e[17];const xe=Ja(se);let we;e[18]!==L||e[19]!==P||e[20]!==Q||e[21]!==m||e[22]!==O||e[23]!==l?(we=Q&&P&&m?t.jsx("button",{type:"button",className:"absolute z-10 flex w-[30px] items-center justify-center text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:{insetInlineStart:Si(l)-8,top:0,bottom:0,touchAction:"manipulation"},"aria-label":O(L?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),"aria-expanded":L,onClick:be=>{be.stopPropagation(),m()},children:t.jsx(pa,{expanded:L})}):null,e[18]=L,e[19]=P,e[20]=Q,e[21]=m,e[22]=O,e[23]=l,e[24]=we):we=e[24];let me;e[25]!==Y||e[26]!==L||e[27]!==P||e[28]!==i||e[29]!==N||e[30]!==m||e[31]!==$||e[32]!==te||e[33]!==O||e[34]!==Z?(me=!te&&(Y.pending||N||$||P&&m)?t.jsx("button",{type:"button",className:"absolute z-10 flex w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",style:{insetInlineStart:Math.max(i-32,2),top:0,bottom:0,touchAction:"manipulation"},"aria-label":Y.pending?O("sessions.aiRename.generating"):O(L?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),disabled:!P||!m,onClick:be=>{be.stopPropagation(),m?.()},children:Y.pending?t.jsx(X,{name:"loader-4",className:"size-3 animate-spin text-primary","aria-label":O("sessions.aiRename.generating")}):N||$?t.jsx(Wn,{state:Z??"unread"}):t.jsx(si,{className:ee("size-[18px] transition-transform duration-150",L?"rotate-0":"-rotate-90 rtl:rotate-90")})}):null,e[25]=Y,e[26]=L,e[27]=P,e[28]=i,e[29]=N,e[30]=m,e[31]=$,e[32]=te,e[33]=O,e[34]=Z,e[35]=me):me=e[35];let Re;e[36]!==r||e[37]!==Y||e[38]!==a||e[39]!==N||e[40]!==A||e[41]!==g||e[42]!==h||e[43]!==D||e[44]!==xe||e[45]!==k?.pinned||e[46]!==T||e[47]!==_||e[48]!==s||e[49]!==ae||e[50]!==q||e[51]!==$||e[52]!==te||e[53]!==O||e[54]!==re||e[55]!==G||e[56]!==z||e[57]!==Z?(Re=T&&D&&A?t.jsx(Ua,{initialTitle:z,indent:re,aiRename:Y,onSubmit:D,onCancel:A}):t.jsx("button",{type:"button",className:ee("flex min-w-0 flex-1 items-center gap-2.5 pe-3.5 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",a?"min-h-10 py-1":"h-9"),style:{paddingInlineStart:re,touchAction:"manipulation"},onClick:()=>{if(_){g?.(!1);return}h()},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:ee("block min-w-0 flex-1 truncate oc-ui-start-align typography-ui-label",r?"text-primary":"text-foreground"),children:z}),k?.pinned?t.jsx(X,{name:"pushpin",className:"size-3 shrink-0 text-muted-foreground","aria-label":O("sessions.sidebar.session.status.pinned")}):null,te&&(Y.pending||N||$)?Y.pending?t.jsx(X,{name:"loader-4",className:"size-3 shrink-0 animate-spin text-primary","aria-label":O("sessions.aiRename.generating")}):t.jsx(Wn,{state:Z??"unread"}):null,q?t.jsx(X,{name:"check",className:"size-3.5 shrink-0 text-muted-foreground","aria-label":O("sessions.sidebar.session.work.doneSuggested")}):null,t.jsx(Ur,{session:s}),t.jsx(Gr,{...xe}),ae?t.jsx(Qr,{sessionId:s.id,running:N,className:"typography-micro"}):G?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:G}):null]}),a?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:a}):null]})}),e[36]=r,e[37]=Y,e[38]=a,e[39]=N,e[40]=A,e[41]=g,e[42]=h,e[43]=D,e[44]=xe,e[45]=k?.pinned,e[46]=T,e[47]=_,e[48]=s,e[49]=ae,e[50]=q,e[51]=$,e[52]=te,e[53]=O,e[54]=re,e[55]=G,e[56]=z,e[57]=Z,e[58]=Re):Re=e[58];let Ae;e[59]!==we||e[60]!==me||e[61]!==Re?(Ae=t.jsxs(t.Fragment,{children:[we,me,Re]}),e[59]=we,e[60]=me,e[61]=Re,e[62]=Ae):Ae=e[62];const Te=Ae;if(!U){const be=r||void 0,De=r&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let Oe;e[63]!==De?(Oe=ee("relative flex items-center gap-1 transition-colors",De),e[63]=De,e[64]=Oe):Oe=e[64];let Le;e[65]!==Te||e[66]!==Oe?(Le=t.jsx("div",{className:Oe,children:Te}),e[65]=Te,e[66]=Oe,e[67]=Le):Le=e[67];let Xe;return e[68]!==be||e[69]!==Le?(Xe=t.jsx("div",{"data-active-session":be,className:"relative overflow-hidden",children:Le}),e[68]=be,e[69]=Le,e[70]=Xe):Xe=e[70],Xe}const Se=Ga+(j?pn:0)+(k?pn:0);let Ce;e[71]!==g?(Ce=be=>g?.(be),e[71]=g,e[72]=Ce):Ce=e[72];const K=r&&"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]";let ge;e[73]!==K?(ge=ee("relative flex w-full items-center gap-1 bg-background transition-colors",K),e[73]=K,e[74]=ge):ge=e[74];let ne;e[75]!==E||e[76]!==y||e[77]!==S||e[78]!==b||e[79]!==C||e[80]!==g||e[81]!==k||e[82]!==_||e[83]!==s.id||e[84]!==z||e[85]!==j?(ne=t.jsx(Ka,{sessionId:s.id,title:z,revealed:_,confirmingDelete:E,onArchive:y,onRequestDelete:b,onConfirmDelete:S,onRequestRename:C,onRevealedChange:g,work:j,pin:k}),e[75]=E,e[76]=y,e[77]=S,e[78]=b,e[79]=C,e[80]=g,e[81]=k,e[82]=_,e[83]=s.id,e[84]=z,e[85]=j,e[86]=ne):ne=e[86];let he;return e[87]!==r||e[88]!==_||e[89]!==Te||e[90]!==Se||e[91]!==Ce||e[92]!==ge||e[93]!==ne?(he=t.jsx(Yn,{actionsWidth:Se,revealed:_,onRevealedChange:Ce,dataActiveSession:r,contentClassName:ge,actions:ne,children:Te}),e[87]=r,e[88]=_,e[89]=Te,e[90]=Se,e[91]=Ce,e[92]=ge,e[93]=ne,e[94]=he):he=e[94],he},So=[],yp=n=>{const e=fe.c(41),{run:s,laneNodes:r,depth:i}=n,{t:a}=ve();let o;e[0]!==s.key?(o=_=>_.runOverviewKey===s.key,e[0]=s.key,e[1]=o):o=e[1];const l=Ve(o);let f;e[2]!==r?(f={nodes:r,includeUnreadSubtasks:!1},e[2]=r,e[3]=f):f=e[3];const d=da(f);let m;e[4]!==s.lastActivity?(m=nr(s.lastActivity),e[4]=s.lastActivity,e[5]=m):m=e[5];const h=m,p=l||void 0,g=l&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let x;e[6]!==g?(x=ee("relative flex items-center overflow-hidden transition-colors",g),e[6]=g,e[7]=x):x=e[7];let y;e[8]!==i?(y=Qn(i),e[8]=i,e[9]=y):y=e[9];let b;e[10]!==y?(b={paddingInlineStart:y,touchAction:"manipulation"},e[10]=y,e[11]=b):b=e[11];let S;e[12]!==s.key?(S=()=>Ve.getState().setRunOverviewKey(s.key),e[12]=s.key,e[13]=S):S=e[13];let R;e[14]!==s.title||e[15]!==a?(R=a("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[14]=s.title,e[15]=a,e[16]=R):R=e[16];let C;e[17]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx(sa,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[17]=C):C=e[17];const D=l?"text-primary":"text-foreground";let A;e[18]!==D?(A=ee("block min-w-0 flex-1 truncate oc-ui-start-align typography-ui-label",D),e[18]=D,e[19]=A):A=e[19];let j;e[20]!==s.title||e[21]!==A?(j=t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[C,t.jsx("span",{dir:"auto",className:A,children:s.title})]}),e[20]=s.title,e[21]=A,e[22]=j):j=e[22];let k;e[23]!==s.providerIDs?(k=t.jsx(Ha,{providerIDs:s.providerIDs}),e[23]=s.providerIDs,e[24]=k):k=e[24];let v;e[25]!==d?(v=d?t.jsx(ma,{state:d}):null,e[25]=d,e[26]=v):v=e[26];let I;e[27]!==h?(I=h?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:h}):null,e[27]=h,e[28]=I):I=e[28];let P;e[29]!==R||e[30]!==j||e[31]!==k||e[32]!==v||e[33]!==I||e[34]!==b||e[35]!==S?(P=t.jsxs("button",{type:"button",className:"flex h-9 w-full min-w-0 items-center gap-2.5 pe-3.5 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:b,onClick:S,"aria-label":R,children:[j,k,v,I]}),e[29]=R,e[30]=j,e[31]=k,e[32]=v,e[33]=I,e[34]=b,e[35]=S,e[36]=P):P=e[36];let L;return e[37]!==P||e[38]!==p||e[39]!==x?(L=t.jsx("div",{"data-active-session":p,className:x,children:P}),e[37]=P,e[38]=p,e[39]=x,e[40]=L):L=e[40],L},No=n=>{const e=fe.c(11),{indent:s,onClick:r}=n,{t:i}=ve();let a;e[0]!==s?(a={paddingInlineStart:s,touchAction:"manipulation"},e[0]=s,e[1]=a):a=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx(si,{className:"size-4"}),e[2]=o):o=e[2];let l;e[3]!==i?(l=i("sessions.sidebar.group.showMore"),e[3]=i,e[4]=l):l=e[4];let f;e[5]!==l?(f=t.jsx("span",{className:"typography-micro",children:l}),e[5]=l,e[6]=f):f=e[6];let d;return e[7]!==r||e[8]!==a||e[9]!==f?(d=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pe-3 text-start text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:a,onClick:r,children:[o,f]}),e[7]=r,e[8]=a,e[9]=f,e[10]=d):d=e[10],d},Co=n=>{const e=fe.c(11),{indent:s,onClick:r}=n,{t:i}=ve();let a;e[0]!==s?(a={paddingInlineStart:s,touchAction:"manipulation"},e[0]=s,e[1]=a):a=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx(Ed,{className:"size-4"}),e[2]=o):o=e[2];let l;e[3]!==i?(l=i("sessions.sidebar.group.showFewer"),e[3]=i,e[4]=l):l=e[4];let f;e[5]!==l?(f=t.jsx("span",{className:"typography-micro",children:l}),e[5]=l,e[6]=f):f=e[6];let d;return e[7]!==r||e[8]!==a||e[9]!==f?(d=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pe-3 text-start text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",style:a,onClick:r,children:[o,f]}),e[7]=r,e[8]=a,e[9]=f,e[10]=d):d=e[10],d},vp=n=>{const e=fe.c(29),{worktree:s}=n,{t:r}=ve();let i;e[0]!==s.path?(i=He(s.path),e[0]=s.path,e[1]=i):i=e[1];const a=i;let o;e[2]!==a?(o={id:a},e[2]=a,e[3]=o):o=e[3];const{attributes:l,listeners:f,setNodeRef:d,transform:m,transition:h,isDragging:p}=ui(o),g=s.branch||s.label||s.path;let x;e[4]!==m?(x=fi.Transform.toString(m),e[4]=m,e[5]=x):x=e[5];const y=p?10:1;let b;e[6]!==x||e[7]!==y||e[8]!==h?(b={transform:x,transition:h,zIndex:y},e[6]=x,e[7]=y,e[8]=h,e[9]=b):b=e[9];const S=p&&"shadow-lg shadow-black/20";let R;e[10]!==S?(R=ee("flex items-center gap-1 rounded-xl bg-background px-1 py-1",S),e[10]=S,e[11]=R):R=e[11];let C;e[12]!==g||e[13]!==r?(C=r("mobile.sessions.dragHandleAria",{label:g}),e[12]=g,e[13]=r,e[14]=C):C=e[14];let D;e[15]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx(ti,{className:"size-4"}),e[15]=D):D=e[15];let A;e[16]!==l||e[17]!==f||e[18]!==C?(A=t.jsx("button",{type:"button",className:"flex size-8 shrink-0 cursor-grab touch-none items-center justify-center rounded-lg text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":C,...l,...f,children:D}),e[16]=l,e[17]=f,e[18]=C,e[19]=A):A=e[19];let j;e[20]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx(X,{name:"git-branch",className:"size-4 shrink-0 text-muted-foreground"}),e[20]=j):j=e[20];let k;e[21]!==g?(k=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-bold text-muted-foreground",children:g}),e[21]=g,e[22]=k):k=e[22];let v;return e[23]!==d||e[24]!==A||e[25]!==k||e[26]!==b||e[27]!==R?(v=t.jsxs("div",{ref:d,style:b,className:R,children:[A,j,k]}),e[23]=d,e[24]=A,e[25]=k,e[26]=b,e[27]=R,e[28]=v):v=e[28],v},wp=n=>{const e=fe.c(58),{project:s,expanded:r,onToggleExpanded:i,onReorderWorktrees:a}=n,{t:o}=ve();let l;e[0]!==s.id?(l={id:s.id},e[0]=s.id,e[1]=l):l=e[1];const{attributes:f,listeners:d,setNodeRef:m,transform:h,transition:p,isDragging:g}=ui(l);let x;e[2]===Symbol.for("react.memo_cache_sentinel")?(x={activationConstraint:{distance:8}},e[2]=x):x=e[2];let y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y={coordinateGetter:di},e[3]=y):y=e[3];const b=ni(_s(ii,x),_s(ri,y)),S=s.worktrees.length>0;let R;e[4]!==a||e[5]!==s.worktrees?(R=te=>{const{active:ce,over:re}=te;if(!re||ce.id===re.id)return;const Y=s.worktrees.map(Np),ye=Y.indexOf(String(ce.id)),Z=Y.indexOf(String(re.id));if(ye<0||Z<0)return;const N=[...Y],[$]=N.splice(ye,1);N.splice(Z,0,$),a(N)},e[4]=a,e[5]=s.worktrees,e[6]=R):R=e[6];const C=R;let D;e[7]!==h?(D=fi.Transform.toString(h),e[7]=h,e[8]=D):D=e[8];const A=g?10:1;let j;e[9]!==D||e[10]!==A||e[11]!==p?(j={transform:D,transition:p,zIndex:A},e[9]=D,e[10]=A,e[11]=p,e[12]=j):j=e[12];const k=g&&"shadow-lg shadow-black/20";let v;e[13]!==k?(v=ee("rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",k),e[13]=k,e[14]=v):v=e[14];let I;e[15]!==s.label||e[16]!==o?(I=o("mobile.sessions.dragHandleAria",{label:s.label}),e[15]=s.label,e[16]=o,e[17]=I):I=e[17];let P;e[18]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx(ti,{className:"size-4"}),e[18]=P):P=e[18];let L;e[19]!==f||e[20]!==d||e[21]!==I?(L=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":I,...f,...d,children:P}),e[19]=f,e[20]=d,e[21]=I,e[22]=L):L=e[22];let _;e[23]!==r||e[24]!==s.label||e[25]!==o?(_=r?o("sessions.sidebar.group.collapseAria",{label:s.label}):o("sessions.sidebar.group.expandAria",{label:s.label}),e[23]=r,e[24]=s.label,e[25]=o,e[26]=_):_=e[26];const E=!S;let T;e[27]===Symbol.for("react.memo_cache_sentinel")?(T={touchAction:"manipulation"},e[27]=T):T=e[27];let O;e[28]!==s?(O=t.jsx(Xn,{project:s}),e[28]=s,e[29]=O):O=e[29];let M;e[30]!==s.label?(M=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]=M):M=e[31];let G;e[32]!==r||e[33]!==S?(G=S?t.jsx(si,{className:ee("size-4 shrink-0 text-muted-foreground transition-transform",r&&"rotate-180")}):null,e[32]=r,e[33]=S,e[34]=G):G=e[34];let F;e[35]!==r||e[36]!==i||e[37]!==_||e[38]!==E||e[39]!==O||e[40]!==M||e[41]!==G?(F=t.jsxs("button",{type:"button",className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 rounded-xl px-1 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:i,"aria-expanded":r,"aria-label":_,disabled:E,style:T,children:[O,M,G]}),e[35]=r,e[36]=i,e[37]=_,e[38]=E,e[39]=O,e[40]=M,e[41]=G,e[42]=F):F=e[42];let z;e[43]!==L||e[44]!==F?(z=t.jsxs("div",{className:"flex items-center gap-1",children:[L,F]}),e[43]=L,e[44]=F,e[45]=z):z=e[45];let U;e[46]!==r||e[47]!==C||e[48]!==S||e[49]!==s.worktrees||e[50]!==b?(U=r&&S?t.jsx(oi,{sensors:b,collisionDetection:ai,onDragEnd:C,children:t.jsx(li,{items:s.worktrees.map(Cp),strategy:ci,children:t.jsx("div",{className:"mt-1 flex flex-col gap-0.5 ps-3",children:s.worktrees.map(Rp)})})}):null,e[46]=r,e[47]=C,e[48]=S,e[49]=s.worktrees,e[50]=b,e[51]=U):U=e[51];let Q;return e[52]!==m||e[53]!==z||e[54]!==U||e[55]!==j||e[56]!==v?(Q=t.jsxs("div",{ref:m,style:j,className:v,children:[z,U]}),e[52]=m,e[53]=z,e[54]=U,e[55]=j,e[56]=v,e[57]=Q):Q=e[57],Q},Ro=({open:n,onOpenChange:e,variant:s="drawer",footer:r})=>{const{t:i}=ve(),{git:a}=Zn(),o=ut(u=>u.ensureStatus),l=Yo(),f=ls(u=>u.activeSessions),d=ls(u=>u.hasLoaded),m=n||s==="sidebar",h=c.useRef(dp),p=Tr(c.useCallback(u=>(m&&(h.current=u.ids),h.current),[m])),g=c.useRef(Jl),x=Uo(c.useCallback(u=>(m&&(g.current=u.rankById),g.current),[m])),y=it(u=>u.projects),b=Xl(u=>u.projects),S=it(u=>u.activeProjectId),R=Dt(u=>u.currentDirectory),C=Be(u=>u.currentSessionId),D=Be(u=>u.setCurrentSession),A=Be(u=>u.archiveSession),j=Be(u=>u.archiveSessions),k=Be(u=>u.deleteSession),v=Be(u=>u.deleteSessions),I=Be(u=>u.updateSessionTitle),P=Be(u=>u.openNewSessionDraft),L=it(u=>u.setActiveProject),_=it(u=>u.setActiveProjectIdOnly),E=it(u=>u.reorderProjects),T=it(u=>u.manualProjectOrder),O=Ct(u=>u.projectSortOrder),M=Ct(u=>u.setProjectSortOrder),G=Ct(u=>u.sidebarViewMode),F=G==="timeline"?"manual":O,z=Ct(u=>u.setSidebarViewMode),U=Ct(u=>u.showWorkSection),Q=Ct(u=>u.setShowWorkSection),te=Ct(u=>u.showPinnedSection),ce=Ct(u=>u.setShowPinnedSection),re=Ct(u=>u.detailedZoneRows),Y=Ct(u=>u.setDetailedZoneRows),ye=Tr(u=>u.toggle),Z=Yl(m),N=it(u=>u.removeProject),$=On(u=>u.projectExpanded),J=On(u=>u.worktreeExpanded),ae=On(u=>u.setProjectExpanded),ie=On(u=>u.setWorktreeExpanded),q=Vr(u=>u.orderByProject),se=Vr(u=>u.setWorktreeOrder),ke=ho(u=>u.expandedParents),xe=ho(u=>u.toggleParent),[we,me]=c.useState(""),[Re,Ae]=c.useState(null),[Te,Se]=c.useState(null),[Ce,K]=c.useState(null),[ge,ne]=c.useState(null),[he,be]=c.useState(null),[De,Oe]=c.useState(null),[Le,Xe]=c.useState(null),[Ft,$t]=c.useState(0),[xn,fs]=c.useState(!1),[rr,yn]=c.useState(!1),[ms,ot]=c.useState(null),[yt,ps]=c.useState(()=>new Map(Be.getState().availableWorktreesByProject)),[Wt,ir]=c.useState(()=>{const u=new Set;for(const[B,W]of Be.getState().availableWorktreesByProject)W.length>0&&u.add(B);return u}),[at,Vt]=c.useState(!1),[or,hs]=c.useState(new Set),[vn,pt]=c.useState(new Map),Ge=c.useRef(null);c.useEffect(()=>{if(!n){me(""),Vt(!1),hs(new Set),pt(new Map),Ae(null),Se(null),K(null),ne(null),be(null),Oe(null);return}Jo(l)},[n]),c.useEffect(()=>{at||hs(new Set)},[at]),c.useEffect(()=>{pt(new Map)},[G]),c.useEffect(()=>{if(!n||y.length===0)return;let u=!1;return(async()=>{const W=await Promise.all(y.map(async H=>{const oe=He(H.path);if(!oe)return null;const pe=await a.checkIsGitRepository(oe).catch(()=>null),ue=pe?await aa({id:H.id,path:oe}).catch(()=>null):[];return[oe,ue,pe]}));u||(ps(H=>{const oe=new Map;for(const pe of W){if(!pe)continue;const[ue,Ze,st]=pe,Bt=st===null||Ze===null;oe.set(ue,Bt?H.get(ue)??[]:Ze)}return la(y,oe)}),ir(H=>{const oe=new Set;for(const pe of W){if(!pe)continue;const[ue,,Ze]=pe;(Ze===null?H.has(ue):Ze)&&oe.add(ue)}return oe}))})(),()=>{u=!0}},[a,n,y,Ft]);const Pe=c.useMemo(()=>ju(y.map(u=>({id:u.id,label:u.label?.trim()||Cr(u.path),path:He(u.path),icon:u.icon,color:u.color,iconImage:u.iconImage,iconBackground:u.iconBackground,isGitRepo:Wt.has(He(u.path)),worktrees:Tm(q[u.id],yt.get(He(u.path))??[]),addedAt:u.addedAt,lastOpenedAt:u.lastOpenedAt})),F,T),[Wt,T,F,y,q,yt]),Ye=c.useMemo(()=>{const u=[...f],B=new Set(u.map(W=>W.id));for(const W of l)B.has(W.id)||(B.add(W.id),u.push(W));return u.filter(W=>!W.time?.archived)},[f,l]),Ue=c.useMemo(()=>{const u=new Map;for(const B of Ye){const W=ct(B);if(!W)continue;const H=u.get(W)??[];H.push(B),u.set(W,H)}return u},[Ye]),Rt=c.useCallback(u=>Mn(Ue,u),[Ue]),{projectSessions:ze,chatSessions:gs}=c.useMemo(()=>ku(Ye,!1),[Ye]),Ke=Ve(u=>u.sessionWorkEnabled),Et=c.useMemo(()=>{const u=new Set;if(!Ke||!U)return u;for(const B of Ye)if(!(ct(B)||An(xt(B))||!na(B))){u.add(B.id);for(const W of Mn(Ue,B.id))u.add(W)}return u},[Ue,Ke,Ye,U]),Mt=c.useMemo(()=>{const u=new Set;if(!te)return u;for(const B of Ye){const W=xt(B);if(!(ct(B)||An(W)||!vr(p,W||null,B.id))){u.add(B.id);for(const H of Mn(Ue,B.id))u.add(H)}}return u},[Ue,p,Ye,te]),Ut=c.useMemo(()=>Et.size>0?gs.filter(u=>!Et.has(u.id)):gs,[gs,Et]),vt=gl(),bs=c.useMemo(()=>new Map(vt.map(u=>[u.id,u])),[vt]),wn=c.useMemo(()=>new Map(vt.map(u=>[u.id,u.name||i("sessions.sidebar.grouping.spaceUnnamed")])),[vt,i]),qe=c.useMemo(()=>Od(ze,Pe.map(u=>({id:u.id,normalizedPath:u.path})),new Map(Pe.map(u=>[u.path,u.worktrees])),!1,[],b,vt),[b,ze,Pe,vt]),Fe=c.useMemo(()=>Ql(ze,u=>{const B=qe.bySessionId.get(u.id);return(B?Pe.find(H=>H.id===B.projectId):void 0)?.path||He(xt(u))||null}),[ze,Pe,qe]),ht=c.useMemo(()=>{const u=new Map(Ye.map(H=>[H.id,H])),B=H=>({session:H,children:(Ue.get(H.id)??[]).map(B),worktree:null}),W=new Map;for(const H of Fe.runs.values())W.set(H.key,H.memberIds.flatMap(oe=>{const pe=u.get(oe);return pe?[B(pe)]:[]}));return W},[Ue,Fe,Ye]),Gt=c.useMemo(()=>({key:Qs,label:"",path:"",worktree:null,space:null,sessions:Ns(Ut,p,x)}),[p,Ut,x]),ar=c.useMemo(()=>new Set(Gt.sessions.filter(u=>vr(p,xt(u)||null,u.id)).map(u=>u.id)),[Gt,p]),_t=c.useMemo(()=>({key:yo,label:"",path:"",worktree:null,space:null,sessions:Mt.size>0?Ns(Ye.filter(u=>Mt.has(u.id)),p,x):[]}),[p,Mt,x,Ye]),xs=c.useMemo(()=>({key:vo,label:"",path:"",worktree:null,space:null,sessions:Et.size>0?Ns(Ye.filter(u=>Et.has(u.id)&&!Mt.has(u.id)),p,x):[]}),[p,Mt,x,Ye,Et]),Kt=`${Qs}::${Qs}`,lr=c.useMemo(()=>Ut.filter(u=>!ct(u)).length,[Ut]),We=we.trim().toLowerCase(),Me=c.useRef(null);c.useEffect(()=>{if(!n)return;const u=window.requestAnimationFrame(()=>{const B=Me.current;if(!B)return;(B.querySelector('[data-active-session="true"]')??B.querySelector('[data-active-project="true"]'))?.scrollIntoView({block:"center"})});return()=>window.cancelAnimationFrame(u)},[n]);const St=c.useMemo(()=>{const u=Su(Pe,F,W=>W.id,qe.sessionsByProject).map(W=>({project:W,buckets:[],isActive:W.id===S})),B=(W,H,oe,pe=null)=>{const ue=He(H)||W.project.path,Ze=ue||"__root__";let st=W.buckets.find(Bt=>Bt.key===Ze);return st||(st={key:Ze,label:(pe?pe.name||i("sessions.sidebar.grouping.spaceUnnamed"):null)||oe?.branch||Cr(ue),path:ue,worktree:oe,space:pe,sessions:[]},W.buckets.push(st)),st};for(const W of u){B(W,W.project.path,null);for(const H of W.project.worktrees)B(W,H.path,H);for(const H of vt)H.directory&&He(H.projectDirectory)===He(W.project.path)&&B(W,H.directory,null,H)}for(const W of ze){const H=qe.bySessionId.get(W.id);if(!H)continue;const oe=u.find(st=>st.project.id===H.projectId);if(!oe)continue;const pe=Ir(oe.project,H.scopeDirectory),ue=H.kind==="space"&&H.spaceId?bs.get(H.spaceId)??null:null;(ue?B(oe,H.scopeDirectory,null,ue):pe&&!Fe.runKeyBySessionId.has(W.id)?B(oe,pe.path,pe):B(oe,oe.project.path,null)).sessions.push(W)}for(const W of u)for(const H of W.buckets)H.sessions=Ns(H.sessions,p,x);return u},[S,p,F,Pe,Fe,ze,x,qe,vt,bs,i]),$s=He(R),Ws=u=>u.isActive?$s===u.project.path?u.project.path:u.project.worktrees.find(W=>gp($s,W.path))?.path??u.project.path:null,gt=u=>$[u.project.id]??!0,cr=(u,B)=>B.sessions.length===0||(J[`${u.project.id}::${B.key}`]??!0);c.useEffect(()=>{if(!(!m||!d))for(const u of St)for(const B of u.buckets){const W=`${u.project.id}::${B.key}`;B.sessions.length===0&&J[W]===!1&&ie(W,!0)}},[d,m,St,ie,J]);const Vs=u=>{pt(B=>{if(!B.has(u))return B;const W=new Map(B);return W.delete(u),W})},ur=u=>{pt(B=>{let W=!1;const H=new Map(B),oe=`${u}::`;for(const pe of H.keys())pe.startsWith(oe)&&(H.delete(pe),W=!0);return W?H:B})},jn=(u,B,W)=>{pt(H=>{const oe=new Map(H);return oe.set(u,B+W),oe})},Us=(u,B,W,H)=>{const oe=H?.pageSize??rn,pe=W===null?Er:Qn(W),ue=H?.alwaysVisibleIds,Ze=new Set(B.sessions.map(je=>je.id)),st=new Map;for(const je of B.sessions){const nt=ct(je);if(nt&&Ze.has(nt)){const Nt=st.get(nt)??[];Nt.push(je),st.set(nt,Nt)}}const Bt=B.sessions.filter(je=>{const nt=ct(je);return!nt||!Ze.has(nt)}),ns=new Set,Xs=Bt.flatMap(je=>{const nt=Fe.runKeyBySessionId.get(je.id),Nt=nt?Fe.runs.get(nt):void 0;return Nt?ns.has(Nt.key)?[]:(ns.add(Nt.key),[{kind:"run",run:Nt}]):[{kind:"session",session:je}]}),Pi=je=>je.kind==="session"&&!!ue?.has(je.session.id),nl=ue?Xs.filter(Pi):[],br=ue?Xs.filter(je=>!Pi(je)):Xs,rl=vn.get(u)??oe,xr=br.slice(0,rl),il=[...nl,...xr],Ti=br.length-xr.length,ol=br.length>oe&&Ti===0,Di=(je,nt)=>{const Nt=st.get(je.id)??[],yr=Nt.length>0,Mi=nt!==null&&!!ke[je.id];return t.jsxs(c.Fragment,{children:[t.jsx(ko,{session:je,active:C===je.id,indent:Er,treeDepth:nt??void 0,statusOnRight:nt===null,hasChildren:yr,expanded:Mi,onToggleChildren:yr?()=>xe(je.id):void 0,onSelect:()=>ys(je),revealed:Te===je.id,onRevealedChange:Ys=>vs(je.id,Ys),confirmingDelete:Ce===je.id,onArchive:()=>{Ht(je)},onRequestDelete:()=>K(je.id),onConfirmDelete:()=>{Sn(je)},renaming:ge===je.id,onRequestRename:()=>Qe(je.id),onSubmitRename:Ys=>{Nn(je.id,Ys)},onCancelRename:()=>ne(null),work:wt(je),pin:dr(je),descendantIdsOf:Rt}),yr&&Mi&&nt!==null?Nt.map(Ys=>Di(Ys,nt+1)):null]},je.id)};return t.jsxs("div",{children:[il.map(je=>je.kind==="run"?t.jsx(yp,{run:je.run,laneNodes:ht.get(je.run.key)??So,depth:W??0},`run:${je.run.key}`):Di(je.session,W)),Ti>0?t.jsx(No,{indent:pe,onClick:()=>jn(u,xr.length,rn)}):null,ol?t.jsx(Co,{indent:pe,onClick:()=>Vs(u)}):null]})},rt=(u,B)=>{ae(u,!B),ur(u)},Gs=(u,B,W)=>{ie(`${u}::${B}`,!W),Vs(`${u}::${B}`)},ys=u=>{const B=xt(u)||null,W=qe.bySessionId.get(u.id),H=W?Pe.find(oe=>oe.id===W.projectId)??null:null;if(H){_(H.id),ae(H.id,!0);const oe=Ir(H,W?.scopeDirectory??"");oe&&ie(`${H.id}::${He(oe.path)}`,!0)}D(u.id,B),e(!1)},vs=(u,B)=>{Se(B?u:null),K(null),be(null),Oe(null)},Ot=(u,B)=>{be(B?u:null),Oe(null),Se(null),K(null)},qt=(u,B)=>(Se(null),K(null),Iu(u,B,Au(B.id,Mn(Ue,B.id),u==="delete"),{archiveSession:A,archiveSessions:j,deleteSession:k,deleteSessions:v},i)),Ht=u=>qt("archive",u),lt=async(u,B)=>{try{await nc(u.id,xt(u)||null,B?"done":"open")}catch{de.error(i("sessions.sidebar.session.work.updateFailed"))}},wt=u=>{if(!Ke||ct(u)||An(xt(u)))return;const B=Et.has(u.id);return{inWork:B,onToggle:()=>{lt(u,B)}}},ws=u=>vr(p,xt(u)||null,u.id),kn=u=>{const B=xt(u);B&&ye({directory:B,sessionId:u.id})},dr=u=>{if(!(ct(u)||!xt(u)))return{pinned:ws(u),onToggle:()=>kn(u)}},Sn=u=>qt("delete",u),Qe=u=>{Se(null),K(null),ne(u)},Nn=async(u,B)=>{ne(null);try{await I(u,B)}catch{de.error(i("mobile.sessions.renameError"))}},fr=()=>{P(),e(!1)},Jt=u=>{ot(u),_(u),yn(!0)},mr=ni(_s(ii,{activationConstraint:{distance:8}}),_s(ri,{coordinateGetter:di})),pr=u=>{M(u),Zs({sidebarProjectSortOrder:u}),u!=="manual"&&Vt(!1)},js=u=>{z(u),Zs({sidebarViewMode:u}),u==="timeline"&&Vt(!1)},It=()=>{const u=!U;Q(u),Zs({sidebarShowWorkSection:u})},Xt=()=>{const u=!te;ce(u),Zs({sidebarShowPinnedSection:u})},Yt=()=>{const u=!re;Y(u),Zs({sidebarDetailedZoneRows:u})},At=(u,B,W,H)=>t.jsxs(en,{onClick:H,className:nn,children:[t.jsx("span",{children:i(B)}),W?t.jsx(X,{name:"check",className:"size-4 text-primary"}):null]},u),Ks=u=>{const{active:B,over:W}=u;if(!W||B.id===W.id)return;const H=Pe.findIndex(pe=>pe.id===B.id),oe=Pe.findIndex(pe=>pe.id===W.id);H<0||oe<0||E(H,oe)},Cn=u=>{hs(B=>{const W=new Set(B);return W.has(u)?W.delete(u):W.add(u),W})},hr=c.useCallback(u=>{const B=xt(u);if(An(B))return i("mobile.sessions.section.chats");const W=qe.bySessionId.get(u.id),H=W?Pe.find(ue=>ue.id===W.projectId)??null:null;if(!H)return Cr(B)||B;const oe=W?.kind==="space"&&W.spaceId?bs.get(W.spaceId):void 0;if(oe)return`${H.label} · ${oe.name||i("sessions.sidebar.grouping.spaceUnnamed")}`;const pe=Ir(H,W?.scopeDirectory??"");return pe?.branch?`${H.label} · ${pe.branch}`:H.label},[Pe,qe,bs,i]),gr=u=>{L(u.id),e(!1)},qs=u=>{_(u.id),P({selectedProjectId:u.id,directoryOverride:u.path}),e(!1)},Qt=c.useMemo(()=>We?St.filter(u=>oa([u.project.label,u.project.path],We)?!0:u.buckets.some(B=>B.sessions.some(W=>Ar(W,u.project.label,We)))):St,[We,St]),ks=c.useMemo(()=>We?Ns(Ye.filter(u=>{if(ct(u))return!1;const B=qe.bySessionId.get(u.id),W=B?Pe.find(H=>H.id===B.projectId)??null:null;return Ar(u,W?.label??"",We)}),p,x):[],[We,p,Pe,x,qe,Ye]),Zt=c.useMemo(()=>We?Zl(Pe,We,u=>[u.label,u.path]):[],[We,Pe]),Ss=G==="timeline"&&!We&&!at,es=!We&&!at,Rn=G!=="timeline"&&!re,ts=Ss||es&&(xs.sessions.length>0||_t.sessions.length>0),Hs=ts;c.useEffect(()=>{if(!(!Hs||!a))for(const u of Pe){const B=He(u.path);B&&ec(()=>o(B,a))}},[o,a,Hs,Pe]);const ss=c.useMemo(()=>{const u=new Map;if(!ts)return u;const B=Nu({sessions:ze,projects:Pe.map(W=>({id:W.id,normalizedPath:W.path,label:W.label})),ownerBySessionId:qe.bySessionId,availableWorktreesByProject:new Map(Pe.map(W=>[W.path,W.worktrees])),gitBranches:Z,homeDirectory:null,hideBranchMatchingProjectLabel:!1,spaceLabelById:wn});for(const W of ze){if(ct(W))continue;const H=B.get(W.id),oe=H?Pe.find(pe=>pe.id===H.projectId):null;!oe||!H||u.set(W.id,{project:oe,branch:H.branchLabel,inSpace:H.inSpace})}return u},[Z,ts,ze,Pe,qe,wn]),zt=c.useCallback(u=>{const B=new Set;return u.flatMap(W=>{const H=ss.get(W.id);if(!H)return[];const oe=Fe.runKeyBySessionId.get(W.id),pe=oe?Fe.runs.get(oe):void 0;return pe?B.has(pe.key)?[]:(B.add(pe.key),[{kind:"run",run:pe,laneNodes:ht.get(pe.key)??So,project:H.project}]):[{kind:"session",session:W,project:H.project,branch:H.branch,inSpace:H.inSpace}]})},[Fe,ht,ss]),w=c.useMemo(()=>{const u=new Map;if(!Ss)return u;const B=Ns(ze.filter(W=>!ct(W)&&ss.has(W.id)),p,x);for(const W of zt(B)){const H=u.get(W.project.id);H?H.push(W):u.set(W.project.id,[W])}return u},[p,ze,x,Ss,ss,zt]),V=c.useMemo(()=>es?zt(xs.sessions.filter(u=>!ct(u))):[],[es,zt,xs]),le=c.useMemo(()=>es?zt(_t.sessions.filter(u=>!ct(u))):[],[es,zt,_t]),Ne=(u,B,W)=>{const H=vn.get(u)??rn,oe=B.slice(0,H),pe=B.length-oe.length;return t.jsxs(t.Fragment,{children:[t.jsx(bo,{entries:oe,showProject:W,handlers:bt}),pe>0?t.jsx(No,{indent:hn,onClick:()=>jn(u,oe.length,rn)}):B.length>rn?t.jsx(Co,{indent:hn,onClick:()=>Vs(u)}):null]})},_e=(u,B,W,H,oe)=>{if(H.sessions.length===0)return null;const pe=$[u]??!0;return t.jsxs("section",{children:[t.jsxs("button",{type:"button",className:"flex min-h-12 w-full min-w-0 items-center gap-2 px-3 py-1.5 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(he){Ot(he,!1);return}rt(u,pe)},"aria-expanded":pe,"aria-label":pe?i("sessions.sidebar.group.collapseAria",{label:W}):i("sessions.sidebar.group.expandAria",{label:W}),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(X,{name:B,className:"size-5"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-header font-semibold text-foreground",children:W}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:H.sessions.filter(ue=>!ct(ue)).length})]}),t.jsx(Bn,{open:pe,children:()=>t.jsx("div",{className:"pb-2",children:t.jsx(bo,{entries:oe,showProject:!0,compact:Rn,handlers:bt})})})]})},bt={currentSessionId:C,revealedSessionId:Te,confirmingDeleteSessionId:Ce,renamingSessionId:ge,onSelect:ys,onRevealedChange:vs,onArchive:u=>{Ht(u)},onRequestDelete:K,onConfirmDelete:u=>{Sn(u)},onRequestRename:Qe,onSubmitRename:(u,B)=>{Nn(u,B)},onCancelRename:()=>ne(null),onToggleWork:Ke?(u,B)=>{lt(u,B)}:void 0,isPinned:ws,onTogglePin:kn,descendantIdsOf:Rt},$e=We&&ks.length===0&&Zt.length===0,Ri=!We&&Pe.length>1&&F==="manual",Js=!at&&!We&&Pe.length>0?t.jsxs(Mr,{children:[t.jsx(_r,{asChild:!0,children:t.jsx(Ee,{type:"button",variant:"chip",size:"sm","aria-label":i("sessions.sidebar.header.displayMode.label"),title:i("sessions.sidebar.header.displayMode.label"),style:{touchAction:"manipulation"},children:t.jsx(X,{name:"equalizer-2",className:"size-4"})})}),t.jsxs(Or,{align:"end",className:"w-64",children:[t.jsx(Ui,{children:i("mobile.sessions.viewMode.label")}),mp.map(([u,B])=>At(u,B,G===u,()=>js(u))),G==="timeline"?null:t.jsxs(t.Fragment,{children:[t.jsx(wr,{}),t.jsx(Ui,{children:i("sessions.sidebar.header.actions.sortProjects")}),fp.map(([u,B])=>At(u,B,F===u,()=>pr(u)))]}),t.jsx(wr,{}),At("pinned","sessions.sidebar.header.displayMode.showPinned",te,Xt),Ke?At("work","sessions.sidebar.header.displayMode.showWork",U,It):null,G==="timeline"?null:At("detailed","sessions.sidebar.header.displayMode.detailedZoneRows",re,Yt),Ri?t.jsxs(t.Fragment,{children:[t.jsx(wr,{}),t.jsx(en,{onClick:()=>Vt(!0),className:nn,children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(X,{name:"drag-move-2",className:"size-4"}),i("mobile.sessions.editOrder")]})})]}):null]})]}):null,En=at?t.jsx(Ee,{type:"button",variant:"chip",size:"sm","aria-label":i("mobile.sessions.doneEditing"),"aria-pressed":!0,onClick:()=>Vt(!1),style:{touchAction:"manipulation"},children:t.jsx(ba,{className:"size-4"})}):null,Ei=!at&&Pe.length>0?t.jsxs(Ee,{type:"button",variant:"default",size:"sm","aria-label":i("mobile.sessions.newChat"),onClick:fr,style:{touchAction:"manipulation"},children:[t.jsx(Rd,{className:"size-4"}),i("mobile.sessions.newChat")]}):null,Ii=at?null:t.jsx(Ee,{type:"button",variant:"chip",size:"sm","aria-label":i("sessions.sidebar.header.actions.addProject"),title:i("sessions.sidebar.header.actions.addProject"),onClick:()=>fs(!0),style:{touchAction:"manipulation"},children:t.jsx(Hi,{className:"size-4"})}),In=Ei||Ii||Js||En?t.jsxs(t.Fragment,{children:[Ii,Js,En,Ei]}):null,Ai=t.jsxs("div",{ref:Me,className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs(er,{ref:Ge,className:"min-h-0 flex-1 overflow-y-auto pb-4",children:[t.jsx("div",{className:ee("px-4 pb-2 pt-1",at&&"hidden"),children:t.jsx(Cu,{value:we,onSearch:me,active:n||s==="sidebar",mobile:!0,placeholder:i("mobile.sessions.search.placeholder"),clearLabel:i("mobile.sessions.clearSearchAria")})}),Pe.length===0&&gs.length===0?t.jsx(Ao,{title:i("mobile.sessions.empty.noProjectsTitle"),description:i("mobile.sessions.empty.noProjectsDescription"),action:t.jsxs("button",{type:"button",className:"flex items-center justify-center gap-2 rounded-2xl bg-primary px-5 py-3 typography-ui-label text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>fs(!0),children:[t.jsx(Hi,{className:"size-4"}),i("sessions.sidebar.header.actions.addProject")]})}):$e?t.jsx(Ao,{title:i("mobile.sessions.empty.searchTitle"),description:i("mobile.sessions.empty.searchDescription")}):We&&!at?t.jsxs("div",{className:"flex flex-col gap-3 px-3 pt-2",children:[ks.length>0?t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center justify-between px-1 pb-1.5",children:[t.jsx("span",{className:"typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:i("mobile.sessions.search.section.sessions")}),t.jsx("span",{className:"typography-micro text-muted-foreground tabular-nums",children:ks.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:ks.map((u,B)=>t.jsx("div",{className:ee(B>0&&"border-t border-border/70"),children:t.jsx(ko,{session:u,active:C===u.id,indent:12,contextLabel:hr(u),onSelect:()=>ys(u)})},u.id))})]}):null,Zt.length>0?t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center justify-between px-1 pb-1.5",children:[t.jsx("span",{className:"typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:i("mobile.sessions.search.section.projects")}),t.jsx("span",{className:"typography-micro text-muted-foreground tabular-nums",children:Zt.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:Zt.map((u,B)=>t.jsxs("div",{className:ee("flex items-center",B>0&&"border-t border-border/70"),children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-3 px-3 py-1.5 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>gr(u),style:{touchAction:"manipulation"},children:[t.jsx(Xn,{project:u}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:u.label})]}),u.isGitRepo?t.jsx(wo,{onClick:()=>Jt(u.id)}):null,t.jsx(jo,{className:"me-2",label:i("mobile.sessions.newSessionInProjectAria",{label:u.label}),onClick:()=>qs(u)})]},u.id))})]}):null]}):at?t.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2",children:[t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:i("mobile.sessions.editOrderHint")}),t.jsx(oi,{sensors:mr,collisionDetection:ai,onDragEnd:Ks,children:t.jsx(li,{items:Pe.map(u=>u.id),strategy:ci,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:Pe.map(u=>t.jsx(wp,{project:u,expanded:or.has(u.id),onToggleExpanded:()=>Cn(u.id),onReorderWorktrees:B=>se(u.id,B)},u.id))})})})]}):t.jsxs("div",{className:"flex flex-col",children:[(()=>{const u=$[Qs]??!0,B=i("mobile.sessions.section.chats");return t.jsxs("section",{children:[t.jsx("div",{className:"flex min-h-12 w-full items-center",children:t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(he){Ot(he,!1);return}rt(Qs,u)},"aria-expanded":u,"aria-label":u?i("sessions.sidebar.group.collapseAria",{label:B}):i("sessions.sidebar.group.expandAria",{label:B}),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(X,{name:"chat-4",className:"size-5"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-header font-semibold text-foreground",children:B}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:lr})]})}),t.jsx(Bn,{open:u,children:()=>t.jsx("div",{className:"pb-2",children:Gt.sessions.length>0?Us(Kt,Gt,null,{pageSize:pp,alwaysVisibleIds:ar}):t.jsx("p",{className:"px-3 pb-1 typography-micro text-muted-foreground",style:{paddingInlineStart:Er},children:i("sessions.sidebar.activity.chatsEmpty")})})})]})})(),_e(yo,"pushpin",i("sessions.sidebar.activity.pinnedTitle"),_t,le),_e(vo,"eye",i("sessions.sidebar.work.title"),xs,V),Qt.map(u=>{const B=gt(u),W=We?u.buckets.filter(oe=>oe.sessions.some(pe=>Ar(pe,u.project.label,We))):u.buckets,H=Ws(u);return t.jsxs("section",{children:[t.jsx(Yn,{actionsWidth:96,revealed:he===`project:${u.project.id}`,onRevealedChange:oe=>Ot(`project:${u.project.id}`,oe),actions:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:he===`project:${u.project.id}`?0:-1,className:ee("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",De===u.project.id?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80"),"aria-label":De===u.project.id?i("mobile.sessions.confirmRemoveProjectAria",{label:u.project.label}):i("mobile.sessions.removeProjectAria",{label:u.project.label}),onClick:()=>{if(De===u.project.id){be(null),Oe(null),N(u.project.id),de.success(i("mobile.sessions.toast.projectRemoved",{label:u.project.label}));return}Oe(u.project.id)},style:{touchAction:"manipulation"},children:t.jsx(Vn,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:he===`project:${u.project.id}`?0:-1,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":i("mobile.sessions.editProjectAria",{label:u.project.label}),onClick:()=>{be(null),Ae(u.project.id)},style:{touchAction:"manipulation"},children:t.jsx(ga,{className:"size-[18px]"})})]}),children:t.jsxs("div",{"data-active-project":u.isActive||void 0,className:"flex min-h-12 w-full items-center",children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(he){Ot(he,!1);return}rt(u.project.id,B)},"aria-expanded":B,"aria-label":B?i("sessions.sidebar.group.collapseAria",{label:u.project.label}):i("sessions.sidebar.group.expandAria",{label:u.project.label}),style:{touchAction:"manipulation"},children:[t.jsx(Xn,{project:u.project}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-header font-semibold text-foreground",children:u.project.label})]}),u.project.isGitRepo?t.jsx(wo,{onClick:()=>Jt(u.project.id)}):null,t.jsx(jo,{className:"me-2",label:i("mobile.sessions.newSessionInProjectAria",{label:u.project.label}),onClick:()=>qs(u.project)})]})}),t.jsx(Bn,{open:B,children:()=>Ss?t.jsx("div",{className:"pb-2",children:Ne(`${u.project.id}::timeline`,w.get(u.project.id)??[],!1)}):t.jsx("div",{className:"pb-2",children:(()=>{const oe=W.find(ue=>ue.worktree===null&&ue.space===null),pe=W.filter(ue=>ue!==oe);return t.jsxs(t.Fragment,{children:[oe&&oe.sessions.length>0?Us(`${u.project.id}::${oe.key}`,oe,0):null,pe.map(ue=>{const Ze=cr(u,ue),st=ue.sessions.length===0,Bt=H===ue.path;return t.jsx(bp,{path:ue.worktree?.path??null,children:ns=>t.jsxs("div",{className:ee("mt-1.5",ns&&"opacity-60"),"aria-busy":ns||void 0,children:[t.jsx(Yn,{actionsWidth:ue.space?96:48,revealed:he===`wt:${ue.key}`,onRevealedChange:Xs=>Ot(`wt:${ue.key}`,Xs),actions:ue.space?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:he===`wt:${ue.key}`?0:-1,className:"flex flex-1 items-center justify-center text-foreground transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":i("spaces.group.access.giveAria",{label:ue.label}),onClick:()=>{be(null),ue.space&&Oi.getState().openAccessDialog(ue.space.id)},style:{touchAction:"manipulation"},children:t.jsx(X,{name:"key",className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:he===`wt:${ue.key}`?0:-1,className:"flex flex-1 items-center justify-center text-foreground transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-label":i("spaces.actions.menuAria",{label:ue.label}),onClick:()=>{be(null),ue.space&&Oi.getState().openActionsSheet(ue.space.id)},style:{touchAction:"manipulation"},children:t.jsx(X,{name:"more-2",className:"size-[18px]"})})]}):ue.worktree&&!ns?t.jsx("button",{type:"button",tabIndex:he===`wt:${ue.key}`?0:-1,className:"flex flex-1 items-center justify-center text-[var(--status-error)] transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive","aria-label":i("mobile.projectEdit.deleteWorktreeAria",{label:ue.label}),onClick:()=>{be(null),ue.worktree&&Xe({project:u.project,worktree:ue.worktree})},style:{touchAction:"manipulation"},children:t.jsx(Vn,{className:"size-[18px]"})}):null,children:t.jsxs("button",{type:"button",className:"flex min-h-10 w-full items-center gap-0.5 py-1 pe-3 text-start transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>{if(he){Ot(he,!1);return}st||Gs(u.project.id,ue.key,Ze)},"aria-expanded":st?void 0:Ze,"aria-label":st?ue.label:Ze?i("sessions.sidebar.group.collapseAria",{label:ue.label}):i("sessions.sidebar.group.expandAria",{label:ue.label}),style:{paddingInlineStart:Si(0),touchAction:"manipulation"},children:[st?t.jsx("span",{"aria-hidden":!0,className:"size-3.5 shrink-0"}):t.jsx(pa,{expanded:Ze}),ns?t.jsx("span",{className:"inline-flex size-3.5 shrink-0 items-center justify-center text-muted-foreground",role:"status","aria-label":i("sessions.sidebar.group.worktreeRemoving"),children:t.jsx(X,{name:"loader-4",className:"size-3.5 animate-spin"})}):t.jsx(X,{name:ue.space?"box-3":"git-branch",className:ee("mx-px size-3 shrink-0",Bt?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground",children:ue.label}),Bt?t.jsx(xp,{ariaLabel:i("mobile.sessions.activeWorktreeAria")}):null]})}),ue.space?t.jsx("div",{className:"pb-1 pe-3",style:{paddingInlineStart:Qn(1)},children:t.jsx(Ru,{spaceId:ue.space.id})}):null,t.jsx(Bn,{open:Ze,children:()=>Us(`${u.project.id}::${ue.key}`,ue,1)})]})},ue.key)})]})})()})})]},u.project.id)})]})]}),r?t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-border/70 px-2 pt-1.5",style:{paddingBottom:"calc(0.375rem + var(--oc-safe-area-bottom, 0px))"},children:[r.instanceLabel&&r.onOpenInstances?t.jsxs(Ee,{type:"button",variant:"info",size:"lg",className:"min-w-0 shrink justify-start",onClick:r.onOpenInstances,"aria-label":i("mobile.menu.instances"),style:{touchAction:"manipulation"},children:[t.jsx(X,{name:"server",className:"size-[18px]"}),t.jsx("span",{className:"block min-w-0 truncate",children:r.instanceLabel})]}):t.jsx("div",{className:"min-w-0 flex-1"}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[r.onOpenUpdate?t.jsxs(Ee,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:r.onOpenUpdate,"aria-label":i("mobile.menu.update"),title:i("mobile.menu.update"),style:{touchAction:"manipulation"},children:[t.jsx(X,{name:"download",className:"size-5"}),t.jsx("span",{className:"absolute inset-e-2 top-2 inline-flex size-2 rounded-full bg-primary","aria-hidden":!0})]}):null,t.jsx(Ee,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:r.onOpenSourceBoard,"aria-label":i("sourceBoard.title"),title:i("sourceBoard.title"),style:{touchAction:"manipulation"},children:t.jsx(X,{name:"todo",className:"size-5"})}),t.jsx(Ee,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:r.onOpenSettings,"aria-label":i("mobile.menu.settings"),title:i("mobile.menu.settings"),style:{touchAction:"manipulation"},children:t.jsx(X,{name:"settings-3",className:"size-5"})}),t.jsxs(Mr,{children:[t.jsx(_r,{asChild:!0,children:t.jsx(Ee,{type:"button",variant:"default",size:"lg",className:"w-10 px-0","aria-label":i("mobile.sessions.footer.more"),title:i("mobile.sessions.footer.more"),style:{touchAction:"manipulation"},children:t.jsx(X,{name:"more",className:"size-5"})})}),t.jsxs(Or,{side:"top",align:"end",className:"w-56",children:[t.jsx(en,{onClick:r.onOpenScheduled,className:nn,children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(X,{name:"calendar-schedule",className:"size-4"}),i("sessions.sidebar.header.actions.scheduledTasks")]})}),t.jsx(en,{onClick:r.onOpenArchive,className:nn,children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(X,{name:"archive",className:"size-4"}),i("sessions.sidebar.nav.archive")]})}),t.jsx(en,{onClick:r.onOpenUsage,className:nn,children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(X,{name:"bar-chart",className:"size-4"}),i("usageStats.openAction")]})})]})]})]})]}):null,t.jsx(Eu,{open:xn,onOpenChange:fs}),t.jsx(tc,{open:rr,onOpenChange:u=>{yn(u),u||ot(null)},project:(()=>{const u=Pe.find(B=>B.id===ms);return u?{id:u.id,path:u.path}:void 0})(),onWorktreeCreated:u=>{P({selectedProjectId:ms,directoryOverride:u,preserveDirectoryOverride:!0}),e(!1)}}),t.jsx(Gm,{open:Re!==null,project:Pe.find(u=>u.id===Re)??null,onClose:()=>Ae(null),onWorktreesChanged:()=>$t(u=>u+1)}),Le?t.jsx(Va,{open:!0,project:{id:Le.project.id,path:Le.project.path},worktree:Le.worktree,onClose:()=>Xe(null),onDeleted:()=>$t(u=>u+1)}):null]});return s==="sidebar"?n?t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsx("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center justify-end gap-2 border-b border-border/70 px-4",children:In?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:In}):null}),Ai]}):null:t.jsxs(Sp,{open:n,onClose:()=>e(!1),onSwipeClose:()=>{if(Te||he){Se(null),be(null),K(null),Oe(null);return}e(!1)},ariaLabel:i("mobile.sessions.sheet.title"),children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",children:[t.jsx("button",{type:"button",className:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":i("mobile.surface.closeAria"),onClick:()=>e(!1),style:{touchAction:"manipulation"},children:t.jsx(X,{name:"close",className:"size-5"})}),In?t.jsx("div",{className:"ms-auto flex shrink-0 items-center gap-2",children:In}):null]}),Ai]})},Eo="mobile-surface-root",jp=16,Io=320,kp="cubic-bezier(0.22, 1, 0.36, 1)",Sp=({open:n,onClose:e,onSwipeClose:s,ariaLabel:r,children:i})=>{const{direction:a}=ve(),o=c.useRef(null),l=c.useRef(null),[f,d]=c.useState(!1),[m,h]=c.useState(n),p=c.useRef(e);c.useEffect(()=>{p.current=e},[e]);const g=c.useRef(s);c.useEffect(()=>{g.current=s},[s]);const x=()=>(g.current??p.current)();if(ki(l,{enabled:n,...a==="rtl"?{onLeftEdgeSwipe:x}:{onRightEdgeSwipe:x}}),typeof document<"u"&&!o.current){let y=document.getElementById(Eo);y||(y=document.createElement("div"),y.id=Eo,document.body.appendChild(y)),o.current=y}return c.useEffect(()=>{if(n){h(!0);const b=window.setTimeout(()=>d(!0),jp);return()=>window.clearTimeout(b)}d(!1);const y=window.setTimeout(()=>h(!1),Io+40);return()=>window.clearTimeout(y)},[n]),c.useEffect(()=>{if(!n)return;const y=document.body.style.overflow;document.body.style.overflow="hidden";const b=S=>{S.key==="Escape"&&p.current()};return document.addEventListener("keydown",b),()=>{document.body.style.overflow=y,document.removeEventListener("keydown",b)}},[n]),o.current?Ds.createPortal(t.jsx("section",{ref:l,role:"dialog","aria-modal":"true","aria-label":r,"aria-hidden":!n,className:"oc-keyboard-inset-surface fixed inset-0 z-50 flex flex-col bg-background text-foreground",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:f?"none":a==="rtl"?"translateX(100%)":"translateX(-100%)",transition:`transform ${Io}ms ${kp}`,visibility:m?"visible":"hidden",pointerEvents:n?"auto":"none"},children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:i})}),o.current):null},Ao=n=>{const e=fe.c(10),{title:s,description:r,action:i}=n;let a;e[0]!==s?(a=t.jsx("p",{className:"typography-ui-label text-foreground",children:s}),e[0]=s,e[1]=a):a=e[1];let o;e[2]!==r?(o=r?t.jsx("p",{className:"typography-meta text-muted-foreground",children:r}):null,e[2]=r,e[3]=o):o=e[3];let l;e[4]!==i?(l=i?t.jsx("div",{className:"pt-2",children:i}):null,e[4]=i,e[5]=l):l=e[5];let f;return e[6]!==a||e[7]!==o||e[8]!==l?(f=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[a,o,l]}),e[6]=a,e[7]=o,e[8]=l,e[9]=f):f=e[9],f};function Np(n){return He(n.path)}function Cp(n){return He(n.path)}function Rp(n){return t.jsx(vp,{worktree:n},He(n.path))}const Ep=6e4,Ip=(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}},Ap=n=>{switch(n?.status.status){case"connected":return"success";case"failed":return"error";case"needs_auth":return"warning";default:return"default"}},Pp=({active:n,className:e,headerAction:s,listClassName:r,hideHeader:i=!1,mobileListDensity:a=!1})=>{const{t:o}=ve(),f=Dt(j=>j.currentDirectory)??null,d=Cs(j=>j.getStatusForDirectory(f)),m=Cs(j=>j.refresh),h=Cs(j=>j.ensureFresh),p=Cs(j=>j.connect),g=Cs(j=>j.disconnect),x=Ps(j=>j.mcpServers),y=Ps(j=>j.loadMcpConfigs),[b,S]=c.useState(!1),[R,C]=c.useState(null);c.useEffect(()=>{y({force:!0})},[y]),c.useEffect(()=>{n&&Promise.all([h({directory:f,silent:!0,maxAgeMs:Ep}),y({force:!0})])},[n,h,f,y]);const D=c.useMemo(()=>{const j=new Set(Object.keys(d));for(const k of x)k?.name&&j.add(k.name);return Array.from(j).sort((k,v)=>k.localeCompare(v))},[x,d]),A=c.useCallback(j=>{if(j?.preventDefault(),b)return;S(!0);const k=new Promise(v=>setTimeout(v,500));Promise.all([m({directory:f}),k]).finally(()=>{S(!1)})},[b,m,f]);return t.jsxs("div",{className:ee("w-full",e),children:[i?null:t.jsx("div",{className:"border-b border-[var(--interactive-border)]",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5",children:[t.jsxs("div",{className:"min-w-0 flex items-baseline gap-2",children:[t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:o("mcpDropdown.title")}),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:b,onClick:A,"aria-label":o("mcpDropdown.actions.refreshAria"),children:t.jsx(X,{name:"refresh",className:ee("h-4 w-4",b&&"animate-spin")})})]})]})}),t.jsx("div",{className:ee("max-h-64 overflow-y-auto",a?"space-y-1 py-3":"px-3 py-2.5",r),children:t.jsxs("div",{className:ee(!a&&D.length>0&&"p-1.5"),children:[D.map(j=>{const k=d[j],v=Ap(k),I=k?.status.status==="connected",P=R===j,L=Ip(k,o);return t.jsxs("div",{className:ee("flex items-center justify-between rounded-lg hover:bg-interactive-hover",a?"gap-3 px-4 py-3":"gap-2 px-2.5 py-2"),children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsxs(rc,{children:[t.jsx(ic,{asChild:!0,children:t.jsx("span",{className:ee("rounded-full flex-shrink-0",a?"h-2.5 w-2.5":"h-2 w-2",v==="success"&&"bg-status-success",v==="error"&&"bg-status-error",v==="warning"&&"bg-status-warning",v==="default"&&"bg-muted-foreground/40"),"aria-label":L})}),t.jsx(oc,{side:"left",children:t.jsx("p",{children:L})})]}),t.jsx("span",{className:ee("truncate",a?"text-[17px] leading-6 font-medium":"typography-ui-label"),children:j})]})}),t.jsx(ac,{checked:I,disabled:P,className:"data-[checked]:bg-status-info",onCheckedChange:async _=>{C(j);try{_?await p(j,f):await g(j,f)}catch(E){Lr.error(E instanceof Error?E.message:o("mcpDropdown.status.unknownError"))}finally{C(null)}}})]},j)}),D.length===0&&t.jsx("div",{className:"px-4 py-5 typography-ui-label text-muted-foreground text-center",children:o("mcpDropdown.empty.configureInConfig")})]})})]})};async function Tp(n,e,s=Number.POSITIVE_INFINITY){const r=Array.from(new Set(n)),i=[];return await lc(r,s,async a=>{try{await e(a)}catch(o){i.push({path:a,error:o instanceof Error?o:null})}}),{paths:r,failures:i}}const Dp=async(n,e,s)=>{const{targetBranch:r,directory:i,sourceBranch:a,git:o,publishChooser:l,toast:f,t:d}=s;if(!(!r||!i)){if(await o.createGitCommit(i,n,{addAll:!0}),e)try{await(await l.prepare("push"))()}catch{f.error(d("gitView.dirtySwitch.pushFailed")),await s.refreshStatusAndBranches(),s.closeDialog();return}f.success(a?e?d("gitView.publish.succeeded"):d("gitView.dirtySwitch.committedNotPushed",{branch:a}):d("gitView.toast.commitCreated")),await s.refreshStatusAndBranches(),s.closeDialog(),await s.performCheckout(r)}},Po={status:"loading"},Mp=1e6,is={type:"list"},_p=2,Op=n=>{const e=n.index?.trim();return!!(e&&e!=="?")},zp=n=>{const e=n.working_dir?.trim(),s=n.index?.trim();return!!(e||s==="?")},To=(n,e)=>e?`${n}\0staged`:n,Bp=n=>{const e=fe.c(6),s=bn(Zr()??null)??"",r=n.visible??!0;let i;e[0]!==r?(i={enabled:r,recheckOnOpen:!0},e[0]=r,e[1]=i):i=e[1];const a=cc(s||null,i);let o;return e[2]!==n||e[3]!==a||e[4]!==s?(o=t.jsx(Lp,{...n,rootDirectory:s,repository:a}),e[2]=n,e[3]=a,e[4]=s,e[5]=o):o=e[5],o},Lp=({rootDirectory:n,repository:e,onClose:s,initialDiff:r,visible:i=!0,onNavigatedToChat:a})=>{const{t:o}=ve(),{git:l,sourceControl:f}=Zn(),{rootIsGitRepo:d,gitDirectory:m,nestedRepos:h}=e,p=m??n,g=uc(p||null),x=Pu(p),y=dc(p||null),b=fc(p||null),[S,R]=c.useState(!1),[C,D]=c.useState(!1),A=_n(w=>w.profiles),j=_n(w=>w.globalIdentity),k=_n(w=>w.loadProfiles),v=_n(w=>w.loadGlobalIdentity);c.useEffect(()=>{k(),v()},[k,v]);const I=mc(),P=ca(w=>w.refreshIdentityAccounts),L=c.useMemo(()=>pc(A,j,w=>bl(w)&&hc(w,I)),[A,j,I]),_=async w=>{if(!(!p||C)){D(!0);try{(await Gu({directory:p,identity:w,remoteName:Ut||null},{git:l,sourceControl:f})).status==="failed"?de.error(o("gitView.toast.applyIdentityFailed")):de.success(o("gitView.toast.appliedIdentity",{name:Pc(w,o)}))}finally{D(!1)}}},E=Xo(p||null),T=gc(p||null),O=ut(w=>w.setActiveDirectory),M=ut(w=>w.ensureAll),G=ut(w=>w.ensureNestedRepos),F=ut(w=>w.selectNestedRepo),z=ut(w=>w.fetchStatus),U=ut(w=>w.fetchBranches),Q=ut(w=>w.prefetchDiffs),te=ut(w=>w.getDiff),ce=ut(w=>w.setDiff),re=ut(w=>w.runtimeKey),Y=JSON.stringify([re,p]),ye=c.useRef(Y);ye.current=Y;const[Z,N]=c.useState(()=>({ownerKey:Y,mode:"working",route:r?.path?{type:"diff",path:r.path,staged:r.staged}:is})),$=Z.ownerKey===Y?Z.mode:"working",J=Z.ownerKey===Y?Z.route:is,[ae,ie]=c.useState(!1),q=c.useCallback(w=>{N({ownerKey:Y,mode:w,route:is}),ie(!1)},[Y]),se=c.useCallback(w=>{N(V=>({ownerKey:Y,mode:V.ownerKey===Y?V.mode:"working",route:w}))},[Y]);c.useEffect(()=>{N(w=>w.ownerKey===Y?w:{ownerKey:Y,mode:"working",route:is}),ie(!1)},[Y]),c.useEffect(()=>{i||ie(!1)},[i]),c.useEffect(()=>{r?.path&&N({ownerKey:ye.current,mode:"working",route:{type:"diff",path:r.path,staged:r.staged}})},[r]);const[ke,xe]=c.useState(null),[we,me]=c.useState(null),[Re,Ae]=c.useState(""),[Te,Se]=c.useState(new Set),[Ce,K]=c.useState(!1),[ge,ne]=c.useState(!1),[he,be]=c.useState([]),[De,Oe]=c.useState([]),[Le,Xe]=c.useState([]),[Ft,$t]=c.useState(null),[xn,fs]=c.useState(null),[rr,yn]=c.useState(0),ms=Tu(),ot=Du({directory:p,branch:g?.current,chooseContributor:ms.choose}),yt=Mu(p,l,f),[ps,Wt]=c.useState(null),[ir,at]=c.useState(!1),[Vt,or]=c.useState([]),[hs,vn]=c.useState("rebase"),pt=c.useCallback((w,V)=>{or(w),vn(V),at(!0)},[]),Ge=g?.current??null,Pe=Xi(w=>w.setOverride),Ye=Xi(w=>w.clearOverride),Ue=tf(p||null,Ge,i&&$==="commit"&&E===!0),Rt=Ue.selectedCommit?.hash??null,ze=bc(p||null,f),gs=c.useMemo(()=>new Set(ze.read?.repository.remotes.map(w=>w.name)??[]),[ze.read]),Ke=sf(p||null,Ge,i&&E===!0,{branches:y,remoteNames:gs,primaryRemote:ze.contexts[0]?.primaryRemote,readContext:ze.contexts[0]??null}),Et=Wd(Ge,Ke.base),Mt=E===!1||Vd(Ge,Ke.base,g!==null,Ke.resolved),Ut=ze.read?.binding?.remotes[0]?.name??ze.read?.repository.remotes.find(w=>w.name==="origin")?.name??ze.read?.repository.remotes[0]?.name??"",vt=ze.read?ze.read.binding?.providers.find(w=>w.readiness==="ready")?.accountId??null:void 0,bs=c.useMemo(()=>xc(A,j,b,w=>({id:"local-config",name:w.userName,...w,color:"info",icon:"user"}),vt),[vt,b,A,j]),wn=c.useMemo(()=>{const w=ze.read;return!w?.binding||ze.status!=="ready"||w.binding.state==="bound"?null:yc(w.binding)?o("gitView.identity.configChanged"):o("gitView.context.needsAttention")},[ze.read,ze.status,o]),qe=qi(w=>n?w.diffRequests.get(n):void 0);c.useEffect(()=>{qe&&N({ownerKey:Y,mode:"pr",route:is})},[Y,qe]);const Fe=nf(p||null,Ge,ze.contexts[0]??null,i&&$==="pr"&&E===!0,qe),ht=Fe.selectedSource;c.useEffect(()=>{!n||!qe||!g||ht!==qe||qi.getState().settleDiffRequest(n,qe)},[qe,n,ht,g]);const Gt=Be(w=>w.currentSessionId),[ar,_t]=c.useState(!1),xs=c.useCallback(()=>{_t(!1),a?.()},[a]),Kt=vc(Gt,n,xs),lr=c.useMemo(()=>$==="pr"?ht:$==="branch"&&Ge&&Ke.base?{kind:"branch",baseRef:Ke.base,headRef:Ge}:$==="commit"&&Rt?{kind:"commit",hash:Rt}:null,[Ke.base,Ge,$,Rt,ht]),We=$==="branch"?Ke.revision:"",Me=Ud(p||null,lr,i&&E===!0,We,Fe.readContext,Fe.provider),{fetchDiff:St,fetchFullFile:$s}=Me,Ws=c.useMemo(()=>Me.files?[...Me.files].sort((w,V)=>w.path.localeCompare(V.path)):null,[Me.files]),gt=J.type==="comparison"&&J.sourceKey===Me.key?J.path:null,[cr,Vs]=c.useState(0),ur=c.useCallback(async w=>{try{const{diff:V}=await St(w),le={original:"",modified:"",isBinary:rf(V)};return le.isBinary||(le.fileDiff=Yi(w,V)),{status:"ready",diff:le}}catch(V){return{status:"error",message:V instanceof Error?V.message:o("diffView.state.failedToLoadDiff")}}},[St,o]),jn=c.useMemo(()=>$==="branch"?Gd(Me.files,We):void 0,[Me.files,We,$]),Us=Kd(Me.files?$==="pr"?JSON.stringify([Me.key,Me.revision]):Me.key:null,i&>?gt:"",i?ur:null,Po,JSON.stringify([$==="pr"?Me.revision:0,cr]),jn),rt=gt?Us.get(gt)??Po:null,[Gs,ys]=c.useState(null),[vs,Ot]=c.useState(null),qt=Gs&&Gs.source===rt?Gs.request:null,Ht=vs&&vs.source===rt?vs.diff:null;c.useEffect(()=>{const w=rt;if(!qt||!gt||w?.status!=="ready"||Ht)return;let V=!1;const le=gt,Ne=async()=>{if($==="pr"){const{original:bt,modified:$e}=await $s(le);return{original:bt,modified:$e,fileDiff:cf({name:le,contents:bt},{name:le,contents:$e})}}const{diff:_e}=await St(le,Mp);return{original:"",modified:"",fileDiff:Yi(le,_e)}};return(async()=>{try{const _e=await Ne();V||Ot({source:w,diff:_e})}catch(_e){if(V)return;de.error(_e instanceof Error?_e.message:o("diffView.state.failedToLoadDiff")),ys(null)}})(),()=>{V=!0}},[rt,gt,Ht,St,$s,$,qt,o]),c.useEffect(()=>{$==="branch"&&Mt&&q("working")},[Mt,q,$]),c.useEffect(()=>{N(w=>w.ownerKey===Y&&w.route.type==="comparison"&&w.route.sourceKey!==Me.key?{...w,route:is}:w)},[Me.key,Y]);const lt=c.useMemo(()=>{const w=g?.files??[],V=new Map;for(const le of w)V.set(le.path,le);return Array.from(V.values()).sort((le,Ne)=>le.path.localeCompare(Ne.path))},[g?.files]),wt=c.useMemo(()=>lt.filter(Op),[lt]),ws=c.useMemo(()=>lt.filter(zp),[lt]),kn=Le,dr=ut(c.useCallback(w=>!p||J.type!=="diff"?null:w.directories.get(p)?.diffCache.get(To(J.path,J.staged))??null,[p,J])),Sn=c.useMemo(()=>J.type!=="diff"?null:lt.find(w=>w.path===J.path)??null,[lt,J]),Qe=c.useCallback(async(w=!0)=>{if(p)try{await Promise.all([z(p,l),U(p,l)])}catch(V){w&&de.error(V instanceof Error?V.message:o("gitView.toast.refreshRepositoryFailed"))}},[p,U,z,l,o]),Nn=c.useMemo(()=>(y?.all??[]).filter(w=>!w.startsWith("remotes/")).sort(),[y]),fr=c.useMemo(()=>(y?.all??[]).filter(w=>w.startsWith("remotes/")).map(w=>w.replace(/^remotes\//,"")).sort(),[y]),Jt=c.useCallback(async w=>{if(!p)return;const V=w.replace(/^remotes\//,"");try{const le=await l.checkoutBranch(p,V);de.success(o("gitView.toast.checkedOut",{name:le.branch||V})),await Qe()}catch(le){de.error(le instanceof Error?le.message:o("gitView.toast.checkoutFailed",{name:V}))}},[p,l,Qe,o]),mr=c.useCallback(w=>{const V=w.replace(/^remotes\//,"");if((g?.files?.length??0)>0){Wt(V);return}Jt(V)},[Jt,g?.files]),pr=c.useCallback(async w=>{if(p)try{await l.createBranch(p,w,Ge??"HEAD"),await l.checkoutBranch(p,w),await Qe()}catch(V){throw de.error(V instanceof Error?V.message:o("gitView.toast.createBranchFailed")),V}},[Ge,p,l,Qe,o]),js=c.useCallback(async()=>{if(!p){Xe([]);return}try{const w=await l.getRemotes(p);Xe(w)}catch{Xe([])}},[p,l]),It=c.useCallback(async()=>{p&&(Promise.allSettled([U(p,l),js()]),await z(p,l).catch(()=>{}))},[p,U,z,l,js]);c.useEffect(()=>{!p||!i||(O(p),M(p,l))},[p,M,l,O,i]),c.useEffect(()=>{i&&js()},[js,i]),c.useEffect(()=>{if(!i||$!=="working"||!p||lt.length===0)return;const w=Array.from(new Set([...wt.map(le=>le.path),...De,...lt.slice(0,20).map(le=>le.path)])).filter(Boolean);if(w.length===0)return;const V=window.setTimeout(()=>{Q(p,l,w,{maxFiles:40})},120);return()=>window.clearTimeout(V)},[lt,p,l,$,Q,wt,De,i]),c.useEffect(()=>{if(!i)return;if(J.type!=="diff"){$t(null);return}const w=To(J.path,J.staged);if(fs(null),!p||te(p,w)){$t(null);return}let V=!1;const le=gn();return $t(null),l.getGitFileDiff(p,{path:J.path,staged:J.staged||void 0}).then(Ne=>{V||ce(p,w,{original:Ne.original??"",modified:Ne.modified??"",isBinary:Ne.isBinary,submodule:Ne.submodule},le)}).catch(Ne=>{if(!V){if(Ne instanceof zi&&Ne.reason!=="path_not_found"){fs({key:`${p}\0${J.path}`,reason:Ne.reason});return}Ne instanceof zi&&z(p,l,{force:!0,silent:!0}),$t(Ne instanceof Error?Ne.message:String(Ne))}}),()=>{V=!0}},[p,rr,z,te,l,J,ce,i]);const Xt=async(w,V,le=!1)=>{if(!p)return;const Ne=yt.start();if(!Ne)return;xe(w);const _e=o(w==="fetch"?"gitView.sync.fetch":w==="pull"?"gitView.sync.pull":w==="publish"?"gitView.publish.title":"gitView.sync.syncChanges");let bt=null;try{if(w==="sync"||w==="publish"){const $e=await ot.prepare(w==="publish"?"push":"sync",{forceChoose:le,onOperation:Ne.onOperation});bt=Tc(await $e())}else if(V&&g)await Dc({action:w,directory:p,remoteName:V.name,status:g,sourceControl:f,git:l,onOperation:Ne.onOperation});else throw new Lt("tracking-required");if(!Ne.isCurrent())return;w==="fetch"&&V?de.success(o("gitView.toast.fetchedFromRemote",{name:V.name})):w==="pull"&&V?de.success(o("gitView.toast.pulledFromRemote",{name:V.name})):w==="sync"?de.success(bt?.kind==="up-to-date"?o("gitView.toast.alreadyUpToDate"):bt?.kind==="pulled"?o("gitView.toast.pulledFromRemote",{name:bt.remoteName}):bt?.kind==="pushed"?o("gitView.toast.pushedToUpstream",{name:bt.remoteName}):o("gitView.toast.syncedChanges")):w==="publish"&&de.success(o("gitView.publish.succeeded")),await It()}catch($e){if($e instanceof Ln||$e instanceof Dr){if(Ne.isCurrent()&&await It(),Ne.isCurrent()&&$e instanceof Ln&&$e.read.availability==="available"&&$e.read.operation.state==="conflicted"&&$e.read.operation.error.code==="CONFLICT"){const Js=((await l.getGitStatus(p).catch(()=>null))?.files??[]).filter(jr).map(En=>En.path);Js.length>0&&pt(Js,"merge")}return}if($e instanceof Lt&&$e.code==="stale-runtime")return;if($e instanceof Lt&&ot.errorMessage($e)){de.info(ot.errorMessage($e));return}await It(),de.error($e instanceof Lt?$e.code==="contributor-publish-cancelled-after-update"?o("gitView.toast.contributorPublishCancelledAfterUpdate"):$e.code==="contributor-publish-cancelled"?o("gitView.toast.contributorPublishCancelled"):o("gitView.toast.syncActionFailed",{action:_e}):$e instanceof Error?$e.message:o("gitView.toast.syncActionFailed",{action:_e}))}finally{Ne.finish(),Ne.isCurrent()&&xe(null)}},Yt=c.useCallback(async(w,V)=>{if(!(!p||w.length===0))try{V==="stage"?w.length>1?await wc(p,w):await jc(p,w[0]):w.length>1?await kc(p,w):await Sc(p,w[0]),await Qe(!1)}catch(le){de.error(le instanceof Error?le.message:o(V==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed"))}},[p,Qe,o]),At=c.useCallback((w,V=!1)=>{se({type:"diff",path:w,staged:V})},[se]),Ks=c.useCallback(async w=>{if(p){Se(V=>new Set(V).add(w));try{await l.revertGitFile(p,w),de.success(o("gitView.toast.revertedFile",{path:w})),await Qe(!1)}catch(V){de.error(V instanceof Error?V.message:o("gitView.toast.revertFailed"))}finally{Se(V=>{const le=new Set(V);return le.delete(w),le})}}},[p,l,Qe,o]),Cn=c.useCallback(async w=>{if(!p||w.length===0||Ce)return;const V=Array.from(new Set(w));K(!0),Se(new Set(V));try{const le=await Tp(V,Ne=>l.revertGitFile(p,Ne),_p);if(await Qe(!1),le.failures.length===0)de.success(V.length===1?o("gitView.toast.revertedFilesSingle",{count:V.length}):o("gitView.toast.revertedFilesPlural",{count:V.length}));else if(le.failures.length===V.length)de.error(le.failures[0]?.error?.message??o("gitView.toast.revertFailed"));else{const Ne=V.length-le.failures.length;de.warning(Ne===1?o("gitView.toast.revertedSomeSingle",{success:Ne,failed:le.failures.length}):o("gitView.toast.revertedSomePlural",{success:Ne,failed:le.failures.length}))}}catch(le){de.error(le instanceof Error?le.message:o("gitView.toast.revertFailed"))}finally{Se(new Set),K(!1)}},[p,l,Ce,Qe,o]),hr=c.useCallback(w=>{const V=w.map(le=>le.trim()).filter(Boolean);if(V.length===0){be([]);return}Ae(le=>`${le.trim()}${le.trim()?`
|
|
23
|
-
|
|
24
|
-
`:""}${V.join(`
|
|
25
|
-
`)}`.trim()),be([])},[]),gr=c.useCallback(async()=>{if(!p)return;const w=wt.map(V=>V.path).sort();if(w.length===0){de.error(o("gitView.toast.selectFileToDescribe"));return}ne(!0);try{const{message:V}=await Gi(p,w);Ae(V.subject?.trim()??""),be(Array.isArray(V.highlights)?V.highlights:[])}catch(V){de.error(V instanceof Error?V.message:o("gitView.toast.generateCommitMessageFailed"))}finally{ne(!1)}},[p,wt,o]),qs=async(w={})=>{if(!p)return;if(!Re.trim()){de.error(o("gitView.toast.enterCommitMessage"));return}const V=wt.map(_e=>_e.path).sort();if(V.length===0){de.error(o("gitView.toast.selectFileToCommit"));return}me(w.pushAfter?"commitAndPush":"commit");let le=null,Ne="pending";try{if(await l.createGitCommit(p,Re.trim(),{files:V}),Ne="local",de.success(o("gitView.toast.commitCreated")),Ae(""),be([]),w.pushAfter){if(le=yt.start(),!le){de.warning(o("gitView.publish.commitKept")),await It();return}const _e=await ot.prepare("push",{onOperation:le.onOperation});xe("publish"),await _e(),Ne="published",de.success(o("gitView.publish.succeeded"))}await It()}catch(_e){if(w.pushAfter&&Ne==="local"&&de.warning(o("gitView.publish.commitKept")),_e instanceof Ln||_e instanceof Dr){await It();return}if(_e instanceof Lt&&_e.code==="stale-runtime")return;if(_e instanceof Lt&&ot.errorMessage(_e)){de.info(ot.errorMessage(_e));return}w.pushAfter&&await It(),de.error(_e instanceof Lt?_e.code==="contributor-publish-cancelled-after-update"?o("gitView.toast.contributorPublishCancelledAfterUpdate"):_e.code==="contributor-publish-cancelled"?o("gitView.toast.contributorPublishCancelled"):o("gitView.toast.syncActionFailed",{action:o("gitView.sync.syncChanges")}):_e instanceof Error?_e.message:o("gitView.toast.createCommitFailed"))}finally{le?.finish(),me(null),w.pushAfter&&xe(null)}},Ci=c.useMemo(()=>(g?.files??[]).filter(jr).length,[g?.files]),Qt=!!g?.mergeInProgress?.head,ks=c.useCallback(async()=>{if(p)try{if(Qt){const w=await l.continueMerge(p);w.conflict?(pt(w.conflictFiles??[],"merge"),de.error(o("gitView.toast.mergeConflictsDetected"))):de.success(o("gitView.toast.mergeCompleted"))}else{const w=await l.continueRebase(p);w.conflict?(pt(w.conflictFiles??[],"rebase"),de.error(o("gitView.toast.rebaseConflictsDetected"))):de.success(o("gitView.toast.rebaseStepCompleted"))}await Qe(!1)}catch(w){de.error(w instanceof Error?w.message:o("gitView.toast.continueOperationFailed"))}},[p,l,Qt,pt,Qe,o]),Zt=c.useCallback(async w=>{if(p)try{w==="merge"?(await l.abortMerge(p),de.success(o("gitView.toast.mergeAborted"))):(await l.abortRebase(p),de.success(o("gitView.toast.rebaseAborted"))),await Qe(!1)}catch(V){de.error(V instanceof Error?V.message:o("gitView.toast.abortOperationFailed"))}},[p,l,Qe,o]),Ss=c.useCallback(()=>{const w=(g?.files??[]).filter(jr).map(V=>V.path);pt(w,Qt?"merge":"rebase")},[Qt,pt,g?.files]),es=c.useMemo(()=>{const w=[];return wt.length>0&&w.push({id:"staged",title:o("gitView.changes.stagedTitle"),entries:wt,statsScope:"staged",actionSymbol:"-",actionAllLabel:o("gitView.changes.unstageAllAria"),getActionLabel:V=>o("gitView.changes.unstageFileAria",{path:V}),onActionFile:V=>{Yt([V],"unstage")},onActionAll:V=>{Yt(V,"unstage")},onViewDiff:V=>At(V,!0),onRevertFile:Ks,showRevertActions:!1,accent:!0}),ws.length>0&&w.push({id:"unstaged",title:o("gitView.changes.title"),entries:ws,statsScope:"working",actionSymbol:"+",actionAllLabel:o("gitView.changes.stageAllAria"),getActionLabel:V=>o("gitView.changes.stageFileAria",{path:V}),onActionFile:V=>{Yt([V],"stage")},onActionAll:V=>{Yt(V,"stage")},onViewDiff:V=>At(V,!1),onRevertFile:Ks}),w},[Ks,At,Yt,wt,o,ws]),Rn=t.jsxs(t.Fragment,{children:[ot.context?t.jsx(_u,{context:ot.context,onSelect:ot.settle}):null,ot.confirmDialog,t.jsx(Ou,{candidates:ms.candidates,onSelect:ms.settle})]}),ts=w=>t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[Rn,t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[s?t.jsx("button",{type:"button",className:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(X,{name:"close",className:"size-5"})}):null,t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[t.jsx("h2",{className:"typography-ui-label text-foreground",children:o("mobile.nav.changes")}),t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:g?.current||p||""})]}),d===!1&&Array.isArray(h)&&h.length>0?t.jsx(Uu,{repositories:h,selectedRepository:m??null,onSelectRepository:V=>{n&&F(n,V)},repositoryRoot:n??void 0}):null]}),t.jsx("div",{className:"min-h-0 flex-1",children:w})]});if(!p)return ts(t.jsx(mt,{message:o("gitView.empty.selectSessionOrDirectory")}));if(d===!1&&E!==!0)return ts(t.jsx(Ku,{root:n,rootIsGitRepo:d,resolvedIsGitRepo:E,nestedRepos:h,onRetryDiscovery:()=>{n&&G(n,{force:!0})}}));if(T&&E===null)return ts(t.jsx(mt,{loading:!0,message:o("gitView.loading.checkingRepository")}));if(J.type==="diff")return t.jsx(Do,{path:J.path,diff:dr,staged:J.staged,fileExists:!!Sn,unavailableReason:xn?.key===`${p}\0${J.path}`?xn.reason:null,error:Ft,onBack:()=>se({type:"list"}),onRetry:()=>yn(w=>w+1)});const Hs=o($==="pr"?Tn("session.githubIntegration.tabs.pullRequests",Fe.provider):$==="branch"?"diffView.scope.branch":$==="commit"?"commitComparison.mode":"mobile.nav.changes"),ss=$==="branch"&&Ke.base?zu(Ke.base):$==="commit"?Rt?.slice(0,8):$==="pr"&&ht?`#${ht.number}`:null;if(gt&&rt)return t.jsx(Do,{path:gt,subtitle:[Hs,ss].filter(Boolean).join(" · "),diff:Ht??(rt.status==="ready"?rt.diff:null),fileExists:!Me.files||Me.files.some(w=>w.path===gt),error:Me.error??(rt.status==="error"?rt.message:null),onBack:()=>se(is),onRetry:()=>{Me.error&&Me.refresh(),Vs(w=>w+1)},onExpandContextRequest:rt.status==="ready"?w=>ys({source:rt,request:w}):void 0,pendingContextExpansion:qt,contextLoading:qt!==null&&!Ht});const zt=()=>$==="pr"&&!ht?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(mt,{loading:Fe.loading,message:Fe.error??(Fe.loading?o(Tn("session.githubPrPicker.loading.pullRequests",Fe.provider)):o(Tn("pullRequestComparison.select",Fe.provider)))}),!Fe.loading&&t.jsx(Qi,{mobile:!0,comparison:Fe})]}):$==="branch"&&!Ke.base?t.jsx(mt,{loading:!Ke.resolved,message:Ke.resolved?o("gitView.pr.toast.baseBranchRequired"):o("diffView.branch.resolvingBase")}):$==="commit"&&!Rt?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[Ue.loading&&t.jsx(X,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:Ue.loading?o("diffView.state.loadingChanges"):Ue.error??o("commitComparison.noCommits")}),Ue.error&&t.jsx(Ee,{variant:"outline",size:"lg",onClick:()=>{Ue.refresh()},children:o("diffView.actions.retry")})]}):Me.error?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx("p",{className:"typography-ui-label font-semibold",children:o("diffView.state.failedToLoadDiff")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:Me.error}),t.jsx(Ee,{variant:"outline",size:"lg",onClick:()=>{Me.refresh()},children:o("diffView.actions.retry")})]}):Ws?Ws.length===0?t.jsx(mt,{icon:$==="branch",message:$==="pr"?o("walkthrough.blocked.emptyDiff.description"):$==="commit"?o("commitComparison.emptyDiff"):o("diffView.branch.empty",{base:ss??""})}):t.jsx(Fp,{files:Ws,onSelect:w=>{Me.key&&se({type:"comparison",path:w,sourceKey:Me.key})}}):t.jsx(mt,{loading:!0,message:o("diffView.state.loadingChanges")});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[Rn,t.jsxs("header",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b border-border/60 px-3 py-2",children:[s?t.jsx("button",{type:"button",className:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(X,{name:"close",className:"size-5"})}):null,t.jsxs(Mr,{open:ae,onOpenChange:ie,children:[t.jsx(_r,{asChild:!0,children:t.jsxs(Ee,{variant:"outline",className:Nc({size:"mobile"}),"data-mobile-comparison-trigger":!0,"aria-label":o("diffView.scope.selectorAria"),children:[t.jsx("span",{children:Hs}),t.jsx(X,{name:"arrow-down-s",className:"size-4"})]})}),t.jsx(Or,{align:"start",children:t.jsxs(Cc,{value:$,onValueChange:w=>{(w==="working"||w==="branch"||w==="commit"||w==="pr")&&q(w)},children:[t.jsx(Dn,{value:"working",className:"min-h-8 items-center",children:o("mobile.nav.changes")}),Et&&t.jsx(Dn,{value:"branch",className:"min-h-8 items-center",children:o("diffView.scope.branch")}),t.jsx(Dn,{value:"commit",className:"min-h-8 items-center",children:o("commitComparison.mode")}),t.jsx(Dn,{value:"pr",className:"min-h-8 items-center",children:o(Tn("session.githubIntegration.tabs.pullRequests",Fe.provider))})]})})]}),i&&$==="branch"&&t.jsx(of,{mobile:!0,branches:y?.all??[],currentBranch:Ge,base:Ke.base,automatic:Ke.source!=="chosen",onSelect:w=>{Ge&&Pe(p,Ge,w)},onSelectAutomatic:()=>{Ge&&Ye(p,Ge)}},JSON.stringify([Y,Ge])),i&&$==="commit"&&t.jsx(af,{mobile:!0,commits:Ue.commits,selectedHash:Rt,loading:Ue.loading,error:Ue.error,onSelect:Ue.select,onRefresh:()=>{Ue.refresh()}},JSON.stringify([Y,Ge])),i&&$==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(Qi,{mobile:!0,comparison:Fe},JSON.stringify([Y,Ge])),ht&&t.jsx(Ee,{variant:"ghost",size:"sm",disabled:Me.loading,"aria-label":o("session.githubIssuePicker.actions.refresh"),onClick:()=>{Me.refresh()},children:t.jsx(X,{name:"refresh",className:"size-4"})})]}),$==="working"&&Gt&&(g?.files?.length??0)>0?t.jsxs(Ee,{variant:"default",className:"ms-auto shrink-0",disabled:Kt.submitting,onClick:()=>_t(!0),"aria-label":o("diffView.actions.reviewAria"),style:{touchAction:"manipulation"},children:[t.jsx(X,{name:Kt.submitting?"loader-4":"search-eye",className:ee("size-4",Kt.submitting&&"animate-spin")}),o("diffView.actions.review")]}):null]}),t.jsx(Rc,{open:ar,onOpenChange:_t,projectDirectory:n||null,submitting:Kt.submitting,onConfirm:Kt.start}),$==="working"&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 px-3 py-2",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(Bu,{currentBranch:g?.current,localBranches:Nn,remoteBranches:fr,branchInfo:y?.branches,currentBranchAhead:g?.ahead,onCheckout:w=>{mr(w)},onCreate:pr,disabled:T,directory:p,switchBlockedNotice:(g?.files?.length??0)>0?o("gitView.branch.switchBlockedNotice"):null})}),t.jsx(Lu,{activeProfile:bs,identities:L,attention:wn,triggerClassName:"max-w-[10rem] shrink [&_.git-identity-label]:hidden sm:[&_.git-identity-label]:inline",onOpen:()=>{P(f,A.map(w=>w.account))},onSelect:w=>{_(w)},isApplying:C,onConfigure:()=>R(!0),applicability:w=>{const V=ze.read?.repository.remotes.find(le=>le.name===Ut);return V?Fu(w,Ec(V.fetch.displayUrl)):{applicable:!0}}}),t.jsx($u,{syncAction:yt.entry?.executing?ke:null,remotes:kn,onFetch:w=>{Xt("fetch",w)},onPull:w=>{Xt("pull",w)},onSync:w=>{Xt("sync",w)},onPublish:()=>{Xt("publish")},onChooseSyncTargets:()=>{Xt("sync",void 0,!0)},currentBranch:g?.current,hasTracking:!!g?.tracking,disabled:T||yt.blocked,aheadCount:g?.ahead??0,behindCount:g?.behind??0,trackingRemoteName:g?.tracking?.split("/")[0],trackingBranch:g?.tracking,hasUncommittedChanges:Wu(lt),choosesPushDestination:x})]}),t.jsx(Jd,{open:S,onOpenChange:R,directory:p}),t.jsx(Vu,{className:"mx-3 mt-3",entry:yt.entry,onRefresh:()=>{yt.refresh()},onCancel:()=>{yt.cancel()}}),$==="working"&&t.jsx(Xd,{mergeInProgress:g?.mergeInProgress,rebaseInProgress:g?.rebaseInProgress,onContinue:ks,onAbort:()=>Zt(Qt?"merge":"rebase"),onResolveWithAI:Ss,conflictCount:Ci,isLoading:ke!==null||we!==null}),$!=="working"?t.jsx("div",{className:"min-h-0 flex-1",children:zt()}):lt.length>0?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden px-4 pt-4",children:t.jsx(Yd,{groups:es,diffStats:g?.diffStats,revertingPaths:Te,onRevertAll:Cn,isRevertingAll:Ce,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:Oe})}),t.jsx("div",{className:"shrink-0 border-t border-border/70 px-4 pb-4 pt-3",children:t.jsx(Qd,{stagedCount:wt.length,commitMessage:Re,onCommitMessageChange:Ae,generatedHighlights:he,onInsertHighlights:hr,onGenerateMessage:gr,isGeneratingMessage:ge,onCommit:()=>{qs({pushAfter:!1})},onCommitAndPush:()=>{qs({pushAfter:!0})},commitAction:we,networkOperationBlocked:yt.blocked,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(mt,{icon:!0,message:o("gitView.empty.cleanTitle"),description:o("mobile.changes.cleanDescription")})}),p&&t.jsx(Zd,{open:ir,onOpenChange:at,conflictFiles:Vt,directory:p,operation:hs,onAbort:()=>{Zt(hs)},onNavigatedToChat:a}),t.jsx(ef,{open:ps!==null,onOpenChange:w=>{w||Wt(null)},targetBranch:ps??"",changedFileCount:g?.files?.length??0,onCommitAndSwitch:(w,V)=>Dp(w,V,{targetBranch:ps,directory:p,sourceBranch:g?.current??null,git:l,publishChooser:ot,toast:de,t:o,refreshStatusAndBranches:Qe,closeDialog:()=>Wt(null),performCheckout:Jt}),onGenerateMessage:async()=>{if(!p)return"";const w=(g?.files??[]).map(le=>le.path).sort(),{message:V}=await Gi(p,w);return V.subject?.trim()??""},onRevertAndSwitch:async()=>{const w=ps;if(!w||!p)return;await Cn((g?.files??[]).map(le=>le.path));const V=await l.getGitStatus(p);if(!V.isClean&&(V.files?.length??0)>0){de.error(o("gitView.dirtySwitch.revertIncomplete"));return}Wt(null),await Jt(w)}})]})},mt=n=>{const e=fe.c(13),{message:s,description:r,loading:i,icon:a}=n,o=i===void 0?!1:i,l=a===void 0?!1:a;let f;e[0]!==o?(f=o?t.jsx(X,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,e[0]=o,e[1]=f):f=e[1];let d;e[2]!==l?(d=l?t.jsx(X,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e[2]=l,e[3]=d):d=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 h;e[6]!==r?(h=r?t.jsx("p",{className:"typography-meta text-muted-foreground",children:r}):null,e[6]=r,e[7]=h):h=e[7];let p;return e[8]!==f||e[9]!==d||e[10]!==m||e[11]!==h?(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,d,m,h]})}),e[8]=f,e[9]=d,e[10]=m,e[11]=h,e[12]=p):p=e[12],p},Do=n=>{const e=fe.c(55),{path:s,subtitle:r,diff:i,staged:a,fileExists:o,unavailableReason:l,error:f,onBack:d,onRetry:m,onExpandContextRequest:h,pendingContextExpansion:p,contextLoading:g}=n,x=a===void 0?!1:a,y=l===void 0?null:l,{t:b}=ve();let S;e[0]!==s?(S=Ic(s)||"text",e[0]=s,e[1]=S):S=e[1];const R=S,C=Ve($p),D=Ve(Wp);let A;e[2]!==C||e[3]!==b?(A=b(C?"diffView.whitespace.hidden":"diffView.whitespace.shown"),e[2]=C,e[3]=b,e[4]=A):A=e[4];const j=A;let k;e[5]!==b?(k=b("header.actions.backAria"),e[5]=b,e[6]=k):k=e[6];let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(X,{name:"arrow-left",className:"size-5"}),e[7]=v):v=e[7];let I;e[8]!==d||e[9]!==k?(I=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":k,onClick:d,children:v}),e[8]=d,e[9]=k,e[10]=I):I=e[10];let P;e[11]!==s?(P=t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:s}),e[11]=s,e[12]=P):P=e[12];let L;e[13]!==r?(L=r&&t.jsx("p",{className:"truncate typography-meta text-muted-foreground",children:r}),e[13]=r,e[14]=L):L=e[14];let _;e[15]!==P||e[16]!==L?(_=t.jsxs("div",{className:"min-w-0 flex-1 px-2",children:[P,L]}),e[15]=P,e[16]=L,e[17]=_):_=e[17];const E=C?"text-foreground":"text-muted-foreground";let T;e[18]!==E?(T=ee("flex size-9 shrink-0 items-center justify-center rounded-lg hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",E),e[18]=E,e[19]=T):T=e[19];let O;e[20]!==b?(O=b("diffView.actions.hideWhitespace"),e[20]=b,e[21]=O):O=e[21];let M;e[22]!==C||e[23]!==D?(M=()=>D(!C),e[22]=C,e[23]=D,e[24]=M):M=e[24];let G;e[25]!==C?(G=t.jsx(Hd,{hidden:C,className:"size-5"}),e[25]=C,e[26]=G):G=e[26];let F;e[27]!==C||e[28]!==T||e[29]!==O||e[30]!==M||e[31]!==G||e[32]!==j?(F=t.jsx("button",{type:"button",className:T,"aria-label":O,"aria-pressed":C,title:j,onClick:M,children:G}),e[27]=C,e[28]=T,e[29]=O,e[30]=M,e[31]=G,e[32]=j,e[33]=F):F=e[33];let z;e[34]!==_||e[35]!==F||e[36]!==I?(z=t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/70 px-3 text-foreground",children:[I,_,F]}),e[34]=_,e[35]=F,e[36]=I,e[37]=z):z=e[37];let U;e[38]!==g||e[39]!==i||e[40]!==f||e[41]!==o||e[42]!==C||e[43]!==R||e[44]!==h||e[45]!==m||e[46]!==s||e[47]!==p||e[48]!==x||e[49]!==b||e[50]!==y?(U=t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:o?y==="nested_repository"?t.jsx(mt,{icon:!0,message:b("diffView.unavailable.nestedRepositoryTitle"),description:b("diffView.unavailable.nestedRepositoryDescription")}):y==="untracked_directory"?t.jsx(mt,{icon:!0,message:b("diffView.unavailable.untrackedDirectoryTitle"),description:b("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:b("mobile.changes.diffDetail.loadFailed")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:f}),t.jsx(Ee,{type:"button",size:"sm",variant:"outline",onClick:m,children:b("diffView.actions.retry")})]})}):i?i.submodule?t.jsx("div",{className:"p-3",children:t.jsx(qd,{state:i.submodule,staged:x})}):i.isBinary?t.jsx(mt,{icon:!0,message:b("diffView.binary.unavailable")}):Ac(s)&&!i.fileDiff?t.jsx(mt,{icon:!0,message:b("mobile.changes.diffDetail.imageUnavailable")}):t.jsx(er,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:t.jsx(lf,{original:i.original,modified:i.modified,fileDiff:i.fileDiff,language:R,fileName:s,renderSideBySide:!1,wrapLines:!0,hideWhitespace:C,layout:"inline",onExpandContextRequest:h,pendingContextExpansion:p,contextLoading:g})}):t.jsx(mt,{loading:!0,message:b("diffView.state.loadingDiff")}):t.jsx(mt,{icon:!0,message:b("mobile.changes.diffDetail.missingTitle"),description:b("mobile.changes.diffDetail.missingDescription")})}),e[38]=g,e[39]=i,e[40]=f,e[41]=o,e[42]=C,e[43]=R,e[44]=h,e[45]=m,e[46]=s,e[47]=p,e[48]=x,e[49]=b,e[50]=y,e[51]=U):U=e[51];let Q;return e[52]!==z||e[53]!==U?(Q=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[z,U]}),e[52]=z,e[53]=U,e[54]=Q):Q=e[54],Q},Fp=n=>{const e=fe.c(12),{files:s,onSelect:r}=n,{t:i}=ve();let a;e[0]!==i?(a=i("gitView.changes.changedFilesAria"),e[0]=i,e[1]=a):a=e[1];let o;if(e[2]!==s||e[3]!==r||e[4]!==i){let f;e[6]!==r||e[7]!==i?(f=d=>{const m=d.status==="A"?i("diffView.change.new"):d.status==="D"?i("diffView.change.deleted"):d.status==="R"?i("diffView.change.renamed"):d.status==="C"?i("diffView.change.copied"):i("diffView.change.modified"),h=d.status==="A"?"var(--status-success)":d.status==="D"?"var(--status-error)":d.status==="R"||d.status==="C"?"var(--status-info)":"var(--status-warning)";return t.jsx("li",{children:t.jsxs(Ee,{variant:"ghost",size:"lg",className:"w-full justify-start gap-2.5 text-start normal-case",onClick:()=>r(d.path),children:[t.jsx("span",{className:"w-4 shrink-0 text-center typography-meta font-semibold uppercase",style:{color:h},"aria-label":m,children:d.status}),t.jsx(ua,{filePath:d.path,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label",title:d.path,children:d.path}),(d.insertions>0||d.deletions>0)&&t.jsxs("span",{className:"shrink-0 typography-meta text-muted-foreground",children:["+",d.insertions," -",d.deletions]}),t.jsx(X,{name:"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground"})]})},d.path)},e[6]=r,e[7]=i,e[8]=f):f=e[8],o=s.map(f),e[2]=s,e[3]=r,e[4]=i,e[5]=o}else o=e[5];let l;return e[9]!==a||e[10]!==o?(l=t.jsx(er,{className:"h-full overflow-y-auto overflow-x-hidden px-3 py-2",children:t.jsx("ul",{"aria-label":a,className:"flex flex-col gap-1",children:o})}),e[9]=a,e[10]=o,e[11]=l):l=e[11],l};function $p(n){return n.diffHideWhitespace}function Wp(n){return n.setDiffHideWhitespace}const Vp=c.lazy(()=>Ms(()=>import("./FilesView-DMNYEydF.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129])).then(n=>({default:n.FilesView}))),kt=n=>bn(n)??"",un=n=>{const e=kt(n);return!e||e==="/"?e||"/":e.split("/").filter(Boolean).at(-1)??e},Up=n=>{const e=kt(n);if(!e||e==="/")return null;const s=e.lastIndexOf("/");return s<=0?e.startsWith("/")?"/":null:e.slice(0,s)},Gp=(n,e)=>{const s=kt(n),r=kt(e);return!r||s===r?un(s):s.startsWith(`${r}/`)?s.slice(r.length+1):s},Kp=n=>{if(typeof n!="number"||!Number.isFinite(n)||n<0)return"";if(n<1024)return`${n} B`;const e=["KB","MB","GB"];let s=n/1024;for(const r of e){if(s<1024||r===e[e.length-1])return`${s.toFixed(s>=10?0:1)} ${r}`;s/=1024}return""},qp=n=>{const e=fe.c(6),{onClose:s,visible:r}=n,i=r===void 0?!0:r,a=Zr()??null;let o;e[0]!==a?(o=kt(a),e[0]=a,e[1]=o):o=e[1];const l=o;let f;return e[2]!==s||e[3]!==l||e[4]!==i?(f=t.jsx(Hp,{root:l,onClose:s,visible:i},l),e[2]=s,e[3]=l,e[4]=i,e[5]=f):f=e[5],f},Hp=({root:n,onClose:e,visible:s})=>{const{t:r}=ve(),{files:i}=Zn(),a=xl(),o=yl(N=>N.setSelectedPath),[l,f]=c.useState(()=>({type:"browser",directory:n})),[d,m]=c.useState([]),[h,p]=c.useState(!1),[g,x]=c.useState(null),[y,b]=c.useState(""),[S,R]=c.useState([]),[C,D]=c.useState(!1),A=c.useRef(0),j=l.type==="browser"?l.directory:l.returnDirectory,k=c.useRef(j);k.current=j;const v=c.useCallback(async(N,$)=>{if(!N)return;const J=!a,ae=A.current+1;A.current=ae,p(!0),$?.background||x(null);try{const ie=await i.listDirectory(N,{respectGitignore:J});if(A.current!==ae)return;x(null),m(ie.entries.slice().sort((q,se)=>q.isDirectory!==se.isDirectory?q.isDirectory?-1:1:q.name.localeCompare(se.name)))}catch(ie){if(A.current!==ae)return;if($?.background){console.error("Failed to reload mobile directory:",ie);return}m([]),x(ie instanceof Error?ie.message:r("mobile.files.error.listFailed"))}finally{A.current===ae&&p(!1)}},[i,a,r]);c.useEffect(()=>{l.type==="browser"&&v(l.directory)},[v,l]);const I=c.useRef(l);I.current=l;const P=c.useRef(d);P.current=d;const L=c.useCallback(({directories:N})=>{const $=I.current;$.type==="browser"&&(N&&!N.some(J=>kt(J)===kt($.directory))||P.current.length>qu||v($.directory,{background:!0}))},[v]);Hu({root:n,active:s,whileInactive:"hold",onChanges:L});const _=c.useCallback(async N=>{kt(N)===kt(k.current)&&await v(k.current)},[v]),{canUpload:E,uploadingDirectory:T,pickFiles:O,uploadElements:M}=Ju({root:n,refreshDirectory:_}),G=T!==null;c.useEffect(()=>{if(l.type!=="browser")return;const N=y.trim();if(!N){R([]),D(!1);return}let $=!1;const J=window.setTimeout(()=>{D(!0),i.search({directory:l.directory,query:N,maxResults:40}).then(ae=>{$||R(ae)}).catch(()=>{$||R([])}).finally(()=>{$||D(!1)})},250);return()=>{$=!0,window.clearTimeout(J)}},[i,y,l]);const F=N=>{b(""),f({type:"browser",directory:N})},z=N=>{o(n,N),f({type:"file",path:N,returnDirectory:j||n})},U=Ve(N=>N.pendingFileFocusPath),Q=Ve(N=>N.pendingFileNavigation);if(c.useEffect(()=>{const N=kt(Q?.path??U??"");!N||!n||(o(n,N,{allowOutsideRoot:!0}),f({type:"file",path:N,returnDirectory:n}),U&&Ve.getState().setPendingFileFocusPath(null))},[U,Q,n,o]),!n)return t.jsx(dn,{message:r("mobile.files.empty.noDirectory")});if(l.type==="file")return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/70 px-3 text-foreground",children:[t.jsx("button",{type:"button",className:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":r("header.actions.backAria"),onClick:()=>f({type:"browser",directory:l.returnDirectory}),style:{touchAction:"manipulation"},children:t.jsx(Ji,{className:"size-5"})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:un(l.path)})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(et,{children:t.jsx(c.Suspense,{fallback:t.jsx(dn,{loading:!0,message:r("filesView.state.loading")}),children:t.jsx(Vp,{mode:"editor-only"})})})})]});const te=l.directory===n?r("mobile.files.rootDirectory"):un(l.directory),ce=y.trim()?S:[],re=Up(l.directory),Y=l.directory!==n&&re!==null&&(re===n||re.startsWith(`${n}/`)),ye=Y&&!y.trim(),Z=Y?re:null;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[M,t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[e?t.jsx("button",{type:"button",className:"-ms-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":r("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(Id,{className:"size-5"})}):null,ye&&Z?t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":r("mobile.files.backToParentAria",{name:un(Z)}),onClick:()=>F(Z),style:{touchAction:"manipulation"},children:t.jsx(Ji,{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:te})}),t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":r("mobile.files.refreshAria"),onClick:()=>{v(l.directory)},style:{touchAction:"manipulation"},children:t.jsx(Ad,{className:ee("size-5",h&&"animate-spin")})}),E?t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50","aria-label":r("sidebarFilesTree.actions.uploadFilesTitle"),onClick:()=>O(l.directory),disabled:G,style:{touchAction:"manipulation"},children:t.jsx(X,{name:G?"loader-4":"upload-2",className:ee("size-5",G&&"animate-spin")})}):null]}),t.jsx("div",{className:"shrink-0 px-4 pb-2 pt-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(Pd,{className:"pointer-events-none absolute inset-s-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(ra,{value:y,onChange:N=>b(N.target.value),placeholder:r("mobile.files.search.placeholder"),className:"h-11 ps-9"})]})}),t.jsx(er,{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-3",children:g?t.jsx(dn,{message:g}):y.trim()?t.jsx(Jp,{results:ce,isSearching:C,onOpenFile:z}):t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:[d.length===0&&!h?t.jsx("div",{className:"px-4 py-8 text-center typography-body text-muted-foreground",children:r("mobile.files.empty.directory")}):null,d.map(N=>t.jsx(el,{name:N.name,path:N.path,directory:N.isDirectory,meta:N.isDirectory?void 0:Kp(N.size),onClick:()=>N.isDirectory?F(N.path):z(N.path)},N.path))]})})]})},el=n=>{const e=fe.c(16),{name:s,path:r,directory:i,meta:a,onClick:o}=n;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={touchAction:"manipulation"},e[0]=l):l=e[0];let f;e[1]!==i||e[2]!==r?(f=i?t.jsx(Md,{className:"size-5 shrink-0 text-primary/80"}):t.jsx(ua,{filePath:r,className:"size-5 shrink-0"}),e[1]=i,e[2]=r,e[3]=f):f=e[3];let d;e[4]!==s?(d=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:s}),e[4]=s,e[5]=d):d=e[5];let m;e[6]!==a?(m=a?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:a}):null,e[6]=a,e[7]=m):m=e[7];let h;e[8]!==i?(h=i?t.jsx(_d,{className:"size-4 shrink-0 text-muted-foreground/60"}):null,e[8]=i,e[9]=h):h=e[9];let p;return e[10]!==o||e[11]!==f||e[12]!==d||e[13]!==m||e[14]!==h?(p=t.jsxs("button",{type:"button",className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3 py-2.5 text-start transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:o,style:l,children:[f,d,m,h]}),e[10]=o,e[11]=f,e[12]=d,e[13]=m,e[14]=h,e[15]=p):p=e[15],p},Jp=n=>{const e=fe.c(10),{results:s,isSearching:r,onOpenFile:i}=n,{t:a}=ve(),o=kt(Zr()??null);if(r){let m;e[0]!==a?(m=a("common.loading"),e[0]=a,e[1]=m):m=e[1];let h;return e[2]!==m?(h=t.jsx(dn,{loading:!0,message:m}),e[2]=m,e[3]=h):h=e[3],h}if(s.length===0){let m;e[4]!==a?(m=a("mobile.files.search.empty"),e[4]=a,e[5]=m):m=e[5];let h;return e[6]!==m?(h=t.jsx(dn,{message:m}),e[6]=m,e[7]=h):h=e[7],h}const l="overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",f=s.map(m=>t.jsx(el,{name:un(m.path),path:m.path,directory:!1,meta:Gp(m.path,o),onClick:()=>i(m.path)},m.path));let d;return e[8]!==f?(d=t.jsx("div",{className:l,children:f}),e[8]=f,e[9]=d):d=e[9],d},dn=n=>{const e=fe.c(7),{message:s,loading:r}=n,i=r===void 0?!1:r;let a;e[0]!==i?(a=i?t.jsx(Td,{className:"size-5 animate-spin text-muted-foreground"}):t.jsx(Dd,{className:"size-6 text-muted-foreground"}),e[0]=i,e[1]=a):a=e[1];let o;e[2]!==s?(o=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[2]=s,e[3]=o):o=e[3];let l;return e[4]!==a||e[5]!==o?(l=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[a,o]})}),e[4]=a,e[5]=o,e[6]=l):l=e[6],l},Mo="mobile-surface-root",Xp=16,_o=320,Yp="cubic-bezier(0.22, 1, 0.36, 1)",Qp=n=>{const e=fe.c(38),{onOpenMcpSettings:s,active:r}=n,{t:i}=ve(),[a,o]=c.useState(!1),l=Dt(eh),f=Cs(th),d=Ps(sh);let m;e[0]!==l||e[1]!==a||e[2]!==d||e[3]!==f?(m=()=>{if(a)return;o(!0);const L=new Promise(nh);Promise.all([f({directory:l||null,silent:!0}),d({force:!0}),L]).finally(()=>o(!1))},e[0]=l,e[1]=a,e[2]=d,e[3]=f,e[4]=m):m=e[4];const h=m;let p;e[5]!==i?(p=i("settings.mcp.sidebar.actions.addServerTitle"),e[5]=i,e[6]=p):p=e[6];let g;e[7]!==i?(g=i("settings.mcp.sidebar.actions.addServerTitle"),e[7]=i,e[8]=g):g=e[8];let x,y;e[9]===Symbol.for("react.memo_cache_sentinel")?(x={touchAction:"manipulation"},y=t.jsx(X,{name:"add",className:"size-5"}),e[9]=x,e[10]=y):(x=e[9],y=e[10]);let b;e[11]!==s||e[12]!==p||e[13]!==g?(b=t.jsx("button",{type:"button",className:"flex size-10 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:s,"aria-label":p,title:g,style:x,children:y}),e[11]=s,e[12]=p,e[13]=g,e[14]=b):b=e[14];let S;e[15]!==i?(S=i("mcpDropdown.actions.refreshAria"),e[15]=i,e[16]=S):S=e[16];let R;e[17]!==i?(R=i("mcpDropdown.actions.refreshAria"),e[17]=i,e[18]=R):R=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C={touchAction:"manipulation"},e[19]=C):C=e[19];const D=a&&"animate-spin";let A;e[20]!==D?(A=ee("size-5",D),e[20]=D,e[21]=A):A=e[21];let j;e[22]!==A?(j=t.jsx(X,{name:"refresh",className:A}),e[22]=A,e[23]=j):j=e[23];let k;e[24]!==a||e[25]!==h||e[26]!==j||e[27]!==S||e[28]!==R?(k=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:h,disabled:a,"aria-label":S,title:R,style:C,children:j}),e[24]=a,e[25]=h,e[26]=j,e[27]=S,e[28]=R,e[29]=k):k=e[29];let v;e[30]!==k||e[31]!==b?(v=t.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-1 px-2 pt-1",children:[b,k]}),e[30]=k,e[31]=b,e[32]=v):v=e[32];let I;e[33]!==r?(I=t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(Pp,{active:r,className:"h-full",listClassName:"max-h-none",hideHeader:!0,mobileListDensity:!0})}),e[33]=r,e[34]=I):I=e[34];let P;return e[35]!==v||e[36]!==I?(P=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[v,I]}),e[35]=v,e[36]=I,e[37]=P):P=e[37],P},Zp=({open:n,onClose:e,tab:s,onTabChange:r,pendingChangesDiff:i,onOpenPlan:a,onOpenMcpSettings:o,variant:l="drawer"})=>{const{t:f,direction:d}=ve(),m=c.useRef(null),h=c.useRef(null),[p,g]=c.useState(!1),[x,y]=c.useState(n),b=c.useRef(e);c.useEffect(()=>{b.current=e},[e]);const S=c.useRef(s);c.useEffect(()=>{S.current=s},[s]);const R=()=>b.current();ki(h,{enabled:l==="drawer"&&n,...d==="rtl"?{onRightEdgeSwipe:R}:{onLeftEdgeSwipe:R}});const[C,D]=c.useState(()=>new Set);if(c.useEffect(()=>{n&&D(k=>{if(k.has(s))return k;const v=new Set(k);return v.add(s),v})},[n,s]),typeof document<"u"&&!m.current){let k=document.getElementById(Mo);k||(k=document.createElement("div"),k.id=Mo,document.body.appendChild(k)),m.current=k}if(c.useEffect(()=>{if(n){y(!0);const v=window.setTimeout(()=>g(!0),Xp);return()=>window.clearTimeout(v)}g(!1);const k=window.setTimeout(()=>y(!1),_o+40);return()=>window.clearTimeout(k)},[n]),c.useEffect(()=>{if(!n)return;const k=document.body.style.overflow;l==="drawer"&&(document.body.style.overflow="hidden");const v=I=>{I.key!=="Escape"||S.current==="terminal"||Oc(I.target)||b.current()};return document.addEventListener("keydown",v),()=>{l==="drawer"&&(document.body.style.overflow=k),document.removeEventListener("keydown",v)}},[n,l]),l==="drawer"&&!m.current)return null;const A=[{id:"changes",label:f("mobile.menu.git"),icon:t.jsx(X,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"files",label:f("mobile.menu.files"),icon:t.jsx(X,{name:"file-text",className:"h-3.5 w-3.5"})},{id:"terminal",label:f("mobile.menu.terminal"),icon:t.jsx(X,{name:"terminal",className:"h-3.5 w-3.5"})},{id:"notes",label:f("contextRail.surface.notes"),icon:t.jsx(X,{name:"sticky-note",className:"h-3.5 w-3.5"})},{id:"mcp",label:f("mobile.menu.mcp"),icon:t.jsx(Mc,{className:"h-3.5 w-3.5"})}],j=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",children:[t.jsx("div",{className:"flex h-9 min-w-0 flex-1 items-center",children:x?t.jsx(_c,{items:A,activeId:s,onSelect:k=>r(k),layoutMode:"fit",variant:"active-pill",nonCompositedIndicator:!0,inactiveTabsIconOnly:!0,className:"h-full"}):null}),t.jsx("button",{type:"button",className:"-me-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":f("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(X,{name:"close",className:"size-5"})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[C.has("changes")?t.jsx("div",{className:ee("h-full",s!=="changes"&&"hidden"),children:t.jsx(et,{children:t.jsx(Bp,{visible:n&&s==="changes",initialDiff:i,onNavigatedToChat:e})})},i?`changes:${i.path}:${i.staged}`:"changes"):null,C.has("files")?t.jsx("div",{className:ee("h-full",s!=="files"&&"hidden"),children:t.jsx(et,{children:t.jsx(qp,{visible:n&&s==="files"})})}):null,C.has("terminal")?t.jsx("div",{className:ee("h-full",s!=="terminal"&&"hidden"),children:t.jsx(et,{children:t.jsx(Xu,{visible:n&&s==="terminal"})})}):null,C.has("notes")?t.jsx("div",{className:ee("h-full",s!=="notes"&&"hidden"),children:t.jsx(et,{children:t.jsx(Yu,{visible:n&&s==="notes",onActionComplete:e,onOpenPlan:a})})}):null,C.has("mcp")?t.jsx("div",{className:ee("h-full",s!=="mcp"&&"hidden"),children:t.jsx(et,{children:t.jsx(Qp,{active:n&&s==="mcp",onOpenMcpSettings:o})})}):null]})]});return l==="panel"?t.jsx("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:j}):Ds.createPortal(t.jsx("section",{ref:h,role:"dialog","aria-modal":"true","aria-label":f("mobile.header.openWorkspaceAria"),"aria-hidden":!n,className:"oc-keyboard-inset-surface oc-bottom-safe-surface fixed inset-0 z-50 flex flex-col bg-background text-foreground",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:p?"none":d==="rtl"?"translateX(-100%)":"translateX(100%)",transition:`transform ${_o}ms ${Yp}`,visibility:x?"visible":"hidden",pointerEvents:n?"auto":"none"},children:j}),m.current)};function eh(n){return n.currentDirectory}function th(n){return n.refresh}function sh(n){return n.loadMcpConfigs}function nh(n){return window.setTimeout(n,500)}function rh(n){const e=fe.c(4),s=2500,{uiFont:r}=zc(),[i,a]=c.useState(!1);let o,l;return e[0]!==s||e[1]!==r?(o=()=>{let f=!1;const d=()=>{f||a(!0)},m=()=>{requestAnimationFrame(()=>requestAnimationFrame(d))},h=Promise.all([Bc(r).catch(ch),document.fonts?.ready?.then(lh).catch(ah)??Promise.resolve(),uf.catch(oh)]).then(ih),p=new Promise(g=>{window.setTimeout(g,s)});return Promise.race([h,p]).then(m),()=>{f=!0}},l=[r,s],e[0]=s,e[1]=r,e[2]=o,e[3]=l):(o=e[2],l=e[3]),c.useEffect(o,l),i}function ih(){}function oh(){}function ah(){}function lh(){}function ch(){}const uh=ya({projectId:Zi().trim().min(1).optional(),text:Zi().optional()}),dh=ya({request:uh.nullish()}),tl=ha("ShortcutRequests"),fh=async()=>{const n=dh.safeParse(await tl.takePending());return n.success?n.data.request??null:null},mh=n=>{if(qr()!=="ios")return()=>{};let e=!1,s=null;const r=()=>{fh().then(i=>{i&&n(i)}).catch(()=>{})};return tl.addListener("pending",r).then(i=>{if(e){i.remove();return}s=i}).catch(()=>{}),r(),()=>{e=!0,s?.remove()}},ph="openchamber",hh=n=>n.replace(/^\/+|\/+$/g,""),gh=n=>{const e=hh(n.pathname).split("/").filter(Boolean);return n.host?[n.host,...e]:e};function bh(n){if(typeof n!="string"||n.length===0)return null;let e;try{e=new URL(n)}catch{return null}if(e.protocol!==`${ph}:`)return null;const s=gh(e),r=(s[0]??"").toLowerCase(),i=s.slice(1),a=e.searchParams;switch(r){case"session":{const o=i[0]||a.get("id")||"";if(!o)return null;const l=a.get("message")?.trim()??"";return{type:"session",sessionId:o,directory:a.get("dir")??void 0,...Lc(l)?{messageId:l}:{}}}case"new":case"new-session":return{type:"new-session",directory:a.get("dir")??void 0,projectId:a.get("project")??void 0,agent:a.get("agent")??void 0,model:a.get("model")??void 0};case"sessions":{const o=a.get("filter");return{type:"sessions",filter:o==="attention"||o==="recent"||o==="all"?o:void 0}}case"status":return{type:"status"};case"settings":return{type:"settings",section:i[0]||a.get("section")||void 0};case"changes":return{type:"changes",path:i.join("/")||a.get("path")||void 0,staged:a.get("staged")==="true"};case"view":{const o=(i[0]||"").toLowerCase();return o==="changes"?{type:"changes"}:o==="files"||o==="mcp"||o==="instances"||o==="update"?{type:"view",target:o}:null}default:return null}}let dt={},sl=!1,cn=null;const xh=n=>{const e=Be.getState(),s=n.projectId?it.getState().projects.find(i=>i.id===n.projectId)??null:null;e.openNewSessionDraft(s?{selectedProjectId:s.id}:void 0);const r=n.text?.trim();if(r){if(n.projectId&&!s){Ki.getState().setPendingInputText(r,"append");return}Ki.getState().requestDraftSubmit(Be.getState().newSessionDraft.draftId,r)}},yh=n=>{switch(n.type){case"shortcut-new-session":return xh(n),!0;case"session":return n.messageId&&!n.directory?(Fc(n.sessionId,n.messageId),!0):(n.messageId&&$c(n.sessionId,n.messageId),Be.getState().setCurrentSession(n.sessionId,n.directory??null),!0);case"new-session":{const e=Be.getState();return e.openNewSessionDraft(),(n.directory||n.projectId)&&e.setNewSessionDraftTarget({directoryOverride:n.directory??null,projectId:n.projectId??null,selectedProjectId:n.projectId??null}),!0}case"sessions":return dt.openSessions?(dt.openSessions(n.filter),!0):!1;case"status":return dt.openSessions?(dt.openSessions(),!0):!1;case"view":return dt.openView?(dt.openView(n.target),!0):!1;case"changes":return dt.openChanges?(dt.openChanges({path:n.path,staged:n.staged}),!0):!1;case"settings":return dt.openSettings?(dt.openSettings(n.section),!0):!1}},Ni=()=>{if(!sl||!cn)return;const n=cn;cn=null,yh(n)||(cn=n)},Kr=n=>{cn=n,Ni()},Oo=n=>{const e=bh(n);e&&Kr(e)},vh=n=>{sl=n,Ni()},wh=n=>{const e=fe.c(3);let s,r;e[0]!==n?(s=()=>(dt=n,Ni(),()=>{dt===n&&(dt={})}),r=[n],e[0]=n,e[1]=s,e[2]=r):(s=e[1],r=e[2]),c.useEffect(s,r)},jh=n=>{const{ready:e}=n;c.useEffect(()=>{vh(e)},[e]),c.useEffect(()=>{if(!tt())return;let s=!1;const r=[];return Ms(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([130,5,55])).then(async({App:i})=>{if(s)return;const a=await i.addListener("appUrlOpen",o=>{Oo(o?.url)});if(s){a.remove();return}r.push(()=>{a.remove()})}).catch(()=>{}),r.push(mh(i=>{Kr({type:"shortcut-new-session",projectId:i.projectId,text:i.text})})),Ms(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([131,55])).then(async({PushNotifications:i})=>{if(s)return;const a=await i.addListener("pushNotificationActionPerformed",o=>{const l=o?.notification?.data,f=typeof l?.url=="string"?l.url:typeof l?.deeplink=="string"?l.deeplink:void 0;if(f){Oo(f);return}const d=typeof l?.sessionId=="string"?l.sessionId:void 0;d&&Kr({type:"session",sessionId:d})});if(s){a.remove();return}r.push(()=>{a.remove()})}).catch(()=>{}),()=>{s=!0,r.forEach(i=>i())}},[])},kh=()=>{if(typeof window>"u")return;const n=window.__OPENCHAMBER_APNS_ENV__;if(n==="development")return"sandbox";if(n==="production")return"production"},zo=/^[A-Za-z0-9+/]{43}=$/,Sh=ha("PushKey"),Nh=async()=>{const n=window.__OPENCHAMBER_PUSH_KEY__;if(n&&zo.test(n))return n;const e=await Sh.get().then(s=>s.key).catch(()=>{});return e&&zo.test(e)?e:void 0},Ch=()=>{if(typeof window>"u")return!1;const e=window.Capacitor?.getPlatform?.();return e==="ios"||e==="android"},Rh=n=>{const{enabled:e}=n,s=Ve(i=>i.nativeNotificationsEnabled),r=c.useRef(null);c.useEffect(()=>{if(!e||!s||!Ch())return;let i=!1;const a=[];return Ms(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([131,55])).then(async({PushNotifications:o})=>{if(i)return;let l=await o.checkPermissions().catch(()=>null);if(l?.receive!=="granted"&&(l=await o.requestPermissions().catch(()=>null)),l?.receive!=="granted")return;const f=await o.addListener("registration",m=>{r.current=m.value,Nh().then(h=>{const p=Bi(),g={token:m.value,platform:qr(),environment:kh()};h&&(g.pushKey=h),p?.push?.registerApnsToken?.(g)})}),d=await o.addListener("registrationError",m=>{console.warn("[Push] APNs registration error:",m)});if(await o.register().catch(()=>{}),i){f.remove(),d.remove();return}a.push(()=>{f.remove()},()=>{d.remove()})}).catch(()=>{}),()=>{i=!0,a.forEach(o=>o())}},[e,s]),c.useEffect(()=>{if(s)return;const i=r.current;if(!i)return;r.current=null,Bi()?.push?.unregisterApnsToken?.({token:i})},[s])},Bo=n=>{const e=fe.c(12),{side:s,isResizing:r,ariaLabel:i,handleProps:a}=n,o=s==="left"?"inset-e-0":"inset-s-0";let l;e[0]!==o?(l=ee("absolute inset-y-0 z-50 w-6 cursor-col-resize touch-none",o),e[0]=o,e[1]=l):l=e[1];const f=s==="left"?"inset-e-0":"inset-s-0",d=r&&"bg-[var(--interactive-border)]";let m;e[2]!==f||e[3]!==d?(m=ee("absolute inset-y-0 w-[3px] transition-colors",f,d),e[2]=f,e[3]=d,e[4]=m):m=e[4];let h;e[5]!==m?(h=t.jsx("div",{className:m}),e[5]=m,e[6]=h):h=e[6];let p;return e[7]!==i||e[8]!==a||e[9]!==l||e[10]!==h?(p=t.jsx("div",{className:l,role:"separator","aria-orientation":"vertical","aria-label":i,...a,children:h}),e[7]=i,e[8]=a,e[9]=l,e[10]=h,e[11]=p):p=e[11],p},Eh=320,Ih=380,Lo=280,Ah=560,Ph=900;function Fo(n,e,s,r){const i=fe.c(23),a=r===void 0?Ah:r,o=c.useRef(null);let l;i[0]!==s||i[1]!==a||i[2]!==e?(l=()=>{if(typeof window>"u")return s;const E=Number.parseInt(window.localStorage.getItem(e)??"",10);return Number.isFinite(E)?Math.min(a,Math.max(Lo,E)):s},i[0]=s,i[1]=a,i[2]=e,i[3]=l):l=i[3];const[f,d]=c.useState(l),[m,h]=c.useState(!1),p=c.useRef(0),g=c.useRef(f),x=c.useRef(null),y=c.useRef(null);let b;i[4]!==a?(b=E=>Math.min(a,Math.max(Lo,Math.round(E))),i[4]=a,i[5]=b):b=i[5];const S=b;let R;i[6]===Symbol.for("react.memo_cache_sentinel")?(R=E=>{const T=o.current;T&&(T.style.width=`${E}px`,T.style.minWidth=`${E}px`,T.style.maxWidth=`${E}px`,T.style.setProperty("--oc-ipad-sidebar-width",`${E}px`))},i[6]=R):R=i[6];const C=R;let D;i[7]!==f?(D=E=>{try{E.currentTarget.setPointerCapture(E.pointerId)}catch{}y.current=E.pointerId,p.current=E.clientX,g.current=f,x.current=f,h(!0),E.preventDefault()},i[7]=f,i[8]=D):D=i[8];const A=D;let j;i[9]!==S||i[10]!==n?(j=E=>{if(y.current!==E.pointerId)return;const T=(n==="left"?1:-1)*(vl(E.currentTarget)?-1:1),O=S(g.current+(E.clientX-p.current)*T);x.current!==O&&(x.current=O,C(O))},i[9]=S,i[10]=n,i[11]=j):j=i[11];const k=j;let v;i[12]!==S||i[13]!==e?(v=E=>{if(y.current!==E.pointerId)return;try{E.currentTarget.releasePointerCapture(E.pointerId)}catch{}const T=S(x.current??g.current);y.current=null,x.current=null,h(!1),d(T);try{window.localStorage.setItem(e,String(T))}catch{}},i[12]=S,i[13]=e,i[14]=v):v=i[14];const I=v;let P;i[15]!==A||i[16]!==I||i[17]!==k?(P={onPointerDown:A,onPointerMove:k,onPointerUp:I,onPointerCancel:I},i[15]=A,i[16]=I,i[17]=k,i[18]=P):P=i[18];const L=P;let _;return i[19]!==L||i[20]!==m||i[21]!==f?(_={asideRef:o,width:f,isResizing:m,handleProps:L},i[19]=L,i[20]=m,i[21]=f,i[22]=_):_=i[22],_}const Th=["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"],Dh=1e3,Mh=({onActiveConnectionDeleted:n})=>{const{t:e,direction:s}=ve();dd();const[r,i]=c.useState(!1);c.useEffect(()=>Be.subscribe((K,ge)=>{K.currentSessionId&&K.currentSessionId!==ge.currentSessionId&&Ve.getState().setRunOverviewKey(null)}),[]);const a=Ve(K=>K.runOverviewKey!==null);c.useEffect(()=>{a&&i(!1)},[a]);const[o,l]=c.useState(null),[f,d]=c.useState(!1),[m,h]=c.useState("changes"),[p,g]=c.useState(null),[x,y]=c.useState("nav"),[b,S]=c.useState(null),R=Ve(K=>K.setSettingsPage),C=Ve(K=>K.wideChatLayoutEnabled),D=Is(K=>K.available),A=Is(K=>K.runtimeType),j=c.useMemo(()=>ei(),[]),k=Ps(K=>K.mcpServers),v=Ps(K=>K.setMcpDraft),I=Ps(K=>K.setSelectedMcp),P=c.useCallback(()=>{l(null),g(null)},[]),L=c.useCallback(K=>{l(K)},[]),_=c.useCallback(()=>{d(!1)},[]),E=c.useCallback(K=>{y(K),L("settings")},[L]),{enabled:T,roomyForPanels:O}=Hr(),G=ru()==="portrait",F=iu(),[z,U]=c.useState(()=>ou().roomyForPanels),Q=c.useCallback(()=>{U(K=>!K)},[]);c.useEffect(()=>{T||U(!1)},[T]);const te=c.useCallback(()=>{S(null),h("files"),d(!0)},[]);c.useEffect(()=>zr(K=>{if(K.type!=="file-open-request")return;const ge=K.directory??Dt.getState().currentDirectory;ge&&(Ve.getState().openContextFile(ge,K.path),te())}),[te]),c.useEffect(()=>zr(K=>{if(K.type!=="plan-open-request")return;const ge=fd(K.directory??Dt.getState().currentDirectory,K.projectId);ge&&g({id:K.planId,title:K.title,projectRef:ge})}),[]);const ce=c.useCallback((K=null)=>{S(K),h("changes"),d(!0)},[]),re=Fo("left","openchamber.ipad.leftSidebarWidth",Eh),Y=Fo("right","openchamber.ipad.rightSidebarWidth",Ih,Ph),ye=O,Z=ye&&f?Y.width:0,N=T&&z?re.width:0;c.useEffect(()=>{if(typeof document>"u")return;const K=document.documentElement;return K.style.setProperty("--oc-chat-inset-left",`${N}px`),K.style.setProperty("--oc-chat-inset-right",`${Z}px`),()=>{K.style.removeProperty("--oc-chat-inset-left"),K.style.removeProperty("--oc-chat-inset-right")}},[N,Z]),c.useEffect(()=>{if(typeof document>"u")return;const K=document.documentElement;return K.classList.toggle("wide-chat-layout",C),()=>K.classList.remove("wide-chat-layout")},[C]),c.useEffect(()=>{if(typeof document>"u")return;const K=T&&(G||F),ge=document.documentElement;return ge.classList.toggle("oc-keep-draft-starters",K),()=>ge.classList.remove("oc-keep-draft-starters")},[F,T,G]);const $=c.useMemo(()=>({openChanges:({diffPath:K,staged:ge}={})=>{ce(K?{path:K,staged:ge===!0}:null)},openFiles:()=>te(),openSettings:()=>E("nav"),openSourceBoard:()=>L("board")}),[ce,te,E,L]),J=c.useMemo(()=>({openSessions:()=>{T?U(!0):i(!0)},openView:K=>{if(K==="files"){te();return}if(K==="mcp"){h("mcp"),d(!0);return}L(K)},openChanges:({path:K,staged:ge}={})=>{ce(K?{path:K,staged:ge===!0}:null)},openSettings:K=>{K&&R(K),E(K?"page-content":"nav")}}),[T,ce,te,E,L,R]);wh(J);const ae=c.useRef(null),ie=()=>{T?U(!0):i(!0)},q=()=>d(!0);ki(ae,{onLeftEdgeSwipe:s==="rtl"?q:ie,onRightEdgeSwipe:s==="rtl"?ie:q});const se=c.useRef(null),ke=c.useCallback(K=>{se.current=K},[]),xe=c.useCallback(()=>au()?!0:p?(g(null),!0):o==="settings"&&se.current?.()?!0:o?(P(),!0):f?(_(),!0):r?(i(!1),!0):!1,[o,P,_,p,r,f]);lu(xe);const we=!j&&D&&(A==="desktop"||A==="web"),me=T?"dialog":"fullscreen",Re=c.useMemo(()=>({instanceLabel:j?on():null,onOpenInstances:j?()=>L("instances"):void 0,onOpenSettings:()=>E("nav"),onOpenUsage:()=>L("usage"),onOpenScheduled:()=>L("scheduled"),onOpenArchive:()=>L("archive"),onOpenSourceBoard:()=>L("board"),onOpenUpdate:we?()=>L("update"):void 0}),[E,L,j,we]),Ae=c.useCallback(K=>{P(),i(!1),K==="file"&&te()},[P,te]),Te=c.useCallback(()=>{P(),i(!1)},[P]),Se=c.useCallback(()=>{P(),i(!1),T&&!O&&U(!1)},[P,T,O]),Ce=c.useCallback(()=>{const K="new-mcp-server";let ge=K,ne=1;for(;k.some(be=>be.name===ge);)ge=`${K}-${ne}`,ne+=1;v({name:ge,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",oauthCallbackPort:"",oauthAuthServerMetadataUrl:"",protocol:"legacy",timeoutStartup:"",timeoutCatalog:"",timeoutExecution:"",codemode:"default",disabled:!1}),I(ge),R("mcp"),E("page-content")},[k,E,v,I,R]);return t.jsx(cu,{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:re.asideRef,className:ee("relative flex h-full shrink-0 flex-col overflow-hidden border-e border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!z&&"border-e-0"),style:{width:z?re.width:0,minWidth:z?re.width:0,maxWidth:z?re.width:0,"--oc-ipad-sidebar-width":`${re.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:re.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!z,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:ee("flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",re.isResizing&&"pointer-events-none",!z&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(et,{children:t.jsx(Ro,{open:!0,variant:"sidebar",onOpenChange:K=>{!K&&!O&&U(!1)},footer:Re})})}),z?t.jsx(Bo,{side:"left",isResizing:re.isResizing,ariaLabel:e("sidebar.resize.leftPanelAria"),handleProps:re.handleProps}):null]}):null,t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col","data-page-scroll-lock":"true",children:[t.jsx(Cm,{onOpenSessions:()=>T?Q():i(!0),onOpenWorkspace:()=>d(!0),compactTitle:T}),t.jsxs("main",{ref:ae,className:"relative min-h-0 flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[t.jsx("div",{className:"h-full w-full",children:t.jsx(et,{children:t.jsx(md,{})})}),t.jsx(et,{children:t.jsx(kd,{})})]})]}),T?null:t.jsx(Ro,{open:r,onOpenChange:i,footer:Re}),t.jsxs("aside",{ref:Y.asideRef,className:ee("relative flex h-full shrink-0 flex-col overflow-hidden border-s border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!Z&&"border-s-0"),style:{width:Z,minWidth:Z,maxWidth:Z,"--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":!Z,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:ee("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",!Z&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(et,{children:t.jsx(Zp,{open:f,onClose:_,tab:m,onTabChange:h,pendingChangesDiff:b,onOpenPlan:g,onOpenMcpSettings:Ce,variant:ye?"panel":"drawer"})})}),Z?t.jsx(Bo,{side:"right",isResizing:Y.isResizing,ariaLabel:e("sidebar.resize.rightPanelAria"),handleProps:Y.handleProps}):null]}),p?t.jsx(Pt,{open:!0,variant:me,onClose:()=>g(null),ariaLabel:p.title,title:p.title,children:t.jsx(et,{children:t.jsx(yd,{savedProjectPlan:{projectRef:p.projectRef,planId:p.id},onNavigatedToChat:()=>{P(),_()}})})}):null,o==="instances"&&j?t.jsx(Pt,{open:!0,variant:me,dialogAlign:"app",onClose:P,ariaLabel:e("mobile.menu.instances"),title:e("mobile.menu.instances"),children:t.jsx(Pm,{onConnect:P,onActiveConnectionDeleted:n})}):null,o==="settings"?t.jsx(Pt,{open:!0,variant:me,dialogAlign:"app",onClose:P,ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(et,{children:t.jsx(bd,{forceMobile:!0,isWindowed:!0,initialMobileStage:x,registerBackHandler:ke,visiblePageSlugs:[...Th],onClose:P})})}):null,o==="usage"?t.jsx(Pt,{open:!0,variant:me,dialogAlign:"app",onClose:P,ariaLabel:e("usageStats.title"),title:e("usageStats.title"),children:t.jsx(et,{children:t.jsx(Bd,{})})}):null,o==="scheduled"?t.jsx(Pt,{open:!0,variant:me,dialogAlign:"app",onClose:P,ariaLabel:e("sessions.scheduledTasks.dialog.title"),title:e("sessions.scheduledTasks.dialog.title"),children:t.jsx(et,{children:t.jsx($d,{layout:"mobile",onLeave:Ae})})}):null,o==="board"?t.jsx(Pt,{open:!0,variant:me,dialogAlign:"app",onClose:P,ariaLabel:e("sourceBoard.title"),headerless:!0,children:t.jsx(et,{children:t.jsx(Fd,{onLeave:Te,onClose:P})})}):null,o==="archive"?t.jsx(Pt,{open:!0,variant:me,dialogAlign:"app",onClose:P,ariaLabel:e("sessions.archivePage.title"),title:e("sessions.archivePage.title"),children:t.jsx(et,{children:t.jsx(Ld,{layout:"mobile",onLeave:Se})})}):null,o==="update"?t.jsx(Pt,{open:!0,variant:me,dialogAlign:"app",onClose:P,ariaLabel:e("mobile.menu.update"),title:e("mobile.menu.update"),children:t.jsx(et,{children:t.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:t.jsx(xd,{initialUpdateDialogOpen:!0})})})}):null]})})};function _h({apis:n}){const e=Ve(N=>N.isolatedSpacesEnabled),{t:s}=ve(),r=ft(N=>N.initializeApp),i=ft(N=>N.isInitialized),a=ft(N=>N.isConnected),o=ft(N=>N.connectionPhase),l=ft(N=>N.providers.length),f=ft(N=>N.agents.length),d=ft(N=>N.loadProviders),m=ft(N=>N.loadAgents),h=Dt(N=>N.currentDirectory),p=Be(N=>N.error),g=Be(N=>N.clearError),x=Ve(N=>N.setIsMobile),y=ca(N=>N.refreshAll),b=Wc(N=>N.refreshStatus),S=it(N=>N.projects),R=ls(N=>N.activeSessions),C=ls(N=>N.archivedSessions),D=ls(N=>N.status==="ready"),A=c.useMemo(()=>[...R,...C],[R,C]);Qu({hasAuthoritativeGlobalSessions:D,sessions:A});const[j,k]=c.useState(0),[v,I]=c.useState(0),[P,L]=c.useState(!1),[_,E]=c.useState("pending"),[T,O]=c.useState(null),M=c.useMemo(()=>on(),[]),[,G]=c.useReducer(N=>N+1,0),F=c.useMemo(()=>ei(),[]),z=c.useRef(0),U=c.useRef(0),Q=c.useCallback(()=>{const N=jt(),$=U.current+1;if(U.current=$,!N){tn("resume:auto-connect",{}),sn();return}tn("resume:reprobe",{});const J=()=>{r(),y(n.sourceControl,{force:!0}),b(n.linear,{force:!0}),l===0&&d({source:"mobileApp:nativeResume"}),f===0&&m({source:"mobileApp:nativeResume"})},ae=q=>{tn("resume:disconnect",{reason:q}),Rs({apiBaseUrl:"",clientToken:null,runtimeKey:Pn}),k(se=>se+1)};$n().then(q=>{if(U.current===$){if(q==="no-connection"){ae("no-connection");return}if(q==="needs-login"){O({kind:"auth-expired",label:on()??""}),ae("needs-login");return}if(q==="unreachable"){const se=[4e3,1e4],ke=xe=>{window.setTimeout(()=>{if(U.current!==$)return;const we=xe===se.length-1;$n({fast:!we}).then(me=>{if(U.current===$&&me!=="switched"){if(me==="unchanged"){J();return}if(me==="needs-login"){O({kind:"auth-expired",label:on()??""}),ae("retry-needs-login");return}if(!we){ke(xe+1);return}ae(`retry-${me}`)}})},se[xe])};ke(0);return}q!=="switched"&&J()}});const ie=Date.now();ie-z.current>=Dh&&(z.current=ie,window.dispatchEvent(new Event("openchamber:system-resume")))},[f,n.sourceControl,n.linear,r,m,d,l,y,b]);Vc(),Uc(Q),c.useEffect(()=>{if(!F)return;let N;const $=()=>{window.clearTimeout(N),N=window.setTimeout(()=>Q(),1500)};return window.addEventListener("online",$),()=>{window.removeEventListener("online",$),window.clearTimeout(N)}},[F,Q]),c.useEffect(()=>{if(F)return Li.subscribe((N,$)=>{N.state==="expired"&&$.state!=="expired"&&(Q(),Li.getState().markAuthenticated())})},[F,Q]),c.useEffect(()=>(Fi(n),()=>Fi(null)),[n]),c.useEffect(()=>Vo(N=>{if(tn("endpoint:changed",{runtimeKey:N.runtimeKey||"none",previousRuntimeKey:N.previousRuntimeKey||"none",connected:!!N.apiBaseUrl}),!!N.runtimeKey&&N.runtimeKey===N.previousRuntimeKey){Zu(),G();return}ed(N),I(J=>J+1),k(J=>J+1)}),[]),c.useEffect(()=>{if(!F||a||jt()){E("done");return}let N=!1;return E("attempting"),(async()=>{const $=await sn().catch(()=>({status:"no-candidate"}));N||($.status==="unreachable"?O({kind:"unreachable",label:$.label}):$.status==="needs-login"&&O({kind:"auth-expired",label:$.label}),E("done"),$.status==="unreachable"&&sn({fast:!1,skipIfConnected:!0}).catch(()=>null))})(),()=>{N=!0}},[]),c.useEffect(()=>{if(!F||!jt())return;let N=!1;const $=J=>{tn("cold-launch:drop",{kind:J?.kind??"unknown"}),J&&O(J),Rs({apiBaseUrl:"",clientToken:null,runtimeKey:Pn}),k(ae=>ae+1)};return $n().then(async J=>{if(N||J==="switched"||J==="unchanged")return;const ae=on();if(J==="needs-login"){$({kind:"auth-expired",label:ae??""});return}if(J==="unreachable"){$(ae?{kind:"unreachable",label:ae}:null),sn({fast:!1,skipIfConnected:!0}).catch(()=>null);return}const ie=await sn().catch(()=>({status:"no-candidate"}));N||ie.status==="connected"||(ie.status==="needs-login"?$({kind:"auth-expired",label:ie.label}):ie.status==="unreachable"?$({kind:"unreachable",label:ie.label}):$(null))}),()=>{N=!0}},[]),c.useEffect(()=>{x(!0)},[x]),c.useEffect(()=>{F&&!jt()||r()},[j,r,F]),c.useEffect(()=>{a&&(l===0&&d({source:"mobileApp:recovery"}),f===0&&m({source:"mobileApp:recovery"}))},[f,a,m,d,l]);const te=c.useRef(!1),[ce,re]=c.useState(F);c.useEffect(()=>{if(!F||!a||te.current)return;let N=!1;const $=window.setTimeout(()=>re(!1),6e3);return(async()=>{const J=await td({refresh:!0});N||(J!=="failed"&&(te.current=!0),re(!1))})(),()=>{N=!0,window.clearTimeout($)}},[j,a,F]),c.useEffect(()=>{a&&$i.setDirectory(h)},[h,a]),c.useEffect(()=>{a&&(y(n.sourceControl,{force:!0}),b(n.linear,{force:!0}))},[n.sourceControl,n.linear,a,y,b]),c.useEffect(()=>{if(!a||S.length===0)return;let N=!1;return(async()=>{const J=new Map(Be.getState().availableWorktreesByProject);if(await Promise.all(S.map(async q=>{const se=q.path.replace(/\\/g,"/").replace(/\/+$/,"");if(se)try{if(!(ut.getState().directories.get(se)?.isGitRepo??await Ms(()=>import("./useAppFontEffects-Bih1DxXi.js").then(me=>me.nw),__vite__mapDeps([9,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83])).then(me=>me.checkIsGitRepository(se))))return;const we=await aa({id:q.id,path:se});if(N)return;J.set(se,we)}catch{}})),N)return;const ae=la(S,J),ie=Be.getState().availableWorktreesByProject;su(ae,ie)||Be.setState({availableWorktrees:[...ae.values()].flat(),availableWorktreesByProject:ae})})(),()=>{N=!0}},[a,S]),c.useEffect(()=>{if(!a)return;let N=!1;const $=zr(J=>{J.type==="worktree-changed"&&nu(S,J.directories,()=>N)});return()=>{N=!0,$()}},[a,S]),c.useEffect(()=>{if(!p)return;const N=window.setTimeout(()=>g(),5e3);return()=>window.clearTimeout(N)},[g,p]),c.useEffect(()=>{if(!(!a&&(F?!!jt():!0))){L(!1);return}const $=window.setTimeout(()=>{L(!0)},F?4e3:8e3);return()=>window.clearTimeout($)},[a,F,j,v]),Gc(),Kc({enabled:!0}),sd(),qc(),Hc(),nd(),rd(h||null),id(),Rh({enabled:F&&a}),jh({ready:F&&a&&i});const Y=rh(),ye=!a&&o==="reconnecting";if(!Y)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(Es,{width:120,height:120,isAnimated:!0,variant:"splash"})});const Z=!!jt();return F&&(!Z||!a&&!ye)?Z?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(Es,{width:120,height:120,isAnimated:!P,variant:"splash"}),P?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:s("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:s("mobile.connect.recovery.description")})]}),t.jsx(Ee,{type:"button",variant:"outline",onClick:()=>{Rs({apiBaseUrl:"",clientToken:null,runtimeKey:Pn}),k(N=>N+1)},children:s("mobile.connect.cancelPassword")})]}):null]})}):_!=="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(Es,{width:120,height:120,isAnimated:!0,variant:"splash"}),M?t.jsxs("div",{className:"absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center",children:[t.jsx("p",{className:"typography-small text-muted-foreground",children:s("mobile.connect.splash.connectingTo")}),t.jsxs("p",{className:"typography-small text-foreground",children:[M,t.jsx(Jc,{})]})]}):null]}):t.jsx(t.Fragment,{children:t.jsx(um,{onConnected:()=>k(N=>N+1),notice:T})}):!a&&!ye?P?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(Es,{width:120,height:120,isAnimated:!0,variant:"splash"})}):t.jsx(et,{children:t.jsx(Xc,{sdk:$i.getSdkClient(),directory:h||"",children:t.jsx(Yc,{apis:n,children:t.jsx(Qc,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[t.jsx(od,{ready:!F||!ce,animated:!0}),t.jsx(Zc,{backgroundWorkEnabled:i}),t.jsx(ad,{}),t.jsx(yf,{}),t.jsx(Mh,{onActiveConnectionDeleted:()=>{Zf(),Rs({apiBaseUrl:"",clientToken:null,runtimeKey:Pn}),k(N=>N+1)}}),t.jsx(eu,{}),t.jsx(tu,{}),e?t.jsxs(t.Fragment,{children:[t.jsx(vd,{}),t.jsx(ld,{}),t.jsx(wd,{}),t.jsx(cd,{}),t.jsx(jd,{})]}):null,t.jsx(Nf,{}),i?t.jsx(ud,{}):null]})})})},v)})}function Oh(n){const e=fe.c(7),s=c.useSyncExternalStore(zh,jt,jt);let r;e[0]!==s?(r=!ei()||!!s,e[0]=s,e[1]=r):r=e[1];let i;e[2]!==n?(i=t.jsx(_h,{...n}),e[2]=n,e[3]=i):i=e[3];let a;return e[4]!==r||e[5]!==i?(a=t.jsx(pd,{enabled:r,children:i}),e[4]=r,e[5]=i,e[6]=a):a=e[6],a}function zh(n){return Vo(()=>n())}function Ax(n){window.__OPENCHAMBER_SURFACE__="mobile",uu(),gd({logLabel:"[mobile-main]",onAppearanceSettled:df}),xf(),du();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");const r=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",i=r?{...n,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:n,a=t.jsx(Oh,{apis:i});al.createRoot(e).render(t.jsx(Pr.StrictMode,{children:t.jsx(fu,{children:t.jsx(mu,{children:t.jsx(pu,{children:t.jsx(hd,{children:r?a:t.jsx(hu,{children:a})})})})})}))}export{Ax as renderMobileApp};
|