@vantran-se/openchamber-web 1.24.4 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -8
- package/bin/lib/commands-connect-url.js +3 -8
- package/bin/lib/commands-tunnel.js +3 -0
- package/dist/assets/{CodeMirrorCommentWidgets-B4a0JkUz.js → CodeMirrorCommentWidgets-B82Oye3V.js} +1 -1
- package/dist/assets/DiffView-DJLmWn6Z.js +4 -0
- package/dist/assets/FilesView-DjksmZRo.js +17 -0
- package/dist/assets/{GitView-Byu2DY7s.js → GitView-DiUsUIgr.js} +4 -4
- package/dist/assets/{GuestAttachDialog-B808E0-d.js → GuestAttachDialog-CYwWYLr3.js} +1 -1
- package/dist/assets/GuestSurfacePane-CmctyRI4.js +1 -0
- package/dist/assets/{JsonTreeView-VW_7czo3.js → JsonTreeView-DOHHcbgJ.js} +1 -1
- package/dist/assets/LinearIssuesView-DaqnylcV.js +1 -0
- package/dist/assets/MarkdownImageGallery-HJNvWt7L.js +1 -0
- package/dist/assets/MarkdownRendererImpl-nDZRGg2I.js +12 -0
- package/dist/assets/OnboardingScreen-C2B5Bsof.js +1 -0
- package/dist/assets/{PatchDiff-DCjGhlYV.js → PatchDiff-C4FLBjpt.js} +1 -1
- package/dist/assets/{PierreDiffViewer-CEDZNkU2.js → PierreDiffViewer-C_1S9c9n.js} +1 -1
- package/dist/assets/PlanView-_eZvb-G5.js +5 -0
- package/dist/assets/PluginPane-sM8fcZIV.js +3 -0
- package/dist/assets/SettingsView-BRfr46hb.js +29 -0
- package/dist/assets/SettingsWindow-CcUDwQHg.js +1 -0
- package/dist/assets/SubmoduleDiffSummary-CrN1ZGwl.js +1 -0
- package/dist/assets/ToolOutputDialog-Cij4jI09.js +15 -0
- package/dist/assets/ToolPartDiffPreview-BXzwQ-JY.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-NU0FHFhT.js → VirtualizedFileDiff-DSWTLJNH.js} +4 -4
- package/dist/assets/{WalkthroughView-BZyjhqHv.js → WalkthroughView-CpUUgY8H.js} +2 -2
- package/dist/assets/appThemeRegistry-B5tHTkR8.js +1 -0
- package/dist/assets/{commitAndPush-BDftrjr6.js → commitAndPush-D7D8qV8p.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-DlWlEM3x.js → computeVirtualFileMetrics-cq9uQ30i.js} +1 -1
- package/dist/assets/de-CUO1-KqF.js +10 -0
- package/dist/assets/es-BlbC6sGJ.js +16 -0
- package/dist/assets/fr-D2nwe_0W.js +14 -0
- package/dist/assets/index-BQOoYIOu.js +1 -0
- package/dist/assets/index-CLcM8HKx.css +1 -0
- package/dist/assets/index-CvLgnuNI.js +41 -0
- package/dist/assets/{isDiffPlainText-CO4e5J_S.js → isDiffPlainText-D0obJ2p8.js} +1 -1
- package/dist/assets/{isFilePlainText-ue6kCou7.js → isFilePlainText-DB3_rjyW.js} +1 -1
- package/dist/assets/ja-CA7vnDsZ.js +16 -0
- package/dist/assets/ko-Chy6a9l-.js +16 -0
- package/dist/assets/main-B9JFK3vF.js +896 -0
- package/dist/assets/main-Bhiqnrhd.js +2 -0
- package/dist/assets/{markdownCore-CK48LG0z.js → markdownCore-tfqOFaBd.js} +4 -4
- package/dist/assets/miniChat-B0UOL5zA.js +2 -0
- package/dist/assets/mobile-BJppFIEo.js +2 -0
- package/dist/assets/{patchFileDiff-D7QVlovD.js → patchFileDiff-Db6KuwCP.js} +3 -3
- package/dist/assets/pl-CTR5A_1P.js +16 -0
- package/dist/assets/pt-BR-BE1O1KEx.js +16 -0
- package/dist/assets/renderElectronMiniChatApp-Yz5sfoFh.js +2 -0
- package/dist/assets/renderMobileApp-QQ-yB8aY.js +25 -0
- package/dist/assets/runtimeEndpointReset-DKDdzRzm.js +27 -0
- package/dist/assets/scheduledTasksApi-C5sCuNqf.js +1 -0
- package/dist/assets/{shikiHighlight-BPu3JiQs.js → shikiHighlight-xURoo5t_.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-DWqRPo9A.js → textMateThemeFromAppTheme-BZLGuYTU.js} +1 -1
- package/dist/assets/tr-Bh5vK6cW.js +7 -0
- package/dist/assets/uk-CLDkZFy_.js +16 -0
- package/dist/assets/useAppFontEffects-BxrtCnfR.js +7337 -0
- package/dist/assets/{useInlineCommentController-CgS0fnw_.js → useInlineCommentController-CeXuR-SR.js} +2 -2
- package/dist/assets/useRootScrollLock-DgWxezc1.js +2 -0
- package/dist/assets/{vendor-codemirror-language-data-Bx2EHc1O.js → vendor-codemirror-language-data-DOuaQUZ0.js} +2 -2
- package/dist/assets/vendor-cron-parser-CjvYVigk.js +2 -0
- package/dist/assets/vendor-opencode-client-_BAHQo4R.js +12 -0
- package/dist/assets/{vendor-remixicon-react-BDmGmFCA.js → vendor-remixicon-react-D6dZ0UwF.js} +1 -1
- package/dist/assets/{vendor-zod-CgAdXWZO.js → vendor-zod-Gea9uBlY.js} +1 -1
- package/dist/assets/{web-components-DxX8bZ1o.js → web-components-63H1h21j.js} +2 -2
- package/dist/assets/zh-CN-DODgcmYj.js +16 -0
- package/dist/assets/zh-TW-ByNfIwLA.js +16 -0
- package/dist/index.html +13 -7
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +5 -5
- package/package.json +6 -5
- package/server/index.d.ts +1 -0
- package/server/index.js +246 -91
- package/server/lib/agent-tool/DOCUMENTATION.md +32 -15
- package/server/lib/agent-tool/runtime.js +135 -54
- package/server/lib/agent-tool/runtime.test.js +155 -87
- package/server/lib/browser-control/DOCUMENTATION.md +37 -2
- package/server/lib/browser-control/provider.js +217 -0
- package/server/lib/browser-control/provider.test.js +251 -0
- package/server/lib/context-obligatory/runtime.js +61 -50
- package/server/lib/context-obligatory/runtime.test.js +62 -162
- package/server/lib/event-stream/DOCUMENTATION.md +12 -1
- package/server/lib/event-stream/delta-coalescer.js +0 -0
- package/server/lib/event-stream/delta-coalescer.test.js +68 -57
- package/server/lib/event-stream/directory-ws-bridge.js +1 -1
- package/server/lib/event-stream/global-hub.js +10 -1
- package/server/lib/event-stream/global-hub.test.js +27 -26
- package/server/lib/event-stream/index.js +6 -0
- package/server/lib/event-stream/protocol.js +26 -19
- package/server/lib/event-stream/protocol.test.js +18 -7
- package/server/lib/event-stream/rebind.test.js +5 -5
- package/server/lib/event-stream/runtime.test.js +17 -15
- package/server/lib/event-stream/translate-v2.js +313 -0
- package/server/lib/event-stream/translate-v2.test.js +209 -0
- package/server/lib/event-stream/upstream-reader.test.js +16 -16
- package/server/lib/fs/DOCUMENTATION.md +4 -2
- package/server/lib/fs/byte-range.js +35 -0
- package/server/lib/fs/byte-range.test.js +31 -0
- package/server/lib/fs/routes.js +47 -42
- package/server/lib/fs/routes.test.js +123 -18
- package/server/lib/git/service.js +12 -0
- package/server/lib/github/DOCUMENTATION.md +1 -1
- package/server/lib/github/pr-status.js +22 -2
- package/server/lib/github/pr-status.test.js +27 -14
- package/server/lib/guests/DOCUMENTATION.md +13 -0
- package/server/lib/guests/catalog.js +12 -0
- package/server/lib/guests/catalog.test.js +33 -0
- package/server/lib/guests/routes.js +10 -1
- package/server/lib/guests/service.js +192 -14
- package/server/lib/guests/service.test.js +201 -1
- package/server/lib/guests/surface.js +630 -0
- package/server/lib/guests/surface.test.js +486 -0
- package/server/lib/markdown-image-grants/routes.js +18 -5
- package/server/lib/markdown-image-grants/routes.test.js +9 -6
- package/server/lib/message-queue/DOCUMENTATION.md +33 -22
- package/server/lib/message-queue/runtime.js +155 -100
- package/server/lib/message-queue/runtime.test.js +168 -82
- package/server/lib/notifications/DOCUMENTATION.md +28 -0
- package/server/lib/notifications/control-stream.http.test.js +68 -0
- package/server/lib/notifications/emitter-runtime.js +15 -0
- package/server/lib/notifications/emitter-runtime.test.js +32 -0
- package/server/lib/notifications/push-runtime.js +5 -1
- package/server/lib/notifications/push-runtime.test.js +2 -2
- package/server/lib/notifications/routes.js +1 -1
- package/server/lib/notifications/runtime.js +115 -26
- package/server/lib/notifications/template-runtime.js +13 -15
- package/server/lib/notifications/template-runtime.test.js +16 -9
- package/server/lib/notifications/trigger-runtime.test.js +187 -0
- package/server/lib/openchamber-control/DOCUMENTATION.md +10 -0
- package/server/lib/openchamber-control/actions.js +3 -2
- package/server/lib/openchamber-control/error.js +1 -1
- package/server/lib/openchamber-control/file-open.js +59 -0
- package/server/lib/openchamber-control/file-open.test.js +57 -0
- package/server/lib/openchamber-control/routes.test.js +12 -0
- package/server/lib/openchamber-control/service.js +102 -49
- package/server/lib/openchamber-control/service.test.js +84 -44
- package/server/lib/openchamber-sessions/archive-store.js +224 -0
- package/server/lib/openchamber-sessions/archive-store.test.js +187 -0
- package/server/lib/openchamber-sessions/opencode-client.js +22 -0
- package/server/lib/openchamber-sessions/routes.js +398 -328
- package/server/lib/openchamber-sessions/routes.test.js +777 -740
- package/server/lib/openchamber-sessions/session-metadata-store.js +285 -0
- package/server/lib/openchamber-sessions/session-metadata-store.test.js +259 -0
- package/server/lib/opencode/DOCUMENTATION.md +449 -29
- package/server/lib/opencode/agents.js +233 -327
- package/server/lib/opencode/auth.js +41 -44
- package/server/lib/opencode/auth.test.js +92 -0
- package/server/lib/opencode/cli-upgrade.d.ts +4 -0
- package/server/lib/opencode/cli-upgrade.js +18 -0
- package/server/lib/opencode/cli-upgrade.test.js +36 -0
- package/server/lib/opencode/commands.js +164 -145
- package/server/lib/opencode/compatibility.d.ts +16 -0
- package/server/lib/opencode/compatibility.js +88 -0
- package/server/lib/opencode/compatibility.test.js +62 -0
- package/server/lib/opencode/config-entity-routes.js +58 -29
- package/server/lib/opencode/config-entity-v2.test.js +290 -0
- package/server/lib/opencode/config-mutation-response.js +17 -7
- package/server/lib/opencode/config-mutation-response.test.js +4 -7
- package/server/lib/opencode/config-paths.test.js +2 -2
- package/server/lib/opencode/config-v2.d.ts +183 -0
- package/server/lib/opencode/config-v2.js +801 -0
- package/server/lib/opencode/config-v2.test.js +466 -0
- package/server/lib/opencode/credential-db.js +144 -0
- package/server/lib/opencode/credential-db.test.js +104 -0
- package/server/lib/opencode/env-runtime.js +48 -9
- package/server/lib/opencode/env-runtime.test.js +45 -0
- package/server/lib/opencode/feature-routes-runtime.js +15 -5
- package/server/lib/opencode/lifecycle-process.test.js +7 -4
- package/server/lib/opencode/lifecycle.js +85 -30
- package/server/lib/opencode/lifecycle.test.js +80 -8
- package/server/lib/opencode/login-shell-env.js +27 -0
- package/server/lib/opencode/managed-config-file.js +119 -0
- package/server/lib/opencode/managed-config-file.test.js +152 -0
- package/server/lib/opencode/managed-plugin-config.js +33 -13
- package/server/lib/opencode/mcp.js +43 -149
- package/server/lib/opencode/network-runtime.js +6 -7
- package/server/lib/opencode/openchamber-routes.test.js +2 -5
- package/server/lib/opencode/plugin-routes.js +3 -3
- package/server/lib/opencode/plugin-routes.test.js +6 -24
- package/server/lib/opencode/plugins.js +91 -40
- package/server/lib/opencode/plugins.test.js +28 -15
- package/server/lib/opencode/providers.js +63 -83
- package/server/lib/opencode/providers.test.js +128 -59
- package/server/lib/opencode/proxy-agent-wiring.test.js +4 -2
- package/server/lib/opencode/proxy.js +179 -129
- package/server/lib/opencode/pwa-manifest-routes.js +4 -2
- package/server/lib/opencode/pwa-manifest-routes.test.js +3 -2
- package/server/lib/opencode/response-envelope.js +14 -0
- package/server/lib/opencode/response-envelope.test.js +23 -0
- package/server/lib/opencode/routes-upgrade.test.js +73 -116
- package/server/lib/opencode/routes.js +121 -428
- package/server/lib/opencode/server-utils-runtime.js +10 -4
- package/server/lib/opencode/session-activity.js +78 -0
- package/server/lib/opencode/session-runtime.js +21 -10
- package/server/lib/opencode/session-runtime.test.js +9 -9
- package/server/lib/opencode/settings-helpers.js +9 -9
- package/server/lib/opencode/settings-helpers.test.js +7 -12
- package/server/lib/opencode/settings-registry.json +6 -8
- package/server/lib/opencode/settings-runtime.js +18 -1
- package/server/lib/opencode/settings-runtime.test.js +31 -2
- package/server/lib/opencode/shared.js +54 -22
- package/server/lib/opencode/shared.test.js +8 -4
- package/server/lib/opencode/shutdown-runtime.js +54 -7
- package/server/lib/opencode/shutdown-runtime.test.js +224 -30
- package/server/lib/opencode/skill-routes.js +23 -24
- package/server/lib/opencode/skills.js +7 -5
- package/server/lib/opencode/tunnel-wiring-runtime.js +2 -1
- package/server/lib/opencode/upgrade-capability.test.js +1 -1
- package/server/lib/opencode/v1-migration-topup.js +288 -0
- package/server/lib/opencode/v1-migration-topup.test.js +266 -0
- package/server/lib/opencode/v2-install.d.ts +8 -0
- package/server/lib/opencode/v2-install.js +158 -0
- package/server/lib/opencode/v2-install.test.js +124 -0
- package/server/lib/opencode/watcher.js +10 -3
- package/server/lib/opencode/watcher.test.js +17 -21
- package/server/lib/opencode/websearch-config.js +66 -0
- package/server/lib/package-manager.js +55 -68
- package/server/lib/package-manager.test.js +241 -75
- package/server/lib/permission-auto-accept/runtime.js +38 -22
- package/server/lib/permission-auto-accept/runtime.test.js +39 -17
- package/server/lib/quota/DOCUMENTATION.md +4 -0
- package/server/lib/quota/providers/xai.js +4 -4
- package/server/lib/relay/tunnel-host.js +4 -1
- package/server/lib/relay/tunnel-host.test.js +7 -0
- package/server/lib/routing/DOCUMENTATION.md +52 -21
- package/server/lib/routing/defaults.js +23 -6
- package/server/lib/routing/jev.js +17 -7
- package/server/lib/routing/routes.http.test.js +68 -33
- package/server/lib/routing/routes.js +65 -22
- package/server/lib/routing/runtime.js +145 -48
- package/server/lib/routing/runtime.test.js +79 -55
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +4 -0
- package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +51 -46
- package/server/lib/scheduled-tasks/runtime.js +81 -74
- package/server/lib/scheduled-tasks/runtime.test.js +53 -1
- package/server/lib/session-assist/DOCUMENTATION.md +8 -3
- package/server/lib/session-assist/context.js +122 -46
- package/server/lib/session-assist/context.test.js +117 -49
- package/server/lib/session-assist/runtime.js +52 -22
- package/server/lib/session-assist/runtime.test.js +145 -173
- package/server/lib/session-goal/DOCUMENTATION.md +23 -15
- package/server/lib/session-goal/create.js +9 -12
- package/server/lib/session-goal/create.test.js +27 -28
- package/server/lib/session-goal/runtime.js +164 -77
- package/server/lib/session-goal/runtime.test.js +271 -519
- package/server/lib/session-knowledge/DOCUMENTATION.md +5 -0
- package/server/lib/session-knowledge/runtime.js +59 -41
- package/server/lib/session-knowledge/runtime.test.js +90 -20
- package/server/lib/small-model/DOCUMENTATION.md +154 -208
- package/server/lib/small-model/client.js +113 -0
- package/server/lib/small-model/index.js +296 -158
- package/server/lib/small-model/index.test.js +423 -256
- package/server/lib/small-model/routes.js +1 -1
- package/server/lib/spaces/DOCUMENTATION.md +807 -0
- package/server/lib/spaces/code-in-bait.js +185 -0
- package/server/lib/spaces/code-in.js +641 -0
- package/server/lib/spaces/code-in.test.js +1048 -0
- package/server/lib/spaces/errors.js +8 -0
- package/server/lib/spaces/exec-http.js +94 -0
- package/server/lib/spaces/gatekeeper-channel.js +202 -0
- package/server/lib/spaces/gatekeeper-channel.test.js +215 -0
- package/server/lib/spaces/gatekeeper-program.cjs +914 -0
- package/server/lib/spaces/gatekeeper-program.test.js +1391 -0
- package/server/lib/spaces/hardening.js +457 -0
- package/server/lib/spaces/hardening.test.js +368 -0
- package/server/lib/spaces/host-git.js +127 -0
- package/server/lib/spaces/host-git.test.js +137 -0
- package/server/lib/spaces/labels.js +234 -0
- package/server/lib/spaces/labels.test.js +219 -0
- package/server/lib/spaces/layout.js +184 -0
- package/server/lib/spaces/layout.test.js +30 -0
- package/server/lib/spaces/manager.js +82 -0
- package/server/lib/spaces/manager.test.js +114 -0
- package/server/lib/spaces/places/code-in.docker.live.test.js +216 -0
- package/server/lib/spaces/places/contract-suite.js +156 -0
- package/server/lib/spaces/places/contract.docker.live.test.js +7 -0
- package/server/lib/spaces/places/contract.test.js +6 -0
- package/server/lib/spaces/places/docker-engine.js +126 -0
- package/server/lib/spaces/places/docker-live-support.js +202 -0
- package/server/lib/spaces/places/docker-tools.js +186 -0
- package/server/lib/spaces/places/docker.js +587 -0
- package/server/lib/spaces/places/docker.test.js +1610 -0
- package/server/lib/spaces/places/escape-suite.js +1018 -0
- package/server/lib/spaces/places/escape.docker.live.test.js +7 -0
- package/server/lib/spaces/places/fake-docker.js +375 -0
- package/server/lib/spaces/places/memory-place.js +103 -0
- package/server/lib/spaces/places/packed.docker.live.test.js +77 -0
- package/server/lib/spaces/places/registry.js +43 -0
- package/server/lib/spaces/places/registry.test.js +50 -0
- package/server/lib/spaces/places/server.docker.live.test.js +225 -0
- package/server/lib/spaces/run-command.js +261 -0
- package/server/lib/spaces/run-command.test.js +396 -0
- package/server/lib/spaces/space-server.js +190 -0
- package/server/lib/spaces/space-server.test.js +335 -0
- package/server/lib/spaces/tools-filler.js +82 -0
- package/server/lib/spaces/tools-filler.test.js +148 -0
- package/server/lib/spaces/tools-pack.js +49 -0
- package/server/lib/spaces/tools-pack.test.js +57 -0
- package/server/lib/spaces/tools.js +138 -0
- package/server/lib/spaces/tools.test.js +153 -0
- package/server/lib/tts/openai-sdk.js +11 -0
- package/server/lib/tts/service.js +7 -5
- package/server/lib/tts/stt.js +3 -2
- package/server/lib/tunnels/DOCUMENTATION.md +2 -0
- package/server/lib/tunnels/routes.js +7 -0
- package/server/lib/tunnels/routes.test.js +55 -0
- package/server/lib/ui-auth/ui-auth.js +38 -2
- package/server/lib/ui-auth/ui-auth.test.js +42 -0
- package/server/lib/ui-auth/ui-passkeys.js +12 -10
- package/server/lib/walkthrough/DOCUMENTATION.md +10 -1
- package/server/lib/walkthrough/pull-request.js +61 -8
- package/server/lib/walkthrough/pull-request.test.js +54 -1
- package/server/lib/walkthrough/routes.js +20 -0
- package/server/lib/walkthrough/routes.test.js +19 -0
- package/server/opencode-proxy.test.js +190 -166
- package/server/opencode-worktree-readiness.test.js +5 -4
- package/dist/assets/DiffView-B2CD9wC8.js +0 -4
- package/dist/assets/FilesView-C4vMFclc.js +0 -13
- package/dist/assets/LinearIssuesView-EzGNCGrd.js +0 -1
- package/dist/assets/MarkdownImageGallery-B2YUDFaB.js +0 -1
- package/dist/assets/MarkdownRendererImpl-B4ikIzR3.js +0 -12
- package/dist/assets/OnboardingScreen-CQHBSTEi.js +0 -1
- package/dist/assets/PlanView-D3x-pTkZ.js +0 -5
- package/dist/assets/PluginPane-DEcgDQ9h.js +0 -3
- package/dist/assets/SettingsView-CSinuH-1.js +0 -29
- package/dist/assets/SettingsWindow-B5CHoJFZ.js +0 -1
- package/dist/assets/SubmoduleDiffSummary-oxeACCWs.js +0 -1
- package/dist/assets/ToolOutputDialog-tLNWmfcW.js +0 -15
- package/dist/assets/ToolPartDiffPreview-CflzmK-x.js +0 -8
- package/dist/assets/appThemeRegistry-DLicw4dH.js +0 -1
- package/dist/assets/de-Bro6_zyl.js +0 -10
- package/dist/assets/es-Bb9XQZvd.js +0 -16
- package/dist/assets/fr-Dgfzn-IL.js +0 -14
- package/dist/assets/index-CtQNmqUL.js +0 -1
- package/dist/assets/index-DqaMWNrC.css +0 -1
- package/dist/assets/index-Dqc6USl3.js +0 -40
- package/dist/assets/ja-BYsakGFh.js +0 -16
- package/dist/assets/ko-BSaQz9aN.js +0 -16
- package/dist/assets/main-B62_pjL5.js +0 -2
- package/dist/assets/main-BEdcOI2P.js +0 -896
- package/dist/assets/miniChat-LT8Rqofr.js +0 -2
- package/dist/assets/mobile-CqarEynh.js +0 -2
- package/dist/assets/pl-OIviPdoj.js +0 -16
- package/dist/assets/pt-BR-Cltg-E6s.js +0 -16
- package/dist/assets/renderElectronMiniChatApp-COyLTtZx.js +0 -2
- package/dist/assets/renderMobileApp-BC1MHg6g.js +0 -25
- package/dist/assets/runtimeEndpointReset-DdrazOVH.js +0 -25
- package/dist/assets/scheduledTasksApi-B2SWMGEU.js +0 -1
- package/dist/assets/tr-CQI-KPre.js +0 -7
- package/dist/assets/uk-CqW7R4DA.js +0 -16
- package/dist/assets/useAppFontEffects-ne84JBVL.js +0 -7333
- package/dist/assets/useRootScrollLock-Cpf1qoGp.js +0 -2
- package/dist/assets/vendor-cron-parser-CUcP7OfX.js +0 -2
- package/dist/assets/vendor-opencode-sdk-BJ73u-bH.js +0 -7
- package/dist/assets/zh-CN-CVZG_o_J.js +0 -16
- package/dist/assets/zh-TW-D5ZxzCZp.js +0 -16
- package/server/lib/opencode/mcp-oauth-callback.test.js +0 -111
- package/server/lib/routing/feature-flag.js +0 -11
- package/server/lib/small-model/call.js +0 -851
- package/server/lib/small-model/call.test.js +0 -1292
- package/server/lib/small-model/catalog.js +0 -13
- package/server/lib/small-model/resolve.js +0 -131
- package/server/lib/small-model/resolve.test.js +0 -197
- package/server/lib/small-model/runtime-providers.js +0 -164
- package/server/lib/small-model/runtime-providers.test.js +0 -118
- package/server/lib/system-prompt/DOCUMENTATION.md +0 -36
- package/server/lib/system-prompt/runtime.js +0 -49
- package/server/lib/system-prompt/runtime.test.js +0 -76
- package/server/lib/walkthrough/reproduce-2607.test.js +0 -148
|
@@ -1,896 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-BZyjhqHv.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-ne84JBVL.js","assets/index-Dqc6USl3.js","assets/vendor-zod-CgAdXWZO.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/index-DqaMWNrC.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-CsXYnR5c.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-framer-motion-Bq3iTZ6r.js","assets/vendor-motion-dom-DcCgeG69.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-ClYN8CzB.js","assets/vendor-tanstack-virtual-core-BewVQryB.js","assets/contextPanelEmbeddedChat-CirXEPJq.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BgPj_McA.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-DzPz9Wgq.js","assets/vendor-codemirror-lang-json-CMBS2tG9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-O0cZX78y.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CfgK872x.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-BPGOH9ye.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-Bx2EHc1O.js","assets/vendor-codemirror-lang-python-HahnQaAS.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-B7H_j0iU.js","assets/vendor-legendapp-list-BuBPBC3R.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/patchFileDiff-D7QVlovD.js","assets/runtimeEndpointReset-DdrazOVH.js","assets/GuestAttachDialog-B808E0-d.js","assets/PluginPane-DEcgDQ9h.js","assets/VirtualizedFileDiff-NU0FHFhT.js","assets/web-components-DxX8bZ1o.js","assets/computeVirtualFileMetrics-DlWlEM3x.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/isDiffPlainText-CO4e5J_S.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-CEDZNkU2.js","assets/Virtualizer-D_a8gKmg.js","assets/useInlineCommentController-CgS0fnw_.js","assets/appThemeRegistry-DLicw4dH.js","assets/textMateThemeFromAppTheme-DWqRPo9A.js","assets/vendor-katex-CHD9BdDO.js","assets/vendor-katex-Cp579UoJ.css","assets/useRootScrollLock-Cpf1qoGp.js","assets/scheduledTasksApi-B2SWMGEU.js","assets/vendor-cron-parser-CUcP7OfX.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-B2CD9wC8.js","assets/SubmoduleDiffSummary-oxeACCWs.js","assets/FilesView-C4vMFclc.js","assets/shikiHighlight-BPu3JiQs.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-VW_7czo3.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-ue6kCou7.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets-B4a0JkUz.js","assets/GitView-Byu2DY7s.js","assets/commitAndPush-BDftrjr6.js","assets/LinearIssuesView-EzGNCGrd.js","assets/PlanView-D3x-pTkZ.js","assets/SettingsWindow-B5CHoJFZ.js","assets/SettingsView-CSinuH-1.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/OnboardingScreen-CQHBSTEi.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{f as Ze,R as c,j as s,r as mt,c as Rm,h as Mm}from"./vendor-react-BUCujlKS.js";import"./vendor-katex-CHD9BdDO.js";import{E as xn,F as Vo,H as Om,I as Bm,h as ls,x as Id,u as Pe,J as Ot,K as ll,a as qt,A as Qr,o as ht,L as Gs,N as Ur,O as $n,P as Td,Q as Fm,R as _m,S as Lm,T as $m,U as Ed,n as ns,V as _n,W as Hr,e as Pn,X as zm,Y as Wm,Z as Km,_ as Vm,$ as Rd,v as hn,B as Cn,a0 as Um,a1 as Hm,a2 as cl,a3 as Gm,a4 as ya,a5 as qm,a6 as Md,f as Ym,a7 as Zn,a8 as Ai,a9 as Qm,aa as Di,ab as cr,ac as wa,d as Do,t as Br,q as us,ad as Od,ae as Xm,af as Jm,ag as Pi,ah as Bd,ai as Fd,i as Zm,aj as bo,ak as yo,al as eh,am as dl,an as th,ao as sh,ap as nh,aq as rh,ar as ul,as as fl,at as ml,au as hl,av as oh,z as pl,aw as ih,ax as ah,ay as lh,C as ch,D as dh}from"./index-Dqc6USl3.js";import{_ as En}from"./vendor-vite-runtime-DD1OZmLC.js";import{v as gl,w as ai,x as cn,y as Ii,z as xl,E as uh,F as fh,G as mh,H as hh,I as ph,J as gh,K as xh,L as bh,M as va,b as yh,c as _d,U as Ld,h as Ti,j as $d,Q as wh,i as vh,f as Sh,R as zd,V as Ei,W as Qn,X as Wd,Y as Kd,P as jh,T as kh,Z as Ch,_ as Nh,$ as Ah,a as Vd,a0 as Dh,a1 as Ud,a2 as Po,a3 as Ph,a4 as Ih,a5 as Th,S as bl,a6 as Eh,r as Rh,a7 as Mh,a8 as Oh,a9 as Bh,aa as yl,u as zr,s as Fh,N as _h,D as Lh,ab as $h,ac as wl,ad as zh,ae as li,o as Wh,m as Kh,q as Hd,t as Vh,af as Uh,ag as Hh,ah as Gh,l as qh,n as Yh,O as Gd,A as Qh,C as Xh}from"./runtimeEndpointReset-DdrazOVH.js";import{f as jt,h as Oe,be as Kt,I as M,g as gn,t as Le,aq as zs,bf as Os,as as Ws,ap as Ks,S as or,Z as vn,af as ir,bg as zn,o as Uo,bh as vl,bi as Jh,bj as Zh,aa as Nt,ab as At,ac as Dt,b as Ht,z as tt,H as ep,bk as qd,bl as no,u as $s,C as Sa,r as Ds,D as Yd,bm as Ri,bn as tp,bo as Qd,bp as Xd,bq as sp,br as np,bs as Sl,bt as jl,bu as ja,bv as Jd,bw as Zd,bx as rp,by as kl,bz as op,bA as ip,bB as ka,bC as Mi,bD as ap,bE as lp,Q as eu,bF as cp,bG as dp,n as ur,bH as tu,bI as up,bJ as fp,p as mp,bK as su,bL as hp,bM as pp,bN as gp,bO as nu,bP as ru,bQ as Cl,bR as ou,bS as iu,bT as au,bU as lu,bV as cu,bW as du,bX as Xr,bY as uu,aF as Ca,bZ as er,b_ as Jr,b$ as xp,c0 as ys,c1 as ws,c2 as Vs,c3 as Ps,c4 as Is,c5 as bn,B as dt,c6 as yn,ay as As,c7 as bp,c8 as yp,aD as In,c9 as Fr,ca as Hs,cb as Ho,cc as fu,cd as Oi,ce as Bi,cf as Fi,cg as wp,ch as Bs,ci as Fs,cj as ks,ck as _s,cl as ss,W as An,cm as fr,cn as Nl,co as pr,cp as mu,R as Go,ag as vp,ah as Na,ai as hu,J as pu,K as Tn,cq as Aa,a5 as Da,cr as Sp,cs as jp,aw as kp,ct as Cp,cu as gu,cv as Np,cw as Ap,ax as Pa,cx as Dp,cy as xu,cz as gr,cA as bu,cB as Pp,l as Gt,s as Ip,cC as Tp,cD as Zr,cE as Ep,aL as eo,cF as Rp,cG as dr,O as yu,cH as Mp,cI as Op,cJ as Wn,cK as Bp,cL as Fp,aA as _p,cM as ci,cN as wu,cO as Ia,cP as Lp,cQ as vu,cR as $p,aE as _i,cS as Li,cT as Al,cU as zp,cV as Dl,cW as _r,c as Gr,d as Ta,a1 as Wp,cX as Su,cY as Ar,cZ as Lr,c_ as Kp,c$ as Vp,d0 as Up,_ as Ea,az as Hp,d1 as Gp,d2 as qp,d3 as Yp,d4 as Qp,d5 as ju,d6 as fn,d7 as Xp,d8 as ku,d9 as Jp,da as $i,db as Zp,dc as Cu,dd as fs,de as eg,df as tg,dg as sg,dh as Nu,di as ng,dj as Ra,dk as Au,a3 as Io,dl as zi,dm as qo,a as Ma,dn as Oa,a2 as rg,dp as Pl,dq as og,dr as Wi,ds as Du,dt as ig,ar as Pu,du as ag,P as Ki,L as lg,dv as Il,dw as cg,dx as dg,dy as Jt,dz as ug,dA as Ln,dB as Ba,dC as Iu,dD as fg,dE as Tu,dF as Eu,dG as mg,E as hg,dH as pg,dI as gg,dJ as xg,dK as Tl,dL as bg,dM as yg,dN as Ru,F as wg,dO as vg,dP as Sg,dQ as wo,dR as jg,dS as kg,dT as Cg,dU as Ng,e as Fa,U as _a,T as La,V as $a,dV as Yo,dW as Ag,dX as qr,a0 as Dg,dY as Pg,dZ as El,d_ as Ig,d$ as Tg,e0 as Eg,aY as Rl,a7 as Ml,a6 as Ol,e1 as Rg,aT as Vi,e2 as Mg,M as Og,N as di,e3 as Bg,e4 as Fg,e5 as Mu,e6 as Ou,e7 as Bu,e8 as _g,G as za,e9 as Lg,a4 as $g,aj as zg,ea as Wg,eb as Bl,ec as Kg,ed as Vg,ee as Ug,ef as Hg,eg as To,eh as Gg,ei as Fl,ej as qg,ek as Yg,el as Qg,em as Xg,en as Ui,eo as Jg,ep as vo,eq as Zg,i as ex,er as tx,es as sx,et as nx,eu as rx,ev as ox,ew as ix,a8 as ax,ex as lx,ey as cx,ez as dx,eA as ux,eB as _l,eC as fx,aM as mx,aN as hx,aP as px,aO as gx,aR as Ll,aS as $l,aV as zl,aW as Wl,aU as Fu,aX as _u,eD as xx,b9 as bx,ba as yx,bb as wx,bc as vx,bd as Sx,b3 as jx,b5 as kx,b6 as Cx,b7 as Nx,b8 as Ax}from"./useAppFontEffects-ne84JBVL.js";import{u as Lu,S as Kl,C as Dx,t as Px,W as $u,f as Ix,G as Tx,a as Ex}from"./useRootScrollLock-Cpf1qoGp.js";import{u as Un,O as Vl,D as Rx,a as Mx,b as Ox,n as Bx,f as Fx,c as Ul,s as _x,d as Lx,e as $x,r as zx}from"./scheduledTasksApi-B2SWMGEU.js";import{f as Qo,h as Dn,T as Xo,M as Jo,D as Zo,j as ei,d as Wx,b as Kx,k as Vx,i as Ux}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as ti,S as Wa,h as Hx,a as zu,v as Wu,s as Gx}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as si}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as Ku,M as Vu,C as Uu,a as Hi,b as Gi,c as qi,d as Hu,e as qx,f as Yx}from"./vendor-base-ui-CsXYnR5c.js";import{c as to,u as rr,d as Qx,p as Xx}from"./vendor-zustand-BAGL70zf.js";import{g as Jx,a as Zx,E as Gu,b as eb,c as tb,d as sb,e as nb,i as rb}from"./contextPanelEmbeddedChat-CirXEPJq.js";import{P as ob}from"./PluginPane-DEcgDQ9h.js";import{a as Ka,s as jr,r as qu}from"./vendor-zod-CgAdXWZO.js";import{u as ib}from"./vendor-tanstack-react-virtual-ClYN8CzB.js";import{d as ab}from"./vendor-tanstack-virtual-core-BewVQryB.js";import{d as Yu}from"./vendor-cron-parser-CUcP7OfX.js";const lb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC",cb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC",ui=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?lb:t.id==="terminal"?cb:void 0}),Hl=t=>{const e=Ze.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=t,[o,l]=c.useState(!1);let a;e[0]!==n?(a=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=a):a=e[1];const d=a,u=r||i;if(u&&!o){let x;e[2]===Symbol.for("react.memo_cache_sentinel")?(x=()=>l(!0),e[2]=x):x=e[2];let b;return e[3]!==u?(b=s.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:x}),e[3]=u,e[4]=b):b=e[4],b}let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=Oe("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=h):h=e[5];let f;return e[6]!==d?(f=s.jsx("span",{className:h,children:d}),e[6]=d,e[7]=f):f=e[7],f},db=t=>{const e=Ze.c(75),{directory:n,className:r}=t,{t:i}=jt(),o=Un(ub),l=Un(fb),a=Un(mb),d=Un(hb),u=Un(pb),h=Un(gb),f=Un(xb);let x,b;e[0]!==u?(x=()=>{u()},b=[u],e[0]=u,e[1]=x,e[2]=b):(x=e[1],b=e[2]),c.useEffect(x,b);const w=xn()&&Vo();let v;e:{let we;e[3]!==l||e[4]!==o?(we=l.find(pe=>pe.id===o)??l.find(bb)??l[0]??Vl[0],e[3]=l,e[4]=o,e[5]=we):we=e[5];const ye=we;if(ye){let pe;e[6]!==ye?(pe=ui(ye),e[6]=ye,e[7]=pe):pe=e[7],v=pe;break e}let Ae;e[8]===Symbol.for("react.memo_cache_sentinel")?(Ae=ui(Vl[0]),e[8]=Ae):Ae=e[8],v=Ae}const y=v;if(!w||!n||l.length===0)return null;let m;e[9]!==n?(m=async we=>{await Om(n,we.id,we.appName)||await Bm(n,we.appName)},e[9]=n,e[10]=m):m=e[10];const p=m;let S;e[11]!==p||e[12]!==f?(S=async we=>{await f(we.id),await p(we)},e[11]=p,e[12]=f,e[13]=S):S=e[13];const g=S;let C;e[14]!==n||e[15]!==i?(C=async()=>{(await gn(n)).ok&&Le.success(i("openInApp.toast.pathCopied"))},e[14]=n,e[15]=i,e[16]=C):C=e[16];const k=C;let j;e[17]!==r?(j=Oe("app-region-no-drag inline-flex h-7 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r),e[17]=r,e[18]=j):j=e[18];let D;e[19]!==p||e[20]!==y?(D=()=>{p(y)},e[19]=p,e[20]=y,e[21]=D):D=e[21];const I=d&&"animate-pulse";let A;e[22]!==I?(A=Oe("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",I),e[22]=I,e[23]=A):A=e[23];let P;e[24]!==y.label||e[25]!==i?(P=i("openInApp.actions.openInAria",{app:y.label}),e[24]=y.label,e[25]=i,e[26]=P):P=e[26];let T;e[27]!==y.fallbackIconDataUrl||e[28]!==y.iconDataUrl||e[29]!==y.label?(T=s.jsx(Hl,{label:y.label,iconDataUrl:y.iconDataUrl,fallbackIconDataUrl:y.fallbackIconDataUrl}),e[27]=y.fallbackIconDataUrl,e[28]=y.iconDataUrl,e[29]=y.label,e[30]=T):T=e[30];let L;e[31]!==A||e[32]!==P||e[33]!==T||e[34]!==D?(L=s.jsx("button",{type:"button",onClick:D,className:A,"aria-label":P,children:T}),e[31]=A,e[32]=P,e[33]=T,e[34]=D,e[35]=L):L=e[35];let $;e[36]===Symbol.for("react.memo_cache_sentinel")?($=Oe("inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors"),e[36]=$):$=e[36];let K;e[37]!==i?(K=i("openInApp.actions.chooseAppAria"),e[37]=i,e[38]=K):K=e[38];let F;e[39]===Symbol.for("react.memo_cache_sentinel")?(F=s.jsx(M,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=F):F=e[39];let W;e[40]!==K?(W=s.jsx(zs,{asChild:!0,children:s.jsx("button",{type:"button",className:$,"aria-label":K,children:F})}),e[40]=K,e[41]=W):W=e[41];let N;e[42]!==k?(N=()=>{k()},e[42]=k,e[43]=N):N=e[43];let R;e[44]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx(M,{name:"file-copy",className:"h-4 w-4"}),e[44]=R):R=e[44];let E;e[45]!==i?(E=i("openInApp.actions.copyPath"),e[45]=i,e[46]=E):E=e[46];let X;e[47]!==E?(X=s.jsx("span",{className:"typography-ui-label text-foreground",children:E}),e[47]=E,e[48]=X):X=e[48];let J;e[49]!==N||e[50]!==X?(J=s.jsxs(Kt,{className:"flex items-center gap-2",onClick:N,children:[R,X]}),e[49]=N,e[50]=X,e[51]=J):J=e[51];let re;e[52]===Symbol.for("react.memo_cache_sentinel")?(re=s.jsx(Os,{}),e[52]=re):re=e[52];let fe;if(e[53]!==l||e[54]!==g||e[55]!==y.id){let we;e[57]!==g||e[58]!==y.id?(we=ye=>{const Ae=ui(ye);return s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{g(ye)},children:[s.jsx(Hl,{label:ye.label,iconDataUrl:ye.iconDataUrl,fallbackIconDataUrl:Ae.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:ye.label}),y.id===ye.id?s.jsx(M,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},ye.id)},e[57]=g,e[58]=y.id,e[59]=we):we=e[59],fe=l.map(we),e[53]=l,e[54]=g,e[55]=y.id,e[56]=fe}else fe=e[56];let ne;e[60]!==a||e[61]!==h||e[62]!==i?(ne=a?s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{h(!0)},children:[s.jsx(M,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:i("openInApp.actions.refreshApps")})]}):null,e[60]=a,e[61]=h,e[62]=i,e[63]=ne):ne=e[63];let te;e[64]!==J||e[65]!==fe||e[66]!==ne?(te=s.jsxs(Ws,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[J,re,fe,ne]}),e[64]=J,e[65]=fe,e[66]=ne,e[67]=te):te=e[67];let ue;e[68]!==W||e[69]!==te?(ue=s.jsxs(Ks,{children:[W,te]}),e[68]=W,e[69]=te,e[70]=ue):ue=e[70];let Se;return e[71]!==L||e[72]!==ue||e[73]!==j?(Se=s.jsxs("div",{className:j,children:[L,ue]}),e[71]=L,e[72]=ue,e[73]=j,e[74]=Se):Se=e[74],Se};function ub(t){return t.selectedAppId}function fb(t){return t.availableApps}function mb(t){return t.isCacheStale}function hb(t){return t.isScanning}function pb(t){return t.initialize}function gb(t){return t.loadInstalledApps}function xb(t){return t.selectApp}function bb(t){return t.id===Rx}const Eo=new Map,Yi=new Set,Qu=()=>{for(const t of Yi)t()},fi=(t,e)=>{const n=t.trim();n&&(e.length===0?Eo.delete(n):Eo.set(n,[...e]),Qu())},yb=t=>{Eo.delete(t.trim())&&Qu()},Xu=[],wb=t=>Eo.get(t.trim())??Xu,vb=t=>(Yi.add(t),()=>{Yi.delete(t)}),Sb=t=>{const e=Ze.c(2);let n;return e[0]!==t?(n=()=>wb(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(vb,n,jb)};function jb(){return Xu}const kb=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Cb=["dev","start","preview","serve"];async function Nb(t,e,n){if(!t)return null;const r=Pb(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const i=Ib(n);if(i){const o=await Tb(t);return{command:`${o==="npm"?"npm run":o==="yarn"?"yarn":o==="pnpm"?"pnpm":o==="bun"?"bun run --shell=bun":"npm run"} ${i}`,label:`Start (${i})`}}}if(await Ab(t)){const i=await Db(),o=typeof i=="number"&&Number.isFinite(i)&&i>0?i:8e3;return{command:`python3 -m http.server ${o}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${o}/`}}return null}async function Ab(t){const e=`${t}/index.html`,n=await Ro(e,t);return typeof n=="string"&&n.trim().length>0}async function Db(){try{const t=await ls("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),n=typeof e?.port=="number"?e.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function Pb(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(Cb.some(i=>n.includes(i)))return e}return null}function Ib(t){for(const{pattern:e}of kb)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Tb(t){const e=await Ro(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),i=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(i.startsWith("bun@"))return"bun";if(i.startsWith("pnpm@"))return"pnpm";if(i.startsWith("yarn@"))return"yarn";if(i.startsWith("npm@"))return"npm"}catch{}const n=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,i]of n){const o=await Ro(`${t}/${r}`,t);if(typeof o=="string"&&o.trim().length>0)return i}return"npm"}async function Ro(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),i=await ls(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(i.ok)return i.text()}catch{}const n=Id()?.files;if(n?.readFile)try{const r=await n.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await ls(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Eb(t){try{const e=await Ro(`${t}/package.json`,t);if(e==null)return null;const r=JSON.parse(e).scripts;return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}const un="__openchamber_auto_discover_preview__",Rb=15e3,Mb=3e3,mi=t=>t.id===un?"scan-2":bh.find(n=>n.key===t.icon)?.Icon??"play",Ob=t=>{const e=(t||"").trim();if(!e)return null;const n=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},Bb=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:i=!1})=>{const{t:o}=jt(),{currentTheme:l}=or(),{terminal:a,runtime:d}=vn(),u=ir(),{isMobile:h}=zn(),f=c.useMemo(()=>xn(),[]),x=gl(G=>G.instances),b=gl(G=>G.load),w=Pe(G=>G.terminalShell),v=Pe(G=>G.terminalLoginShells.includes(G.terminalShell)),y=Pe(G=>G.setSettingsPage),m=Pe(G=>G.setSettingsDialogOpen),p=Pe(G=>G.setSettingsProjectsSelectedId),S=Pe(G=>G.openContextPreview),g=Ot(G=>G.ensureDirectory),C=Ot(G=>G.reconcileServerSessions),k=Ot(G=>G.setTabLabel),j=Ot(G=>G.setTabIconKey),D=Ot(G=>G.setActiveTab),I=Ot(G=>G.setConnecting),A=Ot(G=>G.setTabSessionId),P=Ot(G=>G.setTabPurpose),T=Ot(G=>G.allocateActionExecution),L=Ot(G=>G.setTabLifecycle),$=Ot(G=>G.setTabPreviewUrl),K=Ot(G=>G.matchesActionExecution),F=Ot(G=>G.captureStartedActionMutationRevisions),[W,N]=c.useState([]),R=c.useRef(null),[E,X]=c.useState(null),[J,re]=c.useState(!1),fe=c.useRef({}),ne=c.useRef({}),te=c.useRef({}),ue=c.useRef(new Set),Se=c.useRef(0),[we,ye]=c.useState({}),Ae=t?.id??null,pe=t?.path??"",O=c.useMemo(()=>Ae?{id:Ae,path:pe}:null,[Ae,pe]);c.useEffect(()=>{f&&b().catch(()=>{})},[f,b]);const Q=c.useCallback(async G=>{await Uo(G)},[]),le=c.useCallback(async()=>{if(!O)return;const G=Se.current+1;Se.current=G,re(!0);try{const Z=await vl(O);if(Se.current!==G)return;R.current=Z;const je=Z.projectActions;N(je),X(Ie=>Ie===un||Ie&&je.some(Ve=>Ve.id===Ie)?Ie:null)}catch{if(Se.current!==G)return}finally{Se.current===G&&re(!1)}},[O]),H=c.useMemo(()=>ai(e||O?.path||""),[e,O?.path]),me=c.useMemo(()=>ai(O?.path||""),[O?.path]),ge=c.useMemo(()=>ai(u||"")||H,[u,H]),oe=c.useRef(ge);c.useEffect(()=>{oe.current=ge},[ge]);const de=Ot(G=>H?G.getDirectoryState(H):void 0),_=Ot(G=>me&&me!==H?G.getDirectoryState(me):void 0),B=c.useMemo(()=>{const G=H?[{directory:H,state:de}]:[];return me&&me!==H&&G.push({directory:me,state:_}),G},[de,H,me,_]),he=c.useMemo(()=>{const G=H?[H]:[];return me&&me!==H&&G.push(me),G},[H,me]),ve=c.useCallback(G=>G.id!==un&&G.runIn==="parent"&&me||H,[H,me]),Re=c.useCallback((G,Z,je)=>`${G}::${Z}::${je}`,[]),ce=c.useCallback((G,Z,je=Ot.getState())=>G?je.getDirectoryState(G)?.tabs.find(Ie=>Ie.purpose.type==="project-action"&&Ie.purpose.actionId===Z)??null:null,[]),se=c.useMemo(()=>{const G={};for(const{directory:Z,state:je}of B)for(const Ie of je?.tabs??[]){if(Ie.purpose.type!=="project-action"||!Ie.purpose.executionId||!Ie.terminalSessionId||Ie.lifecycle==="idle"||Ie.lifecycle==="exited")continue;const Ve=cn(Z,Ie.purpose.actionId),Je=Re(Z,Ie.purpose.actionId,Ie.purpose.executionId);G[Ve]={directory:Z,actionId:Ie.purpose.actionId,tabId:Ie.id,sessionId:Ie.terminalSessionId,executionId:Ie.purpose.executionId,status:Ie.lifecycle==="stopping"?"stopping":we[Je]?"waiting-for-preview":"running"}}return G},[Re,we,B]),q=c.useCallback((G,Z,je)=>{const Ie=cn(G,Z),Ve=Re(G,Z,je),it=fe.current[Ie]?.executionId===je,at=globalThis.window,Ye=vt=>{at?.clearTimeout(te.current[vt]),delete te.current[vt]};it&&(delete fe.current[Ie],Ye(Ie)),ne.current[Ve]?.(),delete ne.current[Ve],Ye(Ve),ye(vt=>{if(!vt[Ve])return vt;const Ue={...vt};return delete Ue[Ve],Ue})},[Re]),z=c.useCallback(G=>{ne.current[G]?.(),delete ne.current[G]},[]),ee=c.useCallback(G=>{window.clearTimeout(te.current[G]),delete te.current[G]},[]);c.useEffect(()=>{const G=ne.current,Z=te.current;return()=>{for(const je of Object.keys(G))z(je);for(const je of Object.keys(Z))ee(je)}},[ee,z]),c.useEffect(()=>{const G=new Set(he);for(const Z of Object.values(fe.current))G.has(Z.directory)||q(Z.directory,Z.actionId,Z.executionId);for(const Z of Object.keys(ne.current)){const je=Z.split("::",1)[0]??"";G.has(je)||z(Z)}},[q,z,he]);const ae=c.useCallback((G,Z)=>{Pe.getState().openContextPanelTab(G,{mode:"terminal",targetDirectory:Z===G?null:Z})},[]),Ne=c.useMemo(()=>E?W.find(G=>G.id===E)??null:null,[W,E]),Ce=c.useMemo(()=>({id:un,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),We=!h,Ee=c.useMemo(()=>We?[Ce,...W]:W,[W,Ce,We]);c.useEffect(()=>{le()},[le]),c.useEffect(()=>{const G=he.map(Z=>Ii(a,Z,F,je=>C(Z,je.sessions,{startedActionMutationRevisions:je.startedActionMutationRevisions})));return()=>{for(const Z of G)Z()}},[F,C,a,he]),c.useEffect(()=>{for(const{directory:G,state:Z}of B)if(G)for(const je of Z?.tabs??[]){if(je.purpose.type!=="project-action")continue;const Ie=je.purpose.actionId,Ve=Ee.find(at=>at.id===Ie),Je=Ve?.name??Ie,it=Ve?.icon||"play";je.label!==Je&&k(G,je.id,Je),je.iconKey!==it&&j(G,je.id,it)}},[Ee,j,k,B]),c.useEffect(()=>{const G=globalThis.window;if(!G)return;const Z=je=>{const Ie=je.detail;Ae&&(Ie?.projectId&&Ie.projectId!==Ae||le())};return G.addEventListener(xl,Z),()=>{G.removeEventListener(xl,Z)}},[le,Ae]),c.useEffect(()=>{E&&(E===un&&We||W.some(G=>G.id===E)||X(null))},[W,We,E]),c.useEffect(()=>{const G=je=>{delete te.current[je];const Ie=fe.current[je];if(!Ie||Ie.openedUrl)return;const Ve=Re(Ie.directory,Ie.actionId,Ie.executionId),Je=Ie.announced;if(Je.length!==0){if(window.clearTimeout(te.current[Ve]),delete te.current[Ve],Ie.openedUrl=!0,ye(it=>{if(!it[Ve])return it;const at={...it};return delete at[Ve],at}),Je.length===1){fi(Ie.directory,[]),$(Ie.directory,Ie.tabId,Je[0],{locked:!1,autoOpened:!0}),S(Ie.directory,Je[0]);return}Ie.offering=!0,fi(Ie.directory,Je),Pe.getState().openContextSurface(Ie.directory,"browser"),Le.info(o("projectActions.toast.multipleServers"))}},Z=()=>{const je=Ot.getState(),Ie=je.sessions,Ve=se;for(const[Je,it]of Object.entries(Ve)){const Ye=Ie.get(it.directory)?.tabs.find(ft=>ft.id===it.tabId);if(!Ye||Ye.terminalSessionId!==it.sessionId){q(it.directory,it.actionId,it.executionId);continue}const vt=fe.current[Je],Ue=vt?.executionId===it.executionId?vt:{hostDirectory:oe.current||it.directory,directory:it.directory,tabId:it.tabId,actionId:it.actionId,executionId:it.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1};fe.current[Je]=Ue;const Pt=Ee.find(ft=>ft.id===it.actionId),ke=je.getBuffer(it.directory,it.tabId).chunks;if(!Pt||ke.length===0)continue;const xt=ke.filter(ft=>Ue.lastSeenChunkId===null||ft.id>Ue.lastSeenChunkId);if(xt.length===0)continue;const Ct=xt.map(ft=>ft.data).join(""),Tt=`${Ue.tail}${Ct}`;if(Ue.openInPreview&&(!Ue.openedUrl||Ue.offering)){const ft=gh(Tt),Be=Ue.announced.length;for(const He of ft)Ue.announced.includes(He)||Ue.announced.push(He);const Ke=Ue.announced.length-Be;Ue.offering&&Ke>0?fi(it.directory,Ue.announced):!Ue.openedUrl&&Be===0&&Ue.announced.length>0&&(window.clearTimeout(te.current[Je]),te.current[Je]=window.setTimeout(()=>G(Je),Mb))}const qe=!Ue.openedUrl&&Pt.autoOpenUrl===!0&&!Ue.openInPreview?xh(Tt):null,ze=xt[xt.length-1]?.id??Ue.lastSeenChunkId;if(Ue.lastSeenChunkId=ze,Ue.tail=Tt.slice(-512),qe)if(Ue.openedUrl=!0,Ue.openInPreview){const ft=Ve[Je];ft&&($(ft.directory,ft.tabId,qe,{locked:!1,autoOpened:!1,expectedExecutionId:ft.executionId}),ft.status==="waiting-for-preview"&&ye(Be=>{const Ke=Re(ft.directory,ft.actionId,ft.executionId);if(!Be[Ke])return Be;const He={...Be};return delete He[Ke],He}),window.clearTimeout(te.current[Je]),delete te.current[Je],S(ft.directory,qe))}else Q(qe),Le.success(o("projectActions.toast.openedUrlFromOutput"));fe.current[Je]=Ue}for(const Je of Object.keys(fe.current))if(!Ve[Je]){const it=fe.current[Je],at=it?Ie.get(it.directory)?.tabs.find(vt=>vt.id===it.tabId):void 0;if(at?.purpose.type==="project-action"&&at.purpose.executionId===it?.executionId&&!!at.terminalSessionId&&at.lifecycle!=="idle"&&at.lifecycle!=="exited")continue;delete fe.current[Je],window.clearTimeout(te.current[Je]),delete te.current[Je]}};return Z(),Ot.subscribe((je,Ie)=>{(je.sessions!==Ie.sessions||je.buffers!==Ie.buffers)&&Z()})},[q,oe,Ee,Re,S,Q,se,$,o]),c.useEffect(()=>{for(const{directory:G,state:Z}of B)for(const je of Z?.tabs??[]){if(je.purpose.type!=="project-action"||!je.purpose.executionId||!je.terminalSessionId||je.lifecycle!=="running")continue;const Ie=je.purpose.actionId,Ve=je.purpose.executionId,Je=Re(G,Ie,Ve);if(ne.current[Je])continue;const it=a.connect(je.terminalSessionId,{onEvent:at=>{if(!K(G,je.id,Ve))return;at.type==="snapshot"&&(Ot.getState().replaceBuffer(G,je.id,at.data??"",at.sequence??0,ll(at)),at.status==="running"&&Ot.getState().setTabLifecycle(G,je.id,"running",{expectedExecutionId:Ve}),at.status==="exited"&&(Ot.getState().setTabLifecycle(G,je.id,"exited",{expectedExecutionId:Ve}),Ot.getState().setTabPurpose(G,je.id,{type:"project-action",actionId:Ie,executionId:null}),q(G,Ie,Ve)));const Ye=at.type==="data"?at.data??"":"";Ye&&Ot.getState().appendToBuffer(G,je.id,Ye,at.sequence,at.replayData),at.type==="exit"&&(Ot.getState().setTabLifecycle(G,je.id,"exited",{expectedExecutionId:Ve}),Ot.getState().setTabPurpose(G,je.id,{type:"project-action",actionId:Ie,executionId:null}),q(G,Ie,Ve))},onError:(at,Ye)=>{!Ye||!K(G,je.id,Ve)||(Ot.getState().setTabLifecycle(G,je.id,"exited",{expectedExecutionId:Ve}),Ot.getState().setTabSessionId(G,je.id,null,{expectedExecutionId:Ve}),Ot.getState().setTabPurpose(G,je.id,{type:"project-action",actionId:Ie,executionId:null}),q(G,Ie,Ve))}});ne.current[Je]=it.close}},[q,Re,K,a,B]);const xe=c.useCallback(async G=>{const Z=ve(G);if(!Z)throw new Error(o("projectActions.error.noActiveDirectory"));const je=cn(Z,G.id);g(Z);const Ie=Ot.getState(),Ve=ce(Z,G.id,Ie),Je=Ve?.id??Ie.createTab(Z);k(Z,Je,G.name),j(Z,Je,G.icon||"play"),Ve||P(Z,Je,{type:"project-action",actionId:G.id,executionId:null}),D(Z,Je);const at=Ot.getState().getDirectoryState(Z)?.tabs.find(Ye=>Ye.id===Je);return{executionDirectory:Z,key:je,tabId:Je,sessionId:at?.terminalSessionId??null,executionId:at?.purpose.type==="project-action"?at.purpose.executionId:null}},[g,ve,ce,D,j,k,P,o]),$e=c.useCallback(async G=>{if(d.isVSCode||!i&&h)return;if(!H){Le.error(o("projectActions.error.noActiveDirectoryForAction"));return}const Z=cn(ve(G),G.id),je=se[Z];if(je&&je.status==="running"||ue.current.has(Z))return;ue.current.add(Z);let Ie=null;try{const Ve=G.id===un?await(async()=>{const[Ke,He]=await Promise.all([Jh({id:O?.id??"",path:H}),Eb(H)]),nt=await Nb(H,Ke.actions,He);if(!nt)throw new Error(o("contextPanel.preview.noDevServer"));return{id:un,name:o("projectActions.actions.autoDiscover"),command:nt.command,icon:"scan-2",autoOpenUrl:!0,openUrl:nt.previewUrlHint||""}})():G,Je=Ve.autoOpenUrl===!0&&(Ve.openUrl||"").trim().length>0,it=!Je&&G.id!==un,at=oe.current||H,{executionDirectory:Ye,key:vt,tabId:Ue}=await xe(Ve),Pt=uh(Ve.command);if(!Pt)throw new Error(o("projectActions.error.failedToRunAction"));const ke=Ve.autoOpenUrl===!0&&f&&(Ve.desktopOpenSshForward||"").trim().length>0,xt=Ve.autoOpenUrl?Ob(Ve.openUrl):null,Ct=Ve.autoOpenUrl&&f?fh(Ve.desktopOpenSshForward,x):null;if(a.listSessions){const Ke=ce(Ye,Ve.id);if(Ke?.purpose.type==="project-action"&&Ke.purpose.executionId===null){const He=await mh(a,Ye,{captureStartedActionMutationRevisions:F});He&&C(Ye,He.sessions,{startedActionMutationRevisions:He.startedActionMutationRevisions})}}const Tt=ce(Ye,Ve.id);let qe,ze;if(Tt?.lifecycle==="running"&&Tt.terminalSessionId&&Tt.purpose.type==="project-action"&&Tt.purpose.executionId)qe=Tt.terminalSessionId,ze=Tt.purpose.executionId;else{const Ke=Tt?.purpose.type==="project-action"?Tt.purpose.executionId:null;Ke&&q(Ye,Ve.id,Ke);const He=T(Ye,Ue,Ve.id);if(!He)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));Ie={directory:Ye,tabId:Ue,id:He},I(Ye,Ue,!0,{expectedExecutionId:He});const nt=await hh({terminal:a,createOptions:{cwd:Ye,shell:w,loginShell:v,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground},command:Pt,isRunStillExpected:()=>K(Ye,Ue,He),purpose:{type:"project-action",actionId:Ve.id,executionId:He}});if(!K(Ye,Ue,He)){nt.sessionId===He&&await a.close(nt.sessionId).catch(()=>{});return}ze=nt.purpose?.type==="project-action"?nt.purpose.executionId:He,qe=nt.sessionId,P(Ye,Ue,{type:"project-action",actionId:Ve.id,executionId:ze}),A(Ye,Ue,qe,{expectedExecutionId:ze}),I(Ye,Ue,!1,{expectedExecutionId:ze})}it&&at&&ae(at,Ye),fe.current[vt]={hostDirectory:at,directory:Ye,tabId:Ue,actionId:Ve.id,executionId:ze,lastSeenChunkId:null,openedUrl:!!Ct||!!xt||Je,tail:"",openInPreview:Ve.id===un,announced:[],offering:!1};const ft=Re(Ye,Ve.id,ze);I(Ye,Ue,!0,{expectedExecutionId:ze});const Be=a.connect(qe,{onEvent:Ke=>{if(!K(Ye,Ue,ze)||Ke.purpose?.type==="project-action"&&Ke.purpose.executionId!==ze)return;Ke.type==="snapshot"&&(Ot.getState().replaceBuffer(Ye,Ue,Ke.data??"",Ke.sequence??0,ll(Ke)),Ot.getState().setConnecting(Ye,Ue,!1,{expectedExecutionId:ze}),Ke.purpose?.type==="project-action"&&Ot.getState().setTabPurpose(Ye,Ue,{type:"project-action",actionId:Ke.purpose.actionId,executionId:Ke.purpose.executionId}),Ke.status==="running"&&Ot.getState().setTabLifecycle(Ye,Ue,"running",{expectedExecutionId:ze}),Ke.status==="exited"&&(Ot.getState().setTabLifecycle(Ye,Ue,"exited",{expectedExecutionId:ze}),Ot.getState().setTabPurpose(Ye,Ue,{type:"project-action",actionId:Ve.id,executionId:null}),q(Ye,Ve.id,ze)));const He=Ke.type==="data"?Ke.data??"":"";He&&Ot.getState().appendToBuffer(Ye,Ue,He,Ke.sequence,Ke.replayData),Ke.type==="exit"&&(Ot.getState().setTabLifecycle(Ye,Ue,"exited",{expectedExecutionId:ze}),Ot.getState().setConnecting(Ye,Ue,!1,{expectedExecutionId:ze}),Ot.getState().setTabPurpose(Ye,Ue,{type:"project-action",actionId:Ve.id,executionId:null}),q(Ye,Ve.id,ze))},onError:(Ke,He)=>{K(Ye,Ue,ze)&&(Ot.getState().setConnecting(Ye,Ue,!1,{expectedExecutionId:ze}),He&&(Ot.getState().setTabLifecycle(Ye,Ue,"exited",{expectedExecutionId:ze}),Ot.getState().setTabSessionId(Ye,Ue,null,{expectedExecutionId:ze}),Ot.getState().setTabPurpose(Ye,Ue,{type:"project-action",actionId:Ve.id,executionId:null}),q(Ye,Ve.id,ze)))}});if(!K(Ye,Ue,ze)){Be.close();return}ne.current[ft]?.(),ne.current[ft]=Be.close,window.clearTimeout(te.current[ft]),delete te.current[ft],Ve.id===un&&!xt&&(ye(Ke=>({...Ke,[ft]:!0})),te.current[ft]=window.setTimeout(()=>{delete te.current[ft];const Ke=fe.current[vt];!Ke||Ke.executionId!==ze||Ke.openedUrl||Ke.offering||K(Ye,Ue,ze)&&(ye(He=>{if(!He[ft])return He;const nt={...He};return delete nt[ft],nt}),Ot.getState().setActiveTab(Ye,Ue),ae(Ke.hostDirectory,Ye))},Rb)),Ct?($(Ye,Ue,null,{locked:!0,expectedExecutionId:ze}),Q(Ct),Le.success(o("projectActions.toast.openedForwardedUrl"))):xt?($(Ye,Ue,xt,{locked:!0,autoOpened:!0,expectedExecutionId:ze}),S(at,xt),Le.success(o("projectActions.toast.openedActionUrl"))):Je?($(Ye,Ue,null,{locked:!0,expectedExecutionId:ze}),Le.error(o("projectActions.error.invalidCustomUrlFormat"))):ke?($(Ye,Ue,null,{locked:!0,expectedExecutionId:ze}),Le.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):$(Ye,Ue,null,{locked:!1,autoOpened:!1,expectedExecutionId:ze})}catch(Ve){if(Ie&&K(Ie.directory,Ie.tabId,Ie.id)){const{directory:Je,tabId:it,id:at}=Ie;q(Je,G.id,at),L(Je,it,"exited",{expectedExecutionId:at}),P(Je,it,{type:"project-action",actionId:G.id,executionId:null})}if(Ve instanceof Error&&Ve.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(Ve instanceof Error&&(Ve.message==="COMMAND_MODE_UNSUPPORTED"||Ve.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){Le.error(o("projectActions.error.failedToCreateTerminalSession"));return}Le.error(Ve instanceof Error?Ve.message:o("projectActions.error.failedToRunAction"))}finally{ue.current.delete(Z)}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,oe,x,xe,i,h,f,H,v,w,Q,S,se,ae,d.isVSCode,ve,K,q,Re,ce,C,T,F,I,L,P,$,A,O?.id,o,a]),V=c.useCallback(async G=>{const Z=cn(ve(G),G.id),je=se[Z];je&&await ph({terminal:a,sessionId:je.sessionId,isExecutionStillCurrent:()=>K(je.directory,je.tabId,je.executionId),markStopping:()=>{L(je.directory,je.tabId,"stopping",{expectedExecutionId:je.executionId})},restoreRunning:()=>{L(je.directory,je.tabId,"running",{expectedExecutionId:je.executionId})},clearSession:()=>{A(je.directory,je.tabId,null,{expectedExecutionId:je.executionId})},finalizeExit:()=>{L(je.directory,je.tabId,"exited",{expectedExecutionId:je.executionId}),P(je.directory,je.tabId,{type:"project-action",actionId:je.actionId,executionId:null}),q(je.directory,je.actionId,je.executionId)}})},[q,ve,K,se,L,P,A,a]),De=c.useCallback(()=>{const G=Ne??Ee[0];if(!G)return;const Z=cn(ve(G),G.id),je=se[Z];if(je?.status!=="stopping"){if(je){V(G);return}$e(G)}},[Ee,ve,$e,se,Ne,V]),Fe=c.useCallback(async G=>{if(G.source==="shared"&&O){const Z=R.current?.trust.trusted?R.current:await vl(O);if(R.current=Z,!await Zh(O,Z))return;R.current={...Z,trust:{...Z.trust,trusted:!0}}}await $e(G)},[$e,O]),_e=c.useCallback((G,Z=!1)=>{if(X(G.id),!Z){Fe(G);return}const je=cn(ve(G),G.id),Ie=se[je];if(Ie?.status!=="stopping"){if(Ie){V(G);return}Fe(G)}},[ve,Fe,se,V]),rt=c.useCallback(()=>{O?.id&&(p(O.id),y("projects"),m(!0))},[m,y,p,O?.id]),ct=Ne??Ee[0]??null,et=ct?se[cn(ve(ct),ct.id)]:null,pt=Ot(G=>et?G.getDirectoryState(et.directory)?.tabs.find(Z=>Z.id===et.tabId)?.previewUrl??null:null);if(d.isVSCode||!i&&h||!O||!H)return null;const kt=Ne??Ee[0]??null;if(!kt)return null;const wt=mi(kt),Xe=cn(ve(kt),kt.id),yt=se[Xe],Rt=yt?.status==="stopping",be=yt?.status==="waiting-for-preview",Ge=!!(yt&&pt),ut=()=>{!yt||!pt||S(yt.directory,pt)},Y=kt.id===un;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",disabled:J||Rt,className:Oe("app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2","typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:cursor-not-allowed",n),onClick:De,"aria-label":yt?o("projectActions.actions.stopNamedAria",{name:kt.name}):o("projectActions.actions.runNamedAria",{name:kt.name}),children:Rt||be?s.jsx(M,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):yt?s.jsx(M,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(M,{name:wt,className:"h-5 w-5"})})}),Y?s.jsx(Dt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),Ge?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("projectActions.actions.openPreview"),onClick:ut,children:s.jsx(M,{name:"global",className:"h-4 w-4"})})}),s.jsx(Dt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Ks,{children:[s.jsx(zs,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(M,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(Ws,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Kt,{className:"flex items-center gap-2",onClick:rt,children:[s.jsx(M,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Os,{}),Ee.map(G=>{const Z=mi(G),je=cn(ve(G),G.id),Ie=se[je],Ve=!!Ie,Je=Ie?.status==="stopping";return s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{_e(G,!0)},children:[s.jsx(M,{name:Z,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:G.name}),G.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Je||Ie?.status==="waiting-for-preview"?s.jsx(M,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Ve?s.jsx(M,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},G.id)})]})]})]}):s.jsxs("div",{className:Oe("app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r?"h-9":"h-7",n),children:[s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:De,disabled:J||Rt,className:Oe("inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover",r?"w-9 px-0":"px-2.5","transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed"),"aria-label":yt?o("projectActions.actions.stopNamedAria",{name:kt.name}):o("projectActions.actions.runNamedAria",{name:kt.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:Rt||be?s.jsx(M,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):yt?s.jsx(M,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(M,{name:wt,className:"h-4 w-4"})})})}),Y?s.jsx(Dt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),Ge?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:ut,className:Oe(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-foreground","hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":o("projectActions.actions.openPreview"),children:s.jsx(M,{name:"global",className:"h-4 w-4"})})}),s.jsx(Dt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Ks,{children:[s.jsx(zs,{asChild:!0,children:s.jsx("button",{type:"button",className:Oe(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(M,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(Ws,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Kt,{className:"flex items-center gap-2",onClick:rt,children:[s.jsx(M,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Os,{}),Ee.map(G=>{const Z=mi(G),je=cn(ve(G),G.id),Ie=se[je],Ve=!!Ie,Je=Ie?.status==="stopping";return s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{_e(G,!0)},children:[s.jsx(M,{name:Z,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:G.name}),G.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Je||Ie?.status==="waiting-for-preview"?s.jsx(M,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Ve?s.jsx(M,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},G.id)})]})]})]})},$r=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Fb=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const i=$r(n??"");if(i){const o=qd(t,e,i);if(o)return o}return t.find(o=>o.id===r)??null};function _b(){const t=Ht(w=>w.projects),e=Ht(w=>w.activeProjectId),n=tt(w=>w.availableWorktreesByProject),r=tt(w=>w.currentSessionId),i=ep(r??null),o=tt(w=>r?w.worktreeMetadata.get(r)?.path??"":""),l=tt(w=>w.newSessionDraft?.open?$r(w.newSessionDraft.bootstrapPendingDirectory??w.newSessionDraft.directoryOverride??""):""),a=c.useMemo(()=>$r(o||""),[o]),d=c.useMemo(()=>{const w=typeof i?.directory=="string"?i.directory:"";return $r(w||"")},[i?.directory]),u=a||d||l,h=c.useMemo(()=>Fb({projects:t,worktreesByProject:n,directory:u,activeProjectId:e}),[e,u,t,n]),f=c.useMemo(()=>$r(u||h?.path||""),[u,h?.path]),x=c.useMemo(()=>h?{id:h.id,path:h.path}:null,[h]),b=c.useRef(null);return c.useEffect(()=>{x&&f&&(b.current={projectRef:x,directory:f})},[f,x]),c.useMemo(()=>x&&f?{projectRef:x,directory:f}:b.current,[x,f])}const Lb=({transform:t})=>({...t,y:0}),$b={Item:Kt,Separator:Os},zb={Item:({className:t,...e})=>s.jsx(Vu,{className:Oe(Xd,t),...e}),Separator:({className:t,...e})=>s.jsx(Ku,{className:Oe(Qd,t),...e})},Wb=t=>{const e=Ze.c(67),{tab:n,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:d,onMenuOpenChangeComplete:u,children:h}=t,{t:f}=jt(),[x,b]=c.useState(!1),[w,v]=c.useState(!1),[y,m]=c.useState(!1);let p;e[0]!==n.id?(p={id:n.id},e[0]=n.id,e[1]=p):p=e[1];const{attributes:S,listeners:g,setNodeRef:C,transform:k,transition:j,isDragging:D}=ti(p);let I;e[2]!==f||e[3]!==n.session.title?(I=n.session.title?.trim()||f("sessions.sidebar.session.untitled"),e[2]=f,e[3]=n.session.title,e[4]=I):I=e[4];const A=I,P=!i&&(x||w),T=Sa(n.id),L=n.id;let $;e[5]!==n.session?($=Ds(n.session),e[5]=n.session,e[6]=$):$=e[6];const K=va(L,$),F=T?.type==="busy"||T?.type==="retry",N=Yd(n.id)>0&&!r&&!F,R=F||N;let E;e[7]!==F||e[8]!==f?(E=f(F?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[7]=F,e[8]=f,e[9]=E):E=e[9];const X=E;let J;e[10]!==d||e[11]!==y||e[12]!==r||e[13]!==x||e[14]!==o||e[15]!==n?(J=ge=>({session:n.session,open:x||y,isActive:r,select:()=>o(n),closeOtherTabs:()=>d(n.id),components:ge}),e[10]=d,e[11]=y,e[12]=r,e[13]=x,e[14]=o,e[15]=n,e[16]=J):J=e[16];const re=J;let fe;e[17]!==k?(fe=si.Translate.toString(k),e[17]=k,e[18]=fe):fe=e[18];let ne;e[19]!==fe||e[20]!==j?(ne={transform:fe,transition:j},e[19]=fe,e[20]=j,e[21]=ne):ne=e[21];const te=D&&"z-10 opacity-60";let ue;e[22]!==te?(ue=Oe("session-tab-slot flex h-7 w-44 shrink-0 touch-none",te),e[22]=te,e[23]=ue):ue=e[23];const Se=r?"true":"false";let we;e[24]!==r?(we=r?{"data-active-session-tab":!0}:{},e[24]=r,e[25]=we):we=e[25];let ye;e[26]!==u?(ye=ge=>u?.(ge),e[26]=u,e[27]=ye):ye=e[27];let Ae;e[28]!==h||e[29]!==X||e[30]!==r||e[31]!==K||e[32]!==F||e[33]!==re||e[34]!==x||e[35]!==l||e[36]!==u||e[37]!==o||e[38]!==P||e[39]!==a||e[40]!==R||e[41]!==i||e[42]!==f||e[43]!==n||e[44]!==A?(Ae=s.jsx(Uu,{render:ge=>s.jsxs("div",{...ge,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(n),onKeyDown:r?void 0:oe=>{(oe.key==="Enter"||oe.key===" ")&&(oe.preventDefault(),o(n))},onAuxClick:oe=>{oe.button===1&&(oe.preventDefault(),l(n.id))},"data-controls-open":P?"true":"false",className:Oe("session-tab group/session-tab relative flex h-7 w-full min-w-0 select-none items-center rounded-md px-2",r?"bg-interactive-selection text-interactive-selection-foreground":Oe("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",P&&"bg-interactive-hover text-foreground")),children:[s.jsxs("div",{className:Oe("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pr-10",P&&"pr-10"),children:[s.jsx("div",{className:Oe("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title"),children:r?h:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:s.jsx("span",{className:"block max-w-full overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4",children:A})})}),K?s.jsx(M,{name:"loader-4",className:"ml-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":f("sessions.aiRename.generating")}):R?s.jsx("span",{className:Oe("ml-1.5 h-1.5 w-1.5 shrink-0 rounded-full",F?"bg-primary":"bg-[var(--status-info)]",!i&&"group-hover/session-tab:opacity-0",P&&"opacity-0"),"aria-label":X}):null]}),i?null:s.jsxs("div",{onClick:Vb,onPointerDown:Ub,className:Oe("absolute right-1 top-1/2 hidden -translate-y-1/2 items-center gap-0.5","opacity-0 transition-opacity duration-150","group-hover/session-tab:flex group-hover/session-tab:opacity-100",P&&"flex opacity-100"),children:[s.jsxs(Ks,{open:x,onOpenChange:oe=>{b(oe),oe&&v(!0)},onOpenChangeComplete:oe=>{oe||v(!1),u?.(oe)},children:[s.jsx(zs,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"more",className:"size-4"})})}),s.jsx(Ws,{align:"start",className:"min-w-[190px]",children:a(re($b))})]}),s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.closeTab"),onClick:()=>l(n.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"close",className:"size-4"})})]})]})}),e[28]=h,e[29]=X,e[30]=r,e[31]=K,e[32]=F,e[33]=re,e[34]=x,e[35]=l,e[36]=u,e[37]=o,e[38]=P,e[39]=a,e[40]=R,e[41]=i,e[42]=f,e[43]=n,e[44]=A,e[45]=Ae):Ae=e[45];let pe,O;e[46]===Symbol.for("react.memo_cache_sentinel")?(pe={color:"var(--surface-elevated-foreground)"},O=Oe(Ri,"min-w-[190px]"),e[46]=pe,e[47]=O):(pe=e[46],O=e[47]);let Q;e[48]!==re||e[49]!==a?(Q=a(re(zb)),e[48]=re,e[49]=a,e[50]=Q):Q=e[50];let le;e[51]!==Q?(le=s.jsx(Hi,{children:s.jsx(Gi,{className:"app-region-no-drag z-50",children:s.jsx(qi,{"data-slot":"dropdown-menu-content",style:pe,className:O,children:Q})})}),e[51]=Q,e[52]=le):le=e[52];let H;e[53]!==y||e[54]!==ye||e[55]!==Ae||e[56]!==le?(H=s.jsxs(Hu,{open:y,onOpenChange:m,onOpenChangeComplete:ye,children:[Ae,le]}),e[53]=y,e[54]=ye,e[55]=Ae,e[56]=le,e[57]=H):H=e[57];let me;return e[58]!==S||e[59]!==g||e[60]!==C||e[61]!==ue||e[62]!==Se||e[63]!==we||e[64]!==H||e[65]!==ne?(me=s.jsx("div",{ref:C,style:ne,className:ue,"data-active":Se,...we,...S,...g,children:H}),e[58]=S,e[59]=g,e[60]=C,e[61]=ue,e[62]=Se,e[63]=we,e[64]=H,e[65]=ne,e[66]=me):me=e[66],me},Kb=t=>{const e=Ze.c(64),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=jt(),d=no(Hb),u=no(Gb),h=no(qb),f=no(Yb),x=tt(Qb),b=tt(Xb),w=$s(Jb);let v,y;e[0]!==x||e[1]!==u?(v=()=>{x&&u(x)},y=[x,u],e[0]=x,e[1]=u,e[2]=v,e[3]=y):(v=e[2],y=e[3]),c.useEffect(v,y);let m;if(e[4]!==w){m=new Map;for(const oe of w)m.set(oe.id,oe);e[4]=w,e[5]=m}else m=e[5];const p=m;let S;if(e[6]!==p||e[7]!==d){S=[];for(const oe of d){const de=p.get(oe);de&&S.push({id:oe,session:de})}e[6]=p,e[7]=d,e[8]=S}else S=e[8];const g=S;let C;e[9]!==b?(C=oe=>{b(oe.id,Ds(oe.session))},e[9]=b,e[10]=C):C=e[10];const k=C,j=Zb;let D;e[11]!==h||e[12]!==x||e[13]!==k||e[14]!==g?(D=oe=>{if(h(oe),x&&x!==oe){const de=g.find(_=>_.id===oe);de&&k(de)}},e[11]=h,e[12]=x,e[13]=k,e[14]=g,e[15]=D):D=e[15];const I=D;let A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A={activationConstraint:{distance:8}},e[16]=A):A=e[16];let P;e[17]===Symbol.for("react.memo_cache_sentinel")?(P={activationConstraint:{delay:200,tolerance:6}},e[17]=P):P=e[17];const T=Qo(Dn(Jo,A),Dn(Xo,P));let L;e[18]!==f?(L=oe=>{const{active:de,over:_}=oe;_&&de.id!==_.id&&f(String(de.id),String(_.id))},e[18]=f,e[19]=L):L=e[19];const $=L,K=c.useRef(null);let F;e[20]===Symbol.for("react.memo_cache_sentinel")?(F={left:!1,right:!1},e[20]=F):F=e[20];const[W,N]=c.useState(F);let R;e[21]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{const oe=K.current;if(!oe)return;const de=oe.scrollLeft>2,_=oe.scrollLeft+oe.clientWidth<oe.scrollWidth-2;N(B=>B.left===de&&B.right===_?B:{left:de,right:_})},e[21]=R):R=e[21];const E=R;let X;e[22]===Symbol.for("react.memo_cache_sentinel")?(X=()=>{E();const oe=K.current;if(!oe||!globalThis.ResizeObserver)return;const de=new ResizeObserver(E);return de.observe(oe),()=>de.disconnect()},e[22]=X):X=e[22];let J;e[23]!==g.length?(J=[E,g.length],e[23]=g.length,e[24]=J):J=e[24],c.useEffect(X,J);let re;e[25]===Symbol.for("react.memo_cache_sentinel")?(re=()=>{K.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[25]=re):re=e[25];let fe;e[26]!==x?(fe=[x],e[26]=x,e[27]=fe):fe=e[27],c.useEffect(re,fe);const ne=W.left&&W.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":W.left?"linear-gradient(to right, transparent, black 24px)":W.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let te;e[28]!==g?(te=g.map(ey),e[28]=g,e[29]=te):te=e[29];const ue=te;let Se;e[30]!==x||e[31]!==g?(Se=!x||!g.some(oe=>oe.id===x),e[30]=x,e[31]=g,e[32]=Se):Se=e[32];const we=Se;let ye;e[33]!==a?(ye=a("header.sessionTabs.stripAria"),e[33]=a,e[34]=ye):ye=e[34];let Ae;e[35]!==ne?(Ae=ne?{maskImage:ne,WebkitMaskImage:ne}:void 0,e[35]=ne,e[36]=Ae):Ae=e[36];let pe;e[37]===Symbol.for("react.memo_cache_sentinel")?(pe=[Lb],e[37]=pe):pe=e[37];let O;e[38]!==o||e[39]!==x||e[40]!==I||e[41]!==k||e[42]!==r||e[43]!==n||e[44]!==l||e[45]!==g?(O=g.map(oe=>s.jsx(Wb,{tab:oe,isActive:oe.id===x,suppressControls:oe.id===x&&l,onSelect:k,onClose:j,renderMenu:n,closeOtherTabs:I,onMenuOpenChangeComplete:r,children:oe.id===x?o:null},oe.id)),e[38]=o,e[39]=x,e[40]=I,e[41]=k,e[42]=r,e[43]=n,e[44]=l,e[45]=g,e[46]=O):O=e[46];let Q;e[47]!==O||e[48]!==ue?(Q=s.jsx(Wa,{items:ue,strategy:Hx,children:O}),e[47]=O,e[48]=ue,e[49]=Q):Q=e[49];let le;e[50]!==$||e[51]!==T||e[52]!==Q?(le=s.jsx(Zo,{sensors:T,collisionDetection:ei,modifiers:pe,onDragEnd:$,children:Q}),e[50]=$,e[51]=T,e[52]=Q,e[53]=le):le=e[53];let H;e[54]!==o||e[55]!==we?(H=we?s.jsx("div",{role:"tab","aria-selected":!0,className:"session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2","data-active":"true",children:s.jsx("div",{className:"min-w-0 flex-1",children:o})}):null,e[54]=o,e[55]=we,e[56]=H):H=e[56];let me;e[57]!==Ae||e[58]!==le||e[59]!==H?(me=s.jsxs("div",{ref:K,onScroll:E,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:Ae,children:[le,H]}),e[57]=Ae,e[58]=le,e[59]=H,e[60]=me):me=e[60];let ge;return e[61]!==ye||e[62]!==me?(ge=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":ye,children:me}),e[61]=ye,e[62]=me,e[63]=ge):ge=e[63],ge};function Vb(t){return t.stopPropagation()}function Ub(t){return t.stopPropagation()}function Hb(t){return t.tabIds}function Gb(t){return t.ensureTab}function qb(t){return t.closeOtherTabs}function Yb(t){return t.reorderTabs}function Qb(t){return t.currentSessionId}function Xb(t){return t.setCurrentSession}function Jb(t){return t.activeSessions}function Zb(t){tp(t)}function ey(t){return t.id}const Ju=async t=>{const{entry:e,session:n}=t,r=qt(),i={sessionId:n.id,sessionTitle:n.title,directory:n.directory};if(!(sp(e.action)&&np(e.guest,"conversation"))){await Sl(e,jl(e.action.id,i),t.t,r);return}let l=!1;const a=Qr(()=>{l=!0});let d;try{d=await t.loadRecords()}finally{a()}if(!l){if(!d){t.onLoadFailed();return}await Sl(e,jl(e.action.id,i,d),t.t,r)}};function Qi(t){const e=Ze.c(16),{sessionID:n,directory:r,open:i,Item:o}=t,{t:l}=jt(),{pending:a,disabled:d,hint:u,run:h}=yh(n,r,i),f=a?"loader-4":"ai-generate-2",x=a?"mr-1 size-4 animate-spin":"mr-1 size-[15px]";let b;e[0]!==f||e[1]!==x?(b=s.jsx(M,{name:f,className:x}),e[0]=f,e[1]=x,e[2]=b):b=e[2];let w;e[3]!==l?(w=l("sessions.aiRename.action"),e[3]=l,e[4]=w):w=e[4];let v;e[5]!==o||e[6]!==d||e[7]!==h||e[8]!==b||e[9]!==w?(v=s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(o,{disabled:d,onClick:h,className:"w-full",children:[b,w]})})}),e[5]=o,e[6]=d,e[7]=h,e[8]=b,e[9]=w,e[10]=v):v=e[10];let y;e[11]!==u?(y=s.jsx(Dt,{side:"right",children:u}),e[11]=u,e[12]=y):y=e[12];let m;return e[13]!==v||e[14]!==y?(m=s.jsxs(Nt,{children:[v,y]}),e[13]=v,e[14]=y,e[15]=m):m=e[15],m}const Xi=(t,e)=>({success:t(e.success),failure:t(e.failure),sourceVerificationFailed:t("sessions.sidebar.session.moveToWorktree.sourceVerificationFailed"),applyChangesFailed:t("sessions.sidebar.session.moveToWorktree.applyChangesFailed"),changesMayBeInDestination:t("sessions.sidebar.session.moveToWorktree.changesMayBeInDestination")}),Kn=to(()=>({pendingSessionIds:new Set,requestingSessionIds:new Set,confirmation:null})),Zu=t=>{const e=Ze.c(2);let n;return e[0]!==t?(n=r=>r.pendingSessionIds.has(t)||r.requestingSessionIds.has(t),e[0]=t,e[1]=n):n=e[1],Kn(n)},ty=()=>Kn(uy),ef=()=>Kn.getState().confirmation,Va=t=>{Kn.setState(e=>e.confirmation===t?e:{...e,confirmation:t})},Gl=(t,e)=>{Kn.setState(n=>{if(n.pendingSessionIds.has(t)===e)return n;const r=new Set(n.pendingSessionIds);return e?r.add(t):r.delete(t),{...n,pendingSessionIds:r}})},mr=(t,e)=>{Kn.setState(n=>{if(n.requestingSessionIds.has(t)===e)return n;const r=new Set(n.requestingSessionIds);return e?r.add(t):r.delete(t),{...n,requestingSessionIds:r}})},sy="Unable to apply your changes in the destination directory",ny=t=>t.status===400&&t.message.includes(sy),ry=async(t,e)=>{try{const d=(await Jd(t,{mode:"light"})).current?.trim();if(d)return d}catch{}const n=ht(t),r=ht(e)??e,i=tt.getState().availableWorktreesByProject,l=(i.get(r)??i.get(e)??[]).find(a=>ht(a.path)===n)?.branch?.trim();if(l)return l;throw new Error("Unable to determine the current branch")},ql=t=>{for(const e of t){const n=op(e.id);if(n==="unknown")throw new Error("Session status is unavailable");if(n==="active")throw new Error("Session is not idle")}};class tf extends Error{changesMayBeInDestination;constructor(e,n,r){super(e,{cause:n}),this.name="IncompleteRollbackError",this.changesMayBeInDestination=r}}const oy=(t,e,n)=>{const r=e.map(({sessionId:i,error:o})=>`${i}: ${o.message}`).join(", ");return new tf(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${r}`,{moveError:t,rollbackFailures:e},n)},iy=async(t,e,n,r)=>{const i=[];for(const o of[...t].reverse()){if(ip(o.id)){i.push({sessionId:o.id,error:new Error("Session is not idle")});continue}try{await Zd(o,n,e,!1),tt.getState().setWorktreeMetadata(o.id,r.get(o.id)??null)}catch(l){i.push({sessionId:o.id,error:l instanceof Error?l:new Error(String(l))})}}return i};class sf extends Error{constructor(e){super(e.message,{cause:e}),this.name="ChangesMayBeInDestinationError"}}const Yl=async(t,e,n)=>{try{await eu(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${n.message}`)}throw n},Ql=async(t,e)=>{const n=e?[t,e]:[t];try{await ka(n)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},nf=async(t,e)=>{if(Kn.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");Gl(t.root.id,!0);try{const n=[...t.descendants,t.root],r=new Map(n.map(a=>[a.id,tt.getState().getWorktreeMetadata(a.id)]));ql(n);let i=null;const o=[];let l=!1;try{i=await e();for(const[a,d]of n.entries()){ql(n.slice(a));const u=d.id===t.root.id&&t.moveChanges;try{await Zd(d,t.sourceDirectory,i.directory,u)}catch(h){throw u&&rp(h)&&(l=!0),h}o.push(d),d.id!==t.root.id&&tt.getState().setWorktreeMetadata(d.id,kl(i.metadata))}}catch(a){const d=a instanceof Error?a:new Error(String(a)),u=await iy(o,t.sourceDirectory,i?.directory??t.sourceDirectory,r);if(l&&await Ql(t.sourceDirectory,i?.directory),u.length>0)throw oy(d,u,l);if(l)throw new sf(d);if(i?.onMoveFailure)return i.onMoveFailure(d);throw d}return tt.getState().setWorktreeMetadata(t.root.id,kl(i.metadata)),await Ql(t.sourceDirectory,i.directory),i.directory}finally{Gl(t.root.id,!1)}},ay=async t=>{const e=ht(t.sourceDirectory)??t.sourceDirectory,n=ht(t.destination.path)??t.destination.path;if(e===n)throw new Error("Source and destination are the same");if(t.destination.worktreeStatus!=="ready")throw new Error("Destination worktree is not ready");return nf(t,async()=>({directory:t.destination.path,metadata:t.destination}))},ly=async t=>nf(t,async()=>{const e=Mi(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const n=await ja(t.sourceDirectory)?await ry(t.sourceDirectory,e.path):null,r=await ap(e,n?{startRef:n}:{});try{await lp(r.path)}catch(i){const o=i instanceof Error?i:new Error(String(i));return Yl(e,r,o)}return{directory:r.path,metadata:r,onMoveFailure:async i=>Yl(e,r,i)}}),cy=(t,e,n)=>e instanceof sf?t.changesMayBeInDestination:e instanceof tf&&e.changesMayBeInDestination?`${e.message} ${t.changesMayBeInDestination}`:n&&ny(e)?t.applyChangesFailed:e.message,Ji=(t,e)=>{(t.kind==="existing"?ay({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination,moveChanges:e}):ly({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,moveChanges:e})).then(()=>Le.success(t.messages.success)).catch(r=>{const i=r instanceof Error?r:new Error(String(r));Le.error(t.messages.failure,{description:cy(t.messages,i,e)})})},dy=()=>{const t=ef();t&&(mr(t.intent.root.id,!1),Va(null))},rf=t=>{const e=ef();if(!e)return;const{intent:n}=e;Va(null),mr(n.root.id,!1),Ji(n,t)},Zi=t=>{const e=Kn.getState();e.confirmation||e.pendingSessionIds.has(t.root.id)||e.requestingSessionIds.has(t.root.id)||(mr(t.root.id,!0),(async()=>{try{if(!await ja(t.sourceDirectory)){mr(t.root.id,!1),Ji(t,!1);return}const r=await Jd(t.sourceDirectory);if(r.isClean){mr(t.root.id,!1),Ji(t,!1);return}const i=r.files.filter(o=>{const l=o.index.trim();return l!==""&&l!=="?"}).length;Va({intent:t,dirtyFileCount:r.files.length,stagedFileCount:i})}catch{Le.error(t.messages.failure,{description:t.messages.sourceVerificationFailed}),mr(t.root.id,!1)}})())};function uy(t){return t.confirmation}const Mo="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors",fy=c.memo(function(e){const n=Ze.c(17),{visible:r,title:i,ariaLabel:o,onClick:l,className:a,Icon:d,iconClassName:u,pressed:h}=e,f=r===void 0?!0:r,x=h===void 0?!1:h;if(!f)return null;const b=a??Mo,w=x&&"bg-interactive-selection text-interactive-selection-foreground";let v;n[0]!==b||n[1]!==w?(v=Oe(b,w),n[0]=b,n[1]=w,n[2]=v):v=n[2];const y=u??"h-[18px] w-[18px]";let m;n[3]!==d||n[4]!==y?(m=s.jsx(M,{name:d,className:y}),n[3]=d,n[4]=y,n[5]=m):m=n[5];let p;n[6]!==o||n[7]!==l||n[8]!==x||n[9]!==v||n[10]!==m?(p=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,"aria-label":o,"aria-pressed":x,className:v,children:m})}),n[6]=o,n[7]=l,n[8]=x,n[9]=v,n[10]=m,n[11]=p):p=n[11];let S;n[12]!==i?(S=s.jsx(Dt,{children:s.jsx("p",{children:i})}),n[12]=i,n[13]=S):S=n[13];let g;return n[14]!==p||n[15]!==S?(g=s.jsxs(Nt,{children:[p,S]}),n[14]=p,n[15]=S,n[16]=g):g=n[16],g}),my=c.memo(function(e){const n=Ze.c(43),{isDesktopApp:r,currentInstanceLabel:i,currentInstanceIsLocal:o,isDesktopServicesOpen:l,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:d,shortcutLabel:u,remoteUpdateInfo:h,remoteUpdateChecking:f,remoteUpdateError:x,onOpenRemoteUpdate:b}=e,{t:w}=jt();let v;n[0]!==d||n[1]!==a?(v=T=>{a(T),T&&d()},n[0]=d,n[1]=a,n[2]=v):v=n[2];let y;n[3]!==i||n[4]!==r||n[5]!==w?(y=r?w("header.services.openWithCurrent",{current:i}):w("header.services.open"),n[3]=i,n[4]=r,n[5]=w,n[6]=y):y=n[6];const m=r?"w-auto max-w-[20rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let p;n[7]!==m?(p=Oe(Mo,m),n[7]=m,n[8]=p):p=n[8];let S;n[9]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(M,{name:"server",className:"h-[18px] w-[18px]"}),n[9]=S):S=n[9];let g;n[10]!==i||n[11]!==r?(g=r?s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:i}):null,n[10]=i,n[11]=r,n[12]=g):g=n[12];let C;n[13]!==y||n[14]!==p||n[15]!==g?(C=s.jsx(At,{asChild:!0,children:s.jsx(zs,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":y,className:p,children:[S,g]})})}),n[13]=y,n[14]=p,n[15]=g,n[16]=C):C=n[16];let k;n[17]!==i||n[18]!==u||n[19]!==w?(k=w("header.services.tooltip.currentInstance",{current:i,toggle:u("toggle_services_menu")}),n[17]=i,n[18]=u,n[19]=w,n[20]=k):k=n[20];let j;n[21]!==k?(j=s.jsx(Dt,{children:s.jsx("p",{children:k})}),n[21]=k,n[22]=j):j=n[22];let D;n[23]!==C||n[24]!==j?(D=s.jsxs(Nt,{children:[C,j]}),n[23]=C,n[24]=j,n[25]=D):D=n[25];let I;n[26]!==o||n[27]!==r||n[28]!==l||n[29]!==b||n[30]!==f||n[31]!==x||n[32]!==h||n[33]!==a||n[34]!==w?(I=r?s.jsxs("div",{children:[o?null:s.jsx("div",{className:"border-b border-[var(--interactive-border)] px-4 py-2.5",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label font-medium text-foreground",children:w("header.services.remoteUpdate.title")}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:h?.available?w("header.services.remoteUpdate.available",{version:h.version||""}):f?w("header.services.remoteUpdate.checking"):x||w("header.services.remoteUpdate.upToDate")})]}),h?.available?s.jsx("button",{type:"button",className:"shrink-0 rounded-md bg-[var(--primary-base)] px-3 py-1.5 typography-ui-label font-medium text-[var(--primary-foreground)] hover:opacity-90",onClick:b,children:w("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx(cp,{embedded:!0,open:l,onOpenChange:py,onHostSwitched:()=>a(!1)})]}):null,n[26]=o,n[27]=r,n[28]=l,n[29]=b,n[30]=f,n[31]=x,n[32]=h,n[33]=a,n[34]=w,n[35]=I):I=n[35];let A;n[36]!==I?(A=s.jsx(Ws,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:I}),n[36]=I,n[37]=A):A=n[37];let P;return n[38]!==l||n[39]!==v||n[40]!==D||n[41]!==A?(P=s.jsxs(Ks,{open:l,onOpenChange:v,children:[D,A]}),n[38]=l,n[39]=v,n[40]=D,n[41]=A,n[42]=P):P=n[42],P}),jn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Xl=t=>!t?.isOpen||!Array.isArray(t.tabs)||t.tabs.length===0?null:(t.tabs.find(n=>n.id===t.activeTabId)??t.tabs[t.tabs.length-1])?.mode??null,hy=()=>{Gs("ui.header.render");const{t}=jt(),e=Pe(U=>U.isSidebarOpen),n=Pe(U=>U.openContextOverview),r=Pe(U=>U.closeContextPanel),i=Pe(U=>U.shortcutOverrides),o=Pe(U=>U.sessionTabsEnabled),l=tt(U=>U.getContextUsage),a=tt(U=>!!U.newSessionDraft?.open),d=tt(U=>U.currentSessionId),u=dp(d??""),h=Sa(d??""),f=Zu(d??""),x=$s(rr(c.useCallback(U=>{if(!d)return null;const Te=[...U.activeSessions,...U.archivedSessions].find(Et=>Et.id===d);if(!Te)return null;const ot=Te;return{title:Te.title??null,directory:ot.directory??null,created:Te.time?.created??null,slug:ot.slug??null,shareUrl:Te.share?.url??null,parentId:Te.parentID??null}},[d]))),b=Ht(rr(U=>{if(!U.activeProjectId)return null;const Te=U.projects.find(ot=>ot.id===U.activeProjectId);return Te?{id:Te.id,path:Te.path,label:Te.label}:null})),w=c.useMemo(()=>{if(!b)return null;const U=b.label?.trim();if(U)return U;const Te=b.path.split(/[\\/]/).filter(Boolean);return Te[Te.length-1]??null},[b]),v=ur(U=>U.loadSettings),{isMobile:y}=zn(),m=c.useRef(null),[p,S]=c.useState(()=>typeof window>"u"?!1:xn()),g=c.useMemo(()=>Ur(),[]),C=tu(),[k,j]=c.useState(!1),D=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:I,side:A}=Lu(),P=c.useMemo(()=>{if(typeof window>"u")return null;const U=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof U=="number"&&Number.isFinite(U)&&U>0)return U;if(typeof navigator>"u")return null;const Te=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!Te)return null;const ot=Number.parseInt(Te[1],10),Et=Number.parseInt(Te[2],10);return Number.isNaN(ot)?null:ot===10?Et:ot},[]);mt.useEffect(()=>{typeof window>"u"||S(xn())},[]);const{context:T,output:L}=up(d),$=l(T,L),[K,F]=c.useState(null),W=!d||u;mt.useEffect(()=>{if(!d){F(U=>U===null?U:null);return}if($){F(U=>fp(U,$)?U:$);return}W&&F(U=>U===null?U:null)},[$,d,W]);const[N,R]=c.useState(!1),[E,X]=c.useState("Local"),[J,re]=c.useState(!0),[fe,ne]=c.useState(!1),[te,ue]=c.useState(null),[Se,we]=c.useState(!1),[ye,Ae]=c.useState(null),pe=c.useMemo(()=>$n(),[]),O=Pe(U=>U.workStatusPanelVisible),Q=Pe(U=>U.workStatusPanelEnabled),le=Pe(U=>U.setWorkStatusPanelEnabled),H=Pe(U=>U.workStatusPanelFits),me=Pe(U=>U.workStatusOverlayOpen),ge=Pe(U=>U.setWorkStatusOverlayOpen),de=Q&&H||me,_=c.useCallback(()=>{if(Q&&!H){ge(!me);return}le(!Q)},[ge,le,me,Q,H]),B=!pe&&!O&&!!K,he=c.useCallback(async()=>{if(!(typeof window>"u"||!p))try{if(Vo()){X("Local"),re(!0);return}re(!1);const U=await Td(),Te=Fm(),ot=_m([Lm(Te),...U.hosts]);if(ot.id===$m){X("Local"),re(!0);return}X(Ed(ot.label.trim()||"Instance"))}catch{X("Local"),re(!0)}},[p]);mt.useEffect(()=>(he(),Qr(()=>{he()})),[he]);const ve=c.useCallback(async()=>{if(J){ue(null),Ae(null);return}we(!0),Ae(null);try{const U=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),Te=await ls(`/api/openchamber/update-check?${U.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!Te.ok)throw new Error(`Server responded with ${Te.status}`);const ot=await Te.json();ue({available:ot.available??!1,version:ot.version,currentVersion:ot.currentVersion??"unknown",body:ot.body,nextSuggestedCheckInSec:typeof ot.nextSuggestedCheckInSec=="number"?ot.nextSuggestedCheckInSec:void 0,packageManager:ot.packageManager,updateCommand:ot.updateCommand})}catch(U){ue(null),Ae(U instanceof Error?U.message:t("header.services.remoteUpdate.error"))}finally{we(!1)}},[J,t]);c.useEffect(()=>{ue(null),Ae(null),ne(!1)},[J,E]),c.useEffect(()=>{if(!p||J)return;const U=3e3,Te=3600*1e3;let ot=!1,Et=null;const Mt=$t=>{Et=window.setTimeout(()=>{if(ot||typeof document<"u"&&document.visibilityState!=="visible"){Mt(Te);return}ve().finally(()=>{ot||Mt(Te)})},$t)};return Mt(U),()=>{ot=!0,Et!==null&&window.clearTimeout(Et)}},[ve,J,E,p]);const Re=c.useCallback(()=>{if(te?.available){ne(!0);return}ve()},[ve,te?.available]);mp(),c.useEffect(()=>{v()},[v]);const ce=d?x??null:null,se=c.useRef(null),[q,z]=c.useState(0);c.useEffect(()=>{if(!d){se.current&&(se.current=null,z(Et=>Et+1));return}if(ce){se.current={sessionId:d,session:ce,expiresAt:Date.now()+2e3};return}const U=se.current;if(!U||U.sessionId!==d)return;const Te=U.expiresAt-Date.now();if(Te<=0){se.current=null,z(Et=>Et+1);return}const ot=window.setTimeout(()=>{se.current?.sessionId===d&&(se.current=null),z(Et=>Et+1)},Te);return()=>{window.clearTimeout(ot)}},[d,ce]);const ee=(()=>{if(ce)return ce;if(!d)return null;const U=se.current;return U&&U.sessionId===d&&U.expiresAt>Date.now()?U.session:null})(),ae=tt(U=>d?U.worktreeMetadata.get(d)?.path??"":""),Ne=tt(U=>d?U.worktreeMetadata.get(d)?.branch?.trim()??null:null),Ce=su(U=>d?U.getAttachment(d):void 0),We=c.useMemo(()=>Ce?hp(Ce,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,Ce]),Ee=c.useMemo(()=>Ce?Ce.legacy?"legacy":Ce.degraded?"degraded":Ce.worktreeStatus==="pending"?"pending":Ce.worktreeStatus==="missing"?"missing":Ce.worktreeStatus==="invalid"?"invalid":Ce.attentionReason?"attention":null:null,[Ce]),xe=c.useMemo(()=>jn(ae||""),[ae]),$e=c.useMemo(()=>{const U=typeof ee?.directory=="string"?ee.directory:"";return jn(U||"")},[ee?.directory]),V=va(d??"",$e),De=tt(U=>U.newSessionDraft?.open?jn(U.newSessionDraft.bootstrapPendingDirectory??U.newSessionDraft.directoryOverride??""):""),Fe=tt(U=>U.newSessionDraft.target),_e=tt(U=>U.newSessionDraft.selectedProjectId),rt=tt(U=>U.currentSessionDirectory),ct=ns(U=>U.homeDirectory),et=c.useMemo(()=>xe||$e||De,[De,$e,xe]),pt=Pe(c.useCallback(U=>{const Te=jn(et||"");return Te?Xl(U.contextPanelByDirectory[Te]):null},[et])),kt=tt(U=>{const Te=jn(xe||$e||"");if(!Te)return null;for(const ot of U.availableWorktreesByProject.values()){const Mt=ot.find($t=>jn($t.path)===Te)?.branch?.trim();if(Mt)return Mt}return null}),Xe=pp(et||null)||Ne||kt,yt=a?Fe==="chat":gp($e||rt,ct),Rt=!yt&&!O&&!!(w||Xe||!a&&Ee),be=c.useMemo(()=>{if(!d)return w??"OpenChamber";const U=ee?.title?.trim();return U&&U.length>0?U:"Untitled Session"},[w,ee?.title,d]),Ge=nu(et||void 0,{bootstrap:!1}),ut=ru(),Y=tt(U=>U.updateSessionTitle),G=tt(U=>U.shareSession),Z=tt(U=>U.unshareSession),je=tt(U=>U.archiveSessions),Ie=tt(U=>U.deleteSessions),[Ve,Je]=c.useState(!1),[it,at]=c.useState(!1),Ye=c.useRef(null),[vt,Ue]=c.useState(""),[Pt,ke]=c.useState(null),xt=c.useRef(null),Ct=c.useCallback(()=>{d&&(Ue(ee?.title?.trim()||be),Je(!0))},[ee?.title,d,be]),Tt=c.useRef(Ct);Tt.current=Ct;const qe=c.useCallback(U=>{U&&(U.focus(),U.select())},[]);c.useEffect(()=>{if(at(!1),ke(null),d&&Ye.current===d){Ye.current=null,Tt.current();return}Je(!1),Ue("")},[d]);const ze=c.useCallback(async()=>{if(!d)return;const U=vt.trim();U&&U!==ee?.title?.trim()&&await Y(d,U),Je(!1)},[ee?.title,d,vt,Y]);c.useEffect(()=>{if(!Ve)return;const U=Te=>{const ot=Te.target;(!ot||!xt.current?.contains(ot))&&ze()};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[Ve,ze]);const ft=c.useCallback(U=>{U&&gn(U).then(Te=>{Le[Te.ok?"success":"error"](t(Te.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>Le.error(t("sessions.sidebar.session.copyId.error")))},[t]),Be=c.useCallback(async U=>{if(!U)return;const Te=await G(U);if(Te?.share?.url){const ot=await gn(Te.share.url);Le[ot.ok?"success":"warning"](t("sessions.sidebar.session.share.successTitle"),{description:t(ot.ok?"sessions.sidebar.session.share.successDescription":"sessions.sidebar.session.share.copyUrlError")});return}Le.error(t("sessions.sidebar.session.share.error"))},[G,t]),Ke=c.useCallback(U=>{U&&gn(U).then(Te=>{Le[Te.ok?"success":"error"](t(Te.ok?"sessions.sidebar.session.menu.copied":"sessions.sidebar.session.share.copyUrlError"))}).catch(()=>Le.error(t("sessions.sidebar.session.share.copyUrlError")))},[t]),He=c.useCallback(async U=>{if(!U)return;const Te=await Z(U);Le[Te?"success":"error"](t(Te?"sessions.sidebar.session.unshare.success":"sessions.sidebar.session.unshare.error"))},[t,Z]),nt=c.useCallback(async()=>{if(!d||!et){Le.error(t("sessions.sidebar.session.export.nothingToExport"));return}try{await ut.loadCompleteHistory(d,et)}catch{Le.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}const U=Cl(Ge.getState(),d).list;if(U.length===0){Le.error(t("sessions.sidebar.session.export.nothingToExport"));return}const Te=ou(U,ee?.title??null),ot=iu(ee?.title??null);await au(Te,ot)||lu(Te,ot),Le.success(t("sessions.sidebar.session.export.success"))},[ee?.title,d,Ge,et,ut,t]),St=cu(),Lt=c.useMemo(()=>du(St),[St]),Ut=c.useCallback(U=>{d&&Ju({entry:U,t,session:{id:d,title:ee?.title,directory:$e??et},loadRecords:async()=>{if(!et)return null;try{await ut.loadCompleteHistory(d,et)}catch{return null}return Cl(Ge.getState(),d).list},onLoadFailed:()=>Le.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[ee?.title,d,Ge,et,$e,ut,t]),Bt=c.useCallback(U=>Lt.map(Te=>s.jsxs(U,{onClick:()=>Ut(Te),children:[s.jsx(Xr,{icon:Te.icon,iconSrc:Te.iconSrc,className:"mr-1 size-4"}),Te.action.label]},`${Te.guest.id}:${Te.action.id}`)),[Lt,Ut]),zt=h?.type==="busy"||h?.type==="retry",_t=c.useCallback(()=>{if(!d||!$e||zt||f)return;const U=$s.getState().activeSessions,Te=U.find(Mt=>Mt.id===d);if(!Te)return;const ot=[],Et=[d];for(let Mt=0;Mt<Et.length;Mt+=1){const $t=Et[Mt];for(const Wt of U)Wt.parentID===$t&&(ot.push(Wt),Et.push(Wt.id))}Zi({kind:"quick",root:Te,descendants:ot,sourceDirectory:$e,messages:Xi(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[d,zt,f,$e,t]),Yt=c.useCallback(async()=>{if(!Pt)return;const U=Pt.action,Te=[Pt.sessionId,..._d(Pt.sessionId,[],U==="delete")];if(ke(null),(U==="archive"?await je(Te):await Ie(Te)).failedIds.length>0){Le.error(t(U==="archive"?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error"));return}Le.success(t(U==="archive"?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"))},[je,Ie,Pt,t]),Zt=Pe(U=>U.openGuestPageId),es=uu(U=>U.guests.find(Te=>Te.id===Zt)),Vt=Pe(U=>U.isScheduledTasksDialogOpen),It=Pe(U=>U.isArchivePageOpen),bt=Pe(U=>U.worktreesPageProjectId),cs=Pe(U=>U.isMultiRunLauncherOpen),ms=Ht(U=>{if(!bt)return null;const Te=U.projects.find(ot=>ot.id===bt);return Te?.label?.trim()||Te?.path?.split("/").pop()||null}),hs=c.useMemo(()=>es?{title:es.pageTitle??es.name,subtitle:null}:Vt?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:It?{title:t("sessions.archivePage.title"),subtitle:null}:bt?{title:t("sessions.worktreesPage.title",{project:ms??""}),subtitle:null}:cs?{title:t("sessions.sidebar.header.actions.newMultiRun"),subtitle:null}:null,[es,It,cs,Vt,t,bt,ms]),ds=c.useMemo(()=>jn(et||b?.path||""),[b?.path,et]),nn=_b(),Ts=Ca(U=>U.planModeEnabled),rn=tt(U=>U.isSessionPlanAvailable),os=Ts&&d?rn(d):!1,qs=c.useRef("");c.useEffect(()=>{if(!Ts||!d)return;const U=`${d||"none"}:${$e||"none"}:${ee?.created||0}:${ee?.slug||"none"}`;qs.current!==U&&(qs.current=U)},[Ts,os,ee?.slug,ee?.created,d,$e]);const Ys=c.useCallback(()=>{_n("desktop_open_draft_mini_chat_window",{directory:yt?"":De,projectId:yt?null:_e,apiBaseUrl:Pn(),clientToken:Hr()}).catch(U=>{console.warn("[header] failed to open draft mini chat window",U)})},[De,_e,yt]),Cs=c.useCallback(()=>{if(a){Ys();return}d&&_n("desktop_open_session_mini_chat_window",{sessionId:d,directory:$e||jn(rt||"")||xe,apiBaseUrl:Pn(),clientToken:Hr()}).catch(U=>{console.warn("[header] failed to open session mini chat window",U)})},[d,Ys,a,rt,$e,xe]),Ns=c.useCallback(()=>{const U=jn(et||"");if(!U)return;const Te=Pe.getState().contextPanelByDirectory[U];if(Xl(Te)==="context"){r(U);return}n(U)},[r,n,et]),mn=pt==="context",Es=Mo,Rs=c.useMemo(()=>p&&D&&!k?"88px":C?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!p||I)&&!pe?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[p,k,D,C,pe,I]);mt.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",Rs)},[Rs]);const Qs=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",on=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";mt.useEffect(()=>{if(!p||!D){j(!1);return}let U=!1;const Te=async()=>{try{const Et=await _n("desktop_is_window_fullscreen");U||j(Et===!0)}catch{U||j(!1)}},ot=()=>{Te()};return Te(),window.addEventListener("openchamber:window-resized",ot),()=>{U=!0,window.removeEventListener("openchamber:window-resized",ot)}},[p,D]);const an=c.useMemo(()=>!p||!D||P===null?"":P>=26?"h-12":P<=15?"h-14":"",[p,D,P]),ps=c.useMemo(()=>{if(!(p&&!I||pe)&&!(I&&A==="right"))return{paddingRight:"calc(0.75rem + var(--oc-wco-right-inset, 0px))",minHeight:"max(3rem, var(--oc-wco-titlebar-height, 0px))",height:"max(3rem, var(--oc-wco-titlebar-height, 0px))"}},[p,pe,I,A]),vs=c.useCallback(()=>{if(typeof document>"u")return;const U=m.current?.getBoundingClientRect().height;U&&document.documentElement.style.setProperty("--oc-header-height",`${U}px`)},[]);mt.useEffect(()=>{if(typeof window>"u")return;vs();const U=m.current;if(!U||typeof ResizeObserver>"u")return()=>{};let Te=0;const ot=()=>{Te||(Te=requestAnimationFrame(()=>{Te=0,vs()}))},Et=new ResizeObserver(ot);return Et.observe(U),window.addEventListener("resize",ot),window.addEventListener("orientationchange",ot),()=>{Te&&cancelAnimationFrame(Te),Et.disconnect(),window.removeEventListener("resize",ot),window.removeEventListener("orientationchange",ot)}},[vs]),mt.useEffect(()=>{vs()},[vs,y,an]);const ln=c.useCallback(async U=>{const Te=U.target;Te.closest(".app-region-no-drag")||Te.closest("button, a, input, select, textarea")||U.button===0&&p&&await zm()},[p]),Sn=c.useCallback(U=>er(Jr(U,i)),[i]);xp({rename_current_session:()=>{if(!d||y)return!1;Ct()},toggle_services_menu:()=>{if(N){R(!1);return}R(!0),he()}});const ie=s.jsxs(s.Fragment,{children:[nn?s.jsx(Bb,{projectRef:nn.projectRef,directory:nn.directory,className:"mr-2"}):null,s.jsx(db,{directory:ds,className:"mr-1"}),p?s.jsx(my,{isDesktopApp:p,currentInstanceLabel:E,currentInstanceIsLocal:J,isDesktopServicesOpen:N,setIsDesktopServicesOpen:R,refreshCurrentInstanceLabel:he,shortcutLabel:Sn,remoteUpdateInfo:te,remoteUpdateChecking:Se,remoteUpdateError:ye,onOpenRemoteUpdate:Re}):null]}),Qe=g&&(a||!!d),lt=c.useCallback(({session:U,open:Te,isActive:ot,select:Et,closeOtherTabs:Mt,components:$t})=>{const{Item:Wt,Separator:Ss}=$t,is=U.share?.url??null,Vn=ot&&!pe&&!yt&&ee&&!ee.parentId;return s.jsxs(s.Fragment,{children:[s.jsxs(Wt,{onClick:()=>{ot||Et(),Ye.current=U.id},children:[s.jsx(M,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(Qi,{sessionID:U.id,directory:U.directory,open:Te,Item:Wt}),s.jsxs(Wt,{onClick:()=>ft(U.id),children:[s.jsx(M,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(Ss,{}),is?s.jsxs(s.Fragment,{children:[s.jsxs(Wt,{onClick:()=>Ke(is),children:[s.jsx(M,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyLink")]}),s.jsxs(Wt,{onClick:()=>{He(U.id)},children:[s.jsx(M,{name:"link-unlink-m",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Wt,{onClick:()=>{Be(U.id)},children:[s.jsx(M,{name:"share-2",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.share")]}),ot?s.jsxs(Wt,{onClick:()=>{nt()},children:[s.jsx(M,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}):null,ot?Bt(Wt):null,Vn?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Wt,{disabled:!$e||zt||f,onClick:_t,className:"w-full",children:[s.jsx(M,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(Dt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":zt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(Ss,{}),s.jsxs(Wt,{onClick:Mt,children:[s.jsx(M,{name:"close-circle",className:"mr-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]}),s.jsx(Ss,{}),s.jsxs(Wt,{onClick:()=>ke({action:"archive",sessionId:U.id}),children:[s.jsx(M,{name:"inbox-archive",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Wt,{className:"text-destructive focus:text-destructive",onClick:()=>ke({action:"delete",sessionId:U.id}),children:[s.jsx(M,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})},[ft,Ke,ee,nt,yt,zt,f,pe,_t,Bt,$e,Be,t,He]),st=()=>s.jsxs("div",{onMouseDown:ln,className:Oe("app-region-drag relative flex h-12 select-none items-center",I&&A==="right"?"pr-0":"pr-3",an),style:ps,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:Qs}}),s.jsx("div",{"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:on}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[hs?s.jsxs(s.Fragment,{children:[s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"icon",className:"app-region-no-drag mr-1 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>Pe.getState().closeMainSurfaces(),children:s.jsx(M,{name:"arrow-left",className:"size-[18px]"})})}),s.jsx(Dt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),s.jsxs("div",{className:"mr-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-left",children:[s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:hs.title}),hs.subtitle?s.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:hs.subtitle}):null]})]}):pe||!o?s.jsxs("div",{className:"app-region-no-drag mr-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-left",children:[V?s.jsx(M,{name:"loader-4",className:"mr-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,e?null:s.jsx(Kl,{align:"start",children:s.jsx("button",{type:"button",className:Es,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(M,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[Ve?s.jsxs("form",{ref:xt,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:U=>U.stopPropagation(),onSubmit:U=>{U.preventDefault(),ze()},children:[s.jsx("input",{ref:qe,value:vt,onChange:U=>Ue(U.target.value),onKeyDown:U=>Ti(U,()=>Je(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent typography-ui-label text-[14px] font-normal leading-tight outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Je(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"close",className:"size-4"})})]}):s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:a?t("sessions.switcher.draftTitle"):be}),Rt?s.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[w?s.jsx("span",{className:"truncate",children:w}):null,Xe?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(M,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:Xe})]}):null,!a&&Ee?s.jsxs("span",{className:Oe("inline-flex min-w-0 items-center gap-0.5",Ee==="attention"||Ee==="invalid"||Ee==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[s.jsx(M,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:We})]}):null]}):null]}),s.jsx("div",{className:Oe("flex h-[18px] shrink-0 items-center justify-center",Rt?"self-start":"self-center"),children:d&&!a&&!Ve?s.jsxs(Ks,{open:it,onOpenChange:at,onOpenChangeComplete:U=>{!U&&Ye.current&&Ye.current===d&&(Ye.current=null,Ct())},children:[s.jsx(zs,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"xs",className:"h-[18px] w-6 px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.sessionActions.openAria"),children:s.jsx(M,{name:"more",className:"size-4"})})}),s.jsxs(Ws,{align:"end",className:"min-w-[190px]",children:[s.jsxs(Kt,{onClick:()=>{Ye.current=d},children:[s.jsx(M,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(Qi,{sessionID:d,directory:$e,open:it,Item:Kt}),s.jsxs(Kt,{onClick:()=>d&&ft(d),children:[s.jsx(M,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(Os,{}),ee?.shareUrl?s.jsxs(s.Fragment,{children:[s.jsxs(Kt,{onClick:()=>Ke(ee?.shareUrl),children:[s.jsx(M,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyLink")]}),s.jsxs(Kt,{onClick:()=>{d&&He(d)},children:[s.jsx(M,{name:"link-unlink-m",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Kt,{onClick:()=>{d&&Be(d)},children:[s.jsx(M,{name:"share-2",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.share")]}),s.jsxs(Kt,{onClick:()=>{nt()},children:[s.jsx(M,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}),Bt(Kt),!pe&&!yt&&ee&&!ee.parentId?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Kt,{disabled:!$e||zt||f,onClick:_t,className:"w-full",children:[s.jsx(M,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(Dt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":zt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(Os,{}),s.jsxs(Kt,{onClick:()=>{d&&ke({action:"archive",sessionId:d})},children:[s.jsx(M,{name:"inbox-archive",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Kt,{className:"text-destructive focus:text-destructive",onClick:()=>{d&&ke({action:"delete",sessionId:d})},children:[s.jsx(M,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})]}):null})]}):s.jsxs("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center gap-0.5 text-left",children:[e?null:s.jsx(Kl,{align:"start",children:s.jsx("button",{type:"button",className:Es,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(M,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsx(Kb,{renderMenu:lt,suppressActiveTabControls:Ve,onMenuOpenChangeComplete:U=>{!U&&Ye.current&&Ye.current===d&&(Ye.current=null,Ct())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:Ve?s.jsxs("form",{ref:xt,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:U=>U.stopPropagation(),onSubmit:U=>{U.preventDefault(),ze()},children:[s.jsx("input",{ref:qe,value:vt,onChange:U=>Ue(U.target.value),onKeyDown:U=>Ti(U,()=>Je(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent text-[13px] font-medium leading-4 outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Je(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"close",className:"size-4"})})]}):s.jsx("span",{className:"block overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4 text-foreground max-w-full",children:a?t("sessions.switcher.draftTitle"):be})})})]}),hs||pe||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[B&&K?s.jsx(Dx,{reading:Px(K),contextLimit:K.contextLimit,outputLimit:K.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:Ns,pressed:mn,className:Qe?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,s.jsx(fy,{visible:Qe,title:t(a?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(a?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:Cs,className:Oe(Es,"mr-1"),Icon:"picture-in-picture-2"}),pe?null:s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":de,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:_,className:Oe(Mo,"mr-1",de?"text-foreground":"text-muted-foreground/50"),children:s.jsx(M,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),s.jsx(Dt,{side:"bottom",children:t(Q&&!H?me?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":Q?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),ie,s.jsx($u,{visible:I&&A==="right",position:"right"})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:m,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:st()}),s.jsx(ys,{open:Pt!==null,onOpenChange:U=>{U||ke(null)},children:s.jsxs(ws,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Vs,{children:[s.jsx(Ps,{children:Pt?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),s.jsx(Is,{children:Pt?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:be}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:be})})]}),s.jsxs(bn,{children:[s.jsx(dt,{variant:"outline",size:"sm",onClick:()=>ke(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(dt,{variant:"destructive",size:"sm",onClick:()=>{Yt()},children:Pt?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),s.jsx(Ld,{open:fe,onOpenChange:ne,info:te,downloading:!1,downloaded:!1,progress:null,error:ye,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function py(){}const Jl=280,Zl=168,ec=500,gy=({isOpen:t,isMobile:e,children:n,className:r,topBar:i})=>{const{t:o}=jt(),l=Pe(j=>j.sidebarWidth),a=Pe(j=>j.setSidebarWidth),[d,u]=c.useState(!1),h=c.useRef(0),f=c.useRef(l||Jl),x=c.useRef(null),b=c.useRef(null),w=c.useRef(null),v=c.useCallback(j=>Math.min(ec,Math.max(Zl,j)),[]),y=c.useCallback(j=>{const D=w.current;D&&(D.style.width=`${j}px`,D.style.minWidth=`${j}px`,D.style.maxWidth=`${j}px`,D.style.setProperty("--oc-left-sidebar-width",`${j}px`))},[]);if(c.useEffect(()=>{e&&d&&u(!1)},[e,d]),c.useEffect(()=>{d||(x.current=null,b.current=null)},[d]),e)return null;const m=Math.min(ec,Math.max(Zl,l||Jl)),p=t?m:0,S=j=>{if(t){try{j.currentTarget.setPointerCapture(j.pointerId)}catch{}b.current=j.pointerId,u(!0),h.current=j.clientX,f.current=p,x.current=p,y(p),j.preventDefault()}},g=j=>{if(e||!d||b.current!==j.pointerId)return;const D=j.clientX-h.current,I=v(f.current+D);x.current!==I&&(x.current=I,y(I))},C=j=>{if(b.current!==j.pointerId||e)return;try{j.currentTarget.releasePointerCapture(j.pointerId)}catch{}const D=v(x.current??p);b.current=null,x.current=null,u(!1),a(D)},k=d?x.current??p:p;return s.jsxs("aside",{ref:w,className:Oe("relative flex h-full overflow-hidden border-r border-border will-change-[width] motion-reduce:transition-none","bg-sidebar",!t&&"border-r-0",r),style:{width:`${k}px`,minWidth:`${k}px`,maxWidth:`${k}px`,"--oc-left-sidebar-width":`${d?k:m}px`,overflowX:"clip",transitionProperty:d?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||p===0,children:[t&&s.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&s.jsx("div",{className:Oe("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",d&&"bg-[var(--interactive-border)]"),onPointerDown:S,onPointerMove:g,onPointerUp:C,onPointerCancel:C,role:"separator","aria-orientation":"vertical","aria-label":o("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:Oe("relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[i,s.jsx(yn,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(As,{children:n})})]})]})},xy=()=>{const t=Ze.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={height:"var(--oc-header-height, 3rem)"},t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-left-inset, 0.75rem)"}}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[n,s.jsx("div",{className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),s.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},tc="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:bg-interactive-hover transition-colors",by=()=>{const t=Ze.c(32),{t:e}=jt(),n=Pe(yy),r=Pe(wy),i=c.useRef(null),o=er(Jr("toggle_sidebar",r)),{usesFramelessChrome:l,side:a}=Lu(),d=Sy;let u,h;t[0]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{if(typeof document>"u")return;const T=i.current;if(!T)return;const L=()=>{const K=Math.max(T.getBoundingClientRect().width,T.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(K)}px`)};if(L(),typeof ResizeObserver>"u")return;const $=new ResizeObserver(L);return $.observe(T),()=>{$.disconnect()}},h=[],t[0]=u,t[1]=h):(u=t[0],h=t[1]),c.useEffect(u,h);const f="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2";let x;t[2]===Symbol.for("react.memo_cache_sentinel")?(x={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)"},t[2]=x):x=t[2];const b="flex items-center gap-2";let w;t[3]!==l||t[4]!==a?(w=l&&a==="left"?s.jsx($u,{visible:!0,position:"left"}):null,t[3]=l,t[4]=a,t[5]=w):w=t[5];let v;t[6]!==e||t[7]!==l?(v=l?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,"aria-label":e("header.actions.openAppMenuAria"),className:Oe(tc,"shrink-0"),children:s.jsx(M,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),s.jsx(Dt,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[6]=e,t[7]=l,t[8]=v):v=t[8];const y=Nt;let m;t[9]!==e?(m=e("header.actions.openSessionsAria"),t[9]=e,t[10]=m):m=t[10];let p,S;t[11]===Symbol.for("react.memo_cache_sentinel")?(p=Oe(tc,"shrink-0"),S=s.jsx(M,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[11]=p,t[12]=S):(p=t[11],S=t[12]);let g;t[13]!==m||t[14]!==n?(g=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":m,className:p,children:S})}),t[13]=m,t[14]=n,t[15]=g):g=t[15];const C=Dt,k=e("header.actions.openSessionsWithShortcut",{shortcut:o});let j;t[16]!==k?(j=s.jsx("p",{children:k}),t[16]=k,t[17]=j):j=t[17];let D;t[18]!==C||t[19]!==j?(D=s.jsx(C,{children:j}),t[18]=C,t[19]=j,t[20]=D):D=t[20];let I;t[21]!==y||t[22]!==g||t[23]!==D?(I=s.jsxs(y,{children:[g,D]}),t[21]=y,t[22]=g,t[23]=D,t[24]=I):I=t[24];let A;t[25]!==I||t[26]!==w||t[27]!==v?(A=s.jsxs("div",{ref:i,className:b,children:[w,v,I]}),t[25]=I,t[26]=w,t[27]=v,t[28]=A):A=t[28];let P;return t[29]!==A||t[30]!==x?(P=s.jsx("div",{className:f,style:x,children:A}),t[29]=A,t[30]=x,t[31]=P):P=t[31],P};function yy(t){return t.toggleSidebar}function wy(t){return t.shortcutOverrides}function vy(t){console.warn("[titlebar] failed to open app menu",t)}function Sy(t){const e=t.currentTarget.getBoundingClientRect();_n("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch(vy)}function of(t){const e=Ze.c(5),{className:n}=t,i=`relative inline-block overflow-hidden rounded-[2px] ${n===void 0?"h-5 w-5":n}`;let o,l,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx("span",{className:"absolute left-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-error)]/25"}),l=s.jsx("span",{className:"absolute right-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-success)]/25"}),a=s.jsx(M,{name:"layout-column",className:"absolute inset-0 h-full w-full"}),e[0]=o,e[1]=l,e[2]=a):(o=e[0],l=e[1],a=e[2]);let d;return e[3]!==i?(d=s.jsxs("span",{"aria-hidden":"true",className:i,children:[o,l,a]}),e[3]=i,e[4]=d):d=e[4],d}const sc=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function jy(t,e,n){const r=Ze.c(5),[i,o]=c.useState();let l,a;return r[0]!==n||r[1]!==t||r[2]!==e?(l=()=>{if(e){o(void 0);return}if(!t){o(void 0);return}o(void 0);let d=!1;return(async()=>{const[u,h]=await Promise.all([bp(t),yp(t)]).catch(ky);if(d)return;const f=sc(u),x=sc(h);if(!f||!x||x===f)return;const b=n||"",w=x.split("/").filter(Boolean).pop()||x;o({source:"sdk",path:x,projectDirectory:f,branch:b,label:b||w,name:w,worktreeRoot:x,worktreeStatus:"ready",headState:b?"branch":"unborn",worktreeSource:"existing"})})(),()=>{d=!0}},a=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=l,r[4]=a):(l=r[3],a=r[4]),c.useEffect(l,a),e??i}function ky(){return["",""]}const nc="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",Cy=async(t,e)=>{if(t)return t.authActivate(e);const n=await ls("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:e})}),r=await n.json().catch(()=>null);if(!n.ok||!r)throw new Error(r?.error||n.statusText);return r},rc=({className:t})=>{const{t:e}=jt(),{github:n}=vn(),r=In(b=>b.status),i=In(b=>b.setStatus),[o,l]=c.useState(!1),a=c.useCallback(async b=>{if(!(!b||o)){l(!0);try{i(await Cy(n,b))}catch(w){console.error("Failed to switch GitHub account:",w)}finally{l(!1)}}},[n,o,i]);if(!r?.connected)return null;const d=r.user?.login??null,u=r.user?.avatarUrl??null,h=r.accounts??[],f=d?e("header.github.connectedWithLogin",{login:d}):e("header.github.connected"),x=u?s.jsx("img",{src:u,alt:d?e("header.github.avatarWithLogin",{login:d}):e("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(M,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"});return h.length<=1?s.jsx("div",{className:Oe(nc,t),title:f,children:x}):s.jsxs(Ks,{children:[s.jsx(zs,{asChild:!0,children:s.jsx("button",{type:"button",className:Oe(nc,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:f,disabled:o,children:x})}),s.jsxs(Ws,{align:"end",className:"w-64",children:[s.jsx(Fr,{className:"typography-ui-header font-semibold text-foreground",children:e("header.github.accountsTitle")}),s.jsx(Os,{}),h.map(b=>{const w=b.user,v=!!b.current,y=b.source==="gh-cli"?e("header.github.accountSource.cli"):e("header.github.accountSource.oauth");return s.jsxs(Kt,{className:"gap-2",disabled:o,onSelect:()=>{v||a(b.id)},children:[w?.avatarUrl?s.jsx("img",{src:w.avatarUrl,alt:w.login?e("header.github.avatarWithLogin",{login:w.login}):e("header.github.avatar"),className:"h-6 w-6 rounded-full border border-border/60 bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted",children:s.jsx(M,{name:"github-fill",className:"h-3 w-3 text-muted-foreground"})}),s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:w?.name?.trim()||w?.login||"GitHub"}),w?.login?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:w.login}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:y})]}):null]}),v?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null]},b.id)})]})]})};class ni extends Error{code;model;requiredChars;availableChars;constructor(e,n={}){super(e),this.name="WalkthroughError",this.code=n.code,this.model=n.model,this.requiredChars=n.requiredChars,this.availableChars=n.availableChars}}const ri="/api/walkthrough",af=t=>/^application\/(?:[\w.+-]+\+)?json\b/i.test(t.headers.get("content-type")??""),lf=()=>new ni("This OpenChamber server has no walkthrough API",{code:"server-unsupported"}),Ny=t=>!af(t)&&(t.ok||t.status===404),Ua=async(t,e)=>{if(Ny(t))throw lf();const n=await t.json().catch(()=>null);throw new ni(typeof n?.error=="string"?n.error:e,{code:typeof n?.code=="string"?n.code:void 0,model:n?.model??void 0,requiredChars:typeof n?.requiredChars=="number"?n.requiredChars:void 0,availableChars:typeof n?.availableChars=="number"?n.availableChars:void 0})},cf=async t=>{if(!af(t))throw lf();try{return await t.json()}catch{throw new ni("The server returned a malformed walkthrough response")}};async function Ay(t,e,n={}){const r=await ls(ri,{query:{directory:t,source:JSON.stringify(e),...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}},signal:n.signal});return r.ok?cf(r):Ua(r,"Failed to load walkthrough")}async function Dy(t,e,n={}){const r=await ls(`${ri}/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e,force:n.force===!0,...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}}),signal:n.signal});return r.ok?cf(r):Ua(r,"Failed to generate walkthrough")}async function Py(t,e){const n=await ls(`${ri}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e})});n.ok||await Ua(n,"Failed to cancel walkthrough generation")}async function Iy(t,e,n){const r=await ls(`${ri}/progress`,{query:{directory:t,source:JSON.stringify(e)},signal:n});if(!r.ok)return null;const i=await r.json().catch(()=>null);return typeof i?.stage=="string"?i.stage:null}const Dr={status:"idle",stage:null,result:null,readiness:null,error:null},Ty=t=>t.kind==="working-tree"?`working-tree:${t.scope}`:t.kind==="branch"?`branch:${t.baseRef}...${t.headRef}`:t.kind==="commit"?`commit:${t.hash}`:t.sourceRepo?`pr:${t.sourceRepo.owner}/${t.sourceRepo.repo}:${t.number}`:`pr:${t.number}`,Rn=(t,e)=>`${qt()}\0${t}\0${Ty(e)}`,oc=t=>t instanceof ni?{message:t.message,code:t.code,model:t.model,requiredChars:t.requiredChars,availableChars:t.availableChars}:{message:t instanceof Error?t.message:"Something went wrong"},Zs=new Map,Pr=new Map,Ey=1e3,Ry=to()(Qx((t,e)=>({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{},selectLanguage:(n,r,i)=>{const o=Rn(n,r);t(l=>{const a={...l.selectedLanguage};return i?a[o]=i:delete a[o],{selectedLanguage:a}})},getSelectedLanguage:(n,r)=>e().selectedLanguage[Rn(n,r)],selectModel:(n,r,i)=>{const o=Rn(n,r);t(l=>{const a={...l.selectedModel};return i?a[o]=i:delete a[o],{selectedModel:a}})},getSelectedModel:(n,r)=>e().selectedModel[Rn(n,r)],requestSource:(n,r)=>{t(i=>({requestedSource:{...i.requestedSource,[n]:r}}))},clearRequestedSource:n=>{t(r=>{if(!r.requestedSource[n])return r;const i={...r.requestedSource};return delete i[n],{requestedSource:i}})},getEntry:(n,r)=>e().entries[Rn(n,r)]??Dr,load:async(n,r,i={})=>{if(!n)return;const o=Rn(n,r);if(e().entries[o]?.status==="generating")return;Zs.get(o)?.abort();const a=new AbortController;Zs.set(o,a),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Dr,status:"loading",error:null}}}));try{const d=await Ay(n,r,{model:e().selectedModel[o],language:i.language,signal:a.signal});if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:d.readiness??null,error:null}}})),d.generating&&e().generate(n,r,{language:i.language})}catch(d){if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Dr,status:"error",stage:null,error:oc(d)}}}))}finally{Zs.get(o)===a&&Zs.delete(o)}},generate:async(n,r,i={})=>{if(!n)return;const o=Rn(n,r);Zs.get(o)?.abort();const l=new AbortController;Zs.set(o,l),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Dr,status:"generating",stage:"collecting",error:null}}}));const a=()=>{const d=Pr.get(o);d!==void 0&&(clearInterval(d),Pr.delete(o))};a(),Pr.set(o,setInterval(()=>{Iy(n,r).then(d=>{!d||l.signal.aborted||t(u=>{const h=u.entries[o];return!h||h.status!=="generating"||h.stage===d?u:{entries:{...u.entries,[o]:{...h,stage:d}}}})}).catch(()=>{})},Ey));try{const d=await Dy(n,r,{force:i.force,model:e().selectedModel[o],language:i.language,signal:l.signal});if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:u.entries[o]?.readiness??null,error:null}}}))}catch(d){if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Dr,status:"error",stage:null,error:oc(d)}}}))}finally{a(),Zs.get(o)===l&&Zs.delete(o)}},cancel:(n,r)=>{const i=Rn(n,r);Py(n,r).catch(()=>{}),Zs.get(i)?.abort(),Zs.delete(i),t(o=>{const l=o.entries[i];return l?{entries:{...o.entries,[i]:{...l,status:l.result?"ready":"idle",stage:null,error:null}}}:o})},reset:()=>{for(const n of Zs.values())n.abort();Zs.clear();for(const n of Pr.values())clearInterval(n);Pr.clear(),t({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{}})}}),{name:"walkthrough-store"})),My="border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)] hover:text-[var(--status-info)]",Oy=3e4,ic=20,df=(t,e)=>JSON.stringify([qt(),t,e]),By=t=>{try{const e=JSON.parse(t);if(!Array.isArray(e)||e.length!==3)return null;const[n,r,i]=e;return typeof n!="string"||typeof r!="string"||typeof i!="number"?null:{runtimeKey:n,directory:r,number:i}}catch{return null}},ac=()=>({result:null,hasCheckDetails:!1,fetchedAt:0,isLoading:!1,error:null}),ro=new Map,Fy=t=>{const e=Object.entries(t);return e.length<=ic?t:Object.fromEntries(e.sort(([,n],[,r])=>r.fetchedAt-n.fetchedAt).slice(0,ic))},lc=to()((t,e)=>({entries:{},ensure:async(n,r,i,o)=>{const l=df(r,i),a=o?.includeCheckDetails??!1,d=e().entries[l],u=d&&d.result&&Date.now()-d.fetchedAt<Oy&&(d.hasCheckDetails||!a);if(!o?.force&&u)return d.result;const h=`${l}::${a?"details":"plain"}`,x=ro.get(`${l}::details`)??(a?null:ro.get(h));if(x&&!o?.force)return x;const b=(async()=>{t(w=>({entries:{...w.entries,[l]:{...w.entries[l]??ac(),isLoading:!0,error:null}}}));try{const w=await n.prContext(r,i,{includeDiff:!1,includeCheckDetails:a,sourceRepo:o?.sourceRepo??null});return t(v=>({entries:Fy({...v.entries,[l]:{result:w,hasCheckDetails:a,fetchedAt:Date.now(),isLoading:!1,error:null}})})),w}catch(w){const v=w instanceof Error?w.message:"Failed to load pull request context";return t(y=>({entries:{...y.entries,[l]:{...y.entries[l]??ac(),isLoading:!1,error:v}}})),null}finally{ro.delete(h)}})();return ro.set(h,b),b},invalidate:(n,r)=>{t(i=>{const o={};for(const[l,a]of Object.entries(i.entries)){const d=By(l);d&&d.directory===n&&(r==null||d.number===r)||(o[l]=a)}return{entries:o}})}})),_y=t=>{const e={success:0,failure:0,pending:0,inProgress:0,queued:0};let n;for(const o of t){if(o.status==="in_progress"){e.pending+=1,e.inProgress+=1,o.startedAt&&(!n||o.startedAt<n)&&(n=o.startedAt);continue}if(o.status==="queued"){e.pending+=1,e.queued+=1;continue}const l=typeof o.conclusion=="string"?o.conclusion.toLowerCase():"";if(!l){e.pending+=1;continue}l==="success"||l==="neutral"||l==="skipped"?e.success+=1:e.failure+=1}const r=e.success+e.failure+e.pending;return{state:e.failure>0?"failure":e.pending>0?"pending":r>0?"success":"unknown",total:r,...e,...n?{startedAt:n}:{}}},Ly=35e3,hi=(t,e,n)=>{if(!t)return null;const r=Date.parse(t);if(!Number.isFinite(r))return null;const i=e?Date.parse(e):n??Date.now();if(!Number.isFinite(i)||i<=r)return null;const o=Math.floor((i-r)/6e4);if(o<1)return"<1m";if(o<60)return`${o}m`;const l=Math.floor(o/60),a=o%60;return a>0?`${l}h ${a}m`:`${l}h`},pi=t=>{const e=typeof t=="string"?t.toLowerCase():"";return!!e&&!["success","neutral","skipped"].includes(e)},cc=t=>{switch(t){case"success":return"bg-[color:var(--status-success)]";case"failure":return"bg-[color:var(--status-error)]";case"pending":return"bg-[color:var(--status-warning)]";default:return"bg-muted-foreground/40"}},$y=t=>{const e=t?.pr;if(!e)return null;if(e.state==="merged")return"merged";if(e.state==="closed")return"closed";if(e.draft)return"draft";const n=t?.checks?.state==="failure",r=typeof e.mergeableState=="string"?e.mergeableState:"",i=e.mergeable===!1||r==="blocked"||r==="dirty";return n||i?"blocked":"open"},zy=[2e3,5e3],Wy=600,dc=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),On=t=>{let e=t.trim();return e?(e.startsWith("refs/heads/")&&(e=e.slice(11)),e.startsWith("heads/")&&(e=e.slice(6)),e.startsWith("remotes/")&&(e=e.slice(8)),e):""},Ky=(t,e)=>{const n=On(t);if(!n||n.includes("->"))return"";if(e){const i=`${e}/`;return n.startsWith(i)?n.slice(i.length).trim():""}const r=n.indexOf("/");return r>0?n.slice(r+1).trim():n},Vy=(t,e)=>`${t}::${e}`,Ha=t=>{const e=String(t||"").trim();if(!e)return"";const n=e.indexOf("/");return n<=0?"":e.slice(0,n).trim()},gi=(t,e)=>{if(t.length===0)return null;const n=String(e.selectedRemoteName||"").trim();if(n){const o=t.find(l=>l.name===n);if(o)return o}const r=Ha(e.trackingBranch);if(r){const o=r==="origin"?t.find(a=>a.name==="upstream"):null;if(o)return o;const l=t.find(a=>a.name===r);if(l)return l}const i=t.find(o=>o.name==="origin");return i||(t[0]??null)},Uy=t=>t.startsWith("pr-"),Hy=(t,e)=>{const n=Ha(e),r=new Map(t.map(l=>[l.name,l])),i=[],o=l=>{l&&(i.some(a=>a.name===l.name)||i.push(l))};return n&&o(r.get(n)),o(r.get("upstream")),o(r.get("origin")),t.filter(l=>!Uy(l.name)).forEach(l=>o(l)),t.forEach(l=>o(l)),i},Ir=new Map,oo=Uo;function Gy(t,e){const[n,r]=c.useState(null),[i,o]=c.useState([]),l=c.useRef(null);return c.useEffect(()=>{r(null),o([])},[t]),c.useEffect(()=>{if(!t||!e?.repoUpstream||l.current===t)return;l.current=t;let a=!1;return(async()=>{try{const d=await e.repoUpstream(t);if(a||!d?.isFork||!d.upstream||(r(d.upstream),!e.repoBranches))return;try{const u=await e.repoBranches(d.upstream.owner,d.upstream.repo);a||o(u)}catch{}}catch{}})(),()=>{a=!0}},[t,e]),{detectedUpstream:n,upstreamBranches:i}}const qy=({directory:t,branch:e,baseBranch:n,trackingBranch:r,remotes:i=[],remoteBranches:o=[],onGeneratedDescription:l})=>{const{t:a}=jt(),d=Pe(ie=>ie.timeFormatPreference),{github:u}=vn(),h=In(ie=>ie.status),f=In(ie=>ie.hasChecked),x=Pe(ie=>ie.setSettingsDialogOpen),b=Pe(ie=>ie.setSettingsPage),w=tt(ie=>ie.currentSessionId),v=tt(ie=>!!ie.newSessionDraft?.open),{isMobile:y,hasTouchInput:m,screenWidth:p}=zn(),S=Pe(ie=>ie.openContextSurface),g=Ry(ie=>ie.requestSource),C=!y&&p>=768&&!$n(),k=c.useCallback(()=>{b("integrations"),x(!0)},[x,b]),j=c.useMemo(()=>Vy(t,e),[t,e]),D=c.useMemo(()=>Ir.get(j)??null,[j]),I=Hs(ie=>ie.ensureEntry),A=Hs(ie=>ie.setParams),P=Hs(ie=>ie.startWatching),T=Hs(ie=>ie.stopWatching),L=Hs(ie=>ie.refresh),$=Hs(ie=>ie.updateStatus),[K,F]=c.useState(()=>D?.title??dc(e)),[W,N]=c.useState(()=>D?.body??""),[R,E]=c.useState(()=>D?.draft??!1),[X,J]=c.useState(()=>D?.additionalContext??""),[re,fe]=c.useState(()=>{const ie=typeof D?.targetBaseBranch=="string"?On(D.targetBaseBranch):"";return ie||On(n)}),[ne,te]=c.useState("squash"),[ue,Se]=c.useState(!1),[we,ye]=c.useState(!1),[Ae,pe]=c.useState(!1),[O,Q]=c.useState(!1),[le,H]=c.useState(!1),[me,ge]=c.useState(!1),[oe,de]=c.useState(null),[_,B]=c.useState(""),[he,ve]=c.useState(""),[Re,ce]=c.useState(!1),[se,q]=c.useState(!1),[z,ee]=c.useState(()=>gi(i,{selectedRemoteName:D?.selectedRemoteName,trackingBranch:r})),[ae,Ne]=c.useState(!1),{detectedUpstream:Ce,upstreamBranches:We}=Gy(t,u);c.useEffect(()=>{Ne(!1)},[t]);const Ee=i.some(ie=>ie.name==="upstream"),$e=!!(t&&e&&n&&(e!==n||(Ee||Ce!==null))),V=c.useMemo(()=>Ho(t,e,z?.name??null),[t,e,z?.name]),De=Hs(ie=>ie.entries[V]),Fe=De?.isLoading??!1,_e=De?.status??null,rt=De?.error??null,ct=De?.isInitialStatusResolved??!1,et=c.useMemo(()=>{const ie=ae?null:z?.name?.trim()||null,Qe=new Set;for(const gt of o){const U=Ky(gt,ie);!U||U==="HEAD"||Qe.add(U)}if(ae)for(const gt of We)gt&>!=="HEAD"&&Qe.add(gt);const lt=On(n);lt&<!=="HEAD"&&Qe.add(lt);const st=On(re);return st&&st!=="HEAD"&&Qe.add(st),Array.from(Qe).sort((gt,U)=>gt.localeCompare(U))},[n,o,z?.name,re,We,ae]);c.useEffect(()=>{if(i.length===0){z&&ee(null);return}(!z||!i.some(ie=>ie.name===z.name))&&ee(gi(i,{selectedRemoteName:D?.selectedRemoteName,trackingBranch:r}))},[D?.selectedRemoteName,i,z,r]),c.useEffect(()=>{const ie=On(n);if(!re&&ie){fe(ie);return}if(et.length!==0&&!et.includes(re)){const Qe=et.includes(ie)?ie:et[0];Qe&&fe(Qe)}},[et,n,re]);const[pt,kt]=c.useState(()=>D?.activeSegment??"overview"),[wt,Xe]=c.useState(new Set),[yt,Rt]=c.useState(new Set),be=c.useRef(new Set),Ge=c.useRef(null),ut=c.useRef(!1),Y=c.useRef(new Set),G=c.useRef([]);c.useEffect(()=>{Ce&&!Ee&&Ne(!0)},[Ce,Ee]),c.useEffect(()=>{ae&&Ce?.defaultBranch&&fe(Ce.defaultBranch)},[ae,Ce?.defaultBranch]);const Z=_e?.pr??null,je=Z?.state==="merged"||Z?.state==="closed",Ie=je?null:Z,Ve=Ie?df(t,Ie.number):null,Je=lc(ie=>Ve?ie.entries[Ve]:void 0),it=lc(ie=>ie.ensure),at=Je?.result??null,Ye=Je?.isLoading??!1,vt=c.useCallback(ie=>{kt(ie);const Qe=Ir.get(j);Qe&&Ir.set(j,{...Qe,activeSegment:ie})},[j]);c.useEffect(()=>{!Ie||!u?.prContext||pt==="overview"||it(u,t,Ie.number,{includeCheckDetails:pt==="checks",sourceRepo:_e?.repo??null})},[pt,t,it,u,Ie,_e?.repo]);const Ue=_e?.checks??null,Pt=(Ue?.pending??0)>0,ke=at?.checkRuns??null,xt=at?.fetchedAt;c.useEffect(()=>{if(!ke||ke.length===0)return;const ie=_y(ke);$(V,Qe=>{if(!Qe?.pr||typeof xt=="number"&&typeof Qe.fetchedAt=="number"&&xt<Qe.fetchedAt)return Qe;const lt=Qe.checks;return lt&<.state===ie.state&<.total===ie.total&<.success===ie.success&<.failure===ie.failure&<.pending===ie.pending&<.inProgress===ie.inProgress&<.queued===ie.queued&<.startedAt===ie.startedAt?Qe:{...Qe,checks:ie,...typeof xt=="number"?{fetchedAt:xt}:{}}})},[ke,xt,V,$]),c.useEffect(()=>{if(pt!=="checks"||!Pt||!Z||!u?.prContext)return;const ie=window.setInterval(()=>{it(u,t,Z.number,{includeCheckDetails:!0,sourceRepo:_e?.repo??null,force:!0})},Ly);return()=>window.clearInterval(ie)},[pt,Pt,t,it,u,Z,_e?.repo]);const[Ct,Tt]=c.useState(()=>Date.now());c.useEffect(()=>{if(!Pt)return;Tt(Date.now());const ie=window.setInterval(()=>Tt(Date.now()),3e4);return()=>window.clearInterval(ie)},[Pt]);const qe=Z?`${t}#${Z.number}`:null,ze=!!(qe&&oe===qe);c.useEffect(()=>{if(!u?.prContext||!Z||typeof Z.body=="string"&&Z.body.length>0)return;const ie=`${t}#${Z.number}`;if(be.current.has(ie))return;be.current.add(ie),de(ie);let Qe=!1;return it(u,t,Z.number,{sourceRepo:_e?.repo??null}).then(lt=>{if(Qe)return;const st=lt?.pr;st&&$(V,gt=>!gt?.pr||gt.pr.number!==Z.number?gt:{...gt,pr:{...gt.pr,body:st.body||""}})}).catch(()=>{}).finally(()=>{Qe||de(lt=>lt===ie?null:lt)}),()=>{Qe=!0}},[t,it,u,Z,V,_e?.repo,$]),c.useEffect(()=>{if(!Z){ge(!1),B(""),ve(""),Ge.current=null;return}const ie=Ge.current!==null&&Ge.current!==Z.number;ie&&ge(!1),(!me||ie)&&(B(Z.title||""),ve(Z.body||"")),Ge.current=Z.number},[me,Z]);const ft=c.useCallback(ie=>{if(!ie)return"";const Qe=Date.parse(ie);return Number.isFinite(Qe)?fu(Qe,d,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):ie},[d]),Be=c.useMemo(()=>{const ie=h?.user?.login;return typeof ie=="string"?ie.trim():""},[h]),Ke=c.useMemo(()=>"[&_a[href*='oc-self-mention=1']]:!text-[var(--primary-base)] [&_a[href*='oc-self-mention=1']]:font-semibold [&_a[href*='oc-self-mention=1']]:!no-underline [&_a[href*='oc-self-mention=1']:hover]:!text-[var(--primary-hover)]",[]),He=c.useCallback(ie=>{const Qe=Be.toLowerCase(),lt=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return ie.replace(lt,(st,gt,U)=>{const Te=`@${U}`,ot=U.toLowerCase();return`${gt}[${Te}](https://github.com/${ot}${Qe&&ot===Qe?"?oc-self-mention=1":""})`})},[Be]),nt=c.useMemo(()=>{const ie=(at?.issueComments??[]).map(st=>({id:`issue-${st.id}`,body:st.body||"",authorName:st.author?.name||st.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:st.author?.login||null,avatarUrl:st.author?.avatarUrl||null,createdAt:st.createdAt,context:a("gitView.pr.comments.generalContext"),path:null,line:null})),Qe=(at?.reviewComments??[]).map(st=>({id:`review-${st.id}`,body:st.body||"",authorName:st.author?.name||st.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:st.author?.login||null,avatarUrl:st.author?.avatarUrl||null,createdAt:st.createdAt,context:a("gitView.pr.comments.reviewContext"),path:st.path||null,line:st.line??null})),lt=[...ie,...Qe];return lt.sort((st,gt)=>{const U=st.createdAt?Date.parse(st.createdAt):0,Te=gt.createdAt?Date.parse(gt.createdAt):0,ot=Number.isFinite(U)?U:0,Et=Number.isFinite(Te)?Te:0;return ot-Et}),lt},[at,a]),St=c.useCallback(()=>{const ie=w??(v?"draft":null);return ie?{directory:t,sessionKey:ie}:(Le.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null)},[w,t,v,a]),Lt=c.useCallback((ie,Qe)=>{const lt=Qe.authorLogin?`@${Qe.authorLogin}`:Qe.authorName,st=Qe.path?` · ${Qe.path}${Qe.line?`:${Qe.line}`:""}`:"";Oi.getState().addDraft(ie,{source:"pr-comment",fileLabel:`PR #${Z?.number??""} ${lt}${st}`,startLine:Qe.line??0,endLine:Qe.line??0,code:Qe.body,language:"markdown",text:""})},[Z?.number]),Ut=c.useCallback((ie,Qe)=>{const lt=ie.status||"unknown",st=ie.conclusion??void 0,gt=st?`${lt} / ${st}`:lt,U=ie.app?.name||ie.app?.slug;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:Qe?.hideHeader?"flex items-start justify-end gap-3":"flex items-start justify-between gap-3",children:[Qe?.hideHeader?null:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:ie.name}),s.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:U?`${U} · ${gt}`:gt})]}),ie.detailsUrl?s.jsx(dt,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:s.jsxs("a",{href:ie.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(M,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),ie.output?.title?s.jsx("div",{className:"typography-micro text-foreground",children:ie.output.title}):null,ie.output?.summary?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:ie.output.summary}):null,ie.output?.text?s.jsx("div",{className:"rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground whitespace-pre-wrap break-words max-h-48 overflow-y-auto",children:ie.output.text}):null,Array.isArray(ie.annotations)&&ie.annotations.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",ie.annotations.length>20?` (showing 20/${ie.annotations.length})`:""]}),s.jsx("div",{className:"space-y-1",children:ie.annotations.slice(0,20).map((Te,ot)=>s.jsxs("div",{className:"rounded border border-[var(--status-error-border)] bg-[var(--status-error-background)]/40 px-2 py-2",children:[s.jsxs("div",{className:"typography-micro break-words text-[var(--status-error)]",children:[Te.title||Te.level||"Issue",Te.path?` · ${Te.path}`:"",typeof Te.startLine=="number"?`:${Te.startLine}`:"",typeof Te.endLine=="number"&&Te.endLine!==Te.startLine?`-${Te.endLine}`:""]}),s.jsx("div",{className:"typography-micro text-foreground whitespace-pre-wrap break-words mt-1",children:Te.message}),Te.rawDetails?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words mt-1",children:Te.rawDetails}):null]},`${Te.path||"file"}:${Te.startLine||ot}:${ot}`))})]}):null,ie.job?.steps&&ie.job.steps.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.checks.steps")}),s.jsx("div",{className:"space-y-1",children:ie.job.steps.map((Te,ot)=>{const Et=(Te.conclusion||"").toLowerCase(),Mt=Et&&!["success","neutral","skipped"].includes(Et),$t=`${ie.id??"run"}:${ie.job?.jobId??"job"}:${Te.number??ot}:${Te.name}`,Wt=wt.has($t);return Mt?s.jsxs(Bi,{open:Wt,children:[s.jsxs("button",{type:"button",onClick:()=>{Xe(Ss=>{const is=new Set(Ss);return is.has($t)?is.delete($t):is.add($t),is})},className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-left "+(Mt?"bg-destructive/10 text-destructive":"text-muted-foreground"),children:[Wt?s.jsx(M,{name:"arrow-down-s",className:"size-4"}):s.jsx(M,{name:"arrow-right-s",className:"size-4"}),s.jsx("span",{className:"truncate",children:Te.name}),Te.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:Te.conclusion}):null]}),s.jsx(Fi,{children:s.jsxs("div",{className:"ml-6 mt-1 rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground space-y-1",children:[typeof Te.number=="number"?s.jsxs("div",{children:[a("gitView.pr.checks.stepLabel"),": ",Te.number]}):null,Te.status?s.jsxs("div",{children:[a("gitView.pr.checks.statusLabel"),": ",Te.status]}):null,Te.conclusion?s.jsxs("div",{children:[a("gitView.pr.checks.conclusionLabel"),": ",Te.conclusion]}):null,Te.startedAt?s.jsxs("div",{children:[a("gitView.pr.checks.startedLabel"),": ",ft(Te.startedAt)]}):null,Te.completedAt?s.jsxs("div",{children:[a("gitView.pr.checks.completedLabel"),": ",ft(Te.completedAt)]}):null]})})]},$t):s.jsxs("div",{className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:Te.name}),Te.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:Te.conclusion}):null]},$t)})})]}):null]})},[wt,ft,a]),[Bt,zt]=c.useState(!1),[_t,Yt]=c.useState(!1),Zt=c.useCallback(async()=>{if(!u?.prContext){Le.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!Z)return;const ie=St();if(ie){zt(!0);try{const Qe=await it(u,t,Z.number,{includeCheckDetails:!0,sourceRepo:_e?.repo??null});if(!Qe){Le.error(a("gitView.pr.toast.loadChecksFailed"));return}const st=(Qe.checkRuns??[]).filter(U=>pi(U.conclusion));if(st.length===0){Le.message(a("gitView.pr.toast.noFailedChecks"));return}const gt=Oi.getState();for(const U of st){const Te=(U.annotations??[]).map(Mt=>[[Mt.level,Mt.title].filter(Boolean).join(" "),Mt.path?`${Mt.path}${typeof Mt.startLine=="number"?`:${Mt.startLine}`:""}`:null,Mt.message,Mt.rawDetails].filter(Boolean).join(`
|
|
3
|
-
`)),ot=(U.job?.steps??[]).filter(Mt=>pi(Mt.conclusion)).map(Mt=>`step ${Mt.number??"?"}: ${Mt.name} → ${Mt.conclusion}`),Et=[`check: ${U.job?.workflowName?`${U.job.workflowName} / ${U.name}`:U.name}`,`status: ${U.status??"unknown"} / ${U.conclusion??"unknown"}`,U.detailsUrl?`url: ${U.detailsUrl}`:null,U.output?.title?`title: ${U.output.title}`:null,U.output?.summary?`summary:
|
|
4
|
-
${U.output.summary}`:null,ot.length>0?`failed steps:
|
|
5
|
-
${ot.join(`
|
|
6
|
-
`)}`:null,Te.length>0?`annotations:
|
|
7
|
-
${Te.join(`
|
|
8
|
-
---
|
|
9
|
-
`)}`:null].filter(Boolean).join(`
|
|
10
|
-
|
|
11
|
-
`);gt.addDraft(ie,{source:"pr-check",fileLabel:`PR #${Z.number} · ${U.name}`,startLine:0,endLine:0,code:Et,language:"text",text:""})}}catch(Qe){const lt=Qe instanceof Error?Qe.message:String(Qe);Le.error(a("gitView.pr.toast.loadChecksFailed"),{description:lt})}finally{zt(!1)}}},[t,it,u,Z,St,_e?.repo,a]),es=c.useCallback(async()=>{if(!u?.prContext){Le.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!Z)return;const ie=St();if(ie){Yt(!0);try{if(!await it(u,t,Z.number,{sourceRepo:_e?.repo??null})){Le.error(a("gitView.pr.toast.loadPrCommentsFailed"));return}if(nt.length===0){Le.message(a("gitView.pr.toast.noPrComments"));return}for(const lt of nt)Lt(ie,lt)}catch(Qe){const lt=Qe instanceof Error?Qe.message:String(Qe);Le.error(a("gitView.pr.toast.loadPrCommentsFailed"),{description:lt})}finally{Yt(!1)}}},[Lt,t,it,u,Z,St,_e?.repo,a,nt]),Vt=c.useCallback(async ie=>{const Qe=St();Qe&&Lt(Qe,ie)},[Lt,St]),It=c.useCallback(async ie=>{await L(V,ie)},[V,L]),[bt,cs]=c.useState(!1),ms=c.useRef(!0);c.useEffect(()=>(ms.current=!0,()=>{ms.current=!1}),[]);const hs=c.useCallback(async()=>{if(bt)return;cs(!0);const ie=Date.now();try{await It({force:!0})}finally{const Qe=Wy-(Date.now()-ie);Qe>0&&await new Promise(lt=>window.setTimeout(lt,Qe)),ms.current&&cs(!1)}},[bt,It]),ds=c.useCallback(()=>{G.current.forEach(ie=>{window.clearTimeout(ie)}),G.current=zy.map(ie=>window.setTimeout(()=>{It({force:!0,silent:!0,markInitialResolved:!0})},ie))},[It]);c.useEffect(()=>{if(!u?.prStatus||!$e||i.length<=1||ut.current||_e?.pr)return;const ie=`${j}::${z?.name??""}`;if(Y.current.has(ie))return;Y.current.add(ie);const Qe=Hy(i,r).filter(gt=>gt.name!==z?.name);if(Qe.length===0)return;let lt=!1;return(async()=>{for(const gt of Qe){if(lt)return;try{if(!(await u.prStatus(t,e,gt.name))?.pr)continue;if(lt)return;ee(Te=>Te?.name===gt.name?Te:gt);return}catch{}}})(),()=>{lt=!0}},[e,$e,t,u,i,z?.name,j,_e?.pr,r]),c.useEffect(()=>{I(V),A(V,{directory:t,branch:e,remoteName:z?.name??null,canShow:$e,github:u,githubAuthChecked:f,githubConnected:h?.connected??null})},[e,$e,t,I,u,f,h?.connected,V,z?.name,A]),c.useEffect(()=>(P(V),()=>{T(V)}),[V,P,T]),c.useEffect(()=>{const ie=Ir.get(j)??null;F(ie?.title??dc(e)),N(ie?.body??""),E(ie?.draft??!1),fe(ie?.targetBaseBranch?On(ie.targetBaseBranch):On(n));const Qe=gi(i,{selectedRemoteName:ie?.selectedRemoteName,trackingBranch:r});ee(lt=>lt?.name===Qe?.name?lt:Qe)},[n,e,i,j,r]),c.useEffect(()=>{It({markInitialResolved:!0})},[V,It]),c.useEffect(()=>{!$e||!z?.name||It({force:!0,silent:!0,markInitialResolved:!0})},[$e,It,z?.name]),c.useEffect(()=>{const ie=_e?.resolvedRemoteName?.trim();if(!ie||ut.current)return;const Qe=i.find(lt=>lt.name===ie);Qe&&ee(lt=>lt?.name===Qe.name?lt:Qe)},[i,_e?.resolvedRemoteName]),c.useEffect(()=>{const ie=()=>{const lt=Hs.getState().entries[V]?.lastRefreshAt??0;Date.now()-lt>6e4&&It({force:!0,silent:!0})},Qe=()=>{document.visibilityState==="visible"&&ie()};return window.addEventListener("focus",ie),document.addEventListener("visibilitychange",Qe),()=>{window.removeEventListener("focus",ie),document.removeEventListener("visibilitychange",Qe)}},[V,It]),c.useEffect(()=>{f&&h?.connected===!1&&It({force:!0,silent:!0,markInitialResolved:!0})},[f,h,It]),c.useEffect(()=>{!t||!e||Ir.set(j,{title:K,body:W,draft:R,additionalContext:X,targetBaseBranch:re,selectedRemoteName:z?.name,activeSegment:pt})},[j,K,W,R,X,re,z?.name,t,e,pt]),c.useEffect(()=>{const ie=G.current;return()=>{ie.forEach(Qe=>{window.clearTimeout(Qe)}),G.current=[]}},[]);const nn=c.useCallback(async()=>{if(!ue&&t){Se(!0);try{const Qe={base:ae&&Ce?.defaultBranchSha?Ce.defaultBranchSha:re,head:e};X&&(Qe.context=X);const lt=await wp(t,Qe);lt.title?.trim()&&F(lt.title.trim()),lt.body?.trim()&&N(lt.body.trim()),l?.()}catch(ie){const Qe=ie instanceof Error?ie.message:String(ie);Le.error(a("gitView.pr.toast.generateDescriptionFailed"),{description:Qe})}finally{Se(!1)}}},[X,e,Ce?.defaultBranchSha,t,ue,l,re,a,ae]),Ts=c.useCallback(async()=>{if(!u?.prCreate){Le.error(a("gitView.pr.toast.githubApiUnavailable"));return}const ie=K.trim();if(!ie){Le.error(a("gitView.pr.toast.titleRequired"));return}const Qe=re.trim();if(!Qe){Le.error(a("gitView.pr.toast.baseBranchRequired"));return}if(!ae&&Qe===e){Le.error(a("gitView.pr.toast.baseMustDifferFromHead"));return}ye(!0);try{const lt=Ha(r),st=ae&&Ce,gt=await u.prCreate({directory:t,title:ie,head:e,base:Qe,...W.trim()?{body:W}:{},draft:R,...st?{targetRepo:{owner:Ce.owner,repo:Ce.repo},headRemote:"origin"}:{...z?{remote:z.name}:{},...lt&<!==z?.name?{headRemote:lt}:{}}});Le.success(a("gitView.pr.toast.prCreated")),$(V,U=>U&&{...U,pr:gt}),await It({force:!0}),ds()}catch(lt){const st=lt instanceof Error?lt.message:String(lt);Le.error(a("gitView.pr.toast.createPrFailed"),{description:st})}finally{ye(!1)}},[W,e,Ce,t,R,u,V,It,ds,z,re,K,r,$,ae,a]),rn=c.useCallback(async ie=>{if(!u?.prMerge){Le.error(a("gitView.pr.toast.githubApiUnavailable"));return}Q(!0);try{const Qe=await u.prMerge({directory:t,number:ie.number,method:ne});Qe.merged?Le.success(a("gitView.pr.toast.prMerged")):Le.message(a("gitView.pr.toast.prNotMerged"),{description:Qe.message||a("gitView.pr.notMergeable")}),await It({force:!0}),ds()}catch(Qe){const lt=Qe instanceof Error?Qe.message:String(Qe);Le.error(a("gitView.pr.toast.mergeFailed"),{description:lt}),ie.url&&oo(ie.url)}finally{Q(!1)}},[t,u,ne,It,ds,a]),os=c.useCallback(async ie=>{if(!u?.prReady){Le.error(a("gitView.pr.toast.githubApiUnavailable"));return}H(!0);try{await u.prReady({directory:t,number:ie.number}),Le.success(a("gitView.pr.toast.markedReady")),await It({force:!0}),ds()}catch(Qe){const lt=Qe instanceof Error?Qe.message:String(Qe);Le.error(a("gitView.pr.toast.markReadyFailed"),{description:lt}),ie.url&&oo(ie.url)}finally{H(!1)}},[t,u,It,ds,a]),qs=c.useCallback(async ie=>{if(!u?.prUpdate){Le.error(a("gitView.pr.toast.githubApiUnavailable"));return}const Qe=_.trim();if(!Qe){Le.error(a("gitView.pr.toast.titleRequired"));return}pe(!0);try{const lt=await u.prUpdate({directory:t,number:ie.number,title:Qe,body:he});$(V,st=>st&&{...st,pr:{...st.pr??ie,...lt}}),ge(!1),Le.success(a("gitView.pr.toast.prUpdated")),await It({force:!0}),ds()}catch(lt){const st=lt instanceof Error?lt.message:String(lt);Le.error(a("gitView.pr.toast.updatePrFailed"),{description:st})}finally{pe(!1)}},[t,he,_,u,V,It,ds,$,a]);if(!$e)return s.jsx("section",{className:"border-0 bg-transparent rounded-none",children:s.jsxs("div",{className:"space-y-1 pt-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:a("gitView.pullRequest.title")}),s.jsx(rc,{})]}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pullRequest.availableOnFeatureBranches")})]})});const Ys=_e?.repo?.url||null,Cs=ae&&Ce?.url?Ce.url:Ys,Ns=!!_e?.canMerge,mn=!!_e?.connected,Es=f&&_e?.connected===!1,Rs=$y(_e),Qs=Rs?`var(--pr-${Rs})`:"var(--status-info)",on=Rs==="draft"?"git-pr-draft":Rs==="merged"?"git-merge":Rs==="closed"?"git-close-pull-request":"git-pull-request",an=Z?[`${Z.state}${Z.draft?" (draft)":""}`,Z.mergeable===!1?a("gitView.pr.notMergeable"):null,Z.state==="open"&&typeof Z.mergeableState=="string"&&Z.mergeableState&&Z.mergeableState!=="unknown"?Z.mergeableState:null].filter(Boolean).join(" · "):"",ps=Ue?Ue.total>0?`${Ue.success}/${Ue.total} ${a("gitView.pr.checks.label")}`:`${Ue.state} ${a("gitView.pr.checks.label")}`:"";return s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[s.jsxs("div",{className:"px-0 py-3 border-b border-border/40 flex flex-col gap-1",children:[s.jsxs("div",{className:"@container/pr-actions flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[Z?s.jsxs(dt,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{oo(Z.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:[s.jsx(M,{name:on,className:"size-4 shrink-0",style:{color:Qs}}),a("gitView.pr.actions.openOnGitHub")]}):s.jsx(M,{name:on,className:"size-4 shrink-0",style:{color:"var(--surface-muted-foreground)"}}),s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:a("gitView.pullRequest.title")}),Z?s.jsxs("span",{className:"typography-meta text-muted-foreground truncate",children:["#",Z.number]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[Z&&C?s.jsxs(dt,{variant:"outline",size:"sm",className:Oe("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",My),onClick:()=>{g(t,{kind:"pr",number:Z.number,sourceRepo:_e?.repo?{owner:_e.repo.owner,repo:_e.repo.repo}:void 0}),S(t,"walkthrough")},"aria-label":a("walkthrough.action.open"),children:[s.jsx(M,{name:"route",className:"size-4"}),s.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:a("walkthrough.action.open")})]}):null,s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:Fe||bt,onClick:()=>{hs()},"aria-label":a("gitView.pr.actions.refreshAria"),children:Fe||bt?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}):s.jsx(M,{name:"refresh",className:"size-4 text-muted-foreground"})})}),s.jsx(Dt,{children:s.jsx("p",{children:a("gitView.pr.actions.refresh")})})]}),s.jsx(rc,{className:"h-7 w-7"})]})]}),Z?s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 typography-micro text-muted-foreground",children:[s.jsx("span",{style:{color:Qs},children:an}),Ue?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${cc(Ue.state)}`}),ps]}):null,r&&z&&r.split("/")[0]!==z.name?s.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",z.name]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[Ns&&Z.draft&&Z.state==="open"?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx(dt,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>os(Z),disabled:le||O||Ae||me,"aria-label":a("gitView.pr.actions.markReadyAria"),children:le?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(M,{name:"checkbox-circle",className:"size-4"})})}),s.jsx(Dt,{children:s.jsx("p",{children:a("gitView.pr.actions.markReady")})})]}):null,Ns?s.jsxs(s.Fragment,{children:[s.jsxs(Bs,{value:ne,onValueChange:ie=>te(ie),disabled:O||Z.state!=="open",children:[s.jsx(Fs,{size:"sm",className:"h-7 w-auto min-w-0",children:s.jsx(ks,{})}),s.jsxs(_s,{children:[s.jsx(ss,{value:"squash",children:a("gitView.pr.mergeMethod.squash")}),s.jsx(ss,{value:"merge",children:a("gitView.pr.mergeMethod.merge")}),s.jsx(ss,{value:"rebase",children:a("gitView.pr.mergeMethod.rebase")})]})]}),s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx(dt,{size:"sm",className:"h-7 w-7 px-0",onClick:()=>rn(Z),disabled:O||le||Z.state!=="open"||Z.draft||Ae||me,"aria-label":a("gitView.pr.actions.mergePrAria"),children:O?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(M,{name:"git-merge",className:"size-4"})})}),s.jsx(Dt,{children:s.jsx("p",{children:a("gitView.pr.actions.mergePr")})})]})]}):null]})]}):null]}),s.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[Es?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta text-muted-foreground",children:a("gitView.pr.githubNotConnected")}),s.jsx(dt,{variant:"outline",size:"sm",onClick:k,className:"w-fit",children:a("gitView.pr.actions.openSettings")})]}):null,rt?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:a("gitView.pr.statusUnavailable")}),s.jsx("div",{className:"typography-meta text-muted-foreground break-words",children:rt}),Cs?s.jsx(dt,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:s.jsxs("a",{href:Cs,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(M,{name:"external-link",className:"size-4"}),"Open Repo"]})}):null]}):null,!Z&&!ct&&!rt&&!Es?s.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.pr.checkingStatus")]}):Z&&!je?s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx("div",{className:"h-8 min-w-0",children:s.jsx($d,{className:"h-full",items:[{id:"overview",label:a("gitView.pr.segment.overview")},{id:"checks",label:Ue&&Ue.total>0?`${a("gitView.pr.segment.checks")} ${Ue.success}/${Ue.total}`:a("gitView.pr.segment.checks"),icon:Ue?s.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${cc(Ue.state)}`}):void 0},{id:"comments",label:at?`${a("gitView.pr.segment.comments")} ${(at.issueComments?.length??0)+(at.reviewComments?.length??0)}`:a("gitView.pr.segment.comments")}],activeId:pt,onSelect:ie=>vt(ie),layoutMode:"fit",variant:"active-pill",activePillButtonClassName:"h-7"})}),pt==="overview"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[Ns&&Z.draft?s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.draftMustBeReady")}):null,Ns?null:s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.noMergePermission")}),s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("div",{className:"min-w-0 flex-1",children:me?s.jsx(An,{value:_,onChange:ie=>B(ie.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:m?"on":"off",autoCapitalize:m?"sentences":"off",spellCheck:m}):s.jsx("div",{className:"typography-markdown text-xl font-semibold text-foreground break-words leading-snug",children:Z.title})}),Z.state==="open"?s.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:me?s.jsxs(s.Fragment,{children:[s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx(dt,{variant:"outline",size:"sm",className:"h-9 w-9 px-0",onClick:()=>{ge(!1),B(Z.title||""),ve(Z.body||"")},disabled:Ae,"aria-label":a("gitView.pr.actions.cancelEditingAria"),children:s.jsx(M,{name:"close",className:"size-4"})})}),s.jsx(Dt,{children:s.jsx("p",{children:a("gitView.pr.actions.cancelEditing")})})]}),s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx(dt,{size:"sm",className:"h-9 w-9 px-0",onClick:()=>qs(Z),disabled:Ae||!_.trim(),"aria-label":a("gitView.pr.actions.savePrAria"),children:Ae?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(M,{name:"check",className:"size-4"})})}),s.jsx(Dt,{children:s.jsx("p",{children:a("gitView.pr.actions.savePr")})})]})]}):s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx(dt,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>ge(!0),"aria-label":a("gitView.pr.actions.editPrAria"),children:s.jsx(M,{name:"edit",className:"size-4"})})}),s.jsx(Dt,{children:s.jsx("p",{children:a("gitView.pr.actions.editPr")})})]})}):null]}),me?s.jsx(fr,{value:he,onChange:ie=>ve(ie.target.value),outerClassName:"min-h-[60vh]",placeholder:a("gitView.pr.placeholder.description"),autoCorrect:m?"on":"off",autoCapitalize:m?"sentences":"off",spellCheck:m}):null,me?null:Z.body?.trim()?s.jsx(Nl,{content:Z.body,className:"typography-markdown-body min-w-0 text-muted-foreground break-words",enableFileReferences:!1}):s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:a(ze?"gitView.pr.loadingDescription":"gitView.pr.noDescription")})]}):null,pt==="checks"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[Ue&&Ue.total>0?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-muted/40",children:[Ue.success>0?s.jsx("div",{className:"bg-[color:var(--status-success)]",style:{width:`${Ue.success/Ue.total*100}%`}}):null,Ue.failure>0?s.jsx("div",{className:"bg-[color:var(--status-error)]",style:{width:`${Ue.failure/Ue.total*100}%`}}):null,Ue.pending>0?s.jsx("div",{className:"bg-[color:var(--status-warning)]",style:{width:`${Ue.pending/Ue.total*100}%`}}):null]}),s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Ue.success,"/",Ue.total," ",a("gitView.pr.checks.label")]}),(Ue.inProgress??0)>0?s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-[var(--status-warning)]",children:[s.jsx(M,{name:"loader-4",className:"size-3.5 animate-spin"}),hi(Ue.startedAt,void 0,Ct)]}):null]}):null,Ue?.failure?s.jsxs(dt,{variant:"outline",size:"sm",className:"w-fit gap-1.5 border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)]",onClick:Zt,disabled:Bt,"aria-label":a("gitView.pr.actions.resolveFailedChecksAria"),children:[Bt?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(M,{name:"ai-generate-2",className:"size-4"}),a("gitView.pr.actions.resolveFailedChecks")]}):null,(at?.checkRuns?.length??0)>0?s.jsx("div",{className:"flex flex-col gap-1.5",children:(at?.checkRuns??[]).map((ie,Qe)=>{const lt=`${ie.id??"run"}:${ie.name}:${Qe}`,st=ie.status==="in_progress",gt=ie.status==="queued",U=pi(ie.conclusion),Te=yt.has(lt),ot=!!(ie.output?.title||ie.output?.summary||ie.output?.text||(ie.annotations?.length??0)>0||(ie.job?.steps?.length??0)>0||ie.detailsUrl),Et=ie.job?.workflowName,Mt=st?hi(ie.startedAt,void 0,Ct):hi(ie.startedAt,ie.completedAt);return s.jsxs("div",{className:Oe("rounded-md border border-border/40",U&&"border-[var(--status-error-border)]"),children:[s.jsxs("button",{type:"button",disabled:!ot,onClick:()=>{Rt($t=>{const Wt=new Set($t);return Wt.has(lt)?Wt.delete(lt):Wt.add(lt),Wt})},className:"flex w-full items-center gap-2 px-2.5 py-2 text-left disabled:cursor-default",children:[st?s.jsx(M,{name:"loader-4",className:"size-4 shrink-0 animate-spin text-[var(--status-warning)]"}):gt?s.jsx(M,{name:"time",className:"size-4 shrink-0 text-muted-foreground"}):U?s.jsx(M,{name:"close-circle",className:"size-4 shrink-0 text-[var(--status-error)]"}):s.jsx(M,{name:"checkbox-circle",className:"size-4 shrink-0 text-[var(--status-success)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:Et&&Et!==ie.name?`${Et} / ${ie.name}`:ie.name}),Mt?s.jsx("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:Mt}):null,ot?s.jsx(M,{name:"arrow-down-s",className:Oe("size-4 shrink-0 text-muted-foreground transition-transform",Te&&"rotate-180")}):null]}),Te&&ot?s.jsx("div",{className:"min-w-0 overflow-hidden border-t border-border/40 p-2.5",children:Ut(ie,{hideHeader:!0})}):null]},lt)})}):Ye?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.loading.loading")]}):s.jsx("div",{className:"py-6 text-center typography-micro text-muted-foreground",children:a("gitView.pr.checkDetails.empty")})]}):null,pt==="comments"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[nt.length>0?s.jsx("div",{className:"flex items-center justify-end",children:s.jsxs(dt,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-[var(--status-success)] hover:bg-[var(--status-success-background)] hover:text-[var(--status-success)]",onClick:es,disabled:_t,"aria-label":a("gitView.pr.actions.shareCommentsAria"),children:[_t?s.jsx(M,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(M,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.comments.addAll")]})}):null,nt.length>0?s.jsx("div",{className:"relative pl-3",children:s.jsx("div",{children:nt.map((ie,Qe)=>{const lt=(ie.authorName||"?").charAt(0).toUpperCase(),st=Qe===nt.length-1;return s.jsxs("div",{className:"relative pl-10 pb-5 last:pb-0",children:[st?null:s.jsx("div",{className:"absolute left-4 top-[2.375rem] bottom-[0.375rem] w-px bg-border/60"}),s.jsx("div",{className:"absolute left-0 top-0 z-10 flex size-8 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-surface-elevated text-xs text-muted-foreground",children:ie.avatarUrl?s.jsx("img",{src:ie.avatarUrl,alt:ie.authorName,className:"h-full w-full object-cover"}):s.jsx("span",{children:lt})}),s.jsxs("div",{className:"rounded-lg bg-surface-elevated px-3 pt-0 pb-3 space-y-2",children:[s.jsxs("div",{className:"flex flex-col items-start gap-1 typography-micro text-muted-foreground sm:flex-row sm:flex-wrap sm:items-center sm:gap-x-1 sm:gap-y-1",children:[s.jsxs("span",{className:"text-foreground whitespace-nowrap",children:[ie.authorName,ie.authorLogin&&ie.authorLogin!==ie.authorName?` · @${ie.authorLogin}`:""]}),ie.createdAt?s.jsx("span",{className:"whitespace-nowrap",children:ft(ie.createdAt)}):null,s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsxs(dt,{variant:"ghost",size:"sm",className:"h-6 px-0 has-[>svg]:px-0 sm:px-2 sm:has-[>svg]:px-2.5 text-[var(--status-success)] hover:bg-[var(--status-success-background)] hover:text-[var(--status-success)] justify-start",onClick:()=>{Vt(ie)},"aria-label":a("gitView.pr.actions.sendCommentToAgentAria"),children:[s.jsx(M,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.actions.sendToAgent")]})}),s.jsx(Dt,{children:s.jsx("p",{children:a("gitView.pr.actions.sendCommentToAgent")})})]})]}),s.jsxs("div",{className:"typography-micro text-muted-foreground",children:[ie.context,ie.path?` · ${ie.path}`:"",ie.line?`:${ie.line}`:""]}),s.jsx(Nl,{content:He(ie.body),className:["typography-markdown-body text-foreground break-words [&_a]:no-underline [&_a:hover]:no-underline",Ke].filter(Boolean).join(" "),enableFileReferences:!1})]})]},ie.id)})})}):Ye&&!at?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.loading.loading")]}):s.jsx("div",{className:"py-6 text-center typography-micro text-muted-foreground",children:a("gitView.pr.comments.empty")})]}):null]}):s.jsxs("div",{className:"flex flex-col gap-3",children:[Z&&je?s.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md border border-border/60 bg-surface-muted/40 px-2.5 py-2",children:[s.jsx(M,{name:Z.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:Qs}}),s.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:Z.state==="merged"?a("gitView.pr.history.merged",{number:Z.number,base:Z.base||re}):a("gitView.pr.history.closed",{number:Z.number})}),s.jsx(dt,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{oo(Z.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:s.jsx(M,{name:"external-link",className:"size-3.5"})})]}):null,s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:a("gitView.pr.createTitle")}),s.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," ",s.jsx("span",{className:"opacity-60",children:"(local)"})," → ",re," ",s.jsxs("span",{className:"opacity-60",children:["(",ae&&Ce?"upstream":"remote",")"]})]})]}),Cs?s.jsx(dt,{variant:"outline",size:"sm",asChild:!0,children:s.jsxs("a",{href:Cs,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(M,{name:"external-link",className:"size-4"}),a("gitView.pr.actions.repo")]})}):null]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.title")}),s.jsx(An,{value:K,onChange:ie=>F(ie.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:m?"on":"off",autoCapitalize:m?"sentences":"off",spellCheck:m})]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.baseBranch")}),et.length>0?s.jsxs(Bs,{value:re,onValueChange:fe,children:[s.jsx(Fs,{size:"lg",children:s.jsx(ks,{placeholder:a("gitView.pr.placeholder.selectBaseBranch")})}),s.jsx(_s,{children:et.map(ie=>s.jsx(ss,{value:ie,children:ie},ie))})]}):s.jsx(An,{value:re,onChange:ie=>fe(ie.target.value),placeholder:a("gitView.pr.placeholder.main")})]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.description")}),s.jsx(fr,{value:W,onChange:ie=>N(ie.target.value),className:"min-h-[110px]",placeholder:a("gitView.pr.placeholder.whatChanged"),autoCorrect:m?"on":"off",autoCapitalize:m?"sentences":"off",spellCheck:m})]}),s.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",role:"button",tabIndex:0,"aria-pressed":R,onClick:()=>E(ie=>!ie),onKeyDown:ie=>{(ie.key===" "||ie.key==="Enter")&&(ie.preventDefault(),E(Qe=>!Qe))},children:[s.jsx(pr,{size:"sm",checked:R,onChange:ie=>E(ie),ariaLabel:a("gitView.pr.actions.toggleDraftAria")}),s.jsx("span",{className:"typography-ui-label text-foreground select-none",children:a("gitView.pr.field.draft")})]}),y?s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.optional")}),s.jsx(dt,{variant:"outline",size:"sm",onClick:()=>q(!0),children:X.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),X.trim()&&s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("span",{className:"inline-flex items-center rounded-full bg-[var(--interactive-selection)] px-2 py-0.5 text-xs text-[var(--interactive-selection-foreground)]",children:a("gitView.pr.additionalContext.added")})})]}):s.jsxs(Bi,{open:Re,onOpenChange:ce,children:[s.jsxs(mu,{className:"flex w-full items-center justify-between rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-3 py-2 hover:bg-[var(--interactive-hover)]",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.optional")}),s.jsx("span",{className:"typography-micro text-[var(--primary-base)]",children:Re?a("gitView.pr.actions.hide"):X.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),s.jsx(Fi,{children:s.jsxs("div",{className:"mt-2 space-y-2 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3",children:[s.jsx(fr,{value:X,onChange:ie=>J(ie.target.value),className:"min-h-[100px] bg-transparent",placeholder:a("gitView.pr.placeholder.additionalContext")}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.hint")})]})})]}),s.jsx(Go,{open:se,onClose:()=>q(!1),title:a("gitView.pr.additionalContext.title"),footer:s.jsx(dt,{size:"sm",onClick:()=>q(!1),className:"w-full",children:a("gitView.common.done")}),children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(fr,{value:X,onChange:ie=>J(ie.target.value),className:"min-h-[200px] bg-transparent",placeholder:a("gitView.pr.placeholder.additionalContext"),autoFocus:!0}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.hint")})]})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(dt,{variant:"outline",size:"sm",onClick:nn,disabled:ue||we,children:[ue?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(M,{name:"ai-generate-2",className:"size-4 text-primary"}),a("gitView.commit.generate")]}),s.jsx("div",{className:"flex-1"}),s.jsxs(dt,{size:"sm",className:"min-w-[7.5rem] justify-center gap-2",onClick:Ts,disabled:we||!mn||!re.trim()||!ae&&re.trim()===e,children:[s.jsx("span",{className:"inline-flex size-4 items-center justify-center",children:we?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(M,{name:"git-pull-request",className:"size-4"})}),s.jsx("span",{children:a("gitView.pr.actions.createPr")})]})]})]})]})]})},xi=t=>(t||"").replace(/\\/g,"/").replace(/\/+$/,""),io=new Map,ao=new Map,Mn=t=>`${qt()}::${t}`,Yy=()=>{const t=Ze.c(115),{t:e}=jt(),{git:n}=vn(),r=ir(),{rootIsGitRepo:i,gitDirectory:o,nestedRepos:l}=vp(r??null),a=Na(o??null),d=hu(o??null),u=pu(o??null),{ensureAll:h,ensureNestedRepos:f,selectNestedRepo:x}=Tn(rr(Qy)),b=tt(Xy),w=tt(Jy),v=tt(Zy),y=tt(e1);let m;t[0]!==r?(m=xi(r),t[0]=r,t[1]=m):m=t[1];const p=m;let S;if(t[2]!==y||t[3]!==p||t[4]!==v){e:{if(!p){S=void 0;break e}let z;if(t[6]!==y||t[7]!==p){let ae;t[9]!==p?(ae=Ne=>xi(Ne.path)===p,t[9]=p,t[10]=ae):ae=t[10],z=y.find(ae),t[6]=y,t[7]=p,t[8]=z}else z=t[8];const ee=z;if(ee){S=ee;break e}for(const ae of v.values())if(xi(ae.path)===p){S=ae;break e}S=void 0}t[2]=y,t[3]=p,t[4]=v,t[5]=S}else S=t[5];const g=S;let C;t[11]!==b||t[12]!==g||t[13]!==w?.open||t[14]!==v?(C=()=>{if(b)return v.get(b)??g;if(w?.open)return g},t[11]=b,t[12]=g,t[13]=w?.open,t[14]=v,t[15]=C):C=t[15],w?.open;let k;t[16]!==C?(k=C(),t[16]=C,t[17]=k):k=t[17];const j=k;let D;t[18]!==b?(D=z=>b?z.getAttachment(b):void 0,t[18]=b,t[19]=D):D=t[19];const I=su(D),A=I&&!I.degraded&&!I.legacy?I.worktreeRoot??void 0:void 0,P=jy(r,j,a?.current??void 0);let T,L;t[20]!==h||t[21]!==n||t[22]!==o?(T=()=>{!o||!n||h(o,n)},L=[o,h,n],t[20]=h,t[21]=n,t[22]=o,t[23]=T,t[24]=L):(T=t[23],L=t[24]),c.useEffect(T,L);const[$,K]=c.useState(null);let F;t[25]!==A||t[26]!==P?.projectDirectory?(F=()=>{const z=A||P?.projectDirectory;if(!z){K(null);return}let ee=!1;return Aa(z).then(ae=>{if(ee)return;const Ne=ae.trim();K(Ne&&Ne!=="HEAD"?Ne:null)}).catch(()=>{ee||K(null)}),()=>{ee=!0}},t[25]=A,t[26]=P?.projectDirectory,t[27]=F):F=t[27];const W=P?.projectDirectory;let N;t[28]!==A||t[29]!==W?(N=[A,W],t[28]=A,t[29]=W,t[30]=N):N=t[30],c.useEffect(F,N);let R;t[31]!==o?(R=()=>(o?io.get(Mn(o)):void 0)??[],t[31]=o,t[32]=R):R=t[32];const[E,X]=c.useState(R);let J;t[33]!==o?(J=()=>(o?ao.get(Mn(o)):void 0)??null,t[33]=o,t[34]=J):J=t[34];const[re,fe]=c.useState(J);let ne,te;t[35]!==n||t[36]!==o?(ne=()=>{if(!o||!n?.getRemotes){X([]);return}X(io.get(Mn(o))??[]);let z=!1;return n.getRemotes(o).then(ee=>{z||(io.set(Mn(o),ee??[]),X(ee??[]))}).catch(()=>{z||X(io.get(Mn(o))??[])}),()=>{z=!0}},te=[o,n],t[35]=n,t[36]=o,t[37]=ne,t[38]=te):(ne=t[37],te=t[38]),c.useEffect(ne,te);let ue,Se;t[39]!==n||t[40]!==o?(ue=()=>{if(!o||!n?.getRemoteUrl){fe(null);return}fe(ao.get(Mn(o))??null);let z=!1;return n.getRemoteUrl(o).then(ee=>{z||(ao.set(Mn(o),ee),fe(ee))}).catch(()=>{z||fe(ao.get(Mn(o))??null)}),()=>{z=!0}},Se=[o,n],t[39]=n,t[40]=o,t[41]=ue,t[42]=Se):(ue=t[41],Se=t[42]),c.useEffect(ue,Se);let we;e:{if(!d?.all){let ee;t[43]===Symbol.for("react.memo_cache_sentinel")?(ee=[],t[43]=ee):ee=t[43],we=ee;break e}let z;t[44]!==d.all?(z=d.all.filter(t1).sort(),t[44]=d.all,t[45]=z):z=t[45],we=z}const ye=we;let Ae;e:{if(!d?.all){let ee;t[46]===Symbol.for("react.memo_cache_sentinel")?(ee=[],t[46]=ee):ee=t[46],Ae=ee;break e}let z;t[47]!==d.all?(z=d.all.filter(s1).map(n1).sort(),t[47]=d.all,t[48]=z):z=t[48],Ae=z}const pe=Ae;let O;t[49]!==pe||t[50]!==re||t[51]!==E||t[52]!==a?.tracking?(O=()=>{if(E.length>0)return E;const z=new Set,ee=a?.tracking?.trim();ee&&ee.includes("/")&&z.add(ee.split("/")[0]);for(const ae of pe){const Ne=ae.indexOf("/");Ne>0&&z.add(ae.slice(0,Ne))}return z.size===0&&re&&z.add("origin"),Array.from(z).map(ae=>({name:ae,fetchUrl:re??"",pushUrl:re??""}))},t[49]=pe,t[50]=re,t[51]=E,t[52]=a?.tracking,t[53]=O):O=t[53],a?.tracking;let Q;t[54]!==O?(Q=O(),t[54]=O,t[55]=Q):Q=t[55];const le=Q,H=a?.current??null;a?.tracking;let me;t[56]!==a?.tracking?(me=a?.tracking?.trim().split("/")[0],t[56]=a?.tracking,t[57]=me):me=t[57];const ge=me,oe=(ge&&d?.defaultBranches?.[ge])??d?.defaultBranches?.origin;let de;t[58]!==H||t[59]!==oe||t[60]!==le||t[61]!==ye||t[62]!==$||t[63]!==P?.createdFromBranch?(de=()=>wh({remoteNames:new Set(le.map(r1)),localBranches:ye,worktreeCreatedFromBranch:P?.createdFromBranch,rootBranchHint:$,defaultBranch:oe,headBranch:H}),t[58]=H,t[59]=oe,t[60]=le,t[61]=ye,t[62]=$,t[63]=P?.createdFromBranch,t[64]=de):de=t[64],P?.createdFromBranch;let _;t[65]!==de?(_=de(),t[65]=de,t[66]=_):_=t[66];const B=_;if(!r){let z;t[67]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx(M,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[67]=z):z=t[67];let ee;t[68]!==e?(ee=e("gitView.pullRequest.title"),t[68]=e,t[69]=ee):ee=t[69];let ae;t[70]!==ee?(ae=s.jsx("div",{className:"typography-ui-header text-foreground",children:ee}),t[70]=ee,t[71]=ae):ae=t[71];let Ne;t[72]!==e?(Ne=e("gitView.pullRequest.createHint"),t[72]=e,t[73]=Ne):Ne=t[73];let Ce;t[74]!==Ne?(Ce=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Ne}),t[74]=Ne,t[75]=Ce):Ce=t[75];let We;return t[76]!==ae||t[77]!==Ce?(We=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[z,ae,Ce]}),t[76]=ae,t[77]=Ce,t[78]=We):We=t[78],We}if(i===!1&&u!==!0){let z;t[79]!==r||t[80]!==f?(z=()=>{f(r,{force:!0})},t[79]=r,t[80]=f,t[81]=z):z=t[81];let ee;return t[82]!==u||t[83]!==l||t[84]!==i||t[85]!==z?(ee=s.jsx(vh,{rootIsGitRepo:i,resolvedIsGitRepo:u,nestedRepos:l,onRetryDiscovery:z}),t[82]=u,t[83]=l,t[84]=i,t[85]=z,t[86]=ee):ee=t[86],ee}if(!H){let z;t[87]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx(M,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[87]=z):z=t[87];let ee;t[88]!==e?(ee=e("gitView.pullRequest.title"),t[88]=e,t[89]=ee):ee=t[89];let ae;t[90]!==ee?(ae=s.jsx("div",{className:"typography-ui-header text-foreground",children:ee}),t[90]=ee,t[91]=ae):ae=t[91];let Ne;t[92]!==e?(Ne=e("gitView.pullRequest.createHint"),t[92]=e,t[93]=Ne):Ne=t[93];let Ce;t[94]!==Ne?(Ce=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Ne}),t[94]=Ne,t[95]=Ce):Ce=t[95];let We;return t[96]!==ae||t[97]!==Ce?(We=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[z,ae,Ce]}),t[96]=ae,t[97]=Ce,t[98]=We):We=t[98],We}const he=i===!1&&Array.isArray(l)&&l.length>0;let ve;t[99]!==r||t[100]!==o||t[101]!==l||t[102]!==x||t[103]!==he?(ve=he?s.jsx("div",{className:"flex shrink-0 items-center border-b border-border/60 px-4 py-2",children:s.jsx(Sh,{repositories:l,selectedRepository:o??null,onSelectRepository:z=>{r&&x(r,z)},repositoryRoot:r??void 0})}):null,t[99]=r,t[100]=o,t[101]=l,t[102]=x,t[103]=he,t[104]=ve):ve=t[104];const Re=o??r,ce=a?.tracking??void 0;let se;t[105]!==B||t[106]!==H||t[107]!==pe||t[108]!==E||t[109]!==Re||t[110]!==ce?(se=s.jsx(yn,{as:Da,outerClassName:"h-full min-h-0 flex-1",className:"px-4 py-3",disableHorizontal:!0,preventOverscroll:!0,children:s.jsx(qy,{directory:Re,branch:H,baseBranch:B,trackingBranch:ce,remotes:E,remoteBranches:pe})}),t[105]=B,t[106]=H,t[107]=pe,t[108]=E,t[109]=Re,t[110]=ce,t[111]=se):se=t[111];let q;return t[112]!==ve||t[113]!==se?(q=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[ve,se]}),t[112]=ve,t[113]=se,t[114]=q):q=t[114],q};function Qy(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function Xy(t){return t.currentSessionId}function Jy(t){return t.newSessionDraft}function Zy(t){return t.worktreeMetadata}function e1(t){return t.availableWorktrees}function t1(t){return!t.startsWith("remotes/")}function s1(t){return t.startsWith("remotes/")}function n1(t){return t.replace(/^remotes\//,"")}function r1(t){return t.name}const ea=2e4,o1=(t,e)=>{if(!t)return 1;let n=1;for(let r=0;r<t.length;r+=1)if(t.charCodeAt(r)===10&&(n+=1,n>e))return n;return n},lo=(t,e)=>Np(Ap.getState().dictionary,t,e),i1=t=>{const n=(t instanceof Error?t.message:String(t??"")).toLowerCase();return n.includes("file not found")||n.includes("not found")||n.includes("enoent")||n.includes("no such file")||n.includes("does not exist")?"missing":"unreadable"},a1=async(t,e,n)=>{if(t.readFile)return(await t.readFile(e,{optional:!0,directory:n?.directory})).content??"";const r=new URLSearchParams({path:e,optional:"true"});n?.directory&&r.set("directory",n.directory);const i=await ls(`/api/fs/read?${r.toString()}`,{cache:"no-store",headers:n?.directory?{"x-opencode-directory":n.directory}:void 0});if(!i.ok){const o=await i.json().catch(()=>({error:i.statusText}));throw new Error(o.error||"Failed to read file")}return i.text()},uf=async(t,e,n)=>{if(Sp(e)||jp(e)||kp(e))return{ok:!0};try{const r=await a1(t,e,n);return Cp(r)?{ok:!1,reason:"binary"}:o1(r,ea)>ea?{ok:!1,reason:"too-large"}:{ok:!0}}catch(r){return{ok:!1,reason:i1(r)}}},ff=t=>{if(t==="too-large"){const e=ea.toLocaleString(gu());return lo("contextFileOpen.failure.tooLarge",{count:e})}return lo(t==="missing"?"contextFileOpen.failure.missing":t==="binary"?"filesView.editor.cannotPreviewBinary":"contextFileOpen.failure.unreadable")},uc=8;let ta=null;const mf=t=>{ta={x:t.clientX,y:t.clientY}},hf=t=>{const e=ta;return ta=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:Math.abs(t.clientX-e.x)<=uc&&Math.abs(t.clientY-e.y)<=uc},fc=3,xr=t=>Array.from(t.types).includes("Files"),l1=t=>{const e=Array.from(t.items);return e.length===0?Array.from(t.files):e.flatMap(n=>{if(n.kind!=="file"||n.webkitGetAsEntry()?.isDirectory)return[];const r=n.getAsFile();return r?[r]:[]})},mc=t=>{const e=t.name;return!e||e==="."||e===".."||e.includes("/")||e.includes("\\")?null:e},c1=t=>t.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),as=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},Ga=(t,e)=>{const n=as(e),r=as(t).replace(/\/+$/,"");return n===r?".":!r||!n.startsWith(`${r}/`)?n:n.slice(r.length+1)},d1=(t,e)=>{const n=Ga(t,e);if(n!==".")return n;const r=as(t);return r.split("/").filter(Boolean).pop()??r},u1=t=>{const e=as(t),n=e.lastIndexOf("/");return n<0?"":n===0?"/":e.slice(0,n)},f1=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),m1=new Set(["node_modules"]),h1=t=>m1.has(t),p1=t=>{const e=as(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},g1=8,pn=new Map,qa=t=>JSON.stringify([qt(),t]),x1=t=>{const e=qa(t),n=pn.get(e);return n?(n.touchedAt=Date.now(),pn.delete(e),pn.set(e,n),n):null},bi=t=>{const e=qa(t),n=pn.get(e);if(n)return n.touchedAt=Date.now(),n;if(pn.size>=g1){const i=pn.keys().next().value;i!==void 0&&pn.delete(i)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return pn.set(e,r),r},pf=(t,e)=>s.jsx(Pa,{filePath:t,extension:e}),b1=t=>{const e=Ze.c(3),{status:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=r):r=e[0];const i=r[n];let o;return e[1]!==i?(o=s.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:i}}),e[1]=i,e[2]=o):o=e[2],o},y1=t=>{const e=Ze.c(88),{node:n,root:r,isExpanded:i,isActive:o,isBrowserClient:l,status:a,badge:d,isDropTarget:u,canUpload:h,permissions:f,downloadFile:x,onSelect:b,onToggle:w,onRevealPath:v,onOpenDialog:y,onSetDropTarget:m,onDropFiles:p}=t,{t:S}=jt(),g=n.type==="directory";let C;e[0]!==g||e[1]!==n.path?(C=g?n.path:u1(n.path),e[0]=g,e[1]=n.path,e[2]=C):C=e[2];const k=C,{canRename:j,canCreateFile:D,canCreateFolder:I,canDelete:A,canReveal:P}=f,T=!g&&!!x,L=P&&!l,$=j||D||I||A||T||L,[K,F]=c.useState(!1),[W,N]=c.useState(!1);let R;e[3]!==$?(R=ee=>{$&&(ee?.preventDefault(),N(!0))},e[3]=$,e[4]=R):R=e[4];const E=R;let X;e[5]!==g||e[6]!==n||e[7]!==b||e[8]!==w?(X=()=>{g?w(n.path):b(n)},e[5]=g,e[6]=n,e[7]=b,e[8]=w,e[9]=X):X=e[9];const J=X;let re;e[10]===Symbol.for("react.memo_cache_sentinel")?(re=ee=>{ee.stopPropagation(),N(!1),F(!0)},e[10]=re):re=e[10];const fe=re;let ne;e[11]!==D||e[12]!==I||e[13]!==A||e[14]!==j||e[15]!==L||e[16]!==x||e[17]!==l||e[18]!==g||e[19]!==n||e[20]!==y||e[21]!==v||e[22]!==S?(ne=ee=>{const{Item:ae,Separator:Ne}=ee;return s.jsxs(s.Fragment,{children:[j&&s.jsxs(ae,{onClick:Ce=>{Ce.stopPropagation(),y("rename",n)},children:[s.jsx(M,{name:"edit",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.rename")]}),s.jsxs(ae,{onClick:Ce=>{Ce.stopPropagation(),gn(n.path).then(We=>{if(We.ok){Le.success(S("sidebarFilesTree.toast.pathCopied"));return}Le.error(S("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(M,{name:"file-copy",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.copyPath")]}),!g&&x&&s.jsxs(ae,{onClick:Ce=>{Ce.stopPropagation(),x(n.path).catch(We=>{console.error("Download failed:",We),Le.error(S("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(M,{name:"download",className:"mr-2 h-4 w-4"})," ",S(l?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),L&&s.jsxs(ae,{onClick:Ce=>{Ce.stopPropagation(),v(n.path)},children:[s.jsx(M,{name:"folder-received",className:"mr-2 h-4 w-4"})," ",S(Dp())]}),g&&(D||I)&&s.jsxs(s.Fragment,{children:[s.jsx(Ne,{}),D&&s.jsxs(ae,{onClick:Ce=>{Ce.stopPropagation(),y("createFile",n)},children:[s.jsx(M,{name:"file-add",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.newFile")]}),I&&s.jsxs(ae,{onClick:Ce=>{Ce.stopPropagation(),y("createFolder",n)},children:[s.jsx(M,{name:"folder-add",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.newFolder")]})]}),A&&s.jsxs(s.Fragment,{children:[s.jsx(Ne,{}),s.jsxs(ae,{onClick:Ce=>{Ce.stopPropagation(),y("delete",n)},className:"text-destructive focus:text-destructive",children:[s.jsx(M,{name:"delete-bin",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.delete")]})]})]})},e[11]=D,e[12]=I,e[13]=A,e[14]=j,e[15]=L,e[16]=x,e[17]=l,e[18]=g,e[19]=n,e[20]=y,e[21]=v,e[22]=S,e[23]=ne):ne=e[23];const te=ne;let ue;e[24]!==n.path||e[25]!==r?(ue=ee=>{mf(ee);const ae=Ga(r,n.path);!ae||ae==="."||(ee.dataTransfer.setData("application/x-openchamber-file-path",ae),ee.dataTransfer.effectAllowed="copy")},e[24]=n.path,e[25]=r,e[26]=ue):ue=e[26];const Se=ue;let we;e[27]!==J?(we=ee=>{hf(ee)&&J()},e[27]=J,e[28]=we):we=e[28];const ye=we;let Ae;e[29]!==h||e[30]!==m||e[31]!==k?(Ae=ee=>{!h||!k||!xr(ee.dataTransfer)||(ee.preventDefault(),ee.stopPropagation(),ee.dataTransfer.dropEffect="copy",m(k))},e[29]=h,e[30]=m,e[31]=k,e[32]=Ae):Ae=e[32];const pe=Ae;let O;e[33]!==h||e[34]!==m||e[35]!==k?(O=ee=>{!h||!k||!xr(ee.dataTransfer)||ee.relatedTarget instanceof Node&&ee.currentTarget.contains(ee.relatedTarget)||(ee.stopPropagation(),m(null))},e[33]=h,e[34]=m,e[35]=k,e[36]=O):O=e[36];const Q=O;let le;e[37]!==h||e[38]!==p||e[39]!==k?(le=ee=>{!h||!k||!xr(ee.dataTransfer)||(ee.preventDefault(),ee.stopPropagation(),p(k,ee.dataTransfer))},e[37]=h,e[38]=p,e[39]=k,e[40]=le):le=e[40];const H=le;let me;e[41]===Symbol.for("react.memo_cache_sentinel")?(me={contentVisibility:"auto",blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[41]=me):me=e[41];let ge;e[42]!==E||e[43]!==Q||e[44]!==pe||e[45]!==H?(ge=s.jsx("div",{className:"group relative flex items-center typography-meta",style:me,onContextMenu:E,onDragEnter:pe,onDragOver:pe,onDragLeave:Q,onDrop:H}),e[42]=E,e[43]=Q,e[44]=pe,e[45]=H,e[46]=ge):ge=e[46];const oe=u?"bg-interactive-selection ring-2 ring-inset ring-primary":o?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let de;e[47]!==oe?(de=Oe("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",oe),e[47]=oe,e[48]=de):de=e[48];let _;e[49]!==g||e[50]!==i||e[51]!==n.extension||e[52]!==n.path?(_=g?i?s.jsx(M,{name:"folder-open",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):s.jsx(M,{name:"folder-3",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):pf(n.path,n.extension),e[49]=g,e[50]=i,e[51]=n.extension,e[52]=n.path,e[53]=_):_=e[53];let B;e[54]!==n.name||e[55]!==n.path?(B=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:n.path,children:n.name}),e[54]=n.name,e[55]=n.path,e[56]=B):B=e[56];let he;e[57]!==g||e[58]!==a?(he=!g&&a&&s.jsx(b1,{status:a}),e[57]=g,e[58]=a,e[59]=he):he=e[59];let ve;e[60]!==d||e[61]!==g?(ve=g&&d&&s.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[d.modified>0&&s.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",d.modified]}),d.added>0&&s.jsxs("span",{className:"text-[var(--status-success)]",children:["+",d.added]})]}),e[60]=d,e[61]=g,e[62]=ve):ve=e[62];let Re;e[63]!==E||e[64]!==ye||e[65]!==Se||e[66]!==J||e[67]!==de||e[68]!==_||e[69]!==B||e[70]!==he||e[71]!==ve?(Re=s.jsxs("button",{type:"button",onClick:J,onContextMenu:E,draggable:!0,onDragStart:Se,onDragEnd:ye,className:de,children:[_,B,he,ve]}),e[63]=E,e[64]=ye,e[65]=Se,e[66]=J,e[67]=de,e[68]=_,e[69]=B,e[70]=he,e[71]=ve,e[72]=Re):Re=e[72];let ce;e[73]!==K||e[74]!==$||e[75]!==te||e[76]!==S?(ce=$&&s.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 focus-within:opacity-100 group-hover:opacity-100",children:s.jsxs(Ks,{open:K,onOpenChange:F,children:[s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(zs,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:fe,title:S("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":S("sidebarFilesTree.actions.fileMenuTitle"),children:s.jsx(M,{name:"more-2-fill",className:"h-4 w-4"})})})})}),s.jsx(Dt,{side:"bottom",sideOffset:6,children:S("sidebarFilesTree.actions.fileMenuTitle")})]}),s.jsx(Ws,{align:"end",side:"bottom",onCloseAutoFocus:()=>F(!1),children:te({Item:Kt,Separator:Os})})]})}),e[73]=K,e[74]=$,e[75]=te,e[76]=S,e[77]=ce):ce=e[77];let se;e[78]!==ge||e[79]!==Re||e[80]!==ce?(se=s.jsxs(Wd,{render:ge,children:[Re,ce]}),e[78]=ge,e[79]=Re,e[80]=ce,e[81]=se):se=e[81];let q;e[82]!==te?(q=s.jsx(zd,{className:"min-w-[180px]",children:te({Item:Qn,Separator:Ei})}),e[82]=te,e[83]=q):q=e[83];let z;return e[84]!==W||e[85]!==se||e[86]!==q?(z=s.jsxs(Kd,{open:W,onOpenChange:N,children:[se,q]}),e[84]=W,e[85]=se,e[86]=q,e[87]=z):z=e[87],z},w1=(t,e)=>t.node===e.node&&t.root===e.root&&t.isExpanded===e.isExpanded&&t.isActive===e.isActive&&t.isBrowserClient===e.isBrowserClient&&t.status===e.status&&t.badge===e.badge&&t.isDropTarget===e.isDropTarget&&t.canUpload===e.canUpload&&t.permissions===e.permissions&&t.downloadFile===e.downloadFile&&t.onSelect===e.onSelect&&t.onToggle===e.onToggle&&t.onRevealPath===e.onRevealPath&&t.onOpenDialog===e.onOpenDialog&&t.onSetDropTarget===e.onSetDropTarget&&t.onDropFiles===e.onDropFiles,v1=c.memo(y1,w1),S1=t=>{const e=Ze.c(6),{visible:n}=t,r=n===void 0?!0:n,i=Tn(k1),o=ir();let l;e[0]!==o||e[1]!==i?(l=JSON.stringify([i,o]),e[0]=o,e[1]=i,e[2]=l):l=e[2];let a;return e[3]!==l||e[4]!==r?(a=s.jsx(j1,{visible:r},l),e[3]=l,e[4]=r,e[5]=a):a=e[5],a},j1=({visible:t})=>{const e=c.useRef(t);e.current=t;const{t:n}=jt(),{files:r,runtime:i}=vn(),o=Wm(i.platform),l=ir()??"",a=as(l.trim()),d=qa(a),u=Km(),h=Vm(),f=Rd(be=>be.searchFiles),x=Pe(be=>be.openContextFile),b=Na(t?l:null),[w,v]=c.useState(""),y=xu(w,200),m=c.useRef(null),[p,S]=c.useState([]),[g,C]=c.useState(!1),[k,j]=c.useState(null),[D,I]=c.useState(!1),[A,P]=c.useState(null),T=c.useRef(!1),L=c.useRef(a);L.current=a;const[$,K]=c.useState({}),[F,W]=c.useState({}),N=c.useRef(new Set),R=c.useMemo(()=>new Mx,[]);c.useEffect(()=>()=>R.clear(),[R]);const E=c.useRef(null);c.useEffect(()=>{if(j(null),P(null),!a){K({}),W({}),N.current=new Set;return}const be=x1(a);be?(K({...be.childrenByDir}),W({...be.loadErrorsByDir}),N.current=new Set(be.loadedDirs)):(K({}),W({}),N.current=new Set)},[a]),c.useEffect(()=>{if(!a)return;const be=bi(a);be.childrenByDir=$},[a,$]),c.useEffect(()=>{if(!a)return;const be=bi(a);be.loadErrorsByDir=F},[a,F]),c.useEffect(()=>{if(!a)return;const be=bi(a);be.loadedDirs=new Set(N.current)},[a,$,F]),c.useEffect(()=>()=>{if(!a)return;const be=pn.get(d);be&&be.loadedDirs.size===0&&Object.keys(be.childrenByDir).length===0&&pn.delete(d)},[d,a]);const X=c.useMemo(()=>[],[]),J=c.useMemo(()=>[],[]),re=hn(be=>a?be.byRoot[a]?.expandedPaths??X:X),fe=c.useMemo(()=>new Set(re),[re]),ne=hn(be=>a?be.byRoot[a]?.selectedPath??null:null),te=hn(be=>be.setSelectedPath),ue=hn(be=>be.addOpenPath),Se=hn(be=>be.removeOpenPathsByPrefix),we=hn(be=>be.toggleExpandedPath),ye=hn(be=>be.collapseAllExpandedPaths),Ae=Pe(be=>a?be.contextPanelByDirectory[a]?.tabs??J:J),pe=c.useMemo(()=>new Set(Ae.map(be=>be.mode==="file"?be.targetPath:null).filter(be=>typeof be=="string"&&be.length>0).map(be=>as(be))),[Ae]),[O,Q]=c.useState(null),[le,H]=c.useState(null),[me,ge]=c.useState(""),[oe,de]=c.useState(!1),_=!!r.writeFile,B=!!r.createDirectory,he=!!r.rename,ve=!!r.delete,Re=!!r.revealPath,ce=!!r.uploadFile,se=c.useMemo(()=>({canRename:he,canCreateFile:_,canCreateFolder:B,canDelete:ve,canReveal:Re}),[he,_,B,ve,Re]),q=c.useCallback(be=>{r.revealPath&&r.revealPath(be).catch(()=>{Le.error(n("sidebarFilesTree.toast.revealFailed"))})},[r,n]),z=c.useCallback((be,Ge)=>{Q(be),H(Ge),ge(be==="rename"&&Ge.name||""),de(!1)},[]),ee=c.useCallback((be,Ge)=>{const ut=Ge.filter(Y=>Y&&typeof Y.name=="string"&&Y.name.length>0).filter(Y=>u||!Y.name.startsWith(".")).filter(Y=>h||!h1(Y.name)).map(Y=>{const G=Y.name,Z=as(Y.path||""),je=Z?f1(Z)?Z:as(`${be}/${Z}`):as(`${be}/${G}`),Ie=Y.isDirectory?"directory":"file",Ve=Ie==="file"&&G.includes(".")?G.split(".").pop()?.toLowerCase():void 0;return{name:G,path:je,type:Ie,extension:Ve}});return c1(ut)},[h,u]),ae=c.useCallback(async(be,Ge,ut=!1)=>{if(!e.current||Ge?.())return;const Y=as(be.trim());if(!Y||!ut&&N.current.has(Y))return;const G=qt();return R.run(Y,async Z=>{const je=()=>!Z()||qt()!==G;try{const Ie=r.listDirectory?(await r.listDirectory(Y)).entries:await Cn.listLocalDirectory(Y);if(je())return;const Ve=ee(Y,Ie);N.current=new Set(N.current),N.current.add(Y),W(Je=>{if(!Je[Y])return Je;const it={...Je};return delete it[Y],it}),K(Je=>Je[Y]&&Ox(Je[Y],Ve)?Je:{...Je,[Y]:Ve})}catch(Ie){if(je())return;const Ve=Ie instanceof Error?Ie.message:String(Ie??"");console.error("Failed to load sidebar directory:",Ie),W(Je=>({...Je,[Y]:Ve}))}},ut)},[R,r,ee]),Ne=c.useCallback(async()=>{if(!a)return;E.current?.abort();const be=new AbortController;E.current=be,R.clear();try{const ut=(hn.getState().byRoot[a]?.expandedPaths??[]).map(Z=>as(Z)).filter(Z=>!!Z&&Z!==a&&Z.startsWith(`${a}/`)),Y=[a,...ut];N.current=new Set(N.current);for(const Z of Y)N.current.delete(Z);W(Z=>{if(Object.keys(Z).length===0)return Z;const je={...Z};let Ie=!1;for(const Ve of Y)Ve in je&&(delete je[Ve],Ie=!0);return Ie?je:Z});const G=()=>be.signal.aborted;await ae(a,G);for(let Z=0;Z<ut.length&&!be.signal.aborted;Z+=3){const je=ut.slice(Z,Z+3);await Promise.all(je.map(Ie=>ae(Ie,G)))}}catch(Ge){if(be.signal.aborted)return;console.error("Failed to refresh sidebar tree:",Ge)}finally{E.current===be&&(E.current=null)}},[R,ae,a]),Ce=c.useCallback(async be=>{if(!be){await Ne();return}const Ge=as(be);N.current=new Set(N.current),N.current.delete(Ge),await ae(Ge,void 0,!0)},[ae,Ne]);c.useEffect(()=>{a&&(E.current?.abort(),N.current=new Set,R.clear(),W({}),K(be=>Object.keys(be).length===0?be:{}),ae(a))},[R,ae,a,u,h]),c.useEffect(()=>{if(!t||!a||re.length===0)return;const be=re.map(Y=>as(Y)).filter(Y=>!!Y&&Y!==a&&Y.startsWith(`${a}/`)&&!N.current.has(Y)&&!R.has(Y)).sort((Y,G)=>Y.split("/").length-G.split("/").length);if(be.length===0)return;let Ge=!1;const ut=()=>Ge;return(async()=>{for(let Y=0;Y<be.length&&!Ge;Y+=3){const G=be.slice(Y,Y+3);await Promise.all(G.map(Z=>ae(Z,ut)))}})(),()=>{Ge=!0}},[R,re,ae,a,t]);const We=c.useRef(t);c.useEffect(()=>{const be=t&&!We.current;We.current=t,be&&Ne()},[Ne,t]),c.useEffect(()=>{if(!t)return;if(!l){S([]),C(!1);return}const be=y.trim();if(!be){S([]),C(!1);return}let Ge=!1;return C(!0),f(l,be,150,{includeHidden:u,respectGitignore:!h,type:"file"}).then(ut=>{if(Ge)return;const G=ut.filter(Z=>h||!p1(Z.path)).map(Z=>({name:Z.name,path:as(Z.path),type:"file",extension:Z.extension,relativePath:Z.relativePath}));S(G)}).catch(()=>{Ge||S([])}).finally(()=>{Ge||C(!1)}),()=>{Ge=!0}},[l,y,f,u,h,t]);const Ee=c.useMemo(()=>{const be=new Map;if(!b?.files)return be;for(const Ge of b.files)Ge.index==="A"||Ge.working_dir==="?"?be.set(Ge.path,"git-added"):Ge.index==="D"?be.set(Ge.path,"git-deleted"):(Ge.index==="M"||Ge.working_dir==="M")&&be.set(Ge.path,"git-modified");return be},[b]),xe=c.useMemo(()=>{const be=new Map;if(!b?.files||!a)return be;for(const Ge of b.files){const ut=Ge.index==="M"||Ge.working_dir==="M",Y=Ge.index==="A"||Ge.working_dir==="?";if(!ut&&!Y)continue;const G=Ge.path.split("/");if(G.length<=1)continue;let Z=a;for(let je=0;je<G.length-1;je++){Z=`${Z}/${G[je]}`;let Ie=be.get(Z);Ie||(Ie={modified:0,added:0},be.set(Z,Ie)),ut&&Ie.modified++,Y&&Ie.added++}}return be},[b,a]),$e=c.useCallback(be=>{if(pe.has(be))return"open";if(Ee.size===0)return null;const Ge=be.startsWith(a+"/")?be.slice(a.length+1):be;return Ee.get(Ge)??null},[pe,Ee,a]),V=c.useCallback(be=>{if(xe.size===0)return null;const Ge=xe.get(be);return Ge&&Ge.modified+Ge.added>0?Ge:null},[xe]),De=c.useCallback(async be=>{if(!a)return;const Ge=await uf(r,be.path,{directory:a});if(!Ge.ok){Le.error(ff(Ge.reason));return}te(a,be.path),ue(a,be.path),x(a,be.path)},[ue,r,x,a,te]),Fe=c.useCallback(async be=>{const Ge=as(be);a&&(we(a,Ge),N.current.has(Ge)||await ae(Ge))},[ae,a,we]),_e=c.useCallback(async(be,Ge,ut=!1)=>{const Y=r.uploadFile;if(!Y||Ge.length===0||T.current||!a)return;const G=a,Z=qt();T.current=!0,I(!0),j(be),ut&&P(null);const je=[];for(let Ye=0;Ye<Ge.length;Ye+=fc){const vt=Ge.slice(Ye,Ye+fc),Ue=await Promise.all(vt.map(async Pt=>{const ke=mc(Pt);if(!ke||qt()!==Z)return"failed";try{return(await Y(as(`${be}/${ke}`),Pt,{directory:G,overwrite:ut})).success?"uploaded":"failed"}catch(xt){return!ut&&Um(xt)&&xt.reason==="already-exists"?"conflict":"failed"}}));je.push(...Ue)}const Ie=je.filter(Ye=>Ye==="uploaded").length,Ve=je.filter(Ye=>Ye==="failed").length,Je=Ge.filter((Ye,vt)=>je[vt]==="conflict"),it=Ge.flatMap((Ye,vt)=>{const Ue=mc(Ye);return je[vt]==="uploaded"&&Ue?[as(`${be}/${Ue}`)]:[]}),at=L.current===G&&qt()===Z;try{it.length>0&&Bx({runtimeKey:Z,paths:it}),Ie>0&&at&&await Ce(be),Ie>0&&Le.success(n(Je.length>0?"sidebarFilesTree.toast.uploadedWithoutConflicts":"sidebarFilesTree.toast.uploaded")),Ve>0&&Le.error(n("sidebarFilesTree.toast.uploadFailed")),Je.length>0&&at&&P({directory:be,files:Je,runtimeKey:Z,workspaceRoot:G})}finally{T.current=!1,I(!1),j(null)}},[r.uploadFile,Ce,a,n]),rt=c.useCallback((be,Ge)=>{const ut=l1(Ge);ut.length!==0&&_e(be,ut)},[_e]),ct=c.useCallback(be=>{!ce||T.current||!a||!xr(be.dataTransfer)||(be.preventDefault(),be.dataTransfer.dropEffect="copy",j(a))},[ce,a]),et=c.useCallback(be=>{xr(be.dataTransfer)&&(be.relatedTarget instanceof Node&&be.currentTarget.contains(be.relatedTarget)||j(null))},[]),pt=c.useCallback(be=>{!ce||T.current||!a||!xr(be.dataTransfer)||(be.preventDefault(),rt(a,be.dataTransfer))},[ce,rt,a]),kt=c.useCallback(async be=>{if(be?.preventDefault(),!le||!O)return;de(!0);const Ge=()=>de(!1),ut=()=>Q(null);if(O==="createFile"){if(!me.trim()){Le.error(n("sidebarFilesTree.toast.filenameRequired")),Ge();return}if(!r.writeFile){Le.error(n("sidebarFilesTree.toast.writeNotSupported")),Ge();return}const Y=le.path,G=Y?`${Y}/`:"",Z=as(`${G}${me.trim()}`);await r.writeFile(Z,"").then(async je=>{je.success&&(Le.success(n("sidebarFilesTree.toast.fileCreated")),await Ce(Y)),ut()}).catch(()=>Le.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Ge);return}if(O==="createFolder"){if(!me.trim()){Le.error(n("sidebarFilesTree.toast.folderNameRequired")),Ge();return}const Y=le.path,G=Y?`${Y}/`:"",Z=as(`${G}${me.trim()}`);await r.createDirectory(Z).then(async je=>{je.success&&(Le.success(n("sidebarFilesTree.toast.folderCreated")),await Ce(Y)),ut()}).catch(()=>Le.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Ge);return}if(O==="rename"){if(!me.trim()){Le.error(n("sidebarFilesTree.toast.nameRequired")),Ge();return}if(!r.rename){Le.error(n("sidebarFilesTree.toast.renameNotSupported")),Ge();return}const Y=le.path,G=Y.split("/").slice(0,-1).join("/"),Z=G?`${G}/`:"",je=as(`${Z}${me.trim()}`);await r.rename(Y,je).then(async Ie=>{Ie.success&&(Le.success(n("sidebarFilesTree.toast.renamedSuccessfully")),await Ce(G),a&&Se(a,Y),(ne===Y||ne&&ne.startsWith(`${Y}/`))&&te(a,null)),ut()}).catch(()=>Le.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Ge);return}if(O==="delete"){if(!r.delete){Le.error(n("sidebarFilesTree.toast.deleteNotSupported")),Ge();return}const Y=le.path,G=Y.split("/").slice(0,-1).join("/");await r.delete(Y).then(async Z=>{Z.success&&(Le.success(n("sidebarFilesTree.toast.deletedSuccessfully")),await Ce(G),a&&Se(a,Y),(ne===Y||ne&&ne.startsWith(Y+"/"))&&te(a,null)),ut()}).catch(()=>Le.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Ge);return}Ge()},[O,le,me,r,Ce,Se,a,ne,te,n]);function wt(be,Ge){const ut=$[be]??[];return ut.map((Y,G)=>{const Z=Y.type==="directory",je=Z&&fe.has(Y.path),Ie=ne===Y.path,Ve=G===ut.length-1;return s.jsxs("li",{className:"relative",children:[Ge>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),Ve&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-sidebar/50"})]}),s.jsx(v1,{node:Y,root:a,isExpanded:je,isActive:Ie,isBrowserClient:o,status:Z?void 0:$e(Y.path),badge:Z?V(Y.path):void 0,isDropTarget:Z&&k===Y.path,canUpload:ce&&!D,permissions:se,downloadFile:r.downloadFile,onSelect:De,onToggle:Fe,onRevealPath:q,onOpenDialog:z,onSetDropTarget:j,onDropFiles:rt}),Z&&je&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[F[Y.path]?s.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:F[Y.path],children:F[Y.path]}),s.jsxs(dt,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{Ce(Y.path)},children:[s.jsx(M,{name:"refresh",className:"h-3.5 w-3.5"}),n("sidebarFilesTree.actions.refreshTitle")]})]}):null,wt(Y.path,Ge+1)]})]},Y.path)})}const Xe=!!(a&&$[a]),yt=a?F[a]:null,Rt=k?d1(a,k):"";return s.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex flex-col gap-2 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[_&&s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(dt,{variant:"ghost",size:"sm",onClick:()=>z("createFile",{path:l,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.newFileTitle"),"aria-label":n("sidebarFilesTree.actions.newFileTitle"),children:s.jsx(M,{name:"file-add",className:"h-4 w-4"})})})}),s.jsx(Dt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.newFileTitle")})]}),B&&s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(dt,{variant:"ghost",size:"sm",onClick:()=>z("createFolder",{path:l,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.newFolderTitle"),"aria-label":n("sidebarFilesTree.actions.newFolderTitle"),children:s.jsx(M,{name:"folder-add",className:"h-4 w-4"})})})}),s.jsx(Dt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.newFolderTitle")})]}),s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(dt,{variant:"ghost",size:"sm",onClick:()=>{Ne()},className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.refreshTitle"),"aria-label":n("sidebarFilesTree.actions.refreshTitle"),children:s.jsx(M,{name:"refresh",className:"h-4 w-4"})})})}),s.jsx(Dt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.refreshTitle")})]}),s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(dt,{variant:"ghost",size:"sm",onClick:()=>{a&&ye(a)},className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.collapseAllTitle"),"aria-label":n("sidebarFilesTree.actions.collapseAllTitle"),children:s.jsx(M,{name:"collapse-vertical",className:"h-4 w-4"})})})}),s.jsx(Dt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.collapseAllTitle")})]})]}),s.jsxs("div",{className:"relative min-w-0",children:[s.jsx(M,{name:"search",className:"pointer-events-none absolute left-2 top-2 h-4 w-4 text-muted-foreground"}),s.jsx(An,{ref:m,value:w,onChange:be=>v(be.target.value),placeholder:n("sidebarFilesTree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),w.trim().length>0?s.jsx("button",{type:"button","aria-label":n("sidebarFilesTree.search.clearAria"),className:"absolute right-2 top-2 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{v(""),m.current?.focus()},children:s.jsx(M,{name:"close",className:"h-4 w-4"})}):null]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx(yn,{outerClassName:"h-full min-h-0",className:Oe("p-2",k===a&&"bg-interactive-selection/10"),onDragEnter:ct,onDragOver:ct,onDragLeave:et,onDrop:pt,children:s.jsx("ul",{className:"flex flex-col",children:g?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(M,{name:"loader-4",className:"h-4 w-4 animate-spin"}),n("sidebarFilesTree.state.searching")]}):p.length>0?p.map(be=>{const Ge=ne===be.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>De(be),draggable:!0,onDragStart:ut=>{mf(ut);const Y=be.relativePath||Ga(a??"",be.path);!Y||Y==="."||(ut.dataTransfer.setData("application/x-openchamber-file-path",Y),ut.dataTransfer.effectAllowed="copy")},onDragEnd:ut=>{hf(ut)&&De(be)},className:Oe("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",Ge?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),title:be.path,children:[pf(be.path,be.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},children:be.relativePath??be.path})]})},be.path)}):yt?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{children:yt}),s.jsxs(dt,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{Ne()},children:[s.jsx(M,{name:"refresh",className:"h-3.5 w-3.5"}),n("sidebarFilesTree.actions.refreshTitle")]})]}):Xe&&a?wt(a,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:n("sidebarFilesTree.state.loading")})})}),k?s.jsxs("div",{className:"pointer-events-none absolute left-2 right-2 top-2 z-50 flex items-center gap-2 rounded-md border border-primary bg-background/95 px-2 py-1.5 shadow-sm",children:[s.jsx(M,{name:D?"loader-4":"folder-received",className:Oe("size-4 flex-shrink-0",D&&"animate-spin")}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:Rt,children:n(D?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:Rt})})]}):null]}),s.jsx(ys,{open:!!A,onOpenChange:be=>!be&&P(null),children:s.jsxs(ws,{children:[s.jsxs(Vs,{children:[s.jsx(Ps,{children:n("sidebarFilesTree.dialog.uploadConflicts.title")}),s.jsx(Is,{children:n("sidebarFilesTree.dialog.uploadConflicts.description",{path:A?.directory??""})})]}),s.jsx(yn,{outerClassName:"max-h-52",className:"flex flex-col gap-1 pr-2",children:A?.files.map((be,Ge)=>s.jsx("div",{className:"truncate rounded-md bg-muted px-2 py-1 typography-meta",title:be.name,children:be.name},`${be.name}-${be.size}-${Ge}`))}),s.jsxs(bn,{children:[s.jsx(dt,{variant:"outline",onClick:()=>P(null),disabled:D,children:n("sidebarFilesTree.dialog.cancel")}),s.jsx(dt,{onClick:()=>{if(A){if(A.runtimeKey!==qt()||A.workspaceRoot!==a){P(null);return}_e(A.directory,A.files,!0)}},disabled:D,children:n("sidebarFilesTree.dialog.uploadConflicts.replace")})]})]})}),s.jsx(ys,{open:!!O,onOpenChange:be=>!be&&Q(null),children:s.jsxs(ws,{children:[s.jsxs(Vs,{children:[s.jsxs(Ps,{children:[O==="createFile"&&n("sidebarFilesTree.dialog.createFile.title"),O==="createFolder"&&n("sidebarFilesTree.dialog.createFolder.title"),O==="rename"&&n("sidebarFilesTree.dialog.rename.title"),O==="delete"&&n("sidebarFilesTree.dialog.delete.title")]}),s.jsxs(Is,{children:[O==="createFile"&&n("sidebarFilesTree.dialog.createFile.description",{path:le?.path??n("sidebarFilesTree.dialog.rootFallback")}),O==="createFolder"&&n("sidebarFilesTree.dialog.createFolder.description",{path:le?.path??n("sidebarFilesTree.dialog.rootFallback")}),O==="rename"&&n("sidebarFilesTree.dialog.rename.description",{name:le?.name??""}),O==="delete"&&n("sidebarFilesTree.dialog.delete.description",{name:le?.name??""})]})]}),O!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(An,{value:me,onChange:be=>ge(be.target.value),placeholder:n(O==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:be=>{be.key==="Enter"&&kt()},autoFocus:!0})}),s.jsxs(bn,{children:[s.jsx(dt,{variant:"outline",onClick:()=>Q(null),disabled:oe,children:n("sidebarFilesTree.dialog.cancel")}),s.jsx(dt,{variant:O==="delete"?"destructive":"default",onClick:()=>{kt()},disabled:oe||O!=="delete"&&!me.trim(),children:oe?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):n(O==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})})]})};function k1(t){return t.runtimeKey}const hc=60,C1=t=>{try{return new URL(t).origin}catch{return""}},yi=new Set,gf=to()((t,e)=>({byOrigin:{},resolve:(n,r)=>{const i=C1(n);!i||!r||e().byOrigin[i]||yi.has(i)||(yi.add(i),gr("desktop_browser_fetch_favicon",{url:r}).then(o=>{const l=typeof o?.dataUrl=="string"?o.dataUrl:"";l&&t(a=>{const d={...a.byOrigin,[i]:l},u=Object.keys(d);if(u.length<=hc)return{byOrigin:d};for(const h of u.slice(0,u.length-hc))delete d[h];return{byOrigin:d}})}).catch(()=>{}).finally(()=>{yi.delete(i)}))}})),Ya=t=>t,sa=t=>{const e=Ya(t).type;return typeof e=="string"?e:""},N1=t=>{const e=Ya(t).tool;return typeof e=="string"?e:""},A1=t=>{const e=Ya(t).text;return typeof e=="string"?e:""},D1=t=>{const e=sa(t);return e==="tool"?N1(t).trim().toLowerCase()||"tool":e||"unknown"},P1=t=>{if(t.length===0)return"";const e=[];for(const n of t){const r=D1(n);e.includes(r)||e.push(r)}return e.join(" + ")},I1=t=>t.replace(/\s+/g," ").trim(),T1=t=>{for(const n of t)if(sa(n)==="text"){const r=I1(A1(n));if(r.length===0)continue;return r}const e=t.filter(n=>sa(n)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},E1=(t,e,n)=>`${n(t)} / ${n(e)}`,R1=t=>{if(t==="12h")return!0;if(t==="24h")return!1},M1=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const n=R1(e);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:n===!1?"2-digit":"numeric",minute:"2-digit",...n===void 0?{}:{hour12:n}})},na={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},So={user:0,assistant:0,tool:0,other:0},Bn=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,pc=t=>{const e=t.info.tokens,n=e!==void 0?e:t.parts.find(h=>h.tokens!==void 0)?.tokens;if(typeof n=="number")return{...na,total:Bn(n)};if(!n||typeof n!="object")return na;const r=n,i=Bn(r.input),o=Bn(r.output),l=Bn(r.reasoning),a=Bn(r.cache?.read),d=Bn(r.cache?.write),u=Bn(r.total);return{input:i,output:o,reasoning:l,cacheRead:a,cacheWrite:d,total:u>0?u:i+o+l+a+d}},O1=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},Us=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,n)=>e+Us(n),0):t&&typeof t=="object"?Object.values(t).reduce((e,n)=>e+Us(n),0):0,B1=(t,e)=>{const n=t,r=typeof n.type=="string"?n.type:"";if(r==="reasoning")return{...So,assistant:Us(n.text)+Us(n.content)};const i=O1(n.text,n.content,n.value,n.source?.value,n.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:Us(n.input)+Us(n.output)+Us(n.error)+Us(n.call?.input)+Us(n.call?.output)+Us(n.call?.error)+Us(n.raw)+Math.round(Us(n.metadata)*.25)+Math.round(Us(n.state)*.1),other:0}:e==="user"?{user:i.length,assistant:0,tool:0,other:0}:e==="assistant"?{user:0,assistant:i.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:i.length}},gc=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),F1=t=>{const e=Zr(t.info);return e.isUser?"user":e.role==="assistant"?"assistant":e.role==="tool"?"tool":"other"},_1=(t,e)=>{if(t.length===0)return{...So};const n=t.reduce((r,i)=>{const o=F1(i);let l={...So};for(const a of i.parts)l=gc(l,B1(a,o));return gc(r,l)},{...So});return n.user+=e.length,{user:Math.ceil(n.user/4),assistant:Math.ceil(n.assistant/4),tool:Math.ceil(n.tool/4),other:Math.ceil(n.other/4)}},qn=t=>t.toLocaleString(gu()),L1=(t,e)=>!t||!Number.isFinite(t)?"-":fu(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),$1=(t,e,n)=>{const r=t.find(o=>o.id===e),i=r?.models?.find(o=>o.id===n);return{providerName:r?.name||e||"-",modelName:i?.name||n||"-",contextLimit:typeof i?.limit?.context=="number"?i.limit.context:null}},z1=()=>{const t=Ze.c(209),{t:e}=jt(),n=Pe(W1);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},t[0]=r):r=t[0];const[i,o]=c.useState(r),[l,a]=c.useState(null),d=c.useRef(null),u=tt(K1),h=tt(V1),f=bu(h??void 0),x=Pp(u??"",h??void 0),b=Gt(U1);let w;t[1]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),o(H1),a(null)},t[1]=w):w=t[1];let v;t[2]!==h||t[3]!==u?(v=[h,u],t[2]=h,t[3]=u,t[4]=v):v=t[4],c.useEffect(w,v);let y,m;t[5]===Symbol.for("react.memo_cache_sentinel")?(y=()=>()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)},m=[],t[5]=y,t[6]=m):(y=t[5],m=t[6]),c.useEffect(y,m);let p;t[7]===Symbol.for("react.memo_cache_sentinel")?(p=async(qe,ze)=>{(await gn(ze)).ok?(a(qe),d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{a(Be=>Be===qe?null:Be),d.current=null},2e3)):a(null)},t[7]=p):p=t[7];const S=p;let g;t[8]!==u||t[9]!==f?(g=u?f.find(qe=>qe.id===u)??null:null,t[8]=u,t[9]=f,t[10]=g):g=t[10];const C=g;let k,j,D,I,A,P,T;if(t[11]!==x){k=x.filter(G1),T=x.filter(q1);const qe=Ip(x.map(Y1));D=qe?x[qe.index]??null:null,I=qe?.state==="compacted";let ze;t[19]!==D?(P=D?pc(D):na,ze=Tp({input:P.input,cache:{read:P.cacheRead,write:P.cacheWrite}}),t[19]=D,t[20]=ze,t[21]=P):(ze=t[20],P=t[21]),j=ze,A=k.reduce(Q1,0),t[11]=x,t[12]=k,t[13]=j,t[14]=D,t[15]=I,t[16]=A,t[17]=P,t[18]=T}else k=t[12],j=t[13],D=t[14],I=t[15],A=t[16],P=t[17],T=t[18];const L=A,$=D?.info??null,K=b,F=$?.providerID||"",W=$?.modelID||"";let N;t[22]!==W||t[23]!==K||t[24]!==F?(N=$1(K,F,W),t[22]=W,t[23]=K,t[24]=F,t[25]=N):N=t[25];const R=N,E=R.contextLimit,X=I?null:E&&E>0?Math.min(999,P.total/E*100):0;let J;if(t[26]!==x){const qe=[...x].reverse().find(X1)?.info?.system||"";J=_1(x,qe),t[26]=x,t[27]=J}else J=t[27];const re=J,fe=re.user,ne=re.assistant,te=re.tool,ue=Math.max(0,P.input-fe-ne-te),Se=fe+ne+te+ue,we=x[0]?.info?.time?.created,ye=x.length>0?x[x.length-1]?.info?.time?.created:null;let Ae;t[28]!==C?.title||t[29]!==e?(Ae=C?.title||e("contextSidebar.session.untitled"),t[28]=C?.title,t[29]=e,t[30]=Ae):Ae=t[30];const pe=C?.time?.created??we??null,O=ye??C?.time?.created??null;let Q;t[31]!==ne||t[32]!==ue||t[33]!==te||t[34]!==fe?(Q={user:fe,assistant:ne,tool:te,other:ue},t[31]=ne,t[32]=ue,t[33]=te,t[34]=fe,t[35]=Q):Q=t[35];let le;t[36]!==k.length||t[37]!==Se||t[38]!==j||t[39]!==E||t[40]!==R||t[41]!==x.length||t[42]!==Ae||t[43]!==pe||t[44]!==O||t[45]!==Q||t[46]!==P||t[47]!==L||t[48]!==X||t[49]!==T.length?(le={sessionTitle:Ae,messagesCount:x.length,userMessagesCount:T.length,assistantMessagesCount:k.length,createdAt:pe,lastActivityAt:O,providerModel:R,tokenBreakdown:P,usagePercent:X,cacheHitRate:j,totalAssistantCost:L,contextLimit:E,breakdown:Q,breakdownTotal:Se},t[36]=k.length,t[37]=Se,t[38]=j,t[39]=E,t[40]=R,t[41]=x.length,t[42]=Ae,t[43]=pe,t[44]=O,t[45]=Q,t[46]=P,t[47]=L,t[48]=X,t[49]=T.length,t[50]=le):le=t[50];const H=le;if(!u){let qe;t[51]!==e?(qe=e("contextSidebar.empty.openSession"),t[51]=e,t[52]=qe):qe=t[52];let ze;return t[53]!==qe?(ze=s.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:qe}),t[53]=qe,t[54]=ze):ze=t[54],ze}let me;t[55]!==e?(me=e("contextSidebar.breakdown.user"),t[55]=e,t[56]=me):me=t[56];let ge;t[57]!==me||t[58]!==H.breakdown.user?(ge={key:"user",label:me,value:H.breakdown.user,color:"var(--status-success)"},t[57]=me,t[58]=H.breakdown.user,t[59]=ge):ge=t[59];let oe;t[60]!==e?(oe=e("contextSidebar.breakdown.assistant"),t[60]=e,t[61]=oe):oe=t[61];let de;t[62]!==oe||t[63]!==H.breakdown.assistant?(de={key:"assistant",label:oe,value:H.breakdown.assistant,color:"var(--primary-base)"},t[62]=oe,t[63]=H.breakdown.assistant,t[64]=de):de=t[64];let _;t[65]!==e?(_=e("contextSidebar.breakdown.toolCalls"),t[65]=e,t[66]=_):_=t[66];let B;t[67]!==_||t[68]!==H.breakdown.tool?(B={key:"tool",label:_,value:H.breakdown.tool,color:"var(--status-warning)"},t[67]=_,t[68]=H.breakdown.tool,t[69]=B):B=t[69];let he;t[70]!==e?(he=e("contextSidebar.breakdown.other"),t[70]=e,t[71]=he):he=t[71];let ve;t[72]!==he||t[73]!==H.breakdown.other?(ve={key:"other",label:he,value:H.breakdown.other,color:"var(--surface-muted-foreground)"},t[72]=he,t[73]=H.breakdown.other,t[74]=ve):ve=t[74];let Re;t[75]!==ge||t[76]!==de||t[77]!==B||t[78]!==ve?(Re=[ge,de,B,ve],t[75]=ge,t[76]=de,t[77]=B,t[78]=ve,t[79]=Re):Re=t[79];const ce=Re;let se;t[80]!==H.sessionTitle?(se=s.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:H.sessionTitle}),t[80]=H.sessionTitle,t[81]=se):se=t[81];let q;t[82]!==H.providerModel.modelName||t[83]!==H.providerModel.providerName?(q=s.jsxs("span",{children:[H.providerModel.providerName," / ",H.providerModel.modelName]}),t[82]=H.providerModel.modelName,t[83]=H.providerModel.providerName,t[84]=q):q=t[84];let z;t[85]!==n||t[86]!==H.createdAt?(z=H.createdAt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsx("span",{children:L1(H.createdAt,n)})]}),t[85]=n,t[86]=H.createdAt,t[87]=z):z=t[87];let ee;t[88]!==q||t[89]!==z?(ee=s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground/70",children:[q,z]}),t[88]=q,t[89]=z,t[90]=ee):ee=t[90];let ae;t[91]!==se||t[92]!==ee?(ae=s.jsxs("div",{className:"mb-6",children:[se,ee]}),t[91]=se,t[92]=ee,t[93]=ae):ae=t[93];let Ne;t[94]!==e?(Ne=e("contextSidebar.section.context"),t[94]=e,t[95]=Ne):Ne=t[95];let Ce;t[96]!==Ne?(Ce=s.jsx("span",{className:"typography-micro text-muted-foreground",children:Ne}),t[96]=Ne,t[97]=Ce):Ce=t[97];let We;t[98]!==H.tokenBreakdown.total||t[99]!==H.usagePercent?(We=H.usagePercent===null?"—":qn(H.tokenBreakdown.total),t[98]=H.tokenBreakdown.total,t[99]=H.usagePercent,t[100]=We):We=t[100];let Ee;t[101]!==H.contextLimit?(Ee=H.contextLimit?` / ${qn(H.contextLimit)}`:"",t[101]=H.contextLimit,t[102]=Ee):Ee=t[102];let xe;t[103]!==We||t[104]!==Ee?(xe=s.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[We,Ee]}),t[103]=We,t[104]=Ee,t[105]=xe):xe=t[105];let $e;t[106]!==Ce||t[107]!==xe?($e=s.jsxs("div",{className:"flex items-baseline justify-between",children:[Ce,xe]}),t[106]=Ce,t[107]=xe,t[108]=$e):$e=t[108];let V;t[109]!==H.usagePercent?(V=H.usagePercent!==null&&H.usagePercent>0&&s.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,H.usagePercent)}%`,backgroundColor:H.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[109]=H.usagePercent,t[110]=V):V=t[110];let De;t[111]!==V?(De=s.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:V}),t[111]=V,t[112]=De):De=t[112];let Fe;t[113]!==e||t[114]!==H.usagePercent?(Fe=H.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:H.usagePercent.toFixed(1)}),t[113]=e,t[114]=H.usagePercent,t[115]=Fe):Fe=t[115];let _e;t[116]!==Fe?(_e=s.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:Fe}),t[116]=Fe,t[117]=_e):_e=t[117];let rt;t[118]!==$e||t[119]!==De||t[120]!==_e?(rt=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[$e,De,_e]}),t[118]=$e,t[119]=De,t[120]=_e,t[121]=rt):rt=t[121];let ct;t[122]!==e?(ct=e("contextSidebar.stats.messages"),t[122]=e,t[123]=ct):ct=t[123];let et;t[124]!==H.messagesCount?(et=qn(H.messagesCount),t[124]=H.messagesCount,t[125]=et):et=t[125];let pt;t[126]!==ct||t[127]!==et?(pt={label:ct,value:et},t[126]=ct,t[127]=et,t[128]=pt):pt=t[128];let kt;t[129]!==e?(kt=e("contextSidebar.stats.user"),t[129]=e,t[130]=kt):kt=t[130];let wt;t[131]!==H.userMessagesCount?(wt=qn(H.userMessagesCount),t[131]=H.userMessagesCount,t[132]=wt):wt=t[132];let Xe;t[133]!==kt||t[134]!==wt?(Xe={label:kt,value:wt},t[133]=kt,t[134]=wt,t[135]=Xe):Xe=t[135];let yt;t[136]!==e?(yt=e("contextSidebar.stats.assistant"),t[136]=e,t[137]=yt):yt=t[137];let Rt;t[138]!==H.assistantMessagesCount?(Rt=qn(H.assistantMessagesCount),t[138]=H.assistantMessagesCount,t[139]=Rt):Rt=t[139];let be;t[140]!==yt||t[141]!==Rt?(be={label:yt,value:Rt},t[140]=yt,t[141]=Rt,t[142]=be):be=t[142];let Ge;t[143]!==e?(Ge=e("contextSidebar.stats.cost"),t[143]=e,t[144]=Ge):Ge=t[144];let ut;t[145]!==H.totalAssistantCost?(ut=Ix(H.totalAssistantCost),t[145]=H.totalAssistantCost,t[146]=ut):ut=t[146];let Y;t[147]!==Ge||t[148]!==ut?(Y={label:Ge,value:ut},t[147]=Ge,t[148]=ut,t[149]=Y):Y=t[149];let G;t[150]!==pt||t[151]!==Xe||t[152]!==be||t[153]!==Y?(G=[pt,Xe,be,Y],t[150]=pt,t[151]=Xe,t[152]=be,t[153]=Y,t[154]=G):G=t[154];const Z=G;let je;t[155]!==Z?(je=s.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:Z.map(J1)}),t[155]=Z,t[156]=je):je=t[156];let Ie;t[157]!==e?(Ie=e("contextSidebar.section.lastAssistantMessage"),t[157]=e,t[158]=Ie):Ie=t[158];let Ve;t[159]!==Ie?(Ve=s.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:Ie}),t[159]=Ie,t[160]=Ve):Ve=t[160];let Je;t[161]!==e||t[162]!==H.cacheHitRate.hasInput||t[163]!==H.cacheHitRate.percent||t[164]!==H.tokenBreakdown.cacheRead||t[165]!==H.tokenBreakdown.cacheWrite||t[166]!==H.tokenBreakdown.input||t[167]!==H.tokenBreakdown.output||t[168]!==H.tokenBreakdown.reasoning?(Je=s.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:H.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:H.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:H.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:H.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:H.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:H.cacheHitRate.hasInput?H.cacheHitRate.percent:null,format:"percent"}].map(Z1)}),t[161]=e,t[162]=H.cacheHitRate.hasInput,t[163]=H.cacheHitRate.percent,t[164]=H.tokenBreakdown.cacheRead,t[165]=H.tokenBreakdown.cacheWrite,t[166]=H.tokenBreakdown.input,t[167]=H.tokenBreakdown.output,t[168]=H.tokenBreakdown.reasoning,t[169]=Je):Je=t[169];let it;t[170]!==Ve||t[171]!==Je?(it=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[Ve,Je]}),t[170]=Ve,t[171]=Je,t[172]=it):it=t[172];let at;t[173]!==ce||t[174]!==H.breakdownTotal?(at=s.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:ce.map(qe=>qe.value<=0||H.breakdownTotal<=0?null:s.jsx("div",{style:{width:`${qe.value/H.breakdownTotal*100}%`,backgroundColor:qe.color}},qe.key))}),t[173]=ce,t[174]=H.breakdownTotal,t[175]=at):at=t[175];let Ye;t[176]!==ce||t[177]!==H.breakdownTotal?(Ye=s.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:ce.map(qe=>{const ze=H.breakdownTotal>0?qe.value/H.breakdownTotal*100:0;return s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:qe.color}}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[qe.label," ",s.jsxs("span",{className:"tabular-nums",children:[ze.toFixed(0),"%"]})]})]},qe.key)})}),t[176]=ce,t[177]=H.breakdownTotal,t[178]=Ye):Ye=t[178];let vt;t[179]!==at||t[180]!==Ye?(vt=s.jsxs("div",{className:"mb-6",children:[at,Ye]}),t[179]=at,t[180]=Ye,t[181]=vt):vt=t[181];let Ue;t[182]!==e?(Ue=e("contextSidebar.section.rawMessages"),t[182]=e,t[183]=Ue):Ue=t[183];let Pt;t[184]!==Ue?(Pt=s.jsx("div",{className:"typography-micro text-muted-foreground",children:Ue}),t[184]=Ue,t[185]=Pt):Pt=t[185];let ke;if(t[186]!==l||t[187]!==i||t[188]!==x||t[189]!==e||t[190]!==n){let qe;t[192]!==l||t[193]!==i||t[194]!==e||t[195]!==n?(qe=ze=>{const Be=Zr(ze.info).role,Ke=Be==="assistant",He=Be==="user",nt=i[ze.info.id]===!0,St=l===ze.info.id,Lt=ze.info.time?.created??null,Ut=P1(ze.parts),Bt=Ke?pc({info:ze.info,parts:ze.parts}):null,zt=He?T1(ze.parts):"",_t=M1(Lt,n),Yt=Ut||"—",Zt=Bt?E1(Bt.input,Bt.output,qn):"",es=Be||"unknown",Vt=Ut?`${es}: ${Ut}`:es,It=nt?JSON.stringify({info:ze.info,parts:ze.parts},null,2):"";return s.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[s.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-left hover:bg-[var(--interactive-hover)]","aria-expanded":nt,onClick:()=>{o(bt=>({...bt,[ze.info.id]:bt[ze.info.id]!==!0}))},children:s.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:Ke?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[He?s.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",zt]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:Ke?Yt:Vt}),Ke&&s.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:Zt})]}),s.jsx("span",{className:"text-right text-muted-foreground",children:_t})]})}),nt&&s.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:s.jsxs("div",{className:"group relative max-h-[26rem] w-full overflow-auto bg-[var(--surface-background)]",children:[s.jsx("div",{className:"absolute top-1 right-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:s.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:bt=>{bt.stopPropagation(),S(ze.info.id,It)},"aria-label":e(St?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(St?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:St?s.jsx(M,{name:"check",className:"size-3.5"}):s.jsx(M,{name:"file-copy",className:"size-3.5"})})}),s.jsx(Ep,{language:"json",code:It,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},ze.info.id)},t[192]=l,t[193]=i,t[194]=e,t[195]=n,t[196]=qe):qe=t[196],ke=[...x].reverse().map(qe),t[186]=l,t[187]=i,t[188]=x,t[189]=e,t[190]=n,t[191]=ke}else ke=t[191];let xt;t[197]!==ke?(xt=s.jsx("div",{className:"mt-2.5 space-y-1",children:ke}),t[197]=ke,t[198]=xt):xt=t[198];let Ct;t[199]!==Pt||t[200]!==xt?(Ct=s.jsxs("div",{children:[Pt,xt]}),t[199]=Pt,t[200]=xt,t[201]=Ct):Ct=t[201];let Tt;return t[202]!==ae||t[203]!==rt||t[204]!==je||t[205]!==it||t[206]!==vt||t[207]!==Ct?(Tt=s.jsx(yn,{outerClassName:"h-full",className:"bg-background",children:s.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[ae,rt,je,it,vt,Ct]})}),t[202]=ae,t[203]=rt,t[204]=je,t[205]=it,t[206]=vt,t[207]=Ct,t[208]=Tt):Tt=t[208],Tt};function W1(t){return t.timeFormatPreference}function K1(t){return t.currentSessionId}function V1(t){return t.currentSessionDirectory}function U1(t){return t.providers}function H1(t){return Object.keys(t).length>0?{}:t}function G1(t){return Zr(t.info).role==="assistant"}function q1(t){return Zr(t.info).isUser}function Y1(t){return t.info}function Q1(t,e){const n=Bn(e.info.cost);return t+n}function X1(t){return Zr(t.info).isUser&&typeof t.info.system=="string"}function J1(t){return s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[s.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value})]},t.label)}function Z1(t){return s.jsxs("div",{children:[s.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value!==null&&t.value!==void 0?t.format==="percent"?`${t.value.toFixed(1)}%`:qn(t.value):"—"})]},t.label)}const xf=new Set(["localhost","127.0.0.1","0.0.0.0","::1","[::1]"]),ew=t=>{const e=t.split("/")[0]?.split("?")[0]??"",n=e.startsWith("[")?e.slice(0,e.indexOf("]")+1):e.split(":")[0]??"";return xf.has(n.toLowerCase())},sn="about:blank",br=t=>{const e=t.trim();if(!e)return sn;const n=e.includes("://")?e:`${ew(e)?"http":"https"}://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?sn:r.toString()}catch{return sn}},kr=t=>{try{return xf.has(new URL(t).hostname.toLowerCase())}catch{return!1}},Qa=t=>{if(!t||t===sn)return"";try{return new URL(t).host||t}catch{return t}},tw=new Set([-2,-7,-101,-102,-104,-109,-118,-324]),sw=(t,e)=>tw.has(t)&&kr(e),nw=t=>{if(!t||typeof t!="object")return!1;const e=t;return typeof e.port=="number"&&Number.isFinite(e.port)&&typeof e.url=="string"&&e.url.length>0&&typeof e.command=="string"},rw=async t=>{try{const e=await ls("/api/dev-servers",{signal:t});if(!e.ok)return{kind:"unavailable"};const n=await e.json();if(!n||typeof n!="object")return{kind:"unavailable"};const r=n.servers;return Array.isArray(r)?{kind:"ready",servers:r.filter(nw)}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},ow=async t=>{try{const e=await ls("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!e.ok)return null;const n=await e.json();if(!n||typeof n!="object")return null;const r=n.status;return typeof r=="number"&&Number.isFinite(r)?r:null}catch{return null}},iw=t=>{try{const e=new URL(t),n=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(n)&&n>0?n:null}catch{return null}},aw=({announced:t,discovered:e})=>{const n=new Map;for(const r of t){const i=iw(r);i!==null&&!n.has(i)&&n.set(i,r)}return e?e.map(r=>{const i=n.get(r.port);return{url:i??r.url,port:r.port,announced:i!==void 0}}).sort((r,i)=>r.announced!==i.announced?r.announced?-1:1:r.port-i.port):[...n.entries()].map(([r,i])=>({url:i,port:r,announced:!0})).sort((r,i)=>r.port-i.port)},ra="__openchamberBrowserAnnotationActive",lw=`(() => {
|
|
12
|
-
try {
|
|
13
|
-
var host = document.querySelector('[data-openchamber-annotation]');
|
|
14
|
-
if (host && host.parentNode) host.parentNode.removeChild(host);
|
|
15
|
-
} catch (error) { /* page navigated away */ }
|
|
16
|
-
try {
|
|
17
|
-
var cursor = document.getElementById('openchamber-annotation-cursor');
|
|
18
|
-
if (cursor && cursor.parentNode) cursor.parentNode.removeChild(cursor);
|
|
19
|
-
} catch (error) { /* page navigated away */ }
|
|
20
|
-
try { delete window['${ra}']; } catch (error) { /* non-configurable */ }
|
|
21
|
-
})();`,cw=(t,e)=>{const n=JSON.stringify({theme:t,labels:e});return String.raw`new Promise((resolve) => {
|
|
22
|
-
var CONFIG = ${n};
|
|
23
|
-
var THEME = CONFIG.theme;
|
|
24
|
-
var LABELS = CONFIG.labels;
|
|
25
|
-
var OVERLAY_ATTR = 'data-openchamber-annotation';
|
|
26
|
-
var Z_OVERLAY = 2147483646;
|
|
27
|
-
var MAX_TEXT = 400;
|
|
28
|
-
var MIN_RECT = 3;
|
|
29
|
-
var EDITOR_GAP = 10;
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
var stale = document.querySelector('[' + OVERLAY_ATTR + ']');
|
|
33
|
-
if (stale && stale.parentNode) stale.parentNode.removeChild(stale);
|
|
34
|
-
} catch (error) { /* nothing to clean */ }
|
|
35
|
-
|
|
36
|
-
window['${ra}'] = true;
|
|
37
|
-
|
|
38
|
-
var counter = 0;
|
|
39
|
-
var nextId = function (prefix) { counter += 1; return prefix + '-' + counter; };
|
|
40
|
-
|
|
41
|
-
var selected = null;
|
|
42
|
-
var regions = [];
|
|
43
|
-
var strokes = [];
|
|
44
|
-
var tool = 'select';
|
|
45
|
-
var settled = false;
|
|
46
|
-
|
|
47
|
-
// ---------------------------------------------------------------- geometry
|
|
48
|
-
|
|
49
|
-
var rectFrom = function (domRect) {
|
|
50
|
-
return { x: domRect.left, y: domRect.top, width: domRect.width, height: domRect.height };
|
|
51
|
-
};
|
|
52
|
-
var normalizeRect = function (ax, ay, bx, by) {
|
|
53
|
-
return { x: Math.min(ax, bx), y: Math.min(ay, by), width: Math.abs(bx - ax), height: Math.abs(by - ay) };
|
|
54
|
-
};
|
|
55
|
-
var usableRect = function (rect) { return rect.width >= MIN_RECT && rect.height >= MIN_RECT; };
|
|
56
|
-
|
|
57
|
-
// ------------------------------------------------------------- description
|
|
58
|
-
|
|
59
|
-
var isOverlayNode = function (element) {
|
|
60
|
-
var node = element;
|
|
61
|
-
while (node) {
|
|
62
|
-
if (node.nodeType === 1 && node.hasAttribute && node.hasAttribute(OVERLAY_ATTR)) return true;
|
|
63
|
-
node = node.parentNode || (node.host || null);
|
|
64
|
-
}
|
|
65
|
-
return false;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
var elementFromPoint = function (x, y) {
|
|
69
|
-
var found = document.elementFromPoint(x, y);
|
|
70
|
-
if (!found || isOverlayNode(found)) return null;
|
|
71
|
-
return found;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
var selectorPart = function (element) {
|
|
75
|
-
var part = element.tagName.toLowerCase();
|
|
76
|
-
if (element.id) return part + '#' + element.id;
|
|
77
|
-
var className = typeof element.className === 'string' ? element.className.trim() : '';
|
|
78
|
-
if (className) {
|
|
79
|
-
var first = className.split(/\s+/).filter(Boolean).slice(0, 2).join('.');
|
|
80
|
-
if (first) part += '.' + first;
|
|
81
|
-
}
|
|
82
|
-
return part;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
var buildSelector = function (element) {
|
|
86
|
-
if (element.id) return '#' + element.id;
|
|
87
|
-
var parts = [];
|
|
88
|
-
var node = element;
|
|
89
|
-
var depth = 0;
|
|
90
|
-
while (node && node.nodeType === 1 && depth < 5) {
|
|
91
|
-
var part = selectorPart(node);
|
|
92
|
-
var parent = node.parentElement;
|
|
93
|
-
if (parent) {
|
|
94
|
-
var siblings = Array.prototype.filter.call(parent.children, function (child) {
|
|
95
|
-
return child.tagName === node.tagName;
|
|
96
|
-
});
|
|
97
|
-
if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
|
|
98
|
-
}
|
|
99
|
-
parts.unshift(part);
|
|
100
|
-
if (node.id) break;
|
|
101
|
-
node = parent;
|
|
102
|
-
depth += 1;
|
|
103
|
-
}
|
|
104
|
-
return parts.join(' > ');
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
var INTERESTING_ATTRS = ['id', 'class', 'name', 'type', 'href', 'src', 'alt', 'title', 'role', 'placeholder', 'aria-label', 'data-testid'];
|
|
108
|
-
var STYLE_PROPS = [
|
|
109
|
-
'display', 'position', 'color', 'backgroundColor', 'fontSize', 'fontWeight', 'fontFamily',
|
|
110
|
-
'lineHeight', 'padding', 'margin', 'border', 'borderRadius', 'width', 'height', 'opacity',
|
|
111
|
-
'zIndex', 'flexDirection', 'justifyContent', 'alignItems', 'gap', 'textAlign'
|
|
112
|
-
];
|
|
113
|
-
|
|
114
|
-
var describe = function (element) {
|
|
115
|
-
var computed = window.getComputedStyle(element);
|
|
116
|
-
var attributes = {};
|
|
117
|
-
for (var i = 0; i < INTERESTING_ATTRS.length; i += 1) {
|
|
118
|
-
var name = INTERESTING_ATTRS[i];
|
|
119
|
-
var value = element.getAttribute(name);
|
|
120
|
-
if (value) attributes[name] = String(value).slice(0, 200);
|
|
121
|
-
}
|
|
122
|
-
var computedStyle = {};
|
|
123
|
-
for (var j = 0; j < STYLE_PROPS.length; j += 1) {
|
|
124
|
-
var prop = STYLE_PROPS[j];
|
|
125
|
-
computedStyle[prop] = String(computed[prop] == null ? '' : computed[prop]);
|
|
126
|
-
}
|
|
127
|
-
var ancestry = [];
|
|
128
|
-
var node = element.parentElement;
|
|
129
|
-
var depth = 0;
|
|
130
|
-
while (node && node.nodeType === 1 && depth < 4) {
|
|
131
|
-
var entry = { tag: node.tagName.toLowerCase(), selectorPart: selectorPart(node) };
|
|
132
|
-
if (node.id) entry.id = node.id;
|
|
133
|
-
var cls = typeof node.className === 'string' ? node.className.trim() : '';
|
|
134
|
-
if (cls) entry.className = cls.slice(0, 200);
|
|
135
|
-
ancestry.unshift(entry);
|
|
136
|
-
node = node.parentElement;
|
|
137
|
-
depth += 1;
|
|
138
|
-
}
|
|
139
|
-
var box = element.getBoundingClientRect();
|
|
140
|
-
var text = (element.textContent == null ? '' : String(element.textContent)).replace(/\s+/g, ' ').trim();
|
|
141
|
-
return {
|
|
142
|
-
tag: element.tagName.toLowerCase(),
|
|
143
|
-
text: text.slice(0, MAX_TEXT),
|
|
144
|
-
selector: buildSelector(element),
|
|
145
|
-
path: ancestry.map(function (e) { return e.selectorPart; }).concat([selectorPart(element)]).join(' > '),
|
|
146
|
-
bounds: rectFrom(box),
|
|
147
|
-
center: { x: box.left + box.width / 2, y: box.top + box.height / 2 },
|
|
148
|
-
attributes: attributes,
|
|
149
|
-
computedStyle: computedStyle,
|
|
150
|
-
ancestry: ancestry
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
// ------------------------------------------------------------------ chrome
|
|
155
|
-
|
|
156
|
-
var host = document.createElement('div');
|
|
157
|
-
host.setAttribute(OVERLAY_ATTR, '');
|
|
158
|
-
host.style.cssText = 'position:fixed;inset:0;z-index:' + Z_OVERLAY + ';pointer-events:none';
|
|
159
|
-
var shadow = host.attachShadow({ mode: 'closed' });
|
|
160
|
-
|
|
161
|
-
var style = document.createElement('style');
|
|
162
|
-
style.textContent = [
|
|
163
|
-
':host{all:initial}',
|
|
164
|
-
'*{box-sizing:border-box;font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif}',
|
|
165
|
-
'.layer{position:fixed;inset:0;pointer-events:none}',
|
|
166
|
-
'.box{position:fixed;left:0;top:0;display:none;pointer-events:none;border:1.5px solid ' + THEME.primary + ';background:' + THEME.primarySoft + ';border-radius:2px}',
|
|
167
|
-
'.label{position:fixed;left:0;top:0;display:none;pointer-events:none;padding:1px 6px;border-radius:4px;background:' + THEME.primary + ';color:' + THEME.primaryContrast + ';font-size:11px;line-height:17px;white-space:nowrap;font-weight:600}',
|
|
168
|
-
'.tools{position:fixed;top:14px;left:50%;transform:translateX(-50%);display:flex;gap:2px;padding:4px;border-radius:999px;border:1px solid ' + THEME.border + ';background:' + THEME.glassSurface + ';-webkit-backdrop-filter:' + THEME.glassFilter + ';backdrop-filter:' + THEME.glassFilter + ';box-shadow:0 6px 20px rgba(0,0,0,.24);pointer-events:auto}',
|
|
169
|
-
'.tools button{appearance:none;border:none;background:transparent;color:' + THEME.mutedText + ';border-radius:999px;padding:5px 14px;font-size:12px;line-height:18px;font-weight:500;cursor:pointer;white-space:nowrap}',
|
|
170
|
-
'.tools button:hover{background:' + THEME.primaryFaint + '}',
|
|
171
|
-
'.tools button[aria-pressed="true"]{background:' + THEME.primarySoft + ';color:' + THEME.primary + ';font-weight:600}',
|
|
172
|
-
'.editor{position:fixed;left:0;top:0;display:none;align-items:center;gap:8px;width:min(420px,calc(100vw - 24px));padding:6px;padding-left:16px;border-radius:22px;border:1px solid ' + THEME.border + ';background:' + THEME.glassSurface + ';-webkit-backdrop-filter:' + THEME.glassFilter + ';backdrop-filter:' + THEME.glassFilter + ';box-shadow:0 8px 28px rgba(0,0,0,.3);pointer-events:auto}',
|
|
173
|
-
'.editor textarea{flex:1;min-width:0;resize:none;border:none;background:transparent;color:' + THEME.text + ';font-size:13px;line-height:20px;outline:none;padding:6px 0;min-height:32px;max-height:104px;display:block}',
|
|
174
|
-
'.editor textarea::placeholder{color:' + THEME.mutedText + '}',
|
|
175
|
-
'.editor button{appearance:none;border:none;background:' + THEME.primary + ';color:' + THEME.primaryContrast + ';border-radius:999px;width:32px;height:32px;padding:0;display:flex;align-items:center;justify-content:center;flex-shrink:0;cursor:pointer}',
|
|
176
|
-
'.editor button svg{width:16px;height:16px;display:block}',
|
|
177
|
-
'.editor button[disabled]{opacity:.5;cursor:default}'
|
|
178
|
-
].join('');
|
|
179
|
-
shadow.appendChild(style);
|
|
180
|
-
|
|
181
|
-
var cursorStyle = document.createElement('style');
|
|
182
|
-
cursorStyle.id = 'openchamber-annotation-cursor';
|
|
183
|
-
document.head.appendChild(cursorStyle);
|
|
184
|
-
var setCursor = function (value) {
|
|
185
|
-
cursorStyle.textContent = value ? '*{cursor:' + value + ' !important}' : '';
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
var svgNS = 'http://www.w3.org/2000/svg';
|
|
189
|
-
var svg = document.createElementNS(svgNS, 'svg');
|
|
190
|
-
svg.setAttribute('class', 'layer');
|
|
191
|
-
svg.style.overflow = 'visible';
|
|
192
|
-
shadow.appendChild(svg);
|
|
193
|
-
|
|
194
|
-
var hoverBox = document.createElement('div');
|
|
195
|
-
hoverBox.className = 'box';
|
|
196
|
-
var hoverLabel = document.createElement('div');
|
|
197
|
-
hoverLabel.className = 'label';
|
|
198
|
-
var marqueeBox = document.createElement('div');
|
|
199
|
-
marqueeBox.className = 'box';
|
|
200
|
-
shadow.append(hoverBox, hoverLabel, marqueeBox);
|
|
201
|
-
|
|
202
|
-
var positionBox = function (node, rect) {
|
|
203
|
-
node.style.display = 'block';
|
|
204
|
-
node.style.transform = 'translate(' + rect.x + 'px,' + rect.y + 'px)';
|
|
205
|
-
node.style.width = rect.width + 'px';
|
|
206
|
-
node.style.height = rect.height + 'px';
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
var tools = document.createElement('div');
|
|
210
|
-
tools.className = 'tools';
|
|
211
|
-
shadow.appendChild(tools);
|
|
212
|
-
|
|
213
|
-
var toolButtons = {};
|
|
214
|
-
[['select', LABELS.select], ['marquee', LABELS.marquee], ['draw', LABELS.draw]].forEach(function (entry) {
|
|
215
|
-
var button = document.createElement('button');
|
|
216
|
-
button.type = 'button';
|
|
217
|
-
button.textContent = entry[1];
|
|
218
|
-
button.addEventListener('click', function () { setTool(entry[0]); });
|
|
219
|
-
toolButtons[entry[0]] = button;
|
|
220
|
-
tools.appendChild(button);
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
var editor = document.createElement('div');
|
|
224
|
-
editor.className = 'editor';
|
|
225
|
-
shadow.appendChild(editor);
|
|
226
|
-
|
|
227
|
-
var comment = document.createElement('textarea');
|
|
228
|
-
comment.rows = 1;
|
|
229
|
-
comment.placeholder = LABELS.commentPlaceholder;
|
|
230
|
-
var submit = document.createElement('button');
|
|
231
|
-
submit.type = 'button';
|
|
232
|
-
// Icon-only attach button (Remix attachment-2), matching the chat comment
|
|
233
|
-
// input; the localized label stays available to assistive tech.
|
|
234
|
-
submit.setAttribute('aria-label', LABELS.submit);
|
|
235
|
-
submit.title = LABELS.submit;
|
|
236
|
-
submit.innerHTML = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M14.8287 7.75737L9.1718 13.4142C8.78127 13.8047 8.78127 14.4379 9.1718 14.8284C9.56232 15.219 10.1955 15.219 10.586 14.8284L16.2429 9.17158C17.4144 8.00001 17.4144 6.10052 16.2429 4.92894C15.0713 3.75737 13.1718 3.75737 12.0002 4.92894L6.34337 10.5858C4.39075 12.5384 4.39075 15.7042 6.34337 17.6569C8.29599 19.6095 11.4618 19.6095 13.4144 17.6569L19.0713 12L20.4855 13.4142L14.8287 19.0711C12.095 21.8047 7.66283 21.8047 4.92916 19.0711C2.19549 16.3374 2.19549 11.9053 4.92916 9.17158L10.586 3.51473C12.5386 1.56211 15.7045 1.56211 17.6571 3.51473C19.6097 5.46735 19.6097 8.63317 17.6571 10.5858L12.0002 16.2427C10.8287 17.4142 8.92916 17.4142 7.75759 16.2427C6.58601 15.0711 6.58601 13.1716 7.75759 12L13.4144 6.34316L14.8287 7.75737Z" fill="currentColor"/></svg>';
|
|
237
|
-
editor.append(comment, submit);
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Grows the box with its content.
|
|
241
|
-
*
|
|
242
|
-
* A hidden element reports scrollHeight 0, so measuring one collapses the
|
|
243
|
-
* field to nothing — which is what left a sliver of a click target and an
|
|
244
|
-
* invisible caret. Measuring only while visible, and never below the CSS
|
|
245
|
-
* min-height, keeps it usable.
|
|
246
|
-
*/
|
|
247
|
-
var resizeComment = function () {
|
|
248
|
-
if (editor.style.display === 'none') return;
|
|
249
|
-
comment.style.height = 'auto';
|
|
250
|
-
comment.style.height = Math.max(32, Math.min(comment.scrollHeight, 104)) + 'px';
|
|
251
|
-
};
|
|
252
|
-
comment.addEventListener('input', resizeComment);
|
|
253
|
-
|
|
254
|
-
// -------------------------------------------------------------- selection
|
|
255
|
-
|
|
256
|
-
var lastTargetRect = null;
|
|
257
|
-
|
|
258
|
-
/** Places the comment box under whatever was just marked, kept on screen. */
|
|
259
|
-
var positionEditor = function () {
|
|
260
|
-
if (!lastTargetRect) {
|
|
261
|
-
editor.style.display = 'none';
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
var wasHidden = editor.style.display === 'none';
|
|
265
|
-
editor.style.display = 'flex';
|
|
266
|
-
// Measured now that it is laid out, not while it was still hidden.
|
|
267
|
-
if (wasHidden) resizeComment();
|
|
268
|
-
var box = editor.getBoundingClientRect();
|
|
269
|
-
var left = lastTargetRect.x + lastTargetRect.width / 2 - box.width / 2;
|
|
270
|
-
var top = lastTargetRect.y + lastTargetRect.height + EDITOR_GAP;
|
|
271
|
-
// Above the target when there is no room below, so the box is never left
|
|
272
|
-
// half off the bottom of the page.
|
|
273
|
-
if (top + box.height > window.innerHeight - 8) {
|
|
274
|
-
top = Math.max(8, lastTargetRect.y - box.height - EDITOR_GAP);
|
|
275
|
-
}
|
|
276
|
-
left = Math.max(8, Math.min(left, window.innerWidth - box.width - 8));
|
|
277
|
-
editor.style.transform = 'translate(' + Math.round(left) + 'px,' + Math.round(top) + 'px)';
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
/** Focus after layout: focusing a zero-height field puts the caret nowhere. */
|
|
281
|
-
var focusComment = function () {
|
|
282
|
-
requestAnimationFrame(function () {
|
|
283
|
-
try {
|
|
284
|
-
comment.focus({ preventScroll: true });
|
|
285
|
-
comment.setSelectionRange(comment.value.length, comment.value.length);
|
|
286
|
-
} catch (error) { /* field went away */ }
|
|
287
|
-
});
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
var hasTargets = function () {
|
|
291
|
-
return Boolean(selected) || regions.length > 0 || strokes.length > 0;
|
|
292
|
-
};
|
|
293
|
-
|
|
294
|
-
var syncChrome = function () {
|
|
295
|
-
submit.disabled = !hasTargets();
|
|
296
|
-
if (!hasTargets()) {
|
|
297
|
-
lastTargetRect = null;
|
|
298
|
-
editor.style.display = 'none';
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
positionEditor();
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
var syncSelectionVisuals = function () {
|
|
305
|
-
if (!selected) return;
|
|
306
|
-
var rect = rectFrom(selected.element.getBoundingClientRect());
|
|
307
|
-
if (!usableRect(rect)) {
|
|
308
|
-
selected.outline.style.display = 'none';
|
|
309
|
-
selected.badge.style.display = 'none';
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
positionBox(selected.outline, rect);
|
|
313
|
-
selected.badge.style.display = 'block';
|
|
314
|
-
selected.badge.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
|
|
315
|
-
lastTargetRect = rect;
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
var dropSelection = function () {
|
|
319
|
-
if (!selected) return;
|
|
320
|
-
selected.outline.remove();
|
|
321
|
-
selected.badge.remove();
|
|
322
|
-
selected = null;
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
var selectElement = function (element) {
|
|
326
|
-
var wasSelected = selected && selected.element === element;
|
|
327
|
-
dropSelection();
|
|
328
|
-
if (wasSelected) {
|
|
329
|
-
// Clicking the chosen element again clears it, so a misclick costs one
|
|
330
|
-
// click rather than starting over.
|
|
331
|
-
lastTargetRect = null;
|
|
332
|
-
syncChrome();
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
var outline = document.createElement('div');
|
|
336
|
-
outline.className = 'box';
|
|
337
|
-
var badge = document.createElement('div');
|
|
338
|
-
badge.className = 'label';
|
|
339
|
-
badge.textContent = selectorPart(element);
|
|
340
|
-
shadow.append(outline, badge);
|
|
341
|
-
selected = { id: nextId('element'), element: element, outline: outline, badge: badge };
|
|
342
|
-
syncSelectionVisuals();
|
|
343
|
-
syncChrome();
|
|
344
|
-
focusComment();
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
var setTool = function (next) {
|
|
348
|
-
tool = next;
|
|
349
|
-
hoverBox.style.display = 'none';
|
|
350
|
-
hoverLabel.style.display = 'none';
|
|
351
|
-
marqueeBox.style.display = 'none';
|
|
352
|
-
setCursor(next === 'select' ? '' : 'crosshair');
|
|
353
|
-
for (var key in toolButtons) {
|
|
354
|
-
if (Object.prototype.hasOwnProperty.call(toolButtons, key)) {
|
|
355
|
-
toolButtons[key].setAttribute('aria-pressed', key === next ? 'true' : 'false');
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
// ------------------------------------------------------------- interaction
|
|
361
|
-
|
|
362
|
-
var drag = null;
|
|
363
|
-
|
|
364
|
-
var onPointerMove = function (event) {
|
|
365
|
-
if (drag) {
|
|
366
|
-
if (drag.kind === 'marquee') {
|
|
367
|
-
drag.rect = normalizeRect(drag.startX, drag.startY, event.clientX, event.clientY);
|
|
368
|
-
positionBox(marqueeBox, drag.rect);
|
|
369
|
-
} else if (drag.kind === 'draw') {
|
|
370
|
-
drag.points.push({ x: event.clientX, y: event.clientY });
|
|
371
|
-
drag.path.setAttribute('d', drag.points.map(function (point, index) {
|
|
372
|
-
return (index === 0 ? 'M' : 'L') + point.x + ' ' + point.y;
|
|
373
|
-
}).join(' '));
|
|
374
|
-
}
|
|
375
|
-
return;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
if (tool !== 'select') return;
|
|
379
|
-
var element = elementFromPoint(event.clientX, event.clientY);
|
|
380
|
-
if (!element) {
|
|
381
|
-
hoverBox.style.display = 'none';
|
|
382
|
-
hoverLabel.style.display = 'none';
|
|
383
|
-
return;
|
|
384
|
-
}
|
|
385
|
-
var rect = rectFrom(element.getBoundingClientRect());
|
|
386
|
-
positionBox(hoverBox, rect);
|
|
387
|
-
hoverLabel.textContent = selectorPart(element);
|
|
388
|
-
hoverLabel.style.display = 'block';
|
|
389
|
-
hoverLabel.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
var onPointerDown = function (event) {
|
|
393
|
-
if (event.button !== 0) return;
|
|
394
|
-
if (isOverlayNode(event.target)) return;
|
|
395
|
-
event.preventDefault();
|
|
396
|
-
event.stopPropagation();
|
|
397
|
-
|
|
398
|
-
if (tool === 'select') {
|
|
399
|
-
var element = elementFromPoint(event.clientX, event.clientY);
|
|
400
|
-
if (element) selectElement(element);
|
|
401
|
-
return;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
if (tool === 'marquee') {
|
|
405
|
-
drag = { kind: 'marquee', startX: event.clientX, startY: event.clientY, rect: null };
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
var path = document.createElementNS(svgNS, 'path');
|
|
410
|
-
path.setAttribute('fill', 'none');
|
|
411
|
-
path.setAttribute('stroke', THEME.primary);
|
|
412
|
-
path.setAttribute('stroke-width', '2.5');
|
|
413
|
-
path.setAttribute('stroke-linecap', 'round');
|
|
414
|
-
path.setAttribute('stroke-linejoin', 'round');
|
|
415
|
-
svg.appendChild(path);
|
|
416
|
-
drag = { kind: 'draw', path: path, points: [{ x: event.clientX, y: event.clientY }] };
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
var onPointerUp = function () {
|
|
420
|
-
if (!drag) return;
|
|
421
|
-
var finished = drag;
|
|
422
|
-
drag = null;
|
|
423
|
-
|
|
424
|
-
if (finished.kind === 'marquee') {
|
|
425
|
-
marqueeBox.style.display = 'none';
|
|
426
|
-
var rect = finished.rect;
|
|
427
|
-
if (!rect || !usableRect(rect)) return;
|
|
428
|
-
// A region marks an area, not the elements inside it: expanding it into a
|
|
429
|
-
// selection made the result depend on the page's markup rather than on
|
|
430
|
-
// what was drawn.
|
|
431
|
-
regions.push({ id: nextId('region'), rect: rect });
|
|
432
|
-
var outline = document.createElementNS(svgNS, 'rect');
|
|
433
|
-
outline.setAttribute('x', String(rect.x));
|
|
434
|
-
outline.setAttribute('y', String(rect.y));
|
|
435
|
-
outline.setAttribute('width', String(rect.width));
|
|
436
|
-
outline.setAttribute('height', String(rect.height));
|
|
437
|
-
outline.style.fill = THEME.primarySoft;
|
|
438
|
-
outline.setAttribute('stroke', THEME.primary);
|
|
439
|
-
outline.setAttribute('stroke-width', '1.5');
|
|
440
|
-
outline.setAttribute('rx', '2');
|
|
441
|
-
svg.appendChild(outline);
|
|
442
|
-
lastTargetRect = rect;
|
|
443
|
-
syncChrome();
|
|
444
|
-
focusComment();
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
var points = finished.points;
|
|
449
|
-
if (points.length < 2) {
|
|
450
|
-
if (finished.path.parentNode) finished.path.parentNode.removeChild(finished.path);
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
var minX = points[0].x, minY = points[0].y, maxX = points[0].x, maxY = points[0].y;
|
|
454
|
-
for (var p = 1; p < points.length; p += 1) {
|
|
455
|
-
minX = Math.min(minX, points[p].x);
|
|
456
|
-
minY = Math.min(minY, points[p].y);
|
|
457
|
-
maxX = Math.max(maxX, points[p].x);
|
|
458
|
-
maxY = Math.max(maxY, points[p].y);
|
|
459
|
-
}
|
|
460
|
-
var bounds = { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
461
|
-
strokes.push({ id: nextId('stroke'), points: points, bounds: bounds });
|
|
462
|
-
lastTargetRect = bounds;
|
|
463
|
-
syncChrome();
|
|
464
|
-
focusComment();
|
|
465
|
-
};
|
|
466
|
-
|
|
467
|
-
/**
|
|
468
|
-
* Swallows the page's own mouse handling while annotating.
|
|
469
|
-
*
|
|
470
|
-
* Blocking pointerdown is not enough: a click still follows it, so marking a
|
|
471
|
-
* button pressed that button and marking a link navigated away from the page
|
|
472
|
-
* being annotated. These are the events that reach page code, so these are
|
|
473
|
-
* the ones that have to stop.
|
|
474
|
-
*/
|
|
475
|
-
var blockPageInteraction = function (event) {
|
|
476
|
-
if (isOverlayNode(event.target)) return;
|
|
477
|
-
event.preventDefault();
|
|
478
|
-
event.stopPropagation();
|
|
479
|
-
};
|
|
480
|
-
var BLOCKED_EVENTS = ['click', 'auxclick', 'dblclick', 'mousedown', 'mouseup', 'contextmenu'];
|
|
481
|
-
|
|
482
|
-
var onScrollOrResize = function () {
|
|
483
|
-
syncSelectionVisuals();
|
|
484
|
-
positionEditor();
|
|
485
|
-
};
|
|
486
|
-
|
|
487
|
-
var onKeyDown = function (event) {
|
|
488
|
-
if (event.isComposing || event.keyCode === 229) return;
|
|
489
|
-
if (event.key === 'Escape') {
|
|
490
|
-
event.preventDefault();
|
|
491
|
-
event.stopImmediatePropagation();
|
|
492
|
-
finish(null);
|
|
493
|
-
}
|
|
494
|
-
};
|
|
495
|
-
|
|
496
|
-
var onCommentKeyDown = function (event) {
|
|
497
|
-
// Do not let the annotated page treat typed letters as its own shortcuts.
|
|
498
|
-
event.stopPropagation();
|
|
499
|
-
// WebKit can report the composition-confirming Enter as keyCode 229.
|
|
500
|
-
if (event.isComposing || event.keyCode === 229) return;
|
|
501
|
-
if (event.key === 'Enter' && !event.shiftKey) {
|
|
502
|
-
event.preventDefault();
|
|
503
|
-
attach();
|
|
504
|
-
}
|
|
505
|
-
};
|
|
506
|
-
|
|
507
|
-
document.addEventListener('pointermove', onPointerMove, true);
|
|
508
|
-
document.addEventListener('pointerdown', onPointerDown, true);
|
|
509
|
-
document.addEventListener('pointerup', onPointerUp, true);
|
|
510
|
-
BLOCKED_EVENTS.forEach(function (name) {
|
|
511
|
-
window.addEventListener(name, blockPageInteraction, { capture: true, passive: false });
|
|
512
|
-
});
|
|
513
|
-
window.addEventListener('scroll', onScrollOrResize, true);
|
|
514
|
-
window.addEventListener('resize', onScrollOrResize, true);
|
|
515
|
-
window.addEventListener('keydown', onKeyDown, true);
|
|
516
|
-
comment.addEventListener('keydown', onCommentKeyDown);
|
|
517
|
-
|
|
518
|
-
// ------------------------------------------------------------------ finish
|
|
519
|
-
|
|
520
|
-
var teardown = function () {
|
|
521
|
-
document.removeEventListener('pointermove', onPointerMove, true);
|
|
522
|
-
document.removeEventListener('pointerdown', onPointerDown, true);
|
|
523
|
-
document.removeEventListener('pointerup', onPointerUp, true);
|
|
524
|
-
BLOCKED_EVENTS.forEach(function (name) {
|
|
525
|
-
window.removeEventListener(name, blockPageInteraction, true);
|
|
526
|
-
});
|
|
527
|
-
window.removeEventListener('scroll', onScrollOrResize, true);
|
|
528
|
-
window.removeEventListener('resize', onScrollOrResize, true);
|
|
529
|
-
window.removeEventListener('keydown', onKeyDown, true);
|
|
530
|
-
comment.removeEventListener('keydown', onCommentKeyDown);
|
|
531
|
-
setCursor('');
|
|
532
|
-
if (cursorStyle.parentNode) cursorStyle.parentNode.removeChild(cursorStyle);
|
|
533
|
-
if (host.parentNode) host.parentNode.removeChild(host);
|
|
534
|
-
try { delete window['${ra}']; } catch (error) { /* non-configurable */ }
|
|
535
|
-
};
|
|
536
|
-
|
|
537
|
-
var finish = function (payload) {
|
|
538
|
-
if (settled) return;
|
|
539
|
-
settled = true;
|
|
540
|
-
teardown();
|
|
541
|
-
// Removing the chrome is not enough: the host screenshots this page right
|
|
542
|
-
// after we resolve, and the compositor can still hold a frame containing
|
|
543
|
-
// our outlines. Yield two frames so the page has actually repainted.
|
|
544
|
-
requestAnimationFrame(function () {
|
|
545
|
-
requestAnimationFrame(function () { resolve(payload); });
|
|
546
|
-
});
|
|
547
|
-
};
|
|
548
|
-
|
|
549
|
-
var attach = function () {
|
|
550
|
-
if (!hasTargets()) return;
|
|
551
|
-
finish({
|
|
552
|
-
id: 'annotation-' + Date.now(),
|
|
553
|
-
pageUrl: String(location.href),
|
|
554
|
-
pageTitle: String(document.title || ''),
|
|
555
|
-
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
556
|
-
devicePixelRatio: window.devicePixelRatio || 1,
|
|
557
|
-
comment: comment.value,
|
|
558
|
-
// Zero or one element, never more. Kept as a list so elements, regions
|
|
559
|
-
// and strokes stay one uniform shape for everything downstream.
|
|
560
|
-
elements: selected ? [{ id: selected.id, element: describe(selected.element) }] : [],
|
|
561
|
-
regions: regions.map(function (entry) { return { id: entry.id, rect: entry.rect }; }),
|
|
562
|
-
strokes: strokes.map(function (entry) {
|
|
563
|
-
return { id: entry.id, points: entry.points, bounds: entry.bounds };
|
|
564
|
-
})
|
|
565
|
-
});
|
|
566
|
-
};
|
|
567
|
-
|
|
568
|
-
submit.addEventListener('click', attach);
|
|
569
|
-
|
|
570
|
-
(document.body || document.documentElement).appendChild(host);
|
|
571
|
-
setTool('select');
|
|
572
|
-
syncChrome();
|
|
573
|
-
});`},dw={kind:"idle"},wn=t=>typeof t=="object"&&t!==null,Nn=t=>typeof t=="number"&&Number.isFinite(t),xc=t=>wn(t)&&Object.values(t).every(e=>typeof e=="string"),Xa=t=>wn(t)&&Nn(t.x)&&Nn(t.y)&&Nn(t.width)&&Nn(t.height),bf=t=>wn(t)&&Nn(t.x)&&Nn(t.y),uw=t=>wn(t)&&typeof t.tag=="string"&&typeof t.selectorPart=="string"&&(t.id===void 0||typeof t.id=="string")&&(t.className===void 0||typeof t.className=="string"),fw=t=>wn(t)&&typeof t.tag=="string"&&typeof t.text=="string"&&typeof t.selector=="string"&&typeof t.path=="string"&&Xa(t.bounds)&&bf(t.center)&&xc(t.attributes)&&xc(t.computedStyle)&&Array.isArray(t.ancestry)&&t.ancestry.every(uw),mw=t=>wn(t)&&typeof t.id=="string"&&fw(t.element),hw=t=>wn(t)&&typeof t.id=="string"&&Xa(t.rect),pw=t=>wn(t)&&typeof t.id=="string"&&Xa(t.bounds)&&Array.isArray(t.points)&&t.points.every(bf),gw=t=>wn(t)&&typeof t.id=="string"&&typeof t.pageUrl=="string"&&typeof t.pageTitle=="string"&&typeof t.comment=="string"&&wn(t.viewport)&&Nn(t.viewport.width)&&Nn(t.viewport.height)&&Nn(t.devicePixelRatio)&&Array.isArray(t.elements)&&t.elements.every(mw)&&Array.isArray(t.regions)&&t.regions.every(hw)&&Array.isArray(t.strokes)&&t.strokes.every(pw),xw=1600,bw=t=>new Promise((e,n)=>{const r=new Image;r.onload=()=>e(r),r.onerror=()=>n(new Error("Failed to decode browser page capture")),r.src=t}),yw=async({base64:t,mime:e,captureWidth:n,captureHeight:r,cssWidth:i,cssHeight:o,payload:l,accentColor:a,accentFill:d})=>{if(!t)return null;try{const u=await bw(`data:${e};base64,${t}`),h=Math.max(1,u.naturalWidth||n),f=Math.max(1,u.naturalHeight||r),x=h/Math.max(1,i||h),b=f/Math.max(1,o||f),w=Math.min(1,xw/h),v=document.createElement("canvas");v.width=Math.max(1,Math.floor(h*w)),v.height=Math.max(1,Math.floor(f*w));const y=v.getContext("2d");if(!y)return null;y.scale(w,w),y.drawImage(u,0,0,h,f);const m=C=>({x:C.x*x,y:C.y*b,width:C.width*x,height:C.height*b}),p=Math.max(2,2.5*x/Math.max(w,.2));y.strokeStyle=a,y.fillStyle=d;const S=C=>{const k=m(C);y.lineWidth=p,y.fillRect(k.x,k.y,k.width,k.height),y.strokeRect(k.x,k.y,k.width,k.height)};for(const C of l.elements)S(C.element.bounds);for(const C of l.regions)S(C.rect);for(const C of l.strokes)C.points.length<2||(y.beginPath(),C.points.forEach((k,j)=>{const D=k.x*x,I=k.y*b;j===0?y.moveTo(D,I):y.lineTo(D,I)}),y.lineCap="round",y.lineJoin="round",y.lineWidth=p*1.4,y.stroke());const g=await new Promise(C=>v.toBlob(C,"image/jpeg",.85));return g?new File([g],`browser-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch{return null}},ww="({ width: window.innerWidth, height: window.innerHeight })",vw=async t=>{try{const e=await t.executeJavaScript(ww,!0);if(!e||typeof e!="object")return null;const n=e;return typeof n.width!="number"||typeof n.height!="number"||!Number.isFinite(n.width)||!Number.isFinite(n.height)?null:{width:n.width,height:n.height}}catch{return null}},jo=async t=>{try{await t.executeJavaScript(lw,!1)}catch{}},Sw=async({host:t,theme:e,labels:n})=>{const r=cw(e,n),i=await t.executeJavaScript(r,!0);if(i==null)return null;if(!gw(i))return await jo(t),null;const o=i;try{const l=await vw(t)??o.viewport,a=await t.capturePage();if(!a||!a.base64)return{payload:o,screenshot:null};const d=await yw({base64:a.base64,mime:a.mime||"image/jpeg",captureWidth:a.width,captureHeight:a.height,cssWidth:l.width,cssHeight:l.height,payload:o,accentColor:e.primary,accentFill:e.primarySoft});return{payload:o,screenshot:d}}catch{return{payload:o,screenshot:null}}},en={colorScheme:"dark",primary:"rgb(59, 130, 246)",primarySoft:"rgba(59, 130, 246, 0.16)",primaryFaint:"rgba(59, 130, 246, 0.10)",primaryContrast:"rgb(255, 255, 255)",surface:"rgb(24, 24, 27)",surfaceElevated:"rgb(32, 32, 36)",glassSurface:"rgba(32, 32, 36, 0.64)",glassFilter:"blur(26px) saturate(1.16)",border:"rgba(255, 255, 255, 0.14)",text:"rgb(244, 244, 245)",mutedText:"rgba(244, 244, 245, 0.62)"},jw=()=>{if(typeof document>"u"||!document.body)return null;const t=document.createElement("div");return t.setAttribute("aria-hidden","true"),t.style.cssText="position:fixed;left:-9999px;top:-9999px;width:1px;height:1px;pointer-events:none",document.body.appendChild(t),{read:e=>{t.style.backgroundColor="",t.style.backgroundColor=e;const n=window.getComputedStyle(t).backgroundColor;return n&&n!=="rgba(0, 0, 0, 0)"?n:""},readVariable:e=>window.getComputedStyle(document.documentElement).getPropertyValue(e).trim(),dispose:()=>t.remove()}},kw=t=>{const e=jw();if(!e)return{...en,colorScheme:t};try{const n=(a,d)=>e.read(`var(${a})`)||d,r=(a,d,u)=>e.read(`color-mix(in srgb, var(${a}) ${d}%, transparent)`)||u,i=e.readVariable("--oc-glass-tooltip-opacity")||"62%",o=e.readVariable("--oc-glass-blur")||"26px",l=e.readVariable("--oc-glass-saturation")||"1.16";return{colorScheme:t,glassSurface:e.read(`color-mix(in srgb, var(--surface-elevated) ${i}, transparent)`)||en.glassSurface,glassFilter:`blur(${o}) saturate(${l})`,primary:n("--primary",en.primary),primarySoft:r("--primary",16,en.primarySoft),primaryFaint:r("--primary",10,en.primaryFaint),primaryContrast:n("--primary-foreground",en.primaryContrast),surface:n("--surface-background",en.surface),surfaceElevated:n("--surface-elevated",en.surfaceElevated),border:n("--border",en.border),text:n("--foreground",en.text),mutedText:n("--muted-foreground",en.mutedText)}}catch{return{...en,colorScheme:t}}finally{e.dispose()}},Cw=2e3,Nw=50;let tr=null,yr=null,Wr=null;const Aw=async t=>{try{const e=await ls("/api/browser-control/claim",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t})});return e.ok?(await e.json())?.granted===!0:!1}catch{return!1}},lr=async(t,e)=>{try{const n=await ls("/api/browser-control/result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t,...e})});n.ok||console.warn(`[browser-control] the server rejected the result for ${t} (HTTP ${n.status}); the agent will see this action time out`)}catch(n){console.warn(`[browser-control] could not deliver the result for ${t}:`,n)}},Dw=async(t=Cw)=>{const e=Date.now()+t;for(;!tr&&Date.now()<e;)await new Promise(n=>setTimeout(n,Nw));return tr},Pw=async t=>{const e=t.action==="browser.open",n=tr;if(!(!n&&!(e&&yr))&&await Aw(t.requestId))try{if(e&&!n){const i=typeof t.parameters.url=="string"?t.parameters.url:"";if(!i){await lr(t.requestId,{ok:!1,error:"url is required"});return}yr?.(i);const o=typeof t.parameters.viewport=="string"?t.parameters.viewport:"";if(!o||o==="fill"){await lr(t.requestId,{ok:!0,data:{url:i,opened:!0}});return}const l=await Dw();if(!l){await lr(t.requestId,{ok:!0,data:{url:i,opened:!0,viewportApplied:!1,note:"The panel had no browser view yet, so the viewport was not applied. Call browser.resize now that one exists."}});return}const a=await l.run("browser.resize",{viewport:o}),d=a&&typeof a=="object"?a.viewport??null:null;await lr(t.requestId,{ok:!0,data:{url:i,opened:!0,viewportApplied:!0,viewport:d}});return}const r=await n.run(t.action,t.parameters);await lr(t.requestId,{ok:!0,data:r})}catch(r){await lr(t.requestId,{ok:!1,error:r instanceof Error?r.message:String(r)})}},yf=()=>{Wr||(Wr=eo(t=>{t.type==="browser-control-request"&&Pw({requestId:t.requestId,action:t.action,parameters:t.parameters})}))},wf=()=>{tr||yr||!Wr||(Wr(),Wr=null)},Iw=t=>(tr=t,yf(),()=>{tr===t&&(tr=null),wf()}),Tw=t=>(yr=t,yf(),()=>{yr===t&&(yr=null),wf()}),Ew=50,Rw=6,Mw=2048,Ow=200,vf=t=>{const e=br(String(t??"").trim());if(!e||e.length>Mw)return"";try{const n=new URL(e);return n.protocol!=="http:"&&n.protocol!=="https:"?"":n.toString()}catch{return""}},Bw=(t,e)=>{const n=vf(e.url);if(!n)return t;const r=t.find(l=>l.url===n),i=String(e.title??"").trim().slice(0,Ow)||r?.title||"";return[{url:n,title:i,lastVisitedAt:e.at},...t.filter(l=>l.url!==n)].slice(0,Ew)},Fw=(t,e)=>{const n=vf(e);return t.filter(r=>r.url!==n)},_w=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),Sf=(t,e,n=Rw)=>{const r=String(e??"").trim().toLowerCase(),i=[...t].sort((l,a)=>a.lastVisitedAt-l.lastVisitedAt);if(!r)return i.slice(0,n);const o=r.replace(/^https?:\/\//,"");return i.filter(l=>{const a=_w(l);return l.url===r||a===o?!1:a.includes(o)}).slice(0,n)},bc=20,ko=t=>{const e=ht((t||"").trim());return e?JSON.stringify([qt(),e]):""},Lw=t=>{const e=Object.keys(t);if(e.length<=bc)return t;const n=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,i)=>i[1]-r[1]).slice(0,bc);return Object.fromEntries(n.map(([r])=>[r,t[r]??[]]))},wr=to()(Xx(t=>({byProject:{},recordVisit:(e,n)=>{const r=ko(e);r&&t(i=>{const o=i.byProject[r]??[],l=Bw(o,{...n,at:Date.now()});return l===o?i:{byProject:Lw({...i.byProject,[r]:l})}})},forget:(e,n)=>{const r=ko(e);r&&t(i=>{const o=i.byProject[r];return o?{byProject:{...i.byProject,[r]:Fw(o,n)}}:i})},clear:e=>{const n=ko(e);n&&t(r=>{if(!(n in r.byProject))return r;const i={...r.byProject};return delete i[n],{byProject:i}})}}),{name:"openchamber-browser-history",version:1,storage:Hm(),partialize:t=>({byProject:t.byProject})})),$w=[],jf=t=>e=>{const n=ko(t);return(n?e.byProject[n]:void 0)??$w},oa=new Map,oi=new Map,sr=new Map,nr=new Set,zw=async(t,e)=>{if(!cl()){nr.delete(t),dr(t,{type:"close"});return}if(await Gm(Pn()),!nr.has(t)||!cl())return;const n=ya().websocket(`/api/dev-tunnel?port=${e}`),r=qm(n);sr.set(t,r),r.binaryType="arraybuffer",r.onopen=()=>dr(t,{type:"ready"}),r.onmessage=i=>dr(t,{type:"data",data:i.data instanceof ArrayBuffer?i.data:new TextEncoder().encode(i.data)}),r.onerror=()=>dr(t,{type:"close"}),r.onclose=()=>{nr.delete(t),sr.delete(t),dr(t,{type:"close"})}};Rp(({connectionId:t,remotePort:e,message:n})=>{switch(n.type){case"data":{const r=sr.get(t);r&&n.data&&r.send(n.data);return}case"close":nr.delete(t),sr.get(t)?.close(),sr.delete(t);return;case"connect":nr.add(t),zw(t,e).catch(()=>{nr.delete(t),dr(t,{type:"close"})})}});const kf=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Cf=t=>{if(!t)return!1;try{const e=new URL(t,typeof window<"u"?window.location.href:void 0),n=typeof window<"u"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"";return n&&e.origin===n?!1:!kr(e.toString())}catch{return!1}},Nf=t=>{try{const e=new URL(t),n=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(n)&&n>0?n:0}catch{return 0}},yc=(t,e)=>{try{const n=new URL(t);return n.protocol="http:",n.hostname="127.0.0.1",n.port=String(e),n.toString()}catch{return t}},wc=(t,e)=>{try{oi.set(e,new URL(t).origin)}catch{}};class Kr extends Error{constructor(e){super(e),this.name="DevTunnelUnavailableError"}}const vc=async t=>{if(!t||!kf()||!kr(t))return t;const e=Pn();if(!Cf(e))return t;const n=Nf(t);if(!n)return t;const r=`${e}|${n}`,i=oa.get(r);if(i)return wc(t,i),yc(t,i);try{const o=await gr("desktop_dev_tunnel_open",{baseUrl:e,port:n,relay:Ym(),targetKey:qt(),clientToken:Hr(),requestHeaders:Md()});if(!o||!Number.isInteger(o.localPort)||o.localPort<=0)throw new Kr(t);return oa.set(r,o.localPort),wc(t,o.localPort),yc(t,o.localPort)}catch(o){throw o instanceof Kr?o:new Kr(t)}},Sc=t=>{if(!t||!kf()||!kr(t)||!Cf(Pn()))return!1;const e=Nf(t);return e>0&&!oi.has(e)},Tr=t=>{if(!t)return t;try{const e=new URL(t);if(e.hostname!=="127.0.0.1")return t;const n=oi.get(Number.parseInt(e.port||"0",10));return n?`${n}${e.pathname}${e.search}${e.hash}`:t}catch{return t}},Ww=()=>{oa.clear(),oi.clear(),nr.clear();for(const t of sr.values())t.close();sr.clear(),gr("desktop_relay_dev_tunnel_close_all").catch(()=>{})};typeof window<"u"&&Qr(Ww);const jc=6e3,Kw=120,Vw=80,Uw=`
|
|
574
|
-
var MAX_ELEMENTS = ${Kw};
|
|
575
|
-
var MAX_LABEL_CHARS = ${Vw};
|
|
576
|
-
var visible = function (element) {
|
|
577
|
-
var rect = element.getBoundingClientRect();
|
|
578
|
-
if (rect.width < 1 || rect.height < 1) return false;
|
|
579
|
-
var style = window.getComputedStyle(element);
|
|
580
|
-
return style.visibility !== 'hidden' && style.display !== 'none' && Number(style.opacity) !== 0;
|
|
581
|
-
};
|
|
582
|
-
var label = function (element) {
|
|
583
|
-
var aria = element.getAttribute('aria-label');
|
|
584
|
-
if (aria) return aria.trim();
|
|
585
|
-
var value = element.getAttribute('value');
|
|
586
|
-
var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
587
|
-
if (text) return text.slice(0, MAX_LABEL_CHARS);
|
|
588
|
-
if (value) return String(value).slice(0, MAX_LABEL_CHARS);
|
|
589
|
-
var placeholder = element.getAttribute('placeholder');
|
|
590
|
-
return placeholder ? placeholder.trim().slice(0, MAX_LABEL_CHARS) : '';
|
|
591
|
-
};
|
|
592
|
-
var isUnique = function (selector) {
|
|
593
|
-
try {
|
|
594
|
-
return document.querySelectorAll(selector).length === 1;
|
|
595
|
-
} catch (error) {
|
|
596
|
-
return false;
|
|
597
|
-
}
|
|
598
|
-
};
|
|
599
|
-
|
|
600
|
-
/**
|
|
601
|
-
* Names an element by what it is, falling back to where it sits.
|
|
602
|
-
*
|
|
603
|
-
* A positional chain like 'main > section:nth-of-type(3) > div > a' survives
|
|
604
|
-
* only until the markup shifts, and says nothing about what it points at.
|
|
605
|
-
* Anything the page states about identity — an id, a test id, an accessible
|
|
606
|
-
* name — outlives edits and reads as the thing it selects. The chain remains
|
|
607
|
-
* as the last resort, because something always has to work.
|
|
608
|
-
*/
|
|
609
|
-
var cssPath = function (element) {
|
|
610
|
-
var tag = element.tagName.toLowerCase();
|
|
611
|
-
|
|
612
|
-
if (element.id) {
|
|
613
|
-
var byId = '#' + CSS.escape(element.id);
|
|
614
|
-
if (isUnique(byId)) return byId;
|
|
615
|
-
}
|
|
616
|
-
var stableAttrs = ['data-testid', 'data-test-id', 'data-test', 'name', 'aria-label'];
|
|
617
|
-
for (var a = 0; a < stableAttrs.length; a += 1) {
|
|
618
|
-
var value = element.getAttribute(stableAttrs[a]);
|
|
619
|
-
if (!value) continue;
|
|
620
|
-
var raw = String(value);
|
|
621
|
-
// A value containing a quote would need escaping for no real gain: such
|
|
622
|
-
// attributes are rare, and the positional chain still covers them.
|
|
623
|
-
if (raw.indexOf('"') !== -1) continue;
|
|
624
|
-
var byAttr = tag + '[' + stableAttrs[a] + '="' + raw + '"]';
|
|
625
|
-
if (isUnique(byAttr)) return byAttr;
|
|
626
|
-
}
|
|
627
|
-
var className = typeof element.className === 'string' ? element.className.trim() : '';
|
|
628
|
-
if (className) {
|
|
629
|
-
var classes = className.split(/\\s+/).filter(Boolean);
|
|
630
|
-
for (var c = 0; c < classes.length; c += 1) {
|
|
631
|
-
var byClass = tag + '.' + CSS.escape(classes[c]);
|
|
632
|
-
if (isUnique(byClass)) return byClass;
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
var parts = [];
|
|
637
|
-
var node = element;
|
|
638
|
-
var depth = 0;
|
|
639
|
-
while (node && node.nodeType === 1 && depth < 6) {
|
|
640
|
-
var part = node.tagName.toLowerCase();
|
|
641
|
-
var parent = node.parentElement;
|
|
642
|
-
if (!parent) { parts.unshift(part); break; }
|
|
643
|
-
var siblings = Array.prototype.filter.call(parent.children, function (child) {
|
|
644
|
-
return child.tagName === node.tagName;
|
|
645
|
-
});
|
|
646
|
-
if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
|
|
647
|
-
parts.unshift(part);
|
|
648
|
-
if (node.id) { parts[0] = '#' + CSS.escape(node.id); break; }
|
|
649
|
-
node = parent;
|
|
650
|
-
depth += 1;
|
|
651
|
-
}
|
|
652
|
-
return parts.join(' > ');
|
|
653
|
-
};
|
|
654
|
-
|
|
655
|
-
/** What a screen reader would announce, or '' when there is nothing to say. */
|
|
656
|
-
var accessibleName = function (element) {
|
|
657
|
-
var aria = element.getAttribute('aria-label');
|
|
658
|
-
if (aria && aria.trim()) return aria.trim();
|
|
659
|
-
var labelled = element.getAttribute('aria-labelledby');
|
|
660
|
-
if (labelled) {
|
|
661
|
-
var source = document.getElementById(labelled.split(/\\s+/)[0]);
|
|
662
|
-
if (source && (source.innerText || '').trim()) return source.innerText.trim();
|
|
663
|
-
}
|
|
664
|
-
var title = element.getAttribute('title');
|
|
665
|
-
if (title && title.trim()) return title.trim();
|
|
666
|
-
var alt = element.getAttribute('alt');
|
|
667
|
-
if (alt && alt.trim()) return alt.trim();
|
|
668
|
-
var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
669
|
-
if (text) return text;
|
|
670
|
-
var value = element.getAttribute('value');
|
|
671
|
-
return value && String(value).trim() ? String(value).trim() : '';
|
|
672
|
-
};
|
|
673
|
-
var findByText = function (needle) {
|
|
674
|
-
var wanted = String(needle).replace(/\\s+/g, ' ').trim().toLowerCase();
|
|
675
|
-
var candidates = document.querySelectorAll('a, button, [role="button"], [role="link"], input[type="submit"], input[type="button"], summary, label');
|
|
676
|
-
var exact = null;
|
|
677
|
-
var partial = null;
|
|
678
|
-
for (var i = 0; i < candidates.length; i += 1) {
|
|
679
|
-
var element = candidates[i];
|
|
680
|
-
if (!visible(element)) continue;
|
|
681
|
-
var text = label(element).toLowerCase();
|
|
682
|
-
if (!text) continue;
|
|
683
|
-
if (text === wanted) { exact = element; break; }
|
|
684
|
-
if (!partial && text.indexOf(wanted) !== -1) partial = element;
|
|
685
|
-
}
|
|
686
|
-
return exact || partial;
|
|
687
|
-
};
|
|
688
|
-
`,so=t=>`(() => {
|
|
689
|
-
${Uw}
|
|
690
|
-
${t}
|
|
691
|
-
})()`,Hw=({selector:t}={})=>so(`
|
|
692
|
-
var scopeSelector = ${JSON.stringify(t??"")};
|
|
693
|
-
var root = document;
|
|
694
|
-
if (scopeSelector) {
|
|
695
|
-
try { root = document.querySelector(scopeSelector); }
|
|
696
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + scopeSelector }; }
|
|
697
|
-
if (!root) return { ok: false, error: 'No element matches ' + scopeSelector };
|
|
698
|
-
}
|
|
699
|
-
var interactive = root.querySelectorAll('a[href], button, input, select, textarea, [role="button"], [role="link"], [role="tab"], [contenteditable="true"]');
|
|
700
|
-
var elements = [];
|
|
701
|
-
var visibleTotal = 0;
|
|
702
|
-
for (var i = 0; i < interactive.length; i += 1) {
|
|
703
|
-
var element = interactive[i];
|
|
704
|
-
if (!visible(element)) continue;
|
|
705
|
-
visibleTotal += 1;
|
|
706
|
-
if (elements.length >= MAX_ELEMENTS) continue;
|
|
707
|
-
|
|
708
|
-
var rect = element.getBoundingClientRect();
|
|
709
|
-
// Empty and default-valued fields are left out rather than serialized as
|
|
710
|
-
// "" and false. Repeated across a hundred entries that overhead dwarfed
|
|
711
|
-
// the information it carried.
|
|
712
|
-
var entry = {
|
|
713
|
-
selector: cssPath(element),
|
|
714
|
-
tag: element.tagName.toLowerCase(),
|
|
715
|
-
bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) }
|
|
716
|
-
};
|
|
717
|
-
// The list covers the whole document so anything can be clicked without
|
|
718
|
-
// scrolling to it first, which means bounds alone do not say what is on
|
|
719
|
-
// screen — a negative y reads as a bug otherwise.
|
|
720
|
-
if (rect.bottom > 0 && rect.top < window.innerHeight) entry.inViewport = true;
|
|
721
|
-
var type = element.getAttribute('type');
|
|
722
|
-
if (type) entry.type = type;
|
|
723
|
-
var role = element.getAttribute('role');
|
|
724
|
-
if (role) entry.role = role;
|
|
725
|
-
var labelText = label(element);
|
|
726
|
-
if (labelText) entry.label = labelText;
|
|
727
|
-
if (element.disabled === true) entry.disabled = true;
|
|
728
|
-
// Flagged rather than described: reporting the accessible name of every
|
|
729
|
-
// element would cost more than it tells, while its absence on something
|
|
730
|
-
// clickable is a defect worth naming.
|
|
731
|
-
if (!accessibleName(element)) entry.missingAccessibleName = true;
|
|
732
|
-
elements.push(entry);
|
|
733
|
-
}
|
|
734
|
-
var body = document.body ? (document.body.innerText || '') : '';
|
|
735
|
-
var text = body.replace(/\\n{3,}/g, '\\n\\n').trim();
|
|
736
|
-
var docEl = document.documentElement;
|
|
737
|
-
var result = {
|
|
738
|
-
ok: true,
|
|
739
|
-
url: String(location.href),
|
|
740
|
-
title: String(document.title || ''),
|
|
741
|
-
scope: scopeSelector || 'document',
|
|
742
|
-
scrollY: Math.round(window.scrollY),
|
|
743
|
-
maxScrollY: Math.max(0, Math.round(docEl.scrollHeight - window.innerHeight)),
|
|
744
|
-
text: text.slice(0, ${jc}),
|
|
745
|
-
elements: elements
|
|
746
|
-
};
|
|
747
|
-
// State what was dropped. A capped list that reports only its own length
|
|
748
|
-
// reads as the whole page, and the agent acts as if it had seen everything.
|
|
749
|
-
if (text.length > ${jc}) {
|
|
750
|
-
result.textTruncated = true;
|
|
751
|
-
result.textTotalChars = text.length;
|
|
752
|
-
}
|
|
753
|
-
if (visibleTotal > elements.length) {
|
|
754
|
-
result.elementsTruncated = true;
|
|
755
|
-
result.interactiveElementsOnPage = visibleTotal;
|
|
756
|
-
}
|
|
757
|
-
return result;
|
|
758
|
-
`),Gw=({selector:t,text:e})=>so(`
|
|
759
|
-
var selector = ${JSON.stringify(t??"")};
|
|
760
|
-
var text = ${JSON.stringify(e??"")};
|
|
761
|
-
var target = null;
|
|
762
|
-
if (selector) {
|
|
763
|
-
try { target = document.querySelector(selector); }
|
|
764
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
765
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
766
|
-
} else {
|
|
767
|
-
target = findByText(text);
|
|
768
|
-
if (!target) return { ok: false, error: 'No clickable element has the label ' + text };
|
|
769
|
-
}
|
|
770
|
-
if (target.disabled === true) return { ok: false, error: 'Element is disabled' };
|
|
771
|
-
target.scrollIntoView({ block: 'center', inline: 'center' });
|
|
772
|
-
target.click();
|
|
773
|
-
return { ok: true, clicked: cssPath(target), label: label(target), url: String(location.href) };
|
|
774
|
-
`),qw=({selector:t,value:e,submit:n})=>so(`
|
|
775
|
-
var selector = ${JSON.stringify(t)};
|
|
776
|
-
var value = ${JSON.stringify(e)};
|
|
777
|
-
var target = null;
|
|
778
|
-
try { target = document.querySelector(selector); }
|
|
779
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
780
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
781
|
-
|
|
782
|
-
var editable = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable;
|
|
783
|
-
if (!editable) return { ok: false, error: selector + ' is not a text field' };
|
|
784
|
-
if (target.disabled === true || target.readOnly === true) return { ok: false, error: 'Field is not editable' };
|
|
785
|
-
|
|
786
|
-
target.scrollIntoView({ block: 'center' });
|
|
787
|
-
target.focus();
|
|
788
|
-
if (target.isContentEditable) {
|
|
789
|
-
target.textContent = value;
|
|
790
|
-
} else {
|
|
791
|
-
// Frameworks track the value through the native setter; assigning the
|
|
792
|
-
// property directly leaves React and friends unaware of the change.
|
|
793
|
-
var prototype = target.tagName === 'TEXTAREA' ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
|
|
794
|
-
var setter = Object.getOwnPropertyDescriptor(prototype, 'value');
|
|
795
|
-
if (setter && setter.set) setter.set.call(target, value);
|
|
796
|
-
else target.value = value;
|
|
797
|
-
}
|
|
798
|
-
target.dispatchEvent(new Event('input', { bubbles: true }));
|
|
799
|
-
target.dispatchEvent(new Event('change', { bubbles: true }));
|
|
800
|
-
|
|
801
|
-
if (${n?"true":"false"}) {
|
|
802
|
-
var enter = { key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true };
|
|
803
|
-
target.dispatchEvent(new KeyboardEvent('keydown', enter));
|
|
804
|
-
target.dispatchEvent(new KeyboardEvent('keyup', enter));
|
|
805
|
-
var form = target.form;
|
|
806
|
-
if (form && typeof form.requestSubmit === 'function') form.requestSubmit();
|
|
807
|
-
}
|
|
808
|
-
return { ok: true, selector: cssPath(target), url: String(location.href) };
|
|
809
|
-
`),Yw=({selector:t,direction:e})=>so(`
|
|
810
|
-
var selector = ${JSON.stringify(t??"")};
|
|
811
|
-
var direction = ${JSON.stringify(e??"")};
|
|
812
|
-
|
|
813
|
-
var settle = function (extra) {
|
|
814
|
-
return new Promise(function (resolve) {
|
|
815
|
-
requestAnimationFrame(function () {
|
|
816
|
-
requestAnimationFrame(function () {
|
|
817
|
-
var doc = document.documentElement;
|
|
818
|
-
var maxScrollY = Math.max(0, doc.scrollHeight - window.innerHeight);
|
|
819
|
-
var scrollY = Math.round(window.scrollY);
|
|
820
|
-
var result = { ok: true, scrollY: scrollY, maxScrollY: Math.round(maxScrollY) };
|
|
821
|
-
result.atTop = scrollY <= 1;
|
|
822
|
-
result.atBottom = scrollY >= maxScrollY - 1;
|
|
823
|
-
for (var key in extra) {
|
|
824
|
-
if (Object.prototype.hasOwnProperty.call(extra, key)) result[key] = extra[key];
|
|
825
|
-
}
|
|
826
|
-
resolve(result);
|
|
827
|
-
});
|
|
828
|
-
});
|
|
829
|
-
});
|
|
830
|
-
};
|
|
831
|
-
|
|
832
|
-
if (selector) {
|
|
833
|
-
var target = null;
|
|
834
|
-
try { target = document.querySelector(selector); }
|
|
835
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
836
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
837
|
-
// Instant on purpose: the page's own smooth scrolling would still be
|
|
838
|
-
// animating when the next action runs against it.
|
|
839
|
-
target.scrollIntoView({ block: 'center', behavior: 'instant' });
|
|
840
|
-
return settle({ scrolledTo: cssPath(target) });
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
var doc = document.documentElement;
|
|
844
|
-
var page = Math.round(window.innerHeight * 0.85);
|
|
845
|
-
var bottom = Math.max(0, doc.scrollHeight - window.innerHeight);
|
|
846
|
-
if (direction === 'down') window.scrollTo({ top: window.scrollY + page, behavior: 'instant' });
|
|
847
|
-
else if (direction === 'up') window.scrollTo({ top: window.scrollY - page, behavior: 'instant' });
|
|
848
|
-
else if (direction === 'top') window.scrollTo({ top: 0, behavior: 'instant' });
|
|
849
|
-
else if (direction === 'bottom') window.scrollTo({ top: bottom, behavior: 'instant' });
|
|
850
|
-
else return { ok: false, error: 'Unknown scroll direction: ' + direction };
|
|
851
|
-
return settle({ direction: direction });
|
|
852
|
-
`),Qw=["color","background-color","background-image","opacity","font-family","font-size","font-weight","line-height","letter-spacing","text-align","border-radius","border-width","border-style","border-color","box-shadow","display","position","width","height","padding","margin","gap","flex-direction","justify-content","align-items","z-index","overflow","visibility"],Xw=({selector:t})=>so(`
|
|
853
|
-
var selector = ${JSON.stringify(t)};
|
|
854
|
-
var target = null;
|
|
855
|
-
try { target = document.querySelector(selector); }
|
|
856
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
857
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
858
|
-
|
|
859
|
-
var computed = window.getComputedStyle(target);
|
|
860
|
-
var styles = {};
|
|
861
|
-
var props = ${JSON.stringify(Qw)};
|
|
862
|
-
for (var i = 0; i < props.length; i += 1) {
|
|
863
|
-
var value = computed.getPropertyValue(props[i]);
|
|
864
|
-
if (value) styles[props[i]] = String(value).trim();
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
var rect = target.getBoundingClientRect();
|
|
868
|
-
return {
|
|
869
|
-
ok: true,
|
|
870
|
-
selector: cssPath(target),
|
|
871
|
-
tag: target.tagName.toLowerCase(),
|
|
872
|
-
label: label(target),
|
|
873
|
-
bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) },
|
|
874
|
-
inViewport: rect.bottom > 0 && rect.top < window.innerHeight,
|
|
875
|
-
styles: styles
|
|
876
|
-
};
|
|
877
|
-
`),Jw=t=>{const e=Ze.c(18),{entries:n,activeIndex:r,onSelect:i,onForget:o,onHighlight:l}=t,{t:a}=jt();if(n.length===0)return null;let d;e[0]!==a?(d=a("contextPanel.browser.history.label"),e[0]=a,e[1]=d):d=e[1];let u;if(e[2]!==r||e[3]!==n||e[4]!==o||e[5]!==l||e[6]!==i||e[7]!==a){let f;e[9]!==r||e[10]!==o||e[11]!==l||e[12]!==i||e[13]!==a?(f=(x,b)=>s.jsxs("div",{role:"option","aria-selected":b===r,className:Oe("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",b===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:w=>{w.preventDefault(),i(x.url)},onPointerEnter:()=>l(b),children:[s.jsx(M,{name:"global",className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate typography-micro text-foreground",children:x.title||Qa(x.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:x.url})]}),s.jsx("button",{type:"button",className:Oe("shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity","hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100"),"aria-label":a("contextPanel.browser.history.forget"),title:a("contextPanel.browser.history.forget"),onPointerDown:w=>{w.preventDefault(),w.stopPropagation(),o(x.url)},children:s.jsx(M,{name:"close",className:"size-3","aria-hidden":"true"})})]},x.url),e[9]=r,e[10]=o,e[11]=l,e[12]=i,e[13]=a,e[14]=f):f=e[14],u=n.map(f),e[2]=r,e[3]=n,e[4]=o,e[5]=l,e[6]=i,e[7]=a,e[8]=u}else u=e[8];let h;return e[15]!==d||e[16]!==u?(h=s.jsx("div",{className:"oc-glass-popover oc-glass-floating absolute inset-x-0 top-full z-50 mt-1 overflow-hidden rounded-xl p-1",role:"listbox","aria-label":d,children:u}),e[15]=d,e[16]=u,e[17]=h):h=e[17],h},tn=t=>{const e=Ze.c(17),{icon:n,label:r,onClick:i,disabled:o,pressed:l}=t,a=l?"secondary":"ghost",d=l&&"text-foreground";let u;e[0]!==d?(u=Oe("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",d),e[0]=d,e[1]=u):u=e[1];let h;e[2]!==n?(h=s.jsx(M,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,e[3]=h):h=e[3];let f;e[4]!==o||e[5]!==r||e[6]!==i||e[7]!==l||e[8]!==a||e[9]!==u||e[10]!==h?(f=s.jsx(At,{asChild:!0,children:s.jsx(dt,{type:"button",variant:a,size:"xs",className:u,onClick:i,disabled:o,"aria-label":r,"aria-pressed":l,children:h})}),e[4]=o,e[5]=r,e[6]=i,e[7]=l,e[8]=a,e[9]=u,e[10]=h,e[11]=f):f=e[11];let x;e[12]!==r?(x=s.jsx(Dt,{sideOffset:6,children:r}),e[12]=r,e[13]=x):x=e[13];let b;return e[14]!==f||e[15]!==x?(b=s.jsxs(Nt,{children:[f,x]}),e[14]=f,e[15]=x,e[16]=b):b=e[16],b},Af=t=>{const e=Ze.c(104),{address:n,suggestions:r,onForgetSuggestion:i,onAddressChange:o,onSubmit:l,onBack:a,onForward:d,onReload:u,onOpenExternal:h,canGoBack:f,canGoForward:x,isLoading:b,onAnnotate:w,onOpenDevTools:v,isAnnotating:y,onHardReload:m,onZoomIn:p,onZoomOut:S,onZoomReset:g,zoomPercent:C,onClearCookies:k,onClearCache:j,onToggleDeviceBar:D,isDeviceBarOpen:I}=t;let A;e[0]!==r?(A=r===void 0?[]:r,e[0]=r,e[1]=A):A=e[1];const P=A,T=C===void 0?100:C,{t:L}=jt(),[$,K]=c.useState(!1),[F,W]=c.useState(-1);let N;e[2]!==$||e[3]!==P?(N=$?P:[],e[2]=$,e[3]=P,e[4]=N):N=e[4];const R=N;let E;e[5]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{W(-1)},e[5]=E):E=e[5];let X;e[6]!==n||e[7]!==$?(X=[n,$],e[6]=n,e[7]=$,e[8]=X):X=e[8],c.useEffect(E,X);let J;e[9]!==l?(J=Ee=>{K(!1),W(-1),l(Ee)},e[9]=l,e[10]=J):J=e[10];const re=J;let fe;e[11]!==F||e[12]!==re||e[13]!==R?(fe=Ee=>{if(R.length!==0){if(Ee.key==="ArrowDown"||Ee.key==="ArrowUp"){Ee.preventDefault();const xe=Ee.key==="ArrowDown"?1:-1,$e=R.length;W(V=>{const De=V+xe;return De<-1?$e-1:De>=$e?-1:De});return}if(Ee.key==="Escape"&&F>=0){Ee.preventDefault(),W(-1);return}if(Ee.key==="Enter"&&F>=0){Ee.preventDefault();const xe=R[F];xe&&re(xe.url)}}},e[11]=F,e[12]=re,e[13]=R,e[14]=fe):fe=e[14];const ne=fe;let te;e[15]!==L?(te=L("contextPanel.browser.back"),e[15]=L,e[16]=te):te=e[16];const ue=!f;let Se;e[17]!==a||e[18]!==ue||e[19]!==te?(Se=s.jsx(tn,{icon:"arrow-left",label:te,onClick:a,disabled:ue}),e[17]=a,e[18]=ue,e[19]=te,e[20]=Se):Se=e[20];let we;e[21]!==L?(we=L("contextPanel.browser.forward"),e[21]=L,e[22]=we):we=e[22];const ye=!x;let Ae;e[23]!==d||e[24]!==we||e[25]!==ye?(Ae=s.jsx(tn,{icon:"arrow-right",label:we,onClick:d,disabled:ye}),e[23]=d,e[24]=we,e[25]=ye,e[26]=Ae):Ae=e[26];let pe;e[27]!==b||e[28]!==L?(pe=L(b?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=b,e[28]=L,e[29]=pe):pe=e[29];let O;e[30]!==u||e[31]!==pe?(O=s.jsx(tn,{icon:"refresh",label:pe,onClick:u}),e[30]=u,e[31]=pe,e[32]=O):O=e[32];let Q;e[33]!==m||e[34]!==L?(Q=m?s.jsx(tn,{icon:"restart",label:L("contextPanel.browser.hardReload"),onClick:m}):null,e[33]=m,e[34]=L,e[35]=Q):Q=e[35];let le;e[36]!==n||e[37]!==re?(le=Ee=>{Ee.preventDefault(),re(n)},e[36]=n,e[37]=re,e[38]=le):le=e[38];let H;e[39]!==o?(H=Ee=>o(Ee.target.value),e[39]=o,e[40]=H):H=e[40];let me,ge;e[41]===Symbol.for("react.memo_cache_sentinel")?(me=()=>K(!0),ge=()=>K(!1),e[41]=me,e[42]=ge):(me=e[41],ge=e[42]);const oe=R.length>0;let de;e[43]===Symbol.for("react.memo_cache_sentinel")?(de=Oe("h-6 w-full rounded-full border border-border/50 bg-[var(--surface-elevated)] px-3","typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[43]=de):de=e[43];let _;e[44]!==L?(_=L("contextPanel.browser.addressAria"),e[44]=L,e[45]=_):_=e[45];let B;e[46]!==n||e[47]!==ne||e[48]!==H||e[49]!==oe||e[50]!==_?(B=s.jsx("input",{value:n,onChange:H,onFocus:me,onBlur:ge,onKeyDown:ne,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":oe,"aria-controls":"openchamber-browser-address-suggestions",className:de,"aria-label":_}),e[46]=n,e[47]=ne,e[48]=H,e[49]=oe,e[50]=_,e[51]=B):B=e[51];let he;e[52]!==i?(he=Ee=>i?.(Ee),e[52]=i,e[53]=he):he=e[53];let ve;e[54]!==F||e[55]!==re||e[56]!==he||e[57]!==R?(ve=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(Jw,{entries:R,activeIndex:F,onSelect:re,onForget:he,onHighlight:W})}),e[54]=F,e[55]=re,e[56]=he,e[57]=R,e[58]=ve):ve=e[58];let Re;e[59]!==le||e[60]!==B||e[61]!==ve?(Re=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:le,children:[B,ve]}),e[59]=le,e[60]=B,e[61]=ve,e[62]=Re):Re=e[62];let ce;e[63]!==p||e[64]!==S||e[65]!==g||e[66]!==L||e[67]!==T?(ce=S&&p?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(tn,{icon:"subtract",label:L("contextPanel.browser.zoomOut"),onClick:S}),T!==100&&g?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsxs(dt,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:g,"aria-label":L("contextPanel.browser.zoomReset"),children:[T,"%"]})}),s.jsx(Dt,{sideOffset:6,children:L("contextPanel.browser.zoomReset")})]}):null,s.jsx(tn,{icon:"add",label:L("contextPanel.browser.zoomIn"),onClick:p})]}):null,e[63]=p,e[64]=S,e[65]=g,e[66]=L,e[67]=T,e[68]=ce):ce=e[68];let se;e[69]!==k||e[70]!==L?(se=k?s.jsx(tn,{icon:"delete-bin",label:L("contextPanel.browser.clearCookies"),onClick:k}):null,e[69]=k,e[70]=L,e[71]=se):se=e[71];let q;e[72]!==j||e[73]!==L?(q=j?s.jsx(tn,{icon:"database-2",label:L("contextPanel.browser.clearCache"),onClick:j}):null,e[72]=j,e[73]=L,e[74]=q):q=e[74];let z;e[75]!==I||e[76]!==D||e[77]!==L?(z=D?s.jsx(tn,{icon:"smartphone",label:L("contextPanel.browser.deviceToolbar"),onClick:D,pressed:I}):null,e[75]=I,e[76]=D,e[77]=L,e[78]=z):z=e[78];let ee;e[79]!==y||e[80]!==w||e[81]!==L?(ee=w?s.jsx(tn,{icon:"markup",label:L("contextPanel.browser.annotate.toggle"),onClick:w,pressed:y}):null,e[79]=y,e[80]=w,e[81]=L,e[82]=ee):ee=e[82];let ae;e[83]!==v||e[84]!==L?(ae=v?s.jsx(tn,{icon:"terminal-box",label:L("contextPanel.browser.devTools"),onClick:v}):null,e[83]=v,e[84]=L,e[85]=ae):ae=e[85];let Ne;e[86]!==L?(Ne=L("contextPanel.browser.openExternal"),e[86]=L,e[87]=Ne):Ne=e[87];let Ce;e[88]!==h||e[89]!==Ne?(Ce=s.jsx(tn,{icon:"external-link",label:Ne,onClick:h}),e[88]=h,e[89]=Ne,e[90]=Ce):Ce=e[90];let We;return e[91]!==Se||e[92]!==Ae||e[93]!==O||e[94]!==Q||e[95]!==Re||e[96]!==ce||e[97]!==se||e[98]!==q||e[99]!==z||e[100]!==ee||e[101]!==ae||e[102]!==Ce?(We=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[Se,Ae,O,Q,Re,ce,se,q,z,ee,ae,Ce]}),e[91]=Se,e[92]=Ae,e[93]=O,e[94]=Q,e[95]=Re,e[96]=ce,e[97]=se,e[98]=q,e[99]=z,e[100]=ee,e[101]=ae,e[102]=Ce,e[103]=We):We=e[103],We},Oo={kind:"fill"},kc=240,Zw=3840,Df=[{id:"iphone-se",label:"iPhone SE",width:375,height:667},{id:"iphone-14",label:"iPhone 14",width:390,height:844},{id:"iphone-14-pro-max",label:"iPhone 14 Pro Max",width:430,height:932},{id:"pixel-7",label:"Pixel 7",width:412,height:915},{id:"ipad-mini",label:"iPad mini",width:768,height:1024},{id:"ipad-pro",label:"iPad Pro",width:1024,height:1366},{id:"laptop",label:"Laptop",width:1280,height:800},{id:"desktop",label:"Desktop",width:1440,height:900}],Cc=t=>Number.isFinite(t)?Math.round(Math.min(Zw,Math.max(kc,t))):kc,Bo=t=>t.kind==="fill"?null:{width:t.width,height:t.height},Pf=t=>{const e=Df.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},ev=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},tv=(t,e)=>{const n=Bo(t);if(!n)return null;const r=Math.max(1,e.width),i=Math.max(1,e.height),o=Math.min(1,r/n.width,i/n.height);return{width:n.width,height:n.height,scale:o}},sv=["mobile","tablet","desktop","fill"],nv={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},Nc=t=>typeof t=="string"&&sv.includes(t),ia=t=>t==="fill"?Oo:Pf(nv[t])??Oo,co=t=>{const e=Bo(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=ia(n),i=Bo(r);if(i&&i.width===e.width&&i.height===e.height)return{mode:n,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},rv=t=>{const e=Ze.c(70),{viewport:n,onViewportChange:r,colorScheme:i,onColorSchemeChange:o,scale:l}=t,{t:a}=jt();let d;e[0]!==n?(d=Bo(n),e[0]=n,e[1]=d):d=e[1];const u=d,h=n.kind==="preset"?n.id:"";let f;e[2]!==r||e[3]!==u?(f=(ue,Se)=>{const we=Number.parseInt(Se,10);if(!Number.isFinite(we))return;const ye=u??{width:1280,height:800};r({kind:"custom",width:Cc(ue==="width"?we:ye.width),height:Cc(ue==="height"?we:ye.height)})},e[2]=r,e[3]=u,e[4]=f):f=e[4];const x=f;let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=Oe("h-6 w-14 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2 text-center","typography-micro tabular-nums text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[5]=b):b=e[5];const w=b;let v;e[6]!==r?(v=ue=>{const Se=Pf(ue.target.value);r(Se??Oo)},e[6]=r,e[7]=v):v=e[7];let y;e[8]!==a?(y=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=y):y=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=Oe("h-6 shrink-0 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2","typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[10]=m):m=e[10];let p;e[11]!==a?(p=a("contextPanel.browser.device.responsive"),e[11]=a,e[12]=p):p=e[12];let S;e[13]!==p?(S=s.jsx("option",{value:"",children:p}),e[13]=p,e[14]=S):S=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=Df.map(ov),e[15]=g):g=e[15];let C;e[16]!==h||e[17]!==v||e[18]!==y||e[19]!==S?(C=s.jsxs("select",{value:h,onChange:v,"aria-label":y,className:m,children:[S,g]}),e[16]=h,e[17]=v,e[18]=y,e[19]=S,e[20]=C):C=e[20];const k=u?String(u.width):"";let j;e[21]!==x?(j=ue=>x("width",ue.target.value),e[21]=x,e[22]=j):j=e[22];let D;e[23]!==a?(D=a("contextPanel.browser.device.width"),e[23]=a,e[24]=D):D=e[24];let I;e[25]!==k||e[26]!==j||e[27]!==D?(I=s.jsx("input",{value:k,onChange:j,placeholder:"—",inputMode:"numeric","aria-label":D,className:w}),e[25]=k,e[26]=j,e[27]=D,e[28]=I):I=e[28];let A;e[29]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=A):A=e[29];const P=u?String(u.height):"";let T;e[30]!==x?(T=ue=>x("height",ue.target.value),e[30]=x,e[31]=T):T=e[31];let L;e[32]!==a?(L=a("contextPanel.browser.device.height"),e[32]=a,e[33]=L):L=e[33];let $;e[34]!==P||e[35]!==T||e[36]!==L?($=s.jsx("input",{value:P,onChange:T,placeholder:"—",inputMode:"numeric","aria-label":L,className:w}),e[34]=P,e[35]=T,e[36]=L,e[37]=$):$=e[37];let K;e[38]!==r||e[39]!==n?(K=()=>r(ev(n)),e[38]=r,e[39]=n,e[40]=K):K=e[40];const F=!u;let W;e[41]!==a?(W=a("contextPanel.browser.device.rotate"),e[41]=a,e[42]=W):W=e[42];let N;e[43]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx(M,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=N):N=e[43];let R;e[44]!==K||e[45]!==F||e[46]!==W?(R=s.jsx(At,{asChild:!0,children:s.jsx(dt,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:K,disabled:F,"aria-label":W,children:N})}),e[44]=K,e[45]=F,e[46]=W,e[47]=R):R=e[47];let E;e[48]!==a?(E=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=E):E=e[49];let X;e[50]!==E?(X=s.jsx(Dt,{sideOffset:6,children:E}),e[50]=E,e[51]=X):X=e[51];let J;e[52]!==R||e[53]!==X?(J=s.jsxs(Nt,{children:[R,X]}),e[52]=R,e[53]=X,e[54]=J):J=e[54];let re;e[55]!==l||e[56]!==u?(re=u&&l<1?s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(l*100),"%"]}):null,e[55]=l,e[56]=u,e[57]=re):re=e[57];let fe;e[58]===Symbol.for("react.memo_cache_sentinel")?(fe=["system","light","dark"],e[58]=fe):fe=e[58];let ne;e[59]!==i||e[60]!==o||e[61]!==a?(ne=s.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:fe.map(ue=>s.jsx(dt,{type:"button",variant:i===ue?"secondary":"ghost",size:"xs",className:Oe("shrink-0 rounded-full px-2.5 typography-micro",i===ue?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>o(ue),"aria-pressed":i===ue,children:a(ue==="system"?"contextPanel.browser.device.schemeSystem":ue==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},ue))}),e[59]=i,e[60]=o,e[61]=a,e[62]=ne):ne=e[62];let te;return e[63]!==C||e[64]!==I||e[65]!==$||e[66]!==J||e[67]!==re||e[68]!==ne?(te=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[C,I,A,$,J,re,ne]}),e[63]=C,e[64]=I,e[65]=$,e[66]=J,e[67]=re,e[68]=ne,e[69]=te):te=e[69],te};function ov(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const iv=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},av=2e3,lv=()=>{if(typeof window>"u"||window.__OPENCHAMBER_ELECTRON__)return!1;const t=Pn();if(!t)return!1;try{return!kr(new URL(t,window.location.href).toString())}catch{return!1}},If=t=>{const e=Ze.c(33),{onOpen:n,directory:r}=t,i=r===void 0?"":r,{t:o}=jt();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={kind:"loading"},e[0]=l):l=e[0];const[a,d]=c.useState(l),u=Sb(i),[h]=c.useState(lv);let f,x;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{let I=!0,A=null;const P=new AbortController,T=()=>{rw(P.signal).then(L=>{I&&(d(L),A=setTimeout(T,av))})};return T(),()=>{I=!1,A&&clearTimeout(A),P.abort()}},x=[],e[1]=f,e[2]=x):(f=e[1],x=e[2]),c.useEffect(f,x);const b=a.kind==="ready"?a.servers:null;let w;e[3]!==u||e[4]!==b?(w=aw({announced:u,discovered:b}),e[3]=u,e[4]=b,e[5]=w):w=e[5];const v=w;let y;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(yu,{width:110,height:110,className:"shrink-0 opacity-20"}),e[6]=y):y=e[6];let m;e[7]!==o?(m=o("contextPanel.browser.empty"),e[7]=o,e[8]=m):m=e[8];let p;e[9]!==m?(p=s.jsx("span",{className:"typography-ui-header text-foreground",children:m}),e[9]=m,e[10]=p):p=e[10];let S;e[11]!==o?(S=o("contextPanel.browser.emptyHint"),e[11]=o,e[12]=S):S=e[12];let g;e[13]!==S?(g=s.jsx("span",{className:"typography-micro text-muted-foreground",children:S}),e[13]=S,e[14]=g):g=e[14];let C;e[15]!==g||e[16]!==p?(C=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[p,g]}),e[15]=g,e[16]=p,e[17]=C):C=e[17];let k;e[18]!==u||e[19]!==v||e[20]!==i||e[21]!==n||e[22]!==h||e[23]!==o?(k=v.length>0?s.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[s.jsx("span",{className:"shrink-0 typography-micro text-left text-muted-foreground",children:u.length>0?o("contextPanel.browser.devServers.justStarted"):o("contextPanel.browser.devServers.title")}),h?s.jsx("span",{className:"shrink-0 pb-1 text-left typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.remoteOnly")}):null,s.jsx("div",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto pr-0.5",children:v.map(I=>s.jsxs(dt,{type:"button",variant:"outline",size:"sm",className:"w-full shrink-0 justify-start gap-2",onClick:()=>{yb(i),n(I.url)},children:[s.jsx(M,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:Qa(I.url)||I.url}),s.jsx("span",{className:"ml-auto truncate typography-micro text-muted-foreground",children:iv(I.url)})]},I.port))})]}):null,e[18]=u,e[19]=v,e[20]=i,e[21]=n,e[22]=h,e[23]=o,e[24]=k):k=e[24];let j;e[25]!==v.length||e[26]!==a.kind||e[27]!==o?(j=v.length===0&&a.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.unavailable")}):null,e[25]=v.length,e[26]=a.kind,e[27]=o,e[28]=j):j=e[28];let D;return e[29]!==C||e[30]!==k||e[31]!==j?(D=s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-5 overflow-hidden bg-background p-6 text-center",children:[y,C,k,j]}),e[29]=C,e[30]=k,e[31]=j,e[32]=D):D=e[32],D},Ls=t=>Math.round(t),cv=(t,e)=>{const n=t.text.trim(),r=Object.entries(t.attributes).map(([a,d])=>`${a}="${d}"`).join(" "),i=t.ancestry.map(a=>a.selectorPart).join(" > "),o=t.computedStyle,l=t.bounds;return[`Element ${e+1}: ${t.tag}`,n?`- Text: ${n}`:null,`- Selector: ${t.selector}`,`- Path: ${t.path}`,i?`- Ancestry: ${i}`:null,r?`- Attributes: ${r}`:null,`- Bounds: x=${Ls(l.x)}, y=${Ls(l.y)}, width=${Ls(l.width)}, height=${Ls(l.height)}`,`- Styles: display=${o.display??""}; position=${o.position??""}; font=${o.fontWeight??""} ${o.fontSize??""} / ${o.lineHeight??""} ${o.fontFamily??""}; color=${o.color??""}; background=${o.backgroundColor??""}`].filter(a=>typeof a=="string")},dv=(t,e)=>{const n=t.rect;return`Region ${e+1}: x=${Ls(n.x)}, y=${Ls(n.y)}, width=${Ls(n.width)}, height=${Ls(n.height)}`},uv=(t,e)=>{const n=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${Ls(n.x)}, y=${Ls(n.y)}, width=${Ls(n.width)}, height=${Ls(n.height)}`},fv=({payload:t,screenshotAttached:e,intro:n})=>{const r=n.replace(/[.:]+$/g,""),i=t.comment.trim(),o=[`${r}:`,`Page: ${t.pageTitle.trim()||t.pageUrl||"browser"}`,t.pageTitle.trim()&&t.pageUrl?`URL: ${t.pageUrl}`:null,`Viewport: ${Ls(t.viewport.width)}x${Ls(t.viewport.height)}, DPR ${t.devicePixelRatio}`,`Screenshot: ${e?"attached":"not attached"}`,i?`Comment: ${i}`:null];for(const[l,a]of t.elements.entries())o.push("",...cv(a.element,l));return t.regions.length>0&&(o.push(""),t.regions.forEach((l,a)=>o.push(dv(l,a)))),t.strokes.length>0&&(o.push(""),t.strokes.forEach((l,a)=>o.push(uv(l,a)))),o.filter(l=>typeof l=="string").join(`
|
|
878
|
-
`)},mv=t=>{const e=Ze.c(7),{t:n}=jt(),r=tt(pv),i=tt(gv),o=Oi(xv),l=Mp(bv);let a;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==t||e[4]!==i||e[5]!==n?(a=async d=>{const u=r??(i?"draft":null);if(!u){Le.error(n("contextPanel.browser.annotate.noSession"));return}let h=!1;if(d.screenshot)try{await l(d.screenshot),h=!0}catch{h=!1}o({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:d.payload.pageUrl||"browser",startLine:1,endLine:1,code:fv({payload:d.payload,screenshotAttached:h,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),Le.success(n("contextPanel.browser.annotate.attached"))},e[0]=l,e[1]=o,e[2]=r,e[3]=t,e[4]=i,e[5]=n,e[6]=a):a=e[6],a},hv=()=>{const t=Ze.c(16),{t:e}=jt();let n;t[0]!==e?(n=e("contextPanel.browser.annotate.tool.element"),t[0]=e,t[1]=n):n=t[1];let r;t[2]!==e?(r=e("contextPanel.browser.annotate.tool.region"),t[2]=e,t[3]=r):r=t[3];let i;t[4]!==e?(i=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=i):i=t[5];let o;t[6]!==e?(o=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=o):o=t[7];let l;t[8]!==e?(l=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=l):l=t[9];let a;return t[10]!==n||t[11]!==r||t[12]!==i||t[13]!==o||t[14]!==l?(a={select:n,marquee:r,draw:i,commentPlaceholder:o,submit:l},t[10]=n,t[11]=r,t[12]=i,t[13]=o,t[14]=l,t[15]=a):a=t[15],a};function pv(t){return t.currentSessionId}function gv(t){return t.newSessionDraft?.open}function xv(t){return t.addDraft}function bv(t){return t.addAttachedFile}const yv=3e4,wv=3,vv=250,Sv={attempts:0,windowStartedAt:null},jv=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=yv,r=n?0:t.attempts;return r>=wv?null:{delayMs:vv*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},kv=-3,uo=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",hr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},Cv=(t,{initialUrl:e,onUrlChange:n})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:dw),[o,l]=c.useState(e),[a,d]=c.useState(""),[u,h]=c.useState(!1),[f,x]=c.useState(!1),b=c.useRef(n);b.current=n;const w=c.useRef(Sv);return c.useEffect(()=>{if(!t)return;const v=()=>{try{const A=t.getURL();return uo(A)?A:""}catch{return""}},y=()=>{try{h(t.canGoBack()),x(t.canGoForward())}catch{}},m=A=>{uo(A)&&(l(A),b.current(A))},p=()=>{const A=v();i({kind:"loading",url:A})},S=()=>{const A=v();let P="";try{P=t.getTitle()||""}catch{P=""}d(P),m(A),y(),i(T=>T.kind==="failed"&&T.url===A?T:{kind:"ready",url:A,title:P})},g=A=>{const P=hr(A);uo(P.url)&&(m(P.url),y())},C=A=>{const P=hr(A),T=Array.isArray(P.favicons)?P.favicons.find(Boolean):"",L=v();T&&L&&gf.getState().resolve(L,T)},k=A=>{const P=hr(A);typeof P.title=="string"&&d(P.title)},j=A=>{const P=hr(A);if(P.isMainFrame===!1)return;const T=typeof P.errorCode=="number"?P.errorCode:0;T!==kv&&i({kind:"failed",url:uo(P.validatedURL)?P.validatedURL:v(),code:T,description:typeof P.errorDescription=="string"?P.errorDescription:""})};let D=null;const I=()=>{const A=v(),P=jv(w.current,Date.now());if(!P){i({kind:"failed",url:A,code:0,description:"",crashed:!0});return}w.current=P.state,i({kind:"loading",url:A}),D=setTimeout(()=>{D=null;try{t.reload()}catch{i({kind:"failed",url:A,code:0,description:"",crashed:!0})}},P.delayMs)};t.addEventListener("did-start-loading",p),t.addEventListener("did-stop-loading",S),t.addEventListener("did-navigate",g),t.addEventListener("did-navigate-in-page",g),t.addEventListener("page-title-updated",k),t.addEventListener("page-favicon-updated",C),t.addEventListener("did-fail-load",j),t.addEventListener("render-process-gone",I),t.addEventListener("crashed",I);try{!t.isLoading()&&v()&&S()}catch{}return()=>{D!==null&&clearTimeout(D),t.removeEventListener("render-process-gone",I),t.removeEventListener("crashed",I),t.removeEventListener("did-start-loading",p),t.removeEventListener("did-stop-loading",S),t.removeEventListener("did-navigate",g),t.removeEventListener("did-navigate-in-page",g),t.removeEventListener("page-title-updated",k),t.removeEventListener("page-favicon-updated",C),t.removeEventListener("did-fail-load",j)}},[t]),{status:r,url:o,title:a,canGoBack:u,canGoForward:f}},Nv=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Av=4e4,fo=.5,Dv=-3,Pv=4,Iv="persist:openchamber-browser",Ac=20,Tv=600,Ev=2e4,Rv=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=jt(),{currentTheme:i}=or(),o=c.useRef(null),[l,a]=c.useState(null),d=c.useCallback(ce=>{o.current=ce,a(ce)},[]),u=Pe(ce=>ce.setContextPanelTabTargetPath),h=c.useRef(br(t)),f=h.current!==sn?h.current:"",[x,b]=c.useState(f?null:sn),[w,v]=c.useState(f),[y,m]=c.useState(!1),[p,S]=c.useState(!1),[g,C]=c.useState(0),k=c.useRef(0),[j,D]=c.useState(!1),[I,A]=c.useState(Oo),P=c.useRef(I);P.current=I;const T=c.useRef([]),[L,$]=c.useState("system"),[K,F]=c.useState({width:0,height:0}),W=c.useRef(null),N=c.useRef(null),R=c.useRef(!1),E=c.useRef(Date.now()),X=c.useCallback(ce=>{!ce||ce===sn||!e||!n||u(e,n,ce)},[e,n,u]),J=Cv(l,{initialUrl:f,onUrlChange:c.useCallback(ce=>{const se=Tr(ce);v(se),X(se)},[X])}),[re,fe]=c.useState(null),ne=mv(e),te=hv(),ue=J.status.kind==="loading",Se=wr(jf(e)),we=wr(ce=>ce.recordVisit),ye=wr(ce=>ce.forget);c.useEffect(()=>{J.status.kind==="ready"&&we(e,{url:Tr(J.status.url),title:J.status.title})},[e,J.status,we]);const Ae=c.useMemo(()=>Sf(Se,w),[Se,w]),pe=c.useCallback(ce=>{const se=br(ce);se!==sn&&(v(se),fe(null),vc(se).then(q=>{const z=o.current;if(!z){b(q);return}try{z.loadURL(q)}catch{b(q)}}).catch(q=>{q instanceof Kr&&fe(se)}))},[]);c.useEffect(()=>{if(!f)return;let ce=!0;return vc(f).then(se=>{ce&&b(se)}).catch(se=>{if(ce){if(se instanceof Kr){fe(f),b(sn);return}b(f)}}),()=>{ce=!1}},[]);const O=c.useMemo(()=>({executeJavaScript:async(ce,se)=>{const q=o.current;if(!q)throw new Error("Browser view is not available");return q.executeJavaScript(ce,se)},capturePage:async()=>{const ce=o.current;if(!ce)return null;const se=ce.getWebContentsId();return Number.isFinite(se)?await gr("desktop_browser_capture_page",{webContentsId:se}):null}}),[]),Q=c.useCallback(()=>{if(y){m(!1),jo(O);return}if(!J.url){Le.error(r("contextPanel.browser.annotate.noPage"));return}const ce=kw(i.metadata.variant==="light"?"light":"dark");m(!0),Sw({host:O,theme:ce,labels:te}).then(async se=>{m(!1),se&&await ne(se)}).catch(()=>{m(!1),Le.error(r("contextPanel.browser.annotate.failed"))})},[O,ne,i,y,J.url,te,r]);c.useEffect(()=>{if(!y)return;const ce=se=>{Op(se)||se.key!=="Escape"||(se.preventDefault(),se.stopImmediatePropagation(),m(!1),jo(O))};return window.addEventListener("keydown",ce,!0),()=>window.removeEventListener("keydown",ce,!0)},[O,y]);const le=c.useCallback(async(ce=8e3)=>{const se=Date.now();for(;;){const q=o.current;if(!q)return!1;let z=!1;try{z=q.isLoading()}catch{return!1}if(!z)return!0;if(Date.now()-se>ce)return!1;await new Promise(ee=>setTimeout(ee,120))}},[]),H=c.useCallback(async(ce,se)=>{const q=o.current;if(!q)throw new Error("The browser panel is not ready");const z=()=>{Nc(se.viewport)&&(A(ia(se.viewport)),D(!0))};if(ce==="browser.back"||ce==="browser.forward"){const Ee=ce==="browser.back";if(!(Ee?q.canGoBack():q.canGoForward()))throw new Error(Ee?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");Ee?q.goBack():q.goForward(),await new Promise(V=>setTimeout(V,150)),await le();let $e="";try{$e=q.getTitle()||""}catch{$e=""}return{url:Tr(q.getURL()),title:$e}}if(ce==="browser.capture"){Pe.getState().openContextBrowser(e,q.getURL());const Ee=Date.now()+1200;let xe=0,$e=0;for(;$e<2&&Date.now()<Ee;){const Fe=q.getBoundingClientRect().width;$e=Fe>=2&&Math.abs(Fe-xe)<.5?$e+1:0,xe=Fe,await new Promise(_e=>setTimeout(_e,50))}await new Promise(Fe=>{requestAnimationFrame(()=>requestAnimationFrame(()=>Fe()))}),await le();const V=await O.capturePage();if(!V)throw new Error("The page could not be captured");let De="";try{De=q.getTitle()||""}catch{De=""}return{...V,url:Tr(q.getURL()),title:De,viewport:co(P.current)}}if(ce==="browser.resize"){if(!Nc(se.viewport))throw new Error("viewport is required");return z(),await new Promise(Ee=>setTimeout(Ee,200)),await le(),{viewport:co(ia(se.viewport))}}if(ce==="browser.open"){const Ee=typeof se.url=="string"?se.url:"";if(!Ee)throw new Error("url is required");z(),pe(Ee),await new Promise(V=>setTimeout(V,150));const xe=await le(25e3);let $e="";try{$e=q.getTitle()||""}catch{$e=""}return{url:br(Ee),title:$e,opened:!0,settled:xe,viewport:co(P.current)}}await le();const ee=Ee=>typeof Ee=="string"&&Ee?Ee:void 0,Ne=(()=>{switch(ce){case"browser.snapshot":return Hw({selector:ee(se.selector)});case"browser.click":return Gw({selector:ee(se.selector),text:ee(se.text)});case"browser.type":return qw({selector:String(se.selector??""),value:String(se.value??""),submit:se.submit===!0});case"browser.inspect":return Xw({selector:String(se.selector??"")});case"browser.scroll":return Yw({selector:ee(se.selector),direction:ee(se.direction)});default:return null}})();if(!Ne)throw new Error(`Unsupported browser action: ${ce}`);const Ce=await q.executeJavaScript(Ne,!0);if(!Ce||typeof Ce!="object")throw new Error("The page returned no result");const We=Ce;if(We.ok!==!0)throw new Error(typeof We.error=="string"&&We.error?We.error:"Browser action failed");if(ce==="browser.snapshot"){const Ee=T.current;return{...We,viewport:co(P.current),...Ee.length>0?{consoleProblems:[...Ee]}:{}}}return(ce==="browser.click"||ce==="browser.type"&&se.submit===!0)&&(await new Promise(Ee=>setTimeout(Ee,150)),await le()),Ce},[O,e,pe,le]);c.useEffect(()=>Iw({run:H}),[H]),c.useEffect(()=>{const ce=O;return()=>{jo(ce)}},[O]),c.useEffect(()=>{if(!l)return;const ce=q=>{const z=q;if(typeof z.level!="number"||z.level<2)return;const ee=z.sourceId?`${z.sourceId}${z.line?`:${z.line}`:""}`:"";T.current.push({level:z.level>=3?"error":"warning",message:String(z.message??"").slice(0,400),source:ee}),T.current.length>Ac&&T.current.splice(0,T.current.length-Ac)},se=()=>{T.current=[]};return l.addEventListener("console-message",ce),l.addEventListener("did-start-loading",se),()=>{l.removeEventListener("console-message",ce),l.removeEventListener("did-start-loading",se)}},[l]);const me=c.useRef(new Set),ge=c.useCallback(ce=>{me.current.clear(),pe(ce)},[pe]);c.useEffect(()=>{if(!l)return;const ce=q=>{const z=hr(q),ee=typeof z.url=="string"?z.url:"";!ee||!Sc(ee)||(q.preventDefault(),pe(ee))},se=q=>{const z=hr(q);if(z.isMainFrame===!1||z.errorCode===-3)return;const ee=typeof z.validatedURL=="string"?z.validatedURL:"";!ee||!Sc(ee)||me.current.has(ee)||(me.current.add(ee),pe(ee))};return l.addEventListener("will-navigate",ce),l.addEventListener("did-fail-load",se),()=>{l.removeEventListener("will-navigate",ce),l.removeEventListener("did-fail-load",se)}},[pe,l]),c.useEffect(()=>{if(!l)return;const ce=se=>{const q=se.detail;se.preventDefault(),q?.url&&pe(q.url)};return l.addEventListener("new-window",ce),()=>l.removeEventListener("new-window",ce)},[pe,l]);const oe=c.useCallback(ce=>{const se=Math.min(Pv,Math.max(Dv,ce));k.current=se,C(se);try{o.current?.setZoomLevel(se)}catch{}},[]);c.useEffect(()=>{const ce=se=>{if(!(se instanceof CustomEvent))return;const q=se.detail,z=o.current;!z||document.activeElement!==z||(q==="zoom-in"?oe(k.current+fo):q==="zoom-out"?oe(k.current-fo):q==="zoom-reset"&&oe(0))};return window.addEventListener("openchamber:zoom",ce),()=>window.removeEventListener("openchamber:zoom",ce)},[oe]);const de=c.useCallback(ce=>{gr("desktop_browser_clear_data",{partition:Iv,cookies:ce==="cookies",cache:ce==="cache"}).then(()=>{Le.success(r(ce==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>Le.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const ce=W.current;if(!ce||typeof ResizeObserver>"u")return;const se=new ResizeObserver(q=>{const z=q[0]?.contentRect;z&&F({width:z.width,height:z.height})});return se.observe(ce),()=>se.disconnect()},[]);const _=c.useCallback(ce=>{$(ce);const se=o.current;if(!se)return;let q=-1;try{q=se.getWebContentsId()}catch{return}gr("desktop_browser_set_color_scheme",{webContentsId:q,scheme:ce}).catch(z=>{$("system"),Le.error(z instanceof Error?z.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),B=c.useCallback(()=>{try{ue?o.current?.stop():o.current?.reload()}catch{}},[ue]),he=J.status;c.useEffect(()=>{const ce=()=>{S(!0);const z=setTimeout(()=>{try{o.current?.reload()}catch{}},Tv);return()=>clearTimeout(z)};if(he.kind==="failed"){if(!sw(he.code,he.url)){S(!1);return}const z=Date.now(),ee=N.current?.url===he.url?N.current:{url:he.url,startedAt:z};if(N.current=ee,z-ee.startedAt>Av){S(!1);return}return ce()}if(he.kind==="loading")return;if(N.current=null,he.kind!=="ready"||!he.url||!kr(he.url)){R.current=!0,S(!1);return}if(R.current||Date.now()-E.current>Ev){R.current=!0,S(!1);return}let se=!1,q=null;return ow(Tr(he.url)).then(z=>{if(!se){if(z===null||z<500){R.current=!0,S(!1);return}q=ce()}}),()=>{se=!0,q?.()}},[he]);const ve=J.status.kind==="failed"&&!p?J.status:null,Re=tv(I,K);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(Af,{address:w,onAddressChange:v,onSubmit:ge,suggestions:Ae,onForgetSuggestion:ce=>ye(e,ce),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:B,onOpenExternal:()=>{Uo(J.url||w)},canGoBack:J.canGoBack,canGoForward:J.canGoForward,isLoading:ue,onAnnotate:Q,isAnnotating:y,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>oe(g+fo),onZoomOut:()=>oe(g-fo),onZoomReset:()=>oe(0),zoomPercent:Math.round(Math.pow(1.2,g)*100),onClearCookies:()=>de("cookies"),onClearCache:()=>de("cache"),onToggleDeviceBar:()=>D(ce=>!ce),isDeviceBarOpen:j}),j?s.jsx(rv,{viewport:I,onViewportChange:A,colorScheme:L,onColorSchemeChange:_,scale:Re?.scale??1}):null,s.jsxs("div",{ref:W,className:Oe("relative min-h-0 flex-1 bg-background",Re&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[x!==null?s.jsx("webview",{ref:d,src:x,partition:"persist:openchamber-browser",allowpopups:!0,style:Re?{width:`${Re.width}px`,height:`${Re.height}px`,transform:`scale(${Re.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,x!==null&&!f&&!J.url&&!ue?s.jsx(If,{onOpen:ge,directory:e}):null,p?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.waitingForServerHint")})]}):null,re?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.tunnelFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.tunnelFailedHint",{url:re})})]}):null,ve&&!re?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:ve.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:ve.crashed?r("contextPanel.browser.crashedHint"):ve.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,ue?s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:s.jsx("div",{className:"h-full w-1/3 animate-[browser-progress_1.1s_ease-in-out_infinite] bg-[var(--primary)]"})}):null]})]})},Mv=t=>{const e=Ze.c(49),{initialUrl:n,directory:r,tabID:i}=t,{t:o}=jt(),l=Pe(Bv);let a;e[0]!==n?(a=br(n),e[0]=n,e[1]=a):a=e[1];const d=a,u=d!==sn?d:"",[h,f]=c.useState(u),[x,b]=c.useState(u);let w;e[2]!==u?(w=u?[u]:[],e[2]=u,e[3]=w):w=e[3];const[v,y]=c.useState(w),[m,p]=c.useState(u?0:-1),[S,g]=c.useReducer(Fv,0);let C;e[4]!==r||e[5]!==l||e[6]!==i?(C=te=>{!te||te===sn||!r||!i||l(r,i,te)},e[4]=r,e[5]=l,e[6]=i,e[7]=C):C=e[7];const k=C;let j;e[8]!==r?(j=jf(r),e[8]=r,e[9]=j):j=e[9];const D=wr(j),I=wr(_v),A=wr(Lv);let P;e[10]!==h||e[11]!==D?(P=Sf(D,h),e[10]=h,e[11]=D,e[12]=P):P=e[12];const T=P;let L;e[13]!==r||e[14]!==m||e[15]!==k||e[16]!==I?(L=te=>{const ue=br(te);ue!==sn&&(f(ue),b(ue),k(ue),I(r,{url:ue}),y(Se=>{const we=m>=0?Se.slice(0,m+1):[];return we[we.length-1]===ue?(p(we.length-1),we):(p(we.length),[...we,ue])}))},e[13]=r,e[14]=m,e[15]=k,e[16]=I,e[17]=L):L=e[17];const $=L;let K;e[18]!==v||e[19]!==k?(K=te=>{const ue=v[te];ue&&(p(te),f(ue),b(ue),k(ue))},e[18]=v,e[19]=k,e[20]=K):K=e[20];const F=K;let W;e[21]!==r||e[22]!==A?(W=te=>A(r,te),e[21]=r,e[22]=A,e[23]=W):W=e[23];let N,R;e[24]!==F||e[25]!==m?(R=()=>F(m-1),N=()=>F(m+1),e[24]=F,e[25]=m,e[26]=N,e[27]=R):(N=e[26],R=e[27]);let E;e[28]!==h||e[29]!==x?(E=()=>{Uo(x||h)},e[28]=h,e[29]=x,e[30]=E):E=e[30];const X=m>0,J=m>=0&&m<v.length-1;let re;e[31]!==h||e[32]!==$||e[33]!==T||e[34]!==N||e[35]!==E||e[36]!==X||e[37]!==J||e[38]!==W||e[39]!==R?(re=s.jsx(Af,{address:h,onAddressChange:f,onSubmit:$,suggestions:T,onForgetSuggestion:W,onBack:R,onForward:N,onReload:g,onOpenExternal:E,canGoBack:X,canGoForward:J,isLoading:!1}),e[31]=h,e[32]=$,e[33]=T,e[34]=N,e[35]=E,e[36]=X,e[37]=J,e[38]=W,e[39]=R,e[40]=re):re=e[40];let fe;e[41]!==x||e[42]!==$||e[43]!==S||e[44]!==o?(fe=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:x?s.jsx("iframe",{src:x,title:o("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${x}|${S}`):s.jsx(If,{onOpen:$})}),e[41]=x,e[42]=$,e[43]=S,e[44]=o,e[45]=fe):fe=e[45];let ne;return e[46]!==re||e[47]!==fe?(ne=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[re,fe]}),e[46]=re,e[47]=fe,e[48]=ne):ne=e[48],ne},Ov=t=>{const e=Ze.c(3),[n]=c.useState(Nv);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(Rv,{...t}):s.jsx(Mv,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function Bv(t){return t.setContextPanelTabTargetPath}function Fv(t){return t+1}function _v(t){return t.recordVisit}function Lv(t){return t.forget}const $v=Wn(()=>En(()=>import("./WalkthroughView-BZyjhqHv.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])).then(t=>({default:t.WalkthroughView}))),zv=Wn(()=>En(()=>import("./DiffView-B2CD9wC8.js"),__vite__mapDeps([128,1,2,4,5,6,7,8,9,83,3,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,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,129,117,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.DiffView}))),Wv=Wn(()=>En(()=>import("./FilesView-C4vMFclc.js"),__vite__mapDeps([130,1,2,4,5,6,7,8,9,3,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,84,85,86,131,132,133,134,135,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,136,137,120,121,118,125,138,119,139])).then(t=>({default:t.FilesView}))),Kv=Wn(()=>En(()=>import("./GitView-Byu2DY7s.js"),__vite__mapDeps([140,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,84,85,86,141,117,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,87,115,116,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.GitView}))),Vv=Wn(()=>En(()=>import("./LinearIssuesView-EzGNCGrd.js"),__vite__mapDeps([142,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])).then(t=>({default:t.LinearIssuesView}))),Uv=Wn(()=>En(()=>import("./PlanView-D3x-pTkZ.js"),__vite__mapDeps([143,1,2,4,5,6,7,8,9,131,57,58,59,60,61,62,79,55,56,63,132,133,134,3,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,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,80,81,82,119,139,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,84,85,86])).then(t=>({default:t.PlanView}))),Hv=c.lazy(()=>En(()=>import("./PluginPane-DEcgDQ9h.js").then(t=>t.k),__vite__mapDeps([86,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])).then(t=>({default:t.PluginPane}))),Tf=320,Ja=600,Gv=400,qv=100,Yv=24,Fo=new Map,Qv=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},Dc=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Tf,Math.round(t))):Ja,Pc=t=>{const e=t??(typeof window<"u"?window.innerWidth:Ja*2);return Math.max(Tf,e-Gv)},Xv=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},Jv=(t,e)=>{if(!t)return"";const n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&n.startsWith(r+"/")?n.slice(r.length+1):n},Ef=(t,e)=>t==="chat"?e("contextPanel.mode.chat"):t==="file"?e("contextPanel.mode.files"):t==="diff"?e("contextPanel.mode.diff"):t==="walkthrough"?e("contextPanel.mode.walkthrough"):t==="plan"?e("contextPanel.mode.plan"):t==="browser"?e("contextPanel.mode.browser"):t==="git"?e("layout.rightSidebar.git"):t==="pr"?e("contextPanel.mode.pr"):t==="linear"?e("contextPanel.mode.linear"):t==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):Zn(t)?uu.getState().guests.find(r=>r.id===Di(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),Zv=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const n=e.split("/").filter(Boolean);return n.length===0?e:n[n.length-1]||null},eS=(t,e,n)=>{if(t.mode==="chat"){const r=aa(t.dedupeKey);if(r){const o=e.get(r)?.trim();if(o)return o}const i=t.sessionTitleFallback?.trim();return i||n("contextPanel.mode.chat")}return t.mode==="browser"?Qa(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?Zv(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):Ef(t.mode,n)},tS=t=>{const e=Ze.c(8),{mode:n}=t,r=Ia();let i;if(e[0]!==n||e[1]!==r){let u;e[3]!==n?(u=h=>h.mode===n,e[3]=n,e[4]=u):u=e[4],i=r.find(u),e[0]=n,e[1]=r,e[2]=i}else i=e[2];const o=i,l=o?.icon??Lp,a=o?.iconSrc;let d;return e[5]!==l||e[6]!==a?(d=s.jsx(Xr,{icon:l,iconSrc:a,className:"h-3.5 w-3.5"}),e[5]=l,e[6]=a,e[7]=d):d=e[7],d},Ic=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(Pa,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(of,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(M,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(M,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(M,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="linear")return s.jsx(M,{name:"linear",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(M,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(M,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(M,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(M,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(M,{name:"chat-4",className:"h-3.5 w-3.5"});if(Zn(t.mode))return s.jsx(tS,{mode:t.mode});if(t.mode==="browser"){const n=sS(t.targetPath??"",e);return n?s.jsx("img",{src:n,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):s.jsx(M,{name:"global",className:"h-3.5 w-3.5"})}},sS=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},nS=({visible:t,active:e,fill:n=!1})=>{const{t:r}=jt(),i=Pe(p=>p.contextEditorTreeWidth),o=Pe(p=>p.setContextEditorTreeWidth),[l,a]=c.useState(!1),d=c.useRef(0),u=c.useRef(i),h=c.useRef(null),f=c.useRef(null),x=c.useRef(null),b=c.useCallback(p=>{const S=x.current;S&&(S.style.width=`${p}px`,S.style.setProperty("--oc-editor-tree-width",`${p}px`))},[]),w=p=>{if(t){try{p.currentTarget.setPointerCapture(p.pointerId)}catch{}f.current=p.pointerId,a(!0),d.current=p.clientX,u.current=i,h.current=i,p.preventDefault()}},v=p=>{if(!l||f.current!==p.pointerId)return;const S=d.current-p.clientX,g=Ai(u.current+S);h.current!==g&&(h.current=g,b(g))},y=p=>{if(f.current!==p.pointerId)return;try{p.currentTarget.releasePointerCapture(p.pointerId)}catch{}const S=Ai(h.current??i);f.current=null,h.current=null,a(!1),o(S)},m=t?i:0;return s.jsxs("div",{ref:x,className:Oe("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",n&&"ml-auto"),style:{width:`${l?h.current??m:m}px`,maxWidth:n?"100%":void 0,"--oc-editor-tree-width":`${l?h.current??i:i}px`,overflowX:"clip",transitionProperty:l?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&!n&&s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-20 w-px bg-border"}),t&&!n&&s.jsx("div",{className:Oe("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",l&&"bg-[var(--interactive-border)]"),onPointerDown:w,onPointerMove:v,onPointerUp:y,onPointerCancel:y,role:"separator","aria-orientation":"vertical","aria-label":r("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:Oe("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",l&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)",maxWidth:n?"100%":void 0},"aria-hidden":!t,children:s.jsx(S1,{visible:t&&e})})]})},aa=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,rS=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},oS=(t,e)=>{if(e.length===0)return Fo;const n=new Set(e),r=new Map;for(const i of t){if(!n.has(i.id))continue;const o=i.title?.trim();o&&r.set(i.id,o)}return r.size===0?Fo:r},iS=(t,e)=>{const n=nu(t),r=c.useRef(Fo),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(n.subscribe,c.useCallback(()=>{const o=oS(n.getState().session,i.current);return rS(r.current,o)?r.current:(r.current=o,o)},[n]),()=>Fo)},aS=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,lS=()=>{const{t}=jt(),e=ir()??"",n=c.useMemo(()=>Qv(e),[e]),r=Pe(Y=>n?Y.contextPanelByDirectory[n]:void 0),i=Pe(Y=>Y.closeContextPanel),o=Pe(Y=>Y.closeContextPanelTab),l=Pe(Y=>Y.openContextPanelTab),a=Pe(Y=>Y.toggleContextPanelExpanded),d=Pe(Y=>Y.setContextPanelWidth),u=Pe(Y=>Y.setActiveContextPanelTab),h=Pe(Y=>Y.openContextBrowser);c.useEffect(()=>{if(e)return Tw(Y=>h(e,Y))},[e,h]);const f=Pe(Y=>Y.reorderContextPanelTabs),x=hn(Y=>Y.setSelectedPath),b=Pe(Y=>Y.contextEditorTreeVisible),w=Pe(Y=>Y.contextEditorTreeWidth),v=Pe(Y=>Y.setContextEditorTreeWidth),y=Pe(Y=>Y.toggleContextEditorTree),m=Pe(Y=>Y.contextEditorVisible),p=Pe(Y=>Y.toggleContextEditor),S=Pe(Y=>Y.openNewContextBrowserTab),g=gf(Y=>Y.byOrigin),C=Pe(Y=>Y.allowPromptingSubagentSessions),{themeMode:k,setThemeMode:j,lightThemeId:D,darkThemeId:I,currentTheme:A}=or(),P=c.useMemo(()=>r?.tabs??[],[r?.tabs]),T=P.find(Y=>Y.id===r?.activeTabId)??P[P.length-1]??null,L=!!(r?.isOpen&&T),[$,K]=c.useState(null),F=c.useMemo(()=>P.some(Y=>Y.mode==="file"&&Y.targetPath),[P]),W=F&&(m||!b),N=T?.mode??null,R=N==="file"&&!W,E=!!(L&&r?.expanded&&!R),X=N?r?.widthByMode?.[N]:void 0,J=N?r?.widthFractionByMode?.[N]:void 0,re=N?Bp(N):.5,fe=$??(typeof window<"u"?window.innerWidth:Ja*2),ne=J!=null&&$!=null?Math.round(J*$):X,te=R?w:Dc(ne??Math.round(re*fe),Pc($??fe));c.useEffect(()=>{!n||!N||R||J!=null||X==null||$==null||d(n,N,X,$)},[N,$,n,R,X,J,d]);const ue=c.useMemo(()=>{const Y=[];for(const G of P){if(G.mode!=="chat")continue;const Z=aa(G.dedupeKey);Z&&!Y.includes(Z)&&Y.push(Z)}return Y},[P]),Se=iS(n||void 0,ue),[we,ye]=c.useState(!1),Ae=c.useRef(0),pe=c.useRef(te),O=c.useRef(null),Q=c.useRef(null),le=c.useRef(null),H=c.useRef(new Map),me=c.useRef(new Map),ge=c.useRef(!1);c.useLayoutEffect(()=>{const Y=le.current?.parentElement;if(!Y||typeof ResizeObserver>"u")return;const G=new ResizeObserver(()=>{K(Y.clientWidth||null)});return G.observe(Y),K(Y.clientWidth||null),()=>G.disconnect()},[]),c.useEffect(()=>{if(!L||ge.current){ge.current=L;return}const Y=window.requestAnimationFrame(()=>{le.current?.focus({preventScroll:!0})});return ge.current=!0,()=>window.cancelAnimationFrame(Y)},[L]);const oe=c.useRef(null),de=c.useRef(null),_=c.useCallback(()=>{de.current=null;const Y=le.current,G=O.current;!Y||G===null||Y.style.setProperty("--oc-context-panel-width",`${G}px`)},[]);c.useEffect(()=>()=>{de.current!==null&&clearTimeout(de.current)},[]);const B=c.useCallback(Y=>{const G=oe.current,Z=R?Ai(Y):Dc(Y,Pc(G));return G===null?Z:Math.min(Z,Math.max(1,G))},[R]),he=c.useCallback(Y=>{!L||E||!n||(Q.current=Y.pointerId,ye(!0),Ae.current=Y.clientX,pe.current=te,O.current=te,oe.current=Xv(le.current),document.documentElement.style.cursor="col-resize",Y.preventDefault())},[n,E,L,te]),ve=c.useCallback(()=>{const Y=B(O.current??te),G=oe.current;O.current=null,oe.current=null,de.current!==null&&(clearTimeout(de.current),de.current=null),document.documentElement.style.cursor="",R?v(Y):n&&N&&d(n,N,Y,G??void 0),ye(!1),Q.current=null},[N,B,n,R,v,d,te]);c.useEffect(()=>{if(!we)return;const Y=je=>{if(Q.current!==je.pointerId)return;const Ie=Ae.current-je.clientX,Ve=B(pe.current+Ie);O.current!==Ve&&(O.current=Ve,de.current===null&&(de.current=setTimeout(_,qv)))},G=je=>{Q.current===je.pointerId&&ve()},Z=()=>{ve()};return window.addEventListener("pointermove",Y),window.addEventListener("pointerup",G),window.addEventListener("pointercancel",G),window.addEventListener("blur",Z),()=>{window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",G),window.removeEventListener("pointercancel",G),window.removeEventListener("blur",Z)}},[_,B,ve,we]),c.useEffect(()=>{we||(O.current=null,document.documentElement.style.cursor="")},[we]);const Re=c.useCallback(()=>{n&&i(n)},[i,n]),ce=c.useCallback(()=>{n&&a(n)},[n,a]),se=c.useCallback(Y=>{Y.key==="Escape"&&(Y.target instanceof Node&&!Y.currentTarget.contains(Y.target)||Fp(Y.target)||_p(Y.target)||(Y.preventDefault(),Y.stopPropagation(),Re()))},[Re]);c.useEffect(()=>{if(!(!n||!T)&&T.mode==="file"&&T.targetPath){x(n,T.targetPath,{allowOutsideRoot:!0});return}},[T,n,x]);const q=c.useMemo(()=>P.filter(Y=>Y.mode==="chat"),[P]),z=L&&T?.mode==="chat"?T.id:null,ee=L&&T?.mode==="chat"?aa(T.dedupeKey):null,ae=Jx(q,z);c.useEffect(()=>{if(!L||!n||!ee||typeof window>"u")return;const Y=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){ci(n,ee,!1);return}wu(ee),ci(n,ee,!0)};Y();const G=window.setInterval(Y,1e4);return window.addEventListener("focus",Y),window.addEventListener("blur",Y),document.addEventListener("visibilitychange",Y),()=>{window.clearInterval(G),window.removeEventListener("focus",Y),window.removeEventListener("blur",Y),document.removeEventListener("visibilitychange",Y),ci(n,ee,!1)}},[ee,n,L]);const Ne=c.useCallback((Y,G,Z)=>Zx(me.current,Y,G,n||null,Z,{mode:k,lightThemeId:D,darkThemeId:I,currentTheme:A},{allowPromptingSubagentSessions:C}),[C,A,I,n,D,k]),Ce=ae&&ee?Ne(ae.id,ee,ae.readOnly):null;c.useEffect(()=>{const Y=new Set(P.map(G=>G.id));for(const G of me.current.keys())Y.has(G)||me.current.delete(G)},[P]);const We=c.useCallback(Y=>{!n||T?.mode!=="diff"||l(n,{mode:"diff",targetPath:T.targetPath,stagedDiff:Y==="staged",diffScope:Y})},[T,n,l]),Ee=c.useCallback(()=>{if(typeof window>"u")return;const Y={themeMode:k,lightThemeId:D,darkThemeId:I,currentTheme:A};for(const G of H.current.values()){const Z=G.contentWindow;Z&&Z.postMessage({type:"openchamber:theme-sync",payload:Y},window.location.origin)}},[A,I,D,k]),xe=c.useCallback(()=>{if(typeof window>"u")return;const Y={allowPromptingSubagentSessions:C};for(const G of H.current.values()){const Z=G.contentWindow;Z&&Z.postMessage({type:"openchamber:chat-settings-sync",payload:Y},window.location.origin)}},[C]),$e=c.useCallback((Y,G,Z)=>{const je=G.contentWindow;je&&je.postMessage({type:Gu,payload:{visible:z===Y}},Z)},[z]),V=c.useCallback(()=>{if(!(typeof window>"u"))for(const[Y,G]of H.current.entries())$e(Y,G,window.location.origin)},[$e]);c.useEffect(()=>{if(typeof window>"u")return;const Y=G=>{if(G.origin!==window.location.origin)return;const Z=Array.from(H.current.entries()).find(([,it])=>it.contentWindow===G.source);if(!Z)return;const je=G.data;if(je?.type===eb){const[it,at]=Z;$e(it,at,G.origin);return}if(je?.type===tb){if(typeof je.requestId!="string"||!je.requestId)return;const it=qt(),at={apiBaseUrl:Pn(),clientToken:Hr(),localOrigin:typeof window.__OPENCHAMBER_LOCAL_ORIGIN__=="string"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"",runtimeHeaders:Md(),relayHostId:it.startsWith("host:")?it.slice(5):"",relay:Qm()??void 0};G.source?.postMessage({type:sb,requestId:je.requestId,payload:at},G.origin);return}if(je?.type==="openchamber:theme-sync-request"){Ee();return}if(je?.type==="openchamber:chat-settings-request"){xe();return}if(je?.type!=="openchamber:cycle-theme-request")return;const Ie=["light","dark","system"],Je=(Ie.indexOf(k)+1)%Ie.length;j(Ie[Je])};return window.addEventListener("message",Y),()=>window.removeEventListener("message",Y)},[xe,$e,Ee,j,k]),c.useLayoutEffect(()=>{P.some(G=>G.mode==="chat")&&(Ee(),xe(),V())},[I,D,xe,V,Ee,P,k]);const De=T?.mode==="file"||T?.mode==="chat"||T?.mode==="browser",Fe=c.useMemo(()=>T?P.filter(Y=>Y.mode===T.mode):[],[T,P]),_e=c.useMemo(()=>Fe.map(Y=>{const G=eS(Y,Se,t),Z=aS(G,Yv),je=Jv(Y.targetPath,e);return{id:Y.id,label:Z,icon:Ic(Y,g),title:je?`${G}: ${je}`:G,closeLabel:t("contextPanel.tab.closeTabAria",{label:Z})}}),[Fe,e,g,Se,t]),rt=T?.mode==="context"?s.jsx(z1,{}):T?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Kv,{isActive:L})}):T?.mode==="pr"?s.jsx(Yy,{}):T?.mode==="linear"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Vv,{})}):T?.mode==="notes"?s.jsx(jh,{}):T?.mode==="plan"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Uv,{targetPath:T.targetPath,savedProjectPlan:T.projectPlanId&&T.projectPlanRef?{projectRef:T.projectPlanRef,planId:T.projectPlanId}:null})}):null,ct=c.useMemo(()=>P.filter(Y=>Y.mode==="browser"),[P]),et=c.useMemo(()=>P.filter(Y=>Y.mode==="diff"),[P]),pt=c.useMemo(()=>P.find(Y=>Y.mode==="terminal")??null,[P]),kt=c.useMemo(()=>P.some(Y=>Y.mode==="walkthrough"),[P]),wt=c.useMemo(()=>P.filter(Y=>Zn(Y.mode)),[P]),Xe=c.useMemo(()=>P.some(Y=>Y.mode==="file"),[P]),yt=T?.mode==="file",Rt=Pe(Y=>Y.closeContextPanelTabs),be=c.useCallback(Y=>{if(!n)return null;const{id:G,index:Z,allIds:je,close:Ie}=Y,Ve=()=>Rt(n,je.filter(Pt=>Pt!==G)),Je=()=>Rt(n,je.slice(0,Z)),it=()=>Rt(n,je.slice(Z+1)),at=()=>Rt(n,je),Ye=je.length>1,vt=Z===0,Ue=Z===je.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Qn,{onClick:Ie,children:[s.jsx(M,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),s.jsx(Ei,{}),s.jsxs(Qn,{onClick:Ve,disabled:!Ye,children:[s.jsx(M,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Qn,{onClick:Je,disabled:vt,children:[s.jsx(M,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Qn,{onClick:it,disabled:Ue,children:[s.jsx(M,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),s.jsx(Ei,{}),s.jsxs(Qn,{onClick:at,disabled:!Ye,children:[s.jsx(M,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[Rt,n,t]),Ge=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[De?s.jsx($d,{items:_e,activeId:T?.id??null,onSelect:Y=>{n&&u(n,Y)},onClose:Y=>{n&&o(n,Y)},onReorder:(Y,G)=>{n&&f(n,Y,G)},layoutMode:"scrollable",variant:"default",tabContextMenu:be}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[T?Ic(T,g):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:T?Ef(T.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[T?.mode==="browser"?s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:()=>{n&&S(n)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:s.jsx(M,{name:"add",className:"h-3.5 w-3.5"})}):null,yt&&F?s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:p,className:"h-7 w-7 p-0",title:t("contextRail.editor.toggle"),"aria-label":t("contextRail.editor.toggle"),"aria-pressed":W,children:s.jsx(M,{name:"layout-left",className:"h-3.5 w-3.5"})}):null,yt?s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:y,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":b,children:s.jsx(M,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,R?null:s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:ce,className:"h-7 w-7 p-0",title:t(E?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(E?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:E?s.jsx(M,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(M,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:Re,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(M,{name:"close",className:"h-3.5 w-3.5"})})]})]}),ut=L?E?{"--oc-context-panel-width":$!==null?`${$}px`:"100%",width:$!==null?`${$}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${te}px`}:{"--oc-context-panel-width":`${te}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:le,"data-context-panel":"true",tabIndex:-1,inert:!L||void 0,className:Oe("flex min-h-0 flex-col overflow-hidden bg-background",E?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!L&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:se,style:ut,children:[L&&!E&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),L&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!E&&s.jsx("div",{className:Oe("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",we&&"bg-[var(--interactive-border)]"),onPointerDown:he,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:Oe("relative z-10 flex h-full min-h-0 shrink-0 flex-col duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none","transition-[width,opacity]",!L&&"pointer-events-none select-none opacity-0"),style:{width:E?$!==null?`${$}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!L,children:[Ge,s.jsxs("div",{className:Oe("relative min-h-0 flex-1 overflow-hidden",we&&"pointer-events-none"),children:[Xe?s.jsxs("div",{className:Oe("absolute inset-0 flex",yt?"flex":"hidden"),children:[F||!b?s.jsx("div",{className:Oe("h-full min-w-0 flex-1",F&&!W&&"hidden"),children:F?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Wv,{mode:"editor-only",visible:L&&yt&&W})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(M,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),s.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}):null,s.jsx(nS,{visible:b,active:L&&yt,fill:!W})]}):null,ae&&ee&&Ce?s.jsx("iframe",{ref:Y=>{if(!Y){H.current.delete(ae.id);return}H.current.set(ae.id,Y)},src:Ce,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:ee}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{Ee(),xe(),V()}},ae.id):null,ct.map(Y=>s.jsx("div",{className:Oe("absolute inset-0",T?.id!==Y.id&&"hidden"),children:s.jsx(Ov,{initialUrl:Y.targetPath??"",directory:n,tabID:Y.id})},Y.id)),et.map(Y=>s.jsx("div",{className:Oe("absolute inset-0",T?.id!==Y.id&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(zv,{visible:L&&T?.id===Y.id,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:Y.diffScope??(Y.stagedDiff?"staged":"working"),onDiffScopeChange:We,targetFilePath:Y.targetPath,flushContent:!0})})},Y.id)),pt?s.jsx("div",{className:Oe("absolute inset-0",T?.mode==="terminal"?"block":"hidden"),children:s.jsx(kh,{visible:L&&T?.mode==="terminal",directory:pt.targetDirectory})}):null,kt?s.jsx("div",{className:Oe("absolute inset-0",T?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx($v,{directory:e,visible:L&&T?.mode==="walkthrough"})})}):null,wt.map(Y=>Zn(Y.mode)?s.jsx("div",{className:Oe("absolute inset-0",T?.id===Y.id?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(Hv,{mode:Y.mode})})},Y.id):null),T?.mode!=="chat"&&!yt&&T?.mode!=="browser"&&T?.mode!=="diff"&&T?.mode!=="terminal"&&T?.mode!=="walkthrough"&&!(T&&Zn(T.mode))?rt:null]})]})]})},cS=t=>{const e=Ze.c(43),{open:n,onOpenChange:r}=t,{t:i}=jt(),o=Pe(dS),l=Pe(uS),a=Pe(fS),d=Pe(mS),u=Ia();let h;e[0]!==o||e[1]!==u?(h=vu(o,u),e[0]=o,e[1]=u,e[2]=h):h=e[2];const f=h,x=l.length===0;let b;if(e[3]!==l||e[4]!==f){let I;e[6]!==l?(I=A=>l.includes(A.id),e[6]=l,e[7]=I):I=e[7],b=f.every(I),e[3]=l,e[4]=f,e[5]=b}else b=e[5];const w=b;let v;e[8]!==i?(v=i("contextRail.configure.dialogTitle"),e[8]=i,e[9]=v):v=e[9];let y;e[10]!==v?(y=s.jsx(Ps,{children:v}),e[10]=v,e[11]=y):y=e[11];let m;e[12]!==i?(m=i("contextRail.configure.dialogDescription"),e[12]=i,e[13]=m):m=e[13];let p;e[14]!==m?(p=s.jsx(Is,{children:m}),e[14]=m,e[15]=p):p=e[15];let S;e[16]!==y||e[17]!==p?(S=s.jsxs(Vs,{children:[y,p]}),e[16]=y,e[17]=p,e[18]=S):S=e[18];let g;if(e[19]!==l||e[20]!==a||e[21]!==f||e[22]!==i){let I;e[24]!==l||e[25]!==a||e[26]!==i?(I=A=>s.jsx($p,{settingsItem:`layout.context-rail.surface.${A.id}`,checked:!l.includes(A.id),onChange:P=>a(A.id,P),label:A.label??i(A.labelKey),ariaLabel:A.label??i(A.labelKey)},A.id),e[24]=l,e[25]=a,e[26]=i,e[27]=I):I=e[27],g=f.map(I),e[19]=l,e[20]=a,e[21]=f,e[22]=i,e[23]=g}else g=e[23];let C;e[28]!==g?(C=s.jsx("div",{className:"flex flex-col",children:g}),e[28]=g,e[29]=C):C=e[29];let k;e[30]!==x||e[31]!==w||e[32]!==d||e[33]!==i?(k=x?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[w?s.jsx("span",{className:"text-xs text-destructive",children:i("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(dt,{variant:"link",size:"xs",onClick:()=>d([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[30]=x,e[31]=w,e[32]=d,e[33]=i,e[34]=k):k=e[34];let j;e[35]!==k||e[36]!==S||e[37]!==C?(j=s.jsxs(ws,{className:"max-w-md",children:[S,C,k]}),e[35]=k,e[36]=S,e[37]=C,e[38]=j):j=e[38];let D;return e[39]!==r||e[40]!==n||e[41]!==j?(D=s.jsx(ys,{open:n,onOpenChange:r,children:j}),e[39]=r,e[40]=n,e[41]=j,e[42]=D):D=e[42],D};function dS(t){return t.contextRailOrder}function uS(t){return t.contextRailHiddenSurfaces}function fS(t){return t.setContextRailSurfaceVisible}function mS(t){return t.setContextRailHiddenSurfaces}const Rf=150,hS=500,pS=[],gS=t=>t>99?"99+":String(t),xS=t=>{const e=Ze.c(52),{surface:n,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:d,badgeDescription:u,orderNumber:h,showOrderNumber:f,onSelect:x}=t;let b;e[0]!==n.id?(b={id:n.id},e[0]=n.id,e[1]=b):b=e[1];const{attributes:w,listeners:v,setNodeRef:y,transform:m,transition:p,isDragging:S}=ti(b);let g;e[2]!==a?(g=a!=null&&a>0?gS(a):null,e[2]=a,e[3]=g):g=e[3];const C=g;let k;e[4]!==m?(k=si.Translate.toString(m),e[4]=m,e[5]=k):k=e[5];let j;e[6]!==k||e[7]!==p?(j={transform:k,transition:p},e[6]=k,e[7]=p,e[8]=j):j=e[8];const D=S&&"z-10 opacity-70";let I;e[9]!==D?(I=Oe("relative",D),e[9]=D,e[10]=I):I=e[10];let A;e[11]!==x||e[12]!==n?(A=()=>x(n),e[11]=x,e[12]=n,e[13]=A):A=e[13];const P=d??o,T=r?"text-primary":"text-muted-foreground hover:text-foreground";let L;e[14]!==T?(L=Oe("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",T),e[14]=T,e[15]=L):L=e[15];let $;e[16]!==n.icon||e[17]!==n.iconSrc||e[18]!==n.id?($=n.id==="diff"?s.jsx(of,{className:"h-[18px] w-[18px]"}):s.jsx(Xr,{icon:n.icon,iconSrc:n.iconSrc,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.iconSrc,e[18]=n.id,e[19]=$):$=e[19];let K;e[20]!==C||e[21]!==h||e[22]!==i||e[23]!==f?(K=f&&h!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:h===10?"0":h}):C?s.jsx("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.625rem] font-semibold leading-none",style:{backgroundColor:"var(--status-info-background)",color:"var(--status-info)"},children:C}):i?s.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[20]=C,e[21]=h,e[22]=i,e[23]=f,e[24]=K):K=e[24];let F;e[25]!==w||e[26]!==r||e[27]!==v||e[28]!==L||e[29]!==$||e[30]!==K||e[31]!==A||e[32]!==P?(F=s.jsx(At,{asChild:!0,children:s.jsxs("button",{type:"button",...w,...v,onClick:A,"aria-label":P,"aria-pressed":r,className:L,children:[$,K]})}),e[25]=w,e[26]=r,e[27]=v,e[28]=L,e[29]=$,e[30]=K,e[31]=A,e[32]=P,e[33]=F):F=e[33];let W;e[34]!==o?(W=s.jsx("span",{children:o}),e[34]=o,e[35]=W):W=e[35];let N;e[36]!==l?(N=s.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[36]=l,e[37]=N):N=e[37];let R;e[38]!==u?(R=u?s.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[38]=u,e[39]=R):R=e[39];let E;e[40]!==W||e[41]!==N||e[42]!==R?(E=s.jsx(Dt,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[W,N,R]})}),e[40]=W,e[41]=N,e[42]=R,e[43]=E):E=e[43];let X;e[44]!==F||e[45]!==E?(X=s.jsxs(Nt,{delayDuration:Rf,children:[F,E]}),e[44]=F,e[45]=E,e[46]=X):X=e[46];let J;return e[47]!==y||e[48]!==X||e[49]!==j||e[50]!==I?(J=s.jsx("div",{ref:y,style:j,className:I,children:X}),e[47]=y,e[48]=X,e[49]=j,e[50]=I,e[51]=J):J=e[51],J},bS=()=>{const t=Ze.c(92),{t:e}=jt(),n=ir();let r;t[0]!==n?(r=n?cr(n):"",t[0]=n,t[1]=r):r=t[1];const i=r;let o;t[2]!==i?(o=ce=>i?ce.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const l=Pe(o),a=Pe(yS),d=Pe(wS),u=Pe(vS),h=Pe(SS),f=Pe(jS),x=Pe(kS),b=Pe(CS),w=Ca(NS),v=_i(AS),y=_i(DS),m=In(PS),p=In(IS),{screenWidth:S}=zn(),g=Na(i||null);let C;t[4]!==b?(C=Li("switch_context_surface",b),t[4]=b,t[5]=C):C=t[5];const k=C,[j,D]=c.useState(!1);let I,A;t[6]!==k?(I=()=>{const ce=new Set;let se=null,q=!1;const z=TS,ee=()=>{Dl(k,ce)?!q&&se===null&&(se=setTimeout(()=>D(!0),hS)):(q=!1,se!==null&&(clearTimeout(se),se=null),D(!1))},ae=We=>{if(ce.add(We.key.toLowerCase()),z(We.key)&&Dl(k,ce)){q=!0,se!==null&&(clearTimeout(se),se=null),D(!1);return}ee()},Ne=We=>{ce.delete(We.key.toLowerCase()),ee()},Ce=()=>{ce.clear(),q=!1,se!==null&&(clearTimeout(se),se=null),D(!1)};return window.addEventListener("keydown",ae,!0),window.addEventListener("keyup",Ne,!0),window.addEventListener("blur",Ce),()=>{window.removeEventListener("keydown",ae,!0),window.removeEventListener("keyup",Ne,!0),window.removeEventListener("blur",Ce),se!==null&&clearTimeout(se)}},A=[k],t[6]=k,t[7]=I,t[8]=A):(I=t[7],A=t[8]),c.useEffect(I,A);let P;t[9]===Symbol.for("react.memo_cache_sentinel")?(P={activationConstraint:{distance:8}},t[9]=P):P=t[9];let T;t[10]===Symbol.for("react.memo_cache_sentinel")?(T={activationConstraint:{delay:200,tolerance:6}},t[10]=T):T=t[10];const L=Qo(Dn(Jo,P),Dn(Xo,T)),$=Ia(),K=Al(ES),F=Al(RS),W=l?.tabs??pS;let N;t[11]!==l?.activeTabId||t[12]!==W?(N=W.find(ce=>ce.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=W,t[13]=N):N=t[13];const R=N,E=l?.isOpen?R?.mode??null:null,X=g?.files.length??0;let J;t[14]!==u||t[15]!==d||t[16]!==p||t[17]!==$||t[18]!==y||t[19]!==w||t[20]!==S||t[21]!==W?(J=zp({railOrder:d,hiddenSurfaces:u,planModeEnabled:w,isVSCode:$n(),screenWidth:S,tabs:W,linearConnected:y,githubConnected:p,extras:$}),t[14]=u,t[15]=d,t[16]=p,t[17]=$,t[18]=y,t[19]=w,t[20]=S,t[21]=W,t[22]=J):J=t[22];const re=J;let fe,ne;t[23]!==E||t[24]!==x||t[25]!==i||t[26]!==v||t[27]!==y?(ne=()=>{!i||!v||y||E!=="linear"||x(i)},fe=[E,x,i,v,y],t[23]=E,t[24]=x,t[25]=i,t[26]=v,t[27]=y,t[28]=fe,t[29]=ne):(fe=t[28],ne=t[29]),c.useEffect(ne,fe);let te,ue;t[30]!==E||t[31]!==x||t[32]!==i||t[33]!==m||t[34]!==p?(te=()=>{!i||!m||p||E!=="pr"||x(i)},ue=[E,x,i,m,p],t[30]=E,t[31]=x,t[32]=i,t[33]=m,t[34]=p,t[35]=te,t[36]=ue):(te=t[35],ue=t[36]),c.useEffect(te,ue);const[Se,we]=c.useState(!1);let ye;t[37]!==$||t[38]!==h?(ye=ce=>{const{active:se,over:q}=ce;if(!q||se.id===q.id)return;const z=vu(Pe.getState().contextRailOrder,$).map(MS),ee=z.indexOf(se.id),ae=z.indexOf(q.id);ee===-1||ae===-1||h(zu(z,ee,ae))},t[37]=$,t[38]=h,t[39]=ye):ye=t[39];const Ae=ye;if(!i)return null;let pe;t[40]!==e?(pe=e("contextRail.aria.rail"),t[40]=e,t[41]=pe):pe=t[41];let O;t[42]!==re?(O=re.map(OS),t[42]=re,t[43]=O):O=t[43];let Q;if(t[44]!==E||t[45]!==X||t[46]!==F||t[47]!==i||t[48]!==K||t[49]!==f||t[50]!==j||t[51]!==re||t[52]!==e||t[53]!==a){let ce;t[55]!==E||t[56]!==X||t[57]!==F||t[58]!==i||t[59]!==K||t[60]!==f||t[61]!==j||t[62]!==e||t[63]!==a?(ce=(se,q)=>{const z=se.label??e(se.labelKey),ee=se.id==="git"&&!a?X:0,ae=Zn(se.mode)&&E!==se.mode?K[Di(se.mode)]??0:0,Ne=ee>0?ee:ae>0?ae:null,Ce=Ne!==null&&ee===0;return s.jsx(xS,{surface:se,isActive:E===se.mode,showActivityDot:!1,label:z,description:e(se.descriptionKey),badgeCount:Ne,badgeAriaLabel:Ne!==null?e(Ce?Ne===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":Ne===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:z,count:Ne}):null,badgeDescription:Ne!==null?e(Ce?Ne===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":Ne===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:Ne}):null,orderNumber:q+1,showOrderNumber:j,onSelect:We=>{Zn(We.mode)&&F(Di(We.mode)),f(i,We.mode)}},se.id)},t[55]=E,t[56]=X,t[57]=F,t[58]=i,t[59]=K,t[60]=f,t[61]=j,t[62]=e,t[63]=a,t[64]=ce):ce=t[64],Q=re.map(ce),t[44]=E,t[45]=X,t[46]=F,t[47]=i,t[48]=K,t[49]=f,t[50]=j,t[51]=re,t[52]=e,t[53]=a,t[54]=Q}else Q=t[54];let le;t[65]!==O||t[66]!==Q?(le=s.jsx(Wa,{items:O,strategy:Wu,children:Q}),t[65]=O,t[66]=Q,t[67]=le):le=t[67];let H;t[68]!==Ae||t[69]!==L||t[70]!==le?(H=s.jsx(Zo,{sensors:L,collisionDetection:ei,onDragEnd:Ae,children:le}),t[68]=Ae,t[69]=L,t[70]=le,t[71]=H):H=t[71];let me;t[72]!==e?(me=e("contextRail.configure.open"),t[72]=e,t[73]=me):me=t[73];let ge;t[74]===Symbol.for("react.memo_cache_sentinel")?(ge=()=>we(!0),t[74]=ge):ge=t[74];let oe;t[75]===Symbol.for("react.memo_cache_sentinel")?(oe=s.jsx(M,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[75]=oe):oe=t[75];let de;t[76]!==me?(de=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":me,onClick:ge,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:oe})}),t[76]=me,t[77]=de):de=t[77];let _;t[78]!==e?(_=e("contextRail.configure.open"),t[78]=e,t[79]=_):_=t[79];let B;t[80]!==_?(B=s.jsx(Dt,{side:"left",sideOffset:8,children:_}),t[80]=_,t[81]=B):B=t[81];let he;t[82]!==de||t[83]!==B?(he=s.jsxs(Nt,{delayDuration:Rf,children:[de,B]}),t[82]=de,t[83]=B,t[84]=he):he=t[84];let ve;t[85]!==Se?(ve=s.jsx(cS,{open:Se,onOpenChange:we}),t[85]=Se,t[86]=ve):ve=t[86];let Re;return t[87]!==pe||t[88]!==H||t[89]!==he||t[90]!==ve?(Re=s.jsxs("nav",{"aria-label":pe,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[H,he,ve]}),t[87]=pe,t[88]=H,t[89]=he,t[90]=ve,t[91]=Re):Re=t[91],Re};function yS(t){return t.workStatusPanelVisible}function wS(t){return t.contextRailOrder}function vS(t){return t.contextRailHiddenSurfaces}function SS(t){return t.setContextRailOrder}function jS(t){return t.openContextSurface}function kS(t){return t.closeContextPanel}function CS(t){return t.shortcutOverrides}function NS(t){return t.planModeEnabled}function AS(t){return t.hasChecked}function DS(t){return t.status?.connected===!0}function PS(t){return t.hasChecked}function IS(t){return t.status?.connected===!0}function TS(t){return t.length===1&&t>="0"&&t<="9"}function ES(t){return t.countByGuest}function RS(t){return t.clearBadge}function MS(t){return t.id}function OS(t){return t.id}const BS=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),FS=(t,e,n,r)=>!n||r!==n||t.length===0?[]:_r(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),_S=new Set,LS=[],la=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+/g,"/");n&&!r.startsWith("//")&&(r=`/${r}`);const i=r==="/",o=/^[A-Za-z]:\/$/.test(r);return!i&&!o&&(r=r.replace(/\/+$/,"")),r},$S=()=>{const t=Ze.c(183),{t:e}=jt(),n=Pe(zS),r=Pe(WS),i=Pe(KS),o=Pe(VS),l=Pe(US),a=Pe(HS),d=Pe(GS),u=Pe(qS),h=Pe(YS),f=Pe(QS),x=Pe(XS),b=Pe(JS),w=Pe(ZS),v=tt(e0),y=tt(t0),m=tt(s0),p=Gr(n0);let S;t[0]!==n?(S=qe=>n?qe.activeSessions:LS,t[0]=n,t[1]=S):S=t[1];const g=$s(S);let C;t[2]!==n?(C=qe=>n?qe.ids:_S,t[2]=n,t[3]=C):C=t[3];const k=Gr(C);let j;t[4]!==n?(j=qe=>n?qe.rankById:Ea,t[4]=n,t[5]=j):j=t[5];const D=Ta(j),I=ns(r0),A=Ht(o0),P=Ht(i0),T=ir(),L=Rd(a0),{files:$,git:K}=vn(),F=Tn(l0),{isMobile:W}=zn();let N;t[6]!==T?(N=T?la(T):null,t[6]=T,t[7]=N):N=t[7];const R=N,[E,X]=c.useState(""),re=xu(E,200).trim();let fe;t[8]!==E?(fe=E.trim(),t[8]=E,t[9]=fe):fe=t[9];const ne=fe;let te,ue;t[10]!==n?(te=()=>{n&&X("")},ue=[n],t[10]=n,t[11]=te,t[12]=ue):(te=t[11],ue=t[12]),c.useEffect(te,ue);let Se,we;t[13]!==g||t[14]!==F||t[15]!==K||t[16]!==n?(Se=()=>{if(!n||!K)return;const qe=setTimeout(()=>{const ze=new Set;for(const ft of g){const Be=Ds(ft);!Be||ze.has(Be)||(ze.add(Be),F(Be,K))}},0);return()=>clearTimeout(qe)},we=[n,g,K,F],t[13]=g,t[14]=F,t[15]=K,t[16]=n,t[17]=Se,t[18]=we):(Se=t[17],we=t[18]),c.useEffect(Se,we);let ye;t[19]!==r?(ye=()=>r(!1),t[19]=r,t[20]=ye):ye=t[20];const Ae=ye;let pe;t[21]!==Ae?(pe=qe=>()=>{Ae(),qe()},t[21]=Ae,t[22]=pe):pe=t[22];const O=pe;let Q;t[23]!==A?.id||t[24]!==A?.path||t[25]!==I||t[26]!==m||t[27]!==W||t[28]!==d||t[29]!==u||t[30]!==x||t[31]!==v||t[32]!==O||t[33]!==b||t[34]!==w||t[35]!==l||t[36]!==i||t[37]!==e||t[38]!==p||t[39]!==a?(Q=()=>{const qe=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(M,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:O(()=>{l(!1),v()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(M,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:O(c0)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(M,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:O(d0)},{id:"toggle-sidebar",title:e(W?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(M,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e(W?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:O(()=>{if(W){const{isSessionSwitcherOpen:ze}=Pe.getState();l(!ze)}else a()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(M,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:O(()=>{I&&u(I,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(M,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:O(()=>{I&&d(I)})},{id:"cycle-theme",secondary:!0,title:e("commandPalette.item.cycleTheme"),icon:s.jsx(M,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:e("commandPalette.item.cycleTheme"),onSelect:O(u0)},{id:"open-status",secondary:!0,title:e("commandPalette.item.showOpenCodeStatus"),icon:s.jsx(M,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showOpenCodeStatus"),onSelect:O(f0)},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(M,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:O(()=>i(!0))}];return qe.push({id:"pin-session",secondary:!0,title:e("commandPalette.item.pinSession"),icon:s.jsx(M,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.pinSession"),onSelect:O(()=>{m&&I&&p({directory:I,sessionId:m})})},{id:"copy-session-id",secondary:!0,title:e("commandPalette.item.copySessionId"),icon:s.jsx(M,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.copySessionId"),onSelect:O(()=>{m&&gn(m).then(ze=>{if(ze.ok){Le.success(e("sessions.sidebar.session.copyId.success"));return}Le.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Le.error(e("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:e("commandPalette.item.openMultiRun"),icon:s.jsx(M,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openMultiRun"),onSelect:O(()=>{l(!1),x()})},{id:"open-archive",secondary:!0,title:e("commandPalette.item.openArchive"),icon:s.jsx(M,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openArchive"),onSelect:O(()=>{l(!1),b(!0)})},{id:"open-notes",secondary:!0,title:e("commandPalette.item.openNotes"),icon:s.jsx(M,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openNotes"),onSelect:O(()=>{I&&(w("notes"),u(I,"notes"))})},{id:"open-todos",secondary:!0,title:e("commandPalette.item.openTodos"),icon:s.jsx(M,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openTodos"),onSelect:O(()=>{I&&(w("todos"),u(I,"notes"))})}),qe.push({id:"toggle-memory-debug",secondary:!0,title:e("commandPalette.item.toggleMemoryDebug"),icon:s.jsx(M,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.toggleMemoryDebug"),onSelect:O(m0)}),Ur()&&qe.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(M,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:O(()=>{_n("desktop_open_draft_mini_chat_window",{directory:la(I||A?.path||""),projectId:A?.id??null}).catch(h0)})}),qe},t[23]=A?.id,t[24]=A?.path,t[25]=I,t[26]=m,t[27]=W,t[28]=d,t[29]=u,t[30]=x,t[31]=v,t[32]=O,t[33]=b,t[34]=w,t[35]=l,t[36]=i,t[37]=e,t[38]=p,t[39]=a,t[40]=Q):Q=t[40],A?.id,A?.path;let le;t[41]!==Q?(le=Q(),t[41]=Q,t[42]=le):le=t[42];const H=le,me=Pe(p0);let ge;t[43]===Symbol.for("react.memo_cache_sentinel")?(ge=xn(),t[43]=ge):ge=t[43];const oe=ge;let de,_;t[44]===Symbol.for("react.memo_cache_sentinel")?(de=$n(),_=!oe&&wa(),t[44]=de,t[45]=_):(de=t[44],_=t[45]);let B;t[46]!==W||t[47]!==me?(B={isVSCode:de,isWeb:_,isDesktop:oe,isMobile:W,routingAvailable:me},t[46]=W,t[47]=me,t[48]=B):B=t[48];const he=B;let ve;if(t[49]!==O||t[50]!==i||t[51]!==o||t[52]!==he){let qe;t[54]!==he?(qe=ft=>ft.isAvailable?ft.isAvailable(he):!0,t[54]=he,t[55]=qe):qe=t[55];let ze;t[56]!==O||t[57]!==i||t[58]!==o?(ze=ft=>{const Be=Nh(ft.slug)??"settings-3",Ke=(ft.keywords??[]).join(" ");return{id:`settings:${ft.slug}`,title:ft.title,icon:ft.slug==="mcp"?s.jsx(Hp,{className:"mr-2 h-4 w-4"}):s.jsx(M,{name:Be,className:"mr-2 h-4 w-4"}),searchText:`${ft.title} ${ft.group} ${Ke}`,onSelect:O(()=>{o(ft.slug),i(!0)})}},t[56]=O,t[57]=i,t[58]=o,t[59]=ze):ze=t[59],ve=Ch.filter(g0).filter(qe).map(ze),t[49]=O,t[50]=i,t[51]=o,t[52]=he,t[53]=ve}else ve=t[53];const Re=ve;let ce;if(t[60]!==g||t[61]!==k||t[62]!==D){const qe=g.filter(x0);ce=Wp(qe,k,D),t[60]=g,t[61]=k,t[62]=D,t[63]=ce}else ce=t[63];const se=ce,q=Su(),z=tt(b0);let ee;t[64]!==q||t[65]!==z?(ee=(qe,ze)=>{const ft=z.get(qe);return ft?.branch?ft.branch.trim()||null:ze&&q.get(ze)?.trim()||null},t[64]=q,t[65]=z,t[66]=ee):ee=t[66];const ae=ee;let Ne;t[67]===Symbol.for("react.memo_cache_sentinel")?(Ne=[],t[67]=Ne):Ne=t[67];const[Ce,We]=c.useState(Ne),[Ee,xe]=c.useState(""),$e=BS(R,re);let V;t[68]!==R||t[69]!==$e||t[70]!==n||t[71]!==L||t[72]!==We||t[73]!==xe||t[74]!==re?(V=()=>{if(!n){We([]),xe("");return}if(!$e){We([]),xe("");return}if(!R){We([]),xe("");return}let qe=!1;return L(R,re,40,{type:"file"}).then(ze=>{qe||(We(ze.map(y0)),xe($e))}).catch(()=>{qe||(We([]),xe($e))}),()=>{qe=!0}},t[68]=R,t[69]=$e,t[70]=n,t[71]=L,t[72]=We,t[73]=xe,t[74]=re,t[75]=V):V=t[75];let De;t[76]!==R||t[77]!==$e||t[78]!==n||t[79]!==L||t[80]!==re?(De=[n,R,re,$e,L],t[76]=R,t[77]=$e,t[78]=n,t[79]=L,t[80]=re,t[81]=De):De=t[81],c.useEffect(V,De);const Fe=ne.length>0;let _e;e:{if(!Fe){let ze;t[82]!==H?(ze=H.filter(w0).map(v0),t[82]=H,t[83]=ze):ze=t[83],_e=ze;break e}let qe;t[84]!==H||t[85]!==ne?(qe=_r(H,ne,S0,{limit:7,noFuzzy:!0}),t[84]=H,t[85]=ne,t[86]=qe):qe=t[86],_e=qe}const rt=_e;let ct;e:{if(!Fe){let ze;t[87]===Symbol.for("react.memo_cache_sentinel")?(ze=[],t[87]=ze):ze=t[87],ct=ze;break e}let qe;t[88]!==ne||t[89]!==Re?(qe=_r(Re,ne,j0,{limit:7,noFuzzy:!0}),t[88]=ne,t[89]=Re,t[90]=qe):qe=t[90],ct=qe}const et=ct;let pt;e:{if(!Fe){let ze;t[91]!==se?(ze=se.slice(0,5).map(k0),t[91]=se,t[92]=ze):ze=t[92],pt=ze;break e}let qe;t[93]!==ne||t[94]!==se?(qe=_r(se,ne,C0,{limit:7,threshold:.2}),t[93]=ne,t[94]=se,t[95]=qe):qe=t[95],pt=qe}const kt=pt;let wt;e:{if(!n){let ze;t[96]===Symbol.for("react.memo_cache_sentinel")?(ze=[],t[96]=ze):ze=t[96],wt=ze;break e}let qe;t[97]!==Ce||t[98]!==Ee||t[99]!==$e||t[100]!==re?(qe=FS(Ce,re,$e,Ee),t[97]=Ce,t[98]=Ee,t[99]=$e,t[100]=re,t[101]=qe):qe=t[101],wt=qe}const Xe=wt,yt=n&&$e.length>0&&Ee!==$e;let Rt;e:{if(!Fe){let ze;t[102]===Symbol.for("react.memo_cache_sentinel")?(ze=[],t[102]=ze):ze=t[102],Rt=ze;break e}let qe;if(t[103]!==ne||t[104]!==P){const ze=P.map(N0);qe=_r(ze,ne,A0,{limit:7,threshold:.4}),t[103]=ne,t[104]=P,t[105]=qe}else qe=t[105];Rt=qe}const be=Rt;let Ge,ut,Y,G,Z,je,Ie,Ve,Je,it,at,Ye,vt,Ue;if(t[106]!==ae||t[107]!==Ae||t[108]!==R||t[109]!==$||t[110]!==Fe||t[111]!==n||t[112]!==h||t[113]!==v||t[114]!==E||t[115]!==rt||t[116]!==Xe||t[117]!==be||t[118]!==kt||t[119]!==et||t[120]!==r||t[121]!==y||t[122]!==f||t[123]!==e){const qe=rt.map(D0),ze=et.map(P0),ft=kt.map(I0),Be=Fe?Xe.map(T0):[],Ke=Fe?be.map(E0):[];let He;e:{if(!Fe){He=["commands","sessions"];break e}const It=R0,bt=[{key:"commands",score:It(rt)},{key:"settings",score:It(et)},{key:"sessions",score:It(kt)},{key:"files",score:It(Xe)},{key:"projects",score:It(be)}];bt.sort(M0),He=bt.map(O0)}const nt=He,St=It=>{Ae(),y(It.id,Ds(It))},Lt=async It=>{if(!R)return;const bt=await uf($,It,{directory:R});if(!bt.ok){Le.error(ff(bt.reason));return}h(R,It),Ae()},Ut=(It,bt)=>{Ae(),v({selectedProjectId:It,directoryOverride:bt})},Bt=It=>er(Jr(It,f));G=ys,Ye=n,vt=r;let zt;t[138]!==e?(zt=e("commandPalette.title"),t[138]=e,t[139]=zt):zt=t[139];let _t;t[140]!==zt?(_t=s.jsx(Ps,{children:zt}),t[140]=zt,t[141]=_t):_t=t[141];let Yt;t[142]!==e?(Yt=e("commandPalette.description"),t[142]=e,t[143]=Yt):Yt=t[143];let Zt;t[144]!==Yt?(Zt=s.jsx(Is,{children:Yt}),t[144]=Yt,t[145]=Zt):Zt=t[145],t[146]!==_t||t[147]!==Zt?(Ue=s.jsxs(Vs,{className:"sr-only",children:[_t,Zt]}),t[146]=_t,t[147]=Zt,t[148]=Ue):Ue=t[148],Y=ws,it="overflow-hidden p-0",at=!0,ut=Gp,Ie=!1,Ve="[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-input]]:h-8 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1.5 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4 [&_[cmdk-item]]:typography-meta";let es;t[149]!==e?(es=e("commandPalette.input.placeholder"),t[149]=e,t[150]=es):es=t[150],t[151]!==E||t[152]!==es?(Je=s.jsx(qp,{value:E,onValueChange:X,placeholder:es}),t[151]=E,t[152]=es,t[153]=Je):Je=t[153],Ge=Yp;let Vt;t[154]!==e?(Vt=e("commandPalette.empty.noResults"),t[154]=e,t[155]=Vt):Vt=t[155],t[156]!==Vt?(Z=s.jsx(Qp,{children:Vt}),t[156]=Vt,t[157]=Z):Z=t[157],je=nt.map(It=>It==="commands"&&qe.length>0?s.jsx(Ar,{children:qe.map(bt=>s.jsxs(Lr,{value:bt.id,onSelect:bt.onSelect,children:[bt.icon,s.jsx("span",{children:bt.title}),bt.shortcutId?s.jsx(Kp,{children:Bt(bt.shortcutId)}):null]},bt.id))},"commands"):It==="settings"&&ze.length>0?s.jsx(Ar,{children:ze.map(B0)},"settings"):It==="sessions"&&ft.length>0?s.jsx(Ar,{children:ft.map(bt=>{const cs=bt.title||e("commandPalette.session.untitled"),ms=Ds(bt),hs=ae(bt.id,ms);return s.jsxs(Lr,{value:`session:${bt.id}`,onSelect:()=>St(bt),children:[s.jsx(M,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:cs}),hs?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(M,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:hs})]}):null]},bt.id)})},"sessions"):It==="files"&&Be.length>0?s.jsx(Ar,{children:Be.map(bt=>{const cs=Vp(bt.relativePath||bt.name,{maxLength:80});return s.jsxs(Lr,{value:`file:${bt.path}`,onSelect:()=>{Lt(bt.path)},children:[s.jsx(Pa,{filePath:bt.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":bt.relativePath,children:cs})]},`file:${bt.path}`)})},"files"):It==="projects"&&Ke.length>0?s.jsx(Ar,{children:Ke.map(bt=>{const cs=bt.displayName;return s.jsxs(Lr,{value:`project:${bt.id}`,onSelect:()=>Ut(bt.id,bt.path),children:[s.jsx(M,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:cs}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:bt.path})]},`project:${bt.id}`)})},"projects"):null),t[106]=ae,t[107]=Ae,t[108]=R,t[109]=$,t[110]=Fe,t[111]=n,t[112]=h,t[113]=v,t[114]=E,t[115]=rt,t[116]=Xe,t[117]=be,t[118]=kt,t[119]=et,t[120]=r,t[121]=y,t[122]=f,t[123]=e,t[124]=Ge,t[125]=ut,t[126]=Y,t[127]=G,t[128]=Z,t[129]=je,t[130]=Ie,t[131]=Ve,t[132]=Je,t[133]=it,t[134]=at,t[135]=Ye,t[136]=vt,t[137]=Ue}else Ge=t[124],ut=t[125],Y=t[126],G=t[127],Z=t[128],je=t[129],Ie=t[130],Ve=t[131],Je=t[132],it=t[133],at=t[134],Ye=t[135],vt=t[136],Ue=t[137];let Pt;t[158]!==yt||t[159]!==e?(Pt=yt?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[158]=yt,t[159]=e,t[160]=Pt):Pt=t[160];let ke;t[161]!==Ge||t[162]!==Z||t[163]!==je||t[164]!==Pt?(ke=s.jsxs(Ge,{children:[Z,je,Pt]}),t[161]=Ge,t[162]=Z,t[163]=je,t[164]=Pt,t[165]=ke):ke=t[165];let xt;t[166]!==ut||t[167]!==Ie||t[168]!==Ve||t[169]!==Je||t[170]!==ke?(xt=s.jsxs(ut,{shouldFilter:Ie,className:Ve,children:[Je,ke]}),t[166]=ut,t[167]=Ie,t[168]=Ve,t[169]=Je,t[170]=ke,t[171]=xt):xt=t[171];let Ct;t[172]!==Y||t[173]!==it||t[174]!==at||t[175]!==xt?(Ct=s.jsx(Y,{className:it,showCloseButton:at,children:xt}),t[172]=Y,t[173]=it,t[174]=at,t[175]=xt,t[176]=Ct):Ct=t[176];let Tt;return t[177]!==G||t[178]!==Ye||t[179]!==vt||t[180]!==Ue||t[181]!==Ct?(Tt=s.jsxs(G,{open:Ye,onOpenChange:vt,children:[Ue,Ct]}),t[177]=G,t[178]=Ye,t[179]=vt,t[180]=Ue,t[181]=Ct,t[182]=Tt):Tt=t[182],Tt};function zS(t){return t.isCommandPaletteOpen}function WS(t){return t.setCommandPaletteOpen}function KS(t){return t.setSettingsDialogOpen}function VS(t){return t.setSettingsPage}function US(t){return t.setSessionSwitcherOpen}function HS(t){return t.toggleSidebar}function GS(t){return t.openContextOverview}function qS(t){return t.openContextSurface}function YS(t){return t.openContextFile}function QS(t){return t.shortcutOverrides}function XS(t){return t.openMultiRunLauncher}function JS(t){return t.setArchivePageOpen}function ZS(t){return t.setProjectContextTab}function e0(t){return t.openNewSessionDraft}function t0(t){return t.setCurrentSession}function s0(t){return t.currentSessionId}function n0(t){return t.toggle}function r0(t){return t.currentDirectory}function o0(t){return t.getActiveProject()}function i0(t){return t.projects}function a0(t){return t.searchFiles}function l0(t){return t.ensureStatus}function c0(){ju()}function d0(){fn.requestDirectoryDialog()}function u0(){Xp.invoke("cycle_theme")}function f0(){ku()}function m0(){window.dispatchEvent(new CustomEvent("openchamber:memory-debug-toggle"))}function h0(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function p0(t){return t.routingFeatureAvailable}function g0(t){return t.slug!=="home"}function x0(t){return!Up(t)}function b0(t){return t.worktreeMetadata}function y0(t){return{path:la(t.path),name:t.name,relativePath:t.relativePath}}function w0(t){return!t.secondary}function v0(t){return{item:t,score:0}}function S0(t){return t.searchText}function j0(t){return t.searchText}function k0(t){return{item:t,score:0}}function C0(t){return t.title||""}function N0(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function A0(t){return t.searchText}function D0(t){return t.item}function P0(t){return t.item}function I0(t){return t.item}function T0(t){return t.item}function E0(t){return t.item}function R0(t){return t.length?t[0].score:1/0}function M0(t,e){return t.score-e.score}function O0(t){return t.key}function B0(t){return s.jsxs(Lr,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const Tc=(t,e,n)=>er(Jr(t,e),n),F0=()=>{const t=Ze.c(74),{t:e}=jt(),n=Pe(_0),r=Pe(L0),i=Pe($0);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=$n(),t[0]=o):o=t[0];const l=o;let a,d,u,h,f,x,b,w,v,y,m,p;if(t[1]!==n||t[2]!==r||t[3]!==i||t[4]!==e){const N=[{categoryKey:"helpDialog.section.navigationCommands",items:[{id:"open_command_palette",descriptionKey:"helpDialog.item.openCommandPalette",icon:"command",keys:""},{id:"open_help",descriptionKey:"helpDialog.item.showKeyboardShortcuts",icon:"question",keys:""},{id:"toggle_sidebar",descriptionKey:"helpDialog.item.toggleSessionSidebar",icon:"layout-left",keys:""},{id:"add_selection_to_chat",descriptionKey:"helpDialog.item.addSelectionToChat",icon:"add",keys:""},{id:"cycle_agent",keys:"",descriptionKey:"helpDialog.item.cycleAgent",icon:"ai-agent"},{id:"open_model_selector",descriptionKey:"helpDialog.item.openModelSelector",icon:"ai-generate-2",keys:""},{keys:["↑↓"],descriptionKey:"helpDialog.item.navigateModels",icon:"ai-generate-2"},{keys:["←→"],descriptionKey:"helpDialog.item.adjustThinkingMode",icon:"brain-ai-3"},{id:"cycle_thinking_variant",descriptionKey:"helpDialog.item.cycleThinkingVariant",icon:"brain-ai-3",keys:""},{keys:[er("mod+shift+alt+n")],descriptionKey:"helpDialog.item.newWindow",icon:"window"}]},{categoryKey:"helpDialog.section.sessionManagement",items:[{id:"new_chat",descriptionKey:"helpDialog.item.createNewSession",icon:"add",keys:""},{id:"new_chat_worktree",descriptionKey:"helpDialog.item.createNewWorktreeDraft",icon:"git-branch",keys:""},{id:"open_draft_project_picker",icon:"folder",keys:""},{id:"open_draft_worktree_picker",icon:"git-branch",keys:""},{id:"open_session_list",icon:"list-unordered",keys:""},{id:"focus_input",descriptionKey:"helpDialog.item.focusChatInput",icon:"text",keys:""},{id:"toggle_prompt_navigator",descriptionKey:"helpDialog.item.togglePromptNavigator",icon:"list-unordered",keys:""},{id:"abort_run",descriptionKey:"helpDialog.item.abortActiveRun",icon:"close-circle",keys:""}]},{categoryKey:"helpDialog.section.panels",items:[{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{id:"toggle_terminal_expanded",descriptionKey:"helpDialog.item.toggleTerminalExpanded",icon:"window",keys:""},{keys:[`${er(Li("switch_context_surface",i))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${er(Li("switch_session_tab",i))} + 1...9`],descriptionKey:"helpDialog.item.switchSessionTab",icon:"layout-right"}]},{categoryKey:"helpDialog.section.interface",items:[{id:"cycle_theme",descriptionKey:"helpDialog.item.cycleTheme",icon:"palette",keys:""},{id:"toggle_services_menu",descriptionKey:"helpDialog.item.toggleServicesMenu",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"helpDialog.item.openSettings",icon:"settings-3",keys:""}]}];u=ys,m=n,p=r,d=ws,v="max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let R;t[17]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx(M,{name:"command",className:"h-5 w-5"}),t[17]=R):R=t[17];let E;t[18]!==e?(E=e("helpDialog.title"),t[18]=e,t[19]=E):E=t[19];let X;t[20]!==E?(X=s.jsxs(Ps,{className:"flex items-center gap-2",children:[R,E]}),t[20]=E,t[21]=X):X=t[21];let J;t[22]!==e?(J=e("helpDialog.description"),t[22]=e,t[23]=J):J=t[23];let re;t[24]!==J?(re=s.jsx(Is,{children:J}),t[24]=J,t[25]=re):re=t[25],t[26]!==X||t[27]!==re?(y=s.jsxs(Vs,{children:[X,re]}),t[26]=X,t[27]=re,t[28]=y):y=t[28],a=yn,x="flex-1 min-h-0 mt-3",b="pr-1",w=!0,h="space-y-4",f=N.map(fe=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(fe.categoryKey)}),s.jsx("div",{className:"space-y-1",children:fe.items.filter(ne=>!(l&&ne.id==="toggle_prompt_navigator")).map(ne=>{const te=ne.id?Jp(ne.id):void 0,ue=ne.descriptionKey??(te?.customizable?te.settingsLabelKey:void 0);if(!ue||ne.id&&!Jr(ne.id,i))return null;const Se=ne.id?Tc(ne.id,i,e("settings.openchamber.keyboardShortcuts.unassigned")):Array.isArray(ne.keys)?ne.keys:ne.keys.split(" / ");return s.jsxs("div",{className:"flex items-center justify-between py-1 px-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[ne.icon&&s.jsx(M,{name:ne.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(ue)})]}),s.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(Se)?Se:[Se]).map((we,ye)=>s.jsxs(c.Fragment,{children:[ye>0&&s.jsx("span",{className:"typography-meta text-muted-foreground mx-1",children:e("helpDialog.keyCombiner.or")}),s.jsx("kbd",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 typography-meta font-mono bg-muted rounded border border-border/20",children:we})]},`${we}-${ye}`))})]},ne.id||ue)})})]},fe.categoryKey)),t[1]=n,t[2]=r,t[3]=i,t[4]=e,t[5]=a,t[6]=d,t[7]=u,t[8]=h,t[9]=f,t[10]=x,t[11]=b,t[12]=w,t[13]=v,t[14]=y,t[15]=m,t[16]=p}else a=t[5],d=t[6],u=t[7],h=t[8],f=t[9],x=t[10],b=t[11],w=t[12],v=t[13],y=t[14],m=t[15],p=t[16];let S;t[29]!==h||t[30]!==f?(S=s.jsx("div",{className:h,children:f}),t[29]=h,t[30]=f,t[31]=S):S=t[31];let g;t[32]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(M,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),t[32]=g):g=t[32];let C;t[33]!==e?(C=e("helpDialog.proTips.title"),t[33]=e,t[34]=C):C=t[34];let k;t[35]!==C?(k=s.jsx("p",{className:"font-medium mb-1",children:C}),t[35]=C,t[36]=k):k=t[36];let j;t[37]!==i||t[38]!==e?(j=e("helpDialog.proTips.commandPalette",{shortcut:Tc("open_command_palette",i,e("settings.openchamber.keyboardShortcuts.unassigned"))}),t[37]=i,t[38]=e,t[39]=j):j=t[39];let D;t[40]!==j?(D=s.jsxs("li",{children:["• ",j]}),t[40]=j,t[41]=D):D=t[41];let I;t[42]!==e?(I=e("helpDialog.proTips.recentSessions"),t[42]=e,t[43]=I):I=t[43];let A;t[44]!==I?(A=s.jsxs("li",{children:["• ",I]}),t[44]=I,t[45]=A):A=t[45];let P;t[46]!==e?(P=e("helpDialog.proTips.leaderSequences"),t[46]=e,t[47]=P):P=t[47];let T;t[48]!==P?(T=s.jsxs("li",{children:["• ",P]}),t[48]=P,t[49]=T):T=t[49];let L;t[50]!==D||t[51]!==A||t[52]!==T?(L=s.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[D,A,T]}),t[50]=D,t[51]=A,t[52]=T,t[53]=L):L=t[53];let $;t[54]!==k||t[55]!==L?($=s.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:s.jsxs("div",{className:"flex items-start gap-2",children:[g,s.jsxs("div",{className:"typography-meta text-muted-foreground",children:[k,L]})]})}),t[54]=k,t[55]=L,t[56]=$):$=t[56];let K;t[57]!==a||t[58]!==S||t[59]!==$||t[60]!==x||t[61]!==b||t[62]!==w?(K=s.jsxs(a,{outerClassName:x,className:b,disableHorizontal:w,children:[S,$]}),t[57]=a,t[58]=S,t[59]=$,t[60]=x,t[61]=b,t[62]=w,t[63]=K):K=t[63];let F;t[64]!==d||t[65]!==K||t[66]!==v||t[67]!==y?(F=s.jsxs(d,{className:v,children:[y,K]}),t[64]=d,t[65]=K,t[66]=v,t[67]=y,t[68]=F):F=t[68];let W;return t[69]!==u||t[70]!==F||t[71]!==m||t[72]!==p?(W=s.jsx(u,{open:m,onOpenChange:p,children:F}),t[69]=u,t[70]=F,t[71]=m,t[72]=p,t[73]=W):W=t[73],W};function _0(t){return t.isHelpDialogOpen}function L0(t){return t.setHelpDialogOpen}function $0(t){return t.shortcutOverrides}const z0=()=>{const t=Ze.c(32),{t:e}=jt(),n=Pe(W0),r=Pe(K0),i=Pe(V0);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await gn(i)).ok){Le.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}Le.error(e("openCodeStatusDialog.toast.copyFailed"))},t[0]=i,t[1]=e,t[2]=o):o=t[2];const l=o;let a;t[3]!==e?(a=e("openCodeStatusDialog.title"),t[3]=e,t[4]=a):a=t[4];let d;t[5]!==a?(d=s.jsx(Ps,{children:a}),t[5]=a,t[6]=d):d=t[6];let u;t[7]!==e?(u=e("openCodeStatusDialog.description"),t[7]=e,t[8]=u):u=t[8];let h;t[9]!==u?(h=s.jsx(Is,{children:u}),t[9]=u,t[10]=h):h=t[10];let f;t[11]!==d||t[12]!==h?(f=s.jsxs(Vs,{children:[d,h]}),t[11]=d,t[12]=h,t[13]=f):f=t[13];let x;t[14]!==e?(x=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=x):x=t[15];let b;t[16]!==l||t[17]!==x?(b=s.jsx("div",{className:"flex items-center justify-end",children:s.jsx("button",{type:"button",onClick:l,className:"app-region-no-drag inline-flex h-9 items-center justify-center rounded-md px-3 typography-ui-label font-medium text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:x})}),t[16]=l,t[17]=x,t[18]=b):b=t[18];let w;t[19]!==i||t[20]!==e?(w=i||e("openCodeStatusDialog.empty.noData"),t[19]=i,t[20]=e,t[21]=w):w=t[21];let v;t[22]!==w?(v=s.jsx("pre",{className:"max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap",children:w}),t[22]=w,t[23]=v):v=t[23];let y;t[24]!==f||t[25]!==b||t[26]!==v?(y=s.jsxs(ws,{className:"max-w-2xl",children:[f,b,v]}),t[24]=f,t[25]=b,t[26]=v,t[27]=y):y=t[27];let m;return t[28]!==n||t[29]!==r||t[30]!==y?(m=s.jsx(ys,{open:n,onOpenChange:r,children:y}),t[28]=n,t[29]=r,t[30]=y,t[31]=m):m=t[31],m};function W0(t){return t.isOpenCodeStatusDialogOpen}function K0(t){return t.setOpenCodeStatusDialogOpen}function V0(t){return t.openCodeStatusText}const U0=t=>{const e=Ze.c(16),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:i,sessionSearchInputRef:o,sessionSearchContainerRef:l}=t,a=n===void 0?!0:n;let d,u;e[0]!==a||e[1]!==r||e[2]!==o?(d=()=>{if(!a||!r||typeof window>"u")return;const w=window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>window.cancelAnimationFrame(w)},u=[a,r,o],e[0]=a,e[1]=r,e[2]=o,e[3]=d,e[4]=u):(d=e[3],u=e[4]),c.useEffect(d,u);let h,f;e[5]!==a||e[6]!==o||e[7]!==i?(h=()=>{if(!a||typeof window>"u")return;const w=()=>{i(!0),o.current?.focus(),o.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",w),()=>window.removeEventListener("openchamber:sidebar-session-search",w)},f=[a,i,o],e[5]=a,e[6]=o,e[7]=i,e[8]=h,e[9]=f):(h=e[8],f=e[9]),c.useEffect(h,f);let x,b;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==i?(x=()=>{if(!a||!r||typeof document>"u")return;const w=v=>{l.current&&(l.current.contains(v.target)||i(!1))};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},b=[a,r,i,l],e[10]=a,e[11]=r,e[12]=l,e[13]=i,e[14]=x,e[15]=b):(x=e[14],b=e[15]),c.useEffect(x,b)},H0=t=>{const e=Ze.c(4);let n;e[0]!==t?(n=(o,l)=>{const a=t.get(o);if(!a||a.length===0)return l;const d=new Map(l.map(G0)),u=[];a.forEach(x=>{const b=d.get(x);b&&(u.push(b),d.delete(x))});const h=[],f=[];return l.forEach(x=>{d.has(x.id)&&(x.isArchivedBucket?f.push(x):h.push(x))}),[...h,...u,...f]},e[0]=t,e[1]=n):n=e[1];const r=n;let i;return e[2]!==r?(i={getOrderedGroups:r},e[2]=r,e[3]=i):i=e[3],i};function G0(t){return[t.id,t]}const mo="oc.sessions.projectCollapse",Ec="oc.sessions.groupOrder",Rc="oc.sessions.groupCollapse",Mc=t=>{if(!t)return new Set;try{const e=Ka(jr()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},q0=t=>{if(!t)return new Map;try{const e=qu(jr(),Ka(jr())).safeParse(JSON.parse(t));if(!e.success)return new Map;const n=new Map;for(const[r,i]of Object.entries(e.data))n.set(r,i);return n}catch{return new Map}},Y0=t=>{const e=Ze.c(39),{isVSCode:n,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=Do(),e[0]=i):i=e[0];const o=i;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>Mc(o.getItem(mo)),e[1]=l):l=e[1];const[a,d]=c.useState(l);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>Mc(o.getItem(Rc)),e[2]=u):u=e[2];const[h,f]=c.useState(u);let x;e[3]===Symbol.for("react.memo_cache_sentinel")?(x=()=>q0(o.getItem(Ec)),e[3]=x):x=e[3];const[b,w]=c.useState(x),v=c.useRef(0),y=c.useRef(!1),m=c.useRef(!1),p=c.useRef(null),S=c.useRef(null);let g;e[4]!==n?(g=()=>{if(n)return;const ye=S.current;if(S.current=null,p.current=null,!ye)return;const{projects:Ae}=Ht.getState(),pe=Ae.map(O=>({...O,sidebarCollapsed:ye.has(O.id)}));Br({projects:pe}).catch(Q0)},e[4]=n,e[5]=g):g=e[5];const C=g;let k;e[6]!==C||e[7]!==n?(k=ye=>{!globalThis.window||n||(S.current=ye,p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{C()},700))},e[6]=C,e[7]=n,e[8]=k):k=e[8];const j=k;let D,I;e[9]===Symbol.for("react.memo_cache_sentinel")?(D=()=>()=>{globalThis.window&&p.current!==null&&window.clearTimeout(p.current),p.current=null,S.current=null},I=[],e[9]=D,e[10]=I):(D=e[9],I=e[10]),c.useEffect(D,I);let A,P;e[11]!==b?(P=()=>{if(m.current)try{o.setItem(Ec,JSON.stringify(Object.fromEntries(b.entries())))}catch{}},A=[b,o],e[11]=b,e[12]=A,e[13]=P):(A=e[12],P=e[13]),c.useEffect(P,A);let T,L;e[14]!==h?(T=()=>{if(y.current)try{o.setItem(Rc,JSON.stringify(Array.from(h)))}catch{}},L=[h,o],e[14]=h,e[15]=T,e[16]=L):(T=e[15],L=e[16]),c.useEffect(T,L);let $;e[17]!==r||e[18]!==j?($=()=>{v.current=Date.now()+150,y.current=!0,f(new Set),d(()=>{const ye=new Set(r.map(X0));try{o.setItem(mo,JSON.stringify(Array.from(ye)))}catch{}return j(ye),ye})},e[17]=r,e[18]=j,e[19]=$):$=e[19];const K=$;let F;e[20]!==j?(F=()=>{v.current=Date.now()+150,y.current=!0,f(new Set),d(()=>{const ye=new Set;try{o.setItem(mo,JSON.stringify([]))}catch{}return j(ye),ye})},e[20]=j,e[21]=F):F=e[21];const W=F;let N;e[22]!==j?(N=ye=>{v.current=Date.now()+150,d(Ae=>{const pe=new Set(Ae);pe.has(ye)?pe.delete(ye):pe.add(ye);try{o.setItem(mo,JSON.stringify(Array.from(pe)))}catch{}return j(pe),pe})},e[22]=j,e[23]=N):N=e[23];const R=N;let E;e[24]===Symbol.for("react.memo_cache_sentinel")?(E=ye=>{y.current=!0,f(Ae=>{const pe=new Set(Ae);return pe.has(ye)?pe.delete(ye):pe.add(ye),pe})},e[24]=E):E=e[24];const X=E;let J;e[25]===Symbol.for("react.memo_cache_sentinel")?(J=ye=>{m.current=!0,w(ye)},e[25]=J):J=e[25];const re=J,{getOrderedGroups:fe}=H0(b);let ne;e[26]!==h||e[27]!==a||e[28]!==b?(ne={collapsedProjects:a,collapsedGroups:h,groupOrderByProject:b},e[26]=h,e[27]=a,e[28]=b,e[29]=ne):ne=e[29];const te=ne;let ue;e[30]!==K||e[31]!==W||e[32]!==fe||e[33]!==j||e[34]!==R?(ue={setCollapsedProjects:d,toggleProject:R,collapseAllProjects:K,expandAllProjects:W,scheduleCollapsedProjectsPersist:j,setCollapsedGroups:f,toggleGroup:X,setGroupOrderByProject:re,getOrderedGroups:fe},e[30]=K,e[31]=W,e[32]=fe,e[33]=j,e[34]=R,e[35]=ue):ue=e[35];const Se=ue;let we;return e[36]!==Se||e[37]!==te?(we={state:te,actions:Se},e[36]=Se,e[37]=te,e[38]=we):we=e[38],we};function Q0(){}function X0(t){return t.id}const J0=5*6e4,Z0=t=>{const e=Ze.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:d}=vn(),u=Tn(e2);let h,f;e[0]!==a||e[1]!==u||e[2]!==d||e[3]!==n||e[4]!==o?(h=()=>{if(!a||!d||n.length===0){o(new Map);return}n.forEach(k=>{$i(()=>u(k.normalizedPath,d))})},f=[a,n,d,u,o],e[0]=a,e[1]=u,e[2]=d,e[3]=n,e[4]=o,e[5]=h,e[6]=f):(h=e[5],f=e[6]),c.useEffect(h,f);let x,b;e[7]!==a||e[8]!==i||e[9]!==n||e[10]!==o?(x=()=>{if(!a)return;const k=new Map;n.forEach(j=>{k.set(j.id,i.get(j.normalizedPath)?.isGitRepo??null)}),o(k)},b=[a,n,i,o],e[7]=a,e[8]=i,e[9]=n,e[10]=o,e[11]=x,e[12]=b):(x=e[11],b=e[12]),c.useEffect(x,b);let w;if(e[13]!==i||e[14]!==n){let k;e[16]!==i?(k=j=>{const D=i.get(j.normalizedPath)?.branch??"";return`${j.id}:${D}`},e[16]=i,e[17]=k):k=e[17],w=n.map(k).join("|"),e[13]=i,e[14]=n,e[15]=w}else w=e[15];const v=w;let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=new Map,e[18]=y):y=e[18];const m=c.useRef(y);let p;e[19]===Symbol.for("react.memo_cache_sentinel")?(p=new Map,e[19]=p):p=e[19];const S=c.useRef(p);let g;e[20]!==a||e[21]!==i||e[22]!==n||e[23]!==l?(g=()=>{if(!a)return;let k=!1;const j=setTimeout(()=>{(async()=>{const I=new Set(n.map(t2));for(const K of m.current.keys())I.has(K)||(m.current.delete(K),S.current.delete(K));const A=Date.now(),P=n.filter(K=>{const F=i.get(K.normalizedPath);if(F?.isGitRepo===!1)return m.current.delete(K.id),S.current.delete(K.id),!1;if(F?.isGitRepo!==!0||F.branch===null)return!1;const W=F.branch.trim(),N=`${K.normalizedPath}\0${W}`,R=m.current.get(K.id);if(R===N){const E=S.current.get(K.id);return E&&(E.at=A),!1}return!(R!==void 0&&A-(S.current.get(K.id)?.at??0)<J0)});if(P.length===0)return;const T=await Zp(P,2,async K=>{const F=i.get(K.normalizedPath)?.branch?.trim()??"",W=`${K.normalizedPath}\0${F}`,N=await $i(()=>Aa(K.normalizedPath,F?{knownBranch:F}:void 0)).catch(s2);return{id:K.id,inputKey:W,branch:N}});if(k)return;const L=T.filter(n2);if(L.length===0)return;const $=Date.now();l(K=>{const F=new Map(K);return L.forEach(W=>{const{id:N,branch:R}=W;R&&F.set(N,R)}),F}),L.forEach(K=>{const{id:F,inputKey:W,branch:N}=K;m.current.set(F,W),N&&S.current.set(F,{branch:N,at:$})})})()},150);return()=>{k=!0,clearTimeout(j)}},e[20]=a,e[21]=i,e[22]=n,e[23]=l,e[24]=g):g=e[24];let C;e[25]!==a||e[26]!==i||e[27]!==n||e[28]!==v||e[29]!==l?(C=[a,n,v,i,l],e[25]=a,e[26]=i,e[27]=n,e[28]=v,e[29]=l,e[30]=C):C=e[30],c.useEffect(g,C)};function e2(t){return t.ensureStatus}function t2(t){return t.id}function s2(){return null}function n2(t){return t.branch}const r2=t=>{const e=Ze.c(10),{open:n,onOpenChange:r,project:i,onSave:o}=t;let l;e[0]!==o||e[1]!==n||e[2]!==i?(l=n&&i?s.jsx(Ah,{project:i,onIdentitySave:o,showWorktrees:!1}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=l):l=e[3];let a;e[4]!==l?(a=s.jsx(ws,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(yn,{outerClassName:"max-h-[min(90vh,48rem)]",className:"w-full bg-transparent",children:s.jsx("div",{className:"w-full p-3 sm:p-6 sm:pt-8",children:l})})}),e[4]=l,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==n||e[8]!==a?(d=s.jsx(ys,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=d):d=e[9],d};function o2(t){const e=Ze.c(218),{t:n}=jt(),r=Cu(),{hideDirectoryControls:i,showProjectDisplayControls:o,showRecentControls:l,handleOpenDirectoryDialog:a,onOpenScheduled:d,onOpenMultiRun:u,canOpenMultiRun:h,onOpenArchive:f,headerActionIconClass:x,headerActionButtonClass:b,isSessionSearchOpen:w,setIsSessionSearchOpen:v,sessionSearchInputRef:y,sessionSearchQuery:m,setSessionSearchQuery:p,hasSessionSearchQuery:S,searchMatchCount:g,collapseAllProjects:C,expandAllProjects:k}=t,j=fs(y2),D=fs(b2),I=us(x2),A=us(g2),P=us(p2),T=us(h2),L=us(m2),$=us(f2),K=us(u2),F=us(d2),W=us(c2),N=us(l2),R=o&&W==="single";if(i)return null;let E;e[0]!==b?(E=Oe(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=b,e[1]=E):E=e[1];let X;e[2]!==n?(X=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=X):X=e[3];let J;e[4]!==x?(J=s.jsx(M,{name:"folder-add",className:x}),e[4]=x,e[5]=J):J=e[5];let re;e[6]!==a||e[7]!==E||e[8]!==X||e[9]!==J?(re=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:E,"aria-label":X,children:J})}),e[6]=a,e[7]=E,e[8]=X,e[9]=J,e[10]=re):re=e[10];let fe;e[11]!==n?(fe=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=fe):fe=e[12];let ne;e[13]!==fe?(ne=s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:fe})}),e[13]=fe,e[14]=ne):ne=e[14];let te;e[15]!==re||e[16]!==ne?(te=s.jsxs(Nt,{children:[re,ne]}),e[15]=re,e[16]=ne,e[17]=te):te=e[17];let ue;e[18]!==b?(ue=Oe(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=b,e[19]=ue):ue=e[19];let Se;e[20]!==n?(Se=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=Se):Se=e[21];let we;e[22]!==x?(we=s.jsx(M,{name:"calendar-schedule",className:x}),e[22]=x,e[23]=we):we=e[23];let ye;e[24]!==d||e[25]!==ue||e[26]!==Se||e[27]!==we?(ye=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,className:ue,"aria-label":Se,children:we})}),e[24]=d,e[25]=ue,e[26]=Se,e[27]=we,e[28]=ye):ye=e[28];let Ae;e[29]!==n?(Ae=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=Ae):Ae=e[30];let pe;e[31]!==Ae?(pe=s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Ae})}),e[31]=Ae,e[32]=pe):pe=e[32];let O;e[33]!==ye||e[34]!==pe?(O=s.jsxs(Nt,{children:[ye,pe]}),e[33]=ye,e[34]=pe,e[35]=O):O=e[35];let Q;e[36]!==b?(Q=Oe(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=b,e[37]=Q):Q=e[37];let le;e[38]!==n?(le=n("sessions.sidebar.header.actions.newMultiRun"),e[38]=n,e[39]=le):le=e[39];const H=!h;let me;e[40]!==x?(me=s.jsx(sg,{className:x}),e[40]=x,e[41]=me):me=e[41];let ge;e[42]!==u||e[43]!==Q||e[44]!==le||e[45]!==H||e[46]!==me?(ge=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:Q,"aria-label":le,disabled:H,children:me})}),e[42]=u,e[43]=Q,e[44]=le,e[45]=H,e[46]=me,e[47]=ge):ge=e[47];let oe;e[48]!==n?(oe=n("sessions.sidebar.header.actions.newMultiRun"),e[48]=n,e[49]=oe):oe=e[49];let de;e[50]!==oe?(de=s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:oe})}),e[50]=oe,e[51]=de):de=e[51];let _;e[52]!==ge||e[53]!==de?(_=s.jsxs(Nt,{children:[ge,de]}),e[52]=ge,e[53]=de,e[54]=_):_=e[54];let B;e[55]!==b?(B=Oe(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[55]=b,e[56]=B):B=e[56];let he;e[57]!==n?(he=n("sessions.sidebar.nav.archive"),e[57]=n,e[58]=he):he=e[58];let ve;e[59]!==x?(ve=s.jsx(M,{name:"archive",className:x}),e[59]=x,e[60]=ve):ve=e[60];let Re;e[61]!==f||e[62]!==B||e[63]!==he||e[64]!==ve?(Re=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,className:B,"aria-label":he,children:ve})}),e[61]=f,e[62]=B,e[63]=he,e[64]=ve,e[65]=Re):Re=e[65];let ce;e[66]!==n?(ce=n("sessions.sidebar.nav.archive"),e[66]=n,e[67]=ce):ce=e[67];let se;e[68]!==ce?(se=s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ce})}),e[68]=ce,e[69]=se):se=e[69];let q;e[70]!==Re||e[71]!==se?(q=s.jsxs(Nt,{children:[Re,se]}),e[70]=Re,e[71]=se,e[72]=q):q=e[72];let z;e[73]!==r||e[74]!==x||e[75]!==n?(z=r.length>0&&s.jsxs(Ks,{children:[s.jsx(zs,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"xs",className:"w-6 text-muted-foreground","aria-label":n("sessions.sidebar.header.actions.extensionPages"),children:s.jsx(M,{name:"apps",className:x})})}),s.jsxs(Ws,{align:"start",children:[s.jsx(Fr,{children:n("sessions.sidebar.header.actions.extensionPages")}),r.map(a2)]})]}),e[73]=r,e[74]=x,e[75]=n,e[76]=z):z=e[76];let ee;e[77]!==O||e[78]!==_||e[79]!==q||e[80]!==z||e[81]!==te?(ee=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[te,O,_,q,z]}),e[77]=O,e[78]=_,e[79]=q,e[80]=z,e[81]=te,e[82]=ee):ee=e[82];let ae;e[83]!==v?(ae=()=>v(i2),e[83]=v,e[84]=ae):ae=e[84];let Ne;e[85]!==b?(Ne=Oe(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[85]=b,e[86]=Ne):Ne=e[86];let Ce;e[87]!==n?(Ce=n("sessions.sidebar.header.actions.searchSessions"),e[87]=n,e[88]=Ce):Ce=e[88];let We;e[89]!==x?(We=s.jsx(M,{name:"search",className:x}),e[89]=x,e[90]=We):We=e[90];let Ee;e[91]!==w||e[92]!==ae||e[93]!==Ne||e[94]!==Ce||e[95]!==We?(Ee=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:ae,className:Ne,"aria-label":Ce,"aria-expanded":w,children:We})}),e[91]=w,e[92]=ae,e[93]=Ne,e[94]=Ce,e[95]=We,e[96]=Ee):Ee=e[96];let xe;e[97]!==n?(xe=n("sessions.sidebar.header.actions.searchSessions"),e[97]=n,e[98]=xe):xe=e[98];let $e;e[99]!==xe?($e=s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:xe})}),e[99]=xe,e[100]=$e):$e=e[100];let V;e[101]!==Ee||e[102]!==$e?(V=s.jsxs(Nt,{children:[Ee,$e]}),e[101]=Ee,e[102]=$e,e[103]=V):V=e[103];const De=j&&"bg-interactive-hover text-primary";let Fe;e[104]!==b||e[105]!==De?(Fe=Oe(b,"text-muted-foreground hover:text-foreground hover:bg-transparent",De),e[104]=b,e[105]=De,e[106]=Fe):Fe=e[106];let _e;e[107]!==j||e[108]!==n?(_e=n(j?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[107]=j,e[108]=n,e[109]=_e):_e=e[109];let rt;e[110]!==x?(rt=s.jsx(M,{name:"checkbox-multiple",className:x}),e[110]=x,e[111]=rt):rt=e[111];let ct;e[112]!==j||e[113]!==Fe||e[114]!==_e||e[115]!==rt||e[116]!==D?(ct=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:D,className:Fe,"aria-label":_e,"aria-pressed":j,children:rt})}),e[112]=j,e[113]=Fe,e[114]=_e,e[115]=rt,e[116]=D,e[117]=ct):ct=e[117];let et;e[118]!==j||e[119]!==n?(et=n(j?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[118]=j,e[119]=n,e[120]=et):et=e[120];let pt;e[121]!==et?(pt=s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:et})}),e[121]=et,e[122]=pt):pt=e[122];let kt;e[123]!==ct||e[124]!==pt?(kt=s.jsxs(Nt,{children:[ct,pt]}),e[123]=ct,e[124]=pt,e[125]=kt):kt=e[125];let wt;e[126]!==b?(wt=Oe(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[126]=b,e[127]=wt):wt=e[127];let Xe;e[128]!==n?(Xe=n("sessions.sidebar.header.displayMode.label"),e[128]=n,e[129]=Xe):Xe=e[129];let yt;e[130]!==x?(yt=s.jsx(M,{name:"equalizer-2",className:x}),e[130]=x,e[131]=yt):yt=e[131];let Rt;e[132]!==wt||e[133]!==Xe||e[134]!==yt?(Rt=s.jsx(At,{asChild:!0,children:s.jsx(zs,{asChild:!0,children:s.jsx("button",{type:"button",className:wt,"aria-label":Xe,children:yt})})}),e[132]=wt,e[133]=Xe,e[134]=yt,e[135]=Rt):Rt=e[135];let be;e[136]!==n?(be=n("sessions.sidebar.header.displayMode.label"),e[136]=n,e[137]=be):be=e[137];let Ge;e[138]!==be?(Ge=s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:be})}),e[138]=be,e[139]=Ge):Ge=e[139];let ut;e[140]!==Rt||e[141]!==Ge?(ut=s.jsxs(Nt,{children:[Rt,Ge]}),e[140]=Rt,e[141]=Ge,e[142]=ut):ut=e[142];let Y;e[143]!==n?(Y=n("sessions.sidebar.header.actions.sortProjects"),e[143]=n,e[144]=Y):Y=e[144];let G;e[145]!==Y?(G=s.jsx(Fr,{children:Y}),e[145]=Y,e[146]=G):G=e[146];let Z;e[147]!==P||e[148]!==T||e[149]!==n?(Z=[["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"]].map(Ke=>{const[He,nt]=Ke;return s.jsxs(Kt,{onClick:()=>{T(He),Br({sidebarProjectSortOrder:He})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(nt)}),P===He?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null]},He)}),e[147]=P,e[148]=T,e[149]=n,e[150]=Z):Z=e[150];let je;e[151]===Symbol.for("react.memo_cache_sentinel")?(je=s.jsx(Os,{}),e[151]=je):je=e[151];let Ie;e[152]!==W||e[153]!==N||e[154]!==o||e[155]!==n?(Ie=o?s.jsxs(s.Fragment,{children:[s.jsx(Fr,{children:n("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(Ke=>{const[He,nt]=Ke;return s.jsxs(Kt,{onClick:()=>{N(He),Br({sidebarProjectDisplayMode:He})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(nt)}),W===He?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null]},He)}),s.jsx(Os,{})]}):null,e[152]=W,e[153]=N,e[154]=o,e[155]=n,e[156]=Ie):Ie=e[156];let Ve;e[157]!==n?(Ve=n("sessions.sidebar.header.grouping.label"),e[157]=n,e[158]=Ve):Ve=e[158];let Je;e[159]!==Ve?(Je=s.jsx(Fr,{children:Ve}),e[159]=Ve,e[160]=Je):Je=e[160];let it;e[161]!==L||e[162]!==$||e[163]!==n?(it=[["by-worktree","sessions.sidebar.header.grouping.byWorktree"],["flat","sessions.sidebar.header.grouping.flat"]].map(Ke=>{const[He,nt]=Ke;return s.jsxs(Kt,{onClick:()=>{$(He),Br({sidebarSessionGroupingMode:He})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(nt)}),L===He?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null]},He)}),e[161]=L,e[162]=$,e[163]=n,e[164]=it):it=e[164];let at;e[165]===Symbol.for("react.memo_cache_sentinel")?(at=s.jsx(Os,{}),e[165]=at):at=e[165];let Ye;e[166]!==R||e[167]!==l||e[168]!==I||e[169]!==n||e[170]!==A?(Ye=l&&!R?s.jsxs(Kt,{onClick:()=>{A(),Br({sidebarShowRecentSection:!I})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),I?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[166]=R,e[167]=l,e[168]=I,e[169]=n,e[170]=A,e[171]=Ye):Ye=e[171];let vt;e[172]!==n?(vt=n("sessions.sidebar.header.displayMode.stickyHeaders"),e[172]=n,e[173]=vt):vt=e[173];let Ue;e[174]!==vt?(Ue=s.jsx("span",{children:vt}),e[174]=vt,e[175]=Ue):Ue=e[175];let Pt;e[176]!==K?(Pt=K?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null,e[176]=K,e[177]=Pt):Pt=e[177];let ke;e[178]!==Ue||e[179]!==Pt||e[180]!==F?(ke=s.jsxs(Kt,{onClick:F,className:"flex items-center justify-between",children:[Ue,Pt]}),e[178]=Ue,e[179]=Pt,e[180]=F,e[181]=ke):ke=e[181];let xt;e[182]!==C||e[183]!==k||e[184]!==R||e[185]!==n?(xt=R?null:s.jsxs(s.Fragment,{children:[s.jsx(Os,{}),s.jsxs(Kt,{onClick:C,className:"flex items-center gap-2",children:[s.jsx(M,{name:"contract-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.collapseAll")})]}),s.jsxs(Kt,{onClick:k,className:"flex items-center gap-2",children:[s.jsx(M,{name:"expand-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.expandAll")})]})]}),e[182]=C,e[183]=k,e[184]=R,e[185]=n,e[186]=xt):xt=e[186];let Ct;e[187]!==G||e[188]!==Z||e[189]!==Ie||e[190]!==Je||e[191]!==it||e[192]!==Ye||e[193]!==ke||e[194]!==xt?(Ct=s.jsxs(Ws,{align:"end",className:"min-w-[180px]",children:[G,Z,je,Ie,Je,it,at,Ye,ke,xt]}),e[187]=G,e[188]=Z,e[189]=Ie,e[190]=Je,e[191]=it,e[192]=Ye,e[193]=ke,e[194]=xt,e[195]=Ct):Ct=e[195];let Tt;e[196]!==ut||e[197]!==Ct?(Tt=s.jsxs(Ks,{children:[ut,Ct]}),e[196]=ut,e[197]=Ct,e[198]=Tt):Tt=e[198];let qe;e[199]!==V||e[200]!==kt||e[201]!==Tt?(qe=s.jsxs("div",{className:"flex items-center gap-1.5",children:[V,kt,Tt]}),e[199]=V,e[200]=kt,e[201]=Tt,e[202]=qe):qe=e[202];let ze;e[203]!==ee||e[204]!==qe?(ze=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[ee,qe]}),e[203]=ee,e[204]=qe,e[205]=ze):ze=e[205];let ft;e[206]!==S||e[207]!==w||e[208]!==g||e[209]!==y||e[210]!==m||e[211]!==v||e[212]!==p||e[213]!==n?(ft=w?s.jsxs("div",{className:"pb-1",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between px-0.5 typography-micro text-muted-foreground/80",children:[S?s.jsx("span",{children:g===1?n("sessions.sidebar.header.search.matchCountSingle",{count:g}):n("sessions.sidebar.header.search.matchCountPlural",{count:g})}):s.jsx("span",{}),s.jsx("span",{children:n("sessions.sidebar.header.search.escapeHint")})]}),s.jsx(Vd,{inputRef:y,value:m,onSearch:p,onClose:()=>v(!1),placeholder:n("sessions.sidebar.header.search.placeholder"),clearLabel:n("sessions.sidebar.header.search.clear")})]}):null,e[206]=S,e[207]=w,e[208]=g,e[209]=y,e[210]=m,e[211]=v,e[212]=p,e[213]=n,e[214]=ft):ft=e[214];let Be;return e[215]!==ze||e[216]!==ft?(Be=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1",children:s.jsxs("div",{className:"flex h-auto min-h-8 flex-col gap-1",children:[ze,ft]})}),e[215]=ze,e[216]=ft,e[217]=Be):Be=e[217],Be}function i2(t){return!t}function a2(t){return s.jsxs(Kt,{onSelect:()=>Pe.getState().setOpenGuestPage(t.id),children:[s.jsx(Xr,{icon:tg(t.icon),iconSrc:eg(t.id,t.icon,ya().authenticatedAsset),className:"size-4"}),s.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function l2(t){return t.setProjectDisplayMode}function c2(t){return t.projectDisplayMode}function d2(t){return t.toggleStickyZoneHeaders}function u2(t){return t.stickyZoneHeaders}function f2(t){return t.setSessionGroupingMode}function m2(t){return t.sessionGroupingMode}function h2(t){return t.setProjectSortOrder}function p2(t){return t.projectSortOrder}function g2(t){return t.toggleRecentSection}function x2(t){return t.showRecentSection}function b2(t){return t.toggleMode}function y2(t){return t.enabled}function w2(t){const e=Ze.c(8),{t:n}=jt(),r=t.onNewSession;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(M,{name:"chat-new",className:"h-4 w-4 flex-shrink-0"}),e[0]=i):i=e[0];let o;e[1]!==n?(o=n("sessions.sidebar.header.actions.newSession"),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==o?(l=s.jsx("span",{className:"truncate",children:o}),e[3]=o,e[4]=l):l=e[4];let a;return e[5]!==t.onNewSession||e[6]!==l?(a=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 pt-1.5",children:s.jsxs("button",{type:"button",onClick:r,className:"flex w-full min-w-0 items-center gap-2 rounded-md px-1.5 py-1 text-left typography-ui-label font-normal text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[i,l]})}),e[5]=t.onNewSession,e[6]=l,e[7]=a):a=e[7],a}const wi="inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";function v2(t){const e=Ze.c(13),{onOpenSettings:n,onOpenShortcuts:r,onOpenAbout:i,onOpenUpdate:o,showRuntimeButtons:l,showUpdateButton:a}=t,d=l===void 0?!0:l,u=a===void 0?!0:a,{t:h}=jt();if(!d&&!u)return null;let f;e[0]!==i||e[1]!==n||e[2]!==r||e[3]!==d||e[4]!==h?(f=d?s.jsxs(s.Fragment,{children:[s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:wi,"aria-label":h("sessions.sidebar.footer.actions.settings"),children:s.jsx(M,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(Dt,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:wi,"aria-label":h("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(M,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(Dt,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:wi,"aria-label":h("sessions.sidebar.footer.actions.aboutOpenChamber"),children:s.jsx(M,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(Dt,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[0]=i,e[1]=n,e[2]=r,e[3]=d,e[4]=h,e[5]=f):f=e[5];let x;e[6]!==o||e[7]!==u||e[8]!==h?(x=u?s.jsx(dt,{type:"button",variant:"default",size:"xs",className:"ml-auto border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)]/80 hover:text-[var(--status-info)] dark:border-[var(--status-info-border)] dark:bg-[var(--status-info-background)] dark:hover:bg-[var(--status-info-background)]/80",onClick:o,children:h("sessions.sidebar.footer.actions.update")}):null,e[6]=o,e[7]=u,e[8]=h,e[9]=x):x=e[9];let b;return e[10]!==f||e[11]!==x?(b=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[f,x]}),e[10]=f,e[11]=x,e[12]=b):b=e[12],b}const S2=t=>{for(const e of t.sessions.values())if(e.tabs.some(Od))return!0;return!1},j2=()=>{const t=Ze.c(4),{terminal:e}=vn(),n=Ot(S2);let r,i;return t[0]!==n||t[1]!==e?(r=()=>{const o=k2,l=C2;if(n)return Ii(e,"",l,o);let a=N2;return a=Ii(e,"",l,d=>{o(d),a()}),()=>a()},i=[e,n],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i),null};function k2(t){const e=Ot.getState(),n=Dh(t.sessions),r=new Set([...e.sessions.keys(),...n.keys()]);for(const i of r)e.reconcileServerSessions(i,n.get(i)??[],{startedActionMutationRevisions:t.startedActionMutationRevisions})}function C2(){return new Map(Ot.getState().actionMutationRevisions)}function N2(){}const A2=t=>{const e=Ze.c(12),{normalizedProjects:n,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:d,foldersMap:u,createFolder:h,addSessionToFolder:f}=t,x=r===void 0?!0:r;let b,w;e[0]!==f||e[1]!==h||e[2]!==x||e[3]!==u||e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==i||e[9]!==d?(b=()=>{!x||o||!l||a||n.forEach(v=>{if(d.has(v.normalizedPath))return;const y=Nu(v.normalizedPath),m=i.archivedSessionsByProject.get(v.id)??[],p=u[y]??[],S=new Map(p.map(D2));m.forEach(g=>{const C=ng(g,v.normalizedPath),k=C.toLowerCase();let j=S.get(k);j||(j=h(y,C),S.set(k,j)),j.sessionIds.includes(g.id)||f(y,j.id,g.id)})})},w=[n,x,i,o,l,a,d,u,h,f],e[0]=f,e[1]=h,e[2]=x,e[3]=u,e[4]=l,e[5]=o,e[6]=a,e[7]=n,e[8]=i,e[9]=d,e[10]=b,e[11]=w):(b=e[10],w=e[11]),c.useEffect(b,w)};function D2(t){return[t.name.toLowerCase(),t]}function P2({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:n,projectMap:r,metaByProject:i,rememberedSessionId:o,fallbackSessionId:l}){if(e&&n===t)return{kind:"preserve-current"};if(n==null){const u=!!(e&&Array.from(i.entries()).some(([h,f])=>h!==t&&f.has(e)));if(e&&r&&!u)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const d=(o&&r.has(o)?o:null)??l;return!d||d===e?{kind:"none"}:{kind:"select-session",sessionId:d}}const I2=t=>{const e=Ze.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:d,newSessionDraftOpen:u,mobileVariant:h,openNewSessionDraft:f,setSessionSwitcherOpen:x}=t;let b,w;if(e[0]!==n){w=new Map,b=new Map;const k=(j,D,I,A)=>{w.has(j)||w.set(j,new Map);const P=w.get(j);A.forEach(T=>{const L=ht(T.worktree?.path??T.session.directory??I??D);P.set(T.session.id,{directory:L}),b.has(j)||b.set(j,{id:T.session.id,directory:L}),T.children.length>0&&k(j,D,L,T.children)})};n.forEach(j=>{j.groups.forEach(D=>{k(j.project.id,j.project.normalizedPath,D.directory,D.sessions)})}),e[0]=n,e[1]=b,e[2]=w}else b=e[1],w=e[2];let v;e[3]!==b||e[4]!==w?(v={metaByProject:w,firstSessionByProject:b},e[3]=b,e[4]=w,e[5]=v):v=e[5];const y=v,m=c.useRef(null);let p,S;e[6]!==r||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==d||e[11]!==h||e[12]!==u||e[13]!==f||e[14]!==n||e[15]!==y||e[16]!==o||e[17]!==x?(p=()=>{if(!r||u||Pe.getState().isNewWorktreeDialogOpen||m.current===r)return;const k=n.find(A=>A.project.id===r);if(!k)return;const j=y.metaByProject.get(r);if(l&&j&&j.has(l)){m.current=r,o(A=>{if(A.get(r)===l)return A;const P=new Map(A);return P.set(r,l),P});return}const D=P2({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:j,metaByProject:y.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:y.firstSessionByProject.get(r)?.id??null});if(D.kind==="preserve-current"){a===r&&(m.current=r);return}if(m.current=r,D.kind==="open-draft"){h&&x(!1),f({selectedProjectId:k.project.id,directoryOverride:k.project.normalizedPath});return}if(D.kind!=="select-session")return;const I=j?.get(D.sessionId)?.directory??null;d(D.sessionId,I)},S=[r,i,l,a,d,u,h,f,n,y,x,o],e[6]=r,e[7]=i,e[8]=l,e[9]=a,e[10]=d,e[11]=h,e[12]=u,e[13]=f,e[14]=n,e[15]=y,e[16]=o,e[17]=x,e[18]=p,e[19]=S):(p=e[18],S=e[19]),c.useLayoutEffect(p,S);let g,C;e[20]!==r||e[21]!==l||e[22]!==y||e[23]!==o?(g=()=>{if(!r||!l)return;const k=y.metaByProject.get(r);!k||!k.has(l)||o(j=>{if(j.get(r)===l)return j;const D=new Map(j);return D.set(r,l),D})},C=[r,l,y,o],e[20]=r,e[21]=l,e[22]=y,e[23]=o,e[24]=g,e[25]=C):(g=e[24],C=e[25]),c.useEffect(g,C)},T2=t=>{const e=Ze.c(20);let n,r,i,o;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:i,sessionOwnerBySessionId:o,...n}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=o):(n=e[1],r=e[2],i=e[3],o=e[4]);const l=tt(E2),a=tt(R2);let d;e[5]!==l||e[6]!==o?(d=l?o?.get(l)?.projectId??null:null,e[5]=l,e[6]=o,e[7]=d):d=e[7];const u=d;let h;e[8]!==r?(h=()=>new Map(r),e[8]=r,e[9]=h):h=e[9];const[f,x]=c.useState(h);let b;e[10]!==f||e[11]!==n||e[12]!==l||e[13]!==u||e[14]!==a?(b={...n,activeSessionByProject:f,setActiveSessionByProject:x,currentSessionId:l,currentSessionOwnerProjectId:u,newSessionDraftOpen:a},e[10]=f,e[11]=n,e[12]=l,e[13]=u,e[14]=a,e[15]=b):b=e[15],I2(b);let w,v;return e[16]!==f||e[17]!==i?(w=()=>{i(f)},v=[f,i],e[16]=f,e[17]=i,e[18]=w,e[19]=v):(w=e[18],v=e[19]),c.useEffect(w,v),null};function E2(t){return t.currentSessionId}function R2(t){return!!t.newSessionDraft?.open}const M2=(t,e)=>t?e.kind!==t.kind?e.kind==="project":e.projectRoot.length!==t.projectRoot.length?e.projectRoot.length>t.projectRoot.length:e.projectId.localeCompare(t.projectId)<0:!0,Oc=(t,e,n)=>{M2(t.get(e),n)&&t.set(e,n)},O2=t=>{const e=t;return ht(e.directory)??ht(e.project?.worktree)},B2=(t,e,n,r,i=[])=>{const o=new Map,l=new Map;for(const w of e){const v=ht(w.normalizedPath);if(!v)continue;const y=l.get(v);(!y||w.id.localeCompare(y.id)<0)&&l.set(v,w),Oc(o,v,{projectId:w.id,projectRoot:v,scopeDirectory:v,kind:"project"})}if(!r)for(const[w,v]of n){const y=ht(w),m=y?l.get(y):void 0;if(!(!m||!y))for(const p of v){const S=ht(p.path);S&&Oc(o,S,{projectId:m.id,projectRoot:y,scopeDirectory:S,kind:"worktree"})}}const a=new Map,d=new Map,u=new Map,h=new Map,f=new Map,x=w=>{if(!w)return null;if(a.has(w))return a.get(w)??null;if(r){const p=o.get(w)??null;return a.set(w,p),p}const v=[];let y=w,m=null;for(;y;){if(a.has(y)){m=a.get(y)??null;break}if(v.push(y),m=o.get(y)??null,m)break;y=Xm(y)}for(const p of v)a.set(p,m);return m},b=(w,v,y)=>{for(const m of w){const p=x(O2(m));if(!p)continue;d.set(m.id,p);const S=v.get(p.projectId);if(S?S.push(m):v.set(p.projectId,[m]),!y)continue;const g=y.get(p.scopeDirectory);g?g.add(m.id):y.set(p.scopeDirectory,new Set([m.id]))}};return b(t,u,f),b(i,h),{bySessionId:d,sessionsByProject:u,archivedSessionsByProject:h,sessionsByScope:f,directoryResolutions:a.size}},F2=t=>{const e=Ze.c(7),{ownership:n}=t;let r;e[0]!==n?(r=d=>n.sessionsByProject.get(d)??[],e[0]=n,e[1]=r):r=e[1];const i=r;let o;e[2]!==n?(o=d=>n.archivedSessionsByProject.get(d)??[],e[2]=n,e[3]=o):o=e[3];const l=o;let a;return e[4]!==l||e[5]!==i?(a={getSessionsForProject:i,getArchivedSessionsForProject:l},e[4]=l,e[5]=i,e[6]=a):a=e[6],a},Yn=(t,e)=>`${t}\0${e}`,vr=(t,e)=>t??Ra(e)??ht(e??null),Yr=t=>{if(t.folderScopes&&t.folderScopes.length>0)return t.folderScopes;const e=t.folderScopeKey??ht(t.directory??null);return e?[{scopeKey:e,directory:t.directory}]:[]},Za=t=>t.startsWith("__archived__:"),_2=(t,e)=>t.map(n=>{const r=ht(n.path)??n.path;return`${r}=${e.get(r)??""}`}).join(`
|
|
879
|
-
`),L2=[],$2=t=>{const{normalizedProjects:e,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:o,projectRootBranches:l,gitBranches:a,lastRepoStatus:d,buildGroupedSessions:u,hasSessionSearchQuery:h,normalizedSessionSearchQuery:f,filterSessionNodesForSearch:x,buildGroupSearchText:b,foldersMap:w,standaloneGroups:v}=t,y=c.useRef(new Map),m=c.useMemo(()=>{const I=y.current,A=new Map;let P=0,T=0;const L=(K,F)=>K.length===F.length&&K.every((W,N)=>W===F[N]),$=e.map(K=>{const F=n(K.id),W=r(K.id),N=i.get(K.normalizedPath)??L2,R=o.has(K.id)?!!o.get(K.id):d,E=l.get(K.id)??null,X=_2(N,a),J=I.get(K.id);if(J&&J.project===K&&L(J.activeSessions,F)&&L(J.archivedSessions,W)&&J.availableWorktrees===N&&J.rootBranch===E&&J.worktreeBranchesKey===X&&J.isRepo===R&&J.buildGroupedSessions===u)return P+=1,A.set(K.id,J),J.section;if(T+=1,J){const te=J.project!==K?"project":L(J.activeSessions,F)?L(J.archivedSessions,W)?J.availableWorktrees!==N?"worktrees":J.rootBranch!==E?"branch":J.worktreeBranchesKey!==X?"worktreeBranches":J.isRepo!==R?"repo":"builder":"archived":"sessions";Gs(`ui.sidebar.project_section.rebuilt_reason.${te}`)}const re=Au([...F,...W]),fe=u(re,K.normalizedPath,N,E,R),ne={project:K,groups:fe};return A.set(K.id,{project:K,activeSessions:F,archivedSessions:W,availableWorktrees:N,rootBranch:E,worktreeBranchesKey:X,isRepo:R,buildGroupedSessions:u,section:ne}),ne});return y.current=A,P>0&&Gs("ui.sidebar.project_section.reused",P),T>0&&Gs("ui.sidebar.project_section.rebuilt",T),$},[e,n,r,i,o,d,u,l,a]),p=c.useMemo(()=>m,[m]),S=c.useMemo(()=>{const I=new WeakMap;if(!h)return I;const A=f.trim().toLowerCase(),P=A.startsWith("ses_"),T=$=>$.reduce((K,F)=>K+(!P||F.session.id.toLowerCase()===A?1:0)+T(F.children),0),L=$=>{const K=x($.sessions,f),F=T(K),W=!P&&Io([b($)],f),N=Yr($).flatMap(({scopeKey:E})=>w[E]??[]),R=P?0:N.filter(E=>Io([E.name],f)).length;I.set($,{filteredNodes:K,matchedSessionCount:F,folderNameMatchCount:R,groupMatches:W,hasMatch:W||F>0||R>0})};return p.forEach($=>{$.groups.forEach(L)}),v.forEach(L),I},[h,p,v,x,f,b,w]),g=c.useMemo(()=>h?p.map(I=>({...I,groups:I.groups.filter(A=>S.get(A)?.hasMatch===!0)})).filter(I=>I.groups.length>0):p,[h,p,S]),C=h?g:p,k=c.useRef(new WeakMap),j=c.useMemo(()=>{const I=k.current;return C.map(A=>{const P=I.get(A);if(P&&P.query===f)return P.section;const T=A.groups.filter(R=>!R.isArchivedBucket),L=A.groups.filter(R=>R.isArchivedBucket),$=T.flatMap(R=>h?S.get(R)?.filteredNodes??[]:R.sessions),K=T.map(R=>({scopeKey:R.folderScopeKey??ht(R.directory??null),directory:R.directory??null})).filter(R=>!!R.scopeKey),F=T.find(R=>R.isMain)??null,W={id:"flat",label:F?.label??"",branch:F?.branch??null,description:F?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:F?.directory??A.project.normalizedPath,folderScopeKey:F?.folderScopeKey??A.project.normalizedPath,folderScopes:K,sessions:$};if(h){const R=T.map(E=>S.get(E)).filter(E=>!!E);S.set(W,{filteredNodes:$,matchedSessionCount:R.reduce((E,X)=>E+X.matchedSessionCount,0),folderNameMatchCount:R.reduce((E,X)=>E+X.folderNameMatchCount,0),groupMatches:R.some(E=>E.groupMatches),hasMatch:R.some(E=>E.hasMatch)})}const N={project:A.project,groups:[W,...L]};return I.set(A,{query:f,section:N}),N})},[S,h,f,C]),D=c.useMemo(()=>{if(!h)return 0;const I=(P,T)=>{const L=S.get(T);if(!L)return P;const $=L.folderNameMatchCount+(L.groupMatches?1:0);return P+L.matchedSessionCount+$},A=C.reduce((P,T)=>T.groups.reduce(I,P),0);return v.reduce(I,A)},[h,C,v,S]);return{projectSections:m,visibleProjectSections:p,groupSearchDataByGroup:S,searchableProjectSections:g,sectionsForRender:C,flatSectionsForRender:j,searchMatchCount:D}},z2=180,Bc=150,W2=2,K2=8,Fc=[-1,1,-2,2],vi=t=>`${t.directory}
|
|
880
|
-
${t.sessionId}`,V2=t=>t?.directory?.trim()||null,U2=({enabled:t=!0,currentSessionId:e,sortedSessions:n,recentSessions:r=[],prefetchSession:i})=>{const o=c.useRef(new Map),l=c.useRef([]),a=c.useRef(new Set),d=c.useRef(0),u=c.useMemo(()=>$n(),[]),h=c.useCallback(()=>{d.current+=1,l.current=[],o.current.forEach(b=>window.clearTimeout(b)),o.current.clear()},[]),f=c.useCallback(()=>{if(!(!t||u))for(;a.current.size<W2&&l.current.length>0;){const b=l.current.shift();if(!b)break;if(b.generation!==d.current||tt.getState().currentSessionId===b.sessionId||zi(b.sessionId,b.directory).renderable)continue;const v=vi(b);a.current.add(v),i({directory:b.directory,sessionID:b.sessionId}).catch(()=>{}).finally(()=>{a.current.delete(v),f()})}},[t,u,i]),x=c.useCallback(b=>{const w=b?.id,v=V2(b);if(!t||u||!w||!v||w===e)return;const y={sessionId:w,directory:v,generation:d.current},m=vi(y);if(zi(w,v).renderable||a.current.has(m)||l.current.some(g=>vi(g)===m))return;const p=o.current.get(m);p!==void 0&&window.clearTimeout(p);const S=window.setTimeout(()=>{if(o.current.delete(m),y.generation!==d.current)return;const g=l.current;g.length>=K2&&g.shift(),g.push(y),f()},z2);o.current.set(m,S)},[e,t,u,f]);c.useEffect(()=>{h()},[h,e,t,u]),c.useEffect(()=>{if(!t||u||!e||n.length===0)return;const b=window.setTimeout(()=>{const w=n.findIndex(v=>v.id===e);if(!(w<0))for(const v of Fc)x(n[w+v])},Bc);return()=>window.clearTimeout(b)},[e,t,u,x,n]),c.useEffect(()=>{if(!t||u||!e||r.length===0)return;const b=window.setTimeout(()=>{const w=r.findIndex(v=>v.id===e);if(!(w<0))for(const v of Fc)x(r[w+v])},Bc);return()=>window.clearTimeout(b)},[e,t,u,r,x]),c.useEffect(()=>h,[h])},H2=t=>{const e=Ze.c(3),n=tt(G2);let r;return e[0]!==t||e[1]!==n?(r={...t,currentSessionId:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],U2(r),null};function G2(t){return t.currentSessionId}const q2=(t,e)=>{const n=new Set,r=new Set,i=(o,l)=>{n.add(o.session.id),(!l||e)&&r.add(o.session.id),o.children.forEach(a=>i(a,!0))};return t.forEach(o=>i(o,!1)),{active:n,unread:r}},el=t=>{const e=Ze.c(15),{nodes:n,includeUnreadSubtasks:r,enabled:i}=t,o=i===void 0?!0:i;let l;e[0]!==o||e[1]!==n?(l=o?n:[],e[0]=o,e[1]=n,e[2]=l):l=e[2];let a;e[3]!==r||e[4]!==l?(a=q2(l,r),e[3]=r,e[4]=l,e[5]=a):a=e[5];const d=a;let u;e[6]!==o||e[7]!==d.active?(u=v=>{if(!o)return null;for(const y of d.active){const m=v.statusById.get(y)?.status.type;if(m==="busy"||m==="retry")return"active"}return null},e[6]=o,e[7]=d.active,e[8]=u):u=e[8];const h=qo(u);let f;e[9]!==o||e[10]!==d.unread?(f=v=>{if(!o)return null;for(const y of d.unread)if((v.index.session.unseenCount[y]??0)>0)return"unread";return null},e[9]=o,e[10]=d.unread,e[11]=f):f=e[11];const x=Ma(f);let b;return e[12]!==o||e[13]!==d.active?(b=v=>{if(!o)return null;let y=null;for(const m of d.active){const p=v.bySession.get(m);if(p){if(p.permissions.length>0)return"permission";p.questions.length>0&&(y="question")}}return y},e[12]=o,e[13]=d.active,e[14]=b):b=e[14],Oa(b)??h??x};function Mf(t){const e=Ze.c(21),{state:n,className:r}=t,{t:i}=jt();if(n==="permission"||n==="question"){let h;e[0]!==n||e[1]!==i?(h=i(n==="permission"?"sessions.sidebar.session.status.permissionRequired":"sessions.sidebar.session.status.questionPending"),e[0]=n,e[1]=i,e[2]=h):h=e[2];const f=h,x=n==="permission"?"text-destructive":"text-status-info";let b;e[3]!==r||e[4]!==x?(b=Oe("inline-flex shrink-0 items-center",x,r),e[3]=r,e[4]=x,e[5]=b):b=e[5];const w=n==="permission"?"shield":"question";let v;e[6]!==w?(v=s.jsx(M,{name:w,className:"h-3 w-3"}),e[6]=w,e[7]=v):v=e[7];let y;return e[8]!==f||e[9]!==b||e[10]!==v?(y=s.jsx("span",{className:b,"aria-label":f,title:f,children:v}),e[8]=f,e[9]=b,e[10]=v,e[11]=y):y=e[11],y}let o;e[12]!==n||e[13]!==i?(o=i(n==="active"?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[12]=n,e[13]=i,e[14]=o):o=e[14];const l=o,a=n==="active"?"bg-primary":"bg-[var(--status-info)]";let d;e[15]!==r||e[16]!==a?(d=Oe("h-1.5 w-1.5 shrink-0 rounded-full",a,r),e[15]=r,e[16]=a,e[17]=d):d=e[17];let u;return e[18]!==l||e[19]!==d?(u=s.jsx("span",{className:d,"aria-label":l,title:l}),e[18]=l,e[19]=d,e[20]=u):u=e[20],u}const Y2=t=>{const e=Ze.c(5),{nodes:n,includeUnreadSubtasks:r}=t;let i;e[0]!==r||e[1]!==n?(i={nodes:n,includeUnreadSubtasks:r},e[0]=r,e[1]=n,e[2]=i):i=e[2];const o=el(i);if(!o)return null;let l;return e[3]!==o?(l=s.jsx(Mf,{state:o}),e[3]=o,e[4]=l):l=e[4],l},Q2=t=>{const e=Ze.c(83),{folder:n,displayName:r,sessions:i,subFolderItems:o,isCollapsed:l,collapsedActivityState:a,onToggle:d,onRename:u,onDelete:h,children:f,renderBody:x,mobileVariant:b,alwaysShowActions:w,isRenaming:v,renameDraft:y,onRenameDraftChange:m,onRenameSave:p,onRenameCancel:S,droppableRef:g,isDropTarget:C,onNewSession:k,depth:j,hideActions:D,archivedBucket:I}=t,A=a===void 0?null:a,P=x===void 0?!0:x,L=w===void 0?b===void 0?!1:b:w,$=v===void 0?!1:v,K=y===void 0?"":y,F=C===void 0?!1:C,W=D===void 0?!1:D,N=I===void 0?!1:I,{t:R}=jt(),[E,X]=c.useState(!1),[J,re]=c.useState(""),fe=c.useRef(null),ne=$||E,te=$?K:J;let ue;e[0]!==n.name?(ue=()=>{re(n.name),X(!0)},e[0]=n.name,e[1]=ue):ue=e[1];const Se=ue;let we;e[2]!==te||e[3]!==n.name||e[4]!==$||e[5]!==u||e[6]!==p?(we=()=>{const xe=te.trim();xe&&xe!==n.name&&u(xe),$&&p&&p(),X(!1),re("")},e[2]=te,e[3]=n.name,e[4]=$,e[5]=u,e[6]=p,e[7]=we):we=e[7];const ye=we;let Ae;e[8]!==$||e[9]!==S?(Ae=()=>{$&&S&&S(),X(!1),re("")},e[8]=$,e[9]=S,e[10]=Ae):Ae=e[10];const pe=Ae;let O;e[11]!==$||e[12]!==m?(O=xe=>{$&&m?m(xe):re(xe)},e[11]=$,e[12]=m,e[13]=O):O=e[13];const Q=O;let le,H;e[14]!==$?(le=()=>{if(!$)return;const xe=()=>{const De=fe.current;De&&(De.focus(),De.select())},$e=requestAnimationFrame(xe),V=window.setTimeout(xe,0);return()=>{cancelAnimationFrame($e),window.clearTimeout(V)}},H=[$],e[14]=$,e[15]=le,e[16]=H):(le=e[15],H=e[16]),c.useEffect(le,H);const me=l?"folder":"folder-open",ge=F&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let oe;e[17]!==ge?(oe=Oe("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",ge),e[17]=ge,e[18]=oe):oe=e[18];let de;e[19]!==d||e[20]!==ne?(de=ne?void 0:xe=>{xe.currentTarget.blur(),d()},e[19]=d,e[20]=ne,e[21]=de):de=e[21];const _=ne?void 0:"button",B=ne?void 0:0;let he;e[22]!==d||e[23]!==ne?(he=ne?void 0:xe=>{(xe.key==="Enter"||xe.key===" ")&&(xe.preventDefault(),d())},e[22]=d,e[23]=ne,e[24]=he):he=e[24];let ve;e[25]!==n.name||e[26]!==l||e[27]!==R?(ve=l?R("sessions.sidebar.folderItem.expandAria",{folderName:n.name}):R("sessions.sidebar.folderItem.collapseAria",{folderName:n.name}),e[25]=n.name,e[26]=l,e[27]=R,e[28]=ve):ve=e[28];const Re=N?L?"pr-7":"group-hover/folder:pr-7 group-focus-within/folder:pr-7":L?"pr-20":"group-hover/folder:pr-20 group-focus-within/folder:pr-20";let ce;e[29]!==Re?(ce=Oe("min-w-0 flex items-center gap-1.5 pl-1.5 flex-1 transition-[padding]",Re),e[29]=Re,e[30]=ce):ce=e[30];const se=F?"text-primary":"text-muted-foreground";let q;e[31]!==se?(q=Oe("h-3.5 w-3.5 flex-shrink-0",se),e[31]=se,e[32]=q):q=e[32];let z;e[33]!==me||e[34]!==q?(z=s.jsx(M,{name:me,className:q}),e[33]=me,e[34]=q,e[35]=z):z=e[35];let ee;e[36]!==A||e[37]!==r||e[38]!==te||e[39]!==n.name||e[40]!==pe||e[41]!==Q||e[42]!==ye||e[43]!==l||e[44]!==F||e[45]!==ne||e[46]!==i||e[47]!==R?(ee=ne?s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:X2,onMouseDown:J2,onSubmit:xe=>{xe.preventDefault(),ye()},children:[s.jsx("input",{ref:fe,value:te,onChange:xe=>Q(xe.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:R("sessions.sidebar.folderItem.namePlaceholder"),onClick:Z2,onPointerDown:ej,onMouseDown:tj,onKeyDown:xe=>{if(xe.key==="Escape"){xe.stopPropagation(),pe();return}(xe.key===" "||xe.key==="Enter")&&xe.stopPropagation()}}),s.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:sj,onPointerDown:nj,onMouseDown:rj,children:s.jsx(M,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:xe=>{xe.stopPropagation(),pe()},onPointerDown:oj,onMouseDown:ij,className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"close",className:"size-4"})})]}):s.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:Oe("typography-ui-label font-semibold truncate",F?"text-primary":"text-muted-foreground"),children:r??n.name})}),s.jsx(Dt,{side:"right",sideOffset:8,className:"max-w-xs",children:r??n.name})]}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70 flex-shrink-0",children:["• ",i.length]}),A?s.jsx(Mf,{state:A}):null,l?s.jsx(M,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(M,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]}),e[36]=A,e[37]=r,e[38]=te,e[39]=n.name,e[40]=pe,e[41]=Q,e[42]=ye,e[43]=l,e[44]=F,e[45]=ne,e[46]=i,e[47]=R,e[48]=ee):ee=e[48];let ae;e[49]!==ce||e[50]!==z||e[51]!==ee?(ae=s.jsxs("div",{className:ce,children:[z,ee]}),e[49]=ce,e[50]=z,e[51]=ee,e[52]=ae):ae=e[52];let Ne;e[53]!==L||e[54]!==N||e[55]!==n.name||e[56]!==Se||e[57]!==W||e[58]!==h||e[59]!==k||e[60]!==ne||e[61]!==R?(Ne=!ne&&(!W||N)?s.jsx("div",{className:Oe("absolute right-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",L?"opacity-100":"opacity-0 pointer-events-none group-hover/folder:opacity-100 group-hover/folder:pointer-events-auto group-focus-within/folder:opacity-100 group-focus-within/folder:pointer-events-auto"),children:s.jsxs("div",{className:"flex items-center gap-0.5",children:[!N&&k?s.jsx("button",{type:"button",onClick:xe=>{xe.stopPropagation(),k()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":R("sessions.sidebar.folderItem.newSessionAria",{folderName:n.name}),title:R("sessions.sidebar.project.actions.newSession"),children:s.jsx(M,{name:"add",className:"h-3.5 w-3.5"})}):null,N?null:s.jsx("button",{type:"button",onClick:xe=>{xe.stopPropagation(),Se()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":R("sessions.sidebar.folderItem.renameAria",{folderName:n.name}),children:s.jsx(M,{name:"pencil-ai",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:xe=>{xe.stopPropagation(),h()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":N?R("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:n.name}):R("sessions.sidebar.folderItem.deleteFolderAria",{folderName:n.name}),children:s.jsx(M,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})}):null,e[53]=L,e[54]=N,e[55]=n.name,e[56]=Se,e[57]=W,e[58]=h,e[59]=k,e[60]=ne,e[61]=R,e[62]=Ne):Ne=e[62];let Ce;e[63]!==g||e[64]!==oe||e[65]!==de||e[66]!==_||e[67]!==B||e[68]!==he||e[69]!==ve||e[70]!==ae||e[71]!==Ne?(Ce=s.jsxs("div",{ref:g,className:oe,onClick:de,role:_,tabIndex:B,onKeyDown:he,"aria-label":ve,children:[ae,Ne]}),e[63]=g,e[64]=oe,e[65]=de,e[66]=_,e[67]=B,e[68]=he,e[69]=ve,e[70]=ae,e[71]=Ne,e[72]=Ce):Ce=e[72];let We;e[73]!==f||e[74]!==l||e[75]!==P||e[76]!==i||e[77]!==o||e[78]!==R?(We=!l&&P?s.jsxs("div",{className:"pb-1",children:[o,i.length>0?f:o?null:s.jsx("div",{className:"py-1 pl-1.5 text-left typography-micro text-muted-foreground/70",children:R("sessions.sidebar.folderItem.emptyFolder")})]}):null,e[73]=f,e[74]=l,e[75]=P,e[76]=i,e[77]=o,e[78]=R,e[79]=We):We=e[79];let Ee;return e[80]!==Ce||e[81]!==We?(Ee=s.jsxs("div",{className:"oc-folder",children:[Ce,We]}),e[80]=Ce,e[81]=We,e[82]=Ee):Ee=e[82],Ee},Of=c.memo(Q2);function X2(t){return t.stopPropagation()}function J2(t){return t.stopPropagation()}function Z2(t){return t.stopPropagation()}function ej(t){return t.stopPropagation()}function tj(t){return t.stopPropagation()}function sj(t){return t.stopPropagation()}function nj(t){return t.stopPropagation()}function rj(t){return t.stopPropagation()}function oj(t){return t.stopPropagation()}function ij(t){return t.stopPropagation()}function aj(t){const e=Ze.c(11);let n,r,i;e[0]!==t?({notifyOnSubtasks:r,activityNodes:n,...i}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i):(n=e[1],r=e[2],i=e[3]);const o=i.isCollapsed&&!i.archivedBucket;let l;e[4]!==n||e[5]!==r||e[6]!==o?(l={nodes:n,includeUnreadSubtasks:r,enabled:o},e[4]=n,e[5]=r,e[6]=o,e[7]=l):l=e[7];const a=el(l);let d;return e[8]!==a||e[9]!==i?(d=s.jsx(Of,{...i,collapsedActivityState:a}),e[8]=a,e[9]=i,e[10]=d):d=e[10],d}const _o=t=>{const e=Ze.c(13),{directory:n,className:r}=t,{t:i}=jt();let o;e[0]!==n?(o=Jm(n),e[0]=n,e[1]=o):o=e[1];const l=o;let a;if(e[2]!==l?(a=v=>v.sessions.get(l),e[2]=l,e[3]=a):a=e[3],!Ot(a)?.tabs.some(Od))return null;let h;e[4]!==i?(h=i("sessions.sidebar.projectAction.active"),e[4]=i,e[5]=h):h=e[5];const f=h;let x;e[6]!==r?(x=Oe("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=x):x=e[7];let b;e[8]===Symbol.for("react.memo_cache_sentinel")?(b=s.jsx(M,{name:"pulse",className:"size-3.5"}),e[8]=b):b=e[8];let w;return e[9]!==l||e[10]!==f||e[11]!==x?(w=s.jsx("span",{className:x,role:"img","aria-label":f,title:f,"data-action-directory":l,children:b}),e[9]=l,e[10]=f,e[11]=x,e[12]=w):w=e[12],w},lj=t=>{const e=Ze.c(19),{sessionId:n,dragKey:r,ownerKey:i,sessionDirectory:o,sessionTitle:l,archivedBucket:a,children:d}=t,u=i===void 0?null:i,h=a===void 0?!1:a,f=`session-drag:${r??n}`;let x;e[0]!==h||e[1]!==u||e[2]!==o||e[3]!==n||e[4]!==l?(x={type:"session",sessionId:n,ownerKey:u,sessionDirectory:o,sessionTitle:l,archivedBucket:h},e[0]=h,e[1]=u,e[2]=o,e[3]=n,e[4]=l,e[5]=x):x=e[5];let b;e[6]!==h||e[7]!==f||e[8]!==x?(b={id:f,disabled:h,data:x},e[6]=h,e[7]=f,e[8]=x,e[9]=b):b=e[9];const{attributes:w,listeners:v,setNodeRef:y,isDragging:m}=Wx(b);let p;e[10]!==v?(p=k=>{k.stopPropagation(),v?.onPointerDown&&v.onPointerDown(k)},e[10]=v,e[11]=p):p=e[11];const S=p,g=`touch-pan-y select-none${m?" opacity-30":""}`;let C;return e[12]!==w||e[13]!==d||e[14]!==S||e[15]!==v||e[16]!==y||e[17]!==g?(C=s.jsx("div",{ref:y,...w,...v,onPointerDown:S,className:g,children:d}),e[12]=w,e[13]=d,e[14]=S,e[15]=v,e[16]=y,e[17]=g,e[18]=C):C=e[18],C},Bf=t=>{const e=Ze.c(20),{folderId:n,scopeKey:r,ownerKey:i,disabled:o,children:l}=t,a=o===void 0?!1:o;let d;e[0]!==n||e[1]!==r?(d=Yn(r,n),e[0]=n,e[1]=r,e[2]=d):d=e[2];const u=`folder-drop:${d}`;let h;e[3]!==a||e[4]!==r?(h=a||Za(r),e[3]=a,e[4]=r,e[5]=h):h=e[5];let f;e[6]!==n||e[7]!==i||e[8]!==r?(f={type:"folder",folderId:n,scopeKey:r,ownerKey:i},e[6]=n,e[7]=i,e[8]=r,e[9]=f):f=e[9];let x;e[10]!==u||e[11]!==h||e[12]!==f?(x={id:u,disabled:h,data:f},e[10]=u,e[11]=h,e[12]=f,e[13]=x):x=e[13];const{setNodeRef:b,isOver:w}=Kx(x);let v;e[14]!==l||e[15]!==w||e[16]!==b?(v=l(b,w),e[14]=l,e[15]=w,e[16]=b,e[17]=v):v=e[17];let y;return e[18]!==v?(y=s.jsx(s.Fragment,{children:v}),e[18]=v,e[19]=y):y=e[19],y},cj=t=>{const e=Ze.c(22),{scopeKey:n,ownerKey:r,hasFolders:i,onSessionDroppedOnFolder:o,children:l}=t,a=r===void 0?null:r;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={activationConstraint:{distance:8}},e[0]=d):d=e[0];let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={activationConstraint:{delay:200,tolerance:6}},e[1]=u):u=e[1];const h=Qo(Dn(Jo,d),Dn(Xo,u)),[f,x]=c.useState(null),[b,w]=c.useState("Session"),[v,y]=c.useState(null),[m,p]=c.useState(null);if(!n){let A;return e[2]!==l?(A=s.jsx(s.Fragment,{children:l}),e[2]=l,e[3]=A):A=e[3],A}let S;e[4]!==o||e[5]!==a?(S=A=>{x(null),y(null),p(null);const{active:P,over:T}=A;if(!T)return;const L=P.data.current,$=T.data.current;L?.type!=="session"||!L.sessionId||!L.ownerKey||L.archivedBucket===!0||a&&L.ownerKey!==a||$?.type!=="folder"||!$.folderId||!$.scopeKey||!$.ownerKey||Za($.scopeKey)||$.ownerKey!==L.ownerKey||o(L.sessionId,{folderId:$.folderId,scopeKey:$.scopeKey,ownerKey:$.ownerKey},L.ownerKey)},e[4]=o,e[5]=a,e[6]=S):S=e[6];const g=S;let C,k;e[7]===Symbol.for("react.memo_cache_sentinel")?(C=A=>{const P=A.active.data.current;if(P?.type==="session"&&P.sessionId){x(P.sessionId),w(P.sessionTitle??"Session");const T=A.active.rect.current.initial?.width,L=A.active.rect.current.initial?.height;y(T??null),p(L??null)}},k=()=>{x(null),y(null),p(null)},e[7]=C,e[8]=k):(C=e[7],k=e[8]);let j;e[9]!==m||e[10]!==f||e[11]!==b||e[12]!==v||e[13]!==i?(j=f&&i?s.jsxs("div",{style:{width:v?`${v}px`:"auto",height:m?`${m}px`:"auto"},className:"flex items-center rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2.5 py-1 shadow-none pointer-events-none",children:[s.jsx(M,{name:"sticky-note",className:"h-4 w-4 text-muted-foreground mr-2 flex-shrink-0"}),s.jsx("div",{className:"min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground",children:b})]}):null,e[9]=m,e[10]=f,e[11]=b,e[12]=v,e[13]=i,e[14]=j):j=e[14];let D;e[15]!==j?(D=s.jsx(Vx,{children:j}),e[15]=j,e[16]=D):D=e[16];let I;return e[17]!==l||e[18]!==g||e[19]!==h||e[20]!==D?(I=s.jsxs(Zo,{sensors:h,collisionDetection:ei,onDragStart:C,onDragCancel:k,onDragEnd:g,children:[l,D]}),e[17]=l,e[18]=g,e[19]=h,e[20]=D,e[21]=I):I=e[21],I},Ff=c.createContext(null),dj=({entries:t,descendantIds:e,sessionsById:n,children:r})=>{const i=c.useRef(t),o=c.useRef(e),l=c.useRef(n);i.current=t,o.current=e,l.current=n;const a=c.useRef(null);return a.current===null&&(a.current={getEntries:()=>i.current,getDescendantIds:()=>o.current,getSessionsById:()=>l.current}),s.jsx(Ff.Provider,{value:a.current,children:r})},_f=()=>c.useContext(Ff),uj=(t,e,n)=>{const r=t[0];if(!r)return null;const i=n??r.scopeKey,o=[],l=new Set;for(const a of t){if(i&&a.scopeKey!==i)continue;const d=a.descendantRange,u=d?[a.id,...e.slice(d[0],d[1])]:[a.id];for(const h of u)l.has(h)||(l.add(h),o.push(h))}return o.length>0?{ids:o,scopeKey:i}:null},Lf=(t,e)=>{if(t.size===0)return!1;for(const n of t)if(!e.get(n)?.time?.archived)return!1;return!0},_c=(t,e,n)=>{if(!e)return;const r=i=>{let o=i.session.id===e;for(const l of i.children)o=r(l)||o;return o&&n.add(i.session.id),o};for(const i of t)r(i)},Fn=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const n of t.children)if(Fn(n,e))return!0;return!1},fj=({isSubtaskSession:t,archivedBucket:e,isVSCode:n,sessionDirectory:r})=>!t&&!e&&!n&&!rg(r),mj=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:n})=>!t||e||n,hj=(t,e,n)=>{const r=new Map,i=o=>{const l=Ds(o.session)??ht(o.worktree?.path)??n;if(l){const a=r.get(l)??[];a.push(o.session.id),r.set(l,a)}if(!(o===t&&e))for(const a of o.children)i(a)};return i(t),[...r].map(([o,l])=>({directory:o,sessionIDs:l}))},ca=(t,e)=>{const n=new Set(t);return t.map(r=>e.get(r)).filter(r=>{if(!r)return!1;const i=new Set;let o=r.session.parentID??null;for(;o&&!i.has(o);){if(n.has(o)&&e.has(o))return!1;i.add(o),o=e.get(o)?.session?.parentID??null}return!0})},$f=t=>{const e=new Map(t.map(l=>[l.id,l])),n=new Map;for(const l of t){if(!l.parentId||!e.has(l.parentId))continue;const a=n.get(l.parentId)??[];a.push(l),n.set(l.parentId,a)}const r=new Set,i=[],o=l=>{if(r.has(l.id))return;i.push(l);const a=[l.id];for(;a.length>0;){const d=a.pop();if(!(!d||r.has(d))){r.add(d);for(const u of n.get(d)??[])a.push(u.id)}}};return t.forEach(l=>{(!l.parentId||!e.has(l.parentId))&&o(l)}),t.forEach(o),i},zf=(t,e)=>{const n=e.searchQuery.trim().toLowerCase().startsWith("ses_"),r=new Map(t.map(u=>[u.id,u])),i=new Map,o=new Set;for(const u of t){if(u.parentId&&!r.has(u.parentId)){o.add(u.id);continue}if(u.parentId){const x=i.get(u.parentId)??[];x.push(u.id),i.set(u.parentId,x)}const h=new Set;let f=u.id;for(;f;){if(h.has(f)){o.add(u.id);break}h.add(f),f=r.get(f)?.parentId}}const l=new Set,a=new Set,d=u=>{if(l.has(u))return!0;if(a.has(u))return!1;const h=r.get(u);if(!h)return!1;a.add(u);let f=o.has(u);return!f&&e.archivedBucket&&h.nodeCount===0?f=(i.get(u)??[]).some(d):(!f&&!e.searchQuery&&(f=!0),!f&&(h.nodeCount>0||!n&&Io([h.name],e.searchQuery))&&(f=!0),f||(f=(i.get(u)??[]).some(d))),a.delete(u),f&&l.add(u),f};return t.forEach(u=>d(u.id)),new Set(t.filter(u=>l.has(u.id)).map(u=>u.id))},Lc=new WeakMap;let $c=1;const pj=t=>{const e=Lc.get(t);if(e!==void 0)return e;const n=$c;return $c+=1,Lc.set(t,n),n},Lo=t=>t.children.length===0?"":t.children.map(n=>{const r=pj(n.session);return n.children.length===0?`${n.session.id}@${r}`:`${n.session.id}@${r}:${Lo(n)}`}).join("|"),Wf=(t,e,n,r,i,o)=>{const l=qt(),a=(d,u)=>{if(d.session.id!==u.session.id||d.children.length!==u.children.length)return!0;const h=d.session.directory??i,f=u.session.directory??o,x=Pl(l,h??"",d.session.id),b=Pl(l,f??"",u.session.id);return(x?n.has(x):!1)!==(b?r.has(b):!1)?!0:d.children.some((w,v)=>a(w,u.children[v]))};return a(t,e)},gj=t=>t.actionsAlwaysVisible?"":`transition-opacity duration-150 ${t.menuOpen?"opacity-0":t.hideOnHoverClass}`,$o=(t,e,n,r)=>{if(!e)return null;const i=r?"archived":"active";let o=null;const l=a=>{if(`${n}:${i}:${a.session.id}`===e)return o=a.session.id,!0;for(const u of a.children)if(l(u))return!0;return!1};return t.forEach(a=>l(a)),o},xj=t=>{const e=Ze.c(29),{menuInstanceKey:n,contextMenuInstanceKey:r,openSidebarMenuKey:i,setOpenSidebarMenuKey:o,hasDeferredCloseWork:l,onCloseComplete:a}=t,[d,u]=c.useState(!1),[h,f]=c.useState(!1),x=i===n&&!h,b=r?i===r&&!h:d;let w;e[0]!==l||e[1]!==i||e[2]!==o?(w=I=>{if(i===I){if(l()){f(!0);return}o(null)}},e[0]=l,e[1]=i,e[2]=o,e[3]=w):w=e[3];const v=w;let y;e[4]!==n||e[5]!==v||e[6]!==o?(y=I=>{if(I){u(!1),f(!1),o(n);return}v(n)},e[4]=n,e[5]=v,e[6]=o,e[7]=y):y=e[7];const m=y;let p;e[8]!==r||e[9]!==v||e[10]!==o?(p=I=>{if(!r){u(I);return}if(I){f(!1),o(r);return}v(r)},e[8]=r,e[9]=v,e[10]=o,e[11]=p):p=e[11];const S=p;let g;e[12]!==r||e[13]!==n||e[14]!==a||e[15]!==i||e[16]!==o?(g=I=>{I||(a(),f(!1),(i===n||i===r)&&o(null))},e[12]=r,e[13]=n,e[14]=a,e[15]=i,e[16]=o,e[17]=g):g=e[17];const C=g;let k;e[18]!==x||e[19]!==n||e[20]!==o?(k=()=>{f(!1),o(x?null:n)},e[18]=x,e[19]=n,e[20]=o,e[21]=k):k=e[21];const j=k;let D;return e[22]!==S||e[23]!==m||e[24]!==C||e[25]!==b||e[26]!==x||e[27]!==j?(D={isMenuOpen:x,isContextMenuOpen:b,handleMenuOpenChange:m,handleContextMenuOpenChange:S,handleMenuOpenChangeComplete:C,toggleMenu:j},e[22]=S,e[23]=m,e[24]=C,e[25]=b,e[26]=x,e[27]=j,e[28]=D):D=e[28],D};let da=!1;const ua=new Set;let zc=!1;function bj(){for(const t of ua)t()}function tl(t){da!==t&&(da=t,bj())}function yj(t){t.key==="Shift"&&tl(!0)}function wj(t){t.key==="Shift"&&tl(!1)}function vj(){tl(!1)}function Sj(){zc||typeof window>"u"||(zc=!0,window.addEventListener("keydown",yj),window.addEventListener("keyup",wj),window.addEventListener("blur",vj))}function jj(t){return Sj(),ua.add(t),()=>{ua.delete(t)}}function kj(){return da}function Cj(){return!1}function Nj(){return mt.useSyncExternalStore(jj,kj,Cj)}async function Aj(t,e,n,r){const i=await Promise.all(e.map(async o=>{r();const l=o.directory??o.session.directory,a=await t.session.get({sessionID:o.session.id,directory:l},{throwOnError:!0});if(r(),!a.data||!Ud(n,Po(a.data,o.projectDirectory??a.data.directory)))throw new Error("Fusion source membership changed");const d=await t.session.messages({sessionID:o.session.id,directory:l,limit:50},{throwOnError:!0});if(r(),!d.data)throw new Error("Fusion source messages unavailable");let u="";for(let h=d.data.length-1;h>=0;h-=1){const f=d.data[h];if(f.info.role==="assistant"){u=og(f.parts).trim();break}}return{source:{...o,session:a.data},text:u}}));return r(),i.filter(o=>o.text.length>0)}const Kf=t=>{const e=Ze.c(36),{value:n,onChange:r,className:i,disabled:o,id:l,portalToBody:a}=t,{t:d}=jt(),u=Gt(Dj),h=Gt(Pj),f=Gt(Ij);let x;e[0]!==u?(x=u(),e[0]=u,e[1]=x):x=e[1];const b=x;let w;e[2]!==b?(w=b.filter(Tj),e[2]=b,e[3]=w):w=e[3];const v=w;let y,m;e[4]!==b.length||e[5]!==h?(y=()=>{b.length===0&&h()},m=[b.length,h],e[4]=b.length,e[5]=h,e[6]=y,e[7]=m):(y=e[6],m=e[7]),c.useEffect(y,m);let p,S;e[8]!==f||e[9]!==o||e[10]!==r||e[11]!==v||e[12]!==n?(p=()=>{if(o)return;const T=n.trim();if(T.length>0&&v.some(K=>K.name===T))return;const L=typeof f=="string"&&f.trim().length>0?f.trim():null;if(L&&v.some(K=>K.name===L)){r(L);return}const $=v[0]?.name;$&&r($)},S=[f,o,r,v,n],e[8]=f,e[9]=o,e[10]=r,e[11]=v,e[12]=n,e[13]=p,e[14]=S):(p=e[13],S=e[14]),c.useEffect(p,S);const g=n.trim().length>0?n:void 0;let C;e[15]!==i?(C=Oe("max-w-full",i),e[15]=i,e[16]=C):C=e[16];let k;e[17]!==d?(k=d("multirun.agentSelector.placeholder"),e[17]=d,e[18]=k):k=e[18];let j;e[19]!==k?(j=s.jsx(ks,{placeholder:k}),e[19]=k,e[20]=j):j=e[20];let D;e[21]!==l||e[22]!==C||e[23]!==j?(D=s.jsx(Fs,{id:l,size:"lg",className:C,children:j}),e[21]=l,e[22]=C,e[23]=j,e[24]=D):D=e[24];let I;e[25]!==v?(I=v.length>0&&s.jsx(Wi,{children:v.map(Ej)}),e[25]=v,e[26]=I):I=e[26];let A;e[27]!==a||e[28]!==I?(A=s.jsx(_s,{fitContent:!0,portalToBody:a,children:I}),e[27]=a,e[28]=I,e[29]=A):A=e[29];let P;return e[30]!==o||e[31]!==r||e[32]!==g||e[33]!==D||e[34]!==A?(P=s.jsxs(Bs,{value:g,onValueChange:r,disabled:o,children:[D,A]}),e[30]=o,e[31]=r,e[32]=g,e[33]=D,e[34]=A,e[35]=P):P=e[35],P};function Dj(t){return t.getVisibleAgents}function Pj(t){return t.loadAgents}function Ij(t){return t.currentAgentName}function Tj(t){return Du(t.mode)}function Ej(t){return s.jsx(ss,{value:t.name,className:"w-auto whitespace-nowrap",children:t.name},t.name)}const Rj="h-7",Vr=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,Mj=t=>{const e=Ze.c(12),{model:n,instanceIndex:r,totalSameModel:i,onRemove:o}=t,l=n.displayName||`${n.providerID}/${n.modelID}`,a=i>1?`${l} (${r})`:l;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=Oe("flex items-center gap-1.5 px-2 rounded-md bg-interactive-selection/20 border border-border/30",Rj),e[0]=d):d=e[0];let u;e[1]!==n.providerID?(u=s.jsx(Ki,{providerId:n.providerID,className:"h-3.5 w-3.5"}),e[1]=n.providerID,e[2]=u):u=e[2];let h;e[3]!==a?(h=s.jsx("span",{className:"typography-meta font-medium truncate max-w-[140px]",children:a}),e[3]=a,e[4]=h):h=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(M,{name:"close",className:"h-3.5 w-3.5"}),e[5]=f):f=e[5];let x;e[6]!==o?(x=s.jsx("button",{type:"button",onClick:o,className:"text-muted-foreground hover:text-foreground ml-0.5",children:f}),e[6]=o,e[7]=x):x=e[7];let b;return e[8]!==u||e[9]!==h||e[10]!==x?(b=s.jsxs("div",{className:d,children:[u,h,x]}),e[8]=u,e[9]=h,e[10]=x,e[11]=b):b=e[11],b},Vf=t=>{const e=Ze.c(120),{selectedModels:n,onAdd:r,onRemove:i,onUpdate:o,minModels:l,addButtonLabel:a,showChips:d,maxModels:u,addButtonClassName:h,dropdownSide:f,dropdownClassName:x,containerClassName:b,triggerIcon:w}=t,v=d===void 0?!0:d,y=f===void 0?"top":f,{t:m}=jt(),p=Gt(Oj),S=Gt(Bj),g=Pe(Fj),C=Pe(_j),{favoriteModelsList:k,recentModelsList:j}=ig(),D=Pe(Lj),I=Pe($j),[A,P]=c.useState(!1),[T,L]=c.useState(""),[$,K]=c.useState(null),F=c.useRef(null),W=c.useRef(null),N=u===1,R=u===void 0||n.length<u||N;let E;if(e[0]!==n){E=new Map;for(const _e of n){const rt=`${_e.providerID}:${_e.modelID}`;E.set(rt,(E.get(rt)||0)+1)}e[0]=n,e[1]=E}else E=e[1];const X=E;let J;e[2]!==n?(J=_e=>n.filter(ct=>ct.providerID===_e.providerID&&ct.modelID===_e.modelID).findIndex(ct=>ct.instanceId===_e.instanceId)+1,e[2]=n,e[3]=J):J=e[3];const re=J;let fe,ne;e[4]!==y||e[5]!==A?(fe=()=>{if(!A||!W.current)return;const _e=W.current.getBoundingClientRect();if(y==="bottom"){const wt=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-_e.bottom-16-112;K(Math.max(160,Math.min(320,wt)));return}let rt=W.current.parentElement;for(;rt&&!rt.matches('[role="dialog"], [data-scroll-shadow-scroller]');){const pt=getComputedStyle(rt);if(pt.overflow==="auto"||pt.overflow==="hidden"||pt.overflowY==="auto"||pt.overflowY==="hidden")break;rt=rt.parentElement}const ct=rt?rt.getBoundingClientRect().top:0,et=_e.top-ct-16;K(Math.max(150,Math.min(300,et)))},ne=[y,A],e[4]=y,e[5]=A,e[6]=fe,e[7]=ne):(fe=e[6],ne=e[7]),c.useEffect(fe,ne);let te,ue;e[8]!==R||e[9]!==A?(te=()=>{!R&&A&&(P(!1),L(""))},ue=[R,A],e[8]=R,e[9]=A,e[10]=te,e[11]=ue):(te=e[10],ue=e[11]),c.useEffect(te,ue);let Se,we;e[12]!==A?(Se=()=>{if(!A)return;const _e=rt=>{F.current&&!F.current.contains(rt.target)&&(P(!1),L(""))};return document.addEventListener("mousedown",_e),()=>document.removeEventListener("mousedown",_e)},we=[A],e[12]=A,e[13]=Se,e[14]=we):(Se=e[13],we=e[14]),c.useEffect(Se,we);let ye;e[15]!==N||e[16]!==r||e[17]!==o||e[18]!==n.length?(ye=_e=>{const rt={providerID:_e.providerID,modelID:_e.modelID,displayName:_e.model.name||_e.modelID,instanceId:Vr()};N&&n.length>0&&o?o(0,rt):r(rt),N&&(P(!1),L(""))},e[15]=N,e[16]=r,e[17]=o,e[18]=n.length,e[19]=ye):ye=e[19];const Ae=ye;let pe;e[20]!==m?(pe=m("multirun.modelMultiSelect.search.placeholder"),e[20]=m,e[21]=pe):pe=e[21];let O;e[22]!==m?(O=m("multirun.modelMultiSelect.search.noResults"),e[22]=m,e[23]=O):O=e[23];let Q;e[24]!==m?(Q=m("multirun.modelMultiSelect.sections.favorites"),e[24]=m,e[25]=Q):Q=e[25];let le;e[26]!==m?(le=m("multirun.modelMultiSelect.sections.recent"),e[26]=m,e[27]=le):le=e[27];let H;e[28]!==m?(H=m("multirun.modelMultiSelect.keyboard.hint"),e[28]=m,e[29]=H):H=e[29];let me;e[30]!==m?(me=m("settings.agents.modelSelector.actions.favorite"),e[30]=m,e[31]=me):me=e[31];let ge;e[32]!==m?(ge=m("settings.agents.modelSelector.actions.unfavorite"),e[32]=m,e[33]=ge):ge=e[33];let oe;e[34]!==m?(oe=m("chat.modelControls.capabilities"),e[34]=m,e[35]=oe):oe=e[35];let de;e[36]!==m?(de=m("chat.modelControls.capability.toolCalling"),e[36]=m,e[37]=de):de=e[37];let _;e[38]!==m?(_=m("chat.modelControls.capability.reasoning"),e[38]=m,e[39]=_):_=e[39];let B;e[40]!==m?(B=m("chat.modelControls.input"),e[40]=m,e[41]=B):B=e[41];let he;e[42]!==m?(he=m("chat.modelControls.output"),e[42]=m,e[43]=he):he=e[43];let ve;e[44]!==m?(ve=m("chat.modelControls.costPerMillion"),e[44]=m,e[45]=ve):ve=e[45];let Re;e[46]!==pe||e[47]!==O||e[48]!==Q||e[49]!==le||e[50]!==H||e[51]!==me||e[52]!==ge||e[53]!==oe||e[54]!==de||e[55]!==_||e[56]!==B||e[57]!==he||e[58]!==ve?(Re={searchPlaceholder:pe,noResults:O,favorites:Q,recent:le,keyboardHint:H,favorite:me,unfavorite:ge,capabilities:oe,capabilityToolCalling:de,capabilityReasoning:_,input:B,output:he,costPerMillion:ve},e[46]=pe,e[47]=O,e[48]=Q,e[49]=le,e[50]=H,e[51]=me,e[52]=ge,e[53]=oe,e[54]=de,e[55]=_,e[56]=B,e[57]=he,e[58]=ve,e[59]=Re):Re=e[59];const ce=Re;let se;e[60]!==b?(se=Oe("relative",b),e[60]=b,e[61]=se):se=e[61];const q=A?"":void 0;let z;e[62]!==h?(z=Oe(Pu({size:"default"}),"w-fit",h),e[62]=h,e[63]=z):z=e[63];const ee=!R;let ae;e[64]!==A?(ae=()=>{P(!A)},e[64]=A,e[65]=ae):ae=e[65];let Ne;e[66]!==w?(Ne=w??s.jsx(M,{name:"add",className:"h-3.5 w-3.5 mr-1"}),e[66]=w,e[67]=Ne):Ne=e[67];let Ce;e[68]!==a||e[69]!==m?(Ce=a??m("multirun.modelMultiSelect.actions.addModel"),e[68]=a,e[69]=m,e[70]=Ce):Ce=e[70];let We;e[71]!==q||e[72]!==z||e[73]!==ee||e[74]!==ae||e[75]!==Ne||e[76]!==Ce?(We=s.jsxs("button",{ref:W,type:"button","data-popup-open":q,className:z,disabled:ee,onClick:ae,children:[Ne,Ce]}),e[71]=q,e[72]=z,e[73]=ee,e[74]=ae,e[75]=Ne,e[76]=Ce,e[77]=We):We=e[77];let Ee;e[78]!==$||e[79]!==R||e[80]!==x||e[81]!==y||e[82]!==k||e[83]!==Ae||e[84]!==D||e[85]!==C||e[86]!==A||e[87]!==ce||e[88]!==X||e[89]!==S||e[90]!==I||e[91]!==p||e[92]!==j||e[93]!==T||e[94]!==g?(Ee=A?s.jsx("div",{className:Oe("absolute left-0 z-50 w-[min(420px,calc(100vw-2rem))] max-w-[calc(100vw-2rem)] flex flex-col overflow-hidden rounded-xl border border-border/50 shadow-lg",y==="top"?"bottom-full mb-1":"top-full mt-1",x),style:{background:"linear-gradient(var(--surface-elevated),var(--surface-elevated)),linear-gradient(var(--surface-background),var(--surface-background))"},children:s.jsx(ag,{providers:p,providerOrder:I,favoriteModels:k,recentModels:j,modelsMetadata:S,hiddenModels:D,searchQuery:T,onSearchQueryChange:L,onSelect:Ae,labels:ce,selectionCount:_e=>X.get(`${_e.providerID}:${_e.modelID}`)||0,disabled:!R,maxHeightClassName:"flex-1",maxHeightStyle:{maxHeight:$?`${$}px`:"300px"},stickyHeaders:!0,tooltipsEnabled:A,isFavorite:_e=>C(_e.providerID,_e.modelID),onToggleFavorite:_e=>g(_e.providerID,_e.modelID),onEscape:()=>{P(!1),L("")}})}):null,e[78]=$,e[79]=R,e[80]=x,e[81]=y,e[82]=k,e[83]=Ae,e[84]=D,e[85]=C,e[86]=A,e[87]=ce,e[88]=X,e[89]=S,e[90]=I,e[91]=p,e[92]=j,e[93]=T,e[94]=g,e[95]=Ee):Ee=e[95];let xe;e[96]!==se||e[97]!==We||e[98]!==Ee?(xe=s.jsxs("div",{className:se,ref:F,children:[We,Ee]}),e[96]=se,e[97]=We,e[98]=Ee,e[99]=xe):xe=e[99];let $e;e[100]!==re||e[101]!==X||e[102]!==i||e[103]!==o||e[104]!==p||e[105]!==n||e[106]!==v||e[107]!==m?($e=v&&n.length>0&&s.jsx("div",{className:"flex flex-col gap-2 w-full",children:n.map((_e,rt)=>{const ct=`${_e.providerID}:${_e.modelID}`,et=X.get(ct)||1,pt=re(_e),wt=p.find(be=>be.id===_e.providerID)?.models?.find(be=>be.id===_e.modelID),Xe=wt?.variants?Object.keys(wt.variants):[],yt=Xe.length>0,Rt=_e.variant??"__default__";return s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(Mj,{model:_e,instanceIndex:pt,totalSameModel:et,onRemove:()=>i(rt)}),yt&&s.jsxs(Bs,{value:Rt,onValueChange:be=>{if(!o)return;o(rt,{..._e,variant:be==="__default__"?void 0:be})},children:[s.jsxs(Fs,{size:"sm",className:"gap-1.5",children:[s.jsx(M,{name:"brain-ai-3",className:Oe("h-3.5 w-3.5 flex-shrink-0",Rt==="__default__"?"text-muted-foreground":"text-[color:var(--status-info)]")}),s.jsx(ks,{placeholder:m("multirun.modelMultiSelect.variant.placeholder"),children:be=>be==="__default__"?m("multirun.modelMultiSelect.variant.default"):be})]}),s.jsxs(_s,{fitContent:!0,children:[s.jsx(ss,{value:"__default__",className:"pr-2 [&>span:first-child]:hidden",children:m("multirun.modelMultiSelect.variant.default")}),Xe.map(zj)]})]})]},_e.instanceId)})}),e[100]=re,e[101]=X,e[102]=i,e[103]=o,e[104]=p,e[105]=n,e[106]=v,e[107]=m,e[108]=$e):$e=e[108];let V;e[109]!==xe||e[110]!==$e?(V=s.jsxs("div",{className:"flex flex-wrap gap-1.5 items-center",children:[xe,$e]}),e[109]=xe,e[110]=$e,e[111]=V):V=e[111];let De;e[112]!==u||e[113]!==l||e[114]!==n.length||e[115]!==m?(De=l!==void 0&&n.length<l&&s.jsx("p",{className:"typography-micro text-muted-foreground",children:u!==void 0?m("multirun.modelMultiSelect.validation.minToMax",{min:l,max:u}):m("multirun.modelMultiSelect.validation.minOnly",{min:l})}),e[112]=u,e[113]=l,e[114]=n.length,e[115]=m,e[116]=De):De=e[116];let Fe;return e[117]!==V||e[118]!==De?(Fe=s.jsxs("div",{className:"space-y-2",children:[V,De]}),e[117]=V,e[118]=De,e[119]=Fe):Fe=e[119],Fe};function Oj(t){return t.providers}function Bj(t){return t.modelsMetadata}function Fj(t){return t.toggleFavoriteModel}function _j(t){return t.isFavoriteModel}function Lj(t){return t.hiddenModels}function $j(t){return t.providerOrder}function zj(t){return s.jsx(ss,{value:t,className:"pr-2 [&>span:first-child]:hidden",children:t},t)}const Wj=(t,e,n)=>{const r=t.session.title?.trim()||t.session.id;return`
|
|
881
|
-
|
|
882
|
-
--- RESULT ${n+1}: ${r} ---
|
|
883
|
-
${e.trim()}
|
|
884
|
-
--- END RESULT ${n+1} ---`},Wc=(t,e)=>tt.getState().getWorktreeMetadata(t)?.projectDirectory??e;function Kj({session:t,open:e,onOpenChange:n}){const{t:r}=jt(),i=lg(),o=$s(E=>E.activeSessions),l=$s(E=>E.archivedSessions),a=$s(E=>E.status==="ready"),d=Gt(E=>E.providers),u=Gt(E=>E.currentProviderId),h=Gt(E=>E.currentModelId),f=Gt(E=>E.currentAgentName),[x,b]=c.useState(u??""),[w,v]=c.useState(h??""),[y,m]=c.useState(()=>u&&h?[{providerID:u,modelID:h,instanceId:Vr()}]:[]),[p,S]=c.useState(""),[g,C]=c.useState(f??""),[k,j]=c.useState([]),[D,I]=c.useState(!1),A=c.useMemo(()=>Po(t,Wc(t.id,t.directory)??t.directory),[t]),P=c.useMemo(()=>{const E=new Map;for(const X of i)E.set(X.id,X);for(const X of o)E.set(X.id,X);for(const X of l)E.set(X.id,X);return t.id&&E.set(t.id,t),Array.from(E.values())},[o,l,i,t]);c.useEffect(()=>{j([])},[e,t.id]);const T=c.useMemo(()=>!e||!A?[]:P.map(E=>{if(k.includes(E.id))return null;const X=tt.getState().getDirectoryForSession(E.id)??Ds(E),J=Wc(E.id,X),re=Po(E,J??E.directory);return!re||!Ud(A,re)?null:{session:E,directory:X,projectDirectory:J,identity:re}}).filter(E=>E!==null).sort((E,X)=>(E.session.time?.created??0)-(X.session.time?.created??0)),[P,e,A,k]),$=d.find(E=>E.id===x)?.models.find(E=>E.id===w),K=$?.variants?Object.keys($.variants):[],F=!!(A&&a&&x&&w&&T.length>0&&!D),W=c.useCallback(E=>{m([E]),b(E.providerID),v(E.modelID),S("")},[]),N=y[0]?.displayName||y[0]?.modelID||r("multirun.fusion.model.placeholder"),R=async()=>{if(!A||!F)return;const E=qt(),X=Cn.getSdkClient(),J=()=>{if(qt()!==E||Cn.getSdkClient()!==X)throw new Error("Runtime changed")};I(!0);try{const re=await Aj(X,T,A,J);if(re.length===0){Le.error(r("multirun.fusion.toast.noOutputs"));return}const fe=T[0]?.projectDirectory??T[0]?.directory??null;if(!fe)throw new Error("Fusion requires a session directory");const ne=Ph(A.groupSlug,x,w,A.runGroup),[te,ue]=await Promise.all([Il("session.fusion.visible"),Il("session.fusion.instructions")]),Se=await Ih(X,{title:ne,directory:fe,identity:{group:A.group,groupSlug:A.groupSlug,runGroup:A.runGroup,role:"fusion",providerID:x,modelID:w}},J);Th(Se,fe),tt.getState().setCurrentSession(Se.id,fe),n(!1),J(),await Cn.sendMessage({runtimeKey:E,id:Se.id,providerID:x,modelID:w,variant:p||void 0,agent:g||void 0,text:te,additionalParts:[{text:ue,synthetic:!0},...re.map((we,ye)=>({text:Wj(we.source,we.text,ye),synthetic:!0})),{text:`
|
|
885
|
-
|
|
886
|
-
--- FUSION INPUTS END ---
|
|
887
|
-
Now write the final fused answer.`,synthetic:!0}],directory:fe})}catch(re){if(qt()!==E||Cn.getSdkClient()!==X)return;console.error("[MultiRunFusion] Failed to start fusion",re),Le.error(r("multirun.fusion.toast.failed"))}finally{I(!1)}};return s.jsx(ys,{open:e,onOpenChange:n,children:s.jsxs(ws,{className:"max-w-xl overflow-visible",children:[s.jsxs(Vs,{children:[s.jsx(Ps,{children:r("multirun.fusion.title")}),s.jsx(Is,{children:r("multirun.fusion.description")})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("div",{className:"max-w-full",children:s.jsx(Vf,{selectedModels:y,onAdd:W,onUpdate:(E,X)=>W(X),onRemove:()=>{m([]),b(""),v(""),S("")},maxModels:1,addButtonLabel:N,showChips:!1,addButtonClassName:"w-fit max-w-[min(28rem,calc(100vw-8rem))] justify-start",dropdownSide:"bottom",dropdownClassName:"w-[min(28rem,calc(100vw-8rem))]",triggerIcon:x?s.jsx(Ki,{providerId:x,className:"h-3.5 w-3.5 mr-1"}):void 0})}),K.length>0?s.jsxs(Bs,{value:p||"__default__",onValueChange:E=>S(E==="__default__"?"":E),children:[s.jsxs(Fs,{size:"lg",className:"w-fit",children:[s.jsx(M,{name:"brain-ai-3",className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx(ks,{children:E=>E==="__default__"?r("multirun.modelMultiSelect.variant.default"):E})]}),s.jsxs(_s,{fitContent:!0,portalToBody:!0,children:[s.jsx(ss,{value:"__default__",children:r("multirun.modelMultiSelect.variant.default")}),K.map(E=>s.jsx(ss,{value:E,children:E},E))]})]}):null,s.jsx(Kf,{value:g,onChange:C,portalToBody:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta font-medium text-foreground",children:r("multirun.fusion.sources.label",{count:T.length})}),s.jsx("div",{className:"max-h-56 space-y-1 overflow-auto rounded-lg border border-[var(--interactive-border)] p-1",children:T.map(E=>s.jsxs("div",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 typography-meta",children:[s.jsx(Ki,{providerId:E.identity.providerID,className:"h-4 w-4"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:E.session.title||E.session.id}),s.jsx("button",{type:"button",onClick:()=>j(X=>[...X,E.session.id]),className:"text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"close",className:"h-4 w-4"})})]},E.session.id))})]}),s.jsxs(bn,{children:[s.jsx(dt,{variant:"ghost",onClick:()=>n(!1),children:r("multirun.fusion.actions.cancel")}),s.jsx(dt,{onClick:R,disabled:!F,children:r(D?"multirun.fusion.actions.starting":"multirun.fusion.actions.start")})]})]})})}function Vj(t){const e=Ze.c(7);let n,r,i,o,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("path",{d:"M12 4.5v6.25M12 10.75v3.5M12 10.75H7.25A3.25 3.25 0 0 0 4 14v1.25M12 10.75h4.75A3.25 3.25 0 0 1 20 14v1.25",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round"}),r=s.jsx("path",{d:"M9.25 7.25 12 4.5l2.75 2.75",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round"}),i=s.jsx("circle",{cx:"4",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),o=s.jsx("circle",{cx:"12",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),l=s.jsx("circle",{cx:"20",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),e[0]=n,e[1]=r,e[2]=i,e[3]=o,e[4]=l):(n=e[0],r=e[1],i=e[2],o=e[3],l=e[4]);let a;return e[5]!==t?(a=s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",...t,children:[n,r,i,o,l]}),e[5]=t,e[6]=a):a=e[6],a}const Uf=async(t,e,n)=>{const r=n.getRuntimeKey(),i=ht(t.path);if(!i)throw new Error("Unable to resolve worktree project");const o=await n.listProjectWorktrees(t,{force:!0});if(n.getRuntimeKey()!==r)throw new Error("Runtime changed during worktree refresh");const l=n.getCurrentProjects(),a=l.find(w=>w.id===t.id)??null;if(!a||ht(a.path??null)!==i)throw new Error("Project removed during worktree refresh");const d=sl({rawWorktreesByProjectRef:n.rawWorktreesByProjectRef,publishedWorktreesByProject:n.getPublishedWorktreesByProject(),runtimeKey:r}),u=o.map(w=>zo(w));u.sort((w,v)=>Hf({metadata:w},{metadata:v}));const h=cg(d.worktreesByProject,i,u,e?.projectDirectory);Uj(n.rawWorktreesByProjectRef,r),n.rawWorktreesByProjectRef.current={runtimeKey:r,revision:n.rawWorktreesByProjectRef.current.revision,worktreesByProject:h};const f=n.getPublishedWorktreesByProject(),x=dg(n.partitionWorktreesByRegisteredProject(l,h),f),b=[...x.values()].flat();return n.recordWorktreesSeen(b.map(w=>w.path),n.now()),n.worktreeMapsEqual(x,f)||n.publishTopology({availableWorktrees:b,availableWorktreesByProject:x}),u},Uj=(t,e)=>(t.current.runtimeKey!==e||(t.current={...t.current,revision:t.current.revision+1}),t.current.revision),Hj=t=>new Map([...t.entries()].map(([e,n])=>[e,n.map(r=>zo(r))])),sl=t=>((t.rawWorktreesByProjectRef.current.runtimeKey!==t.runtimeKey||t.rawWorktreesByProjectRef.current.worktreesByProject.size===0&&t.publishedWorktreesByProject.size>0)&&(t.rawWorktreesByProjectRef.current={runtimeKey:t.runtimeKey,revision:t.rawWorktreesByProjectRef.current.runtimeKey===t.runtimeKey?t.rawWorktreesByProjectRef.current.revision:0,worktreesByProject:Hj(t.publishedWorktreesByProject)}),t.rawWorktreesByProjectRef.current),Hf=(t,e)=>{const n=t.metadata.branch||t.metadata.name||t.metadata.label||t.metadata.path,r=e.metadata.branch||e.metadata.name||e.metadata.label||e.metadata.path,i=n.localeCompare(r,void 0,{sensitivity:"base"});return i!==0?i:t.metadata.path.localeCompare(e.metadata.path,void 0,{sensitivity:"base"})},Kc=t=>{const e=t.split("/").filter(Boolean);return e[e.length-1]??t},zo=t=>({...t,path:ht(t.path)??t.path,projectDirectory:ht(t.projectDirectory)??t.projectDirectory,worktreeRoot:ht(t.worktreeRoot??t.path)??t.worktreeRoot}),Vc=t=>{const{currentWorktree:e,path:n,projectDirectory:r,projectRootBranch:i}=t,l=ht(e?.path??null)===n,a=l?e?.branch??"":i??"",d={path:n,projectDirectory:r,branch:a,label:l?e?.label||e?.branch||e?.name||Kc(n):i||Kc(n),name:l?e?.name:void 0,worktreeRoot:l?ht(e?.worktreeRoot??n)??n:n,worktreeStatus:l?e?.worktreeStatus??"ready":"ready",worktreeSource:l?e?.worktreeSource??"existing":"existing",headState:l?e?.headState:i?"branch":void 0};return l&&e?{...e,...d}:d},Uc=t=>{const e=ht(t.projectPath??null),n=ht(t.sourceDirectory??null)??ht(t.currentWorktree?.path??null),r=ht(t.discoveredWorktrees.find(h=>ht(h.projectDirectory??null))?.projectDirectory??null),i=ht(t.currentWorktree?.projectDirectory??null),o=r??i??e,l=new Map,a=h=>{const f=ht(h.metadata.path??null);!f||l.has(f)||l.set(f,{...h,metadata:zo({...h.metadata,path:f})})};for(const h of t.discoveredWorktrees){const f=ht(h.path??null);f&&a({metadata:zo({...h,path:f,projectDirectory:ht(h.projectDirectory??null)??o??e??f}),isPrimary:o===f,isCurrent:n===f})}o&&!l.has(o)&&a({metadata:Vc({path:o,projectDirectory:o,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:!0,isCurrent:n===o}),n&&!l.has(n)&&a({metadata:Vc({path:n,projectDirectory:o??e??n,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:o===n,isCurrent:!0});const d=[],u=[];for(const h of l.values()){if(h.isPrimary){d.push(h);continue}u.push(h)}return d.sort((h,f)=>h.metadata.path.localeCompare(f.metadata.path,void 0,{sensitivity:"base"})),u.sort(Hf),[...d,...u]},Gj=(t,e)=>{const n=e.getRuntimeKey(),r=e.getPublishedWorktreesByProject(),i=sl({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:r,runtimeKey:n}),l=(t.projectId?e.projects.find(u=>u.id===t.projectId)??null:null)??(t.sourceDirectory?e.resolveProject(t.sourceDirectory):null),a=ht(l?.path??null);return{cachedTargets:Uc({projectPath:a,discoveredWorktrees:a?i.worktreesByProject.get(a)??[]:[],sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch}),refreshTargets:(async()=>{if(!l||!a)throw new Error("Unable to resolve worktree project");const u=await Uf(l,t.currentWorktree,e);return Uc({projectPath:a,discoveredWorktrees:u,sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch})})()}},qj=t=>{if(t.rawWorktreesByProjectRef.current.runtimeKey!==t.runtimeKey)return!1;if(t.rawWorktreesByProjectRef.current.revision!==t.capturedRevision)return t.requestRediscovery(),!1;const e=t.partitionWorktreesByRegisteredProject(t.projects,t.nextRawWorktreesByProject),n=[...e.values()].flat();return t.recordWorktreesSeen(n.map(r=>r.path),t.now()),t.rawWorktreesByProjectRef.current={runtimeKey:t.runtimeKey,revision:t.capturedRevision,worktreesByProject:new Map(t.nextRawWorktreesByProject)},t.worktreeMapsEqual(e,t.publishedWorktreesByProject)||t.publishTopology({availableWorktrees:n,availableWorktreesByProject:e}),!0},Yj=t=>({refreshState:t.isRefreshing?"loading":t.loadFailed&&t.targets.length===0?"error":null,showNewWorktreeAction:!0}),Qj=(t,e)=>ht(t.worktree?.path??null)===ht(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch,fa=6,ho=14,Hc=fa+14+6,Si=new WeakMap,Xj=t=>{const e=t.closest("[data-session-row]"),n=e?.closest(".overlay-scrollbar-container");if(!e||!n)return;Si.get(n)?.();const r=e.getBoundingClientRect().top;let i=3,o=!1,l=null;const a=()=>{o=!0,l!==null&&window.cancelAnimationFrame(l),l=null,Si.delete(n),n.removeEventListener("wheel",a),n.removeEventListener("touchstart",a)},d=()=>{if(o||!e.isConnected||!n.isConnected){a();return}const u=e.getBoundingClientRect().top-r;if(Math.abs(u)>.5&&(n.scrollTop+=u,Gs("ui.sidebar.selection_scroll_anchor_adjustment")),i-=1,i<=0){a();return}l=window.requestAnimationFrame(d)};n.addEventListener("wheel",a,{passive:!0}),n.addEventListener("touchstart",a,{passive:!0}),Si.set(n,a),l=window.requestAnimationFrame(d)},Jj=c.memo(function(e){const n=Ze.c(22),{archiveLabel:r,deleteLabel:i,buttonSizeClass:o,iconSizeClass:l,onPointerDown:a,onMouseDown:d,onArchive:u,onDelete:h}=e,f=Nj(),x=f?i:r;let b;n[0]!==u||n[1]!==h||n[2]!==f?(b=k=>{if(f||k.shiftKey){h(k);return}u(k)},n[0]=u,n[1]=h,n[2]=f,n[3]=b):b=n[3];const w=b,v=f?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let y;n[4]!==o||n[5]!==v?(y=Oe("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",v,o),n[4]=o,n[5]=v,n[6]=y):y=n[6];const m=f?"delete-bin":"archive";let p;n[7]!==l||n[8]!==m?(p=s.jsx(M,{name:m,className:l}),n[7]=l,n[8]=m,n[9]=p):p=n[9];let S;n[10]!==w||n[11]!==x||n[12]!==d||n[13]!==a||n[14]!==y||n[15]!==p?(S=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",className:y,"aria-label":x,onPointerDown:a,onMouseDown:d,onClick:w,onKeyDown:ak,children:p})}),n[10]=w,n[11]=x,n[12]=d,n[13]=a,n[14]=y,n[15]=p,n[16]=S):S=n[16];let g;n[17]!==x?(g=s.jsx(Dt,{side:"left",sideOffset:8,children:x}),n[17]=x,n[18]=g):g=n[18];let C;return n[19]!==S||n[20]!==g?(C=s.jsxs(Nt,{children:[S,g]}),n[19]=S,n[20]=g,n[21]=C):C=n[21],C});function Zj(t){Gs("ui.sidebar_session_node.render");const{t:e}=jt(),{node:n,depth:r=0,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:d=!1,pinnedSessionIds:u,expandedParents:h,hasSessionSearchQuery:f,normalizedSessionSearchQuery:x,notifyOnSubtasks:b,editingId:w,editingRowKey:v,setEditingId:y,setEditingRowKey:m,editTitle:p,setEditTitle:S,handleSaveEdit:g,handleCancelEdit:C,toggleParent:k,handleSessionSelect:j,handleSessionDoubleClick:D,handleShareSession:I,copiedSessionId:A,handleCopyShareUrl:P,handleCopySessionId:T,handleUnshareSession:L,openSidebarMenuKey:$,setOpenSidebarMenuKey:K,createFolderAndStartRename:F,handleDeleteSession:W,handleRestoreSession:N,startSessionWorktreeMenuLoad:R,mobileVariant:E,alwaysShowActions:X,secondaryMeta:J,renderContext:re="project",rowKey:fe,dragKey:ne,children:te}=t,ue=Gr(Me=>Me.toggle),Se=Jt(Me=>Me.getFoldersForScope),we=Jt(Me=>Me.getSessionFolderId),ye=Jt(Me=>Me.removeSessionFromFolder),Ae=Jt(Me=>Me.addSessionToFolder),pe=Pe(Me=>Me.openContextPanelTab),O=c.useMemo(()=>$n(),[]),Q=c.useMemo(()=>Ur(),[]),le=c.useContext(ug),H=O?"group-hover:opacity-100 group-hover:pointer-events-auto":"group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto",me=O?"group-hover:opacity-0":"group-hover:opacity-0 group-focus-within:opacity-0",ge=O,oe=!d&&!E,de=O?oe&&ge?"group-hover:pr-18":oe||ge?"group-hover:pr-14":"group-hover:pr-8":oe?"group-hover:pr-7 group-focus-within:pr-7":"group-hover:pr-3 group-focus-within:pr-3",_=oe?"pr-13":"pr-7",B=O?oe?"pr-18":"pr-14":oe?"pr-7":"pr-3",he=c.useRef(!1),[ve,Re]=c.useState(!1),ce=c.useRef(w);ce.current=w;const se=c.useRef(null),q=c.useRef(!1),z=c.useRef(g);z.current=g;const ee=p,ae=c.useRef(ee);ae.current=ee;const Ne=c.useRef(null),Ce=c.useRef(!1),We=c.useRef(null),Ee=c.useRef(null),xe=n.session,$e=xe,V=Ht(c.useCallback(Me=>{if(J?.projectLabel||!o)return null;const Ft=Me.projects.find(Qt=>Qt.id===o);return Ft?Ft.label?.trim()||Ln(ht(Ft.path)??Ft.path,null)||Ft.path:null},[o,J?.projectLabel])),De=J?.projectLabel??(V?Ba(V):null),Fe=J?.branchLabel??n.worktree?.branch??null,_e=c.useMemo(()=>{if(O)return null;const Me=n.worktree?.branch?.trim(),Ft=ht(n.worktree?.path??null);return Me&&Ft?Ho(Ft,Me):null},[O,n.worktree]),rt=Iu(_e),ct=rt?`var(--pr-${rt.visualState})`:void 0,et=us(Me=>Me.sessionGroupingMode),pt=!!Fe&&(re==="recent"||et==="flat"),kt=c.useMemo(()=>{if(!rt)return null;switch(rt.visualState){case"merged":return e("sessions.sidebar.group.pr.status.merged");case"open":return rt.canMerge===!0||rt.mergeableState==="clean"||rt.checks?.state==="success"?e("sessions.sidebar.group.pr.status.readyToMerge"):e("sessions.sidebar.group.pr.status.open");case"blocked":return rt.mergeableState==="dirty"?e("sessions.sidebar.group.pr.status.mergeConflicts"):e("sessions.sidebar.group.pr.status.mergeBlocked");case"draft":return e("sessions.sidebar.group.pr.status.draft");case"closed":return e("sessions.sidebar.group.pr.status.closed");default:return null}},[rt,e]),wt=tt(Me=>Me.currentSessionId===xe.id),Xe=ht(xe.directory??null)??ht(i??null),yt=a!==void 0?a:o??Xe??null,Rt=fg(),be=Tu(),Ge=O,ut=fs(Me=>Me.enabled),Y=fs(c.useCallback(Me=>Me.selectedIds.has(xe.id),[xe.id])),G=fs(Me=>Me.toggleSelected),Z=fs(Me=>Me.setRange),je=_f(),Ie=fe??xe.id,Ve=w===xe.id&&v===Ie,Je=c.useCallback(Me=>{const Ft=[],Qt=rs=>{rs.children.forEach(xs=>{Ft.push(xs.session.id),Qt(xs)})};return Qt(Me),Ft},[]),it=c.useCallback(Me=>{const Ft=[],Qt=rs=>{rs.children.forEach(xs=>{Ft.push(xs.session),Qt(xs)})};return Qt(Me),Ft},[]),[at,Ye]=c.useState(!1),[vt,Ue]=c.useState(!0),Pt=`${re}:${d?"archived":"active"}:${xe.id}`,ke=fe?`session-menu:${fe}`:Pt,xt=fe?`session-context:${fe}`:null,Ct=Eu(c.useCallback(Me=>!!Me.sessionMemoryState.get(mg(xe.id))?.isZombie,[xe.id])),qe=Sa(xe.id)?.type??"idle",ze=qe==="busy"||qe==="retry",ft=hg(xe.id,ze),Be=Zu(xe.id),Ke=va(xe.id,Xe),He=Be||Ke,nt=n.worktree??tt.getState().getWorktreeMetadata(xe.id)??null,[St,Lt]=c.useState([]),[Ut,Bt]=c.useState(!1),[zt,_t]=c.useState(!1),Yt=c.useRef(!1),Zt=c.useRef(0),es=pg(xe.id,Xe??void 0,{bootstrap:!1}),Vt=gg($e),It=Vt?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center",title:e(Tl[Vt.status]),"aria-label":e(Tl[Vt.status]),children:s.jsx(M,{name:"target",className:"h-3 w-3",style:{color:xg[Vt.status]}})}):null,bt=$e.title||e("sessions.sidebar.session.untitled"),cs=n.children.length>0,ms=bg(u,Xe,xe.id),hs=Pt,ds=f?!0:h.has(hs),nn=c.useMemo(()=>hj(n,ds,Xe),[ds,n,Xe]),Ts=yg(nn),rn=!!$e.parentID,qs=Yd(xe.id)>0&&(!rn||b),Ys=$e.time?.updated||$e.time?.created||Date.now(),Cs=Ru(Ys),Ns=wg(Ys),{isMenuOpen:mn,isContextMenuOpen:Es,handleMenuOpenChange:Rs,handleContextMenuOpenChange:Qs,handleMenuOpenChangeComplete:on,toggleMenu:an}=xj({menuInstanceKey:ke,contextMenuInstanceKey:xt,openSidebarMenuKey:$,setOpenSidebarMenuKey:K,hasDeferredCloseWork:()=>se.current!==null,onCloseComplete:()=>{if(!se.current)return;const{id:Me,title:Ft}=se.current;se.current=null,y(Me),m(Ie),S(Ft)}}),ps=mn||Es,vs=c.useMemo(()=>Po($e)!==null,[$e]),[ln,Sn]=c.useState(!1),ie=c.useMemo(()=>Je(n).length,[Je,n]),Qe=c.useCallback(async Me=>{const Ft=[];let Qt=0;for(const rs of Me)try{if(!Xe)throw new Error("Session directory is required for export");const xs=await Rt({directory:Xe,sessionID:rs.session.id});if(!xs)throw new Error("Session runtime changed during export");const Xt=rs.session.title||e("sessions.sidebar.session.export.untitledSubagent"),Xs=rs.session.agent,ts=await Qe(rs.children);Qt+=ts.skipped,Ft.push({title:Xt,agent:Xs,records:xs,children:ts.children})}catch{Qt+=Je(rs).length+1}return{children:Ft,skipped:Qt}},[Je,Rt,Xe,e]),lt=c.useCallback(Me=>{Me<=0||Le.warning(Me===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:Me}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:Me}))},[e]),st=c.useCallback(async Me=>{if(!Xe){Le.error(e("sessions.sidebar.session.export.nothingToExport"));return}const Ft=await Rt({directory:Xe,sessionID:xe.id}).catch(()=>null);if(!Ft){Le.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}if(Ft.length===0){Le.error(e("sessions.sidebar.session.export.nothingToExport"));return}let Qt,rs=0;if(Me&&n.children.length>0){const ts=await Qe(n.children);Qt=ts.children,rs=ts.skipped}const xs=ou(Ft,$e.title??null,Qt),Xt=iu($e.title??null),Xs=await au(xs,Xt);if(Xs){Le.success(e("sessions.sidebar.session.export.success"),{action:{label:e(Sg()),onClick:()=>{vg(Xs).then(ts=>{ts||Le.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),lt(rs);return}lu(xs,Xt),Le.success(e("sessions.sidebar.session.export.success")),lt(rs)},[Qe,Rt,n.children,$e.title,xe.id,Xe,lt,e]),gt=cu(),U=c.useMemo(()=>du(gt),[gt]),Te=c.useCallback(Me=>{Ju({entry:Me,t:e,session:{id:xe.id,title:$e.title,directory:Xe},loadRecords:()=>Xe?Rt({directory:Xe,sessionID:xe.id}).catch(()=>null):Promise.resolve(null),onLoadFailed:()=>Le.error(e("sessions.sidebar.session.export.failedLoadHistory"))})},[Rt,$e.title,xe.id,Xe,e]),ot=c.useCallback(async()=>{if(n.children.length>0){Ue(!0),Ye(!0);return}await st(!1)},[st,n.children.length]),Et=c.useCallback(()=>{Xe&&_n("desktop_open_session_mini_chat_window",{sessionId:xe.id,directory:Xe,apiBaseUrl:Pn(),clientToken:Hr()}).catch(Me=>{console.warn("[session-sidebar] failed to open mini chat window",Me)})},[xe.id,Xe]);if(c.useEffect(()=>{if(!Ve)return;const Me=Ft=>{const rs=(Ft.target instanceof HTMLElement?Ft.target:null)?.closest?.(`[data-session-rename-form="${CSS.escape(Ie)}"]`);Ee.current&&!rs&&z.current(ae.current)};return document.addEventListener("mousedown",Me),()=>document.removeEventListener("mousedown",Me)},[Ve,Ie]),c.useLayoutEffect(()=>{if(!Ve){Ne.current===Ie&&(Ne.current=null);return}Ne.current!==Ie&&(Ne.current=Ie,Ce.current=!0)},[p,Ve,Ie]),c.useLayoutEffect(()=>{if(!Ve||!Ce.current)return;const Me=We.current;!Me||Me.value!==p||(Ce.current=!1,Me.focus(),Me.select())},[p,Ve,ee]),Ve)return s.jsx("div",{style:{paddingLeft:Hc+r*ho},className:"group relative my-0.5 flex items-center rounded-sm py-1 pr-1.5",children:s.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-0",children:s.jsxs("form",{ref:Ee,"data-session-rename-form":Ie,className:"flex w-full items-center gap-2",onSubmit:Me=>{Me.preventDefault(),g(ee)},children:[s.jsx("input",{ref:We,value:ee,onChange:Me=>S(Me.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:e("sessions.sidebar.session.menu.rename"),onKeyDown:Me=>Ti(Me,C)}),s.jsx("button",{type:"submit","aria-label":e("sessions.sidebar.session.rename.save"),title:e("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:C,"aria-label":e("sessions.sidebar.session.rename.cancel"),title:e("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"close",className:"size-4"})})]})})},xe.id);const Mt=es.length,$t=Ts===1?e("sessions.sidebar.session.status.questionPendingSingle"):e("sessions.sidebar.session.status.questionPendingMany",{count:Ts}),Wt=gj({actionsAlwaysVisible:X&&!O,menuOpen:ps,hideOnHoverClass:me}),Ss=!He&&!ze&&qs&&!wt,is=ze||Ss,Vn=e(ze?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),um=s.jsx("span",{className:Oe("h-1.5 w-1.5 rounded-full",ze?"bg-primary":"bg-[var(--status-info)]"),"aria-label":Vn,title:Vn}),ii=(ze||Ss)&&ft,fm=!X&&cs&&(He||is||ms),nl=ms&&!He&&!is,mm=s.jsx(M,{name:"pushpin",className:"h-3 w-3 flex-shrink-0 text-primary","aria-label":e("sessions.sidebar.session.status.pinned")}),hm=He||is||nl?s.jsx("span",{style:{left:fa+r*ho},className:Oe("pointer-events-none absolute top-1/2 inline-flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center transition-opacity",fm?"opacity-100 group-hover:opacity-0 group-focus-within:opacity-0":""),children:He?s.jsx(M,{name:"loader-4",className:"h-3 w-3 animate-spin text-primary","aria-label":e(Ke?"sessions.aiRename.generating":"sessions.sidebar.session.status.movingToWorktree")}):is?um:nl?mm:null}):null,pm=cs&&!X&&(He||is||ms),gm=cs?s.jsx("span",{role:"button",tabIndex:0,onClick:Me=>{Me.stopPropagation(),Me.currentTarget.blur(),k(hs)},onKeyDown:Me=>{(Me.key==="Enter"||Me.key===" ")&&(Me.preventDefault(),Me.stopPropagation(),k(hs))},style:{minWidth:14,minHeight:14,left:fa+r*ho},className:Oe("absolute top-1/2 inline-flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",pm?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto":""),"aria-label":e(ds?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:ds?s.jsx(M,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(M,{name:"arrow-right-s",className:"h-3 w-3"})}):null,rl=Ct?s.jsx(M,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,xm=Me=>{Me.preventDefault(),Me.stopPropagation(),an()},bm=Me=>{Me.preventDefault(),Me.stopPropagation()},ym=Me=>{Me.preventDefault(),Me.stopPropagation()},wm=Me=>{Me.preventDefault(),Me.stopPropagation()},vm=Me=>{Me.preventDefault(),Me.stopPropagation()},Sm=Me=>{Me.preventDefault(),Me.stopPropagation(),K(null),W(xe,{archivedBucket:d})},jm=Me=>{Me.preventDefault(),Me.stopPropagation(),K(null),W(xe,{archivedBucket:d,hardDelete:!0,skipConfirm:!0})},km=Me=>{Me.preventDefault(),Me.stopPropagation()},Cm=Me=>{Me.preventDefault(),Me.stopPropagation()},Nm=Me=>{Me.preventDefault(),Me.stopPropagation(),le?.vscode?.executeCommand("openchamber.openSessionInEditor",xe.id,bt)},ol=Me=>{if(he.current){he.current=!1;return}if(ut){if(Me?.preventDefault(),Me?.stopPropagation(),Me?.shiftKey){const Ft=je?.getEntries(),Qt=Ft??Array.from(document.querySelectorAll("[data-session-row]")).map(Xt=>Xt.getAttribute("data-session-row")).filter(Xt=>!!Xt).map(Xt=>({id:Xt,rowKey:Xt,scopeKey:yt,archived:d})),rs=Ft?fs.getState().anchorRowKey:fs.getState().anchorId,xs=new Map;xs.set(xe.id,Je(n)),Z(rs,Ie,Qt,je?.getDescendantIds()??[],yt,xs);return}G(xe.id,yt,Je(n),Ie);return}Me?.currentTarget&&Xj(Me.currentTarget),j(xe.id,Xe)},Am=Me=>{Me.defaultPrevented||(Me.target instanceof HTMLElement?Me.target:null)?.closest('button, a, input, [role="menuitem"], [role="menu"]')||ol(Me)},Dm=Me=>{(Me.button===2||Me.button===0&&Me.ctrlKey&&!ut)&&(he.current=!0)},Pm=Me=>{E&&Me.pointerType==="touch"&&Re(!0),Me.button===0&&!wt&&!ut&&!Ge&&Xe&&!zi(xe.id,Xe).renderable&&be({directory:Xe,sessionID:xe.id}).catch(()=>{})},il=Me=>{E&&Me.pointerType==="touch"&&Re(!1)},Im=Me=>{Yt.current=Me,Zt.current+=1;const Ft=Zt.current;if(!Me){Bt(!1),_t(!1);return}const Qt=R({projectId:o??null,sourceDirectory:Xe,currentWorktree:nt});Lt(Qt.cachedTargets),Bt(!0),_t(!1),Qt.refreshTargets.then(rs=>{!Yt.current||Zt.current!==Ft||(Lt(rs),Bt(!1),_t(!1))}).catch(()=>{!Yt.current||Zt.current!==Ft||(Bt(!1),_t(!0))})},al=({Item:Me,Separator:Ft,Sub:Qt,SubTrigger:rs,SubContent:xs})=>s.jsxs(s.Fragment,{children:[s.jsxs(Me,{onClick:()=>{se.current={id:xe.id,title:bt}},className:"[&>svg]:mr-1",children:[s.jsx(M,{name:"pencil-ai",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]}),s.jsx(Qi,{sessionID:xe.id,directory:Xe,open:ps,Item:Me}),s.jsxs(Me,{onClick:()=>T(xe.id),className:"[&>svg]:mr-1",children:[s.jsx(M,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyId")]}),s.jsxs(Me,{onClick:()=>Xe&&ue({directory:Xe,sessionId:xe.id}),className:"[&>svg]:mr-1",children:[ms?s.jsx(M,{name:"unpin",className:"mr-1 h-4 w-4"}):s.jsx(M,{name:"pushpin",className:"mr-1 h-4 w-4"}),e(ms?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]}),$e.share?s.jsxs(s.Fragment,{children:[s.jsx(Me,{onClick:()=>{$e.share?.url&&P($e.share.url,xe.id)},className:"[&>svg]:mr-1",children:A===xe.id?s.jsxs(s.Fragment,{children:[s.jsx(M,{name:"check",className:"mr-1 h-4 w-4",style:{color:"var(--status-success)"}}),e("sessions.sidebar.session.menu.copied")]}):s.jsxs(s.Fragment,{children:[s.jsx(M,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyLink")]})}),s.jsxs(Me,{onClick:()=>L(xe.id),className:"[&>svg]:mr-1",children:[s.jsx(M,{name:"link-unlink-m",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Me,{onClick:()=>I($e),className:"[&>svg]:mr-1",children:[s.jsx(M,{name:"share-2",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.share")]}),s.jsxs(Me,{onClick:()=>{ot()},className:"[&>svg]:mr-1",children:[s.jsx(M,{name:"download",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]}),U.map(Xt=>s.jsxs(Me,{onClick:()=>Te(Xt),className:"[&>svg]:mr-1",children:[s.jsx(Xr,{icon:Xt.icon,iconSrc:Xt.iconSrc,className:"mr-1 size-4"}),Xt.action.label]},`${Xt.guest.id}:${Xt.action.id}`)),fj({isSubtaskSession:rn,archivedBucket:!!d,isVSCode:O,sessionDirectory:Xe})?(()=>{const Xt=mj({sessionDirectory:Xe,isStreaming:ze,isMovingToWorktree:Be}),Xs=Yj({targets:St,isRefreshing:Ut,loadFailed:zt});return s.jsxs(Qt,{onOpenChange:Im,children:[s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsxs(rs,{disabled:Xt,className:"w-full [&>svg]:mr-1","data-session-worktree-submenu-trigger":xe.id,children:[s.jsx(M,{name:"folder-shared",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.moveToWorktreeTargets")]})}),s.jsx(Dt,{side:"right",className:"max-w-72",children:e(Be?"sessions.sidebar.session.moveToWorktree.tooltipMoving":ze?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltipTargets")})]}),s.jsxs(xs,{className:"min-w-[220px]","data-session-worktree-submenu":xe.id,children:[St.map(ts=>{const Js=ht(ts.metadata.path??null)??ts.metadata.path,Nr=ts.isPrimary?e("sessions.sidebar.session.moveToWorktree.main"):ts.metadata.label||ts.metadata.branch||ts.metadata.name||ts.metadata.path,gs=ts.isCurrent||ts.metadata.worktreeStatus!=="ready";return s.jsxs(Me,{disabled:gs,title:ts.metadata.path,"data-session-worktree-target":Js,onClick:()=>{gs||!Xe||Zi({kind:"existing",root:$e,descendants:it(n),sourceDirectory:Xe,destination:ts.metadata,messages:Xi(e,{success:"sessions.sidebar.session.moveToWorktree.existingSuccess",failure:"sessions.sidebar.session.moveToWorktree.existingFailed"})})},children:[s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1 truncate",children:[s.jsx("span",{className:"truncate",children:Nr}),ts.isCurrent?s.jsx("span",{className:"sr-only",children:e("sessions.sidebar.session.moveToWorktree.current")}):null]}),ts.isCurrent?s.jsx(M,{name:"check",className:"ml-2 h-3.5 w-3.5 flex-shrink-0 text-primary","aria-hidden":"true"}):null]},Js)}),Xs.refreshState==="loading"?s.jsx(Me,{disabled:!0,"data-session-worktree-refresh-state":"loading",className:"py-0.5 text-muted-foreground typography-micro",children:e("sessions.sidebar.session.moveToWorktree.refreshing")}):null,Xs.refreshState==="error"?s.jsx(Me,{disabled:!0,"data-session-worktree-refresh-state":"error",className:"py-0.5 text-muted-foreground typography-micro",children:e("sessions.sidebar.session.moveToWorktree.loadFailed")}):null,s.jsx(Ft,{}),s.jsxs(Me,{disabled:Xt,"data-session-worktree-new-action":"true",onClick:()=>{Xt||!Xe||Zi({kind:"quick",root:$e,descendants:it(n),sourceDirectory:Xe,messages:Xi(e,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},className:"[&>svg]:mr-1",children:[s.jsx(M,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.newWorktree")]})]})]})})():null,vs?s.jsxs(Me,{onClick:()=>Sn(!0),className:"[&>svg]:mr-1",children:[s.jsx(Vj,{className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.runFusion")]}):null,Xe&&!d?(()=>{const Xt=[],Xs=gs=>{const js=ht(gs??null);js&&!Xt.includes(js)&&Xt.push(js)};if(o&&!O){const gs=Ht.getState().projects.find(ar=>ar.id===o),js=ht(gs?.path??null);Xs(js),js&&(tt.getState().availableWorktreesByProject.get(js)??[]).forEach(ar=>Xs(ar.path))}Xs(Ra(Xe)),Xs(Xe);const ts=Xt.flatMap(gs=>Se(gs).map(js=>({scope:gs,folder:js}))),Js=ts.find(({scope:gs,folder:js})=>we(gs,xe.id)===js.id)??null,Nr=Xt[0]??Xe;return s.jsxs(s.Fragment,{children:[s.jsx(Ft,{}),s.jsxs(Qt,{children:[s.jsxs(rs,{className:"[&>svg]:mr-1",children:[s.jsx(M,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]}),s.jsxs(xs,{className:"min-w-[180px]",children:[ts.length===0?s.jsx(Me,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):ts.map(({scope:gs,folder:js})=>{const ar=Js?.folder.id===js.id;return s.jsxs(Me,{onClick:()=>{if(ar){ye(gs,xe.id);return}Js&&Js.scope!==gs&&ye(Js.scope,xe.id),Ae(gs,js.id,xe.id)},children:[s.jsx("span",{className:"flex-1 truncate",children:js.name}),ar?s.jsx(M,{name:"check",className:"ml-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},js.id)}),s.jsx(Ft,{}),s.jsxs(Me,{onClick:()=>{const gs=F(Nr);gs&&(q.current=!0,Js&&Js.scope!==Nr&&ye(Js.scope,xe.id),Ae(Nr,gs.id,xe.id))},children:[s.jsx(M,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),Js?s.jsxs(Me,{onClick:()=>{ye(Js.scope,xe.id)},className:"text-destructive focus:text-destructive",children:[s.jsx(M,{name:"close",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,O?null:s.jsxs(Me,{disabled:!Xe,onClick:()=>{Xe&&pe(Xe,{mode:"chat",dedupeKey:`session:${xe.id}`,label:bt,sessionTitleFallback:bt})},className:"[&>svg]:mr-1",children:[s.jsx(M,{name:"chat-4",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openInSidePanel")}),s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-[var(--status-warning)] bg-[var(--status-warning)]/10",children:e("sessions.sidebar.session.menu.betaBadge")})]}),Q?s.jsxs(Me,{disabled:!Xe,onClick:Et,className:"[&>svg]:mr-1",children:[s.jsx(M,{name:"window",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]}):null,s.jsx(Ft,{}),d?null:s.jsxs(Me,{className:"[&>svg]:mr-1",onClick:()=>W(xe,{archivedBucket:d}),children:[s.jsx(M,{name:"inbox-archive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]}),d?s.jsxs(Me,{className:"[&>svg]:mr-1",onClick:()=>N(xe),children:[s.jsx(M,{name:"inbox-unarchive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.restore")]}):null,s.jsxs(Me,{className:"text-destructive focus:text-destructive [&>svg]:mr-1",onClick:()=>W(xe,{archivedBucket:d,hardDelete:!0}),children:[s.jsx(M,{name:"delete-bin",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})]}),Tm=s.jsx(Ws,{align:"end",className:"min-w-[180px]",finalFocus:()=>q.current?(q.current=!1,!1):!ce.current,children:al({Item:Kt,Separator:Os,Sub:kg,SubTrigger:Cg,SubContent:Ng})}),Em=s.jsx(Hi,{children:s.jsx(Gi,{className:"app-region-no-drag z-50",children:s.jsx(qi,{"data-slot":"dropdown-menu-content",finalFocus:()=>q.current?(q.current=!1,!1):!ce.current,style:{color:"var(--surface-elevated-foreground)"},className:Oe(Ri,"min-w-[180px]"),children:al({Item:({className:Me,...Ft})=>s.jsx(Vu,{className:Oe(Xd,Me),...Ft}),Separator:({className:Me,...Ft})=>s.jsx(Ku,{className:Oe(Qd,Me),...Ft}),Sub:qx,SubTrigger:({className:Me,children:Ft,...Qt})=>s.jsxs(Yx,{className:Oe(jg,Me),...Qt,children:[Ft,s.jsx(M,{name:"arrow-right-s",className:"ml-auto size-3.5"})]}),SubContent:({className:Me,children:Ft,...Qt})=>s.jsx(Hi,{children:s.jsx(Gi,{className:"app-region-no-drag z-50",children:s.jsx(qi,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:Oe(Ri,Me),...Qt,children:Ft})})})})})})});return s.jsxs(c.Fragment,{children:[s.jsx(lj,{sessionId:xe.id,dragKey:ne??Ie,ownerKey:l??yt,sessionDirectory:Xe??null,sessionTitle:bt,archivedBucket:d,children:s.jsxs(Hu,{open:Es,onOpenChange:Qs,onOpenChangeComplete:on,children:[s.jsxs(Uu,{render:s.jsx("div",{"data-session-row":xe.id,"data-session-scope":yt??"","data-session-archived":d?"1":"0","aria-current":wt?"page":void 0,onClick:Am,style:{paddingLeft:Hc+r*ho},className:Oe("group relative my-0.5 flex cursor-pointer items-center rounded-md py-1 pr-1.5",(wt||Y)&&"bg-interactive-selection text-interactive-selection-foreground",Y&&"ring-1 ring-inset ring-border")}),children:[hm,gm,s.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button","aria-pressed":ut?Y:void 0,onPointerDown:Pm,onPointerUp:il,onPointerCancel:il,onMouseDown:Dm,onClick:Me=>ol(Me),onDoubleClick:Me=>{Me.stopPropagation(),D(xe.id,bt)},className:Oe("flex min-w-0 flex-1 cursor-pointer flex-col gap-0 overflow-hidden text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring text-foreground select-none transition-[padding]",ve&&"bg-interactive-hover/70",X?O?de:_:ps?B:de),children:s.jsxs("div",{className:"flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden",children:[s.jsx("div",{className:Oe("block min-w-0 flex-1 truncate typography-ui-label font-normal",wt||Y?"text-interactive-selection-foreground":qs?"text-foreground":"text-foreground/80"),children:wo(bt,x)}),!d&&Xe&&(re==="recent"||et==="flat"&&n.worktree&&ht(n.worktree.path)!==ht(n.worktree.projectDirectory))?s.jsx(_o,{directory:Xe,className:X?void 0:ps?"mr-1":O?"group-hover:mr-1":"group-hover:mr-1 group-focus-within:mr-1"}):null,X?s.jsx("span",{className:"ml-2 inline-flex flex-shrink-0 items-center gap-1 typography-micro text-muted-foreground/75",children:ii?s.jsx(bl,{sessionId:xe.id,running:ze}):s.jsxs(s.Fragment,{children:[It,pt?s.jsx(M,{name:"git-branch",className:Oe("h-3 w-3",!ct&&"text-muted-foreground/60"),style:ct?{color:ct}:void 0}):null,Ns]})}):ii||It||pt||re==="recent"?s.jsx("div",{className:Oe("relative ml-1 flex h-4 flex-shrink-0 items-center justify-end",ps?"hidden":O?"group-hover:hidden":"group-hover:hidden group-focus-within:hidden"),children:s.jsx("span",{className:"inline-flex items-center gap-1 whitespace-nowrap text-right",children:ii?s.jsx(bl,{sessionId:xe.id,running:ze,className:"typography-micro"}):s.jsxs(s.Fragment,{children:[It,pt?s.jsx(M,{name:"git-branch",className:Oe("h-3 w-3",!ct&&"text-muted-foreground/60"),style:ct?{color:ct}:void 0}):null,re==="recent"?s.jsx("span",{className:"flex-shrink-0 typography-micro leading-none text-muted-foreground/75 tabular-nums",children:Ns}):null]})})}):null,Mt>0?s.jsxs("span",{className:Oe("inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0",Wt),title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[s.jsx(M,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Mt})]}):null,Ts>0?s.jsxs("span",{className:Oe("inline-flex items-center gap-1 rounded bg-status-info/10 px-1 py-0.5 text-[0.7rem] text-status-info flex-shrink-0",Wt),title:$t,"aria-label":$t,children:[s.jsx(M,{name:"question",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Ts})]}):null]})})}),O?null:s.jsx(Dt,{side:"right",sideOffset:8,className:"max-w-xs text-left",children:s.jsxs("div",{className:"flex min-w-44 flex-col gap-1.5 text-left text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:bt}),s.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:Cs,children:Ns})]}),De?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(M,{name:"folder",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 truncate",children:De})]}):null,Fe?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(M,{name:"git-branch",className:"h-3 w-3 flex-shrink-0",style:ct?{color:ct}:void 0}),s.jsx("span",{className:"min-w-0 truncate",children:Fe})]}):null,rt&&kt?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(M,{name:"git-pull-request",className:"h-3 w-3 flex-shrink-0",style:ct?{color:ct}:void 0}),s.jsxs("span",{className:"min-w-0 truncate",style:ct?{color:ct}:void 0,children:["#",rt.number," · ",kt]})]}):null]})})]})}),rl&&!E?s.jsx("div",{className:"absolute right-0 top-1/2 -translate-y-1/2 z-10",children:rl}):null,s.jsxs("div",{className:Oe("absolute right-0 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",ps||X&&!O?"opacity-100":Oe("opacity-0",H)),children:[oe?s.jsx(Jj,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:X?"h-6 w-6":"h-4 w-4",iconSizeClass:X?"h-3.5 w-3.5":"h-2.5 w-2.5",onPointerDown:wm,onMouseDown:vm,onArchive:Sm,onDelete:jm}):null,ge?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",className:Oe("inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",X?"h-6 w-6":"h-4 w-4"),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:km,onMouseDown:Cm,onClick:Nm,onKeyDown:Me=>Me.stopPropagation(),children:s.jsx(M,{name:"external-link",className:Oe(X?"h-3.5 w-3.5":"h-2.5 w-2.5")})})}),s.jsx(Dt,{side:"left",sideOffset:8,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,s.jsxs(Ks,{open:mn,onOpenChange:Rs,onOpenChangeComplete:on,children:[s.jsx(zs,{asChild:!0,children:s.jsx("button",{type:"button",className:Oe("inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",X?"h-6 w-6 opacity-100":ps?"h-4 w-4 opacity-100":Oe("h-4 w-4 opacity-0",H)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:bm,onMouseDown:ym,onClick:xm,onKeyDown:Me=>Me.stopPropagation(),children:s.jsx(M,{name:"more-2",className:Oe(X?"h-3.5 w-3.5":"h-2.5 w-2.5")})})}),Tm]})]})]}),Em]})}),cs&&ds?te:null,s.jsx(ys,{open:at,onOpenChange:Ye,children:s.jsxs(ws,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Vs,{children:[s.jsx(Ps,{children:e("sessions.sidebar.session.export.dialog.title")}),s.jsx(Is,{children:ie===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:ie}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:ie})})]}),s.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:vt,onChange:Me=>Ue(Me.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),s.jsxs(bn,{children:[s.jsx(dt,{type:"button",onClick:()=>Ye(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),s.jsx(dt,{type:"button",onClick:()=>{Ye(!1),st(vt)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})}),vs?s.jsx(Kj,{session:$e,open:ln,onOpenChange:Sn}):null]},xe.id)}const Gc=t=>ht(t.session.directory??null),ek=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null),tk=t=>{if(!t.openSidebarMenuKey)return null;if(t.rowKey&&(t.openSidebarMenuKey===`session-menu:${t.rowKey}`||t.openSidebarMenuKey===`session-context:${t.rowKey}`))return t.node.session.id;const e=t.archivedBucket?"archived":"active",n=`${t.renderContext??"project"}:${e}:`;return t.openSidebarMenuKey.startsWith(n)?t.openSidebarMenuKey.slice(n.length):null},qc=t=>t.menuOpenSessionId??tk(t),po=(t,e,n)=>e?n.has(t.node.session.id)?!0:Fn(t.node,e):!1,ma=(t,e,n,r,i)=>{if(t.session.id!==e.session.id)return!0;const o=i(t);if(n.has(o)!==r.has(o)||t.children.length!==e.children.length)return!0;for(let l=0;l<t.children.length;l+=1)if(ma(t.children[l],e.children[l],n,r,i))return!0;return!1},sk=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const n=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return ma(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${t.renderContext??"project"}:${n}:${i.session.id}`)||ma(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${e.renderContext??"project"}:${r}:${i.session.id}`)},nk=(t,e)=>t.id===e.id&&t.title===e.title&&t.directory===e.directory&&t.parentID===e.parentID&&t.share?.url===e.share?.url&&t.time?.created===e.time?.created&&t.time?.updated===e.time?.updated&&t.time?.archived===e.time?.archived&&Eh(t,e),rk=(t,e)=>{if(t.node.session.id!==e.node.session.id||!nk(t.node.session,e.node.session)||!Qj(t.node,e.node))return"node";if(t.depth!==e.depth)return"depth";if(t.groupDirectory!==e.groupDirectory)return"groupDirectory";if(t.projectId!==e.projectId)return"projectId";if(t.archivedBucket!==e.archivedBucket)return"archivedBucket";if((t.renderContext??"project")!==(e.renderContext??"project"))return"renderContext";if(t.mobileVariant!==e.mobileVariant)return"mobileVariant";if(t.alwaysShowActions!==e.alwaysShowActions)return"alwaysShowActions";if(t.hasSessionSearchQuery!==e.hasSessionSearchQuery)return"hasSessionSearchQuery";if(t.normalizedSessionSearchQuery!==e.normalizedSessionSearchQuery)return"normalizedSessionSearchQuery";if(t.notifyOnSubtasks!==e.notifyOnSubtasks)return"notifyOnSubtasks";if(t.nodeStructureKey!==e.nodeStructureKey)return"nodeStructureKey";if(t.relativeTimeTick!==e.relativeTimeTick)return"relativeTimeTick";if(Gc(t.node)!==Gc(e.node))return"nodeDirectory";if(!ek(t.secondaryMeta,e.secondaryMeta))return"secondaryMeta";if(t.pinnedSessionIds!==e.pinnedSessionIds&&Wf(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory))return"pinnedSessionIds";if(t.expandedParents!==e.expandedParents&&sk(t,e))return"expandedParents";if(t.editingId!==e.editingId&&(po(t,t.editingId,t.subtreeContainsEditing)||po(e,e.editingId,e.subtreeContainsEditing)))return"editingId";if(t.editingRowKey!==e.editingRowKey&&(t.editingRowKey===t.rowKey||e.editingRowKey===e.rowKey))return"editingRowKey";if(t.editTitle!==e.editTitle&&(po(t,t.editingId,t.subtreeContainsEditing)||po(e,e.editingId,e.subtreeContainsEditing)))return"editTitle";if(t.copiedSessionId!==e.copiedSessionId&&(Fn(t.node,t.copiedSessionId)||Fn(e.node,e.copiedSessionId)))return"copiedSessionId";if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const r=qc(t),i=qc(e);if(Fn(t.node,r)||Fn(e.node,i))return"openSidebarMenuKey"}return t.setEditingId===e.setEditingId&&t.setEditingRowKey===e.setEditingRowKey&&t.setEditTitle===e.setEditTitle&&t.handleSaveEdit===e.handleSaveEdit&&t.handleCancelEdit===e.handleCancelEdit&&t.toggleParent===e.toggleParent&&t.handleSessionSelect===e.handleSessionSelect&&t.handleSessionDoubleClick===e.handleSessionDoubleClick&&t.handleShareSession===e.handleShareSession&&t.handleCopyShareUrl===e.handleCopyShareUrl&&t.handleCopySessionId===e.handleCopySessionId&&t.handleUnshareSession===e.handleUnshareSession&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.createFolderAndStartRename===e.createFolderAndStartRename&&t.handleDeleteSession===e.handleDeleteSession&&t.handleRestoreSession===e.handleRestoreSession&&t.startSessionWorktreeMenuLoad===e.startSessionWorktreeMenuLoad&&t.children===e.children?null:"callbacks"},ok=(t,e)=>{const n=rk(t,e);return n===null?!0:(Gs(`ui.sidebar_session_node.props_changed.${n}`),!1)},ik=c.memo(Zj,ok);function ak(t){return t.stopPropagation()}const lk=t=>{const{t:e}=jt(),n=c.useRef(null),r=c.useRef(t.editingId),i=c.useRef(t.editTitle),o=c.useRef(t.deleteSessionConfirm);r.current=t.editingId,i.current=t.editTitle,o.current=t.deleteSessionConfirm;const l=Pe(te=>te.setSessionSwitcherOpen),a=tt(te=>te.setCurrentSession),d=tt(te=>te.updateSessionTitle),u=tt(te=>te.shareSession),h=tt(te=>te.unshareSession),f=tt(te=>te.deleteSession),x=tt(te=>te.deleteSessions),b=tt(te=>te.archiveSession),w=tt(te=>te.archiveSessions),v=tt(te=>te.unarchiveSession),{mobileVariant:y,allowReselect:m,onSessionSelected:p,resetSessionSearch:S,descendantIds:g,showDeletionDialog:C,setDeleteSessionConfirm:k,setEditingId:j,setEditingRowKey:D,editingSessionId:I,editingOccurrenceKey:A,setEditTitle:P,setCopiedSessionId:T}=t;c.useEffect(()=>()=>{n.current&&clearTimeout(n.current)},[]);const L=c.useCallback((te,ue)=>{if(Pi("navigation.session_select"),Pe.getState().closeMainSurfaces(),y&&l(!1),te===tt.getState().currentSessionId){m&&p?.(te),S();return}Pi("navigation.session_state_set"),a(te,ue??null),p?.(te),S()},[m,y,p,S,a,l]),$=c.useCallback((te,ue)=>{j(te),D(A),P(ue)},[A,P,j,D]),K=c.useCallback(async te=>{if(!r.current)return;const Se=(te??i.current).trim();Se&&await d(I,Se),j(null),D(null),P("")},[I,P,j,D,d]),F=c.useCallback(()=>{j(null),D(null),P("")},[P,j,D]),W=c.useCallback(async(te,ue)=>{try{return(await gn(te)).ok?(T(ue),n.current&&clearTimeout(n.current),n.current=window.setTimeout(()=>{T(null),n.current=null},2e3),!0):!1}catch{return!1}},[T]),N=c.useCallback(async te=>{const ue=await u(te.id);if(!ue?.share?.url){Le.error(e("sessions.sidebar.session.share.error"));return}const Se=await W(ue.share.url,te.id);Le[Se?"success":"warning"](e("sessions.sidebar.session.share.successTitle"),{description:e(Se?"sessions.sidebar.session.share.successDescription":"sessions.sidebar.session.share.copyUrlError")})},[W,u,e]),R=c.useCallback((te,ue)=>{W(te,ue).then(Se=>{Se||Le.error(e("sessions.sidebar.session.share.copyUrlError"))})},[W,e]),E=c.useCallback(te=>{gn(te).then(ue=>{if(ue.ok){Le.success(e("sessions.sidebar.session.copyId.success"));return}Le.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Le.error(e("sessions.sidebar.session.copyId.error")))},[e]),X=c.useCallback(async te=>{await h(te)?Le.success(e("sessions.sidebar.session.unshare.success")):Le.error(e("sessions.sidebar.session.unshare.error"))},[e,h]),J=c.useCallback(async(te,ue,Se)=>{const we=ue?.archivedBucket===!0||ue?.hardDelete===!0,ye=Se?.descendantIds??g;await Rh(we?"delete":"archive",te,ye,{archiveSession:b,archiveSessions:w,deleteSession:f,deleteSessions:x},e)},[b,w,f,x,g,e]),re=c.useCallback((te,ue)=>{const Se=ue?.archivedBucket===!0||ue?.hardDelete===!0,we=_d(te.id,g,Se);if(!C||ue?.skipConfirm===!0){J(te,ue,{descendantIds:we});return}k({session:te,descendantCount:we.length,descendantIds:we,archivedBucket:Se})},[g,J,k,C]),fe=c.useCallback(async()=>{const te=o.current;if(!te)return;const{session:ue,archivedBucket:Se,descendantIds:we}=te;k(null),await J(ue,{archivedBucket:Se},{descendantIds:we})},[J,k]),ne=c.useCallback(async te=>{await v(te.id)?Le.success(e("sessions.sidebar.session.restore.success")):Le.error(e("sessions.sidebar.session.restore.error"))},[e,v]);return c.useMemo(()=>({handleSessionSelect:L,handleSessionDoubleClick:$,handleSaveEdit:K,handleCancelEdit:F,handleShareSession:N,handleCopyShareUrl:R,handleCopySessionId:E,handleUnshareSession:X,handleDeleteSession:re,handleRestoreSession:ne,confirmDeleteSession:fe}),[F,E,R,re,ne,K,$,L,N,X,fe])};function ck(t){const e=Ze.c(71),{t:n}=jt(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t;let d,u,h,f,x,b,w,v,y,m;if(e[0]!==i||e[1]!==n||e[2]!==r){const R=n("sessions.sidebar.session.untitled");f=ys,y=!!r,e[13]!==i?(m=X=>{X||i(null)},e[13]=i,e[14]=m):m=e[14],h=ws,w=!1,v="max-w-sm gap-5",u=Vs;let E;e[15]!==n||e[16]!==r?.archivedBucket?(E=r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.title"):n("sessions.sidebar.dialogs.archiveSession.title"),e[15]=n,e[16]=r?.archivedBucket,e[17]=E):E=e[17],e[18]!==E?(b=s.jsx(Ps,{children:E}),e[18]=E,e[19]=b):b=e[19],d=Is,x=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||R,count:r.descendantCount}):n("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||R,count:r.descendantCount}):r.descendantCount===1?n("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||R,count:r.descendantCount}):n("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||R,count:r.descendantCount}):r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||R}):n("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||R}),e[0]=i,e[1]=n,e[2]=r,e[3]=d,e[4]=u,e[5]=h,e[6]=f,e[7]=x,e[8]=b,e[9]=w,e[10]=v,e[11]=y,e[12]=m}else d=e[3],u=e[4],h=e[5],f=e[6],x=e[7],b=e[8],w=e[9],v=e[10],y=e[11],m=e[12];let p;e[20]!==d||e[21]!==x?(p=s.jsx(d,{children:x}),e[20]=d,e[21]=x,e[22]=p):p=e[22];let S;e[23]!==u||e[24]!==b||e[25]!==p?(S=s.jsxs(u,{children:[b,p]}),e[23]=u,e[24]=b,e[25]=p,e[26]=S):S=e[26];let g;e[27]!==l||e[28]!==o?(g=()=>l(!o),e[27]=l,e[28]=o,e[29]=g):g=e[29];const C=!o;let k;e[30]!==o?(k=o?s.jsx(M,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(M,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[30]=o,e[31]=k):k=e[31];let j;e[32]!==n?(j=n("sessions.sidebar.dialogs.neverAsk"),e[32]=n,e[33]=j):j=e[33];let D;e[34]!==k||e[35]!==j||e[36]!==g||e[37]!==C?(D=s.jsxs("button",{type:"button",onClick:g,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-pressed":C,children:[k,j]}),e[34]=k,e[35]=j,e[36]=g,e[37]=C,e[38]=D):D=e[38];let I;e[39]!==i?(I=()=>i(null),e[39]=i,e[40]=I):I=e[40];let A;e[41]!==n?(A=n("sessions.sidebar.dialogs.cancel"),e[41]=n,e[42]=A):A=e[42];let P;e[43]!==I||e[44]!==A?(P=s.jsx("button",{type:"button",onClick:I,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:A}),e[43]=I,e[44]=A,e[45]=P):P=e[45];let T;e[46]!==a?(T=()=>{a()},e[46]=a,e[47]=T):T=e[47];let L;e[48]!==n||e[49]!==r?.archivedBucket?(L=r?.archivedBucket?n("sessions.sidebar.bulkActions.delete"):n("sessions.sidebar.bulkActions.archive"),e[48]=n,e[49]=r?.archivedBucket,e[50]=L):L=e[50];let $;e[51]!==T||e[52]!==L?($=s.jsx("button",{type:"button",onClick:T,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:L}),e[51]=T,e[52]=L,e[53]=$):$=e[53];let K;e[54]!==P||e[55]!==$?(K=s.jsxs("div",{className:"flex items-center gap-2",children:[P,$]}),e[54]=P,e[55]=$,e[56]=K):K=e[56];let F;e[57]!==D||e[58]!==K?(F=s.jsxs(bn,{className:"w-full sm:items-center sm:justify-between",children:[D,K]}),e[57]=D,e[58]=K,e[59]=F):F=e[59];let W;e[60]!==h||e[61]!==w||e[62]!==F||e[63]!==v||e[64]!==S?(W=s.jsxs(h,{showCloseButton:w,className:v,children:[S,F]}),e[60]=h,e[61]=w,e[62]=F,e[63]=v,e[64]=S,e[65]=W):W=e[65];let N;return e[66]!==f||e[67]!==W||e[68]!==y||e[69]!==m?(N=s.jsx(f,{open:y,onOpenChange:m,children:W}),e[66]=f,e[67]=W,e[68]=y,e[69]=m,e[70]=N):N=e[70],N}function dk(t){const e=Ze.c(57),{t:n}=jt(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t,d=r?.archivedBucket===!0,u=r?.sessionCount??0;let h;e[0]!==d||e[1]!==u||e[2]!==n?(h=n(d?u===1?"sessions.sidebar.dialogs.deleteSession.title":"sessions.sidebar.dialogs.deleteSessions.title":u===1?"sessions.sidebar.dialogs.archiveSession.title":"sessions.sidebar.dialogs.archiveSessions.title"),e[0]=d,e[1]=u,e[2]=n,e[3]=h):h=e[3];const f=h;let x;e[4]!==d||e[5]!==u||e[6]!==n?(x=d?u===1?n("sessions.sidebar.dialogs.deleteSessions.singleDescription",{count:u}):n("sessions.sidebar.dialogs.deleteSessions.pluralDescription",{count:u}):u===1?n("sessions.sidebar.dialogs.archiveSessions.singleDescription",{count:u}):n("sessions.sidebar.dialogs.archiveSessions.pluralDescription",{count:u}),e[4]=d,e[5]=u,e[6]=n,e[7]=x):x=e[7];const b=x,w=!!r;let v;e[8]!==i?(v=N=>{N||i(null)},e[8]=i,e[9]=v):v=e[9];let y;e[10]!==f?(y=s.jsx(Ps,{children:f}),e[10]=f,e[11]=y):y=e[11];let m;e[12]!==b?(m=s.jsx(Is,{children:b}),e[12]=b,e[13]=m):m=e[13];let p;e[14]!==y||e[15]!==m?(p=s.jsxs(Vs,{children:[y,m]}),e[14]=y,e[15]=m,e[16]=p):p=e[16];let S;e[17]!==l||e[18]!==o?(S=()=>l(!o),e[17]=l,e[18]=o,e[19]=S):S=e[19];const g=!o;let C;e[20]!==o?(C=o?s.jsx(M,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(M,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[20]=o,e[21]=C):C=e[21];let k;e[22]!==n?(k=n("sessions.sidebar.dialogs.neverAsk"),e[22]=n,e[23]=k):k=e[23];let j;e[24]!==k||e[25]!==S||e[26]!==g||e[27]!==C?(j=s.jsxs("button",{type:"button",onClick:S,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-pressed":g,children:[C,k]}),e[24]=k,e[25]=S,e[26]=g,e[27]=C,e[28]=j):j=e[28];let D;e[29]!==i?(D=()=>i(null),e[29]=i,e[30]=D):D=e[30];let I;e[31]!==n?(I=n("sessions.sidebar.dialogs.cancel"),e[31]=n,e[32]=I):I=e[32];let A;e[33]!==D||e[34]!==I?(A=s.jsx("button",{type:"button",onClick:D,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:I}),e[33]=D,e[34]=I,e[35]=A):A=e[35];let P;e[36]!==a?(P=()=>{a()},e[36]=a,e[37]=P):P=e[37];let T;e[38]!==d||e[39]!==n?(T=n(d?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=d,e[39]=n,e[40]=T):T=e[40];let L;e[41]!==P||e[42]!==T?(L=s.jsx("button",{type:"button",onClick:P,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:T}),e[41]=P,e[42]=T,e[43]=L):L=e[43];let $;e[44]!==A||e[45]!==L?($=s.jsxs("div",{className:"flex items-center gap-2",children:[A,L]}),e[44]=A,e[45]=L,e[46]=$):$=e[46];let K;e[47]!==j||e[48]!==$?(K=s.jsxs(bn,{className:"w-full sm:items-center sm:justify-between",children:[j,$]}),e[47]=j,e[48]=$,e[49]=K):K=e[49];let F;e[50]!==K||e[51]!==p?(F=s.jsxs(ws,{showCloseButton:!1,className:"max-w-sm gap-5",children:[p,K]}),e[50]=K,e[51]=p,e[52]=F):F=e[52];let W;return e[53]!==w||e[54]!==F||e[55]!==v?(W=s.jsx(ys,{open:w,onOpenChange:v,children:F}),e[53]=w,e[54]=F,e[55]=v,e[56]=W):W=e[56],W}function Gf(t){const e=Ze.c(36),{t:n}=jt(),{value:r,setValue:i,onConfirm:o}=t,l=!!r;let a;e[0]!==i?(a=C=>{C||i(null)},e[0]=i,e[1]=a):a=e[1];let d;e[2]!==n?(d=n("sessions.sidebar.dialogs.deleteFolder.title"),e[2]=n,e[3]=d):d=e[3];let u;e[4]!==d?(u=s.jsx(Ps,{children:d}),e[4]=d,e[5]=u):u=e[5];let h;e[6]!==n||e[7]!==r?(h=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?n("sessions.sidebar.dialogs.deleteFolder.withOneSubfolder",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withManySubfolders",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders",{folderName:r.folderName}):n("sessions.sidebar.dialogs.deleteFolder.single",{folderName:r?.folderName??""}),e[6]=n,e[7]=r,e[8]=h):h=e[8];let f;e[9]!==h?(f=s.jsx(Is,{children:h}),e[9]=h,e[10]=f):f=e[10];let x;e[11]!==u||e[12]!==f?(x=s.jsxs(Vs,{children:[u,f]}),e[11]=u,e[12]=f,e[13]=x):x=e[13];let b;e[14]!==i?(b=()=>i(null),e[14]=i,e[15]=b):b=e[15];let w;e[16]!==n?(w=n("sessions.sidebar.dialogs.cancel"),e[16]=n,e[17]=w):w=e[17];let v;e[18]!==b||e[19]!==w?(v=s.jsx("button",{type:"button",onClick:b,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:w}),e[18]=b,e[19]=w,e[20]=v):v=e[20];let y;e[21]!==n?(y=n("sessions.sidebar.bulkActions.delete"),e[21]=n,e[22]=y):y=e[22];let m;e[23]!==o||e[24]!==y?(m=s.jsx("button",{type:"button",onClick:o,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:y}),e[23]=o,e[24]=y,e[25]=m):m=e[25];let p;e[26]!==m||e[27]!==v?(p=s.jsxs(bn,{children:[v,m]}),e[26]=m,e[27]=v,e[28]=p):p=e[28];let S;e[29]!==p||e[30]!==x?(S=s.jsxs(ws,{showCloseButton:!1,className:"max-w-sm gap-5",children:[x,p]}),e[29]=p,e[30]=x,e[31]=S):S=e[31];let g;return e[32]!==l||e[33]!==a||e[34]!==S?(g=s.jsx(ys,{open:l,onOpenChange:a,children:S}),e[32]=l,e[33]=a,e[34]=S,e[35]=g):g=e[35],g}const uk=new Set;function Wo(t){const e=Ze.c(120),{node:n,depth:r,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:d,secondaryMeta:u,renderContext:h,rowKey:f,dragKey:x,renderExtras:b,pinnedSessionIds:w,expandedParents:v,hasSessionSearchQuery:y,normalizedSessionSearchQuery:m,notifyOnSubtasks:p,editingId:S,editingRowKey:g,setEditingId:C,setEditingRowKey:k,editTitle:j,setEditTitle:D,toggleParent:I,openSidebarMenuKey:A,setOpenSidebarMenuKey:P,allowReselect:T,onSessionSelected:L,resetSessionSearch:$,deleteSessionConfirm:K,setDeleteSessionConfirm:F,startFolderRename:W,copiedSessionId:N,setCopiedSessionId:R,startSessionWorktreeMenuLoad:E,mobileVariant:X,alwaysShowActions:J,renderChildren:re}=t,fe=r===void 0?0:r,ne=d===void 0?!1:d,te=h===void 0?"project":h,ue=re===void 0?!0:re,Se=f??`${te}:${ne?"archived":"active"}:${n.session.id}`,we=Jt(pk),ye=Jt(hk),Ae=Pe(mk),pe=Pe(fk);let O;if(e[0]!==n){O=[];const We=Ee=>Ee.children.forEach(xe=>{O.push(xe.session.id),We(xe)});We(n),e[0]=n,e[1]=O}else O=e[1];const Q=O.join(`
|
|
888
|
-
`);let le;e[2]!==Q?(le=Q?Q.split(`
|
|
889
|
-
`):[],e[2]=Q,e[3]=le):le=e[3];const H=le;let me;e[4]!==we||e[5]!==W||e[6]!==ye?(me=(We,Ee)=>{if(!We)return null;Ee&&Jt.getState().collapsedFolderIds.has(Ee)&&ye(Ee);const xe=we(We,"New folder",Ee);return W(We,xe),xe},e[4]=we,e[5]=W,e[6]=ye,e[7]=me):me=e[7];const ge=me;let oe;e[8]!==T||e[9]!==N||e[10]!==K||e[11]!==H||e[12]!==j||e[13]!==S||e[14]!==Se||e[15]!==X||e[16]!==n.session.id||e[17]!==L||e[18]!==$||e[19]!==R||e[20]!==F||e[21]!==D||e[22]!==C||e[23]!==k||e[24]!==Ae?(oe={mobileVariant:X,allowReselect:T,onSessionSelected:L,resetSessionSearch:$,descendantIds:H,showDeletionDialog:Ae,setDeleteSessionConfirm:F,deleteSessionConfirm:K,editingId:S,setEditingId:C,setEditingRowKey:k,editingSessionId:n.session.id,editingOccurrenceKey:Se,editTitle:j,setEditTitle:D,copiedSessionId:N,setCopiedSessionId:R},e[8]=T,e[9]=N,e[10]=K,e[11]=H,e[12]=j,e[13]=S,e[14]=Se,e[15]=X,e[16]=n.session.id,e[17]=L,e[18]=$,e[19]=R,e[20]=F,e[21]=D,e[22]=C,e[23]=k,e[24]=Ae,e[25]=oe):oe=e[25];const de=lk(oe),_=b?.childRenderExtrasFor,B=n.session.directory??i;let he;e[26]!==ne||e[27]!==o||e[28]!==te||e[29]!==B?(he={groupDirectory:B,projectId:o,archivedBucket:ne,renderContext:te},e[26]=ne,e[27]=o,e[28]=te,e[29]=B,e[30]=he):he=e[30];const ve=he,Re=x??f??n.session.id,ce=b?.subtreeContainsEditing??uk,se=b?.menuOpenSessionId??null,q=b?.nodeStructureKey??"",z=b?.relativeTimeTick;let ee;e[31]!==T||e[32]!==J||e[33]!==ve||e[34]!==_||e[35]!==N||e[36]!==K||e[37]!==fe||e[38]!==j||e[39]!==S||e[40]!==g||e[41]!==v||e[42]!==l||e[43]!==y||e[44]!==X||e[45]!==n.children||e[46]!==m||e[47]!==p||e[48]!==L||e[49]!==A||e[50]!==w||e[51]!==ue||e[52]!==$||e[53]!==a||e[54]!==R||e[55]!==F||e[56]!==D||e[57]!==C||e[58]!==k||e[59]!==P||e[60]!==W||e[61]!==E||e[62]!==I?(ee=ue?n.children.map(We=>s.jsx(Wo,{node:We,pinnedSessionIds:w,expandedParents:v,hasSessionSearchQuery:y,normalizedSessionSearchQuery:m,notifyOnSubtasks:p,editingId:S,editingRowKey:g,setEditingId:C,setEditingRowKey:k,editTitle:j,copiedSessionId:N,setEditTitle:D,toggleParent:I,openSidebarMenuKey:A,setOpenSidebarMenuKey:P,allowReselect:T,onSessionSelected:L,resetSessionSearch:$,deleteSessionConfirm:K,setDeleteSessionConfirm:F,startFolderRename:W,setCopiedSessionId:R,startSessionWorktreeMenuLoad:E,mobileVariant:X,alwaysShowActions:J,depth:fe+1,folderOwnerKey:l,selectionScopeKey:a,...ve,renderExtras:_?.(We)},We.session.id)):null,e[31]=T,e[32]=J,e[33]=ve,e[34]=_,e[35]=N,e[36]=K,e[37]=fe,e[38]=j,e[39]=S,e[40]=g,e[41]=v,e[42]=l,e[43]=y,e[44]=X,e[45]=n.children,e[46]=m,e[47]=p,e[48]=L,e[49]=A,e[50]=w,e[51]=ue,e[52]=$,e[53]=a,e[54]=R,e[55]=F,e[56]=D,e[57]=C,e[58]=k,e[59]=P,e[60]=W,e[61]=E,e[62]=I,e[63]=ee):ee=e[63];let ae;e[64]!==J||e[65]!==ne||e[66]!==N||e[67]!==ge||e[68]!==fe||e[69]!==j||e[70]!==S||e[71]!==g||e[72]!==Se||e[73]!==v||e[74]!==l||e[75]!==i||e[76]!==y||e[77]!==X||e[78]!==n||e[79]!==m||e[80]!==p||e[81]!==A||e[82]!==w||e[83]!==o||e[84]!==te||e[85]!==u||e[86]!==a||e[87]!==de.handleCancelEdit||e[88]!==de.handleCopySessionId||e[89]!==de.handleCopyShareUrl||e[90]!==de.handleDeleteSession||e[91]!==de.handleRestoreSession||e[92]!==de.handleSaveEdit||e[93]!==de.handleSessionDoubleClick||e[94]!==de.handleSessionSelect||e[95]!==de.handleShareSession||e[96]!==de.handleUnshareSession||e[97]!==D||e[98]!==C||e[99]!==k||e[100]!==P||e[101]!==E||e[102]!==Re||e[103]!==ce||e[104]!==se||e[105]!==q||e[106]!==z||e[107]!==ee||e[108]!==I?(ae=s.jsx(ik,{expandedParents:v,hasSessionSearchQuery:y,normalizedSessionSearchQuery:m,notifyOnSubtasks:p,editingId:S,editingRowKey:g,setEditingId:C,setEditingRowKey:k,editTitle:j,setEditTitle:D,handleSaveEdit:de.handleSaveEdit,handleCancelEdit:de.handleCancelEdit,toggleParent:I,handleSessionSelect:de.handleSessionSelect,handleSessionDoubleClick:de.handleSessionDoubleClick,handleShareSession:de.handleShareSession,copiedSessionId:N,handleCopyShareUrl:de.handleCopyShareUrl,handleCopySessionId:de.handleCopySessionId,handleUnshareSession:de.handleUnshareSession,openSidebarMenuKey:A,setOpenSidebarMenuKey:P,createFolderAndStartRename:ge,handleDeleteSession:de.handleDeleteSession,handleRestoreSession:de.handleRestoreSession,startSessionWorktreeMenuLoad:E,mobileVariant:X,alwaysShowActions:J,pinnedSessionIds:w,node:n,depth:fe,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:ne,secondaryMeta:u,renderContext:te,rowKey:Se,dragKey:Re,subtreeContainsEditing:ce,menuOpenSessionId:se,nodeStructureKey:q,relativeTimeTick:z,children:ee}),e[64]=J,e[65]=ne,e[66]=N,e[67]=ge,e[68]=fe,e[69]=j,e[70]=S,e[71]=g,e[72]=Se,e[73]=v,e[74]=l,e[75]=i,e[76]=y,e[77]=X,e[78]=n,e[79]=m,e[80]=p,e[81]=A,e[82]=w,e[83]=o,e[84]=te,e[85]=u,e[86]=a,e[87]=de.handleCancelEdit,e[88]=de.handleCopySessionId,e[89]=de.handleCopyShareUrl,e[90]=de.handleDeleteSession,e[91]=de.handleRestoreSession,e[92]=de.handleSaveEdit,e[93]=de.handleSessionDoubleClick,e[94]=de.handleSessionSelect,e[95]=de.handleShareSession,e[96]=de.handleUnshareSession,e[97]=D,e[98]=C,e[99]=k,e[100]=P,e[101]=E,e[102]=Re,e[103]=ce,e[104]=se,e[105]=q,e[106]=z,e[107]=ee,e[108]=I,e[109]=ae):ae=e[109];let Ne;e[110]!==K||e[111]!==n.session.id||e[112]!==de.confirmDeleteSession||e[113]!==F||e[114]!==pe||e[115]!==Ae?(Ne=K?.session.id===n.session.id?s.jsx(ck,{value:K,setValue:F,showDeletionDialog:Ae,setShowDeletionDialog:pe,onConfirm:de.confirmDeleteSession}):null,e[110]=K,e[111]=n.session.id,e[112]=de.confirmDeleteSession,e[113]=F,e[114]=pe,e[115]=Ae,e[116]=Ne):Ne=e[116];let Ce;return e[117]!==ae||e[118]!==Ne?(Ce=s.jsxs(s.Fragment,{children:[ae,Ne]}),e[117]=ae,e[118]=Ne,e[119]=Ce):Ce=e[119],Ce}function fk(t){return t.setShowDeletionDialog}function mk(t){return t.showDeletionDialog}function hk(t){return t.toggleFolderCollapse}function pk(t){return t.createFolder}const gk=24,xk=t=>Array.from({length:Math.min(t,gk)},(e,n)=>n),bk=(t,e,n)=>{const r=new Set(t);for(const i of e)i>=0&&i<n&&r.add(i);return[...r].sort((i,o)=>i-o)},yk=(t,e)=>t.find(n=>n.end>e)?.index??0;function Yc(t,e){return e?.kind==="activity-header"||e?.kind==="project-header"||e?.kind==="group-header"&&t.kind!=="project-header"?"pb-2":void 0}function wk({model:t,scrollElement:e,pinnedRowIndexes:n,renderRow:r,onFirstVisibleIndexChange:i}){const o=t.rows,l=c.useCallback(()=>e,[e]),a=c.useCallback(y=>o[y]?.estimateSize??32,[o]),d=c.useCallback(y=>o[y]?.key??y,[o]),u=c.useCallback(y=>bk(ab(y),n,o.length),[n,o.length]),h=ib({count:o.length,enabled:e!==null,getScrollElement:l,estimateSize:a,getItemKey:d,overscan:8,rangeExtractor:u}),f=h.getVirtualItems(),x=e?h.getTotalSize():0,b=e?Math.max(x-e.clientHeight,0):0,w=e?Math.min(e.scrollTop,b):0,v=yk(f,w);if(c.useLayoutEffect(()=>{i(v)},[v,i]),!e){const y=xk(o.length),m=y.reduce((S,g)=>S+(o[g]?.estimateSize??0),0),p=o.reduce((S,g)=>S+g.estimateSize,0);return s.jsxs("div",{"data-sidebar-virtual-pending":"true",children:[y.map(S=>{const g=o[S];return g?s.jsx("div",{className:Yc(g,o[S+1]),children:r(g,S)},g.key):null}),p>m?s.jsx("div",{"aria-hidden":"true",style:{height:p-m}}):null]})}return s.jsx("div",{"data-sidebar-virtual-ready":"true",style:{height:x,position:"relative"},children:f.map(y=>{const m=o[y.index];return m?s.jsx("div",{className:`[&_[data-session-row]]:my-px ${Yc(m,o[y.index+1])??""}`,"data-index":y.index,"data-sidebar-virtual-start":y.start,ref:h.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${y.start}px)`},children:r(m,y.index)},m.key):null})})}const vk=t=>{const e=Ze.c(33),{activityKey:n,collapsed:r,forceExpanded:i,alwaysShowActions:o,onToggle:l,onNewChat:a}=t,{t:d}=jt(),u=n==="chats",h=i?void 0:l,f=u?"pr-10":"pr-3.5";let x;e[0]!==f?(x=Oe("group flex w-full items-center gap-1.5 py-1 pl-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",f),e[0]=f,e[1]=x):x=e[1];const b=!r,w=u?"chat-4":"history",v=!i&&"group-hover:hidden";let y;e[2]!==v?(y=Oe("h-3.5 w-3.5 text-muted-foreground/80",v),e[2]=v,e[3]=y):y=e[3];let m;e[4]!==w||e[5]!==y?(m=s.jsx(M,{name:w,className:y}),e[4]=w,e[5]=y,e[6]=m):m=e[6];let p;e[7]!==r||e[8]!==i?(p=i?null:s.jsx("span",{className:"hidden h-3.5 w-3.5 items-center justify-center text-muted-foreground group-hover:inline-flex",children:s.jsx(M,{name:r?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}),e[7]=r,e[8]=i,e[9]=p):p=e[9];let S;e[10]!==m||e[11]!==p?(S=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[m,p]}),e[10]=m,e[11]=p,e[12]=S):S=e[12];const g=u?"sessions.sidebar.activity.chatsTitle":"sessions.sidebar.activity.recentTitle";let C;e[13]!==d||e[14]!==g?(C=d(g),e[13]=d,e[14]=g,e[15]=C):C=e[15];let k;e[16]!==C?(k=s.jsx("span",{className:"typography-ui-label font-semibold lowercase text-foreground",children:C}),e[16]=C,e[17]=k):k=e[17];let j;e[18]!==i||e[19]!==h||e[20]!==S||e[21]!==k||e[22]!==x||e[23]!==b?(j=s.jsxs("button",{type:"button",onClick:h,disabled:i,className:x,"aria-expanded":b,children:[S,k]}),e[18]=i,e[19]=h,e[20]=S,e[21]=k,e[22]=x,e[23]=b,e[24]=j):j=e[24];let D;e[25]!==o||e[26]!==u||e[27]!==a||e[28]!==d?(D=u?s.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),a()},className:Oe("absolute right-0.5 top-1/2 z-10 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",o?"opacity-100":"opacity-0 pointer-events-none group-hover/chats:opacity-100 group-hover/chats:pointer-events-auto group-focus-within/chats:opacity-100 group-focus-within/chats:pointer-events-auto"),"aria-label":d("sessions.sidebar.header.actions.newSession"),children:s.jsx(M,{name:"add",className:"h-4 w-4"})}):null,e[25]=o,e[26]=u,e[27]=a,e[28]=d,e[29]=D):D=e[29];let I;return e[30]!==j||e[31]!==D?(I=s.jsxs("div",{className:"relative group/chats -ml-2.5 -mr-2",children:[j,D]}),e[30]=j,e[31]=D,e[32]=I):I=e[32],I},Sk=(t,e)=>{const n=t.groups.find(o=>o.isMain&&o.sessions.length>0)??t.groups.find(o=>o.sessions.length>0)??t.groups.find(o=>o.isMain)??t.groups[0];if(!n)return[];const r=t.groups.find(o=>o.isArchivedBucket&&o.id!==n.id);return(e.mainWorkspaceOnly?[n,...r?[r]:[]]:[...t.groups.find(o=>o.isMain)?[t.groups.find(o=>o.isMain)]:[],...t.groups.filter(o=>!o.isMain)]).map(o=>({group:o,groupKey:`${t.project.id}:${o.id}`,projectId:t.project.id,hideGroupLabel:e.mainWorkspaceOnly?o.id===n.id:o.isMain}))},jk=[],kk=32,go=32,Hn=28,Qc=(t,e,n,r)=>{const i=r.get(t.session.id),o=r.get(e.session.id);if(i!==void 0||o!==void 0){if(i===void 0)return 1;if(o===void 0)return-1;if(i!==o)return i-o}return Fa(t.session,e.session,n,Ea)},Xc=t=>{const e=new Map,n=new Map,r=[],i=new WeakMap,o=t.map(l=>({node:l,visited:!1})).reverse();for(;o.length>0;){const l=o.pop();if(!l)continue;if(!l.visited){e.set(l.node.session.id,l.node),n.set(l.node.session.id,l.node.session);const d=r.length;r.push(l.node.session.id),i.set(l.node,[d,d+1]),o.push({node:l.node,visited:!0});for(let u=l.node.children.length-1;u>=0;u-=1){const h=l.node.children[u];h&&o.push({node:h,visited:!1})}continue}const a=i.get(l.node);a&&i.set(l.node,Object.freeze([a[0],r.length]))}return{byId:e,sessionsById:n,preorderIds:Object.freeze(r),subtreeRangeByNode:i}},Ck=(t,e,n)=>`${t}:${e?"archived":"active"}:${n}`,Nk=(t,e)=>{let n=null;for(const r of t){if(r.rowIndex>e)break;n=r}return n},Ak=t=>{const e=[],n=[],r=[],i=[],o=[],l=new Map,a=new Map,d=t.mode==="search",u=t.pinnedSessionIds instanceof Set?t.pinnedSessionIds:new Set(t.pinnedSessionIds);let h=0;const x=[...[...t.authoritativeSections.flatMap(g=>g.groups.flatMap(C=>C.sessions)),...t.chatGroup?.sessions??[]]];for(;x.length>0;){const g=x.pop();g&&(l.set(g.session.id,g.session),x.push(...g.children))}const b=g=>{const C=a.get(g)??0;return a.set(g,C+1),C===0?g:`${g}:${C}`},w=g=>{e.push(Object.freeze(g))},v=g=>{const C=[...g.nodes].reverse().map(k=>({node:k,depth:0,directory:g.groupDirectory}));for(;C.length>0;){const k=C.pop();if(!k)continue;const j=b(`${g.containerKey}:session:${k.node.session.id}`),D=k.node.session.directory??k.directory;l.set(k.node.session.id,k.node.session),w({kind:"session",key:j,estimateSize:kk,node:k.node,depth:k.depth,projectId:g.projectId,groupDirectory:k.directory,ownerKey:g.ownerKey,selectionScopeKey:g.selectionScopeKey,archived:g.archived,renderContext:g.renderContext,secondaryMeta:g.secondaryMeta??null});const I=g.indexedNodes?.subtreeRangeByNode.get(k.node),A=I&&I[1]>I[0]+1?Object.freeze([(g.selectionPoolOffset??0)+I[0]+1,(g.selectionPoolOffset??0)+I[1]]):void 0;if(n.push(Object.freeze({id:k.node.session.id,rowKey:j,scopeKey:g.selectionScopeKey,archived:g.archived,descendantRange:A})),!(!d&&!t.expandedParents.has(Ck(g.renderContext,g.archived,k.node.session.id))))for(let P=k.node.children.length-1;P>=0;P-=1){const T=k.node.children[P];T&&C.push({node:T,depth:k.depth+1,directory:D})}}},y=(g,C,k,j)=>{const D=t.groupSearchDataByGroup.get(g);if(d&&D?.hasMatch!==!0)return;d&&D&&(h+=D.matchedSessionCount+D.folderNameMatchCount+(D.groupMatches?1:0));const I=[...d?D?.filteredNodes??[]:g.sessions].sort((Q,le)=>Qc(Q,le,u,t.sessionOrderIndex)),A=Xc(I),P=r.length;r.push(...A.preorderIds);for(const[Q,le]of A.sessionsById)l.set(Q,le);const T=vr(k,g.directory),L=!d&&t.collapsedGroups.has(C);if(!j){const Q=A.preorderIds.flatMap(le=>A.sessionsById.get(le)??[]);w({kind:"group-header",key:`${C}:header`,estimateSize:go,group:g,groupKey:C,projectId:k,collapsed:L,forceExpanded:d,allSessions:Object.freeze(Q)})}if(L)return;const $=Yr(g).flatMap(({scopeKey:Q,directory:le})=>(t.foldersMap[Q]??jk).map(H=>({folder:H,scopeKey:Q,scopeDirectory:le,ownerKey:T,nodes:ca(H.sessionIds,A.byId).sort((me,ge)=>Qc(me,ge,u,t.sessionOrderIndex))}))),K=zf($.map(Q=>({id:Q.folder.id,name:Q.folder.name,parentId:Q.folder.parentId,nodeCount:Q.nodes.length})),{archivedBucket:g.isArchivedBucket===!0,searchQuery:d?t.normalizedQuery:""}),F=$.filter(Q=>K.has(Q.folder.id)),W=new Map(F.map(Q=>[Yn(Q.scopeKey,Q.folder.id),Q])),N=new Map;for(const Q of F){if(!Q.folder.parentId)continue;const le=Yn(Q.scopeKey,Q.folder.parentId),H=N.get(le)??[];H.push(Q),N.set(le,H)}const R=$f(F.map(Q=>({...Q.folder,scopeKey:Q.scopeKey}))).map(Q=>W.get(Yn(Q.scopeKey??"",Q.id))).filter(Q=>!!Q),E=new Set(F.flatMap(Q=>Q.folder.sessionIds)),X=I.filter(Q=>!E.has(Q.session.id)),J=new Map,re=R.map(Q=>({folder:Q,visited:!1})),fe=new Set;for(;re.length>0;){const Q=re.pop();if(!Q)continue;const le=Yn(Q.folder.scopeKey,Q.folder.folder.id);if(!Q.visited){if(fe.has(le))continue;fe.add(le),re.push({folder:Q.folder,visited:!0});for(const me of N.get(le)??[])re.push({folder:me,visited:!1});continue}const H=Q.folder.nodes.flatMap(me=>{const ge=A.subtreeRangeByNode.get(me);return ge?A.preorderIds.slice(ge[0],ge[1]).flatMap(oe=>A.sessionsById.get(oe)??[]):[me.session]});for(const me of N.get(le)??[])H.push(...J.get(Yn(me.scopeKey,me.folder.id))??[]);J.set(le,Object.freeze(H))}const ne=new Set,te=(Q,le)=>{const H=Yn(Q.scopeKey,Q.folder.id);if(ne.has(H))return;ne.add(H);const me=le?`${le} / ${Q.folder.name}`:Q.folder.name,ge=`${C}:folder:${H}`,oe=!d&&t.collapsedFolders.has(Q.folder.id),de=J.get(H)??[],_=oe&&!g.isArchivedBucket?ca([...new Set(de.map(ve=>ve.id))],A.byId):[],B=T?t.folderAuthorityByOwner.get(T):void 0,he=!!T&&!g.isArchivedBucket&&!Za(Q.scopeKey)&&B?.complete===!0&&B.scopeKeys.includes(Q.scopeKey);if(w({kind:"folder-header",key:ge,estimateSize:go,group:g,folder:Q.folder,displayName:me,scopeKey:Q.scopeKey,scopeDirectory:Q.scopeDirectory,ownerKey:T,nodes:Q.nodes,activityNodes:_,projectId:k,archived:g.isArchivedBucket===!0,collapsed:oe,forceExpanded:d,deleteSessions:de,subFolderCount:N.get(H)?.length??0,dropEnabled:he}),T&&o.push(Object.freeze({rowKey:ge,scopeKey:Q.scopeKey,folderId:Q.folder.id,ownerKey:T,enabled:he})),!oe){v({nodes:Q.nodes,containerKey:ge,projectId:k,groupDirectory:Q.scopeDirectory??g.directory,ownerKey:T,selectionScopeKey:T,archived:g.isArchivedBucket===!0,renderContext:"project",indexedNodes:A,selectionPoolOffset:P});for(const ve of N.get(H)??[])te(ve,me)}};for(const Q of R)te(Q,"");const ue=k?t.sessionBatchSize:void 0,Se=ue??(t.hideDirectoryControls?10:5),we=ue??7,ye=Math.max(Se,t.visibleCountByContainer.get(C)??Se),Ae=g.isArchivedBucket||d?X:X.slice(0,ye);v({nodes:Ae,containerKey:C,projectId:k,groupDirectory:g.directory,ownerKey:T,selectionScopeKey:T,archived:g.isArchivedBucket===!0,renderContext:"project",indexedNodes:A,selectionPoolOffset:P});const pe=X.length-Ae.length;!d&&!g.isArchivedBucket&&pe>0?w({kind:"show-control",key:`${C}:more`,estimateSize:Hn,control:"more",containerKey:C,currentCount:Ae.length,increment:we}):!d&&!g.isArchivedBucket&&X.length>Se&&pe===0&&w({kind:"show-control",key:`${C}:fewer`,estimateSize:Hn,control:"fewer",containerKey:C,currentCount:Ae.length,increment:we});const O=t.groupStatusByKey.get(C);I.length===0&&F.length===0?O&&O.state!=="ready"?w({kind:"status",key:`${C}:status`,estimateSize:Hn,status:O,group:g,groupKey:C}):w({kind:"empty",key:`${C}:empty`,estimateSize:Hn,emptyKind:g.isArchivedBucket?"archived":"group",group:g}):O&&O.state!=="ready"&&O.state!=="loading"&&w({kind:"status",key:`${C}:status`,estimateSize:Hn,status:O,group:g,groupKey:C})},m=g=>{const C=!d&&t.collapsedActivities.has(g),k=e.length;return w({kind:"activity-header",key:`activity:${g}:header`,estimateSize:go,activityKey:g,collapsed:C,forceExpanded:d}),i.push(Object.freeze({rowIndex:k,kind:"activity",id:g})),C};if(t.chatGroup){const g=t.groupSearchDataByGroup.get(t.chatGroup);(!d||g?.hasMatch===!0)&&(m("chats")||y(t.chatGroup,"activity:chats",null,!0))}if(t.showRecentSection)for(const g of t.recentSections){if(g.items.length===0||m("active-now"))continue;const k=`activity:${g.key}`,j=7,D=Math.max(j,t.visibleCountByContainer.get(k)??j),I=d?g.items:g.items.slice(0,D);for(const P of I){const T=Xc([P.node]),L=r.length;r.push(...T.preorderIds),v({nodes:[P.node],containerKey:k,projectId:P.projectId,groupDirectory:P.groupDirectory,ownerKey:vr(P.projectId,P.groupDirectory),selectionScopeKey:vr(P.projectId,P.groupDirectory),archived:!1,renderContext:"recent",secondaryMeta:P.secondaryMeta,indexedNodes:T,selectionPoolOffset:L}),d&&(h+=1)}const A=g.items.length-I.length;!d&&A>0?w({kind:"show-control",key:`${k}:more`,estimateSize:Hn,control:"more",containerKey:k,currentCount:I.length,increment:7}):!d&&g.items.length>j&&w({kind:"show-control",key:`${k}:fewer`,estimateSize:Hn,control:"fewer",containerKey:k,currentCount:I.length,increment:7})}let p=t.singleProjectMode?t.sections.filter(g=>g.project.id===t.singleProjectId):[...t.sections];if(t.showOnlyMainWorkspace){const g=p.find(C=>C.project.id===t.activeProjectId)??p[0];p=g?[g]:[]}for(const g of p){const C=!d&&!t.singleProjectMode&&!t.showOnlyMainWorkspace&&t.collapsedProjects.has(g.project.id);if(!t.showOnlyMainWorkspace){const j=e.length;w({kind:"project-header",key:`project:${g.project.id}:header`,estimateSize:go,section:g,collapsed:C,forceExpanded:d}),i.push(Object.freeze({rowIndex:j,kind:"project",id:g.project.id}))}if(C)continue;const k=Sk(g,{mainWorkspaceOnly:t.showOnlyMainWorkspace});for(const j of k)y(j.group,j.groupKey,j.projectId,j.hideGroupLabel)}e.length===0&&w({kind:"empty",key:d?"sidebar:search-empty":"sidebar:empty",estimateSize:72,emptyKind:d?"search":"sidebar"});const S=new Map;return e.forEach((g,C)=>S.set(g.key,C)),Object.freeze({rows:Object.freeze(e),selectionEntries:Object.freeze(n),selectionDescendantIds:Object.freeze(r),rowIndexByKey:S,stickyHeaders:Object.freeze(i),folderDropTargets:Object.freeze(o),folderAuthorityByOwner:t.folderAuthorityByOwner,sessionById:l,searchMatchCount:d?h:0})},qf=c.createContext(null);function Jc(t){let e=0,n=t;for(;n;){e+=n.offsetTop;const o=n.offsetParent;n=o instanceof HTMLElement?o:null}const r=t.closest("[data-sidebar-virtual-start]"),i=Number(r?.dataset.sidebarVirtualStart??"0");return e+(Number.isFinite(i)?i:0)}function Dk(t){const e=Ze.c(14),{enabled:n,suspended:r,layoutKey:i,scrollRef:o,children:l}=t,a=r===void 0?!1:r,d=i===void 0?"":i;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,e[0]=u):u=e[0];const h=c.useRef(u),f=c.useRef(null);let x;e[1]===Symbol.for("react.memo_cache_sentinel")?(x=p=>(h.current.add(p),f.current?.(),()=>{h.current.delete(p),f.current?.()}),e[1]=x):x=e[1];const b=x;let w;e[2]!==n||e[3]!==o||e[4]!==a?(w=()=>{const p=o.current;if(!n||a||!p)return;const S=document.createElement("div");S.dataset.sidebarCrossfadeLayer="true",S.className="pointer-events-none sticky top-0 z-30 h-0",S.style.marginBlock="0px",p.prepend(S);let g=null,C=null,k=null,j=0;const D=new Set;let I=[];const A=window.matchMedia("(prefers-reduced-motion: reduce)"),P=Ik,T=()=>{k?.cancel(),k=null,C?.remove(),C=null},L=()=>{let N=null,R=-1/0;for(const{entry:E,top:X}of I)X<=p.scrollTop&&X>=R&&(R=X,N=E);if(g!==N){if(T(),g&&N&&!A.matches){const E=g.host.cloneNode(!0);E instanceof HTMLElement&&(E.inert=!0,E.setAttribute("aria-hidden","true"),E.querySelectorAll("[id]").forEach(Pk),E.className="pointer-events-none absolute inset-x-0 top-0 z-30",C=E)}g&&(P(g,g.slot),g.slot.style.removeProperty("height")),g=N,S.hidden=!N,N&&(N.slot.style.height=`${N.host.getBoundingClientRect().height}px`,P(N,S),C&&(S.append(C),k=C.animate([{opacity:1},{opacity:0}],{duration:150,easing:"ease-out"}),k.onfinish=T))}},$=()=>{g&&(g.slot.style.height=`${g.host.getBoundingClientRect().height}px`);const N=Jc(p)+p.clientTop;I=Array.from(h.current,R=>({entry:R,top:Jc(R.slot)-N})),L()},K=new ResizeObserver($),F=new MutationObserver(()=>{cancelAnimationFrame(j),j=requestAnimationFrame($)});K.observe(p);const W=()=>{F.disconnect();for(const N of D)h.current.has(N)||(K.unobserve(N.host),N.slot.parentElement&&K.unobserve(N.slot.parentElement),D.delete(N));for(const N of h.current){const R=N.slot.closest("[data-sidebar-virtual-start]");R&&F.observe(R,{attributes:!0,attributeFilter:["data-sidebar-virtual-start"]}),D.has(N)||(K.observe(N.host),N.slot.parentElement&&K.observe(N.slot.parentElement),D.add(N))}cancelAnimationFrame(j),j=requestAnimationFrame($)};return f.current=W,p.addEventListener("scroll",L,{passive:!0}),W(),$(),()=>{f.current=null,cancelAnimationFrame(j),p.removeEventListener("scroll",L),K.disconnect(),F.disconnect(),T(),S.hidden=!0,g&&(P(g,g.slot),g.slot.style.removeProperty("height")),S.remove()}},e[2]=n,e[3]=o,e[4]=a,e[5]=w):w=e[5];let v;e[6]!==n||e[7]!==d||e[8]!==o||e[9]!==a?(v=[n,a,d,o],e[6]=n,e[7]=d,e[8]=o,e[9]=a,e[10]=v):v=e[10],c.useLayoutEffect(w,v);const y=n?b:null;let m;return e[11]!==l||e[12]!==y?(m=s.jsx(qf.Provider,{value:y,children:l}),e[11]=l,e[12]=y,e[13]=m):m=e[13],m}function Pk(t){return t.removeAttribute("id")}function Ik(t,e){const n=document.activeElement,r=n instanceof HTMLElement&&t.host.contains(n);e.moveBefore&&e.isConnected&&t.host.isConnected?e.moveBefore(t.host,null):e.append(t.host),r&&n.focus({preventScroll:!0})}function Tk(t){const e=Ze.c(15);let n,r;e[0]!==t?({register:r,...n}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);const i=c.useRef(null),[o]=c.useState(Ek);let l,a;e[3]!==o||e[4]!==r?(l=()=>{const x=i.current;if(!x)return;x.append(o);const b=r({slot:x,host:o});return()=>{b(),o.remove()}},a=[o,r],e[3]=o,e[4]=r,e[5]=l,e[6]=a):(l=e[5],a=e[6]),c.useLayoutEffect(l,a);let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx("div",{ref:i}),e[7]=d):d=e[7];let u;e[8]!==n?(u=s.jsx("div",{...n}),e[8]=n,e[9]=u):u=e[9];let h;e[10]!==o||e[11]!==u?(h=Rm.createPortal(u,o),e[10]=o,e[11]=u,e[12]=h):h=e[12];let f;return e[13]!==h?(f=s.jsxs(s.Fragment,{children:[d,h]}),e[13]=h,e[14]=f):f=e[14],f}function Ek(){const t=document.createElement("div");return t.className="pointer-events-auto flow-root",t}function Yf(t){const e=Ze.c(3),n=c.useContext(qf);let r;return e[0]!==t||e[1]!==n?(r=n?s.jsx(Tk,{...t,register:n}):s.jsx("div",{...t}),e[0]=t,e[1]=n,e[2]=r):r=e[2],r}const ji=t=>{const e=Ze.c(22),{id:n,projectLabel:r,projectIcon:i,projectColor:o,projectIconImage:l,projectIconBackground:a,isCollapsed:d,alwaysShowActions:u}=t,h=u===void 0?!1:u,{currentTheme:f}=or(),x=i?_a[i]:null,b=o?La[o]??null:null,w=d!==void 0,v=w?h?"hidden":"group-hover/project:hidden group-focus-within/project:hidden":void 0;let y;e[0]!==h||e[1]!==w||e[2]!==d?(y=w?s.jsx("span",{className:Oe("h-3.5 w-3.5 items-center justify-center text-muted-foreground",h?"inline-flex":"hidden group-hover/project:inline-flex group-focus-within/project:inline-flex"),children:s.jsx(M,{name:d?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[0]=h,e[1]=w,e[2]=d,e[3]=y):y=e[3];let m;e[4]!==h||e[5]!==f||e[6]!==w||e[7]!==b||e[8]!==v||e[9]!==n||e[10]!==a||e[11]!==l||e[12]!==x?(m=l?s.jsx("span",{className:Oe("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",w&&h?"hidden":"inline-flex",v),style:a?{backgroundColor:a}:void 0,children:s.jsx($a,{project:{id:n,iconImage:l},options:{themeVariant:f.metadata.variant,iconColor:f.colors.surface.foreground},className:"h-full w-full object-contain",fallback:x?s.jsx(M,{name:x,className:"h-3.5 w-3.5",style:b?{color:b}:void 0}):s.jsx(M,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:b?{color:b}:void 0})})}):x?s.jsx(M,{name:x,className:Oe("h-3.5 w-3.5",v),style:b?{color:b}:void 0}):s.jsx(M,{name:"folder",className:Oe("h-3.5 w-3.5 text-muted-foreground/80",v),style:b?{color:b}:void 0}),e[4]=h,e[5]=f,e[6]=w,e[7]=b,e[8]=v,e[9]=n,e[10]=a,e[11]=l,e[12]=x,e[13]=m):m=e[13];let p;e[14]!==y||e[15]!==m?(p=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[y,m]}),e[14]=y,e[15]=m,e[16]=p):p=e[16];let S;e[17]!==r?(S=s.jsx("span",{className:"truncate typography-ui-label font-semibold lowercase text-foreground",children:r}),e[17]=r,e[18]=S):S=e[18];let g;return e[19]!==p||e[20]!==S?(g=s.jsxs(s.Fragment,{children:[p,S]}),e[19]=p,e[20]=S,e[21]=g):g=e[21],g},Rk=t=>{const e=Ze.c(61),{id:n,disabled:r,projectLabel:i,projectDescription:o,projectDirectory:l,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:h,isCollapsed:f,isRepo:x,hideDirectoryControls:b,alwaysShowActions:w,onToggle:v,onNewSession:y,onNewWorktreeSession:m,onManageWorktrees:p,onRenameStart:S,onClose:g,children:C,showCreateButtons:k,hideHeader:j,statusIndicator:D,openSidebarMenuKey:I,setOpenSidebarMenuKey:A,projectPickerOptions:P,onProjectSelect:T}=t,L=r===void 0?!1:r,$=k===void 0?!0:k,K=j===void 0?!1:j,F=D===void 0?null:D,{t:W}=jt(),N=us(Bk);let R;e[0]!==L||e[1]!==n?(R={id:n,disabled:L},e[0]=L,e[1]=n,e[2]=R):R=e[2];const{attributes:E,listeners:X,setNodeRef:J,transform:re,transition:fe,isDragging:ne}=ti(R),te=c.useRef(!1),ue=`project:${n}`,Se=I===ue,[we,ye]=c.useState(!1),Ae=!!(P&&T);let pe;e[3]!==ue||e[4]!==A?(pe=z=>{z&&ye(!1),A(z?ue:null)},e[3]=ue,e[4]=A,e[5]=pe):pe=e[5];const O=pe;let Q;e[6]!==b||e[7]!==x||e[8]!==g||e[9]!==p||e[10]!==y||e[11]!==S||e[12]!==$||e[13]!==W?(Q=z=>s.jsxs(s.Fragment,{children:[$&&!x&&!b&&y&&s.jsxs(z,{onClick:y,children:[s.jsx(M,{name:"add",className:"mr-1.5 h-4 w-4"}),W("sessions.sidebar.project.actions.newSession")]}),x&&!b&&p&&s.jsxs(z,{onClick:p,children:[s.jsx(M,{name:"node-tree",className:"mr-1.5 h-4 w-4"}),W("sessions.sidebar.project.actions.manageWorktrees")]}),s.jsxs(z,{onClick:S,children:[s.jsx(M,{name:"pencil-ai",className:"mr-1.5 h-4 w-4"}),W("sessions.sidebar.project.actions.edit")]}),s.jsxs(z,{onClick:g,className:"text-destructive focus:text-destructive",children:[s.jsx(M,{name:"close",className:"mr-1.5 h-4 w-4"}),W("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=b,e[7]=x,e[8]=g,e[9]=p,e[10]=y,e[11]=S,e[12]=$,e[13]=W,e[14]=Q):Q=e[14];const le=Q,H=Fk,me=_k,ge=Lk;let oe;e[15]===Symbol.for("react.memo_cache_sentinel")?(oe=z=>{(z.button===2||z.button===0&&z.ctrlKey)&&(te.current=!0)},e[15]=oe):oe=e[15];const de=oe;let _;e[16]!==v?(_=z=>{if(z.currentTarget.blur(),te.current){te.current=!1;return}v()},e[16]=v,e[17]=_):_=e[17];const B=_;let he;e[18]!==re?(he=si.Transform.toString(re),e[18]=re,e[19]=he):he=e[19];let ve;e[20]!==he||e[21]!==fe?(ve={transform:he,transition:fe},e[20]=he,e[21]=fe,e[22]=ve):ve=e[22];const Re=ne&&"opacity-30";let ce;e[23]!==Re?(ce=Oe("relative",Re),e[23]=Re,e[24]=ce):ce=e[24];let se;e[25]!==w||e[26]!==E||e[27]!==O||e[28]!==B||e[29]!==b||e[30]!==K||e[31]!==n||e[32]!==f||e[33]!==we||e[34]!==Se||e[35]!==Ae||e[36]!==x||e[37]!==X||e[38]!==y||e[39]!==m||e[40]!==T||e[41]!==d||e[42]!==o||e[43]!==l||e[44]!==a||e[45]!==h||e[46]!==u||e[47]!==i||e[48]!==P||e[49]!==le||e[50]!==$||e[51]!==F||e[52]!==N||e[53]!==W?(se=K?null:s.jsx(s.Fragment,{children:s.jsxs(Kd,{open:we,onOpenChange:ye,children:[s.jsx(Wd,{render:s.jsx(Yf,{className:Oe("-ml-2.5 -mr-2 text-left group/project select-none",N&&"sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":N?"true":void 0,onContextMenu:z=>{b||(z.preventDefault(),ye(!0))}}),children:s.jsxs("div",{className:"relative flex items-center gap-1 py-1 pl-4 pr-3.5",...E,children:[Ae?s.jsxs(Ks,{children:[s.jsx(zs,{asChild:!0,children:s.jsxs("button",{type:"button",className:Oe("flex min-w-0 flex-1 items-center gap-1.5 rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-[padding]",x&&!b?w||Se?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":w||Se?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),"aria-label":W("sessions.sidebar.project.selectAria",{project:i}),children:[s.jsx(ji,{id:n,projectLabel:i,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:h}),s.jsx(M,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),l?s.jsx(_o,{directory:l,className:"ml-auto"}):null]})}),s.jsx(Ws,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:P?.map(z=>s.jsxs(Kt,{onClick:()=>T?.(z.id),className:"flex items-center justify-between gap-3",title:z.projectDescription,children:[s.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:s.jsx(ji,{...z})}),z.id===n?s.jsx(M,{name:"check",className:"h-4 w-4 flex-shrink-0 text-primary"}):null]},z.id))})]}):s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsxs("button",{type:"button",onMouseDown:de,onClick:B,...X,className:Oe("flex-1 min-w-0 flex items-center gap-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-md cursor-grab active:cursor-grabbing transition-[padding]",x&&!b?w||Se?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":w||Se?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),children:[s.jsx(ji,{id:n,projectLabel:i,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:h,isCollapsed:f,alwaysShowActions:w}),F?s.jsx("span",{className:"ml-1 inline-flex flex-shrink-0 items-center",children:F}):null,l?s.jsx(_o,{directory:l,className:"ml-auto"}):null]})}),s.jsx(Dt,{side:"right",sideOffset:8,children:o})]}),s.jsxs("div",{className:Oe("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",$?"right-7":"right-0.5"),children:[$&&x&&!b&&m?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),m()},className:Oe("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:text-foreground transition-opacity",w?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":W("sessions.sidebar.project.actions.newWorktree"),children:s.jsx(M,{name:"node-tree",className:"h-4 w-4"})})}),s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:W("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,b?null:s.jsxs(Ks,{open:Se,onOpenChange:O,children:[s.jsx(zs,{asChild:!0,children:s.jsx("button",{type:"button",className:Oe("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition-opacity focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:text-foreground",Se?"opacity-100 pointer-events-auto":w?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":W("sessions.sidebar.project.actions.projectMenu"),onPointerDown:me,onMouseDown:ge,onClick:H,children:s.jsx(M,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(Ws,{align:"end",className:"min-w-[180px]",children:le(Kt)})]})]}),$&&y?s.jsx("div",{className:"absolute right-0.5 top-1/2 z-10 -translate-y-1/2",children:s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),y()},className:Oe("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",w?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":W(x?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:s.jsx(M,{name:"add",className:"h-4 w-4"})})}),s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:W(x?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),s.jsx(zd,{className:"min-w-[180px]",children:le(Qn)})]})}),e[25]=w,e[26]=E,e[27]=O,e[28]=B,e[29]=b,e[30]=K,e[31]=n,e[32]=f,e[33]=we,e[34]=Se,e[35]=Ae,e[36]=x,e[37]=X,e[38]=y,e[39]=m,e[40]=T,e[41]=d,e[42]=o,e[43]=l,e[44]=a,e[45]=h,e[46]=u,e[47]=i,e[48]=P,e[49]=le,e[50]=$,e[51]=F,e[52]=N,e[53]=W,e[54]=se):se=e[54];let q;return e[55]!==C||e[56]!==J||e[57]!==ve||e[58]!==ce||e[59]!==se?(q=s.jsxs("div",{ref:J,style:ve,className:ce,children:[se,C]}),e[55]=C,e[56]=J,e[57]=ve,e[58]=ce,e[59]=se,e[60]=q):q=e[60],q},Mk=t=>{const e=Ze.c(21),{id:n,disabled:r,children:i}=t,o=r===void 0?!1:r;let l;e[0]!==o||e[1]!==n?(l={id:n,disabled:o},e[0]=o,e[1]=n,e[2]=l):l=e[2];const{listeners:a,setNodeRef:d,setActivatorNodeRef:u,transform:h,transition:f,isDragging:x}=ti(l);let b;e[3]!==a||e[4]!==u?(b={listeners:a,setActivatorNodeRef:u},e[3]=a,e[4]=u,e[5]=b):b=e[5];const w=b;let v;e[6]!==h?(v=si.Transform.toString(h),e[6]=h,e[7]=v):v=e[7];let y;e[8]!==v||e[9]!==f?(y={transform:v,transition:f},e[8]=v,e[9]=f,e[10]=y):y=e[10];const m=x&&"opacity-50";let p;e[11]!==m?(p=Oe("space-y-0.5 rounded-md",m),e[11]=m,e[12]=p):p=e[12];let S;e[13]!==i||e[14]!==w?(S=i(w),e[13]=i,e[14]=w,e[15]=S):S=e[15];let g;return e[16]!==d||e[17]!==y||e[18]!==p||e[19]!==S?(g=s.jsx("div",{ref:d,style:y,className:p,children:S}),e[16]=d,e[17]=y,e[18]=p,e[19]=S,e[20]=g):g=e[20],g},Ok=c.memo(Mk);function Bk(t){return t.stickyZoneHeaders}function Fk(t){t.stopPropagation()}function _k(t){t.stopPropagation()}function Lk(t){t.stopPropagation()}const Zc=[],$k=t=>{const e=Ze.c(6),{nodes:n,includeUnreadSubtasks:r,children:i}=t;let o;e[0]!==r||e[1]!==n?(o={nodes:n,includeUnreadSubtasks:r},e[0]=r,e[1]=n,e[2]=o):o=e[2];const l=el(o);let a;return e[3]!==i||e[4]!==l?(a=i(l),e[3]=i,e[4]=l,e[5]=a):a=e[5],a},Er=(t,e)=>e?t.sessions.some(n=>Fn(n,e)):!1,zk=(t,e,n)=>t.sessions.some(r=>Wf(r,r,e,n,t.directory,t.directory)),Wk=(t,e,n)=>{const r=i=>{const o=i.session.id;return e.get(o)!==n.get(o)?!0:i.children.some(r)};return t.sessions.some(r)},Kk=(t,e,n)=>{const r=t.isArchivedBucket?"archived":"active",i=o=>{const l=`project:${r}:${o.session.id}`;return e.has(l)!==n.has(l)?!0:o.children.some(i)};return t.sessions.some(i)},Vk=(t,e)=>{if(t.group!==e.group||t.groupKey!==e.groupKey||t.projectId!==e.projectId||t.hideGroupLabel!==e.hideGroupLabel||t.compactBodyPadding!==e.compactBodyPadding||t.groupSearchDataByGroup!==e.groupSearchDataByGroup||t.visibleSessionCount!==e.visibleSessionCount||t.sessionBatchSize!==e.sessionBatchSize||t.collapsedGroups!==e.collapsedGroups&&t.collapsedGroups.has(t.groupKey)!==e.collapsedGroups.has(e.groupKey)||t.pinnedSessionIds!==e.pinnedSessionIds&&zk(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.sessionOrderIndex!==e.sessionOrderIndex&&Wk(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.expandedParents!==e.expandedParents&&Kk(e.group,t.expandedParents,e.expandedParents)||t.editingId!==e.editingId&&(Er(e.group,t.editingId)||Er(e.group,e.editingId))||t.editingRowKey!==e.editingRowKey||t.editTitle!==e.editTitle&&Er(e.group,e.editingId)||t.copiedSessionId!==e.copiedSessionId&&(Er(e.group,t.copiedSessionId)||Er(e.group,e.copiedSessionId)))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const n=e.group.isArchivedBucket===!0,r=$o(e.group.sessions,t.openSidebarMenuKey,"project",n),i=$o(e.group.sessions,e.openSidebarMenuKey,"project",n);if(r||i)return!1}if(t.folderRename!==e.folderRename){const n=e.group.folderScopes?.map(r=>r.scopeKey)??[e.group.folderScopeKey??ht(e.group.directory??null)];if(n.includes(t.folderRename?.scopeKey??null)||n.includes(e.folderRename?.scopeKey??null))return!1}return t.hasSessionSearchQuery===e.hasSessionSearchQuery&&t.normalizedSessionSearchQuery===e.normalizedSessionSearchQuery&&t.hideDirectoryControls===e.hideDirectoryControls&&t.showMoreGroupSessions===e.showMoreGroupSessions&&t.resetGroupSessionLimit===e.resetGroupSessionLimit&&t.mobileVariant===e.mobileVariant&&t.alwaysShowActions===e.alwaysShowActions&&t.setActiveProjectIdOnly===e.setActiveProjectIdOnly&&t.setSessionSwitcherOpen===e.setSessionSwitcherOpen&&t.openNewSessionDraft===e.openNewSessionDraft&&t.onToggleCollapsedGroup===e.onToggleCollapsedGroup&&t.dragHandleProps===e.dragHandleProps&&t.renderBody===e.renderBody&&t.notifyOnSubtasks===e.notifyOnSubtasks&&t.setEditingId===e.setEditingId&&t.setEditingRowKey===e.setEditingRowKey&&t.setEditTitle===e.setEditTitle&&t.toggleParent===e.toggleParent&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.allowReselect===e.allowReselect&&t.onSessionSelected===e.onSessionSelected&&t.resetSessionSearch===e.resetSessionSearch&&t.deleteSessionConfirm===e.deleteSessionConfirm&&t.setDeleteSessionConfirm===e.setDeleteSessionConfirm&&t.startFolderRename===e.startFolderRename&&t.setCopiedSessionId===e.setCopiedSessionId&&t.startSessionWorktreeMenuLoad===e.startSessionWorktreeMenuLoad&&t.setFolderRenameDraft===e.setFolderRenameDraft&&t.clearFolderRename===e.clearFolderRename};function Uk(t){const{t:e}=jt(),{group:n,groupKey:r,projectId:i,hideGroupLabel:o,renderBody:l=!0,hasSessionSearchQuery:a,normalizedSessionSearchQuery:d,groupSearchDataByGroup:u,visibleSessionCount:h,sessionBatchSize:f,collapsedGroups:x,hideDirectoryControls:b,showMoreGroupSessions:w,resetGroupSessionLimit:v,mobileVariant:y,alwaysShowActions:m,activeProjectId:p,setActiveProjectIdOnly:S,setSessionSwitcherOpen:g,openNewSessionDraft:C,pinnedSessionIds:k,sessionOrderIndex:j,notifyOnSubtasks:D,onToggleCollapsedGroup:I,dragHandleProps:A,compactBodyPadding:P=!1,expandedParents:T,editingId:L,editingRowKey:$,openSidebarMenuKey:K,editTitle:F,copiedSessionId:W,folderRename:N,setFolderRenameDraft:R,clearFolderRename:E}=t,X=Jt(Be=>Be.toggleFolderCollapse),J=Jt(Be=>Be.renameFolder),re=Jt(Be=>Be.deleteFolder),fe=Jt(Be=>Be.addSessionToFolder),ne=Pe(Be=>Be.showDeletionDialog),[te,ue]=c.useState(null),Se=c.useCallback((Be,Ke)=>{const He=j.get(Be.session.id),nt=j.get(Ke.session.id);if(He!==void 0||nt!==void 0){if(He===void 0)return 1;if(nt===void 0)return-1;if(He!==nt)return He-nt}return Fa(Be.session,Ke.session,k,Ea)},[k,j]),we=a?u.get(n):null,ye=a?!1:x.has(r),Ae=c.useMemo(()=>{if(n.isMain||n.isArchivedBucket||o)return null;const Be=ht(n.directory??null),Ke=n.branch?.trim();return Be&&Ke?Ho(Be,Ke):null},[n.branch,n.directory,n.isArchivedBucket,n.isMain,o]),pe=Iu(Ae),O=pe?`var(--pr-${pe.visualState})`:void 0,Q=Yo(),le=c.useMemo(()=>{const Be=n.folderScopes?.map(Ke=>ht(Ke.directory))??[ht(n.directory??null)];return[...new Set(Be.filter(Ke=>!!Ke))]},[n.directory,n.folderScopes]);c.useSyncExternalStore(c.useCallback(Be=>le.length>0?Q.subscribeBootstrap(Be):()=>{},[le.length,Q]),c.useCallback(()=>le.map(Be=>`${Be}\0${Q.getBootstrapState(Be)??""}\0${Q.getBootstrapFailure(Be)??""}\0${Q.getInitializationState(Be)??""}\0${Q.getInitializationFailure(Be)??""}`).join(""),[le,Q]),c.useCallback(()=>"",[]));const H=le.some(Be=>{const Ke=Q.getBootstrapState(Be);return Ke==="queued"||Ke==="running"}),me=le.find(Be=>Q.getBootstrapState(Be)==="failed"||Q.getInitializationState(Be)==="failed")??null,ge=me!==null&&Q.getBootstrapState(me)==="failed",oe=me?ge?Q.getBootstrapFailure(me):Q.getInitializationFailure(me):void 0,de=oe==="os-permission"&&Bd(),[_,B]=c.useState(!1),he=c.useCallback(()=>{me&&Q.requestBootstrap({directory:me,priority:ye?"visible":"expanded",reason:n.isMain?"project-expanded":"worktree-expanded",force:!0})},[Q,me,n.isMain,ye]),ve=c.useCallback(async()=>{if(!(!me||!de||_)){B(!0);try{(await Fd(me)).success&&he()}finally{B(!1)}}},[de,me,_,he]),Re=f??(b?10:5),ce=Math.max(Re,h??Re),se=a?we?.groupMatches===!0:!1,q=a,z=c.useMemo(()=>[...q?we?.filteredNodes??[]:n.sessions].sort(Se),[Se,n.sessions,we?.filteredNodes,q]),ee=n.folderScopeKey??ht(n.directory??null),ae=vr(i,n.directory),Ne=c.useMemo(()=>n.folderScopes&&n.folderScopes.length>0?n.folderScopes:ee?[{scopeKey:ee,directory:n.directory??null}]:[],[ee,n.directory,n.folderScopes]),Ce=Jt(rr(c.useCallback(Be=>Ne.map(({scopeKey:Ke})=>Be.foldersMap[Ke]??Zc),[Ne]))),We=c.useMemo(()=>Ne.flatMap(({scopeKey:Be,directory:Ke},He)=>(Ce[He]??Zc).map(St=>({folder:St,scopeKey:Be,scopeDirectory:Ke}))),[Ce,Ne]),Ee=Jt(rr(c.useCallback(Be=>new Set(Ce.flatMap(Ke=>Ke.filter(He=>Be.collapsedFolderIds.has(He.id)).map(He=>He.id))),[Ce]))),xe=c.useMemo(()=>{const Be=new Map,Ke=He=>{He.forEach(nt=>{Be.set(nt.session.id,nt),nt.children.length>0&&Ke(nt.children)})};return Ke(z),Be},[z]),$e=c.useMemo(()=>We.map(({folder:Be,scopeKey:Ke,scopeDirectory:He})=>{const nt=ca(Be.sessionIds,xe).sort(Se);return{folder:Be,scopeKey:Ke,scopeDirectory:He,nodes:nt}}),[We,xe,Se]),V=c.useMemo(()=>{const Be=zf($e.map(({folder:Ke,nodes:He})=>({id:Ke.id,name:Ke.name,parentId:Ke.parentId,nodeCount:He.length})),{archivedBucket:n.isArchivedBucket===!0,searchQuery:a?d:""});return $e.filter(({folder:Ke})=>Be.has(Ke.id))},[$e,n.isArchivedBucket,a,d]),De=L,Fe=K,_e=c.useMemo(()=>new Set(V.flatMap(Be=>Be.folder.sessionIds)),[V]),rt=c.useMemo(()=>z.filter(Be=>!_e.has(Be.session.id)),[z,_e]),ct=c.useMemo(()=>{const Be=new Map(V.map(Ke=>[Ke.folder.id,Ke]));return $f(V.map(Ke=>Ke.folder)).map(Ke=>Be.get(Ke.id)).filter(Ke=>!!Ke)},[V]),et=c.useMemo(()=>{const Be=new Map;return V.forEach(Ke=>{if(!Ke.folder.parentId)return;const He=Be.get(Ke.folder.parentId)??[];He.push(Ke),Be.set(Ke.folder.parentId,He)}),Be},[V]),pt=c.useMemo(()=>{const Be=new Map(V.map(nt=>[nt.folder.id,nt])),Ke=new Map,He=(nt,St)=>{const Lt=Ke.get(nt);if(Lt!==void 0)return Lt;if(St.has(nt))return[];St.add(nt);const Ut=Be.get(nt),Bt=Ut?[...Ut.nodes]:[];for(const zt of et.get(nt)??[])Bt.push(...He(zt.folder.id,St));return Ke.set(nt,Bt),Bt};return V.forEach(({folder:nt})=>He(nt.id,new Set)),Ke},[V,et]),kt="project",wt=c.useMemo(()=>{const Be=new Set;return _c(z,De,Be),V.forEach(({nodes:Ke})=>{_c(Ke,De,Be)}),Be},[z,V,De]),Xe=c.useMemo(()=>{if(!Fe)return null;const Be=$o(z,Fe,kt,!!n.isArchivedBucket);if(Be)return Be;for(const{nodes:Ke}of V){const He=$o(Ke,Fe,kt,!!n.isArchivedBucket);if(He)return He}return null},[Fe,z,V,n.isArchivedBucket]),yt=c.useCallback(Be=>{const Ke=new WeakMap,He=nt=>{Ke.set(nt,Lo(nt));for(const St of nt.children)He(St)};return Be.forEach(He),Ke},[]),Rt=c.useMemo(()=>yt(z),[yt,z]),be=c.useMemo(()=>{const Be=new WeakMap;return V.forEach(({nodes:Ke})=>{Ke.forEach(He=>Be.set(He,Lo(He)))}),Be},[V]),Ge=c.useCallback(Be=>Rt.get(Be)??be.get(Be)??"",[Rt,be]),ut=c.useCallback(Be=>({subtreeContainsEditing:wt,menuOpenSessionId:Xe,nodeStructureKey:Ge(Be)}),[wt,Xe,Ge]),Y=rt.length,G=n.isArchivedBucket||a?rt:rt.slice(0,ce),Z=Y-G.length,je=!n.isArchivedBucket&&!a&&Y>Re&&Z===0,Ie=c.useCallback(Be=>{const Ke=[],He=nt=>{nt.forEach(St=>{Ke.push(St.session),St.children.length>0&&He(St.children)})};return He(Be),Ke},[]),Ve=c.useMemo(()=>Ie(z),[Ie,z]),Je=c.useMemo(()=>{if(!n.isArchivedBucket)return new Map;const Be=new Map,Ke=new Map;for(const{folder:nt}of V){if(!nt.parentId)continue;const St=Ke.get(nt.parentId)??[];St.push(nt.id),Ke.set(nt.parentId,St)}const He=(nt,St)=>{if(St.has(nt))return[];St.add(nt);const Lt=V.find(({folder:zt})=>zt.id===nt),Ut=Lt?Ie(Lt.nodes):[],Bt=Ke.get(nt)??[];for(const zt of Bt)Ut.push(...He(zt,St));return Ut};for(const{folder:nt}of V)Be.set(nt.id,He(nt.id,new Set));return Be},[V,Ie,n.isArchivedBucket]);if(a&&!se&&ct.length===0&&rt.length===0)return null;const it=!n.isMain&&!!n.branch,at=n.branch&&Ag(n.branch,n.label)?{label:n.branch}:null,Ye=ye?s.jsx(Y2,{nodes:z,includeUnreadSubtasks:D}):null,vt=(Be,Ke)=>{const{folder:He,scopeKey:nt,scopeDirectory:St,nodes:Lt}=Be,Ut=Je.get(He.id)??[],Bt=N?.folderId===He.id&&N?.scopeKey===nt,zt=a?!1:Ee.has(He.id),_t=Yt=>s.jsx(Bf,{folderId:He.id,scopeKey:nt,ownerKey:ae,children:(Zt,es)=>s.jsx(Of,{folder:He,displayName:Ke,sessions:Lt,isCollapsed:zt,collapsedActivityState:Yt,onToggle:()=>X(He.id),onRename:Vt=>{J(nt,He.id,Vt)},onDelete:()=>{if(n.isArchivedBucket){fn.requestDelete({sessions:Ut,mode:"session"});return}if(!ne){re(nt,He.id);return}const Vt=V.filter(({folder:bt})=>bt.parentId===He.id).length,It=Lt.length;ue({scopeKey:nt,folderId:He.id,folderName:He.name,subFolderCount:Vt,sessionCount:It})},groupDirectory:St??n.directory,projectId:i,mobileVariant:y,alwaysShowActions:m,isRenaming:Bt,renameDraft:Bt?N?.draft:void 0,onRenameDraftChange:R,onRenameSave:()=>{const Vt=N?.draft.trim()??"";Vt&&J(nt,He.id,Vt),E()},onRenameCancel:E,droppableRef:Zt,isDropTarget:es,depth:0,onNewSession:()=>{i&&i!==p&&S(i),y&&g(!1),C({selectedProjectId:i,directoryOverride:St??n.directory,targetFolderId:He.id,target:n.draftTarget})},hideActions:!1,archivedBucket:n.isArchivedBucket===!0,children:Lt.map(Vt=>s.jsx(Wo,{node:Vt,pinnedSessionIds:k,expandedParents:T,hasSessionSearchQuery:a,normalizedSessionSearchQuery:d,notifyOnSubtasks:D,editingId:L,editingRowKey:$,editTitle:F,copiedSessionId:W,openSidebarMenuKey:K,mobileVariant:y,alwaysShowActions:m,groupDirectory:St??n.directory,projectId:i,folderOwnerKey:ae,selectionScopeKey:ae,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:wt,menuOpenSessionId:Xe,nodeStructureKey:Ge(Vt),childRenderExtrasFor:ut},setEditingId:t.setEditingId,setEditingRowKey:t.setEditingRowKey,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,resetSessionSearch:t.resetSessionSearch,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,setCopiedSessionId:t.setCopiedSessionId,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},Vt.session.id))})},He.id);return zt?s.jsx($k,{nodes:pt.get(He.id)??Lt,includeUnreadSubtasks:D,children:_t},He.id):_t(null)},Ue=()=>{const Be=new Map;for(const St of V){const Lt=St.folder.parentId;if(!Lt)continue;const Ut=Be.get(Lt);Ut?Ut.push(St):Be.set(Lt,[St])}const Ke=[],He=new Set,nt=(St,Lt)=>{if(He.has(St.folder.id))return;He.add(St.folder.id);const Ut=Lt?`${Lt} / ${St.folder.name}`:St.folder.name;Ke.push(vt(St,Ut)),!(!a&&Ee.has(St.folder.id))&&(Be.get(St.folder.id)??[]).forEach(zt=>nt(zt,Ut))};return ct.forEach(St=>nt(St,"")),Ke},Pt=!!(!n.isMain&&n.worktree),ke=n.worktree?.worktreeStatus==="missing"?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center text-status-warning",title:e("sessions.sidebar.group.worktreeMissing"),"aria-label":e("sessions.sidebar.group.worktreeMissing"),children:s.jsx(M,{name:"alert",className:"h-3 w-3"})}):null,xt=m?Pt?"pr-14":"pr-7":Pt?"pr-2 group-hover/gh:pr-14 group-focus-within/gh:pr-14":"pr-2 group-hover/gh:pr-7 group-focus-within/gh:pr-7",Ct=me?s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(oe==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":ge?"sessions.sidebar.group.empty.loadFailed":"sessions.sidebar.group.empty.initializationFailed"),de?s.jsx(dt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:_,onClick:()=>{ve()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,s.jsx(dt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:he,children:e("sessions.sidebar.group.empty.retry")})]}):null,Tt=Be=>s.jsx(Wo,{node:Be,pinnedSessionIds:k,expandedParents:T,hasSessionSearchQuery:a,normalizedSessionSearchQuery:d,notifyOnSubtasks:D,editingId:L,editingRowKey:$,editTitle:F,copiedSessionId:W,openSidebarMenuKey:K,mobileVariant:y,alwaysShowActions:m,groupDirectory:n.directory,projectId:i,folderOwnerKey:ae,selectionScopeKey:ae,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:wt,menuOpenSessionId:Xe,nodeStructureKey:Ge(Be),childRenderExtrasFor:ut},setEditingId:t.setEditingId,setEditingRowKey:t.setEditingRowKey,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,resetSessionSearch:t.resetSessionSearch,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,setCopiedSessionId:t.setCopiedSessionId,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},Be.session.id),qe=s.jsxs(cj,{scopeKey:Ne[0]?.scopeKey??ee,ownerKey:ae,hasFolders:V.length>0,onSessionDroppedOnFolder:(Be,Ke)=>{const He=V.find(({folder:St,scopeKey:Lt})=>St.id===Ke.folderId&&Lt===Ke.scopeKey);if(!He)return;const nt=Jt.getState();for(const{scopeKey:St}of Ne)St!==He.scopeKey&&nt.getSessionFolderId(St,Be)&&nt.removeSessionFromFolder(St,Be);fe(He.scopeKey,Ke.folderId,Be)},children:[Ue(),G.map(Tt),Y===0&&V.length===0?s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:n.isArchivedBucket?e("sessions.sidebar.group.empty.noArchivedSessions"):H?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(M,{name:"loader-4",className:"size-3 animate-spin"}),e("sessions.sidebar.group.empty.loadingSessions")]}):Ct||(n.emptyMessage??e("sessions.sidebar.group.empty.noSessionsInWorkspace"))}):null,Y>0&&Ct?s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-status-error",children:Ct}):null,Z>0?s.jsx("button",{type:"button",onClick:()=>w(r,G.length,f??7),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,je?s.jsx("button",{type:"button",onClick:()=>v(r),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showFewer")}):null]}),ze="pb-2",ft=s.jsx(Gf,{value:te,setValue:ue,onConfirm:()=>{const Be=te;Be&&(re(Be.scopeKey,Be.folderId),ue(null))}});return o?l?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"oc-group",children:s.jsx("div",{className:Oe("oc-group-body",ze),children:qe})}),ft]}):null:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"oc-group",children:[s.jsxs("div",{className:Oe("group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md","cursor-pointer"),onClick:()=>I(r),role:"button",tabIndex:0,onKeyDown:Be=>{(Be.key==="Enter"||Be.key===" ")&&(Be.preventDefault(),I(r))},"aria-label":ye?e("sessions.sidebar.group.expandAria",{label:n.label}):e("sessions.sidebar.group.collapseAria",{label:n.label}),"aria-expanded":!ye,children:[s.jsxs("div",{ref:A?.setActivatorNodeRef,className:Oe("min-w-0 flex flex-1 items-start gap-1 overflow-hidden pl-1.5 transition-[padding]",xt),...A?.listeners??{},children:[s.jsxs("div",{className:"min-w-0 flex flex-1 flex-col justify-center gap-0.5 overflow-hidden",children:[s.jsx("p",{className:"typography-ui-label font-normal truncate text-foreground/92",children:n.isArchivedBucket?s.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsx(M,{name:"archive",className:Oe("h-3.5 w-3.5 shrink-0 text-muted-foreground",m?"hidden":"group-hover/gh:hidden")}),s.jsx("span",{className:Oe("text-muted-foreground h-3.5 w-3.5 items-center justify-center",m?"inline-flex":"hidden group-hover/gh:inline-flex"),children:ye?s.jsx(M,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(M,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:wo(n.label,d)}),ke,Ye]}):!n.isMain||n.worktree?s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsx(M,{name:"git-branch",className:Oe("h-3.5 w-3.5 shrink-0",!O&&"text-muted-foreground",m?"hidden":"group-hover/gh:hidden"),style:O?{color:O}:void 0}),s.jsx("span",{className:Oe("text-muted-foreground h-3.5 w-3.5 items-center justify-center",m?"inline-flex":"hidden group-hover/gh:inline-flex"),children:ye?s.jsx(M,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(M,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 truncate typography-ui-label font-semibold text-muted-foreground",children:wo(n.label,d)}),ke,Ye,pe?s.jsxs("span",{className:"ml-auto flex-shrink-0 text-[0.72rem] font-medium leading-none",style:O?{color:O}:void 0,children:["#",pe.number]}):null]}):s.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[s.jsx("span",{className:"min-w-0 truncate",children:wo(n.label,d)}),Ye]})}),it&&at?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[n.isArchivedBucket?s.jsx(M,{name:"archive",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(M,{name:"git-branch",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 truncate text-[11px] font-medium text-muted-foreground/80",children:at.label})]}):null]}),!n.isArchivedBucket&&n.directory?s.jsx(_o,{directory:n.directory,className:"self-center"}):null]}),n.isArchivedBucket&&Ve.length>0?s.jsx("div",{className:Oe("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",m?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Be=>{Be.stopPropagation(),fn.requestDelete({sessions:Ve,mode:"session"})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.sidebar.group.actions.deleteArchivedInGroupAria",{label:n.label}),children:s.jsx(M,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteArchivedSessions")})})]})}):null,n.directory&&!n.isMain&&n.worktree?s.jsx("div",{className:Oe("absolute right-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",m?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Be=>{Be.stopPropagation(),fn.requestDelete({sessions:Ve,mode:"worktree",worktree:n.worktree})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.sidebar.group.actions.deleteGroupAria",{label:n.label}),children:s.jsx(M,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteWorktree")})})]})}):null,n.directory?s.jsx("div",{className:Oe("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",m?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Be=>{Be.stopPropagation(),i&&i!==p&&S(i),y&&g(!1),C({selectedProjectId:i,directoryOverride:n.directory})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.sidebar.group.actions.newDraftInGroupAria",{label:n.label}),children:s.jsx(M,{name:"add",className:"h-4 w-4"})})}),s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.project.actions.newDraftSession")})})]})}):null]}),!ye&&l?s.jsx("div",{className:Oe("oc-group-body",ze),children:qe}):null]}),ft]})}const Hk=c.memo(Uk,Vk),ki=({projectId:t,mobileVariant:e,closeMobileSwitcher:n,setActiveProjectIdOnly:r,setSessionSwitcherOpen:i})=>{t&&r(t),e&&n&&i(!1)},ed=(t,e)=>Ba(t.label?.trim()||Ln(t.normalizedPath,e)||t.normalizedPath);function Gk(t){const e=Ze.c(99),{model:n,view:r,actions:i}=t;Gs("ui.sidebar_projects_list.render");const{t:o}=jt(),l=Yo(),a=Jt(r3),d=Jt(n3),u=Jt(s3),h=Jt(t3),f=Pe(e3),[x,b]=c.useState(null),[w,v]=c.useState(null),[y,m]=c.useState(null),[p,S]=c.useState(null),[g,C]=c.useState(!1),k=c.useRef(null);let j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j={activationConstraint:{distance:8}},e[0]=j):j=e[0];let D;e[1]===Symbol.for("react.memo_cache_sentinel")?(D={activationConstraint:{delay:200,tolerance:6}},e[1]=D):D=e[1];let I;e[2]===Symbol.for("react.memo_cache_sentinel")?(I={coordinateGetter:Gx},e[2]=I):I=e[2];const A=Qo(Dn(Jo,j),Dn(Xo,D),Dn(Ux,I));let P;e[3]===Symbol.for("react.memo_cache_sentinel")?(P=_=>{k.current=_,S(_)},e[3]=P):P=e[3];const T=P;let L;if(e[4]!==n.projectSections||e[5]!==r.homeDirectory){let _;e[7]!==r.homeDirectory?(_=B=>({id:B.project.id,projectLabel:ed(B.project,r.homeDirectory),projectDescription:qr(B.project.normalizedPath,r.homeDirectory),projectIcon:B.project.icon,projectColor:B.project.color,projectIconImage:B.project.iconImage,projectIconBackground:B.project.iconBackground}),e[7]=r.homeDirectory,e[8]=_):_=e[8],L=n.projectSections.map(_),e[4]=n.projectSections,e[5]=r.homeDirectory,e[6]=L}else L=e[6];const $=L;let K;e:{if(!r.stickyZoneHeaders){K=-1;break e}let _;if(e[9]!==n.rowModel.stickyHeaders||e[10]!==w){let B;e[12]!==w?(B=he=>`${he.kind}:${he.id}`===w,e[12]=w,e[13]=B):B=e[13],_=n.rowModel.stickyHeaders.findIndex(B),e[9]=n.rowModel.stickyHeaders,e[10]=w,e[11]=_}else _=e[11];K=_}const F=K;let W;if(e[14]!==y||e[15]!==n.groupProps.editingRowKey||e[16]!==n.rowModel.rowIndexByKey||e[17]!==n.rowModel.rows||e[18]!==n.rowModel.stickyHeaders||e[19]!==n.state.openSidebarMenuKey||e[20]!==F){if(W=new Set,y){let _;e[22]!==y||e[23]!==n.rowModel.rowIndexByKey?(_=n.rowModel.rowIndexByKey.get(y),e[22]=y,e[23]=n.rowModel.rowIndexByKey,e[24]=_):_=e[24];const B=_;B!==void 0&&W.add(B)}for(let _=0;_<n.rowModel.rows.length;_=_+1,_){const B=n.rowModel.rows[_];B?.kind==="session"&&(n.groupProps.editingRowKey===B.key||n.state.openSidebarMenuKey===`session-menu:${B.key}`||n.state.openSidebarMenuKey===`session-context:${B.key}`)&&W.add(_)}if(F>=0){const _=Math.max(0,F-1),B=Math.min(n.rowModel.stickyHeaders.length-1,F+1);for(let he=_;he<=B;he=he+1,he){const ve=n.rowModel.stickyHeaders[he];ve&&W.add(ve.rowIndex)}}e[14]=y,e[15]=n.groupProps.editingRowKey,e[16]=n.rowModel.rowIndexByKey,e[17]=n.rowModel.rows,e[18]=n.rowModel.stickyHeaders,e[19]=n.state.openSidebarMenuKey,e[20]=F,e[21]=W}else W=e[21];const N=W;let R;e[25]!==n.rowModel.stickyHeaders||e[26]!==r.stickyZoneHeaders?(R=_=>{const B=r.stickyZoneHeaders?Nk(n.rowModel.stickyHeaders,_):null,he=B?`${B.kind}:${B.id}`:null;v(ve=>ve===he?ve:he)},e[25]=n.rowModel.stickyHeaders,e[26]=r.stickyZoneHeaders,e[27]=R):R=e[27];const E=R;let X;e[28]!==l||e[29]!==o?(X=_=>{const B=()=>{_.status.directory&&l.requestBootstrap({directory:_.status.directory,priority:"expanded",reason:_.group.isMain?"project-expanded":"worktree-expanded",force:!0})},he=async()=>{if(!_.status.directory)return;(await Fd(_.status.directory)).success&&B()};let ve;e:switch(_.status.state){case"permission-denied":{ve=o("sessions.sidebar.group.empty.permissionDenied");break e}case"load-failed":{ve=o("sessions.sidebar.group.empty.loadFailed");break e}case"initialization-failed":{ve=o("sessions.sidebar.group.empty.initializationFailed");break e}default:ve=o("sessions.sidebar.group.empty.loadingSessions")}return s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[_.status.state==="loading"?s.jsx(M,{name:"loader-4",className:"size-3 animate-spin"}):null,ve,_.status.canGrantAccess?s.jsx(dt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:()=>{he()},children:o("sessions.sidebar.group.empty.grantAccess")}):null,_.status.state!=="loading"?s.jsx(dt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:B,children:o("sessions.sidebar.group.empty.retry")}):null]})})},e[28]=l,e[29]=o,e[30]=X):X=e[30];const J=X;let re;e[31]!==i||e[32]!==u||e[33]!==n.emptyState||e[34]!==n.groupProps||e[35]!==n.projectRepoStatus||e[36]!==n.searchEmptyState||e[37]!==n.singleProjectMode||e[38]!==n.state||e[39]!==$||e[40]!==d||e[41]!==J||e[42]!==f||e[43]!==o||e[44]!==a||e[45]!==r.alwaysShowActions||e[46]!==r.hideDirectoryControls||e[47]!==r.homeDirectory||e[48]!==r.mobileVariant||e[49]!==r.projectSortOrder||e[50]!==r.stickyZoneHeaders?(re=_=>{if(_.kind==="activity-header")return s.jsx(Yf,{className:r.stickyZoneHeaders?"sticky top-0 z-20 bg-sidebar":void 0,"data-sidebar-sticky-header":r.stickyZoneHeaders?"true":void 0,children:s.jsx(vk,{activityKey:_.activityKey,collapsed:_.collapsed,forceExpanded:_.forceExpanded,alwaysShowActions:r.alwaysShowActions,onToggle:()=>n.state.setCollapsedActivityKeys(B=>{const he=new Set(B);return he.has(_.activityKey)?he.delete(_.activityKey):he.add(_.activityKey),he}),onNewChat:()=>{Pe.getState().closeMainSurfaces(),r.mobileVariant&&i.setSessionSwitcherOpen(!1),i.openNewSessionDraft({selectedProjectId:Dg,directoryOverride:null})}})});if(_.kind==="project-header"){const B=_.section.project,he=ed(B,r.homeDirectory);return s.jsx(Rk,{id:B.id,disabled:n.singleProjectMode||_.forceExpanded||n.state.editingId!==null||r.projectSortOrder!=="manual",projectLabel:he,projectDescription:qr(B.normalizedPath,r.homeDirectory),projectDirectory:B.normalizedPath,projectIcon:B.icon,projectColor:B.color,projectIconImage:B.iconImage,projectIconBackground:B.iconBackground,isCollapsed:_.collapsed,isRepo:!!n.projectRepoStatus.get(B.id),hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,statusIndicator:_.collapsed?i.renderProjectStatusIndicator?.(B.id,_.section.groups):null,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,projectPickerOptions:n.singleProjectMode?$:void 0,onProjectSelect:n.singleProjectMode?i.setSingleProjectId:void 0,onToggle:()=>{!_.forceExpanded&&!n.singleProjectMode&&i.toggleProject(B.id)},onNewSession:()=>{ki({projectId:B.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:B.id,directoryOverride:B.normalizedPath})},onNewWorktreeSession:()=>{ki({projectId:B.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!1,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewWorktreeDialog()},onManageWorktrees:()=>i.openWorktreesPage(B.id),onRenameStart:()=>i.openProjectEditDialog(B.id),onClose:()=>i.removeProject(B.id),showCreateButtons:!0})}if(_.kind==="group-header")return s.jsx(Ok,{id:_.groupKey,disabled:_.forceExpanded||n.state.editingId!==null,children:B=>s.jsx(Hk,{...n.groupProps,...i.group,group:_.group,groupKey:_.groupKey,projectId:_.projectId,visibleSessionCount:n.state.visibleSessionCountByGroup.get(_.groupKey),editingId:n.state.editingId,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,dragHandleProps:B,renderBody:!1})});if(_.kind==="folder-header"){const B=n.groupProps.folderRename?.folderId===_.folder.id&&n.groupProps.folderRename.scopeKey===_.scopeKey;return s.jsx(Bf,{folderId:_.folder.id,scopeKey:_.scopeKey,ownerKey:_.ownerKey,disabled:!_.dropEnabled,children:(he,ve)=>s.jsx(aj,{notifyOnSubtasks:n.groupProps.notifyOnSubtasks,activityNodes:_.activityNodes,folder:_.folder,displayName:_.displayName,sessions:_.nodes,isCollapsed:_.collapsed,onToggle:_.forceExpanded?Zk:()=>a(_.folder.id),onRename:Re=>d(_.scopeKey,_.folder.id,Re),onDelete:()=>{_.archived?fn.requestDelete({sessions:[..._.deleteSessions],mode:"session"}):f?b({scopeKey:_.scopeKey,folderId:_.folder.id,folderName:_.folder.name,subFolderCount:_.subFolderCount,sessionCount:_.nodes.length}):u(_.scopeKey,_.folder.id)},renderBody:!1,groupDirectory:_.scopeDirectory??_.group.directory,projectId:_.projectId,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,isRenaming:B,renameDraft:B?n.groupProps.folderRename?.draft:void 0,onRenameDraftChange:n.groupProps.setFolderRenameDraft,onRenameSave:()=>{const Re=n.groupProps.folderRename?.draft.trim();Re&&d(_.scopeKey,_.folder.id,Re),n.groupProps.clearFolderRename()},onRenameCancel:n.groupProps.clearFolderRename,droppableRef:he,isDropTarget:ve,onNewSession:()=>{ki({projectId:_.projectId,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:_.projectId,directoryOverride:_.scopeDirectory??_.group.directory,targetFolderId:_.folder.id,target:_.group.draftTarget})},archivedBucket:_.archived})})}if(_.kind==="session"){const B=new Set;return Fn(_.node,n.state.editingId)&&B.add(_.node.session.id),s.jsx("div",{onFocusCapture:()=>m(_.key),onBlurCapture:()=>m(he=>he===_.key?null:he),children:s.jsx(Wo,{...n.groupProps,node:_.node,depth:_.depth,groupDirectory:_.groupDirectory,projectId:_.projectId,folderOwnerKey:_.ownerKey,selectionScopeKey:_.selectionScopeKey,archivedBucket:_.archived,renderContext:_.renderContext,rowKey:_.key,dragKey:_.key,secondaryMeta:_.secondaryMeta,renderChildren:!1,editingId:n.state.editingId,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,renderExtras:{subtreeContainsEditing:B,menuOpenSessionId:n.state.openSidebarMenuKey===`session-menu:${_.key}`||n.state.openSidebarMenuKey===`session-context:${_.key}`?_.node.session.id:null,nodeStructureKey:Lo(_.node)}})})}return _.kind==="show-control"?s.jsx("button",{type:"button",className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",onClick:()=>{_.containerKey.startsWith("activity:")?n.state.setVisibleActivityCountByKey(B=>{const he=new Map(B);return _.control==="more"?he.set(_.containerKey,_.currentCount+_.increment):he.delete(_.containerKey),he}):_.control==="more"?i.group.showMoreGroupSessions(_.containerKey,_.currentCount,_.increment):i.group.resetGroupSessionLimit(_.containerKey)},children:o(_.control==="more"?"sessions.sidebar.group.showMore":"sessions.sidebar.group.showFewer")}):_.kind==="status"?J(_):_.emptyKind==="sidebar"?n.emptyState:_.emptyKind==="search"?n.searchEmptyState:s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:_.emptyKind==="archived"?o("sessions.sidebar.group.empty.noArchivedSessions"):_.group?.emptyMessage??o("sessions.sidebar.group.empty.noSessionsInWorkspace")})},e[31]=i,e[32]=u,e[33]=n.emptyState,e[34]=n.groupProps,e[35]=n.projectRepoStatus,e[36]=n.searchEmptyState,e[37]=n.singleProjectMode,e[38]=n.state,e[39]=$,e[40]=d,e[41]=J,e[42]=f,e[43]=o,e[44]=a,e[45]=r.alwaysShowActions,e[46]=r.hideDirectoryControls,e[47]=r.homeDirectory,e[48]=r.mobileVariant,e[49]=r.projectSortOrder,e[50]=r.stickyZoneHeaders,e[51]=re):re=e[51];const fe=re;let ne;e[52]!==n.rowModel.rows?(ne=n.rowModel.rows.flatMap(Jk),e[52]=n.rowModel.rows,e[53]=ne):ne=e[53];const te=ne;let ue;e[54]!==n.sectionsForRender?(ue=new Set(n.sectionsForRender.map(Xk)),e[54]=n.sectionsForRender,e[55]=ue):ue=e[55];const Se=ue;let we;e[56]!==n.rowModel.stickyHeaders?(we=n.rowModel.stickyHeaders.map(Qk).join(""),e[56]=n.rowModel.stickyHeaders,e[57]=we):we=e[57];const ye=we;let Ae;e[58]!==Se?(Ae=_=>{C(Se.has(String(_.active.id)))},e[58]=Se,e[59]=Ae):Ae=e[59];let pe;e[60]===Symbol.for("react.memo_cache_sentinel")?(pe=()=>C(!1),e[60]=pe):pe=e[60];let O;e[61]!==i||e[62]!==h||e[63]!==n.rowModel.folderAuthorityByOwner||e[64]!==n.rowModel.folderDropTargets||e[65]!==n.rowModel.rows||e[66]!==n.sectionsForRender||e[67]!==n.state||e[68]!==r.hasSessionSearchQuery||e[69]!==r.projectSortOrder?(O=_=>{if(C(!1),!_.over)return;const B=_.active.data.current,he=_.over.data.current;if(B?.type==="session"&&B.sessionId&&B.ownerKey&&B.archivedBucket!==!0&&he?.type==="folder"&&he.folderId&&he.scopeKey&&he.ownerKey===B.ownerKey){const Ee=n.rowModel.folderDropTargets.find(V=>V.folderId===he.folderId&&V.scopeKey===he.scopeKey&&V.ownerKey===B.ownerKey),xe=n.rowModel.folderAuthorityByOwner.get(B.ownerKey);if(!Ee?.enabled||xe?.complete!==!0)return;const $e=Jt.getState();for(const V of xe.scopeKeys)V!==he.scopeKey&&$e.removeSessionFromFolder(V,B.sessionId);h(he.scopeKey,he.folderId,B.sessionId);return}if(r.hasSessionSearchQuery||n.state.editingId!==null||_.active.id===_.over.id)return;const ve=String(_.active.id),Re=String(_.over.id),ce=n.sectionsForRender.map(Yk),se=ce.indexOf(ve),q=ce.indexOf(Re);if(se>=0&&q>=0&&r.projectSortOrder==="manual"){i.reorderProjects(se,q);return}const z=n.rowModel.rows.find(Ee=>Ee.kind==="group-header"&&Ee.groupKey===ve),ee=n.rowModel.rows.find(Ee=>Ee.kind==="group-header"&&Ee.groupKey===Re);if(!z||!ee||z.projectId!==ee.projectId||!z.projectId)return;const ae=z.projectId,Ne=n.sectionsForRender.find(Ee=>Ee.project.id===ae);if(!Ne)return;const Ce=Ne.groups.findIndex(Ee=>Ee.id===z.group.id),We=Ne.groups.findIndex(Ee=>Ee.id===ee.group.id);Ce<0||We<0||i.setGroupOrderByProject(Ee=>new Map(Ee).set(ae,zu(Ne.groups,Ce,We).map(qk)))},e[61]=i,e[62]=h,e[63]=n.rowModel.folderAuthorityByOwner,e[64]=n.rowModel.folderDropTargets,e[65]=n.rowModel.rows,e[66]=n.sectionsForRender,e[67]=n.state,e[68]=r.hasSessionSearchQuery,e[69]=r.projectSortOrder,e[70]=O):O=e[70];let Q;e[71]!==E||e[72]!==n.rowModel||e[73]!==N||e[74]!==fe||e[75]!==p?(Q=s.jsx(wk,{model:n.rowModel,scrollElement:p,pinnedRowIndexes:N,renderRow:fe,onFirstVisibleIndexChange:E}),e[71]=E,e[72]=n.rowModel,e[73]=N,e[74]=fe,e[75]=p,e[76]=Q):Q=e[76];let le;e[77]!==te||e[78]!==Q?(le=s.jsx(Wa,{items:te,strategy:Wu,children:Q}),e[77]=te,e[78]=Q,e[79]=le):le=e[79];let H;e[80]!==A||e[81]!==Ae||e[82]!==O||e[83]!==le?(H=s.jsx(yn,{ref:T,useScrollShadow:!0,hideTopScrollShadow:!0,scrollShadowSize:96,outerClassName:"flex-1 min-h-0",className:"oc-sidebar-scroller pb-1 pl-2.5 pr-2 [overflow-anchor:none]",children:s.jsx(Zo,{sensors:A,collisionDetection:ei,onDragStart:Ae,onDragCancel:pe,onDragEnd:O,children:le})}),e[80]=A,e[81]=Ae,e[82]=O,e[83]=le,e[84]=H):H=e[84];let me;e[85]!==g||e[86]!==H||e[87]!==r.stickyZoneHeaders||e[88]!==ye?(me=s.jsx(Dk,{enabled:r.stickyZoneHeaders,suspended:g,layoutKey:ye,scrollRef:k,children:H}),e[85]=g,e[86]=H,e[87]=r.stickyZoneHeaders,e[88]=ye,e[89]=me):me=e[89];let ge;e[90]!==u||e[91]!==x?(ge=()=>{x&&(u(x.scopeKey,x.folderId),b(null))},e[90]=u,e[91]=x,e[92]=ge):ge=e[92];let oe;e[93]!==x||e[94]!==ge?(oe=s.jsx(Gf,{value:x,setValue:b,onConfirm:ge}),e[93]=x,e[94]=ge,e[95]=oe):oe=e[95];let de;return e[96]!==me||e[97]!==oe?(de=s.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[me,oe]}),e[96]=me,e[97]=oe,e[98]=de):de=e[98],de}function qk(t){return t.id}function Yk(t){return t.project.id}function Qk(t){const{kind:e,id:n,rowIndex:r}=t;return`${e}:${n}:${r}`}function Xk(t){return t.project.id}function Jk(t){return t.kind==="project-header"?[t.section.project.id]:t.kind==="group-header"?[t.groupKey]:[]}function Zk(){}function e3(t){return t.showDeletionDialog}function t3(t){return t.addSessionToFolder}function s3(t){return t.deleteFolder}function n3(t){return t.renameFolder}function r3(t){return t.toggleFolderCollapse}const o3=c.memo(Gk),ha=new Map,td=(t,e)=>{for(const n of t){const r=ht(n??null);r&&!ha.has(r)&&ha.set(r,e)}},sd=t=>{const e=ht(t??null);return e?ha.get(e)??0:0},Rr=t=>!!t.time?.archived,i3=t=>{const{t:e}=jt(),n=c.useRef(t.gitBranches);n.current=t.gitBranches;const r=c.useCallback(a=>[a.label,a.branch??"",a.description??"",a.directory??""].join(" ").toLowerCase(),[]),i=c.useCallback(a=>{const d=ht(a.directory??null)??"";return`${(a.title||e("sessions.sidebar.session.untitled")).trim()} ${d}`.toLowerCase()},[e]),o=c.useCallback((a,d)=>{if(!d)return a;const u=d.trim().toLowerCase(),h=u.startsWith("ses_");return a.flatMap(f=>{if(h&&Rr(f.session))return[];if(h?f.session.id.toLowerCase()===u:Io([i(f.session)],d))return[f];const b=o(f.children,d);return b.length===0?[]:[{...f,children:b}]})},[i]),l=c.useCallback((a,d,u,h,f)=>{const x=ht(d??null),b=Au(a),w=new Map(b.map(F=>[F.id,F])),v=new Map;b.forEach(F=>{const W=F.parentID;if(!W)return;const N=w.get(W);if(!N||Rr(N)!==Rr(F))return;const R=v.get(W)??[];R.push(F),v.set(W,R)});const y=new Map;u.forEach(F=>{if(F.path){const W=ht(F.path)??F.path;y.set(W,F)}});const m=F=>{const W=ht(F.directory??null),N=t.worktreeMetadata.get(F.id)??null;if(N)return N;if(W){const R=y.get(W)??null;if(R&&W!==x)return R}return null},p=new Set,S=F=>{p.add(F.id);const W=v.get(F.id)??[],N=[];for(const R of W)p.has(R.id)||N.push(S(R));return{session:F,children:N,worktree:m(F)}},g=b.filter(F=>{const W=F.parentID;if(!W)return!0;const N=w.get(W);return N?Rr(N)!==Rr(F):!0}),C=[],k=F=>{p.has(F.id)||C.push(S(F))};g.forEach(k),b.forEach(k);const j=new Map,D="__archived__",I=F=>{if(F.time?.archived)return D;if(t.isVSCode)return x??"__project_root__";const N=ht(t.worktreeMetadata.get(F.id)?.path??null)??Ds(F);return N?N!==x&&y.has(N)?N:N===x?x??"__project_root__":D:D};C.forEach(F=>{const W=I(F.session);j.has(W)||j.set(W,[]),j.get(W)?.push(F)});const A=x??"__project_root__",P=[{id:"root",label:f&&h&&h!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:h}):e("sessions.sidebar.grouping.projectRoot"),branch:h??null,description:x?qr(x,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:x,folderScopeKey:x,sessions:j.get(A)??[]}],T=new Map;u.forEach(F=>{const W=ht(F.path)??F.path,N=j.get(W)??[],R=N.length>0,E=N.reduce((X,J)=>{const re=Pg(J.session,t.sessionOrderRanks);return Number.isFinite(re)?Math.max(X,re):X},0);T.set(W,{hasActiveSession:R,lastUpdatedAt:E})});const L=[...u].sort((F,W)=>{const N=ht(F.path)??F.path,R=ht(W.path)??W.path,E=T.get(N)??{hasActiveSession:!1,lastUpdatedAt:0},X=T.get(R)??{hasActiveSession:!1,lastUpdatedAt:0};if(E.hasActiveSession!==X.hasActiveSession)return E.hasActiveSession?-1:1;if(E.hasActiveSession&&X.hasActiveSession)return X.lastUpdatedAt-E.lastUpdatedAt;const J=sd(F.path),re=sd(W.path);if(J!==re)return re-J;const fe=(F.label||F.branch||F.name||F.path||"").toLowerCase(),ne=(W.label||W.branch||W.name||W.path||"").toLowerCase();return fe.localeCompare(ne)});(t.isVSCode?[]:L).forEach(F=>{const W=ht(F.path)??F.path,N=n.current.get(W)?.trim()||null,R=F.branch?.trim()||null,X=!!(N&&R&&F.label&&El(F.label)===El(R))?N:F.label||F.name||Ln(W,t.homeDirectory)||W;P.push({id:`worktree:${W}`,label:X,branch:N||R,description:qr(W,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:F,directory:W,folderScopeKey:W,sessions:j.get(W)??[]})});const K=j.get(D)??[];return K.length>0&&P.push({id:"archived",label:e("sessions.sidebar.grouping.archived"),branch:null,description:e("sessions.sidebar.grouping.archivedDescription"),isMain:!1,isArchivedBucket:!0,worktree:null,directory:null,folderScopeKey:!t.isVSCode&&x?Nu(x):null,sessions:K}),P},[t.homeDirectory,t.worktreeMetadata,t.sessionOrderRanks,t.isVSCode,e]);return{buildGroupSearchText:r,buildSessionSearchText:i,filterSessionNodesForSearch:o,buildGroupedSessions:l}},a3=t=>{const e=Ze.c(51),{selectedCount:n,scopeKey:r,scopeFolders:i,archivedBucket:o,onMoveToFolder:l,onCreateFolderAndMove:a,onRemoveFromFolder:d,canRemoveFromFolder:u,onRestore:h,onDelete:f,onDone:x}=t,{t:b}=jt(),w=!!r&&!o;let v;e[0]!==o||e[1]!==b?(v=b(o?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[0]=o,e[1]=b,e[2]=v):v=e[2];const y=v;let m;e[3]!==n||e[4]!==b?(m=b("sessions.sidebar.bulkActions.selectedCount",{count:n}),e[3]=n,e[4]=b,e[5]=m):m=e[5];let p;e[6]!==m?(p=s.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:m}),e[6]=m,e[7]=p):p=e[7];let S;e[8]!==w||e[9]!==u||e[10]!==a||e[11]!==l||e[12]!==d||e[13]!==i||e[14]!==b?(S=w?s.jsxs(Ks,{children:[s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx(zs,{asChild:!0,children:s.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":b("sessions.sidebar.bulkActions.moveToFolder"),children:s.jsx(M,{name:"folder",className:"h-4 w-4"})})})}),s.jsx(Dt,{side:"top",sideOffset:4,children:s.jsx("p",{children:b("sessions.sidebar.bulkActions.moveToFolder")})})]}),s.jsxs(Ws,{align:"end",className:"min-w-[180px]",children:[i.length===0?s.jsx(Kt,{disabled:!0,className:"text-muted-foreground",children:b("sessions.sidebar.folders.none")}):i.map(N=>s.jsx(Kt,{onClick:()=>l(N.id),children:s.jsx("span",{className:"flex-1 truncate",children:N.name})},N.id)),s.jsx(Os,{}),s.jsxs(Kt,{onClick:a,children:[s.jsx(M,{name:"add",className:"mr-1 h-4 w-4"}),b("sessions.sidebar.folders.newFolderEllipsis")]}),u?s.jsxs(Kt,{onClick:d,className:"text-destructive focus:text-destructive",children:[s.jsx(M,{name:"close",className:"mr-1 h-4 w-4"}),b("sessions.sidebar.folders.removeFromFolder")]}):null]})]}):null,e[8]=w,e[9]=u,e[10]=a,e[11]=l,e[12]=d,e[13]=i,e[14]=b,e[15]=S):S=e[15];let g;e[16]!==o||e[17]!==h||e[18]!==b?(g=o?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:h,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":b("sessions.sidebar.bulkActions.restore"),children:s.jsx(M,{name:"inbox-unarchive",className:"h-4 w-4"})})}),s.jsx(Dt,{side:"top",sideOffset:4,children:s.jsx("p",{children:b("sessions.sidebar.bulkActions.restore")})})]}):null,e[16]=o,e[17]=h,e[18]=b,e[19]=g):g=e[19];let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=Oe("inline-flex h-7 w-7 items-center justify-center rounded-md text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50"),e[20]=C):C=e[20];let k;e[21]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(M,{name:"delete-bin",className:"h-4 w-4"}),e[21]=k):k=e[21];let j;e[22]!==y||e[23]!==f?(j=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,className:C,"aria-label":y,children:k})}),e[22]=y,e[23]=f,e[24]=j):j=e[24];let D;e[25]!==y?(D=s.jsx(Dt,{side:"top",sideOffset:4,children:s.jsx("p",{children:y})}),e[25]=y,e[26]=D):D=e[26];let I;e[27]!==j||e[28]!==D?(I=s.jsxs(Nt,{children:[j,D]}),e[27]=j,e[28]=D,e[29]=I):I=e[29];let A;e[30]!==b?(A=b("sessions.sidebar.header.actions.exitSelection"),e[30]=b,e[31]=A):A=e[31];let P;e[32]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx(M,{name:"close",className:"h-4 w-4"}),e[32]=P):P=e[32];let T;e[33]!==x||e[34]!==A?(T=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:x,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":A,children:P})}),e[33]=x,e[34]=A,e[35]=T):T=e[35];let L;e[36]!==b?(L=b("sessions.sidebar.header.actions.exitSelection"),e[36]=b,e[37]=L):L=e[37];let $;e[38]!==L?($=s.jsx(Dt,{side:"top",sideOffset:4,children:s.jsx("p",{children:L})}),e[38]=L,e[39]=$):$=e[39];let K;e[40]!==T||e[41]!==$?(K=s.jsxs(Nt,{children:[T,$]}),e[40]=T,e[41]=$,e[42]=K):K=e[42];let F;e[43]!==I||e[44]!==K||e[45]!==S||e[46]!==g?(F=s.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[S,g,I,K]}),e[43]=I,e[44]=K,e[45]=S,e[46]=g,e[47]=F):F=e[47];let W;return e[48]!==F||e[49]!==p?(W=s.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-t border-border px-2.5 py-1.5",children:[p,F]}),e[48]=F,e[49]=p,e[50]=W):W=e[50],W},nd=new Map,l3=(t,e)=>{if(!t)return[];const n=e(t);return n.length>0?n.map(r=>r.scopeKey):[t]},c3=(t,e)=>{const n=t.sessionIds.filter(o=>e.has(o));if(n.length===0)return{ready:!1,value:null};const r=Lf(new Set(n),e),i={sessionIds:n,sessionCount:n.length,archivedBucket:r};return{ready:n.length===t.sessionIds.length&&r===t.archivedBucket,value:i}},d3=t=>{const e=Ze.c(77),{t:n}=jt(),{isInlineEditing:r,showDeletionDialog:i,foldersMap:o,getFolderScopesForProject:l,addSessionsToFolder:a,removeSessionsFromFolders:d,createFolderAndStartRename:u,archiveSessions:h,unarchiveSessions:f,deleteSessions:x,bulkDeleteConfirm:b,setBulkDeleteConfirm:w}=t,v=fs(u3),y=fs(f3),m=y>0,p=fs(m3),S=fs(h3),g=_f(),C=p3,k=g3;let j;e[0]!==m||e[1]!==g||e[2]!==p?(j=m&&Lf(p,g?.getSessionsById()??nd),e[0]=m,e[1]=g,e[2]=p,e[3]=j):j=e[3];const D=j;let I;e:{if(S){I=S;break e}I=null}const A=I;let P;e[4]!==A||e[5]!==l?(P=l3(A,l),e[4]=A,e[5]=l,e[6]=P):P=e[6];const T=P;let L;if(e[7]!==o||e[8]!==T){let ge;e[10]!==o?(ge=oe=>o[oe]??[],e[10]=o,e[11]=ge):ge=e[11],L=T.flatMap(ge),e[7]=o,e[8]=T,e[9]=L}else L=e[9];const $=L;let K;e[12]!==o||e[13]!==T?(K=ge=>{for(const oe of T)if((o[oe]??[]).some(de=>de.id===ge))return oe;return null},e[12]=o,e[13]=T,e[14]=K):K=e[14];const F=K;let W;e:{if(!m){W=!1;break e}for(const ge of T)for(const oe of o[ge]??[])for(const de of oe.sessionIds)if(p.has(de)){W=!0;break e}W=!1}const N=W;let R;e[15]!==a||e[16]!==d||e[17]!==p||e[18]!==T?(R=(ge,oe)=>{const de=Array.from(p);for(const _ of T)_!==ge&&d(_,de);a(ge,oe,de)},e[15]=a,e[16]=d,e[17]=p,e[18]=T,e[19]=R):R=e[19];const E=R;let X;e[20]!==m||e[21]!==E||e[22]!==F?(X=ge=>{if(!m)return;const oe=F(ge);oe&&E(oe,ge)},e[20]=m,e[21]=E,e[22]=F,e[23]=X):X=e[23];const J=X;let re;e[24]!==u||e[25]!==m||e[26]!==E||e[27]!==T?(re=()=>{const ge=T[0];if(!ge||!m)return;const oe=u(ge);oe&&E(ge,oe.id)},e[24]=u,e[25]=m,e[26]=E,e[27]=T,e[28]=re):re=e[28];const fe=re;let ne;e[29]!==m||e[30]!==d||e[31]!==p||e[32]!==T?(ne=()=>{if(!m)return;const ge=Array.from(p);for(const oe of T)d(oe,ge)},e[29]=m,e[30]=d,e[31]=p,e[32]=T,e[33]=ne):ne=e[33];const te=ne;let ue;e[34]!==h||e[35]!==x||e[36]!==n?(ue=async(ge,oe)=>{if(ge.length!==0)if(oe){const{deletedIds:de,failedIds:_}=await x(ge);de.length>0&&Le.success(de.length===1?n("sessions.sidebar.bulkActions.deletedSingle",{count:de.length}):n("sessions.sidebar.bulkActions.deletedPlural",{count:de.length})),_.length>0&&Le.error(_.length===1?n("sessions.sidebar.bulkActions.failedDeleteSingle",{count:_.length}):n("sessions.sidebar.bulkActions.failedDeletePlural",{count:_.length})),fs.getState().removeMany(de)}else{const{archivedIds:de,failedIds:_}=await h(ge);de.length>0&&Le.success(de.length===1?n("sessions.sidebar.bulkActions.archivedSingle",{count:de.length}):n("sessions.sidebar.bulkActions.archivedPlural",{count:de.length})),_.length>0&&Le.error(_.length===1?n("sessions.sidebar.bulkActions.failedArchiveSingle",{count:_.length}):n("sessions.sidebar.bulkActions.failedArchivePlural",{count:_.length})),fs.getState().removeMany(de)}},e[34]=h,e[35]=x,e[36]=n,e[37]=ue):ue=e[37];const Se=ue;let we;e[38]!==D||e[39]!==Se||e[40]!==m||e[41]!==p||e[42]!==w||e[43]!==i?(we=()=>{if(!m)return;const ge=Array.from(p);if(!i){Se(ge,D);return}w({sessionIds:ge,sessionCount:ge.length,archivedBucket:D})},e[38]=D,e[39]=Se,e[40]=m,e[41]=p,e[42]=w,e[43]=i,e[44]=we):we=e[44];const ye=we;let Ae;e[45]!==D||e[46]!==m||e[47]!==p||e[48]!==n||e[49]!==f?(Ae=async()=>{if(!m||!D)return;const ge=Array.from(p),{restoredIds:oe,failedIds:de}=await f(ge);oe.length>0&&Le.success(oe.length===1?n("sessions.sidebar.bulkActions.restoredSingle",{count:oe.length}):n("sessions.sidebar.bulkActions.restoredPlural",{count:oe.length})),de.length>0&&Le.error(de.length===1?n("sessions.sidebar.bulkActions.failedRestoreSingle",{count:de.length}):n("sessions.sidebar.bulkActions.failedRestorePlural",{count:de.length})),fs.getState().removeMany(oe)},e[45]=D,e[46]=m,e[47]=p,e[48]=n,e[49]=f,e[50]=Ae):Ae=e[50];const pe=Ae;let O;e[51]!==b||e[52]!==Se||e[53]!==g||e[54]!==w?(O=async()=>{if(!b)return;const ge=g?.getSessionsById()??nd,oe=c3(b,ge);if(!oe.ready){w(oe.value);return}w(null),await Se(oe.value.sessionIds,oe.value.archivedBucket)},e[51]=b,e[52]=Se,e[53]=g,e[54]=w,e[55]=O):O=e[55];const Q=O;let le,H;e[56]!==b||e[57]!==ye||e[58]!==r||e[59]!==g||e[60]!==v?(le=()=>{if(!v)return;const ge=/Macintosh|Mac OS X/.test(navigator.userAgent||""),oe=de=>{if(b||r)return;const _=de.target instanceof HTMLElement?de.target:null;if(_&&(_.tagName==="INPUT"||_.tagName==="TEXTAREA"||_.isContentEditable))return;const B=ge?de.metaKey:de.ctrlKey;if(de.key==="Escape"){de.preventDefault(),fs.getState().disable();return}if(B&&de.key==="Backspace"){de.preventDefault(),ye();return}if(B&&(de.key==="a"||de.key==="A")){const he=uj(g?.getEntries()??[],g?.getDescendantIds()??[],fs.getState().scopeKey);if(!he)return;de.preventDefault(),fs.getState().replaceAll(he.ids,he.scopeKey)}};return window.addEventListener("keydown",oe),()=>window.removeEventListener("keydown",oe)},H=[b,ye,r,g,v],e[56]=b,e[57]=ye,e[58]=r,e[59]=g,e[60]=v,e[61]=le,e[62]=H):(le=e[61],H=e[62]),c.useEffect(le,H);let me;return e[63]!==N||e[64]!==$||e[65]!==D||e[66]!==Q||e[67]!==A||e[68]!==fe||e[69]!==ye||e[70]!==J||e[71]!==te||e[72]!==pe||e[73]!==m||e[74]!==y||e[75]!==v?(me={selectionModeEnabled:v,hasSelection:m,selectedIdsSize:y,bulkScopeIsArchived:D,derivedSelectionScope:A,bulkScopeFolders:$,bulkCanRemoveFromFolder:N,handleToggleSelectionMode:C,handleExitSelectionMode:k,handleBulkMoveToFolder:J,handleBulkCreateFolderAndMove:fe,handleBulkRemoveFromFolder:te,handleBulkDelete:ye,handleBulkRestore:pe,confirmBulkDelete:Q},e[63]=N,e[64]=$,e[65]=D,e[66]=Q,e[67]=A,e[68]=fe,e[69]=ye,e[70]=J,e[71]=te,e[72]=pe,e[73]=m,e[74]=y,e[75]=v,e[76]=me):me=e[76],me};function u3(t){return t.enabled}function f3(t){return t.selectedIds.size}function m3(t){return t.selectedIds}function h3(t){return t.scopeKey}function p3(){fs.getState().toggleMode()}function g3(){fs.getState().disable()}function x3(t){const e=Ze.c(37),{getFolderScopesForProject:n,isInlineEditing:r,startFolderRename:i}=t,[o,l]=c.useState(null),a=Pe(N3),d=Pe(C3),u=Jt(k3),h=Jt(j3),f=Jt(S3),x=Jt(v3),b=tt(w3),w=tt(y3),v=tt(b3);let y;e[0]!==h||e[1]!==i?(y=k=>{const j=h(k,"New folder");return i(k,j),j},e[0]=h,e[1]=i,e[2]=y):y=e[2];let m;e[3]!==f||e[4]!==b||e[5]!==o||e[6]!==v||e[7]!==u||e[8]!==n||e[9]!==r||e[10]!==x||e[11]!==a||e[12]!==y||e[13]!==w?(m={isInlineEditing:r,showDeletionDialog:a,foldersMap:u,getFolderScopesForProject:n,addSessionsToFolder:f,removeSessionsFromFolders:x,createFolderAndStartRename:y,archiveSessions:b,unarchiveSessions:w,deleteSessions:v,bulkDeleteConfirm:o,setBulkDeleteConfirm:l},e[3]=f,e[4]=b,e[5]=o,e[6]=v,e[7]=u,e[8]=n,e[9]=r,e[10]=x,e[11]=a,e[12]=y,e[13]=w,e[14]=m):m=e[14];const p=d3(m);let S;e[15]!==p.bulkCanRemoveFromFolder||e[16]!==p.bulkScopeFolders||e[17]!==p.bulkScopeIsArchived||e[18]!==p.derivedSelectionScope||e[19]!==p.handleBulkCreateFolderAndMove||e[20]!==p.handleBulkDelete||e[21]!==p.handleBulkMoveToFolder||e[22]!==p.handleBulkRemoveFromFolder||e[23]!==p.handleBulkRestore||e[24]!==p.handleExitSelectionMode||e[25]!==p.hasSelection||e[26]!==p.selectedIdsSize||e[27]!==p.selectionModeEnabled?(S=p.selectionModeEnabled&&p.hasSelection?s.jsx(a3,{selectedCount:p.selectedIdsSize,scopeKey:p.derivedSelectionScope,scopeFolders:p.bulkScopeFolders,archivedBucket:p.bulkScopeIsArchived,onMoveToFolder:p.handleBulkMoveToFolder,onCreateFolderAndMove:p.handleBulkCreateFolderAndMove,onRemoveFromFolder:p.handleBulkRemoveFromFolder,canRemoveFromFolder:p.bulkCanRemoveFromFolder,onRestore:p.handleBulkRestore,onDelete:p.handleBulkDelete,onDone:p.handleExitSelectionMode}):null,e[15]=p.bulkCanRemoveFromFolder,e[16]=p.bulkScopeFolders,e[17]=p.bulkScopeIsArchived,e[18]=p.derivedSelectionScope,e[19]=p.handleBulkCreateFolderAndMove,e[20]=p.handleBulkDelete,e[21]=p.handleBulkMoveToFolder,e[22]=p.handleBulkRemoveFromFolder,e[23]=p.handleBulkRestore,e[24]=p.handleExitSelectionMode,e[25]=p.hasSelection,e[26]=p.selectedIdsSize,e[27]=p.selectionModeEnabled,e[28]=S):S=e[28];let g;e[29]!==p.confirmBulkDelete||e[30]!==o||e[31]!==d||e[32]!==a?(g=s.jsx(dk,{value:o,setValue:l,showDeletionDialog:a,setShowDeletionDialog:d,onConfirm:p.confirmBulkDelete}),e[29]=p.confirmBulkDelete,e[30]=o,e[31]=d,e[32]=a,e[33]=g):g=e[33];let C;return e[34]!==S||e[35]!==g?(C=s.jsxs(s.Fragment,{children:[S,g]}),e[34]=S,e[35]=g,e[36]=C):C=e[36],C}function b3(t){return t.deleteSessions}function y3(t){return t.unarchiveSessions}function w3(t){return t.archiveSessions}function v3(t){return t.removeSessionsFromFolders}function S3(t){return t.addSessionsToFolder}function j3(t){return t.createFolder}function k3(t){return t.foldersMap}function C3(t){return t.setShowDeletionDialog}function N3(t){return t.showDeletionDialog}const Qf="oc.sessions.expandedParents.v3",A3=Ka(jr()),D3=()=>{try{const t=globalThis.localStorage.getItem(Qf);if(t===null)return new Set;const e=A3.safeParse(JSON.parse(t));return e.success?new Set(e.data):new Set}catch{return new Set}},P3=()=>{const[t,e]=c.useState(D3),n=c.useRef(t);n.current=t;const r=c.useCallback(i=>{const o=Ig(n.current,i);n.current=o,e(o);try{globalThis.localStorage.setItem(Qf,JSON.stringify([...o]))}catch{}},[]);return{expandedParents:t,toggleParent:r}},I3=t=>{const e=Ze.c(20),{childStores:n,sections:r,chatGroup:i,canGrantAccess:o}=t;let l;e[0]!==i||e[1]!==r?(l=[...r.flatMap(T3),...i?[{key:"activity:chats",group:i}]:[]].map(M3),e[0]=i,e[1]=r,e[2]=l):l=e[2];const a=l;let d;e[3]!==a?(d=new Set(a.flatMap(O3)),e[3]=a,e[4]=d):d=e[4];let u;e[5]!==d?(u=[...d],e[5]=d,e[6]=u):u=e[6];const h=u;let f;e[7]!==n||e[8]!==h.length?(f=m=>h.length>0?n.subscribeBootstrap(m):B3,e[7]=n,e[8]=h.length,e[9]=f):f=e[9];let x;e[10]!==n||e[11]!==h?(x=()=>h.map(m=>`${m}\0${n.getBootstrapState(m)??""}\0${n.getBootstrapFailure(m)??""}\0${n.getInitializationState(m)??""}\0${n.getInitializationFailure(m)??""}`).join(""),e[10]=n,e[11]=h,e[12]=x):x=e[12];const b=c.useSyncExternalStore(f,x,F3);let w;if(e[13]!==o||e[14]!==n||e[15]!==a){w=new Map;for(const{key:m,directories:p}of a){const S=p.find(g=>n.getBootstrapState(g)==="failed"||n.getInitializationState(g)==="failed");if(S){const g=n.getBootstrapState(S)==="failed",C=g?n.getBootstrapFailure(S):n.getInitializationFailure(S);w.set(m,{state:C==="os-permission"?"permission-denied":g?"load-failed":"initialization-failed",directory:S,canGrantAccess:C==="os-permission"&&o})}else{const g=p.some(C=>{const k=n.getBootstrapState(C);return k==="queued"||k==="running"});w.set(m,{state:g?"loading":"ready",directory:p[0]??null,canGrantAccess:!1})}}e[13]=o,e[14]=n,e[15]=a,e[16]=w}else w=e[16];const v=w;let y;return e[17]!==b||e[18]!==v?(y={groupStatusByKey:v,bootstrapSnapshot:b},e[17]=b,e[18]=v,e[19]=y):y=e[19],y};function T3(t){return t.groups.map(e=>({key:`${t.project.id}:${e.id}`,group:e}))}function E3(t){return ht(t.directory)}function R3(t){return!!t}function M3(t){const{key:e,group:n}=t;return{key:e,directories:Yr(n).map(E3).filter(R3)}}function O3(t){return t.directories}function B3(){}function F3(){return""}const _3=5*6e4,L3=[],$3=t=>!t.parentID,z3=t=>{const e=Ze.c(289),{topology:n,view:r,actions:i}=t;let o,l,a,d,u;e[0]!==i?({alwaysShowActions:o,notifyOnSubtasks:l,projectViewActions:a,rowActions:d,...u}=i,e[0]=i,e[1]=o,e[2]=l,e[3]=a,e[4]=d,e[5]=u):(o=e[1],l=e[2],a=e[3],d=e[4],u=e[5]);const h=Jt(K3),f=Jt(V3),x=Jt(U3),b=Jt(H3),w=r.projectView,{getOrderedGroups:v,setGroupOrderByProject:y,toggleGroup:m,toggleProject:p}=a;let S;e[6]!==n.isVSCode||e[7]!==n.knownDirectories?(S={knownDirectories:n.knownDirectories,isVSCode:n.isVSCode,isVisible:!0},e[6]=n.isVSCode,e[7]=n.knownDirectories,e[8]=S):S=e[8];const g=Mh(S);let C;e[9]===Symbol.for("react.memo_cache_sentinel")?(C=new Map,e[9]=C):C=e[9];const[k,j]=c.useState(C);let D;e[10]===Symbol.for("react.memo_cache_sentinel")?(D=new Set,e[10]=D):D=e[10];const[I,A]=c.useState(D);let P;e[11]===Symbol.for("react.memo_cache_sentinel")?(P=new Map,e[11]=P):P=e[11];const[T,L]=c.useState(P);let $;e[12]===Symbol.for("react.memo_cache_sentinel")?($=(st,gt,U)=>{const Te=U===void 0?7:U;j(ot=>new Map(ot).set(st,gt+Te))},e[12]=$):$=e[12];const K=$;let F;e[13]===Symbol.for("react.memo_cache_sentinel")?(F=st=>{j(gt=>{if(!gt.has(st))return gt;const U=new Map(gt);return U.delete(st),U})},e[13]=F):F=e[13];const W=F,N=us(G3),R=us(q3),E=us(Y3),X=us(Q3);let J;e[14]!==n.isVSCode?(J=!n.isVSCode&&!Zm(),e[14]=n.isVSCode,e[15]=J):J=e[15];const fe=J&&R==="single",ne=N&&!fe;let te;e[16]!==g.pinnedSessionIds||e[17]!==g.rootSessions||e[18]!==g.sessionOrderRanks||e[19]!==ne||e[20]!==n.isVSCode?(te={enabled:ne,isVSCode:n.isVSCode,pinnedSessionIds:g.pinnedSessionIds,sessionOrderRanks:g.sessionOrderRanks,sessions:g.rootSessions},e[16]=g.pinnedSessionIds,e[17]=g.rootSessions,e[18]=g.sessionOrderRanks,e[19]=ne,e[20]=n.isVSCode,e[21]=te):te=e[21];const ue=Oh(te),[Se,we]=c.useState(null),[ye,Ae]=c.useState(null),[pe,O]=c.useState(""),[Q,le]=c.useState(null),[H,me]=c.useState(null),[ge,oe]=c.useState(null),[de,_]=c.useState(null);let B;e[22]===Symbol.for("react.memo_cache_sentinel")?(B=(st,gt)=>{_({scopeKey:st,folderId:gt.id,draft:gt.name})},e[22]=B):B=e[22];const he=B;let ve;e[23]===Symbol.for("react.memo_cache_sentinel")?(ve=st=>{_(gt=>gt?{...gt,draft:st}:null)},e[23]=ve):ve=e[23];const Re=ve;let ce;e[24]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>_(null),e[24]=ce):ce=e[24];const se=ce,{expandedParents:q,toggleParent:z}=P3(),ee=tt(X3);let ae;e[25]!==ee?(ae=(st,gt)=>{st!==tt.getState().currentSessionId&&ee(st,gt)},e[25]=ee,e[26]=ae):ae=e[26];const Ne=ae,Ce=Tu();let We;e[27]!==g.pinnedSessionIds||e[28]!==g.sessionOrderRanks||e[29]!==n.gitBranches||e[30]!==n.isVSCode||e[31]!==n.worktreeMetadata||e[32]!==r.homeDirectory?(We={homeDirectory:r.homeDirectory,worktreeMetadata:n.worktreeMetadata,pinnedSessionIds:g.pinnedSessionIds,sessionOrderRanks:g.sessionOrderRanks,gitBranches:n.gitBranches,isVSCode:n.isVSCode},e[27]=g.pinnedSessionIds,e[28]=g.sessionOrderRanks,e[29]=n.gitBranches,e[30]=n.isVSCode,e[31]=n.worktreeMetadata,e[32]=r.homeDirectory,e[33]=We):We=e[33];const{buildGroupedSessions:Ee,filterSessionNodesForSearch:xe,buildGroupSearchText:$e}=i3(We);let V;e[34]!==g.archivedSessions||e[35]!==g.sessions||e[36]!==n.availableWorktreesByProject||e[37]!==n.isVSCode||e[38]!==n.projects?(V=B2(g.sessions,n.projects,n.availableWorktreesByProject,n.isVSCode,g.archivedSessions),e[34]=g.archivedSessions,e[35]=g.sessions,e[36]=n.availableWorktreesByProject,e[37]=n.isVSCode,e[38]=n.projects,e[39]=V):V=e[39];const De=V;let Fe;e[40]!==De?(Fe={ownership:De},e[40]=De,e[41]=Fe):Fe=e[41];const{getSessionsForProject:_e,getArchivedSessionsForProject:rt}=F2(Fe);let ct;e:{if(n.isVSCode){ct=null;break e}let st;e[42]!==g.chatSessions||e[43]!==r.homeDirectory?(st=Tg(r.homeDirectory)??g.chatSessions.map(J3).find(Boolean)??null,e[42]=g.chatSessions,e[43]=r.homeDirectory,e[44]=st):st=e[44];const gt=st;if(!gt){ct=null;break e}let U;if(e[45]!==gt||e[46]!==g.chatSessions){const Mt=[gt,...g.chatSessions.map(Z3).filter(Boolean)];let $t;e[48]!==Mt?($t=new Set(Mt),e[48]=Mt,e[49]=$t):$t=e[49],U=Array.from($t).filter(e4).map(t4),e[45]=gt,e[46]=g.chatSessions,e[47]=U}else U=e[47];const Te=U;let ot;if(e[50]!==g.chatSessions||e[51]!==g.childrenMap){let Mt;e[53]!==g.childrenMap?(Mt=$t=>yl(g.childrenMap,$t),e[53]=g.childrenMap,e[54]=Mt):Mt=e[54],ot=g.chatSessions.filter(s4).map(Mt),e[50]=g.chatSessions,e[51]=g.childrenMap,e[52]=ot}else ot=e[52];let Et;e[55]!==gt||e[56]!==Te||e[57]!==ot?(Et={id:"managed-chats",label:"",branch:null,description:null,isMain:!0,worktree:null,directory:gt,folderScopeKey:gt,folderScopes:Te,draftTarget:"chat",sessions:ot},e[55]=gt,e[56]=Te,e[57]=ot,e[58]=Et):Et=e[58],ct=Et}const et=ct;let pt;e[59]!==et?(pt=et?[et]:L3,e[59]=et,e[60]=pt):pt=e[60];const kt=pt;let wt;e[61]!==$e||e[62]!==Ee||e[63]!==xe||e[64]!==h||e[65]!==rt||e[66]!==_e||e[67]!==kt||e[68]!==n.availableWorktreesByProject||e[69]!==n.gitBranches||e[70]!==n.lastRepoStatus||e[71]!==n.projectRepoStatus||e[72]!==n.projectRootBranches||e[73]!==n.projects||e[74]!==r.hasSessionSearchQuery||e[75]!==r.normalizedSessionSearchQuery?(wt={normalizedProjects:n.projects,getSessionsForProject:_e,getArchivedSessionsForProject:rt,availableWorktreesByProject:n.availableWorktreesByProject,projectRepoStatus:n.projectRepoStatus,projectRootBranches:n.projectRootBranches,gitBranches:n.gitBranches,lastRepoStatus:n.lastRepoStatus,buildGroupedSessions:Ee,hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,filterSessionNodesForSearch:xe,buildGroupSearchText:$e,foldersMap:h,standaloneGroups:kt},e[61]=$e,e[62]=Ee,e[63]=xe,e[64]=h,e[65]=rt,e[66]=_e,e[67]=kt,e[68]=n.availableWorktreesByProject,e[69]=n.gitBranches,e[70]=n.lastRepoStatus,e[71]=n.projectRepoStatus,e[72]=n.projectRootBranches,e[73]=n.projects,e[74]=r.hasSessionSearchQuery,e[75]=r.normalizedSessionSearchQuery,e[76]=wt):wt=e[76];const{projectSections:Xe,groupSearchDataByGroup:yt,sectionsForRender:Rt,flatSectionsForRender:be}=$2(wt),Ge=r.onSearchMatchCountChange;let ut,Y;e[77]!==Ge?(ut=()=>()=>Ge(0),Y=[Ge],e[77]=Ge,e[78]=ut,e[79]=Y):(ut=e[78],Y=e[79]),c.useEffect(ut,Y);const G=Yo(),Z=r.useGroupedSections?Rt:be;let je;e[80]!==Z||e[81]!==r.showInlineArchived?(je=r.showInlineArchived?Z:Z.map(o4),e[80]=Z,e[81]=r.showInlineArchived,e[82]=je):je=e[82];const Ie=je;let Ve;e[83]!==be?(Ve=st=>be.find(U=>U.project.id===st)?.groups.find(i4)?.folderScopes??[],e[83]=be,e[84]=Ve):Ve=e[84];const Je=Ve;let it;e[85]!==b||e[86]!==g.hasAuthoritativeGlobalSessions||e[87]!==x||e[88]!==h||e[89]!==De||e[90]!==n.projects||e[91]!==r.isSessionsLoading||e[92]!==r.isWorktreeTopologyLoading||e[93]!==r.unresolvedWorktreeProjectPaths?(it={enabled:!0,normalizedProjects:n.projects,ownership:De,isSessionsLoading:r.isSessionsLoading,hasAuthoritativeGlobalSessions:g.hasAuthoritativeGlobalSessions,isWorktreeTopologyLoading:r.isWorktreeTopologyLoading,unresolvedWorktreeProjectPaths:r.unresolvedWorktreeProjectPaths,foldersMap:h,createFolder:x,addSessionToFolder:b},e[85]=b,e[86]=g.hasAuthoritativeGlobalSessions,e[87]=x,e[88]=h,e[89]=De,e[90]=n.projects,e[91]=r.isSessionsLoading,e[92]=r.isWorktreeTopologyLoading,e[93]=r.unresolvedWorktreeProjectPaths,e[94]=it):it=e[94],A2(it);const{github:at}=vn(),Ye=In(a4),vt=In(l4),Ue=Hs(c4),Pt=Hs(d4),ke=Hs(u4);let xt;e[95]===Symbol.for("react.memo_cache_sentinel")?(xt=new Set,e[95]=xt):xt=e[95];const Ct=c.useRef(xt);let Tt;e[96]!==Ue||e[97]!==at||e[98]!==vt||e[99]!==Ye||e[100]!==Xe||e[101]!==w.collapsedProjects||e[102]!==ke||e[103]!==Pt||e[104]!==n.gitBranches?(Tt=()=>{if(!at||!vt||!Ye?.connected)return;const st=new Map,gt=Date.now();Xe.forEach(U=>{w.collapsedProjects.has(U.project.id)||U.groups.forEach(Te=>{if(Te.isArchivedBucket||Te.isMain)return;const ot=ht(Te.directory??null),Et=Te.branch?.trim()||n.gitBranches.get(ot||"")?.trim();if(!ot||!Et)return;const Mt=Ho(ot,Et),$t=Hs.getState().entries[Mt],Wt=$t?.status?.pr?.state==="closed"||$t?.status?.pr?.state==="merged",Ss=`${ot}::${Et}`,is=Math.max($t?.lastRefreshAt??0,$t?.lastDiscoveryPollAt??0),Vn=!!($t?.isInitialStatusResolved&&(!$t.status?.pr||Wt)&&(!Ct.current.has(Ss)||gt-is>=_3));(!$t||!$t.isInitialStatusResolved||Vn)&&(Vn&&Ct.current.add(Ss),st.set(Mt,{directory:ot,branch:Et}))})}),st.forEach((U,Te)=>{Ue(Te),Pt(Te,{...U,remoteName:null,canShow:!0,github:at,githubAuthChecked:vt,githubConnected:Ye.connected})}),st.size&&ke([...st.values()],{silent:!0,markInitialResolved:!0})},e[96]=Ue,e[97]=at,e[98]=vt,e[99]=Ye,e[100]=Xe,e[101]=w.collapsedProjects,e[102]=ke,e[103]=Pt,e[104]=n.gitBranches,e[105]=Tt):Tt=e[105];const qe=Ye?.connected;let ze;e[106]!==Ue||e[107]!==at||e[108]!==vt||e[109]!==Xe||e[110]!==w.collapsedProjects||e[111]!==ke||e[112]!==Pt||e[113]!==qe||e[114]!==n.gitBranches?(ze=[Ue,at,vt,qe,Xe,w.collapsedProjects,ke,Pt,n.gitBranches],e[106]=Ue,e[107]=at,e[108]=vt,e[109]=Xe,e[110]=w.collapsedProjects,e[111]=ke,e[112]=Pt,e[113]=qe,e[114]=n.gitBranches,e[115]=ze):ze=e[115],c.useEffect(Tt,ze);let ft;e[116]!==g.orderedSessions?(ft=new Map(g.orderedSessions.map(f4)),e[116]=g.orderedSessions,e[117]=ft):ft=e[117];const Be=ft;let Ke;if(e[118]!==v||e[119]!==Ie){let st;e[121]!==v?(st=gt=>{const U=v(gt.project.id,gt.groups);return U===gt.groups?gt:{...gt,groups:U}},e[121]=v,e[122]=st):st=e[122],Ke=Ie.map(st),e[118]=v,e[119]=Ie,e[120]=Ke}else Ke=e[120];const He=Ke;let nt;if(e[123]!==g.childrenMap||e[124]!==ue||e[125]!==n.availableWorktreesByProject||e[126]!==n.gitBranches||e[127]!==n.projects||e[128]!==r.hasSessionSearchQuery||e[129]!==r.homeDirectory||e[130]!==r.normalizedSessionSearchQuery){const st=new Map;for(const U of ue){const Te=ht(U.directory??null);if(!Te)continue;let ot=null,Et=-1;for(const Ss of n.projects){const is=ht(Ss.normalizedPath);is&&(Te===is||Te.startsWith(`${is}/`))&&is.length>Et&&(ot=Ss,Et=is.length)}if(!ot)continue;const Mt=n.availableWorktreesByProject.get(ot.normalizedPath)?.find(Ss=>ht(Ss.path)===Te),$t=Ba(ot.label?.trim()||Ln(ot.normalizedPath,r.homeDirectory)||ot.normalizedPath),Wt=Mt?.branch?.trim()||n.gitBranches.get(Te)?.trim()||null;st.set(U.id,{projectId:ot.id,groupDirectory:Te,projectLabel:$t,branchLabel:Wt&&Wt!=="HEAD"&&Wt!==$t?Wt:null})}let gt;e[132]!==g.childrenMap?(gt=U=>yl(g.childrenMap,U),e[132]=g.childrenMap,e[133]=gt):gt=e[133],nt=Bh({sessions:ue,getSessionLocation:U=>st.get(U)??null,getSessionNode:gt,query:r.hasSessionSearchQuery?r.normalizedSessionSearchQuery:""}),e[123]=g.childrenMap,e[124]=ue,e[125]=n.availableWorktreesByProject,e[126]=n.gitBranches,e[127]=n.projects,e[128]=r.hasSessionSearchQuery,e[129]=r.homeDirectory,e[130]=r.normalizedSessionSearchQuery,e[131]=nt}else nt=e[131];const St=nt;let Lt;e[134]===Symbol.for("react.memo_cache_sentinel")?(Lt=Bd(),e[134]=Lt):Lt=e[134];let Ut;e[135]!==et||e[136]!==G||e[137]!==He?(Ut={childStores:G,sections:He,chatGroup:et,canGrantAccess:Lt},e[135]=et,e[136]=G,e[137]=He,e[138]=Ut):Ut=e[138];const{groupStatusByKey:Bt,bootstrapSnapshot:zt}=I3(Ut);let _t;e[139]!==Xe||e[140]!==E||e[141]!==fe||e[142]!==r.activeProjectId?(_t=null,fe&&(Xe.some(st=>st.project.id===E)?_t=E:Xe.some(st=>st.project.id===r.activeProjectId)?_t=r.activeProjectId:_t=Xe[0]?.project.id??null),e[139]=Xe,e[140]=E,e[141]=fe,e[142]=r.activeProjectId,e[143]=_t):_t=e[143];const Yt=fe&&!r.useGroupedSections?20:void 0;let Zt;e[144]!==i.startSessionWorktreeMenuLoad||e[145]!==o||e[146]!==g.pinnedSessionIds||e[147]!==ge||e[148]!==H||e[149]!==pe||e[150]!==Se||e[151]!==ye||e[152]!==q||e[153]!==de||e[154]!==yt||e[155]!==l||e[156]!==w.collapsedGroups||e[157]!==d.allowReselect||e[158]!==d.onSessionSelected||e[159]!==d.resetSessionSearch||e[160]!==Be||e[161]!==Yt||e[162]!==z||e[163]!==r.activeProjectId||e[164]!==r.hasSessionSearchQuery||e[165]!==r.hideDirectoryControls||e[166]!==r.mobileVariant||e[167]!==r.normalizedSessionSearchQuery?(Zt={hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,groupSearchDataByGroup:yt,collapsedGroups:w.collapsedGroups,hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:o,activeProjectId:r.activeProjectId,notifyOnSubtasks:l,pinnedSessionIds:g.pinnedSessionIds,sessionOrderIndex:Be,expandedParents:q,editingId:Se,editingRowKey:ye,editTitle:pe,copiedSessionId:ge,sessionBatchSize:Yt,setEditingId:we,setEditingRowKey:Ae,setEditTitle:O,toggleParent:z,allowReselect:d.allowReselect,onSessionSelected:d.onSessionSelected,resetSessionSearch:d.resetSessionSearch,deleteSessionConfirm:H,setDeleteSessionConfirm:me,startFolderRename:he,setCopiedSessionId:oe,startSessionWorktreeMenuLoad:i.startSessionWorktreeMenuLoad,folderRename:de,setFolderRenameDraft:Re,clearFolderRename:se},e[144]=i.startSessionWorktreeMenuLoad,e[145]=o,e[146]=g.pinnedSessionIds,e[147]=ge,e[148]=H,e[149]=pe,e[150]=Se,e[151]=ye,e[152]=q,e[153]=de,e[154]=yt,e[155]=l,e[156]=w.collapsedGroups,e[157]=d.allowReselect,e[158]=d.onSessionSelected,e[159]=d.resetSessionSearch,e[160]=Be,e[161]=Yt,e[162]=z,e[163]=r.activeProjectId,e[164]=r.hasSessionSearchQuery,e[165]=r.hideDirectoryControls,e[166]=r.mobileVariant,e[167]=r.normalizedSessionSearchQuery,e[168]=Zt):Zt=e[168];const es=Zt;let Vt;e[169]!==u.openNewSessionDraft||e[170]!==u.setActiveProjectIdOnly||e[171]!==u.setSessionSwitcherOpen||e[172]!==m?(Vt={showMoreGroupSessions:K,resetGroupSessionLimit:W,setActiveProjectIdOnly:u.setActiveProjectIdOnly,setSessionSwitcherOpen:u.setSessionSwitcherOpen,openNewSessionDraft:u.openNewSessionDraft,onToggleCollapsedGroup:m},e[169]=u.openNewSessionDraft,e[170]=u.setActiveProjectIdOnly,e[171]=u.setSessionSwitcherOpen,e[172]=m,e[173]=Vt):Vt=e[173];const It=Vt;let bt;if(e[174]!==et||e[175]!==G||e[176]!==g.hasAuthoritativeGlobalSessions||e[177]!==He){bt=new Map;for(const st of He)for(const gt of st.groups){const U=vr(st.project.id,gt.directory);if(!U)continue;const Te=Yr(gt),ot=bt.get(U),Et=[...new Set([...ot?.scopeKeys??[],...Te.map(m4)])],Mt=g.hasAuthoritativeGlobalSessions&&Te.every($t=>{const Wt=ht($t.directory);return!Wt||G.getBootstrapState(Wt)==="complete"});bt.set(U,{scopeKeys:Et,complete:(ot?.complete??!0)&&Mt})}if(et){let st;e[179]!==et.directory?(st=vr(null,et.directory),e[179]=et.directory,e[180]=st):st=e[180];const gt=st;if(gt){let U;e[181]!==et?(U=Yr(et).map(h4),e[181]=et,e[182]=U):U=e[182];let Te;e[183]!==g.hasAuthoritativeGlobalSessions||e[184]!==U?(Te={scopeKeys:U,complete:g.hasAuthoritativeGlobalSessions},e[183]=g.hasAuthoritativeGlobalSessions,e[184]=U,e[185]=Te):Te=e[185],bt.set(gt,Te)}}e[174]=et,e[175]=G,e[176]=g.hasAuthoritativeGlobalSessions,e[177]=He,e[178]=bt}else bt=e[178];const cs=bt;let ms;e[186]!==T||e[187]!==k?(ms=new Map([...k,...T]),e[186]=T,e[187]=k,e[188]=ms):ms=e[188];const hs=ms,ds=r.hasSessionSearchQuery?"search":"normal",nn=N&&!fe,Ts=fe&&!r.useGroupedSections?20:void 0;let rn;e[189]!==et||e[190]!==I||e[191]!==f||e[192]!==g.pinnedSessionIds||e[193]!==q||e[194]!==cs||e[195]!==h||e[196]!==yt||e[197]!==Bt||e[198]!==He||e[199]!==Xe||e[200]!==w.collapsedGroups||e[201]!==w.collapsedProjects||e[202]!==St||e[203]!==_t||e[204]!==Be||e[205]!==fe||e[206]!==ds||e[207]!==nn||e[208]!==Ts||e[209]!==r.activeProjectId||e[210]!==r.hideDirectoryControls||e[211]!==r.normalizedSessionSearchQuery||e[212]!==r.showOnlyMainWorkspace||e[213]!==hs?(rn=Ak({mode:ds,sections:He,authoritativeSections:Xe,chatGroup:et,recentSections:St,showRecentSection:nn,foldersMap:h,groupSearchDataByGroup:yt,normalizedQuery:r.normalizedSessionSearchQuery,collapsedProjects:w.collapsedProjects,collapsedGroups:w.collapsedGroups,collapsedFolders:f,collapsedActivities:I,expandedParents:q,visibleCountByContainer:hs,pinnedSessionIds:g.pinnedSessionIds,sessionOrderIndex:Be,groupStatusByKey:Bt,folderAuthorityByOwner:cs,activeProjectId:r.activeProjectId,singleProjectMode:fe,singleProjectId:_t,showOnlyMainWorkspace:r.showOnlyMainWorkspace,hideDirectoryControls:r.hideDirectoryControls,sessionBatchSize:Ts}),e[189]=et,e[190]=I,e[191]=f,e[192]=g.pinnedSessionIds,e[193]=q,e[194]=cs,e[195]=h,e[196]=yt,e[197]=Bt,e[198]=He,e[199]=Xe,e[200]=w.collapsedGroups,e[201]=w.collapsedProjects,e[202]=St,e[203]=_t,e[204]=Be,e[205]=fe,e[206]=ds,e[207]=nn,e[208]=Ts,e[209]=r.activeProjectId,e[210]=r.hideDirectoryControls,e[211]=r.normalizedSessionSearchQuery,e[212]=r.showOnlyMainWorkspace,e[213]=hs,e[214]=rn):rn=e[214];const os=rn;let qs,Ys;e[215]!==Ge||e[216]!==os.searchMatchCount?(qs=()=>{Ge(os.searchMatchCount)},Ys=[Ge,os.searchMatchCount],e[215]=Ge,e[216]=os.searchMatchCount,e[217]=qs,e[218]=Ys):(qs=e[217],Ys=e[218]),c.useEffect(qs,Ys);let Cs;e[219]!==I||e[220]!==Se||e[221]!==Q||e[222]!==T||e[223]!==k?(Cs={editingId:Se,openSidebarMenuKey:Q,setOpenSidebarMenuKey:le,visibleSessionCountByGroup:k,collapsedActivityKeys:I,setCollapsedActivityKeys:A,visibleActivityCountByKey:T,setVisibleActivityCountByKey:L},e[219]=I,e[220]=Se,e[221]=Q,e[222]=T,e[223]=k,e[224]=Cs):Cs=e[224];let Ns;e[225]!==es||e[226]!==He||e[227]!==Xe||e[228]!==os||e[229]!==fe||e[230]!==Cs||e[231]!==n.projectRepoStatus||e[232]!==r.emptyState||e[233]!==r.searchEmptyState?(Ns={rowModel:os,sectionsForRender:He,projectSections:Xe,singleProjectMode:fe,emptyState:r.emptyState,searchEmptyState:r.searchEmptyState,projectRepoStatus:n.projectRepoStatus,state:Cs,groupProps:es},e[225]=es,e[226]=He,e[227]=Xe,e[228]=os,e[229]=fe,e[230]=Cs,e[231]=n.projectRepoStatus,e[232]=r.emptyState,e[233]=r.searchEmptyState,e[234]=Ns):Ns=e[234];const mn=Ns;let Es;e[235]!==o||e[236]!==r.hasSessionSearchQuery||e[237]!==r.hideDirectoryControls||e[238]!==r.homeDirectory||e[239]!==r.mobileVariant||e[240]!==r.projectSortOrder||e[241]!==r.stickyZoneHeaders?(Es={homeDirectory:r.homeDirectory,hasSessionSearchQuery:r.hasSessionSearchQuery,hideDirectoryControls:r.hideDirectoryControls,stickyZoneHeaders:r.stickyZoneHeaders,mobileVariant:r.mobileVariant,alwaysShowActions:o,projectSortOrder:r.projectSortOrder},e[235]=o,e[236]=r.hasSessionSearchQuery,e[237]=r.hideDirectoryControls,e[238]=r.homeDirectory,e[239]=r.mobileVariant,e[240]=r.projectSortOrder,e[241]=r.stickyZoneHeaders,e[242]=Es):Es=e[242];const Rs=Es;let Qs;e[243]!==It||e[244]!==u.openNewSessionDraft||e[245]!==u.openNewWorktreeDialog||e[246]!==u.openProjectEditDialog||e[247]!==u.openWorktreesPage||e[248]!==u.removeProject||e[249]!==u.renderProjectStatusIndicator||e[250]!==u.reorderProjects||e[251]!==u.setActiveProjectIdOnly||e[252]!==u.setSessionSwitcherOpen||e[253]!==y||e[254]!==X||e[255]!==p?(Qs={group:It,toggleProject:p,setActiveProjectIdOnly:u.setActiveProjectIdOnly,setSessionSwitcherOpen:u.setSessionSwitcherOpen,openNewSessionDraft:u.openNewSessionDraft,openNewWorktreeDialog:u.openNewWorktreeDialog,openWorktreesPage:u.openWorktreesPage,openProjectEditDialog:u.openProjectEditDialog,removeProject:u.removeProject,reorderProjects:u.reorderProjects,setGroupOrderByProject:y,renderProjectStatusIndicator:u.renderProjectStatusIndicator,setSingleProjectId:X},e[243]=It,e[244]=u.openNewSessionDraft,e[245]=u.openNewWorktreeDialog,e[246]=u.openProjectEditDialog,e[247]=u.openWorktreesPage,e[248]=u.removeProject,e[249]=u.renderProjectStatusIndicator,e[250]=u.reorderProjects,e[251]=u.setActiveProjectIdOnly,e[252]=u.setSessionSwitcherOpen,e[253]=y,e[254]=X,e[255]=p,e[256]=Qs):Qs=e[256];const on=Qs;let an;e[257]===Symbol.for("react.memo_cache_sentinel")?(an=s.jsx(j2,{}),e[257]=an):an=e[257];let ps;e[258]!==i.initialActiveSessionByProject||e[259]!==i.openNewSessionDraft||e[260]!==i.persistActiveSessionByProject||e[261]!==i.setSessionSwitcherOpen||e[262]!==De.bySessionId||e[263]!==Xe||e[264]!==Ne||e[265]!==r.activeProjectId||e[266]!==r.mobileVariant?(ps=s.jsx(T2,{projectSections:Xe,activeProjectId:r.activeProjectId,initialActiveSessionByProject:i.initialActiveSessionByProject,persistActiveSessionByProject:i.persistActiveSessionByProject,mobileVariant:r.mobileVariant,openNewSessionDraft:i.openNewSessionDraft,setSessionSwitcherOpen:i.setSessionSwitcherOpen,sessionOwnerBySessionId:De.bySessionId,handleSessionSelect:Ne}),e[258]=i.initialActiveSessionByProject,e[259]=i.openNewSessionDraft,e[260]=i.persistActiveSessionByProject,e[261]=i.setSessionSwitcherOpen,e[262]=De.bySessionId,e[263]=Xe,e[264]=Ne,e[265]=r.activeProjectId,e[266]=r.mobileVariant,e[267]=ps):ps=e[267];let vs;e[268]!==g.orderedSessions||e[269]!==Ce||e[270]!==ue?(vs=s.jsx(H2,{sortedSessions:g.orderedSessions,recentSessions:ue,prefetchSession:Ce}),e[268]=g.orderedSessions,e[269]=Ce,e[270]=ue,e[271]=vs):vs=e[271];let ln;e[272]!==on||e[273]!==mn||e[274]!==Rs?(ln=s.jsx(o3,{model:mn,view:Rs,actions:on}),e[272]=on,e[273]=mn,e[274]=Rs,e[275]=ln):ln=e[275];const Sn=Se!==null;let ie;e[276]!==Je||e[277]!==Sn?(ie=s.jsx(x3,{getFolderScopesForProject:Je,isInlineEditing:Sn,startFolderRename:he}),e[276]=Je,e[277]=Sn,e[278]=ie):ie=e[278];let Qe;e[279]!==os.selectionDescendantIds||e[280]!==os.selectionEntries||e[281]!==os.sessionById||e[282]!==ln||e[283]!==ie?(Qe=s.jsxs(dj,{entries:os.selectionEntries,descendantIds:os.selectionDescendantIds,sessionsById:os.sessionById,children:[ln,ie]}),e[279]=os.selectionDescendantIds,e[280]=os.selectionEntries,e[281]=os.sessionById,e[282]=ln,e[283]=ie,e[284]=Qe):Qe=e[284];let lt;return e[285]!==ps||e[286]!==vs||e[287]!==Qe?(lt=s.jsxs(s.Fragment,{children:[an,ps,vs,Qe]}),e[285]=ps,e[286]=vs,e[287]=Qe,e[288]=lt):lt=e[288],lt},W3=t=>{const e=Ze.c(2);let n;return e[0]!==t?(n=t.view.isVisible?s.jsx(z3,{...t}):null,e[0]=t,e[1]=n):n=e[1],n};function K3(t){return t.foldersMap}function V3(t){return t.collapsedFolderIds}function U3(t){return t.createFolder}function H3(t){return t.addSessionToFolder}function G3(t){return t.showRecentSection}function q3(t){return t.projectDisplayMode}function Y3(t){return t.singleProjectId}function Q3(t){return t.setSingleProjectId}function X3(t){return t.setCurrentSession}function J3(t){return Ra(t.directory)}function Z3(t){return ht(t.directory??null)}function e4(t){return!!t}function t4(t){return{scopeKey:t,directory:t}}function s4(t){return!t.time?.archived&&$3(t)}function n4(t){return t.isArchivedBucket}function r4(t){return!t.isArchivedBucket}function o4(t){return t.groups.some(n4)?{...t,groups:t.groups.filter(r4)}:t}function i4(t){return!t.isArchivedBucket}function a4(t){return t.status}function l4(t){return t.hasChecked}function c4(t){return t.ensureEntry}function d4(t){return t.setParams}function u4(t){return t.refreshTargets}function f4(t,e){return[t.id,e]}function m4(t){return t.scopeKey}function h4(t){return t.scopeKey}const Xf=(t,e,n)=>{const r=new Set;for(const i of t){const o=ht(i.path);o&&r.add(o)}if(n?.includeWorktrees===!1)return r;for(const i of e.values())for(const o of i){const l=ht(o.path);l&&r.add(l)}return r},rd="oc.sessions.activeSessionByProject",p4=[],g4=qu(jr(),jr().min(1).catch("")),x4=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:n,allowReselect:r=!1,hideDirectoryControls:i=!1,showOnlyMainWorkspace:o=!1})=>{Pi("react.session_sidebar_render"),Gs("ui.session_sidebar.render"),Gs(`ui.session_sidebar.render.${e?"mobile":"desktop"}`),Gs(`ui.session_sidebar.render.${t?"visible":"hidden"}`);const{t:l}=jt(),[a,d]=c.useState(!1),[u,h]=c.useState(""),f=c.useCallback(()=>{h(""),d(!1)},[]),[x,b]=c.useState(0),w=c.useRef(null),v=c.useRef(null),[y,m]=c.useState(null),p=c.useMemo(()=>Do(),[]),[S,g]=c.useState(new Map),C=Pe(ke=>ke.isNewWorktreeDialogOpen),k=Pe(ke=>ke.setNewWorktreeDialogOpen),[j,D]=c.useState(!1),I=c.useMemo(()=>{try{const ke=p.getItem(rd);if(!ke)return new Map;const xt=g4.safeParse(JSON.parse(ke));if(!xt.success)return new Map;const Ct=new Map;return Object.entries(xt.data).forEach(([Tt,qe])=>{qe&&Ct.set(Tt,qe)}),Ct}catch{return new Map}},[p]),A=c.useCallback(ke=>{try{p.setItem(rd,JSON.stringify(Object.fromEntries(ke.entries())))}catch{}},[p]),[P,T]=c.useState(new Map),L=ns(ke=>ke.homeDirectory),$=Ht(ke=>ke.projects),K=Ht(ke=>ke.activeProjectId),F=Ht(ke=>ke.removeProject),W=Ht(ke=>ke.setActiveProjectIdOnly),N=Ht(ke=>ke.updateProjectMeta),R=Ht(ke=>ke.reorderProjects),E=Pe(ke=>ke.setSettingsDialogOpen),X=Pe(ke=>ke.toggleHelpDialog),J=Pe(ke=>ke.setAboutDialogOpen),re=Pe(ke=>ke.setSessionSwitcherOpen),fe=Pe(ke=>ke.setScheduledTasksDialogOpen),ne=Pe(ke=>ke.setArchivePageOpen),te=Pe(ke=>ke.setWorktreesPageProjectId),ue=Pe(ke=>ke.openMultiRunLauncher),Se=Pe(ke=>ke.notifyOnSubtasks),we=c.useMemo(()=>u.trim().toLowerCase(),[u]),ye=we.length>0;U0({enabled:t,isSessionSearchOpen:a,setIsSessionSearchOpen:d,sessionSearchInputRef:v,sessionSearchContainerRef:w});const Ae=Su(t),pe=c.useMemo(()=>$n(),[]),O=tt(ke=>ke.setCurrentSession),Q=tt(ke=>ke.worktreeMetadata),le=tt(ke=>ke.availableWorktreesByProject),H=tt(ke=>ke.openNewSessionDraft),me=c.useMemo(()=>Xf($,le,{includeWorktrees:!pe}),[le,pe,$]),ge=c.useCallback(ke=>{Pe.getState().closeMainSurfaces(),H(ke),pe&&window.dispatchEvent(new CustomEvent("openchamber:navigate",{detail:{view:"chat"}}))},[pe,H]),oe=zr(rr(ke=>({checkForUpdates:ke.checkForUpdates,available:ke.available,runtimeType:ke.runtimeType,info:ke.info,downloading:ke.downloading,downloaded:ke.downloaded,progress:ke.progress,error:ke.error,downloadUpdate:ke.downloadUpdate,restartToUpdate:ke.restartToUpdate}))),de=qt(),_=c.useMemo(()=>`${de}|${$.map(ke=>`${ke.id}:${ht(ke.path)??""}`).join("|")}`,[$,de]),[B,he]=c.useState(pe?_:null),[ve,Re]=c.useReducer(ke=>ke+1,0),ce=!pe&&B!==_,[se,q]=c.useState(new Set),z=c.useRef({runtimeKey:null,revision:0,worktreesByProject:new Map});c.useEffect(()=>{let ke=!1;return(async()=>{const Ct=de,Tt=Ht.getState().projects;if(tt.setState({worktreeDiscoveryByProject:new Map(Tt.map(Bt=>[ht(Bt.path)??Bt.path,"loading"]))}),Tt.length===0||pe){ke||(z.current={runtimeKey:null,revision:0,worktreesByProject:new Map},q(new Set),he(_));return}const qe=tt.getState().availableWorktreesByProject,ze=sl({rawWorktreesByProjectRef:z,publishedWorktreesByProject:qe,runtimeKey:Ct}),ft=ze.revision,Be=new Map(ze.worktreesByProject),Ke=new Set,He=3;let nt=0;const St=Array.from({length:He},async()=>{for(;;){const Bt=nt;if(nt+=1,Bt>=Tt.length)return;const zt=Tt[Bt],_t=ht(zt.path);if(_t)try{const Yt=await $i(async()=>Tn.getState().directories.get(_t)?.isGitRepo??await ja(_t)?Ol({id:zt.id,path:_t}):null);if(Yt===null){Be.delete(_t);continue}if(ke)return;Yt.length===0?Be.delete(_t):Be.set(_t,Yt)}catch{Ke.add(_t)}}});if(await Promise.all(St),ke||qt()!==Ct)return;const Lt=new Set(Tt.map(Bt=>ht(Bt.path)).filter(Boolean));for(const Bt of Be.keys())Lt.has(Bt)||Be.delete(Bt);qj({rawWorktreesByProjectRef:z,runtimeKey:Ct,capturedRevision:ft,nextRawWorktreesByProject:Be,publishedWorktreesByProject:qe,partitionWorktreesByRegisteredProject:Ml,projects:Tt,worktreeMapsEqual:Rl,recordWorktreesSeen:td,publishTopology:Bt=>{tt.setState(Bt)},requestRediscovery:()=>{Re()},now:()=>Date.now()})&&(q(Ke),tt.setState({worktreeDiscoveryByProject:new Map(Tt.map(Bt=>{const zt=ht(Bt.path)??Bt.path;return[zt,Ke.has(zt)?"error":"ready"]}))}),he(_))})(),()=>{ke=!0}},[pe,_,de,ve]);const ee=c.useMemo(()=>xn(),[]),{isTablet:ae}=zn(),Ne=e||ae,Ce=c.useMemo(()=>s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:l("sessions.sidebar.empty.noSessions.title")}),s.jsx("p",{className:"typography-meta mt-1",children:l("sessions.sidebar.empty.noSessions.description")})]}),[l]),We=c.useMemo(()=>$.find(ke=>ke.id===y)??null,[$,y]),Ee=c.useCallback(ke=>{y&&N(y,{label:ke.label,icon:ke.icon,color:ke.color,iconBackground:ke.iconBackground,defaultAgent:ke.defaultAgent??null,defaultModel:ke.defaultModel??null,defaultVariant:ke.defaultVariant??null})},[y,N]),xe=c.useCallback(()=>{k(!0)},[k]),$e=c.useCallback(()=>{const ke=zr.getState();if(ke.available&&ke.info){D(!0);return}oe.checkForUpdates().then(()=>{const{available:xt,error:Ct}=zr.getState();if(Ct){Le.error(l("sessions.sidebar.updateCheck.errorTitle"),{description:Ct});return}if(!xt){Le.success(l("sessions.sidebar.updateCheck.latestVersion"));return}D(!0)})},[l,oe]),V=c.useCallback(()=>{e&&re(!1),E(!0)},[e,re,E]),De=oe.available&&(oe.runtimeType==="desktop"||oe.runtimeType==="web"),Fe=c.useCallback(()=>{fn.requestDirectoryDialog()},[]),_e=c.useMemo(()=>$.flatMap(ke=>{const xt=ht(ke.path);return xt?[{id:ke.id,path:ke.path,label:ke.label,normalizedPath:xt,icon:ke.icon??void 0,color:ke.color??void 0,iconImage:ke.iconImage??void 0,iconBackground:ke.iconBackground??void 0,addedAt:ke.addedAt,lastOpenedAt:ke.lastOpenedAt,sidebarCollapsed:ke.sidebarCollapsed}]:[]}),[$]),rt=c.useMemo(()=>_e.map(ke=>ke.normalizedPath),[_e]),ct=Eg(t?rt:p4);Z0({enabled:t,normalizedProjects:_e,gitRepoStatus:ct,setProjectRepoStatus:g,setProjectRootBranches:T});const et=tt(ke=>ke.isLoading),pt=c.useRef(!1);K&&S.has(K)&&(pt.current=!!S.get(K));const kt=us(ke=>ke.showArchivedSessions),wt=us(ke=>ke.projectSortOrder),Xe=us(ke=>ke.stickyZoneHeaders),yt=Ht(ke=>ke.manualProjectOrder),Rt={isVisible:t,mobileVariant:e,onSessionSelected:n,allowReselect:r,hideDirectoryControls:i,showOnlyMainWorkspace:o,t:l,isTablet:ae,projects:$,activeProjectId:K,manualProjectOrder:yt,worktreeMetadata:Q,availableWorktreesByProject:le,gitBranches:Ae,gitRepoStatus:ct,updateStore:oe,showArchivedSessions:kt,projectSortOrder:wt,projectRepoStatus:S,projectRootBranches:P,resolvedWorktreeTopologyKey:B,unresolvedWorktreeProjectPaths:se,isSessionSearchOpen:a,sessionSearchQuery:u,editingProjectDialogId:y,updateDialogOpen:j},be=c.useRef(null),Ge=be.current;if(Ge){let ke=!1;for(const xt of Object.keys(Rt))Object.is(Ge[xt],Rt[xt])||(Gs(`ui.session_sidebar.source.${xt}`),ke=!0);ke||Gs("ui.session_sidebar.source.parent_or_context")}be.current=Rt;const ut=c.useMemo(()=>Fh(_e,wt,yt),[_e,wt,yt]),Y=Y0({isVSCode:pe,projects:ut}),G=c.useMemo(()=>s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:l("sessions.sidebar.empty.noMatches.title")}),s.jsx("p",{className:"typography-meta mt-1",children:l("sessions.sidebar.empty.noMatches.description")})]}),[l]),Z=pe&&kt,Ie=us(ke=>ke.sessionGroupingMode)==="by-worktree"&&!pe,it=e?"inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md leading-none text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed":"inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md leading-none text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed",at="h-4.5 w-4.5",Ye=c.useCallback(()=>{e&&re(!1),ue()},[e,ue,re]),vt=c.useMemo(()=>({projects:$,getCurrentProjects:()=>Ht.getState().projects,rawWorktreesByProjectRef:z,getPublishedWorktreesByProject:()=>tt.getState().availableWorktreesByProject,resolveProject:ke=>Mi(ke),listProjectWorktrees:Ol,partitionWorktreesByRegisteredProject:Ml,worktreeMapsEqual:Rl,recordWorktreesSeen:td,publishTopology:ke=>{tt.setState(ke)},getRuntimeKey:qt,now:()=>Date.now()}),[$]),Ue=c.useCallback(ke=>{const xt=ke.projectId?$.find(Ct=>Ct.id===ke.projectId)??null:ke.sourceDirectory?Mi(ke.sourceDirectory):null;return Gj(ke,{...vt,projectRootBranch:xt?P.get(xt.id)??null:null})},[P,$,vt]);c.useEffect(()=>{if(!pe)return eo(ke=>{if(ke.type==="session-created"){Re();return}if(ke.type==="worktree-changed")for(const xt of Rg(ke.directories)){const Ct=ht(xt.path),Tt=qt(),qe=ze=>{!Ct||qt()!==Tt||tt.setState(ft=>({worktreeDiscoveryByProject:new Map(ft.worktreeDiscoveryByProject).set(Ct,ze)}))};qe("loading"),Uf(xt,null,vt).then(()=>{!Ct||qt()!==Tt||(qe("ready"),q(ze=>{if(!ze.has(Ct))return ze;const ft=new Set(ze);return ft.delete(Ct),ft}))}).catch(()=>{!Ct||qt()!==Tt||(qe("error"),q(ze=>new Set(ze).add(Ct)))})}})},[pe,vt]);const Pt=c.useCallback(()=>{Pe.getState().closeMainSurfaces(),e&&re(!1),H()},[e,H,re]);return s.jsx(Vi,{delay:400,closeDelay:0,timeout:300,children:s.jsxs("div",{ref:w,className:Oe("relative flex h-full flex-col text-foreground overflow-x-hidden",e?"":"bg-transparent"),children:[!i&&!pe?s.jsx(w2,{onNewSession:Pt}):null,s.jsx(o2,{hideDirectoryControls:i,showProjectDisplayControls:!pe,showRecentControls:!pe,handleOpenDirectoryDialog:Fe,onOpenScheduled:()=>{e&&re(!1),fe(!0)},onOpenMultiRun:Ye,canOpenMultiRun:$.length>0,onOpenArchive:()=>{e&&re(!1),ne(!0)},headerActionIconClass:at,headerActionButtonClass:it,isSessionSearchOpen:a,setIsSessionSearchOpen:d,sessionSearchInputRef:v,sessionSearchQuery:u,setSessionSearchQuery:h,hasSessionSearchQuery:ye,searchMatchCount:x,collapseAllProjects:Y.actions.collapseAllProjects,expandAllProjects:Y.actions.expandAllProjects}),s.jsx(W3,{topology:{projects:ut,availableWorktreesByProject:le,knownDirectories:me,isVSCode:pe,worktreeMetadata:Q,gitBranches:Ae,projectRepoStatus:S,projectRootBranches:P,lastRepoStatus:pt.current},view:{isVisible:t,hasSessionSearchQuery:ye,normalizedSessionSearchQuery:we,activeProjectId:K,showInlineArchived:Z,useGroupedSections:Ie,homeDirectory:L,mobileVariant:e,hideDirectoryControls:i,showOnlyMainWorkspace:o,isDesktopShellRuntime:ee,stickyZoneHeaders:Xe,projectSortOrder:wt,emptyState:Ce,searchEmptyState:G,isSessionsLoading:et,isWorktreeTopologyLoading:ce,unresolvedWorktreeProjectPaths:se,projectView:Y.state,onSearchMatchCountChange:b},actions:{rowActions:{allowReselect:r,onSessionSelected:n,resetSessionSearch:f},alwaysShowActions:Ne,notifyOnSubtasks:Se,setActiveProjectIdOnly:W,setSessionSwitcherOpen:re,openNewSessionDraft:ge,openNewWorktreeDialog:xe,openWorktreesPage:ke=>{e&&re(!1),te(ke)},openProjectEditDialog:m,removeProject:F,reorderProjects:R,startSessionWorktreeMenuLoad:Ue,initialActiveSessionByProject:I,persistActiveSessionByProject:A,projectViewActions:Y.actions}}),s.jsx(v2,{onOpenSettings:V,onOpenShortcuts:X,onOpenAbout:()=>J(!0),onOpenUpdate:$e,showRuntimeButtons:!pe,showUpdateButton:De}),s.jsx(Ld,{open:j,onOpenChange:D,info:oe.info,downloading:oe.downloading,downloaded:oe.downloaded,progress:oe.progress,error:oe.error,onDownload:oe.downloadUpdate,onRestart:oe.restartToUpdate,runtimeType:oe.runtimeType}),s.jsx(r2,{open:!!We,onOpenChange:ke=>{ke||m(null)},project:We,onSave:Ee}),s.jsx(_h,{open:C,onOpenChange:k,onWorktreeCreated:(ke,xt)=>{if(Pe.getState().closeMainSurfaces(),e&&re(!1),xt?.sessionId){O(xt.sessionId,ke);return}H({directoryOverride:ke,preserveDirectoryOverride:!0})}})]})})},b4=c.memo(x4),kn=t=>t?s.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,dn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},y4=()=>{const{t}=jt(),[e,n]=c.useState(!1),[r,i]=c.useState(!1),[o,l]=c.useState(null),[a,d]=c.useState([]),[u,h]=c.useState(!1),[f,x]=c.useState(!1),[b,w]=c.useState(!1),[v,y]=c.useState(!1),[m,p]=c.useState(new Set),S=tt(B=>B.getWorktreeMetadata),g=tt(B=>B.newSessionDraft),C=tt(B=>B.setNewSessionDraftTarget),k=tt(B=>B.setDraftBootstrapPendingDirectory),j=Mg,D=tt(B=>B.deleteSessions),I=tt(B=>B.archiveSessions),A=Pe(B=>B.showDeletionDialog),P=Pe(B=>B.setShowDeletionDialog),T=ns(B=>B.currentDirectory),L=ns(B=>B.homeDirectory),$=ns(B=>B.isHomeReady),K=Ht(B=>B.projects),F=Ht(B=>B.activeProjectId),{isMobile:W,isTablet:N,hasTouchInput:R}=zn(),E=W||N||R,X=c.useMemo(()=>{const he=(F?K.find(ve=>ve.id===F)??null:null)?.path??T;return dn(he)},[F,T,K]),J=c.useCallback(B=>{const ve=dn(B.projectDirectory)||X;return{id:(K.find(ce=>dn(ce.path)===ve)??null)?.id??`path:${ve}`,path:ve}},[X,K]),re=v&&m.size>0,fe=c.useMemo(()=>{const B=o?.worktree;return B&&typeof B.branch=="string"&&B.branch.trim().length>0?!0:a.length>0&&a.every(({metadata:he})=>typeof he.branch=="string"&&he.branch.trim().length>0)},[o?.worktree,a]),ne=o?.mode==="worktree",te=ne,ue=b||!ne||!fe,Se=b||!ne;c.useEffect(()=>{r||!$||K.length>0||(i(!0),n(!0))},[r,$,K.length]);const we=c.useCallback(B=>{l({sessions:B.sessions,dateLabel:B.dateLabel,mode:B.mode??"session",worktree:B.worktree??null})},[]),ye=c.useCallback(()=>{l(null),d([]),h(!1),x(!1),w(!1),y(!1),p(new Set)},[]),Ae=c.useCallback(async B=>{if(B.sessions.length===0)return;if(B.sessions.length===1){const ce=B.sessions[0];await j(ce.id)?Le.success(t("sessions.sidebar.session.delete.success")):Le.error(t("sessions.sidebar.session.delete.error"));return}const he=B.sessions.map(ce=>ce.id),{deletedIds:ve,failedIds:Re}=await D(he);if(ve.length>0){const ce=Re.length>0?Re.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:Re.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:Re.length}):B.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:B.dateLabel}):void 0;Le.success(ve.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:ve.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:ve.length}),{description:kn(ce)})}Re.length>0&&Le.error(Re.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Re.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:Re.length}),{description:kn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[j,D,t]);c.useEffect(()=>fn.onDeleteRequest(B=>{if(!A&&(B.mode??"session")==="session"){Ae(B);return}we(B)}),[we,A,Ae]),c.useEffect(()=>fn.onDirectoryRequest(()=>{n(!0)}),[]),c.useEffect(()=>{if(!o){d([]),h(!1),x(!1),y(!1),p(new Set);return}const B=o.sessions.map(Re=>{const ce=S(Re.id);return ce?{session:Re,metadata:ce}:null}).filter(Re=>!!Re);d(B),h(!1),y(!1),p(new Set);const he=new Map;if(o.worktree?.path&&he.set(dn(o.worktree.path),o.worktree),B.forEach(({metadata:Re})=>{Re.path&&he.set(dn(Re.path),Re)}),he.size===0){y(!0);return}let ve=!1;return(async()=>{const Re=new Map,ce=new Set;await Promise.all(Array.from(he.entries()).map(async([se,q])=>{try{const z=await Og(q.path);Re.set(se,z),z?.isDirty&&ce.add(se)}catch{q.status&&(Re.set(se,q.status),q.status.isDirty&&ce.add(se))}})).catch(se=>{console.warn("Failed to inspect worktree status before deletion:",se)}),!ve&&(p(ce),y(!0),l(se=>{if(!se?.worktree?.path)return se;const q=dn(se.worktree.path),z=Re.get(q);if(!z)return se;const ee=se.worktree.status;return ee?.isDirty===z.isDirty&&ee?.ahead===z.ahead&&ee?.behind===z.behind&&ee?.upstream===z.upstream?se:{...se,worktree:{...se.worktree,status:z}}}),d(se=>se.map(q=>{const z=dn(q.metadata.path),ee=Re.get(z);return ee?{session:q.session,metadata:{...q.metadata,status:ee}}:q})))})(),()=>{ve=!0}},[o,S]),c.useEffect(()=>{fe||h(!1)},[fe]);const pe=c.useCallback(async(B,he,ve)=>{const Re=u&&fe,ce=J(B),se=dn(B.path),q=dn(ce.path);try{await eu(ce,B,{deleteRemoteBranch:Re,deleteLocalBranch:he});const z=dn(g?.directoryOverride);return g?.open&&se&&z===se&&q&&(k(null),C({projectId:ce.id,directoryOverride:q},{force:!0})),dn(T)===se&&q&&ns.getState().setDirectory(q,{showOverlay:!1}),!0}catch(z){return Le.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:di(B)}),{id:ve,description:kn(z instanceof Error?z.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[fe,T,u,J,g?.directoryOverride,g?.open,k,C,t]),O=c.useCallback((B,he,ve)=>{const Re=u&&fe,ce=Le.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:di(B)}));(async()=>{try{if(he.length>0){const{failedIds:z}=await I(he);if(z.length>0){Le.error(z.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:z.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:z.length}),{id:ce,description:kn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))});return}}if(!await pe(B,ve,ce))return;const q=t(Re?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");Le.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:di(B)}),{id:ce,description:kn(q)})}catch(se){Le.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:ce,description:kn(se instanceof Error?se.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}})()},[I,fe,u,pe,t]),Q=c.useCallback(async()=>{if(o){w(!0);try{const B=te,he=B&&u,ve=B&&f;if(ne&&o.worktree){O(o.worktree,o.sessions.map(Re=>Re.id),ve),ye();return}if(o.sessions.length===1){const Re=o.sessions[0];if(!await j(Re.id)){Le.error(t("sessions.sidebar.session.delete.error")),w(!1);return}const se=!ne&&B?t(he?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.attachedArchived"):void 0;Le.success(t("sessions.sidebar.session.delete.success"),{description:kn(se),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const Re=o.sessions.map(z=>z.id);let ce=[],se=[];const q=await D(Re);if(ce=q.deletedIds,se=q.failedIds,ce.length>0){const z=!ne&&B?t(he?"sessions.sidebar.sessionDialogs.worktree.archivedAndRemoteRemoved":"sessions.sidebar.sessionDialogs.worktree.attachedArchivedPlural"):void 0,ae=[se.length>0?se.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:se.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:se.length}):o.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:o.dateLabel}):void 0,z].filter(Boolean).join(" ");Le.success(ce.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:ce.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:ce.length}),{description:kn(ae||void 0),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(se.length>0&&(Le.error(se.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:se.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:se.length}),{description:kn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),ce.length===0)){w(!1);return}}ye()}finally{w(!1)}}},[o,u,f,j,D,ye,te,ne,O,t]),le=o?.worktree??a[0]?.metadata??null,H=o?o.mode==="worktree"?o.sessions.length===0?t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):o.sessions.length===1?t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:o.sessions.length}):t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:o.sessions.length}):o.sessions.length===1?o.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:o.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):o.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:o.sessions.length,dateLabel:o.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:o.sessions.length}):"",me=o?s.jsxs("div",{className:Oe(ne?"space-y-3":"space-y-2"),children:[o.sessions.length>0&&s.jsxs("div",{className:Oe(ne?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[ne&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-meta font-medium text-foreground",children:o.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:o.sessions.length})]}),s.jsxs("ul",{className:Oe(ne?"mt-2 space-y-1":"space-y-0.5"),children:[o.sessions.slice(0,5).map(B=>s.jsxs("li",{className:Oe(ne?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground/80"),children:[s.jsx("span",{className:Oe(!ne&&"hidden"),children:"•"}),s.jsx("span",{className:"truncate",children:B.title||t("sessions.sidebar.session.untitled")})]},B.id)),o.sessions.length>5&&s.jsx("li",{className:Oe(ne?"px-2.5 py-1 text-xs text-muted-foreground/70":"typography-micro text-muted-foreground/70"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:o.sessions.length-5})})]})]}),ne?s.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/30 p-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(M,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-meta font-medium text-foreground",children:t("sessions.sidebar.sessionDialogs.worktree.label")}),le?.label?s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:le.label}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:le?qr(le.path,L):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),re&&s.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):s.jsx("div",{className:"rounded-xl border border-border/40 bg-sidebar/60 p-3",children:s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,ge=ne?fe?s.jsxs("button",{type:"button",onClick:()=>{ue||h(B=>!B)},disabled:ue,className:Oe("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",ue?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[u?s.jsx(M,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(M,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):s.jsx("span",{className:"text-xs text-muted-foreground/70",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,oe=ne?s.jsxs("button",{type:"button",onClick:()=>{Se||x(B=>!B)},disabled:Se,className:Oe("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",Se?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[f?s.jsx(M,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(M,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,de=ne?s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[oe,ge]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(dt,{variant:"ghost",onClick:ye,disabled:b,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(dt,{variant:"destructive",onClick:Q,disabled:b,children:t(b?"sessions.sidebar.sessionDialogs.actions.deleting":"sessions.sidebar.sessionDialogs.actions.deleteWorktree")})]})]}):s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>P(!A),className:"inline-flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-pressed":!A,children:[A?s.jsx(M,{name:"checkbox-blank",className:"size-4"}):s.jsx(M,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(dt,{variant:"ghost",onClick:ye,disabled:b,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(dt,{variant:"destructive",onClick:Q,disabled:b,children:b?t("sessions.sidebar.sessionDialogs.actions.deleting"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),_=ne?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return s.jsxs(s.Fragment,{children:[E?s.jsx(Go,{open:!!o,onClose:()=>{b||ye()},title:_,footer:s.jsx("div",{className:"flex justify-end gap-2",children:de}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[H&&s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:H}),me]})}):s.jsx(ys,{open:!!o,onOpenChange:B=>{if(!B){if(b)return;ye()}},children:s.jsxs(ws,{className:Oe(ne?"max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3":"max-w-[min(520px,100vw-2rem)] space-y-2 pb-2"),children:[s.jsxs(Vs,{children:[s.jsxs(Ps,{className:Oe(ne&&"flex items-center gap-2"),children:[ne&&s.jsx(M,{name:"delete-bin",className:"h-5 w-5"}),_]}),H&&s.jsx(Is,{children:H})]}),s.jsx("div",{className:Oe(ne&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:me}),s.jsx(bn,{className:"mt-2 gap-2 pt-1 pb-1",children:de})]})}),s.jsx(Lh,{open:e,onOpenChange:n})]})};function w4(t){const e=Ze.c(64),{t:n}=jt(),{value:r,onMoveSessionOnly:i,onMoveAllChanges:o,onCancel:l}=t,a=!!r;let d;e[0]!==l?(d=W=>{W||l()},e[0]=l,e[1]=d):d=e[1];let u;e[2]!==n?(u=n("sessions.sidebar.session.moveToWorktree.confirm.title"),e[2]=n,e[3]=u):u=e[3];let h;e[4]!==u?(h=s.jsx(Ps,{children:u}),e[4]=u,e[5]=h):h=e[5];const f=r?.dirtyFileCount??0;let x;e[6]!==n||e[7]!==f?(x=n("sessions.sidebar.session.moveToWorktree.confirm.changedFiles",{count:f}),e[6]=n,e[7]=f,e[8]=x):x=e[8];let b;e[9]!==n?(b=n("sessions.sidebar.session.moveToWorktree.confirm.ownership"),e[9]=n,e[10]=b):b=e[10];let w;e[11]!==x||e[12]!==b?(w=s.jsxs(Is,{children:[x," ",b]}),e[11]=x,e[12]=b,e[13]=w):w=e[13];let v;e[14]!==h||e[15]!==w?(v=s.jsxs(Vs,{children:[h,w]}),e[14]=h,e[15]=w,e[16]=v):v=e[16];let y;e[17]!==n?(y=n("sessions.sidebar.session.moveToWorktree.confirm.sessionOnlyHelp"),e[17]=n,e[18]=y):y=e[18];let m;e[19]!==y?(m=s.jsx("p",{children:y}),e[19]=y,e[20]=m):m=e[20];let p;e[21]!==n?(p=n("sessions.sidebar.session.moveToWorktree.confirm.allChangesHelp"),e[21]=n,e[22]=p):p=e[22];let S;e[23]!==p?(S=s.jsx("p",{children:p}),e[23]=p,e[24]=S):S=e[24];let g;e[25]!==n||e[26]!==r?(g=r&&r.stagedFileCount>0?s.jsx("p",{"data-session-worktree-move-staged-warning":"true",children:n("sessions.sidebar.session.moveToWorktree.confirm.stagedWarning")}):null,e[25]=n,e[26]=r,e[27]=g):g=e[27];let C;e[28]!==n?(C=n("sessions.sidebar.session.moveToWorktree.confirm.baseWarning"),e[28]=n,e[29]=C):C=e[29];let k;e[30]!==C?(k=s.jsx("p",{children:C}),e[30]=C,e[31]=k):k=e[31];let j;e[32]!==m||e[33]!==S||e[34]!==g||e[35]!==k?(j=s.jsxs("div",{className:"space-y-2 typography-ui-label text-muted-foreground",children:[m,S,g,k]}),e[32]=m,e[33]=S,e[34]=g,e[35]=k,e[36]=j):j=e[36];let D;e[37]!==n?(D=n("sessions.sidebar.session.moveToWorktree.confirm.cancel"),e[37]=n,e[38]=D):D=e[38];let I;e[39]!==l||e[40]!==D?(I=s.jsx(dt,{type:"button",variant:"neutral","data-session-worktree-move-action":"cancel",onClick:l,children:D}),e[39]=l,e[40]=D,e[41]=I):I=e[41];let A;e[42]!==n?(A=n("sessions.sidebar.session.moveToWorktree.confirm.allChanges"),e[42]=n,e[43]=A):A=e[43];let P;e[44]!==o||e[45]!==A?(P=s.jsx(dt,{type:"button",variant:"outline","data-session-worktree-move-action":"all-changes",onClick:o,children:A}),e[44]=o,e[45]=A,e[46]=P):P=e[46];let T;e[47]!==n?(T=n("sessions.sidebar.session.moveToWorktree.confirm.sessionOnly"),e[47]=n,e[48]=T):T=e[48];let L;e[49]!==i||e[50]!==T?(L=s.jsx(dt,{type:"button",autoFocus:!0,"data-session-worktree-move-action":"session-only",onClick:i,children:T}),e[49]=i,e[50]=T,e[51]=L):L=e[51];let $;e[52]!==I||e[53]!==P||e[54]!==L?($=s.jsxs(bn,{className:"gap-2 sm:justify-end",children:[I,P,L]}),e[52]=I,e[53]=P,e[54]=L,e[55]=$):$=e[55];let K;e[56]!==j||e[57]!==$||e[58]!==v?(K=s.jsxs(ws,{id:"session-worktree-move-confirm-dialog",showCloseButton:!1,className:"max-w-md gap-5",children:[v,j,$]}),e[56]=j,e[57]=$,e[58]=v,e[59]=K):K=e[59];let F;return e[60]!==a||e[61]!==d||e[62]!==K?(F=s.jsx(ys,{open:a,onOpenChange:d,children:K}),e[60]=a,e[61]=d,e[62]=K,e[63]=F):F=e[63],F}function Jf(t){if(!t||!t.trim())return{valid:!1,error:"required"};try{return Yu.CronExpressionParser.parse(t),{valid:!0}}catch(e){return{valid:!1,error:e instanceof Error?e.message:"Invalid cron expression"}}}function v4(t,e,n=4){try{const r=e?{tz:e,currentDate:new Date}:{currentDate:new Date},i=Yu.CronExpressionParser.parse(t,r),o=[];for(let l=0;l<n;l+=1){const a=i.next();a&&o.push(a.toDate())}return o}catch{return[]}}const S4=[{expression:"*/5 * * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.every5min"},{expression:"0 * * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.everyHour"},{expression:"0 9 * * 1",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.monday9am"},{expression:"0 9,17 * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.9am5pm"},{expression:"0 0 1 * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.firstOfMonth"}],j4={"Europe/Kiev":"Europe/Kyiv","Asia/Calcutta":"Asia/Kolkata","Asia/Saigon":"Asia/Ho_Chi_Minh","Asia/Rangoon":"Asia/Yangon","Asia/Katmandu":"Asia/Kathmandu","America/Godthab":"America/Nuuk","Atlantic/Faeroe":"Atlantic/Faroe","Pacific/Enderbury":"Pacific/Kanton"},Jn=t=>j4[t]??t,Zf=[0,1,2,3,4,5,6],od="flex h-6 w-6 cursor-pointer items-center justify-center text-foreground transition-none outline-none focus:outline-none flex-shrink-0",pa=typeof Intl<"u"&&typeof Intl.supportedValuesOf=="function"?[...new Set(Intl.supportedValuesOf("timeZone").map(Jn))]:["UTC","Europe/Kyiv","Europe/London","Europe/Berlin","America/New_York","America/Los_Angeles","Asia/Tokyo"],id=()=>{const t=new Date,e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`},Co=t=>{const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!e)return null;const n=Number(e[1]),r=Number(e[2]),i=Number(e[3]),o=new Date(n,r-1,i);return Number.isNaN(o.getTime())||o.getFullYear()!==n||o.getMonth()!==r-1||o.getDate()!==i?null:o},ad=t=>{const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`},k4=(t,e,n)=>{const r=Co(t);return r?new Intl.DateTimeFormat(n,{month:"short",day:"numeric",year:"numeric"}).format(r):e},ld=(t,e)=>new Date(t.getFullYear(),t.getMonth()+e,1),C4=(t,e)=>{const n=t.getFullYear(),r=t.getMonth(),l=(new Date(n,r,1).getDay()-e+7)%7,a=new Date(n,r+1,0).getDate(),d=new Date(n,r,0).getDate(),u=[];for(let h=0;h<42;h+=1){const f=h-l+1;if(f<=0){const x=d+f;u.push({date:new Date(n,r-1,x),inCurrentMonth:!1});continue}if(f>a){u.push({date:new Date(n,r+1,f-a),inCurrentMonth:!1});continue}u.push({date:new Date(n,r,f),inCurrentMonth:!0})}return u},N4=t=>{const e=/^([01]\d|2[0-3]):([0-5]\d)$/.exec(t);if(!e)return{hour24:"00",hour12:"12",minute:"00",meridiem:"AM"};const n=Number(e[1]),r=e[2],i=n>=12?"PM":"AM",o=n%12===0?12:n%12;return{hour24:String(n).padStart(2,"0"),hour12:String(o).padStart(2,"0"),minute:r,meridiem:i}},Gn=(t,e,n)=>{const r=Number(t),i=Number(e),o=Number.isFinite(r)?Math.min(12,Math.max(1,r)):12,l=Number.isFinite(i)?Math.min(59,Math.max(0,i)):0;let a=o%12;return n==="PM"&&(a+=12),`${String(a).padStart(2,"0")}:${String(l).padStart(2,"0")}`},Cr=(t,e)=>{const{max:n,min:r=0,loop:i=!1}=e;let o=Number.parseInt(t,10);return Number.isFinite(o)?(i?(o>n&&(o=r),o<r&&(o=n)):(o>n&&(o=n),o<r&&(o=r)),String(o).padStart(2,"0")):"00"},cd=t=>/^(0[1-9]|1[0-2])$/.test(t)?t:Cr(t,{min:1,max:12}),xo=t=>/^[0-5][0-9]$/.test(t)?t:Cr(t,{max:59}),A4=(t,e)=>Cr(String(Number.parseInt(t,10)+e),{min:1,max:12,loop:!0}),dd=(t,e)=>Cr(String(Number.parseInt(t,10)+e),{min:0,max:59,loop:!0}),D4=t=>{try{const e=Intl.Locale;if(typeof e!="function")return 1;const r=new e(t).weekInfo?.firstDay;return typeof r!="number"?1:r%7}catch{return 1}},P4=t=>{try{const e=new Intl.DateTimeFormat(t,{hour:"numeric"}).resolvedOptions();return typeof e.hour12=="boolean"?!e.hour12:e.hourCycle==="h23"||e.hourCycle==="h24"}catch{return!0}},I4=t=>{const e=new Intl.DateTimeFormat(t,{weekday:"short"}),n=new Date(2023,0,1);return Zf.map(r=>e.format(new Date(n.getFullYear(),n.getMonth(),n.getDate()+r)))},T4=(t,e)=>[...t.slice(e),...t.slice(0,e)],Ms=t=>{const e=Ze.c(6),{htmlFor:n,required:r,children:i}=t;let o;e[0]!==r?(o=r&&s.jsx("span",{className:"ml-0.5 text-destructive",children:"*"}),e[0]=r,e[1]=o):o=e[1];let l;return e[2]!==i||e[3]!==n||e[4]!==o?(l=s.jsx("div",{className:"flex items-center gap-1.5",children:s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[i,o]})}),e[2]=i,e[3]=n,e[4]=o,e[5]=l):l=e[5],l},ud=t=>{const e=Ze.c(84),{value:n,onChange:r,use24Hour:i,hourAriaLabel:o,minuteAriaLabel:l,periodAriaLabel:a,amLabel:d,pmLabel:u}=t;let h;e[0]!==n?(h=N4(n),e[0]=n,e[1]=h):h=e[1];const f=h,x=mt.useRef(null),b=mt.useRef(null),[w,v]=mt.useState(null),[y,m]=mt.useState(null),p=mt.useRef(null),S=mt.useRef(null);let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=B=>{p.current=B,v(B)},e[2]=g):g=e[2];const C=g;let k;e[3]===Symbol.for("react.memo_cache_sentinel")?(k=B=>{S.current=B,m(B)},e[3]=k):k=e[3];const j=k,D=_4,I=L4,A=$4;let P;e[4]!==r||e[5]!==f.meridiem||e[6]!==f.minute||e[7]!==i?(P=B=>{const he=B.replace(/\D/g,"").slice(0,2);C(he),he.length===2&&(r(i?A(D(he),f.minute):Gn(cd(he),f.minute,f.meridiem)),C(null),b.current?.focus())},e[4]=r,e[5]=f.meridiem,e[6]=f.minute,e[7]=i,e[8]=P):P=e[8];const T=P;let L;e[9]!==r||e[10]!==f.meridiem||e[11]!==f.minute||e[12]!==i?(L=()=>{const B=p.current;if(B!==null&&(C(null),B.length!==0)){if(i){r(A(D(B.padStart(2,"0")),f.minute));return}r(Gn(cd(B.padStart(2,"0")),f.minute,f.meridiem))}},e[9]=r,e[10]=f.meridiem,e[11]=f.minute,e[12]=i,e[13]=L):L=e[13];const $=L;let K;e[14]!==r||e[15]!==f.hour12||e[16]!==f.hour24||e[17]!==f.meridiem||e[18]!==i?(K=B=>{const he=B.replace(/\D/g,"").slice(0,2);j(he),he.length===2&&(r(i?A(f.hour24,xo(he)):Gn(f.hour12,xo(he),f.meridiem)),j(null))},e[14]=r,e[15]=f.hour12,e[16]=f.hour24,e[17]=f.meridiem,e[18]=i,e[19]=K):K=e[19];const F=K;let W;e[20]!==r||e[21]!==f.hour12||e[22]!==f.hour24||e[23]!==f.meridiem||e[24]!==i?(W=()=>{const B=S.current;B!==null&&(j(null),B.length!==0&&r(i?A(f.hour24,xo(B.padStart(2,"0"))):Gn(f.hour12,xo(B.padStart(2,"0")),f.meridiem)))},e[20]=r,e[21]=f.hour12,e[22]=f.hour24,e[23]=f.meridiem,e[24]=i,e[25]=W):W=e[25];const N=W;let R;e[26]!==r||e[27]!==f.hour12||e[28]!==f.hour24||e[29]!==f.meridiem||e[30]!==f.minute||e[31]!==i?(R=B=>r(i?A(I(f.hour24,B),f.minute):Gn(A4(f.hour12,B),f.minute,f.meridiem)),e[26]=r,e[27]=f.hour12,e[28]=f.hour24,e[29]=f.meridiem,e[30]=f.minute,e[31]=i,e[32]=R):R=e[32];const E=R;let X;e[33]!==r||e[34]!==f.hour12||e[35]!==f.hour24||e[36]!==f.meridiem||e[37]!==f.minute||e[38]!==i?(X=B=>r(i?A(f.hour24,dd(f.minute,B)):Gn(f.hour12,dd(f.minute,B),f.meridiem)),e[33]=r,e[34]=f.hour12,e[35]=f.hour24,e[36]=f.meridiem,e[37]=f.minute,e[38]=i,e[39]=X):X=e[39];const J=X;let re;e[40]!==r||e[41]!==f.hour12||e[42]!==f.meridiem||e[43]!==f.minute?(re=B=>{B!==f.meridiem&&r(Gn(f.hour12,f.minute,B))},e[40]=r,e[41]=f.hour12,e[42]=f.meridiem,e[43]=f.minute,e[44]=re):re=e[44];const fe=re;let ne;e[45]!==$||e[46]!==E?(ne=B=>{if(B.key==="ArrowRight"){B.preventDefault(),$(),b.current?.focus();return}(B.key==="ArrowUp"||B.key==="ArrowDown")&&(B.preventDefault(),C(null),E(B.key==="ArrowUp"?1:-1))},e[45]=$,e[46]=E,e[47]=ne):ne=e[47];const te=ne;let ue;e[48]!==N||e[49]!==J?(ue=B=>{if(B.key==="ArrowLeft"&&(B.currentTarget.selectionStart??0)===0){B.preventDefault(),N(),x.current?.focus();return}(B.key==="ArrowUp"||B.key==="ArrowDown")&&(B.preventDefault(),j(null),J(B.key==="ArrowUp"?1:-1))},e[48]=N,e[49]=J,e[50]=ue):ue=e[50];const Se=ue,we=i?"px-2":"pl-2 pr-1";let ye;e[51]!==we?(ye=Oe("oc-surface-elevated inline-flex h-9 w-fit items-center gap-1 rounded-md border border-border bg-surface-elevated focus-within:ring-1 focus-within:ring-ring focus-within:border-ring",we),e[51]=we,e[52]=ye):ye=e[52];const Ae=w??(i?f.hour24:f.hour12);let pe;e[53]!==T?(pe=B=>T(B.target.value),e[53]=T,e[54]=pe):pe=e[54];let O;e[55]===Symbol.for("react.memo_cache_sentinel")?(O=()=>C(""),e[55]=O):O=e[55];let Q;e[56]!==$||e[57]!==o||e[58]!==te||e[59]!==Ae||e[60]!==pe?(Q=s.jsx("input",{ref:x,inputMode:"numeric",value:Ae,onChange:pe,onKeyDown:te,onFocus:O,onBlur:$,maxLength:2,"aria-label":o,className:"h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover"}),e[56]=$,e[57]=o,e[58]=te,e[59]=Ae,e[60]=pe,e[61]=Q):Q=e[61];let le;e[62]===Symbol.for("react.memo_cache_sentinel")?(le=s.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:":"}),e[62]=le):le=e[62];const H=y??f.minute;let me;e[63]!==F?(me=B=>F(B.target.value),e[63]=F,e[64]=me):me=e[64];let ge;e[65]===Symbol.for("react.memo_cache_sentinel")?(ge=()=>j(""),e[65]=ge):ge=e[65];let oe;e[66]!==N||e[67]!==l||e[68]!==Se||e[69]!==H||e[70]!==me?(oe=s.jsx("input",{ref:b,inputMode:"numeric",value:H,onChange:me,onKeyDown:Se,onFocus:ge,onBlur:N,maxLength:2,"aria-label":l,className:"h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover"}),e[66]=N,e[67]=l,e[68]=Se,e[69]=H,e[70]=me,e[71]=oe):oe=e[71];let de;e[72]!==d||e[73]!==f.meridiem||e[74]!==a||e[75]!==u||e[76]!==fe||e[77]!==i?(de=i?null:s.jsxs(Bs,{value:f.meridiem,onValueChange:B=>fe(B),children:[s.jsx(Fs,{"aria-label":a,className:"ml-1 h-7 w-fit border-0 bg-transparent pl-2 pr-1 shadow-none hover:bg-interactive-hover focus:ring-0",children:s.jsx(ks,{})}),s.jsxs(_s,{children:[s.jsx(ss,{value:"AM",children:d}),s.jsx(ss,{value:"PM",children:u})]})]}),e[72]=d,e[73]=f.meridiem,e[74]=a,e[75]=u,e[76]=fe,e[77]=i,e[78]=de):de=e[78];let _;return e[79]!==ye||e[80]!==Q||e[81]!==oe||e[82]!==de?(_=s.jsxs("div",{className:ye,children:[Q,le,oe,de]}),e[79]=ye,e[80]=Q,e[81]=oe,e[82]=de,e[83]=_):_=e[83],_},fd=t=>new Date(t.getFullYear(),t.getMonth(),1),E4=()=>{const t=new Date;return new Date(t.getFullYear(),t.getMonth(),t.getDate())},md=(t,e)=>t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate(),R4=t=>{if(!t)return["09:00"];const n=(Array.isArray(t.schedule.times)?t.schedule.times:t.schedule.time?[t.schedule.time]:[]).filter(i=>typeof i=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(i)).map(i=>i.trim()),r=Array.from(new Set(n)).sort((i,o)=>i.localeCompare(o));return r.length>0?r:["09:00"]},hd=(t,e)=>{const n=Jn(Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC");return t?{id:t.id,name:t.name,enabled:t.enabled,schedule:{kind:t.schedule.kind==="cron"?"cron":t.schedule.kind==="once"?"once":t.schedule.kind==="weekly"?"weekly":"daily",times:R4(t),onceDate:typeof t.schedule.date=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t.schedule.date)?t.schedule.date:id(),onceTime:typeof t.schedule.time=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(t.schedule.time)?t.schedule.time:"09:00",weekdays:Array.isArray(t.schedule.weekdays)?t.schedule.weekdays:[1],timezone:Jn(t.schedule.timezone||n),cronExpression:t.schedule.kind==="cron"&&typeof t.schedule.cron=="string"?t.schedule.cron:""},execution:{prompt:t.execution.prompt,providerID:t.execution.providerID,modelID:t.execution.modelID,variant:t.execution.variant||"",agent:t.execution.agent||"",goalEnabled:t.execution.goalEnabled===!0,goalTokenBudget:typeof t.execution.goalTokenBudget=="number"&&t.execution.goalTokenBudget>0?t.execution.goalTokenBudget:null,permissionAutoAccept:t.execution.permissionAutoAccept===!0},state:t.state}:{name:"",enabled:!0,schedule:{kind:"daily",times:["09:00"],onceDate:id(),onceTime:"09:00",weekdays:[1],timezone:n,cronExpression:""},execution:{prompt:"",providerID:e.providerID,modelID:e.modelID,variant:e.variant,agent:e.agent,goalEnabled:!1,goalTokenBudget:null,permissionAutoAccept:!1}}},M4=(t,e)=>{if(!t.name.trim())return e("sessions.scheduledTasks.editor.validation.taskNameRequired");if(!t.execution.prompt.trim())return e("sessions.scheduledTasks.editor.validation.promptRequired");if(!t.execution.providerID.trim()||!t.execution.modelID.trim())return e("sessions.scheduledTasks.editor.validation.modelRequired");if(t.schedule.kind==="once"){if(!/^\d{4}-\d{2}-\d{2}$/.test(t.schedule.onceDate))return e("sessions.scheduledTasks.editor.validation.dateFormat");if(!/^([01]\d|2[0-3]):([0-5]\d)$/.test(t.schedule.onceTime))return e("sessions.scheduledTasks.editor.validation.timeFormat")}else if(t.schedule.kind==="cron"){if(!t.schedule.cronExpression.trim())return e("sessions.scheduledTasks.editor.validation.cronRequired");if(!Jf(t.schedule.cronExpression).valid)return e("sessions.scheduledTasks.editor.validation.cronInvalid")}else if(t.schedule.times.filter(r=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(r)).length===0)return e("sessions.scheduledTasks.editor.validation.atLeastOneTime");return t.schedule.kind==="weekly"&&t.schedule.weekdays.length===0?e("sessions.scheduledTasks.editor.validation.atLeastOneWeekday"):t.schedule.timezone.trim()?null:e("sessions.scheduledTasks.editor.validation.timezoneRequired")},O4=t=>{const e=t.filter(n=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(n));return Array.from(new Set(e)).sort((n,r)=>n.localeCompare(r))},B4=t=>{const e=Ze.c(64),{draft:n,setDraft:r,locale:i,t:o}=t,l=n.schedule.cronExpression;let a;e[0]!==l?(a=l.trim()?Jf(l):null,e[0]=l,e[1]=a):a=e[1];const d=a;let u;e:{if(!d?.valid||!l.trim()){let R;e[2]===Symbol.for("react.memo_cache_sentinel")?(R=[],e[2]=R):R=e[2],u=R;break e}let N;e[3]!==l||e[4]!==n.schedule.timezone?(N=v4(l,n.schedule.timezone),e[3]=l,e[4]=n.schedule.timezone,e[5]=N):N=e[5],u=N}const h=u;let f;e[6]!==n.schedule.timezone||e[7]!==i?(f=N=>new Intl.DateTimeFormat(i,{timeZone:n.schedule.timezone,month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(N),e[6]=n.schedule.timezone,e[7]=i,e[8]=f):f=e[8];const x=f;let b;e[9]!==o?(b=o("sessions.scheduledTasks.editor.cronExpression.label"),e[9]=o,e[10]=b):b=e[10];let w;e[11]!==b?(w=s.jsx(Ms,{htmlFor:"sched-cron",required:!0,children:b}),e[11]=b,e[12]=w):w=e[12];let v;e[13]!==r?(v=N=>r(R=>({...R,schedule:{...R.schedule,cronExpression:N.target.value}})),e[13]=r,e[14]=v):v=e[14];let y;e[15]!==o?(y=o("sessions.scheduledTasks.editor.cronExpression.placeholder"),e[15]=o,e[16]=y):y=e[16];let m;e[17]!==l||e[18]!==v||e[19]!==y?(m=s.jsx(An,{id:"sched-cron",value:l,onChange:v,placeholder:y,className:"w-full max-w-xs font-mono"}),e[17]=l,e[18]=v,e[19]=y,e[20]=m):m=e[20];let p;e[21]!==l||e[22]!==d||e[23]!==o?(p=d&&!d.valid&&l.trim()?s.jsx("span",{className:"typography-micro text-destructive",children:o("sessions.scheduledTasks.editor.validation.cronInvalid")}):null,e[21]=l,e[22]=d,e[23]=o,e[24]=p):p=e[24];let S;e[25]!==w||e[26]!==m||e[27]!==p?(S=s.jsxs("div",{className:"flex flex-col gap-1",children:[w,m,p]}),e[25]=w,e[26]=m,e[27]=p,e[28]=S):S=e[28];let g;e[29]!==x||e[30]!==h||e[31]!==o?(g=h.length>0?s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:o("sessions.scheduledTasks.editor.cronExpression.nextRuns")}),s.jsx("span",{className:"typography-micro text-foreground",children:h.map(x).join(", ")})]}):null,e[29]=x,e[30]=h,e[31]=o,e[32]=g):g=e[32];let C;e[33]!==o?(C=o("sessions.scheduledTasks.editor.cronExpression.examples"),e[33]=o,e[34]=C):C=e[34];let k;e[35]!==C?(k=s.jsx("span",{className:"typography-meta text-muted-foreground",children:C}),e[35]=C,e[36]=k):k=e[36];let j;e[37]!==r||e[38]!==o?(j=S4.map(N=>s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 typography-micro text-foreground hover:bg-interactive-hover",onClick:()=>r(R=>({...R,schedule:{...R.schedule,cronExpression:N.expression}})),children:[s.jsx("span",{className:"font-mono",children:N.expression}),s.jsx("span",{className:"text-muted-foreground",children:o(N.labelKey)})]},N.expression)),e[37]=r,e[38]=o,e[39]=j):j=e[39];let D;e[40]!==j?(D=s.jsx("div",{className:"flex flex-wrap gap-1.5",children:j}),e[40]=j,e[41]=D):D=e[41];let I;e[42]!==k||e[43]!==D?(I=s.jsxs("div",{className:"flex flex-col gap-1",children:[k,D]}),e[42]=k,e[43]=D,e[44]=I):I=e[44];let A;e[45]!==o?(A=o("sessions.scheduledTasks.editor.timezone.label"),e[45]=o,e[46]=A):A=e[46];let P;e[47]!==A?(P=s.jsx(Ms,{children:A}),e[47]=A,e[48]=P):P=e[48];let T;e[49]!==r?(T=N=>{r(R=>({...R,schedule:{...R.schedule,timezone:N}}))},e[49]=r,e[50]=T):T=e[50];let L;e[51]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx(Fs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(ks,{})}),e[51]=L):L=e[51];let $;e[52]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx(_s,{children:pa.map(z4)}),e[52]=$):$=e[52];let K;e[53]!==n.schedule.timezone||e[54]!==T?(K=s.jsxs(Bs,{value:n.schedule.timezone,onValueChange:T,children:[L,$]}),e[53]=n.schedule.timezone,e[54]=T,e[55]=K):K=e[55];let F;e[56]!==P||e[57]!==K?(F=s.jsxs("div",{className:"flex flex-col gap-1",children:[P,K]}),e[56]=P,e[57]=K,e[58]=F):F=e[58];let W;return e[59]!==S||e[60]!==g||e[61]!==I||e[62]!==F?(W=s.jsxs("div",{className:"flex flex-col gap-3",children:[S,g,I,F]}),e[59]=S,e[60]=g,e[61]=I,e[62]=F,e[63]=W):W=e[63],W};function F4(t){const{open:e,task:n,onOpenChange:r,onSave:i}=t,{t:o,locale:l}=jt(),a=Gt(V=>V.loadProviders),d=Gt(V=>V.loadAgents),u=Gt(V=>V.providers),h=Gt(V=>V.currentProviderId),f=Gt(V=>V.currentModelId),x=Gt(V=>V.currentVariant||""),b=Gt(V=>V.currentAgentName||""),w=Pe(V=>V.timeFormatPreference),v=Pe(V=>V.weekStartPreference),y=Pe(V=>V.isMobile),[m,p]=mt.useState(()=>hd(n,{providerID:h,modelID:f,variant:x,agent:b})),[S,g]=mt.useState(!1),[C,k]=mt.useState(!1),[j,D]=mt.useState(!1),[I,A]=mt.useState(""),[P,T]=mt.useState(!1),[L,$]=mt.useState(""),[K,F]=mt.useState(!1),[W,N]=mt.useState(""),[R,E]=mt.useState(()=>{const V=Co(n?.schedule?.date||"")||new Date;return new Date(V.getFullYear(),V.getMonth(),1)}),X=mt.useRef(null),J=mt.useRef(null),re=mt.useRef(null),fe=mt.useRef(null),ne=mt.useRef(null),te=mt.useMemo(()=>P4(l),[l]),ue=mt.useMemo(()=>D4(l),[l]),Se=mt.useMemo(()=>w==="24h"?!0:w==="12h"?!1:te,[w,te]),we=mt.useMemo(()=>v==="sunday"?0:v==="monday"?1:ue,[v,ue]),ye=mt.useMemo(()=>{const V=I4(l);return T4(Zf.map(De=>({value:De,label:V[De]||""})),we)},[l,we]);mt.useEffect(()=>{e&&(a({source:"scheduledTaskEditor"}),d({source:"scheduledTaskEditor"}))},[e,a,d]),mt.useEffect(()=>{if(!e)return;p(hd(n,{providerID:h,modelID:f,variant:x,agent:b}));const V=Co(n?.schedule?.date||"")||new Date;E(new Date(V.getFullYear(),V.getMonth(),1)),k(!1),T(!1),D(!1),$(""),A("")},[e,n,h,f,x,b]),mt.useEffect(()=>{if(!C)return;const V=De=>{X.current&&!X.current.contains(De.target)&&k(!1)};return document.addEventListener("mousedown",V),()=>{document.removeEventListener("mousedown",V)}},[C]);const Ae=mt.useMemo(()=>{const De=u.find(Fe=>Fe.id===m.execution.providerID)?.models?.find(Fe=>Fe.id===m.execution.modelID);return De?.variants?Object.keys(De.variants):[]},[u,m.execution.providerID,m.execution.modelID]),pe=Ae.length>0,O=mt.useMemo(()=>!pe||!m.execution.variant?"__default":Ae.includes(m.execution.variant)?m.execution.variant:"__default",[m.execution.variant,pe,Ae]);mt.useEffect(()=>{pe||!m.execution.variant||p(V=>({...V,execution:{...V.execution,variant:""}}))},[pe,m.execution.variant]);const Q=mt.useCallback((V,De)=>{p(Fe=>{const _e=new Set(Fe.schedule.weekdays);return De?_e.add(V):_e.delete(V),{...Fe,schedule:{...Fe.schedule,weekdays:Array.from(_e).sort((rt,ct)=>rt-ct)}}})},[]),le=mt.useCallback((V,De)=>{p(Fe=>{const _e=Fe.schedule.times.slice();return _e[V]=De,{...Fe,schedule:{...Fe.schedule,times:_e}}})},[]),H=mt.useCallback(V=>{p(De=>{const Fe=De.schedule.times.filter((_e,rt)=>rt!==V);return{...De,schedule:{...De.schedule,times:Fe.length>0?Fe:["09:00"]}}})},[]),me=mt.useCallback(()=>{p(V=>({...V,schedule:{...V.schedule,times:[...V.schedule.times,"12:00"]}}))},[]),ge=mt.useMemo(()=>E4(),[]),oe=mt.useMemo(()=>fd(ge),[ge]),de=mt.useMemo(()=>{const V=Co(m.schedule.onceDate);return V?md(V,ge)?o("sessions.scheduledTasks.editor.date.today"):new Intl.DateTimeFormat(l,{weekday:"short"}).format(V):null},[m.schedule.onceDate,l,o,ge]),_=mt.useMemo(()=>fd(R).getTime()<=oe.getTime(),[R,oe]),B=mt.useMemo(()=>ye.map(V=>V.label),[ye]),he=mt.useCallback(V=>{p(De=>({...De,schedule:{...De.schedule,onceDate:V}}))},[]),ve=mt.useCallback((V,De)=>{if(V.startsWith("/")){const ct=V.indexOf(" "),et=V.indexOf(`
|
|
890
|
-
`),pt=Math.min(ct===-1?V.length:ct,et===-1?V.length:et);if(De<=pt&&ct===-1){$(V.substring(1,pt)),T(!0),D(!1),F(!1);return}}T(!1);const Fe=V.substring(0,De),_e=Fe.lastIndexOf("#");if(_e!==-1){const ct=_e>0?Fe[_e-1]:null,et=Fe.substring(_e+1);if((!ct||/\s/.test(ct))&&!et.includes(" ")&&!et.includes(`
|
|
891
|
-
`)){N(et),F(!0),D(!1);return}}F(!1);const rt=Fe.lastIndexOf("@");if(rt!==-1){const ct=rt>0?Fe[rt-1]:null,et=Fe.substring(rt+1);(!ct||/\s/.test(ct))&&!et.includes(" ")&&!et.includes(`
|
|
892
|
-
`)?(A(et),D(!0)):D(!1);return}D(!1)},[]),Re=mt.useCallback(V=>{p(De=>({...De,execution:{...De.execution,prompt:V}}))},[]),ce=mt.useCallback(V=>{const De=m.execution.prompt,_e=J.current?.selectionStart??De.length,ct=De.substring(0,_e).lastIndexOf("@"),et=V.relativePath&&V.relativePath.trim().length>0?V.relativePath.trim():V.path||V.name,pt=ct!==-1?ct:_e,kt=`${De.substring(0,pt)}@${et} ${De.substring(_e)}`,wt=pt+et.length+2;Re(kt),D(!1),A(""),requestAnimationFrame(()=>{const Xe=J.current;Xe&&(Xe.selectionStart=wt,Xe.selectionEnd=wt,Xe.focus()),ve(kt,wt)})},[m.execution.prompt,Re,ve]),se=mt.useCallback(V=>{const De=m.execution.prompt,_e=J.current?.selectionStart??De.length,ct=De.substring(0,_e).lastIndexOf("@"),et=ct!==-1?ct:_e,pt=`${De.substring(0,et)}@${V} ${De.substring(_e)}`,kt=et+V.length+2;Re(pt),D(!1),A(""),requestAnimationFrame(()=>{const wt=J.current;wt&&(wt.selectionStart=kt,wt.selectionEnd=kt,wt.focus()),ve(pt,kt)})},[m.execution.prompt,Re,ve]),q=mt.useCallback(V=>{const De=`/${V.name} `;Re(De),T(!1),$(""),F(!1),requestAnimationFrame(()=>{const Fe=J.current;Fe&&(Fe.focus(),Fe.selectionStart=Fe.value.length,Fe.selectionEnd=Fe.value.length),ve(De,De.length)})},[Re,ve]),z=mt.useCallback((V,De)=>{const Fe=m.execution.prompt,rt=J.current?.selectionStart??Fe.length,et=Fe.substring(0,rt).lastIndexOf("#"),pt=et!==-1?et:rt,kt=`${Fe.substring(0,pt)}#${De} ${Fe.substring(rt)}`,wt=pt+De.length+2;Re(kt),F(!1),N(""),requestAnimationFrame(()=>{const Xe=J.current;Xe&&(Xe.selectionStart=wt,Xe.selectionEnd=wt,Xe.focus()),ve(kt,wt)})},[m.execution.prompt,Re,ve]),ee=mt.useCallback(V=>{if(P&&fe.current&&(V.key==="Enter"||V.key==="ArrowUp"||V.key==="ArrowDown"||V.key==="Escape"||V.key==="Tab")){V.preventDefault(),fe.current.handleKeyDown(V.key);return}j&&re.current&&(V.key==="Enter"||V.key==="ArrowUp"||V.key==="ArrowDown"||V.key==="Escape"||V.key==="Tab")&&(V.preventDefault(),re.current.handleKeyDown(V.key)),K&&ne.current&&(V.key==="Enter"||V.key==="ArrowUp"||V.key==="ArrowDown"||V.key==="Escape"||V.key==="Tab")&&(V.preventDefault(),ne.current.handleKeyDown(V.key))},[P,j,K]),ae=mt.useCallback(async()=>{const V=M4(m,o);if(V){Le.error(V);return}const De={...m.id?{id:m.id}:{},name:m.name.trim(),enabled:m.enabled,schedule:{kind:m.schedule.kind,timezone:m.schedule.timezone.trim(),...m.schedule.kind==="cron"?{cron:m.schedule.cronExpression.trim()}:m.schedule.kind==="once"?{date:m.schedule.onceDate,time:m.schedule.onceTime}:{times:O4(m.schedule.times),...m.schedule.kind==="weekly"?{weekdays:m.schedule.weekdays}:{}}},execution:{prompt:m.execution.prompt,providerID:m.execution.providerID,modelID:m.execution.modelID,...m.execution.variant.trim()?{variant:m.execution.variant.trim()}:{},...m.execution.agent.trim()?{agent:m.execution.agent.trim()}:{},...m.execution.permissionAutoAccept?{permissionAutoAccept:!0}:{},...m.execution.goalEnabled?{goalEnabled:!0}:{},...m.execution.goalEnabled&&m.execution.goalTokenBudget?{goalTokenBudget:m.execution.goalTokenBudget}:{}},...m.state?{state:m.state}:{}};g(!0);try{await i(De),r(!1)}catch(Fe){Le.error(Fe instanceof Error?Fe.message:o("sessions.scheduledTasks.editor.toast.saveFailed"))}finally{g(!1)}},[m,r,i,o]),Ne=mt.useId(),Ce=mt.useCallback(()=>typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]'),[]),We=o(n?"sessions.scheduledTasks.editor.title.edit":"sessions.scheduledTasks.editor.title.new"),Ee=o("sessions.scheduledTasks.editor.description"),xe=s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ms,{htmlFor:"sched-name",required:!0,children:o("sessions.scheduledTasks.editor.taskName.label")}),s.jsx(An,{id:"sched-name",value:m.name,onChange:V=>p(De=>({...De,name:V.target.value})),placeholder:o("sessions.scheduledTasks.editor.taskName.placeholder"),maxLength:80,className:"w-full sm:max-w-[220px]"})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.scheduleType.label")}),s.jsxs(Bs,{value:m.schedule.kind,onValueChange:V=>{p(De=>({...De,schedule:{...De.schedule,kind:V,...V==="cron"&&!De.schedule.cronExpression?{cronExpression:"0 * * * *"}:{}}}))},children:[s.jsx(Fs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(ks,{children:V=>o(V==="daily"?"sessions.scheduledTasks.editor.scheduleType.daily":V==="weekly"?"sessions.scheduledTasks.editor.scheduleType.weekly":V==="cron"?"sessions.scheduledTasks.editor.scheduleType.cron":"sessions.scheduledTasks.editor.scheduleType.once")})}),s.jsxs(_s,{children:[s.jsx(ss,{value:"daily",children:o("sessions.scheduledTasks.editor.scheduleType.daily")}),s.jsx(ss,{value:"weekly",children:o("sessions.scheduledTasks.editor.scheduleType.weekly")}),s.jsx(ss,{value:"once",children:o("sessions.scheduledTasks.editor.scheduleType.once")}),s.jsx(ss,{value:"cron",children:o("sessions.scheduledTasks.editor.scheduleType.cron")})]})]})]})]}),m.schedule.kind==="cron"?s.jsx(B4,{draft:m,setDraft:p,locale:l,t:o}):m.schedule.kind==="once"?s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",ref:X,children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.date.label")}),s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",className:Oe(Pu({size:"default"}),"w-fit max-w-full"),onClick:()=>k(V=>!V),children:[s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(M,{name:"calendar",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:k4(m.schedule.onceDate,o("sessions.scheduledTasks.editor.date.placeholder"),l)})]}),s.jsx(M,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"})]}),C?s.jsxs("div",{className:"oc-surface-elevated absolute left-0 top-[calc(100%+6px)] z-50 w-[288px] rounded-xl border border-border bg-surface-elevated p-3 shadow-sm",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover disabled:cursor-not-allowed disabled:opacity-40",onClick:()=>E(V=>ld(V,-1)),"aria-label":o("sessions.scheduledTasks.editor.date.previousMonth"),disabled:_,children:s.jsx(M,{name:"arrow-left-s",className:"h-4 w-4"})}),s.jsx("div",{className:"typography-ui-label text-foreground",children:new Intl.DateTimeFormat(l,{month:"long",year:"numeric"}).format(R)}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover",onClick:()=>E(V=>ld(V,1)),"aria-label":o("sessions.scheduledTasks.editor.date.nextMonth"),children:s.jsx(M,{name:"arrow-right-s",className:"h-4 w-4"})})]}),s.jsx("div",{className:"mb-1 grid grid-cols-7 gap-1 px-1",children:B.map((V,De)=>s.jsx("div",{className:"py-1 text-center typography-micro text-muted-foreground",children:V},`${V}-${De}`))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:C4(R,we).map(({date:V,inCurrentMonth:De})=>{const Fe=ad(V),_e=Fe===m.schedule.onceDate,rt=md(V,ge),ct=V.getTime()<ge.getTime(),et=_e?"bg-interactive-selection text-interactive-selection-foreground":ct?"text-muted-foreground/40":De?"text-foreground hover:bg-interactive-hover":"text-muted-foreground/60 hover:bg-interactive-hover";return s.jsx("button",{type:"button",onClick:()=>{ct||(he(Fe),k(!1))},disabled:ct,className:["h-8 rounded-md typography-ui-label",et,rt&&!_e?"ring-1 ring-inset ring-ring bg-interactive-selection text-interactive-selection-foreground":"",ct?"cursor-not-allowed opacity-45":""].join(" "),children:V.getDate()},Fe)})}),s.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-border pt-2",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:de||""}),s.jsx(dt,{type:"button",size:"xs",variant:"ghost",onClick:()=>{he(ad(ge)),E(new Date(ge.getFullYear(),ge.getMonth(),1))},children:o("sessions.scheduledTasks.editor.date.jumpToToday")})]})]}):null]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.time.label")}),s.jsx(ud,{value:m.schedule.onceTime,use24Hour:Se,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:V=>p(De=>({...De,schedule:{...De.schedule,onceTime:V}}))}),s.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Bs,{value:m.schedule.timezone,onValueChange:V=>{p(De=>({...De,schedule:{...De.schedule,timezone:V}}))},children:[s.jsx(Fs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(ks,{})}),s.jsx(_s,{children:pa.map(V=>s.jsx(ss,{value:V,children:V},V))})]})]})]})]}):s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[m.schedule.kind==="weekly"?s.jsxs("div",{className:"flex flex-col gap-1 sm:col-span-2",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.weekdays.label")}),s.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-2",children:ye.map(V=>{const De=m.schedule.weekdays.includes(V.value);return s.jsxs("div",{className:["group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta",De?"text-foreground":"text-muted-foreground"].join(" "),children:[s.jsx(pr,{checked:De,onChange:Fe=>Q(V.value,Fe),ariaLabel:V.label}),s.jsx("button",{type:"button",onClick:()=>Q(V.value,!De),className:"group-hover:text-foreground",children:V.label})]},V.value)})})]}):null,s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.times.label")}),s.jsx("div",{className:"flex flex-col gap-2",children:m.schedule.times.map((V,De)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ud,{value:V,use24Hour:Se,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:Fe=>le(De,Fe)}),m.schedule.times.length>1?s.jsx(dt,{type:"button",size:"icon",variant:"ghost",onClick:()=>H(De),"aria-label":o("sessions.scheduledTasks.editor.times.removeAria"),children:s.jsx(M,{name:"close",className:"h-4 w-4"})}):null]},De))}),s.jsx("div",{children:s.jsxs(dt,{type:"button",size:"sm",variant:"outline",onClick:me,children:[s.jsx(M,{name:"add",className:"mr-1 h-4 w-4"})," ",o("sessions.scheduledTasks.editor.times.add")]})})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Bs,{value:m.schedule.timezone,onValueChange:V=>{p(De=>({...De,schedule:{...De.schedule,timezone:V}}))},children:[s.jsx(Fs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(ks,{})}),s.jsx(_s,{children:pa.map(V=>s.jsx(ss,{value:V,children:V},V))})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ms,{required:!0,children:o("sessions.scheduledTasks.editor.model.label")}),s.jsx(Bg,{providerId:m.execution.providerID,modelId:m.execution.modelID,onChange:(V,De)=>{p(Fe=>({...Fe,execution:{...Fe.execution,providerID:V,modelID:De,variant:""}}))}})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.thinkingLevel.label")}),s.jsxs(Bs,{value:O,disabled:!pe,onValueChange:V=>{p(De=>({...De,execution:{...De.execution,variant:V==="__default"?"":V}}))},children:[s.jsx(Fs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(ks,{children:V=>V==="__default"?o("sessions.scheduledTasks.editor.thinkingLevel.default"):V})}),s.jsxs(_s,{children:[s.jsx(ss,{value:"__default",children:o("sessions.scheduledTasks.editor.thinkingLevel.default")}),Ae.map(V=>s.jsx(ss,{value:V,children:V},V))]})]})]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.agent.label")}),s.jsx(Fg,{agentName:m.execution.agent,filter:V=>Du(V.mode),onChange:V=>p(De=>({...De,execution:{...De.execution,agent:V}}))})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ms,{htmlFor:"sched-prompt",required:!0,children:o("sessions.scheduledTasks.editor.prompt.label")}),s.jsxs("div",{className:"relative",children:[s.jsx(fr,{id:"sched-prompt",ref:J,value:m.execution.prompt,onChange:V=>{const De=V.target.value;Re(De);const Fe=V.target.selectionStart??De.length;ve(De,Fe)},onKeyDown:ee,rows:8,placeholder:o("sessions.scheduledTasks.editor.prompt.placeholder"),className:"typography-meta min-h-[120px] max-h-[300px] resize-none overflow-y-auto"}),P?s.jsx(Mu,{ref:fe,searchQuery:L,onCommandSelect:q,onClose:()=>T(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,j?s.jsx(Ou,{ref:re,searchQuery:I,onFileSelect:ce,onAgentSelect:se,onClose:()=>D(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,K?s.jsx(Bu,{ref:ne,searchQuery:W,onSnippetSelect:z,onClose:()=>F(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null]})]}),m.execution.goalEnabled?s.jsxs("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-2",children:[s.jsxs("label",{className:"inline-flex cursor-pointer items-center gap-2",children:[s.jsx(pr,{checked:m.execution.goalTokenBudget!==null,onChange:V=>p(De=>({...De,execution:{...De.execution,goalTokenBudget:V?2e5:null}})),ariaLabel:o("sessions.scheduledTasks.editor.goal.budgetAria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.goal.budgetLabel")})]}),m.execution.goalTokenBudget!==null?s.jsx(_g,{value:m.execution.goalTokenBudget,onValueChange:V=>{typeof V=="number"&&Number.isFinite(V)&&V>0&&p(De=>({...De,execution:{...De.execution,goalTokenBudget:Math.floor(V)}}))},min:1e3,max:1e8,step:5e4}):null]}):null]}),$e=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("label",{className:"inline-flex items-center gap-2",children:[s.jsx(pr,{checked:m.enabled,onChange:V=>p(De=>({...De,enabled:V})),ariaLabel:o("sessions.scheduledTasks.editor.enabled.aria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.enabled.label")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",className:Oe(od),onClick:()=>p(V=>({...V,execution:{...V.execution,permissionAutoAccept:!V.execution.permissionAutoAccept}})),"aria-pressed":m.execution.permissionAutoAccept,"aria-label":o("sessions.scheduledTasks.editor.permissionAutoAccept.aria"),children:m.execution.permissionAutoAccept?s.jsx(M,{name:"shield-check",className:"h-[18px] w-[18px]",style:{color:"var(--status-info)"},"aria-hidden":"true"}):s.jsx(M,{name:"shield-user",className:"h-[18px] w-[18px]","aria-hidden":"true"})})}),s.jsx(Dt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.permissionAutoAccept.label")})]}),s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",className:Oe(od,m.execution.goalEnabled&&"text-[var(--status-info)]"),onClick:()=>p(V=>({...V,execution:{...V.execution,goalEnabled:!V.execution.goalEnabled}})),"aria-pressed":m.execution.goalEnabled,"aria-label":o("sessions.scheduledTasks.editor.goal.aria"),children:m.execution.goalEnabled?s.jsx(M,{name:"target-fill",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"}):s.jsx(M,{name:"target",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"})})}),s.jsx(Dt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.goal.label")})]}),s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:S,children:o("sessions.scheduledTasks.editor.actions.cancel")}),s.jsx(dt,{type:"button",size:"sm",onClick:ae,disabled:S,children:o(S?"sessions.scheduledTasks.editor.actions.saving":"sessions.scheduledTasks.editor.actions.save")})]})]});return y?s.jsx(Go,{open:e,title:We,onClose:()=>r(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:V=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:We}),V]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:Ee})]}),footer:$e,children:xe}):s.jsx(ys,{open:e,onOpenChange:V=>{!V&&Ce()||r(V)},children:s.jsxs(ws,{"aria-describedby":Ne,className:"!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden",children:[s.jsx(Is,{id:Ne,className:"sr-only",children:Ee}),s.jsx("header",{className:"shrink-0 px-4 sm:px-6 pt-5 pb-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl",children:[s.jsx(Ps,{className:"typography-ui-label font-medium text-foreground",children:We}),s.jsx("p",{className:"typography-meta mt-0.5 text-muted-foreground",children:Ee})]})}),s.jsx(Da,{className:"flex-1 min-h-0 overflow-auto [scrollbar-gutter:stable_both-edges]",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 pb-5",children:xe})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsx("div",{className:"mx-auto w-full max-w-2xl",children:$e})})]})})}function _4(t){return Cr(t,{min:0,max:23})}function L4(t,e){return Cr(String(Number.parseInt(t,10)+e),{min:0,max:23,loop:!0})}function $4(t,e){const n=Number(t),r=Number(e),i=Number.isFinite(n)?Math.min(23,Math.max(0,n)):0,o=Number.isFinite(r)?Math.min(59,Math.max(0,r)):0;return`${String(i).padStart(2,"0")}:${String(o).padStart(2,"0")}`}function z4(t){return s.jsx(ss,{value:t,children:t},t)}const W4=t=>{const n=(Array.isArray(t.schedule.times)?t.schedule.times:t.schedule.time?[t.schedule.time]:[]).filter(r=>typeof r=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(r));return Array.from(new Set(n)).sort((r,i)=>r.localeCompare(i))},K4=(t,e)=>{const n=W4(t).join(", ")||"--:--",r=i=>e(i===0?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sun":i===1?"sessions.scheduledTasks.dialog.schedule.weekdayShort.mon":i===2?"sessions.scheduledTasks.dialog.schedule.weekdayShort.tue":i===3?"sessions.scheduledTasks.dialog.schedule.weekdayShort.wed":i===4?"sessions.scheduledTasks.dialog.schedule.weekdayShort.thu":i===5?"sessions.scheduledTasks.dialog.schedule.weekdayShort.fri":i===6?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sat":"sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown");if(t.schedule.kind==="daily")return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.dailyWithTimezone",{time:n,timezone:Jn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.daily",{time:n});if(t.schedule.kind==="weekly"){const i=Array.isArray(t.schedule.weekdays)?t.schedule.weekdays.map(o=>r(o)).join(", "):"";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone",{days:i,time:n,timezone:Jn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.weekly",{days:i,time:n})}if(t.schedule.kind==="once"){const i=typeof t.schedule.date=="string"&&t.schedule.date.trim().length>0?t.schedule.date:e("sessions.scheduledTasks.dialog.schedule.unknownDate"),o=typeof t.schedule.time=="string"&&t.schedule.time.trim().length>0?t.schedule.time:"--:--";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.onceWithTimezone",{date:i,time:o,timezone:Jn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.once",{date:i,time:o})}return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.cronWithTimezone",{cron:t.schedule.cron||"",timezone:Jn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.cron",{cron:t.schedule.cron||""})},V4=(t,e)=>!t||!Number.isFinite(t)?"":Lg(t,e),pd=(t,e)=>{if(!t||!Number.isFinite(t))return"";const n=t-Date.now(),r=Math.abs(n),i=6e4,o=60*i,l=24*o,a=n>=0;if(r<i)return e(a?"sessions.scheduledTasks.dialog.relativeTime.inLessThanOneMinute":"sessions.scheduledTasks.dialog.relativeTime.justNow");if(r<o){const f=Math.round(r/i);return a?e("sessions.scheduledTasks.dialog.relativeTime.inMinutes",{count:f}):e("sessions.scheduledTasks.dialog.relativeTime.minutesAgo",{count:f})}if(r<l){const f=Math.floor(r/o),x=Math.round(r%o/i),b=x>0?`${f}h ${x}m`:`${f}h`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:b}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:b})}const d=Math.floor(r/l),u=Math.round(r%l/o),h=u>0?`${d}d ${u}h`:`${d}d`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:h}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:h})},U4={success:{tone:"success",Icon:"checkbox-circle"},error:{tone:"error",Icon:"error-warning"},running:{tone:"warning",Icon:"loader-4",spin:!0},idle:{tone:"muted",Icon:"pulse"}},H4=t=>({color:`var(--status-${t})`,backgroundColor:`var(--status-${t}-background)`,borderColor:`var(--status-${t}-border)`});function G4(){const{t}=jt(),e=Pe(N=>N.isScheduledTasksDialogOpen),n=Pe(N=>N.setScheduledTasksDialogOpen),r=Pe(N=>N.isMobile),i=Pe(N=>N.timeFormatPreference),o=Ht(N=>N.projects),l=Ht(N=>N.getActiveProject()),a=ns(N=>N.homeDirectory),{currentTheme:d}=or(),[u,h]=mt.useState(""),[f,x]=mt.useState([]),[b,w]=mt.useState(!0),[v,y]=mt.useState(!1),[m,p]=mt.useState(null),[S,g]=mt.useState(null),C=mt.useMemo(()=>o.find(N=>N.id===u)||null,[o,u]),k=mt.useCallback(N=>{const R=N.label?.trim()||Ln(N.path,a||void 0),E=N.icon?_a[N.icon]:null,X=N.color?La[N.color]:void 0,J=E?s.jsx(M,{name:E,className:"h-3.5 w-3.5 shrink-0",style:X?{color:X}:void 0}):s.jsx(M,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:X?{color:X}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[N.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:N.iconBackground?{backgroundColor:N.iconBackground}:void 0,children:s.jsx($a,{project:{id:N.id,iconImage:N.iconImage??null},options:{themeVariant:d.metadata.variant,iconColor:d.colors.surface.foreground},className:"h-full w-full object-contain",fallback:J})}):J,s.jsx("span",{className:"truncate",children:R})]})},[a,d.metadata.variant,d.colors.surface.foreground]),j=mt.useCallback(async(N,R)=>{if(!N){x([]);return}R?.silent||w(!0);try{const E=await Fx(N);E.sort((X,J)=>{if(X.enabled!==J.enabled)return X.enabled?-1:1;const re=X.name.localeCompare(J.name);return re!==0?re:(X.state?.nextRunAt||Number.MAX_SAFE_INTEGER)-(J.state?.nextRunAt||Number.MAX_SAFE_INTEGER)}),x(E)}catch(E){Le.error(E instanceof Error?E.message:t("sessions.scheduledTasks.dialog.toast.loadFailed")),R?.silent||x([])}finally{R?.silent||w(!1)}},[t]);mt.useEffect(()=>{if(!e)return;const N=l?.id||o[0]?.id||"";h(N),N?j(N):(x([]),w(!1))},[e,l,o,j]),mt.useEffect(()=>{if(!e)return;let N=null;const R=eo(E=>{E.type==="scheduled-task-ran"&&E.projectId===u&&(N&&clearTimeout(N),N=setTimeout(()=>{j(u,{silent:!0})},400))});return()=>{N&&clearTimeout(N),R()}},[e,u,j]);const D=mt.useCallback(async N=>{if(!u)throw new Error(t("sessions.scheduledTasks.dialog.error.chooseProjectFirst"));await Ul(u,N),await j(u),Le.success(t("sessions.scheduledTasks.dialog.toast.saved"))},[u,j,t]),I=mt.useCallback(async(N,R)=>{if(u){g(N.id),x(E=>E.map(X=>X.id===N.id?{...X,enabled:R}:X));try{N.loopFile?await _x(u,N.id,R):await Ul(u,{...N,enabled:R}),await j(u,{silent:!0})}catch(E){Le.error(E instanceof Error?E.message:t("sessions.scheduledTasks.dialog.toast.updateFailed")),await j(u,{silent:!0})}finally{g(null)}}},[u,j,t]),A=mt.useCallback(async N=>{if(!(!u||!window.confirm(N.loopFile?t("sessions.scheduledTasks.dialog.confirm.deleteLoopFile",{taskName:N.name}):t("sessions.scheduledTasks.dialog.confirm.deleteTask",{taskName:N.name})))){g(N.id);try{N.loopFile?await Lx(u,N.id):await $x(u,N.id),await j(u,{silent:!0}),Le.success(t("sessions.scheduledTasks.dialog.toast.deleted"))}catch(E){Le.error(E instanceof Error?E.message:t("sessions.scheduledTasks.dialog.toast.deleteFailed"))}finally{g(null)}}},[u,j,t]),P=mt.useCallback(N=>{if(!N.loopFile){p(N),y(!0);return}C?.path&&(n(!1),hn.getState().setSelectedPath(C.path,N.loopFile,{allowOutsideRoot:!0}),Pe.getState().openContextFile(C.path,N.loopFile))},[C?.path,n]),T=mt.useCallback(async N=>{if(u){g(N.id);try{const{sessionId:R,persistError:E}=await zx(u,N.id);if(await Promise.all([j(u,{silent:!0}),za()]),E?Le.warning(t("sessions.scheduledTasks.dialog.toast.startedPersistWarning")):Le.success(t("sessions.scheduledTasks.dialog.toast.started")),R){const X=o.find(J=>J.id===u);tt.getState().setCurrentSession(R,X?.path??null)}}catch(R){Le.error(R instanceof Error?R.message:t("sessions.scheduledTasks.dialog.toast.runFailed"))}finally{g(null)}}},[u,o,j,t]),L=s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.label")}),s.jsxs(Bs,{value:u||"__none",onValueChange:N=>{const R=N==="__none"?"":N;h(R),R?j(R):x([])},children:[s.jsx(Fs,{size:"lg",className:r?"w-full":void 0,children:C?s.jsx(ks,{children:k(C)}):s.jsx(ks,{placeholder:t("sessions.scheduledTasks.dialog.project.placeholder")})}),s.jsxs(_s,{children:[o.length===0?s.jsx(ss,{value:"__none",children:t("sessions.scheduledTasks.dialog.project.empty")}):null,o.map(N=>s.jsx(ss,{value:N.id,children:k(N)},N.id))]})]})]}),$=()=>{p(null),y(!0)},K=N=>{h(N),N?j(N):x([])},F=s.jsx("div",{className:"min-h-[280px]",children:b?s.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx(M,{name:"loader-4",className:"h-4 w-4 animate-spin"})," ",t("sessions.scheduledTasks.dialog.loading")]}):f.length===0?s.jsx("div",{className:"rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground",children:t(u?"sessions.scheduledTasks.dialog.empty.noTasks":"sessions.scheduledTasks.dialog.empty.selectProject")}):s.jsx("div",{className:"space-y-2.5",children:f.map(N=>{const R=S===N.id,E=N.state?.lastStatus||"idle",X=U4[E],J=t(E==="success"?"sessions.scheduledTasks.dialog.status.success":E==="error"?"sessions.scheduledTasks.dialog.status.error":E==="running"?"sessions.scheduledTasks.dialog.status.running":"sessions.scheduledTasks.dialog.status.idle"),re=N.state?.nextRunAt,fe=N.state?.lastRunAt;return s.jsxs("div",{className:Oe("rounded-lg border border-border p-4 transition-opacity"),children:[s.jsxs("div",{className:Oe("min-w-0",!N.enabled&&"opacity-60"),children:[s.jsx("div",{className:"typography-ui-header truncate font-semibold text-foreground",children:N.name}),s.jsx("div",{className:"typography-micro truncate text-muted-foreground",children:K4(N,t)}),N.loopFile?s.jsx("div",{className:"typography-micro truncate text-muted-foreground/70",title:N.loopFile,children:t("sessions.scheduledTasks.dialog.loopFile.note",{file:N.loopFile})}):null]}),s.jsxs("div",{className:Oe("mt-3 flex flex-wrap items-center gap-x-5 gap-y-1 typography-micro text-muted-foreground",!N.enabled&&"opacity-60"),children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(M,{name:"timer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.nextRun.label")}),re?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-foreground",children:pd(re,t)}),s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:V4(re,i)})]}):s.jsx("span",{children:"—"})]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(M,{name:"history",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.lastRun.label")}),E==="running"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:"var(--status-warning)"},children:[s.jsx(M,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),t("sessions.scheduledTasks.dialog.lastRun.runningNow")]}):fe?s.jsxs(s.Fragment,{children:[X.tone!=="muted"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:`var(--status-${X.tone})`},children:[s.jsx(M,{name:X.Icon,className:"h-3.5 w-3.5"}),J]}):null,s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:pd(fe,t)})]}):s.jsx("span",{children:t("sessions.scheduledTasks.dialog.lastRun.never")})]})]}),N.state?.lastError?s.jsxs("div",{className:Oe("mt-3 flex items-start gap-2 rounded-md border p-2 typography-micro",!N.enabled&&"opacity-60"),style:H4("error"),children:[s.jsx(M,{name:"error-warning",className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"min-w-0 break-words",children:N.state.lastError})]}):null,s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("label",{className:Oe("inline-flex cursor-pointer items-center gap-2 typography-micro font-medium",N.enabled?"text-foreground":"text-muted-foreground",R&&"cursor-not-allowed opacity-50"),children:[s.jsx(pr,{checked:N.enabled,onChange:ne=>{I(N,ne)},ariaLabel:N.enabled?t("sessions.scheduledTasks.dialog.taskToggle.pauseAria",{taskName:N.name}):t("sessions.scheduledTasks.dialog.taskToggle.enableAria",{taskName:N.name}),disabled:R}),N.enabled?t("sessions.scheduledTasks.dialog.taskToggle.enabled"):t("sessions.scheduledTasks.dialog.taskToggle.paused")]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsxs(dt,{variant:"outline",size:"sm",onClick:()=>{T(N)},disabled:R,children:[s.jsx(M,{name:"play",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.runNow")]}),s.jsxs(dt,{variant:"outline",size:"sm",onClick:()=>P(N),disabled:R,"aria-label":t("sessions.scheduledTasks.dialog.actions.editAria",{taskName:N.name}),children:[s.jsx(M,{name:"edit-2",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.edit")]}),s.jsx(dt,{variant:"destructive",size:"sm",onClick:()=>{A(N)},disabled:R,"aria-label":t("sessions.scheduledTasks.dialog.actions.deleteAria",{taskName:N.name}),children:s.jsx(M,{name:"delete-bin",className:"h-4 w-4"})})]})]})]},N.id)})})}),W=s.jsxs("div",{className:"space-y-4",children:[L,F]});return s.jsxs(s.Fragment,{children:[r?s.jsx(Go,{open:e,title:t("sessions.scheduledTasks.dialog.title"),onClose:()=>n(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:N=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:t("sessions.scheduledTasks.dialog.title")}),N]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("sessions.scheduledTasks.dialog.description")})]}),footer:s.jsxs(dt,{className:"w-full",onClick:$,disabled:!u,children:[s.jsx(M,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]}),children:W}):e?s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-surface-elevated",children:s.jsxs("div",{className:"flex min-h-0 flex-1",children:[s.jsx("div",{className:"flex w-60 flex-shrink-0 flex-col border-r border-border/50",children:s.jsx("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:o.length===0?s.jsx("div",{className:"px-2 py-2 typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.empty")}):o.map(N=>s.jsx("button",{type:"button",onClick:()=>K(N.id),className:Oe("flex w-full min-w-0 items-center rounded-md px-2 py-1.5 text-left typography-ui-label focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",u===N.id?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:k(N)},N.id))})}),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("div",{className:"flex items-center px-6 pt-3",children:s.jsxs(dt,{size:"sm",onClick:$,disabled:!u,children:[s.jsx(M,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]})}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-4",children:s.jsx("div",{className:"mx-auto w-full max-w-3xl",children:F})})]})]})}):null,s.jsx(F4,{open:v,task:m,onOpenChange:y,onSave:D})]})}const No=100;function q4(){const t=Ze.c(108),{t:e}=jt(),n=Pe(nC),r=Pe(sC),i=tt(tC),o=tt(eC),l=ns(Z4);let a;t[0]!==n?(a=re=>n?re.archivedSessions:[],t[0]=n,t[1]=a):a=t[1];const d=$s(rr(a)),[u,h]=c.useState(""),[f,x]=c.useState(null),[b,w]=c.useState(No);let v;t[2]!==u?(v=u.trim().toLowerCase(),t[2]=u,t[3]=v):v=t[3];const y=v;let m;e:{if(!n){let fe;t[4]===Symbol.for("react.memo_cache_sentinel")?(fe=[],t[4]=fe):fe=t[4],m=fe;break e}let re;t[5]!==d?(re=[...d].sort(J4),t[5]=d,t[6]=re):re=t[6],m=re}const p=m;let S;if(t[7]!==l||t[8]!==p||t[9]!==e){const re=new Map;for(const fe of p){const ne=ht(Ds(fe))??"",te=re.get(ne);if(te){te.sessions.push(fe);continue}re.set(ne,{directory:ne,label:ne?Ln(ne,l)||ne:e("sessions.archivePage.otherProjects"),sessions:[fe]})}S=[...re.values()].sort(X4),t[7]=l,t[8]=p,t[9]=e,t[10]=S}else S=t[10];const g=S;let C;e:{if(y){if(y.startsWith("ses_")){let ne;if(t[11]!==y||t[12]!==p){let te;t[14]!==y?(te=ue=>ue.id.toLowerCase()===y,t[14]=y,t[15]=te):te=t[15],ne=p.filter(te),t[11]=y,t[12]=p,t[13]=ne}else ne=t[13];C=ne;break e}let fe;t[16]!==y||t[17]!==p?(fe=$g(p,y,Q4),t[16]=y,t[17]=p,t[18]=fe):fe=t[18],C=fe;break e}if(f===null){C=p;break e}let re;t[19]!==g||t[20]!==f?(re=g.find(fe=>fe.directory===f)?.sessions??[],t[19]=g,t[20]=f,t[21]=re):re=t[21],C=re}const k=C;let j,D,I,A,P,T,L,$,K,F;if(t[22]!==d.length||t[23]!==g||t[24]!==k||t[25]!==l||t[26]!==y||t[27]!==n||t[28]!==u||t[29]!==f||t[30]!==i||t[31]!==r||t[32]!==e||t[33]!==o||t[34]!==b){P=Symbol.for("react.early_return_sentinel");e:{const re=k.slice(0,b);j=k.length-re.length;const fe=d.length;let ne;t[45]===Symbol.for("react.memo_cache_sentinel")?(ne=_=>{x(_),w(No)},t[45]=ne):ne=t[45];const te=ne;let ue;t[46]!==i||t[47]!==r?(ue=_=>{const B=ht(Ds(_));i(_.id,B??void 0),r(!1)},t[46]=i,t[47]=r,t[48]=ue):ue=t[48];const Se=ue;let we;t[49]!==e||t[50]!==o?(we=_=>{o(_.id).then(B=>{B?Le.success(e("sessions.sidebar.session.restore.success")):Le.error(e("sessions.sidebar.session.restore.error"))})},t[49]=e,t[50]=o,t[51]=we):we=t[51];const ye=we;if(!n){P=null;break e}let Ae;t[52]!==e?(Ae=(_,B,he,ve,Re,ce,se)=>s.jsxs("div",{className:"group/dir relative",children:[s.jsxs("button",{type:"button",onClick:Re,title:ce,className:Oe("flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left typography-ui-label transition-[padding] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",se?"group-hover/dir:pr-8 group-focus-within/dir:pr-8":"",ve?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B}),s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground/70",children:he})]}),se?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>fn.requestDelete({sessions:se,mode:"session"}),className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:text-destructive group-hover/dir:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.deleteProjectAria",{label:B}),children:s.jsx(M,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),s.jsx(Dt,{side:"bottom",sideOffset:4,children:e("sessions.archivePage.deleteProject")})]}):null]},_),t[52]=e,t[53]=Ae):Ae=t[53];const pe=Ae;A="absolute inset-0 z-10 flex flex-col bg-background",D="flex min-h-0 flex-1";let O;if(t[54]!==pe||t[55]!==f||t[56]!==e||t[57]!==fe){let _;t[59]===Symbol.for("react.memo_cache_sentinel")?(_=()=>te(null),t[59]=_):_=t[59],O=pe("__all__",e("sessions.archivePage.allDirectories"),fe,f===null,_),t[54]=pe,t[55]=f,t[56]=e,t[57]=fe,t[58]=O}else O=t[58];let Q;if(t[60]!==g||t[61]!==pe||t[62]!==f){let _;t[64]!==pe||t[65]!==f?(_=B=>pe(B.directory||"__none__",B.label,B.sessions.length,f===B.directory,()=>te(B.directory),B.directory||void 0,B.sessions),t[64]=pe,t[65]=f,t[66]=_):_=t[66],Q=g.map(_),t[60]=g,t[61]=pe,t[62]=f,t[63]=Q}else Q=t[63];t[67]!==O||t[68]!==Q?(I=s.jsx("div",{className:"flex w-64 flex-shrink-0 flex-col border-r border-border/50",children:s.jsxs("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:[O,Q]})}),t[67]=O,t[68]=Q,t[69]=I):I=t[69],K="flex min-w-0 flex-1 flex-col";let le;t[70]===Symbol.for("react.memo_cache_sentinel")?(le=_=>{h(_),w(No)},t[70]=le):le=t[70];let H;t[71]!==e?(H=e("sessions.archivePage.searchPlaceholder"),t[71]=e,t[72]=H):H=t[72];let me;t[73]!==e?(me=e("sessions.sidebar.header.search.clear"),t[73]=e,t[74]=me):me=t[74];let ge;t[75]!==u||t[76]!==H||t[77]!==me?(ge=s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(Vd,{value:u,onSearch:le,placeholder:H,clearLabel:me})}),t[75]=u,t[76]=H,t[77]=me,t[78]=ge):ge=t[78];let oe;t[79]!==k.length||t[80]!==e?(oe=k.length===1?e("sessions.archivePage.countSingle",{count:k.length}):e("sessions.archivePage.countPlural",{count:k.length}),t[79]=k.length,t[80]=e,t[81]=oe):oe=t[81];let de;t[82]!==oe?(de=s.jsx("span",{className:"flex h-8 flex-shrink-0 items-center self-start typography-micro text-muted-foreground",children:oe}),t[82]=oe,t[83]=de):de=t[83],t[84]!==ge||t[85]!==de?(F=s.jsxs("div",{className:"flex items-center gap-3 px-6 pt-3",children:[ge,de]}),t[84]=ge,t[85]=de,t[86]=F):F=t[86],$="min-h-0 flex-1 overflow-y-auto px-6 py-3",T="mx-auto w-full max-w-3xl space-y-0.5",L=re.length===0?s.jsx("div",{className:"py-10 text-center text-muted-foreground",children:s.jsx("p",{className:"typography-ui-label font-semibold",children:e(y?"sessions.archivePage.empty.noMatches":"sessions.archivePage.empty.noArchived")})}):re.map(_=>{const B=ht(Ds(_))??"",he=B?Ln(B,l)||B:null;return s.jsxs("div",{className:"group relative flex cursor-pointer items-center gap-3 rounded-md py-1 pl-2 pr-2 transition-[padding] hover:bg-interactive-hover/40 hover:pr-14 focus-within:pr-14",onClick:()=>Se(_),role:"button",tabIndex:0,onKeyDown:ve=>{(ve.key==="Enter"||ve.key===" ")&&(ve.preventDefault(),Se(_))},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:_.title||e("sessions.sidebar.session.untitled")}),y&&he?s.jsx("span",{className:"max-w-40 flex-shrink-0 truncate text-[0.72rem] text-muted-foreground/70",title:B,children:he}):null,s.jsx("span",{className:"flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:Ru(_.time?.archived??_.time?.updated??_.time?.created??Date.now())}),s.jsx("button",{type:"button",onClick:ve=>{ve.stopPropagation(),ye(_)},className:"absolute right-7 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-foreground group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.restoreSessionAria",{title:_.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(M,{name:"inbox-unarchive",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:ve=>{ve.stopPropagation(),fn.requestDelete({sessions:[_],mode:"session"})},className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-destructive group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.deleteSessionAria",{title:_.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(M,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},_.id)})}t[22]=d.length,t[23]=g,t[24]=k,t[25]=l,t[26]=y,t[27]=n,t[28]=u,t[29]=f,t[30]=i,t[31]=r,t[32]=e,t[33]=o,t[34]=b,t[35]=j,t[36]=D,t[37]=I,t[38]=A,t[39]=P,t[40]=T,t[41]=L,t[42]=$,t[43]=K,t[44]=F}else j=t[35],D=t[36],I=t[37],A=t[38],P=t[39],T=t[40],L=t[41],$=t[42],K=t[43],F=t[44];if(P!==Symbol.for("react.early_return_sentinel"))return P;let W;t[87]!==j||t[88]!==e?(W=j>0?s.jsx("button",{type:"button",onClick:()=>w(Y4),className:"mt-1 flex items-center justify-start rounded-md px-2 py-1 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,t[87]=j,t[88]=e,t[89]=W):W=t[89];let N;t[90]!==W||t[91]!==T||t[92]!==L?(N=s.jsxs("div",{className:T,children:[L,W]}),t[90]=W,t[91]=T,t[92]=L,t[93]=N):N=t[93];let R;t[94]!==N||t[95]!==$?(R=s.jsx("div",{className:$,children:N}),t[94]=N,t[95]=$,t[96]=R):R=t[96];let E;t[97]!==R||t[98]!==K||t[99]!==F?(E=s.jsxs("div",{className:K,children:[F,R]}),t[97]=R,t[98]=K,t[99]=F,t[100]=E):E=t[100];let X;t[101]!==D||t[102]!==I||t[103]!==E?(X=s.jsxs("div",{className:D,children:[I,E]}),t[101]=D,t[102]=I,t[103]=E,t[104]=X):X=t[104];let J;return t[105]!==A||t[106]!==X?(J=s.jsx("div",{className:A,children:X}),t[105]=A,t[106]=X,t[107]=J):J=t[107],J}function Y4(t){return t+No}function Q4(t){return[t.title]}function X4(t,e){return e.sessions.length-t.sessions.length}function J4(t,e){return(e.time?.archived??0)-(t.time?.archived??0)}function Z4(t){return t.homeDirectory}function eC(t){return t.unarchiveSession}function tC(t){return t.setCurrentSession}function sC(t){return t.setArchivePageOpen}function nC(t){return t.isArchivePageOpen}function rC(){const t=Ze.c(18),{t:e}=jt(),n=Pe(aC),r=Pe(iC),i=Ht(oC);let o;t[0]!==n?(o=b=>b.projects.find(w=>w.id===n)??null,t[0]=n,t[1]=o):o=t[1];const l=Ht(o);if(!n||!l)return null;let a;t[2]!==l.id||t[3]!==i||t[4]!==r?(a=()=>{i(l.id),r(!0)},t[2]=l.id,t[3]=i,t[4]=r,t[5]=a):a=t[5];let d;t[6]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(M,{name:"node-tree",className:"mr-1 h-3.5 w-3.5"}),t[6]=d):d=t[6];let u;t[7]!==e?(u=e("sessions.sidebar.project.actions.newWorktree"),t[7]=e,t[8]=u):u=t[8];let h;t[9]!==a||t[10]!==u?(h=s.jsx("div",{className:"flex items-center",children:s.jsxs(dt,{size:"sm",onClick:a,children:[d,u]})}),t[9]=a,t[10]=u,t[11]=h):h=t[11];let f;t[12]!==l.id||t[13]!==l.path?(f=s.jsx($h,{projectRef:{id:l.id,path:l.path},sections:"list-only"}),t[12]=l.id,t[13]=l.path,t[14]=f):f=t[14];let x;return t[15]!==h||t[16]!==f?(x=s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:s.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:s.jsxs("div",{className:"mx-auto w-full max-w-4xl space-y-4",children:[h,f]})})}),t[15]=h,t[16]=f,t[17]=x):x=t[17],x}function oC(t){return t.setActiveProjectIdOnly}function iC(t){return t.setNewWorktreeDialogOpen}function aC(t){return t.worktreesPageProjectId}function em(t){const e=Ze.c(30),{git:n}=vn(),r=hu(t),i=pu(t),o=zg(t),l=Wg(t),a=Tn(fC),d=Tn(uC);let u,h;e[0]!==t||e[1]!==d||e[2]!==n||e[3]!==i||e[4]!==o?(u=()=>{!t||!n||i!==null||o||d(t,n,{silent:!0})},h=[t,n,d,i,o],e[0]=t,e[1]=d,e[2]=n,e[3]=i,e[4]=o,e[5]=u,e[6]=h):(u=e[5],h=e[6]),c.useEffect(u,h);let f;e[7]!==r?.all||e[8]!==t||e[9]!==a||e[10]!==n||e[11]!==i?(f=()=>{!t||!n||i===!0&&(r?.all||a(t,n))},e[7]=r?.all,e[8]=t,e[9]=a,e[10]=n,e[11]=i,e[12]=f):f=e[12];const x=r?.all;let b;e[13]!==t||e[14]!==a||e[15]!==n||e[16]!==i||e[17]!==x?(b=[t,n,i,x,a],e[13]=t,e[14]=a,e[15]=n,e[16]=i,e[17]=x,e[18]=b):b=e[18],c.useEffect(f,b);const w=o||i===!0&&l;let v;e:{if(!r?.all){let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[19]=j):j=e[19],v=j;break e}let k;e[20]!==r.all?(k=r.all.filter(dC).sort(),e[20]=r.all,e[21]=k):k=e[21],v=k}const y=v;let m;e:{if(!r?.all){let j;e[22]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[22]=j):j=e[22],m=j;break e}let k;e[23]!==r.all?(k=r.all.filter(cC).map(lC).sort(),e[23]=r.all,e[24]=k):k=e[24],m=k}const p=m;let S;e:{if(!t){S=null;break e}if(i!==null){S=i;break e}if(w){S=null;break e}S=r?.all?!0:null}const g=S;let C;return e[25]!==g||e[26]!==w||e[27]!==y||e[28]!==p?(C={localBranches:y,remoteBranches:p,isLoading:w,isGitRepository:g},e[25]=g,e[26]=w,e[27]=y,e[28]=p,e[29]=C):C=e[29],C}function lC(t){return t.replace(/^remotes\//,"")}function cC(t){return t.startsWith("remotes/")}function dC(t){return!t.startsWith("remotes/")}function uC(t){return t.fetchStatus}function fC(t){return t.fetchBranches}const mC=({directory:t,value:e,onChange:n,className:r,disabled:i,id:o})=>{const{t:l}=jt(),{localBranches:a,remoteBranches:d,isLoading:u,isGitRepository:h}=em(t),f=c.useMemo(()=>[...a,...d.map(b=>`remotes/${b}`)],[a,d]);c.useEffect(()=>{if(i||u||f.length===0||e&&f.includes(e))return;const b=e;let w=!1;return(async()=>{try{const y=t?await Aa(t).catch(()=>null):null;if(w)return;const m=localStorage.getItem(wl),{sourceBranch:p,shouldClearSavedSourceBranch:S}=zh({branches:f,savedSourceBranch:m,rootBranch:y});if(S&&localStorage.removeItem(wl),w||b&&f.includes(b))return;p&&n(p)}catch{}})(),()=>{w=!0}},[f,t,i,u,n,e]);const x=i||!h||u;return s.jsxs("div",{children:[s.jsxs(Bs,{value:e,onValueChange:n,disabled:x,children:[s.jsx(Fs,{id:o,size:"lg",className:Oe("min-w-0 max-w-full *:data-[slot=select-value]:truncate",r??"w-fit"),children:s.jsx(ks,{placeholder:l(u?"multiRun.branchSelector.status.loadingBranches":"multiRun.branchSelector.placeholder.selectSourceBranch")})}),s.jsx(_s,{className:"max-h-[280px] max-w-[320px]",children:u?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.loadingBranches")}):a.length===0&&d.length===0?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.noBranchesFound")}):s.jsxs(s.Fragment,{children:[a.length>0&&s.jsxs(Wi,{children:[s.jsx(Bl,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.localBranches")}),a.map(b=>s.jsx(ss,{value:b,className:"whitespace-normal break-all",children:b},b))]}),a.length>0&&d.length>0&&s.jsx(Kg,{}),d.length>0&&s.jsxs(Wi,{children:[s.jsx(Bl,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.remoteBranches")}),d.map(b=>s.jsx(ss,{value:`remotes/${b}`,className:"whitespace-normal break-all",children:b},`remotes/${b}`))]})]})})]}),h===!1&&s.jsx("p",{className:"typography-micro text-muted-foreground/70 mt-2",children:l("multiRun.branchSelector.status.notInGitRepository")})]})},hC=10*1024*1024,Ao=t=>{const e=Ze.c(3),{children:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",tabIndex:-1,className:"inline-flex items-center justify-center text-muted-foreground/50 hover:text-muted-foreground transition-colors",children:s.jsx(M,{name:"information",className:"h-3.5 w-3.5"})})}),e[0]=r):r=e[0];let i;return e[1]!==n?(i=s.jsxs(Nt,{children:[r,s.jsx(Dt,{side:"top",className:"max-w-[240px]",children:n})]}),e[1]=n,e[2]=i):i=e[2],i},Xn=t=>{const e=Ze.c(9),{htmlFor:n,required:r,children:i,info:o}=t;let l;e[0]!==r?(l=r&&s.jsx("span",{className:"text-destructive ml-0.5",children:"*"}),e[0]=r,e[1]=l):l=e[1];let a;e[2]!==i||e[3]!==n||e[4]!==l?(a=s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[i,l]}),e[2]=i,e[3]=n,e[4]=l,e[5]=a):a=e[5];const d=o&&o;let u;return e[6]!==a||e[7]!==d?(u=s.jsxs("div",{className:"flex items-center gap-1.5",children:[a,d]}),e[6]=a,e[7]=d,e[8]=u):u=e[8],u},pC=({initialPrompt:t,onCreated:e,onCancel:n,isWindowed:r=!1})=>{const{t:i}=jt(),[o,l]=c.useState(""),[a,d]=c.useState(()=>[{id:Vr(),prompt:"",models:[]}]),[u,h]=c.useState(""),[f,x]=c.useState([]),[b,w]=c.useState(!1),[v,y]=c.useState([]),[m,p]=c.useState(!1),[S,g]=c.useState(!1),[C,k]=c.useState(!0),j=c.useRef(null),D=ns(q=>q.currentDirectory??null),I=ns(q=>q.homeDirectory??null),A=c.useMemo(()=>{if(typeof window>"u")return null;const q=window.__VSCODE_CONFIG__?.workspaceFolder;return typeof q=="string"&&q.trim().length>0?q.trim():null},[]),P=Ht(q=>q.activeProjectId),T=Ht(q=>q.setActiveProjectIdOnly),L=Ht(q=>q.projects),[$,K]=c.useState(()=>P??null);c.useEffect(()=>{if(P){K(P);return}!$&&L.length>0&&K(L[0].id)},[P,L,$]);const F=c.useMemo(()=>$?L.find(q=>q.id===$)??null:null,[L,$]),W=F?.path??D,N=c.useCallback(q=>{K(q),q!==P&&T(q)},[P,T]),{currentTheme:R}=or(),E=c.useCallback(q=>{const z=q.label?.trim()||Ln(q.path,I),ee=q.icon?_a[q.icon]:null,ae=q.color?La[q.color]:void 0,Ne=ee?s.jsx(M,{name:ee,className:"h-3.5 w-3.5 shrink-0",style:ae?{color:ae}:void 0}):s.jsx(M,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:ae?{color:ae}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[q.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:q.iconBackground?{backgroundColor:q.iconBackground}:void 0,children:s.jsx($a,{project:{id:q.id,iconImage:q.iconImage??null},options:{themeVariant:R.metadata.variant,iconColor:R.colors.surface.foreground},className:"h-full w-full object-contain",fallback:Ne})}):Ne,s.jsx("span",{className:"truncate",children:z})]})},[I,R.metadata.variant,R.colors.surface.foreground]),X=c.useMemo(()=>{if(F?.path)return{id:F.id,path:F.path};const q=D??A;return q?{id:`path:${q}`,path:q}:null},[F,D,A]),[J]=c.useState(()=>typeof window<"u"?xn():!1),re=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),fe=tu(),ne=c.useMemo(()=>{if(typeof window>"u")return null;const q=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof q=="number"&&Number.isFinite(q)&&q>0)return q;if(typeof navigator>"u")return null;const z=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!z)return null;const ee=Number.parseInt(z[1],10),ae=Number.parseInt(z[2],10);return Number.isNaN(ee)?null:ee===10?ae:ee},[]),te=c.useMemo(()=>J&&re||fe?"pl-[88px]":"pl-3",[J,re,fe]),ue=c.useMemo(()=>!J||!re||ne===null?"":ne>=26?"h-12":ne<=15?"h-14":"",[J,re,ne]),Se=c.useCallback(async q=>{q.target.closest("button, a, input, select, textarea")||q.button===0&&J&&await Vg()},[J]);c.useEffect(()=>{if(!n)return;const q=z=>{z.key==="Escape"&&(z.preventDefault(),z.stopPropagation(),n())};return window.addEventListener("keydown",q,!0),()=>window.removeEventListener("keydown",q,!0)},[n]);const[we,ye]=c.useState(""),{isLoading:Ae,isGitRepository:pe}=em(W),O=c.useRef(!1),Q=pe===!0,le=Q&&C;c.useEffect(()=>{if(pe===!1){O.current=!0,k(!1);return}pe===!0&&O.current&&(O.current=!1,k(!0))},[pe]);const H=li(q=>q.createMultiRun),me=li(q=>q.error),ge=li(q=>q.clearError);c.useEffect(()=>{typeof t=="string"&&t.trim().length>0&&d(q=>{const z=[...q];return z.length>0&&!z[0].prompt.trim()&&(z[0]={...z[0],prompt:t}),z})},[t]),c.useEffect(()=>{if(!X)return;let q=!1;return g(!0),(async()=>{try{const z=await Ug(X);q||y(z)}catch{}finally{q||g(!1)}})(),()=>{q=!0}},[X]);const oe=c.useCallback((q,z)=>{d(ee=>ee.map(ae=>ae.id===q?{...ae,...z}:ae))},[]),de=c.useCallback(q=>{d(z=>z.filter(ee=>ee.id!==q))},[]),_=c.useCallback(()=>{d(q=>[...q,{id:Vr(),prompt:"",models:[]}])},[]),B=async q=>{const z=q.target.files;if(!z)return;let ee=0;for(let ae=0;ae<z.length;ae++){const Ne=z[ae];if(Ne.size>hC){Le.error(i("multirun.launcher.toast.fileTooLarge",{fileName:Ne.name}));continue}try{const Ce=await new Promise((We,Ee)=>{const xe=new FileReader;xe.onload=()=>We(xe.result),xe.onerror=Ee,xe.readAsDataURL(Ne)});x(We=>[...We,{id:Vr(),filename:Ne.name,mimeType:Ne.type||"application/octet-stream",size:Ne.size,dataUrl:Ce}]),ee++}catch(Ce){console.error("File attach failed",Ce),Le.error(i("multirun.launcher.toast.attachFailed",{fileName:Ne.name}))}}ee>0&&Le.success(ee===1?i("multirun.launcher.toast.attachedSingle",{count:ee}):i("multirun.launcher.toast.attachedPlural",{count:ee})),j.current&&(j.current.value="")},he=q=>{x(z=>z.filter(ee=>ee.id!==q))},ve=c.useMemo(()=>a.reduce((q,z)=>q+z.models.length,0),[a]),Re=async q=>{q.preventDefault();const z=a.filter(ee=>ee.prompt.trim()&&ee.models.length>=1);if(z.length!==0&&!(ve<1)){w(!0),ge();try{$&&$!==P&&T($);const ee=f.map(Ee=>({mime:Ee.mimeType,filename:Ee.filename,url:Ee.dataUrl})),ae=v.filter(Ee=>Ee.trim().length>0),Ne=z.map(Ee=>({prompt:Ee.prompt.trim(),models:Ee.models.map(xe=>({providerID:xe.providerID,modelID:xe.modelID,displayName:xe.displayName,variant:xe.variant}))})),Ce={name:o.trim(),groups:Ne,agent:u||void 0,worktreeBaseBranch:le?we:void 0,isolateRuns:le,files:ee.length>0?ee:void 0,setupCommands:ae.length>0?ae:void 0},We=await H(Ce);We&&(We.failedCount>0&&Le.error(i("multirun.launcher.toast.partialFailure",{failed:We.failedCount})),We.firstSessionId&&tt.getState().setCurrentSession(We.firstSessionId),e?.())}finally{w(!1)}}},ce=!!(o.trim()&&a.some(q=>q.prompt.trim()&&q.models.length>=1)&&ve>=1&&W&&!Ae&&(pe===!1||!le||we)),se=v.filter(q=>q.trim()).length;return s.jsxs("form",{onSubmit:Re,className:"flex flex-col h-full bg-background",children:[r?null:s.jsxs("header",{onMouseDown:Se,className:Oe("relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none",te,ue),style:{borderColor:"var(--interactive-border)"},children:[s.jsx("h1",{className:"typography-ui-label font-medium",children:i("multirun.launcher.title")}),n&&s.jsx("div",{className:"absolute right-0 flex items-center pr-3",children:s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":i("multirun.launcher.actions.closeEsc"),className:"inline-flex h-9 w-9 items-center justify-center p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring app-region-no-drag",children:s.jsx(M,{name:"close",className:"h-5 w-5"})})}),s.jsx(Dt,{children:s.jsx("p",{children:i("multirun.launcher.actions.closeEsc")})})]})})]}),s.jsx(Da,{className:"flex-1 min-h-0 overflow-auto",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 py-5",children:s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Xn,{htmlFor:"multirun-project",required:!0,children:i("multirun.launcher.project.label")}),L.length>0?s.jsxs(Bs,{value:$??void 0,onValueChange:N,children:[s.jsx(Fs,{id:"multirun-project",size:"lg",className:"w-fit max-w-full",children:F?s.jsx(ks,{children:E(F)}):s.jsx(ks,{placeholder:i("multirun.launcher.project.placeholder")})}),s.jsx(_s,{fitContent:!0,children:L.map(q=>s.jsx(ss,{value:q.id,className:"max-w-[24rem]",children:E(q)},q.id))})]}):s.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:i("multirun.launcher.project.empty")})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Xn,{htmlFor:"group-name",required:!0,info:s.jsx(Ao,{children:i("multirun.launcher.groupName.info")}),children:i("multirun.launcher.groupName.label")}),s.jsx(An,{id:"group-name",value:o,onChange:q=>l(q.target.value),placeholder:i("multirun.launcher.groupName.placeholder"),className:"typography-meta w-full",required:!0})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Xn,{htmlFor:"multirun-worktree-base-branch",info:s.jsx(Ao,{children:i("multirun.launcher.baseBranch.info")}),children:i("multirun.launcher.baseBranch.label")}),s.jsx(mC,{directory:W,value:we,onChange:ye,disabled:!le,id:"multirun-worktree-base-branch"}),s.jsxs("label",{className:"mt-1.5 flex w-fit items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(pr,{checked:C,onChange:k,disabled:!Q,ariaLabel:i("multirun.launcher.isolateRuns.label")}),s.jsx("span",{children:i("multirun.launcher.isolateRuns.label")})]})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Xn,{htmlFor:"multirun-agent",info:s.jsx(Ao,{children:i("multirun.launcher.agent.info")}),children:i("multirun.launcher.agent.label")}),s.jsx(Kf,{value:u,onChange:h,id:"multirun-agent"})]})]}),s.jsxs(Bi,{open:m,onOpenChange:p,children:[s.jsxs(mu,{className:"w-full flex items-center gap-2 py-1.5 px-2 -mx-2 rounded-lg hover:bg-[var(--interactive-hover)]/50 transition-colors group",children:[s.jsx(M,{name:"terminal",className:"h-3.5 w-3.5 text-muted-foreground/70"}),s.jsx("span",{className:"typography-meta font-medium text-muted-foreground group-hover:text-foreground transition-colors",children:i("multirun.launcher.setupCommands.label")}),se>0&&s.jsx("span",{className:"inline-flex items-center justify-center h-4 min-w-4 px-1 rounded-full typography-micro font-medium",style:{backgroundColor:"var(--primary-base)",color:"var(--primary-foreground)",fontSize:"0.625rem",lineHeight:1},children:se}),s.jsx(M,{name:"arrow-down-s",className:Oe("h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto",m&&"rotate-180")})]}),s.jsx(Fi,{children:s.jsx("div",{className:"pt-2 space-y-1.5",children:S?s.jsx("p",{className:"typography-meta text-muted-foreground/70 px-2",children:i("multirun.launcher.setupCommands.loading")}):s.jsxs(s.Fragment,{children:[v.map((q,z)=>s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(An,{value:q,onChange:ee=>{const ae=[...v];ae[z]=ee.target.value,y(ae)},placeholder:i("multirun.launcher.setupCommands.commandPlaceholder"),className:"h-8 flex-1 font-mono text-xs"}),s.jsx("button",{type:"button",onClick:()=>y(v.filter((ee,ae)=>ae!==z)),className:"flex-shrink-0 flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":i("multirun.launcher.setupCommands.removeCommandAria"),children:s.jsx(M,{name:"close",className:"h-3.5 w-3.5"})})]},`${q}-${z}`)),s.jsxs("button",{type:"button",onClick:()=>y([...v,""]),className:"flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1",children:[s.jsx(M,{name:"add",className:"h-3 w-3"}),i("multirun.launcher.setupCommands.addCommand")]})]})})})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Xn,{htmlFor:"prompt",required:!0,children:i("multirun.launcher.attachments.label")}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx("input",{ref:j,type:"file",multiple:!0,className:"hidden",onChange:B,accept:"*/*"}),s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>j.current?.click(),className:"inline-flex items-center gap-1 h-6 px-2 rounded-md typography-micro text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(M,{name:"attachment-2",className:"h-3 w-3"}),i("multirun.launcher.attachments.attach")]})}),s.jsx(Dt,{children:i("multirun.launcher.attachments.tooltip")})]}),f.map(q=>s.jsxs("div",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md typography-micro border",style:{backgroundColor:"var(--surface-elevated)",borderColor:"var(--interactive-border)"},children:[q.mimeType.startsWith("image/")?s.jsx(M,{name:"file-image",className:"h-3 w-3 text-muted-foreground"}):s.jsx(M,{name:"file",className:"h-3 w-3 text-muted-foreground"}),s.jsx("span",{className:"truncate max-w-[100px]",title:q.filename,children:q.filename}),s.jsx("button",{type:"button",onClick:()=>he(q.id),className:"text-muted-foreground hover:text-destructive",children:s.jsx(M,{name:"close",className:"h-3 w-3"})})]},q.id))]})]}),a.map((q,z)=>s.jsx(gC,{group:q,groupIndex:z,canRemove:a.length>1,onUpdate:oe,onRemove:de},q.id)),s.jsxs("button",{type:"button",onClick:_,className:"flex items-center gap-1.5 py-2 px-3 -mx-3 rounded-lg typography-meta font-medium text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(M,{name:"add",className:"h-3.5 w-3.5"}),i("multirun.launcher.groups.addGroup")]}),me&&s.jsx("div",{className:"px-3 py-2 rounded-lg typography-meta",style:{backgroundColor:"var(--status-error-background)",color:"var(--status-error)",borderWidth:1,borderColor:"var(--status-error-border)"},children:me})]})})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl flex items-center justify-end gap-2",children:[!le&&pe!==null?s.jsxs("div",{className:"mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(M,{name:"information",className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:i("multirun.launcher.project.gitRequired")})]}):null,!r&&n?s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:n,children:i("multirun.launcher.actions.cancel")}):null,s.jsx(dt,{type:"submit",size:"sm",disabled:!ce||b,children:b?i("multirun.launcher.actions.creating"):s.jsx(s.Fragment,{children:i("multirun.launcher.actions.startWithRunCount",{count:ve})})})]})})]})},gC=t=>{const e=Ze.c(99),{group:n,groupIndex:r,canRemove:i,onUpdate:o,onRemove:l}=t,{t:a}=jt(),[d,u]=c.useState(!1),[h,f]=c.useState(""),[x,b]=c.useState(!1),[w,v]=c.useState(""),[y,m]=c.useState(!1),[p,S]=c.useState(""),g=c.useRef(null),C=c.useRef(null),k=c.useRef(null),j=c.useRef(null);let D;e[0]!==n.id||e[1]!==n.models||e[2]!==o?(D=ae=>{o(n.id,{models:[...n.models,ae]})},e[0]=n.id,e[1]=n.models,e[2]=o,e[3]=D):D=e[3];const I=D;let A;e[4]!==n.id||e[5]!==n.models||e[6]!==o?(A=ae=>{o(n.id,{models:n.models.filter((Ne,Ce)=>Ce!==ae)})},e[4]=n.id,e[5]=n.models,e[6]=o,e[7]=A):A=e[7];const P=A;let T;e[8]!==n.id||e[9]!==n.models||e[10]!==o?(T=(ae,Ne)=>{o(n.id,{models:n.models.map((Ce,We)=>We===ae?Ne:Ce)})},e[8]=n.id,e[9]=n.models,e[10]=o,e[11]=T):T=e[11];const L=T;let $;e[12]===Symbol.for("react.memo_cache_sentinel")?($=(ae,Ne)=>{if(ae.startsWith("/")){const xe=ae.indexOf(" "),$e=ae.indexOf(`
|
|
893
|
-
`),V=Math.min(xe===-1?ae.length:xe,$e===-1?ae.length:$e);if(Ne<=V&&xe===-1){v(ae.substring(1,V)),b(!0),u(!1),m(!1);return}}b(!1);const Ce=ae.substring(0,Ne),We=Ce.lastIndexOf("#");if(We!==-1){const xe=We>0?Ce[We-1]:null,$e=Ce.substring(We+1);if((!xe||/\s/.test(xe))&&!$e.includes(" ")&&!$e.includes(`
|
|
894
|
-
`)){S($e),m(!0),u(!1);return}}m(!1);const Ee=Ce.lastIndexOf("@");if(Ee!==-1){const xe=Ee>0?Ce[Ee-1]:null,$e=Ce.substring(Ee+1);(!xe||/\s/.test(xe))&&!$e.includes(" ")&&!$e.includes(`
|
|
895
|
-
`)?(f($e),u(!0)):u(!1);return}u(!1)},e[12]=$):$=e[12];const K=$;let F;e[13]!==n.id||e[14]!==o?(F=ae=>{o(n.id,{prompt:ae})},e[13]=n.id,e[14]=o,e[15]=F):F=e[15];const W=F;let N;e[16]!==n.prompt||e[17]!==W?(N=ae=>{const Ne=n.prompt,We=g.current?.selectionStart??Ne.length,xe=Ne.substring(0,We).lastIndexOf("@"),$e=ae.relativePath&&ae.relativePath.trim().length>0?ae.relativePath.trim():ae.path||ae.name,V=xe!==-1?xe:We,De=`${Ne.substring(0,V)}@${$e} ${Ne.substring(We)}`,Fe=V+$e.length+2;W(De),u(!1),f(""),requestAnimationFrame(()=>{const _e=g.current;_e&&(_e.selectionStart=Fe,_e.selectionEnd=Fe,_e.focus()),K(De,Fe)})},e[16]=n.prompt,e[17]=W,e[18]=N):N=e[18];const R=N;let E;e[19]!==n.prompt||e[20]!==W?(E=ae=>{const Ne=n.prompt,We=g.current?.selectionStart??Ne.length,xe=Ne.substring(0,We).lastIndexOf("@"),$e=xe!==-1?xe:We,V=`${Ne.substring(0,$e)}@${ae} ${Ne.substring(We)}`,De=$e+ae.length+2;W(V),u(!1),f(""),requestAnimationFrame(()=>{const Fe=g.current;Fe&&(Fe.selectionStart=De,Fe.selectionEnd=De,Fe.focus()),K(V,De)})},e[19]=n.prompt,e[20]=W,e[21]=E):E=e[21];const X=E;let J;e[22]!==W?(J=ae=>{const Ne=`/${ae.name} `;W(Ne),b(!1),v(""),m(!1),requestAnimationFrame(()=>{const Ce=g.current;Ce&&(Ce.focus(),Ce.selectionStart=Ce.value.length,Ce.selectionEnd=Ce.value.length),K(Ne,Ne.length)})},e[22]=W,e[23]=J):J=e[23];const re=J;let fe;e[24]!==n.prompt||e[25]!==W?(fe=(ae,Ne)=>{const Ce=n.prompt,Ee=g.current?.selectionStart??Ce.length,$e=Ce.substring(0,Ee).lastIndexOf("#"),V=$e!==-1?$e:Ee,De=`${Ce.substring(0,V)}#${Ne} ${Ce.substring(Ee)}`,Fe=V+Ne.length+2;W(De),m(!1),S(""),requestAnimationFrame(()=>{const _e=g.current;_e&&(_e.selectionStart=Fe,_e.selectionEnd=Fe,_e.focus()),K(De,Fe)})},e[24]=n.prompt,e[25]=W,e[26]=fe):fe=e[26];const ne=fe;let te;e[27]!==x||e[28]!==d||e[29]!==y?(te=ae=>{if(x&&k.current&&(ae.key==="Enter"||ae.key==="ArrowUp"||ae.key==="ArrowDown"||ae.key==="Escape"||ae.key==="Tab")){ae.preventDefault(),k.current.handleKeyDown(ae.key);return}d&&C.current&&(ae.key==="Enter"||ae.key==="ArrowUp"||ae.key==="ArrowDown"||ae.key==="Escape"||ae.key==="Tab")&&(ae.preventDefault(),C.current.handleKeyDown(ae.key)),y&&j.current&&(ae.key==="Enter"||ae.key==="ArrowUp"||ae.key==="ArrowDown"||ae.key==="Escape"||ae.key==="Tab")&&(ae.preventDefault(),j.current.handleKeyDown(ae.key))},e[27]=x,e[28]=d,e[29]=y,e[30]=te):te=e[30];const ue=te,Se=r+1;let we;e[31]!==a||e[32]!==Se?(we=a("multirun.launcher.groups.groupLabel",{index:Se}),e[31]=a,e[32]=Se,e[33]=we):we=e[33];let ye;e[34]!==we?(ye=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:we}),e[34]=we,e[35]=ye):ye=e[35];let Ae;e[36]!==i||e[37]!==n.id||e[38]!==l||e[39]!==a?(Ae=i&&s.jsx("button",{type:"button",onClick:()=>l(n.id),className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10","aria-label":a("multirun.launcher.groups.removeGroup"),children:s.jsx(M,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=i,e[37]=n.id,e[38]=l,e[39]=a,e[40]=Ae):Ae=e[40];let pe;e[41]!==ye||e[42]!==Ae?(pe=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[ye,Ae]}),e[41]=ye,e[42]=Ae,e[43]=pe):pe=e[43];let O;e[44]!==a?(O=a("multirun.launcher.groups.prompt.label"),e[44]=a,e[45]=O):O=e[45];let Q;e[46]!==O?(Q=s.jsx(Xn,{required:!0,children:O}),e[46]=O,e[47]=Q):Q=e[47];const le=n.prompt;let H;e[48]!==W?(H=ae=>{const Ne=ae.target.value;W(Ne);const Ce=ae.target.selectionStart??Ne.length;K(Ne,Ce)},e[48]=W,e[49]=H):H=e[49];let me;e[50]!==a?(me=a("multirun.launcher.groups.prompt.placeholder"),e[50]=a,e[51]=me):me=e[51];let ge;e[52]!==n.prompt||e[53]!==ue||e[54]!==H||e[55]!==me?(ge=s.jsx(fr,{ref:g,value:le,onChange:H,onKeyDown:ue,placeholder:me,className:"typography-meta min-h-[80px] max-h-[200px] resize-none overflow-y-auto field-sizing-content",required:!0}),e[52]=n.prompt,e[53]=ue,e[54]=H,e[55]=me,e[56]=ge):ge=e[56];let oe;e[57]!==w||e[58]!==re||e[59]!==x?(oe=x?s.jsx(Mu,{ref:k,searchQuery:w,onCommandSelect:re,onClose:()=>b(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=w,e[58]=re,e[59]=x,e[60]=oe):oe=e[60];let de;e[61]!==X||e[62]!==R||e[63]!==h||e[64]!==d?(de=d?s.jsx(Ou,{ref:C,searchQuery:h,onFileSelect:R,onAgentSelect:X,onClose:()=>u(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=X,e[62]=R,e[63]=h,e[64]=d,e[65]=de):de=e[65];let _;e[66]!==ne||e[67]!==y||e[68]!==p?(_=y?s.jsx(Bu,{ref:j,searchQuery:p,onSnippetSelect:ne,onClose:()=>m(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=ne,e[67]=y,e[68]=p,e[69]=_):_=e[69];let B;e[70]!==ge||e[71]!==oe||e[72]!==de||e[73]!==_?(B=s.jsxs("div",{className:"relative",children:[ge,oe,de,_]}),e[70]=ge,e[71]=oe,e[72]=de,e[73]=_,e[74]=B):B=e[74];let he;e[75]!==Q||e[76]!==B?(he=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[Q,B]}),e[75]=Q,e[76]=B,e[77]=he):he=e[77];let ve;e[78]!==a?(ve=a("multirun.launcher.models.info"),e[78]=a,e[79]=ve):ve=e[79];let Re;e[80]!==ve?(Re=s.jsx(Ao,{children:ve}),e[80]=ve,e[81]=Re):Re=e[81];let ce;e[82]!==a?(ce=a("multirun.launcher.models.label"),e[82]=a,e[83]=ce):ce=e[83];let se;e[84]!==Re||e[85]!==ce?(se=s.jsx(Xn,{required:!0,info:Re,children:ce}),e[84]=Re,e[85]=ce,e[86]=se):se=e[86];let q;e[87]!==n.models||e[88]!==I||e[89]!==P||e[90]!==L?(q=s.jsx(Vf,{selectedModels:n.models,onAdd:I,onRemove:P,onUpdate:L,minModels:1}),e[87]=n.models,e[88]=I,e[89]=P,e[90]=L,e[91]=q):q=e[91];let z;e[92]!==se||e[93]!==q?(z=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[se,q]}),e[92]=se,e[93]=q,e[94]=z):z=e[94];let ee;return e[95]!==pe||e[96]!==he||e[97]!==z?(ee=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[pe,he,z]}),e[95]=pe,e[96]=he,e[97]=z,e[98]=ee):ee=e[98],ee};function xC(t){const e=[],n=(r,i)=>{const o=ht(r);!o||e.some(l=>l.directory===o)||e.push({directory:o,priority:"selected",reason:i})};return n(t.currentDirectory,"current-directory"),n(t.currentSessionDirectory,"selected-session"),e}const bC=t=>{const e=new Map;for(const n of t){const r=Ds(n);r&&e.set(n.id,{directory:r,sessionId:n.id})}return e},yC=(t,e)=>{if(!t)return[];const n=[];return t.forEach((r,i)=>{e.has(i)||n.push(r)}),n},wC=t=>{const e=Ze.c(5),{enabled:n,hasAuthoritativeGlobalSessions:r,sessions:i}=t,o=n===void 0?!0:n,l=c.useRef(null);let a,d;e[0]!==o||e[1]!==r||e[2]!==i?(a=()=>{if(!o||!r)return;const u=qt(),h=bC(i),f=l.current?.runtimeKey===u?l.current.identities:null;for(const x of yC(f,h))Hg({runtimeKey:u,...x});l.current={runtimeKey:u,identities:h}},d=[o,r,i],e[0]=o,e[1]=r,e[2]=i,e[3]=a,e[4]=d):(a=e[3],d=e[4]),c.useEffect(a,d)},vC=new Map,SC=t=>{const e=Ze.c(23),{isVSCode:n}=t,r=Yo(),i=Ht(jC),o=ns(kC),l=tt(CC);let a;e[0]!==n?(a=I=>n?vC:I.availableWorktreesByProject,e[0]=n,e[1]=a):a=e[1];const d=tt(a),u=!n;let h;e[2]!==d||e[3]!==i||e[4]!==u?(h=Xf(i,d,{includeWorktrees:u}),e[2]=d,e[3]=i,e[4]=u,e[5]=h):h=e[5];const f=h,x=$s(NC),b=$s(AC),w=$s(DC),v=`session-list-sync:${c.useId()}`;let y,m;e[6]!==v||e[7]!==r||e[8]!==o||e[9]!==l?(y=()=>(r.setBootstrapDemand(v,xC({currentDirectory:o,currentSessionDirectory:l})),()=>r.clearBootstrapDemand(v)),m=[v,r,o,l],e[6]=v,e[7]=r,e[8]=o,e[9]=l,e[10]=y,e[11]=m):(y=e[10],m=e[11]),c.useEffect(y,m);const p=c.useRef(null);let S,g;e[12]!==n||e[13]!==f?(S=()=>{const I=new Set(f),A=p.current;p.current=I;const P=A?[...I].filter(T=>!A.has(T)):n?[...I]:[];P.length&&ka(P,To())},g=[n,f],e[12]=n,e[13]=f,e[14]=S,e[15]=g):(S=e[14],g=e[15]),c.useEffect(S,g);let C;e[16]===Symbol.for("react.memo_cache_sentinel")?(C=[],e[16]=C):C=e[16],c.useEffect(PC,C);let k;e[17]!==b||e[18]!==x?(k=[...x,...b],e[17]=b,e[18]=x,e[19]=k):k=e[19];const j=k;let D;e[20]!==j||e[21]!==w?(D={enabled:!0,hasAuthoritativeGlobalSessions:w,sessions:j},e[20]=j,e[21]=w,e[22]=D):D=e[22],wC(D)};function jC(t){return t.projects}function kC(t){return t.currentDirectory}function CC(t){return t.currentSessionDirectory}function NC(t){return t.activeSessions}function AC(t){return t.archivedSessions}function DC(t){return t.status==="ready"}function PC(){let t=null,e=!1;const n=new Set,r=eo(i=>{if(i.type==="scheduled-task-ran")e=!0;else if(i.type==="session-created")n.add(i.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,n.clear(),za(To());return}const o=[...n];n.clear(),o.length&&ka(o,To())},500)});return()=>{t&&clearTimeout(t),r()}}const IC=Wn(()=>En(()=>import("./SettingsWindow-B5CHoJFZ.js"),__vite__mapDeps([144,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,145,84,85,86,146,131,132,133,134,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,147,148,149])).then(t=>({default:t.SettingsWindow}))),TC=()=>{const t=Ze.c(72);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],SC(e),Wh();const n=Pe(EC),r=Pe(RC),i=Pe(MC),o=Pe(OC),[l,a]=c.useState(!1);let d,u;t[1]!==i?(d=()=>{i&&a(!0)},u=[i],t[1]=i,t[2]=d,t[3]=u):(d=t[2],u=t[3]),c.useEffect(d,u);const h=Pe(BC),f=Pe(FC),x=Pe(_C),b=Pe(LC),w=Pe($C),v=Pe(zC),y=Pe(WC),m=Cu();let p;if(t[4]!==m||t[5]!==y){let B;t[7]!==y?(B=he=>he.id===y,t[7]=y,t[8]=B):B=t[8],p=m.find(B),t[4]=m,t[5]=y,t[6]=p}else p=t[6];const S=p;let g,C;t[9]!==S||t[10]!==y?(g=()=>{y&&!S&&Pe.getState().setOpenGuestPage(null)},C=[y,S],t[9]=S,t[10]=y,t[11]=g,t[12]=C):(g=t[11],C=t[12]),c.useEffect(g,C);let k;t[13]===Symbol.for("react.memo_cache_sentinel")?(k=[],t[13]=k):k=t[13],c.useEffect(VC,k);const j=b||w||!!v||h||!!S;let D;t[14]===Symbol.for("react.memo_cache_sentinel")?(D=[],t[14]=D):D=t[14],c.useEffect(HC,D);const{isMobile:I}=zn();Kh();const A=ty();let P,T;t[15]!==I||t[16]!==r?(P=()=>{Pe.getState().isMobile!==I&&r(I)},T=[I,r],t[15]=I,t[16]=r,t[17]=P,t[18]=T):(P=t[17],T=t[18]),c.useEffect(P,T);let L,$,K,F;t[19]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx($S,{}),$=s.jsx(F0,{}),K=s.jsx(z0,{}),F=s.jsx(y4,{}),t[19]=L,t[20]=$,t[21]=K,t[22]=F):(L=t[19],$=t[20],K=t[21],F=t[22]);let W;t[23]!==A?(W=s.jsx(w4,{value:A,onMoveSessionOnly:GC,onMoveAllChanges:qC,onCancel:dy}),t[23]=A,t[24]=W):W=t[24];let N;t[25]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx(by,{}),t[25]=N):N=t[25];let R;t[26]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx(xy,{}),t[26]=R):R=t[26];let E;t[27]!==n?(E=s.jsx(b4,{isVisible:n}),t[27]=n,t[28]=E):E=t[28];let X;t[29]!==I||t[30]!==n||t[31]!==E?(X=s.jsx(gy,{isOpen:n,isMobile:I,className:"border-border",topBar:R,children:E}),t[29]=I,t[30]=n,t[31]=E,t[32]=X):X=t[32];let J;t[33]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsx(hy,{}),t[33]=J):J=t[33];const re=j&&"invisible";let fe;t[34]!==re?(fe=Oe("absolute inset-0",re),t[34]=re,t[35]=fe):fe=t[35];const ne=!i&&!j;let te;t[36]!==ne?(te=s.jsx(As,{children:s.jsx(Hd,{active:ne})}),t[36]=ne,t[37]=te):te=t[37];let ue;t[38]!==fe||t[39]!==te?(ue=s.jsx("div",{className:fe,children:te}),t[38]=fe,t[39]=te,t[40]=ue):ue=t[40];let Se;t[41]!==h||t[42]!==x||t[43]!==f?(Se=h&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(As,{children:s.jsx(pC,{isWindowed:!0,initialPrompt:x,onCreated:()=>f(!1),onCancel:()=>f(!1)})})}),t[41]=h,t[42]=x,t[43]=f,t[44]=Se):Se=t[44];let we;t[45]===Symbol.for("react.memo_cache_sentinel")?(we=s.jsx(As,{children:s.jsx(G4,{})}),t[45]=we):we=t[45];let ye;t[46]===Symbol.for("react.memo_cache_sentinel")?(ye=s.jsx(As,{children:s.jsx(q4,{})}),t[46]=ye):ye=t[46];let Ae;t[47]===Symbol.for("react.memo_cache_sentinel")?(Ae=s.jsx(As,{children:s.jsx(rC,{})}),t[47]=Ae):Ae=t[47];let pe;t[48]!==S?(pe=S&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(As,{children:s.jsx(ob,{mode:`plugin:${S.id}`,surface:"page",item:null,onDismiss:YC})})}),t[48]=S,t[49]=pe):pe=t[49];let O;t[50]!==ue||t[51]!==Se||t[52]!==pe?(O=s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[ue,Se,we,ye,Ae,pe]}),t[50]=ue,t[51]=Se,t[52]=pe,t[53]=O):O=t[53];let Q;t[54]===Symbol.for("react.memo_cache_sentinel")?(Q=s.jsx(lS,{}),t[54]=Q):Q=t[54];let le;t[55]!==O?(le=s.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border bg-background","data-page-scroll-lock":"true",children:s.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children:s.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true","data-chat-area":"true",children:[O,Q]})})}),t[55]=O,t[56]=le):le=t[56];let H;t[57]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(As,{children:s.jsx(bS,{})})}),t[57]=H):H=t[57];let me;t[58]===Symbol.for("react.memo_cache_sentinel")?(me=s.jsx(As,{children:s.jsx(Tx,{})}),t[58]=me):me=t[58];let ge;t[59]!==le?(ge=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[J,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[le,H,me]})]}),t[59]=le,t[60]=ge):ge=t[60];let oe;t[61]!==X||t[62]!==ge?(oe=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[X,ge]}),t[61]=X,t[62]=ge,t[63]=oe):oe=t[63];let de;t[64]!==i||t[65]!==o||t[66]!==l?(de=l?s.jsx(c.Suspense,{fallback:null,children:s.jsx(IC,{open:i,onOpenChange:o})}):null,t[64]=i,t[65]=o,t[66]=l,t[67]=de):de=t[67];let _;return t[68]!==W||t[69]!==oe||t[70]!==de?(_=s.jsx(Vh,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[L,$,K,F,W,N,oe,de]})}),t[68]=W,t[69]=oe,t[70]=de,t[71]=_):_=t[71],_};function EC(t){return t.isSidebarOpen}function RC(t){return t.setIsMobile}function MC(t){return t.isSettingsDialogOpen}function OC(t){return t.setSettingsDialogOpen}function BC(t){return t.isMultiRunLauncherOpen}function FC(t){return t.setMultiRunLauncherOpen}function _C(t){return t.multiRunLauncherPrefillPrompt}function LC(t){return t.isScheduledTasksDialogOpen}function $C(t){return t.isArchivePageOpen}function zC(t){return t.worktreesPageProjectId}function WC(t){return t.openGuestPageId}function KC(){return Pe.getState().setOpenGuestPage(null)}function VC(){return Qr(KC)}function UC(){return Pe.getState().closeMainSurfaces()}function HC(){const t=UC,e=tt.subscribe((n,r)=>{const i=!!n.currentSessionId&&n.currentSessionId!==r.currentSessionId,o=!!n.newSessionDraft?.open&&n.newSessionDraft!==r.newSessionDraft;(i||o)&&t()});return()=>{e()}}function GC(){return rf(!1)}function qC(){return rf(!0)}function YC(){return Pe.getState().setOpenGuestPage(null)}const tm=12,QC=[{id:"left",x:22,y:58,delay:0,radius:120,colorVar:"--status-success"},{id:"center",x:50,y:42,delay:120,radius:150,colorVar:"--primary-base"},{id:"right",x:78,y:55,delay:200,radius:130,colorVar:"--status-info"}],XC=t=>{const e=Ze.c(18),{isActive:n,burstKey:r,className:i,durationMs:o,bursts:l,onComplete:a}=t,d=r===void 0?0:r,u=o===void 0?900:o,h=l===void 0?QC:l,f=mt.useRef(!1);let x,b;e[0]!==n||e[1]!==a?(x=()=>{!n&&f.current&&a?.(),n&&(f.current=!0)},b=[n,a],e[0]=n,e[1]=a,e[2]=x,e[3]=b):(x=e[2],b=e[3]),mt.useEffect(x,b);let w;e[4]===Symbol.for("react.memo_cache_sentinel")?(w=Array.from({length:tm},JC),e[4]=w):w=e[4];const v=w;if(!n)return null;let y;e[5]!==i?(y=Oe("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=y):y=e[6];let m;if(e[7]!==d||e[8]!==h||e[9]!==u){let S;e[11]!==d||e[12]!==u?(S=g=>{const C={"--burst-delay":`${g.delay}ms`,"--burst-x":`${g.x}%`,"--burst-y":`${g.y}%`,"--firework-color":`var(${g.colorVar})`,"--firework-duration":`${u}ms`};return s.jsx("div",{className:"firework-burst",style:C,children:v.map((k,j)=>{const D=k.x*g.radius,I=k.y*g.radius,A={"--translate-x":`${D}px`,"--translate-y":`${I}px`,"--particle-delay":`${k.delay}ms`,color:`var(${g.colorVar})`};return s.jsx("span",{className:"firework-particle",style:A},`${g.id}-${j}-${d}`)})},`${g.id}-${d}`)},e[11]=d,e[12]=u,e[13]=S):S=e[13],m=h.map(S),e[7]=d,e[8]=h,e[9]=u,e[10]=m}else m=e[10];let p;return e[14]!==d||e[15]!==y||e[16]!==m?(p=s.jsx("div",{className:y,"aria-hidden":"true","data-burst-key":d,children:m}),e[14]=d,e[15]=y,e[16]=m,e[17]=p):p=e[17],p};function JC(t,e){const n=Math.PI*2*e/tm;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const ZC=t=>{const e=Ze.c(13);let n;e[0]!==t?(n={},e[0]=t,e[1]=n):n=e[1];const{durationMs:r}=n,i=r===void 0?3400:r;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o={isActive:!1,cycle:0},e[2]=o):o=e[2];const[l,a]=mt.useState(o),d=mt.useRef(null);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},e[3]=u):u=e[3];const h=u;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{h(),a(e5)},e[4]=f):f=e[4];const x=f;let b;e[5]!==i?(b=()=>{h(),a(t5),d.current=window.setTimeout(()=>{a(s5),d.current=null},i)},e[5]=i,e[6]=b):b=e[6];const w=b;let v,y;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>()=>h(),y=[h],e[7]=v,e[8]=y):(v=e[7],y=e[8]),mt.useEffect(v,y);let m;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==w?(m={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:w,dismissFireworks:x},e[9]=l.cycle,e[10]=l.isActive,e[11]=w,e[12]=m):m=e[12],m};function e5(t){return t.isActive?{...t,isActive:!1}:t}function t5(t){return{isActive:!0,cycle:t.cycle+1}}function s5(t){return t.isActive?{...t,isActive:!1}:t}const sm=c.createContext(void 0),n5=t=>{const e=Ze.c(10),{children:n}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=ZC();let a;e[0]!==l||e[1]!==o?(a={triggerFireworks:o,dismissFireworks:l},e[0]=l,e[1]=o,e[2]=a):a=e[2];const d=a;let u;e[3]!==i||e[4]!==r?(u=s.jsx(XC,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=u):u=e[5];let h;return e[6]!==n||e[7]!==u||e[8]!==d?(h=s.jsxs(sm.Provider,{value:d,children:[n,u]}),e[6]=n,e[7]=u,e[8]=d,e[9]=h):h=e[9],h},GN=()=>{const t=c.useContext(sm);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},ga="openchamber_requests_in_flight",nm=1e3,r5=300*1e3,Ko=Math.ceil(r5/nm),o5=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(ga)==="1"}catch{return!1}},rm=()=>({enabled:!0,startedAt:Date.now(),inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],peakAgeMs:0,inFlightStarts:new Map,sampleCount:0,lastSampleAt:null,fetchWrapped:!1,originalFetch:null,sampleTimer:null});let i5=1;const a5=(t,e)=>{const n=window.__openchamberRequestsInFlight__;!n||!n.enabled||(n.inFlight+=1,n.totalStarted+=1,n.inFlight>n.peak&&(n.peak=n.inFlight),n.inFlightStarts.set(t,e))},l5=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},om=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),n=[];for(const r of t.inFlightStarts.values())n.push(Math.max(0,e-r));return n.sort((r,i)=>r-i),n},Sr=(t,e)=>{const n=t.length;if(n===0)return 0;if(n===1)return t[0];const r=e/100*(n-1),i=Math.floor(r),o=Math.ceil(r);return i===o?t[i]:t[i]+(t[o]-t[i])*(r-i)},c5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t||t.fetchWrapped)return;const e=window.fetch.bind(window);t.originalFetch=e,t.fetchWrapped=!0;const n=async(r,i)=>{const o=i5++;a5(o,Date.now());try{return await e(r,i)}finally{l5(o)}};window.fetch=n},gd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Mr=t=>{t.length>Ko&&t.splice(0,t.length-Ko)},d5=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=om(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(Sr(e,50)),t.p90Samples.push(Sr(e,90)),t.p99Samples.push(Sr(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Mr(t.samples),Mr(t.p50Samples),Mr(t.p90Samples),Mr(t.p99Samples),Mr(t.maxSamples),t.lastSampleAt=Date.now()},u5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(d5,nm))},xd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},bd=t=>{if(!(typeof window>"u"))try{if(t){xd(),gd(),window.localStorage.setItem(ga,"1"),window.__openchamberRequestsInFlight__=rm(),c5(),u5();return}window.localStorage.removeItem(ga),xd(),gd(),delete window.__openchamberRequestsInFlight__}catch{}},f5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=rm();t.startedAt=e.startedAt,t.inFlight=e.inFlight,t.peak=e.peak,t.totalStarted=e.totalStarted,t.totalSettled=e.totalSettled,t.samples=e.samples,t.p50Samples=e.p50Samples,t.p90Samples=e.p90Samples,t.p99Samples=e.p99Samples,t.maxSamples=e.maxSamples,t.peakAgeMs=e.peakAgeMs,t.inFlightStarts=e.inFlightStarts,t.sampleCount=e.sampleCount,t.lastSampleAt=e.lastSampleAt},xa=()=>{if(typeof window>"u")return yd();const t=window.__openchamberRequestsInFlight__;if(!o5()||!t)return yd();const e=om(t);return{enabled:!0,startedAt:t.startedAt,durationMs:Math.max(0,Date.now()-t.startedAt),inFlight:t.inFlight,peak:t.peak,totalStarted:t.totalStarted,totalSettled:t.totalSettled,samples:t.samples.slice(),ageP50:Sr(e,50),ageP90:Sr(e,90),ageP99:Sr(e,99),ageMax:e.length>0?e[e.length-1]:0,peakAgeMs:t.peakAgeMs,p50Samples:t.p50Samples.slice(),p90Samples:t.p90Samples.slice(),p99Samples:t.p99Samples.slice(),maxSamples:t.maxSamples.slice(),sampleCount:t.sampleCount,lastSampleAt:t.lastSampleAt,windowSeconds:Ko}},yd=()=>({enabled:!1,startedAt:null,durationMs:0,inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],ageP50:0,ageP90:0,ageP99:0,ageMax:0,peakAgeMs:0,p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],sampleCount:0,lastSampleAt:null,windowSeconds:Ko});function m5(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const im=t=>{if(t<1e3)return`${Math.round(t)}ms`;const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const n=Math.floor(e/60),r=Math.round(e%60);return`${n}m ${r}s`},ba=t=>`${(t/1e3).toFixed(2)} s`,bs=t=>{const e=Ze.c(8),{label:n,value:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=i):i=e[0];let o;e[1]!==n?(o=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:n}),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==r?(l=s.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==o||e[6]!==l?(a=s.jsxs("div",{className:"rounded-md p-2",style:i,children:[o,l]}),e[5]=o,e[6]=l,e[7]=a):a=e[7],a},wd=t=>{const e=Ze.c(43),{title:n,snapshot:r,emptyLabel:i}=t,{t:o}=jt();let l;if(e[0]!==i||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==o||e[6]!==n){const a=r.entries.slice(0,12);let d;e[8]!==r.entries?(d=r.entries.reduce(g5,0),e[8]=r.entries,e[9]=d):d=e[9];const u=d;let h;e[10]!==n?(h=s.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:n}),e[10]=n,e[11]=h):h=e[11];let f;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==o?(f=r.startedAt?im(r.durationMs):o("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=o,e[15]=f):f=e[15];let x;e[16]!==f?(x=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=x):x=e[17];let b;e[18]!==h||e[19]!==x?(b=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h,x]}),e[18]=h,e[19]=x,e[20]=b):b=e[20];let w;e[21]!==o?(w=o("memoryDebugPanel.metric.metrics"),e[21]=o,e[22]=w):w=e[22];let v;e[23]!==r.entries.length||e[24]!==w?(v=s.jsx(bs,{label:w,value:r.entries.length}),e[23]=r.entries.length,e[24]=w,e[25]=v):v=e[25];let y;e[26]!==o?(y=o("memoryDebugPanel.metric.samples"),e[26]=o,e[27]=y):y=e[27];let m;e[28]!==y||e[29]!==u?(m=s.jsx(bs,{label:y,value:u}),e[28]=y,e[29]=u,e[30]=m):m=e[30];let p;e[31]!==o?(p=o("memoryDebugPanel.metric.lastUpdate"),e[31]=o,e[32]=p):p=e[32];let S;e[33]!==r.lastUpdatedAt||e[34]!==o?(S=r.lastUpdatedAt?o("memoryDebugPanel.common.live"):o("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=o,e[35]=S):S=e[35];let g;e[36]!==p||e[37]!==S?(g=s.jsx(bs,{label:p,value:S}),e[36]=p,e[37]=S,e[38]=g):g=e[38];let C;e[39]!==m||e[40]!==g||e[41]!==v?(C=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[v,m,g]}),e[39]=m,e[40]=g,e[41]=v,e[42]=C):C=e[42],l=s.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[b,C,a.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:i}):s.jsx(yn,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:a.map(k=>s.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] p-2",style:{backgroundColor:"color-mix(in srgb, var(--surface-elevated) 88%, transparent)"},children:[s.jsx("div",{className:"typography-meta font-medium text-[var(--surface-foreground)] break-all",children:k.metric}),s.jsxs("div",{className:"mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:o("memoryDebugPanel.metric.countValue",{value:k.count})}),s.jsx("span",{children:o("memoryDebugPanel.metric.avgValue",{value:k.avg})}),s.jsx("span",{children:o("memoryDebugPanel.metric.maxValue",{value:k.max})}),s.jsx("span",{children:o("memoryDebugPanel.metric.totalValue",{value:k.total})})]})]},k.metric))})})]}),e[0]=i,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=o,e[6]=n,e[7]=l}else l=e[7];return l},vd=t=>{const e=Ze.c(24),{series:n,peak:r,windowSeconds:i,ariaLabel:o,maxLabel:l}=t,a=i,d=n.reduce(x5,0),u=r>0?52/r:0;let h;e[0]!==d||e[1]!==a?(h=g=>a-d+g,e[0]=d,e[1]=a,e[2]=h):h=e[2];const f=h;let x;e[3]!==u?(x=g=>56-g*u,e[3]=u,e[4]=x):x=e[4];const b=x;let w;e[5]!==l?(w=s.jsx("span",{className:"pointer-events-none absolute left-0 top-0 typography-meta text-[var(--surface-muted-foreground)]",children:l}),e[5]=l,e[6]=w):w=e[6];const v=`0 0 ${a} 56`;let y;e[7]!==a?(y=s.jsx("line",{x1:0,y1:56,x2:a,y2:56,stroke:"var(--interactive-border)",strokeWidth:1,vectorEffect:"non-scaling-stroke"}),e[7]=a,e[8]=y):y=e[8];let m;if(e[9]!==n||e[10]!==f||e[11]!==b){let g;e[13]!==f||e[14]!==b?(g=(C,k)=>{const j=C.samples.length;if(j===0)return null;const D=C.samples.map((A,P)=>`${f(P)},${b(A).toFixed(2)}`),I=`M ${D.join(" L ")}`;return s.jsxs(c.Fragment,{children:[C.filled?s.jsx("path",{d:`M ${f(0)},56 L ${D.join(" L ")} L ${f(j-1)},56 Z`,fill:`color-mix(in srgb, ${C.color} 18%, transparent)`,stroke:"none"}):null,s.jsx("path",{d:I,fill:"none",stroke:C.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},k)},e[13]=f,e[14]=b,e[15]=g):g=e[15],m=n.map(g),e[9]=n,e[10]=f,e[11]=b,e[12]=m}else m=e[12];let p;e[16]!==o||e[17]!==v||e[18]!==y||e[19]!==m?(p=s.jsxs("svg",{viewBox:v,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":o,children:[y,m]}),e[16]=o,e[17]=v,e[18]=y,e[19]=m,e[20]=p):p=e[20];let S;return e[21]!==w||e[22]!==p?(S=s.jsxs("div",{className:"relative w-full",children:[w,p]}),e[21]=w,e[22]=p,e[23]=S):S=e[23],S},h5=t=>{const e=Ze.c(100),{onClose:n}=t,{t:r}=jt(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),d=tt(b5),u=Eu(y5),h=bu(),f=Gg(w5),x=Hs(v5),[b,w]=c.useState(S5),[v,y]=c.useState(j5),[m,p]=c.useState(k5),S=[{label:"p50",current:m.ageP50,samples:m.p50Samples,color:"var(--status-success)"},{label:"p90",current:m.ageP90,samples:m.p90Samples,color:"var(--status-info)"},{label:"p99",current:m.ageP99,samples:m.p99Samples,color:"var(--status-warning)"},{label:"max",current:m.ageMax,samples:m.maxSamples,color:"var(--status-error)"}];let g;e[0]!==m.samples?(g=m.samples.reduce(C5,0),e[0]=m.samples,e[1]=g):g=e[1];const C=g,k=S.reduce(A5,0);let j;e[2]!==b.entries?(j=new Map,b.entries.forEach(Fe=>{j.set(Fe.metric,Fe.count)}),e[2]=b.entries,e[3]=j):j=e[3];let D;e[4]!==j?(D=j.get("ui.message_list.render")??0,e[4]=j,e[5]=D):D=e[5];let I;e[6]!==j?(I=j.get("ui.message_list.render.streaming")??0,e[6]=j,e[7]=I):I=e[7];let A;e[8]!==j?(A=j.get("ui.chat_message.render")??0,e[8]=j,e[9]=A):A=e[9];let P;e[10]!==j?(P=j.get("ui.chat_message.render.streaming")??0,e[10]=j,e[11]=P):P=e[11];let T;e[12]!==j?(T=j.get("ui.chat_message.render.static_during_stream")??0,e[12]=j,e[13]=T):T=e[13];let L;e[14]!==j?(L=j.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=j,e[15]=L):L=e[15];let $;e[16]!==D||e[17]!==I||e[18]!==A||e[19]!==P||e[20]!==T||e[21]!==L?($={messageListRender:D,messageListRenderStreaming:I,chatMessageRender:A,chatMessageRenderStreaming:P,chatMessageRenderStaticDuringStream:T,chatMessageRenderStaticOutsideActiveTurnDuringStream:L},e[16]=D,e[17]=I,e[18]=A,e[19]=P,e[20]=T,e[21]=L,e[22]=$):$=e[22];const K=$;let F,W;e[23]===Symbol.for("react.memo_cache_sentinel")?(W=()=>{const Fe=()=>{w(bo()),y(yo()),p(xa())};Fe();const _e=window.setInterval(Fe,500);return()=>window.clearInterval(_e)},F=[],e[23]=F,e[24]=W):(F=e[23],W=e[24]),c.useEffect(W,F);let N,R;e[25]!==l?(N=()=>{if(l==="idle")return;const Fe=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(Fe)},R=[l],e[25]=l,e[26]=N,e[27]=R):(N=e[26],R=e[27]),c.useEffect(N,R);let E=0,X=0,J=0;for(const Fe of Object.keys(f)){const _e=f[Fe]??[];X=X+_e.length;for(const rt of _e)rt.role==="user"?J=J+1:rt.role==="assistant"&&(E=E+1)}let re;e[28]!==E||e[29]!==X||e[30]!==J?(re={assistant:E,total:X,user:J},e[28]=E,e[29]=X,e[30]=J,e[31]=re):re=e[31];const fe=re;let ne;if(e[32]!==d||e[33]!==f||e[34]!==u||e[35]!==h||e[36]!==r){let Fe;e[38]!==d||e[39]!==f||e[40]!==u||e[41]!==r?(Fe=_e=>{const rt=f[_e.id]??[];let ct=0,et=0;for(const kt of rt)kt.role==="user"?et=et+1:kt.role==="assistant"&&(ct=ct+1);const pt=u.get(_e.id);return{id:_e.id,title:_e.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:ct,messageCount:rt.length,userMessageCount:et,isStreaming:pt?.isStreaming||!1,isZombie:pt?.isZombie||!1,backgroundCount:pt?.backgroundMessageCount||0,lastAccessed:pt?.lastAccessedAt||0,isCurrent:_e.id===d}},e[38]=d,e[39]=f,e[40]=u,e[41]=r,e[42]=Fe):Fe=e[42],ne=h.map(Fe).sort(D5),e[32]=d,e[33]=f,e[34]=u,e[35]=h,e[36]=r,e[37]=ne}else ne=e[37];const te=ne;let ue;e[43]!==f?(ue=Object.keys(f),e[43]=f,e[44]=ue):ue=e[44];const Se=ue.length;let we;e[45]===Symbol.for("react.memo_cache_sentinel")?(we=async()=>{try{const Fe={generatedAt:new Date().toISOString(),ui:bo(),vscode:yo()};await navigator.clipboard.writeText(JSON.stringify(Fe,null,2)),a("copied")}catch{a("error")}},e[45]=we):we=e[45];const ye=we,Ae=Yg,pe="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let O;e[46]===Symbol.for("react.memo_cache_sentinel")?(O={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=O):O=e[46];let Q;e[47]!==i?(Q=m5(i),e[47]=i,e[48]=Q):Q=e[48];let le;e[49]!==Q?(le=s.jsx(M,{name:Q,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=Q,e[50]=le):le=e[50];let H;e[51]!==r?(H=r("memoryDebugPanel.title"),e[51]=r,e[52]=H):H=e[52];let me;e[53]!==H?(me=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:H}),e[53]=H,e[54]=me):me=e[54];let ge;e[55]!==le||e[56]!==me?(ge=s.jsxs("div",{className:"flex items-center gap-2",children:[le,me]}),e[55]=le,e[56]=me,e[57]=ge):ge=e[57];let oe;e[58]!==i?(oe=i==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(dt,{size:"xs",variant:"ghost",onClick:ye,children:s.jsx(M,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(dt,{size:"xs",variant:"ghost",onClick:()=>{eh(),w(bo()),y(yo())},children:s.jsx(M,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=i,e[59]=oe):oe=e[59];let de;e[60]!==i?(de=i==="requests"?s.jsx(dt,{size:"xs",variant:"ghost",onClick:()=>{f5(),p(xa())},children:s.jsx(M,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=i,e[61]=de):de=e[61];let _;e[62]!==n?(_=n?s.jsx(dt,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(M,{name:"close",className:"h-4 w-4"})}):null,e[62]=n,e[63]=_):_=e[63];let B;e[64]!==oe||e[65]!==de||e[66]!==_?(B=s.jsxs("div",{className:"flex items-center gap-1",children:[oe,de,_]}),e[64]=oe,e[65]=de,e[66]=_,e[67]=B):B=e[67];let he;e[68]!==ge||e[69]!==B?(he=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[ge,B]}),e[68]=ge,e[69]=B,e[70]=he):he=e[70];let ve;e[71]===Symbol.for("react.memo_cache_sentinel")?(ve={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=ve):ve=e[71];const Re=i==="memory"?"secondary":"ghost";let ce;e[72]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>o("memory"),e[72]=ce):ce=e[72];let se;e[73]!==r?(se=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=se):se=e[74];let q;e[75]!==Re||e[76]!==se?(q=s.jsx(dt,{size:"sm",variant:Re,className:"flex-1",onClick:ce,children:se}),e[75]=Re,e[76]=se,e[77]=q):q=e[77];const z=i==="streaming"?"secondary":"ghost";let ee;e[78]===Symbol.for("react.memo_cache_sentinel")?(ee=()=>o("streaming"),e[78]=ee):ee=e[78];let ae;e[79]!==r?(ae=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=ae):ae=e[80];let Ne;e[81]!==z||e[82]!==ae?(Ne=s.jsx(dt,{size:"sm",variant:z,className:"flex-1",onClick:ee,children:ae}),e[81]=z,e[82]=ae,e[83]=Ne):Ne=e[83];const Ce=i==="requests"?"secondary":"ghost";let We;e[84]===Symbol.for("react.memo_cache_sentinel")?(We=()=>o("requests"),e[84]=We):We=e[84];let Ee;e[85]!==r?(Ee=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=Ee):Ee=e[86];let xe;e[87]!==Ce||e[88]!==Ee?(xe=s.jsx(dt,{size:"sm",variant:Ce,className:"flex-1",onClick:We,children:Ee}),e[87]=Ce,e[88]=Ee,e[89]=xe):xe=e[89];let $e;e[90]!==q||e[91]!==Ne||e[92]!==xe?($e=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:ve,children:[q,Ne,xe]}),e[90]=q,e[91]=Ne,e[92]=xe,e[93]=$e):$e=e[93];const V=i==="memory"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(bs,{label:r("memoryDebugPanel.metric.totalMessages"),value:fe.total}),s.jsx(bs,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${Se} / ${Fl.MAX_SESSIONS}`}),s.jsx(bs,{label:r("memoryDebugPanel.metric.userMessages"),value:fe.user}),s.jsx(bs,{label:r("memoryDebugPanel.metric.assistantMessages"),value:fe.assistant})]}),s.jsxs("div",{className:"typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2",children:[s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.viewportWindow")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.messagesValue",{count:qg()})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.zombieTimeout")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.minutesValue",{count:Fl.ZOMBIE_TIMEOUT/1e3/60})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.githubTotalRequests")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:x})]})]}),s.jsxs("div",{className:"border-t border-[var(--interactive-border)] pt-2",children:[s.jsx("div",{className:"mb-1 typography-meta font-semibold text-[var(--surface-foreground)]",children:r("memoryDebugPanel.section.sessionsInMemory")}),s.jsx(yn,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:te.map(Fe=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:Fe.isCurrent?"color-mix(in srgb, var(--interactive-selection) 22%, transparent)":"color-mix(in srgb, var(--surface-muted) 35%, transparent)"},children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx("span",{className:"truncate text-[var(--surface-foreground)]",children:Fe.title}),Fe.isStreaming?s.jsx(M,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,Fe.isZombie?s.jsx("span",{className:"text-[var(--status-warning)]",children:"!"}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.roleMsgsValue",{assistant:Fe.assistantMessageCount,user:Fe.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:Fe.messageCount})}),Fe.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",Fe.backgroundCount]}):null]})]},Fe.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx(dt,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:h.map(P5),currentSessionId:d,cachedSessions:Object.keys(f),messageRoleCounts:fe,sessionMessageRoleCounts:te.map(I5),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(Dt,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):i==="streaming"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r(l==="copied"?"memoryDebugPanel.streaming.copy.copied":l==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),s.jsx(dt,{size:"xs",variant:"outline",onClick:ye,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(bs,{label:r("memoryDebugPanel.metric.uiMetrics"),value:b.entries.length}),s.jsx(bs,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:v.entries.length}),s.jsx(bs,{label:r("memoryDebugPanel.metric.messageListRenders"),value:K.messageListRender}),s.jsx(bs,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:K.messageListRenderStreaming}),s.jsx(bs,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:K.chatMessageRender}),s.jsx(bs,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:K.chatMessageRenderStreaming}),s.jsx(bs,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:K.chatMessageRenderStaticDuringStream}),s.jsx(bs,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:K.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(wd,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:b,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),v.entries.length>0?s.jsx(wd,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:v,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(bs,{label:r("memoryDebugPanel.requests.totalRequests"),value:`${m.totalSettled} / ${m.totalStarted}`}),s.jsx(bs,{label:r("memoryDebugPanel.requests.tracking"),value:m.startedAt?im(m.durationMs):r("memoryDebugPanel.common.idle")})]}),m.samples.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:r("memoryDebugPanel.requests.noSamples")}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.inFlight")}),s.jsxs("span",{children:[s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:m.inFlight}),s.jsxs("span",{className:"text-[var(--surface-muted-foreground)]",children:[" · ",r("memoryDebugPanel.requests.peak")," "]}),s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:m.peak})]})]}),s.jsx(vd,{series:[{samples:m.samples,color:"var(--status-info)",filled:!0}],peak:C,windowSeconds:m.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:m.peak}),maxLabel:`${C}`}),s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.duration")}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:ba(m.peakAgeMs)})]}),s.jsx(vd,{series:S.map(T5),peak:k,windowSeconds:m.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:ba(k)}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:S.map(E5)}),s.jsxs("div",{className:"flex items-center justify-between typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r("memoryDebugPanel.requests.windowHint",{seconds:m.windowSeconds})}),s.jsx("span",{children:r("memoryDebugPanel.requests.now")})]})]})]});let De;return e[94]!==Ae||e[95]!==O||e[96]!==he||e[97]!==$e||e[98]!==V?(De=s.jsxs(Ae,{className:pe,style:O,children:[he,$e,V]}),e[94]=Ae,e[95]=O,e[96]=he,e[97]=$e,e[98]=V,e[99]=De):De=e[99],De},p5=h5;function g5(t,e){return t+e.count}function x5(t,e){return Math.max(t,e.samples.length)}function b5(t){return t.currentSessionId}function y5(t){return t.sessionMemoryState}function w5(t){return t.message}function v5(t){return t.totalRequestCount}function S5(){return bo()}function j5(){return yo()}function k5(){return xa()}function C5(t,e){return Math.max(t,e)}function N5(t,e){return Math.max(t,e)}function A5(t,e){return e.samples.reduce(N5,t)}function D5(t,e){return e.lastAccessed-t.lastAccessed}function P5(t){return{id:t.id,title:t.title}}function I5(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function T5(t){return{samples:t.samples,color:t.color}}function E5(t){return s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:t.color}}),s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:t.label}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:ba(t.current)})]},t.label)}const R5=()=>{if(typeof document>"u")return"";const t=document.activeElement;if(t instanceof HTMLTextAreaElement)return t.value.slice(t.selectionStart??0,t.selectionEnd??0);if(t instanceof HTMLInputElement){const e=t.type?.toLowerCase()??"text";if(["text","search","url","tel","password"].includes(e))return t.value.slice(t.selectionStart??0,t.selectionEnd??0)}return t instanceof HTMLElement&&t.isContentEditable?t.ownerDocument.defaultView?.getSelection?.()?.toString()??"":""},M5=async()=>{const t=R5()||window.getSelection()?.toString()||"";if(!t.trim())return!1;try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(t),!0}catch{}return document.execCommand("copy")},Sd="openchamber:menu-action",Ci="openchamber:check-for-updates",O5=t=>{const e=tt(m=>m.openNewSessionDraft),n=Pe(m=>m.toggleCommandPalette),r=Pe(m=>m.setCommandPaletteOpen),i=Pe(m=>m.toggleHelpDialog),o=Pe(m=>m.toggleSidebar),l=Pe(m=>m.setSessionSwitcherOpen),a=Pe(m=>m.setSettingsDialogOpen),d=Pe(m=>m.setAboutDialogOpen),u=zr(m=>m.checkForUpdates),{setThemeMode:h}=or(),f=c.useRef(!1),x=c.useCallback(()=>{f.current||(f.current=!0,u().then(()=>{const{available:m,error:p}=zr.getState();if(p){Le.error("Failed to check for updates",{description:p});return}m||Le.success("You are on the latest version")}).finally(()=>{f.current=!1}))},[u]),b=c.useCallback(()=>{fn.requestDirectoryDialog()},[]),w=c.useCallback(m=>{const p=Qg();if(p.length===0)return;const S=tt.getState().currentSessionId,g=p.findIndex(j=>j.id===S);let C=m>0?0:p.length-1;g>=0&&(C=(g+m+p.length)%p.length);const k=p[C];k&&(l(!1),tt.getState().setCurrentSession(k.id))},[l]),v=c.useCallback(m=>{const{activeProjectId:p,projects:S,setActiveProject:g}=Ht.getState();if(S.length===0)return;const C=S.findIndex(D=>D.id===p);let k=m>0?0:S.length-1;C>=0&&(k=(C+m+S.length)%S.length);const j=S[k];j&&g(j.id)},[]),y=c.useCallback(m=>{switch(m){case"about":d(!0);break;case"settings":a(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const p=tt.getState(),S=ns.getState().currentDirectory;e(p.currentSessionId&&S?{directoryOverride:S}:void 0)}break;case"new-worktree-session":l(!1),ju();break;case"change-workspace":b();break;case"toggle-right-sidebar":{const p=ns.getState().currentDirectory;if(!p)break;const S=Pe.getState(),g=cr(p),C=S.contextPanelByDirectory[g];C?.isOpen?S.closeContextPanel(g):C?.activeTabId?S.setActiveContextPanelTab(g,C.activeTabId):S.openContextSurface(g,"git");break}case"open-right-sidebar-git":{const p=ns.getState().currentDirectory;if(!p)break;Pe.getState().openContextSurface(cr(p),"git");break}case"open-right-sidebar-files":{const p=ns.getState().currentDirectory;if(!p)break;Pe.getState().openContextSurface(cr(p),"file");break}case"toggle-terminal":{const p=ns.getState().currentDirectory;if(!p)break;Pe.getState().openContextSurface(cr(p),"terminal");break}case"toggle-terminal-expanded":{const p=ns.getState().currentDirectory;if(!p)break;const S=cr(p),g=Pe.getState(),C=g.contextPanelByDirectory[S];(C?.isOpen?C.tabs.find(j=>j.id===C.activeTabId)?.mode:null)!=="terminal"&&g.openContextSurface(S,"terminal"),g.toggleContextPanelExpanded(S);break}case"copy":{const p=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(p)||M5();break}case"theme-light":h("light");break;case"theme-dark":h("dark");break;case"theme-system":h("system");break;case"add-selection-to-chat":Xg();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":ns.getState().goBack();break;case"go-forward":ns.getState().goForward();break;case"previous-session":w(-1);break;case"next-session":w(1);break;case"previous-project":v(-1);break;case"next-project":v(1);break;case"help-dialog":i();break;case"download-logs":{ku().catch(()=>{Le.error("Failed to collect OpenCode status")});break}}},[b,v,w,t,e,d,l,r,a,h,n,i,o]);c.useEffect(()=>{const m=S=>{const g=S.detail;g&&y(g)},p=()=>{x()};return window.addEventListener(Sd,m),window.addEventListener(Ci,p),()=>{window.removeEventListener(Sd,m),window.removeEventListener(Ci,p)}},[y,x]),c.useEffect(()=>{if(typeof window>"u")return;const p=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof p!="function")return;let S=null,g=null;return p("openchamber:menu-action",C=>{const k=C?.payload;typeof k=="string"&&y(k)}).then(C=>{S=C}).catch(()=>{}),p("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(Ci))}).then(C=>{g=C}).catch(()=>{}),()=>{(async()=>{try{const k=S?.();k instanceof Promise&&await k}catch{}try{const k=g?.();k instanceof Promise&&await k}catch{}})()}},[y])},B5="openchamber:tray-action",F5=5e3,_5=500,L5=20,jd=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},kd=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,am=t=>{const e=typeof t.permission=="string"?t.permission:"Permission",n=Array.isArray(t.patterns)?t.patterns.find(r=>typeof r=="string"&&r.trim()):"";return n?`${e}: ${n}`:e},lm=t=>{const e=Array.isArray(t.questions)?t.questions[0]:void 0;return e?.header||e?.question||"Question"},$5=(t,e)=>Fa(t,e,Gr.getState().ids,Ta.getState().rankById),z5=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},W5=(t,e,n,r,i)=>{if(!t)return"";const o=qd(n,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||z5(t),d=vo(t);let u=d&&i.get(d)||"";if(!u){for(const[h,f]of Tn.getState().directories)if(vo(h)===d){u=f.status?.current??"";break}}if(!u)for(const h of r.values()){const f=h.find(x=>vo(x.path)===d);if(f?.branch){u=f.branch;break}}return u?`${a} · ${u}`:a},K5=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=ur.getState(),r=n==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const i=new Map(t.map(l=>[l.providerId,l])),o=[];for(const l of Zg){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const d=[];for(const[h,f]of Object.entries(a.usage?.windows??{})){const x=r==="remaining"?f.remainingPercent:f.usedPercent;d.push({label:tx(h),value:ex(f.valueLabel,x)})}const u=!a.ok&&a.error?a.error:d.length===0?"No rate limits reported":null;o.push({provider:l.name,rows:d,status:u})}return{mode:r,groups:o}},V5=async()=>{try{if(Vo())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=Pn();if(e&&dl(e,t))return"Local OpenChamber";const r=(await Td()).hosts.find(i=>e?dl(e,th(i)):!1);return r?.label?.trim()?Ed(r.label.trim()):"Instance"}catch{return""}},U5=()=>{const t=new Map,e=new Map,n=[],r=new Map;let i;try{i=Ui()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[o,l]of i.children.entries()){const a=l.getState();a.vcs?.branch&&e.set(vo(o)??o,a.vcs.branch);for(const d of a.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(a.session_status??{})){const h=u?.type,f=h==="busy"?"busy":h==="retry"?"retry":"idle",x=t.get(d);(!x||x==="idle")&&t.set(d,f)}for(const[d,u]of Object.entries(a.permission??{}))for(const h of u??[]){if(!h?.id)continue;const f=h.sessionID||d;n.push({kind:"permission",id:h.id,sessionId:f,sessionTitle:"",label:am(h),directory:o})}for(const[d,u]of Object.entries(a.question??{}))for(const h of u??[]){if(!h?.id)continue;const f=h.sessionID||d;n.push({kind:"question",id:h.id,sessionId:f,sessionTitle:"",label:lm(h),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},H5=(t,e)=>{const n=Ma.getState().index.session,r=$s.getState().activeSessions,i=new Map;for(const p of r)if(p?.id&&p.parentID){const S=i.get(p.parentID)??[];S.push(p.id),i.set(p.parentID,S)}const o=p=>{const S=[],g=[...i.get(p)??[]],C=new Set;for(;g.length;){const k=g.pop();C.has(k)||(C.add(k),S.push(k),g.push(...i.get(k)??[]))}return S},l=Pe.getState();let a=0;if(l.dockBadgeEnabled)for(const p of r){if(!p?.id||p.parentID)continue;let S=n.unseenCount[p.id]??0;S===0&&l.notifyOnSubtasks&&(S=o(p.id).reduce((g,C)=>g+(n.unseenCount[C]??0),0)),S>0&&(a+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:a};const d=U5(),u=new Map(d.titleById);for(const p of r)p?.id&&p.title&&u.set(p.id,p.title);const h=qo.getState().statusById,f=p=>{const S=d.statusById.get(p);return S&&S!=="idle"?S:h.get(p)?.status.type??S??"idle"},x=p=>{const S=p.map(g=>f(g));return S.includes("busy")?"busy":S.includes("retry")?"retry":"idle"},b=Ht.getState().projects,w=tt.getState().availableWorktreesByProject,v=r.filter(p=>p?.id&&!p.parentID).slice().sort($5).slice(0,L5).map(p=>{const S=[p.id,...o(p.id)],g=Ds(p)??"";return{id:p.id,title:p.title||"Untitled session",status:x(S),branch:g?d.branchByDirectory.get(g)??"":"",unseen:S.reduce((C,k)=>C+(n.unseenCount[k]??0),0),hasError:S.some(C=>n.unseenHasError[C]??!1),directory:g,subtitle:W5(g,p,b,w,d.branchByDirectory)}}),y=d.approvals.map(p=>({...p,sessionTitle:u.get(p.sessionId)||""})),m=new Set(y.map(p=>p.id));for(const[p,S]of Oa.getState().bySession){const g=u.get(p)||"";for(const C of S.permissions)m.has(C.id)||(m.add(C.id),y.push({kind:"permission",id:C.id,sessionId:p,sessionTitle:g,label:am(C),directory:S.directory}));for(const C of S.questions)m.has(C.id)||(m.add(C.id),y.push({kind:"question",id:C.id,sessionId:p,sessionTitle:g,label:lm(C),directory:S.directory}))}return{sessions:v,approvals:y,instanceName:t,usage:K5(),dockBadgeCount:a}},G5=()=>{c.useEffect(()=>{if(!jd()||!Ur())return;const t=kd();let e=!1,n="",r=null,i="";const o=()=>{if(e)return;const j=H5(i,t),D=JSON.stringify(j);D!==n&&(n=D,_n("desktop_tray_update",j))},l=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,o()},_5))},a=Ma.subscribe(()=>l()),d=$s.subscribe(()=>l()),u=Pe.subscribe((j,D)=>{(j.dockBadgeEnabled!==D.dockBadgeEnabled||j.notifyOnSubtasks!==D.notifyOnSubtasks)&&l()}),h=()=>{e=!0,r!==null&&window.clearTimeout(r),a(),d(),u()};if(!t)return o(),h;V5().then(j=>{e||(i=j,o())});const f=new Map,x=()=>{if(e)return;let j;try{j=Ui()}catch{return}const D=new Set;for(const[I,A]of j.children.entries())D.add(I),f.has(I)||f.set(I,A.subscribe(()=>l()));for(const[I,A]of f)D.has(I)||(A(),f.delete(I))};let b=null;try{b=Ui().subscribeRegistry(()=>{x(),l()})}catch{}x();const w=Ht.subscribe(()=>l()),v=tt.subscribe(()=>l()),y=Tn.subscribe(()=>l()),m=qo.subscribe(()=>l()),p=Oa.subscribe(()=>l()),S=Ta.subscribe(()=>l()),g=Gr.subscribe(()=>l()),C=ur.subscribe(()=>l());ur.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:j,results:D}=ur.getState();j.length>0&&j.some(A=>!D.some(P=>P.providerId===A))&&ur.getState().fetchQuotas(j)});const k=window.setInterval(()=>{x(),o()},F5);return o(),()=>{h(),window.clearInterval(k),w(),v(),y(),m(),p(),S(),g(),C(),b?.();for(const j of f.values())j();f.clear()}},[]),c.useEffect(()=>{if(!jd()||!kd()||!Ur())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{i.type==="respond-permission"&&Jg(i.sessionId,i.id,i.response).catch(()=>{Le.error("Failed to respond to permission request")})};let r=null;return e(B5,i=>{const o=i?.payload;!o||typeof o!="object"||typeof o.type!="string"||n(o)}).then(i=>{r=i}).catch(()=>{}),()=>{try{const i=r?.();i instanceof Promise&&i.catch(()=>{})}catch{}}},[])},q5=30*6e4,Y5=(t,e,n=q5)=>{const r=new Map;for(const[i,o]of Object.entries(t.sessions)){if(o.status!=="busy"&&o.status!=="retry"||t.serverTime-o.lastUpdateAt>n||e.isKnown(i))continue;const l=e.resolveDirectory(i);if(!l)continue;const a=r.get(l)??[];a.push({id:`host-seed:${i}`,type:"session.status",properties:{sessionID:i,status:{type:"busy"}}}),r.set(l,a)}return r};let Or=null;const cm=()=>{if(Or)return Or;const t=qt();return Or=(async()=>{const e=await Cn.getHostSessionStatusSnapshot();if(!e||qt()!==t)return;const n=qo.getState(),r=$s.getState().entityById,i=Y5(e,{isKnown:l=>n.statusById.has(l)||n.observedById.has(l),resolveDirectory:l=>{const a=r.get(l);return a?Ds(a):null}});for(const[l,a]of i)sx(l,a);const o=[];for(const[l,a]of Object.entries(e.pending??{})){const d=r.get(l),u=d?Ds(d):null;u&&o.push({sessionId:l,directory:u,permissions:a.permissions,questions:a.questions})}nx(o)})().finally(()=>{Or=null}),Or},Q5=45e3,X5=(t,e,n=window.setInterval.bind(window),r=window.clearInterval.bind(window))=>{t();const i=n(e,Q5);return()=>r(i)},J5=t=>{const e=Ze.c(3);let n,r;e[0]!==t?(n=()=>{if(t)return X5(eN,sN)},r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),c.useEffect(n,r)};function Z5(){return cm()}function eN(){rx(To()).finally(Z5)}function tN(){return cm()}function sN(){za().finally(tN)}const nN="/api/notifications/stream",rN=()=>typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus(),oN=t=>{if(!t||typeof t!="object")return null;const e=t,n=e.properties&&typeof e.properties=="object"?e.properties:null;return e.type!=="openchamber:notification"||!n?null:{title:typeof n.title=="string"?n.title:void 0,body:typeof n.body=="string"?n.body:void 0,tag:typeof n.tag=="string"?n.tag:void 0}},iN=t=>{const e=Ze.c(3),n=t?.enabled??!0;let r,i;e[0]!==n?(r=()=>{if(!n||xn()||!wa()||typeof window>"u"||typeof EventSource>"u")return;const o=new EventSource(ya().sse(nN));return o.onmessage=aN,()=>{o.close()}},i=[n],e[0]=n,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function aN(t){let e;try{e=JSON.parse(t.data)}catch{return}const n=Pe.getState();if(!n.nativeNotificationsEnabled||n.notificationMode!=="always"&&rN())return;const r=oN(e);if(!r)return;Id()?.notifications?.notifyAgentCompletion(r)}const lN=6e4,cN=t=>{const e=Ze.c(10),n=Pe(dN),r=ox(uN),o=Uh(t)?.path??null;let l,a;e[0]!==n||e[1]!==r||e[2]!==o?(l=()=>{n&&r(o,{maxAgeMs:lN})},a=[n,r,o],e[0]=n,e[1]=r,e[2]=o,e[3]=l,e[4]=a):(l=e[3],a=e[4]),c.useEffect(l,a);let d,u;e[5]!==n||e[6]!==r||e[7]!==o?(d=()=>{if(n)return eo(h=>{h.type==="agent-memory-changed"&&r(o)})},u=[n,r,o],e[5]=n,e[6]=r,e[7]=o,e[8]=d,e[9]=u):(d=e[8],u=e[9]),c.useEffect(d,u)};function dN(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function uN(t){return t.load}const Cd="pwa-install-toast-shown",Nd="pwa-install-toast-dismissed",fN=()=>{const t=Ze.c(6),{browserTab:e}=Hh(),{t:n}=jt(),r=c.useRef(n);let i,o;t[0]!==n?(i=()=>{r.current=n},o=[n],t[0]=n,t[1]=i,t[2]=o):(i=t[1],o=t[2]),c.useEffect(i,o);let l,a;t[3]!==e?(l=()=>{if(typeof window>"u"||!wa()||!e)return;let d=null,u=null;const h=()=>{u!==null&&(Le.dismiss(u),u=null)},f=async()=>{if(!d)return;const w=d;d=null,h(),await w.prompt();const{outcome:v}=await w.userChoice;v==="accepted"&&Le.success(r.current("pwa.installPrompt.started"))},x=w=>{const v=w;if(typeof v.prompt!="function")return;v.preventDefault(),d=v;const y=Do(),m=sh();Gh({dismissed:y.getItem(Nd),sessionShown:m.getItem(Cd),hasActiveToast:u!==null})&&(m.setItem(Cd,"true"),u=Le.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{f()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{Do().setItem(Nd,"true"),h()}}}))},b=()=>{d=null,h(),Le.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",x),window.addEventListener("appinstalled",b),()=>{h(),window.removeEventListener("beforeinstallprompt",x),window.removeEventListener("appinstalled",b)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},mN=({open:t,onOpenChange:e})=>{const{t:n}=jt(),r=!1,[i,o]=c.useState(null),[l,a]=c.useState(null),[d,u]=c.useState(!1),[h,f]=c.useState(!1),[x,b]=c.useState(null),[w,v]=c.useState(!1);c.useCallback(async()=>{},[x,d,r,n]),c.useEffect(()=>{if(!t)return;(async()=>{try{const p=await ls("/api/system/info");if(p.ok){const S=await p.json();if(typeof S.openchamberVersion=="string"&&S.openchamberVersion.trim()){o(S.openchamberVersion);return}}}catch{}o(await ix())})()},[t]),c.useEffect(()=>{if(!t)return;let m=!1;return(async()=>{try{const S=await ls("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!S.ok)return;const g=await S.json().catch(()=>null),C=typeof g?.currentVersion=="string"?g.currentVersion.trim():"";!m&&C&&a(C)}catch{}})(),()=>{m=!0}},[t]),c.useEffect(()=>{{b(null),v(!1);return}},[t,r]);const y=i;return s.jsx(ys,{open:t,onOpenChange:e,children:s.jsx(ws,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(yu,{width:64,height:64}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"OpenChamber"}),s.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[y&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:y})}),l&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:l})})]})]}),r,s.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-4",children:[s.jsxs("a",{href:"https://github.com/openchamber/openchamber",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(M,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://discord.gg/ZYRSdnwwKA",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(M,{name:"discord-fill",className:"h-4 w-4"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:"https://x.com/openchamber_dev",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(M,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:n("aboutDialog.footerNote")})]})})})},Ad=t=>{if(!(typeof window>"u")){if(t){window.location.href="openchamber://focus/mcp-auth";return}window.location.replace("/")}},Ni=(t,e)=>{const n=t.get(e);return typeof n!="string"?null:n.trim()||null},hN=(t,e)=>{const n=t instanceof Error?t.message:e;return/oauth state required/i.test(n)?"Authorization session expired or was cleared during reload. Return to OpenChamber and click Authorize again.":n},pN=()=>{const t=ax(a=>a.completeAuth),[e,n]=c.useState("working"),[r,i]=c.useState(!1),[o,l]=c.useState("Completing MCP authorization...");return c.useEffect(()=>{if(typeof window>"u"){n("error"),l("Browser context unavailable.");return}const a=new URLSearchParams(window.location.search),d=Ni(a,"code"),u=lx(a),h=cx(a),f=Ni(a,"error"),x=Ni(a,"error_description");if(f){h&&ls(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(x??f);return}(async()=>{try{if(!d)throw new Error("Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into OpenChamber manually.");let b=u,w=!1;if(h){const v=await ls(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`);if(v.ok){const y=await v.json().catch(()=>null);w=y?.origin===dx,i(w),!b&&y?.name?.trim()&&(b={name:y.name.trim(),directory:typeof y.directory=="string"&&y.directory.trim()?y.directory.trim():null})}}if(!b?.name)throw new Error("Authorization session details were not available. Start authorization again from MCP Settings or paste the returned code into OpenChamber manually.");await t(b.name,d,b.directory),h&&await ls(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("success"),w&&Ad(!0),l("Authorization completed. You can close this tab and return to OpenChamber.")}catch(b){h&&await ls(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(hN(b,"Failed to complete MCP authorization."))}})()},[t]),s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-6 py-12 text-foreground",children:s.jsxs("div",{className:"w-full max-w-xl rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-8 shadow-sm",children:[s.jsxs("div",{className:"space-y-3 text-center",children:[s.jsx("h1",{className:ux,children:e==="working"?"Completing Authorization":e==="success"?"Authorization Complete":"Authorization Failed"}),s.jsx("p",{className:Oe("typography-body",e==="error"?"text-[var(--status-error)]":e==="success"?"text-[var(--status-success)]":"text-[var(--status-info)]"),children:o})]}),e!=="working"&&s.jsx("div",{className:"mt-8 flex justify-center",children:s.jsx(dt,{type:"button",onClick:()=>Ad(r),children:"Return to OpenChamber"})})]})})},Dd=Wn(()=>En(()=>import("./OnboardingScreen-CQHBSTEi.js"),__vite__mapDeps([150,1,2,4,5,6,7,8,9,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(t=>({default:t.OnboardingScreen}))),gN=()=>{const t=Ze.c(3),e=Pe(SN),n=Pe(jN);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(mN,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},xN=t=>{const e=Ze.c(21),{onRetry:n,isRetrying:r}=t,{t:i}=jt();let o;e[0]!==i?(o=i("startup.initRecovery.title"),e[0]=i,e[1]=o):o=e[1];let l;e[2]!==o?(l=s.jsx("h1",{className:"typography-title text-foreground",children:o}),e[2]=o,e[3]=l):l=e[3];let a;e[4]!==i?(a=i("startup.initRecovery.description"),e[4]=i,e[5]=a):a=e[5];let d;e[6]!==a?(d=s.jsx("p",{className:"typography-body text-muted-foreground",children:a}),e[6]=a,e[7]=d):d=e[7];let u;e[8]!==l||e[9]!==d?(u=s.jsxs("div",{className:"flex flex-col gap-2",children:[l,d]}),e[8]=l,e[9]=d,e[10]=u):u=e[10];let h;e[11]!==r||e[12]!==i?(h=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[11]=r,e[12]=i,e[13]=h):h=e[13];let f;e[14]!==r||e[15]!==n||e[16]!==h?(f=s.jsx(dt,{type:"button",onClick:n,disabled:r,children:h}),e[14]=r,e[15]=n,e[16]=h,e[17]=f):f=e[17];let x;return e[18]!==u||e[19]!==f?(x=s.jsx("div",{className:"flex h-full items-center justify-center bg-background px-6 text-foreground",children:s.jsxs("div",{className:"flex max-w-md flex-col items-center gap-4 text-center",children:[u,f]})}),e[18]=u,e[19]=f,e[20]=x):x=e[20],x},Pd=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",bN=()=>{if(typeof window>"u"||!rb())return null;const t=new URLSearchParams(window.location.search),e=t.get("sessionId"),n=typeof e=="string"?e.trim():"";if(!n)return null;const r=t.get("directory"),i=typeof r=="string"&&r.trim().length>0?r.trim():null;return{sessionId:n,directory:i,readOnly:t.get("readOnly")==="1"||t.get("readOnly")==="true",allowPromptingSubagentSessions:t.has("allowPromptingSubagentSessions")?t.get("allowPromptingSubagentSessions")==="1":void 0}},yN=()=>typeof window>"u"?!1:window.location.pathname===xx,wN=t=>{const e=Ze.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=ns(kN),l=tt(CN),a=tt(NN),d=ru(),u=c.useRef(null);let h;e[0]!==n.directory?(h=Pd(n.directory),e[0]=n.directory,e[1]=h):h=e[1];const f=h;let x;e[2]!==o?(x=Pd(o),e[2]=o,e[3]=x):x=e[3];const b=x;let w,v;if(e[4]!==b||e[5]!==l||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==d?(w=()=>{if(r||f&&b!==f)return;const C=`${f}
|
|
896
|
-
${n.sessionId}`;u.current===C&&l||(u.current=C,a(n.sessionId,n.directory),d.ensureSessionRenderable(n.sessionId,!0))},v=[b,l,n.directory,n.sessionId,f,r,a,d],e[4]=b,e[5]=l,e[6]=n.directory,e[7]=n.sessionId,e[8]=f,e[9]=r,e[10]=a,e[11]=d,e[12]=w,e[13]=v):(w=e[12],v=e[13]),c.useEffect(w,v),f&&b!==f)return null;let y;e[14]!==i?(y=s.jsx(Fu,{embeddedBackgroundWorkEnabled:i}),e[14]=i,e[15]=y):y=e[15];let m;e[16]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(Gd,{}),e[16]=m):m=e[16];let p;e[17]!==i||e[18]!==n.allowPromptingSubagentSessions||e[19]!==n.readOnly?(p=s.jsx(Hd,{active:i,messagesEnabled:!0,readOnly:n.readOnly,initialAllowPromptingSubagentSessions:n.allowPromptingSubagentSessions}),e[17]=i,e[18]=n.allowPromptingSubagentSessions,e[19]=n.readOnly,e[20]=p):p=e[20];let S;e[21]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(_u,{}),e[21]=S):S=e[21];let g;return e[22]!==y||e[23]!==p?(g=s.jsxs(s.Fragment,{children:[y,m,p,S]}),e[22]=y,e[23]=p,e[24]=g):g=e[24],g};function vN({apis:t}){c.useEffect(()=>{nh("App:mounted"),rh()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=Gt(O=>O.initializeApp),n=Gt(O=>O.isInitialized),r=Gt(O=>O.isConnected),i=Gt(O=>O.providers.length),o=Gt(O=>O.agents.length),l=Gt(O=>O.loadProviders),a=Gt(O=>O.loadAgents),d=tt(O=>O.error),u=tt(O=>O.clearError),h=ns(O=>O.currentDirectory),f=ns(O=>O.setDirectory),x=ns(O=>O.isSwitchingDirectory),[b,w]=c.useState(!1),v=In(O=>O.refreshStatus),y=_i(O=>O.refreshStatus),[m,p]=c.useState(()=>t.runtime.isVSCode),[S,g]=c.useState(!1),[C,k]=c.useState(!1),[j,D]=c.useState(0),[I,A]=c.useState(0),[P,T]=c.useState(!1),L=Pe(O=>O.wideChatLayoutEnabled),$=Pe(O=>O.mobileKeyboardMode),K=c.useMemo(()=>xn(),[]),F=Ca(O=>O.setPlanModeEnabled),[W,N]=c.useState(()=>ul()),[R,E]=c.useState(()=>{const O=fl();return O!==null?ml({isDesktopShell:!0,bootOutcome:O}):null}),X=c.useRef(!1),J=c.useMemo(()=>bN(),[]),re=!J||S,fe=c.useMemo(()=>yN(),[]);c.useEffect(()=>(hl(b),bd(b),()=>{hl(!1),bd(!1)}),[b]),c.useEffect(()=>{oh($)},[$]),c.useEffect(()=>{p(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>Qr(O=>{qh(O),A(Q=>Q+1),k(!1),D(Q=>Q+1)}),[]);const ne=_l(O=>{const Q=qt();return Object.values(O.runsByOriginalSessionID).filter(le=>le.status==="running"&&le.runtimeKey===Q).map(le=>`${le.originalSessionID}:${le.phase}:${le.lastForwardedMessageID??""}:${le.expectedAssistantParentID??""}`).sort().join("|")});c.useEffect(()=>{if(J)return;const O=qt(),Q=Object.values(_l.getState().runsByOriginalSessionID).filter(le=>le.status==="running"&&le.runtimeKey===O);for(const le of Q)fx(le.originalSessionID)},[ne,J,I]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",L),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[L]),c.useEffect(()=>(pl(t),()=>pl(null)),[t]),c.useEffect(()=>{J||(v(t.github,{force:!0}),y(t.linear,{force:!0}))},[t.github,t.linear,J,r,v,y,I]),mx();const te=W==="valid",ue=R?.screen==="main";c.useEffect(()=>{if(!ih({isDesktopShell:K,isInitialized:n,bootOutcomeKnown:te,bootViewIsMain:ue}))return;const O=setTimeout(()=>{const Q=document.getElementById("initial-loading");Q&&(Q.classList.add("fade-out"),setTimeout(()=>{Q.remove()},300))},150);return()=>clearTimeout(O)},[K,n,te,ue]),c.useEffect(()=>{if(!K||W!=="malformed")return;const O=document.getElementById("initial-loading");O&&(O.textContent="Desktop startup failed — please restart the app.")},[K,W]),c.useEffect(()=>{if(K)return;const O=setTimeout(()=>{const Q=document.getElementById("initial-loading");Q&&!n&&(Q.classList.add("fade-out"),setTimeout(()=>{Q.remove()},300))},5e3);return()=>clearTimeout(O)},[K,n]),c.useEffect(()=>{let O=!1;return(async()=>{const le=await ls("/health",{method:"GET"}).catch(()=>null);if(!le||!le.ok||O)return;const H=await le.json().catch(()=>null);if(!H||O)return;const me=H.planModeExperimentalEnabled;F(me===!0||me===1||me==="1"||me==="true")})(),()=>{O=!0}},[F]),c.useEffect(()=>{m||e()},[e,m]),c.useEffect(()=>{if(m||n)return;let O=!0,Q,le=0;const H=10,me=1e3,ge=async()=>{if(!O)return;if(le>=H){k(!0);return}const oe=Gt.getState();if(oe.isInitialized){k(!1);return}le+=1,await oe.initializeApp();const de=Gt.getState();if(!O)return;if(de.isInitialized){k(!1);return}if(le>=H){k(!0);return}const _=Math.min(me*Math.pow(2,le-1),16e3);Q=setTimeout(ge,_)};return Q=setTimeout(ge,me),()=>{O=!1,Q&&clearTimeout(Q)}},[j,n,m]),c.useEffect(()=>{n&&k(!1)},[n]),c.useEffect(()=>{if(!C)return;const O=document.getElementById("initial-loading");O&&(O.classList.add("fade-out"),setTimeout(()=>{O.remove()},300))},[C]),c.useEffect(()=>{if(m||!r||i>0&&o>0)return;let O=!0,Q=0;const le=15,H=async()=>{const ge=Gt.getState();if(!(ge.providers.length>0&&ge.agents.length>0))try{ge.providers.length===0&&await l({source:"startupRecovery"}),Gt.getState().agents.length===0&&await a({source:"startupRecovery"})}catch{}};H();const me=setInterval(()=>{if(O){if(++Q>=le){clearInterval(me);return}H()}},2e3);return()=>{O=!1,clearInterval(me)}},[r,m,a,l,i,o]),c.useEffect(()=>{x||m||r&&Cn.setDirectory(h)},[h,x,r,m]),c.useEffect(()=>{if(!J||typeof window>"u")return;const O=H=>{g(H?.visible===!0)},Q=H=>{if(H.origin!==window.location.origin||H.source!==window.parent)return;const me=H.data;me?.type===Gu&&O(me.payload)},le=window;return le.__openchamberSetEmbeddedVisibility=O,window.addEventListener("message",Q),nb(),()=>{window.removeEventListener("message",Q),le.__openchamberSetEmbeddedVisibility===O&&delete le.__openchamberSetEmbeddedVisibility}},[J]),c.useEffect(()=>{!J?.directory||m||h!==J.directory&&f(J.directory,{showOverlay:!1})},[h,J,m,f]),c.useEffect(()=>{if(!J||typeof window>"u")return;const O=Q=>{Q.storageArea===window.localStorage&&Q.key==="ui-store"&&Pe.persist.rehydrate()};return window.addEventListener("storage",O),()=>{window.removeEventListener("storage",O)}},[J]),c.useEffect(()=>{if(typeof window>"u")return;const O=Q=>{const le=Q.detail,H=typeof le?.sessionId=="string"?le.sessionId.trim():"";if(!H)return;const me=typeof le?.directory=="string"&&le.directory.trim().length>0?le.directory.trim():null;tt.getState().setCurrentSession(H,me)};return window.addEventListener("openchamber:open-session",O),()=>window.removeEventListener("openchamber:open-session",O)},[]),c.useEffect(()=>{if(typeof window>"u")return;const O=()=>{_n("desktop_open_draft_mini_chat_window",{directory:"",projectId:null})};return window.addEventListener("openchamber:open-mini-chat",O),()=>window.removeEventListener("openchamber:open-mini-chat",O)},[]),c.useEffect(()=>{if(typeof window>"u")return;const O=()=>{const Q=tt.getState().currentSessionId;Q&&wu(Q)};return window.addEventListener("focus",O),()=>window.removeEventListener("focus",O)},[]),c.useEffect(()=>{if(typeof window>"u")return;const O=Q=>{const le=Q.detail,H=typeof le?.directory=="string"&&le.directory.trim().length>0?le.directory.trim():null,me=typeof le?.projectId=="string"&&le.projectId.trim().length>0?le.projectId.trim():null,ge=!!(H||me);Pe.getState().setSessionSwitcherOpen(!1),tt.getState().openNewSessionDraft({target:ge?"project":"chat",selectedProjectId:ge?me:null,directoryOverride:ge?H:null,preserveDirectoryOverride:!!H})};return window.addEventListener("openchamber:open-draft-session",O),()=>window.removeEventListener("openchamber:open-draft-session",O)},[]),c.useEffect(()=>{typeof window>"u"||!n||x||X.current||(X.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,x]),hx({enabled:re}),iN({enabled:re}),cN(h||null),px(),fN(),gx(),Ex(),Yh();const Se=c.useCallback(()=>{w(O=>!O)},[]);O5(Se),G5(),J5(!J),c.useEffect(()=>{if(J)return;const O=()=>w(Q=>!Q);return window.addEventListener("openchamber:memory-debug-toggle",O),()=>window.removeEventListener("openchamber:memory-debug-toggle",O)},[J]),c.useEffect(()=>{J||d&&setTimeout(()=>u(),5e3)},[u,J,d]),c.useEffect(()=>{if(!K||W!=="not-injected")return;let O=!1,Q=0;const le=200,H=2e3,me=50,ge=()=>{if(O)return;Q++;const oe=ul();if(oe!=="not-injected"){if(O=!0,N(oe),oe==="valid"){const _=fl();_&&E(ml({isDesktopShell:!0,bootOutcome:_}))}return}const de=Math.min(le*Math.pow(1.1,Q),H);if(Q>=me){const _=document.getElementById("initial-loading");_&&!_.textContent?.includes("taking longer")&&(_.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(ge,de)};return window.setTimeout(ge,le),()=>{O=!0}},[K,W]);const we=c.useCallback(async()=>{if(ah({isDesktopShell:xn(),isDesktopLocalOriginActive:Vo()})){await lh();return}window.location.reload()},[]),ye=c.useCallback(async()=>{if(!P){k(!1),T(!0);try{await Gt.getState().initializeApp()}finally{T(!1)}Gt.getState().isInitialized||D(O=>O+1)}},[P]),Ae=O=>{if(O.screen==="recovery")return O.variant};if(K&&R&&R.screen!=="main"){if(R.screen==="chooser")return s.jsx(As,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Dd,{mode:"first-launch",localAvailable:R.localAvailable!==!1,onCliAvailable:we,onChooseRemote:()=>{}})})})});const O=Ae(R),Q=R.screen==="recovery"&&"url"in R?R.url:void 0;return s.jsx(As,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Dd,{mode:"recovery",recoveryVariant:O,recoveryHostUrl:Q,recoveryHostLabel:void 0,localAvailable:R.localAvailable!==!1,onCliAvailable:we})})})})}if(J)return s.jsx(As,{children:s.jsx(Ll,{sdk:Cn.getSdkClient(),directory:h||"",children:s.jsx($l,{apis:t,children:s.jsx(Vi,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:"h-full text-foreground bg-background",children:[s.jsx(wN,{embeddedSessionChat:J,isVSCodeRuntime:m,embeddedBackgroundWorkEnabled:re}),s.jsx(zl,{}),s.jsx(Wl,{})]})})})},I)});if(fe)return s.jsx(As,{children:s.jsx(pN,{})});if(C&&!n&&!m&&!J)return s.jsx(As,{children:s.jsx(xN,{onRetry:()=>{ye()},isRetrying:P})});const pe=!n&&!K;return s.jsx(As,{children:s.jsx(Ll,{sdk:Cn.getSdkClient(),directory:h||"",children:s.jsx($l,{apis:t,children:s.jsx(n5,{children:s.jsx(Vi,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:K?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[s.jsx(Fu,{embeddedBackgroundWorkEnabled:re}),s.jsx(Gd,{}),s.jsx(TC,{}),s.jsx(Qh,{ready:n&&(!K||te&&ue)}),s.jsx(_u,{}),s.jsx(zl,{}),s.jsx(Wl,{}),!pe&&s.jsxs(s.Fragment,{children:[s.jsx(Xh,{}),s.jsx(gN,{}),b&&s.jsx(p5,{onClose:()=>w(!1)})]})]})})})})},I)})}function SN(t){return t.isAboutDialogOpen}function jN(t){return t.setAboutDialogOpen}function kN(t){return t.currentDirectory}function CN(t){return t.currentSessionId}function NN(t){return t.setCurrentSession}const AN=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();bx();ch().then(()=>{Promise.all([dh(),yx()]).catch(t=>{console.error("[main] settings init failed:",t)}),wx(),vx(),Sx()}).catch(t=>{console.error("[main] appearance init failed:",t)});const dm=document.getElementById("root");if(!dm)throw new Error("Root element not found");jx();Mm.createRoot(dm).render(s.jsx(mt.StrictMode,{children:s.jsx(kx,{children:s.jsx(Cx,{children:s.jsx(Nx,{children:s.jsx(Ax,{children:s.jsx(vN,{apis:AN})})})})})}));const qN=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{My as W,jy as a,GN as b,ff as g,qN as m,Ry as u,uf as v};
|