@openchamber/web 1.22.1 → 1.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +11 -1
- package/bin/cli.test.js +92 -0
- package/bin/lib/cli-startup.js +49 -0
- package/bin/lib/commands-startup.js +41 -6
- package/dist/assets/{CodeMirrorCommentWidgets-BO_2OW4E.js → CodeMirrorCommentWidgets-DbcnxAfY.js} +1 -1
- package/dist/assets/DiffView-Dp1tomqK.js +4 -0
- package/dist/assets/{DirtyBranchSwitchDialog-jADfXQnR.js → DirtyBranchSwitchDialog-DE2sKIYv.js} +1 -1
- package/dist/assets/FilesView-C_of2nIT.js +17 -0
- package/dist/assets/{GitView-Cv2xH-S6.js → GitView-CKgUkb5Z.js} +4 -4
- package/dist/assets/{JsonTreeView-DUiIpERC.js → JsonTreeView-Bce2ettZ.js} +1 -1
- package/dist/assets/{LinearIssuesView-CoZ7pQN5.js → LinearIssuesView-BZVWM2zw.js} +1 -1
- package/dist/assets/MarkdownImageGallery-DdROVz29.js +1 -0
- package/dist/assets/MarkdownRendererImpl-CenrzmMN.js +12 -0
- package/dist/assets/OnboardingScreen-DyqYG_NP.js +1 -0
- package/dist/assets/{PatchDiff-BymkP9JA.js → PatchDiff-CR3RVO5I.js} +1 -1
- package/dist/assets/PierreDiffViewer-KihzO94X.js +161 -0
- package/dist/assets/PlanView-jcQAfr2A.js +5 -0
- package/dist/assets/SettingsView-Buvom5A2.js +28 -0
- package/dist/assets/{SettingsWindow-COzgfFxM.js → SettingsWindow-CV_hzB5v.js} +1 -1
- package/dist/assets/SymbolsNerdFontMono-Regular-aK5vsLov.woff2 +0 -0
- package/dist/assets/{ToolOutputDialog-Dlhh_-oe.js → ToolOutputDialog-llKecK_Z.js} +6 -6
- package/dist/assets/{ToolPartDiffPreview-b9joNtXH.js → ToolPartDiffPreview-ZDMTdCGn.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-vqW3KKo5.js → VirtualizedFileDiff-ClvqQ4j0.js} +1 -1
- package/dist/assets/WalkthroughView-BgpSnSlU.js +4 -0
- package/dist/assets/{computeVirtualFileMetrics-DUnyszhW.js → computeVirtualFileMetrics-Nm5_wabb.js} +2 -2
- package/dist/assets/contextPanelEmbeddedChat-CirXEPJq.js +1 -0
- package/dist/assets/de-DTQDjaiv.js +10 -0
- package/dist/assets/es-SOCFd_r-.js +16 -0
- package/dist/assets/fr-CP6jqIzw.js +14 -0
- package/dist/assets/ghostty-vt-DdA0Zryv.wasm +0 -0
- package/dist/assets/index-B68h5S5B.css +1 -0
- package/dist/assets/index-CRf2xk51.js +39 -0
- package/dist/assets/{index-DLiD86ge.js → index-Du9sZhDb.js} +1 -1
- package/dist/assets/{isDiffPlainText-TNageFjy.js → isDiffPlainText-EQERIius.js} +1 -1
- package/dist/assets/{isFilePlainText-JPmZOYSp.js → isFilePlainText-BCoVpkQy.js} +1 -1
- package/dist/assets/ja-BKfafwsD.js +16 -0
- package/dist/assets/ko-BA5xgCYp.js +16 -0
- package/dist/assets/main-BNiPEont.js +930 -0
- package/dist/assets/{main-DCB4JgVe.js → main-DPf32fO6.js} +2 -2
- package/dist/assets/markdownCore-CQ7CAuuV.js +5 -0
- package/dist/assets/{miniChat-BtV7N5OF.js → miniChat-CHqVTsgj.js} +2 -2
- package/dist/assets/{mobile-DZV_sfX7.js → mobile-BQmgHA57.js} +2 -2
- package/dist/assets/patchFileDiff-C4X_trug.js +13 -0
- package/dist/assets/pl-B215pG1Y.js +16 -0
- package/dist/assets/pt-BR-Bo2pnlEa.js +16 -0
- package/dist/assets/renderElectronMiniChatApp-BUcHPOXW.js +2 -0
- package/dist/assets/renderMobileApp-BvTmuRE-.js +25 -0
- package/dist/assets/runtimeEndpointReset-C8GAA2kS.js +17 -0
- package/dist/assets/scheduledTasksApi-BAScWwt3.js +1 -0
- package/dist/assets/{shikiHighlight-CRpCl7UT.js → shikiHighlight-BTObuQCR.js} +1 -1
- package/dist/assets/surface-BvRzS58U.js +1 -0
- package/dist/assets/tr-CUaxHc8X.js +7 -0
- package/dist/assets/uk-YTJgyqAZ.js +16 -0
- package/dist/assets/{useAppFontEffects-CCgvcQ6u.js → useAppFontEffects-theH_IJL.js} +143 -137
- package/dist/assets/useGitComparison-B94I6kOI.js +1 -0
- package/dist/assets/useInlineCommentController-Bs3PgeA8.js +2 -0
- package/dist/assets/useRootScrollLock-hSYwnxZs.js +1 -0
- package/dist/assets/{vendor-base-ui-BeMD8X_w.js → vendor-base-ui-DdV8vhHn.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-BxpoC5Fp.js → vendor-codemirror-language-data-Cxgr01md.js} +2 -2
- package/dist/assets/vendor-legendapp-list-BuBPBC3R.js +1 -0
- package/dist/assets/vendor-zod-BPAANqvH.js +39 -0
- package/dist/assets/{web-components-B6QgbmTo.js → web-components-CaS0ksnZ.js} +1 -1
- package/dist/assets/zh-CN-CZ2BxZS6.js +16 -0
- package/dist/assets/zh-TW-BsUrPdXz.js +16 -0
- package/dist/index.html +5 -43
- package/dist/mini-chat.html +4 -4
- package/dist/mobile.html +4 -4
- package/package.json +3 -4
- package/server/index.d.ts +15 -0
- package/server/index.js +52 -10
- package/server/lib/changelog/update-notes.js +82 -0
- package/server/lib/changelog/update-notes.test.js +59 -0
- package/server/lib/data-dir-migration.js +40 -0
- package/server/lib/data-dir-migration.test.js +59 -0
- package/server/lib/event-stream/runtime.test.js +12 -12
- package/server/lib/fs/DOCUMENTATION.md +5 -0
- package/server/lib/fs/routes.js +63 -21
- package/server/lib/fs/routes.test.js +187 -1
- package/server/lib/git/DOCUMENTATION.md +29 -5
- package/server/lib/git/routes.js +24 -4
- package/server/lib/git/service.js +194 -198
- package/server/lib/git/service.test.js +440 -25
- package/server/lib/inherited-env.js +16 -9
- package/server/lib/inherited-env.test.js +8 -9
- package/server/lib/message-queue/DOCUMENTATION.md +20 -7
- package/server/lib/message-queue/runtime.js +59 -7
- package/server/lib/message-queue/runtime.test.js +59 -3
- package/server/lib/network-defaults.js +23 -0
- package/server/lib/network-defaults.test.js +52 -0
- package/server/lib/opencode/DOCUMENTATION.md +25 -5
- package/server/lib/opencode/bootstrap-runtime.js +2 -0
- package/server/lib/opencode/config-paths.test.js +116 -0
- package/server/lib/opencode/feature-routes-runtime.js +4 -0
- package/server/lib/opencode/input-history-scope.js +14 -0
- package/server/lib/opencode/openchamber-routes.js +64 -4
- package/server/lib/opencode/openchamber-routes.test.js +128 -1
- package/server/lib/opencode/plugins.js +2 -2
- package/server/lib/opencode/providers.js +44 -2
- package/server/lib/opencode/providers.test.js +131 -4
- package/server/lib/opencode/routes.js +9 -7
- package/server/lib/opencode/server-startup-runtime.js +1 -1
- package/server/lib/opencode/settings-files.js +214 -0
- package/server/lib/opencode/settings-helpers.js +113 -41
- package/server/lib/opencode/settings-helpers.test.js +342 -0
- package/server/lib/opencode/settings-registry.json +747 -0
- package/server/lib/opencode/settings-runtime.js +139 -18
- package/server/lib/opencode/settings-runtime.test.js +163 -5
- package/server/lib/opencode/shared.js +4 -1
- package/server/lib/opencode/skill-routes.js +2 -1
- package/server/lib/opencode/snippets.js +1 -2
- package/server/lib/package-manager.js +3 -28
- package/server/lib/project-context/DOCUMENTATION.md +25 -1
- package/server/lib/project-context/routes.http.test.js +18 -0
- package/server/lib/project-context/routes.js +15 -0
- package/server/lib/project-context/runtime.js +248 -23
- package/server/lib/project-context/runtime.test.js +106 -3
- package/server/lib/projects/DOCUMENTATION.md +76 -0
- package/server/lib/projects/project-config.js +142 -9
- package/server/lib/projects/project-id.js +17 -0
- package/server/lib/projects/project-setup.js +409 -0
- package/server/lib/projects/project-setup.test.js +557 -0
- package/server/lib/projects/routes.js +59 -0
- package/server/lib/quota/DOCUMENTATION.md +38 -1
- package/server/lib/quota/index.js +1 -0
- package/server/lib/quota/providers/cline-pass.js +125 -0
- package/server/lib/quota/providers/cline-pass.test.js +103 -0
- package/server/lib/quota/providers/hyper.js +118 -0
- package/server/lib/quota/providers/hyper.test.js +126 -0
- package/server/lib/quota/providers/index.js +15 -0
- package/server/lib/quota/providers/neuralwatt.js +3 -6
- package/server/lib/quota/providers/neuralwatt.test.js +7 -7
- package/server/lib/quota/providers/ollama-cloud.js +31 -0
- package/server/lib/quota/providers/ollama-cloud.test.js +33 -1
- package/server/lib/quota/providers/opencode-go.js +1 -1
- package/server/lib/quota/providers/opencode-go.test.js +26 -1
- package/server/lib/quota/providers/openrouter.js +119 -24
- package/server/lib/quota/providers/openrouter.test.js +330 -0
- package/server/lib/quota/utils/auth.js +1 -1
- package/server/lib/relay/DOCUMENTATION.md +55 -0
- package/server/lib/relay/cross-compat.test.js +26 -0
- package/server/lib/relay/downstream-scheduler.js +154 -0
- package/server/lib/relay/downstream-scheduler.test.js +162 -0
- package/server/lib/relay/e2ee.js +10 -8
- package/server/lib/relay/flow-control.test.js +177 -0
- package/server/lib/relay/host-client.js +37 -8
- package/server/lib/relay/host-client.test.js +9 -1
- package/server/lib/relay/tunnel-codec.js +9 -0
- package/server/lib/relay/tunnel-host.js +66 -17
- package/server/lib/session-assist/runtime.js +6 -10
- package/server/lib/session-goal/DOCUMENTATION.md +20 -7
- package/server/lib/session-goal/runtime.js +80 -20
- package/server/lib/session-goal/runtime.test.js +426 -0
- package/server/lib/skills-catalog/DOCUMENTATION.md +1 -1
- package/server/lib/skills-catalog/install.js +3 -2
- package/server/lib/small-model/DOCUMENTATION.md +3 -2
- package/server/lib/small-model/call.js +9 -4
- package/server/lib/small-model/call.test.js +29 -0
- package/server/lib/small-model/index.js +5 -10
- package/server/lib/small-model/runtime-providers.js +15 -7
- package/server/lib/small-model/runtime-providers.test.js +7 -1
- package/server/lib/terminal/DOCUMENTATION.md +14 -10
- package/server/lib/terminal/runtime.js +160 -24
- package/server/lib/terminal/runtime.test.js +571 -37
- package/server/lib/terminal/shells.js +17 -0
- package/server/lib/terminal/shells.test.js +32 -1
- package/server/lib/walkthrough/DOCUMENTATION.md +33 -14
- package/server/lib/walkthrough/model-settings.js +8 -12
- package/server/lib/walkthrough/prompt.js +3 -1
- package/server/lib/walkthrough/routes.test.js +26 -5
- package/server/lib/walkthrough/sources.js +23 -2
- package/dist/assets/DiffView-CNnDxRmO.js +0 -4
- package/dist/assets/FilesView-8wdiG2mj.js +0 -17
- package/dist/assets/MarkdownImageGallery-DffjmciG.js +0 -1
- package/dist/assets/MarkdownRendererImpl-DxqdYDAx.js +0 -12
- package/dist/assets/OnboardingScreen-CTZe6HZn.js +0 -1
- package/dist/assets/PierreDiffViewer-BvwtCxW4.js +0 -157
- package/dist/assets/PlanView-C1qvAm7m.js +0 -5
- package/dist/assets/SettingsView-xGONHFGS.js +0 -28
- package/dist/assets/WalkthroughView-D-HFgdmM.js +0 -4
- package/dist/assets/contextPanelEmbeddedChat-CV-DwAiX.js +0 -1
- package/dist/assets/de-Cv_4FoXm.js +0 -10
- package/dist/assets/es-BIWNEbnS.js +0 -16
- package/dist/assets/fr-SD3OfMHJ.js +0 -14
- package/dist/assets/index-CHUT_bDS.css +0 -1
- package/dist/assets/index-DDInLQDd.js +0 -40
- package/dist/assets/ja-D7I9HofF.js +0 -16
- package/dist/assets/ko-BsVJM_PQ.js +0 -16
- package/dist/assets/main-De8Z5w49.js +0 -928
- package/dist/assets/markdownCore-BoQVG5-a.js +0 -3
- package/dist/assets/patchFileDiff-Chmiz6hq.js +0 -10
- package/dist/assets/pl-XR9Bs8Be.js +0 -16
- package/dist/assets/pt-BR-Due4be8g.js +0 -16
- package/dist/assets/renderElectronMiniChatApp-8tXADjfl.js +0 -2
- package/dist/assets/renderMobileApp-Cji7Hma5.js +0 -25
- package/dist/assets/runtimeEndpointReset-gWt3Lb5D.js +0 -16
- package/dist/assets/scheduledTasksApi-9e-UX6im.js +0 -1
- package/dist/assets/tr-DBJcAv4y.js +0 -7
- package/dist/assets/uk-COYh2BaN.js +0 -16
- package/dist/assets/useInlineCommentController-BkfXnjNZ.js +0 -2
- package/dist/assets/useRootScrollLock-KzOUytpn.js +0 -1
- package/dist/assets/vendor-ghostty-web-CrxinGGH.js +0 -13
- package/dist/assets/vendor-legendapp-list-gg7YLRW7.js +0 -1
- package/dist/assets/vendor-zod-DVWEh-IS.js +0 -39
- package/dist/assets/zh-CN-Cjk6lzhc.js +0 -16
- package/dist/assets/zh-TW-Dk0dOg03.js +0 -16
|
@@ -1,928 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-D-HFgdmM.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-CCgvcQ6u.js","assets/index-DDInLQDd.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-zod-DVWEh-IS.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/index-CHUT_bDS.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-BeMD8X_w.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/contextPanelEmbeddedChat-CV-DwAiX.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-framer-motion-livSKyyV.js","assets/vendor-motion-dom-D_o3BTI3.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-g05Cx3z9.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/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-BxpoC5Fp.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-gg7YLRW7.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/PierreDiffViewer-BvwtCxW4.js","assets/web-components-B6QgbmTo.js","assets/computeVirtualFileMetrics-DUnyszhW.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/VirtualizedFileDiff-vqW3KKo5.js","assets/isDiffPlainText-TNageFjy.js","assets/vendor-diff-C3JhlQdm.js","assets/Virtualizer-D_a8gKmg.js","assets/useInlineCommentController-BkfXnjNZ.js","assets/runtimeEndpointReset-gWt3Lb5D.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/patchFileDiff-Chmiz6hq.js","assets/useRootScrollLock-KzOUytpn.js","assets/scheduledTasksApi-9e-UX6im.js","assets/vendor-cron-parser-CUcP7OfX.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-CNnDxRmO.js","assets/FilesView-8wdiG2mj.js","assets/shikiHighlight-CRpCl7UT.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-DUiIpERC.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-JPmZOYSp.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets-BO_2OW4E.js","assets/GitView-Cv2xH-S6.js","assets/DirtyBranchSwitchDialog-jADfXQnR.js","assets/LinearIssuesView-CoZ7pQN5.js","assets/PlanView-C1qvAm7m.js","assets/SettingsWindow-COzgfFxM.js","assets/SettingsView-xGONHFGS.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/OnboardingScreen-CTZe6HZn.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{f as Xe,R as c,j as s,r as rt,h as zm}from"./vendor-react-BUCujlKS.js";import{z as gn,A as Ho,O as Ya,D as Vm,B as Um,C as dd,r as cs,o as Go,u as Te,E as Km,F as Pn,G as Hm,H as dt,I as Gs,J as qo,K as ud,L as Gm,N as qm,P as Qm,Q as Ym,R as md,v as Qo,m as es,S as Mn,T as Lr,e as Nn,U as Xm,a as xs,V as Jm,W as Zm,X as ef,Y as fd,n as un,w as qs,Z as tf,_ as xa,$ as sf,a0 as Xa,a1 as nf,a2 as rf,a3 as hd,f as of,a4 as af,a5 as or,a6 as ba,d as Io,a7 as Rr,a8 as as,a9 as Ni,aa as lf,ab as cf,i as df,ac as go,ad as xo,ae as uf,af as Ja,ag as mf,ah as ff,ai as hf,aj as pf,ak as Za,al as el,am as tl,an as sl,ao as gf,t as nl,ap as xf,aq as bf,ar as yf,x as wf,y as Sf}from"./index-DDInLQDd.js";import{_ as _n}from"./vendor-vite-runtime-DD1OZmLC.js";import{f as pt,h as Re,b2 as Wt,I as E,g as hn,t as Be,b3 as Qs,b4 as Es,b5 as Ys,b6 as Xs,N as er,W as Dn,b7 as Ln,o as Yo,b8 as rl,a7 as xt,a8 as bt,a9 as yt,b as zt,y as Qe,G as vf,b9 as eo,u as Ds,A as ya,C as pd,ba as Ai,bb as jf,bc as gd,bd as xd,r as _s,be as bd,bf as wa,bg as Xo,bh as yd,bi as wd,bj as kf,bk as ol,bl as Cf,bm as Nf,bn as Sa,bo as Pi,bp as Af,bq as Pf,L as Sd,br as Df,l as Kt,bs as Tf,n as ar,bt as vd,p as If,bu as jd,bv as Rf,bw as Ef,bx as Mf,by as kd,bz as Cd,bA as Of,ax as va,bB as Qn,bC as Qr,bD as Bf,bE as Ss,bF as vs,bG as Ls,bH as Ts,bI as Is,bJ as xn,B as ot,aq as Hs,bK as Ff,bL as _f,av as An,bM as bo,bN as Ks,bO as Jo,bP as Nd,bQ as Di,bR as Lf,bS as Ms,bT as Os,bU as Ns,bV as Bs,bW as ts,T as kn,bX as lr,bY as il,bZ as ur,M as Zo,ac as Yr,ad as $f,ae as ja,af as Ad,ag as Pd,ai as Bn,b_ as ei,b$ as Cn,a2 as ka,c0 as Wf,c1 as zf,ap as Vf,c2 as Uf,c3 as Kf,c4 as Hf,ar as Ca,c5 as Na,c6 as mr,c7 as Dd,c8 as Gf,c9 as qf,ca as Xr,cb as Qf,cc as Yf,cd as ir,O as Td,ce as Xf,cf as $n,cg as Jf,ch as Zf,ci as ai,cj as Id,ck as Rd,cl as eh,aw as Ti,cm as Ii,cn as th,co as al,cp as Er,c as $r,d as Aa,_ as sh,cq as Ed,cr as kr,cs as Mr,ct as nh,cu as rh,cv as oh,X as Md,as as ih,cw as ah,cx as lh,cy as ch,cz as dh,cA as Od,cB as pn,cC as uh,cD as Bd,cE as mh,cF as Ri,cG as fh,cH as hh,cI as Fd,cJ as ph,cK as _d,a0 as Ro,cL as Ei,R as Pa,Q as Da,S as Ta,cM as Ia,a as Ra,$ as gh,cN as ll,cO as Mi,cP as Ld,cQ as xh,cR as $d,cS as bh,P as Oi,H as yh,cT as cl,cU as wh,cV as dl,cW as Sh,cX as ls,cY as vh,cZ as Fn,c_ as Ea,c$ as Wd,d0 as jh,d1 as zd,d2 as Vd,d3 as kh,D as Ch,d4 as Nh,d5 as Ah,d6 as Ph,d7 as ul,d8 as Dh,d9 as Th,da as Ud,E as Ih,db as yo,dc as Kd,dd as Rh,de as Eh,df as Mh,dg as Oh,e as Hd,dh as Ma,di as Bh,dj as Wr,dk as Fh,dl as ml,dm as _h,dn as Lh,Z as $h,dp as Wh,aJ as Bi,a3 as fl,aN as hl,a4 as pl,dq as zh,J as Vh,K as li,dr as Uh,ds as Kh,dt as Gd,du as qd,dv as Qd,dw as Hh,F as Oa,dx as Gh,a1 as qh,dy as Qh,dz as Yh,dA as Xh,dB as Jh,dC as Zh,dD as ep,dE as tp,dF as sp,dG as Eo,ah as np,dH as rp,dI as gl,dJ as op,dK as ip,dL as ap,dM as lp,dN as Mo,dO as cp,dP as xl,dQ as dp,dR as up,dS as mp,dT as fp,dU as hp,dV as pp,dW as wo,dX as gp,dY as xp,i as bp,dZ as yp,d_ as wp,d$ as Sp,e0 as vp,a5 as jp,e1 as kp,e2 as Cp,e3 as Np,e4 as Ap,e5 as bl,e6 as Pp,aD as Dp,aE as Tp,aF as Ip,aH as yl,aI as wl,aL as Sl,aK as Yd,aM as Xd,e7 as Rp,aZ as Ep,a_ as Mp,a$ as Op,b0 as Bp,b1 as Fp,aT as _p,aV as Lp,aW as $p,aX as Wp,aY as zp}from"./useAppFontEffects-CCgvcQ6u.js";import{u as Jd,S as vl,C as Vp,W as Zd,f as Up,a as Kp}from"./useRootScrollLock-KzOUytpn.js";import{j as jl,k as qt,n as Hp,l as kl,t as wn,m as Gp,o as ci,q as qp,s as Qp,U as eu,v as Fi,w as _i,d as tu,x as su,c as Yp,b as Xp,y as nu,z as Li,A as Kn,E as ru,F as ou,P as Jp,T as Zp,G as eg,H as tg,I as sg,S as Cl,J as ng,K as rg,L as og,u as Or,N as ig,D as ag,W as lg,M as Nl,Q as cg,f as dg,h as iu,i as ug,R as mg,V as fg,X as hg,e as pg,g as gg,O as au,C as xg}from"./runtimeEndpointReset-gWt3Lb5D.js";import{u as zn,n as bg,f as yg,a as Al,s as wg,d as Sg,b as vg,r as jg}from"./scheduledTasksApi-9e-UX6im.js";import{f as zr,h as On,T as lu,M as cu,D as Vr,j as Ur,d as kg,P as $i,b as Cg,k as Wi,i as Ng}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as ti,S as Oo,h as Ag,a as du,v as zi,s as Pg}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as si}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as uu,M as mu,C as fu,a as Vi,b as Ui,c as Ki,d as hu,e as Dg,f as Tg}from"./vendor-base-ui-BeMD8X_w.js";import{c as tr,u as Zn,d as pu,p as Ig}from"./vendor-zustand-BAGL70zf.js";import{g as Rg,b as Eg,E as gu,c as Mg,d as Og,e as Bg,f as Fg,i as _g}from"./contextPanelEmbeddedChat-CV-DwAiX.js";import{a as Ba,s as wr,r as xu}from"./vendor-zod-DVWEh-IS.js";import{u as Lg}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{d as bu}from"./vendor-cron-parser-CUcP7OfX.js";const $g="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",Wg="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",di=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?$g:t.id==="terminal"?Wg:void 0}),Pl=t=>{const e=Xe.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 u=a,d=r||i;if(d&&!o){let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>l(!0),e[2]=g):g=e[2];let p;return e[3]!==d?(p=s.jsx("img",{src:d,alt:"",className:"h-4 w-4 rounded-sm",onError:g}),e[3]=d,e[4]=p):p=e[4],p}let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=Re("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]!==u?(f=s.jsx("span",{className:h,children:u}),e[6]=u,e[7]=f):f=e[7],f},zg=t=>{const e=Xe.c(75),{directory:n,className:r}=t,{t:i}=pt(),o=zn(Vg),l=zn(Ug),a=zn(Kg),u=zn(Hg),d=zn(Gg),h=zn(qg),f=zn(Qg);let g,p;e[0]!==d?(g=()=>{d()},p=[d],e[0]=d,e[1]=g,e[2]=p):(g=e[1],p=e[2]),c.useEffect(g,p);const w=gn()&&Ho();let v;e:{let _;e[3]!==l||e[4]!==o?(_=l.find(ue=>ue.id===o)??l.find(Yg)??l[0]??Ya[0],e[3]=l,e[4]=o,e[5]=_):_=e[5];const le=_;if(le){let ue;e[6]!==le?(ue=di(le),e[6]=le,e[7]=ue):ue=e[7],v=ue;break e}let ee;e[8]===Symbol.for("react.memo_cache_sentinel")?(ee=di(Ya[0]),e[8]=ee):ee=e[8],v=ee}const x=v;if(!w||!n||l.length===0)return null;let m;e[9]!==n?(m=async _=>{await Um(n,_.id,_.appName)||await dd(n,_.appName)},e[9]=n,e[10]=m):m=e[10];const b=m;let y;e[11]!==b||e[12]!==f?(y=async _=>{await f(_.id),await b(_)},e[11]=b,e[12]=f,e[13]=y):y=e[13];const S=y;let N;e[14]!==n||e[15]!==i?(N=async()=>{(await hn(n)).ok&&Be.success(i("openInApp.toast.pathCopied"))},e[14]=n,e[15]=i,e[16]=N):N=e[16];const C=N;let k;e[17]!==r?(k=Re("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]=k):k=e[18];let A;e[19]!==b||e[20]!==x?(A=()=>{b(x)},e[19]=b,e[20]=x,e[21]=A):A=e[21];const P=u&&"animate-pulse";let D;e[22]!==P?(D=Re("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",P),e[22]=P,e[23]=D):D=e[23];let M;e[24]!==x.label||e[25]!==i?(M=i("openInApp.actions.openInAria",{app:x.label}),e[24]=x.label,e[25]=i,e[26]=M):M=e[26];let $;e[27]!==x.fallbackIconDataUrl||e[28]!==x.iconDataUrl||e[29]!==x.label?($=s.jsx(Pl,{label:x.label,iconDataUrl:x.iconDataUrl,fallbackIconDataUrl:x.fallbackIconDataUrl}),e[27]=x.fallbackIconDataUrl,e[28]=x.iconDataUrl,e[29]=x.label,e[30]=$):$=e[30];let R;e[31]!==D||e[32]!==M||e[33]!==$||e[34]!==A?(R=s.jsx("button",{type:"button",onClick:A,className:D,"aria-label":M,children:$}),e[31]=D,e[32]=M,e[33]=$,e[34]=A,e[35]=R):R=e[35];let K;e[36]===Symbol.for("react.memo_cache_sentinel")?(K=Re("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]=K):K=e[36];let L;e[37]!==i?(L=i("openInApp.actions.chooseAppAria"),e[37]=i,e[38]=L):L=e[38];let O;e[39]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(E,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=O):O=e[39];let I;e[40]!==L?(I=s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button",className:K,"aria-label":L,children:O})}),e[40]=L,e[41]=I):I=e[41];let j;e[42]!==C?(j=()=>{C()},e[42]=C,e[43]=j):j=e[43];let T;e[44]===Symbol.for("react.memo_cache_sentinel")?(T=s.jsx(E,{name:"file-copy",className:"h-4 w-4"}),e[44]=T):T=e[44];let F;e[45]!==i?(F=i("openInApp.actions.copyPath"),e[45]=i,e[46]=F):F=e[46];let U;e[47]!==F?(U=s.jsx("span",{className:"typography-ui-label text-foreground",children:F}),e[47]=F,e[48]=U):U=e[48];let H;e[49]!==j||e[50]!==U?(H=s.jsxs(Wt,{className:"flex items-center gap-2",onClick:j,children:[T,U]}),e[49]=j,e[50]=U,e[51]=H):H=e[51];let Y;e[52]===Symbol.for("react.memo_cache_sentinel")?(Y=s.jsx(Es,{}),e[52]=Y):Y=e[52];let me;if(e[53]!==l||e[54]!==S||e[55]!==x.id){let _;e[57]!==S||e[58]!==x.id?(_=le=>{const ee=di(le);return s.jsxs(Wt,{className:"flex items-center gap-2",onClick:()=>{S(le)},children:[s.jsx(Pl,{label:le.label,iconDataUrl:le.iconDataUrl,fallbackIconDataUrl:ee.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:le.label}),x.id===le.id?s.jsx(E,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},le.id)},e[57]=S,e[58]=x.id,e[59]=_):_=e[59],me=l.map(_),e[53]=l,e[54]=S,e[55]=x.id,e[56]=me}else me=e[56];let Z;e[60]!==a||e[61]!==h||e[62]!==i?(Z=a?s.jsxs(Wt,{className:"flex items-center gap-2",onClick:()=>{h(!0)},children:[s.jsx(E,{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]=Z):Z=e[63];let re;e[64]!==H||e[65]!==me||e[66]!==Z?(re=s.jsxs(Ys,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[H,Y,me,Z]}),e[64]=H,e[65]=me,e[66]=Z,e[67]=re):re=e[67];let se;e[68]!==I||e[69]!==re?(se=s.jsxs(Xs,{children:[I,re]}),e[68]=I,e[69]=re,e[70]=se):se=e[70];let fe;return e[71]!==R||e[72]!==se||e[73]!==k?(fe=s.jsxs("div",{className:k,children:[R,se]}),e[71]=R,e[72]=se,e[73]=k,e[74]=fe):fe=e[74],fe};function Vg(t){return t.selectedAppId}function Ug(t){return t.availableApps}function Kg(t){return t.isCacheStale}function Hg(t){return t.isScanning}function Gg(t){return t.initialize}function qg(t){return t.loadInstalledApps}function Qg(t){return t.selectApp}function Yg(t){return t.id===Vm}const Bo=new Map,Hi=new Set,yu=()=>{for(const t of Hi)t()},ui=(t,e)=>{const n=t.trim();n&&(e.length===0?Bo.delete(n):Bo.set(n,[...e]),yu())},Xg=t=>{Bo.delete(t.trim())&&yu()},wu=[],Jg=t=>Bo.get(t.trim())??wu,Zg=t=>(Hi.add(t),()=>{Hi.delete(t)}),ex=t=>{const e=Xe.c(2);let n;return e[0]!==t?(n=()=>Jg(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(Zg,n,tx)};function tx(){return wu}const sx=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],nx=["dev","start","preview","serve"];async function rx(t,e,n){if(!t)return null;const r=ax(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const i=lx(n);if(i){const o=await cx(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 ox(t)){const i=await ix(),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 ox(t){const e=`${t}/index.html`,n=await Fo(e,t);return typeof n=="string"&&n.trim().length>0}async function ix(){try{const t=await cs("/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 ax(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(nx.some(i=>n.includes(i)))return e}return null}function lx(t){for(const{pattern:e}of sx)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function cx(t){const e=await Fo(`${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 Fo(`${t}/${r}`,t);if(typeof o=="string"&&o.trim().length>0)return i}return"npm"}async function Fo(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),i=await cs(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(i.ok)return i.text()}catch{}const n=Go()?.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 cs(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function dx(t){try{const e=await Fo(`${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 ux=(t,e,n)=>new Promise(r=>{let i=!1,o=null,l=null;const a=u=>{i||(i=!0,l&&clearTimeout(l),o?.close(),r(u))};o=t.connect(e,{onEvent:u=>{(u.type==="exit"||u.type==="snapshot"&&u.status==="exited")&&a(!0)},onError:(u,d)=>{d&&a(!0)}}),i?o.close():l=setTimeout(()=>a(!1),n)}),Vs="__openchamber_auto_discover_preview__",mx=15e3,fx=3e3,hx=t=>{let e="";for(let n=0;n<t.length;n+=1){const r=t.charCodeAt(n);r>=0&&r<=8||r===11||r===12||r>=14&&r<=31||r===127||(e+=t[n])}return e},px=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}},gx=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:i=!1})=>{const{t:o}=pt(),{currentTheme:l}=er(),{terminal:a,runtime:u}=Dn(),{isMobile:d}=Ln(),h=c.useMemo(()=>gn(),[]),f=jl(oe=>oe.instances),g=jl(oe=>oe.load),p=Te(oe=>oe.terminalShell),w=Te(oe=>oe.terminalLoginShells.includes(oe.terminalShell)),v=Te(oe=>oe.setSettingsPage),x=Te(oe=>oe.setSettingsDialogOpen),m=Te(oe=>oe.setSettingsProjectsSelectedId),b=Te(oe=>oe.openContextPreview),y=qt(oe=>oe.ensureDirectory),S=qt(oe=>oe.setTabLabel),N=qt(oe=>oe.setTabIconKey),C=qt(oe=>oe.setActiveTab),k=qt(oe=>oe.setConnecting),A=qt(oe=>oe.setTabSessionId),P=qt(oe=>oe.setTabPreviewUrl),D=qt(oe=>oe.projectActionRuns),M=qt(oe=>oe.setProjectActionRun),$=qt(oe=>oe.updateProjectActionRunStatus),R=qt(oe=>oe.removeProjectActionRun),[K,L]=c.useState([]),[O,I]=c.useState(null),[j,T]=c.useState(!1),F=c.useRef({}),U=c.useRef({}),H=c.useRef({}),Y=c.useRef({}),me=c.useRef(new Set),Z=c.useRef(0),re=t?.id??null,se=t?.path??"",fe=c.useMemo(()=>re?{id:re,path:se}:null,[re,se]);c.useEffect(()=>{h&&g().catch(()=>{})},[h,g]);const _=c.useCallback(async oe=>{await Yo(oe)},[]),le=c.useCallback(async()=>{if(!fe)return;const oe=Z.current+1;Z.current=oe,T(!0);try{const Pe=await rl(fe);if(Z.current!==oe)return;const Ne=Pe.actions;L(Ne),I(B=>B===Vs||B&&Ne.some(ce=>ce.id===B)?B:null)}catch{if(Z.current!==oe)return}finally{Z.current===oe&&T(!1)}},[fe]),ee=c.useMemo(()=>Hp(e||fe?.path||""),[e,fe?.path]),ue=c.useMemo(()=>O?K.find(oe=>oe.id===O)??null:null,[K,O]),W=c.useMemo(()=>({id:Vs,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),ne=!d,pe=c.useMemo(()=>ne?[W,...K]:K,[K,W,ne]);c.useEffect(()=>{le()},[le]),c.useEffect(()=>{if(typeof window>"u")return;const oe=Pe=>{const Ne=Pe.detail;re&&(Ne?.projectId&&Ne.projectId!==re||le())};return window.addEventListener(kl,oe),()=>{window.removeEventListener(kl,oe)}},[le,re]),c.useEffect(()=>{O&&(O===Vs&&ne||K.some(oe=>oe.id===O)||I(null))},[K,ne,O]),c.useEffect(()=>{const oe=Ne=>{delete Y.current[Ne];const B=U.current[Ne];if(!B||B.openedUrl)return;const ce=qt.getState(),be=ce.projectActionRuns[Ne];if(!be)return;const ge=B.announced;if(ge.length!==0){if(B.openedUrl=!0,ce.updateProjectActionRunStatus(Ne,"running"),ge.length===1){ui(be.directory,[]),P(be.directory,be.tabId,ge[0],{locked:!1,autoOpened:!0}),b(be.directory,ge[0]);return}B.offering=!0,ui(be.directory,ge),Te.getState().openContextSurface(be.directory,"browser"),Be.info(o("projectActions.toast.multipleServers"))}},Pe=()=>{const Ne=qt.getState(),B=Ne.sessions,ce=Ne.projectActionRuns;for(const[be,ge]of Object.entries(ce)){const tt=B.get(ge.directory)?.tabs.find(qe=>qe.id===ge.tabId);if(!tt||tt.terminalSessionId!==ge.sessionId){R(be);continue}const Ue=U.current[be]??{lastSeenChunkId:null,openedUrl:!1,tail:"",openInPreview:!1,announced:[],offering:!1};U.current[be]=Ue;const de=pe.find(qe=>qe.id===ge.actionId),X=Ne.getBuffer(ge.directory,ge.tabId).chunks;if(!de||X.length===0)continue;const we=X.filter(qe=>Ue.lastSeenChunkId===null||qe.id>Ue.lastSeenChunkId);if(we.length===0)continue;const ze=we.map(qe=>qe.data).join(""),Ve=`${Ue.tail}${ze}`;if(Ue.openInPreview&&(!Ue.openedUrl||Ue.offering)){const qe=qp(Ve),at=Ue.announced.length;for(const Pt of qe)Ue.announced.includes(Pt)||Ue.announced.push(Pt);const gt=Ue.announced.length-at;Ue.offering&>>0?ui(ge.directory,Ue.announced):!Ue.openedUrl&&at===0&&Ue.announced.length>0&&(window.clearTimeout(Y.current[be]),Y.current[be]=window.setTimeout(()=>oe(be),fx))}const He=!Ue.openedUrl&&de.autoOpenUrl===!0&&!Ue.openInPreview?Qp(Ve):null,$e=we[we.length-1]?.id??Ue.lastSeenChunkId;if(Ue.lastSeenChunkId=$e,Ue.tail=Ve.slice(-512),He)if(Ue.openedUrl=!0,Ue.openInPreview){const qe=ce[be];qe&&(P(qe.directory,qe.tabId,He,{locked:!1,autoOpened:!1}),qe.status==="waiting-for-preview"&&$(be,"running"),window.clearTimeout(Y.current[be]),delete Y.current[be],b(qe.directory,He))}else _(He),Be.success(o("projectActions.toast.openedUrlFromOutput"));U.current[be]=Ue}for(const be of Object.keys(U.current))ce[be]||(delete U.current[be],window.clearTimeout(Y.current[be]),delete Y.current[be])};return Pe(),qt.subscribe((Ne,B)=>{(Ne.sessions!==B.sessions||Ne.buffers!==B.buffers)&&Pe()})},[pe,b,_,D,R,P,o,$]);const xe=c.useCallback(async(oe,Pe={})=>{if(!ee)throw new Error(o("projectActions.error.noActiveDirectory"));const Ne=wn(ee,oe.id);y(ee);const B=qt.getState(),ce=B.getDirectoryState(ee);let be=F.current[Ne]||null;const ge=be?!!ce?.tabs.some(Ue=>Ue.id===be):!1;(!be||!ge)&&(be=B.createTab(ee),F.current[Ne]=be),S(ee,be,`Action: ${oe.name}`),N(ee,be,oe.icon||"play"),C(ee,be),Pe.revealTerminal!==!1&&Te.getState().openContextPanelTab(ee,{mode:"terminal"});const tt=qt.getState().getDirectoryState(ee)?.tabs.find(Ue=>Ue.id===be);return{key:Ne,tabId:be,sessionId:tt?.terminalSessionId??null}},[y,ee,C,N,S,o]),Ce=c.useCallback(async oe=>{if(u.isVSCode||!i&&d)return;if(!ee){Be.error(o("projectActions.error.noActiveDirectoryForAction"));return}const Pe=wn(ee,oe.id),Ne=D[Pe];if(!(Ne&&Ne.status==="running")&&!me.current.has(Pe)){me.current.add(Pe);try{const B=oe.id===Vs?await(async()=>{const[He,$e]=await Promise.all([rl({id:fe?.id??"",path:ee}),dx(ee)]),qe=await rx(ee,He.actions,$e);if(!qe)throw new Error(o("contextPanel.preview.noDevServer"));return{id:Vs,name:o("projectActions.actions.autoDiscover"),command:qe.command,icon:"scan-2",autoOpenUrl:!0,openUrl:qe.previewUrlHint||""}})():oe,ce=B.autoOpenUrl===!0&&(B.openUrl||"").trim().length>0,be=!ce&&oe.id!==Vs,{key:ge,tabId:_e,sessionId:tt}=await xe(B,{revealTerminal:be});let Ue=tt;if(!Ue){k(ee,_e,!0);try{Ue=(await a.createSession({cwd:ee,sessionId:_e,shell:p,loginShell:w,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground})).sessionId,A(ee,_e,Ue)}finally{k(ee,_e,!1)}}if(!Ue)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));H.current[ge]?.(),k(ee,_e,!0);const de=a.connect(Ue,{onEvent:He=>{He.type==="snapshot"&&(qt.getState().replaceBuffer(ee,_e,He.data??"",He.sequence??0),qt.getState().setConnecting(ee,_e,!1)),He.type==="data"&&typeof He.data=="string"&&He.data.length>0&&qt.getState().appendToBuffer(ee,_e,He.data,He.sequence,He.replayData),He.type==="exit"&&(qt.getState().setTabLifecycle(ee,_e,"exited"),qt.getState().setConnecting(ee,_e,!1),qt.getState().removeProjectActionRun(ge),delete U.current[ge],H.current[ge]?.(),delete H.current[ge],window.clearTimeout(Y.current[ge]),delete Y.current[ge])},onError:(He,$e)=>{qt.getState().setConnecting(ee,_e,!1),$e&&(qt.getState().setTabLifecycle(ee,_e,"exited"),qt.getState().setTabSessionId(ee,_e,null),qt.getState().removeProjectActionRun(ge))}});H.current[ge]=de.close;const X=B.autoOpenUrl===!0&&h&&(B.desktopOpenSshForward||"").trim().length>0,we=B.autoOpenUrl?px(B.openUrl):null,ze=B.autoOpenUrl&&h?Gp(B.desktopOpenSshForward,f):null;M({key:ge,directory:ee,actionId:B.id,tabId:_e,sessionId:Ue,status:B.id===Vs&&!we?"waiting-for-preview":"running"}),window.clearTimeout(Y.current[ge]),delete Y.current[ge],B.id===Vs&&!we&&(Y.current[ge]=window.setTimeout(()=>{const He=qt.getState(),$e=He.projectActionRuns[ge];He.updateProjectActionRunStatus(ge,"running"),$e&&(He.setActiveTab($e.directory,$e.tabId),Te.getState().openContextPanelTab($e.directory,{mode:"terminal"})),delete Y.current[ge]},mx)),U.current[ge]={lastSeenChunkId:null,openedUrl:!!ze||!!we||ce,tail:"",openInPreview:B.id===Vs,announced:[],offering:!1};const Ve=hx(B.command.trim().replace(/\r\n|\r/g,`
|
|
3
|
-
`));await a.sendInput(Ue,`${Ve}\r`),ze?(P(ee,_e,null,{locked:!0}),_(ze),Be.success(o("projectActions.toast.openedForwardedUrl"))):we?(P(ee,_e,we,{locked:!0,autoOpened:!0}),b(ee,we),Be.success(o("projectActions.toast.openedActionUrl"))):ce?(P(ee,_e,null,{locked:!0}),Be.error(o("projectActions.error.invalidCustomUrlFormat"))):X?(P(ee,_e,null,{locked:!0}),Be.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):P(ee,_e,null,{locked:!1,autoOpened:!1})}catch(B){R(Pe),delete U.current[Pe],H.current[Pe]?.(),delete H.current[Pe],window.clearTimeout(Y.current[Pe]),delete Y.current[Pe],Be.error(B instanceof Error?B.message:o("projectActions.error.failedToRunAction"))}finally{me.current.delete(Pe)}}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,f,xe,i,d,h,ee,w,p,_,b,D,u.isVSCode,R,k,M,P,A,fe?.id,o,a]),Me=c.useCallback(async oe=>{const Pe=wn(ee,oe.id),Ne=D[Pe];if(!Ne)return;$(Pe,"stopping");const B=ux(a,Ne.sessionId,1e3);try{await a.sendInput(Ne.sessionId,"")}catch{}const ce=await B;if(qt.getState().getDirectoryState(Ne.directory)?.tabs.find(_e=>_e.id===Ne.tabId)?.terminalSessionId===Ne.sessionId&&!ce){if(typeof a.forceKill=="function")try{await a.forceKill({sessionId:Ne.sessionId})}catch{}else try{await a.close(Ne.sessionId)}catch{}A(Ne.directory,Ne.tabId,null)}R(Pe),delete U.current[Pe],H.current[Pe]?.(),delete H.current[Pe],window.clearTimeout(Y.current[Pe]),delete Y.current[Pe]},[ee,D,R,A,a,$]),ve=c.useCallback(()=>{const oe=ue??pe[0];if(!oe)return;const Pe=wn(ee,oe.id),Ne=D[Pe];if(Ne?.status!=="stopping"){if(Ne){Me(oe);return}Ce(oe)}},[pe,ee,Ce,D,ue,Me]),Ie=c.useCallback((oe,Pe=!1)=>{if(I(oe.id),!Pe){Ce(oe);return}const Ne=wn(ee,oe.id),B=D[Ne];if(B?.status!=="stopping"){if(B){Me(oe);return}Ce(oe)}},[ee,Ce,D,Me]),ye=c.useCallback(()=>{fe?.id&&(m(fe.id),v("projects"),x(!0))},[x,v,m,fe?.id]),q=ue??pe[0]??null,De=q?D[wn(ee,q.id)]:null,ke=qt(oe=>De?oe.sessions.get(De.directory)?.tabs.find(Pe=>Pe.id===De.tabId)?.previewUrl??null:null);if(u.isVSCode||!i&&d||!fe||!ee)return null;const te=ue??pe[0]??null;if(!te)return null;const he=te.icon||"play",ae=te.id===Vs?"scan-2":ci[he]||"play",Q=wn(ee,te.id),z=D[Q],G=z?.status==="stopping",ie=z?.status==="waiting-for-preview",Oe=!!(z&&ke),Fe=()=>{!z||!ke||b(z.directory,ke)},Se=te.id===Vs;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",disabled:j||G,className:Re("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-primary","disabled:cursor-not-allowed",n),onClick:ve,"aria-label":z?o("projectActions.actions.stopNamedAria",{name:te.name}):o("projectActions.actions.runNamedAria",{name:te.name}),children:G||ie?s.jsx(E,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):z?s.jsx(E,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(E,{name:ae,className:"h-5 w-5"})})}),Se?s.jsx(yt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),Oe?s.jsxs(xt,{children:[s.jsx(bt,{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-primary","aria-label":o("projectActions.actions.openPreview"),onClick:Fe,children:s.jsx(E,{name:"global",className:"h-4 w-4"})})}),s.jsx(yt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Xs,{children:[s.jsx(Qs,{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-primary","aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(E,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(Ys,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Wt,{className:"flex items-center gap-2",onClick:ye,children:[s.jsx(E,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Es,{}),pe.map(oe=>{const Pe=oe.icon||"play",Ne=oe.id===Vs?"scan-2":ci[Pe]||"play",B=wn(ee,oe.id),ce=D[B],be=!!ce,ge=ce?.status==="stopping";return s.jsxs(Wt,{className:"flex items-center gap-2",onClick:()=>{Ie(oe,!0)},children:[s.jsx(E,{name:Ne,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:oe.name}),ge||ce?.status==="waiting-for-preview"?s.jsx(E,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):be?s.jsx(E,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},oe.id)})]})]})]}):s.jsxs("div",{className:Re("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(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:ve,disabled:j||G,className:Re("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-primary disabled:cursor-not-allowed"),"aria-label":z?o("projectActions.actions.stopNamedAria",{name:te.name}):o("projectActions.actions.runNamedAria",{name:te.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:G||ie?s.jsx(E,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):z?s.jsx(E,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(E,{name:ae,className:"h-4 w-4"})})})}),Se?s.jsx(yt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),Oe?s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Fe,className:Re(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-primary"),"aria-label":o("projectActions.actions.openPreview"),children:s.jsx(E,{name:"global",className:"h-4 w-4"})})}),s.jsx(yt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Xs,{children:[s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button",className:Re(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-primary"),"aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(E,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(Ys,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Wt,{className:"flex items-center gap-2",onClick:ye,children:[s.jsx(E,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Es,{}),pe.map(oe=>{const Pe=oe.icon||"play",Ne=oe.id===Vs?"scan-2":ci[Pe]||"play",B=wn(ee,oe.id),ce=D[B],be=!!ce,ge=ce?.status==="stopping";return s.jsxs(Wt,{className:"flex items-center gap-2",onClick:()=>{Ie(oe,!0)},children:[s.jsx(E,{name:Ne,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:oe.name}),ge||ce?.status==="waiting-for-preview"?s.jsx(E,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):be?s.jsx(E,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},oe.id)})]})]})]})},to=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function xx(){const t=zt(f=>f.activeProjectId?f.projects.find(g=>g.id===f.activeProjectId)??null:null),e=Qe(f=>f.currentSessionId),n=vf(e??null),r=Qe(f=>e?f.worktreeMetadata.get(e)?.path??"":""),i=Qe(f=>f.newSessionDraft?.open?to(f.newSessionDraft.bootstrapPendingDirectory??f.newSessionDraft.directoryOverride??""):""),o=c.useMemo(()=>to(r||""),[r]),l=c.useMemo(()=>{const f=typeof n?.directory=="string"?n.directory:"";return to(f||"")},[n?.directory]),a=o||l||i,u=c.useMemo(()=>to(a||t?.path||""),[t?.path,a]),d=c.useMemo(()=>t?{id:t.id,path:t.path}:null,[t]),h=c.useRef(null);return c.useEffect(()=>{d&&u&&(h.current={projectRef:d,directory:u})},[u,d]),c.useMemo(()=>d&&u?{projectRef:d,directory:u}:h.current,[d,u])}const bx=({transform:t})=>({...t,y:0}),yx={Item:Wt,Separator:Es},wx={Item:({className:t,...e})=>s.jsx(mu,{className:Re(xd,t),...e}),Separator:({className:t,...e})=>s.jsx(uu,{className:Re(gd,t),...e})},Sx=t=>{const e=Xe.c(62),{tab:n,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:u,onMenuOpenChangeComplete:d,children:h}=t,{t:f}=pt(),[g,p]=c.useState(!1),[w,v]=c.useState(!1),[x,m]=c.useState(!1);let b;e[0]!==n.id?(b={id:n.id},e[0]=n.id,e[1]=b):b=e[1];const{attributes:y,listeners:S,setNodeRef:N,transform:C,transition:k,isDragging:A}=ti(b);let P;e[2]!==f||e[3]!==n.session.title?(P=n.session.title?.trim()||f("sessions.sidebar.session.untitled"),e[2]=f,e[3]=n.session.title,e[4]=P):P=e[4];const D=P,M=!i&&(g||w),$=ya(n.id),R=$?.type==="busy"||$?.type==="retry",L=pd(n.id)>0&&!r&&!R,O=R||L;let I;e[5]!==R||e[6]!==f?(I=f(R?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[5]=R,e[6]=f,e[7]=I):I=e[7];const j=I;let T;e[8]!==u||e[9]!==r||e[10]!==o||e[11]!==n?(T=pe=>({session:n.session,isActive:r,select:()=>o(n),closeOtherTabs:()=>u(n.id),components:pe}),e[8]=u,e[9]=r,e[10]=o,e[11]=n,e[12]=T):T=e[12];const F=T;let U;e[13]!==C?(U=si.Translate.toString(C),e[13]=C,e[14]=U):U=e[14];let H;e[15]!==U||e[16]!==k?(H={transform:U,transition:k},e[15]=U,e[16]=k,e[17]=H):H=e[17];const Y=A&&"z-10 opacity-60";let me;e[18]!==Y?(me=Re("session-tab-slot flex h-7 w-44 shrink-0 touch-none",Y),e[18]=Y,e[19]=me):me=e[19];const Z=r?"true":"false";let re;e[20]!==r?(re=r?{"data-active-session-tab":!0}:{},e[20]=r,e[21]=re):re=e[21];let se;e[22]!==d?(se=pe=>d?.(pe),e[22]=d,e[23]=se):se=e[23];let fe;e[24]!==h||e[25]!==j||e[26]!==r||e[27]!==R||e[28]!==F||e[29]!==g||e[30]!==l||e[31]!==d||e[32]!==o||e[33]!==M||e[34]!==a||e[35]!==O||e[36]!==i||e[37]!==f||e[38]!==n||e[39]!==D?(fe=s.jsx(fu,{render:pe=>s.jsxs("div",{...pe,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(n),onKeyDown:r?void 0:xe=>{(xe.key==="Enter"||xe.key===" ")&&(xe.preventDefault(),o(n))},onAuxClick:xe=>{xe.button===1&&(xe.preventDefault(),l(n.id))},"data-controls-open":M?"true":"false",className:Re("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":Re("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",M&&"bg-interactive-hover text-foreground")),children:[s.jsxs("div",{className:Re("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pr-10",M&&"pr-10"),children:[s.jsx("div",{className:Re("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:D})})}),O?s.jsx("span",{className:Re("ml-1.5 h-1.5 w-1.5 shrink-0 rounded-full",R?"bg-primary":"bg-[var(--status-info)]",!i&&"group-hover/session-tab:opacity-0",M&&"opacity-0"),"aria-label":j}):null]}),i?null:s.jsxs("div",{onClick:jx,onPointerDown:kx,className:Re("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",M&&"flex opacity-100"),children:[s.jsxs(Xs,{open:g,onOpenChange:xe=>{p(xe),xe&&v(!0)},onOpenChangeComplete:xe=>{xe||v(!1),d?.(xe)},children:[s.jsx(Qs,{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(E,{name:"more",className:"size-4"})})}),s.jsx(Ys,{align:"start",className:"min-w-[190px]",children:a(F(yx))})]}),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(E,{name:"close",className:"size-4"})})]})]})}),e[24]=h,e[25]=j,e[26]=r,e[27]=R,e[28]=F,e[29]=g,e[30]=l,e[31]=d,e[32]=o,e[33]=M,e[34]=a,e[35]=O,e[36]=i,e[37]=f,e[38]=n,e[39]=D,e[40]=fe):fe=e[40];let _,le;e[41]===Symbol.for("react.memo_cache_sentinel")?(_={color:"var(--surface-elevated-foreground)"},le=Re(Ai,"min-w-[190px]"),e[41]=_,e[42]=le):(_=e[41],le=e[42]);let ee;e[43]!==F||e[44]!==a?(ee=a(F(wx)),e[43]=F,e[44]=a,e[45]=ee):ee=e[45];let ue;e[46]!==ee?(ue=s.jsx(Vi,{children:s.jsx(Ui,{className:"app-region-no-drag z-50",children:s.jsx(Ki,{"data-slot":"dropdown-menu-content",style:_,className:le,children:ee})})}),e[46]=ee,e[47]=ue):ue=e[47];let W;e[48]!==x||e[49]!==se||e[50]!==fe||e[51]!==ue?(W=s.jsxs(hu,{open:x,onOpenChange:m,onOpenChangeComplete:se,children:[fe,ue]}),e[48]=x,e[49]=se,e[50]=fe,e[51]=ue,e[52]=W):W=e[52];let ne;return e[53]!==y||e[54]!==S||e[55]!==N||e[56]!==re||e[57]!==W||e[58]!==H||e[59]!==me||e[60]!==Z?(ne=s.jsx("div",{ref:N,style:H,className:me,"data-active":Z,...re,...y,...S,children:W}),e[53]=y,e[54]=S,e[55]=N,e[56]=re,e[57]=W,e[58]=H,e[59]=me,e[60]=Z,e[61]=ne):ne=e[61],ne},vx=t=>{const e=Xe.c(64),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=pt(),u=eo(Cx),d=eo(Nx),h=eo(Ax),f=eo(Px),g=Qe(Dx),p=Qe(Tx),w=Ds(Ix);let v,x;e[0]!==g||e[1]!==d?(v=()=>{g&&d(g)},x=[g,d],e[0]=g,e[1]=d,e[2]=v,e[3]=x):(v=e[2],x=e[3]),c.useEffect(v,x);let m;if(e[4]!==w){m=new Map;for(const ve of w)m.set(ve.id,ve);e[4]=w,e[5]=m}else m=e[5];const b=m;let y;if(e[6]!==b||e[7]!==u){y=[];for(const ve of u){const Ie=b.get(ve);Ie&&y.push({id:ve,session:Ie})}e[6]=b,e[7]=u,e[8]=y}else y=e[8];const S=y;let N;e[9]!==p?(N=ve=>{p(ve.id,_s(ve.session))},e[9]=p,e[10]=N):N=e[10];const C=N,k=Rx;let A;e[11]!==h||e[12]!==g||e[13]!==C||e[14]!==S?(A=ve=>{if(h(ve),g&&g!==ve){const Ie=S.find(ye=>ye.id===ve);Ie&&C(Ie)}},e[11]=h,e[12]=g,e[13]=C,e[14]=S,e[15]=A):A=e[15];const P=A;let D;e[16]===Symbol.for("react.memo_cache_sentinel")?(D={activationConstraint:{distance:8}},e[16]=D):D=e[16];let M;e[17]===Symbol.for("react.memo_cache_sentinel")?(M={activationConstraint:{delay:200,tolerance:6}},e[17]=M):M=e[17];const $=zr(On(cu,D),On(lu,M));let R;e[18]!==f?(R=ve=>{const{active:Ie,over:ye}=ve;ye&&Ie.id!==ye.id&&f(String(Ie.id),String(ye.id))},e[18]=f,e[19]=R):R=e[19];const K=R,L=c.useRef(null);let O;e[20]===Symbol.for("react.memo_cache_sentinel")?(O={left:!1,right:!1},e[20]=O):O=e[20];const[I,j]=c.useState(O);let T;e[21]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{const ve=L.current;if(!ve)return;const Ie=ve.scrollLeft>2,ye=ve.scrollLeft+ve.clientWidth<ve.scrollWidth-2;j(q=>q.left===Ie&&q.right===ye?q:{left:Ie,right:ye})},e[21]=T):T=e[21];const F=T;let U;e[22]===Symbol.for("react.memo_cache_sentinel")?(U=()=>{F();const ve=L.current;if(!ve||!globalThis.ResizeObserver)return;const Ie=new ResizeObserver(F);return Ie.observe(ve),()=>Ie.disconnect()},e[22]=U):U=e[22];let H;e[23]!==S.length?(H=[F,S.length],e[23]=S.length,e[24]=H):H=e[24],c.useEffect(U,H);let Y;e[25]===Symbol.for("react.memo_cache_sentinel")?(Y=()=>{L.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[25]=Y):Y=e[25];let me;e[26]!==g?(me=[g],e[26]=g,e[27]=me):me=e[27],c.useEffect(Y,me);const Z=I.left&&I.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":I.left?"linear-gradient(to right, transparent, black 24px)":I.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let re;e[28]!==S?(re=S.map(Ex),e[28]=S,e[29]=re):re=e[29];const se=re;let fe;e[30]!==g||e[31]!==S?(fe=!g||!S.some(ve=>ve.id===g),e[30]=g,e[31]=S,e[32]=fe):fe=e[32];const _=fe;let le;e[33]!==a?(le=a("header.sessionTabs.stripAria"),e[33]=a,e[34]=le):le=e[34];let ee;e[35]!==Z?(ee=Z?{maskImage:Z,WebkitMaskImage:Z}:void 0,e[35]=Z,e[36]=ee):ee=e[36];let ue;e[37]===Symbol.for("react.memo_cache_sentinel")?(ue=[bx],e[37]=ue):ue=e[37];let W;e[38]!==o||e[39]!==g||e[40]!==P||e[41]!==C||e[42]!==r||e[43]!==n||e[44]!==l||e[45]!==S?(W=S.map(ve=>s.jsx(Sx,{tab:ve,isActive:ve.id===g,suppressControls:ve.id===g&&l,onSelect:C,onClose:k,renderMenu:n,closeOtherTabs:P,onMenuOpenChangeComplete:r,children:ve.id===g?o:null},ve.id)),e[38]=o,e[39]=g,e[40]=P,e[41]=C,e[42]=r,e[43]=n,e[44]=l,e[45]=S,e[46]=W):W=e[46];let ne;e[47]!==W||e[48]!==se?(ne=s.jsx(Oo,{items:se,strategy:Ag,children:W}),e[47]=W,e[48]=se,e[49]=ne):ne=e[49];let pe;e[50]!==K||e[51]!==$||e[52]!==ne?(pe=s.jsx(Vr,{sensors:$,collisionDetection:Ur,modifiers:ue,onDragEnd:K,children:ne}),e[50]=K,e[51]=$,e[52]=ne,e[53]=pe):pe=e[53];let xe;e[54]!==o||e[55]!==_?(xe=_?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]=_,e[56]=xe):xe=e[56];let Ce;e[57]!==ee||e[58]!==pe||e[59]!==xe?(Ce=s.jsxs("div",{ref:L,onScroll:F,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:ee,children:[pe,xe]}),e[57]=ee,e[58]=pe,e[59]=xe,e[60]=Ce):Ce=e[60];let Me;return e[61]!==le||e[62]!==Ce?(Me=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":le,children:Ce}),e[61]=le,e[62]=Ce,e[63]=Me):Me=e[63],Me};function jx(t){return t.stopPropagation()}function kx(t){return t.stopPropagation()}function Cx(t){return t.tabIds}function Nx(t){return t.ensureTab}function Ax(t){return t.closeOtherTabs}function Px(t){return t.reorderTabs}function Dx(t){return t.currentSessionId}function Tx(t){return t.setCurrentSession}function Ix(t){return t.activeSessions}function Rx(t){jf(t)}function Ex(t){return t.id}function Mx(t){if(typeof t!="number"||!Number.isFinite(t))return"";const e=new Date(t);if(Number.isNaN(e.getTime()))return"";const n=e.toLocaleString(wa(),{month:"short"}),r=e.getDate(),i=e.getFullYear(),o=String(e.getHours()).padStart(2,"0"),l=String(e.getMinutes()).padStart(2,"0");return`${n} ${r}, ${i}, ${o}:${l}`}function Ox(t){if(t.info.role==="user")return"";const e=typeof t.info.providerID=="string"?t.info.providerID.trim():"",n=typeof t.info.modelID=="string"?t.info.modelID.trim():"";return e&&n?`${e}/${n}`:n||e}function Bx(t){const e=t.info.role==="user"?"User":"Assistant",n=Mx(t.info.time?.created),r=Ox(t),i=n&&r?`${n} (${r})`:n||r;return i?`**${e}**
|
|
4
|
-
|
|
5
|
-
*${i}*`:`**${e}**`}function Fx(t){return t.filter(e=>e.type==="text"&&typeof e.text=="string").map(e=>e.text).join("")}function Su(t){const e=Bx(t),n=Fx(t.parts).trim();return n?`${e}
|
|
6
|
-
|
|
7
|
-
${n}`:""}function vu(t,e){const n="#".repeat(Math.min(e+1,6)),r=t.agent?` — ${t.agent}`:"",i=`${n} Sub-agent: ${t.title}${r}
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
`,o=t.records.map(Su).filter(Boolean).join(`
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
`),l=[i+o];for(const a of t.children)l.push(vu(a,e+1));return l.join(`
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
`)}function ju(t,e,n){const r=e?.trim()||"Session",i=new Date().toISOString().split("T")[0],o=`# ${r}
|
|
20
|
-
|
|
21
|
-
*Exported on ${i}*
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
`,l=t.map(Su).filter(Boolean).join(`
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
`);let a=o+l;if(n&&n.length>0){const u=n.map(d=>vu(d,1)).join(`
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
`);a+=`
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
`+u}return a}function ku(t,e){const n=new Blob([t],{type:"text/markdown;charset=utf-8"}),r=URL.createObjectURL(n),i=document.createElement("a");i.href=r,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}async function Cu(t,e){const n=await Km(e,t);if(n)return n;if(!Pn())return null;try{const r=await Go()?.vscode?.saveMarkdown?.({fileName:e,content:t});if(!r||r.saved!==!0)return null;const i=typeof r.path=="string"?r.path.trim():"";return i.length>0?i:null}catch{return null}}async function _x(t){const e=Go()?.files;if(e?.revealPath)try{return!!(await e.revealPath(t))?.success}catch{return!1}return await Hm(t)?!0:dd(t)}function Lx(){return bd()}function Nu(t){const r=(t?.trim()||"session").normalize("NFKC").toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"").slice(0,60)||"session",i=new Date().toISOString().split("T")[0];return`${r}-${i}.md`}const Gi=(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")}),Wn=tr(()=>({pendingSessionIds:new Set,requestingSessionIds:new Set,confirmation:null})),Au=t=>{const e=Xe.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],Wn(n)},$x=()=>Wn(Yx),Pu=()=>Wn.getState().confirmation,Fa=t=>{Wn.setState(e=>e.confirmation===t?e:{...e,confirmation:t})},Dl=(t,e)=>{Wn.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}})},cr=(t,e)=>{Wn.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}})},Wx="Unable to apply your changes in the destination directory",zx=t=>t.status===400&&t.message.includes(Wx),Vx=async(t,e)=>{try{const u=(await yd(t,{mode:"light"})).current?.trim();if(u)return u}catch{}const n=dt(t),r=dt(e)??e,i=Qe.getState().availableWorktreesByProject,l=(i.get(r)??i.get(e)??[]).find(a=>dt(a.path)===n)?.branch?.trim();if(l)return l;throw new Error("Unable to determine the current branch")},Tl=t=>{for(const e of t){const n=Cf(e.id);if(n==="unknown")throw new Error("Session status is unavailable");if(n==="active")throw new Error("Session is not idle")}};class Du extends Error{changesMayBeInDestination;constructor(e,n,r){super(e,{cause:n}),this.name="IncompleteRollbackError",this.changesMayBeInDestination=r}}const Ux=(t,e,n)=>{const r=e.map(({sessionId:i,error:o})=>`${i}: ${o.message}`).join(", ");return new Du(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${r}`,{moveError:t,rollbackFailures:e},n)},Kx=async(t,e,n,r)=>{const i=[];for(const o of[...t].reverse()){if(Nf(o.id)){i.push({sessionId:o.id,error:new Error("Session is not idle")});continue}try{await wd(o,n,e,!1),Qe.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 Tu extends Error{constructor(e){super(e.message,{cause:e}),this.name="ChangesMayBeInDestinationError"}}const Il=async(t,e,n)=>{try{await Sd(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${n.message}`)}throw n},Rl=async(t,e)=>{const n=e?[t,e]:[t];try{await Sa(n)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},Iu=async(t,e)=>{if(Wn.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");Dl(t.root.id,!0);try{const n=[...t.descendants,t.root],r=new Map(n.map(a=>[a.id,Qe.getState().getWorktreeMetadata(a.id)]));Tl(n);let i=null;const o=[];let l=!1;try{i=await e();for(const[a,u]of n.entries()){Tl(n.slice(a));const d=u.id===t.root.id&&t.moveChanges;try{await wd(u,t.sourceDirectory,i.directory,d)}catch(h){throw d&&kf(h)&&(l=!0),h}o.push(u),u.id!==t.root.id&&Qe.getState().setWorktreeMetadata(u.id,ol(i.metadata))}}catch(a){const u=a instanceof Error?a:new Error(String(a)),d=await Kx(o,t.sourceDirectory,i?.directory??t.sourceDirectory,r);if(l&&await Rl(t.sourceDirectory,i?.directory),d.length>0)throw Ux(u,d,l);if(l)throw new Tu(u);if(i?.onMoveFailure)return i.onMoveFailure(u);throw u}return Qe.getState().setWorktreeMetadata(t.root.id,ol(i.metadata)),await Rl(t.sourceDirectory,i.directory),i.directory}finally{Dl(t.root.id,!1)}},Hx=async t=>{const e=dt(t.sourceDirectory)??t.sourceDirectory,n=dt(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 Iu(t,async()=>({directory:t.destination.path,metadata:t.destination}))},Gx=async t=>Iu(t,async()=>{const e=Pi(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const n=await Xo(t.sourceDirectory)?await Vx(t.sourceDirectory,e.path):null,r=await Af(e,n?{startRef:n}:{});try{await Pf(r.path)}catch(i){const o=i instanceof Error?i:new Error(String(i));return Il(e,r,o)}return{directory:r.path,metadata:r,onMoveFailure:async i=>Il(e,r,i)}}),qx=(t,e,n)=>e instanceof Tu?t.changesMayBeInDestination:e instanceof Du&&e.changesMayBeInDestination?`${e.message} ${t.changesMayBeInDestination}`:n&&zx(e)?t.applyChangesFailed:e.message,qi=(t,e)=>{(t.kind==="existing"?Hx({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination,moveChanges:e}):Gx({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,moveChanges:e})).then(()=>Be.success(t.messages.success)).catch(r=>{const i=r instanceof Error?r:new Error(String(r));Be.error(t.messages.failure,{description:qx(t.messages,i,e)})})},Qx=()=>{const t=Pu();t&&(cr(t.intent.root.id,!1),Fa(null))},Ru=t=>{const e=Pu();if(!e)return;const{intent:n}=e;Fa(null),cr(n.root.id,!1),qi(n,t)},Qi=t=>{const e=Wn.getState();e.confirmation||e.pendingSessionIds.has(t.root.id)||e.requestingSessionIds.has(t.root.id)||(cr(t.root.id,!0),(async()=>{try{if(!await Xo(t.sourceDirectory)){cr(t.root.id,!1),qi(t,!1);return}const r=await yd(t.sourceDirectory);if(r.isClean){cr(t.root.id,!1),qi(t,!1);return}const i=r.files.filter(o=>{const l=o.index.trim();return l!==""&&l!=="?"}).length;Fa({intent:t,dirtyFileCount:r.files.length,stagedFileCount:i})}catch{Be.error(t.messages.failure,{description:t.messages.sourceVerificationFailed}),cr(t.root.id,!1)}})())};function Yx(t){return t.confirmation}const _o="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-primary disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors",Xx=c.memo(function(e){const n=Xe.c(17),{visible:r,title:i,ariaLabel:o,onClick:l,className:a,Icon:u,iconClassName:d,pressed:h}=e,f=r===void 0?!0:r,g=h===void 0?!1:h;if(!f)return null;const p=a??_o,w=g&&"bg-interactive-selection text-interactive-selection-foreground";let v;n[0]!==p||n[1]!==w?(v=Re(p,w),n[0]=p,n[1]=w,n[2]=v):v=n[2];const x=d??"h-[18px] w-[18px]";let m;n[3]!==u||n[4]!==x?(m=s.jsx(E,{name:u,className:x}),n[3]=u,n[4]=x,n[5]=m):m=n[5];let b;n[6]!==o||n[7]!==l||n[8]!==g||n[9]!==v||n[10]!==m?(b=s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,"aria-label":o,"aria-pressed":g,className:v,children:m})}),n[6]=o,n[7]=l,n[8]=g,n[9]=v,n[10]=m,n[11]=b):b=n[11];let y;n[12]!==i?(y=s.jsx(yt,{children:s.jsx("p",{children:i})}),n[12]=i,n[13]=y):y=n[13];let S;return n[14]!==b||n[15]!==y?(S=s.jsxs(xt,{children:[b,y]}),n[14]=b,n[15]=y,n[16]=S):S=n[16],S}),Jx=c.memo(function(e){const n=Xe.c(43),{isDesktopApp:r,currentInstanceLabel:i,currentInstanceIsLocal:o,isDesktopServicesOpen:l,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:u,shortcutLabel:d,remoteUpdateInfo:h,remoteUpdateChecking:f,remoteUpdateError:g,onOpenRemoteUpdate:p}=e,{t:w}=pt();let v;n[0]!==u||n[1]!==a?(v=$=>{a($),$&&u()},n[0]=u,n[1]=a,n[2]=v):v=n[2];let x;n[3]!==i||n[4]!==r||n[5]!==w?(x=r?w("header.services.openWithCurrent",{current:i}):w("header.services.open"),n[3]=i,n[4]=r,n[5]=w,n[6]=x):x=n[6];const m=r?"w-auto max-w-[20rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let b;n[7]!==m?(b=Re(_o,m),n[7]=m,n[8]=b):b=n[8];let y;n[9]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(E,{name:"server",className:"h-[18px] w-[18px]"}),n[9]=y):y=n[9];let S;n[10]!==i||n[11]!==r?(S=r?s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:i}):null,n[10]=i,n[11]=r,n[12]=S):S=n[12];let N;n[13]!==x||n[14]!==b||n[15]!==S?(N=s.jsx(bt,{asChild:!0,children:s.jsx(Qs,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":x,className:b,children:[y,S]})})}),n[13]=x,n[14]=b,n[15]=S,n[16]=N):N=n[16];let C;n[17]!==i||n[18]!==d||n[19]!==w?(C=w("header.services.tooltip.currentInstance",{current:i,toggle:d("toggle_services_menu")}),n[17]=i,n[18]=d,n[19]=w,n[20]=C):C=n[20];let k;n[21]!==C?(k=s.jsx(yt,{children:s.jsx("p",{children:C})}),n[21]=C,n[22]=k):k=n[22];let A;n[23]!==N||n[24]!==k?(A=s.jsxs(xt,{children:[N,k]}),n[23]=N,n[24]=k,n[25]=A):A=n[25];let P;n[26]!==o||n[27]!==r||n[28]!==l||n[29]!==p||n[30]!==f||n[31]!==g||n[32]!==h||n[33]!==a||n[34]!==w?(P=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"):g||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:p,children:w("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx(Df,{embedded:!0,open:l,onOpenChange:tb,onHostSwitched:()=>a(!1)})]}):null,n[26]=o,n[27]=r,n[28]=l,n[29]=p,n[30]=f,n[31]=g,n[32]=h,n[33]=a,n[34]=w,n[35]=P):P=n[35];let D;n[36]!==P?(D=s.jsx(Ys,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:P}),n[36]=P,n[37]=D):D=n[37];let M;return n[38]!==l||n[39]!==v||n[40]!==A||n[41]!==D?(M=s.jsxs(Xs,{open:l,onOpenChange:v,children:[A,D]}),n[38]=l,n[39]=v,n[40]=A,n[41]=D,n[42]=M):M=n[42],M}),Zx=(t,e)=>t===e?!0:!t||!e?!1:t.totalTokens===e.totalTokens&&t.percentage===e.percentage&&t.contextLimit===e.contextLimit&&(t.outputLimit??0)===(e.outputLimit??0)&&(t.normalizedOutput??0)===(e.normalizedOutput??0)&&t.thresholdLimit===e.thresholdLimit&&(t.lastMessageId??"")===(e.lastMessageId??""),Sn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},El=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,eb=()=>{Gs("ui.header.render");const{t}=pt(),e=Te(V=>V.isSidebarOpen),n=Te(V=>V.openContextOverview),r=Te(V=>V.closeContextPanel),i=Te(V=>V.shortcutOverrides),o=Te(V=>V.sessionTabsEnabled),l=Kt(V=>V.getCurrentModel),a=Qe(V=>V.getContextUsage),u=Qe(V=>!!V.newSessionDraft?.open),d=Qe(V=>V.currentSessionId),h=Tf(d??""),f=ya(d??""),g=Au(d??""),p=Ds(Zn(c.useCallback(V=>{if(!d)return null;const Le=[...V.activeSessions,...V.archivedSessions].find(mt=>mt.id===d);if(!Le)return null;const Je=Le;return{title:Le.title??null,directory:Je.directory??null,created:Le.time?.created??null,slug:Je.slug??null,shareUrl:Le.share?.url??null,parentId:Le.parentID??null}},[d]))),w=zt(Zn(V=>{if(!V.activeProjectId)return null;const Le=V.projects.find(Je=>Je.id===V.activeProjectId);return Le?{id:Le.id,path:Le.path,label:Le.label}:null})),v=c.useMemo(()=>{if(!w)return null;const V=w.label?.trim();if(V)return V;const Le=w.path.split(/[\\/]/).filter(Boolean);return Le[Le.length-1]??null},[w]),x=ar(V=>V.loadSettings),{isMobile:m}=Ln(),b=c.useRef(null),[y,S]=c.useState(()=>typeof window>"u"?!1:gn()),N=c.useMemo(()=>qo(),[]),C=vd(),[k,A]=c.useState(!1),P=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:D,side:M}=Jd(),$=c.useMemo(()=>{if(typeof window>"u")return null;const V=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof V=="number"&&Number.isFinite(V)&&V>0)return V;if(typeof navigator>"u")return null;const Le=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!Le)return null;const Je=Number.parseInt(Le[1],10),mt=Number.parseInt(Le[2],10);return Number.isNaN(Je)?null:Je===10?mt:Je},[]);rt.useEffect(()=>{typeof window>"u"||S(gn())},[]);const R=l(),K=R&&typeof R.limit=="object"&&R.limit!==null?R.limit:null,L=K&&typeof K.context=="number"?K.context:0,O=K&&typeof K.output=="number"?K.output:0,I=a(L,O),[j,T]=c.useState(null),F=!d||h;rt.useEffect(()=>{if(!d){T(V=>V===null?V:null);return}if(I&&I.totalTokens>0){T(V=>Zx(V,I)?V:I);return}F&&T(V=>V===null?V:null)},[I,d,F]);const[U,H]=c.useState(!1),[Y,me]=c.useState("Local"),[Z,re]=c.useState(!0),[se,fe]=c.useState(!1),[_,le]=c.useState(null),[ee,ue]=c.useState(!1),[W,ne]=c.useState(null),pe=c.useMemo(()=>Pn(),[]),xe=Te(V=>V.workStatusPanelVisible),Ce=Te(V=>V.workStatusPanelEnabled),Me=Te(V=>V.setWorkStatusPanelEnabled),ve=Te(V=>V.workStatusPanelFits),Ie=Te(V=>V.workStatusOverlayOpen),ye=Te(V=>V.setWorkStatusOverlayOpen),De=Ce&&ve||Ie,ke=c.useCallback(()=>{if(Ce&&!ve){ye(!Ie);return}Me(!Ce)},[ye,Me,Ie,Ce,ve]),te=!pe&&!xe&&!!j&&j.totalTokens>0,he=j&&j.contextLimit>0?Math.min(999,j.totalTokens/j.contextLimit*100):0,ae=c.useCallback(async()=>{if(!(typeof window>"u"||!y))try{if(Ho()){me("Local"),re(!0);return}re(!1);const V=await ud(),Le=Gm(),Je=qm([Qm(Le),...V.hosts]);if(Je.id===Ym){me("Local"),re(!0);return}me(md(Je.label.trim()||"Instance"))}catch{me("Local"),re(!0)}},[y]);rt.useEffect(()=>(ae(),Qo(()=>{ae()})),[ae]);const Q=c.useCallback(async()=>{if(Z){le(null),ne(null);return}ue(!0),ne(null);try{const V=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),Le=await cs(`/api/openchamber/update-check?${V.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!Le.ok)throw new Error(`Server responded with ${Le.status}`);const Je=await Le.json();le({available:Je.available??!1,version:Je.version,currentVersion:Je.currentVersion??"unknown",body:Je.body,nextSuggestedCheckInSec:typeof Je.nextSuggestedCheckInSec=="number"?Je.nextSuggestedCheckInSec:void 0,packageManager:Je.packageManager,updateCommand:Je.updateCommand})}catch(V){le(null),ne(V instanceof Error?V.message:t("header.services.remoteUpdate.error"))}finally{ue(!1)}},[Z,t]);c.useEffect(()=>{le(null),ne(null),fe(!1)},[Z,Y]),c.useEffect(()=>{if(!y||Z)return;const V=3e3,Le=3600*1e3;let Je=!1,mt=null;const ft=Ot=>{mt=window.setTimeout(()=>{if(Je||typeof document<"u"&&document.visibilityState!=="visible"){ft(Le);return}Q().finally(()=>{Je||ft(Le)})},Ot)};return ft(V),()=>{Je=!0,mt!==null&&window.clearTimeout(mt)}},[Q,Z,Y,y]);const z=c.useCallback(()=>{if(_?.available){fe(!0);return}Q()},[Q,_?.available]);If(),c.useEffect(()=>{x()},[x]);const G=d?p??null:null,ie=c.useRef(null),[Oe,Fe]=c.useState(0);c.useEffect(()=>{if(!d){ie.current&&(ie.current=null,Fe(mt=>mt+1));return}if(G){ie.current={sessionId:d,session:G,expiresAt:Date.now()+2e3};return}const V=ie.current;if(!V||V.sessionId!==d)return;const Le=V.expiresAt-Date.now();if(Le<=0){ie.current=null,Fe(mt=>mt+1);return}const Je=window.setTimeout(()=>{ie.current?.sessionId===d&&(ie.current=null),Fe(mt=>mt+1)},Le);return()=>{window.clearTimeout(Je)}},[d,G]);const Se=(()=>{if(G)return G;if(!d)return null;const V=ie.current;return V&&V.sessionId===d&&V.expiresAt>Date.now()?V.session:null})(),oe=Qe(V=>d?V.worktreeMetadata.get(d)?.path??"":""),Pe=Qe(V=>d?V.worktreeMetadata.get(d)?.branch?.trim()??null:null),Ne=jd(V=>d?V.getAttachment(d):void 0),B=c.useMemo(()=>Ne?Rf(Ne,{pending:t("gitView.empty.worktreeSetupInProgress")}):null,[t,Ne]),ce=c.useMemo(()=>Ne?Ne.legacy?"legacy":Ne.degraded?"degraded":Ne.worktreeStatus==="pending"?"pending":Ne.worktreeStatus==="missing"?"missing":Ne.worktreeStatus==="invalid"?"invalid":Ne.attentionReason?"attention":null:null,[Ne]),be=c.useMemo(()=>Sn(oe||""),[oe]),ge=c.useMemo(()=>{const V=typeof Se?.directory=="string"?Se.directory:"";return Sn(V||"")},[Se?.directory]),_e=Qe(V=>V.newSessionDraft?.open?Sn(V.newSessionDraft.bootstrapPendingDirectory??V.newSessionDraft.directoryOverride??""):""),tt=Qe(V=>V.newSessionDraft.target),Ue=Qe(V=>V.newSessionDraft.selectedProjectId),de=Qe(V=>V.currentSessionDirectory),X=es(V=>V.homeDirectory),we=c.useMemo(()=>be||ge||_e,[_e,ge,be]),ze=Te(c.useCallback(V=>{const Le=Sn(we||"");return Le?El(V.contextPanelByDirectory[Le]):null},[we])),Ve=Qe(V=>{const Le=Sn(be||ge||"");if(!Le)return null;for(const Je of V.availableWorktreesByProject.values()){const ft=Je.find(Ot=>Sn(Ot.path)===Le)?.branch?.trim();if(ft)return ft}return null}),$e=Ef(we||null)||Pe||Ve,qe=u?tt==="chat":Mf(ge||de,X),at=!qe&&!xe&&!!(v||$e||!u&&ce),gt=c.useMemo(()=>{if(!d)return v??"OpenChamber";const V=Se?.title?.trim();return V&&V.length>0?V:"Untitled Session"},[v,Se?.title,d]),Pt=kd(we||void 0,{bootstrap:!1}),Ge=Cd(),It=Qe(V=>V.updateSessionTitle),kt=Qe(V=>V.shareSession),Mt=Qe(V=>V.unshareSession),Tt=Qe(V=>V.archiveSessions),wt=Qe(V=>V.deleteSessions),[St,vt]=c.useState(!1),[ht,Ze]=c.useState(!1),je=c.useRef(null),[nt,lt]=c.useState(""),[Ct,Ye]=c.useState(null),it=c.useRef(null),Nt=c.useCallback(()=>{d&&(lt(Se?.title?.trim()||gt),vt(!0))},[Se?.title,d,gt]),Dt=c.useRef(Nt);Dt.current=Nt;const Rt=c.useCallback(V=>{V&&(V.focus(),V.select())},[]);c.useEffect(()=>{if(Ze(!1),Ye(null),d&&je.current===d){je.current=null,Dt.current();return}vt(!1),lt("")},[d]);const Vt=c.useCallback(async()=>{if(!d)return;const V=nt.trim();V&&V!==Se?.title?.trim()&&await It(d,V),vt(!1)},[Se?.title,d,nt,It]);c.useEffect(()=>{if(!St)return;const V=Le=>{const Je=Le.target;(!Je||!it.current?.contains(Je))&&Vt()};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[St,Vt]);const Qt=c.useCallback(V=>{V&&hn(V).then(Le=>{Be[Le.ok?"success":"error"](t(Le.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>Be.error(t("sessions.sidebar.session.copyId.error")))},[t]),Ut=c.useCallback(async V=>{if(!V)return;const Le=await kt(V);if(Le?.share?.url){const Je=await hn(Le.share.url);Be[Je.ok?"success":"warning"](t("sessions.sidebar.session.share.successTitle"),{description:t(Je.ok?"sessions.sidebar.session.share.successDescription":"sessions.sidebar.session.share.copyUrlError")});return}Be.error(t("sessions.sidebar.session.share.error"))},[kt,t]),Ft=c.useCallback(V=>{V&&hn(V).then(Le=>{Be[Le.ok?"success":"error"](t(Le.ok?"sessions.sidebar.session.menu.copied":"sessions.sidebar.session.share.copyUrlError"))}).catch(()=>Be.error(t("sessions.sidebar.session.share.copyUrlError")))},[t]),Yt=c.useCallback(async V=>{if(!V)return;const Le=await Mt(V);Be[Le?"success":"error"](t(Le?"sessions.sidebar.session.unshare.success":"sessions.sidebar.session.unshare.error"))},[t,Mt]),$t=c.useCallback(async()=>{if(!d||!we){Be.error(t("sessions.sidebar.session.export.nothingToExport"));return}try{await Ge.loadCompleteHistory(d,we)}catch{Be.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}const V=Of(Pt.getState(),d).list;if(V.length===0){Be.error(t("sessions.sidebar.session.export.nothingToExport"));return}const Le=ju(V,Se?.title??null),Je=Nu(Se?.title??null);await Cu(Le,Je)||ku(Le,Je),Be.success(t("sessions.sidebar.session.export.success"))},[Se?.title,d,Pt,we,Ge,t]),_t=f?.type==="busy"||f?.type==="retry",Ee=c.useCallback(()=>{if(!d||!ge||_t||g)return;const V=Ds.getState().activeSessions,Le=V.find(ft=>ft.id===d);if(!Le)return;const Je=[],mt=[d];for(let ft=0;ft<mt.length;ft+=1){const Ot=mt[ft];for(const ss of V)ss.parentID===Ot&&(Je.push(ss),mt.push(ss.id))}Qi({kind:"quick",root:Le,descendants:Je,sourceDirectory:ge,messages:Gi(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[d,_t,g,ge,t]),Ke=c.useCallback(async()=>{if(!Ct)return;const V=Ds.getState().activeSessions,Le=[Ct.sessionId];for(let Ot=0;Ot<Le.length;Ot+=1){const ss=Le[Ot];for(const Ht of V)Ht.parentID===ss&&!Le.includes(Ht.id)&&Le.push(Ht.id)}const Je=Ct.action;if(Ye(null),(Je==="archive"?await Tt(Le):await wt(Le)).failedIds.length>0){Be.error(t(Je==="archive"?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error"));return}Be.success(t(Je==="archive"?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"))},[Tt,wt,Ct,t]),et=Te(V=>V.isScheduledTasksDialogOpen),ct=Te(V=>V.isArchivePageOpen),ut=Te(V=>V.worktreesPageProjectId),jt=Te(V=>V.isMultiRunLauncherOpen),st=zt(V=>{if(!ut)return null;const Le=V.projects.find(Je=>Je.id===ut);return Le?.label?.trim()||Le?.path?.split("/").pop()||null}),Lt=c.useMemo(()=>et?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:ct?{title:t("sessions.archivePage.title"),subtitle:null}:ut?{title:t("sessions.worktreesPage.title",{project:st??""}),subtitle:null}:jt?{title:t("sessions.sidebar.header.actions.newMultiRun"),subtitle:null}:null,[ct,jt,et,t,ut,st]),Xt=c.useMemo(()=>Sn(we||w?.path||""),[w?.path,we]),ds=xx(),js=va(V=>V.planModeEnabled),ns=Qe(V=>V.isSessionPlanAvailable),Js=js&&d?ns(d):!1,rs=c.useRef("");c.useEffect(()=>{if(!js||!d)return;const V=`${d||"none"}:${ge||"none"}:${Se?.created||0}:${Se?.slug||"none"}`;rs.current!==V&&(rs.current=V)},[js,Js,Se?.slug,Se?.created,d,ge]);const As=c.useCallback(()=>{Mn("desktop_open_draft_mini_chat_window",{directory:qe?"":_e,projectId:qe?null:Ue,apiBaseUrl:Nn(),clientToken:Lr()}).catch(V=>{console.warn("[header] failed to open draft mini chat window",V)})},[_e,Ue,qe]),$s=c.useCallback(()=>{if(u){As();return}d&&Mn("desktop_open_session_mini_chat_window",{sessionId:d,directory:ge||Sn(de||"")||be,apiBaseUrl:Nn(),clientToken:Lr()}).catch(V=>{console.warn("[header] failed to open session mini chat window",V)})},[d,As,u,de,ge,be]),Zs=c.useCallback(()=>{const V=Sn(we||"");if(!V)return;const Le=Te.getState().contextPanelByDirectory[V];if(El(Le)==="context"){r(V);return}n(V)},[r,n,we]),ln=ze==="context",bs=_o,ks=c.useMemo(()=>y&&P&&!k?"5.5rem":C?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!y||D)&&!pe?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[y,k,P,C,pe,D]);rt.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",ks)},[ks]);const Ws=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",cn=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";rt.useEffect(()=>{if(!y||!P){A(!1);return}let V=!1;const Le=async()=>{try{const mt=await Mn("desktop_is_window_fullscreen");V||A(mt===!0)}catch{V||A(!1)}},Je=()=>{Le()};return Le(),window.addEventListener("openchamber:window-resized",Je),()=>{V=!0,window.removeEventListener("openchamber:window-resized",Je)}},[y,P]);const us=c.useMemo(()=>!y||!P||$===null?"":$>=26?"h-12":$<=15?"h-14":"",[y,P,$]),zs=c.useMemo(()=>{if(!(y&&!D||pe)&&!(D&&M==="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))"}},[y,pe,D,M]),At=c.useCallback(()=>{if(typeof document>"u")return;const V=b.current?.getBoundingClientRect().height;V&&document.documentElement.style.setProperty("--oc-header-height",`${V}px`)},[]);rt.useEffect(()=>{if(typeof window>"u")return;At();const V=b.current;if(!V||typeof ResizeObserver>"u")return()=>{};let Le=0;const Je=()=>{Le||(Le=requestAnimationFrame(()=>{Le=0,At()}))},mt=new ResizeObserver(Je);return mt.observe(V),window.addEventListener("resize",Je),window.addEventListener("orientationchange",Je),()=>{Le&&cancelAnimationFrame(Le),mt.disconnect(),window.removeEventListener("resize",Je),window.removeEventListener("orientationchange",Je)}},[At]),rt.useEffect(()=>{At()},[At,m,us]);const Bt=c.useCallback(async V=>{const Le=V.target;Le.closest(".app-region-no-drag")||Le.closest("button, a, input, select, textarea")||V.button===0&&y&&await Xm()},[y]),Jt=c.useCallback(V=>Qn(Qr(V,i)),[i]);Bf({rename_current_session:()=>{if(!d||m)return!1;Nt()},toggle_services_menu:()=>{if(U){H(!1);return}H(!0),ae()}});const ms=s.jsxs(s.Fragment,{children:[ds?s.jsx(gx,{projectRef:ds.projectRef,directory:ds.directory,className:"mr-2"}):null,s.jsx(zg,{directory:Xt,className:"mr-1"}),y?s.jsx(Jx,{isDesktopApp:y,currentInstanceLabel:Y,currentInstanceIsLocal:Z,isDesktopServicesOpen:U,setIsDesktopServicesOpen:H,refreshCurrentInstanceLabel:ae,shortcutLabel:Jt,remoteUpdateInfo:_,remoteUpdateChecking:ee,remoteUpdateError:W,onOpenRemoteUpdate:z}):null]}),fs=N&&(u||!!d),Ps=c.useCallback(({session:V,isActive:Le,select:Je,closeOtherTabs:mt,components:ft})=>{const{Item:Ot,Separator:ss}=ft,Ht=V.share?.url??null,en=Le&&!pe&&!qe&&Se&&!Se.parentId;return s.jsxs(s.Fragment,{children:[s.jsxs(Ot,{onClick:()=>{Le||Je(),je.current=V.id},children:[s.jsx(E,{name:"pencil-ai",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsxs(Ot,{onClick:()=>Qt(V.id),children:[s.jsx(E,{name:"file-copy",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(ss,{}),Ht?s.jsxs(s.Fragment,{children:[s.jsxs(Ot,{onClick:()=>Ft(Ht),children:[s.jsx(E,{name:"file-copy",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.copyLink")]}),s.jsxs(Ot,{onClick:()=>{Yt(V.id)},children:[s.jsx(E,{name:"link-unlink-m",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Ot,{onClick:()=>{Ut(V.id)},children:[s.jsx(E,{name:"share-2",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.share")]}),Le?s.jsxs(Ot,{onClick:()=>{$t()},children:[s.jsx(E,{name:"download",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}):null,en?s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Ot,{disabled:!ge||_t||g,onClick:Ee,className:"w-full",children:[s.jsx(E,{name:"folder-shared",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(yt,{side:"right",className:"max-w-72",children:t(g?"sessions.sidebar.session.moveToWorktree.tooltipMoving":_t?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(ss,{}),s.jsxs(Ot,{onClick:mt,children:[s.jsx(E,{name:"close-circle",className:"mr-2 size-4"}),t("header.sessionTabs.closeOtherTabs")]}),s.jsx(ss,{}),s.jsxs(Ot,{onClick:()=>Ye({action:"archive",sessionId:V.id}),children:[s.jsx(E,{name:"inbox-archive",className:"mr-2 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Ot,{className:"text-destructive focus:text-destructive",onClick:()=>Ye({action:"delete",sessionId:V.id}),children:[s.jsx(E,{name:"delete-bin",className:"mr-2 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})},[Qt,Ft,Se,$t,qe,_t,g,pe,Ee,ge,Ut,t,Yt]),J=()=>s.jsxs("div",{onMouseDown:Bt,className:Re("app-region-drag relative flex h-12 select-none items-center",D&&M==="right"?"pr-0":"pr-3",us),style:zs,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:Ws}}),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:cn}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[Lt?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:Lt.title}),Lt.subtitle?s.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:Lt.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:[e?null:s.jsx(vl,{align:"start",children:s.jsx("button",{type:"button",className:bs,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(E,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[St?s.jsxs("form",{ref:it,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:V=>V.stopPropagation(),onSubmit:V=>{V.preventDefault(),Vt()},children:[s.jsx("input",{ref:Rt,value:nt,onChange:V=>lt(V.target.value),onKeyDown:V=>{V.stopPropagation(),V.key==="Escape"&&vt(!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(E,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>vt(!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(E,{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:u?t("sessions.switcher.draftTitle"):gt}),at?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:[v?s.jsx("span",{className:"truncate",children:v}):null,$e?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(E,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:$e})]}):null,!u&&ce?s.jsxs("span",{className:Re("inline-flex min-w-0 items-center gap-0.5",ce==="attention"||ce==="invalid"||ce==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[s.jsx(E,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:B})]}):null]}):null]}),s.jsx("div",{className:Re("flex h-[18px] shrink-0 items-center justify-center",at?"self-start":"self-center"),children:d&&!u&&!St?s.jsxs(Xs,{open:ht,onOpenChange:Ze,onOpenChangeComplete:V=>{!V&&je.current&&je.current===d&&(je.current=null,Nt())},children:[s.jsx(Qs,{asChild:!0,children:s.jsx(ot,{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(E,{name:"more",className:"size-4"})})}),s.jsxs(Ys,{align:"end",className:"min-w-[190px]",children:[s.jsxs(Wt,{onClick:()=>{je.current=d},children:[s.jsx(E,{name:"pencil-ai",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsxs(Wt,{onClick:()=>d&&Qt(d),children:[s.jsx(E,{name:"file-copy",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(Es,{}),Se?.shareUrl?s.jsxs(s.Fragment,{children:[s.jsxs(Wt,{onClick:()=>Ft(Se?.shareUrl),children:[s.jsx(E,{name:"file-copy",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.copyLink")]}),s.jsxs(Wt,{onClick:()=>{d&&Yt(d)},children:[s.jsx(E,{name:"link-unlink-m",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Wt,{onClick:()=>{d&&Ut(d)},children:[s.jsx(E,{name:"share-2",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.share")]}),s.jsxs(Wt,{onClick:()=>{$t()},children:[s.jsx(E,{name:"download",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}),!pe&&!qe&&Se&&!Se.parentId?s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Wt,{disabled:!ge||_t||g,onClick:Ee,className:"w-full",children:[s.jsx(E,{name:"folder-shared",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(yt,{side:"right",className:"max-w-72",children:t(g?"sessions.sidebar.session.moveToWorktree.tooltipMoving":_t?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(Es,{}),s.jsxs(Wt,{onClick:()=>{d&&Ye({action:"archive",sessionId:d})},children:[s.jsx(E,{name:"inbox-archive",className:"mr-2 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Wt,{className:"text-destructive focus:text-destructive",onClick:()=>{d&&Ye({action:"delete",sessionId:d})},children:[s.jsx(E,{name:"delete-bin",className:"mr-2 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(vl,{align:"start",children:s.jsx("button",{type:"button",className:bs,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(E,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsx(vx,{renderMenu:Ps,suppressActiveTabControls:St,onMenuOpenChangeComplete:V=>{!V&&je.current&&je.current===d&&(je.current=null,Nt())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:St?s.jsxs("form",{ref:it,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:V=>V.stopPropagation(),onSubmit:V=>{V.preventDefault(),Vt()},children:[s.jsx("input",{ref:Rt,value:nt,onChange:V=>lt(V.target.value),onKeyDown:V=>{V.stopPropagation(),V.key==="Escape"&&vt(!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(E,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>vt(!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(E,{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:u?t("sessions.switcher.draftTitle"):gt})})})]}),Lt||pe||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[te&&j?s.jsx(Vp,{totalTokens:j.totalTokens,percentage:he,colorPercentage:j.percentage,contextLimit:j.contextLimit,outputLimit:j.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:Zs,pressed:ln,className:fs?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,s.jsx(Xx,{visible:fs,title:t(u?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(u?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:$s,className:Re(bs,"mr-1"),Icon:"picture-in-picture-2"}),pe?null:s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":De,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:ke,className:Re(_o,"mr-1",De?"text-foreground":"text-muted-foreground/50"),children:s.jsx(E,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),s.jsx(yt,{side:"bottom",children:t(Ce&&!ve?Ie?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":Ce?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),ms,s.jsx(Zd,{visible:D&&M==="right",position:"right"})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:b,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:J()}),s.jsx(Ss,{open:Ct!==null,onOpenChange:V=>{V||Ye(null)},children:s.jsxs(vs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Ls,{children:[s.jsx(Ts,{children:Ct?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),s.jsx(Is,{children:Ct?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:gt}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:gt})})]}),s.jsxs(xn,{children:[s.jsx(ot,{variant:"outline",size:"sm",onClick:()=>Ye(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ot,{variant:"destructive",size:"sm",onClick:()=>{Ke()},children:Ct?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),s.jsx(eu,{open:se,onOpenChange:fe,info:_,downloading:!1,downloaded:!1,progress:null,error:W,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function tb(){}const Ml=280,Ol=280,Bl=500,sb=({isOpen:t,isMobile:e,children:n,className:r,topBar:i})=>{const{t:o}=pt(),l=Te(k=>k.sidebarWidth),a=Te(k=>k.setSidebarWidth),[u,d]=c.useState(!1),h=c.useRef(0),f=c.useRef(l||Ml),g=c.useRef(null),p=c.useRef(null),w=c.useRef(null),v=c.useCallback(k=>Math.min(Bl,Math.max(Ol,k)),[]),x=c.useCallback(k=>{const A=w.current;A&&(A.style.width=`${k}px`,A.style.minWidth=`${k}px`,A.style.maxWidth=`${k}px`,A.style.setProperty("--oc-left-sidebar-width",`${k}px`))},[]);if(c.useEffect(()=>{e&&u&&d(!1)},[e,u]),c.useEffect(()=>{u||(g.current=null,p.current=null)},[u]),e)return null;const m=Math.min(Bl,Math.max(Ol,l||Ml)),b=t?m:0,y=k=>{if(t){try{k.currentTarget.setPointerCapture(k.pointerId)}catch{}p.current=k.pointerId,d(!0),h.current=k.clientX,f.current=b,g.current=b,x(b),k.preventDefault()}},S=k=>{if(e||!u||p.current!==k.pointerId)return;const A=k.clientX-h.current,P=v(f.current+A);g.current!==P&&(g.current=P,x(P))},N=k=>{if(p.current!==k.pointerId||e)return;try{k.currentTarget.releasePointerCapture(k.pointerId)}catch{}const A=v(g.current??b);p.current=null,g.current=null,d(!1),a(A)},C=u?g.current??b:b;return s.jsxs("aside",{ref:w,className:Re("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:`${C}px`,minWidth:`${C}px`,maxWidth:`${C}px`,"--oc-left-sidebar-width":`${u?C:m}px`,overflowX:"clip",transitionProperty:u?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||b===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:Re("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",u&&"bg-[var(--interactive-border)]"),onPointerDown:y,onPointerMove:S,onPointerUp:N,onPointerCancel:N,role:"separator","aria-orientation":"vertical","aria-label":o("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:Re("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",u&&"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("div",{className:"min-h-0 flex-1 overflow-y-auto",children:s.jsx(Hs,{children:n})})]})]})},nb=()=>{const t=Xe.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},Fl="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-primary hover:bg-interactive-hover transition-colors",rb=()=>{const t=Xe.c(32),{t:e}=pt(),n=Te(ob),r=Te(ib),i=c.useRef(null),o=Qn(Qr("toggle_sidebar",r)),{usesFramelessChrome:l,side:a}=Jd(),u=lb;let d,h;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{if(typeof document>"u")return;const $=i.current;if(!$)return;const R=()=>{const L=Math.max($.getBoundingClientRect().width,$.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(L)}px`)};if(R(),typeof ResizeObserver>"u")return;const K=new ResizeObserver(R);return K.observe($),()=>{K.disconnect()}},h=[],t[0]=d,t[1]=h):(d=t[0],h=t[1]),c.useEffect(d,h);const f="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2";let g;t[2]===Symbol.for("react.memo_cache_sentinel")?(g={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)"},t[2]=g):g=t[2];const p="flex items-center gap-2";let w;t[3]!==l||t[4]!==a?(w=l&&a==="left"?s.jsx(Zd,{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(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,"aria-label":e("header.actions.openAppMenuAria"),className:Re(Fl,"shrink-0"),children:s.jsx(E,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),s.jsx(yt,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[6]=e,t[7]=l,t[8]=v):v=t[8];const x=xt;let m;t[9]!==e?(m=e("header.actions.openSessionsAria"),t[9]=e,t[10]=m):m=t[10];let b,y;t[11]===Symbol.for("react.memo_cache_sentinel")?(b=Re(Fl,"shrink-0"),y=s.jsx(E,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[11]=b,t[12]=y):(b=t[11],y=t[12]);let S;t[13]!==m||t[14]!==n?(S=s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":m,className:b,children:y})}),t[13]=m,t[14]=n,t[15]=S):S=t[15];const N=yt,C=e("header.actions.openSessionsWithShortcut",{shortcut:o});let k;t[16]!==C?(k=s.jsx("p",{children:C}),t[16]=C,t[17]=k):k=t[17];let A;t[18]!==N||t[19]!==k?(A=s.jsx(N,{children:k}),t[18]=N,t[19]=k,t[20]=A):A=t[20];let P;t[21]!==x||t[22]!==S||t[23]!==A?(P=s.jsxs(x,{children:[S,A]}),t[21]=x,t[22]=S,t[23]=A,t[24]=P):P=t[24];let D;t[25]!==P||t[26]!==w||t[27]!==v?(D=s.jsxs("div",{ref:i,className:p,children:[w,v,P]}),t[25]=P,t[26]=w,t[27]=v,t[28]=D):D=t[28];let M;return t[29]!==D||t[30]!==g?(M=s.jsx("div",{className:f,style:g,children:D}),t[29]=D,t[30]=g,t[31]=M):M=t[31],M};function ob(t){return t.toggleSidebar}function ib(t){return t.shortcutOverrides}function ab(t){console.warn("[titlebar] failed to open app menu",t)}function lb(t){const e=t.currentTarget.getBoundingClientRect();Mn("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch(ab)}function Eu(t){const e=Xe.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(E,{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 u;return e[3]!==i?(u=s.jsxs("span",{"aria-hidden":"true",className:i,children:[o,l,a]}),e[3]=i,e[4]=u):u=e[4],u}const _l=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function cb(t,e,n){const r=Xe.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 u=!1;return(async()=>{const[d,h]=await Promise.all([Ff(t),_f(t)]).catch(db);if(u)return;const f=_l(d),g=_l(h);if(!f||!g||g===f)return;const p=n||"",w=g.split("/").filter(Boolean).pop()||g;o({source:"sdk",path:g,projectDirectory:f,branch:p,label:p||w,name:w,worktreeRoot:g,worktreeStatus:"ready",headState:p?"branch":"unborn",worktreeSource:"existing"})})(),()=>{u=!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 db(){return["",""]}const Ll="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",ub=async(t,e)=>{if(t)return t.authActivate(e);const n=await cs("/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},$l=({className:t})=>{const{t:e}=pt(),{github:n}=Dn(),r=An(p=>p.status),i=An(p=>p.setStatus),[o,l]=c.useState(!1),a=c.useCallback(async p=>{if(!(!p||o)){l(!0);try{i(await ub(n,p))}catch(w){console.error("Failed to switch GitHub account:",w)}finally{l(!1)}}},[n,o,i]);if(!r?.connected)return null;const u=r.user?.login??null,d=r.user?.avatarUrl??null,h=r.accounts??[],f=u?e("header.github.connectedWithLogin",{login:u}):e("header.github.connected"),g=d?s.jsx("img",{src:d,alt:u?e("header.github.avatarWithLogin",{login:u}):e("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(E,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"});return h.length<=1?s.jsx("div",{className:Re(Ll,t),title:f,children:g}):s.jsxs(Xs,{children:[s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button",className:Re(Ll,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:f,disabled:o,children:g})}),s.jsxs(Ys,{align:"end",className:"w-64",children:[s.jsx(bo,{className:"typography-ui-header font-semibold text-foreground",children:e("header.github.accountsTitle")}),s.jsx(Es,{}),h.map(p=>{const w=p.user,v=!!p.current,x=p.source==="gh-cli"?e("header.github.accountSource.cli"):e("header.github.accountSource.oauth");return s.jsxs(Wt,{className:"gap-2",disabled:o,onSelect:()=>{v||a(p.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(E,{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:x})]}):null]}),v?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]},p.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",Mu=t=>/^application\/(?:[\w.+-]+\+)?json\b/i.test(t.headers.get("content-type")??""),Ou=()=>new ni("This OpenChamber server has no walkthrough API",{code:"server-unsupported"}),mb=t=>!Mu(t)&&(t.ok||t.status===404),_a=async(t,e)=>{if(mb(t))throw Ou();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})},Bu=async t=>{if(!Mu(t))throw Ou();try{return await t.json()}catch{throw new ni("The server returned a malformed walkthrough response")}};async function fb(t,e,n={}){const r=await cs(ri,{query:{directory:t,source:JSON.stringify(e),...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}},signal:n.signal});return r.ok?Bu(r):_a(r,"Failed to load walkthrough")}async function hb(t,e,n={}){const r=await cs(`${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?Bu(r):_a(r,"Failed to generate walkthrough")}async function pb(t,e){const n=await cs(`${ri}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e})});n.ok||await _a(n,"Failed to cancel walkthrough generation")}async function gb(t,e,n){const r=await cs(`${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 Cr={status:"idle",stage:null,result:null,readiness:null,error:null},xb=t=>t.kind==="working-tree"?`working-tree:${t.scope}`:t.kind==="branch"?`branch:${t.baseRef}...${t.headRef}`:`pr:${t.number}`,Tn=(t,e)=>`${xs()}\0${t}\0${xb(e)}`,Wl=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"},nn=new Map,Nr=new Map,bb=1e3,yb=tr()(pu((t,e)=>({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{},selectLanguage:(n,r,i)=>{const o=Tn(n,r);t(l=>{const a={...l.selectedLanguage};return i?a[o]=i:delete a[o],{selectedLanguage:a}})},getSelectedLanguage:(n,r)=>e().selectedLanguage[Tn(n,r)],selectModel:(n,r,i)=>{const o=Tn(n,r);t(l=>{const a={...l.selectedModel};return i?a[o]=i:delete a[o],{selectedModel:a}})},getSelectedModel:(n,r)=>e().selectedModel[Tn(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[Tn(n,r)]??Cr,load:async(n,r,i={})=>{if(!n)return;const o=Tn(n,r);if(e().entries[o]?.status==="generating")return;nn.get(o)?.abort();const a=new AbortController;nn.set(o,a),t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Cr,status:"loading",error:null}}}));try{const u=await fb(n,r,{model:e().selectedModel[o],language:i.language,signal:a.signal});if(a.signal.aborted)return;t(d=>({entries:{...d.entries,[o]:{status:"ready",stage:null,result:u,readiness:u.readiness??null,error:null}}})),u.generating&&e().generate(n,r,{language:i.language})}catch(u){if(a.signal.aborted)return;t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Cr,status:"error",stage:null,error:Wl(u)}}}))}finally{nn.get(o)===a&&nn.delete(o)}},generate:async(n,r,i={})=>{if(!n)return;const o=Tn(n,r);nn.get(o)?.abort();const l=new AbortController;nn.set(o,l),t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Cr,status:"generating",stage:"collecting",error:null}}}));const a=()=>{const u=Nr.get(o);u!==void 0&&(clearInterval(u),Nr.delete(o))};a(),Nr.set(o,setInterval(()=>{gb(n,r).then(u=>{!u||l.signal.aborted||t(d=>{const h=d.entries[o];return!h||h.status!=="generating"||h.stage===u?d:{entries:{...d.entries,[o]:{...h,stage:u}}}})}).catch(()=>{})},bb));try{const u=await hb(n,r,{force:i.force,model:e().selectedModel[o],language:i.language,signal:l.signal});if(l.signal.aborted)return;t(d=>({entries:{...d.entries,[o]:{status:"ready",stage:null,result:u,readiness:d.entries[o]?.readiness??null,error:null}}}))}catch(u){if(l.signal.aborted)return;t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Cr,status:"error",stage:null,error:Wl(u)}}}))}finally{a(),nn.get(o)===l&&nn.delete(o)}},cancel:(n,r)=>{const i=Tn(n,r);pb(n,r).catch(()=>{}),nn.get(i)?.abort(),nn.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 nn.values())n.abort();nn.clear();for(const n of Nr.values())clearInterval(n);Nr.clear(),t({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{}})}}),{name:"walkthrough-store"})),wb="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)]",Sb=3e4,zl=20,Fu=(t,e)=>JSON.stringify([xs(),t,e]),vb=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}},Vl=()=>({result:null,hasCheckDetails:!1,fetchedAt:0,isLoading:!1,error:null}),so=new Map,jb=t=>{const e=Object.entries(t);return e.length<=zl?t:Object.fromEntries(e.sort(([,n],[,r])=>r.fetchedAt-n.fetchedAt).slice(0,zl))},Ul=tr()((t,e)=>({entries:{},ensure:async(n,r,i,o)=>{const l=Fu(r,i),a=o?.includeCheckDetails??!1,u=e().entries[l],d=u&&u.result&&Date.now()-u.fetchedAt<Sb&&(u.hasCheckDetails||!a);if(!o?.force&&d)return u.result;const h=`${l}::${a?"details":"plain"}`,g=so.get(`${l}::details`)??(a?null:so.get(h));if(g&&!o?.force)return g;const p=(async()=>{t(w=>({entries:{...w.entries,[l]:{...w.entries[l]??Vl(),isLoading:!0,error:null}}}));try{const w=await n.prContext(r,i,{includeDiff:!1,includeCheckDetails:a,sourceRepo:o?.sourceRepo??null});return t(v=>({entries:jb({...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(x=>({entries:{...x.entries,[l]:{...x.entries[l]??Vl(),isLoading:!1,error:v}}})),null}finally{so.delete(h)}})();return so.set(h,p),p},invalidate:(n,r)=>{t(i=>{const o={};for(const[l,a]of Object.entries(i.entries)){const u=vb(l);u&&u.directory===n&&(r==null||u.number===r)||(o[l]=a)}return{entries:o}})}})),kb=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}:{}}},Cb=35e3,mi=(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`},fi=t=>{const e=typeof t=="string"?t.toLowerCase():"";return!!e&&!["success","neutral","skipped"].includes(e)},Kl=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"}},Nb=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"},Ab=[2e3,5e3],Pb=600,Hl=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),Rn=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):""},Db=(t,e)=>{const n=Rn(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},Tb=(t,e)=>`${t}::${e}`,La=t=>{const e=String(t||"").trim();if(!e)return"";const n=e.indexOf("/");return n<=0?"":e.slice(0,n).trim()},hi=(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=La(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)},Ib=t=>t.startsWith("pr-"),Rb=(t,e)=>{const n=La(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=>!Ib(l.name)).forEach(l=>o(l)),t.forEach(l=>o(l)),i},Ar=new Map,no=Yo;function Eb(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 u=await e.repoUpstream(t);if(a||!u?.isFork||!u.upstream||(r(u.upstream),!e.repoBranches))return;try{const d=await e.repoBranches(u.upstream.owner,u.upstream.repo);a||o(d)}catch{}}catch{}})(),()=>{a=!0}},[t,e]),{detectedUpstream:n,upstreamBranches:i}}const Mb=({directory:t,branch:e,baseBranch:n,trackingBranch:r,remotes:i=[],remoteBranches:o=[],onGeneratedDescription:l})=>{const{t:a}=pt(),u=Te(J=>J.timeFormatPreference),{github:d}=Dn(),h=An(J=>J.status),f=An(J=>J.hasChecked),g=Te(J=>J.setSettingsDialogOpen),p=Te(J=>J.setSettingsPage),w=Qe(J=>J.currentSessionId),v=Qe(J=>!!J.newSessionDraft?.open),{isMobile:x,hasTouchInput:m,screenWidth:b}=Ln(),y=Te(J=>J.openContextSurface),S=yb(J=>J.requestSource),N=!x&&b>=768&&!Pn(),C=c.useCallback(()=>{p("integrations"),g(!0)},[g,p]),k=c.useMemo(()=>Tb(t,e),[t,e]),A=c.useMemo(()=>Ar.get(k)??null,[k]),P=Ks(J=>J.ensureEntry),D=Ks(J=>J.setParams),M=Ks(J=>J.startWatching),$=Ks(J=>J.stopWatching),R=Ks(J=>J.refresh),K=Ks(J=>J.updateStatus),[L,O]=c.useState(()=>A?.title??Hl(e)),[I,j]=c.useState(()=>A?.body??""),[T,F]=c.useState(()=>A?.draft??!1),[U,H]=c.useState(()=>A?.additionalContext??""),[Y,me]=c.useState(()=>{const J=typeof A?.targetBaseBranch=="string"?Rn(A.targetBaseBranch):"";return J||Rn(n)}),[Z,re]=c.useState("squash"),[se,fe]=c.useState(!1),[_,le]=c.useState(!1),[ee,ue]=c.useState(!1),[W,ne]=c.useState(!1),[pe,xe]=c.useState(!1),[Ce,Me]=c.useState(!1),[ve,Ie]=c.useState(null),[ye,q]=c.useState(""),[De,ke]=c.useState(""),[te,he]=c.useState(!1),[ae,Q]=c.useState(!1),[z,G]=c.useState(()=>hi(i,{selectedRemoteName:A?.selectedRemoteName,trackingBranch:r})),[ie,Oe]=c.useState(!1),{detectedUpstream:Fe,upstreamBranches:Se}=Eb(t,d);c.useEffect(()=>{Oe(!1)},[t]);const oe=i.some(J=>J.name==="upstream"),Ne=!!(t&&e&&n&&(e!==n||(oe||Fe!==null))),B=c.useMemo(()=>Jo(t,e,z?.name??null),[t,e,z?.name]),ce=Ks(J=>J.entries[B]),be=ce?.isLoading??!1,ge=ce?.status??null,_e=ce?.error??null,tt=ce?.isInitialStatusResolved??!1,Ue=c.useMemo(()=>{const J=ie?null:z?.name?.trim()||null,We=new Set;for(const Je of o){const mt=Db(Je,J);!mt||mt==="HEAD"||We.add(mt)}if(ie)for(const Je of Se)Je&&Je!=="HEAD"&&We.add(Je);const V=Rn(n);V&&V!=="HEAD"&&We.add(V);const Le=Rn(Y);return Le&&Le!=="HEAD"&&We.add(Le),Array.from(We).sort((Je,mt)=>Je.localeCompare(mt))},[n,o,z?.name,Y,Se,ie]);c.useEffect(()=>{if(i.length===0){z&&G(null);return}(!z||!i.some(J=>J.name===z.name))&&G(hi(i,{selectedRemoteName:A?.selectedRemoteName,trackingBranch:r}))},[A?.selectedRemoteName,i,z,r]),c.useEffect(()=>{const J=Rn(n);if(!Y&&J){me(J);return}if(Ue.length!==0&&!Ue.includes(Y)){const We=Ue.includes(J)?J:Ue[0];We&&me(We)}},[Ue,n,Y]);const[de,X]=c.useState(()=>A?.activeSegment??"overview"),[we,ze]=c.useState(new Set),[Ve,He]=c.useState(new Set),$e=c.useRef(new Set),qe=c.useRef(null),at=c.useRef(!1),gt=c.useRef(new Set),Pt=c.useRef([]);c.useEffect(()=>{Fe&&!oe&&Oe(!0)},[Fe,oe]),c.useEffect(()=>{ie&&Fe?.defaultBranch&&me(Fe.defaultBranch)},[ie,Fe?.defaultBranch]);const Ge=ge?.pr??null,It=Ge?.state==="merged"||Ge?.state==="closed",kt=It?null:Ge,Mt=kt?Fu(t,kt.number):null,Tt=Ul(J=>Mt?J.entries[Mt]:void 0),wt=Ul(J=>J.ensure),St=Tt?.result??null,vt=Tt?.isLoading??!1,ht=c.useCallback(J=>{X(J);const We=Ar.get(k);We&&Ar.set(k,{...We,activeSegment:J})},[k]);c.useEffect(()=>{!kt||!d?.prContext||de==="overview"||wt(d,t,kt.number,{includeCheckDetails:de==="checks",sourceRepo:ge?.repo??null})},[de,t,wt,d,kt,ge?.repo]);const Ze=ge?.checks??null,je=(Ze?.pending??0)>0,nt=St?.checkRuns??null,lt=St?.fetchedAt;c.useEffect(()=>{if(!nt||nt.length===0)return;const J=kb(nt);K(B,We=>{if(!We?.pr||typeof lt=="number"&&typeof We.fetchedAt=="number"&<<We.fetchedAt)return We;const V=We.checks;return V&&V.state===J.state&&V.total===J.total&&V.success===J.success&&V.failure===J.failure&&V.pending===J.pending&&V.inProgress===J.inProgress&&V.queued===J.queued&&V.startedAt===J.startedAt?We:{...We,checks:J,...typeof lt=="number"?{fetchedAt:lt}:{}}})},[nt,lt,B,K]),c.useEffect(()=>{if(de!=="checks"||!je||!Ge||!d?.prContext)return;const J=window.setInterval(()=>{wt(d,t,Ge.number,{includeCheckDetails:!0,sourceRepo:ge?.repo??null,force:!0})},Cb);return()=>window.clearInterval(J)},[de,je,t,wt,d,Ge,ge?.repo]);const[Ct,Ye]=c.useState(()=>Date.now());c.useEffect(()=>{if(!je)return;Ye(Date.now());const J=window.setInterval(()=>Ye(Date.now()),3e4);return()=>window.clearInterval(J)},[je]);const it=Ge?`${t}#${Ge.number}`:null,Nt=!!(it&&ve===it);c.useEffect(()=>{if(!d?.prContext||!Ge||typeof Ge.body=="string"&&Ge.body.length>0)return;const J=`${t}#${Ge.number}`;if($e.current.has(J))return;$e.current.add(J),Ie(J);let We=!1;return wt(d,t,Ge.number,{sourceRepo:ge?.repo??null}).then(V=>{if(We)return;const Le=V?.pr;Le&&K(B,Je=>!Je?.pr||Je.pr.number!==Ge.number?Je:{...Je,pr:{...Je.pr,body:Le.body||""}})}).catch(()=>{}).finally(()=>{We||Ie(V=>V===J?null:V)}),()=>{We=!0}},[t,wt,d,Ge,B,ge?.repo,K]),c.useEffect(()=>{if(!Ge){Me(!1),q(""),ke(""),qe.current=null;return}const J=qe.current!==null&&qe.current!==Ge.number;J&&Me(!1),(!Ce||J)&&(q(Ge.title||""),ke(Ge.body||"")),qe.current=Ge.number},[Ce,Ge]);const Dt=c.useCallback(J=>{if(!J)return"";const We=Date.parse(J);return Number.isFinite(We)?Nd(We,u,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):J},[u]),Rt=c.useMemo(()=>{const J=h?.user?.login;return typeof J=="string"?J.trim():""},[h]),Vt=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)]",[]),Qt=c.useCallback(J=>{const We=Rt.toLowerCase(),V=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return J.replace(V,(Le,Je,mt)=>{const ft=`@${mt}`,Ot=mt.toLowerCase();return`${Je}[${ft}](https://github.com/${Ot}${We&&Ot===We?"?oc-self-mention=1":""})`})},[Rt]),Ut=c.useMemo(()=>{const J=(St?.issueComments??[]).map(Le=>({id:`issue-${Le.id}`,body:Le.body||"",authorName:Le.author?.name||Le.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:Le.author?.login||null,avatarUrl:Le.author?.avatarUrl||null,createdAt:Le.createdAt,context:a("gitView.pr.comments.generalContext"),path:null,line:null})),We=(St?.reviewComments??[]).map(Le=>({id:`review-${Le.id}`,body:Le.body||"",authorName:Le.author?.name||Le.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:Le.author?.login||null,avatarUrl:Le.author?.avatarUrl||null,createdAt:Le.createdAt,context:a("gitView.pr.comments.reviewContext"),path:Le.path||null,line:Le.line??null})),V=[...J,...We];return V.sort((Le,Je)=>{const mt=Le.createdAt?Date.parse(Le.createdAt):0,ft=Je.createdAt?Date.parse(Je.createdAt):0,Ot=Number.isFinite(mt)?mt:0,ss=Number.isFinite(ft)?ft:0;return Ot-ss}),V},[St,a]),Ft=c.useCallback(()=>{const J=w??(v?"draft":null);return J?{directory:t,sessionKey:J}:(Be.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null)},[w,t,v,a]),Yt=c.useCallback((J,We)=>{const V=We.authorLogin?`@${We.authorLogin}`:We.authorName,Le=We.path?` · ${We.path}${We.line?`:${We.line}`:""}`:"";Di.getState().addDraft(J,{source:"pr-comment",fileLabel:`PR #${Ge?.number??""} ${V}${Le}`,startLine:We.line??0,endLine:We.line??0,code:We.body,language:"markdown",text:""})},[Ge?.number]),$t=c.useCallback((J,We)=>{const V=J.status||"unknown",Le=J.conclusion??void 0,Je=Le?`${V} / ${Le}`:V,mt=J.app?.name||J.app?.slug;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:We?.hideHeader?"flex items-start justify-end gap-3":"flex items-start justify-between gap-3",children:[We?.hideHeader?null:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:J.name}),s.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:mt?`${mt} · ${Je}`:Je})]}),J.detailsUrl?s.jsx(ot,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:s.jsxs("a",{href:J.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(E,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),J.output?.title?s.jsx("div",{className:"typography-micro text-foreground",children:J.output.title}):null,J.output?.summary?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:J.output.summary}):null,J.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:J.output.text}):null,Array.isArray(J.annotations)&&J.annotations.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",J.annotations.length>20?` (showing 20/${J.annotations.length})`:""]}),s.jsx("div",{className:"space-y-1",children:J.annotations.slice(0,20).map((ft,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:[ft.title||ft.level||"Issue",ft.path?` · ${ft.path}`:"",typeof ft.startLine=="number"?`:${ft.startLine}`:"",typeof ft.endLine=="number"&&ft.endLine!==ft.startLine?`-${ft.endLine}`:""]}),s.jsx("div",{className:"typography-micro text-foreground whitespace-pre-wrap break-words mt-1",children:ft.message}),ft.rawDetails?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words mt-1",children:ft.rawDetails}):null]},`${ft.path||"file"}:${ft.startLine||Ot}:${Ot}`))})]}):null,J.job?.steps&&J.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:J.job.steps.map((ft,Ot)=>{const ss=(ft.conclusion||"").toLowerCase(),Ht=ss&&!["success","neutral","skipped"].includes(ss),en=`${J.id??"run"}:${J.job?.jobId??"job"}:${ft.number??Ot}:${ft.name}`,yn=we.has(en);return Ht?s.jsxs(Fi,{open:yn,children:[s.jsxs("button",{type:"button",onClick:()=>{ze(ii=>{const sr=new Set(ii);return sr.has(en)?sr.delete(en):sr.add(en),sr})},className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-left "+(Ht?"bg-destructive/10 text-destructive":"text-muted-foreground"),children:[yn?s.jsx(E,{name:"arrow-down-s",className:"size-4"}):s.jsx(E,{name:"arrow-right-s",className:"size-4"}),s.jsx("span",{className:"truncate",children:ft.name}),ft.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:ft.conclusion}):null]}),s.jsx(_i,{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 ft.number=="number"?s.jsxs("div",{children:[a("gitView.pr.checks.stepLabel"),": ",ft.number]}):null,ft.status?s.jsxs("div",{children:[a("gitView.pr.checks.statusLabel"),": ",ft.status]}):null,ft.conclusion?s.jsxs("div",{children:[a("gitView.pr.checks.conclusionLabel"),": ",ft.conclusion]}):null,ft.startedAt?s.jsxs("div",{children:[a("gitView.pr.checks.startedLabel"),": ",Dt(ft.startedAt)]}):null,ft.completedAt?s.jsxs("div",{children:[a("gitView.pr.checks.completedLabel"),": ",Dt(ft.completedAt)]}):null]})})]},en):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:ft.name}),ft.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:ft.conclusion}):null]},en)})})]}):null]})},[we,Dt,a]),[_t,Ee]=c.useState(!1),[Ke,et]=c.useState(!1),ct=c.useCallback(async()=>{if(!d?.prContext){Be.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!Ge)return;const J=Ft();if(J){Ee(!0);try{const We=await wt(d,t,Ge.number,{includeCheckDetails:!0,sourceRepo:ge?.repo??null});if(!We){Be.error(a("gitView.pr.toast.loadChecksFailed"));return}const Le=(We.checkRuns??[]).filter(mt=>fi(mt.conclusion));if(Le.length===0){Be.message(a("gitView.pr.toast.noFailedChecks"));return}const Je=Di.getState();for(const mt of Le){const ft=(mt.annotations??[]).map(Ht=>[[Ht.level,Ht.title].filter(Boolean).join(" "),Ht.path?`${Ht.path}${typeof Ht.startLine=="number"?`:${Ht.startLine}`:""}`:null,Ht.message,Ht.rawDetails].filter(Boolean).join(`
|
|
38
|
-
`)),Ot=(mt.job?.steps??[]).filter(Ht=>fi(Ht.conclusion)).map(Ht=>`step ${Ht.number??"?"}: ${Ht.name} → ${Ht.conclusion}`),ss=[`check: ${mt.job?.workflowName?`${mt.job.workflowName} / ${mt.name}`:mt.name}`,`status: ${mt.status??"unknown"} / ${mt.conclusion??"unknown"}`,mt.detailsUrl?`url: ${mt.detailsUrl}`:null,mt.output?.title?`title: ${mt.output.title}`:null,mt.output?.summary?`summary:
|
|
39
|
-
${mt.output.summary}`:null,Ot.length>0?`failed steps:
|
|
40
|
-
${Ot.join(`
|
|
41
|
-
`)}`:null,ft.length>0?`annotations:
|
|
42
|
-
${ft.join(`
|
|
43
|
-
---
|
|
44
|
-
`)}`:null].filter(Boolean).join(`
|
|
45
|
-
|
|
46
|
-
`);Je.addDraft(J,{source:"pr-check",fileLabel:`PR #${Ge.number} · ${mt.name}`,startLine:0,endLine:0,code:ss,language:"text",text:""})}}catch(We){const V=We instanceof Error?We.message:String(We);Be.error(a("gitView.pr.toast.loadChecksFailed"),{description:V})}finally{Ee(!1)}}},[t,wt,d,Ge,Ft,ge?.repo,a]),ut=c.useCallback(async()=>{if(!d?.prContext){Be.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!Ge)return;const J=Ft();if(J){et(!0);try{if(!await wt(d,t,Ge.number,{sourceRepo:ge?.repo??null})){Be.error(a("gitView.pr.toast.loadPrCommentsFailed"));return}if(Ut.length===0){Be.message(a("gitView.pr.toast.noPrComments"));return}for(const V of Ut)Yt(J,V)}catch(We){const V=We instanceof Error?We.message:String(We);Be.error(a("gitView.pr.toast.loadPrCommentsFailed"),{description:V})}finally{et(!1)}}},[Yt,t,wt,d,Ge,Ft,ge?.repo,a,Ut]),jt=c.useCallback(async J=>{const We=Ft();We&&Yt(We,J)},[Yt,Ft]),st=c.useCallback(async J=>{await R(B,J)},[B,R]),[Lt,Xt]=c.useState(!1),ds=c.useRef(!0);c.useEffect(()=>(ds.current=!0,()=>{ds.current=!1}),[]);const js=c.useCallback(async()=>{if(Lt)return;Xt(!0);const J=Date.now();try{await st({force:!0})}finally{const We=Pb-(Date.now()-J);We>0&&await new Promise(V=>window.setTimeout(V,We)),ds.current&&Xt(!1)}},[Lt,st]),ns=c.useCallback(()=>{Pt.current.forEach(J=>{window.clearTimeout(J)}),Pt.current=Ab.map(J=>window.setTimeout(()=>{st({force:!0,silent:!0,markInitialResolved:!0})},J))},[st]);c.useEffect(()=>{if(!d?.prStatus||!Ne||i.length<=1||at.current||ge?.pr)return;const J=`${k}::${z?.name??""}`;if(gt.current.has(J))return;gt.current.add(J);const We=Rb(i,r).filter(Je=>Je.name!==z?.name);if(We.length===0)return;let V=!1;return(async()=>{for(const Je of We){if(V)return;try{if(!(await d.prStatus(t,e,Je.name))?.pr)continue;if(V)return;G(ft=>ft?.name===Je.name?ft:Je);return}catch{}}})(),()=>{V=!0}},[e,Ne,t,d,i,z?.name,k,ge?.pr,r]),c.useEffect(()=>{P(B),D(B,{directory:t,branch:e,remoteName:z?.name??null,canShow:Ne,github:d,githubAuthChecked:f,githubConnected:h?.connected??null})},[e,Ne,t,P,d,f,h?.connected,B,z?.name,D]),c.useEffect(()=>(M(B),()=>{$(B)}),[B,M,$]),c.useEffect(()=>{const J=Ar.get(k)??null;O(J?.title??Hl(e)),j(J?.body??""),F(J?.draft??!1),me(J?.targetBaseBranch?Rn(J.targetBaseBranch):Rn(n));const We=hi(i,{selectedRemoteName:J?.selectedRemoteName,trackingBranch:r});G(V=>V?.name===We?.name?V:We)},[n,e,i,k,r]),c.useEffect(()=>{st({markInitialResolved:!0})},[B,st]),c.useEffect(()=>{!Ne||!z?.name||st({force:!0,silent:!0,markInitialResolved:!0})},[Ne,st,z?.name]),c.useEffect(()=>{const J=ge?.resolvedRemoteName?.trim();if(!J||at.current)return;const We=i.find(V=>V.name===J);We&&G(V=>V?.name===We.name?V:We)},[i,ge?.resolvedRemoteName]),c.useEffect(()=>{const J=()=>{const V=Ks.getState().entries[B]?.lastRefreshAt??0;Date.now()-V>6e4&&st({force:!0,silent:!0})},We=()=>{document.visibilityState==="visible"&&J()};return window.addEventListener("focus",J),document.addEventListener("visibilitychange",We),()=>{window.removeEventListener("focus",J),document.removeEventListener("visibilitychange",We)}},[B,st]),c.useEffect(()=>{f&&h?.connected===!1&&st({force:!0,silent:!0,markInitialResolved:!0})},[f,h,st]),c.useEffect(()=>{!t||!e||Ar.set(k,{title:L,body:I,draft:T,additionalContext:U,targetBaseBranch:Y,selectedRemoteName:z?.name,activeSegment:de})},[k,L,I,T,U,Y,z?.name,t,e,de]),c.useEffect(()=>{const J=Pt.current;return()=>{J.forEach(We=>{window.clearTimeout(We)}),Pt.current=[]}},[]);const Js=c.useCallback(async()=>{if(!se&&t){fe(!0);try{const We={base:ie&&Fe?.defaultBranchSha?Fe.defaultBranchSha:Y,head:e};U&&(We.context=U);const V=await Lf(t,We);V.title?.trim()&&O(V.title.trim()),V.body?.trim()&&j(V.body.trim()),l?.()}catch(J){const We=J instanceof Error?J.message:String(J);Be.error(a("gitView.pr.toast.generateDescriptionFailed"),{description:We})}finally{fe(!1)}}},[U,e,Fe?.defaultBranchSha,t,se,l,Y,a,ie]),rs=c.useCallback(async()=>{if(!d?.prCreate){Be.error(a("gitView.pr.toast.githubApiUnavailable"));return}const J=L.trim();if(!J){Be.error(a("gitView.pr.toast.titleRequired"));return}const We=Y.trim();if(!We){Be.error(a("gitView.pr.toast.baseBranchRequired"));return}if(!ie&&We===e){Be.error(a("gitView.pr.toast.baseMustDifferFromHead"));return}le(!0);try{const V=La(r),Le=ie&&Fe,Je=await d.prCreate({directory:t,title:J,head:e,base:We,...I.trim()?{body:I}:{},draft:T,...Le?{targetRepo:{owner:Fe.owner,repo:Fe.repo},headRemote:"origin"}:{...z?{remote:z.name}:{},...V&&V!==z?.name?{headRemote:V}:{}}});Be.success(a("gitView.pr.toast.prCreated")),K(B,mt=>mt&&{...mt,pr:Je}),await st({force:!0}),ns()}catch(V){const Le=V instanceof Error?V.message:String(V);Be.error(a("gitView.pr.toast.createPrFailed"),{description:Le})}finally{le(!1)}},[I,e,Fe,t,T,d,B,st,ns,z,Y,L,r,K,ie,a]),As=c.useCallback(async J=>{if(!d?.prMerge){Be.error(a("gitView.pr.toast.githubApiUnavailable"));return}ne(!0);try{const We=await d.prMerge({directory:t,number:J.number,method:Z});We.merged?Be.success(a("gitView.pr.toast.prMerged")):Be.message(a("gitView.pr.toast.prNotMerged"),{description:We.message||a("gitView.pr.notMergeable")}),await st({force:!0}),ns()}catch(We){const V=We instanceof Error?We.message:String(We);Be.error(a("gitView.pr.toast.mergeFailed"),{description:V}),J.url&&no(J.url)}finally{ne(!1)}},[t,d,Z,st,ns,a]),$s=c.useCallback(async J=>{if(!d?.prReady){Be.error(a("gitView.pr.toast.githubApiUnavailable"));return}xe(!0);try{await d.prReady({directory:t,number:J.number}),Be.success(a("gitView.pr.toast.markedReady")),await st({force:!0}),ns()}catch(We){const V=We instanceof Error?We.message:String(We);Be.error(a("gitView.pr.toast.markReadyFailed"),{description:V}),J.url&&no(J.url)}finally{xe(!1)}},[t,d,st,ns,a]),Zs=c.useCallback(async J=>{if(!d?.prUpdate){Be.error(a("gitView.pr.toast.githubApiUnavailable"));return}const We=ye.trim();if(!We){Be.error(a("gitView.pr.toast.titleRequired"));return}ue(!0);try{const V=await d.prUpdate({directory:t,number:J.number,title:We,body:De});K(B,Le=>Le&&{...Le,pr:{...Le.pr??J,...V}}),Me(!1),Be.success(a("gitView.pr.toast.prUpdated")),await st({force:!0}),ns()}catch(V){const Le=V instanceof Error?V.message:String(V);Be.error(a("gitView.pr.toast.updatePrFailed"),{description:Le})}finally{ue(!1)}},[t,De,ye,d,B,st,ns,K,a]);if(!Ne)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($l,{})]}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pullRequest.availableOnFeatureBranches")})]})});const ln=ge?.repo?.url||null,bs=ie&&Fe?.url?Fe.url:ln,ks=!!ge?.canMerge,Ws=!!ge?.connected,cn=f&&ge?.connected===!1,us=Nb(ge),zs=us?`var(--pr-${us})`:"var(--status-info)",At=us==="draft"?"git-pr-draft":us==="merged"?"git-merge":us==="closed"?"git-close-pull-request":"git-pull-request",Bt=Ge?[`${Ge.state}${Ge.draft?" (draft)":""}`,Ge.mergeable===!1?a("gitView.pr.notMergeable"):null,Ge.state==="open"&&typeof Ge.mergeableState=="string"&&Ge.mergeableState&&Ge.mergeableState!=="unknown"?Ge.mergeableState:null].filter(Boolean).join(" · "):"",Jt=Ze?Ze.total>0?`${Ze.success}/${Ze.total} ${a("gitView.pr.checks.label")}`:`${Ze.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:[Ge?s.jsxs(ot,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{no(Ge.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:[s.jsx(E,{name:At,className:"size-4 shrink-0",style:{color:zs}}),a("gitView.pr.actions.openOnGitHub")]}):s.jsx(E,{name:At,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")}),Ge?s.jsxs("span",{className:"typography-meta text-muted-foreground truncate",children:["#",Ge.number]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[Ge&&N?s.jsxs(ot,{variant:"outline",size:"sm",className:Re("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",wb),onClick:()=>{S(t,{kind:"pr",number:Ge.number}),y(t,"walkthrough")},"aria-label":a("walkthrough.action.open"),children:[s.jsx(E,{name:"route",className:"size-4"}),s.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:a("walkthrough.action.open")})]}):null,s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx(ot,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:be||Lt,onClick:()=>{js()},"aria-label":a("gitView.pr.actions.refreshAria"),children:be||Lt?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}):s.jsx(E,{name:"refresh",className:"size-4 text-muted-foreground"})})}),s.jsx(yt,{children:s.jsx("p",{children:a("gitView.pr.actions.refresh")})})]}),s.jsx($l,{className:"h-7 w-7"})]})]}),Ge?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:zs},children:Bt}),Ze?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${Kl(Ze.state)}`}),Jt]}):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:[ks&&Ge.draft&&Ge.state==="open"?s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx(ot,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>$s(Ge),disabled:pe||W||ee||Ce,"aria-label":a("gitView.pr.actions.markReadyAria"),children:pe?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"checkbox-circle",className:"size-4"})})}),s.jsx(yt,{children:s.jsx("p",{children:a("gitView.pr.actions.markReady")})})]}):null,ks?s.jsxs(s.Fragment,{children:[s.jsxs(Ms,{value:Z,onValueChange:J=>re(J),disabled:W||Ge.state!=="open",children:[s.jsx(Os,{size:"sm",className:"h-7 w-auto min-w-0",children:s.jsx(Ns,{})}),s.jsxs(Bs,{children:[s.jsx(ts,{value:"squash",children:a("gitView.pr.mergeMethod.squash")}),s.jsx(ts,{value:"merge",children:a("gitView.pr.mergeMethod.merge")}),s.jsx(ts,{value:"rebase",children:a("gitView.pr.mergeMethod.rebase")})]})]}),s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx(ot,{size:"sm",className:"h-7 w-7 px-0",onClick:()=>As(Ge),disabled:W||pe||Ge.state!=="open"||Ge.draft||ee||Ce,"aria-label":a("gitView.pr.actions.mergePrAria"),children:W?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"git-merge",className:"size-4"})})}),s.jsx(yt,{children:s.jsx("p",{children:a("gitView.pr.actions.mergePr")})})]})]}):null]})]}):null]}),s.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[cn?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta text-muted-foreground",children:a("gitView.pr.githubNotConnected")}),s.jsx(ot,{variant:"outline",size:"sm",onClick:C,className:"w-fit",children:a("gitView.pr.actions.openSettings")})]}):null,_e?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:_e}),bs?s.jsx(ot,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:s.jsxs("a",{href:bs,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(E,{name:"external-link",className:"size-4"}),"Open Repo"]})}):null]}):null,!Ge&&!tt&&!_e&&!cn?s.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.pr.checkingStatus")]}):Ge&&!It?s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx("div",{className:"h-8 min-w-0",children:s.jsx(tu,{className:"h-full",items:[{id:"overview",label:a("gitView.pr.segment.overview")},{id:"checks",label:Ze&&Ze.total>0?`${a("gitView.pr.segment.checks")} ${Ze.success}/${Ze.total}`:a("gitView.pr.segment.checks"),icon:Ze?s.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${Kl(Ze.state)}`}):void 0},{id:"comments",label:St?`${a("gitView.pr.segment.comments")} ${(St.issueComments?.length??0)+(St.reviewComments?.length??0)}`:a("gitView.pr.segment.comments")}],activeId:de,onSelect:J=>ht(J),layoutMode:"fit",variant:"active-pill",activePillButtonClassName:"h-7"})}),de==="overview"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[ks&&Ge.draft?s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.draftMustBeReady")}):null,ks?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:Ce?s.jsx(kn,{value:ye,onChange:J=>q(J.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:Ge.title})}),Ge.state==="open"?s.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:Ce?s.jsxs(s.Fragment,{children:[s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx(ot,{variant:"outline",size:"sm",className:"h-9 w-9 px-0",onClick:()=>{Me(!1),q(Ge.title||""),ke(Ge.body||"")},disabled:ee,"aria-label":a("gitView.pr.actions.cancelEditingAria"),children:s.jsx(E,{name:"close",className:"size-4"})})}),s.jsx(yt,{children:s.jsx("p",{children:a("gitView.pr.actions.cancelEditing")})})]}),s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx(ot,{size:"sm",className:"h-9 w-9 px-0",onClick:()=>Zs(Ge),disabled:ee||!ye.trim(),"aria-label":a("gitView.pr.actions.savePrAria"),children:ee?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"check",className:"size-4"})})}),s.jsx(yt,{children:s.jsx("p",{children:a("gitView.pr.actions.savePr")})})]})]}):s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx(ot,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>Me(!0),"aria-label":a("gitView.pr.actions.editPrAria"),children:s.jsx(E,{name:"edit",className:"size-4"})})}),s.jsx(yt,{children:s.jsx("p",{children:a("gitView.pr.actions.editPr")})})]})}):null]}),Ce?s.jsx(lr,{value:De,onChange:J=>ke(J.target.value),outerClassName:"min-h-[60vh]",placeholder:a("gitView.pr.placeholder.description"),autoCorrect:m?"on":"off",autoCapitalize:m?"sentences":"off",spellCheck:m}):null,Ce?null:Ge.body?.trim()?s.jsx(il,{content:Ge.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(Nt?"gitView.pr.loadingDescription":"gitView.pr.noDescription")})]}):null,de==="checks"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[Ze&&Ze.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:[Ze.success>0?s.jsx("div",{className:"bg-[color:var(--status-success)]",style:{width:`${Ze.success/Ze.total*100}%`}}):null,Ze.failure>0?s.jsx("div",{className:"bg-[color:var(--status-error)]",style:{width:`${Ze.failure/Ze.total*100}%`}}):null,Ze.pending>0?s.jsx("div",{className:"bg-[color:var(--status-warning)]",style:{width:`${Ze.pending/Ze.total*100}%`}}):null]}),s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Ze.success,"/",Ze.total," ",a("gitView.pr.checks.label")]}),(Ze.inProgress??0)>0?s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-[var(--status-warning)]",children:[s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}),mi(Ze.startedAt,void 0,Ct)]}):null]}):null,Ze?.failure?s.jsxs(ot,{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:ct,disabled:_t,"aria-label":a("gitView.pr.actions.resolveFailedChecksAria"),children:[_t?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4"}),a("gitView.pr.actions.resolveFailedChecks")]}):null,(St?.checkRuns?.length??0)>0?s.jsx("div",{className:"flex flex-col gap-1.5",children:(St?.checkRuns??[]).map((J,We)=>{const V=`${J.id??"run"}:${J.name}:${We}`,Le=J.status==="in_progress",Je=J.status==="queued",mt=fi(J.conclusion),ft=Ve.has(V),Ot=!!(J.output?.title||J.output?.summary||J.output?.text||(J.annotations?.length??0)>0||(J.job?.steps?.length??0)>0||J.detailsUrl),ss=J.job?.workflowName,Ht=Le?mi(J.startedAt,void 0,Ct):mi(J.startedAt,J.completedAt);return s.jsxs("div",{className:Re("rounded-md border border-border/40",mt&&"border-[var(--status-error-border)]"),children:[s.jsxs("button",{type:"button",disabled:!Ot,onClick:()=>{He(en=>{const yn=new Set(en);return yn.has(V)?yn.delete(V):yn.add(V),yn})},className:"flex w-full items-center gap-2 px-2.5 py-2 text-left disabled:cursor-default",children:[Le?s.jsx(E,{name:"loader-4",className:"size-4 shrink-0 animate-spin text-[var(--status-warning)]"}):Je?s.jsx(E,{name:"time",className:"size-4 shrink-0 text-muted-foreground"}):mt?s.jsx(E,{name:"close-circle",className:"size-4 shrink-0 text-[var(--status-error)]"}):s.jsx(E,{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:ss&&ss!==J.name?`${ss} / ${J.name}`:J.name}),Ht?s.jsx("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:Ht}):null,Ot?s.jsx(E,{name:"arrow-down-s",className:Re("size-4 shrink-0 text-muted-foreground transition-transform",ft&&"rotate-180")}):null]}),ft&&Ot?s.jsx("div",{className:"min-w-0 overflow-hidden border-t border-border/40 p-2.5",children:$t(J,{hideHeader:!0})}):null]},V)})}):vt?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(E,{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,de==="comments"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[Ut.length>0?s.jsx("div",{className:"flex items-center justify-end",children:s.jsxs(ot,{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:ut,disabled:Ke,"aria-label":a("gitView.pr.actions.shareCommentsAria"),children:[Ke?s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.comments.addAll")]})}):null,Ut.length>0?s.jsx("div",{className:"relative pl-3",children:s.jsx("div",{children:Ut.map((J,We)=>{const V=(J.authorName||"?").charAt(0).toUpperCase(),Le=We===Ut.length-1;return s.jsxs("div",{className:"relative pl-10 pb-5 last:pb-0",children:[Le?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:J.avatarUrl?s.jsx("img",{src:J.avatarUrl,alt:J.authorName,className:"h-full w-full object-cover"}):s.jsx("span",{children:V})}),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:[J.authorName,J.authorLogin&&J.authorLogin!==J.authorName?` · @${J.authorLogin}`:""]}),J.createdAt?s.jsx("span",{className:"whitespace-nowrap",children:Dt(J.createdAt)}):null,s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsxs(ot,{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:()=>{jt(J)},"aria-label":a("gitView.pr.actions.sendCommentToAgentAria"),children:[s.jsx(E,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.actions.sendToAgent")]})}),s.jsx(yt,{children:s.jsx("p",{children:a("gitView.pr.actions.sendCommentToAgent")})})]})]}),s.jsxs("div",{className:"typography-micro text-muted-foreground",children:[J.context,J.path?` · ${J.path}`:"",J.line?`:${J.line}`:""]}),s.jsx(il,{content:Qt(J.body),className:["typography-markdown-body text-foreground break-words [&_a]:no-underline [&_a:hover]:no-underline",Vt].filter(Boolean).join(" "),enableFileReferences:!1})]})]},J.id)})})}):vt&&!St?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(E,{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:[Ge&&It?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(E,{name:Ge.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:zs}}),s.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:Ge.state==="merged"?a("gitView.pr.history.merged",{number:Ge.number,base:Ge.base||Y}):a("gitView.pr.history.closed",{number:Ge.number})}),s.jsx(ot,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{no(Ge.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:s.jsx(E,{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)"})," → ",Y," ",s.jsxs("span",{className:"opacity-60",children:["(",ie&&Fe?"upstream":"remote",")"]})]})]}),bs?s.jsx(ot,{variant:"outline",size:"sm",asChild:!0,children:s.jsxs("a",{href:bs,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(E,{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(kn,{value:L,onChange:J=>O(J.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")}),Ue.length>0?s.jsxs(Ms,{value:Y,onValueChange:me,children:[s.jsx(Os,{size:"lg",children:s.jsx(Ns,{placeholder:a("gitView.pr.placeholder.selectBaseBranch")})}),s.jsx(Bs,{children:Ue.map(J=>s.jsx(ts,{value:J,children:J},J))})]}):s.jsx(kn,{value:Y,onChange:J=>me(J.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(lr,{value:I,onChange:J=>j(J.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":T,onClick:()=>F(J=>!J),onKeyDown:J=>{(J.key===" "||J.key==="Enter")&&(J.preventDefault(),F(We=>!We))},children:[s.jsx(ur,{size:"sm",checked:T,onChange:J=>F(J),ariaLabel:a("gitView.pr.actions.toggleDraftAria")}),s.jsx("span",{className:"typography-ui-label text-foreground select-none",children:a("gitView.pr.field.draft")})]}),x?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(ot,{variant:"outline",size:"sm",onClick:()=>Q(!0),children:U.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),U.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(Fi,{open:te,onOpenChange:he,children:[s.jsxs(su,{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:te?a("gitView.pr.actions.hide"):U.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),s.jsx(_i,{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(lr,{value:U,onChange:J=>H(J.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(Zo,{open:ae,onClose:()=>Q(!1),title:a("gitView.pr.additionalContext.title"),footer:s.jsx(ot,{size:"sm",onClick:()=>Q(!1),className:"w-full",children:a("gitView.common.done")}),children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(lr,{value:U,onChange:J=>H(J.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(ot,{variant:"outline",size:"sm",onClick:Js,disabled:se||_,children:[se?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4 text-primary"}),a("gitView.commit.generate")]}),s.jsx("div",{className:"flex-1"}),s.jsxs(ot,{size:"sm",className:"min-w-[7.5rem] justify-center gap-2",onClick:rs,disabled:_||!Ws||!Y.trim()||!ie&&Y.trim()===e,children:[s.jsx("span",{className:"inline-flex size-4 items-center justify-center",children:_?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"git-pull-request",className:"size-4"})}),s.jsx("span",{children:a("gitView.pr.actions.createPr")})]})]})]})]})]})},Ob=t=>{const{remoteNames:e,localBranches:n,worktreeCreatedFromBranch:r,rootBranchHint:i,defaultBranch:o,headBranch:l}=t,a=typeof l=="string"?l.trim():"",u=p=>{if(!p)return"";let w=p.trim();if(!w||w==="HEAD")return"";if(n.includes(w))return w;w.startsWith("refs/heads/")&&(w=w.slice(11)),w.startsWith("heads/")&&(w=w.slice(6)),w.startsWith("remotes/")&&(w=w.slice(8));const v=w.indexOf("/");if(v>0){const x=w.slice(0,v);if(e.has(x)){const m=w.slice(v+1).trim();m&&(w=m)}}return w},d=p=>{const w=u(typeof p=="string"?p:"");return w&&w!==a?w:""},h=d(r);if(h)return h;const f=d(i);if(f)return f;const g=d(o);return g||(n.includes("main")?"main":n.includes("master")?"master":n.includes("develop")?"develop":"main")},o5=t=>{const{baseBranch:e,localBranches:n,remoteBranches:r}=t;return n.includes(e)?!0:r.some(i=>{const o=i.indexOf("/");return o>0&&i.slice(o+1)===e})},pi=t=>(t||"").replace(/\\/g,"/").replace(/\/+$/,""),ro=new Map,oo=new Map,In=t=>`${xs()}::${t}`,Bb=()=>{const t=Xe.c(115),{t:e}=pt(),{git:n}=Dn(),r=Yr(),{rootIsGitRepo:i,gitDirectory:o,nestedRepos:l}=$f(r??null),a=ja(o??null),u=Ad(o??null),d=Pd(o??null),{ensureAll:h,ensureNestedRepos:f,selectNestedRepo:g}=Bn(Zn(Fb)),p=Qe(_b),w=Qe(Lb),v=Qe($b),x=Qe(Wb);let m;t[0]!==r?(m=pi(r),t[0]=r,t[1]=m):m=t[1];const b=m;let y;if(t[2]!==x||t[3]!==b||t[4]!==v){e:{if(!b){y=void 0;break e}let z;if(t[6]!==x||t[7]!==b){let ie;t[9]!==b?(ie=Oe=>pi(Oe.path)===b,t[9]=b,t[10]=ie):ie=t[10],z=x.find(ie),t[6]=x,t[7]=b,t[8]=z}else z=t[8];const G=z;if(G){y=G;break e}for(const ie of v.values())if(pi(ie.path)===b){y=ie;break e}y=void 0}t[2]=x,t[3]=b,t[4]=v,t[5]=y}else y=t[5];const S=y;let N;t[11]!==p||t[12]!==S||t[13]!==w?.open||t[14]!==v?(N=()=>{if(p)return v.get(p)??S;if(w?.open)return S},t[11]=p,t[12]=S,t[13]=w?.open,t[14]=v,t[15]=N):N=t[15],w?.open;let C;t[16]!==N?(C=N(),t[16]=N,t[17]=C):C=t[17];const k=C;let A;t[18]!==p?(A=z=>p?z.getAttachment(p):void 0,t[18]=p,t[19]=A):A=t[19];const P=jd(A),D=P&&!P.degraded&&!P.legacy?P.worktreeRoot??void 0:void 0,M=cb(r,k,a?.current??void 0);let $,R;t[20]!==h||t[21]!==n||t[22]!==o?($=()=>{!o||!n||h(o,n)},R=[o,h,n],t[20]=h,t[21]=n,t[22]=o,t[23]=$,t[24]=R):($=t[23],R=t[24]),c.useEffect($,R);const[K,L]=c.useState(null);let O;t[25]!==D||t[26]!==M?.projectDirectory?(O=()=>{const z=D||M?.projectDirectory;if(!z){L(null);return}let G=!1;return ei(z).then(ie=>{if(G)return;const Oe=ie.trim();L(Oe&&Oe!=="HEAD"?Oe:null)}).catch(()=>{G||L(null)}),()=>{G=!0}},t[25]=D,t[26]=M?.projectDirectory,t[27]=O):O=t[27];const I=M?.projectDirectory;let j;t[28]!==D||t[29]!==I?(j=[D,I],t[28]=D,t[29]=I,t[30]=j):j=t[30],c.useEffect(O,j);let T;t[31]!==o?(T=()=>(o?ro.get(In(o)):void 0)??[],t[31]=o,t[32]=T):T=t[32];const[F,U]=c.useState(T);let H;t[33]!==o?(H=()=>(o?oo.get(In(o)):void 0)??null,t[33]=o,t[34]=H):H=t[34];const[Y,me]=c.useState(H);let Z,re;t[35]!==n||t[36]!==o?(Z=()=>{if(!o||!n?.getRemotes){U([]);return}U(ro.get(In(o))??[]);let z=!1;return n.getRemotes(o).then(G=>{z||(ro.set(In(o),G??[]),U(G??[]))}).catch(()=>{z||U(ro.get(In(o))??[])}),()=>{z=!0}},re=[o,n],t[35]=n,t[36]=o,t[37]=Z,t[38]=re):(Z=t[37],re=t[38]),c.useEffect(Z,re);let se,fe;t[39]!==n||t[40]!==o?(se=()=>{if(!o||!n?.getRemoteUrl){me(null);return}me(oo.get(In(o))??null);let z=!1;return n.getRemoteUrl(o).then(G=>{z||(oo.set(In(o),G),me(G))}).catch(()=>{z||me(oo.get(In(o))??null)}),()=>{z=!0}},fe=[o,n],t[39]=n,t[40]=o,t[41]=se,t[42]=fe):(se=t[41],fe=t[42]),c.useEffect(se,fe);let _;e:{if(!u?.all){let G;t[43]===Symbol.for("react.memo_cache_sentinel")?(G=[],t[43]=G):G=t[43],_=G;break e}let z;t[44]!==u.all?(z=u.all.filter(zb).sort(),t[44]=u.all,t[45]=z):z=t[45],_=z}const le=_;let ee;e:{if(!u?.all){let G;t[46]===Symbol.for("react.memo_cache_sentinel")?(G=[],t[46]=G):G=t[46],ee=G;break e}let z;t[47]!==u.all?(z=u.all.filter(Vb).map(Ub).sort(),t[47]=u.all,t[48]=z):z=t[48],ee=z}const ue=ee;let W;t[49]!==ue||t[50]!==Y||t[51]!==F||t[52]!==a?.tracking?(W=()=>{if(F.length>0)return F;const z=new Set,G=a?.tracking?.trim();G&&G.includes("/")&&z.add(G.split("/")[0]);for(const ie of ue){const Oe=ie.indexOf("/");Oe>0&&z.add(ie.slice(0,Oe))}return z.size===0&&Y&&z.add("origin"),Array.from(z).map(ie=>({name:ie,fetchUrl:Y??"",pushUrl:Y??""}))},t[49]=ue,t[50]=Y,t[51]=F,t[52]=a?.tracking,t[53]=W):W=t[53],a?.tracking;let ne;t[54]!==W?(ne=W(),t[54]=W,t[55]=ne):ne=t[55];const pe=ne,xe=a?.current??null;a?.tracking;let Ce;t[56]!==a?.tracking?(Ce=a?.tracking?.trim().split("/")[0],t[56]=a?.tracking,t[57]=Ce):Ce=t[57];const Me=Ce,ve=(Me&&u?.defaultBranches?.[Me])??u?.defaultBranches?.origin;let Ie;t[58]!==xe||t[59]!==ve||t[60]!==pe||t[61]!==le||t[62]!==K||t[63]!==M?.createdFromBranch?(Ie=()=>Ob({remoteNames:new Set(pe.map(Kb)),localBranches:le,worktreeCreatedFromBranch:M?.createdFromBranch,rootBranchHint:K,defaultBranch:ve,headBranch:xe}),t[58]=xe,t[59]=ve,t[60]=pe,t[61]=le,t[62]=K,t[63]=M?.createdFromBranch,t[64]=Ie):Ie=t[64],M?.createdFromBranch;let ye;t[65]!==Ie?(ye=Ie(),t[65]=Ie,t[66]=ye):ye=t[66];const q=ye;if(!r){let z;t[67]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx(E,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[67]=z):z=t[67];let G;t[68]!==e?(G=e("gitView.pullRequest.title"),t[68]=e,t[69]=G):G=t[69];let ie;t[70]!==G?(ie=s.jsx("div",{className:"typography-ui-header text-foreground",children:G}),t[70]=G,t[71]=ie):ie=t[71];let Oe;t[72]!==e?(Oe=e("gitView.pullRequest.createHint"),t[72]=e,t[73]=Oe):Oe=t[73];let Fe;t[74]!==Oe?(Fe=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Oe}),t[74]=Oe,t[75]=Fe):Fe=t[75];let Se;return t[76]!==ie||t[77]!==Fe?(Se=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[z,ie,Fe]}),t[76]=ie,t[77]=Fe,t[78]=Se):Se=t[78],Se}if(i===!1&&d!==!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 G;return t[82]!==d||t[83]!==l||t[84]!==i||t[85]!==z?(G=s.jsx(Yp,{rootIsGitRepo:i,resolvedIsGitRepo:d,nestedRepos:l,onRetryDiscovery:z}),t[82]=d,t[83]=l,t[84]=i,t[85]=z,t[86]=G):G=t[86],G}if(!xe){let z;t[87]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx(E,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[87]=z):z=t[87];let G;t[88]!==e?(G=e("gitView.pullRequest.title"),t[88]=e,t[89]=G):G=t[89];let ie;t[90]!==G?(ie=s.jsx("div",{className:"typography-ui-header text-foreground",children:G}),t[90]=G,t[91]=ie):ie=t[91];let Oe;t[92]!==e?(Oe=e("gitView.pullRequest.createHint"),t[92]=e,t[93]=Oe):Oe=t[93];let Fe;t[94]!==Oe?(Fe=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Oe}),t[94]=Oe,t[95]=Fe):Fe=t[95];let Se;return t[96]!==ie||t[97]!==Fe?(Se=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[z,ie,Fe]}),t[96]=ie,t[97]=Fe,t[98]=Se):Se=t[98],Se}const De=i===!1&&Array.isArray(l)&&l.length>0;let ke;t[99]!==r||t[100]!==o||t[101]!==l||t[102]!==g||t[103]!==De?(ke=De?s.jsx("div",{className:"flex shrink-0 items-center border-b border-border/60 px-4 py-2",children:s.jsx(Xp,{repositories:l,selectedRepository:o??null,onSelectRepository:z=>{r&&g(r,z)},repositoryRoot:r??void 0})}):null,t[99]=r,t[100]=o,t[101]=l,t[102]=g,t[103]=De,t[104]=ke):ke=t[104];const te=o??r,he=a?.tracking??void 0;let ae;t[105]!==q||t[106]!==xe||t[107]!==ue||t[108]!==F||t[109]!==te||t[110]!==he?(ae=s.jsx(Cn,{as:ka,outerClassName:"h-full min-h-0 flex-1",className:"px-4 py-3",disableHorizontal:!0,preventOverscroll:!0,children:s.jsx(Mb,{directory:te,branch:xe,baseBranch:q,trackingBranch:he,remotes:F,remoteBranches:ue})}),t[105]=q,t[106]=xe,t[107]=ue,t[108]=F,t[109]=te,t[110]=he,t[111]=ae):ae=t[111];let Q;return t[112]!==ke||t[113]!==ae?(Q=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[ke,ae]}),t[112]=ke,t[113]=ae,t[114]=Q):Q=t[114],Q};function Fb(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function _b(t){return t.currentSessionId}function Lb(t){return t.newSessionDraft}function $b(t){return t.worktreeMetadata}function Wb(t){return t.availableWorktrees}function zb(t){return!t.startsWith("remotes/")}function Vb(t){return t.startsWith("remotes/")}function Ub(t){return t.replace(/^remotes\//,"")}function Kb(t){return t.name}const Yi=2e4,Hb=(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},io=(t,e)=>Kf(Hf.getState().dictionary,t,e),Gb=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"},qb=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 cs(`/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()},_u=async(t,e,n)=>{if(Wf(e)||zf(e)||Vf(e))return{ok:!0};try{const r=await qb(t,e,n);return Uf(r)?{ok:!1,reason:"binary"}:Hb(r,Yi)>Yi?{ok:!1,reason:"too-large"}:{ok:!0}}catch(r){return{ok:!1,reason:Gb(r)}}},Lu=t=>{if(t==="too-large"){const e=Yi.toLocaleString(wa());return io("contextFileOpen.failure.tooLarge",{count:e})}return io(t==="missing"?"contextFileOpen.failure.missing":t==="binary"?"filesView.editor.cannotPreviewBinary":"contextFileOpen.failure.unreadable")},Gl=8;let Xi=null;const $u=t=>{Xi={x:t.clientX,y:t.clientY}},Wu=t=>{const e=Xi;return Xi=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:Math.abs(t.clientX-e.x)<=Gl&&Math.abs(t.clientY-e.y)<=Gl},ql=3,fr=t=>Array.from(t.types).includes("Files"),Qb=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]:[]})},Ql=t=>{const e=t.name;return!e||e==="."||e===".."||e.includes("/")||e.includes("\\")?null:e},Yb=t=>t.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),is=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},$a=(t,e)=>{const n=is(e),r=is(t).replace(/\/+$/,"");return n===r?".":!r||!n.startsWith(`${r}/`)?n:n.slice(r.length+1)},Xb=(t,e)=>{const n=$a(t,e);if(n!==".")return n;const r=is(t);return r.split("/").filter(Boolean).pop()??r},Jb=t=>{const e=is(t),n=e.lastIndexOf("/");return n<0?"":n===0?"/":e.slice(0,n)},Zb=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),ey=new Set(["node_modules"]),ty=t=>ey.has(t),sy=t=>{const e=is(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},ny=8,mn=new Map,Wa=t=>JSON.stringify([xs(),t]),ry=t=>{const e=Wa(t),n=mn.get(e);return n?(n.touchedAt=Date.now(),mn.delete(e),mn.set(e,n),n):null},gi=t=>{const e=Wa(t),n=mn.get(e);if(n)return n.touchedAt=Date.now(),n;if(mn.size>=ny){const i=mn.keys().next().value;i!==void 0&&mn.delete(i)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return mn.set(e,r),r},oy=t=>{mn.delete(Wa(t))},zu=(t,e)=>s.jsx(Ca,{filePath:t,extension:e}),iy=t=>{const e=Xe.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},ay=t=>{const e=Xe.c(87),{node:n,root:r,isExpanded:i,isActive:o,isBrowserClient:l,status:a,badge:u,isDropTarget:d,canUpload:h,permissions:f,downloadFile:g,onSelect:p,onToggle:w,onRevealPath:v,onOpenDialog:x,onSetDropTarget:m,onDropFiles:b}=t,{t:y}=pt(),S=n.type==="directory";let N;e[0]!==S||e[1]!==n.path?(N=S?n.path:Jb(n.path),e[0]=S,e[1]=n.path,e[2]=N):N=e[2];const C=N,{canRename:k,canCreateFile:A,canCreateFolder:P,canDelete:D,canReveal:M}=f,$=!S&&!!g,R=M&&!l,K=k||A||P||D||$||R,[L,O]=c.useState(!1),[I,j]=c.useState(!1);let T;e[3]!==K?(T=z=>{K&&(z?.preventDefault(),j(!0))},e[3]=K,e[4]=T):T=e[4];const F=T;let U;e[5]!==S||e[6]!==n||e[7]!==p||e[8]!==w?(U=()=>{S?w(n.path):p(n)},e[5]=S,e[6]=n,e[7]=p,e[8]=w,e[9]=U):U=e[9];const H=U;let Y;e[10]===Symbol.for("react.memo_cache_sentinel")?(Y=z=>{z.stopPropagation(),j(!1),O(!0)},e[10]=Y):Y=e[10];const me=Y;let Z;e[11]!==A||e[12]!==P||e[13]!==D||e[14]!==k||e[15]!==R||e[16]!==g||e[17]!==l||e[18]!==S||e[19]!==n||e[20]!==x||e[21]!==v||e[22]!==y?(Z=z=>{const{Item:G,Separator:ie}=z;return s.jsxs(s.Fragment,{children:[k&&s.jsxs(G,{onClick:Oe=>{Oe.stopPropagation(),x("rename",n)},children:[s.jsx(E,{name:"edit",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.rename")]}),s.jsxs(G,{onClick:Oe=>{Oe.stopPropagation(),hn(n.path).then(Fe=>{if(Fe.ok){Be.success(y("sidebarFilesTree.toast.pathCopied"));return}Be.error(y("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(E,{name:"file-copy",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.copyPath")]}),!S&&g&&s.jsxs(G,{onClick:Oe=>{Oe.stopPropagation(),g(n.path).catch(Fe=>{console.error("Download failed:",Fe),Be.error(y("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(E,{name:"download",className:"mr-2 h-4 w-4"})," ",y(l?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),R&&s.jsxs(G,{onClick:Oe=>{Oe.stopPropagation(),v(n.path)},children:[s.jsx(E,{name:"folder-received",className:"mr-2 h-4 w-4"})," ",y(bd())]}),S&&(A||P)&&s.jsxs(s.Fragment,{children:[s.jsx(ie,{}),A&&s.jsxs(G,{onClick:Oe=>{Oe.stopPropagation(),x("createFile",n)},children:[s.jsx(E,{name:"file-add",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.newFile")]}),P&&s.jsxs(G,{onClick:Oe=>{Oe.stopPropagation(),x("createFolder",n)},children:[s.jsx(E,{name:"folder-add",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.newFolder")]})]}),D&&s.jsxs(s.Fragment,{children:[s.jsx(ie,{}),s.jsxs(G,{onClick:Oe=>{Oe.stopPropagation(),x("delete",n)},className:"text-destructive focus:text-destructive",children:[s.jsx(E,{name:"delete-bin",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.delete")]})]})]})},e[11]=A,e[12]=P,e[13]=D,e[14]=k,e[15]=R,e[16]=g,e[17]=l,e[18]=S,e[19]=n,e[20]=x,e[21]=v,e[22]=y,e[23]=Z):Z=e[23];const re=Z;let se;e[24]!==n.path||e[25]!==r?(se=z=>{$u(z);const G=$a(r,n.path);!G||G==="."||(z.dataTransfer.setData("application/x-openchamber-file-path",G),z.dataTransfer.effectAllowed="copy")},e[24]=n.path,e[25]=r,e[26]=se):se=e[26];const fe=se;let _;e[27]!==H?(_=z=>{Wu(z)&&H()},e[27]=H,e[28]=_):_=e[28];const le=_;let ee;e[29]!==h||e[30]!==m||e[31]!==C?(ee=z=>{!h||!C||!fr(z.dataTransfer)||(z.preventDefault(),z.stopPropagation(),z.dataTransfer.dropEffect="copy",m(C))},e[29]=h,e[30]=m,e[31]=C,e[32]=ee):ee=e[32];const ue=ee;let W;e[33]!==h||e[34]!==m||e[35]!==C?(W=z=>{!h||!C||!fr(z.dataTransfer)||z.relatedTarget instanceof Node&&z.currentTarget.contains(z.relatedTarget)||(z.stopPropagation(),m(null))},e[33]=h,e[34]=m,e[35]=C,e[36]=W):W=e[36];const ne=W;let pe;e[37]!==h||e[38]!==b||e[39]!==C?(pe=z=>{!h||!C||!fr(z.dataTransfer)||(z.preventDefault(),z.stopPropagation(),b(C,z.dataTransfer))},e[37]=h,e[38]=b,e[39]=C,e[40]=pe):pe=e[40];const xe=pe;let Ce;e[41]!==F||e[42]!==ne||e[43]!==ue||e[44]!==xe?(Ce=s.jsx("div",{className:"group relative flex items-center",onContextMenu:F,onDragEnter:ue,onDragOver:ue,onDragLeave:ne,onDrop:xe}),e[41]=F,e[42]=ne,e[43]=ue,e[44]=xe,e[45]=Ce):Ce=e[45];const Me=d?"bg-interactive-selection ring-2 ring-inset ring-primary":o?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let ve;e[46]!==Me?(ve=Re("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",Me),e[46]=Me,e[47]=ve):ve=e[47];let Ie;e[48]!==S||e[49]!==i||e[50]!==n.extension||e[51]!==n.path?(Ie=S?i?s.jsx(E,{name:"folder-open",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):s.jsx(E,{name:"folder-3",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):zu(n.path,n.extension),e[48]=S,e[49]=i,e[50]=n.extension,e[51]=n.path,e[52]=Ie):Ie=e[52];let ye;e[53]!==n.name||e[54]!==n.path?(ye=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:n.path,children:n.name}),e[53]=n.name,e[54]=n.path,e[55]=ye):ye=e[55];let q;e[56]!==S||e[57]!==a?(q=!S&&a&&s.jsx(iy,{status:a}),e[56]=S,e[57]=a,e[58]=q):q=e[58];let De;e[59]!==u||e[60]!==S?(De=S&&u&&s.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[u.modified>0&&s.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",u.modified]}),u.added>0&&s.jsxs("span",{className:"text-[var(--status-success)]",children:["+",u.added]})]}),e[59]=u,e[60]=S,e[61]=De):De=e[61];let ke;e[62]!==F||e[63]!==le||e[64]!==fe||e[65]!==H||e[66]!==ve||e[67]!==Ie||e[68]!==ye||e[69]!==q||e[70]!==De?(ke=s.jsxs("button",{type:"button",onClick:H,onContextMenu:F,draggable:!0,onDragStart:fe,onDragEnd:le,className:ve,children:[Ie,ye,q,De]}),e[62]=F,e[63]=le,e[64]=fe,e[65]=H,e[66]=ve,e[67]=Ie,e[68]=ye,e[69]=q,e[70]=De,e[71]=ke):ke=e[71];let te;e[72]!==L||e[73]!==K||e[74]!==re||e[75]!==y?(te=K&&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(Xs,{open:L,onOpenChange:O,children:[s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(Qs,{asChild:!0,children:s.jsx(ot,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:me,title:y("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":y("sidebarFilesTree.actions.fileMenuTitle"),children:s.jsx(E,{name:"more-2-fill",className:"h-4 w-4"})})})})}),s.jsx(yt,{side:"bottom",sideOffset:6,children:y("sidebarFilesTree.actions.fileMenuTitle")})]}),s.jsx(Ys,{align:"end",side:"bottom",onCloseAutoFocus:()=>O(!1),children:re({Item:Wt,Separator:Es})})]})}),e[72]=L,e[73]=K,e[74]=re,e[75]=y,e[76]=te):te=e[76];let he;e[77]!==Ce||e[78]!==ke||e[79]!==te?(he=s.jsxs(ru,{render:Ce,children:[ke,te]}),e[77]=Ce,e[78]=ke,e[79]=te,e[80]=he):he=e[80];let ae;e[81]!==re?(ae=s.jsx(nu,{className:"min-w-[180px]",children:re({Item:Kn,Separator:Li})}),e[81]=re,e[82]=ae):ae=e[82];let Q;return e[83]!==I||e[84]!==he||e[85]!==ae?(Q=s.jsxs(ou,{open:I,onOpenChange:j,children:[he,ae]}),e[83]=I,e[84]=he,e[85]=ae,e[86]=Q):Q=e[86],Q},ly=(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,cy=c.memo(ay,ly),dy=()=>{const{t}=pt(),{files:e,runtime:n}=Dn(),r=Jm(n.platform),i=Yr()??"",o=is(i.trim()),l=Zm(),a=ef(),u=fd(X=>X.searchFiles),d=Te(X=>X.openContextFile),h=ja(i),[f,g]=c.useState(""),p=Na(f,200),w=c.useRef(null),[v,x]=c.useState([]),[m,b]=c.useState(!1),[y,S]=c.useState(null),[N,C]=c.useState(!1),[k,A]=c.useState(null),P=c.useRef(!1),D=c.useRef(o);D.current=o;const[M,$]=c.useState({}),[R,K]=c.useState({}),L=c.useRef(new Set),O=c.useRef(new Set),I=c.useRef(null);c.useEffect(()=>{if(S(null),A(null),!o){$({}),K({}),L.current=new Set;return}const X=ry(o);X?($({...X.childrenByDir}),K({...X.loadErrorsByDir}),L.current=new Set(X.loadedDirs)):($({}),K({}),L.current=new Set)},[o]),c.useEffect(()=>{if(!o)return;const X=gi(o);X.childrenByDir=M},[o,M]),c.useEffect(()=>{if(!o)return;const X=gi(o);X.loadErrorsByDir=R},[o,R]),c.useEffect(()=>{if(!o)return;const X=gi(o);X.loadedDirs=new Set(L.current)},[o,M,R]),c.useEffect(()=>()=>{if(!o)return;const X=mn.get(o);X&&X.loadedDirs.size===0&&Object.keys(X.childrenByDir).length===0&&oy(o)},[o]);const j=c.useMemo(()=>[],[]),T=c.useMemo(()=>[],[]),F=un(X=>o?X.byRoot[o]?.expandedPaths??j:j),U=un(X=>o?X.byRoot[o]?.selectedPath??null:null),H=un(X=>X.setSelectedPath),Y=un(X=>X.addOpenPath),me=un(X=>X.removeOpenPathsByPrefix),Z=un(X=>X.toggleExpandedPath),re=un(X=>X.collapseAllExpandedPaths),se=Te(X=>o?X.contextPanelByDirectory[o]?.tabs??T:T),fe=c.useMemo(()=>new Set(se.map(X=>X.mode==="file"?X.targetPath:null).filter(X=>typeof X=="string"&&X.length>0).map(X=>is(X))),[se]),[_,le]=c.useState(null),[ee,ue]=c.useState(null),[W,ne]=c.useState(""),[pe,xe]=c.useState(!1),Ce=!!e.writeFile,Me=!!e.createDirectory,ve=!!e.rename,Ie=!!e.delete,ye=!!e.revealPath,q=!!e.uploadFile,De=c.useMemo(()=>({canRename:ve,canCreateFile:Ce,canCreateFolder:Me,canDelete:Ie,canReveal:ye}),[ve,Ce,Me,Ie,ye]),ke=c.useCallback(X=>{e.revealPath&&e.revealPath(X).catch(()=>{Be.error(t("sidebarFilesTree.toast.revealFailed"))})},[e,t]),te=c.useCallback((X,we)=>{le(X),ue(we),ne(X==="rename"&&we.name||""),xe(!1)},[]),he=c.useCallback((X,we)=>{const ze=we.filter(Ve=>Ve&&typeof Ve.name=="string"&&Ve.name.length>0).filter(Ve=>l||!Ve.name.startsWith(".")).filter(Ve=>a||!ty(Ve.name)).map(Ve=>{const He=Ve.name,$e=is(Ve.path||""),qe=$e?Zb($e)?$e:is(`${X}/${$e}`):is(`${X}/${He}`),at=Ve.isDirectory?"directory":"file",gt=at==="file"&&He.includes(".")?He.split(".").pop()?.toLowerCase():void 0;return{name:He,path:qe,type:at,extension:gt}});return Yb(ze)},[a,l]),ae=c.useCallback(async(X,we)=>{const ze=is(X.trim());if(!ze||L.current.has(ze)||O.current.has(ze))return;O.current=new Set(O.current),O.current.add(ze);const Ve=e.listDirectory?e.listDirectory(ze).then(He=>He.entries.map($e=>({name:$e.name,path:$e.path,isDirectory:$e.isDirectory}))):qs.listLocalDirectory(ze).then(He=>He.map($e=>({name:$e.name,path:$e.path,isDirectory:$e.isDirectory})));try{const He=await Ve;if(we?.())return;const $e=he(ze,He);L.current=new Set(L.current),L.current.add(ze),K(qe=>{if(!qe[ze])return qe;const at={...qe};return delete at[ze],at}),$(qe=>({...qe,[ze]:$e}))}catch(He){if(we?.())return;const $e=He instanceof Error?He.message:String(He??"");console.error("Failed to load sidebar directory:",He),K(qe=>({...qe,[ze]:$e}))}finally{O.current=new Set(O.current),O.current.delete(ze)}},[e,he]),Q=c.useCallback(async()=>{if(!o)return;I.current?.abort();const X=new AbortController;I.current=X;try{const ze=(un.getState().byRoot[o]?.expandedPaths??[]).map($e=>is($e)).filter($e=>!!$e&&$e!==o&&$e.startsWith(`${o}/`)),Ve=[o,...ze];L.current=new Set(L.current);for(const $e of Ve)L.current.delete($e);K($e=>{if(Object.keys($e).length===0)return $e;const qe={...$e};let at=!1;for(const gt of Ve)gt in qe&&(delete qe[gt],at=!0);return at?qe:$e});const He=()=>X.signal.aborted;await ae(o,He);for(let $e=0;$e<ze.length&&!X.signal.aborted;$e+=3){const qe=ze.slice($e,$e+3);await Promise.all(qe.map(at=>ae(at,He)))}}catch(we){if(X.signal.aborted)return;console.error("Failed to refresh sidebar tree:",we)}finally{I.current===X&&(I.current=null)}},[ae,o]),z=c.useCallback(async X=>{if(!X){await Q();return}const we=is(X);L.current=new Set(L.current),L.current.delete(we),O.current=new Set(O.current),O.current.delete(we),await ae(we)},[ae,Q]);c.useEffect(()=>{o&&(I.current?.abort(),L.current=new Set,O.current=new Set,K({}),$(X=>Object.keys(X).length===0?X:{}),ae(o))},[ae,o,l,a]),c.useEffect(()=>{if(!o||F.length===0)return;const X=F.map(Ve=>is(Ve)).filter(Ve=>!!Ve&&Ve!==o&&Ve.startsWith(`${o}/`)&&!L.current.has(Ve)&&!O.current.has(Ve)).sort((Ve,He)=>Ve.split("/").length-He.split("/").length);if(X.length===0)return;let we=!1;const ze=()=>we;return(async()=>{for(let Ve=0;Ve<X.length&&!we;Ve+=3){const He=X.slice(Ve,Ve+3);await Promise.all(He.map($e=>ae($e,ze)))}})(),()=>{we=!0}},[F,ae,o]),c.useEffect(()=>{if(!i){x([]),b(!1);return}const X=p.trim();if(!X){x([]),b(!1);return}let we=!1;return b(!0),u(i,X,150,{includeHidden:l,respectGitignore:!a,type:"file"}).then(ze=>{if(we)return;const He=ze.filter($e=>a||!sy($e.path)).map($e=>({name:$e.name,path:is($e.path),type:"file",extension:$e.extension,relativePath:$e.relativePath}));x(He)}).catch(()=>{we||x([])}).finally(()=>{we||b(!1)}),()=>{we=!0}},[i,p,u,l,a]);const G=c.useMemo(()=>{const X=new Map;if(!h?.files)return X;for(const we of h.files)we.index==="A"||we.working_dir==="?"?X.set(we.path,"git-added"):we.index==="D"?X.set(we.path,"git-deleted"):(we.index==="M"||we.working_dir==="M")&&X.set(we.path,"git-modified");return X},[h]),ie=c.useMemo(()=>{const X=new Map;if(!h?.files||!o)return X;for(const we of h.files){const ze=we.index==="M"||we.working_dir==="M",Ve=we.index==="A"||we.working_dir==="?";if(!ze&&!Ve)continue;const He=we.path.split("/");if(He.length<=1)continue;let $e=o;for(let qe=0;qe<He.length-1;qe++){$e=`${$e}/${He[qe]}`;let at=X.get($e);at||(at={modified:0,added:0},X.set($e,at)),ze&&at.modified++,Ve&&at.added++}}return X},[h,o]),Oe=c.useCallback(X=>{if(fe.has(X))return"open";if(G.size===0)return null;const we=X.startsWith(o+"/")?X.slice(o.length+1):X;return G.get(we)??null},[fe,G,o]),Fe=c.useCallback(X=>{if(ie.size===0)return null;const we=ie.get(X);return we&&we.modified+we.added>0?we:null},[ie]),Se=c.useCallback(async X=>{if(!o)return;const we=await _u(e,X.path,{directory:o});if(!we.ok){Be.error(Lu(we.reason));return}H(o,X.path),Y(o,X.path),d(o,X.path)},[Y,e,d,o,H]),oe=c.useCallback(async X=>{const we=is(X);o&&(Z(o,we),L.current.has(we)||await ae(we))},[ae,o,Z]),Pe=c.useCallback(async(X,we,ze=!1)=>{const Ve=e.uploadFile;if(!Ve||we.length===0||P.current||!o)return;const He=o,$e=xs();P.current=!0,C(!0),S(X),ze&&A(null);const qe=[];for(let kt=0;kt<we.length;kt+=ql){const Mt=we.slice(kt,kt+ql),Tt=await Promise.all(Mt.map(async wt=>{const St=Ql(wt);if(!St||xs()!==$e)return"failed";try{return(await Ve(is(`${X}/${St}`),wt,{directory:He,overwrite:ze})).success?"uploaded":"failed"}catch(vt){return!ze&&tf(vt)&&vt.reason==="already-exists"?"conflict":"failed"}}));qe.push(...Tt)}const at=qe.filter(kt=>kt==="uploaded").length,gt=qe.filter(kt=>kt==="failed").length,Pt=we.filter((kt,Mt)=>qe[Mt]==="conflict"),Ge=we.flatMap((kt,Mt)=>{const Tt=Ql(kt);return qe[Mt]==="uploaded"&&Tt?[is(`${X}/${Tt}`)]:[]}),It=D.current===He&&xs()===$e;try{Ge.length>0&&bg({runtimeKey:$e,paths:Ge}),at>0&&It&&await z(X),at>0&&Be.success(t(Pt.length>0?"sidebarFilesTree.toast.uploadedWithoutConflicts":"sidebarFilesTree.toast.uploaded")),gt>0&&Be.error(t("sidebarFilesTree.toast.uploadFailed")),Pt.length>0&&It&&A({directory:X,files:Pt,runtimeKey:$e,workspaceRoot:He})}finally{P.current=!1,C(!1),S(null)}},[e.uploadFile,z,o,t]),Ne=c.useCallback((X,we)=>{const ze=Qb(we);ze.length!==0&&Pe(X,ze)},[Pe]),B=c.useCallback(X=>{!q||P.current||!o||!fr(X.dataTransfer)||(X.preventDefault(),X.dataTransfer.dropEffect="copy",S(o))},[q,o]),ce=c.useCallback(X=>{fr(X.dataTransfer)&&(X.relatedTarget instanceof Node&&X.currentTarget.contains(X.relatedTarget)||S(null))},[]),be=c.useCallback(X=>{!q||P.current||!o||!fr(X.dataTransfer)||(X.preventDefault(),Ne(o,X.dataTransfer))},[q,Ne,o]),ge=c.useCallback(async X=>{if(X?.preventDefault(),!ee||!_)return;xe(!0);const we=()=>xe(!1),ze=()=>le(null);if(_==="createFile"){if(!W.trim()){Be.error(t("sidebarFilesTree.toast.filenameRequired")),we();return}if(!e.writeFile){Be.error(t("sidebarFilesTree.toast.writeNotSupported")),we();return}const Ve=ee.path,He=Ve?`${Ve}/`:"",$e=is(`${He}${W.trim()}`);await e.writeFile($e,"").then(async qe=>{qe.success&&(Be.success(t("sidebarFilesTree.toast.fileCreated")),await z(Ve)),ze()}).catch(()=>Be.error(t("sidebarFilesTree.toast.operationFailed"))).finally(we);return}if(_==="createFolder"){if(!W.trim()){Be.error(t("sidebarFilesTree.toast.folderNameRequired")),we();return}const Ve=ee.path,He=Ve?`${Ve}/`:"",$e=is(`${He}${W.trim()}`);await e.createDirectory($e).then(async qe=>{qe.success&&(Be.success(t("sidebarFilesTree.toast.folderCreated")),await z(Ve)),ze()}).catch(()=>Be.error(t("sidebarFilesTree.toast.operationFailed"))).finally(we);return}if(_==="rename"){if(!W.trim()){Be.error(t("sidebarFilesTree.toast.nameRequired")),we();return}if(!e.rename){Be.error(t("sidebarFilesTree.toast.renameNotSupported")),we();return}const Ve=ee.path,He=Ve.split("/").slice(0,-1).join("/"),$e=He?`${He}/`:"",qe=is(`${$e}${W.trim()}`);await e.rename(Ve,qe).then(async at=>{at.success&&(Be.success(t("sidebarFilesTree.toast.renamedSuccessfully")),await z(He),o&&me(o,Ve),(U===Ve||U&&U.startsWith(`${Ve}/`))&&H(o,null)),ze()}).catch(()=>Be.error(t("sidebarFilesTree.toast.operationFailed"))).finally(we);return}if(_==="delete"){if(!e.delete){Be.error(t("sidebarFilesTree.toast.deleteNotSupported")),we();return}const Ve=ee.path,He=Ve.split("/").slice(0,-1).join("/");await e.delete(Ve).then(async $e=>{$e.success&&(Be.success(t("sidebarFilesTree.toast.deletedSuccessfully")),await z(He),o&&me(o,Ve),(U===Ve||U&&U.startsWith(Ve+"/"))&&H(o,null)),ze()}).catch(()=>Be.error(t("sidebarFilesTree.toast.operationFailed"))).finally(we);return}we()},[_,ee,W,e,z,me,o,U,H,t]);function _e(X,we){const ze=M[X]??[];return ze.map((Ve,He)=>{const $e=Ve.type==="directory",qe=$e&&F.includes(Ve.path),at=U===Ve.path,gt=He===ze.length-1;return s.jsxs("li",{className:"relative",children:[we>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),gt&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-sidebar/50"})]}),s.jsx(cy,{node:Ve,root:o,isExpanded:qe,isActive:at,isBrowserClient:r,status:$e?void 0:Oe(Ve.path),badge:$e?Fe(Ve.path):void 0,isDropTarget:$e&&y===Ve.path,canUpload:q&&!N,permissions:De,downloadFile:e.downloadFile,onSelect:Se,onToggle:oe,onRevealPath:ke,onOpenDialog:te,onSetDropTarget:S,onDropFiles:Ne}),$e&&qe&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[R[Ve.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:R[Ve.path],children:R[Ve.path]}),s.jsxs(ot,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{z(Ve.path)},children:[s.jsx(E,{name:"refresh",className:"h-3.5 w-3.5"}),t("sidebarFilesTree.actions.refreshTitle")]})]}):null,_e(Ve.path,we+1)]})]},Ve.path)})}const tt=!!(o&&M[o]),Ue=o?R[o]:null,de=y?Xb(o,y):"";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:[Ce&&s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>te("createFile",{path:i,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:t("sidebarFilesTree.actions.newFileTitle"),"aria-label":t("sidebarFilesTree.actions.newFileTitle"),children:s.jsx(E,{name:"file-add",className:"h-4 w-4"})})})}),s.jsx(yt,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.newFileTitle")})]}),Me&&s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>te("createFolder",{path:i,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:t("sidebarFilesTree.actions.newFolderTitle"),"aria-label":t("sidebarFilesTree.actions.newFolderTitle"),children:s.jsx(E,{name:"folder-add",className:"h-4 w-4"})})})}),s.jsx(yt,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.newFolderTitle")})]}),s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>{Q()},className:"h-8 w-8 p-0 flex-shrink-0",title:t("sidebarFilesTree.actions.refreshTitle"),"aria-label":t("sidebarFilesTree.actions.refreshTitle"),children:s.jsx(E,{name:"refresh",className:"h-4 w-4"})})})}),s.jsx(yt,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.refreshTitle")})]}),s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>{o&&re(o)},className:"h-8 w-8 p-0 flex-shrink-0",title:t("sidebarFilesTree.actions.collapseAllTitle"),"aria-label":t("sidebarFilesTree.actions.collapseAllTitle"),children:s.jsx(E,{name:"collapse-vertical",className:"h-4 w-4"})})})}),s.jsx(yt,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.collapseAllTitle")})]})]}),s.jsxs("div",{className:"relative min-w-0",children:[s.jsx(E,{name:"search",className:"pointer-events-none absolute left-2 top-2 h-4 w-4 text-muted-foreground"}),s.jsx(kn,{ref:w,value:f,onChange:X=>g(X.target.value),placeholder:t("sidebarFilesTree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),f.trim().length>0?s.jsx("button",{type:"button","aria-label":t("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:()=>{g(""),w.current?.focus()},children:s.jsx(E,{name:"close",className:"h-4 w-4"})}):null]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx(Cn,{outerClassName:"h-full min-h-0",className:Re("p-2",y===o&&"bg-interactive-selection/10"),onDragEnter:B,onDragOver:B,onDragLeave:ce,onDrop:be,children:s.jsx("ul",{className:"flex flex-col",children:m?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(E,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("sidebarFilesTree.state.searching")]}):v.length>0?v.map(X=>{const we=U===X.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>Se(X),draggable:!0,onDragStart:ze=>{$u(ze);const Ve=X.relativePath||$a(o??"",X.path);!Ve||Ve==="."||(ze.dataTransfer.setData("application/x-openchamber-file-path",Ve),ze.dataTransfer.effectAllowed="copy")},onDragEnd:ze=>{Wu(ze)&&Se(X)},className:Re("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",we?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),title:X.path,children:[zu(X.path,X.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},children:X.relativePath??X.path})]})},X.path)}):Ue?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{children:Ue}),s.jsxs(ot,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{Q()},children:[s.jsx(E,{name:"refresh",className:"h-3.5 w-3.5"}),t("sidebarFilesTree.actions.refreshTitle")]})]}):tt&&o?_e(o,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:t("sidebarFilesTree.state.loading")})})}),y?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(E,{name:N?"loader-4":"folder-received",className:Re("size-4 flex-shrink-0",N&&"animate-spin")}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:de,children:t(N?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:de})})]}):null]}),s.jsx(Ss,{open:!!k,onOpenChange:X=>!X&&A(null),children:s.jsxs(vs,{children:[s.jsxs(Ls,{children:[s.jsx(Ts,{children:t("sidebarFilesTree.dialog.uploadConflicts.title")}),s.jsx(Is,{children:t("sidebarFilesTree.dialog.uploadConflicts.description",{path:k?.directory??""})})]}),s.jsx(Cn,{outerClassName:"max-h-52",className:"flex flex-col gap-1 pr-2",children:k?.files.map((X,we)=>s.jsx("div",{className:"truncate rounded-md bg-muted px-2 py-1 typography-meta",title:X.name,children:X.name},`${X.name}-${X.size}-${we}`))}),s.jsxs(xn,{children:[s.jsx(ot,{variant:"outline",onClick:()=>A(null),disabled:N,children:t("sidebarFilesTree.dialog.cancel")}),s.jsx(ot,{onClick:()=>{if(k){if(k.runtimeKey!==xs()||k.workspaceRoot!==o){A(null);return}Pe(k.directory,k.files,!0)}},disabled:N,children:t("sidebarFilesTree.dialog.uploadConflicts.replace")})]})]})}),s.jsx(Ss,{open:!!_,onOpenChange:X=>!X&&le(null),children:s.jsxs(vs,{children:[s.jsxs(Ls,{children:[s.jsxs(Ts,{children:[_==="createFile"&&t("sidebarFilesTree.dialog.createFile.title"),_==="createFolder"&&t("sidebarFilesTree.dialog.createFolder.title"),_==="rename"&&t("sidebarFilesTree.dialog.rename.title"),_==="delete"&&t("sidebarFilesTree.dialog.delete.title")]}),s.jsxs(Is,{children:[_==="createFile"&&t("sidebarFilesTree.dialog.createFile.description",{path:ee?.path??t("sidebarFilesTree.dialog.rootFallback")}),_==="createFolder"&&t("sidebarFilesTree.dialog.createFolder.description",{path:ee?.path??t("sidebarFilesTree.dialog.rootFallback")}),_==="rename"&&t("sidebarFilesTree.dialog.rename.description",{name:ee?.name??""}),_==="delete"&&t("sidebarFilesTree.dialog.delete.description",{name:ee?.name??""})]})]}),_!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(kn,{value:W,onChange:X=>ne(X.target.value),placeholder:t(_==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:X=>{X.key==="Enter"&&ge()},autoFocus:!0})}),s.jsxs(xn,{children:[s.jsx(ot,{variant:"outline",onClick:()=>le(null),disabled:pe,children:t("sidebarFilesTree.dialog.cancel")}),s.jsx(ot,{variant:_==="delete"?"destructive":"default",onClick:()=>{ge()},disabled:pe||_!=="delete"&&!W.trim(),children:pe?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t(_==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})})]})},Yl=60,uy=t=>{try{return new URL(t).origin}catch{return""}},xi=new Set,Vu=tr()((t,e)=>({byOrigin:{},resolve:(n,r)=>{const i=uy(n);!i||!r||e().byOrigin[i]||xi.has(i)||(xi.add(i),mr("desktop_browser_fetch_favicon",{url:r}).then(o=>{const l=typeof o?.dataUrl=="string"?o.dataUrl:"";l&&t(a=>{const u={...a.byOrigin,[i]:l},d=Object.keys(u);if(d.length<=Yl)return{byOrigin:u};for(const h of d.slice(0,d.length-Yl))delete u[h];return{byOrigin:u}})}).catch(()=>{}).finally(()=>{xi.delete(i)}))}})),za=t=>t,Ji=t=>{const e=za(t).type;return typeof e=="string"?e:""},my=t=>{const e=za(t).tool;return typeof e=="string"?e:""},fy=t=>{const e=za(t).text;return typeof e=="string"?e:""},hy=t=>{const e=Ji(t);return e==="tool"?my(t).trim().toLowerCase()||"tool":e||"unknown"},py=t=>{if(t.length===0)return"";const e=[];for(const n of t){const r=hy(n);e.includes(r)||e.push(r)}return e.join(" + ")},gy=t=>t.replace(/\s+/g," ").trim(),xy=t=>{for(const n of t)if(Ji(n)==="text"){const r=gy(fy(n));if(r.length===0)continue;return r}const e=t.filter(n=>Ji(n)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},by=(t,e,n)=>`${n(t)} / ${n(e)}`,yy=t=>{if(t==="12h")return!0;if(t==="24h")return!1},wy=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const n=yy(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}})},Zi={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},So={user:0,assistant:0,tool:0,other:0},En=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,bi=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{...Zi,total:En(n)};if(!n||typeof n!="object")return Zi;const r=n,i=En(r.input),o=En(r.output),l=En(r.reasoning),a=En(r.cache?.read),u=En(r.cache?.write),d=En(r.total);return{input:i,output:o,reasoning:l,cacheRead:a,cacheWrite:u,total:d>0?d:i+o+l+a+u}},Sy=(...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,vy=(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=Sy(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}},Xl=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),jy=t=>{const e=Xr(t.info);return e.isUser?"user":e.role==="assistant"?"assistant":e.role==="tool"?"tool":"other"},ky=(t,e)=>{if(t.length===0)return{...So};const n=t.reduce((r,i)=>{const o=jy(i);let l={...So};for(const a of i.parts)l=Xl(l,vy(a,o));return Xl(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)}},Un=t=>t.toLocaleString(wa()),Cy=(t,e)=>!t||!Number.isFinite(t)?"-":Nd(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),Ny=(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}},Ay=()=>{const t=Xe.c(203),{t:e}=pt(),n=Te(Py);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),u=c.useRef(null),d=Qe(Dy),h=Qe(Ty),f=Dd(h??void 0),g=Gf(d??"",h??void 0),p=Kt(Iy);let w;t[1]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null),o(Ry),a(null)},t[1]=w):w=t[1];let v;t[2]!==h||t[3]!==d?(v=[h,d],t[2]=h,t[3]=d,t[4]=v):v=t[4],c.useEffect(w,v);let x,m;t[5]===Symbol.for("react.memo_cache_sentinel")?(x=()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},m=[],t[5]=x,t[6]=m):(x=t[5],m=t[6]),c.useEffect(x,m);let b;t[7]===Symbol.for("react.memo_cache_sentinel")?(b=async(ht,Ze)=>{(await hn(Ze)).ok?(a(ht),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{a(nt=>nt===ht?null:nt),u.current=null},2e3)):a(null)},t[7]=b):b=t[7];const y=b;let S;t[8]!==d||t[9]!==f?(S=d?f.find(ht=>ht.id===d)??null:null,t[8]=d,t[9]=f,t[10]=S):S=t[10];const N=S;let C,k,A,P,D,M;if(t[11]!==p||t[12]!==g){C=g.filter(Ey);let ht;t[19]!==g?(ht=g.filter(My),t[19]=g,t[20]=ht):ht=t[20],M=ht;let Ze=null;for(let nt=C.length-1;nt>=0;nt=nt-1,nt){const lt=C[nt];if(bi(lt).total>0){Ze=lt;break}}P=Ze?bi(Ze):Zi,k=qf({input:P.input,cache:{read:P.cacheRead,write:P.cacheWrite}}),D=C.reduce(Oy,0);const je=Ze?.info??null;A=Ny(p,je?.providerID||"",je?.modelID||""),t[11]=p,t[12]=g,t[13]=C,t[14]=k,t[15]=A,t[16]=P,t[17]=D,t[18]=M}else C=t[13],k=t[14],A=t[15],P=t[16],D=t[17],M=t[18];const $=A,R=$.contextLimit,K=R&&R>0?Math.min(999,P.total/R*100):0;let L;if(t[21]!==g){const ht=[...g].reverse().find(By)?.info?.system||"";L=ky(g,ht),t[21]=g,t[22]=L}else L=t[22];const O=L,I=O.user,j=O.assistant,T=O.tool,F=Math.max(0,P.input-I-j-T),U=I+j+T+F,H=g[0]?.info?.time?.created,Y=g.length>0?g[g.length-1]?.info?.time?.created:null;let me;t[23]!==N?.title||t[24]!==e?(me=N?.title||e("contextSidebar.session.untitled"),t[23]=N?.title,t[24]=e,t[25]=me):me=t[25];const Z=N?.time?.created??H??null,re=Y??N?.time?.created??null;let se;t[26]!==j||t[27]!==F||t[28]!==T||t[29]!==I?(se={user:I,assistant:j,tool:T,other:F},t[26]=j,t[27]=F,t[28]=T,t[29]=I,t[30]=se):se=t[30];let fe;t[31]!==C.length||t[32]!==U||t[33]!==k||t[34]!==R||t[35]!==$||t[36]!==g.length||t[37]!==Z||t[38]!==re||t[39]!==se||t[40]!==me||t[41]!==P||t[42]!==D||t[43]!==K||t[44]!==M.length?(fe={sessionTitle:me,messagesCount:g.length,userMessagesCount:M.length,assistantMessagesCount:C.length,createdAt:Z,lastActivityAt:re,providerModel:$,tokenBreakdown:P,usagePercent:K,cacheHitRate:k,totalAssistantCost:D,contextLimit:R,breakdown:se,breakdownTotal:U},t[31]=C.length,t[32]=U,t[33]=k,t[34]=R,t[35]=$,t[36]=g.length,t[37]=Z,t[38]=re,t[39]=se,t[40]=me,t[41]=P,t[42]=D,t[43]=K,t[44]=M.length,t[45]=fe):fe=t[45];const _=fe;if(!d){let ht;t[46]!==e?(ht=e("contextSidebar.empty.openSession"),t[46]=e,t[47]=ht):ht=t[47];let Ze;return t[48]!==ht?(Ze=s.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:ht}),t[48]=ht,t[49]=Ze):Ze=t[49],Ze}let le;t[50]!==e?(le=e("contextSidebar.breakdown.user"),t[50]=e,t[51]=le):le=t[51];let ee;t[52]!==le||t[53]!==_.breakdown.user?(ee={key:"user",label:le,value:_.breakdown.user,color:"var(--status-success)"},t[52]=le,t[53]=_.breakdown.user,t[54]=ee):ee=t[54];let ue;t[55]!==e?(ue=e("contextSidebar.breakdown.assistant"),t[55]=e,t[56]=ue):ue=t[56];let W;t[57]!==ue||t[58]!==_.breakdown.assistant?(W={key:"assistant",label:ue,value:_.breakdown.assistant,color:"var(--primary-base)"},t[57]=ue,t[58]=_.breakdown.assistant,t[59]=W):W=t[59];let ne;t[60]!==e?(ne=e("contextSidebar.breakdown.toolCalls"),t[60]=e,t[61]=ne):ne=t[61];let pe;t[62]!==ne||t[63]!==_.breakdown.tool?(pe={key:"tool",label:ne,value:_.breakdown.tool,color:"var(--status-warning)"},t[62]=ne,t[63]=_.breakdown.tool,t[64]=pe):pe=t[64];let xe;t[65]!==e?(xe=e("contextSidebar.breakdown.other"),t[65]=e,t[66]=xe):xe=t[66];let Ce;t[67]!==xe||t[68]!==_.breakdown.other?(Ce={key:"other",label:xe,value:_.breakdown.other,color:"var(--surface-muted-foreground)"},t[67]=xe,t[68]=_.breakdown.other,t[69]=Ce):Ce=t[69];let Me;t[70]!==ee||t[71]!==W||t[72]!==pe||t[73]!==Ce?(Me=[ee,W,pe,Ce],t[70]=ee,t[71]=W,t[72]=pe,t[73]=Ce,t[74]=Me):Me=t[74];const ve=Me;let Ie;t[75]!==_.sessionTitle?(Ie=s.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:_.sessionTitle}),t[75]=_.sessionTitle,t[76]=Ie):Ie=t[76];let ye;t[77]!==_.providerModel.modelName||t[78]!==_.providerModel.providerName?(ye=s.jsxs("span",{children:[_.providerModel.providerName," / ",_.providerModel.modelName]}),t[77]=_.providerModel.modelName,t[78]=_.providerModel.providerName,t[79]=ye):ye=t[79];let q;t[80]!==n||t[81]!==_.createdAt?(q=_.createdAt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsx("span",{children:Cy(_.createdAt,n)})]}),t[80]=n,t[81]=_.createdAt,t[82]=q):q=t[82];let De;t[83]!==ye||t[84]!==q?(De=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:[ye,q]}),t[83]=ye,t[84]=q,t[85]=De):De=t[85];let ke;t[86]!==Ie||t[87]!==De?(ke=s.jsxs("div",{className:"mb-6",children:[Ie,De]}),t[86]=Ie,t[87]=De,t[88]=ke):ke=t[88];let te;t[89]!==e?(te=e("contextSidebar.section.context"),t[89]=e,t[90]=te):te=t[90];let he;t[91]!==te?(he=s.jsx("span",{className:"typography-micro text-muted-foreground",children:te}),t[91]=te,t[92]=he):he=t[92];let ae;t[93]!==_.tokenBreakdown.total?(ae=Un(_.tokenBreakdown.total),t[93]=_.tokenBreakdown.total,t[94]=ae):ae=t[94];let Q;t[95]!==_.contextLimit?(Q=_.contextLimit?` / ${Un(_.contextLimit)}`:"",t[95]=_.contextLimit,t[96]=Q):Q=t[96];let z;t[97]!==ae||t[98]!==Q?(z=s.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[ae,Q]}),t[97]=ae,t[98]=Q,t[99]=z):z=t[99];let G;t[100]!==he||t[101]!==z?(G=s.jsxs("div",{className:"flex items-baseline justify-between",children:[he,z]}),t[100]=he,t[101]=z,t[102]=G):G=t[102];let ie;t[103]!==_.usagePercent?(ie=_.usagePercent>0&&s.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,_.usagePercent)}%`,backgroundColor:_.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[103]=_.usagePercent,t[104]=ie):ie=t[104];let Oe;t[105]!==ie?(Oe=s.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:ie}),t[105]=ie,t[106]=Oe):Oe=t[106];let Fe;t[107]!==e||t[108]!==_.usagePercent?(Fe=e("contextSidebar.context.percentUsed",{percent:_.usagePercent.toFixed(1)}),t[107]=e,t[108]=_.usagePercent,t[109]=Fe):Fe=t[109];let Se;t[110]!==Fe?(Se=s.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:Fe}),t[110]=Fe,t[111]=Se):Se=t[111];let oe;t[112]!==G||t[113]!==Oe||t[114]!==Se?(oe=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[G,Oe,Se]}),t[112]=G,t[113]=Oe,t[114]=Se,t[115]=oe):oe=t[115];let Pe;t[116]!==e?(Pe=e("contextSidebar.stats.messages"),t[116]=e,t[117]=Pe):Pe=t[117];let Ne;t[118]!==_.messagesCount?(Ne=Un(_.messagesCount),t[118]=_.messagesCount,t[119]=Ne):Ne=t[119];let B;t[120]!==Pe||t[121]!==Ne?(B={label:Pe,value:Ne},t[120]=Pe,t[121]=Ne,t[122]=B):B=t[122];let ce;t[123]!==e?(ce=e("contextSidebar.stats.user"),t[123]=e,t[124]=ce):ce=t[124];let be;t[125]!==_.userMessagesCount?(be=Un(_.userMessagesCount),t[125]=_.userMessagesCount,t[126]=be):be=t[126];let ge;t[127]!==ce||t[128]!==be?(ge={label:ce,value:be},t[127]=ce,t[128]=be,t[129]=ge):ge=t[129];let _e;t[130]!==e?(_e=e("contextSidebar.stats.assistant"),t[130]=e,t[131]=_e):_e=t[131];let tt;t[132]!==_.assistantMessagesCount?(tt=Un(_.assistantMessagesCount),t[132]=_.assistantMessagesCount,t[133]=tt):tt=t[133];let Ue;t[134]!==_e||t[135]!==tt?(Ue={label:_e,value:tt},t[134]=_e,t[135]=tt,t[136]=Ue):Ue=t[136];let de;t[137]!==e?(de=e("contextSidebar.stats.cost"),t[137]=e,t[138]=de):de=t[138];let X;t[139]!==_.totalAssistantCost?(X=Up(_.totalAssistantCost),t[139]=_.totalAssistantCost,t[140]=X):X=t[140];let we;t[141]!==de||t[142]!==X?(we={label:de,value:X},t[141]=de,t[142]=X,t[143]=we):we=t[143];let ze;t[144]!==B||t[145]!==ge||t[146]!==Ue||t[147]!==we?(ze=[B,ge,Ue,we],t[144]=B,t[145]=ge,t[146]=Ue,t[147]=we,t[148]=ze):ze=t[148];const Ve=ze;let He;t[149]!==Ve?(He=s.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:Ve.map(Fy)}),t[149]=Ve,t[150]=He):He=t[150];let $e;t[151]!==e?($e=e("contextSidebar.section.lastAssistantMessage"),t[151]=e,t[152]=$e):$e=t[152];let qe;t[153]!==$e?(qe=s.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:$e}),t[153]=$e,t[154]=qe):qe=t[154];let at;t[155]!==e||t[156]!==_.cacheHitRate.hasInput||t[157]!==_.cacheHitRate.percent||t[158]!==_.tokenBreakdown.cacheRead||t[159]!==_.tokenBreakdown.cacheWrite||t[160]!==_.tokenBreakdown.input||t[161]!==_.tokenBreakdown.output||t[162]!==_.tokenBreakdown.reasoning?(at=s.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:_.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:_.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:_.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:_.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:_.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:_.cacheHitRate.hasInput?_.cacheHitRate.percent:null,format:"percent"}].map(_y)}),t[155]=e,t[156]=_.cacheHitRate.hasInput,t[157]=_.cacheHitRate.percent,t[158]=_.tokenBreakdown.cacheRead,t[159]=_.tokenBreakdown.cacheWrite,t[160]=_.tokenBreakdown.input,t[161]=_.tokenBreakdown.output,t[162]=_.tokenBreakdown.reasoning,t[163]=at):at=t[163];let gt;t[164]!==qe||t[165]!==at?(gt=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[qe,at]}),t[164]=qe,t[165]=at,t[166]=gt):gt=t[166];let Pt;t[167]!==ve||t[168]!==_.breakdownTotal?(Pt=s.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:ve.map(ht=>ht.value<=0||_.breakdownTotal<=0?null:s.jsx("div",{style:{width:`${ht.value/_.breakdownTotal*100}%`,backgroundColor:ht.color}},ht.key))}),t[167]=ve,t[168]=_.breakdownTotal,t[169]=Pt):Pt=t[169];let Ge;t[170]!==ve||t[171]!==_.breakdownTotal?(Ge=s.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:ve.map(ht=>{const Ze=_.breakdownTotal>0?ht.value/_.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:ht.color}}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[ht.label," ",s.jsxs("span",{className:"tabular-nums",children:[Ze.toFixed(0),"%"]})]})]},ht.key)})}),t[170]=ve,t[171]=_.breakdownTotal,t[172]=Ge):Ge=t[172];let It;t[173]!==Pt||t[174]!==Ge?(It=s.jsxs("div",{className:"mb-6",children:[Pt,Ge]}),t[173]=Pt,t[174]=Ge,t[175]=It):It=t[175];let kt;t[176]!==e?(kt=e("contextSidebar.section.rawMessages"),t[176]=e,t[177]=kt):kt=t[177];let Mt;t[178]!==kt?(Mt=s.jsx("div",{className:"typography-micro text-muted-foreground",children:kt}),t[178]=kt,t[179]=Mt):Mt=t[179];let Tt;if(t[180]!==l||t[181]!==i||t[182]!==g||t[183]!==e||t[184]!==n){let ht;t[186]!==l||t[187]!==i||t[188]!==e||t[189]!==n?(ht=Ze=>{const nt=Xr(Ze.info).role,lt=nt==="assistant",Ct=nt==="user",Ye=i[Ze.info.id]===!0,it=l===Ze.info.id,Nt=Ze.info.time?.created??null,Dt=py(Ze.parts),Rt=lt?bi({info:Ze.info,parts:Ze.parts}):null,Vt=Ct?xy(Ze.parts):"",Qt=wy(Nt,n),Ut=Dt||"—",Ft=Rt?by(Rt.input,Rt.output,Un):"",Yt=nt||"unknown",$t=Dt?`${Yt}: ${Dt}`:Yt,_t=Ye?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":Ye,onClick:()=>{o(Ee=>({...Ee,[Ze.info.id]:Ee[Ze.info.id]!==!0}))},children:s.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:lt?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[Ct?s.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",Vt]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:lt?Ut:$t}),lt&&s.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:Ft})]}),s.jsx("span",{className:"text-right text-muted-foreground",children:Qt})]})}),Ye&&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:Ee=>{Ee.stopPropagation(),y(Ze.info.id,_t)},"aria-label":e(it?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(it?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:it?s.jsx(E,{name:"check",className:"size-3.5"}):s.jsx(E,{name:"file-copy",className:"size-3.5"})})}),s.jsx(Qf,{language:"json",code:_t,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},Ze.info.id)},t[186]=l,t[187]=i,t[188]=e,t[189]=n,t[190]=ht):ht=t[190],Tt=[...g].reverse().map(ht),t[180]=l,t[181]=i,t[182]=g,t[183]=e,t[184]=n,t[185]=Tt}else Tt=t[185];let wt;t[191]!==Tt?(wt=s.jsx("div",{className:"mt-2.5 space-y-1",children:Tt}),t[191]=Tt,t[192]=wt):wt=t[192];let St;t[193]!==Mt||t[194]!==wt?(St=s.jsxs("div",{children:[Mt,wt]}),t[193]=Mt,t[194]=wt,t[195]=St):St=t[195];let vt;return t[196]!==ke||t[197]!==oe||t[198]!==He||t[199]!==gt||t[200]!==It||t[201]!==St?(vt=s.jsx("div",{className:"h-full overflow-y-auto bg-background",children:s.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[ke,oe,He,gt,It,St]})}),t[196]=ke,t[197]=oe,t[198]=He,t[199]=gt,t[200]=It,t[201]=St,t[202]=vt):vt=t[202],vt};function Py(t){return t.timeFormatPreference}function Dy(t){return t.currentSessionId}function Ty(t){return t.currentSessionDirectory}function Iy(t){return t.providers}function Ry(t){return Object.keys(t).length>0?{}:t}function Ey(t){return Xr(t.info).role==="assistant"}function My(t){return Xr(t.info).isUser}function Oy(t,e){const n=En(e.info.cost);return t+n}function By(t){return Xr(t.info).isUser&&typeof t.info.system=="string"}function Fy(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 _y(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)}%`:Un(t.value):"—"})]},t.label)}const Uu=new Set(["localhost","127.0.0.1","0.0.0.0","::1","[::1]"]),Ly=t=>{const e=t.split("/")[0]?.split("?")[0]??"",n=e.startsWith("[")?e.slice(0,e.indexOf("]")+1):e.split(":")[0]??"";return Uu.has(n.toLowerCase())},an="about:blank",hr=t=>{const e=t.trim();if(!e)return an;const n=e.includes("://")?e:`${Ly(e)?"http":"https"}://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?an:r.toString()}catch{return an}},Sr=t=>{try{return Uu.has(new URL(t).hostname.toLowerCase())}catch{return!1}},Va=t=>{if(!t||t===an)return"";try{return new URL(t).host||t}catch{return t}},$y=new Set([-2,-7,-101,-102,-104,-109,-118,-324]),Wy=(t,e)=>$y.has(t)&&Sr(e),zy=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"},Vy=async t=>{try{const e=await cs("/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(zy)}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},Uy=async t=>{try{const e=await cs("/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}},Ky=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}},Hy=({announced:t,discovered:e})=>{const n=new Map;for(const r of t){const i=Ky(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)},ea="__openchamberBrowserAnnotationActive",Gy=`(() => {
|
|
47
|
-
try {
|
|
48
|
-
var host = document.querySelector('[data-openchamber-annotation]');
|
|
49
|
-
if (host && host.parentNode) host.parentNode.removeChild(host);
|
|
50
|
-
} catch (error) { /* page navigated away */ }
|
|
51
|
-
try {
|
|
52
|
-
var cursor = document.getElementById('openchamber-annotation-cursor');
|
|
53
|
-
if (cursor && cursor.parentNode) cursor.parentNode.removeChild(cursor);
|
|
54
|
-
} catch (error) { /* page navigated away */ }
|
|
55
|
-
try { delete window['${ea}']; } catch (error) { /* non-configurable */ }
|
|
56
|
-
})();`,qy=(t,e)=>{const n=JSON.stringify({theme:t,labels:e});return String.raw`new Promise((resolve) => {
|
|
57
|
-
var CONFIG = ${n};
|
|
58
|
-
var THEME = CONFIG.theme;
|
|
59
|
-
var LABELS = CONFIG.labels;
|
|
60
|
-
var OVERLAY_ATTR = 'data-openchamber-annotation';
|
|
61
|
-
var Z_OVERLAY = 2147483646;
|
|
62
|
-
var MAX_TEXT = 400;
|
|
63
|
-
var MIN_RECT = 3;
|
|
64
|
-
var EDITOR_GAP = 10;
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
var stale = document.querySelector('[' + OVERLAY_ATTR + ']');
|
|
68
|
-
if (stale && stale.parentNode) stale.parentNode.removeChild(stale);
|
|
69
|
-
} catch (error) { /* nothing to clean */ }
|
|
70
|
-
|
|
71
|
-
window['${ea}'] = true;
|
|
72
|
-
|
|
73
|
-
var counter = 0;
|
|
74
|
-
var nextId = function (prefix) { counter += 1; return prefix + '-' + counter; };
|
|
75
|
-
|
|
76
|
-
var selected = null;
|
|
77
|
-
var regions = [];
|
|
78
|
-
var strokes = [];
|
|
79
|
-
var tool = 'select';
|
|
80
|
-
var settled = false;
|
|
81
|
-
|
|
82
|
-
// ---------------------------------------------------------------- geometry
|
|
83
|
-
|
|
84
|
-
var rectFrom = function (domRect) {
|
|
85
|
-
return { x: domRect.left, y: domRect.top, width: domRect.width, height: domRect.height };
|
|
86
|
-
};
|
|
87
|
-
var normalizeRect = function (ax, ay, bx, by) {
|
|
88
|
-
return { x: Math.min(ax, bx), y: Math.min(ay, by), width: Math.abs(bx - ax), height: Math.abs(by - ay) };
|
|
89
|
-
};
|
|
90
|
-
var usableRect = function (rect) { return rect.width >= MIN_RECT && rect.height >= MIN_RECT; };
|
|
91
|
-
|
|
92
|
-
// ------------------------------------------------------------- description
|
|
93
|
-
|
|
94
|
-
var isOverlayNode = function (element) {
|
|
95
|
-
var node = element;
|
|
96
|
-
while (node) {
|
|
97
|
-
if (node.nodeType === 1 && node.hasAttribute && node.hasAttribute(OVERLAY_ATTR)) return true;
|
|
98
|
-
node = node.parentNode || (node.host || null);
|
|
99
|
-
}
|
|
100
|
-
return false;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
var elementFromPoint = function (x, y) {
|
|
104
|
-
var found = document.elementFromPoint(x, y);
|
|
105
|
-
if (!found || isOverlayNode(found)) return null;
|
|
106
|
-
return found;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
var selectorPart = function (element) {
|
|
110
|
-
var part = element.tagName.toLowerCase();
|
|
111
|
-
if (element.id) return part + '#' + element.id;
|
|
112
|
-
var className = typeof element.className === 'string' ? element.className.trim() : '';
|
|
113
|
-
if (className) {
|
|
114
|
-
var first = className.split(/\s+/).filter(Boolean).slice(0, 2).join('.');
|
|
115
|
-
if (first) part += '.' + first;
|
|
116
|
-
}
|
|
117
|
-
return part;
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
var buildSelector = function (element) {
|
|
121
|
-
if (element.id) return '#' + element.id;
|
|
122
|
-
var parts = [];
|
|
123
|
-
var node = element;
|
|
124
|
-
var depth = 0;
|
|
125
|
-
while (node && node.nodeType === 1 && depth < 5) {
|
|
126
|
-
var part = selectorPart(node);
|
|
127
|
-
var parent = node.parentElement;
|
|
128
|
-
if (parent) {
|
|
129
|
-
var siblings = Array.prototype.filter.call(parent.children, function (child) {
|
|
130
|
-
return child.tagName === node.tagName;
|
|
131
|
-
});
|
|
132
|
-
if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
|
|
133
|
-
}
|
|
134
|
-
parts.unshift(part);
|
|
135
|
-
if (node.id) break;
|
|
136
|
-
node = parent;
|
|
137
|
-
depth += 1;
|
|
138
|
-
}
|
|
139
|
-
return parts.join(' > ');
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
var INTERESTING_ATTRS = ['id', 'class', 'name', 'type', 'href', 'src', 'alt', 'title', 'role', 'placeholder', 'aria-label', 'data-testid'];
|
|
143
|
-
var STYLE_PROPS = [
|
|
144
|
-
'display', 'position', 'color', 'backgroundColor', 'fontSize', 'fontWeight', 'fontFamily',
|
|
145
|
-
'lineHeight', 'padding', 'margin', 'border', 'borderRadius', 'width', 'height', 'opacity',
|
|
146
|
-
'zIndex', 'flexDirection', 'justifyContent', 'alignItems', 'gap', 'textAlign'
|
|
147
|
-
];
|
|
148
|
-
|
|
149
|
-
var describe = function (element) {
|
|
150
|
-
var computed = window.getComputedStyle(element);
|
|
151
|
-
var attributes = {};
|
|
152
|
-
for (var i = 0; i < INTERESTING_ATTRS.length; i += 1) {
|
|
153
|
-
var name = INTERESTING_ATTRS[i];
|
|
154
|
-
var value = element.getAttribute(name);
|
|
155
|
-
if (value) attributes[name] = String(value).slice(0, 200);
|
|
156
|
-
}
|
|
157
|
-
var computedStyle = {};
|
|
158
|
-
for (var j = 0; j < STYLE_PROPS.length; j += 1) {
|
|
159
|
-
var prop = STYLE_PROPS[j];
|
|
160
|
-
computedStyle[prop] = String(computed[prop] == null ? '' : computed[prop]);
|
|
161
|
-
}
|
|
162
|
-
var ancestry = [];
|
|
163
|
-
var node = element.parentElement;
|
|
164
|
-
var depth = 0;
|
|
165
|
-
while (node && node.nodeType === 1 && depth < 4) {
|
|
166
|
-
var entry = { tag: node.tagName.toLowerCase(), selectorPart: selectorPart(node) };
|
|
167
|
-
if (node.id) entry.id = node.id;
|
|
168
|
-
var cls = typeof node.className === 'string' ? node.className.trim() : '';
|
|
169
|
-
if (cls) entry.className = cls.slice(0, 200);
|
|
170
|
-
ancestry.unshift(entry);
|
|
171
|
-
node = node.parentElement;
|
|
172
|
-
depth += 1;
|
|
173
|
-
}
|
|
174
|
-
var box = element.getBoundingClientRect();
|
|
175
|
-
var text = (element.textContent == null ? '' : String(element.textContent)).replace(/\s+/g, ' ').trim();
|
|
176
|
-
return {
|
|
177
|
-
tag: element.tagName.toLowerCase(),
|
|
178
|
-
text: text.slice(0, MAX_TEXT),
|
|
179
|
-
selector: buildSelector(element),
|
|
180
|
-
path: ancestry.map(function (e) { return e.selectorPart; }).concat([selectorPart(element)]).join(' > '),
|
|
181
|
-
bounds: rectFrom(box),
|
|
182
|
-
center: { x: box.left + box.width / 2, y: box.top + box.height / 2 },
|
|
183
|
-
attributes: attributes,
|
|
184
|
-
computedStyle: computedStyle,
|
|
185
|
-
ancestry: ancestry
|
|
186
|
-
};
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
// ------------------------------------------------------------------ chrome
|
|
190
|
-
|
|
191
|
-
var host = document.createElement('div');
|
|
192
|
-
host.setAttribute(OVERLAY_ATTR, '');
|
|
193
|
-
host.style.cssText = 'position:fixed;inset:0;z-index:' + Z_OVERLAY + ';pointer-events:none';
|
|
194
|
-
var shadow = host.attachShadow({ mode: 'closed' });
|
|
195
|
-
|
|
196
|
-
var style = document.createElement('style');
|
|
197
|
-
style.textContent = [
|
|
198
|
-
':host{all:initial}',
|
|
199
|
-
'*{box-sizing:border-box;font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif}',
|
|
200
|
-
'.layer{position:fixed;inset:0;pointer-events:none}',
|
|
201
|
-
'.box{position:fixed;left:0;top:0;display:none;pointer-events:none;border:1.5px solid ' + THEME.primary + ';background:' + THEME.primarySoft + ';border-radius:2px}',
|
|
202
|
-
'.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}',
|
|
203
|
-
'.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}',
|
|
204
|
-
'.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}',
|
|
205
|
-
'.tools button:hover{background:' + THEME.primaryFaint + '}',
|
|
206
|
-
'.tools button[aria-pressed="true"]{background:' + THEME.primarySoft + ';color:' + THEME.primary + ';font-weight:600}',
|
|
207
|
-
'.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}',
|
|
208
|
-
'.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}',
|
|
209
|
-
'.editor textarea::placeholder{color:' + THEME.mutedText + '}',
|
|
210
|
-
'.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}',
|
|
211
|
-
'.editor button svg{width:16px;height:16px;display:block}',
|
|
212
|
-
'.editor button[disabled]{opacity:.5;cursor:default}'
|
|
213
|
-
].join('');
|
|
214
|
-
shadow.appendChild(style);
|
|
215
|
-
|
|
216
|
-
var cursorStyle = document.createElement('style');
|
|
217
|
-
cursorStyle.id = 'openchamber-annotation-cursor';
|
|
218
|
-
document.head.appendChild(cursorStyle);
|
|
219
|
-
var setCursor = function (value) {
|
|
220
|
-
cursorStyle.textContent = value ? '*{cursor:' + value + ' !important}' : '';
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
var svgNS = 'http://www.w3.org/2000/svg';
|
|
224
|
-
var svg = document.createElementNS(svgNS, 'svg');
|
|
225
|
-
svg.setAttribute('class', 'layer');
|
|
226
|
-
svg.style.overflow = 'visible';
|
|
227
|
-
shadow.appendChild(svg);
|
|
228
|
-
|
|
229
|
-
var hoverBox = document.createElement('div');
|
|
230
|
-
hoverBox.className = 'box';
|
|
231
|
-
var hoverLabel = document.createElement('div');
|
|
232
|
-
hoverLabel.className = 'label';
|
|
233
|
-
var marqueeBox = document.createElement('div');
|
|
234
|
-
marqueeBox.className = 'box';
|
|
235
|
-
shadow.append(hoverBox, hoverLabel, marqueeBox);
|
|
236
|
-
|
|
237
|
-
var positionBox = function (node, rect) {
|
|
238
|
-
node.style.display = 'block';
|
|
239
|
-
node.style.transform = 'translate(' + rect.x + 'px,' + rect.y + 'px)';
|
|
240
|
-
node.style.width = rect.width + 'px';
|
|
241
|
-
node.style.height = rect.height + 'px';
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
var tools = document.createElement('div');
|
|
245
|
-
tools.className = 'tools';
|
|
246
|
-
shadow.appendChild(tools);
|
|
247
|
-
|
|
248
|
-
var toolButtons = {};
|
|
249
|
-
[['select', LABELS.select], ['marquee', LABELS.marquee], ['draw', LABELS.draw]].forEach(function (entry) {
|
|
250
|
-
var button = document.createElement('button');
|
|
251
|
-
button.type = 'button';
|
|
252
|
-
button.textContent = entry[1];
|
|
253
|
-
button.addEventListener('click', function () { setTool(entry[0]); });
|
|
254
|
-
toolButtons[entry[0]] = button;
|
|
255
|
-
tools.appendChild(button);
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
var editor = document.createElement('div');
|
|
259
|
-
editor.className = 'editor';
|
|
260
|
-
shadow.appendChild(editor);
|
|
261
|
-
|
|
262
|
-
var comment = document.createElement('textarea');
|
|
263
|
-
comment.rows = 1;
|
|
264
|
-
comment.placeholder = LABELS.commentPlaceholder;
|
|
265
|
-
var submit = document.createElement('button');
|
|
266
|
-
submit.type = 'button';
|
|
267
|
-
// Icon-only attach button (Remix attachment-2), matching the chat comment
|
|
268
|
-
// input; the localized label stays available to assistive tech.
|
|
269
|
-
submit.setAttribute('aria-label', LABELS.submit);
|
|
270
|
-
submit.title = LABELS.submit;
|
|
271
|
-
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>';
|
|
272
|
-
editor.append(comment, submit);
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Grows the box with its content.
|
|
276
|
-
*
|
|
277
|
-
* A hidden element reports scrollHeight 0, so measuring one collapses the
|
|
278
|
-
* field to nothing — which is what left a sliver of a click target and an
|
|
279
|
-
* invisible caret. Measuring only while visible, and never below the CSS
|
|
280
|
-
* min-height, keeps it usable.
|
|
281
|
-
*/
|
|
282
|
-
var resizeComment = function () {
|
|
283
|
-
if (editor.style.display === 'none') return;
|
|
284
|
-
comment.style.height = 'auto';
|
|
285
|
-
comment.style.height = Math.max(32, Math.min(comment.scrollHeight, 104)) + 'px';
|
|
286
|
-
};
|
|
287
|
-
comment.addEventListener('input', resizeComment);
|
|
288
|
-
|
|
289
|
-
// -------------------------------------------------------------- selection
|
|
290
|
-
|
|
291
|
-
var lastTargetRect = null;
|
|
292
|
-
|
|
293
|
-
/** Places the comment box under whatever was just marked, kept on screen. */
|
|
294
|
-
var positionEditor = function () {
|
|
295
|
-
if (!lastTargetRect) {
|
|
296
|
-
editor.style.display = 'none';
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
var wasHidden = editor.style.display === 'none';
|
|
300
|
-
editor.style.display = 'flex';
|
|
301
|
-
// Measured now that it is laid out, not while it was still hidden.
|
|
302
|
-
if (wasHidden) resizeComment();
|
|
303
|
-
var box = editor.getBoundingClientRect();
|
|
304
|
-
var left = lastTargetRect.x + lastTargetRect.width / 2 - box.width / 2;
|
|
305
|
-
var top = lastTargetRect.y + lastTargetRect.height + EDITOR_GAP;
|
|
306
|
-
// Above the target when there is no room below, so the box is never left
|
|
307
|
-
// half off the bottom of the page.
|
|
308
|
-
if (top + box.height > window.innerHeight - 8) {
|
|
309
|
-
top = Math.max(8, lastTargetRect.y - box.height - EDITOR_GAP);
|
|
310
|
-
}
|
|
311
|
-
left = Math.max(8, Math.min(left, window.innerWidth - box.width - 8));
|
|
312
|
-
editor.style.transform = 'translate(' + Math.round(left) + 'px,' + Math.round(top) + 'px)';
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
/** Focus after layout: focusing a zero-height field puts the caret nowhere. */
|
|
316
|
-
var focusComment = function () {
|
|
317
|
-
requestAnimationFrame(function () {
|
|
318
|
-
try {
|
|
319
|
-
comment.focus({ preventScroll: true });
|
|
320
|
-
comment.setSelectionRange(comment.value.length, comment.value.length);
|
|
321
|
-
} catch (error) { /* field went away */ }
|
|
322
|
-
});
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
var hasTargets = function () {
|
|
326
|
-
return Boolean(selected) || regions.length > 0 || strokes.length > 0;
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
var syncChrome = function () {
|
|
330
|
-
submit.disabled = !hasTargets();
|
|
331
|
-
if (!hasTargets()) {
|
|
332
|
-
lastTargetRect = null;
|
|
333
|
-
editor.style.display = 'none';
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
positionEditor();
|
|
337
|
-
};
|
|
338
|
-
|
|
339
|
-
var syncSelectionVisuals = function () {
|
|
340
|
-
if (!selected) return;
|
|
341
|
-
var rect = rectFrom(selected.element.getBoundingClientRect());
|
|
342
|
-
if (!usableRect(rect)) {
|
|
343
|
-
selected.outline.style.display = 'none';
|
|
344
|
-
selected.badge.style.display = 'none';
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
positionBox(selected.outline, rect);
|
|
348
|
-
selected.badge.style.display = 'block';
|
|
349
|
-
selected.badge.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
|
|
350
|
-
lastTargetRect = rect;
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
var dropSelection = function () {
|
|
354
|
-
if (!selected) return;
|
|
355
|
-
selected.outline.remove();
|
|
356
|
-
selected.badge.remove();
|
|
357
|
-
selected = null;
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
var selectElement = function (element) {
|
|
361
|
-
var wasSelected = selected && selected.element === element;
|
|
362
|
-
dropSelection();
|
|
363
|
-
if (wasSelected) {
|
|
364
|
-
// Clicking the chosen element again clears it, so a misclick costs one
|
|
365
|
-
// click rather than starting over.
|
|
366
|
-
lastTargetRect = null;
|
|
367
|
-
syncChrome();
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
var outline = document.createElement('div');
|
|
371
|
-
outline.className = 'box';
|
|
372
|
-
var badge = document.createElement('div');
|
|
373
|
-
badge.className = 'label';
|
|
374
|
-
badge.textContent = selectorPart(element);
|
|
375
|
-
shadow.append(outline, badge);
|
|
376
|
-
selected = { id: nextId('element'), element: element, outline: outline, badge: badge };
|
|
377
|
-
syncSelectionVisuals();
|
|
378
|
-
syncChrome();
|
|
379
|
-
focusComment();
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
var setTool = function (next) {
|
|
383
|
-
tool = next;
|
|
384
|
-
hoverBox.style.display = 'none';
|
|
385
|
-
hoverLabel.style.display = 'none';
|
|
386
|
-
marqueeBox.style.display = 'none';
|
|
387
|
-
setCursor(next === 'select' ? '' : 'crosshair');
|
|
388
|
-
for (var key in toolButtons) {
|
|
389
|
-
if (Object.prototype.hasOwnProperty.call(toolButtons, key)) {
|
|
390
|
-
toolButtons[key].setAttribute('aria-pressed', key === next ? 'true' : 'false');
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
// ------------------------------------------------------------- interaction
|
|
396
|
-
|
|
397
|
-
var drag = null;
|
|
398
|
-
|
|
399
|
-
var onPointerMove = function (event) {
|
|
400
|
-
if (drag) {
|
|
401
|
-
if (drag.kind === 'marquee') {
|
|
402
|
-
drag.rect = normalizeRect(drag.startX, drag.startY, event.clientX, event.clientY);
|
|
403
|
-
positionBox(marqueeBox, drag.rect);
|
|
404
|
-
} else if (drag.kind === 'draw') {
|
|
405
|
-
drag.points.push({ x: event.clientX, y: event.clientY });
|
|
406
|
-
drag.path.setAttribute('d', drag.points.map(function (point, index) {
|
|
407
|
-
return (index === 0 ? 'M' : 'L') + point.x + ' ' + point.y;
|
|
408
|
-
}).join(' '));
|
|
409
|
-
}
|
|
410
|
-
return;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
if (tool !== 'select') return;
|
|
414
|
-
var element = elementFromPoint(event.clientX, event.clientY);
|
|
415
|
-
if (!element) {
|
|
416
|
-
hoverBox.style.display = 'none';
|
|
417
|
-
hoverLabel.style.display = 'none';
|
|
418
|
-
return;
|
|
419
|
-
}
|
|
420
|
-
var rect = rectFrom(element.getBoundingClientRect());
|
|
421
|
-
positionBox(hoverBox, rect);
|
|
422
|
-
hoverLabel.textContent = selectorPart(element);
|
|
423
|
-
hoverLabel.style.display = 'block';
|
|
424
|
-
hoverLabel.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
var onPointerDown = function (event) {
|
|
428
|
-
if (event.button !== 0) return;
|
|
429
|
-
if (isOverlayNode(event.target)) return;
|
|
430
|
-
event.preventDefault();
|
|
431
|
-
event.stopPropagation();
|
|
432
|
-
|
|
433
|
-
if (tool === 'select') {
|
|
434
|
-
var element = elementFromPoint(event.clientX, event.clientY);
|
|
435
|
-
if (element) selectElement(element);
|
|
436
|
-
return;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
if (tool === 'marquee') {
|
|
440
|
-
drag = { kind: 'marquee', startX: event.clientX, startY: event.clientY, rect: null };
|
|
441
|
-
return;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
var path = document.createElementNS(svgNS, 'path');
|
|
445
|
-
path.setAttribute('fill', 'none');
|
|
446
|
-
path.setAttribute('stroke', THEME.primary);
|
|
447
|
-
path.setAttribute('stroke-width', '2.5');
|
|
448
|
-
path.setAttribute('stroke-linecap', 'round');
|
|
449
|
-
path.setAttribute('stroke-linejoin', 'round');
|
|
450
|
-
svg.appendChild(path);
|
|
451
|
-
drag = { kind: 'draw', path: path, points: [{ x: event.clientX, y: event.clientY }] };
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
var onPointerUp = function () {
|
|
455
|
-
if (!drag) return;
|
|
456
|
-
var finished = drag;
|
|
457
|
-
drag = null;
|
|
458
|
-
|
|
459
|
-
if (finished.kind === 'marquee') {
|
|
460
|
-
marqueeBox.style.display = 'none';
|
|
461
|
-
var rect = finished.rect;
|
|
462
|
-
if (!rect || !usableRect(rect)) return;
|
|
463
|
-
// A region marks an area, not the elements inside it: expanding it into a
|
|
464
|
-
// selection made the result depend on the page's markup rather than on
|
|
465
|
-
// what was drawn.
|
|
466
|
-
regions.push({ id: nextId('region'), rect: rect });
|
|
467
|
-
var outline = document.createElementNS(svgNS, 'rect');
|
|
468
|
-
outline.setAttribute('x', String(rect.x));
|
|
469
|
-
outline.setAttribute('y', String(rect.y));
|
|
470
|
-
outline.setAttribute('width', String(rect.width));
|
|
471
|
-
outline.setAttribute('height', String(rect.height));
|
|
472
|
-
outline.style.fill = THEME.primarySoft;
|
|
473
|
-
outline.setAttribute('stroke', THEME.primary);
|
|
474
|
-
outline.setAttribute('stroke-width', '1.5');
|
|
475
|
-
outline.setAttribute('rx', '2');
|
|
476
|
-
svg.appendChild(outline);
|
|
477
|
-
lastTargetRect = rect;
|
|
478
|
-
syncChrome();
|
|
479
|
-
focusComment();
|
|
480
|
-
return;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
var points = finished.points;
|
|
484
|
-
if (points.length < 2) {
|
|
485
|
-
if (finished.path.parentNode) finished.path.parentNode.removeChild(finished.path);
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
var minX = points[0].x, minY = points[0].y, maxX = points[0].x, maxY = points[0].y;
|
|
489
|
-
for (var p = 1; p < points.length; p += 1) {
|
|
490
|
-
minX = Math.min(minX, points[p].x);
|
|
491
|
-
minY = Math.min(minY, points[p].y);
|
|
492
|
-
maxX = Math.max(maxX, points[p].x);
|
|
493
|
-
maxY = Math.max(maxY, points[p].y);
|
|
494
|
-
}
|
|
495
|
-
var bounds = { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
496
|
-
strokes.push({ id: nextId('stroke'), points: points, bounds: bounds });
|
|
497
|
-
lastTargetRect = bounds;
|
|
498
|
-
syncChrome();
|
|
499
|
-
focusComment();
|
|
500
|
-
};
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
* Swallows the page's own mouse handling while annotating.
|
|
504
|
-
*
|
|
505
|
-
* Blocking pointerdown is not enough: a click still follows it, so marking a
|
|
506
|
-
* button pressed that button and marking a link navigated away from the page
|
|
507
|
-
* being annotated. These are the events that reach page code, so these are
|
|
508
|
-
* the ones that have to stop.
|
|
509
|
-
*/
|
|
510
|
-
var blockPageInteraction = function (event) {
|
|
511
|
-
if (isOverlayNode(event.target)) return;
|
|
512
|
-
event.preventDefault();
|
|
513
|
-
event.stopPropagation();
|
|
514
|
-
};
|
|
515
|
-
var BLOCKED_EVENTS = ['click', 'auxclick', 'dblclick', 'mousedown', 'mouseup', 'contextmenu'];
|
|
516
|
-
|
|
517
|
-
var onScrollOrResize = function () {
|
|
518
|
-
syncSelectionVisuals();
|
|
519
|
-
positionEditor();
|
|
520
|
-
};
|
|
521
|
-
|
|
522
|
-
var onKeyDown = function (event) {
|
|
523
|
-
if (event.key === 'Escape') {
|
|
524
|
-
event.preventDefault();
|
|
525
|
-
event.stopImmediatePropagation();
|
|
526
|
-
finish(null);
|
|
527
|
-
}
|
|
528
|
-
};
|
|
529
|
-
|
|
530
|
-
var onCommentKeyDown = function (event) {
|
|
531
|
-
// Do not let the annotated page treat typed letters as its own shortcuts.
|
|
532
|
-
event.stopPropagation();
|
|
533
|
-
if (event.key === 'Enter' && !event.shiftKey) {
|
|
534
|
-
event.preventDefault();
|
|
535
|
-
attach();
|
|
536
|
-
}
|
|
537
|
-
};
|
|
538
|
-
|
|
539
|
-
document.addEventListener('pointermove', onPointerMove, true);
|
|
540
|
-
document.addEventListener('pointerdown', onPointerDown, true);
|
|
541
|
-
document.addEventListener('pointerup', onPointerUp, true);
|
|
542
|
-
BLOCKED_EVENTS.forEach(function (name) {
|
|
543
|
-
window.addEventListener(name, blockPageInteraction, { capture: true, passive: false });
|
|
544
|
-
});
|
|
545
|
-
window.addEventListener('scroll', onScrollOrResize, true);
|
|
546
|
-
window.addEventListener('resize', onScrollOrResize, true);
|
|
547
|
-
window.addEventListener('keydown', onKeyDown, true);
|
|
548
|
-
comment.addEventListener('keydown', onCommentKeyDown);
|
|
549
|
-
|
|
550
|
-
// ------------------------------------------------------------------ finish
|
|
551
|
-
|
|
552
|
-
var teardown = function () {
|
|
553
|
-
document.removeEventListener('pointermove', onPointerMove, true);
|
|
554
|
-
document.removeEventListener('pointerdown', onPointerDown, true);
|
|
555
|
-
document.removeEventListener('pointerup', onPointerUp, true);
|
|
556
|
-
BLOCKED_EVENTS.forEach(function (name) {
|
|
557
|
-
window.removeEventListener(name, blockPageInteraction, true);
|
|
558
|
-
});
|
|
559
|
-
window.removeEventListener('scroll', onScrollOrResize, true);
|
|
560
|
-
window.removeEventListener('resize', onScrollOrResize, true);
|
|
561
|
-
window.removeEventListener('keydown', onKeyDown, true);
|
|
562
|
-
comment.removeEventListener('keydown', onCommentKeyDown);
|
|
563
|
-
setCursor('');
|
|
564
|
-
if (cursorStyle.parentNode) cursorStyle.parentNode.removeChild(cursorStyle);
|
|
565
|
-
if (host.parentNode) host.parentNode.removeChild(host);
|
|
566
|
-
try { delete window['${ea}']; } catch (error) { /* non-configurable */ }
|
|
567
|
-
};
|
|
568
|
-
|
|
569
|
-
var finish = function (payload) {
|
|
570
|
-
if (settled) return;
|
|
571
|
-
settled = true;
|
|
572
|
-
teardown();
|
|
573
|
-
// Removing the chrome is not enough: the host screenshots this page right
|
|
574
|
-
// after we resolve, and the compositor can still hold a frame containing
|
|
575
|
-
// our outlines. Yield two frames so the page has actually repainted.
|
|
576
|
-
requestAnimationFrame(function () {
|
|
577
|
-
requestAnimationFrame(function () { resolve(payload); });
|
|
578
|
-
});
|
|
579
|
-
};
|
|
580
|
-
|
|
581
|
-
var attach = function () {
|
|
582
|
-
if (!hasTargets()) return;
|
|
583
|
-
finish({
|
|
584
|
-
id: 'annotation-' + Date.now(),
|
|
585
|
-
pageUrl: String(location.href),
|
|
586
|
-
pageTitle: String(document.title || ''),
|
|
587
|
-
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
588
|
-
devicePixelRatio: window.devicePixelRatio || 1,
|
|
589
|
-
comment: comment.value,
|
|
590
|
-
// Zero or one element, never more. Kept as a list so elements, regions
|
|
591
|
-
// and strokes stay one uniform shape for everything downstream.
|
|
592
|
-
elements: selected ? [{ id: selected.id, element: describe(selected.element) }] : [],
|
|
593
|
-
regions: regions.map(function (entry) { return { id: entry.id, rect: entry.rect }; }),
|
|
594
|
-
strokes: strokes.map(function (entry) {
|
|
595
|
-
return { id: entry.id, points: entry.points, bounds: entry.bounds };
|
|
596
|
-
})
|
|
597
|
-
});
|
|
598
|
-
};
|
|
599
|
-
|
|
600
|
-
submit.addEventListener('click', attach);
|
|
601
|
-
|
|
602
|
-
(document.body || document.documentElement).appendChild(host);
|
|
603
|
-
setTool('select');
|
|
604
|
-
syncChrome();
|
|
605
|
-
});`},Qy={kind:"idle"},bn=t=>typeof t=="object"&&t!==null,jn=t=>typeof t=="number"&&Number.isFinite(t),Jl=t=>bn(t)&&Object.values(t).every(e=>typeof e=="string"),Ua=t=>bn(t)&&jn(t.x)&&jn(t.y)&&jn(t.width)&&jn(t.height),Ku=t=>bn(t)&&jn(t.x)&&jn(t.y),Yy=t=>bn(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"),Xy=t=>bn(t)&&typeof t.tag=="string"&&typeof t.text=="string"&&typeof t.selector=="string"&&typeof t.path=="string"&&Ua(t.bounds)&&Ku(t.center)&&Jl(t.attributes)&&Jl(t.computedStyle)&&Array.isArray(t.ancestry)&&t.ancestry.every(Yy),Jy=t=>bn(t)&&typeof t.id=="string"&&Xy(t.element),Zy=t=>bn(t)&&typeof t.id=="string"&&Ua(t.rect),e1=t=>bn(t)&&typeof t.id=="string"&&Ua(t.bounds)&&Array.isArray(t.points)&&t.points.every(Ku),t1=t=>bn(t)&&typeof t.id=="string"&&typeof t.pageUrl=="string"&&typeof t.pageTitle=="string"&&typeof t.comment=="string"&&bn(t.viewport)&&jn(t.viewport.width)&&jn(t.viewport.height)&&jn(t.devicePixelRatio)&&Array.isArray(t.elements)&&t.elements.every(Jy)&&Array.isArray(t.regions)&&t.regions.every(Zy)&&Array.isArray(t.strokes)&&t.strokes.every(e1),s1=1600,n1=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}),r1=async({base64:t,mime:e,captureWidth:n,captureHeight:r,cssWidth:i,cssHeight:o,payload:l,accentColor:a,accentFill:u})=>{if(!t)return null;try{const d=await n1(`data:${e};base64,${t}`),h=Math.max(1,d.naturalWidth||n),f=Math.max(1,d.naturalHeight||r),g=h/Math.max(1,i||h),p=f/Math.max(1,o||f),w=Math.min(1,s1/h),v=document.createElement("canvas");v.width=Math.max(1,Math.floor(h*w)),v.height=Math.max(1,Math.floor(f*w));const x=v.getContext("2d");if(!x)return null;x.scale(w,w),x.drawImage(d,0,0,h,f);const m=N=>({x:N.x*g,y:N.y*p,width:N.width*g,height:N.height*p}),b=Math.max(2,2.5*g/Math.max(w,.2));x.strokeStyle=a,x.fillStyle=u;const y=N=>{const C=m(N);x.lineWidth=b,x.fillRect(C.x,C.y,C.width,C.height),x.strokeRect(C.x,C.y,C.width,C.height)};for(const N of l.elements)y(N.element.bounds);for(const N of l.regions)y(N.rect);for(const N of l.strokes)N.points.length<2||(x.beginPath(),N.points.forEach((C,k)=>{const A=C.x*g,P=C.y*p;k===0?x.moveTo(A,P):x.lineTo(A,P)}),x.lineCap="round",x.lineJoin="round",x.lineWidth=b*1.4,x.stroke());const S=await new Promise(N=>v.toBlob(N,"image/jpeg",.85));return S?new File([S],`browser-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch{return null}},o1="({ width: window.innerWidth, height: window.innerHeight })",i1=async t=>{try{const e=await t.executeJavaScript(o1,!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}},vo=async t=>{try{await t.executeJavaScript(Gy,!1)}catch{}},a1=async({host:t,theme:e,labels:n})=>{const r=qy(e,n),i=await t.executeJavaScript(r,!0);if(i==null)return null;if(!t1(i))return await vo(t),null;const o=i;try{const l=await i1(t)??o.viewport,a=await t.capturePage();if(!a||!a.base64)return{payload:o,screenshot:null};const u=await r1({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:u}}catch{return{payload:o,screenshot:null}}},rn={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)"},l1=()=>{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()}},c1=t=>{const e=l1();if(!e)return{...rn,colorScheme:t};try{const n=(a,u)=>e.read(`var(${a})`)||u,r=(a,u,d)=>e.read(`color-mix(in srgb, var(${a}) ${u}%, transparent)`)||d,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)`)||rn.glassSurface,glassFilter:`blur(${o}) saturate(${l})`,primary:n("--primary",rn.primary),primarySoft:r("--primary",16,rn.primarySoft),primaryFaint:r("--primary",10,rn.primaryFaint),primaryContrast:n("--primary-foreground",rn.primaryContrast),surface:n("--surface-background",rn.surface),surfaceElevated:n("--surface-elevated",rn.surfaceElevated),border:n("--border",rn.border),text:n("--foreground",rn.text),mutedText:n("--muted-foreground",rn.mutedText)}}catch{return{...rn,colorScheme:t}}finally{e.dispose()}};let pr=null,gr=null,jo=null,Kr=0,Lo=null;const fn=new Set,d1=3e4,u1=45e3,Hu=()=>{jo&&(clearTimeout(jo),jo=null)},Gu=()=>{if(gr||fn.size===0)return;const t=Math.min(1e3*Math.pow(2,Math.min(Kr,5)),d1);gr=setTimeout(()=>{gr=null,Kr+=1,Ka()},t)},Hr=()=>{Hu(),pr&&pr.close(),pr=null},Zl=()=>{Hu(),fn.size!==0&&(jo=setTimeout(()=>{Hr(),Gu()},u1))},m1=t=>{if(!t||t.trim().length===0)return null;try{const e=JSON.parse(t),n=typeof e?.type=="string"?e.type:"",r=e?.properties;return n?{type:n,properties:r}:null}catch{return null}},ao=t=>!t||typeof t!="object"?null:t,f1=t=>{if(t.type==="openchamber:event-stream-ready"){Kr=0;return}if(t.type==="openchamber:heartbeat")return;if(t.type==="openchamber:agent-memory-changed"){const u=ao(t.properties),h={type:"agent-memory-changed",scope:u?.scope==="project"?"project":"global",...typeof u?.projectId=="string"&&u.projectId.length>0?{projectId:u.projectId}:{}};for(const f of fn)f(h);return}if(t.type==="openchamber:session-created"){const u=ao(t.properties),d=typeof u?.sessionId=="string"?u.sessionId:"",h=typeof u?.directory=="string"?u.directory:"";if(!d||!h)return;const f={type:"session-created",sessionId:d,directory:h,createdAt:typeof u?.createdAt=="number"?u.createdAt:Date.now(),promptDispatched:u?.promptDispatched===!0,dispatchedAsCommand:u?.dispatchedAsCommand===!0,...typeof u?.projectId=="string"&&u.projectId.length>0?{projectId:u.projectId}:{}};for(const g of fn)g(f);return}if(t.type==="openchamber:browser-control-request"){const u=ao(t.properties),d=typeof u?.requestId=="string"?u.requestId:"",h=typeof u?.action=="string"?u.action:"";if(!d||!h)return;const f=u?.parameters,g={type:"browser-control-request",requestId:d,action:h,parameters:f&&typeof f=="object"&&!Array.isArray(f)?f:{}};for(const p of fn)p(g);return}if(t.type!=="openchamber:scheduled-task-ran")return;const e=ao(t.properties),n=typeof e?.projectId=="string"?e.projectId:"",r=typeof e?.taskId=="string"?e.taskId:"",i=typeof e?.ranAt=="number"?e.ranAt:Date.now(),o=e?.status,l=o==="running"||o==="error"?o:"success";if(!n||!r)return;const a={type:"scheduled-task-ran",projectId:n,taskId:r,ranAt:i,status:l,...typeof e?.sessionId=="string"&&e.sessionId.length>0?{sessionId:e.sessionId}:{}};for(const u of fn)u(a)},Ka=()=>{if(typeof window>"u"||fn.size===0||typeof EventSource!="function"||pr&&pr.readyState!==EventSource.CLOSED)return;Hr();const t=typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,e=new EventSource(xa().sse("/api/openchamber/events",t?{browser:"1"}:void 0));e.onopen=()=>{Zl()},e.onmessage=n=>{Zl();const r=m1(n.data);r&&f1(r)},e.onerror=()=>{Hr(),Gu()},pr=e},h1=()=>{Lo||typeof window>"u"||(Lo=Qo(()=>{Hr(),Kr=0,Ka()}))},p1=()=>{Lo?.(),Lo=null},Jr=t=>(fn.add(t),h1(),Ka(),()=>{fn.delete(t),fn.size===0&&(gr&&(clearTimeout(gr),gr=null),Kr=0,Hr(),p1())}),g1=2e3,x1=50;let Yn=null,xr=null,Br=null;const b1=async t=>{try{const e=await cs("/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}},rr=async(t,e)=>{try{const n=await cs("/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)}},y1=async(t=g1)=>{const e=Date.now()+t;for(;!Yn&&Date.now()<e;)await new Promise(n=>setTimeout(n,x1));return Yn},w1=async t=>{const e=t.action==="browser.open",n=Yn;if(!(!n&&!(e&&xr))&&await b1(t.requestId))try{if(e&&!n){const i=typeof t.parameters.url=="string"?t.parameters.url:"";if(!i){await rr(t.requestId,{ok:!1,error:"url is required"});return}xr?.(i);const o=typeof t.parameters.viewport=="string"?t.parameters.viewport:"";if(!o||o==="fill"){await rr(t.requestId,{ok:!0,data:{url:i,opened:!0}});return}const l=await y1();if(!l){await rr(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}),u=a&&typeof a=="object"?a.viewport??null:null;await rr(t.requestId,{ok:!0,data:{url:i,opened:!0,viewportApplied:!0,viewport:u}});return}const r=await n.run(t.action,t.parameters);await rr(t.requestId,{ok:!0,data:r})}catch(r){await rr(t.requestId,{ok:!1,error:r instanceof Error?r.message:String(r)})}},qu=()=>{Br||(Br=Jr(t=>{t.type==="browser-control-request"&&w1({requestId:t.requestId,action:t.action,parameters:t.parameters})}))},Qu=()=>{Yn||xr||!Br||(Br(),Br=null)},S1=t=>(Yn=t,qu(),()=>{Yn===t&&(Yn=null),Qu()}),v1=t=>(xr=t,qu(),()=>{xr===t&&(xr=null),Qu()}),j1=50,k1=6,C1=2048,N1=200,Yu=t=>{const e=hr(String(t??"").trim());if(!e||e.length>C1)return"";try{const n=new URL(e);return n.protocol!=="http:"&&n.protocol!=="https:"?"":n.toString()}catch{return""}},A1=(t,e)=>{const n=Yu(e.url);if(!n)return t;const r=t.find(l=>l.url===n),i=String(e.title??"").trim().slice(0,N1)||r?.title||"";return[{url:n,title:i,lastVisitedAt:e.at},...t.filter(l=>l.url!==n)].slice(0,j1)},P1=(t,e)=>{const n=Yu(e);return t.filter(r=>r.url!==n)},D1=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),Xu=(t,e,n=k1)=>{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=D1(l);return l.url===r||a===o?!1:a.includes(o)}).slice(0,n)},ec=20,ko=t=>{const e=dt((t||"").trim());return e?JSON.stringify([xs(),e]):""},T1=t=>{const e=Object.keys(t);if(e.length<=ec)return t;const n=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,i)=>i[1]-r[1]).slice(0,ec);return Object.fromEntries(n.map(([r])=>[r,t[r]??[]]))},br=tr()(Ig(t=>({byProject:{},recordVisit:(e,n)=>{const r=ko(e);r&&t(i=>{const o=i.byProject[r]??[],l=A1(o,{...n,at:Date.now()});return l===o?i:{byProject:T1({...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]:P1(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:sf(),partialize:t=>({byProject:t.byProject})})),I1=[],Ju=t=>e=>{const n=ko(t);return(n?e.byProject[n]:void 0)??I1},ta=new Map,oi=new Map,Xn=new Map,Jn=new Set,R1=async(t,e)=>{if(!Xa()){Jn.delete(t),ir(t,{type:"close"});return}if(await nf(Nn()),!Jn.has(t)||!Xa())return;const n=xa().websocket(`/api/dev-tunnel?port=${e}`),r=rf(n);Xn.set(t,r),r.binaryType="arraybuffer",r.onopen=()=>ir(t,{type:"ready"}),r.onmessage=i=>ir(t,{type:"data",data:i.data instanceof ArrayBuffer?i.data:new TextEncoder().encode(i.data)}),r.onerror=()=>ir(t,{type:"close"}),r.onclose=()=>{Jn.delete(t),Xn.delete(t),ir(t,{type:"close"})}};Yf(({connectionId:t,remotePort:e,message:n})=>{switch(n.type){case"data":{const r=Xn.get(t);r&&n.data&&r.send(n.data);return}case"close":Jn.delete(t),Xn.get(t)?.close(),Xn.delete(t);return;case"connect":Jn.add(t),R1(t,e).catch(()=>{Jn.delete(t),ir(t,{type:"close"})})}});const Zu=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,em=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:!Sr(e.toString())}catch{return!1}},tm=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}},tc=(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}},sc=(t,e)=>{try{oi.set(e,new URL(t).origin)}catch{}};class Fr extends Error{constructor(e){super(e),this.name="DevTunnelUnavailableError"}}const nc=async t=>{if(!t||!Zu()||!Sr(t))return t;const e=Nn();if(!em(e))return t;const n=tm(t);if(!n)return t;const r=`${e}|${n}`,i=ta.get(r);if(i)return sc(t,i),tc(t,i);try{const o=await mr("desktop_dev_tunnel_open",{baseUrl:e,port:n,relay:of(),targetKey:xs(),clientToken:Lr(),requestHeaders:hd()});if(!o||!Number.isInteger(o.localPort)||o.localPort<=0)throw new Fr(t);return ta.set(r,o.localPort),sc(t,o.localPort),tc(t,o.localPort)}catch(o){throw o instanceof Fr?o:new Fr(t)}},rc=t=>{if(!t||!Zu()||!Sr(t)||!em(Nn()))return!1;const e=tm(t);return e>0&&!oi.has(e)},Pr=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}},E1=()=>{ta.clear(),oi.clear(),Jn.clear();for(const t of Xn.values())t.close();Xn.clear(),mr("desktop_relay_dev_tunnel_close_all").catch(()=>{})};typeof window<"u"&&Qo(E1);const oc=6e3,M1=120,O1=80,B1=`
|
|
606
|
-
var MAX_ELEMENTS = ${M1};
|
|
607
|
-
var MAX_LABEL_CHARS = ${O1};
|
|
608
|
-
var visible = function (element) {
|
|
609
|
-
var rect = element.getBoundingClientRect();
|
|
610
|
-
if (rect.width < 1 || rect.height < 1) return false;
|
|
611
|
-
var style = window.getComputedStyle(element);
|
|
612
|
-
return style.visibility !== 'hidden' && style.display !== 'none' && Number(style.opacity) !== 0;
|
|
613
|
-
};
|
|
614
|
-
var label = function (element) {
|
|
615
|
-
var aria = element.getAttribute('aria-label');
|
|
616
|
-
if (aria) return aria.trim();
|
|
617
|
-
var value = element.getAttribute('value');
|
|
618
|
-
var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
619
|
-
if (text) return text.slice(0, MAX_LABEL_CHARS);
|
|
620
|
-
if (value) return String(value).slice(0, MAX_LABEL_CHARS);
|
|
621
|
-
var placeholder = element.getAttribute('placeholder');
|
|
622
|
-
return placeholder ? placeholder.trim().slice(0, MAX_LABEL_CHARS) : '';
|
|
623
|
-
};
|
|
624
|
-
var isUnique = function (selector) {
|
|
625
|
-
try {
|
|
626
|
-
return document.querySelectorAll(selector).length === 1;
|
|
627
|
-
} catch (error) {
|
|
628
|
-
return false;
|
|
629
|
-
}
|
|
630
|
-
};
|
|
631
|
-
|
|
632
|
-
/**
|
|
633
|
-
* Names an element by what it is, falling back to where it sits.
|
|
634
|
-
*
|
|
635
|
-
* A positional chain like 'main > section:nth-of-type(3) > div > a' survives
|
|
636
|
-
* only until the markup shifts, and says nothing about what it points at.
|
|
637
|
-
* Anything the page states about identity — an id, a test id, an accessible
|
|
638
|
-
* name — outlives edits and reads as the thing it selects. The chain remains
|
|
639
|
-
* as the last resort, because something always has to work.
|
|
640
|
-
*/
|
|
641
|
-
var cssPath = function (element) {
|
|
642
|
-
var tag = element.tagName.toLowerCase();
|
|
643
|
-
|
|
644
|
-
if (element.id) {
|
|
645
|
-
var byId = '#' + CSS.escape(element.id);
|
|
646
|
-
if (isUnique(byId)) return byId;
|
|
647
|
-
}
|
|
648
|
-
var stableAttrs = ['data-testid', 'data-test-id', 'data-test', 'name', 'aria-label'];
|
|
649
|
-
for (var a = 0; a < stableAttrs.length; a += 1) {
|
|
650
|
-
var value = element.getAttribute(stableAttrs[a]);
|
|
651
|
-
if (!value) continue;
|
|
652
|
-
var raw = String(value);
|
|
653
|
-
// A value containing a quote would need escaping for no real gain: such
|
|
654
|
-
// attributes are rare, and the positional chain still covers them.
|
|
655
|
-
if (raw.indexOf('"') !== -1) continue;
|
|
656
|
-
var byAttr = tag + '[' + stableAttrs[a] + '="' + raw + '"]';
|
|
657
|
-
if (isUnique(byAttr)) return byAttr;
|
|
658
|
-
}
|
|
659
|
-
var className = typeof element.className === 'string' ? element.className.trim() : '';
|
|
660
|
-
if (className) {
|
|
661
|
-
var classes = className.split(/\\s+/).filter(Boolean);
|
|
662
|
-
for (var c = 0; c < classes.length; c += 1) {
|
|
663
|
-
var byClass = tag + '.' + CSS.escape(classes[c]);
|
|
664
|
-
if (isUnique(byClass)) return byClass;
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
var parts = [];
|
|
669
|
-
var node = element;
|
|
670
|
-
var depth = 0;
|
|
671
|
-
while (node && node.nodeType === 1 && depth < 6) {
|
|
672
|
-
var part = node.tagName.toLowerCase();
|
|
673
|
-
var parent = node.parentElement;
|
|
674
|
-
if (!parent) { parts.unshift(part); break; }
|
|
675
|
-
var siblings = Array.prototype.filter.call(parent.children, function (child) {
|
|
676
|
-
return child.tagName === node.tagName;
|
|
677
|
-
});
|
|
678
|
-
if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
|
|
679
|
-
parts.unshift(part);
|
|
680
|
-
if (node.id) { parts[0] = '#' + CSS.escape(node.id); break; }
|
|
681
|
-
node = parent;
|
|
682
|
-
depth += 1;
|
|
683
|
-
}
|
|
684
|
-
return parts.join(' > ');
|
|
685
|
-
};
|
|
686
|
-
|
|
687
|
-
/** What a screen reader would announce, or '' when there is nothing to say. */
|
|
688
|
-
var accessibleName = function (element) {
|
|
689
|
-
var aria = element.getAttribute('aria-label');
|
|
690
|
-
if (aria && aria.trim()) return aria.trim();
|
|
691
|
-
var labelled = element.getAttribute('aria-labelledby');
|
|
692
|
-
if (labelled) {
|
|
693
|
-
var source = document.getElementById(labelled.split(/\\s+/)[0]);
|
|
694
|
-
if (source && (source.innerText || '').trim()) return source.innerText.trim();
|
|
695
|
-
}
|
|
696
|
-
var title = element.getAttribute('title');
|
|
697
|
-
if (title && title.trim()) return title.trim();
|
|
698
|
-
var alt = element.getAttribute('alt');
|
|
699
|
-
if (alt && alt.trim()) return alt.trim();
|
|
700
|
-
var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
701
|
-
if (text) return text;
|
|
702
|
-
var value = element.getAttribute('value');
|
|
703
|
-
return value && String(value).trim() ? String(value).trim() : '';
|
|
704
|
-
};
|
|
705
|
-
var findByText = function (needle) {
|
|
706
|
-
var wanted = String(needle).replace(/\\s+/g, ' ').trim().toLowerCase();
|
|
707
|
-
var candidates = document.querySelectorAll('a, button, [role="button"], [role="link"], input[type="submit"], input[type="button"], summary, label');
|
|
708
|
-
var exact = null;
|
|
709
|
-
var partial = null;
|
|
710
|
-
for (var i = 0; i < candidates.length; i += 1) {
|
|
711
|
-
var element = candidates[i];
|
|
712
|
-
if (!visible(element)) continue;
|
|
713
|
-
var text = label(element).toLowerCase();
|
|
714
|
-
if (!text) continue;
|
|
715
|
-
if (text === wanted) { exact = element; break; }
|
|
716
|
-
if (!partial && text.indexOf(wanted) !== -1) partial = element;
|
|
717
|
-
}
|
|
718
|
-
return exact || partial;
|
|
719
|
-
};
|
|
720
|
-
`,Zr=t=>`(() => {
|
|
721
|
-
${B1}
|
|
722
|
-
${t}
|
|
723
|
-
})()`,F1=({selector:t}={})=>Zr(`
|
|
724
|
-
var scopeSelector = ${JSON.stringify(t??"")};
|
|
725
|
-
var root = document;
|
|
726
|
-
if (scopeSelector) {
|
|
727
|
-
try { root = document.querySelector(scopeSelector); }
|
|
728
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + scopeSelector }; }
|
|
729
|
-
if (!root) return { ok: false, error: 'No element matches ' + scopeSelector };
|
|
730
|
-
}
|
|
731
|
-
var interactive = root.querySelectorAll('a[href], button, input, select, textarea, [role="button"], [role="link"], [role="tab"], [contenteditable="true"]');
|
|
732
|
-
var elements = [];
|
|
733
|
-
var visibleTotal = 0;
|
|
734
|
-
for (var i = 0; i < interactive.length; i += 1) {
|
|
735
|
-
var element = interactive[i];
|
|
736
|
-
if (!visible(element)) continue;
|
|
737
|
-
visibleTotal += 1;
|
|
738
|
-
if (elements.length >= MAX_ELEMENTS) continue;
|
|
739
|
-
|
|
740
|
-
var rect = element.getBoundingClientRect();
|
|
741
|
-
// Empty and default-valued fields are left out rather than serialized as
|
|
742
|
-
// "" and false. Repeated across a hundred entries that overhead dwarfed
|
|
743
|
-
// the information it carried.
|
|
744
|
-
var entry = {
|
|
745
|
-
selector: cssPath(element),
|
|
746
|
-
tag: element.tagName.toLowerCase(),
|
|
747
|
-
bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) }
|
|
748
|
-
};
|
|
749
|
-
// The list covers the whole document so anything can be clicked without
|
|
750
|
-
// scrolling to it first, which means bounds alone do not say what is on
|
|
751
|
-
// screen — a negative y reads as a bug otherwise.
|
|
752
|
-
if (rect.bottom > 0 && rect.top < window.innerHeight) entry.inViewport = true;
|
|
753
|
-
var type = element.getAttribute('type');
|
|
754
|
-
if (type) entry.type = type;
|
|
755
|
-
var role = element.getAttribute('role');
|
|
756
|
-
if (role) entry.role = role;
|
|
757
|
-
var labelText = label(element);
|
|
758
|
-
if (labelText) entry.label = labelText;
|
|
759
|
-
if (element.disabled === true) entry.disabled = true;
|
|
760
|
-
// Flagged rather than described: reporting the accessible name of every
|
|
761
|
-
// element would cost more than it tells, while its absence on something
|
|
762
|
-
// clickable is a defect worth naming.
|
|
763
|
-
if (!accessibleName(element)) entry.missingAccessibleName = true;
|
|
764
|
-
elements.push(entry);
|
|
765
|
-
}
|
|
766
|
-
var body = document.body ? (document.body.innerText || '') : '';
|
|
767
|
-
var text = body.replace(/\\n{3,}/g, '\\n\\n').trim();
|
|
768
|
-
var docEl = document.documentElement;
|
|
769
|
-
var result = {
|
|
770
|
-
ok: true,
|
|
771
|
-
url: String(location.href),
|
|
772
|
-
title: String(document.title || ''),
|
|
773
|
-
scope: scopeSelector || 'document',
|
|
774
|
-
scrollY: Math.round(window.scrollY),
|
|
775
|
-
maxScrollY: Math.max(0, Math.round(docEl.scrollHeight - window.innerHeight)),
|
|
776
|
-
text: text.slice(0, ${oc}),
|
|
777
|
-
elements: elements
|
|
778
|
-
};
|
|
779
|
-
// State what was dropped. A capped list that reports only its own length
|
|
780
|
-
// reads as the whole page, and the agent acts as if it had seen everything.
|
|
781
|
-
if (text.length > ${oc}) {
|
|
782
|
-
result.textTruncated = true;
|
|
783
|
-
result.textTotalChars = text.length;
|
|
784
|
-
}
|
|
785
|
-
if (visibleTotal > elements.length) {
|
|
786
|
-
result.elementsTruncated = true;
|
|
787
|
-
result.interactiveElementsOnPage = visibleTotal;
|
|
788
|
-
}
|
|
789
|
-
return result;
|
|
790
|
-
`),_1=({selector:t,text:e})=>Zr(`
|
|
791
|
-
var selector = ${JSON.stringify(t??"")};
|
|
792
|
-
var text = ${JSON.stringify(e??"")};
|
|
793
|
-
var target = null;
|
|
794
|
-
if (selector) {
|
|
795
|
-
try { target = document.querySelector(selector); }
|
|
796
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
797
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
798
|
-
} else {
|
|
799
|
-
target = findByText(text);
|
|
800
|
-
if (!target) return { ok: false, error: 'No clickable element has the label ' + text };
|
|
801
|
-
}
|
|
802
|
-
if (target.disabled === true) return { ok: false, error: 'Element is disabled' };
|
|
803
|
-
target.scrollIntoView({ block: 'center', inline: 'center' });
|
|
804
|
-
target.click();
|
|
805
|
-
return { ok: true, clicked: cssPath(target), label: label(target), url: String(location.href) };
|
|
806
|
-
`),L1=({selector:t,value:e,submit:n})=>Zr(`
|
|
807
|
-
var selector = ${JSON.stringify(t)};
|
|
808
|
-
var value = ${JSON.stringify(e)};
|
|
809
|
-
var target = null;
|
|
810
|
-
try { target = document.querySelector(selector); }
|
|
811
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
812
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
813
|
-
|
|
814
|
-
var editable = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable;
|
|
815
|
-
if (!editable) return { ok: false, error: selector + ' is not a text field' };
|
|
816
|
-
if (target.disabled === true || target.readOnly === true) return { ok: false, error: 'Field is not editable' };
|
|
817
|
-
|
|
818
|
-
target.scrollIntoView({ block: 'center' });
|
|
819
|
-
target.focus();
|
|
820
|
-
if (target.isContentEditable) {
|
|
821
|
-
target.textContent = value;
|
|
822
|
-
} else {
|
|
823
|
-
// Frameworks track the value through the native setter; assigning the
|
|
824
|
-
// property directly leaves React and friends unaware of the change.
|
|
825
|
-
var prototype = target.tagName === 'TEXTAREA' ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
|
|
826
|
-
var setter = Object.getOwnPropertyDescriptor(prototype, 'value');
|
|
827
|
-
if (setter && setter.set) setter.set.call(target, value);
|
|
828
|
-
else target.value = value;
|
|
829
|
-
}
|
|
830
|
-
target.dispatchEvent(new Event('input', { bubbles: true }));
|
|
831
|
-
target.dispatchEvent(new Event('change', { bubbles: true }));
|
|
832
|
-
|
|
833
|
-
if (${n?"true":"false"}) {
|
|
834
|
-
var enter = { key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true };
|
|
835
|
-
target.dispatchEvent(new KeyboardEvent('keydown', enter));
|
|
836
|
-
target.dispatchEvent(new KeyboardEvent('keyup', enter));
|
|
837
|
-
var form = target.form;
|
|
838
|
-
if (form && typeof form.requestSubmit === 'function') form.requestSubmit();
|
|
839
|
-
}
|
|
840
|
-
return { ok: true, selector: cssPath(target), url: String(location.href) };
|
|
841
|
-
`),$1=({selector:t,direction:e})=>Zr(`
|
|
842
|
-
var selector = ${JSON.stringify(t??"")};
|
|
843
|
-
var direction = ${JSON.stringify(e??"")};
|
|
844
|
-
|
|
845
|
-
var settle = function (extra) {
|
|
846
|
-
return new Promise(function (resolve) {
|
|
847
|
-
requestAnimationFrame(function () {
|
|
848
|
-
requestAnimationFrame(function () {
|
|
849
|
-
var doc = document.documentElement;
|
|
850
|
-
var maxScrollY = Math.max(0, doc.scrollHeight - window.innerHeight);
|
|
851
|
-
var scrollY = Math.round(window.scrollY);
|
|
852
|
-
var result = { ok: true, scrollY: scrollY, maxScrollY: Math.round(maxScrollY) };
|
|
853
|
-
result.atTop = scrollY <= 1;
|
|
854
|
-
result.atBottom = scrollY >= maxScrollY - 1;
|
|
855
|
-
for (var key in extra) {
|
|
856
|
-
if (Object.prototype.hasOwnProperty.call(extra, key)) result[key] = extra[key];
|
|
857
|
-
}
|
|
858
|
-
resolve(result);
|
|
859
|
-
});
|
|
860
|
-
});
|
|
861
|
-
});
|
|
862
|
-
};
|
|
863
|
-
|
|
864
|
-
if (selector) {
|
|
865
|
-
var target = null;
|
|
866
|
-
try { target = document.querySelector(selector); }
|
|
867
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
868
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
869
|
-
// Instant on purpose: the page's own smooth scrolling would still be
|
|
870
|
-
// animating when the next action runs against it.
|
|
871
|
-
target.scrollIntoView({ block: 'center', behavior: 'instant' });
|
|
872
|
-
return settle({ scrolledTo: cssPath(target) });
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
var doc = document.documentElement;
|
|
876
|
-
var page = Math.round(window.innerHeight * 0.85);
|
|
877
|
-
var bottom = Math.max(0, doc.scrollHeight - window.innerHeight);
|
|
878
|
-
if (direction === 'down') window.scrollTo({ top: window.scrollY + page, behavior: 'instant' });
|
|
879
|
-
else if (direction === 'up') window.scrollTo({ top: window.scrollY - page, behavior: 'instant' });
|
|
880
|
-
else if (direction === 'top') window.scrollTo({ top: 0, behavior: 'instant' });
|
|
881
|
-
else if (direction === 'bottom') window.scrollTo({ top: bottom, behavior: 'instant' });
|
|
882
|
-
else return { ok: false, error: 'Unknown scroll direction: ' + direction };
|
|
883
|
-
return settle({ direction: direction });
|
|
884
|
-
`),W1=["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"],z1=({selector:t})=>Zr(`
|
|
885
|
-
var selector = ${JSON.stringify(t)};
|
|
886
|
-
var target = null;
|
|
887
|
-
try { target = document.querySelector(selector); }
|
|
888
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
889
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
890
|
-
|
|
891
|
-
var computed = window.getComputedStyle(target);
|
|
892
|
-
var styles = {};
|
|
893
|
-
var props = ${JSON.stringify(W1)};
|
|
894
|
-
for (var i = 0; i < props.length; i += 1) {
|
|
895
|
-
var value = computed.getPropertyValue(props[i]);
|
|
896
|
-
if (value) styles[props[i]] = String(value).trim();
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
var rect = target.getBoundingClientRect();
|
|
900
|
-
return {
|
|
901
|
-
ok: true,
|
|
902
|
-
selector: cssPath(target),
|
|
903
|
-
tag: target.tagName.toLowerCase(),
|
|
904
|
-
label: label(target),
|
|
905
|
-
bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) },
|
|
906
|
-
inViewport: rect.bottom > 0 && rect.top < window.innerHeight,
|
|
907
|
-
styles: styles
|
|
908
|
-
};
|
|
909
|
-
`),V1=t=>{const e=Xe.c(18),{entries:n,activeIndex:r,onSelect:i,onForget:o,onHighlight:l}=t,{t:a}=pt();if(n.length===0)return null;let u;e[0]!==a?(u=a("contextPanel.browser.history.label"),e[0]=a,e[1]=u):u=e[1];let d;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=(g,p)=>s.jsxs("div",{role:"option","aria-selected":p===r,className:Re("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",p===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:w=>{w.preventDefault(),i(g.url)},onPointerEnter:()=>l(p),children:[s.jsx(E,{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:g.title||Va(g.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:g.url})]}),s.jsx("button",{type:"button",className:Re("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(g.url)},children:s.jsx(E,{name:"close",className:"size-3","aria-hidden":"true"})})]},g.url),e[9]=r,e[10]=o,e[11]=l,e[12]=i,e[13]=a,e[14]=f):f=e[14],d=n.map(f),e[2]=r,e[3]=n,e[4]=o,e[5]=l,e[6]=i,e[7]=a,e[8]=d}else d=e[8];let h;return e[15]!==u||e[16]!==d?(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":u,children:d}),e[15]=u,e[16]=d,e[17]=h):h=e[17],h},on=t=>{const e=Xe.c(17),{icon:n,label:r,onClick:i,disabled:o,pressed:l}=t,a=l?"secondary":"ghost",u=l&&"text-foreground";let d;e[0]!==u?(d=Re("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",u),e[0]=u,e[1]=d):d=e[1];let h;e[2]!==n?(h=s.jsx(E,{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]!==d||e[10]!==h?(f=s.jsx(bt,{asChild:!0,children:s.jsx(ot,{type:"button",variant:a,size:"xs",className:d,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]=d,e[10]=h,e[11]=f):f=e[11];let g;e[12]!==r?(g=s.jsx(yt,{sideOffset:6,children:r}),e[12]=r,e[13]=g):g=e[13];let p;return e[14]!==f||e[15]!==g?(p=s.jsxs(xt,{children:[f,g]}),e[14]=f,e[15]=g,e[16]=p):p=e[16],p},sm=t=>{const e=Xe.c(104),{address:n,suggestions:r,onForgetSuggestion:i,onAddressChange:o,onSubmit:l,onBack:a,onForward:u,onReload:d,onOpenExternal:h,canGoBack:f,canGoForward:g,isLoading:p,onAnnotate:w,onOpenDevTools:v,isAnnotating:x,onHardReload:m,onZoomIn:b,onZoomOut:y,onZoomReset:S,zoomPercent:N,onClearCookies:C,onClearCache:k,onToggleDeviceBar:A,isDeviceBarOpen:P}=t;let D;e[0]!==r?(D=r===void 0?[]:r,e[0]=r,e[1]=D):D=e[1];const M=D,$=N===void 0?100:N,{t:R}=pt(),[K,L]=c.useState(!1),[O,I]=c.useState(-1);let j;e[2]!==K||e[3]!==M?(j=K?M:[],e[2]=K,e[3]=M,e[4]=j):j=e[4];const T=j;let F;e[5]===Symbol.for("react.memo_cache_sentinel")?(F=()=>{I(-1)},e[5]=F):F=e[5];let U;e[6]!==n||e[7]!==K?(U=[n,K],e[6]=n,e[7]=K,e[8]=U):U=e[8],c.useEffect(F,U);let H;e[9]!==l?(H=oe=>{L(!1),I(-1),l(oe)},e[9]=l,e[10]=H):H=e[10];const Y=H;let me;e[11]!==O||e[12]!==Y||e[13]!==T?(me=oe=>{if(T.length!==0){if(oe.key==="ArrowDown"||oe.key==="ArrowUp"){oe.preventDefault();const Pe=oe.key==="ArrowDown"?1:-1,Ne=T.length;I(B=>{const ce=B+Pe;return ce<-1?Ne-1:ce>=Ne?-1:ce});return}if(oe.key==="Escape"&&O>=0){oe.preventDefault(),I(-1);return}if(oe.key==="Enter"&&O>=0){oe.preventDefault();const Pe=T[O];Pe&&Y(Pe.url)}}},e[11]=O,e[12]=Y,e[13]=T,e[14]=me):me=e[14];const Z=me;let re;e[15]!==R?(re=R("contextPanel.browser.back"),e[15]=R,e[16]=re):re=e[16];const se=!f;let fe;e[17]!==a||e[18]!==se||e[19]!==re?(fe=s.jsx(on,{icon:"arrow-left",label:re,onClick:a,disabled:se}),e[17]=a,e[18]=se,e[19]=re,e[20]=fe):fe=e[20];let _;e[21]!==R?(_=R("contextPanel.browser.forward"),e[21]=R,e[22]=_):_=e[22];const le=!g;let ee;e[23]!==u||e[24]!==_||e[25]!==le?(ee=s.jsx(on,{icon:"arrow-right",label:_,onClick:u,disabled:le}),e[23]=u,e[24]=_,e[25]=le,e[26]=ee):ee=e[26];let ue;e[27]!==p||e[28]!==R?(ue=R(p?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=p,e[28]=R,e[29]=ue):ue=e[29];let W;e[30]!==d||e[31]!==ue?(W=s.jsx(on,{icon:"refresh",label:ue,onClick:d}),e[30]=d,e[31]=ue,e[32]=W):W=e[32];let ne;e[33]!==m||e[34]!==R?(ne=m?s.jsx(on,{icon:"restart",label:R("contextPanel.browser.hardReload"),onClick:m}):null,e[33]=m,e[34]=R,e[35]=ne):ne=e[35];let pe;e[36]!==n||e[37]!==Y?(pe=oe=>{oe.preventDefault(),Y(n)},e[36]=n,e[37]=Y,e[38]=pe):pe=e[38];let xe;e[39]!==o?(xe=oe=>o(oe.target.value),e[39]=o,e[40]=xe):xe=e[40];let Ce,Me;e[41]===Symbol.for("react.memo_cache_sentinel")?(Ce=()=>L(!0),Me=()=>L(!1),e[41]=Ce,e[42]=Me):(Ce=e[41],Me=e[42]);const ve=T.length>0;let Ie;e[43]===Symbol.for("react.memo_cache_sentinel")?(Ie=Re("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]=Ie):Ie=e[43];let ye;e[44]!==R?(ye=R("contextPanel.browser.addressAria"),e[44]=R,e[45]=ye):ye=e[45];let q;e[46]!==n||e[47]!==Z||e[48]!==xe||e[49]!==ve||e[50]!==ye?(q=s.jsx("input",{value:n,onChange:xe,onFocus:Ce,onBlur:Me,onKeyDown:Z,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":ve,"aria-controls":"openchamber-browser-address-suggestions",className:Ie,"aria-label":ye}),e[46]=n,e[47]=Z,e[48]=xe,e[49]=ve,e[50]=ye,e[51]=q):q=e[51];let De;e[52]!==i?(De=oe=>i?.(oe),e[52]=i,e[53]=De):De=e[53];let ke;e[54]!==O||e[55]!==Y||e[56]!==De||e[57]!==T?(ke=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(V1,{entries:T,activeIndex:O,onSelect:Y,onForget:De,onHighlight:I})}),e[54]=O,e[55]=Y,e[56]=De,e[57]=T,e[58]=ke):ke=e[58];let te;e[59]!==pe||e[60]!==q||e[61]!==ke?(te=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:pe,children:[q,ke]}),e[59]=pe,e[60]=q,e[61]=ke,e[62]=te):te=e[62];let he;e[63]!==b||e[64]!==y||e[65]!==S||e[66]!==R||e[67]!==$?(he=y&&b?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(on,{icon:"subtract",label:R("contextPanel.browser.zoomOut"),onClick:y}),$!==100&&S?s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsxs(ot,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:S,"aria-label":R("contextPanel.browser.zoomReset"),children:[$,"%"]})}),s.jsx(yt,{sideOffset:6,children:R("contextPanel.browser.zoomReset")})]}):null,s.jsx(on,{icon:"add",label:R("contextPanel.browser.zoomIn"),onClick:b})]}):null,e[63]=b,e[64]=y,e[65]=S,e[66]=R,e[67]=$,e[68]=he):he=e[68];let ae;e[69]!==C||e[70]!==R?(ae=C?s.jsx(on,{icon:"delete-bin",label:R("contextPanel.browser.clearCookies"),onClick:C}):null,e[69]=C,e[70]=R,e[71]=ae):ae=e[71];let Q;e[72]!==k||e[73]!==R?(Q=k?s.jsx(on,{icon:"database-2",label:R("contextPanel.browser.clearCache"),onClick:k}):null,e[72]=k,e[73]=R,e[74]=Q):Q=e[74];let z;e[75]!==P||e[76]!==A||e[77]!==R?(z=A?s.jsx(on,{icon:"smartphone",label:R("contextPanel.browser.deviceToolbar"),onClick:A,pressed:P}):null,e[75]=P,e[76]=A,e[77]=R,e[78]=z):z=e[78];let G;e[79]!==x||e[80]!==w||e[81]!==R?(G=w?s.jsx(on,{icon:"markup",label:R("contextPanel.browser.annotate.toggle"),onClick:w,pressed:x}):null,e[79]=x,e[80]=w,e[81]=R,e[82]=G):G=e[82];let ie;e[83]!==v||e[84]!==R?(ie=v?s.jsx(on,{icon:"terminal-box",label:R("contextPanel.browser.devTools"),onClick:v}):null,e[83]=v,e[84]=R,e[85]=ie):ie=e[85];let Oe;e[86]!==R?(Oe=R("contextPanel.browser.openExternal"),e[86]=R,e[87]=Oe):Oe=e[87];let Fe;e[88]!==h||e[89]!==Oe?(Fe=s.jsx(on,{icon:"external-link",label:Oe,onClick:h}),e[88]=h,e[89]=Oe,e[90]=Fe):Fe=e[90];let Se;return e[91]!==fe||e[92]!==ee||e[93]!==W||e[94]!==ne||e[95]!==te||e[96]!==he||e[97]!==ae||e[98]!==Q||e[99]!==z||e[100]!==G||e[101]!==ie||e[102]!==Fe?(Se=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[fe,ee,W,ne,te,he,ae,Q,z,G,ie,Fe]}),e[91]=fe,e[92]=ee,e[93]=W,e[94]=ne,e[95]=te,e[96]=he,e[97]=ae,e[98]=Q,e[99]=z,e[100]=G,e[101]=ie,e[102]=Fe,e[103]=Se):Se=e[103],Se},$o={kind:"fill"},ic=240,U1=3840,nm=[{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}],ac=t=>Number.isFinite(t)?Math.round(Math.min(U1,Math.max(ic,t))):ic,Wo=t=>t.kind==="fill"?null:{width:t.width,height:t.height},rm=t=>{const e=nm.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},K1=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},H1=(t,e)=>{const n=Wo(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}},G1=["mobile","tablet","desktop","fill"],q1={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},lc=t=>typeof t=="string"&&G1.includes(t),sa=t=>t==="fill"?$o:rm(q1[t])??$o,lo=t=>{const e=Wo(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=sa(n),i=Wo(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}},Q1=t=>{const e=Xe.c(70),{viewport:n,onViewportChange:r,colorScheme:i,onColorSchemeChange:o,scale:l}=t,{t:a}=pt();let u;e[0]!==n?(u=Wo(n),e[0]=n,e[1]=u):u=e[1];const d=u,h=n.kind==="preset"?n.id:"";let f;e[2]!==r||e[3]!==d?(f=(se,fe)=>{const _=Number.parseInt(fe,10);if(!Number.isFinite(_))return;const le=d??{width:1280,height:800};r({kind:"custom",width:ac(se==="width"?_:le.width),height:ac(se==="height"?_:le.height)})},e[2]=r,e[3]=d,e[4]=f):f=e[4];const g=f;let p;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=Re("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]=p):p=e[5];const w=p;let v;e[6]!==r?(v=se=>{const fe=rm(se.target.value);r(fe??$o)},e[6]=r,e[7]=v):v=e[7];let x;e[8]!==a?(x=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=x):x=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=Re("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 b;e[11]!==a?(b=a("contextPanel.browser.device.responsive"),e[11]=a,e[12]=b):b=e[12];let y;e[13]!==b?(y=s.jsx("option",{value:"",children:b}),e[13]=b,e[14]=y):y=e[14];let S;e[15]===Symbol.for("react.memo_cache_sentinel")?(S=nm.map(Y1),e[15]=S):S=e[15];let N;e[16]!==h||e[17]!==v||e[18]!==x||e[19]!==y?(N=s.jsxs("select",{value:h,onChange:v,"aria-label":x,className:m,children:[y,S]}),e[16]=h,e[17]=v,e[18]=x,e[19]=y,e[20]=N):N=e[20];const C=d?String(d.width):"";let k;e[21]!==g?(k=se=>g("width",se.target.value),e[21]=g,e[22]=k):k=e[22];let A;e[23]!==a?(A=a("contextPanel.browser.device.width"),e[23]=a,e[24]=A):A=e[24];let P;e[25]!==C||e[26]!==k||e[27]!==A?(P=s.jsx("input",{value:C,onChange:k,placeholder:"—",inputMode:"numeric","aria-label":A,className:w}),e[25]=C,e[26]=k,e[27]=A,e[28]=P):P=e[28];let D;e[29]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=D):D=e[29];const M=d?String(d.height):"";let $;e[30]!==g?($=se=>g("height",se.target.value),e[30]=g,e[31]=$):$=e[31];let R;e[32]!==a?(R=a("contextPanel.browser.device.height"),e[32]=a,e[33]=R):R=e[33];let K;e[34]!==M||e[35]!==$||e[36]!==R?(K=s.jsx("input",{value:M,onChange:$,placeholder:"—",inputMode:"numeric","aria-label":R,className:w}),e[34]=M,e[35]=$,e[36]=R,e[37]=K):K=e[37];let L;e[38]!==r||e[39]!==n?(L=()=>r(K1(n)),e[38]=r,e[39]=n,e[40]=L):L=e[40];const O=!d;let I;e[41]!==a?(I=a("contextPanel.browser.device.rotate"),e[41]=a,e[42]=I):I=e[42];let j;e[43]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(E,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=j):j=e[43];let T;e[44]!==L||e[45]!==O||e[46]!==I?(T=s.jsx(bt,{asChild:!0,children:s.jsx(ot,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:L,disabled:O,"aria-label":I,children:j})}),e[44]=L,e[45]=O,e[46]=I,e[47]=T):T=e[47];let F;e[48]!==a?(F=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=F):F=e[49];let U;e[50]!==F?(U=s.jsx(yt,{sideOffset:6,children:F}),e[50]=F,e[51]=U):U=e[51];let H;e[52]!==T||e[53]!==U?(H=s.jsxs(xt,{children:[T,U]}),e[52]=T,e[53]=U,e[54]=H):H=e[54];let Y;e[55]!==l||e[56]!==d?(Y=d&&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]=d,e[57]=Y):Y=e[57];let me;e[58]===Symbol.for("react.memo_cache_sentinel")?(me=["system","light","dark"],e[58]=me):me=e[58];let Z;e[59]!==i||e[60]!==o||e[61]!==a?(Z=s.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:me.map(se=>s.jsx(ot,{type:"button",variant:i===se?"secondary":"ghost",size:"xs",className:Re("shrink-0 rounded-full px-2.5 typography-micro",i===se?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>o(se),"aria-pressed":i===se,children:a(se==="system"?"contextPanel.browser.device.schemeSystem":se==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},se))}),e[59]=i,e[60]=o,e[61]=a,e[62]=Z):Z=e[62];let re;return e[63]!==N||e[64]!==P||e[65]!==K||e[66]!==H||e[67]!==Y||e[68]!==Z?(re=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[N,P,D,K,H,Y,Z]}),e[63]=N,e[64]=P,e[65]=K,e[66]=H,e[67]=Y,e[68]=Z,e[69]=re):re=e[69],re};function Y1(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const X1=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},J1=2e3,Z1=()=>{if(typeof window>"u"||window.__OPENCHAMBER_ELECTRON__)return!1;const t=Nn();if(!t)return!1;try{return!Sr(new URL(t,window.location.href).toString())}catch{return!1}},om=t=>{const e=Xe.c(33),{onOpen:n,directory:r}=t,i=r===void 0?"":r,{t:o}=pt();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={kind:"loading"},e[0]=l):l=e[0];const[a,u]=c.useState(l),d=ex(i),[h]=c.useState(Z1);let f,g;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{let P=!0,D=null;const M=new AbortController,$=()=>{Vy(M.signal).then(R=>{P&&(u(R),D=setTimeout($,J1))})};return $(),()=>{P=!1,D&&clearTimeout(D),M.abort()}},g=[],e[1]=f,e[2]=g):(f=e[1],g=e[2]),c.useEffect(f,g);const p=a.kind==="ready"?a.servers:null;let w;e[3]!==d||e[4]!==p?(w=Hy({announced:d,discovered:p}),e[3]=d,e[4]=p,e[5]=w):w=e[5];const v=w;let x;e[6]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsx(Td,{width:110,height:110,className:"shrink-0 opacity-20"}),e[6]=x):x=e[6];let m;e[7]!==o?(m=o("contextPanel.browser.empty"),e[7]=o,e[8]=m):m=e[8];let b;e[9]!==m?(b=s.jsx("span",{className:"typography-ui-header text-foreground",children:m}),e[9]=m,e[10]=b):b=e[10];let y;e[11]!==o?(y=o("contextPanel.browser.emptyHint"),e[11]=o,e[12]=y):y=e[12];let S;e[13]!==y?(S=s.jsx("span",{className:"typography-micro text-muted-foreground",children:y}),e[13]=y,e[14]=S):S=e[14];let N;e[15]!==S||e[16]!==b?(N=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[b,S]}),e[15]=S,e[16]=b,e[17]=N):N=e[17];let C;e[18]!==d||e[19]!==v||e[20]!==i||e[21]!==n||e[22]!==h||e[23]!==o?(C=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:d.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(P=>s.jsxs(ot,{type:"button",variant:"outline",size:"sm",className:"w-full shrink-0 justify-start gap-2",onClick:()=>{Xg(i),n(P.url)},children:[s.jsx(E,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:Va(P.url)||P.url}),s.jsx("span",{className:"ml-auto truncate typography-micro text-muted-foreground",children:X1(P.url)})]},P.port))})]}):null,e[18]=d,e[19]=v,e[20]=i,e[21]=n,e[22]=h,e[23]=o,e[24]=C):C=e[24];let k;e[25]!==v.length||e[26]!==a.kind||e[27]!==o?(k=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]=k):k=e[28];let A;return e[29]!==N||e[30]!==C||e[31]!==k?(A=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:[x,N,C,k]}),e[29]=N,e[30]=C,e[31]=k,e[32]=A):A=e[32],A},Fs=t=>Math.round(t),ew=(t,e)=>{const n=t.text.trim(),r=Object.entries(t.attributes).map(([a,u])=>`${a}="${u}"`).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=${Fs(l.x)}, y=${Fs(l.y)}, width=${Fs(l.width)}, height=${Fs(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")},tw=(t,e)=>{const n=t.rect;return`Region ${e+1}: x=${Fs(n.x)}, y=${Fs(n.y)}, width=${Fs(n.width)}, height=${Fs(n.height)}`},sw=(t,e)=>{const n=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${Fs(n.x)}, y=${Fs(n.y)}, width=${Fs(n.width)}, height=${Fs(n.height)}`},nw=({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: ${Fs(t.viewport.width)}x${Fs(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("",...ew(a.element,l));return t.regions.length>0&&(o.push(""),t.regions.forEach((l,a)=>o.push(tw(l,a)))),t.strokes.length>0&&(o.push(""),t.strokes.forEach((l,a)=>o.push(sw(l,a)))),o.filter(l=>typeof l=="string").join(`
|
|
910
|
-
`)},rw=t=>{const e=Xe.c(7),{t:n}=pt(),r=Qe(iw),i=Qe(aw),o=Di(lw),l=Xf(cw);let a;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==t||e[4]!==i||e[5]!==n?(a=async u=>{const d=r??(i?"draft":null);if(!d){Be.error(n("contextPanel.browser.annotate.noSession"));return}let h=!1;if(u.screenshot)try{await l(u.screenshot),h=!0}catch{h=!1}o({directory:t,sessionKey:d},{source:"preview-annotation",fileLabel:u.payload.pageUrl||"browser",startLine:1,endLine:1,code:nw({payload:u.payload,screenshotAttached:h,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),Be.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},ow=()=>{const t=Xe.c(16),{t:e}=pt();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 iw(t){return t.currentSessionId}function aw(t){return t.newSessionDraft?.open}function lw(t){return t.addDraft}function cw(t){return t.addAttachedFile}const dw=3e4,uw=3,mw=250,fw={attempts:0,windowStartedAt:null},hw=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=dw,r=n?0:t.attempts;return r>=uw?null:{delayMs:mw*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},pw=-3,co=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",dr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},gw=(t,{initialUrl:e,onUrlChange:n})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:Qy),[o,l]=c.useState(e),[a,u]=c.useState(""),[d,h]=c.useState(!1),[f,g]=c.useState(!1),p=c.useRef(n);p.current=n;const w=c.useRef(fw);return c.useEffect(()=>{if(!t)return;const v=()=>{try{const D=t.getURL();return co(D)?D:""}catch{return""}},x=()=>{try{h(t.canGoBack()),g(t.canGoForward())}catch{}},m=D=>{co(D)&&(l(D),p.current(D))},b=()=>{const D=v();i({kind:"loading",url:D})},y=()=>{const D=v();let M="";try{M=t.getTitle()||""}catch{M=""}u(M),m(D),x(),i($=>$.kind==="failed"&&$.url===D?$:{kind:"ready",url:D,title:M})},S=D=>{const M=dr(D);co(M.url)&&(m(M.url),x())},N=D=>{const M=dr(D),$=Array.isArray(M.favicons)?M.favicons.find(Boolean):"",R=v();$&&R&&Vu.getState().resolve(R,$)},C=D=>{const M=dr(D);typeof M.title=="string"&&u(M.title)},k=D=>{const M=dr(D);if(M.isMainFrame===!1)return;const $=typeof M.errorCode=="number"?M.errorCode:0;$!==pw&&i({kind:"failed",url:co(M.validatedURL)?M.validatedURL:v(),code:$,description:typeof M.errorDescription=="string"?M.errorDescription:""})};let A=null;const P=()=>{const D=v(),M=hw(w.current,Date.now());if(!M){i({kind:"failed",url:D,code:0,description:"",crashed:!0});return}w.current=M.state,i({kind:"loading",url:D}),A=setTimeout(()=>{A=null;try{t.reload()}catch{i({kind:"failed",url:D,code:0,description:"",crashed:!0})}},M.delayMs)};t.addEventListener("did-start-loading",b),t.addEventListener("did-stop-loading",y),t.addEventListener("did-navigate",S),t.addEventListener("did-navigate-in-page",S),t.addEventListener("page-title-updated",C),t.addEventListener("page-favicon-updated",N),t.addEventListener("did-fail-load",k),t.addEventListener("render-process-gone",P),t.addEventListener("crashed",P);try{!t.isLoading()&&v()&&y()}catch{}return()=>{A!==null&&clearTimeout(A),t.removeEventListener("render-process-gone",P),t.removeEventListener("crashed",P),t.removeEventListener("did-start-loading",b),t.removeEventListener("did-stop-loading",y),t.removeEventListener("did-navigate",S),t.removeEventListener("did-navigate-in-page",S),t.removeEventListener("page-title-updated",C),t.removeEventListener("page-favicon-updated",N),t.removeEventListener("did-fail-load",k)}},[t]),{status:r,url:o,title:a,canGoBack:d,canGoForward:f}},xw=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,bw=4e4,cc=.5,yw=-3,ww=4,Sw="persist:openchamber-browser",dc=20,vw=600,jw=2e4,kw=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=pt(),{currentTheme:i}=er(),o=c.useRef(null),[l,a]=c.useState(null),u=c.useCallback(te=>{o.current=te,a(te)},[]),d=Te(te=>te.setContextPanelTabTargetPath),h=c.useRef(hr(t)),f=h.current!==an?h.current:"",[g,p]=c.useState(f?null:an),[w,v]=c.useState(f),[x,m]=c.useState(!1),[b,y]=c.useState(!1),[S,N]=c.useState(0),[C,k]=c.useState(!1),[A,P]=c.useState($o),D=c.useRef(A);D.current=A;const M=c.useRef([]),[$,R]=c.useState("system"),[K,L]=c.useState({width:0,height:0}),O=c.useRef(null),I=c.useRef(null),j=c.useRef(!1),T=c.useRef(Date.now()),F=c.useCallback(te=>{!te||te===an||!e||!n||d(e,n,te)},[e,n,d]),U=gw(l,{initialUrl:f,onUrlChange:c.useCallback(te=>{const he=Pr(te);v(he),F(he)},[F])}),[H,Y]=c.useState(null),me=rw(e),Z=ow(),re=U.status.kind==="loading",se=br(Ju(e)),fe=br(te=>te.recordVisit),_=br(te=>te.forget);c.useEffect(()=>{U.status.kind==="ready"&&fe(e,{url:Pr(U.status.url),title:U.status.title})},[e,U.status,fe]);const le=c.useMemo(()=>Xu(se,w),[se,w]),ee=c.useCallback(te=>{const he=hr(te);he!==an&&(v(he),Y(null),nc(he).then(ae=>{const Q=o.current;if(!Q){p(ae);return}try{Q.loadURL(ae)}catch{p(ae)}}).catch(ae=>{ae instanceof Fr&&Y(he)}))},[]);c.useEffect(()=>{if(!f)return;let te=!0;return nc(f).then(he=>{te&&p(he)}).catch(he=>{if(te){if(he instanceof Fr){Y(f),p(an);return}p(f)}}),()=>{te=!1}},[]);const ue=c.useMemo(()=>({executeJavaScript:async(te,he)=>{const ae=o.current;if(!ae)throw new Error("Browser view is not available");return ae.executeJavaScript(te,he)},capturePage:async()=>{const te=o.current;if(!te)return null;const he=te.getWebContentsId();return Number.isFinite(he)?await mr("desktop_browser_capture_page",{webContentsId:he}):null}}),[]),W=c.useCallback(()=>{if(x){m(!1),vo(ue);return}if(!U.url){Be.error(r("contextPanel.browser.annotate.noPage"));return}const te=c1(i.metadata.variant==="light"?"light":"dark");m(!0),a1({host:ue,theme:te,labels:Z}).then(async he=>{m(!1),he&&await me(he)}).catch(()=>{m(!1),Be.error(r("contextPanel.browser.annotate.failed"))})},[ue,me,i,x,U.url,Z,r]);c.useEffect(()=>{if(!x)return;const te=he=>{he.key==="Escape"&&(he.preventDefault(),he.stopImmediatePropagation(),m(!1),vo(ue))};return window.addEventListener("keydown",te,!0),()=>window.removeEventListener("keydown",te,!0)},[ue,x]);const ne=c.useCallback(async(te=8e3)=>{const he=Date.now();for(;;){const ae=o.current;if(!ae)return!1;let Q=!1;try{Q=ae.isLoading()}catch{return!1}if(!Q)return!0;if(Date.now()-he>te)return!1;await new Promise(z=>setTimeout(z,120))}},[]),pe=c.useCallback(async(te,he)=>{const ae=o.current;if(!ae)throw new Error("The browser panel is not ready");const Q=()=>{lc(he.viewport)&&(P(sa(he.viewport)),k(!0))};if(te==="browser.back"||te==="browser.forward"){const Se=te==="browser.back";if(!(Se?ae.canGoBack():ae.canGoForward()))throw new Error(Se?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");Se?ae.goBack():ae.goForward(),await new Promise(Ne=>setTimeout(Ne,150)),await ne();let Pe="";try{Pe=ae.getTitle()||""}catch{Pe=""}return{url:Pr(ae.getURL()),title:Pe}}if(te==="browser.capture"){Te.getState().openContextBrowser(e,ae.getURL());const Se=Date.now()+1200;let oe=0,Pe=0;for(;Pe<2&&Date.now()<Se;){const ce=ae.getBoundingClientRect().width;Pe=ce>=2&&Math.abs(ce-oe)<.5?Pe+1:0,oe=ce,await new Promise(be=>setTimeout(be,50))}await new Promise(ce=>{requestAnimationFrame(()=>requestAnimationFrame(()=>ce()))}),await ne();const Ne=await ue.capturePage();if(!Ne)throw new Error("The page could not be captured");let B="";try{B=ae.getTitle()||""}catch{B=""}return{...Ne,url:Pr(ae.getURL()),title:B,viewport:lo(D.current)}}if(te==="browser.resize"){if(!lc(he.viewport))throw new Error("viewport is required");return Q(),await new Promise(Se=>setTimeout(Se,200)),await ne(),{viewport:lo(sa(he.viewport))}}if(te==="browser.open"){const Se=typeof he.url=="string"?he.url:"";if(!Se)throw new Error("url is required");Q(),ee(Se),await new Promise(Ne=>setTimeout(Ne,150));const oe=await ne(25e3);let Pe="";try{Pe=ae.getTitle()||""}catch{Pe=""}return{url:hr(Se),title:Pe,opened:!0,settled:oe,viewport:lo(D.current)}}await ne();const z=Se=>typeof Se=="string"&&Se?Se:void 0,ie=(()=>{switch(te){case"browser.snapshot":return F1({selector:z(he.selector)});case"browser.click":return _1({selector:z(he.selector),text:z(he.text)});case"browser.type":return L1({selector:String(he.selector??""),value:String(he.value??""),submit:he.submit===!0});case"browser.inspect":return z1({selector:String(he.selector??"")});case"browser.scroll":return $1({selector:z(he.selector),direction:z(he.direction)});default:return null}})();if(!ie)throw new Error(`Unsupported browser action: ${te}`);const Oe=await ae.executeJavaScript(ie,!0);if(!Oe||typeof Oe!="object")throw new Error("The page returned no result");const Fe=Oe;if(Fe.ok!==!0)throw new Error(typeof Fe.error=="string"&&Fe.error?Fe.error:"Browser action failed");if(te==="browser.snapshot"){const Se=M.current;return{...Fe,viewport:lo(D.current),...Se.length>0?{consoleProblems:[...Se]}:{}}}return(te==="browser.click"||te==="browser.type"&&he.submit===!0)&&(await new Promise(Se=>setTimeout(Se,150)),await ne()),Oe},[ue,e,ee,ne]);c.useEffect(()=>S1({run:pe}),[pe]),c.useEffect(()=>{const te=ue;return()=>{vo(te)}},[ue]),c.useEffect(()=>{if(!l)return;const te=ae=>{const Q=ae;if(typeof Q.level!="number"||Q.level<2)return;const z=Q.sourceId?`${Q.sourceId}${Q.line?`:${Q.line}`:""}`:"";M.current.push({level:Q.level>=3?"error":"warning",message:String(Q.message??"").slice(0,400),source:z}),M.current.length>dc&&M.current.splice(0,M.current.length-dc)},he=()=>{M.current=[]};return l.addEventListener("console-message",te),l.addEventListener("did-start-loading",he),()=>{l.removeEventListener("console-message",te),l.removeEventListener("did-start-loading",he)}},[l]);const xe=c.useRef(new Set),Ce=c.useCallback(te=>{xe.current.clear(),ee(te)},[ee]);c.useEffect(()=>{if(!l)return;const te=ae=>{const Q=dr(ae),z=typeof Q.url=="string"?Q.url:"";!z||!rc(z)||(ae.preventDefault(),ee(z))},he=ae=>{const Q=dr(ae);if(Q.isMainFrame===!1||Q.errorCode===-3)return;const z=typeof Q.validatedURL=="string"?Q.validatedURL:"";!z||!rc(z)||xe.current.has(z)||(xe.current.add(z),ee(z))};return l.addEventListener("will-navigate",te),l.addEventListener("did-fail-load",he),()=>{l.removeEventListener("will-navigate",te),l.removeEventListener("did-fail-load",he)}},[ee,l]),c.useEffect(()=>{if(!l)return;const te=he=>{const ae=he.detail;he.preventDefault(),ae?.url&&ee(ae.url)};return l.addEventListener("new-window",te),()=>l.removeEventListener("new-window",te)},[ee,l]);const Me=c.useCallback(te=>{const he=Math.min(ww,Math.max(yw,te));N(he);try{o.current?.setZoomLevel(he)}catch{}},[]),ve=c.useCallback(te=>{mr("desktop_browser_clear_data",{partition:Sw,cookies:te==="cookies",cache:te==="cache"}).then(()=>{Be.success(r(te==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>Be.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const te=O.current;if(!te||typeof ResizeObserver>"u")return;const he=new ResizeObserver(ae=>{const Q=ae[0]?.contentRect;Q&&L({width:Q.width,height:Q.height})});return he.observe(te),()=>he.disconnect()},[]);const Ie=c.useCallback(te=>{R(te);const he=o.current;if(!he)return;let ae=-1;try{ae=he.getWebContentsId()}catch{return}mr("desktop_browser_set_color_scheme",{webContentsId:ae,scheme:te}).catch(Q=>{R("system"),Be.error(Q instanceof Error?Q.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),ye=c.useCallback(()=>{try{re?o.current?.stop():o.current?.reload()}catch{}},[re]),q=U.status;c.useEffect(()=>{const te=()=>{y(!0);const Q=setTimeout(()=>{try{o.current?.reload()}catch{}},vw);return()=>clearTimeout(Q)};if(q.kind==="failed"){if(!Wy(q.code,q.url)){y(!1);return}const Q=Date.now(),z=I.current?.url===q.url?I.current:{url:q.url,startedAt:Q};if(I.current=z,Q-z.startedAt>bw){y(!1);return}return te()}if(q.kind==="loading")return;if(I.current=null,q.kind!=="ready"||!q.url||!Sr(q.url)){j.current=!0,y(!1);return}if(j.current||Date.now()-T.current>jw){j.current=!0,y(!1);return}let he=!1,ae=null;return Uy(Pr(q.url)).then(Q=>{if(!he){if(Q===null||Q<500){j.current=!0,y(!1);return}ae=te()}}),()=>{he=!0,ae?.()}},[q]);const De=U.status.kind==="failed"&&!b?U.status:null,ke=H1(A,K);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(sm,{address:w,onAddressChange:v,onSubmit:Ce,suggestions:le,onForgetSuggestion:te=>_(e,te),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:ye,onOpenExternal:()=>{Yo(U.url||w)},canGoBack:U.canGoBack,canGoForward:U.canGoForward,isLoading:re,onAnnotate:W,isAnnotating:x,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>Me(S+cc),onZoomOut:()=>Me(S-cc),onZoomReset:()=>Me(0),zoomPercent:Math.round(Math.pow(1.2,S)*100),onClearCookies:()=>ve("cookies"),onClearCache:()=>ve("cache"),onToggleDeviceBar:()=>k(te=>!te),isDeviceBarOpen:C}),C?s.jsx(Q1,{viewport:A,onViewportChange:P,colorScheme:$,onColorSchemeChange:Ie,scale:ke?.scale??1}):null,s.jsxs("div",{ref:O,className:Re("relative min-h-0 flex-1 bg-background",ke&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[g!==null?s.jsx("webview",{ref:u,src:g,partition:"persist:openchamber-browser",allowpopups:!0,style:ke?{width:`${ke.width}px`,height:`${ke.height}px`,transform:`scale(${ke.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,g!==null&&!f&&!U.url&&!re?s.jsx(om,{onOpen:Ce,directory:e}):null,b?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,H?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:H})})]}):null,De&&!H?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:De.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:De.crashed?r("contextPanel.browser.crashedHint"):De.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,re?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]})]})},Cw=t=>{const e=Xe.c(49),{initialUrl:n,directory:r,tabID:i}=t,{t:o}=pt(),l=Te(Aw);let a;e[0]!==n?(a=hr(n),e[0]=n,e[1]=a):a=e[1];const u=a,d=u!==an?u:"",[h,f]=c.useState(d),[g,p]=c.useState(d);let w;e[2]!==d?(w=d?[d]:[],e[2]=d,e[3]=w):w=e[3];const[v,x]=c.useState(w),[m,b]=c.useState(d?0:-1),[y,S]=c.useReducer(Pw,0);let N;e[4]!==r||e[5]!==l||e[6]!==i?(N=re=>{!re||re===an||!r||!i||l(r,i,re)},e[4]=r,e[5]=l,e[6]=i,e[7]=N):N=e[7];const C=N;let k;e[8]!==r?(k=Ju(r),e[8]=r,e[9]=k):k=e[9];const A=br(k),P=br(Dw),D=br(Tw);let M;e[10]!==h||e[11]!==A?(M=Xu(A,h),e[10]=h,e[11]=A,e[12]=M):M=e[12];const $=M;let R;e[13]!==r||e[14]!==m||e[15]!==C||e[16]!==P?(R=re=>{const se=hr(re);se!==an&&(f(se),p(se),C(se),P(r,{url:se}),x(fe=>{const _=m>=0?fe.slice(0,m+1):[];return _[_.length-1]===se?(b(_.length-1),_):(b(_.length),[..._,se])}))},e[13]=r,e[14]=m,e[15]=C,e[16]=P,e[17]=R):R=e[17];const K=R;let L;e[18]!==v||e[19]!==C?(L=re=>{const se=v[re];se&&(b(re),f(se),p(se),C(se))},e[18]=v,e[19]=C,e[20]=L):L=e[20];const O=L;let I;e[21]!==r||e[22]!==D?(I=re=>D(r,re),e[21]=r,e[22]=D,e[23]=I):I=e[23];let j,T;e[24]!==O||e[25]!==m?(T=()=>O(m-1),j=()=>O(m+1),e[24]=O,e[25]=m,e[26]=j,e[27]=T):(j=e[26],T=e[27]);let F;e[28]!==h||e[29]!==g?(F=()=>{Yo(g||h)},e[28]=h,e[29]=g,e[30]=F):F=e[30];const U=m>0,H=m>=0&&m<v.length-1;let Y;e[31]!==h||e[32]!==K||e[33]!==$||e[34]!==j||e[35]!==F||e[36]!==U||e[37]!==H||e[38]!==I||e[39]!==T?(Y=s.jsx(sm,{address:h,onAddressChange:f,onSubmit:K,suggestions:$,onForgetSuggestion:I,onBack:T,onForward:j,onReload:S,onOpenExternal:F,canGoBack:U,canGoForward:H,isLoading:!1}),e[31]=h,e[32]=K,e[33]=$,e[34]=j,e[35]=F,e[36]=U,e[37]=H,e[38]=I,e[39]=T,e[40]=Y):Y=e[40];let me;e[41]!==g||e[42]!==K||e[43]!==y||e[44]!==o?(me=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:g?s.jsx("iframe",{src:g,title:o("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${g}|${y}`):s.jsx(om,{onOpen:K})}),e[41]=g,e[42]=K,e[43]=y,e[44]=o,e[45]=me):me=e[45];let Z;return e[46]!==Y||e[47]!==me?(Z=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[Y,me]}),e[46]=Y,e[47]=me,e[48]=Z):Z=e[48],Z},Nw=t=>{const e=Xe.c(3),[n]=c.useState(xw);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(kw,{...t}):s.jsx(Cw,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function Aw(t){return t.setContextPanelTabTargetPath}function Pw(t){return t+1}function Dw(t){return t.recordVisit}function Tw(t){return t.forget}const Iw=$n(()=>_n(()=>import("./WalkthroughView-D-HFgdmM.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])).then(t=>({default:t.WalkthroughView}))),Rw=$n(()=>_n(()=>import("./DiffView-CNnDxRmO.js"),__vite__mapDeps([124,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,116,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,117,118,119,120,121,122,123])).then(t=>({default:t.DiffView}))),Ew=$n(()=>_n(()=>import("./FilesView-8wdiG2mj.js"),__vite__mapDeps([125,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,116,126,127,128,129,130,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,131,132,117,118,114,121,133,115,134])).then(t=>({default:t.FilesView}))),Mw=$n(()=>_n(()=>import("./GitView-Cv2xH-S6.js"),__vite__mapDeps([135,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,116,136,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,117,118,120,121,122,123])).then(t=>({default:t.GitView}))),Ow=$n(()=>_n(()=>import("./LinearIssuesView-CoZ7pQN5.js"),__vite__mapDeps([137,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}))),Bw=$n(()=>_n(()=>import("./PlanView-C1qvAm7m.js"),__vite__mapDeps([138,1,2,4,5,6,7,8,9,126,57,58,59,60,61,62,79,55,56,63,127,128,129,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,115,116,134,117,118,102,103,87,88,89,90,91,92,93,94,95,96,97,98,99,100])).then(t=>({default:t.PlanView}))),Fw=380,_w=1400,im=600,Lw=100,$w=24,zo=new Map,Ww=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},uc=t=>Number.isFinite(t)?Math.min(_w,Math.max(Fw,Math.round(t))):im,zw=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},Vw=(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},am=(t,e)=>e(t==="chat"?"contextPanel.mode.chat":t==="file"?"contextPanel.mode.files":t==="diff"?"contextPanel.mode.diff":t==="walkthrough"?"contextPanel.mode.walkthrough":t==="plan"?"contextPanel.mode.plan":t==="browser"?"contextPanel.mode.browser":t==="git"?"layout.rightSidebar.git":t==="pr"?"contextPanel.mode.pr":t==="linear"?"contextPanel.mode.linear":t==="notes"?"contextRail.surface.notes":t==="terminal"?"layout.mainTab.terminal":"contextPanel.mode.context"),Uw=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},Kw=(t,e,n)=>{if(t.mode==="chat"){const r=na(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"?Va(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?Uw(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):am(t.mode,n)},mc=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(Ca,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(Eu,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(E,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(E,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(E,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="linear")return s.jsx(E,{name:"linear",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(E,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(E,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(E,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(E,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(E,{name:"chat-4",className:"h-3.5 w-3.5"});if(t.mode==="browser"){const n=Hw(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(E,{name:"global",className:"h-3.5 w-3.5"})}},Hw=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},Gw=200,qw=480,Qw=({visible:t})=>{const{t:e}=pt(),n=Te(m=>m.contextEditorTreeWidth),r=Te(m=>m.setContextEditorTreeWidth),[i,o]=c.useState(!1),l=c.useRef(0),a=c.useRef(n),u=c.useRef(null),d=c.useRef(null),h=c.useRef(null),f=c.useCallback(m=>Math.min(qw,Math.max(Gw,Math.round(m))),[]),g=c.useCallback(m=>{const b=h.current;b&&(b.style.width=`${m}px`,b.style.setProperty("--oc-editor-tree-width",`${m}px`))},[]),p=m=>{if(t){try{m.currentTarget.setPointerCapture(m.pointerId)}catch{}d.current=m.pointerId,o(!0),l.current=m.clientX,a.current=n,u.current=n,m.preventDefault()}},w=m=>{if(!i||d.current!==m.pointerId)return;const b=l.current-m.clientX,y=f(a.current+b);u.current!==y&&(u.current=y,g(y))},v=m=>{if(d.current!==m.pointerId)return;try{m.currentTarget.releasePointerCapture(m.pointerId)}catch{}const b=f(u.current??n);d.current=null,u.current=null,o(!1),r(b)},x=t?n:0;return s.jsxs("div",{ref:h,className:Re("relative h-full flex-shrink-0 overflow-hidden border-l border-border bg-background will-change-[width] motion-reduce:transition-none",!t&&"border-l-0"),style:{width:`${i?u.current??x:x}px`,"--oc-editor-tree-width":`${i?u.current??n:n}px`,overflowX:"clip",transitionProperty:i?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&s.jsx("div",{className:Re("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",i&&"bg-[var(--interactive-border)]"),onPointerDown:p,onPointerMove:w,onPointerUp:v,onPointerCancel:v,role:"separator","aria-orientation":"vertical","aria-label":e("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:Re("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",i&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)"},"aria-hidden":!t,children:s.jsx(dy,{})})]})},na=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,Yw=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},Xw=(t,e)=>{if(e.length===0)return zo;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?zo:r},Jw=(t,e)=>{const n=kd(t),r=c.useRef(zo),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(n.subscribe,c.useCallback(()=>{const o=Xw(n.getState().session,i.current);return Yw(r.current,o)?r.current:(r.current=o,o)},[n]),()=>zo)},Zw=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,eS=()=>{const{t}=pt(),e=Yr()??"",n=c.useMemo(()=>Ww(e),[e]),r=Te(de=>n?de.contextPanelByDirectory[n]:void 0),i=Te(de=>de.closeContextPanel),o=Te(de=>de.closeContextPanelTab),l=Te(de=>de.openContextPanelTab),a=Te(de=>de.toggleContextPanelExpanded),u=Te(de=>de.setContextPanelWidth),d=Te(de=>de.setActiveContextPanelTab),h=Te(de=>de.openContextBrowser);c.useEffect(()=>{if(e)return v1(de=>h(e,de))},[e,h]);const f=Te(de=>de.reorderContextPanelTabs),g=un(de=>de.setSelectedPath),p=Te(de=>de.contextEditorTreeVisible),w=Te(de=>de.toggleContextEditorTree),v=Te(de=>de.openNewContextBrowserTab),x=Vu(de=>de.byOrigin),m=Te(de=>de.allowPromptingSubagentSessions),{themeMode:b,setThemeMode:y,lightThemeId:S,darkThemeId:N,currentTheme:C}=er(),k=c.useMemo(()=>r?.tabs??[],[r?.tabs]),A=k.find(de=>de.id===r?.activeTabId)??k[k.length-1]??null,P=!!(r?.isOpen&&A),D=!!(P&&r?.expanded),[M,$]=c.useState(null),R=A?.mode??null,K=R?r?.widthByMode?.[R]:void 0,L=R?Jf(R):.5,O=M??(typeof window<"u"?window.innerWidth:im*2),I=uc(K??Math.round(L*O)),j=c.useMemo(()=>{const de=[];for(const X of k){if(X.mode!=="chat")continue;const we=na(X.dedupeKey);we&&!de.includes(we)&&de.push(we)}return de},[k]),T=Jw(n||void 0,j),[F,U]=c.useState(!1),H=c.useRef(0),Y=c.useRef(I),me=c.useRef(null),Z=c.useRef(null),re=c.useRef(null),se=c.useRef(new Map),fe=c.useRef(new Map),_=c.useRef(!1);c.useLayoutEffect(()=>{const de=re.current?.parentElement;if(!de||typeof ResizeObserver>"u")return;const X=new ResizeObserver(()=>{$(de.clientWidth||null)});return X.observe(de),$(de.clientWidth||null),()=>X.disconnect()},[]),c.useEffect(()=>{if(!P||_.current){_.current=P;return}const de=window.requestAnimationFrame(()=>{re.current?.focus({preventScroll:!0})});return _.current=!0,()=>window.cancelAnimationFrame(de)},[P]);const le=c.useRef(null),ee=c.useRef(null),ue=c.useCallback(()=>{ee.current=null;const de=re.current,X=me.current;!de||X===null||de.style.setProperty("--oc-context-panel-width",`${X}px`)},[]);c.useEffect(()=>()=>{ee.current!==null&&clearTimeout(ee.current)},[]);const W=c.useCallback(de=>{const X=uc(de),we=le.current;return we===null?X:Math.min(X,Math.max(1,we))},[]),ne=c.useCallback(de=>{!P||D||!n||(Z.current=de.pointerId,U(!0),H.current=de.clientX,Y.current=I,me.current=I,le.current=zw(re.current),document.documentElement.style.cursor="col-resize",de.preventDefault())},[n,D,P,I]),pe=c.useCallback(()=>{const de=W(me.current??I);me.current=null,le.current=null,ee.current!==null&&(clearTimeout(ee.current),ee.current=null),document.documentElement.style.cursor="",n&&R&&u(n,R,de),U(!1),Z.current=null},[R,W,n,u,I]);c.useEffect(()=>{if(!F)return;const de=ze=>{if(Z.current!==ze.pointerId)return;const Ve=H.current-ze.clientX,He=W(Y.current+Ve);me.current!==He&&(me.current=He,ee.current===null&&(ee.current=setTimeout(ue,Lw)))},X=ze=>{Z.current===ze.pointerId&&pe()},we=()=>{pe()};return window.addEventListener("pointermove",de),window.addEventListener("pointerup",X),window.addEventListener("pointercancel",X),window.addEventListener("blur",we),()=>{window.removeEventListener("pointermove",de),window.removeEventListener("pointerup",X),window.removeEventListener("pointercancel",X),window.removeEventListener("blur",we)}},[ue,W,pe,F]),c.useEffect(()=>{F||(me.current=null,document.documentElement.style.cursor="")},[F]);const xe=c.useCallback(()=>{n&&i(n)},[i,n]),Ce=c.useCallback(()=>{n&&a(n)},[n,a]),Me=c.useCallback(de=>{de.key==="Escape"&&(Zf(de.target)||(de.preventDefault(),de.stopPropagation(),xe()))},[xe]);c.useEffect(()=>{if(!(!n||!A)&&A.mode==="file"&&A.targetPath){g(n,A.targetPath,{allowOutsideRoot:!0});return}},[A,n,g]);const ve=c.useMemo(()=>k.filter(de=>de.mode==="chat"),[k]),Ie=P&&A?.mode==="chat"?A.id:null,ye=P&&A?.mode==="chat"?na(A.dedupeKey):null,q=Rg(ve,Ie);c.useEffect(()=>{if(!P||!n||!ye||typeof window>"u")return;const de=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){ai(n,ye,!1);return}Id(ye),ai(n,ye,!0)};de();const X=window.setInterval(de,1e4);return window.addEventListener("focus",de),window.addEventListener("blur",de),document.addEventListener("visibilitychange",de),()=>{window.clearInterval(X),window.removeEventListener("focus",de),window.removeEventListener("blur",de),document.removeEventListener("visibilitychange",de),ai(n,ye,!1)}},[ye,n,P]);const De=c.useCallback((de,X,we)=>Eg(fe.current,de,X,n||null,we,{mode:b,lightThemeId:S,darkThemeId:N,currentTheme:C},{allowPromptingSubagentSessions:m}),[m,C,N,n,S,b]),ke=q&&ye?De(q.id,ye,q.readOnly):null;c.useEffect(()=>{const de=new Set(k.map(X=>X.id));for(const X of fe.current.keys())de.has(X)||fe.current.delete(X)},[k]);const te=c.useCallback(de=>{!n||A?.mode!=="diff"||l(n,{mode:"diff",targetPath:A.targetPath,stagedDiff:de==="staged",diffScope:de})},[A,n,l]),he=c.useCallback(()=>{if(typeof window>"u")return;const de={themeMode:b,lightThemeId:S,darkThemeId:N,currentTheme:C};for(const X of se.current.values()){const we=X.contentWindow;we&&we.postMessage({type:"openchamber:theme-sync",payload:de},window.location.origin)}},[C,N,S,b]),ae=c.useCallback(()=>{if(typeof window>"u")return;const de={allowPromptingSubagentSessions:m};for(const X of se.current.values()){const we=X.contentWindow;we&&we.postMessage({type:"openchamber:chat-settings-sync",payload:de},window.location.origin)}},[m]),Q=c.useCallback((de,X,we)=>{const ze=X.contentWindow;ze&&ze.postMessage({type:gu,payload:{visible:Ie===de}},we)},[Ie]),z=c.useCallback(()=>{if(!(typeof window>"u"))for(const[de,X]of se.current.entries())Q(de,X,window.location.origin)},[Q]);c.useEffect(()=>{if(typeof window>"u")return;const de=X=>{if(X.origin!==window.location.origin)return;const we=Array.from(se.current.entries()).find(([,qe])=>qe.contentWindow===X.source);if(!we)return;const ze=X.data;if(ze?.type===Mg){const[qe,at]=we;Q(qe,at,X.origin);return}if(ze?.type===Og){if(typeof ze.requestId!="string"||!ze.requestId)return;const qe=xs(),at={apiBaseUrl:Nn(),clientToken:Lr(),localOrigin:typeof window.__OPENCHAMBER_LOCAL_ORIGIN__=="string"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"",runtimeHeaders:hd(),relayHostId:qe.startsWith("host:")?qe.slice(5):"",relay:af()??void 0};X.source?.postMessage({type:Bg,requestId:ze.requestId,payload:at},X.origin);return}if(ze?.type==="openchamber:theme-sync-request"){he();return}if(ze?.type==="openchamber:chat-settings-request"){ae();return}if(ze?.type!=="openchamber:cycle-theme-request")return;const Ve=["light","dark","system"],$e=(Ve.indexOf(b)+1)%Ve.length;y(Ve[$e])};return window.addEventListener("message",de),()=>window.removeEventListener("message",de)},[ae,Q,he,y,b]),c.useLayoutEffect(()=>{k.some(X=>X.mode==="chat")&&(he(),ae(),z())},[N,S,ae,z,he,k,b]);const G=A?.mode==="file"||A?.mode==="chat"||A?.mode==="browser",ie=c.useMemo(()=>A?k.filter(de=>de.mode===A.mode):[],[A,k]),Oe=c.useMemo(()=>ie.map(de=>{const X=Kw(de,T,t),we=Zw(X,$w),ze=Vw(de.targetPath,e);return{id:de.id,label:we,icon:mc(de,x),title:ze?`${X}: ${ze}`:X,closeLabel:t("contextPanel.tab.closeTabAria",{label:we})}}),[ie,e,x,T,t]),Fe=A?.mode==="context"?s.jsx(Ay,{}):A?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Mw,{isActive:P})}):A?.mode==="pr"?s.jsx(Bb,{}):A?.mode==="linear"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Ow,{})}):A?.mode==="notes"?s.jsx(Jp,{}):A?.mode==="plan"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Bw,{targetPath:A.targetPath,savedProjectPlan:A.projectPlanId&&A.projectPlanRef?{projectRef:A.projectPlanRef,planId:A.projectPlanId}:null})}):null,Se=c.useMemo(()=>k.filter(de=>de.mode==="browser"),[k]),oe=c.useMemo(()=>k.filter(de=>de.mode==="diff"),[k]),Pe=c.useMemo(()=>k.some(de=>de.mode==="terminal"),[k]),Ne=c.useMemo(()=>k.some(de=>de.mode==="walkthrough"),[k]),B=c.useMemo(()=>k.some(de=>de.mode==="file"),[k]),ce=c.useMemo(()=>k.some(de=>de.mode==="file"&&de.targetPath),[k]),be=A?.mode==="file",ge=Te(de=>de.closeContextPanelTabs),_e=c.useCallback(de=>{if(!n)return null;const{id:X,index:we,allIds:ze,close:Ve}=de,He=()=>ge(n,ze.filter(It=>It!==X)),$e=()=>ge(n,ze.slice(0,we)),qe=()=>ge(n,ze.slice(we+1)),at=()=>ge(n,ze),gt=ze.length>1,Pt=we===0,Ge=we===ze.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Kn,{onClick:Ve,children:[s.jsx(E,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),s.jsx(Li,{}),s.jsxs(Kn,{onClick:He,disabled:!gt,children:[s.jsx(E,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Kn,{onClick:$e,disabled:Pt,children:[s.jsx(E,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Kn,{onClick:qe,disabled:Ge,children:[s.jsx(E,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),s.jsx(Li,{}),s.jsxs(Kn,{onClick:at,disabled:!gt,children:[s.jsx(E,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[ge,n,t]),tt=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[G?s.jsx(tu,{items:Oe,activeId:A?.id??null,onSelect:de=>{n&&d(n,de)},onClose:de=>{n&&o(n,de)},onReorder:(de,X)=>{n&&f(n,de,X)},layoutMode:"scrollable",variant:"default",tabContextMenu:_e}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[A?mc(A,x):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:A?am(A.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[A?.mode==="browser"?s.jsx(ot,{type:"button",variant:"ghost",size:"sm",onClick:()=>{n&&v(n)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:s.jsx(E,{name:"add",className:"h-3.5 w-3.5"})}):null,be?s.jsx(ot,{type:"button",variant:"ghost",size:"sm",onClick:w,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":p,children:s.jsx(E,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,s.jsx(ot,{type:"button",variant:"ghost",size:"sm",onClick:Ce,className:"h-7 w-7 p-0",title:t(D?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(D?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:D?s.jsx(E,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(E,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(ot,{type:"button",variant:"ghost",size:"sm",onClick:xe,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]})]}),Ue=P?D?{"--oc-context-panel-width":M!==null?`${M}px`:"100%",width:M!==null?`${M}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${I}px`}:{"--oc-context-panel-width":`${I}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:re,"data-context-panel":"true",tabIndex:-1,inert:!P||void 0,className:Re("flex min-h-0 flex-col overflow-hidden bg-background",D?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!P&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:Me,style:Ue,children:[P&&!D&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),P&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!D&&s.jsx("div",{className:Re("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",F&&"bg-[var(--interactive-border)]"),onPointerDown:ne,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:Re("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]",!P&&"pointer-events-none select-none opacity-0"),style:{width:D?M!==null?`${M}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!P,children:[tt,s.jsxs("div",{className:Re("relative min-h-0 flex-1 overflow-hidden",F&&"pointer-events-none"),children:[B?s.jsxs("div",{className:Re("absolute inset-0 flex",be?"flex":"hidden"),children:[s.jsx("div",{className:"h-full min-w-0 flex-1",children:ce?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Ew,{mode:"editor-only"})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(E,{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")})]})}),s.jsx(Qw,{visible:p})]}):null,q&&ye&&ke?s.jsx("iframe",{ref:de=>{if(!de){se.current.delete(q.id);return}se.current.set(q.id,de)},src:ke,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:ye}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{he(),ae(),z()}},q.id):null,Se.map(de=>s.jsx("div",{className:Re("absolute inset-0",A?.id!==de.id&&"hidden"),children:s.jsx(Nw,{initialUrl:de.targetPath??"",directory:n,tabID:de.id})},de.id)),oe.map(de=>s.jsx("div",{className:Re("absolute inset-0",A?.id!==de.id&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(Rw,{hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:de.diffScope??(de.stagedDiff?"staged":"working"),onDiffScopeChange:te,targetFilePath:de.targetPath,flushContent:!0})})},de.id)),Pe?s.jsx("div",{className:Re("absolute inset-0",A?.mode==="terminal"?"block":"hidden"),children:s.jsx(Zp,{visible:P&&A?.mode==="terminal"})}):null,Ne?s.jsx("div",{className:Re("absolute inset-0",A?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(Iw,{directory:e,visible:A?.mode==="walkthrough"})})}):null,A?.mode!=="chat"&&!be&&A?.mode!=="browser"&&A?.mode!=="diff"&&A?.mode!=="terminal"&&A?.mode!=="walkthrough"?Fe:null]})]})]})},tS=t=>{const e=Xe.c(42),{open:n,onOpenChange:r}=t,{t:i}=pt(),o=Te(sS),l=Te(nS),a=Te(rS),u=Te(oS);let d;e[0]!==o?(d=Rd(o),e[0]=o,e[1]=d):d=e[1];const h=d,f=l.length===0;let g;if(e[2]!==l||e[3]!==h){let A;e[5]!==l?(A=P=>l.includes(P.id),e[5]=l,e[6]=A):A=e[6],g=h.every(A),e[2]=l,e[3]=h,e[4]=g}else g=e[4];const p=g;let w;e[7]!==i?(w=i("contextRail.configure.dialogTitle"),e[7]=i,e[8]=w):w=e[8];let v;e[9]!==w?(v=s.jsx(Ts,{children:w}),e[9]=w,e[10]=v):v=e[10];let x;e[11]!==i?(x=i("contextRail.configure.dialogDescription"),e[11]=i,e[12]=x):x=e[12];let m;e[13]!==x?(m=s.jsx(Is,{children:x}),e[13]=x,e[14]=m):m=e[14];let b;e[15]!==v||e[16]!==m?(b=s.jsxs(Ls,{children:[v,m]}),e[15]=v,e[16]=m,e[17]=b):b=e[17];let y;if(e[18]!==l||e[19]!==a||e[20]!==h||e[21]!==i){let A;e[23]!==l||e[24]!==a||e[25]!==i?(A=P=>s.jsx(eh,{settingsItem:`layout.context-rail.surface.${P.id}`,checked:!l.includes(P.id),onChange:D=>a(P.id,D),label:i(P.labelKey),ariaLabel:i(P.labelKey)},P.id),e[23]=l,e[24]=a,e[25]=i,e[26]=A):A=e[26],y=h.map(A),e[18]=l,e[19]=a,e[20]=h,e[21]=i,e[22]=y}else y=e[22];let S;e[27]!==y?(S=s.jsx("div",{className:"flex flex-col",children:y}),e[27]=y,e[28]=S):S=e[28];let N;e[29]!==f||e[30]!==p||e[31]!==u||e[32]!==i?(N=f?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[p?s.jsx("span",{className:"text-xs text-destructive",children:i("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(ot,{variant:"link",size:"xs",onClick:()=>u([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[29]=f,e[30]=p,e[31]=u,e[32]=i,e[33]=N):N=e[33];let C;e[34]!==N||e[35]!==b||e[36]!==S?(C=s.jsxs(vs,{className:"max-w-md",children:[b,S,N]}),e[34]=N,e[35]=b,e[36]=S,e[37]=C):C=e[37];let k;return e[38]!==r||e[39]!==n||e[40]!==C?(k=s.jsx(Ss,{open:n,onOpenChange:r,children:C}),e[38]=r,e[39]=n,e[40]=C,e[41]=k):k=e[41],k};function sS(t){return t.contextRailOrder}function nS(t){return t.contextRailHiddenSurfaces}function rS(t){return t.setContextRailSurfaceVisible}function oS(t){return t.setContextRailHiddenSurfaces}const lm=150,iS=500,aS=[],lS=t=>t>99?"99+":String(t),cS=t=>{const e=Xe.c(51),{surface:n,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:u,badgeDescription:d,orderNumber:h,showOrderNumber:f,onSelect:g}=t;let p;e[0]!==n.id?(p={id:n.id},e[0]=n.id,e[1]=p):p=e[1];const{attributes:w,listeners:v,setNodeRef:x,transform:m,transition:b,isDragging:y}=ti(p);let S;e[2]!==a?(S=a!=null&&a>0?lS(a):null,e[2]=a,e[3]=S):S=e[3];const N=S;let C;e[4]!==m?(C=si.Translate.toString(m),e[4]=m,e[5]=C):C=e[5];let k;e[6]!==C||e[7]!==b?(k={transform:C,transition:b},e[6]=C,e[7]=b,e[8]=k):k=e[8];const A=y&&"z-10 opacity-70";let P;e[9]!==A?(P=Re("relative",A),e[9]=A,e[10]=P):P=e[10];let D;e[11]!==g||e[12]!==n?(D=()=>g(n),e[11]=g,e[12]=n,e[13]=D):D=e[13];const M=u??o,$=r?"text-primary":"text-muted-foreground hover:text-foreground";let R;e[14]!==$?(R=Re("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",$),e[14]=$,e[15]=R):R=e[15];let K;e[16]!==n.icon||e[17]!==n.id?(K=n.id==="diff"?s.jsx(Eu,{}):s.jsx(E,{name:n.icon,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.id,e[18]=K):K=e[18];let L;e[19]!==N||e[20]!==h||e[21]!==i||e[22]!==f?(L=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}):N?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:N}):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[19]=N,e[20]=h,e[21]=i,e[22]=f,e[23]=L):L=e[23];let O;e[24]!==w||e[25]!==r||e[26]!==v||e[27]!==R||e[28]!==K||e[29]!==L||e[30]!==D||e[31]!==M?(O=s.jsx(bt,{asChild:!0,children:s.jsxs("button",{type:"button",...w,...v,onClick:D,"aria-label":M,"aria-pressed":r,className:R,children:[K,L]})}),e[24]=w,e[25]=r,e[26]=v,e[27]=R,e[28]=K,e[29]=L,e[30]=D,e[31]=M,e[32]=O):O=e[32];let I;e[33]!==o?(I=s.jsx("span",{children:o}),e[33]=o,e[34]=I):I=e[34];let j;e[35]!==l?(j=s.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[35]=l,e[36]=j):j=e[36];let T;e[37]!==d?(T=d?s.jsx("span",{className:"typography-micro text-muted-foreground",children:d}):null,e[37]=d,e[38]=T):T=e[38];let F;e[39]!==I||e[40]!==j||e[41]!==T?(F=s.jsx(yt,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[I,j,T]})}),e[39]=I,e[40]=j,e[41]=T,e[42]=F):F=e[42];let U;e[43]!==O||e[44]!==F?(U=s.jsxs(xt,{delayDuration:lm,children:[O,F]}),e[43]=O,e[44]=F,e[45]=U):U=e[45];let H;return e[46]!==x||e[47]!==U||e[48]!==k||e[49]!==P?(H=s.jsx("div",{ref:x,style:k,className:P,children:U}),e[46]=x,e[47]=U,e[48]=k,e[49]=P,e[50]=H):H=e[50],H},dS=()=>{const t=Xe.c(86),{t:e}=pt(),n=Yr();let r;t[0]!==n?(r=n?or(n):"",t[0]=n,t[1]=r):r=t[1];const i=r;let o;t[2]!==i?(o=De=>i?De.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const l=Te(o),a=Te(uS),u=Te(mS),d=Te(fS),h=Te(hS),f=Te(pS),g=Te(gS),p=Te(xS),w=va(bS),v=Ti(yS),x=Ti(wS),m=An(SS),b=An(vS),{screenWidth:y}=Ln(),S=ja(i||null);let N;t[4]!==p?(N=Ii("switch_context_surface",p),t[4]=p,t[5]=N):N=t[5];const C=N,[k,A]=c.useState(!1);let P,D;t[6]!==C?(P=()=>{const De=new Set;let ke=null,te=!1;const he=jS,ae=()=>{al(C,De)?!te&&ke===null&&(ke=setTimeout(()=>A(!0),iS)):(te=!1,ke!==null&&(clearTimeout(ke),ke=null),A(!1))},Q=ie=>{if(De.add(ie.key.toLowerCase()),he(ie.key)&&al(C,De)){te=!0,ke!==null&&(clearTimeout(ke),ke=null),A(!1);return}ae()},z=ie=>{De.delete(ie.key.toLowerCase()),ae()},G=()=>{De.clear(),te=!1,ke!==null&&(clearTimeout(ke),ke=null),A(!1)};return window.addEventListener("keydown",Q,!0),window.addEventListener("keyup",z,!0),window.addEventListener("blur",G),()=>{window.removeEventListener("keydown",Q,!0),window.removeEventListener("keyup",z,!0),window.removeEventListener("blur",G),ke!==null&&clearTimeout(ke)}},D=[C],t[6]=C,t[7]=P,t[8]=D):(P=t[7],D=t[8]),c.useEffect(P,D);let M;t[9]===Symbol.for("react.memo_cache_sentinel")?(M={activationConstraint:{distance:8}},t[9]=M):M=t[9];let $;t[10]===Symbol.for("react.memo_cache_sentinel")?($={activationConstraint:{delay:200,tolerance:6}},t[10]=$):$=t[10];const R=zr(On(cu,M),On(lu,$)),K=l?.tabs??aS;let L;t[11]!==l?.activeTabId||t[12]!==K?(L=K.find(De=>De.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=K,t[13]=L):L=t[13];const O=L,I=l?.isOpen?O?.mode??null:null,j=S?.files.length??0;let T;t[14]!==d||t[15]!==u||t[16]!==b||t[17]!==x||t[18]!==w||t[19]!==y||t[20]!==K?(T=th({railOrder:u,hiddenSurfaces:d,planModeEnabled:w,isVSCode:Pn(),screenWidth:y,tabs:K,linearConnected:x,githubConnected:b}),t[14]=d,t[15]=u,t[16]=b,t[17]=x,t[18]=w,t[19]=y,t[20]=K,t[21]=T):T=t[21];const F=T;let U,H;t[22]!==I||t[23]!==g||t[24]!==i||t[25]!==v||t[26]!==x?(H=()=>{!i||!v||x||I!=="linear"||g(i)},U=[I,g,i,v,x],t[22]=I,t[23]=g,t[24]=i,t[25]=v,t[26]=x,t[27]=U,t[28]=H):(U=t[27],H=t[28]),c.useEffect(H,U);let Y,me;t[29]!==I||t[30]!==g||t[31]!==i||t[32]!==m||t[33]!==b?(Y=()=>{!i||!m||b||I!=="pr"||g(i)},me=[I,g,i,m,b],t[29]=I,t[30]=g,t[31]=i,t[32]=m,t[33]=b,t[34]=Y,t[35]=me):(Y=t[34],me=t[35]),c.useEffect(Y,me);const[Z,re]=c.useState(!1);let se;t[36]!==h?(se=De=>{const{active:ke,over:te}=De;if(!te||ke.id===te.id)return;const he=Rd(Te.getState().contextRailOrder).map(kS),ae=he.indexOf(ke.id),Q=he.indexOf(te.id);ae===-1||Q===-1||h(du(he,ae,Q))},t[36]=h,t[37]=se):se=t[37];const fe=se;if(!i)return null;let _;t[38]!==e?(_=e("contextRail.aria.rail"),t[38]=e,t[39]=_):_=t[39];let le;t[40]!==F?(le=F.map(CS),t[40]=F,t[41]=le):le=t[41];let ee;if(t[42]!==I||t[43]!==j||t[44]!==i||t[45]!==f||t[46]!==k||t[47]!==F||t[48]!==e||t[49]!==a){let De;t[51]!==I||t[52]!==j||t[53]!==i||t[54]!==f||t[55]!==k||t[56]!==e||t[57]!==a?(De=(ke,te)=>{const he=e(ke.labelKey),ae=ke.id==="git"&&!a?j:0,Q=ae>0?ae:null;return s.jsx(cS,{surface:ke,isActive:I===ke.mode,showActivityDot:!1,label:he,description:e(ke.descriptionKey),badgeCount:Q,badgeAriaLabel:Q!==null?e(Q===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:he,count:Q}):null,badgeDescription:Q!==null?e(Q===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:Q}):null,orderNumber:te+1,showOrderNumber:k,onSelect:z=>f(i,z.mode)},ke.id)},t[51]=I,t[52]=j,t[53]=i,t[54]=f,t[55]=k,t[56]=e,t[57]=a,t[58]=De):De=t[58],ee=F.map(De),t[42]=I,t[43]=j,t[44]=i,t[45]=f,t[46]=k,t[47]=F,t[48]=e,t[49]=a,t[50]=ee}else ee=t[50];let ue;t[59]!==le||t[60]!==ee?(ue=s.jsx(Oo,{items:le,strategy:zi,children:ee}),t[59]=le,t[60]=ee,t[61]=ue):ue=t[61];let W;t[62]!==fe||t[63]!==R||t[64]!==ue?(W=s.jsx(Vr,{sensors:R,collisionDetection:Ur,onDragEnd:fe,children:ue}),t[62]=fe,t[63]=R,t[64]=ue,t[65]=W):W=t[65];let ne;t[66]!==e?(ne=e("contextRail.configure.open"),t[66]=e,t[67]=ne):ne=t[67];let pe;t[68]===Symbol.for("react.memo_cache_sentinel")?(pe=()=>re(!0),t[68]=pe):pe=t[68];let xe;t[69]===Symbol.for("react.memo_cache_sentinel")?(xe=s.jsx(E,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[69]=xe):xe=t[69];let Ce;t[70]!==ne?(Ce=s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":ne,onClick:pe,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:xe})}),t[70]=ne,t[71]=Ce):Ce=t[71];let Me;t[72]!==e?(Me=e("contextRail.configure.open"),t[72]=e,t[73]=Me):Me=t[73];let ve;t[74]!==Me?(ve=s.jsx(yt,{side:"left",sideOffset:8,children:Me}),t[74]=Me,t[75]=ve):ve=t[75];let Ie;t[76]!==Ce||t[77]!==ve?(Ie=s.jsxs(xt,{delayDuration:lm,children:[Ce,ve]}),t[76]=Ce,t[77]=ve,t[78]=Ie):Ie=t[78];let ye;t[79]!==Z?(ye=s.jsx(tS,{open:Z,onOpenChange:re}),t[79]=Z,t[80]=ye):ye=t[80];let q;return t[81]!==_||t[82]!==W||t[83]!==Ie||t[84]!==ye?(q=s.jsxs("nav",{"aria-label":_,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[W,Ie,ye]}),t[81]=_,t[82]=W,t[83]=Ie,t[84]=ye,t[85]=q):q=t[85],q};function uS(t){return t.workStatusPanelVisible}function mS(t){return t.contextRailOrder}function fS(t){return t.contextRailHiddenSurfaces}function hS(t){return t.setContextRailOrder}function pS(t){return t.openContextSurface}function gS(t){return t.closeContextPanel}function xS(t){return t.shortcutOverrides}function bS(t){return t.planModeEnabled}function yS(t){return t.hasChecked}function wS(t){return t.status?.connected===!0}function SS(t){return t.hasChecked}function vS(t){return t.status?.connected===!0}function jS(t){return t.length===1&&t>="0"&&t<="9"}function kS(t){return t.id}function CS(t){return t.id}const NS=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),AS=(t,e,n,r)=>!n||r!==n||t.length===0?[]:Er(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),PS=new Set,DS=[],ra=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},TS=()=>{const t=Xe.c(182),{t:e}=pt(),n=Te(IS),r=Te(RS),i=Te(ES),o=Te(MS),l=Te(OS),a=Te(BS),u=Te(FS),d=Te(_S),h=Te(LS),f=Te($S),g=Te(WS),p=Te(zS),w=Te(VS),v=Qe(US),x=Qe(KS),m=Qe(HS),b=$r(GS);let y;t[0]!==n?(y=Ye=>n?Ye.activeSessions:DS,t[0]=n,t[1]=y):y=t[1];const S=Ds(y);let N;t[2]!==n?(N=Ye=>n?Ye.ids:PS,t[2]=n,t[3]=N):N=t[3];const C=$r(N);let k;t[4]!==n?(k=Ye=>n?Ye.rankById:Md,t[4]=n,t[5]=k):k=t[5];const A=Aa(k),P=es(qS),D=zt(QS),M=zt(YS),$=Yr(),R=fd(XS),{files:K,git:L}=Dn(),O=Bn(JS),{isMobile:I}=Ln();let j;t[6]!==$?(j=$?ra($):null,t[6]=$,t[7]=j):j=t[7];const T=j,[F,U]=c.useState(""),Y=Na(F,200).trim();let me;t[8]!==F?(me=F.trim(),t[8]=F,t[9]=me):me=t[9];const Z=me;let re,se;t[10]!==n?(re=()=>{n&&U("")},se=[n],t[10]=n,t[11]=re,t[12]=se):(re=t[11],se=t[12]),c.useEffect(re,se);let fe,_;t[13]!==S||t[14]!==O||t[15]!==L||t[16]!==n?(fe=()=>{if(!n||!L)return;const Ye=setTimeout(()=>{const it=new Set;for(const Nt of S){const Dt=_s(Nt);!Dt||it.has(Dt)||(it.add(Dt),O(Dt,L))}},0);return()=>clearTimeout(Ye)},_=[n,S,L,O],t[13]=S,t[14]=O,t[15]=L,t[16]=n,t[17]=fe,t[18]=_):(fe=t[17],_=t[18]),c.useEffect(fe,_);let le;t[19]!==r?(le=()=>r(!1),t[19]=r,t[20]=le):le=t[20];const ee=le;let ue;t[21]!==ee?(ue=Ye=>()=>{ee(),Ye()},t[21]=ee,t[22]=ue):ue=t[22];const W=ue;let ne;t[23]!==D?.id||t[24]!==D?.path||t[25]!==P||t[26]!==m||t[27]!==I||t[28]!==u||t[29]!==d||t[30]!==g||t[31]!==v||t[32]!==W||t[33]!==p||t[34]!==w||t[35]!==l||t[36]!==i||t[37]!==e||t[38]!==b||t[39]!==a?(ne=()=>{const Ye=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(E,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:W(()=>{l(!1),v()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(E,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:W(ZS)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(E,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:W(ev)},{id:"toggle-sidebar",title:e(I?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(E,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e(I?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:W(()=>{if(I){const{isSessionSwitcherOpen:it}=Te.getState();l(!it)}else a()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(E,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:W(()=>{P&&d(P,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(E,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:W(()=>{P&&u(P)})},{id:"cycle-theme",secondary:!0,title:e("commandPalette.item.cycleTheme"),icon:s.jsx(E,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:e("commandPalette.item.cycleTheme"),onSelect:W(tv)},{id:"open-status",secondary:!0,title:e("commandPalette.item.showOpenCodeStatus"),icon:s.jsx(E,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showOpenCodeStatus"),onSelect:W(sv)},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(E,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:W(()=>i(!0))}];return Ye.push({id:"pin-session",secondary:!0,title:e("commandPalette.item.pinSession"),icon:s.jsx(E,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.pinSession"),onSelect:W(()=>{m&&P&&b({directory:P,sessionId:m})})},{id:"copy-session-id",secondary:!0,title:e("commandPalette.item.copySessionId"),icon:s.jsx(E,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.copySessionId"),onSelect:W(()=>{m&&hn(m).then(it=>{if(it.ok){Be.success(e("sessions.sidebar.session.copyId.success"));return}Be.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Be.error(e("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:e("commandPalette.item.openMultiRun"),icon:s.jsx(E,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openMultiRun"),onSelect:W(()=>{l(!1),g()})},{id:"open-archive",secondary:!0,title:e("commandPalette.item.openArchive"),icon:s.jsx(E,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openArchive"),onSelect:W(()=>{l(!1),p(!0)})},{id:"open-notes",secondary:!0,title:e("commandPalette.item.openNotes"),icon:s.jsx(E,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openNotes"),onSelect:W(()=>{P&&(w("notes"),d(P,"notes"))})},{id:"open-todos",secondary:!0,title:e("commandPalette.item.openTodos"),icon:s.jsx(E,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openTodos"),onSelect:W(()=>{P&&(w("todos"),d(P,"notes"))})}),Ye.push({id:"toggle-memory-debug",secondary:!0,title:e("commandPalette.item.toggleMemoryDebug"),icon:s.jsx(E,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.toggleMemoryDebug"),onSelect:W(nv)}),qo()&&Ye.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(E,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:W(()=>{Mn("desktop_open_draft_mini_chat_window",{directory:ra(P||D?.path||""),projectId:D?.id??null}).catch(rv)})}),Ye},t[23]=D?.id,t[24]=D?.path,t[25]=P,t[26]=m,t[27]=I,t[28]=u,t[29]=d,t[30]=g,t[31]=v,t[32]=W,t[33]=p,t[34]=w,t[35]=l,t[36]=i,t[37]=e,t[38]=b,t[39]=a,t[40]=ne):ne=t[40],D?.id,D?.path;let pe;t[41]!==ne?(pe=ne(),t[41]=ne,t[42]=pe):pe=t[42];const xe=pe;let Ce;t[43]===Symbol.for("react.memo_cache_sentinel")?(Ce=gn(),t[43]=Ce):Ce=t[43];const Me=Ce;let ve,Ie;t[44]===Symbol.for("react.memo_cache_sentinel")?(ve=Pn(),Ie=!Me&&ba(),t[44]=ve,t[45]=Ie):(ve=t[44],Ie=t[45]);let ye;t[46]!==I?(ye={isVSCode:ve,isWeb:Ie,isDesktop:Me,isMobile:I},t[46]=I,t[47]=ye):ye=t[47];const q=ye;let De;if(t[48]!==W||t[49]!==i||t[50]!==o||t[51]!==q){let Ye;t[53]!==q?(Ye=Nt=>Nt.isAvailable?Nt.isAvailable(q):!0,t[53]=q,t[54]=Ye):Ye=t[54];let it;t[55]!==W||t[56]!==i||t[57]!==o?(it=Nt=>{const Dt=tg(Nt.slug)??"settings-3",Rt=(Nt.keywords??[]).join(" ");return{id:`settings:${Nt.slug}`,title:Nt.title,icon:Nt.slug==="mcp"?s.jsx(ih,{className:"mr-2 h-4 w-4"}):s.jsx(E,{name:Dt,className:"mr-2 h-4 w-4"}),searchText:`${Nt.title} ${Nt.group} ${Rt}`,onSelect:W(()=>{o(Nt.slug),i(!0)})}},t[55]=W,t[56]=i,t[57]=o,t[58]=it):it=t[58],De=eg.filter(ov).filter(Ye).map(it),t[48]=W,t[49]=i,t[50]=o,t[51]=q,t[52]=De}else De=t[52];const ke=De;let te;if(t[59]!==S||t[60]!==C||t[61]!==A){const Ye=S.filter(iv);te=sh(Ye,C,A),t[59]=S,t[60]=C,t[61]=A,t[62]=te}else te=t[62];const he=te,ae=Ed(),Q=Qe(av);let z;t[63]!==ae||t[64]!==Q?(z=(Ye,it)=>{const Nt=Q.get(Ye);return Nt?.branch?Nt.branch.trim()||null:it&&ae.get(it)?.trim()||null},t[63]=ae,t[64]=Q,t[65]=z):z=t[65];const G=z;let ie;t[66]===Symbol.for("react.memo_cache_sentinel")?(ie=[],t[66]=ie):ie=t[66];const[Oe,Fe]=c.useState(ie),[Se,oe]=c.useState(""),Pe=NS(T,Y);let Ne;t[67]!==T||t[68]!==Pe||t[69]!==n||t[70]!==R||t[71]!==Fe||t[72]!==oe||t[73]!==Y?(Ne=()=>{if(!n){Fe([]),oe("");return}if(!Pe){Fe([]),oe("");return}if(!T){Fe([]),oe("");return}let Ye=!1;return R(T,Y,40,{type:"file"}).then(it=>{Ye||(Fe(it.map(lv)),oe(Pe))}).catch(()=>{Ye||(Fe([]),oe(Pe))}),()=>{Ye=!0}},t[67]=T,t[68]=Pe,t[69]=n,t[70]=R,t[71]=Fe,t[72]=oe,t[73]=Y,t[74]=Ne):Ne=t[74];let B;t[75]!==T||t[76]!==Pe||t[77]!==n||t[78]!==R||t[79]!==Y?(B=[n,T,Y,Pe,R],t[75]=T,t[76]=Pe,t[77]=n,t[78]=R,t[79]=Y,t[80]=B):B=t[80],c.useEffect(Ne,B);const ce=Z.length>0;let be;e:{if(!ce){let it;t[81]!==xe?(it=xe.filter(cv).map(dv),t[81]=xe,t[82]=it):it=t[82],be=it;break e}let Ye;t[83]!==xe||t[84]!==Z?(Ye=Er(xe,Z,uv,{limit:7,noFuzzy:!0}),t[83]=xe,t[84]=Z,t[85]=Ye):Ye=t[85],be=Ye}const ge=be;let _e;e:{if(!ce){let it;t[86]===Symbol.for("react.memo_cache_sentinel")?(it=[],t[86]=it):it=t[86],_e=it;break e}let Ye;t[87]!==Z||t[88]!==ke?(Ye=Er(ke,Z,mv,{limit:7,noFuzzy:!0}),t[87]=Z,t[88]=ke,t[89]=Ye):Ye=t[89],_e=Ye}const tt=_e;let Ue;e:{if(!ce){let it;t[90]!==he?(it=he.slice(0,5).map(fv),t[90]=he,t[91]=it):it=t[91],Ue=it;break e}let Ye;t[92]!==Z||t[93]!==he?(Ye=Er(he,Z,hv,{limit:7,threshold:.2}),t[92]=Z,t[93]=he,t[94]=Ye):Ye=t[94],Ue=Ye}const de=Ue;let X;e:{if(!n){let it;t[95]===Symbol.for("react.memo_cache_sentinel")?(it=[],t[95]=it):it=t[95],X=it;break e}let Ye;t[96]!==Oe||t[97]!==Se||t[98]!==Pe||t[99]!==Y?(Ye=AS(Oe,Y,Pe,Se),t[96]=Oe,t[97]=Se,t[98]=Pe,t[99]=Y,t[100]=Ye):Ye=t[100],X=Ye}const we=X,ze=n&&Pe.length>0&&Se!==Pe;let Ve;e:{if(!ce){let it;t[101]===Symbol.for("react.memo_cache_sentinel")?(it=[],t[101]=it):it=t[101],Ve=it;break e}let Ye;if(t[102]!==Z||t[103]!==M){const it=M.map(pv);Ye=Er(it,Z,gv,{limit:7,threshold:.4}),t[102]=Z,t[103]=M,t[104]=Ye}else Ye=t[104];Ve=Ye}const He=Ve;let $e,qe,at,gt,Pt,Ge,It,kt,Mt,Tt,wt,St,vt,ht;if(t[105]!==G||t[106]!==ee||t[107]!==T||t[108]!==K||t[109]!==ce||t[110]!==n||t[111]!==h||t[112]!==v||t[113]!==F||t[114]!==ge||t[115]!==we||t[116]!==He||t[117]!==de||t[118]!==tt||t[119]!==r||t[120]!==x||t[121]!==f||t[122]!==e){const Ye=ge.map(xv),it=tt.map(bv),Nt=de.map(yv),Dt=ce?we.map(wv):[],Rt=ce?He.map(Sv):[];let Vt;e:{if(!ce){Vt=["commands","sessions"];break e}const jt=vv,st=[{key:"commands",score:jt(ge)},{key:"settings",score:jt(tt)},{key:"sessions",score:jt(de)},{key:"files",score:jt(we)},{key:"projects",score:jt(He)}];st.sort(jv),Vt=st.map(kv)}const Qt=Vt,Ut=jt=>{ee(),x(jt.id,_s(jt))},Ft=async jt=>{if(!T)return;const st=await _u(K,jt,{directory:T});if(!st.ok){Be.error(Lu(st.reason));return}h(T,jt),ee()},Yt=(jt,st)=>{ee(),v({selectedProjectId:jt,directoryOverride:st})},$t=jt=>Qn(Qr(jt,f));gt=Ss,St=n,vt=r;let _t;t[137]!==e?(_t=e("commandPalette.title"),t[137]=e,t[138]=_t):_t=t[138];let Ee;t[139]!==_t?(Ee=s.jsx(Ts,{children:_t}),t[139]=_t,t[140]=Ee):Ee=t[140];let Ke;t[141]!==e?(Ke=e("commandPalette.description"),t[141]=e,t[142]=Ke):Ke=t[142];let et;t[143]!==Ke?(et=s.jsx(Is,{children:Ke}),t[143]=Ke,t[144]=et):et=t[144],t[145]!==Ee||t[146]!==et?(ht=s.jsxs(Ls,{className:"sr-only",children:[Ee,et]}),t[145]=Ee,t[146]=et,t[147]=ht):ht=t[147],at=vs,Tt="overflow-hidden p-0",wt=!0,qe=ah,It=!1,kt="[&_[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 ct;t[148]!==e?(ct=e("commandPalette.input.placeholder"),t[148]=e,t[149]=ct):ct=t[149],t[150]!==F||t[151]!==ct?(Mt=s.jsx(lh,{value:F,onValueChange:U,placeholder:ct}),t[150]=F,t[151]=ct,t[152]=Mt):Mt=t[152],$e=ch;let ut;t[153]!==e?(ut=e("commandPalette.empty.noResults"),t[153]=e,t[154]=ut):ut=t[154],t[155]!==ut?(Pt=s.jsx(dh,{children:ut}),t[155]=ut,t[156]=Pt):Pt=t[156],Ge=Qt.map(jt=>jt==="commands"&&Ye.length>0?s.jsx(kr,{children:Ye.map(st=>s.jsxs(Mr,{value:st.id,onSelect:st.onSelect,children:[st.icon,s.jsx("span",{children:st.title}),st.shortcutId?s.jsx(nh,{children:$t(st.shortcutId)}):null]},st.id))},"commands"):jt==="settings"&&it.length>0?s.jsx(kr,{children:it.map(Cv)},"settings"):jt==="sessions"&&Nt.length>0?s.jsx(kr,{children:Nt.map(st=>{const Lt=st.title||e("commandPalette.session.untitled"),Xt=_s(st),ds=G(st.id,Xt);return s.jsxs(Mr,{value:`session:${st.id}`,onSelect:()=>Ut(st),children:[s.jsx(E,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:Lt}),ds?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(E,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:ds})]}):null]},st.id)})},"sessions"):jt==="files"&&Dt.length>0?s.jsx(kr,{children:Dt.map(st=>{const Lt=rh(st.relativePath||st.name,{maxLength:80});return s.jsxs(Mr,{value:`file:${st.path}`,onSelect:()=>{Ft(st.path)},children:[s.jsx(Ca,{filePath:st.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":st.relativePath,children:Lt})]},`file:${st.path}`)})},"files"):jt==="projects"&&Rt.length>0?s.jsx(kr,{children:Rt.map(st=>{const Lt=st.displayName;return s.jsxs(Mr,{value:`project:${st.id}`,onSelect:()=>Yt(st.id,st.path),children:[s.jsx(E,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:Lt}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:st.path})]},`project:${st.id}`)})},"projects"):null),t[105]=G,t[106]=ee,t[107]=T,t[108]=K,t[109]=ce,t[110]=n,t[111]=h,t[112]=v,t[113]=F,t[114]=ge,t[115]=we,t[116]=He,t[117]=de,t[118]=tt,t[119]=r,t[120]=x,t[121]=f,t[122]=e,t[123]=$e,t[124]=qe,t[125]=at,t[126]=gt,t[127]=Pt,t[128]=Ge,t[129]=It,t[130]=kt,t[131]=Mt,t[132]=Tt,t[133]=wt,t[134]=St,t[135]=vt,t[136]=ht}else $e=t[123],qe=t[124],at=t[125],gt=t[126],Pt=t[127],Ge=t[128],It=t[129],kt=t[130],Mt=t[131],Tt=t[132],wt=t[133],St=t[134],vt=t[135],ht=t[136];let Ze;t[157]!==ze||t[158]!==e?(Ze=ze?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[157]=ze,t[158]=e,t[159]=Ze):Ze=t[159];let je;t[160]!==$e||t[161]!==Pt||t[162]!==Ge||t[163]!==Ze?(je=s.jsxs($e,{children:[Pt,Ge,Ze]}),t[160]=$e,t[161]=Pt,t[162]=Ge,t[163]=Ze,t[164]=je):je=t[164];let nt;t[165]!==qe||t[166]!==It||t[167]!==kt||t[168]!==Mt||t[169]!==je?(nt=s.jsxs(qe,{shouldFilter:It,className:kt,children:[Mt,je]}),t[165]=qe,t[166]=It,t[167]=kt,t[168]=Mt,t[169]=je,t[170]=nt):nt=t[170];let lt;t[171]!==at||t[172]!==Tt||t[173]!==wt||t[174]!==nt?(lt=s.jsx(at,{className:Tt,showCloseButton:wt,children:nt}),t[171]=at,t[172]=Tt,t[173]=wt,t[174]=nt,t[175]=lt):lt=t[175];let Ct;return t[176]!==gt||t[177]!==St||t[178]!==vt||t[179]!==ht||t[180]!==lt?(Ct=s.jsxs(gt,{open:St,onOpenChange:vt,children:[ht,lt]}),t[176]=gt,t[177]=St,t[178]=vt,t[179]=ht,t[180]=lt,t[181]=Ct):Ct=t[181],Ct};function IS(t){return t.isCommandPaletteOpen}function RS(t){return t.setCommandPaletteOpen}function ES(t){return t.setSettingsDialogOpen}function MS(t){return t.setSettingsPage}function OS(t){return t.setSessionSwitcherOpen}function BS(t){return t.toggleSidebar}function FS(t){return t.openContextOverview}function _S(t){return t.openContextSurface}function LS(t){return t.openContextFile}function $S(t){return t.shortcutOverrides}function WS(t){return t.openMultiRunLauncher}function zS(t){return t.setArchivePageOpen}function VS(t){return t.setProjectContextTab}function US(t){return t.openNewSessionDraft}function KS(t){return t.setCurrentSession}function HS(t){return t.currentSessionId}function GS(t){return t.toggle}function qS(t){return t.currentDirectory}function QS(t){return t.getActiveProject()}function YS(t){return t.projects}function XS(t){return t.searchFiles}function JS(t){return t.ensureStatus}function ZS(){Od()}function ev(){pn.requestDirectoryDialog()}function tv(){uh.invoke("cycle_theme")}function sv(){Bd()}function nv(){window.dispatchEvent(new CustomEvent("openchamber:memory-debug-toggle"))}function rv(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function ov(t){return t.slug!=="home"}function iv(t){return!oh(t)}function av(t){return t.worktreeMetadata}function lv(t){return{path:ra(t.path),name:t.name,relativePath:t.relativePath}}function cv(t){return!t.secondary}function dv(t){return{item:t,score:0}}function uv(t){return t.searchText}function mv(t){return t.searchText}function fv(t){return{item:t,score:0}}function hv(t){return t.title||""}function pv(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function gv(t){return t.searchText}function xv(t){return t.item}function bv(t){return t.item}function yv(t){return t.item}function wv(t){return t.item}function Sv(t){return t.item}function vv(t){return t.length?t[0].score:1/0}function jv(t,e){return t.score-e.score}function kv(t){return t.key}function Cv(t){return s.jsxs(Mr,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const fc=(t,e,n)=>Qn(Qr(t,e),n),Nv=()=>{const t=Xe.c(68),{t:e}=pt(),n=Te(Av),r=Te(Pv),i=Te(Dv);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=Pn(),t[0]=o):o=t[0];const l=o;let a,u,d,h,f,g,p,w,v;if(t[1]!==n||t[2]!==r||t[3]!==i||t[4]!==e){const L=[{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:[Qn("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:[`${Qn(Ii("switch_context_surface",i))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${Qn(Ii("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=Ss,w=n,v=r,a=vs,g="max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let O;t[14]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(E,{name:"command",className:"h-5 w-5"}),t[14]=O):O=t[14];let I;t[15]!==e?(I=e("helpDialog.title"),t[15]=e,t[16]=I):I=t[16];let j;t[17]!==I?(j=s.jsxs(Ts,{className:"flex items-center gap-2",children:[O,I]}),t[17]=I,t[18]=j):j=t[18];let T;t[19]!==e?(T=e("helpDialog.description"),t[19]=e,t[20]=T):T=t[20];let F;t[21]!==T?(F=s.jsx(Is,{children:T}),t[21]=T,t[22]=F):F=t[22],t[23]!==j||t[24]!==F?(p=s.jsxs(Ls,{children:[j,F]}),t[23]=j,t[24]=F,t[25]=p):p=t[25],f="flex-1 overflow-y-auto mt-3 pr-1",d="space-y-4",h=L.map(U=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(U.categoryKey)}),s.jsx("div",{className:"space-y-1",children:U.items.filter(H=>!(l&&H.id==="toggle_prompt_navigator")).map(H=>{const Y=H.id?mh(H.id):void 0,me=H.descriptionKey??(Y?.customizable?Y.settingsLabelKey:void 0);if(!me||H.id&&!Qr(H.id,i))return null;const Z=H.id?fc(H.id,i,e("settings.openchamber.keyboardShortcuts.unassigned")):Array.isArray(H.keys)?H.keys:H.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:[H.icon&&s.jsx(E,{name:H.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(me)})]}),s.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(Z)?Z:[Z]).map((re,se)=>s.jsxs(c.Fragment,{children:[se>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:re})]},`${re}-${se}`))})]},H.id||me)})})]},U.categoryKey)),t[1]=n,t[2]=r,t[3]=i,t[4]=e,t[5]=a,t[6]=u,t[7]=d,t[8]=h,t[9]=f,t[10]=g,t[11]=p,t[12]=w,t[13]=v}else a=t[5],u=t[6],d=t[7],h=t[8],f=t[9],g=t[10],p=t[11],w=t[12],v=t[13];let x;t[26]!==d||t[27]!==h?(x=s.jsx("div",{className:d,children:h}),t[26]=d,t[27]=h,t[28]=x):x=t[28];let m;t[29]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(E,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),t[29]=m):m=t[29];let b;t[30]!==e?(b=e("helpDialog.proTips.title"),t[30]=e,t[31]=b):b=t[31];let y;t[32]!==b?(y=s.jsx("p",{className:"font-medium mb-1",children:b}),t[32]=b,t[33]=y):y=t[33];let S;t[34]!==i||t[35]!==e?(S=e("helpDialog.proTips.commandPalette",{shortcut:fc("open_command_palette",i,e("settings.openchamber.keyboardShortcuts.unassigned"))}),t[34]=i,t[35]=e,t[36]=S):S=t[36];let N;t[37]!==S?(N=s.jsxs("li",{children:["• ",S]}),t[37]=S,t[38]=N):N=t[38];let C;t[39]!==e?(C=e("helpDialog.proTips.recentSessions"),t[39]=e,t[40]=C):C=t[40];let k;t[41]!==C?(k=s.jsxs("li",{children:["• ",C]}),t[41]=C,t[42]=k):k=t[42];let A;t[43]!==e?(A=e("helpDialog.proTips.leaderSequences"),t[43]=e,t[44]=A):A=t[44];let P;t[45]!==A?(P=s.jsxs("li",{children:["• ",A]}),t[45]=A,t[46]=P):P=t[46];let D;t[47]!==N||t[48]!==k||t[49]!==P?(D=s.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[N,k,P]}),t[47]=N,t[48]=k,t[49]=P,t[50]=D):D=t[50];let M;t[51]!==y||t[52]!==D?(M=s.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:s.jsxs("div",{className:"flex items-start gap-2",children:[m,s.jsxs("div",{className:"typography-meta text-muted-foreground",children:[y,D]})]})}),t[51]=y,t[52]=D,t[53]=M):M=t[53];let $;t[54]!==M||t[55]!==f||t[56]!==x?($=s.jsxs("div",{className:f,children:[x,M]}),t[54]=M,t[55]=f,t[56]=x,t[57]=$):$=t[57];let R;t[58]!==a||t[59]!==$||t[60]!==g||t[61]!==p?(R=s.jsxs(a,{className:g,children:[p,$]}),t[58]=a,t[59]=$,t[60]=g,t[61]=p,t[62]=R):R=t[62];let K;return t[63]!==u||t[64]!==R||t[65]!==w||t[66]!==v?(K=s.jsx(u,{open:w,onOpenChange:v,children:R}),t[63]=u,t[64]=R,t[65]=w,t[66]=v,t[67]=K):K=t[67],K};function Av(t){return t.isHelpDialogOpen}function Pv(t){return t.setHelpDialogOpen}function Dv(t){return t.shortcutOverrides}const Tv=()=>{const t=Xe.c(32),{t:e}=pt(),n=Te(Iv),r=Te(Rv),i=Te(Ev);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await hn(i)).ok){Be.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}Be.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 u;t[5]!==a?(u=s.jsx(Ts,{children:a}),t[5]=a,t[6]=u):u=t[6];let d;t[7]!==e?(d=e("openCodeStatusDialog.description"),t[7]=e,t[8]=d):d=t[8];let h;t[9]!==d?(h=s.jsx(Is,{children:d}),t[9]=d,t[10]=h):h=t[10];let f;t[11]!==u||t[12]!==h?(f=s.jsxs(Ls,{children:[u,h]}),t[11]=u,t[12]=h,t[13]=f):f=t[13];let g;t[14]!==e?(g=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=g):g=t[15];let p;t[16]!==l||t[17]!==g?(p=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-primary",children:g})}),t[16]=l,t[17]=g,t[18]=p):p=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 x;t[24]!==f||t[25]!==p||t[26]!==v?(x=s.jsxs(vs,{className:"max-w-2xl",children:[f,p,v]}),t[24]=f,t[25]=p,t[26]=v,t[27]=x):x=t[27];let m;return t[28]!==n||t[29]!==r||t[30]!==x?(m=s.jsx(Ss,{open:n,onOpenChange:r,children:x}),t[28]=n,t[29]=r,t[30]=x,t[31]=m):m=t[31],m};function Iv(t){return t.isOpenCodeStatusDialogOpen}function Rv(t){return t.setOpenCodeStatusDialogOpen}function Ev(t){return t.openCodeStatusText}const Mv=t=>{const e=Xe.c(16),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:i,sessionSearchInputRef:o,sessionSearchContainerRef:l}=t,a=n===void 0?!0:n;let u,d;e[0]!==a||e[1]!==r||e[2]!==o?(u=()=>{if(!a||!r||typeof window>"u")return;const w=window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>window.cancelAnimationFrame(w)},d=[a,r,o],e[0]=a,e[1]=r,e[2]=o,e[3]=u,e[4]=d):(u=e[3],d=e[4]),c.useEffect(u,d);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 g,p;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==i?(g=()=>{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)},p=[a,r,i,l],e[10]=a,e[11]=r,e[12]=l,e[13]=i,e[14]=g,e[15]=p):(g=e[14],p=e[15]),c.useEffect(g,p)},Ov=t=>{const e=Xe.c(4);let n;e[0]!==t?(n=(o,l)=>{const a=t.get(o);if(!a||a.length===0)return l;const u=new Map(l.map(Bv)),d=[];a.forEach(g=>{const p=u.get(g);p&&(d.push(p),u.delete(g))});const h=[],f=[];return l.forEach(g=>{u.has(g.id)&&(g.isArchivedBucket?f.push(g):h.push(g))}),[...h,...d,...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 Bv(t){return[t.id,t]}const uo="oc.sessions.projectCollapse",hc="oc.sessions.groupOrder",pc="oc.sessions.groupCollapse",gc=t=>{if(!t)return new Set;try{const e=Ba(wr()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},Fv=t=>{if(!t)return new Map;try{const e=xu(wr(),Ba(wr())).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}},_v=t=>{const e=Xe.c(39),{isVSCode:n,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=Io(),e[0]=i):i=e[0];const o=i;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>gc(o.getItem(uo)),e[1]=l):l=e[1];const[a,u]=c.useState(l);let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>gc(o.getItem(pc)),e[2]=d):d=e[2];const[h,f]=c.useState(d);let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=()=>Fv(o.getItem(hc)),e[3]=g):g=e[3];const[p,w]=c.useState(g),v=c.useRef(0),x=c.useRef(!1),m=c.useRef(!1),b=c.useRef(null),y=c.useRef(null);let S;e[4]!==n?(S=()=>{if(n)return;const le=y.current;if(y.current=null,b.current=null,!le)return;const{projects:ee}=zt.getState(),ue=ee.map(W=>({...W,sidebarCollapsed:le.has(W.id)}));Rr({projects:ue}).catch(Lv)},e[4]=n,e[5]=S):S=e[5];const N=S;let C;e[6]!==N||e[7]!==n?(C=le=>{!globalThis.window||n||(y.current=le,b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>{N()},700))},e[6]=N,e[7]=n,e[8]=C):C=e[8];const k=C;let A,P;e[9]===Symbol.for("react.memo_cache_sentinel")?(A=()=>()=>{globalThis.window&&b.current!==null&&window.clearTimeout(b.current),b.current=null,y.current=null},P=[],e[9]=A,e[10]=P):(A=e[9],P=e[10]),c.useEffect(A,P);let D,M;e[11]!==p?(M=()=>{if(m.current)try{o.setItem(hc,JSON.stringify(Object.fromEntries(p.entries())))}catch{}},D=[p,o],e[11]=p,e[12]=D,e[13]=M):(D=e[12],M=e[13]),c.useEffect(M,D);let $,R;e[14]!==h?($=()=>{if(x.current)try{o.setItem(pc,JSON.stringify(Array.from(h)))}catch{}},R=[h,o],e[14]=h,e[15]=$,e[16]=R):($=e[15],R=e[16]),c.useEffect($,R);let K;e[17]!==r||e[18]!==k?(K=()=>{v.current=Date.now()+150,x.current=!0,f(new Set),u(()=>{const le=new Set(r.map($v));try{o.setItem(uo,JSON.stringify(Array.from(le)))}catch{}return k(le),le})},e[17]=r,e[18]=k,e[19]=K):K=e[19];const L=K;let O;e[20]!==k?(O=()=>{v.current=Date.now()+150,x.current=!0,f(new Set),u(()=>{const le=new Set;try{o.setItem(uo,JSON.stringify([]))}catch{}return k(le),le})},e[20]=k,e[21]=O):O=e[21];const I=O;let j;e[22]!==k?(j=le=>{v.current=Date.now()+150,u(ee=>{const ue=new Set(ee);ue.has(le)?ue.delete(le):ue.add(le);try{o.setItem(uo,JSON.stringify(Array.from(ue)))}catch{}return k(ue),ue})},e[22]=k,e[23]=j):j=e[23];const T=j;let F;e[24]===Symbol.for("react.memo_cache_sentinel")?(F=le=>{x.current=!0,f(ee=>{const ue=new Set(ee);return ue.has(le)?ue.delete(le):ue.add(le),ue})},e[24]=F):F=e[24];const U=F;let H;e[25]===Symbol.for("react.memo_cache_sentinel")?(H=le=>{m.current=!0,w(le)},e[25]=H):H=e[25];const Y=H,{getOrderedGroups:me}=Ov(p);let Z;e[26]!==h||e[27]!==a||e[28]!==p?(Z={collapsedProjects:a,collapsedGroups:h,groupOrderByProject:p},e[26]=h,e[27]=a,e[28]=p,e[29]=Z):Z=e[29];const re=Z;let se;e[30]!==L||e[31]!==I||e[32]!==me||e[33]!==k||e[34]!==T?(se={setCollapsedProjects:u,toggleProject:T,collapseAllProjects:L,expandAllProjects:I,scheduleCollapsedProjectsPersist:k,setCollapsedGroups:f,toggleGroup:U,setGroupOrderByProject:Y,getOrderedGroups:me},e[30]=L,e[31]=I,e[32]=me,e[33]=k,e[34]=T,e[35]=se):se=e[35];const fe=se;let _;return e[36]!==fe||e[37]!==re?(_={state:re,actions:fe},e[36]=fe,e[37]=re,e[38]=_):_=e[38],_};function Lv(){}function $v(t){return t.id}const Wv=5*6e4,zv=t=>{const e=Xe.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:u}=Dn(),d=Bn(Vv);let h,f;e[0]!==a||e[1]!==d||e[2]!==u||e[3]!==n||e[4]!==o?(h=()=>{if(!a||!u||n.length===0){o(new Map);return}n.forEach(C=>{Ri(()=>d(C.normalizedPath,u))})},f=[a,n,u,d,o],e[0]=a,e[1]=d,e[2]=u,e[3]=n,e[4]=o,e[5]=h,e[6]=f):(h=e[5],f=e[6]),c.useEffect(h,f);let g,p;e[7]!==a||e[8]!==i||e[9]!==n||e[10]!==o?(g=()=>{if(!a)return;const C=new Map;n.forEach(k=>{C.set(k.id,i.get(k.normalizedPath)?.isGitRepo??null)}),o(C)},p=[a,n,i,o],e[7]=a,e[8]=i,e[9]=n,e[10]=o,e[11]=g,e[12]=p):(g=e[11],p=e[12]),c.useEffect(g,p);let w;if(e[13]!==i||e[14]!==n){let C;e[16]!==i?(C=k=>{const A=i.get(k.normalizedPath)?.branch??"";return`${k.id}:${A}`},e[16]=i,e[17]=C):C=e[17],w=n.map(C).join("|"),e[13]=i,e[14]=n,e[15]=w}else w=e[15];const v=w;let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=new Map,e[18]=x):x=e[18];const m=c.useRef(x);let b;e[19]===Symbol.for("react.memo_cache_sentinel")?(b=new Map,e[19]=b):b=e[19];const y=c.useRef(b);let S;e[20]!==a||e[21]!==i||e[22]!==n||e[23]!==l?(S=()=>{if(!a)return;let C=!1;const k=setTimeout(()=>{(async()=>{const P=new Set(n.map(Uv));for(const L of m.current.keys())P.has(L)||(m.current.delete(L),y.current.delete(L));const D=Date.now(),M=n.filter(L=>{const O=i.get(L.normalizedPath);if(O?.isGitRepo===!1)return m.current.delete(L.id),y.current.delete(L.id),!1;if(O?.isGitRepo!==!0||O.branch===null)return!1;const I=O.branch.trim(),j=`${L.normalizedPath}\0${I}`,T=m.current.get(L.id);if(T===j){const F=y.current.get(L.id);return F&&(F.at=D),!1}return!(T!==void 0&&D-(y.current.get(L.id)?.at??0)<Wv)});if(M.length===0)return;const $=await fh(M,2,async L=>{const O=i.get(L.normalizedPath)?.branch?.trim()??"",I=`${L.normalizedPath}\0${O}`,j=await Ri(()=>ei(L.normalizedPath,O?{knownBranch:O}:void 0)).catch(Kv);return{id:L.id,inputKey:I,branch:j}});if(C)return;const R=$.filter(Hv);if(R.length===0)return;const K=Date.now();l(L=>{const O=new Map(L);return R.forEach(I=>{const{id:j,branch:T}=I;T&&O.set(j,T)}),O}),R.forEach(L=>{const{id:O,inputKey:I,branch:j}=L;m.current.set(O,I),j&&y.current.set(O,{branch:j,at:K})})})()},150);return()=>{C=!0,clearTimeout(k)}},e[20]=a,e[21]=i,e[22]=n,e[23]=l,e[24]=S):S=e[24];let N;e[25]!==a||e[26]!==i||e[27]!==n||e[28]!==v||e[29]!==l?(N=[a,n,v,i,l],e[25]=a,e[26]=i,e[27]=n,e[28]=v,e[29]=l,e[30]=N):N=e[30],c.useEffect(S,N)};function Vv(t){return t.ensureStatus}function Uv(t){return t.id}function Kv(){return null}function Hv(t){return t.branch}const Gv=t=>{const e=Xe.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(sg,{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(vs,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(Cn,{outerClassName:"max-h-[min(90vh,48rem)]",className:"w-full bg-background",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 u;return e[6]!==r||e[7]!==n||e[8]!==a?(u=s.jsx(Ss,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=u):u=e[9],u},qv=(t,e)=>{if(!e)return Array.from(t);const n=[],r=new Set;for(const i of t){r.has(i)||(r.add(i),n.push(i));const o=e.get(i);if(o)for(const l of o)r.has(l)||(r.add(l),n.push(l))}return n},gs=tr()((t,e)=>({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null,enable:()=>{e().enabled||t({enabled:!0})},disable:()=>{t({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null})},toggleMode:()=>{e().enabled?t({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null}):t({enabled:!0})},toggleSelected:(n,r,i)=>{const o=e(),l=new Set(o.selectedIds);let a=o.scopeKey,u=o.anchorId;r!==null&&o.scopeKey!==null&&r!==o.scopeKey?(l.clear(),a=r,u=null):a===null&&r!==null&&(a=r);const h=i&&i.length>0?[n,...i]:[n];if(l.has(n)){for(const g of h)l.delete(g);u===n&&(u=null)}else{for(const g of h)l.add(g);u=n}l.size===0?t({selectedIds:l,scopeKey:null,anchorId:null}):t({selectedIds:l,scopeKey:a,anchorId:u})},setRange:(n,r,i,o,l)=>{const a=e();if(i.length===0)return;const u=n&&i.includes(n)?n:i[0],d=i.indexOf(u),h=i.indexOf(r);if(d<0||h<0)return;const[f,g]=d<=h?[d,h]:[h,d],p=i.slice(f,g+1),w=qv(p,l),x=o!==null&&a.scopeKey!==null&&o!==a.scopeKey?new Set:new Set(a.selectedIds);for(const m of w)x.add(m);t({selectedIds:x,scopeKey:o??a.scopeKey,anchorId:u})},replaceAll:(n,r)=>{if(n.length===0){t({selectedIds:new Set,scopeKey:null,anchorId:null});return}t({selectedIds:new Set(n),scopeKey:r,anchorId:n[0]??null})},clear:()=>{t({selectedIds:new Set,scopeKey:null,anchorId:null})},removeMany:n=>{const r=e();if(r.selectedIds.size===0||n.length===0)return;const i=new Set(r.selectedIds);for(const o of n)i.delete(o);i.size!==r.selectedIds.size&&(i.size===0?t({selectedIds:i,scopeKey:null,anchorId:null}):t({selectedIds:i}))}}));function Qv(t){const e=Xe.c(213),{t:n}=pt(),{hideDirectoryControls:r,showProjectDisplayControls:i,showRecentControls:o,handleOpenDirectoryDialog:l,onOpenScheduled:a,onOpenMultiRun:u,canOpenMultiRun:d,onOpenArchive:h,headerActionIconClass:f,headerActionButtonClass:g,isSessionSearchOpen:p,setIsSessionSearchOpen:w,sessionSearchInputRef:v,sessionSearchQuery:x,setSessionSearchQuery:m,hasSessionSearchQuery:b,searchMatchCount:y,collapseAllProjects:S,expandAllProjects:N}=t,C=gs(l0),k=gs(a0),A=as(i0),P=as(o0),D=as(r0),M=as(n0),$=as(s0),R=as(t0),K=as(e0),L=as(Zv),O=as(Jv),I=as(Xv),j=i&&O==="single";if(r)return null;let T;e[0]!==g?(T=Re(g,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=g,e[1]=T):T=e[1];let F;e[2]!==n?(F=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=F):F=e[3];let U;e[4]!==f?(U=s.jsx(E,{name:"folder-add",className:f}),e[4]=f,e[5]=U):U=e[5];let H;e[6]!==l||e[7]!==T||e[8]!==F||e[9]!==U?(H=s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,className:T,"aria-label":F,children:U})}),e[6]=l,e[7]=T,e[8]=F,e[9]=U,e[10]=H):H=e[10];let Y;e[11]!==n?(Y=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=Y):Y=e[12];let me;e[13]!==Y?(me=s.jsx(yt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Y})}),e[13]=Y,e[14]=me):me=e[14];let Z;e[15]!==H||e[16]!==me?(Z=s.jsxs(xt,{children:[H,me]}),e[15]=H,e[16]=me,e[17]=Z):Z=e[17];let re;e[18]!==g?(re=Re(g,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=g,e[19]=re):re=e[19];let se;e[20]!==n?(se=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=se):se=e[21];let fe;e[22]!==f?(fe=s.jsx(E,{name:"calendar-schedule",className:f}),e[22]=f,e[23]=fe):fe=e[23];let _;e[24]!==a||e[25]!==re||e[26]!==se||e[27]!==fe?(_=s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:re,"aria-label":se,children:fe})}),e[24]=a,e[25]=re,e[26]=se,e[27]=fe,e[28]=_):_=e[28];let le;e[29]!==n?(le=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=le):le=e[30];let ee;e[31]!==le?(ee=s.jsx(yt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:le})}),e[31]=le,e[32]=ee):ee=e[32];let ue;e[33]!==_||e[34]!==ee?(ue=s.jsxs(xt,{children:[_,ee]}),e[33]=_,e[34]=ee,e[35]=ue):ue=e[35];let W;e[36]!==g?(W=Re(g,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=g,e[37]=W):W=e[37];let ne;e[38]!==n?(ne=n("sessions.sidebar.header.actions.newMultiRun"),e[38]=n,e[39]=ne):ne=e[39];const pe=!d;let xe;e[40]!==f?(xe=s.jsx(hh,{className:f}),e[40]=f,e[41]=xe):xe=e[41];let Ce;e[42]!==u||e[43]!==W||e[44]!==ne||e[45]!==pe||e[46]!==xe?(Ce=s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:W,"aria-label":ne,disabled:pe,children:xe})}),e[42]=u,e[43]=W,e[44]=ne,e[45]=pe,e[46]=xe,e[47]=Ce):Ce=e[47];let Me;e[48]!==n?(Me=n("sessions.sidebar.header.actions.newMultiRun"),e[48]=n,e[49]=Me):Me=e[49];let ve;e[50]!==Me?(ve=s.jsx(yt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Me})}),e[50]=Me,e[51]=ve):ve=e[51];let Ie;e[52]!==Ce||e[53]!==ve?(Ie=s.jsxs(xt,{children:[Ce,ve]}),e[52]=Ce,e[53]=ve,e[54]=Ie):Ie=e[54];let ye;e[55]!==g?(ye=Re(g,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[55]=g,e[56]=ye):ye=e[56];let q;e[57]!==n?(q=n("sessions.sidebar.nav.archive"),e[57]=n,e[58]=q):q=e[58];let De;e[59]!==f?(De=s.jsx(E,{name:"archive",className:f}),e[59]=f,e[60]=De):De=e[60];let ke;e[61]!==h||e[62]!==ye||e[63]!==q||e[64]!==De?(ke=s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:h,className:ye,"aria-label":q,children:De})}),e[61]=h,e[62]=ye,e[63]=q,e[64]=De,e[65]=ke):ke=e[65];let te;e[66]!==n?(te=n("sessions.sidebar.nav.archive"),e[66]=n,e[67]=te):te=e[67];let he;e[68]!==te?(he=s.jsx(yt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:te})}),e[68]=te,e[69]=he):he=e[69];let ae;e[70]!==ke||e[71]!==he?(ae=s.jsxs(xt,{children:[ke,he]}),e[70]=ke,e[71]=he,e[72]=ae):ae=e[72];let Q;e[73]!==ue||e[74]!==Ie||e[75]!==ae||e[76]!==Z?(Q=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[Z,ue,Ie,ae]}),e[73]=ue,e[74]=Ie,e[75]=ae,e[76]=Z,e[77]=Q):Q=e[77];let z;e[78]!==w?(z=()=>w(Yv),e[78]=w,e[79]=z):z=e[79];let G;e[80]!==g?(G=Re(g,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[80]=g,e[81]=G):G=e[81];let ie;e[82]!==n?(ie=n("sessions.sidebar.header.actions.searchSessions"),e[82]=n,e[83]=ie):ie=e[83];let Oe;e[84]!==f?(Oe=s.jsx(E,{name:"search",className:f}),e[84]=f,e[85]=Oe):Oe=e[85];let Fe;e[86]!==p||e[87]!==z||e[88]!==G||e[89]!==ie||e[90]!==Oe?(Fe=s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:z,className:G,"aria-label":ie,"aria-expanded":p,children:Oe})}),e[86]=p,e[87]=z,e[88]=G,e[89]=ie,e[90]=Oe,e[91]=Fe):Fe=e[91];let Se;e[92]!==n?(Se=n("sessions.sidebar.header.actions.searchSessions"),e[92]=n,e[93]=Se):Se=e[93];let oe;e[94]!==Se?(oe=s.jsx(yt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Se})}),e[94]=Se,e[95]=oe):oe=e[95];let Pe;e[96]!==Fe||e[97]!==oe?(Pe=s.jsxs(xt,{children:[Fe,oe]}),e[96]=Fe,e[97]=oe,e[98]=Pe):Pe=e[98];const Ne=C&&"bg-interactive-hover text-primary";let B;e[99]!==g||e[100]!==Ne?(B=Re(g,"text-muted-foreground hover:text-foreground hover:bg-transparent",Ne),e[99]=g,e[100]=Ne,e[101]=B):B=e[101];let ce;e[102]!==C||e[103]!==n?(ce=n(C?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[102]=C,e[103]=n,e[104]=ce):ce=e[104];let be;e[105]!==f?(be=s.jsx(E,{name:"checkbox-multiple",className:f}),e[105]=f,e[106]=be):be=e[106];let ge;e[107]!==C||e[108]!==B||e[109]!==ce||e[110]!==be||e[111]!==k?(ge=s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:k,className:B,"aria-label":ce,"aria-pressed":C,children:be})}),e[107]=C,e[108]=B,e[109]=ce,e[110]=be,e[111]=k,e[112]=ge):ge=e[112];let _e;e[113]!==C||e[114]!==n?(_e=n(C?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[113]=C,e[114]=n,e[115]=_e):_e=e[115];let tt;e[116]!==_e?(tt=s.jsx(yt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:_e})}),e[116]=_e,e[117]=tt):tt=e[117];let Ue;e[118]!==ge||e[119]!==tt?(Ue=s.jsxs(xt,{children:[ge,tt]}),e[118]=ge,e[119]=tt,e[120]=Ue):Ue=e[120];let de;e[121]!==g?(de=Re(g,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[121]=g,e[122]=de):de=e[122];let X;e[123]!==n?(X=n("sessions.sidebar.header.displayMode.label"),e[123]=n,e[124]=X):X=e[124];let we;e[125]!==f?(we=s.jsx(E,{name:"equalizer-2",className:f}),e[125]=f,e[126]=we):we=e[126];let ze;e[127]!==de||e[128]!==X||e[129]!==we?(ze=s.jsx(bt,{asChild:!0,children:s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button",className:de,"aria-label":X,children:we})})}),e[127]=de,e[128]=X,e[129]=we,e[130]=ze):ze=e[130];let Ve;e[131]!==n?(Ve=n("sessions.sidebar.header.displayMode.label"),e[131]=n,e[132]=Ve):Ve=e[132];let He;e[133]!==Ve?(He=s.jsx(yt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Ve})}),e[133]=Ve,e[134]=He):He=e[134];let $e;e[135]!==ze||e[136]!==He?($e=s.jsxs(xt,{children:[ze,He]}),e[135]=ze,e[136]=He,e[137]=$e):$e=e[137];let qe;e[138]!==n?(qe=n("sessions.sidebar.header.actions.sortProjects"),e[138]=n,e[139]=qe):qe=e[139];let at;e[140]!==qe?(at=s.jsx(bo,{children:qe}),e[140]=qe,e[141]=at):at=e[141];let gt;e[142]!==D||e[143]!==M||e[144]!==n?(gt=[["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(Dt=>{const[Rt,Vt]=Dt;return s.jsxs(Wt,{onClick:()=>{M(Rt),Rr({sidebarProjectSortOrder:Rt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Vt)}),D===Rt?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]},Rt)}),e[142]=D,e[143]=M,e[144]=n,e[145]=gt):gt=e[145];let Pt;e[146]===Symbol.for("react.memo_cache_sentinel")?(Pt=s.jsx(Es,{}),e[146]=Pt):Pt=e[146];let Ge;e[147]!==O||e[148]!==I||e[149]!==i||e[150]!==n?(Ge=i?s.jsxs(s.Fragment,{children:[s.jsx(bo,{children:n("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(Dt=>{const[Rt,Vt]=Dt;return s.jsxs(Wt,{onClick:()=>{I(Rt),Rr({sidebarProjectDisplayMode:Rt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Vt)}),O===Rt?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]},Rt)}),s.jsx(Es,{})]}):null,e[147]=O,e[148]=I,e[149]=i,e[150]=n,e[151]=Ge):Ge=e[151];let It;e[152]!==n?(It=n("sessions.sidebar.header.grouping.label"),e[152]=n,e[153]=It):It=e[153];let kt;e[154]!==It?(kt=s.jsx(bo,{children:It}),e[154]=It,e[155]=kt):kt=e[155];let Mt;e[156]!==$||e[157]!==R||e[158]!==n?(Mt=[["by-worktree","sessions.sidebar.header.grouping.byWorktree"],["flat","sessions.sidebar.header.grouping.flat"]].map(Dt=>{const[Rt,Vt]=Dt;return s.jsxs(Wt,{onClick:()=>{R(Rt),Rr({sidebarSessionGroupingMode:Rt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Vt)}),$===Rt?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]},Rt)}),e[156]=$,e[157]=R,e[158]=n,e[159]=Mt):Mt=e[159];let Tt;e[160]===Symbol.for("react.memo_cache_sentinel")?(Tt=s.jsx(Es,{}),e[160]=Tt):Tt=e[160];let wt;e[161]!==j||e[162]!==o||e[163]!==A||e[164]!==n||e[165]!==P?(wt=o&&!j?s.jsxs(Wt,{onClick:()=>{P(),Rr({sidebarShowRecentSection:!A})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),A?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[161]=j,e[162]=o,e[163]=A,e[164]=n,e[165]=P,e[166]=wt):wt=e[166];let St;e[167]!==n?(St=n("sessions.sidebar.header.displayMode.stickyHeaders"),e[167]=n,e[168]=St):St=e[168];let vt;e[169]!==St?(vt=s.jsx("span",{children:St}),e[169]=St,e[170]=vt):vt=e[170];let ht;e[171]!==K?(ht=K?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null,e[171]=K,e[172]=ht):ht=e[172];let Ze;e[173]!==vt||e[174]!==ht||e[175]!==L?(Ze=s.jsxs(Wt,{onClick:L,className:"flex items-center justify-between",children:[vt,ht]}),e[173]=vt,e[174]=ht,e[175]=L,e[176]=Ze):Ze=e[176];let je;e[177]!==S||e[178]!==N||e[179]!==j||e[180]!==n?(je=j?null:s.jsxs(s.Fragment,{children:[s.jsx(Es,{}),s.jsxs(Wt,{onClick:S,className:"flex items-center gap-2",children:[s.jsx(E,{name:"contract-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.collapseAll")})]}),s.jsxs(Wt,{onClick:N,className:"flex items-center gap-2",children:[s.jsx(E,{name:"expand-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.expandAll")})]})]}),e[177]=S,e[178]=N,e[179]=j,e[180]=n,e[181]=je):je=e[181];let nt;e[182]!==at||e[183]!==gt||e[184]!==Ge||e[185]!==kt||e[186]!==Mt||e[187]!==wt||e[188]!==Ze||e[189]!==je?(nt=s.jsxs(Ys,{align:"end",className:"min-w-[180px]",children:[at,gt,Pt,Ge,kt,Mt,Tt,wt,Ze,je]}),e[182]=at,e[183]=gt,e[184]=Ge,e[185]=kt,e[186]=Mt,e[187]=wt,e[188]=Ze,e[189]=je,e[190]=nt):nt=e[190];let lt;e[191]!==$e||e[192]!==nt?(lt=s.jsxs(Xs,{children:[$e,nt]}),e[191]=$e,e[192]=nt,e[193]=lt):lt=e[193];let Ct;e[194]!==Pe||e[195]!==Ue||e[196]!==lt?(Ct=s.jsxs("div",{className:"flex items-center gap-1.5",children:[Pe,Ue,lt]}),e[194]=Pe,e[195]=Ue,e[196]=lt,e[197]=Ct):Ct=e[197];let Ye;e[198]!==Q||e[199]!==Ct?(Ye=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[Q,Ct]}),e[198]=Q,e[199]=Ct,e[200]=Ye):Ye=e[200];let it;e[201]!==b||e[202]!==p||e[203]!==y||e[204]!==v||e[205]!==x||e[206]!==w||e[207]!==m||e[208]!==n?(it=p?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:[b?s.jsx("span",{children:y===1?n("sessions.sidebar.header.search.matchCountSingle",{count:y}):n("sessions.sidebar.header.search.matchCountPlural",{count:y})}):s.jsx("span",{}),s.jsx("span",{children:n("sessions.sidebar.header.search.escapeHint")})]}),s.jsxs("div",{className:"relative",children:[s.jsx(E,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{ref:v,value:x,onChange:Dt=>m(Dt.target.value),placeholder:n("sessions.sidebar.header.search.placeholder"),className:"h-8 w-full rounded-md border border-border bg-transparent pl-8 pr-8 typography-ui-label text-foreground outline-none focus-visible:ring-2 focus-visible:ring-primary/50",onKeyDown:Dt=>{Dt.key==="Escape"&&(Dt.stopPropagation(),b?m(""):w(!1))}}),x.length>0?s.jsx("button",{type:"button",onClick:()=>m(""),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 hover:bg-interactive-hover/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":n("sessions.sidebar.header.search.clear"),children:s.jsx(E,{name:"close",className:"h-3.5 w-3.5"})}):null]})]}):null,e[201]=b,e[202]=p,e[203]=y,e[204]=v,e[205]=x,e[206]=w,e[207]=m,e[208]=n,e[209]=it):it=e[209];let Nt;return e[210]!==Ye||e[211]!==it?(Nt=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:[Ye,it]})}),e[210]=Ye,e[211]=it,e[212]=Nt):Nt=e[212],Nt}function Yv(t){return!t}function Xv(t){return t.setProjectDisplayMode}function Jv(t){return t.projectDisplayMode}function Zv(t){return t.toggleStickyZoneHeaders}function e0(t){return t.stickyZoneHeaders}function t0(t){return t.setSessionGroupingMode}function s0(t){return t.sessionGroupingMode}function n0(t){return t.setProjectSortOrder}function r0(t){return t.projectSortOrder}function o0(t){return t.toggleRecentSection}function i0(t){return t.showRecentSection}function a0(t){return t.toggleMode}function l0(t){return t.enabled}function c0(t){const e=Xe.c(8),{t:n}=pt(),r=t.onNewSession;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(E,{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-primary/50",children:[i,l]})}),e[5]=t.onNewSession,e[6]=l,e[7]=a):a=e[7],a}const yi="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-primary/50";function d0(t){const e=Xe.c(13),{onOpenSettings:n,onOpenShortcuts:r,onOpenAbout:i,onOpenUpdate:o,showRuntimeButtons:l,showUpdateButton:a}=t,u=l===void 0?!0:l,d=a===void 0?!0:a,{t:h}=pt();if(!u&&!d)return null;let f;e[0]!==i||e[1]!==n||e[2]!==r||e[3]!==u||e[4]!==h?(f=u?s.jsxs(s.Fragment,{children:[s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:yi,"aria-label":h("sessions.sidebar.footer.actions.settings"),children:s.jsx(E,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(yt,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:yi,"aria-label":h("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(E,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(yt,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:yi,"aria-label":h("sessions.sidebar.footer.actions.aboutOpenChamber"),children:s.jsx(E,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(yt,{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]=u,e[4]=h,e[5]=f):f=e[5];let g;e[6]!==o||e[7]!==d||e[8]!==h?(g=d?s.jsx(ot,{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]=d,e[8]=h,e[9]=g):g=e[9];let p;return e[10]!==f||e[11]!==g?(p=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[f,g]}),e[10]=f,e[11]=g,e[12]=p):p=e[12],p}const u0=t=>{const e=Xe.c(12),{normalizedProjects:n,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:u,foldersMap:d,createFolder:h,addSessionToFolder:f}=t,g=r===void 0?!0:r;let p,w;e[0]!==f||e[1]!==h||e[2]!==g||e[3]!==d||e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==i||e[9]!==u?(p=()=>{!g||o||!l||a||n.forEach(v=>{if(u.has(v.normalizedPath))return;const x=Fd(v.normalizedPath),m=i.archivedSessionsByProject.get(v.id)??[],b=d[x]??[],y=new Map(b.map(m0));m.forEach(S=>{const N=ph(S,v.normalizedPath),C=N.toLowerCase();let k=y.get(C);k||(k=h(x,N),y.set(C,k)),k.sessionIds.includes(S.id)||f(x,k.id,S.id)})})},w=[n,g,i,o,l,a,u,d,h,f],e[0]=f,e[1]=h,e[2]=g,e[3]=d,e[4]=l,e[5]=o,e[6]=a,e[7]=n,e[8]=i,e[9]=u,e[10]=p,e[11]=w):(p=e[10],w=e[11]),c.useEffect(p,w)};function m0(t){return[t.name.toLowerCase(),t]}function f0({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 d=!!(e&&Array.from(i.entries()).some(([h,f])=>h!==t&&f.has(e)));if(e&&r&&!d)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const u=(o&&r.has(o)?o:null)??l;return!u||u===e?{kind:"none"}:{kind:"select-session",sessionId:u}}const h0=t=>{const e=Xe.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:u,newSessionDraftOpen:d,mobileVariant:h,openNewSessionDraft:f,setSessionSwitcherOpen:g}=t;let p,w;if(e[0]!==n){w=new Map,p=new Map;const C=(k,A,P,D)=>{w.has(k)||w.set(k,new Map);const M=w.get(k);D.forEach($=>{const R=dt($.worktree?.path??$.session.directory??P??A);M.set($.session.id,{directory:R}),p.has(k)||p.set(k,{id:$.session.id,directory:R}),$.children.length>0&&C(k,A,R,$.children)})};n.forEach(k=>{k.groups.forEach(A=>{C(k.project.id,k.project.normalizedPath,A.directory,A.sessions)})}),e[0]=n,e[1]=p,e[2]=w}else p=e[1],w=e[2];let v;e[3]!==p||e[4]!==w?(v={metaByProject:w,firstSessionByProject:p},e[3]=p,e[4]=w,e[5]=v):v=e[5];const x=v,m=c.useRef(null);let b,y;e[6]!==r||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==u||e[11]!==h||e[12]!==d||e[13]!==f||e[14]!==n||e[15]!==x||e[16]!==o||e[17]!==g?(b=()=>{if(!r||d||Te.getState().isNewWorktreeDialogOpen||m.current===r)return;const C=n.find(D=>D.project.id===r);if(!C)return;const k=x.metaByProject.get(r);if(l&&k&&k.has(l)){m.current=r,o(D=>{if(D.get(r)===l)return D;const M=new Map(D);return M.set(r,l),M});return}const A=f0({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:k,metaByProject:x.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:x.firstSessionByProject.get(r)?.id??null});if(A.kind==="preserve-current"){a===r&&(m.current=r);return}if(m.current=r,A.kind==="open-draft"){h&&g(!1),f({selectedProjectId:C.project.id,directoryOverride:C.project.normalizedPath});return}if(A.kind!=="select-session")return;const P=k?.get(A.sessionId)?.directory??null;u(A.sessionId,P)},y=[r,i,l,a,u,d,h,f,n,x,g,o],e[6]=r,e[7]=i,e[8]=l,e[9]=a,e[10]=u,e[11]=h,e[12]=d,e[13]=f,e[14]=n,e[15]=x,e[16]=o,e[17]=g,e[18]=b,e[19]=y):(b=e[18],y=e[19]),c.useLayoutEffect(b,y);let S,N;e[20]!==r||e[21]!==l||e[22]!==x||e[23]!==o?(S=()=>{if(!r||!l)return;const C=x.metaByProject.get(r);!C||!C.has(l)||o(k=>{if(k.get(r)===l)return k;const A=new Map(k);return A.set(r,l),A})},N=[r,l,x,o],e[20]=r,e[21]=l,e[22]=x,e[23]=o,e[24]=S,e[25]=N):(S=e[24],N=e[25]),c.useEffect(S,N)},p0=t=>{const e=Xe.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=Qe(g0),a=Qe(x0);let u;e[5]!==l||e[6]!==o?(u=l?o?.get(l)?.projectId??null:null,e[5]=l,e[6]=o,e[7]=u):u=e[7];const d=u;let h;e[8]!==r?(h=()=>new Map(r),e[8]=r,e[9]=h):h=e[9];const[f,g]=c.useState(h);let p;e[10]!==f||e[11]!==n||e[12]!==l||e[13]!==d||e[14]!==a?(p={...n,activeSessionByProject:f,setActiveSessionByProject:g,currentSessionId:l,currentSessionOwnerProjectId:d,newSessionDraftOpen:a},e[10]=f,e[11]=n,e[12]=l,e[13]=d,e[14]=a,e[15]=p):p=e[15],h0(p);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 g0(t){return t.currentSessionId}function x0(t){return!!t.newSessionDraft?.open}const xc={selected:0,"active-project":1,expanded:2,visible:3,background:4};function cm(t){const e=new Map,n=(r,i,o)=>{const l=dt(r??null);if(!l)return;const a=e.get(l);a&&xc[a.priority]<=xc[i]||e.set(l,{directory:l,priority:i,reason:o})};for(const r of t.knownDirectories??[])n(r,"background","known-project");n(t.activeProjectDirectory,"active-project","project-expanded");for(const r of t.projectSections??[]){const i=!t.collapsedProjects.has(r.project.id);let o="background";r.project.id===t.activeProjectId?o="active-project":i&&(o="expanded"),n(r.project.normalizedPath,o,i?"project-expanded":"known-project");for(const l of r.groups){if(!l.directory||l.isArchivedBucket||l.isMain)continue;const a=i&&!t.collapsedGroups.has(`${r.project.id}:${l.id}`);let u="background";a?u="expanded":i&&(u="visible"),n(l.directory,u,a?"worktree-expanded":"known-worktree")}}return n(t.currentDirectory,"selected","current-directory"),n(t.currentSessionDirectory,"selected","selected-session"),[...e.values()]}const b0=(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,bc=(t,e,n)=>{b0(t.get(e),n)&&t.set(e,n)},y0=t=>{const e=t;return dt(e.directory)??dt(e.project?.worktree)},w0=t=>{if(t==="/"||/^[A-Z]:$/.test(t))return null;const e=t.lastIndexOf("/");return e<0?null:e===0?"/":e===2&&/^[A-Z]:\//.test(t)?t.slice(0,2):t.slice(0,e)},S0=(t,e,n,r,i=[])=>{const o=new Map,l=new Map;for(const w of e){const v=dt(w.normalizedPath);if(!v)continue;const x=l.get(v);(!x||w.id.localeCompare(x.id)<0)&&l.set(v,w),bc(o,v,{projectId:w.id,projectRoot:v,scopeDirectory:v,kind:"project"})}if(!r)for(const[w,v]of n){const x=dt(w),m=x?l.get(x):void 0;if(!(!m||!x))for(const b of v){const y=dt(b.path);y&&bc(o,y,{projectId:m.id,projectRoot:x,scopeDirectory:y,kind:"worktree"})}}const a=new Map,u=new Map,d=new Map,h=new Map,f=new Map,g=w=>{if(!w)return null;if(a.has(w))return a.get(w)??null;if(r){const b=o.get(w)??null;return a.set(w,b),b}const v=[];let x=w,m=null;for(;x;){if(a.has(x)){m=a.get(x)??null;break}if(v.push(x),m=o.get(x)??null,m)break;x=w0(x)}for(const b of v)a.set(b,m);return m},p=(w,v,x)=>{for(const m of w){const b=g(y0(m));if(!b)continue;u.set(m.id,b);const y=v.get(b.projectId);if(y?y.push(m):v.set(b.projectId,[m]),!x)continue;const S=x.get(b.scopeDirectory);S?S.add(m.id):x.set(b.scopeDirectory,new Set([m.id]))}};return p(t,d,f),p(i,h),{bySessionId:u,sessionsByProject:d,archivedSessionsByProject:h,sessionsByScope:f,directoryResolutions:a.size}},v0=t=>{const e=Xe.c(7),{ownership:n}=t;let r;e[0]!==n?(r=u=>n.sessionsByProject.get(u)??[],e[0]=n,e[1]=r):r=e[1];const i=r;let o;e[2]!==n?(o=u=>n.archivedSessionsByProject.get(u)??[],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},j0=(t,e)=>t.map(n=>{const r=dt(n.path)??n.path;return`${r}=${e.get(r)??""}`}).join(`
|
|
911
|
-
`),k0=[],C0=t=>{const{normalizedProjects:e,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:o,projectRootBranches:l,gitBranches:a,lastRepoStatus:u,buildGroupedSessions:d,hasSessionSearchQuery:h,normalizedSessionSearchQuery:f,filterSessionNodesForSearch:g,buildGroupSearchText:p,foldersMap:w,standaloneGroups:v}=t,x=c.useRef(new Map),m=c.useMemo(()=>{const P=x.current,D=new Map;let M=0,$=0;const R=(L,O)=>L.length===O.length&&L.every((I,j)=>I===O[j]),K=e.map(L=>{const O=n(L.id),I=r(L.id),j=i.get(L.normalizedPath)??k0,T=o.has(L.id)?!!o.get(L.id):u,F=l.get(L.id)??null,U=j0(j,a),H=P.get(L.id);if(H&&H.project===L&&R(H.activeSessions,O)&&R(H.archivedSessions,I)&&H.availableWorktrees===j&&H.rootBranch===F&&H.worktreeBranchesKey===U&&H.isRepo===T&&H.buildGroupedSessions===d)return M+=1,D.set(L.id,H),H.section;if($+=1,H){const re=H.project!==L?"project":R(H.activeSessions,O)?R(H.archivedSessions,I)?H.availableWorktrees!==j?"worktrees":H.rootBranch!==F?"branch":H.worktreeBranchesKey!==U?"worktreeBranches":H.isRepo!==T?"repo":"builder":"archived":"sessions";Gs(`ui.sidebar.project_section.rebuilt_reason.${re}`)}const Y=_d([...O,...I]),me=d(Y,L.normalizedPath,j,F,T),Z={project:L,groups:me};return D.set(L.id,{project:L,activeSessions:O,archivedSessions:I,availableWorktrees:j,rootBranch:F,worktreeBranchesKey:U,isRepo:T,buildGroupedSessions:d,section:Z}),Z});return x.current=D,M>0&&Gs("ui.sidebar.project_section.reused",M),$>0&&Gs("ui.sidebar.project_section.rebuilt",$),K},[e,n,r,i,o,u,d,l,a]),b=c.useMemo(()=>m,[m]),y=c.useMemo(()=>{const P=new WeakMap;if(!h)return P;const D=$=>$.reduce((R,K)=>R+1+D(K.children),0),M=$=>{const R=g($.sessions,f),K=D(R),L=Ro([p($)],f),O=dt($.directory??null),j=(O?w[O]??[]:[]).filter(T=>Ro([T.name],f)).length;P.set($,{filteredNodes:R,matchedSessionCount:K,folderNameMatchCount:j,groupMatches:L,hasMatch:L||K>0||j>0})};return b.forEach($=>{$.groups.forEach(M)}),v.forEach(M),P},[h,b,v,g,f,p,w]),S=c.useMemo(()=>h?b.map(P=>({...P,groups:P.groups.filter(D=>y.get(D)?.hasMatch===!0)})).filter(P=>P.groups.length>0):b,[h,b,y]),N=h?S:b,C=c.useRef(new WeakMap),k=c.useMemo(()=>{const P=C.current;return N.map(D=>{const M=P.get(D);if(M&&M.query===f)return M.section;const $=D.groups.filter(T=>!T.isArchivedBucket),R=D.groups.filter(T=>T.isArchivedBucket),K=$.flatMap(T=>h?y.get(T)?.filteredNodes??[]:T.sessions),L=$.map(T=>({scopeKey:T.folderScopeKey??dt(T.directory??null),directory:T.directory??null})).filter(T=>!!T.scopeKey),O=$.find(T=>T.isMain)??null,I={id:"flat",label:O?.label??"",branch:O?.branch??null,description:O?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:O?.directory??D.project.normalizedPath,folderScopeKey:O?.folderScopeKey??D.project.normalizedPath,folderScopes:L,sessions:K};if(h){const T=$.map(F=>y.get(F)).filter(F=>!!F);y.set(I,{filteredNodes:K,matchedSessionCount:T.reduce((F,U)=>F+U.matchedSessionCount,0),folderNameMatchCount:T.reduce((F,U)=>F+U.folderNameMatchCount,0),groupMatches:T.some(F=>F.groupMatches),hasMatch:T.some(F=>F.hasMatch)})}const j={project:D.project,groups:[I,...R]};return P.set(D,{query:f,section:j}),j})},[y,h,f,N]),A=c.useMemo(()=>{if(!h)return 0;const P=(M,$)=>{const R=y.get($);if(!R)return M;const K=R.folderNameMatchCount+(R.groupMatches?1:0);return M+R.matchedSessionCount+K},D=N.reduce((M,$)=>$.groups.reduce(P,M),0);return v.reduce(P,D)},[h,N,v,y]);return{projectSections:m,visibleProjectSections:b,groupSearchDataByGroup:y,searchableProjectSections:S,sectionsForRender:N,flatSectionsForRender:k,searchMatchCount:A}},N0=180,yc=150,A0=2,P0=8,wc=[-1,1,-2,2],wi=t=>`${t.directory}
|
|
912
|
-
${t.sessionId}`,D0=t=>t?.directory?.trim()||null,T0=({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),u=c.useRef(0),d=c.useMemo(()=>Pn(),[]),h=c.useCallback(()=>{u.current+=1,l.current=[],o.current.forEach(p=>window.clearTimeout(p)),o.current.clear()},[]),f=c.useCallback(()=>{if(!(!t||d))for(;a.current.size<A0&&l.current.length>0;){const p=l.current.shift();if(!p)break;if(p.generation!==u.current||Qe.getState().currentSessionId===p.sessionId||Ei(p.sessionId,p.directory).renderable)continue;const v=wi(p);a.current.add(v),i({directory:p.directory,sessionID:p.sessionId}).catch(()=>{}).finally(()=>{a.current.delete(v),f()})}},[t,d,i]),g=c.useCallback(p=>{const w=p?.id,v=D0(p);if(!t||d||!w||!v||w===e)return;const x={sessionId:w,directory:v,generation:u.current},m=wi(x);if(Ei(w,v).renderable||a.current.has(m)||l.current.some(S=>wi(S)===m))return;const b=o.current.get(m);b!==void 0&&window.clearTimeout(b);const y=window.setTimeout(()=>{if(o.current.delete(m),x.generation!==u.current)return;const S=l.current;S.length>=P0&&S.shift(),S.push(x),f()},N0);o.current.set(m,y)},[e,t,d,f]);c.useEffect(()=>{h()},[h,e,t,d]),c.useEffect(()=>{if(!t||d||!e||n.length===0)return;const p=window.setTimeout(()=>{const w=n.findIndex(v=>v.id===e);if(!(w<0))for(const v of wc)g(n[w+v])},yc);return()=>window.clearTimeout(p)},[e,t,d,g,n]),c.useEffect(()=>{if(!t||d||!e||r.length===0)return;const p=window.setTimeout(()=>{const w=r.findIndex(v=>v.id===e);if(!(w<0))for(const v of wc)g(r[w+v])},yc);return()=>window.clearTimeout(p)},[e,t,d,r,g]),c.useEffect(()=>h,[h])},I0=t=>{const e=Xe.c(3),n=Qe(R0);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],T0(r),null};function R0(t){return t.currentSessionId}const Co=t=>{const e=Xe.c(22),{id:n,projectLabel:r,projectIcon:i,projectColor:o,projectIconImage:l,projectIconBackground:a,isCollapsed:u,alwaysShowActions:d}=t,h=d===void 0?!1:d,{currentTheme:f}=er(),g=i?Pa[i]:null,p=o?Da[o]??null:null,w=u!==void 0,v=w?h?"hidden":"group-hover/project:hidden group-focus-within/project:hidden":void 0;let x;e[0]!==h||e[1]!==w||e[2]!==u?(x=w?s.jsx("span",{className:Re("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(E,{name:u?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[0]=h,e[1]=w,e[2]=u,e[3]=x):x=e[3];let m;e[4]!==h||e[5]!==f||e[6]!==w||e[7]!==p||e[8]!==v||e[9]!==n||e[10]!==a||e[11]!==l||e[12]!==g?(m=l?s.jsx("span",{className:Re("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(Ta,{project:{id:n,iconImage:l},options:{themeVariant:f.metadata.variant,iconColor:f.colors.surface.foreground},className:"h-full w-full object-contain",fallback:g?s.jsx(E,{name:g,className:"h-3.5 w-3.5",style:p?{color:p}:void 0}):s.jsx(E,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:p?{color:p}:void 0})})}):g?s.jsx(E,{name:g,className:Re("h-3.5 w-3.5",v),style:p?{color:p}:void 0}):s.jsx(E,{name:"folder",className:Re("h-3.5 w-3.5 text-muted-foreground/80",v),style:p?{color:p}:void 0}),e[4]=h,e[5]=f,e[6]=w,e[7]=p,e[8]=v,e[9]=n,e[10]=a,e[11]=l,e[12]=g,e[13]=m):m=e[13];let b;e[14]!==x||e[15]!==m?(b=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[x,m]}),e[14]=x,e[15]=m,e[16]=b):b=e[16];let y;e[17]!==r?(y=s.jsx("span",{className:"truncate text-[14px] font-semibold lowercase text-foreground",children:r}),e[17]=r,e[18]=y):y=e[18];let S;return e[19]!==b||e[20]!==y?(S=s.jsxs(s.Fragment,{children:[b,y]}),e[19]=b,e[20]=y,e[21]=S):S=e[21],S},E0=t=>{const e=Xe.c(62),{id:n,disabled:r,projectLabel:i,projectDescription:o,projectIcon:l,projectColor:a,projectIconImage:u,projectIconBackground:d,isCollapsed:h,isRepo:f,isDesktopShell:g,hideDirectoryControls:p,alwaysShowActions:w,onToggle:v,onNewSession:x,onNewWorktreeSession:m,onManageWorktrees:b,onRenameStart:y,onClose:S,sentinelRef:N,children:C,showCreateButtons:k,hideHeader:A,statusIndicator:P,openSidebarMenuKey:D,setOpenSidebarMenuKey:M,projectPickerOptions:$,onProjectSelect:R}=t,K=r===void 0?!1:r,L=k===void 0?!0:k,O=A===void 0?!1:A,I=P===void 0?null:P,{t:j}=pt(),T=as(B0);let F;e[0]!==K||e[1]!==n?(F={id:n,disabled:K},e[0]=K,e[1]=n,e[2]=F):F=e[2];const{attributes:U,listeners:H,setNodeRef:Y,transform:me,transition:Z,isDragging:re}=ti(F),se=c.useRef(!1),fe=`project:${n}`,_=D===fe,[le,ee]=c.useState(!1),ue=!!($&&R);let W;e[3]!==fe||e[4]!==M?(W=G=>{G&&ee(!1),M(G?fe:null)},e[3]=fe,e[4]=M,e[5]=W):W=e[5];const ne=W;let pe;e[6]!==p||e[7]!==f||e[8]!==S||e[9]!==b||e[10]!==x||e[11]!==y||e[12]!==L||e[13]!==j?(pe=G=>s.jsxs(s.Fragment,{children:[L&&!f&&!p&&x&&s.jsxs(G,{onClick:x,children:[s.jsx(E,{name:"add",className:"mr-1.5 h-4 w-4"}),j("sessions.sidebar.project.actions.newSession")]}),f&&!p&&b&&s.jsxs(G,{onClick:b,children:[s.jsx(E,{name:"node-tree",className:"mr-1.5 h-4 w-4"}),j("sessions.sidebar.project.actions.manageWorktrees")]}),s.jsxs(G,{onClick:y,children:[s.jsx(E,{name:"pencil-ai",className:"mr-1.5 h-4 w-4"}),j("sessions.sidebar.project.actions.edit")]}),s.jsxs(G,{onClick:S,className:"text-destructive focus:text-destructive",children:[s.jsx(E,{name:"close",className:"mr-1.5 h-4 w-4"}),j("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=p,e[7]=f,e[8]=S,e[9]=b,e[10]=x,e[11]=y,e[12]=L,e[13]=j,e[14]=pe):pe=e[14];const xe=pe,Ce=F0,Me=_0,ve=L0;let Ie;e[15]===Symbol.for("react.memo_cache_sentinel")?(Ie=G=>{(G.button===2||G.button===0&&G.ctrlKey)&&(se.current=!0)},e[15]=Ie):Ie=e[15];const ye=Ie;let q;e[16]!==v?(q=G=>{if(G.currentTarget.blur(),se.current){se.current=!1;return}v()},e[16]=v,e[17]=q):q=e[17];const De=q;let ke;e[18]!==me?(ke=si.Transform.toString(me),e[18]=me,e[19]=ke):ke=e[19];let te;e[20]!==ke||e[21]!==Z?(te={transform:ke,transition:Z},e[20]=ke,e[21]=Z,e[22]=te):te=e[22];const he=re&&"opacity-30";let ae;e[23]!==he?(ae=Re("relative",he),e[23]=he,e[24]=ae):ae=e[24];let Q;e[25]!==w||e[26]!==U||e[27]!==ne||e[28]!==De||e[29]!==p||e[30]!==O||e[31]!==n||e[32]!==h||e[33]!==le||e[34]!==g||e[35]!==_||e[36]!==ue||e[37]!==f||e[38]!==H||e[39]!==x||e[40]!==m||e[41]!==R||e[42]!==a||e[43]!==o||e[44]!==l||e[45]!==d||e[46]!==u||e[47]!==i||e[48]!==$||e[49]!==xe||e[50]!==N||e[51]!==L||e[52]!==I||e[53]!==T||e[54]!==j?(Q=O?null:s.jsxs(s.Fragment,{children:[g&&s.jsx("div",{ref:N,"data-project-id":n,className:"absolute top-0 h-px w-full pointer-events-none","aria-hidden":"true"}),s.jsxs(ou,{open:le,onOpenChange:ee,children:[s.jsx(ru,{render:s.jsx("div",{className:Re("-ml-2.5 -mr-2 text-left group/project select-none",T&&"sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":T?"true":void 0,onContextMenu:G=>{p||(G.preventDefault(),ee(!0))}}),children:s.jsxs("div",{className:"relative flex items-center gap-1 py-1 pl-4 pr-3.5",...U,children:[ue?s.jsxs(Xs,{children:[s.jsx(Qs,{asChild:!0,children:s.jsxs("button",{type:"button",className:Re("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-primary/50 transition-[padding]",f&&!p?w?"pr-20":"pr-7 group-hover/project:pr-20 group-focus-within/project:pr-20":w?"pr-14":"pr-7 group-hover/project:pr-14 group-focus-within/project:pr-14"),"aria-label":j("sessions.sidebar.project.selectAria",{project:i}),children:[s.jsx(Co,{id:n,projectLabel:i,projectIcon:l,projectColor:a,projectIconImage:u,projectIconBackground:d}),s.jsx(E,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]})}),s.jsx(Ys,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:$?.map(G=>s.jsxs(Wt,{onClick:()=>R?.(G.id),className:"flex items-center justify-between gap-3",title:G.projectDescription,children:[s.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:s.jsx(Co,{...G})}),G.id===n?s.jsx(E,{name:"check",className:"h-4 w-4 flex-shrink-0 text-primary"}):null]},G.id))})]}):s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsxs("button",{type:"button",onMouseDown:ye,onClick:De,...H,className:Re("flex-1 min-w-0 flex items-center gap-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 rounded-md cursor-grab active:cursor-grabbing transition-[padding]",f&&!p?w?"pr-20":"pr-7 group-hover/project:pr-20 group-focus-within/project:pr-20":w?"pr-14":"pr-7 group-hover/project:pr-14 group-focus-within/project:pr-14"),children:[s.jsx(Co,{id:n,projectLabel:i,projectIcon:l,projectColor:a,projectIconImage:u,projectIconBackground:d,isCollapsed:h,alwaysShowActions:w}),I?s.jsx("span",{className:"ml-1 inline-flex flex-shrink-0 items-center",children:I}):null]})}),s.jsx(yt,{side:"right",sideOffset:8,children:o})]}),s.jsxs("div",{className:Re("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",L?"right-7":"right-0.5"),children:[L&&f&&!p&&m?s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:G=>{G.stopPropagation(),m()},className:Re("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-primary/50 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":j("sessions.sidebar.project.actions.newWorktree"),children:s.jsx(E,{name:"node-tree",className:"h-4 w-4"})})}),s.jsx(yt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:j("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,p?null:s.jsxs(Xs,{open:_,onOpenChange:ne,children:[s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button",className:Re("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-primary/50 hover:text-foreground",_?"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":j("sessions.sidebar.project.actions.projectMenu"),onPointerDown:Me,onMouseDown:ve,onClick:Ce,children:s.jsx(E,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(Ys,{align:"end",className:"min-w-[180px]",children:xe(Wt)})]})]}),L&&x?s.jsx("div",{className:"absolute right-0.5 top-1/2 z-10 -translate-y-1/2",children:s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:G=>{G.stopPropagation(),x()},className:Re("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-primary/50 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":j(f?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:s.jsx(E,{name:"add",className:"h-4 w-4"})})}),s.jsx(yt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:j(f?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),s.jsx(nu,{className:"min-w-[180px]",children:xe(Kn)})]})]}),e[25]=w,e[26]=U,e[27]=ne,e[28]=De,e[29]=p,e[30]=O,e[31]=n,e[32]=h,e[33]=le,e[34]=g,e[35]=_,e[36]=ue,e[37]=f,e[38]=H,e[39]=x,e[40]=m,e[41]=R,e[42]=a,e[43]=o,e[44]=l,e[45]=d,e[46]=u,e[47]=i,e[48]=$,e[49]=xe,e[50]=N,e[51]=L,e[52]=I,e[53]=T,e[54]=j,e[55]=Q):Q=e[55];let z;return e[56]!==C||e[57]!==Y||e[58]!==te||e[59]!==ae||e[60]!==Q?(z=s.jsxs("div",{ref:Y,style:te,className:ae,children:[Q,C]}),e[56]=C,e[57]=Y,e[58]=te,e[59]=ae,e[60]=Q,e[61]=z):z=e[61],z},M0=t=>{const e=Xe.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:u,setActivatorNodeRef:d,transform:h,transition:f,isDragging:g}=ti(l);let p;e[3]!==a||e[4]!==d?(p={listeners:a,setActivatorNodeRef:d},e[3]=a,e[4]=d,e[5]=p):p=e[5];const w=p;let v;e[6]!==h?(v=si.Transform.toString(h),e[6]=h,e[7]=v):v=e[7];let x;e[8]!==v||e[9]!==f?(x={transform:v,transition:f},e[8]=v,e[9]=f,e[10]=x):x=e[10];const m=g&&"opacity-50";let b;e[11]!==m?(b=Re("space-y-0.5 rounded-md",m),e[11]=m,e[12]=b):b=e[12];let y;e[13]!==i||e[14]!==w?(y=i(w),e[13]=i,e[14]=w,e[15]=y):y=e[15];let S;return e[16]!==u||e[17]!==x||e[18]!==b||e[19]!==y?(S=s.jsx("div",{ref:u,style:x,className:b,children:y}),e[16]=u,e[17]=x,e[18]=b,e[19]=y,e[20]=S):S=e[20],S},O0=c.memo(M0);function B0(t){return t.stickyZoneHeaders}function F0(t){t.stopPropagation()}function _0(t){t.stopPropagation()}function L0(t){t.stopPropagation()}const $0=(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}},dm=t=>{const e=Xe.c(9),{nodes:n,includeUnreadSubtasks:r,enabled:i}=t,o=i===void 0?!0:i;let l;e[0]!==r||e[1]!==n?(l=$0(n,r),e[0]=r,e[1]=n,e[2]=l):l=e[2];const a=l;let u;e[3]!==o||e[4]!==a.active?(u=g=>{if(!o)return null;for(const p of a.active){const w=g.statusById.get(p)?.status.type;if(w==="busy"||w==="retry")return"active"}return null},e[3]=o,e[4]=a.active,e[5]=u):u=e[5];const d=Ia(u);let h;e[6]!==o||e[7]!==a.unread?(h=g=>{if(!o)return null;for(const p of a.unread)if((g.index.session.unseenCount[p]??0)>0)return"unread";return null},e[6]=o,e[7]=a.unread,e[8]=h):h=e[8];const f=Ra(h);return d??f};function um(t){const e=Xe.c(6),{state:n,activeLabel:r,unreadLabel:i,className:o}=t,l=n==="active"?r:i,a=n==="active"?"bg-primary":"bg-[var(--status-info)]";let u;e[0]!==o||e[1]!==a?(u=Re("h-1.5 w-1.5 shrink-0 rounded-full",a,o),e[0]=o,e[1]=a,e[2]=u):u=e[2];let d;return e[3]!==l||e[4]!==u?(d=s.jsx("span",{className:u,"aria-label":l,title:l}),e[3]=l,e[4]=u,e[5]=d):d=e[5],d}const W0=t=>{const e=Xe.c(11),{nodes:n,includeUnreadSubtasks:r}=t,{t:i}=pt();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=dm(o);if(!l)return null;let a;e[3]!==i?(a=i("sessions.sidebar.session.status.active"),e[3]=i,e[4]=a):a=e[4];let u;e[5]!==i?(u=i("sessions.sidebar.session.status.unread"),e[5]=i,e[6]=u):u=e[6];let d;return e[7]!==l||e[8]!==a||e[9]!==u?(d=s.jsx(um,{state:l,activeLabel:a,unreadLabel:u}),e[7]=l,e[8]=a,e[9]=u,e[10]=d):d=e[10],d},z0=t=>{const e=Xe.c(82),{folder:n,displayName:r,sessions:i,subFolderItems:o,isCollapsed:l,collapsedActivityState:a,onToggle:u,onRename:d,onDelete:h,children:f,mobileVariant:g,alwaysShowActions:p,isRenaming:w,renameDraft:v,onRenameDraftChange:x,onRenameSave:m,onRenameCancel:b,droppableRef:y,isDropTarget:S,onNewSession:N,depth:C,hideActions:k,archivedBucket:A}=t,P=a===void 0?null:a,M=p===void 0?g===void 0?!1:g:p,$=w===void 0?!1:w,R=v===void 0?"":v,K=S===void 0?!1:S,L=k===void 0?!1:k,O=A===void 0?!1:A,{t:I}=pt(),[j,T]=c.useState(!1),[F,U]=c.useState(""),H=c.useRef(null),Y=$||j,me=$?R:F;let Z;e[0]!==n.name?(Z=()=>{U(n.name),T(!0)},e[0]=n.name,e[1]=Z):Z=e[1];const re=Z;let se;e[2]!==me||e[3]!==n.name||e[4]!==$||e[5]!==d||e[6]!==m?(se=()=>{const Se=me.trim();Se&&Se!==n.name&&d(Se),$&&m&&m(),T(!1),U("")},e[2]=me,e[3]=n.name,e[4]=$,e[5]=d,e[6]=m,e[7]=se):se=e[7];const fe=se;let _;e[8]!==$||e[9]!==b?(_=()=>{$&&b&&b(),T(!1),U("")},e[8]=$,e[9]=b,e[10]=_):_=e[10];const le=_;let ee;e[11]!==$||e[12]!==x?(ee=Se=>{$&&x?x(Se):U(Se)},e[11]=$,e[12]=x,e[13]=ee):ee=e[13];const ue=ee;let W,ne;e[14]!==$?(W=()=>{if(!$)return;const Se=()=>{const Ne=H.current;Ne&&(Ne.focus(),Ne.select())},oe=requestAnimationFrame(Se),Pe=window.setTimeout(Se,0);return()=>{cancelAnimationFrame(oe),window.clearTimeout(Pe)}},ne=[$],e[14]=$,e[15]=W,e[16]=ne):(W=e[15],ne=e[16]),c.useEffect(W,ne);const pe=l?"folder":"folder-open",xe=K&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let Ce;e[17]!==xe?(Ce=Re("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",xe),e[17]=xe,e[18]=Ce):Ce=e[18];let Me;e[19]!==u||e[20]!==Y?(Me=Y?void 0:Se=>{Se.currentTarget.blur(),u()},e[19]=u,e[20]=Y,e[21]=Me):Me=e[21];const ve=Y?void 0:"button",Ie=Y?void 0:0;let ye;e[22]!==u||e[23]!==Y?(ye=Y?void 0:Se=>{(Se.key==="Enter"||Se.key===" ")&&(Se.preventDefault(),u())},e[22]=u,e[23]=Y,e[24]=ye):ye=e[24];let q;e[25]!==n.name||e[26]!==l||e[27]!==I?(q=l?I("sessions.sidebar.folderItem.expandAria",{folderName:n.name}):I("sessions.sidebar.folderItem.collapseAria",{folderName:n.name}),e[25]=n.name,e[26]=l,e[27]=I,e[28]=q):q=e[28];const De=O?M?"pr-7":"group-hover/folder:pr-7 group-focus-within/folder:pr-7":M?"pr-20":"group-hover/folder:pr-20 group-focus-within/folder:pr-20";let ke;e[29]!==De?(ke=Re("min-w-0 flex items-center gap-1.5 pl-1.5 flex-1 transition-[padding]",De),e[29]=De,e[30]=ke):ke=e[30];const te=K?"text-primary":"text-muted-foreground";let he;e[31]!==te?(he=Re("h-3.5 w-3.5 flex-shrink-0",te),e[31]=te,e[32]=he):he=e[32];let ae;e[33]!==pe||e[34]!==he?(ae=s.jsx(E,{name:pe,className:he}),e[33]=pe,e[34]=he,e[35]=ae):ae=e[35];let Q;e[36]!==P||e[37]!==r||e[38]!==me||e[39]!==n.name||e[40]!==le||e[41]!==ue||e[42]!==fe||e[43]!==l||e[44]!==K||e[45]!==Y||e[46]!==i||e[47]!==I?(Q=Y?s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:U0,onMouseDown:K0,onSubmit:Se=>{Se.preventDefault(),fe()},children:[s.jsx("input",{ref:H,value:me,onChange:Se=>ue(Se.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:I("sessions.sidebar.folderItem.namePlaceholder"),onClick:H0,onPointerDown:G0,onMouseDown:q0,onKeyDown:Se=>{if(Se.key==="Escape"){Se.stopPropagation(),le();return}(Se.key===" "||Se.key==="Enter")&&Se.stopPropagation()}}),s.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:Q0,onPointerDown:Y0,onMouseDown:X0,children:s.jsx(E,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:Se=>{Se.stopPropagation(),le()},onPointerDown:J0,onMouseDown:Z0,className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(E,{name:"close",className:"size-4"})})]}):s.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("span",{className:Re("typography-ui-label font-semibold truncate",K?"text-primary":"text-muted-foreground"),children:r??n.name})}),s.jsx(yt,{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]}),P?s.jsx(um,{state:P,activeLabel:I("sessions.sidebar.session.status.active"),unreadLabel:I("sessions.sidebar.session.status.unread")}):null,l?s.jsx(E,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(E,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]}),e[36]=P,e[37]=r,e[38]=me,e[39]=n.name,e[40]=le,e[41]=ue,e[42]=fe,e[43]=l,e[44]=K,e[45]=Y,e[46]=i,e[47]=I,e[48]=Q):Q=e[48];let z;e[49]!==ke||e[50]!==ae||e[51]!==Q?(z=s.jsxs("div",{className:ke,children:[ae,Q]}),e[49]=ke,e[50]=ae,e[51]=Q,e[52]=z):z=e[52];let G;e[53]!==M||e[54]!==O||e[55]!==n.name||e[56]!==re||e[57]!==L||e[58]!==h||e[59]!==N||e[60]!==Y||e[61]!==I?(G=!Y&&(!L||O)?s.jsx("div",{className:Re("absolute right-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",M?"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:[!O&&N?s.jsx("button",{type:"button",onClick:Se=>{Se.stopPropagation(),N()},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-primary/50","aria-label":I("sessions.sidebar.folderItem.newSessionAria",{folderName:n.name}),title:I("sessions.sidebar.project.actions.newSession"),children:s.jsx(E,{name:"add",className:"h-3.5 w-3.5"})}):null,O?null:s.jsx("button",{type:"button",onClick:Se=>{Se.stopPropagation(),re()},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-primary/50","aria-label":I("sessions.sidebar.folderItem.renameAria",{folderName:n.name}),children:s.jsx(E,{name:"pencil-ai",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:Se=>{Se.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-primary/50","aria-label":O?I("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:n.name}):I("sessions.sidebar.folderItem.deleteFolderAria",{folderName:n.name}),children:s.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})}):null,e[53]=M,e[54]=O,e[55]=n.name,e[56]=re,e[57]=L,e[58]=h,e[59]=N,e[60]=Y,e[61]=I,e[62]=G):G=e[62];let ie;e[63]!==y||e[64]!==Ce||e[65]!==Me||e[66]!==ve||e[67]!==Ie||e[68]!==ye||e[69]!==q||e[70]!==z||e[71]!==G?(ie=s.jsxs("div",{ref:y,className:Ce,onClick:Me,role:ve,tabIndex:Ie,onKeyDown:ye,"aria-label":q,children:[z,G]}),e[63]=y,e[64]=Ce,e[65]=Me,e[66]=ve,e[67]=Ie,e[68]=ye,e[69]=q,e[70]=z,e[71]=G,e[72]=ie):ie=e[72];let Oe;e[73]!==f||e[74]!==l||e[75]!==i||e[76]!==o||e[77]!==I?(Oe=l?null: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:I("sessions.sidebar.folderItem.emptyFolder")})]}),e[73]=f,e[74]=l,e[75]=i,e[76]=o,e[77]=I,e[78]=Oe):Oe=e[78];let Fe;return e[79]!==ie||e[80]!==Oe?(Fe=s.jsxs("div",{className:"oc-folder",children:[ie,Oe]}),e[79]=ie,e[80]=Oe,e[81]=Fe):Fe=e[81],Fe},V0=c.memo(z0);function U0(t){return t.stopPropagation()}function K0(t){return t.stopPropagation()}function H0(t){return t.stopPropagation()}function G0(t){return t.stopPropagation()}function q0(t){return t.stopPropagation()}function Q0(t){return t.stopPropagation()}function Y0(t){return t.stopPropagation()}function X0(t){return t.stopPropagation()}function J0(t){return t.stopPropagation()}function Z0(t){return t.stopPropagation()}const ej=t=>{const e=Xe.c(15),{sessionId:n,sessionDirectory:r,sessionTitle:i,children:o}=t,l=`session-drag:${n}`;let a;e[0]!==r||e[1]!==n||e[2]!==i?(a={type:"session",sessionId:n,sessionDirectory:r,sessionTitle:i},e[0]=r,e[1]=n,e[2]=i,e[3]=a):a=e[3];let u;e[4]!==l||e[5]!==a?(u={id:l,data:a},e[4]=l,e[5]=a,e[6]=u):u=e[6];const{attributes:d,listeners:h,setNodeRef:f,isDragging:g}=kg(u);let p;e[7]!==h?(p=m=>{m.stopPropagation(),h?.onPointerDown&&h.onPointerDown(m)},e[7]=h,e[8]=p):p=e[8];const w=p,v=g?"opacity-30":void 0;let x;return e[9]!==d||e[10]!==o||e[11]!==w||e[12]!==f||e[13]!==v?(x=s.jsx("div",{ref:f,...d,onPointerDown:w,className:v,children:o}),e[9]=d,e[10]=o,e[11]=w,e[12]=f,e[13]=v,e[14]=x):x=e[14],x},tj=t=>{const e=Xe.c(11),{folderId:n,children:r}=t,i=`folder-drop:${n}`;let o;e[0]!==n?(o={type:"folder",folderId:n},e[0]=n,e[1]=o):o=e[1];let l;e[2]!==i||e[3]!==o?(l={id:i,data:o},e[2]=i,e[3]=o,e[4]=l):l=e[4];const{setNodeRef:a,isOver:u}=Cg(l);let d;e[5]!==r||e[6]!==u||e[7]!==a?(d=r(a,u),e[5]=r,e[6]=u,e[7]=a,e[8]=d):d=e[8];let h;return e[9]!==d?(h=s.jsx(s.Fragment,{children:d}),e[9]=d,e[10]=h):h=e[10],h},sj=t=>{const e=Xe.c(20),{scopeKey:n,hasFolders:r,onSessionDroppedOnFolder:i,children:o}=t;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={activationConstraint:{distance:8}},e[0]=l):l=e[0];const a=zr(On($i,l)),[u,d]=c.useState(null),[h,f]=c.useState("Session"),[g,p]=c.useState(null),[w,v]=c.useState(null);if(!n){let k;return e[1]!==o?(k=s.jsx(s.Fragment,{children:o}),e[1]=o,e[2]=k):k=e[2],k}let x;e[3]!==i?(x=k=>{d(null),p(null),v(null);const{active:A,over:P}=k;if(!P)return;const D=A.data.current,M=P.data.current;D?.type==="session"&&D.sessionId&&M?.type==="folder"&&M.folderId&&i(D.sessionId,M.folderId)},e[3]=i,e[4]=x):x=e[4];const m=x;let b,y;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=k=>{const A=k.active.data.current;if(A?.type==="session"&&A.sessionId){d(A.sessionId),f(A.sessionTitle??"Session");const P=k.active.rect.current.initial?.width,D=k.active.rect.current.initial?.height;p(typeof P=="number"?P:null),v(typeof D=="number"?D:null)}},y=()=>{d(null),p(null),v(null)},e[5]=b,e[6]=y):(b=e[5],y=e[6]);let S;e[7]!==w||e[8]!==u||e[9]!==h||e[10]!==g||e[11]!==r?(S=u&&r?s.jsxs("div",{style:{width:g?`${g}px`:"auto",height:w?`${w}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(E,{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:h})]}):null,e[7]=w,e[8]=u,e[9]=h,e[10]=g,e[11]=r,e[12]=S):S=e[12];let N;e[13]!==S?(N=s.jsx(Wi,{children:S}),e[13]=S,e[14]=N):N=e[14];let C;return e[15]!==o||e[16]!==m||e[17]!==a||e[18]!==N?(C=s.jsxs(Vr,{sensors:a,collisionDetection:Ur,onDragStart:b,onDragCancel:y,onDragEnd:m,children:[o,N]}),e[15]=o,e[16]=m,e[17]=a,e[18]=N,e[19]=C):C=e[19],C},oa=(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)},Gn=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const n of t.children)if(Gn(n,e))return!0;return!1},nj=({isSubtaskSession:t,archivedBucket:e,isVSCode:n,sessionDirectory:r})=>!t&&!e&&!n&&!gh(r),rj=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:n})=>!t||e||n,oj=(t,e,n)=>{const r=new Map,i=o=>{const l=_s(o.session)??dt(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}))},ij=(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})},aj=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 u=a.pop();if(!(!u||r.has(u))){r.add(u);for(const d of n.get(u)??[])a.push(d.id)}}};return t.forEach(l=>{(!l.parentId||!e.has(l.parentId))&&o(l)}),t.forEach(o),i},lj=(t,e)=>{const n=new Map(t.map(u=>[u.id,u])),r=new Map,i=new Set;for(const u of t){if(u.parentId&&!n.has(u.parentId)){i.add(u.id);continue}if(u.parentId){const f=r.get(u.parentId)??[];f.push(u.id),r.set(u.parentId,f)}const d=new Set;let h=u.id;for(;h;){if(d.has(h)){i.add(u.id);break}d.add(h),h=n.get(h)?.parentId}}const o=new Set,l=new Set,a=u=>{if(o.has(u))return!0;if(l.has(u))return!1;const d=n.get(u);if(!d)return!1;l.add(u);let h=i.has(u);return!h&&e.archivedBucket&&d.nodeCount===0?h=(r.get(u)??[]).some(a):(!h&&!e.searchQuery&&(h=!0),!h&&(d.nodeCount>0||Ro([d.name],e.searchQuery))&&(h=!0),h||(h=(r.get(u)??[]).some(a))),l.delete(u),h&&o.add(u),h};return t.forEach(u=>a(u.id)),new Set(t.filter(u=>o.has(u.id)).map(u=>u.id))},Sc=new WeakMap;let vc=1;const cj=t=>{const e=Sc.get(t);if(e!==void 0)return e;const n=vc;return vc+=1,Sc.set(t,n),n},Vo=t=>t.children.length===0?"":t.children.map(n=>{const r=cj(n.session);return n.children.length===0?`${n.session.id}@${r}`:`${n.session.id}@${r}:${Vo(n)}`}).join("|"),mm=(t,e,n,r,i,o)=>{const l=xs(),a=(u,d)=>{if(u.session.id!==d.session.id||u.children.length!==d.children.length)return!0;const h=u.session.directory??i,f=d.session.directory??o,g=ll(l,h??"",u.session.id),p=ll(l,f??"",d.session.id);return(g?n.has(g):!1)!==(p?r.has(p):!1)?!0:u.children.some((w,v)=>a(w,d.children[v]))};return a(t,e)},dj=t=>t.actionsAlwaysVisible?"":`transition-opacity duration-150 ${t.menuOpen?"opacity-0":t.hideOnHoverClass}`,Gr=(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 d of a.children)if(l(d))return!0;return!1};return t.forEach(a=>l(a)),o};let ia=!1;const aa=new Set;let jc=!1;function uj(){for(const t of aa)t()}function Ha(t){ia!==t&&(ia=t,uj())}function mj(t){t.key==="Shift"&&Ha(!0)}function fj(t){t.key==="Shift"&&Ha(!1)}function hj(){Ha(!1)}function pj(){jc||typeof window>"u"||(jc=!0,window.addEventListener("keydown",mj),window.addEventListener("keyup",fj),window.addEventListener("blur",hj))}function gj(t){return pj(),aa.add(t),()=>{aa.delete(t)}}function xj(){return ia}function bj(){return!1}function yj(){return rt.useSyncExternalStore(gj,xj,bj)}const wj=/^[a-z0-9](?:[a-z0-9-]{0,48}[a-z0-9])?$/,fm=/^g[1-9]\d*$/,Dr=(t,e,n,r,i)=>{if(!wj.test(t)||e!==void 0&&!fm.test(e)||!n?.trim()||!r?.trim()||n!==n.trim()||r!==r.trim())return null;if(i===void 0)return{groupSlug:t,runGroup:e,providerID:n,modelID:r,fusion:!1};if(i==="fusion")return{groupSlug:t,runGroup:e,providerID:n,modelID:r,fusion:!0};if(!/^\d+$/.test(i))return null;const o=Number.parseInt(i,10);return!Number.isSafeInteger(o)||o<=0?null:{groupSlug:t,runGroup:e,providerID:n,modelID:r,index:o,fusion:!1}},No=t=>{if(!t)return null;const e=t.split("/");if(e.length<3||e.length>5)return null;const[n]=e;if(e.length===3)return Dr(n,void 0,e[1],e[2],void 0);if(e.length===4){const[,a,u,d]=e;return fm.test(a)?Dr(n,a,u,d,void 0):Dr(n,void 0,a,u,d)}const[,r,i,o,l]=e;return r===""?Dr(n,void 0,i,o,l):Dr(n,r,i,o,l)},Sj=t=>{const e=[t.groupSlug];return t.runGroup&&e.push(t.runGroup),e.push(t.providerID,t.modelID),t.index!==void 0&&e.push(String(t.index)),e.join("/")},vj=(t,e,n,r)=>{const i=[t];return r&&i.push(r),i.push(e,n,"fusion"),i.join("/")},hm=t=>{const e=Xe.c(36),{value:n,onChange:r,className:i,disabled:o,id:l,portalToBody:a}=t,{t:u}=pt(),d=Kt(jj),h=Kt(kj),f=Kt(Cj);let g;e[0]!==d?(g=d(),e[0]=d,e[1]=g):g=e[1];const p=g;let w;e[2]!==p?(w=p.filter(Nj),e[2]=p,e[3]=w):w=e[3];const v=w;let x,m;e[4]!==p.length||e[5]!==h?(x=()=>{p.length===0&&h()},m=[p.length,h],e[4]=p.length,e[5]=h,e[6]=x,e[7]=m):(x=e[6],m=e[7]),c.useEffect(x,m);let b,y;e[8]!==f||e[9]!==o||e[10]!==r||e[11]!==v||e[12]!==n?(b=()=>{if(o)return;const $=n.trim();if($.length>0&&v.some(L=>L.name===$))return;const R=typeof f=="string"&&f.trim().length>0?f.trim():null;if(R&&v.some(L=>L.name===R)){r(R);return}const K=v[0]?.name;K&&r(K)},y=[f,o,r,v,n],e[8]=f,e[9]=o,e[10]=r,e[11]=v,e[12]=n,e[13]=b,e[14]=y):(b=e[13],y=e[14]),c.useEffect(b,y);const S=n.trim().length>0?n:void 0;let N;e[15]!==i?(N=Re("max-w-full",i),e[15]=i,e[16]=N):N=e[16];let C;e[17]!==u?(C=u("multirun.agentSelector.placeholder"),e[17]=u,e[18]=C):C=e[18];let k;e[19]!==C?(k=s.jsx(Ns,{placeholder:C}),e[19]=C,e[20]=k):k=e[20];let A;e[21]!==l||e[22]!==N||e[23]!==k?(A=s.jsx(Os,{id:l,size:"lg",className:N,children:k}),e[21]=l,e[22]=N,e[23]=k,e[24]=A):A=e[24];let P;e[25]!==v?(P=v.length>0&&s.jsx(Mi,{children:v.map(Aj)}),e[25]=v,e[26]=P):P=e[26];let D;e[27]!==a||e[28]!==P?(D=s.jsx(Bs,{fitContent:!0,portalToBody:a,children:P}),e[27]=a,e[28]=P,e[29]=D):D=e[29];let M;return e[30]!==o||e[31]!==r||e[32]!==S||e[33]!==A||e[34]!==D?(M=s.jsxs(Ms,{value:S,onValueChange:r,disabled:o,children:[A,D]}),e[30]=o,e[31]=r,e[32]=S,e[33]=A,e[34]=D,e[35]=M):M=e[35],M};function jj(t){return t.getVisibleAgents}function kj(t){return t.loadAgents}function Cj(t){return t.currentAgentName}function Nj(t){return Ld(t.mode)}function Aj(t){return s.jsx(ts,{value:t.name,className:"w-auto whitespace-nowrap",children:t.name},t.name)}const Pj="h-7",_r=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,Dj=t=>{const e=Xe.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 u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=Re("flex items-center gap-1.5 px-2 rounded-md bg-interactive-selection/20 border border-border/30",Pj),e[0]=u):u=e[0];let d;e[1]!==n.providerID?(d=s.jsx(Oi,{providerId:n.providerID,className:"h-3.5 w-3.5"}),e[1]=n.providerID,e[2]=d):d=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(E,{name:"close",className:"h-3.5 w-3.5"}),e[5]=f):f=e[5];let g;e[6]!==o?(g=s.jsx("button",{type:"button",onClick:o,className:"text-muted-foreground hover:text-foreground ml-0.5",children:f}),e[6]=o,e[7]=g):g=e[7];let p;return e[8]!==d||e[9]!==h||e[10]!==g?(p=s.jsxs("div",{className:u,children:[d,h,g]}),e[8]=d,e[9]=h,e[10]=g,e[11]=p):p=e[11],p},pm=t=>{const e=Xe.c(120),{selectedModels:n,onAdd:r,onRemove:i,onUpdate:o,minModels:l,addButtonLabel:a,showChips:u,maxModels:d,addButtonClassName:h,dropdownSide:f,dropdownClassName:g,containerClassName:p,triggerIcon:w}=t,v=u===void 0?!0:u,x=f===void 0?"top":f,{t:m}=pt(),b=Kt(Tj),y=Kt(Ij),S=Te(Rj),N=Te(Ej),{favoriteModelsList:C,recentModelsList:k}=xh(),A=Te(Mj),P=Te(Oj),[D,M]=c.useState(!1),[$,R]=c.useState(""),[K,L]=c.useState(null),O=c.useRef(null),I=c.useRef(null),j=d===1,T=d===void 0||n.length<d||j;let F;if(e[0]!==n){F=new Map;for(const ge of n){const _e=`${ge.providerID}:${ge.modelID}`;F.set(_e,(F.get(_e)||0)+1)}e[0]=n,e[1]=F}else F=e[1];const U=F;let H;e[2]!==n?(H=ge=>n.filter(tt=>tt.providerID===ge.providerID&&tt.modelID===ge.modelID).findIndex(tt=>tt.instanceId===ge.instanceId)+1,e[2]=n,e[3]=H):H=e[3];const Y=H;let me,Z;e[4]!==x||e[5]!==D?(me=()=>{if(!D||!I.current)return;const ge=I.current.getBoundingClientRect();if(x==="bottom"){const we=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-ge.bottom-16-112;L(Math.max(160,Math.min(320,we)));return}let _e=I.current.parentElement;for(;_e&&!_e.matches('[role="dialog"], [data-scroll-shadow-scroller]');){const de=getComputedStyle(_e);if(de.overflow==="auto"||de.overflow==="hidden"||de.overflowY==="auto"||de.overflowY==="hidden")break;_e=_e.parentElement}const tt=_e?_e.getBoundingClientRect().top:0,Ue=ge.top-tt-16;L(Math.max(150,Math.min(300,Ue)))},Z=[x,D],e[4]=x,e[5]=D,e[6]=me,e[7]=Z):(me=e[6],Z=e[7]),c.useEffect(me,Z);let re,se;e[8]!==T||e[9]!==D?(re=()=>{!T&&D&&(M(!1),R(""))},se=[T,D],e[8]=T,e[9]=D,e[10]=re,e[11]=se):(re=e[10],se=e[11]),c.useEffect(re,se);let fe,_;e[12]!==D?(fe=()=>{if(!D)return;const ge=_e=>{O.current&&!O.current.contains(_e.target)&&(M(!1),R(""))};return document.addEventListener("mousedown",ge),()=>document.removeEventListener("mousedown",ge)},_=[D],e[12]=D,e[13]=fe,e[14]=_):(fe=e[13],_=e[14]),c.useEffect(fe,_);let le;e[15]!==j||e[16]!==r||e[17]!==o||e[18]!==n.length?(le=ge=>{const _e={providerID:ge.providerID,modelID:ge.modelID,displayName:ge.model.name||ge.modelID,instanceId:_r()};j&&n.length>0&&o?o(0,_e):r(_e),j&&(M(!1),R(""))},e[15]=j,e[16]=r,e[17]=o,e[18]=n.length,e[19]=le):le=e[19];const ee=le;let ue;e[20]!==m?(ue=m("multirun.modelMultiSelect.search.placeholder"),e[20]=m,e[21]=ue):ue=e[21];let W;e[22]!==m?(W=m("multirun.modelMultiSelect.search.noResults"),e[22]=m,e[23]=W):W=e[23];let ne;e[24]!==m?(ne=m("multirun.modelMultiSelect.sections.favorites"),e[24]=m,e[25]=ne):ne=e[25];let pe;e[26]!==m?(pe=m("multirun.modelMultiSelect.sections.recent"),e[26]=m,e[27]=pe):pe=e[27];let xe;e[28]!==m?(xe=m("multirun.modelMultiSelect.keyboard.hint"),e[28]=m,e[29]=xe):xe=e[29];let Ce;e[30]!==m?(Ce=m("settings.agents.modelSelector.actions.favorite"),e[30]=m,e[31]=Ce):Ce=e[31];let Me;e[32]!==m?(Me=m("settings.agents.modelSelector.actions.unfavorite"),e[32]=m,e[33]=Me):Me=e[33];let ve;e[34]!==m?(ve=m("chat.modelControls.capabilities"),e[34]=m,e[35]=ve):ve=e[35];let Ie;e[36]!==m?(Ie=m("chat.modelControls.capability.toolCalling"),e[36]=m,e[37]=Ie):Ie=e[37];let ye;e[38]!==m?(ye=m("chat.modelControls.capability.reasoning"),e[38]=m,e[39]=ye):ye=e[39];let q;e[40]!==m?(q=m("chat.modelControls.input"),e[40]=m,e[41]=q):q=e[41];let De;e[42]!==m?(De=m("chat.modelControls.output"),e[42]=m,e[43]=De):De=e[43];let ke;e[44]!==m?(ke=m("chat.modelControls.costPerMillion"),e[44]=m,e[45]=ke):ke=e[45];let te;e[46]!==ue||e[47]!==W||e[48]!==ne||e[49]!==pe||e[50]!==xe||e[51]!==Ce||e[52]!==Me||e[53]!==ve||e[54]!==Ie||e[55]!==ye||e[56]!==q||e[57]!==De||e[58]!==ke?(te={searchPlaceholder:ue,noResults:W,favorites:ne,recent:pe,keyboardHint:xe,favorite:Ce,unfavorite:Me,capabilities:ve,capabilityToolCalling:Ie,capabilityReasoning:ye,input:q,output:De,costPerMillion:ke},e[46]=ue,e[47]=W,e[48]=ne,e[49]=pe,e[50]=xe,e[51]=Ce,e[52]=Me,e[53]=ve,e[54]=Ie,e[55]=ye,e[56]=q,e[57]=De,e[58]=ke,e[59]=te):te=e[59];const he=te;let ae;e[60]!==p?(ae=Re("relative",p),e[60]=p,e[61]=ae):ae=e[61];const Q=D?"":void 0;let z;e[62]!==h?(z=Re($d({size:"default"}),"w-fit",h),e[62]=h,e[63]=z):z=e[63];const G=!T;let ie;e[64]!==D?(ie=()=>{M(!D)},e[64]=D,e[65]=ie):ie=e[65];let Oe;e[66]!==w?(Oe=w??s.jsx(E,{name:"add",className:"h-3.5 w-3.5 mr-1"}),e[66]=w,e[67]=Oe):Oe=e[67];let Fe;e[68]!==a||e[69]!==m?(Fe=a??m("multirun.modelMultiSelect.actions.addModel"),e[68]=a,e[69]=m,e[70]=Fe):Fe=e[70];let Se;e[71]!==Q||e[72]!==z||e[73]!==G||e[74]!==ie||e[75]!==Oe||e[76]!==Fe?(Se=s.jsxs("button",{ref:I,type:"button","data-popup-open":Q,className:z,disabled:G,onClick:ie,children:[Oe,Fe]}),e[71]=Q,e[72]=z,e[73]=G,e[74]=ie,e[75]=Oe,e[76]=Fe,e[77]=Se):Se=e[77];let oe;e[78]!==K||e[79]!==T||e[80]!==g||e[81]!==x||e[82]!==C||e[83]!==ee||e[84]!==A||e[85]!==N||e[86]!==D||e[87]!==he||e[88]!==U||e[89]!==y||e[90]!==P||e[91]!==b||e[92]!==k||e[93]!==$||e[94]!==S?(oe=D?s.jsx("div",{className:Re("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",x==="top"?"bottom-full mb-1":"top-full mt-1",g),style:{background:"linear-gradient(var(--surface-elevated),var(--surface-elevated)),linear-gradient(var(--surface-background),var(--surface-background))"},children:s.jsx(bh,{providers:b,providerOrder:P,favoriteModels:C,recentModels:k,modelsMetadata:y,hiddenModels:A,searchQuery:$,onSearchQueryChange:R,onSelect:ee,labels:he,selectionCount:ge=>U.get(`${ge.providerID}:${ge.modelID}`)||0,disabled:!T,maxHeightClassName:"flex-1",maxHeightStyle:{maxHeight:K?`${K}px`:"300px"},stickyHeaders:!0,tooltipsEnabled:D,isFavorite:ge=>N(ge.providerID,ge.modelID),onToggleFavorite:ge=>S(ge.providerID,ge.modelID),onEscape:()=>{M(!1),R("")}})}):null,e[78]=K,e[79]=T,e[80]=g,e[81]=x,e[82]=C,e[83]=ee,e[84]=A,e[85]=N,e[86]=D,e[87]=he,e[88]=U,e[89]=y,e[90]=P,e[91]=b,e[92]=k,e[93]=$,e[94]=S,e[95]=oe):oe=e[95];let Pe;e[96]!==ae||e[97]!==Se||e[98]!==oe?(Pe=s.jsxs("div",{className:ae,ref:O,children:[Se,oe]}),e[96]=ae,e[97]=Se,e[98]=oe,e[99]=Pe):Pe=e[99];let Ne;e[100]!==Y||e[101]!==U||e[102]!==i||e[103]!==o||e[104]!==b||e[105]!==n||e[106]!==v||e[107]!==m?(Ne=v&&n.length>0&&s.jsx("div",{className:"flex flex-col gap-2 w-full",children:n.map((ge,_e)=>{const tt=`${ge.providerID}:${ge.modelID}`,Ue=U.get(tt)||1,de=Y(ge),we=b.find($e=>$e.id===ge.providerID)?.models?.find($e=>$e.id===ge.modelID),ze=we?.variants?Object.keys(we.variants):[],Ve=ze.length>0,He=ge.variant??"__default__";return s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(Dj,{model:ge,instanceIndex:de,totalSameModel:Ue,onRemove:()=>i(_e)}),Ve&&s.jsxs(Ms,{value:He,onValueChange:$e=>{if(!o)return;o(_e,{...ge,variant:$e==="__default__"?void 0:$e})},children:[s.jsxs(Os,{size:"sm",className:"gap-1.5",children:[s.jsx(E,{name:"brain-ai-3",className:Re("h-3.5 w-3.5 flex-shrink-0",He==="__default__"?"text-muted-foreground":"text-[color:var(--status-info)]")}),s.jsx(Ns,{placeholder:m("multirun.modelMultiSelect.variant.placeholder"),children:$e=>$e==="__default__"?m("multirun.modelMultiSelect.variant.default"):$e})]}),s.jsxs(Bs,{fitContent:!0,children:[s.jsx(ts,{value:"__default__",className:"pr-2 [&>span:first-child]:hidden",children:m("multirun.modelMultiSelect.variant.default")}),ze.map(Bj)]})]})]},ge.instanceId)})}),e[100]=Y,e[101]=U,e[102]=i,e[103]=o,e[104]=b,e[105]=n,e[106]=v,e[107]=m,e[108]=Ne):Ne=e[108];let B;e[109]!==Pe||e[110]!==Ne?(B=s.jsxs("div",{className:"flex flex-wrap gap-1.5 items-center",children:[Pe,Ne]}),e[109]=Pe,e[110]=Ne,e[111]=B):B=e[111];let ce;e[112]!==d||e[113]!==l||e[114]!==n.length||e[115]!==m?(ce=l!==void 0&&n.length<l&&s.jsx("p",{className:"typography-micro text-muted-foreground",children:d!==void 0?m("multirun.modelMultiSelect.validation.minToMax",{min:l,max:d}):m("multirun.modelMultiSelect.validation.minOnly",{min:l})}),e[112]=d,e[113]=l,e[114]=n.length,e[115]=m,e[116]=ce):ce=e[116];let be;return e[117]!==B||e[118]!==ce?(be=s.jsxs("div",{className:"space-y-2",children:[B,ce]}),e[117]=B,e[118]=ce,e[119]=be):be=e[119],be};function Tj(t){return t.providers}function Ij(t){return t.modelsMetadata}function Rj(t){return t.toggleFavoriteModel}function Ej(t){return t.isFavoriteModel}function Mj(t){return t.hiddenModels}function Oj(t){return t.providerOrder}function Bj(t){return s.jsx(ts,{value:t,className:"pr-2 [&>span:first-child]:hidden",children:t},t)}const Fj=(t,e,n)=>{const r=t.session.title?.trim()||t.session.id;return`
|
|
913
|
-
|
|
914
|
-
--- RESULT ${n+1}: ${r} ---
|
|
915
|
-
${e.trim()}
|
|
916
|
-
--- END RESULT ${n+1} ---`},kc=(t,e)=>Qe.getState().getWorktreeMetadata(t)?.projectDirectory??e,_j=async t=>{const e=t.directory??void 0,n=wh(t.session.id,e);if(n.length===0&&t.directory){const i=(await qs.withDirectory(t.directory,()=>qs.getSdkClient().session.messages({sessionID:t.session.id,directory:t.directory??void 0,limit:50}))).data??[];for(let o=i.length-1;o>=0;o-=1){const l=i[o];if(l.info?.role==="assistant")return dl(l.parts??[]).trim()}return""}for(let r=n.length-1;r>=0;r-=1){const i=n[r];if(i.role==="assistant")return dl(Sh(i.id,e)).trim()}return""};function Lj({session:t,open:e,onOpenChange:n}){const{t:r}=pt(),i=yh(),o=Ds(j=>j.activeSessions),l=Ds(j=>j.archivedSessions),a=Kt(j=>j.providers),u=Kt(j=>j.currentProviderId),d=Kt(j=>j.currentModelId),h=Kt(j=>j.currentAgentName),[f,g]=c.useState(u??""),[p,w]=c.useState(d??""),[v,x]=c.useState(()=>u&&d?[{providerID:u,modelID:d,instanceId:_r()}]:[]),[m,b]=c.useState(""),[y,S]=c.useState(h??""),[N,C]=c.useState([]),[k,A]=c.useState(!1),P=c.useMemo(()=>No(t.title),[t.title]),D=c.useMemo(()=>{const j=new Map;for(const T of i)j.set(T.id,T);for(const T of o)j.set(T.id,T);for(const T of l)j.set(T.id,T);return t.id&&j.set(t.id,t),Array.from(j.values())},[o,l,i,t]);c.useEffect(()=>{if(!e||!P)return;const j=Qe.getState().getDirectoryForSession(t.id),T=kc(t.id,j),F=D.map(U=>{const H=No(U.title);if(!H||H.groupSlug!==P.groupSlug||H.fusion||(H.runGroup??null)!==(P.runGroup??null))return null;const Y=Qe.getState().getDirectoryForSession(U.id)??_s(U),me=kc(U.id,Y);return T&&me&&T!==me?null:{session:U,directory:Y,projectDirectory:me}}).filter(U=>U!==null).sort((U,H)=>(U.session.time?.created??0)-(H.session.time?.created??0));C(F)},[D,e,P,t.id]);const $=a.find(j=>j.id===f)?.models.find(j=>j.id===p),R=$?.variants?Object.keys($.variants):[],K=!!(P&&f&&p&&N.length>0&&!k),L=c.useCallback(j=>{x([j]),g(j.providerID),w(j.modelID),b("")},[]),O=v[0]?.displayName||v[0]?.modelID||r("multirun.fusion.model.placeholder"),I=async()=>{if(!(!P||!f||!p)){A(!0);try{const j=await Promise.all(N.map(Z=>_j(Z))),T=N.map((Z,re)=>({source:Z,text:j[re]??""})).filter(Z=>Z.text.trim().length>0);if(T.length===0){Be.error(r("multirun.fusion.toast.noOutputs"));return}const F=N[0]?.projectDirectory??N[0]?.directory??null,U=vj(P.groupSlug,f,p,P.runGroup),[H,Y]=await Promise.all([cl("session.fusion.visible"),cl("session.fusion.instructions")]),me=await Qe.getState().createSession(U,F,null);if(!me)throw new Error("Failed to create fusion session");Qe.getState().setCurrentSession(me.id,F),n(!1),await qs.sendMessage({id:me.id,providerID:f,modelID:p,variant:m||void 0,agent:y||void 0,text:H,additionalParts:[{text:Y,synthetic:!0},...T.map((Z,re)=>({text:Fj(Z.source,Z.text,re),synthetic:!0})),{text:`
|
|
917
|
-
|
|
918
|
-
--- FUSION INPUTS END ---
|
|
919
|
-
Now write the final fused answer.`,synthetic:!0}],directory:F??qs.getDirectory()})}catch(j){console.error("[MultiRunFusion] Failed to start fusion",j),Be.error(r("multirun.fusion.toast.failed"))}finally{A(!1)}}};return s.jsx(Ss,{open:e,onOpenChange:n,children:s.jsxs(vs,{className:"max-w-xl overflow-visible",children:[s.jsxs(Ls,{children:[s.jsx(Ts,{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(pm,{selectedModels:v,onAdd:L,onUpdate:(j,T)=>L(T),onRemove:()=>{x([]),g(""),w(""),b("")},maxModels:1,addButtonLabel:O,showChips:!1,addButtonClassName:"w-fit max-w-[min(28rem,calc(100vw-8rem))] justify-start",dropdownSide:"bottom",dropdownClassName:"w-[min(28rem,calc(100vw-8rem))]",triggerIcon:f?s.jsx(Oi,{providerId:f,className:"h-3.5 w-3.5 mr-1"}):void 0})}),R.length>0?s.jsxs(Ms,{value:m||"__default__",onValueChange:j=>b(j==="__default__"?"":j),children:[s.jsxs(Os,{size:"lg",className:"w-fit",children:[s.jsx(E,{name:"brain-ai-3",className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx(Ns,{children:j=>j==="__default__"?r("multirun.modelMultiSelect.variant.default"):j})]}),s.jsxs(Bs,{fitContent:!0,portalToBody:!0,children:[s.jsx(ts,{value:"__default__",children:r("multirun.modelMultiSelect.variant.default")}),R.map(j=>s.jsx(ts,{value:j,children:j},j))]})]}):null,s.jsx(hm,{value:y,onChange:S,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:N.length})}),s.jsx("div",{className:"max-h-56 space-y-1 overflow-auto rounded-lg border border-[var(--interactive-border)] p-1",children:N.map(j=>s.jsxs("div",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 typography-meta",children:[s.jsx(Oi,{providerId:No(j.session.title)?.providerID??"",className:"h-4 w-4"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:j.session.title||j.session.id}),s.jsx("button",{type:"button",onClick:()=>C(T=>T.filter(F=>F.session.id!==j.session.id)),className:"text-muted-foreground hover:text-foreground",children:s.jsx(E,{name:"close",className:"h-4 w-4"})})]},j.session.id))})]}),s.jsxs(xn,{children:[s.jsx(ot,{variant:"ghost",onClick:()=>n(!1),children:r("multirun.fusion.actions.cancel")}),s.jsx(ot,{onClick:I,disabled:!K,children:r(k?"multirun.fusion.actions.starting":"multirun.fusion.actions.start")})]})]})})}function $j(t){const e=Xe.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 Wj=(t,e)=>(t.current.runtimeKey!==e||(t.current={...t.current,revision:t.current.revision+1}),t.current.revision),gm=t=>new Map([...t.entries()].map(([e,n])=>[e,n.map(r=>qr(r))])),la=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:gm(t.publishedWorktreesByProject)}),t.rawWorktreesByProjectRef.current),xm=(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"})},Cc=t=>{const e=t.split("/").filter(Boolean);return e[e.length-1]??t},qr=t=>({...t,path:dt(t.path)??t.path,projectDirectory:dt(t.projectDirectory)??t.projectDirectory,worktreeRoot:dt(t.worktreeRoot??t.path)??t.worktreeRoot}),Nc=t=>{const{currentWorktree:e,path:n,projectDirectory:r,projectRootBranch:i}=t,l=dt(e?.path??null)===n,a=l?e?.branch??"":i??"",u={path:n,projectDirectory:r,branch:a,label:l?e?.label||e?.branch||e?.name||Cc(n):i||Cc(n),name:l?e?.name:void 0,worktreeRoot:l?dt(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,...u}:u},Ac=t=>{const e=dt(t.projectPath??null),n=dt(t.sourceDirectory??null)??dt(t.currentWorktree?.path??null),r=dt(t.discoveredWorktrees.find(h=>dt(h.projectDirectory??null))?.projectDirectory??null),i=dt(t.currentWorktree?.projectDirectory??null),o=r??i??e,l=new Map,a=h=>{const f=dt(h.metadata.path??null);!f||l.has(f)||l.set(f,{...h,metadata:qr({...h.metadata,path:f})})};for(const h of t.discoveredWorktrees){const f=dt(h.path??null);f&&a({metadata:qr({...h,path:f,projectDirectory:dt(h.projectDirectory??null)??o??e??f}),isPrimary:o===f,isCurrent:n===f})}o&&!l.has(o)&&a({metadata:Nc({path:o,projectDirectory:o,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:!0,isCurrent:n===o}),n&&!l.has(n)&&a({metadata:Nc({path:n,projectDirectory:o??e??n,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:o===n,isCurrent:!0});const u=[],d=[];for(const h of l.values()){if(h.isPrimary){u.push(h);continue}d.push(h)}return u.sort((h,f)=>h.metadata.path.localeCompare(f.metadata.path,void 0,{sensitivity:"base"})),d.sort(xm),[...u,...d]},zj=(t,e)=>{const n=e.getRuntimeKey(),r=e.getPublishedWorktreesByProject(),i=la({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:r,runtimeKey:n}),l=(t.projectId?e.projects.find(d=>d.id===t.projectId)??null:null)??(t.sourceDirectory?e.resolveProject(t.sourceDirectory):null),a=dt(l?.path??null);return{cachedTargets:Ac({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 d=await e.listProjectWorktrees(l,{force:!0});if(e.getRuntimeKey()!==n)throw new Error("Runtime changed during worktree refresh");const h=e.getCurrentProjects(),f=h.find(S=>S.id===l.id)??null;if(!f||dt(f.path??null)!==a)throw new Error("Project removed during worktree refresh");const g=la({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:e.getPublishedWorktreesByProject(),runtimeKey:n}),p=gm(g.worktreesByProject),w=[...d].map(S=>qr(S)).sort((S,N)=>xm({metadata:S},{metadata:N})),v=dt(w.find(S=>dt(S.projectDirectory??null))?.projectDirectory??t.currentWorktree?.projectDirectory??l.path),x=new Set([a]);for(const[S,N]of p.entries()){const C=dt(N.find(k=>dt(k.projectDirectory??null))?.projectDirectory??S);C&&C===v&&x.add(S)}for(const S of x){if(w.length===0){p.delete(S);continue}p.set(S,w.map(N=>qr(N)))}Wj(e.rawWorktreesByProjectRef,n),e.rawWorktreesByProjectRef.current={runtimeKey:n,revision:e.rawWorktreesByProjectRef.current.revision,worktreesByProject:p};const m=e.partitionWorktreesByRegisteredProject(h,p),b=[...m.values()].flat();e.recordWorktreesSeen(b.map(S=>S.path),e.now());const y=e.getPublishedWorktreesByProject();return e.worktreeMapsEqual(m,y)||e.publishTopology({availableWorktrees:b,availableWorktreesByProject:m}),Ac({projectPath:a,discoveredWorktrees:w,sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch})})()}},Vj=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},Uj=t=>({refreshState:t.isRefreshing?"loading":t.loadFailed&&t.targets.length===0?"error":null,showNewWorktreeAction:!0}),Kj=(t,e)=>dt(t.worktree?.path??null)===dt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch,ca=6,mo=14,Pc=ca+14+6,Si=new WeakMap,Hj=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)},u=()=>{if(o||!e.isConnected||!n.isConnected){a();return}const d=e.getBoundingClientRect().top-r;if(Math.abs(d)>.5&&(n.scrollTop+=d,Gs("ui.sidebar.selection_scroll_anchor_adjustment")),i-=1,i<=0){a();return}l=window.requestAnimationFrame(u)};n.addEventListener("wheel",a,{passive:!0}),n.addEventListener("touchstart",a,{passive:!0}),Si.set(n,a),l=window.requestAnimationFrame(u)},Gj=c.memo(function(e){const n=Xe.c(22),{archiveLabel:r,deleteLabel:i,buttonSizeClass:o,iconSizeClass:l,onPointerDown:a,onMouseDown:u,onArchive:d,onDelete:h}=e,f=yj(),g=f?i:r;let p;n[0]!==d||n[1]!==h||n[2]!==f?(p=C=>{if(f||C.shiftKey){h(C);return}d(C)},n[0]=d,n[1]=h,n[2]=f,n[3]=p):p=n[3];const w=p,v=f?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let x;n[4]!==o||n[5]!==v?(x=Re("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",v,o),n[4]=o,n[5]=v,n[6]=x):x=n[6];const m=f?"delete-bin":"archive";let b;n[7]!==l||n[8]!==m?(b=s.jsx(E,{name:m,className:l}),n[7]=l,n[8]=m,n[9]=b):b=n[9];let y;n[10]!==w||n[11]!==g||n[12]!==u||n[13]!==a||n[14]!==x||n[15]!==b?(y=s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",className:x,"aria-label":g,onPointerDown:a,onMouseDown:u,onClick:w,onKeyDown:s2,children:b})}),n[10]=w,n[11]=g,n[12]=u,n[13]=a,n[14]=x,n[15]=b,n[16]=y):y=n[16];let S;n[17]!==g?(S=s.jsx(yt,{side:"left",sideOffset:8,children:g}),n[17]=g,n[18]=S):S=n[18];let N;return n[19]!==y||n[20]!==S?(N=s.jsxs(xt,{children:[y,S]}),n[19]=y,n[20]=S,n[21]=N):N=n[21],N});function qj(t){Gs("ui.sidebar_session_node.render");const{t:e}=pt(),{node:n,depth:r=0,groupDirectory:i,projectId:o,archivedBucket:l=!1,pinnedSessionIds:a,expandedParents:u,hasSessionSearchQuery:d,normalizedSessionSearchQuery:h,notifyOnSubtasks:f,editingId:g,setEditingId:p,editTitle:w,setEditTitle:v,handleSaveEdit:x,handleCancelEdit:m,toggleParent:b,handleSessionSelect:y,handleSessionDoubleClick:S,handleShareSession:N,copiedSessionId:C,handleCopyShareUrl:k,handleCopySessionId:A,handleUnshareSession:P,openSidebarMenuKey:D,setOpenSidebarMenuKey:M,createFolderAndStartRename:$,handleDeleteSession:R,handleRestoreSession:K,startSessionWorktreeMenuLoad:L,mobileVariant:O,alwaysShowActions:I,secondaryMeta:j,renderContext:T="project",children:F}=t,U=$r(Ae=>Ae.toggle),H=ls(Ae=>Ae.getFoldersForScope),Y=ls(Ae=>Ae.getSessionFolderId),me=ls(Ae=>Ae.removeSessionFromFolder),Z=ls(Ae=>Ae.addSessionToFolder),re=Te(Ae=>Ae.openContextPanelTab),se=c.useMemo(()=>Pn(),[]),fe=c.useMemo(()=>qo(),[]),_=c.useContext(vh),le=se?"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",ee=se?"group-hover:opacity-0":"group-hover:opacity-0 group-focus-within:opacity-0",ue=se,W=!l&&!O,ne=se?W&&ue?"group-hover:pr-18":W||ue?"group-hover:pr-14":"group-hover:pr-8":W?"group-hover:pr-7 group-focus-within:pr-7":"group-hover:pr-3 group-focus-within:pr-3",pe=W?"pr-13":"pr-7",xe=c.useRef(!1),[Ce,Me]=c.useState(!1),ve=c.useRef(g);ve.current=g;const Ie=c.useRef(null),ye=c.useRef(!1),q=c.useRef(x);q.current=x;const[De,ke]=c.useState(w),te=c.useRef(De);te.current=De;const he=c.useRef(null),ae=c.useRef(!1),Q=c.useRef(null),z=c.useRef(null),G=n.session,ie=G,Oe=zt(c.useCallback(Ae=>{if(j?.projectLabel||!o)return null;const Et=Ae.projects.find(Gt=>Gt.id===o);return Et?Et.label?.trim()||Fn(dt(Et.path)??Et.path,null)||Et.path:null},[o,j?.projectLabel])),Fe=j?.projectLabel??(Oe?Ea(Oe):null),Se=j?.branchLabel??n.worktree?.branch??null,oe=c.useMemo(()=>{if(se)return null;const Ae=n.worktree?.branch?.trim(),Et=dt(n.worktree?.path??null);return Ae&&Et?Jo(Et,Ae):null},[se,n.worktree]),Pe=Wd(oe),Ne=Pe?`var(--pr-${Pe.visualState})`:void 0,B=as(Ae=>Ae.sessionGroupingMode),ce=!!Se&&(T==="recent"||B==="flat"),be=c.useMemo(()=>{if(!Pe)return null;switch(Pe.visualState){case"merged":return e("sessions.sidebar.group.pr.status.merged");case"open":return Pe.canMerge===!0||Pe.mergeableState==="clean"||Pe.checks?.state==="success"?e("sessions.sidebar.group.pr.status.readyToMerge"):e("sessions.sidebar.group.pr.status.open");case"blocked":return Pe.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}},[Pe,e]),ge=Qe(Ae=>Ae.currentSessionId===G.id),_e=dt(G.directory??null)??dt(i??null),tt=o??_e??null,Ue=jh(),de=zd(),X=se,we=gs(Ae=>Ae.enabled),ze=gs(c.useCallback(Ae=>Ae.selectedIds.has(G.id),[G.id])),Ve=gs(Ae=>Ae.toggleSelected),He=gs(Ae=>Ae.setRange),$e=c.useCallback(Ae=>{const Et=[],Gt=os=>{os.children.forEach(ys=>{Et.push(ys.session.id),Gt(ys)})};return Gt(Ae),Et},[]),qe=c.useCallback(Ae=>{const Et=[],Gt=os=>{os.children.forEach(ys=>{Et.push(ys.session),Gt(ys)})};return Gt(Ae),Et},[]),[at,gt]=c.useState(!1),[Pt,Ge]=c.useState(!0),It=`${T}:${l?"archived":"active"}:${G.id}`,kt=Vd(c.useCallback(Ae=>!!Ae.sessionMemoryState.get(kh(G.id))?.isZombie,[G.id])),Tt=ya(G.id)?.type??"idle",wt=Tt==="busy"||Tt==="retry",St=Ch(G.id,wt),vt=Au(G.id),ht=n.worktree??Qe.getState().getWorktreeMetadata(G.id)??null,[Ze,je]=c.useState([]),[nt,lt]=c.useState(!1),[Ct,Ye]=c.useState(!1),it=c.useRef(!1),Nt=c.useRef(0),Dt=Nh(G.id,_e??void 0,{bootstrap:!1}),Rt=Ah(ie),Vt=Rt?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center",title:e(ul[Rt.status]),"aria-label":e(ul[Rt.status]),children:s.jsx(E,{name:"target",className:"h-3 w-3",style:{color:Ph[Rt.status]}})}):null,Qt=ie.title||e("sessions.sidebar.session.untitled"),Ut=n.children.length>0,Ft=Dh(a,_e,G.id),Yt=It,$t=d?!0:u.has(Yt),_t=c.useMemo(()=>oj(n,$t,_e),[$t,n,_e]),Ee=Th(_t),Ke=!!ie.parentID,ct=pd(G.id)>0&&(!Ke||f),ut=ie.time?.updated||ie.time?.created||Date.now(),jt=Ud(ut),st=Ih(ut),Lt=D===It,[Xt,ds]=c.useState(!1),js=Lt||Xt,ns=c.useMemo(()=>No(ie.title)!==null,[ie.title]),[Js,rs]=c.useState(!1),As=c.useMemo(()=>$e(n).length,[$e,n]),$s=c.useCallback(async Ae=>{const Et=[];let Gt=0;for(const os of Ae)try{if(!_e)throw new Error("Session directory is required for export");const ys=await Ue({directory:_e,sessionID:os.session.id});if(!ys)throw new Error("Session runtime changed during export");const hs=os.session.title||e("sessions.sidebar.session.export.untitledSubagent"),tn=os.session.agent,Zt=await $s(os.children);Gt+=Zt.skipped,Et.push({title:hs,agent:tn,records:ys,children:Zt.children})}catch{Gt+=$e(os).length+1}return{children:Et,skipped:Gt}},[$e,Ue,_e,e]),Zs=c.useCallback(Ae=>{Ae<=0||Be.warning(Ae===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:Ae}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:Ae}))},[e]),ln=c.useCallback(async Ae=>{if(!_e){Be.error(e("sessions.sidebar.session.export.nothingToExport"));return}const Et=await Ue({directory:_e,sessionID:G.id}).catch(()=>null);if(!Et){Be.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}if(Et.length===0){Be.error(e("sessions.sidebar.session.export.nothingToExport"));return}let Gt,os=0;if(Ae&&n.children.length>0){const Zt=await $s(n.children);Gt=Zt.children,os=Zt.skipped}const ys=ju(Et,ie.title??null,Gt),hs=Nu(ie.title??null),tn=await Cu(ys,hs);if(tn){Be.success(e("sessions.sidebar.session.export.success"),{action:{label:e(Lx()),onClick:()=>{_x(tn).then(Zt=>{Zt||Be.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),Zs(os);return}ku(ys,hs),Be.success(e("sessions.sidebar.session.export.success")),Zs(os)},[$s,Ue,n.children,ie.title,G.id,_e,Zs,e]),bs=c.useCallback(async()=>{if(n.children.length>0){Ge(!0),gt(!0);return}await ln(!1)},[ln,n.children.length]),ks=c.useCallback(()=>{_e&&Mn("desktop_open_session_mini_chat_window",{sessionId:G.id,directory:_e,apiBaseUrl:Nn(),clientToken:Lr()}).catch(Ae=>{console.warn("[session-sidebar] failed to open mini chat window",Ae)})},[G.id,_e]);if(c.useEffect(()=>{if(g!==G.id)return;const Ae=Et=>{const os=(Et.target instanceof HTMLElement?Et.target:null)?.closest?.(`[data-session-rename-form="${CSS.escape(G.id)}"]`);z.current&&!os&&q.current(te.current)};return document.addEventListener("mousedown",Ae),()=>document.removeEventListener("mousedown",Ae)},[g,G.id]),c.useLayoutEffect(()=>{if(g!==G.id){he.current===G.id&&(he.current=null);return}he.current!==G.id&&(he.current=G.id,ae.current=!0,ke(w))},[g,w,G.id]),c.useLayoutEffect(()=>{if(g!==G.id||!ae.current)return;const Ae=Q.current;!Ae||Ae.value!==w||(ae.current=!1,Ae.focus(),Ae.select())},[g,w,De,G.id]),g===G.id)return s.jsx("div",{style:{paddingLeft:Pc+r*mo},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:z,"data-session-rename-form":G.id,className:"flex w-full items-center gap-2",onSubmit:Ae=>{Ae.preventDefault(),x(De)},children:[s.jsx("input",{ref:Q,value:De,onChange:Ae=>ke(Ae.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:Ae=>{if(Ae.stopPropagation(),Ae.key==="Escape"){m();return}}}),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(E,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:m,"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(E,{name:"close",className:"size-4"})})]})})},G.id);const Ws=Dt.length,cn=Ee===1?e("sessions.sidebar.session.status.questionPendingSingle"):e("sessions.sidebar.session.status.questionPendingMany",{count:Ee}),us=dj({actionsAlwaysVisible:I&&!se,menuOpen:js,hideOnHoverClass:ee}),zs=!vt&&!wt&&ct&&!ge,At=wt||zs,Bt=e(wt?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),Jt=s.jsx("span",{className:Re("h-1.5 w-1.5 rounded-full",wt?"bg-primary":"bg-[var(--status-info)]"),"aria-label":Bt,title:Bt}),ms=(wt||zs)&&St,fs=!I&&Ut&&(vt||At||Ft),Ps=Ft&&!vt&&!At,J=s.jsx(E,{name:"pushpin",className:"h-3 w-3 flex-shrink-0 text-primary","aria-label":e("sessions.sidebar.session.status.pinned")}),We=vt||At||Ps?s.jsx("span",{style:{left:ca+r*mo},className:Re("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",fs?"opacity-100 group-hover:opacity-0 group-focus-within:opacity-0":""),children:vt?s.jsx(E,{name:"loader-4",className:"h-3 w-3 animate-spin text-primary","aria-label":e("sessions.sidebar.session.status.movingToWorktree")}):At?Jt:Ps?J:null}):null,V=Ut&&!I&&(vt||At||Ft),Le=Ut?s.jsx("span",{role:"button",tabIndex:0,onClick:Ae=>{Ae.stopPropagation(),Ae.currentTarget.blur(),b(Yt)},onKeyDown:Ae=>{(Ae.key==="Enter"||Ae.key===" ")&&(Ae.preventDefault(),Ae.stopPropagation(),b(Yt))},style:{minWidth:14,minHeight:14,left:ca+r*mo},className:Re("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-primary/50 transition-opacity",V?"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($t?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:$t?s.jsx(E,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(E,{name:"arrow-right-s",className:"h-3 w-3"})}):null,Je=kt?s.jsx(E,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,mt=Ae=>{Ae&&ds(!1),M(Ae?It:null)},ft=Ae=>{if(!Ae&&Ie.current){const{id:Et,title:Gt}=Ie.current;Ie.current=null,p(Et),v(Gt)}},Ot=Ae=>{ds(Ae)},ss=Ae=>{Ae.preventDefault(),Ae.stopPropagation(),M(Lt?null:It)},Ht=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},en=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},yn=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},ii=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},sr=Ae=>{Ae.preventDefault(),Ae.stopPropagation(),M(null),R(G,{archivedBucket:l})},Rm=Ae=>{Ae.preventDefault(),Ae.stopPropagation(),M(null),R(G,{archivedBucket:l,hardDelete:!0,skipConfirm:!0})},Em=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},Mm=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},Om=Ae=>{Ae.preventDefault(),Ae.stopPropagation(),_?.vscode?.executeCommand("openchamber.openSessionInEditor",G.id,Qt)},Ga=Ae=>{if(xe.current){xe.current=!1;return}if(we){if(Ae?.preventDefault(),Ae?.stopPropagation(),Ae?.shiftKey){const Gt=Array.from(document.querySelectorAll("[data-session-row]")).map(hs=>hs.getAttribute("data-session-row")).filter(hs=>hs!==null&&hs.length>0),os=gs.getState().anchorId,ys=new Map;ys.set(G.id,$e(n)),He(os,G.id,Gt,tt,ys);return}Ve(G.id,tt,$e(n));return}Ae?.currentTarget&&Hj(Ae.currentTarget),y(G.id,_e)},Bm=Ae=>{Ae.defaultPrevented||(Ae.target instanceof HTMLElement?Ae.target:null)?.closest('button, a, input, [role="menuitem"], [role="menu"]')||Ga(Ae)},Fm=Ae=>{(Ae.button===2||Ae.button===0&&Ae.ctrlKey&&!we)&&(xe.current=!0)},_m=Ae=>{O&&Ae.pointerType==="touch"&&Me(!0),Ae.button===0&&!ge&&!we&&!X&&_e&&!Ei(G.id,_e).renderable&&de({directory:_e,sessionID:G.id}).catch(()=>{})},qa=Ae=>{O&&Ae.pointerType==="touch"&&Me(!1)},Lm=Ae=>{it.current=Ae,Nt.current+=1;const Et=Nt.current;if(!Ae){lt(!1),Ye(!1);return}const Gt=L({projectId:o??null,sourceDirectory:_e,currentWorktree:ht});je(Gt.cachedTargets),lt(!0),Ye(!1),Gt.refreshTargets.then(os=>{!it.current||Nt.current!==Et||(je(os),lt(!1),Ye(!1))}).catch(()=>{!it.current||Nt.current!==Et||(lt(!1),Ye(!0))})},Qa=({Item:Ae,Separator:Et,Sub:Gt,SubTrigger:os,SubContent:ys})=>s.jsxs(s.Fragment,{children:[s.jsxs(Ae,{onClick:()=>{Ie.current={id:G.id,title:Qt}},className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"pencil-ai",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]}),s.jsxs(Ae,{onClick:()=>A(G.id),className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyId")]}),s.jsxs(Ae,{onClick:()=>_e&&U({directory:_e,sessionId:G.id}),className:"[&>svg]:mr-1",children:[Ft?s.jsx(E,{name:"unpin",className:"mr-1 h-4 w-4"}):s.jsx(E,{name:"pushpin",className:"mr-1 h-4 w-4"}),e(Ft?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]}),ie.share?s.jsxs(s.Fragment,{children:[s.jsx(Ae,{onClick:()=>{ie.share?.url&&k(ie.share.url,G.id)},className:"[&>svg]:mr-1",children:C===G.id?s.jsxs(s.Fragment,{children:[s.jsx(E,{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(E,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyLink")]})}),s.jsxs(Ae,{onClick:()=>P(G.id),className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"link-unlink-m",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Ae,{onClick:()=>N(ie),className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"share-2",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.share")]}),s.jsxs(Ae,{onClick:()=>{bs()},className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"download",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]}),nj({isSubtaskSession:Ke,archivedBucket:!!l,isVSCode:se,sessionDirectory:_e})?(()=>{const hs=rj({sessionDirectory:_e,isStreaming:wt,isMovingToWorktree:vt}),tn=Uj({targets:Ze,isRefreshing:nt,loadFailed:Ct});return s.jsxs(Gt,{onOpenChange:Lm,children:[s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsxs(os,{disabled:hs,className:"w-full [&>svg]:mr-1","data-session-worktree-submenu-trigger":G.id,children:[s.jsx(E,{name:"folder-shared",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.moveToWorktreeTargets")]})}),s.jsx(yt,{side:"right",className:"max-w-72",children:e(vt?"sessions.sidebar.session.moveToWorktree.tooltipMoving":wt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltipTargets")})]}),s.jsxs(ys,{className:"min-w-[220px]","data-session-worktree-submenu":G.id,children:[Ze.map(Zt=>{const sn=dt(Zt.metadata.path??null)??Zt.metadata.path,jr=Zt.isPrimary?e("sessions.sidebar.session.moveToWorktree.main"):Zt.metadata.label||Zt.metadata.branch||Zt.metadata.name||Zt.metadata.path,ps=Zt.isCurrent||Zt.metadata.worktreeStatus!=="ready";return s.jsxs(Ae,{disabled:ps,title:Zt.metadata.path,"data-session-worktree-target":sn,onClick:()=>{ps||!_e||Qi({kind:"existing",root:ie,descendants:qe(n),sourceDirectory:_e,destination:Zt.metadata,messages:Gi(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:jr}),Zt.isCurrent?s.jsx("span",{className:"sr-only",children:e("sessions.sidebar.session.moveToWorktree.current")}):null]}),Zt.isCurrent?s.jsx(E,{name:"check",className:"ml-2 h-3.5 w-3.5 flex-shrink-0 text-primary","aria-hidden":"true"}):null]},sn)}),tn.refreshState==="loading"?s.jsx(Ae,{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,tn.refreshState==="error"?s.jsx(Ae,{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(Et,{}),s.jsxs(Ae,{disabled:hs,"data-session-worktree-new-action":"true",onClick:()=>{hs||!_e||Qi({kind:"quick",root:ie,descendants:qe(n),sourceDirectory:_e,messages:Gi(e,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.newWorktree")]})]})]})})():null,ns?s.jsxs(Ae,{onClick:()=>rs(!0),className:"[&>svg]:mr-1",children:[s.jsx($j,{className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.runFusion")]}):null,_e&&!l?(()=>{const hs=[],tn=ps=>{const Cs=dt(ps??null);Cs&&!hs.includes(Cs)&&hs.push(Cs)};if(o&&!se){const ps=zt.getState().projects.find(nr=>nr.id===o),Cs=dt(ps?.path??null);tn(Cs),Cs&&(Qe.getState().availableWorktreesByProject.get(Cs)??[]).forEach(nr=>tn(nr.path))}tn(Kd(_e)),tn(_e);const Zt=hs.flatMap(ps=>H(ps).map(Cs=>({scope:ps,folder:Cs}))),sn=Zt.find(({scope:ps,folder:Cs})=>Y(ps,G.id)===Cs.id)??null,jr=hs[0]??_e;return s.jsxs(s.Fragment,{children:[s.jsx(Et,{}),s.jsxs(Gt,{children:[s.jsxs(os,{className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]}),s.jsxs(ys,{className:"min-w-[180px]",children:[Zt.length===0?s.jsx(Ae,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):Zt.map(({scope:ps,folder:Cs})=>{const nr=sn?.folder.id===Cs.id;return s.jsxs(Ae,{onClick:()=>{if(nr){me(ps,G.id);return}sn&&sn.scope!==ps&&me(sn.scope,G.id),Z(ps,Cs.id,G.id)},children:[s.jsx("span",{className:"flex-1 truncate",children:Cs.name}),nr?s.jsx(E,{name:"check",className:"ml-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},Cs.id)}),s.jsx(Et,{}),s.jsxs(Ae,{onClick:()=>{const ps=$(jr);ps&&(ye.current=!0,sn&&sn.scope!==jr&&me(sn.scope,G.id),Z(jr,ps.id,G.id))},children:[s.jsx(E,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),sn?s.jsxs(Ae,{onClick:()=>{me(sn.scope,G.id)},className:"text-destructive focus:text-destructive",children:[s.jsx(E,{name:"close",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,se?null:s.jsxs(Ae,{disabled:!_e,onClick:()=>{_e&&re(_e,{mode:"chat",dedupeKey:`session:${G.id}`,label:Qt,sessionTitleFallback:Qt})},className:"[&>svg]:mr-1",children:[s.jsx(E,{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")})]}),fe?s.jsxs(Ae,{disabled:!_e,onClick:ks,className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"window",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]}):null,s.jsx(Et,{}),l?null:s.jsxs(Ae,{className:"[&>svg]:mr-1",onClick:()=>R(G,{archivedBucket:l}),children:[s.jsx(E,{name:"inbox-archive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]}),l?s.jsxs(Ae,{className:"[&>svg]:mr-1",onClick:()=>K(G),children:[s.jsx(E,{name:"inbox-unarchive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.restore")]}):null,s.jsxs(Ae,{className:"text-destructive focus:text-destructive [&>svg]:mr-1",onClick:()=>R(G,{archivedBucket:l,hardDelete:!0}),children:[s.jsx(E,{name:"delete-bin",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})]}),$m=s.jsx(Ys,{align:"end",className:"min-w-[180px]",finalFocus:()=>ye.current?(ye.current=!1,!1):!ve.current,children:Qa({Item:Wt,Separator:Es,Sub:Eh,SubTrigger:Mh,SubContent:Oh})}),Wm=s.jsx(Vi,{children:s.jsx(Ui,{className:"app-region-no-drag z-50",children:s.jsx(Ki,{"data-slot":"dropdown-menu-content",finalFocus:()=>ye.current?(ye.current=!1,!1):!ve.current,style:{color:"var(--surface-elevated-foreground)"},className:Re(Ai,"min-w-[180px]"),children:Qa({Item:({className:Ae,...Et})=>s.jsx(mu,{className:Re(xd,Ae),...Et}),Separator:({className:Ae,...Et})=>s.jsx(uu,{className:Re(gd,Ae),...Et}),Sub:Dg,SubTrigger:({className:Ae,children:Et,...Gt})=>s.jsxs(Tg,{className:Re(Rh,Ae),...Gt,children:[Et,s.jsx(E,{name:"arrow-right-s",className:"ml-auto size-3.5"})]}),SubContent:({className:Ae,children:Et,...Gt})=>s.jsx(Vi,{children:s.jsx(Ui,{className:"app-region-no-drag z-50",children:s.jsx(Ki,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:Re(Ai,Ae),...Gt,children:Et})})})})})})});return s.jsxs(c.Fragment,{children:[s.jsx(ej,{sessionId:G.id,sessionDirectory:_e??null,sessionTitle:Qt,children:s.jsxs(hu,{open:Xt,onOpenChange:Ot,onOpenChangeComplete:ft,children:[s.jsxs(fu,{render:s.jsx("div",{"data-session-row":G.id,"data-session-scope":tt??"","data-session-archived":l?"1":"0","aria-current":ge?"page":void 0,onClick:Bm,style:{paddingLeft:Pc+r*mo},className:Re("group relative my-0.5 flex cursor-pointer items-center rounded-md py-1 pr-1.5",ge&&!ze&&"bg-primary/10",ze&&"bg-interactive-selection")}),children:[We,Le,s.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onPointerDown:_m,onPointerUp:qa,onPointerCancel:qa,onMouseDown:Fm,onClick:Ae=>Ga(Ae),onDoubleClick:Ae=>{Ae.stopPropagation(),S(G.id,Qt)},className:Re("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-primary/50 text-foreground select-none transition-[padding]",Ce&&"bg-interactive-hover/70",I?se?ne:pe:ne),children:s.jsxs("div",{className:"flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden",children:[s.jsx("div",{className:Re("block min-w-0 flex-1 truncate typography-ui-label font-normal",ge?"text-primary":ct?"text-foreground":"text-foreground/80"),children:yo(Qt,h)}),I?s.jsx("span",{className:"ml-2 inline-flex flex-shrink-0 items-center gap-1 typography-micro text-muted-foreground/75",children:ms?s.jsx(Cl,{sessionId:G.id,running:wt}):s.jsxs(s.Fragment,{children:[Vt,ce?s.jsx(E,{name:"git-branch",className:Re("h-3 w-3",!Ne&&"text-muted-foreground/60"),style:Ne?{color:Ne}:void 0}):null,st]})}):ms||Vt||ce||T==="recent"?s.jsx("div",{className:"relative ml-1 flex h-4 flex-shrink-0 items-center justify-end",children:s.jsx("span",{className:Re("inline-flex items-center gap-1 whitespace-nowrap text-right transition-opacity duration-150",js?"opacity-0":ee),children:ms?s.jsx(Cl,{sessionId:G.id,running:wt,className:"typography-micro"}):s.jsxs(s.Fragment,{children:[Vt,ce?s.jsx(E,{name:"git-branch",className:Re("h-3 w-3",!Ne&&"text-muted-foreground/60"),style:Ne?{color:Ne}:void 0}):null,T==="recent"?s.jsx("span",{className:"flex-shrink-0 typography-micro leading-none text-muted-foreground/75 tabular-nums",children:st}):null]})})}):null,Ws>0?s.jsxs("span",{className:Re("inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0",us),title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[s.jsx(E,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Ws})]}):null,Ee>0?s.jsxs("span",{className:Re("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",us),title:cn,"aria-label":cn,children:[s.jsx(E,{name:"question",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Ee})]}):null]})})}),se?null:s.jsx(yt,{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:Qt}),s.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:jt,children:st})]}),Fe?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(E,{name:"folder",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 truncate",children:Fe})]}):null,Se?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(E,{name:"git-branch",className:"h-3 w-3 flex-shrink-0",style:Ne?{color:Ne}:void 0}),s.jsx("span",{className:"min-w-0 truncate",children:Se})]}):null,Pe&&be?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(E,{name:"git-pull-request",className:"h-3 w-3 flex-shrink-0",style:Ne?{color:Ne}:void 0}),s.jsxs("span",{className:"min-w-0 truncate",style:Ne?{color:Ne}:void 0,children:["#",Pe.number," · ",be]})]}):null]})})]})}),Je&&!O?s.jsx("div",{className:"absolute right-0 top-1/2 -translate-y-1/2 z-10",children:Je}):null,s.jsxs("div",{className:Re("absolute right-0 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",js||I&&!se?"opacity-100":Re("opacity-0",le)),children:[W?s.jsx(Gj,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:I?"h-6 w-6":"h-4 w-4",iconSizeClass:I?"h-3.5 w-3.5":"h-2.5 w-2.5",onPointerDown:yn,onMouseDown:ii,onArchive:sr,onDelete:Rm}):null,ue?s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",className:Re("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-primary/50 transition-opacity",I?"h-6 w-6":"h-4 w-4"),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:Em,onMouseDown:Mm,onClick:Om,onKeyDown:Ae=>Ae.stopPropagation(),children:s.jsx(E,{name:"external-link",className:Re(I?"h-3.5 w-3.5":"h-2.5 w-2.5")})})}),s.jsx(yt,{side:"left",sideOffset:8,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,s.jsxs(Xs,{open:Lt,onOpenChange:mt,onOpenChangeComplete:ft,children:[s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button",className:Re("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-primary/50 transition-opacity",I?"h-6 w-6 opacity-100":js?"h-4 w-4 opacity-100":Re("h-4 w-4 opacity-0",le)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:Ht,onMouseDown:en,onClick:ss,onKeyDown:Ae=>Ae.stopPropagation(),children:s.jsx(E,{name:"more-2",className:Re(I?"h-3.5 w-3.5":"h-2.5 w-2.5")})})}),$m]})]})]}),Wm]})}),Ut&&$t?F:null,s.jsx(Ss,{open:at,onOpenChange:gt,children:s.jsxs(vs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Ls,{children:[s.jsx(Ts,{children:e("sessions.sidebar.session.export.dialog.title")}),s.jsx(Is,{children:As===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:As}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:As})})]}),s.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:Pt,onChange:Ae=>Ge(Ae.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),s.jsxs(xn,{children:[s.jsx(ot,{type:"button",onClick:()=>gt(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),s.jsx(ot,{type:"button",onClick:()=>{gt(!1),ln(Pt)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})}),ns?s.jsx(Lj,{session:ie,open:Js,onOpenChange:rs}):null]},G.id)}const Dc=t=>dt(t.session.directory??null),Qj=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null),Yj=t=>{if(!t.openSidebarMenuKey)return null;const e=t.archivedBucket?"archived":"active",n=`${t.renderContext??"project"}:${e}:`;return t.openSidebarMenuKey.startsWith(n)?t.openSidebarMenuKey.slice(n.length):null},Tc=t=>t.menuOpenSessionId??Yj(t),fo=(t,e,n)=>e?n.has(t.node.session.id)?!0:Gn(t.node,e):!1,da=(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(da(t.children[l],e.children[l],n,r,i))return!0;return!1},Xj=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const n=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return da(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${t.renderContext??"project"}:${n}:${i.session.id}`)||da(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${e.renderContext??"project"}:${r}:${i.session.id}`)},Jj=(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,Zj=(t,e)=>{if(t.node.session.id!==e.node.session.id||!Jj(t.node.session,e.node.session)||!Kj(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(Dc(t.node)!==Dc(e.node))return"nodeDirectory";if(!Qj(t.secondaryMeta,e.secondaryMeta))return"secondaryMeta";if(t.pinnedSessionIds!==e.pinnedSessionIds&&mm(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory))return"pinnedSessionIds";if(t.expandedParents!==e.expandedParents&&Xj(t,e))return"expandedParents";if(t.editingId!==e.editingId&&(fo(t,t.editingId,t.subtreeContainsEditing)||fo(e,e.editingId,e.subtreeContainsEditing)))return"editingId";if(t.editTitle!==e.editTitle&&(fo(t,t.editingId,t.subtreeContainsEditing)||fo(e,e.editingId,e.subtreeContainsEditing)))return"editTitle";if(t.copiedSessionId!==e.copiedSessionId&&(Gn(t.node,t.copiedSessionId)||Gn(e.node,e.copiedSessionId)))return"copiedSessionId";if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const r=Tc(t),i=Tc(e);if(Gn(t.node,r)||Gn(e.node,i))return"openSidebarMenuKey"}return t.setEditingId===e.setEditingId&&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"},e2=(t,e)=>{const n=Zj(t,e);return n===null?!0:(Gs(`ui.sidebar_session_node.props_changed.${n}`),!1)},t2=c.memo(qj,e2);function s2(t){return t.stopPropagation()}const n2=t=>{const{t:e}=pt(),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=Te(re=>re.setSessionSwitcherOpen),a=Qe(re=>re.setCurrentSession),u=Qe(re=>re.updateSessionTitle),d=Qe(re=>re.shareSession),h=Qe(re=>re.unshareSession),f=Qe(re=>re.deleteSession),g=Qe(re=>re.deleteSessions),p=Qe(re=>re.archiveSession),w=Qe(re=>re.archiveSessions),v=Qe(re=>re.unarchiveSession),{mobileVariant:x,allowReselect:m,onSessionSelected:b,isSessionSearchOpen:y,sessionSearchQuery:S,setSessionSearchQuery:N,setIsSessionSearchOpen:C,descendantIds:k,showDeletionDialog:A,setDeleteSessionConfirm:P,setEditingId:D,setEditTitle:M,setCopiedSessionId:$}=t;c.useEffect(()=>()=>{n.current&&clearTimeout(n.current)},[]);const R=c.useCallback((re,se)=>{Ni("navigation.session_select"),Te.getState().closeMainSurfaces();const fe=()=>{!y&&S.length===0||(N(""),C(!1))};if(x&&l(!1),re===Qe.getState().currentSessionId){m&&b?.(re),fe();return}Ni("navigation.session_state_set"),a(re,se??null),b?.(re),fe()},[m,y,x,b,S,a,C,N,l]),K=c.useCallback((re,se)=>{D(re),M(se)},[M,D]),L=c.useCallback(async re=>{const se=r.current;if(!se)return;const fe=(re??i.current).trim();fe&&await u(se,fe),D(null),M("")},[M,D,u]),O=c.useCallback(()=>{D(null),M("")},[M,D]),I=c.useCallback(async(re,se)=>{try{return(await hn(re)).ok?($(se),n.current&&clearTimeout(n.current),n.current=window.setTimeout(()=>{$(null),n.current=null},2e3),!0):!1}catch{return!1}},[$]),j=c.useCallback(async re=>{const se=await d(re.id);if(!se?.share?.url){Be.error(e("sessions.sidebar.session.share.error"));return}const fe=await I(se.share.url,re.id);Be[fe?"success":"warning"](e("sessions.sidebar.session.share.successTitle"),{description:e(fe?"sessions.sidebar.session.share.successDescription":"sessions.sidebar.session.share.copyUrlError")})},[I,d,e]),T=c.useCallback((re,se)=>{I(re,se).then(fe=>{fe||Be.error(e("sessions.sidebar.session.share.copyUrlError"))})},[I,e]),F=c.useCallback(re=>{hn(re).then(se=>{if(se.ok){Be.success(e("sessions.sidebar.session.copyId.success"));return}Be.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Be.error(e("sessions.sidebar.session.copyId.error")))},[e]),U=c.useCallback(async re=>{await h(re)?Be.success(e("sessions.sidebar.session.unshare.success")):Be.error(e("sessions.sidebar.session.unshare.error"))},[e,h]),H=c.useCallback(async(re,se,fe)=>{const _=se?.archivedBucket===!0||se?.hardDelete===!0,le=fe?.descendantIds??k;if(le.length===0){(_?await f(re.id):await p(re.id))?Be.success(e(_?"sessions.sidebar.session.delete.success":"sessions.sidebar.session.archive.success")):Be.error(e(_?"sessions.sidebar.session.delete.error":"sessions.sidebar.session.archive.error"));return}const ee=[re.id,...le];if(_){const{deletedIds:ne,failedIds:pe}=await g(ee);if(pe.length===0){const xe=ne.length;Be.success(xe===1?e("sessions.sidebar.bulkActions.deletedSingle",{count:xe}):e("sessions.sidebar.bulkActions.deletedPlural",{count:xe}))}else Be.error(e("sessions.sidebar.session.delete.error"));return}const{archivedIds:ue,failedIds:W}=await w(ee);ue.length>0&&Be.success(ue.length===1?e("sessions.sidebar.bulkActions.archivedSingle",{count:ue.length}):e("sessions.sidebar.bulkActions.archivedPlural",{count:ue.length})),W.length>0&&Be.error(W.length===1?e("sessions.sidebar.bulkActions.failedArchiveSingle",{count:W.length}):e("sessions.sidebar.bulkActions.failedArchivePlural",{count:W.length}))},[p,w,f,g,k,e]),Y=c.useCallback((re,se)=>{const fe=se?.archivedBucket===!0||se?.hardDelete===!0,_=[...k];if(!A||se?.skipConfirm===!0){H(re,se,{descendantIds:_});return}P({session:re,descendantCount:_.length,descendantIds:_,archivedBucket:fe})},[k,H,P,A]),me=c.useCallback(async()=>{const re=o.current;if(!re)return;const{session:se,archivedBucket:fe,descendantIds:_}=re;P(null),await H(se,{archivedBucket:fe},{descendantIds:_})},[H,P]),Z=c.useCallback(async re=>{await v(re.id)?Be.success(e("sessions.sidebar.session.restore.success")):Be.error(e("sessions.sidebar.session.restore.error"))},[e,v]);return c.useMemo(()=>({handleSessionSelect:R,handleSessionDoubleClick:K,handleSaveEdit:L,handleCancelEdit:O,handleShareSession:j,handleCopyShareUrl:T,handleCopySessionId:F,handleUnshareSession:U,handleDeleteSession:Y,handleRestoreSession:Z,confirmDeleteSession:me}),[O,F,T,Y,Z,L,K,R,j,U,me])};function r2(t){const e=Xe.c(71),{t:n}=pt(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t;let u,d,h,f,g,p,w,v,x,m;if(e[0]!==i||e[1]!==n||e[2]!==r){const T=n("sessions.sidebar.session.untitled");f=Ss,x=!!r,e[13]!==i?(m=U=>{U||i(null)},e[13]=i,e[14]=m):m=e[14],h=vs,w=!1,v="max-w-sm gap-5",d=Ls;let F;e[15]!==n||e[16]!==r?.archivedBucket?(F=r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.title"):n("sessions.sidebar.dialogs.archiveSession.title"),e[15]=n,e[16]=r?.archivedBucket,e[17]=F):F=e[17],e[18]!==F?(p=s.jsx(Ts,{children:F}),e[18]=F,e[19]=p):p=e[19],u=Is,g=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||T,count:r.descendantCount}):n("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||T,count:r.descendantCount}):r.descendantCount===1?n("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||T,count:r.descendantCount}):n("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||T,count:r.descendantCount}):r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||T}):n("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||T}),e[0]=i,e[1]=n,e[2]=r,e[3]=u,e[4]=d,e[5]=h,e[6]=f,e[7]=g,e[8]=p,e[9]=w,e[10]=v,e[11]=x,e[12]=m}else u=e[3],d=e[4],h=e[5],f=e[6],g=e[7],p=e[8],w=e[9],v=e[10],x=e[11],m=e[12];let b;e[20]!==u||e[21]!==g?(b=s.jsx(u,{children:g}),e[20]=u,e[21]=g,e[22]=b):b=e[22];let y;e[23]!==d||e[24]!==p||e[25]!==b?(y=s.jsxs(d,{children:[p,b]}),e[23]=d,e[24]=p,e[25]=b,e[26]=y):y=e[26];let S;e[27]!==l||e[28]!==o?(S=()=>l(!o),e[27]=l,e[28]=o,e[29]=S):S=e[29];const N=!o;let C;e[30]!==o?(C=o?s.jsx(E,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(E,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[30]=o,e[31]=C):C=e[31];let k;e[32]!==n?(k=n("sessions.sidebar.dialogs.neverAsk"),e[32]=n,e[33]=k):k=e[33];let A;e[34]!==C||e[35]!==k||e[36]!==S||e[37]!==N?(A=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-primary/50","aria-pressed":N,children:[C,k]}),e[34]=C,e[35]=k,e[36]=S,e[37]=N,e[38]=A):A=e[38];let P;e[39]!==i?(P=()=>i(null),e[39]=i,e[40]=P):P=e[40];let D;e[41]!==n?(D=n("sessions.sidebar.dialogs.cancel"),e[41]=n,e[42]=D):D=e[42];let M;e[43]!==P||e[44]!==D?(M=s.jsx("button",{type:"button",onClick:P,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-primary/50",children:D}),e[43]=P,e[44]=D,e[45]=M):M=e[45];let $;e[46]!==a?($=()=>{a()},e[46]=a,e[47]=$):$=e[47];let R;e[48]!==n||e[49]!==r?.archivedBucket?(R=r?.archivedBucket?n("sessions.sidebar.bulkActions.delete"):n("sessions.sidebar.bulkActions.archive"),e[48]=n,e[49]=r?.archivedBucket,e[50]=R):R=e[50];let K;e[51]!==$||e[52]!==R?(K=s.jsx("button",{type:"button",onClick:$,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:R}),e[51]=$,e[52]=R,e[53]=K):K=e[53];let L;e[54]!==M||e[55]!==K?(L=s.jsxs("div",{className:"flex items-center gap-2",children:[M,K]}),e[54]=M,e[55]=K,e[56]=L):L=e[56];let O;e[57]!==A||e[58]!==L?(O=s.jsxs(xn,{className:"w-full sm:items-center sm:justify-between",children:[A,L]}),e[57]=A,e[58]=L,e[59]=O):O=e[59];let I;e[60]!==h||e[61]!==w||e[62]!==O||e[63]!==v||e[64]!==y?(I=s.jsxs(h,{showCloseButton:w,className:v,children:[y,O]}),e[60]=h,e[61]=w,e[62]=O,e[63]=v,e[64]=y,e[65]=I):I=e[65];let j;return e[66]!==f||e[67]!==I||e[68]!==x||e[69]!==m?(j=s.jsx(f,{open:x,onOpenChange:m,children:I}),e[66]=f,e[67]=I,e[68]=x,e[69]=m,e[70]=j):j=e[70],j}function o2(t){const e=Xe.c(57),{t:n}=pt(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t,u=r?.archivedBucket===!0,d=r?.sessionCount??0;let h;e[0]!==u||e[1]!==d||e[2]!==n?(h=n(u?d===1?"sessions.sidebar.dialogs.deleteSession.title":"sessions.sidebar.dialogs.deleteSessions.title":d===1?"sessions.sidebar.dialogs.archiveSession.title":"sessions.sidebar.dialogs.archiveSessions.title"),e[0]=u,e[1]=d,e[2]=n,e[3]=h):h=e[3];const f=h;let g;e[4]!==u||e[5]!==d||e[6]!==n?(g=u?d===1?n("sessions.sidebar.dialogs.deleteSessions.singleDescription",{count:d}):n("sessions.sidebar.dialogs.deleteSessions.pluralDescription",{count:d}):d===1?n("sessions.sidebar.dialogs.archiveSessions.singleDescription",{count:d}):n("sessions.sidebar.dialogs.archiveSessions.pluralDescription",{count:d}),e[4]=u,e[5]=d,e[6]=n,e[7]=g):g=e[7];const p=g,w=!!r;let v;e[8]!==i?(v=j=>{j||i(null)},e[8]=i,e[9]=v):v=e[9];let x;e[10]!==f?(x=s.jsx(Ts,{children:f}),e[10]=f,e[11]=x):x=e[11];let m;e[12]!==p?(m=s.jsx(Is,{children:p}),e[12]=p,e[13]=m):m=e[13];let b;e[14]!==x||e[15]!==m?(b=s.jsxs(Ls,{children:[x,m]}),e[14]=x,e[15]=m,e[16]=b):b=e[16];let y;e[17]!==l||e[18]!==o?(y=()=>l(!o),e[17]=l,e[18]=o,e[19]=y):y=e[19];const S=!o;let N;e[20]!==o?(N=o?s.jsx(E,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(E,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[20]=o,e[21]=N):N=e[21];let C;e[22]!==n?(C=n("sessions.sidebar.dialogs.neverAsk"),e[22]=n,e[23]=C):C=e[23];let k;e[24]!==C||e[25]!==y||e[26]!==S||e[27]!==N?(k=s.jsxs("button",{type:"button",onClick:y,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-primary/50","aria-pressed":S,children:[N,C]}),e[24]=C,e[25]=y,e[26]=S,e[27]=N,e[28]=k):k=e[28];let A;e[29]!==i?(A=()=>i(null),e[29]=i,e[30]=A):A=e[30];let P;e[31]!==n?(P=n("sessions.sidebar.dialogs.cancel"),e[31]=n,e[32]=P):P=e[32];let D;e[33]!==A||e[34]!==P?(D=s.jsx("button",{type:"button",onClick:A,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-primary/50",children:P}),e[33]=A,e[34]=P,e[35]=D):D=e[35];let M;e[36]!==a?(M=()=>{a()},e[36]=a,e[37]=M):M=e[37];let $;e[38]!==u||e[39]!==n?($=n(u?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=u,e[39]=n,e[40]=$):$=e[40];let R;e[41]!==M||e[42]!==$?(R=s.jsx("button",{type:"button",onClick:M,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:$}),e[41]=M,e[42]=$,e[43]=R):R=e[43];let K;e[44]!==D||e[45]!==R?(K=s.jsxs("div",{className:"flex items-center gap-2",children:[D,R]}),e[44]=D,e[45]=R,e[46]=K):K=e[46];let L;e[47]!==k||e[48]!==K?(L=s.jsxs(xn,{className:"w-full sm:items-center sm:justify-between",children:[k,K]}),e[47]=k,e[48]=K,e[49]=L):L=e[49];let O;e[50]!==L||e[51]!==b?(O=s.jsxs(vs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[b,L]}),e[50]=L,e[51]=b,e[52]=O):O=e[52];let I;return e[53]!==w||e[54]!==O||e[55]!==v?(I=s.jsx(Ss,{open:w,onOpenChange:v,children:O}),e[53]=w,e[54]=O,e[55]=v,e[56]=I):I=e[56],I}function i2(t){const e=Xe.c(36),{t:n}=pt(),{value:r,setValue:i,onConfirm:o}=t,l=!!r;let a;e[0]!==i?(a=N=>{N||i(null)},e[0]=i,e[1]=a):a=e[1];let u;e[2]!==n?(u=n("sessions.sidebar.dialogs.deleteFolder.title"),e[2]=n,e[3]=u):u=e[3];let d;e[4]!==u?(d=s.jsx(Ts,{children:u}),e[4]=u,e[5]=d):d=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 g;e[11]!==d||e[12]!==f?(g=s.jsxs(Ls,{children:[d,f]}),e[11]=d,e[12]=f,e[13]=g):g=e[13];let p;e[14]!==i?(p=()=>i(null),e[14]=i,e[15]=p):p=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]!==p||e[19]!==w?(v=s.jsx("button",{type:"button",onClick:p,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-primary/50",children:w}),e[18]=p,e[19]=w,e[20]=v):v=e[20];let x;e[21]!==n?(x=n("sessions.sidebar.bulkActions.delete"),e[21]=n,e[22]=x):x=e[22];let m;e[23]!==o||e[24]!==x?(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:x}),e[23]=o,e[24]=x,e[25]=m):m=e[25];let b;e[26]!==m||e[27]!==v?(b=s.jsxs(xn,{children:[v,m]}),e[26]=m,e[27]=v,e[28]=b):b=e[28];let y;e[29]!==b||e[30]!==g?(y=s.jsxs(vs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[g,b]}),e[29]=b,e[30]=g,e[31]=y):y=e[31];let S;return e[32]!==l||e[33]!==a||e[34]!==y?(S=s.jsx(Ss,{open:l,onOpenChange:a,children:y}),e[32]=l,e[33]=a,e[34]=y,e[35]=S):S=e[35],S}const a2=new Set;function Uo(t){const e=Xe.c(142),{node:n,depth:r,groupDirectory:i,projectId:o,archivedBucket:l,secondaryMeta:a,renderContext:u,renderExtras:d,pinnedSessionIds:h,expandedParents:f,hasSessionSearchQuery:g,normalizedSessionSearchQuery:p,notifyOnSubtasks:w,editingId:v,setEditingId:x,editTitle:m,setEditTitle:b,toggleParent:y,openSidebarMenuKey:S,setOpenSidebarMenuKey:N,allowReselect:C,onSessionSelected:k,isSessionSearchOpen:A,sessionSearchQuery:P,setSessionSearchQuery:D,setIsSessionSearchOpen:M,deleteSessionConfirm:$,setDeleteSessionConfirm:R,startFolderRename:K,copiedSessionId:L,setCopiedSessionId:O,startSessionWorktreeMenuLoad:I,mobileVariant:j,alwaysShowActions:T}=t,F=r===void 0?0:r,U=l===void 0?!1:l,H=u===void 0?"project":u,Y=ls(u2),me=ls(d2),Z=Te(c2),re=Te(l2);let se;if(e[0]!==n){se=[];const Ne=B=>B.children.forEach(ce=>{se.push(ce.session.id),Ne(ce)});Ne(n),e[0]=n,e[1]=se}else se=e[1];const fe=se.join(`
|
|
920
|
-
`);let _;e[2]!==fe?(_=fe?fe.split(`
|
|
921
|
-
`):[],e[2]=fe,e[3]=_):_=e[3];const le=_;let ee;e[4]!==Y||e[5]!==K||e[6]!==me?(ee=(Ne,B)=>{if(!Ne)return null;B&&ls.getState().collapsedFolderIds.has(B)&&me(B);const ce=Y(Ne,"New folder",B);return K(Ne,ce),ce},e[4]=Y,e[5]=K,e[6]=me,e[7]=ee):ee=e[7];const ue=ee;let W;e[8]!==C||e[9]!==L||e[10]!==$||e[11]!==le||e[12]!==m||e[13]!==v||e[14]!==A||e[15]!==j||e[16]!==k||e[17]!==P||e[18]!==O||e[19]!==R||e[20]!==b||e[21]!==x||e[22]!==M||e[23]!==D||e[24]!==Z?(W={mobileVariant:j,allowReselect:C,onSessionSelected:k,isSessionSearchOpen:A,sessionSearchQuery:P,setSessionSearchQuery:D,setIsSessionSearchOpen:M,descendantIds:le,showDeletionDialog:Z,setDeleteSessionConfirm:R,deleteSessionConfirm:$,editingId:v,setEditingId:x,editTitle:m,setEditTitle:b,copiedSessionId:L,setCopiedSessionId:O},e[8]=C,e[9]=L,e[10]=$,e[11]=le,e[12]=m,e[13]=v,e[14]=A,e[15]=j,e[16]=k,e[17]=P,e[18]=O,e[19]=R,e[20]=b,e[21]=x,e[22]=M,e[23]=D,e[24]=Z,e[25]=W):W=e[25];const ne=n2(W),pe=d?.childRenderExtrasFor,xe=n.session.directory??i;let Ce;e[26]!==U||e[27]!==o||e[28]!==H||e[29]!==xe?(Ce={groupDirectory:xe,projectId:o,archivedBucket:U,renderContext:H},e[26]=U,e[27]=o,e[28]=H,e[29]=xe,e[30]=Ce):Ce=e[30];const Me=Ce,ve=ne.handleSaveEdit,Ie=ne.handleCancelEdit,ye=ne.handleSessionSelect,q=ne.handleSessionDoubleClick,De=ne.handleShareSession,ke=ne.handleCopyShareUrl,te=ne.handleCopySessionId,he=ne.handleUnshareSession,ae=ne.handleDeleteSession,Q=ne.handleRestoreSession,z=d?.subtreeContainsEditing??a2,G=d?.menuOpenSessionId??null,ie=d?.nodeStructureKey??"",Oe=d?.relativeTimeTick;let Fe;if(e[31]!==C||e[32]!==T||e[33]!==Me||e[34]!==pe||e[35]!==L||e[36]!==$||e[37]!==F||e[38]!==m||e[39]!==v||e[40]!==f||e[41]!==g||e[42]!==A||e[43]!==j||e[44]!==n.children||e[45]!==p||e[46]!==w||e[47]!==k||e[48]!==S||e[49]!==h||e[50]!==P||e[51]!==O||e[52]!==R||e[53]!==b||e[54]!==x||e[55]!==M||e[56]!==N||e[57]!==D||e[58]!==K||e[59]!==I||e[60]!==y){let Ne;e[62]!==C||e[63]!==T||e[64]!==Me||e[65]!==pe||e[66]!==L||e[67]!==$||e[68]!==F||e[69]!==m||e[70]!==v||e[71]!==f||e[72]!==g||e[73]!==A||e[74]!==j||e[75]!==p||e[76]!==w||e[77]!==k||e[78]!==S||e[79]!==h||e[80]!==P||e[81]!==O||e[82]!==R||e[83]!==b||e[84]!==x||e[85]!==M||e[86]!==N||e[87]!==D||e[88]!==K||e[89]!==I||e[90]!==y?(Ne=B=>s.jsx(Uo,{node:B,pinnedSessionIds:h,expandedParents:f,hasSessionSearchQuery:g,normalizedSessionSearchQuery:p,notifyOnSubtasks:w,editingId:v,setEditingId:x,editTitle:m,copiedSessionId:L,setEditTitle:b,toggleParent:y,openSidebarMenuKey:S,setOpenSidebarMenuKey:N,allowReselect:C,onSessionSelected:k,isSessionSearchOpen:A,sessionSearchQuery:P,setSessionSearchQuery:D,setIsSessionSearchOpen:M,deleteSessionConfirm:$,setDeleteSessionConfirm:R,startFolderRename:K,setCopiedSessionId:O,startSessionWorktreeMenuLoad:I,mobileVariant:j,alwaysShowActions:T,depth:F+1,...Me,renderExtras:pe?.(B)},B.session.id),e[62]=C,e[63]=T,e[64]=Me,e[65]=pe,e[66]=L,e[67]=$,e[68]=F,e[69]=m,e[70]=v,e[71]=f,e[72]=g,e[73]=A,e[74]=j,e[75]=p,e[76]=w,e[77]=k,e[78]=S,e[79]=h,e[80]=P,e[81]=O,e[82]=R,e[83]=b,e[84]=x,e[85]=M,e[86]=N,e[87]=D,e[88]=K,e[89]=I,e[90]=y,e[91]=Ne):Ne=e[91],Fe=n.children.map(Ne),e[31]=C,e[32]=T,e[33]=Me,e[34]=pe,e[35]=L,e[36]=$,e[37]=F,e[38]=m,e[39]=v,e[40]=f,e[41]=g,e[42]=A,e[43]=j,e[44]=n.children,e[45]=p,e[46]=w,e[47]=k,e[48]=S,e[49]=h,e[50]=P,e[51]=O,e[52]=R,e[53]=b,e[54]=x,e[55]=M,e[56]=N,e[57]=D,e[58]=K,e[59]=I,e[60]=y,e[61]=Fe}else Fe=e[61];let Se;e[92]!==T||e[93]!==U||e[94]!==L||e[95]!==ue||e[96]!==F||e[97]!==m||e[98]!==v||e[99]!==f||e[100]!==i||e[101]!==g||e[102]!==j||e[103]!==n||e[104]!==p||e[105]!==w||e[106]!==S||e[107]!==h||e[108]!==o||e[109]!==H||e[110]!==a||e[111]!==ne.handleCancelEdit||e[112]!==ne.handleCopySessionId||e[113]!==ne.handleCopyShareUrl||e[114]!==ne.handleDeleteSession||e[115]!==ne.handleRestoreSession||e[116]!==ne.handleSaveEdit||e[117]!==ne.handleSessionDoubleClick||e[118]!==ne.handleSessionSelect||e[119]!==ne.handleShareSession||e[120]!==ne.handleUnshareSession||e[121]!==b||e[122]!==x||e[123]!==N||e[124]!==I||e[125]!==z||e[126]!==G||e[127]!==ie||e[128]!==Oe||e[129]!==Fe||e[130]!==y?(Se=s.jsx(t2,{expandedParents:f,hasSessionSearchQuery:g,normalizedSessionSearchQuery:p,notifyOnSubtasks:w,editingId:v,setEditingId:x,editTitle:m,setEditTitle:b,handleSaveEdit:ve,handleCancelEdit:Ie,toggleParent:y,handleSessionSelect:ye,handleSessionDoubleClick:q,handleShareSession:De,copiedSessionId:L,handleCopyShareUrl:ke,handleCopySessionId:te,handleUnshareSession:he,openSidebarMenuKey:S,setOpenSidebarMenuKey:N,createFolderAndStartRename:ue,handleDeleteSession:ae,handleRestoreSession:Q,startSessionWorktreeMenuLoad:I,mobileVariant:j,alwaysShowActions:T,pinnedSessionIds:h,node:n,depth:F,groupDirectory:i,projectId:o,archivedBucket:U,secondaryMeta:a,renderContext:H,subtreeContainsEditing:z,menuOpenSessionId:G,nodeStructureKey:ie,relativeTimeTick:Oe,children:Fe}),e[92]=T,e[93]=U,e[94]=L,e[95]=ue,e[96]=F,e[97]=m,e[98]=v,e[99]=f,e[100]=i,e[101]=g,e[102]=j,e[103]=n,e[104]=p,e[105]=w,e[106]=S,e[107]=h,e[108]=o,e[109]=H,e[110]=a,e[111]=ne.handleCancelEdit,e[112]=ne.handleCopySessionId,e[113]=ne.handleCopyShareUrl,e[114]=ne.handleDeleteSession,e[115]=ne.handleRestoreSession,e[116]=ne.handleSaveEdit,e[117]=ne.handleSessionDoubleClick,e[118]=ne.handleSessionSelect,e[119]=ne.handleShareSession,e[120]=ne.handleUnshareSession,e[121]=b,e[122]=x,e[123]=N,e[124]=I,e[125]=z,e[126]=G,e[127]=ie,e[128]=Oe,e[129]=Fe,e[130]=y,e[131]=Se):Se=e[131];let oe;e[132]!==$||e[133]!==n.session.id||e[134]!==ne.confirmDeleteSession||e[135]!==R||e[136]!==re||e[137]!==Z?(oe=$?.session.id===n.session.id?s.jsx(r2,{value:$,setValue:R,showDeletionDialog:Z,setShowDeletionDialog:re,onConfirm:ne.confirmDeleteSession}):null,e[132]=$,e[133]=n.session.id,e[134]=ne.confirmDeleteSession,e[135]=R,e[136]=re,e[137]=Z,e[138]=oe):oe=e[138];let Pe;return e[139]!==Se||e[140]!==oe?(Pe=s.jsxs(s.Fragment,{children:[Se,oe]}),e[139]=Se,e[140]=oe,e[141]=Pe):Pe=e[141],Pe}function l2(t){return t.setShowDeletionDialog}function c2(t){return t.showDeletionDialog}function d2(t){return t.toggleFolderCollapse}function u2(t){return t.createFolder}const m2=50,f2=28,Ic=[],h2=t=>{const e=Xe.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=dm(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},Tr=(t,e)=>e?t.sessions.some(n=>Gn(n,e)):!1,p2=(t,e,n)=>t.sessions.some(r=>mm(r,r,e,n,t.directory,t.directory)),g2=(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)},x2=(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)},b2=(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&&p2(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.sessionOrderIndex!==e.sessionOrderIndex&&g2(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.expandedParents!==e.expandedParents&&x2(e.group,t.expandedParents,e.expandedParents)||t.editingId!==e.editingId&&(Tr(e.group,t.editingId)||Tr(e.group,e.editingId))||t.editTitle!==e.editTitle&&Tr(e.group,e.editingId)||t.copiedSessionId!==e.copiedSessionId&&(Tr(e.group,t.copiedSessionId)||Tr(e.group,e.copiedSessionId)))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const n=e.group.isArchivedBucket===!0,r=Gr(e.group.sessions,t.openSidebarMenuKey,"project",n),i=Gr(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??dt(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.scrollContainerRef===e.scrollContainerRef&&t.notifyOnSubtasks===e.notifyOnSubtasks&&t.setEditingId===e.setEditingId&&t.setEditTitle===e.setEditTitle&&t.toggleParent===e.toggleParent&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.allowReselect===e.allowReselect&&t.onSessionSelected===e.onSessionSelected&&t.isSessionSearchOpen===e.isSessionSearchOpen&&t.sessionSearchQuery===e.sessionSearchQuery&&t.setSessionSearchQuery===e.setSessionSearchQuery&&t.setIsSessionSearchOpen===e.setIsSessionSearchOpen&&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 y2(t){const{t:e}=pt(),{group:n,groupKey:r,projectId:i,hideGroupLabel:o,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,groupSearchDataByGroup:u,visibleSessionCount:d,sessionBatchSize:h,collapsedGroups:f,hideDirectoryControls:g,showMoreGroupSessions:p,resetGroupSessionLimit:w,mobileVariant:v,alwaysShowActions:x,activeProjectId:m,setActiveProjectIdOnly:b,setSessionSwitcherOpen:y,openNewSessionDraft:S,pinnedSessionIds:N,sessionOrderIndex:C,notifyOnSubtasks:k,onToggleCollapsedGroup:A,dragHandleProps:P,compactBodyPadding:D=!1,scrollContainerRef:M,expandedParents:$,editingId:R,openSidebarMenuKey:K,editTitle:L,copiedSessionId:O,folderRename:I,setFolderRenameDraft:j,clearFolderRename:T}=t,F=ls(Ee=>Ee.toggleFolderCollapse),U=ls(Ee=>Ee.renameFolder),H=ls(Ee=>Ee.deleteFolder),Y=ls(Ee=>Ee.addSessionToFolder),me=Te(Ee=>Ee.showDeletionDialog),[Z,re]=c.useState(null),se=c.useCallback((Ee,Ke)=>{const et=C.get(Ee.session.id),ct=C.get(Ke.session.id);if(et!==void 0||ct!==void 0){if(et===void 0)return 1;if(ct===void 0)return-1;if(et!==ct)return et-ct}return Hd(Ee.session,Ke.session,N,Md)},[N,C]),fe=l?u.get(n):null,_=l?!1:f.has(r),le=c.useMemo(()=>{if(n.isMain||n.isArchivedBucket||o)return null;const Ee=dt(n.directory??null),Ke=n.branch?.trim();return Ee&&Ke?Jo(Ee,Ke):null},[n.branch,n.directory,n.isArchivedBucket,n.isMain,o]),ee=Wd(le),ue=ee?`var(--pr-${ee.visualState})`:void 0,W=Ma(),ne=c.useMemo(()=>{const Ee=n.folderScopes?.map(Ke=>dt(Ke.directory))??[dt(n.directory??null)];return[...new Set(Ee.filter(Ke=>!!Ke))]},[n.directory,n.folderScopes]);c.useSyncExternalStore(c.useCallback(Ee=>ne.length>0?W.subscribeBootstrap(Ee):()=>{},[ne.length,W]),c.useCallback(()=>ne.map(Ee=>`${Ee}\0${W.getBootstrapState(Ee)??""}\0${W.getBootstrapFailure(Ee)??""}`).join(""),[ne,W]),c.useCallback(()=>"",[]));const pe=ne.some(Ee=>{const Ke=W.getBootstrapState(Ee);return Ke==="queued"||Ke==="running"}),xe=ne.find(Ee=>W.getBootstrapState(Ee)==="failed")??null,Ce=xe?W.getBootstrapFailure(xe):void 0,Me=Ce==="os-permission"&&lf(),[ve,Ie]=c.useState(!1),ye=c.useCallback(()=>{xe&&W.requestBootstrap({directory:xe,priority:_?"visible":"expanded",reason:n.isMain?"project-expanded":"worktree-expanded",force:!0})},[W,xe,n.isMain,_]),q=c.useCallback(async()=>{if(!(!xe||!Me||ve)){Ie(!0);try{(await cf(xe)).success&&ye()}finally{Ie(!1)}}},[Me,xe,ve,ye]),De=h??(g?10:5),ke=Math.max(De,d??De),te=l?fe?.groupMatches===!0:!1,he=l,ae=c.useMemo(()=>[...he?fe?.filteredNodes??[]:n.sessions].sort(se),[se,n.sessions,fe?.filteredNodes,he]),Q=n.folderScopeKey??dt(n.directory??null),z=c.useMemo(()=>n.folderScopes&&n.folderScopes.length>0?n.folderScopes:Q?[{scopeKey:Q,directory:n.directory??null}]:[],[Q,n.directory,n.folderScopes]),G=ls(Zn(c.useCallback(Ee=>z.map(({scopeKey:Ke})=>Ee.foldersMap[Ke]??Ic),[z]))),ie=c.useMemo(()=>z.flatMap(({scopeKey:Ee,directory:Ke},et)=>(G[et]??Ic).map(ut=>({folder:ut,scopeKey:Ee,scopeDirectory:Ke}))),[G,z]),Oe=ls(Zn(c.useCallback(Ee=>new Set(G.flatMap(Ke=>Ke.filter(et=>Ee.collapsedFolderIds.has(et.id)).map(et=>et.id))),[G]))),Fe=c.useMemo(()=>{const Ee=new Map,Ke=et=>{et.forEach(ct=>{Ee.set(ct.session.id,ct),ct.children.length>0&&Ke(ct.children)})};return Ke(ae),Ee},[ae]),Se=c.useMemo(()=>ie.map(({folder:Ee,scopeKey:Ke,scopeDirectory:et})=>{const ct=ij(Ee.sessionIds,Fe).sort(se);return{folder:Ee,scopeKey:Ke,scopeDirectory:et,nodes:ct}}),[ie,Fe,se]),oe=c.useMemo(()=>{const Ee=lj(Se.map(({folder:Ke,nodes:et})=>({id:Ke.id,name:Ke.name,parentId:Ke.parentId,nodeCount:et.length})),{archivedBucket:n.isArchivedBucket===!0,searchQuery:l?a:""});return Se.filter(({folder:Ke})=>Ee.has(Ke.id))},[Se,n.isArchivedBucket,l,a]),Pe=R,Ne=K,B=$,ce=c.useMemo(()=>new Set(oe.flatMap(Ee=>Ee.folder.sessionIds)),[oe]),be=c.useMemo(()=>ae.filter(Ee=>!ce.has(Ee.session.id)),[ae,ce]),ge=c.useMemo(()=>{const Ee=new Map(oe.map(Ke=>[Ke.folder.id,Ke]));return aj(oe.map(Ke=>Ke.folder)).map(Ke=>Ee.get(Ke.id)).filter(Ke=>!!Ke)},[oe]),_e=c.useMemo(()=>{const Ee=new Map;return oe.forEach(Ke=>{if(!Ke.folder.parentId)return;const et=Ee.get(Ke.folder.parentId)??[];et.push(Ke),Ee.set(Ke.folder.parentId,et)}),Ee},[oe]),tt=c.useMemo(()=>{const Ee=new Map(oe.map(ct=>[ct.folder.id,ct])),Ke=new Map,et=(ct,ut)=>{const jt=Ke.get(ct);if(jt!==void 0)return jt;if(ut.has(ct))return[];ut.add(ct);const st=Ee.get(ct),Lt=st?[...st.nodes]:[];for(const Xt of _e.get(ct)??[])Lt.push(...et(Xt.folder.id,ut));return Ke.set(ct,Lt),Lt};return oe.forEach(({folder:ct})=>et(ct.id,new Set)),Ke},[oe,_e]),Ue="project",de=c.useMemo(()=>{const Ee=new Set;return oa(ae,Pe,Ee),oe.forEach(({nodes:Ke})=>{oa(Ke,Pe,Ee)}),Ee},[ae,oe,Pe]),X=c.useMemo(()=>{if(!Ne)return null;const Ee=Gr(ae,Ne,Ue,!!n.isArchivedBucket);if(Ee)return Ee;for(const{nodes:Ke}of oe){const et=Gr(Ke,Ne,Ue,!!n.isArchivedBucket);if(et)return et}return null},[Ne,ae,oe,n.isArchivedBucket]),we=c.useCallback(Ee=>{const Ke=new WeakMap,et=ct=>{Ke.set(ct,Vo(ct));for(const ut of ct.children)et(ut)};return Ee.forEach(et),Ke},[]),ze=c.useMemo(()=>we(ae),[we,ae]),Ve=c.useMemo(()=>{const Ee=new WeakMap;return oe.forEach(({nodes:Ke})=>{Ke.forEach(et=>Ee.set(et,Vo(et)))}),Ee},[oe]),He=c.useCallback(Ee=>ze.get(Ee)??Ve.get(Ee)??"",[ze,Ve]),$e=c.useCallback(Ee=>({subtreeContainsEditing:de,menuOpenSessionId:X,nodeStructureKey:He(Ee)}),[de,X,He]),qe=be.length,at=n.isArchivedBucket||l?be:be.slice(0,ke),gt=qe-at.length,Pt=!n.isArchivedBucket&&!l&&qe>De&>===0,Ge=n.isArchivedBucket===!0&&!l&&at.length>=m2,It=n.isArchivedBucket?"archived":"active",kt=Ge&&at.some(Ee=>{if(Ee.children.length===0)return!1;const Ke=`project:${It}:${Ee.session.id}`;return B.has(Ke)}),Mt=c.useRef(null),[Tt,wt]=c.useState(null),[St,vt]=c.useState(0),[,ht]=c.useState(0);c.useEffect(()=>{if(!Ge)return;const Ee=Mt.current;if(!Ee||!globalThis.ResizeObserver)return;const Ke=new ResizeObserver(()=>ht(et=>et+1));return Ke.observe(Ee),()=>Ke.disconnect()},[Ge]),c.useLayoutEffect(()=>{if(!Ge){Tt!==null&&wt(null),St!==0&&vt(0);return}const Ee=Mt.current;if(!Ee)return;let Ke=Tt;const et=M?.current??null;if(et&&et.contains(Ee)){if(Ke=et,Ke!==Tt){wt(Ke);return}}else if(!Ke||!Ke.contains(Ee)){let ut=Ee.parentElement;for(;ut;){const jt=window.getComputedStyle(ut);if(jt.overflowY==="auto"||jt.overflowY==="scroll"){Ke=ut;break}ut=ut.parentElement}if(Ke!==Tt){wt(Ke);return}}if(!Ke)return;const ct=Ee.getBoundingClientRect().top-Ke.getBoundingClientRect().top+Ke.scrollTop;vt(ut=>Math.abs(ut-ct)<1?ut:ct)});const Ze=Ge&&Tt!==null,je=Lg({count:at.length,enabled:Ze,getScrollElement:()=>Tt,initialOffset:()=>Tt?.scrollTop??0,estimateSize:()=>f2,overscan:kt?20:8,scrollMargin:St,getItemKey:Ee=>at[Ee]?.session.id??Ee}),nt=c.useCallback(Ee=>{const Ke=[],et=ct=>{ct.forEach(ut=>{Ke.push(ut.session),ut.children.length>0&&et(ut.children)})};return et(Ee),Ke},[]),lt=c.useMemo(()=>nt(ae),[nt,ae]),Ct=c.useMemo(()=>{if(!n.isArchivedBucket)return new Map;const Ee=new Map,Ke=new Map;for(const{folder:ct}of oe){if(!ct.parentId)continue;const ut=Ke.get(ct.parentId)??[];ut.push(ct.id),Ke.set(ct.parentId,ut)}const et=(ct,ut)=>{if(ut.has(ct))return[];ut.add(ct);const jt=oe.find(({folder:Xt})=>Xt.id===ct),st=jt?nt(jt.nodes):[],Lt=Ke.get(ct)??[];for(const Xt of Lt)st.push(...et(Xt,ut));return st};for(const{folder:ct}of oe)Ee.set(ct.id,et(ct.id,new Set));return Ee},[oe,nt,n.isArchivedBucket]);if(l&&!te&&ge.length===0&&be.length===0)return null;const Ye=!n.isMain&&!!n.branch,it=n.branch&&Bh(n.branch,n.label)?{label:n.branch}:null,Nt=_?s.jsx(W0,{nodes:ae,includeUnreadSubtasks:k}):null,Dt=(Ee,Ke)=>{const{folder:et,scopeKey:ct,scopeDirectory:ut,nodes:jt}=Ee,st=Ct.get(et.id)??[],Lt=I?.folderId===et.id&&I?.scopeKey===ct,Xt=l?!1:Oe.has(et.id),ds=js=>s.jsx(tj,{folderId:et.id,children:(ns,Js)=>s.jsx(V0,{folder:et,displayName:Ke,sessions:jt,isCollapsed:Xt,collapsedActivityState:js,onToggle:()=>F(et.id),onRename:rs=>{U(ct,et.id,rs)},onDelete:()=>{if(n.isArchivedBucket){pn.requestDelete({sessions:st,mode:"session"});return}if(!me){H(ct,et.id);return}const rs=oe.filter(({folder:$s})=>$s.parentId===et.id).length,As=jt.length;re({scopeKey:ct,folderId:et.id,folderName:et.name,subFolderCount:rs,sessionCount:As})},groupDirectory:ut??n.directory,projectId:i,mobileVariant:v,alwaysShowActions:x,isRenaming:Lt,renameDraft:Lt?I?.draft:void 0,onRenameDraftChange:j,onRenameSave:()=>{const rs=I?.draft.trim()??"";rs&&U(ct,et.id,rs),T()},onRenameCancel:T,droppableRef:ns,isDropTarget:Js,depth:0,onNewSession:()=>{i&&i!==m&&b(i),v&&y(!1),S({selectedProjectId:i,directoryOverride:ut??n.directory,targetFolderId:et.id,target:n.draftTarget})},hideActions:!1,archivedBucket:n.isArchivedBucket===!0,children:jt.map(rs=>s.jsx(Uo,{node:rs,pinnedSessionIds:N,expandedParents:$,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,notifyOnSubtasks:k,editingId:R,editTitle:L,copiedSessionId:O,openSidebarMenuKey:K,mobileVariant:v,alwaysShowActions:x,groupDirectory:ut??n.directory,projectId:i,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:de,menuOpenSessionId:X,nodeStructureKey:He(rs),childRenderExtrasFor:$e},setEditingId:t.setEditingId,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,isSessionSearchOpen:t.isSessionSearchOpen,sessionSearchQuery:t.sessionSearchQuery,setSessionSearchQuery:t.setSessionSearchQuery,setIsSessionSearchOpen:t.setIsSessionSearchOpen,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,setCopiedSessionId:t.setCopiedSessionId,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},rs.session.id))})},et.id);return Xt?s.jsx(h2,{nodes:tt.get(et.id)??jt,includeUnreadSubtasks:k,children:ds},et.id):ds(null)},Rt=()=>{const Ee=new Map;for(const ut of oe){const jt=ut.folder.parentId;if(!jt)continue;const st=Ee.get(jt);st?st.push(ut):Ee.set(jt,[ut])}const Ke=[],et=new Set,ct=(ut,jt)=>{if(et.has(ut.folder.id))return;et.add(ut.folder.id);const st=jt?`${jt} / ${ut.folder.name}`:ut.folder.name;Ke.push(Dt(ut,st)),!(!l&&Oe.has(ut.folder.id))&&(Ee.get(ut.folder.id)??[]).forEach(Xt=>ct(Xt,st))};return ge.forEach(ut=>ct(ut,"")),Ke},Vt=!!(!n.isMain&&n.worktree),Qt=x?Vt?"pr-14":"pr-7":Vt?"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",Ut=xe?s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(Ce==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":"sessions.sidebar.group.empty.loadFailed"),Me?s.jsx(ot,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:ve,onClick:()=>{q()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,s.jsx(ot,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:ye,children:e("sessions.sidebar.group.empty.retry")})]}):null,Ft=Ee=>s.jsx(Uo,{node:Ee,pinnedSessionIds:N,expandedParents:$,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,notifyOnSubtasks:k,editingId:R,editTitle:L,copiedSessionId:O,openSidebarMenuKey:K,mobileVariant:v,alwaysShowActions:x,groupDirectory:n.directory,projectId:i,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:de,menuOpenSessionId:X,nodeStructureKey:He(Ee),childRenderExtrasFor:$e},setEditingId:t.setEditingId,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,isSessionSearchOpen:t.isSessionSearchOpen,sessionSearchQuery:t.sessionSearchQuery,setSessionSearchQuery:t.setSessionSearchQuery,setIsSessionSearchOpen:t.setIsSessionSearchOpen,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,setCopiedSessionId:t.setCopiedSessionId,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},Ee.session.id),Yt=s.jsxs(sj,{scopeKey:z[0]?.scopeKey??Q,hasFolders:oe.length>0,onSessionDroppedOnFolder:(Ee,Ke)=>{const et=oe.find(({folder:ut})=>ut.id===Ke);if(!et)return;const ct=ls.getState();for(const{scopeKey:ut}of z)ut!==et.scopeKey&&ct.getSessionFolderId(ut,Ee)&&ct.removeSessionFromFolder(ut,Ee);Y(et.scopeKey,Ke,Ee)},children:[Rt(),Ge?s.jsx("div",{ref:Mt,children:Ze?s.jsx("div",{style:{height:je.getTotalSize(),position:"relative"},children:je.getVirtualItems().map(Ee=>{const Ke=at[Ee.index];return Ke?s.jsx("div",{"data-index":Ee.index,ref:je.measureElement,className:"[&_[data-session-row]]:my-px",style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${Ee.start-St}px)`},children:Ft(Ke)},Ke.session.id):null})}):at.map(Ft)}):at.map(Ft),qe===0&&oe.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"):pe?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(E,{name:"loader-4",className:"size-3 animate-spin"}),e("sessions.sidebar.group.empty.loadingSessions")]}):Ut||(n.emptyMessage??e("sessions.sidebar.group.empty.noSessionsInWorkspace"))}):null,qe>0&&Ut?s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-status-error",children:Ut}):null,gt>0?s.jsx("button",{type:"button",onClick:()=>p(r,at.length,h??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,Pt?s.jsx("button",{type:"button",onClick:()=>w(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]}),$t="pb-2",_t=s.jsx(i2,{value:Z,setValue:re,onConfirm:()=>{const Ee=Z;Ee&&(H(Ee.scopeKey,Ee.folderId),re(null))}});return o?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"oc-group",children:s.jsx("div",{className:Re("oc-group-body",$t),children:Yt})}),_t]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"oc-group",children:[s.jsxs("div",{className:Re("group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md","cursor-pointer"),onClick:()=>A(r),role:"button",tabIndex:0,onKeyDown:Ee=>{(Ee.key==="Enter"||Ee.key===" ")&&(Ee.preventDefault(),A(r))},"aria-label":_?e("sessions.sidebar.group.expandAria",{label:n.label}):e("sessions.sidebar.group.collapseAria",{label:n.label}),"aria-expanded":!_,children:[s.jsx("div",{ref:P?.setActivatorNodeRef,className:Re("min-w-0 flex flex-1 items-start gap-1 overflow-hidden pl-1.5 transition-[padding]",Qt),...P?.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:"text-[14px] 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(E,{name:"archive",className:Re("h-3.5 w-3.5 shrink-0 text-muted-foreground",x?"hidden":"group-hover/gh:hidden")}),s.jsx("span",{className:Re("text-muted-foreground h-3.5 w-3.5 items-center justify-center",x?"inline-flex":"hidden group-hover/gh:inline-flex"),children:_?s.jsx(E,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(E,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:yo(n.label,a)}),Nt]}):!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(E,{name:"git-branch",className:Re("h-3.5 w-3.5 shrink-0",!ue&&"text-muted-foreground",x?"hidden":"group-hover/gh:hidden"),style:ue?{color:ue}:void 0}),s.jsx("span",{className:Re("text-muted-foreground h-3.5 w-3.5 items-center justify-center",x?"inline-flex":"hidden group-hover/gh:inline-flex"),children:_?s.jsx(E,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(E,{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:yo(n.label,a)}),Nt,ee?s.jsxs("span",{className:"ml-auto flex-shrink-0 text-[0.72rem] font-medium leading-none",style:ue?{color:ue}:void 0,children:["#",ee.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:yo(n.label,a)}),Nt]})}),Ye&&it?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[n.isArchivedBucket?s.jsx(E,{name:"archive",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(E,{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:it.label})]}):null]})}),n.isArchivedBucket&<.length>0?s.jsx("div",{className:Re("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",x?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Ee=>{Ee.stopPropagation(),pn.requestDelete({sessions:lt,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-primary/50","aria-label":e("sessions.sidebar.group.actions.deleteArchivedInGroupAria",{label:n.label}),children:s.jsx(E,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(yt,{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:Re("absolute right-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",x?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Ee=>{Ee.stopPropagation(),pn.requestDelete({sessions:lt,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-primary/50","aria-label":e("sessions.sidebar.group.actions.deleteGroupAria",{label:n.label}),children:s.jsx(E,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(yt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteWorktree")})})]})}):null,n.directory?s.jsx("div",{className:Re("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",x?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Ee=>{Ee.stopPropagation(),i&&i!==m&&b(i),v&&y(!1),S({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-primary/50","aria-label":e("sessions.sidebar.group.actions.newDraftInGroupAria",{label:n.label}),children:s.jsx(E,{name:"add",className:"h-4 w-4"})})}),s.jsx(yt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.project.actions.newDraftSession")})})]})}):null]}),_?null:s.jsx("div",{className:Re("oc-group-body",$t),children:Yt})]}),_t]})}const Ao=c.memo(y2,b2),w2=(t,e,n)=>e?t.filter(r=>r.project.id===n):t,S2=t=>t?"top-content":"empty-state",v2=(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[n,...r?[r]:[]].map(o=>({group:o,groupKey:`${t.project.id}:${o.id}`,projectId:t.project.id,hideGroupLabel:o.id===n.id}))},j2=48,k2=32,C2=24,vi=(t,e)=>Ea(t.label?.trim()||Fn(t.normalizedPath,e)||t.normalizedPath);function N2(t){const e=Xe.c(42);Gs("ui.sidebar_projects_list.render");const{t:n}=pt(),{model:r,view:i,actions:o}=t,l=r.state.editingId!==null,a=i.isDesktopShellRuntime&&i.stickyZoneHeaders&&!r.singleProjectMode;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={activationConstraint:{distance:8}},e[0]=u):u=e[0];let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={coordinateGetter:Pg},e[1]=d):d=e[1];const h=zr(On($i,u),On(Ng,d));let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f={activationConstraint:{distance:8}},e[2]=f):f=e[2];const g=zr(On($i,f)),p=c.useRef(null),w=c.useRef(0);let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v=fe=>{const le=fe.scrollTop>1?Math.min(k2+fe.scrollTop,j2):0;w.current=le;const ee=fe.closest(".oc-sticky-fade-root");ee?.style.setProperty("--scroll-shadow-top-size",`${le}px`),ee?.style.setProperty("--scroll-shadow-top-clear-size",`${Math.min(Math.max(le-8,0),C2)}px`)},e[3]=v):v=e[3];const x=v;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=fe=>{fe.target.closest("[data-overlay-scrollbar-thumb], [data-sidebar-sticky-header]")||fe.clientY-fe.currentTarget.getBoundingClientRect().top>=w.current||(fe.preventDefault(),fe.stopPropagation())},e[4]=m):m=e[4];const b=m,y=w2(r.sectionsForRender,r.singleProjectMode,r.singleProjectId),S=r.projectSections.length>0&&y.length>0;let N,C;e[5]!==a||e[6]!==S?(N=()=>{a&&S&&p.current&&x(p.current)},C=[a,S,x],e[5]=a,e[6]=S,e[7]=N,e[8]=C):(N=e[7],C=e[8]),c.useLayoutEffect(N,C);let k=null;for(const fe of r.projectSections)r.stuckProjectHeaders.has(fe.project.id)&&(k=fe.project);const A=k??(r.hasSharedSessions?null:y[0]?.project??null),P=A?vi(A,i.homeDirectory):null;let D;if(e[9]!==r.projectSections||e[10]!==i.homeDirectory){let fe;e[12]!==i.homeDirectory?(fe=_=>({id:_.project.id,projectLabel:vi(_.project,i.homeDirectory),projectDescription:Wr(_.project.normalizedPath,i.homeDirectory),projectIcon:_.project.icon,projectColor:_.project.color,projectIconImage:_.project.iconImage,projectIconBackground:_.project.iconBackground}),e[12]=i.homeDirectory,e[13]=fe):fe=e[13],D=r.projectSections.map(fe),e[9]=r.projectSections,e[10]=i.homeDirectory,e[11]=D}else D=e[11];const M=D;if(r.projectSections.length===0){let fe;return e[14]!==r.emptyState||e[15]!==r.topContent?(fe=s.jsxs(Cn,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:"flex-1 min-h-0",className:"space-y-1 pb-1 pl-2.5 pr-2",children:[r.topContent,r.emptyState]}),e[14]=r.emptyState,e[15]=r.topContent,e[16]=fe):fe=e[16],fe}if(r.sectionsForRender.length===0){const _=S2(r.topContentHasSearchMatches===!0)==="top-content"?r.topContent:r.searchEmptyState;let le;return e[17]!==_?(le=s.jsx(Cn,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:"flex-1 min-h-0",className:"space-y-1 pb-1 pl-2.5 pr-2",children:_}),e[17]=_,e[18]=le):le=e[18],le}const $="oc-sticky-fade-root relative flex min-h-0 flex-1";let R;e[19]!==a?(R=a?{"--scroll-shadow-top-size":"0px"}:void 0,e[19]=a,e[20]=R):R=e[20];const K=a?b:void 0,L=a?b:void 0,O=a?b:void 0,I=Cn,j=!0,T=!a,F=96,U="flex-1 min-h-0",H="oc-sidebar-scroller oc-sticky-fade-scroller space-y-1.5 pb-1 pl-2.5 pr-2 [overflow-anchor:none]";let Y;e[21]!==a?(Y=a?fe=>x(fe.currentTarget):void 0,e[21]=a,e[22]=Y):Y=e[22];const me=i.showOnlyMainWorkspace?s.jsx("div",{className:"space-y-[0.6rem] py-1",children:(()=>{const fe=y.find(le=>le.project.id===r.activeProjectId)??y[0];if(!fe)return i.hasSessionSearchQuery?r.searchEmptyState:r.emptyState;const _=v2(fe);return _.length?_.map(le=>{const{group:ee,groupKey:ue,projectId:W,hideGroupLabel:ne}=le;return s.jsx(c.Fragment,{children:s.jsx(Ao,{...r.groupProps,...o.group,editingId:r.state.editingId,openSidebarMenuKey:r.state.openSidebarMenuKey,setOpenSidebarMenuKey:r.state.setOpenSidebarMenuKey,group:ee,groupKey:ue,projectId:W,hideGroupLabel:ne,visibleSessionCount:r.state.visibleSessionCountByGroup.get(ue),compactBodyPadding:!0,scrollContainerRef:p})},ue)}):s.jsx("div",{className:"py-1 text-left typography-micro text-muted-foreground",children:n("sessions.sidebar.empty.noSessions.title")})})()}):s.jsxs(Vr,{sensors:h,collisionDetection:Ur,onDragEnd:fe=>{if(l||i.projectSortOrder!=="manual")return;const{active:_,over:le}=fe;if(!le||_.id===le.id)return;const ee=r.sectionsForRender.findIndex(W=>W.project.id===_.id),ue=r.sectionsForRender.findIndex(W=>W.project.id===le.id);ee===-1||ue===-1||ee===ue||o.reorderProjects(ee,ue)},children:[s.jsx(Oo,{items:y.map(T2),strategy:zi,children:y.map(fe=>{const _=fe.project,le=_.id,ee=vi(_,i.homeDirectory),ue=Wr(_.normalizedPath,i.homeDirectory),W=r.singleProjectMode?!1:i.collapsedProjects.has(le),ne=r.projectRepoStatus.get(le);return s.jsx(E0,{id:le,disabled:r.singleProjectMode||i.projectSortOrder!=="manual",projectLabel:ee,projectDescription:ue,projectIcon:_.icon,projectColor:_.color,projectIconImage:_.iconImage,projectIconBackground:_.iconBackground,isCollapsed:W,isRepo:!!ne,isDesktopShell:i.isDesktopShellRuntime,hideDirectoryControls:i.hideDirectoryControls,mobileVariant:i.mobileVariant,alwaysShowActions:i.alwaysShowActions,statusIndicator:W?o.renderProjectStatusIndicator?.(le,fe.groups):null,openSidebarMenuKey:r.state.openSidebarMenuKey,setOpenSidebarMenuKey:r.state.setOpenSidebarMenuKey,projectPickerOptions:r.singleProjectMode?M:void 0,onProjectSelect:r.singleProjectMode?o.setSingleProjectId:void 0,onToggle:()=>{r.singleProjectMode||o.toggleProject(le)},onNewSession:()=>{le!==r.activeProjectId&&o.setActiveProjectIdOnly(le),i.mobileVariant&&o.setSessionSwitcherOpen(!1),o.openNewSessionDraft({selectedProjectId:le,directoryOverride:_.normalizedPath})},onNewWorktreeSession:()=>{le!==r.activeProjectId&&o.setActiveProjectIdOnly(le),o.openNewWorktreeDialog()},onManageWorktrees:()=>o.openWorktreesPage(le),onRenameStart:()=>o.openProjectEditDialog(le),onClose:()=>o.removeProject(le),sentinelRef:pe=>{r.projectHeaderSentinelRefs.current.set(le,pe)},showCreateButtons:!0,children:W?null:s.jsx("div",{className:"space-y-0 pt-0.5 pb-0.5",children:(()=>{const pe=fe.groups,xe=pe.find(D2)??null,Ce=xe?pe.filter(Me=>Me.id!==xe.id):pe;return s.jsxs(Vr,{sensors:g,collisionDetection:Ur,onDragEnd:Me=>{if(l)return;const{active:ve,over:Ie}=Me;if(!Ie||ve.id===Ie.id)return;const ye=Ce.findIndex(te=>te.id===ve.id),q=Ce.findIndex(te=>te.id===Ie.id);if(ye===-1||q===-1||ye===q)return;const De=du(Ce,ye,q).map(P2),ke=xe?[xe.id,...De]:De;o.setGroupOrderByProject(te=>{const he=new Map(te);return he.set(le,ke),he})},children:[xe?s.jsx(Ao,{...r.groupProps,...o.group,editingId:r.state.editingId,openSidebarMenuKey:r.state.openSidebarMenuKey,setOpenSidebarMenuKey:r.state.setOpenSidebarMenuKey,group:xe,groupKey:`${le}:${xe.id}`,projectId:le,hideGroupLabel:!0,visibleSessionCount:r.state.visibleSessionCountByGroup.get(`${le}:${xe.id}`),scrollContainerRef:p}):null,s.jsx(Oo,{items:Ce.map(A2),strategy:zi,children:Ce.map(Me=>{const ve=`${le}:${Me.id}`;return s.jsx(O0,{id:Me.id,disabled:l,children:Ie=>s.jsx(Ao,{...r.groupProps,...o.group,editingId:r.state.editingId,openSidebarMenuKey:r.state.openSidebarMenuKey,setOpenSidebarMenuKey:r.state.setOpenSidebarMenuKey,group:Me,groupKey:ve,projectId:le,visibleSessionCount:r.state.visibleSessionCountByGroup.get(ve),dragHandleProps:Ie,scrollContainerRef:p})},Me.id)})}),s.jsx(Wi,{dropAnimation:null})]})})()})},le)})}),s.jsx(Wi,{dropAnimation:null})]});let Z;e[23]!==I||e[24]!==r.topContent||e[25]!==T||e[26]!==Y||e[27]!==me?(Z=s.jsxs(I,{ref:p,useScrollShadow:j,hideTopScrollShadow:T,scrollShadowSize:F,outerClassName:U,className:H,onScroll:Y,children:[r.topContent,me]}),e[23]=I,e[24]=r.topContent,e[25]=T,e[26]=Y,e[27]=me,e[28]=Z):Z=e[28];let re;e[29]!==a||e[30]!==A||e[31]!==P||e[32]!==r.hasSharedSessions||e[33]!==n?(re=a&&(A||r.hasSharedSessions)?s.jsx("div",{className:"oc-sticky-fade-overlay pointer-events-none absolute inset-x-0 top-0 z-30 flex items-center gap-1.5 py-1 pl-4 pr-5","aria-hidden":"true",children:A&&P?s.jsx(Co,{id:A.id,projectLabel:P,projectIcon:A.icon,projectColor:A.color,projectIconImage:A.iconImage,projectIconBackground:A.iconBackground}):s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"history",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground/80"}),s.jsx("span",{className:"truncate text-[14px] font-semibold lowercase text-foreground",children:n("sessions.sidebar.activity.recentTitle")})]})}):null,e[29]=a,e[30]=A,e[31]=P,e[32]=r.hasSharedSessions,e[33]=n,e[34]=re):re=e[34];let se;return e[35]!==K||e[36]!==L||e[37]!==O||e[38]!==Z||e[39]!==re||e[40]!==R?(se=s.jsxs("div",{className:$,style:R,onPointerDownCapture:K,onClickCapture:L,onContextMenuCapture:O,children:[Z,re]}),e[35]=K,e[36]=L,e[37]=O,e[38]=Z,e[39]=re,e[40]=R,e[41]=se):se=e[41],se}function A2(t){return t.id}function P2(t){return t.id}function D2(t){return t.isMain}function T2(t){return t.project.id}const I2=c.memo(N2),ua=new Map,Rc=(t,e)=>{for(const n of t){const r=dt(n??null);r&&!ua.has(r)&&ua.set(r,e)}},Ec=t=>{const e=dt(t??null);return e?ua.get(e)??0:0},ho=t=>!!t.time?.archived,R2=t=>{const{t:e}=pt(),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 u=dt(a.directory??null)??"";return`${(a.title||e("sessions.sidebar.session.untitled")).trim()} ${u}`.toLowerCase()},[e]),o=c.useCallback((a,u)=>u?a.flatMap(d=>{if(Ro([i(d.session)],u))return[d];const f=o(d.children,u);return f.length===0?[]:[{...d,children:f}]}):a,[i]),l=c.useCallback((a,u,d,h,f)=>{const g=dt(u??null),p=_d(a),w=new Map(p.map(O=>[O.id,O])),v=new Map;p.forEach(O=>{const I=O.parentID;if(!I)return;const j=w.get(I);if(!j||ho(j)!==ho(O))return;const T=v.get(I)??[];T.push(O),v.set(I,T)});const x=new Map;d.forEach(O=>{if(O.path){const I=dt(O.path)??O.path;x.set(I,O)}});const m=O=>{const I=dt(O.directory??null),j=t.worktreeMetadata.get(O.id)??null;if(j)return j;if(I){const T=x.get(I)??null;if(T&&I!==g)return T}return null},b=new Set,y=O=>{b.add(O.id);const I=v.get(O.id)??[],j=[];for(const T of I)b.has(T.id)||j.push(y(T));return{session:O,children:j,worktree:m(O)}},S=p.filter(O=>{const I=O.parentID;if(!I)return!0;const j=w.get(I);return j?ho(j)!==ho(O):!0}),N=[],C=O=>{b.has(O.id)||N.push(y(O))};S.forEach(C),p.forEach(C);const k=new Map,A="__archived__",P=O=>{if(O.time?.archived)return A;if(t.isVSCode)return g??"__project_root__";const j=dt(t.worktreeMetadata.get(O.id)?.path??null)??_s(O);return j?j!==g&&x.has(j)?j:j===g?g??"__project_root__":A:A};N.forEach(O=>{const I=P(O.session);k.has(I)||k.set(I,[]),k.get(I)?.push(O)});const D=g??"__project_root__",M=[{id:"root",label:f&&h&&h!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:h}):e("sessions.sidebar.grouping.projectRoot"),branch:h??null,description:g?Wr(g,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:g,folderScopeKey:g,sessions:k.get(D)??[]}],$=new Map;d.forEach(O=>{const I=dt(O.path)??O.path,j=k.get(I)??[],T=j.length>0,F=j.reduce((U,H)=>{const Y=Fh(H.session,t.sessionOrderRanks);return Number.isFinite(Y)?Math.max(U,Y):U},0);$.set(I,{hasActiveSession:T,lastUpdatedAt:F})});const R=[...d].sort((O,I)=>{const j=dt(O.path)??O.path,T=dt(I.path)??I.path,F=$.get(j)??{hasActiveSession:!1,lastUpdatedAt:0},U=$.get(T)??{hasActiveSession:!1,lastUpdatedAt:0};if(F.hasActiveSession!==U.hasActiveSession)return F.hasActiveSession?-1:1;if(F.hasActiveSession&&U.hasActiveSession)return U.lastUpdatedAt-F.lastUpdatedAt;const H=Ec(O.path),Y=Ec(I.path);if(H!==Y)return Y-H;const me=(O.label||O.branch||O.name||O.path||"").toLowerCase(),Z=(I.label||I.branch||I.name||I.path||"").toLowerCase();return me.localeCompare(Z)});(t.isVSCode?[]:R).forEach(O=>{const I=dt(O.path)??O.path,j=n.current.get(I)?.trim()||null,T=O.branch?.trim()||null,U=!!(j&&T&&O.label&&ml(O.label)===ml(T))?j:O.label||O.name||Fn(I,t.homeDirectory)||I;M.push({id:`worktree:${I}`,label:U,branch:j||T,description:Wr(I,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:O,directory:I,folderScopeKey:I,sessions:k.get(I)??[]})});const L=k.get(A)??[];return L.length>0&&M.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&&g?Fd(g):null,sessions:L}),M},[t.homeDirectory,t.worktreeMetadata,t.sessionOrderRanks,t.isVSCode,e]);return{buildGroupSearchText:r,buildSessionSearchText:i,filterSessionNodesForSearch:o,buildGroupedSessions:l}},E2=t=>{const e=Xe.c(10),{enabled:n,isDesktopShellRuntime:r,projectSections:i,projectHeaderSentinelRefs:o}=t,l=n===void 0?!0:n;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Set,e[0]=a):a=e[0];const[u,d]=c.useState(a);let h;e[1]!==l||e[2]!==r||e[3]!==o?(h=()=>{if(!l||!r){d(M2);return}const p=Array.from(o.current.values()).find(O2)?.closest(".oc-sidebar-scroller")??null;if(!p)return;const w=new IntersectionObserver(v=>{d(x=>{const m=new Set(x);let b=!1;for(const y of v){const S=y.target.dataset.projectId;if(!S)continue;const N=y.rootBounds?.top??p.getBoundingClientRect().top,C=!y.isIntersecting&&y.boundingClientRect.top<N;m.has(S)!==C&&(b=!0,C?m.add(S):m.delete(S))}return b?m:x})},{root:p,threshold:0});return o.current.forEach(v=>{v&&w.observe(v)}),()=>w.disconnect()},e[1]=l,e[2]=r,e[3]=o,e[4]=h):h=e[4];let f;return e[5]!==l||e[6]!==r||e[7]!==o||e[8]!==i?(f=[l,r,o,i],e[5]=l,e[6]=r,e[7]=o,e[8]=i,e[9]=f):f=e[9],c.useEffect(h,f),u};function M2(t){return t.size===0?t:new Set}function O2(t){return t!==null}const B2=t=>{const e=Xe.c(51),{selectedCount:n,scopeKey:r,scopeFolders:i,archivedBucket:o,onMoveToFolder:l,onCreateFolderAndMove:a,onRemoveFromFolder:u,canRemoveFromFolder:d,onRestore:h,onDelete:f,onDone:g}=t,{t:p}=pt(),w=!!r&&!o;let v;e[0]!==o||e[1]!==p?(v=p(o?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[0]=o,e[1]=p,e[2]=v):v=e[2];const x=v;let m;e[3]!==n||e[4]!==p?(m=p("sessions.sidebar.bulkActions.selectedCount",{count:n}),e[3]=n,e[4]=p,e[5]=m):m=e[5];let b;e[6]!==m?(b=s.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:m}),e[6]=m,e[7]=b):b=e[7];let y;e[8]!==w||e[9]!==d||e[10]!==a||e[11]!==l||e[12]!==u||e[13]!==i||e[14]!==p?(y=w?s.jsxs(Xs,{children:[s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx(Qs,{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-primary/50","aria-label":p("sessions.sidebar.bulkActions.moveToFolder"),children:s.jsx(E,{name:"folder",className:"h-4 w-4"})})})}),s.jsx(yt,{side:"top",sideOffset:4,children:s.jsx("p",{children:p("sessions.sidebar.bulkActions.moveToFolder")})})]}),s.jsxs(Ys,{align:"end",className:"min-w-[180px]",children:[i.length===0?s.jsx(Wt,{disabled:!0,className:"text-muted-foreground",children:p("sessions.sidebar.folders.none")}):i.map(j=>s.jsx(Wt,{onClick:()=>l(j.id),children:s.jsx("span",{className:"flex-1 truncate",children:j.name})},j.id)),s.jsx(Es,{}),s.jsxs(Wt,{onClick:a,children:[s.jsx(E,{name:"add",className:"mr-1 h-4 w-4"}),p("sessions.sidebar.folders.newFolderEllipsis")]}),d?s.jsxs(Wt,{onClick:u,className:"text-destructive focus:text-destructive",children:[s.jsx(E,{name:"close",className:"mr-1 h-4 w-4"}),p("sessions.sidebar.folders.removeFromFolder")]}):null]})]}):null,e[8]=w,e[9]=d,e[10]=a,e[11]=l,e[12]=u,e[13]=i,e[14]=p,e[15]=y):y=e[15];let S;e[16]!==o||e[17]!==h||e[18]!==p?(S=o?s.jsxs(xt,{children:[s.jsx(bt,{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-primary/50","aria-label":p("sessions.sidebar.bulkActions.restore"),children:s.jsx(E,{name:"inbox-unarchive",className:"h-4 w-4"})})}),s.jsx(yt,{side:"top",sideOffset:4,children:s.jsx("p",{children:p("sessions.sidebar.bulkActions.restore")})})]}):null,e[16]=o,e[17]=h,e[18]=p,e[19]=S):S=e[19];let N;e[20]===Symbol.for("react.memo_cache_sentinel")?(N=Re("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]=N):N=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(E,{name:"delete-bin",className:"h-4 w-4"}),e[21]=C):C=e[21];let k;e[22]!==x||e[23]!==f?(k=s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,className:N,"aria-label":x,children:C})}),e[22]=x,e[23]=f,e[24]=k):k=e[24];let A;e[25]!==x?(A=s.jsx(yt,{side:"top",sideOffset:4,children:s.jsx("p",{children:x})}),e[25]=x,e[26]=A):A=e[26];let P;e[27]!==k||e[28]!==A?(P=s.jsxs(xt,{children:[k,A]}),e[27]=k,e[28]=A,e[29]=P):P=e[29];let D;e[30]!==p?(D=p("sessions.sidebar.header.actions.exitSelection"),e[30]=p,e[31]=D):D=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(E,{name:"close",className:"h-4 w-4"}),e[32]=M):M=e[32];let $;e[33]!==g||e[34]!==D?($=s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:g,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-primary/50","aria-label":D,children:M})}),e[33]=g,e[34]=D,e[35]=$):$=e[35];let R;e[36]!==p?(R=p("sessions.sidebar.header.actions.exitSelection"),e[36]=p,e[37]=R):R=e[37];let K;e[38]!==R?(K=s.jsx(yt,{side:"top",sideOffset:4,children:s.jsx("p",{children:R})}),e[38]=R,e[39]=K):K=e[39];let L;e[40]!==$||e[41]!==K?(L=s.jsxs(xt,{children:[$,K]}),e[40]=$,e[41]=K,e[42]=L):L=e[42];let O;e[43]!==P||e[44]!==L||e[45]!==y||e[46]!==S?(O=s.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[y,S,P,L]}),e[43]=P,e[44]=L,e[45]=y,e[46]=S,e[47]=O):O=e[47];let I;return e[48]!==O||e[49]!==b?(I=s.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-t border-border px-2.5 py-1.5",children:[b,O]}),e[48]=O,e[49]=b,e[50]=I):I=e[50],I},F2=(t,e)=>{if(!t)return[];const n=e(t);return n.length>0?n.map(r=>r.scopeKey):[t]},_2=t=>{const{t:e}=pt(),{isInlineEditing:n,showDeletionDialog:r,foldersMap:i,getFolderScopesForProject:o,addSessionsToFolder:l,removeSessionsFromFolders:a,createFolderAndStartRename:u,archiveSessions:d,unarchiveSessions:h,deleteSessions:f,setBulkDeleteConfirm:g}=t,p=gs(j=>j.enabled),w=gs(j=>j.selectedIds.size),v=w>0,x=gs(j=>j.selectedIds),m=gs(j=>j.scopeKey),b=c.useCallback(()=>{gs.getState().toggleMode()},[]),y=c.useCallback(()=>{gs.getState().disable()},[]),S=c.useMemo(()=>{if(!v||typeof document>"u")return!1;let j=!1,T=!1;for(const F of x){const U=document.querySelectorAll(`[data-session-row="${CSS.escape(F)}"]`);for(const H of U)H.getAttribute("data-session-archived")==="1"?T=!0:j=!0}return T&&!j},[v,x]),N=c.useMemo(()=>{if(m)return m;if(!v||typeof document>"u")return null;for(const j of x){const F=document.querySelector(`[data-session-row="${CSS.escape(j)}"]`)?.getAttribute("data-session-scope");if(F&&F.length>0)return F}return null},[v,x,m]),C=c.useMemo(()=>F2(N,o),[N,o]),k=c.useMemo(()=>C.flatMap(j=>i[j]??[]),[i,C]),A=c.useCallback(j=>{for(const T of C)if((i[T]??[]).some(F=>F.id===j))return T;return null},[i,C]),P=c.useMemo(()=>{if(!v)return!1;for(const j of C)for(const T of i[j]??[])for(const F of T.sessionIds)if(x.has(F))return!0;return!1},[i,C,v,x]),D=c.useCallback((j,T)=>{const F=Array.from(x);for(const U of C)U!==j&&a(U,F);l(j,T,F)},[l,a,x,C]),M=c.useCallback(j=>{if(!v)return;const T=A(j);T&&D(T,j)},[v,D,A]),$=c.useCallback(()=>{const j=C[0];if(!j||!v)return;const T=u(j);T&&D(j,T.id)},[u,v,D,C]),R=c.useCallback(()=>{if(!v)return;const j=Array.from(x);for(const T of C)a(T,j)},[a,x,C,v]),K=c.useCallback(async()=>{const j=Array.from(x);if(j.length!==0){if(S){const{deletedIds:T,failedIds:F}=await f(j);T.length>0&&Be.success(T.length===1?e("sessions.sidebar.bulkActions.deletedSingle",{count:T.length}):e("sessions.sidebar.bulkActions.deletedPlural",{count:T.length})),F.length>0&&Be.error(F.length===1?e("sessions.sidebar.bulkActions.failedDeleteSingle",{count:F.length}):e("sessions.sidebar.bulkActions.failedDeletePlural",{count:F.length}))}else{const{archivedIds:T,failedIds:F}=await d(j);T.length>0&&Be.success(T.length===1?e("sessions.sidebar.bulkActions.archivedSingle",{count:T.length}):e("sessions.sidebar.bulkActions.archivedPlural",{count:T.length})),F.length>0&&Be.error(F.length===1?e("sessions.sidebar.bulkActions.failedArchiveSingle",{count:F.length}):e("sessions.sidebar.bulkActions.failedArchivePlural",{count:F.length}))}gs.getState().clear()}},[d,S,f,x,e]),L=c.useCallback(()=>{if(!v)return;const j=x.size;if(!r){K();return}g({sessionCount:j,archivedBucket:S})},[S,K,x,r,g,v]),O=c.useCallback(async()=>{if(!v||!S)return;const j=Array.from(x),{restoredIds:T,failedIds:F}=await h(j);T.length>0&&Be.success(T.length===1?e("sessions.sidebar.bulkActions.restoredSingle",{count:T.length}):e("sessions.sidebar.bulkActions.restoredPlural",{count:T.length})),F.length>0&&Be.error(F.length===1?e("sessions.sidebar.bulkActions.failedRestoreSingle",{count:F.length}):e("sessions.sidebar.bulkActions.failedRestorePlural",{count:F.length})),gs.getState().clear()},[S,v,x,e,h]),I=c.useCallback(async()=>{g(null),await K()},[K]);return c.useEffect(()=>{if(!p)return;const j=typeof navigator<"u"&&/Macintosh|Mac OS X/.test(navigator.userAgent||""),T=F=>{if(n)return;const U=F.target;if(U&&(U.tagName==="INPUT"||U.tagName==="TEXTAREA"||U.isContentEditable))return;const H=j?F.metaKey:F.ctrlKey;if(F.key==="Escape"){F.preventDefault(),gs.getState().disable();return}if(H&&F.key==="Backspace"){F.preventDefault(),L();return}if(H&&(F.key==="a"||F.key==="A")){const Y=typeof document<"u"?Array.from(document.querySelectorAll("[data-session-row]")):[];if(Y.length===0)return;F.preventDefault();const Z=gs.getState().scopeKey??Y[0]?.getAttribute("data-session-scope")??null,re=fe=>Z?fe.getAttribute("data-session-scope")===Z:!0,se=Y.filter(re).map(fe=>fe.getAttribute("data-session-row")).filter(fe=>typeof fe=="string"&&fe.length>0);if(se.length===0)return;gs.getState().replaceAll(se,Z||null)}};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[L,n,p]),{selectionModeEnabled:p,hasSelection:v,selectedIdsSize:w,bulkScopeIsArchived:S,derivedSelectionScope:N,bulkScopeFolders:k,bulkCanRemoveFromFolder:P,handleToggleSelectionMode:b,handleExitSelectionMode:y,handleBulkMoveToFolder:M,handleBulkCreateFolderAndMove:$,handleBulkRemoveFromFolder:R,handleBulkDelete:L,handleBulkRestore:O,confirmBulkDelete:I}};function L2(t){const e=Xe.c(36),{getFolderScopesForProject:n,isInlineEditing:r,startFolderRename:i}=t,[o,l]=c.useState(null),a=Te(q2),u=Te(G2),d=ls(H2),h=ls(K2),f=ls(U2),g=ls(V2),p=Qe(z2),w=Qe(W2),v=Qe($2);let x;e[0]!==h||e[1]!==i?(x=C=>{const k=h(C,"New folder");return i(C,k),k},e[0]=h,e[1]=i,e[2]=x):x=e[2];let m;e[3]!==f||e[4]!==p||e[5]!==v||e[6]!==d||e[7]!==n||e[8]!==r||e[9]!==g||e[10]!==a||e[11]!==x||e[12]!==w?(m={isInlineEditing:r,showDeletionDialog:a,foldersMap:d,getFolderScopesForProject:n,addSessionsToFolder:f,removeSessionsFromFolders:g,createFolderAndStartRename:x,archiveSessions:p,unarchiveSessions:w,deleteSessions:v,setBulkDeleteConfirm:l},e[3]=f,e[4]=p,e[5]=v,e[6]=d,e[7]=n,e[8]=r,e[9]=g,e[10]=a,e[11]=x,e[12]=w,e[13]=m):m=e[13];const b=_2(m);let y;e[14]!==b.bulkCanRemoveFromFolder||e[15]!==b.bulkScopeFolders||e[16]!==b.bulkScopeIsArchived||e[17]!==b.derivedSelectionScope||e[18]!==b.handleBulkCreateFolderAndMove||e[19]!==b.handleBulkDelete||e[20]!==b.handleBulkMoveToFolder||e[21]!==b.handleBulkRemoveFromFolder||e[22]!==b.handleBulkRestore||e[23]!==b.handleExitSelectionMode||e[24]!==b.hasSelection||e[25]!==b.selectedIdsSize||e[26]!==b.selectionModeEnabled?(y=b.selectionModeEnabled&&b.hasSelection?s.jsx(B2,{selectedCount:b.selectedIdsSize,scopeKey:b.derivedSelectionScope,scopeFolders:b.bulkScopeFolders,archivedBucket:b.bulkScopeIsArchived,onMoveToFolder:b.handleBulkMoveToFolder,onCreateFolderAndMove:b.handleBulkCreateFolderAndMove,onRemoveFromFolder:b.handleBulkRemoveFromFolder,canRemoveFromFolder:b.bulkCanRemoveFromFolder,onRestore:b.handleBulkRestore,onDelete:b.handleBulkDelete,onDone:b.handleExitSelectionMode}):null,e[14]=b.bulkCanRemoveFromFolder,e[15]=b.bulkScopeFolders,e[16]=b.bulkScopeIsArchived,e[17]=b.derivedSelectionScope,e[18]=b.handleBulkCreateFolderAndMove,e[19]=b.handleBulkDelete,e[20]=b.handleBulkMoveToFolder,e[21]=b.handleBulkRemoveFromFolder,e[22]=b.handleBulkRestore,e[23]=b.handleExitSelectionMode,e[24]=b.hasSelection,e[25]=b.selectedIdsSize,e[26]=b.selectionModeEnabled,e[27]=y):y=e[27];let S;e[28]!==b.confirmBulkDelete||e[29]!==o||e[30]!==u||e[31]!==a?(S=s.jsx(o2,{value:o,setValue:l,showDeletionDialog:a,setShowDeletionDialog:u,onConfirm:b.confirmBulkDelete}),e[28]=b.confirmBulkDelete,e[29]=o,e[30]=u,e[31]=a,e[32]=S):S=e[32];let N;return e[33]!==y||e[34]!==S?(N=s.jsxs(s.Fragment,{children:[y,S]}),e[33]=y,e[34]=S,e[35]=N):N=e[35],N}function $2(t){return t.deleteSessions}function W2(t){return t.unarchiveSessions}function z2(t){return t.archiveSessions}function V2(t){return t.removeSessionsFromFolders}function U2(t){return t.addSessionsToFolder}function K2(t){return t.createFolder}function H2(t){return t.foldersMap}function G2(t){return t.setShowDeletionDialog}function q2(t){return t.showDeletionDialog}const Mc=7,Q2=6e4,Y2=()=>{const t=Xe.c(2),[e,n]=c.useState(0);let r,i;return t[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{const o=setInterval(()=>{n(J2)},Q2);return()=>clearInterval(o)},i=[],t[0]=r,t[1]=i):(r=t[0],i=t[1]),c.useEffect(r,i),e};function X2(t){const{sections:e,variant:n="section",initialVisibleCount:r=Mc,batchSize:i=Mc}=t,{t:o}=pt(),{pinnedSessionIds:l}=t,a=as(y=>y.stickyZoneHeaders),[u,d]=c.useState(new Set),[h,f]=c.useState(new Map),g=n==="flat",p=c.useCallback(y=>{f(S=>{if(!S.has(y))return S;const N=new Map(S);return N.delete(y),N})},[]),w=c.useCallback(y=>{p(y),d(S=>{const N=new Set(S);return N.has(y)?N.delete(y):N.add(y),N})},[p]),v=c.useCallback((y,S,N)=>{f(C=>{const k=Math.min(N,S+i),A=new Map(C);return A.set(y,k),A})},[i]),x=Y2(),m=c.useCallback(y=>{const S=new Set;oa(y,t.editingId,S);const N=Gr(y,t.openSidebarMenuKey,"recent",!1),C=new WeakMap,k=P=>{C.set(P,Vo(P)),P.children.forEach(k)};y.forEach(k);const A=P=>({subtreeContainsEditing:S,menuOpenSessionId:N,nodeStructureKey:C.get(P)??"",relativeTimeTick:x,childRenderExtrasFor:A});return P=>({subtreeContainsEditing:S,menuOpenSessionId:N,nodeStructureKey:C.get(P)??"",relativeTimeTick:x,childRenderExtrasFor:A})},[t.editingId,t.openSidebarMenuKey,x]),b=e.filter(y=>y.items.length>0||y.key==="chats");return b.length===0?null:s.jsx("div",{className:Re(g?"space-y-0.5 pb-2":"space-y-2 pb-2"),children:b.map(y=>{const S=u.has(y.key),N=Math.max(r,h.get(y.key)??r),C=y.items.slice(0,N),k=y.items.length-C.length,A=y.key==="chats"&&!!t.renderChatsSection,P=!A&&!g&&y.items.length>r&&k===0,D=m(C.map($=>$.node)),M=$=>s.jsx(Uo,{node:$.node,pinnedSessionIds:l,expandedParents:t.expandedParents,hasSessionSearchQuery:t.hasSessionSearchQuery,normalizedSessionSearchQuery:t.normalizedSessionSearchQuery,notifyOnSubtasks:t.notifyOnSubtasks,editingId:t.editingId,editTitle:t.editTitle,copiedSessionId:t.copiedSessionId,openSidebarMenuKey:t.openSidebarMenuKey,mobileVariant:t.mobileVariant,alwaysShowActions:t.alwaysShowActions,groupDirectory:$.groupDirectory,projectId:$.projectId,secondaryMeta:$.secondaryMeta,renderContext:"recent",renderExtras:D($.node),setEditingId:t.setEditingId,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,isSessionSearchOpen:t.isSessionSearchOpen,sessionSearchQuery:t.sessionSearchQuery,setSessionSearchQuery:t.setSessionSearchQuery,setIsSessionSearchOpen:t.setIsSessionSearchOpen,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,setCopiedSessionId:t.setCopiedSessionId,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},$.node.session.id);return g?s.jsxs("div",{className:"space-y-0.5",children:[C.map(M),k>0?s.jsx("button",{type:"button",onClick:()=>v(y.key,C.length,y.items.length),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:o("sessions.sidebar.group.showMore")}):null]},y.key):s.jsxs("div",{className:"relative space-y-1",children:[s.jsxs("div",{className:Re("relative group/chats","-ml-2.5 -mr-2",a&&"sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":a?"true":void 0,children:[s.jsxs("button",{type:"button",onClick:()=>w(y.key),className:Re("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",y.key==="chats"?"pr-10":"pr-3.5"),"aria-expanded":!S,children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[s.jsx(E,{name:y.key==="chats"?"chat-4":"history",className:Re("h-3.5 w-3.5 text-muted-foreground/80","group-hover:hidden")}),s.jsx("span",{className:"hidden h-3.5 w-3.5 items-center justify-center text-muted-foreground group-hover:inline-flex",children:S?s.jsx(E,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(E,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"text-[14px] font-semibold lowercase text-foreground",children:y.title})]}),y.key==="chats"&&t.onNewChat?s.jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),t.onNewChat?.()},className:Re("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",t.alwaysShowActions?"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":o("sessions.sidebar.header.actions.newSession"),children:s.jsx(E,{name:"add",className:"h-4 w-4"})}):null]}),S?null:s.jsxs("div",{className:Re("space-y-0.5"),children:[A?t.renderChatsSection?.(y.items):C.map(M),!A&&k>0?s.jsx("button",{type:"button",onClick:()=>v(y.key,C.length,y.items.length),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:o("sessions.sidebar.group.showMore")}):null,P?s.jsx("button",{type:"button",onClick:()=>p(y.key),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:o("sessions.sidebar.group.showFewer")}):null]})]},y.key)})})}function J2(t){return t+1}const Z2=t=>{const e=Xe.c(61),{projects:n,availableWorktreesByProject:r,gitBranches:i,homeDirectory:o,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,isDesktopShellRuntime:u,sessions:d,childrenMap:h,pinnedSessionIds:f,recentSessions:g,chatSessions:p,showRecentSection:w}=t,{t:v}=pt();let x;if(e[0]!==r||e[1]!==i||e[2]!==o||e[3]!==n||e[4]!==d){x=new Map;for(const L of d){const O=dt(L.directory??null);if(!O)continue;let I=null,j=-1;for(const H of n){const Y=dt(H.normalizedPath);Y&&(O===Y||O.startsWith(`${Y}/`))&&Y.length>j&&(I=H,j=Y.length)}if(!I)continue;const T=r.get(I.normalizedPath)?.find(H=>dt(H.path)===O),F=Ea(I.label?.trim()||Fn(I.normalizedPath,o)||I.normalizedPath),U=T?.branch?.trim()||i.get(O)?.trim()||null;x.set(L.id,{projectId:I.id,groupDirectory:O,projectLabel:F,branchLabel:U&&U!=="HEAD"&&U!==F?U:null})}e[0]=r,e[1]=i,e[2]=o,e[3]=n,e[4]=d,e[5]=x}else x=e[5];const m=x;let b;e[6]!==m?(b=L=>m.get(L)??null,e[6]=m,e[7]=b):b=e[7];const y=b;let S;e[8]!==h?(S=L=>({session:L,children:(h.get(L.id)??[]).filter(ek).map(tk),worktree:null}),e[8]=h,e[9]=S):S=e[9];const N=S,C=l?a:"";let k;e[10]!==y||e[11]!==N||e[12]!==g||e[13]!==C?(k=ng({sessions:g,getSessionLocation:y,getSessionNode:N,query:C}),e[10]=y,e[11]=N,e[12]=g,e[13]=C,e[14]=k):k=e[14];const A=k;let P;e[15]!==v?(P=v("sessions.sidebar.activity.chatsTitle"),e[15]=v,e[16]=P):P=e[16];let D;if(e[17]!==p||e[18]!==N){let L;e[20]!==N?(L=O=>({node:N(O),projectId:null,groupDirectory:O.directory??null,secondaryMeta:null}),e[20]=N,e[21]=L):L=e[21],D=p.map(L),e[17]=p,e[18]=N,e[19]=D}else D=e[19];let M;e[22]!==P||e[23]!==D?(M={key:"chats",title:P,items:D},e[22]=P,e[23]=D,e[24]=M):M=e[24];let $;e[25]!==A||e[26]!==w||e[27]!==v||e[28]!==M?($=[M,...w?A.map(L=>({...L,title:v("sessions.sidebar.activity.recentTitle")})):[]],e[25]=A,e[26]=w,e[27]=v,e[28]=M,e[29]=$):$=e[29];const R=$;let K;return e[30]!==u||e[31]!==f||e[32]!==t.allowReselect||e[33]!==t.alwaysShowActions||e[34]!==t.copiedSessionId||e[35]!==t.deleteSessionConfirm||e[36]!==t.editTitle||e[37]!==t.editingId||e[38]!==t.expandedParents||e[39]!==t.hasSessionSearchQuery||e[40]!==t.isSessionSearchOpen||e[41]!==t.mobileVariant||e[42]!==t.normalizedSessionSearchQuery||e[43]!==t.notifyOnSubtasks||e[44]!==t.onNewChat||e[45]!==t.onSessionSelected||e[46]!==t.openSidebarMenuKey||e[47]!==t.renderChatsSection||e[48]!==t.sessionSearchQuery||e[49]!==t.setCopiedSessionId||e[50]!==t.setDeleteSessionConfirm||e[51]!==t.setEditTitle||e[52]!==t.setEditingId||e[53]!==t.setIsSessionSearchOpen||e[54]!==t.setOpenSidebarMenuKey||e[55]!==t.setSessionSearchQuery||e[56]!==t.startFolderRename||e[57]!==t.startSessionWorktreeMenuLoad||e[58]!==t.toggleParent||e[59]!==R?(K=s.jsx(X2,{sections:R,variant:"section",isDesktopShellRuntime:u,pinnedSessionIds:f,expandedParents:t.expandedParents,hasSessionSearchQuery:t.hasSessionSearchQuery,normalizedSessionSearchQuery:t.normalizedSessionSearchQuery,notifyOnSubtasks:t.notifyOnSubtasks,editingId:t.editingId,editTitle:t.editTitle,copiedSessionId:t.copiedSessionId,openSidebarMenuKey:t.openSidebarMenuKey,mobileVariant:t.mobileVariant,alwaysShowActions:t.alwaysShowActions,onNewChat:t.onNewChat,renderChatsSection:t.renderChatsSection,setEditingId:t.setEditingId,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,isSessionSearchOpen:t.isSessionSearchOpen,sessionSearchQuery:t.sessionSearchQuery,setSessionSearchQuery:t.setSessionSearchQuery,setIsSessionSearchOpen:t.setIsSessionSearchOpen,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,setCopiedSessionId:t.setCopiedSessionId,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad}),e[30]=u,e[31]=f,e[32]=t.allowReselect,e[33]=t.alwaysShowActions,e[34]=t.copiedSessionId,e[35]=t.deleteSessionConfirm,e[36]=t.editTitle,e[37]=t.editingId,e[38]=t.expandedParents,e[39]=t.hasSessionSearchQuery,e[40]=t.isSessionSearchOpen,e[41]=t.mobileVariant,e[42]=t.normalizedSessionSearchQuery,e[43]=t.notifyOnSubtasks,e[44]=t.onNewChat,e[45]=t.onSessionSelected,e[46]=t.openSidebarMenuKey,e[47]=t.renderChatsSection,e[48]=t.sessionSearchQuery,e[49]=t.setCopiedSessionId,e[50]=t.setDeleteSessionConfirm,e[51]=t.setEditTitle,e[52]=t.setEditingId,e[53]=t.setIsSessionSearchOpen,e[54]=t.setOpenSidebarMenuKey,e[55]=t.setSessionSearchQuery,e[56]=t.startFolderRename,e[57]=t.startSessionWorktreeMenuLoad,e[58]=t.toggleParent,e[59]=R,e[60]=K):K=e[60],K};function ek(t){return!t.time?.archived}function tk(t){return{session:t,children:[],worktree:null}}const bm="oc.sessions.expandedParents.v3",sk=Ba(wr()),nk=()=>{try{const t=globalThis.localStorage.getItem(bm);if(t===null)return new Set;const e=sk.safeParse(JSON.parse(t));return e.success?new Set(e.data):new Set}catch{return new Set}},rk=()=>{const[t,e]=c.useState(nk),n=c.useRef(t);n.current=t;const r=c.useCallback(i=>{const o=_h(n.current,i);n.current=o,e(o);try{globalThis.localStorage.setItem(bm,JSON.stringify([...o]))}catch{}},[]);return{expandedParents:t,toggleParent:r}},ok=5*6e4,ik=[],ak=t=>!t.parentID,lk=t=>{const e=Xe.c(292),{topology:n,view:r,actions:i}=t;let o,l,a,u,d;e[0]!==i?({alwaysShowActions:o,notifyOnSubtasks:l,projectViewActions:a,rowActions:u,...d}=i,e[0]=i,e[1]=o,e[2]=l,e[3]=a,e[4]=u,e[5]=d):(o=e[1],l=e[2],a=e[3],u=e[4],d=e[5]);const h=ls(dk),f=ls(uk),g=ls(mk),p=r.projectView,{getOrderedGroups:w,setGroupOrderByProject:v,toggleGroup:x,toggleProject:m}=a;let b;e[6]!==n.isVSCode||e[7]!==n.knownDirectories?(b={knownDirectories:n.knownDirectories,isVSCode:n.isVSCode,isVisible:!0},e[6]=n.isVSCode,e[7]=n.knownDirectories,e[8]=b):b=e[8];const y=rg(b);let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=new Map,e[9]=S):S=e[9];const[N,C]=c.useState(S);let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=(At,Bt)=>{C(Jt=>new Map(Jt).set(At,Bt+7))},e[10]=k):k=e[10];const A=k;let P;e[11]===Symbol.for("react.memo_cache_sentinel")?(P=At=>{C(Bt=>{if(!Bt.has(At))return Bt;const Jt=new Map(Bt);return Jt.delete(At),Jt})},e[11]=P):P=e[11];const D=P,M=as(fk),$=as(hk),R=as(pk),K=as(gk);let L;e[12]!==n.isVSCode?(L=!n.isVSCode&&!df(),e[12]=n.isVSCode,e[13]=L):L=e[13];const I=L&&$==="single",j=M&&!I;let T;e[14]!==y.pinnedSessionIds||e[15]!==y.rootSessions||e[16]!==y.sessionOrderRanks||e[17]!==j||e[18]!==n.isVSCode?(T={enabled:j,isVSCode:n.isVSCode,pinnedSessionIds:y.pinnedSessionIds,sessionOrderRanks:y.sessionOrderRanks,sessions:y.rootSessions},e[14]=y.pinnedSessionIds,e[15]=y.rootSessions,e[16]=y.sessionOrderRanks,e[17]=j,e[18]=n.isVSCode,e[19]=T):T=e[19];const F=og(T),[U,H]=c.useState(null),[Y,me]=c.useState(""),[Z,re]=c.useState(null),[se,fe]=c.useState(null),[_,le]=c.useState(null),[ee,ue]=c.useState(null);let W;e[20]===Symbol.for("react.memo_cache_sentinel")?(W=(At,Bt)=>{ue({scopeKey:At,folderId:Bt.id,draft:Bt.name})},e[20]=W):W=e[20];const ne=W;let pe;e[21]===Symbol.for("react.memo_cache_sentinel")?(pe=At=>{ue(Bt=>Bt?{...Bt,draft:At}:null)},e[21]=pe):pe=e[21];const xe=pe;let Ce;e[22]===Symbol.for("react.memo_cache_sentinel")?(Ce=()=>ue(null),e[22]=Ce):Ce=e[22];const Me=Ce,{expandedParents:ve,toggleParent:Ie}=rk(),ye=Qe(xk);let q;e[23]!==ye?(q=(At,Bt)=>{At!==Qe.getState().currentSessionId&&ye(At,Bt)},e[23]=ye,e[24]=q):q=e[24];const De=q,ke=zd();let te;e[25]!==y.pinnedSessionIds||e[26]!==y.sessionOrderRanks||e[27]!==n.gitBranches||e[28]!==n.isVSCode||e[29]!==n.worktreeMetadata||e[30]!==r.homeDirectory?(te={homeDirectory:r.homeDirectory,worktreeMetadata:n.worktreeMetadata,pinnedSessionIds:y.pinnedSessionIds,sessionOrderRanks:y.sessionOrderRanks,gitBranches:n.gitBranches,isVSCode:n.isVSCode},e[25]=y.pinnedSessionIds,e[26]=y.sessionOrderRanks,e[27]=n.gitBranches,e[28]=n.isVSCode,e[29]=n.worktreeMetadata,e[30]=r.homeDirectory,e[31]=te):te=e[31];const{buildGroupedSessions:he,filterSessionNodesForSearch:ae,buildGroupSearchText:Q}=R2(te);let z;e[32]!==y.archivedSessions||e[33]!==y.sessions||e[34]!==n.availableWorktreesByProject||e[35]!==n.isVSCode||e[36]!==n.projects?(z=S0(y.sessions,n.projects,n.availableWorktreesByProject,n.isVSCode,y.archivedSessions),e[32]=y.archivedSessions,e[33]=y.sessions,e[34]=n.availableWorktreesByProject,e[35]=n.isVSCode,e[36]=n.projects,e[37]=z):z=e[37];const G=z;let ie;e[38]!==G?(ie={ownership:G},e[38]=G,e[39]=ie):ie=e[39];const{getSessionsForProject:Oe,getArchivedSessionsForProject:Fe}=v0(ie);let Se;e:{if(n.isVSCode){Se=null;break e}let At;e[40]!==y.chatSessions||e[41]!==r.homeDirectory?(At=Lh(r.homeDirectory)??y.chatSessions.map(bk).find(Boolean)??null,e[40]=y.chatSessions,e[41]=r.homeDirectory,e[42]=At):At=e[42];const Bt=At;if(!Bt){Se=null;break e}let Jt;if(e[43]!==Bt||e[44]!==y.chatSessions){const J=[Bt,...y.chatSessions.map(yk).filter(Boolean)];let We;e[46]!==J?(We=new Set(J),e[46]=J,e[47]=We):We=e[47],Jt=Array.from(We).filter(wk).map(Sk),e[43]=Bt,e[44]=y.chatSessions,e[45]=Jt}else Jt=e[45];const ms=Jt;let fs;if(e[48]!==y.chatSessions||e[49]!==y.childrenMap){let J;e[51]!==y.childrenMap?(J=We=>({session:We,children:(y.childrenMap.get(We.id)??[]).filter(jk).map(kk),worktree:null}),e[51]=y.childrenMap,e[52]=J):J=e[52],fs=y.chatSessions.filter(vk).map(J),e[48]=y.chatSessions,e[49]=y.childrenMap,e[50]=fs}else fs=e[50];let Ps;e[53]!==Bt||e[54]!==ms||e[55]!==fs?(Ps={id:"managed-chats",label:"",branch:null,description:null,isMain:!0,worktree:null,directory:Bt,folderScopeKey:Bt,folderScopes:ms,draftTarget:"chat",sessions:fs},e[53]=Bt,e[54]=ms,e[55]=fs,e[56]=Ps):Ps=e[56],Se=Ps}const oe=Se;let Pe;e[57]!==oe?(Pe=oe?[oe]:ik,e[57]=oe,e[58]=Pe):Pe=e[58];const Ne=Pe;let B;e[59]!==Q||e[60]!==he||e[61]!==ae||e[62]!==h||e[63]!==Fe||e[64]!==Oe||e[65]!==Ne||e[66]!==n.availableWorktreesByProject||e[67]!==n.gitBranches||e[68]!==n.lastRepoStatus||e[69]!==n.projectRepoStatus||e[70]!==n.projectRootBranches||e[71]!==n.projects||e[72]!==r.hasSessionSearchQuery||e[73]!==r.normalizedSessionSearchQuery?(B={normalizedProjects:n.projects,getSessionsForProject:Oe,getArchivedSessionsForProject:Fe,availableWorktreesByProject:n.availableWorktreesByProject,projectRepoStatus:n.projectRepoStatus,projectRootBranches:n.projectRootBranches,gitBranches:n.gitBranches,lastRepoStatus:n.lastRepoStatus,buildGroupedSessions:he,hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,filterSessionNodesForSearch:ae,buildGroupSearchText:Q,foldersMap:h,standaloneGroups:Ne},e[59]=Q,e[60]=he,e[61]=ae,e[62]=h,e[63]=Fe,e[64]=Oe,e[65]=Ne,e[66]=n.availableWorktreesByProject,e[67]=n.gitBranches,e[68]=n.lastRepoStatus,e[69]=n.projectRepoStatus,e[70]=n.projectRootBranches,e[71]=n.projects,e[72]=r.hasSessionSearchQuery,e[73]=r.normalizedSessionSearchQuery,e[74]=B):B=e[74];const{projectSections:ce,groupSearchDataByGroup:be,sectionsForRender:ge,flatSectionsForRender:_e,searchMatchCount:tt}=C0(B),Ue=r.onSearchMatchCountChange;let de,X;e[75]!==Ue||e[76]!==tt?(de=()=>{Ue(tt)},X=[Ue,tt],e[75]=Ue,e[76]=tt,e[77]=de,e[78]=X):(de=e[77],X=e[78]),c.useEffect(de,X);let we,ze;e[79]!==Ue?(we=()=>()=>Ue(0),ze=[Ue],e[79]=Ue,e[80]=we,e[81]=ze):(we=e[80],ze=e[81]),c.useEffect(we,ze);const Ve=Ma(),He=`session-collection-expansion:${c.useId()}`;let $e,qe;e[82]!==Ve||e[83]!==He||e[84]!==ce||e[85]!==p.collapsedGroups||e[86]!==p.collapsedProjects||e[87]!==r.activeProjectId?($e=()=>(Ve.setBootstrapDemand(He,cm({projectSections:ce,activeProjectId:r.activeProjectId,collapsedProjects:p.collapsedProjects,collapsedGroups:p.collapsedGroups,currentDirectory:null,currentSessionDirectory:null})),()=>Ve.clearBootstrapDemand(He)),qe=[Ve,He,ce,p.collapsedProjects,p.collapsedGroups,r.activeProjectId],e[82]=Ve,e[83]=He,e[84]=ce,e[85]=p.collapsedGroups,e[86]=p.collapsedProjects,e[87]=r.activeProjectId,e[88]=$e,e[89]=qe):($e=e[88],qe=e[89]),c.useEffect($e,qe);const at=r.useGroupedSections?ge:_e;let gt;e[90]!==at||e[91]!==r.showInlineArchived?(gt=r.showInlineArchived?at:at.map(Ak),e[90]=at,e[91]=r.showInlineArchived,e[92]=gt):gt=e[92];const Pt=gt;let Ge;e[93]!==_e?(Ge=At=>_e.find(Jt=>Jt.project.id===At)?.groups.find(Pk)?.folderScopes??[],e[93]=_e,e[94]=Ge):Ge=e[94];const It=Ge;let kt;e[95]===Symbol.for("react.memo_cache_sentinel")?(kt=new Map,e[95]=kt):kt=e[95];const Mt=c.useRef(kt);let Tt;e[96]!==ce||e[97]!==r.isDesktopShellRuntime||e[98]!==r.stickyZoneHeaders?(Tt={enabled:r.stickyZoneHeaders,isDesktopShellRuntime:r.isDesktopShellRuntime,projectSections:ce,projectHeaderSentinelRefs:Mt},e[96]=ce,e[97]=r.isDesktopShellRuntime,e[98]=r.stickyZoneHeaders,e[99]=Tt):Tt=e[99];const wt=E2(Tt);let St;e[100]!==g||e[101]!==y.hasAuthoritativeGlobalSessions||e[102]!==f||e[103]!==h||e[104]!==G||e[105]!==n.projects||e[106]!==r.isSessionsLoading||e[107]!==r.isWorktreeTopologyLoading||e[108]!==r.unresolvedWorktreeProjectPaths?(St={enabled:!0,normalizedProjects:n.projects,ownership:G,isSessionsLoading:r.isSessionsLoading,hasAuthoritativeGlobalSessions:y.hasAuthoritativeGlobalSessions,isWorktreeTopologyLoading:r.isWorktreeTopologyLoading,unresolvedWorktreeProjectPaths:r.unresolvedWorktreeProjectPaths,foldersMap:h,createFolder:f,addSessionToFolder:g},e[100]=g,e[101]=y.hasAuthoritativeGlobalSessions,e[102]=f,e[103]=h,e[104]=G,e[105]=n.projects,e[106]=r.isSessionsLoading,e[107]=r.isWorktreeTopologyLoading,e[108]=r.unresolvedWorktreeProjectPaths,e[109]=St):St=e[109],u0(St);const{github:vt}=Dn(),ht=An(Dk),Ze=An(Tk),je=Ks(Ik),nt=Ks(Rk),lt=Ks(Ek);let Ct;e[110]===Symbol.for("react.memo_cache_sentinel")?(Ct=new Set,e[110]=Ct):Ct=e[110];const Ye=c.useRef(Ct);let it;e[111]!==je||e[112]!==vt||e[113]!==Ze||e[114]!==ht||e[115]!==ce||e[116]!==p.collapsedProjects||e[117]!==lt||e[118]!==nt||e[119]!==n.gitBranches?(it=()=>{if(!vt||!Ze||!ht?.connected)return;const At=new Map,Bt=Date.now();ce.forEach(Jt=>{p.collapsedProjects.has(Jt.project.id)||Jt.groups.forEach(ms=>{if(ms.isArchivedBucket||ms.isMain)return;const fs=dt(ms.directory??null),Ps=ms.branch?.trim()||n.gitBranches.get(fs||"")?.trim();if(!fs||!Ps)return;const J=Jo(fs,Ps),We=Ks.getState().entries[J],V=We?.status?.pr?.state==="closed"||We?.status?.pr?.state==="merged",Le=`${fs}::${Ps}`,Je=Math.max(We?.lastRefreshAt??0,We?.lastDiscoveryPollAt??0),mt=!!(We?.isInitialStatusResolved&&(!We.status?.pr||V)&&(!Ye.current.has(Le)||Bt-Je>=ok));(!We||!We.isInitialStatusResolved||mt)&&(mt&&Ye.current.add(Le),At.set(J,{directory:fs,branch:Ps}))})}),At.forEach((Jt,ms)=>{je(ms),nt(ms,{...Jt,remoteName:null,canShow:!0,github:vt,githubAuthChecked:Ze,githubConnected:ht.connected})}),At.size&<([...At.values()],{silent:!0,markInitialResolved:!0})},e[111]=je,e[112]=vt,e[113]=Ze,e[114]=ht,e[115]=ce,e[116]=p.collapsedProjects,e[117]=lt,e[118]=nt,e[119]=n.gitBranches,e[120]=it):it=e[120];const Nt=ht?.connected;let Dt;e[121]!==je||e[122]!==vt||e[123]!==Ze||e[124]!==ce||e[125]!==p.collapsedProjects||e[126]!==lt||e[127]!==nt||e[128]!==Nt||e[129]!==n.gitBranches?(Dt=[je,vt,Ze,Nt,ce,p.collapsedProjects,lt,nt,n.gitBranches],e[121]=je,e[122]=vt,e[123]=Ze,e[124]=ce,e[125]=p.collapsedProjects,e[126]=lt,e[127]=nt,e[128]=Nt,e[129]=n.gitBranches,e[130]=Dt):Dt=e[130],c.useEffect(it,Dt);let Rt;e[131]!==y.orderedSessions?(Rt=new Map(y.orderedSessions.map(Mk)),e[131]=y.orderedSessions,e[132]=Rt):Rt=e[132];const Vt=Rt;let Qt;if(e[133]!==w||e[134]!==Pt){let At;e[136]!==w?(At=Bt=>{const Jt=w(Bt.project.id,Bt.groups);return Jt===Bt.groups?Bt:{...Bt,groups:Jt}},e[136]=w,e[137]=At):At=e[137],Qt=Pt.map(At),e[133]=w,e[134]=Pt,e[135]=Qt}else Qt=e[135];const Ut=Qt;let Ft;e[138]!==ce||e[139]!==R||e[140]!==I||e[141]!==r.activeProjectId?(Ft=null,I&&(ce.some(At=>At.project.id===R)?Ft=R:ce.some(At=>At.project.id===r.activeProjectId)?Ft=r.activeProjectId:Ft=ce[0]?.project.id??null),e[138]=ce,e[139]=R,e[140]=I,e[141]=r.activeProjectId,e[142]=Ft):Ft=e[142];const Yt=I&&!r.useGroupedSections?20:void 0;let $t;e[143]!==i.startSessionWorktreeMenuLoad||e[144]!==o||e[145]!==y.pinnedSessionIds||e[146]!==_||e[147]!==se||e[148]!==Y||e[149]!==U||e[150]!==ve||e[151]!==ee||e[152]!==be||e[153]!==l||e[154]!==p.collapsedGroups||e[155]!==u.allowReselect||e[156]!==u.isSessionSearchOpen||e[157]!==u.onSessionSelected||e[158]!==u.sessionSearchQuery||e[159]!==u.setIsSessionSearchOpen||e[160]!==u.setSessionSearchQuery||e[161]!==Vt||e[162]!==Yt||e[163]!==Ie||e[164]!==r.activeProjectId||e[165]!==r.hasSessionSearchQuery||e[166]!==r.hideDirectoryControls||e[167]!==r.mobileVariant||e[168]!==r.normalizedSessionSearchQuery?($t={hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,groupSearchDataByGroup:be,collapsedGroups:p.collapsedGroups,hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:o,activeProjectId:r.activeProjectId,notifyOnSubtasks:l,pinnedSessionIds:y.pinnedSessionIds,sessionOrderIndex:Vt,expandedParents:ve,editingId:U,editTitle:Y,copiedSessionId:_,sessionBatchSize:Yt,setEditingId:H,setEditTitle:me,toggleParent:Ie,allowReselect:u.allowReselect,onSessionSelected:u.onSessionSelected,isSessionSearchOpen:u.isSessionSearchOpen,sessionSearchQuery:u.sessionSearchQuery,setSessionSearchQuery:u.setSessionSearchQuery,setIsSessionSearchOpen:u.setIsSessionSearchOpen,deleteSessionConfirm:se,setDeleteSessionConfirm:fe,startFolderRename:ne,setCopiedSessionId:le,startSessionWorktreeMenuLoad:i.startSessionWorktreeMenuLoad,folderRename:ee,setFolderRenameDraft:xe,clearFolderRename:Me},e[143]=i.startSessionWorktreeMenuLoad,e[144]=o,e[145]=y.pinnedSessionIds,e[146]=_,e[147]=se,e[148]=Y,e[149]=U,e[150]=ve,e[151]=ee,e[152]=be,e[153]=l,e[154]=p.collapsedGroups,e[155]=u.allowReselect,e[156]=u.isSessionSearchOpen,e[157]=u.onSessionSelected,e[158]=u.sessionSearchQuery,e[159]=u.setIsSessionSearchOpen,e[160]=u.setSessionSearchQuery,e[161]=Vt,e[162]=Yt,e[163]=Ie,e[164]=r.activeProjectId,e[165]=r.hasSessionSearchQuery,e[166]=r.hideDirectoryControls,e[167]=r.mobileVariant,e[168]=r.normalizedSessionSearchQuery,e[169]=$t):$t=e[169];const _t=$t;let Ee;e[170]!==d.openNewSessionDraft||e[171]!==d.setActiveProjectIdOnly||e[172]!==d.setSessionSwitcherOpen||e[173]!==x?(Ee={showMoreGroupSessions:A,resetGroupSessionLimit:D,setActiveProjectIdOnly:d.setActiveProjectIdOnly,setSessionSwitcherOpen:d.setSessionSwitcherOpen,openNewSessionDraft:d.openNewSessionDraft,onToggleCollapsedGroup:x},e[170]=d.openNewSessionDraft,e[171]=d.setActiveProjectIdOnly,e[172]=d.setSessionSwitcherOpen,e[173]=x,e[174]=Ee):Ee=e[174];const Ke=Ee;let et;e[175]!==oe||e[176]!==Ke||e[177]!==_t||e[178]!==Z?(et=()=>oe?s.jsx(Ao,{..._t,...Ke,group:oe,groupKey:"managed-chats",projectId:null,hideGroupLabel:!0,sessionBatchSize:20,scrollContainerRef:void 0,openSidebarMenuKey:Z,setOpenSidebarMenuKey:re}):null,e[175]=oe,e[176]=Ke,e[177]=_t,e[178]=Z,e[179]=et):et=e[179];const ct=et;let ut;e[180]!==d||e[181]!==r.mobileVariant?(ut=()=>{Te.getState().closeMainSurfaces(),r.mobileVariant&&d.setSessionSwitcherOpen(!1),d.openNewSessionDraft({selectedProjectId:$h,directoryOverride:null})},e[180]=d,e[181]=r.mobileVariant,e[182]=ut):ut=e[182];const jt=ut;let st;e[183]!==i.startSessionWorktreeMenuLoad||e[184]!==o||e[185]!==y.chatSessions||e[186]!==y.childrenMap||e[187]!==y.pinnedSessionIds||e[188]!==_||e[189]!==se||e[190]!==Y||e[191]!==U||e[192]!==ve||e[193]!==jt||e[194]!==l||e[195]!==Z||e[196]!==F||e[197]!==ct||e[198]!==u.allowReselect||e[199]!==u.isSessionSearchOpen||e[200]!==u.onSessionSelected||e[201]!==u.sessionSearchQuery||e[202]!==u.setIsSessionSearchOpen||e[203]!==u.setSessionSearchQuery||e[204]!==M||e[205]!==I||e[206]!==Ie||e[207]!==n.availableWorktreesByProject||e[208]!==n.gitBranches||e[209]!==n.isVSCode||e[210]!==n.projects||e[211]!==r.hasSessionSearchQuery||e[212]!==r.homeDirectory||e[213]!==r.isDesktopShellRuntime||e[214]!==r.mobileVariant||e[215]!==r.normalizedSessionSearchQuery?(st=n.isVSCode?null:s.jsx(Z2,{projects:n.projects,availableWorktreesByProject:n.availableWorktreesByProject,gitBranches:n.gitBranches,homeDirectory:r.homeDirectory,hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,isDesktopShellRuntime:r.isDesktopShellRuntime,sessions:F,childrenMap:y.childrenMap,pinnedSessionIds:y.pinnedSessionIds,recentSessions:F,expandedParents:ve,notifyOnSubtasks:l,editingId:U,editTitle:Y,copiedSessionId:_,openSidebarMenuKey:Z,mobileVariant:r.mobileVariant,alwaysShowActions:o,setEditingId:H,setEditTitle:me,toggleParent:Ie,setOpenSidebarMenuKey:re,allowReselect:u.allowReselect,onSessionSelected:u.onSessionSelected,isSessionSearchOpen:u.isSessionSearchOpen,sessionSearchQuery:u.sessionSearchQuery,setSessionSearchQuery:u.setSessionSearchQuery,setIsSessionSearchOpen:u.setIsSessionSearchOpen,deleteSessionConfirm:se,setDeleteSessionConfirm:fe,startFolderRename:ne,setCopiedSessionId:le,startSessionWorktreeMenuLoad:i.startSessionWorktreeMenuLoad,chatSessions:y.chatSessions,renderChatsSection:ct,onNewChat:jt,showRecentSection:M&&!I}),e[183]=i.startSessionWorktreeMenuLoad,e[184]=o,e[185]=y.chatSessions,e[186]=y.childrenMap,e[187]=y.pinnedSessionIds,e[188]=_,e[189]=se,e[190]=Y,e[191]=U,e[192]=ve,e[193]=jt,e[194]=l,e[195]=Z,e[196]=F,e[197]=ct,e[198]=u.allowReselect,e[199]=u.isSessionSearchOpen,e[200]=u.onSessionSelected,e[201]=u.sessionSearchQuery,e[202]=u.setIsSessionSearchOpen,e[203]=u.setSessionSearchQuery,e[204]=M,e[205]=I,e[206]=Ie,e[207]=n.availableWorktreesByProject,e[208]=n.gitBranches,e[209]=n.isVSCode,e[210]=n.projects,e[211]=r.hasSessionSearchQuery,e[212]=r.homeDirectory,e[213]=r.isDesktopShellRuntime,e[214]=r.mobileVariant,e[215]=r.normalizedSessionSearchQuery,e[216]=st):st=e[216];const Lt=st;let Xt;e[217]!==be||e[218]!==Ne||e[219]!==r.hasSessionSearchQuery?(Xt=r.hasSessionSearchQuery&&Ne.some(At=>be.get(At)?.hasMatch===!0),e[217]=be,e[218]=Ne,e[219]=r.hasSessionSearchQuery,e[220]=Xt):Xt=e[220];const ds=Xt,js=!!Lt;let ns;e[221]!==U||e[222]!==Z||e[223]!==N?(ns={editingId:U,openSidebarMenuKey:Z,setOpenSidebarMenuKey:re,visibleSessionCountByGroup:N},e[221]=U,e[222]=Z,e[223]=N,e[224]=ns):ns=e[224];let Js;e[225]!==_t||e[226]!==Ut||e[227]!==ce||e[228]!==Lt||e[229]!==Ft||e[230]!==I||e[231]!==wt||e[232]!==js||e[233]!==ns||e[234]!==ds||e[235]!==n.projectRepoStatus||e[236]!==r.activeProjectId||e[237]!==r.emptyState||e[238]!==r.searchEmptyState?(Js={topContent:Lt,topContentHasSearchMatches:ds,hasSharedSessions:js,sectionsForRender:Ut,projectSections:ce,activeProjectId:r.activeProjectId,singleProjectMode:I,singleProjectId:Ft,emptyState:r.emptyState,searchEmptyState:r.searchEmptyState,projectRepoStatus:n.projectRepoStatus,stuckProjectHeaders:wt,projectHeaderSentinelRefs:Mt,state:ns,groupProps:_t},e[225]=_t,e[226]=Ut,e[227]=ce,e[228]=Lt,e[229]=Ft,e[230]=I,e[231]=wt,e[232]=js,e[233]=ns,e[234]=ds,e[235]=n.projectRepoStatus,e[236]=r.activeProjectId,e[237]=r.emptyState,e[238]=r.searchEmptyState,e[239]=Js):Js=e[239];const rs=Js;let As;e[240]!==o||e[241]!==p.collapsedProjects||e[242]!==r.hasSessionSearchQuery||e[243]!==r.hideDirectoryControls||e[244]!==r.homeDirectory||e[245]!==r.isDesktopShellRuntime||e[246]!==r.mobileVariant||e[247]!==r.normalizedSessionSearchQuery||e[248]!==r.projectSortOrder||e[249]!==r.showOnlyMainWorkspace||e[250]!==r.stickyZoneHeaders?(As={homeDirectory:r.homeDirectory,collapsedProjects:p.collapsedProjects,showOnlyMainWorkspace:r.showOnlyMainWorkspace,hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,hideDirectoryControls:r.hideDirectoryControls,isDesktopShellRuntime:r.isDesktopShellRuntime,stickyZoneHeaders:r.stickyZoneHeaders,mobileVariant:r.mobileVariant,alwaysShowActions:o,projectSortOrder:r.projectSortOrder},e[240]=o,e[241]=p.collapsedProjects,e[242]=r.hasSessionSearchQuery,e[243]=r.hideDirectoryControls,e[244]=r.homeDirectory,e[245]=r.isDesktopShellRuntime,e[246]=r.mobileVariant,e[247]=r.normalizedSessionSearchQuery,e[248]=r.projectSortOrder,e[249]=r.showOnlyMainWorkspace,e[250]=r.stickyZoneHeaders,e[251]=As):As=e[251];const $s=As;let Zs;e[252]!==Ke||e[253]!==d.openNewSessionDraft||e[254]!==d.openNewWorktreeDialog||e[255]!==d.openProjectEditDialog||e[256]!==d.openWorktreesPage||e[257]!==d.removeProject||e[258]!==d.renderProjectStatusIndicator||e[259]!==d.reorderProjects||e[260]!==d.setActiveProjectIdOnly||e[261]!==d.setSessionSwitcherOpen||e[262]!==v||e[263]!==K||e[264]!==m?(Zs={group:Ke,toggleProject:m,setActiveProjectIdOnly:d.setActiveProjectIdOnly,setSessionSwitcherOpen:d.setSessionSwitcherOpen,openNewSessionDraft:d.openNewSessionDraft,openNewWorktreeDialog:d.openNewWorktreeDialog,openWorktreesPage:d.openWorktreesPage,openProjectEditDialog:d.openProjectEditDialog,removeProject:d.removeProject,reorderProjects:d.reorderProjects,setGroupOrderByProject:v,renderProjectStatusIndicator:d.renderProjectStatusIndicator,setSingleProjectId:K},e[252]=Ke,e[253]=d.openNewSessionDraft,e[254]=d.openNewWorktreeDialog,e[255]=d.openProjectEditDialog,e[256]=d.openWorktreesPage,e[257]=d.removeProject,e[258]=d.renderProjectStatusIndicator,e[259]=d.reorderProjects,e[260]=d.setActiveProjectIdOnly,e[261]=d.setSessionSwitcherOpen,e[262]=v,e[263]=K,e[264]=m,e[265]=Zs):Zs=e[265];const ln=Zs;let bs;e[266]!==i.initialActiveSessionByProject||e[267]!==i.openNewSessionDraft||e[268]!==i.persistActiveSessionByProject||e[269]!==i.setSessionSwitcherOpen||e[270]!==G.bySessionId||e[271]!==ce||e[272]!==De||e[273]!==r.activeProjectId||e[274]!==r.mobileVariant?(bs=s.jsx(p0,{projectSections:ce,activeProjectId:r.activeProjectId,initialActiveSessionByProject:i.initialActiveSessionByProject,persistActiveSessionByProject:i.persistActiveSessionByProject,mobileVariant:r.mobileVariant,openNewSessionDraft:i.openNewSessionDraft,setSessionSwitcherOpen:i.setSessionSwitcherOpen,sessionOwnerBySessionId:G.bySessionId,handleSessionSelect:De}),e[266]=i.initialActiveSessionByProject,e[267]=i.openNewSessionDraft,e[268]=i.persistActiveSessionByProject,e[269]=i.setSessionSwitcherOpen,e[270]=G.bySessionId,e[271]=ce,e[272]=De,e[273]=r.activeProjectId,e[274]=r.mobileVariant,e[275]=bs):bs=e[275];let ks;e[276]!==y.orderedSessions||e[277]!==ke||e[278]!==F?(ks=s.jsx(I0,{sortedSessions:y.orderedSessions,recentSessions:F,prefetchSession:ke}),e[276]=y.orderedSessions,e[277]=ke,e[278]=F,e[279]=ks):ks=e[279];let Ws;e[280]!==ln||e[281]!==rs||e[282]!==$s?(Ws=s.jsx(I2,{model:rs,view:$s,actions:ln}),e[280]=ln,e[281]=rs,e[282]=$s,e[283]=Ws):Ws=e[283];const cn=U!==null;let us;e[284]!==It||e[285]!==cn?(us=s.jsx(L2,{getFolderScopesForProject:It,isInlineEditing:cn,startFolderRename:ne}),e[284]=It,e[285]=cn,e[286]=us):us=e[286];let zs;return e[287]!==bs||e[288]!==ks||e[289]!==Ws||e[290]!==us?(zs=s.jsxs(s.Fragment,{children:[bs,ks,Ws,us]}),e[287]=bs,e[288]=ks,e[289]=Ws,e[290]=us,e[291]=zs):zs=e[291],zs},ck=t=>{const e=Xe.c(2);let n;return e[0]!==t?(n=t.view.isVisible?s.jsx(lk,{...t}):null,e[0]=t,e[1]=n):n=e[1],n};function dk(t){return t.foldersMap}function uk(t){return t.createFolder}function mk(t){return t.addSessionToFolder}function fk(t){return t.showRecentSection}function hk(t){return t.projectDisplayMode}function pk(t){return t.singleProjectId}function gk(t){return t.setSingleProjectId}function xk(t){return t.setCurrentSession}function bk(t){return Kd(t.directory)}function yk(t){return dt(t.directory??null)}function wk(t){return!!t}function Sk(t){return{scopeKey:t,directory:t}}function vk(t){return!t.time?.archived&&ak(t)}function jk(t){return!t.time?.archived}function kk(t){return{session:t,children:[],worktree:null}}function Ck(t){return t.isArchivedBucket}function Nk(t){return!t.isArchivedBucket}function Ak(t){return t.groups.some(Ck)?{...t,groups:t.groups.filter(Nk)}:t}function Pk(t){return!t.isArchivedBucket}function Dk(t){return t.status}function Tk(t){return t.hasChecked}function Ik(t){return t.ensureEntry}function Rk(t){return t.setParams}function Ek(t){return t.refreshTargets}function Mk(t,e){return[t.id,e]}const ym=(t,e,n)=>{const r=new Set;for(const i of t){const o=dt(i.path)?.toLowerCase();o&&r.add(o)}if(n?.includeWorktrees===!1)return r;for(const i of e.values())for(const o of i){const l=dt(o.path)?.toLowerCase();l&&r.add(l)}return r},Oc="oc.sessions.activeSessionByProject",Ok=[],Bk=xu(wr(),wr().min(1).catch("")),Fk=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:n,allowReselect:r=!1,hideDirectoryControls:i=!1,showOnlyMainWorkspace:o=!1})=>{Ni("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}=pt(),[a,u]=c.useState(!1),[d,h]=c.useState(""),[f,g]=c.useState(0),p=c.useRef(null),w=c.useRef(null),[v,x]=c.useState(null),m=c.useMemo(()=>Io(),[]),[b,y]=c.useState(new Map),S=Te(je=>je.isNewWorktreeDialogOpen),N=Te(je=>je.setNewWorktreeDialogOpen),[C,k]=c.useState(!1),A=c.useMemo(()=>{try{const je=m.getItem(Oc);if(!je)return new Map;const nt=Bk.safeParse(JSON.parse(je));if(!nt.success)return new Map;const lt=new Map;return Object.entries(nt.data).forEach(([Ct,Ye])=>{Ye&<.set(Ct,Ye)}),lt}catch{return new Map}},[m]),P=c.useCallback(je=>{try{m.setItem(Oc,JSON.stringify(Object.fromEntries(je.entries())))}catch{}},[m]),[D,M]=c.useState(new Map),$=es(je=>je.homeDirectory),R=zt(je=>je.projects),K=zt(je=>je.activeProjectId),L=zt(je=>je.removeProject),O=zt(je=>je.setActiveProjectIdOnly),I=zt(je=>je.updateProjectMeta),j=zt(je=>je.reorderProjects),T=Te(je=>je.setSettingsDialogOpen),F=Te(je=>je.toggleHelpDialog),U=Te(je=>je.setAboutDialogOpen),H=Te(je=>je.setSessionSwitcherOpen),Y=Te(je=>je.setScheduledTasksDialogOpen),me=Te(je=>je.setArchivePageOpen),Z=Te(je=>je.setWorktreesPageProjectId),re=Te(je=>je.openMultiRunLauncher),se=Te(je=>je.notifyOnSubtasks),fe=Na(d,120),_=c.useMemo(()=>fe.trim().toLowerCase(),[fe]),le=_.length>0;Mv({enabled:t,isSessionSearchOpen:a,setIsSessionSearchOpen:u,sessionSearchInputRef:w,sessionSearchContainerRef:p});const ee=Ed(t),ue=c.useMemo(()=>Pn(),[]),W=Qe(je=>je.setCurrentSession),ne=Qe(je=>je.worktreeMetadata),pe=Qe(je=>je.availableWorktreesByProject),xe=Qe(je=>je.openNewSessionDraft),Ce=c.useMemo(()=>ym(R,pe,{includeWorktrees:!ue}),[pe,ue,R]),Me=c.useCallback(je=>{Te.getState().closeMainSurfaces(),xe(je),ue&&window.dispatchEvent(new CustomEvent("openchamber:navigate",{detail:{view:"chat"}}))},[ue,xe]),ve=Or(Zn(je=>({checkForUpdates:je.checkForUpdates,available:je.available,runtimeType:je.runtimeType,info:je.info,downloading:je.downloading,downloaded:je.downloaded,progress:je.progress,error:je.error,downloadUpdate:je.downloadUpdate,restartToUpdate:je.restartToUpdate}))),Ie=xs(),ye=c.useMemo(()=>`${Ie}|${R.map(je=>`${je.id}:${dt(je.path)??""}`).join("|")}`,[R,Ie]),[q,De]=c.useState(ue?ye:null),[ke,te]=c.useReducer(je=>je+1,0),he=!ue&&q!==ye,[ae,Q]=c.useState(new Set),z=c.useRef({runtimeKey:null,revision:0,worktreesByProject:new Map});c.useEffect(()=>{let je=!1;return(async()=>{const lt=Ie,Ct=zt.getState().projects;if(Ct.length===0||ue){je||(z.current={runtimeKey:null,revision:0,worktreesByProject:new Map},Q(new Set),De(ye));return}const Ye=Qe.getState().availableWorktreesByProject,it=la({rawWorktreesByProjectRef:z,publishedWorktreesByProject:Ye,runtimeKey:lt}),Nt=it.revision,Dt=new Map(it.worktreesByProject),Rt=new Set,Vt=3;let Qt=0;const Ut=Array.from({length:Vt},async()=>{for(;;){const $t=Qt;if(Qt+=1,$t>=Ct.length)return;const _t=Ct[$t],Ee=dt(_t.path);if(Ee)try{const Ke=await Ri(async()=>Bn.getState().directories.get(Ee)?.isGitRepo??await Xo(Ee)?fl({id:_t.id,path:Ee}):null);if(Ke===null){Dt.delete(Ee);continue}if(je)return;Ke.length===0?Dt.delete(Ee):Dt.set(Ee,Ke)}catch{Rt.add(Ee)}}});if(await Promise.all(Ut),je||xs()!==lt)return;const Ft=new Set(Ct.map($t=>dt($t.path)).filter(Boolean));for(const $t of Dt.keys())Ft.has($t)||Dt.delete($t);Vj({rawWorktreesByProjectRef:z,runtimeKey:lt,capturedRevision:Nt,nextRawWorktreesByProject:Dt,publishedWorktreesByProject:Ye,partitionWorktreesByRegisteredProject:pl,projects:Ct,worktreeMapsEqual:hl,recordWorktreesSeen:Rc,publishTopology:$t=>{Qe.setState($t)},requestRediscovery:()=>{te()},now:()=>Date.now()})&&(Q(Rt),De(ye))})(),()=>{je=!0}},[ue,ye,Ie,ke]),c.useEffect(()=>{if(!ue)return Jr(je=>{je.type==="session-created"&&te()})},[ue]);const G=c.useMemo(()=>gn(),[]),{isTablet:ie}=Ln(),Oe=e||ie,Fe=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]),Se=c.useMemo(()=>R.find(je=>je.id===v)??null,[R,v]),oe=c.useCallback(je=>{v&&I(v,{label:je.label,icon:je.icon,color:je.color,iconBackground:je.iconBackground,defaultModel:je.defaultModel??null})},[v,I]),Pe=c.useCallback(()=>{N(!0)},[N]),Ne=c.useCallback(()=>{const je=Or.getState();if(je.available&&je.info){k(!0);return}ve.checkForUpdates().then(()=>{const{available:nt,error:lt}=Or.getState();if(lt){Be.error(l("sessions.sidebar.updateCheck.errorTitle"),{description:lt});return}if(!nt){Be.success(l("sessions.sidebar.updateCheck.latestVersion"));return}k(!0)})},[l,ve]),B=c.useCallback(()=>{e&&H(!1),T(!0)},[e,H,T]),ce=ve.available&&(ve.runtimeType==="desktop"||ve.runtimeType==="web"),be=c.useCallback(()=>{pn.requestDirectoryDialog()},[]),ge=c.useMemo(()=>R.flatMap(je=>{const nt=dt(je.path);return nt?[{id:je.id,path:je.path,label:je.label,normalizedPath:nt,icon:je.icon??void 0,color:je.color??void 0,iconImage:je.iconImage??void 0,iconBackground:je.iconBackground??void 0,addedAt:je.addedAt,lastOpenedAt:je.lastOpenedAt,sidebarCollapsed:je.sidebarCollapsed}]:[]}),[R]),_e=c.useMemo(()=>ge.map(je=>je.normalizedPath),[ge]),tt=Wh(t?_e:Ok);zv({enabled:t,normalizedProjects:ge,gitRepoStatus:tt,setProjectRepoStatus:y,setProjectRootBranches:M});const Ue=Qe(je=>je.isLoading),de=c.useRef(!1);K&&b.has(K)&&(de.current=!!b.get(K));const X=as(je=>je.showArchivedSessions),we=as(je=>je.projectSortOrder),ze=as(je=>je.stickyZoneHeaders),Ve=zt(je=>je.manualProjectOrder),He={isVisible:t,mobileVariant:e,onSessionSelected:n,allowReselect:r,hideDirectoryControls:i,showOnlyMainWorkspace:o,t:l,isTablet:ie,projects:R,activeProjectId:K,manualProjectOrder:Ve,worktreeMetadata:ne,availableWorktreesByProject:pe,gitBranches:ee,gitRepoStatus:tt,updateStore:ve,showArchivedSessions:X,projectSortOrder:we,projectRepoStatus:b,projectRootBranches:D,resolvedWorktreeTopologyKey:q,unresolvedWorktreeProjectPaths:ae,isSessionSearchOpen:a,sessionSearchQuery:d,editingProjectDialogId:v,updateDialogOpen:C},$e=c.useRef(null),qe=$e.current;if(qe){let je=!1;for(const nt of Object.keys(He))Object.is(qe[nt],He[nt])||(Gs(`ui.session_sidebar.source.${nt}`),je=!0);je||Gs("ui.session_sidebar.source.parent_or_context")}$e.current=He;const at=c.useMemo(()=>{const je=[...ge];switch(we){case"a-z":je.sort((nt,lt)=>{const Ct=(nt.label||nt.path).toLowerCase(),Ye=(lt.label||lt.path).toLowerCase();return Ct.localeCompare(Ye)});break;case"z-a":je.sort((nt,lt)=>{const Ct=(nt.label||nt.path).toLowerCase();return(lt.label||lt.path).toLowerCase().localeCompare(Ct)});break;case"date-added":je.sort((nt,lt)=>(lt.addedAt??0)-(nt.addedAt??0));break;case"recent":je.sort((nt,lt)=>(lt.lastOpenedAt??0)-(nt.lastOpenedAt??0));break;case"manual":{const nt=new Map(Ve.map((lt,Ct)=>[lt,Ct]));je.sort((lt,Ct)=>{const Ye=nt.get(lt.id)??1/0,it=nt.get(Ct.id)??1/0;return Ye-it});break}}return je},[ge,we,Ve]),gt=_v({isVSCode:ue,projects:at}),Pt=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]),Ge=ue&&X,kt=as(je=>je.sessionGroupingMode)==="by-worktree"&&!ue,wt=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-primary/50 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-primary/50 disabled:cursor-not-allowed",St="h-4.5 w-4.5",vt=c.useCallback(()=>{e&&H(!1),re()},[e,re,H]),ht=c.useCallback(je=>{const nt=je.projectId?R.find(lt=>lt.id===je.projectId)??null:je.sourceDirectory?Pi(je.sourceDirectory):null;return zj(je,{projects:R,getCurrentProjects:()=>zt.getState().projects,rawWorktreesByProjectRef:z,getPublishedWorktreesByProject:()=>Qe.getState().availableWorktreesByProject,resolveProject:lt=>Pi(lt),listProjectWorktrees:fl,partitionWorktreesByRegisteredProject:pl,worktreeMapsEqual:hl,recordWorktreesSeen:Rc,publishTopology:lt=>{Qe.setState(lt)},getRuntimeKey:xs,now:()=>Date.now(),projectRootBranch:nt?D.get(nt.id)??null:null})},[D,R]),Ze=c.useCallback(()=>{Te.getState().closeMainSurfaces(),e&&H(!1),xe()},[e,xe,H]);return s.jsx(Bi,{delay:400,closeDelay:0,timeout:300,children:s.jsxs("div",{ref:p,className:Re("relative flex h-full flex-col text-foreground overflow-x-hidden",e?"":"bg-transparent"),children:[!i&&!ue?s.jsx(c0,{onNewSession:Ze}):null,s.jsx(Qv,{hideDirectoryControls:i,showProjectDisplayControls:!ue,showRecentControls:!ue,handleOpenDirectoryDialog:be,onOpenScheduled:()=>{e&&H(!1),Y(!0)},onOpenMultiRun:vt,canOpenMultiRun:R.length>0,onOpenArchive:()=>{e&&H(!1),me(!0)},headerActionIconClass:St,headerActionButtonClass:wt,isSessionSearchOpen:a,setIsSessionSearchOpen:u,sessionSearchInputRef:w,sessionSearchQuery:d,setSessionSearchQuery:h,hasSessionSearchQuery:le,searchMatchCount:f,collapseAllProjects:gt.actions.collapseAllProjects,expandAllProjects:gt.actions.expandAllProjects}),s.jsx(ck,{topology:{projects:at,availableWorktreesByProject:pe,knownDirectories:Ce,isVSCode:ue,worktreeMetadata:ne,gitBranches:ee,projectRepoStatus:b,projectRootBranches:D,lastRepoStatus:de.current},view:{isVisible:t,hasSessionSearchQuery:le,normalizedSessionSearchQuery:_,activeProjectId:K,showInlineArchived:Ge,useGroupedSections:kt,homeDirectory:$,mobileVariant:e,hideDirectoryControls:i,showOnlyMainWorkspace:o,isDesktopShellRuntime:G,stickyZoneHeaders:ze,projectSortOrder:we,emptyState:Fe,searchEmptyState:Pt,isSessionsLoading:Ue,isWorktreeTopologyLoading:he,unresolvedWorktreeProjectPaths:ae,projectView:gt.state,onSearchMatchCountChange:g},actions:{rowActions:{allowReselect:r,onSessionSelected:n,isSessionSearchOpen:a,sessionSearchQuery:d,setSessionSearchQuery:h,setIsSessionSearchOpen:u},alwaysShowActions:Oe,notifyOnSubtasks:se,setActiveProjectIdOnly:O,setSessionSwitcherOpen:H,openNewSessionDraft:Me,openNewWorktreeDialog:Pe,openWorktreesPage:je=>{e&&H(!1),Z(je)},openProjectEditDialog:x,removeProject:L,reorderProjects:j,startSessionWorktreeMenuLoad:ht,initialActiveSessionByProject:A,persistActiveSessionByProject:P,projectViewActions:gt.actions}}),s.jsx(d0,{onOpenSettings:B,onOpenShortcuts:F,onOpenAbout:()=>U(!0),onOpenUpdate:Ne,showRuntimeButtons:!ue,showUpdateButton:ce}),s.jsx(eu,{open:C,onOpenChange:k,info:ve.info,downloading:ve.downloading,downloaded:ve.downloaded,progress:ve.progress,error:ve.error,onDownload:ve.downloadUpdate,onRestart:ve.restartToUpdate,runtimeType:ve.runtimeType}),s.jsx(Gv,{open:!!Se,onOpenChange:je=>{je||x(null)},project:Se,onSave:oe}),s.jsx(ig,{open:S,onOpenChange:N,onWorktreeCreated:(je,nt)=>{if(Te.getState().closeMainSurfaces(),e&&H(!1),nt?.sessionId){W(nt.sessionId,je);return}xe({directoryOverride:je,preserveDirectoryOverride:!0})}})]})})},_k=c.memo(Fk),vn=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(/\/+$/,"")},Lk=()=>{const{t}=pt(),[e,n]=c.useState(!1),[r,i]=c.useState(!1),[o,l]=c.useState(null),[a,u]=c.useState([]),[d,h]=c.useState(!1),[f,g]=c.useState(!1),[p,w]=c.useState(!1),[v,x]=c.useState(!1),[m,b]=c.useState(new Set),y=Qe(q=>q.getWorktreeMetadata),S=Qe(q=>q.newSessionDraft),N=Qe(q=>q.setNewSessionDraftTarget),C=Qe(q=>q.setDraftBootstrapPendingDirectory),k=zh,A=Qe(q=>q.deleteSessions),P=Qe(q=>q.archiveSessions),D=Te(q=>q.showDeletionDialog),M=Te(q=>q.setShowDeletionDialog),$=es(q=>q.currentDirectory),R=es(q=>q.homeDirectory),K=es(q=>q.isHomeReady),L=zt(q=>q.projects),O=zt(q=>q.activeProjectId),{isMobile:I,isTablet:j,hasTouchInput:T}=Ln(),F=I||j||T,U=c.useMemo(()=>{const De=(O?L.find(ke=>ke.id===O)??null:null)?.path??$;return dn(De)},[O,$,L]),H=c.useCallback(q=>{const ke=dn(q.projectDirectory)||U;return{id:(L.find(he=>dn(he.path)===ke)??null)?.id??`path:${ke}`,path:ke}},[U,L]),Y=v&&m.size>0,me=c.useMemo(()=>{const q=o?.worktree;return q&&typeof q.branch=="string"&&q.branch.trim().length>0?!0:a.length>0&&a.every(({metadata:De})=>typeof De.branch=="string"&&De.branch.trim().length>0)},[o?.worktree,a]),Z=o?.mode==="worktree",re=Z,se=p||!Z||!me,fe=p||!Z;c.useEffect(()=>{r||!K||L.length>0||(i(!0),n(!0))},[r,K,L.length]);const _=c.useCallback(q=>{l({sessions:q.sessions,dateLabel:q.dateLabel,mode:q.mode??"session",worktree:q.worktree??null})},[]),le=c.useCallback(()=>{l(null),u([]),h(!1),g(!1),w(!1),x(!1),b(new Set)},[]),ee=c.useCallback(async q=>{if(q.sessions.length===0)return;if(q.sessions.length===1){const he=q.sessions[0];await k(he.id)?Be.success(t("sessions.sidebar.session.delete.success")):Be.error(t("sessions.sidebar.session.delete.error"));return}const De=q.sessions.map(he=>he.id),{deletedIds:ke,failedIds:te}=await A(De);if(ke.length>0){const he=te.length>0?te.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:te.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:te.length}):q.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:q.dateLabel}):void 0;Be.success(ke.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:ke.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:ke.length}),{description:vn(he)})}te.length>0&&Be.error(te.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:te.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:te.length}),{description:vn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[k,A,t]);c.useEffect(()=>pn.onDeleteRequest(q=>{if(!D&&(q.mode??"session")==="session"){ee(q);return}_(q)}),[_,D,ee]),c.useEffect(()=>pn.onDirectoryRequest(()=>{n(!0)}),[]),c.useEffect(()=>{if(!o){u([]),h(!1),g(!1),x(!1),b(new Set);return}const q=o.sessions.map(te=>{const he=y(te.id);return he?{session:te,metadata:he}:null}).filter(te=>!!te);u(q),h(!1),x(!1),b(new Set);const De=new Map;if(o.worktree?.path&&De.set(dn(o.worktree.path),o.worktree),q.forEach(({metadata:te})=>{te.path&&De.set(dn(te.path),te)}),De.size===0){x(!0);return}let ke=!1;return(async()=>{const te=new Map,he=new Set;await Promise.all(Array.from(De.entries()).map(async([ae,Q])=>{try{const z=await Vh(Q.path);te.set(ae,z),z?.isDirty&&he.add(ae)}catch{Q.status&&(te.set(ae,Q.status),Q.status.isDirty&&he.add(ae))}})).catch(ae=>{console.warn("Failed to inspect worktree status before deletion:",ae)}),!ke&&(b(he),x(!0),l(ae=>{if(!ae?.worktree?.path)return ae;const Q=dn(ae.worktree.path),z=te.get(Q);if(!z)return ae;const G=ae.worktree.status;return G?.isDirty===z.isDirty&&G?.ahead===z.ahead&&G?.behind===z.behind&&G?.upstream===z.upstream?ae:{...ae,worktree:{...ae.worktree,status:z}}}),u(ae=>ae.map(Q=>{const z=dn(Q.metadata.path),G=te.get(z);return G?{session:Q.session,metadata:{...Q.metadata,status:G}}:Q})))})(),()=>{ke=!0}},[o,y]),c.useEffect(()=>{me||h(!1)},[me]);const ue=c.useCallback(async(q,De,ke)=>{const te=d&&me,he=H(q),ae=dn(q.path),Q=dn(he.path);try{await Sd(he,q,{deleteRemoteBranch:te,deleteLocalBranch:De});const z=dn(S?.directoryOverride);return S?.open&&ae&&z===ae&&Q&&(C(null),N({projectId:he.id,directoryOverride:Q},{force:!0})),dn($)===ae&&Q&&es.getState().setDirectory(Q,{showOverlay:!1}),!0}catch(z){return Be.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:li(q)}),{id:ke,description:vn(z instanceof Error?z.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[me,$,d,H,S?.directoryOverride,S?.open,C,N,t]),W=c.useCallback((q,De,ke)=>{const te=d&&me,he=Be.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:li(q)}));(async()=>{try{if(De.length>0){const{failedIds:z}=await P(De);if(z.length>0){Be.error(z.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:z.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:z.length}),{id:he,description:vn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))});return}}if(!await ue(q,ke,he))return;const Q=t(te?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");Be.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:li(q)}),{id:he,description:vn(Q)})}catch(ae){Be.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:he,description:vn(ae instanceof Error?ae.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}})()},[P,me,d,ue,t]),ne=c.useCallback(async()=>{if(o){w(!0);try{const q=re,De=q&&d,ke=q&&f;if(Z&&o.worktree){W(o.worktree,o.sessions.map(te=>te.id),ke),le();return}if(o.sessions.length===1){const te=o.sessions[0];if(!await k(te.id)){Be.error(t("sessions.sidebar.session.delete.error")),w(!1);return}const ae=!Z&&q?t(De?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.attachedArchived"):void 0;Be.success(t("sessions.sidebar.session.delete.success"),{description:vn(ae),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const te=o.sessions.map(z=>z.id);let he=[],ae=[];const Q=await A(te);if(he=Q.deletedIds,ae=Q.failedIds,he.length>0){const z=!Z&&q?t(De?"sessions.sidebar.sessionDialogs.worktree.archivedAndRemoteRemoved":"sessions.sidebar.sessionDialogs.worktree.attachedArchivedPlural"):void 0,ie=[ae.length>0?ae.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:ae.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:ae.length}):o.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:o.dateLabel}):void 0,z].filter(Boolean).join(" ");Be.success(he.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:he.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:he.length}),{description:vn(ie||void 0),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(ae.length>0&&(Be.error(ae.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:ae.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:ae.length}),{description:vn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),he.length===0)){w(!1);return}}le()}finally{w(!1)}}},[o,d,f,k,A,le,re,Z,W,t]),pe=o?.worktree??a[0]?.metadata??null,xe=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}):"",Ce=o?s.jsxs("div",{className:Re(Z?"space-y-3":"space-y-2"),children:[o.sessions.length>0&&s.jsxs("div",{className:Re(Z?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[Z&&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:Re(Z?"mt-2 space-y-1":"space-y-0.5"),children:[o.sessions.slice(0,5).map(q=>s.jsxs("li",{className:Re(Z?"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:Re(!Z&&"hidden"),children:"•"}),s.jsx("span",{className:"truncate",children:q.title||t("sessions.sidebar.session.untitled")})]},q.id)),o.sessions.length>5&&s.jsx("li",{className:Re(Z?"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})})]})]}),Z?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(E,{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")}),pe?.label?s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:pe.label}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:pe?Wr(pe.path,R):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),Y&&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,Me=Z?me?s.jsxs("button",{type:"button",onClick:()=>{se||h(q=>!q)},disabled:se,className:Re("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-primary"),children:[d?s.jsx(E,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(E,{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,ve=Z?s.jsxs("button",{type:"button",onClick:()=>{fe||g(q=>!q)},disabled:fe,className:Re("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",fe?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),children:[f?s.jsx(E,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(E,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,Ie=Z?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:[ve,Me]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ot,{variant:"ghost",onClick:le,disabled:p,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ot,{variant:"destructive",onClick:ne,disabled:p,children:t(p?"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:()=>M(!D),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-primary/50","aria-pressed":!D,children:[D?s.jsx(E,{name:"checkbox-blank",className:"size-4"}):s.jsx(E,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ot,{variant:"ghost",onClick:le,disabled:p,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ot,{variant:"destructive",onClick:ne,disabled:p,children:p?t("sessions.sidebar.sessionDialogs.actions.deleting"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),ye=Z?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:[F?s.jsx(Zo,{open:!!o,onClose:()=>{p||le()},title:ye,footer:s.jsx("div",{className:"flex justify-end gap-2",children:Ie}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[xe&&s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:xe}),Ce]})}):s.jsx(Ss,{open:!!o,onOpenChange:q=>{if(!q){if(p)return;le()}},children:s.jsxs(vs,{className:Re(Z?"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(Ls,{children:[s.jsxs(Ts,{className:Re(Z&&"flex items-center gap-2"),children:[Z&&s.jsx(E,{name:"delete-bin",className:"h-5 w-5"}),ye]}),xe&&s.jsx(Is,{children:xe})]}),s.jsx("div",{className:Re(Z&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:Ce}),s.jsx(xn,{className:"mt-2 gap-2 pt-1 pb-1",children:Ie})]})}),s.jsx(ag,{open:e,onOpenChange:n})]})};function $k(t){const e=Xe.c(64),{t:n}=pt(),{value:r,onMoveSessionOnly:i,onMoveAllChanges:o,onCancel:l}=t,a=!!r;let u;e[0]!==l?(u=I=>{I||l()},e[0]=l,e[1]=u):u=e[1];let d;e[2]!==n?(d=n("sessions.sidebar.session.moveToWorktree.confirm.title"),e[2]=n,e[3]=d):d=e[3];let h;e[4]!==d?(h=s.jsx(Ts,{children:d}),e[4]=d,e[5]=h):h=e[5];const f=r?.dirtyFileCount??0;let g;e[6]!==n||e[7]!==f?(g=n("sessions.sidebar.session.moveToWorktree.confirm.changedFiles",{count:f}),e[6]=n,e[7]=f,e[8]=g):g=e[8];let p;e[9]!==n?(p=n("sessions.sidebar.session.moveToWorktree.confirm.ownership"),e[9]=n,e[10]=p):p=e[10];let w;e[11]!==g||e[12]!==p?(w=s.jsxs(Is,{children:[g," ",p]}),e[11]=g,e[12]=p,e[13]=w):w=e[13];let v;e[14]!==h||e[15]!==w?(v=s.jsxs(Ls,{children:[h,w]}),e[14]=h,e[15]=w,e[16]=v):v=e[16];let x;e[17]!==n?(x=n("sessions.sidebar.session.moveToWorktree.confirm.sessionOnlyHelp"),e[17]=n,e[18]=x):x=e[18];let m;e[19]!==x?(m=s.jsx("p",{children:x}),e[19]=x,e[20]=m):m=e[20];let b;e[21]!==n?(b=n("sessions.sidebar.session.moveToWorktree.confirm.allChangesHelp"),e[21]=n,e[22]=b):b=e[22];let y;e[23]!==b?(y=s.jsx("p",{children:b}),e[23]=b,e[24]=y):y=e[24];let S;e[25]!==n||e[26]!==r?(S=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]=S):S=e[27];let N;e[28]!==n?(N=n("sessions.sidebar.session.moveToWorktree.confirm.baseWarning"),e[28]=n,e[29]=N):N=e[29];let C;e[30]!==N?(C=s.jsx("p",{children:N}),e[30]=N,e[31]=C):C=e[31];let k;e[32]!==m||e[33]!==y||e[34]!==S||e[35]!==C?(k=s.jsxs("div",{className:"space-y-2 typography-ui-label text-muted-foreground",children:[m,y,S,C]}),e[32]=m,e[33]=y,e[34]=S,e[35]=C,e[36]=k):k=e[36];let A;e[37]!==n?(A=n("sessions.sidebar.session.moveToWorktree.confirm.cancel"),e[37]=n,e[38]=A):A=e[38];let P;e[39]!==l||e[40]!==A?(P=s.jsx(ot,{type:"button",variant:"neutral","data-session-worktree-move-action":"cancel",onClick:l,children:A}),e[39]=l,e[40]=A,e[41]=P):P=e[41];let D;e[42]!==n?(D=n("sessions.sidebar.session.moveToWorktree.confirm.allChanges"),e[42]=n,e[43]=D):D=e[43];let M;e[44]!==o||e[45]!==D?(M=s.jsx(ot,{type:"button",variant:"outline","data-session-worktree-move-action":"all-changes",onClick:o,children:D}),e[44]=o,e[45]=D,e[46]=M):M=e[46];let $;e[47]!==n?($=n("sessions.sidebar.session.moveToWorktree.confirm.sessionOnly"),e[47]=n,e[48]=$):$=e[48];let R;e[49]!==i||e[50]!==$?(R=s.jsx(ot,{type:"button",autoFocus:!0,"data-session-worktree-move-action":"session-only",onClick:i,children:$}),e[49]=i,e[50]=$,e[51]=R):R=e[51];let K;e[52]!==P||e[53]!==M||e[54]!==R?(K=s.jsxs(xn,{className:"gap-2 sm:justify-end",children:[P,M,R]}),e[52]=P,e[53]=M,e[54]=R,e[55]=K):K=e[55];let L;e[56]!==k||e[57]!==K||e[58]!==v?(L=s.jsxs(vs,{id:"session-worktree-move-confirm-dialog",showCloseButton:!1,className:"max-w-md gap-5",children:[v,k,K]}),e[56]=k,e[57]=K,e[58]=v,e[59]=L):L=e[59];let O;return e[60]!==a||e[61]!==u||e[62]!==L?(O=s.jsx(Ss,{open:a,onOpenChange:u,children:L}),e[60]=a,e[61]=u,e[62]=L,e[63]=O):O=e[63],O}function wm(t){if(!t||!t.trim())return{valid:!1,error:"required"};try{return bu.CronExpressionParser.parse(t),{valid:!0}}catch(e){return{valid:!1,error:e instanceof Error?e.message:"Invalid cron expression"}}}function Wk(t,e,n=4){try{const r=e?{tz:e,currentDate:new Date}:{currentDate:new Date},i=bu.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 zk=[{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"}],Vk={"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"},qn=t=>Vk[t]??t,Sm=[0,1,2,3,4,5,6],Bc="flex h-6 w-6 cursor-pointer items-center justify-center text-foreground transition-none outline-none focus:outline-none flex-shrink-0",ma=typeof Intl<"u"&&typeof Intl.supportedValuesOf=="function"?[...new Set(Intl.supportedValuesOf("timeZone").map(qn))]:["UTC","Europe/Kyiv","Europe/London","Europe/Berlin","America/New_York","America/Los_Angeles","Asia/Tokyo"],Fc=()=>{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}`},Po=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},_c=t=>{const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`},Uk=(t,e,n)=>{const r=Po(t);return r?new Intl.DateTimeFormat(n,{month:"short",day:"numeric",year:"numeric"}).format(r):e},Lc=(t,e)=>new Date(t.getFullYear(),t.getMonth()+e,1),Kk=(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(),u=new Date(n,r,0).getDate(),d=[];for(let h=0;h<42;h+=1){const f=h-l+1;if(f<=0){const g=u+f;d.push({date:new Date(n,r-1,g),inCurrentMonth:!1});continue}if(f>a){d.push({date:new Date(n,r+1,f-a),inCurrentMonth:!1});continue}d.push({date:new Date(n,r,f),inCurrentMonth:!0})}return d},Hk=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}},Vn=(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")}`},vr=(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"},$c=t=>/^(0[1-9]|1[0-2])$/.test(t)?t:vr(t,{min:1,max:12}),po=t=>/^[0-5][0-9]$/.test(t)?t:vr(t,{max:59}),Gk=(t,e)=>vr(String(Number.parseInt(t,10)+e),{min:1,max:12,loop:!0}),Wc=(t,e)=>vr(String(Number.parseInt(t,10)+e),{min:0,max:59,loop:!0}),qk=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}},Qk=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}},Yk=t=>{const e=new Intl.DateTimeFormat(t,{weekday:"short"}),n=new Date(2023,0,1);return Sm.map(r=>e.format(new Date(n.getFullYear(),n.getMonth(),n.getDate()+r)))},Xk=(t,e)=>[...t.slice(e),...t.slice(0,e)],Rs=t=>{const e=Xe.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},zc=t=>{const e=Xe.c(84),{value:n,onChange:r,use24Hour:i,hourAriaLabel:o,minuteAriaLabel:l,periodAriaLabel:a,amLabel:u,pmLabel:d}=t;let h;e[0]!==n?(h=Hk(n),e[0]=n,e[1]=h):h=e[1];const f=h,g=rt.useRef(null),p=rt.useRef(null),[w,v]=rt.useState(null),[x,m]=rt.useState(null),b=rt.useRef(null),y=rt.useRef(null);let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=q=>{b.current=q,v(q)},e[2]=S):S=e[2];const N=S;let C;e[3]===Symbol.for("react.memo_cache_sentinel")?(C=q=>{y.current=q,m(q)},e[3]=C):C=e[3];const k=C,A=r4,P=o4,D=i4;let M;e[4]!==r||e[5]!==f.meridiem||e[6]!==f.minute||e[7]!==i?(M=q=>{const De=q.replace(/\D/g,"").slice(0,2);N(De),De.length===2&&(r(i?D(A(De),f.minute):Vn($c(De),f.minute,f.meridiem)),N(null),p.current?.focus())},e[4]=r,e[5]=f.meridiem,e[6]=f.minute,e[7]=i,e[8]=M):M=e[8];const $=M;let R;e[9]!==r||e[10]!==f.meridiem||e[11]!==f.minute||e[12]!==i?(R=()=>{const q=b.current;if(q!==null&&(N(null),q.length!==0)){if(i){r(D(A(q.padStart(2,"0")),f.minute));return}r(Vn($c(q.padStart(2,"0")),f.minute,f.meridiem))}},e[9]=r,e[10]=f.meridiem,e[11]=f.minute,e[12]=i,e[13]=R):R=e[13];const K=R;let L;e[14]!==r||e[15]!==f.hour12||e[16]!==f.hour24||e[17]!==f.meridiem||e[18]!==i?(L=q=>{const De=q.replace(/\D/g,"").slice(0,2);k(De),De.length===2&&(r(i?D(f.hour24,po(De)):Vn(f.hour12,po(De),f.meridiem)),k(null))},e[14]=r,e[15]=f.hour12,e[16]=f.hour24,e[17]=f.meridiem,e[18]=i,e[19]=L):L=e[19];const O=L;let I;e[20]!==r||e[21]!==f.hour12||e[22]!==f.hour24||e[23]!==f.meridiem||e[24]!==i?(I=()=>{const q=y.current;q!==null&&(k(null),q.length!==0&&r(i?D(f.hour24,po(q.padStart(2,"0"))):Vn(f.hour12,po(q.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]=I):I=e[25];const j=I;let T;e[26]!==r||e[27]!==f.hour12||e[28]!==f.hour24||e[29]!==f.meridiem||e[30]!==f.minute||e[31]!==i?(T=q=>r(i?D(P(f.hour24,q),f.minute):Vn(Gk(f.hour12,q),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]=T):T=e[32];const F=T;let U;e[33]!==r||e[34]!==f.hour12||e[35]!==f.hour24||e[36]!==f.meridiem||e[37]!==f.minute||e[38]!==i?(U=q=>r(i?D(f.hour24,Wc(f.minute,q)):Vn(f.hour12,Wc(f.minute,q),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]=U):U=e[39];const H=U;let Y;e[40]!==r||e[41]!==f.hour12||e[42]!==f.meridiem||e[43]!==f.minute?(Y=q=>{q!==f.meridiem&&r(Vn(f.hour12,f.minute,q))},e[40]=r,e[41]=f.hour12,e[42]=f.meridiem,e[43]=f.minute,e[44]=Y):Y=e[44];const me=Y;let Z;e[45]!==K||e[46]!==F?(Z=q=>{if(q.key==="ArrowRight"){q.preventDefault(),K(),p.current?.focus();return}(q.key==="ArrowUp"||q.key==="ArrowDown")&&(q.preventDefault(),N(null),F(q.key==="ArrowUp"?1:-1))},e[45]=K,e[46]=F,e[47]=Z):Z=e[47];const re=Z;let se;e[48]!==j||e[49]!==H?(se=q=>{if(q.key==="ArrowLeft"&&(q.currentTarget.selectionStart??0)===0){q.preventDefault(),j(),g.current?.focus();return}(q.key==="ArrowUp"||q.key==="ArrowDown")&&(q.preventDefault(),k(null),H(q.key==="ArrowUp"?1:-1))},e[48]=j,e[49]=H,e[50]=se):se=e[50];const fe=se,_=i?"px-2":"pl-2 pr-1";let le;e[51]!==_?(le=Re("inline-flex h-9 w-fit items-center gap-1 rounded-md border border-border bg-background focus-within:ring-1 focus-within:ring-interactive-focusRing focus-within:border-interactive-focusRing",_),e[51]=_,e[52]=le):le=e[52];const ee=w??(i?f.hour24:f.hour12);let ue;e[53]!==$?(ue=q=>$(q.target.value),e[53]=$,e[54]=ue):ue=e[54];let W;e[55]===Symbol.for("react.memo_cache_sentinel")?(W=()=>N(""),e[55]=W):W=e[55];let ne;e[56]!==K||e[57]!==o||e[58]!==re||e[59]!==ee||e[60]!==ue?(ne=s.jsx("input",{ref:g,inputMode:"numeric",value:ee,onChange:ue,onKeyDown:re,onFocus:W,onBlur:K,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]=K,e[57]=o,e[58]=re,e[59]=ee,e[60]=ue,e[61]=ne):ne=e[61];let pe;e[62]===Symbol.for("react.memo_cache_sentinel")?(pe=s.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:":"}),e[62]=pe):pe=e[62];const xe=x??f.minute;let Ce;e[63]!==O?(Ce=q=>O(q.target.value),e[63]=O,e[64]=Ce):Ce=e[64];let Me;e[65]===Symbol.for("react.memo_cache_sentinel")?(Me=()=>k(""),e[65]=Me):Me=e[65];let ve;e[66]!==j||e[67]!==l||e[68]!==fe||e[69]!==xe||e[70]!==Ce?(ve=s.jsx("input",{ref:p,inputMode:"numeric",value:xe,onChange:Ce,onKeyDown:fe,onFocus:Me,onBlur:j,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]=j,e[67]=l,e[68]=fe,e[69]=xe,e[70]=Ce,e[71]=ve):ve=e[71];let Ie;e[72]!==u||e[73]!==f.meridiem||e[74]!==a||e[75]!==d||e[76]!==me||e[77]!==i?(Ie=i?null:s.jsxs(Ms,{value:f.meridiem,onValueChange:q=>me(q),children:[s.jsx(Os,{"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(Ns,{})}),s.jsxs(Bs,{children:[s.jsx(ts,{value:"AM",children:u}),s.jsx(ts,{value:"PM",children:d})]})]}),e[72]=u,e[73]=f.meridiem,e[74]=a,e[75]=d,e[76]=me,e[77]=i,e[78]=Ie):Ie=e[78];let ye;return e[79]!==le||e[80]!==ne||e[81]!==ve||e[82]!==Ie?(ye=s.jsxs("div",{className:le,children:[ne,pe,ve,Ie]}),e[79]=le,e[80]=ne,e[81]=ve,e[82]=Ie,e[83]=ye):ye=e[83],ye},Vc=t=>new Date(t.getFullYear(),t.getMonth(),1),Jk=()=>{const t=new Date;return new Date(t.getFullYear(),t.getMonth(),t.getDate())},Uc=(t,e)=>t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate(),Zk=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"]},Kc=(t,e)=>{const n=qn(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:Zk(t),onceDate:typeof t.schedule.date=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t.schedule.date)?t.schedule.date:Fc(),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:qn(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:Fc(),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}}},e4=(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(!wm(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")},t4=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))},s4=t=>{const e=Xe.c(64),{draft:n,setDraft:r,locale:i,t:o}=t,l=n.schedule.cronExpression;let a;e[0]!==l?(a=l.trim()?wm(l):null,e[0]=l,e[1]=a):a=e[1];const u=a;let d;e:{if(!u?.valid||!l.trim()){let T;e[2]===Symbol.for("react.memo_cache_sentinel")?(T=[],e[2]=T):T=e[2],d=T;break e}let j;e[3]!==l||e[4]!==n.schedule.timezone?(j=Wk(l,n.schedule.timezone),e[3]=l,e[4]=n.schedule.timezone,e[5]=j):j=e[5],d=j}const h=d;let f;e[6]!==n.schedule.timezone||e[7]!==i?(f=j=>new Intl.DateTimeFormat(i,{timeZone:n.schedule.timezone,month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(j),e[6]=n.schedule.timezone,e[7]=i,e[8]=f):f=e[8];const g=f;let p;e[9]!==o?(p=o("sessions.scheduledTasks.editor.cronExpression.label"),e[9]=o,e[10]=p):p=e[10];let w;e[11]!==p?(w=s.jsx(Rs,{htmlFor:"sched-cron",required:!0,children:p}),e[11]=p,e[12]=w):w=e[12];let v;e[13]!==r?(v=j=>r(T=>({...T,schedule:{...T.schedule,cronExpression:j.target.value}})),e[13]=r,e[14]=v):v=e[14];let x;e[15]!==o?(x=o("sessions.scheduledTasks.editor.cronExpression.placeholder"),e[15]=o,e[16]=x):x=e[16];let m;e[17]!==l||e[18]!==v||e[19]!==x?(m=s.jsx(kn,{id:"sched-cron",value:l,onChange:v,placeholder:x,className:"w-full max-w-xs font-mono"}),e[17]=l,e[18]=v,e[19]=x,e[20]=m):m=e[20];let b;e[21]!==l||e[22]!==u||e[23]!==o?(b=u&&!u.valid&&l.trim()?s.jsx("span",{className:"typography-micro text-destructive",children:o("sessions.scheduledTasks.editor.validation.cronInvalid")}):null,e[21]=l,e[22]=u,e[23]=o,e[24]=b):b=e[24];let y;e[25]!==w||e[26]!==m||e[27]!==b?(y=s.jsxs("div",{className:"flex flex-col gap-1",children:[w,m,b]}),e[25]=w,e[26]=m,e[27]=b,e[28]=y):y=e[28];let S;e[29]!==g||e[30]!==h||e[31]!==o?(S=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(g).join(", ")})]}):null,e[29]=g,e[30]=h,e[31]=o,e[32]=S):S=e[32];let N;e[33]!==o?(N=o("sessions.scheduledTasks.editor.cronExpression.examples"),e[33]=o,e[34]=N):N=e[34];let C;e[35]!==N?(C=s.jsx("span",{className:"typography-meta text-muted-foreground",children:N}),e[35]=N,e[36]=C):C=e[36];let k;e[37]!==r||e[38]!==o?(k=zk.map(j=>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(T=>({...T,schedule:{...T.schedule,cronExpression:j.expression}})),children:[s.jsx("span",{className:"font-mono",children:j.expression}),s.jsx("span",{className:"text-muted-foreground",children:o(j.labelKey)})]},j.expression)),e[37]=r,e[38]=o,e[39]=k):k=e[39];let A;e[40]!==k?(A=s.jsx("div",{className:"flex flex-wrap gap-1.5",children:k}),e[40]=k,e[41]=A):A=e[41];let P;e[42]!==C||e[43]!==A?(P=s.jsxs("div",{className:"flex flex-col gap-1",children:[C,A]}),e[42]=C,e[43]=A,e[44]=P):P=e[44];let D;e[45]!==o?(D=o("sessions.scheduledTasks.editor.timezone.label"),e[45]=o,e[46]=D):D=e[46];let M;e[47]!==D?(M=s.jsx(Rs,{children:D}),e[47]=D,e[48]=M):M=e[48];let $;e[49]!==r?($=j=>{r(T=>({...T,schedule:{...T.schedule,timezone:j}}))},e[49]=r,e[50]=$):$=e[50];let R;e[51]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx(Os,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ns,{})}),e[51]=R):R=e[51];let K;e[52]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx(Bs,{children:ma.map(a4)}),e[52]=K):K=e[52];let L;e[53]!==n.schedule.timezone||e[54]!==$?(L=s.jsxs(Ms,{value:n.schedule.timezone,onValueChange:$,children:[R,K]}),e[53]=n.schedule.timezone,e[54]=$,e[55]=L):L=e[55];let O;e[56]!==M||e[57]!==L?(O=s.jsxs("div",{className:"flex flex-col gap-1",children:[M,L]}),e[56]=M,e[57]=L,e[58]=O):O=e[58];let I;return e[59]!==y||e[60]!==S||e[61]!==P||e[62]!==O?(I=s.jsxs("div",{className:"flex flex-col gap-3",children:[y,S,P,O]}),e[59]=y,e[60]=S,e[61]=P,e[62]=O,e[63]=I):I=e[63],I};function n4(t){const{open:e,task:n,onOpenChange:r,onSave:i}=t,{t:o,locale:l}=pt(),a=Kt(B=>B.loadProviders),u=Kt(B=>B.loadAgents),d=Kt(B=>B.providers),h=Kt(B=>B.currentProviderId),f=Kt(B=>B.currentModelId),g=Kt(B=>B.currentVariant||""),p=Kt(B=>B.currentAgentName||""),w=Te(B=>B.timeFormatPreference),v=Te(B=>B.weekStartPreference),x=Te(B=>B.isMobile),[m,b]=rt.useState(()=>Kc(n,{providerID:h,modelID:f,variant:g,agent:p})),[y,S]=rt.useState(!1),[N,C]=rt.useState(!1),[k,A]=rt.useState(!1),[P,D]=rt.useState(""),[M,$]=rt.useState(!1),[R,K]=rt.useState(""),[L,O]=rt.useState(!1),[I,j]=rt.useState(""),[T,F]=rt.useState(()=>{const B=Po(n?.schedule?.date||"")||new Date;return new Date(B.getFullYear(),B.getMonth(),1)}),U=rt.useRef(null),H=rt.useRef(null),Y=rt.useRef(null),me=rt.useRef(null),Z=rt.useRef(null),re=rt.useMemo(()=>Qk(l),[l]),se=rt.useMemo(()=>qk(l),[l]),fe=rt.useMemo(()=>w==="24h"?!0:w==="12h"?!1:re,[w,re]),_=rt.useMemo(()=>v==="sunday"?0:v==="monday"?1:se,[v,se]),le=rt.useMemo(()=>{const B=Yk(l);return Xk(Sm.map(ce=>({value:ce,label:B[ce]||""})),_)},[l,_]);rt.useEffect(()=>{e&&(a({source:"scheduledTaskEditor"}),u({source:"scheduledTaskEditor"}))},[e,a,u]),rt.useEffect(()=>{if(!e)return;b(Kc(n,{providerID:h,modelID:f,variant:g,agent:p}));const B=Po(n?.schedule?.date||"")||new Date;F(new Date(B.getFullYear(),B.getMonth(),1)),C(!1),$(!1),A(!1),K(""),D("")},[e,n,h,f,g,p]),rt.useEffect(()=>{if(!N)return;const B=ce=>{U.current&&!U.current.contains(ce.target)&&C(!1)};return document.addEventListener("mousedown",B),()=>{document.removeEventListener("mousedown",B)}},[N]);const ee=rt.useMemo(()=>{const ce=d.find(be=>be.id===m.execution.providerID)?.models?.find(be=>be.id===m.execution.modelID);return ce?.variants?Object.keys(ce.variants):[]},[d,m.execution.providerID,m.execution.modelID]),ue=ee.length>0,W=rt.useMemo(()=>!ue||!m.execution.variant?"__default":ee.includes(m.execution.variant)?m.execution.variant:"__default",[m.execution.variant,ue,ee]);rt.useEffect(()=>{ue||!m.execution.variant||b(B=>({...B,execution:{...B.execution,variant:""}}))},[ue,m.execution.variant]);const ne=rt.useCallback((B,ce)=>{b(be=>{const ge=new Set(be.schedule.weekdays);return ce?ge.add(B):ge.delete(B),{...be,schedule:{...be.schedule,weekdays:Array.from(ge).sort((_e,tt)=>_e-tt)}}})},[]),pe=rt.useCallback((B,ce)=>{b(be=>{const ge=be.schedule.times.slice();return ge[B]=ce,{...be,schedule:{...be.schedule,times:ge}}})},[]),xe=rt.useCallback(B=>{b(ce=>{const be=ce.schedule.times.filter((ge,_e)=>_e!==B);return{...ce,schedule:{...ce.schedule,times:be.length>0?be:["09:00"]}}})},[]),Ce=rt.useCallback(()=>{b(B=>({...B,schedule:{...B.schedule,times:[...B.schedule.times,"12:00"]}}))},[]),Me=rt.useMemo(()=>Jk(),[]),ve=rt.useMemo(()=>Vc(Me),[Me]),Ie=rt.useMemo(()=>{const B=Po(m.schedule.onceDate);return B?Uc(B,Me)?o("sessions.scheduledTasks.editor.date.today"):new Intl.DateTimeFormat(l,{weekday:"short"}).format(B):null},[m.schedule.onceDate,l,o,Me]),ye=rt.useMemo(()=>Vc(T).getTime()<=ve.getTime(),[T,ve]),q=rt.useMemo(()=>le.map(B=>B.label),[le]),De=rt.useCallback(B=>{b(ce=>({...ce,schedule:{...ce.schedule,onceDate:B}}))},[]),ke=rt.useCallback((B,ce)=>{if(B.startsWith("/")){const tt=B.indexOf(" "),Ue=B.indexOf(`
|
|
922
|
-
`),de=Math.min(tt===-1?B.length:tt,Ue===-1?B.length:Ue);if(ce<=de&&tt===-1){K(B.substring(1,de)),$(!0),A(!1),O(!1);return}}$(!1);const be=B.substring(0,ce),ge=be.lastIndexOf("#");if(ge!==-1){const tt=ge>0?be[ge-1]:null,Ue=be.substring(ge+1);if((!tt||/\s/.test(tt))&&!Ue.includes(" ")&&!Ue.includes(`
|
|
923
|
-
`)){j(Ue),O(!0),A(!1);return}}O(!1);const _e=be.lastIndexOf("@");if(_e!==-1){const tt=_e>0?be[_e-1]:null,Ue=be.substring(_e+1);(!tt||/\s/.test(tt))&&!Ue.includes(" ")&&!Ue.includes(`
|
|
924
|
-
`)?(D(Ue),A(!0)):A(!1);return}A(!1)},[]),te=rt.useCallback(B=>{b(ce=>({...ce,execution:{...ce.execution,prompt:B}}))},[]),he=rt.useCallback(B=>{const ce=m.execution.prompt,ge=H.current?.selectionStart??ce.length,tt=ce.substring(0,ge).lastIndexOf("@"),Ue=B.relativePath&&B.relativePath.trim().length>0?B.relativePath.trim():B.path||B.name,de=tt!==-1?tt:ge,X=`${ce.substring(0,de)}@${Ue} ${ce.substring(ge)}`,we=de+Ue.length+2;te(X),A(!1),D(""),requestAnimationFrame(()=>{const ze=H.current;ze&&(ze.selectionStart=we,ze.selectionEnd=we,ze.focus()),ke(X,we)})},[m.execution.prompt,te,ke]),ae=rt.useCallback(B=>{const ce=m.execution.prompt,ge=H.current?.selectionStart??ce.length,tt=ce.substring(0,ge).lastIndexOf("@"),Ue=tt!==-1?tt:ge,de=`${ce.substring(0,Ue)}@${B} ${ce.substring(ge)}`,X=Ue+B.length+2;te(de),A(!1),D(""),requestAnimationFrame(()=>{const we=H.current;we&&(we.selectionStart=X,we.selectionEnd=X,we.focus()),ke(de,X)})},[m.execution.prompt,te,ke]),Q=rt.useCallback(B=>{const ce=`/${B.name} `;te(ce),$(!1),K(""),O(!1),requestAnimationFrame(()=>{const be=H.current;be&&(be.focus(),be.selectionStart=be.value.length,be.selectionEnd=be.value.length),ke(ce,ce.length)})},[te,ke]),z=rt.useCallback((B,ce)=>{const be=m.execution.prompt,_e=H.current?.selectionStart??be.length,Ue=be.substring(0,_e).lastIndexOf("#"),de=Ue!==-1?Ue:_e,X=`${be.substring(0,de)}#${ce} ${be.substring(_e)}`,we=de+ce.length+2;te(X),O(!1),j(""),requestAnimationFrame(()=>{const ze=H.current;ze&&(ze.selectionStart=we,ze.selectionEnd=we,ze.focus()),ke(X,we)})},[m.execution.prompt,te,ke]),G=rt.useCallback(B=>{if(M&&me.current&&(B.key==="Enter"||B.key==="ArrowUp"||B.key==="ArrowDown"||B.key==="Escape"||B.key==="Tab")){B.preventDefault(),me.current.handleKeyDown(B.key);return}k&&Y.current&&(B.key==="Enter"||B.key==="ArrowUp"||B.key==="ArrowDown"||B.key==="Escape"||B.key==="Tab")&&(B.preventDefault(),Y.current.handleKeyDown(B.key)),L&&Z.current&&(B.key==="Enter"||B.key==="ArrowUp"||B.key==="ArrowDown"||B.key==="Escape"||B.key==="Tab")&&(B.preventDefault(),Z.current.handleKeyDown(B.key))},[M,k,L]),ie=rt.useCallback(async()=>{const B=e4(m,o);if(B){Be.error(B);return}const ce={...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:t4(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}:{}};S(!0);try{await i(ce),r(!1)}catch(be){Be.error(be instanceof Error?be.message:o("sessions.scheduledTasks.editor.toast.saveFailed"))}finally{S(!1)}},[m,r,i,o]),Oe=rt.useId(),Fe=rt.useCallback(()=>typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]'),[]),Se=o(n?"sessions.scheduledTasks.editor.title.edit":"sessions.scheduledTasks.editor.title.new"),oe=o("sessions.scheduledTasks.editor.description"),Pe=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(Rs,{htmlFor:"sched-name",required:!0,children:o("sessions.scheduledTasks.editor.taskName.label")}),s.jsx(kn,{id:"sched-name",value:m.name,onChange:B=>b(ce=>({...ce,name:B.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(Rs,{children:o("sessions.scheduledTasks.editor.scheduleType.label")}),s.jsxs(Ms,{value:m.schedule.kind,onValueChange:B=>{b(ce=>({...ce,schedule:{...ce.schedule,kind:B,...B==="cron"&&!ce.schedule.cronExpression?{cronExpression:"0 * * * *"}:{}}}))},children:[s.jsx(Os,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ns,{children:B=>o(B==="daily"?"sessions.scheduledTasks.editor.scheduleType.daily":B==="weekly"?"sessions.scheduledTasks.editor.scheduleType.weekly":B==="cron"?"sessions.scheduledTasks.editor.scheduleType.cron":"sessions.scheduledTasks.editor.scheduleType.once")})}),s.jsxs(Bs,{children:[s.jsx(ts,{value:"daily",children:o("sessions.scheduledTasks.editor.scheduleType.daily")}),s.jsx(ts,{value:"weekly",children:o("sessions.scheduledTasks.editor.scheduleType.weekly")}),s.jsx(ts,{value:"once",children:o("sessions.scheduledTasks.editor.scheduleType.once")}),s.jsx(ts,{value:"cron",children:o("sessions.scheduledTasks.editor.scheduleType.cron")})]})]})]})]}),m.schedule.kind==="cron"?s.jsx(s4,{draft:m,setDraft:b,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:U,children:[s.jsx(Rs,{children:o("sessions.scheduledTasks.editor.date.label")}),s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",className:Re($d({size:"default"}),"w-fit max-w-full"),onClick:()=>C(B=>!B),children:[s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(E,{name:"calendar",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:Uk(m.schedule.onceDate,o("sessions.scheduledTasks.editor.date.placeholder"),l)})]}),s.jsx(E,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"})]}),N?s.jsxs("div",{className:"absolute left-0 top-[calc(100%+6px)] z-50 w-[288px] rounded-xl border border-border bg-background 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:()=>F(B=>Lc(B,-1)),"aria-label":o("sessions.scheduledTasks.editor.date.previousMonth"),disabled:ye,children:s.jsx(E,{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(T)}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover",onClick:()=>F(B=>Lc(B,1)),"aria-label":o("sessions.scheduledTasks.editor.date.nextMonth"),children:s.jsx(E,{name:"arrow-right-s",className:"h-4 w-4"})})]}),s.jsx("div",{className:"mb-1 grid grid-cols-7 gap-1 px-1",children:q.map((B,ce)=>s.jsx("div",{className:"py-1 text-center typography-micro text-muted-foreground",children:B},`${B}-${ce}`))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:Kk(T,_).map(({date:B,inCurrentMonth:ce})=>{const be=_c(B),ge=be===m.schedule.onceDate,_e=Uc(B,Me),tt=B.getTime()<Me.getTime(),Ue=ge?"bg-interactive-selection text-interactive-selection-foreground":tt?"text-muted-foreground/40":ce?"text-foreground hover:bg-interactive-hover":"text-muted-foreground/60 hover:bg-interactive-hover";return s.jsx("button",{type:"button",onClick:()=>{tt||(De(be),C(!1))},disabled:tt,className:["h-8 rounded-md typography-ui-label",Ue,_e&&!ge?"ring-1 ring-inset ring-interactive-focusRing bg-interactive-hover/50":"",tt?"cursor-not-allowed opacity-45":""].join(" "),children:B.getDate()},be)})}),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:Ie||""}),s.jsx(ot,{type:"button",size:"xs",variant:"ghost",onClick:()=>{De(_c(Me)),F(new Date(Me.getFullYear(),Me.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(Rs,{children:o("sessions.scheduledTasks.editor.time.label")}),s.jsx(zc,{value:m.schedule.onceTime,use24Hour:fe,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:B=>b(ce=>({...ce,schedule:{...ce.schedule,onceTime:B}}))}),s.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[s.jsx(Rs,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Ms,{value:m.schedule.timezone,onValueChange:B=>{b(ce=>({...ce,schedule:{...ce.schedule,timezone:B}}))},children:[s.jsx(Os,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ns,{})}),s.jsx(Bs,{children:ma.map(B=>s.jsx(ts,{value:B,children:B},B))})]})]})]})]}):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(Rs,{children:o("sessions.scheduledTasks.editor.weekdays.label")}),s.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-2",children:le.map(B=>{const ce=m.schedule.weekdays.includes(B.value);return s.jsxs("div",{className:["group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta",ce?"text-foreground":"text-muted-foreground"].join(" "),children:[s.jsx(ur,{checked:ce,onChange:be=>ne(B.value,be),ariaLabel:B.label}),s.jsx("button",{type:"button",onClick:()=>ne(B.value,!ce),className:"group-hover:text-foreground",children:B.label})]},B.value)})})]}):null,s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Rs,{children:o("sessions.scheduledTasks.editor.times.label")}),s.jsx("div",{className:"flex flex-col gap-2",children:m.schedule.times.map((B,ce)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(zc,{value:B,use24Hour:fe,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:be=>pe(ce,be)}),m.schedule.times.length>1?s.jsx(ot,{type:"button",size:"icon",variant:"ghost",onClick:()=>xe(ce),"aria-label":o("sessions.scheduledTasks.editor.times.removeAria"),children:s.jsx(E,{name:"close",className:"h-4 w-4"})}):null]},ce))}),s.jsx("div",{children:s.jsxs(ot,{type:"button",size:"sm",variant:"outline",onClick:Ce,children:[s.jsx(E,{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(Rs,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Ms,{value:m.schedule.timezone,onValueChange:B=>{b(ce=>({...ce,schedule:{...ce.schedule,timezone:B}}))},children:[s.jsx(Os,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ns,{})}),s.jsx(Bs,{children:ma.map(B=>s.jsx(ts,{value:B,children:B},B))})]})]})]}),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(Rs,{required:!0,children:o("sessions.scheduledTasks.editor.model.label")}),s.jsx(Uh,{providerId:m.execution.providerID,modelId:m.execution.modelID,onChange:(B,ce)=>{b(be=>({...be,execution:{...be.execution,providerID:B,modelID:ce,variant:""}}))}})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Rs,{children:o("sessions.scheduledTasks.editor.thinkingLevel.label")}),s.jsxs(Ms,{value:W,disabled:!ue,onValueChange:B=>{b(ce=>({...ce,execution:{...ce.execution,variant:B==="__default"?"":B}}))},children:[s.jsx(Os,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ns,{children:B=>B==="__default"?o("sessions.scheduledTasks.editor.thinkingLevel.default"):B})}),s.jsxs(Bs,{children:[s.jsx(ts,{value:"__default",children:o("sessions.scheduledTasks.editor.thinkingLevel.default")}),ee.map(B=>s.jsx(ts,{value:B,children:B},B))]})]})]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Rs,{children:o("sessions.scheduledTasks.editor.agent.label")}),s.jsx(Kh,{agentName:m.execution.agent,filter:B=>Ld(B.mode),onChange:B=>b(ce=>({...ce,execution:{...ce.execution,agent:B}}))})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Rs,{htmlFor:"sched-prompt",required:!0,children:o("sessions.scheduledTasks.editor.prompt.label")}),s.jsxs("div",{className:"relative",children:[s.jsx(lr,{id:"sched-prompt",ref:H,value:m.execution.prompt,onChange:B=>{const ce=B.target.value;te(ce);const be=B.target.selectionStart??ce.length;ke(ce,be)},onKeyDown:G,rows:8,placeholder:o("sessions.scheduledTasks.editor.prompt.placeholder"),className:"typography-meta min-h-[120px] max-h-[300px] resize-none overflow-y-auto"}),M?s.jsx(Gd,{ref:me,searchQuery:R,onCommandSelect:Q,onClose:()=>$(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,k?s.jsx(qd,{ref:Y,searchQuery:P,onFileSelect:he,onAgentSelect:ae,onClose:()=>A(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,L?s.jsx(Qd,{ref:Z,searchQuery:I,onSnippetSelect:z,onClose:()=>O(!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(ur,{checked:m.execution.goalTokenBudget!==null,onChange:B=>b(ce=>({...ce,execution:{...ce.execution,goalTokenBudget:B?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(Hh,{value:m.execution.goalTokenBudget,onValueChange:B=>{typeof B=="number"&&Number.isFinite(B)&&B>0&&b(ce=>({...ce,execution:{...ce.execution,goalTokenBudget:Math.floor(B)}}))},min:1e3,max:1e8,step:5e4}):null]}):null]}),Ne=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(ur,{checked:m.enabled,onChange:B=>b(ce=>({...ce,enabled:B})),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(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",className:Re(Bc),onClick:()=>b(B=>({...B,execution:{...B.execution,permissionAutoAccept:!B.execution.permissionAutoAccept}})),"aria-pressed":m.execution.permissionAutoAccept,"aria-label":o("sessions.scheduledTasks.editor.permissionAutoAccept.aria"),children:m.execution.permissionAutoAccept?s.jsx(E,{name:"shield-check",className:"h-[18px] w-[18px]",style:{color:"var(--status-info)"},"aria-hidden":"true"}):s.jsx(E,{name:"shield-user",className:"h-[18px] w-[18px]","aria-hidden":"true"})})}),s.jsx(yt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.permissionAutoAccept.label")})]}),s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",className:Re(Bc,m.execution.goalEnabled&&"text-[var(--status-info)]"),onClick:()=>b(B=>({...B,execution:{...B.execution,goalEnabled:!B.execution.goalEnabled}})),"aria-pressed":m.execution.goalEnabled,"aria-label":o("sessions.scheduledTasks.editor.goal.aria"),children:m.execution.goalEnabled?s.jsx(E,{name:"target-fill",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"}):s.jsx(E,{name:"target",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"})})}),s.jsx(yt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.goal.label")})]}),s.jsx(ot,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:y,children:o("sessions.scheduledTasks.editor.actions.cancel")}),s.jsx(ot,{type:"button",size:"sm",onClick:ie,disabled:y,children:o(y?"sessions.scheduledTasks.editor.actions.saving":"sessions.scheduledTasks.editor.actions.save")})]})]});return x?s.jsx(Zo,{open:e,title:Se,onClose:()=>r(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:B=>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:Se}),B]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:oe})]}),footer:Ne,children:Pe}):s.jsx(Ss,{open:e,onOpenChange:B=>{!B&&Fe()||r(B)},children:s.jsxs(vs,{"aria-describedby":Oe,className:"!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden",children:[s.jsx(Is,{id:Oe,className:"sr-only",children:oe}),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(Ts,{className:"typography-ui-label font-medium text-foreground",children:Se}),s.jsx("p",{className:"typography-meta mt-0.5 text-muted-foreground",children:oe})]})}),s.jsx(ka,{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:Pe})}),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:Ne})})]})})}function r4(t){return vr(t,{min:0,max:23})}function o4(t,e){return vr(String(Number.parseInt(t,10)+e),{min:0,max:23,loop:!0})}function i4(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 a4(t){return s.jsx(ts,{value:t,children:t},t)}const l4=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))},c4=(t,e)=>{const n=l4(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:qn(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:qn(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:qn(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:qn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.cron",{cron:t.schedule.cron||""})},d4=(t,e)=>!t||!Number.isFinite(t)?"":Gh(t,e),Hc=(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),g=Math.round(r%o/i),p=g>0?`${f}h ${g}m`:`${f}h`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:p}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:p})}const u=Math.floor(r/l),d=Math.round(r%l/o),h=d>0?`${u}d ${d}h`:`${u}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"}},m4=t=>({color:`var(--status-${t})`,backgroundColor:`var(--status-${t}-background)`,borderColor:`var(--status-${t}-border)`});function f4(){const{t}=pt(),e=Te(j=>j.isScheduledTasksDialogOpen),n=Te(j=>j.setScheduledTasksDialogOpen),r=Te(j=>j.isMobile),i=Te(j=>j.timeFormatPreference),o=zt(j=>j.projects),l=zt(j=>j.getActiveProject()),a=es(j=>j.homeDirectory),{currentTheme:u}=er(),[d,h]=rt.useState(""),[f,g]=rt.useState([]),[p,w]=rt.useState(!0),[v,x]=rt.useState(!1),[m,b]=rt.useState(null),[y,S]=rt.useState(null),N=rt.useMemo(()=>o.find(j=>j.id===d)||null,[o,d]),C=rt.useCallback(j=>{const T=j.label?.trim()||Fn(j.path,a||void 0),F=j.icon?Pa[j.icon]:null,U=j.color?Da[j.color]:void 0,H=F?s.jsx(E,{name:F,className:"h-3.5 w-3.5 shrink-0",style:U?{color:U}:void 0}):s.jsx(E,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:U?{color:U}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[j.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:j.iconBackground?{backgroundColor:j.iconBackground}:void 0,children:s.jsx(Ta,{project:{id:j.id,iconImage:j.iconImage??null},options:{themeVariant:u.metadata.variant,iconColor:u.colors.surface.foreground},className:"h-full w-full object-contain",fallback:H})}):H,s.jsx("span",{className:"truncate",children:T})]})},[a,u.metadata.variant,u.colors.surface.foreground]),k=rt.useCallback(async(j,T)=>{if(!j){g([]);return}T?.silent||w(!0);try{const F=await yg(j);F.sort((U,H)=>{if(U.enabled!==H.enabled)return U.enabled?-1:1;const Y=U.name.localeCompare(H.name);return Y!==0?Y:(U.state?.nextRunAt||Number.MAX_SAFE_INTEGER)-(H.state?.nextRunAt||Number.MAX_SAFE_INTEGER)}),g(F)}catch(F){Be.error(F instanceof Error?F.message:t("sessions.scheduledTasks.dialog.toast.loadFailed")),T?.silent||g([])}finally{T?.silent||w(!1)}},[t]);rt.useEffect(()=>{if(!e)return;const j=l?.id||o[0]?.id||"";h(j),j?k(j):(g([]),w(!1))},[e,l,o,k]),rt.useEffect(()=>{if(!e)return;let j=null;const T=Jr(F=>{F.type==="scheduled-task-ran"&&F.projectId===d&&(j&&clearTimeout(j),j=setTimeout(()=>{k(d,{silent:!0})},400))});return()=>{j&&clearTimeout(j),T()}},[e,d,k]);const A=rt.useCallback(async j=>{if(!d)throw new Error(t("sessions.scheduledTasks.dialog.error.chooseProjectFirst"));await Al(d,j),await k(d),Be.success(t("sessions.scheduledTasks.dialog.toast.saved"))},[d,k,t]),P=rt.useCallback(async(j,T)=>{if(d){S(j.id),g(F=>F.map(U=>U.id===j.id?{...U,enabled:T}:U));try{j.loopFile?await wg(d,j.id,T):await Al(d,{...j,enabled:T}),await k(d,{silent:!0})}catch(F){Be.error(F instanceof Error?F.message:t("sessions.scheduledTasks.dialog.toast.updateFailed")),await k(d,{silent:!0})}finally{S(null)}}},[d,k,t]),D=rt.useCallback(async j=>{if(!(!d||!window.confirm(j.loopFile?t("sessions.scheduledTasks.dialog.confirm.deleteLoopFile",{taskName:j.name}):t("sessions.scheduledTasks.dialog.confirm.deleteTask",{taskName:j.name})))){S(j.id);try{j.loopFile?await Sg(d,j.id):await vg(d,j.id),await k(d,{silent:!0}),Be.success(t("sessions.scheduledTasks.dialog.toast.deleted"))}catch(F){Be.error(F instanceof Error?F.message:t("sessions.scheduledTasks.dialog.toast.deleteFailed"))}finally{S(null)}}},[d,k,t]),M=rt.useCallback(j=>{if(!j.loopFile){b(j),x(!0);return}N?.path&&(n(!1),un.getState().setSelectedPath(N.path,j.loopFile,{allowOutsideRoot:!0}),Te.getState().openContextFile(N.path,j.loopFile))},[N?.path,n]),$=rt.useCallback(async j=>{if(d){S(j.id);try{const{sessionId:T,persistError:F}=await jg(d,j.id);if(await Promise.all([k(d,{silent:!0}),Oa()]),F?Be.warning(t("sessions.scheduledTasks.dialog.toast.startedPersistWarning")):Be.success(t("sessions.scheduledTasks.dialog.toast.started")),T){const U=o.find(H=>H.id===d);Qe.getState().setCurrentSession(T,U?.path??null)}}catch(T){Be.error(T instanceof Error?T.message:t("sessions.scheduledTasks.dialog.toast.runFailed"))}finally{S(null)}}},[d,o,k,t]),R=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(Ms,{value:d||"__none",onValueChange:j=>{const T=j==="__none"?"":j;h(T),T?k(T):g([])},children:[s.jsx(Os,{size:"lg",className:r?"w-full":void 0,children:N?s.jsx(Ns,{children:C(N)}):s.jsx(Ns,{placeholder:t("sessions.scheduledTasks.dialog.project.placeholder")})}),s.jsxs(Bs,{children:[o.length===0?s.jsx(ts,{value:"__none",children:t("sessions.scheduledTasks.dialog.project.empty")}):null,o.map(j=>s.jsx(ts,{value:j.id,children:C(j)},j.id))]})]})]}),K=()=>{b(null),x(!0)},L=j=>{h(j),j?k(j):g([])},O=s.jsx("div",{className:"min-h-[280px]",children:p?s.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx(E,{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(d?"sessions.scheduledTasks.dialog.empty.noTasks":"sessions.scheduledTasks.dialog.empty.selectProject")}):s.jsx("div",{className:"space-y-2.5",children:f.map(j=>{const T=y===j.id,F=j.state?.lastStatus||"idle",U=u4[F],H=t(F==="success"?"sessions.scheduledTasks.dialog.status.success":F==="error"?"sessions.scheduledTasks.dialog.status.error":F==="running"?"sessions.scheduledTasks.dialog.status.running":"sessions.scheduledTasks.dialog.status.idle"),Y=j.state?.nextRunAt,me=j.state?.lastRunAt;return s.jsxs("div",{className:Re("rounded-lg border border-border p-4 transition-opacity",!j.enabled&&"opacity-60"),children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-header truncate font-semibold text-foreground",children:j.name}),s.jsx("div",{className:"typography-micro truncate text-muted-foreground",children:c4(j,t)}),j.loopFile?s.jsx("div",{className:"typography-micro truncate text-muted-foreground/70",title:j.loopFile,children:t("sessions.scheduledTasks.dialog.loopFile.note",{file:j.loopFile})}):null]}),s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-5 gap-y-1 typography-micro text-muted-foreground",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(E,{name:"timer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.nextRun.label")}),Y?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-foreground",children:Hc(Y,t)}),s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:d4(Y,i)})]}):s.jsx("span",{children:"—"})]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(E,{name:"history",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.lastRun.label")}),F==="running"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:"var(--status-warning)"},children:[s.jsx(E,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),t("sessions.scheduledTasks.dialog.lastRun.runningNow")]}):me?s.jsxs(s.Fragment,{children:[U.tone!=="muted"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:`var(--status-${U.tone})`},children:[s.jsx(E,{name:U.Icon,className:"h-3.5 w-3.5"}),H]}):null,s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:Hc(me,t)})]}):s.jsx("span",{children:t("sessions.scheduledTasks.dialog.lastRun.never")})]})]}),j.state?.lastError?s.jsxs("div",{className:"mt-3 flex items-start gap-2 rounded-md border p-2 typography-micro",style:m4("error"),children:[s.jsx(E,{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:j.state.lastError})]}):null,s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("label",{className:Re("inline-flex cursor-pointer items-center gap-2 typography-micro font-medium",j.enabled?"text-foreground":"text-muted-foreground",T&&"cursor-not-allowed opacity-50"),children:[s.jsx(ur,{checked:j.enabled,onChange:Z=>{P(j,Z)},ariaLabel:j.enabled?t("sessions.scheduledTasks.dialog.taskToggle.pauseAria",{taskName:j.name}):t("sessions.scheduledTasks.dialog.taskToggle.enableAria",{taskName:j.name}),disabled:T}),j.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(ot,{variant:"outline",size:"sm",onClick:()=>{$(j)},disabled:T,children:[s.jsx(E,{name:"play",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.runNow")]}),s.jsxs(ot,{variant:"outline",size:"sm",onClick:()=>M(j),disabled:T,"aria-label":t("sessions.scheduledTasks.dialog.actions.editAria",{taskName:j.name}),children:[s.jsx(E,{name:"edit-2",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.edit")]}),s.jsx(ot,{variant:"destructive",size:"sm",onClick:()=>{D(j)},disabled:T,"aria-label":t("sessions.scheduledTasks.dialog.actions.deleteAria",{taskName:j.name}),children:s.jsx(E,{name:"delete-bin",className:"h-4 w-4"})})]})]})]},j.id)})})}),I=s.jsxs("div",{className:"space-y-4",children:[R,O]});return s.jsxs(s.Fragment,{children:[r?s.jsx(Zo,{open:e,title:t("sessions.scheduledTasks.dialog.title"),onClose:()=>n(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:j=>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")}),j]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("sessions.scheduledTasks.dialog.description")})]}),footer:s.jsxs(ot,{className:"w-full",onClick:K,disabled:!d,children:[s.jsx(E,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]}),children:I}):e?s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",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(j=>s.jsx("button",{type:"button",onClick:()=>L(j.id),className:Re("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-primary/50",d===j.id?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:C(j)},j.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(ot,{size:"sm",onClick:K,disabled:!d,children:[s.jsx(E,{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:O})})]})]})}):null,s.jsx(n4,{open:v,task:m,onOpenChange:x,onSave:A})]})}const Do=100;function h4(){const t=Xe.c(101),{t:e}=pt(),n=Te(j4),r=Te(v4),i=Qe(S4),o=Qe(w4),l=es(y4);let a;t[0]!==n?(a=Y=>n?Y.archivedSessions:[],t[0]=n,t[1]=a):a=t[1];const u=Ds(Zn(a)),[d,h]=c.useState(""),[f,g]=c.useState(null),[p,w]=c.useState(Do);let v;t[2]!==d?(v=d.trim().toLowerCase(),t[2]=d,t[3]=v):v=t[3];const x=v;let m;e:{if(!n){let me;t[4]===Symbol.for("react.memo_cache_sentinel")?(me=[],t[4]=me):me=t[4],m=me;break e}let Y;t[5]!==u?(Y=[...u].sort(b4),t[5]=u,t[6]=Y):Y=t[6],m=Y}const b=m;let y;if(t[7]!==l||t[8]!==b||t[9]!==e){const Y=new Map;for(const me of b){const Z=dt(_s(me))??"",re=Y.get(Z);if(re){re.sessions.push(me);continue}Y.set(Z,{directory:Z,label:Z?Fn(Z,l)||Z:e("sessions.archivePage.otherProjects"),sessions:[me]})}y=[...Y.values()].sort(x4),t[7]=l,t[8]=b,t[9]=e,t[10]=y}else y=t[10];const S=y;let N;e:{if(x){let me;t[11]!==x||t[12]!==b?(me=qh(b,x,g4),t[11]=x,t[12]=b,t[13]=me):me=t[13],N=me;break e}if(f===null){N=b;break e}let Y;t[14]!==S||t[15]!==f?(Y=S.find(me=>me.directory===f)?.sessions??[],t[14]=S,t[15]=f,t[16]=Y):Y=t[16],N=Y}const C=N;let k,A,P,D,M,$,R,K,L,O;if(t[17]!==u.length||t[18]!==S||t[19]!==C||t[20]!==l||t[21]!==x||t[22]!==n||t[23]!==d||t[24]!==f||t[25]!==i||t[26]!==r||t[27]!==e||t[28]!==o||t[29]!==p){M=Symbol.for("react.early_return_sentinel");e:{const Y=C.slice(0,p);k=C.length-Y.length;const me=u.length;let Z;t[40]===Symbol.for("react.memo_cache_sentinel")?(Z=ye=>{g(ye),w(Do)},t[40]=Z):Z=t[40];const re=Z;let se;t[41]!==i||t[42]!==r?(se=ye=>{const q=dt(_s(ye));i(ye.id,q??void 0),r(!1)},t[41]=i,t[42]=r,t[43]=se):se=t[43];const fe=se;let _;t[44]!==e||t[45]!==o?(_=ye=>{o(ye.id).then(q=>{q?Be.success(e("sessions.sidebar.session.restore.success")):Be.error(e("sessions.sidebar.session.restore.error"))})},t[44]=e,t[45]=o,t[46]=_):_=t[46];const le=_;if(!n){M=null;break e}let ee;t[47]!==e?(ee=(ye,q,De,ke,te,he,ae)=>s.jsxs("div",{className:"group/dir relative",children:[s.jsxs("button",{type:"button",onClick:te,title:he,className:Re("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-primary/50",ae?"group-hover/dir:pr-8 group-focus-within/dir:pr-8":"",ke?"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:q}),s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground/70",children:De})]}),ae?s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>pn.requestDelete({sessions:ae,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-primary/50","aria-label":e("sessions.archivePage.deleteProjectAria",{label:q}),children:s.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),s.jsx(yt,{side:"bottom",sideOffset:4,children:e("sessions.archivePage.deleteProject")})]}):null]},ye),t[47]=e,t[48]=ee):ee=t[48];const ue=ee;D="absolute inset-0 z-10 flex flex-col bg-background",A="flex min-h-0 flex-1";let W;if(t[49]!==ue||t[50]!==f||t[51]!==e||t[52]!==me){let ye;t[54]===Symbol.for("react.memo_cache_sentinel")?(ye=()=>re(null),t[54]=ye):ye=t[54],W=ue("__all__",e("sessions.archivePage.allDirectories"),me,f===null,ye),t[49]=ue,t[50]=f,t[51]=e,t[52]=me,t[53]=W}else W=t[53];let ne;if(t[55]!==S||t[56]!==ue||t[57]!==f){let ye;t[59]!==ue||t[60]!==f?(ye=q=>ue(q.directory||"__none__",q.label,q.sessions.length,f===q.directory,()=>re(q.directory),q.directory||void 0,q.sessions),t[59]=ue,t[60]=f,t[61]=ye):ye=t[61],ne=S.map(ye),t[55]=S,t[56]=ue,t[57]=f,t[58]=ne}else ne=t[58];t[62]!==W||t[63]!==ne?(P=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:[W,ne]})}),t[62]=W,t[63]=ne,t[64]=P):P=t[64],L="flex min-w-0 flex-1 flex-col";let pe;t[65]===Symbol.for("react.memo_cache_sentinel")?(pe=s.jsx(E,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t[65]=pe):pe=t[65];let xe;t[66]===Symbol.for("react.memo_cache_sentinel")?(xe=ye=>{h(ye.target.value),w(Do)},t[66]=xe):xe=t[66];let Ce;t[67]!==e?(Ce=e("sessions.archivePage.searchPlaceholder"),t[67]=e,t[68]=Ce):Ce=t[68];let Me;t[69]!==d||t[70]!==Ce?(Me=s.jsxs("div",{className:"relative min-w-0 flex-1",children:[pe,s.jsx("input",{value:d,onChange:xe,placeholder:Ce,className:"h-8 w-full rounded-md border border-border bg-transparent pl-8 pr-3 typography-ui-label text-foreground outline-none focus-visible:ring-2 focus-visible:ring-primary/50"})]}),t[69]=d,t[70]=Ce,t[71]=Me):Me=t[71];let ve;t[72]!==C.length||t[73]!==e?(ve=C.length===1?e("sessions.archivePage.countSingle",{count:C.length}):e("sessions.archivePage.countPlural",{count:C.length}),t[72]=C.length,t[73]=e,t[74]=ve):ve=t[74];let Ie;t[75]!==ve?(Ie=s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:ve}),t[75]=ve,t[76]=Ie):Ie=t[76],t[77]!==Me||t[78]!==Ie?(O=s.jsxs("div",{className:"flex items-center gap-3 px-6 pt-3",children:[Me,Ie]}),t[77]=Me,t[78]=Ie,t[79]=O):O=t[79],K="min-h-0 flex-1 overflow-y-auto px-6 py-3",$="mx-auto w-full max-w-3xl space-y-0.5",R=Y.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(x?"sessions.archivePage.empty.noMatches":"sessions.archivePage.empty.noArchived")})}):Y.map(ye=>{const q=dt(_s(ye))??"",De=q?Fn(q,l)||q: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:()=>fe(ye),role:"button",tabIndex:0,onKeyDown:ke=>{(ke.key==="Enter"||ke.key===" ")&&(ke.preventDefault(),fe(ye))},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:ye.title||e("sessions.sidebar.session.untitled")}),x&&De?s.jsx("span",{className:"max-w-40 flex-shrink-0 truncate text-[0.72rem] text-muted-foreground/70",title:q,children:De}):null,s.jsx("span",{className:"flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:Ud(ye.time?.archived??ye.time?.updated??ye.time?.created??Date.now())}),s.jsx("button",{type:"button",onClick:ke=>{ke.stopPropagation(),le(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-primary/50","aria-label":e("sessions.archivePage.restoreSessionAria",{title:ye.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(E,{name:"inbox-unarchive",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:ke=>{ke.stopPropagation(),pn.requestDelete({sessions:[ye],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-primary/50","aria-label":e("sessions.archivePage.deleteSessionAria",{title:ye.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},ye.id)})}t[17]=u.length,t[18]=S,t[19]=C,t[20]=l,t[21]=x,t[22]=n,t[23]=d,t[24]=f,t[25]=i,t[26]=r,t[27]=e,t[28]=o,t[29]=p,t[30]=k,t[31]=A,t[32]=P,t[33]=D,t[34]=M,t[35]=$,t[36]=R,t[37]=K,t[38]=L,t[39]=O}else k=t[30],A=t[31],P=t[32],D=t[33],M=t[34],$=t[35],R=t[36],K=t[37],L=t[38],O=t[39];if(M!==Symbol.for("react.early_return_sentinel"))return M;let I;t[80]!==k||t[81]!==e?(I=k>0?s.jsx("button",{type:"button",onClick:()=>w(p4),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[80]=k,t[81]=e,t[82]=I):I=t[82];let j;t[83]!==I||t[84]!==$||t[85]!==R?(j=s.jsxs("div",{className:$,children:[R,I]}),t[83]=I,t[84]=$,t[85]=R,t[86]=j):j=t[86];let T;t[87]!==j||t[88]!==K?(T=s.jsx("div",{className:K,children:j}),t[87]=j,t[88]=K,t[89]=T):T=t[89];let F;t[90]!==T||t[91]!==L||t[92]!==O?(F=s.jsxs("div",{className:L,children:[O,T]}),t[90]=T,t[91]=L,t[92]=O,t[93]=F):F=t[93];let U;t[94]!==A||t[95]!==P||t[96]!==F?(U=s.jsxs("div",{className:A,children:[P,F]}),t[94]=A,t[95]=P,t[96]=F,t[97]=U):U=t[97];let H;return t[98]!==D||t[99]!==U?(H=s.jsx("div",{className:D,children:U}),t[98]=D,t[99]=U,t[100]=H):H=t[100],H}function p4(t){return t+Do}function g4(t){return[t.title]}function x4(t,e){return e.sessions.length-t.sessions.length}function b4(t,e){return(e.time?.archived??0)-(t.time?.archived??0)}function y4(t){return t.homeDirectory}function w4(t){return t.unarchiveSession}function S4(t){return t.setCurrentSession}function v4(t){return t.setArchivePageOpen}function j4(t){return t.isArchivePageOpen}function k4(){const t=Xe.c(18),{t:e}=pt(),n=Te(A4),r=Te(N4),i=zt(C4);let o;t[0]!==n?(o=p=>p.projects.find(w=>w.id===n)??null,t[0]=n,t[1]=o):o=t[1];const l=zt(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 u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(E,{name:"node-tree",className:"mr-1 h-3.5 w-3.5"}),t[6]=u):u=t[6];let d;t[7]!==e?(d=e("sessions.sidebar.project.actions.newWorktree"),t[7]=e,t[8]=d):d=t[8];let h;t[9]!==a||t[10]!==d?(h=s.jsx("div",{className:"flex items-center",children:s.jsxs(ot,{size:"sm",onClick:a,children:[u,d]})}),t[9]=a,t[10]=d,t[11]=h):h=t[11];let f;t[12]!==l.id||t[13]!==l.path?(f=s.jsx(lg,{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 g;return t[15]!==h||t[16]!==f?(g=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]=g):g=t[17],g}function C4(t){return t.setActiveProjectIdOnly}function N4(t){return t.setNewWorktreeDialogOpen}function A4(t){return t.worktreesPageProjectId}const fa=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").substring(0,50),P4=(t,e)=>{const n=fa(t),r=fa(e);return`${n}-${r}`.substring(0,60)},Gc=(t,e)=>`${t}/${e}`,D4=t=>{const e=t.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},qc=(t,e)=>{const n=D4(e),r=t.directory,i=typeof r=="string"&&r.trim().length>0?t:{...t,directory:n};sp(t.id,n),Qe.getState().markSessionAsOpenChamberCreated(t.id),Ds.getState().upsertSession(i);try{Eo().ensureChild(n,{bootstrap:!1}).setState(l=>{const a=l.session.findIndex(d=>d.id===t.id);if(a>=0&&l.session[a]===i)return l;const u=a>=0?l.session.map((d,h)=>h===a?i:d):[...l.session,i].sort((d,h)=>d.id.localeCompare(h.id));return{session:u,sessionTotal:Math.max(l.sessionTotal,u.length),limit:Math.max(l.limit,u.length)}})}catch{}return i},T4=()=>{const t=zt.getState(),e=t.activeProjectId;if(!e)return null;const n=t.projects.find(i=>i.id===e);if(n?.path)return{id:n.id,path:n.path};const r=es.getState().currentDirectory??null;if(r&&r.trim().length>0){const i=r.replace(/\\/g,"/").replace(/\/+$/,"")||r;return{id:`path:${i}`,path:i}}return null},ji=tr()(pu(t=>({isLoading:!1,error:null,createMultiRun:async e=>{const n=e.name.trim(),{groups:r,agent:i,files:o,setupCommands:l}=e;if(!n)return t({error:"Group name is required"}),null;if(!r||r.length===0)return t({error:"At least one run group is required"}),null;for(let a=0;a<r.length;a++){if(!r[a].prompt.trim())return t({error:`Group ${a+1}: prompt is required`}),null;if(r[a].models.length<1)return t({error:`Group ${a+1}: select at least 1 model`}),null}t({isLoading:!0,error:null});try{const a=T4();if(!a)return t({error:"Select a project",isLoading:!1}),null;const u=a.path,h=await Xo(u)&&e.isolateRuns!==!1,f=fa(n),g=h?await ei(u):void 0,p=h?await Qh(u):null,w=[],v=l?.filter(S=>S.trim().length>0)??[];for(let S=0;S<r.length;S++){const N=r[S],C=N.prompt,k=new Map;for(const P of N.models){const D=`${P.providerID}:${P.modelID}`;k.set(D,(k.get(D)||0)+1)}const A=new Map;for(const P of N.models){const D=`${P.providerID}:${P.modelID}`,M=k.get(D)||1,$=(A.get(D)||0)+1;A.set(D,$);const R=P4(P.providerID,P.modelID),K=r.length>1?`g${S+1}`:void 0,L=M>1?Gc(f,`${R}/${$}`):Gc(f,R),O=K?`${K}/${L}`:L,I=Sj({groupSlug:f,runGroup:K,providerID:P.providerID,modelID:P.modelID,index:M>1?$:void 0});try{if(!h){const U=await qs.withDirectory(u,()=>qs.createSession({title:I}));qc(U,u),w.push({sessionId:U.id,worktreePath:u,providerID:P.providerID,modelID:P.modelID,variant:P.variant,prompt:C});continue}const j=await Yh(a,{preferredName:O,mode:"new",branchName:O,worktreeName:O,startRef:e.worktreeBaseBranch||"HEAD",setupCommands:v,returnAfterDirectoryCreated:!0},{resolvedRootTrackingRemote:p}),T={...j,createdFromBranch:g,kind:"standard"};await Xh(a)&&await Jh(j.path);const F=await qs.withDirectory(j.path,()=>qs.createSession({title:I}));qc(F,j.path),Qe.getState().setWorktreeMetadata(F.id,T),w.push({sessionId:F.id,worktreePath:j.path,providerID:P.providerID,modelID:P.modelID,variant:P.variant,prompt:C})}catch(j){console.warn("[MultiRun] Failed to create session:",j)}}}const x=l?.filter(S=>S.trim().length>0)??[];x.length>0&&Zh(a,x).catch(()=>{console.warn("[MultiRun] Failed to save worktree setup commands")});const m=w.map(S=>S.sessionId),b=w[0]?.sessionId??null;if(m.length===0)return t({error:"Failed to create any sessions",isLoading:!1}),null;const y=o?.map(S=>({type:"file",mime:S.mime,filename:S.filename,url:S.url}));return(async()=>{try{const S=ep.getState().expandText;await Promise.allSettled(w.map(async N=>{try{const C=await S(N.prompt).catch(()=>N.prompt);await tp({sessionId:N.sessionId,directory:N.worktreePath,content:C,providerID:N.providerID,modelID:N.modelID,variant:N.variant,agent:i,files:y})}catch(C){console.warn("[MultiRun] Failed to start run:",C)}}))}catch(S){console.warn("[MultiRun] Failed to start runs:",S)}})(),t({isLoading:!1}),{groupSlug:f,sessionIds:m,firstSessionId:b}}catch(a){return t({error:a instanceof Error?a.message:"Failed to create Multi-Run",isLoading:!1}),null}},clearError:()=>{t({error:null})}}),{name:"multirun-store"}));function vm(t){const e=Xe.c(30),{git:n}=Dn(),r=Ad(t),i=Pd(t),o=np(t),l=rp(t),a=Bn(O4),u=Bn(M4);let d,h;e[0]!==t||e[1]!==u||e[2]!==n||e[3]!==i||e[4]!==o?(d=()=>{!t||!n||i!==null||o||u(t,n,{silent:!0})},h=[t,n,u,i,o],e[0]=t,e[1]=u,e[2]=n,e[3]=i,e[4]=o,e[5]=d,e[6]=h):(d=e[5],h=e[6]),c.useEffect(d,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 g=r?.all;let p;e[13]!==t||e[14]!==a||e[15]!==n||e[16]!==i||e[17]!==g?(p=[t,n,i,g,a],e[13]=t,e[14]=a,e[15]=n,e[16]=i,e[17]=g,e[18]=p):p=e[18],c.useEffect(f,p);const w=o||i===!0&&l;let v;e:{if(!r?.all){let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=[],e[19]=k):k=e[19],v=k;break e}let C;e[20]!==r.all?(C=r.all.filter(E4).sort(),e[20]=r.all,e[21]=C):C=e[21],v=C}const x=v;let m;e:{if(!r?.all){let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=[],e[22]=k):k=e[22],m=k;break e}let C;e[23]!==r.all?(C=r.all.filter(R4).map(I4).sort(),e[23]=r.all,e[24]=C):C=e[24],m=C}const b=m;let y;e:{if(!t){y=null;break e}if(i!==null){y=i;break e}if(w){y=null;break e}y=r?.all?!0:null}const S=y;let N;return e[25]!==S||e[26]!==w||e[27]!==x||e[28]!==b?(N={localBranches:x,remoteBranches:b,isLoading:w,isGitRepository:S},e[25]=S,e[26]=w,e[27]=x,e[28]=b,e[29]=N):N=e[29],N}function I4(t){return t.replace(/^remotes\//,"")}function R4(t){return t.startsWith("remotes/")}function E4(t){return!t.startsWith("remotes/")}function M4(t){return t.fetchStatus}function O4(t){return t.fetchBranches}const B4=({directory:t,value:e,onChange:n,className:r,disabled:i,id:o})=>{const{t:l}=pt(),{localBranches:a,remoteBranches:u,isLoading:d,isGitRepository:h}=vm(t),f=c.useMemo(()=>[...a,...u.map(p=>`remotes/${p}`)],[a,u]);c.useEffect(()=>{if(i||d||f.length===0||e&&f.includes(e))return;const p=e;let w=!1;return(async()=>{try{const x=t?await ei(t).catch(()=>null):null;if(w)return;const m=localStorage.getItem(Nl),{sourceBranch:b,shouldClearSavedSourceBranch:y}=cg({branches:f,savedSourceBranch:m,rootBranch:x});if(y&&localStorage.removeItem(Nl),w||p&&f.includes(p))return;b&&n(b)}catch{}})(),()=>{w=!0}},[f,t,i,d,n,e]);const g=i||!h||d;return s.jsxs("div",{children:[s.jsxs(Ms,{value:e,onValueChange:n,disabled:g,children:[s.jsx(Os,{id:o,size:"lg",className:Re("min-w-0 max-w-full *:data-[slot=select-value]:truncate",r??"w-fit"),children:s.jsx(Ns,{placeholder:l(d?"multiRun.branchSelector.status.loadingBranches":"multiRun.branchSelector.placeholder.selectSourceBranch")})}),s.jsx(Bs,{className:"max-h-[280px] max-w-[320px]",children:d?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.loadingBranches")}):a.length===0&&u.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(Mi,{children:[s.jsx(gl,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.localBranches")}),a.map(p=>s.jsx(ts,{value:p,className:"whitespace-normal break-all",children:p},p))]}),a.length>0&&u.length>0&&s.jsx(op,{}),u.length>0&&s.jsxs(Mi,{children:[s.jsx(gl,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.remoteBranches")}),u.map(p=>s.jsx(ts,{value:`remotes/${p}`,className:"whitespace-normal break-all",children:p},`remotes/${p}`))]})]})})]}),h===!1&&s.jsx("p",{className:"typography-micro text-muted-foreground/70 mt-2",children:l("multiRun.branchSelector.status.notInGitRepository")})]})},F4=10*1024*1024,To=t=>{const e=Xe.c(3),{children:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(bt,{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(E,{name:"information",className:"h-3.5 w-3.5"})})}),e[0]=r):r=e[0];let i;return e[1]!==n?(i=s.jsxs(xt,{children:[r,s.jsx(yt,{side:"top",className:"max-w-[240px]",children:n})]}),e[1]=n,e[2]=i):i=e[2],i},Hn=t=>{const e=Xe.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 u=o&&o;let d;return e[6]!==a||e[7]!==u?(d=s.jsxs("div",{className:"flex items-center gap-1.5",children:[a,u]}),e[6]=a,e[7]=u,e[8]=d):d=e[8],d},_4=({initialPrompt:t,onCreated:e,onCancel:n,isWindowed:r=!1})=>{const{t:i}=pt(),[o,l]=c.useState(""),[a,u]=c.useState(()=>[{id:_r(),prompt:"",models:[]}]),[d,h]=c.useState(""),[f,g]=c.useState([]),[p,w]=c.useState(!1),[v,x]=c.useState([]),[m,b]=c.useState(!1),[y,S]=c.useState(!1),[N,C]=c.useState(!0),k=c.useRef(null),A=es(Q=>Q.currentDirectory??null),P=es(Q=>Q.homeDirectory??null),D=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},[]),M=zt(Q=>Q.activeProjectId),$=zt(Q=>Q.setActiveProjectIdOnly),R=zt(Q=>Q.projects),[K,L]=c.useState(()=>M??null);c.useEffect(()=>{if(M){L(M);return}!K&&R.length>0&&L(R[0].id)},[M,R,K]);const O=c.useMemo(()=>K?R.find(Q=>Q.id===K)??null:null,[R,K]),I=O?.path??A,j=c.useCallback(Q=>{L(Q),Q!==M&&$(Q)},[M,$]),{currentTheme:T}=er(),F=c.useCallback(Q=>{const z=Q.label?.trim()||Fn(Q.path,P),G=Q.icon?Pa[Q.icon]:null,ie=Q.color?Da[Q.color]:void 0,Oe=G?s.jsx(E,{name:G,className:"h-3.5 w-3.5 shrink-0",style:ie?{color:ie}:void 0}):s.jsx(E,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:ie?{color:ie}: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(Ta,{project:{id:Q.id,iconImage:Q.iconImage??null},options:{themeVariant:T.metadata.variant,iconColor:T.colors.surface.foreground},className:"h-full w-full object-contain",fallback:Oe})}):Oe,s.jsx("span",{className:"truncate",children:z})]})},[P,T.metadata.variant,T.colors.surface.foreground]),U=c.useMemo(()=>{if(O?.path)return{id:O.id,path:O.path};const Q=A??D;return Q?{id:`path:${Q}`,path:Q}:null},[O,A,D]),[H]=c.useState(()=>typeof window<"u"?gn():!1),Y=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),me=vd(),Z=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 G=Number.parseInt(z[1],10),ie=Number.parseInt(z[2],10);return Number.isNaN(G)?null:G===10?ie:G},[]),re=c.useMemo(()=>H&&Y||me?"pl-[5.5rem]":"pl-3",[H,Y,me]),se=c.useMemo(()=>!H||!Y||Z===null?"":Z>=26?"h-12":Z<=15?"h-14":"",[H,Y,Z]),fe=c.useCallback(async Q=>{Q.target.closest("button, a, input, select, textarea")||Q.button===0&&H&&await ip()},[H]);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[_,le]=c.useState(""),{isLoading:ee,isGitRepository:ue}=vm(I),W=c.useRef(!1),ne=ue===!0,pe=ne&&N;c.useEffect(()=>{if(ue===!1){W.current=!0,C(!1);return}ue===!0&&W.current&&(W.current=!1,C(!0))},[ue]);const xe=ji(Q=>Q.createMultiRun),Ce=ji(Q=>Q.error),Me=ji(Q=>Q.clearError);c.useEffect(()=>{typeof t=="string"&&t.trim().length>0&&u(Q=>{const z=[...Q];return z.length>0&&!z[0].prompt.trim()&&(z[0]={...z[0],prompt:t}),z})},[t]),c.useEffect(()=>{if(!U)return;let Q=!1;return S(!0),(async()=>{try{const z=await ap(U);Q||x(z)}catch{}finally{Q||S(!1)}})(),()=>{Q=!0}},[U]);const ve=c.useCallback((Q,z)=>{u(G=>G.map(ie=>ie.id===Q?{...ie,...z}:ie))},[]),Ie=c.useCallback(Q=>{u(z=>z.filter(G=>G.id!==Q))},[]),ye=c.useCallback(()=>{u(Q=>[...Q,{id:_r(),prompt:"",models:[]}])},[]),q=async Q=>{const z=Q.target.files;if(!z)return;let G=0;for(let ie=0;ie<z.length;ie++){const Oe=z[ie];if(Oe.size>F4){Be.error(i("multirun.launcher.toast.fileTooLarge",{fileName:Oe.name}));continue}try{const Fe=await new Promise((Se,oe)=>{const Pe=new FileReader;Pe.onload=()=>Se(Pe.result),Pe.onerror=oe,Pe.readAsDataURL(Oe)});g(Se=>[...Se,{id:_r(),filename:Oe.name,mimeType:Oe.type||"application/octet-stream",size:Oe.size,dataUrl:Fe}]),G++}catch(Fe){console.error("File attach failed",Fe),Be.error(i("multirun.launcher.toast.attachFailed",{fileName:Oe.name}))}}G>0&&Be.success(G===1?i("multirun.launcher.toast.attachedSingle",{count:G}):i("multirun.launcher.toast.attachedPlural",{count:G})),k.current&&(k.current.value="")},De=Q=>{g(z=>z.filter(G=>G.id!==Q))},ke=c.useMemo(()=>a.reduce((Q,z)=>Q+z.models.length,0),[a]),te=async Q=>{Q.preventDefault();const z=a.filter(G=>G.prompt.trim()&&G.models.length>=1);if(z.length!==0&&!(ke<1)){w(!0),Me();try{K&&K!==M&&$(K);const G=f.map(oe=>({mime:oe.mimeType,filename:oe.filename,url:oe.dataUrl})),ie=v.filter(oe=>oe.trim().length>0),Oe=z.map(oe=>({prompt:oe.prompt.trim(),models:oe.models.map(Pe=>({providerID:Pe.providerID,modelID:Pe.modelID,displayName:Pe.displayName,variant:Pe.variant}))})),Fe={name:o.trim(),groups:Oe,agent:d||void 0,worktreeBaseBranch:pe?_:void 0,isolateRuns:pe,files:G.length>0?G:void 0,setupCommands:ie.length>0?ie:void 0},Se=await xe(Fe);Se&&(Se.firstSessionId&&Qe.getState().setCurrentSession(Se.firstSessionId),e?.())}finally{w(!1)}}},he=!!(o.trim()&&a.some(Q=>Q.prompt.trim()&&Q.models.length>=1)&&ke>=1&&I&&!ee&&(ue===!1||!pe||_)),ae=v.filter(Q=>Q.trim()).length;return s.jsxs("form",{onSubmit:te,className:"flex flex-col h-full bg-background",children:[r?null:s.jsxs("header",{onMouseDown:fe,className:Re("relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none",re,se),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(xt,{children:[s.jsx(bt,{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-primary app-region-no-drag",children:s.jsx(E,{name:"close",className:"h-5 w-5"})})}),s.jsx(yt,{children:s.jsx("p",{children:i("multirun.launcher.actions.closeEsc")})})]})})]}),s.jsx(ka,{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(Hn,{htmlFor:"multirun-project",required:!0,children:i("multirun.launcher.project.label")}),R.length>0?s.jsxs(Ms,{value:K??void 0,onValueChange:j,children:[s.jsx(Os,{id:"multirun-project",size:"lg",className:"w-fit max-w-full",children:O?s.jsx(Ns,{children:F(O)}):s.jsx(Ns,{placeholder:i("multirun.launcher.project.placeholder")})}),s.jsx(Bs,{fitContent:!0,children:R.map(Q=>s.jsx(ts,{value:Q.id,className:"max-w-[24rem]",children:F(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(Hn,{htmlFor:"group-name",required:!0,info:s.jsx(To,{children:i("multirun.launcher.groupName.info")}),children:i("multirun.launcher.groupName.label")}),s.jsx(kn,{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(Hn,{htmlFor:"multirun-worktree-base-branch",info:s.jsx(To,{children:i("multirun.launcher.baseBranch.info")}),children:i("multirun.launcher.baseBranch.label")}),s.jsx(B4,{directory:I,value:_,onChange:le,disabled:!pe,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(ur,{checked:N,onChange:C,disabled:!ne,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(Hn,{htmlFor:"multirun-agent",info:s.jsx(To,{children:i("multirun.launcher.agent.info")}),children:i("multirun.launcher.agent.label")}),s.jsx(hm,{value:d,onChange:h,id:"multirun-agent"})]})]}),s.jsxs(Fi,{open:m,onOpenChange:b,children:[s.jsxs(su,{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(E,{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")}),ae>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:ae}),s.jsx(E,{name:"arrow-down-s",className:Re("h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto",m&&"rotate-180")})]}),s.jsx(_i,{children:s.jsx("div",{className:"pt-2 space-y-1.5",children:y?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(kn,{value:Q,onChange:G=>{const ie=[...v];ie[z]=G.target.value,x(ie)},placeholder:i("multirun.launcher.setupCommands.commandPlaceholder"),className:"h-8 flex-1 font-mono text-xs"}),s.jsx("button",{type:"button",onClick:()=>x(v.filter((G,ie)=>ie!==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-primary/50","aria-label":i("multirun.launcher.setupCommands.removeCommandAria"),children:s.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]},`${Q}-${z}`)),s.jsxs("button",{type:"button",onClick:()=>x([...v,""]),className:"flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1",children:[s.jsx(E,{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(Hn,{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:k,type:"file",multiple:!0,className:"hidden",onChange:q,accept:"*/*"}),s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>k.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(E,{name:"attachment-2",className:"h-3 w-3"}),i("multirun.launcher.attachments.attach")]})}),s.jsx(yt,{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(E,{name:"file-image",className:"h-3 w-3 text-muted-foreground"}):s.jsx(E,{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:()=>De(Q.id),className:"text-muted-foreground hover:text-destructive",children:s.jsx(E,{name:"close",className:"h-3 w-3"})})]},Q.id))]})]}),a.map((Q,z)=>s.jsx(L4,{group:Q,groupIndex:z,canRemove:a.length>1,onUpdate:ve,onRemove:Ie},Q.id)),s.jsxs("button",{type:"button",onClick:ye,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(E,{name:"add",className:"h-3.5 w-3.5"}),i("multirun.launcher.groups.addGroup")]}),Ce&&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:Ce})]})})}),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:[!pe&&ue!==null?s.jsxs("div",{className:"mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(E,{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(ot,{type:"button",variant:"ghost",size:"sm",onClick:n,children:i("multirun.launcher.actions.cancel")}):null,s.jsx(ot,{type:"submit",size:"sm",disabled:!he||p,children:p?i("multirun.launcher.actions.creating"):s.jsx(s.Fragment,{children:i("multirun.launcher.actions.startWithRunCount",{count:ke})})})]})})]})},L4=t=>{const e=Xe.c(99),{group:n,groupIndex:r,canRemove:i,onUpdate:o,onRemove:l}=t,{t:a}=pt(),[u,d]=c.useState(!1),[h,f]=c.useState(""),[g,p]=c.useState(!1),[w,v]=c.useState(""),[x,m]=c.useState(!1),[b,y]=c.useState(""),S=c.useRef(null),N=c.useRef(null),C=c.useRef(null),k=c.useRef(null);let A;e[0]!==n.id||e[1]!==n.models||e[2]!==o?(A=ie=>{o(n.id,{models:[...n.models,ie]})},e[0]=n.id,e[1]=n.models,e[2]=o,e[3]=A):A=e[3];const P=A;let D;e[4]!==n.id||e[5]!==n.models||e[6]!==o?(D=ie=>{o(n.id,{models:n.models.filter((Oe,Fe)=>Fe!==ie)})},e[4]=n.id,e[5]=n.models,e[6]=o,e[7]=D):D=e[7];const M=D;let $;e[8]!==n.id||e[9]!==n.models||e[10]!==o?($=(ie,Oe)=>{o(n.id,{models:n.models.map((Fe,Se)=>Se===ie?Oe:Fe)})},e[8]=n.id,e[9]=n.models,e[10]=o,e[11]=$):$=e[11];const R=$;let K;e[12]===Symbol.for("react.memo_cache_sentinel")?(K=(ie,Oe)=>{if(ie.startsWith("/")){const Pe=ie.indexOf(" "),Ne=ie.indexOf(`
|
|
925
|
-
`),B=Math.min(Pe===-1?ie.length:Pe,Ne===-1?ie.length:Ne);if(Oe<=B&&Pe===-1){v(ie.substring(1,B)),p(!0),d(!1),m(!1);return}}p(!1);const Fe=ie.substring(0,Oe),Se=Fe.lastIndexOf("#");if(Se!==-1){const Pe=Se>0?Fe[Se-1]:null,Ne=Fe.substring(Se+1);if((!Pe||/\s/.test(Pe))&&!Ne.includes(" ")&&!Ne.includes(`
|
|
926
|
-
`)){y(Ne),m(!0),d(!1);return}}m(!1);const oe=Fe.lastIndexOf("@");if(oe!==-1){const Pe=oe>0?Fe[oe-1]:null,Ne=Fe.substring(oe+1);(!Pe||/\s/.test(Pe))&&!Ne.includes(" ")&&!Ne.includes(`
|
|
927
|
-
`)?(f(Ne),d(!0)):d(!1);return}d(!1)},e[12]=K):K=e[12];const L=K;let O;e[13]!==n.id||e[14]!==o?(O=ie=>{o(n.id,{prompt:ie})},e[13]=n.id,e[14]=o,e[15]=O):O=e[15];const I=O;let j;e[16]!==n.prompt||e[17]!==I?(j=ie=>{const Oe=n.prompt,Se=S.current?.selectionStart??Oe.length,Pe=Oe.substring(0,Se).lastIndexOf("@"),Ne=ie.relativePath&&ie.relativePath.trim().length>0?ie.relativePath.trim():ie.path||ie.name,B=Pe!==-1?Pe:Se,ce=`${Oe.substring(0,B)}@${Ne} ${Oe.substring(Se)}`,be=B+Ne.length+2;I(ce),d(!1),f(""),requestAnimationFrame(()=>{const ge=S.current;ge&&(ge.selectionStart=be,ge.selectionEnd=be,ge.focus()),L(ce,be)})},e[16]=n.prompt,e[17]=I,e[18]=j):j=e[18];const T=j;let F;e[19]!==n.prompt||e[20]!==I?(F=ie=>{const Oe=n.prompt,Se=S.current?.selectionStart??Oe.length,Pe=Oe.substring(0,Se).lastIndexOf("@"),Ne=Pe!==-1?Pe:Se,B=`${Oe.substring(0,Ne)}@${ie} ${Oe.substring(Se)}`,ce=Ne+ie.length+2;I(B),d(!1),f(""),requestAnimationFrame(()=>{const be=S.current;be&&(be.selectionStart=ce,be.selectionEnd=ce,be.focus()),L(B,ce)})},e[19]=n.prompt,e[20]=I,e[21]=F):F=e[21];const U=F;let H;e[22]!==I?(H=ie=>{const Oe=`/${ie.name} `;I(Oe),p(!1),v(""),m(!1),requestAnimationFrame(()=>{const Fe=S.current;Fe&&(Fe.focus(),Fe.selectionStart=Fe.value.length,Fe.selectionEnd=Fe.value.length),L(Oe,Oe.length)})},e[22]=I,e[23]=H):H=e[23];const Y=H;let me;e[24]!==n.prompt||e[25]!==I?(me=(ie,Oe)=>{const Fe=n.prompt,oe=S.current?.selectionStart??Fe.length,Ne=Fe.substring(0,oe).lastIndexOf("#"),B=Ne!==-1?Ne:oe,ce=`${Fe.substring(0,B)}#${Oe} ${Fe.substring(oe)}`,be=B+Oe.length+2;I(ce),m(!1),y(""),requestAnimationFrame(()=>{const ge=S.current;ge&&(ge.selectionStart=be,ge.selectionEnd=be,ge.focus()),L(ce,be)})},e[24]=n.prompt,e[25]=I,e[26]=me):me=e[26];const Z=me;let re;e[27]!==g||e[28]!==u||e[29]!==x?(re=ie=>{if(g&&C.current&&(ie.key==="Enter"||ie.key==="ArrowUp"||ie.key==="ArrowDown"||ie.key==="Escape"||ie.key==="Tab")){ie.preventDefault(),C.current.handleKeyDown(ie.key);return}u&&N.current&&(ie.key==="Enter"||ie.key==="ArrowUp"||ie.key==="ArrowDown"||ie.key==="Escape"||ie.key==="Tab")&&(ie.preventDefault(),N.current.handleKeyDown(ie.key)),x&&k.current&&(ie.key==="Enter"||ie.key==="ArrowUp"||ie.key==="ArrowDown"||ie.key==="Escape"||ie.key==="Tab")&&(ie.preventDefault(),k.current.handleKeyDown(ie.key))},e[27]=g,e[28]=u,e[29]=x,e[30]=re):re=e[30];const se=re,fe=r+1;let _;e[31]!==a||e[32]!==fe?(_=a("multirun.launcher.groups.groupLabel",{index:fe}),e[31]=a,e[32]=fe,e[33]=_):_=e[33];let le;e[34]!==_?(le=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:_}),e[34]=_,e[35]=le):le=e[35];let ee;e[36]!==i||e[37]!==n.id||e[38]!==l||e[39]!==a?(ee=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(E,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=i,e[37]=n.id,e[38]=l,e[39]=a,e[40]=ee):ee=e[40];let ue;e[41]!==le||e[42]!==ee?(ue=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[le,ee]}),e[41]=le,e[42]=ee,e[43]=ue):ue=e[43];let W;e[44]!==a?(W=a("multirun.launcher.groups.prompt.label"),e[44]=a,e[45]=W):W=e[45];let ne;e[46]!==W?(ne=s.jsx(Hn,{required:!0,children:W}),e[46]=W,e[47]=ne):ne=e[47];const pe=n.prompt;let xe;e[48]!==I?(xe=ie=>{const Oe=ie.target.value;I(Oe);const Fe=ie.target.selectionStart??Oe.length;L(Oe,Fe)},e[48]=I,e[49]=xe):xe=e[49];let Ce;e[50]!==a?(Ce=a("multirun.launcher.groups.prompt.placeholder"),e[50]=a,e[51]=Ce):Ce=e[51];let Me;e[52]!==n.prompt||e[53]!==se||e[54]!==xe||e[55]!==Ce?(Me=s.jsx(lr,{ref:S,value:pe,onChange:xe,onKeyDown:se,placeholder:Ce,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]=se,e[54]=xe,e[55]=Ce,e[56]=Me):Me=e[56];let ve;e[57]!==w||e[58]!==Y||e[59]!==g?(ve=g?s.jsx(Gd,{ref:C,searchQuery:w,onCommandSelect:Y,onClose:()=>p(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=w,e[58]=Y,e[59]=g,e[60]=ve):ve=e[60];let Ie;e[61]!==U||e[62]!==T||e[63]!==h||e[64]!==u?(Ie=u?s.jsx(qd,{ref:N,searchQuery:h,onFileSelect:T,onAgentSelect:U,onClose:()=>d(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=U,e[62]=T,e[63]=h,e[64]=u,e[65]=Ie):Ie=e[65];let ye;e[66]!==Z||e[67]!==x||e[68]!==b?(ye=x?s.jsx(Qd,{ref:k,searchQuery:b,onSnippetSelect:Z,onClose:()=>m(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=Z,e[67]=x,e[68]=b,e[69]=ye):ye=e[69];let q;e[70]!==Me||e[71]!==ve||e[72]!==Ie||e[73]!==ye?(q=s.jsxs("div",{className:"relative",children:[Me,ve,Ie,ye]}),e[70]=Me,e[71]=ve,e[72]=Ie,e[73]=ye,e[74]=q):q=e[74];let De;e[75]!==ne||e[76]!==q?(De=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[ne,q]}),e[75]=ne,e[76]=q,e[77]=De):De=e[77];let ke;e[78]!==a?(ke=a("multirun.launcher.models.info"),e[78]=a,e[79]=ke):ke=e[79];let te;e[80]!==ke?(te=s.jsx(To,{children:ke}),e[80]=ke,e[81]=te):te=e[81];let he;e[82]!==a?(he=a("multirun.launcher.models.label"),e[82]=a,e[83]=he):he=e[83];let ae;e[84]!==te||e[85]!==he?(ae=s.jsx(Hn,{required:!0,info:te,children:he}),e[84]=te,e[85]=he,e[86]=ae):ae=e[86];let Q;e[87]!==n.models||e[88]!==P||e[89]!==M||e[90]!==R?(Q=s.jsx(pm,{selectedModels:n.models,onAdd:P,onRemove:M,onUpdate:R,minModels:1}),e[87]=n.models,e[88]=P,e[89]=M,e[90]=R,e[91]=Q):Q=e[91];let z;e[92]!==ae||e[93]!==Q?(z=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[ae,Q]}),e[92]=ae,e[93]=Q,e[94]=z):z=e[94];let G;return e[95]!==ue||e[96]!==De||e[97]!==z?(G=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[ue,De,z]}),e[95]=ue,e[96]=De,e[97]=z,e[98]=G):G=e[98],G},$4=t=>{const e=new Map;for(const n of t){const r=_s(n);r&&e.set(n.id,{directory:r,sessionId:n.id})}return e},W4=(t,e)=>{if(!t)return[];const n=[];return t.forEach((r,i)=>{e.has(i)||n.push(r)}),n},z4=t=>{const e=Xe.c(5),{enabled:n,hasAuthoritativeGlobalSessions:r,sessions:i}=t,o=n===void 0?!0:n,l=c.useRef(null);let a,u;e[0]!==o||e[1]!==r||e[2]!==i?(a=()=>{if(!o||!r)return;const d=xs(),h=$4(i),f=l.current?.runtimeKey===d?l.current.identities:null;for(const g of W4(f,h))lp({runtimeKey:d,...g});l.current={runtimeKey:d,identities:h}},u=[o,r,i],e[0]=o,e[1]=r,e[2]=i,e[3]=a,e[4]=u):(a=e[3],u=e[4]),c.useEffect(a,u)},V4=new Map,U4=t=>{const e=Xe.c(26),{isVSCode:n}=t,r=Ma(),i=zt(K4),o=zt(H4),l=es(G4),a=Qe(q4);let u;e[0]!==n?(u=D=>n?V4:D.availableWorktreesByProject,e[0]=n,e[1]=u):u=e[1];const d=Qe(u),h=!n;let f;e[2]!==d||e[3]!==i||e[4]!==h?(f=ym(i,d,{includeWorktrees:h}),e[2]=d,e[3]=i,e[4]=h,e[5]=f):f=e[5];const g=f,p=Ds(Q4),w=Ds(Y4),v=Ds(X4),x=`session-list-sync:${c.useId()}`;let m,b;e[6]!==o||e[7]!==x||e[8]!==r||e[9]!==l||e[10]!==a||e[11]!==g||e[12]!==i?(m=()=>(r.setBootstrapDemand(x,cm({knownDirectories:g,activeProjectDirectory:dt(i.find(D=>D.id===o)?.path??null),activeProjectId:o,collapsedProjects:new Set,collapsedGroups:new Set,currentDirectory:l,currentSessionDirectory:a})),()=>r.clearBootstrapDemand(x)),b=[o,x,r,l,a,g,i],e[6]=o,e[7]=x,e[8]=r,e[9]=l,e[10]=a,e[11]=g,e[12]=i,e[13]=m,e[14]=b):(m=e[13],b=e[14]),c.useEffect(m,b);const y=c.useRef(null);let S,N;e[15]!==n||e[16]!==g?(S=()=>{const D=new Set(g),M=y.current;y.current=D;const $=M?[...D].filter(R=>!M.has(R)):n?[...D]:[];$.length&&Sa($,Mo())},N=[n,g],e[15]=n,e[16]=g,e[17]=S,e[18]=N):(S=e[17],N=e[18]),c.useEffect(S,N);let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=[],e[19]=C):C=e[19],c.useEffect(J4,C);let k;e[20]!==w||e[21]!==p?(k=[...p,...w],e[20]=w,e[21]=p,e[22]=k):k=e[22];const A=k;let P;e[23]!==A||e[24]!==v?(P={enabled:!0,hasAuthoritativeGlobalSessions:v,sessions:A},e[23]=A,e[24]=v,e[25]=P):P=e[25],z4(P)};function K4(t){return t.projects}function H4(t){return t.activeProjectId}function G4(t){return t.currentDirectory}function q4(t){return t.currentSessionDirectory}function Q4(t){return t.activeSessions}function Y4(t){return t.archivedSessions}function X4(t){return t.status==="ready"}function J4(){let t=null,e=!1;const n=new Set,r=Jr(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(),Oa(Mo());return}const o=[...n];n.clear(),o.length&&Sa(o,Mo())},500)});return()=>{t&&clearTimeout(t),r()}}const Z4=$n(()=>_n(()=>import("./SettingsWindow-COzgfFxM.js"),__vite__mapDeps([139,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,140,116,141,126,127,128,129,117,118,102,103,87,88,89,90,91,92,93,94,95,96,97,98,99,100,142,143])).then(t=>({default:t.SettingsWindow}))),e3=()=>{const t=Xe.c(58);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],U4(e);const n=Te(t3),r=Te(s3),i=Te(n3),o=Te(r3),[l,a]=c.useState(!1);let u,d;t[1]!==i?(u=()=>{i&&a(!0)},d=[i],t[1]=i,t[2]=u,t[3]=d):(u=t[2],d=t[3]),c.useEffect(u,d);const h=Te(o3),f=Te(i3),g=Te(a3),p=Te(l3),w=Te(c3),v=Te(d3),x=p||w||!!v||h;let m;t[4]===Symbol.for("react.memo_cache_sentinel")?(m=[],t[4]=m):m=t[4],c.useEffect(m3,m);const{isMobile:b}=Ln();dg();const y=$x();let S,N;t[5]!==b||t[6]!==r?(S=()=>{Te.getState().isMobile!==b&&r(b)},N=[b,r],t[5]=b,t[6]=r,t[7]=S,t[8]=N):(S=t[7],N=t[8]),c.useEffect(S,N);let C,k,A,P;t[9]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(TS,{}),k=s.jsx(Nv,{}),A=s.jsx(Tv,{}),P=s.jsx(Lk,{}),t[9]=C,t[10]=k,t[11]=A,t[12]=P):(C=t[9],k=t[10],A=t[11],P=t[12]);let D;t[13]!==y?(D=s.jsx($k,{value:y,onMoveSessionOnly:f3,onMoveAllChanges:h3,onCancel:Qx}),t[13]=y,t[14]=D):D=t[14];let M;t[15]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(rb,{}),t[15]=M):M=t[15];let $;t[16]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx(nb,{}),t[16]=$):$=t[16];let R;t[17]!==n?(R=s.jsx(_k,{isVisible:n}),t[17]=n,t[18]=R):R=t[18];let K;t[19]!==b||t[20]!==n||t[21]!==R?(K=s.jsx(sb,{isOpen:n,isMobile:b,className:"border-border",topBar:$,children:R}),t[19]=b,t[20]=n,t[21]=R,t[22]=K):K=t[22];let L;t[23]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx(eb,{}),t[23]=L):L=t[23];const O=x&&"invisible";let I;t[24]!==O?(I=Re("absolute inset-0",O),t[24]=O,t[25]=I):I=t[25];const j=!i&&!x;let T;t[26]!==j?(T=s.jsx(Hs,{children:s.jsx(iu,{active:j})}),t[26]=j,t[27]=T):T=t[27];let F;t[28]!==I||t[29]!==T?(F=s.jsx("div",{className:I,children:T}),t[28]=I,t[29]=T,t[30]=F):F=t[30];let U;t[31]!==h||t[32]!==g||t[33]!==f?(U=h&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Hs,{children:s.jsx(_4,{isWindowed:!0,initialPrompt:g,onCreated:()=>f(!1),onCancel:()=>f(!1)})})}),t[31]=h,t[32]=g,t[33]=f,t[34]=U):U=t[34];let H;t[35]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx(Hs,{children:s.jsx(f4,{})}),t[35]=H):H=t[35];let Y;t[36]===Symbol.for("react.memo_cache_sentinel")?(Y=s.jsx(Hs,{children:s.jsx(h4,{})}),t[36]=Y):Y=t[36];let me;t[37]===Symbol.for("react.memo_cache_sentinel")?(me=s.jsx(Hs,{children:s.jsx(k4,{})}),t[37]=me):me=t[37];let Z;t[38]!==F||t[39]!==U?(Z=s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[F,U,H,Y,me]}),t[38]=F,t[39]=U,t[40]=Z):Z=t[40];let re;t[41]===Symbol.for("react.memo_cache_sentinel")?(re=s.jsx(eS,{}),t[41]=re):re=t[41];let se;t[42]!==Z?(se=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:[Z,re]})})}),t[42]=Z,t[43]=se):se=t[43];let fe;t[44]===Symbol.for("react.memo_cache_sentinel")?(fe=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(Hs,{children:s.jsx(dS,{})})}),t[44]=fe):fe=t[44];let _;t[45]!==se?(_=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[L,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[se,fe]})]}),t[45]=se,t[46]=_):_=t[46];let le;t[47]!==K||t[48]!==_?(le=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[K,_]}),t[47]=K,t[48]=_,t[49]=le):le=t[49];let ee;t[50]!==i||t[51]!==o||t[52]!==l?(ee=l?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Z4,{open:i,onOpenChange:o})}):null,t[50]=i,t[51]=o,t[52]=l,t[53]=ee):ee=t[53];let ue;return t[54]!==D||t[55]!==le||t[56]!==ee?(ue=s.jsx(ug,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[C,k,A,P,D,M,le,ee]})}),t[54]=D,t[55]=le,t[56]=ee,t[57]=ue):ue=t[57],ue};function t3(t){return t.isSidebarOpen}function s3(t){return t.setIsMobile}function n3(t){return t.isSettingsDialogOpen}function r3(t){return t.setSettingsDialogOpen}function o3(t){return t.isMultiRunLauncherOpen}function i3(t){return t.setMultiRunLauncherOpen}function a3(t){return t.multiRunLauncherPrefillPrompt}function l3(t){return t.isScheduledTasksDialogOpen}function c3(t){return t.isArchivePageOpen}function d3(t){return t.worktreesPageProjectId}function u3(){return Te.getState().closeMainSurfaces()}function m3(){const t=u3,e=Qe.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 f3(){return Ru(!1)}function h3(){return Ru(!0)}const jm=12,p3=[{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"}],g3=t=>{const e=Xe.c(18),{isActive:n,burstKey:r,className:i,durationMs:o,bursts:l,onComplete:a}=t,u=r===void 0?0:r,d=o===void 0?900:o,h=l===void 0?p3:l,f=rt.useRef(!1);let g,p;e[0]!==n||e[1]!==a?(g=()=>{!n&&f.current&&a?.(),n&&(f.current=!0)},p=[n,a],e[0]=n,e[1]=a,e[2]=g,e[3]=p):(g=e[2],p=e[3]),rt.useEffect(g,p);let w;e[4]===Symbol.for("react.memo_cache_sentinel")?(w=Array.from({length:jm},x3),e[4]=w):w=e[4];const v=w;if(!n)return null;let x;e[5]!==i?(x=Re("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=x):x=e[6];let m;if(e[7]!==u||e[8]!==h||e[9]!==d){let y;e[11]!==u||e[12]!==d?(y=S=>{const N={"--burst-delay":`${S.delay}ms`,"--burst-x":`${S.x}%`,"--burst-y":`${S.y}%`,"--firework-color":`var(${S.colorVar})`,"--firework-duration":`${d}ms`};return s.jsx("div",{className:"firework-burst",style:N,children:v.map((C,k)=>{const A=C.x*S.radius,P=C.y*S.radius,D={"--translate-x":`${A}px`,"--translate-y":`${P}px`,"--particle-delay":`${C.delay}ms`,color:`var(${S.colorVar})`};return s.jsx("span",{className:"firework-particle",style:D},`${S.id}-${k}-${u}`)})},`${S.id}-${u}`)},e[11]=u,e[12]=d,e[13]=y):y=e[13],m=h.map(y),e[7]=u,e[8]=h,e[9]=d,e[10]=m}else m=e[10];let b;return e[14]!==u||e[15]!==x||e[16]!==m?(b=s.jsx("div",{className:x,"aria-hidden":"true","data-burst-key":u,children:m}),e[14]=u,e[15]=x,e[16]=m,e[17]=b):b=e[17],b};function x3(t,e){const n=Math.PI*2*e/jm;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const b3=t=>{const e=Xe.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]=rt.useState(o),u=rt.useRef(null);let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{u.current&&(window.clearTimeout(u.current),u.current=null)},e[3]=d):d=e[3];const h=d;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{h(),a(y3)},e[4]=f):f=e[4];const g=f;let p;e[5]!==i?(p=()=>{h(),a(w3),u.current=window.setTimeout(()=>{a(S3),u.current=null},i)},e[5]=i,e[6]=p):p=e[6];const w=p;let v,x;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>()=>h(),x=[h],e[7]=v,e[8]=x):(v=e[7],x=e[8]),rt.useEffect(v,x);let m;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==w?(m={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:w,dismissFireworks:g},e[9]=l.cycle,e[10]=l.isActive,e[11]=w,e[12]=m):m=e[12],m};function y3(t){return t.isActive?{...t,isActive:!1}:t}function w3(t){return{isActive:!0,cycle:t.cycle+1}}function S3(t){return t.isActive?{...t,isActive:!1}:t}const km=c.createContext(void 0),v3=t=>{const e=Xe.c(10),{children:n}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=b3();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 u=a;let d;e[3]!==i||e[4]!==r?(d=s.jsx(g3,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=d):d=e[5];let h;return e[6]!==n||e[7]!==d||e[8]!==u?(h=s.jsxs(km.Provider,{value:u,children:[n,d]}),e[6]=n,e[7]=d,e[8]=u,e[9]=h):h=e[9],h},i5=()=>{const t=c.useContext(km);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},ha="openchamber_requests_in_flight",Cm=1e3,j3=300*1e3,Ko=Math.ceil(j3/Cm),k3=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(ha)==="1"}catch{return!1}},Nm=()=>({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 C3=1;const N3=(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))},A3=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},Am=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},yr=(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)},P3=()=>{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=C3++;N3(o,Date.now());try{return await e(r,i)}finally{A3(o)}};window.fetch=n},Qc=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Ir=t=>{t.length>Ko&&t.splice(0,t.length-Ko)},D3=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=Am(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(yr(e,50)),t.p90Samples.push(yr(e,90)),t.p99Samples.push(yr(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Ir(t.samples),Ir(t.p50Samples),Ir(t.p90Samples),Ir(t.p99Samples),Ir(t.maxSamples),t.lastSampleAt=Date.now()},T3=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(D3,Cm))},Yc=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Xc=t=>{if(!(typeof window>"u"))try{if(t){Yc(),Qc(),window.localStorage.setItem(ha,"1"),window.__openchamberRequestsInFlight__=Nm(),P3(),T3();return}window.localStorage.removeItem(ha),Yc(),Qc(),delete window.__openchamberRequestsInFlight__}catch{}},I3=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=Nm();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},pa=()=>{if(typeof window>"u")return Jc();const t=window.__openchamberRequestsInFlight__;if(!k3()||!t)return Jc();const e=Am(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:yr(e,50),ageP90:yr(e,90),ageP99:yr(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}},Jc=()=>({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 R3(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const Pm=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`},ga=t=>`${(t/1e3).toFixed(2)} s`,ws=t=>{const e=Xe.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},Zc=t=>{const e=Xe.c(43),{title:n,snapshot:r,emptyLabel:i}=t,{t:o}=pt();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 u;e[8]!==r.entries?(u=r.entries.reduce(O3,0),e[8]=r.entries,e[9]=u):u=e[9];const d=u;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?Pm(r.durationMs):o("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=o,e[15]=f):f=e[15];let g;e[16]!==f?(g=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=g):g=e[17];let p;e[18]!==h||e[19]!==g?(p=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h,g]}),e[18]=h,e[19]=g,e[20]=p):p=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(ws,{label:w,value:r.entries.length}),e[23]=r.entries.length,e[24]=w,e[25]=v):v=e[25];let x;e[26]!==o?(x=o("memoryDebugPanel.metric.samples"),e[26]=o,e[27]=x):x=e[27];let m;e[28]!==x||e[29]!==d?(m=s.jsx(ws,{label:x,value:d}),e[28]=x,e[29]=d,e[30]=m):m=e[30];let b;e[31]!==o?(b=o("memoryDebugPanel.metric.lastUpdate"),e[31]=o,e[32]=b):b=e[32];let y;e[33]!==r.lastUpdatedAt||e[34]!==o?(y=r.lastUpdatedAt?o("memoryDebugPanel.common.live"):o("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=o,e[35]=y):y=e[35];let S;e[36]!==b||e[37]!==y?(S=s.jsx(ws,{label:b,value:y}),e[36]=b,e[37]=y,e[38]=S):S=e[38];let N;e[39]!==m||e[40]!==S||e[41]!==v?(N=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[v,m,S]}),e[39]=m,e[40]=S,e[41]=v,e[42]=N):N=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:[p,N,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(Cn,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:a.map(C=>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:C.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:C.count})}),s.jsx("span",{children:o("memoryDebugPanel.metric.avgValue",{value:C.avg})}),s.jsx("span",{children:o("memoryDebugPanel.metric.maxValue",{value:C.max})}),s.jsx("span",{children:o("memoryDebugPanel.metric.totalValue",{value:C.total})})]})]},C.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},ed=t=>{const e=Xe.c(24),{series:n,peak:r,windowSeconds:i,ariaLabel:o,maxLabel:l}=t,a=i,u=n.reduce(B3,0),d=r>0?52/r:0;let h;e[0]!==u||e[1]!==a?(h=S=>a-u+S,e[0]=u,e[1]=a,e[2]=h):h=e[2];const f=h;let g;e[3]!==d?(g=S=>56-S*d,e[3]=d,e[4]=g):g=e[4];const p=g;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 x;e[7]!==a?(x=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]=x):x=e[8];let m;if(e[9]!==n||e[10]!==f||e[11]!==p){let S;e[13]!==f||e[14]!==p?(S=(N,C)=>{const k=N.samples.length;if(k===0)return null;const A=N.samples.map((D,M)=>`${f(M)},${p(D).toFixed(2)}`),P=`M ${A.join(" L ")}`;return s.jsxs(c.Fragment,{children:[N.filled?s.jsx("path",{d:`M ${f(0)},56 L ${A.join(" L ")} L ${f(k-1)},56 Z`,fill:`color-mix(in srgb, ${N.color} 18%, transparent)`,stroke:"none"}):null,s.jsx("path",{d:P,fill:"none",stroke:N.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},C)},e[13]=f,e[14]=p,e[15]=S):S=e[15],m=n.map(S),e[9]=n,e[10]=f,e[11]=p,e[12]=m}else m=e[12];let b;e[16]!==o||e[17]!==v||e[18]!==x||e[19]!==m?(b=s.jsxs("svg",{viewBox:v,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":o,children:[x,m]}),e[16]=o,e[17]=v,e[18]=x,e[19]=m,e[20]=b):b=e[20];let y;return e[21]!==w||e[22]!==b?(y=s.jsxs("div",{className:"relative w-full",children:[w,b]}),e[21]=w,e[22]=b,e[23]=y):y=e[23],y},E3=t=>{const e=Xe.c(100),{onClose:n}=t,{t:r}=pt(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),u=Qe(F3),d=Vd(_3),h=Dd(),f=cp(L3),g=Ks($3),[p,w]=c.useState(W3),[v,x]=c.useState(z3),[m,b]=c.useState(V3),y=[{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 S;e[0]!==m.samples?(S=m.samples.reduce(U3,0),e[0]=m.samples,e[1]=S):S=e[1];const N=S,C=y.reduce(H3,0);let k;e[2]!==p.entries?(k=new Map,p.entries.forEach(be=>{k.set(be.metric,be.count)}),e[2]=p.entries,e[3]=k):k=e[3];let A;e[4]!==k?(A=k.get("ui.message_list.render")??0,e[4]=k,e[5]=A):A=e[5];let P;e[6]!==k?(P=k.get("ui.message_list.render.streaming")??0,e[6]=k,e[7]=P):P=e[7];let D;e[8]!==k?(D=k.get("ui.chat_message.render")??0,e[8]=k,e[9]=D):D=e[9];let M;e[10]!==k?(M=k.get("ui.chat_message.render.streaming")??0,e[10]=k,e[11]=M):M=e[11];let $;e[12]!==k?($=k.get("ui.chat_message.render.static_during_stream")??0,e[12]=k,e[13]=$):$=e[13];let R;e[14]!==k?(R=k.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=k,e[15]=R):R=e[15];let K;e[16]!==A||e[17]!==P||e[18]!==D||e[19]!==M||e[20]!==$||e[21]!==R?(K={messageListRender:A,messageListRenderStreaming:P,chatMessageRender:D,chatMessageRenderStreaming:M,chatMessageRenderStaticDuringStream:$,chatMessageRenderStaticOutsideActiveTurnDuringStream:R},e[16]=A,e[17]=P,e[18]=D,e[19]=M,e[20]=$,e[21]=R,e[22]=K):K=e[22];const L=K;let O,I;e[23]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{const be=()=>{w(go()),x(xo()),b(pa())};be();const ge=window.setInterval(be,500);return()=>window.clearInterval(ge)},O=[],e[23]=O,e[24]=I):(O=e[23],I=e[24]),c.useEffect(I,O);let j,T;e[25]!==l?(j=()=>{if(l==="idle")return;const be=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(be)},T=[l],e[25]=l,e[26]=j,e[27]=T):(j=e[26],T=e[27]),c.useEffect(j,T);let F=0,U=0,H=0;for(const be of Object.keys(f)){const ge=f[be]??[];U=U+ge.length;for(const _e of ge)_e.role==="user"?H=H+1:_e.role==="assistant"&&(F=F+1)}let Y;e[28]!==F||e[29]!==U||e[30]!==H?(Y={assistant:F,total:U,user:H},e[28]=F,e[29]=U,e[30]=H,e[31]=Y):Y=e[31];const me=Y;let Z;if(e[32]!==u||e[33]!==f||e[34]!==d||e[35]!==h||e[36]!==r){let be;e[38]!==u||e[39]!==f||e[40]!==d||e[41]!==r?(be=ge=>{const _e=f[ge.id]??[];let tt=0,Ue=0;for(const X of _e)X.role==="user"?Ue=Ue+1:X.role==="assistant"&&(tt=tt+1);const de=d.get(ge.id);return{id:ge.id,title:ge.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:tt,messageCount:_e.length,userMessageCount:Ue,isStreaming:de?.isStreaming||!1,isZombie:de?.isZombie||!1,backgroundCount:de?.backgroundMessageCount||0,lastAccessed:de?.lastAccessedAt||0,isCurrent:ge.id===u}},e[38]=u,e[39]=f,e[40]=d,e[41]=r,e[42]=be):be=e[42],Z=h.map(be).sort(G3),e[32]=u,e[33]=f,e[34]=d,e[35]=h,e[36]=r,e[37]=Z}else Z=e[37];const re=Z;let se;e[43]!==f?(se=Object.keys(f),e[43]=f,e[44]=se):se=e[44];const fe=se.length;let _;e[45]===Symbol.for("react.memo_cache_sentinel")?(_=async()=>{try{const be={generatedAt:new Date().toISOString(),ui:go(),vscode:xo()};await navigator.clipboard.writeText(JSON.stringify(be,null,2)),a("copied")}catch{a("error")}},e[45]=_):_=e[45];const le=_,ee=up,ue="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let W;e[46]===Symbol.for("react.memo_cache_sentinel")?(W={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=W):W=e[46];let ne;e[47]!==i?(ne=R3(i),e[47]=i,e[48]=ne):ne=e[48];let pe;e[49]!==ne?(pe=s.jsx(E,{name:ne,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=ne,e[50]=pe):pe=e[50];let xe;e[51]!==r?(xe=r("memoryDebugPanel.title"),e[51]=r,e[52]=xe):xe=e[52];let Ce;e[53]!==xe?(Ce=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:xe}),e[53]=xe,e[54]=Ce):Ce=e[54];let Me;e[55]!==pe||e[56]!==Ce?(Me=s.jsxs("div",{className:"flex items-center gap-2",children:[pe,Ce]}),e[55]=pe,e[56]=Ce,e[57]=Me):Me=e[57];let ve;e[58]!==i?(ve=i==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(ot,{size:"xs",variant:"ghost",onClick:le,children:s.jsx(E,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(ot,{size:"xs",variant:"ghost",onClick:()=>{uf(),w(go()),x(xo())},children:s.jsx(E,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=i,e[59]=ve):ve=e[59];let Ie;e[60]!==i?(Ie=i==="requests"?s.jsx(ot,{size:"xs",variant:"ghost",onClick:()=>{I3(),b(pa())},children:s.jsx(E,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=i,e[61]=Ie):Ie=e[61];let ye;e[62]!==n?(ye=n?s.jsx(ot,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(E,{name:"close",className:"h-4 w-4"})}):null,e[62]=n,e[63]=ye):ye=e[63];let q;e[64]!==ve||e[65]!==Ie||e[66]!==ye?(q=s.jsxs("div",{className:"flex items-center gap-1",children:[ve,Ie,ye]}),e[64]=ve,e[65]=Ie,e[66]=ye,e[67]=q):q=e[67];let De;e[68]!==Me||e[69]!==q?(De=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[Me,q]}),e[68]=Me,e[69]=q,e[70]=De):De=e[70];let ke;e[71]===Symbol.for("react.memo_cache_sentinel")?(ke={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=ke):ke=e[71];const te=i==="memory"?"secondary":"ghost";let he;e[72]===Symbol.for("react.memo_cache_sentinel")?(he=()=>o("memory"),e[72]=he):he=e[72];let ae;e[73]!==r?(ae=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=ae):ae=e[74];let Q;e[75]!==te||e[76]!==ae?(Q=s.jsx(ot,{size:"sm",variant:te,className:"flex-1",onClick:he,children:ae}),e[75]=te,e[76]=ae,e[77]=Q):Q=e[77];const z=i==="streaming"?"secondary":"ghost";let G;e[78]===Symbol.for("react.memo_cache_sentinel")?(G=()=>o("streaming"),e[78]=G):G=e[78];let ie;e[79]!==r?(ie=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=ie):ie=e[80];let Oe;e[81]!==z||e[82]!==ie?(Oe=s.jsx(ot,{size:"sm",variant:z,className:"flex-1",onClick:G,children:ie}),e[81]=z,e[82]=ie,e[83]=Oe):Oe=e[83];const Fe=i==="requests"?"secondary":"ghost";let Se;e[84]===Symbol.for("react.memo_cache_sentinel")?(Se=()=>o("requests"),e[84]=Se):Se=e[84];let oe;e[85]!==r?(oe=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=oe):oe=e[86];let Pe;e[87]!==Fe||e[88]!==oe?(Pe=s.jsx(ot,{size:"sm",variant:Fe,className:"flex-1",onClick:Se,children:oe}),e[87]=Fe,e[88]=oe,e[89]=Pe):Pe=e[89];let Ne;e[90]!==Q||e[91]!==Oe||e[92]!==Pe?(Ne=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:ke,children:[Q,Oe,Pe]}),e[90]=Q,e[91]=Oe,e[92]=Pe,e[93]=Ne):Ne=e[93];const B=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(ws,{label:r("memoryDebugPanel.metric.totalMessages"),value:me.total}),s.jsx(ws,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${fe} / ${xl.MAX_SESSIONS}`}),s.jsx(ws,{label:r("memoryDebugPanel.metric.userMessages"),value:me.user}),s.jsx(ws,{label:r("memoryDebugPanel.metric.assistantMessages"),value:me.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:dp()})})]}),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:xl.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:g})]})]}),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(Cn,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:re.map(be=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:be.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:be.title}),be.isStreaming?s.jsx(E,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,be.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:be.assistantMessageCount,user:be.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:be.messageCount})}),be.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",be.backgroundCount]}):null]})]},be.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(xt,{children:[s.jsx(bt,{asChild:!0,children:s.jsx(ot,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:h.map(q3),currentSessionId:u,cachedSessions:Object.keys(f),messageRoleCounts:me,sessionMessageRoleCounts:re.map(Q3),memoryStates:Object.fromEntries(d)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(yt,{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(ot,{size:"xs",variant:"outline",onClick:le,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(ws,{label:r("memoryDebugPanel.metric.uiMetrics"),value:p.entries.length}),s.jsx(ws,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:v.entries.length}),s.jsx(ws,{label:r("memoryDebugPanel.metric.messageListRenders"),value:L.messageListRender}),s.jsx(ws,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:L.messageListRenderStreaming}),s.jsx(ws,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:L.chatMessageRender}),s.jsx(ws,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:L.chatMessageRenderStreaming}),s.jsx(ws,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:L.chatMessageRenderStaticDuringStream}),s.jsx(ws,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:L.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(Zc,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:p,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),v.entries.length>0?s.jsx(Zc,{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(ws,{label:r("memoryDebugPanel.requests.totalRequests"),value:`${m.totalSettled} / ${m.totalStarted}`}),s.jsx(ws,{label:r("memoryDebugPanel.requests.tracking"),value:m.startedAt?Pm(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(ed,{series:[{samples:m.samples,color:"var(--status-info)",filled:!0}],peak:N,windowSeconds:m.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:m.peak}),maxLabel:`${N}`}),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:ga(m.peakAgeMs)})]}),s.jsx(ed,{series:y.map(Y3),peak:C,windowSeconds:m.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:ga(C)}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:y.map(X3)}),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 ce;return e[94]!==ee||e[95]!==W||e[96]!==De||e[97]!==Ne||e[98]!==B?(ce=s.jsxs(ee,{className:ue,style:W,children:[De,Ne,B]}),e[94]=ee,e[95]=W,e[96]=De,e[97]=Ne,e[98]=B,e[99]=ce):ce=e[99],ce},M3=E3;function O3(t,e){return t+e.count}function B3(t,e){return Math.max(t,e.samples.length)}function F3(t){return t.currentSessionId}function _3(t){return t.sessionMemoryState}function L3(t){return t.message}function $3(t){return t.totalRequestCount}function W3(){return go()}function z3(){return xo()}function V3(){return pa()}function U3(t,e){return Math.max(t,e)}function K3(t,e){return Math.max(t,e)}function H3(t,e){return e.samples.reduce(K3,t)}function G3(t,e){return e.lastAccessed-t.lastAccessed}function q3(t){return{id:t.id,title:t.title}}function Q3(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function Y3(t){return{samples:t.samples,color:t.color}}function X3(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:ga(t.current)})]},t.label)}const J3=()=>{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()??"":""},Z3=async()=>{const t=J3()||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")},td="openchamber:menu-action",ki="openchamber:check-for-updates",eC=t=>{const e=Qe(m=>m.openNewSessionDraft),n=Te(m=>m.toggleCommandPalette),r=Te(m=>m.setCommandPaletteOpen),i=Te(m=>m.toggleHelpDialog),o=Te(m=>m.toggleSidebar),l=Te(m=>m.setSessionSwitcherOpen),a=Te(m=>m.setSettingsDialogOpen),u=Te(m=>m.setAboutDialogOpen),d=Or(m=>m.checkForUpdates),{setThemeMode:h}=er(),f=c.useRef(!1),g=c.useCallback(()=>{f.current||(f.current=!0,d().then(()=>{const{available:m,error:b}=Or.getState();if(b){Be.error("Failed to check for updates",{description:b});return}m||Be.success("You are on the latest version")}).finally(()=>{f.current=!1}))},[d]),p=c.useCallback(()=>{pn.requestDirectoryDialog()},[]),w=c.useCallback(m=>{const b=mp();if(b.length===0)return;const y=Qe.getState().currentSessionId,S=b.findIndex(k=>k.id===y);let N=m>0?0:b.length-1;S>=0&&(N=(S+m+b.length)%b.length);const C=b[N];C&&(l(!1),Qe.getState().setCurrentSession(C.id))},[l]),v=c.useCallback(m=>{const{activeProjectId:b,projects:y,setActiveProject:S}=zt.getState();if(y.length===0)return;const N=y.findIndex(A=>A.id===b);let C=m>0?0:y.length-1;N>=0&&(C=(N+m+y.length)%y.length);const k=y[C];k&&S(k.id)},[]),x=c.useCallback(m=>{switch(m){case"about":u(!0);break;case"settings":a(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const b=Qe.getState(),y=es.getState().currentDirectory;e(b.currentSessionId&&y?{directoryOverride:y}:void 0)}break;case"new-worktree-session":l(!1),Od();break;case"change-workspace":p();break;case"toggle-right-sidebar":{const b=es.getState().currentDirectory;if(!b)break;const y=Te.getState(),S=or(b),N=y.contextPanelByDirectory[S];N?.isOpen?y.closeContextPanel(S):N?.activeTabId?y.setActiveContextPanelTab(S,N.activeTabId):y.openContextSurface(S,"git");break}case"open-right-sidebar-git":{const b=es.getState().currentDirectory;if(!b)break;Te.getState().openContextSurface(or(b),"git");break}case"open-right-sidebar-files":{const b=es.getState().currentDirectory;if(!b)break;Te.getState().openContextSurface(or(b),"file");break}case"toggle-terminal":{const b=es.getState().currentDirectory;if(!b)break;Te.getState().openContextSurface(or(b),"terminal");break}case"toggle-terminal-expanded":{const b=es.getState().currentDirectory;if(!b)break;const y=or(b),S=Te.getState(),N=S.contextPanelByDirectory[y];(N?.isOpen?N.tabs.find(k=>k.id===N.activeTabId)?.mode:null)!=="terminal"&&S.openContextSurface(y,"terminal"),S.toggleContextPanelExpanded(y);break}case"copy":{const b=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(b)||Z3();break}case"theme-light":h("light");break;case"theme-dark":h("dark");break;case"theme-system":h("system");break;case"add-selection-to-chat":fp();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":es.getState().goBack();break;case"go-forward":es.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":{Bd().catch(()=>{Be.error("Failed to collect OpenCode status")});break}}},[p,v,w,t,e,u,l,r,a,h,n,i,o]);c.useEffect(()=>{const m=y=>{const S=y.detail;S&&x(S)},b=()=>{g()};return window.addEventListener(td,m),window.addEventListener(ki,b),()=>{window.removeEventListener(td,m),window.removeEventListener(ki,b)}},[x,g]),c.useEffect(()=>{if(typeof window>"u")return;const b=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof b!="function")return;let y=null,S=null;return b("openchamber:menu-action",N=>{const C=N?.payload;typeof C=="string"&&x(C)}).then(N=>{y=N}).catch(()=>{}),b("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(ki))}).then(N=>{S=N}).catch(()=>{}),()=>{(async()=>{try{const C=y?.();C instanceof Promise&&await C}catch{}try{const C=S?.();C instanceof Promise&&await C}catch{}})()}},[x])},tC="openchamber:tray-action",sd=5e3,sC=500,Dm=20,nd=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},rd=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,nC=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},rC=t=>{const e=Array.isArray(t.questions)?t.questions[0]:void 0;return e?.header||e?.question||"Question"},Tm=(t,e)=>Hd(t,e,$r.getState().ids,Aa.getState().rankById),oC=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},iC=(t,e,n,r,i)=>{if(!t)return"";const o=gp(n,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||oC(t),u=wo(t);let d=u&&i.get(u)||"";if(!d){for(const[h,f]of Bn.getState().directories)if(wo(h)===u){d=f.status?.current??"";break}}if(!d)for(const h of r.values()){const f=h.find(g=>wo(g.path)===u);if(f?.branch){d=f.branch;break}}return d?`${a} · ${d}`:a},aC=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=ar.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 xp){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const u=[];for(const[h,f]of Object.entries(a.usage?.windows??{})){const g=r==="remaining"?f.remainingPercent:f.usedPercent;u.push({label:yp(h),value:bp(f.valueLabel,g)})}const d=!a.ok&&a.error?a.error:u.length===0?"No rate limits reported":null;o.push({provider:l.name,rows:u,status:d})}return{mode:r,groups:o}},lC=async()=>{try{if(Ho())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=Nn();if(e&&Ja(e,t))return"Local OpenChamber";const r=(await ud()).hosts.find(i=>e?Ja(e,mf(i)):!1);return r?.label?.trim()?md(r.label.trim()):"Instance"}catch{return""}},cC=()=>{const t=new Map,e=new Map,n=[],r=new Map;let i;try{i=Eo()}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(wo(o)??o,a.vcs.branch);for(const u of a.session)u?.id&&r.set(u.id,u.title);for(const[u,d]of Object.entries(a.session_status??{})){const h=d?.type,f=h==="busy"?"busy":h==="retry"?"retry":"idle",g=t.get(u);(!g||g==="idle")&&t.set(u,f)}for(const[u,d]of Object.entries(a.permission??{}))for(const h of d??[]){if(!h?.id)continue;const f=h.sessionID||u;n.push({kind:"permission",id:h.id,sessionId:f,sessionTitle:"",label:nC(h),directory:o})}for(const[u,d]of Object.entries(a.question??{}))for(const h of d??[]){if(!h?.id)continue;const f=h.sessionID||u;n.push({kind:"question",id:h.id,sessionId:f,sessionTitle:"",label:rC(h),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},dC=()=>{const t=Ds.getState().activeSessions,e=new Set;t.filter(r=>r?.id&&!r.parentID).slice().sort(Tm).slice(0,Dm).forEach(r=>{const i=_s(r);i&&e.add(i)});const n=new Map;for(const r of t){if(!r?.id)continue;const i=_s(r);if(!i||!e.has(i))continue;const o=n.get(i)??[];o.push(r.id),n.set(i,o)}return n},uC=t=>{const e=cC(),n=Ra.getState().index.session,r=Ds.getState().activeSessions,i=new Map(e.titleById),o=new Map;for(const x of r)if(x?.id&&(x.title&&i.set(x.id,x.title),x.parentID)){const m=o.get(x.parentID)??[];m.push(x.id),o.set(x.parentID,m)}const l=x=>{const m=[],b=[...o.get(x)??[]],y=new Set;for(;b.length;){const S=b.pop();y.has(S)||(y.add(S),m.push(S),b.push(...o.get(S)??[]))}return m},a=Ia.getState().statusById,u=x=>{const m=e.statusById.get(x);return m&&m!=="idle"?m:a.get(x)?.status.type??m??"idle"},d=x=>{const m=x.map(b=>u(b));return m.includes("busy")?"busy":m.includes("retry")?"retry":"idle"},h=zt.getState().projects,f=Qe.getState().availableWorktreesByProject,g=r.filter(x=>x?.id&&!x.parentID).slice().sort(Tm).slice(0,Dm).map(x=>{const m=[x.id,...l(x.id)],b=_s(x)??"";return{id:x.id,title:x.title||"Untitled session",status:d(m),branch:b?e.branchByDirectory.get(b)??"":"",unseen:m.reduce((y,S)=>y+(n.unseenCount[S]??0),0),hasError:m.some(y=>n.unseenHasError[y]??!1),directory:b,subtitle:iC(b,x,h,f,e.branchByDirectory)}}),p=e.approvals.map(x=>({...x,sessionTitle:i.get(x.sessionId)||""})),w=Te.getState();let v=0;if(w.dockBadgeEnabled)for(const x of r){if(!x?.id||x.parentID)continue;let m=n.unseenCount[x.id]??0;m===0&&w.notifyOnSubtasks&&(m=l(x.id).reduce((b,y)=>b+(n.unseenCount[y]??0),0)),m>0&&(v+=1)}return{sessions:g,approvals:p,instanceName:t,usage:aC(),dockBadgeCount:v}},mC=()=>{c.useEffect(()=>{if(!nd()||!rd()||!qo())return;let t=!1,e="",n=null,r="";const i=()=>{if(t)return;const C=uC(r),k=JSON.stringify(C);k!==e&&(e=k,Mn("desktop_tray_update",C))};lC().then(C=>{t||(r=C,i())});const o=async()=>{const C=dC();await Promise.all([...C.entries()].map(async([k,A])=>{const P=await qs.getSessionStatusForDirectory(k).catch(()=>null);t||P===null||hp(k,P,A)}))},l=()=>{t||n!==null||(n=window.setTimeout(()=>{n=null,i()},sC))},a=new Map,u=()=>{if(t)return;let C;try{C=Eo()}catch{return}const k=new Set;for(const[A,P]of C.children.entries())k.add(A),a.has(A)||a.set(A,P.subscribe(()=>l()));for(const[A,P]of a)k.has(A)||(P(),a.delete(A))};let d=null;try{d=Eo().subscribeRegistry(()=>{u(),l()})}catch{}u();const h=Ra.subscribe(()=>l()),f=Ds.subscribe(()=>l()),g=zt.subscribe(()=>l()),p=Qe.subscribe(()=>l()),w=Bn.subscribe(()=>l()),v=Te.subscribe(()=>l()),x=Ia.subscribe(()=>l()),m=Aa.subscribe(()=>l()),b=$r.subscribe(()=>l());o();const y=window.setInterval(()=>{o()},sd),S=ar.subscribe(()=>l());ar.getState().loadSettings().then(()=>{if(t)return;const{dropdownProviderIds:C,results:k}=ar.getState();C.length>0&&C.some(P=>!k.some(D=>D.providerId===P))&&ar.getState().fetchQuotas(C)});const N=window.setInterval(()=>{u(),i()},sd);return i(),()=>{t=!0,n!==null&&window.clearTimeout(n),window.clearInterval(N),window.clearInterval(y),h(),f(),g(),p(),w(),v(),x(),m(),b(),S(),d?.();for(const C of a.values())C();a.clear()}},[]),c.useEffect(()=>{if(!nd()||!rd()||typeof window>"u")return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{i.type==="respond-permission"&&pp(i.sessionId,i.id,i.response).catch(()=>{Be.error("Failed to respond to permission request")})};let r=null;return e(tC,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{}}},[])},fC=45e3,hC=(t,e,n=window.setInterval.bind(window),r=window.clearInterval.bind(window))=>{t();const i=n(e,fC);return()=>r(i)},pC=t=>{const e=Xe.c(3);let n,r;e[0]!==t?(n=()=>{if(t)return hC(gC,xC)},r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),c.useEffect(n,r)};function gC(){wp(Mo())}function xC(){Oa()}const bC="/api/notifications/stream",yC=()=>typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus(),wC=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}},SC=t=>{const e=Xe.c(3),n=t?.enabled??!0;let r,i;e[0]!==n?(r=()=>{if(!n||gn()||!ba()||typeof window>"u"||typeof EventSource>"u")return;const o=new EventSource(xa().sse(bC));return o.onmessage=vC,()=>{o.close()}},i=[n],e[0]=n,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function vC(t){let e;try{e=JSON.parse(t.data)}catch{return}const n=Te.getState();if(!n.nativeNotificationsEnabled||n.notificationMode!=="always"&&yC())return;const r=wC(e);if(!r)return;Go()?.notifications?.notifyAgentCompletion(r)}const jC=6e4,kC=t=>{const e=Xe.c(10),n=Te(CC),r=Sp(NC),o=mg(t)?.path??null;let l,a;e[0]!==n||e[1]!==r||e[2]!==o?(l=()=>{n&&r(o,{maxAgeMs:jC})},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 u,d;e[5]!==n||e[6]!==r||e[7]!==o?(u=()=>{if(n)return Jr(h=>{h.type==="agent-memory-changed"&&r(o)})},d=[n,r,o],e[5]=n,e[6]=r,e[7]=o,e[8]=u,e[9]=d):(u=e[8],d=e[9]),c.useEffect(u,d)};function CC(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function NC(t){return t.load}const od="pwa-install-toast-shown",id="pwa-install-toast-dismissed",AC=()=>{const t=Xe.c(6),{browserTab:e}=fg(),{t:n}=pt(),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"||!ba()||!e)return;let u=null,d=null;const h=()=>{d!==null&&(Be.dismiss(d),d=null)},f=async()=>{if(!u)return;const w=u;u=null,h(),await w.prompt();const{outcome:v}=await w.userChoice;v==="accepted"&&Be.success(r.current("pwa.installPrompt.started"))},g=w=>{const v=w;if(typeof v.prompt!="function")return;v.preventDefault(),u=v;const x=Io(),m=ff();hg({dismissed:x.getItem(id),sessionShown:m.getItem(od),hasActiveToast:d!==null})&&(m.setItem(od,"true"),d=Be.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:()=>{Io().setItem(id,"true"),h()}}}))},p=()=>{u=null,h(),Be.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",g),window.addEventListener("appinstalled",p),()=>{h(),window.removeEventListener("beforeinstallprompt",g),window.removeEventListener("appinstalled",p)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},PC=({open:t,onOpenChange:e})=>{const{t:n}=pt(),r=!1,[i,o]=c.useState(null),[l,a]=c.useState(null),[u,d]=c.useState(!1),[h,f]=c.useState(!1),[g,p]=c.useState(null),[w,v]=c.useState(!1);c.useCallback(async()=>{},[g,u,r,n]),c.useEffect(()=>{if(!t)return;(async()=>{try{const b=await cs("/api/system/info");if(b.ok){const y=await b.json();if(typeof y.openchamberVersion=="string"&&y.openchamberVersion.trim()){o(y.openchamberVersion);return}}}catch{}o(await vp())})()},[t]),c.useEffect(()=>{if(!t)return;let m=!1;return(async()=>{try{const y=await cs("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!y.ok)return;const S=await y.json().catch(()=>null),N=typeof S?.currentVersion=="string"?S.currentVersion.trim():"";!m&&N&&a(N)}catch{}})(),()=>{m=!0}},[t]),c.useEffect(()=>{{p(null),v(!1);return}},[t,r]);const x=i;return s.jsx(Ss,{open:t,onOpenChange:e,children:s.jsx(vs,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(Td,{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:[x&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:x})}),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(E,{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(E,{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(E,{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("/")}},Ci=(t,e)=>{const n=t.get(e);return typeof n!="string"?null:n.trim()||null},DC=(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},TC=()=>{const t=jp(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),u=Ci(a,"code"),d=kp(a),h=Cp(a),f=Ci(a,"error"),g=Ci(a,"error_description");if(f){h&&cs(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(g??f);return}(async()=>{try{if(!u)throw new Error("Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into OpenChamber manually.");let p=d,w=!1;if(h){const v=await cs(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`);if(v.ok){const x=await v.json().catch(()=>null);w=x?.origin===Np,i(w),!p&&x?.name?.trim()&&(p={name:x.name.trim(),directory:typeof x.directory=="string"&&x.directory.trim()?x.directory.trim():null})}}if(!p?.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(p.name,u,p.directory),h&&await cs(`/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(p){h&&await cs(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(DC(p,"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:Ap,children:e==="working"?"Completing Authorization":e==="success"?"Authorization Complete":"Authorization Failed"}),s.jsx("p",{className:Re("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(ot,{type:"button",onClick:()=>ad(r),children:"Return to OpenChamber"})})]})})},ld=$n(()=>_n(()=>import("./OnboardingScreen-CTZe6HZn.js"),__vite__mapDeps([144,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}))),IC=()=>{const t=Xe.c(3),e=Te(FC),n=Te(_C);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(PC,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},RC=t=>{const e=Xe.c(21),{onRetry:n,isRetrying:r}=t,{t:i}=pt();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 u;e[6]!==a?(u=s.jsx("p",{className:"typography-body text-muted-foreground",children:a}),e[6]=a,e[7]=u):u=e[7];let d;e[8]!==l||e[9]!==u?(d=s.jsxs("div",{className:"flex flex-col gap-2",children:[l,u]}),e[8]=l,e[9]=u,e[10]=d):d=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(ot,{type:"button",onClick:n,disabled:r,children:h}),e[14]=r,e[15]=n,e[16]=h,e[17]=f):f=e[17];let g;return e[18]!==d||e[19]!==f?(g=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:[d,f]})}),e[18]=d,e[19]=f,e[20]=g):g=e[20],g},cd=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",EC=()=>{if(typeof window>"u"||!_g())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}},MC=()=>typeof window>"u"?!1:window.location.pathname===Rp,OC=t=>{const e=Xe.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=es(LC),l=Qe($C),a=Qe(WC),u=Cd(),d=c.useRef(null);let h;e[0]!==n.directory?(h=cd(n.directory),e[0]=n.directory,e[1]=h):h=e[1];const f=h;let g;e[2]!==o?(g=cd(o),e[2]=o,e[3]=g):g=e[3];const p=g;let w,v;if(e[4]!==p||e[5]!==l||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==u?(w=()=>{if(r||f&&p!==f)return;const N=`${f}
|
|
928
|
-
${n.sessionId}`;d.current===N&&l||(d.current=N,a(n.sessionId,n.directory),u.ensureSessionRenderable(n.sessionId,!0))},v=[p,l,n.directory,n.sessionId,f,r,a,u],e[4]=p,e[5]=l,e[6]=n.directory,e[7]=n.sessionId,e[8]=f,e[9]=r,e[10]=a,e[11]=u,e[12]=w,e[13]=v):(w=e[12],v=e[13]),c.useEffect(w,v),f&&p!==f)return null;let x;e[14]!==i?(x=s.jsx(Yd,{embeddedBackgroundWorkEnabled:i}),e[14]=i,e[15]=x):x=e[15];let m;e[16]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(au,{}),e[16]=m):m=e[16];let b;e[17]!==i||e[18]!==n.allowPromptingSubagentSessions||e[19]!==n.readOnly?(b=s.jsx(iu,{active:i,messagesEnabled:!0,readOnly:n.readOnly,initialAllowPromptingSubagentSessions:n.allowPromptingSubagentSessions}),e[17]=i,e[18]=n.allowPromptingSubagentSessions,e[19]=n.readOnly,e[20]=b):b=e[20];let y;e[21]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(Xd,{}),e[21]=y):y=e[21];let S;return e[22]!==x||e[23]!==b?(S=s.jsxs(s.Fragment,{children:[x,m,b,y]}),e[22]=x,e[23]=b,e[24]=S):S=e[24],S};function BC({apis:t}){c.useEffect(()=>{hf("App:mounted"),pf()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=Kt(W=>W.initializeApp),n=Kt(W=>W.isInitialized),r=Kt(W=>W.isConnected),i=Kt(W=>W.providers.length),o=Kt(W=>W.agents.length),l=Kt(W=>W.loadProviders),a=Kt(W=>W.loadAgents),u=Qe(W=>W.error),d=Qe(W=>W.clearError),h=es(W=>W.currentDirectory),f=es(W=>W.setDirectory),g=es(W=>W.isSwitchingDirectory),[p,w]=c.useState(!1),v=An(W=>W.refreshStatus),x=Ti(W=>W.refreshStatus),[m,b]=c.useState(()=>t.runtime.isVSCode),[y,S]=c.useState(!1),[N,C]=c.useState(!1),[k,A]=c.useState(0),[P,D]=c.useState(0),[M,$]=c.useState(!1),R=Te(W=>W.wideChatLayoutEnabled),K=Te(W=>W.mobileKeyboardMode),L=c.useMemo(()=>gn(),[]),O=va(W=>W.setPlanModeEnabled),[I,j]=c.useState(()=>Za()),[T,F]=c.useState(()=>{const W=el();return W!==null?tl({isDesktopShell:!0,bootOutcome:W}):null}),U=c.useRef(!1),H=c.useMemo(()=>EC(),[]),Y=!H||y,me=c.useMemo(()=>MC(),[]);c.useEffect(()=>(sl(p),()=>{sl(!1)}),[p]),c.useEffect(()=>(Xc(p),()=>{Xc(!1)}),[p]),c.useEffect(()=>{gf(K)},[K]),c.useEffect(()=>{b(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>Qo(W=>{pg(W),D(ne=>ne+1),C(!1),A(ne=>ne+1)}),[]);const Z=bl(W=>{const ne=xs();return Object.values(W.runsByOriginalSessionID).filter(pe=>pe.status==="running"&&pe.runtimeKey===ne).map(pe=>`${pe.originalSessionID}:${pe.phase}:${pe.lastForwardedMessageID??""}:${pe.expectedAssistantParentID??""}`).sort().join("|")});c.useEffect(()=>{if(H)return;const W=xs(),ne=Object.values(bl.getState().runsByOriginalSessionID).filter(pe=>pe.status==="running"&&pe.runtimeKey===W);for(const pe of ne)Pp(pe.originalSessionID)},[Z,H,P]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",R),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[R]),c.useEffect(()=>(nl(t),()=>nl(null)),[t]),c.useEffect(()=>{H||(v(t.github,{force:!0}),x(t.linear,{force:!0}))},[t.github,t.linear,H,r,v,x,P]),Dp();const re=I==="valid",se=T?.screen==="main";c.useEffect(()=>{if(!xf({isDesktopShell:L,isInitialized:n,bootOutcomeKnown:re,bootViewIsMain:se}))return;const W=setTimeout(()=>{const ne=document.getElementById("initial-loading");ne&&(ne.classList.add("fade-out"),setTimeout(()=>{ne.remove()},300))},150);return()=>clearTimeout(W)},[L,n,re,se]),c.useEffect(()=>{if(!L||I!=="malformed")return;const W=document.getElementById("initial-loading");W&&(W.textContent="Desktop startup failed — please restart the app.")},[L,I]),c.useEffect(()=>{if(L)return;const W=setTimeout(()=>{const ne=document.getElementById("initial-loading");ne&&!n&&(ne.classList.add("fade-out"),setTimeout(()=>{ne.remove()},300))},5e3);return()=>clearTimeout(W)},[L,n]),c.useEffect(()=>{let W=!1;return(async()=>{const pe=await cs("/health",{method:"GET"}).catch(()=>null);if(!pe||!pe.ok||W)return;const xe=await pe.json().catch(()=>null);if(!xe||W)return;const Ce=xe.planModeExperimentalEnabled;O(Ce===!0||Ce===1||Ce==="1"||Ce==="true")})(),()=>{W=!0}},[O]),c.useEffect(()=>{m||e()},[e,m]),c.useEffect(()=>{if(m||n)return;let W=!0,ne,pe=0;const xe=10,Ce=1e3,Me=async()=>{if(!W)return;if(pe>=xe){C(!0);return}const ve=Kt.getState();if(ve.isInitialized){C(!1);return}pe+=1,await ve.initializeApp();const Ie=Kt.getState();if(!W)return;if(Ie.isInitialized){C(!1);return}if(pe>=xe){C(!0);return}const ye=Math.min(Ce*Math.pow(2,pe-1),16e3);ne=setTimeout(Me,ye)};return ne=setTimeout(Me,Ce),()=>{W=!1,ne&&clearTimeout(ne)}},[k,n,m]),c.useEffect(()=>{n&&C(!1)},[n]),c.useEffect(()=>{if(!N)return;const W=document.getElementById("initial-loading");W&&(W.classList.add("fade-out"),setTimeout(()=>{W.remove()},300))},[N]),c.useEffect(()=>{if(m||!r||i>0&&o>0)return;let W=!0,ne=0;const pe=15,xe=async()=>{const Me=Kt.getState();if(!(Me.providers.length>0&&Me.agents.length>0))try{Me.providers.length===0&&await l({source:"startupRecovery"}),Kt.getState().agents.length===0&&await a({source:"startupRecovery"})}catch{}};xe();const Ce=setInterval(()=>{if(W){if(++ne>=pe){clearInterval(Ce);return}xe()}},2e3);return()=>{W=!1,clearInterval(Ce)}},[r,m,a,l,i,o]),c.useEffect(()=>{g||m||r&&qs.setDirectory(h)},[h,g,r,m]),c.useEffect(()=>{if(!H||typeof window>"u")return;const W=xe=>{S(xe?.visible===!0)},ne=xe=>{if(xe.origin!==window.location.origin||xe.source!==window.parent)return;const Ce=xe.data;Ce?.type===gu&&W(Ce.payload)},pe=window;return pe.__openchamberSetEmbeddedVisibility=W,window.addEventListener("message",ne),Fg(),()=>{window.removeEventListener("message",ne),pe.__openchamberSetEmbeddedVisibility===W&&delete pe.__openchamberSetEmbeddedVisibility}},[H]),c.useEffect(()=>{!H?.directory||m||h!==H.directory&&f(H.directory,{showOverlay:!1})},[h,H,m,f]),c.useEffect(()=>{if(!H||typeof window>"u")return;const W=ne=>{ne.storageArea===window.localStorage&&ne.key==="ui-store"&&Te.persist.rehydrate()};return window.addEventListener("storage",W),()=>{window.removeEventListener("storage",W)}},[H]),c.useEffect(()=>{if(typeof window>"u")return;const W=ne=>{const pe=ne.detail,xe=typeof pe?.sessionId=="string"?pe.sessionId.trim():"";if(!xe)return;const Ce=typeof pe?.directory=="string"&&pe.directory.trim().length>0?pe.directory.trim():null;Qe.getState().setCurrentSession(xe,Ce)};return window.addEventListener("openchamber:open-session",W),()=>window.removeEventListener("openchamber:open-session",W)},[]),c.useEffect(()=>{if(typeof window>"u")return;const W=()=>{Mn("desktop_open_draft_mini_chat_window",{directory:"",projectId:null})};return window.addEventListener("openchamber:open-mini-chat",W),()=>window.removeEventListener("openchamber:open-mini-chat",W)},[]),c.useEffect(()=>{if(typeof window>"u")return;const W=()=>{const ne=Qe.getState().currentSessionId;ne&&Id(ne)};return window.addEventListener("focus",W),()=>window.removeEventListener("focus",W)},[]),c.useEffect(()=>{if(typeof window>"u")return;const W=ne=>{const pe=ne.detail,xe=typeof pe?.directory=="string"&&pe.directory.trim().length>0?pe.directory.trim():null,Ce=typeof pe?.projectId=="string"&&pe.projectId.trim().length>0?pe.projectId.trim():null,Me=!!(xe||Ce);Te.getState().setSessionSwitcherOpen(!1),Qe.getState().openNewSessionDraft({target:Me?"project":"chat",selectedProjectId:Me?Ce:null,directoryOverride:Me?xe:null,preserveDirectoryOverride:!!xe})};return window.addEventListener("openchamber:open-draft-session",W),()=>window.removeEventListener("openchamber:open-draft-session",W)},[]),c.useEffect(()=>{typeof window>"u"||!n||g||U.current||(U.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,g]),Tp({enabled:Y}),SC({enabled:Y}),kC(h||null),AC(),Ip(),Kp(),gg();const fe=c.useCallback(()=>{w(W=>!W)},[]);eC(fe),mC(),pC(!H),c.useEffect(()=>{if(H)return;const W=()=>w(ne=>!ne);return window.addEventListener("openchamber:memory-debug-toggle",W),()=>window.removeEventListener("openchamber:memory-debug-toggle",W)},[H]),c.useEffect(()=>{H||u&&setTimeout(()=>d(),5e3)},[d,H,u]),c.useEffect(()=>{if(!L||I!=="not-injected")return;let W=!1,ne=0;const pe=200,xe=2e3,Ce=50,Me=()=>{if(W)return;ne++;const ve=Za();if(ve!=="not-injected"){if(W=!0,j(ve),ve==="valid"){const ye=el();ye&&F(tl({isDesktopShell:!0,bootOutcome:ye}))}return}const Ie=Math.min(pe*Math.pow(1.1,ne),xe);if(ne>=Ce){const ye=document.getElementById("initial-loading");ye&&!ye.textContent?.includes("taking longer")&&(ye.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(Me,Ie)};return window.setTimeout(Me,pe),()=>{W=!0}},[L,I]);const _=c.useCallback(async()=>{if(bf({isDesktopShell:gn(),isDesktopLocalOriginActive:Ho()})){await yf();return}window.location.reload()},[]),le=c.useCallback(async()=>{if(!M){C(!1),$(!0);try{await Kt.getState().initializeApp()}finally{$(!1)}Kt.getState().isInitialized||A(W=>W+1)}},[M]),ee=W=>{if(W.screen==="recovery")return W.variant};if(L&&T&&T.screen!=="main"){if(T.screen==="chooser")return s.jsx(Hs,{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(ld,{mode:"first-launch",localAvailable:T.localAvailable!==!1,onCliAvailable:_,onChooseRemote:()=>{}})})})});const W=ee(T),ne=T.screen==="recovery"&&"url"in T?T.url:void 0;return s.jsx(Hs,{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(ld,{mode:"recovery",recoveryVariant:W,recoveryHostUrl:ne,recoveryHostLabel:void 0,localAvailable:T.localAvailable!==!1,onCliAvailable:_})})})})}if(H)return s.jsx(Hs,{children:s.jsx(yl,{sdk:qs.getSdkClient(),directory:h||"",children:s.jsx(wl,{apis:t,children:s.jsx(Bi,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:"h-full text-foreground bg-background",children:[s.jsx(OC,{embeddedSessionChat:H,isVSCodeRuntime:m,embeddedBackgroundWorkEnabled:Y}),s.jsx(Sl,{})]})})})},P)});if(me)return s.jsx(Hs,{children:s.jsx(TC,{})});if(N&&!n&&!m&&!H)return s.jsx(Hs,{children:s.jsx(RC,{onRetry:()=>{le()},isRetrying:M})});const ue=!n&&!L;return s.jsx(Hs,{children:s.jsx(yl,{sdk:qs.getSdkClient(),directory:h||"",children:s.jsx(wl,{apis:t,children:s.jsx(v3,{children:s.jsx(Bi,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:L?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[s.jsx(Yd,{embeddedBackgroundWorkEnabled:Y}),s.jsx(au,{}),s.jsx(e3,{}),s.jsx(Xd,{}),s.jsx(Sl,{}),!ue&&s.jsxs(s.Fragment,{children:[s.jsx(xg,{}),s.jsx(IC,{}),p&&s.jsx(M3,{onClose:()=>w(!1)})]})]})})})})},P)})}function FC(t){return t.isAboutDialogOpen}function _C(t){return t.setAboutDialogOpen}function LC(t){return t.currentDirectory}function $C(t){return t.currentSessionId}function WC(t){return t.setCurrentSession}const zC=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();Ep();wf().then(()=>{Promise.all([Sf(),Mp()]).catch(t=>{console.error("[main] settings init failed:",t)}),Op(),Bp(),Fp()}).catch(t=>{console.error("[main] appearance init failed:",t)});const Im=document.getElementById("root");if(!Im)throw new Error("Root element not found");_p();zm.createRoot(Im).render(s.jsx(rt.StrictMode,{children:s.jsx(Lp,{children:s.jsx($p,{children:s.jsx(Wp,{children:s.jsx(zp,{children:s.jsx(BC,{apis:zC})})})})})}));const a5=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{wb as W,cb as a,i5 as b,Ob as d,Lu as g,o5 as h,a5 as m,yb as u,_u as v};
|