@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,16 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DLiD86ge.js","assets/useAppFontEffects-CCgvcQ6u.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.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/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/isFilePlainText-JPmZOYSp.js","assets/isDiffPlainText-TNageFjy.js","assets/vendor-diff-C3JhlQdm.js","assets/vendor-lru_map-Tstukz9J.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/PlanView-C1qvAm7m.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/useInlineCommentController-BkfXnjNZ.js","assets/CodeMirrorCommentWidgets-BO_2OW4E.js","assets/vendor-ghostty-web-CrxinGGH.js","assets/vendor-capacitor-keyboard-CYccoJjr.js","assets/vendor-capacitor-core-B4EWRrHz.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as Qt}from"./vendor-vite-runtime-DD1OZmLC.js";import{f as ze,r as ce,j as t,R as h}from"./vendor-react-BUCujlKS.js";import{e8 as Eo,e9 as $n,c3 as Ir,c4 as Cr,aU as Ao,f as nt,o as Bo,bE as Ds,bF as Ps,bH as Rs,I as R,b$ as Lo,bY as Un,h as le,B as Ie,bf as Tr,g as Mo,t as Ne,ea as Fo,eb as Oo,ec as $o,O as Uo,dR as Wo,ed as _o,ee as Vo,ef as zo,y as it,eg as Go,l as Nt,eh as Ho,dr as Dr,ei as Ko,ds as qo,bZ as Es,cP as Yo,bG as Ks,ba as Jo,bd as Qo,bc as Xo,b7 as xs,ej as Zo,ek as ea,el as ta,em as sa,en as na,eo as ra,ep as oa,eq as aa,b as It,c7 as ia,a3 as Wn,bg as la,dL as Pr,dA as Rr,dC as ca,er as da,u as Yt,cB as ua,es as pn,T as bt,dj as fa,et as _n,eu as ma,ev as ha,ew as Vn,ex as pa,ey as ga,ez as xa,eA as ba,b8 as ya,eB as wa,b6 as zt,b3 as Gt,b5 as Ht,bX as qs,bS as Pn,bT as Rn,eC as Er,bU as Ar,bV as En,bW as ks,N as Br,eD as va,Q as Sa,eE as ja,eF as zn,eG as Na,U as ka,V as Ia,S as Ca,eH as Lr,eI as Ta,d_ as Da,r as Mr,eJ as Pa,eK as Ra,eL as Ea,a1 as gn,eM as Aa,M as fs,a7 as hs,a8 as ps,a9 as gs,cw as xn,cx as bn,cy as yn,cz as wn,cr as At,cs as Dt,eN as Ns,b2 as Bt,bB as vn,bI as Ba,bJ as An,W as Bn,av as Is,c5 as La,eO as Fr,aw as Sn,af as Ma,dH as Fa,ai as Ln,eP as Ls,m as Or,cT as Vt,eQ as Oa,eR as Zs,eS as $a,eT as Gn,cR as Hn,eU as Ua,b_ as Wa,dz as _a,dB as Va,eV as za,eW as Ga,cv as Ha,$ as Ka,H as qa,c as Ya,d as Ja,cM as Qa,eX as $r,_ as Ur,X as Xa,d$ as Tt,eY as Za,eZ as ei,e_ as Wr,a0 as Ys,e$ as Rt,f0 as jn,f1 as ti,f2 as _r,f3 as Ms,ce as si,f4 as ni,f5 as ri,f6 as oi,f7 as ai,f8 as ii,dc as li,dn as ci,Z as Nn,dX as di,cZ as ui,f9 as fi,at as mi,ac as hi,bQ as pi,fa as Vr,e5 as gi,fb as xi,fc as bi,fd as yi,fe as wi,bN as vi,cX as Si,n as ji,a5 as Ni,ff as ki}from"./useAppFontEffects-CCgvcQ6u.js";import{as as Ii,at as Kn,au as Ci,i as Ti,av as Di,F as zr,a6 as Pi,r as Mt,u as Ve,A as Ri,b as Ei,v as Ai,a as Ws,d as qn,a7 as Gr,$ as Bi,aw as $t,o as Li,m as bs,z as Hr,aa as Mi,ab as Fi,ax as Oi,ay as $i,H as zs,w as ms,Z as Ui,az as Wi,ah as _i,aA as ws,aB as en,aC as Kr,aD as Vi,Y as zi,n as Gi,y as Hi}from"./index-DDInLQDd.js";import{g as Ki,h as qi,i as Yi,d as Ji,C as Qi,c as Xi,M as Zi,S as el,a as tl,b as sl}from"./vendor-base-ui-BeMD8X_w.js";import{c as Js,d as qr,p as Yr,a as nl}from"./vendor-zustand-BAGL70zf.js";import{i as Jr}from"./contextPanelEmbeddedChat-CV-DwAiX.js";import{r as rl,a as ol,s as Yn}from"./vendor-zod-DVWEh-IS.js";import{f as Qr,h as Xr,P as Zr,k as al,D as eo,j as to}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as so,S as no,h as il,v as ll,a as cl}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as ro}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";const dl=["typescript","javascript","tsx","jsx","json","markdown"],oo={unified:{poolSize:1,totalASTLRUCacheSize:24,lineDiffType:"none"},split:{poolSize:2,totalASTLRUCacheSize:56,lineDiffType:"word-alt"}};let Jn=null;const ao=()=>(Jn??=Promise.all([Qt(()=>import("./index-DLiD86ge.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])),Qt(()=>import("./workerFactory-tw7cIdmV.js"),[]),Qt(()=>import("./appThemeRegistry-BK0dHKa6.js"),__vite__mapDeps([113,114,100,101,5,85,86,87,88,89,90,91,92,93,94,95,96,97,98]))]).then(([s,e,n])=>({WorkerPoolManager:s.WorkerPoolManager,workerFactory:e.workerFactory,ensurePierreThemeRegistered:n.ensurePierreThemeRegistered})),Jn),Cs={},Qn=new Set,kn=new Set;let _s={light:"pierre-light",dark:"pierre-dark"};const ul=()=>{for(const s of kn)s()},io=(s,e)=>{e.setRenderOptions({theme:_s,lineDiffType:oo[s].lineDiffType})},In=s=>{typeof window>"u"||Qn.has(s)||(Qn.add(s),ao().then(e=>{if(Cs[s])return;const n=oo[s],r=new e.WorkerPoolManager({workerFactory:e.workerFactory,poolSize:n.poolSize,totalASTLRUCacheSize:n.totalASTLRUCacheSize},{theme:{light:"pierre-light",dark:"pierre-dark"},langs:dl,lineDiffType:n.lineDiffType,preferredHighlighter:"shiki-wasm"});r.initialize(),Cs[s]=r,io(s,r),ul()}))},fl=s=>(kn.add(s),()=>kn.delete(s)),ml=s=>{if(!(_s.light===s.light&&_s.dark===s.dark)){_s=s;for(const e of Object.keys(Cs)){const n=Cs[e];n&&io(e,n)}}},Gf=s=>{const e=ze.c(15),{children:n}=s,r=Eo();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=$n(!1),e[0]=o):o=e[0];const a=o;let i;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=$n(!0),e[1]=i):i=e[1];const l=i,c=r?.lightThemeId??a.metadata.id,d=r?.darkThemeId??l.metadata.id;let u;e[2]!==c||e[3]!==r?.availableThemes?(u=r?.availableThemes.find(N=>N.metadata.id===c)??a,e[2]=c,e[3]=r?.availableThemes,e[4]=u):u=e[4];const f=u;let b;e[5]!==d||e[6]!==r?.availableThemes?(b=r?.availableThemes.find(N=>N.metadata.id===d)??l,e[5]=d,e[6]=r?.availableThemes,e[7]=b):b=e[7];const m=b;let x,g;e[8]!==m||e[9]!==f?(x=()=>{let N=!1;return ao().then(A=>{N||(A.ensurePierreThemeRegistered(f),A.ensurePierreThemeRegistered(m),ml({light:f.metadata.id,dark:m.metadata.id}))}),()=>{N=!0}},g=[m,f],e[8]=m,e[9]=f,e[10]=x,e[11]=g):(x=e[10],g=e[11]),ce.useEffect(x,g);let S;e[12]===Symbol.for("react.memo_cache_sentinel")?(S=[],e[12]=S):S=e[12],ce.useEffect(pl,S);let p;return e[13]!==n?(p=t.jsx(t.Fragment,{children:n}),e[13]=n,e[14]=p):p=e[14],p},Hf=s=>{const e=ze.c(5),n=s===void 0?"unified":s;let r;e[0]!==n?(r=()=>Cs[n],e[0]=n,e[1]=r):r=e[1];const o=ce.useSyncExternalStore(fl,r,gl);let a,i;return e[2]!==n?(a=()=>{In(n)},i=[n],e[2]=n,e[3]=a,e[4]=i):(a=e[3],i=e[4]),ce.useEffect(a,i),o};function hl(){In("unified"),In("split")}function pl(){if(typeof window>"u")return;const s=hl;if(typeof window.requestIdleCallback=="function"){const n=window.requestIdleCallback(s,{timeout:5e3});return()=>window.cancelIdleCallback(n)}const e=window.setTimeout(s,2e3);return()=>window.clearTimeout(e)}function gl(){}const tn=(s,e)=>Ir(Cr.getState().dictionary,s,e),xl=s=>{const e=s.message.toLowerCase();return e.includes("code signature")||e.includes("did not pass validation")||e.includes("code requirement")||e.includes("not signed")?"signature":e.includes("command is disabled")?"updater-disabled":"unknown"},bl=s=>{const e=xl(s);return e==="signature"?tn("updateDialog.error.signatureRejected"):e==="updater-disabled"?tn("updateDialog.error.updaterDisabled"):s.message.trim()||tn("updateDialog.error.restartFailed")},Xn="openchamber.update-install-id";function yl(){if(!(typeof window>"u"||typeof crypto.randomUUID!="function"))try{const s=window.localStorage.getItem(Xn)?.trim();if(s)return s;const e=crypto.randomUUID();return window.localStorage.setItem(Xn,e),e}catch{return}}function wl(){if(typeof window>"u")return"unknown";try{const{deviceType:s}=Ao();return s}catch{return"unknown"}}function vl(){const s=typeof window<"u"?window.__OPENCHAMBER_ELECTRON__?.arch?.toLowerCase?.():void 0;if(s==="arm64"||s==="aarch64")return"arm64";if(s==="x64"||s==="amd64"||s==="x86_64")return"x64";const e=typeof window<"u"?window.__VSCODE_CONFIG__?.arch?.toLowerCase?.():void 0;if(e==="arm64"||e==="aarch64")return"arm64";if(e==="x64"||e==="amd64"||e==="x86_64")return"x64";const r=(typeof navigator<"u"?navigator.userAgentData:void 0)?.architecture?.toLowerCase?.();if(r==="arm"||r==="arm64"||r==="aarch64")return"arm64";if(r==="x86"||r==="x64"||r==="amd64")return"x64";const o=typeof navigator<"u"?navigator.userAgent.toLowerCase():"";return o.includes("aarch64")||o.includes("arm64")||o.includes("armv")?"arm64":o.includes("x86_64")||o.includes("x64")||o.includes("amd64")||o.includes("win64")?"x64":"unknown"}function Sl(){const s=Ei();if(s==="android"||s==="ios")return s;if(typeof navigator>"u")return"web";const e=(navigator.platform||"").toLowerCase();return e.includes("mac")?"macos":e.includes("win")?"windows":e.includes("linux")?"linux":"web"}function jl(s){const e=Ve.getState().reportUsage,n=new URLSearchParams({reportUsage:e?"true":"false"});if(n.set("deviceClass",wl()),n.set("arch",vl()),n.set("platform",Sl()),e&&(s==="desktop"||s==="mobile")){const r=yl();r&&n.set("installId",r)}return s==="desktop"?(n.set("appType","desktop-electron"),n.set("instanceMode",Ri()?"local":"remote"),n):s==="vscode"?(n.set("appType","vscode"),n.set("instanceMode","local"),n):s==="mobile"?(n.set("appType","mobile-capacitor"),n.set("instanceMode","remote"),n):(n.set("appType","web"),n.set("instanceMode","unknown"),n)}async function Fs(s,e){try{const n=jl(s),r=typeof window<"u"?window.__VSCODE_CONFIG__?.extensionVersion:void 0;e?n.set("currentVersion",e):s==="vscode"&&r&&n.set("currentVersion",r);const o=await Mt(`/api/openchamber/update-check?${n.toString()}`,{method:"GET",headers:{Accept:"application/json"},priority:"low"});if(!o.ok)throw new Error(`Server responded with ${o.status}`);const a=await o.json();return{available:a.available??!1,version:a.version,currentVersion:a.currentVersion??"unknown",body:a.body,releaseUrl:a.releaseUrl,downloadUrl:a.downloadUrl,nextSuggestedCheckInSec:typeof a.nextSuggestedCheckInSec=="number"&&Number.isFinite(a.nextSuggestedCheckInSec)?a.nextSuggestedCheckInSec:void 0,packageManager:a.packageManager,updateCommand:a.updateCommand}}catch(n){return console.warn("Failed to check for updates:",n),null}}function Nl(){return Ti()?"mobile":Di()?"desktop":zr()?"vscode":Pi()?"web":null}const Zn={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null},kl=Js()((s,e)=>({...Zn,checkForUpdates:async()=>{const n=Nl();if(!n)return null;s({checking:!0,error:null,runtimeType:n});try{let r=null,o=null;if(n==="desktop"){const a="1.22.1",[i,l]=await Promise.allSettled([Kn(),Fs("desktop",a)]),c=i.status==="fulfilled"?i.value:null;return o=l.status==="fulfilled"?l.value?.nextSuggestedCheckInSec??null:null,s({checking:!1,available:c?.available??!1,info:c,lastChecked:Date.now(),nextCheckInSec:o}),o}else n==="web"?(r=await Fs("web"),o=r?.nextSuggestedCheckInSec??null):n==="vscode"?o=(await Fs("vscode"))?.nextSuggestedCheckInSec??null:n==="mobile"&&(r=await Fs("mobile","1.22.1"),o=r?.nextSuggestedCheckInSec??null);return s({checking:!1,available:n==="vscode"?!1:r?.available??!1,info:n==="vscode"?null:r,lastChecked:Date.now(),nextCheckInSec:o}),o}catch(r){return s({checking:!1,error:r instanceof Error?r.message:"Failed to check for updates"}),null}},downloadUpdate:async()=>{const{available:n,runtimeType:r}=e();if(!(r!=="desktop"||!n)){s({downloading:!0,error:null,progress:null});try{const o=await Kn();if(!o?.available)throw new Error("Update detected, but desktop package is not ready yet. Retry in a moment.");if(s(i=>({info:i.info?{...i.info,...o,body:i.info.body||o.body,available:i.info.available}:o})),!await Ci(i=>{s({progress:i})}))throw new Error("Desktop update only works on Local instance");s({downloading:!1,downloaded:!0})}catch(o){s({downloading:!1,error:o instanceof Error?o.message:"Failed to download update"})}}},restartToUpdate:async()=>{const{downloaded:n,runtimeType:r}=e();if(!(r!=="desktop"||!n)){s({error:null});try{if(!await Ii())throw new Error(Ir(Cr.getState().dictionary,"updateDialog.error.restartUnavailable"))}catch(o){s({error:bl(o instanceof Error?o:new Error(String(o)))})}}},dismiss:()=>{s({available:!1,downloaded:!1,info:null})},reset:()=>{s(Zn)}})),er="https://github.com/openchamber/openchamber/releases";function Il(s){const e=new Date(`${s}T00:00:00`);return Number.isNaN(e.getTime())?s:new Intl.DateTimeFormat(Tr(),{year:"numeric",month:"short",day:"numeric"}).format(e)}function Cl(s){return s.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,"").trim()}function tr(s){return s.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,"$1[@$2](https://github.com/$2)")}function Tl(s,e){const n=s.split(".").map(o=>Number.parseInt(o,10)),r=e.split(".").map(o=>Number.parseInt(o,10));for(let o=0;o<3;o+=1){const a=Number.isFinite(n[o])?n[o]:0,i=Number.isFinite(r[o])?r[o]:0;if(a!==i)return i-a}return 0}function Dl(s){const e=/^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})\s*$/gm,n=[];let r;for(;(r=e.exec(s))!==null;)n.push({version:r[1]??"",date:r[2]??"",start:r.index});return n.length===0?[]:n.map((o,a)=>{const i=n[a+1]?.start??s.length,l=s.slice(o.start,i).trim();return{version:o.version,date:o.date,start:o.start,end:i,raw:l}})}const sr=2e3,Pl=600*1e3;async function Rl(){try{const s=await Mt("/api/openchamber/update-install",{method:"POST",headers:{"Content-Type":"application/json"}});return s.ok?{success:!0,autoRestart:(await s.json().catch(()=>({}))).autoRestart!==!1}:{success:!1,error:(await s.json().catch(()=>({}))).error||`Server error: ${s.status}`}}catch(s){return{success:!1,error:s instanceof Error?s.message:void 0}}}async function El(){try{return(await Mt("/health",{method:"GET",headers:{Accept:"application/json"}})).ok}catch{return!1}}async function Al(s,e=Math.ceil(Pl/sr),n=sr){for(let r=0;r<e;r++){try{const o=await Mt("/api/openchamber/update-check?reportUsage=false",{method:"GET",headers:{Accept:"application/json"}});if(o.ok){const a=await o.json().catch(()=>null);if(a&&a.available===!1||a&&typeof a.currentVersion=="string"&&typeof s=="string"&&a.currentVersion!==s)return!0}else if((o.status===401||o.status===403)&&await El())return!0}catch{}await new Promise(o=>setTimeout(o,n))}return!1}const Kf=({open:s,onOpenChange:e,info:n,downloading:r,downloaded:o,progress:a,error:i,onDownload:l,onRestart:c,runtimeType:d="desktop"})=>{const{t:u}=nt(),[f,b]=ce.useState(!1),[m,x]=ce.useState("idle"),[g,S]=ce.useState(null),p=n?.version?n.releaseUrl||`${er}/tag/v${n.version}`:er,N=n?.downloadUrl||p,A=a?.total?Math.round(a.downloaded/a.total*100):0,L=d==="web",I=d==="mobile",T=n?.updateCommand||"openchamber update";ce.useEffect(()=>{s||(x("idle"),S(null))},[s]);const y=async()=>{(await Mo(T)).ok&&(b(!0),setTimeout(()=>b(!1),2e3))},v=ce.useCallback(async q=>{await Bo(q)},[]),$=ce.useCallback(async()=>{x("updating"),S(null);const q=await Rl();if(!q.success){x("error"),S(q.error||u("updateDialog.error.updateFailed"));return}q.autoRestart&&(x("restarting"),await new Promise(J=>setTimeout(J,2e3))),x("reconnecting"),await Al(n?.currentVersion)?window.location.reload():(x("error"),S(u("updateDialog.error.takingLonger")))},[n?.currentVersion,u]),U=ce.useCallback(()=>{v(N)},[v,N]),W=m!=="idle"&&m!=="error",z=ce.useMemo(()=>{if(!n?.body)return null;const q=n.body.trim();if(!q)return null;const se=Dl(q);if(se.length===0)return{kind:"raw",title:u("updateDialog.changelog.title"),content:tr(q)};const J=[...se].sort((G,ee)=>Tl(G.version,ee.version));return{kind:"sections",title:u("updateDialog.changelog.title"),sections:J.map(G=>({version:G.version,dateLabel:Il(G.date),content:tr(Cl(G.raw)||q)}))}},[n?.body,u]);return t.jsx(Ds,{open:s,onOpenChange:W?void 0:e,children:t.jsxs(Ps,{className:"max-w-4xl p-5 bg-background border-[var(--interactive-border)]",showCloseButton:!0,children:[t.jsxs("div",{className:"flex items-center mb-1",children:[t.jsxs(Rs,{className:"flex items-center gap-2.5",children:[t.jsx(R,{name:"download-cloud",className:"h-5 w-5 text-[var(--primary-base)]"}),t.jsx("span",{className:"text-lg font-semibold text-foreground",children:u(m==="restarting"||m==="reconnecting"?"updateDialog.header.updating":"updateDialog.header.updateAvailable")})]}),(n?.currentVersion||n?.version)&&t.jsxs("div",{className:"flex items-center gap-2 font-mono text-sm ml-3",children:[n?.currentVersion&&t.jsx("span",{className:"text-muted-foreground",children:n.currentVersion}),n?.currentVersion&&n?.version&&t.jsx("span",{className:"text-muted-foreground/50",children:"→"}),n?.version&&t.jsx("span",{className:"text-[var(--primary-base)] font-medium",children:n.version})]})]}),t.jsxs("div",{className:"space-y-2",children:[L&&W&&t.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/30 p-5 border border-[var(--surface-subtle)]",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(R,{name:"loader",className:"h-5 w-5 animate-spin text-[var(--primary-base)]"}),t.jsxs("div",{className:"typography-ui-label text-foreground",children:[m==="updating"&&u("updateDialog.status.installingUpdate"),m==="restarting"&&u("updateDialog.status.serverRestarting"),m==="reconnecting"&&u("updateDialog.status.waitingForServer")]})]}),t.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:u("updateDialog.status.autoReloadHint")})]}),z&&!W&&t.jsx("div",{className:"rounded-lg border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20 overflow-hidden",children:t.jsx(Lo,{className:"max-h-[400px] p-0",fillContainer:!1,children:z.kind==="raw"?t.jsx("div",{className:"p-4 typography-markdown-body text-foreground leading-relaxed break-words [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline",onClickCapture:q=>{const J=q.target.closest("a");J&&J.href&&(q.preventDefault(),q.stopPropagation(),v(J.href))},children:t.jsx(Un,{content:z.content,disableLinkSafety:!0,enableFileReferences:!1})}):t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:z.sections.map(q=>t.jsxs("div",{className:"p-4",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[t.jsxs("span",{className:"typography-ui-label font-mono text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-1.5 py-0.5 rounded",children:["v",q.version]}),t.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:q.dateLabel})]}),t.jsx("div",{className:"typography-markdown-body text-foreground leading-relaxed break-words [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline",onClickCapture:se=>{const G=se.target.closest("a");G&&G.href&&(se.preventDefault(),se.stopPropagation(),v(G.href))},children:t.jsx(Un,{content:q.content,disableLinkSafety:!0,enableFileReferences:!1})})]},q.version))})})}),L&&m==="error"&&t.jsxs("div",{className:"space-y-2 mt-4",children:[t.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[t.jsx(R,{name:"terminal",className:"h-4 w-4"}),t.jsx("span",{children:u("updateDialog.fallback.updateViaTerminal")})]}),t.jsxs("div",{className:"flex items-center gap-2 p-1 pl-3 bg-[var(--surface-elevated)]/50 rounded-md border border-[var(--surface-subtle)]",children:[t.jsx("code",{className:"flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap",children:T}),t.jsx("button",{onClick:y,className:le("flex items-center justify-center p-2 rounded","text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]","transition-colors",f&&"text-[var(--status-success)]"),title:u(f?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:f?t.jsx(R,{name:"check",className:"h-4 w-4"}):t.jsx(R,{name:"clipboard",className:"h-4 w-4"})})]})]}),!L&&!I&&r&&t.jsxs("div",{className:"space-y-2 mt-4",children:[t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsx("span",{className:"text-muted-foreground",children:u("updateDialog.status.downloadingPayload")}),t.jsxs("span",{className:"font-mono text-foreground",children:[A,"%"]})]}),t.jsx("div",{className:"h-1.5 bg-[var(--surface-subtle)] rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-[var(--primary-base)] transition-all duration-300",style:{width:`${A}%`}})})]}),(i||g)&&t.jsx("div",{className:"p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg",children:t.jsx("p",{className:"text-sm text-[var(--status-error)]",children:i||g})})]}),t.jsxs("div",{className:"mt-4 flex items-center justify-between gap-4",children:[t.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors shrink-0",children:[t.jsx(R,{name:"external-link",className:"h-4 w-4"}),"GitHub"]}),t.jsxs("div",{className:"flex-1 flex justify-end",children:[!L&&!I&&!o&&!r&&t.jsxs("button",{onClick:l,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity",children:[t.jsx(R,{name:"download",className:"h-4 w-4"}),u("updateDialog.actions.downloadUpdate")]}),!L&&!I&&r&&t.jsxs("button",{disabled:!0,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)]/50 text-[var(--primary-foreground)] cursor-not-allowed",children:[t.jsx(R,{name:"loader",className:"h-4 w-4 animate-spin"}),u("updateDialog.status.downloading")]}),!L&&!I&&o&&t.jsxs("button",{onClick:c,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--status-success)] text-white hover:opacity-90 transition-opacity",children:[t.jsx(R,{name:"restart",className:"h-4 w-4"}),u("updateDialog.actions.restartToUpdate")]}),I&&t.jsxs(Ie,{onClick:U,size:"default",children:[t.jsx(R,{name:"external-link",className:"h-4 w-4"}),u("updateDialog.actions.openMobileUpdate")]}),L&&!W&&t.jsxs("button",{onClick:$,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity",children:[t.jsx(R,{name:"download",className:"h-4 w-4"}),u("updateDialog.actions.updateNow")]}),L&&W&&t.jsxs("button",{disabled:!0,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)]/50 text-[var(--primary-foreground)] cursor-not-allowed",children:[t.jsx(R,{name:"loader",className:"h-4 w-4 animate-spin"}),u("updateDialog.status.updating")]})]})]})]})})},qf=s=>!(s.dismissed==="true"||s.sessionShown==="true"||s.hasActiveToast),Bl=s=>!(!s.version||s.seenVersions.has(s.version)||s.dismissedVersion!==null&&s.dismissedVersion===s.version),Ll=s=>{if(s===null||typeof s!="object")return"";const e=s.version;return typeof e!="string"?"":e.trim()},Ml=s=>!s||s.upgrade?.supported!==!0||s.available!==!0||typeof s.latestVersion!="string"?"":s.latestVersion.trim(),us="opencode-update-available",Os="opencode-upgrade-progress",Fl=5e3,Ol=[1e4,6e4],nr="opencode-update-toast-dismissed-version",Yf=()=>{const{t:s}=nt(),e=Ve(i=>i.showOpenCodeUpdateNotifications),n=ce.useRef(new Set),r=ce.useRef(!1);ce.useEffect(()=>{e||Ne.dismiss(us)},[e]);const o=ce.useCallback(()=>{Ne.dismiss(Os),Fo({message:s("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]}).catch(()=>{})},[s]),a=ce.useCallback(async()=>{if(!r.current){r.current=!0,Ne.dismiss(us),Ne.message(s("opencodeUpdate.toast.upgrading.title"),{id:Os,description:s("opencodeUpdate.toast.upgrading.description"),duration:1/0,icon:t.jsx(R,{name:"refresh",className:"h-4 w-4 animate-spin text-muted-foreground"})});try{const i=await Mt("/api/opencode/upgrade",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({})}),l=await i.json().catch(()=>null);if(!i.ok||l?.success===!1)throw new Error(l?.error||i.statusText||s("opencodeUpdate.toast.failed.description"));Ne.success(s("opencodeUpdate.toast.updated.title"),{id:Os,description:l?.version?s("opencodeUpdate.toast.updated.descriptionWithVersion",{version:l.version}):s("opencodeUpdate.toast.updated.description"),duration:1/0,icon:t.jsx(R,{name:"check",className:"h-4 w-4 text-[var(--status-success)]"}),action:{label:s("opencodeUpdate.toast.actions.reload"),onClick:o}})}catch(i){Ne.error(s("opencodeUpdate.toast.failed.title"),{id:Os,description:i instanceof Error?i.message:s("opencodeUpdate.toast.failed.description"),duration:1/0})}finally{r.current=!1}}},[o,s]);return ce.useEffect(()=>{const i=b=>{if(!Ve.getState().showOpenCodeUpdateNotifications){Ne.dismiss(us);return}Bl({version:b,dismissedVersion:qn().getItem(nr),seenVersions:n.current})&&(n.current.add(b),Ne.info(s("opencodeUpdate.toast.available.title"),{id:us,description:s("opencodeUpdate.toast.available.description",{version:b}),duration:1/0,action:{label:s("opencodeUpdate.toast.actions.update"),onClick:a},cancel:{label:s("opencodeUpdate.toast.actions.dismiss"),onClick:()=>{qn().setItem(nr,b),Gr({openCodeUpdateToastDismissedVersion:b}),Ne.dismiss(us)}}}))};let l=!1;const c=[],d=async(b,m=Ws())=>{try{const x=await Mt("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!x.ok)throw new Error(x.statusText||"OpenCode upgrade status check failed");const g=await x.json().catch(()=>null),S=Ml(g);!l&&m===Ws()&&S&&i(S)}catch{const x=Ol[b];!l&&m===Ws()&&x!==void 0&&c.push(setTimeout(()=>{d(b+1,m)},x))}},u=b=>{Ll(b.detail)&&d(0)};e&&c.push(setTimeout(()=>{d(0)},Fl));const f=Ai(({runtimeKey:b})=>{n.current.clear(),Ne.dismiss(us),Ve.getState().showOpenCodeUpdateNotifications&&d(0,b)});return window.addEventListener("openchamber:opencode-update-available",u),()=>{l=!0;for(const b of c)clearTimeout(b);f(),window.removeEventListener("openchamber:opencode-update-available",u)}},[a,e,s]),null},Jf=()=>{const s=ze.c(3),[e,n]=h.useState($l),{isUpdating:r}=e;let o,a;if(s[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>$o(n),a=[],s[0]=o,s[1]=a):(o=s[0],a=s[1]),h.useEffect(o,a),!r)return null;let i;return s[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-background/90",children:t.jsx(Uo,{width:80,height:80,isAnimated:!0})}),s[2]=i):i=s[2],i};function $l(){return Oo()}class Ul extends h.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){this.setState({error:e,errorInfo:n})}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};render(){return this.state.hasError?t.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:t.jsxs(Wo,{className:"w-full max-w-md",children:[t.jsx(_o,{className:"text-center",children:t.jsxs(Vo,{className:"flex items-center justify-center gap-2 text-destructive",children:[t.jsx(R,{name:"chat-3",className:"h-5 w-5"}),this.props.texts.title]})}),t.jsxs(zo,{className:"space-y-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground text-center",children:this.props.texts.description}),this.props.sessionId&&t.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:[this.props.texts.sessionLabel,": ",this.props.sessionId]}),this.state.error&&t.jsxs("details",{className:"text-xs font-mono bg-muted p-3 rounded",children:[t.jsx("summary",{className:"cursor-pointer hover:bg-interactive-hover/80",children:this.props.texts.detailsSummary}),t.jsx("pre",{className:"mt-2 max-h-48 overflow-auto",children:this.state.error.toString()})]}),t.jsx("div",{className:"flex gap-2",children:t.jsxs(Ie,{onClick:this.handleReset,variant:"outline",className:"flex-1",children:[t.jsx(R,{name:"restart",className:"h-4 w-4 mr-2"}),this.props.texts.resetAction]})}),t.jsx("div",{className:"text-xs text-muted-foreground text-center",children:this.props.texts.persistentHint})]})]})}):this.props.children}}function Wl(s){const e=ze.c(22),{t:n}=nt();let r;e[0]!==n?(r=n("chat.errorBoundary.title"),e[0]=n,e[1]=r):r=e[1];let o;e[2]!==n?(o=n("chat.errorBoundary.description"),e[2]=n,e[3]=o):o=e[3];let a;e[4]!==n?(a=n("chat.errorBoundary.sessionLabel"),e[4]=n,e[5]=a):a=e[5];let i;e[6]!==n?(i=n("chat.errorBoundary.detailsSummary"),e[6]=n,e[7]=i):i=e[7];let l;e[8]!==n?(l=n("chat.errorBoundary.resetAction"),e[8]=n,e[9]=l):l=e[9];let c;e[10]!==n?(c=n("chat.errorBoundary.persistentHint"),e[10]=n,e[11]=c):c=e[11];let d;e[12]!==r||e[13]!==o||e[14]!==a||e[15]!==i||e[16]!==l||e[17]!==c?(d={title:r,description:o,sessionLabel:a,detailsSummary:i,resetAction:l,persistentHint:c},e[12]=r,e[13]=o,e[14]=a,e[15]=i,e[16]=l,e[17]=c,e[18]=d):d=e[18];let u;return e[19]!==s||e[20]!==d?(u=t.jsx(Ul,{...s,texts:d}),e[19]=s,e[20]=d,e[21]=u):u=e[21],u}const Qf=s=>{const e=ze.c(8),{active:n,messagesEnabled:r,readOnly:o,initialAllowPromptingSubagentSessions:a}=s,i=n===void 0?!0:n,l=o===void 0?!1:o,d=it(_l)||void 0;let u;e[0]!==i||e[1]!==a||e[2]!==r||e[3]!==l?(u=t.jsx(Go,{active:i,messagesEnabled:r,readOnly:l,initialAllowPromptingSubagentSessions:a}),e[0]=i,e[1]=a,e[2]=r,e[3]=l,e[4]=u):u=e[4];let f;return e[5]!==d||e[6]!==u?(f=t.jsx(Wl,{sessionId:d,children:u}),e[5]=d,e[6]=u,e[7]=f):f=e[7],f};function _l(s){return s.currentSessionId}const Vl=Ki,zl=s=>{const e=ze.c(14);let n,r,o,a;e[0]!==s?({className:o,asChild:n,children:r,...a}=s,e[0]=s,e[1]=n,e[2]=r,e[3]=o,e[4]=a):(n=e[1],r=e[2],o=e[3],a=e[4]);let i;e[5]!==n||e[6]!==r?(i=n&&ce.isValidElement(r)?{render:r}:{children:r},e[5]=n,e[6]=r,e[7]=i):i=e[7];const l=i;let c;e[8]!==o?(c=le("flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-left text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",o),e[8]=o,e[9]=c):c=e[9];let d;return e[10]!==a||e[11]!==l||e[12]!==c?(d=t.jsx(qi,{className:c,...a,...l}),e[10]=a,e[11]=l,e[12]=c,e[13]=d):d=e[13],d},Gl=s=>{const e=ze.c(8);let n,r;e[0]!==s?({className:n,...r}=s,e[0]=s,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let o;e[3]!==n?(o=le("transition-opacity duration-100 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0","motion-reduce:transition-none",n),e[3]=n,e[4]=o):o=e[4];let a;return e[5]!==r||e[6]!==o?(a=t.jsx(Yi,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a},rr=s=>({providerID:s.providerID,modelID:s.modelID,variant:s.variant,agent:s.agent});function Hl(s){const e=ze.c(131),{t:n}=nt(),{open:r,onOpenChange:o,target:a,projectDirectory:i,submitting:l,allowRunAsGoal:c,onConfirm:d}=s,u=l===void 0?!1:l,f=c===void 0?!1:c;let b;e[0]!==f?(b=f&&!zr(),e[0]=f,e[1]=b):b=e[1];const m=b,x=Nt(nc),g=Nt(sc),S=Ho(tc),p=Nt(ec),N=Nt(Zl),A=Nt(Xl),L=Nt(Ql),I=Nt(Jl);let T;e[2]!==I||e[3]!==A||e[4]!==N||e[5]!==L?(T=()=>rr({providerID:N,modelID:A,variant:L,agent:I}),e[2]=I,e[3]=A,e[4]=N,e[5]=L,e[6]=T):T=e[6];const[y,v]=h.useState(T);let $,U;e[7]!==S||e[8]!==g||e[9]!==x||e[10]!==r||e[11]!==i?($=()=>{r&&(x({directory:i,source:"todoSendDialog"}),g({directory:i}),S())},U=[r,x,g,S,i],e[7]=S,e[8]=g,e[9]=x,e[10]=r,e[11]=i,e[12]=$,e[13]=U):($=e[12],U=e[13]),h.useEffect($,U);let W,z;e[14]!==I||e[15]!==A||e[16]!==N||e[17]!==L||e[18]!==r?(W=()=>{r&&v(rr({providerID:N,modelID:A,variant:L,agent:I}))},z=[r,N,A,L,I],e[14]=I,e[15]=A,e[16]=N,e[17]=L,e[18]=r,e[19]=W,e[20]=z):(W=e[19],z=e[20]),h.useEffect(W,z);let q,se;e[21]!==y.modelID||e[22]!==y.providerID||e[23]!==r||e[24]!==p?(q=()=>{if(!r||p.length===0)return;const $e=p.find(Xe=>Xe.id===y.providerID)??p[0],_e=Array.isArray($e?.models)?$e.models:[],st=_e.some(Xe=>Xe.id===y.modelID),Pe=_e[0]?.id??"";$e?.id===y.providerID&&st||v(Xe=>({...Xe,providerID:$e?.id??"",modelID:st?Xe.modelID:Pe,variant:""}))},se=[r,p,y.providerID,y.modelID],e[21]=y.modelID,e[22]=y.providerID,e[23]=r,e[24]=p,e[25]=q,e[26]=se):(q=e[25],se=e[26]),h.useEffect(q,se);const J=Yl;let G;if(e[27]!==y.modelID||e[28]!==y.providerID||e[29]!==p){let $e;e[31]!==y.providerID?($e=st=>st.id===y.providerID,e[31]=y.providerID,e[32]=$e):$e=e[32],G=p.find($e)?.models?.find(st=>st.id===y.modelID),e[27]=y.modelID,e[28]=y.providerID,e[29]=p,e[30]=G}else G=e[30];const ee=G;let ue;e[33]!==ee?(ue=ee?.variants?Object.keys(ee.variants):[],e[33]=ee,e[34]=ue):ue=e[34];const V=ue,P=V.length>0;let B,M;e[35]!==y.variant||e[36]!==P?(B=()=>{P||!y.variant||v(ql)},M=[P,y.variant],e[35]=y.variant,e[36]=P,e[37]=B,e[38]=M):(B=e[37],M=e[38]),h.useEffect(B,M);let D;e[39]!==y.modelID||e[40]!==y.providerID?(D=y.providerID.trim().length>0&&y.modelID.trim().length>0,e[39]=y.modelID,e[40]=y.providerID,e[41]=D):D=e[41];const _=D;let E;e[42]!==_||e[43]!==y||e[44]!==d||e[45]!==u?(E=()=>{!_||u||d(y)},e[42]=_,e[43]=y,e[44]=d,e[45]=u,e[46]=E):E=e[46];const K=E;let O,ne;e[47]!==K||e[48]!==r?(O=()=>{if(!r)return;const $e=_e=>{(_e.metaKey||_e.ctrlKey)&&_e.key==="Enter"&&(_e.preventDefault(),K())};return window.addEventListener("keydown",$e),()=>window.removeEventListener("keydown",$e)},ne=[r,K],e[47]=K,e[48]=r,e[49]=O,e[50]=ne):(O=e[49],ne=e[50]),h.useEffect(O,ne);let X;e[51]!==n||e[52]!==a?(X=n(a==="worktree"?"rightSidebar.contextNotesTodo.sendDialog.title.newWorktree":"rightSidebar.contextNotesTodo.sendDialog.title.newSession"),e[51]=n,e[52]=a,e[53]=X):X=e[53];const te=X;let ge;e[54]!==o||e[55]!==u?(ge=$e=>{u||o($e)},e[54]=o,e[55]=u,e[56]=ge):ge=e[56];let re;e[57]!==te?(re=t.jsx(Ks,{children:t.jsx(Rs,{children:te})}),e[57]=te,e[58]=re):re=e[58];let pe;e[59]!==n?(pe=n("chat.modelControls.model"),e[59]=n,e[60]=pe):pe=e[60];let Z;e[61]!==pe?(Z=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:pe}),e[61]=pe,e[62]=Z):Z=e[62];let de;e[63]===Symbol.for("react.memo_cache_sentinel")?(de=($e,_e)=>{v(st=>({...st,providerID:$e,modelID:_e,variant:""}))},e[63]=de):de=e[63];let me;e[64]!==y.modelID||e[65]!==y.providerID?(me=t.jsx(Dr,{providerId:y.providerID,modelId:y.modelID,className:"max-w-[320px] justify-between",dropdownPortalToBody:!0,onChange:de}),e[64]=y.modelID,e[65]=y.providerID,e[66]=me):me=e[66];let j;e[67]!==Z||e[68]!==me?(j=t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[Z,me]}),e[67]=Z,e[68]=me,e[69]=j):j=e[69];let Y;e[70]!==n?(Y=n("sessions.scheduledTasks.editor.thinkingLevel.label"),e[70]=n,e[71]=Y):Y=e[71];let F;e[72]!==Y?(F=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:Y}),e[72]=Y,e[73]=F):F=e[73];const ae=!P;let he;e[74]===Symbol.for("react.memo_cache_sentinel")?(he=$e=>v(_e=>({..._e,variant:$e})),e[74]=he):he=e[74];let we;e[75]!==y.variant||e[76]!==ae||e[77]!==V?(we=t.jsx(Ko,{value:y.variant,options:V,disabled:ae,onChange:he}),e[75]=y.variant,e[76]=ae,e[77]=V,e[78]=we):we=e[78];let Te;e[79]!==F||e[80]!==we?(Te=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[F,we]}),e[79]=F,e[80]=we,e[81]=Te):Te=e[81];let Ge;e[82]!==n?(Ge=n("sessions.scheduledTasks.editor.agent.label"),e[82]=n,e[83]=Ge):Ge=e[83];let Fe;e[84]!==Ge?(Fe=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:Ge}),e[84]=Ge,e[85]=Fe):Fe=e[85];let ve;e[86]===Symbol.for("react.memo_cache_sentinel")?(ve=$e=>v(_e=>({..._e,agent:$e})),e[86]=ve):ve=e[86];let Re;e[87]!==y.agent?(Re=t.jsx(qo,{agentName:y.agent,filter:J,dropdownPortalToBody:!0,onChange:ve}),e[87]=y.agent,e[88]=Re):Re=e[88];let Ce;e[89]!==Fe||e[90]!==Re?(Ce=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[Fe,Re]}),e[89]=Fe,e[90]=Re,e[91]=Ce):Ce=e[91];let Ue;e[92]!==j||e[93]!==Te||e[94]!==Ce?(Ue=t.jsxs("div",{className:"flex flex-col gap-4",children:[j,Te,Ce]}),e[92]=j,e[93]=Te,e[94]=Ce,e[95]=Ue):Ue=e[95];const He=`flex items-center gap-3 ${m?"justify-between":"justify-end"}`;let qe;e[96]!==y.runAsGoal||e[97]!==m||e[98]!==u||e[99]!==n?(qe=m?t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Es,{checked:y.runAsGoal===!0,onChange:$e=>v(_e=>({..._e,runAsGoal:$e})),disabled:u,ariaLabel:n("sessions.scheduledTasks.editor.goal.aria")}),t.jsx("button",{type:"button",className:"truncate typography-ui-label text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:u,onClick:()=>v(Kl),children:n("sessions.scheduledTasks.editor.goal.label")})]}):null,e[96]=y.runAsGoal,e[97]=m,e[98]=u,e[99]=n,e[100]=qe):qe=e[100];let Ke;e[101]!==o?(Ke=()=>o(!1),e[101]=o,e[102]=Ke):Ke=e[102];let We;e[103]!==n?(We=n("rightSidebar.contextNotesTodo.sendDialog.actions.cancel"),e[103]=n,e[104]=We):We=e[104];let tt;e[105]!==u||e[106]!==Ke||e[107]!==We?(tt=t.jsx(Ie,{variant:"ghost",size:"sm",onClick:Ke,disabled:u,children:We}),e[105]=u,e[106]=Ke,e[107]=We,e[108]=tt):tt=e[108];const ct=!_||u;let Be;e[109]!==u||e[110]!==n?(Be=n(u?"rightSidebar.contextNotesTodo.sendDialog.actions.sending":"rightSidebar.contextNotesTodo.sendDialog.actions.send"),e[109]=u,e[110]=n,e[111]=Be):Be=e[111];let Ye;e[112]!==K||e[113]!==ct||e[114]!==Be?(Ye=t.jsx(Ie,{size:"sm",onClick:K,disabled:ct,children:Be}),e[112]=K,e[113]=ct,e[114]=Be,e[115]=Ye):Ye=e[115];let Qe;e[116]!==tt||e[117]!==Ye?(Qe=t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[tt,Ye]}),e[116]=tt,e[117]=Ye,e[118]=Qe):Qe=e[118];let Je;e[119]!==He||e[120]!==qe||e[121]!==Qe?(Je=t.jsxs("div",{className:He,children:[qe,Qe]}),e[119]=He,e[120]=qe,e[121]=Qe,e[122]=Je):Je=e[122];let De;e[123]!==re||e[124]!==Ue||e[125]!==Je?(De=t.jsxs(Ps,{className:"max-w-md overflow-visible",children:[re,Ue,Je]}),e[123]=re,e[124]=Ue,e[125]=Je,e[126]=De):De=e[126];let ot;return e[127]!==r||e[128]!==ge||e[129]!==De?(ot=t.jsx(Ds,{open:r,onOpenChange:ge,children:De}),e[127]=r,e[128]=ge,e[129]=De,e[130]=ot):ot=e[130],ot}function Kl(s){return{...s,runAsGoal:s.runAsGoal!==!0}}function ql(s){return{...s,variant:""}}function Yl(s){return Yo(s.mode)}function Jl(s){return s.currentAgentName||""}function Ql(s){return s.currentVariant||""}function Xl(s){return s.currentModelId}function Zl(s){return s.currentProviderId}function ec(s){return s.providers}function tc(s){return s.loadAgents}function sc(s){return s.loadAgents}function nc(s){return s.loadProviders}function rc(s){const e=ze.c(4);let n;e[0]!==s?({...n}=s,e[0]=s,e[1]=n):n=e[1];let r;return e[2]!==n?(r=t.jsx(Ji,{...n}),e[2]=n,e[3]=r):r=e[3],r}function oc(s){const e=ze.c(4);let n;e[0]!==s?({...n}=s,e[0]=s,e[1]=n):n=e[1];let r;return e[2]!==n?(r=t.jsx(Qi,{...n}),e[2]=n,e[3]=r):r=e[3],r}function ac(s){const e=ze.c(20);let n,r,o,a,i;e[0]!==s?({className:r,positionerClassName:o,children:n,style:i,...a}=s,e[0]=s,e[1]=n,e[2]=r,e[3]=o,e[4]=a,e[5]=i):(n=e[1],r=e[2],o=e[3],a=e[4],i=e[5]);let l;e[6]!==o?(l=le("app-region-no-drag z-50",o),e[6]=o,e[7]=l):l=e[7];let c;e[8]!==i?(c={color:"var(--surface-elevated-foreground)",...i},e[8]=i,e[9]=c):c=e[9];let d;e[10]!==r?(d=le(Jo,r),e[10]=r,e[11]=d):d=e[11];let u;e[12]!==n||e[13]!==a||e[14]!==c||e[15]!==d?(u=t.jsx(Xi,{"data-slot":"dropdown-menu-content",style:c,className:d,...a,children:n}),e[12]=n,e[13]=a,e[14]=c,e[15]=d,e[16]=u):u=e[16];let f;return e[17]!==l||e[18]!==u?(f=t.jsx(tl,{children:t.jsx(sl,{className:l,children:u})}),e[17]=l,e[18]=u,e[19]=f):f=e[19],f}function Xf(s){const e=ze.c(8);let n,r;e[0]!==s?({className:n,...r}=s,e[0]=s,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let o;e[3]!==n?(o=le(Qo,n),e[3]=n,e[4]=o):o=e[4];let a;return e[5]!==r||e[6]!==o?(a=t.jsx(Zi,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a}function Zf(s){const e=ze.c(8);let n,r;e[0]!==s?({className:n,...r}=s,e[0]=s,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let o;e[3]!==n?(o=le(Xo,n),e[3]=n,e[4]=o):o=e[4];let a;return e[5]!==r||e[6]!==o?(a=t.jsx(el,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a}const ic=280,or=4,lc=({transform:s})=>({...s,y:0}),cc=s=>{const e=ze.c(18),{id:n,children:r,className:o}=s;let a;e[0]!==n?(a={id:n},e[0]=n,e[1]=a):a=e[1];const{attributes:i,listeners:l,setNodeRef:c,transform:d,transition:u,isDragging:f}=so(a);let b;e[2]!==d?(b=ro.Transform.toString(d),e[2]=d,e[3]=b):b=e[3];let m;e[4]!==b||e[5]!==u?(m={transform:b,transition:u},e[4]=b,e[5]=u,e[6]=m):m=e[6];const x=f&&"opacity-50";let g;e[7]!==o||e[8]!==x?(g=le("h-full rounded-md",o,x),e[7]=o,e[8]=x,e[9]=g):g=e[9];let S;return e[10]!==i||e[11]!==r||e[12]!==n||e[13]!==l||e[14]!==c||e[15]!==m||e[16]!==g?(S=t.jsx("div",{ref:c,"data-sortable-tab-id":n,style:m,className:g,...i,...l,children:r}),e[10]=i,e[11]=r,e[12]=n,e[13]=l,e[14]=c,e[15]=m,e[16]=g,e[17]=S):S=e[17],S},dc=s=>{const e=ze.c(6),{id:n,children:r,className:o}=s;let a;e[0]!==o?(a=le("h-full",o),e[0]=o,e[1]=a):a=e[1];let i;return e[2]!==r||e[3]!==n||e[4]!==a?(i=t.jsx("div",{className:a,"data-sortable-tab-id":n,children:r}),e[2]=r,e[3]=n,e[4]=a,e[5]=i):i=e[5],i},Ts=s=>{const e=ze.c(137),{items:n,activeId:r,onSelect:o,onClose:a,onReorder:i,layoutMode:l,variant:c,activePillInsetClassName:d,activePillButtonClassName:u,inactiveTabsIconOnly:f,animateActivePill:b,activePillLowercase:m,nonCompositedIndicator:x,tabContextMenu:g,className:S}=s,p=l===void 0?"scrollable":l,N=c===void 0?"default":c,A=f===void 0?!1:f,L=m===void 0?!0:m,I=x===void 0?!1:x,{t:T}=nt(),y=Ve(uc),{isTablet:v}=xs(),$=y||v,U=h.useRef(null);let W;e[0]===Symbol.for("react.memo_cache_sentinel")?(W={left:!1,right:!1},e[0]=W):W=e[0];const[z,q]=h.useState(W);let se;e[1]!==n?(se=n.map(fc),e[1]=n,e[2]=se):se=e[2];const J=se,G=p==="scrollable",ee=N==="default",ue=N==="active-pill",P=ue||N==="animated",B=ee,M=P||B,D=ue&&G,_=P,E=b??P,K=typeof i=="function",O=K?cc:dc;let ne;e[3]===Symbol.for("react.memo_cache_sentinel")?(ne=new Map,e[3]=ne):ne=e[3];const X=h.useRef(ne),[te,ge]=h.useState(null),[re,pe]=h.useState(!1),[Z,de]=h.useState(null),me=h.useRef(!1),j=h.useRef(0),Y=h.useRef(r),F=h.useRef(null);let ae;e:{if(!M||!Z||!r||Z===r){ae=0;break e}const Ee=n.findIndex(Me=>Me.id===Z),fe=n.findIndex(Me=>Me.id===r);if(Ee<0||fe<0){ae=0;break e}ae=Ee>fe?or:-or}const he=ae;let we;e[4]===Symbol.for("react.memo_cache_sentinel")?(we={activationConstraint:{distance:8}},e[4]=we):we=e[4];const Te=Qr(Xr(Zr,we)),Ge=mc;let Fe;e[5]===Symbol.for("react.memo_cache_sentinel")?(Fe=(Ee,fe)=>{if(fe){X.current.set(Ee,fe);return}X.current.delete(Ee)},e[5]=Fe):Fe=e[5];const ve=Fe;let Re;e[6]!==r||e[7]!==M?(Re=()=>{if(!M||!r){ge(hc);return}const Ee=U.current,fe=X.current.get(r);if(!Ee||!fe){ge(pc);return}let Me=0,Ze=0,ht=fe;for(;ht&&ht!==Ee;)Me=Me+ht.offsetLeft,Ze=Ze+ht.offsetTop,ht=ht.offsetParent;const xt={left:Me,top:Ze,width:fe.offsetWidth,height:fe.offsetHeight};ge(St=>Ge(St,xt)?St:xt)},e[6]=r,e[7]=M,e[8]=Re):Re=e[8];const Ce=Re;let Ue;e[9]!==G?(Ue=()=>{if(!G){q({left:!1,right:!1});return}const Ee=U.current;if(!Ee){q({left:!1,right:!1});return}q({left:Ee.scrollLeft>2,right:Ee.scrollLeft+Ee.clientWidth<Ee.scrollWidth-2})},e[9]=G,e[10]=Ue):Ue=e[10];const He=Ue;let qe;e[11]!==G||e[12]!==He?(qe=()=>{if(!G){q({left:!1,right:!1});return}const Ee=U.current;if(!Ee)return;He(),Ee.addEventListener("scroll",He,{passive:!0});const fe=new ResizeObserver(He);return fe.observe(Ee),()=>{Ee.removeEventListener("scroll",He),fe.disconnect()}},e[11]=G,e[12]=He,e[13]=qe):qe=e[13];let Ke;e[14]!==G||e[15]!==n.length||e[16]!==He?(Ke=[G,n.length,He],e[14]=G,e[15]=n.length,e[16]=He,e[17]=Ke):Ke=e[17],h.useEffect(qe,Ke);let We;e[18]!==r||e[19]!==Ce||e[20]!==M?(We=()=>{if(!M){ge(null);return}Ce();const Ee=U.current;if(!Ee)return;const fe=new ResizeObserver(()=>{performance.now()-j.current>ic&&pe(!1),Ce()});if(fe.observe(Ee),r){const Me=X.current.get(r);Me&&fe.observe(Me)}return()=>{fe.disconnect()}},e[18]=r,e[19]=Ce,e[20]=M,e[21]=We):We=e[21];let tt;e[22]!==r||e[23]!==n.length||e[24]!==Ce||e[25]!==M?(tt=[r,n.length,Ce,M],e[22]=r,e[23]=n.length,e[24]=Ce,e[25]=M,e[26]=tt):tt=e[26],h.useEffect(We,tt);let ct;e[27]!==Ce?(ct=()=>{Ce()},e[27]=Ce,e[28]=ct):ct=e[28],h.useLayoutEffect(ct);let Be;e[29]!==J?(Be=J.join("\0"),e[29]=J,e[30]=Be):Be=e[30];const Ye=Be;let Qe,Je;e[31]!==r||e[32]!==Ye||e[33]!==M?(Qe=()=>{if(!M){me.current=!1,pe(!1);return}const Ee=F.current!==Ye;if(F.current=Ye,!me.current){me.current=!0,Y.current=r;return}const fe=Y.current!==r;if(Y.current=r,!fe||Ee){pe(!1);return}j.current=performance.now(),pe(!0)},Je=[r,Ye,M],e[31]=r,e[32]=Ye,e[33]=M,e[34]=Qe,e[35]=Je):(Qe=e[34],Je=e[35]),h.useLayoutEffect(Qe,Je);let De;e[36]!==r||e[37]!==G||e[38]!==He?(De=()=>{if(!G||!r)return;const Ee=U.current;if(!Ee)return;const fe=window.requestAnimationFrame(()=>{const Me=typeof window.CSS?.escape=="function"?window.CSS.escape(r):r.replace(/"/g,'\\"'),Ze=Ee.querySelector(`[data-sortable-tab-id="${Me}"]`);Ze&&(Ze.scrollIntoView({block:"nearest",inline:"nearest"}),He())});return()=>{window.cancelAnimationFrame(fe)}},e[36]=r,e[37]=G,e[38]=He,e[39]=De):De=e[39];let ot;e[40]!==r||e[41]!==G||e[42]!==n.length||e[43]!==He?(ot=[r,G,n.length,He],e[40]=r,e[41]=G,e[42]=n.length,e[43]=He,e[44]=ot):ot=e[44],h.useEffect(De,ot);let $e;e[45]!==i?($e=Ee=>{if(!i)return;const{active:fe,over:Me}=Ee;!Me||fe.id===Me.id||i(String(fe.id),String(Me.id))},e[45]=i,e[46]=$e):$e=e[46];const _e=$e;let st;e[47]!==S?(st=le("relative flex h-full min-w-0 flex-1",S),e[47]=S,e[48]=st):st=e[48];let Pe;e[49]!==G||e[50]!==z||e[51]!==P?(Pe=G&&z.left?t.jsx("div",{className:le("pointer-events-none absolute inset-y-0 left-0 z-20 bg-gradient-to-r to-transparent",P?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e[49]=G,e[50]=z,e[51]=P,e[52]=Pe):Pe=e[52];let Xe;e[53]!==G||e[54]!==z||e[55]!==P?(Xe=G&&z.right?t.jsx("div",{className:le("pointer-events-none absolute inset-y-0 right-0 z-20 bg-gradient-to-l to-transparent",P?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e[53]=G,e[54]=z,e[55]=P,e[56]=Xe):Xe=e[56];const dt=P?"items-center overflow-x-hidden overflow-y-hidden":"items-stretch",lt=P&&"@container/pill-tabs",ut=P&&"pill-tabs__track",yt=P&&(d??"gap-0.5 py-0.5"),w=B&&"items-center overflow-y-hidden",H=_&&"rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[color-mix(in_srgb,var(--foreground)_4%,transparent)] p-0.5 gap-0.5",ke=G?"overflow-x-auto scrollbar-none":"overflow-x-hidden";let Ae;e[57]!==dt||e[58]!==lt||e[59]!==ut||e[60]!==yt||e[61]!==w||e[62]!==H||e[63]!==ke?(Ae=le("relative flex h-full min-w-0 flex-1",dt,lt,ut,yt,w,H,ke),e[57]=dt,e[58]=lt,e[59]=ut,e[60]=yt,e[61]=w,e[62]=H,e[63]=ke,e[64]=Ae):Ae=e[64];let k;e[65]!==G?(k=G?{scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,e[65]=G,e[66]=k):k=e[66];let oe;e[67]!==T?(oe=T("sortableTabsStrip.aria.tabs"),e[67]=T,e[68]=oe):oe=e[68];let ye;e[69]!==I||e[70]!==he||e[71]!==te||e[72]!==re||e[73]!==E||e[74]!==P?(ye=P&&te?t.jsx("div",{className:le("pointer-events-none absolute left-0 top-0 z-0 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[var(--surface-elevated)]","border border-[color-mix(in_srgb,var(--foreground)_7%,transparent)]","shadow-[0_1px_2px_color-mix(in_srgb,var(--foreground)_10%,transparent),0_2px_6px_color-mix(in_srgb,var(--foreground)_6%,transparent)]",E&&re&&(I?"pill-tabs__indicator--is-animated-layout":"pill-tabs__indicator--is-animated")),style:I?{left:`${te.left+he}px`,top:`${te.top}px`,width:`${te.width}px`,height:`${te.height}px`}:{transform:`translate3d(${te.left+he}px, ${te.top}px, 0)`,width:`${te.width}px`,height:`${te.height}px`}}):null,e[69]=I,e[70]=he,e[71]=te,e[72]=re,e[73]=E,e[74]=P,e[75]=ye):ye=e[75];let xe;e[76]!==he||e[77]!==te||e[78]!==re||e[79]!==B?(xe=B&&te?t.jsx("div",{className:le("pointer-events-none absolute left-0 -bottom-px z-10 h-[3px] rounded-t-[2px] bg-[var(--primary-base)]",re&&"underline-tabs__indicator--is-animated"),style:{transform:`translate3d(${te.left+he}px, 0, 0)`,width:`${te.width}px`},"aria-hidden":!0}):null,e[76]=he,e[77]=te,e[78]=re,e[79]=B,e[80]=xe):xe=e[80];let je;if(e[81]!==O||e[82]!==r||e[83]!==u||e[84]!==L||e[85]!==$||e[86]!==A||e[87]!==ue||e[88]!==y||e[89]!==G||e[90]!==J||e[91]!==n||e[92]!==a||e[93]!==o||e[94]!==g||e[95]!==D||e[96]!==P||e[97]!==M){let Ee;e[99]!==O||e[100]!==r||e[101]!==u||e[102]!==L||e[103]!==$||e[104]!==A||e[105]!==ue||e[106]!==y||e[107]!==G||e[108]!==J||e[109]!==a||e[110]!==o||e[111]!==g||e[112]!==D||e[113]!==P||e[114]!==M?(Ee=(fe,Me)=>{const Ze=fe.id===r,ht=A&&P&&!Ze&&!!fe.icon,xt=!ht,St=!!fe.icon,kt=A&&P&&Ze&&!G&&!D,wt=fe.closable!==!1&&!!a,jt=wt&&!!fe.icon,Ct=G||D?void 0:P?kt?"flex-none basis-auto":y?"flex-1 basis-0 min-w-0":"flex-1 basis-0 min-w-fit":"min-w-0 flex-1 basis-0",Et=wt?mt=>{mt.button===1&&(mt.preventDefault(),mt.stopPropagation(),a?.(fe.id))}:void 0,_t=wt?gc:void 0,Ft=!y&&g?g({id:fe.id,index:Me,isActive:Ze,allIds:J,close:()=>a?.(fe.id)}):null,Xt=t.jsxs("div",{ref:mt=>ve(fe.id,mt),onAuxClick:Et,onMouseDown:_t,className:le("group flex h-full min-w-0 flex-nowrap items-center",G||D?"shrink-0":P?"w-full":"w-full min-w-0",P?"relative z-10 bg-transparent":Ze?"relative z-10 bg-transparent text-foreground":"relative z-10 bg-transparent text-muted-foreground hover:text-foreground"),children:[t.jsx("button",{type:"button",role:"tab","aria-selected":Ze,"aria-label":ht?fe.title??fe.label:void 0,onClick:()=>o(fe.id),onPointerDown:M?()=>{pe(!0),de(fe.id)}:void 0,onPointerUp:M?()=>de(null):void 0,onPointerLeave:M?()=>de(null):void 0,onPointerCancel:M?()=>de(null):void 0,className:le(P?"animated-tabs__button pill-tabs__button relative z-10 flex flex-1 min-w-0 flex-nowrap items-center justify-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] text-sm font-medium transition-colors duration-150 !min-h-0":"flex h-full min-w-0 flex-nowrap items-center typography-micro",P&&L?"lowercase":null,P&&(ht?"gap-0":"gap-1.5"),P?D?"shrink-0 whitespace-nowrap px-3 text-center":G?"max-w-56 shrink-0 px-3 text-center":ht?"px-2 !min-w-0 text-center":kt?"shrink-0 whitespace-nowrap px-3 text-center":"px-3 text-center":G?"max-w-56 justify-start truncate px-3 text-left":"w-full justify-center truncate px-3 text-center",P?u??(ue?y?"h-[38px]":"h-[31px]":"h-7"):null,P?Ze?"text-foreground":"text-muted-foreground hover:text-foreground":null,P?"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-background":null),title:fe.title??fe.label,children:P?t.jsxs(t.Fragment,{children:[St?t.jsxs("span",{className:"relative flex h-4 w-4 shrink-0 items-center justify-center",children:[t.jsx("span",{className:le("flex items-center justify-center transition-opacity",jt&&($?"opacity-0":"group-hover:opacity-0")),children:fe.icon}),jt?t.jsx("span",{role:"button",tabIndex:-1,className:le("absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground",$?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:xc,onClick:mt=>{mt.stopPropagation(),a?.(fe.id)},"aria-label":fe.closeLabel??`Close ${fe.label} tab`,title:fe.closeLabel??`Close ${fe.label} tab`,children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,xt?t.jsx("span",{className:"animated-tabs__label truncate",children:fe.label}):null]}):t.jsxs("span",{className:le("flex min-w-0 flex-nowrap items-center gap-1.5",!G&&"justify-center"),children:[St?t.jsxs("span",{className:le("relative flex h-4 w-4 shrink-0 items-center justify-center transition-colors duration-200 ease-out",Ze?"text-[var(--primary-base)]":"text-muted-foreground"),children:[t.jsx("span",{className:le("flex items-center justify-center transition-opacity",jt&&($?"opacity-0":"group-hover:opacity-0")),children:fe.icon}),jt?t.jsx("span",{role:"button",tabIndex:-1,className:le("absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground",$?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:bc,onClick:mt=>{mt.stopPropagation(),a?.(fe.id)},"aria-label":fe.closeLabel??`Close ${fe.label} tab`,title:fe.closeLabel??`Close ${fe.label} tab`,children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,t.jsx("span",{className:"truncate leading-[1.2]",children:fe.label})]})}),wt&&!jt?t.jsx("button",{type:"button",onPointerDown:yc,onClick:mt=>{mt.stopPropagation(),a?.(fe.id)},className:le("relative z-20 inline-flex !min-h-0 !min-w-0 items-center justify-center transition-opacity",P?"-ml-2.5 mr-1 h-[88%] w-5 self-center !aspect-auto rounded-md":"aspect-square h-[65%] min-h-4 max-h-5 rounded-sm mr-1",P?Ze?"text-muted-foreground hover:bg-transparent hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-transparent hover:text-foreground group-hover:opacity-100":Ze?"text-muted-foreground hover:bg-interactive-hover/60 hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-interactive-hover/80 hover:text-foreground group-hover:opacity-100"),"aria-label":fe.closeLabel??`Close ${fe.label} tab`,title:fe.closeLabel??`Close ${fe.label} tab`,children:t.jsx(R,{name:"close",className:"h-3 w-3"})}):null]});return t.jsx(O,{id:fe.id,className:Ct,children:Ft?t.jsxs(rc,{children:[t.jsx(oc,{render:mt=>t.jsx("div",{...mt,className:le("flex h-full min-w-0",mt.className),children:Xt})}),t.jsx(ac,{className:"w-52",children:Ft})]}):Xt},fe.id)},e[99]=O,e[100]=r,e[101]=u,e[102]=L,e[103]=$,e[104]=A,e[105]=ue,e[106]=y,e[107]=G,e[108]=J,e[109]=a,e[110]=o,e[111]=g,e[112]=D,e[113]=P,e[114]=M,e[115]=Ee):Ee=e[115],je=n.map(Ee),e[81]=O,e[82]=r,e[83]=u,e[84]=L,e[85]=$,e[86]=A,e[87]=ue,e[88]=y,e[89]=G,e[90]=J,e[91]=n,e[92]=a,e[93]=o,e[94]=g,e[95]=D,e[96]=P,e[97]=M,e[98]=je}else je=e[98];let C;e[116]!==Ae||e[117]!==k||e[118]!==oe||e[119]!==ye||e[120]!==xe||e[121]!==je?(C=t.jsxs("div",{ref:U,className:Ae,style:k,role:"tablist","aria-label":oe,children:[ye,xe,je]}),e[116]=Ae,e[117]=k,e[118]=oe,e[119]=ye,e[120]=xe,e[121]=je,e[122]=C):C=e[122];let Q;e[123]!==st||e[124]!==Pe||e[125]!==Xe||e[126]!==C?(Q=t.jsxs("div",{className:st,children:[Pe,Xe,C]}),e[123]=st,e[124]=Pe,e[125]=Xe,e[126]=C,e[127]=Q):Q=e[127];const ie=Q;if(!K)return ie;let Oe;e[128]===Symbol.for("react.memo_cache_sentinel")?(Oe=[lc],e[128]=Oe):Oe=e[128];let be;e[129]!==J||e[130]!==ie?(be=t.jsx(no,{items:J,strategy:il,children:ie}),e[129]=J,e[130]=ie,e[131]=be):be=e[131];let Le;e[132]===Symbol.for("react.memo_cache_sentinel")?(Le=t.jsx(al,{dropAnimation:null}),e[132]=Le):Le=e[132];let rt;return e[133]!==_e||e[134]!==Te||e[135]!==be?(rt=t.jsxs(eo,{sensors:Te,collisionDetection:to,onDragEnd:_e,modifiers:Oe,children:[be,Le]}),e[133]=_e,e[134]=Te,e[135]=be,e[136]=rt):rt=e[136],rt};function uc(s){return s.isMobile}function fc(s){return s.id}function mc(s,e){return!s||!e?s===e:Math.abs(s.left-e.left)<.5&&Math.abs(s.top-e.top)<.5&&Math.abs(s.width-e.width)<.5&&Math.abs(s.height-e.height)<.5}function hc(s){return s===null?s:null}function pc(s){return s===null?s:null}function gc(s){s.button===1&&s.preventDefault()}function xc(s){s.stopPropagation()}function bc(s){s.stopPropagation()}function yc(s){s.stopPropagation()}const qt=Js()(qr(Yr((s,e)=>({selectedProfileId:null,defaultGitIdentityId:null,profiles:[],globalIdentity:null,discoveredCredentials:[],isLoading:!1,setSelectedProfile:n=>{s({selectedProfileId:n})},loadProfiles:async()=>{s({isLoading:!0});const n=e().profiles;try{const r=await ra();return s({profiles:r,isLoading:!1}),!0}catch(r){return console.error("Failed to load git identity profiles:",r),s({profiles:n,isLoading:!1}),!1}},loadGlobalIdentity:async()=>{try{const n=await na();if(n&&n.userName&&n.userEmail){const r={id:"global",name:"Global Identity",userName:n.userName,userEmail:n.userEmail,authType:n.sshCommand?"ssh":void 0,sshKey:n.sshCommand?n.sshCommand.replace("ssh -i ",""):null,color:"info",icon:"fingerprint"};s({globalIdentity:r})}else s({globalIdentity:null});return!0}catch(n){return console.error("Failed to load global git identity:",n),s({globalIdentity:null}),!1}},loadDiscoveredCredentials:async()=>{try{const n=await sa();return s({discoveredCredentials:n}),!0}catch(n){return console.error("Failed to discover git credentials:",n),s({discoveredCredentials:[]}),!1}},loadDefaultGitIdentityId:async()=>{const n=r=>{if(typeof r!="string")return null;const o=r.trim();return o.length>0?o:null};try{let r=null;if(r===null){const o=Li()?.settings;if(o)try{const i=(await o.load())?.settings||{};r=n(i.defaultGitIdentityId)}catch{}}if(r===null)try{const o=await Mt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(o.ok){const a=await o.json().catch(()=>null);r=n(a?.defaultGitIdentityId)}}catch{}return s({defaultGitIdentityId:r}),!0}catch(r){return console.error("Failed to load default git identity setting:",r),!1}},setDefaultGitIdentityId:async n=>{try{const r=typeof n=="string"?n.trim():"",o=r.length>0?r:"";return await Gr({defaultGitIdentityId:o}),s({defaultGitIdentityId:o.length>0?o:null}),!0}catch(r){return console.error("Failed to save default git identity setting:",r),!1}},createProfile:async n=>{try{const r={...n,id:n.id||`profile-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,color:n.color||"keyword",icon:n.icon||"branch"};return $t("saving"),await ta(r),$t("saved"),await e().loadProfiles(),!0}catch(r){return $t("error"),console.error("Failed to create git identity profile:",r),!1}},updateProfile:async(n,r)=>{try{const o=e().profiles.find(i=>i.id===n);if(!o)throw new Error("Profile not found");const a={...o,...r};return $t("saving"),await ea(n,a),$t("saved"),await e().loadProfiles(),!0}catch(o){return $t("error"),console.error("Failed to update git identity profile:",o),!1}},deleteProfile:async n=>{try{return $t("saving"),await Zo(n),$t("saved"),e().selectedProfileId===n&&s({selectedProfileId:null}),await e().loadProfiles(),!0}catch(r){return $t("error"),console.error("Failed to delete git identity profile:",r),!1}},getProfileById:n=>{const{profiles:r,globalIdentity:o}=e();return n==="global"?o||void 0:r.find(a=>a.id===n)},getUnimportedCredentials:()=>{const{profiles:n,discoveredCredentials:r}=e();return r.filter(o=>!n.some(a=>a.authType==="token"&&a.host===o.host))}}),{name:"git-identities-store",storage:Bi(),partialize:s=>({selectedProfileId:s.selectedProfileId})}),{name:"git-identities-store"}));typeof window<"u"&&(window.__zustand_git_identities_store__=qt);const Gs=oa,Wt=s=>{const e=ze.c(11),{title:n,description:r,info:o,settingsItem:a,titleAccessory:i,headerAction:l,children:c,className:d,contentClassName:u,divider:f}=s,b=f===void 0?!0:f;let m;return e[0]!==c||e[1]!==d||e[2]!==u||e[3]!==r||e[4]!==b||e[5]!==l||e[6]!==o||e[7]!==a||e[8]!==n||e[9]!==i?(m=t.jsx(aa,{title:n,description:r,info:o,settingsItem:a,titleAccessory:i,headerAction:l,divider:b,className:d,contentClassName:u,children:c}),e[0]=c,e[1]=d,e[2]=u,e[3]=r,e[4]=b,e[5]=l,e[6]=o,e[7]=a,e[8]=n,e[9]=i,e[10]=m):m=e[10],m},wc=450,vc=({projectRef:s=null,sections:e="all"})=>{const{t:n}=nt(),{isMobile:r,isTablet:o}=xs(),a=r||o,i=It(D=>D.getActiveProject()),l=s?.path??i?.path??null,c=it(D=>D.getWorktreeMetadata),d=ia(),u=bs(D=>D.homeDirectory),[f,b]=h.useState([]),[m,x]=h.useState(!1),[g,S]=h.useState(!1),[p,N]=h.useState(null),[A,L]=h.useState(null),[I,T]=h.useState([]),[y,v]=h.useState(!1),$=h.useRef(!1),U=h.useMemo(()=>s?.id&&s?.path?{id:s.id,path:s.path}:!i?.id||!l?null:{id:i.id,path:l},[i?.id,l,s?.id,s?.path]),W=h.useCallback(async()=>{if(!(!U||A===!1))try{const D=await Wn(U);T(D)}catch{}},[U,A]);h.useEffect(()=>{if(!l)return;let D=!1;return L(null),(async()=>{try{const _=await la(l);if(D)return;L(_)}catch{}})(),()=>{D=!0}},[l]),h.useEffect(()=>{if(!U){T([]),v(!1);return}if(A===!1){T([]),v(!1);return}let D=!1;return v(!0),T([]),(async()=>{try{const _=await Wn(U);if(D)return;T(_)}catch{}finally{D||v(!1)}})(),()=>{D=!0}},[U,A]),h.useEffect(()=>{if(!U)return;let D=!1;return S(!0),(async()=>{try{const[_,E]=await Promise.all([Pr(U),Rr(U)]);if(!D){const K=_.length>0?_:[""];b(K),N(JSON.stringify(K)),x(E)}}catch{D||(b([""]),N(JSON.stringify([""])),x(!1))}finally{D||S(!1)}})(),()=>{D=!0}},[U]);const z=h.useCallback(async D=>{if(!U)return!1;const _=D.filter(E=>E.trim().length>0);try{return await ca(U,_)?(N(JSON.stringify(D)),!0):(Ne.error(n("settings.openchamber.worktrees.setup.toast.saveFailed")),!1)}catch{return Ne.error(n("settings.openchamber.worktrees.setup.toast.saveFailed")),!1}},[U,n]),q=h.useMemo(()=>p===null?!1:p!==JSON.stringify(f),[p,f]);h.useEffect(()=>{if(!q||g||$.current)return;const D=window.setTimeout(()=>{$.current||($.current=!0,(async()=>{try{await z(f)}finally{$.current=!1}})())},wc);return()=>{window.clearTimeout(D)}},[q,g,z,f]);const se=h.useCallback((D,_)=>{b(E=>{const K=[...E];return K[D]=_,K})},[]),J=h.useCallback(()=>{b(D=>[...D,""])},[]),G=h.useCallback(D=>{b(_=>{const E=_.filter((K,O)=>O!==D);return E.length>0?E:[""]})},[]),ee=h.useCallback(()=>{!q||$.current||($.current=!0,(async()=>{try{await z(f)}finally{$.current=!1}})())},[q,z,f]),ue=h.useCallback(D=>{x(D),U&&da(U,D)},[U]),V=h.useCallback(D=>{const _=pe=>pe.replace(/\\/g,"/").replace(/\/+$/,""),E=_(D.path),K=d.filter(pe=>{const Z=c(pe.id);if(Z?.path&&_(Z.path)===E)return!0;const de=pe.directory;return!!(de&&_(de)===E)}),O=new Set(K.map(pe=>pe.id)),ne=[...Yt.getState().activeSessions,...Yt.getState().archivedSessions],X=pe=>{const Z=ne.filter(me=>{const j=me.parentID;return j&&pe.has(j)});if(Z.length===0)return[];const de=new Set(Z.map(me=>me.id));return[...Z,...X(de)]},te=X(O),ge=new Set,re=[...K,...te].filter(pe=>ge.has(pe.id)?!1:(ge.add(pe.id),!0));ua.requestDelete({sessions:re,mode:"worktree",worktree:D})},[d,c]),P=h.useMemo(()=>d.map(D=>D.id).join(","),[d]);h.useEffect(()=>{A&&l&&W()},[P,A,l,W]);const B=t.jsxs(pn,{children:[n("settings.openchamber.worktrees.setup.tooltipPrefix")," ",t.jsx("code",{className:"font-mono text-xs bg-sidebar-accent/50 px-1 rounded",children:"$ROOT_PROJECT_PATH"})," ",n("settings.openchamber.worktrees.setup.tooltipSuffix")]}),M=t.jsx(pn,{children:n("settings.openchamber.worktrees.list.tooltip")});return l?A===!1?t.jsx(Wt,{title:n("settings.projects.page.section.worktree"),settingsItem:"projects.worktree",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.openchamber.worktrees.state.gitOnly")})}):t.jsxs(t.Fragment,{children:[e==="all"?t.jsx(Wt,{title:n("settings.projects.page.section.worktree"),settingsItem:"projects.worktree",titleAccessory:B,children:g?t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.openchamber.worktrees.setup.loading")}):t.jsxs("div",{className:le("space-y-2",Gs),children:[f.map((D,_)=>t.jsxs("div",{className:"flex w-full gap-2",children:[t.jsx(bt,{value:D,onChange:E=>se(_,E.target.value),onBlur:ee,placeholder:n("settings.openchamber.worktrees.setup.commandPlaceholder"),className:"h-7 min-w-0 flex-1 font-mono text-xs"}),t.jsx(Ie,{type:"button",variant:"ghost",size:"icon",onClick:()=>G(_),className:"h-7 w-7 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive","aria-label":n("settings.openchamber.worktrees.setup.removeCommandAria"),children:t.jsx(R,{name:"close",className:"h-4 w-4"})})]},_)),t.jsxs(Ie,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:J,children:[t.jsx(R,{name:"add",className:"h-3.5 w-3.5"}),n("settings.openchamber.worktrees.setup.addCommand")]}),t.jsxs("label",{"data-settings-item":"projects.worktree.setup.wait",className:"flex cursor-pointer items-center gap-2 py-1",children:[t.jsx(Es,{checked:m,onChange:ue,ariaLabel:n("settings.openchamber.worktrees.setup.waitForCommandsAria")}),t.jsx("span",{className:le("typography-ui-label font-normal",m?"text-foreground":"text-foreground/60"),children:n("settings.openchamber.worktrees.setup.waitForCommands")})]})]})}):null,t.jsx(Wt,{title:n("settings.openchamber.worktrees.list.title"),titleAccessory:M,children:y?t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.openchamber.worktrees.list.loading")}):I.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground/70",children:n("settings.openchamber.worktrees.list.empty")}):t.jsx("div",{className:le("space-y-1",e==="all"&&Gs),children:I.map(D=>t.jsxs("div",{className:"group flex w-full items-center gap-2 py-1.5",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"flex min-w-0 items-center gap-2",children:t.jsx("p",{className:"typography-meta min-w-0 truncate text-foreground",children:D.label||D.branch||n("settings.openchamber.worktrees.list.detachedHead")})}),t.jsx("p",{className:"typography-micro truncate text-muted-foreground/60",children:fa(D.path,u)})]}),t.jsx("button",{type:"button",onClick:()=>V(D),className:le("flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-opacity hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",a?"opacity-100":"opacity-0 group-hover:opacity-100"),"aria-label":n("settings.openchamber.worktrees.list.deleteWorktreeAria",{name:D.branch||D.label||D.path}),children:t.jsx(R,{name:"delete-bin",className:"h-4 w-4"})})]},D.path))})})]}):t.jsx(Wt,{title:n("settings.projects.page.section.worktree"),settingsItem:"projects.worktree",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.openchamber.worktrees.state.selectProject")})})},ar=(s,e)=>e.updatedAtMs-s.updatedAtMs,ir=Js((s,e)=>({instances:[],statusesById:{},importCandidates:[],isLoading:!1,isSaving:!1,isImportsLoading:!1,initialized:!1,listenerReady:!1,error:null,load:async()=>{if(!e().isLoading){s({isLoading:!0,error:null});try{const[n,r]=await Promise.all([ga(),Vn()]),o={};for(const a of r.sort(ar))o[a.id]=a;e().listenerReady||await xa(a=>{s(i=>({statusesById:{...i.statusesById,[a.id]:a}}))}),s({instances:n.instances,statusesById:o,isLoading:!1,initialized:!0,listenerReady:!0})}catch(n){s({isLoading:!1,error:n instanceof Error?n.message:String(n)})}}},loadImports:async()=>{if(!e().isImportsLoading){s({isImportsLoading:!0,error:null});try{const n=await pa();s({importCandidates:n,isImportsLoading:!1})}catch(n){s({isImportsLoading:!1,error:n instanceof Error?n.message:String(n)})}}},refreshStatuses:async()=>{try{const n=await Vn(),r={};for(const o of n.sort(ar))r[o.id]=o;s({statusesById:r})}catch(n){s({error:n instanceof Error?n.message:String(n)})}},setInstances:async n=>{s({isSaving:!0,error:null});try{await ha({instances:n}),s({instances:n,isSaving:!1}),await e().refreshStatuses()}catch(r){throw s({isSaving:!1,error:r instanceof Error?r.message:String(r)}),r}},upsertInstance:async n=>{const r=e().instances,o=r.some(a=>a.id===n.id)?r.map(a=>a.id===n.id?n:a):[n,...r];await e().setInstances(o)},createFromCommand:async(n,r,o)=>{const a=ba(n,r);o&&o.trim()&&(a.nickname=o.trim()),await e().upsertInstance(a)},removeInstance:async n=>{await _n(n).catch(()=>{});const r=e().instances.filter(o=>o.id!==n);await e().setInstances(r),s(o=>{const a={...o.statusesById};return delete a[n],{statusesById:a}})},connect:async n=>{s({error:null});try{await ma(n),await e().refreshStatuses()}catch(r){throw s({error:r instanceof Error?r.message:String(r)}),r}},disconnect:async n=>{s({error:null});try{await _n(n),await e().refreshStatuses()}catch(r){throw s({error:r instanceof Error?r.message:String(r)}),r}},retry:async n=>{await e().connect(n)},getStatus:n=>e().statusesById[n]||null,clearError:()=>s({error:null})})),lo=[{key:"play",label:"Play",Icon:"play"},{key:"build",label:"Build",Icon:"hammer"},{key:"lint",label:"Lint",Icon:"checkbox-circle"},{key:"terminal",label:"Terminal",Icon:"terminal-box"},{key:"tools",label:"Tools",Icon:"tools"},{key:"bug",label:"Bug",Icon:"bug"},{key:"flask",label:"Flask",Icon:"flask"},{key:"rocket",label:"Rocket",Icon:"rocket"},{key:"code",label:"Code",Icon:"code"},{key:"server",label:"Server",Icon:"server"},{key:"branch",label:"Branch",Icon:"git-branch"},{key:"search",label:"Search",Icon:"search"},{key:"settings",label:"Settings",Icon:"settings-3"},{key:"brain",label:"Brain",Icon:"brain-ai-3"},{key:"stack",label:"Stack",Icon:"stack"},{key:"robot",label:"Robot",Icon:"robot-2"},{key:"command",label:"Command",Icon:"command"},{key:"file",label:"File",Icon:"file-text"}],co=Object.fromEntries(lo.map(s=>[s.key,s.Icon])),Sc="openchamber:project-actions-updated",jc=s=>{const e=(s||"").trim().replace(/\\/g,"/");return e?e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e:""},em=(s,e)=>`${jc(s)}::${e}`,Nc=s=>{const e=s.trim();return!e||e==="0.0.0.0"||e==="::"?"127.0.0.1":e},lr=s=>{if(typeof s!="number"||!Number.isFinite(s))return null;const e=Math.round(s);return e<1||e>65535?null:e},kc=(s,e)=>{if(!e.enabled||e.type!=="local")return null;const n=lr(e.localPort),r=lr(e.remotePort);if(!n||!r)return null;const o=Nc(e.localHost||s.localForward.bindHost||"127.0.0.1"),a=(e.remoteHost||"127.0.0.1").trim(),i=(s.nickname||s.id||"instance").trim();return{id:`${s.id}::${e.id}`,label:`${i} - ${o}:${n} -> ${a}:${r}`,url:`http://${o}:${n}`}},uo=s=>{const e=[];for(const n of s)if(!(!n?.id||!Array.isArray(n.portForwards)))for(const r of n.portForwards){const o=kc(n,r);o&&e.push(o)}return e},tm=(s,e)=>{const n=(s||"").trim();return n&&uo(e).find(a=>a.id===n)?.url||null},Ic=450,Cc=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`action_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,Tc=()=>({id:Cc(),name:"",command:"",icon:"play"}),Dc=({projectRef:s})=>{const{t:e}=nt(),n=h.useMemo(()=>Hr(),[]),r=ir(T=>T.instances),o=ir(T=>T.load),[a,i]=h.useState([]),[l,c]=h.useState(!1),[d,u]=h.useState(null),[f,b]=h.useState({}),m=h.useRef(!1),x=h.useRef(null);h.useEffect(()=>{n&&o().catch(()=>{})},[n,o]),h.useEffect(()=>{let T=!1;return c(!0),(async()=>{try{const y=await ya(s);if(T)return;i(y.actions),u(JSON.stringify({actions:y.actions}))}catch{if(T)return;i([]),u(JSON.stringify({actions:[]}))}finally{T||c(!1)}})(),()=>{T=!0}},[s]);const g=h.useMemo(()=>n?uo(r):[],[r,n]),S=h.useMemo(()=>a.some(y=>y.name.trim().length===0||y.command.trim().length===0)?e("settings.projects.actions.validation.fillNameAndCommand"):null,[a,e]),p=h.useMemo(()=>d===null?!1:d!==JSON.stringify({actions:a}),[a,d]),N=h.useCallback(async T=>await wa(s,{actions:T,primaryActionId:null})?(u(JSON.stringify({actions:T})),typeof window<"u"&&window.dispatchEvent(new CustomEvent(Sc,{detail:{projectId:s.id}})),!0):(Ne.error(e("settings.projects.actions.toast.saveFailed")),!1),[s,e]);h.useEffect(()=>{if(!p||l||S||m.current)return;const T=window.setTimeout(()=>{m.current||(m.current=!0,(async()=>{try{await N(a)}finally{m.current=!1}})())},Ic);return()=>{window.clearTimeout(T)}},[a,p,l,N,S]),h.useEffect(()=>{if(!p||!S||l){S||(x.current=null);return}const T=window.setTimeout(()=>{x.current!==S&&(x.current=S,Ne.error(S))},1e3);return()=>{window.clearTimeout(T)}},[p,l,S]);const A=h.useCallback(()=>{const T=Tc();i(y=>[...y,T]),b(y=>({...y,[T.id]:!0}))},[]),L=h.useCallback(T=>{i(y=>y.filter(v=>v.id!==T)),b(y=>{const v={...y};return delete v[T],v})},[]),I=h.useCallback((T,y)=>{i(v=>v.map($=>$.id===T?y($):$))},[]);return t.jsxs(Wt,{title:e("settings.projects.actions.title"),info:e("settings.projects.actions.description"),settingsItem:"projects.actions",headerAction:t.jsxs(Ie,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:A,children:[t.jsx(R,{name:"add",className:"h-3.5 w-3.5"}),e("settings.projects.actions.actions.add")]}),contentClassName:"space-y-0",children:[l?t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.loading")}):a.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.empty")}):t.jsx("div",{className:le("space-y-0",Gs),children:a.map(T=>{const y=T.icon||"play",v=co[y]||"play",$=f[T.id]??!1,U=T.name.trim()||e("settings.projects.actions.state.untitled");return t.jsxs(Vl,{open:$,onOpenChange:W=>{b(z=>({...z,[T.id]:W}))},className:"py-1.5",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs(zl,{className:"group flex-1 justify-start gap-2 rounded-md px-0 pr-1 py-1 hover:bg-[var(--interactive-hover)] focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",children:[$?t.jsx(R,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):t.jsx(R,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"}),t.jsx(R,{name:v,className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:U})})]}),t.jsx(Ie,{type:"button",variant:"ghost",size:"xs",className:"!font-normal h-7 w-7 px-0 text-muted-foreground hover:text-[var(--status-error)]",onClick:()=>L(T.id),children:t.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"})})]}),t.jsx(Gl,{className:"pt-1.5",children:t.jsxs("div",{className:"space-y-2 pb-4 pl-3 pr-1",children:[t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[t.jsxs(zt,{children:[t.jsx(Gt,{asChild:!0,children:t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-[var(--interactive-border)] text-foreground hover:bg-[var(--interactive-hover)]","aria-label":e("settings.projects.actions.field.selectIconAria"),children:t.jsx(R,{name:v,className:"h-4 w-4"})})}),t.jsx(Ht,{align:"start",className:"w-56 p-2",children:t.jsx("div",{className:"grid grid-cols-6 gap-1",children:lo.map(W=>{const z=W.Icon,q=(T.icon||"play")===W.key;return t.jsx("button",{type:"button",onClick:()=>I(T.id,se=>({...se,icon:W.key})),className:le("inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-foreground hover:bg-[var(--interactive-hover)]",q&&"border-[var(--primary-base)] bg-[var(--primary-base)]/10 text-[var(--primary-base)]"),"aria-label":e("settings.projects.actions.field.iconAria",{icon:W.label}),children:t.jsx(R,{name:z,className:"h-4 w-4"})},W.key)})})})]}),t.jsx(bt,{value:T.name,onChange:W=>I(T.id,z=>({...z,name:W.target.value})),placeholder:e("settings.projects.actions.field.actionNamePlaceholder"),className:"h-7 flex-1 min-w-0"})]}),t.jsxs("div",{className:"py-1",children:[t.jsx("p",{className:"typography-meta mb-0.5 text-muted-foreground",children:e("settings.projects.actions.field.command")}),t.jsx(qs,{value:T.command,onChange:W=>I(T.id,z=>({...z,command:W.target.value})),placeholder:e("settings.projects.actions.field.commandPlaceholder"),className:"min-h-[88px] w-full font-mono text-xs"})]}),t.jsxs("div",{className:"py-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:e("settings.projects.actions.field.autoOpenUrl")}),t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2",role:"button",tabIndex:0,"aria-pressed":T.autoOpenUrl===!0,onClick:()=>I(T.id,W=>({...W,...W.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})),onKeyDown:W=>{(W.key===" "||W.key==="Enter")&&(W.preventDefault(),I(T.id,z=>({...z,...z.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})))},children:[t.jsx(Es,{checked:T.autoOpenUrl===!0,onChange:W=>I(T.id,z=>({...z,...W?{autoOpenUrl:!0}:{autoOpenUrl:void 0}})),ariaLabel:e("settings.projects.actions.field.autoOpenUrlForAria",{title:U})}),t.jsx("span",{className:"typography-ui-label font-normal text-foreground/80",children:e("settings.projects.actions.field.autoOpenUrlDescription")})]})]}),T.autoOpenUrl===!0?t.jsxs("div",{className:"mt-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(bt,{value:T.openUrl||"",onChange:W=>I(T.id,z=>({...z,openUrl:W.target.value})),placeholder:e("settings.projects.actions.field.overrideUrlPlaceholder"),className:"h-7 w-full max-w-[24rem]"}),t.jsx(pn,{contentClassName:"max-w-xs",children:e("settings.projects.actions.field.overrideUrlTooltip")})]}),n?t.jsxs("div",{className:"mt-2",children:[t.jsx("p",{className:"typography-meta mb-0.5 text-muted-foreground",children:e("settings.projects.actions.field.desktopSshForward")}),g.length>0?t.jsxs(Pn,{value:T.desktopOpenSshForward&&g.some(W=>W.id===T.desktopOpenSshForward)?T.desktopOpenSshForward:"__none__",onValueChange:W=>{I(T.id,z=>({...z,...W==="__none__"?{desktopOpenSshForward:void 0}:{desktopOpenSshForward:W}}))},children:[t.jsx(Rn,{size:Er,className:"w-full",children:t.jsx(Ar,{placeholder:e("settings.projects.actions.field.useOutputManualUrl")})}),t.jsxs(En,{children:[t.jsx(ks,{value:"__none__",children:e("settings.projects.actions.field.useOutputManualUrl")}),g.map(W=>t.jsx(ks,{value:W.id,children:W.label},W.id))]})]}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.noDesktopSshForwards")})]}):null]}):null]})]})})]},T.id)})}),S&&a.length>0?t.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:S}):null]})},sn="__default__",fo=s=>s.charAt(0).toUpperCase()+s.slice(1),Pc=s=>{const e=ze.c(138),{form:n}=s,{t:r}=nt(),{currentTheme:o}=Br(),a=Nt(Rc),{name:i,setName:l,icon:c,setIcon:d,color:u,setColor:f,iconBackground:b,setIconBackground:m,parsedDefaultModel:x,defaultVariant:g,handleDefaultModelChange:S,handleDefaultVariantChange:p,isUploadingIcon:N,isRemovingCustomIcon:A,isDiscoveringIcon:L,pendingRemoveImageIcon:I,setPendingRemoveImageIcon:T,pendingUploadIconPreviewUrl:y,setPreviewImageFailed:v,hasPendingUploadImageIcon:$,hasCustomIcon:U,effectiveHasImageIcon:W,hasRemovableImageIcon:z,showImagePreview:q,fileInputRef:se,handleUploadIcon:J,handleRemoveImageIcon:G,handleDiscoverIcon:ee,currentIconImage:ue,project:V}=n;let P;e:{const{providerId:Pe,modelId:Xe}=x;if(!Pe||!Xe){let lt;e[0]===Symbol.for("react.memo_cache_sentinel")?(lt=[],e[0]=lt):lt=e[0],P=lt;break e}let dt;if(e[1]!==Xe||e[2]!==Pe||e[3]!==a){const lt=a.find(ut=>ut.id===Pe)?.models.find(ut=>ut.id===Xe);dt=va(lt),e[1]=Xe,e[2]=Pe,e[3]=a,e[4]=dt}else dt=e[4];P=dt}const B=P;if(!V)return null;const M=u?Sa[u]??null:null;let D;e[5]!==r?(D=r("settings.projects.page.field.projectName"),e[5]=r,e[6]=D):D=e[6];let _;e[7]!==l?(_=Pe=>l(Pe.target.value),e[7]=l,e[8]=_):_=e[8];let E;e[9]!==r?(E=r("settings.projects.page.field.projectNamePlaceholder"),e[9]=r,e[10]=E):E=e[10];let K;e[11]===Symbol.for("react.memo_cache_sentinel")?(K=le("h-8 rounded-md px-3",Gs),e[11]=K):K=e[11];let O;e[12]!==i||e[13]!==_||e[14]!==E?(O=t.jsx(bt,{value:i,onChange:_,placeholder:E,className:K}),e[12]=i,e[13]=_,e[14]=E,e[15]=O):O=e[15];let ne;e[16]!==D||e[17]!==O?(ne=t.jsx(Wt,{title:D,settingsItem:"projects.name",divider:!1,children:O}),e[16]=D,e[17]=O,e[18]=ne):ne=e[18];let X;e[19]!==r?(X=r("settings.projects.page.section.chatDefaults"),e[19]=r,e[20]=X):X=e[20];let te;e[21]!==r?(te=r("settings.projects.page.section.chatDefaultsDescription"),e[21]=r,e[22]=te):te=e[22];let ge;e[23]!==r?(ge=r("settings.projects.page.field.projectModel"),e[23]=r,e[24]=ge):ge=e[24];let re;e[25]!==S||e[26]!==x.modelId||e[27]!==x.providerId?(re=t.jsx(Dr,{providerId:x.providerId,modelId:x.modelId,onChange:S,className:ja}),e[25]=S,e[26]=x.modelId,e[27]=x.providerId,e[28]=re):re=e[28];let pe;e[29]!==ge||e[30]!==re?(pe=t.jsx(zn,{settingsItem:"projects.default-model",label:ge,children:re}),e[29]=ge,e[30]=re,e[31]=pe):pe=e[31];let Z;e[32]!==B||e[33]!==g||e[34]!==p||e[35]!==r?(Z=B.length>0?t.jsx(zn,{settingsItem:"projects.default-thinking",label:r("settings.projects.page.field.projectThinking"),children:t.jsxs(Pn,{value:g??sn,onValueChange:Pe=>p(Pe===sn?void 0:Pe),children:[t.jsx(Rn,{size:Er,className:Na,"aria-label":r("settings.projects.page.field.projectThinking"),children:t.jsx(Ar,{children:g?fo(g):r("settings.projects.page.option.thinkingDefault")})}),t.jsxs(En,{children:[t.jsx(ks,{value:sn,children:r("settings.projects.page.option.thinkingDefault")}),B.map(Ec)]})]})}):null,e[32]=B,e[33]=g,e[34]=p,e[35]=r,e[36]=Z):Z=e[36];let de;e[37]!==pe||e[38]!==Z||e[39]!==X||e[40]!==te?(de=t.jsxs(Wt,{title:X,info:te,contentClassName:"space-y-0",children:[pe,Z]}),e[37]=pe,e[38]=Z,e[39]=X,e[40]=te,e[41]=de):de=e[41];let me;e[42]!==r?(me=r("settings.projects.page.field.accentColor"),e[42]=r,e[43]=me):me=e[43];let j;e[44]!==f?(j=()=>f(null),e[44]=f,e[45]=j):j=e[45];const Y=u===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let F;e[46]!==Y?(F=le("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",Y),e[46]=Y,e[47]=F):F=e[47];let ae;e[48]!==r?(ae=r("settings.projects.page.field.none"),e[48]=r,e[49]=ae):ae=e[49];let he;e[50]===Symbol.for("react.memo_cache_sentinel")?(he=t.jsx(R,{name:"close",className:"h-4 w-4 text-muted-foreground"}),e[50]=he):he=e[50];let we;e[51]!==j||e[52]!==F||e[53]!==ae?(we=t.jsx("button",{type:"button",onClick:j,className:F,title:ae,children:he}),e[51]=j,e[52]=F,e[53]=ae,e[54]=we):we=e[54];let Te;e[55]!==u||e[56]!==f?(Te=ka.map(Pe=>t.jsx("button",{type:"button",onClick:()=>f(Pe.key),className:le("h-7 w-7 rounded-md border transition-colors",u===Pe.key?"border-2 border-foreground ring-1 ring-[var(--primary-base)]/40":"border-transparent hover:border-border/70"),style:{backgroundColor:Pe.cssVar},title:Pe.label},Pe.key)),e[55]=u,e[56]=f,e[57]=Te):Te=e[57];let Ge;e[58]!==we||e[59]!==Te?(Ge=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[we,Te]}),e[58]=we,e[59]=Te,e[60]=Ge):Ge=e[60];let Fe;e[61]!==me||e[62]!==Ge?(Fe=t.jsx(Wt,{title:me,settingsItem:"projects.accent-color",children:Ge}),e[61]=me,e[62]=Ge,e[63]=Fe):Fe=e[63];let ve;e[64]!==r?(ve=r("settings.projects.page.field.projectIcon"),e[64]=r,e[65]=ve):ve=e[65];let Re;e[66]!==J?(Re=Pe=>{const Xe=Pe.target.files?.[0]??null;J(Xe),Pe.currentTarget.value=""},e[66]=J,e[67]=Re):Re=e[67];let Ce;e[68]!==se||e[69]!==Re?(Ce=t.jsx("input",{ref:se,type:"file",accept:"image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg",className:"hidden",onChange:Re}),e[68]=se,e[69]=Re,e[70]=Ce):Ce=e[70];let Ue;e[71]!==d?(Ue=()=>d(null),e[71]=d,e[72]=Ue):Ue=e[72];const He=c===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let qe;e[73]!==He?(qe=le("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",He),e[73]=He,e[74]=qe):qe=e[74];let Ke;e[75]!==r?(Ke=r("settings.projects.page.field.none"),e[75]=r,e[76]=Ke):Ke=e[76];let We;e[77]===Symbol.for("react.memo_cache_sentinel")?(We=t.jsx(R,{name:"close",className:"h-4 w-4 text-muted-foreground"}),e[77]=We):We=e[77];let tt;e[78]!==Ue||e[79]!==qe||e[80]!==Ke?(tt=t.jsx("button",{type:"button",onClick:Ue,className:qe,title:Ke,children:We}),e[78]=Ue,e[79]=qe,e[80]=Ke,e[81]=tt):tt=e[81];let ct;e[82]!==M||e[83]!==c||e[84]!==d?(ct=Ia.map(Pe=>{const Xe=Pe.Icon;return t.jsx("button",{type:"button",onClick:()=>d(Pe.key),className:le("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",c===Pe.key?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-transparent hover:border-border hover:bg-[var(--surface-muted)]"),title:Pe.label,children:t.jsx(R,{name:Xe,className:"w-4 h-4",style:M&&c===Pe.key?{color:M}:void 0})},Pe.key)}),e[82]=M,e[83]=c,e[84]=d,e[85]=ct):ct=e[85];let Be;e[86]!==tt||e[87]!==ct?(Be=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[tt,ct]}),e[86]=tt,e[87]=ct,e[88]=Be):Be=e[88];let Ye;e[89]!==ue||e[90]!==o||e[91]!==W||e[92]!==$||e[93]!==b||e[94]!==y||e[95]!==V||e[96]!==v||e[97]!==q||e[98]!==r?(Ye=W&&q&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"typography-meta text-muted-foreground",children:r("settings.projects.page.field.preview")}),t.jsx("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/60 bg-[var(--surface-elevated)] p-1",children:t.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]",style:b?{backgroundColor:b}:void 0,children:$&&y?t.jsx("img",{src:y,alt:"",className:"h-full w-full object-contain",draggable:!1,onError:()=>v(!0)}):t.jsx(Ca,{project:{...V,iconImage:ue??V.iconImage},options:{themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},className:"h-full w-full object-contain",onError:()=>v(!0)})})})]}),e[89]=ue,e[90]=o,e[91]=W,e[92]=$,e[93]=b,e[94]=y,e[95]=V,e[96]=v,e[97]=q,e[98]=r,e[99]=Ye):Ye=e[99];let Qe;e[100]!==W||e[101]!==b||e[102]!==m||e[103]!==r?(Qe=W&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("input",{type:"color",value:b??"#000000",onChange:Pe=>m(Pe.target.value),className:"h-7 w-9 cursor-pointer rounded border border-border bg-transparent p-1","aria-label":r("settings.projects.page.field.projectIconBackgroundAria")}),t.jsx(bt,{value:b??"",onChange:Pe=>m(Pe.target.value),placeholder:"#000000",className:"h-7 w-[8rem]"}),t.jsx(Ie,{type:"button",size:"xs",variant:"outline",onClick:()=>m(null),className:"h-7 w-7 p-0","aria-label":r("settings.projects.page.field.clearIconBackgroundAria"),title:r("settings.projects.page.field.clearBackground"),disabled:!b,children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})})]}),e[100]=W,e[101]=b,e[102]=m,e[103]=r,e[104]=Qe):Qe=e[104];let Je;e[105]!==se||e[106]!==ee||e[107]!==U||e[108]!==L||e[109]!==N||e[110]!==r?(Je=!U&&t.jsxs(t.Fragment,{children:[t.jsx(Ie,{size:"xs",className:"h-6 !font-normal",onClick:()=>se.current?.click(),disabled:N,children:r(N?"settings.projects.page.actions.uploading":"settings.projects.page.actions.uploadIcon")}),t.jsx(Ie,{size:"xs",className:"h-6 !font-normal",variant:"outline",onClick:()=>{ee()},disabled:L,children:r(L?"settings.projects.page.actions.discovering":"settings.projects.page.actions.discoverFavicon")})]}),e[105]=se,e[106]=ee,e[107]=U,e[108]=L,e[109]=N,e[110]=r,e[111]=Je):Je=e[111];let De;e[112]!==G||e[113]!==z||e[114]!==A||e[115]!==r?(De=z&&t.jsx(Ie,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>{G()},disabled:A,children:r(A?"settings.projects.page.actions.removing":"settings.projects.page.actions.removeProjectIcon")}),e[112]=G,e[113]=z,e[114]=A,e[115]=r,e[116]=De):De=e[116];let ot;e[117]!==A||e[118]!==I||e[119]!==T||e[120]!==r?(ot=I&&t.jsx(Ie,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>T(!1),disabled:A,children:r("settings.projects.page.actions.undoRemove")}),e[117]=A,e[118]=I,e[119]=T,e[120]=r,e[121]=ot):ot=e[121];let $e;e[122]!==Je||e[123]!==De||e[124]!==ot?($e=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Je,De,ot]}),e[122]=Je,e[123]=De,e[124]=ot,e[125]=$e):$e=e[125];let _e;e[126]!==ve||e[127]!==Ce||e[128]!==Be||e[129]!==Ye||e[130]!==Qe||e[131]!==$e?(_e=t.jsxs(Wt,{title:ve,settingsItem:"projects.icon",contentClassName:"space-y-3",children:[Ce,Be,Ye,Qe,$e]}),e[126]=ve,e[127]=Ce,e[128]=Be,e[129]=Ye,e[130]=Qe,e[131]=$e,e[132]=_e):_e=e[132];let st;return e[133]!==de||e[134]!==Fe||e[135]!==_e||e[136]!==ne?(st=t.jsxs(t.Fragment,{children:[ne,de,Fe,_e]}),e[133]=de,e[134]=Fe,e[135]=_e,e[136]=ne,e[137]=st):st=e[137],st};function Rc(s){return s.providers}function Ec(s){return t.jsx(ks,{value:s,children:fo(s)},s)}const Ac=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,Bc=s=>{if(!s)return null;const e=s.trim();return e&&Ac.test(e)?e.toLowerCase():null},Lc=s=>{const{t:e}=nt(),n=It(Z=>Z.uploadProjectIcon),r=It(Z=>Z.removeProjectIcon),o=It(Z=>Z.discoverProjectIcon),a=It(Z=>s?Z.projects.find(de=>de.id===s.id)?.iconImage??null:null),[i,l]=h.useState(""),[c,d]=h.useState(null),[u,f]=h.useState(null),[b,m]=h.useState(null),[x,g]=h.useState(void 0),[S,p]=h.useState(void 0),[N,A]=h.useState(!1),[L,I]=h.useState(!1),[T,y]=h.useState(!1),[v,$]=h.useState(!1),[U,W]=h.useState(null),[z,q]=h.useState(null),[se,J]=h.useState(!1),G=h.useRef(null),ee=h.useCallback(()=>{W(null),q(Z=>(Z&&URL.revokeObjectURL(Z),null))},[]),ue=s?.id??null;h.useEffect(()=>{if(!s){l(""),d(null),f(null),m(null),g(void 0),p(void 0);return}l(s.label??""),d(s.icon??null),f(s.color??null),m(s.iconBackground??null),g(s.defaultModel),p(s.defaultVariant),$(!1),ee(),J(!1)},[s,ee]),h.useEffect(()=>()=>{ee()},[ee]);const V=h.useMemo(()=>Lr(x)??{providerId:"",modelId:""},[x]),P=!!s?.iconImage,B=!!(U&&z),M=s?.iconImage?.source==="custom",D=P&&!v||B,_=D,E=!!(s&&P&&!v),K=!se&&(B||E),O=!!s&&(i.trim()!==(s?.label??"").trim()||c!==(s?.icon??null)||u!==(s?.color??null)||b!==(s?.iconBackground??null)||(x??void 0)!==(s?.defaultModel??void 0)||(S??void 0)!==(s?.defaultVariant??void 0)||v||!!U),ne=h.useCallback((Z,de)=>{g(Z&&de?`${Z}/${de}`:void 0),p(void 0)},[]),X=h.useCallback(Z=>{p(Z)},[]),te=h.useCallback(Z=>{!s||!Z||N||($(!1),J(!1),W(Z),q(de=>(de&&URL.revokeObjectURL(de),URL.createObjectURL(Z))))},[N,s]),ge=h.useCallback(()=>{!s||!_||L||(B&&ee(),$(!!P),J(!1))},[ee,B,_,P,L,s]),re=h.useCallback(async()=>{if(!(!s||T)){ee(),$(!1),J(!1),y(!0);try{const Z=await o(s.id);if(!Z.ok){Ne.error(Z.error||e("settings.projects.page.toast.discoverIconFailed"));return}if(Z.skipped){Ne.success(e("settings.projects.page.toast.customIconAlreadySet"));return}Ne.success(e("settings.projects.page.toast.iconDiscovered"))}finally{y(!1)}}},[ee,o,T,s,e]),pe=h.useCallback(async Z=>{const de=Z?.silent===!0;if(!s)return null;const me=i.trim();if(!me)return null;if(U){A(!0);const Y=await n(s.id,U);if(A(!1),!Y.ok)return Ne.error(Y.error||e("settings.projects.page.toast.uploadIconFailed")),null;de||Ne.success(e("settings.projects.page.toast.iconUpdated")),ee(),$(!1)}const j=v&&!!s.iconImage;if(j){I(!0);const Y=await r(s.id);if(I(!1),!Y.ok)return Ne.error(Y.error||e("settings.projects.page.toast.removeIconFailed")),null;de||Ne.success(e("settings.projects.page.toast.iconRemoved")),$(!1),m(null)}return{label:me,icon:c,color:u,iconBackground:Bc(j?null:b),defaultModel:x??null,defaultVariant:x?S??null:null}},[ee,u,x,S,c,b,i,v,U,s,r,e,n]);return h.useEffect(()=>{J(!1)},[ue,a?.updatedAt]),{name:i,setName:l,icon:c,setIcon:d,color:u,setColor:f,iconBackground:b,setIconBackground:m,defaultModel:x,defaultVariant:S,parsedDefaultModel:V,handleDefaultModelChange:ne,handleDefaultVariantChange:X,isUploadingIcon:N,isRemovingCustomIcon:L,isDiscoveringIcon:T,pendingRemoveImageIcon:v,setPendingRemoveImageIcon:$,pendingUploadIconFile:U,pendingUploadIconPreviewUrl:z,previewImageFailed:se,setPreviewImageFailed:J,hasStoredImageIcon:P,hasPendingUploadImageIcon:B,hasCustomIcon:M,effectiveHasImageIcon:D,hasRemovableImageIcon:_,showStoredImagePreview:E,showImagePreview:K,fileInputRef:G,clearPendingUploadIcon:ee,handleUploadIcon:te,handleRemoveImageIcon:ge,handleDiscoverIcon:re,hasChanges:O,prepareSaveData:pe,currentIconImage:a,project:s}},Mc=450,Fc=(s,e)=>{const{t:n}=nt(),{hasChanges:r,name:o,icon:a,color:i,iconBackground:l,defaultModel:c,pendingRemoveImageIcon:d,pendingUploadIconFile:u,isUploadingIcon:f,isRemovingCustomIcon:b,prepareSaveData:m}=s,x=h.useRef(!1);h.useEffect(()=>{if(!r||!o.trim()||f||b||x.current)return;const g=window.setTimeout(()=>{x.current||(x.current=!0,(async()=>{try{const S=await m({silent:!0});if(S)try{await e(S)}catch{Ne.error(n("settings.projects.page.toast.saveFailed"))}}finally{x.current=!1}})())},Mc);return()=>{window.clearTimeout(g)}},[i,c,r,a,l,b,f,o,e,d,u,m,n])},sm=s=>{const e=ze.c(16),{project:n,onIdentitySave:r,showWorktrees:o}=s,a=o===void 0?!0:o,i=Lc(n);let l;e:{if(!n){l=null;break e}let g;e[0]!==n.id||e[1]!==n.path?(g={id:n.id,path:n.path},e[0]=n.id,e[1]=n.path,e[2]=g):g=e[2],l=g}const c=l;let d;if(e[3]!==r?(d=async g=>{await r(g)},e[3]=r,e[4]=d):d=e[4],Fc(i,d),!n||!c)return null;let f;e[5]!==i?(f=t.jsx(Pc,{form:i}),e[5]=i,e[6]=f):f=e[6];let b;e[7]!==c?(b=t.jsx(Dc,{projectRef:c}),e[7]=c,e[8]=b):b=e[8];let m;e[9]!==c||e[10]!==a?(m=a?t.jsx(vc,{projectRef:c}):null,e[9]=c,e[10]=a,e[11]=m):m=e[11];let x;return e[12]!==f||e[13]!==b||e[14]!==m?(x=t.jsxs("div",{className:"space-y-0",children:[f,b,m]}),e[12]=f,e[13]=b,e[14]=m,e[15]=x):x=e[15],x},mo=()=>{const s=Ta();return{displayMode:s,installed:s!=="browser",browserTab:s==="browser"}},nm=()=>{const s=ze.c(2),[e,n]=h.useState(Oc);let r,o;return s[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const a=[window.matchMedia("(display-mode: standalone)"),window.matchMedia("(display-mode: minimal-ui)"),window.matchMedia("(display-mode: fullscreen)"),window.matchMedia("(display-mode: window-controls-overlay)")],i=()=>{n(mo())};i();for(const l of a)typeof l.addEventListener=="function"?l.addEventListener("change",i):typeof l.addListener=="function"&&l.addListener(i);return window.addEventListener("appinstalled",i),window.addEventListener("focus",i),()=>{for(const l of a)typeof l.removeEventListener=="function"?l.removeEventListener("change",i):typeof l.removeListener=="function"&&l.removeListener(i);window.removeEventListener("appinstalled",i),window.removeEventListener("focus",i)}},o=[],s[0]=r,s[1]=o):(r=s[0],o=s[1]),h.useEffect(r,o),e};function Oc(){return mo()}const $c=[{slug:"home",title:"Settings",group:"general",kind:"single",description:"Search and jump to common pages.",keywords:["search","settings"]},{slug:"general",title:"General",group:"general",kind:"single",keywords:["general","startup","launch at login","autostart","tray","password","passkey","security","privacy","telemetry","transport","network","lan","binary","cli"]},{slug:"projects",title:"Projects",group:"projects",kind:"split",keywords:["project","projects","worktree","worktrees","repo","repository","directory"]},{slug:"remote-instances",title:"Remote Instances",group:"projects",kind:"single",keywords:["ssh","remote","instances","tunnels","forwarding","connection"],isAvailable:s=>!s.isVSCode},{slug:"providers",title:"Providers",group:"opencode",kind:"split",keywords:["provider","providers","models","model","api key","api keys","openai","anthropic","ollama","credentials"]},{slug:"usage",title:"Usage",group:"general",kind:"split",keywords:["quota","billing","tokens","usage","limits"]},{slug:"agents",title:"Agents",group:"opencode",kind:"split",keywords:["agent","agents","prompts","tools","permissions"]},{slug:"behavior",title:"Behavior",group:"opencode",kind:"single",keywords:["behavior","agents.md","system prompt","global rules","instructions","override"]},{slug:"commands",title:"Commands",group:"opencode",kind:"split",keywords:["command","commands","slash","macros","automation"]},{slug:"mcp",title:"MCP",group:"opencode",kind:"split",keywords:["mcp","model context protocol","servers","tools","remote","stdio"]},{slug:"plugins",title:"Plugins",group:"opencode",kind:"split",keywords:["plugin","plugins","extensions","addons","npm","opencode-wakatime"]},{slug:"skills.installed",title:"Skills",group:"content",kind:"split",keywords:["skill","skills","instructions","install","catalog"]},{slug:"skills.catalog",title:"Skills Catalog",group:"content",kind:"single",keywords:["install","catalog","external","repository","skills catalog"]},{slug:"git",title:"Git",group:"projects",kind:"single",keywords:["git","identity","identities","ssh","profiles","credentials","keys","commit","gitmoji"],isAvailable:s=>!s.isVSCode},{slug:"appearance",title:"Appearance",group:"general",kind:"single",keywords:["theme","font","spacing","padding","corner radius","radius","input bar","keyboard","viewport","mobile","terminal","pwa","install name","app shortcuts"]},{slug:"chat",title:"Chat",group:"general",kind:"single",keywords:["tools","diff","reasoning","dotfiles","draft","queue","output","copy","image","split messages","message actions"]},{slug:"shortcuts",title:"Shortcuts",group:"general",kind:"single",keywords:["keyboard","hotkeys","shortcuts","bindings"],isAvailable:s=>!s.isVSCode},{slug:"sessions",title:"Sessions",group:"general",kind:"single",keywords:["defaults","default agent","default model","retention","memory","limits","zen"]},{slug:"magic-prompts",title:"Magic Prompts",group:"content",kind:"split",keywords:["prompts","templates","git","github","review","commit","pull request"],isAvailable:s=>!s.isVSCode},{slug:"snippets",title:"Snippets",group:"content",kind:"split",keywords:["prompt","templates","multi-run","strategy","approach"]},{slug:"notifications",title:"Notifications",group:"general",kind:"single",keywords:["alerts","native","summary","summarization"]},{slug:"voice",title:"Voice",group:"general",kind:"single",keywords:["tts","speech","voice"],isAvailable:s=>!s.isVSCode},{slug:"tunnel",title:"External Tunnel",group:"projects",kind:"single",keywords:["tunnel","external","cloudflare","qr","remote","mobile","share"],isAvailable:s=>!s.isVSCode},{slug:"about",title:"About",group:"general",kind:"single",keywords:["about","version","updates","release","changelog"],isAvailable:s=>s.isMobile&&!s.isVSCode},{slug:"integrations",title:"Integrations",group:"general",kind:"single",keywords:["integration","connect","oauth","github","linear"],isAvailable:s=>!s.isVSCode}],Uc={sessions:"sessions",agents:"agents",commands:"commands",mcp:"mcp",skills:"skills.installed",providers:"providers",usage:"usage","git-identities":"git",settings:"home"};function Wc(s){const e=s.trim().toLowerCase();return $c.find(n=>n.slug===e)??null}function _c(s){const e=(s??"").trim().toLowerCase();if(!e)return"home";const n=Uc[e];if(n)return n;const r=Wc(e);return r?r.slug:"home"}function rm(s){switch(s){case"general":return"settings-3";case"projects":return"folders";case"remote-instances":return"computer";case"appearance":return"palette";case"chat":return"chat-ai-3";case"magic-prompts":return"ai-generate-2";case"snippets":return"chat-thread";case"notifications":return"notification-3";case"shortcuts":return"command";case"sessions":return"chat-history";case"providers":return"cloud";case"agents":return"ai-agent";case"behavior":return"brain";case"commands":return"slash-commands-2";case"mcp":return null;case"plugins":return"plug-2";case"skills.installed":return"book-open";case"skills.catalog":return"book";case"git":return"git-branch";case"integrations":return"plug";case"usage":return"bar-chart-2";case"voice":return"mic";case"tunnel":return"home-office";case"about":return"information";case"home":return null;default:return"robot-2"}}const Vc=["chat","git","diff","terminal","files"],zc=["settings","agents","commands","skills","providers","usage","git-identities"],Lt={SESSION:"session",TAB:"tab",SETTINGS:"settings",FILE:"file"};function cr(s){const e=Gc();return{sessionId:Hc(e),tab:Kc(e),settingsPath:qc(e),diffFile:Yc(e)}}function Gc(){if(typeof window>"u")return new URLSearchParams;try{return new URLSearchParams(window.location.search)}catch{return new URLSearchParams}}function Hc(s){const e=s.get(Lt.SESSION);return!e||e.trim().length===0?null:e.trim()}function Kc(s){const e=s.get(Lt.TAB);if(!e)return null;const n=e.toLowerCase().trim();return Vc.includes(n)?n:null}function qc(s){const e=s.get(Lt.SETTINGS);if(!e)return null;const n=e.toLowerCase().trim();return n.length===0?null:n==="openchamber"||n==="general"||n==="preferences"?"home":(zc.includes(n),n)}function Yc(s){const e=s.get(Lt.FILE);if(!e||e.trim().length===0)return null;try{return decodeURIComponent(e.trim())}catch{return e.trim()}}function dr(){if(typeof window>"u")return!1;try{const s=new URLSearchParams(window.location.search);return s.has(Lt.SESSION)||s.has(Lt.TAB)||s.has(Lt.SETTINGS)||s.has(Lt.FILE)}catch{return!1}}function ho(s){const e=new URLSearchParams;if(s.sessionId&&s.sessionId.trim().length>0&&e.set(Lt.SESSION,s.sessionId),s.isSettingsOpen){const n=s.settingsPath.trim().length>0?s.settingsPath:"home";return e.set(Lt.SETTINGS,n),e}return e}function Jc(s,e){const n=typeof window<"u"?window.location.pathname:"/",r=s.toString();return r?`${n}?${r}`:n}function Qc(s){if(typeof window>"u")return!0;try{const e=new URLSearchParams(window.location.search),n=ho(s),r=[...e.entries()].sort((a,i)=>a[0].localeCompare(i[0])),o=[...n.entries()].sort((a,i)=>a[0].localeCompare(i[0]));if(r.length!==o.length)return!1;for(let a=0;a<r.length;a++)if(r[a][0]!==o[a][0]||r[a][1]!==o[a][1])return!1;return!0}catch{return!0}}function ur(s,e={}){if(!(typeof window>"u")&&!(Xc()||Jr())&&!(!e.force&&Qc(s)))try{const n=ho(s),r=Jc(n);e.replace?window.history.replaceState({...window.history.state,route:s},"",r):window.history.pushState({route:s},"",r)}catch{}}function Xc(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}async function Zc(s){const e=s.trim();if(!e)return;const n=it.getState();n.currentSessionId!==e&&n.setCurrentSession(e,n.getDirectoryForSession(e));const r=await Da().catch(()=>null);if(!r)return;const o=it.getState();if(o.currentSessionId!==e)return;const a=[...r.activeSessions,...r.archivedSessions].find(l=>l.id===e);if(!a)return;const i=Mr(a);!i||i===o.currentSessionDirectory||o.setCurrentSession(e,i)}function ed(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}function om(){const s=h.useMemo(()=>ed(),[]),e=h.useMemo(()=>Jr(),[]),n=h.useRef(!1),r=h.useRef(!1),o=Ve(u=>u.setSettingsDialogOpen),a=Ve(u=>u.setSettingsPage),i=Ve(u=>u.navigateToDiff),l=h.useCallback(async u=>{if(!r.current){r.current=!0;try{if(u.sessionId&&await Zc(u.sessionId),u.settingsPath){a(_c(u.settingsPath)),o(!0);return}if(Ve.getState().isSettingsDialogOpen&&o(!1),u.tab&&u.tab!=="chat"){const f=bs.getState().currentDirectory;if(f){const b=u.tab==="files"?"file":u.tab;Ve.getState().openContextSurface(f,b)}}u.diffFile&&(u.tab==="diff"||!u.tab)&&i(u.diffFile)}finally{r.current=!1}}},[o,a,i]),c=h.useCallback(()=>{const u=it.getState(),f=Ve.getState();return{sessionId:u.currentSessionId,isSettingsOpen:f.isSettingsDialogOpen,settingsPath:f.settingsPage}},[]),d=h.useCallback((u={})=>{if(s||e||r.current)return;const f=c();ur(f,u)},[s,e,c]);h.useEffect(()=>{if(n.current||(n.current=!0,!dr()))return;const u=cr();(async()=>(await l(u),!s&&!e&&ur({...c(),sessionId:u.sessionId??it.getState().currentSessionId,settingsPath:u.settingsPath??Ve.getState().settingsPage},{replace:!0,force:!0})))()},[l,c,s,e]),h.useEffect(()=>{if(s||e)return;let u=it.getState().currentSessionId;return it.subscribe(b=>{const m=b.currentSessionId;m===u||r.current||(u=m,d())})},[s,e,d]),h.useEffect(()=>{if(s||e)return;let u=Ve.getState().isSettingsDialogOpen,f=Ve.getState().settingsPage;return Ve.subscribe(m=>{if(r.current)return;const x=m.isSettingsDialogOpen!==u,g=m.settingsPage!==f;u=m.isSettingsDialogOpen,f=m.settingsPage,(x||g)&&d()})},[s,e,d]),h.useEffect(()=>{if(typeof window>"u"||s||e)return;const u=()=>{const f=cr();dr()?l(f):Ve.getState().isSettingsDialogOpen&&o(!1)};return window.addEventListener("popstate",u),()=>{window.removeEventListener("popstate",u)}},[l,s,e,o])}function am(){const s=ze.c(5),e=kl(sd),n=h.useRef(e);let r,o;s[0]!==e?(r=()=>{n.current=e},o=[e],s[0]=e,s[1]=r,s[2]=o):(r=s[1],o=s[2]),h.useEffect(r,o);let a,i;s[3]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{let l=!1,c=null;const d=td,u=f=>{l||(c=window.setTimeout(async()=>{const b=await n.current(),m=typeof b=="number"&&Number.isFinite(b)?d(b):36e5;u(m)},f))};return u(3e3),()=>{l=!0,c!==null&&window.clearTimeout(c)}},i=[],s[3]=a,s[4]=i):(a=s[3],i=s[4]),h.useEffect(a,i)}function td(s){const e=Math.round(s*1e3);return Math.max(3e5,Math.min(864e5,e))}function sd(s){return s.checkForUpdates}const Cn=1e3,Ss=60*Cn,nn=60*Ss,nd=(s,e)=>{const n=Math.max(0,s);return n<Ss?e("common.duration.secondsCompact",{seconds:Math.floor(n/Cn)}):n<nn?e("common.duration.minutesSecondsCompact",{minutes:Math.floor(n/Ss),seconds:Math.floor(n%Ss/Cn)}):e("common.duration.hoursMinutesCompact",{hours:Math.floor(n/nn),minutes:Math.floor(n%nn/Ss)})},rd=1e3,im=s=>{const e=ze.c(12),{sessionId:n,running:r,className:o}=s,{t:a}=nt(),i=Pa(n),l=Ra(n),c=Ea(r,rd),d=r?Math.max(0,c-(i??c)):l;if(d===void 0)return null;let u,f;e[0]!==d||e[1]!==r||e[2]!==a?(u=nd(d,a),f=r?a("sessions.sidebar.session.status.activeFor",{duration:u}):a("sessions.sidebar.session.status.lastTurnDuration",{duration:u}),e[0]=d,e[1]=r,e[2]=a,e[3]=u,e[4]=f):(u=e[3],f=e[4]);const b=f,m=r?"text-primary":"text-[var(--status-info)]";let x;e[5]!==o||e[6]!==m?(x=le("shrink-0 tabular-nums",m,o),e[5]=o,e[6]=m,e[7]=x):x=e[7];let g;return e[8]!==b||e[9]!==u||e[10]!==x?(g=t.jsx("span",{className:x,"aria-label":b,title:b,children:u}),e[8]=b,e[9]=u,e[10]=x,e[11]=g):g=e[11],g},od=()=>{const s=ze.c(14),[e,n]=ce.useState(!1),[r,o]=ce.useState(!1);let a,i;s[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{n(Hr()),o(Mi())},i=[],s[0]=a,s[1]=i):(a=s[0],i=s[1]),ce.useEffect(a,i);let l;s[2]!==e?(l=async x=>e?await Fi(x):{success:!0,path:x},s[2]=e,s[3]=l):l=s[3];const c=l;let d;s[4]!==e?(d=async x=>e?await Oi():{success:!0},s[4]=e,s[5]=d):d=s[5];const u=d;let f;s[6]!==e?(f=async x=>e?await $i():{success:!0},s[6]=e,s[7]=f):f=s[7];const b=f;let m;return s[8]!==r||s[9]!==e||s[10]!==c||s[11]!==u||s[12]!==b?(m={isDesktop:e,canRequestAccess:r,requestAccess:c,startAccessing:u,stopAccessing:b},s[8]=r,s[9]=e,s[10]=c,s[11]=u,s[12]=b,s[13]=m):m=s[13],m},po="openchamber:recent-git-branches:v1",go=5,ad=rl(Yn(),ol(Yn())),xo=s=>{const e=zs(s);return e?`${Ws()}:${e}`:null},bo=()=>{try{const s=localStorage.getItem(po),e=ad.safeParse(s?JSON.parse(s):null);return e.success?Object.fromEntries(Object.entries(e.data).map(([n,r])=>[n,r.slice(0,go)])):{}}catch{return{}}},fr=s=>{const e=xo(s);return e?bo()[e]??[]:[]},mr=(s,e)=>{const n=xo(s);if(!n||!e)return[];const r=bo(),o=[e,...(r[n]??[]).filter(a=>a!==e)].slice(0,go);try{localStorage.setItem(po,JSON.stringify({...r,[n]:o}))}catch{}return o},id=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),ld=({currentBranch:s,localBranches:e,remoteBranches:n,branchInfo:r,currentBranchAhead:o=0,onCheckout:a,onCreate:i,remotes:l=[],disabled:c=!1,directory:d,switchBlockedNotice:u=null})=>{const{t:f}=nt(),{isMobile:b}=xs(),[m,x]=h.useState(!1),[g,S]=h.useState(""),[p,N]=h.useState(!1),[A,L]=h.useState(!1),[I,T]=h.useState(""),[y,v]=h.useState(!1),[$,U]=h.useState(()=>fr(d)),[W,z]=h.useState({}),q=h.useRef(null),se=h.useCallback(E=>{E.stopPropagation()},[]),J=l.length>1,G=h.useMemo(()=>id(I),[I]),ee=h.useMemo(()=>gn(e,g,E=>[E]),[g,e]),ue=h.useMemo(()=>gn(n,g,E=>[E]),[g,n]),V=E=>{if(E===s){x(!1);return}U(mr(d,E)),a(E),x(!1),S("")},P=()=>{N(!0),setTimeout(()=>q.current?.focus(),50)},B=async()=>{if(!(!G||y)){if(J){L(!0);return}v(!0);try{await i(G,l[0]),T(""),N(!1),x(!1)}finally{v(!1)}}},M=async E=>{if(!(!G||y)){v(!0);try{await i(G,E),T(""),N(!1),L(!1),x(!1)}finally{v(!1)}}},D=()=>{L(!1)},_=()=>{T(""),N(!1),L(!1)};if(h.useEffect(()=>{m||(S(""),N(!1),L(!1),T(""))},[m]),h.useEffect(()=>{d&&U(s?mr(d,s):fr(d))},[s,d]),h.useEffect(()=>{if(!m)return;const E=$.filter(O=>e.includes(O)).slice(0,5);if(E.length===0)return z({});let K=!1;return Aa(d,E).then(({counts:O})=>{K||z(O)}).catch(()=>{K||z({})}),()=>{K=!0}},[d,m,e,$]),b){const E=$.filter(O=>e.includes(O)),K=(O,ne=!1)=>{const X=W[O]??(O===s?o:0),te=X===1?f("gitView.branch.unpushedSingle"):f("gitView.branch.unpushedPlural",{count:X});return t.jsxs("button",{type:"button",onClick:()=>V(O),className:"flex w-full items-center gap-2 rounded-lg px-2 py-2.5 text-left typography-ui-label hover:bg-interactive-hover",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate",children:O}),X>0?t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-muted-foreground",title:te,"aria-label":te,children:[t.jsx(R,{name:"arrow-up",className:"size-3","aria-hidden":"true"}),t.jsx("span",{"aria-hidden":"true",children:X})]}):null,s===O?t.jsx(R,{name:"check",className:"size-4 shrink-0 text-primary"}):null]},`${ne?"remote":"local"}-${O}`)};return t.jsxs(t.Fragment,{children:[t.jsxs(Ie,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-full justify-start gap-1.5 px-2 py-1",disabled:c,onClick:()=>x(!0),children:[t.jsx(R,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("span",{className:"min-w-0 truncate font-medium text-left",children:s||f("gitView.branch.detachedHead")}),t.jsx(R,{name:"arrow-down-s",className:"size-4 opacity-60"})]}),t.jsx(fs,{open:m,title:f("gitView.branch.currentBranchTooltip"),onClose:()=>x(!1),children:t.jsxs("div",{className:"flex flex-col gap-2 px-3 pb-4 pt-1",children:[t.jsx("input",{autoFocus:!0,value:g,onChange:O=>S(O.target.value),placeholder:f("gitView.branch.searchPlaceholder"),className:"h-9 w-full rounded-lg border border-border bg-transparent px-3 typography-meta outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-primary"}),u?t.jsxs("div",{className:"flex items-start gap-2 px-2 py-1",children:[t.jsx(R,{name:"alert",className:"mt-0.5 size-3.5 shrink-0 text-[var(--status-warning)]","aria-hidden":"true"}),t.jsx("span",{className:"typography-micro text-muted-foreground",children:u})]}):null,E.length>0?t.jsxs("section",{children:[t.jsx("p",{className:"px-2 pb-1 pt-2 typography-meta text-muted-foreground",children:f("gitView.branch.recentBranches")}),E.map(O=>K(O))]}):null,t.jsxs("section",{children:[t.jsx("p",{className:"px-2 pb-1 pt-2 typography-meta text-muted-foreground",children:f("gitView.branch.localBranches")}),ee.map(O=>K(O))]}),t.jsxs("section",{children:[t.jsx("p",{className:"px-2 pb-1 pt-2 typography-meta text-muted-foreground",children:f("gitView.branch.remoteBranches")}),ue.map(O=>K(O,!0))]})]})})]})}return t.jsxs(zt,{open:m,onOpenChange:x,children:[t.jsxs(hs,{children:[t.jsx(ps,{asChild:!0,children:t.jsx(Gt,{asChild:!0,children:t.jsxs(Ie,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-full justify-start gap-1.5 px-2 py-1",disabled:c,children:[t.jsx(R,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("span",{className:"min-w-0 truncate font-medium text-left",children:s||f("gitView.branch.detachedHead")}),t.jsx(R,{name:"arrow-down-s",className:"size-4 opacity-60"})]})})}),t.jsx(gs,{sideOffset:8,children:f("gitView.branch.currentBranchTooltip")})]}),t.jsx(Ht,{align:"start",className:"w-72 p-0 max-h-[60vh] flex flex-col",children:t.jsxs(xn,{className:"h-full min-h-0",shouldFilter:!1,children:[t.jsx(bn,{placeholder:f("gitView.branch.searchPlaceholder"),value:g,onValueChange:S,onKeyDown:se}),u?t.jsxs("div",{className:"flex items-start gap-2 border-b border-border/60 px-3 py-2",children:[t.jsx(R,{name:"alert",className:"mt-0.5 size-3.5 shrink-0 text-[var(--status-warning)]","aria-hidden":"true"}),t.jsx("span",{className:"typography-micro text-muted-foreground",children:u})]}):null,t.jsxs(yn,{scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx(wn,{children:f("gitView.branch.empty")}),t.jsx(At,{children:A?t.jsxs("div",{className:"px-2 py-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("button",{type:"button",onClick:D,disabled:y,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(R,{name:"arrow-left",className:"size-4"})}),t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[f("gitView.branch.pushToPrefix")," ",t.jsx("span",{className:"text-foreground font-medium",children:G})," ",f("gitView.branch.pushToSuffix")]})]}),t.jsx("div",{className:"flex flex-col gap-1",children:l.map(E=>t.jsxs("button",{type:"button",onClick:()=>M(E),disabled:y,className:"flex flex-col items-start gap-0.5 px-2 py-1.5 rounded-md text-left hover:bg-accent disabled:opacity-50",children:[t.jsxs("span",{className:"typography-ui-label text-foreground",children:[y?t.jsx(R,{name:"loader-4",className:"inline size-3 mr-1.5 animate-spin"}):null,E.name]}),t.jsx("span",{className:"typography-micro text-muted-foreground truncate max-w-full",children:E.pushUrl})]},E.name))})]}):p?t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg",children:[t.jsx("input",{ref:q,placeholder:f("gitView.branch.newBranchPlaceholder"),value:I,onChange:E=>T(E.target.value),onClick:E=>E.stopPropagation(),onKeyDown:E=>{se(E),E.key==="Enter"?(E.preventDefault(),B()):E.key==="Escape"&&(E.preventDefault(),_())},className:"flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground"}),t.jsx("button",{type:"button",onClick:B,disabled:!G||y,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:y?t.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(R,{name:"add",className:"size-4"})}),t.jsx("button",{type:"button",onClick:_,disabled:y,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(R,{name:"close",className:"size-4"})})]}):t.jsxs(Dt,{onSelect:P,children:[t.jsx(R,{name:"add",className:"size-4"}),t.jsx("span",{children:f("gitView.branch.create")})]})}),t.jsx(Ns,{}),$.filter(E=>e.includes(E)).length>0?t.jsxs(t.Fragment,{children:[t.jsx(At,{heading:f("gitView.branch.recentBranches"),children:$.filter(E=>e.includes(E)).map(E=>t.jsxs(Dt,{onSelect:()=>V(E),children:[t.jsxs("span",{className:"flex flex-1 items-center gap-2 min-w-0",children:[t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:E}),(()=>{const K=W[E]??(E===s?o:0),O=K===1?f("gitView.branch.unpushedSingle"):f("gitView.branch.unpushedPlural",{count:K});return K>0?t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full px-1.5 py-0.5 typography-micro text-muted-foreground",title:O,"aria-label":O,children:[t.jsx(R,{name:"arrow-up",className:"size-3","aria-hidden":"true"}),t.jsx("span",{"aria-hidden":"true",children:K})]}):null})()]}),s===E?t.jsx("span",{className:"typography-micro text-primary",children:f("gitView.branch.currentBadge")}):null]},`recent-${E}`))}),t.jsx(Ns,{})]}):null,t.jsxs(At,{heading:f("gitView.branch.localBranches"),children:[ee.map(E=>t.jsxs(Dt,{onSelect:()=>V(E),children:[t.jsxs("span",{className:"flex flex-1 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:E}),(r?.[E]?.ahead||r?.[E]?.behind)&&t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[r[E].ahead||0," ahead ·"," ",r[E].behind||0," behind"]})]}),s===E&&t.jsx("span",{className:"typography-micro text-primary",children:f("gitView.branch.currentBadge")})]},`local-${E}`)),ee.length===0&&t.jsx(Dt,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:f("gitView.branch.noLocalBranches")})})]}),t.jsx(Ns,{}),t.jsxs(At,{heading:f("gitView.branch.remoteBranches"),children:[ue.map(E=>t.jsx(Dt,{onSelect:()=>V(E),children:t.jsx("span",{className:"typography-ui-label text-foreground",children:E})},`remote-${E}`)),ue.length===0&&t.jsx(Dt,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:f("gitView.branch.noRemoteBranches")})})]})]})]})})]})},cd=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),dd=({currentBranch:s,onRename:e,showEditButton:n=!0})=>{const{t:r}=nt(),[o,a]=h.useState(!1),[i,l]=h.useState(s||""),[c,d]=h.useState(!1),u=h.useRef(null),f=()=>{!s||!e||(l(s),a(!0),setTimeout(()=>u.current?.focus(),0))},b=async()=>{if(!s||!e||!i.trim())return;const g=cd(i);if(g===s){a(!1);return}d(!0);try{await e(s,g),a(!1),l("")}finally{d(!1)}},m=()=>{a(!1),l("")},x=g=>{g.key==="Enter"?(g.preventDefault(),b()):g.key==="Escape"&&(g.preventDefault(),m())};return o?t.jsx("div",{className:"flex items-center gap-2 rounded-md bg-primary/12 px-2 py-1 h-8",children:t.jsxs("form",{className:"flex w-full items-center gap-2",onSubmit:g=>{g.preventDefault(),b()},children:[t.jsx(R,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("input",{ref:u,value:i,onChange:g=>l(g.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",placeholder:r("gitView.branch.namePlaceholder"),onKeyDown:x,autoFocus:!0}),t.jsx("button",{type:"submit",disabled:c,"aria-label":r(c?"gitView.branch.renameSaving":"gitView.branch.renameSave"),title:r(c?"gitView.branch.renameSaving":"gitView.branch.renameSave"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:c?t.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(R,{name:"check",className:"size-4"})}),t.jsx("button",{type:"button",onClick:m,disabled:c,"aria-label":r("gitView.branch.renameCancel"),title:r("gitView.branch.renameCancel"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(R,{name:"close",className:"size-4"})})]})}):t.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1.5 px-2 py-1 h-8",children:[t.jsx(R,{name:"git-branch",className:"size-4 text-primary shrink-0"}),t.jsxs("div",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[t.jsx("span",{className:"truncate typography-ui-label font-normal text-foreground",children:s||r("gitView.branch.detachedHead")}),n&&e&&s&&t.jsx(Ie,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:f,title:r("gitView.branch.renameTitle"),children:t.jsx(R,{name:"edit",className:"size-4"})})]})]})},ud=s=>{const e=ze.c(44),{syncAction:n,remotes:r,onFetch:o,onSync:a,onRemoveRemote:i,disabled:l,removingRemoteName:c,aheadCount:d,behindCount:u,trackingRemoteName:f,hasUncommittedChanges:b}=s,m=r===void 0?[]:r,x=c===void 0?null:c,g=d===void 0?0:d,S=u===void 0?0:u,p=b===void 0?!1:b,{t:N}=nt(),A=h.useRef(!1),L=!!x,I=m.find(ae=>ae.name===f)??m[0],T=S>0&&p,y=l||n!==null||L||!I||T,v=l||n!==null||L||m.length===0,$=g>0||S>0;let U;e[0]!==N?(U=N("gitView.sync.sync"),e[0]=N,e[1]=U):U=e[1];const W=S>0?`↓${S}`:null,z=g>0?`↑${g}`:null;let q;e[2]!==U||e[3]!==W||e[4]!==z?(q=[U,W,z].filter(Boolean),e[2]=U,e[3]=W,e[4]=z,e[5]=q):q=e[5];const se=q.join(" "),J=T?N("gitView.sync.commitOrStashTooltip"):I?$?N("gitView.sync.syncChangesTooltip",{ahead:g,behind:S}):N("gitView.sync.syncChanges"):N("gitView.sync.noRemoteTooltip"),G=()=>{I&&a(I)},ee="inline-flex items-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] border border-border/60 bg-[var(--surface-elevated)] overflow-hidden",ue=T?0:void 0;let V;e[6]===Symbol.for("react.memo_cache_sentinel")?(V=le("inline-flex h-7 items-center gap-1.5 px-2 typography-ui-label font-medium text-foreground","transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50"),e[6]=V):V=e[6];let P;e[7]!==N?(P=N("gitView.sync.syncChanges"),e[7]=N,e[8]=P):P=e[8];let B;e[9]!==n?(B=n==="sync"?t.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(R,{name:"refresh",className:"size-4"}),e[9]=n,e[10]=B):B=e[10];let M;e[11]!==se?(M=t.jsx("span",{className:"whitespace-nowrap tabular-nums",children:se}),e[11]=se,e[12]=M):M=e[12];let D;e[13]!==G||e[14]!==y||e[15]!==P||e[16]!==B||e[17]!==M?(D=t.jsxs("button",{type:"button",onClick:G,disabled:y,className:V,"aria-label":P,children:[B,M]}),e[13]=G,e[14]=y,e[15]=P,e[16]=B,e[17]=M,e[18]=D):D=e[18];let _;e[19]!==ue||e[20]!==D?(_=t.jsx(ps,{asChild:!0,children:t.jsx("span",{className:"inline-flex",tabIndex:ue,children:D})}),e[19]=ue,e[20]=D,e[21]=_):_=e[21];let E;e[22]!==J?(E=t.jsx(gs,{sideOffset:8,children:J}),e[22]=J,e[23]=E):E=e[23];let K;e[24]!==_||e[25]!==E?(K=t.jsxs(hs,{children:[_,E]}),e[24]=_,e[25]=E,e[26]=K):K=e[26];const O=zt;let ne;e[27]===Symbol.for("react.memo_cache_sentinel")?(ne=le("inline-flex h-7 w-6 items-center justify-center border-l border-[var(--interactive-border)] text-muted-foreground","transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50"),e[27]=ne):ne=e[27];let X;e[28]!==N?(X=N("gitView.sync.moreActionsAria"),e[28]=N,e[29]=X):X=e[29];let te;e[30]===Symbol.for("react.memo_cache_sentinel")?(te=t.jsx(R,{name:"arrow-down-s",className:"size-4"}),e[30]=te):te=e[30];let ge;e[31]!==v||e[32]!==X?(ge=t.jsx(Gt,{asChild:!0,children:t.jsx("button",{type:"button",className:ne,disabled:v,"aria-label":X,children:te})}),e[31]=v,e[32]=X,e[33]=ge):ge=e[33];const re=Ht,pe="start",Z=-40,de="w-[min(360px,calc(100vw-2rem))] max-h-[320px] overflow-y-auto",me=m.map(ae=>t.jsx(Bt,{onSelect:he=>{if(A.current){he.preventDefault(),A.current=!1;return}o(ae)},children:t.jsxs("div",{className:"flex w-full items-center gap-2",children:[t.jsx(R,{name:"refresh",className:"size-4 text-muted-foreground"}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:N("gitView.sync.fetchFromRemote",{name:ae.name})}),t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:ae.fetchUrl})]})}),i&&ae.name!==f?t.jsx(Ie,{type:"button",variant:"destructive",size:"xs",className:"h-6 w-6 px-0",disabled:n!==null||L,onPointerDown:he=>{A.current=!0,he.preventDefault(),he.stopPropagation()},onClick:he=>{A.current=!0,he.preventDefault(),he.stopPropagation(),i(ae)},"aria-label":N("gitView.header.removeRemoteAria",{name:ae.name}),title:N("gitView.header.removeRemoteTitle",{name:ae.name}),children:x===ae.name?t.jsx(R,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(R,{name:"close",className:"size-3.5"})}):null]})},ae.name));let j;e[34]!==re||e[35]!==me?(j=t.jsx(re,{align:pe,alignOffset:Z,className:de,children:me}),e[34]=re,e[35]=me,e[36]=j):j=e[36];let Y;e[37]!==O||e[38]!==ge||e[39]!==j?(Y=t.jsxs(O,{children:[ge,j]}),e[37]=O,e[38]=ge,e[39]=j,e[40]=Y):Y=e[40];let F;return e[41]!==K||e[42]!==Y?(F=t.jsxs("div",{className:ee,children:[K,Y]}),e[41]=K,e[42]=Y,e[43]=F):F=e[43],F},fd=s=>{const e=ze.c(27),{repositories:n,selectedRepository:r,onSelectRepository:o,repositoryRoot:a}=s,{t:i}=nt();let l;e[0]!==a?(l=A=>{const L=`${a??""}/`;return A.startsWith(L)?A.slice(L.length):A},e[0]=a,e[1]=l):l=e[1];const c=l,d=r??void 0;let u;e[2]!==o?(u=A=>{A&&o(A)},e[2]=o,e[3]=u):u=e[3];let f;e[4]!==i?(f=i("gitView.empty.selectRepositoryPlaceholder"),e[4]=i,e[5]=f):f=e[5];let b;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(R,{name:"folder-3",className:"size-4 text-muted-foreground"}),e[6]=b):b=e[6];let m;e[7]!==c||e[8]!==r?(m=r?c(r):"",e[7]=c,e[8]=r,e[9]=m):m=e[9];let x;e[10]!==m?(x=t.jsx("span",{className:"min-w-0 truncate font-medium text-left",children:m}),e[10]=m,e[11]=x):x=e[11];let g;e[12]!==f||e[13]!==x?(g=t.jsxs(Rn,{size:"sm",className:"max-w-[13rem] gap-1.5 px-2 py-1","aria-label":f,children:[b,x]}),e[12]=f,e[13]=x,e[14]=g):g=e[14];let S;if(e[15]!==c||e[16]!==n){let A;e[18]!==c?(A=L=>t.jsx(ks,{value:L,children:t.jsx("span",{className:"truncate",children:c(L)})},L),e[18]=c,e[19]=A):A=e[19],S=n.map(A),e[15]=c,e[16]=n,e[17]=S}else S=e[17];let p;e[20]!==S?(p=t.jsx(En,{align:"start",children:S}),e[20]=S,e[21]=p):p=e[21];let N;return e[22]!==p||e[23]!==d||e[24]!==u||e[25]!==g?(N=t.jsxs(Pn,{value:d,onValueChange:u,children:[g,p]}),e[22]=p,e[23]=d,e[24]=u,e[25]=g,e[26]=N):N=e[26],N},md={branch:"git-branch",briefcase:"briefcase",house:"home",graduation:"graduation-cap",code:"code",heart:"heart",user:"user-3",fingerprint:"fingerprint"},hd={keyword:"var(--syntax-keyword)",error:"var(--status-error)",string:"var(--syntax-string)",function:"var(--syntax-function)",type:"var(--syntax-type)",success:"var(--status-success)",info:"var(--status-info)",warning:"var(--status-warning)"};function yo(s){return s&&hd[s]||"var(--primary)"}const hr=s=>{const e=ze.c(8),{icon:n,className:r,colorToken:o}=s,a=md[n??"branch"]??"user-3";let i;e[0]!==o?(i=yo(o),e[0]=o,e[1]=i):i=e[1];let l;e[2]!==i?(l={color:i},e[2]=i,e[3]=l):l=e[3];let c;return e[4]!==r||e[5]!==a||e[6]!==l?(c=t.jsx(R,{name:a,className:r,style:l}),e[4]=r,e[5]=a,e[6]=l,e[7]=c):c=e[7],c},wo=s=>{const e=ze.c(35),{activeProfile:n,identities:r,onSelect:o,isApplying:a,iconOnly:i}=s,l=i===void 0?!1:i,{t:c}=nt(),d=a||r.length===0,u=n?.color;let f;e[0]!==u?(f=yo(u),e[0]=u,e[1]=f):f=e[1];let b;e[2]!==f?(b={color:f},e[2]=f,e[3]=b):b=e[3];let m;e[4]!==n?.color||e[5]!==n?.icon||e[6]!==a?(m=a?t.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(hr,{icon:n?.icon,colorToken:n?.color,className:"size-4"}),e[4]=n?.color,e[5]=n?.icon,e[6]=a,e[7]=m):m=e[7];let x;e[8]!==n?.name||e[9]!==l||e[10]!==c?(x=!l&&t.jsx("span",{className:"git-identity-label min-w-0 flex-1 truncate text-left",children:n?.name||c("gitView.header.noIdentity")}),e[8]=n?.name,e[9]=l,e[10]=c,e[11]=x):x=e[11];let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(R,{name:"arrow-down-s",className:"size-4 opacity-60"}),e[12]=g):g=e[12];let S;e[13]!==d||e[14]!==b||e[15]!==m||e[16]!==x?(S=t.jsx(ps,{asChild:!0,children:t.jsx(Gt,{asChild:!0,children:t.jsxs(Ie,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-[15rem] justify-start gap-1.5 px-2 py-1 typography-ui-label",style:b,disabled:d,children:[m,x,g]})})}),e[13]=d,e[14]=b,e[15]=m,e[16]=x,e[17]=S):S=e[17];let p;e[18]!==c?(p=c("gitView.header.identityTooltip"),e[18]=c,e[19]=p):p=e[19];let N;e[20]!==p?(N=t.jsx(gs,{sideOffset:8,children:p}),e[20]=p,e[21]=N):N=e[21];let A;e[22]!==N||e[23]!==S?(A=t.jsxs(hs,{children:[S,N]}),e[22]=N,e[23]=S,e[24]=A):A=e[24];let L;e[25]!==n?.id||e[26]!==r||e[27]!==o||e[28]!==c?(L=r.length===0?t.jsx("div",{className:"px-2 py-1.5",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:c("gitView.header.noProfiles")})}):r.map(y=>{const v=n?.id===y.id;return t.jsx(Bt,{onSelect:()=>o(y),children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(hr,{icon:y.icon,colorToken:y.color,className:"size-4"}),t.jsxs("span",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:y.name}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:y.userEmail})]}),v?t.jsx(R,{name:"check",className:"ml-auto size-4 text-foreground"}):null]})},y.id)}),e[25]=n?.id,e[26]=r,e[27]=o,e[28]=c,e[29]=L):L=e[29];let I;e[30]!==L?(I=t.jsx(Ht,{align:"end",className:"w-64",children:L}),e[30]=L,e[31]=I):I=e[31];let T;return e[32]!==A||e[33]!==I?(T=t.jsxs(zt,{children:[A,I]}),e[32]=A,e[33]=I,e[34]=T):T=e[34],T},pd=s=>{const e=ze.c(21),{comparison:n,trackingBranch:r,tooltipDelayMs:o}=s,a=o===void 0?1e3:o,{t:i}=nt(),l=`${n.remote}/${n.branch}`,c=n.ahead===0&&n.behind===0;let d;e[0]!==i||e[1]!==l||e[2]!==r?(d=r?i("gitView.header.upstreamTooltipTracking",{target:l,tracking:r}):i("gitView.header.upstreamTooltip",{target:l}),e[0]=i,e[1]=l,e[2]=r,e[3]=d):d=e[3];const u=d;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx(R,{name:"git-branch",className:"size-3.5 shrink-0"}),e[4]=f):f=e[4];let b;e[5]!==l?(b=t.jsx("span",{className:"min-w-0 truncate text-foreground/80",children:l}),e[5]=l,e[6]=b):b=e[6];let m;e[7]!==n.ahead||e[8]!==n.behind||e[9]!==c||e[10]!==i?(m=c?t.jsx("span",{className:"tabular-nums text-muted-foreground",children:i("gitView.header.upstreamSynced")}):t.jsxs("span",{className:"inline-flex items-center gap-1 tabular-nums",children:[n.ahead>0?t.jsxs("span",{className:"text-[var(--status-info)]",children:["↑",n.ahead]}):null,n.behind>0?t.jsxs("span",{className:"text-[var(--status-warning)]",children:["↓",n.behind]}):null]}),e[7]=n.ahead,e[8]=n.behind,e[9]=c,e[10]=i,e[11]=m):m=e[11];let x;e[12]!==b||e[13]!==m?(x=t.jsx(ps,{asChild:!0,children:t.jsxs("div",{className:"inline-flex h-8 max-w-full items-center gap-1.5 rounded-md border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2 typography-micro text-muted-foreground",children:[f,b,m]})}),e[12]=b,e[13]=m,e[14]=x):x=e[14];let g;e[15]!==u?(g=t.jsx(gs,{sideOffset:8,children:u}),e[15]=u,e[16]=g):g=e[16];let S;return e[17]!==x||e[18]!==g||e[19]!==a?(S=t.jsxs(hs,{delayDuration:a,children:[x,g]}),e[17]=x,e[18]=g,e[19]=a,e[20]=S):S=e[20],S},lm=s=>{const e=ze.c(84),{directory:n,status:r,localBranches:o,remoteBranches:a,branchInfo:i,syncAction:l,remotes:c,onFetch:d,onSync:u,onRemoveRemote:f,removingRemoteName:b,onCheckoutBranch:m,onCreateBranch:x,onRenameBranch:g,activeIdentityProfile:S,availableIdentities:p,onSelectIdentity:N,isApplyingIdentity:A,isWorktreeMode:L,onOpenHistory:I,onOpenGraph:T,onOpenStashes:y,onOpenUpdateBranch:v,onOpenReintegrateCommits:$,pullRequest:U,prChecks:W,onOpenPullRequest:z,repositoryOptions:q,selectedRepository:se,onSelectRepository:J,repositoryRoot:G}=s,{t:ee}=nt(),{isMobile:ue}=xs();if(!r)return null;let V;e[0]!==q?(V=q??[],e[0]=q,e[1]=V):V=e[1];let P;e[2]!==V?(P=V.filter(Boolean),e[2]=V,e[3]=P):P=e[3];const B=P;let M;e[4]!==T||e[5]!==I||e[6]!==$||e[7]!==y||e[8]!==v||e[9]!==ee?(M=I||T||y||v?t.jsxs(zt,{children:[t.jsxs(hs,{children:[t.jsx(ps,{asChild:!0,children:t.jsx(Gt,{asChild:!0,children:t.jsx(Ie,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0","aria-label":ee("gitView.header.repositoryViews"),children:t.jsx(R,{name:"more-fill",className:"size-4"})})})}),t.jsx(gs,{sideOffset:8,children:ee("gitView.header.repositoryViews")})]}),t.jsxs(Ht,{align:"end",children:[I?t.jsxs(Bt,{onSelect:I,children:[t.jsx(R,{name:"history",className:"size-4"}),ee("gitView.history.title")]}):null,T?t.jsxs(Bt,{onSelect:T,children:[t.jsx(R,{name:"git-branch",className:"size-4"}),ee("gitView.graph.title")]}):null,y?t.jsxs(Bt,{onSelect:y,children:[t.jsx(R,{name:"archive-stack",className:"size-4"}),ee("gitView.stashes.title")]}):null,v?t.jsxs(Bt,{onSelect:v,children:[t.jsx(R,{name:"git-merge",className:"size-4"}),ee("gitView.header.updateBranch")]}):null,$?t.jsxs(Bt,{onSelect:$,children:[t.jsx(R,{name:"split-cells-horizontal",className:"size-4"}),ee("gitView.integrate.title")]}):null]})]}):null,e[4]=T,e[5]=I,e[6]=$,e[7]=y,e[8]=v,e[9]=ee,e[10]=M):M=e[10];let D;e[11]!==M?(D=t.jsx("div",{className:"flex items-center gap-1 shrink-0",children:M}),e[11]=M,e[12]=D):D=e[12];const _=D,E=W?W.state==="success"?"var(--status-success)":W.state==="failure"?"var(--status-error)":"var(--status-warning)":null,K=U?U.state==="merged"?"merged":U.state==="closed"?"closed":U.draft?"draft":W?.state==="failure"||U.mergeable===!1||U.mergeableState==="blocked"||U.mergeableState==="dirty"?"blocked":"open":null;let O;e[13]!==z||e[14]!==E||e[15]!==K||e[16]!==U||e[17]!==ee?(O=U&&z?t.jsxs(hs,{children:[t.jsx(ps,{asChild:!0,children:t.jsxs(Ie,{variant:"ghost",size:"sm",onClick:z,className:"h-8 gap-1.5 px-2 typography-micro",children:[t.jsx(R,{name:"git-pull-request",className:"size-3.5",style:{color:`var(--pr-${K})`}}),t.jsx("span",{className:"tabular-nums text-foreground/80",children:ee("gitView.pr.numberLabel",{number:U.number})}),E?t.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:E}}):null]})}),t.jsx(gs,{sideOffset:8,children:ee("gitView.header.openPullRequest")})]}):null,e[13]=z,e[14]=E,e[15]=K,e[16]=U,e[17]=ee,e[18]=O):O=e[18];const ne=O,X=!r;let te;e[19]!==r.tracking?(te=r.tracking?.split("/")[0],e[19]=r.tracking,e[20]=te):te=e[20];const ge=(r.files?.length??0)>0;let re;e[21]!==d||e[22]!==f||e[23]!==u||e[24]!==c||e[25]!==b||e[26]!==r.ahead||e[27]!==r.behind||e[28]!==l||e[29]!==X||e[30]!==te||e[31]!==ge?(re=t.jsx(ud,{syncAction:l,remotes:c,onFetch:d,onSync:u,onRemoveRemote:f,removingRemoteName:b,disabled:X,iconOnly:!0,aheadCount:r.ahead,behindCount:r.behind,trackingRemoteName:te,hasUncommittedChanges:ge}),e[21]=d,e[22]=f,e[23]=u,e[24]=c,e[25]=b,e[26]=r.ahead,e[27]=r.behind,e[28]=l,e[29]=X,e[30]=te,e[31]=ge,e[32]=re):re=e[32];const pe=re;let Z;e[33]!==r.tracking||e[34]!==r.upstreamComparison?(Z=r.upstreamComparison?t.jsx(pd,{comparison:r.upstreamComparison,trackingBranch:r.tracking,tooltipDelayMs:1e3}):null,e[33]=r.tracking,e[34]=r.upstreamComparison,e[35]=Z):Z=e[35];const de=Z;let me;e[36]!==S||e[37]!==p||e[38]!==A||e[39]!==N?(me=t.jsx(wo,{activeProfile:S,identities:p,onSelect:N,isApplying:A,iconOnly:!0}),e[36]=S,e[37]=p,e[38]=A,e[39]=N,e[40]=me):me=e[40];const j=me;let Y;e[41]!==i||e[42]!==n||e[43]!==ue||e[44]!==L||e[45]!==o||e[46]!==m||e[47]!==x||e[48]!==g||e[49]!==a||e[50]!==c||e[51]!==r.ahead||e[52]!==r.current||e[53]!==r.files?.length||e[54]!==ee?(Y=L&&!ue?t.jsx(dd,{currentBranch:r.current,onRename:g}):t.jsx(ld,{directory:n,currentBranch:r.current,localBranches:o,remoteBranches:a,branchInfo:i,currentBranchAhead:r.ahead,onCheckout:m,onCreate:x,remotes:c,switchBlockedNotice:(r.files?.length??0)>0?ee("gitView.branch.switchBlockedNotice"):null}),e[41]=i,e[42]=n,e[43]=ue,e[44]=L,e[45]=o,e[46]=m,e[47]=x,e[48]=g,e[49]=a,e[50]=c,e[51]=r.ahead,e[52]=r.current,e[53]=r.files?.length,e[54]=ee,e[55]=Y):Y=e[55];let F;e[56]!==J||e[57]!==B||e[58]!==G||e[59]!==se?(F=B.length>0&&J?t.jsx(fd,{repositories:B,selectedRepository:se??null,onSelectRepository:J,repositoryRoot:G}):null,e[56]=J,e[57]=B,e[58]=G,e[59]=se,e[60]=F):F=e[60];let ae;e[61]!==Y||e[62]!==F?(ae=t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:[Y,F]}),e[61]=Y,e[62]=F,e[63]=ae):ae=e[63];let he;e[64]!==j?(he=t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:j}),e[64]=j,e[65]=he):he=e[65];let we;e[66]!==ae||e[67]!==he?(we=t.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[ae,he]}),e[66]=ae,e[67]=he,e[68]=we):we=e[68];let Te;e[69]!==ne?(Te=ne?t.jsx("div",{className:"shrink-0",children:ne}):null,e[69]=ne,e[70]=Te):Te=e[70];let Ge;e[71]===Symbol.for("react.memo_cache_sentinel")?(Ge=t.jsx("div",{className:"min-w-0 flex-1"}),e[71]=Ge):Ge=e[71];let Fe;e[72]!==de?(Fe=de?t.jsx("div",{className:"min-w-0 shrink",children:de}):null,e[72]=de,e[73]=Fe):Fe=e[73];let ve;e[74]!==pe?(ve=t.jsx("div",{className:"shrink-0",children:pe}),e[74]=pe,e[75]=ve):ve=e[75];let Re;e[76]!==_||e[77]!==Te||e[78]!==Fe||e[79]!==ve?(Re=t.jsxs("div",{className:"mt-3 flex h-8 min-w-0 items-center gap-2",children:[Te,Ge,Fe,_,ve]}),e[76]=_,e[77]=Te,e[78]=Fe,e[79]=ve,e[80]=Re):Re=e[80];let Ce;return e[81]!==we||e[82]!==Re?(Ce=t.jsxs("header",{className:"@container/git-header px-3 py-2 bg-transparent",children:[we,Re]}),e[81]=we,e[82]=Re,e[83]=Ce):Ce=e[83],Ce},gd=s=>s==="/",Hs=s=>s.replace(/\\/g,"/"),Mn=s=>{if(!s||gd(s))return s;let e=s;for(;e.length>1&&e.endsWith("/");)e=e.slice(0,-1);return e},Jt=s=>s.endsWith("/"),xd=s=>{const e=s.trim();return!e||Jt(e)?e:`${e}/`},Fn=s=>s.lastIndexOf("/"),vo=s=>{if(Jt(s))return s;const e=Fn(s);return e<0?s:s.slice(0,e+1)},bd=s=>{const e=Fn(s);return s.slice(e+1)},So=s=>{const e=Mn(s.trim());if(!e||e==="~"||e==="~/"||e==="/")return null;const n=Fn(e);return n<0?null:e.startsWith("~/")&&n<=1?"~/":n===0?"/":`${e.slice(0,n)}/`},yd=s=>Jt(s)&&So(s)!==null,wd=(s,e)=>`${vo(s)}${e}/`,Ut=s=>{if(!s)return null;const e=Mn(Hs(s.trim()));return e?e.toLowerCase():null},pr=(s,e)=>{const n=s.trim();return n==="~"?e:n.startsWith("~/")?`${e}${n.slice(1)}`:n},vd=s=>typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?s.metaKey&&!s.ctrlKey:s.ctrlKey&&!s.metaKey,rn=s=>{if(!s)return;s.focus({preventScroll:!0});const e=s.value.length;s.setSelectionRange(e,e),s.scrollLeft=s.scrollWidth},Sd=async()=>{try{const s=await Mt("/api/fs/home",{method:"GET",headers:{Accept:"application/json"}});if(s.ok){const e=await s.json();if(typeof e.home=="string"&&e.home.trim().length>0)return Hs(e.home.trim())}}catch{}return ms.getFilesystemHome().catch(()=>null)},cm=({open:s,onOpenChange:e})=>{const{t:n}=nt(),r=bs(k=>k.homeDirectory),o=It(k=>k.projects),a=It(k=>k.addProject),i=Ve(k=>k.setSessionSwitcherOpen),l=it(k=>k.openNewSessionDraft),c=It(k=>k.addProjects),d=qt(k=>k.profiles),u=qt(k=>k.globalIdentity),f=qt(k=>k.defaultGitIdentityId),b=qt(k=>k.loadProfiles),m=qt(k=>k.loadGlobalIdentity),x=qt(k=>k.loadDefaultGitIdentityId),{canRequestAccess:g,requestAccess:S,startAccessing:p}=od(),{isMobile:N}=xs(),A=h.useRef(null),L=h.useRef(null),I=h.useRef(new Map),[T,y]=h.useState(""),[v,$]=h.useState("~/"),[U,W]=h.useState([]),[z,q]=h.useState(!1),[se,J]=h.useState(!1),[G,ee]=h.useState(null),[ue,V]=h.useState(0),[P,B]=h.useState(0),[M,D]=h.useState(!1),[_,E]=h.useState(!1),[K,O]=h.useState(0),[ne,X]=h.useState(!1),[te,ge]=h.useState(""),[re,pe]=h.useState(null),[Z,de]=h.useState(!1),[me,j]=h.useState([]),Y=T||r,F=h.useMemo(()=>new Set(o.map(k=>Ut(k.path)).filter(k=>!!k)),[o]);h.useEffect(()=>{if(!s)return;$("~/"),W([]),B(0),D(!1),E(!1),X(!1),ge(""),pe(null),de(!1),j([]),requestAnimationFrame(()=>rn(A.current));let k=!1;return(async()=>{const ye=await Sd();k||(y(ye||r||""),requestAnimationFrame(()=>rn(A.current)))})(),()=>{k=!0}},[r,s]),h.useEffect(()=>{s&&(b(),m(),x())},[x,b,m,s]);const ae=h.useMemo(()=>{const k=new Map;u&&k.set(u.id,u);for(const oe of d)k.set(oe.id,oe);return Array.from(k.values())},[d,u]);h.useEffect(()=>{if(!s||!ne||re!==null)return;const k=typeof f=="string"?f.trim():"";if(k&&ae.some(ye=>ye.id===k)){pe(k);return}const oe=ae.find(ye=>ye.authType==="ssh"||ye.sshKey);oe&&pe(oe.id)},[ae,f,ne,s,re]);const he=h.useMemo(()=>ae.find(k=>k.id===re)??null,[ae,re]),we=h.useMemo(()=>vo(v),[v]),Te=h.useMemo(()=>Jt(v)?"":bd(v),[v]),Ge=h.useMemo(()=>Y?pr(we,Y):"",[we,Y]);h.useEffect(()=>{if(!s||!Ge){W([]),ee(null);return}let k=!1;return q(!0),J(!1),ee(null),ms.listLocalDirectory(Ge).then(oe=>{if(k)return;J(!1),ee(null);const ye=oe.filter(xe=>xe.isDirectory).map(xe=>({name:xe.name,path:Hs(xe.path)})).sort((xe,je)=>xe.name.localeCompare(je.name));W(ye)}).catch(oe=>{if(!k){W([]);const ye=Ui(oe)?oe.reason:"unknown";ee(ye),J(ye==="not-found")}}).finally(()=>{k||q(!1)}),()=>{k=!0}},[Ge,ue,s]);const Fe=h.useMemo(()=>{const k=Te.toLowerCase(),oe=Z||Te.startsWith(".");return U.filter(ye=>ye.name.toLowerCase().startsWith(k)&&(oe||!ye.name.startsWith(".")))},[Te,U,Z]),ve=h.useMemo(()=>{const k=[];yd(v)&&k.push({type:"up",value:"browse:up",name:"..",path:So(v)});for(const oe of Fe){const ye=Ut(oe.path);k.push({type:"directory",value:`browse:${oe.path}`,name:oe.name,path:oe.path,disabled:!!(ye&&F.has(ye))})}return k},[F,Fe,v]);h.useEffect(()=>{B(0)},[v,ve.length]),h.useEffect(()=>{j([])},[Ge]);const Re=h.useMemo(()=>me.filter(k=>{const oe=Ut(k);return!!(oe&&!F.has(oe))}),[F,me]),Ce=h.useCallback(k=>{j(oe=>oe.includes(k)?oe.filter(ye=>ye!==k):[...oe,k])},[]),Ue=h.useMemo(()=>Y?Mn(pr(v,Y)):"",[Y,v]),He=Ut(Ue),qe=!!(He&&F.has(He)),Ke=h.useMemo(()=>Te?Fe.find(k=>k.name===Te)??null:null,[Te,Fe]),We=!!(Ue&&!qe&&(G===null||G==="not-found")&&(Jt(v)&&se||!Jt(v)&&Te.trim().length>0&&Ke===null)),tt=!M&&!_&&G!=="os-permission"&&G!=="invalid-response"&&G!=="unknown"&&(!ne&&Re.length>0||!qe&&!!Ue),ct=tt&&te.trim().length>0,Be=ve[P]??null,Ye=!!(Be&&(Be.type==="up"||Be.type==="directory")),Qe=vn("mod"),Je=!ne&&Re.length>0?n("directoryExplorerDialog.actions.addSelected"):n(qe?"directoryExplorerDialog.actions.alreadyAdded":ne?M?"directoryExplorerDialog.actions.cloning":"directoryExplorerDialog.actions.cloneAndAdd":M?"directoryExplorerDialog.actions.adding":We?"directoryExplorerDialog.actions.createAndAdd":"directoryExplorerDialog.actions.addProject");h.useLayoutEffect(()=>{const k=L.current;if(!k)return;const oe=()=>O(Math.ceil(k.getBoundingClientRect().width));if(oe(),typeof ResizeObserver>"u")return;const ye=new ResizeObserver(oe);return ye.observe(k),()=>ye.disconnect()},[Je]),h.useLayoutEffect(()=>{const k=A.current;k&&(k.scrollLeft=k.scrollWidth)},[K,v]),h.useLayoutEffect(()=>{s&&rn(A.current)},[s]),h.useLayoutEffect(()=>{const k=ve[P];k&&I.current.get(k.value)?.scrollIntoView({block:"nearest"})},[P,ve]);const De=h.useCallback(()=>{e(!1)},[e]),ot=h.useCallback((k,oe)=>{N&&i(!1),l({selectedProjectId:k,directoryOverride:oe}),De()},[De,N,l,i]),$e=h.useCallback(async(k,oe)=>{k.stopPropagation();const ye=Ut(oe);if(ye&&F.has(ye))return;const xe=await a(oe);if(!xe){Ne.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}ot(xe.id,xe.path)},[a,F,ot,n]),_e=h.useCallback(async k=>{if(M)return;const oe=Ut(k),ye=ne?[]:me.filter(je=>{const C=Ut(je);return!!(C&&!F.has(C))});if(ye.length===0&&(!k||oe&&F.has(oe)))return;let xe=k;D(!0);try{const je=!ne&&We&&Ut(k)===Ut(Ue);if(ne){const Q=te.trim();if(!Q){Ne.error(n("directoryExplorerDialog.toast.cloneUrlRequired"));return}xe=(await ms.cloneRepository({remoteUrl:Q,destinationPath:k,gitIdentityId:he?.id??null})).path}else if(ye.length>0){const Q=await c(ye);if(Q.length===0){Ne.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}Ne.success(n("directoryExplorerDialog.toast.addedProjects",{count:Q.length})),j([]),De();return}else je&&await ms.createDirectory(k,{asProject:!0});const C=await a(xe);if(!C){Ne.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}ot(C.id,C.path)}catch(je){Ne.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:je instanceof Error?je.message:n("directoryExplorerDialog.toast.unknownError")})}finally{D(!1)}},[a,c,F,te,De,ne,M,ot,he?.id,me,We,Ue,n]),st=h.useCallback(k=>{$(xd(k))},[]),Pe=h.useCallback(k=>{$(wd(v,k.name))},[v]),Xe=h.useCallback(k=>{if(k){if(k.type==="up"){k.path&&st(k.path);return}Pe(k)}},[st,Pe]),dt=h.useCallback(async()=>{if(!(!g||_)){E(!0);try{const k=await S(Ue);if(!k.success||!k.path){k.error&&k.error!=="Directory selection cancelled"&&Ne.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:k.error});return}const oe=await p(k.path);if(!oe.success){Ne.error(n("directoryExplorerDialog.toast.failedToOpenDirectory"),{description:oe.error||n("directoryExplorerDialog.toast.desktopCouldNotGrantAccess")});return}j([]),await _e(k.path)}catch(k){Ne.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:k instanceof Error?k.message:n("directoryExplorerDialog.toast.unknownError")})}finally{E(!1)}}},[g,_e,_,S,p,n,Ue]),lt=h.useCallback(k=>{if(k.key==="ArrowDown"){k.preventDefault(),B(oe=>Math.min(ve.length-1,oe+1));return}if(k.key==="ArrowUp"){k.preventDefault(),B(oe=>Math.max(0,oe-1));return}if(k.key===" "){if(Jt(v)){k.preventDefault(),Be&&Be.type==="directory"&&!Be.disabled&&Ce(Be.path);return}return}if(k.key==="Enter"){if(k.preventDefault(),vd(k)){_e(Ue);return}Ye&&Xe(Be);return}k.key==="Backspace"&&v===""&&(k.preventDefault(),De())},[Xe,_e,De,Ye,Be,v,ve.length,Ue,Ce]),ut=t.jsxs("button",{type:"button",onClick:()=>de(k=>!k),className:"flex flex-shrink-0 items-center gap-2 rounded-lg px-2 py-1 typography-meta text-muted-foreground transition-colors hover:bg-interactive-hover/40",children:[Z?t.jsx(R,{name:"checkbox",className:"h-4 w-4 text-primary"}):t.jsx(R,{name:"checkbox-blank",className:"h-4 w-4"}),n("directoryExplorerDialog.toggle.showHidden")]}),yt=t.jsxs("div",{className:"px-2.5 py-1.5",children:[ne?t.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[t.jsx(bt,{value:te,onChange:k=>ge(k.target.value),placeholder:n("directoryExplorerDialog.clone.remoteUrlPlaceholder"),className:"min-w-0 flex-1 border-border/60 bg-[var(--surface-elevated)] font-mono typography-ui-label shadow-none",spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"}),t.jsx(wo,{activeProfile:he,identities:ae,onSelect:k=>pe(k.id),isApplying:M,iconOnly:!0})]}):null,t.jsxs("div",{className:"relative",children:[t.jsx(R,{name:"folder-add",className:"pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/80"}),t.jsx(bt,{ref:A,value:v,onChange:k=>$(Hs(k.target.value)),onKeyDown:lt,placeholder:n("directoryExplorerDialog.pathInput.placeholder"),className:"border-transparent bg-transparent pl-9 font-mono typography-ui-label shadow-none focus-visible:ring-0",style:!N&&K>0?{paddingRight:`${K+24}px`}:void 0,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"}),N?null:t.jsx(Ie,{ref:L,variant:"outline",size:"xs",tabIndex:-1,className:"absolute right-1.5 top-1/2 h-7 -translate-y-1/2 gap-1 px-2 typography-meta",disabled:ne?!ct:!tt,onMouseDown:k=>k.preventDefault(),onClick:()=>{_e(Ue)},title:Je,children:Je})]})]}),w=t.jsx("div",{className:"relative min-h-0 flex-1 overflow-hidden rounded-xl border border-border/60 bg-[var(--surface-elevated)] shadow-sm",children:t.jsxs("div",{className:"max-h-[min(28rem,58vh)] overflow-y-auto p-2",children:[t.jsx("div",{className:"px-2 pb-1 pt-0.5 typography-meta font-medium uppercase tracking-wide text-muted-foreground/80",children:n("directoryExplorerDialog.browse.directories")}),z?t.jsx("div",{className:"py-10 text-center typography-ui-label text-muted-foreground",children:n("directoryExplorerDialog.browse.loading")}):G&&G!=="not-found"?t.jsxs("div",{className:"flex flex-col items-center gap-3 px-4 py-10 text-center",children:[t.jsx("div",{className:"typography-ui-label text-status-error",children:n(G==="os-permission"?"directoryExplorerDialog.browse.permissionDenied":"directoryExplorerDialog.browse.loadFailed")}),t.jsxs("div",{className:"flex items-center gap-2",children:[G==="os-permission"&&g?t.jsx(Ie,{size:"xs",onClick:()=>{dt()},disabled:_,children:n("directoryExplorerDialog.browse.grantAccess")}):null,t.jsx(Ie,{variant:"outline",size:"xs",onClick:()=>V(k=>k+1),children:n("directoryExplorerDialog.browse.retry")})]})]}):ve.length===0?t.jsx("div",{className:"py-10 text-center typography-ui-label text-muted-foreground",children:n("directoryExplorerDialog.browse.empty")}):t.jsx("div",{className:"space-y-0.5",children:ve.map((k,oe)=>{const ye=oe===P;return t.jsxs("button",{ref:xe=>{xe?I.current.set(k.value,xe):I.current.delete(k.value)},type:"button",onMouseEnter:()=>B(oe),onMouseDown:xe=>xe.preventDefault(),onClick:()=>Xe(k),className:le("flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",ye&&"bg-interactive-selection text-interactive-selection-foreground",!ye&&"hover:bg-interactive-hover/50",k.type==="directory"&&k.disabled&&"opacity-45"),children:[k.type==="up"?t.jsx(R,{name:"arrow-left-s",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/80"}):t.jsx(R,{name:"folder-6",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/80"}),t.jsx("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:t.jsx("span",{className:"truncate typography-ui-label text-foreground",children:k.name})}),k.type==="directory"&&k.disabled?t.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 typography-meta text-muted-foreground",children:n("directoryExplorerDialog.browse.addedBadge")}):k.type==="directory"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onMouseDown:xe=>xe.stopPropagation(),onClick:xe=>{xe.stopPropagation(),Ce(k.path)},title:n("directoryExplorerDialog.browse.selectForAdd"),"aria-label":n("directoryExplorerDialog.browse.selectForAdd"),"aria-pressed":me.includes(k.path),className:"flex-shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",children:t.jsx(R,{name:me.includes(k.path)?"checkbox":"checkbox-blank",className:"h-4 w-4"})}),t.jsx("button",{type:"button",onMouseDown:xe=>xe.stopPropagation(),onClick:xe=>$e(xe,k.path),className:"flex-shrink-0 rounded-full p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",title:n("directoryExplorerDialog.browse.quickAdd"),children:t.jsx(R,{name:"add",className:"h-3.5 w-3.5"})})]}):null]},k.value)})})]})}),H=t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[yt,w]}),ke=t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-micro text-muted-foreground",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(R,{name:"arrow-up-s",className:"h-3.5 w-3.5"}),t.jsx(R,{name:"arrow-down-s",className:"-ml-1 h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.navigate")]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(R,{name:"corner-down-left",className:"h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.select")]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx("span",{children:Qe}),t.jsx(R,{name:"corner-down-left",className:"h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.add")]})]}),Ae=()=>t.jsxs(t.Fragment,{children:[N?null:ke,t.jsxs("div",{className:le("flex w-full flex-row justify-end gap-2 sm:w-auto",N&&"justify-stretch"),children:[g?t.jsx(Ie,{variant:"ghost",size:"xs",onClick:dt,disabled:M||_||ne,children:n(_?"directoryExplorerDialog.actions.openingFinder":"directoryExplorerDialog.actions.openInFinder")}):null,t.jsx(Ie,{variant:"ghost",size:"xs",onClick:()=>{X(k=>!k),j([])},disabled:M||_,className:le(N&&"flex-1"),children:n(ne?"directoryExplorerDialog.actions.addLocalProject":"directoryExplorerDialog.actions.cloneRepository")}),N?t.jsx(Ie,{size:"xs",onClick:()=>{_e(Ue)},disabled:ne?!ct:!tt,className:"flex-1",children:Je}):null]})]});return N?t.jsx(fs,{open:s,onClose:De,title:n("directoryExplorerDialog.title"),className:"h-[88dvh] max-h-[720px]",contentMaxHeightClassName:"flex-1",footer:t.jsx("div",{className:"flex flex-col gap-2",children:Ae()}),children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-3",children:[t.jsx("div",{className:"flex justify-end",children:ut}),H]})}):t.jsx(Ds,{open:s,onOpenChange:e,children:t.jsxs(Ps,{className:"flex w-full max-w-xl flex-col gap-0 overflow-hidden p-0 sm:max-h-[80vh]",initialFocus:!1,children:[t.jsx(Ks,{className:"px-5 pb-2 pt-5",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx(Rs,{children:n("directoryExplorerDialog.title")}),t.jsx(Ba,{className:"mt-2",children:n("directoryExplorerDialog.description")})]}),ut]})}),t.jsx("div",{className:"min-h-0 flex-1 px-2 pb-0",children:H}),t.jsx(An,{className:"flex w-full flex-col gap-3 px-5 py-3 sm:flex-row sm:items-center sm:justify-between",children:Ae()})]})})};function gr(s){const{localBranches:e,remoteBranches:n,query:r}=s,o=r.trim();if(!o)return{matching:[],otherLocal:e,otherRemote:n};const a=[...e.map(c=>({label:c,value:c,source:"local"})),...n.map(c=>({label:c,value:`remotes/${c}`,source:"remote"}))],i=gn(a,o,c=>[c.label]),l=new Set(i);return{matching:i,otherLocal:a.filter(c=>c.source==="local"&&!l.has(c)).map(c=>c.label),otherRemote:a.filter(c=>c.source==="remote"&&!l.has(c)).map(c=>c.label)}}const on="oc:lastWorktreeSourceBranch",jd=({mode:s,sourceBranch:e,linkedPr:n,selectedBranch:r})=>s==="existing-branch"?r||null:n?null:e||null,Nd=({branches:s,savedSourceBranch:e,rootBranch:n})=>!!(e&&s.includes(e))&&e?{sourceBranch:e,shouldClearSavedSourceBranch:!1}:{sourceBranch:n&&s.includes(n)?n:s.includes("main")?"main":s.includes("master")?"master":s[0]??"",shouldClearSavedSourceBranch:!!e};function kd({open:s,onOpenChange:e,onSelect:n}){const{t:r}=nt(),o=Ve(j=>j.isMobile),{github:a}=Bn(),i=Is(j=>j.status),l=Is(j=>j.hasChecked),c=Ve(j=>j.setSettingsDialogOpen),d=Ve(j=>j.setSettingsPage),u=It(j=>j.getActiveProject()),f=u?.path??null,b=ce.useMemo(()=>f&&u?{id:u.id,path:f}:null,[u,f]),[m,x]=ce.useState("issues"),[g,S]=ce.useState(""),[p,N]=ce.useState([]),[A,L]=ce.useState([]),[I,T]=ce.useState(!1),[y,v]=ce.useState(!1),[$,U]=ce.useState(null),[W,z]=ce.useState(null),[q,se]=ce.useState(null),[J,G]=ce.useState(!1),[ee,ue]=ce.useState(new Map),[V,P]=ce.useState(1),[B,M]=ce.useState(!1),D=La(g,350),_=ce.useCallback(async j=>{if(!(!f||!a)&&!(l&&i?.connected===!1)){T(!0),U(null),P(1),M(!1);try{if(m==="issues"&&a.issuesList){const Y=await a.issuesList(f,{page:1,query:j});Y.connected===!1?(U(r("session.githubIntegration.error.notConnected")),N([])):(N(Y.issues??[]),P(Y.page??1),M(!!Y.hasMore))}else if(m==="prs"&&a.prsList){const Y=await a.prsList(f,{page:1,query:j});Y.connected===!1?(U(r("session.githubIntegration.error.notConnected")),L([])):(L(Y.prs??[]),P(Y.page??1),M(!!Y.hasMore))}}catch(Y){U(Y instanceof Error?Y.message:r("session.githubIntegration.error.loadDataFailed"))}finally{T(!1)}}},[f,a,l,i,m,r]);ce.useEffect(()=>{if(!s||!f||l&&i?.connected===!1||!a)return;if(!D.trim()){_();return}const j=new AbortController;T(!0),U(null),P(1),M(!1);const Y=m==="issues"&&a.issuesList?a.issuesList(f,{page:1,query:D.trim()}):m==="prs"&&a.prsList?a.prsList(f,{page:1,query:D.trim()}):null;if(!Y){T(!1);return}return Y.then(F=>{j.signal.aborted||("issues"in F?F.connected===!1?(U(r("session.githubIntegration.error.notConnected")),N([])):(N(F.issues??[]),P(F.page??1),M(!!F.hasMore)):"prs"in F&&(F.connected===!1?(U(r("session.githubIntegration.error.notConnected")),L([])):(L(F.prs??[]),P(F.page??1),M(!!F.hasMore))))}).catch(F=>{j.signal.aborted||U(F instanceof Error?F.message:r("session.githubIntegration.error.loadDataFailed"))}).finally(()=>{j.signal.aborted||T(!1)}),()=>j.abort()},[s,f,a,l,i,m,D,_,r]);const E=ce.useCallback(async()=>{if(!(!f||!a)&&!(I||y)&&B){v(!0);try{const j=V+1;if(m==="issues"&&a.issuesList){const Y=D.trim()?await a.issuesList(f,{page:j,query:D.trim()}):await a.issuesList(f,{page:j});Y.connected!==!1&&(N(F=>[...F,...Y.issues??[]]),P(Y.page??j),M(!!Y.hasMore))}else if(m==="prs"&&a.prsList){const Y=D.trim()?await a.prsList(f,{page:j,query:D.trim()}):await a.prsList(f,{page:j});Y.connected!==!1&&(L(F=>[...F,...Y.prs??[]]),P(Y.page??j),M(!!Y.hasMore))}}catch{}finally{v(!1)}}},[f,a,m,V,B,I,y,D]);ce.useEffect(()=>{if(!s){x("issues"),S(""),N([]),L([]),z(null),se(null),G(!1),U(null),ue(new Map),P(1),M(!1);return}_()},[s,_]);const K=ce.useCallback(async j=>{if(!(!b||!j)&&!ee.has(j))try{const F=(await Fr(b,{mode:"new",branchName:j,worktreeName:j})).errors.find(ae=>ae.code==="branch_in_use");ue(ae=>new Map(ae).set(j,{isValid:!F,error:F?r(F.code==="branch_exists"?"session.githubIntegration.validation.branchAlreadyExists":"session.githubIntegration.validation.branchAlreadyCheckedOut"):null}))}catch{ue(Y=>new Map(Y).set(j,{isValid:!1,error:r("session.githubIntegration.validation.failed")}))}},[b,ee,r]);ce.useEffect(()=>{!s||m!=="prs"||A.forEach(j=>{j.head&&K(j.head)})},[s,m,A,K]);const O=l&&i?.connected===!0,ne=()=>{d("integrations"),c(!0)},X=j=>{z(j),se(null)},te=j=>{se(j),z(null)},ge=()=>{W?n({type:"issue",item:W}):q&&n({type:"pr",item:q,includeDiff:J}),e(!1)},re=()=>{z(null),se(null),G(!1)},pe=W||q&&ee.get(q.head??"")?.isValid!==!1,Z=j=>j.head?ee.get(j.head)?.isValid===!1:!0,de=t.jsx(t.Fragment,{children:O?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative mt-2",children:[t.jsx(R,{name:"search",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(bt,{value:g,onChange:j=>S(j.target.value),placeholder:r(m==="issues"?"session.githubIntegration.search.issuesPlaceholder":"session.githubIntegration.search.prsPlaceholder"),className:"h-8 pl-9"})]}),t.jsx("div",{className:"mt-2 h-[300px] overflow-hidden",children:t.jsxs("div",{className:"h-full overflow-y-auto",children:[I&&t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx(R,{name:"loader-4",className:"h-5 w-5 animate-spin text-muted-foreground"})}),$&&t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-destructive/10 text-destructive",children:[t.jsx(R,{name:"error-warning",className:"h-4 w-4"}),t.jsx("span",{className:"typography-small",children:$})]})}),!I&&!$&&m==="issues"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[p.length>0?p.map(j=>t.jsx("button",{onClick:()=>X(j),className:le("w-full text-left px-2 py-1.5 rounded transition-colors",W?.number===j.number?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("span",{className:"text-muted-foreground shrink-0 typography-micro",children:["#",j.number]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"typography-small line-clamp-2",children:j.title}),j.sourceRepo?.source==="upstream"?t.jsxs("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info mt-0.5 inline-block",children:[j.sourceRepo.owner,"/",j.sourceRepo.repo]}):null]})]})},`${j.sourceRepo?.owner??""}-${j.sourceRepo?.repo??""}-${j.number}`)):t.jsx("div",{className:"flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground",children:r("session.githubIntegration.empty.noIssuesFound")}),B&&!y&&t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>{E()},className:"h-7 text-xs",children:r("session.githubIntegration.actions.loadMore")})}),y&&t.jsx("div",{className:"flex items-center justify-center py-2",children:t.jsx(R,{name:"loader-4",className:"h-4 w-4 animate-spin text-muted-foreground"})})]}),!I&&!$&&m==="prs"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[A.length>0?A.map(j=>{const Y=Z(j),F=j.head?ee.get(j.head):void 0;return t.jsx("button",{onClick:()=>!Y&&te(j),disabled:Y,className:le("w-full text-left px-2 py-1.5 rounded transition-colors",q?.number===j.number?"bg-interactive-selection text-interactive-selection-foreground":Y?"opacity-50 cursor-not-allowed":"hover:bg-interactive-hover"),children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("span",{className:"text-muted-foreground shrink-0 typography-micro",children:["#",j.number]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"typography-small line-clamp-1",children:j.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[j.head," → ",j.base]}),j.sourceRepo?.source==="upstream"?t.jsxs("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info",children:[j.sourceRepo.owner,"/",j.sourceRepo.repo]}):null,Y&&F?.error&&t.jsx("span",{className:"typography-micro text-destructive",children:F.error})]})]})]})},`${j.sourceRepo?.owner??""}-${j.sourceRepo?.repo??""}-${j.number}`)}):t.jsx("div",{className:"flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground",children:r("session.githubIntegration.empty.noPullRequestsFound")}),B&&!y&&t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>{E()},className:"h-7 text-xs",children:r("session.githubIntegration.actions.loadMore")})}),y&&t.jsx("div",{className:"flex items-center justify-center py-2",children:t.jsx(R,{name:"loader-4",className:"h-4 w-4 animate-spin text-muted-foreground"})})]})]})})]}):t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 gap-4",children:[t.jsx(R,{name:"github",className:"h-12 w-12 text-muted-foreground"}),t.jsxs("div",{className:"text-center",children:[t.jsx("p",{className:"typography-ui-label text-foreground",children:r("session.githubIntegration.connect.title")}),t.jsx("p",{className:"typography-small text-muted-foreground mt-1",children:r("session.githubIntegration.connect.description")})]}),t.jsx(Ie,{onClick:ne,size:"sm",children:r("session.githubIntegration.connect.action")})]})}),me=t.jsxs("div",{className:le("w-full",o?"flex flex-col gap-2":"flex flex-row items-center"),children:[t.jsxs("div",{className:le("flex items-center gap-4",o?"w-full justify-center order-1":"flex-1"),children:[!o&&(W||q)&&t.jsxs("div",{className:"flex items-center gap-2 px-2 h-8 rounded-md bg-muted/50 border border-border/50",children:[t.jsx(R,{name:"check",className:"h-3.5 w-3.5 text-status-success shrink-0"}),t.jsx("span",{className:"typography-small truncate max-w-[150px]",children:W?r("session.githubIntegration.selected.issueNumber",{number:W.number}):r("session.githubIntegration.selected.prNumber",{number:q?.number??""})}),t.jsx("button",{onClick:re,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})})]}),m==="prs"&&q&&t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer h-8",children:[t.jsx(Es,{checked:J,onChange:j=>G(j),ariaLabel:r("session.githubIntegration.includeDiffAria")}),t.jsx("span",{className:"typography-small text-foreground",children:r("session.githubIntegration.includeDiff")})]})]}),t.jsxs("div",{className:le("flex gap-2",o?"w-full order-2":"justify-end"),children:[t.jsx(Ie,{variant:"outline",size:"sm",onClick:()=>e(!1),className:le(o&&"flex-1"),children:r("session.githubIntegration.actions.cancel")}),t.jsx(Ie,{size:"sm",onClick:ge,disabled:!pe,className:le(o&&"flex-1"),children:r("session.githubIntegration.actions.select")})]})]});return t.jsx(t.Fragment,{children:o?t.jsx(fs,{open:s,title:r("session.githubIntegration.title"),onClose:()=>e(!1),footer:O?me:void 0,renderHeader:j=>t.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2 border-b border-border/40",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:r("session.githubIntegration.title")}),j]}),t.jsx("div",{className:"w-full",children:t.jsx(Ts,{items:[{id:"issues",label:r("session.githubIntegration.tabs.issues"),icon:t.jsx(R,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"prs",label:r("session.githubIntegration.tabs.pullRequests"),icon:t.jsx(R,{name:"git-pull-request",className:"h-3.5 w-3.5"})}],activeId:m,onSelect:Y=>{x(Y),S("")},variant:"active-pill",layoutMode:"fit"})}),(W||q)&&t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded-md bg-muted/50 border border-border/50",children:[t.jsx(R,{name:"check",className:"h-3.5 w-3.5 text-status-success shrink-0"}),t.jsx("span",{className:"typography-small truncate flex-1",children:W?r("session.githubIntegration.selected.issueNumber",{number:W.number}):r("session.githubIntegration.selected.prNumber",{number:q?.number??""})}),t.jsx("button",{onClick:re,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})})]})]}),children:de}):t.jsx(Ds,{open:s,onOpenChange:e,children:t.jsxs(Ps,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[t.jsx(Ks,{className:"flex flex-row items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(Rs,{className:"flex items-center gap-2 shrink-0",children:[t.jsx(R,{name:"github",className:"h-5 w-5"}),r("session.githubIntegration.title")]}),t.jsx("div",{className:"w-[220px]",children:t.jsx(Ts,{items:[{id:"issues",label:r("session.githubIntegration.tabs.issues"),icon:t.jsx(R,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"prs",label:r("session.githubIntegration.tabs.pullRequests"),icon:t.jsx(R,{name:"git-pull-request",className:"h-3.5 w-3.5"})}],activeId:m,onSelect:j=>{x(j),S("")},variant:"active-pill",layoutMode:"fit"})})]})}),de,t.jsx(An,{className:"mt-1",children:me})]})})})}const js=s=>s.trim().replace(/^refs\/heads\//,"").replace(/^heads\//,"").replace(/\s+/g,"-").replace(/^\/+|\/+$/g,""),Id=s=>String(s).trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")||"pr-head",xr=(s,e,n)=>{const r=js(s.head||"");if(!r)throw new Error("PR head branch is missing");if(e.includes(r))return{existingBranch:r,setUpstream:void 0,upstreamRemote:void 0,upstreamBranch:void 0,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:r};const o=n.find(d=>{const u=d.indexOf("/");return u<=0||u>=d.length-1?!1:d.slice(u+1)===r});if(o){const d=o.indexOf("/"),u=o.slice(0,d);return{existingBranch:`remotes/${o}`,setUpstream:!0,upstreamRemote:u,upstreamBranch:r,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:`${u}/${r}`}}const a=String(s.headLabel||"").split(":")[0]?.trim(),i=s.headRepo?.owner||a||"pr-head",l=`pr-${Id(i)}`,c=s.headRepo?.cloneUrl||s.headRepo?.sshUrl||"";if(!c)throw new Error("PR head repository URL is unavailable. The fork may have been deleted; push the branch to a reachable repository and try again.");return{existingBranch:`remotes/${l}/${r}`,setUpstream:!0,upstreamRemote:l,upstreamBranch:r,ensureRemoteName:l,ensureRemoteUrl:c,sourceLabel:`${l}/${r}`}},pt=s=>s.trim().replace(/^refs\/heads\//,"").replace(/^heads\//,"").replace(/\s+/g,"-").replace(/^\/+|\/+$/g,"").split("/").join("-").replace(/[^A-Za-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"").slice(0,80),Cd=s=>{const e={repo:s.repo??null,issue:s.issue,comments:s.comments};return`GitHub issue context (JSON)
|
|
3
|
-
${JSON.stringify(e,null,2)}`},Td=s=>`GitHub pull request context (JSON)
|
|
4
|
-
${JSON.stringify(s,null,2)}`,Dd=s=>{const e={issue:s.issue,comments:s.comments};return`Linear issue context (JSON)
|
|
5
|
-
${JSON.stringify(e,null,2)}`};function dm({open:s,onOpenChange:e,onWorktreeCreated:n}){const{t:r}=nt(),{github:o,git:a,linear:i}=Bn(),l=Ve(w=>w.isMobile),c=Is(w=>w.status),d=Is(w=>w.hasChecked),u=Sn(w=>w.status),f=Sn(w=>w.hasChecked),b=It(w=>w.getActiveProject()),m=b?.path??null,x=ce.useMemo(()=>m&&b?{id:b.id,path:m}:null,[b,m]),[g,S]=ce.useState("new-branch"),[p,N]=ce.useState({branchName:"",worktreeName:"",isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,linkedLinearIssue:null,includePrDiff:!1}),[A,L]=ce.useState({selectedBranch:"",worktreeName:""}),I=Ma(m),T=Fa(m),y=Ln(w=>w.fetchBranches),v=ce.useMemo(()=>I?.all?I.all.filter(w=>!w.startsWith("remotes/")).sort():[],[I]),$=ce.useMemo(()=>I?.all?I.all.filter(w=>w.startsWith("remotes/")).map(w=>w.replace(/^remotes\//,"")).sort():[],[I]),U=it(w=>w.availableWorktreesByProject),W=ce.useMemo(()=>{if(!m)return new Set;const w=U.get(m)??[];return new Set(w.map(H=>H.name))},[U,m]),z=ce.useCallback((w=10)=>{for(let H=0;H<w;H++){const ke=Ls();if(!W.has(ke))return ke}return`${Ls()}-${Date.now().toString(36).slice(-4)}`},[W]),[q,se]=ce.useState(!1),[J,G]=ce.useState(!1),[ee,ue]=ce.useState(!1),[V,P]=ce.useState(!1),[B,M]=ce.useState(!1),[D,_]=ce.useState(!1),[E,K]=ce.useState(""),[O,ne]=ce.useState(""),X=ce.useRef(null),te=ce.useRef(null),ge=ce.useRef(null),re=ce.useRef(null),pe=ce.useCallback(w=>{w.stopPropagation()},[]),Z=ce.useCallback(w=>{let H=w;for(;H&&H!==document.body;){const{overflowY:ke}=window.getComputedStyle(H);if((ke==="auto"||ke==="scroll")&&H.scrollHeight>H.clientHeight)return H;H=H.parentElement}return null},[]),de=ce.useCallback(w=>{w&&(w.scrollTop=0)},[]),me=ce.useCallback(w=>{const H=w.current?.querySelector('[data-slot="command-list"]')??null;de(H)},[de]),j=ce.useCallback(w=>{const H=Z(w.current);de(H)},[Z,de]),Y=ce.useMemo(()=>gr({localBranches:v,remoteBranches:$,query:E}),[v,$,E]),F=ce.useMemo(()=>gr({localBranches:v,remoteBranches:$,query:O}),[v,$,O]),ae=E.trim().length>0,he=O.trim().length>0,we=Y.matching.length>0,Te=F.matching.length>0,Ge=!!(m&&a),Fe=ce.useCallback(()=>{!m||!a||y(m,a)},[m,a,y]);ce.useEffect(()=>{!s||!m||!a||I?.all||y(m,a)},[s,m,a,I?.all,y]),ce.useEffect(()=>{!ee&&!B&&K("")},[ee,B]),ce.useEffect(()=>{!V&&!D&&ne("")},[V,D]),ce.useEffect(()=>{ee&&me(X),B&&j(ge)},[ee,B,E,me,j]),ce.useEffect(()=>{V&&me(te),D&&j(re)},[V,D,O,me,j]);const[ve,Re]=ce.useState({isValidating:!1,branchError:null,worktreeError:null,touched:!1}),[Ce,Ue]=ce.useState(!1),[He,qe]=ce.useState(null),Ke=ce.useRef(!1),We=ce.useCallback(()=>{const w=Nt.getState(),H=w.getVisibleAgents();if(w.settingsDefaultAgent){const ke=H.find(Ae=>Ae.name===w.settingsDefaultAgent);if(ke)return ke.name}return H.find(ke=>ke.name==="build")?.name||H[0]?.name},[]),tt=ce.useCallback(()=>{const w=Nt.getState(),H=w.settingsDefaultModel;if(!H)return null;const ke=Lr(H);if(!ke)return null;const{providerId:Ae,modelId:k}=ke;return w.getModelMetadata(Ae,k)?{providerID:Ae,modelID:k}:null},[]),ct=ce.useCallback((w,H)=>{const ke=Nt.getState(),Ae=ke.settingsDefaultVariant,k=ke.currentProviderId===w&&ke.currentModelId===H?ke.currentVariant:void 0,xe=ke.providers.find(je=>je.id===w)?.models.find(je=>je.id===H)?.variants;if(!xe)return Ae||k||void 0;if(Ae&&Object.prototype.hasOwnProperty.call(xe,Ae))return Ae;if(k&&Object.prototype.hasOwnProperty.call(xe,k))return k},[]),Be=ce.useCallback(async w=>{const H=Nt.getState(),ke=Or.getState().lastUsedProvider,Ae=tt(),k=Ae?.providerID||H.currentProviderId||ke?.providerID,oe=Ae?.modelID||H.currentModelId||ke?.modelID,ye=We()||H.currentAgentName||void 0;if(!k||!oe){Ne.error(r("session.newWorktree.error.noModelSelected"));return}const xe=ct(k,oe);if(w.linearIssue){if(!i?.issueGet)return;const je=await i.issueGet(w.linearIssue.identifier);if(je.connected===!1||!je.issue)throw new Error("Failed to load issue context");const C=je.issue,Q=C.comments??[],ie=C.assignee?.displayName||C.assignee?.name,Oe=await Vt("linear.issue.review.visible",{identifier:C.identifier}),be=await Vt("linear.issue.review.instructions"),Le=Dd({issue:C,comments:Q});Oa(i,{sessionId:w.sessionId,issueIdentifier:C.identifier}),await it.getState().sendMessage(Oe,k,oe,ye,void 0,void 0,[{text:be,synthetic:!0},{text:Le,synthetic:!0}],xe,void 0,{sessionId:w.sessionId,directory:w.directory}),Zs(w.sessionId,w.directory,$a({identifier:C.identifier,title:C.title,url:C.url,author:ie?{login:ie,avatarUrl:C.assignee?.avatarUrl||void 0}:w.linearIssue.author,linkedAt:Date.now()}),!0).catch(()=>{}),Ne.success(r("session.newWorktree.toast.sessionFromIssue"));return}if(!(!m||!o)){if(w.issue){if(!o.issueGet||!o.issueComments)return;const je=await o.issueGet(m,w.issue.number,{sourceRepo:w.issue.sourceRepo??null});if(je.connected===!1||!je.repo||!je.issue)throw new Error("Failed to load issue context");const C=await o.issueComments(m,w.issue.number,{sourceRepo:w.issue.sourceRepo??null});if(C.connected===!1)throw new Error("Failed to load issue comments");const Q=await Vt("github.issue.review.visible",{issue_number:String(w.issue.number)}),ie=await Vt("github.issue.review.instructions"),Oe=Cd({repo:je.repo,issue:je.issue,comments:C.comments??[]});await it.getState().sendMessage(Q,k,oe,ye,void 0,void 0,[{text:ie,synthetic:!0},{text:Oe,synthetic:!0}],xe,void 0,{sessionId:w.sessionId}),Zs(w.sessionId,w.directory,Gn({url:je.issue.url,number:je.issue.number,title:je.issue.title,kind:"issue",author:je.issue.author,linkedAt:Date.now()}),!0).catch(()=>{}),Ne.success(r("session.newWorktree.toast.sessionFromIssue"));return}if(w.pr){if(!o.prContext)return;const je=await o.prContext(m,w.pr.number,{sourceRepo:w.pr.sourceRepo??null,includeDiff:w.includeDiff,includeCheckDetails:!1});if(je.connected===!1||!je.repo||!je.pr)throw new Error("Failed to load PR context");const C=await Vt("github.pr.review.visible",{pr_number:String(w.pr.number)}),Q=await Vt("github.pr.review.instructions"),ie=Td(je);await it.getState().sendMessage(C,k,oe,ye,void 0,void 0,[{text:Q,synthetic:!0},{text:ie,synthetic:!0}],xe,void 0,{sessionId:w.sessionId}),Zs(w.sessionId,w.directory,Gn({url:je.pr.url,number:je.pr.number,title:je.pr.title,kind:"pull",author:je.pr.author,linkedAt:Date.now()}),!0).catch(()=>{}),Ne.success(r("session.newWorktree.toast.sessionFromPr"))}}},[o,i,m,We,tt,ct,r]),Ye=g==="new-branch"?p:A;ce.useEffect(()=>{if(!s||!I?.all||!m||p.sourceBranch)return;const w=p.sourceBranch;let H=!1;return(async()=>{try{const Ae=await Wa(m).catch(()=>null);if(H)return;const k=localStorage.getItem(on),{sourceBranch:oe,shouldClearSavedSourceBranch:ye}=Nd({branches:I.all,savedSourceBranch:k,rootBranch:Ae});if(ye&&localStorage.removeItem(on),H||w)return;oe&&N(xe=>({...xe,sourceBranch:oe}))}catch{}})(),()=>{H=!0}},[s,I?.all,m,p.sourceBranch]),ce.useLayoutEffect(()=>{if(!s){Ke.current=!1;return}if(Ke.current)return;Ke.current=!0,S("new-branch"),L({selectedBranch:"",worktreeName:""}),ue(!1),P(!1),M(!1),_(!1),K(""),ne(""),Re({isValidating:!1,branchError:null,worktreeError:null,touched:!1});const w=z();N({branchName:w,worktreeName:w,isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,linkedLinearIssue:null,includePrDiff:!1})},[s,z]),ce.useEffect(()=>{if(g!=="new-branch"||!p.isSyncingWorktreeName)return;const w=js(p.branchName),H=pt(w);N(ke=>({...ke,worktreeName:H}))},[g,p.branchName,p.isSyncingWorktreeName]);const Qe=ce.useCallback(async()=>{if(!x||!ve.touched||Ce)return;He&&He.abort();const w=new AbortController;qe(w),Re(H=>({...H,isValidating:!0}));try{const H=g==="new-branch"?p.branchName:A.selectedBranch,ke=Ye.worktreeName,Ae=js(H),k=pt(ke);let oe=null,ye=null;if(Ae||(oe=r("session.newWorktree.error.branchNameRequired")),k||(ye=r("session.newWorktree.error.worktreeDirectoryRequired")),Ae&&k){const xe=g==="new-branch"?p.linkedPr:null,je=xe?xr(xe,v,$):null,C={mode:g==="existing-branch"||je?"existing":"new",branchName:Ae,worktreeName:k,existingBranch:je?.existingBranch??(g==="existing-branch"?Ae:void 0)};je?.ensureRemoteName&&(C.ensureRemoteName=je.ensureRemoteName),je?.ensureRemoteUrl&&(C.ensureRemoteUrl=je.ensureRemoteUrl);const Q=await Fr(x,C);if(w.signal.aborted)return;Q.ok||Q.errors.forEach(ie=>{if(ie.code==="worktree_exists"){ye=ye??ie.message;return}ie.code.startsWith("branch_")&&(oe=oe??ie.message)})}w.signal.aborted||Re(xe=>({...xe,isValidating:!1,branchError:oe,worktreeError:ye}))}catch{w.signal.aborted||Re(H=>({...H,isValidating:!1}))}},[x,g,p.branchName,p.linkedPr,A.selectedBranch,Ye.worktreeName,v,$,ve.touched,He,Ce,r]),Je=g==="new-branch"?p.branchName:A.selectedBranch;ce.useEffect(()=>{if(!s||!x||!ve.touched||Ce)return;const w=setTimeout(()=>{Qe()},300);return()=>clearTimeout(w)},[Ye.worktreeName,Je,s,x,Qe,ve.touched,Ce]);const De=async()=>{if(!x||!m){Ne.error(r("session.newWorktree.error.noActiveProject"));return}Re(k=>({...k,touched:!0}));const w=g==="new-branch"?p.branchName:A.selectedBranch,H=Ye.worktreeName,ke=js(w),Ae=pt(H);if(!ke){Ne.error(r("session.newWorktree.error.branchNameRequired"));return}if(!Ae){Ne.error(r("session.newWorktree.error.worktreeDirectoryRequired"));return}He&&(He.abort(),qe(null)),Re(k=>({...k,isValidating:!1,branchError:null,worktreeError:null})),Ue(!0);try{const k=g==="new-branch"?p.linkedPr:null,oe=g==="new-branch"?p.linkedIssue:null,ye=g==="new-branch"?p.linkedLinearIssue:null,xe=g==="new-branch"?p.linkedPr:null,je=g==="new-branch"?p.includePrDiff:!1,C=!!(oe||xe||ye),Q=await Pr(x),ie=p.sourceBranch;let Oe="";const be=(()=>{if(k){const Me=xr(k,v,$);Oe=Me.sourceLabel;const Ze={preferredName:ke||Ae,mode:"existing",branchName:ke,worktreeName:Ae,existingBranch:Me.existingBranch,setupCommands:Q,setUpstream:Me.setUpstream,upstreamRemote:Me.upstreamRemote,upstreamBranch:Me.upstreamBranch,returnAfterDirectoryCreated:!0};return Me.ensureRemoteName&&(Ze.ensureRemoteName=Me.ensureRemoteName),Me.ensureRemoteUrl&&(Ze.ensureRemoteUrl=Me.ensureRemoteUrl),Ze}Oe=g==="new-branch"?ie:"";const fe={preferredName:ke||Ae,mode:g==="existing-branch"?"existing":"new",branchName:g==="existing-branch"?void 0:ke,worktreeName:Ae,existingBranch:g==="existing-branch"?ke:void 0,setupCommands:Q,returnAfterDirectoryCreated:!0};return ie&&g==="new-branch"&&(fe.startRef=ie),fe})(),Le=await _a(x,be);let rt=null;if(C){await Rr(x)&&await Va(Le.path);const fe=ye?`${ye.identifier} ${ye.title}`.trim():oe?`#${oe.number} ${oe.title}`.trim():xe?`#${xe.number} ${xe.title}`.trim():r("session.newWorktree.newSessionTitle"),Me=await za(fe,Le.path,null);if(!Me?.id)throw new Error("Failed to create session");rt=Me.id,n?.(Le.path,{sessionId:rt}),e(!1),Ue(!1),Ga(Me.id,fe).catch(()=>{});try{it.getState().initializeNewOpenChamberSession(Me.id,Nt.getState().agents)}catch{}}else e(!1),Ue(!1);const Ee=jd({mode:g,sourceBranch:p.sourceBranch,linkedPr:!!p.linkedPr,selectedBranch:A.selectedBranch});Ee&&localStorage.setItem(on,Ee),Ne.success(r("session.newWorktree.toast.worktreeCreated"),{description:r("session.newWorktree.toast.worktreeCreatedDescription",{target:`${Le.branch||Le.name}${Oe?` ${r("session.newWorktree.fromSource",{source:Oe})}`:""}`})}),rt?Be({sessionId:rt,directory:Le.path,issue:oe,pr:xe,linearIssue:ye,includeDiff:je}).catch(fe=>{const Me=r(ye?"session.newWorktree.error.sendLinearContextFailed":"session.newWorktree.error.sendGitHubContextFailed"),Ze=fe instanceof Error?fe.message:Me;Ne.error(Me,{description:Ze})}):n?.(Le.path)}catch(k){const oe=k instanceof Error?k.message:r("session.newWorktree.error.createWorktreeFailed");Ne.error(r("session.newWorktree.error.createWorktreeFailed"),{description:oe})}finally{Ue(!1)}},ot=w=>{S(w),Re(H=>({...H,touched:!1,branchError:null,worktreeError:null}))},$e=w=>{if(!w){N(H=>({...H,linkedIssue:null,linkedPr:null,linkedLinearIssue:null,includePrDiff:!1,branchName:""}));return}if(w.type==="issue"){const H=w.item,ke=`issue-${H.number}-${Ls()}`;N(Ae=>({...Ae,linkedIssue:H,linkedPr:null,linkedLinearIssue:null,includePrDiff:!1,branchName:ke,worktreeName:pt(ke),isSyncingWorktreeName:!0}))}else if(w.type==="pr"){const H=w.item;N(ke=>({...ke,linkedPr:H,linkedIssue:null,linkedLinearIssue:null,includePrDiff:w.includeDiff??!1,branchName:H.head,worktreeName:pt(H.head),isSyncingWorktreeName:!0}))}},_e=w=>{const H=`issue-${w.identifier}-${Ls()}`;N(ke=>({...ke,linkedLinearIssue:{identifier:w.identifier,title:w.title,url:w.url,author:w.author},linkedIssue:null,linkedPr:null,includePrDiff:!1,branchName:H,worktreeName:pt(H),isSyncingWorktreeName:!0}))},st=d&&c?.connected===!0,Pe=!!i&&f&&u?.connected===!0,dt=(g==="existing-branch"?!!A.selectedBranch&&!!A.worktreeName&&!ve.branchError&&!ve.worktreeError:!!js(p.branchName)&&!!p.worktreeName&&!ve.branchError&&!ve.worktreeError)&&!Ce,lt=()=>{N(w=>({...w,linkedIssue:null,linkedPr:null,linkedLinearIssue:null,branchName:"",includePrDiff:!1,isSyncingWorktreeName:!0}))},ut=g==="new-branch"&&(st||Pe)?t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[st&&t.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>se(!0),className:"h-8 w-8 px-0",title:r("session.newWorktree.actions.startFromGitHubIssuePr"),"aria-label":r("session.newWorktree.actions.startFromGitHubIssuePr"),children:t.jsx(R,{name:"github",className:"size-4 text-status-success"})}),Pe&&t.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>G(!0),className:"h-8 w-8 px-0",title:r("session.newWorktree.actions.startFromLinearIssue"),"aria-label":r("session.newWorktree.actions.startFromLinearIssue"),children:t.jsx(R,{name:"linear",className:"size-4"})})]}):null,yt=t.jsxs("div",{className:le("flex gap-2",l?"flex-col w-full":"flex-row items-center"),children:[t.jsx("div",{className:le("flex items-center gap-1.5 text-destructive",l?"w-full justify-center order-first":"mr-auto"),children:ve.touched&&(ve.branchError||ve.worktreeError)&&t.jsxs(t.Fragment,{children:[t.jsx(R,{name:"error-warning",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"typography-micro",children:ve.branchError||ve.worktreeError})]})}),t.jsxs("div",{className:le("flex gap-2",l&&"w-full"),children:[t.jsx(Ie,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:Ce,className:le(l&&"flex-1"),children:r("session.newWorktree.actions.cancel")}),t.jsxs(Ie,{size:"sm",onClick:De,disabled:!dt||Ce,className:le("gap-1.5",l&&"flex-1"),children:[Ce&&t.jsx(R,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),r(Ce?"session.newWorktree.actions.creating":"session.newWorktree.actions.createWorktree")]})]})]});return t.jsxs(t.Fragment,{children:[l?t.jsxs(fs,{open:s,title:r("session.newWorktree.title"),onClose:()=>e(!1),footer:yt,children:[t.jsx("div",{className:"w-full mb-4",children:t.jsx(Ts,{items:[{id:"new-branch",label:r("session.newWorktree.mode.newBranch"),icon:t.jsx(R,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"existing-branch",label:r("session.newWorktree.mode.existingBranch"),icon:t.jsx(R,{name:"git-repository",className:"h-3.5 w-3.5"})}],activeId:g,onSelect:w=>{(w==="new-branch"||w==="existing-branch")&&ot(w)},variant:"active-pill",layoutMode:"fit",className:"w-full"})}),t.jsxs("div",{className:"space-y-6",children:[g==="existing-branch"?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.selectBranch")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(Ie,{variant:"outline",size:"sm",onClick:()=>M(!0),className:"flex-1 justify-between h-9",children:[t.jsx("span",{className:A.selectedBranch?"text-foreground":"text-muted-foreground",children:A.selectedBranch||r("session.newWorktree.chooseBranch")}),t.jsx(R,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(Ie,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:Fe,disabled:!Ge||T,title:r("session.newWorktree.fetchBranches"),children:T?t.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(R,{name:"refresh",className:"size-4"})})]}),t.jsx(fs,{open:B,title:r("session.newWorktree.selectBranch"),onClose:()=>M(!1),children:t.jsxs("div",{className:"space-y-4",ref:ge,children:[t.jsx(bt,{value:E,onChange:w=>K(w.target.value),placeholder:r("session.newWorktree.searchBranches"),className:"h-8"}),T?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):v.length===0&&$.length===0?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noBranchesFound")}):t.jsxs("div",{className:"space-y-4",children:[ae&&we&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.matchingBranches")}),t.jsx("div",{className:"space-y-1",children:Y.matching.map(w=>t.jsx("button",{onClick:()=>{L(H=>({...H,selectedBranch:w.value,worktreeName:pt(w.label)})),Re(H=>({...H,touched:!0})),M(!1)},className:le("w-full text-left px-3 py-2.5 rounded-md transition-colors",A.selectedBranch===w.value?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:w.label})},`${w.source}-${w.value}`))})]}),ae&&!we&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),!ae&&Y.otherLocal.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:Y.otherLocal.map(w=>t.jsx("button",{onClick:()=>{L(H=>({...H,selectedBranch:w,worktreeName:pt(w)})),Re(H=>({...H,touched:!0})),M(!1)},className:le("w-full text-left px-3 py-2.5 rounded-md transition-colors",A.selectedBranch===w?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:w})},w))})]}),!ae&&Y.otherRemote.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:Y.otherRemote.map(w=>t.jsx("button",{onClick:()=>{L(H=>({...H,selectedBranch:`remotes/${w}`,worktreeName:pt(w)})),Re(H=>({...H,touched:!0})),M(!1)},className:le("w-full text-left px-3 py-2.5 rounded-md transition-colors",A.selectedBranch===`remotes/${w}`?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:w})},`remotes/${w}`))})]})]})]})})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("label",{className:"typography-ui-label text-foreground font-semibold shrink-0",children:r("session.newWorktree.branchName")}),ut]}),t.jsx(bt,{value:p.branchName,onChange:w=>{N(H=>({...H,branchName:w.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null,linkedLinearIssue:null}))},onBlur:()=>Re(w=>({...w,touched:!0})),placeholder:r("session.newWorktree.branchNamePlaceholder"),disabled:!!p.linkedPr,className:le("h-8",ve.touched&&ve.branchError&&"border-destructive",p.linkedPr&&"bg-muted text-muted-foreground")}),p.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(R,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.usingPrBranch",{branch:p.linkedPr.head})})]}),p.linkedIssue&&!p.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(R,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.fromIssue",{number:p.linkedIssue.number,title:p.linkedIssue.title})})]}),p.linkedLinearIssue&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(R,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.fromLinearIssue",{identifier:p.linkedLinearIssue.identifier,title:p.linkedLinearIssue.title})})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"typography-ui-label text-foreground font-semibold",children:r("session.newWorktree.worktreeDirectory")}),g!=="existing-branch"&&t.jsxs("button",{onClick:()=>{const w=pt(g==="new-branch"?p.branchName:"");N(H=>({...H,worktreeName:w,isSyncingWorktreeName:!0}))},disabled:!p.branchName||p.worktreeName===pt(p.branchName),className:le("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",p.worktreeName===pt(p.branchName)||!p.branchName?"text-muted-foreground/40 cursor-not-allowed":"text-muted-foreground hover:text-foreground hover:bg-muted"),title:r("session.newWorktree.resetToMatchBranchName"),children:[t.jsx(R,{name:"refresh",className:"h-3 w-3"}),t.jsx("span",{children:r("session.newWorktree.actions.reset")})]})]}),t.jsx(bt,{value:Ye.worktreeName,onChange:w=>{g==="new-branch"?N(H=>({...H,worktreeName:w.target.value,isSyncingWorktreeName:!1})):L(H=>({...H,worktreeName:w.target.value}))},onBlur:()=>Re(w=>({...w,touched:!0})),placeholder:r("session.newWorktree.worktreeDirectoryPlaceholder"),className:le("h-8",ve.touched&&ve.worktreeError&&"border-destructive")})]}),g==="new-branch"&&!p.linkedPr&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.sourceBranch")}),t.jsxs(Ie,{variant:"outline",size:"sm",onClick:()=>_(!0),className:"w-full justify-between h-9",children:[t.jsx("span",{className:p.sourceBranch?"text-foreground":"text-muted-foreground",children:p.sourceBranch||r("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(R,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),p.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:r("session.newWorktree.newBranchFromSource",{source:p.sourceBranch})}),t.jsx(fs,{open:D,title:r("session.newWorktree.selectSourceBranch"),onClose:()=>_(!1),children:t.jsxs("div",{className:"space-y-4",ref:re,children:[t.jsx(bt,{value:O,onChange:w=>ne(w.target.value),placeholder:r("session.newWorktree.searchBranches"),className:"h-8"}),T?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):v.length===0&&$.length===0?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noBranchesFound")}):t.jsxs("div",{className:"space-y-4",children:[he&&Te&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.matchingBranches")}),t.jsx("div",{className:"space-y-1",children:F.matching.map(w=>t.jsx("button",{onClick:()=>{N(H=>({...H,sourceBranch:w.value})),_(!1)},className:le("w-full text-left px-3 py-2.5 rounded-md transition-colors",p.sourceBranch===w.value?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:w.label})},`${w.source}-${w.value}`))})]}),he&&!Te&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),!he&&F.otherLocal.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:F.otherLocal.map(w=>t.jsx("button",{onClick:()=>{N(H=>({...H,sourceBranch:w})),_(!1)},className:le("w-full text-left px-3 py-2.5 rounded-md transition-colors",p.sourceBranch===w?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:w})},w))})]}),!he&&F.otherRemote.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:F.otherRemote.map(w=>t.jsx("button",{onClick:()=>{N(H=>({...H,sourceBranch:`remotes/${w}`})),_(!1)},className:le("w-full text-left px-3 py-2.5 rounded-md transition-colors",p.sourceBranch===`remotes/${w}`?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:w})},`remotes/${w}`))})]})]})]})})]}),(p.linkedIssue||p.linkedPr||p.linkedLinearIssue)&&g==="new-branch"&&t.jsxs("div",{className:"mt-2 px-2 py-1.5 rounded bg-muted/30",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(R,{name:p.linkedLinearIssue?"linear":"github",className:le("h-3.5 w-3.5 shrink-0",p.linkedLinearIssue?"text-foreground":"text-status-success")}),p.linkedLinearIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:p.linkedLinearIssue.identifier}),p.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.issueNumber",{number:p.linkedIssue.number})}),p.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.prNumber",{number:p.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:p.linkedLinearIssue?.title||p.linkedIssue?.title||p.linkedPr?.title}),t.jsx("a",{href:p.linkedLinearIssue?.url||p.linkedIssue?.url||p.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:w=>w.stopPropagation(),children:t.jsx(R,{name:"external-link",className:"h-3 w-3"})}),t.jsx("button",{onClick:lt,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})})]}),p.linkedPr&&t.jsxs("div",{className:"flex items-center gap-2 mt-0.5 pl-5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[p.linkedPr.head," → ",p.linkedPr.base]}),p.includePrDiff&&t.jsx("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success",children:r("session.newWorktree.includeDiffBadge")})]})]})]})]}):t.jsx(Ds,{open:s,onOpenChange:e,children:t.jsxs(Ps,{className:"max-w-lg max-h-[80vh] flex flex-col",children:[t.jsx(Ks,{className:"flex flex-row items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(Rs,{className:"flex items-center gap-2 shrink-0",children:[t.jsx(R,{name:"git-branch",className:"h-5 w-5"}),r("session.newWorktree.title")]}),t.jsx("div",{className:"w-[280px] shrink-0",children:t.jsx(Ts,{items:[{id:"new-branch",label:r("session.newWorktree.mode.newBranch"),icon:t.jsx(R,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"existing-branch",label:r("session.newWorktree.mode.existingBranch"),icon:t.jsx(R,{name:"git-repository",className:"h-3.5 w-3.5"})}],activeId:g,onSelect:w=>{(w==="new-branch"||w==="existing-branch")&&ot(w)},variant:"active-pill",layoutMode:"fit",className:"w-full"})})]})}),t.jsxs("div",{className:"flex-1 overflow-y-auto mt-2 space-y-6",children:[g==="existing-branch"?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.selectBranch")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(zt,{open:ee,onOpenChange:ue,children:[t.jsx(Gt,{asChild:!0,children:t.jsxs("button",{type:"button",className:le(Hn({size:"default"}),"min-w-[220px] max-w-full"),children:[t.jsx("span",{className:le("truncate",A.selectedBranch?"text-foreground":"text-muted-foreground"),children:A.selectedBranch||r("session.newWorktree.chooseBranch")}),t.jsx(R,{name:"arrow-down-s",className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),t.jsx(Ht,{align:"start",sideOffset:6,portalToBody:!0,className:"w-[min(42rem,calc(100vw-2rem))] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",ref:X,children:t.jsxs(xn,{shouldFilter:!1,children:[t.jsx(bn,{placeholder:r("session.newWorktree.searchBranches"),value:E,onValueChange:K,onKeyDown:pe}),t.jsx(yn,{disableHorizontal:!0,children:T?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):v.length===0&&$.length===0?t.jsx(wn,{children:r("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[ae&&we&&t.jsx(At,{heading:r("session.newWorktree.matchingBranches"),children:Y.matching.map(w=>t.jsx(Dt,{value:w.value,onSelect:()=>{L(H=>({...H,selectedBranch:w.value,worktreeName:pt(w.label)})),Re(H=>({...H,touched:!0})),ue(!1)},children:t.jsx("span",{className:"typography-small break-all",children:w.label})},`${w.source}-${w.value}`))}),ae&&!we&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),!ae&&Y.otherLocal.length>0&&t.jsx(t.Fragment,{children:t.jsx(At,{heading:r("session.newWorktree.localBranches"),children:Y.otherLocal.map(w=>t.jsx(Dt,{value:w,onSelect:()=>{L(H=>({...H,selectedBranch:w,worktreeName:pt(w)})),Re(H=>({...H,touched:!0})),ue(!1)},children:t.jsx("span",{className:"typography-small break-all",children:w})},`local-${w}`))})}),!ae&&Y.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[Y.otherLocal.length>0&&t.jsx(Ns,{}),t.jsx(At,{heading:r("session.newWorktree.remoteBranches"),children:Y.otherRemote.map(w=>t.jsx(Dt,{value:`remotes/${w}`,onSelect:()=>{L(H=>({...H,selectedBranch:`remotes/${w}`,worktreeName:pt(w)})),Re(H=>({...H,touched:!0})),ue(!1)},children:t.jsx("span",{className:"typography-small break-all",children:w})},`remote-${w}`))})]})]})})]})})]}),t.jsx(Ie,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:Fe,disabled:!Ge||T,title:r("session.newWorktree.fetchBranches"),children:T?t.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(R,{name:"refresh",className:"size-4"})})]})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("label",{className:"typography-ui-label text-foreground font-semibold shrink-0",children:r("session.newWorktree.branchName")}),ut]}),t.jsx(bt,{value:p.branchName,onChange:w=>{N(H=>({...H,branchName:w.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null,linkedLinearIssue:null}))},onBlur:()=>Re(w=>({...w,touched:!0})),placeholder:r("session.newWorktree.branchNamePlaceholder"),disabled:!!p.linkedPr,className:le("h-8",ve.touched&&ve.branchError&&"border-destructive",p.linkedPr&&"bg-muted text-muted-foreground")}),p.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(R,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.usingPrBranch",{branch:p.linkedPr.head})})]}),p.linkedIssue&&!p.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(R,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.fromIssue",{number:p.linkedIssue.number,title:p.linkedIssue.title})})]}),p.linkedLinearIssue&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(R,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.fromLinearIssue",{identifier:p.linkedLinearIssue.identifier,title:p.linkedLinearIssue.title})})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"typography-ui-label text-foreground font-semibold",children:r("session.newWorktree.worktreeDirectory")}),g!=="existing-branch"&&t.jsxs("button",{onClick:()=>{const w=pt(g==="new-branch"?p.branchName:"");N(H=>({...H,worktreeName:w,isSyncingWorktreeName:!0}))},disabled:!p.branchName||p.worktreeName===pt(p.branchName),className:le("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",p.worktreeName===pt(p.branchName)||!p.branchName?"text-muted-foreground/40 cursor-not-allowed":"text-muted-foreground hover:text-foreground hover:bg-muted"),title:r("session.newWorktree.resetToMatchBranchName"),children:[t.jsx(R,{name:"refresh",className:"h-3 w-3"}),t.jsx("span",{children:r("session.newWorktree.actions.reset")})]})]}),t.jsx(bt,{value:Ye.worktreeName,onChange:w=>{g==="new-branch"?N(H=>({...H,worktreeName:w.target.value,isSyncingWorktreeName:!1})):L(H=>({...H,worktreeName:w.target.value}))},onBlur:()=>Re(w=>({...w,touched:!0})),placeholder:r("session.newWorktree.worktreeDirectoryPlaceholder"),className:le("h-8",ve.touched&&ve.worktreeError&&"border-destructive")})]}),g==="new-branch"&&!p.linkedPr&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.sourceBranch")}),t.jsxs(zt,{open:V,onOpenChange:P,children:[t.jsx(Gt,{asChild:!0,children:t.jsxs("button",{type:"button",className:le(Hn({size:"default"}),"min-w-[220px] max-w-full"),children:[t.jsx("span",{className:le("truncate",p.sourceBranch?"text-foreground":"text-muted-foreground"),children:p.sourceBranch||r("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(R,{name:"arrow-down-s",className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),t.jsx(Ht,{align:"start",portalToBody:!0,className:"w-[min(42rem,calc(100vw-2rem))] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",ref:te,children:t.jsxs(xn,{shouldFilter:!1,children:[t.jsx(bn,{placeholder:r("session.newWorktree.searchBranches"),value:O,onValueChange:ne,onKeyDown:pe}),t.jsx(yn,{disableHorizontal:!0,children:T?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):v.length===0&&$.length===0?t.jsx(wn,{children:r("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[he&&Te&&t.jsx(At,{heading:r("session.newWorktree.matchingBranches"),children:F.matching.map(w=>t.jsx(Dt,{value:w.value,onSelect:()=>{N(H=>({...H,sourceBranch:w.value})),P(!1)},children:t.jsx("span",{className:"typography-small break-all",children:w.label})},`${w.source}-${w.value}`))}),he&&!Te&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),!he&&F.otherLocal.length>0&&t.jsx(t.Fragment,{children:t.jsx(At,{heading:r("session.newWorktree.localBranches"),children:F.otherLocal.map(w=>t.jsx(Dt,{value:w,onSelect:()=>{N(H=>({...H,sourceBranch:w})),P(!1)},children:t.jsx("span",{className:"typography-small break-all",children:w})},`local-${w}`))})}),!he&&F.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[F.otherLocal.length>0&&t.jsx(Ns,{}),t.jsx(At,{heading:r("session.newWorktree.remoteBranches"),children:F.otherRemote.map(w=>t.jsx(Dt,{value:`remotes/${w}`,onSelect:()=>{N(H=>({...H,sourceBranch:`remotes/${w}`})),P(!1)},children:t.jsx("span",{className:"typography-small break-all",children:w})},`remote-${w}`))})]})]})})]})})]}),p.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:r("session.newWorktree.newBranchFromSource",{source:p.sourceBranch})})]}),(p.linkedIssue||p.linkedPr||p.linkedLinearIssue)&&g==="new-branch"&&t.jsxs("div",{className:"mt-2 px-2 py-1.5 rounded bg-muted/30",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(R,{name:p.linkedLinearIssue?"linear":"github",className:le("h-3.5 w-3.5 shrink-0",p.linkedLinearIssue?"text-foreground":"text-status-success")}),p.linkedLinearIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:p.linkedLinearIssue.identifier}),p.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.issueNumber",{number:p.linkedIssue.number})}),p.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.prNumber",{number:p.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:p.linkedLinearIssue?.title||p.linkedIssue?.title||p.linkedPr?.title}),t.jsx("a",{href:p.linkedLinearIssue?.url||p.linkedIssue?.url||p.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:w=>w.stopPropagation(),children:t.jsx(R,{name:"external-link",className:"h-3 w-3"})}),t.jsx("button",{onClick:lt,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})})]}),p.linkedPr&&t.jsxs("div",{className:"flex items-center gap-2 mt-0.5 pl-5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[p.linkedPr.head," → ",p.linkedPr.base]}),p.includePrDiff&&t.jsx("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success",children:r("session.newWorktree.includeDiffBadge")})]})]})]}),t.jsxs(An,{className:"mt-1 flex items-center justify-between",children:[t.jsx("div",{className:"flex items-center gap-1.5 text-destructive",children:ve.touched&&(ve.branchError||ve.worktreeError)&&t.jsxs(t.Fragment,{children:[t.jsx(R,{name:"error-warning",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"typography-micro",children:ve.branchError||ve.worktreeError})]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ie,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:Ce,children:r("session.newWorktree.actions.cancel")}),t.jsxs(Ie,{size:"sm",onClick:De,disabled:!dt||Ce,className:"gap-1.5",children:[Ce&&t.jsx(R,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),r(Ce?"session.newWorktree.actions.creating":"session.newWorktree.actions.createWorktree")]})]})]})]})}),t.jsx(kd,{open:q,onOpenChange:se,onSelect:$e}),t.jsx(Ua,{open:J,onOpenChange:G,mode:"select",onSelect:_e})]})}const Pd=2880*60*1e3,Rd=s=>!!s.parentID,Ed=s=>!!s.time?.archived,Ad=s=>{const e=s.time?.updated,n=s.time?.created;return typeof e=="number"&&Number.isFinite(e)?e:typeof n=="number"&&Number.isFinite(n)?n:0},Bd=(s,e,n=Date.now())=>{const r=n-Pd;return s.filter(o=>Ed(o)||Rd(o)?!1:e.has(o.id)||Ad(o)>=r)},um=({sessions:s,getSessionLocation:e,getSessionNode:n,query:r})=>[{key:"active-now",items:s.flatMap(o=>{const a=typeof o.title=="string"?o.title.toLowerCase():"";if(r&&!a.includes(r))return[];const i=e(o.id);return[{node:n?.(o)??{session:o,children:[],worktree:null},projectId:i?.projectId??null,groupDirectory:i?.groupDirectory??o.directory??null,secondaryMeta:i?{projectLabel:i.projectLabel,branchLabel:i.branchLabel}:null}]})}],jo=s=>s.parentID??null,Ld=(s,e)=>{const n=[],r=[];for(const o of s)if(!Ha(o)){if(Ka(o.directory)){if(e)continue;r.push(o);continue}n.push(o)}return{projectSessions:n,chatSessions:r}},Md=new Set,Fd=(s,e,n)=>{if(s.time?.archived)return!0;const r=zs(Mr(s))?.toLowerCase();return!r||e.size===0?!n:e.has(r)},Od=(s,e)=>{const n=[...s],r=new Set(s.map(o=>o.id));for(const o of e)r.has(o.id)||(r.add(o.id),n.push(o));return n},$d=(s,e)=>{const n=[],r=new Set([e]),o=a=>{for(const i of s.get(a)??[])r.has(i.id)||(r.add(i.id),n.push(i.id),o(i.id))};return o(e),n},Ud=({globalActiveSessions:s,liveSessions:e,knownDirectories:n,isVSCode:r,globalStructure:o})=>{$r("sidebarStructureBuilds");const i=Od(s??[],e),l=Ld(i,r),c=l.projectSessions.filter(g=>Fd(g,n,r)),d=[...c,...l.chatSessions],u=new Map(d.map(g=>[g.id,g])),f=new Set(c.map(g=>g.id)),b=o?.activeRootIds??[],m=new Set(b),x=[...b.flatMap(g=>{if(!f.has(g))return[];const S=u.get(g);return S?[S]:[]}),...c.filter(g=>!m.has(g.id)&&!jo(g))];return{chatSessionIds:new Set(l.chatSessions.map(g=>g.id)),projectSessions:c,rootSessions:x,sessionById:u,sessions:d,hierarchy:o?{rootIds:o.activeRootIds,childrenByParentId:o.activeChildrenByParentId}:void 0}},Wd=(s,e,n)=>{const r=Ur(s.sessions,e,n,s.hierarchy),o=new Map;for(const a of r){const i=jo(a);if(!i)continue;const l=o.get(i)??[];l.push(a),o.set(i,l)}return{chatSessions:r.filter(a=>s.chatSessionIds.has(a.id)),childrenMap:o,orderedSessions:r}},fm=s=>{const e=ze.c(33),{knownDirectories:n,isVSCode:r,isVisible:o}=s,a=Yt(_d),i=Yt(Vd),l=Yt(zd),c=Yt(Gd),d=qa(),u=Ya(Hd);let f;e[0]!==o?(f=W=>o?W.rankById:Xa,e[0]=o,e[1]=f):f=e[1];const b=Ja(f);let m;e[2]!==a||e[3]!==i||e[4]!==r||e[5]!==n||e[6]!==d?(m=Ud({globalActiveSessions:a,globalStructure:i,liveSessions:d,knownDirectories:n,isVSCode:r}),e[2]=a,e[3]=i,e[4]=r,e[5]=n,e[6]=d,e[7]=m):m=e[7];const x=m;let g;e[8]!==u||e[9]!==b||e[10]!==x?(g=Wd(x,u,b),e[8]=u,e[9]=b,e[10]=x,e[11]=g):g=e[11];const S=g,{chatSessions:p,orderedSessions:N}=S,A=x.projectSessions;let L;e[12]!==l||e[13]!==x.sessions?(L=new Map([...x.sessions,...l].map(Kd)),e[12]=l,e[13]=x.sessions,e[14]=L):L=e[14];const I=L;let T;if(e[15]!==l||e[16]!==S.childrenMap){T=new Map(S.childrenMap);for(const W of l){const z=W.parentID;if(!z)continue;const q=T.get(z)??[];q.push(W),T.set(z,q)}e[15]=l,e[16]=S.childrenMap,e[17]=T}else T=e[17];const y=T;let v;e[18]!==y||e[19]!==I?(v=(W,z)=>$d(y,W).filter(q=>z.includeArchived||!I.get(q)?.time?.archived),e[18]=y,e[19]=I,e[20]=v):v=e[20];const $=v;let U;return e[21]!==l||e[22]!==p||e[23]!==y||e[24]!==$||e[25]!==c||e[26]!==d||e[27]!==N||e[28]!==u||e[29]!==b||e[30]!==A||e[31]!==x.rootSessions?(U={archivedSessions:l,childrenMap:y,chatSessions:p,getDescendantIds:$,hasAuthoritativeGlobalSessions:c,liveSessions:d,orderedSessions:N,pinnedSessionIds:u,sessionOrderRanks:b,sessions:A,rootSessions:x.rootSessions},e[21]=l,e[22]=p,e[23]=y,e[24]=$,e[25]=c,e[26]=d,e[27]=N,e[28]=u,e[29]=b,e[30]=A,e[31]=x.rootSessions,e[32]=U):U=e[32],U},mm=s=>{const e=ze.c(9),{enabled:n,isVSCode:r,pinnedSessionIds:o,sessionOrderRanks:a,sessions:i}=s;let l;e[0]!==n||e[1]!==r?(l=u=>n&&!r?u.activeSessionIds:Md,e[0]=n,e[1]=r,e[2]=l):l=e[2];const c=Qa(l);let d;e:{if(!n||r){let f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=[],e[3]=f):f=e[3],d=f;break e}$r("recentCandidatesVisited",i.length);let u;e[4]!==c||e[5]!==o||e[6]!==a||e[7]!==i?(u=Ur(Bd(i,c),o,a),e[4]=c,e[5]=o,e[6]=a,e[7]=i,e[8]=u):u=e[8],d=u}return d};function _d(s){return s.activeSessions}function Vd(s){return s.structure}function zd(s){return s.archivedSessions}function Gd(s){return s.status==="ready"}function Hd(s){return s.ids}function Kd(s){return[s.id,s]}const On=(s,e)=>s==="global"?"global":`project:${e??""}`,No=(s,e)=>s.createdAt>e?"new":s.updatedAt>e?"changed":null,br=(s,e)=>s.reduce((n,r)=>No(r,e)?n+1:n,0),ko=s=>{const e=ze.c(29),{expanded:n,onToggleExpanded:r,header:o,children:a,actions:i,footer:l,expandLabel:c}=s,{t:d}=nt(),u=!n&&"cursor-pointer hover:border-[var(--interactive-border)] hover:bg-interactive-hover/30";let f;e[0]!==u?(f=le("flex flex-col gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2 py-1.5",u),e[0]=u,e[1]=f):f=e[1];const b=n?void 0:r;let m;e[2]!==n||e[3]!==r?(m=n?void 0:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),r())},e[2]=n,e[3]=r,e[4]=m):m=e[4];const x=n?void 0:"button",g=n?void 0:0,S=n?void 0:c;let p;e[5]!==a||e[6]!==o?(p=t.jsxs("div",{className:"min-w-0 flex-1",children:[o,a]}),e[5]=a,e[6]=o,e[7]=p):p=e[7];let N;e[8]!==n||e[9]!==r||e[10]!==d?(N=n?t.jsx("button",{type:"button",onClick:r,className:"inline-flex h-6 w-6 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("rightSidebar.contextNotesTodo.notes.actions.collapse"),title:d("rightSidebar.contextNotesTodo.notes.actions.collapse"),children:t.jsx(R,{name:"arrow-up-s",className:"h-3.5 w-3.5"})}):null,e[8]=n,e[9]=r,e[10]=d,e[11]=N):N=e[11];let A;e[12]!==i||e[13]!==N?(A=t.jsxs("div",{className:"flex flex-shrink-0 flex-col items-center gap-0.5",onClick:qd,onKeyDown:Yd,children:[N,i]}),e[12]=i,e[13]=N,e[14]=A):A=e[14];let L;e[15]!==A||e[16]!==p?(L=t.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[p,A]}),e[15]=A,e[16]=p,e[17]=L):L=e[17];let I;e[18]!==l?(I=l?t.jsx("div",{className:"min-w-0",children:l}):null,e[18]=l,e[19]=I):I=e[19];let T;return e[20]!==L||e[21]!==I||e[22]!==f||e[23]!==b||e[24]!==m||e[25]!==x||e[26]!==g||e[27]!==S?(T=t.jsxs("li",{className:f,onClick:b,onKeyDown:m,role:x,tabIndex:g,"aria-label":S,children:[L,I]}),e[20]=L,e[21]=I,e[22]=f,e[23]=b,e[24]=m,e[25]=x,e[26]=g,e[27]=S,e[28]=T):T=e[28],T};function qd(s){return s.stopPropagation()}function Yd(s){return s.stopPropagation()}const Jd=s=>{const e=ze.c(52),{entry:n,badge:r,expanded:o,onToggleExpanded:a,onSave:i,onDelete:l}=s,{t:c}=nt(),[d,u]=h.useState(n.title),[f,b]=h.useState(n.body);let m,x;e[0]!==n.body||e[1]!==n.title||e[2]!==o?(m=()=>{o||(u(n.title),b(n.body))},x=[n.body,n.title,o],e[0]=n.body,e[1]=n.title,e[2]=o,e[3]=m,e[4]=x):(m=e[3],x=e[4]),h.useEffect(m,x);let g;e[5]!==f||e[6]!==n.body||e[7]!==n.title||e[8]!==i||e[9]!==d?(g=()=>{const J=d.trim(),G=f.trim();if(!J||!G){u(n.title),b(n.body);return}J===n.title&&G===n.body||i({title:J,body:G})},e[5]=f,e[6]=n.body,e[7]=n.title,e[8]=i,e[9]=d,e[10]=g):g=e[10];const S=g,p=`rightSidebar.contextNotesTodo.memory.type.${n.type}`;let N;e[11]!==c||e[12]!==p?(N=c(p),e[11]=c,e[12]=p,e[13]=N):N=e[13];const A=N;let L;e[14]!==S||e[15]!==o||e[16]!==a?(L=()=>{o&&S(),a()},e[14]=S,e[15]=o,e[16]=a,e[17]=L):L=e[17];const I=n.title;let T;e[18]!==n.flagged||e[19]!==c?(T=n.flagged?t.jsxs("span",{className:"flex items-center gap-1 text-[var(--status-error)]",children:[t.jsx(R,{name:"error-warning",className:"h-3 w-3 flex-shrink-0"}),c("rightSidebar.contextNotesTodo.memory.flagged")]}):null,e[18]=n.flagged,e[19]=c,e[20]=T):T=e[20];let y;e[21]!==T||e[22]!==A?(y=t.jsxs("span",{className:"flex flex-wrap items-center gap-x-2 typography-micro text-muted-foreground",children:[A,T]}),e[21]=T,e[22]=A,e[23]=y):y=e[23];let v;e[24]!==r||e[25]!==c?(v=r?t.jsx("span",{className:le("mb-0.5 mr-1.5 inline-block rounded-full px-1.5 py-px typography-micro font-medium",r==="new"?"bg-[var(--status-success)]/15 text-[var(--status-success)]":"bg-[var(--status-warning)]/15 text-[var(--status-warning)]"),children:c(r==="new"?"rightSidebar.contextNotesTodo.memory.badge.new":"rightSidebar.contextNotesTodo.memory.badge.changed")}):null,e[24]=r,e[25]=c,e[26]=v):v=e[26];let $;e[27]!==c?($=c("rightSidebar.contextNotesTodo.memory.actions.delete"),e[27]=c,e[28]=$):$=e[28];let U;e[29]!==c?(U=c("rightSidebar.contextNotesTodo.memory.actions.delete"),e[29]=c,e[30]=U):U=e[30];let W;e[31]===Symbol.for("react.memo_cache_sentinel")?(W=t.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"}),e[31]=W):W=e[31];let z;e[32]!==l||e[33]!==$||e[34]!==U?(z=t.jsx("button",{type:"button",onClick:l,className:"inline-flex h-6 w-6 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":$,title:U,children:W}),e[32]=l,e[33]=$,e[34]=U,e[35]=z):z=e[35];let q;e[36]!==f||e[37]!==S||e[38]!==n.body||e[39]!==n.title||e[40]!==o||e[41]!==c||e[42]!==d?(q=o?t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(bt,{value:d,onChange:J=>u(J.target.value.slice(0,Za)),onBlur:S,"aria-label":c("rightSidebar.contextNotesTodo.memory.actions.editTitle"),className:"h-7 typography-ui-label"}),t.jsx(qs,{simple:!0,rows:Math.min(20,Math.max(3,f.split(`
|
|
6
|
-
`).length+1)),value:f,onChange:J=>b(J.target.value.slice(0,ei)),onBlur:S,"aria-label":c("rightSidebar.contextNotesTodo.memory.actions.editBody"),className:"min-h-0 w-full resize-none bg-transparent p-0 typography-meta leading-normal text-muted-foreground focus-visible:outline-none focus-visible:ring-0"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",children:n.title}),t.jsx("p",{className:"line-clamp-2 whitespace-pre-wrap break-words typography-meta text-muted-foreground",children:n.body})]}),e[36]=f,e[37]=S,e[38]=n.body,e[39]=n.title,e[40]=o,e[41]=c,e[42]=d,e[43]=q):q=e[43];let se;return e[44]!==n.title||e[45]!==o||e[46]!==v||e[47]!==z||e[48]!==q||e[49]!==L||e[50]!==y?(se=t.jsx(ko,{expanded:o,onToggleExpanded:L,expandLabel:I,footer:y,header:v,actions:z,children:q}),e[44]=n.title,e[45]=o,e[46]=v,e[47]=z,e[48]=q,e[49]=L,e[50]=y,e[51]=se):se=e[51],se},Qd=s=>{const e=ze.c(59),{projectPath:n,query:r}=s,{t:o}=nt(),[a,i]=h.useState("project"),[l,c]=h.useState(null),d=Tt(Xd);let u;e[0]!==n?(u=X=>Wr(X,n),e[0]=n,e[1]=u):u=e[1];const f=Tt(u),b=Tt(Zd),m=Tt(eu),x=Tt(tu),g=Tt(su),S=Ve(nu),p=a==="global"?d:f,N=a==="global"?b:m;let A;e[2]!==n||e[3]!==a?(A=On(a,n),e[2]=n,e[3]=a,e[4]=A):A=e[4];const L=A;let I;e[5]!==L?(I=X=>X.agentMemoryViewedAt[L]??0,e[5]=L,e[6]=I):I=e[6];const T=Ve(I),y=h.useRef(T),[v,$]=h.useState(T);let U,W;e[7]!==S||e[8]!==L?(U=()=>(y.current=Ve.getState().agentMemoryViewedAt[L]??0,$(y.current),()=>{S(L,Date.now())}),W=[S,L],e[7]=S,e[8]=L,e[9]=U,e[10]=W):(U=e[9],W=e[10]),h.useEffect(U,W);let z;if(e[11]!==p||e[12]!==r){let X;e[14]!==r?(X=te=>Ys([te.title,te.body],r),e[14]=r,e[15]=X):X=e[15],z=p.filter(X),e[11]=p,e[12]=r,e[13]=z}else z=e[13];const q=z;let se;e[16]!==x||e[17]!==a||e[18]!==o?(se=async X=>{if(!await x(a,X)){const te=Tt.getState().error;Ne.error(o("rightSidebar.contextNotesTodo.memory.toast.deleteFailed"),te?{description:te}:void 0)}},e[16]=x,e[17]=a,e[18]=o,e[19]=se):se=e[19];const J=se;let G;e[20]!==g||e[21]!==a||e[22]!==o?(G=async(X,te)=>{if(!await g(a,X,te)){const ge=Tt.getState().error;Ne.error(o("rightSidebar.contextNotesTodo.memory.toast.saveFailed"),ge?{description:ge}:void 0)}},e[20]=g,e[21]=a,e[22]=o,e[23]=G):G=e[23];const ee=G;let ue;e[24]!==o?(ue=o("rightSidebar.contextNotesTodo.memory.scope.project"),e[24]=o,e[25]=ue):ue=e[25];let V;e[26]!==f.length||e[27]!==ue?(V={id:"project",label:ue,count:f.length},e[26]=f.length,e[27]=ue,e[28]=V):V=e[28];let P;e[29]!==o?(P=o("rightSidebar.contextNotesTodo.memory.scope.global"),e[29]=o,e[30]=P):P=e[30];let B;e[31]!==d.length||e[32]!==P?(B={id:"global",label:P,count:d.length},e[31]=d.length,e[32]=P,e[33]=B):B=e[33];let M;e[34]!==V||e[35]!==B?(M=[V,B],e[34]=V,e[35]=B,e[36]=M):M=e[36];const D=M;let _;e[37]!==o?(_=o("rightSidebar.contextNotesTodo.memory.scope.label"),e[37]=o,e[38]=_):_=e[38];let E;e[39]!==a||e[40]!==D?(E=D.map(X=>t.jsx(Ie,{type:"button",variant:"chip",size:"xs","aria-pressed":a===X.id,className:"!font-normal",onClick:()=>i(X.id),children:`${X.label} ${X.count}`},X.id)),e[39]=a,e[40]=D,e[41]=E):E=e[41];let K;e[42]!==_||e[43]!==E?(K=t.jsx("div",{role:"group","aria-label":_,className:"flex items-center gap-1",children:E}),e[42]=_,e[43]=E,e[44]=K):K=e[44];let O;e[45]!==v||e[46]!==l||e[47]!==J||e[48]!==ee||e[49]!==n||e[50]!==r||e[51]!==a||e[52]!==N||e[53]!==o||e[54]!==q?(O=a==="project"&&!n?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("rightSidebar.contextNotesTodo.memory.empty.noProject")}):N?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("rightSidebar.contextNotesTodo.memory.empty.unavailable")}):q.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:r.trim()?o("rightSidebar.contextNotesTodo.memory.empty.noMatches"):o("rightSidebar.contextNotesTodo.memory.empty.nothing")}):t.jsx("ul",{className:"flex flex-col gap-1.5",children:q.map(X=>t.jsx(Jd,{entry:X,badge:No(X,v),expanded:l===X.id,onToggleExpanded:()=>c(l===X.id?null:X.id),onSave:te=>{ee(X.id,te)},onDelete:()=>{J(X.id)}},X.id))}),e[45]=v,e[46]=l,e[47]=J,e[48]=ee,e[49]=n,e[50]=r,e[51]=a,e[52]=N,e[53]=o,e[54]=q,e[55]=O):O=e[55];let ne;return e[56]!==K||e[57]!==O?(ne=t.jsxs("div",{className:"flex flex-col gap-2",children:[K,O]}),e[56]=K,e[57]=O,e[58]=ne):ne=e[58],ne};function Xd(s){return s.global}function Zd(s){return s.globalFailed}function eu(s){return s.projectFailed}function tu(s){return s.deleteEntry}function su(s){return s.saveEntry}function nu(s){return s.markAgentMemoryViewed}const ru=400,ou=s=>{const e=ze.c(61),{note:n,pinned:r,expanded:o,onToggleExpanded:a,onSaveBody:i,onTogglePinned:l,onDelete:c}=s,{t:d}=nt(),[u,f]=h.useState(n.body),b=h.useRef(n.body),m=h.useRef(null);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{m.current!==null&&(window.clearTimeout(m.current),m.current=null)},e[0]=x):x=e[0];const g=x;let S,p;e[1]!==u||e[2]!==n.body?(S=()=>{n.body!==b.current&&u===b.current&&(b.current=n.body,f(n.body))},p=[u,n.body],e[1]=u,e[2]=n.body,e[3]=S,e[4]=p):(S=e[3],p=e[4]),h.useEffect(S,p);let N,A;e[5]!==u||e[6]!==i?(N=()=>{if(u!==b.current)return m.current=window.setTimeout(()=>{m.current=null,u.trim()&&(b.current=u,i(u))},ru),g},A=[g,u,i],e[5]=u,e[6]=i,e[7]=N,e[8]=A):(N=e[7],A=e[8]),h.useEffect(N,A);let L,I;e[9]===Symbol.for("react.memo_cache_sentinel")?(L=()=>g,I=[g],e[9]=L,e[10]=I):(L=e[9],I=e[10]),h.useEffect(L,I);let T;e[11]!==u||e[12]!==i?(T=()=>{if(g(),u!==b.current){if(!u.trim()){f(b.current);return}b.current=u,i(u)}},e[11]=u,e[12]=i,e[13]=T):T=e[13];const y=T;let v;e[14]!==n.source||e[15]!==d?(v=n.source==="selection"?d("rightSidebar.contextNotesTodo.notes.source.selection"):n.source==="agent"?d("rightSidebar.contextNotesTodo.notes.source.agent"):null,e[14]=n.source,e[15]=d,e[16]=v):v=e[16];const $=v;let U;e[17]!==d?(U=d("rightSidebar.contextNotesTodo.notes.actions.expand"),e[17]=d,e[18]=U):U=e[18];let W;e[19]!==$?(W=$?t.jsx("span",{className:"typography-micro text-muted-foreground",children:$}):null,e[19]=$,e[20]=W):W=e[20];const z=r?"text-primary":"text-muted-foreground hover:text-foreground";let q;e[21]!==z?(q=le("inline-flex h-6 w-6 items-center justify-center rounded-md hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",z),e[21]=z,e[22]=q):q=e[22];let se;e[23]!==r||e[24]!==d?(se=d(r?"rightSidebar.contextNotesTodo.notes.actions.unpin":"rightSidebar.contextNotesTodo.notes.actions.pin"),e[23]=r,e[24]=d,e[25]=se):se=e[25];let J;e[26]!==r||e[27]!==d?(J=d(r?"rightSidebar.contextNotesTodo.notes.actions.unpin":"rightSidebar.contextNotesTodo.notes.actions.pin"),e[26]=r,e[27]=d,e[28]=J):J=e[28];const G=r?"pushpin-2-fill":"pushpin";let ee;e[29]!==G?(ee=t.jsx(R,{name:G,className:"h-3.5 w-3.5"}),e[29]=G,e[30]=ee):ee=e[30];let ue;e[31]!==l||e[32]!==r||e[33]!==q||e[34]!==se||e[35]!==J||e[36]!==ee?(ue=t.jsx("button",{type:"button",onClick:l,className:q,"aria-pressed":r,"aria-label":se,title:J,children:ee}),e[31]=l,e[32]=r,e[33]=q,e[34]=se,e[35]=J,e[36]=ee,e[37]=ue):ue=e[37];let V;e[38]!==d?(V=d("rightSidebar.contextNotesTodo.notes.actions.delete"),e[38]=d,e[39]=V):V=e[39];let P;e[40]!==d?(P=d("rightSidebar.contextNotesTodo.notes.actions.delete"),e[40]=d,e[41]=P):P=e[41];let B;e[42]===Symbol.for("react.memo_cache_sentinel")?(B=t.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"}),e[42]=B):B=e[42];let M;e[43]!==c||e[44]!==V||e[45]!==P?(M=t.jsx("button",{type:"button",onClick:c,className:"inline-flex h-6 w-6 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":V,title:P,children:B}),e[43]=c,e[44]=V,e[45]=P,e[46]=M):M=e[46];let D;e[47]!==ue||e[48]!==M?(D=t.jsxs(t.Fragment,{children:[ue,M]}),e[47]=ue,e[48]=M,e[49]=D):D=e[49];let _;e[50]!==u||e[51]!==o||e[52]!==y?(_=o?t.jsx(qs,{simple:!0,autoFocus:!0,rows:Math.min(20,Math.max(3,u.split(`
|
|
7
|
-
`).length+1)),value:u,onChange:K=>f(K.target.value.slice(0,jn)),onBlur:y,className:"min-h-0 w-full resize-none bg-transparent p-0 typography-ui-label leading-normal text-foreground focus-visible:outline-none focus-visible:ring-0"}):t.jsx("p",{className:"line-clamp-3 whitespace-pre-wrap break-words typography-ui-label leading-normal text-foreground",title:u,children:u}),e[50]=u,e[51]=o,e[52]=y,e[53]=_):_=e[53];let E;return e[54]!==o||e[55]!==a||e[56]!==U||e[57]!==W||e[58]!==D||e[59]!==_?(E=t.jsx(ko,{expanded:o,onToggleExpanded:a,expandLabel:U,footer:W,actions:D,children:_}),e[54]=o,e[55]=a,e[56]=U,e[57]=W,e[58]=D,e[59]=_,e[60]=E):E=e[60],E},au=s=>{const e=ze.c(69),{projectRef:n,notes:r,disabled:o,query:a,pinnedNoteIds:i,onTogglePinned:l}=s,{t:c}=nt(),[d,u]=h.useState(""),[f,b]=h.useState(null),m=Ve(iu),x=Ve(lu),g=Rt(cu),S=Rt(du),p=Rt(uu);let N;if(e[0]!==r||e[1]!==a){let O;e[3]!==a?(O=ne=>Ys([ne.body],a),e[3]=a,e[4]=O):O=e[4],N=r.filter(O),e[0]=r,e[1]=a,e[2]=N}else N=e[2];const A=N;let L;e[5]!==n?(L=O=>{const ne=Rt.getState().getEntry(n).error;Ne.error(O,ne?{description:ne}:void 0)},e[5]=n,e[6]=L):L=e[6];const I=L;let T;e[7]!==d||e[8]!==g||e[9]!==n||e[10]!==I||e[11]!==c?(T=async()=>{const O=d.trim();if(!O)return;if(!await g(n,{body:O})){I(c("rightSidebar.contextNotesTodo.toast.createNoteFailed"));return}u("")},e[7]=d,e[8]=g,e[9]=n,e[10]=I,e[11]=c,e[12]=T):T=e[12];const y=T;let v;e[13]!==p||e[14]!==n||e[15]!==I||e[16]!==c?(v=async O=>{await p(n,O)||I(c("rightSidebar.contextNotesTodo.toast.deleteNoteFailed"))},e[13]=p,e[14]=n,e[15]=I,e[16]=c,e[17]=v):v=e[17];const $=v;let U;e[18]!==l||e[19]!==I||e[20]!==c?(U=async(O,ne)=>{await l(O,ne)||I(c("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))},e[18]=l,e[19]=I,e[20]=c,e[21]=U):U=e[21];const W=U;let z;e[22]!==n||e[23]!==I||e[24]!==S||e[25]!==c?(z=(O,ne)=>{S(n,O,ne).then(X=>{X||I(c("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))})},e[22]=n,e[23]=I,e[24]=S,e[25]=c,e[26]=z):z=e[26];const q=z;let se;e[27]===Symbol.for("react.memo_cache_sentinel")?(se=O=>u(O.target.value.slice(0,jn)),e[27]=se):se=e[27];let J;e[28]!==c?(J=c("rightSidebar.contextNotesTodo.notes.placeholder"),e[28]=c,e[29]=J):J=e[29];let G;e[30]!==d.length?(G=t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[d.length,"/",jn]}),e[30]=d.length,e[31]=G):G=e[31];let ee;e[32]!==y?(ee=()=>{y()},e[32]=y,e[33]=ee):ee=e[33];let ue;e[34]!==d||e[35]!==o?(ue=o||d.trim().length===0,e[34]=d,e[35]=o,e[36]=ue):ue=e[36];let V;e[37]!==c?(V=c("rightSidebar.contextNotesTodo.notes.addAria"),e[37]=c,e[38]=V):V=e[38];let P;e[39]!==c?(P=c("rightSidebar.contextNotesTodo.notes.addAria"),e[39]=c,e[40]=P):P=e[40];let B;e[41]===Symbol.for("react.memo_cache_sentinel")?(B=t.jsx(R,{name:"add",className:"h-4 w-4"}),e[41]=B):B=e[41];let M;e[42]!==ee||e[43]!==ue||e[44]!==V||e[45]!==P?(M=t.jsx("button",{type:"button",onClick:ee,disabled:ue,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 disabled:cursor-not-allowed disabled:opacity-40","aria-label":V,title:P,children:B}),e[42]=ee,e[43]=ue,e[44]=V,e[45]=P,e[46]=M):M=e[46];let D;e[47]!==M||e[48]!==G?(D=t.jsxs(t.Fragment,{children:[G,M]}),e[47]=M,e[48]=G,e[49]=D):D=e[49];let _;e[50]!==d||e[51]!==o||e[52]!==m||e[53]!==x||e[54]!==D||e[55]!==J?(_=t.jsx(qs,{value:d,onChange:se,placeholder:J,resizedHeight:m,onResizeHeightChange:x,useScrollShadow:!0,scrollShadowSize:56,disabled:o,endSlot:D}),e[50]=d,e[51]=o,e[52]=m,e[53]=x,e[54]=D,e[55]=J,e[56]=_):_=e[56];let E;e[57]!==f||e[58]!==$||e[59]!==q||e[60]!==W||e[61]!==i||e[62]!==a||e[63]!==c||e[64]!==A?(E=t.jsx("div",{children:A.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:a.trim()?c("rightSidebar.contextNotesTodo.search.noResults",{query:a.trim()}):c("rightSidebar.contextNotesTodo.notes.empty")}):t.jsx("ul",{className:"flex flex-col gap-1.5",children:A.map(O=>t.jsx(ou,{note:O,pinned:i.has(O.id),expanded:f===O.id,onToggleExpanded:()=>b(ne=>ne===O.id?null:O.id),onSaveBody:ne=>q(O.id,ne),onTogglePinned:()=>{W(O.id,!i.has(O.id))},onDelete:()=>{$(O.id)}},O.id))})}),e[57]=f,e[58]=$,e[59]=q,e[60]=W,e[61]=i,e[62]=a,e[63]=c,e[64]=A,e[65]=E):E=e[65];let K;return e[66]!==_||e[67]!==E?(K=t.jsxs("div",{className:"space-y-2",children:[_,E]}),e[66]=_,e[67]=E,e[68]=K):K=e[68],K};function iu(s){return s.notesPanelHeight}function lu(s){return s.setNotesPanelHeight}function cu(s){return s.createNote}function du(s){return s.saveNoteBody}function uu(s){return s.deleteNote}const fu=({projectRef:s,plans:e,query:n,onOpenPlan:r,pinnedPlanIds:o,onTogglePinned:a})=>{const{t:i}=nt(),l=h.useRef(null),[c,d]=h.useState(!1),[u,f]=h.useState(null),b=Rt(y=>y.createPlan),m=Rt(y=>y.deletePlan),x=bs(y=>y.currentDirectory),g=Ve(y=>y.openContextPanelTab),S=h.useCallback(async y=>{if(!u){f(y);try{await m(s,y)||Ne.error(i("rightSidebar.contextNotesTodo.toast.deletePlanFailed"))}finally{f(null)}}},[u,s,m,i]),p=h.useCallback(async(y,v)=>{if(!y.trim()){Ne.error(i("rightSidebar.contextNotesTodo.toast.planFileEmpty"));return}const $=ti(y,v||i("rightSidebar.contextNotesTodo.plan.defaultTitle"));if(!await b(s,{title:$.title,body:$.body})){Ne.error(i("rightSidebar.contextNotesTodo.toast.importPlanFailed"));return}Ne.success(i("rightSidebar.contextNotesTodo.toast.planImported"))},[b,s,i]),N=h.useCallback(async()=>{if(c)return;const y=await Wi({defaultPath:s.path,filters:[{name:"Plan files",extensions:["md","markdown","txt"]},{name:"All files",extensions:["*"]}]});if(y.success&&y.path){d(!0);try{const v=new URLSearchParams({path:y.path,allowOutsideWorkspace:"true"});y.outsideFileGrant&&v.set("outsideFileGrant",y.outsideFileGrant);const $=await Mt(`/api/fs/read?${v.toString()}`,{cache:"no-store"});if(!$.ok){Ne.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"));return}const U=await $.text(),W=y.path.split("/").pop()?.replace(/\.(md|markdown|txt)$/i,"").trim()||"";await p(U,W)}catch(v){const $=v instanceof Error?v.message:void 0;Ne.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),$?{description:$}:void 0)}finally{d(!1)}return}y.error==="Native file picker not available"&&l.current?.click()},[p,c,s.path,i]),A=h.useCallback(async y=>{if(y){d(!0);try{const v=await y.text(),$=y.name.replace(/\.(md|markdown|txt)$/i,"").trim();await p(v,$)}catch(v){const $=v instanceof Error?v.message:void 0;Ne.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),$?{description:$}:void 0)}finally{d(!1)}}},[p,i]),L=h.useCallback(async(y,v)=>{if(!await a(y,v)){const U=Rt.getState().getEntry(s).error;Ne.error(i("rightSidebar.contextNotesTodo.toast.updatePlanFailed"),U?{description:U}:void 0)}},[a,s,i]),I=h.useMemo(()=>e.filter(y=>Ys([y.title],n)),[e,n]),T=h.useCallback(y=>{if(r){r({id:y.id,title:y.title,projectRef:s});return}const v=x?.trim()||s.path.trim();v&&g(v,{mode:"plan",projectPlanId:y.id,projectPlanRef:s,dedupeKey:`plan:${_r(s)}:${y.id}`,label:y.title})},[x,r,g,s]);return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t.jsx("input",{ref:l,type:"file",accept:".md,.markdown,.txt,text/markdown,text/plain",className:"hidden",onChange:y=>{const v=y.target.files?.[0]??null;A(v),y.currentTarget.value=""}}),t.jsx("button",{type:"button",onClick:N,disabled:c,className:"inline-flex h-6 w-6 items-center justify-center rounded-md border border-border/70 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 disabled:opacity-50","aria-label":i("rightSidebar.contextNotesTodo.plans.importFromFile"),title:i("rightSidebar.contextNotesTodo.plans.importFromFile"),children:t.jsx(R,{name:"add",className:"h-3.5 w-3.5"})})]}),t.jsx("div",{className:"rounded-lg border border-border/60 bg-background/40",children:I.length===0?t.jsx("p",{className:"px-3 py-3 typography-meta text-muted-foreground",children:n.trim()?i("rightSidebar.contextNotesTodo.search.noResults",{query:n.trim()}):i("rightSidebar.contextNotesTodo.plans.empty")}):t.jsx("ul",{className:"divide-y divide-border/50",children:I.map(y=>t.jsxs("li",{className:"flex items-center gap-1.5 px-2.5 py-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>T(y),className:"flex min-w-0 flex-1 items-center justify-between gap-3 rounded-md px-1.5 py-1 text-left hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:[t.jsx("span",{className:"min-w-0 truncate typography-ui-label text-foreground",children:y.title}),t.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:new Date(y.createdAt).toLocaleDateString(Tr())})]}),t.jsx("button",{type:"button",onClick:()=>{L(y.id,!o.has(y.id))},className:le("inline-flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",o.has(y.id)?"text-primary":"text-muted-foreground hover:text-foreground"),"aria-pressed":o.has(y.id),"aria-label":o.has(y.id)?i("rightSidebar.contextNotesTodo.notes.actions.unpin"):i("rightSidebar.contextNotesTodo.notes.actions.pin"),title:o.has(y.id)?i("rightSidebar.contextNotesTodo.notes.actions.unpin"):i("rightSidebar.contextNotesTodo.notes.actions.pin"),children:t.jsx(R,{name:"pushpin",className:"h-3.5 w-3.5"})}),t.jsx("button",{type:"button",onClick:()=>{S(y.id)},disabled:u===y.id,className:"inline-flex h-6 w-6 flex-shrink-0 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 disabled:cursor-not-allowed disabled:opacity-50",title:i("rightSidebar.contextNotesTodo.plans.deletePlan"),"aria-label":i("rightSidebar.contextNotesTodo.plans.deletePlanWithTitle",{title:y.title}),children:t.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},y.id))})})]})},mu=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`todo_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,hu=s=>[...s.filter(e=>!e.completed),...s.filter(e=>e.completed)],yr=(s,e)=>{const n=s.findIndex(r=>r.completed);return n===-1?[...s,e]:[...s.slice(0,n),e,...s.slice(n)]},pu=s=>{const e=ze.c(20),{id:n,children:r}=s;let o;e[0]!==n?(o={id:n},e[0]=n,e[1]=o):o=e[1];const{attributes:a,listeners:i,setNodeRef:l,setActivatorNodeRef:c,transform:d,transition:u,isDragging:f}=so(o);let b;e[2]!==d?(b=ro.Transform.toString(d),e[2]=d,e[3]=b):b=e[3];let m;e[4]!==b||e[5]!==u?(m={transform:b,transition:u},e[4]=b,e[5]=u,e[6]=m):m=e[6];const x=f&&"opacity-60";let g;e[7]!==x?(g=le(x),e[7]=x,e[8]=g):g=e[8];let S;e[9]!==a||e[10]!==r||e[11]!==f||e[12]!==i||e[13]!==c?(S=r({attributes:a,listeners:i,setActivatorNodeRef:c,isDragging:f}),e[9]=a,e[10]=r,e[11]=f,e[12]=i,e[13]=c,e[14]=S):S=e[14];let p;return e[15]!==l||e[16]!==m||e[17]!==g||e[18]!==S?(p=t.jsx("li",{ref:l,style:m,className:g,children:S}),e[15]=l,e[16]=m,e[17]=g,e[18]=S,e[19]=p):p=e[19],p},gu=s=>{const e=ze.c(82),{todos:n,query:r,disabled:o,canCreateWorktree:a,sendingTodoId:i,onPersistTodos:l,onSendToCurrentSession:c,onSendToNewSession:d,onSendToNewWorktreeSession:u}=s,{t:f}=nt(),[b,m]=h.useState(""),[x,g]=h.useState(xu);let S;e[0]!==b||e[1]!==l||e[2]!==n?(S=()=>{const j=b.trim();j&&(l(yr(n,{id:mu(),text:j.slice(0,Ms),completed:!1,createdAt:Date.now()})),m(""))},e[0]=b,e[1]=l,e[2]=n,e[3]=S):S=e[3];const p=S;let N;e[4]===Symbol.for("react.memo_cache_sentinel")?(N=j=>{g(Y=>{const F=new Set(Y);return F.has(j)?F.delete(j):F.add(j),F})},e[4]=N):N=e[4];const A=N;let L;e[5]!==l||e[6]!==n?(L=(j,Y)=>{const F=n.find(we=>we.id===j);if(!F||F.completed===Y)return;const ae=n.filter(we=>we.id!==j),he={...F,completed:Y};l(Y?[...ae,he]:yr(ae,he))},e[5]=l,e[6]=n,e[7]=L):L=e[7];const I=L;let T;e[8]!==l||e[9]!==n?(T=j=>{l(n.filter(Y=>Y.id!==j))},e[8]=l,e[9]=n,e[10]=T):T=e[10];const y=T;let v;e[11]!==l||e[12]!==n?(v=()=>{const j=n.filter(bu);j.length!==n.length&&l(j)},e[11]=l,e[12]=n,e[13]=v):v=e[13];const $=v;let U;e[14]!==l||e[15]!==n?(U=j=>{const{active:Y,over:F}=j;if(!F||Y.id===F.id)return;const ae=n.findIndex(we=>we.id===Y.id),he=n.findIndex(we=>we.id===F.id);ae===-1||he===-1||l(hu(cl(n,ae,he)))},e[14]=l,e[15]=n,e[16]=U):U=e[16];const W=U;let z;e[17]===Symbol.for("react.memo_cache_sentinel")?(z={activationConstraint:{distance:8}},e[17]=z):z=e[17];const q=Qr(Xr(Zr,z));let se;e[18]!==b?(se=b.slice(0,Ms),e[18]=b,e[19]=se):se=e[19];const J=se;let G;e[20]!==n?(G=n.reduce(yu,0),e[20]=n,e[21]=G):G=e[21];const ee=G;let ue;if(e[22]!==r||e[23]!==n){let j;e[25]!==r?(j=Y=>Ys([Y.text],r),e[25]=r,e[26]=j):j=e[26],ue=n.filter(j),e[22]=r,e[23]=n,e[24]=ue}else ue=e[24];const V=ue,P=o||ee===0;let B;e[27]!==f?(B=f("rightSidebar.contextNotesTodo.todo.clearCompleted"),e[27]=f,e[28]=B):B=e[28];let M;e[29]!==$||e[30]!==P||e[31]!==B?(M=t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("button",{type:"button",onClick:$,disabled:P,className:"typography-meta rounded-md px-1.5 py-0.5 text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50",children:B})}),e[29]=$,e[30]=P,e[31]=B,e[32]=M):M=e[32];let D;e[33]!==J.length?(D=t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[J.length,"/",Ms]}),e[33]=J.length,e[34]=D):D=e[34];let _;e[35]!==M||e[36]!==D?(_=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[M,D]}),e[35]=M,e[36]=D,e[37]=_):_=e[37];let E;e[38]===Symbol.for("react.memo_cache_sentinel")?(E=j=>m(j.target.value.slice(0,Ms)),e[38]=E):E=e[38];let K;e[39]!==p?(K=j=>{j.key==="Enter"&&(j.preventDefault(),p())},e[39]=p,e[40]=K):K=e[40];let O;e[41]!==f?(O=f("rightSidebar.contextNotesTodo.todo.inputPlaceholder"),e[41]=f,e[42]=O):O=e[42];let ne;e[43]!==o||e[44]!==K||e[45]!==O||e[46]!==J?(ne=t.jsx(bt,{value:J,onChange:E,onKeyDown:K,placeholder:O,disabled:o,className:"h-8"}),e[43]=o,e[44]=K,e[45]=O,e[46]=J,e[47]=ne):ne=e[47];let X;e[48]!==o||e[49]!==J?(X=o||J.trim().length===0,e[48]=o,e[49]=J,e[50]=X):X=e[50];let te;e[51]!==f?(te=f("rightSidebar.contextNotesTodo.todo.addAria"),e[51]=f,e[52]=te):te=e[52];let ge;e[53]!==f?(ge=f("rightSidebar.contextNotesTodo.todo.addAria"),e[53]=f,e[54]=ge):ge=e[54];let re;e[55]===Symbol.for("react.memo_cache_sentinel")?(re=t.jsx(R,{name:"add",className:"h-4 w-4"}),e[55]=re):re=e[55];let pe;e[56]!==p||e[57]!==X||e[58]!==te||e[59]!==ge?(pe=t.jsx("button",{type:"button",onClick:p,disabled:X,className:"inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border border-border/70 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 disabled:opacity-50","aria-label":te,title:ge,children:re}),e[56]=p,e[57]=X,e[58]=te,e[59]=ge,e[60]=pe):pe=e[60];let Z;e[61]!==ne||e[62]!==pe?(Z=t.jsxs("div",{className:"flex items-center gap-1.5",children:[ne,pe]}),e[61]=ne,e[62]=pe,e[63]=Z):Z=e[63];let de;e[64]!==a||e[65]!==x||e[66]!==y||e[67]!==W||e[68]!==I||e[69]!==c||e[70]!==d||e[71]!==u||e[72]!==r||e[73]!==i||e[74]!==f||e[75]!==q||e[76]!==V?(de=t.jsx("div",{className:"rounded-lg border border-border/60 bg-background/40",children:V.length===0?t.jsx("p",{className:"px-3 py-3 typography-meta text-muted-foreground",children:r.trim()?f("rightSidebar.contextNotesTodo.search.noResults",{query:r.trim()}):f("rightSidebar.contextNotesTodo.todo.empty")}):t.jsx(eo,{sensors:q,collisionDetection:to,onDragEnd:W,children:t.jsx(no,{items:V.map(wu),strategy:ll,children:t.jsx("ul",{className:"divide-y divide-border/50",children:V.map(j=>{const Y=x.has(j.id);return t.jsx(pu,{id:j.id,children:F=>t.jsxs("div",{className:le("flex gap-1.5 px-2.5 py-1.5",Y?"items-start":"items-center"),children:[t.jsx("button",{type:"button",ref:F.setActivatorNodeRef,...F.attributes,...F.listeners,onClick:vu,className:"flex h-6 w-4 flex-shrink-0 touch-none items-center justify-center text-muted-foreground hover:text-foreground","aria-label":f("rightSidebar.contextNotesTodo.todo.actions.reorder",{text:j.text}),title:f("rightSidebar.contextNotesTodo.todo.actions.reorder",{text:j.text}),children:t.jsx(R,{name:"draggable",className:"h-3.5 w-3.5"})}),t.jsx("div",{className:"flex h-6 items-center",children:t.jsx(Es,{checked:j.completed,onChange:ae=>I(j.id,ae),ariaLabel:f("rightSidebar.contextNotesTodo.todo.actions.markComplete",{text:j.text})})}),t.jsx("button",{type:"button",onClick:()=>A(j.id),className:le("block min-h-6 min-w-0 flex-1 bg-transparent p-0 text-left typography-ui-label leading-normal text-foreground",Y?"whitespace-normal break-words":"overflow-hidden text-ellipsis whitespace-nowrap","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",j.completed&&"text-muted-foreground line-through"),title:Y?void 0:j.text,"aria-label":Y?f("rightSidebar.contextNotesTodo.todo.actions.collapse",{text:j.text}):f("rightSidebar.contextNotesTodo.todo.actions.expand",{text:j.text}),children:j.text}),t.jsxs("div",{className:"flex h-6 items-center gap-0.5",children:[t.jsx("button",{type:"button",onClick:()=>y(j.id),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":f("rightSidebar.contextNotesTodo.todo.actions.delete",{text:j.text}),title:f("rightSidebar.contextNotesTodo.todo.actions.delete",{text:j.text}),children:t.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"})}),t.jsxs(zt,{children:[t.jsx(Gt,{asChild:!0,children:t.jsx("button",{type:"button",disabled:i===j.id,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 disabled:cursor-not-allowed disabled:opacity-50","aria-label":f("rightSidebar.contextNotesTodo.todo.actions.send",{text:j.text}),title:f("rightSidebar.contextNotesTodo.todo.actions.send",{text:j.text}),children:t.jsx(R,{name:"send-plane",className:"h-3.5 w-3.5"})})}),t.jsxs(Ht,{align:"end",className:"w-56",children:[t.jsx(Bt,{onClick:()=>c(j.text),children:f("rightSidebar.contextNotesTodo.todo.sendMenu.currentSession")}),t.jsx(Bt,{onClick:()=>d(j.id,j.text),children:f("rightSidebar.contextNotesTodo.todo.sendMenu.newSession")}),t.jsx(Bt,{onClick:()=>u(j.id,j.text),disabled:!a,children:f("rightSidebar.contextNotesTodo.todo.sendMenu.newWorktreeSession")})]})]})]})]})},j.id)})})})})}),e[64]=a,e[65]=x,e[66]=y,e[67]=W,e[68]=I,e[69]=c,e[70]=d,e[71]=u,e[72]=r,e[73]=i,e[74]=f,e[75]=q,e[76]=V,e[77]=de):de=e[77];let me;return e[78]!==_||e[79]!==Z||e[80]!==de?(me=t.jsxs("div",{className:"space-y-2",children:[_,Z,de]}),e[78]=_,e[79]=Z,e[80]=de,e[81]=me):me=e[81],me};function xu(){return new Set}function bu(s){return!s.completed}function yu(s,e){return s+(e.completed?1:0)}function wu(s){return s.id}function vu(s){s.preventDefault(),s.stopPropagation()}const Su=s=>{const{projectRef:e,canCreateWorktree:n,onActionComplete:r}=s,{t:o}=nt(),[a,i]=h.useState(null),[l,c]=h.useState(!1),[d,u]=h.useState(null),f=it(v=>v.currentSessionId),b=it(v=>v.createSession),m=it(v=>v.initializeNewOpenChamberSession),x=it(v=>v.sendMessage),g=it(v=>v.setCurrentSession),S=si(v=>v.setPendingInputText),p=Ve(v=>v.setSessionSwitcherOpen),N=h.useCallback(()=>{p(!1)},[p]),A=h.useCallback(v=>{if(!f){Ne.error(o("rightSidebar.contextNotesTodo.toast.noActiveSession"));return}N();const $=`\`\`\`md
|
|
8
|
-
${v}
|
|
9
|
-
\`\`\``;S($,"append"),Ne.success(o("rightSidebar.contextNotesTodo.toast.sentToCurrentSession")),r?.()},[f,r,N,S,o]),L=h.useCallback((v,$)=>{!e||d||i({kind:"session",todoId:v,todoText:$})},[e,d]),I=h.useCallback((v,$)=>{if(!(!e||d)){if(!n){Ne.error(o("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}i({kind:"worktree",todoId:v,todoText:$})}},[n,e,d,o]),T=h.useCallback(async v=>{if(!e||!a)return;const $=await Vt("plan.todo.visible",{todo_text:a.todoText}),W=[{synthetic:!0,text:await Vt("plan.todo.instructions",{todo_text:a.todoText})}];c(!0),u(a.todoId);try{N();let z=null,q=e.path;if(a.kind==="worktree"){if(!n){Ne.error(o("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}const J=await ni(e.path,ri());if(!J?.id)return;z=J.id,q=J.path}else{const J=await b(void 0,e.path,null);if(!J?.id){Ne.error(o("rightSidebar.contextNotesTodo.toast.createSessionFailed"));return}z=J.id,q=J.directory??e.path,m(J.id,Nt.getState().agents??[])}if(!z)return;const se=Or.getState();se.saveSessionModelSelection(z,v.providerID,v.modelID),v.agent.trim()&&(se.saveSessionAgentSelection(z,v.agent),se.saveAgentModelForSession(z,v.agent,v.providerID,v.modelID),se.saveAgentModelVariantForSession(z,v.agent,v.providerID,v.modelID,v.variant||void 0)),g(z,q),await x($,v.providerID,v.modelID,v.agent.trim()||void 0,void 0,void 0,W,v.variant||void 0),Ne.success(a.kind==="worktree"?o("rightSidebar.contextNotesTodo.toast.sentToNewWorktreeSession"):o("rightSidebar.contextNotesTodo.toast.sentToNewSession")),i(null),r?.()}catch(z){const q=z instanceof Error?z.message:void 0;Ne.error(o("rightSidebar.contextNotesTodo.toast.sendTodoFailed"),q?{description:q}:void 0)}finally{c(!1),u(null)}},[n,b,m,r,a,e,N,x,g,o]),y=h.useCallback(()=>{l||i(null)},[l]);return{pendingSendTarget:a,isSubmitting:l,sendingTodoId:d,sendToCurrentSession:A,sendToNewSession:L,sendToNewWorktreeSession:I,confirmSend:T,closeDialog:y}},ju=h.lazy(()=>Qt(()=>import("./PlanView-C1qvAm7m.js"),__vite__mapDeps([115,2,3,4,5,6,7,8,9,116,57,58,59,60,61,62,79,55,56,63,117,118,119,1,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,120,121,113,114,100,101,85,86,87,88,89,90,91,92,93,94,95,96,97,98])).then(s=>({default:s.PlanView}))),wr=["notes","todos","plans","memory"],Nu=120,ku=320,an=s=>Math.min(ku,Math.max(Nu,Math.round(s))),Iu=s=>[...s.filter(e=>!e.completed),...s.filter(e=>e.completed)],vs=(s,e)=>s.toLowerCase().includes(e),Cu=s=>{const e=ze.c(242),{projectRef:n,projectLabel:r,canCreateWorktree:o,onActionComplete:a,onOpenPlan:i,className:l}=s,c=o===void 0?!1:o,{t:d}=nt();let u;e[0]!==n?(u=_r(n),e[0]=n,e[1]=u):u=e[1];const f=u;let b;e[2]!==f?(b=Se=>(f?Se.entries[f]:void 0)??oi,e[2]=f,e[3]=b):b=e[3];const m=Rt(b),x=Rt(Tu),g=Rt(Du),S=it(Pu),p=it(Ru),N=it(Eu),A=it(Au);let L;e[4]===Symbol.for("react.memo_cache_sentinel")?(L={notes:[],plans:[]},e[4]=L):L=e[4];const[I,T]=h.useState(L);let y,v;e[5]!==p||e[6]!==S||e[7]!==N.open||e[8]!==N.projectContextPins?(y=()=>{if(N.open){T(N.projectContextPins??{notes:[],plans:[]});return}let Se=!1;return ai(p,S).then(et=>{Se||T({notes:et.notes.map(Bu),plans:et.plans.map(Lu)})}),()=>{Se=!0}},v=[p,S,N.open,N.projectContextPins],e[5]=p,e[6]=S,e[7]=N.open,e[8]=N.projectContextPins,e[9]=y,e[10]=v):(y=e[9],v=e[10]),h.useEffect(y,v);let $;e[11]!==p||e[12]!==S||e[13]!==N.open||e[14]!==A?($=async(Se,et,vt)=>{if(N.open)return A(Se,et,vt),!0;if(!S||!p)return!1;const Ot=await ii(p,S,Se,et,vt);return Ot?(T(Ot),!0):!1},e[11]=p,e[12]=S,e[13]=N.open,e[14]=A,e[15]=$):$=e[15];const U=$;let W;e[16]!==I.notes?(W=new Set(I.notes),e[16]=I.notes,e[17]=W):W=e[17];const z=W;let q;e[18]!==I.plans?(q=new Set(I.plans),e[18]=I.plans,e[19]=q):q=e[19];const se=q,J=Ve(Mu),G=Tt(Fu),ee=J&&!G,ue=Tt(Ou);let V;e[20]!==n?.path?(V=Se=>Wr(Se,n?.path??null),e[20]=n?.path,e[21]=V):V=e[21];const P=Tt(V),B=Ve($u),M=Ve(Uu),D=Ve(Wu);let _;e[22]!==M?(_=wr.includes(M)?M:"notes",e[22]=M,e[23]=_):_=e[23];const E=_,K=E==="memory"&&!ee?"notes":E,[O,ne]=h.useState(""),[X,te]=h.useState(null);let ge;e[24]!==O?(ge=O.trim().toLowerCase(),e[24]=O,e[25]=ge):ge=e[25];const re=ge;let pe;e[26]!==m.todos?(pe=Iu(m.todos),e[26]=m.todos,e[27]=pe):pe=e[27];const Z=pe,de=m.loading&&!m.loaded;let me;e[28]!==ue||e[29]!==P?(me=[...ue,...P],e[28]=ue,e[29]=P,e[30]=me):me=e[30];const j=me;let Y;e:{if(!re){let ft;e[31]!==m.notes.length||e[32]!==m.plans.length||e[33]!==j.length||e[34]!==Z.length?(ft={notes:m.notes.length,todos:Z.length,plans:m.plans.length,memory:j.length},e[31]=m.notes.length,e[32]=m.plans.length,e[33]=j.length,e[34]=Z.length,e[35]=ft):ft=e[35],Y=ft;break e}let Se;if(e[36]!==m.notes||e[37]!==re){let ft;e[39]!==re?(ft=ys=>vs(ys.body,re),e[39]=re,e[40]=ft):ft=e[40],Se=m.notes.filter(ft),e[36]=m.notes,e[37]=re,e[38]=Se}else Se=e[38];const et=Se.length;let vt;if(e[41]!==Z||e[42]!==re){let ft;e[44]!==re?(ft=ys=>vs(ys.text,re),e[44]=re,e[45]=ft):ft=e[45],vt=Z.filter(ft),e[41]=Z,e[42]=re,e[43]=vt}else vt=e[43];const Ot=vt.length;let cs;if(e[46]!==m.plans||e[47]!==re){let ft;e[49]!==re?(ft=ys=>vs(ys.title,re),e[49]=re,e[50]=ft):ft=e[50],cs=m.plans.filter(ft),e[46]=m.plans,e[47]=re,e[48]=cs}else cs=e[48];const Ro=cs.length;let ds;e[51]!==j||e[52]!==re?(ds=j.filter(ft=>vs(ft.title,re)||vs(ft.body,re)),e[51]=j,e[52]=re,e[53]=ds):ds=e[53];let Bs;e[54]!==Se.length||e[55]!==vt.length||e[56]!==cs.length||e[57]!==ds.length?(Bs={notes:et,todos:Ot,plans:Ro,memory:ds.length},e[54]=Se.length,e[55]=vt.length,e[56]=cs.length,e[57]=ds.length,e[58]=Bs):Bs=e[58],Y=Bs}const F=Y,ae=Ve(_u);let he;e[59]!==n?.path?(he=Se=>Se.agentMemoryViewedAt[On("project",n?.path??null)]??0,e[59]=n?.path,e[60]=he):he=e[60];const we=Ve(he),Te=br(ue,ae)+br(P,we),Ge=Ve(Vu),Fe=Ve(zu),[ve,Re]=h.useState(!1),[Ce,Ue]=h.useState(null),He=Ce??Ge;let qe;e[61]!==He?(qe=an(He),e[61]=He,e[62]=qe):qe=e[62];const Ke=qe;let We;e[63]!==Ke?(We=Se=>{Se.currentTarget.setPointerCapture(Se.pointerId),Re(!0),Ue(Ke)},e[63]=Ke,e[64]=We):We=e[64];const tt=We;let ct;e[65]===Symbol.for("react.memo_cache_sentinel")?(ct=Se=>{if(!Se.currentTarget.hasPointerCapture(Se.pointerId))return;const et=Se.currentTarget.closest("nav")?.getBoundingClientRect().right??0;Ue(an(et-Se.clientX))},e[65]=ct):ct=e[65];const Be=ct;let Ye;e[66]!==Fe?(Ye=Se=>{Se.currentTarget.hasPointerCapture(Se.pointerId)&&Se.currentTarget.releasePointerCapture(Se.pointerId),Re(!1),Ue(et=>(et!==null&&Fe(an(et)),null))},e[66]=Fe,e[67]=Ye):Ye=e[67];const Qe=Ye;let Je;e[68]!==c||e[69]!==a||e[70]!==n?(Je={projectRef:n,canCreateWorktree:c,onActionComplete:a},e[68]=c,e[69]=a,e[70]=n,e[71]=Je):Je=e[71];const De=Su(Je);let ot,$e;e[72]!==x||e[73]!==n?(ot=()=>{n&&x(n)},$e=[x,n],e[72]=x,e[73]=n,e[74]=ot,e[75]=$e):(ot=e[74],$e=e[75]),h.useEffect(ot,$e);const _e=h.useRef(null);let st,Pe;e[76]!==m.error||e[77]!==m.loaded||e[78]!==d?(st=()=>{if(!m.error){_e.current=null;return}_e.current!==m.error&&(_e.current=m.error,m.loaded||Ne.error(d("rightSidebar.contextNotesTodo.toast.loadNotesFailed")))},Pe=[m.error,m.loaded,d],e[76]=m.error,e[77]=m.loaded,e[78]=d,e[79]=st,e[80]=Pe):(st=e[79],Pe=e[80]),h.useEffect(st,Pe);let Xe;e[81]===Symbol.for("react.memo_cache_sentinel")?(Xe=()=>{te(null)},e[81]=Xe):Xe=e[81];let dt;e[82]!==f?(dt=[f],e[82]=f,e[83]=dt):dt=e[83],h.useEffect(Xe,dt);let lt,ut;e[84]!==K?(lt=()=>{K!=="plans"&&te(null)},ut=[K],e[84]=K,e[85]=lt,e[86]=ut):(lt=e[85],ut=e[86]),h.useEffect(lt,ut);let yt;e[87]===Symbol.for("react.memo_cache_sentinel")?(yt=()=>{ne("")},e[87]=yt):yt=e[87];let w;e[88]!==f?(w=[f],e[88]=f,e[89]=w):w=e[89],h.useEffect(yt,w);let H,ke;e[90]!==K||e[91]!==F||e[92]!==D||e[93]!==re?(H=()=>{if(!re||F[K]>0)return;const Se=wr.find(et=>F[et]>0);Se&&D(Se)},ke=[K,F,D,re],e[90]=K,e[91]=F,e[92]=D,e[93]=re,e[94]=H,e[95]=ke):(H=e[94],ke=e[95]),h.useEffect(H,ke);let Ae;e[96]!==n||e[97]!==g||e[98]!==d?(Ae=Se=>{n&&g(n,Se).then(et=>{et||Ne.error(d("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))})},e[96]=n,e[97]=g,e[98]=d,e[99]=Ae):Ae=e[99];const k=Ae;let oe;e[100]!==d?(oe=d("rightSidebar.contextNotesTodo.tabs.notes"),e[100]=d,e[101]=oe):oe=e[101];const ye=String(F.notes);let xe;e[102]!==oe||e[103]!==ye?(xe={id:"notes",icon:"sticky-note",label:oe,count:ye},e[102]=oe,e[103]=ye,e[104]=xe):xe=e[104];let je;e[105]!==d?(je=d("rightSidebar.contextNotesTodo.tabs.todos"),e[105]=d,e[106]=je):je=e[106];const C=String(F.todos);let Q;e[107]!==je||e[108]!==C?(Q={id:"todos",icon:"checkbox-circle",label:je,count:C},e[107]=je,e[108]=C,e[109]=Q):Q=e[109];let ie;e[110]!==d?(ie=d("rightSidebar.contextNotesTodo.tabs.plans"),e[110]=d,e[111]=ie):ie=e[111];const Oe=String(F.plans);let be;e[112]!==ie||e[113]!==Oe?(be={id:"plans",icon:"file-text",label:ie,count:Oe},e[112]=ie,e[113]=Oe,e[114]=be):be=e[114];let Le;e[115]!==F.memory||e[116]!==Te||e[117]!==ee||e[118]!==d?(Le=ee?[{id:"memory",icon:"brain-4",label:d("rightSidebar.contextNotesTodo.tabs.memory"),count:Te>0?`${Te}/${F.memory}`:String(F.memory)}]:[],e[115]=F.memory,e[116]=Te,e[117]=ee,e[118]=d,e[119]=Le):Le=e[119];let rt;e[120]!==xe||e[121]!==Q||e[122]!==be||e[123]!==Le?(rt=[xe,Q,be,...Le],e[120]=xe,e[121]=Q,e[122]=be,e[123]=Le,e[124]=rt):rt=e[124];const Ee=rt;if(!n){let Se;e[125]!==l?(Se=le("w-full min-w-0 p-3",l),e[125]=l,e[126]=Se):Se=e[126];let et;e[127]!==d?(et=d("rightSidebar.contextNotesTodo.empty.selectProject"),e[127]=d,e[128]=et):et=e[128];let vt;e[129]!==et?(vt=t.jsx("p",{className:"typography-meta text-muted-foreground",children:et}),e[129]=et,e[130]=vt):vt=e[130];let Ot;return e[131]!==Se||e[132]!==vt?(Ot=t.jsx("div",{className:Se,children:vt}),e[131]=Se,e[132]=vt,e[133]=Ot):Ot=e[133],Ot}let fe;e[134]!==r||e[135]!==n.path?(fe=r?.trim()||n.path.split("/").filter(Boolean).pop()||n.path,e[134]=r,e[135]=n.path,e[136]=fe):fe=e[136];const Me=fe;let Ze;e[137]!==l?(Ze=le("flex h-full min-h-0 w-full min-w-0 flex-col",l),e[137]=l,e[138]=Ze):Ze=e[138];let ht;e[139]!==X||e[140]!==d?(ht=X?t.jsx("button",{type:"button",onClick:()=>te(null),className:"inline-flex h-6 w-6 flex-shrink-0 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("rightSidebar.contextNotesTodo.plans.actions.back"),title:d("rightSidebar.contextNotesTodo.plans.actions.back"),children:t.jsx(R,{name:"arrow-left-s",className:"h-4 w-4"})}):null,e[139]=X,e[140]=d,e[141]=ht):ht=e[141];let xt;e[142]!==n.path||e[143]!==Me?(xt=t.jsx("h3",{className:"min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",title:n.path,children:Me}),e[142]=n.path,e[143]=Me,e[144]=xt):xt=e[144];let St;e[145]===Symbol.for("react.memo_cache_sentinel")?(St=t.jsx(R,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e[145]=St):St=e[145];let kt;e[146]===Symbol.for("react.memo_cache_sentinel")?(kt=Se=>ne(Se.target.value),e[146]=kt):kt=e[146];let wt;e[147]!==d?(wt=d("rightSidebar.contextNotesTodo.search.placeholder"),e[147]=d,e[148]=wt):wt=e[148];let jt;e[149]!==O||e[150]!==wt?(jt=t.jsx(bt,{value:O,onChange:kt,placeholder:wt,className:"h-8 pl-7 pr-7"}),e[149]=O,e[150]=wt,e[151]=jt):jt=e[151];let Ct;e[152]!==O||e[153]!==d?(Ct=O?t.jsx("button",{type:"button",onClick:()=>ne(""),className:"absolute right-1.5 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 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":d("rightSidebar.contextNotesTodo.search.clear"),title:d("rightSidebar.contextNotesTodo.search.clear"),children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})}):null,e[152]=O,e[153]=d,e[154]=Ct):Ct=e[154];let Et;e[155]!==jt||e[156]!==Ct?(Et=t.jsxs("div",{className:"relative w-40 flex-shrink-0",children:[St,jt,Ct]}),e[155]=jt,e[156]=Ct,e[157]=Et):Et=e[157];let _t;e[158]!==ht||e[159]!==xt||e[160]!==Et?(_t=t.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2 p-3 pb-2",children:[ht,xt,Et]}),e[158]=ht,e[159]=xt,e[160]=Et,e[161]=_t):_t=e[161];let Ft;e[162]!==K||e[163]!==B||e[164]!==Ee||e[165]!==D||e[166]!==d?(Ft=B?t.jsx("nav",{className:"flex flex-shrink-0 items-center gap-1.5 overflow-x-auto px-3 pb-2","aria-label":d("rightSidebar.contextNotesTodo.sections.label"),children:Ee.map(Se=>{const et=K===Se.id;return t.jsxs("button",{type:"button",onClick:()=>D(Se.id),"aria-current":et?"page":void 0,className:le("flex flex-shrink-0 items-center gap-1.5 rounded-full border px-3 py-1.5 transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",et?"border-transparent bg-interactive-active text-foreground":"border-[var(--interactive-border)] text-muted-foreground"),children:[t.jsx(R,{name:Se.icon,className:"h-4 w-4 flex-shrink-0"}),et?t.jsx("span",{className:"whitespace-nowrap typography-meta",children:Se.label}):null,t.jsx("span",{className:"typography-micro text-muted-foreground",children:Se.count})]},Se.id)})}):null,e[162]=K,e[163]=B,e[164]=Ee,e[165]=D,e[166]=d,e[167]=Ft):Ft=e[167];const Xt=X?"overflow-hidden":"overflow-y-auto";let mt;e[168]!==Xt?(mt=le("min-h-0 min-w-0 flex-1 p-3",Xt),e[168]=Xt,e[169]=mt):mt=e[169];let Zt;e[170]!==K||e[171]!==m.notes||e[172]!==de||e[173]!==z||e[174]!==n||e[175]!==O||e[176]!==U?(Zt=K==="notes"?t.jsx(au,{projectRef:n,notes:m.notes,disabled:de,query:O,pinnedNoteIds:z,onTogglePinned:(Se,et)=>U("note",Se,et)}):null,e[170]=K,e[171]=m.notes,e[172]=de,e[173]=z,e[174]=n,e[175]=O,e[176]=U,e[177]=Zt):Zt=e[177];let es;e[178]!==K||e[179]!==c||e[180]!==k||e[181]!==de||e[182]!==O||e[183]!==De.sendToCurrentSession||e[184]!==De.sendToNewSession||e[185]!==De.sendToNewWorktreeSession||e[186]!==De.sendingTodoId||e[187]!==Z?(es=K==="todos"?t.jsx(gu,{todos:Z,query:O,disabled:de,canCreateWorktree:c,sendingTodoId:De.sendingTodoId,onPersistTodos:k,onSendToCurrentSession:De.sendToCurrentSession,onSendToNewSession:De.sendToNewSession,onSendToNewWorktreeSession:De.sendToNewWorktreeSession}):null,e[178]=K,e[179]=c,e[180]=k,e[181]=de,e[182]=O,e[183]=De.sendToCurrentSession,e[184]=De.sendToNewSession,e[185]=De.sendToNewWorktreeSession,e[186]=De.sendingTodoId,e[187]=Z,e[188]=es):es=e[188];let ts;e[189]!==K||e[190]!==ee||e[191]!==n.path||e[192]!==O?(ts=K==="memory"&&ee?t.jsx(Qd,{projectPath:n.path,query:O}):null,e[189]=K,e[190]=ee,e[191]=n.path,e[192]=O,e[193]=ts):ts=e[193];let ss;e[194]!==K||e[195]!==m.plans||e[196]!==i||e[197]!==X||e[198]!==se||e[199]!==n||e[200]!==O||e[201]!==U?(ss=K==="plans"&&!X?t.jsx(fu,{projectRef:n,plans:m.plans,query:O,pinnedPlanIds:se,onTogglePinned:(Se,et)=>U("plan",Se,et),onOpenPlan:i??te}):null,e[194]=K,e[195]=m.plans,e[196]=i,e[197]=X,e[198]=se,e[199]=n,e[200]=O,e[201]=U,e[202]=ss):ss=e[202];let ns;e[203]!==K||e[204]!==X||e[205]!==n?(ns=K==="plans"&&X&&n?t.jsx(h.Suspense,{fallback:null,children:t.jsx(ju,{savedProjectPlan:{projectRef:n,planId:X.id},onNavigatedToChat:()=>te(null)})}):null,e[203]=K,e[204]=X,e[205]=n,e[206]=ns):ns=e[206];let rs;e[207]!==mt||e[208]!==Zt||e[209]!==es||e[210]!==ts||e[211]!==ss||e[212]!==ns?(rs=t.jsxs("div",{className:mt,children:[Zt,es,ts,ss,ns]}),e[207]=mt,e[208]=Zt,e[209]=es,e[210]=ts,e[211]=ss,e[212]=ns,e[213]=rs):rs=e[213];let os;e[214]!==K||e[215]!==Qe||e[216]!==tt||e[217]!==B||e[218]!==ve||e[219]!==Ee||e[220]!==D||e[221]!==Ke||e[222]!==d?(os=B?null:t.jsxs("nav",{className:"relative flex flex-shrink-0 flex-col gap-0.5 overflow-y-auto border-l border-[var(--interactive-border)] p-2",style:{width:`${Ke}px`},"aria-label":d("rightSidebar.contextNotesTodo.sections.label"),children:[t.jsx("div",{className:le("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",ve&&"bg-[var(--interactive-border)]"),onPointerDown:tt,onPointerMove:Be,onPointerUp:Qe,onPointerCancel:Qe,role:"separator","aria-orientation":"vertical","aria-label":d("rightSidebar.contextNotesTodo.sections.resize")}),Ee.map(Se=>{const et=K===Se.id;return t.jsxs("button",{type:"button",onClick:()=>D(Se.id),"aria-current":et?"page":void 0,className:le("flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",et?"bg-interactive-active text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),style:{minHeight:0},children:[t.jsx(R,{name:Se.icon,className:"h-3.5 w-3.5 flex-shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",children:Se.label}),t.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:Se.count})]},Se.id)})]}),e[214]=K,e[215]=Qe,e[216]=tt,e[217]=B,e[218]=ve,e[219]=Ee,e[220]=D,e[221]=Ke,e[222]=d,e[223]=os):os=e[223];let as;e[224]!==rs||e[225]!==os?(as=t.jsxs("div",{className:"flex min-h-0 flex-1",children:[rs,os]}),e[224]=rs,e[225]=os,e[226]=as):as=e[226];const Qs=De.pendingSendTarget!==null;let is;e[227]!==De?(is=Se=>{Se||De.closeDialog()},e[227]=De,e[228]=is):is=e[228];const Xs=De.pendingSendTarget?.kind??"session";let ls;e[229]!==n.path||e[230]!==De.confirmSend||e[231]!==De.isSubmitting||e[232]!==Qs||e[233]!==is||e[234]!==Xs?(ls=t.jsx(Hl,{open:Qs,onOpenChange:is,target:Xs,projectDirectory:n.path,submitting:De.isSubmitting,onConfirm:De.confirmSend}),e[229]=n.path,e[230]=De.confirmSend,e[231]=De.isSubmitting,e[232]=Qs,e[233]=is,e[234]=Xs,e[235]=ls):ls=e[235];let As;return e[236]!==Ze||e[237]!==_t||e[238]!==Ft||e[239]!==as||e[240]!==ls?(As=t.jsxs("div",{className:Ze,children:[_t,Ft,as,ls]}),e[236]=Ze,e[237]=_t,e[238]=Ft,e[239]=as,e[240]=ls,e[241]=As):As=e[241],As};function Tu(s){return s.load}function Du(s){return s.saveTodos}function Pu(s){return s.currentSessionId}function Ru(s){return s.currentSessionDirectory}function Eu(s){return s.newSessionDraft}function Au(s){return s.setDraftProjectContextPin}function Bu(s){return s.id}function Lu(s){return s.id}function Mu(s){return s.agentMemoryFeatureAvailable&&s.agentMemoryToolEnabled}function Fu(s){return s.disabled}function Ou(s){return s.global}function $u(s){return s.isMobile}function Uu(s){return s.projectContextTab}function Wu(s){return s.setProjectContextTab}function _u(s){return s.agentMemoryViewedAt[On("global",null)]??0}function Vu(s){return s.projectContextSidebarWidth}function zu(s){return s.setProjectContextSidebarWidth}const Gu=({projects:s,worktreesByProject:e,directory:n,activeProjectId:r,chatDraftOpen:o,chatDraftTarget:a,homeDirectory:i})=>{const l=li(n)??ci(i),c=zs(n),d=zs(l);if((o?a==="chat":!!(c&&d&&(c===d||c.startsWith(`${d}/`))))&&l)return{id:Nn,path:l};const f=di(s,e,n);if(f)return{id:f.id,path:f.path};if(c)return null;const b=s.find(m=>m.id===r)??null;return b?{id:b.id,path:b.path}:null},Hu=s=>{const e=ze.c(8),n=It(Ku),r=It(qu),o=bs(Yu),a=it(Ju),i=it(Qu),l=it(Xu);let c;return e[0]!==r||e[1]!==i||e[2]!==l||e[3]!==s||e[4]!==o||e[5]!==n||e[6]!==a?(c=Gu({projects:n,worktreesByProject:a,directory:s,activeProjectId:r,chatDraftOpen:i,chatDraftTarget:l,homeDirectory:o}),e[0]=r,e[1]=i,e[2]=l,e[3]=s,e[4]=o,e[5]=n,e[6]=a,e[7]=c):c=e[7],c};function Ku(s){return s.projects}function qu(s){return s.activeProjectId}function Yu(s){return s.homeDirectory}function Ju(s){return s.availableWorktreesByProject}function Qu(s){return s.newSessionDraft.open}function Xu(s){return s.newSessionDraft.target}const hm=s=>{const e=ze.c(18),{onActionComplete:n,onOpenPlan:r}=s,o=bs(Zu),{t:a}=nt(),i=Ln(ef),l=it(tf),c=Hu(l),d=It(sf);let u;e[0]!==c||e[1]!==d?(u=c?d.find(p=>p.id===c.id)??null:null,e[0]=c,e[1]=d,e[2]=u):u=e[2];const f=u;let b;e:{if(!c){b=null;break e}if(c.id===Nn){let N;e[3]!==a?(N=a("sessions.sidebar.activity.chatsTitle"),e[3]=a,e[4]=N):N=e[4],b=N;break e}let p;e[5]!==o||e[6]!==f?.label||e[7]!==c.path?(p=f?.label?.trim()||ui(c.path,o)||c.path,e[5]=o,e[6]=f?.label,e[7]=c.path,e[8]=p):p=e[8],b=p}const m=b;let x;e:{if(!c||c.id===Nn){x=!1;break e}let p;e[9]!==i||e[10]!==c.path?(p=i.get(c.path)?.isGitRepo,e[9]=i,e[10]=c.path,e[11]=p):p=e[11],x=p===!0}const g=x;let S;return e[12]!==g||e[13]!==n||e[14]!==r||e[15]!==m||e[16]!==c?(S=t.jsx("div",{className:"h-full min-h-0 overflow-hidden bg-background",children:t.jsx(Cu,{projectRef:c,projectLabel:m,canCreateWorktree:g,onActionComplete:n,onOpenPlan:r})}),e[12]=g,e[13]=n,e[14]=r,e[15]=m,e[16]=c,e[17]=S):S=e[17],S};function Zu(s){return s.homeDirectory}function ef(s){return s.directories}function tf(s){return s.currentSessionDirectory}function sf(s){return s.projects}const Vs=Object.freeze({chunks:Object.freeze([]),byteLength:0,lastSequence:-1}),Tn=512*1024,nf=new TextEncoder,rf=new TextDecoder,ln=s=>{const e=nf.encode(s);if(e.byteLength<=Tn)return{text:s,byteLength:e.byteLength};let n=e.byteLength-Tn;for(;n<e.byteLength&&(e[n]&192)===128;)n+=1;const r=e.subarray(n);return{text:rf.decode(r),byteLength:r.byteLength}},Kt=(s,e)=>`${s}\0${e}`,cn=(s,e)=>{let n=null;for(const r of s.keys())e(r)&&(n??=new Map(s),n.delete(r));return n},of="terminal-store";let vr=!1,Sr=0;const $s=()=>typeof globalThis.crypto?.randomUUID=="function"?`tab-${globalThis.crypto.randomUUID()}`:(Sr+=1,`tab-${Date.now().toString(36)}-${Sr.toString(36)}`),dn=s=>typeof s=="object"&&s!==null,af=s=>{const e=/^tab-(\d+)$/.exec(s);if(!e)return null;const n=Number(e[1]);return Number.isFinite(n)?n:null};function gt(s){let e=s.trim();for(;e.length>1&&e.endsWith("/");)e=e.slice(0,-1);return e}const lf=/^Terminal(?: (\d+))?$/,jr=s=>{let e=0;for(const n of s){const r=lf.exec(n.label);if(!r)continue;const o=r[1]?Number.parseInt(r[1],10):1;Number.isSafeInteger(o)&&(e=Math.max(e,o))}return e===0?"Terminal":`Terminal ${e+1}`},Us=(s,e)=>({id:s,terminalSessionId:null,lifecycle:"idle",label:e,iconKey:null,isConnecting:!1,createdAt:Date.now(),previewUrl:null,previewAutoOpened:!1,previewUrlLocked:!1}),un=s=>({tabs:[s],activeTabId:s.id}),Pt=(s,e)=>s.tabs.findIndex(n=>n.id===e);let fn=null,mn=null;const cf=s=>{if(mn&&fn?.sessions===s.sessions&&fn.nextTabId===s.nextTabId)return mn;const e={sessions:Array.from(s.sessions.entries()).map(([n,r])=>[n,{activeTabId:r.activeTabId,tabs:r.tabs.map(o=>({id:o.id,label:o.label,iconKey:o.iconKey,createdAt:o.createdAt}))}]),nextTabId:s.nextTabId};return fn={sessions:s.sessions,nextTabId:s.nextTabId},mn=e,e},df=()=>{const s=nl(()=>_i());if(!s)return;let e=null;return{getItem:n=>s.getItem(n),setItem:(n,r)=>{if(r.state!==e)return e=r.state,s.setItem(n,r)},removeItem:n=>(e=null,s.removeItem(n))}},at=Js()(qr(Yr((s,e)=>({sessions:new Map,buffers:new Map,projectActionRuns:{},nextChunkId:1,nextTabId:1,hasHydrated:typeof window>"u",ensureDirectory:n=>{const r=gt(n);r&&s(o=>{if(o.sessions.has(r))return o;const a=new Map(o.sessions),i=$s(),l=Us(i,"Terminal");return a.set(r,un(l)),{sessions:a,nextTabId:o.nextTabId+1}})},getDirectoryState:n=>{const r=gt(n);return e().sessions.get(r)},getActiveTab:n=>{const r=gt(n),o=e().sessions.get(r);if(!o)return;const a=o.activeTabId;return a?o.tabs.find(i=>i.id===a)??o.tabs[0]:o.tabs[0]},getBuffer:(n,r)=>e().buffers.get(Kt(gt(n),r))??Vs,createTab:n=>{const r=gt(n);if(!r)return"tab-invalid";const o=$s();return s(a=>{const i=new Map(a.sessions),l=i.get(r),c=a.nextTabId+1,d=jr(l?.tabs??[]),u=Us(o,d);return l?i.set(r,{...l,tabs:[...l.tabs,u]}):i.set(r,un(u)),{sessions:i,nextTabId:c}}),o},adoptServerSessions:(n,r)=>{const o=gt(n);!o||r.length===0||s(a=>{const i=a.sessions.get(o),l=new Set;for(const x of i?.tabs??[])l.add(x.id),x.terminalSessionId&&l.add(x.terminalSessionId);const c=r.filter(x=>!l.has(x.sessionId));if(c.length===0)return a;const d=[...i?.tabs??[]],u=d.length===1&&d[0].terminalSessionId===null&&d[0].lifecycle==="idle"&&!a.buffers.has(Kt(o,d[0].id))?d[0]:null;u&&(d.length=0);for(const x of c){const g={...Us(x.sessionId,u&&d.length===0?u.label:jr(d)),terminalSessionId:x.sessionId,lifecycle:x.status,createdAt:x.createdAt??Date.now()};d.push(g)}const f=i?.activeTabId??null,b=f&&d.some(x=>x.id===f)?f:d[0]?.id??null,m=new Map(a.sessions);return m.set(o,{tabs:d,activeTabId:b}),{sessions:m}})},setActiveTab:(n,r)=>{const o=gt(n);s(a=>{const i=new Map(a.sessions),l=i.get(o);return!l||l.activeTabId===r||Pt(l,r)<0?a:(i.set(o,{...l,activeTabId:r}),{sessions:i})})},setTabLabel:(n,r,o)=>{const a=gt(n),i=o.trim();i&&s(l=>{const c=new Map(l.sessions),d=c.get(a);if(!d)return l;const u=Pt(d,r);if(u<0||d.tabs[u]?.label===i)return l;const f=[...d.tabs];return f[u]={...f[u],label:i},c.set(a,{...d,tabs:f}),{sessions:c}})},setTabIconKey:(n,r,o)=>{const a=gt(n);s(i=>{const l=new Map(i.sessions),c=l.get(a);if(!c)return i;const d=Pt(c,r);if(d<0)return i;const u=o?.trim()||null;if(c.tabs[d]?.iconKey===u)return i;const f=[...c.tabs];return f[d]={...f[d],iconKey:u},l.set(a,{...c,tabs:f}),{sessions:l}})},closeTab:(n,r)=>{const o=gt(n);s(a=>{const i=new Map(a.sessions),l=i.get(o);if(!l)return a;const c=Pt(l,r);if(c<0)return a;const d=l.tabs.filter(g=>g.id!==r),u=Object.fromEntries(Object.entries(a.projectActionRuns).filter(([,g])=>!(g.directory===o&&g.tabId===r))),f=Object.keys(u).length!==Object.keys(a.projectActionRuns).length,b=Kt(o,r),m=a.buffers.has(b)?cn(a.buffers,g=>g===b):null;if(d.length===0){const g=$s(),S=Us(g,"Terminal");return i.set(o,un(S)),{sessions:i,nextTabId:a.nextTabId+1,...m?{buffers:m}:{},...f?{projectActionRuns:u}:{}}}let x=l.activeTabId;return l.activeTabId===r&&(x=d[Math.min(c,d.length-1)]?.id??d[0]?.id??null),i.set(o,{...l,tabs:d,activeTabId:x}),{sessions:i,...m?{buffers:m}:{},...f?{projectActionRuns:u}:{}}})},setTabSessionId:(n,r,o)=>{const a=gt(n);s(i=>{const l=new Map(i.sessions),c=l.get(a);if(!c)return i;const d=Pt(c,r);if(d<0)return i;const u=c.tabs[d],f=o!==null&&u.terminalSessionId!==o,b=o?"running":u.terminalSessionId?"exited":u.lifecycle,m={...u,terminalSessionId:o,lifecycle:b,isConnecting:!1},x=Kt(a,r),g=f&&i.buffers.has(x)?cn(i.buffers,p=>p===x):null,S=[...c.tabs];return S[d]=m,l.set(a,{...c,tabs:S}),{sessions:l,...g?{buffers:g}:{}}})},setTabLifecycle:(n,r,o)=>{const a=gt(n);s(i=>{const l=new Map(i.sessions),c=l.get(a);if(!c)return i;const d=Pt(c,r);if(d<0)return i;const u=[...c.tabs];return u[d]={...u[d],lifecycle:o,isConnecting:!1},l.set(a,{...c,tabs:u}),{sessions:l}})},setConnecting:(n,r,o)=>{const a=gt(n);s(i=>{const l=new Map(i.sessions),c=l.get(a);if(!c)return i;const d=Pt(c,r);if(d<0)return i;const u=[...c.tabs];return u[d]={...u[d],isConnecting:o},l.set(a,{...c,tabs:u}),{sessions:l}})},replaceBuffer:(n,r,o,a)=>{const i=gt(n);s(l=>{const c=l.sessions.get(i);if(!c||Pt(c,r)<0)return l;const d=Kt(i,r),u=l.buffers.get(d)??Vs;if(u.lastSequence>a)return l;const f=ln(o);if(u.lastSequence===a&&u.byteLength===f.byteLength&&u.chunks.map(x=>x.data).join("")===f.text)return l;const b=l.nextChunkId,m=new Map(l.buffers);return m.set(d,{chunks:f.text?[{id:b,data:f.text,byteLength:f.byteLength}]:[],byteLength:f.byteLength,lastSequence:a}),{buffers:m,nextChunkId:f.text?b+1:b}})},appendToBuffer:(n,r,o,a,i)=>{if(!o)return;const l=gt(n);s(c=>{const d=c.sessions.get(l);if(!d||Pt(d,r)<0)return c;const u=Kt(l,r),f=c.buffers.get(u)??Vs;if(a!==void 0&&a<=f.lastSequence)return c;const b=c.nextChunkId,m=ln(o),x=i!==void 0&&i!==o?ln(i).text:void 0,g={id:b,data:m.text,...x!==void 0?{replayData:x}:{},byteLength:m.byteLength},S=[...f.chunks,g];let p=f.byteLength+g.byteLength;for(;p>Tn&&S.length>1;){const A=S.shift();if(!A)break;p-=A.byteLength}const N=new Map(c.buffers);return N.set(u,{chunks:S,byteLength:p,lastSequence:a??f.lastSequence}),{buffers:N,nextChunkId:b+1}})},setTabPreviewUrl:(n,r,o,a={})=>{const i=gt(n);s(l=>{const c=new Map(l.sessions),d=c.get(i);if(!d)return l;const u=Pt(d,r);if(u<0)return l;const f=d.tabs[u],b=a.autoOpened??f.previewAutoOpened,m=a.locked??f.previewUrlLocked;if(f.previewUrl===o&&f.previewAutoOpened===b&&f.previewUrlLocked===m)return l;const x=[...d.tabs];return x[u]={...f,previewUrl:o,previewAutoOpened:b,previewUrlLocked:m},c.set(i,{...d,tabs:x}),{sessions:c}})},markPreviewAutoOpened:(n,r)=>{const o=gt(n);s(a=>{const i=new Map(a.sessions),l=i.get(o);if(!l)return a;const c=Pt(l,r);if(c<0)return a;const d=l.tabs[c];if(!d.previewUrl||d.previewAutoOpened)return a;const u=[...l.tabs];return u[c]={...d,previewAutoOpened:!0},i.set(o,{...l,tabs:u}),{sessions:i}})},setProjectActionRun:n=>{s(r=>{const o=r.projectActionRuns[n.key];return o&&o.directory===n.directory&&o.actionId===n.actionId&&o.tabId===n.tabId&&o.sessionId===n.sessionId&&o.status===n.status?r:{projectActionRuns:{...r.projectActionRuns,[n.key]:n}}})},updateProjectActionRunStatus:(n,r)=>{s(o=>{const a=o.projectActionRuns[n];return!a||a.status===r?o:{projectActionRuns:{...o.projectActionRuns,[n]:{...a,status:r}}}})},removeProjectActionRun:n=>{s(r=>{if(!r.projectActionRuns[n])return r;const o={...r.projectActionRuns};return delete o[n],{projectActionRuns:o}})},removeDirectory:n=>{const r=gt(n);s(o=>{const a=new Map(o.sessions);a.delete(r);const i=Kt(r,""),l=cn(o.buffers,d=>d.startsWith(i)),c=Object.fromEntries(Object.entries(o.projectActionRuns).filter(([,d])=>d.directory!==r));return{sessions:a,...l?{buffers:l}:{},projectActionRuns:c}})},clearAll:()=>{s({sessions:new Map,buffers:new Map,projectActionRuns:{},nextChunkId:1,nextTabId:1})}}),{name:of,storage:df(),partialize:cf,merge:(s,e)=>{if(!dn(s))return e;const n=Array.isArray(s.sessions)?s.sessions:[],r=new Map;let o=0;for(const l of n){if(!Array.isArray(l)||l.length!==2)continue;const[c,d]=l;if(typeof c!="string"||!dn(d))continue;const u=Array.isArray(d.tabs)?d.tabs:[],f=[],b=new Map;for(const S of u){if(!dn(S))continue;const p=typeof S.id=="string"?S.id:null;if(!p)continue;const N=af(p);N!==null&&(o=Math.max(o,N));const A=N===null?p:$s();b.set(p,A),f.push({id:A,label:typeof S.label=="string"?S.label:"Terminal",iconKey:typeof S.iconKey=="string"?S.iconKey:null,terminalSessionId:null,lifecycle:"idle",createdAt:typeof S.createdAt=="number"?S.createdAt:Date.now(),isConnecting:!1,previewUrl:null,previewAutoOpened:!1,previewUrlLocked:!1})}if(f.length===0)continue;const m=typeof d.activeTabId=="string"?d.activeTabId:null,x=m?b.get(m)??m:null,g=x?f.some(S=>S.id===x):!1;r.set(c,{tabs:f,activeTabId:g?x:f[0].id})}const a=typeof s.nextTabId=="number"&&Number.isFinite(s.nextTabId)?s.nextTabId:1,i=Math.max(e.nextTabId,a,o+1);return{...e,sessions:r,buffers:new Map,nextChunkId:1,nextTabId:i,hasHydrated:!0}}})));if(typeof window<"u"&&!vr){vr=!0;const s=at.persist,e=()=>{at.getState().hasHydrated||at.setState({hasHydrated:!0})};s?.hasHydrated?.()?e():s?.onFinishHydration?s.onFinishHydration(e):e()}function uf(s){const{colors:e}=s,n=e.syntax.base;return{background:e.surface.background,foreground:n.foreground,cursor:e.interactive.cursor,cursorAccent:e.surface.background,selectionBackground:e.interactive.selection,selectionForeground:e.interactive.selectionForeground,selectionInactiveBackground:e.interactive.selection+"50",black:e.surface.muted,red:e.status.error,green:e.status.success,yellow:e.status.warning,blue:n.function,magenta:n.keyword,cyan:n.type,white:n.foreground,brightBlack:n.comment,brightRed:e.status.error,brightGreen:e.status.success,brightYellow:e.status.warning,brightBlue:n.function,brightMagenta:n.keyword,brightCyan:n.type,brightWhite:e.surface.elevatedForeground}}function ff(s,e,n,r,o=!1){const i=`${s}, "JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace`;return{cursorBlink:!1,cursorStyle:"bar",fontSize:e,fontFamily:i,allowTransparency:!1,theme:{background:n.background,foreground:n.foreground,cursor:n.cursor,cursorAccent:n.cursorAccent,selectionBackground:n.selectionBackground,selectionForeground:n.selectionForeground,black:n.black,red:n.red,green:n.green,yellow:n.yellow,blue:n.blue,magenta:n.magenta,cyan:n.cyan,white:n.white,brightBlack:n.brightBlack,brightRed:n.brightRed,brightGreen:n.brightGreen,brightYellow:n.brightYellow,brightBlue:n.brightBlue,brightMagenta:n.brightMagenta,brightCyan:n.brightCyan,brightWhite:n.brightWhite},scrollback:1e4,ghostty:r,disableStdin:o}}const hn=["\x1B[0m","\x1B[m"],mf=s=>{const e=s.trim(),n=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(e)?.[1];if(n){const a=n.length<=4?n.slice(0,3).split("").map(i=>i+i).join(""):n.slice(0,6);return[Number.parseInt(a.slice(0,2),16),Number.parseInt(a.slice(2,4),16),Number.parseInt(a.slice(4,6),16)]}const r=/^rgba?\(\s*(\d{1,3})\s*[, ]\s*(\d{1,3})\s*[, ]\s*(\d{1,3})(?:\s*[,/]\s*[\d.]+)?\s*\)$/i.exec(e);if(!r)return null;const o=r.slice(1,4).map(Number);return o.some(a=>a<0||a>255)?null:o},Nr=s=>{const e=mf(s);return e?`\x1B[0;48;2;${e[0]};${e[1]};${e[2]}m`:null},hf=(s,e,n)=>{const r=e+s;if(!n)return{data:r,carry:""};let o=0;const a=Math.max(...hn.map(c=>c.length))-1;for(let c=1;c<=Math.min(a,r.length);c+=1){const d=r.slice(-c);hn.some(u=>u.length>d.length&&u.startsWith(d))&&(o=c)}const i=o>0?r.slice(-o):"";let l=o>0?r.slice(0,-o):r;for(const c of hn)l=l.replaceAll(c,n);return{data:l,carry:i}},pf=(s,e,n,r,o)=>{if(n.width<=0||n.height<=0||r<=0||o<=0)return null;const a=Math.floor((s-n.left)/n.width*r),i=Math.floor((e-n.top)/n.height*o);return{column:Math.max(0,Math.min(r-1,a)),row:Math.max(0,Math.min(o-1,i))}},gf=(s,e)=>{const n=Math.max(0,Math.min(s.length-1,e)),r=i=>!!(i&&!/^\s+$/u.test(i));if(!r(s[n]))return{startColumn:n,endColumn:n};let o=n,a=n;for(;o>0&&r(s[o-1]);)o-=1;for(;a<s.length-1&&r(s[a+1]);)a+=1;return{startColumn:o,endColumn:a}};let xf=null;const bf=()=>xf??=Qt(()=>import("./vendor-ghostty-web-CrxinGGH.js"),__vite__mapDeps([122,5])).then(async s=>({module:s,ghostty:await s.Ghostty.load()})),yf=2e3,wf=()=>Promise.resolve(window.__openchamberEnsureNerdFonts?.()).catch(()=>{}),vf=s=>{const e=Promise.all([fi(s),wf()]).then(()=>{}),n=new Promise(r=>{const o=setTimeout(()=>r(!1),yf);e.then(()=>{clearTimeout(o),r(!0)})});return{loaded:e,loadedBeforeTimeout:n}},Sf=(s,e,n)=>{if(typeof window>"u"||typeof document>"u")return null;const r=document.createElement("canvas").getContext("2d");if(!r||s.clientWidth<24||s.clientHeight<24)return null;r.font=`${n}px ${e}`;const o=r.measureText("M"),a=Math.ceil(o.width),i=Math.ceil((o.actualBoundingBoxAscent||n*.8)+(o.actualBoundingBoxDescent||n*.2))+2;if(a<1||i<1)return null;const l=window.getComputedStyle(s),c=(Number.parseInt(l.paddingLeft,10)||0)+(Number.parseInt(l.paddingRight,10)||0),d=(Number.parseInt(l.paddingTop,10)||0)+(Number.parseInt(l.paddingBottom,10)||0);return{cols:Math.max(2,Math.floor((s.clientWidth-c-15)/a)),rows:Math.max(1,Math.floor((s.clientHeight-d)/i))}},Io=h.forwardRef(({sessionKey:s,chunks:e,onInput:n,onResize:r,theme:o,monoFont:a,fontFamily:i,fontSize:l,className:c,enableTouchScroll:d=!1,autoFocus:u=!0,isVisible:f=!0},b)=>{const m=h.useRef(null),x=h.useRef(null),g=h.useRef(null),S=h.useRef(n),p=h.useRef(r),N=h.useRef(null),A=h.useRef(null),L=h.useRef(null),I=h.useRef(""),T=h.useRef(""),y=h.useRef(Nr(o.background)),v=h.useRef(!1),$=h.useRef(0),U=h.useRef(f),W=h.useRef(!1),[z,q]=h.useState(0),[se,J]=h.useState(0);S.current=n,p.current=r,U.current=f,y.current=Nr(o.background),h.useLayoutEffect(()=>{const V=m.current;if(!V)return;const P=Sf(V,i,l);A.current=P,P&&p.current(P.cols,P.rows)},[i,l]);const G=h.useCallback(()=>{const V=m.current,P=x.current;if(!V||!P||!g.current||!U.current)return;const B=V.getBoundingClientRect();if(!(B.width<24||B.height<24))try{g.current.fit();const M={cols:P.cols,rows:P.rows};(!N.current||N.current.cols!==M.cols||N.current.rows!==M.rows)&&(N.current=M,p.current(M.cols,M.rows)),W.current||(W.current=!0,q(D=>D+1))}catch{}},[]),ee=h.useCallback(()=>{if(v.current||!I.current||!x.current)return;const V=x.current,P=I.current;I.current="";const B=hf(P,T.current,y.current);if(T.current=B.carry,!B.data){I.current&&ee();return}v.current=!0;const M=$.current;V.write(B.data,()=>{x.current!==V||$.current!==M||(v.current=!1,I.current&&ee())})},[]),ue=h.useCallback(()=>{L.current=null,I.current="",T.current="",v.current=!1,$.current+=1;const V=x.current;if(!V){J(P=>P+1);return}try{V.reset();const P=y.current;P&&V.write(`${P}\x1B[2J\x1B[H`)}catch{J(P=>P+1)}},[]);return h.useEffect(()=>{const V=m.current;if(!V)return;let P=!1,B=null,M=null,D=null,_=null,E=[];const K=()=>{B&&U.current&&(B.options.cursorBlink=!0)},O=ge=>{ge.relatedTarget instanceof Node&&V.contains(ge.relatedTarget)||B&&(B.options.cursorBlink=!1)},ne=()=>{B&&U.current&&V.contains(document.activeElement)&&(B.options.cursorBlink=!0)},X=()=>{B&&(B.options.cursorBlink=!1)};V.addEventListener("focusin",K),V.addEventListener("focusout",O),window.addEventListener("focus",ne),window.addEventListener("blur",X);const te=vf(a);return Promise.all([bf(),te.loadedBeforeTimeout]).then(([{module:ge,ghostty:re},pe])=>{if(P)return;B=new ge.Terminal({...ff(i,l,o,re,!1),...A.current??{}});const Z=new ge.FitAddon;B.loadAddon(Z),B.open(V),V.setAttribute("autocapitalize","off"),V.setAttribute("autocorrect","off"),V.setAttribute("spellcheck","false"),x.current=B,g.current=Z,E=[B.onData(me=>S.current(me))],M=new ResizeObserver(()=>{D&&clearTimeout(D),D=setTimeout(G,80)}),M.observe(V),G();const de=y.current;de&&B.write(`${de}\x1B[2J\x1B[H`),_=requestAnimationFrame(G),pe||te.loaded.then(()=>{!P&&x.current===B&&J(me=>me+1)})}),()=>{P=!0;const ge=document.activeElement;ge instanceof HTMLElement&&V.contains(ge)&&(ge.blur(),window.Capacitor?.getPlatform?.()==="android"&&Qt(async()=>{const{Keyboard:pe}=await import("./vendor-capacitor-keyboard-CYccoJjr.js");return{Keyboard:pe}},__vite__mapDeps([123,124])).then(({Keyboard:pe})=>pe.hide()).catch(()=>{})),M?.disconnect(),D&&clearTimeout(D),_!==null&&cancelAnimationFrame(_),V.removeEventListener("focusin",K),V.removeEventListener("focusout",O),window.removeEventListener("focus",ne),window.removeEventListener("blur",X),E.forEach(re=>re.dispose()),B?.dispose(),x.current=null,g.current=null,N.current=null,L.current=null,I.current="",T.current="",v.current=!1,$.current+=1,W.current=!1}},[G,i,l,a,se,o]),h.useEffect(()=>{const V=x.current,P=m.current;!V||!P||(V.options.cursorBlink=f&&document.hasFocus()&&P.contains(document.activeElement))},[f,z]),h.useEffect(()=>{if(!x.current)return;if(e.length===0){L.current!==null&&ue();return}const P=L.current;let B=-1;if(P!==null){for(let _=e.length-1;_>=0;_-=1){const E=e[_].id;if(E===P){B=_;break}if(E<P)break}if(B<0){ue();return}}const M=B<0,D=B>=0?e.slice(B+1):e;I.current+=D.map(_=>M?_.replayData??_.data:_.data).join(""),L.current=e.at(-1)?.id??null,ee()},[e,ee,z,ue]),h.useEffect(()=>{if(!u||!f)return;const V=requestAnimationFrame(()=>x.current?.focus());return()=>cancelAnimationFrame(V)},[u,f,z,s]),h.useEffect(()=>{const V=m.current;if(!d||!V)return;const P=B=>{const M=B;if(!M.isComposing)switch(M.inputType){case"insertText":M.data&&S.current(M.data);break;case"insertLineBreak":case"insertParagraph":S.current("\r");break;case"deleteContentBackward":S.current("");break}};return V.addEventListener("beforeinput",P),()=>V.removeEventListener("beforeinput",P)},[d,z]),h.useEffect(()=>{const V=m.current,P=x.current;if(!d||!V||!P)return;let B=null,M=null,D="idle",_=0,E=0,K=0,O=0,ne=null;const X=Math.max(12,l+2),te=()=>{window.Capacitor?.getPlatform?.()==="android"&&Qt(async()=>{const{Keyboard:ae}=await import("./vendor-capacitor-keyboard-CYccoJjr.js");return{Keyboard:ae}},__vite__mapDeps([123,124])).then(({Keyboard:ae})=>ae.show()).catch(()=>{})},ge=()=>{M&&(clearTimeout(M),M=null)},re=(F,ae)=>{const he=V.querySelector("canvas");return he?pf(F,ae,he.getBoundingClientRect(),P.cols,P.rows):null},pe=(F,ae)=>{const he=V.querySelector("canvas");if(!he)return;const we=he.getBoundingClientRect(),Te=we.left+(ae.column+.5)/P.cols*we.width,Ge=we.top+(ae.row+.5)/P.rows*we.height;he.dispatchEvent(new MouseEvent(F,{bubbles:!0,cancelable:!0,button:0,buttons:1,clientX:Te,clientY:Ge}))},Z=()=>{document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,button:0,buttons:0}))},de=F=>{F.pointerType!=="touch"||B!==null||(B=F.pointerId,D="pending",_=F.clientX,E=F.clientY,K=F.clientY,O=0,ne=null,V.setPointerCapture(F.pointerId),M=setTimeout(()=>{if(M=null,B!==F.pointerId||D!=="pending")return;const ae=re(_,E);if(!ae)return;const he=P.buffer.active,we=Math.max(0,he.length-P.rows-he.viewportY+ae.row),Te=he.getLine(we),Ge=Array.from({length:P.cols},(Re,Ce)=>Te?.getCell(Ce)?.getChars()??""),Fe=gf(Ge,ae.column),ve={column:Fe.startColumn,row:ae.row};ne={column:Fe.endColumn,row:ae.row},D="selecting",pe("mousedown",ve),pe("mousemove",ne)},350))},me=F=>{if(B!==F.pointerId)return;if(D==="selecting"){const we=re(F.clientX,F.clientY);we&&(!ne||we.column!==ne.column||we.row!==ne.row)&&(ne=we,pe("mousemove",we)),F.cancelable&&F.preventDefault();return}if(D==="pending"){if(Math.hypot(F.clientX-_,F.clientY-E)<8)return;ge(),D="scrolling"}if(D!=="scrolling")return;const ae=K-F.clientY;K=F.clientY,O+=ae;const he=Math.trunc(O/X);he&&(P.scrollLines(he),O-=he*X),F.cancelable&&F.preventDefault()},j=F=>{if(B!==F.pointerId)return;const ae=D==="pending",he=D==="selecting";ge(),V.hasPointerCapture(F.pointerId)&&V.releasePointerCapture(F.pointerId),B=null,D="idle",he&&Z(),ae&&(P.focus(),te())},Y=F=>{if(B!==F.pointerId)return;const ae=D==="selecting";ge(),V.hasPointerCapture(F.pointerId)&&V.releasePointerCapture(F.pointerId),B=null,D="idle",ae&&Z()};return V.addEventListener("pointerdown",de),V.addEventListener("pointermove",me,{passive:!1}),V.addEventListener("pointerup",j),V.addEventListener("pointercancel",Y),()=>{ge(),V.removeEventListener("pointerdown",de),V.removeEventListener("pointermove",me),V.removeEventListener("pointerup",j),V.removeEventListener("pointercancel",Y)}},[d,l,z]),h.useImperativeHandle(b,()=>({focus:()=>x.current?.focus(),fit:G,getSelection:()=>{const V=x.current,P=V?.getSelectionPosition(),B=V?.getSelection()??"";return!P||!B.trim()?null:{text:B,startLine:P.start.y+1,endLine:P.end.y+1}}}),[G]),t.jsx("div",{ref:m,"data-terminal-owner":"main",className:le("terminal-viewport-container h-full w-full overflow-hidden touch-none",c)})});Io.displayName="TerminalViewport";const jf="\x1B",Co=new RegExp(`${jf}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Nf=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,kf=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,If=/Serving HTTP on .*? port (\d{2,5})/i,Cf=new Set([".",",",";",":","!","?"]),To=s=>{let e=s;for(;e.length>0;){const n=e[e.length-1];if(n===")"||n==="]"||n==="}"||n===">"){const r=n===")"?"(":n==="]"?"[":n==="}"?"{":"<",o=e.slice(0,-1),a=(o.match(new RegExp(`\\${r}`,"g"))||[]).length,i=(o.match(new RegExp(`\\${n}`,"g"))||[]).length;if(a>i)break;e=o;continue}if(Cf.has(n)){e=e.slice(0,-1);continue}break}return e},Dn=s=>{let e=To(s);return e=e.replace("0.0.0.0","127.0.0.1"),e=e.replace("[::1]","127.0.0.1"),e=e.replace("[::]","127.0.0.1"),e},Tf=s=>{if(!s)return[];const e=s.replace(Co,""),n=[],r=new Set,o=i=>{r.has(i)||(r.add(i),n.push(i))},a=e.match(If);if(a?.[1]){const i=Number.parseInt(a[1],10);Number.isFinite(i)&&i>0&&i<=65535&&o(`http://127.0.0.1:${i}/`)}for(const i of e.split(`
|
|
10
|
-
`)){if(!kf.test(i))continue;const l=Array.from(i.matchAll(Nf));if(l.length===0)continue;const c=l.find(d=>{try{return!!new URL(Dn(d[1])).port}catch{return!1}});o(Dn((c??l[0])[1]))}return n},Do=s=>Tf(s)[0]??null,Df=async(s,e=1500)=>{if(!s||typeof window>"u")return!1;let n;try{n=new URL(s)}catch{return!1}if(n.protocol!=="http:"&&n.protocol!=="https:")return!1;const r=n.hostname.toLowerCase();if(r!=="localhost"&&r!=="127.0.0.1"&&r!=="0.0.0.0"&&r!=="::1"&&r!=="::")return!1;const o=new AbortController,a=window.setTimeout(()=>o.abort(),e);try{const i=await Mt("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:n.toString()}),cache:"no-store",signal:o.signal});return i.ok?(await i.json().catch(()=>null))?.ok===!0:!1}catch{return!1}finally{window.clearTimeout(a)}},Pf=/https?:\/\/[^\s<>'"`]+/gi,pm=(s,{requireAnnounced:e=!1}={})=>{const n=Do(s);if(n)return n;if(e)return null;const r=String(s||"").replace(Co,""),o=[];for(const l of r.match(Pf)??[])try{const c=new URL(To(l));c.port&&o.push(c)}catch{}if(o.length===0)return null;const a=l=>{const c=l.hostname.toLowerCase();return(c==="localhost"||c==="127.0.0.1"||c==="0.0.0.0"||c==="::1"?50:0)-(l.search||l.hash?10:0)};let i=o[0];for(const l of o.slice(1))a(l)>a(i)&&(i=l);return Dn(i.toString())},Rf={esc:"\x1B",tab:" ",enter:"\r","arrow-up":"\x1B[A","arrow-down":"\x1B[B","arrow-left":"\x1B[D","arrow-right":"\x1B[C"},Ef=(s,e)=>{if(e&&s.startsWith("arrow-")){const n=e==="ctrl"?"5":"3",r={"arrow-up":"A","arrow-down":"B","arrow-right":"C","arrow-left":"D"}[s];return`\x1B[1;${n}${r}`}return Rf[s]},Po=s=>{const e=s[0]?.toUpperCase();return!e||e<"A"||e>"Z"?null:String.fromCharCode(e.charCodeAt(0)&31)},Af=(s,e)=>s&&(e==="ctrl"?Po(s)??s:s.length===1&&s!=="\x1B"?`\x1B${s}`:s),kr={cols:80,rows:24},gm=({visible:s})=>{const{t:e}=nt(),{terminal:n,runtime:r}=Bn(),{currentTheme:o}=Br(),a=h.useRef({themeMode:"dark",terminalBackground:"",terminalForeground:""});a.current={themeMode:o.metadata.variant==="light"?"light":"dark",terminalBackground:o.colors.surface.background,terminalForeground:o.colors.syntax.base.foreground};const{monoFont:i}=mi(),l=Ve(C=>C.terminalFontSize),c=Ve(C=>C.terminalShell),d=Ve(C=>C.terminalLoginShells.includes(C.terminalShell)),{isMobile:u,isTablet:f,hasTouchOnlyPointer:b}=xs(),m=u||f,x=(m||b)&&r.platform==="web",g=r.platform!=="vscode",S=Ve(C=>C.showTerminalQuickKeysOnDesktop),p=m||S,N=it(C=>C.currentSessionId),A=it(C=>C.newSessionDraft),L=N!==null||A?.open===!0,I=hi()??null,T=at(C=>I?C.sessions.get(I):void 0),y=at(C=>C.hasHydrated),v=at(C=>C.ensureDirectory),$=at(C=>C.createTab),U=at(C=>C.setActiveTab),W=at(C=>C.closeTab),z=at(C=>C.setTabSessionId),q=at(C=>C.adoptServerSessions),se=at(C=>C.setTabLifecycle),J=at(C=>C.setConnecting),G=at(C=>C.appendToBuffer),ee=at(C=>C.replaceBuffer),ue=at(C=>C.setTabPreviewUrl),V=pi(C=>C.addDraft),P=Ve(C=>C.openContextPreview),B=h.useMemo(()=>T?g?T.activeTabId??T.tabs[0]?.id??null:T.tabs[0]?.id??null:null,[T,g]),M=h.useMemo(()=>{if(T)return B?T.tabs.find(C=>C.id===B)??T.tabs[0]:T.tabs[0]},[T,B]),D=h.useMemo(()=>(T?.tabs??[]).map(C=>({icon:(()=>{const Q=C.iconKey?co[C.iconKey]??"terminal":"terminal";return t.jsx(R,{name:Q,className:"h-4 w-4"})})(),id:C.id,label:C.label,title:C.label,closeLabel:e("terminalView.tabs.closeTabTitle")})),[T?.tabs,e]),_=M?.terminalSessionId??null,E=M?.lifecycle??"idle",K=at(C=>I&&B?C.getBuffer(I,B).chunks:Vs.chunks),O=M?.isConnecting??!1,ne=M?.previewUrl??null,[X,te]=h.useState(null),[ge,re]=h.useState(!1),[pe,Z]=h.useState(!1),[de,me]=h.useState(null),[j,Y]=h.useState(!1),F=h.useRef(null),ae=h.useRef(null),he=h.useRef(B),we=h.useRef(_),Te=h.useRef(I),Ge=h.useRef(null),Fe=h.useRef(null),ve=h.useRef(new Set),Re=h.useRef(""),Ce=h.useRef(new Set),Ue=h.useRef(0),He=h.useCallback(()=>{Re.current="",Ce.current.clear(),Ue.current+=1},[]),qe=h.useCallback(()=>{x||typeof document<"u"&&!document.hasFocus()||Ge.current?.focus()},[x]),Ke=h.useCallback(()=>{x||Ge.current?.focus()},[x]),We=s??!1,[tt,ct]=h.useState(We);h.useEffect(()=>{We&&ct(!0)},[We]),h.useEffect(()=>{we.current=_},[_]),h.useEffect(()=>{!_||!n.updateAppearance||n.updateAppearance(_,a.current).catch(()=>{})},[o.colors.surface.background,o.colors.syntax.base.foreground,o.metadata.variant,n,_]),h.useEffect(()=>{he.current=B,He()},[B,He]),h.useEffect(()=>{Te.current=I},[I]),h.useEffect(()=>{if(!y||!I||!n.listSessions)return;let C=!1;const Q=I;return n.listSessions(Q).then(ie=>{C||Te.current!==Q||q(Q,ie)}).catch(()=>{}),()=>{C=!0}},[y,I,n,q]),h.useEffect(()=>{if(!n.touchSessions)return;const C=()=>{if(typeof navigator<"u"&&!navigator.onLine)return;const ie=[];for(const Oe of at.getState().sessions.values())for(const be of Oe.tabs)be.terminalSessionId&&ie.push(be.terminalSessionId);ie.length>0&&n.touchSessions?.(ie).catch(()=>{})};C();const Q=setInterval(C,600*1e3);return()=>clearInterval(Q)},[n]),h.useEffect(()=>{!p&&de!==null&&me(null)},[p,de,me]),h.useEffect(()=>{!_&&de!==null&&me(null)},[_,de,me]);const Be=h.useCallback(()=>{F.current?.(),F.current=null,ae.current=null,Z(!1)},[]);h.useEffect(()=>()=>{Be(),we.current=null},[Be]);const Ye=h.useCallback((C,Q,ie)=>{if(!ie)return;const Oe=`${Re.current}${ie}`.replace(/\r\n|\r/g,`
|
|
11
|
-
`),be=Oe.split(`
|
|
12
|
-
`),Le=Oe.endsWith(`
|
|
13
|
-
`)?be.join(`
|
|
14
|
-
`):be.slice(0,-1).join(`
|
|
15
|
-
`);if(Re.current=Oe.endsWith(`
|
|
16
|
-
`)?"":(be[be.length-1]??"").slice(-1024),!Le)return;const rt=Do(Le);if(!rt||Ce.current.has(rt))return;const Ee=Ue.current;Ce.current.add(rt),Df(rt).then(fe=>{if(Ce.current.delete(rt),!fe||Ue.current!==Ee)return;const Me=at.getState().getDirectoryState(C)?.tabs.find(Ze=>Ze.id===Q);!Me||Me.previewUrlLocked||Me.previewUrl===rt||ue(C,Q,rt,{locked:!1,autoOpened:!1})})},[ue]),Qe=h.useCallback((C,Q,ie)=>{if(ae.current===ie)return;Be(),ae.current=ie;const Oe=n.connect(ie,{onEvent:be=>{if(ae.current===ie)switch(be.type){case"snapshot":{J(C,Q,!1),te(null),re(!1),Z(!1),qe(),ee(C,Q,be.data??"",be.sequence??0),Ye(C,Q,be.data??""),be.status==="exited"&&se(C,Q,"exited");break}case"reconnecting":{te(null),re(!1),Z(!0);break}case"data":{be.data&&(G(C,Q,be.data,be.sequence,be.replayData),Ye(C,Q,be.data));break}case"exit":{const Le=typeof be.exitCode=="number"?be.exitCode:null,rt=typeof be.signal=="number"?be.signal:null,fe=!!at.getState().getDirectoryState(C)?.tabs.find(Me=>Me.id===Q)?.label?.startsWith("Action:");G(C,Q,e("terminalView.stream.processExitedMessage",{exitCodeSegment:Le!==null?e("terminalView.stream.processExitedWithCode",{exitCode:Le}):"",signalSegment:rt!==null?e("terminalView.stream.processExitedWithSignal",{signal:rt}):""})),se(C,Q,"exited"),J(C,Q,!1),te(fe?null:e("terminalView.error.sessionEnded")),re(!1),Z(!1),Be();break}}},onError:(be,Le)=>{if(ae.current===ie){if(!Le){te(null),re(!1);return}if(Z(!1),be.code==="SESSION_NOT_FOUND"&&!at.getState().getDirectoryState(C)?.tabs.find(Ee=>Ee.id===Q)?.label?.startsWith("Action:")){te(null),re(!1),J(C,Q,!1),z(C,Q,null),se(C,Q,"idle"),Be();return}te(e("terminalView.error.connectionFailed",{message:be.message})),re(!0),J(C,Q,!1),se(C,Q,"exited"),z(C,Q,null),Be()}}});F.current=()=>{Oe.close(),ae.current=null}},[G,ee,Be,qe,Ye,J,se,z,e,n]);h.useEffect(()=>{let C=!1;if(!y||!tt)return;if(!I){te(e(L?"terminalView.empty.noWorkingDirectory":"terminalView.empty.selectSession")),Be();return}return(async()=>{const ie=I;if(!Te.current||Te.current!==ie)return;if(!at.getState().getDirectoryState(ie)){v(ie);return}const be=at.getState().getDirectoryState(ie);if(!be||be.tabs.length===0)return;const Le=g?be.activeTabId??be.tabs[0]?.id??null:be.tabs[0]?.id??null;if(!Le)return;const rt=be.tabs.find(xt=>xt.id===Le)??be.tabs[0],Ee=rt?.terminalSessionId??null,fe=rt?.lifecycle??"idle",Me=!!rt?.label?.startsWith("Action:"),Ze=at.getState().getBuffer(ie,Le),ht=Ze.byteLength>0||Ze.chunks.length>0;if(!Ee){if(fe==="exited"){J(ie,Le,!1);return}if(Me&&ht){J(ie,Le,!1);return}const xt=`${ie}\0${Le}`;if(ve.current.has(xt))return;const St=Fe.current??kr;ve.current.add(xt),te(null),re(!1),Z(!1),J(ie,Le,!0);try{const kt=await n.createSession({cwd:ie,sessionId:Le,cols:St.cols,rows:St.rows,shell:c,loginShell:d,...a.current}),wt=!C&&Te.current===ie&&he.current===Le;if(!at.getState().getDirectoryState(ie)?.tabs.find(Et=>Et.id===Le)){try{await n.close(kt.sessionId)}catch{}return}if(z(ie,Le,kt.sessionId),!wt)return;const Ct=Fe.current;Ct&&(Ct.cols!==St.cols||Ct.rows!==St.rows)&&n.resize({sessionId:kt.sessionId,...Ct}).catch(()=>{});return}catch(kt){const wt=at.getState().getDirectoryState(ie)?.tabs.find(jt=>jt.id===Le);if(!wt||wt.terminalSessionId||(J(ie,Le,!1),Te.current!==ie||he.current!==Le))return;te(kt instanceof Error?kt.message:e("terminalView.error.startSessionFailed")),re(!0),Z(!1);return}finally{ve.current.delete(xt)}}!Ee||C||(we.current=Ee,Qe(ie,Le,Ee))})(),()=>{C=!0,we.current=null,Be()}},[L,I,_,E,B,tt,g,y,v,J,se,z,Qe,Be,e,n,d,c]),h.useEffect(()=>{if(!We||x)return;if(typeof window>"u"){qe();return}const C=window.requestAnimationFrame(()=>{qe()});return()=>{window.cancelAnimationFrame(C)}},[B,qe,We,x]);const Je=h.useCallback(async()=>{if(!I||j)return;const C=at.getState().getDirectoryState(I),Q=g?B??C?.activeTabId??C?.tabs[0]?.id??null:C?.tabs[0]?.id??null;if(!Q)return;const ie=C?.tabs.find(Oe=>Oe.id===Q)?.terminalSessionId??null;if(!(!ie||!n.restartSession)){Y(!0),te(null),re(!1),Z(!1),Be(),He();try{const Oe=Fe.current??kr,be=await n.restartSession(ie,{cwd:I,shell:c,loginShell:d,...Oe,...a.current});if(at.getState().getDirectoryState(I)?.tabs.find(rt=>rt.id===Q)?.terminalSessionId!==ie||(z(I,Q,be.sessionId),se(I,Q,"running"),Te.current!==I||he.current!==Q))return;we.current=be.sessionId,Qe(I,Q,be.sessionId)}catch(Oe){if(at.getState().getDirectoryState(I)?.tabs.find(Le=>Le.id===Q)?.terminalSessionId!==ie||Te.current!==I||he.current!==Q)return;te(Oe instanceof Error?Oe.message:e("terminalView.error.restartFailed")),re(!1),Z(!1),we.current=ie,Qe(I,Q,ie)}finally{Y(!1)}}},[B,Be,I,g,j,He,se,z,Qe,e,n,d,c]),De=h.useCallback(async()=>{await Je()},[Je]),ot=h.useCallback(()=>{if(!I)return;const C=$(I);U(I,C),te(null),re(!1),Z(!1),Be()},[$,Be,I,U]),$e=h.useCallback(()=>{const C=Ge.current?.getSelection(),Q=N??(A?.open?"draft":null);!C||!Q||!M||!I||V({directory:I,sessionKey:Q},{source:"terminal",fileLabel:M.label,startLine:C.startLine,endLine:C.endLine,code:C.text,language:"",terminalId:M.terminalSessionId??M.id,text:""})},[M,V,N,I,A?.open]),_e=h.useCallback(C=>{I&&(U(I,C),te(null),re(!1),Z(!1),Be())},[Be,I,U]),st=h.useCallback(C=>{if(!I)return;C===B&&Be(),te(null),re(!1),Z(!1);const Q=at.getState().getDirectoryState(I)?.tabs.find(ie=>ie.id===C)?.terminalSessionId;(async()=>{Q&&await n.close(Q),W(I,C)})().catch(ie=>te(ie instanceof Error?ie.message:e("terminalView.error.sessionEnded")))},[B,W,Be,I,e,n]),Pe=h.useCallback(C=>{if(!C||pe)return;let Q=C,ie=!1;de&&C.length>0&&(Q=Af(C,de),ie=!0);const Oe=we.current;Oe&&(n.sendInput(Oe,Q).catch(be=>{pe||te(be instanceof Error?be.message:e("terminalView.error.sendInputFailed"))}),ie&&(me(null),Ke()))},[de,Ke,pe,me,e,n]),Xe=h.useCallback((C,Q)=>{const ie=Fe.current;if((!ie||ie.cols!==C||ie.rows!==Q)&&(Fe.current={cols:C,rows:Q}),!We)return;const Oe=we.current;Oe&&n.resize({sessionId:Oe,cols:C,rows:Q}).catch(()=>{})},[We,n]),dt=h.useCallback(C=>{me(Q=>Q===C?null:C),Ke()},[Ke,me]),lt=h.useCallback(C=>{const Q=Ef(C,de);Q&&(Pe(Q),me(null),Ke())},[de,Ke,Pe,me]),ut=h.useMemo(()=>({Tab:"tab",Enter:"enter",ArrowUp:"arrow-up",ArrowDown:"arrow-down",ArrowLeft:"arrow-left",ArrowRight:"arrow-right",Escape:"esc"}),[]),yt=h.useCallback(C=>{if(C.repeat)return;const Q=C.key;if(!Q||Q==="Control"||Q==="Meta"||Q==="Alt"||Q==="Shift")return;const ie=Q.length===1?Q.toLowerCase():Q;if(ie in ut){C.preventDefault(),C.stopPropagation(),lt(ut[ie]);return}if(de!=="ctrl")return;const Oe=C.code??"",be=Q.length===1&&/[a-zA-Z]/.test(Q)?Q.toUpperCase():Oe.startsWith("Key")&&Oe.length===4?Oe.slice(3).toUpperCase():null;if(be&&be.length===1&&be>="A"&&be<="Z"){const Le=Po(be);if(!Le)return;C.preventDefault(),C.stopPropagation(),Pe(Le),me(null),Ke()}},[de,Ke,lt,Pe,ut,me]);h.useEffect(()=>{if(!(!p||!de||!_))return window.addEventListener("keydown",yt),()=>window.removeEventListener("keydown",yt)},[de,yt,p,_]);const w=h.useMemo(()=>{const C=ws[en].stack;if(typeof window>"u")return(ws[i]??ws[en]).stack;const ie=window.getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono");return ie&&ie.trim().length>0?ie.trim():(ws[i]??ws[en]).stack??C},[i]),H=h.useMemo(()=>uf(o),[o]),ke=`${I??"no-dir"}::${B??"no-tab"}`;if(h.useEffect(()=>{if(!We||x)return;const C=Ge.current;if(!C)return;const Q=()=>{C.fit()};if(typeof window<"u"){const ie=window.requestAnimationFrame(()=>{Q(),qe()}),Oe=[220,400].map(be=>window.setTimeout(Q,be));return()=>{window.cancelAnimationFrame(ie),Oe.forEach(be=>window.clearTimeout(be))}}Q()},[qe,We,x,ke,_]),h.useEffect(()=>{if(!We||!x)return;let C=null;const Q=()=>{C!==null&&window.cancelAnimationFrame(C),C=window.requestAnimationFrame(()=>{C=null,Ge.current?.fit()})};return window.addEventListener("oc:keyboard-settled",Q),()=>{window.removeEventListener("oc:keyboard-settled",Q),C!==null&&window.cancelAnimationFrame(C)}},[We,ke,x]),!L)return t.jsx("div",{className:"flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:e("terminalView.empty.selectSession")});if(!I)return t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-sm text-muted-foreground",children:[t.jsx("p",{children:e("terminalView.empty.noWorkingDirectoryForSession")}),t.jsx("button",{onClick:Je,className:"rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:e("terminalView.actions.retry")})]});const Ae=!_||O||j||pe,k=tt,oe=m?"lg":"xs",ye=m?"w-10 p-0":"w-9 p-0",xe=C=>{m&&C.preventDefault()},je=t.jsxs(t.Fragment,{children:[t.jsx(Ie,{type:"button",size:oe,variant:"outline",onPointerDown:xe,onClick:()=>lt("esc"),disabled:Ae,children:e("terminalView.quickKeys.escape")}),t.jsxs(Ie,{type:"button",size:oe,variant:"outline",className:ye,onPointerDown:xe,onClick:()=>lt("tab"),disabled:Ae,children:[t.jsx(R,{name:"arrow-right",className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.tabAria")})]}),t.jsxs(Ie,{type:"button",size:oe,variant:"chip","aria-pressed":de==="ctrl",className:m?"px-3":"px-2",onPointerDown:xe,onClick:()=>dt("ctrl"),disabled:Ae,children:[t.jsx("span",{className:"text-xs font-medium",children:vn("ctrl")}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.controlModifierAria")})]}),t.jsxs(Ie,{type:"button",size:oe,variant:"chip","aria-pressed":de==="alt",className:m?"px-3":"px-2",onPointerDown:xe,onClick:()=>dt("alt"),disabled:Ae,children:[t.jsx("span",{className:"text-xs font-medium",children:vn("alt")}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.altModifierAria")})]}),t.jsxs(Ie,{type:"button",size:oe,variant:"outline",className:ye,onPointerDown:xe,onClick:()=>lt("arrow-up"),disabled:Ae,children:[t.jsx(R,{name:"arrow-up"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowUpAria")})]}),t.jsxs(Ie,{type:"button",size:oe,variant:"outline",className:ye,onPointerDown:xe,onClick:()=>lt("arrow-left"),disabled:Ae,children:[t.jsx(R,{name:"arrow-left"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowLeftAria")})]}),t.jsxs(Ie,{type:"button",size:oe,variant:"outline",className:ye,onPointerDown:xe,onClick:()=>lt("arrow-down"),disabled:Ae,children:[t.jsx(R,{name:"arrow-down"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowDownAria")})]}),t.jsxs(Ie,{type:"button",size:oe,variant:"outline",className:ye,onPointerDown:xe,onClick:()=>lt("arrow-right"),disabled:Ae,children:[t.jsx(R,{name:"arrow-right"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowRightAria")})]}),t.jsxs(Ie,{type:"button",size:oe,variant:"outline",className:ye,onPointerDown:xe,onClick:()=>lt("enter"),disabled:Ae,children:[t.jsx(R,{name:"arrow-go-back"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.enterAria")})]})]});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-[var(--surface-background)]",children:[t.jsxs("div",{className:le("app-region-no-drag sticky top-0 z-20 shrink-0 bg-[var(--surface-background)] text-xs",m?"px-3 py-1.5":"pl-3 pr-1.5 py-1"),children:[g&&T?t.jsxs("div",{className:"flex items-center gap-2 pl-1 pr-1",children:[t.jsx("div",{className:le("min-w-0 flex-1",m?"h-8":"h-7"),children:t.jsx(Ts,{items:D,activeId:B,onSelect:_e,onClose:st,layoutMode:"scrollable",variant:"default",className:"h-full bg-transparent"})}),t.jsx(Ie,{type:"button",size:"xs",variant:"ghost",className:le("shrink-0",m?"h-8 w-8 p-0":"h-7 w-7 p-0"),onClick:ot,title:e("terminalView.tabs.newTabTitle"),children:t.jsx(R,{name:"add",className:`${m?"h-[18px] w-[18px]":"h-4 w-4"}`})}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1 overflow-visible",children:[t.jsx(Ie,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{Je()},disabled:j,title:e("terminalView.actions.restart"),"aria-label":e("terminalView.actions.restart"),children:t.jsx(R,{name:"restart",className:"h-4 w-4"})}),t.jsx(Ie,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 p-0",onClick:$e,title:e("terminalView.actions.attachSelection"),"aria-label":e("terminalView.actions.attachSelection"),children:t.jsx(R,{name:"attachment-2",className:"h-4 w-4"})}),ne?t.jsxs(Ie,{type:"button",size:"xs",variant:"outline",className:"h-6 shrink-0 gap-1 px-2",onClick:()=>{I&&P(I,ne)},title:e("terminalView.preview.openTitle"),children:[t.jsx(R,{name:"global",className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"whitespace-nowrap",children:e("terminalView.preview.open")})]}):null]})]}):null,!m&&p&&g&&T?t.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1 pl-1 pr-1",children:je}):null,!m&&p&&(!g||!T)?t.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1",children:je}):null]}),t.jsxs("div",{className:"relative flex-1 overflow-hidden",style:{backgroundColor:H.background},children:[t.jsx("div",{className:"h-full w-full box-border pl-4 pr-1.5 pt-3 pb-4",children:k?t.jsx(Io,{ref:C=>{Ge.current=C},sessionKey:ke,chunks:K,onInput:Pe,onResize:Xe,theme:H,monoFont:i,fontFamily:w,fontSize:l,enableTouchScroll:x,autoFocus:We,isVisible:We},ke):null}),!pe&&X&&t.jsxs("div",{className:"absolute inset-x-0 bottom-0 bg-[var(--status-error-background)] px-3 py-2 text-xs text-[var(--status-error-foreground)] flex items-center justify-between gap-2",children:[t.jsx("span",{children:X}),ge&&m&&t.jsx(Ie,{size:"sm",variant:"secondary",className:"h-6 px-2 py-0 text-xs",onClick:De,disabled:j,title:e("terminalView.actions.hardRestartTitle"),type:"button",children:e("terminalView.actions.hardRestart")})]})]}),m&&p?t.jsx("div",{className:"shrink-0 overflow-x-auto border-t border-border/40 bg-[var(--surface-background)] px-2 pt-1.5 pb-[max(0.375rem,calc(var(--oc-app-bottom-safe,0px)-var(--oc-keyboard-inset,0px)))] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:t.jsx("div",{className:"flex min-w-max items-center gap-1.5",children:je})}):null]})},xm=s=>{const e=ze.c(31),{rootIsGitRepo:n,resolvedIsGitRepo:r,nestedRepos:o,onRetryDiscovery:a,emptyStateFooter:i}=s,{t:l}=nt();if(n!==!1||r===!0)return null;if(o==null){let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx(R,{name:"loader-4",className:"mb-3 size-6 animate-spin text-muted-foreground"}),e[0]=f):f=e[0];let b;e[1]!==o||e[2]!==l?(b=l(o===null?"gitView.empty.discoverFailed":"gitView.empty.discoveringRepositories"),e[1]=o,e[2]=l,e[3]=b):b=e[3];let m;e[4]!==b?(m=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:b}),e[4]=b,e[5]=m):m=e[5];let x;e[6]!==o||e[7]!==a||e[8]!==l?(x=o===null?t.jsxs(Ie,{type:"button",variant:"outline",size:"sm",className:"mt-3 gap-1.5",onClick:a,children:[t.jsx(R,{name:"refresh",className:"size-4"}),l("gitView.empty.retryDiscovery")]}):null,e[6]=o,e[7]=a,e[8]=l,e[9]=x):x=e[9];let g;return e[10]!==m||e[11]!==x?(g=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[f,m,x]}),e[10]=m,e[11]=x,e[12]=g):g=e[12],g}if(o==="unsupported"||o.length===0){let f;e[13]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx(R,{name:"git-branch",className:"mb-3 size-6 text-muted-foreground"}),e[13]=f):f=e[13];let b;e[14]!==l?(b=l("gitView.empty.notGitRepository"),e[14]=l,e[15]=b):b=e[15];let m;e[16]!==b?(m=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:b}),e[16]=b,e[17]=m):m=e[17];let x;e[18]!==l?(x=l("gitView.empty.notGitRepositoryDescription"),e[18]=l,e[19]=x):x=e[19];let g;e[20]!==x?(g=t.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:x}),e[20]=x,e[21]=g):g=e[21];let S;return e[22]!==i||e[23]!==m||e[24]!==g?(S=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[f,m,g,i]}),e[22]=i,e[23]=m,e[24]=g,e[25]=S):S=e[25],S}let c;e[26]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(R,{name:"loader-4",className:"mb-3 size-6 animate-spin text-muted-foreground"}),e[26]=c):c=e[26];let d;e[27]!==l?(d=l("gitView.loading.checkingRepository"),e[27]=l,e[28]=d):d=e[28];let u;return e[29]!==d?(u=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[c,t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:d})]}),e[29]=d,e[30]=u):u=e[30],u},bm=()=>{Kr(),ms.reconnectToRuntimeBaseUrl(),Vr()},ym=s=>{it.getState().prepareForRuntimeSwitch(s.previousRuntimeKey),s.previousRuntimeKey&&gi.getState().stopRunningRunsForRuntime(s.previousRuntimeKey),Kr(),at.getState().clearAll(),ms.reconnectToRuntimeBaseUrl(),Nt.setState({providers:[],agents:[],isConnected:!1,isInitialized:!1,connectionPhase:"connecting",lastDisconnectReason:null}),It.getState().resetForRuntimeSwitch(),Rt.getState().reset(),Yt.getState().resetForRuntimeSwitch(),xi(new Map),bi(),yi(),wi.getState().reset(),Vi.getState().resetForRuntimeSwitch(s.previousRuntimeKey),zi.getState().resetForRuntimeSwitch(),Ln.getState().resetForRuntimeSwitch(s.runtimeKey),vi.getState().resetForRuntimeSwitch(),Si.getState().resetForRuntimeSwitch(s.runtimeKey),Gi.getState().resetForRuntimeSwitch(s.runtimeKey),Sn.getState().resetForRuntimeSwitch(),Is.getState().resetForRuntimeSwitch(),ji.getState().resetForRuntimeSwitch(),Ni.getState().resetForRuntimeSwitch(),ki.getState().resetForRuntimeSwitch(),Tt.getState().reset(),Ve.getState().applyLinearIssueListFiltersForRuntime(),it.getState().restoreForRuntimeSwitch(s.runtimeKey),Vr(),queueMicrotask(()=>{Hi()})};export{Hl as $,Xf as A,ld as B,Jf as C,cm as D,oc as E,rc as F,$c as G,rm as H,sm as I,um as J,fm as K,mm as L,on as M,dm as N,Yf as O,hm as P,Nd as Q,Hu as R,im as S,gm as T,Kf as U,nm as V,vc as W,qf as X,qt as Y,Wc as Z,_c as _,ud as a,Hf as a0,lm as a1,fd as b,xm as c,Ts as d,ym as e,am as f,om as g,Qf as h,Gf as i,ir as j,at as k,Sc as l,tm as m,jc as n,co as o,Ld as p,Tf as q,bm as r,pm as s,em as t,kl as u,Vl as v,Gl as w,zl as x,ac as y,Zf as z};
|