@openchamber/web 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{CodeMirrorCommentWidgets-zm3C1FvM.js → CodeMirrorCommentWidgets-CmKmyb9T.js} +1 -1
- package/dist/assets/{DiffView-DNExNi1z.js → DiffView-8-PFpZ2p.js} +1 -1
- package/dist/assets/{FilesView-DUCLmHBi.js → FilesView-0Ie20mEk.js} +9 -9
- package/dist/assets/{GitView-Bz9z6gZA.js → GitView-DNUSu00w.js} +1 -1
- package/dist/assets/{GuestAttachDialog-UGp4KDlK.js → GuestAttachDialog-Cv6QzjHC.js} +1 -1
- package/dist/assets/{GuestSurfacePane-B3pdB_2u.js → GuestSurfacePane-Bt3jB_Ye.js} +1 -1
- package/dist/assets/{JsonTreeView-7lVecnZl.js → JsonTreeView-BlyHTRhM.js} +1 -1
- package/dist/assets/{LinearIssuesView-CTGRS9Vq.js → LinearIssuesView-CSl2MUfA.js} +1 -1
- package/dist/assets/MarkdownImageGallery-2UXJF-5B.js +1 -0
- package/dist/assets/MarkdownRendererImpl-DVHqZoug.js +12 -0
- package/dist/assets/{OnboardingScreen-CBx6cXPP.js → OnboardingScreen-CIdXJpfc.js} +1 -1
- package/dist/assets/{PatchDiff-D7VVpR_l.js → PatchDiff-ByvnbG5T.js} +1 -1
- package/dist/assets/{PierreDiffViewer-Gbfks1pk.js → PierreDiffViewer-BXieg0mH.js} +1 -1
- package/dist/assets/{PlanView-CPSK0x97.js → PlanView-DEIi3Q7M.js} +3 -3
- package/dist/assets/PluginPane-BEPUWVho.js +3 -0
- package/dist/assets/{SettingsView-Dql7z6Ww.js → SettingsView-CiNh-RbW.js} +16 -16
- package/dist/assets/{SettingsWindow-D6oi-UmV.js → SettingsWindow-BIz224xs.js} +1 -1
- package/dist/assets/{SubmoduleDiffSummary-BXA0FAWj.js → SubmoduleDiffSummary-CXKmlps9.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BQJsSbDm.js → ToolOutputDialog-BsgAK8xu.js} +6 -6
- package/dist/assets/{ToolPartDiffPreview-FY9w0TVT.js → ToolPartDiffPreview-vdPObXOf.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-B9YhAya5.js → VirtualizedFileDiff-BkFNKWS5.js} +1 -1
- package/dist/assets/{WalkthroughView-CmFgOUFN.js → WalkthroughView-6oE-MuDL.js} +2 -2
- package/dist/assets/{appThemeRegistry-BebxalUt.js → appThemeRegistry-aHUNHoqP.js} +1 -1
- package/dist/assets/{commitAndPush-Wfxng_IK.js → commitAndPush-Bon9r94r.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-BCOqgixN.js → computeVirtualFileMetrics-DKqr_1AQ.js} +1 -1
- package/dist/assets/de-CgAJ51z7.js +10 -0
- package/dist/assets/es-zGi_ravM.js +16 -0
- package/dist/assets/fr-CPfogrWx.js +14 -0
- package/dist/assets/index-CHfphYL3.js +41 -0
- package/dist/assets/{index-3TiDNtfN.js → index-DpFttslC.js} +1 -1
- package/dist/assets/index-DvMJ3w6V.css +1 -0
- package/dist/assets/{isDiffPlainText-DnDYQmWK.js → isDiffPlainText-kzAgpIgi.js} +1 -1
- package/dist/assets/{isFilePlainText-BA_AHX7d.js → isFilePlainText-Uj6y-jzz.js} +1 -1
- package/dist/assets/ja-DMk6wd-U.js +16 -0
- package/dist/assets/ko-BFpzJ8jc.js +16 -0
- package/dist/assets/{main-DtUmJp9B.js → main-CbfMxn-I.js} +2 -2
- package/dist/assets/main-anyZFMIs.js +896 -0
- package/dist/assets/{markdownCore-BSnlUXBf.js → markdownCore-CmM47cAE.js} +5 -5
- package/dist/assets/{miniChat-BYfLUnDK.js → miniChat-CiAKBC10.js} +2 -2
- package/dist/assets/{mobile-DH3hI6gd.js → mobile-CsT4sJwC.js} +2 -2
- package/dist/assets/{patchFileDiff--L7lt_GZ.js → patchFileDiff-DeaE08W0.js} +1 -1
- package/dist/assets/{pl-BkI_xHqz.js → pl-VdRPcZrB.js} +5 -5
- package/dist/assets/pt-BR-BRys_lOW.js +16 -0
- package/dist/assets/{renderElectronMiniChatApp-C7kpNW_-.js → renderElectronMiniChatApp-C5677jy0.js} +2 -2
- package/dist/assets/{renderMobileApp-i0nq7Dwy.js → renderMobileApp-D4dBBAqQ.js} +7 -7
- package/dist/assets/runtimeEndpointReset-5r0hkd-2.js +27 -0
- package/dist/assets/{scheduledTasksApi-Cy7uZCaI.js → scheduledTasksApi-BZCNJ588.js} +1 -1
- package/dist/assets/{shikiHighlight-D4vxipfr.js → shikiHighlight-BSUEa3yF.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-BYAHtJwQ.js → textMateThemeFromAppTheme-CsATFZIV.js} +1 -1
- package/dist/assets/tr-CA9ckNnm.js +7 -0
- package/dist/assets/uk-byjR-y8D.js +16 -0
- package/dist/assets/{useAppFontEffects-DHZ9-L30.js → useAppFontEffects-BWQZ5DeI.js} +153 -150
- package/dist/assets/{useInlineCommentController-CvpOMK-R.js → useInlineCommentController-DlFyVfBu.js} +1 -1
- package/dist/assets/{useRootScrollLock-DzNFi-fn.js → useRootScrollLock-Cp1eFoM2.js} +2 -2
- package/dist/assets/{vendor-codemirror-language-data-j3fhlwUM.js → vendor-codemirror-language-data-BwwommM0.js} +2 -2
- package/dist/assets/{web-components-BvHNFSEG.js → web-components-D3Yjr4Zx.js} +1 -1
- package/dist/assets/zh-CN-DRabgxdG.js +16 -0
- package/dist/assets/zh-TW-rbY5c9UK.js +16 -0
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +2 -2
- package/server/index.js +64 -0
- package/server/lib/event-stream/global-hub.js +23 -1
- package/server/lib/event-stream/global-hub.test.js +35 -0
- package/server/lib/event-stream/global-ws-bridge.js +3 -1
- package/server/lib/event-stream/upstream-reader.js +3 -2
- package/server/lib/opencode/DOCUMENTATION.md +6 -2
- package/server/lib/opencode/bootstrap-runtime.js +2 -1
- package/server/lib/opencode/config-entity-v2.test.js +27 -0
- package/server/lib/opencode/config-paths.test.js +12 -0
- package/server/lib/opencode/core-routes.js +17 -4
- package/server/lib/opencode/core-routes.test.js +26 -0
- package/server/lib/opencode/mcp.js +7 -2
- package/server/lib/opencode/project-directory-runtime.js +8 -0
- package/server/lib/opencode/project-directory-runtime.test.js +13 -0
- package/server/lib/opencode/proxy.js +38 -2
- package/server/lib/opencode/routes.js +18 -0
- package/server/lib/opencode/server-utils-runtime.js +5 -0
- package/server/lib/opencode/settings-helpers.js +3 -0
- package/server/lib/opencode/settings-helpers.test.js +1 -1
- package/server/lib/opencode/settings-registry.json +3 -0
- package/server/lib/opencode/shared.js +17 -2
- package/server/lib/opencode/shutdown-runtime.js +3 -0
- package/server/lib/opencode/watcher.js +3 -1
- package/server/lib/realtime-proxy.js +5 -1
- package/server/lib/realtime-proxy.test.js +29 -0
- package/server/lib/relay/tunnel-host.js +4 -1
- package/server/lib/relay/tunnel-host.test.js +11 -0
- package/server/lib/small-model/DOCUMENTATION.md +11 -10
- package/server/lib/small-model/index.js +27 -32
- package/server/lib/small-model/index.test.js +28 -16
- package/server/lib/spaces/DOCUMENTATION.md +381 -20
- package/server/lib/spaces/code-in-bait.js +145 -6
- package/server/lib/spaces/code-in.js +10 -150
- package/server/lib/spaces/code-in.test.js +7 -83
- package/server/lib/spaces/code-out.js +1819 -0
- package/server/lib/spaces/code-out.test.js +3945 -0
- package/server/lib/spaces/code-transfer.js +173 -0
- package/server/lib/spaces/command-stream.test.js +181 -0
- package/server/lib/spaces/dispatcher.js +670 -0
- package/server/lib/spaces/dispatcher.test.js +582 -0
- package/server/lib/spaces/gatekeeper-channel.js +2 -0
- package/server/lib/spaces/gatekeeper-channel.test.js +9 -3
- package/server/lib/spaces/gatekeeper-program.cjs +4 -1
- package/server/lib/spaces/gatekeeper-program.test.js +3 -0
- package/server/lib/spaces/hardening.js +20 -4
- package/server/lib/spaces/hardening.test.js +18 -3
- package/server/lib/spaces/host-git.js +7 -4
- package/server/lib/spaces/host-git.test.js +6 -2
- package/server/lib/spaces/host.js +304 -0
- package/server/lib/spaces/host.test.js +273 -0
- package/server/lib/spaces/journey.js +393 -0
- package/server/lib/spaces/journey.test.js +384 -0
- package/server/lib/spaces/layout.js +26 -2
- package/server/lib/spaces/manager.js +4 -3
- package/server/lib/spaces/manager.test.js +6 -0
- package/server/lib/spaces/places/code-out.docker.live.test.js +412 -0
- package/server/lib/spaces/places/contract-suite.js +36 -0
- package/server/lib/spaces/places/dispatcher.docker.live.test.js +296 -0
- package/server/lib/spaces/places/docker.js +15 -3
- package/server/lib/spaces/places/docker.test.js +33 -2
- package/server/lib/spaces/places/escape-suite.js +86 -14
- package/server/lib/spaces/places/memory-place.js +24 -1
- package/server/lib/spaces/places/registry.js +1 -1
- package/server/lib/spaces/places/server.docker.live.test.js +69 -33
- package/server/lib/spaces/places/sessions.docker.live.test.js +220 -0
- package/server/lib/spaces/routes.js +207 -0
- package/server/lib/spaces/routes.test.js +211 -0
- package/server/lib/spaces/run-command.js +261 -8
- package/server/lib/spaces/run-command.test.js +193 -3
- package/server/lib/spaces/space-events.js +153 -0
- package/server/lib/spaces/space-events.test.js +160 -0
- package/server/lib/spaces/space-records.js +98 -0
- package/server/lib/spaces/space-records.test.js +73 -0
- package/server/lib/spaces/space-sessions.js +210 -0
- package/server/lib/spaces/space-sessions.test.js +161 -0
- package/server/lib/spaces/websocket.js +329 -0
- package/server/lib/spaces/websocket.test.js +345 -0
- package/server/lib/ui-auth/ui-auth.js +8 -2
- package/server/lib/ui-auth/ui-auth.test.js +29 -0
- package/server/opencode-proxy.test.js +113 -0
- package/dist/assets/MarkdownImageGallery-DQk5adUs.js +0 -1
- package/dist/assets/MarkdownRendererImpl-DPF8fZpX.js +0 -12
- package/dist/assets/PluginPane-BIGsUx69.js +0 -3
- package/dist/assets/de-CMA45TC-.js +0 -10
- package/dist/assets/es-DPL4fBtl.js +0 -16
- package/dist/assets/fr-OHBKBseP.js +0 -14
- package/dist/assets/index-BLUZa5u0.js +0 -41
- package/dist/assets/index-Cm2rrq69.css +0 -1
- package/dist/assets/ja-DvX4WSRf.js +0 -16
- package/dist/assets/ko-BUcLd8YZ.js +0 -16
- package/dist/assets/main-B_jri4i-.js +0 -896
- package/dist/assets/pt-BR-7wFtQlV9.js +0 -16
- package/dist/assets/runtimeEndpointReset-CfEYbcCc.js +0 -27
- package/dist/assets/tr-TsD-AqEH.js +0 -7
- package/dist/assets/uk-B-qspCmD.js +0 -16
- package/dist/assets/zh-CN-DYuPJV5i.js +0 -16
- package/dist/assets/zh-TW-BX_2D_lV.js +0 -16
|
@@ -1,896 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-CmFgOUFN.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-DHZ9-L30.js","assets/index-BLUZa5u0.js","assets/vendor-zod-BSoePkpP.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-DYdsLbCM.js","assets/index-Cm2rrq69.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-CsXYnR5c.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-framer-motion-Bq3iTZ6r.js","assets/vendor-motion-dom-DcCgeG69.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-ClYN8CzB.js","assets/vendor-tanstack-virtual-core-BewVQryB.js","assets/contextPanelEmbeddedChat-CirXEPJq.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BgPj_McA.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-DzPz9Wgq.js","assets/vendor-codemirror-lang-json-CMBS2tG9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-O0cZX78y.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CfgK872x.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-BPGOH9ye.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-j3fhlwUM.js","assets/vendor-codemirror-lang-python-HahnQaAS.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-B7H_j0iU.js","assets/vendor-legendapp-list-BuBPBC3R.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/patchFileDiff--L7lt_GZ.js","assets/runtimeEndpointReset-CfEYbcCc.js","assets/GuestAttachDialog-UGp4KDlK.js","assets/PluginPane-BIGsUx69.js","assets/VirtualizedFileDiff-B9YhAya5.js","assets/web-components-BvHNFSEG.js","assets/computeVirtualFileMetrics-BCOqgixN.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/isDiffPlainText-DnDYQmWK.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-Gbfks1pk.js","assets/Virtualizer-D_a8gKmg.js","assets/useInlineCommentController-CvpOMK-R.js","assets/appThemeRegistry-BebxalUt.js","assets/textMateThemeFromAppTheme-BYAHtJwQ.js","assets/vendor-katex-CHD9BdDO.js","assets/vendor-katex-Cp579UoJ.css","assets/useRootScrollLock-DzNFi-fn.js","assets/scheduledTasksApi-Cy7uZCaI.js","assets/vendor-cron-parser-CjvYVigk.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-DNExNi1z.js","assets/SubmoduleDiffSummary-BXA0FAWj.js","assets/changesTree-CePHbFcj.js","assets/FilesView-DUCLmHBi.js","assets/shikiHighlight-D4vxipfr.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-7lVecnZl.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-BA_AHX7d.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets-zm3C1FvM.js","assets/GitView-Bz9z6gZA.js","assets/commitAndPush-Wfxng_IK.js","assets/LinearIssuesView-CTGRS9Vq.js","assets/PlanView-CPSK0x97.js","assets/GuestSurfacePane-B3pdB_2u.js","assets/SettingsWindow-D6oi-UmV.js","assets/SettingsView-Dql7z6Ww.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/OnboardingScreen-CBx6cXPP.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{f as et,R as c,j as s,r as ct,c as Hm,h as Gm}from"./vendor-react-BUCujlKS.js";import"./vendor-katex-CHD9BdDO.js";import{E as vn,F as ti,H as qm,I as Ym,h as ws,x as zd,u as Pe,J as Ot,K as vl,a as Qt,y as Dr,o as xt,L as Rs,N as Qr,O as Wn,P as Wd,Q as Qm,R as Xm,S as Jm,T as Zm,U as Kd,n as os,V as zn,W as Xr,e as En,X as eh,Y as th,Z as sh,_ as nh,$ as Vd,v as yn,B as fn,a0 as rh,a1 as Sl,a2 as oh,a3 as Ud,a4 as ih,a5 as Hd,f as ah,a6 as er,a7 as or,a8 as Lo,a9 as Gi,aa as lh,ab as La,d as $o,t as gr,q as ys,ac as Gd,ad as ch,ae as qi,af as qd,ag as Yd,i as dh,ah as Io,ai as To,aj as uh,ak as jl,al as fh,am as mh,an as hh,ao as ph,ap as kl,aq as Cl,ar as Nl,as as Al,at as gh,A as Pl,au as xh,av as bh,aw as yh,C as wh,D as vh}from"./index-BLUZa5u0.js";import{_ as jn}from"./vendor-vite-runtime-DD1OZmLC.js";import{z as Dl,E as Ai,F as cn,G as Yi,H as Il,I as Sh,J as jh,K as kh,L as Ch,M as Nh,Q as Ah,R as Ph,V as Dh,W as $a,a as Ih,e as Qd,X as Xd,h as Qi,m as Jd,Y as Th,k as Eh,j as Rh,Z as Zd,_ as Xi,$ as tr,a0 as eu,a1 as tu,l as Mh,P as Oh,T as Bh,a2 as Fh,a3 as _h,a4 as Lh,a5 as $h,b as su,a6 as zh,a7 as nu,a8 as zo,a9 as Wh,aa as Kh,ab as Vh,S as Pi,ac as ru,ad as ou,d as Uh,ae as Hh,c as Gh,af as qh,r as Tl,ag as Yh,ah as Qh,ai as uo,u as Ur,s as Xh,N as Jh,D as Zh,aj as ep,ak as El,al as tp,am as Di,w as sp,q as np,x as iu,U as rp,y as op,an as ip,ao as ap,ap as lp,O as cp,o as dp,t as up,v as au,A as fp,C as mp}from"./runtimeEndpointReset-CfEYbcCc.js";import{f as kt,h as Re,bh as Ht,I as F,g as fr,t as ze,at as _s,bi as As,av as Ls,as as $s,T as Kn,_ as kn,ai as mr,bj as Vn,o as so,bk as Rl,bl as hp,bm as pp,ae as wt,af as vt,ag as St,b as Gt,z as nt,H as gp,bn as lu,bo as fo,u as js,r as Ps,D as cu,C as du,bp as Ji,bq as xp,br as uu,bs as fu,S as za,bt as bp,bu as yp,bv as Ml,bw as Ol,bx as mu,by as wp,bz as Bl,bA as vp,bB as Sp,bC as Wa,bD as Zi,bE as hu,bF as jp,bG as kp,bH as Cp,Q as pu,bI as Np,bJ as Ap,bK as Pp,n as yr,bL as gu,bM as Dp,bN as Ip,p as Tp,bO as xu,bP as Ep,bQ as Rp,bR as Mp,bS as bu,bT as yu,bU as wu,bV as vu,bW as Su,bX as ju,bY as ku,bZ as no,b_ as Ka,aJ as Va,b$ as ir,c0 as ro,c1 as Op,c2 as Ds,c3 as Is,c4 as sn,c5 as Hs,c6 as Gs,c7 as Un,B as ut,c8 as On,aB as Ns,c9 as Bp,ca as Fp,aH as Rn,cb as xr,cc as Vs,cd as si,ce as Cu,cf as ea,cg as ta,ch as sa,ci as _p,cj as Ms,ck as Os,cl as Cs,cm as Bs,cn as rs,X as In,co as wr,cp as Fl,cq as Sr,cr as Nu,R as ni,aj as Lp,ak as Ua,al as Au,J as Pu,K as Mn,cs as Ha,a9 as Ga,ct as $p,cu as zp,az as Wp,cv as Kp,cw as Du,cx as Vp,cy as Up,aA as qa,cz as Hp,cA as Iu,cB as jr,cC as Tu,cD as Gp,l as Ut,s as qp,cE as Yp,cF as Qp,aO as Hn,cG as Xp,cH as br,O as Eu,cI as Jp,cJ as Zp,cK as Gn,cL as eg,cM as tg,aD as sg,cN as Ii,cO as ng,cP as rg,cQ as og,cR as Ru,cS as ig,cT as Ya,cU as ag,cV as Mu,cW as lg,aI as na,cX as ra,cY as _l,cZ as cg,c_ as Ll,c$ as zr,c as Jr,d as Qa,a4 as dg,a1 as Ou,d0 as Mr,d1 as Wr,d2 as ug,d3 as fg,d4 as mg,$ as Xa,aC as hg,d5 as pg,d6 as gg,d7 as xg,d8 as bg,d9 as Bu,da as mn,db as yg,dc as Fu,dd as wg,a8 as oa,de as vg,df as _u,dg as hs,dh as Sg,di as jg,dj as kg,dk as Lu,dl as Cg,dm as Ja,dn as $u,a6 as Wo,dp as ia,dq as ri,a as Za,dr as el,a5 as Ng,ds as $l,U as oi,V as ii,W as ai,dt as Ag,du as aa,dv as zu,dw as Pg,dx as Dg,au as Wu,dy as Ig,dz as tl,P as la,L as Tg,dA as zl,dB as Eg,dC as Rg,dD as ss,dE as Mg,dF as cr,dG as Ku,dH as Vu,dI as Uu,dJ as Hu,dK as Og,E as Bg,dL as Fg,dM as _g,dN as Lg,dO as Wl,dP as Gu,dQ as $g,dR as qu,F as zg,dS as Wg,dT as Kg,dU as Vg,dV as Hr,dW as Ug,dX as Hg,dY as Gg,dZ as qg,e as sl,d_ as li,d$ as Yg,e0 as Zr,a3 as Qg,G as ci,e1 as Xg,e2 as Jg,e3 as Kl,e4 as Zg,e5 as ex,a0 as tx,e6 as sx,e7 as nx,a$ as Vl,ab as Ul,aa as Hl,e8 as rx,aW as ca,e9 as ox,M as ix,N as Ti,ea as ax,eb as lx,ec as Yu,ed as Qu,ee as Xu,ef as cx,eg as dx,a7 as ux,am as fx,eh as mx,ei as Gl,ej as hx,ek as px,el as gx,em as xx,en as Ko,eo as bx,ep as ql,eq as yx,er as wx,es as vx,et as Sx,eu as da,ev as jx,ew as Eo,ex as kx,i as Cx,ey as Nx,ez as Ax,eA as Px,eB as Dx,eC as Ix,eD as Tx,eE as Yl,eF as Ex,aP as Rx,aQ as Mx,aS as Ox,aR as Bx,aU as Ql,aV as Xl,aY as Jl,aZ as Zl,aX as Ju,a_ as Zu,eG as Fx,bc as _x,bd as Lx,be as $x,bf as zx,bg as Wx,b6 as Kx,b8 as Vx,b9 as Ux,ba as Hx,bb as Gx}from"./useAppFontEffects-DHZ9-L30.js";import{u as ef,S as ec,C as qx,t as Yx,W as tf,f as Qx,G as Xx,a as Jx}from"./useRootScrollLock-DzNFi-fn.js";import{u as Yn,O as tc,D as Zx,a as eb,b as tb,f as sb,c as sc,s as nb,d as rb,e as ob,r as ib}from"./scheduledTasksApi-Cy7uZCaI.js";import{f as di,h as Tn,T as ui,M as fi,D as mi,j as hi,d as ab,b as lb,k as cb,i as db}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as pi,S as nl,h as ub,a as sf,v as nf,s as fb}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as gi}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as rf,M as of,C as af,a as ua,b as fa,c as ma,d as lf,e as mb,f as hb}from"./vendor-base-ui-CsXYnR5c.js";import{c as oo,u as dr,d as pb,p as gb}from"./vendor-zustand-BAGL70zf.js";import{g as xb,a as bb,E as cf,b as yb,c as wb,d as vb,e as Sb,i as jb}from"./contextPanelEmbeddedChat-CirXEPJq.js";import{P as kb}from"./PluginPane-BIGsUx69.js";import{a as rl,s as ur,r as df,o as nc,b as rc}from"./vendor-zod-BSoePkpP.js";import{u as Cb}from"./vendor-tanstack-react-virtual-ClYN8CzB.js";import{d as Nb}from"./vendor-tanstack-virtual-core-BewVQryB.js";import{d as uf}from"./vendor-cron-parser-CjvYVigk.js";const Ab="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC",Pb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC",Ei=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?Ab:t.id==="terminal"?Pb:void 0}),oc=t=>{const e=et.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=t,[o,l]=c.useState(!1);let a;e[0]!==n?(a=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=a):a=e[1];const d=a,u=r||i;if(u&&!o){let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>l(!0),e[2]=p):p=e[2];let y;return e[3]!==u?(y=s.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:p}),e[3]=u,e[4]=y):y=e[4],y}let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=Re("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=m):m=e[5];let f;return e[6]!==d?(f=s.jsx("span",{className:m,children:d}),e[6]=d,e[7]=f):f=e[7],f},Db=t=>{const e=et.c(75),{directory:n,className:r}=t,{t:i}=kt(),o=Yn(Ib),l=Yn(Tb),a=Yn(Eb),d=Yn(Rb),u=Yn(Mb),m=Yn(Ob),f=Yn(Bb);let p,y;e[0]!==u?(p=()=>{u()},y=[u],e[0]=u,e[1]=p,e[2]=y):(p=e[1],y=e[2]),c.useEffect(p,y);const x=vn()&&ti();let k;e:{let Se;e[3]!==l||e[4]!==o?(Se=l.find(V=>V.id===o)??l.find(Fb)??l[0]??tc[0],e[3]=l,e[4]=o,e[5]=Se):Se=e[5];const me=Se;if(me){let V;e[6]!==me?(V=Ei(me),e[6]=me,e[7]=V):V=e[7],k=V;break e}let ke;e[8]===Symbol.for("react.memo_cache_sentinel")?(ke=Ei(tc[0]),e[8]=ke):ke=e[8],k=ke}const w=k;if(!x||!n||l.length===0)return null;let h;e[9]!==n?(h=async Se=>{await qm(n,Se.id,Se.appName)||await Ym(n,Se.appName)},e[9]=n,e[10]=h):h=e[10];const g=h;let j;e[11]!==g||e[12]!==f?(j=async Se=>{await f(Se.id),await g(Se)},e[11]=g,e[12]=f,e[13]=j):j=e[13];const b=j;let S;e[14]!==n||e[15]!==i?(S=async()=>{(await fr(n)).ok&&ze.success(i("openInApp.toast.pathCopied"))},e[14]=n,e[15]=i,e[16]=S):S=e[16];const C=S;let v;e[17]!==r?(v=Re("app-region-no-drag inline-flex h-7 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r),e[17]=r,e[18]=v):v=e[18];let M;e[19]!==g||e[20]!==w?(M=()=>{g(w)},e[19]=g,e[20]=w,e[21]=M):M=e[21];const R=d&&"animate-pulse";let I;e[22]!==R?(I=Re("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",R),e[22]=R,e[23]=I):I=e[23];let B;e[24]!==w.label||e[25]!==i?(B=i("openInApp.actions.openInAria",{app:w.label}),e[24]=w.label,e[25]=i,e[26]=B):B=e[26];let O;e[27]!==w.fallbackIconDataUrl||e[28]!==w.iconDataUrl||e[29]!==w.label?(O=s.jsx(oc,{label:w.label,iconDataUrl:w.iconDataUrl,fallbackIconDataUrl:w.fallbackIconDataUrl}),e[27]=w.fallbackIconDataUrl,e[28]=w.iconDataUrl,e[29]=w.label,e[30]=O):O=e[30];let T;e[31]!==I||e[32]!==B||e[33]!==O||e[34]!==M?(T=s.jsx("button",{type:"button",onClick:M,className:I,"aria-label":B,children:O}),e[31]=I,e[32]=B,e[33]=O,e[34]=M,e[35]=T):T=e[35];let $;e[36]===Symbol.for("react.memo_cache_sentinel")?($=Re("inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors"),e[36]=$):$=e[36];let _;e[37]!==i?(_=i("openInApp.actions.chooseAppAria"),e[37]=i,e[38]=_):_=e[38];let Y;e[39]===Symbol.for("react.memo_cache_sentinel")?(Y=s.jsx(F,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=Y):Y=e[39];let L;e[40]!==_?(L=s.jsx(_s,{asChild:!0,children:s.jsx("button",{type:"button",className:$,"aria-label":_,children:Y})}),e[40]=_,e[41]=L):L=e[41];let A;e[42]!==C?(A=()=>{C()},e[42]=C,e[43]=A):A=e[43];let D;e[44]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx(F,{name:"file-copy",className:"h-4 w-4"}),e[44]=D):D=e[44];let P;e[45]!==i?(P=i("openInApp.actions.copyPath"),e[45]=i,e[46]=P):P=e[46];let Z;e[47]!==P?(Z=s.jsx("span",{className:"typography-ui-label text-foreground",children:P}),e[47]=P,e[48]=Z):Z=e[48];let X;e[49]!==A||e[50]!==Z?(X=s.jsxs(Ht,{className:"flex items-center gap-2",onClick:A,children:[D,Z]}),e[49]=A,e[50]=Z,e[51]=X):X=e[51];let se;e[52]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx(As,{}),e[52]=se):se=e[52];let ce;if(e[53]!==l||e[54]!==b||e[55]!==w.id){let Se;e[57]!==b||e[58]!==w.id?(Se=me=>{const ke=Ei(me);return s.jsxs(Ht,{className:"flex items-center gap-2",onClick:()=>{b(me)},children:[s.jsx(oc,{label:me.label,iconDataUrl:me.iconDataUrl,fallbackIconDataUrl:ke.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:me.label}),w.id===me.id?s.jsx(F,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},me.id)},e[57]=b,e[58]=w.id,e[59]=Se):Se=e[59],ce=l.map(Se),e[53]=l,e[54]=b,e[55]=w.id,e[56]=ce}else ce=e[56];let re;e[60]!==a||e[61]!==m||e[62]!==i?(re=a?s.jsxs(Ht,{className:"flex items-center gap-2",onClick:()=>{m(!0)},children:[s.jsx(F,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:i("openInApp.actions.refreshApps")})]}):null,e[60]=a,e[61]=m,e[62]=i,e[63]=re):re=e[63];let ge;e[64]!==X||e[65]!==ce||e[66]!==re?(ge=s.jsxs(Ls,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[X,se,ce,re]}),e[64]=X,e[65]=ce,e[66]=re,e[67]=ge):ge=e[67];let ae;e[68]!==L||e[69]!==ge?(ae=s.jsxs($s,{children:[L,ge]}),e[68]=L,e[69]=ge,e[70]=ae):ae=e[70];let Ee;return e[71]!==T||e[72]!==ae||e[73]!==v?(Ee=s.jsxs("div",{className:v,children:[T,ae]}),e[71]=T,e[72]=ae,e[73]=v,e[74]=Ee):Ee=e[74],Ee};function Ib(t){return t.selectedAppId}function Tb(t){return t.availableApps}function Eb(t){return t.isCacheStale}function Rb(t){return t.isScanning}function Mb(t){return t.initialize}function Ob(t){return t.loadInstalledApps}function Bb(t){return t.selectApp}function Fb(t){return t.id===Zx}const Vo=new Map,ha=new Set,ff=()=>{for(const t of ha)t()},Ri=(t,e)=>{const n=t.trim();n&&(e.length===0?Vo.delete(n):Vo.set(n,[...e]),ff())},_b=t=>{Vo.delete(t.trim())&&ff()},mf=[],Lb=t=>Vo.get(t.trim())??mf,$b=t=>(ha.add(t),()=>{ha.delete(t)}),zb=t=>{const e=et.c(2);let n;return e[0]!==t?(n=()=>Lb(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore($b,n,Wb)};function Wb(){return mf}const Kb=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Vb=["dev","start","preview","serve"];async function Ub(t,e,n){if(!t)return null;const r=qb(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const i=Yb(n);if(i){const o=await Qb(t);return{command:`${o==="npm"?"npm run":o==="yarn"?"yarn":o==="pnpm"?"pnpm":o==="bun"?"bun run --shell=bun":"npm run"} ${i}`,label:`Start (${i})`}}}if(await Hb(t)){const i=await Gb(),o=typeof i=="number"&&Number.isFinite(i)&&i>0?i:8e3;return{command:`python3 -m http.server ${o}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${o}/`}}return null}async function Hb(t){const e=`${t}/index.html`,n=await Uo(e,t);return typeof n=="string"&&n.trim().length>0}async function Gb(){try{const t=await ws("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),n=typeof e?.port=="number"?e.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function qb(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(Vb.some(i=>n.includes(i)))return e}return null}function Yb(t){for(const{pattern:e}of Kb)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Qb(t){const e=await Uo(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),i=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(i.startsWith("bun@"))return"bun";if(i.startsWith("pnpm@"))return"pnpm";if(i.startsWith("yarn@"))return"yarn";if(i.startsWith("npm@"))return"npm"}catch{}const n=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,i]of n){const o=await Uo(`${t}/${r}`,t);if(typeof o=="string"&&o.trim().length>0)return i}return"npm"}async function Uo(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),i=await ws(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(i.ok)return i.text()}catch{}const n=zd()?.files;if(n?.readFile)try{const r=await n.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await ws(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Xb(t){try{const e=await Uo(`${t}/package.json`,t);if(e==null)return null;const r=JSON.parse(e).scripts;return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}const un="__openchamber_auto_discover_preview__",Jb=15e3,Zb=3e3,Mi=t=>t.id===un?"scan-2":Dh.find(n=>n.key===t.icon)?.Icon??"play",ey=t=>{const e=(t||"").trim();if(!e)return null;const n=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},ty=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:i=!1})=>{const{t:o}=kt(),{currentTheme:l}=Kn(),{terminal:a,runtime:d}=kn(),u=mr(),{isMobile:m}=Vn(),f=c.useMemo(()=>vn(),[]),p=Dl(ee=>ee.instances),y=Dl(ee=>ee.load),x=Pe(ee=>ee.terminalShell),k=Pe(ee=>ee.terminalLoginShells.includes(ee.terminalShell)),w=Pe(ee=>ee.setSettingsPage),h=Pe(ee=>ee.setSettingsDialogOpen),g=Pe(ee=>ee.setSettingsProjectsSelectedId),j=Pe(ee=>ee.openContextPreview),b=Ot(ee=>ee.ensureDirectory),S=Ot(ee=>ee.reconcileServerSessions),C=Ot(ee=>ee.setTabLabel),v=Ot(ee=>ee.setTabIconKey),M=Ot(ee=>ee.setActiveTab),R=Ot(ee=>ee.setConnecting),I=Ot(ee=>ee.setTabSessionId),B=Ot(ee=>ee.setTabPurpose),O=Ot(ee=>ee.allocateActionExecution),T=Ot(ee=>ee.setTabLifecycle),$=Ot(ee=>ee.setTabPreviewUrl),_=Ot(ee=>ee.matchesActionExecution),Y=Ot(ee=>ee.captureStartedActionMutationRevisions),[L,A]=c.useState([]),D=c.useRef(null),[P,Z]=c.useState(null),[X,se]=c.useState(!1),ce=c.useRef({}),re=c.useRef({}),ge=c.useRef({}),ae=c.useRef(new Set),Ee=c.useRef(0),[Se,me]=c.useState({}),ke=t?.id??null,V=t?.path??"",J=c.useMemo(()=>ke?{id:ke,path:V}:null,[ke,V]);c.useEffect(()=>{f&&y().catch(()=>{})},[f,y]);const de=c.useCallback(async ee=>{await so(ee)},[]),we=c.useCallback(async()=>{if(!J)return;const ee=Ee.current+1;Ee.current=ee,se(!0);try{const fe=await Rl(J);if(Ee.current!==ee)return;D.current=fe;const Ie=fe.projectActions;A(Ie),Z($e=>$e===un||$e&&Ie.some(H=>H.id===$e)?$e:null)}catch{if(Ee.current!==ee)return}finally{Ee.current===ee&&se(!1)}},[J]),G=c.useMemo(()=>Ai(e||J?.path||""),[e,J?.path]),Ce=c.useMemo(()=>Ai(J?.path||""),[J?.path]),Te=c.useMemo(()=>Ai(u||"")||G,[u,G]),pe=c.useRef(Te);c.useEffect(()=>{pe.current=Te},[Te]);const ne=Ot(ee=>G?ee.getDirectoryState(G):void 0),xe=Ot(ee=>Ce&&Ce!==G?ee.getDirectoryState(Ce):void 0),U=c.useMemo(()=>{const ee=G?[{directory:G,state:ne}]:[];return Ce&&Ce!==G&&ee.push({directory:Ce,state:xe}),ee},[ne,G,Ce,xe]),z=c.useMemo(()=>{const ee=G?[G]:[];return Ce&&Ce!==G&&ee.push(Ce),ee},[G,Ce]),Q=c.useCallback(ee=>ee.id!==un&&ee.runIn==="parent"&&Ce||G,[G,Ce]),ue=c.useCallback((ee,fe,Ie)=>`${ee}::${fe}::${Ie}`,[]),le=c.useCallback((ee,fe,Ie=Ot.getState())=>ee?Ie.getDirectoryState(ee)?.tabs.find($e=>$e.purpose.type==="project-action"&&$e.purpose.actionId===fe)??null:null,[]),W=c.useMemo(()=>{const ee={};for(const{directory:fe,state:Ie}of U)for(const $e of Ie?.tabs??[]){if($e.purpose.type!=="project-action"||!$e.purpose.executionId||!$e.terminalSessionId||$e.lifecycle==="idle"||$e.lifecycle==="exited")continue;const H=cn(fe,$e.purpose.actionId),Be=ue(fe,$e.purpose.actionId,$e.purpose.executionId);ee[H]={directory:fe,actionId:$e.purpose.actionId,tabId:$e.id,sessionId:$e.terminalSessionId,executionId:$e.purpose.executionId,status:$e.lifecycle==="stopping"?"stopping":Se[Be]?"waiting-for-preview":"running"}}return ee},[ue,Se,U]),E=c.useCallback((ee,fe,Ie)=>{const $e=cn(ee,fe),H=ue(ee,fe,Ie),Ye=ce.current[$e]?.executionId===Ie,qe=globalThis.window,Xe=jt=>{qe?.clearTimeout(ge.current[jt]),delete ge.current[jt]};Ye&&(delete ce.current[$e],Xe($e)),re.current[H]?.(),delete re.current[H],Xe(H),me(jt=>{if(!jt[H])return jt;const Ve={...jt};return delete Ve[H],Ve})},[ue]),K=c.useCallback(ee=>{re.current[ee]?.(),delete re.current[ee]},[]),te=c.useCallback(ee=>{window.clearTimeout(ge.current[ee]),delete ge.current[ee]},[]);c.useEffect(()=>{const ee=re.current,fe=ge.current;return()=>{for(const Ie of Object.keys(ee))K(Ie);for(const Ie of Object.keys(fe))te(Ie)}},[te,K]),c.useEffect(()=>{const ee=new Set(z);for(const fe of Object.values(ce.current))ee.has(fe.directory)||E(fe.directory,fe.actionId,fe.executionId);for(const fe of Object.keys(re.current)){const Ie=fe.split("::",1)[0]??"";ee.has(Ie)||K(fe)}},[E,K,z]);const oe=c.useCallback((ee,fe)=>{Pe.getState().openContextPanelTab(ee,{mode:"terminal",targetDirectory:fe===ee?null:fe})},[]),he=c.useMemo(()=>P?L.find(ee=>ee.id===P)??null:null,[L,P]),ie=c.useMemo(()=>({id:un,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),Fe=!m,_e=c.useMemo(()=>Fe?[ie,...L]:L,[L,ie,Fe]);c.useEffect(()=>{we()},[we]),c.useEffect(()=>{const ee=z.map(fe=>Yi(a,fe,Y,Ie=>S(fe,Ie.sessions,{startedActionMutationRevisions:Ie.startedActionMutationRevisions})));return()=>{for(const fe of ee)fe()}},[Y,S,a,z]),c.useEffect(()=>{for(const{directory:ee,state:fe}of U)if(ee)for(const Ie of fe?.tabs??[]){if(Ie.purpose.type!=="project-action")continue;const $e=Ie.purpose.actionId,H=_e.find(qe=>qe.id===$e),Be=H?.name??$e,Ye=H?.icon||"play";Ie.label!==Be&&C(ee,Ie.id,Be),Ie.iconKey!==Ye&&v(ee,Ie.id,Ye)}},[_e,v,C,U]),c.useEffect(()=>{const ee=globalThis.window;if(!ee)return;const fe=Ie=>{const $e=Ie.detail;ke&&($e?.projectId&&$e.projectId!==ke||we())};return ee.addEventListener(Il,fe),()=>{ee.removeEventListener(Il,fe)}},[we,ke]),c.useEffect(()=>{P&&(P===un&&Fe||L.some(ee=>ee.id===P)||Z(null))},[L,Fe,P]),c.useEffect(()=>{const ee=Ie=>{delete ge.current[Ie];const $e=ce.current[Ie];if(!$e||$e.openedUrl)return;const H=ue($e.directory,$e.actionId,$e.executionId),Be=$e.announced;if(Be.length!==0){if(window.clearTimeout(ge.current[H]),delete ge.current[H],$e.openedUrl=!0,me(Ye=>{if(!Ye[H])return Ye;const qe={...Ye};return delete qe[H],qe}),Be.length===1){Ri($e.directory,[]),$($e.directory,$e.tabId,Be[0],{locked:!1,autoOpened:!0}),j($e.directory,Be[0]);return}$e.offering=!0,Ri($e.directory,Be),Pe.getState().openContextSurface($e.directory,"browser"),ze.info(o("projectActions.toast.multipleServers"))}},fe=()=>{const Ie=Ot.getState(),$e=Ie.sessions,H=W;for(const[Be,Ye]of Object.entries(H)){const Xe=$e.get(Ye.directory)?.tabs.find(ve=>ve.id===Ye.tabId);if(!Xe||Xe.terminalSessionId!==Ye.sessionId){E(Ye.directory,Ye.actionId,Ye.executionId);continue}const jt=ce.current[Be],Ve=jt?.executionId===Ye.executionId?jt:{hostDirectory:pe.current||Ye.directory,directory:Ye.directory,tabId:Ye.tabId,actionId:Ye.actionId,executionId:Ye.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1};ce.current[Be]=Ve;const pt=_e.find(ve=>ve.id===Ye.actionId),Rt=Ie.getBuffer(Ye.directory,Ye.tabId).chunks;if(!pt||Rt.length===0)continue;const De=Rt.filter(ve=>Ve.lastSeenChunkId===null||ve.id>Ve.lastSeenChunkId);if(De.length===0)continue;const yt=De.map(ve=>ve.data).join(""),Pt=`${Ve.tail}${yt}`;if(Ve.openInPreview&&(!Ve.openedUrl||Ve.offering)){const ve=Ah(Pt),Qe=Ve.announced.length;for(const Ze of ve)Ve.announced.includes(Ze)||Ve.announced.push(Ze);const Ge=Ve.announced.length-Qe;Ve.offering&&Ge>0?Ri(Ye.directory,Ve.announced):!Ve.openedUrl&&Qe===0&&Ve.announced.length>0&&(window.clearTimeout(ge.current[Be]),ge.current[Be]=window.setTimeout(()=>ee(Be),Zb))}const Ue=!Ve.openedUrl&&pt.autoOpenUrl===!0&&!Ve.openInPreview?Ph(Pt):null,He=De[De.length-1]?.id??Ve.lastSeenChunkId;if(Ve.lastSeenChunkId=He,Ve.tail=Pt.slice(-512),Ue)if(Ve.openedUrl=!0,Ve.openInPreview){const ve=H[Be];ve&&($(ve.directory,ve.tabId,Ue,{locked:!1,autoOpened:!1,expectedExecutionId:ve.executionId}),ve.status==="waiting-for-preview"&&me(Qe=>{const Ge=ue(ve.directory,ve.actionId,ve.executionId);if(!Qe[Ge])return Qe;const Ze={...Qe};return delete Ze[Ge],Ze}),window.clearTimeout(ge.current[Be]),delete ge.current[Be],j(ve.directory,Ue))}else de(Ue),ze.success(o("projectActions.toast.openedUrlFromOutput"));ce.current[Be]=Ve}for(const Be of Object.keys(ce.current))if(!H[Be]){const Ye=ce.current[Be],qe=Ye?$e.get(Ye.directory)?.tabs.find(jt=>jt.id===Ye.tabId):void 0;if(qe?.purpose.type==="project-action"&&qe.purpose.executionId===Ye?.executionId&&!!qe.terminalSessionId&&qe.lifecycle!=="idle"&&qe.lifecycle!=="exited")continue;delete ce.current[Be],window.clearTimeout(ge.current[Be]),delete ge.current[Be]}};return fe(),Ot.subscribe((Ie,$e)=>{(Ie.sessions!==$e.sessions||Ie.buffers!==$e.buffers)&&fe()})},[E,pe,_e,ue,j,de,W,$,o]),c.useEffect(()=>{for(const{directory:ee,state:fe}of U)for(const Ie of fe?.tabs??[]){if(Ie.purpose.type!=="project-action"||!Ie.purpose.executionId||!Ie.terminalSessionId||Ie.lifecycle!=="running")continue;const $e=Ie.purpose.actionId,H=Ie.purpose.executionId,Be=ue(ee,$e,H);if(re.current[Be])continue;const Ye=a.connect(Ie.terminalSessionId,{onEvent:qe=>{if(!_(ee,Ie.id,H))return;qe.type==="snapshot"&&(Ot.getState().replaceBuffer(ee,Ie.id,qe.data??"",qe.sequence??0,vl(qe)),qe.status==="running"&&Ot.getState().setTabLifecycle(ee,Ie.id,"running",{expectedExecutionId:H}),qe.status==="exited"&&(Ot.getState().setTabLifecycle(ee,Ie.id,"exited",{expectedExecutionId:H}),Ot.getState().setTabPurpose(ee,Ie.id,{type:"project-action",actionId:$e,executionId:null}),E(ee,$e,H)));const Xe=qe.type==="data"?qe.data??"":"";Xe&&Ot.getState().appendToBuffer(ee,Ie.id,Xe,qe.sequence,qe.replayData),qe.type==="exit"&&(Ot.getState().setTabLifecycle(ee,Ie.id,"exited",{expectedExecutionId:H}),Ot.getState().setTabPurpose(ee,Ie.id,{type:"project-action",actionId:$e,executionId:null}),E(ee,$e,H))},onError:(qe,Xe)=>{!Xe||!_(ee,Ie.id,H)||(Ot.getState().setTabLifecycle(ee,Ie.id,"exited",{expectedExecutionId:H}),Ot.getState().setTabSessionId(ee,Ie.id,null,{expectedExecutionId:H}),Ot.getState().setTabPurpose(ee,Ie.id,{type:"project-action",actionId:$e,executionId:null}),E(ee,$e,H))}});re.current[Be]=Ye.close}},[E,ue,_,a,U]);const Ae=c.useCallback(async ee=>{const fe=Q(ee);if(!fe)throw new Error(o("projectActions.error.noActiveDirectory"));const Ie=cn(fe,ee.id);b(fe);const $e=Ot.getState(),H=le(fe,ee.id,$e),Be=H?.id??$e.createTab(fe);C(fe,Be,ee.name),v(fe,Be,ee.icon||"play"),H||B(fe,Be,{type:"project-action",actionId:ee.id,executionId:null}),M(fe,Be);const qe=Ot.getState().getDirectoryState(fe)?.tabs.find(Xe=>Xe.id===Be);return{executionDirectory:fe,key:Ie,tabId:Be,sessionId:qe?.terminalSessionId??null,executionId:qe?.purpose.type==="project-action"?qe.purpose.executionId:null}},[b,Q,le,M,v,C,B,o]),Me=c.useCallback(async ee=>{if(d.isVSCode||!i&&m)return;if(!G){ze.error(o("projectActions.error.noActiveDirectoryForAction"));return}const fe=cn(Q(ee),ee.id),Ie=W[fe];if(Ie&&Ie.status==="running"||ae.current.has(fe))return;ae.current.add(fe);let $e=null;try{const H=ee.id===un?await(async()=>{const[Ge,Ze]=await Promise.all([hp({id:J?.id??"",path:G}),Xb(G)]),lt=await Ub(G,Ge.actions,Ze);if(!lt)throw new Error(o("contextPanel.preview.noDevServer"));return{id:un,name:o("projectActions.actions.autoDiscover"),command:lt.command,icon:"scan-2",autoOpenUrl:!0,openUrl:lt.previewUrlHint||""}})():ee,Be=H.autoOpenUrl===!0&&(H.openUrl||"").trim().length>0,Ye=!Be&&ee.id!==un,qe=pe.current||G,{executionDirectory:Xe,key:jt,tabId:Ve}=await Ae(H),pt=Sh(H.command);if(!pt)throw new Error(o("projectActions.error.failedToRunAction"));const Rt=H.autoOpenUrl===!0&&f&&(H.desktopOpenSshForward||"").trim().length>0,De=H.autoOpenUrl?ey(H.openUrl):null,yt=H.autoOpenUrl&&f?jh(H.desktopOpenSshForward,p):null;if(a.listSessions){const Ge=le(Xe,H.id);if(Ge?.purpose.type==="project-action"&&Ge.purpose.executionId===null){const Ze=await kh(a,Xe,{captureStartedActionMutationRevisions:Y});Ze&&S(Xe,Ze.sessions,{startedActionMutationRevisions:Ze.startedActionMutationRevisions})}}const Pt=le(Xe,H.id);let Ue,He;if(Pt?.lifecycle==="running"&&Pt.terminalSessionId&&Pt.purpose.type==="project-action"&&Pt.purpose.executionId)Ue=Pt.terminalSessionId,He=Pt.purpose.executionId;else{const Ge=Pt?.purpose.type==="project-action"?Pt.purpose.executionId:null;Ge&&E(Xe,H.id,Ge);const Ze=O(Xe,Ve,H.id);if(!Ze)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));$e={directory:Xe,tabId:Ve,id:Ze},R(Xe,Ve,!0,{expectedExecutionId:Ze});const lt=await Ch({terminal:a,createOptions:{cwd:Xe,shell:x,loginShell:k,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground},command:pt,isRunStillExpected:()=>_(Xe,Ve,Ze),purpose:{type:"project-action",actionId:H.id,executionId:Ze}});if(!_(Xe,Ve,Ze)){lt.sessionId===Ze&&await a.close(lt.sessionId).catch(()=>{});return}He=lt.purpose?.type==="project-action"?lt.purpose.executionId:Ze,Ue=lt.sessionId,B(Xe,Ve,{type:"project-action",actionId:H.id,executionId:He}),I(Xe,Ve,Ue,{expectedExecutionId:He}),R(Xe,Ve,!1,{expectedExecutionId:He})}Ye&&qe&&oe(qe,Xe),ce.current[jt]={hostDirectory:qe,directory:Xe,tabId:Ve,actionId:H.id,executionId:He,lastSeenChunkId:null,openedUrl:!!yt||!!De||Be,tail:"",openInPreview:H.id===un,announced:[],offering:!1};const ve=ue(Xe,H.id,He);R(Xe,Ve,!0,{expectedExecutionId:He});const Qe=a.connect(Ue,{onEvent:Ge=>{if(!_(Xe,Ve,He)||Ge.purpose?.type==="project-action"&&Ge.purpose.executionId!==He)return;Ge.type==="snapshot"&&(Ot.getState().replaceBuffer(Xe,Ve,Ge.data??"",Ge.sequence??0,vl(Ge)),Ot.getState().setConnecting(Xe,Ve,!1,{expectedExecutionId:He}),Ge.purpose?.type==="project-action"&&Ot.getState().setTabPurpose(Xe,Ve,{type:"project-action",actionId:Ge.purpose.actionId,executionId:Ge.purpose.executionId}),Ge.status==="running"&&Ot.getState().setTabLifecycle(Xe,Ve,"running",{expectedExecutionId:He}),Ge.status==="exited"&&(Ot.getState().setTabLifecycle(Xe,Ve,"exited",{expectedExecutionId:He}),Ot.getState().setTabPurpose(Xe,Ve,{type:"project-action",actionId:H.id,executionId:null}),E(Xe,H.id,He)));const Ze=Ge.type==="data"?Ge.data??"":"";Ze&&Ot.getState().appendToBuffer(Xe,Ve,Ze,Ge.sequence,Ge.replayData),Ge.type==="exit"&&(Ot.getState().setTabLifecycle(Xe,Ve,"exited",{expectedExecutionId:He}),Ot.getState().setConnecting(Xe,Ve,!1,{expectedExecutionId:He}),Ot.getState().setTabPurpose(Xe,Ve,{type:"project-action",actionId:H.id,executionId:null}),E(Xe,H.id,He))},onError:(Ge,Ze)=>{_(Xe,Ve,He)&&(Ot.getState().setConnecting(Xe,Ve,!1,{expectedExecutionId:He}),Ze&&(Ot.getState().setTabLifecycle(Xe,Ve,"exited",{expectedExecutionId:He}),Ot.getState().setTabSessionId(Xe,Ve,null,{expectedExecutionId:He}),Ot.getState().setTabPurpose(Xe,Ve,{type:"project-action",actionId:H.id,executionId:null}),E(Xe,H.id,He)))}});if(!_(Xe,Ve,He)){Qe.close();return}re.current[ve]?.(),re.current[ve]=Qe.close,window.clearTimeout(ge.current[ve]),delete ge.current[ve],H.id===un&&!De&&(me(Ge=>({...Ge,[ve]:!0})),ge.current[ve]=window.setTimeout(()=>{delete ge.current[ve];const Ge=ce.current[jt];!Ge||Ge.executionId!==He||Ge.openedUrl||Ge.offering||_(Xe,Ve,He)&&(me(Ze=>{if(!Ze[ve])return Ze;const lt={...Ze};return delete lt[ve],lt}),Ot.getState().setActiveTab(Xe,Ve),oe(Ge.hostDirectory,Xe))},Jb)),yt?($(Xe,Ve,null,{locked:!0,expectedExecutionId:He}),de(yt),ze.success(o("projectActions.toast.openedForwardedUrl"))):De?($(Xe,Ve,De,{locked:!0,autoOpened:!0,expectedExecutionId:He}),j(qe,De),ze.success(o("projectActions.toast.openedActionUrl"))):Be?($(Xe,Ve,null,{locked:!0,expectedExecutionId:He}),ze.error(o("projectActions.error.invalidCustomUrlFormat"))):Rt?($(Xe,Ve,null,{locked:!0,expectedExecutionId:He}),ze.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):$(Xe,Ve,null,{locked:!1,autoOpened:!1,expectedExecutionId:He})}catch(H){if($e&&_($e.directory,$e.tabId,$e.id)){const{directory:Be,tabId:Ye,id:qe}=$e;E(Be,ee.id,qe),T(Be,Ye,"exited",{expectedExecutionId:qe}),B(Be,Ye,{type:"project-action",actionId:ee.id,executionId:null})}if(H instanceof Error&&H.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(H instanceof Error&&(H.message==="COMMAND_MODE_UNSUPPORTED"||H.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){ze.error(o("projectActions.error.failedToCreateTerminalSession"));return}ze.error(H instanceof Error?H.message:o("projectActions.error.failedToRunAction"))}finally{ae.current.delete(fe)}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,pe,p,Ae,i,m,f,G,k,x,de,j,W,oe,d.isVSCode,Q,_,E,ue,le,S,O,Y,R,T,B,$,I,J?.id,o,a]),q=c.useCallback(async ee=>{const fe=cn(Q(ee),ee.id),Ie=W[fe];Ie&&await Nh({terminal:a,sessionId:Ie.sessionId,isExecutionStillCurrent:()=>_(Ie.directory,Ie.tabId,Ie.executionId),markStopping:()=>{T(Ie.directory,Ie.tabId,"stopping",{expectedExecutionId:Ie.executionId})},restoreRunning:()=>{T(Ie.directory,Ie.tabId,"running",{expectedExecutionId:Ie.executionId})},clearSession:()=>{I(Ie.directory,Ie.tabId,null,{expectedExecutionId:Ie.executionId})},finalizeExit:()=>{T(Ie.directory,Ie.tabId,"exited",{expectedExecutionId:Ie.executionId}),B(Ie.directory,Ie.tabId,{type:"project-action",actionId:Ie.actionId,executionId:null}),E(Ie.directory,Ie.actionId,Ie.executionId)}})},[E,Q,_,W,T,B,I,a]),Ne=c.useCallback(()=>{const ee=he??_e[0];if(!ee)return;const fe=cn(Q(ee),ee.id),Ie=W[fe];if(Ie?.status!=="stopping"){if(Ie){q(ee);return}Me(ee)}},[_e,Q,Me,W,he,q]),je=c.useCallback(async ee=>{if(ee.source==="shared"&&J){const fe=D.current?.trust.trusted?D.current:await Rl(J);if(D.current=fe,!await pp(J,fe))return;D.current={...fe,trust:{...fe.trust,trusted:!0}}}await Me(ee)},[Me,J]),We=c.useCallback((ee,fe=!1)=>{if(Z(ee.id),!fe){je(ee);return}const Ie=cn(Q(ee),ee.id),$e=W[Ie];if($e?.status!=="stopping"){if($e){q(ee);return}je(ee)}},[Q,je,W,q]),tt=c.useCallback(()=>{J?.id&&(g(J.id),w("projects"),h(!0))},[h,w,g,J?.id]),it=he??_e[0]??null,rt=it?W[cn(Q(it),it.id)]:null,ot=Ot(ee=>rt?ee.getDirectoryState(rt.directory)?.tabs.find(fe=>fe.id===rt.tabId)?.previewUrl??null:null);if(d.isVSCode||!i&&m||!J||!G)return null;const ft=he??_e[0]??null;if(!ft)return null;const st=Mi(ft),Ct=cn(Q(ft),ft.id),ht=W[Ct],be=ht?.status==="stopping",Je=ht?.status==="waiting-for-preview",dt=!!(ht&&ot),Ke=()=>{!ht||!ot||j(ht.directory,ot)},mt=ft.id===un;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",disabled:X||be,className:Re("app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2","typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:cursor-not-allowed",n),onClick:Ne,"aria-label":ht?o("projectActions.actions.stopNamedAria",{name:ft.name}):o("projectActions.actions.runNamedAria",{name:ft.name}),children:be||Je?s.jsx(F,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):ht?s.jsx(F,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(F,{name:st,className:"h-5 w-5"})})}),mt?s.jsx(St,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),dt?s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("projectActions.actions.openPreview"),onClick:Ke,children:s.jsx(F,{name:"global",className:"h-4 w-4"})})}),s.jsx(St,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs($s,{children:[s.jsx(_s,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(F,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(Ls,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Ht,{className:"flex items-center gap-2",onClick:tt,children:[s.jsx(F,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(As,{}),_e.map(ee=>{const fe=Mi(ee),Ie=cn(Q(ee),ee.id),$e=W[Ie],H=!!$e,Be=$e?.status==="stopping";return s.jsxs(Ht,{className:"flex items-center gap-2",onClick:()=>{We(ee,!0)},children:[s.jsx(F,{name:fe,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:ee.name}),ee.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Be||$e?.status==="waiting-for-preview"?s.jsx(F,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):H?s.jsx(F,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},ee.id)})]})]})]}):s.jsxs("div",{className:Re("app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r?"h-9":"h-7",n),children:[s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Ne,disabled:X||be,className:Re("inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover",r?"w-9 px-0":"px-2.5","transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed"),"aria-label":ht?o("projectActions.actions.stopNamedAria",{name:ft.name}):o("projectActions.actions.runNamedAria",{name:ft.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:be||Je?s.jsx(F,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):ht?s.jsx(F,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(F,{name:st,className:"h-4 w-4"})})})}),mt?s.jsx(St,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),dt?s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Ke,className:Re(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-foreground","hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":o("projectActions.actions.openPreview"),children:s.jsx(F,{name:"global",className:"h-4 w-4"})})}),s.jsx(St,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs($s,{children:[s.jsx(_s,{asChild:!0,children:s.jsx("button",{type:"button",className:Re(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(F,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(Ls,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Ht,{className:"flex items-center gap-2",onClick:tt,children:[s.jsx(F,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(As,{}),_e.map(ee=>{const fe=Mi(ee),Ie=cn(Q(ee),ee.id),$e=W[Ie],H=!!$e,Be=$e?.status==="stopping";return s.jsxs(Ht,{className:"flex items-center gap-2",onClick:()=>{We(ee,!0)},children:[s.jsx(F,{name:fe,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:ee.name}),ee.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Be||$e?.status==="waiting-for-preview"?s.jsx(F,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):H?s.jsx(F,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},ee.id)})]})]})]})},Kr=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},sy=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const i=Kr(n??"");if(i){const o=lu(t,e,i);if(o)return o}return t.find(o=>o.id===r)??null};function ny(){const t=Gt(x=>x.projects),e=Gt(x=>x.activeProjectId),n=nt(x=>x.availableWorktreesByProject),r=nt(x=>x.currentSessionId),i=gp(r??null),o=nt(x=>r?x.worktreeMetadata.get(r)?.path??"":""),l=nt(x=>x.newSessionDraft?.open?Kr(x.newSessionDraft.bootstrapPendingDirectory??x.newSessionDraft.directoryOverride??""):""),a=c.useMemo(()=>Kr(o||""),[o]),d=c.useMemo(()=>{const x=typeof i?.directory=="string"?i.directory:"";return Kr(x||"")},[i?.directory]),u=a||d||l,m=c.useMemo(()=>sy({projects:t,worktreesByProject:n,directory:u,activeProjectId:e}),[e,u,t,n]),f=c.useMemo(()=>Kr(u||m?.path||""),[u,m?.path]),p=c.useMemo(()=>m?{id:m.id,path:m.path}:null,[m]),y=c.useRef(null);return c.useEffect(()=>{p&&f&&(y.current={projectRef:p,directory:f})},[f,p]),c.useMemo(()=>p&&f?{projectRef:p,directory:f}:y.current,[p,f])}const ry=({transform:t})=>({...t,y:0}),oy={Item:Ht,Separator:As},iy={Item:({className:t,...e})=>s.jsx(of,{className:Re(fu,t),...e}),Separator:({className:t,...e})=>s.jsx(rf,{className:Re(uu,t),...e})},ay=t=>{const e=et.c(67),{tab:n,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:d,onMenuOpenChangeComplete:u,children:m}=t,{t:f}=kt(),[p,y]=c.useState(!1),[x,k]=c.useState(!1),[w,h]=c.useState(!1);let g;e[0]!==n.id?(g={id:n.id},e[0]=n.id,e[1]=g):g=e[1];const{attributes:j,listeners:b,setNodeRef:S,transform:C,transition:v,isDragging:M}=pi(g);let R;e[2]!==f||e[3]!==n.session.title?(R=n.session.title?.trim()||f("sessions.sidebar.session.untitled"),e[2]=f,e[3]=n.session.title,e[4]=R):R=e[4];const I=R,B=!i&&(p||x),O=n.id;let T;e[5]!==n.session?(T=Ps(n.session),e[5]=n.session,e[6]=T):T=e[6];const $=$a(O,T),_=cu(n.id),L=du(n.id)>0&&!r&&!_,A=_||L;let D;e[7]!==_||e[8]!==f?(D=f(_?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[7]=_,e[8]=f,e[9]=D):D=e[9];const P=D;let Z;e[10]!==d||e[11]!==w||e[12]!==r||e[13]!==p||e[14]!==o||e[15]!==n?(Z=Ce=>({session:n.session,open:p||w,isActive:r,select:()=>o(n),closeOtherTabs:()=>d(n.id),components:Ce}),e[10]=d,e[11]=w,e[12]=r,e[13]=p,e[14]=o,e[15]=n,e[16]=Z):Z=e[16];const X=Z;let se;e[17]!==C?(se=gi.Translate.toString(C),e[17]=C,e[18]=se):se=e[18];let ce;e[19]!==se||e[20]!==v?(ce={transform:se,transition:v},e[19]=se,e[20]=v,e[21]=ce):ce=e[21];const re=M&&"z-10 opacity-60";let ge;e[22]!==re?(ge=Re("session-tab-slot flex h-7 w-44 shrink-0 touch-none",re),e[22]=re,e[23]=ge):ge=e[23];const ae=r?"true":"false";let Ee;e[24]!==r?(Ee=r?{"data-active-session-tab":!0}:{},e[24]=r,e[25]=Ee):Ee=e[25];let Se;e[26]!==u?(Se=Ce=>u?.(Ce),e[26]=u,e[27]=Se):Se=e[27];let me;e[28]!==m||e[29]!==P||e[30]!==r||e[31]!==$||e[32]!==_||e[33]!==X||e[34]!==p||e[35]!==l||e[36]!==u||e[37]!==o||e[38]!==B||e[39]!==a||e[40]!==A||e[41]!==i||e[42]!==f||e[43]!==n||e[44]!==I?(me=s.jsx(af,{render:Ce=>s.jsxs("div",{...Ce,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(n),onKeyDown:r?void 0:Te=>{(Te.key==="Enter"||Te.key===" ")&&(Te.preventDefault(),o(n))},onAuxClick:Te=>{Te.button===1&&(Te.preventDefault(),l(n.id))},"data-controls-open":B?"true":"false",className:Re("session-tab group/session-tab relative flex h-7 w-full min-w-0 select-none items-center rounded-md px-2",r?"bg-interactive-selection text-interactive-selection-foreground":Re("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",B&&"bg-interactive-hover text-foreground")),children:[s.jsxs("div",{className:Re("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pr-10",B&&"pr-10"),children:[s.jsx("div",{className:Re("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title"),children:r?m:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:s.jsx("span",{className:"block max-w-full overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4",children:I})})}),$?s.jsx(F,{name:"loader-4",className:"ml-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":f("sessions.aiRename.generating")}):A?s.jsx(za,{state:_?"running":"unread",label:P,className:Re("ml-1.5 shrink-0",!i&&"group-hover/session-tab:opacity-0",B&&"opacity-0")}):null]}),i?null:s.jsxs("div",{onClick:cy,onPointerDown:dy,className:Re("absolute right-1 top-1/2 hidden -translate-y-1/2 items-center gap-0.5","opacity-0 transition-opacity duration-150","group-hover/session-tab:flex group-hover/session-tab:opacity-100",B&&"flex opacity-100"),children:[s.jsxs($s,{open:p,onOpenChange:Te=>{y(Te),Te&&k(!0)},onOpenChangeComplete:Te=>{Te||k(!1),u?.(Te)},children:[s.jsx(_s,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(F,{name:"more",className:"size-4"})})}),s.jsx(Ls,{align:"start",className:"min-w-[190px]",children:a(X(oy))})]}),s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.closeTab"),onClick:()=>l(n.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(F,{name:"close",className:"size-4"})})]})]})}),e[28]=m,e[29]=P,e[30]=r,e[31]=$,e[32]=_,e[33]=X,e[34]=p,e[35]=l,e[36]=u,e[37]=o,e[38]=B,e[39]=a,e[40]=A,e[41]=i,e[42]=f,e[43]=n,e[44]=I,e[45]=me):me=e[45];let ke,V;e[46]===Symbol.for("react.memo_cache_sentinel")?(ke={color:"var(--surface-elevated-foreground)"},V=Re(Ji,"min-w-[190px]"),e[46]=ke,e[47]=V):(ke=e[46],V=e[47]);let J;e[48]!==X||e[49]!==a?(J=a(X(iy)),e[48]=X,e[49]=a,e[50]=J):J=e[50];let de;e[51]!==J?(de=s.jsx(ua,{children:s.jsx(fa,{className:"app-region-no-drag z-50",children:s.jsx(ma,{"data-slot":"dropdown-menu-content",style:ke,className:V,children:J})})}),e[51]=J,e[52]=de):de=e[52];let we;e[53]!==w||e[54]!==Se||e[55]!==me||e[56]!==de?(we=s.jsxs(lf,{open:w,onOpenChange:h,onOpenChangeComplete:Se,children:[me,de]}),e[53]=w,e[54]=Se,e[55]=me,e[56]=de,e[57]=we):we=e[57];let G;return e[58]!==j||e[59]!==b||e[60]!==S||e[61]!==ge||e[62]!==ae||e[63]!==Ee||e[64]!==we||e[65]!==ce?(G=s.jsx("div",{ref:S,style:ce,className:ge,"data-active":ae,...Ee,...j,...b,children:we}),e[58]=j,e[59]=b,e[60]=S,e[61]=ge,e[62]=ae,e[63]=Ee,e[64]=we,e[65]=ce,e[66]=G):G=e[66],G},ly=t=>{const e=et.c(64),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=kt(),d=fo(uy),u=fo(fy),m=fo(my),f=fo(hy),p=nt(py),y=nt(gy),x=js(xy);let k,w;e[0]!==p||e[1]!==u?(k=()=>{p&&u(p)},w=[p,u],e[0]=p,e[1]=u,e[2]=k,e[3]=w):(k=e[2],w=e[3]),c.useEffect(k,w);let h;if(e[4]!==x){h=new Map;for(const pe of x)h.set(pe.id,pe);e[4]=x,e[5]=h}else h=e[5];const g=h;let j;if(e[6]!==g||e[7]!==d){j=[];for(const pe of d){const ne=g.get(pe);ne&&j.push({id:pe,session:ne})}e[6]=g,e[7]=d,e[8]=j}else j=e[8];const b=j;let S;e[9]!==y?(S=pe=>{y(pe.id,Ps(pe.session))},e[9]=y,e[10]=S):S=e[10];const C=S,v=by;let M;e[11]!==m||e[12]!==p||e[13]!==C||e[14]!==b?(M=pe=>{if(m(pe),p&&p!==pe){const ne=b.find(xe=>xe.id===pe);ne&&C(ne)}},e[11]=m,e[12]=p,e[13]=C,e[14]=b,e[15]=M):M=e[15];const R=M;let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I={activationConstraint:{distance:8}},e[16]=I):I=e[16];let B;e[17]===Symbol.for("react.memo_cache_sentinel")?(B={activationConstraint:{delay:200,tolerance:6}},e[17]=B):B=e[17];const O=di(Tn(fi,I),Tn(ui,B));let T;e[18]!==f?(T=pe=>{const{active:ne,over:xe}=pe;xe&&ne.id!==xe.id&&f(String(ne.id),String(xe.id))},e[18]=f,e[19]=T):T=e[19];const $=T,_=c.useRef(null);let Y;e[20]===Symbol.for("react.memo_cache_sentinel")?(Y={left:!1,right:!1},e[20]=Y):Y=e[20];const[L,A]=c.useState(Y);let D;e[21]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{const pe=_.current;if(!pe)return;const ne=pe.scrollLeft>2,xe=pe.scrollLeft+pe.clientWidth<pe.scrollWidth-2;A(U=>U.left===ne&&U.right===xe?U:{left:ne,right:xe})},e[21]=D):D=e[21];const P=D;let Z;e[22]===Symbol.for("react.memo_cache_sentinel")?(Z=()=>{P();const pe=_.current;if(!pe||!globalThis.ResizeObserver)return;const ne=new ResizeObserver(P);return ne.observe(pe),()=>ne.disconnect()},e[22]=Z):Z=e[22];let X;e[23]!==b.length?(X=[P,b.length],e[23]=b.length,e[24]=X):X=e[24],c.useEffect(Z,X);let se;e[25]===Symbol.for("react.memo_cache_sentinel")?(se=()=>{_.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[25]=se):se=e[25];let ce;e[26]!==p?(ce=[p],e[26]=p,e[27]=ce):ce=e[27],c.useEffect(se,ce);const re=L.left&&L.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":L.left?"linear-gradient(to right, transparent, black 24px)":L.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let ge;e[28]!==b?(ge=b.map(yy),e[28]=b,e[29]=ge):ge=e[29];const ae=ge;let Ee;e[30]!==p||e[31]!==b?(Ee=!p||!b.some(pe=>pe.id===p),e[30]=p,e[31]=b,e[32]=Ee):Ee=e[32];const Se=Ee;let me;e[33]!==a?(me=a("header.sessionTabs.stripAria"),e[33]=a,e[34]=me):me=e[34];let ke;e[35]!==re?(ke=re?{maskImage:re,WebkitMaskImage:re}:void 0,e[35]=re,e[36]=ke):ke=e[36];let V;e[37]===Symbol.for("react.memo_cache_sentinel")?(V=[ry],e[37]=V):V=e[37];let J;e[38]!==o||e[39]!==p||e[40]!==R||e[41]!==C||e[42]!==r||e[43]!==n||e[44]!==l||e[45]!==b?(J=b.map(pe=>s.jsx(ay,{tab:pe,isActive:pe.id===p,suppressControls:pe.id===p&&l,onSelect:C,onClose:v,renderMenu:n,closeOtherTabs:R,onMenuOpenChangeComplete:r,children:pe.id===p?o:null},pe.id)),e[38]=o,e[39]=p,e[40]=R,e[41]=C,e[42]=r,e[43]=n,e[44]=l,e[45]=b,e[46]=J):J=e[46];let de;e[47]!==J||e[48]!==ae?(de=s.jsx(nl,{items:ae,strategy:ub,children:J}),e[47]=J,e[48]=ae,e[49]=de):de=e[49];let we;e[50]!==$||e[51]!==O||e[52]!==de?(we=s.jsx(mi,{sensors:O,collisionDetection:hi,modifiers:V,onDragEnd:$,children:de}),e[50]=$,e[51]=O,e[52]=de,e[53]=we):we=e[53];let G;e[54]!==o||e[55]!==Se?(G=Se?s.jsx("div",{role:"tab","aria-selected":!0,className:"session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2","data-active":"true",children:s.jsx("div",{className:"min-w-0 flex-1",children:o})}):null,e[54]=o,e[55]=Se,e[56]=G):G=e[56];let Ce;e[57]!==ke||e[58]!==we||e[59]!==G?(Ce=s.jsxs("div",{ref:_,onScroll:P,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:ke,children:[we,G]}),e[57]=ke,e[58]=we,e[59]=G,e[60]=Ce):Ce=e[60];let Te;return e[61]!==me||e[62]!==Ce?(Te=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":me,children:Ce}),e[61]=me,e[62]=Ce,e[63]=Te):Te=e[63],Te};function cy(t){return t.stopPropagation()}function dy(t){return t.stopPropagation()}function uy(t){return t.tabIds}function fy(t){return t.ensureTab}function my(t){return t.closeOtherTabs}function hy(t){return t.reorderTabs}function py(t){return t.currentSessionId}function gy(t){return t.setCurrentSession}function xy(t){return t.activeSessions}function by(t){xp(t)}function yy(t){return t.id}const hf=async t=>{const{entry:e,session:n}=t,r=Qt(),i={sessionId:n.id,sessionTitle:n.title,directory:n.directory};if(!(bp(e.action)&&yp(e.guest,"conversation"))){await Ml(e,Ol(e.action.id,i),t.t,r);return}let l=!1;const a=Dr(()=>{l=!0});let d;try{d=await t.loadRecords()}finally{a()}if(!l){if(!d){t.onLoadFailed();return}await Ml(e,Ol(e.action.id,i,d),t.t,r)}};function pa(t){const e=et.c(16),{sessionID:n,directory:r,open:i,Item:o}=t,{t:l}=kt(),{pending:a,disabled:d,hint:u,run:m}=Ih(n,r,i),f=a?"loader-4":"ai-generate-2",p=a?"mr-1 size-4 animate-spin":"mr-1 size-[15px]";let y;e[0]!==f||e[1]!==p?(y=s.jsx(F,{name:f,className:p}),e[0]=f,e[1]=p,e[2]=y):y=e[2];let x;e[3]!==l?(x=l("sessions.aiRename.action"),e[3]=l,e[4]=x):x=e[4];let k;e[5]!==o||e[6]!==d||e[7]!==m||e[8]!==y||e[9]!==x?(k=s.jsx(vt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(o,{disabled:d,onClick:m,className:"w-full",children:[y,x]})})}),e[5]=o,e[6]=d,e[7]=m,e[8]=y,e[9]=x,e[10]=k):k=e[10];let w;e[11]!==u?(w=s.jsx(St,{side:"right",children:u}),e[11]=u,e[12]=w):w=e[12];let h;return e[13]!==k||e[14]!==w?(h=s.jsxs(wt,{children:[k,w]}),e[13]=k,e[14]=w,e[15]=h):h=e[15],h}const ga=(t,e)=>({success:t(e.success),failure:t(e.failure),outcomeUnknown:t("sessions.sidebar.session.moveToWorktree.outcomeUnknown")});class pf extends Error{constructor(e){super(e.message,{cause:e}),this.name="SessionMoveOutcomeUnknownError"}}const xi=oo(()=>({pendingSessionIds:new Set})),gf=t=>{const e=et.c(2);let n;return e[0]!==t?(n=r=>r.pendingSessionIds.has(t),e[0]=t,e[1]=n):n=e[1],xi(n)},ic=(t,e)=>{xi.setState(n=>{if(n.pendingSessionIds.has(t)===e)return n;const r=new Set(n.pendingSessionIds);return e?r.add(t):r.delete(t),{...n,pendingSessionIds:r}})},wy=async(t,e)=>{try{const d=(await Cp(t,{mode:"light"})).current?.trim();if(d)return d}catch{}const n=xt(t),r=xt(e)??e,i=nt.getState().availableWorktreesByProject,l=(i.get(r)??i.get(e)??[]).find(a=>xt(a.path)===n)?.branch?.trim();if(l)return l;throw new Error("Unable to determine the current branch")},ac=t=>{for(const e of t){const n=vp(e.id);if(n==="unknown")throw new Error("Session status is unavailable");if(n==="active")throw new Error("Session is not idle")}};class vy extends Error{constructor(e,n){super(e,{cause:n}),this.name="IncompleteRollbackError"}}const Sy=(t,e)=>{const n=e.map(({sessionId:r,error:i})=>`${r}: ${i.message}`).join(", ");return new vy(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${n}`,{moveError:t,rollbackFailures:e})},jy=async(t,e,n,r)=>{const i=[];for(const o of[...t].reverse()){if(Sp(o.id)){i.push({sessionId:o.id,error:new Error("Session is not idle")});continue}try{await mu(o,n,e),nt.getState().setWorktreeMetadata(o.id,r.get(o.id)??null)}catch(l){i.push({sessionId:o.id,error:l instanceof Error?l:new Error(String(l))})}}return i},lc=async(t,e,n)=>{try{await pu(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${n.message}`)}throw n},cc=async(t,e)=>{const n=e?[t,e]:[t];try{await Wa(n)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},xf=async(t,e)=>{if(xi.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");ic(t.root.id,!0);try{const n=[...t.descendants,t.root],r=new Map(n.map(a=>[a.id,nt.getState().getWorktreeMetadata(a.id)]));ac(n);let i=null;const o=[];let l=!1;try{i=await e();for(const[a,d]of n.entries()){ac(n.slice(a));try{await mu(d,t.sourceDirectory,i.directory)}catch(u){throw wp(u)&&(l=!0),u}o.push(d),d.id!==t.root.id&&nt.getState().setWorktreeMetadata(d.id,Bl(i.metadata))}}catch(a){const d=a instanceof Error?a:new Error(String(a)),u=await jy(o,t.sourceDirectory,i?.directory??t.sourceDirectory,r);if(l&&await cc(t.sourceDirectory,i?.directory),u.length>0)throw Sy(d,u);if(i?.onMoveFailure&&!l)return i.onMoveFailure(d);throw i?.onMoveFailure&&l?new pf(d):d}return nt.getState().setWorktreeMetadata(t.root.id,Bl(i.metadata)),await cc(t.sourceDirectory,i.directory),i.directory}finally{ic(t.root.id,!1)}},ky=async t=>{const e=xt(t.sourceDirectory)??t.sourceDirectory,n=xt(t.destination.path)??t.destination.path;if(e===n)throw new Error("Source and destination are the same");if(t.destination.worktreeStatus!=="ready")throw new Error("Destination worktree is not ready");return xf(t,async()=>({directory:t.destination.path,metadata:t.destination}))},Cy=async t=>xf(t,async()=>{const e=Zi(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const n=await hu(t.sourceDirectory)?await wy(t.sourceDirectory,e.path):null,r=await jp(e,n?{startRef:n}:{});try{await kp(r.path)}catch(i){const o=i instanceof Error?i:new Error(String(i));return lc(e,r,o)}return{directory:r.path,metadata:r,onMoveFailure:async i=>lc(e,r,i)}}),Ny=t=>{(t.kind==="existing"?ky({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination}):Cy({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory})).then(()=>ze.success(t.messages.success)).catch(n=>{const r=n instanceof Error?n:new Error(String(n));ze.error(t.messages.failure,{description:r instanceof pf?t.messages.outcomeUnknown:r.message})})},xa=t=>{xi.getState().pendingSessionIds.has(t.root.id)||Ny(t)},Ho="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors",Ay=c.memo(function(e){const n=et.c(17),{visible:r,title:i,ariaLabel:o,onClick:l,className:a,Icon:d,iconClassName:u,pressed:m}=e,f=r===void 0?!0:r,p=m===void 0?!1:m;if(!f)return null;const y=a??Ho,x=p&&"bg-interactive-selection text-interactive-selection-foreground";let k;n[0]!==y||n[1]!==x?(k=Re(y,x),n[0]=y,n[1]=x,n[2]=k):k=n[2];const w=u??"h-[18px] w-[18px]";let h;n[3]!==d||n[4]!==w?(h=s.jsx(F,{name:d,className:w}),n[3]=d,n[4]=w,n[5]=h):h=n[5];let g;n[6]!==o||n[7]!==l||n[8]!==p||n[9]!==k||n[10]!==h?(g=s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,"aria-label":o,"aria-pressed":p,className:k,children:h})}),n[6]=o,n[7]=l,n[8]=p,n[9]=k,n[10]=h,n[11]=g):g=n[11];let j;n[12]!==i?(j=s.jsx(St,{children:s.jsx("p",{children:i})}),n[12]=i,n[13]=j):j=n[13];let b;return n[14]!==g||n[15]!==j?(b=s.jsxs(wt,{children:[g,j]}),n[14]=g,n[15]=j,n[16]=b):b=n[16],b}),Py=c.memo(function(e){const n=et.c(43),{isDesktopApp:r,currentInstanceLabel:i,currentInstanceIsLocal:o,isDesktopServicesOpen:l,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:d,shortcutLabel:u,remoteUpdateInfo:m,remoteUpdateChecking:f,remoteUpdateError:p,onOpenRemoteUpdate:y}=e,{t:x}=kt();let k;n[0]!==d||n[1]!==a?(k=O=>{a(O),O&&d()},n[0]=d,n[1]=a,n[2]=k):k=n[2];let w;n[3]!==i||n[4]!==r||n[5]!==x?(w=r?x("header.services.openWithCurrent",{current:i}):x("header.services.open"),n[3]=i,n[4]=r,n[5]=x,n[6]=w):w=n[6];const h=r?"w-auto max-w-[20rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let g;n[7]!==h?(g=Re(Ho,h),n[7]=h,n[8]=g):g=n[8];let j;n[9]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(F,{name:"server",className:"h-[18px] w-[18px]"}),n[9]=j):j=n[9];let b;n[10]!==i||n[11]!==r?(b=r?s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:i}):null,n[10]=i,n[11]=r,n[12]=b):b=n[12];let S;n[13]!==w||n[14]!==g||n[15]!==b?(S=s.jsx(vt,{asChild:!0,children:s.jsx(_s,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":w,className:g,children:[j,b]})})}),n[13]=w,n[14]=g,n[15]=b,n[16]=S):S=n[16];let C;n[17]!==i||n[18]!==u||n[19]!==x?(C=x("header.services.tooltip.currentInstance",{current:i,toggle:u("toggle_services_menu")}),n[17]=i,n[18]=u,n[19]=x,n[20]=C):C=n[20];let v;n[21]!==C?(v=s.jsx(St,{children:s.jsx("p",{children:C})}),n[21]=C,n[22]=v):v=n[22];let M;n[23]!==S||n[24]!==v?(M=s.jsxs(wt,{children:[S,v]}),n[23]=S,n[24]=v,n[25]=M):M=n[25];let R;n[26]!==o||n[27]!==r||n[28]!==l||n[29]!==y||n[30]!==f||n[31]!==p||n[32]!==m||n[33]!==a||n[34]!==x?(R=r?s.jsxs("div",{children:[o?null:s.jsx("div",{className:"border-b border-[var(--interactive-border)] px-4 py-2.5",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label font-medium text-foreground",children:x("header.services.remoteUpdate.title")}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:m?.available?x("header.services.remoteUpdate.available",{version:m.version||""}):f?x("header.services.remoteUpdate.checking"):p||x("header.services.remoteUpdate.upToDate")})]}),m?.available?s.jsx("button",{type:"button",className:"shrink-0 rounded-md bg-[var(--primary-base)] px-3 py-1.5 typography-ui-label font-medium text-[var(--primary-foreground)] hover:opacity-90",onClick:y,children:x("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx(Np,{embedded:!0,open:l,onOpenChange:Iy,onHostSwitched:()=>a(!1)})]}):null,n[26]=o,n[27]=r,n[28]=l,n[29]=y,n[30]=f,n[31]=p,n[32]=m,n[33]=a,n[34]=x,n[35]=R):R=n[35];let I;n[36]!==R?(I=s.jsx(Ls,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:R}),n[36]=R,n[37]=I):I=n[37];let B;return n[38]!==l||n[39]!==k||n[40]!==M||n[41]!==I?(B=s.jsxs($s,{open:l,onOpenChange:k,children:[M,I]}),n[38]=l,n[39]=k,n[40]=M,n[41]=I,n[42]=B):B=n[42],B}),Nn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},dc=t=>!t?.isOpen||!Array.isArray(t.tabs)||t.tabs.length===0?null:(t.tabs.find(n=>n.id===t.activeTabId)??t.tabs[t.tabs.length-1])?.mode??null,Dy=()=>{Rs("ui.header.render");const{t}=kt(),e=Pe(N=>N.isSidebarOpen),n=Pe(N=>N.openContextOverview),r=Pe(N=>N.closeContextPanel),i=Pe(N=>N.shortcutOverrides),o=Pe(N=>N.sessionTabsEnabled),l=nt(N=>N.getContextUsage),a=nt(N=>!!N.newSessionDraft?.open),d=nt(N=>N.currentSessionId),u=Ap(d??""),m=Pp(d??""),f=gf(d??""),p=js(dr(c.useCallback(N=>{if(!d)return null;const ye=[...N.activeSessions,...N.archivedSessions].find(at=>at.id===d);if(!ye)return null;const Le=ye;return{title:ye.title??null,directory:Le.directory??null,created:ye.time?.created??null,slug:Le.slug??null,parentId:ye.parentID??null}},[d]))),y=Gt(dr(N=>{if(!N.activeProjectId)return null;const ye=N.projects.find(Le=>Le.id===N.activeProjectId);return ye?{id:ye.id,path:ye.path,label:ye.label}:null})),x=c.useMemo(()=>{if(!y)return null;const N=y.label?.trim();if(N)return N;const ye=y.path.split(/[\\/]/).filter(Boolean);return ye[ye.length-1]??null},[y]),k=yr(N=>N.loadSettings),{isMobile:w}=Vn(),h=c.useRef(null),[g,j]=c.useState(()=>typeof window>"u"?!1:vn()),b=c.useMemo(()=>Qr(),[]),S=gu(),[C,v]=c.useState(!1),M=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:R,side:I}=ef(),B=c.useMemo(()=>{if(typeof window>"u")return null;const N=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof N=="number"&&Number.isFinite(N)&&N>0)return N;if(typeof navigator>"u")return null;const ye=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!ye)return null;const Le=Number.parseInt(ye[1],10),at=Number.parseInt(ye[2],10);return Number.isNaN(Le)?null:Le===10?at:Le},[]);ct.useEffect(()=>{typeof window>"u"||j(vn())},[]);const{context:O,output:T}=Dp(d),$=l(O,T),[_,Y]=c.useState(null),L=!d||u;ct.useEffect(()=>{if(!d){Y(N=>N===null?N:null);return}if($){Y(N=>Ip(N,$)?N:$);return}L&&Y(N=>N===null?N:null)},[$,d,L]);const[A,D]=c.useState(!1),[P,Z]=c.useState("Local"),[X,se]=c.useState(!0),[ce,re]=c.useState(!1),[ge,ae]=c.useState(null),[Ee,Se]=c.useState(!1),[me,ke]=c.useState(null),V=c.useMemo(()=>Wn(),[]),J=Pe(N=>N.workStatusPanelVisible),de=Pe(N=>N.workStatusPanelEnabled),we=Pe(N=>N.setWorkStatusPanelEnabled),G=Pe(N=>N.workStatusPanelFits),Ce=Pe(N=>N.workStatusOverlayOpen),Te=Pe(N=>N.setWorkStatusOverlayOpen),ne=de&&G||Ce,xe=c.useCallback(()=>{if(de&&!G){Te(!Ce);return}we(!de)},[Te,we,Ce,de,G]),U=!V&&!J&&!!_,z=c.useCallback(async()=>{if(!(typeof window>"u"||!g))try{if(ti()){Z("Local"),se(!0);return}se(!1);const N=await Wd(),ye=Qm(),Le=Xm([Jm(ye),...N.hosts]);if(Le.id===Zm){Z("Local"),se(!0);return}Z(Kd(Le.label.trim()||"Instance"))}catch{Z("Local"),se(!0)}},[g]);ct.useEffect(()=>(z(),Dr(()=>{z()})),[z]);const Q=c.useCallback(async()=>{if(X){ae(null),ke(null);return}Se(!0),ke(null);try{const N=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),ye=await ws(`/api/openchamber/update-check?${N.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!ye.ok)throw new Error(`Server responded with ${ye.status}`);const Le=await ye.json();ae({available:Le.available??!1,version:Le.version,currentVersion:Le.currentVersion??"unknown",body:Le.body,nextSuggestedCheckInSec:typeof Le.nextSuggestedCheckInSec=="number"?Le.nextSuggestedCheckInSec:void 0,packageManager:Le.packageManager,updateCommand:Le.updateCommand})}catch(N){ae(null),ke(N instanceof Error?N.message:t("header.services.remoteUpdate.error"))}finally{Se(!1)}},[X,t]);c.useEffect(()=>{ae(null),ke(null),re(!1)},[X,P]),c.useEffect(()=>{if(!g||X)return;const N=3e3,ye=3600*1e3;let Le=!1,at=null;const Tt=Dt=>{at=window.setTimeout(()=>{if(Le||typeof document<"u"&&document.visibilityState!=="visible"){Tt(ye);return}Q().finally(()=>{Le||Tt(ye)})},Dt)};return Tt(N),()=>{Le=!0,at!==null&&window.clearTimeout(at)}},[Q,X,P,g]);const ue=c.useCallback(()=>{if(ge?.available){re(!0);return}Q()},[Q,ge?.available]);Tp(),c.useEffect(()=>{k()},[k]);const le=d?p??null:null,W=c.useRef(null),[E,K]=c.useState(0);c.useEffect(()=>{if(!d){W.current&&(W.current=null,K(at=>at+1));return}if(le){W.current={sessionId:d,session:le,expiresAt:Date.now()+2e3};return}const N=W.current;if(!N||N.sessionId!==d)return;const ye=N.expiresAt-Date.now();if(ye<=0){W.current=null,K(at=>at+1);return}const Le=window.setTimeout(()=>{W.current?.sessionId===d&&(W.current=null),K(at=>at+1)},ye);return()=>{window.clearTimeout(Le)}},[d,le]);const te=(()=>{if(le)return le;if(!d)return null;const N=W.current;return N&&N.sessionId===d&&N.expiresAt>Date.now()?N.session:null})(),oe=nt(N=>d?N.worktreeMetadata.get(d)?.path??"":""),he=nt(N=>d?N.worktreeMetadata.get(d)?.branch?.trim()??null:null),ie=xu(N=>d?N.getAttachment(d):void 0),Fe=c.useMemo(()=>ie?Ep(ie,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,ie]),_e=c.useMemo(()=>ie?ie.legacy?"legacy":ie.degraded?"degraded":ie.worktreeStatus==="pending"?"pending":ie.worktreeStatus==="missing"?"missing":ie.worktreeStatus==="invalid"?"invalid":ie.attentionReason?"attention":null:null,[ie]),Ae=c.useMemo(()=>Nn(oe||""),[oe]),Me=c.useMemo(()=>{const N=typeof te?.directory=="string"?te.directory:"";return Nn(N||"")},[te?.directory]),q=$a(d??"",Me),Ne=nt(N=>N.newSessionDraft?.open?Nn(N.newSessionDraft.bootstrapPendingDirectory??N.newSessionDraft.directoryOverride??""):""),je=nt(N=>N.newSessionDraft.target),We=nt(N=>N.newSessionDraft.selectedProjectId),tt=nt(N=>N.currentSessionDirectory),it=os(N=>N.homeDirectory),rt=c.useMemo(()=>Ae||Me||Ne,[Ne,Me,Ae]),ot=Pe(c.useCallback(N=>{const ye=Nn(rt||"");return ye?dc(N.contextPanelByDirectory[ye]):null},[rt])),ft=nt(N=>{const ye=Nn(Ae||Me||"");if(!ye)return null;for(const Le of N.availableWorktreesByProject.values()){const Tt=Le.find(Dt=>Nn(Dt.path)===ye)?.branch?.trim();if(Tt)return Tt}return null}),Ct=Rp(rt||null)||he||ft,ht=a?je==="chat":Mp(Me||tt,it),be=!ht&&!J&&!!(x||Ct||!a&&_e),Je=c.useMemo(()=>{if(!d)return x??"OpenChamber";const N=te?.title?.trim();return N&&N.length>0?N:"Untitled Session"},[x,te?.title,d]),dt=bu(),Ke=nt(N=>N.updateSessionTitle),mt=nt(N=>N.archiveSessions),ee=nt(N=>N.deleteSessions),[fe,Ie]=c.useState(!1),[$e,H]=c.useState(!1),Be=c.useRef(null),[Ye,qe]=c.useState(""),[Xe,jt]=c.useState(null),Ve=c.useRef(null),pt=c.useCallback(()=>{d&&(qe(te?.title?.trim()||Je),Ie(!0))},[te?.title,d,Je]),Rt=c.useRef(pt);Rt.current=pt;const De=c.useCallback(N=>{N&&(N.focus(),N.select())},[]);c.useEffect(()=>{if(H(!1),jt(null),d&&Be.current===d){Be.current=null,Rt.current();return}Ie(!1),qe("")},[d]);const yt=c.useCallback(async()=>{if(!d)return;const N=Ye.trim();N&&N!==te?.title?.trim()&&await Ke(d,N),Ie(!1)},[te?.title,d,Ye,Ke]);c.useEffect(()=>{if(!fe)return;const N=ye=>{const Le=ye.target;(!Le||!Ve.current?.contains(Le))&&yt()};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[fe,yt]);const Pt=c.useCallback(N=>{N&&fr(N).then(ye=>{ze[ye.ok?"success":"error"](t(ye.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>ze.error(t("sessions.sidebar.session.copyId.error")))},[t]),Ue=c.useCallback(async()=>{if(!d||!rt){ze.error(t("sessions.sidebar.session.export.nothingToExport"));return}const N=await dt({sessionID:d,directory:rt}).catch(()=>null);if(!N){ze.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(N.length===0){ze.error(t("sessions.sidebar.session.export.nothingToExport"));return}const ye=yu(N,te?.title??null),Le=wu(te?.title??null);await vu(ye,Le)||Su(ye,Le),ze.success(t("sessions.sidebar.session.export.success"))},[te?.title,d,dt,rt,t]),He=ju(),ve=c.useMemo(()=>ku(He),[He]),Qe=c.useCallback(N=>{d&&hf({entry:N,t,session:{id:d,title:te?.title,directory:Me??rt},loadRecords:async()=>{if(!rt)return null;try{return await dt({sessionID:d,directory:rt})}catch{return null}},onLoadFailed:()=>ze.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[te?.title,d,dt,rt,Me,t]),Ge=c.useCallback(N=>ve.map(ye=>s.jsxs(N,{onClick:()=>Qe(ye),children:[s.jsx(no,{icon:ye.icon,iconSrc:ye.iconSrc,className:"mr-1 size-4"}),ye.action.label]},`${ye.guest.id}:${ye.action.id}`)),[ve,Qe]),Ze=m?.type==="busy"||m?.type==="retry",lt=c.useCallback(()=>{if(!d||!Me||Ze||f)return;const N=js.getState().activeSessions,ye=N.find(Tt=>Tt.id===d);if(!ye)return;const Le=[],at=[d];for(let Tt=0;Tt<at.length;Tt+=1){const Dt=at[Tt];for(const bt of N)bt.parentID===Dt&&(Le.push(bt),at.push(bt.id))}xa({kind:"quick",root:ye,descendants:Le,sourceDirectory:Me,messages:ga(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[d,Ze,f,Me,t]),Bt=c.useCallback(async()=>{if(!Xe)return;const N=Xe.action,ye=[Xe.sessionId,...Qd(Xe.sessionId,[],N==="delete")];if(jt(null),(N==="archive"?await mt(ye):await ee(ye)).failedIds.length>0){ze.error(t(N==="archive"?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error"));return}ze.success(t(N==="archive"?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"))},[mt,ee,Xe,t]),$t=Pe(N=>N.openGuestPageId),Wt=Ka(N=>N.guests.find(ye=>ye.id===$t)),Xt=Pe(N=>N.isScheduledTasksDialogOpen),Ft=Pe(N=>N.isArchivePageOpen),Jt=Pe(N=>N.isUsageStatsPageOpen),Lt=Pe(N=>N.worktreesPageProjectId),is=Pe(N=>N.isMultiRunLauncherOpen),_t=Gt(N=>{if(!Lt)return null;const ye=N.projects.find(Le=>Le.id===Lt);return ye?.label?.trim()||ye?.path?.split("/").pop()||null}),zt=c.useMemo(()=>Wt?{title:Wt.pageTitle??Wt.name,subtitle:null}:Xt?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:Ft?{title:t("sessions.archivePage.title"),subtitle:null}:Jt?{title:t("usageStats.title"),subtitle:null}:Lt?{title:t("sessions.worktreesPage.title",{project:_t??""}),subtitle:null}:is?{title:t("sessions.sidebar.header.actions.newMultiRun"),subtitle:null}:null,[Wt,Ft,is,Xt,Jt,t,Lt,_t]),Nt=c.useMemo(()=>Nn(rt||y?.path||""),[y?.path,rt]),At=ny(),us=Va(N=>N.planModeEnabled),xs=nt(N=>N.isSessionPlanAvailable),qs=us&&d?xs(d):!1,Zt=c.useRef("");c.useEffect(()=>{if(!us||!d)return;const N=`${d||"none"}:${Me||"none"}:${te?.created||0}:${te?.slug||"none"}`;Zt.current!==N&&(Zt.current=N)},[us,qs,te?.slug,te?.created,d,Me]);const nn=c.useCallback(()=>{zn("desktop_open_draft_mini_chat_window",{directory:ht?"":Ne,projectId:ht?null:We,apiBaseUrl:En(),clientToken:Xr()}).catch(N=>{console.warn("[header] failed to open draft mini chat window",N)})},[Ne,We,ht]),Cn=c.useCallback(()=>{if(a){nn();return}d&&zn("desktop_open_session_mini_chat_window",{sessionId:d,directory:Me||Nn(tt||"")||Ae,apiBaseUrl:En(),clientToken:Xr()}).catch(N=>{console.warn("[header] failed to open session mini chat window",N)})},[d,nn,a,tt,Me,Ae]),rn=c.useCallback(()=>{const N=Nn(rt||"");if(!N)return;const ye=Pe.getState().contextPanelByDirectory[N];if(dc(ye)==="context"){r(N);return}n(N)},[r,n,rt]),hn=ot==="context",on=Ho,Ts=c.useMemo(()=>g&&M&&!C?"88px":S?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!g||R)&&!V?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[g,C,M,S,V,R]);ct.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",Ts)},[Ts]);const zs=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",Ws=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";ct.useEffect(()=>{if(!g||!M){v(!1);return}let N=!1;const ye=async()=>{try{const at=await zn("desktop_is_window_fullscreen");N||v(at===!0)}catch{N||v(!1)}},Le=()=>{ye()};return ye(),window.addEventListener("openchamber:window-resized",Le),()=>{N=!0,window.removeEventListener("openchamber:window-resized",Le)}},[g,M]);const an=c.useMemo(()=>!g||!M||B===null?"":B>=26?"h-12":B<=15?"h-14":"",[g,M,B]),as=c.useMemo(()=>{if(!(g&&!R||V)&&!(R&&I==="right"))return{paddingRight:"calc(0.75rem + var(--oc-wco-right-inset, 0px))",minHeight:"max(3rem, var(--oc-wco-titlebar-height, 0px))",height:"max(3rem, var(--oc-wco-titlebar-height, 0px))"}},[g,V,R,I]),ps=c.useCallback(()=>{if(typeof document>"u")return;const N=h.current?.getBoundingClientRect().height;N&&document.documentElement.style.setProperty("--oc-header-height",`${N}px`)},[]);ct.useEffect(()=>{if(typeof window>"u")return;ps();const N=h.current;if(!N||typeof ResizeObserver>"u")return()=>{};let ye=0;const Le=()=>{ye||(ye=requestAnimationFrame(()=>{ye=0,ps()}))},at=new ResizeObserver(Le);return at.observe(N),window.addEventListener("resize",Le),window.addEventListener("orientationchange",Le),()=>{ye&&cancelAnimationFrame(ye),at.disconnect(),window.removeEventListener("resize",Le),window.removeEventListener("orientationchange",Le)}},[ps]),ct.useEffect(()=>{ps()},[ps,w,an]);const Ys=c.useCallback(async N=>{const ye=N.target;ye.closest(".app-region-no-drag")||ye.closest("button, a, input, select, textarea")||N.button===0&&g&&await eh()},[g]),fs=c.useCallback(N=>ir(ro(N,i)),[i]);Op({rename_current_session:()=>{if(!d||w)return!1;pt()},toggle_services_menu:()=>{if(A){D(!1);return}D(!0),z()}});const ln=s.jsxs(s.Fragment,{children:[At?s.jsx(ty,{projectRef:At.projectRef,directory:At.directory,className:"mr-2"}):null,s.jsx(Db,{directory:Nt,className:"mr-1"}),g?s.jsx(Py,{isDesktopApp:g,currentInstanceLabel:P,currentInstanceIsLocal:X,isDesktopServicesOpen:A,setIsDesktopServicesOpen:D,refreshCurrentInstanceLabel:z,shortcutLabel:fs,remoteUpdateInfo:ge,remoteUpdateChecking:Ee,remoteUpdateError:me,onOpenRemoteUpdate:ue}):null]}),pn=b&&(a||!!d),gn=c.useCallback(({session:N,open:ye,isActive:Le,select:at,closeOtherTabs:Tt,components:Dt})=>{const{Item:bt,Separator:Kt}=Dt,ls=Le&&!V&&!ht&&te&&!te.parentId;return s.jsxs(s.Fragment,{children:[s.jsxs(bt,{onClick:()=>{Le||at(),Be.current=N.id},children:[s.jsx(F,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(pa,{sessionID:N.id,directory:N.directory,open:ye,Item:bt}),s.jsxs(bt,{onClick:()=>Pt(N.id),children:[s.jsx(F,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(Kt,{}),Le?s.jsxs(bt,{onClick:()=>{Ue()},children:[s.jsx(F,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}):null,Le?Ge(bt):null,ls?s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(bt,{disabled:!Me||Ze||f,onClick:lt,className:"w-full",children:[s.jsx(F,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(St,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Ze?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(Kt,{}),s.jsxs(bt,{onClick:Tt,children:[s.jsx(F,{name:"close-circle",className:"mr-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]}),s.jsx(Kt,{}),s.jsxs(bt,{onClick:()=>jt({action:"archive",sessionId:N.id}),children:[s.jsx(F,{name:"inbox-archive",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(bt,{className:"text-destructive focus:text-destructive",onClick:()=>jt({action:"delete",sessionId:N.id}),children:[s.jsx(F,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})},[Pt,te,Ue,ht,Ze,f,V,lt,Ge,Me,t]),xn=()=>s.jsxs("div",{onMouseDown:Ys,className:Re("app-region-drag relative flex h-12 select-none items-center",R&&I==="right"?"pr-0":"pr-3",an),style:as,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:zs}}),s.jsx("div",{"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:Ws}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[zt?s.jsxs(s.Fragment,{children:[s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx(ut,{variant:"ghost",size:"icon",className:"app-region-no-drag mr-1 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>Pe.getState().closeMainSurfaces(),children:s.jsx(F,{name:"arrow-left",className:"size-[18px]"})})}),s.jsx(St,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),s.jsxs("div",{className:"mr-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-left",children:[s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:zt.title}),zt.subtitle?s.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:zt.subtitle}):null]})]}):V||!o?s.jsxs("div",{className:"app-region-no-drag mr-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-left",children:[q?s.jsx(F,{name:"loader-4",className:"mr-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,e?null:s.jsx(ec,{align:"start",children:s.jsx("button",{type:"button",className:on,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(F,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[fe?s.jsxs("form",{ref:Ve,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:N=>N.stopPropagation(),onSubmit:N=>{N.preventDefault(),yt()},children:[s.jsx("input",{ref:De,value:Ye,onChange:N=>qe(N.target.value),onKeyDown:N=>Qi(N,()=>Ie(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent typography-ui-label text-[14px] font-normal leading-tight outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(F,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Ie(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(F,{name:"close",className:"size-4"})})]}):a?null:s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Je}),be?s.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[x?s.jsx("span",{className:"truncate",children:x}):null,Ct?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(F,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:Ct})]}):null,!a&&_e?s.jsxs("span",{className:Re("inline-flex min-w-0 items-center gap-0.5",_e==="attention"||_e==="invalid"||_e==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[s.jsx(F,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:Fe})]}):null]}):null]}),s.jsx("div",{className:Re("flex h-[18px] shrink-0 items-center justify-center",be?"self-start":"self-center"),children:d&&!a&&!fe?s.jsxs($s,{open:$e,onOpenChange:H,onOpenChangeComplete:N=>{!N&&Be.current&&Be.current===d&&(Be.current=null,pt())},children:[s.jsx(_s,{asChild:!0,children:s.jsx(ut,{variant:"ghost",size:"xs",className:"h-[18px] w-6 px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.sessionActions.openAria"),children:s.jsx(F,{name:"more",className:"size-4"})})}),s.jsxs(Ls,{align:"end",className:"min-w-[190px]",children:[s.jsxs(Ht,{onClick:()=>{Be.current=d},children:[s.jsx(F,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(pa,{sessionID:d,directory:Me,open:$e,Item:Ht}),s.jsxs(Ht,{onClick:()=>d&&Pt(d),children:[s.jsx(F,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(As,{}),s.jsxs(Ht,{onClick:()=>{Ue()},children:[s.jsx(F,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}),Ge(Ht),!V&&!ht&&te&&!te.parentId?s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Ht,{disabled:!Me||Ze||f,onClick:lt,className:"w-full",children:[s.jsx(F,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(St,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Ze?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(As,{}),s.jsxs(Ht,{onClick:()=>{d&&jt({action:"archive",sessionId:d})},children:[s.jsx(F,{name:"inbox-archive",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Ht,{className:"text-destructive focus:text-destructive",onClick:()=>{d&&jt({action:"delete",sessionId:d})},children:[s.jsx(F,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})]}):null})]}):s.jsxs("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center gap-0.5 text-left",children:[e?null:s.jsx(ec,{align:"start",children:s.jsx("button",{type:"button",className:on,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(F,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsx(ly,{renderMenu:gn,suppressActiveTabControls:fe,onMenuOpenChangeComplete:N=>{!N&&Be.current&&Be.current===d&&(Be.current=null,pt())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:fe?s.jsxs("form",{ref:Ve,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:N=>N.stopPropagation(),onSubmit:N=>{N.preventDefault(),yt()},children:[s.jsx("input",{ref:De,value:Ye,onChange:N=>qe(N.target.value),onKeyDown:N=>Qi(N,()=>Ie(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent text-[13px] font-medium leading-4 outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(F,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Ie(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(F,{name:"close",className:"size-4"})})]}):s.jsx("span",{className:"block overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4 text-foreground max-w-full",children:a?t("sessions.switcher.draftTitle"):Je})})})]}),zt||V||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[U&&_?s.jsx(qx,{reading:Yx(_),contextLimit:_.contextLimit,outputLimit:_.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:rn,pressed:hn,className:pn?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,s.jsx(Ay,{visible:pn,title:t(a?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(a?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:Cn,className:Re(on,"mr-1"),Icon:"picture-in-picture-2"}),V?null:s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":ne,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:xe,className:Re(Ho,"mr-1",ne?"text-foreground":"text-muted-foreground/50"),children:s.jsx(F,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),s.jsx(St,{side:"bottom",children:t(de&&!G?Ce?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":de?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),ln,s.jsx(tf,{visible:R&&I==="right",position:"right"})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:h,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:xn()}),s.jsx(Ds,{open:Xe!==null,onOpenChange:N=>{N||jt(null)},children:s.jsxs(Is,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(sn,{children:[s.jsx(Hs,{children:Xe?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),s.jsx(Gs,{children:Xe?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:Je}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:Je})})]}),s.jsxs(Un,{children:[s.jsx(ut,{variant:"outline",size:"sm",onClick:()=>jt(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ut,{variant:"destructive",size:"sm",onClick:()=>{Bt()},children:Xe?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),s.jsx(Xd,{open:ce,onOpenChange:re,info:ge,downloading:!1,downloaded:!1,progress:null,error:me,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function Iy(){}const uc=280,fc=264,mc=500,Ty=({isOpen:t,isMobile:e,children:n,className:r,topBar:i})=>{const{t:o}=kt(),l=Pe(v=>v.sidebarWidth),a=Pe(v=>v.setSidebarWidth),[d,u]=c.useState(!1),m=c.useRef(0),f=c.useRef(l||uc),p=c.useRef(null),y=c.useRef(null),x=c.useRef(null),k=c.useCallback(v=>Math.min(mc,Math.max(fc,v)),[]),w=c.useCallback(v=>{const M=x.current;M&&(M.style.width=`${v}px`,M.style.minWidth=`${v}px`,M.style.maxWidth=`${v}px`,M.style.setProperty("--oc-left-sidebar-width",`${v}px`))},[]);if(c.useEffect(()=>{e&&d&&u(!1)},[e,d]),c.useEffect(()=>{d||(p.current=null,y.current=null)},[d]),e)return null;const h=Math.min(mc,Math.max(fc,l||uc)),g=t?h:0,j=v=>{if(t){try{v.currentTarget.setPointerCapture(v.pointerId)}catch{}y.current=v.pointerId,u(!0),m.current=v.clientX,f.current=g,p.current=g,w(g),v.preventDefault()}},b=v=>{if(e||!d||y.current!==v.pointerId)return;const M=v.clientX-m.current,R=k(f.current+M);p.current!==R&&(p.current=R,w(R))},S=v=>{if(y.current!==v.pointerId||e)return;try{v.currentTarget.releasePointerCapture(v.pointerId)}catch{}const M=k(p.current??g);y.current=null,p.current=null,u(!1),a(M)},C=d?p.current??g:g;return s.jsxs("aside",{ref:x,className:Re("relative flex h-full overflow-hidden border-r border-border will-change-[width] motion-reduce:transition-none","bg-sidebar",!t&&"border-r-0",r),style:{width:`${C}px`,minWidth:`${C}px`,maxWidth:`${C}px`,"--oc-left-sidebar-width":`${d?C:h}px`,overflowX:"clip",transitionProperty:d?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||g===0,children:[t&&s.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&s.jsx("div",{className:Re("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",d&&"bg-[var(--interactive-border)]"),onPointerDown:j,onPointerMove:b,onPointerUp:S,onPointerCancel:S,role:"separator","aria-orientation":"vertical","aria-label":o("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:Re("relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[i,s.jsx(On,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(Ns,{children:n})})]})]})},Ey=()=>{const t=et.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={height:"var(--oc-header-height, 3rem)"},t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-left-inset, 0.75rem)"}}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[n,s.jsx("div",{className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),s.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},mo="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:bg-interactive-hover transition-colors",Ry=()=>{const t=et.c(37),{t:e}=kt(),n=Pe(My),r=Pe(Oy),i=Pe(By),o=c.useRef(null),l=ir(ro("toggle_sidebar",i)),a=Fy,{usesFramelessChrome:d,side:u}=ef(),m=Ly;let f,p;t[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{if(typeof document>"u")return;const _=o.current;if(!_)return;const Y=()=>{const A=Math.max(_.getBoundingClientRect().width,_.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(A)}px`)};if(Y(),typeof ResizeObserver>"u")return;const L=new ResizeObserver(Y);return L.observe(_),()=>{L.disconnect()}},p=[],t[0]=f,t[1]=p):(f=t[0],p=t[1]),c.useEffect(f,p);const y="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2";let x;t[2]===Symbol.for("react.memo_cache_sentinel")?(x={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)"},t[2]=x):x=t[2];const k="flex items-center gap-2";let w;t[3]!==d||t[4]!==u?(w=d&&u==="left"?s.jsx(tf,{visible:!0,position:"left"}):null,t[3]=d,t[4]=u,t[5]=w):w=t[5];let h;t[6]!==e||t[7]!==d?(h=d?s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:m,"aria-label":e("header.actions.openAppMenuAria"),className:Re(mo,"shrink-0"),children:s.jsx(F,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),s.jsx(St,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[6]=e,t[7]=d,t[8]=h):h=t[8];const g=wt;let j;t[9]!==e?(j=e("header.actions.openSessionsAria"),t[9]=e,t[10]=j):j=t[10];let b,S;t[11]===Symbol.for("react.memo_cache_sentinel")?(b=Re(mo,"shrink-0"),S=s.jsx(F,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[11]=b,t[12]=S):(b=t[11],S=t[12]);let C;t[13]!==j||t[14]!==n?(C=s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":j,className:b,children:S})}),t[13]=j,t[14]=n,t[15]=C):C=t[15];const v=St,M=e("header.actions.openSessionsWithShortcut",{shortcut:l});let R;t[16]!==M?(R=s.jsx("p",{children:M}),t[16]=M,t[17]=R):R=t[17];let I;t[18]!==v||t[19]!==R?(I=s.jsx(v,{children:R}),t[18]=v,t[19]=R,t[20]=I):I=t[20];let B;t[21]!==g||t[22]!==C||t[23]!==I?(B=s.jsxs(g,{children:[C,I]}),t[21]=g,t[22]=C,t[23]=I,t[24]=B):B=t[24];let O;t[25]!==a||t[26]!==r||t[27]!==e?(O=r?s.jsxs("button",{type:"button",onClick:a,className:Re(mo,"-ml-1 w-auto shrink-0 px-2 font-normal"),children:[s.jsx(F,{name:"chat-new",className:"h-[18px] w-[18px]"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:Re(mo,"-ml-1 shrink-0"),children:s.jsx(F,{name:"chat-new",className:"h-[18px] w-[18px]"})})}),s.jsx(St,{children:s.jsx("p",{children:e("sessions.sidebar.header.actions.newSession")})})]}),t[25]=a,t[26]=r,t[27]=e,t[28]=O):O=t[28];let T;t[29]!==B||t[30]!==O||t[31]!==w||t[32]!==h?(T=s.jsxs("div",{ref:o,className:k,children:[w,h,B,O]}),t[29]=B,t[30]=O,t[31]=w,t[32]=h,t[33]=T):T=t[33];let $;return t[34]!==T||t[35]!==x?($=s.jsx("div",{className:y,style:x,children:T}),t[34]=T,t[35]=x,t[36]=$):$=t[36],$};function My(t){return t.toggleSidebar}function Oy(t){return t.isSidebarOpen}function By(t){return t.shortcutOverrides}function Fy(){Pe.getState().closeMainSurfaces(),nt.getState().openNewSessionDraft()}function _y(t){console.warn("[titlebar] failed to open app menu",t)}function Ly(t){const e=t.currentTarget.getBoundingClientRect();zn("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch(_y)}function bf(t){const e=et.c(5),{className:n}=t,i=`relative inline-block overflow-hidden rounded-[2px] ${n===void 0?"h-5 w-5":n}`;let o,l,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx("span",{className:"absolute left-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-error)]/25"}),l=s.jsx("span",{className:"absolute right-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-success)]/25"}),a=s.jsx(F,{name:"layout-column",className:"absolute inset-0 h-full w-full"}),e[0]=o,e[1]=l,e[2]=a):(o=e[0],l=e[1],a=e[2]);let d;return e[3]!==i?(d=s.jsxs("span",{"aria-hidden":"true",className:i,children:[o,l,a]}),e[3]=i,e[4]=d):d=e[4],d}const hc=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function $y(t,e,n){const r=et.c(5),[i,o]=c.useState();let l,a;return r[0]!==n||r[1]!==t||r[2]!==e?(l=()=>{if(e){o(void 0);return}if(!t){o(void 0);return}o(void 0);let d=!1;return(async()=>{const[u,m]=await Promise.all([Bp(t),Fp(t)]).catch(zy);if(d)return;const f=hc(u),p=hc(m);if(!f||!p||p===f)return;const y=n||"",x=p.split("/").filter(Boolean).pop()||p;o({source:"sdk",path:p,projectDirectory:f,branch:y,label:y||x,name:x,worktreeRoot:p,worktreeStatus:"ready",headState:y?"branch":"unborn",worktreeSource:"existing"})})(),()=>{d=!0}},a=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=l,r[4]=a):(l=r[3],a=r[4]),c.useEffect(l,a),e??i}function zy(){return["",""]}const pc="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",Wy=async(t,e)=>{if(t)return t.authActivate(e);const n=await ws("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:e})}),r=await n.json().catch(()=>null);if(!n.ok||!r)throw new Error(r?.error||n.statusText);return r},gc=({className:t})=>{const{t:e}=kt(),{github:n}=kn(),r=Rn(y=>y.status),i=Rn(y=>y.setStatus),[o,l]=c.useState(!1),a=c.useCallback(async y=>{if(!(!y||o)){l(!0);try{i(await Wy(n,y))}catch(x){console.error("Failed to switch GitHub account:",x)}finally{l(!1)}}},[n,o,i]);if(!r?.connected)return null;const d=r.user?.login??null,u=r.user?.avatarUrl??null,m=r.accounts??[],f=d?e("header.github.connectedWithLogin",{login:d}):e("header.github.connected"),p=u?s.jsx("img",{src:u,alt:d?e("header.github.avatarWithLogin",{login:d}):e("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(F,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"});return m.length<=1?s.jsx("div",{className:Re(pc,t),title:f,children:p}):s.jsxs($s,{children:[s.jsx(_s,{asChild:!0,children:s.jsx("button",{type:"button",className:Re(pc,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:f,disabled:o,children:p})}),s.jsxs(Ls,{align:"end",className:"w-64",children:[s.jsx(xr,{className:"typography-ui-header font-semibold text-foreground",children:e("header.github.accountsTitle")}),s.jsx(As,{}),m.map(y=>{const x=y.user,k=!!y.current,w=y.source==="gh-cli"?e("header.github.accountSource.cli"):e("header.github.accountSource.oauth");return s.jsxs(Ht,{className:"gap-2",disabled:o,onSelect:()=>{k||a(y.id)},children:[x?.avatarUrl?s.jsx("img",{src:x.avatarUrl,alt:x.login?e("header.github.avatarWithLogin",{login:x.login}):e("header.github.avatar"),className:"h-6 w-6 rounded-full border border-border/60 bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted",children:s.jsx(F,{name:"github-fill",className:"h-3 w-3 text-muted-foreground"})}),s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:x?.name?.trim()||x?.login||"GitHub"}),x?.login?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:x.login}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:w})]}):null]}),k?s.jsx(F,{name:"check",className:"h-4 w-4 text-primary"}):null]},y.id)})]})]})};class bi extends Error{code;model;requiredChars;availableChars;constructor(e,n={}){super(e),this.name="WalkthroughError",this.code=n.code,this.model=n.model,this.requiredChars=n.requiredChars,this.availableChars=n.availableChars}}const yi="/api/walkthrough",yf=t=>/^application\/(?:[\w.+-]+\+)?json\b/i.test(t.headers.get("content-type")??""),wf=()=>new bi("This OpenChamber server has no walkthrough API",{code:"server-unsupported"}),Ky=t=>!yf(t)&&(t.ok||t.status===404),ol=async(t,e)=>{if(Ky(t))throw wf();const n=await t.json().catch(()=>null);throw new bi(typeof n?.error=="string"?n.error:e,{code:typeof n?.code=="string"?n.code:void 0,model:n?.model??void 0,requiredChars:typeof n?.requiredChars=="number"?n.requiredChars:void 0,availableChars:typeof n?.availableChars=="number"?n.availableChars:void 0})},vf=async t=>{if(!yf(t))throw wf();try{return await t.json()}catch{throw new bi("The server returned a malformed walkthrough response")}};async function Vy(t,e,n={}){const r=await ws(yi,{query:{directory:t,source:JSON.stringify(e),...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}},signal:n.signal});return r.ok?vf(r):ol(r,"Failed to load walkthrough")}async function Uy(t,e,n={}){const r=await ws(`${yi}/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e,force:n.force===!0,...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}}),signal:n.signal});return r.ok?vf(r):ol(r,"Failed to generate walkthrough")}async function Hy(t,e){const n=await ws(`${yi}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e})});n.ok||await ol(n,"Failed to cancel walkthrough generation")}async function Gy(t,e,n){const r=await ws(`${yi}/progress`,{query:{directory:t,source:JSON.stringify(e)},signal:n});if(!r.ok)return null;const i=await r.json().catch(()=>null);return typeof i?.stage=="string"?i.stage:null}const Or={status:"idle",stage:null,result:null,readiness:null,error:null},qy=t=>t.kind==="working-tree"?`working-tree:${t.scope}`:t.kind==="branch"?`branch:${t.baseRef}...${t.headRef}`:t.kind==="commit"?`commit:${t.hash}`:t.sourceRepo?`pr:${t.sourceRepo.owner}/${t.sourceRepo.repo}:${t.number}`:`pr:${t.number}`,Bn=(t,e)=>`${Qt()}\0${t}\0${qy(e)}`,xc=t=>t instanceof bi?{message:t.message,code:t.code,model:t.model,requiredChars:t.requiredChars,availableChars:t.availableChars}:{message:t instanceof Error?t.message:"Something went wrong"},Js=new Map,Br=new Map,Yy=1e3,Qy=oo()(pb((t,e)=>({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{},selectLanguage:(n,r,i)=>{const o=Bn(n,r);t(l=>{const a={...l.selectedLanguage};return i?a[o]=i:delete a[o],{selectedLanguage:a}})},getSelectedLanguage:(n,r)=>e().selectedLanguage[Bn(n,r)],selectModel:(n,r,i)=>{const o=Bn(n,r);t(l=>{const a={...l.selectedModel};return i?a[o]=i:delete a[o],{selectedModel:a}})},getSelectedModel:(n,r)=>e().selectedModel[Bn(n,r)],requestSource:(n,r)=>{t(i=>({requestedSource:{...i.requestedSource,[n]:r}}))},clearRequestedSource:n=>{t(r=>{if(!r.requestedSource[n])return r;const i={...r.requestedSource};return delete i[n],{requestedSource:i}})},getEntry:(n,r)=>e().entries[Bn(n,r)]??Or,load:async(n,r,i={})=>{if(!n)return;const o=Bn(n,r);if(e().entries[o]?.status==="generating")return;Js.get(o)?.abort();const a=new AbortController;Js.set(o,a),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Or,status:"loading",error:null}}}));try{const d=await Vy(n,r,{model:e().selectedModel[o],language:i.language,signal:a.signal});if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:d.readiness??null,error:null}}})),d.generating&&e().generate(n,r,{language:i.language})}catch(d){if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Or,status:"error",stage:null,error:xc(d)}}}))}finally{Js.get(o)===a&&Js.delete(o)}},generate:async(n,r,i={})=>{if(!n)return;const o=Bn(n,r);Js.get(o)?.abort();const l=new AbortController;Js.set(o,l),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Or,status:"generating",stage:"collecting",error:null}}}));const a=()=>{const d=Br.get(o);d!==void 0&&(clearInterval(d),Br.delete(o))};a(),Br.set(o,setInterval(()=>{Gy(n,r).then(d=>{!d||l.signal.aborted||t(u=>{const m=u.entries[o];return!m||m.status!=="generating"||m.stage===d?u:{entries:{...u.entries,[o]:{...m,stage:d}}}})}).catch(()=>{})},Yy));try{const d=await Uy(n,r,{force:i.force,model:e().selectedModel[o],language:i.language,signal:l.signal});if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:u.entries[o]?.readiness??null,error:null}}}))}catch(d){if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Or,status:"error",stage:null,error:xc(d)}}}))}finally{a(),Js.get(o)===l&&Js.delete(o)}},cancel:(n,r)=>{const i=Bn(n,r);Hy(n,r).catch(()=>{}),Js.get(i)?.abort(),Js.delete(i),t(o=>{const l=o.entries[i];return l?{entries:{...o.entries,[i]:{...l,status:l.result?"ready":"idle",stage:null,error:null}}}:o})},reset:()=>{for(const n of Js.values())n.abort();Js.clear();for(const n of Br.values())clearInterval(n);Br.clear(),t({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{}})}}),{name:"walkthrough-store"})),Xy="border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)] hover:text-[var(--status-info)]",Jy=3e4,bc=20,Sf=(t,e)=>JSON.stringify([Qt(),t,e]),Zy=t=>{try{const e=JSON.parse(t);if(!Array.isArray(e)||e.length!==3)return null;const[n,r,i]=e;return typeof n!="string"||typeof r!="string"||typeof i!="number"?null:{runtimeKey:n,directory:r,number:i}}catch{return null}},yc=()=>({result:null,hasCheckDetails:!1,fetchedAt:0,isLoading:!1,error:null}),ho=new Map,e1=t=>{const e=Object.entries(t);return e.length<=bc?t:Object.fromEntries(e.sort(([,n],[,r])=>r.fetchedAt-n.fetchedAt).slice(0,bc))},wc=oo()((t,e)=>({entries:{},ensure:async(n,r,i,o)=>{const l=Sf(r,i),a=o?.includeCheckDetails??!1,d=e().entries[l],u=d&&d.result&&Date.now()-d.fetchedAt<Jy&&(d.hasCheckDetails||!a);if(!o?.force&&u)return d.result;const m=`${l}::${a?"details":"plain"}`,p=ho.get(`${l}::details`)??(a?null:ho.get(m));if(p&&!o?.force)return p;const y=(async()=>{t(x=>({entries:{...x.entries,[l]:{...x.entries[l]??yc(),isLoading:!0,error:null}}}));try{const x=await n.prContext(r,i,{includeDiff:!1,includeCheckDetails:a,sourceRepo:o?.sourceRepo??null});return t(k=>({entries:e1({...k.entries,[l]:{result:x,hasCheckDetails:a,fetchedAt:Date.now(),isLoading:!1,error:null}})})),x}catch(x){const k=x instanceof Error?x.message:"Failed to load pull request context";return t(w=>({entries:{...w.entries,[l]:{...w.entries[l]??yc(),isLoading:!1,error:k}}})),null}finally{ho.delete(m)}})();return ho.set(m,y),y},invalidate:(n,r)=>{t(i=>{const o={};for(const[l,a]of Object.entries(i.entries)){const d=Zy(l);d&&d.directory===n&&(r==null||d.number===r)||(o[l]=a)}return{entries:o}})}})),t1=t=>{const e={success:0,failure:0,pending:0,inProgress:0,queued:0};let n;for(const o of t){if(o.status==="in_progress"){e.pending+=1,e.inProgress+=1,o.startedAt&&(!n||o.startedAt<n)&&(n=o.startedAt);continue}if(o.status==="queued"){e.pending+=1,e.queued+=1;continue}const l=typeof o.conclusion=="string"?o.conclusion.toLowerCase():"";if(!l){e.pending+=1;continue}l==="success"||l==="neutral"||l==="skipped"?e.success+=1:e.failure+=1}const r=e.success+e.failure+e.pending;return{state:e.failure>0?"failure":e.pending>0?"pending":r>0?"success":"unknown",total:r,...e,...n?{startedAt:n}:{}}},s1=35e3,Oi=(t,e,n)=>{if(!t)return null;const r=Date.parse(t);if(!Number.isFinite(r))return null;const i=e?Date.parse(e):n??Date.now();if(!Number.isFinite(i)||i<=r)return null;const o=Math.floor((i-r)/6e4);if(o<1)return"<1m";if(o<60)return`${o}m`;const l=Math.floor(o/60),a=o%60;return a>0?`${l}h ${a}m`:`${l}h`},Bi=t=>{const e=typeof t=="string"?t.toLowerCase():"";return!!e&&!["success","neutral","skipped"].includes(e)},vc=t=>{switch(t){case"success":return"bg-[color:var(--status-success)]";case"failure":return"bg-[color:var(--status-error)]";case"pending":return"bg-[color:var(--status-warning)]";default:return"bg-muted-foreground/40"}},n1=t=>{const e=t?.pr;if(!e)return null;if(e.state==="merged")return"merged";if(e.state==="closed")return"closed";if(e.draft)return"draft";const n=t?.checks?.state==="failure",r=typeof e.mergeableState=="string"?e.mergeableState:"",i=e.mergeable===!1||r==="blocked"||r==="dirty";return n||i?"blocked":"open"},r1=[2e3,5e3],o1=600,Sc=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),_n=t=>{let e=t.trim();return e?(e.startsWith("refs/heads/")&&(e=e.slice(11)),e.startsWith("heads/")&&(e=e.slice(6)),e.startsWith("remotes/")&&(e=e.slice(8)),e):""},i1=(t,e)=>{const n=_n(t);if(!n||n.includes("->"))return"";if(e){const i=`${e}/`;return n.startsWith(i)?n.slice(i.length).trim():""}const r=n.indexOf("/");return r>0?n.slice(r+1).trim():n},a1=(t,e)=>`${t}::${e}`,il=t=>{const e=String(t||"").trim();if(!e)return"";const n=e.indexOf("/");return n<=0?"":e.slice(0,n).trim()},Fi=(t,e)=>{if(t.length===0)return null;const n=String(e.selectedRemoteName||"").trim();if(n){const o=t.find(l=>l.name===n);if(o)return o}const r=il(e.trackingBranch);if(r){const o=r==="origin"?t.find(a=>a.name==="upstream"):null;if(o)return o;const l=t.find(a=>a.name===r);if(l)return l}const i=t.find(o=>o.name==="origin");return i||(t[0]??null)},l1=t=>t.startsWith("pr-"),c1=(t,e)=>{const n=il(e),r=new Map(t.map(l=>[l.name,l])),i=[],o=l=>{l&&(i.some(a=>a.name===l.name)||i.push(l))};return n&&o(r.get(n)),o(r.get("upstream")),o(r.get("origin")),t.filter(l=>!l1(l.name)).forEach(l=>o(l)),t.forEach(l=>o(l)),i},Fr=new Map,po=so;function d1(t,e){const[n,r]=c.useState(null),[i,o]=c.useState([]),l=c.useRef(null);return c.useEffect(()=>{r(null),o([])},[t]),c.useEffect(()=>{if(!t||!e?.repoUpstream||l.current===t)return;l.current=t;let a=!1;return(async()=>{try{const d=await e.repoUpstream(t);if(a||!d?.isFork||!d.upstream||(r(d.upstream),!e.repoBranches))return;try{const u=await e.repoBranches(d.upstream.owner,d.upstream.repo);a||o(u)}catch{}}catch{}})(),()=>{a=!0}},[t,e]),{detectedUpstream:n,upstreamBranches:i}}const u1=({directory:t,branch:e,baseBranch:n,trackingBranch:r,remotes:i=[],remoteBranches:o=[],onGeneratedDescription:l})=>{const{t:a}=kt(),d=Pe(N=>N.timeFormatPreference),{github:u}=kn(),m=Rn(N=>N.status),f=Rn(N=>N.hasChecked),p=Pe(N=>N.setSettingsDialogOpen),y=Pe(N=>N.setSettingsPage),x=nt(N=>N.currentSessionId),k=nt(N=>!!N.newSessionDraft?.open),{isMobile:w,hasTouchInput:h,screenWidth:g}=Vn(),j=Pe(N=>N.openContextSurface),b=Qy(N=>N.requestSource),S=!w&&g>=768&&!Wn(),C=c.useCallback(()=>{y("integrations"),p(!0)},[p,y]),v=c.useMemo(()=>a1(t,e),[t,e]),M=c.useMemo(()=>Fr.get(v)??null,[v]),R=Vs(N=>N.ensureEntry),I=Vs(N=>N.setParams),B=Vs(N=>N.startWatching),O=Vs(N=>N.stopWatching),T=Vs(N=>N.refresh),$=Vs(N=>N.updateStatus),[_,Y]=c.useState(()=>M?.title??Sc(e)),[L,A]=c.useState(()=>M?.body??""),[D,P]=c.useState(()=>M?.draft??!1),[Z,X]=c.useState(()=>M?.additionalContext??""),[se,ce]=c.useState(()=>{const N=typeof M?.targetBaseBranch=="string"?_n(M.targetBaseBranch):"";return N||_n(n)}),[re,ge]=c.useState("squash"),[ae,Ee]=c.useState(!1),[Se,me]=c.useState(!1),[ke,V]=c.useState(!1),[J,de]=c.useState(!1),[we,G]=c.useState(!1),[Ce,Te]=c.useState(!1),[pe,ne]=c.useState(null),[xe,U]=c.useState(""),[z,Q]=c.useState(""),[ue,le]=c.useState(!1),[W,E]=c.useState(!1),[K,te]=c.useState(()=>Fi(i,{selectedRemoteName:M?.selectedRemoteName,trackingBranch:r})),[oe,he]=c.useState(!1),{detectedUpstream:ie,upstreamBranches:Fe}=d1(t,u);c.useEffect(()=>{he(!1)},[t]);const _e=i.some(N=>N.name==="upstream"),Me=!!(t&&e&&n&&(e!==n||(_e||ie!==null))),q=c.useMemo(()=>si(t,e,K?.name??null),[t,e,K?.name]),Ne=Vs(N=>N.entries[q]),je=Ne?.isLoading??!1,We=Ne?.status??null,tt=Ne?.error??null,it=Ne?.isInitialStatusResolved??!1,rt=c.useMemo(()=>{const N=oe?null:K?.name?.trim()||null,ye=new Set;for(const Tt of o){const Dt=i1(Tt,N);!Dt||Dt==="HEAD"||ye.add(Dt)}if(oe)for(const Tt of Fe)Tt&&Tt!=="HEAD"&&ye.add(Tt);const Le=_n(n);Le&&Le!=="HEAD"&&ye.add(Le);const at=_n(se);return at&&at!=="HEAD"&&ye.add(at),Array.from(ye).sort((Tt,Dt)=>Tt.localeCompare(Dt))},[n,o,K?.name,se,Fe,oe]);c.useEffect(()=>{if(i.length===0){K&&te(null);return}(!K||!i.some(N=>N.name===K.name))&&te(Fi(i,{selectedRemoteName:M?.selectedRemoteName,trackingBranch:r}))},[M?.selectedRemoteName,i,K,r]),c.useEffect(()=>{const N=_n(n);if(!se&&N){ce(N);return}if(rt.length!==0&&!rt.includes(se)){const ye=rt.includes(N)?N:rt[0];ye&&ce(ye)}},[rt,n,se]);const[ot,ft]=c.useState(()=>M?.activeSegment??"overview"),[st,Ct]=c.useState(new Set),[ht,be]=c.useState(new Set),Je=c.useRef(new Set),dt=c.useRef(null),Ke=c.useRef(!1),mt=c.useRef(new Set),ee=c.useRef([]);c.useEffect(()=>{ie&&!_e&&he(!0)},[ie,_e]),c.useEffect(()=>{oe&&ie?.defaultBranch&&ce(ie.defaultBranch)},[oe,ie?.defaultBranch]);const fe=We?.pr??null,Ie=fe?.state==="merged"||fe?.state==="closed",$e=Ie?null:fe,H=$e?Sf(t,$e.number):null,Be=wc(N=>H?N.entries[H]:void 0),Ye=wc(N=>N.ensure),qe=Be?.result??null,Xe=Be?.isLoading??!1,jt=c.useCallback(N=>{ft(N);const ye=Fr.get(v);ye&&Fr.set(v,{...ye,activeSegment:N})},[v]);c.useEffect(()=>{!$e||!u?.prContext||ot==="overview"||Ye(u,t,$e.number,{includeCheckDetails:ot==="checks",sourceRepo:We?.repo??null})},[ot,t,Ye,u,$e,We?.repo]);const Ve=We?.checks??null,pt=(Ve?.pending??0)>0,Rt=qe?.checkRuns??null,De=qe?.fetchedAt;c.useEffect(()=>{if(!Rt||Rt.length===0)return;const N=t1(Rt);$(q,ye=>{if(!ye?.pr||typeof De=="number"&&typeof ye.fetchedAt=="number"&&De<ye.fetchedAt)return ye;const Le=ye.checks;return Le&&Le.state===N.state&&Le.total===N.total&&Le.success===N.success&&Le.failure===N.failure&&Le.pending===N.pending&&Le.inProgress===N.inProgress&&Le.queued===N.queued&&Le.startedAt===N.startedAt?ye:{...ye,checks:N,...typeof De=="number"?{fetchedAt:De}:{}}})},[Rt,De,q,$]),c.useEffect(()=>{if(ot!=="checks"||!pt||!fe||!u?.prContext)return;const N=window.setInterval(()=>{Ye(u,t,fe.number,{includeCheckDetails:!0,sourceRepo:We?.repo??null,force:!0})},s1);return()=>window.clearInterval(N)},[ot,pt,t,Ye,u,fe,We?.repo]);const[yt,Pt]=c.useState(()=>Date.now());c.useEffect(()=>{if(!pt)return;Pt(Date.now());const N=window.setInterval(()=>Pt(Date.now()),3e4);return()=>window.clearInterval(N)},[pt]);const Ue=fe?`${t}#${fe.number}`:null,He=!!(Ue&&pe===Ue);c.useEffect(()=>{if(!u?.prContext||!fe||typeof fe.body=="string"&&fe.body.length>0)return;const N=`${t}#${fe.number}`;if(Je.current.has(N))return;Je.current.add(N),ne(N);let ye=!1;return Ye(u,t,fe.number,{sourceRepo:We?.repo??null}).then(Le=>{if(ye)return;const at=Le?.pr;at&&$(q,Tt=>!Tt?.pr||Tt.pr.number!==fe.number?Tt:{...Tt,pr:{...Tt.pr,body:at.body||""}})}).catch(()=>{}).finally(()=>{ye||ne(Le=>Le===N?null:Le)}),()=>{ye=!0}},[t,Ye,u,fe,q,We?.repo,$]),c.useEffect(()=>{if(!fe){Te(!1),U(""),Q(""),dt.current=null;return}const N=dt.current!==null&&dt.current!==fe.number;N&&Te(!1),(!Ce||N)&&(U(fe.title||""),Q(fe.body||"")),dt.current=fe.number},[Ce,fe]);const ve=c.useCallback(N=>{if(!N)return"";const ye=Date.parse(N);return Number.isFinite(ye)?Cu(ye,d,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):N},[d]),Qe=c.useMemo(()=>{const N=m?.user?.login;return typeof N=="string"?N.trim():""},[m]),Ge=c.useMemo(()=>"[&_a[href*='oc-self-mention=1']]:!text-[var(--primary-base)] [&_a[href*='oc-self-mention=1']]:font-semibold [&_a[href*='oc-self-mention=1']]:!no-underline [&_a[href*='oc-self-mention=1']:hover]:!text-[var(--primary-hover)]",[]),Ze=c.useCallback(N=>{const ye=Qe.toLowerCase(),Le=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return N.replace(Le,(at,Tt,Dt)=>{const bt=`@${Dt}`,Kt=Dt.toLowerCase();return`${Tt}[${bt}](https://github.com/${Kt}${ye&&Kt===ye?"?oc-self-mention=1":""})`})},[Qe]),lt=c.useMemo(()=>{const N=(qe?.issueComments??[]).map(at=>({id:`issue-${at.id}`,body:at.body||"",authorName:at.author?.name||at.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:at.author?.login||null,avatarUrl:at.author?.avatarUrl||null,createdAt:at.createdAt,context:a("gitView.pr.comments.generalContext"),path:null,line:null})),ye=(qe?.reviewComments??[]).map(at=>({id:`review-${at.id}`,body:at.body||"",authorName:at.author?.name||at.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:at.author?.login||null,avatarUrl:at.author?.avatarUrl||null,createdAt:at.createdAt,context:a("gitView.pr.comments.reviewContext"),path:at.path||null,line:at.line??null})),Le=[...N,...ye];return Le.sort((at,Tt)=>{const Dt=at.createdAt?Date.parse(at.createdAt):0,bt=Tt.createdAt?Date.parse(Tt.createdAt):0,Kt=Number.isFinite(Dt)?Dt:0,ls=Number.isFinite(bt)?bt:0;return Kt-ls}),Le},[qe,a]),Bt=c.useCallback(()=>{const N=x??(k?"draft":null);return N?{directory:t,sessionKey:N}:(ze.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null)},[x,t,k,a]),$t=c.useCallback((N,ye)=>{const Le=ye.authorLogin?`@${ye.authorLogin}`:ye.authorName,at=ye.path?` · ${ye.path}${ye.line?`:${ye.line}`:""}`:"";ea.getState().addDraft(N,{source:"pr-comment",fileLabel:`PR #${fe?.number??""} ${Le}${at}`,startLine:ye.line??0,endLine:ye.line??0,code:ye.body,language:"markdown",text:""})},[fe?.number]),Wt=c.useCallback((N,ye)=>{const Le=N.status||"unknown",at=N.conclusion??void 0,Tt=at?`${Le} / ${at}`:Le,Dt=N.app?.name||N.app?.slug;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:ye?.hideHeader?"flex items-start justify-end gap-3":"flex items-start justify-between gap-3",children:[ye?.hideHeader?null:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:N.name}),s.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:Dt?`${Dt} · ${Tt}`:Tt})]}),N.detailsUrl?s.jsx(ut,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:s.jsxs("a",{href:N.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(F,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),N.output?.title?s.jsx("div",{className:"typography-micro text-foreground",children:N.output.title}):null,N.output?.summary?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:N.output.summary}):null,N.output?.text?s.jsx("div",{className:"rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground whitespace-pre-wrap break-words max-h-48 overflow-y-auto",children:N.output.text}):null,Array.isArray(N.annotations)&&N.annotations.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",N.annotations.length>20?` (showing 20/${N.annotations.length})`:""]}),s.jsx("div",{className:"space-y-1",children:N.annotations.slice(0,20).map((bt,Kt)=>s.jsxs("div",{className:"rounded border border-[var(--status-error-border)] bg-[var(--status-error-background)]/40 px-2 py-2",children:[s.jsxs("div",{className:"typography-micro break-words text-[var(--status-error)]",children:[bt.title||bt.level||"Issue",bt.path?` · ${bt.path}`:"",typeof bt.startLine=="number"?`:${bt.startLine}`:"",typeof bt.endLine=="number"&&bt.endLine!==bt.startLine?`-${bt.endLine}`:""]}),s.jsx("div",{className:"typography-micro text-foreground whitespace-pre-wrap break-words mt-1",children:bt.message}),bt.rawDetails?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words mt-1",children:bt.rawDetails}):null]},`${bt.path||"file"}:${bt.startLine||Kt}:${Kt}`))})]}):null,N.job?.steps&&N.job.steps.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.checks.steps")}),s.jsx("div",{className:"space-y-1",children:N.job.steps.map((bt,Kt)=>{const ls=(bt.conclusion||"").toLowerCase(),gt=ls&&!["success","neutral","skipped"].includes(ls),It=`${N.id??"run"}:${N.job?.jobId??"job"}:${bt.number??Kt}:${bt.name}`,Mt=st.has(It);return gt?s.jsxs(ta,{open:Mt,children:[s.jsxs("button",{type:"button",onClick:()=>{Ct(Vt=>{const Yt=new Set(Vt);return Yt.has(It)?Yt.delete(It):Yt.add(It),Yt})},className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-left "+(gt?"bg-destructive/10 text-destructive":"text-muted-foreground"),children:[Mt?s.jsx(F,{name:"arrow-down-s",className:"size-4"}):s.jsx(F,{name:"arrow-right-s",className:"size-4"}),s.jsx("span",{className:"truncate",children:bt.name}),bt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:bt.conclusion}):null]}),s.jsx(sa,{children:s.jsxs("div",{className:"ml-6 mt-1 rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground space-y-1",children:[typeof bt.number=="number"?s.jsxs("div",{children:[a("gitView.pr.checks.stepLabel"),": ",bt.number]}):null,bt.status?s.jsxs("div",{children:[a("gitView.pr.checks.statusLabel"),": ",bt.status]}):null,bt.conclusion?s.jsxs("div",{children:[a("gitView.pr.checks.conclusionLabel"),": ",bt.conclusion]}):null,bt.startedAt?s.jsxs("div",{children:[a("gitView.pr.checks.startedLabel"),": ",ve(bt.startedAt)]}):null,bt.completedAt?s.jsxs("div",{children:[a("gitView.pr.checks.completedLabel"),": ",ve(bt.completedAt)]}):null]})})]},It):s.jsxs("div",{className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:bt.name}),bt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:bt.conclusion}):null]},It)})})]}):null]})},[st,ve,a]),[Xt,Ft]=c.useState(!1),[Jt,Lt]=c.useState(!1),is=c.useCallback(async()=>{if(!u?.prContext){ze.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!fe)return;const N=Bt();if(N){Ft(!0);try{const ye=await Ye(u,t,fe.number,{includeCheckDetails:!0,sourceRepo:We?.repo??null});if(!ye){ze.error(a("gitView.pr.toast.loadChecksFailed"));return}const at=(ye.checkRuns??[]).filter(Dt=>Bi(Dt.conclusion));if(at.length===0){ze.message(a("gitView.pr.toast.noFailedChecks"));return}const Tt=ea.getState();for(const Dt of at){const bt=(Dt.annotations??[]).map(gt=>[[gt.level,gt.title].filter(Boolean).join(" "),gt.path?`${gt.path}${typeof gt.startLine=="number"?`:${gt.startLine}`:""}`:null,gt.message,gt.rawDetails].filter(Boolean).join(`
|
|
3
|
-
`)),Kt=(Dt.job?.steps??[]).filter(gt=>Bi(gt.conclusion)).map(gt=>`step ${gt.number??"?"}: ${gt.name} → ${gt.conclusion}`),ls=[`check: ${Dt.job?.workflowName?`${Dt.job.workflowName} / ${Dt.name}`:Dt.name}`,`status: ${Dt.status??"unknown"} / ${Dt.conclusion??"unknown"}`,Dt.detailsUrl?`url: ${Dt.detailsUrl}`:null,Dt.output?.title?`title: ${Dt.output.title}`:null,Dt.output?.summary?`summary:
|
|
4
|
-
${Dt.output.summary}`:null,Kt.length>0?`failed steps:
|
|
5
|
-
${Kt.join(`
|
|
6
|
-
`)}`:null,bt.length>0?`annotations:
|
|
7
|
-
${bt.join(`
|
|
8
|
-
---
|
|
9
|
-
`)}`:null].filter(Boolean).join(`
|
|
10
|
-
|
|
11
|
-
`);Tt.addDraft(N,{source:"pr-check",fileLabel:`PR #${fe.number} · ${Dt.name}`,startLine:0,endLine:0,code:ls,language:"text",text:""})}}catch(ye){const Le=ye instanceof Error?ye.message:String(ye);ze.error(a("gitView.pr.toast.loadChecksFailed"),{description:Le})}finally{Ft(!1)}}},[t,Ye,u,fe,Bt,We?.repo,a]),_t=c.useCallback(async()=>{if(!u?.prContext){ze.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!fe)return;const N=Bt();if(N){Lt(!0);try{if(!await Ye(u,t,fe.number,{sourceRepo:We?.repo??null})){ze.error(a("gitView.pr.toast.loadPrCommentsFailed"));return}if(lt.length===0){ze.message(a("gitView.pr.toast.noPrComments"));return}for(const Le of lt)$t(N,Le)}catch(ye){const Le=ye instanceof Error?ye.message:String(ye);ze.error(a("gitView.pr.toast.loadPrCommentsFailed"),{description:Le})}finally{Lt(!1)}}},[$t,t,Ye,u,fe,Bt,We?.repo,a,lt]),zt=c.useCallback(async N=>{const ye=Bt();ye&&$t(ye,N)},[$t,Bt]),Nt=c.useCallback(async N=>{await T(q,N)},[q,T]),[At,us]=c.useState(!1),xs=c.useRef(!0);c.useEffect(()=>(xs.current=!0,()=>{xs.current=!1}),[]);const qs=c.useCallback(async()=>{if(At)return;us(!0);const N=Date.now();try{await Nt({force:!0})}finally{const ye=o1-(Date.now()-N);ye>0&&await new Promise(Le=>window.setTimeout(Le,ye)),xs.current&&us(!1)}},[At,Nt]),Zt=c.useCallback(()=>{ee.current.forEach(N=>{window.clearTimeout(N)}),ee.current=r1.map(N=>window.setTimeout(()=>{Nt({force:!0,silent:!0,markInitialResolved:!0})},N))},[Nt]);c.useEffect(()=>{if(!u?.prStatus||!Me||i.length<=1||Ke.current||We?.pr)return;const N=`${v}::${K?.name??""}`;if(mt.current.has(N))return;mt.current.add(N);const ye=c1(i,r).filter(Tt=>Tt.name!==K?.name);if(ye.length===0)return;let Le=!1;return(async()=>{for(const Tt of ye){if(Le)return;try{if(!(await u.prStatus(t,e,Tt.name))?.pr)continue;if(Le)return;te(bt=>bt?.name===Tt.name?bt:Tt);return}catch{}}})(),()=>{Le=!0}},[e,Me,t,u,i,K?.name,v,We?.pr,r]),c.useEffect(()=>{R(q),I(q,{directory:t,branch:e,remoteName:K?.name??null,canShow:Me,github:u,githubAuthChecked:f,githubConnected:m?.connected??null})},[e,Me,t,R,u,f,m?.connected,q,K?.name,I]),c.useEffect(()=>(B(q),()=>{O(q)}),[q,B,O]),c.useEffect(()=>{const N=Fr.get(v)??null;Y(N?.title??Sc(e)),A(N?.body??""),P(N?.draft??!1),ce(N?.targetBaseBranch?_n(N.targetBaseBranch):_n(n));const ye=Fi(i,{selectedRemoteName:N?.selectedRemoteName,trackingBranch:r});te(Le=>Le?.name===ye?.name?Le:ye)},[n,e,i,v,r]),c.useEffect(()=>{Nt({markInitialResolved:!0})},[q,Nt]),c.useEffect(()=>{!Me||!K?.name||Nt({force:!0,silent:!0,markInitialResolved:!0})},[Me,Nt,K?.name]),c.useEffect(()=>{const N=We?.resolvedRemoteName?.trim();if(!N||Ke.current)return;const ye=i.find(Le=>Le.name===N);ye&&te(Le=>Le?.name===ye.name?Le:ye)},[i,We?.resolvedRemoteName]),c.useEffect(()=>{const N=()=>{const Le=Vs.getState().entries[q]?.lastRefreshAt??0;Date.now()-Le>6e4&&Nt({force:!0,silent:!0})},ye=()=>{document.visibilityState==="visible"&&N()};return window.addEventListener("focus",N),document.addEventListener("visibilitychange",ye),()=>{window.removeEventListener("focus",N),document.removeEventListener("visibilitychange",ye)}},[q,Nt]),c.useEffect(()=>{f&&m?.connected===!1&&Nt({force:!0,silent:!0,markInitialResolved:!0})},[f,m,Nt]),c.useEffect(()=>{!t||!e||Fr.set(v,{title:_,body:L,draft:D,additionalContext:Z,targetBaseBranch:se,selectedRemoteName:K?.name,activeSegment:ot})},[v,_,L,D,Z,se,K?.name,t,e,ot]),c.useEffect(()=>{const N=ee.current;return()=>{N.forEach(ye=>{window.clearTimeout(ye)}),ee.current=[]}},[]);const nn=c.useCallback(async()=>{if(!ae&&t){Ee(!0);try{const ye={base:oe&&ie?.defaultBranchSha?ie.defaultBranchSha:se,head:e};Z&&(ye.context=Z);const Le=await _p(t,ye);Le.title?.trim()&&Y(Le.title.trim()),Le.body?.trim()&&A(Le.body.trim()),l?.()}catch(N){const ye=N instanceof Error?N.message:String(N);ze.error(a("gitView.pr.toast.generateDescriptionFailed"),{description:ye})}finally{Ee(!1)}}},[Z,e,ie?.defaultBranchSha,t,ae,l,se,a,oe]),Cn=c.useCallback(async()=>{if(!u?.prCreate){ze.error(a("gitView.pr.toast.githubApiUnavailable"));return}const N=_.trim();if(!N){ze.error(a("gitView.pr.toast.titleRequired"));return}const ye=se.trim();if(!ye){ze.error(a("gitView.pr.toast.baseBranchRequired"));return}if(!oe&&ye===e){ze.error(a("gitView.pr.toast.baseMustDifferFromHead"));return}me(!0);try{const Le=il(r),at=oe&&ie,Tt=await u.prCreate({directory:t,title:N,head:e,base:ye,...L.trim()?{body:L}:{},draft:D,...at?{targetRepo:{owner:ie.owner,repo:ie.repo},headRemote:"origin"}:{...K?{remote:K.name}:{},...Le&&Le!==K?.name?{headRemote:Le}:{}}});ze.success(a("gitView.pr.toast.prCreated")),$(q,Dt=>Dt&&{...Dt,pr:Tt}),await Nt({force:!0}),Zt()}catch(Le){const at=Le instanceof Error?Le.message:String(Le);ze.error(a("gitView.pr.toast.createPrFailed"),{description:at})}finally{me(!1)}},[L,e,ie,t,D,u,q,Nt,Zt,K,se,_,r,$,oe,a]),rn=c.useCallback(async N=>{if(!u?.prMerge){ze.error(a("gitView.pr.toast.githubApiUnavailable"));return}de(!0);try{const ye=await u.prMerge({directory:t,number:N.number,method:re});ye.merged?ze.success(a("gitView.pr.toast.prMerged")):ze.message(a("gitView.pr.toast.prNotMerged"),{description:ye.message||a("gitView.pr.notMergeable")}),await Nt({force:!0}),Zt()}catch(ye){const Le=ye instanceof Error?ye.message:String(ye);ze.error(a("gitView.pr.toast.mergeFailed"),{description:Le}),N.url&&po(N.url)}finally{de(!1)}},[t,u,re,Nt,Zt,a]),hn=c.useCallback(async N=>{if(!u?.prReady){ze.error(a("gitView.pr.toast.githubApiUnavailable"));return}G(!0);try{await u.prReady({directory:t,number:N.number}),ze.success(a("gitView.pr.toast.markedReady")),await Nt({force:!0}),Zt()}catch(ye){const Le=ye instanceof Error?ye.message:String(ye);ze.error(a("gitView.pr.toast.markReadyFailed"),{description:Le}),N.url&&po(N.url)}finally{G(!1)}},[t,u,Nt,Zt,a]),on=c.useCallback(async N=>{if(!u?.prUpdate){ze.error(a("gitView.pr.toast.githubApiUnavailable"));return}const ye=xe.trim();if(!ye){ze.error(a("gitView.pr.toast.titleRequired"));return}V(!0);try{const Le=await u.prUpdate({directory:t,number:N.number,title:ye,body:z});$(q,at=>at&&{...at,pr:{...at.pr??N,...Le}}),Te(!1),ze.success(a("gitView.pr.toast.prUpdated")),await Nt({force:!0}),Zt()}catch(Le){const at=Le instanceof Error?Le.message:String(Le);ze.error(a("gitView.pr.toast.updatePrFailed"),{description:at})}finally{V(!1)}},[t,z,xe,u,q,Nt,Zt,$,a]);if(!Me)return s.jsx("section",{className:"border-0 bg-transparent rounded-none",children:s.jsxs("div",{className:"space-y-1 pt-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:a("gitView.pullRequest.title")}),s.jsx(gc,{})]}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pullRequest.availableOnFeatureBranches")})]})});const Ts=We?.repo?.url||null,zs=oe&&ie?.url?ie.url:Ts,Ws=!!We?.canMerge,an=!!We?.connected,as=f&&We?.connected===!1,ps=n1(We),Ys=ps?`var(--pr-${ps})`:"var(--status-info)",fs=ps==="draft"?"git-pr-draft":ps==="merged"?"git-merge":ps==="closed"?"git-close-pull-request":"git-pull-request",ln=fe?[`${fe.state}${fe.draft?" (draft)":""}`,fe.mergeable===!1?a("gitView.pr.notMergeable"):null,fe.state==="open"&&typeof fe.mergeableState=="string"&&fe.mergeableState&&fe.mergeableState!=="unknown"?fe.mergeableState:null].filter(Boolean).join(" · "):"",pn=Ve?Ve.total>0?`${Ve.success}/${Ve.total} ${a("gitView.pr.checks.label")}`:`${Ve.state} ${a("gitView.pr.checks.label")}`:"";return s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[s.jsxs("div",{className:"px-0 py-3 border-b border-border/40 flex flex-col gap-1",children:[s.jsxs("div",{className:"@container/pr-actions flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[fe?s.jsxs(ut,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{po(fe.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:[s.jsx(F,{name:fs,className:"size-4 shrink-0",style:{color:Ys}}),a("gitView.pr.actions.openOnGitHub")]}):s.jsx(F,{name:fs,className:"size-4 shrink-0",style:{color:"var(--surface-muted-foreground)"}}),s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:a("gitView.pullRequest.title")}),fe?s.jsxs("span",{className:"typography-meta text-muted-foreground truncate",children:["#",fe.number]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[fe&&S?s.jsxs(ut,{variant:"outline",size:"sm",className:Re("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",Xy),onClick:()=>{b(t,{kind:"pr",number:fe.number,sourceRepo:We?.repo?{owner:We.repo.owner,repo:We.repo.repo}:void 0}),j(t,"walkthrough")},"aria-label":a("walkthrough.action.open"),children:[s.jsx(F,{name:"route",className:"size-4"}),s.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:a("walkthrough.action.open")})]}):null,s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx(ut,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:je||At,onClick:()=>{qs()},"aria-label":a("gitView.pr.actions.refreshAria"),children:je||At?s.jsx(F,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}):s.jsx(F,{name:"refresh",className:"size-4 text-muted-foreground"})})}),s.jsx(St,{children:s.jsx("p",{children:a("gitView.pr.actions.refresh")})})]}),s.jsx(gc,{className:"h-7 w-7"})]})]}),fe?s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 typography-micro text-muted-foreground",children:[s.jsx("span",{style:{color:Ys},children:ln}),Ve?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${vc(Ve.state)}`}),pn]}):null,r&&K&&r.split("/")[0]!==K.name?s.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",K.name]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[Ws&&fe.draft&&fe.state==="open"?s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx(ut,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>hn(fe),disabled:we||J||ke||Ce,"aria-label":a("gitView.pr.actions.markReadyAria"),children:we?s.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(F,{name:"checkbox-circle",className:"size-4"})})}),s.jsx(St,{children:s.jsx("p",{children:a("gitView.pr.actions.markReady")})})]}):null,Ws?s.jsxs(s.Fragment,{children:[s.jsxs(Ms,{value:re,onValueChange:N=>ge(N),disabled:J||fe.state!=="open",children:[s.jsx(Os,{size:"sm",className:"h-7 w-auto min-w-0",children:s.jsx(Cs,{})}),s.jsxs(Bs,{children:[s.jsx(rs,{value:"squash",children:a("gitView.pr.mergeMethod.squash")}),s.jsx(rs,{value:"merge",children:a("gitView.pr.mergeMethod.merge")}),s.jsx(rs,{value:"rebase",children:a("gitView.pr.mergeMethod.rebase")})]})]}),s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx(ut,{size:"sm",className:"h-7 w-7 px-0",onClick:()=>rn(fe),disabled:J||we||fe.state!=="open"||fe.draft||ke||Ce,"aria-label":a("gitView.pr.actions.mergePrAria"),children:J?s.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(F,{name:"git-merge",className:"size-4"})})}),s.jsx(St,{children:s.jsx("p",{children:a("gitView.pr.actions.mergePr")})})]})]}):null]})]}):null]}),s.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[as?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta text-muted-foreground",children:a("gitView.pr.githubNotConnected")}),s.jsx(ut,{variant:"outline",size:"sm",onClick:C,className:"w-fit",children:a("gitView.pr.actions.openSettings")})]}):null,tt?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:a("gitView.pr.statusUnavailable")}),s.jsx("div",{className:"typography-meta text-muted-foreground break-words",children:tt}),zs?s.jsx(ut,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:s.jsxs("a",{href:zs,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(F,{name:"external-link",className:"size-4"}),"Open Repo"]})}):null]}):null,!fe&&!it&&!tt&&!as?s.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[s.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.pr.checkingStatus")]}):fe&&!Ie?s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx("div",{className:"h-8 min-w-0",children:s.jsx(Jd,{className:"h-full",items:[{id:"overview",label:a("gitView.pr.segment.overview")},{id:"checks",label:Ve&&Ve.total>0?`${a("gitView.pr.segment.checks")} ${Ve.success}/${Ve.total}`:a("gitView.pr.segment.checks"),icon:Ve?s.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${vc(Ve.state)}`}):void 0},{id:"comments",label:qe?`${a("gitView.pr.segment.comments")} ${(qe.issueComments?.length??0)+(qe.reviewComments?.length??0)}`:a("gitView.pr.segment.comments")}],activeId:ot,onSelect:N=>jt(N),layoutMode:"fit",variant:"active-pill",activePillButtonClassName:"h-7"})}),ot==="overview"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[Ws&&fe.draft?s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.draftMustBeReady")}):null,Ws?null:s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.noMergePermission")}),s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("div",{className:"min-w-0 flex-1",children:Ce?s.jsx(In,{value:xe,onChange:N=>U(N.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:h?"on":"off",autoCapitalize:h?"sentences":"off",spellCheck:h}):s.jsx("div",{className:"typography-markdown text-xl font-semibold text-foreground break-words leading-snug",children:fe.title})}),fe.state==="open"?s.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:Ce?s.jsxs(s.Fragment,{children:[s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx(ut,{variant:"outline",size:"sm",className:"h-9 w-9 px-0",onClick:()=>{Te(!1),U(fe.title||""),Q(fe.body||"")},disabled:ke,"aria-label":a("gitView.pr.actions.cancelEditingAria"),children:s.jsx(F,{name:"close",className:"size-4"})})}),s.jsx(St,{children:s.jsx("p",{children:a("gitView.pr.actions.cancelEditing")})})]}),s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx(ut,{size:"sm",className:"h-9 w-9 px-0",onClick:()=>on(fe),disabled:ke||!xe.trim(),"aria-label":a("gitView.pr.actions.savePrAria"),children:ke?s.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(F,{name:"check",className:"size-4"})})}),s.jsx(St,{children:s.jsx("p",{children:a("gitView.pr.actions.savePr")})})]})]}):s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx(ut,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>Te(!0),"aria-label":a("gitView.pr.actions.editPrAria"),children:s.jsx(F,{name:"edit",className:"size-4"})})}),s.jsx(St,{children:s.jsx("p",{children:a("gitView.pr.actions.editPr")})})]})}):null]}),Ce?s.jsx(wr,{value:z,onChange:N=>Q(N.target.value),outerClassName:"min-h-[60vh]",placeholder:a("gitView.pr.placeholder.description"),autoCorrect:h?"on":"off",autoCapitalize:h?"sentences":"off",spellCheck:h}):null,Ce?null:fe.body?.trim()?s.jsx(Fl,{content:fe.body,className:"typography-markdown-body min-w-0 text-muted-foreground break-words",enableFileReferences:!1}):s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:a(He?"gitView.pr.loadingDescription":"gitView.pr.noDescription")})]}):null,ot==="checks"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[Ve&&Ve.total>0?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-muted/40",children:[Ve.success>0?s.jsx("div",{className:"bg-[color:var(--status-success)]",style:{width:`${Ve.success/Ve.total*100}%`}}):null,Ve.failure>0?s.jsx("div",{className:"bg-[color:var(--status-error)]",style:{width:`${Ve.failure/Ve.total*100}%`}}):null,Ve.pending>0?s.jsx("div",{className:"bg-[color:var(--status-warning)]",style:{width:`${Ve.pending/Ve.total*100}%`}}):null]}),s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Ve.success,"/",Ve.total," ",a("gitView.pr.checks.label")]}),(Ve.inProgress??0)>0?s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-[var(--status-warning)]",children:[s.jsx(F,{name:"loader-4",className:"size-3.5 animate-spin"}),Oi(Ve.startedAt,void 0,yt)]}):null]}):null,Ve?.failure?s.jsxs(ut,{variant:"outline",size:"sm",className:"w-fit gap-1.5 border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)]",onClick:is,disabled:Xt,"aria-label":a("gitView.pr.actions.resolveFailedChecksAria"),children:[Xt?s.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(F,{name:"ai-generate-2",className:"size-4"}),a("gitView.pr.actions.resolveFailedChecks")]}):null,(qe?.checkRuns?.length??0)>0?s.jsx("div",{className:"flex flex-col gap-1.5",children:(qe?.checkRuns??[]).map((N,ye)=>{const Le=`${N.id??"run"}:${N.name}:${ye}`,at=N.status==="in_progress",Tt=N.status==="queued",Dt=Bi(N.conclusion),bt=ht.has(Le),Kt=!!(N.output?.title||N.output?.summary||N.output?.text||(N.annotations?.length??0)>0||(N.job?.steps?.length??0)>0||N.detailsUrl),ls=N.job?.workflowName,gt=at?Oi(N.startedAt,void 0,yt):Oi(N.startedAt,N.completedAt);return s.jsxs("div",{className:Re("rounded-md border border-border/40",Dt&&"border-[var(--status-error-border)]"),children:[s.jsxs("button",{type:"button",disabled:!Kt,onClick:()=>{be(It=>{const Mt=new Set(It);return Mt.has(Le)?Mt.delete(Le):Mt.add(Le),Mt})},className:"flex w-full items-center gap-2 px-2.5 py-2 text-left disabled:cursor-default",children:[at?s.jsx(F,{name:"loader-4",className:"size-4 shrink-0 animate-spin text-[var(--status-warning)]"}):Tt?s.jsx(F,{name:"time",className:"size-4 shrink-0 text-muted-foreground"}):Dt?s.jsx(F,{name:"close-circle",className:"size-4 shrink-0 text-[var(--status-error)]"}):s.jsx(F,{name:"checkbox-circle",className:"size-4 shrink-0 text-[var(--status-success)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:ls&&ls!==N.name?`${ls} / ${N.name}`:N.name}),gt?s.jsx("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:gt}):null,Kt?s.jsx(F,{name:"arrow-down-s",className:Re("size-4 shrink-0 text-muted-foreground transition-transform",bt&&"rotate-180")}):null]}),bt&&Kt?s.jsx("div",{className:"min-w-0 overflow-hidden border-t border-border/40 p-2.5",children:Wt(N,{hideHeader:!0})}):null]},Le)})}):Xe?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.loading.loading")]}):s.jsx("div",{className:"py-6 text-center typography-micro text-muted-foreground",children:a("gitView.pr.checkDetails.empty")})]}):null,ot==="comments"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[lt.length>0?s.jsx("div",{className:"flex items-center justify-end",children:s.jsxs(ut,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-[var(--status-success)] hover:bg-[var(--status-success-background)] hover:text-[var(--status-success)]",onClick:_t,disabled:Jt,"aria-label":a("gitView.pr.actions.shareCommentsAria"),children:[Jt?s.jsx(F,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(F,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.comments.addAll")]})}):null,lt.length>0?s.jsx("div",{className:"relative pl-3",children:s.jsx("div",{children:lt.map((N,ye)=>{const Le=(N.authorName||"?").charAt(0).toUpperCase(),at=ye===lt.length-1;return s.jsxs("div",{className:"relative pl-10 pb-5 last:pb-0",children:[at?null:s.jsx("div",{className:"absolute left-4 top-[2.375rem] bottom-[0.375rem] w-px bg-border/60"}),s.jsx("div",{className:"absolute left-0 top-0 z-10 flex size-8 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-surface-elevated text-xs text-muted-foreground",children:N.avatarUrl?s.jsx("img",{src:N.avatarUrl,alt:N.authorName,className:"h-full w-full object-cover"}):s.jsx("span",{children:Le})}),s.jsxs("div",{className:"rounded-lg bg-surface-elevated px-3 pt-0 pb-3 space-y-2",children:[s.jsxs("div",{className:"flex flex-col items-start gap-1 typography-micro text-muted-foreground sm:flex-row sm:flex-wrap sm:items-center sm:gap-x-1 sm:gap-y-1",children:[s.jsxs("span",{className:"text-foreground whitespace-nowrap",children:[N.authorName,N.authorLogin&&N.authorLogin!==N.authorName?` · @${N.authorLogin}`:""]}),N.createdAt?s.jsx("span",{className:"whitespace-nowrap",children:ve(N.createdAt)}):null,s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsxs(ut,{variant:"ghost",size:"sm",className:"h-6 px-0 has-[>svg]:px-0 sm:px-2 sm:has-[>svg]:px-2.5 text-[var(--status-success)] hover:bg-[var(--status-success-background)] hover:text-[var(--status-success)] justify-start",onClick:()=>{zt(N)},"aria-label":a("gitView.pr.actions.sendCommentToAgentAria"),children:[s.jsx(F,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.actions.sendToAgent")]})}),s.jsx(St,{children:s.jsx("p",{children:a("gitView.pr.actions.sendCommentToAgent")})})]})]}),s.jsxs("div",{className:"typography-micro text-muted-foreground",children:[N.context,N.path?` · ${N.path}`:"",N.line?`:${N.line}`:""]}),s.jsx(Fl,{content:Ze(N.body),className:["typography-markdown-body text-foreground break-words [&_a]:no-underline [&_a:hover]:no-underline",Ge].filter(Boolean).join(" "),enableFileReferences:!1})]})]},N.id)})})}):Xe&&!qe?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.loading.loading")]}):s.jsx("div",{className:"py-6 text-center typography-micro text-muted-foreground",children:a("gitView.pr.comments.empty")})]}):null]}):s.jsxs("div",{className:"flex flex-col gap-3",children:[fe&&Ie?s.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md border border-border/60 bg-surface-muted/40 px-2.5 py-2",children:[s.jsx(F,{name:fe.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:Ys}}),s.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:fe.state==="merged"?a("gitView.pr.history.merged",{number:fe.number,base:fe.base||se}):a("gitView.pr.history.closed",{number:fe.number})}),s.jsx(ut,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{po(fe.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:s.jsx(F,{name:"external-link",className:"size-3.5"})})]}):null,s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:a("gitView.pr.createTitle")}),s.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," ",s.jsx("span",{className:"opacity-60",children:"(local)"})," → ",se," ",s.jsxs("span",{className:"opacity-60",children:["(",oe&&ie?"upstream":"remote",")"]})]})]}),zs?s.jsx(ut,{variant:"outline",size:"sm",asChild:!0,children:s.jsxs("a",{href:zs,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(F,{name:"external-link",className:"size-4"}),a("gitView.pr.actions.repo")]})}):null]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.title")}),s.jsx(In,{value:_,onChange:N=>Y(N.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:h?"on":"off",autoCapitalize:h?"sentences":"off",spellCheck:h})]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.baseBranch")}),rt.length>0?s.jsxs(Ms,{value:se,onValueChange:ce,children:[s.jsx(Os,{size:"lg",children:s.jsx(Cs,{placeholder:a("gitView.pr.placeholder.selectBaseBranch")})}),s.jsx(Bs,{children:rt.map(N=>s.jsx(rs,{value:N,children:N},N))})]}):s.jsx(In,{value:se,onChange:N=>ce(N.target.value),placeholder:a("gitView.pr.placeholder.main")})]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.description")}),s.jsx(wr,{value:L,onChange:N=>A(N.target.value),className:"min-h-[110px]",placeholder:a("gitView.pr.placeholder.whatChanged"),autoCorrect:h?"on":"off",autoCapitalize:h?"sentences":"off",spellCheck:h})]}),s.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",role:"button",tabIndex:0,"aria-pressed":D,onClick:()=>P(N=>!N),onKeyDown:N=>{(N.key===" "||N.key==="Enter")&&(N.preventDefault(),P(ye=>!ye))},children:[s.jsx(Sr,{size:"sm",checked:D,onChange:N=>P(N),ariaLabel:a("gitView.pr.actions.toggleDraftAria")}),s.jsx("span",{className:"typography-ui-label text-foreground select-none",children:a("gitView.pr.field.draft")})]}),w?s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.optional")}),s.jsx(ut,{variant:"outline",size:"sm",onClick:()=>E(!0),children:Z.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),Z.trim()&&s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("span",{className:"inline-flex items-center rounded-full bg-[var(--interactive-selection)] px-2 py-0.5 text-xs text-[var(--interactive-selection-foreground)]",children:a("gitView.pr.additionalContext.added")})})]}):s.jsxs(ta,{open:ue,onOpenChange:le,children:[s.jsxs(Nu,{className:"flex w-full items-center justify-between rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-3 py-2 hover:bg-[var(--interactive-hover)]",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.optional")}),s.jsx("span",{className:"typography-micro text-[var(--primary-base)]",children:ue?a("gitView.pr.actions.hide"):Z.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),s.jsx(sa,{children:s.jsxs("div",{className:"mt-2 space-y-2 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3",children:[s.jsx(wr,{value:Z,onChange:N=>X(N.target.value),className:"min-h-[100px] bg-transparent",placeholder:a("gitView.pr.placeholder.additionalContext")}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.hint")})]})})]}),s.jsx(ni,{open:W,onClose:()=>E(!1),title:a("gitView.pr.additionalContext.title"),footer:s.jsx(ut,{size:"sm",onClick:()=>E(!1),className:"w-full",children:a("gitView.common.done")}),children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(wr,{value:Z,onChange:N=>X(N.target.value),className:"min-h-[200px] bg-transparent",placeholder:a("gitView.pr.placeholder.additionalContext"),autoFocus:!0}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.hint")})]})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(ut,{variant:"outline",size:"sm",onClick:nn,disabled:ae||Se,children:[ae?s.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(F,{name:"ai-generate-2",className:"size-4 text-primary"}),a("gitView.commit.generate")]}),s.jsx("div",{className:"flex-1"}),s.jsxs(ut,{size:"sm",className:"min-w-[7.5rem] justify-center gap-2",onClick:Cn,disabled:Se||!an||!se.trim()||!oe&&se.trim()===e,children:[s.jsx("span",{className:"inline-flex size-4 items-center justify-center",children:Se?s.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(F,{name:"git-pull-request",className:"size-4"})}),s.jsx("span",{children:a("gitView.pr.actions.createPr")})]})]})]})]})]})},_i=t=>(t||"").replace(/\\/g,"/").replace(/\/+$/,""),go=new Map,xo=new Map,Fn=t=>`${Qt()}::${t}`,f1=()=>{const t=et.c(115),{t:e}=kt(),{git:n}=kn(),r=mr(),{rootIsGitRepo:i,gitDirectory:o,nestedRepos:l}=Lp(r??null),a=Ua(o??null),d=Au(o??null),u=Pu(o??null),{ensureAll:m,ensureNestedRepos:f,selectNestedRepo:p}=Mn(dr(m1)),y=nt(h1),x=nt(p1),k=nt(g1),w=nt(x1);let h;t[0]!==r?(h=_i(r),t[0]=r,t[1]=h):h=t[1];const g=h;let j;if(t[2]!==w||t[3]!==g||t[4]!==k){e:{if(!g){j=void 0;break e}let K;if(t[6]!==w||t[7]!==g){let oe;t[9]!==g?(oe=he=>_i(he.path)===g,t[9]=g,t[10]=oe):oe=t[10],K=w.find(oe),t[6]=w,t[7]=g,t[8]=K}else K=t[8];const te=K;if(te){j=te;break e}for(const oe of k.values())if(_i(oe.path)===g){j=oe;break e}j=void 0}t[2]=w,t[3]=g,t[4]=k,t[5]=j}else j=t[5];const b=j;let S;t[11]!==y||t[12]!==b||t[13]!==x?.open||t[14]!==k?(S=()=>{if(y)return k.get(y)??b;if(x?.open)return b},t[11]=y,t[12]=b,t[13]=x?.open,t[14]=k,t[15]=S):S=t[15],x?.open;let C;t[16]!==S?(C=S(),t[16]=S,t[17]=C):C=t[17];const v=C;let M;t[18]!==y?(M=K=>y?K.getAttachment(y):void 0,t[18]=y,t[19]=M):M=t[19];const R=xu(M),I=R&&!R.degraded&&!R.legacy?R.worktreeRoot??void 0:void 0,B=$y(r,v,a?.current??void 0);let O,T;t[20]!==m||t[21]!==n||t[22]!==o?(O=()=>{!o||!n||m(o,n)},T=[o,m,n],t[20]=m,t[21]=n,t[22]=o,t[23]=O,t[24]=T):(O=t[23],T=t[24]),c.useEffect(O,T);const[$,_]=c.useState(null);let Y;t[25]!==I||t[26]!==B?.projectDirectory?(Y=()=>{const K=I||B?.projectDirectory;if(!K){_(null);return}let te=!1;return Ha(K).then(oe=>{if(te)return;const he=oe.trim();_(he&&he!=="HEAD"?he:null)}).catch(()=>{te||_(null)}),()=>{te=!0}},t[25]=I,t[26]=B?.projectDirectory,t[27]=Y):Y=t[27];const L=B?.projectDirectory;let A;t[28]!==I||t[29]!==L?(A=[I,L],t[28]=I,t[29]=L,t[30]=A):A=t[30],c.useEffect(Y,A);let D;t[31]!==o?(D=()=>(o?go.get(Fn(o)):void 0)??[],t[31]=o,t[32]=D):D=t[32];const[P,Z]=c.useState(D);let X;t[33]!==o?(X=()=>(o?xo.get(Fn(o)):void 0)??null,t[33]=o,t[34]=X):X=t[34];const[se,ce]=c.useState(X);let re,ge;t[35]!==n||t[36]!==o?(re=()=>{if(!o||!n?.getRemotes){Z([]);return}Z(go.get(Fn(o))??[]);let K=!1;return n.getRemotes(o).then(te=>{K||(go.set(Fn(o),te??[]),Z(te??[]))}).catch(()=>{K||Z(go.get(Fn(o))??[])}),()=>{K=!0}},ge=[o,n],t[35]=n,t[36]=o,t[37]=re,t[38]=ge):(re=t[37],ge=t[38]),c.useEffect(re,ge);let ae,Ee;t[39]!==n||t[40]!==o?(ae=()=>{if(!o||!n?.getRemoteUrl){ce(null);return}ce(xo.get(Fn(o))??null);let K=!1;return n.getRemoteUrl(o).then(te=>{K||(xo.set(Fn(o),te),ce(te))}).catch(()=>{K||ce(xo.get(Fn(o))??null)}),()=>{K=!0}},Ee=[o,n],t[39]=n,t[40]=o,t[41]=ae,t[42]=Ee):(ae=t[41],Ee=t[42]),c.useEffect(ae,Ee);let Se;e:{if(!d?.all){let te;t[43]===Symbol.for("react.memo_cache_sentinel")?(te=[],t[43]=te):te=t[43],Se=te;break e}let K;t[44]!==d.all?(K=d.all.filter(b1).sort(),t[44]=d.all,t[45]=K):K=t[45],Se=K}const me=Se;let ke;e:{if(!d?.all){let te;t[46]===Symbol.for("react.memo_cache_sentinel")?(te=[],t[46]=te):te=t[46],ke=te;break e}let K;t[47]!==d.all?(K=d.all.filter(y1).map(w1).sort(),t[47]=d.all,t[48]=K):K=t[48],ke=K}const V=ke;let J;t[49]!==V||t[50]!==se||t[51]!==P||t[52]!==a?.tracking?(J=()=>{if(P.length>0)return P;const K=new Set,te=a?.tracking?.trim();te&&te.includes("/")&&K.add(te.split("/")[0]);for(const oe of V){const he=oe.indexOf("/");he>0&&K.add(oe.slice(0,he))}return K.size===0&&se&&K.add("origin"),Array.from(K).map(oe=>({name:oe,fetchUrl:se??"",pushUrl:se??""}))},t[49]=V,t[50]=se,t[51]=P,t[52]=a?.tracking,t[53]=J):J=t[53],a?.tracking;let de;t[54]!==J?(de=J(),t[54]=J,t[55]=de):de=t[55];const we=de,G=a?.current??null;a?.tracking;let Ce;t[56]!==a?.tracking?(Ce=a?.tracking?.trim().split("/")[0],t[56]=a?.tracking,t[57]=Ce):Ce=t[57];const Te=Ce,pe=(Te&&d?.defaultBranches?.[Te])??d?.defaultBranches?.origin;let ne;t[58]!==G||t[59]!==pe||t[60]!==we||t[61]!==me||t[62]!==$||t[63]!==B?.createdFromBranch?(ne=()=>Th({remoteNames:new Set(we.map(v1)),localBranches:me,worktreeCreatedFromBranch:B?.createdFromBranch,rootBranchHint:$,defaultBranch:pe,headBranch:G}),t[58]=G,t[59]=pe,t[60]=we,t[61]=me,t[62]=$,t[63]=B?.createdFromBranch,t[64]=ne):ne=t[64],B?.createdFromBranch;let xe;t[65]!==ne?(xe=ne(),t[65]=ne,t[66]=xe):xe=t[66];const U=xe;if(!r){let K;t[67]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx(F,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[67]=K):K=t[67];let te;t[68]!==e?(te=e("gitView.pullRequest.title"),t[68]=e,t[69]=te):te=t[69];let oe;t[70]!==te?(oe=s.jsx("div",{className:"typography-ui-header text-foreground",children:te}),t[70]=te,t[71]=oe):oe=t[71];let he;t[72]!==e?(he=e("gitView.pullRequest.createHint"),t[72]=e,t[73]=he):he=t[73];let ie;t[74]!==he?(ie=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:he}),t[74]=he,t[75]=ie):ie=t[75];let Fe;return t[76]!==oe||t[77]!==ie?(Fe=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[K,oe,ie]}),t[76]=oe,t[77]=ie,t[78]=Fe):Fe=t[78],Fe}if(i===!1&&u!==!0){let K;t[79]!==r||t[80]!==f?(K=()=>{f(r,{force:!0})},t[79]=r,t[80]=f,t[81]=K):K=t[81];let te;return t[82]!==u||t[83]!==l||t[84]!==i||t[85]!==K?(te=s.jsx(Eh,{rootIsGitRepo:i,resolvedIsGitRepo:u,nestedRepos:l,onRetryDiscovery:K}),t[82]=u,t[83]=l,t[84]=i,t[85]=K,t[86]=te):te=t[86],te}if(!G){let K;t[87]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx(F,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[87]=K):K=t[87];let te;t[88]!==e?(te=e("gitView.pullRequest.title"),t[88]=e,t[89]=te):te=t[89];let oe;t[90]!==te?(oe=s.jsx("div",{className:"typography-ui-header text-foreground",children:te}),t[90]=te,t[91]=oe):oe=t[91];let he;t[92]!==e?(he=e("gitView.pullRequest.createHint"),t[92]=e,t[93]=he):he=t[93];let ie;t[94]!==he?(ie=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:he}),t[94]=he,t[95]=ie):ie=t[95];let Fe;return t[96]!==oe||t[97]!==ie?(Fe=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[K,oe,ie]}),t[96]=oe,t[97]=ie,t[98]=Fe):Fe=t[98],Fe}const z=i===!1&&Array.isArray(l)&&l.length>0;let Q;t[99]!==r||t[100]!==o||t[101]!==l||t[102]!==p||t[103]!==z?(Q=z?s.jsx("div",{className:"flex shrink-0 items-center border-b border-border/60 px-4 py-2",children:s.jsx(Rh,{repositories:l,selectedRepository:o??null,onSelectRepository:K=>{r&&p(r,K)},repositoryRoot:r??void 0})}):null,t[99]=r,t[100]=o,t[101]=l,t[102]=p,t[103]=z,t[104]=Q):Q=t[104];const ue=o??r,le=a?.tracking??void 0;let W;t[105]!==U||t[106]!==G||t[107]!==V||t[108]!==P||t[109]!==ue||t[110]!==le?(W=s.jsx(On,{as:Ga,outerClassName:"h-full min-h-0 flex-1",className:"px-4 py-3",disableHorizontal:!0,preventOverscroll:!0,children:s.jsx(u1,{directory:ue,branch:G,baseBranch:U,trackingBranch:le,remotes:P,remoteBranches:V})}),t[105]=U,t[106]=G,t[107]=V,t[108]=P,t[109]=ue,t[110]=le,t[111]=W):W=t[111];let E;return t[112]!==Q||t[113]!==W?(E=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[Q,W]}),t[112]=Q,t[113]=W,t[114]=E):E=t[114],E};function m1(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function h1(t){return t.currentSessionId}function p1(t){return t.newSessionDraft}function g1(t){return t.worktreeMetadata}function x1(t){return t.availableWorktrees}function b1(t){return!t.startsWith("remotes/")}function y1(t){return t.startsWith("remotes/")}function w1(t){return t.replace(/^remotes\//,"")}function v1(t){return t.name}const ba=2e4,S1=(t,e)=>{if(!t)return 1;let n=1;for(let r=0;r<t.length;r+=1)if(t.charCodeAt(r)===10&&(n+=1,n>e))return n;return n},bo=(t,e)=>Vp(Up.getState().dictionary,t,e),j1=t=>{const n=(t instanceof Error?t.message:String(t??"")).toLowerCase();return n.includes("file not found")||n.includes("not found")||n.includes("enoent")||n.includes("no such file")||n.includes("does not exist")?"missing":"unreadable"},k1=async(t,e,n)=>{if(t.readFile)return(await t.readFile(e,{optional:!0,directory:n?.directory})).content??"";const r=new URLSearchParams({path:e,optional:"true"});n?.directory&&r.set("directory",n.directory);const i=await ws(`/api/fs/read?${r.toString()}`,{cache:"no-store",headers:n?.directory?{"x-opencode-directory":n.directory}:void 0});if(!i.ok){const o=await i.json().catch(()=>({error:i.statusText}));throw new Error(o.error||"Failed to read file")}return i.text()},jf=async(t,e,n)=>{if($p(e)||zp(e)||Wp(e))return{ok:!0};try{const r=await k1(t,e,n);return Kp(r)?{ok:!1,reason:"binary"}:S1(r,ba)>ba?{ok:!1,reason:"too-large"}:{ok:!0}}catch(r){return{ok:!1,reason:j1(r)}}},kf=t=>{if(t==="too-large"){const e=ba.toLocaleString(Du());return bo("contextFileOpen.failure.tooLarge",{count:e})}return bo(t==="missing"?"contextFileOpen.failure.missing":t==="binary"?"filesView.editor.cannotPreviewBinary":"contextFileOpen.failure.unreadable")},jc=8;let ya=null;const Cf=t=>{ya={x:t.clientX,y:t.clientY}},Nf=t=>{const e=ya;return ya=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:Math.abs(t.clientX-e.x)<=jc&&Math.abs(t.clientY-e.y)<=jc},kr=t=>Array.from(t.types).includes("Files"),C1=t=>{const e=Array.from(t.items);return e.length===0?Array.from(t.files):e.flatMap(n=>{if(n.kind!=="file"||n.webkitGetAsEntry()?.isDirectory)return[];const r=n.getAsFile();return r?[r]:[]})},N1=t=>t.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),gs=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},al=(t,e)=>{const n=gs(e),r=gs(t).replace(/\/+$/,"");return n===r?".":!r||!n.startsWith(`${r}/`)?n:n.slice(r.length+1)},A1=(t,e)=>{const n=al(t,e);if(n!==".")return n;const r=gs(t);return r.split("/").filter(Boolean).pop()??r},P1=t=>{const e=gs(t),n=e.lastIndexOf("/");return n<0?"":n===0?"/":e.slice(0,n)},D1=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),I1=new Set(["node_modules"]),T1=t=>I1.has(t),E1=t=>{const e=gs(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},R1=8,wn=new Map,ll=t=>JSON.stringify([Qt(),t]),M1=t=>{const e=ll(t),n=wn.get(e);return n?(n.touchedAt=Date.now(),wn.delete(e),wn.set(e,n),n):null},Li=t=>{const e=ll(t),n=wn.get(e);if(n)return n.touchedAt=Date.now(),n;if(wn.size>=R1){const i=wn.keys().next().value;i!==void 0&&wn.delete(i)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return wn.set(e,r),r},Af=(t,e)=>s.jsx(qa,{filePath:t,extension:e}),O1=t=>{const e=et.c(3),{status:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=r):r=e[0];const i=r[n];let o;return e[1]!==i?(o=s.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:i}}),e[1]=i,e[2]=o):o=e[2],o},B1=t=>{const e=et.c(90),{node:n,root:r,isExpanded:i,isActive:o,isBrowserClient:l,status:a,badge:d,isDropTarget:u,canUpload:m,permissions:f,downloadFile:p,onSelect:y,onToggle:x,onRevealPath:k,onOpenDialog:w,onSetDropTarget:h,onDropFiles:g,onPickFiles:j}=t,{t:b}=kt(),S=n.type==="directory";let C;e[0]!==S||e[1]!==n.path?(C=S?n.path:P1(n.path),e[0]=S,e[1]=n.path,e[2]=C):C=e[2];const v=C,{canRename:M,canCreateFile:R,canCreateFolder:I,canDelete:B,canReveal:O}=f,T=!S&&!!p,$=O&&!l,_=S&&m,Y=M||R||I||_||B||T||$,[L,A]=c.useState(!1),[D,P]=c.useState(!1);let Z;e[3]!==Y?(Z=he=>{Y&&(he?.preventDefault(),P(!0))},e[3]=Y,e[4]=Z):Z=e[4];const X=Z;let se;e[5]!==S||e[6]!==n||e[7]!==y||e[8]!==x?(se=()=>{S?x(n.path):y(n)},e[5]=S,e[6]=n,e[7]=y,e[8]=x,e[9]=se):se=e[9];const ce=se;let re;e[10]===Symbol.for("react.memo_cache_sentinel")?(re=he=>{he.stopPropagation(),P(!1),A(!0)},e[10]=re):re=e[10];const ge=re;let ae;e[11]!==R||e[12]!==I||e[13]!==B||e[14]!==M||e[15]!==$||e[16]!==_||e[17]!==p||e[18]!==l||e[19]!==S||e[20]!==n||e[21]!==w||e[22]!==j||e[23]!==k||e[24]!==b?(ae=he=>{const{Item:ie,Separator:Fe}=he;return s.jsxs(s.Fragment,{children:[M&&s.jsxs(ie,{onClick:_e=>{_e.stopPropagation(),w("rename",n)},children:[s.jsx(F,{name:"edit",className:"mr-2 h-4 w-4"})," ",b("sidebarFilesTree.menu.rename")]}),s.jsxs(ie,{onClick:_e=>{_e.stopPropagation(),fr(n.path).then(Ae=>{if(Ae.ok){ze.success(b("sidebarFilesTree.toast.pathCopied"));return}ze.error(b("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(F,{name:"file-copy",className:"mr-2 h-4 w-4"})," ",b("sidebarFilesTree.menu.copyPath")]}),!S&&p&&s.jsxs(ie,{onClick:_e=>{_e.stopPropagation(),p(n.path).catch(Ae=>{console.error("Download failed:",Ae),ze.error(b("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(F,{name:"download",className:"mr-2 h-4 w-4"})," ",b(l?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),$&&s.jsxs(ie,{onClick:_e=>{_e.stopPropagation(),k(n.path)},children:[s.jsx(F,{name:"folder-received",className:"mr-2 h-4 w-4"})," ",b(Hp())]}),S&&(R||I||_)&&s.jsxs(s.Fragment,{children:[s.jsx(Fe,{}),R&&s.jsxs(ie,{onClick:_e=>{_e.stopPropagation(),w("createFile",n)},children:[s.jsx(F,{name:"file-add",className:"mr-2 h-4 w-4"})," ",b("sidebarFilesTree.menu.newFile")]}),I&&s.jsxs(ie,{onClick:_e=>{_e.stopPropagation(),w("createFolder",n)},children:[s.jsx(F,{name:"folder-add",className:"mr-2 h-4 w-4"})," ",b("sidebarFilesTree.menu.newFolder")]}),_&&s.jsxs(ie,{onClick:_e=>{_e.stopPropagation(),j(n.path)},children:[s.jsx(F,{name:"upload-2",className:"mr-2 h-4 w-4"})," ",b("sidebarFilesTree.menu.uploadFiles")]})]}),B&&s.jsxs(s.Fragment,{children:[s.jsx(Fe,{}),s.jsxs(ie,{onClick:_e=>{_e.stopPropagation(),w("delete",n)},className:"text-destructive focus:text-destructive",children:[s.jsx(F,{name:"delete-bin",className:"mr-2 h-4 w-4"})," ",b("sidebarFilesTree.menu.delete")]})]})]})},e[11]=R,e[12]=I,e[13]=B,e[14]=M,e[15]=$,e[16]=_,e[17]=p,e[18]=l,e[19]=S,e[20]=n,e[21]=w,e[22]=j,e[23]=k,e[24]=b,e[25]=ae):ae=e[25];const Ee=ae;let Se;e[26]!==n.path||e[27]!==r?(Se=he=>{Cf(he);const ie=al(r,n.path);!ie||ie==="."||(he.dataTransfer.setData("application/x-openchamber-file-path",ie),he.dataTransfer.effectAllowed="copy")},e[26]=n.path,e[27]=r,e[28]=Se):Se=e[28];const me=Se;let ke;e[29]!==ce?(ke=he=>{Nf(he)&&ce()},e[29]=ce,e[30]=ke):ke=e[30];const V=ke;let J;e[31]!==m||e[32]!==h||e[33]!==v?(J=he=>{!m||!v||!kr(he.dataTransfer)||(he.preventDefault(),he.stopPropagation(),he.dataTransfer.dropEffect="copy",h(v))},e[31]=m,e[32]=h,e[33]=v,e[34]=J):J=e[34];const de=J;let we;e[35]!==m||e[36]!==h||e[37]!==v?(we=he=>{!m||!v||!kr(he.dataTransfer)||he.relatedTarget instanceof Node&&he.currentTarget.contains(he.relatedTarget)||(he.stopPropagation(),h(null))},e[35]=m,e[36]=h,e[37]=v,e[38]=we):we=e[38];const G=we;let Ce;e[39]!==m||e[40]!==g||e[41]!==v?(Ce=he=>{!m||!v||!kr(he.dataTransfer)||(he.preventDefault(),he.stopPropagation(),g(v,he.dataTransfer))},e[39]=m,e[40]=g,e[41]=v,e[42]=Ce):Ce=e[42];const Te=Ce;let pe;e[43]===Symbol.for("react.memo_cache_sentinel")?(pe={contentVisibility:"auto",blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[43]=pe):pe=e[43];let ne;e[44]!==X||e[45]!==G||e[46]!==de||e[47]!==Te?(ne=s.jsx("div",{className:"group relative flex items-center typography-meta",style:pe,onContextMenu:X,onDragEnter:de,onDragOver:de,onDragLeave:G,onDrop:Te}),e[44]=X,e[45]=G,e[46]=de,e[47]=Te,e[48]=ne):ne=e[48];const xe=u?"bg-interactive-selection ring-2 ring-inset ring-primary":o?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let U;e[49]!==xe?(U=Re("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",xe),e[49]=xe,e[50]=U):U=e[50];let z;e[51]!==S||e[52]!==i||e[53]!==n.extension||e[54]!==n.path?(z=S?i?s.jsx(F,{name:"folder-open",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):s.jsx(F,{name:"folder-3",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):Af(n.path,n.extension),e[51]=S,e[52]=i,e[53]=n.extension,e[54]=n.path,e[55]=z):z=e[55];let Q;e[56]!==n.name||e[57]!==n.path?(Q=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:n.path,children:n.name}),e[56]=n.name,e[57]=n.path,e[58]=Q):Q=e[58];let ue;e[59]!==S||e[60]!==a?(ue=!S&&a&&s.jsx(O1,{status:a}),e[59]=S,e[60]=a,e[61]=ue):ue=e[61];let le;e[62]!==d||e[63]!==S?(le=S&&d&&s.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[d.modified>0&&s.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",d.modified]}),d.added>0&&s.jsxs("span",{className:"text-[var(--status-success)]",children:["+",d.added]})]}),e[62]=d,e[63]=S,e[64]=le):le=e[64];let W;e[65]!==X||e[66]!==V||e[67]!==me||e[68]!==ce||e[69]!==U||e[70]!==z||e[71]!==Q||e[72]!==ue||e[73]!==le?(W=s.jsxs("button",{type:"button",onClick:ce,onContextMenu:X,draggable:!0,onDragStart:me,onDragEnd:V,className:U,children:[z,Q,ue,le]}),e[65]=X,e[66]=V,e[67]=me,e[68]=ce,e[69]=U,e[70]=z,e[71]=Q,e[72]=ue,e[73]=le,e[74]=W):W=e[74];let E;e[75]!==L||e[76]!==Y||e[77]!==Ee||e[78]!==b?(E=Y&&s.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 focus-within:opacity-100 group-hover:opacity-100",children:s.jsxs($s,{open:L,onOpenChange:A,children:[s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(_s,{asChild:!0,children:s.jsx(ut,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:ge,title:b("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":b("sidebarFilesTree.actions.fileMenuTitle"),children:s.jsx(F,{name:"more-2-fill",className:"h-4 w-4"})})})})}),s.jsx(St,{side:"bottom",sideOffset:6,children:b("sidebarFilesTree.actions.fileMenuTitle")})]}),s.jsx(Ls,{align:"end",side:"bottom",onCloseAutoFocus:()=>A(!1),children:Ee({Item:Ht,Separator:As})})]})}),e[75]=L,e[76]=Y,e[77]=Ee,e[78]=b,e[79]=E):E=e[79];let K;e[80]!==ne||e[81]!==W||e[82]!==E?(K=s.jsxs(eu,{render:ne,children:[W,E]}),e[80]=ne,e[81]=W,e[82]=E,e[83]=K):K=e[83];let te;e[84]!==Ee?(te=s.jsx(Zd,{className:"min-w-[180px]",children:Ee({Item:tr,Separator:Xi})}),e[84]=Ee,e[85]=te):te=e[85];let oe;return e[86]!==D||e[87]!==K||e[88]!==te?(oe=s.jsxs(tu,{open:D,onOpenChange:P,children:[K,te]}),e[86]=D,e[87]=K,e[88]=te,e[89]=oe):oe=e[89],oe},F1=(t,e)=>t.node===e.node&&t.root===e.root&&t.isExpanded===e.isExpanded&&t.isActive===e.isActive&&t.isBrowserClient===e.isBrowserClient&&t.status===e.status&&t.badge===e.badge&&t.isDropTarget===e.isDropTarget&&t.canUpload===e.canUpload&&t.permissions===e.permissions&&t.downloadFile===e.downloadFile&&t.onSelect===e.onSelect&&t.onToggle===e.onToggle&&t.onRevealPath===e.onRevealPath&&t.onOpenDialog===e.onOpenDialog&&t.onSetDropTarget===e.onSetDropTarget&&t.onDropFiles===e.onDropFiles&&t.onPickFiles===e.onPickFiles,_1=c.memo(B1,F1),L1=t=>{const e=et.c(6),{visible:n}=t,r=n===void 0?!0:n,i=Mn(z1),o=mr();let l;e[0]!==o||e[1]!==i?(l=JSON.stringify([i,o]),e[0]=o,e[1]=i,e[2]=l):l=e[2];let a;return e[3]!==l||e[4]!==r?(a=s.jsx($1,{visible:r},l),e[3]=l,e[4]=r,e[5]=a):a=e[5],a},$1=({visible:t})=>{const e=c.useRef(t);e.current=t;const{t:n}=kt(),{files:r,runtime:i}=kn(),o=th(i.platform),l=mr()??"",a=gs(l.trim()),d=ll(a),u=sh(),m=nh(),f=Vd(be=>be.searchFiles),p=Pe(be=>be.openContextFile),y=Ua(t?l:null),[x,k]=c.useState(""),w=Iu(x,200),h=c.useRef(null),[g,j]=c.useState([]),[b,S]=c.useState(!1),[C,v]=c.useState(null),[M,R]=c.useState({}),[I,B]=c.useState({}),O=c.useRef(new Set),T=c.useMemo(()=>new eb,[]);c.useEffect(()=>()=>T.clear(),[T]);const $=c.useRef(null);c.useEffect(()=>{if(v(null),!a){R({}),B({}),O.current=new Set;return}const be=M1(a);be?(R({...be.childrenByDir}),B({...be.loadErrorsByDir}),O.current=new Set(be.loadedDirs)):(R({}),B({}),O.current=new Set)},[a]),c.useEffect(()=>{if(!a)return;const be=Li(a);be.childrenByDir=M},[a,M]),c.useEffect(()=>{if(!a)return;const be=Li(a);be.loadErrorsByDir=I},[a,I]),c.useEffect(()=>{if(!a)return;const be=Li(a);be.loadedDirs=new Set(O.current)},[a,M,I]),c.useEffect(()=>()=>{if(!a)return;const be=wn.get(d);be&&be.loadedDirs.size===0&&Object.keys(be.childrenByDir).length===0&&wn.delete(d)},[d,a]);const _=c.useMemo(()=>[],[]),Y=c.useMemo(()=>[],[]),L=yn(be=>a?be.byRoot[a]?.expandedPaths??_:_),A=c.useMemo(()=>new Set(L),[L]),D=yn(be=>a?be.byRoot[a]?.selectedPath??null:null),P=yn(be=>be.setSelectedPath),Z=yn(be=>be.addOpenPath),X=yn(be=>be.removeOpenPathsByPrefix),se=yn(be=>be.toggleExpandedPath),ce=yn(be=>be.collapseAllExpandedPaths),re=Pe(be=>a?be.contextPanelByDirectory[a]?.tabs??Y:Y),ge=c.useMemo(()=>new Set(re.map(be=>be.mode==="file"?be.targetPath:null).filter(be=>typeof be=="string"&&be.length>0).map(be=>gs(be))),[re]),[ae,Ee]=c.useState(null),[Se,me]=c.useState(null),[ke,V]=c.useState(""),[J,de]=c.useState(!1),we=!!r.writeFile,G=!!r.createDirectory,Ce=!!r.rename,Te=!!r.delete,pe=!!r.revealPath,ne=c.useMemo(()=>({canRename:Ce,canCreateFile:we,canCreateFolder:G,canDelete:Te,canReveal:pe}),[Ce,we,G,Te,pe]),xe=c.useCallback(be=>{r.revealPath&&r.revealPath(be).catch(()=>{ze.error(n("sidebarFilesTree.toast.revealFailed"))})},[r,n]),U=c.useCallback((be,Je)=>{Ee(be),me(Je),V(be==="rename"&&Je.name||""),de(!1)},[]),z=c.useCallback((be,Je)=>{const dt=Je.filter(Ke=>Ke&&typeof Ke.name=="string"&&Ke.name.length>0).filter(Ke=>u||!Ke.name.startsWith(".")).filter(Ke=>m||!T1(Ke.name)).map(Ke=>{const mt=Ke.name,ee=gs(Ke.path||""),fe=ee?D1(ee)?ee:gs(`${be}/${ee}`):gs(`${be}/${mt}`),Ie=Ke.isDirectory?"directory":"file",$e=Ie==="file"&&mt.includes(".")?mt.split(".").pop()?.toLowerCase():void 0;return{name:mt,path:fe,type:Ie,extension:$e}});return N1(dt)},[m,u]),Q=c.useCallback(async(be,Je,dt=!1)=>{if(!e.current||Je?.())return;const Ke=gs(be.trim());if(!Ke||!dt&&O.current.has(Ke))return;const mt=Qt();return T.run(Ke,async ee=>{const fe=()=>!ee()||Qt()!==mt;try{const Ie=r.listDirectory?(await r.listDirectory(Ke)).entries:await fn.listLocalDirectory(Ke);if(fe())return;const $e=z(Ke,Ie);O.current=new Set(O.current),O.current.add(Ke),B(H=>{if(!H[Ke])return H;const Be={...H};return delete Be[Ke],Be}),R(H=>H[Ke]&&tb(H[Ke],$e)?H:{...H,[Ke]:$e})}catch(Ie){if(fe())return;const $e=Ie instanceof Error?Ie.message:String(Ie??"");console.error("Failed to load sidebar directory:",Ie),B(H=>({...H,[Ke]:$e}))}},dt)},[T,r,z]),ue=c.useCallback(async()=>{if(!a)return;$.current?.abort();const be=new AbortController;$.current=be,T.clear();try{const dt=(yn.getState().byRoot[a]?.expandedPaths??[]).map(ee=>gs(ee)).filter(ee=>!!ee&&ee!==a&&ee.startsWith(`${a}/`)),Ke=[a,...dt];O.current=new Set(O.current);for(const ee of Ke)O.current.delete(ee);B(ee=>{if(Object.keys(ee).length===0)return ee;const fe={...ee};let Ie=!1;for(const $e of Ke)$e in fe&&(delete fe[$e],Ie=!0);return Ie?fe:ee});const mt=()=>be.signal.aborted;await Q(a,mt);for(let ee=0;ee<dt.length&&!be.signal.aborted;ee+=3){const fe=dt.slice(ee,ee+3);await Promise.all(fe.map(Ie=>Q(Ie,mt)))}}catch(Je){if(be.signal.aborted)return;console.error("Failed to refresh sidebar tree:",Je)}finally{$.current===be&&($.current=null)}},[T,Q,a]),le=c.useCallback(async be=>{if(!be){await ue();return}const Je=gs(be);O.current=new Set(O.current),O.current.delete(Je),await Q(Je,void 0,!0)},[Q,ue]);c.useEffect(()=>{a&&($.current?.abort(),O.current=new Set,T.clear(),B({}),R(be=>Object.keys(be).length===0?be:{}),Q(a))},[T,Q,a,u,m]),c.useEffect(()=>{if(!t||!a||L.length===0)return;const be=L.map(Ke=>gs(Ke)).filter(Ke=>!!Ke&&Ke!==a&&Ke.startsWith(`${a}/`)&&!O.current.has(Ke)&&!T.has(Ke)).sort((Ke,mt)=>Ke.split("/").length-mt.split("/").length);if(be.length===0)return;let Je=!1;const dt=()=>Je;return(async()=>{for(let Ke=0;Ke<be.length&&!Je;Ke+=3){const mt=be.slice(Ke,Ke+3);await Promise.all(mt.map(ee=>Q(ee,dt)))}})(),()=>{Je=!0}},[T,L,Q,a,t]);const W=c.useRef(t);c.useEffect(()=>{const be=t&&!W.current;W.current=t,be&&ue()},[ue,t]),c.useEffect(()=>{if(!t)return;if(!l){j([]),S(!1);return}const be=w.trim();if(!be){j([]),S(!1);return}let Je=!1;return S(!0),f(l,be,150,{includeHidden:u,respectGitignore:!m,type:"file"}).then(dt=>{if(Je)return;const mt=dt.filter(ee=>m||!E1(ee.path)).map(ee=>({name:ee.name,path:gs(ee.path),type:"file",extension:ee.extension,relativePath:ee.relativePath}));j(mt)}).catch(()=>{Je||j([])}).finally(()=>{Je||S(!1)}),()=>{Je=!0}},[l,w,f,u,m,t]);const E=c.useMemo(()=>{const be=new Map;if(!y?.files)return be;for(const Je of y.files)Je.index==="A"||Je.working_dir==="?"?be.set(Je.path,"git-added"):Je.index==="D"?be.set(Je.path,"git-deleted"):(Je.index==="M"||Je.working_dir==="M")&&be.set(Je.path,"git-modified");return be},[y]),K=c.useMemo(()=>{const be=new Map;if(!y?.files||!a)return be;for(const Je of y.files){const dt=Je.index==="M"||Je.working_dir==="M",Ke=Je.index==="A"||Je.working_dir==="?";if(!dt&&!Ke)continue;const mt=Je.path.split("/");if(mt.length<=1)continue;let ee=a;for(let fe=0;fe<mt.length-1;fe++){ee=`${ee}/${mt[fe]}`;let Ie=be.get(ee);Ie||(Ie={modified:0,added:0},be.set(ee,Ie)),dt&&Ie.modified++,Ke&&Ie.added++}}return be},[y,a]),te=c.useCallback(be=>{if(ge.has(be))return"open";if(E.size===0)return null;const Je=be.startsWith(a+"/")?be.slice(a.length+1):be;return E.get(Je)??null},[ge,E,a]),oe=c.useCallback(be=>{if(K.size===0)return null;const Je=K.get(be);return Je&&Je.modified+Je.added>0?Je:null},[K]),he=c.useCallback(async be=>{if(!a)return;const Je=await jf(r,be.path,{directory:a});if(!Je.ok){ze.error(kf(Je.reason));return}P(a,be.path),Z(a,be.path),p(a,be.path)},[Z,r,p,a,P]),ie=c.useCallback(async be=>{const Je=gs(be);a&&(se(a,Je),O.current.has(Je)||await Q(Je))},[Q,a,se]),{canUpload:Fe,uploadingDirectory:_e,uploadFiles:Ae,pickFiles:Me,uploadElements:q}=Mh({root:a,refreshDirectory:le}),Ne=_e!==null,je=_e??C,We=c.useCallback((be,Je)=>{const dt=C1(Je);dt.length!==0&&(v(null),Ae(be,dt))},[Ae]),tt=c.useCallback(be=>{!Fe||Ne||!a||!kr(be.dataTransfer)||(be.preventDefault(),be.dataTransfer.dropEffect="copy",v(a))},[Fe,Ne,a]),it=c.useCallback(be=>{kr(be.dataTransfer)&&(be.relatedTarget instanceof Node&&be.currentTarget.contains(be.relatedTarget)||v(null))},[]),rt=c.useCallback(be=>{!Fe||Ne||!a||!kr(be.dataTransfer)||(be.preventDefault(),We(a,be.dataTransfer))},[Fe,We,Ne,a]),ot=c.useCallback(async be=>{if(be?.preventDefault(),!Se||!ae)return;de(!0);const Je=()=>de(!1),dt=()=>Ee(null);if(ae==="createFile"){if(!ke.trim()){ze.error(n("sidebarFilesTree.toast.filenameRequired")),Je();return}if(!r.writeFile){ze.error(n("sidebarFilesTree.toast.writeNotSupported")),Je();return}const Ke=Se.path,mt=Ke?`${Ke}/`:"",ee=gs(`${mt}${ke.trim()}`);await r.writeFile(ee,"").then(async fe=>{fe.success&&(ze.success(n("sidebarFilesTree.toast.fileCreated")),await le(Ke)),dt()}).catch(()=>ze.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Je);return}if(ae==="createFolder"){if(!ke.trim()){ze.error(n("sidebarFilesTree.toast.folderNameRequired")),Je();return}const Ke=Se.path,mt=Ke?`${Ke}/`:"",ee=gs(`${mt}${ke.trim()}`);await r.createDirectory(ee).then(async fe=>{fe.success&&(ze.success(n("sidebarFilesTree.toast.folderCreated")),await le(Ke)),dt()}).catch(()=>ze.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Je);return}if(ae==="rename"){if(!ke.trim()){ze.error(n("sidebarFilesTree.toast.nameRequired")),Je();return}if(!r.rename){ze.error(n("sidebarFilesTree.toast.renameNotSupported")),Je();return}const Ke=Se.path,mt=Ke.split("/").slice(0,-1).join("/"),ee=mt?`${mt}/`:"",fe=gs(`${ee}${ke.trim()}`);await r.rename(Ke,fe).then(async Ie=>{Ie.success&&(ze.success(n("sidebarFilesTree.toast.renamedSuccessfully")),await le(mt),a&&X(a,Ke),(D===Ke||D&&D.startsWith(`${Ke}/`))&&P(a,null)),dt()}).catch(()=>ze.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Je);return}if(ae==="delete"){if(!r.delete){ze.error(n("sidebarFilesTree.toast.deleteNotSupported")),Je();return}const Ke=Se.path,mt=Ke.split("/").slice(0,-1).join("/");await r.delete(Ke).then(async ee=>{ee.success&&(ze.success(n("sidebarFilesTree.toast.deletedSuccessfully")),await le(mt),a&&X(a,Ke),(D===Ke||D&&D.startsWith(Ke+"/"))&&P(a,null)),dt()}).catch(()=>ze.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Je);return}Je()},[ae,Se,ke,r,le,X,a,D,P,n]);function ft(be,Je){const dt=M[be]??[];return dt.map((Ke,mt)=>{const ee=Ke.type==="directory",fe=ee&&A.has(Ke.path),Ie=D===Ke.path,$e=mt===dt.length-1;return s.jsxs("li",{className:"relative",children:[Je>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),$e&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-sidebar/50"})]}),s.jsx(_1,{node:Ke,root:a,isExpanded:fe,isActive:Ie,isBrowserClient:o,status:ee?void 0:te(Ke.path),badge:ee?oe(Ke.path):void 0,isDropTarget:ee&&je===Ke.path,canUpload:Fe&&!Ne,permissions:ne,downloadFile:r.downloadFile,onSelect:he,onToggle:ie,onRevealPath:xe,onOpenDialog:U,onSetDropTarget:v,onDropFiles:We,onPickFiles:Me}),ee&&fe&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[I[Ke.path]?s.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:I[Ke.path],children:I[Ke.path]}),s.jsxs(ut,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{le(Ke.path)},children:[s.jsx(F,{name:"refresh",className:"h-3.5 w-3.5"}),n("sidebarFilesTree.actions.refreshTitle")]})]}):null,ft(Ke.path,Je+1)]})]},Ke.path)})}const st=!!(a&&M[a]),Ct=a?I[a]:null,ht=je?A1(a,je):"";return s.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex flex-col gap-2 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[we&&s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>U("createFile",{path:l,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.newFileTitle"),"aria-label":n("sidebarFilesTree.actions.newFileTitle"),children:s.jsx(F,{name:"file-add",className:"h-4 w-4"})})})}),s.jsx(St,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.newFileTitle")})]}),G&&s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>U("createFolder",{path:l,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.newFolderTitle"),"aria-label":n("sidebarFilesTree.actions.newFolderTitle"),children:s.jsx(F,{name:"folder-add",className:"h-4 w-4"})})})}),s.jsx(St,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.newFolderTitle")})]}),Fe&&s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>Me(a),disabled:!a||Ne,className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.uploadFilesTitle"),"aria-label":n("sidebarFilesTree.actions.uploadFilesTitle"),children:s.jsx(F,{name:"upload-2",className:"h-4 w-4"})})})}),s.jsx(St,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.uploadFilesTitle")})]}),s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>{ue()},className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.refreshTitle"),"aria-label":n("sidebarFilesTree.actions.refreshTitle"),children:s.jsx(F,{name:"refresh",className:"h-4 w-4"})})})}),s.jsx(St,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.refreshTitle")})]}),s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>{a&&ce(a)},className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.collapseAllTitle"),"aria-label":n("sidebarFilesTree.actions.collapseAllTitle"),children:s.jsx(F,{name:"collapse-vertical",className:"h-4 w-4"})})})}),s.jsx(St,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.collapseAllTitle")})]})]}),s.jsxs("div",{className:"relative min-w-0",children:[s.jsx(F,{name:"search",className:"pointer-events-none absolute left-2 top-2 h-4 w-4 text-muted-foreground"}),s.jsx(In,{ref:h,value:x,onChange:be=>k(be.target.value),placeholder:n("sidebarFilesTree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),x.trim().length>0?s.jsx("button",{type:"button","aria-label":n("sidebarFilesTree.search.clearAria"),className:"absolute right-2 top-2 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{k(""),h.current?.focus()},children:s.jsx(F,{name:"close",className:"h-4 w-4"})}):null]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx(On,{outerClassName:"h-full min-h-0",className:Re("p-2",je===a&&"bg-interactive-selection/10"),onDragEnter:tt,onDragOver:tt,onDragLeave:it,onDrop:rt,children:s.jsx("ul",{className:"flex flex-col",children:b?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(F,{name:"loader-4",className:"h-4 w-4 animate-spin"}),n("sidebarFilesTree.state.searching")]}):g.length>0?g.map(be=>{const Je=D===be.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>he(be),draggable:!0,onDragStart:dt=>{Cf(dt);const Ke=be.relativePath||al(a??"",be.path);!Ke||Ke==="."||(dt.dataTransfer.setData("application/x-openchamber-file-path",Ke),dt.dataTransfer.effectAllowed="copy")},onDragEnd:dt=>{Nf(dt)&&he(be)},className:Re("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",Je?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),title:be.path,children:[Af(be.path,be.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},children:be.relativePath??be.path})]})},be.path)}):Ct?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{children:Ct}),s.jsxs(ut,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{ue()},children:[s.jsx(F,{name:"refresh",className:"h-3.5 w-3.5"}),n("sidebarFilesTree.actions.refreshTitle")]})]}):st&&a?ft(a,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:n("sidebarFilesTree.state.loading")})})}),je?s.jsxs("div",{className:"pointer-events-none absolute left-2 right-2 top-2 z-50 flex items-center gap-2 rounded-md border border-primary bg-background/95 px-2 py-1.5 shadow-sm",children:[s.jsx(F,{name:Ne?"loader-4":"folder-received",className:Re("size-4 flex-shrink-0",Ne&&"animate-spin")}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:ht,children:n(Ne?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:ht})})]}):null]}),q,s.jsx(Ds,{open:!!ae,onOpenChange:be=>!be&&Ee(null),children:s.jsxs(Is,{children:[s.jsxs(sn,{children:[s.jsxs(Hs,{children:[ae==="createFile"&&n("sidebarFilesTree.dialog.createFile.title"),ae==="createFolder"&&n("sidebarFilesTree.dialog.createFolder.title"),ae==="rename"&&n("sidebarFilesTree.dialog.rename.title"),ae==="delete"&&n("sidebarFilesTree.dialog.delete.title")]}),s.jsxs(Gs,{children:[ae==="createFile"&&n("sidebarFilesTree.dialog.createFile.description",{path:Se?.path??n("sidebarFilesTree.dialog.rootFallback")}),ae==="createFolder"&&n("sidebarFilesTree.dialog.createFolder.description",{path:Se?.path??n("sidebarFilesTree.dialog.rootFallback")}),ae==="rename"&&n("sidebarFilesTree.dialog.rename.description",{name:Se?.name??""}),ae==="delete"&&n("sidebarFilesTree.dialog.delete.description",{name:Se?.name??""})]})]}),ae!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(In,{value:ke,onChange:be=>V(be.target.value),placeholder:n(ae==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:be=>{be.key==="Enter"&&ot()},autoFocus:!0})}),s.jsxs(Un,{children:[s.jsx(ut,{variant:"outline",onClick:()=>Ee(null),disabled:J,children:n("sidebarFilesTree.dialog.cancel")}),s.jsx(ut,{variant:ae==="delete"?"destructive":"default",onClick:()=>{ot()},disabled:J||ae!=="delete"&&!ke.trim(),children:J?s.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):n(ae==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})})]})};function z1(t){return t.runtimeKey}const kc=60,W1=t=>{try{return new URL(t).origin}catch{return""}},$i=new Set,Pf=oo()((t,e)=>({byOrigin:{},resolve:(n,r)=>{const i=W1(n);!i||!r||e().byOrigin[i]||$i.has(i)||($i.add(i),jr("desktop_browser_fetch_favicon",{url:r}).then(o=>{const l=typeof o?.dataUrl=="string"?o.dataUrl:"";l&&t(a=>{const d={...a.byOrigin,[i]:l},u=Object.keys(d);if(u.length<=kc)return{byOrigin:d};for(const m of u.slice(0,u.length-kc))delete d[m];return{byOrigin:d}})}).catch(()=>{}).finally(()=>{$i.delete(i)}))}})),cl=t=>t,wa=t=>{const e=cl(t).type;return typeof e=="string"?e:""},K1=t=>{const e=cl(t).tool;return typeof e=="string"?e:""},V1=t=>{const e=cl(t).text;return typeof e=="string"?e:""},U1=t=>{const e=wa(t);return e==="tool"?K1(t).trim().toLowerCase()||"tool":e||"unknown"},H1=t=>{if(t.length===0)return"";const e=[];for(const n of t){const r=U1(n);e.includes(r)||e.push(r)}return e.join(" + ")},G1=t=>t.replace(/\s+/g," ").trim(),q1=t=>{for(const n of t)if(wa(n)==="text"){const r=G1(V1(n));if(r.length===0)continue;return r}const e=t.filter(n=>wa(n)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},Y1=(t,e,n)=>`${n(t)} / ${n(e)}`,Q1=t=>{if(t==="12h")return!0;if(t==="24h")return!1},X1=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const n=Q1(e);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:n===!1?"2-digit":"numeric",minute:"2-digit",...n===void 0?{}:{hour12:n}})},va={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},Ro={user:0,assistant:0,tool:0,other:0},Ln=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,Cc=t=>{const e=t.info.tokens,n=e!==void 0?e:t.parts.find(m=>m.tokens!==void 0)?.tokens;if(typeof n=="number")return{...va,total:Ln(n)};if(!n||typeof n!="object")return va;const r=n,i=Ln(r.input),o=Ln(r.output),l=Ln(r.reasoning),a=Ln(r.cache?.read),d=Ln(r.cache?.write),u=Ln(r.total);return{input:i,output:o,reasoning:l,cacheRead:a,cacheWrite:d,total:u>0?u:i+o+l+a+d}},J1=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},Ks=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,n)=>e+Ks(n),0):t&&typeof t=="object"?Object.values(t).reduce((e,n)=>e+Ks(n),0):0,Z1=(t,e)=>{const n=t,r=typeof n.type=="string"?n.type:"";if(r==="reasoning")return{...Ro,assistant:Ks(n.text)+Ks(n.content)};const i=J1(n.text,n.content,n.value,n.source?.value,n.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:Ks(n.input)+Ks(n.output)+Ks(n.error)+Ks(n.call?.input)+Ks(n.call?.output)+Ks(n.call?.error)+Ks(n.raw)+Math.round(Ks(n.metadata)*.25)+Math.round(Ks(n.state)*.1),other:0}:e==="user"?{user:i.length,assistant:0,tool:0,other:0}:e==="assistant"?{user:0,assistant:i.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:i.length}},Nc=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),ew=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",tw=(t,e)=>{if(t.length===0)return{...Ro};const n=t.reduce((r,i)=>{const o=ew(i);let l={...Ro};for(const a of i.parts)l=Nc(l,Z1(a,o));return Nc(r,l)},{...Ro});return n.user+=e.length,{user:Math.ceil(n.user/4),assistant:Math.ceil(n.assistant/4),tool:Math.ceil(n.tool/4),other:Math.ceil(n.other/4)}},Jn=t=>t.toLocaleString(Du()),sw=(t,e)=>!t||!Number.isFinite(t)?"-":Cu(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),nw=(t,e,n)=>{const r=t.find(o=>o.id===e),i=r?.models?.find(o=>o.id===n);return{providerName:r?.name||e||"-",modelName:i?.name||n||"-",contextLimit:typeof i?.limit?.context=="number"?i.limit.context:null}},rw=()=>{const t=et.c(209),{t:e}=kt(),n=Pe(ow);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},t[0]=r):r=t[0];const[i,o]=c.useState(r),[l,a]=c.useState(null),d=c.useRef(null),u=nt(iw),m=nt(aw),f=Tu(m??void 0),p=Gp(u??"",m??void 0),y=Ut(lw);let x;t[1]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),o(cw),a(null)},t[1]=x):x=t[1];let k;t[2]!==m||t[3]!==u?(k=[m,u],t[2]=m,t[3]=u,t[4]=k):k=t[4],c.useEffect(x,k);let w,h;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=()=>()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)},h=[],t[5]=w,t[6]=h):(w=t[5],h=t[6]),c.useEffect(w,h);let g;t[7]===Symbol.for("react.memo_cache_sentinel")?(g=async(Ue,He)=>{(await fr(He)).ok?(a(Ue),d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{a(Qe=>Qe===Ue?null:Qe),d.current=null},2e3)):a(null)},t[7]=g):g=t[7];const j=g;let b;t[8]!==u||t[9]!==f?(b=u?f.find(Ue=>Ue.id===u)??null:null,t[8]=u,t[9]=f,t[10]=b):b=t[10];const S=b;let C,v,M,R,I,B,O;if(t[11]!==p){C=p.filter(dw),O=p.filter(uw);const Ue=qp(p.map(fw));M=Ue?p[Ue.index]??null:null,R=Ue?.state==="compacted";let He;t[19]!==M?(B=M?Cc(M):va,He=Yp({input:B.input,cache:{read:B.cacheRead,write:B.cacheWrite}}),t[19]=M,t[20]=He,t[21]=B):(He=t[20],B=t[21]),v=He,I=C.reduce(mw,0),t[11]=p,t[12]=C,t[13]=v,t[14]=M,t[15]=R,t[16]=I,t[17]=B,t[18]=O}else C=t[12],v=t[13],M=t[14],R=t[15],I=t[16],B=t[17],O=t[18];const T=I,$=M?.info??null,_=y,Y=$?.providerID||"",L=$?.modelID||"";let A;t[22]!==L||t[23]!==_||t[24]!==Y?(A=nw(_,Y,L),t[22]=L,t[23]=_,t[24]=Y,t[25]=A):A=t[25];const D=A,P=D.contextLimit,Z=R?null:P&&P>0?Math.min(999,B.total/P*100):0;let X;if(t[26]!==p){const Ue=[...p].reverse().find(hw),He=Ue?.info.role==="system"?Ue.info.text:"";X=tw(p,He),t[26]=p,t[27]=X}else X=t[27];const se=X,ce=se.user,re=se.assistant,ge=se.tool,ae=Math.max(0,B.input-ce-re-ge),Ee=ce+re+ge+ae,Se=p[0]?.info?.time?.created,me=p.length>0?p[p.length-1]?.info?.time?.created:null;let ke;t[28]!==S?.title||t[29]!==e?(ke=S?.title||e("contextSidebar.session.untitled"),t[28]=S?.title,t[29]=e,t[30]=ke):ke=t[30];const V=S?.time?.created??Se??null,J=me??S?.time?.created??null;let de;t[31]!==re||t[32]!==ae||t[33]!==ge||t[34]!==ce?(de={user:ce,assistant:re,tool:ge,other:ae},t[31]=re,t[32]=ae,t[33]=ge,t[34]=ce,t[35]=de):de=t[35];let we;t[36]!==C.length||t[37]!==Ee||t[38]!==v||t[39]!==P||t[40]!==D||t[41]!==p.length||t[42]!==ke||t[43]!==V||t[44]!==J||t[45]!==de||t[46]!==B||t[47]!==T||t[48]!==Z||t[49]!==O.length?(we={sessionTitle:ke,messagesCount:p.length,userMessagesCount:O.length,assistantMessagesCount:C.length,createdAt:V,lastActivityAt:J,providerModel:D,tokenBreakdown:B,usagePercent:Z,cacheHitRate:v,totalAssistantCost:T,contextLimit:P,breakdown:de,breakdownTotal:Ee},t[36]=C.length,t[37]=Ee,t[38]=v,t[39]=P,t[40]=D,t[41]=p.length,t[42]=ke,t[43]=V,t[44]=J,t[45]=de,t[46]=B,t[47]=T,t[48]=Z,t[49]=O.length,t[50]=we):we=t[50];const G=we;if(!u){let Ue;t[51]!==e?(Ue=e("contextSidebar.empty.openSession"),t[51]=e,t[52]=Ue):Ue=t[52];let He;return t[53]!==Ue?(He=s.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:Ue}),t[53]=Ue,t[54]=He):He=t[54],He}let Ce;t[55]!==e?(Ce=e("contextSidebar.breakdown.user"),t[55]=e,t[56]=Ce):Ce=t[56];let Te;t[57]!==Ce||t[58]!==G.breakdown.user?(Te={key:"user",label:Ce,value:G.breakdown.user,color:"var(--status-success)"},t[57]=Ce,t[58]=G.breakdown.user,t[59]=Te):Te=t[59];let pe;t[60]!==e?(pe=e("contextSidebar.breakdown.assistant"),t[60]=e,t[61]=pe):pe=t[61];let ne;t[62]!==pe||t[63]!==G.breakdown.assistant?(ne={key:"assistant",label:pe,value:G.breakdown.assistant,color:"var(--primary-base)"},t[62]=pe,t[63]=G.breakdown.assistant,t[64]=ne):ne=t[64];let xe;t[65]!==e?(xe=e("contextSidebar.breakdown.toolCalls"),t[65]=e,t[66]=xe):xe=t[66];let U;t[67]!==xe||t[68]!==G.breakdown.tool?(U={key:"tool",label:xe,value:G.breakdown.tool,color:"var(--status-warning)"},t[67]=xe,t[68]=G.breakdown.tool,t[69]=U):U=t[69];let z;t[70]!==e?(z=e("contextSidebar.breakdown.other"),t[70]=e,t[71]=z):z=t[71];let Q;t[72]!==z||t[73]!==G.breakdown.other?(Q={key:"other",label:z,value:G.breakdown.other,color:"var(--surface-muted-foreground)"},t[72]=z,t[73]=G.breakdown.other,t[74]=Q):Q=t[74];let ue;t[75]!==Te||t[76]!==ne||t[77]!==U||t[78]!==Q?(ue=[Te,ne,U,Q],t[75]=Te,t[76]=ne,t[77]=U,t[78]=Q,t[79]=ue):ue=t[79];const le=ue;let W;t[80]!==G.sessionTitle?(W=s.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:G.sessionTitle}),t[80]=G.sessionTitle,t[81]=W):W=t[81];let E;t[82]!==G.providerModel.modelName||t[83]!==G.providerModel.providerName?(E=s.jsxs("span",{children:[G.providerModel.providerName," / ",G.providerModel.modelName]}),t[82]=G.providerModel.modelName,t[83]=G.providerModel.providerName,t[84]=E):E=t[84];let K;t[85]!==n||t[86]!==G.createdAt?(K=G.createdAt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsx("span",{children:sw(G.createdAt,n)})]}),t[85]=n,t[86]=G.createdAt,t[87]=K):K=t[87];let te;t[88]!==E||t[89]!==K?(te=s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground/70",children:[E,K]}),t[88]=E,t[89]=K,t[90]=te):te=t[90];let oe;t[91]!==W||t[92]!==te?(oe=s.jsxs("div",{className:"mb-6",children:[W,te]}),t[91]=W,t[92]=te,t[93]=oe):oe=t[93];let he;t[94]!==e?(he=e("contextSidebar.section.context"),t[94]=e,t[95]=he):he=t[95];let ie;t[96]!==he?(ie=s.jsx("span",{className:"typography-micro text-muted-foreground",children:he}),t[96]=he,t[97]=ie):ie=t[97];let Fe;t[98]!==G.tokenBreakdown.total||t[99]!==G.usagePercent?(Fe=G.usagePercent===null?"—":Jn(G.tokenBreakdown.total),t[98]=G.tokenBreakdown.total,t[99]=G.usagePercent,t[100]=Fe):Fe=t[100];let _e;t[101]!==G.contextLimit?(_e=G.contextLimit?` / ${Jn(G.contextLimit)}`:"",t[101]=G.contextLimit,t[102]=_e):_e=t[102];let Ae;t[103]!==Fe||t[104]!==_e?(Ae=s.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[Fe,_e]}),t[103]=Fe,t[104]=_e,t[105]=Ae):Ae=t[105];let Me;t[106]!==ie||t[107]!==Ae?(Me=s.jsxs("div",{className:"flex items-baseline justify-between",children:[ie,Ae]}),t[106]=ie,t[107]=Ae,t[108]=Me):Me=t[108];let q;t[109]!==G.usagePercent?(q=G.usagePercent!==null&&G.usagePercent>0&&s.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,G.usagePercent)}%`,backgroundColor:G.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[109]=G.usagePercent,t[110]=q):q=t[110];let Ne;t[111]!==q?(Ne=s.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:q}),t[111]=q,t[112]=Ne):Ne=t[112];let je;t[113]!==e||t[114]!==G.usagePercent?(je=G.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:G.usagePercent.toFixed(1)}),t[113]=e,t[114]=G.usagePercent,t[115]=je):je=t[115];let We;t[116]!==je?(We=s.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:je}),t[116]=je,t[117]=We):We=t[117];let tt;t[118]!==Me||t[119]!==Ne||t[120]!==We?(tt=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[Me,Ne,We]}),t[118]=Me,t[119]=Ne,t[120]=We,t[121]=tt):tt=t[121];let it;t[122]!==e?(it=e("contextSidebar.stats.messages"),t[122]=e,t[123]=it):it=t[123];let rt;t[124]!==G.messagesCount?(rt=Jn(G.messagesCount),t[124]=G.messagesCount,t[125]=rt):rt=t[125];let ot;t[126]!==it||t[127]!==rt?(ot={label:it,value:rt},t[126]=it,t[127]=rt,t[128]=ot):ot=t[128];let ft;t[129]!==e?(ft=e("contextSidebar.stats.user"),t[129]=e,t[130]=ft):ft=t[130];let st;t[131]!==G.userMessagesCount?(st=Jn(G.userMessagesCount),t[131]=G.userMessagesCount,t[132]=st):st=t[132];let Ct;t[133]!==ft||t[134]!==st?(Ct={label:ft,value:st},t[133]=ft,t[134]=st,t[135]=Ct):Ct=t[135];let ht;t[136]!==e?(ht=e("contextSidebar.stats.assistant"),t[136]=e,t[137]=ht):ht=t[137];let be;t[138]!==G.assistantMessagesCount?(be=Jn(G.assistantMessagesCount),t[138]=G.assistantMessagesCount,t[139]=be):be=t[139];let Je;t[140]!==ht||t[141]!==be?(Je={label:ht,value:be},t[140]=ht,t[141]=be,t[142]=Je):Je=t[142];let dt;t[143]!==e?(dt=e("contextSidebar.stats.cost"),t[143]=e,t[144]=dt):dt=t[144];let Ke;t[145]!==G.totalAssistantCost?(Ke=Qx(G.totalAssistantCost),t[145]=G.totalAssistantCost,t[146]=Ke):Ke=t[146];let mt;t[147]!==dt||t[148]!==Ke?(mt={label:dt,value:Ke},t[147]=dt,t[148]=Ke,t[149]=mt):mt=t[149];let ee;t[150]!==ot||t[151]!==Ct||t[152]!==Je||t[153]!==mt?(ee=[ot,Ct,Je,mt],t[150]=ot,t[151]=Ct,t[152]=Je,t[153]=mt,t[154]=ee):ee=t[154];const fe=ee;let Ie;t[155]!==fe?(Ie=s.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:fe.map(pw)}),t[155]=fe,t[156]=Ie):Ie=t[156];let $e;t[157]!==e?($e=e("contextSidebar.section.lastAssistantMessage"),t[157]=e,t[158]=$e):$e=t[158];let H;t[159]!==$e?(H=s.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:$e}),t[159]=$e,t[160]=H):H=t[160];let Be;t[161]!==e||t[162]!==G.cacheHitRate.hasInput||t[163]!==G.cacheHitRate.percent||t[164]!==G.tokenBreakdown.cacheRead||t[165]!==G.tokenBreakdown.cacheWrite||t[166]!==G.tokenBreakdown.input||t[167]!==G.tokenBreakdown.output||t[168]!==G.tokenBreakdown.reasoning?(Be=s.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:G.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:G.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:G.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:G.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:G.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:G.cacheHitRate.hasInput?G.cacheHitRate.percent:null,format:"percent"}].map(gw)}),t[161]=e,t[162]=G.cacheHitRate.hasInput,t[163]=G.cacheHitRate.percent,t[164]=G.tokenBreakdown.cacheRead,t[165]=G.tokenBreakdown.cacheWrite,t[166]=G.tokenBreakdown.input,t[167]=G.tokenBreakdown.output,t[168]=G.tokenBreakdown.reasoning,t[169]=Be):Be=t[169];let Ye;t[170]!==H||t[171]!==Be?(Ye=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[H,Be]}),t[170]=H,t[171]=Be,t[172]=Ye):Ye=t[172];let qe;t[173]!==le||t[174]!==G.breakdownTotal?(qe=s.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:le.map(Ue=>Ue.value<=0||G.breakdownTotal<=0?null:s.jsx("div",{style:{width:`${Ue.value/G.breakdownTotal*100}%`,backgroundColor:Ue.color}},Ue.key))}),t[173]=le,t[174]=G.breakdownTotal,t[175]=qe):qe=t[175];let Xe;t[176]!==le||t[177]!==G.breakdownTotal?(Xe=s.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:le.map(Ue=>{const He=G.breakdownTotal>0?Ue.value/G.breakdownTotal*100:0;return s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:Ue.color}}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[Ue.label," ",s.jsxs("span",{className:"tabular-nums",children:[He.toFixed(0),"%"]})]})]},Ue.key)})}),t[176]=le,t[177]=G.breakdownTotal,t[178]=Xe):Xe=t[178];let jt;t[179]!==qe||t[180]!==Xe?(jt=s.jsxs("div",{className:"mb-6",children:[qe,Xe]}),t[179]=qe,t[180]=Xe,t[181]=jt):jt=t[181];let Ve;t[182]!==e?(Ve=e("contextSidebar.section.rawMessages"),t[182]=e,t[183]=Ve):Ve=t[183];let pt;t[184]!==Ve?(pt=s.jsx("div",{className:"typography-micro text-muted-foreground",children:Ve}),t[184]=Ve,t[185]=pt):pt=t[185];let Rt;if(t[186]!==l||t[187]!==i||t[188]!==p||t[189]!==e||t[190]!==n){let Ue;t[192]!==l||t[193]!==i||t[194]!==e||t[195]!==n?(Ue=He=>{const ve=He.info.role,Qe=ve==="assistant",Ge=ve==="user",Ze=i[He.info.id]===!0,lt=l===He.info.id,Bt=He.info.time?.created??null,$t=H1(He.parts),Wt=Qe?Cc({info:He.info,parts:He.parts}):null,Xt=Ge?q1(He.parts):"",Ft=X1(Bt,n),Jt=$t||"—",Lt=Wt?Y1(Wt.input,Wt.output,Jn):"",is=ve||"unknown",_t=$t?`${is}: ${$t}`:is,zt=Ze?JSON.stringify({info:He.info,parts:He.parts},null,2):"";return s.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[s.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-left hover:bg-[var(--interactive-hover)]","aria-expanded":Ze,onClick:()=>{o(Nt=>({...Nt,[He.info.id]:Nt[He.info.id]!==!0}))},children:s.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:Qe?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[Ge?s.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",Xt]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:Qe?Jt:_t}),Qe&&s.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:Lt})]}),s.jsx("span",{className:"text-right text-muted-foreground",children:Ft})]})}),Ze&&s.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:s.jsxs("div",{className:"group relative max-h-[26rem] w-full overflow-auto bg-[var(--surface-background)]",children:[s.jsx("div",{className:"absolute top-1 right-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:s.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:Nt=>{Nt.stopPropagation(),j(He.info.id,zt)},"aria-label":e(lt?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(lt?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:lt?s.jsx(F,{name:"check",className:"size-3.5"}):s.jsx(F,{name:"file-copy",className:"size-3.5"})})}),s.jsx(Qp,{language:"json",code:zt,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},He.info.id)},t[192]=l,t[193]=i,t[194]=e,t[195]=n,t[196]=Ue):Ue=t[196],Rt=[...p].reverse().map(Ue),t[186]=l,t[187]=i,t[188]=p,t[189]=e,t[190]=n,t[191]=Rt}else Rt=t[191];let De;t[197]!==Rt?(De=s.jsx("div",{className:"mt-2.5 space-y-1",children:Rt}),t[197]=Rt,t[198]=De):De=t[198];let yt;t[199]!==pt||t[200]!==De?(yt=s.jsxs("div",{children:[pt,De]}),t[199]=pt,t[200]=De,t[201]=yt):yt=t[201];let Pt;return t[202]!==oe||t[203]!==tt||t[204]!==Ie||t[205]!==Ye||t[206]!==jt||t[207]!==yt?(Pt=s.jsx(On,{outerClassName:"h-full",className:"bg-background",children:s.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[oe,tt,Ie,Ye,jt,yt]})}),t[202]=oe,t[203]=tt,t[204]=Ie,t[205]=Ye,t[206]=jt,t[207]=yt,t[208]=Pt):Pt=t[208],Pt};function ow(t){return t.timeFormatPreference}function iw(t){return t.currentSessionId}function aw(t){return t.currentSessionDirectory}function lw(t){return t.providers}function cw(t){return Object.keys(t).length>0?{}:t}function dw(t){return t.info.role==="assistant"}function uw(t){return t.info.role==="user"}function fw(t){return t.info}function mw(t,e){const n=Ln(e.info.cost);return t+n}function hw(t){return t.info.role==="system"}function pw(t){return s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[s.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value})]},t.label)}function gw(t){return s.jsxs("div",{children:[s.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value!==null&&t.value!==void 0?t.format==="percent"?`${t.value.toFixed(1)}%`:Jn(t.value):"—"})]},t.label)}const Df=new Set(["localhost","127.0.0.1","0.0.0.0","::1","[::1]"]),xw=t=>{const e=t.split("/")[0]?.split("?")[0]??"",n=e.startsWith("[")?e.slice(0,e.indexOf("]")+1):e.split(":")[0]??"";return Df.has(n.toLowerCase())},tn="about:blank",Cr=t=>{const e=t.trim();if(!e)return tn;const n=e.includes("://")?e:`${xw(e)?"http":"https"}://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?tn:r.toString()}catch{return tn}},Ir=t=>{try{return Df.has(new URL(t).hostname.toLowerCase())}catch{return!1}},dl=t=>{if(!t||t===tn)return"";try{return new URL(t).host||t}catch{return t}},bw=new Set([-2,-7,-101,-102,-104,-109,-118,-324]),yw=(t,e)=>bw.has(t)&&Ir(e),ww=t=>{if(!t||typeof t!="object")return!1;const e=t;return typeof e.port=="number"&&Number.isFinite(e.port)&&typeof e.url=="string"&&e.url.length>0&&typeof e.command=="string"},vw=async t=>{try{const e=await ws("/api/dev-servers",{signal:t});if(!e.ok)return{kind:"unavailable"};const n=await e.json();if(!n||typeof n!="object")return{kind:"unavailable"};const r=n.servers;return Array.isArray(r)?{kind:"ready",servers:r.filter(ww)}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},Sw=async t=>{try{const e=await ws("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!e.ok)return null;const n=await e.json();if(!n||typeof n!="object")return null;const r=n.status;return typeof r=="number"&&Number.isFinite(r)?r:null}catch{return null}},jw=t=>{try{const e=new URL(t),n=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(n)&&n>0?n:null}catch{return null}},kw=({announced:t,discovered:e})=>{const n=new Map;for(const r of t){const i=jw(r);i!==null&&!n.has(i)&&n.set(i,r)}return e?e.map(r=>{const i=n.get(r.port);return{url:i??r.url,port:r.port,announced:i!==void 0}}).sort((r,i)=>r.announced!==i.announced?r.announced?-1:1:r.port-i.port):[...n.entries()].map(([r,i])=>({url:i,port:r,announced:!0})).sort((r,i)=>r.port-i.port)},Sa="__openchamberBrowserAnnotationActive",Cw=`(() => {
|
|
12
|
-
try {
|
|
13
|
-
var host = document.querySelector('[data-openchamber-annotation]');
|
|
14
|
-
if (host && host.parentNode) host.parentNode.removeChild(host);
|
|
15
|
-
} catch (error) { /* page navigated away */ }
|
|
16
|
-
try {
|
|
17
|
-
var cursor = document.getElementById('openchamber-annotation-cursor');
|
|
18
|
-
if (cursor && cursor.parentNode) cursor.parentNode.removeChild(cursor);
|
|
19
|
-
} catch (error) { /* page navigated away */ }
|
|
20
|
-
try { delete window['${Sa}']; } catch (error) { /* non-configurable */ }
|
|
21
|
-
})();`,Nw=(t,e)=>{const n=JSON.stringify({theme:t,labels:e});return String.raw`new Promise((resolve) => {
|
|
22
|
-
var CONFIG = ${n};
|
|
23
|
-
var THEME = CONFIG.theme;
|
|
24
|
-
var LABELS = CONFIG.labels;
|
|
25
|
-
var OVERLAY_ATTR = 'data-openchamber-annotation';
|
|
26
|
-
var Z_OVERLAY = 2147483646;
|
|
27
|
-
var MAX_TEXT = 400;
|
|
28
|
-
var MIN_RECT = 3;
|
|
29
|
-
var EDITOR_GAP = 10;
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
var stale = document.querySelector('[' + OVERLAY_ATTR + ']');
|
|
33
|
-
if (stale && stale.parentNode) stale.parentNode.removeChild(stale);
|
|
34
|
-
} catch (error) { /* nothing to clean */ }
|
|
35
|
-
|
|
36
|
-
window['${Sa}'] = true;
|
|
37
|
-
|
|
38
|
-
var counter = 0;
|
|
39
|
-
var nextId = function (prefix) { counter += 1; return prefix + '-' + counter; };
|
|
40
|
-
|
|
41
|
-
var selected = null;
|
|
42
|
-
var regions = [];
|
|
43
|
-
var strokes = [];
|
|
44
|
-
var tool = 'select';
|
|
45
|
-
var settled = false;
|
|
46
|
-
|
|
47
|
-
// ---------------------------------------------------------------- geometry
|
|
48
|
-
|
|
49
|
-
var rectFrom = function (domRect) {
|
|
50
|
-
return { x: domRect.left, y: domRect.top, width: domRect.width, height: domRect.height };
|
|
51
|
-
};
|
|
52
|
-
var normalizeRect = function (ax, ay, bx, by) {
|
|
53
|
-
return { x: Math.min(ax, bx), y: Math.min(ay, by), width: Math.abs(bx - ax), height: Math.abs(by - ay) };
|
|
54
|
-
};
|
|
55
|
-
var usableRect = function (rect) { return rect.width >= MIN_RECT && rect.height >= MIN_RECT; };
|
|
56
|
-
|
|
57
|
-
// ------------------------------------------------------------- description
|
|
58
|
-
|
|
59
|
-
var isOverlayNode = function (element) {
|
|
60
|
-
var node = element;
|
|
61
|
-
while (node) {
|
|
62
|
-
if (node.nodeType === 1 && node.hasAttribute && node.hasAttribute(OVERLAY_ATTR)) return true;
|
|
63
|
-
node = node.parentNode || (node.host || null);
|
|
64
|
-
}
|
|
65
|
-
return false;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
var elementFromPoint = function (x, y) {
|
|
69
|
-
var found = document.elementFromPoint(x, y);
|
|
70
|
-
if (!found || isOverlayNode(found)) return null;
|
|
71
|
-
return found;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
var selectorPart = function (element) {
|
|
75
|
-
var part = element.tagName.toLowerCase();
|
|
76
|
-
if (element.id) return part + '#' + element.id;
|
|
77
|
-
var className = typeof element.className === 'string' ? element.className.trim() : '';
|
|
78
|
-
if (className) {
|
|
79
|
-
var first = className.split(/\s+/).filter(Boolean).slice(0, 2).join('.');
|
|
80
|
-
if (first) part += '.' + first;
|
|
81
|
-
}
|
|
82
|
-
return part;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
var buildSelector = function (element) {
|
|
86
|
-
if (element.id) return '#' + element.id;
|
|
87
|
-
var parts = [];
|
|
88
|
-
var node = element;
|
|
89
|
-
var depth = 0;
|
|
90
|
-
while (node && node.nodeType === 1 && depth < 5) {
|
|
91
|
-
var part = selectorPart(node);
|
|
92
|
-
var parent = node.parentElement;
|
|
93
|
-
if (parent) {
|
|
94
|
-
var siblings = Array.prototype.filter.call(parent.children, function (child) {
|
|
95
|
-
return child.tagName === node.tagName;
|
|
96
|
-
});
|
|
97
|
-
if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
|
|
98
|
-
}
|
|
99
|
-
parts.unshift(part);
|
|
100
|
-
if (node.id) break;
|
|
101
|
-
node = parent;
|
|
102
|
-
depth += 1;
|
|
103
|
-
}
|
|
104
|
-
return parts.join(' > ');
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
var INTERESTING_ATTRS = ['id', 'class', 'name', 'type', 'href', 'src', 'alt', 'title', 'role', 'placeholder', 'aria-label', 'data-testid'];
|
|
108
|
-
var STYLE_PROPS = [
|
|
109
|
-
'display', 'position', 'color', 'backgroundColor', 'fontSize', 'fontWeight', 'fontFamily',
|
|
110
|
-
'lineHeight', 'padding', 'margin', 'border', 'borderRadius', 'width', 'height', 'opacity',
|
|
111
|
-
'zIndex', 'flexDirection', 'justifyContent', 'alignItems', 'gap', 'textAlign'
|
|
112
|
-
];
|
|
113
|
-
|
|
114
|
-
var describe = function (element) {
|
|
115
|
-
var computed = window.getComputedStyle(element);
|
|
116
|
-
var attributes = {};
|
|
117
|
-
for (var i = 0; i < INTERESTING_ATTRS.length; i += 1) {
|
|
118
|
-
var name = INTERESTING_ATTRS[i];
|
|
119
|
-
var value = element.getAttribute(name);
|
|
120
|
-
if (value) attributes[name] = String(value).slice(0, 200);
|
|
121
|
-
}
|
|
122
|
-
var computedStyle = {};
|
|
123
|
-
for (var j = 0; j < STYLE_PROPS.length; j += 1) {
|
|
124
|
-
var prop = STYLE_PROPS[j];
|
|
125
|
-
computedStyle[prop] = String(computed[prop] == null ? '' : computed[prop]);
|
|
126
|
-
}
|
|
127
|
-
var ancestry = [];
|
|
128
|
-
var node = element.parentElement;
|
|
129
|
-
var depth = 0;
|
|
130
|
-
while (node && node.nodeType === 1 && depth < 4) {
|
|
131
|
-
var entry = { tag: node.tagName.toLowerCase(), selectorPart: selectorPart(node) };
|
|
132
|
-
if (node.id) entry.id = node.id;
|
|
133
|
-
var cls = typeof node.className === 'string' ? node.className.trim() : '';
|
|
134
|
-
if (cls) entry.className = cls.slice(0, 200);
|
|
135
|
-
ancestry.unshift(entry);
|
|
136
|
-
node = node.parentElement;
|
|
137
|
-
depth += 1;
|
|
138
|
-
}
|
|
139
|
-
var box = element.getBoundingClientRect();
|
|
140
|
-
var text = (element.textContent == null ? '' : String(element.textContent)).replace(/\s+/g, ' ').trim();
|
|
141
|
-
return {
|
|
142
|
-
tag: element.tagName.toLowerCase(),
|
|
143
|
-
text: text.slice(0, MAX_TEXT),
|
|
144
|
-
selector: buildSelector(element),
|
|
145
|
-
path: ancestry.map(function (e) { return e.selectorPart; }).concat([selectorPart(element)]).join(' > '),
|
|
146
|
-
bounds: rectFrom(box),
|
|
147
|
-
center: { x: box.left + box.width / 2, y: box.top + box.height / 2 },
|
|
148
|
-
attributes: attributes,
|
|
149
|
-
computedStyle: computedStyle,
|
|
150
|
-
ancestry: ancestry
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
// ------------------------------------------------------------------ chrome
|
|
155
|
-
|
|
156
|
-
var host = document.createElement('div');
|
|
157
|
-
host.setAttribute(OVERLAY_ATTR, '');
|
|
158
|
-
host.style.cssText = 'position:fixed;inset:0;z-index:' + Z_OVERLAY + ';pointer-events:none';
|
|
159
|
-
var shadow = host.attachShadow({ mode: 'closed' });
|
|
160
|
-
|
|
161
|
-
var style = document.createElement('style');
|
|
162
|
-
style.textContent = [
|
|
163
|
-
':host{all:initial}',
|
|
164
|
-
'*{box-sizing:border-box;font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif}',
|
|
165
|
-
'.layer{position:fixed;inset:0;pointer-events:none}',
|
|
166
|
-
'.box{position:fixed;left:0;top:0;display:none;pointer-events:none;border:1.5px solid ' + THEME.primary + ';background:' + THEME.primarySoft + ';border-radius:2px}',
|
|
167
|
-
'.label{position:fixed;left:0;top:0;display:none;pointer-events:none;padding:1px 6px;border-radius:4px;background:' + THEME.primary + ';color:' + THEME.primaryContrast + ';font-size:11px;line-height:17px;white-space:nowrap;font-weight:600}',
|
|
168
|
-
'.tools{position:fixed;top:14px;left:50%;transform:translateX(-50%);display:flex;gap:2px;padding:4px;border-radius:999px;border:1px solid ' + THEME.border + ';background:' + THEME.glassSurface + ';-webkit-backdrop-filter:' + THEME.glassFilter + ';backdrop-filter:' + THEME.glassFilter + ';box-shadow:0 6px 20px rgba(0,0,0,.24);pointer-events:auto}',
|
|
169
|
-
'.tools button{appearance:none;border:none;background:transparent;color:' + THEME.mutedText + ';border-radius:999px;padding:5px 14px;font-size:12px;line-height:18px;font-weight:500;cursor:pointer;white-space:nowrap}',
|
|
170
|
-
'.tools button:hover{background:' + THEME.primaryFaint + '}',
|
|
171
|
-
'.tools button[aria-pressed="true"]{background:' + THEME.primarySoft + ';color:' + THEME.primary + ';font-weight:600}',
|
|
172
|
-
'.editor{position:fixed;left:0;top:0;display:none;align-items:center;gap:8px;width:min(420px,calc(100vw - 24px));padding:6px;padding-left:16px;border-radius:22px;border:1px solid ' + THEME.border + ';background:' + THEME.glassSurface + ';-webkit-backdrop-filter:' + THEME.glassFilter + ';backdrop-filter:' + THEME.glassFilter + ';box-shadow:0 8px 28px rgba(0,0,0,.3);pointer-events:auto}',
|
|
173
|
-
'.editor textarea{flex:1;min-width:0;resize:none;border:none;background:transparent;color:' + THEME.text + ';font-size:13px;line-height:20px;outline:none;padding:6px 0;min-height:32px;max-height:104px;display:block}',
|
|
174
|
-
'.editor textarea::placeholder{color:' + THEME.mutedText + '}',
|
|
175
|
-
'.editor button{appearance:none;border:none;background:' + THEME.primary + ';color:' + THEME.primaryContrast + ';border-radius:999px;width:32px;height:32px;padding:0;display:flex;align-items:center;justify-content:center;flex-shrink:0;cursor:pointer}',
|
|
176
|
-
'.editor button svg{width:16px;height:16px;display:block}',
|
|
177
|
-
'.editor button[disabled]{opacity:.5;cursor:default}'
|
|
178
|
-
].join('');
|
|
179
|
-
shadow.appendChild(style);
|
|
180
|
-
|
|
181
|
-
var cursorStyle = document.createElement('style');
|
|
182
|
-
cursorStyle.id = 'openchamber-annotation-cursor';
|
|
183
|
-
document.head.appendChild(cursorStyle);
|
|
184
|
-
var setCursor = function (value) {
|
|
185
|
-
cursorStyle.textContent = value ? '*{cursor:' + value + ' !important}' : '';
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
var svgNS = 'http://www.w3.org/2000/svg';
|
|
189
|
-
var svg = document.createElementNS(svgNS, 'svg');
|
|
190
|
-
svg.setAttribute('class', 'layer');
|
|
191
|
-
svg.style.overflow = 'visible';
|
|
192
|
-
shadow.appendChild(svg);
|
|
193
|
-
|
|
194
|
-
var hoverBox = document.createElement('div');
|
|
195
|
-
hoverBox.className = 'box';
|
|
196
|
-
var hoverLabel = document.createElement('div');
|
|
197
|
-
hoverLabel.className = 'label';
|
|
198
|
-
var marqueeBox = document.createElement('div');
|
|
199
|
-
marqueeBox.className = 'box';
|
|
200
|
-
shadow.append(hoverBox, hoverLabel, marqueeBox);
|
|
201
|
-
|
|
202
|
-
var positionBox = function (node, rect) {
|
|
203
|
-
node.style.display = 'block';
|
|
204
|
-
node.style.transform = 'translate(' + rect.x + 'px,' + rect.y + 'px)';
|
|
205
|
-
node.style.width = rect.width + 'px';
|
|
206
|
-
node.style.height = rect.height + 'px';
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
var tools = document.createElement('div');
|
|
210
|
-
tools.className = 'tools';
|
|
211
|
-
shadow.appendChild(tools);
|
|
212
|
-
|
|
213
|
-
var toolButtons = {};
|
|
214
|
-
[['select', LABELS.select], ['marquee', LABELS.marquee], ['draw', LABELS.draw]].forEach(function (entry) {
|
|
215
|
-
var button = document.createElement('button');
|
|
216
|
-
button.type = 'button';
|
|
217
|
-
button.textContent = entry[1];
|
|
218
|
-
button.addEventListener('click', function () { setTool(entry[0]); });
|
|
219
|
-
toolButtons[entry[0]] = button;
|
|
220
|
-
tools.appendChild(button);
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
var editor = document.createElement('div');
|
|
224
|
-
editor.className = 'editor';
|
|
225
|
-
shadow.appendChild(editor);
|
|
226
|
-
|
|
227
|
-
var comment = document.createElement('textarea');
|
|
228
|
-
comment.rows = 1;
|
|
229
|
-
comment.placeholder = LABELS.commentPlaceholder;
|
|
230
|
-
var submit = document.createElement('button');
|
|
231
|
-
submit.type = 'button';
|
|
232
|
-
// Icon-only attach button (Remix attachment-2), matching the chat comment
|
|
233
|
-
// input; the localized label stays available to assistive tech.
|
|
234
|
-
submit.setAttribute('aria-label', LABELS.submit);
|
|
235
|
-
submit.title = LABELS.submit;
|
|
236
|
-
submit.innerHTML = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M14.8287 7.75737L9.1718 13.4142C8.78127 13.8047 8.78127 14.4379 9.1718 14.8284C9.56232 15.219 10.1955 15.219 10.586 14.8284L16.2429 9.17158C17.4144 8.00001 17.4144 6.10052 16.2429 4.92894C15.0713 3.75737 13.1718 3.75737 12.0002 4.92894L6.34337 10.5858C4.39075 12.5384 4.39075 15.7042 6.34337 17.6569C8.29599 19.6095 11.4618 19.6095 13.4144 17.6569L19.0713 12L20.4855 13.4142L14.8287 19.0711C12.095 21.8047 7.66283 21.8047 4.92916 19.0711C2.19549 16.3374 2.19549 11.9053 4.92916 9.17158L10.586 3.51473C12.5386 1.56211 15.7045 1.56211 17.6571 3.51473C19.6097 5.46735 19.6097 8.63317 17.6571 10.5858L12.0002 16.2427C10.8287 17.4142 8.92916 17.4142 7.75759 16.2427C6.58601 15.0711 6.58601 13.1716 7.75759 12L13.4144 6.34316L14.8287 7.75737Z" fill="currentColor"/></svg>';
|
|
237
|
-
editor.append(comment, submit);
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Grows the box with its content.
|
|
241
|
-
*
|
|
242
|
-
* A hidden element reports scrollHeight 0, so measuring one collapses the
|
|
243
|
-
* field to nothing — which is what left a sliver of a click target and an
|
|
244
|
-
* invisible caret. Measuring only while visible, and never below the CSS
|
|
245
|
-
* min-height, keeps it usable.
|
|
246
|
-
*/
|
|
247
|
-
var resizeComment = function () {
|
|
248
|
-
if (editor.style.display === 'none') return;
|
|
249
|
-
comment.style.height = 'auto';
|
|
250
|
-
comment.style.height = Math.max(32, Math.min(comment.scrollHeight, 104)) + 'px';
|
|
251
|
-
};
|
|
252
|
-
comment.addEventListener('input', resizeComment);
|
|
253
|
-
|
|
254
|
-
// -------------------------------------------------------------- selection
|
|
255
|
-
|
|
256
|
-
var lastTargetRect = null;
|
|
257
|
-
|
|
258
|
-
/** Places the comment box under whatever was just marked, kept on screen. */
|
|
259
|
-
var positionEditor = function () {
|
|
260
|
-
if (!lastTargetRect) {
|
|
261
|
-
editor.style.display = 'none';
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
var wasHidden = editor.style.display === 'none';
|
|
265
|
-
editor.style.display = 'flex';
|
|
266
|
-
// Measured now that it is laid out, not while it was still hidden.
|
|
267
|
-
if (wasHidden) resizeComment();
|
|
268
|
-
var box = editor.getBoundingClientRect();
|
|
269
|
-
var left = lastTargetRect.x + lastTargetRect.width / 2 - box.width / 2;
|
|
270
|
-
var top = lastTargetRect.y + lastTargetRect.height + EDITOR_GAP;
|
|
271
|
-
// Above the target when there is no room below, so the box is never left
|
|
272
|
-
// half off the bottom of the page.
|
|
273
|
-
if (top + box.height > window.innerHeight - 8) {
|
|
274
|
-
top = Math.max(8, lastTargetRect.y - box.height - EDITOR_GAP);
|
|
275
|
-
}
|
|
276
|
-
left = Math.max(8, Math.min(left, window.innerWidth - box.width - 8));
|
|
277
|
-
editor.style.transform = 'translate(' + Math.round(left) + 'px,' + Math.round(top) + 'px)';
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
/** Focus after layout: focusing a zero-height field puts the caret nowhere. */
|
|
281
|
-
var focusComment = function () {
|
|
282
|
-
requestAnimationFrame(function () {
|
|
283
|
-
try {
|
|
284
|
-
comment.focus({ preventScroll: true });
|
|
285
|
-
comment.setSelectionRange(comment.value.length, comment.value.length);
|
|
286
|
-
} catch (error) { /* field went away */ }
|
|
287
|
-
});
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
var hasTargets = function () {
|
|
291
|
-
return Boolean(selected) || regions.length > 0 || strokes.length > 0;
|
|
292
|
-
};
|
|
293
|
-
|
|
294
|
-
var syncChrome = function () {
|
|
295
|
-
submit.disabled = !hasTargets();
|
|
296
|
-
if (!hasTargets()) {
|
|
297
|
-
lastTargetRect = null;
|
|
298
|
-
editor.style.display = 'none';
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
positionEditor();
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
var syncSelectionVisuals = function () {
|
|
305
|
-
if (!selected) return;
|
|
306
|
-
var rect = rectFrom(selected.element.getBoundingClientRect());
|
|
307
|
-
if (!usableRect(rect)) {
|
|
308
|
-
selected.outline.style.display = 'none';
|
|
309
|
-
selected.badge.style.display = 'none';
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
positionBox(selected.outline, rect);
|
|
313
|
-
selected.badge.style.display = 'block';
|
|
314
|
-
selected.badge.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
|
|
315
|
-
lastTargetRect = rect;
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
var dropSelection = function () {
|
|
319
|
-
if (!selected) return;
|
|
320
|
-
selected.outline.remove();
|
|
321
|
-
selected.badge.remove();
|
|
322
|
-
selected = null;
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
var selectElement = function (element) {
|
|
326
|
-
var wasSelected = selected && selected.element === element;
|
|
327
|
-
dropSelection();
|
|
328
|
-
if (wasSelected) {
|
|
329
|
-
// Clicking the chosen element again clears it, so a misclick costs one
|
|
330
|
-
// click rather than starting over.
|
|
331
|
-
lastTargetRect = null;
|
|
332
|
-
syncChrome();
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
var outline = document.createElement('div');
|
|
336
|
-
outline.className = 'box';
|
|
337
|
-
var badge = document.createElement('div');
|
|
338
|
-
badge.className = 'label';
|
|
339
|
-
badge.textContent = selectorPart(element);
|
|
340
|
-
shadow.append(outline, badge);
|
|
341
|
-
selected = { id: nextId('element'), element: element, outline: outline, badge: badge };
|
|
342
|
-
syncSelectionVisuals();
|
|
343
|
-
syncChrome();
|
|
344
|
-
focusComment();
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
var setTool = function (next) {
|
|
348
|
-
tool = next;
|
|
349
|
-
hoverBox.style.display = 'none';
|
|
350
|
-
hoverLabel.style.display = 'none';
|
|
351
|
-
marqueeBox.style.display = 'none';
|
|
352
|
-
setCursor(next === 'select' ? '' : 'crosshair');
|
|
353
|
-
for (var key in toolButtons) {
|
|
354
|
-
if (Object.prototype.hasOwnProperty.call(toolButtons, key)) {
|
|
355
|
-
toolButtons[key].setAttribute('aria-pressed', key === next ? 'true' : 'false');
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
// ------------------------------------------------------------- interaction
|
|
361
|
-
|
|
362
|
-
var drag = null;
|
|
363
|
-
|
|
364
|
-
var onPointerMove = function (event) {
|
|
365
|
-
if (drag) {
|
|
366
|
-
if (drag.kind === 'marquee') {
|
|
367
|
-
drag.rect = normalizeRect(drag.startX, drag.startY, event.clientX, event.clientY);
|
|
368
|
-
positionBox(marqueeBox, drag.rect);
|
|
369
|
-
} else if (drag.kind === 'draw') {
|
|
370
|
-
drag.points.push({ x: event.clientX, y: event.clientY });
|
|
371
|
-
drag.path.setAttribute('d', drag.points.map(function (point, index) {
|
|
372
|
-
return (index === 0 ? 'M' : 'L') + point.x + ' ' + point.y;
|
|
373
|
-
}).join(' '));
|
|
374
|
-
}
|
|
375
|
-
return;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
if (tool !== 'select') return;
|
|
379
|
-
var element = elementFromPoint(event.clientX, event.clientY);
|
|
380
|
-
if (!element) {
|
|
381
|
-
hoverBox.style.display = 'none';
|
|
382
|
-
hoverLabel.style.display = 'none';
|
|
383
|
-
return;
|
|
384
|
-
}
|
|
385
|
-
var rect = rectFrom(element.getBoundingClientRect());
|
|
386
|
-
positionBox(hoverBox, rect);
|
|
387
|
-
hoverLabel.textContent = selectorPart(element);
|
|
388
|
-
hoverLabel.style.display = 'block';
|
|
389
|
-
hoverLabel.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
var onPointerDown = function (event) {
|
|
393
|
-
if (event.button !== 0) return;
|
|
394
|
-
if (isOverlayNode(event.target)) return;
|
|
395
|
-
event.preventDefault();
|
|
396
|
-
event.stopPropagation();
|
|
397
|
-
|
|
398
|
-
if (tool === 'select') {
|
|
399
|
-
var element = elementFromPoint(event.clientX, event.clientY);
|
|
400
|
-
if (element) selectElement(element);
|
|
401
|
-
return;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
if (tool === 'marquee') {
|
|
405
|
-
drag = { kind: 'marquee', startX: event.clientX, startY: event.clientY, rect: null };
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
var path = document.createElementNS(svgNS, 'path');
|
|
410
|
-
path.setAttribute('fill', 'none');
|
|
411
|
-
path.setAttribute('stroke', THEME.primary);
|
|
412
|
-
path.setAttribute('stroke-width', '2.5');
|
|
413
|
-
path.setAttribute('stroke-linecap', 'round');
|
|
414
|
-
path.setAttribute('stroke-linejoin', 'round');
|
|
415
|
-
svg.appendChild(path);
|
|
416
|
-
drag = { kind: 'draw', path: path, points: [{ x: event.clientX, y: event.clientY }] };
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
var onPointerUp = function () {
|
|
420
|
-
if (!drag) return;
|
|
421
|
-
var finished = drag;
|
|
422
|
-
drag = null;
|
|
423
|
-
|
|
424
|
-
if (finished.kind === 'marquee') {
|
|
425
|
-
marqueeBox.style.display = 'none';
|
|
426
|
-
var rect = finished.rect;
|
|
427
|
-
if (!rect || !usableRect(rect)) return;
|
|
428
|
-
// A region marks an area, not the elements inside it: expanding it into a
|
|
429
|
-
// selection made the result depend on the page's markup rather than on
|
|
430
|
-
// what was drawn.
|
|
431
|
-
regions.push({ id: nextId('region'), rect: rect });
|
|
432
|
-
var outline = document.createElementNS(svgNS, 'rect');
|
|
433
|
-
outline.setAttribute('x', String(rect.x));
|
|
434
|
-
outline.setAttribute('y', String(rect.y));
|
|
435
|
-
outline.setAttribute('width', String(rect.width));
|
|
436
|
-
outline.setAttribute('height', String(rect.height));
|
|
437
|
-
outline.style.fill = THEME.primarySoft;
|
|
438
|
-
outline.setAttribute('stroke', THEME.primary);
|
|
439
|
-
outline.setAttribute('stroke-width', '1.5');
|
|
440
|
-
outline.setAttribute('rx', '2');
|
|
441
|
-
svg.appendChild(outline);
|
|
442
|
-
lastTargetRect = rect;
|
|
443
|
-
syncChrome();
|
|
444
|
-
focusComment();
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
var points = finished.points;
|
|
449
|
-
if (points.length < 2) {
|
|
450
|
-
if (finished.path.parentNode) finished.path.parentNode.removeChild(finished.path);
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
var minX = points[0].x, minY = points[0].y, maxX = points[0].x, maxY = points[0].y;
|
|
454
|
-
for (var p = 1; p < points.length; p += 1) {
|
|
455
|
-
minX = Math.min(minX, points[p].x);
|
|
456
|
-
minY = Math.min(minY, points[p].y);
|
|
457
|
-
maxX = Math.max(maxX, points[p].x);
|
|
458
|
-
maxY = Math.max(maxY, points[p].y);
|
|
459
|
-
}
|
|
460
|
-
var bounds = { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
461
|
-
strokes.push({ id: nextId('stroke'), points: points, bounds: bounds });
|
|
462
|
-
lastTargetRect = bounds;
|
|
463
|
-
syncChrome();
|
|
464
|
-
focusComment();
|
|
465
|
-
};
|
|
466
|
-
|
|
467
|
-
/**
|
|
468
|
-
* Swallows the page's own mouse handling while annotating.
|
|
469
|
-
*
|
|
470
|
-
* Blocking pointerdown is not enough: a click still follows it, so marking a
|
|
471
|
-
* button pressed that button and marking a link navigated away from the page
|
|
472
|
-
* being annotated. These are the events that reach page code, so these are
|
|
473
|
-
* the ones that have to stop.
|
|
474
|
-
*/
|
|
475
|
-
var blockPageInteraction = function (event) {
|
|
476
|
-
if (isOverlayNode(event.target)) return;
|
|
477
|
-
event.preventDefault();
|
|
478
|
-
event.stopPropagation();
|
|
479
|
-
};
|
|
480
|
-
var BLOCKED_EVENTS = ['click', 'auxclick', 'dblclick', 'mousedown', 'mouseup', 'contextmenu'];
|
|
481
|
-
|
|
482
|
-
var onScrollOrResize = function () {
|
|
483
|
-
syncSelectionVisuals();
|
|
484
|
-
positionEditor();
|
|
485
|
-
};
|
|
486
|
-
|
|
487
|
-
var onKeyDown = function (event) {
|
|
488
|
-
if (event.isComposing || event.keyCode === 229) return;
|
|
489
|
-
if (event.key === 'Escape') {
|
|
490
|
-
event.preventDefault();
|
|
491
|
-
event.stopImmediatePropagation();
|
|
492
|
-
finish(null);
|
|
493
|
-
}
|
|
494
|
-
};
|
|
495
|
-
|
|
496
|
-
var onCommentKeyDown = function (event) {
|
|
497
|
-
// Do not let the annotated page treat typed letters as its own shortcuts.
|
|
498
|
-
event.stopPropagation();
|
|
499
|
-
// WebKit can report the composition-confirming Enter as keyCode 229.
|
|
500
|
-
if (event.isComposing || event.keyCode === 229) return;
|
|
501
|
-
if (event.key === 'Enter' && !event.shiftKey) {
|
|
502
|
-
event.preventDefault();
|
|
503
|
-
attach();
|
|
504
|
-
}
|
|
505
|
-
};
|
|
506
|
-
|
|
507
|
-
document.addEventListener('pointermove', onPointerMove, true);
|
|
508
|
-
document.addEventListener('pointerdown', onPointerDown, true);
|
|
509
|
-
document.addEventListener('pointerup', onPointerUp, true);
|
|
510
|
-
BLOCKED_EVENTS.forEach(function (name) {
|
|
511
|
-
window.addEventListener(name, blockPageInteraction, { capture: true, passive: false });
|
|
512
|
-
});
|
|
513
|
-
window.addEventListener('scroll', onScrollOrResize, true);
|
|
514
|
-
window.addEventListener('resize', onScrollOrResize, true);
|
|
515
|
-
window.addEventListener('keydown', onKeyDown, true);
|
|
516
|
-
comment.addEventListener('keydown', onCommentKeyDown);
|
|
517
|
-
|
|
518
|
-
// ------------------------------------------------------------------ finish
|
|
519
|
-
|
|
520
|
-
var teardown = function () {
|
|
521
|
-
document.removeEventListener('pointermove', onPointerMove, true);
|
|
522
|
-
document.removeEventListener('pointerdown', onPointerDown, true);
|
|
523
|
-
document.removeEventListener('pointerup', onPointerUp, true);
|
|
524
|
-
BLOCKED_EVENTS.forEach(function (name) {
|
|
525
|
-
window.removeEventListener(name, blockPageInteraction, true);
|
|
526
|
-
});
|
|
527
|
-
window.removeEventListener('scroll', onScrollOrResize, true);
|
|
528
|
-
window.removeEventListener('resize', onScrollOrResize, true);
|
|
529
|
-
window.removeEventListener('keydown', onKeyDown, true);
|
|
530
|
-
comment.removeEventListener('keydown', onCommentKeyDown);
|
|
531
|
-
setCursor('');
|
|
532
|
-
if (cursorStyle.parentNode) cursorStyle.parentNode.removeChild(cursorStyle);
|
|
533
|
-
if (host.parentNode) host.parentNode.removeChild(host);
|
|
534
|
-
try { delete window['${Sa}']; } catch (error) { /* non-configurable */ }
|
|
535
|
-
};
|
|
536
|
-
|
|
537
|
-
var finish = function (payload) {
|
|
538
|
-
if (settled) return;
|
|
539
|
-
settled = true;
|
|
540
|
-
teardown();
|
|
541
|
-
// Removing the chrome is not enough: the host screenshots this page right
|
|
542
|
-
// after we resolve, and the compositor can still hold a frame containing
|
|
543
|
-
// our outlines. Yield two frames so the page has actually repainted.
|
|
544
|
-
requestAnimationFrame(function () {
|
|
545
|
-
requestAnimationFrame(function () { resolve(payload); });
|
|
546
|
-
});
|
|
547
|
-
};
|
|
548
|
-
|
|
549
|
-
var attach = function () {
|
|
550
|
-
if (!hasTargets()) return;
|
|
551
|
-
finish({
|
|
552
|
-
id: 'annotation-' + Date.now(),
|
|
553
|
-
pageUrl: String(location.href),
|
|
554
|
-
pageTitle: String(document.title || ''),
|
|
555
|
-
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
556
|
-
devicePixelRatio: window.devicePixelRatio || 1,
|
|
557
|
-
comment: comment.value,
|
|
558
|
-
// Zero or one element, never more. Kept as a list so elements, regions
|
|
559
|
-
// and strokes stay one uniform shape for everything downstream.
|
|
560
|
-
elements: selected ? [{ id: selected.id, element: describe(selected.element) }] : [],
|
|
561
|
-
regions: regions.map(function (entry) { return { id: entry.id, rect: entry.rect }; }),
|
|
562
|
-
strokes: strokes.map(function (entry) {
|
|
563
|
-
return { id: entry.id, points: entry.points, bounds: entry.bounds };
|
|
564
|
-
})
|
|
565
|
-
});
|
|
566
|
-
};
|
|
567
|
-
|
|
568
|
-
submit.addEventListener('click', attach);
|
|
569
|
-
|
|
570
|
-
(document.body || document.documentElement).appendChild(host);
|
|
571
|
-
setTool('select');
|
|
572
|
-
syncChrome();
|
|
573
|
-
});`},Aw={kind:"idle"},Sn=t=>typeof t=="object"&&t!==null,Dn=t=>typeof t=="number"&&Number.isFinite(t),Ac=t=>Sn(t)&&Object.values(t).every(e=>typeof e=="string"),ul=t=>Sn(t)&&Dn(t.x)&&Dn(t.y)&&Dn(t.width)&&Dn(t.height),If=t=>Sn(t)&&Dn(t.x)&&Dn(t.y),Pw=t=>Sn(t)&&typeof t.tag=="string"&&typeof t.selectorPart=="string"&&(t.id===void 0||typeof t.id=="string")&&(t.className===void 0||typeof t.className=="string"),Dw=t=>Sn(t)&&typeof t.tag=="string"&&typeof t.text=="string"&&typeof t.selector=="string"&&typeof t.path=="string"&&ul(t.bounds)&&If(t.center)&&Ac(t.attributes)&&Ac(t.computedStyle)&&Array.isArray(t.ancestry)&&t.ancestry.every(Pw),Iw=t=>Sn(t)&&typeof t.id=="string"&&Dw(t.element),Tw=t=>Sn(t)&&typeof t.id=="string"&&ul(t.rect),Ew=t=>Sn(t)&&typeof t.id=="string"&&ul(t.bounds)&&Array.isArray(t.points)&&t.points.every(If),Rw=t=>Sn(t)&&typeof t.id=="string"&&typeof t.pageUrl=="string"&&typeof t.pageTitle=="string"&&typeof t.comment=="string"&&Sn(t.viewport)&&Dn(t.viewport.width)&&Dn(t.viewport.height)&&Dn(t.devicePixelRatio)&&Array.isArray(t.elements)&&t.elements.every(Iw)&&Array.isArray(t.regions)&&t.regions.every(Tw)&&Array.isArray(t.strokes)&&t.strokes.every(Ew),Mw=1600,Ow=t=>new Promise((e,n)=>{const r=new Image;r.onload=()=>e(r),r.onerror=()=>n(new Error("Failed to decode browser page capture")),r.src=t}),Bw=async({base64:t,mime:e,captureWidth:n,captureHeight:r,cssWidth:i,cssHeight:o,payload:l,accentColor:a,accentFill:d})=>{if(!t)return null;try{const u=await Ow(`data:${e};base64,${t}`),m=Math.max(1,u.naturalWidth||n),f=Math.max(1,u.naturalHeight||r),p=m/Math.max(1,i||m),y=f/Math.max(1,o||f),x=Math.min(1,Mw/m),k=document.createElement("canvas");k.width=Math.max(1,Math.floor(m*x)),k.height=Math.max(1,Math.floor(f*x));const w=k.getContext("2d");if(!w)return null;w.scale(x,x),w.drawImage(u,0,0,m,f);const h=S=>({x:S.x*p,y:S.y*y,width:S.width*p,height:S.height*y}),g=Math.max(2,2.5*p/Math.max(x,.2));w.strokeStyle=a,w.fillStyle=d;const j=S=>{const C=h(S);w.lineWidth=g,w.fillRect(C.x,C.y,C.width,C.height),w.strokeRect(C.x,C.y,C.width,C.height)};for(const S of l.elements)j(S.element.bounds);for(const S of l.regions)j(S.rect);for(const S of l.strokes)S.points.length<2||(w.beginPath(),S.points.forEach((C,v)=>{const M=C.x*p,R=C.y*y;v===0?w.moveTo(M,R):w.lineTo(M,R)}),w.lineCap="round",w.lineJoin="round",w.lineWidth=g*1.4,w.stroke());const b=await new Promise(S=>k.toBlob(S,"image/jpeg",.85));return b?new File([b],`browser-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch{return null}},Fw="({ width: window.innerWidth, height: window.innerHeight })",_w=async t=>{try{const e=await t.executeJavaScript(Fw,!0);if(!e||typeof e!="object")return null;const n=e;return typeof n.width!="number"||typeof n.height!="number"||!Number.isFinite(n.width)||!Number.isFinite(n.height)?null:{width:n.width,height:n.height}}catch{return null}},Mo=async t=>{try{await t.executeJavaScript(Cw,!1)}catch{}},Lw=async({host:t,theme:e,labels:n})=>{const r=Nw(e,n),i=await t.executeJavaScript(r,!0);if(i==null)return null;if(!Rw(i))return await Mo(t),null;const o=i;try{const l=await _w(t)??o.viewport,a=await t.capturePage();if(!a||!a.base64)return{payload:o,screenshot:null};const d=await Bw({base64:a.base64,mime:a.mime||"image/jpeg",captureWidth:a.width,captureHeight:a.height,cssWidth:l.width,cssHeight:l.height,payload:o,accentColor:e.primary,accentFill:e.primarySoft});return{payload:o,screenshot:d}}catch{return{payload:o,screenshot:null}}},Zs={colorScheme:"dark",primary:"rgb(59, 130, 246)",primarySoft:"rgba(59, 130, 246, 0.16)",primaryFaint:"rgba(59, 130, 246, 0.10)",primaryContrast:"rgb(255, 255, 255)",surface:"rgb(24, 24, 27)",surfaceElevated:"rgb(32, 32, 36)",glassSurface:"rgba(32, 32, 36, 0.64)",glassFilter:"blur(26px) saturate(1.16)",border:"rgba(255, 255, 255, 0.14)",text:"rgb(244, 244, 245)",mutedText:"rgba(244, 244, 245, 0.62)"},$w=()=>{if(typeof document>"u"||!document.body)return null;const t=document.createElement("div");return t.setAttribute("aria-hidden","true"),t.style.cssText="position:fixed;left:-9999px;top:-9999px;width:1px;height:1px;pointer-events:none",document.body.appendChild(t),{read:e=>{t.style.backgroundColor="",t.style.backgroundColor=e;const n=window.getComputedStyle(t).backgroundColor;return n&&n!=="rgba(0, 0, 0, 0)"?n:""},readVariable:e=>window.getComputedStyle(document.documentElement).getPropertyValue(e).trim(),dispose:()=>t.remove()}},zw=t=>{const e=$w();if(!e)return{...Zs,colorScheme:t};try{const n=(a,d)=>e.read(`var(${a})`)||d,r=(a,d,u)=>e.read(`color-mix(in srgb, var(${a}) ${d}%, transparent)`)||u,i=e.readVariable("--oc-glass-tooltip-opacity")||"62%",o=e.readVariable("--oc-glass-blur")||"26px",l=e.readVariable("--oc-glass-saturation")||"1.16";return{colorScheme:t,glassSurface:e.read(`color-mix(in srgb, var(--surface-elevated) ${i}, transparent)`)||Zs.glassSurface,glassFilter:`blur(${o}) saturate(${l})`,primary:n("--primary",Zs.primary),primarySoft:r("--primary",16,Zs.primarySoft),primaryFaint:r("--primary",10,Zs.primaryFaint),primaryContrast:n("--primary-foreground",Zs.primaryContrast),surface:n("--surface-background",Zs.surface),surfaceElevated:n("--surface-elevated",Zs.surfaceElevated),border:n("--border",Zs.border),text:n("--foreground",Zs.text),mutedText:n("--muted-foreground",Zs.mutedText)}}catch{return{...Zs,colorScheme:t}}finally{e.dispose()}},Ww=2e3,Kw=50,Vw=400,Us=new Map;let ja=null,$n=null,Gr=null;const ka=async t=>{try{const e=await ws("/api/browser-control/claim",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t})});return e.ok?(await e.json())?.granted===!0:!1}catch{return!1}},Pn=async(t,e)=>{try{const n=await ws("/api/browser-control/result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t,...e})});n.ok||console.warn(`[browser-control] the server rejected the result for ${t} (HTTP ${n.status}); the agent will see this action time out`)}catch(n){console.warn(`[browser-control] could not deliver the result for ${t}:`,n)}},Uw=async(t,e=Ww)=>{const n=Date.now()+e;for(;!Us.has(t)&&Date.now()<n;)await new Promise(r=>setTimeout(r,Kw));return Us.get(t)??null},Tf=()=>{const t=ja?Us.get(ja):void 0;if(t)return t;let e=null;for(const n of Us.values())e=n;return e},Hw=()=>{const t=Tf();return[...Us.values()].map(e=>{let n={title:"",url:""};try{n=e.describe()}catch{}return{id:e.tabId,title:n.title,url:n.url,active:e===t}})},Gw=t=>`There is no browser tab with id ${t}. Call browser.snapshot to list the open tabs, or omit tabId to use the tab the user is looking at.`,qw=async t=>{const e=t.action==="browser.open",{tabId:n,...r}=t.parameters,i=n===void 0?null:String(n);if(i!==null){const l=Us.get(i);if(!l){if(Us.size===0&&!$n)return;if(await new Promise(a=>setTimeout(a,Vw)),Us.has(i)){await Pc(t,Us.get(i),r);return}if(!await ka(t.requestId))return;await Pn(t.requestId,{ok:!1,error:Gw(i)});return}await Pc(t,l,r);return}const o=Tf();if(!(!o&&!(e&&$n))&&await ka(t.requestId))try{const l=typeof t.parameters.url=="string"?t.parameters.url:"";if(e&&!l){await Pn(t.requestId,{ok:!1,error:"url is required"});return}const a=e&&$n?$n(l):null;if(e&&!a&&!o){await Pn(t.requestId,{ok:!1,error:"There is no browser here to open the page in."});return}if(a){const d=typeof t.parameters.viewport=="string"?t.parameters.viewport:"";if(!d||d==="fill"){await Pn(t.requestId,{ok:!0,data:{url:l,opened:!0,tabId:a}});return}const u=await Uw(a);if(!u){await Pn(t.requestId,{ok:!0,data:{url:l,opened:!0,tabId:a,viewportApplied:!1,note:"The panel had no browser view yet, so the viewport was not applied. Call browser.resize now that one exists."}});return}const m=await u.run("browser.resize",{viewport:d}),f=m&&typeof m=="object"?m.viewport??null:null;await Pn(t.requestId,{ok:!0,data:{url:l,opened:!0,tabId:a,viewportApplied:!0,viewport:f}});return}await Pn(t.requestId,await Ef(o,t.action,r))}catch(l){await Pn(t.requestId,{ok:!1,error:l instanceof Error?l.message:String(l)})}},Pc=async(t,e,n)=>{await ka(t.requestId)&&await Pn(t.requestId,await Ef(e,t.action,n))},Ef=async(t,e,n)=>{try{const r=await t.run(e,n);return e==="browser.snapshot"&&Object(r)===r?{ok:!0,data:{...Object(r),tabs:Hw()}}:{ok:!0,data:r}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},Rf=()=>{Gr||(Gr=Hn(t=>{t.type==="browser-control-request"&&qw({requestId:t.requestId,action:t.action,parameters:t.parameters})}))},Mf=()=>{Us.size>0||$n||!Gr||(Gr(),Gr=null)},Yw=t=>(Us.set(t.tabId,t),Rf(),()=>{Us.get(t.tabId)===t&&Us.delete(t.tabId),Mf()}),Qw=t=>{ja=t},Xw=t=>($n=t,Rf(),()=>{$n===t&&($n=null),Mf()}),Jw=50,Zw=6,ev=2048,tv=200,Of=t=>{const e=Cr(String(t??"").trim());if(!e||e.length>ev)return"";try{const n=new URL(e);return n.protocol!=="http:"&&n.protocol!=="https:"?"":n.toString()}catch{return""}},sv=(t,e)=>{const n=Of(e.url);if(!n)return t;const r=t.find(l=>l.url===n),i=String(e.title??"").trim().slice(0,tv)||r?.title||"";return[{url:n,title:i,lastVisitedAt:e.at},...t.filter(l=>l.url!==n)].slice(0,Jw)},nv=(t,e)=>{const n=Of(e);return t.filter(r=>r.url!==n)},rv=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),Bf=(t,e,n=Zw)=>{const r=String(e??"").trim().toLowerCase(),i=[...t].sort((l,a)=>a.lastVisitedAt-l.lastVisitedAt);if(!r)return i.slice(0,n);const o=r.replace(/^https?:\/\//,"");return i.filter(l=>{const a=rv(l);return l.url===r||a===o?!1:a.includes(o)}).slice(0,n)},Dc=20,Oo=t=>{const e=xt((t||"").trim());return e?JSON.stringify([Qt(),e]):""},ov=t=>{const e=Object.keys(t);if(e.length<=Dc)return t;const n=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,i)=>i[1]-r[1]).slice(0,Dc);return Object.fromEntries(n.map(([r])=>[r,t[r]??[]]))},Nr=oo()(gb(t=>({byProject:{},recordVisit:(e,n)=>{const r=Oo(e);r&&t(i=>{const o=i.byProject[r]??[],l=sv(o,{...n,at:Date.now()});return l===o?i:{byProject:ov({...i.byProject,[r]:l})}})},forget:(e,n)=>{const r=Oo(e);r&&t(i=>{const o=i.byProject[r];return o?{byProject:{...i.byProject,[r]:nv(o,n)}}:i})},clear:e=>{const n=Oo(e);n&&t(r=>{if(!(n in r.byProject))return r;const i={...r.byProject};return delete i[n],{byProject:i}})}}),{name:"openchamber-browser-history",version:1,storage:rh(),partialize:t=>({byProject:t.byProject})})),iv=[],Ff=t=>e=>{const n=Oo(t);return(n?e.byProject[n]:void 0)??iv},Ca=new Map,wi=new Map,ar=new Map,lr=new Set,av=async(t,e)=>{if(!Sl()){lr.delete(t),br(t,{type:"close"});return}if(await oh(En()),!lr.has(t)||!Sl())return;const n=Ud().websocket(`/api/dev-tunnel?port=${e}`),r=ih(n);ar.set(t,r),r.binaryType="arraybuffer",r.onopen=()=>br(t,{type:"ready"}),r.onmessage=i=>br(t,{type:"data",data:i.data instanceof ArrayBuffer?i.data:new TextEncoder().encode(i.data)}),r.onerror=()=>br(t,{type:"close"}),r.onclose=()=>{lr.delete(t),ar.delete(t),br(t,{type:"close"})}};Xp(({connectionId:t,remotePort:e,message:n})=>{switch(n.type){case"data":{const r=ar.get(t);r&&n.data&&r.send(n.data);return}case"close":lr.delete(t),ar.get(t)?.close(),ar.delete(t);return;case"connect":lr.add(t),av(t,e).catch(()=>{lr.delete(t),br(t,{type:"close"})})}});const _f=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Lf=t=>{if(!t)return!1;try{const e=new URL(t,typeof window<"u"?window.location.href:void 0),n=typeof window<"u"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"";return n&&e.origin===n?!1:!Ir(e.toString())}catch{return!1}},$f=t=>{try{const e=new URL(t),n=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(n)&&n>0?n:0}catch{return 0}},Ic=(t,e)=>{try{const n=new URL(t);return n.protocol="http:",n.hostname="127.0.0.1",n.port=String(e),n.toString()}catch{return t}},Tc=(t,e)=>{try{wi.set(e,new URL(t).origin)}catch{}};class qr extends Error{constructor(e){super(e),this.name="DevTunnelUnavailableError"}}const Ec=async t=>{if(!t||!_f()||!Ir(t))return t;const e=En();if(!Lf(e))return t;const n=$f(t);if(!n)return t;const r=`${e}|${n}`,i=Ca.get(r);if(i)return Tc(t,i),Ic(t,i);try{const o=await jr("desktop_dev_tunnel_open",{baseUrl:e,port:n,relay:ah(),targetKey:Qt(),clientToken:Xr(),requestHeaders:Hd()});if(!o||!Number.isInteger(o.localPort)||o.localPort<=0)throw new qr(t);return Ca.set(r,o.localPort),Tc(t,o.localPort),Ic(t,o.localPort)}catch(o){throw o instanceof qr?o:new qr(t)}},Rc=t=>{if(!t||!_f()||!Ir(t)||!Lf(En()))return!1;const e=$f(t);return e>0&&!wi.has(e)},pr=t=>{if(!t)return t;try{const e=new URL(t);if(e.hostname!=="127.0.0.1")return t;const n=wi.get(Number.parseInt(e.port||"0",10));return n?`${n}${e.pathname}${e.search}${e.hash}`:t}catch{return t}},lv=()=>{Ca.clear(),wi.clear(),lr.clear();for(const t of ar.values())t.close();ar.clear(),jr("desktop_relay_dev_tunnel_close_all").catch(()=>{})};typeof window<"u"&&Dr(lv);const Mc=6e3,cv=120,dv=80,uv=`
|
|
574
|
-
var MAX_ELEMENTS = ${cv};
|
|
575
|
-
var MAX_LABEL_CHARS = ${dv};
|
|
576
|
-
var visible = function (element) {
|
|
577
|
-
var rect = element.getBoundingClientRect();
|
|
578
|
-
if (rect.width < 1 || rect.height < 1) return false;
|
|
579
|
-
var style = window.getComputedStyle(element);
|
|
580
|
-
return style.visibility !== 'hidden' && style.display !== 'none' && Number(style.opacity) !== 0;
|
|
581
|
-
};
|
|
582
|
-
var label = function (element) {
|
|
583
|
-
var aria = element.getAttribute('aria-label');
|
|
584
|
-
if (aria) return aria.trim();
|
|
585
|
-
var value = element.getAttribute('value');
|
|
586
|
-
var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
587
|
-
if (text) return text.slice(0, MAX_LABEL_CHARS);
|
|
588
|
-
if (value) return String(value).slice(0, MAX_LABEL_CHARS);
|
|
589
|
-
var placeholder = element.getAttribute('placeholder');
|
|
590
|
-
return placeholder ? placeholder.trim().slice(0, MAX_LABEL_CHARS) : '';
|
|
591
|
-
};
|
|
592
|
-
var isUnique = function (selector) {
|
|
593
|
-
try {
|
|
594
|
-
return document.querySelectorAll(selector).length === 1;
|
|
595
|
-
} catch (error) {
|
|
596
|
-
return false;
|
|
597
|
-
}
|
|
598
|
-
};
|
|
599
|
-
|
|
600
|
-
/**
|
|
601
|
-
* Names an element by what it is, falling back to where it sits.
|
|
602
|
-
*
|
|
603
|
-
* A positional chain like 'main > section:nth-of-type(3) > div > a' survives
|
|
604
|
-
* only until the markup shifts, and says nothing about what it points at.
|
|
605
|
-
* Anything the page states about identity — an id, a test id, an accessible
|
|
606
|
-
* name — outlives edits and reads as the thing it selects. The chain remains
|
|
607
|
-
* as the last resort, because something always has to work.
|
|
608
|
-
*/
|
|
609
|
-
var cssPath = function (element) {
|
|
610
|
-
var tag = element.tagName.toLowerCase();
|
|
611
|
-
|
|
612
|
-
if (element.id) {
|
|
613
|
-
var byId = '#' + CSS.escape(element.id);
|
|
614
|
-
if (isUnique(byId)) return byId;
|
|
615
|
-
}
|
|
616
|
-
var stableAttrs = ['data-testid', 'data-test-id', 'data-test', 'name', 'aria-label'];
|
|
617
|
-
for (var a = 0; a < stableAttrs.length; a += 1) {
|
|
618
|
-
var value = element.getAttribute(stableAttrs[a]);
|
|
619
|
-
if (!value) continue;
|
|
620
|
-
var raw = String(value);
|
|
621
|
-
// A value containing a quote would need escaping for no real gain: such
|
|
622
|
-
// attributes are rare, and the positional chain still covers them.
|
|
623
|
-
if (raw.indexOf('"') !== -1) continue;
|
|
624
|
-
var byAttr = tag + '[' + stableAttrs[a] + '="' + raw + '"]';
|
|
625
|
-
if (isUnique(byAttr)) return byAttr;
|
|
626
|
-
}
|
|
627
|
-
var className = typeof element.className === 'string' ? element.className.trim() : '';
|
|
628
|
-
if (className) {
|
|
629
|
-
var classes = className.split(/\\s+/).filter(Boolean);
|
|
630
|
-
for (var c = 0; c < classes.length; c += 1) {
|
|
631
|
-
var byClass = tag + '.' + CSS.escape(classes[c]);
|
|
632
|
-
if (isUnique(byClass)) return byClass;
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
var parts = [];
|
|
637
|
-
var node = element;
|
|
638
|
-
var depth = 0;
|
|
639
|
-
while (node && node.nodeType === 1 && depth < 6) {
|
|
640
|
-
var part = node.tagName.toLowerCase();
|
|
641
|
-
var parent = node.parentElement;
|
|
642
|
-
if (!parent) { parts.unshift(part); break; }
|
|
643
|
-
var siblings = Array.prototype.filter.call(parent.children, function (child) {
|
|
644
|
-
return child.tagName === node.tagName;
|
|
645
|
-
});
|
|
646
|
-
if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
|
|
647
|
-
parts.unshift(part);
|
|
648
|
-
if (node.id) { parts[0] = '#' + CSS.escape(node.id); break; }
|
|
649
|
-
node = parent;
|
|
650
|
-
depth += 1;
|
|
651
|
-
}
|
|
652
|
-
return parts.join(' > ');
|
|
653
|
-
};
|
|
654
|
-
|
|
655
|
-
/** What a screen reader would announce, or '' when there is nothing to say. */
|
|
656
|
-
var accessibleName = function (element) {
|
|
657
|
-
var aria = element.getAttribute('aria-label');
|
|
658
|
-
if (aria && aria.trim()) return aria.trim();
|
|
659
|
-
var labelled = element.getAttribute('aria-labelledby');
|
|
660
|
-
if (labelled) {
|
|
661
|
-
var source = document.getElementById(labelled.split(/\\s+/)[0]);
|
|
662
|
-
if (source && (source.innerText || '').trim()) return source.innerText.trim();
|
|
663
|
-
}
|
|
664
|
-
var title = element.getAttribute('title');
|
|
665
|
-
if (title && title.trim()) return title.trim();
|
|
666
|
-
var alt = element.getAttribute('alt');
|
|
667
|
-
if (alt && alt.trim()) return alt.trim();
|
|
668
|
-
var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
669
|
-
if (text) return text;
|
|
670
|
-
var value = element.getAttribute('value');
|
|
671
|
-
return value && String(value).trim() ? String(value).trim() : '';
|
|
672
|
-
};
|
|
673
|
-
var findByText = function (needle) {
|
|
674
|
-
var wanted = String(needle).replace(/\\s+/g, ' ').trim().toLowerCase();
|
|
675
|
-
var candidates = document.querySelectorAll('a, button, [role="button"], [role="link"], input[type="submit"], input[type="button"], summary, label');
|
|
676
|
-
var exact = null;
|
|
677
|
-
var partial = null;
|
|
678
|
-
for (var i = 0; i < candidates.length; i += 1) {
|
|
679
|
-
var element = candidates[i];
|
|
680
|
-
if (!visible(element)) continue;
|
|
681
|
-
var text = label(element).toLowerCase();
|
|
682
|
-
if (!text) continue;
|
|
683
|
-
if (text === wanted) { exact = element; break; }
|
|
684
|
-
if (!partial && text.indexOf(wanted) !== -1) partial = element;
|
|
685
|
-
}
|
|
686
|
-
return exact || partial;
|
|
687
|
-
};
|
|
688
|
-
`,io=t=>`(() => {
|
|
689
|
-
${uv}
|
|
690
|
-
${t}
|
|
691
|
-
})()`,fv=({selector:t}={})=>io(`
|
|
692
|
-
var scopeSelector = ${JSON.stringify(t??"")};
|
|
693
|
-
var root = document;
|
|
694
|
-
if (scopeSelector) {
|
|
695
|
-
try { root = document.querySelector(scopeSelector); }
|
|
696
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + scopeSelector }; }
|
|
697
|
-
if (!root) return { ok: false, error: 'No element matches ' + scopeSelector };
|
|
698
|
-
}
|
|
699
|
-
var interactive = root.querySelectorAll('a[href], button, input, select, textarea, [role="button"], [role="link"], [role="tab"], [contenteditable="true"]');
|
|
700
|
-
var elements = [];
|
|
701
|
-
var visibleTotal = 0;
|
|
702
|
-
for (var i = 0; i < interactive.length; i += 1) {
|
|
703
|
-
var element = interactive[i];
|
|
704
|
-
if (!visible(element)) continue;
|
|
705
|
-
visibleTotal += 1;
|
|
706
|
-
if (elements.length >= MAX_ELEMENTS) continue;
|
|
707
|
-
|
|
708
|
-
var rect = element.getBoundingClientRect();
|
|
709
|
-
// Empty and default-valued fields are left out rather than serialized as
|
|
710
|
-
// "" and false. Repeated across a hundred entries that overhead dwarfed
|
|
711
|
-
// the information it carried.
|
|
712
|
-
var entry = {
|
|
713
|
-
selector: cssPath(element),
|
|
714
|
-
tag: element.tagName.toLowerCase(),
|
|
715
|
-
bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) }
|
|
716
|
-
};
|
|
717
|
-
// The list covers the whole document so anything can be clicked without
|
|
718
|
-
// scrolling to it first, which means bounds alone do not say what is on
|
|
719
|
-
// screen — a negative y reads as a bug otherwise.
|
|
720
|
-
if (rect.bottom > 0 && rect.top < window.innerHeight) entry.inViewport = true;
|
|
721
|
-
var type = element.getAttribute('type');
|
|
722
|
-
if (type) entry.type = type;
|
|
723
|
-
var role = element.getAttribute('role');
|
|
724
|
-
if (role) entry.role = role;
|
|
725
|
-
var labelText = label(element);
|
|
726
|
-
if (labelText) entry.label = labelText;
|
|
727
|
-
if (element.disabled === true) entry.disabled = true;
|
|
728
|
-
// Flagged rather than described: reporting the accessible name of every
|
|
729
|
-
// element would cost more than it tells, while its absence on something
|
|
730
|
-
// clickable is a defect worth naming.
|
|
731
|
-
if (!accessibleName(element)) entry.missingAccessibleName = true;
|
|
732
|
-
elements.push(entry);
|
|
733
|
-
}
|
|
734
|
-
var body = document.body ? (document.body.innerText || '') : '';
|
|
735
|
-
var text = body.replace(/\\n{3,}/g, '\\n\\n').trim();
|
|
736
|
-
var docEl = document.documentElement;
|
|
737
|
-
var result = {
|
|
738
|
-
ok: true,
|
|
739
|
-
url: String(location.href),
|
|
740
|
-
title: String(document.title || ''),
|
|
741
|
-
scope: scopeSelector || 'document',
|
|
742
|
-
scrollY: Math.round(window.scrollY),
|
|
743
|
-
maxScrollY: Math.max(0, Math.round(docEl.scrollHeight - window.innerHeight)),
|
|
744
|
-
text: text.slice(0, ${Mc}),
|
|
745
|
-
elements: elements
|
|
746
|
-
};
|
|
747
|
-
// State what was dropped. A capped list that reports only its own length
|
|
748
|
-
// reads as the whole page, and the agent acts as if it had seen everything.
|
|
749
|
-
if (text.length > ${Mc}) {
|
|
750
|
-
result.textTruncated = true;
|
|
751
|
-
result.textTotalChars = text.length;
|
|
752
|
-
}
|
|
753
|
-
if (visibleTotal > elements.length) {
|
|
754
|
-
result.elementsTruncated = true;
|
|
755
|
-
result.interactiveElementsOnPage = visibleTotal;
|
|
756
|
-
}
|
|
757
|
-
return result;
|
|
758
|
-
`),mv=({selector:t,text:e})=>io(`
|
|
759
|
-
var selector = ${JSON.stringify(t??"")};
|
|
760
|
-
var text = ${JSON.stringify(e??"")};
|
|
761
|
-
var target = null;
|
|
762
|
-
if (selector) {
|
|
763
|
-
try { target = document.querySelector(selector); }
|
|
764
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
765
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
766
|
-
} else {
|
|
767
|
-
target = findByText(text);
|
|
768
|
-
if (!target) return { ok: false, error: 'No clickable element has the label ' + text };
|
|
769
|
-
}
|
|
770
|
-
if (target.disabled === true) return { ok: false, error: 'Element is disabled' };
|
|
771
|
-
target.scrollIntoView({ block: 'center', inline: 'center' });
|
|
772
|
-
target.click();
|
|
773
|
-
return { ok: true, clicked: cssPath(target), label: label(target), url: String(location.href) };
|
|
774
|
-
`),hv=({selector:t,value:e,submit:n})=>io(`
|
|
775
|
-
var selector = ${JSON.stringify(t)};
|
|
776
|
-
var value = ${JSON.stringify(e)};
|
|
777
|
-
var target = null;
|
|
778
|
-
try { target = document.querySelector(selector); }
|
|
779
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
780
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
781
|
-
|
|
782
|
-
var editable = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable;
|
|
783
|
-
if (!editable) return { ok: false, error: selector + ' is not a text field' };
|
|
784
|
-
if (target.disabled === true || target.readOnly === true) return { ok: false, error: 'Field is not editable' };
|
|
785
|
-
|
|
786
|
-
target.scrollIntoView({ block: 'center' });
|
|
787
|
-
target.focus();
|
|
788
|
-
if (target.isContentEditable) {
|
|
789
|
-
target.textContent = value;
|
|
790
|
-
} else {
|
|
791
|
-
// Frameworks track the value through the native setter; assigning the
|
|
792
|
-
// property directly leaves React and friends unaware of the change.
|
|
793
|
-
var prototype = target.tagName === 'TEXTAREA' ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
|
|
794
|
-
var setter = Object.getOwnPropertyDescriptor(prototype, 'value');
|
|
795
|
-
if (setter && setter.set) setter.set.call(target, value);
|
|
796
|
-
else target.value = value;
|
|
797
|
-
}
|
|
798
|
-
target.dispatchEvent(new Event('input', { bubbles: true }));
|
|
799
|
-
target.dispatchEvent(new Event('change', { bubbles: true }));
|
|
800
|
-
|
|
801
|
-
if (${n?"true":"false"}) {
|
|
802
|
-
var enter = { key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true };
|
|
803
|
-
target.dispatchEvent(new KeyboardEvent('keydown', enter));
|
|
804
|
-
target.dispatchEvent(new KeyboardEvent('keyup', enter));
|
|
805
|
-
var form = target.form;
|
|
806
|
-
if (form && typeof form.requestSubmit === 'function') form.requestSubmit();
|
|
807
|
-
}
|
|
808
|
-
return { ok: true, selector: cssPath(target), url: String(location.href) };
|
|
809
|
-
`),pv=({selector:t,direction:e})=>io(`
|
|
810
|
-
var selector = ${JSON.stringify(t??"")};
|
|
811
|
-
var direction = ${JSON.stringify(e??"")};
|
|
812
|
-
|
|
813
|
-
var settle = function (extra) {
|
|
814
|
-
return new Promise(function (resolve) {
|
|
815
|
-
requestAnimationFrame(function () {
|
|
816
|
-
requestAnimationFrame(function () {
|
|
817
|
-
var doc = document.documentElement;
|
|
818
|
-
var maxScrollY = Math.max(0, doc.scrollHeight - window.innerHeight);
|
|
819
|
-
var scrollY = Math.round(window.scrollY);
|
|
820
|
-
var result = { ok: true, scrollY: scrollY, maxScrollY: Math.round(maxScrollY) };
|
|
821
|
-
result.atTop = scrollY <= 1;
|
|
822
|
-
result.atBottom = scrollY >= maxScrollY - 1;
|
|
823
|
-
for (var key in extra) {
|
|
824
|
-
if (Object.prototype.hasOwnProperty.call(extra, key)) result[key] = extra[key];
|
|
825
|
-
}
|
|
826
|
-
resolve(result);
|
|
827
|
-
});
|
|
828
|
-
});
|
|
829
|
-
});
|
|
830
|
-
};
|
|
831
|
-
|
|
832
|
-
if (selector) {
|
|
833
|
-
var target = null;
|
|
834
|
-
try { target = document.querySelector(selector); }
|
|
835
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
836
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
837
|
-
// Instant on purpose: the page's own smooth scrolling would still be
|
|
838
|
-
// animating when the next action runs against it.
|
|
839
|
-
target.scrollIntoView({ block: 'center', behavior: 'instant' });
|
|
840
|
-
return settle({ scrolledTo: cssPath(target) });
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
var doc = document.documentElement;
|
|
844
|
-
var page = Math.round(window.innerHeight * 0.85);
|
|
845
|
-
var bottom = Math.max(0, doc.scrollHeight - window.innerHeight);
|
|
846
|
-
if (direction === 'down') window.scrollTo({ top: window.scrollY + page, behavior: 'instant' });
|
|
847
|
-
else if (direction === 'up') window.scrollTo({ top: window.scrollY - page, behavior: 'instant' });
|
|
848
|
-
else if (direction === 'top') window.scrollTo({ top: 0, behavior: 'instant' });
|
|
849
|
-
else if (direction === 'bottom') window.scrollTo({ top: bottom, behavior: 'instant' });
|
|
850
|
-
else return { ok: false, error: 'Unknown scroll direction: ' + direction };
|
|
851
|
-
return settle({ direction: direction });
|
|
852
|
-
`),gv=["color","background-color","background-image","opacity","font-family","font-size","font-weight","line-height","letter-spacing","text-align","border-radius","border-width","border-style","border-color","box-shadow","display","position","width","height","padding","margin","gap","flex-direction","justify-content","align-items","z-index","overflow","visibility"],xv=({selector:t})=>io(`
|
|
853
|
-
var selector = ${JSON.stringify(t)};
|
|
854
|
-
var target = null;
|
|
855
|
-
try { target = document.querySelector(selector); }
|
|
856
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
857
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
858
|
-
|
|
859
|
-
var computed = window.getComputedStyle(target);
|
|
860
|
-
var styles = {};
|
|
861
|
-
var props = ${JSON.stringify(gv)};
|
|
862
|
-
for (var i = 0; i < props.length; i += 1) {
|
|
863
|
-
var value = computed.getPropertyValue(props[i]);
|
|
864
|
-
if (value) styles[props[i]] = String(value).trim();
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
var rect = target.getBoundingClientRect();
|
|
868
|
-
return {
|
|
869
|
-
ok: true,
|
|
870
|
-
selector: cssPath(target),
|
|
871
|
-
tag: target.tagName.toLowerCase(),
|
|
872
|
-
label: label(target),
|
|
873
|
-
bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) },
|
|
874
|
-
inViewport: rect.bottom > 0 && rect.top < window.innerHeight,
|
|
875
|
-
styles: styles
|
|
876
|
-
};
|
|
877
|
-
`),bv=t=>{const e=et.c(18),{entries:n,activeIndex:r,onSelect:i,onForget:o,onHighlight:l}=t,{t:a}=kt();if(n.length===0)return null;let d;e[0]!==a?(d=a("contextPanel.browser.history.label"),e[0]=a,e[1]=d):d=e[1];let u;if(e[2]!==r||e[3]!==n||e[4]!==o||e[5]!==l||e[6]!==i||e[7]!==a){let f;e[9]!==r||e[10]!==o||e[11]!==l||e[12]!==i||e[13]!==a?(f=(p,y)=>s.jsxs("div",{role:"option","aria-selected":y===r,className:Re("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",y===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:x=>{x.preventDefault(),i(p.url)},onPointerEnter:()=>l(y),children:[s.jsx(F,{name:"global",className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate typography-micro text-foreground",children:p.title||dl(p.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:p.url})]}),s.jsx("button",{type:"button",className:Re("shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity","hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100"),"aria-label":a("contextPanel.browser.history.forget"),title:a("contextPanel.browser.history.forget"),onPointerDown:x=>{x.preventDefault(),x.stopPropagation(),o(p.url)},children:s.jsx(F,{name:"close",className:"size-3","aria-hidden":"true"})})]},p.url),e[9]=r,e[10]=o,e[11]=l,e[12]=i,e[13]=a,e[14]=f):f=e[14],u=n.map(f),e[2]=r,e[3]=n,e[4]=o,e[5]=l,e[6]=i,e[7]=a,e[8]=u}else u=e[8];let m;return e[15]!==d||e[16]!==u?(m=s.jsx("div",{className:"oc-glass-popover oc-glass-floating absolute inset-x-0 top-full z-50 mt-1 overflow-hidden rounded-xl p-1",role:"listbox","aria-label":d,children:u}),e[15]=d,e[16]=u,e[17]=m):m=e[17],m},en=t=>{const e=et.c(17),{icon:n,label:r,onClick:i,disabled:o,pressed:l}=t,a=l?"secondary":"ghost",d=l&&"text-foreground";let u;e[0]!==d?(u=Re("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",d),e[0]=d,e[1]=u):u=e[1];let m;e[2]!==n?(m=s.jsx(F,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,e[3]=m):m=e[3];let f;e[4]!==o||e[5]!==r||e[6]!==i||e[7]!==l||e[8]!==a||e[9]!==u||e[10]!==m?(f=s.jsx(vt,{asChild:!0,children:s.jsx(ut,{type:"button",variant:a,size:"xs",className:u,onClick:i,disabled:o,"aria-label":r,"aria-pressed":l,children:m})}),e[4]=o,e[5]=r,e[6]=i,e[7]=l,e[8]=a,e[9]=u,e[10]=m,e[11]=f):f=e[11];let p;e[12]!==r?(p=s.jsx(St,{sideOffset:6,children:r}),e[12]=r,e[13]=p):p=e[13];let y;return e[14]!==f||e[15]!==p?(y=s.jsxs(wt,{children:[f,p]}),e[14]=f,e[15]=p,e[16]=y):y=e[16],y},zf=t=>{const e=et.c(104),{address:n,suggestions:r,onForgetSuggestion:i,onAddressChange:o,onSubmit:l,onBack:a,onForward:d,onReload:u,onOpenExternal:m,canGoBack:f,canGoForward:p,isLoading:y,onAnnotate:x,onOpenDevTools:k,isAnnotating:w,onHardReload:h,onZoomIn:g,onZoomOut:j,onZoomReset:b,zoomPercent:S,onClearCookies:C,onClearCache:v,onToggleDeviceBar:M,isDeviceBarOpen:R}=t;let I;e[0]!==r?(I=r===void 0?[]:r,e[0]=r,e[1]=I):I=e[1];const B=I,O=S===void 0?100:S,{t:T}=kt(),[$,_]=c.useState(!1),[Y,L]=c.useState(-1);let A;e[2]!==$||e[3]!==B?(A=$?B:[],e[2]=$,e[3]=B,e[4]=A):A=e[4];const D=A;let P;e[5]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{L(-1)},e[5]=P):P=e[5];let Z;e[6]!==n||e[7]!==$?(Z=[n,$],e[6]=n,e[7]=$,e[8]=Z):Z=e[8],c.useEffect(P,Z);let X;e[9]!==l?(X=_e=>{_(!1),L(-1),l(_e)},e[9]=l,e[10]=X):X=e[10];const se=X;let ce;e[11]!==Y||e[12]!==se||e[13]!==D?(ce=_e=>{if(D.length!==0){if(_e.key==="ArrowDown"||_e.key==="ArrowUp"){_e.preventDefault();const Ae=_e.key==="ArrowDown"?1:-1,Me=D.length;L(q=>{const Ne=q+Ae;return Ne<-1?Me-1:Ne>=Me?-1:Ne});return}if(_e.key==="Escape"&&Y>=0){_e.preventDefault(),L(-1);return}if(_e.key==="Enter"&&Y>=0){_e.preventDefault();const Ae=D[Y];Ae&&se(Ae.url)}}},e[11]=Y,e[12]=se,e[13]=D,e[14]=ce):ce=e[14];const re=ce;let ge;e[15]!==T?(ge=T("contextPanel.browser.back"),e[15]=T,e[16]=ge):ge=e[16];const ae=!f;let Ee;e[17]!==a||e[18]!==ae||e[19]!==ge?(Ee=s.jsx(en,{icon:"arrow-left",label:ge,onClick:a,disabled:ae}),e[17]=a,e[18]=ae,e[19]=ge,e[20]=Ee):Ee=e[20];let Se;e[21]!==T?(Se=T("contextPanel.browser.forward"),e[21]=T,e[22]=Se):Se=e[22];const me=!p;let ke;e[23]!==d||e[24]!==Se||e[25]!==me?(ke=s.jsx(en,{icon:"arrow-right",label:Se,onClick:d,disabled:me}),e[23]=d,e[24]=Se,e[25]=me,e[26]=ke):ke=e[26];let V;e[27]!==y||e[28]!==T?(V=T(y?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=y,e[28]=T,e[29]=V):V=e[29];let J;e[30]!==u||e[31]!==V?(J=s.jsx(en,{icon:"refresh",label:V,onClick:u}),e[30]=u,e[31]=V,e[32]=J):J=e[32];let de;e[33]!==h||e[34]!==T?(de=h?s.jsx(en,{icon:"restart",label:T("contextPanel.browser.hardReload"),onClick:h}):null,e[33]=h,e[34]=T,e[35]=de):de=e[35];let we;e[36]!==n||e[37]!==se?(we=_e=>{_e.preventDefault(),se(n)},e[36]=n,e[37]=se,e[38]=we):we=e[38];let G;e[39]!==o?(G=_e=>o(_e.target.value),e[39]=o,e[40]=G):G=e[40];let Ce,Te;e[41]===Symbol.for("react.memo_cache_sentinel")?(Ce=()=>_(!0),Te=()=>_(!1),e[41]=Ce,e[42]=Te):(Ce=e[41],Te=e[42]);const pe=D.length>0;let ne;e[43]===Symbol.for("react.memo_cache_sentinel")?(ne=Re("h-6 w-full rounded-full border border-border/50 bg-[var(--surface-elevated)] px-3","typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[43]=ne):ne=e[43];let xe;e[44]!==T?(xe=T("contextPanel.browser.addressAria"),e[44]=T,e[45]=xe):xe=e[45];let U;e[46]!==n||e[47]!==re||e[48]!==G||e[49]!==pe||e[50]!==xe?(U=s.jsx("input",{value:n,onChange:G,onFocus:Ce,onBlur:Te,onKeyDown:re,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":pe,"aria-controls":"openchamber-browser-address-suggestions",className:ne,"aria-label":xe}),e[46]=n,e[47]=re,e[48]=G,e[49]=pe,e[50]=xe,e[51]=U):U=e[51];let z;e[52]!==i?(z=_e=>i?.(_e),e[52]=i,e[53]=z):z=e[53];let Q;e[54]!==Y||e[55]!==se||e[56]!==z||e[57]!==D?(Q=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(bv,{entries:D,activeIndex:Y,onSelect:se,onForget:z,onHighlight:L})}),e[54]=Y,e[55]=se,e[56]=z,e[57]=D,e[58]=Q):Q=e[58];let ue;e[59]!==we||e[60]!==U||e[61]!==Q?(ue=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:we,children:[U,Q]}),e[59]=we,e[60]=U,e[61]=Q,e[62]=ue):ue=e[62];let le;e[63]!==g||e[64]!==j||e[65]!==b||e[66]!==T||e[67]!==O?(le=j&&g?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(en,{icon:"subtract",label:T("contextPanel.browser.zoomOut"),onClick:j}),O!==100&&b?s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsxs(ut,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:b,"aria-label":T("contextPanel.browser.zoomReset"),children:[O,"%"]})}),s.jsx(St,{sideOffset:6,children:T("contextPanel.browser.zoomReset")})]}):null,s.jsx(en,{icon:"add",label:T("contextPanel.browser.zoomIn"),onClick:g})]}):null,e[63]=g,e[64]=j,e[65]=b,e[66]=T,e[67]=O,e[68]=le):le=e[68];let W;e[69]!==C||e[70]!==T?(W=C?s.jsx(en,{icon:"delete-bin",label:T("contextPanel.browser.clearCookies"),onClick:C}):null,e[69]=C,e[70]=T,e[71]=W):W=e[71];let E;e[72]!==v||e[73]!==T?(E=v?s.jsx(en,{icon:"database-2",label:T("contextPanel.browser.clearCache"),onClick:v}):null,e[72]=v,e[73]=T,e[74]=E):E=e[74];let K;e[75]!==R||e[76]!==M||e[77]!==T?(K=M?s.jsx(en,{icon:"smartphone",label:T("contextPanel.browser.deviceToolbar"),onClick:M,pressed:R}):null,e[75]=R,e[76]=M,e[77]=T,e[78]=K):K=e[78];let te;e[79]!==w||e[80]!==x||e[81]!==T?(te=x?s.jsx(en,{icon:"markup",label:T("contextPanel.browser.annotate.toggle"),onClick:x,pressed:w}):null,e[79]=w,e[80]=x,e[81]=T,e[82]=te):te=e[82];let oe;e[83]!==k||e[84]!==T?(oe=k?s.jsx(en,{icon:"terminal-box",label:T("contextPanel.browser.devTools"),onClick:k}):null,e[83]=k,e[84]=T,e[85]=oe):oe=e[85];let he;e[86]!==T?(he=T("contextPanel.browser.openExternal"),e[86]=T,e[87]=he):he=e[87];let ie;e[88]!==m||e[89]!==he?(ie=s.jsx(en,{icon:"external-link",label:he,onClick:m}),e[88]=m,e[89]=he,e[90]=ie):ie=e[90];let Fe;return e[91]!==Ee||e[92]!==ke||e[93]!==J||e[94]!==de||e[95]!==ue||e[96]!==le||e[97]!==W||e[98]!==E||e[99]!==K||e[100]!==te||e[101]!==oe||e[102]!==ie?(Fe=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[Ee,ke,J,de,ue,le,W,E,K,te,oe,ie]}),e[91]=Ee,e[92]=ke,e[93]=J,e[94]=de,e[95]=ue,e[96]=le,e[97]=W,e[98]=E,e[99]=K,e[100]=te,e[101]=oe,e[102]=ie,e[103]=Fe):Fe=e[103],Fe},Go={kind:"fill"},Oc=240,yv=3840,Wf=[{id:"iphone-se",label:"iPhone SE",width:375,height:667},{id:"iphone-14",label:"iPhone 14",width:390,height:844},{id:"iphone-14-pro-max",label:"iPhone 14 Pro Max",width:430,height:932},{id:"pixel-7",label:"Pixel 7",width:412,height:915},{id:"ipad-mini",label:"iPad mini",width:768,height:1024},{id:"ipad-pro",label:"iPad Pro",width:1024,height:1366},{id:"laptop",label:"Laptop",width:1280,height:800},{id:"desktop",label:"Desktop",width:1440,height:900}],Bc=t=>Number.isFinite(t)?Math.round(Math.min(yv,Math.max(Oc,t))):Oc,qo=t=>t.kind==="fill"?null:{width:t.width,height:t.height},Kf=t=>{const e=Wf.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},wv=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},vv=(t,e)=>{const n=qo(t);if(!n)return null;const r=Math.max(1,e.width),i=Math.max(1,e.height),o=Math.min(1,r/n.width,i/n.height);return{width:n.width,height:n.height,scale:o}},Sv=["mobile","tablet","desktop","fill"],jv={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},Fc=t=>typeof t=="string"&&Sv.includes(t),Na=t=>t==="fill"?Go:Kf(jv[t])??Go,yo=t=>{const e=qo(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=Na(n),i=qo(r);if(i&&i.width===e.width&&i.height===e.height)return{mode:n,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},kv=t=>{const e=et.c(70),{viewport:n,onViewportChange:r,colorScheme:i,onColorSchemeChange:o,scale:l}=t,{t:a}=kt();let d;e[0]!==n?(d=qo(n),e[0]=n,e[1]=d):d=e[1];const u=d,m=n.kind==="preset"?n.id:"";let f;e[2]!==r||e[3]!==u?(f=(ae,Ee)=>{const Se=Number.parseInt(Ee,10);if(!Number.isFinite(Se))return;const me=u??{width:1280,height:800};r({kind:"custom",width:Bc(ae==="width"?Se:me.width),height:Bc(ae==="height"?Se:me.height)})},e[2]=r,e[3]=u,e[4]=f):f=e[4];const p=f;let y;e[5]===Symbol.for("react.memo_cache_sentinel")?(y=Re("h-6 w-14 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2 text-center","typography-micro tabular-nums text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[5]=y):y=e[5];const x=y;let k;e[6]!==r?(k=ae=>{const Ee=Kf(ae.target.value);r(Ee??Go)},e[6]=r,e[7]=k):k=e[7];let w;e[8]!==a?(w=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=w):w=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=Re("h-6 shrink-0 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2","typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[10]=h):h=e[10];let g;e[11]!==a?(g=a("contextPanel.browser.device.responsive"),e[11]=a,e[12]=g):g=e[12];let j;e[13]!==g?(j=s.jsx("option",{value:"",children:g}),e[13]=g,e[14]=j):j=e[14];let b;e[15]===Symbol.for("react.memo_cache_sentinel")?(b=Wf.map(Cv),e[15]=b):b=e[15];let S;e[16]!==m||e[17]!==k||e[18]!==w||e[19]!==j?(S=s.jsxs("select",{value:m,onChange:k,"aria-label":w,className:h,children:[j,b]}),e[16]=m,e[17]=k,e[18]=w,e[19]=j,e[20]=S):S=e[20];const C=u?String(u.width):"";let v;e[21]!==p?(v=ae=>p("width",ae.target.value),e[21]=p,e[22]=v):v=e[22];let M;e[23]!==a?(M=a("contextPanel.browser.device.width"),e[23]=a,e[24]=M):M=e[24];let R;e[25]!==C||e[26]!==v||e[27]!==M?(R=s.jsx("input",{value:C,onChange:v,placeholder:"—",inputMode:"numeric","aria-label":M,className:x}),e[25]=C,e[26]=v,e[27]=M,e[28]=R):R=e[28];let I;e[29]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=I):I=e[29];const B=u?String(u.height):"";let O;e[30]!==p?(O=ae=>p("height",ae.target.value),e[30]=p,e[31]=O):O=e[31];let T;e[32]!==a?(T=a("contextPanel.browser.device.height"),e[32]=a,e[33]=T):T=e[33];let $;e[34]!==B||e[35]!==O||e[36]!==T?($=s.jsx("input",{value:B,onChange:O,placeholder:"—",inputMode:"numeric","aria-label":T,className:x}),e[34]=B,e[35]=O,e[36]=T,e[37]=$):$=e[37];let _;e[38]!==r||e[39]!==n?(_=()=>r(wv(n)),e[38]=r,e[39]=n,e[40]=_):_=e[40];const Y=!u;let L;e[41]!==a?(L=a("contextPanel.browser.device.rotate"),e[41]=a,e[42]=L):L=e[42];let A;e[43]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx(F,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=A):A=e[43];let D;e[44]!==_||e[45]!==Y||e[46]!==L?(D=s.jsx(vt,{asChild:!0,children:s.jsx(ut,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:_,disabled:Y,"aria-label":L,children:A})}),e[44]=_,e[45]=Y,e[46]=L,e[47]=D):D=e[47];let P;e[48]!==a?(P=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=P):P=e[49];let Z;e[50]!==P?(Z=s.jsx(St,{sideOffset:6,children:P}),e[50]=P,e[51]=Z):Z=e[51];let X;e[52]!==D||e[53]!==Z?(X=s.jsxs(wt,{children:[D,Z]}),e[52]=D,e[53]=Z,e[54]=X):X=e[54];let se;e[55]!==l||e[56]!==u?(se=u&&l<1?s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(l*100),"%"]}):null,e[55]=l,e[56]=u,e[57]=se):se=e[57];let ce;e[58]===Symbol.for("react.memo_cache_sentinel")?(ce=["system","light","dark"],e[58]=ce):ce=e[58];let re;e[59]!==i||e[60]!==o||e[61]!==a?(re=s.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:ce.map(ae=>s.jsx(ut,{type:"button",variant:i===ae?"secondary":"ghost",size:"xs",className:Re("shrink-0 rounded-full px-2.5 typography-micro",i===ae?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>o(ae),"aria-pressed":i===ae,children:a(ae==="system"?"contextPanel.browser.device.schemeSystem":ae==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},ae))}),e[59]=i,e[60]=o,e[61]=a,e[62]=re):re=e[62];let ge;return e[63]!==S||e[64]!==R||e[65]!==$||e[66]!==X||e[67]!==se||e[68]!==re?(ge=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[S,R,I,$,X,se,re]}),e[63]=S,e[64]=R,e[65]=$,e[66]=X,e[67]=se,e[68]=re,e[69]=ge):ge=e[69],ge};function Cv(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const Nv=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},Av=2e3,Pv=()=>{if(typeof window>"u"||window.__OPENCHAMBER_ELECTRON__)return!1;const t=En();if(!t)return!1;try{return!Ir(new URL(t,window.location.href).toString())}catch{return!1}},Vf=t=>{const e=et.c(33),{onOpen:n,directory:r}=t,i=r===void 0?"":r,{t:o}=kt();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={kind:"loading"},e[0]=l):l=e[0];const[a,d]=c.useState(l),u=zb(i),[m]=c.useState(Pv);let f,p;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{let R=!0,I=null;const B=new AbortController,O=()=>{vw(B.signal).then(T=>{R&&(d(T),I=setTimeout(O,Av))})};return O(),()=>{R=!1,I&&clearTimeout(I),B.abort()}},p=[],e[1]=f,e[2]=p):(f=e[1],p=e[2]),c.useEffect(f,p);const y=a.kind==="ready"?a.servers:null;let x;e[3]!==u||e[4]!==y?(x=kw({announced:u,discovered:y}),e[3]=u,e[4]=y,e[5]=x):x=e[5];const k=x;let w;e[6]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(Eu,{width:110,height:110,className:"shrink-0 opacity-20"}),e[6]=w):w=e[6];let h;e[7]!==o?(h=o("contextPanel.browser.empty"),e[7]=o,e[8]=h):h=e[8];let g;e[9]!==h?(g=s.jsx("span",{className:"typography-ui-header text-foreground",children:h}),e[9]=h,e[10]=g):g=e[10];let j;e[11]!==o?(j=o("contextPanel.browser.emptyHint"),e[11]=o,e[12]=j):j=e[12];let b;e[13]!==j?(b=s.jsx("span",{className:"typography-micro text-muted-foreground",children:j}),e[13]=j,e[14]=b):b=e[14];let S;e[15]!==b||e[16]!==g?(S=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[g,b]}),e[15]=b,e[16]=g,e[17]=S):S=e[17];let C;e[18]!==u||e[19]!==k||e[20]!==i||e[21]!==n||e[22]!==m||e[23]!==o?(C=k.length>0?s.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[s.jsx("span",{className:"shrink-0 typography-micro text-left text-muted-foreground",children:u.length>0?o("contextPanel.browser.devServers.justStarted"):o("contextPanel.browser.devServers.title")}),m?s.jsx("span",{className:"shrink-0 pb-1 text-left typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.remoteOnly")}):null,s.jsx("div",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto pr-0.5",children:k.map(R=>s.jsxs(ut,{type:"button",variant:"outline",size:"sm",className:"w-full shrink-0 justify-start gap-2",onClick:()=>{_b(i),n(R.url)},children:[s.jsx(F,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:dl(R.url)||R.url}),s.jsx("span",{className:"ml-auto truncate typography-micro text-muted-foreground",children:Nv(R.url)})]},R.port))})]}):null,e[18]=u,e[19]=k,e[20]=i,e[21]=n,e[22]=m,e[23]=o,e[24]=C):C=e[24];let v;e[25]!==k.length||e[26]!==a.kind||e[27]!==o?(v=k.length===0&&a.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.unavailable")}):null,e[25]=k.length,e[26]=a.kind,e[27]=o,e[28]=v):v=e[28];let M;return e[29]!==S||e[30]!==C||e[31]!==v?(M=s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-5 overflow-hidden bg-background p-6 text-center",children:[w,S,C,v]}),e[29]=S,e[30]=C,e[31]=v,e[32]=M):M=e[32],M},Fs=t=>Math.round(t),Dv=(t,e)=>{const n=t.text.trim(),r=Object.entries(t.attributes).map(([a,d])=>`${a}="${d}"`).join(" "),i=t.ancestry.map(a=>a.selectorPart).join(" > "),o=t.computedStyle,l=t.bounds;return[`Element ${e+1}: ${t.tag}`,n?`- Text: ${n}`:null,`- Selector: ${t.selector}`,`- Path: ${t.path}`,i?`- Ancestry: ${i}`:null,r?`- Attributes: ${r}`:null,`- Bounds: x=${Fs(l.x)}, y=${Fs(l.y)}, width=${Fs(l.width)}, height=${Fs(l.height)}`,`- Styles: display=${o.display??""}; position=${o.position??""}; font=${o.fontWeight??""} ${o.fontSize??""} / ${o.lineHeight??""} ${o.fontFamily??""}; color=${o.color??""}; background=${o.backgroundColor??""}`].filter(a=>typeof a=="string")},Iv=(t,e)=>{const n=t.rect;return`Region ${e+1}: x=${Fs(n.x)}, y=${Fs(n.y)}, width=${Fs(n.width)}, height=${Fs(n.height)}`},Tv=(t,e)=>{const n=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${Fs(n.x)}, y=${Fs(n.y)}, width=${Fs(n.width)}, height=${Fs(n.height)}`},Ev=({payload:t,screenshotAttached:e,intro:n})=>{const r=n.replace(/[.:]+$/g,""),i=t.comment.trim(),o=[`${r}:`,`Page: ${t.pageTitle.trim()||t.pageUrl||"browser"}`,t.pageTitle.trim()&&t.pageUrl?`URL: ${t.pageUrl}`:null,`Viewport: ${Fs(t.viewport.width)}x${Fs(t.viewport.height)}, DPR ${t.devicePixelRatio}`,`Screenshot: ${e?"attached":"not attached"}`,i?`Comment: ${i}`:null];for(const[l,a]of t.elements.entries())o.push("",...Dv(a.element,l));return t.regions.length>0&&(o.push(""),t.regions.forEach((l,a)=>o.push(Iv(l,a)))),t.strokes.length>0&&(o.push(""),t.strokes.forEach((l,a)=>o.push(Tv(l,a)))),o.filter(l=>typeof l=="string").join(`
|
|
878
|
-
`)},Rv=t=>{const e=et.c(7),{t:n}=kt(),r=nt(Ov),i=nt(Bv),o=ea(Fv),l=Jp(_v);let a;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==t||e[4]!==i||e[5]!==n?(a=async d=>{const u=r??(i?"draft":null);if(!u){ze.error(n("contextPanel.browser.annotate.noSession"));return}let m=!1;if(d.screenshot)try{await l(d.screenshot),m=!0}catch{m=!1}o({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:d.payload.pageUrl||"browser",startLine:1,endLine:1,code:Ev({payload:d.payload,screenshotAttached:m,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),ze.success(n("contextPanel.browser.annotate.attached"))},e[0]=l,e[1]=o,e[2]=r,e[3]=t,e[4]=i,e[5]=n,e[6]=a):a=e[6],a},Mv=()=>{const t=et.c(16),{t:e}=kt();let n;t[0]!==e?(n=e("contextPanel.browser.annotate.tool.element"),t[0]=e,t[1]=n):n=t[1];let r;t[2]!==e?(r=e("contextPanel.browser.annotate.tool.region"),t[2]=e,t[3]=r):r=t[3];let i;t[4]!==e?(i=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=i):i=t[5];let o;t[6]!==e?(o=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=o):o=t[7];let l;t[8]!==e?(l=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=l):l=t[9];let a;return t[10]!==n||t[11]!==r||t[12]!==i||t[13]!==o||t[14]!==l?(a={select:n,marquee:r,draw:i,commentPlaceholder:o,submit:l},t[10]=n,t[11]=r,t[12]=i,t[13]=o,t[14]=l,t[15]=a):a=t[15],a};function Ov(t){return t.currentSessionId}function Bv(t){return t.newSessionDraft?.open}function Fv(t){return t.addDraft}function _v(t){return t.addAttachedFile}const Lv=3e4,$v=3,zv=250,Wv={attempts:0,windowStartedAt:null},Kv=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=Lv,r=n?0:t.attempts;return r>=$v?null:{delayMs:zv*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},Vv=-3,wo=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",vr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},Uv=(t,{initialUrl:e,onUrlChange:n})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:Aw),[o,l]=c.useState(e),[a,d]=c.useState(""),[u,m]=c.useState(!1),[f,p]=c.useState(!1),y=c.useRef(n);y.current=n;const x=c.useRef(Wv);return c.useEffect(()=>{if(!t)return;const k=()=>{try{const I=t.getURL();return wo(I)?I:""}catch{return""}},w=()=>{try{m(t.canGoBack()),p(t.canGoForward())}catch{}},h=I=>{wo(I)&&(l(I),y.current(I))},g=()=>{const I=k();i({kind:"loading",url:I})},j=()=>{const I=k();let B="";try{B=t.getTitle()||""}catch{B=""}d(B),h(I),w(),i(O=>O.kind==="failed"&&O.url===I?O:{kind:"ready",url:I,title:B})},b=I=>{const B=vr(I);wo(B.url)&&(h(B.url),w())},S=I=>{const B=vr(I),O=Array.isArray(B.favicons)?B.favicons.find(Boolean):"",T=k();O&&T&&Pf.getState().resolve(T,O)},C=I=>{const B=vr(I);typeof B.title=="string"&&d(B.title)},v=I=>{const B=vr(I);if(B.isMainFrame===!1)return;const O=typeof B.errorCode=="number"?B.errorCode:0;O!==Vv&&i({kind:"failed",url:wo(B.validatedURL)?B.validatedURL:k(),code:O,description:typeof B.errorDescription=="string"?B.errorDescription:""})};let M=null;const R=()=>{const I=k(),B=Kv(x.current,Date.now());if(!B){i({kind:"failed",url:I,code:0,description:"",crashed:!0});return}x.current=B.state,i({kind:"loading",url:I}),M=setTimeout(()=>{M=null;try{t.reload()}catch{i({kind:"failed",url:I,code:0,description:"",crashed:!0})}},B.delayMs)};t.addEventListener("did-start-loading",g),t.addEventListener("did-stop-loading",j),t.addEventListener("did-navigate",b),t.addEventListener("did-navigate-in-page",b),t.addEventListener("page-title-updated",C),t.addEventListener("page-favicon-updated",S),t.addEventListener("did-fail-load",v),t.addEventListener("render-process-gone",R),t.addEventListener("crashed",R);try{!t.isLoading()&&k()&&j()}catch{}return()=>{M!==null&&clearTimeout(M),t.removeEventListener("render-process-gone",R),t.removeEventListener("crashed",R),t.removeEventListener("did-start-loading",g),t.removeEventListener("did-stop-loading",j),t.removeEventListener("did-navigate",b),t.removeEventListener("did-navigate-in-page",b),t.removeEventListener("page-title-updated",C),t.removeEventListener("page-favicon-updated",S),t.removeEventListener("did-fail-load",v)}},[t]),{status:r,url:o,title:a,canGoBack:u,canGoForward:f}},Hv=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Gv=4e4,vo=.5,qv=-3,Yv=4,Qv="persist:openchamber-browser",_c=20,Xv=600,Jv=2e4,Zv=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=kt(),{currentTheme:i}=Kn(),o=c.useRef(null),[l,a]=c.useState(null),d=c.useCallback(W=>{o.current=W,a(W)},[]),u=Pe(W=>W.setContextPanelTabTargetPath),m=c.useRef(Cr(t)),f=m.current!==tn?m.current:"",[p,y]=c.useState(f?null:tn),[x,k]=c.useState(f),[w,h]=c.useState(!1),[g,j]=c.useState(!1),[b,S]=c.useState(0),C=c.useRef(0),[v,M]=c.useState(!1),[R,I]=c.useState(Go),B=c.useRef(R);B.current=R;const O=c.useRef([]),[T,$]=c.useState("system"),[_,Y]=c.useState({width:0,height:0}),L=c.useRef(null),A=c.useRef(null),D=c.useRef(!1),P=c.useRef(Date.now()),Z=c.useCallback(W=>{!W||W===tn||!e||!n||u(e,n,W)},[e,n,u]),X=Uv(l,{initialUrl:f,onUrlChange:c.useCallback(W=>{const E=pr(W);k(E),Z(E)},[Z])}),[se,ce]=c.useState(null),re=Rv(e),ge=Mv(),ae=X.status.kind==="loading",Ee=Nr(Ff(e)),Se=Nr(W=>W.recordVisit),me=Nr(W=>W.forget);c.useEffect(()=>{X.status.kind==="ready"&&Se(e,{url:pr(X.status.url),title:X.status.title})},[e,X.status,Se]);const ke=c.useMemo(()=>Bf(Ee,x),[Ee,x]),V=c.useCallback(W=>{const E=Cr(W);E!==tn&&(k(E),ce(null),Ec(E).then(K=>{const te=o.current;if(!te){y(K);return}try{te.loadURL(K)}catch{y(K)}}).catch(K=>{K instanceof qr&&ce(E)}))},[]);c.useEffect(()=>{if(!f)return;let W=!0;return Ec(f).then(E=>{W&&y(E)}).catch(E=>{if(W){if(E instanceof qr){ce(f),y(tn);return}y(f)}}),()=>{W=!1}},[]);const J=c.useMemo(()=>({executeJavaScript:async(W,E)=>{const K=o.current;if(!K)throw new Error("Browser view is not available");return K.executeJavaScript(W,E)},capturePage:async()=>{const W=o.current;if(!W)return null;const E=W.getWebContentsId();return Number.isFinite(E)?await jr("desktop_browser_capture_page",{webContentsId:E}):null}}),[]),de=c.useCallback(()=>{if(w){h(!1),Mo(J);return}if(!X.url){ze.error(r("contextPanel.browser.annotate.noPage"));return}const W=zw(i.metadata.variant==="light"?"light":"dark");h(!0),Lw({host:J,theme:W,labels:ge}).then(async E=>{h(!1),E&&await re(E)}).catch(()=>{h(!1),ze.error(r("contextPanel.browser.annotate.failed"))})},[J,re,i,w,X.url,ge,r]);c.useEffect(()=>{if(!w)return;const W=E=>{Zp(E)||E.key!=="Escape"||(E.preventDefault(),E.stopImmediatePropagation(),h(!1),Mo(J))};return window.addEventListener("keydown",W,!0),()=>window.removeEventListener("keydown",W,!0)},[J,w]);const we=c.useCallback(async(W=8e3)=>{const E=Date.now();for(;;){const K=o.current;if(!K)return!1;let te=!1;try{te=K.isLoading()}catch{return!1}if(!te)return!0;if(Date.now()-E>W)return!1;await new Promise(oe=>setTimeout(oe,120))}},[]),G=c.useCallback(async(W,E)=>{const K=o.current;if(!K)throw new Error("The browser panel is not ready");const te=()=>{Fc(E.viewport)&&(I(Na(E.viewport)),M(!0))};if(W==="browser.back"||W==="browser.forward"){const Ae=W==="browser.back";if(!(Ae?K.canGoBack():K.canGoForward()))throw new Error(Ae?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");Ae?K.goBack():K.goForward(),await new Promise(Ne=>setTimeout(Ne,150)),await we();let q="";try{q=K.getTitle()||""}catch{q=""}return{url:pr(K.getURL()),title:q}}if(W==="browser.capture"){const Ae=Pe.getState(),Me=er(e),q=Ae.contextPanelByDirectory[Me],Ne=!!(q?.isOpen&&q.activeTabId===n);Ne||Ae.setActiveContextPanelTab(e,n);const je=()=>{if(Ne||!q)return;const We=Pe.getState(),tt=We.contextPanelByDirectory[Me];!tt?.isOpen||tt.activeTabId!==n||(q.activeTabId&&q.activeTabId!==n&&We.setActiveContextPanelTab(e,q.activeTabId),q.isOpen||We.closeContextPanel(e))};try{const We=Date.now()+1200;let tt=0,it=0;for(;it<2&&Date.now()<We;){const ft=K.getBoundingClientRect().width;it=ft>=2&&Math.abs(ft-tt)<.5?it+1:0,tt=ft,await new Promise(st=>setTimeout(st,50))}await new Promise(ft=>{requestAnimationFrame(()=>requestAnimationFrame(()=>ft()))}),await we();const rt=await J.capturePage();if(!rt)throw new Error("The page could not be captured");let ot="";try{ot=K.getTitle()||""}catch{ot=""}return{...rt,url:pr(K.getURL()),title:ot,viewport:yo(B.current)}}finally{je()}}if(W==="browser.resize"){if(!Fc(E.viewport))throw new Error("viewport is required");return te(),await new Promise(Ae=>setTimeout(Ae,200)),await we(),{viewport:yo(Na(E.viewport))}}if(W==="browser.open"){const Ae=typeof E.url=="string"?E.url:"";if(!Ae)throw new Error("url is required");te(),V(Ae),await new Promise(Ne=>setTimeout(Ne,150));const Me=await we(25e3);let q="";try{q=K.getTitle()||""}catch{q=""}return{url:Cr(Ae),title:q,opened:!0,settled:Me,viewport:yo(B.current)}}await we();const oe=Ae=>typeof Ae=="string"&&Ae?Ae:void 0,ie=(()=>{switch(W){case"browser.snapshot":return fv({selector:oe(E.selector)});case"browser.click":return mv({selector:oe(E.selector),text:oe(E.text)});case"browser.type":return hv({selector:String(E.selector??""),value:String(E.value??""),submit:E.submit===!0});case"browser.inspect":return xv({selector:String(E.selector??"")});case"browser.scroll":return pv({selector:oe(E.selector),direction:oe(E.direction)});default:return null}})();if(!ie)throw new Error(`Unsupported browser action: ${W}`);const Fe=await K.executeJavaScript(ie,!0);if(!Fe||typeof Fe!="object")throw new Error("The page returned no result");const _e=Fe;if(_e.ok!==!0)throw new Error(typeof _e.error=="string"&&_e.error?_e.error:"Browser action failed");if(W==="browser.snapshot"){const Ae=O.current;return{..._e,viewport:yo(B.current),...Ae.length>0?{consoleProblems:[...Ae]}:{}}}return(W==="browser.click"||W==="browser.type"&&E.submit===!0)&&(await new Promise(Ae=>setTimeout(Ae,150)),await we()),Fe},[J,e,V,n,we]),Ce=c.useCallback(()=>{const W=o.current;if(!W)return{title:"",url:""};let E="",K="";try{E=W.getTitle()||""}catch{E=""}try{K=pr(W.getURL())}catch{K=""}return{title:E,url:K}},[]);c.useEffect(()=>Yw({tabId:n,describe:Ce,run:G}),[Ce,G,n]),c.useEffect(()=>{const W=J;return()=>{Mo(W)}},[J]),c.useEffect(()=>{if(!l)return;const W=K=>{const te=K;if(typeof te.level!="number"||te.level<2)return;const oe=te.sourceId?`${te.sourceId}${te.line?`:${te.line}`:""}`:"";O.current.push({level:te.level>=3?"error":"warning",message:String(te.message??"").slice(0,400),source:oe}),O.current.length>_c&&O.current.splice(0,O.current.length-_c)},E=()=>{O.current=[]};return l.addEventListener("console-message",W),l.addEventListener("did-start-loading",E),()=>{l.removeEventListener("console-message",W),l.removeEventListener("did-start-loading",E)}},[l]);const Te=c.useRef(new Set),pe=c.useCallback(W=>{Te.current.clear(),V(W)},[V]);c.useEffect(()=>{if(!l)return;const W=K=>{const te=vr(K),oe=typeof te.url=="string"?te.url:"";!oe||!Rc(oe)||(K.preventDefault(),V(oe))},E=K=>{const te=vr(K);if(te.isMainFrame===!1||te.errorCode===-3)return;const oe=typeof te.validatedURL=="string"?te.validatedURL:"";!oe||!Rc(oe)||Te.current.has(oe)||(Te.current.add(oe),V(oe))};return l.addEventListener("will-navigate",W),l.addEventListener("did-fail-load",E),()=>{l.removeEventListener("will-navigate",W),l.removeEventListener("did-fail-load",E)}},[V,l]),c.useEffect(()=>{if(!l)return;const W=E=>{const K=E.detail;E.preventDefault(),K?.url&&V(K.url)};return l.addEventListener("new-window",W),()=>l.removeEventListener("new-window",W)},[V,l]);const ne=c.useCallback(W=>{const E=Math.min(Yv,Math.max(qv,W));C.current=E,S(E);try{o.current?.setZoomLevel(E)}catch{}},[]);c.useEffect(()=>{const W=E=>{if(!(E instanceof CustomEvent))return;const K=E.detail,te=o.current;!te||document.activeElement!==te||(K==="zoom-in"?ne(C.current+vo):K==="zoom-out"?ne(C.current-vo):K==="zoom-reset"&&ne(0))};return window.addEventListener("openchamber:zoom",W),()=>window.removeEventListener("openchamber:zoom",W)},[ne]);const xe=c.useCallback(W=>{jr("desktop_browser_clear_data",{partition:Qv,cookies:W==="cookies",cache:W==="cache"}).then(()=>{ze.success(r(W==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>ze.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const W=L.current;if(!W||typeof ResizeObserver>"u")return;const E=new ResizeObserver(K=>{const te=K[0]?.contentRect;te&&Y({width:te.width,height:te.height})});return E.observe(W),()=>E.disconnect()},[]);const U=c.useCallback(W=>{$(W);const E=o.current;if(!E)return;let K=-1;try{K=E.getWebContentsId()}catch{return}jr("desktop_browser_set_color_scheme",{webContentsId:K,scheme:W}).catch(te=>{$("system"),ze.error(te instanceof Error?te.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),z=c.useCallback(()=>{try{ae?o.current?.stop():o.current?.reload()}catch{}},[ae]),Q=X.status;c.useEffect(()=>{const W=()=>{j(!0);const te=setTimeout(()=>{try{o.current?.reload()}catch{}},Xv);return()=>clearTimeout(te)};if(Q.kind==="failed"){if(!yw(Q.code,Q.url)){j(!1);return}const te=Date.now(),oe=A.current?.url===Q.url?A.current:{url:Q.url,startedAt:te};if(A.current=oe,te-oe.startedAt>Gv){j(!1);return}return W()}if(Q.kind==="loading")return;if(A.current=null,Q.kind!=="ready"||!Q.url||!Ir(Q.url)){D.current=!0,j(!1);return}if(D.current||Date.now()-P.current>Jv){D.current=!0,j(!1);return}let E=!1,K=null;return Sw(pr(Q.url)).then(te=>{if(!E){if(te===null||te<500){D.current=!0,j(!1);return}K=W()}}),()=>{E=!0,K?.()}},[Q]);const ue=X.status.kind==="failed"&&!g?X.status:null,le=vv(R,_);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(zf,{address:x,onAddressChange:k,onSubmit:pe,suggestions:ke,onForgetSuggestion:W=>me(e,W),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:z,onOpenExternal:()=>{so(X.url||x)},canGoBack:X.canGoBack,canGoForward:X.canGoForward,isLoading:ae,onAnnotate:de,isAnnotating:w,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>ne(b+vo),onZoomOut:()=>ne(b-vo),onZoomReset:()=>ne(0),zoomPercent:Math.round(Math.pow(1.2,b)*100),onClearCookies:()=>xe("cookies"),onClearCache:()=>xe("cache"),onToggleDeviceBar:()=>M(W=>!W),isDeviceBarOpen:v}),v?s.jsx(kv,{viewport:R,onViewportChange:I,colorScheme:T,onColorSchemeChange:U,scale:le?.scale??1}):null,s.jsxs("div",{ref:L,className:Re("relative min-h-0 flex-1 bg-background",le&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[p!==null?s.jsx("webview",{ref:d,src:p,partition:"persist:openchamber-browser",allowpopups:!0,style:le?{width:`${le.width}px`,height:`${le.height}px`,transform:`scale(${le.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,p!==null&&!f&&!X.url&&!ae?s.jsx(Vf,{onOpen:pe,directory:e}):null,g?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.waitingForServerHint")})]}):null,se?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.tunnelFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.tunnelFailedHint",{url:se})})]}):null,ue&&!se?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:ue.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:ue.crashed?r("contextPanel.browser.crashedHint"):ue.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,ae?s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:s.jsx("div",{className:"h-full w-1/3 animate-[browser-progress_1.1s_ease-in-out_infinite] bg-[var(--primary)]"})}):null]})]})},eS=t=>{const e=et.c(49),{initialUrl:n,directory:r,tabID:i}=t,{t:o}=kt(),l=Pe(sS);let a;e[0]!==n?(a=Cr(n),e[0]=n,e[1]=a):a=e[1];const d=a,u=d!==tn?d:"",[m,f]=c.useState(u),[p,y]=c.useState(u);let x;e[2]!==u?(x=u?[u]:[],e[2]=u,e[3]=x):x=e[3];const[k,w]=c.useState(x),[h,g]=c.useState(u?0:-1),[j,b]=c.useReducer(nS,0);let S;e[4]!==r||e[5]!==l||e[6]!==i?(S=ge=>{!ge||ge===tn||!r||!i||l(r,i,ge)},e[4]=r,e[5]=l,e[6]=i,e[7]=S):S=e[7];const C=S;let v;e[8]!==r?(v=Ff(r),e[8]=r,e[9]=v):v=e[9];const M=Nr(v),R=Nr(rS),I=Nr(oS);let B;e[10]!==m||e[11]!==M?(B=Bf(M,m),e[10]=m,e[11]=M,e[12]=B):B=e[12];const O=B;let T;e[13]!==r||e[14]!==h||e[15]!==C||e[16]!==R?(T=ge=>{const ae=Cr(ge);ae!==tn&&(f(ae),y(ae),C(ae),R(r,{url:ae}),w(Ee=>{const Se=h>=0?Ee.slice(0,h+1):[];return Se[Se.length-1]===ae?(g(Se.length-1),Se):(g(Se.length),[...Se,ae])}))},e[13]=r,e[14]=h,e[15]=C,e[16]=R,e[17]=T):T=e[17];const $=T;let _;e[18]!==k||e[19]!==C?(_=ge=>{const ae=k[ge];ae&&(g(ge),f(ae),y(ae),C(ae))},e[18]=k,e[19]=C,e[20]=_):_=e[20];const Y=_;let L;e[21]!==r||e[22]!==I?(L=ge=>I(r,ge),e[21]=r,e[22]=I,e[23]=L):L=e[23];let A,D;e[24]!==Y||e[25]!==h?(D=()=>Y(h-1),A=()=>Y(h+1),e[24]=Y,e[25]=h,e[26]=A,e[27]=D):(A=e[26],D=e[27]);let P;e[28]!==m||e[29]!==p?(P=()=>{so(p||m)},e[28]=m,e[29]=p,e[30]=P):P=e[30];const Z=h>0,X=h>=0&&h<k.length-1;let se;e[31]!==m||e[32]!==$||e[33]!==O||e[34]!==A||e[35]!==P||e[36]!==Z||e[37]!==X||e[38]!==L||e[39]!==D?(se=s.jsx(zf,{address:m,onAddressChange:f,onSubmit:$,suggestions:O,onForgetSuggestion:L,onBack:D,onForward:A,onReload:b,onOpenExternal:P,canGoBack:Z,canGoForward:X,isLoading:!1}),e[31]=m,e[32]=$,e[33]=O,e[34]=A,e[35]=P,e[36]=Z,e[37]=X,e[38]=L,e[39]=D,e[40]=se):se=e[40];let ce;e[41]!==p||e[42]!==$||e[43]!==j||e[44]!==o?(ce=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:p?s.jsx("iframe",{src:p,title:o("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${p}|${j}`):s.jsx(Vf,{onOpen:$})}),e[41]=p,e[42]=$,e[43]=j,e[44]=o,e[45]=ce):ce=e[45];let re;return e[46]!==se||e[47]!==ce?(re=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[se,ce]}),e[46]=se,e[47]=ce,e[48]=re):re=e[48],re},tS=t=>{const e=et.c(3),[n]=c.useState(Hv);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(Zv,{...t}):s.jsx(eS,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function sS(t){return t.setContextPanelTabTargetPath}function nS(t){return t+1}function rS(t){return t.recordVisit}function oS(t){return t.forget}const iS=Gn(()=>jn(()=>import("./WalkthroughView-CmFgOUFN.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.WalkthroughView}))),aS=Gn(()=>jn(()=>import("./DiffView-DNExNi1z.js"),__vite__mapDeps([128,1,2,4,5,6,7,8,9,83,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,129,117,118,119,120,121,130,122,123,124,125,126,127])).then(t=>({default:t.DiffView}))),lS=Gn(()=>jn(()=>import("./FilesView-DUCLmHBi.js"),__vite__mapDeps([131,1,2,4,5,6,7,8,9,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,85,86,132,133,134,135,136,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,137,138,120,121,118,139,125,119,140])).then(t=>({default:t.FilesView}))),cS=Gn(()=>jn(()=>import("./GitView-Bz9z6gZA.js"),__vite__mapDeps([141,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,85,86,142,130,117,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,87,115,116,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.GitView}))),dS=Gn(()=>jn(()=>import("./LinearIssuesView-CTGRS9Vq.js"),__vite__mapDeps([143,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(t=>({default:t.LinearIssuesView}))),uS=Gn(()=>jn(()=>import("./PlanView-CPSK0x97.js"),__vite__mapDeps([144,1,2,4,5,6,7,8,9,132,57,58,59,60,61,62,79,55,56,63,133,134,135,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,80,81,82,119,140,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,84,85,86])).then(t=>({default:t.PlanView}))),Uf=c.lazy(()=>jn(()=>import("./PluginPane-BIGsUx69.js").then(t=>t.p),__vite__mapDeps([86,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(t=>({default:t.PluginPane}))),Hf={top:{container:"flex-col",page:"border-b border-border",vertical:!0},bottom:{container:"flex-col-reverse",page:"border-t border-border",vertical:!0},left:{container:"flex-row",page:"border-r border-border",vertical:!1},right:{container:"flex-row-reverse",page:"border-l border-border",vertical:!1}},fS=t=>{const e=et.c(12),{mode:n,docking:r}=t,[i,o]=c.useState(null),l=Hf[r.dock],a=Math.max(ig,i??r.size),d=l.vertical?"max-h-[50%] transition-[height]":"max-w-[50%] transition-[width]";let u;e[0]!==l.page||e[1]!==d?(u=Re("shrink-0 overflow-hidden duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d,l.page),e[0]=l.page,e[1]=d,e[2]=u):u=e[2];let m;e[3]!==l.vertical||e[4]!==a?(m=l.vertical?{height:a}:{width:a},e[3]=l.vertical,e[4]=a,e[5]=m):m=e[5];let f;e[6]!==n?(f=s.jsx(Uf,{mode:n,onResize:o}),e[6]=n,e[7]=f):f=e[7];let p;return e[8]!==u||e[9]!==m||e[10]!==f?(p=s.jsx("div",{className:u,style:m,children:f}),e[8]=u,e[9]=m,e[10]=f,e[11]=p):p=e[11],p},Lc=c.lazy(()=>jn(()=>import("./GuestSurfacePane-B3pdB_2u.js"),__vite__mapDeps([145,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,86])).then(t=>({default:t.GuestSurfacePane}))),Gf=320,fl=600,mS=400,hS=100,pS=24,Yo=new Map,gS=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},$c=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Gf,Math.round(t))):fl,zc=t=>{const e=t??(typeof window<"u"?window.innerWidth:fl*2);return Math.max(Gf,e-mS)},xS=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},bS=(t,e)=>{if(!t)return"";const n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&n.startsWith(r+"/")?n.slice(r.length+1):n},qf=(t,e)=>t==="chat"?e("contextPanel.mode.chat"):t==="file"?e("contextPanel.mode.files"):t==="diff"?e("contextPanel.mode.diff"):t==="walkthrough"?e("contextPanel.mode.walkthrough"):t==="plan"?e("contextPanel.mode.plan"):t==="browser"?e("contextPanel.mode.browser"):t==="git"?e("layout.rightSidebar.git"):t==="pr"?e("contextPanel.mode.pr"):t==="linear"?e("contextPanel.mode.linear"):t==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):or(t)?Ka.getState().guests.find(r=>r.id===Lo(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),yS=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const n=e.split("/").filter(Boolean);return n.length===0?e:n[n.length-1]||null},wS=(t,e,n)=>{if(t.mode==="chat"){const r=Aa(t.dedupeKey);if(r){const o=e.get(r)?.trim();if(o)return o}const i=t.sessionTitleFallback?.trim();return i||n("contextPanel.mode.chat")}return t.mode==="browser"?dl(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?yS(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):qf(t.mode,n)},vS=t=>{const e=et.c(8),{mode:n}=t,r=Ya();let i;if(e[0]!==n||e[1]!==r){let u;e[3]!==n?(u=m=>m.mode===n,e[3]=n,e[4]=u):u=e[4],i=r.find(u),e[0]=n,e[1]=r,e[2]=i}else i=e[2];const o=i,l=o?.icon??ag,a=o?.iconSrc;let d;return e[5]!==l||e[6]!==a?(d=s.jsx(no,{icon:l,iconSrc:a,className:"h-3.5 w-3.5"}),e[5]=l,e[6]=a,e[7]=d):d=e[7],d},Wc=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(qa,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(bf,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(F,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(F,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(F,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="linear")return s.jsx(F,{name:"linear",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(F,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(F,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(F,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(F,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(F,{name:"chat-4",className:"h-3.5 w-3.5"});if(or(t.mode))return s.jsx(vS,{mode:t.mode});if(t.mode==="browser"){const n=SS(t.targetPath??"",e);return n?s.jsx("img",{src:n,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):s.jsx(F,{name:"global",className:"h-3.5 w-3.5"})}},SS=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},jS=({visible:t,active:e,fill:n=!1})=>{const{t:r}=kt(),i=Pe(g=>g.contextEditorTreeWidth),o=Pe(g=>g.setContextEditorTreeWidth),[l,a]=c.useState(!1),d=c.useRef(0),u=c.useRef(i),m=c.useRef(null),f=c.useRef(null),p=c.useRef(null),y=c.useCallback(g=>{const j=p.current;j&&(j.style.width=`${g}px`,j.style.setProperty("--oc-editor-tree-width",`${g}px`))},[]),x=g=>{if(t){try{g.currentTarget.setPointerCapture(g.pointerId)}catch{}f.current=g.pointerId,a(!0),d.current=g.clientX,u.current=i,m.current=i,g.preventDefault()}},k=g=>{if(!l||f.current!==g.pointerId)return;const j=d.current-g.clientX,b=Gi(u.current+j);m.current!==b&&(m.current=b,y(b))},w=g=>{if(f.current!==g.pointerId)return;try{g.currentTarget.releasePointerCapture(g.pointerId)}catch{}const j=Gi(m.current??i);f.current=null,m.current=null,a(!1),o(j)},h=t?i:0;return s.jsxs("div",{ref:p,className:Re("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",n&&"ml-auto"),style:{width:`${l?m.current??h:h}px`,maxWidth:n?"100%":void 0,"--oc-editor-tree-width":`${l?m.current??i:i}px`,overflowX:"clip",transitionProperty:l?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&!n&&s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-20 w-px bg-border"}),t&&!n&&s.jsx("div",{className:Re("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",l&&"bg-[var(--interactive-border)]"),onPointerDown:x,onPointerMove:k,onPointerUp:w,onPointerCancel:w,role:"separator","aria-orientation":"vertical","aria-label":r("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:Re("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",l&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)",maxWidth:n?"100%":void 0},"aria-hidden":!t,children:s.jsx(L1,{visible:t&&e})})]})},Aa=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,kS=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},CS=(t,e)=>{if(e.length===0)return Yo;const n=new Set(e),r=new Map;for(const i of t){if(!n.has(i.id))continue;const o=i.title?.trim();o&&r.set(i.id,o)}return r.size===0?Yo:r},NS=(t,e)=>{const n=og(t),r=c.useRef(Yo),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(n.subscribe,c.useCallback(()=>{const o=CS(n.getState().session,i.current);return kS(r.current,o)?r.current:(r.current=o,o)},[n]),()=>Yo)},AS=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,PS=()=>{const{t}=kt(),e=mr()??"",n=c.useMemo(()=>gS(e),[e]),r=Pe(H=>n?H.contextPanelByDirectory[n]:void 0),i=Pe(H=>H.closeContextPanel),o=Pe(H=>H.closeContextPanelTab),l=Pe(H=>H.openContextPanelTab),a=Pe(H=>H.toggleContextPanelExpanded),d=Pe(H=>H.setContextPanelWidth),u=Pe(H=>H.setActiveContextPanelTab),m=Pe(H=>H.openAgentBrowserTab);c.useEffect(()=>{if(e)return Xw(H=>m(e,H))},[e,m]);const f=Pe(H=>H.openContextFile);c.useEffect(()=>Hn(H=>{if(H.type!=="file-open-request")return;const Be=H.directory??e;Be&&f(Be,H.path)}),[e,f]);const p=Pe(H=>H.reorderContextPanelTabs),y=yn(H=>H.setSelectedPath),x=Pe(H=>H.contextEditorTreeVisible),k=Pe(H=>H.contextEditorTreeWidth),w=Pe(H=>H.setContextEditorTreeWidth),h=Pe(H=>H.toggleContextEditorTree),g=Pe(H=>H.contextEditorVisible),j=Pe(H=>H.toggleContextEditor),b=Pe(H=>H.openNewContextBrowserTab),S=Pf(H=>H.byOrigin),C=Pe(H=>H.allowPromptingSubagentSessions),{themeMode:v,setThemeMode:M,lightThemeId:R,darkThemeId:I,currentTheme:B}=Kn(),O=c.useMemo(()=>r?.tabs??[],[r?.tabs]),T=O.find(H=>H.id===r?.activeTabId)??O[O.length-1]??null,$=T?.mode==="browser"?T.id:null;c.useEffect(()=>{$&&Qw($)},[$]);const _=!!(r?.isOpen&&T),[Y,L]=c.useState(null),A=c.useMemo(()=>O.some(H=>H.mode==="file"&&H.targetPath),[O]),D=A&&(g||!x),P=T?.mode??null,Z=P==="file"&&!D,X=!!(_&&r?.expanded&&!Z),se=P?r?.widthByMode?.[P]:void 0,ce=P?r?.widthFractionByMode?.[P]:void 0,re=P?eg(P):.5,ge=Y??(typeof window<"u"?window.innerWidth:fl*2),ae=ce!=null&&Y!=null?Math.round(ce*Y):se,Ee=Z?k:$c(ae??Math.round(re*ge),zc(Y??ge));c.useEffect(()=>{!n||!P||Z||ce!=null||se==null||Y==null||d(n,P,se,Y)},[P,Y,n,Z,se,ce,d]);const Se=c.useMemo(()=>{const H=[];for(const Be of O){if(Be.mode!=="chat")continue;const Ye=Aa(Be.dedupeKey);Ye&&!H.includes(Ye)&&H.push(Ye)}return H},[O]),me=NS(n||void 0,Se),[ke,V]=c.useState(!1),J=c.useRef(0),de=c.useRef(Ee),we=c.useRef(null),G=c.useRef(null),Ce=c.useRef(null),Te=c.useRef(new Map),pe=c.useRef(new Map),ne=c.useRef(!1);c.useLayoutEffect(()=>{const H=Ce.current?.parentElement;if(!H||typeof ResizeObserver>"u")return;const Be=new ResizeObserver(()=>{L(H.clientWidth||null)});return Be.observe(H),L(H.clientWidth||null),()=>Be.disconnect()},[]),c.useEffect(()=>{if(!_||ne.current){ne.current=_;return}const H=window.requestAnimationFrame(()=>{Ce.current?.focus({preventScroll:!0})});return ne.current=!0,()=>window.cancelAnimationFrame(H)},[_]);const xe=c.useRef(null),U=c.useRef(null),z=c.useCallback(()=>{U.current=null;const H=Ce.current,Be=we.current;!H||Be===null||H.style.setProperty("--oc-context-panel-width",`${Be}px`)},[]);c.useEffect(()=>()=>{U.current!==null&&clearTimeout(U.current)},[]);const Q=c.useCallback(H=>{const Be=xe.current,Ye=Z?Gi(H):$c(H,zc(Be));return Be===null?Ye:Math.min(Ye,Math.max(1,Be))},[Z]),ue=c.useCallback(H=>{!_||X||!n||(G.current=H.pointerId,V(!0),J.current=H.clientX,de.current=Ee,we.current=Ee,xe.current=xS(Ce.current),document.documentElement.style.cursor="col-resize",H.preventDefault())},[n,X,_,Ee]),le=c.useCallback(()=>{const H=Q(we.current??Ee),Be=xe.current;we.current=null,xe.current=null,U.current!==null&&(clearTimeout(U.current),U.current=null),document.documentElement.style.cursor="",Z?w(H):n&&P&&d(n,P,H,Be??void 0),V(!1),G.current=null},[P,Q,n,Z,w,d,Ee]);c.useEffect(()=>{if(!ke)return;const H=qe=>{if(G.current!==qe.pointerId)return;const Xe=J.current-qe.clientX,jt=Q(de.current+Xe);we.current!==jt&&(we.current=jt,U.current===null&&(U.current=setTimeout(z,hS)))},Be=qe=>{G.current===qe.pointerId&&le()},Ye=()=>{le()};return window.addEventListener("pointermove",H),window.addEventListener("pointerup",Be),window.addEventListener("pointercancel",Be),window.addEventListener("blur",Ye),()=>{window.removeEventListener("pointermove",H),window.removeEventListener("pointerup",Be),window.removeEventListener("pointercancel",Be),window.removeEventListener("blur",Ye)}},[z,Q,le,ke]),c.useEffect(()=>{ke||(we.current=null,document.documentElement.style.cursor="")},[ke]);const W=c.useCallback(()=>{n&&i(n)},[i,n]),E=c.useCallback(()=>{n&&a(n)},[n,a]),K=c.useCallback(H=>{H.key==="Escape"&&(H.target instanceof Node&&!H.currentTarget.contains(H.target)||tg(H.target)||sg(H.target)||(H.preventDefault(),H.stopPropagation(),W()))},[W]);c.useEffect(()=>{if(!(!n||!T)&&T.mode==="file"&&T.targetPath){y(n,T.targetPath,{allowOutsideRoot:!0});return}},[T,n,y]);const te=c.useMemo(()=>O.filter(H=>H.mode==="chat"),[O]),oe=_&&T?.mode==="chat"?T.id:null,he=_&&T?.mode==="chat"?Aa(T.dedupeKey):null,ie=xb(te,oe);c.useEffect(()=>{if(!_||!n||!he||typeof window>"u")return;const H=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){Ii(n,he,!1);return}Ru(he),Ii(n,he,!0)};H();const Be=window.setInterval(H,1e4);return window.addEventListener("focus",H),window.addEventListener("blur",H),document.addEventListener("visibilitychange",H),()=>{window.clearInterval(Be),window.removeEventListener("focus",H),window.removeEventListener("blur",H),document.removeEventListener("visibilitychange",H),Ii(n,he,!1)}},[he,n,_]);const Fe=c.useCallback((H,Be,Ye)=>bb(pe.current,H,Be,n||null,Ye,{mode:v,lightThemeId:R,darkThemeId:I,currentTheme:B},{allowPromptingSubagentSessions:C}),[C,B,I,n,R,v]),_e=ie&&he?Fe(ie.id,he,ie.readOnly):null;c.useEffect(()=>{const H=new Set(O.map(Be=>Be.id));for(const Be of pe.current.keys())H.has(Be)||pe.current.delete(Be)},[O]);const Ae=c.useCallback(H=>{!n||T?.mode!=="diff"||l(n,{mode:"diff",targetPath:T.targetPath,stagedDiff:H==="staged",diffScope:H})},[T,n,l]),Me=c.useCallback(()=>{if(typeof window>"u")return;const H={themeMode:v,lightThemeId:R,darkThemeId:I,currentTheme:B};for(const Be of Te.current.values()){const Ye=Be.contentWindow;Ye&&Ye.postMessage({type:"openchamber:theme-sync",payload:H},window.location.origin)}},[B,I,R,v]),q=c.useCallback(()=>{if(typeof window>"u")return;const H={allowPromptingSubagentSessions:C};for(const Be of Te.current.values()){const Ye=Be.contentWindow;Ye&&Ye.postMessage({type:"openchamber:chat-settings-sync",payload:H},window.location.origin)}},[C]),Ne=c.useCallback((H,Be,Ye)=>{const qe=Be.contentWindow;qe&&qe.postMessage({type:cf,payload:{visible:oe===H}},Ye)},[oe]),je=c.useCallback(()=>{if(!(typeof window>"u"))for(const[H,Be]of Te.current.entries())Ne(H,Be,window.location.origin)},[Ne]);c.useEffect(()=>{if(typeof window>"u")return;const H=Be=>{if(Be.origin!==window.location.origin)return;const Ye=Array.from(Te.current.entries()).find(([,pt])=>pt.contentWindow===Be.source);if(!Ye)return;const qe=Be.data;if(qe?.type===yb){const[pt,Rt]=Ye;Ne(pt,Rt,Be.origin);return}if(qe?.type===wb){if(typeof qe.requestId!="string"||!qe.requestId)return;const pt=Qt(),Rt={apiBaseUrl:En(),clientToken:Xr(),localOrigin:typeof window.__OPENCHAMBER_LOCAL_ORIGIN__=="string"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"",runtimeHeaders:Hd(),relayHostId:pt.startsWith("host:")?pt.slice(5):"",relay:lh()??void 0};Be.source?.postMessage({type:vb,requestId:qe.requestId,payload:Rt},Be.origin);return}if(qe?.type==="openchamber:theme-sync-request"){Me();return}if(qe?.type==="openchamber:chat-settings-request"){q();return}if(qe?.type!=="openchamber:cycle-theme-request")return;const Xe=["light","dark","system"],Ve=(Xe.indexOf(v)+1)%Xe.length;M(Xe[Ve])};return window.addEventListener("message",H),()=>window.removeEventListener("message",H)},[q,Ne,Me,M,v]),c.useLayoutEffect(()=>{O.some(Be=>Be.mode==="chat")&&(Me(),q(),je())},[I,R,q,je,Me,O,v]);const We=T?.mode==="file"||T?.mode==="chat"||T?.mode==="browser",tt=c.useMemo(()=>T?O.filter(H=>H.mode===T.mode):[],[T,O]),it=c.useMemo(()=>tt.map(H=>{const Be=wS(H,me,t),Ye=AS(Be,pS),qe=bS(H.targetPath,e);return{id:H.id,label:Ye,icon:Wc(H,S),title:qe?`${Be}: ${qe}`:Be,closeLabel:t("contextPanel.tab.closeTabAria",{label:Ye})}}),[tt,e,S,me,t]),rt=T?.mode==="context"?s.jsx(rw,{}):T?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(cS,{isActive:_})}):T?.mode==="pr"?s.jsx(f1,{}):T?.mode==="linear"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(dS,{})}):T?.mode==="notes"?s.jsx(Oh,{}):T?.mode==="plan"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(uS,{targetPath:T.targetPath,savedProjectPlan:T.projectPlanId&&T.projectPlanRef?{projectRef:T.projectPlanRef,planId:T.projectPlanId}:null})}):null,ot=c.useMemo(()=>O.filter(H=>H.mode==="browser"),[O]),ft=c.useMemo(()=>O.filter(H=>H.mode==="diff"),[O]),st=c.useMemo(()=>O.find(H=>H.mode==="terminal")??null,[O]),Ct=c.useMemo(()=>O.some(H=>H.mode==="walkthrough"),[O]),ht=c.useMemo(()=>O.filter(H=>or(H.mode)),[O]),be=Ka(H=>H.guests),Je=c.useMemo(()=>new Set(be.filter(ng).map(H=>H.id)),[be]),dt=c.useMemo(()=>{const H=new Map;for(const Be of be){const Ye=rg(Be);Ye&&H.set(Be.id,Ye)}return H},[be]),Ke=c.useMemo(()=>O.some(H=>H.mode==="file"),[O]),mt=T?.mode==="file",ee=Pe(H=>H.closeContextPanelTabs),fe=c.useCallback(H=>{if(!n)return null;const{id:Be,index:Ye,allIds:qe,close:Xe}=H,jt=()=>ee(n,qe.filter(Ue=>Ue!==Be)),Ve=()=>ee(n,qe.slice(0,Ye)),pt=()=>ee(n,qe.slice(Ye+1)),Rt=()=>ee(n,qe),De=qe.length>1,yt=Ye===0,Pt=Ye===qe.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(tr,{onClick:Xe,children:[s.jsx(F,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),s.jsx(Xi,{}),s.jsxs(tr,{onClick:jt,disabled:!De,children:[s.jsx(F,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),s.jsxs(tr,{onClick:Ve,disabled:yt,children:[s.jsx(F,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(tr,{onClick:pt,disabled:Pt,children:[s.jsx(F,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),s.jsx(Xi,{}),s.jsxs(tr,{onClick:Rt,disabled:!De,children:[s.jsx(F,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[ee,n,t]),Ie=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[We?s.jsx(Jd,{items:it,activeId:T?.id??null,onSelect:H=>{n&&u(n,H)},onClose:H=>{n&&o(n,H)},onReorder:(H,Be)=>{n&&p(n,H,Be)},layoutMode:"scrollable",variant:"default",tabContextMenu:fe}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[T?Wc(T,S):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:T?qf(T.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[T?.mode==="browser"?s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:()=>{n&&b(n)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:s.jsx(F,{name:"add",className:"h-3.5 w-3.5"})}):null,mt&&A?s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:j,className:"h-7 w-7 p-0",title:t("contextRail.editor.toggle"),"aria-label":t("contextRail.editor.toggle"),"aria-pressed":D,children:s.jsx(F,{name:"layout-left",className:"h-3.5 w-3.5"})}):null,mt?s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:h,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":x,children:s.jsx(F,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,Z?null:s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:E,className:"h-7 w-7 p-0",title:t(X?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(X?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:X?s.jsx(F,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(F,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:W,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(F,{name:"close",className:"h-3.5 w-3.5"})})]})]}),$e=_?X?{"--oc-context-panel-width":Y!==null?`${Y}px`:"100%",width:Y!==null?`${Y}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${Ee}px`}:{"--oc-context-panel-width":`${Ee}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:Ce,"data-context-panel":"true",tabIndex:-1,inert:!_||void 0,className:Re("flex min-h-0 flex-col overflow-hidden bg-background",X?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!_&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:K,style:$e,children:[_&&!X&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),_&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!X&&s.jsx("div",{className:Re("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",ke&&"bg-[var(--interactive-border)]"),onPointerDown:ue,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:Re("relative z-10 flex h-full min-h-0 shrink-0 flex-col duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none","transition-[width,opacity]",!_&&"pointer-events-none select-none opacity-0"),style:{width:X?Y!==null?`${Y}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!_,children:[Ie,s.jsxs("div",{className:Re("relative min-h-0 flex-1 overflow-hidden",ke&&"pointer-events-none"),children:[Ke?s.jsxs("div",{className:Re("absolute inset-0 flex",mt?"flex":"hidden"),children:[A||!x?s.jsx("div",{className:Re("h-full min-w-0 flex-1",A&&!D&&"hidden"),children:A?s.jsx(c.Suspense,{fallback:null,children:s.jsx(lS,{mode:"editor-only",visible:_&&mt&&D})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(F,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),s.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}):null,s.jsx(jS,{visible:x,active:_&&mt,fill:!D})]}):null,ie&&he&&_e?s.jsx("iframe",{ref:H=>{if(!H){Te.current.delete(ie.id);return}Te.current.set(ie.id,H)},src:_e,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:he}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{Me(),q(),je()}},ie.id):null,ot.map(H=>s.jsx("div",{className:Re("absolute inset-0",T?.id!==H.id&&"invisible pointer-events-none"),"aria-hidden":T?.id!==H.id||void 0,children:s.jsx(tS,{initialUrl:H.targetPath??"",directory:n,tabID:H.id})},H.id)),ft.map(H=>s.jsx("div",{className:Re("absolute inset-0",T?.id!==H.id&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(aS,{visible:_&&T?.id===H.id,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:H.diffScope??(H.stagedDiff?"staged":"working"),onDiffScopeChange:Ae,targetFilePath:H.targetPath,flushContent:!0})})},H.id)),st?s.jsx("div",{className:Re("absolute inset-0",T?.mode==="terminal"?"block":"hidden"),children:s.jsx(Bh,{visible:_&&T?.mode==="terminal",directory:st.targetDirectory})}):null,Ct?s.jsx("div",{className:Re("absolute inset-0",T?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(iS,{directory:e,visible:_&&T?.mode==="walkthrough"})})}):null,ht.map(H=>{if(!or(H.mode))return null;const Be=Lo(H.mode),Ye=Je.has(Be),qe=dt.get(Be),Xe=T?.id===H.id,jt=Xe&&_;return Ye&&!qe&&!jt?null:s.jsx("div",{className:Re("absolute inset-0",Xe?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:Ye?qe?s.jsxs("div",{className:Re("flex h-full",Hf[qe.dock].container),children:[s.jsx(fS,{mode:H.mode,docking:qe}),s.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:jt?s.jsx(Lc,{mode:H.mode}):null})]}):s.jsx(Lc,{mode:H.mode}):s.jsx(Uf,{mode:H.mode})})},H.id)}),T?.mode!=="chat"&&!mt&&T?.mode!=="browser"&&T?.mode!=="diff"&&T?.mode!=="terminal"&&T?.mode!=="walkthrough"&&!(T&&or(T.mode))?rt:null]})]})]})},DS=t=>{const e=et.c(43),{open:n,onOpenChange:r}=t,{t:i}=kt(),o=Pe(IS),l=Pe(TS),a=Pe(ES),d=Pe(RS),u=Ya();let m;e[0]!==o||e[1]!==u?(m=Mu(o,u),e[0]=o,e[1]=u,e[2]=m):m=e[2];const f=m,p=l.length===0;let y;if(e[3]!==l||e[4]!==f){let R;e[6]!==l?(R=I=>l.includes(I.id),e[6]=l,e[7]=R):R=e[7],y=f.every(R),e[3]=l,e[4]=f,e[5]=y}else y=e[5];const x=y;let k;e[8]!==i?(k=i("contextRail.configure.dialogTitle"),e[8]=i,e[9]=k):k=e[9];let w;e[10]!==k?(w=s.jsx(Hs,{children:k}),e[10]=k,e[11]=w):w=e[11];let h;e[12]!==i?(h=i("contextRail.configure.dialogDescription"),e[12]=i,e[13]=h):h=e[13];let g;e[14]!==h?(g=s.jsx(Gs,{children:h}),e[14]=h,e[15]=g):g=e[15];let j;e[16]!==w||e[17]!==g?(j=s.jsxs(sn,{children:[w,g]}),e[16]=w,e[17]=g,e[18]=j):j=e[18];let b;if(e[19]!==l||e[20]!==a||e[21]!==f||e[22]!==i){let R;e[24]!==l||e[25]!==a||e[26]!==i?(R=I=>s.jsx(lg,{settingsItem:`layout.context-rail.surface.${I.id}`,checked:!l.includes(I.id),onChange:B=>a(I.id,B),label:I.label??i(I.labelKey),ariaLabel:I.label??i(I.labelKey)},I.id),e[24]=l,e[25]=a,e[26]=i,e[27]=R):R=e[27],b=f.map(R),e[19]=l,e[20]=a,e[21]=f,e[22]=i,e[23]=b}else b=e[23];let S;e[28]!==b?(S=s.jsx("div",{className:"flex flex-col",children:b}),e[28]=b,e[29]=S):S=e[29];let C;e[30]!==p||e[31]!==x||e[32]!==d||e[33]!==i?(C=p?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[x?s.jsx("span",{className:"text-xs text-destructive",children:i("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(ut,{variant:"link",size:"xs",onClick:()=>d([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[30]=p,e[31]=x,e[32]=d,e[33]=i,e[34]=C):C=e[34];let v;e[35]!==C||e[36]!==j||e[37]!==S?(v=s.jsxs(Is,{className:"max-w-md",children:[j,S,C]}),e[35]=C,e[36]=j,e[37]=S,e[38]=v):v=e[38];let M;return e[39]!==r||e[40]!==n||e[41]!==v?(M=s.jsx(Ds,{open:n,onOpenChange:r,children:v}),e[39]=r,e[40]=n,e[41]=v,e[42]=M):M=e[42],M};function IS(t){return t.contextRailOrder}function TS(t){return t.contextRailHiddenSurfaces}function ES(t){return t.setContextRailSurfaceVisible}function RS(t){return t.setContextRailHiddenSurfaces}const Yf=150,MS=500,OS=[],BS=t=>t>99?"99+":String(t),FS=t=>{const e=et.c(52),{surface:n,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:d,badgeDescription:u,orderNumber:m,showOrderNumber:f,onSelect:p}=t;let y;e[0]!==n.id?(y={id:n.id},e[0]=n.id,e[1]=y):y=e[1];const{attributes:x,listeners:k,setNodeRef:w,transform:h,transition:g,isDragging:j}=pi(y);let b;e[2]!==a?(b=a!=null&&a>0?BS(a):null,e[2]=a,e[3]=b):b=e[3];const S=b;let C;e[4]!==h?(C=gi.Translate.toString(h),e[4]=h,e[5]=C):C=e[5];let v;e[6]!==C||e[7]!==g?(v={transform:C,transition:g},e[6]=C,e[7]=g,e[8]=v):v=e[8];const M=j&&"z-10 opacity-70";let R;e[9]!==M?(R=Re("relative",M),e[9]=M,e[10]=R):R=e[10];let I;e[11]!==p||e[12]!==n?(I=()=>p(n),e[11]=p,e[12]=n,e[13]=I):I=e[13];const B=d??o,O=r?"text-primary":"text-muted-foreground hover:text-foreground";let T;e[14]!==O?(T=Re("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",O),e[14]=O,e[15]=T):T=e[15];let $;e[16]!==n.icon||e[17]!==n.iconSrc||e[18]!==n.id?($=n.id==="diff"?s.jsx(bf,{className:"h-[18px] w-[18px]"}):s.jsx(no,{icon:n.icon,iconSrc:n.iconSrc,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.iconSrc,e[18]=n.id,e[19]=$):$=e[19];let _;e[20]!==S||e[21]!==m||e[22]!==i||e[23]!==f?(_=f&&m!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:m===10?"0":m}):S?s.jsx("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.625rem] font-semibold leading-none",style:{backgroundColor:"var(--status-info-background)",color:"var(--status-info)"},children:S}):i?s.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[20]=S,e[21]=m,e[22]=i,e[23]=f,e[24]=_):_=e[24];let Y;e[25]!==x||e[26]!==r||e[27]!==k||e[28]!==T||e[29]!==$||e[30]!==_||e[31]!==I||e[32]!==B?(Y=s.jsx(vt,{asChild:!0,children:s.jsxs("button",{type:"button",...x,...k,onClick:I,"aria-label":B,"aria-pressed":r,className:T,children:[$,_]})}),e[25]=x,e[26]=r,e[27]=k,e[28]=T,e[29]=$,e[30]=_,e[31]=I,e[32]=B,e[33]=Y):Y=e[33];let L;e[34]!==o?(L=s.jsx("span",{children:o}),e[34]=o,e[35]=L):L=e[35];let A;e[36]!==l?(A=s.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[36]=l,e[37]=A):A=e[37];let D;e[38]!==u?(D=u?s.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[38]=u,e[39]=D):D=e[39];let P;e[40]!==L||e[41]!==A||e[42]!==D?(P=s.jsx(St,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[L,A,D]})}),e[40]=L,e[41]=A,e[42]=D,e[43]=P):P=e[43];let Z;e[44]!==Y||e[45]!==P?(Z=s.jsxs(wt,{delayDuration:Yf,children:[Y,P]}),e[44]=Y,e[45]=P,e[46]=Z):Z=e[46];let X;return e[47]!==w||e[48]!==Z||e[49]!==v||e[50]!==R?(X=s.jsx("div",{ref:w,style:v,className:R,children:Z}),e[47]=w,e[48]=Z,e[49]=v,e[50]=R,e[51]=X):X=e[51],X},_S=()=>{const t=et.c(92),{t:e}=kt(),n=mr();let r;t[0]!==n?(r=n?er(n):"",t[0]=n,t[1]=r):r=t[1];const i=r;let o;t[2]!==i?(o=le=>i?le.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const l=Pe(o),a=Pe(LS),d=Pe($S),u=Pe(zS),m=Pe(WS),f=Pe(KS),p=Pe(VS),y=Pe(US),x=Va(HS),k=na(GS),w=na(qS),h=Rn(YS),g=Rn(QS),{screenWidth:j}=Vn(),b=Ua(i||null);let S;t[4]!==y?(S=ra("switch_context_surface",y),t[4]=y,t[5]=S):S=t[5];const C=S,[v,M]=c.useState(!1);let R,I;t[6]!==C?(R=()=>{const le=new Set;let W=null,E=!1;const K=XS,te=()=>{Ll(C,le)?!E&&W===null&&(W=setTimeout(()=>M(!0),MS)):(E=!1,W!==null&&(clearTimeout(W),W=null),M(!1))},oe=Fe=>{if(le.add(Fe.key.toLowerCase()),K(Fe.key)&&Ll(C,le)){E=!0,W!==null&&(clearTimeout(W),W=null),M(!1);return}te()},he=Fe=>{le.delete(Fe.key.toLowerCase()),te()},ie=()=>{le.clear(),E=!1,W!==null&&(clearTimeout(W),W=null),M(!1)};return window.addEventListener("keydown",oe,!0),window.addEventListener("keyup",he,!0),window.addEventListener("blur",ie),()=>{window.removeEventListener("keydown",oe,!0),window.removeEventListener("keyup",he,!0),window.removeEventListener("blur",ie),W!==null&&clearTimeout(W)}},I=[C],t[6]=C,t[7]=R,t[8]=I):(R=t[7],I=t[8]),c.useEffect(R,I);let B;t[9]===Symbol.for("react.memo_cache_sentinel")?(B={activationConstraint:{distance:8}},t[9]=B):B=t[9];let O;t[10]===Symbol.for("react.memo_cache_sentinel")?(O={activationConstraint:{delay:200,tolerance:6}},t[10]=O):O=t[10];const T=di(Tn(fi,B),Tn(ui,O)),$=Ya(),_=_l(JS),Y=_l(ZS),L=l?.tabs??OS;let A;t[11]!==l?.activeTabId||t[12]!==L?(A=L.find(le=>le.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=L,t[13]=A):A=t[13];const D=A,P=l?.isOpen?D?.mode??null:null,Z=b?.files.length??0;let X;t[14]!==u||t[15]!==d||t[16]!==g||t[17]!==$||t[18]!==w||t[19]!==x||t[20]!==j||t[21]!==L?(X=cg({railOrder:d,hiddenSurfaces:u,planModeEnabled:x,isVSCode:Wn(),screenWidth:j,tabs:L,linearConnected:w,githubConnected:g,extras:$}),t[14]=u,t[15]=d,t[16]=g,t[17]=$,t[18]=w,t[19]=x,t[20]=j,t[21]=L,t[22]=X):X=t[22];const se=X;let ce,re;t[23]!==P||t[24]!==p||t[25]!==i||t[26]!==k||t[27]!==w?(re=()=>{!i||!k||w||P!=="linear"||p(i)},ce=[P,p,i,k,w],t[23]=P,t[24]=p,t[25]=i,t[26]=k,t[27]=w,t[28]=ce,t[29]=re):(ce=t[28],re=t[29]),c.useEffect(re,ce);let ge,ae;t[30]!==P||t[31]!==p||t[32]!==i||t[33]!==h||t[34]!==g?(ge=()=>{!i||!h||g||P!=="pr"||p(i)},ae=[P,p,i,h,g],t[30]=P,t[31]=p,t[32]=i,t[33]=h,t[34]=g,t[35]=ge,t[36]=ae):(ge=t[35],ae=t[36]),c.useEffect(ge,ae);const[Ee,Se]=c.useState(!1);let me;t[37]!==$||t[38]!==m?(me=le=>{const{active:W,over:E}=le;if(!E||W.id===E.id)return;const K=Mu(Pe.getState().contextRailOrder,$).map(e0),te=K.indexOf(W.id),oe=K.indexOf(E.id);te===-1||oe===-1||m(sf(K,te,oe))},t[37]=$,t[38]=m,t[39]=me):me=t[39];const ke=me;if(!i)return null;let V;t[40]!==e?(V=e("contextRail.aria.rail"),t[40]=e,t[41]=V):V=t[41];let J;t[42]!==se?(J=se.map(t0),t[42]=se,t[43]=J):J=t[43];let de;if(t[44]!==P||t[45]!==Z||t[46]!==Y||t[47]!==i||t[48]!==_||t[49]!==f||t[50]!==v||t[51]!==se||t[52]!==e||t[53]!==a){let le;t[55]!==P||t[56]!==Z||t[57]!==Y||t[58]!==i||t[59]!==_||t[60]!==f||t[61]!==v||t[62]!==e||t[63]!==a?(le=(W,E)=>{const K=W.label??e(W.labelKey),te=W.id==="git"&&!a?Z:0,oe=or(W.mode)&&P!==W.mode?_[Lo(W.mode)]??0:0,he=te>0?te:oe>0?oe:null,ie=he!==null&&te===0;return s.jsx(FS,{surface:W,isActive:P===W.mode,showActivityDot:!1,label:K,description:e(W.descriptionKey),badgeCount:he,badgeAriaLabel:he!==null?e(ie?he===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":he===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:K,count:he}):null,badgeDescription:he!==null?e(ie?he===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":he===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:he}):null,orderNumber:E+1,showOrderNumber:v,onSelect:Fe=>{or(Fe.mode)&&Y(Lo(Fe.mode)),f(i,Fe.mode)}},W.id)},t[55]=P,t[56]=Z,t[57]=Y,t[58]=i,t[59]=_,t[60]=f,t[61]=v,t[62]=e,t[63]=a,t[64]=le):le=t[64],de=se.map(le),t[44]=P,t[45]=Z,t[46]=Y,t[47]=i,t[48]=_,t[49]=f,t[50]=v,t[51]=se,t[52]=e,t[53]=a,t[54]=de}else de=t[54];let we;t[65]!==J||t[66]!==de?(we=s.jsx(nl,{items:J,strategy:nf,children:de}),t[65]=J,t[66]=de,t[67]=we):we=t[67];let G;t[68]!==ke||t[69]!==T||t[70]!==we?(G=s.jsx(mi,{sensors:T,collisionDetection:hi,onDragEnd:ke,children:we}),t[68]=ke,t[69]=T,t[70]=we,t[71]=G):G=t[71];let Ce;t[72]!==e?(Ce=e("contextRail.configure.open"),t[72]=e,t[73]=Ce):Ce=t[73];let Te;t[74]===Symbol.for("react.memo_cache_sentinel")?(Te=()=>Se(!0),t[74]=Te):Te=t[74];let pe;t[75]===Symbol.for("react.memo_cache_sentinel")?(pe=s.jsx(F,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[75]=pe):pe=t[75];let ne;t[76]!==Ce?(ne=s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":Ce,onClick:Te,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:pe})}),t[76]=Ce,t[77]=ne):ne=t[77];let xe;t[78]!==e?(xe=e("contextRail.configure.open"),t[78]=e,t[79]=xe):xe=t[79];let U;t[80]!==xe?(U=s.jsx(St,{side:"left",sideOffset:8,children:xe}),t[80]=xe,t[81]=U):U=t[81];let z;t[82]!==ne||t[83]!==U?(z=s.jsxs(wt,{delayDuration:Yf,children:[ne,U]}),t[82]=ne,t[83]=U,t[84]=z):z=t[84];let Q;t[85]!==Ee?(Q=s.jsx(DS,{open:Ee,onOpenChange:Se}),t[85]=Ee,t[86]=Q):Q=t[86];let ue;return t[87]!==V||t[88]!==G||t[89]!==z||t[90]!==Q?(ue=s.jsxs("nav",{"aria-label":V,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[G,z,Q]}),t[87]=V,t[88]=G,t[89]=z,t[90]=Q,t[91]=ue):ue=t[91],ue};function LS(t){return t.workStatusPanelVisible}function $S(t){return t.contextRailOrder}function zS(t){return t.contextRailHiddenSurfaces}function WS(t){return t.setContextRailOrder}function KS(t){return t.openContextSurface}function VS(t){return t.closeContextPanel}function US(t){return t.shortcutOverrides}function HS(t){return t.planModeEnabled}function GS(t){return t.hasChecked}function qS(t){return t.status?.connected===!0}function YS(t){return t.hasChecked}function QS(t){return t.status?.connected===!0}function XS(t){return t.length===1&&t>="0"&&t<="9"}function JS(t){return t.countByGuest}function ZS(t){return t.clearBadge}function e0(t){return t.id}function t0(t){return t.id}const s0=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),n0=(t,e,n,r)=>!n||r!==n||t.length===0?[]:zr(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),r0=new Set,o0=[],Pa=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+/g,"/");n&&!r.startsWith("//")&&(r=`/${r}`);const i=r==="/",o=/^[A-Za-z]:\/$/.test(r);return!i&&!o&&(r=r.replace(/\/+$/,"")),r},i0=()=>{const t=et.c(183),{t:e}=kt(),n=Pe(a0),r=Pe(l0),i=Pe(c0),o=Pe(d0),l=Pe(u0),a=Pe(f0),d=Pe(m0),u=Pe(h0),m=Pe(p0),f=Pe(g0),p=Pe(x0),y=Pe(b0),x=Pe(y0),k=nt(w0),w=nt(v0),h=nt(S0),g=Jr(j0);let j;t[0]!==n?(j=Ue=>n?Ue.activeSessions:o0,t[0]=n,t[1]=j):j=t[1];const b=js(j);let S;t[2]!==n?(S=Ue=>n?Ue.ids:r0,t[2]=n,t[3]=S):S=t[3];const C=Jr(S);let v;t[4]!==n?(v=Ue=>n?Ue.rankById:Xa,t[4]=n,t[5]=v):v=t[5];const M=Qa(v),R=os(k0),I=Gt(C0),B=Gt(N0),O=mr(),T=Vd(A0),{files:$,git:_}=kn(),Y=Mn(P0),{isMobile:L}=Vn();let A;t[6]!==O?(A=O?Pa(O):null,t[6]=O,t[7]=A):A=t[7];const D=A,[P,Z]=c.useState(""),se=Iu(P,200).trim();let ce;t[8]!==P?(ce=P.trim(),t[8]=P,t[9]=ce):ce=t[9];const re=ce;let ge,ae;t[10]!==n?(ge=()=>{n&&Z("")},ae=[n],t[10]=n,t[11]=ge,t[12]=ae):(ge=t[11],ae=t[12]),c.useEffect(ge,ae);let Ee,Se;t[13]!==b||t[14]!==Y||t[15]!==_||t[16]!==n?(Ee=()=>{if(!n||!_)return;const Ue=setTimeout(()=>{const He=new Set;for(const ve of b){const Qe=Ps(ve);!Qe||He.has(Qe)||(He.add(Qe),Y(Qe,_))}},0);return()=>clearTimeout(Ue)},Se=[n,b,_,Y],t[13]=b,t[14]=Y,t[15]=_,t[16]=n,t[17]=Ee,t[18]=Se):(Ee=t[17],Se=t[18]),c.useEffect(Ee,Se);let me;t[19]!==r?(me=()=>r(!1),t[19]=r,t[20]=me):me=t[20];const ke=me;let V;t[21]!==ke?(V=Ue=>()=>{ke(),Ue()},t[21]=ke,t[22]=V):V=t[22];const J=V;let de;t[23]!==I?.id||t[24]!==I?.path||t[25]!==R||t[26]!==h||t[27]!==L||t[28]!==d||t[29]!==u||t[30]!==p||t[31]!==k||t[32]!==J||t[33]!==y||t[34]!==x||t[35]!==l||t[36]!==i||t[37]!==e||t[38]!==g||t[39]!==a?(de=()=>{const Ue=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(F,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:J(()=>{l(!1),k()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(F,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:J(D0)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(F,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:J(I0)},{id:"toggle-sidebar",title:e(L?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(F,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e(L?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:J(()=>{if(L){const{isSessionSwitcherOpen:He}=Pe.getState();l(!He)}else a()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(F,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:J(()=>{R&&u(R,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(F,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:J(()=>{R&&d(R)})},{id:"cycle-theme",secondary:!0,title:e("commandPalette.item.cycleTheme"),icon:s.jsx(F,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:e("commandPalette.item.cycleTheme"),onSelect:J(T0)},{id:"open-status",secondary:!0,title:e("commandPalette.item.showOpenCodeStatus"),icon:s.jsx(F,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showOpenCodeStatus"),onSelect:J(E0)},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(F,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:J(()=>i(!0))}];return Ue.push({id:"pin-session",secondary:!0,title:e("commandPalette.item.pinSession"),icon:s.jsx(F,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.pinSession"),onSelect:J(()=>{h&&R&&g({directory:R,sessionId:h})})},{id:"copy-session-id",secondary:!0,title:e("commandPalette.item.copySessionId"),icon:s.jsx(F,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.copySessionId"),onSelect:J(()=>{h&&fr(h).then(He=>{if(He.ok){ze.success(e("sessions.sidebar.session.copyId.success"));return}ze.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>ze.error(e("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:e("commandPalette.item.openMultiRun"),icon:s.jsx(F,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openMultiRun"),onSelect:J(()=>{l(!1),p()})},{id:"open-archive",secondary:!0,title:e("commandPalette.item.openArchive"),icon:s.jsx(F,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openArchive"),onSelect:J(()=>{l(!1),y(!0)})},{id:"open-notes",secondary:!0,title:e("commandPalette.item.openNotes"),icon:s.jsx(F,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openNotes"),onSelect:J(()=>{R&&(x("notes"),u(R,"notes"))})},{id:"open-todos",secondary:!0,title:e("commandPalette.item.openTodos"),icon:s.jsx(F,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openTodos"),onSelect:J(()=>{R&&(x("todos"),u(R,"notes"))})}),Wn()||Ue.push({id:"restart-opencode",secondary:!0,title:e("commandPalette.item.restartOpenCode"),icon:s.jsx(F,{name:"restart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.restartOpenCode"),onSelect:J(()=>{_h(e)})}),Ue.push({id:"toggle-memory-debug",secondary:!0,title:e("commandPalette.item.toggleMemoryDebug"),icon:s.jsx(F,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.toggleMemoryDebug"),onSelect:J(R0)}),Qr()&&Ue.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(F,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:J(()=>{zn("desktop_open_draft_mini_chat_window",{directory:Pa(R||I?.path||""),projectId:I?.id??null}).catch(M0)})}),Ue},t[23]=I?.id,t[24]=I?.path,t[25]=R,t[26]=h,t[27]=L,t[28]=d,t[29]=u,t[30]=p,t[31]=k,t[32]=J,t[33]=y,t[34]=x,t[35]=l,t[36]=i,t[37]=e,t[38]=g,t[39]=a,t[40]=de):de=t[40],I?.id,I?.path;let we;t[41]!==de?(we=de(),t[41]=de,t[42]=we):we=t[42];const G=we,Ce=Pe(O0);let Te;t[43]===Symbol.for("react.memo_cache_sentinel")?(Te=vn(),t[43]=Te):Te=t[43];const pe=Te;let ne,xe;t[44]===Symbol.for("react.memo_cache_sentinel")?(ne=Wn(),xe=!pe&&La(),t[44]=ne,t[45]=xe):(ne=t[44],xe=t[45]);let U;t[46]!==L||t[47]!==Ce?(U={isVSCode:ne,isWeb:xe,isDesktop:pe,isMobile:L,routingAvailable:Ce},t[46]=L,t[47]=Ce,t[48]=U):U=t[48];const z=U;let Q;if(t[49]!==J||t[50]!==i||t[51]!==o||t[52]!==z){let Ue;t[54]!==z?(Ue=ve=>ve.isAvailable?ve.isAvailable(z):!0,t[54]=z,t[55]=Ue):Ue=t[55];let He;t[56]!==J||t[57]!==i||t[58]!==o?(He=ve=>{const Qe=Lh(ve.slug)??"settings-3",Ge=(ve.keywords??[]).join(" ");return{id:`settings:${ve.slug}`,title:ve.title,icon:ve.slug==="mcp"?s.jsx(hg,{className:"mr-2 h-4 w-4"}):s.jsx(F,{name:Qe,className:"mr-2 h-4 w-4"}),searchText:`${ve.title} ${ve.group} ${Ge}`,onSelect:J(()=>{o(ve.slug),i(!0)})}},t[56]=J,t[57]=i,t[58]=o,t[59]=He):He=t[59],Q=Fh.filter(B0).filter(Ue).map(He),t[49]=J,t[50]=i,t[51]=o,t[52]=z,t[53]=Q}else Q=t[53];const ue=Q;let le;if(t[60]!==b||t[61]!==C||t[62]!==M){const Ue=b.filter(F0);le=dg(Ue,C,M),t[60]=b,t[61]=C,t[62]=M,t[63]=le}else le=t[63];const W=le,E=Ou(),K=nt(_0);let te;t[64]!==E||t[65]!==K?(te=(Ue,He)=>{const ve=K.get(Ue);return ve?.branch?ve.branch.trim()||null:He&&E.get(He)?.trim()||null},t[64]=E,t[65]=K,t[66]=te):te=t[66];const oe=te;let he;t[67]===Symbol.for("react.memo_cache_sentinel")?(he=[],t[67]=he):he=t[67];const[ie,Fe]=c.useState(he),[_e,Ae]=c.useState(""),Me=s0(D,se);let q;t[68]!==D||t[69]!==Me||t[70]!==n||t[71]!==T||t[72]!==Fe||t[73]!==Ae||t[74]!==se?(q=()=>{if(!n){Fe([]),Ae("");return}if(!Me){Fe([]),Ae("");return}if(!D){Fe([]),Ae("");return}let Ue=!1;return T(D,se,40,{type:"file"}).then(He=>{Ue||(Fe(He.map(L0)),Ae(Me))}).catch(()=>{Ue||(Fe([]),Ae(Me))}),()=>{Ue=!0}},t[68]=D,t[69]=Me,t[70]=n,t[71]=T,t[72]=Fe,t[73]=Ae,t[74]=se,t[75]=q):q=t[75];let Ne;t[76]!==D||t[77]!==Me||t[78]!==n||t[79]!==T||t[80]!==se?(Ne=[n,D,se,Me,T],t[76]=D,t[77]=Me,t[78]=n,t[79]=T,t[80]=se,t[81]=Ne):Ne=t[81],c.useEffect(q,Ne);const je=re.length>0;let We;e:{if(!je){let He;t[82]!==G?(He=G.filter($0).map(z0),t[82]=G,t[83]=He):He=t[83],We=He;break e}let Ue;t[84]!==G||t[85]!==re?(Ue=zr(G,re,W0,{limit:7,noFuzzy:!0}),t[84]=G,t[85]=re,t[86]=Ue):Ue=t[86],We=Ue}const tt=We;let it;e:{if(!je){let He;t[87]===Symbol.for("react.memo_cache_sentinel")?(He=[],t[87]=He):He=t[87],it=He;break e}let Ue;t[88]!==re||t[89]!==ue?(Ue=zr(ue,re,K0,{limit:7,noFuzzy:!0}),t[88]=re,t[89]=ue,t[90]=Ue):Ue=t[90],it=Ue}const rt=it;let ot;e:{if(!je){let He;t[91]!==W?(He=W.slice(0,5).map(V0),t[91]=W,t[92]=He):He=t[92],ot=He;break e}let Ue;t[93]!==re||t[94]!==W?(Ue=zr(W,re,U0,{limit:7,threshold:.2}),t[93]=re,t[94]=W,t[95]=Ue):Ue=t[95],ot=Ue}const ft=ot;let st;e:{if(!n){let He;t[96]===Symbol.for("react.memo_cache_sentinel")?(He=[],t[96]=He):He=t[96],st=He;break e}let Ue;t[97]!==ie||t[98]!==_e||t[99]!==Me||t[100]!==se?(Ue=n0(ie,se,Me,_e),t[97]=ie,t[98]=_e,t[99]=Me,t[100]=se,t[101]=Ue):Ue=t[101],st=Ue}const Ct=st,ht=n&&Me.length>0&&_e!==Me;let be;e:{if(!je){let He;t[102]===Symbol.for("react.memo_cache_sentinel")?(He=[],t[102]=He):He=t[102],be=He;break e}let Ue;if(t[103]!==re||t[104]!==B){const He=B.map(H0);Ue=zr(He,re,G0,{limit:7,threshold:.4}),t[103]=re,t[104]=B,t[105]=Ue}else Ue=t[105];be=Ue}const Je=be;let dt,Ke,mt,ee,fe,Ie,$e,H,Be,Ye,qe,Xe,jt,Ve;if(t[106]!==oe||t[107]!==ke||t[108]!==D||t[109]!==$||t[110]!==je||t[111]!==n||t[112]!==m||t[113]!==k||t[114]!==P||t[115]!==tt||t[116]!==Ct||t[117]!==Je||t[118]!==ft||t[119]!==rt||t[120]!==r||t[121]!==w||t[122]!==f||t[123]!==e){const Ue=tt.map(q0),He=rt.map(Y0),ve=ft.map(Q0),Qe=je?Ct.map(X0):[],Ge=je?Je.map(J0):[];let Ze;e:{if(!je){Ze=["commands","sessions"];break e}const Nt=Z0,At=[{key:"commands",score:Nt(tt)},{key:"settings",score:Nt(rt)},{key:"sessions",score:Nt(ft)},{key:"files",score:Nt(Ct)},{key:"projects",score:Nt(Je)}];At.sort(ej),Ze=At.map(tj)}const lt=Ze,Bt=Nt=>{ke(),w(Nt.id,Ps(Nt))},$t=async Nt=>{if(!D)return;const At=await jf($,Nt,{directory:D});if(!At.ok){ze.error(kf(At.reason));return}m(D,Nt),ke()},Wt=(Nt,At)=>{ke(),k({selectedProjectId:Nt,directoryOverride:At})},Xt=Nt=>ir(ro(Nt,f));ee=Ds,Xe=n,jt=r;let Ft;t[138]!==e?(Ft=e("commandPalette.title"),t[138]=e,t[139]=Ft):Ft=t[139];let Jt;t[140]!==Ft?(Jt=s.jsx(Hs,{children:Ft}),t[140]=Ft,t[141]=Jt):Jt=t[141];let Lt;t[142]!==e?(Lt=e("commandPalette.description"),t[142]=e,t[143]=Lt):Lt=t[143];let is;t[144]!==Lt?(is=s.jsx(Gs,{children:Lt}),t[144]=Lt,t[145]=is):is=t[145],t[146]!==Jt||t[147]!==is?(Ve=s.jsxs(sn,{className:"sr-only",children:[Jt,is]}),t[146]=Jt,t[147]=is,t[148]=Ve):Ve=t[148],mt=Is,Ye="overflow-hidden p-0",qe=!0,Ke=pg,$e=!1,H="[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-input]]:h-8 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1.5 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4 [&_[cmdk-item]]:typography-meta";let _t;t[149]!==e?(_t=e("commandPalette.input.placeholder"),t[149]=e,t[150]=_t):_t=t[150],t[151]!==P||t[152]!==_t?(Be=s.jsx(gg,{value:P,onValueChange:Z,placeholder:_t}),t[151]=P,t[152]=_t,t[153]=Be):Be=t[153],dt=xg;let zt;t[154]!==e?(zt=e("commandPalette.empty.noResults"),t[154]=e,t[155]=zt):zt=t[155],t[156]!==zt?(fe=s.jsx(bg,{children:zt}),t[156]=zt,t[157]=fe):fe=t[157],Ie=lt.map(Nt=>Nt==="commands"&&Ue.length>0?s.jsx(Mr,{children:Ue.map(At=>s.jsxs(Wr,{value:At.id,onSelect:At.onSelect,children:[At.icon,s.jsx("span",{children:At.title}),At.shortcutId?s.jsx(ug,{children:Xt(At.shortcutId)}):null]},At.id))},"commands"):Nt==="settings"&&He.length>0?s.jsx(Mr,{children:He.map(sj)},"settings"):Nt==="sessions"&&ve.length>0?s.jsx(Mr,{children:ve.map(At=>{const us=At.title||e("commandPalette.session.untitled"),xs=Ps(At),qs=oe(At.id,xs);return s.jsxs(Wr,{value:`session:${At.id}`,onSelect:()=>Bt(At),children:[s.jsx(F,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:us}),qs?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(F,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:qs})]}):null]},At.id)})},"sessions"):Nt==="files"&&Qe.length>0?s.jsx(Mr,{children:Qe.map(At=>{const us=fg(At.relativePath||At.name,{maxLength:80});return s.jsxs(Wr,{value:`file:${At.path}`,onSelect:()=>{$t(At.path)},children:[s.jsx(qa,{filePath:At.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":At.relativePath,children:us})]},`file:${At.path}`)})},"files"):Nt==="projects"&&Ge.length>0?s.jsx(Mr,{children:Ge.map(At=>{const us=At.displayName;return s.jsxs(Wr,{value:`project:${At.id}`,onSelect:()=>Wt(At.id,At.path),children:[s.jsx(F,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:us}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:At.path})]},`project:${At.id}`)})},"projects"):null),t[106]=oe,t[107]=ke,t[108]=D,t[109]=$,t[110]=je,t[111]=n,t[112]=m,t[113]=k,t[114]=P,t[115]=tt,t[116]=Ct,t[117]=Je,t[118]=ft,t[119]=rt,t[120]=r,t[121]=w,t[122]=f,t[123]=e,t[124]=dt,t[125]=Ke,t[126]=mt,t[127]=ee,t[128]=fe,t[129]=Ie,t[130]=$e,t[131]=H,t[132]=Be,t[133]=Ye,t[134]=qe,t[135]=Xe,t[136]=jt,t[137]=Ve}else dt=t[124],Ke=t[125],mt=t[126],ee=t[127],fe=t[128],Ie=t[129],$e=t[130],H=t[131],Be=t[132],Ye=t[133],qe=t[134],Xe=t[135],jt=t[136],Ve=t[137];let pt;t[158]!==ht||t[159]!==e?(pt=ht?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[158]=ht,t[159]=e,t[160]=pt):pt=t[160];let Rt;t[161]!==dt||t[162]!==fe||t[163]!==Ie||t[164]!==pt?(Rt=s.jsxs(dt,{children:[fe,Ie,pt]}),t[161]=dt,t[162]=fe,t[163]=Ie,t[164]=pt,t[165]=Rt):Rt=t[165];let De;t[166]!==Ke||t[167]!==$e||t[168]!==H||t[169]!==Be||t[170]!==Rt?(De=s.jsxs(Ke,{shouldFilter:$e,className:H,children:[Be,Rt]}),t[166]=Ke,t[167]=$e,t[168]=H,t[169]=Be,t[170]=Rt,t[171]=De):De=t[171];let yt;t[172]!==mt||t[173]!==Ye||t[174]!==qe||t[175]!==De?(yt=s.jsx(mt,{className:Ye,showCloseButton:qe,children:De}),t[172]=mt,t[173]=Ye,t[174]=qe,t[175]=De,t[176]=yt):yt=t[176];let Pt;return t[177]!==ee||t[178]!==Xe||t[179]!==jt||t[180]!==Ve||t[181]!==yt?(Pt=s.jsxs(ee,{open:Xe,onOpenChange:jt,children:[Ve,yt]}),t[177]=ee,t[178]=Xe,t[179]=jt,t[180]=Ve,t[181]=yt,t[182]=Pt):Pt=t[182],Pt};function a0(t){return t.isCommandPaletteOpen}function l0(t){return t.setCommandPaletteOpen}function c0(t){return t.setSettingsDialogOpen}function d0(t){return t.setSettingsPage}function u0(t){return t.setSessionSwitcherOpen}function f0(t){return t.toggleSidebar}function m0(t){return t.openContextOverview}function h0(t){return t.openContextSurface}function p0(t){return t.openContextFile}function g0(t){return t.shortcutOverrides}function x0(t){return t.openMultiRunLauncher}function b0(t){return t.setArchivePageOpen}function y0(t){return t.setProjectContextTab}function w0(t){return t.openNewSessionDraft}function v0(t){return t.setCurrentSession}function S0(t){return t.currentSessionId}function j0(t){return t.toggle}function k0(t){return t.currentDirectory}function C0(t){return t.getActiveProject()}function N0(t){return t.projects}function A0(t){return t.searchFiles}function P0(t){return t.ensureStatus}function D0(){Bu()}function I0(){mn.requestDirectoryDialog()}function T0(){yg.invoke("cycle_theme")}function E0(){Fu()}function R0(){window.dispatchEvent(new CustomEvent("openchamber:memory-debug-toggle"))}function M0(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function O0(t){return t.routingFeatureAvailable}function B0(t){return t.slug!=="home"}function F0(t){return!mg(t)}function _0(t){return t.worktreeMetadata}function L0(t){return{path:Pa(t.path),name:t.name,relativePath:t.relativePath}}function $0(t){return!t.secondary}function z0(t){return{item:t,score:0}}function W0(t){return t.searchText}function K0(t){return t.searchText}function V0(t){return{item:t,score:0}}function U0(t){return t.title||""}function H0(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function G0(t){return t.searchText}function q0(t){return t.item}function Y0(t){return t.item}function Q0(t){return t.item}function X0(t){return t.item}function J0(t){return t.item}function Z0(t){return t.length?t[0].score:1/0}function ej(t,e){return t.score-e.score}function tj(t){return t.key}function sj(t){return s.jsxs(Wr,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const Kc=(t,e,n)=>ir(ro(t,e),n),nj=()=>{const t=et.c(73),{t:e}=kt(),n=Pe(rj),r=Pe(oj),i=Pe(ij);let o,l,a,d,u,m,f,p,y,x,k,w;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==e){const Y=[{categoryKey:"helpDialog.section.navigationCommands",items:[{id:"open_command_palette",descriptionKey:"helpDialog.item.openCommandPalette",icon:"command",keys:""},{id:"open_help",descriptionKey:"helpDialog.item.showKeyboardShortcuts",icon:"question",keys:""},{id:"toggle_sidebar",descriptionKey:"helpDialog.item.toggleSessionSidebar",icon:"layout-left",keys:""},{id:"add_selection_to_chat",descriptionKey:"helpDialog.item.addSelectionToChat",icon:"add",keys:""},{id:"cycle_agent",keys:"",descriptionKey:"helpDialog.item.cycleAgent",icon:"ai-agent"},{id:"open_model_selector",descriptionKey:"helpDialog.item.openModelSelector",icon:"ai-generate-2",keys:""},{keys:["↑↓"],descriptionKey:"helpDialog.item.navigateModels",icon:"ai-generate-2"},{keys:["←→"],descriptionKey:"helpDialog.item.adjustThinkingMode",icon:"brain-ai-3"},{id:"cycle_thinking_variant",descriptionKey:"helpDialog.item.cycleThinkingVariant",icon:"brain-ai-3",keys:""},{keys:[ir("mod+shift+alt+n")],descriptionKey:"helpDialog.item.newWindow",icon:"window"}]},{categoryKey:"helpDialog.section.sessionManagement",items:[{id:"new_chat",descriptionKey:"helpDialog.item.createNewSession",icon:"add",keys:""},{id:"new_chat_worktree",descriptionKey:"helpDialog.item.createNewWorktreeDraft",icon:"git-branch",keys:""},{id:"open_draft_project_picker",icon:"folder",keys:""},{id:"open_draft_worktree_picker",icon:"git-branch",keys:""},{id:"open_session_list",icon:"list-unordered",keys:""},{id:"focus_input",descriptionKey:"helpDialog.item.focusChatInput",icon:"text",keys:""},{id:"toggle_prompt_navigator",descriptionKey:"helpDialog.item.togglePromptNavigator",icon:"list-unordered",keys:""},{id:"abort_run",descriptionKey:"helpDialog.item.abortActiveRun",icon:"close-circle",keys:""}]},{categoryKey:"helpDialog.section.panels",items:[{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{id:"toggle_terminal_expanded",descriptionKey:"helpDialog.item.toggleTerminalExpanded",icon:"window",keys:""},{keys:[`${ir(ra("switch_context_surface",i))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${ir(ra("switch_session_tab",i))} + 1...9`],descriptionKey:"helpDialog.item.switchSessionTab",icon:"layout-right"}]},{categoryKey:"helpDialog.section.interface",items:[{id:"cycle_theme",descriptionKey:"helpDialog.item.cycleTheme",icon:"palette",keys:""},{id:"toggle_services_menu",descriptionKey:"helpDialog.item.toggleServicesMenu",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"helpDialog.item.openSettings",icon:"settings-3",keys:""}]}];a=Ds,k=n,w=r,l=Is,y="max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let L;t[16]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx(F,{name:"command",className:"h-5 w-5"}),t[16]=L):L=t[16];let A;t[17]!==e?(A=e("helpDialog.title"),t[17]=e,t[18]=A):A=t[18];let D;t[19]!==A?(D=s.jsxs(Hs,{className:"flex items-center gap-2",children:[L,A]}),t[19]=A,t[20]=D):D=t[20];let P;t[21]!==e?(P=e("helpDialog.description"),t[21]=e,t[22]=P):P=t[22];let Z;t[23]!==P?(Z=s.jsx(Gs,{children:P}),t[23]=P,t[24]=Z):Z=t[24],t[25]!==D||t[26]!==Z?(x=s.jsxs(sn,{children:[D,Z]}),t[25]=D,t[26]=Z,t[27]=x):x=t[27],o=On,m="flex-1 min-h-0 mt-3",f="pr-1",p=!0,d="space-y-4",u=Y.map(X=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(X.categoryKey)}),s.jsx("div",{className:"space-y-1",children:X.items.map(se=>{const ce=se.id?wg(se.id):void 0,re=se.descriptionKey??(ce?.customizable?ce.settingsLabelKey:void 0);if(!re||se.id&&!ro(se.id,i))return null;const ge=se.id?Kc(se.id,i,e("settings.openchamber.keyboardShortcuts.unassigned")):Array.isArray(se.keys)?se.keys:se.keys.split(" / ");return s.jsxs("div",{className:"flex items-center justify-between py-1 px-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[se.icon&&s.jsx(F,{name:se.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(re)})]}),s.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(ge)?ge:[ge]).map((ae,Ee)=>s.jsxs(c.Fragment,{children:[Ee>0&&s.jsx("span",{className:"typography-meta text-muted-foreground mx-1",children:e("helpDialog.keyCombiner.or")}),s.jsx("kbd",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 typography-meta font-mono bg-muted rounded border border-border/20",children:ae})]},`${ae}-${Ee}`))})]},se.id||re)})})]},X.categoryKey)),t[0]=n,t[1]=r,t[2]=i,t[3]=e,t[4]=o,t[5]=l,t[6]=a,t[7]=d,t[8]=u,t[9]=m,t[10]=f,t[11]=p,t[12]=y,t[13]=x,t[14]=k,t[15]=w}else o=t[4],l=t[5],a=t[6],d=t[7],u=t[8],m=t[9],f=t[10],p=t[11],y=t[12],x=t[13],k=t[14],w=t[15];let h;t[28]!==d||t[29]!==u?(h=s.jsx("div",{className:d,children:u}),t[28]=d,t[29]=u,t[30]=h):h=t[30];let g;t[31]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(F,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),t[31]=g):g=t[31];let j;t[32]!==e?(j=e("helpDialog.proTips.title"),t[32]=e,t[33]=j):j=t[33];let b;t[34]!==j?(b=s.jsx("p",{className:"font-medium mb-1",children:j}),t[34]=j,t[35]=b):b=t[35];let S;t[36]!==i||t[37]!==e?(S=e("helpDialog.proTips.commandPalette",{shortcut:Kc("open_command_palette",i,e("settings.openchamber.keyboardShortcuts.unassigned"))}),t[36]=i,t[37]=e,t[38]=S):S=t[38];let C;t[39]!==S?(C=s.jsxs("li",{children:["• ",S]}),t[39]=S,t[40]=C):C=t[40];let v;t[41]!==e?(v=e("helpDialog.proTips.recentSessions"),t[41]=e,t[42]=v):v=t[42];let M;t[43]!==v?(M=s.jsxs("li",{children:["• ",v]}),t[43]=v,t[44]=M):M=t[44];let R;t[45]!==e?(R=e("helpDialog.proTips.leaderSequences"),t[45]=e,t[46]=R):R=t[46];let I;t[47]!==R?(I=s.jsxs("li",{children:["• ",R]}),t[47]=R,t[48]=I):I=t[48];let B;t[49]!==C||t[50]!==M||t[51]!==I?(B=s.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[C,M,I]}),t[49]=C,t[50]=M,t[51]=I,t[52]=B):B=t[52];let O;t[53]!==b||t[54]!==B?(O=s.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:s.jsxs("div",{className:"flex items-start gap-2",children:[g,s.jsxs("div",{className:"typography-meta text-muted-foreground",children:[b,B]})]})}),t[53]=b,t[54]=B,t[55]=O):O=t[55];let T;t[56]!==o||t[57]!==m||t[58]!==O||t[59]!==f||t[60]!==p||t[61]!==h?(T=s.jsxs(o,{outerClassName:m,className:f,disableHorizontal:p,children:[h,O]}),t[56]=o,t[57]=m,t[58]=O,t[59]=f,t[60]=p,t[61]=h,t[62]=T):T=t[62];let $;t[63]!==l||t[64]!==T||t[65]!==y||t[66]!==x?($=s.jsxs(l,{className:y,children:[x,T]}),t[63]=l,t[64]=T,t[65]=y,t[66]=x,t[67]=$):$=t[67];let _;return t[68]!==a||t[69]!==$||t[70]!==k||t[71]!==w?(_=s.jsx(a,{open:k,onOpenChange:w,children:$}),t[68]=a,t[69]=$,t[70]=k,t[71]=w,t[72]=_):_=t[72],_};function rj(t){return t.isHelpDialogOpen}function oj(t){return t.setHelpDialogOpen}function ij(t){return t.shortcutOverrides}const aj=()=>{const t=et.c(32),{t:e}=kt(),n=Pe(lj),r=Pe(cj),i=Pe(dj);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await fr(i)).ok){ze.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}ze.error(e("openCodeStatusDialog.toast.copyFailed"))},t[0]=i,t[1]=e,t[2]=o):o=t[2];const l=o;let a;t[3]!==e?(a=e("openCodeStatusDialog.title"),t[3]=e,t[4]=a):a=t[4];let d;t[5]!==a?(d=s.jsx(Hs,{children:a}),t[5]=a,t[6]=d):d=t[6];let u;t[7]!==e?(u=e("openCodeStatusDialog.description"),t[7]=e,t[8]=u):u=t[8];let m;t[9]!==u?(m=s.jsx(Gs,{children:u}),t[9]=u,t[10]=m):m=t[10];let f;t[11]!==d||t[12]!==m?(f=s.jsxs(sn,{children:[d,m]}),t[11]=d,t[12]=m,t[13]=f):f=t[13];let p;t[14]!==e?(p=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=p):p=t[15];let y;t[16]!==l||t[17]!==p?(y=s.jsx("div",{className:"flex items-center justify-end",children:s.jsx("button",{type:"button",onClick:l,className:"app-region-no-drag inline-flex h-9 items-center justify-center rounded-md px-3 typography-ui-label font-medium text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:p})}),t[16]=l,t[17]=p,t[18]=y):y=t[18];let x;t[19]!==i||t[20]!==e?(x=i||e("openCodeStatusDialog.empty.noData"),t[19]=i,t[20]=e,t[21]=x):x=t[21];let k;t[22]!==x?(k=s.jsx("pre",{className:"max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap",children:x}),t[22]=x,t[23]=k):k=t[23];let w;t[24]!==f||t[25]!==y||t[26]!==k?(w=s.jsxs(Is,{className:"max-w-2xl",children:[f,y,k]}),t[24]=f,t[25]=y,t[26]=k,t[27]=w):w=t[27];let h;return t[28]!==n||t[29]!==r||t[30]!==w?(h=s.jsx(Ds,{open:n,onOpenChange:r,children:w}),t[28]=n,t[29]=r,t[30]=w,t[31]=h):h=t[31],h};function lj(t){return t.isOpenCodeStatusDialogOpen}function cj(t){return t.setOpenCodeStatusDialogOpen}function dj(t){return t.openCodeStatusText}const uj=t=>{const e=et.c(16),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:i,sessionSearchInputRef:o,sessionSearchContainerRef:l}=t,a=n===void 0?!0:n;let d,u;e[0]!==a||e[1]!==r||e[2]!==o?(d=()=>{if(!a||!r||typeof window>"u")return;const x=window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>window.cancelAnimationFrame(x)},u=[a,r,o],e[0]=a,e[1]=r,e[2]=o,e[3]=d,e[4]=u):(d=e[3],u=e[4]),c.useEffect(d,u);let m,f;e[5]!==a||e[6]!==o||e[7]!==i?(m=()=>{if(!a||typeof window>"u")return;const x=()=>{i(!0),o.current?.focus(),o.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",x),()=>window.removeEventListener("openchamber:sidebar-session-search",x)},f=[a,i,o],e[5]=a,e[6]=o,e[7]=i,e[8]=m,e[9]=f):(m=e[8],f=e[9]),c.useEffect(m,f);let p,y;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==i?(p=()=>{if(!a||!r||typeof document>"u")return;const x=k=>{l.current&&(l.current.contains(k.target)||i(!1))};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},y=[a,r,i,l],e[10]=a,e[11]=r,e[12]=l,e[13]=i,e[14]=p,e[15]=y):(p=e[14],y=e[15]),c.useEffect(p,y)},fj=t=>{const e=et.c(4);let n;e[0]!==t?(n=(o,l)=>{const a=t.get(o);if(!a||a.length===0)return l;const d=new Map(l.map(mj)),u=[];a.forEach(p=>{const y=d.get(p);y&&(u.push(y),d.delete(p))});const m=[],f=[];return l.forEach(p=>{d.has(p.id)&&(p.isArchivedBucket?f.push(p):m.push(p))}),[...m,...u,...f]},e[0]=t,e[1]=n):n=e[1];const r=n;let i;return e[2]!==r?(i={getOrderedGroups:r},e[2]=r,e[3]=i):i=e[3],i};function mj(t){return[t.id,t]}const So="oc.sessions.projectCollapse",Vc="oc.sessions.groupOrder",Uc="oc.sessions.groupCollapse",Hc=t=>{if(!t)return new Set;try{const e=rl(ur()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},hj=t=>{if(!t)return new Map;try{const e=df(ur(),rl(ur())).safeParse(JSON.parse(t));if(!e.success)return new Map;const n=new Map;for(const[r,i]of Object.entries(e.data))n.set(r,i);return n}catch{return new Map}},pj=t=>{const e=et.c(39),{isVSCode:n,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=$o(),e[0]=i):i=e[0];const o=i;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>Hc(o.getItem(So)),e[1]=l):l=e[1];const[a,d]=c.useState(l);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>Hc(o.getItem(Uc)),e[2]=u):u=e[2];const[m,f]=c.useState(u);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=()=>hj(o.getItem(Vc)),e[3]=p):p=e[3];const[y,x]=c.useState(p),k=c.useRef(0),w=c.useRef(!1),h=c.useRef(!1),g=c.useRef(null),j=c.useRef(null);let b;e[4]!==n?(b=()=>{if(n)return;const me=j.current;if(j.current=null,g.current=null,!me)return;const{projects:ke}=Gt.getState(),V=ke.map(J=>({...J,sidebarCollapsed:me.has(J.id)}));gr({projects:V}).catch(gj)},e[4]=n,e[5]=b):b=e[5];const S=b;let C;e[6]!==S||e[7]!==n?(C=me=>{!globalThis.window||n||(j.current=me,g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{S()},700))},e[6]=S,e[7]=n,e[8]=C):C=e[8];const v=C;let M,R;e[9]===Symbol.for("react.memo_cache_sentinel")?(M=()=>()=>{globalThis.window&&g.current!==null&&window.clearTimeout(g.current),g.current=null,j.current=null},R=[],e[9]=M,e[10]=R):(M=e[9],R=e[10]),c.useEffect(M,R);let I,B;e[11]!==y?(B=()=>{if(h.current)try{o.setItem(Vc,JSON.stringify(Object.fromEntries(y.entries())))}catch{}},I=[y,o],e[11]=y,e[12]=I,e[13]=B):(I=e[12],B=e[13]),c.useEffect(B,I);let O,T;e[14]!==m?(O=()=>{if(w.current)try{o.setItem(Uc,JSON.stringify(Array.from(m)))}catch{}},T=[m,o],e[14]=m,e[15]=O,e[16]=T):(O=e[15],T=e[16]),c.useEffect(O,T);let $;e[17]!==r||e[18]!==v?($=()=>{k.current=Date.now()+150,w.current=!0,f(new Set),d(()=>{const me=new Set(r.map(xj));try{o.setItem(So,JSON.stringify(Array.from(me)))}catch{}return v(me),me})},e[17]=r,e[18]=v,e[19]=$):$=e[19];const _=$;let Y;e[20]!==v?(Y=()=>{k.current=Date.now()+150,w.current=!0,f(new Set),d(()=>{const me=new Set;try{o.setItem(So,JSON.stringify([]))}catch{}return v(me),me})},e[20]=v,e[21]=Y):Y=e[21];const L=Y;let A;e[22]!==v?(A=me=>{k.current=Date.now()+150,d(ke=>{const V=new Set(ke);V.has(me)?V.delete(me):V.add(me);try{o.setItem(So,JSON.stringify(Array.from(V)))}catch{}return v(V),V})},e[22]=v,e[23]=A):A=e[23];const D=A;let P;e[24]===Symbol.for("react.memo_cache_sentinel")?(P=me=>{w.current=!0,f(ke=>{const V=new Set(ke);return V.has(me)?V.delete(me):V.add(me),V})},e[24]=P):P=e[24];const Z=P;let X;e[25]===Symbol.for("react.memo_cache_sentinel")?(X=me=>{h.current=!0,x(me)},e[25]=X):X=e[25];const se=X,{getOrderedGroups:ce}=fj(y);let re;e[26]!==m||e[27]!==a||e[28]!==y?(re={collapsedProjects:a,collapsedGroups:m,groupOrderByProject:y},e[26]=m,e[27]=a,e[28]=y,e[29]=re):re=e[29];const ge=re;let ae;e[30]!==_||e[31]!==L||e[32]!==ce||e[33]!==v||e[34]!==D?(ae={setCollapsedProjects:d,toggleProject:D,collapseAllProjects:_,expandAllProjects:L,scheduleCollapsedProjectsPersist:v,setCollapsedGroups:f,toggleGroup:Z,setGroupOrderByProject:se,getOrderedGroups:ce},e[30]=_,e[31]=L,e[32]=ce,e[33]=v,e[34]=D,e[35]=ae):ae=e[35];const Ee=ae;let Se;return e[36]!==Ee||e[37]!==ge?(Se={state:ge,actions:Ee},e[36]=Ee,e[37]=ge,e[38]=Se):Se=e[38],Se};function gj(){}function xj(t){return t.id}const bj=5*6e4,yj=t=>{const e=et.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:d}=kn(),u=Mn(wj);let m,f;e[0]!==a||e[1]!==u||e[2]!==d||e[3]!==n||e[4]!==o?(m=()=>{if(!a||!d||n.length===0){o(new Map);return}n.forEach(C=>{oa(()=>u(C.normalizedPath,d))})},f=[a,n,d,u,o],e[0]=a,e[1]=u,e[2]=d,e[3]=n,e[4]=o,e[5]=m,e[6]=f):(m=e[5],f=e[6]),c.useEffect(m,f);let p,y;e[7]!==a||e[8]!==i||e[9]!==n||e[10]!==o?(p=()=>{if(!a)return;const C=new Map;n.forEach(v=>{C.set(v.id,i.get(v.normalizedPath)?.isGitRepo??null)}),o(C)},y=[a,n,i,o],e[7]=a,e[8]=i,e[9]=n,e[10]=o,e[11]=p,e[12]=y):(p=e[11],y=e[12]),c.useEffect(p,y);let x;if(e[13]!==i||e[14]!==n){let C;e[16]!==i?(C=v=>{const M=i.get(v.normalizedPath)?.branch??"";return`${v.id}:${M}`},e[16]=i,e[17]=C):C=e[17],x=n.map(C).join("|"),e[13]=i,e[14]=n,e[15]=x}else x=e[15];const k=x;let w;e[18]===Symbol.for("react.memo_cache_sentinel")?(w=new Map,e[18]=w):w=e[18];const h=c.useRef(w);let g;e[19]===Symbol.for("react.memo_cache_sentinel")?(g=new Map,e[19]=g):g=e[19];const j=c.useRef(g);let b;e[20]!==a||e[21]!==i||e[22]!==n||e[23]!==l?(b=()=>{if(!a)return;let C=!1;const v=setTimeout(()=>{(async()=>{const R=new Set(n.map(vj));for(const _ of h.current.keys())R.has(_)||(h.current.delete(_),j.current.delete(_));const I=Date.now(),B=n.filter(_=>{const Y=i.get(_.normalizedPath);if(Y?.isGitRepo===!1)return h.current.delete(_.id),j.current.delete(_.id),!1;if(Y?.isGitRepo!==!0||Y.branch===null)return!1;const L=Y.branch.trim(),A=`${_.normalizedPath}\0${L}`,D=h.current.get(_.id);if(D===A){const P=j.current.get(_.id);return P&&(P.at=I),!1}return!(D!==void 0&&I-(j.current.get(_.id)?.at??0)<bj)});if(B.length===0)return;const O=await vg(B,2,async _=>{const Y=i.get(_.normalizedPath)?.branch?.trim()??"",L=`${_.normalizedPath}\0${Y}`,A=await oa(()=>Ha(_.normalizedPath,Y?{knownBranch:Y}:void 0)).catch(Sj);return{id:_.id,inputKey:L,branch:A}});if(C)return;const T=O.filter(jj);if(T.length===0)return;const $=Date.now();l(_=>{const Y=new Map(_);return T.forEach(L=>{const{id:A,branch:D}=L;D&&Y.set(A,D)}),Y}),T.forEach(_=>{const{id:Y,inputKey:L,branch:A}=_;h.current.set(Y,L),A&&j.current.set(Y,{branch:A,at:$})})})()},150);return()=>{C=!0,clearTimeout(v)}},e[20]=a,e[21]=i,e[22]=n,e[23]=l,e[24]=b):b=e[24];let S;e[25]!==a||e[26]!==i||e[27]!==n||e[28]!==k||e[29]!==l?(S=[a,n,k,i,l],e[25]=a,e[26]=i,e[27]=n,e[28]=k,e[29]=l,e[30]=S):S=e[30],c.useEffect(b,S)};function wj(t){return t.ensureStatus}function vj(t){return t.id}function Sj(){return null}function jj(t){return t.branch}const kj=t=>{const e=et.c(10),{open:n,onOpenChange:r,project:i,onSave:o}=t;let l;e[0]!==o||e[1]!==n||e[2]!==i?(l=n&&i?s.jsx($h,{project:i,onIdentitySave:o,showWorktrees:!1}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=l):l=e[3];let a;e[4]!==l?(a=s.jsx(Is,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(On,{outerClassName:"max-h-[min(90vh,48rem)]",className:"w-full bg-transparent",children:s.jsx("div",{className:"w-full p-3 sm:p-6 sm:pt-8",children:l})})}),e[4]=l,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==n||e[8]!==a?(d=s.jsx(Ds,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=d):d=e[9],d};function Cj(t){const e=et.c(199),{t:n}=kt(),r=_u(),{hideDirectoryControls:i,showProjectDisplayControls:o,showRecentControls:l,handleOpenDirectoryDialog:a,onOpenScheduled:d,onOpenMultiRun:u,canOpenMultiRun:m,onOpenArchive:f,headerActionIconClass:p,headerActionButtonClass:y,isSessionSearchOpen:x,setIsSessionSearchOpen:k,sessionSearchInputRef:w,sessionSearchQuery:h,setSessionSearchQuery:g,hasSessionSearchQuery:j,searchMatchCount:b,collapseAllProjects:S,expandAllProjects:C}=t,v=hs(Lj),M=hs(_j),R=ys(Fj),I=ys(Bj),B=ys(Oj),O=ys(Mj),T=ys(Rj),$=ys(Ej),_=ys(Tj),Y=ys(Ij),L=ys(Dj),A=ys(Pj),D=o&&L==="single",P=o&&_==="timeline";if(i)return null;let Z;e[0]!==y?(Z=Re(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=y,e[1]=Z):Z=e[1];let X;e[2]!==n?(X=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=X):X=e[3];let se;e[4]!==p?(se=s.jsx(F,{name:"folder-add",className:p}),e[4]=p,e[5]=se):se=e[5];let ce;e[6]!==a||e[7]!==Z||e[8]!==X||e[9]!==se?(ce=s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:Z,"aria-label":X,children:se})}),e[6]=a,e[7]=Z,e[8]=X,e[9]=se,e[10]=ce):ce=e[10];let re;e[11]!==n?(re=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=re):re=e[12];let ge;e[13]!==re?(ge=s.jsx(St,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:re})}),e[13]=re,e[14]=ge):ge=e[14];let ae;e[15]!==ce||e[16]!==ge?(ae=s.jsxs(wt,{children:[ce,ge]}),e[15]=ce,e[16]=ge,e[17]=ae):ae=e[17];let Ee;e[18]!==y?(Ee=Re(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=y,e[19]=Ee):Ee=e[19];let Se;e[20]!==n?(Se=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=Se):Se=e[21];let me;e[22]!==p?(me=s.jsx(F,{name:"calendar-schedule",className:p}),e[22]=p,e[23]=me):me=e[23];let ke;e[24]!==d||e[25]!==Ee||e[26]!==Se||e[27]!==me?(ke=s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,className:Ee,"aria-label":Se,children:me})}),e[24]=d,e[25]=Ee,e[26]=Se,e[27]=me,e[28]=ke):ke=e[28];let V;e[29]!==n?(V=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=V):V=e[30];let J;e[31]!==V?(J=s.jsx(St,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:V})}),e[31]=V,e[32]=J):J=e[32];let de;e[33]!==ke||e[34]!==J?(de=s.jsxs(wt,{children:[ke,J]}),e[33]=ke,e[34]=J,e[35]=de):de=e[35];let we;e[36]!==y?(we=Re(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=y,e[37]=we):we=e[37];let G;e[38]!==n?(G=n("sessions.sidebar.header.actions.newMultiRun"),e[38]=n,e[39]=G):G=e[39];const Ce=!m;let Te;e[40]!==p?(Te=s.jsx(kg,{className:p}),e[40]=p,e[41]=Te):Te=e[41];let pe;e[42]!==u||e[43]!==we||e[44]!==G||e[45]!==Ce||e[46]!==Te?(pe=s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:we,"aria-label":G,disabled:Ce,children:Te})}),e[42]=u,e[43]=we,e[44]=G,e[45]=Ce,e[46]=Te,e[47]=pe):pe=e[47];let ne;e[48]!==n?(ne=n("sessions.sidebar.header.actions.newMultiRun"),e[48]=n,e[49]=ne):ne=e[49];let xe;e[50]!==ne?(xe=s.jsx(St,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ne})}),e[50]=ne,e[51]=xe):xe=e[51];let U;e[52]!==pe||e[53]!==xe?(U=s.jsxs(wt,{children:[pe,xe]}),e[52]=pe,e[53]=xe,e[54]=U):U=e[54];let z;e[55]!==y?(z=Re(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[55]=y,e[56]=z):z=e[56];let Q;e[57]!==n?(Q=n("sessions.sidebar.nav.archive"),e[57]=n,e[58]=Q):Q=e[58];let ue;e[59]!==p?(ue=s.jsx(F,{name:"archive",className:p}),e[59]=p,e[60]=ue):ue=e[60];let le;e[61]!==f||e[62]!==z||e[63]!==Q||e[64]!==ue?(le=s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,className:z,"aria-label":Q,children:ue})}),e[61]=f,e[62]=z,e[63]=Q,e[64]=ue,e[65]=le):le=e[65];let W;e[66]!==n?(W=n("sessions.sidebar.nav.archive"),e[66]=n,e[67]=W):W=e[67];let E;e[68]!==W?(E=s.jsx(St,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:W})}),e[68]=W,e[69]=E):E=e[69];let K;e[70]!==le||e[71]!==E?(K=s.jsxs(wt,{children:[le,E]}),e[70]=le,e[71]=E,e[72]=K):K=e[72];let te;e[73]!==r||e[74]!==p||e[75]!==n?(te=r.length>0&&s.jsxs($s,{children:[s.jsx(_s,{asChild:!0,children:s.jsx(ut,{variant:"ghost",size:"xs",className:"w-6 text-muted-foreground","aria-label":n("sessions.sidebar.header.actions.extensionPages"),children:s.jsx(F,{name:"apps",className:p})})}),s.jsxs(Ls,{align:"start",children:[s.jsx(xr,{children:n("sessions.sidebar.header.actions.extensionPages")}),r.map(Aj)]})]}),e[73]=r,e[74]=p,e[75]=n,e[76]=te):te=e[76];let oe;e[77]!==de||e[78]!==U||e[79]!==K||e[80]!==te||e[81]!==ae?(oe=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[ae,de,U,K,te]}),e[77]=de,e[78]=U,e[79]=K,e[80]=te,e[81]=ae,e[82]=oe):oe=e[82];let he;e[83]!==k?(he=()=>k(Nj),e[83]=k,e[84]=he):he=e[84];let ie;e[85]!==y?(ie=Re(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[85]=y,e[86]=ie):ie=e[86];let Fe;e[87]!==n?(Fe=n("sessions.sidebar.header.actions.searchSessions"),e[87]=n,e[88]=Fe):Fe=e[88];let _e;e[89]!==p?(_e=s.jsx(F,{name:"search",className:p}),e[89]=p,e[90]=_e):_e=e[90];let Ae;e[91]!==x||e[92]!==he||e[93]!==ie||e[94]!==Fe||e[95]!==_e?(Ae=s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:he,className:ie,"aria-label":Fe,"aria-expanded":x,children:_e})}),e[91]=x,e[92]=he,e[93]=ie,e[94]=Fe,e[95]=_e,e[96]=Ae):Ae=e[96];let Me;e[97]!==n?(Me=n("sessions.sidebar.header.actions.searchSessions"),e[97]=n,e[98]=Me):Me=e[98];let q;e[99]!==Me?(q=s.jsx(St,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Me})}),e[99]=Me,e[100]=q):q=e[100];let Ne;e[101]!==Ae||e[102]!==q?(Ne=s.jsxs(wt,{children:[Ae,q]}),e[101]=Ae,e[102]=q,e[103]=Ne):Ne=e[103];const je=v&&"bg-interactive-hover text-primary";let We;e[104]!==y||e[105]!==je?(We=Re(y,"text-muted-foreground hover:text-foreground hover:bg-transparent",je),e[104]=y,e[105]=je,e[106]=We):We=e[106];let tt;e[107]!==v||e[108]!==n?(tt=n(v?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[107]=v,e[108]=n,e[109]=tt):tt=e[109];let it;e[110]!==p?(it=s.jsx(F,{name:"checkbox-multiple",className:p}),e[110]=p,e[111]=it):it=e[111];let rt;e[112]!==v||e[113]!==We||e[114]!==tt||e[115]!==it||e[116]!==M?(rt=s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:M,className:We,"aria-label":tt,"aria-pressed":v,children:it})}),e[112]=v,e[113]=We,e[114]=tt,e[115]=it,e[116]=M,e[117]=rt):rt=e[117];let ot;e[118]!==v||e[119]!==n?(ot=n(v?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[118]=v,e[119]=n,e[120]=ot):ot=e[120];let ft;e[121]!==ot?(ft=s.jsx(St,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ot})}),e[121]=ot,e[122]=ft):ft=e[122];let st;e[123]!==rt||e[124]!==ft?(st=s.jsxs(wt,{children:[rt,ft]}),e[123]=rt,e[124]=ft,e[125]=st):st=e[125];let Ct;e[126]!==y?(Ct=Re(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[126]=y,e[127]=Ct):Ct=e[127];let ht;e[128]!==n?(ht=n("sessions.sidebar.header.displayMode.label"),e[128]=n,e[129]=ht):ht=e[129];let be;e[130]!==p?(be=s.jsx(F,{name:"equalizer-2",className:p}),e[130]=p,e[131]=be):be=e[131];let Je;e[132]!==Ct||e[133]!==ht||e[134]!==be?(Je=s.jsx(vt,{asChild:!0,children:s.jsx(_s,{asChild:!0,children:s.jsx("button",{type:"button",className:Ct,"aria-label":ht,children:be})})}),e[132]=Ct,e[133]=ht,e[134]=be,e[135]=Je):Je=e[135];let dt;e[136]!==n?(dt=n("sessions.sidebar.header.displayMode.label"),e[136]=n,e[137]=dt):dt=e[137];let Ke;e[138]!==dt?(Ke=s.jsx(St,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:dt})}),e[138]=dt,e[139]=Ke):Ke=e[139];let mt;e[140]!==Je||e[141]!==Ke?(mt=s.jsxs(wt,{children:[Je,Ke]}),e[140]=Je,e[141]=Ke,e[142]=mt):mt=e[142];let ee;e[143]!==Y||e[144]!==o||e[145]!==_||e[146]!==n||e[147]!==P?(ee=o?s.jsxs(s.Fragment,{children:[s.jsx(xr,{children:n("sessions.sidebar.header.viewMode.label")}),[["projects","sessions.sidebar.header.viewMode.projects"],["timeline","sessions.sidebar.header.viewMode.timeline"]].map(Ve=>{const[pt,Rt]=Ve;return s.jsxs(Ht,{onClick:()=>{Y(pt),gr({sidebarViewMode:pt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Rt)}),_===pt?s.jsx(F,{name:"check",className:"h-4 w-4 text-primary"}):null]},pt)}),P?null:s.jsx(As,{})]}):null,e[143]=Y,e[144]=o,e[145]=_,e[146]=n,e[147]=P,e[148]=ee):ee=e[148];let fe;e[149]!==L||e[150]!==B||e[151]!==A||e[152]!==O||e[153]!==$||e[154]!==o||e[155]!==n||e[156]!==P||e[157]!==T?(fe=P?null:s.jsxs(s.Fragment,{children:[s.jsx(xr,{children:n("sessions.sidebar.header.actions.sortProjects")}),[["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"],["z-a","sessions.sidebar.header.projectSort.zToA"],["date-added","sessions.sidebar.header.projectSort.dateAdded"],["recent","sessions.sidebar.header.projectSort.recent"]].map(Ve=>{const[pt,Rt]=Ve;return s.jsxs(Ht,{onClick:()=>{O(pt),gr({sidebarProjectSortOrder:pt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Rt)}),B===pt?s.jsx(F,{name:"check",className:"h-4 w-4 text-primary"}):null]},pt)}),s.jsx(As,{}),o?s.jsxs(s.Fragment,{children:[s.jsx(xr,{children:n("sessions.sidebar.header.actions.sortWorktrees")}),[["recent","sessions.sidebar.header.worktreeSort.recent"],["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"]].map(Ve=>{const[pt,Rt]=Ve;return s.jsxs(Ht,{onClick:()=>{$(pt),gr({sidebarWorktreeSortOrder:pt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Rt)}),T===pt?s.jsx(F,{name:"check",className:"h-4 w-4 text-primary"}):null]},pt)}),s.jsx(As,{})]}):null,o?s.jsxs(s.Fragment,{children:[s.jsx(xr,{children:n("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(Ve=>{const[pt,Rt]=Ve;return s.jsxs(Ht,{onClick:()=>{A(pt),gr({sidebarProjectDisplayMode:pt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Rt)}),L===pt?s.jsx(F,{name:"check",className:"h-4 w-4 text-primary"}):null]},pt)}),s.jsx(As,{})]}):null]}),e[149]=L,e[150]=B,e[151]=A,e[152]=O,e[153]=$,e[154]=o,e[155]=n,e[156]=P,e[157]=T,e[158]=fe):fe=e[158];let Ie;e[159]!==D||e[160]!==l||e[161]!==R||e[162]!==n||e[163]!==P||e[164]!==I?(Ie=!P&&l&&!D?s.jsxs(Ht,{onClick:()=>{I(),gr({sidebarShowRecentSection:!R})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),R?s.jsx(F,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[159]=D,e[160]=l,e[161]=R,e[162]=n,e[163]=P,e[164]=I,e[165]=Ie):Ie=e[165];let $e;e[166]!==S||e[167]!==C||e[168]!==D||e[169]!==n||e[170]!==P?($e=!P&&!D?s.jsxs(s.Fragment,{children:[s.jsx(As,{}),s.jsxs(Ht,{onClick:S,className:"flex items-center gap-2",children:[s.jsx(F,{name:"contract-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.collapseAll")})]}),s.jsxs(Ht,{onClick:C,className:"flex items-center gap-2",children:[s.jsx(F,{name:"expand-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.expandAll")})]})]}):null,e[166]=S,e[167]=C,e[168]=D,e[169]=n,e[170]=P,e[171]=$e):$e=e[171];let H;e[172]!==ee||e[173]!==fe||e[174]!==Ie||e[175]!==$e?(H=s.jsxs(Ls,{align:"end",className:"min-w-[180px]",children:[ee,fe,Ie,$e]}),e[172]=ee,e[173]=fe,e[174]=Ie,e[175]=$e,e[176]=H):H=e[176];let Be;e[177]!==mt||e[178]!==H?(Be=s.jsxs($s,{children:[mt,H]}),e[177]=mt,e[178]=H,e[179]=Be):Be=e[179];let Ye;e[180]!==Ne||e[181]!==st||e[182]!==Be?(Ye=s.jsxs("div",{className:"flex items-center gap-1.5",children:[Ne,st,Be]}),e[180]=Ne,e[181]=st,e[182]=Be,e[183]=Ye):Ye=e[183];let qe;e[184]!==oe||e[185]!==Ye?(qe=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[oe,Ye]}),e[184]=oe,e[185]=Ye,e[186]=qe):qe=e[186];let Xe;e[187]!==j||e[188]!==x||e[189]!==b||e[190]!==w||e[191]!==h||e[192]!==k||e[193]!==g||e[194]!==n?(Xe=x?s.jsx("div",{className:"pb-1",children:s.jsx(su,{inputRef:w,value:h,onSearch:g,onClose:()=>k(!1),placeholder:n("sessions.sidebar.header.search.placeholder"),clearLabel:n("sessions.sidebar.header.search.clear"),leadingHint:j?b===1?n("sessions.sidebar.header.search.matchCountSingle",{count:b}):n("sessions.sidebar.header.search.matchCountPlural",{count:b}):void 0,trailingHint:n("sessions.sidebar.header.search.escapeHint")})}):null,e[187]=j,e[188]=x,e[189]=b,e[190]=w,e[191]=h,e[192]=k,e[193]=g,e[194]=n,e[195]=Xe):Xe=e[195];let jt;return e[196]!==qe||e[197]!==Xe?(jt=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1",children:s.jsxs("div",{className:"flex h-auto min-h-8 flex-col gap-1",children:[qe,Xe]})}),e[196]=qe,e[197]=Xe,e[198]=jt):jt=e[198],jt}function Nj(t){return!t}function Aj(t){return s.jsxs(Ht,{onSelect:()=>Pe.getState().setOpenGuestPage(t.id),children:[s.jsx(no,{icon:jg(t.icon),iconSrc:Sg(t.id,t.icon,Ud().authenticatedAsset),className:"size-4"}),s.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function Pj(t){return t.setProjectDisplayMode}function Dj(t){return t.projectDisplayMode}function Ij(t){return t.setSidebarViewMode}function Tj(t){return t.sidebarViewMode}function Ej(t){return t.setWorktreeSortOrder}function Rj(t){return t.worktreeSortOrder}function Mj(t){return t.setProjectSortOrder}function Oj(t){return t.projectSortOrder}function Bj(t){return t.toggleRecentSection}function Fj(t){return t.showRecentSection}function _j(t){return t.toggleMode}function Lj(t){return t.enabled}const jo="inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";function $j(t){const e=et.c(14),{onOpenSettings:n,onOpenUsage:r,onOpenShortcuts:i,onOpenAbout:o,onOpenUpdate:l,showRuntimeButtons:a,showUpdateButton:d}=t,u=a===void 0?!0:a,m=d===void 0?!0:d,{t:f}=kt();if(!u&&!m)return null;let p;e[0]!==o||e[1]!==n||e[2]!==i||e[3]!==r||e[4]!==u||e[5]!==f?(p=u?s.jsxs(s.Fragment,{children:[s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:jo,"aria-label":f("sessions.sidebar.footer.actions.settings"),children:s.jsx(F,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(St,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:jo,"aria-label":f("usageStats.openAction"),children:s.jsx(F,{name:"bar-chart",className:"h-4.5 w-4.5"})})}),s.jsx(St,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("usageStats.openAction")})})]}),s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:jo,"aria-label":f("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(F,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(St,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:o,className:jo,"aria-label":f("sessions.sidebar.footer.actions.aboutOpenChamber"),children:s.jsx(F,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(St,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=r,e[4]=u,e[5]=f,e[6]=p):p=e[6];let y;e[7]!==l||e[8]!==m||e[9]!==f?(y=m?s.jsx(ut,{type:"button",variant:"default",size:"xs",className:"ml-auto border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)]/80 hover:text-[var(--status-info)] dark:border-[var(--status-info-border)] dark:bg-[var(--status-info-background)] dark:hover:bg-[var(--status-info-background)]/80",onClick:l,children:f("sessions.sidebar.footer.actions.update")}):null,e[7]=l,e[8]=m,e[9]=f,e[10]=y):y=e[10];let x;return e[11]!==p||e[12]!==y?(x=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[p,y]}),e[11]=p,e[12]=y,e[13]=x):x=e[13],x}const zj=t=>{for(const e of t.sessions.values())if(e.tabs.some(Gd))return!0;return!1},Wj=()=>{const t=et.c(4),{terminal:e}=kn(),n=Ot(zj);let r,i;return t[0]!==n||t[1]!==e?(r=()=>{const o=Kj,l=Vj;if(n)return Yi(e,"",l,o);let a=Uj;return a=Yi(e,"",l,d=>{o(d),a()}),()=>a()},i=[e,n],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i),null};function Kj(t){const e=Ot.getState(),n=zh(t.sessions),r=new Set([...e.sessions.keys(),...n.keys()]);for(const i of r)e.reconcileServerSessions(i,n.get(i)??[],{startedActionMutationRevisions:t.startedActionMutationRevisions})}function Vj(){return new Map(Ot.getState().actionMutationRevisions)}function Uj(){}const Hj=t=>{const e=et.c(12),{normalizedProjects:n,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:d,foldersMap:u,createFolder:m,addSessionToFolder:f}=t,p=r===void 0?!0:r;let y,x;e[0]!==f||e[1]!==m||e[2]!==p||e[3]!==u||e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==i||e[9]!==d?(y=()=>{!p||o||!l||a||n.forEach(k=>{if(d.has(k.normalizedPath))return;const w=Lu(k.normalizedPath),h=i.archivedSessionsByProject.get(k.id)??[],g=u[w]??[],j=new Map(g.map(Gj));h.forEach(b=>{const S=Cg(b,k.normalizedPath),C=S.toLowerCase();let v=j.get(C);v||(v=m(w,S),j.set(C,v)),v.sessionIds.includes(b.id)||f(w,v.id,b.id)})})},x=[n,p,i,o,l,a,d,u,m,f],e[0]=f,e[1]=m,e[2]=p,e[3]=u,e[4]=l,e[5]=o,e[6]=a,e[7]=n,e[8]=i,e[9]=d,e[10]=y,e[11]=x):(y=e[10],x=e[11]),c.useEffect(y,x)};function Gj(t){return[t.name.toLowerCase(),t]}function qj({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:n,projectMap:r,metaByProject:i,rememberedSessionId:o,fallbackSessionId:l}){if(e&&n===t)return{kind:"preserve-current"};if(n==null){const u=!!(e&&Array.from(i.entries()).some(([m,f])=>m!==t&&f.has(e)));if(e&&r&&!u)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const d=(o&&r.has(o)?o:null)??l;return!d||d===e?{kind:"none"}:{kind:"select-session",sessionId:d}}const Yj=t=>{const e=et.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:d,newSessionDraftOpen:u,mobileVariant:m,openNewSessionDraft:f,setSessionSwitcherOpen:p}=t;let y,x;if(e[0]!==n){x=new Map,y=new Map;const C=(v,M,R,I)=>{x.has(v)||x.set(v,new Map);const B=x.get(v);I.forEach(O=>{const T=xt(O.worktree?.path??O.session.directory??R??M);B.set(O.session.id,{directory:T}),y.has(v)||y.set(v,{id:O.session.id,directory:T}),O.children.length>0&&C(v,M,T,O.children)})};n.forEach(v=>{v.groups.forEach(M=>{C(v.project.id,v.project.normalizedPath,M.directory,M.sessions)})}),e[0]=n,e[1]=y,e[2]=x}else y=e[1],x=e[2];let k;e[3]!==y||e[4]!==x?(k={metaByProject:x,firstSessionByProject:y},e[3]=y,e[4]=x,e[5]=k):k=e[5];const w=k,h=c.useRef(null);let g,j;e[6]!==r||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==d||e[11]!==m||e[12]!==u||e[13]!==f||e[14]!==n||e[15]!==w||e[16]!==o||e[17]!==p?(g=()=>{if(!r||u||Pe.getState().isNewWorktreeDialogOpen||h.current===r)return;const C=n.find(I=>I.project.id===r);if(!C)return;const v=w.metaByProject.get(r);if(l&&v&&v.has(l)){h.current=r,o(I=>{if(I.get(r)===l)return I;const B=new Map(I);return B.set(r,l),B});return}const M=qj({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:v,metaByProject:w.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:w.firstSessionByProject.get(r)?.id??null});if(M.kind==="preserve-current"){a===r&&(h.current=r);return}if(h.current=r,M.kind==="open-draft"){m&&p(!1),f({selectedProjectId:C.project.id,directoryOverride:C.project.normalizedPath});return}if(M.kind!=="select-session")return;const R=v?.get(M.sessionId)?.directory??null;d(M.sessionId,R)},j=[r,i,l,a,d,u,m,f,n,w,p,o],e[6]=r,e[7]=i,e[8]=l,e[9]=a,e[10]=d,e[11]=m,e[12]=u,e[13]=f,e[14]=n,e[15]=w,e[16]=o,e[17]=p,e[18]=g,e[19]=j):(g=e[18],j=e[19]),c.useLayoutEffect(g,j);let b,S;e[20]!==r||e[21]!==l||e[22]!==w||e[23]!==o?(b=()=>{if(!r||!l)return;const C=w.metaByProject.get(r);!C||!C.has(l)||o(v=>{if(v.get(r)===l)return v;const M=new Map(v);return M.set(r,l),M})},S=[r,l,w,o],e[20]=r,e[21]=l,e[22]=w,e[23]=o,e[24]=b,e[25]=S):(b=e[24],S=e[25]),c.useEffect(b,S)},Qj=t=>{const e=et.c(20);let n,r,i,o;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:i,sessionOwnerBySessionId:o,...n}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=o):(n=e[1],r=e[2],i=e[3],o=e[4]);const l=nt(Xj),a=nt(Jj);let d;e[5]!==l||e[6]!==o?(d=l?o?.get(l)?.projectId??null:null,e[5]=l,e[6]=o,e[7]=d):d=e[7];const u=d;let m;e[8]!==r?(m=()=>new Map(r),e[8]=r,e[9]=m):m=e[9];const[f,p]=c.useState(m);let y;e[10]!==f||e[11]!==n||e[12]!==l||e[13]!==u||e[14]!==a?(y={...n,activeSessionByProject:f,setActiveSessionByProject:p,currentSessionId:l,currentSessionOwnerProjectId:u,newSessionDraftOpen:a},e[10]=f,e[11]=n,e[12]=l,e[13]=u,e[14]=a,e[15]=y):y=e[15],Yj(y);let x,k;return e[16]!==f||e[17]!==i?(x=()=>{i(f)},k=[f,i],e[16]=f,e[17]=i,e[18]=x,e[19]=k):(x=e[18],k=e[19]),c.useEffect(x,k),null};function Xj(t){return t.currentSessionId}function Jj(t){return!!t.newSessionDraft?.open}const Zj=t=>{const e=et.c(7),{ownership:n}=t;let r;e[0]!==n?(r=d=>n.sessionsByProject.get(d)??[],e[0]=n,e[1]=r):r=e[1];const i=r;let o;e[2]!==n?(o=d=>n.archivedSessionsByProject.get(d)??[],e[2]=n,e[3]=o):o=e[3];const l=o;let a;return e[4]!==l||e[5]!==i?(a={getSessionsForProject:i,getArchivedSessionsForProject:l},e[4]=l,e[5]=i,e[6]=a):a=e[6],a},Zn=(t,e)=>`${t}\0${e}`,nr=(t,e)=>t??Ja(e)??xt(e??null),eo=t=>{if(t.folderScopes&&t.folderScopes.length>0)return t.folderScopes;const e=t.folderScopeKey??xt(t.directory??null);return e?[{scopeKey:e,directory:t.directory}]:[]},ml=t=>t.startsWith("__archived__:"),e2=(t,e)=>t.map(n=>{const r=xt(n.path)??n.path;return`${r}=${e.get(r)??""}`}).join(`
|
|
879
|
-
`),t2=[],s2=t=>{const{normalizedProjects:e,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:o,projectRootBranches:l,gitBranches:a,lastRepoStatus:d,buildGroupedSessions:u,hasSessionSearchQuery:m,normalizedSessionSearchQuery:f,filterSessionNodesForSearch:p,buildGroupSearchText:y,foldersMap:x,standaloneGroups:k}=t,w=c.useRef(new Map),h=c.useMemo(()=>{const R=w.current,I=new Map;let B=0,O=0;const T=(_,Y)=>_.length===Y.length&&_.every((L,A)=>L===Y[A]),$=e.map(_=>{const Y=n(_.id),L=r(_.id),A=i.get(_.normalizedPath)??t2,D=o.has(_.id)?!!o.get(_.id):d,P=l.get(_.id)??null,Z=e2(A,a),X=R.get(_.id);if(X&&X.project===_&&T(X.activeSessions,Y)&&T(X.archivedSessions,L)&&X.availableWorktrees===A&&X.rootBranch===P&&X.worktreeBranchesKey===Z&&X.isRepo===D&&X.buildGroupedSessions===u)return B+=1,I.set(_.id,X),X.section;if(O+=1,X){const ge=X.project!==_?"project":T(X.activeSessions,Y)?T(X.archivedSessions,L)?X.availableWorktrees!==A?"worktrees":X.rootBranch!==P?"branch":X.worktreeBranchesKey!==Z?"worktreeBranches":X.isRepo!==D?"repo":"builder":"archived":"sessions";Rs(`ui.sidebar.project_section.rebuilt_reason.${ge}`)}const se=$u([...Y,...L]),ce=u(se,_.normalizedPath,A,P,D),re={project:_,groups:ce};return I.set(_.id,{project:_,activeSessions:Y,archivedSessions:L,availableWorktrees:A,rootBranch:P,worktreeBranchesKey:Z,isRepo:D,buildGroupedSessions:u,section:re}),re});return w.current=I,B>0&&Rs("ui.sidebar.project_section.reused",B),O>0&&Rs("ui.sidebar.project_section.rebuilt",O),$},[e,n,r,i,o,d,u,l,a]),g=c.useMemo(()=>h,[h]),j=c.useMemo(()=>{const R=new WeakMap;if(!m)return R;const I=f.trim().toLowerCase(),B=I.startsWith("ses_"),O=$=>$.reduce((_,Y)=>_+(!B||Y.session.id.toLowerCase()===I?1:0)+O(Y.children),0),T=$=>{const _=p($.sessions,f),Y=O(_),L=!B&&Wo([y($)],f),A=eo($).flatMap(({scopeKey:P})=>x[P]??[]),D=B?0:A.filter(P=>Wo([P.name],f)).length;R.set($,{filteredNodes:_,matchedSessionCount:Y,folderNameMatchCount:D,groupMatches:L,hasMatch:L||Y>0||D>0})};return g.forEach($=>{$.groups.forEach(T)}),k.forEach(T),R},[m,g,k,p,f,y,x]),b=c.useMemo(()=>m?g.map(R=>({...R,groups:R.groups.filter(I=>j.get(I)?.hasMatch===!0)})).filter(R=>R.groups.length>0):g,[m,g,j]),S=m?b:g,C=c.useRef(new WeakMap),v=c.useMemo(()=>{const R=C.current;return S.map(I=>{const B=R.get(I);if(B&&B.query===f)return B.section;const O=I.groups.filter(D=>!D.isArchivedBucket),T=I.groups.filter(D=>D.isArchivedBucket),$=O.flatMap(D=>m?j.get(D)?.filteredNodes??[]:D.sessions),_=O.map(D=>({scopeKey:D.folderScopeKey??xt(D.directory??null),directory:D.directory??null})).filter(D=>!!D.scopeKey),Y=O.find(D=>D.isMain)??null,L={id:"flat",label:Y?.label??"",branch:Y?.branch??null,description:Y?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:Y?.directory??I.project.normalizedPath,folderScopeKey:Y?.folderScopeKey??I.project.normalizedPath,folderScopes:_,sessions:$};if(m){const D=O.map(P=>j.get(P)).filter(P=>!!P);j.set(L,{filteredNodes:$,matchedSessionCount:D.reduce((P,Z)=>P+Z.matchedSessionCount,0),folderNameMatchCount:D.reduce((P,Z)=>P+Z.folderNameMatchCount,0),groupMatches:D.some(P=>P.groupMatches),hasMatch:D.some(P=>P.hasMatch)})}const A={project:I.project,groups:[L,...T]};return R.set(I,{query:f,section:A}),A})},[j,m,f,S]),M=c.useMemo(()=>{if(!m)return 0;const R=(B,O)=>{const T=j.get(O);if(!T)return B;const $=T.folderNameMatchCount+(T.groupMatches?1:0);return B+T.matchedSessionCount+$},I=S.reduce((B,O)=>O.groups.reduce(R,B),0);return k.reduce(R,I)},[m,S,k,j]);return{projectSections:h,visibleProjectSections:g,groupSearchDataByGroup:j,searchableProjectSections:b,sectionsForRender:S,flatSectionsForRender:v,searchMatchCount:M}},n2=180,Gc=150,r2=2,o2=8,qc=[-1,1],zi=t=>`${t.directory}
|
|
880
|
-
${t.sessionId}`,i2=t=>t?.directory?.trim()||null,a2=({enabled:t=!0,currentSessionId:e,sortedSessions:n,recentSessions:r=[],prefetchSession:i})=>{const o=c.useRef(new Map),l=c.useRef([]),a=c.useRef(new Set),d=c.useRef(0),u=c.useMemo(()=>Wn(),[]),m=c.useCallback(()=>{d.current+=1,l.current=[],o.current.forEach(y=>window.clearTimeout(y)),o.current.clear()},[]),f=c.useCallback(()=>{if(!(!t||u))for(;a.current.size<r2&&l.current.length>0;){const y=l.current.shift();if(!y)break;if(y.generation!==d.current||nt.getState().currentSessionId===y.sessionId||ia(y.sessionId,y.directory).renderable)continue;const k=zi(y);a.current.add(k),i({directory:y.directory,sessionID:y.sessionId}).catch(()=>{}).finally(()=>{a.current.delete(k),f()})}},[t,u,i]),p=c.useCallback(y=>{const x=y?.id,k=i2(y);if(!t||u||!x||!k||x===e)return;const w={sessionId:x,directory:k,generation:d.current},h=zi(w);if(ia(x,k).renderable||a.current.has(h)||l.current.some(b=>zi(b)===h))return;const g=o.current.get(h);g!==void 0&&window.clearTimeout(g);const j=window.setTimeout(()=>{if(o.current.delete(h),w.generation!==d.current)return;const b=l.current;b.length>=o2&&b.shift(),b.push(w),f()},n2);o.current.set(h,j)},[e,t,u,f]);c.useEffect(()=>{m()},[m,e,t,u]),c.useEffect(()=>{if(!t||u||!e||n.length===0)return;const y=window.setTimeout(()=>{const x=n.findIndex(k=>k.id===e);if(!(x<0))for(const k of qc)p(n[x+k])},Gc);return()=>window.clearTimeout(y)},[e,t,u,p,n]),c.useEffect(()=>{if(!t||u||!e||r.length===0)return;const y=window.setTimeout(()=>{const x=r.findIndex(k=>k.id===e);if(!(x<0))for(const k of qc)p(r[x+k])},Gc);return()=>window.clearTimeout(y)},[e,t,u,r,p]),c.useEffect(()=>m,[m])},l2=t=>{const e=et.c(3),n=nt(c2);let r;return e[0]!==t||e[1]!==n?(r={...t,currentSessionId:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],a2(r),null};function c2(t){return t.currentSessionId}const d2=(t,e)=>{const n=new Set,r=new Set,i=(o,l)=>{n.add(o.session.id),(!l||e)&&r.add(o.session.id),o.children.forEach(a=>i(a,!0))};return t.forEach(o=>i(o,!1)),{active:n,unread:r}},hl=t=>{const e=et.c(15),{nodes:n,includeUnreadSubtasks:r,enabled:i}=t,o=i===void 0?!0:i;let l;e[0]!==o||e[1]!==n?(l=o?n:[],e[0]=o,e[1]=n,e[2]=l):l=e[2];let a;e[3]!==r||e[4]!==l?(a=d2(l,r),e[3]=r,e[4]=l,e[5]=a):a=e[5];const d=a;let u;e[6]!==o||e[7]!==d.active?(u=k=>{if(!o)return null;for(const w of d.active){const h=k.statusById.get(w)?.status.type;if(h==="busy"||h==="retry")return"active"}return null},e[6]=o,e[7]=d.active,e[8]=u):u=e[8];const m=ri(u);let f;e[9]!==o||e[10]!==d.unread?(f=k=>{if(!o)return null;for(const w of d.unread)if((k.index.session.unseenCount[w]??0)>0)return"unread";return null},e[9]=o,e[10]=d.unread,e[11]=f):f=e[11];const p=Za(f);let y;return e[12]!==o||e[13]!==d.active?(y=k=>{if(!o)return null;let w=null;for(const h of d.active){const g=k.bySession.get(h);if(g){if(g.permissions.length>0)return"permission";g.forms.length>0&&(w="form")}}return w},e[12]=o,e[13]=d.active,e[14]=y):y=e[14],el(y)??m??p};function Qf(t){const e=et.c(19),{state:n,className:r}=t,{t:i}=kt();if(n==="permission"||n==="form"){let u;e[0]!==n||e[1]!==i?(u=i(n==="permission"?"sessions.sidebar.session.status.permissionRequired":"sessions.sidebar.session.status.questionPending"),e[0]=n,e[1]=i,e[2]=u):u=e[2];const m=u,f=n==="permission"?"text-destructive":"text-status-info";let p;e[3]!==r||e[4]!==f?(p=Re("inline-flex shrink-0 items-center",f,r),e[3]=r,e[4]=f,e[5]=p):p=e[5];const y=n==="permission"?"shield":"question";let x;e[6]!==y?(x=s.jsx(F,{name:y,className:"h-3 w-3"}),e[6]=y,e[7]=x):x=e[7];let k;return e[8]!==m||e[9]!==p||e[10]!==x?(k=s.jsx("span",{className:p,"aria-label":m,title:m,children:x}),e[8]=m,e[9]=p,e[10]=x,e[11]=k):k=e[11],k}let o;e[12]!==n||e[13]!==i?(o=i(n==="active"?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[12]=n,e[13]=i,e[14]=o):o=e[14];const l=o,a=n==="active"?"running":"unread";let d;return e[15]!==r||e[16]!==l||e[17]!==a?(d=s.jsx(za,{state:a,label:l,className:r}),e[15]=r,e[16]=l,e[17]=a,e[18]=d):d=e[18],d}const u2=t=>{const e=et.c(5),{nodes:n,includeUnreadSubtasks:r}=t;let i;e[0]!==r||e[1]!==n?(i={nodes:n,includeUnreadSubtasks:r},e[0]=r,e[1]=n,e[2]=i):i=e[2];const o=hl(i);if(!o)return null;let l;return e[3]!==o?(l=s.jsx(Qf,{state:o}),e[3]=o,e[4]=l):l=e[4],l},f2=t=>{const e=et.c(83),{folder:n,displayName:r,sessions:i,subFolderItems:o,isCollapsed:l,collapsedActivityState:a,onToggle:d,onRename:u,onDelete:m,children:f,renderBody:p,mobileVariant:y,alwaysShowActions:x,isRenaming:k,renameDraft:w,onRenameDraftChange:h,onRenameSave:g,onRenameCancel:j,droppableRef:b,isDropTarget:S,onNewSession:C,depth:v,hideActions:M,archivedBucket:R}=t,I=a===void 0?null:a,B=p===void 0?!0:p,T=x===void 0?y===void 0?!1:y:x,$=k===void 0?!1:k,_=w===void 0?"":w,Y=S===void 0?!1:S,L=M===void 0?!1:M,A=R===void 0?!1:R,{t:D}=kt(),[P,Z]=c.useState(!1),[X,se]=c.useState(""),ce=c.useRef(null),re=$||P,ge=$?_:X;let ae;e[0]!==n.name?(ae=()=>{se(n.name),Z(!0)},e[0]=n.name,e[1]=ae):ae=e[1];const Ee=ae;let Se;e[2]!==ge||e[3]!==n.name||e[4]!==$||e[5]!==u||e[6]!==g?(Se=()=>{const Ae=ge.trim();Ae&&Ae!==n.name&&u(Ae),$&&g&&g(),Z(!1),se("")},e[2]=ge,e[3]=n.name,e[4]=$,e[5]=u,e[6]=g,e[7]=Se):Se=e[7];const me=Se;let ke;e[8]!==$||e[9]!==j?(ke=()=>{$&&j&&j(),Z(!1),se("")},e[8]=$,e[9]=j,e[10]=ke):ke=e[10];const V=ke;let J;e[11]!==$||e[12]!==h?(J=Ae=>{$&&h?h(Ae):se(Ae)},e[11]=$,e[12]=h,e[13]=J):J=e[13];const de=J;let we,G;e[14]!==$?(we=()=>{if(!$)return;const Ae=()=>{const Ne=ce.current;Ne&&(Ne.focus(),Ne.select())},Me=requestAnimationFrame(Ae),q=window.setTimeout(Ae,0);return()=>{cancelAnimationFrame(Me),window.clearTimeout(q)}},G=[$],e[14]=$,e[15]=we,e[16]=G):(we=e[15],G=e[16]),c.useEffect(we,G);const Ce=l?"folder":"folder-open",Te=Y&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let pe;e[17]!==Te?(pe=Re("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",Te),e[17]=Te,e[18]=pe):pe=e[18];let ne;e[19]!==d||e[20]!==re?(ne=re?void 0:Ae=>{Ae.currentTarget.blur(),d()},e[19]=d,e[20]=re,e[21]=ne):ne=e[21];const xe=re?void 0:"button",U=re?void 0:0;let z;e[22]!==d||e[23]!==re?(z=re?void 0:Ae=>{(Ae.key==="Enter"||Ae.key===" ")&&(Ae.preventDefault(),d())},e[22]=d,e[23]=re,e[24]=z):z=e[24];let Q;e[25]!==n.name||e[26]!==l||e[27]!==D?(Q=l?D("sessions.sidebar.folderItem.expandAria",{folderName:n.name}):D("sessions.sidebar.folderItem.collapseAria",{folderName:n.name}),e[25]=n.name,e[26]=l,e[27]=D,e[28]=Q):Q=e[28];const ue=A?T?"pr-7":"group-hover/folder:pr-7 group-focus-within/folder:pr-7":T?"pr-20":"group-hover/folder:pr-20 group-focus-within/folder:pr-20";let le;e[29]!==ue?(le=Re("min-w-0 flex items-center gap-1.5 pl-1.5 flex-1 transition-[padding]",ue),e[29]=ue,e[30]=le):le=e[30];const W=Y?"text-primary":"text-muted-foreground";let E;e[31]!==W?(E=Re("h-3.5 w-3.5 flex-shrink-0",W),e[31]=W,e[32]=E):E=e[32];let K;e[33]!==Ce||e[34]!==E?(K=s.jsx(F,{name:Ce,className:E}),e[33]=Ce,e[34]=E,e[35]=K):K=e[35];let te;e[36]!==I||e[37]!==r||e[38]!==ge||e[39]!==n.name||e[40]!==V||e[41]!==de||e[42]!==me||e[43]!==l||e[44]!==Y||e[45]!==re||e[46]!==i||e[47]!==D?(te=re?s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:m2,onMouseDown:h2,onSubmit:Ae=>{Ae.preventDefault(),me()},children:[s.jsx("input",{ref:ce,value:ge,onChange:Ae=>de(Ae.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:D("sessions.sidebar.folderItem.namePlaceholder"),onClick:p2,onPointerDown:g2,onMouseDown:x2,onKeyDown:Ae=>{if(Ae.key==="Escape"){Ae.stopPropagation(),V();return}(Ae.key===" "||Ae.key==="Enter")&&Ae.stopPropagation()}}),s.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:b2,onPointerDown:y2,onMouseDown:w2,children:s.jsx(F,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:Ae=>{Ae.stopPropagation(),V()},onPointerDown:v2,onMouseDown:S2,className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(F,{name:"close",className:"size-4"})})]}):s.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("span",{className:Re("typography-ui-label font-semibold truncate",Y?"text-primary":"text-muted-foreground"),children:r??n.name})}),s.jsx(St,{side:"right",sideOffset:8,className:"max-w-xs",children:r??n.name})]}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70 flex-shrink-0",children:["• ",i.length]}),I?s.jsx(Qf,{state:I}):null,l?s.jsx(F,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(F,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]}),e[36]=I,e[37]=r,e[38]=ge,e[39]=n.name,e[40]=V,e[41]=de,e[42]=me,e[43]=l,e[44]=Y,e[45]=re,e[46]=i,e[47]=D,e[48]=te):te=e[48];let oe;e[49]!==le||e[50]!==K||e[51]!==te?(oe=s.jsxs("div",{className:le,children:[K,te]}),e[49]=le,e[50]=K,e[51]=te,e[52]=oe):oe=e[52];let he;e[53]!==T||e[54]!==A||e[55]!==n.name||e[56]!==Ee||e[57]!==L||e[58]!==m||e[59]!==C||e[60]!==re||e[61]!==D?(he=!re&&(!L||A)?s.jsx("div",{className:Re("absolute right-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",T?"opacity-100":"opacity-0 pointer-events-none group-hover/folder:opacity-100 group-hover/folder:pointer-events-auto group-focus-within/folder:opacity-100 group-focus-within/folder:pointer-events-auto"),children:s.jsxs("div",{className:"flex items-center gap-0.5",children:[!A&&C?s.jsx("button",{type:"button",onClick:Ae=>{Ae.stopPropagation(),C()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":D("sessions.sidebar.folderItem.newSessionAria",{folderName:n.name}),title:D("sessions.sidebar.project.actions.newSession"),children:s.jsx(F,{name:"add",className:"h-3.5 w-3.5"})}):null,A?null:s.jsx("button",{type:"button",onClick:Ae=>{Ae.stopPropagation(),Ee()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":D("sessions.sidebar.folderItem.renameAria",{folderName:n.name}),children:s.jsx(F,{name:"pencil-ai",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:Ae=>{Ae.stopPropagation(),m()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":A?D("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:n.name}):D("sessions.sidebar.folderItem.deleteFolderAria",{folderName:n.name}),children:s.jsx(F,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})}):null,e[53]=T,e[54]=A,e[55]=n.name,e[56]=Ee,e[57]=L,e[58]=m,e[59]=C,e[60]=re,e[61]=D,e[62]=he):he=e[62];let ie;e[63]!==b||e[64]!==pe||e[65]!==ne||e[66]!==xe||e[67]!==U||e[68]!==z||e[69]!==Q||e[70]!==oe||e[71]!==he?(ie=s.jsxs("div",{ref:b,className:pe,onClick:ne,role:xe,tabIndex:U,onKeyDown:z,"aria-label":Q,children:[oe,he]}),e[63]=b,e[64]=pe,e[65]=ne,e[66]=xe,e[67]=U,e[68]=z,e[69]=Q,e[70]=oe,e[71]=he,e[72]=ie):ie=e[72];let Fe;e[73]!==f||e[74]!==l||e[75]!==B||e[76]!==i||e[77]!==o||e[78]!==D?(Fe=!l&&B?s.jsxs("div",{className:"pb-1",children:[o,i.length>0?f:o?null:s.jsx("div",{className:"py-1 pl-1.5 text-left typography-micro text-muted-foreground/70",children:D("sessions.sidebar.folderItem.emptyFolder")})]}):null,e[73]=f,e[74]=l,e[75]=B,e[76]=i,e[77]=o,e[78]=D,e[79]=Fe):Fe=e[79];let _e;return e[80]!==ie||e[81]!==Fe?(_e=s.jsxs("div",{className:"oc-folder",children:[ie,Fe]}),e[80]=ie,e[81]=Fe,e[82]=_e):_e=e[82],_e},Xf=c.memo(f2);function m2(t){return t.stopPropagation()}function h2(t){return t.stopPropagation()}function p2(t){return t.stopPropagation()}function g2(t){return t.stopPropagation()}function x2(t){return t.stopPropagation()}function b2(t){return t.stopPropagation()}function y2(t){return t.stopPropagation()}function w2(t){return t.stopPropagation()}function v2(t){return t.stopPropagation()}function S2(t){return t.stopPropagation()}function j2(t){const e=et.c(11);let n,r,i;e[0]!==t?({notifyOnSubtasks:r,activityNodes:n,...i}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i):(n=e[1],r=e[2],i=e[3]);const o=i.isCollapsed&&!i.archivedBucket;let l;e[4]!==n||e[5]!==r||e[6]!==o?(l={nodes:n,includeUnreadSubtasks:r,enabled:o},e[4]=n,e[5]=r,e[6]=o,e[7]=l):l=e[7];const a=hl(l);let d;return e[8]!==a||e[9]!==i?(d=s.jsx(Xf,{...i,collapsedActivityState:a}),e[8]=a,e[9]=i,e[10]=d):d=e[10],d}const to=t=>{const e=et.c(13),{directory:n,className:r}=t,{t:i}=kt();let o;e[0]!==n?(o=ch(n),e[0]=n,e[1]=o):o=e[1];const l=o;let a;if(e[2]!==l?(a=k=>k.sessions.get(l),e[2]=l,e[3]=a):a=e[3],!Ot(a)?.tabs.some(Gd))return null;let m;e[4]!==i?(m=i("sessions.sidebar.projectAction.active"),e[4]=i,e[5]=m):m=e[5];const f=m;let p;e[6]!==r?(p=Re("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=p):p=e[7];let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(F,{name:"pulse",className:"size-3.5"}),e[8]=y):y=e[8];let x;return e[9]!==l||e[10]!==f||e[11]!==p?(x=s.jsx("span",{className:p,role:"img","aria-label":f,title:f,"data-action-directory":l,children:y}),e[9]=l,e[10]=f,e[11]=p,e[12]=x):x=e[12],x},k2=t=>{const e=et.c(19),{sessionId:n,dragKey:r,ownerKey:i,sessionDirectory:o,sessionTitle:l,archivedBucket:a,children:d}=t,u=i===void 0?null:i,m=a===void 0?!1:a,f=`session-drag:${r??n}`;let p;e[0]!==m||e[1]!==u||e[2]!==o||e[3]!==n||e[4]!==l?(p={type:"session",sessionId:n,ownerKey:u,sessionDirectory:o,sessionTitle:l,archivedBucket:m},e[0]=m,e[1]=u,e[2]=o,e[3]=n,e[4]=l,e[5]=p):p=e[5];let y;e[6]!==m||e[7]!==f||e[8]!==p?(y={id:f,disabled:m,data:p},e[6]=m,e[7]=f,e[8]=p,e[9]=y):y=e[9];const{attributes:x,listeners:k,setNodeRef:w,isDragging:h}=ab(y);let g;e[10]!==k?(g=C=>{C.stopPropagation(),k?.onPointerDown&&k.onPointerDown(C)},e[10]=k,e[11]=g):g=e[11];const j=g,b=`touch-pan-y select-none${h?" opacity-30":""}`;let S;return e[12]!==x||e[13]!==d||e[14]!==j||e[15]!==k||e[16]!==w||e[17]!==b?(S=s.jsx("div",{ref:w,...x,...k,onPointerDown:j,className:b,children:d}),e[12]=x,e[13]=d,e[14]=j,e[15]=k,e[16]=w,e[17]=b,e[18]=S):S=e[18],S},Jf=t=>{const e=et.c(20),{folderId:n,scopeKey:r,ownerKey:i,disabled:o,children:l}=t,a=o===void 0?!1:o;let d;e[0]!==n||e[1]!==r?(d=Zn(r,n),e[0]=n,e[1]=r,e[2]=d):d=e[2];const u=`folder-drop:${d}`;let m;e[3]!==a||e[4]!==r?(m=a||ml(r),e[3]=a,e[4]=r,e[5]=m):m=e[5];let f;e[6]!==n||e[7]!==i||e[8]!==r?(f={type:"folder",folderId:n,scopeKey:r,ownerKey:i},e[6]=n,e[7]=i,e[8]=r,e[9]=f):f=e[9];let p;e[10]!==u||e[11]!==m||e[12]!==f?(p={id:u,disabled:m,data:f},e[10]=u,e[11]=m,e[12]=f,e[13]=p):p=e[13];const{setNodeRef:y,isOver:x}=lb(p);let k;e[14]!==l||e[15]!==x||e[16]!==y?(k=l(y,x),e[14]=l,e[15]=x,e[16]=y,e[17]=k):k=e[17];let w;return e[18]!==k?(w=s.jsx(s.Fragment,{children:k}),e[18]=k,e[19]=w):w=e[19],w},C2=t=>{const e=et.c(22),{scopeKey:n,ownerKey:r,hasFolders:i,onSessionDroppedOnFolder:o,children:l}=t,a=r===void 0?null:r;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={activationConstraint:{distance:8}},e[0]=d):d=e[0];let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={activationConstraint:{delay:200,tolerance:6}},e[1]=u):u=e[1];const m=di(Tn(fi,d),Tn(ui,u)),[f,p]=c.useState(null),[y,x]=c.useState("Session"),[k,w]=c.useState(null),[h,g]=c.useState(null);if(!n){let I;return e[2]!==l?(I=s.jsx(s.Fragment,{children:l}),e[2]=l,e[3]=I):I=e[3],I}let j;e[4]!==o||e[5]!==a?(j=I=>{p(null),w(null),g(null);const{active:B,over:O}=I;if(!O)return;const T=B.data.current,$=O.data.current;T?.type!=="session"||!T.sessionId||!T.ownerKey||T.archivedBucket===!0||a&&T.ownerKey!==a||$?.type!=="folder"||!$.folderId||!$.scopeKey||!$.ownerKey||ml($.scopeKey)||$.ownerKey!==T.ownerKey||o(T.sessionId,{folderId:$.folderId,scopeKey:$.scopeKey,ownerKey:$.ownerKey},T.ownerKey)},e[4]=o,e[5]=a,e[6]=j):j=e[6];const b=j;let S,C;e[7]===Symbol.for("react.memo_cache_sentinel")?(S=I=>{const B=I.active.data.current;if(B?.type==="session"&&B.sessionId){p(B.sessionId),x(B.sessionTitle??"Session");const O=I.active.rect.current.initial?.width,T=I.active.rect.current.initial?.height;w(O??null),g(T??null)}},C=()=>{p(null),w(null),g(null)},e[7]=S,e[8]=C):(S=e[7],C=e[8]);let v;e[9]!==h||e[10]!==f||e[11]!==y||e[12]!==k||e[13]!==i?(v=f&&i?s.jsxs("div",{style:{width:k?`${k}px`:"auto",height:h?`${h}px`:"auto"},className:"flex items-center rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2.5 py-1 shadow-none pointer-events-none",children:[s.jsx(F,{name:"sticky-note",className:"h-4 w-4 text-muted-foreground mr-2 flex-shrink-0"}),s.jsx("div",{className:"min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground",children:y})]}):null,e[9]=h,e[10]=f,e[11]=y,e[12]=k,e[13]=i,e[14]=v):v=e[14];let M;e[15]!==v?(M=s.jsx(cb,{children:v}),e[15]=v,e[16]=M):M=e[16];let R;return e[17]!==l||e[18]!==b||e[19]!==m||e[20]!==M?(R=s.jsxs(mi,{sensors:m,collisionDetection:hi,onDragStart:S,onDragCancel:C,onDragEnd:b,children:[l,M]}),e[17]=l,e[18]=b,e[19]=m,e[20]=M,e[21]=R):R=e[21],R},Zf=c.createContext(null),N2=({entries:t,descendantIds:e,sessionsById:n,children:r})=>{const i=c.useRef(t),o=c.useRef(e),l=c.useRef(n);i.current=t,o.current=e,l.current=n;const a=c.useRef(null);return a.current===null&&(a.current={getEntries:()=>i.current,getDescendantIds:()=>o.current,getSessionsById:()=>l.current}),s.jsx(Zf.Provider,{value:a.current,children:r})},em=()=>c.useContext(Zf),A2=(t,e,n)=>{const r=t[0];if(!r)return null;const i=n??r.scopeKey,o=[],l=new Set;for(const a of t){if(i&&a.scopeKey!==i)continue;const d=a.descendantRange,u=d?[a.id,...e.slice(d[0],d[1])]:[a.id];for(const m of u)l.has(m)||(l.add(m),o.push(m))}return o.length>0?{ids:o,scopeKey:i}:null},tm=(t,e)=>{if(t.size===0)return!1;for(const n of t)if(!e.get(n)?.time?.archived)return!1;return!0},Yc=(t,e,n)=>{if(!e)return;const r=i=>{let o=i.session.id===e;for(const l of i.children)o=r(l)||o;return o&&n.add(i.session.id),o};for(const i of t)r(i)},Pr=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const n of t.children)if(Pr(n,e))return!0;return!1},P2=({isSubtaskSession:t,archivedBucket:e,isVSCode:n,sessionDirectory:r})=>!t&&!e&&!n&&!Ng(r),D2=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:n})=>!t||e||n,I2=(t,e,n)=>{const r=new Map,i=o=>{const l=Ps(o.session)??xt(o.worktree?.path)??n;if(l){const a=r.get(l)??[];a.push(o.session.id),r.set(l,a)}if(!(o===t&&e))for(const a of o.children)i(a)};return i(t),[...r].map(([o,l])=>({directory:o,sessionIDs:l}))},Da=(t,e)=>{const n=new Set(t);return t.map(r=>e.get(r)).filter(r=>{if(!r)return!1;const i=new Set;let o=r.session.parentID??null;for(;o&&!i.has(o);){if(n.has(o)&&e.has(o))return!1;i.add(o),o=e.get(o)?.session?.parentID??null}return!0})},sm=t=>{const e=new Map(t.map(l=>[l.id,l])),n=new Map;for(const l of t){if(!l.parentId||!e.has(l.parentId))continue;const a=n.get(l.parentId)??[];a.push(l),n.set(l.parentId,a)}const r=new Set,i=[],o=l=>{if(r.has(l.id))return;i.push(l);const a=[l.id];for(;a.length>0;){const d=a.pop();if(!(!d||r.has(d))){r.add(d);for(const u of n.get(d)??[])a.push(u.id)}}};return t.forEach(l=>{(!l.parentId||!e.has(l.parentId))&&o(l)}),t.forEach(o),i},nm=(t,e)=>{const n=e.searchQuery.trim().toLowerCase().startsWith("ses_"),r=new Map(t.map(u=>[u.id,u])),i=new Map,o=new Set;for(const u of t){if(u.parentId&&!r.has(u.parentId)){o.add(u.id);continue}if(u.parentId){const p=i.get(u.parentId)??[];p.push(u.id),i.set(u.parentId,p)}const m=new Set;let f=u.id;for(;f;){if(m.has(f)){o.add(u.id);break}m.add(f),f=r.get(f)?.parentId}}const l=new Set,a=new Set,d=u=>{if(l.has(u))return!0;if(a.has(u))return!1;const m=r.get(u);if(!m)return!1;a.add(u);let f=o.has(u);return!f&&e.archivedBucket&&m.nodeCount===0?f=(i.get(u)??[]).some(d):(!f&&!e.searchQuery&&(f=!0),!f&&(m.nodeCount>0||!n&&Wo([m.name],e.searchQuery))&&(f=!0),f||(f=(i.get(u)??[]).some(d))),a.delete(u),f&&l.add(u),f};return t.forEach(u=>d(u.id)),new Set(t.filter(u=>l.has(u.id)).map(u=>u.id))},Qc=new WeakMap;let Xc=1;const T2=t=>{const e=Qc.get(t);if(e!==void 0)return e;const n=Xc;return Xc+=1,Qc.set(t,n),n},Qo=t=>t.children.length===0?"":t.children.map(n=>{const r=T2(n.session);return n.children.length===0?`${n.session.id}@${r}`:`${n.session.id}@${r}:${Qo(n)}`}).join("|"),rm=(t,e,n,r,i,o)=>{const l=Qt(),a=(d,u)=>{if(d.session.id!==u.session.id||d.children.length!==u.children.length)return!0;const m=d.session.directory??i,f=u.session.directory??o,p=$l(l,m??"",d.session.id),y=$l(l,f??"",u.session.id);return(p?n.has(p):!1)!==(y?r.has(y):!1)?!0:d.children.some((x,k)=>a(x,u.children[k]))};return a(t,e)},E2=t=>t.actionsAlwaysVisible?"":`transition-opacity duration-150 ${t.menuOpen?"opacity-0":t.hideOnHoverClass}`,R2=(t,e)=>t?t.branchLabel??null:e??null,M2=(t,e)=>{if(e)return null;const n=t?.branch?.trim(),r=xt(t?.path??null);return n&&r?si(r,n):null},Xo=(t,e,n,r)=>{if(!e)return null;const i=r?"archived":"active";let o=null;const l=a=>{if(`${n}:${i}:${a.session.id}`===e)return o=a.session.id,!0;for(const u of a.children)if(l(u))return!0;return!1};return t.forEach(a=>l(a)),o},O2=t=>{const e=et.c(29),{menuInstanceKey:n,contextMenuInstanceKey:r,openSidebarMenuKey:i,setOpenSidebarMenuKey:o,hasDeferredCloseWork:l,onCloseComplete:a}=t,[d,u]=c.useState(!1),[m,f]=c.useState(!1),p=i===n&&!m,y=r?i===r&&!m:d;let x;e[0]!==l||e[1]!==i||e[2]!==o?(x=R=>{if(i===R){if(l()){f(!0);return}o(null)}},e[0]=l,e[1]=i,e[2]=o,e[3]=x):x=e[3];const k=x;let w;e[4]!==n||e[5]!==k||e[6]!==o?(w=R=>{if(R){u(!1),f(!1),o(n);return}k(n)},e[4]=n,e[5]=k,e[6]=o,e[7]=w):w=e[7];const h=w;let g;e[8]!==r||e[9]!==k||e[10]!==o?(g=R=>{if(!r){u(R);return}if(R){f(!1),o(r);return}k(r)},e[8]=r,e[9]=k,e[10]=o,e[11]=g):g=e[11];const j=g;let b;e[12]!==r||e[13]!==n||e[14]!==a||e[15]!==i||e[16]!==o?(b=R=>{R||(a(),f(!1),(i===n||i===r)&&o(null))},e[12]=r,e[13]=n,e[14]=a,e[15]=i,e[16]=o,e[17]=b):b=e[17];const S=b;let C;e[18]!==p||e[19]!==n||e[20]!==o?(C=()=>{f(!1),o(p?null:n)},e[18]=p,e[19]=n,e[20]=o,e[21]=C):C=e[21];const v=C;let M;return e[22]!==j||e[23]!==h||e[24]!==S||e[25]!==y||e[26]!==p||e[27]!==v?(M={isMenuOpen:p,isContextMenuOpen:y,handleMenuOpenChange:h,handleContextMenuOpenChange:j,handleMenuOpenChangeComplete:S,toggleMenu:v},e[22]=j,e[23]=h,e[24]=S,e[25]=y,e[26]=p,e[27]=v,e[28]=M):M=e[28],M},B2=t=>{const e=et.c(10),{project:n,fallback:r}=t,{currentTheme:i}=Kn(),o=n.iconImage??null;let l;e[0]!==n.id||e[1]!==o?(l={id:n.id,iconImage:o},e[0]=n.id,e[1]=o,e[2]=l):l=e[2];let a;e[3]!==i.colors.surface.foreground||e[4]!==i.metadata.variant?(a={themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},e[3]=i.colors.surface.foreground,e[4]=i.metadata.variant,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==l||e[8]!==a?(d=s.jsx(ai,{project:l,options:a,className:"h-full w-full object-contain",fallback:r}),e[6]=r,e[7]=l,e[8]=a,e[9]=d):d=e[9],d},F2=t=>{const e=et.c(13),{project:n}=t,r=n?.icon?oi[n.icon]:null,i=n?.color?ii[n.color]??null:null;let o;e[0]!==i||e[1]!==r?(o=r?s.jsx(F,{name:r,className:Re("h-3.5 w-3.5",!i&&"text-muted-foreground/75"),style:i?{color:i}:void 0}):s.jsx(F,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/75",style:i?{color:i}:void 0}),e[0]=i,e[1]=r,e[2]=o):o=e[2];const l=o;if(!n?.iconImage){let m;return e[3]!==l?(m=s.jsx("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:l}),e[3]=l,e[4]=m):m=e[4],m}let a;e[5]!==n.iconBackground?(a=n.iconBackground?{backgroundColor:n.iconBackground}:void 0,e[5]=n.iconBackground,e[6]=a):a=e[6];let d;e[7]!==l||e[8]!==n?(d=s.jsx(B2,{project:n,fallback:l}),e[7]=l,e[8]=n,e[9]=d):d=e[9];let u;return e[10]!==a||e[11]!==d?(u=s.jsx("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:a,children:d}),e[10]=a,e[11]=d,e[12]=u):u=e[12],u},Jc=t=>{const e=et.c(43),{compact:n,project:r,projectLabel:i,title:o,titleClassName:l,branchLabel:a,statusDot:d,pinnedMarker:u,timeSlot:m,directoryIndicator:f,prBadge:p,zombieIndicator:y,badges:x,metaPaddingClass:k,hideMetaOnHoverClass:w}=t,h=n===void 0?!1:n,g=!h&&(!!a||!!p||!!y||!!x);let j;e[0]!==w||e[1]!==k?(j=Re("ml-auto flex flex-shrink-0 items-center gap-1 transition-opacity",k,w),e[0]=w,e[1]=k,e[2]=j):j=e[2];const b=h?x:null;let S;e[3]!==m?(S=s.jsx("span",{className:"typography-micro leading-none text-muted-foreground/50 tabular-nums",children:m}),e[3]=m,e[4]=S):S=e[4];let C;e[5]!==f||e[6]!==u||e[7]!==d||e[8]!==j||e[9]!==b||e[10]!==S?(C=s.jsxs("span",{className:j,children:[b,f,u,d,S]}),e[5]=f,e[6]=u,e[7]=d,e[8]=j,e[9]=b,e[10]=S,e[11]=C):C=e[11];const v=C;if(h){let _;e[12]!==l?(_=Re("min-w-0 flex-1 truncate typography-ui-label font-normal",l),e[12]=l,e[13]=_):_=e[13];let Y;e[14]!==_||e[15]!==o?(Y=s.jsx("div",{className:_,children:o}),e[14]=_,e[15]=o,e[16]=Y):Y=e[16];let L;return e[17]!==v||e[18]!==Y?(L=s.jsxs("div",{className:"relative flex w-full min-w-0 items-center gap-1",children:[Y,v]}),e[17]=v,e[18]=Y,e[19]=L):L=e[19],L}let M;e[20]!==r?(M=s.jsx(F2,{project:r}),e[20]=r,e[21]=M):M=e[21];let R;e[22]!==i?(R=i?s.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/85",children:i}):null,e[22]=i,e[23]=R):R=e[23];let I;e[24]!==v||e[25]!==M||e[26]!==R?(I=s.jsxs("div",{className:"relative flex h-5 w-full min-w-0 items-center gap-1",children:[M,R,v]}),e[24]=v,e[25]=M,e[26]=R,e[27]=I):I=e[27];let B;e[28]!==l?(B=Re("w-full min-w-0 truncate typography-ui-label font-normal",l),e[28]=l,e[29]=B):B=e[29];let O;e[30]!==B||e[31]!==o?(O=s.jsx("div",{className:B,children:o}),e[30]=B,e[31]=o,e[32]=O):O=e[32];let T;e[33]!==x||e[34]!==a||e[35]!==g||e[36]!==p||e[37]!==y?(T=g?s.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1",children:[a?s.jsxs(s.Fragment,{children:[s.jsx(F,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40"}),s.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:a})]}):null,s.jsxs("span",{className:"ml-auto flex flex-shrink-0 items-center gap-1",children:[y??p,x]})]}):null,e[33]=x,e[34]=a,e[35]=g,e[36]=p,e[37]=y,e[38]=T):T=e[38];let $;return e[39]!==O||e[40]!==T||e[41]!==I?($=s.jsxs("div",{className:"flex w-full min-w-0 flex-col gap-px",children:[I,O,T]}),e[39]=O,e[40]=T,e[41]=I,e[42]=$):$=e[42],$};let Ia=!1;const Ta=new Set;let Zc=!1;function _2(){for(const t of Ta)t()}function pl(t){Ia!==t&&(Ia=t,_2())}function L2(t){t.key==="Shift"&&pl(!0)}function $2(t){t.key==="Shift"&&pl(!1)}function z2(){pl(!1)}function W2(){Zc||typeof window>"u"||(Zc=!0,window.addEventListener("keydown",L2),window.addEventListener("keyup",$2),window.addEventListener("blur",z2))}function K2(t){return W2(),Ta.add(t),()=>{Ta.delete(t)}}function V2(){return Ia}function U2(){return!1}function H2(){return ct.useSyncExternalStore(K2,V2,U2)}async function G2(t,e,n){const r=await Promise.all(t.map(async i=>{n();const o=i.directory??i.session.directory,l=await fn.getSession(i.session.id,o);if(n(),!nu(e,zo(l,i.projectDirectory??l.directory)))throw new Error("Fusion source membership changed");const a=await fn.getSessionMessages(i.session.id,{limit:50},o);n();let d="";for(const u of a.items)if(u.info.role==="assistant"){d=Ag(u.parts).trim();break}return{source:{...i,session:l},text:d}}));return n(),r.filter(i=>i.text.length>0)}const om=t=>{const e=et.c(36),{value:n,onChange:r,className:i,disabled:o,id:l,portalToBody:a}=t,{t:d}=kt(),u=Ut(q2),m=Ut(Y2),f=Ut(Q2);let p;e[0]!==u?(p=u(),e[0]=u,e[1]=p):p=e[1];const y=p;let x;e[2]!==y?(x=y.filter(X2),e[2]=y,e[3]=x):x=e[3];const k=x;let w,h;e[4]!==y.length||e[5]!==m?(w=()=>{y.length===0&&m()},h=[y.length,m],e[4]=y.length,e[5]=m,e[6]=w,e[7]=h):(w=e[6],h=e[7]),c.useEffect(w,h);let g,j;e[8]!==f||e[9]!==o||e[10]!==r||e[11]!==k||e[12]!==n?(g=()=>{if(o)return;const O=n.trim();if(O.length>0&&k.some(_=>_.name===O))return;const T=typeof f=="string"&&f.trim().length>0?f.trim():null;if(T&&k.some(_=>_.name===T)){r(T);return}const $=k[0]?.name;$&&r($)},j=[f,o,r,k,n],e[8]=f,e[9]=o,e[10]=r,e[11]=k,e[12]=n,e[13]=g,e[14]=j):(g=e[13],j=e[14]),c.useEffect(g,j);const b=n.trim().length>0?n:void 0;let S;e[15]!==i?(S=Re("max-w-full",i),e[15]=i,e[16]=S):S=e[16];let C;e[17]!==d?(C=d("multirun.agentSelector.placeholder"),e[17]=d,e[18]=C):C=e[18];let v;e[19]!==C?(v=s.jsx(Cs,{placeholder:C}),e[19]=C,e[20]=v):v=e[20];let M;e[21]!==l||e[22]!==S||e[23]!==v?(M=s.jsx(Os,{id:l,size:"lg",className:S,children:v}),e[21]=l,e[22]=S,e[23]=v,e[24]=M):M=e[24];let R;e[25]!==k?(R=k.length>0&&s.jsx(aa,{children:k.map(J2)}),e[25]=k,e[26]=R):R=e[26];let I;e[27]!==a||e[28]!==R?(I=s.jsx(Bs,{fitContent:!0,portalToBody:a,children:R}),e[27]=a,e[28]=R,e[29]=I):I=e[29];let B;return e[30]!==o||e[31]!==r||e[32]!==b||e[33]!==M||e[34]!==I?(B=s.jsxs(Ms,{value:b,onValueChange:r,disabled:o,children:[M,I]}),e[30]=o,e[31]=r,e[32]=b,e[33]=M,e[34]=I,e[35]=B):B=e[35],B};function q2(t){return t.getVisibleAgents}function Y2(t){return t.loadAgents}function Q2(t){return t.currentAgentName}function X2(t){return zu(t.mode)}function J2(t){return s.jsx(rs,{value:t.name,className:"w-auto whitespace-nowrap",children:Pg(t)},t.name)}const Z2="h-7",Yr=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,ek=t=>{const e=et.c(12),{model:n,instanceIndex:r,totalSameModel:i,onRemove:o}=t,l=n.displayName||`${n.providerID}/${n.modelID}`,a=i>1?`${l} (${r})`:l;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=Re("flex items-center gap-1.5 px-2 rounded-md bg-interactive-selection/20 border border-border/30",Z2),e[0]=d):d=e[0];let u;e[1]!==n.providerID?(u=s.jsx(la,{providerId:n.providerID,className:"h-3.5 w-3.5"}),e[1]=n.providerID,e[2]=u):u=e[2];let m;e[3]!==a?(m=s.jsx("span",{className:"typography-meta font-medium truncate max-w-[140px]",children:a}),e[3]=a,e[4]=m):m=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(F,{name:"close",className:"h-3.5 w-3.5"}),e[5]=f):f=e[5];let p;e[6]!==o?(p=s.jsx("button",{type:"button",onClick:o,className:"text-muted-foreground hover:text-foreground ml-0.5",children:f}),e[6]=o,e[7]=p):p=e[7];let y;return e[8]!==u||e[9]!==m||e[10]!==p?(y=s.jsxs("div",{className:d,children:[u,m,p]}),e[8]=u,e[9]=m,e[10]=p,e[11]=y):y=e[11],y},im=t=>{const e=et.c(119),{selectedModels:n,onAdd:r,onRemove:i,onUpdate:o,minModels:l,addButtonLabel:a,showChips:d,maxModels:u,addButtonClassName:m,dropdownSide:f,dropdownClassName:p,containerClassName:y,triggerIcon:x}=t,k=d===void 0?!0:d,w=f===void 0?"top":f,{t:h}=kt(),g=Ut(tk),j=Pe(sk),b=Pe(nk),{favoriteModelsList:S,recentModelsList:C}=Dg(),v=Pe(rk),M=Pe(ok),[R,I]=c.useState(!1),[B,O]=c.useState(""),[T,$]=c.useState(null),_=c.useRef(null),Y=c.useRef(null),L=u===1,A=u===void 0||n.length<u||L;let D;if(e[0]!==n){D=new Map;for(const je of n){const We=`${je.providerID}:${je.modelID}`;D.set(We,(D.get(We)||0)+1)}e[0]=n,e[1]=D}else D=e[1];const P=D;let Z;e[2]!==n?(Z=je=>n.filter(tt=>tt.providerID===je.providerID&&tt.modelID===je.modelID).findIndex(tt=>tt.instanceId===je.instanceId)+1,e[2]=n,e[3]=Z):Z=e[3];const X=Z;let se,ce;e[4]!==w||e[5]!==R?(se=()=>{if(!R||!Y.current)return;const je=Y.current.getBoundingClientRect();if(w==="bottom"){const ft=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-je.bottom-16-112;$(Math.max(160,Math.min(320,ft)));return}let We=Y.current.parentElement;for(;We&&!We.matches('[role="dialog"], [data-scroll-shadow-scroller]');){const rt=getComputedStyle(We);if(rt.overflow==="auto"||rt.overflow==="hidden"||rt.overflowY==="auto"||rt.overflowY==="hidden")break;We=We.parentElement}const tt=We?We.getBoundingClientRect().top:0,it=je.top-tt-16;$(Math.max(150,Math.min(300,it)))},ce=[w,R],e[4]=w,e[5]=R,e[6]=se,e[7]=ce):(se=e[6],ce=e[7]),c.useEffect(se,ce);let re,ge;e[8]!==A||e[9]!==R?(re=()=>{!A&&R&&(I(!1),O(""))},ge=[A,R],e[8]=A,e[9]=R,e[10]=re,e[11]=ge):(re=e[10],ge=e[11]),c.useEffect(re,ge);let ae,Ee;e[12]!==R?(ae=()=>{if(!R)return;const je=We=>{_.current&&!_.current.contains(We.target)&&(I(!1),O(""))};return document.addEventListener("mousedown",je),()=>document.removeEventListener("mousedown",je)},Ee=[R],e[12]=R,e[13]=ae,e[14]=Ee):(ae=e[13],Ee=e[14]),c.useEffect(ae,Ee);let Se;e[15]!==L||e[16]!==r||e[17]!==o||e[18]!==n.length?(Se=je=>{const We={providerID:je.providerID,modelID:je.modelID,displayName:je.model.name||je.modelID,instanceId:Yr()};L&&n.length>0&&o?o(0,We):r(We),L&&(I(!1),O(""))},e[15]=L,e[16]=r,e[17]=o,e[18]=n.length,e[19]=Se):Se=e[19];const me=Se;let ke;e[20]!==h?(ke=h("multirun.modelMultiSelect.search.placeholder"),e[20]=h,e[21]=ke):ke=e[21];let V;e[22]!==h?(V=h("multirun.modelMultiSelect.search.noResults"),e[22]=h,e[23]=V):V=e[23];let J;e[24]!==h?(J=h("multirun.modelMultiSelect.sections.favorites"),e[24]=h,e[25]=J):J=e[25];let de;e[26]!==h?(de=h("multirun.modelMultiSelect.sections.recent"),e[26]=h,e[27]=de):de=e[27];let we;e[28]!==h?(we=h("multirun.modelMultiSelect.keyboard.hint"),e[28]=h,e[29]=we):we=e[29];let G;e[30]!==h?(G=h("settings.agents.modelSelector.actions.favorite"),e[30]=h,e[31]=G):G=e[31];let Ce;e[32]!==h?(Ce=h("settings.agents.modelSelector.actions.unfavorite"),e[32]=h,e[33]=Ce):Ce=e[33];let Te;e[34]!==h?(Te=h("chat.modelControls.capabilities"),e[34]=h,e[35]=Te):Te=e[35];let pe;e[36]!==h?(pe=h("chat.modelControls.capability.toolCalling"),e[36]=h,e[37]=pe):pe=e[37];let ne;e[38]!==h?(ne=h("chat.modelControls.capability.reasoning"),e[38]=h,e[39]=ne):ne=e[39];let xe;e[40]!==h?(xe=h("chat.modelControls.input"),e[40]=h,e[41]=xe):xe=e[41];let U;e[42]!==h?(U=h("chat.modelControls.output"),e[42]=h,e[43]=U):U=e[43];let z;e[44]!==h?(z=h("chat.modelControls.costPerMillion"),e[44]=h,e[45]=z):z=e[45];let Q;e[46]!==ke||e[47]!==V||e[48]!==J||e[49]!==de||e[50]!==we||e[51]!==G||e[52]!==Ce||e[53]!==Te||e[54]!==pe||e[55]!==ne||e[56]!==xe||e[57]!==U||e[58]!==z?(Q={searchPlaceholder:ke,noResults:V,favorites:J,recent:de,keyboardHint:we,favorite:G,unfavorite:Ce,capabilities:Te,capabilityToolCalling:pe,capabilityReasoning:ne,input:xe,output:U,costPerMillion:z},e[46]=ke,e[47]=V,e[48]=J,e[49]=de,e[50]=we,e[51]=G,e[52]=Ce,e[53]=Te,e[54]=pe,e[55]=ne,e[56]=xe,e[57]=U,e[58]=z,e[59]=Q):Q=e[59];const ue=Q;let le;e[60]!==y?(le=Re("relative",y),e[60]=y,e[61]=le):le=e[61];const W=R?"":void 0;let E;e[62]!==m?(E=Re(Wu({size:"default"}),"w-fit",m),e[62]=m,e[63]=E):E=e[63];const K=!A;let te;e[64]!==R?(te=()=>{I(!R)},e[64]=R,e[65]=te):te=e[65];let oe;e[66]!==x?(oe=x??s.jsx(F,{name:"add",className:"h-3.5 w-3.5 mr-1"}),e[66]=x,e[67]=oe):oe=e[67];let he;e[68]!==a||e[69]!==h?(he=a??h("multirun.modelMultiSelect.actions.addModel"),e[68]=a,e[69]=h,e[70]=he):he=e[70];let ie;e[71]!==W||e[72]!==E||e[73]!==K||e[74]!==te||e[75]!==oe||e[76]!==he?(ie=s.jsxs("button",{ref:Y,type:"button","data-popup-open":W,className:E,disabled:K,onClick:te,children:[oe,he]}),e[71]=W,e[72]=E,e[73]=K,e[74]=te,e[75]=oe,e[76]=he,e[77]=ie):ie=e[77];let Fe;e[78]!==T||e[79]!==A||e[80]!==p||e[81]!==w||e[82]!==S||e[83]!==me||e[84]!==v||e[85]!==b||e[86]!==R||e[87]!==ue||e[88]!==P||e[89]!==M||e[90]!==g||e[91]!==C||e[92]!==B||e[93]!==j?(Fe=R?s.jsx("div",{className:Re("absolute left-0 z-50 w-[min(420px,calc(100vw-2rem))] max-w-[calc(100vw-2rem)] flex flex-col overflow-hidden rounded-xl border border-border/50 shadow-lg",w==="top"?"bottom-full mb-1":"top-full mt-1",p),style:{background:"linear-gradient(var(--surface-elevated),var(--surface-elevated)),linear-gradient(var(--surface-background),var(--surface-background))"},children:s.jsx(Ig,{providers:g,providerOrder:M,favoriteModels:S,recentModels:C,hiddenModels:v,searchQuery:B,onSearchQueryChange:O,onSelect:me,labels:ue,selectionCount:je=>P.get(`${je.providerID}:${je.modelID}`)||0,disabled:!A,maxHeightClassName:"flex-1",maxHeightStyle:{maxHeight:T?`${T}px`:"300px"},stickyHeaders:!0,tooltipsEnabled:R,isFavorite:je=>b(je.providerID,je.modelID),onToggleFavorite:je=>j(je.providerID,je.modelID),onEscape:()=>{I(!1),O("")}})}):null,e[78]=T,e[79]=A,e[80]=p,e[81]=w,e[82]=S,e[83]=me,e[84]=v,e[85]=b,e[86]=R,e[87]=ue,e[88]=P,e[89]=M,e[90]=g,e[91]=C,e[92]=B,e[93]=j,e[94]=Fe):Fe=e[94];let _e;e[95]!==le||e[96]!==ie||e[97]!==Fe?(_e=s.jsxs("div",{className:le,ref:_,children:[ie,Fe]}),e[95]=le,e[96]=ie,e[97]=Fe,e[98]=_e):_e=e[98];let Ae;e[99]!==X||e[100]!==P||e[101]!==i||e[102]!==o||e[103]!==g||e[104]!==n||e[105]!==k||e[106]!==h?(Ae=k&&n.length>0&&s.jsx("div",{className:"flex flex-col gap-2 w-full",children:n.map((je,We)=>{const tt=`${je.providerID}:${je.modelID}`,it=P.get(tt)||1,rt=X(je),ft=g.find(be=>be.id===je.providerID)?.models?.find(be=>be.id===je.modelID),st=tl(ft?.variants),Ct=st.length>0,ht=je.variant??"__default__";return s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(ek,{model:je,instanceIndex:rt,totalSameModel:it,onRemove:()=>i(We)}),Ct&&s.jsxs(Ms,{value:ht,onValueChange:be=>{if(!o)return;o(We,{...je,variant:be==="__default__"?void 0:be})},children:[s.jsxs(Os,{size:"sm",className:"gap-1.5",children:[s.jsx(F,{name:"brain-ai-3",className:Re("h-3.5 w-3.5 flex-shrink-0",ht==="__default__"?"text-muted-foreground":"text-[color:var(--status-info)]")}),s.jsx(Cs,{placeholder:h("multirun.modelMultiSelect.variant.placeholder"),children:be=>be==="__default__"?h("multirun.modelMultiSelect.variant.default"):be})]}),s.jsxs(Bs,{fitContent:!0,children:[s.jsx(rs,{value:"__default__",className:"pr-2 [&>span:first-child]:hidden",children:h("multirun.modelMultiSelect.variant.default")}),st.map(ik)]})]})]},je.instanceId)})}),e[99]=X,e[100]=P,e[101]=i,e[102]=o,e[103]=g,e[104]=n,e[105]=k,e[106]=h,e[107]=Ae):Ae=e[107];let Me;e[108]!==_e||e[109]!==Ae?(Me=s.jsxs("div",{className:"flex flex-wrap gap-1.5 items-center",children:[_e,Ae]}),e[108]=_e,e[109]=Ae,e[110]=Me):Me=e[110];let q;e[111]!==u||e[112]!==l||e[113]!==n.length||e[114]!==h?(q=l!==void 0&&n.length<l&&s.jsx("p",{className:"typography-micro text-muted-foreground",children:u!==void 0?h("multirun.modelMultiSelect.validation.minToMax",{min:l,max:u}):h("multirun.modelMultiSelect.validation.minOnly",{min:l})}),e[111]=u,e[112]=l,e[113]=n.length,e[114]=h,e[115]=q):q=e[115];let Ne;return e[116]!==Me||e[117]!==q?(Ne=s.jsxs("div",{className:"space-y-2",children:[Me,q]}),e[116]=Me,e[117]=q,e[118]=Ne):Ne=e[118],Ne};function tk(t){return t.providers}function sk(t){return t.toggleFavoriteModel}function nk(t){return t.isFavoriteModel}function rk(t){return t.hiddenModels}function ok(t){return t.providerOrder}function ik(t){return s.jsx(rs,{value:t,className:"pr-2 [&>span:first-child]:hidden",children:t},t)}const ak=(t,e,n)=>{const r=t.session.title?.trim()||t.session.id;return`
|
|
881
|
-
|
|
882
|
-
--- RESULT ${n+1}: ${r} ---
|
|
883
|
-
${e.trim()}
|
|
884
|
-
--- END RESULT ${n+1} ---`},ed=(t,e)=>nt.getState().getWorktreeMetadata(t)?.projectDirectory??e;function lk({session:t,open:e,onOpenChange:n}){const{t:r}=kt(),i=Tg(),o=js(P=>P.activeSessions),l=js(P=>P.archivedSessions),a=js(P=>P.status==="ready"),d=Ut(P=>P.providers),u=Ut(P=>P.currentProviderId),m=Ut(P=>P.currentModelId),f=Ut(P=>P.currentAgentName),[p,y]=c.useState(u??""),[x,k]=c.useState(m??""),[w,h]=c.useState(()=>u&&m?[{providerID:u,modelID:m,instanceId:Yr()}]:[]),[g,j]=c.useState(""),[b,S]=c.useState(f??""),[C,v]=c.useState([]),[M,R]=c.useState(!1),I=c.useMemo(()=>zo(t,ed(t.id,t.directory)??t.directory),[t]),B=c.useMemo(()=>{const P=new Map;for(const Z of i)P.set(Z.id,Z);for(const Z of o)P.set(Z.id,Z);for(const Z of l)P.set(Z.id,Z);return t.id&&P.set(t.id,t),Array.from(P.values())},[o,l,i,t]);c.useEffect(()=>{v([])},[e,t.id]);const O=c.useMemo(()=>!e||!I?[]:B.map(P=>{if(C.includes(P.id))return null;const Z=nt.getState().getDirectoryForSession(P.id)??Ps(P),X=ed(P.id,Z),se=zo(P,X??P.directory);return!se||!nu(I,se)?null:{session:P,directory:Z,projectDirectory:X,identity:se}}).filter(P=>P!==null).sort((P,Z)=>(P.session.time?.created??0)-(Z.session.time?.created??0)),[B,e,I,C]),$=d.find(P=>P.id===p)?.models.find(P=>P.id===x),_=tl($?.variants),Y=!!(I&&a&&p&&x&&O.length>0&&!M),L=c.useCallback(P=>{h([P]),y(P.providerID),k(P.modelID),j("")},[]),A=w[0]?.displayName||w[0]?.modelID||r("multirun.fusion.model.placeholder"),D=async()=>{if(!I||!Y)return;const P=Qt(),Z=fn.getSdkClient(),X=()=>{if(Qt()!==P||fn.getSdkClient()!==Z)throw new Error("Runtime changed")};R(!0);try{const se=await G2(O,I,X);if(se.length===0){ze.error(r("multirun.fusion.toast.noOutputs"));return}const ce=O[0]?.projectDirectory??O[0]?.directory??null;if(!ce)throw new Error("Fusion requires a session directory");const re=Wh(I.groupSlug,p,x,I.runGroup),[ge,ae]=await Promise.all([zl("session.fusion.visible"),zl("session.fusion.instructions")]),Ee=await Kh({title:re,directory:ce,identity:{group:I.group,groupSlug:I.groupSlug,runGroup:I.runGroup,role:"fusion",providerID:p,modelID:x},selection:{model:{providerID:p,id:x,variant:g||void 0},agent:b||void 0}},X);Vh(Ee,ce),nt.getState().setCurrentSession(Ee.id,ce),n(!1),X(),await fn.sendMessage({runtimeKey:P,id:Ee.id,providerID:p,model:{providerID:p,id:x,variant:g||void 0},agent:b||void 0,text:ge,context:[{text:ae},...se.map((Se,me)=>({text:ak(Se.source,Se.text,me)})),{text:`
|
|
885
|
-
|
|
886
|
-
--- FUSION INPUTS END ---
|
|
887
|
-
Now write the final fused answer.`}],directory:ce})}catch(se){if(Qt()!==P||fn.getSdkClient()!==Z)return;console.error("[MultiRunFusion] Failed to start fusion",se),ze.error(r("multirun.fusion.toast.failed"))}finally{R(!1)}};return s.jsx(Ds,{open:e,onOpenChange:n,children:s.jsxs(Is,{className:"max-w-xl overflow-visible",children:[s.jsxs(sn,{children:[s.jsx(Hs,{children:r("multirun.fusion.title")}),s.jsx(Gs,{children:r("multirun.fusion.description")})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("div",{className:"max-w-full",children:s.jsx(im,{selectedModels:w,onAdd:L,onUpdate:(P,Z)=>L(Z),onRemove:()=>{h([]),y(""),k(""),j("")},maxModels:1,addButtonLabel:A,showChips:!1,addButtonClassName:"w-fit max-w-[min(28rem,calc(100vw-8rem))] justify-start",dropdownSide:"bottom",dropdownClassName:"w-[min(28rem,calc(100vw-8rem))]",triggerIcon:p?s.jsx(la,{providerId:p,className:"h-3.5 w-3.5 mr-1"}):void 0})}),_.length>0?s.jsxs(Ms,{value:g||"__default__",onValueChange:P=>j(P==="__default__"?"":P),children:[s.jsxs(Os,{size:"lg",className:"w-fit",children:[s.jsx(F,{name:"brain-ai-3",className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx(Cs,{children:P=>P==="__default__"?r("multirun.modelMultiSelect.variant.default"):P})]}),s.jsxs(Bs,{fitContent:!0,portalToBody:!0,children:[s.jsx(rs,{value:"__default__",children:r("multirun.modelMultiSelect.variant.default")}),_.map(P=>s.jsx(rs,{value:P,children:P},P))]})]}):null,s.jsx(om,{value:b,onChange:S,portalToBody:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta font-medium text-foreground",children:r("multirun.fusion.sources.label",{count:O.length})}),s.jsx("div",{className:"max-h-56 space-y-1 overflow-auto rounded-lg border border-[var(--interactive-border)] p-1",children:O.map(P=>s.jsxs("div",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 typography-meta",children:[s.jsx(la,{providerId:P.identity.providerID,className:"h-4 w-4"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:P.session.title||P.session.id}),s.jsx("button",{type:"button",onClick:()=>v(Z=>[...Z,P.session.id]),className:"text-muted-foreground hover:text-foreground",children:s.jsx(F,{name:"close",className:"h-4 w-4"})})]},P.session.id))})]}),s.jsxs(Un,{children:[s.jsx(ut,{variant:"ghost",onClick:()=>n(!1),children:r("multirun.fusion.actions.cancel")}),s.jsx(ut,{onClick:D,disabled:!Y,children:r(M?"multirun.fusion.actions.starting":"multirun.fusion.actions.start")})]})]})})}function ck(t){const e=et.c(7);let n,r,i,o,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("path",{d:"M12 4.5v6.25M12 10.75v3.5M12 10.75H7.25A3.25 3.25 0 0 0 4 14v1.25M12 10.75h4.75A3.25 3.25 0 0 1 20 14v1.25",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round"}),r=s.jsx("path",{d:"M9.25 7.25 12 4.5l2.75 2.75",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round"}),i=s.jsx("circle",{cx:"4",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),o=s.jsx("circle",{cx:"12",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),l=s.jsx("circle",{cx:"20",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),e[0]=n,e[1]=r,e[2]=i,e[3]=o,e[4]=l):(n=e[0],r=e[1],i=e[2],o=e[3],l=e[4]);let a;return e[5]!==t?(a=s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",...t,children:[n,r,i,o,l]}),e[5]=t,e[6]=a):a=e[6],a}const am=async(t,e,n)=>{const r=n.getRuntimeKey(),i=xt(t.path);if(!i)throw new Error("Unable to resolve worktree project");const o=await n.listProjectWorktrees(t,{force:!0});if(n.getRuntimeKey()!==r)throw new Error("Runtime changed during worktree refresh");const l=n.getCurrentProjects(),a=l.find(x=>x.id===t.id)??null;if(!a||xt(a.path??null)!==i)throw new Error("Project removed during worktree refresh");const d=gl({rawWorktreesByProjectRef:n.rawWorktreesByProjectRef,publishedWorktreesByProject:n.getPublishedWorktreesByProject(),runtimeKey:r}),u=o.map(x=>Jo(x));u.sort((x,k)=>lm({metadata:x},{metadata:k}));const m=Eg(d.worktreesByProject,i,u,e?.projectDirectory);dk(n.rawWorktreesByProjectRef,r),n.rawWorktreesByProjectRef.current={runtimeKey:r,revision:n.rawWorktreesByProjectRef.current.revision,worktreesByProject:m};const f=n.getPublishedWorktreesByProject(),p=Rg(n.partitionWorktreesByRegisteredProject(l,m),f),y=[...p.values()].flat();return n.recordWorktreesSeen(y.map(x=>x.path),n.now()),n.worktreeMapsEqual(p,f)||n.publishTopology({availableWorktrees:y,availableWorktreesByProject:p}),u},dk=(t,e)=>(t.current.runtimeKey!==e||(t.current={...t.current,revision:t.current.revision+1}),t.current.revision),uk=t=>new Map([...t.entries()].map(([e,n])=>[e,n.map(r=>Jo(r))])),gl=t=>((t.rawWorktreesByProjectRef.current.runtimeKey!==t.runtimeKey||t.rawWorktreesByProjectRef.current.worktreesByProject.size===0&&t.publishedWorktreesByProject.size>0)&&(t.rawWorktreesByProjectRef.current={runtimeKey:t.runtimeKey,revision:t.rawWorktreesByProjectRef.current.runtimeKey===t.runtimeKey?t.rawWorktreesByProjectRef.current.revision:0,worktreesByProject:uk(t.publishedWorktreesByProject)}),t.rawWorktreesByProjectRef.current),lm=(t,e)=>{const n=t.metadata.branch||t.metadata.name||t.metadata.label||t.metadata.path,r=e.metadata.branch||e.metadata.name||e.metadata.label||e.metadata.path,i=n.localeCompare(r,void 0,{sensitivity:"base"});return i!==0?i:t.metadata.path.localeCompare(e.metadata.path,void 0,{sensitivity:"base"})},td=t=>{const e=t.split("/").filter(Boolean);return e[e.length-1]??t},Jo=t=>({...t,path:xt(t.path)??t.path,projectDirectory:xt(t.projectDirectory)??t.projectDirectory,worktreeRoot:xt(t.worktreeRoot??t.path)??t.worktreeRoot}),sd=t=>{const{currentWorktree:e,path:n,projectDirectory:r,projectRootBranch:i}=t,l=xt(e?.path??null)===n,a=l?e?.branch??"":i??"",d={path:n,projectDirectory:r,branch:a,label:l?e?.label||e?.branch||e?.name||td(n):i||td(n),name:l?e?.name:void 0,worktreeRoot:l?xt(e?.worktreeRoot??n)??n:n,worktreeStatus:l?e?.worktreeStatus??"ready":"ready",worktreeSource:l?e?.worktreeSource??"existing":"existing",headState:l?e?.headState:i?"branch":void 0};return l&&e?{...e,...d}:d},nd=t=>{const e=xt(t.projectPath??null),n=xt(t.sourceDirectory??null)??xt(t.currentWorktree?.path??null),r=xt(t.discoveredWorktrees.find(m=>xt(m.projectDirectory??null))?.projectDirectory??null),i=xt(t.currentWorktree?.projectDirectory??null),o=r??i??e,l=new Map,a=m=>{const f=xt(m.metadata.path??null);!f||l.has(f)||l.set(f,{...m,metadata:Jo({...m.metadata,path:f})})};for(const m of t.discoveredWorktrees){const f=xt(m.path??null);f&&a({metadata:Jo({...m,path:f,projectDirectory:xt(m.projectDirectory??null)??o??e??f}),isPrimary:o===f,isCurrent:n===f})}o&&!l.has(o)&&a({metadata:sd({path:o,projectDirectory:o,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:!0,isCurrent:n===o}),n&&!l.has(n)&&a({metadata:sd({path:n,projectDirectory:o??e??n,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:o===n,isCurrent:!0});const d=[],u=[];for(const m of l.values()){if(m.isPrimary){d.push(m);continue}u.push(m)}return d.sort((m,f)=>m.metadata.path.localeCompare(f.metadata.path,void 0,{sensitivity:"base"})),u.sort(lm),[...d,...u]},cm=(t,e)=>{const n=t.projectId?e.projects.find(o=>o.id===t.projectId)??null:null;if(n)return n;const r=t.sourceDirectory?e.resolveProject(t.sourceDirectory):null;if(r)return r;const i=t.currentWorktree?.projectDirectory??null;return i?e.resolveProject(i):null},fk=(t,e)=>{const n=e.getRuntimeKey(),r=e.getPublishedWorktreesByProject(),i=gl({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:r,runtimeKey:n}),o=cm(t,e),l=xt(o?.path??null);return{cachedTargets:nd({projectPath:l,discoveredWorktrees:l?i.worktreesByProject.get(l)??[]:[],sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch}),refreshTargets:(async()=>{if(!o||!l)throw new Error("Unable to resolve worktree project");const d=await am(o,t.currentWorktree,e);return nd({projectPath:l,discoveredWorktrees:d,sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch})})()}},mk=t=>{if(t.rawWorktreesByProjectRef.current.runtimeKey!==t.runtimeKey)return!1;if(t.rawWorktreesByProjectRef.current.revision!==t.capturedRevision)return t.requestRediscovery(),!1;const e=t.partitionWorktreesByRegisteredProject(t.projects,t.nextRawWorktreesByProject),n=[...e.values()].flat();return t.recordWorktreesSeen(n.map(r=>r.path),t.now()),t.rawWorktreesByProjectRef.current={runtimeKey:t.runtimeKey,revision:t.capturedRevision,worktreesByProject:new Map(t.nextRawWorktreesByProject)},t.worktreeMapsEqual(e,t.publishedWorktreesByProject)||t.publishTopology({availableWorktrees:n,availableWorktreesByProject:e}),!0},hk=t=>({refreshState:t.isRefreshing?"loading":t.loadFailed&&t.targets.length===0?"error":null,showNewWorktreeAction:!0}),pk=(t,e)=>xt(t.worktree?.path??null)===xt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch,Vr=6,ko=14,rd=Vr+14+6,Wi=new WeakMap,gk=t=>{const e=t.closest("[data-session-row]"),n=e?.closest(".overlay-scrollbar-container");if(!e||!n)return;Wi.get(n)?.();const r=e.getBoundingClientRect().top;let i=3,o=!1,l=null;const a=()=>{o=!0,l!==null&&window.cancelAnimationFrame(l),l=null,Wi.delete(n),n.removeEventListener("wheel",a),n.removeEventListener("touchstart",a)},d=()=>{if(o||!e.isConnected||!n.isConnected){a();return}const u=e.getBoundingClientRect().top-r;if(Math.abs(u)>.5&&(n.scrollTop+=u,Rs("ui.sidebar.selection_scroll_anchor_adjustment")),i-=1,i<=0){a();return}l=window.requestAnimationFrame(d)};n.addEventListener("wheel",a,{passive:!0}),n.addEventListener("touchstart",a,{passive:!0}),Wi.set(n,a),l=window.requestAnimationFrame(d)},xk=c.memo(function(e){const n=et.c(22),{archiveLabel:r,deleteLabel:i,buttonSizeClass:o,iconSizeClass:l,onPointerDown:a,onMouseDown:d,onArchive:u,onDelete:m}=e,f=H2(),p=f?i:r;let y;n[0]!==u||n[1]!==m||n[2]!==f?(y=C=>{if(f||C.shiftKey){m(C);return}u(C)},n[0]=u,n[1]=m,n[2]=f,n[3]=y):y=n[3];const x=y,k=f?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let w;n[4]!==o||n[5]!==k?(w=Re("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",k,o),n[4]=o,n[5]=k,n[6]=w):w=n[6];const h=f?"delete-bin":"archive";let g;n[7]!==l||n[8]!==h?(g=s.jsx(F,{name:h,className:l}),n[7]=l,n[8]=h,n[9]=g):g=n[9];let j;n[10]!==x||n[11]!==p||n[12]!==d||n[13]!==a||n[14]!==w||n[15]!==g?(j=s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",className:w,"aria-label":p,onPointerDown:a,onMouseDown:d,onClick:x,onKeyDown:Nk,children:g})}),n[10]=x,n[11]=p,n[12]=d,n[13]=a,n[14]=w,n[15]=g,n[16]=j):j=n[16];let b;n[17]!==p?(b=s.jsx(St,{side:"left",sideOffset:8,children:p}),n[17]=p,n[18]=b):b=n[18];let S;return n[19]!==j||n[20]!==b?(S=s.jsxs(wt,{children:[j,b]}),n[19]=j,n[20]=b,n[21]=S):S=n[21],S});function bk(t){Rs("ui.sidebar_session_node.render");const{t:e}=kt(),{node:n,depth:r=0,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:d=!1,pinnedSessionIds:u,expandedParents:m,hasSessionSearchQuery:f,normalizedSessionSearchQuery:p,notifyOnSubtasks:y,editingId:x,editingRowKey:k,setEditingId:w,setEditingRowKey:h,editTitle:g,setEditTitle:j,handleSaveEdit:b,handleCancelEdit:S,toggleParent:C,handleSessionSelect:v,handleSessionDoubleClick:M,handleCopySessionId:R,openSidebarMenuKey:I,setOpenSidebarMenuKey:B,createFolderAndStartRename:O,handleDeleteSession:T,handleRestoreSession:$,startSessionWorktreeMenuLoad:_,onEditProject:Y,mobileVariant:L,alwaysShowActions:A,secondaryMeta:D,renderContext:P="project",rowKey:Z,dragKey:X,children:se}=t,ce=Jr(Oe=>Oe.toggle),re=ss(Oe=>Oe.getFoldersForScope),ge=ss(Oe=>Oe.getSessionFolderId),ae=ss(Oe=>Oe.removeSessionFromFolder),Ee=ss(Oe=>Oe.addSessionToFolder),Se=Pe(Oe=>Oe.openContextPanelTab),me=c.useMemo(()=>Wn(),[]),ke=c.useMemo(()=>Qr(),[]),V=c.useContext(Mg),J=me?"group-hover:opacity-100 group-hover:pointer-events-auto":"group-hover:opacity-100 group-hover:pointer-events-auto group-has-[:focus-visible]:opacity-100 group-has-[:focus-visible]:pointer-events-auto",de=me?"group-hover:opacity-0":"group-hover:opacity-0 group-has-[:focus-visible]:opacity-0",we=me,G=!d&&!L,Ce=me?G&&we?"group-hover:pr-18":G||we?"group-hover:pr-14":"group-hover:pr-8":G?"group-hover:pr-7 group-has-[:focus-visible]:pr-7":"group-hover:pr-3 group-has-[:focus-visible]:pr-3",Te=G?"pr-13":"pr-7",pe=me?G?"pr-18":"pr-14":G?"pr-7":"pr-3",ne=c.useRef(!1),[xe,U]=c.useState(!1),z=c.useRef(x);z.current=x;const Q=c.useRef(null),ue=c.useRef(!1),le=c.useRef(b);le.current=b;const W=g,E=c.useRef(W);E.current=W;const K=c.useRef(null),te=c.useRef(!1),oe=c.useRef(null),he=c.useRef(null),ie=n.session,Fe=ie,_e=Gt(c.useCallback(Oe=>{if(D?.projectLabel||!o)return null;const Et=Oe.projects.find(es=>es.id===o);return Et?Et.label?.trim()||cr(xt(Et.path)??Et.path,null)||Et.path:null},[o,D?.projectLabel])),Ae=P==="timeline"||P==="timeline-chat",Me=P==="timeline-chat",q=Gt(c.useCallback(Oe=>!Ae||!o?null:Oe.projects.find(Et=>Et.id===o)??null,[Ae,o])),Ne=D?.projectLabel??(_e?Ku(_e):null),je=R2(D,n.worktree?.branch??null),We=c.useMemo(()=>M2(n.worktree,me),[me,n.worktree]),tt=Vu(We),it=tt?`var(--pr-${tt.visualState})`:void 0,rt=!!je&&P==="recent",ot=c.useMemo(()=>{if(!tt)return null;switch(tt.visualState){case"merged":return e("sessions.sidebar.group.pr.status.merged");case"open":return tt.canMerge===!0||tt.mergeableState==="clean"||tt.checks?.state==="success"?e("sessions.sidebar.group.pr.status.readyToMerge"):e("sessions.sidebar.group.pr.status.open");case"blocked":return tt.mergeableState==="dirty"?e("sessions.sidebar.group.pr.status.mergeConflicts"):e("sessions.sidebar.group.pr.status.mergeBlocked");case"draft":return e("sessions.sidebar.group.pr.status.draft");case"closed":return e("sessions.sidebar.group.pr.status.closed");default:return null}},[tt,e]),ft=nt(Oe=>Oe.currentSessionId===ie.id),st=xt(ie.directory??null)??xt(i??null),Ct=a!==void 0?a:o??st??null,ht=bu(),be=Uu(),Je=me,dt=hs(Oe=>Oe.enabled),Ke=hs(c.useCallback(Oe=>Oe.selectedIds.has(ie.id),[ie.id])),mt=hs(Oe=>Oe.toggleSelected),ee=hs(Oe=>Oe.setRange),fe=em(),Ie=Z??ie.id,$e=x===ie.id&&k===Ie,H=c.useCallback(Oe=>{const Et=[],es=ds=>{ds.children.forEach(vs=>{Et.push(vs.session.id),es(vs)})};return es(Oe),Et},[]),Be=c.useCallback(Oe=>{const Et=[],es=ds=>{ds.children.forEach(vs=>{Et.push(vs.session),es(vs)})};return es(Oe),Et},[]),[Ye,qe]=c.useState(!1),[Xe,jt]=c.useState(!0),Ve=`${P}:${d?"archived":"active"}:${ie.id}`,pt=Z?`session-menu:${Z}`:Ve,Rt=Z?`session-context:${Z}`:null,De=Hu(c.useCallback(Oe=>!!Oe.sessionMemoryState.get(Og(ie.id))?.isZombie,[ie.id])),yt=cu(ie.id),Pt=Bg(ie.id,yt),Ue=gf(ie.id),He=$a(ie.id,st),ve=Ue||He,Qe=n.worktree??nt.getState().getWorktreeMetadata(ie.id)??null,[Ge,Ze]=c.useState([]),[lt,Bt]=c.useState(!1),[$t,Wt]=c.useState(!1),Xt=c.useRef(!1),Ft=c.useRef(0),Jt=Fg(ie.id,st??void 0,{bootstrap:!1}),Lt=_g(Fe),is=Pe(Oe=>Oe.sessionSuggestionEnabled),_t=Lt?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center",title:e(Wl[Lt.status]),"aria-label":e(Wl[Lt.status]),children:s.jsx(F,{name:"target",className:"h-3 w-3",style:{color:Lg[Lt.status]}})}):null,zt=Fe.title||e("sessions.sidebar.session.untitled"),Nt=!Ae&&n.children.length>0,At=Gu(u,st,ie.id),us=Ve,xs=f?!0:m.has(us),qs=c.useMemo(()=>I2(n,xs,st),[xs,n,st]),Zt=$g(qs),nn=!!Fe.parentID,rn=du(ie.id)>0&&(!nn||y),hn=Fe.time?.updated||Fe.time?.created||Date.now(),on=qu(hn),Ts=zg(hn),{isMenuOpen:zs,isContextMenuOpen:Ws,handleMenuOpenChange:an,handleContextMenuOpenChange:as,handleMenuOpenChangeComplete:ps,toggleMenu:Ys}=O2({menuInstanceKey:pt,contextMenuInstanceKey:Rt,openSidebarMenuKey:I,setOpenSidebarMenuKey:B,hasDeferredCloseWork:()=>Q.current!==null,onCloseComplete:()=>{if(!Q.current)return;const{id:Oe,title:Et}=Q.current;Q.current=null,w(Oe),h(Ie),j(Et)}}),fs=zs||Ws,ln=c.useMemo(()=>zo(Fe)!==null,[Fe]),[pn,gn]=c.useState(!1),xn=c.useMemo(()=>H(n).length,[H,n]),bn=c.useCallback(async Oe=>{const Et=[];let es=0;for(const ds of Oe)try{if(!st)throw new Error("Session directory is required for export");const vs=await ht({directory:st,sessionID:ds.session.id});if(!vs)throw new Error("Session runtime changed during export");const ts=ds.session.title||e("sessions.sidebar.session.export.untitledSubagent"),Qs=ds.session.agent,ns=await bn(ds.children);es+=ns.skipped,Et.push({title:ts,agent:Qs,records:vs,children:ns.children})}catch{es+=H(ds).length+1}return{children:Et,skipped:es}},[H,ht,st,e]),N=c.useCallback(Oe=>{Oe<=0||ze.warning(Oe===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:Oe}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:Oe}))},[e]),ye=c.useCallback(async Oe=>{if(!st){ze.error(e("sessions.sidebar.session.export.nothingToExport"));return}const Et=await ht({directory:st,sessionID:ie.id}).catch(()=>null);if(!Et){ze.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}if(Et.length===0){ze.error(e("sessions.sidebar.session.export.nothingToExport"));return}let es,ds=0;if(Oe&&n.children.length>0){const ns=await bn(n.children);es=ns.children,ds=ns.skipped}const vs=yu(Et,Fe.title??null,es),ts=wu(Fe.title??null),Qs=await vu(vs,ts);if(Qs){ze.success(e("sessions.sidebar.session.export.success"),{action:{label:e(Kg()),onClick:()=>{Wg(Qs).then(ns=>{ns||ze.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),N(ds);return}Su(vs,ts),ze.success(e("sessions.sidebar.session.export.success")),N(ds)},[bn,ht,n.children,Fe.title,ie.id,st,N,e]),Le=ju(),at=c.useMemo(()=>ku(Le),[Le]),Tt=c.useCallback(Oe=>{hf({entry:Oe,t:e,session:{id:ie.id,title:Fe.title,directory:st},loadRecords:()=>st?ht({directory:st,sessionID:ie.id}).catch(()=>null):Promise.resolve(null),onLoadFailed:()=>ze.error(e("sessions.sidebar.session.export.failedLoadHistory"))})},[ht,Fe.title,ie.id,st,e]),Dt=c.useCallback(async()=>{if(n.children.length>0){jt(!0),qe(!0);return}await ye(!1)},[ye,n.children.length]),bt=c.useCallback(()=>{st&&zn("desktop_open_session_mini_chat_window",{sessionId:ie.id,directory:st,apiBaseUrl:En(),clientToken:Xr()}).catch(Oe=>{console.warn("[session-sidebar] failed to open mini chat window",Oe)})},[ie.id,st]);if(c.useEffect(()=>{if(!$e)return;const Oe=Et=>{const ds=(Et.target instanceof HTMLElement?Et.target:null)?.closest?.(`[data-session-rename-form="${CSS.escape(Ie)}"]`);he.current&&!ds&&le.current(E.current)};return document.addEventListener("mousedown",Oe),()=>document.removeEventListener("mousedown",Oe)},[$e,Ie]),c.useLayoutEffect(()=>{if(!$e){K.current===Ie&&(K.current=null);return}K.current!==Ie&&(K.current=Ie,te.current=!0)},[g,$e,Ie]),c.useLayoutEffect(()=>{if(!$e||!te.current)return;const Oe=oe.current;!Oe||Oe.value!==g||(te.current=!1,Oe.focus(),Oe.select())},[g,$e,W]),$e){const Oe=s.jsxs("form",{ref:he,"data-session-rename-form":Ie,className:"flex h-[1lh] w-full items-center gap-2 typography-ui-label",onSubmit:Et=>{Et.preventDefault(),b(W)},children:[s.jsx("input",{ref:oe,value:W,onChange:Et=>j(Et.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:e("sessions.sidebar.session.menu.rename"),onKeyDown:Et=>Qi(Et,S)}),s.jsx("button",{type:"submit","aria-label":e("sessions.sidebar.session.rename.save"),title:e("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(F,{name:"check",className:"size-3.5"})}),s.jsx("button",{type:"button",onClick:S,"aria-label":e("sessions.sidebar.session.rename.cancel"),title:e("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(F,{name:"close",className:"size-3.5"})})]});return Ae?s.jsx("div",{style:{paddingLeft:Vr+4},className:Re("group relative my-0.5 flex items-center rounded-md pr-2.5",Me?"py-1":"py-1.5",ft&&"bg-interactive-selection/70 text-interactive-selection-foreground"),children:s.jsx(Jc,{compact:Me,project:q,projectLabel:Ne,title:Oe,titleClassName:"text-foreground",branchLabel:je,statusDot:null,pinnedMarker:null,timeSlot:Ts,directoryIndicator:null,prBadge:tt?s.jsxs("span",{className:"inline-flex flex-shrink-0 items-center gap-1 typography-micro",style:it?{color:it}:void 0,children:[s.jsx(F,{name:"git-pull-request",className:"h-3 w-3",style:it?{color:it}:void 0}),s.jsxs("span",{className:"leading-none tabular-nums",children:["#",tt.number]})]}):null,zombieIndicator:null,badges:null,hideMetaOnHoverClass:""})},ie.id):s.jsx("div",{style:{paddingLeft:rd+r*ko},className:"group relative my-0.5 flex items-center rounded-sm py-1 pr-1.5",children:s.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-0",children:Oe})},ie.id)}const Kt=Jt.length,ls=Zt===1?e("sessions.sidebar.session.status.questionPendingSingle"):e("sessions.sidebar.session.status.questionPendingMany",{count:Zt}),gt=E2({actionsAlwaysVisible:A&&!me,menuOpen:fs,hideOnHoverClass:de}),It=!ve&&!yt&&rn&&!ft,Mt=yt||It,Vt=e(yt?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),Yt=s.jsx(za,{state:yt?"running":"unread",label:Vt}),qt=(yt||It)&&Pt,cs=!A&&Nt&&(ve||Mt||At),ms=At&&!ve&&!Mt,qn=s.jsx(F,{name:"pushpin",className:"h-3 w-3 flex-shrink-0 text-primary","aria-label":e("sessions.sidebar.session.status.pinned")}),ao=ve||Mt||ms?s.jsx("span",{style:{left:Vr+r*ko},className:Re("pointer-events-none absolute top-1/2 inline-flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center transition-opacity",cs?"opacity-100 group-hover:opacity-0 group-has-[:focus-visible]:opacity-0":""),children:ve?s.jsx(F,{name:"loader-4",className:"h-3 w-3 animate-spin text-primary","aria-label":e(He?"sessions.aiRename.generating":"sessions.sidebar.session.status.movingToWorktree")}):Mt?Yt:ms?qn:null}):null,vi=Nt&&!A&&(ve||Mt||At),lo=Nt?s.jsx("span",{role:"button",tabIndex:0,onClick:Oe=>{Oe.stopPropagation(),Oe.currentTarget.blur(),C(us)},onKeyDown:Oe=>{(Oe.key==="Enter"||Oe.key===" ")&&(Oe.preventDefault(),Oe.stopPropagation(),C(us))},style:{minWidth:14,minHeight:14,left:Vr+r*ko},className:Re("absolute top-1/2 inline-flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",vi?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-has-[:focus-visible]:opacity-100 group-has-[:focus-visible]:pointer-events-auto":""),"aria-label":e(xs?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:xs?s.jsx(F,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(F,{name:"arrow-right-s",className:"h-3 w-3"})}):null,Si=De?s.jsx(F,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,Am=Oe=>{Oe.preventDefault(),Oe.stopPropagation(),Ys()},Pm=Oe=>{Oe.preventDefault(),Oe.stopPropagation()},Dm=Oe=>{Oe.preventDefault(),Oe.stopPropagation()},ji=Oe=>{Oe.preventDefault(),Oe.stopPropagation()},ki=Oe=>{Oe.preventDefault(),Oe.stopPropagation()},Im=Oe=>{Oe.preventDefault(),Oe.stopPropagation(),B(null),T(ie,{archivedBucket:d})},Tm=Oe=>{Oe.preventDefault(),Oe.stopPropagation(),B(null),T(ie,{archivedBucket:d,hardDelete:!0,skipConfirm:!0})},Em=Oe=>{Oe.preventDefault(),Oe.stopPropagation()},Rm=Oe=>{Oe.preventDefault(),Oe.stopPropagation()},Mm=Oe=>{Oe.preventDefault(),Oe.stopPropagation(),V?.vscode?.executeCommand("openchamber.openSessionInEditor",ie.id,zt)},xl=Oe=>{if(ne.current){ne.current=!1;return}if(dt){if(Oe?.preventDefault(),Oe?.stopPropagation(),Oe?.shiftKey){const Et=fe?.getEntries(),es=Et??Array.from(document.querySelectorAll("[data-session-row]")).map(ts=>ts.getAttribute("data-session-row")).filter(ts=>!!ts).map(ts=>({id:ts,rowKey:ts,scopeKey:Ct,archived:d})),ds=Et?hs.getState().anchorRowKey:hs.getState().anchorId,vs=new Map;vs.set(ie.id,H(n)),ee(ds,Ie,es,fe?.getDescendantIds()??[],Ct,vs);return}mt(ie.id,Ct,H(n),Ie);return}Oe?.currentTarget&&gk(Oe.currentTarget),v(ie.id,st)},Om=Oe=>{Oe.defaultPrevented||(Oe.target instanceof HTMLElement?Oe.target:null)?.closest('button, a, input, [role="menuitem"], [role="menu"]')||xl(Oe)},Bm=Oe=>{(Oe.button===2||Oe.button===0&&Oe.ctrlKey&&!dt)&&(ne.current=!0)},Fm=Oe=>{L&&Oe.pointerType==="touch"&&U(!0),Oe.button===0&&!ft&&!dt&&!Je&&st&&!ia(ie.id,st).renderable&&be({directory:st,sessionID:ie.id}).catch(()=>{})},bl=Oe=>{L&&Oe.pointerType==="touch"&&U(!1)},_m=Oe=>{Xt.current=Oe,Ft.current+=1;const Et=Ft.current;if(!Oe){Bt(!1),Wt(!1);return}const es=_({projectId:o??null,sourceDirectory:st,currentWorktree:Qe});Ze(es.cachedTargets),Bt(!0),Wt(!1),es.refreshTargets.then(ds=>{!Xt.current||Ft.current!==Et||(Ze(ds),Bt(!1),Wt(!1))}).catch(()=>{!Xt.current||Ft.current!==Et||(Bt(!1),Wt(!0))})},yl=({Item:Oe,Separator:Et,Sub:es,SubTrigger:ds,SubContent:vs})=>s.jsxs(s.Fragment,{children:[s.jsxs(Oe,{onClick:()=>{Q.current={id:ie.id,title:zt}},className:"[&>svg]:mr-1",children:[s.jsx(F,{name:"pencil-ai",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]}),s.jsx(pa,{sessionID:ie.id,directory:st,open:fs,Item:Oe}),s.jsxs(Oe,{onClick:()=>R(ie.id),className:"[&>svg]:mr-1",children:[s.jsx(F,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyId")]}),s.jsxs(Oe,{onClick:()=>st&&ce({directory:st,sessionId:ie.id}),className:"[&>svg]:mr-1",children:[At?s.jsx(F,{name:"unpin",className:"mr-1 h-4 w-4"}):s.jsx(F,{name:"pushpin",className:"mr-1 h-4 w-4"}),e(At?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]}),s.jsxs(Oe,{onClick:()=>{Dt()},className:"[&>svg]:mr-1",children:[s.jsx(F,{name:"download",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]}),at.map(ts=>s.jsxs(Oe,{onClick:()=>Tt(ts),className:"[&>svg]:mr-1",children:[s.jsx(no,{icon:ts.icon,iconSrc:ts.iconSrc,className:"mr-1 size-4"}),ts.action.label]},`${ts.guest.id}:${ts.action.id}`)),Ae&&o&&Y?s.jsxs(Oe,{onClick:()=>Y(o),className:"[&>svg]:mr-1",children:[s.jsx(F,{name:"pencil-ai",className:"h-4 w-4"}),e("sessions.sidebar.project.actions.edit")]}):null,P2({isSubtaskSession:nn,archivedBucket:!!d,isVSCode:me,sessionDirectory:st})?(()=>{const ts=D2({sessionDirectory:st,isStreaming:yt,isMovingToWorktree:Ue}),Qs=hk({targets:Ge,isRefreshing:lt,loadFailed:$t});return s.jsxs(es,{onOpenChange:_m,children:[s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsxs(ds,{disabled:ts,className:"w-full [&>svg]:mr-1","data-session-worktree-submenu-trigger":ie.id,children:[s.jsx(F,{name:"folder-shared",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.moveToWorktreeTargets")]})}),s.jsx(St,{side:"right",className:"max-w-72",children:e(Ue?"sessions.sidebar.session.moveToWorktree.tooltipMoving":yt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltipTargets")})]}),s.jsxs(vs,{className:"min-w-[220px]","data-session-worktree-submenu":ie.id,children:[Ge.map(ns=>{const Xs=xt(ns.metadata.path??null)??ns.metadata.path,Rr=ns.isPrimary?e("sessions.sidebar.session.moveToWorktree.main"):ns.metadata.label||ns.metadata.branch||ns.metadata.name||ns.metadata.path,bs=ns.isCurrent||ns.metadata.worktreeStatus!=="ready";return s.jsxs(Oe,{disabled:bs,title:ns.metadata.path,"data-session-worktree-target":Xs,onClick:()=>{bs||!st||xa({kind:"existing",root:Fe,descendants:Be(n),sourceDirectory:st,destination:ns.metadata,messages:ga(e,{success:"sessions.sidebar.session.moveToWorktree.existingSuccess",failure:"sessions.sidebar.session.moveToWorktree.existingFailed"})})},children:[s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1 truncate",children:[s.jsx("span",{className:"truncate",children:Rr}),ns.isCurrent?s.jsx("span",{className:"sr-only",children:e("sessions.sidebar.session.moveToWorktree.current")}):null]}),ns.isCurrent?s.jsx(F,{name:"check",className:"ml-2 h-3.5 w-3.5 flex-shrink-0 text-primary","aria-hidden":"true"}):null]},Xs)}),Qs.refreshState==="loading"?s.jsx(Oe,{disabled:!0,"data-session-worktree-refresh-state":"loading",className:"py-0.5 text-muted-foreground typography-micro",children:e("sessions.sidebar.session.moveToWorktree.refreshing")}):null,Qs.refreshState==="error"?s.jsx(Oe,{disabled:!0,"data-session-worktree-refresh-state":"error",className:"py-0.5 text-muted-foreground typography-micro",children:e("sessions.sidebar.session.moveToWorktree.loadFailed")}):null,s.jsx(Et,{}),s.jsxs(Oe,{disabled:ts,"data-session-worktree-new-action":"true",onClick:()=>{ts||!st||xa({kind:"quick",root:Fe,descendants:Be(n),sourceDirectory:st,messages:ga(e,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},className:"[&>svg]:mr-1",children:[s.jsx(F,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.newWorktree")]})]})]})})():null,ln?s.jsxs(Oe,{onClick:()=>gn(!0),className:"[&>svg]:mr-1",children:[s.jsx(ck,{className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.runFusion")]}):null,st&&!d&&!Ae?(()=>{const ts=[],Qs=bs=>{const ks=xt(bs??null);ks&&!ts.includes(ks)&&ts.push(ks)};if(o&&!me){const bs=Gt.getState().projects.find(hr=>hr.id===o),ks=xt(bs?.path??null);Qs(ks),ks&&(nt.getState().availableWorktreesByProject.get(ks)??[]).forEach(hr=>Qs(hr.path))}Qs(Ja(st)),Qs(st);const ns=ts.flatMap(bs=>re(bs).map(ks=>({scope:bs,folder:ks}))),Xs=ns.find(({scope:bs,folder:ks})=>ge(bs,ie.id)===ks.id)??null,Rr=ts[0]??st;return s.jsxs(s.Fragment,{children:[s.jsx(Et,{}),s.jsxs(es,{children:[s.jsxs(ds,{className:"[&>svg]:mr-1",children:[s.jsx(F,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]}),s.jsxs(vs,{className:"min-w-[180px]",children:[ns.length===0?s.jsx(Oe,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):ns.map(({scope:bs,folder:ks})=>{const hr=Xs?.folder.id===ks.id;return s.jsxs(Oe,{onClick:()=>{if(hr){ae(bs,ie.id);return}Xs&&Xs.scope!==bs&&ae(Xs.scope,ie.id),Ee(bs,ks.id,ie.id)},children:[s.jsx("span",{className:"flex-1 truncate",children:ks.name}),hr?s.jsx(F,{name:"check",className:"ml-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},ks.id)}),s.jsx(Et,{}),s.jsxs(Oe,{onClick:()=>{const bs=O(Rr);bs&&(ue.current=!0,Xs&&Xs.scope!==Rr&&ae(Xs.scope,ie.id),Ee(Rr,bs.id,ie.id))},children:[s.jsx(F,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),Xs?s.jsxs(Oe,{onClick:()=>{ae(Xs.scope,ie.id)},className:"text-destructive focus:text-destructive",children:[s.jsx(F,{name:"close",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,me?null:s.jsxs(Oe,{disabled:!st,onClick:()=>{st&&Se(st,{mode:"chat",dedupeKey:`session:${ie.id}`,label:zt,sessionTitleFallback:zt})},className:"[&>svg]:mr-1",children:[s.jsx(F,{name:"chat-4",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openInSidePanel")}),s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-[var(--status-warning)] bg-[var(--status-warning)]/10",children:e("sessions.sidebar.session.menu.betaBadge")})]}),ke?s.jsxs(Oe,{disabled:!st,onClick:bt,className:"[&>svg]:mr-1",children:[s.jsx(F,{name:"window",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]}):null,s.jsx(Et,{}),d?null:s.jsxs(Oe,{className:"[&>svg]:mr-1",onClick:()=>T(ie,{archivedBucket:d}),children:[s.jsx(F,{name:"inbox-archive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]}),d?s.jsxs(Oe,{className:"[&>svg]:mr-1",onClick:()=>$(ie),children:[s.jsx(F,{name:"inbox-unarchive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.restore")]}):null,s.jsxs(Oe,{className:"text-destructive focus:text-destructive [&>svg]:mr-1",onClick:()=>T(ie,{archivedBucket:d,hardDelete:!0}),children:[s.jsx(F,{name:"delete-bin",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})]}),Lm=Oe=>{Oe.preventDefault(),Oe.stopPropagation(),st&&ce({directory:st,sessionId:ie.id})},Ci=A?"h-6 w-6":Ae&&!Me?"h-5 w-5":"h-4 w-4",co=A?"h-3.5 w-3.5":Ae&&!Me?"h-3 w-3":"h-2.5 w-2.5",Er=is&&!yt&&!ft?Vg(Fe):null,Ni=Er?e("sessions.sidebar.session.status.nextStep",{suggestion:Er}):"",$m=Ae&&!Me,wl=Oe=>{if(!Er)return null;const Et=s.jsx("span",{className:Re("inline-flex flex-shrink-0 items-center text-status-info",Oe),"aria-label":Ni,children:s.jsx(F,{name:"pencil-ai-2",className:"h-3 w-3"})});return $m?s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:Et}),s.jsx(St,{side:"top",sideOffset:6,className:"max-w-xs",children:s.jsx("p",{children:Ni})})]}):Et},zm=Kt>0||Zt>0||Er?s.jsxs(s.Fragment,{children:[wl(),Kt>0?s.jsxs("span",{className:"inline-flex flex-shrink-0 items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive",title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[s.jsx(F,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Kt})]}):null,Zt>0?s.jsxs("span",{className:"inline-flex flex-shrink-0 items-center gap-1 rounded bg-status-info/10 px-1 py-0.5 text-[0.7rem] text-status-info",title:ls,"aria-label":ls,children:[s.jsx(F,{name:"question",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Zt})]}):null]}):null,Wm=Ae&&tt?s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsxs("button",{type:"button",className:"inline-flex flex-shrink-0 items-center gap-1 rounded typography-micro hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default disabled:no-underline",style:it?{color:it}:void 0,disabled:!tt.url,"aria-label":ot?`#${tt.number} · ${ot}`:`#${tt.number}`,onPointerDown:ji,onMouseDown:ki,onClick:Oe=>{Oe.preventDefault(),Oe.stopPropagation(),tt.url&&so(tt.url)},onKeyDown:Oe=>Oe.stopPropagation(),children:[s.jsx(F,{name:"git-pull-request",className:"h-3 w-3",style:it?{color:it}:void 0}),s.jsxs("span",{className:"leading-none tabular-nums",children:["#",tt.number]})]})}),s.jsx(St,{side:"top",sideOffset:6,children:s.jsx("p",{children:ot?`#${tt.number} · ${ot}`:`#${tt.number}`})})]}):null,Km=Ae?s.jsx(Jc,{compact:Me,project:q,projectLabel:Ne,title:Hr(zt,p),titleClassName:ft||Ke?"text-interactive-selection-foreground":rn?"text-foreground":"text-foreground/80",branchLabel:je,statusDot:Mt?Yt:null,pinnedMarker:At&&!ve?qn:null,timeSlot:qt?s.jsx(Pi,{sessionId:ie.id,running:yt,className:"typography-micro"}):Ts,directoryIndicator:!d&&st?s.jsx(to,{directory:st}):null,prBadge:Wm,zombieIndicator:Si,badges:zm,metaPaddingClass:A?G?"pr-19":"pr-13":void 0,hideMetaOnHoverClass:A&&!me?"":Re(de,fs&&"opacity-0")}):null,Vm=s.jsx(Ls,{align:"end",className:"min-w-[180px]",finalFocus:()=>ue.current?(ue.current=!1,!1):!z.current,children:yl({Item:Ht,Separator:As,Sub:Hg,SubTrigger:Gg,SubContent:qg})}),Um=s.jsx(ua,{children:s.jsx(fa,{className:"app-region-no-drag z-50",children:s.jsx(ma,{"data-slot":"dropdown-menu-content",finalFocus:()=>ue.current?(ue.current=!1,!1):!z.current,style:{color:"var(--surface-elevated-foreground)"},className:Re(Ji,"min-w-[180px]"),children:yl({Item:({className:Oe,...Et})=>s.jsx(of,{className:Re(fu,Oe),...Et}),Separator:({className:Oe,...Et})=>s.jsx(rf,{className:Re(uu,Oe),...Et}),Sub:mb,SubTrigger:({className:Oe,children:Et,...es})=>s.jsxs(hb,{className:Re(Ug,Oe),...es,children:[Et,s.jsx(F,{name:"arrow-right-s",className:"ml-auto size-3.5"})]}),SubContent:({className:Oe,children:Et,...es})=>s.jsx(ua,{children:s.jsx(fa,{className:"app-region-no-drag z-50",children:s.jsx(ma,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:Re(Ji,Oe),...es,children:Et})})})})})})});return s.jsxs(c.Fragment,{children:[s.jsx(k2,{sessionId:ie.id,dragKey:X??Ie,ownerKey:l??Ct,sessionDirectory:st??null,sessionTitle:zt,archivedBucket:d,children:s.jsxs(lf,{open:Ws,onOpenChange:as,onOpenChangeComplete:ps,children:[s.jsxs(af,{render:s.jsx("div",{"data-session-row":ie.id,"data-session-scope":Ct??"","data-session-archived":d?"1":"0","aria-current":ft?"page":void 0,onClick:Om,style:{paddingLeft:Ae?Vr+4:rd+r*ko},className:Re("group relative my-0.5 flex cursor-pointer items-center rounded-md pr-2.5",Ae&&!Me?"py-1.5":"py-1",Ae&&!(ft||Ke)&&"hover:bg-interactive-hover/60",(ft||Ke)&&"bg-interactive-selection/70 text-interactive-selection-foreground",Ke&&"ring-1 ring-inset ring-border")}),children:[Ae?null:ao,Ae?null:lo,s.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button","aria-pressed":dt?Ke:void 0,onPointerDown:Fm,onPointerUp:bl,onPointerCancel:bl,onMouseDown:Bm,onClick:Oe=>xl(Oe),onDoubleClick:Oe=>{Oe.stopPropagation(),M(ie.id,zt)},className:Re("flex min-w-0 flex-1 cursor-pointer flex-col gap-0 overflow-hidden text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring text-foreground select-none transition-[padding]",xe&&"bg-interactive-hover/70",Ae?void 0:A?me?Ce:Te:fs?pe:Ce),children:Ae?Km:s.jsxs("div",{className:"flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden",children:[s.jsx("div",{className:Re("block min-w-0 flex-1 truncate typography-ui-label font-normal",ft||Ke?"text-interactive-selection-foreground":rn?"text-foreground":"text-foreground/80"),children:Hr(zt,p)}),!d&&st&&P==="recent"?s.jsx(to,{directory:st,className:A?void 0:fs?"mr-1":me?"group-hover:mr-1":"group-hover:mr-1 group-has-[:focus-visible]:mr-1"}):null,A?s.jsx("span",{className:"ml-2 inline-flex flex-shrink-0 items-center gap-1 typography-micro text-muted-foreground/75",children:qt?s.jsx(Pi,{sessionId:ie.id,running:yt}):s.jsxs(s.Fragment,{children:[_t,rt?s.jsx(F,{name:"git-branch",className:Re("h-3 w-3",!it&&"text-muted-foreground/60"),style:it?{color:it}:void 0}):null,Ts]})}):qt||_t||rt||P==="recent"?s.jsx("div",{className:Re("relative ml-1 flex h-4 flex-shrink-0 items-center justify-end",fs?"hidden":me?"group-hover:hidden":"group-hover:hidden group-has-[:focus-visible]:hidden"),children:s.jsx("span",{className:"inline-flex items-center gap-1 whitespace-nowrap text-right",children:qt?s.jsx(Pi,{sessionId:ie.id,running:yt,className:"typography-micro"}):s.jsxs(s.Fragment,{children:[_t,rt?s.jsx(F,{name:"git-branch",className:Re("h-3 w-3",!it&&"text-muted-foreground/60"),style:it?{color:it}:void 0}):null,P==="recent"?s.jsx("span",{className:"flex-shrink-0 typography-micro leading-none text-muted-foreground/75 tabular-nums",children:Ts}):null]})})}):null,wl(gt),Kt>0?s.jsxs("span",{className:Re("inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0",gt),title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[s.jsx(F,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Kt})]}):null,Zt>0?s.jsxs("span",{className:Re("inline-flex items-center gap-1 rounded bg-status-info/10 px-1 py-0.5 text-[0.7rem] text-status-info flex-shrink-0",gt),title:ls,"aria-label":ls,children:[s.jsx(F,{name:"question",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Zt})]}):null]})})}),!me&&!Ae?s.jsx(St,{side:"right",sideOffset:8,className:"max-w-xs text-left",children:s.jsxs("div",{className:"flex min-w-44 flex-col gap-1.5 text-left text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:zt}),s.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:on,children:Ts})]}),Ne&&!Ae?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(F,{name:"folder",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 truncate",children:Ne})]}):null,je?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(F,{name:"git-branch",className:"h-3 w-3 flex-shrink-0",style:it?{color:it}:void 0}),s.jsx("span",{className:"min-w-0 truncate",children:je})]}):null,tt&&ot?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(F,{name:"git-pull-request",className:"h-3 w-3 flex-shrink-0",style:it?{color:it}:void 0}),s.jsxs("span",{className:"min-w-0 truncate",style:it?{color:it}:void 0,children:["#",tt.number," · ",ot]})]}):null,Er?s.jsxs("div",{className:"flex min-w-0 items-start gap-1.5 text-status-info",children:[s.jsx(F,{name:"pencil-ai-2",className:"mt-0.5 h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 line-clamp-3",children:Ni})]}):null]})}):null]})}),Si&&!L&&!Ae?s.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 z-10",children:Si}):null,s.jsxs("div",{className:Re("absolute right-1 z-10 flex items-center gap-0.5 transition-opacity",Ae&&!Me?"top-1.5 h-5":"top-1/2 -translate-y-1/2",fs||A&&!me?"opacity-100":Re("opacity-0",J)),children:[Ae?s.jsx("button",{type:"button",className:Re("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",Ci,At?"text-primary":"text-muted-foreground hover:text-foreground"),"aria-label":e(At?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin"),onPointerDown:ji,onMouseDown:ki,onClick:Lm,onKeyDown:Oe=>Oe.stopPropagation(),children:s.jsx(F,{name:"pushpin",className:co})}):null,G?s.jsx(xk,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:Ci,iconSizeClass:co,onPointerDown:ji,onMouseDown:ki,onArchive:Im,onDelete:Tm}):null,we?s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",className:Re("inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",Ci),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:Em,onMouseDown:Rm,onClick:Mm,onKeyDown:Oe=>Oe.stopPropagation(),children:s.jsx(F,{name:"external-link",className:co})})}),s.jsx(St,{side:"left",sideOffset:8,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,s.jsxs($s,{open:zs,onOpenChange:an,onOpenChangeComplete:ps,children:[s.jsx(_s,{asChild:!0,children:s.jsx("button",{type:"button",className:Re("inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",A?"h-6 w-6 opacity-100":fs?"h-4 w-4 opacity-100":Re("h-4 w-4 opacity-0",J)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:Pm,onMouseDown:Dm,onClick:Am,onKeyDown:Oe=>Oe.stopPropagation(),children:s.jsx(F,{name:"more-2",className:co})})}),Vm]})]})]}),Um]})}),Nt&&xs?se:null,s.jsx(Ds,{open:Ye,onOpenChange:qe,children:s.jsxs(Is,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(sn,{children:[s.jsx(Hs,{children:e("sessions.sidebar.session.export.dialog.title")}),s.jsx(Gs,{children:xn===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:xn}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:xn})})]}),s.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:Xe,onChange:Oe=>jt(Oe.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),s.jsxs(Un,{children:[s.jsx(ut,{type:"button",onClick:()=>qe(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),s.jsx(ut,{type:"button",onClick:()=>{qe(!1),ye(Xe)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})}),ln?s.jsx(lk,{session:Fe,open:pn,onOpenChange:gn}):null]},ie.id)}const od=t=>xt(t.session.directory??null),yk=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null),wk=t=>{if(!t.openSidebarMenuKey)return null;if(t.rowKey&&(t.openSidebarMenuKey===`session-menu:${t.rowKey}`||t.openSidebarMenuKey===`session-context:${t.rowKey}`))return t.node.session.id;const e=t.archivedBucket?"archived":"active",n=`${t.renderContext??"project"}:${e}:`;return t.openSidebarMenuKey.startsWith(n)?t.openSidebarMenuKey.slice(n.length):null},id=t=>t.menuOpenSessionId??wk(t),Co=(t,e,n)=>e?n.has(t.node.session.id)?!0:Pr(t.node,e):!1,Ea=(t,e,n,r,i)=>{if(t.session.id!==e.session.id)return!0;const o=i(t);if(n.has(o)!==r.has(o)||t.children.length!==e.children.length)return!0;for(let l=0;l<t.children.length;l+=1)if(Ea(t.children[l],e.children[l],n,r,i))return!0;return!1},vk=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const n=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return Ea(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${t.renderContext??"project"}:${n}:${i.session.id}`)||Ea(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${e.renderContext??"project"}:${r}:${i.session.id}`)},Sk=(t,e)=>t.id===e.id&&t.title===e.title&&t.directory===e.directory&&t.parentID===e.parentID&&t.time?.created===e.time?.created&&t.time?.updated===e.time?.updated&&t.time?.archived===e.time?.archived&&ru(t,e),jk=(t,e)=>{if(t.node.session.id!==e.node.session.id||!Sk(t.node.session,e.node.session)||!pk(t.node,e.node))return"node";if(t.depth!==e.depth)return"depth";if(t.groupDirectory!==e.groupDirectory)return"groupDirectory";if(t.projectId!==e.projectId)return"projectId";if(t.archivedBucket!==e.archivedBucket)return"archivedBucket";if((t.renderContext??"project")!==(e.renderContext??"project"))return"renderContext";if(t.mobileVariant!==e.mobileVariant)return"mobileVariant";if(t.alwaysShowActions!==e.alwaysShowActions)return"alwaysShowActions";if(t.hasSessionSearchQuery!==e.hasSessionSearchQuery)return"hasSessionSearchQuery";if(t.normalizedSessionSearchQuery!==e.normalizedSessionSearchQuery)return"normalizedSessionSearchQuery";if(t.notifyOnSubtasks!==e.notifyOnSubtasks)return"notifyOnSubtasks";if(t.nodeStructureKey!==e.nodeStructureKey)return"nodeStructureKey";if(t.relativeTimeTick!==e.relativeTimeTick)return"relativeTimeTick";if(od(t.node)!==od(e.node))return"nodeDirectory";if(!yk(t.secondaryMeta,e.secondaryMeta))return"secondaryMeta";if(t.pinnedSessionIds!==e.pinnedSessionIds&&rm(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory))return"pinnedSessionIds";if(t.expandedParents!==e.expandedParents&&vk(t,e))return"expandedParents";if(t.editingId!==e.editingId&&(Co(t,t.editingId,t.subtreeContainsEditing)||Co(e,e.editingId,e.subtreeContainsEditing)))return"editingId";if(t.editingRowKey!==e.editingRowKey&&(t.editingRowKey===t.rowKey||e.editingRowKey===e.rowKey))return"editingRowKey";if(t.editTitle!==e.editTitle&&(Co(t,t.editingId,t.subtreeContainsEditing)||Co(e,e.editingId,e.subtreeContainsEditing)))return"editTitle";if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const r=id(t),i=id(e);if(Pr(t.node,r)||Pr(e.node,i))return"openSidebarMenuKey"}return t.setEditingId===e.setEditingId&&t.setEditingRowKey===e.setEditingRowKey&&t.setEditTitle===e.setEditTitle&&t.handleSaveEdit===e.handleSaveEdit&&t.handleCancelEdit===e.handleCancelEdit&&t.toggleParent===e.toggleParent&&t.handleSessionSelect===e.handleSessionSelect&&t.handleSessionDoubleClick===e.handleSessionDoubleClick&&t.handleCopySessionId===e.handleCopySessionId&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.createFolderAndStartRename===e.createFolderAndStartRename&&t.handleDeleteSession===e.handleDeleteSession&&t.handleRestoreSession===e.handleRestoreSession&&t.startSessionWorktreeMenuLoad===e.startSessionWorktreeMenuLoad&&t.onEditProject===e.onEditProject&&t.children===e.children?null:"callbacks"},kk=(t,e)=>{const n=jk(t,e);return n===null?!0:(Rs(`ui.sidebar_session_node.props_changed.${n}`),!1)},Ck=c.memo(bk,kk);function Nk(t){return t.stopPropagation()}const Ak=t=>{const{t:e}=kt(),n=c.useRef(null),r=c.useRef(t.editingId),i=c.useRef(t.editTitle),o=c.useRef(t.deleteSessionConfirm);r.current=t.editingId,i.current=t.editTitle,o.current=t.deleteSessionConfirm;const l=Pe(D=>D.setSessionSwitcherOpen),a=nt(D=>D.setCurrentSession),d=nt(D=>D.updateSessionTitle),u=nt(D=>D.deleteSession),m=nt(D=>D.deleteSessions),f=nt(D=>D.archiveSession),p=nt(D=>D.archiveSessions),y=nt(D=>D.unarchiveSession),{mobileVariant:x,allowReselect:k,onSessionSelected:w,resetSessionSearch:h,descendantIds:g,showDeletionDialog:j,setDeleteSessionConfirm:b,setEditingId:S,setEditingRowKey:C,editingSessionId:v,editingOccurrenceKey:M,setEditTitle:R}=t;c.useEffect(()=>()=>{n.current&&clearTimeout(n.current)},[]);const I=c.useCallback((D,P)=>{if(qi("navigation.session_select"),Pe.getState().closeMainSurfaces(),x&&l(!1),D===nt.getState().currentSessionId){k&&w?.(D),h();return}qi("navigation.session_state_set"),a(D,P??null),w?.(D),h()},[k,x,w,h,a,l]),B=c.useCallback((D,P)=>{S(D),C(M),R(P)},[M,R,S,C]),O=c.useCallback(async D=>{if(!r.current)return;const Z=(D??i.current).trim();if(Z)try{await d(v,Z)}catch(X){console.error("[session-actions] rename failed",X),ze.error(e("sessions.sidebar.session.rename.error",{detail:ou(X instanceof Error?X:new Error(String(X)),e)}))}S(null),C(null),R("")},[v,R,S,C,e,d]),T=c.useCallback(()=>{S(null),C(null),R("")},[R,S,C]),$=c.useCallback(D=>{fr(D).then(P=>{if(P.ok){ze.success(e("sessions.sidebar.session.copyId.success"));return}ze.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>ze.error(e("sessions.sidebar.session.copyId.error")))},[e]),_=c.useCallback(async(D,P,Z)=>{const X=P?.archivedBucket===!0||P?.hardDelete===!0,se=Z?.descendantIds??g;await Uh(X?"delete":"archive",D,se,{archiveSession:f,archiveSessions:p,deleteSession:u,deleteSessions:m},e)},[f,p,u,m,g,e]),Y=c.useCallback((D,P)=>{const Z=P?.archivedBucket===!0||P?.hardDelete===!0,X=Qd(D.id,g,Z);if(!j||P?.skipConfirm===!0){_(D,P,{descendantIds:X});return}b({session:D,descendantCount:X.length,descendantIds:X,archivedBucket:Z})},[g,_,b,j]),L=c.useCallback(async()=>{const D=o.current;if(!D)return;const{session:P,archivedBucket:Z,descendantIds:X}=D;b(null),await _(P,{archivedBucket:Z},{descendantIds:X})},[_,b]),A=c.useCallback(async D=>{await y(D.id)?ze.success(e("sessions.sidebar.session.restore.success")):ze.error(e("sessions.sidebar.session.restore.error"))},[e,y]);return c.useMemo(()=>({handleSessionSelect:I,handleSessionDoubleClick:B,handleSaveEdit:O,handleCancelEdit:T,handleCopySessionId:$,handleDeleteSession:Y,handleRestoreSession:A,confirmDeleteSession:L}),[T,$,Y,A,O,B,I,L])};function Pk(t){const e=et.c(71),{t:n}=kt(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t;let d,u,m,f,p,y,x,k,w,h;if(e[0]!==i||e[1]!==n||e[2]!==r){const D=n("sessions.sidebar.session.untitled");f=Ds,w=!!r,e[13]!==i?(h=Z=>{Z||i(null)},e[13]=i,e[14]=h):h=e[14],m=Is,x=!1,k="max-w-sm gap-5",u=sn;let P;e[15]!==n||e[16]!==r?.archivedBucket?(P=r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.title"):n("sessions.sidebar.dialogs.archiveSession.title"),e[15]=n,e[16]=r?.archivedBucket,e[17]=P):P=e[17],e[18]!==P?(y=s.jsx(Hs,{children:P}),e[18]=P,e[19]=y):y=e[19],d=Gs,p=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||D,count:r.descendantCount}):n("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||D,count:r.descendantCount}):r.descendantCount===1?n("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||D,count:r.descendantCount}):n("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||D,count:r.descendantCount}):r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||D}):n("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||D}),e[0]=i,e[1]=n,e[2]=r,e[3]=d,e[4]=u,e[5]=m,e[6]=f,e[7]=p,e[8]=y,e[9]=x,e[10]=k,e[11]=w,e[12]=h}else d=e[3],u=e[4],m=e[5],f=e[6],p=e[7],y=e[8],x=e[9],k=e[10],w=e[11],h=e[12];let g;e[20]!==d||e[21]!==p?(g=s.jsx(d,{children:p}),e[20]=d,e[21]=p,e[22]=g):g=e[22];let j;e[23]!==u||e[24]!==y||e[25]!==g?(j=s.jsxs(u,{children:[y,g]}),e[23]=u,e[24]=y,e[25]=g,e[26]=j):j=e[26];let b;e[27]!==l||e[28]!==o?(b=()=>l(!o),e[27]=l,e[28]=o,e[29]=b):b=e[29];const S=!o;let C;e[30]!==o?(C=o?s.jsx(F,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(F,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[30]=o,e[31]=C):C=e[31];let v;e[32]!==n?(v=n("sessions.sidebar.dialogs.neverAsk"),e[32]=n,e[33]=v):v=e[33];let M;e[34]!==C||e[35]!==v||e[36]!==b||e[37]!==S?(M=s.jsxs("button",{type:"button",onClick:b,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-pressed":S,children:[C,v]}),e[34]=C,e[35]=v,e[36]=b,e[37]=S,e[38]=M):M=e[38];let R;e[39]!==i?(R=()=>i(null),e[39]=i,e[40]=R):R=e[40];let I;e[41]!==n?(I=n("sessions.sidebar.dialogs.cancel"),e[41]=n,e[42]=I):I=e[42];let B;e[43]!==R||e[44]!==I?(B=s.jsx("button",{type:"button",onClick:R,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:I}),e[43]=R,e[44]=I,e[45]=B):B=e[45];let O;e[46]!==a?(O=()=>{a()},e[46]=a,e[47]=O):O=e[47];let T;e[48]!==n||e[49]!==r?.archivedBucket?(T=r?.archivedBucket?n("sessions.sidebar.bulkActions.delete"):n("sessions.sidebar.bulkActions.archive"),e[48]=n,e[49]=r?.archivedBucket,e[50]=T):T=e[50];let $;e[51]!==O||e[52]!==T?($=s.jsx("button",{type:"button",onClick:O,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:T}),e[51]=O,e[52]=T,e[53]=$):$=e[53];let _;e[54]!==B||e[55]!==$?(_=s.jsxs("div",{className:"flex items-center gap-2",children:[B,$]}),e[54]=B,e[55]=$,e[56]=_):_=e[56];let Y;e[57]!==M||e[58]!==_?(Y=s.jsxs(Un,{className:"w-full sm:items-center sm:justify-between",children:[M,_]}),e[57]=M,e[58]=_,e[59]=Y):Y=e[59];let L;e[60]!==m||e[61]!==x||e[62]!==Y||e[63]!==k||e[64]!==j?(L=s.jsxs(m,{showCloseButton:x,className:k,children:[j,Y]}),e[60]=m,e[61]=x,e[62]=Y,e[63]=k,e[64]=j,e[65]=L):L=e[65];let A;return e[66]!==f||e[67]!==L||e[68]!==w||e[69]!==h?(A=s.jsx(f,{open:w,onOpenChange:h,children:L}),e[66]=f,e[67]=L,e[68]=w,e[69]=h,e[70]=A):A=e[70],A}function Dk(t){const e=et.c(57),{t:n}=kt(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t,d=r?.archivedBucket===!0,u=r?.sessionCount??0;let m;e[0]!==d||e[1]!==u||e[2]!==n?(m=n(d?u===1?"sessions.sidebar.dialogs.deleteSession.title":"sessions.sidebar.dialogs.deleteSessions.title":u===1?"sessions.sidebar.dialogs.archiveSession.title":"sessions.sidebar.dialogs.archiveSessions.title"),e[0]=d,e[1]=u,e[2]=n,e[3]=m):m=e[3];const f=m;let p;e[4]!==d||e[5]!==u||e[6]!==n?(p=d?u===1?n("sessions.sidebar.dialogs.deleteSessions.singleDescription",{count:u}):n("sessions.sidebar.dialogs.deleteSessions.pluralDescription",{count:u}):u===1?n("sessions.sidebar.dialogs.archiveSessions.singleDescription",{count:u}):n("sessions.sidebar.dialogs.archiveSessions.pluralDescription",{count:u}),e[4]=d,e[5]=u,e[6]=n,e[7]=p):p=e[7];const y=p,x=!!r;let k;e[8]!==i?(k=A=>{A||i(null)},e[8]=i,e[9]=k):k=e[9];let w;e[10]!==f?(w=s.jsx(Hs,{children:f}),e[10]=f,e[11]=w):w=e[11];let h;e[12]!==y?(h=s.jsx(Gs,{children:y}),e[12]=y,e[13]=h):h=e[13];let g;e[14]!==w||e[15]!==h?(g=s.jsxs(sn,{children:[w,h]}),e[14]=w,e[15]=h,e[16]=g):g=e[16];let j;e[17]!==l||e[18]!==o?(j=()=>l(!o),e[17]=l,e[18]=o,e[19]=j):j=e[19];const b=!o;let S;e[20]!==o?(S=o?s.jsx(F,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(F,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[20]=o,e[21]=S):S=e[21];let C;e[22]!==n?(C=n("sessions.sidebar.dialogs.neverAsk"),e[22]=n,e[23]=C):C=e[23];let v;e[24]!==C||e[25]!==j||e[26]!==b||e[27]!==S?(v=s.jsxs("button",{type:"button",onClick:j,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-pressed":b,children:[S,C]}),e[24]=C,e[25]=j,e[26]=b,e[27]=S,e[28]=v):v=e[28];let M;e[29]!==i?(M=()=>i(null),e[29]=i,e[30]=M):M=e[30];let R;e[31]!==n?(R=n("sessions.sidebar.dialogs.cancel"),e[31]=n,e[32]=R):R=e[32];let I;e[33]!==M||e[34]!==R?(I=s.jsx("button",{type:"button",onClick:M,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:R}),e[33]=M,e[34]=R,e[35]=I):I=e[35];let B;e[36]!==a?(B=()=>{a()},e[36]=a,e[37]=B):B=e[37];let O;e[38]!==d||e[39]!==n?(O=n(d?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=d,e[39]=n,e[40]=O):O=e[40];let T;e[41]!==B||e[42]!==O?(T=s.jsx("button",{type:"button",onClick:B,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:O}),e[41]=B,e[42]=O,e[43]=T):T=e[43];let $;e[44]!==I||e[45]!==T?($=s.jsxs("div",{className:"flex items-center gap-2",children:[I,T]}),e[44]=I,e[45]=T,e[46]=$):$=e[46];let _;e[47]!==v||e[48]!==$?(_=s.jsxs(Un,{className:"w-full sm:items-center sm:justify-between",children:[v,$]}),e[47]=v,e[48]=$,e[49]=_):_=e[49];let Y;e[50]!==_||e[51]!==g?(Y=s.jsxs(Is,{showCloseButton:!1,className:"max-w-sm gap-5",children:[g,_]}),e[50]=_,e[51]=g,e[52]=Y):Y=e[52];let L;return e[53]!==x||e[54]!==Y||e[55]!==k?(L=s.jsx(Ds,{open:x,onOpenChange:k,children:Y}),e[53]=x,e[54]=Y,e[55]=k,e[56]=L):L=e[56],L}function dm(t){const e=et.c(36),{t:n}=kt(),{value:r,setValue:i,onConfirm:o}=t,l=!!r;let a;e[0]!==i?(a=S=>{S||i(null)},e[0]=i,e[1]=a):a=e[1];let d;e[2]!==n?(d=n("sessions.sidebar.dialogs.deleteFolder.title"),e[2]=n,e[3]=d):d=e[3];let u;e[4]!==d?(u=s.jsx(Hs,{children:d}),e[4]=d,e[5]=u):u=e[5];let m;e[6]!==n||e[7]!==r?(m=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?n("sessions.sidebar.dialogs.deleteFolder.withOneSubfolder",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withManySubfolders",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders",{folderName:r.folderName}):n("sessions.sidebar.dialogs.deleteFolder.single",{folderName:r?.folderName??""}),e[6]=n,e[7]=r,e[8]=m):m=e[8];let f;e[9]!==m?(f=s.jsx(Gs,{children:m}),e[9]=m,e[10]=f):f=e[10];let p;e[11]!==u||e[12]!==f?(p=s.jsxs(sn,{children:[u,f]}),e[11]=u,e[12]=f,e[13]=p):p=e[13];let y;e[14]!==i?(y=()=>i(null),e[14]=i,e[15]=y):y=e[15];let x;e[16]!==n?(x=n("sessions.sidebar.dialogs.cancel"),e[16]=n,e[17]=x):x=e[17];let k;e[18]!==y||e[19]!==x?(k=s.jsx("button",{type:"button",onClick:y,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:x}),e[18]=y,e[19]=x,e[20]=k):k=e[20];let w;e[21]!==n?(w=n("sessions.sidebar.bulkActions.delete"),e[21]=n,e[22]=w):w=e[22];let h;e[23]!==o||e[24]!==w?(h=s.jsx("button",{type:"button",onClick:o,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:w}),e[23]=o,e[24]=w,e[25]=h):h=e[25];let g;e[26]!==h||e[27]!==k?(g=s.jsxs(Un,{children:[k,h]}),e[26]=h,e[27]=k,e[28]=g):g=e[28];let j;e[29]!==g||e[30]!==p?(j=s.jsxs(Is,{showCloseButton:!1,className:"max-w-sm gap-5",children:[p,g]}),e[29]=g,e[30]=p,e[31]=j):j=e[31];let b;return e[32]!==l||e[33]!==a||e[34]!==j?(b=s.jsx(Ds,{open:l,onOpenChange:a,children:j}),e[32]=l,e[33]=a,e[34]=j,e[35]=b):b=e[35],b}const Ik=new Set;function Tk(t){const e=et.c(113),{node:n,depth:r,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:d,secondaryMeta:u,renderContext:m,rowKey:f,dragKey:p,renderExtras:y,pinnedSessionIds:x,expandedParents:k,hasSessionSearchQuery:w,normalizedSessionSearchQuery:h,notifyOnSubtasks:g,editingId:j,editingRowKey:b,setEditingId:S,setEditingRowKey:C,editTitle:v,setEditTitle:M,toggleParent:R,openSidebarMenuKey:I,setOpenSidebarMenuKey:B,allowReselect:O,onSessionSelected:T,resetSessionSearch:$,deleteSessionConfirm:_,setDeleteSessionConfirm:Y,startFolderRename:L,startSessionWorktreeMenuLoad:A,onEditProject:D,mobileVariant:P,alwaysShowActions:Z,renderChildren:X}=t,se=r===void 0?0:r,ce=d===void 0?!1:d,re=m===void 0?"project":m,ge=X===void 0?!0:X;Rs("ui.sidebar_tree_item.render");const ae=f??`${re}:${ce?"archived":"active"}:${n.session.id}`,Ee=ss(Ok),Se=ss(Mk),me=Pe(Rk),ke=Pe(Ek);let V;if(e[0]!==n){V=[];const ie=Fe=>Fe.children.forEach(_e=>{V.push(_e.session.id),ie(_e)});ie(n),e[0]=n,e[1]=V}else V=e[1];const J=V.join(`
|
|
888
|
-
`);let de;e[2]!==J?(de=J?J.split(`
|
|
889
|
-
`):[],e[2]=J,e[3]=de):de=e[3];const we=de;let G;e[4]!==Ee||e[5]!==L||e[6]!==Se?(G=(ie,Fe)=>{if(!ie)return null;Fe&&ss.getState().collapsedFolderIds.has(Fe)&&Se(Fe);const _e=Ee(ie,"New folder",Fe);return L(ie,_e),_e},e[4]=Ee,e[5]=L,e[6]=Se,e[7]=G):G=e[7];const Ce=G;let Te;e[8]!==O||e[9]!==_||e[10]!==we||e[11]!==v||e[12]!==j||e[13]!==ae||e[14]!==P||e[15]!==n.session.id||e[16]!==T||e[17]!==$||e[18]!==Y||e[19]!==M||e[20]!==S||e[21]!==C||e[22]!==me?(Te={mobileVariant:P,allowReselect:O,onSessionSelected:T,resetSessionSearch:$,descendantIds:we,showDeletionDialog:me,setDeleteSessionConfirm:Y,deleteSessionConfirm:_,editingId:j,setEditingId:S,setEditingRowKey:C,editingSessionId:n.session.id,editingOccurrenceKey:ae,editTitle:v,setEditTitle:M},e[8]=O,e[9]=_,e[10]=we,e[11]=v,e[12]=j,e[13]=ae,e[14]=P,e[15]=n.session.id,e[16]=T,e[17]=$,e[18]=Y,e[19]=M,e[20]=S,e[21]=C,e[22]=me,e[23]=Te):Te=e[23];const pe=Ak(Te),ne=y?.childRenderExtrasFor,xe=n.session.directory??i;let U;e[24]!==ce||e[25]!==o||e[26]!==re||e[27]!==xe?(U={groupDirectory:xe,projectId:o,archivedBucket:ce,renderContext:re},e[24]=ce,e[25]=o,e[26]=re,e[27]=xe,e[28]=U):U=e[28];const z=U,Q=p??f??n.session.id,ue=y?.subtreeContainsEditing??Ik,le=y?.menuOpenSessionId??null,W=y?.nodeStructureKey??"",E=y?.relativeTimeTick;let K;e[29]!==O||e[30]!==Z||e[31]!==z||e[32]!==ne||e[33]!==_||e[34]!==se||e[35]!==v||e[36]!==j||e[37]!==b||e[38]!==k||e[39]!==l||e[40]!==w||e[41]!==P||e[42]!==n.children||e[43]!==h||e[44]!==g||e[45]!==T||e[46]!==I||e[47]!==x||e[48]!==ge||e[49]!==$||e[50]!==a||e[51]!==Y||e[52]!==M||e[53]!==S||e[54]!==C||e[55]!==B||e[56]!==L||e[57]!==A||e[58]!==R?(K=ge?n.children.map(ie=>s.jsx(Zo,{node:ie,pinnedSessionIds:x,expandedParents:k,hasSessionSearchQuery:w,normalizedSessionSearchQuery:h,notifyOnSubtasks:g,editingId:j,editingRowKey:b,setEditingId:S,setEditingRowKey:C,editTitle:v,setEditTitle:M,toggleParent:R,openSidebarMenuKey:I,setOpenSidebarMenuKey:B,allowReselect:O,onSessionSelected:T,resetSessionSearch:$,deleteSessionConfirm:_,setDeleteSessionConfirm:Y,startFolderRename:L,startSessionWorktreeMenuLoad:A,mobileVariant:P,alwaysShowActions:Z,depth:se+1,folderOwnerKey:l,selectionScopeKey:a,...z,renderExtras:ne?.(ie)},ie.session.id)):null,e[29]=O,e[30]=Z,e[31]=z,e[32]=ne,e[33]=_,e[34]=se,e[35]=v,e[36]=j,e[37]=b,e[38]=k,e[39]=l,e[40]=w,e[41]=P,e[42]=n.children,e[43]=h,e[44]=g,e[45]=T,e[46]=I,e[47]=x,e[48]=ge,e[49]=$,e[50]=a,e[51]=Y,e[52]=M,e[53]=S,e[54]=C,e[55]=B,e[56]=L,e[57]=A,e[58]=R,e[59]=K):K=e[59];let te;e[60]!==Z||e[61]!==ce||e[62]!==Ce||e[63]!==se||e[64]!==v||e[65]!==j||e[66]!==b||e[67]!==ae||e[68]!==k||e[69]!==l||e[70]!==i||e[71]!==w||e[72]!==P||e[73]!==n||e[74]!==h||e[75]!==g||e[76]!==D||e[77]!==I||e[78]!==x||e[79]!==o||e[80]!==re||e[81]!==u||e[82]!==a||e[83]!==pe.handleCancelEdit||e[84]!==pe.handleCopySessionId||e[85]!==pe.handleDeleteSession||e[86]!==pe.handleRestoreSession||e[87]!==pe.handleSaveEdit||e[88]!==pe.handleSessionDoubleClick||e[89]!==pe.handleSessionSelect||e[90]!==M||e[91]!==S||e[92]!==C||e[93]!==B||e[94]!==A||e[95]!==Q||e[96]!==ue||e[97]!==le||e[98]!==W||e[99]!==E||e[100]!==K||e[101]!==R?(te=s.jsx(Ck,{expandedParents:k,hasSessionSearchQuery:w,normalizedSessionSearchQuery:h,notifyOnSubtasks:g,editingId:j,editingRowKey:b,setEditingId:S,setEditingRowKey:C,editTitle:v,setEditTitle:M,handleSaveEdit:pe.handleSaveEdit,handleCancelEdit:pe.handleCancelEdit,toggleParent:R,handleSessionSelect:pe.handleSessionSelect,handleSessionDoubleClick:pe.handleSessionDoubleClick,handleCopySessionId:pe.handleCopySessionId,openSidebarMenuKey:I,setOpenSidebarMenuKey:B,createFolderAndStartRename:Ce,handleDeleteSession:pe.handleDeleteSession,handleRestoreSession:pe.handleRestoreSession,startSessionWorktreeMenuLoad:A,onEditProject:D,mobileVariant:P,alwaysShowActions:Z,pinnedSessionIds:x,node:n,depth:se,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:ce,secondaryMeta:u,renderContext:re,rowKey:ae,dragKey:Q,subtreeContainsEditing:ue,menuOpenSessionId:le,nodeStructureKey:W,relativeTimeTick:E,children:K}),e[60]=Z,e[61]=ce,e[62]=Ce,e[63]=se,e[64]=v,e[65]=j,e[66]=b,e[67]=ae,e[68]=k,e[69]=l,e[70]=i,e[71]=w,e[72]=P,e[73]=n,e[74]=h,e[75]=g,e[76]=D,e[77]=I,e[78]=x,e[79]=o,e[80]=re,e[81]=u,e[82]=a,e[83]=pe.handleCancelEdit,e[84]=pe.handleCopySessionId,e[85]=pe.handleDeleteSession,e[86]=pe.handleRestoreSession,e[87]=pe.handleSaveEdit,e[88]=pe.handleSessionDoubleClick,e[89]=pe.handleSessionSelect,e[90]=M,e[91]=S,e[92]=C,e[93]=B,e[94]=A,e[95]=Q,e[96]=ue,e[97]=le,e[98]=W,e[99]=E,e[100]=K,e[101]=R,e[102]=te):te=e[102];let oe;e[103]!==_||e[104]!==n.session.id||e[105]!==pe.confirmDeleteSession||e[106]!==Y||e[107]!==ke||e[108]!==me?(oe=_?.session.id===n.session.id?s.jsx(Pk,{value:_,setValue:Y,showDeletionDialog:me,setShowDeletionDialog:ke,onConfirm:pe.confirmDeleteSession}):null,e[103]=_,e[104]=n.session.id,e[105]=pe.confirmDeleteSession,e[106]=Y,e[107]=ke,e[108]=me,e[109]=oe):oe=e[109];let he;return e[110]!==te||e[111]!==oe?(he=s.jsxs(s.Fragment,{children:[te,oe]}),e[110]=te,e[111]=oe,e[112]=he):he=e[112],he}function Ek(t){return t.setShowDeletionDialog}function Rk(t){return t.showDeletionDialog}function Mk(t){return t.toggleFolderCollapse}function Ok(t){return t.createFolder}const Bk=(t,e)=>t.session.id===e.session.id&&t.session.title===e.session.title&&t.session.directory===e.session.directory&&t.session.parentID===e.session.parentID&&t.session.time?.created===e.session.time?.created&&t.session.time?.updated===e.session.time?.updated&&t.session.time?.archived===e.session.time?.archived&&ru(t.session,e.session)&&xt(t.worktree?.path??null)===xt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch&&t.children.length===e.children.length,Fk=(t,e)=>{if(t.node!==e.node&&!Bk(t.node,e.node)||(t.renderExtras?.nodeStructureKey??"")!==(e.renderExtras?.nodeStructureKey??"")||(t.renderExtras?.menuOpenSessionId??null)!==(e.renderExtras?.menuOpenSessionId??null)||t.renderExtras?.relativeTimeTick!==e.renderExtras?.relativeTimeTick)return!1;const n=e.node.session.id;if((t.renderExtras?.subtreeContainsEditing?.has(n)??!1)!==(e.renderExtras?.subtreeContainsEditing?.has(n)??!1)||(t.secondaryMeta?.projectLabel??null)!==(e.secondaryMeta?.projectLabel??null)||(t.secondaryMeta?.branchLabel??null)!==(e.secondaryMeta?.branchLabel??null))return!1;const r=["depth","groupDirectory","projectId","folderOwnerKey","selectionScopeKey","archivedBucket","renderContext","rowKey","dragKey","renderChildren","hasSessionSearchQuery","normalizedSessionSearchQuery","notifyOnSubtasks","editingId","editingRowKey","editTitle","openSidebarMenuKey","mobileVariant","alwaysShowActions","allowReselect","pinnedSessionIds","expandedParents","deleteSessionConfirm","setEditingId","setEditingRowKey","setEditTitle","toggleParent","setOpenSidebarMenuKey","startSessionWorktreeMenuLoad","onEditProject","onSessionSelected","resetSessionSearch","setDeleteSessionConfirm","startFolderRename"];for(const i of r)if(t[i]!==e[i])return!1;return!0},Zo=c.memo(Tk,Fk),_k=24,Lk=t=>Array.from({length:Math.min(t,_k)},(e,n)=>n),$k=(t,e,n)=>{const r=new Set(t);for(const i of e)i>=0&&i<n&&r.add(i);return[...r].sort((i,o)=>i-o)},zk=(t,e)=>t.find(n=>n.end>e)?.index??0;function ad(t,e){return e?.kind==="activity-header"||e?.kind==="project-header"||e?.kind==="group-header"&&t.kind!=="project-header"?"pb-2":void 0}function Wk({model:t,scrollElement:e,pinnedRowIndexes:n,renderRow:r,onFirstVisibleIndexChange:i}){const o=t.rows,l=c.useCallback(()=>e,[e]),a=c.useCallback(w=>o[w]?.estimateSize??32,[o]),d=c.useCallback(w=>o[w]?.key??w,[o]),u=c.useCallback(w=>$k(Nb(w),n,o.length),[n,o.length]),m=Cb({count:o.length,enabled:e!==null,getScrollElement:l,estimateSize:a,getItemKey:d,overscan:8,rangeExtractor:u}),f=m.getVirtualItems(),p=e?m.getTotalSize():0,y=e?Math.max(p-e.clientHeight,0):0,x=e?Math.min(e.scrollTop,y):0,k=zk(f,x);if(c.useLayoutEffect(()=>{i(k)},[k,i]),!e){const w=Lk(o.length),h=w.reduce((j,b)=>j+(o[b]?.estimateSize??0),0),g=o.reduce((j,b)=>j+b.estimateSize,0);return s.jsxs("div",{"data-sidebar-virtual-pending":"true",children:[w.map(j=>{const b=o[j];return b?s.jsx("div",{className:ad(b,o[j+1]),children:r(b,j)},b.key):null}),g>h?s.jsx("div",{"aria-hidden":"true",style:{height:g-h}}):null]})}return s.jsx("div",{"data-sidebar-virtual-ready":"true",style:{height:p,position:"relative"},children:f.map(w=>{const h=o[w.index];return h?s.jsx("div",{className:`[&_[data-session-row]]:my-px ${ad(h,o[w.index+1])??""}`,"data-index":w.index,"data-sidebar-virtual-start":w.start,ref:m.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${w.start}px)`},children:r(h,w.index)},h.key):null})})}const Kk={chats:"chat-4","active-now":"history",timeline:"folder"},ld={chats:"sessions.sidebar.activity.chatsTitle","active-now":"sessions.sidebar.activity.recentTitle",timeline:"sessions.sidebar.activity.timelineTitle"},Vk=t=>{const e=et.c(48),{activityKey:n,collapsed:r,forceExpanded:i,alwaysShowActions:o,onToggle:l,onNewChat:a,timelineView:d}=t,u=d===void 0?!1:d,{t:m}=kt(),f=n==="chats";if(u){const O=i?void 0:l;let T;e[0]===Symbol.for("react.memo_cache_sentinel")?(T=Re("group flex w-full items-center gap-1 py-2 pl-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","pr-3.5"),e[0]=T):T=e[0];const $=!r,_=ld[n];let Y;e[1]!==m||e[2]!==_?(Y=m(_),e[1]=m,e[2]=_,e[3]=Y):Y=e[3];let L;e[4]!==Y?(L=s.jsx("span",{className:"typography-ui-label font-semibold lowercase text-foreground",children:Y}),e[4]=Y,e[5]=L):L=e[5];let A;e[6]!==r||e[7]!==i?(A=i?null:s.jsx(F,{name:r?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5 text-muted-foreground"}),e[6]=r,e[7]=i,e[8]=A):A=e[8];let D;return e[9]!==i||e[10]!==O||e[11]!==$||e[12]!==L||e[13]!==A?(D=s.jsx("div",{className:"relative group/chats -mr-2",children:s.jsxs("button",{type:"button",onClick:O,disabled:i,className:T,"aria-expanded":$,children:[L,A]})}),e[9]=i,e[10]=O,e[11]=$,e[12]=L,e[13]=A,e[14]=D):D=e[14],D}const p=i?void 0:l,y=f?"pr-10":"pr-3.5";let x;e[15]!==y?(x=Re("group flex w-full items-center gap-1.5 py-1 pl-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",y),e[15]=y,e[16]=x):x=e[16];const k=!r,w=Kk[n],h=!i&&"group-hover:hidden";let g;e[17]!==h?(g=Re("h-3.5 w-3.5 text-muted-foreground/80",h),e[17]=h,e[18]=g):g=e[18];let j;e[19]!==w||e[20]!==g?(j=s.jsx(F,{name:w,className:g}),e[19]=w,e[20]=g,e[21]=j):j=e[21];let b;e[22]!==r||e[23]!==i?(b=i?null:s.jsx("span",{className:"hidden h-3.5 w-3.5 items-center justify-center text-muted-foreground group-hover:inline-flex",children:s.jsx(F,{name:r?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}),e[22]=r,e[23]=i,e[24]=b):b=e[24];let S;e[25]!==b||e[26]!==j?(S=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[j,b]}),e[25]=b,e[26]=j,e[27]=S):S=e[27];const C=ld[n];let v;e[28]!==m||e[29]!==C?(v=m(C),e[28]=m,e[29]=C,e[30]=v):v=e[30];let M;e[31]!==v?(M=s.jsx("span",{className:"typography-ui-label font-semibold lowercase text-foreground",children:v}),e[31]=v,e[32]=M):M=e[32];let R;e[33]!==i||e[34]!==S||e[35]!==M||e[36]!==p||e[37]!==x||e[38]!==k?(R=s.jsxs("button",{type:"button",onClick:p,disabled:i,className:x,"aria-expanded":k,children:[S,M]}),e[33]=i,e[34]=S,e[35]=M,e[36]=p,e[37]=x,e[38]=k,e[39]=R):R=e[39];let I;e[40]!==o||e[41]!==f||e[42]!==a||e[43]!==m?(I=f?s.jsx("button",{type:"button",onClick:O=>{O.stopPropagation(),a()},className:Re("absolute right-0.5 top-1/2 z-10 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",o?"opacity-100":"opacity-0 pointer-events-none group-hover/chats:opacity-100 group-hover/chats:pointer-events-auto group-focus-within/chats:opacity-100 group-focus-within/chats:pointer-events-auto"),"aria-label":m("sessions.sidebar.header.actions.newSession"),children:s.jsx(F,{name:"add",className:"h-4 w-4"})}):null,e[40]=o,e[41]=f,e[42]=a,e[43]=m,e[44]=I):I=e[44];let B;return e[45]!==R||e[46]!==I?(B=s.jsxs("div",{className:"relative group/chats -ml-2.5 -mr-2",children:[R,I]}),e[45]=R,e[46]=I,e[47]=B):B=e[47],B},Uk=(t,e)=>{const n=t.groups.find(o=>o.isMain&&o.sessions.length>0)??t.groups.find(o=>o.sessions.length>0)??t.groups.find(o=>o.isMain)??t.groups[0];if(!n)return[];const r=t.groups.find(o=>o.isArchivedBucket&&o.id!==n.id);return(e.mainWorkspaceOnly?[n,...r?[r]:[]]:[...t.groups.find(o=>o.isMain)?[t.groups.find(o=>o.isMain)]:[],...t.groups.filter(o=>!o.isMain)]).map(o=>({group:o,groupKey:`${t.project.id}:${o.id}`,projectId:t.project.id,hideGroupLabel:e.mainWorkspaceOnly?o.id===n.id:o.isMain}))},Hk=[],Gk=32,qk=64,Yk=3,Qk=7,No=32,Qn=28,cd=(t,e,n,r)=>{const i=r.get(t.session.id),o=r.get(e.session.id);if(i!==void 0||o!==void 0){if(i===void 0)return 1;if(o===void 0)return-1;if(i!==o)return i-o}return sl(t.session,e.session,n,Xa)},Ki=t=>{const e=new Map,n=new Map,r=[],i=new WeakMap,o=t.map(l=>({node:l,visited:!1})).reverse();for(;o.length>0;){const l=o.pop();if(!l)continue;if(!l.visited){e.set(l.node.session.id,l.node),n.set(l.node.session.id,l.node.session);const d=r.length;r.push(l.node.session.id),i.set(l.node,[d,d+1]),o.push({node:l.node,visited:!0});for(let u=l.node.children.length-1;u>=0;u-=1){const m=l.node.children[u];m&&o.push({node:m,visited:!1})}continue}const a=i.get(l.node);a&&i.set(l.node,Object.freeze([a[0],r.length]))}return{byId:e,sessionsById:n,preorderIds:Object.freeze(r),subtreeRangeByNode:i}},Xk=(t,e,n)=>`${t}:${e?"archived":"active"}:${n}`,Jk=(t,e)=>{let n=null;for(const r of t){if(r.rowIndex>e)break;n=r}return n},Zk=t=>{const e=[],n=[],r=[],i=[],o=[],l=new Map,a=new Map,d=t.mode==="search",u=t.pinnedSessionIds instanceof Set?t.pinnedSessionIds:new Set(t.pinnedSessionIds);let m=0;const p=[...[...t.authoritativeSections.flatMap(S=>S.groups.flatMap(C=>C.sessions)),...t.chatGroup?.sessions??[]]];for(;p.length>0;){const S=p.pop();S&&(l.set(S.session.id,S.session),p.push(...S.children))}const y=S=>{const C=a.get(S)??0;return a.set(S,C+1),C===0?S:`${S}:${C}`},x=S=>{e.push(Object.freeze(S))},k=S=>{const C=[...S.nodes].reverse().map(v=>({node:v,depth:0,directory:S.groupDirectory}));for(;C.length>0;){const v=C.pop();if(!v)continue;const M=y(`${S.containerKey}:session:${v.node.session.id}`),R=v.node.session.directory??v.directory;l.set(v.node.session.id,v.node.session),x({kind:"session",key:M,estimateSize:S.renderContext==="timeline"?qk:Gk,node:v.node,depth:v.depth,projectId:S.projectId,groupDirectory:v.directory,ownerKey:S.ownerKey,selectionScopeKey:S.selectionScopeKey,archived:S.archived,renderContext:S.renderContext,secondaryMeta:S.getSecondaryMeta?S.getSecondaryMeta(v.node.session.id):S.secondaryMeta??null});const I=S.indexedNodes?.subtreeRangeByNode.get(v.node),B=I&&I[1]>I[0]+1?Object.freeze([(S.selectionPoolOffset??0)+I[0]+1,(S.selectionPoolOffset??0)+I[1]]):void 0;if(n.push(Object.freeze({id:v.node.session.id,rowKey:M,scopeKey:S.selectionScopeKey,archived:S.archived,descendantRange:B})),!(!d&&!t.expandedParents.has(Xk(S.renderContext,S.archived,v.node.session.id))))for(let O=v.node.children.length-1;O>=0;O-=1){const T=v.node.children[O];T&&C.push({node:T,depth:v.depth+1,directory:R})}}},w=(S,C,v,M,R)=>{const I=t.groupSearchDataByGroup.get(S);if(d&&I?.hasMatch!==!0)return;d&&I&&(m+=I.matchedSessionCount+I.folderNameMatchCount+(I.groupMatches?1:0));const B=[...d?I?.filteredNodes??[]:S.sessions].sort((ne,xe)=>cd(ne,xe,u,t.sessionOrderIndex)),O=Ki(B),T=r.length;r.push(...O.preorderIds);for(const[ne,xe]of O.sessionsById)l.set(ne,xe);const $=nr(v,S.directory),_=!d&&t.collapsedGroups.has(C);if(!M){const ne=O.preorderIds.flatMap(xe=>O.sessionsById.get(xe)??[]);x({kind:"group-header",key:`${C}:header`,estimateSize:No,group:S,groupKey:C,projectId:v,collapsed:_,forceExpanded:d,allSessions:Object.freeze(ne)})}if(_)return;const Y=eo(S).flatMap(({scopeKey:ne,directory:xe})=>(t.foldersMap[ne]??Hk).map(U=>({folder:U,scopeKey:ne,scopeDirectory:xe,ownerKey:$,nodes:Da(U.sessionIds,O.byId).sort((z,Q)=>cd(z,Q,u,t.sessionOrderIndex))}))),L=nm(Y.map(ne=>({id:ne.folder.id,name:ne.folder.name,parentId:ne.folder.parentId,nodeCount:ne.nodes.length})),{archivedBucket:S.isArchivedBucket===!0,searchQuery:d?t.normalizedQuery:""}),A=Y.filter(ne=>L.has(ne.folder.id)),D=new Map(A.map(ne=>[Zn(ne.scopeKey,ne.folder.id),ne])),P=new Map;for(const ne of A){if(!ne.folder.parentId)continue;const xe=Zn(ne.scopeKey,ne.folder.parentId),U=P.get(xe)??[];U.push(ne),P.set(xe,U)}const Z=sm(A.map(ne=>({...ne.folder,scopeKey:ne.scopeKey}))).map(ne=>D.get(Zn(ne.scopeKey??"",ne.id))).filter(ne=>!!ne),X=new Set(A.flatMap(ne=>ne.folder.sessionIds)),se=B.filter(ne=>!X.has(ne.session.id)),ce=new Map,re=Z.map(ne=>({folder:ne,visited:!1})),ge=new Set;for(;re.length>0;){const ne=re.pop();if(!ne)continue;const xe=Zn(ne.folder.scopeKey,ne.folder.folder.id);if(!ne.visited){if(ge.has(xe))continue;ge.add(xe),re.push({folder:ne.folder,visited:!0});for(const z of P.get(xe)??[])re.push({folder:z,visited:!1});continue}const U=ne.folder.nodes.flatMap(z=>{const Q=O.subtreeRangeByNode.get(z);return Q?O.preorderIds.slice(Q[0],Q[1]).flatMap(ue=>O.sessionsById.get(ue)??[]):[z.session]});for(const z of P.get(xe)??[])U.push(...ce.get(Zn(z.scopeKey,z.folder.id))??[]);ce.set(xe,Object.freeze(U))}const ae=new Set,Ee=(ne,xe)=>{const U=Zn(ne.scopeKey,ne.folder.id);if(ae.has(U))return;ae.add(U);const z=xe?`${xe} / ${ne.folder.name}`:ne.folder.name,Q=`${C}:folder:${U}`,ue=!d&&t.collapsedFolders.has(ne.folder.id),le=ce.get(U)??[],W=ue&&!S.isArchivedBucket?Da([...new Set(le.map(te=>te.id))],O.byId):[],E=$?t.folderAuthorityByOwner.get($):void 0,K=!!$&&!S.isArchivedBucket&&!ml(ne.scopeKey)&&E?.complete===!0&&E.scopeKeys.includes(ne.scopeKey);if(x({kind:"folder-header",key:Q,estimateSize:No,group:S,folder:ne.folder,displayName:z,scopeKey:ne.scopeKey,scopeDirectory:ne.scopeDirectory,ownerKey:$,nodes:ne.nodes,activityNodes:W,projectId:v,archived:S.isArchivedBucket===!0,collapsed:ue,forceExpanded:d,deleteSessions:le,subFolderCount:P.get(U)?.length??0,dropEnabled:K}),$&&o.push(Object.freeze({rowKey:Q,scopeKey:ne.scopeKey,folderId:ne.folder.id,ownerKey:$,enabled:K})),!ue){k({nodes:ne.nodes,containerKey:Q,projectId:v,groupDirectory:ne.scopeDirectory??S.directory,ownerKey:$,selectionScopeKey:$,archived:S.isArchivedBucket===!0,renderContext:"project",indexedNodes:O,selectionPoolOffset:T});for(const te of P.get(U)??[])Ee(te,z)}};for(const ne of Z)Ee(ne,"");const Se=v?t.sessionBatchSize:void 0,me=R?.initial??Se??(t.hideDirectoryControls?10:5),ke=R?.increment??Se??7,V=Math.max(me,t.visibleCountByContainer.get(C)??me),J=ne=>R?.pinnedAlwaysVisible===!0&&Gu(u,ne.session.directory??S.directory,ne.session.id),de=se.filter(ne=>!J(ne));let we=V;const G=S.isArchivedBucket||d?se:se.filter(ne=>J(ne)?!0:we<=0?!1:(we-=1,!0));k({nodes:G,containerKey:C,projectId:v,groupDirectory:S.directory,ownerKey:$,selectionScopeKey:$,archived:S.isArchivedBucket===!0,renderContext:R?.renderContext??"project",indexedNodes:O,selectionPoolOffset:T});const Ce=se.length-G.length,Te=V-we;!d&&!S.isArchivedBucket&&Ce>0?x({kind:"show-control",key:`${C}:more`,estimateSize:Qn,control:"more",containerKey:C,currentCount:Te,increment:ke}):!d&&!S.isArchivedBucket&&de.length>me&&Ce===0&&x({kind:"show-control",key:`${C}:fewer`,estimateSize:Qn,control:"fewer",containerKey:C,currentCount:Te,increment:ke});const pe=t.groupStatusByKey.get(C);B.length===0&&A.length===0?pe&&pe.state!=="ready"?x({kind:"status",key:`${C}:status`,estimateSize:Qn,status:pe,group:S,groupKey:C}):x({kind:"empty",key:`${C}:empty`,estimateSize:Qn,emptyKind:S.isArchivedBucket?"archived":"group",group:S,projectId:v}):pe&&pe.state!=="ready"&&pe.state!=="loading"&&x({kind:"status",key:`${C}:status`,estimateSize:Qn,status:pe,group:S,groupKey:C})},h=S=>{const C=!d&&t.collapsedActivities.has(S),v=e.length;return x({kind:"activity-header",key:`activity:${S}:header`,estimateSize:No,activityKey:S,collapsed:C,forceExpanded:d}),i.push(Object.freeze({rowIndex:v,kind:"activity",id:S})),C},g=t.viewMode==="timeline";if(t.chatGroup){const S=t.groupSearchDataByGroup.get(t.chatGroup);(!d||S?.hasMatch===!0)&&(h("chats")||w(t.chatGroup,"activity:chats",null,!0,g?{initial:Yk,increment:Qk,pinnedAlwaysVisible:!0,renderContext:"timeline-chat"}:void 0))}if(g){const S=t.timelineItems??[];if(S.length>0&&!h("timeline")){const v="activity:timeline";for(const M of S){const R=Ki([M.node]),I=r.length;r.push(...R.preorderIds);const B=nr(M.projectId,M.groupDirectory);k({nodes:[M.node],containerKey:v,projectId:M.projectId,groupDirectory:M.groupDirectory,ownerKey:B,selectionScopeKey:null,archived:!1,renderContext:"timeline",secondaryMeta:M.secondaryMeta,indexedNodes:R,selectionPoolOffset:I}),d&&(m+=1)}}}if(!g&&t.showRecentSection)for(const S of t.recentSections){if(S.items.length===0||h("active-now"))continue;const v=`activity:${S.key}`,M=7,R=Math.max(M,t.visibleCountByContainer.get(v)??M),I=d?S.items:S.items.slice(0,R);for(const O of I){const T=Ki([O.node]),$=r.length;r.push(...T.preorderIds),k({nodes:[O.node],containerKey:v,projectId:O.projectId,groupDirectory:O.groupDirectory,ownerKey:nr(O.projectId,O.groupDirectory),selectionScopeKey:nr(O.projectId,O.groupDirectory),archived:!1,renderContext:"recent",secondaryMeta:O.secondaryMeta,getSecondaryMeta:O.getSecondaryMeta,indexedNodes:T,selectionPoolOffset:$}),d&&(m+=1)}const B=S.items.length-I.length;!d&&B>0?x({kind:"show-control",key:`${v}:more`,estimateSize:Qn,control:"more",containerKey:v,currentCount:I.length,increment:7}):!d&&S.items.length>M&&x({kind:"show-control",key:`${v}:fewer`,estimateSize:Qn,control:"fewer",containerKey:v,currentCount:I.length,increment:7})}let j=g?[]:t.singleProjectMode?t.sections.filter(S=>S.project.id===t.singleProjectId):[...t.sections];if(t.showOnlyMainWorkspace){const S=j.find(C=>C.project.id===t.activeProjectId)??j[0];j=S?[S]:[]}for(const S of j){const C=!d&&!t.singleProjectMode&&!t.showOnlyMainWorkspace&&t.collapsedProjects.has(S.project.id);if(!t.showOnlyMainWorkspace){const M=e.length;x({kind:"project-header",key:`project:${S.project.id}:header`,estimateSize:No,section:S,collapsed:C,forceExpanded:d}),i.push(Object.freeze({rowIndex:M,kind:"project",id:S.project.id}))}if(C)continue;const v=Uk(S,{mainWorkspaceOnly:t.showOnlyMainWorkspace});for(const M of v)w(M.group,M.groupKey,M.projectId,M.hideGroupLabel)}e.length===0&&x({kind:"empty",key:d?"sidebar:search-empty":"sidebar:empty",estimateSize:72,emptyKind:d?"search":"sidebar"});const b=new Map;return e.forEach((S,C)=>b.set(S.key,C)),Object.freeze({rows:Object.freeze(e),selectionEntries:Object.freeze(n),selectionDescendantIds:Object.freeze(r),rowIndexByKey:b,stickyHeaders:Object.freeze(i),folderDropTargets:Object.freeze(o),folderAuthorityByOwner:t.folderAuthorityByOwner,sessionById:l,searchMatchCount:d?m:0})},um=c.createContext(null);function dd(t){let e=0,n=t;for(;n;){e+=n.offsetTop;const o=n.offsetParent;n=o instanceof HTMLElement?o:null}const r=t.closest("[data-sidebar-virtual-start]"),i=Number(r?.dataset.sidebarVirtualStart??"0");return e+(Number.isFinite(i)?i:0)}function e3(t){const e=et.c(14),{enabled:n,suspended:r,layoutKey:i,scrollRef:o,children:l}=t,a=r===void 0?!1:r,d=i===void 0?"":i;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,e[0]=u):u=e[0];const m=c.useRef(u),f=c.useRef(null);let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=g=>(m.current.add(g),f.current?.(),()=>{m.current.delete(g),f.current?.()}),e[1]=p):p=e[1];const y=p;let x;e[2]!==n||e[3]!==o||e[4]!==a?(x=()=>{const g=o.current;if(!n||a||!g)return;const j=document.createElement("div");j.dataset.sidebarCrossfadeLayer="true",j.className="pointer-events-none sticky top-0 z-30 h-0",j.style.marginBlock="0px",g.prepend(j);let b=null,S=null,C=null,v=0;const M=new Set;let R=[];const I=window.matchMedia("(prefers-reduced-motion: reduce)"),B=s3,O=()=>{C?.cancel(),C=null,S?.remove(),S=null},T=()=>{let A=null,D=-1/0;for(const{entry:P,top:Z}of R)Z<=g.scrollTop&&Z>=D&&(D=Z,A=P);if(b!==A){if(O(),b&&A&&!I.matches){const P=b.host.cloneNode(!0);P instanceof HTMLElement&&(P.inert=!0,P.setAttribute("aria-hidden","true"),P.querySelectorAll("[id]").forEach(t3),P.className="pointer-events-none absolute inset-x-0 top-0 z-30",S=P)}b&&(B(b,b.slot),b.slot.style.removeProperty("height")),b=A,j.hidden=!A,A&&(A.slot.style.height=`${A.host.getBoundingClientRect().height}px`,B(A,j),S&&(j.append(S),C=S.animate([{opacity:1},{opacity:0}],{duration:150,easing:"ease-out"}),C.onfinish=O))}},$=()=>{b&&(b.slot.style.height=`${b.host.getBoundingClientRect().height}px`);const A=dd(g)+g.clientTop;R=Array.from(m.current,D=>({entry:D,top:dd(D.slot)-A})),T()},_=new ResizeObserver($),Y=new MutationObserver(()=>{cancelAnimationFrame(v),v=requestAnimationFrame($)});_.observe(g);const L=()=>{Y.disconnect();for(const A of M)m.current.has(A)||(_.unobserve(A.host),A.slot.parentElement&&_.unobserve(A.slot.parentElement),M.delete(A));for(const A of m.current){const D=A.slot.closest("[data-sidebar-virtual-start]");D&&Y.observe(D,{attributes:!0,attributeFilter:["data-sidebar-virtual-start"]}),M.has(A)||(_.observe(A.host),A.slot.parentElement&&_.observe(A.slot.parentElement),M.add(A))}cancelAnimationFrame(v),v=requestAnimationFrame($)};return f.current=L,g.addEventListener("scroll",T,{passive:!0}),L(),$(),()=>{f.current=null,cancelAnimationFrame(v),g.removeEventListener("scroll",T),_.disconnect(),Y.disconnect(),O(),j.hidden=!0,b&&(B(b,b.slot),b.slot.style.removeProperty("height")),j.remove()}},e[2]=n,e[3]=o,e[4]=a,e[5]=x):x=e[5];let k;e[6]!==n||e[7]!==d||e[8]!==o||e[9]!==a?(k=[n,a,d,o],e[6]=n,e[7]=d,e[8]=o,e[9]=a,e[10]=k):k=e[10],c.useLayoutEffect(x,k);const w=n?y:null;let h;return e[11]!==l||e[12]!==w?(h=s.jsx(um.Provider,{value:w,children:l}),e[11]=l,e[12]=w,e[13]=h):h=e[13],h}function t3(t){return t.removeAttribute("id")}function s3(t,e){const n=document.activeElement,r=n instanceof HTMLElement&&t.host.contains(n);e.moveBefore&&e.isConnected&&t.host.isConnected?e.moveBefore(t.host,null):e.append(t.host),r&&n.focus({preventScroll:!0})}function n3(t){const e=et.c(15);let n,r;e[0]!==t?({register:r,...n}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);const i=c.useRef(null),[o]=c.useState(r3);let l,a;e[3]!==o||e[4]!==r?(l=()=>{const p=i.current;if(!p)return;p.append(o);const y=r({slot:p,host:o});return()=>{y(),o.remove()}},a=[o,r],e[3]=o,e[4]=r,e[5]=l,e[6]=a):(l=e[5],a=e[6]),c.useLayoutEffect(l,a);let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx("div",{ref:i}),e[7]=d):d=e[7];let u;e[8]!==n?(u=s.jsx("div",{...n}),e[8]=n,e[9]=u):u=e[9];let m;e[10]!==o||e[11]!==u?(m=Hm.createPortal(u,o),e[10]=o,e[11]=u,e[12]=m):m=e[12];let f;return e[13]!==m?(f=s.jsxs(s.Fragment,{children:[d,m]}),e[13]=m,e[14]=f):f=e[14],f}function r3(){const t=document.createElement("div");return t.className="pointer-events-auto flow-root",t}function fm(t){const e=et.c(3),n=c.useContext(um);let r;return e[0]!==t||e[1]!==n?(r=n?s.jsx(n3,{...t,register:n}):s.jsx("div",{...t}),e[0]=t,e[1]=n,e[2]=r):r=e[2],r}const Vi=t=>{const e=et.c(22),{id:n,projectLabel:r,projectIcon:i,projectColor:o,projectIconImage:l,projectIconBackground:a,isCollapsed:d,alwaysShowActions:u}=t,m=u===void 0?!1:u,{currentTheme:f}=Kn(),p=i?oi[i]:null,y=o?ii[o]??null:null,x=d!==void 0,k=x?m?"hidden":"group-hover/project:hidden group-focus-within/project:hidden":void 0;let w;e[0]!==m||e[1]!==x||e[2]!==d?(w=x?s.jsx("span",{className:Re("h-3.5 w-3.5 items-center justify-center text-muted-foreground",m?"inline-flex":"hidden group-hover/project:inline-flex group-focus-within/project:inline-flex"),children:s.jsx(F,{name:d?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[0]=m,e[1]=x,e[2]=d,e[3]=w):w=e[3];let h;e[4]!==m||e[5]!==f||e[6]!==x||e[7]!==y||e[8]!==k||e[9]!==n||e[10]!==a||e[11]!==l||e[12]!==p?(h=l?s.jsx("span",{className:Re("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",x&&m?"hidden":"inline-flex",k),style:a?{backgroundColor:a}:void 0,children:s.jsx(ai,{project:{id:n,iconImage:l},options:{themeVariant:f.metadata.variant,iconColor:f.colors.surface.foreground},className:"h-full w-full object-contain",fallback:p?s.jsx(F,{name:p,className:"h-3.5 w-3.5",style:y?{color:y}:void 0}):s.jsx(F,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:y?{color:y}:void 0})})}):p?s.jsx(F,{name:p,className:Re("h-3.5 w-3.5",k),style:y?{color:y}:void 0}):s.jsx(F,{name:"folder",className:Re("h-3.5 w-3.5 text-muted-foreground/80",k),style:y?{color:y}:void 0}),e[4]=m,e[5]=f,e[6]=x,e[7]=y,e[8]=k,e[9]=n,e[10]=a,e[11]=l,e[12]=p,e[13]=h):h=e[13];let g;e[14]!==w||e[15]!==h?(g=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[w,h]}),e[14]=w,e[15]=h,e[16]=g):g=e[16];let j;e[17]!==r?(j=s.jsx("span",{className:"truncate typography-ui-label font-semibold lowercase text-foreground",children:r}),e[17]=r,e[18]=j):j=e[18];let b;return e[19]!==g||e[20]!==j?(b=s.jsxs(s.Fragment,{children:[g,j]}),e[19]=g,e[20]=j,e[21]=b):b=e[21],b},o3=t=>{const e=et.c(60),{id:n,disabled:r,projectLabel:i,projectDescription:o,projectDirectory:l,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:m,isCollapsed:f,isRepo:p,hideDirectoryControls:y,alwaysShowActions:x,onToggle:k,onNewSession:w,onNewWorktreeSession:h,onManageWorktrees:g,onRenameStart:j,onClose:b,children:S,showCreateButtons:C,hideHeader:v,statusIndicator:M,openSidebarMenuKey:R,setOpenSidebarMenuKey:I,projectPickerOptions:B,onProjectSelect:O}=t,T=r===void 0?!1:r,$=C===void 0?!0:C,_=v===void 0?!1:v,Y=M===void 0?null:M,{t:L}=kt();let A;e[0]!==T||e[1]!==n?(A={id:n,disabled:T},e[0]=T,e[1]=n,e[2]=A):A=e[2];const{attributes:D,listeners:P,setNodeRef:Z,transform:X,transition:se,isDragging:ce}=pi(A),re=c.useRef(!1),ge=`project:${n}`,ae=R===ge,[Ee,Se]=c.useState(!1),me=!!(B&&O);let ke;e[3]!==ge||e[4]!==I?(ke=E=>{E&&Se(!1),I(E?ge:null)},e[3]=ge,e[4]=I,e[5]=ke):ke=e[5];const V=ke;let J;e[6]!==y||e[7]!==p||e[8]!==b||e[9]!==g||e[10]!==w||e[11]!==j||e[12]!==$||e[13]!==L?(J=E=>s.jsxs(s.Fragment,{children:[$&&!p&&!y&&w&&s.jsxs(E,{onClick:w,children:[s.jsx(F,{name:"add",className:"mr-1.5 h-4 w-4"}),L("sessions.sidebar.project.actions.newSession")]}),p&&!y&&g&&s.jsxs(E,{onClick:g,children:[s.jsx(F,{name:"node-tree",className:"mr-1.5 h-4 w-4"}),L("sessions.sidebar.project.actions.manageWorktrees")]}),s.jsxs(E,{onClick:j,children:[s.jsx(F,{name:"pencil-ai",className:"mr-1.5 h-4 w-4"}),L("sessions.sidebar.project.actions.edit")]}),s.jsxs(E,{onClick:b,className:"text-destructive focus:text-destructive",children:[s.jsx(F,{name:"close",className:"mr-1.5 h-4 w-4"}),L("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=y,e[7]=p,e[8]=b,e[9]=g,e[10]=w,e[11]=j,e[12]=$,e[13]=L,e[14]=J):J=e[14];const de=J,we=l3,G=c3,Ce=d3;let Te;e[15]===Symbol.for("react.memo_cache_sentinel")?(Te=E=>{(E.button===2||E.button===0&&E.ctrlKey)&&(re.current=!0)},e[15]=Te):Te=e[15];const pe=Te;let ne;e[16]!==k?(ne=E=>{if(E.currentTarget.blur(),re.current){re.current=!1;return}k()},e[16]=k,e[17]=ne):ne=e[17];const xe=ne;let U;e[18]!==X?(U=gi.Transform.toString(X),e[18]=X,e[19]=U):U=e[19];let z;e[20]!==U||e[21]!==se?(z={transform:U,transition:se},e[20]=U,e[21]=se,e[22]=z):z=e[22];const Q=ce&&"opacity-30";let ue;e[23]!==Q?(ue=Re("relative",Q),e[23]=Q,e[24]=ue):ue=e[24];let le;e[25]!==x||e[26]!==D||e[27]!==V||e[28]!==xe||e[29]!==y||e[30]!==_||e[31]!==n||e[32]!==f||e[33]!==Ee||e[34]!==ae||e[35]!==me||e[36]!==p||e[37]!==P||e[38]!==w||e[39]!==h||e[40]!==O||e[41]!==d||e[42]!==o||e[43]!==l||e[44]!==a||e[45]!==m||e[46]!==u||e[47]!==i||e[48]!==B||e[49]!==de||e[50]!==$||e[51]!==Y||e[52]!==L?(le=_?null:s.jsx(s.Fragment,{children:s.jsxs(tu,{open:Ee,onOpenChange:Se,children:[s.jsx(eu,{render:s.jsx(fm,{className:Re("-ml-2.5 -mr-2 text-left group/project select-none","sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":"true",onContextMenu:E=>{y||(E.preventDefault(),Se(!0))}}),children:s.jsxs("div",{className:"relative flex items-center gap-1 py-1 pl-4 pr-3.5",...D,children:[me?s.jsxs($s,{children:[s.jsx(_s,{asChild:!0,children:s.jsxs("button",{type:"button",className:Re("flex min-w-0 flex-1 items-center gap-1.5 rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-[padding]",p&&!y?x||ae?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":x||ae?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),"aria-label":L("sessions.sidebar.project.selectAria",{project:i}),children:[s.jsx(Vi,{id:n,projectLabel:i,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:m}),s.jsx(F,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),l?s.jsx(to,{directory:l,className:"ml-auto"}):null]})}),s.jsx(Ls,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:B?.map(E=>s.jsxs(Ht,{onClick:()=>O?.(E.id),className:"flex items-center justify-between gap-3",title:E.projectDescription,children:[s.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:s.jsx(Vi,{...E})}),E.id===n?s.jsx(F,{name:"check",className:"h-4 w-4 flex-shrink-0 text-primary"}):null]},E.id))})]}):s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsxs("button",{type:"button",onMouseDown:pe,onClick:xe,...P,className:Re("flex-1 min-w-0 flex items-center gap-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-md cursor-grab active:cursor-grabbing transition-[padding]",p&&!y?x||ae?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":x||ae?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),children:[s.jsx(Vi,{id:n,projectLabel:i,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:m,isCollapsed:f,alwaysShowActions:x}),Y?s.jsx("span",{className:"ml-1 inline-flex flex-shrink-0 items-center",children:Y}):null,l?s.jsx(to,{directory:l,className:"ml-auto"}):null]})}),s.jsx(St,{side:"right",sideOffset:8,children:o})]}),s.jsxs("div",{className:Re("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",$?"right-7":"right-0.5"),children:[$&&p&&!y&&h?s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),h()},className:Re("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:text-foreground transition-opacity",x?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":L("sessions.sidebar.project.actions.newWorktree"),children:s.jsx(F,{name:"node-tree",className:"h-4 w-4"})})}),s.jsx(St,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:L("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,y?null:s.jsxs($s,{open:ae,onOpenChange:V,children:[s.jsx(_s,{asChild:!0,children:s.jsx("button",{type:"button",className:Re("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition-opacity focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:text-foreground",ae?"opacity-100 pointer-events-auto":x?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":L("sessions.sidebar.project.actions.projectMenu"),onPointerDown:G,onMouseDown:Ce,onClick:we,children:s.jsx(F,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(Ls,{align:"end",className:"min-w-[180px]",children:de(Ht)})]})]}),$&&w?s.jsx("div",{className:"absolute right-0.5 top-1/2 z-10 -translate-y-1/2",children:s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),w()},className:Re("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",x?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":L(p?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:s.jsx(F,{name:"add",className:"h-4 w-4"})})}),s.jsx(St,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:L(p?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),s.jsx(Zd,{className:"min-w-[180px]",children:de(tr)})]})}),e[25]=x,e[26]=D,e[27]=V,e[28]=xe,e[29]=y,e[30]=_,e[31]=n,e[32]=f,e[33]=Ee,e[34]=ae,e[35]=me,e[36]=p,e[37]=P,e[38]=w,e[39]=h,e[40]=O,e[41]=d,e[42]=o,e[43]=l,e[44]=a,e[45]=m,e[46]=u,e[47]=i,e[48]=B,e[49]=de,e[50]=$,e[51]=Y,e[52]=L,e[53]=le):le=e[53];let W;return e[54]!==S||e[55]!==Z||e[56]!==z||e[57]!==ue||e[58]!==le?(W=s.jsxs("div",{ref:Z,style:z,className:ue,children:[le,S]}),e[54]=S,e[55]=Z,e[56]=z,e[57]=ue,e[58]=le,e[59]=W):W=e[59],W},i3=t=>{const e=et.c(21),{id:n,disabled:r,children:i}=t,o=r===void 0?!1:r;let l;e[0]!==o||e[1]!==n?(l={id:n,disabled:o},e[0]=o,e[1]=n,e[2]=l):l=e[2];const{listeners:a,setNodeRef:d,setActivatorNodeRef:u,transform:m,transition:f,isDragging:p}=pi(l);let y;e[3]!==a||e[4]!==u?(y={listeners:a,setActivatorNodeRef:u},e[3]=a,e[4]=u,e[5]=y):y=e[5];const x=y;let k;e[6]!==m?(k=gi.Transform.toString(m),e[6]=m,e[7]=k):k=e[7];let w;e[8]!==k||e[9]!==f?(w={transform:k,transition:f},e[8]=k,e[9]=f,e[10]=w):w=e[10];const h=p&&"opacity-50";let g;e[11]!==h?(g=Re("space-y-0.5 rounded-md",h),e[11]=h,e[12]=g):g=e[12];let j;e[13]!==i||e[14]!==x?(j=i(x),e[13]=i,e[14]=x,e[15]=j):j=e[15];let b;return e[16]!==d||e[17]!==w||e[18]!==g||e[19]!==j?(b=s.jsx("div",{ref:d,style:w,className:g,children:j}),e[16]=d,e[17]=w,e[18]=g,e[19]=j,e[20]=b):b=e[20],b},a3=c.memo(i3);function l3(t){t.stopPropagation()}function c3(t){t.stopPropagation()}function d3(t){t.stopPropagation()}const ud=[],u3=t=>{const e=et.c(6),{nodes:n,includeUnreadSubtasks:r,children:i}=t;let o;e[0]!==r||e[1]!==n?(o={nodes:n,includeUnreadSubtasks:r},e[0]=r,e[1]=n,e[2]=o):o=e[2];const l=hl(o);let a;return e[3]!==i||e[4]!==l?(a=i(l),e[3]=i,e[4]=l,e[5]=a):a=e[5],a},Ui=(t,e)=>e?t.sessions.some(n=>Pr(n,e)):!1,f3=(t,e,n)=>t.sessions.some(r=>rm(r,r,e,n,t.directory,t.directory)),m3=(t,e,n)=>{const r=i=>{const o=i.session.id;return e.get(o)!==n.get(o)?!0:i.children.some(r)};return t.sessions.some(r)},h3=(t,e,n)=>{const r=t.isArchivedBucket?"archived":"active",i=o=>{const l=`project:${r}:${o.session.id}`;return e.has(l)!==n.has(l)?!0:o.children.some(i)};return t.sessions.some(i)},p3=(t,e)=>{if(t.group!==e.group||t.groupKey!==e.groupKey||t.projectId!==e.projectId||t.hideGroupLabel!==e.hideGroupLabel||t.compactBodyPadding!==e.compactBodyPadding||t.groupSearchDataByGroup!==e.groupSearchDataByGroup||t.visibleSessionCount!==e.visibleSessionCount||t.sessionBatchSize!==e.sessionBatchSize||t.collapsedGroups!==e.collapsedGroups&&t.collapsedGroups.has(t.groupKey)!==e.collapsedGroups.has(e.groupKey)||t.pinnedSessionIds!==e.pinnedSessionIds&&f3(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.sessionOrderIndex!==e.sessionOrderIndex&&m3(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.expandedParents!==e.expandedParents&&h3(e.group,t.expandedParents,e.expandedParents)||t.editingId!==e.editingId&&(Ui(e.group,t.editingId)||Ui(e.group,e.editingId))||t.editingRowKey!==e.editingRowKey||t.editTitle!==e.editTitle&&Ui(e.group,e.editingId))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const n=e.group.isArchivedBucket===!0,r=Xo(e.group.sessions,t.openSidebarMenuKey,"project",n),i=Xo(e.group.sessions,e.openSidebarMenuKey,"project",n);if(r||i)return!1}if(t.folderRename!==e.folderRename){const n=e.group.folderScopes?.map(r=>r.scopeKey)??[e.group.folderScopeKey??xt(e.group.directory??null)];if(n.includes(t.folderRename?.scopeKey??null)||n.includes(e.folderRename?.scopeKey??null))return!1}return t.hasSessionSearchQuery===e.hasSessionSearchQuery&&t.normalizedSessionSearchQuery===e.normalizedSessionSearchQuery&&t.hideDirectoryControls===e.hideDirectoryControls&&t.showMoreGroupSessions===e.showMoreGroupSessions&&t.resetGroupSessionLimit===e.resetGroupSessionLimit&&t.mobileVariant===e.mobileVariant&&t.alwaysShowActions===e.alwaysShowActions&&t.setActiveProjectIdOnly===e.setActiveProjectIdOnly&&t.setSessionSwitcherOpen===e.setSessionSwitcherOpen&&t.openNewSessionDraft===e.openNewSessionDraft&&t.onToggleCollapsedGroup===e.onToggleCollapsedGroup&&t.dragHandleProps===e.dragHandleProps&&t.renderBody===e.renderBody&&t.notifyOnSubtasks===e.notifyOnSubtasks&&t.setEditingId===e.setEditingId&&t.setEditingRowKey===e.setEditingRowKey&&t.setEditTitle===e.setEditTitle&&t.toggleParent===e.toggleParent&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.allowReselect===e.allowReselect&&t.onSessionSelected===e.onSessionSelected&&t.resetSessionSearch===e.resetSessionSearch&&t.deleteSessionConfirm===e.deleteSessionConfirm&&t.setDeleteSessionConfirm===e.setDeleteSessionConfirm&&t.startFolderRename===e.startFolderRename&&t.startSessionWorktreeMenuLoad===e.startSessionWorktreeMenuLoad&&t.setFolderRenameDraft===e.setFolderRenameDraft&&t.clearFolderRename===e.clearFolderRename};function g3(t){const{t:e}=kt(),{group:n,groupKey:r,projectId:i,hideGroupLabel:o,renderBody:l=!0,hasSessionSearchQuery:a,normalizedSessionSearchQuery:d,groupSearchDataByGroup:u,visibleSessionCount:m,sessionBatchSize:f,collapsedGroups:p,hideDirectoryControls:y,showMoreGroupSessions:x,resetGroupSessionLimit:k,mobileVariant:w,alwaysShowActions:h,activeProjectId:g,setActiveProjectIdOnly:j,setSessionSwitcherOpen:b,openNewSessionDraft:S,pinnedSessionIds:C,sessionOrderIndex:v,notifyOnSubtasks:M,onToggleCollapsedGroup:R,dragHandleProps:I,compactBodyPadding:B=!1,expandedParents:O,editingId:T,editingRowKey:$,openSidebarMenuKey:_,editTitle:Y,folderRename:L,setFolderRenameDraft:A,clearFolderRename:D}=t,P=ss(ve=>ve.toggleFolderCollapse),Z=ss(ve=>ve.renameFolder),X=ss(ve=>ve.deleteFolder),se=ss(ve=>ve.addSessionToFolder),ce=Pe(ve=>ve.showDeletionDialog),[re,ge]=c.useState(null),ae=c.useCallback((ve,Qe)=>{const Ge=v.get(ve.session.id),Ze=v.get(Qe.session.id);if(Ge!==void 0||Ze!==void 0){if(Ge===void 0)return 1;if(Ze===void 0)return-1;if(Ge!==Ze)return Ge-Ze}return sl(ve.session,Qe.session,C,Xa)},[C,v]),Ee=a?u.get(n):null,Se=a?!1:p.has(r),me=c.useMemo(()=>{if(n.isMain||n.isArchivedBucket||o)return null;const ve=xt(n.directory??null),Qe=n.branch?.trim();return ve&&Qe?si(ve,Qe):null},[n.branch,n.directory,n.isArchivedBucket,n.isMain,o]),ke=Vu(me),V=ke?`var(--pr-${ke.visualState})`:void 0,J=li(),de=c.useMemo(()=>{const ve=n.folderScopes?.map(Qe=>xt(Qe.directory))??[xt(n.directory??null)];return[...new Set(ve.filter(Qe=>!!Qe))]},[n.directory,n.folderScopes]);c.useSyncExternalStore(c.useCallback(ve=>de.length>0?J.subscribeBootstrap(ve):()=>{},[de.length,J]),c.useCallback(()=>de.map(ve=>`${ve}\0${J.getBootstrapState(ve)??""}\0${J.getBootstrapFailure(ve)??""}\0${J.getInitializationState(ve)??""}\0${J.getInitializationFailure(ve)??""}`).join(""),[de,J]),c.useCallback(()=>"",[]));const we=de.some(ve=>{const Qe=J.getBootstrapState(ve);return Qe==="queued"||Qe==="running"}),G=de.find(ve=>J.getBootstrapState(ve)==="failed"||J.getInitializationState(ve)==="failed")??null,Ce=G!==null&&J.getBootstrapState(G)==="failed",Te=G?Ce?J.getBootstrapFailure(G):J.getInitializationFailure(G):void 0,pe=Te==="os-permission"&&qd(),[ne,xe]=c.useState(!1),U=c.useCallback(()=>{G&&J.requestBootstrap({directory:G,priority:Se?"visible":"expanded",reason:n.isMain?"project-expanded":"worktree-expanded",force:!0})},[J,G,n.isMain,Se]),z=c.useCallback(async()=>{if(!(!G||!pe||ne)){xe(!0);try{(await Yd(G)).success&&U()}finally{xe(!1)}}},[pe,G,ne,U]),Q=f??(y?10:5),ue=Math.max(Q,m??Q),le=a?Ee?.groupMatches===!0:!1,W=a,E=c.useMemo(()=>[...W?Ee?.filteredNodes??[]:n.sessions].sort(ae),[ae,n.sessions,Ee?.filteredNodes,W]),K=n.folderScopeKey??xt(n.directory??null),te=nr(i,n.directory),oe=c.useMemo(()=>n.folderScopes&&n.folderScopes.length>0?n.folderScopes:K?[{scopeKey:K,directory:n.directory??null}]:[],[K,n.directory,n.folderScopes]),he=ss(dr(c.useCallback(ve=>oe.map(({scopeKey:Qe})=>ve.foldersMap[Qe]??ud),[oe]))),ie=c.useMemo(()=>oe.flatMap(({scopeKey:ve,directory:Qe},Ge)=>(he[Ge]??ud).map(lt=>({folder:lt,scopeKey:ve,scopeDirectory:Qe}))),[he,oe]),Fe=ss(dr(c.useCallback(ve=>new Set(he.flatMap(Qe=>Qe.filter(Ge=>ve.collapsedFolderIds.has(Ge.id)).map(Ge=>Ge.id))),[he]))),_e=c.useMemo(()=>{const ve=new Map,Qe=Ge=>{Ge.forEach(Ze=>{ve.set(Ze.session.id,Ze),Ze.children.length>0&&Qe(Ze.children)})};return Qe(E),ve},[E]),Ae=c.useMemo(()=>ie.map(({folder:ve,scopeKey:Qe,scopeDirectory:Ge})=>{const Ze=Da(ve.sessionIds,_e).sort(ae);return{folder:ve,scopeKey:Qe,scopeDirectory:Ge,nodes:Ze}}),[ie,_e,ae]),Me=c.useMemo(()=>{const ve=nm(Ae.map(({folder:Qe,nodes:Ge})=>({id:Qe.id,name:Qe.name,parentId:Qe.parentId,nodeCount:Ge.length})),{archivedBucket:n.isArchivedBucket===!0,searchQuery:a?d:""});return Ae.filter(({folder:Qe})=>ve.has(Qe.id))},[Ae,n.isArchivedBucket,a,d]),q=T,Ne=_,je=c.useMemo(()=>new Set(Me.flatMap(ve=>ve.folder.sessionIds)),[Me]),We=c.useMemo(()=>E.filter(ve=>!je.has(ve.session.id)),[E,je]),tt=c.useMemo(()=>{const ve=new Map(Me.map(Qe=>[Qe.folder.id,Qe]));return sm(Me.map(Qe=>Qe.folder)).map(Qe=>ve.get(Qe.id)).filter(Qe=>!!Qe)},[Me]),it=c.useMemo(()=>{const ve=new Map;return Me.forEach(Qe=>{if(!Qe.folder.parentId)return;const Ge=ve.get(Qe.folder.parentId)??[];Ge.push(Qe),ve.set(Qe.folder.parentId,Ge)}),ve},[Me]),rt=c.useMemo(()=>{const ve=new Map(Me.map(Ze=>[Ze.folder.id,Ze])),Qe=new Map,Ge=(Ze,lt)=>{const Bt=Qe.get(Ze);if(Bt!==void 0)return Bt;if(lt.has(Ze))return[];lt.add(Ze);const $t=ve.get(Ze),Wt=$t?[...$t.nodes]:[];for(const Xt of it.get(Ze)??[])Wt.push(...Ge(Xt.folder.id,lt));return Qe.set(Ze,Wt),Wt};return Me.forEach(({folder:Ze})=>Ge(Ze.id,new Set)),Qe},[Me,it]),ot="project",ft=c.useMemo(()=>{const ve=new Set;return Yc(E,q,ve),Me.forEach(({nodes:Qe})=>{Yc(Qe,q,ve)}),ve},[E,Me,q]),st=c.useMemo(()=>{if(!Ne)return null;const ve=Xo(E,Ne,ot,!!n.isArchivedBucket);if(ve)return ve;for(const{nodes:Qe}of Me){const Ge=Xo(Qe,Ne,ot,!!n.isArchivedBucket);if(Ge)return Ge}return null},[Ne,E,Me,n.isArchivedBucket]),Ct=c.useCallback(ve=>{const Qe=new WeakMap,Ge=Ze=>{Qe.set(Ze,Qo(Ze));for(const lt of Ze.children)Ge(lt)};return ve.forEach(Ge),Qe},[]),ht=c.useMemo(()=>Ct(E),[Ct,E]),be=c.useMemo(()=>{const ve=new WeakMap;return Me.forEach(({nodes:Qe})=>{Qe.forEach(Ge=>ve.set(Ge,Qo(Ge)))}),ve},[Me]),Je=c.useCallback(ve=>ht.get(ve)??be.get(ve)??"",[ht,be]),dt=c.useCallback(ve=>({subtreeContainsEditing:ft,menuOpenSessionId:st,nodeStructureKey:Je(ve)}),[ft,st,Je]),Ke=We.length,mt=n.isArchivedBucket||a?We:We.slice(0,ue),ee=Ke-mt.length,fe=!n.isArchivedBucket&&!a&&Ke>Q&&ee===0,Ie=c.useCallback(ve=>{const Qe=[],Ge=Ze=>{Ze.forEach(lt=>{Qe.push(lt.session),lt.children.length>0&&Ge(lt.children)})};return Ge(ve),Qe},[]),$e=c.useMemo(()=>Ie(E),[Ie,E]),H=c.useMemo(()=>{if(!n.isArchivedBucket)return new Map;const ve=new Map,Qe=new Map;for(const{folder:Ze}of Me){if(!Ze.parentId)continue;const lt=Qe.get(Ze.parentId)??[];lt.push(Ze.id),Qe.set(Ze.parentId,lt)}const Ge=(Ze,lt)=>{if(lt.has(Ze))return[];lt.add(Ze);const Bt=Me.find(({folder:Xt})=>Xt.id===Ze),$t=Bt?Ie(Bt.nodes):[],Wt=Qe.get(Ze)??[];for(const Xt of Wt)$t.push(...Ge(Xt,lt));return $t};for(const{folder:Ze}of Me)ve.set(Ze.id,Ge(Ze.id,new Set));return ve},[Me,Ie,n.isArchivedBucket]);if(a&&!le&&tt.length===0&&We.length===0)return null;const Be=!n.isMain&&!!n.branch,Ye=n.branch&&Yg(n.branch,n.label)?{label:n.branch}:null,qe=Se?s.jsx(u2,{nodes:E,includeUnreadSubtasks:M}):null,Xe=(ve,Qe)=>{const{folder:Ge,scopeKey:Ze,scopeDirectory:lt,nodes:Bt}=ve,$t=H.get(Ge.id)??[],Wt=L?.folderId===Ge.id&&L?.scopeKey===Ze,Xt=a?!1:Fe.has(Ge.id),Ft=Jt=>s.jsx(Jf,{folderId:Ge.id,scopeKey:Ze,ownerKey:te,children:(Lt,is)=>s.jsx(Xf,{folder:Ge,displayName:Qe,sessions:Bt,isCollapsed:Xt,collapsedActivityState:Jt,onToggle:()=>P(Ge.id),onRename:_t=>{Z(Ze,Ge.id,_t)},onDelete:()=>{if(n.isArchivedBucket){mn.requestDelete({sessions:$t,mode:"session"});return}if(!ce){X(Ze,Ge.id);return}const _t=Me.filter(({folder:Nt})=>Nt.parentId===Ge.id).length,zt=Bt.length;ge({scopeKey:Ze,folderId:Ge.id,folderName:Ge.name,subFolderCount:_t,sessionCount:zt})},groupDirectory:lt??n.directory,projectId:i,mobileVariant:w,alwaysShowActions:h,isRenaming:Wt,renameDraft:Wt?L?.draft:void 0,onRenameDraftChange:A,onRenameSave:()=>{const _t=L?.draft.trim()??"";_t&&Z(Ze,Ge.id,_t),D()},onRenameCancel:D,droppableRef:Lt,isDropTarget:is,depth:0,onNewSession:()=>{i&&i!==g&&j(i),w&&b(!1),S({selectedProjectId:i,directoryOverride:lt??n.directory,targetFolderId:Ge.id,target:n.draftTarget})},hideActions:!1,archivedBucket:n.isArchivedBucket===!0,children:Bt.map(_t=>s.jsx(Zo,{node:_t,pinnedSessionIds:C,expandedParents:O,hasSessionSearchQuery:a,normalizedSessionSearchQuery:d,notifyOnSubtasks:M,editingId:T,editingRowKey:$,editTitle:Y,openSidebarMenuKey:_,mobileVariant:w,alwaysShowActions:h,groupDirectory:lt??n.directory,projectId:i,folderOwnerKey:te,selectionScopeKey:te,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:ft,menuOpenSessionId:st,nodeStructureKey:Je(_t),childRenderExtrasFor:dt},setEditingId:t.setEditingId,setEditingRowKey:t.setEditingRowKey,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,resetSessionSearch:t.resetSessionSearch,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},_t.session.id))})},Ge.id);return Xt?s.jsx(u3,{nodes:rt.get(Ge.id)??Bt,includeUnreadSubtasks:M,children:Ft},Ge.id):Ft(null)},jt=()=>{const ve=new Map;for(const lt of Me){const Bt=lt.folder.parentId;if(!Bt)continue;const $t=ve.get(Bt);$t?$t.push(lt):ve.set(Bt,[lt])}const Qe=[],Ge=new Set,Ze=(lt,Bt)=>{if(Ge.has(lt.folder.id))return;Ge.add(lt.folder.id);const $t=Bt?`${Bt} / ${lt.folder.name}`:lt.folder.name;Qe.push(Xe(lt,$t)),!(!a&&Fe.has(lt.folder.id))&&(ve.get(lt.folder.id)??[]).forEach(Xt=>Ze(Xt,$t))};return tt.forEach(lt=>Ze(lt,"")),Qe},Ve=!!(!n.isMain&&n.worktree),pt=n.worktree?.worktreeStatus==="missing"?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center text-status-warning",title:e("sessions.sidebar.group.worktreeMissing"),"aria-label":e("sessions.sidebar.group.worktreeMissing"),children:s.jsx(F,{name:"alert",className:"h-3 w-3"})}):null,Rt=h?Ve?"pr-14":"pr-7":Ve?"pr-2 group-hover/gh:pr-14 group-focus-within/gh:pr-14":"pr-2 group-hover/gh:pr-7 group-focus-within/gh:pr-7",De=G?s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(Te==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":Ce?"sessions.sidebar.group.empty.loadFailed":"sessions.sidebar.group.empty.initializationFailed"),pe?s.jsx(ut,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:ne,onClick:()=>{z()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,s.jsx(ut,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:U,children:e("sessions.sidebar.group.empty.retry")})]}):null,yt=ve=>s.jsx(Zo,{node:ve,pinnedSessionIds:C,expandedParents:O,hasSessionSearchQuery:a,normalizedSessionSearchQuery:d,notifyOnSubtasks:M,editingId:T,editingRowKey:$,editTitle:Y,openSidebarMenuKey:_,mobileVariant:w,alwaysShowActions:h,groupDirectory:n.directory,projectId:i,folderOwnerKey:te,selectionScopeKey:te,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:ft,menuOpenSessionId:st,nodeStructureKey:Je(ve),childRenderExtrasFor:dt},setEditingId:t.setEditingId,setEditingRowKey:t.setEditingRowKey,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,resetSessionSearch:t.resetSessionSearch,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},ve.session.id),Pt=s.jsxs(C2,{scopeKey:oe[0]?.scopeKey??K,ownerKey:te,hasFolders:Me.length>0,onSessionDroppedOnFolder:(ve,Qe)=>{const Ge=Me.find(({folder:lt,scopeKey:Bt})=>lt.id===Qe.folderId&&Bt===Qe.scopeKey);if(!Ge)return;const Ze=ss.getState();for(const{scopeKey:lt}of oe)lt!==Ge.scopeKey&&Ze.getSessionFolderId(lt,ve)&&Ze.removeSessionFromFolder(lt,ve);se(Ge.scopeKey,Qe.folderId,ve)},children:[jt(),mt.map(yt),Ke===0&&Me.length===0?!n.isArchivedBucket&&!we&&!De&&n.directory&&!n.emptyMessage?s.jsx(ut,{variant:"link",size:"xs",className:"w-full justify-start pl-[26px] text-left font-normal normal-case text-muted-foreground/70 underline-offset-auto hover:text-foreground hover:underline",onClick:()=>{i&&i!==g&&j(i),w&&b(!1),S({selectedProjectId:i,directoryOverride:n.directory,target:n.draftTarget})},children:e("sessions.sidebar.group.empty.startSession")}):s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:n.isArchivedBucket?e("sessions.sidebar.group.empty.noArchivedSessions"):we?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(F,{name:"loader-4",className:"size-3 animate-spin"}),e("sessions.sidebar.group.empty.loadingSessions")]}):De||(n.emptyMessage??e("sessions.sidebar.group.empty.noSessionsInWorkspace"))}):null,Ke>0&&De?s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-status-error",children:De}):null,ee>0?s.jsx("button",{type:"button",onClick:()=>x(r,mt.length,f??7),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,fe?s.jsx("button",{type:"button",onClick:()=>k(r),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showFewer")}):null]}),Ue="pb-2",He=s.jsx(dm,{value:re,setValue:ge,onConfirm:()=>{const ve=re;ve&&(X(ve.scopeKey,ve.folderId),ge(null))}});return o?l?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"oc-group",children:s.jsx("div",{className:Re("oc-group-body",Ue),children:Pt})}),He]}):null:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"oc-group",children:[s.jsxs("div",{className:Re("group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md","cursor-pointer"),onClick:()=>R(r),role:"button",tabIndex:0,onKeyDown:ve=>{(ve.key==="Enter"||ve.key===" ")&&(ve.preventDefault(),R(r))},"aria-label":Se?e("sessions.sidebar.group.expandAria",{label:n.label}):e("sessions.sidebar.group.collapseAria",{label:n.label}),"aria-expanded":!Se,children:[s.jsxs("div",{ref:I?.setActivatorNodeRef,className:Re("min-w-0 flex flex-1 items-start gap-1 overflow-hidden pl-1.5 transition-[padding]",Rt),...I?.listeners??{},children:[s.jsxs("div",{className:"min-w-0 flex flex-1 flex-col justify-center gap-0.5 overflow-hidden",children:[s.jsx("p",{className:"typography-ui-label font-normal truncate text-foreground/92",children:n.isArchivedBucket?s.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsx(F,{name:"archive",className:Re("h-3.5 w-3.5 shrink-0 text-muted-foreground",h?"hidden":"group-hover/gh:hidden")}),s.jsx("span",{className:Re("text-muted-foreground h-3.5 w-3.5 items-center justify-center",h?"inline-flex":"hidden group-hover/gh:inline-flex"),children:Se?s.jsx(F,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(F,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:Hr(n.label,d)}),pt,qe]}):!n.isMain||n.worktree?s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsx(F,{name:"git-branch",className:Re("h-3.5 w-3.5 shrink-0",!V&&"text-muted-foreground",h?"hidden":"group-hover/gh:hidden"),style:V?{color:V}:void 0}),s.jsx("span",{className:Re("text-muted-foreground h-3.5 w-3.5 items-center justify-center",h?"inline-flex":"hidden group-hover/gh:inline-flex"),children:Se?s.jsx(F,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(F,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 truncate typography-ui-label font-semibold text-muted-foreground",children:Hr(n.label,d)}),pt,qe,ke?s.jsxs("span",{className:"ml-auto flex-shrink-0 text-[0.72rem] font-medium leading-none",style:V?{color:V}:void 0,children:["#",ke.number]}):null]}):s.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[s.jsx("span",{className:"min-w-0 truncate",children:Hr(n.label,d)}),qe]})}),Be&&Ye?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[n.isArchivedBucket?s.jsx(F,{name:"archive",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(F,{name:"git-branch",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 truncate text-[11px] font-medium text-muted-foreground/80",children:Ye.label})]}):null]}),!n.isArchivedBucket&&n.directory?s.jsx(to,{directory:n.directory,className:"self-center"}):null]}),n.isArchivedBucket&&$e.length>0?s.jsx("div",{className:Re("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",h?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:ve=>{ve.stopPropagation(),mn.requestDelete({sessions:$e,mode:"session"})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.sidebar.group.actions.deleteArchivedInGroupAria",{label:n.label}),children:s.jsx(F,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(St,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteArchivedSessions")})})]})}):null,n.directory&&!n.isMain&&n.worktree?s.jsx("div",{className:Re("absolute right-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",h?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:ve=>{ve.stopPropagation(),mn.requestDelete({sessions:$e,mode:"worktree",worktree:n.worktree})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.sidebar.group.actions.deleteGroupAria",{label:n.label}),children:s.jsx(F,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(St,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteWorktree")})})]})}):null,n.directory?s.jsx("div",{className:Re("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",h?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:ve=>{ve.stopPropagation(),i&&i!==g&&j(i),w&&b(!1),S({selectedProjectId:i,directoryOverride:n.directory})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.sidebar.group.actions.newDraftInGroupAria",{label:n.label}),children:s.jsx(F,{name:"add",className:"h-4 w-4"})})}),s.jsx(St,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.project.actions.newDraftSession")})})]})}):null]}),!Se&&l?s.jsx("div",{className:Re("oc-group-body",Ue),children:Pt}):null]}),He]})}const x3=c.memo(g3,p3),Ao=({projectId:t,mobileVariant:e,closeMobileSwitcher:n,setActiveProjectIdOnly:r,setSessionSwitcherOpen:i})=>{t&&r(t),e&&n&&i(!1)},fd=(t,e)=>Ku(t.label?.trim()||cr(t.normalizedPath,e)||t.normalizedPath);function b3(t){const e=et.c(104),{model:n,view:r,actions:i}=t;Rs("ui.sidebar_projects_list.render");const{t:o}=kt(),l=li(),a=ss(D3),d=ss(P3),u=ss(A3),m=ss(N3),f=Pe(C3),[p,y]=c.useState(null),[x,k]=c.useState(null),[w,h]=c.useState(null),[g,j]=c.useState(null),[b,S]=c.useState(!1),C=c.useRef(null);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={activationConstraint:{distance:8}},e[0]=v):v=e[0];let M;e[1]===Symbol.for("react.memo_cache_sentinel")?(M={activationConstraint:{delay:200,tolerance:6}},e[1]=M):M=e[1];let R;e[2]===Symbol.for("react.memo_cache_sentinel")?(R={coordinateGetter:fb},e[2]=R):R=e[2];const I=di(Tn(fi,v),Tn(ui,M),Tn(db,R));let B;e[3]===Symbol.for("react.memo_cache_sentinel")?(B=z=>{C.current=z,j(z)},e[3]=B):B=e[3];const O=B;let T;if(e[4]!==n.projectSections||e[5]!==r.homeDirectory){let z;e[7]!==r.homeDirectory?(z=Q=>({id:Q.project.id,projectLabel:fd(Q.project,r.homeDirectory),projectDescription:Zr(Q.project.normalizedPath,r.homeDirectory),projectIcon:Q.project.icon,projectColor:Q.project.color,projectIconImage:Q.project.iconImage,projectIconBackground:Q.project.iconBackground}),e[7]=r.homeDirectory,e[8]=z):z=e[8],T=n.projectSections.map(z),e[4]=n.projectSections,e[5]=r.homeDirectory,e[6]=T}else T=e[6];const $=T;let _;e:{if(!r.stickyZoneHeaders){_=-1;break e}let z;if(e[9]!==n.rowModel.stickyHeaders||e[10]!==x){let Q;e[12]!==x?(Q=ue=>`${ue.kind}:${ue.id}`===x,e[12]=x,e[13]=Q):Q=e[13],z=n.rowModel.stickyHeaders.findIndex(Q),e[9]=n.rowModel.stickyHeaders,e[10]=x,e[11]=z}else z=e[11];_=z}const Y=_;let L;if(e[14]!==w||e[15]!==n.groupProps.editingRowKey||e[16]!==n.rowModel.rowIndexByKey||e[17]!==n.rowModel.rows||e[18]!==n.rowModel.stickyHeaders||e[19]!==n.state.openSidebarMenuKey||e[20]!==Y){if(L=new Set,w){let z;e[22]!==w||e[23]!==n.rowModel.rowIndexByKey?(z=n.rowModel.rowIndexByKey.get(w),e[22]=w,e[23]=n.rowModel.rowIndexByKey,e[24]=z):z=e[24];const Q=z;Q!==void 0&&L.add(Q)}for(let z=0;z<n.rowModel.rows.length;z=z+1,z){const Q=n.rowModel.rows[z];Q?.kind==="session"&&(n.groupProps.editingRowKey===Q.key||n.state.openSidebarMenuKey===`session-menu:${Q.key}`||n.state.openSidebarMenuKey===`session-context:${Q.key}`)&&L.add(z)}if(Y>=0){const z=Math.max(0,Y-1),Q=Math.min(n.rowModel.stickyHeaders.length-1,Y+1);for(let ue=z;ue<=Q;ue=ue+1,ue){const le=n.rowModel.stickyHeaders[ue];le&&L.add(le.rowIndex)}}e[14]=w,e[15]=n.groupProps.editingRowKey,e[16]=n.rowModel.rowIndexByKey,e[17]=n.rowModel.rows,e[18]=n.rowModel.stickyHeaders,e[19]=n.state.openSidebarMenuKey,e[20]=Y,e[21]=L}else L=e[21];const A=L;let D;e[25]!==n.rowModel.stickyHeaders||e[26]!==r.stickyZoneHeaders?(D=z=>{const Q=r.stickyZoneHeaders?Jk(n.rowModel.stickyHeaders,z):null,ue=Q?`${Q.kind}:${Q.id}`:null;k(le=>le===ue?le:ue)},e[25]=n.rowModel.stickyHeaders,e[26]=r.stickyZoneHeaders,e[27]=D):D=e[27];const P=D;let Z;e[28]!==l||e[29]!==o?(Z=z=>{const Q=()=>{if(!z.status.directory){ci();return}l.requestBootstrap({directory:z.status.directory,priority:"expanded",reason:z.group.isMain?"project-expanded":"worktree-expanded",force:!0})},ue=async()=>{if(!z.status.directory)return;(await Yd(z.status.directory)).success&&Q()};let le;e:switch(z.status.state){case"permission-denied":{le=o("sessions.sidebar.group.empty.permissionDenied");break e}case"load-failed":{le=o("sessions.sidebar.group.empty.loadFailed");break e}case"initialization-failed":{le=o("sessions.sidebar.group.empty.initializationFailed");break e}default:le=o("sessions.sidebar.group.empty.loadingSessions")}return s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[z.status.state==="loading"?s.jsx(F,{name:"loader-4",className:"size-3 animate-spin"}):null,le,z.status.canGrantAccess?s.jsx(ut,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:()=>{ue()},children:o("sessions.sidebar.group.empty.grantAccess")}):null,z.status.state!=="loading"?s.jsx(ut,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:Q,children:o("sessions.sidebar.group.empty.retry")}):null]})})},e[28]=l,e[29]=o,e[30]=Z):Z=e[30];const X=Z;let se;e[31]!==i||e[32]!==u||e[33]!==n.emptyState||e[34]!==n.groupProps||e[35]!==n.projectRepoStatus||e[36]!==n.searchEmptyState||e[37]!==n.singleProjectMode||e[38]!==n.state||e[39]!==$||e[40]!==d||e[41]!==X||e[42]!==f||e[43]!==o||e[44]!==a||e[45]!==r.alwaysShowActions||e[46]!==r.hideDirectoryControls||e[47]!==r.homeDirectory||e[48]!==r.mobileVariant||e[49]!==r.projectSortOrder||e[50]!==r.stickyZoneHeaders||e[51]!==r.timelineView||e[52]!==r.worktreeSortOrder?(se=z=>{if(z.kind==="activity-header")return s.jsx(fm,{className:r.stickyZoneHeaders?"sticky top-0 z-20 bg-sidebar":void 0,"data-sidebar-sticky-header":r.stickyZoneHeaders?"true":void 0,children:s.jsx(Vk,{activityKey:z.activityKey,collapsed:z.collapsed,forceExpanded:z.forceExpanded,alwaysShowActions:r.alwaysShowActions,timelineView:r.timelineView,onToggle:()=>{if(!z.collapsed){const Q=`activity:${z.activityKey}`;i.group.resetGroupSessionLimit(Q),n.state.setVisibleActivityCountByKey(ue=>{if(!ue.has(Q))return ue;const le=new Map(ue);return le.delete(Q),le})}n.state.setCollapsedActivityKeys(Q=>{const ue=new Set(Q);return ue.has(z.activityKey)?ue.delete(z.activityKey):ue.add(z.activityKey),ue})},onNewChat:()=>{Pe.getState().closeMainSurfaces(),r.mobileVariant&&i.setSessionSwitcherOpen(!1),i.openNewSessionDraft({selectedProjectId:Qg,directoryOverride:null})}})});if(z.kind==="project-header"){const Q=z.section.project,ue=fd(Q,r.homeDirectory);return s.jsx(o3,{id:Q.id,disabled:n.singleProjectMode||z.forceExpanded||n.state.editingId!==null||r.projectSortOrder!=="manual",projectLabel:ue,projectDescription:Zr(Q.normalizedPath,r.homeDirectory),projectDirectory:Q.normalizedPath,projectIcon:Q.icon,projectColor:Q.color,projectIconImage:Q.iconImage,projectIconBackground:Q.iconBackground,isCollapsed:z.collapsed,isRepo:!!n.projectRepoStatus.get(Q.id),hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,statusIndicator:z.collapsed?i.renderProjectStatusIndicator?.(Q.id,z.section.groups):null,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,projectPickerOptions:n.singleProjectMode?$:void 0,onProjectSelect:n.singleProjectMode?i.setSingleProjectId:void 0,onToggle:()=>{!z.forceExpanded&&!n.singleProjectMode&&i.toggleProject(Q.id)},onNewSession:()=>{Ao({projectId:Q.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:Q.id,directoryOverride:Q.normalizedPath})},onNewWorktreeSession:()=>{Ao({projectId:Q.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!1,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewWorktreeDialog()},onManageWorktrees:()=>i.openWorktreesPage(Q.id),onRenameStart:()=>i.openProjectEditDialog(Q.id),onClose:()=>i.removeProject(Q.id),showCreateButtons:!0})}if(z.kind==="group-header")return s.jsx(a3,{id:z.groupKey,disabled:z.forceExpanded||n.state.editingId!==null||r.worktreeSortOrder!=="manual",children:Q=>s.jsx(x3,{...n.groupProps,...i.group,group:z.group,groupKey:z.groupKey,projectId:z.projectId,visibleSessionCount:n.state.visibleSessionCountByGroup.get(z.groupKey),editingId:n.state.editingId,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,dragHandleProps:Q,renderBody:!1})});if(z.kind==="folder-header"){const Q=n.groupProps.folderRename?.folderId===z.folder.id&&n.groupProps.folderRename.scopeKey===z.scopeKey;return s.jsx(Jf,{folderId:z.folder.id,scopeKey:z.scopeKey,ownerKey:z.ownerKey,disabled:!z.dropEnabled,children:(ue,le)=>s.jsx(j2,{notifyOnSubtasks:n.groupProps.notifyOnSubtasks,activityNodes:z.activityNodes,folder:z.folder,displayName:z.displayName,sessions:z.nodes,isCollapsed:z.collapsed,onToggle:z.forceExpanded?k3:()=>a(z.folder.id),onRename:W=>d(z.scopeKey,z.folder.id,W),onDelete:()=>{z.archived?mn.requestDelete({sessions:[...z.deleteSessions],mode:"session"}):f?y({scopeKey:z.scopeKey,folderId:z.folder.id,folderName:z.folder.name,subFolderCount:z.subFolderCount,sessionCount:z.nodes.length}):u(z.scopeKey,z.folder.id)},renderBody:!1,groupDirectory:z.scopeDirectory??z.group.directory,projectId:z.projectId,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,isRenaming:Q,renameDraft:Q?n.groupProps.folderRename?.draft:void 0,onRenameDraftChange:n.groupProps.setFolderRenameDraft,onRenameSave:()=>{const W=n.groupProps.folderRename?.draft.trim();W&&d(z.scopeKey,z.folder.id,W),n.groupProps.clearFolderRename()},onRenameCancel:n.groupProps.clearFolderRename,droppableRef:ue,isDropTarget:le,onNewSession:()=>{Ao({projectId:z.projectId,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:z.projectId,directoryOverride:z.scopeDirectory??z.group.directory,targetFolderId:z.folder.id,target:z.group.draftTarget})},archivedBucket:z.archived})})}if(z.kind==="session"){const Q=new Set;return Pr(z.node,n.state.editingId)&&Q.add(z.node.session.id),s.jsx("div",{onFocusCapture:()=>h(z.key),onBlurCapture:()=>h(ue=>ue===z.key?null:ue),children:s.jsx(Zo,{...n.groupProps,node:z.node,depth:z.depth,groupDirectory:z.groupDirectory,projectId:z.projectId,folderOwnerKey:z.ownerKey,selectionScopeKey:z.selectionScopeKey,archivedBucket:z.archived,renderContext:z.renderContext,rowKey:z.key,dragKey:z.key,secondaryMeta:z.secondaryMeta,renderChildren:!1,editingId:n.state.editingId,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,renderExtras:{subtreeContainsEditing:Q,menuOpenSessionId:n.state.openSidebarMenuKey===`session-menu:${z.key}`||n.state.openSidebarMenuKey===`session-context:${z.key}`?z.node.session.id:null,nodeStructureKey:Qo(z.node)}})})}if(z.kind==="show-control")return s.jsx("button",{type:"button",className:Re("mt-0.5 flex items-center justify-start rounded-md pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",r.timelineView?"pl-[10px]":"pl-[26px]"),onClick:()=>{z.containerKey.startsWith("activity:")?n.state.setVisibleActivityCountByKey(Q=>{const ue=new Map(Q);return z.control==="more"?ue.set(z.containerKey,z.currentCount+z.increment):ue.delete(z.containerKey),ue}):z.control==="more"?i.group.showMoreGroupSessions(z.containerKey,z.currentCount,z.increment):i.group.resetGroupSessionLimit(z.containerKey)},children:o(z.control==="more"?"sessions.sidebar.group.showMore":"sessions.sidebar.group.showFewer")});if(z.kind==="status")return X(z);if(z.emptyKind==="sidebar")return n.emptyState;if(z.emptyKind==="search")return n.searchEmptyState;if(z.emptyKind==="group"&&z.group?.directory&&!z.group.emptyMessage){const Q=z.group;return s.jsx(ut,{variant:"link",size:"xs",className:"w-full justify-start pl-[26px] text-left font-normal normal-case text-muted-foreground/70 underline-offset-auto hover:text-foreground hover:underline",onClick:()=>{Ao({projectId:z.projectId??null,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:z.projectId,directoryOverride:Q.directory,target:Q.draftTarget})},children:o("sessions.sidebar.group.empty.startSession")})}return s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:z.emptyKind==="archived"?o("sessions.sidebar.group.empty.noArchivedSessions"):z.group?.emptyMessage??o("sessions.sidebar.group.empty.noSessionsInWorkspace")})},e[31]=i,e[32]=u,e[33]=n.emptyState,e[34]=n.groupProps,e[35]=n.projectRepoStatus,e[36]=n.searchEmptyState,e[37]=n.singleProjectMode,e[38]=n.state,e[39]=$,e[40]=d,e[41]=X,e[42]=f,e[43]=o,e[44]=a,e[45]=r.alwaysShowActions,e[46]=r.hideDirectoryControls,e[47]=r.homeDirectory,e[48]=r.mobileVariant,e[49]=r.projectSortOrder,e[50]=r.stickyZoneHeaders,e[51]=r.timelineView,e[52]=r.worktreeSortOrder,e[53]=se):se=e[53];const ce=se;let re;e[54]!==n.rowModel.rows?(re=n.rowModel.rows.flatMap(j3),e[54]=n.rowModel.rows,e[55]=re):re=e[55];const ge=re;let ae;e[56]!==n.sectionsForRender?(ae=new Set(n.sectionsForRender.map(S3)),e[56]=n.sectionsForRender,e[57]=ae):ae=e[57];const Ee=ae;let Se;e[58]!==n.rowModel.stickyHeaders?(Se=n.rowModel.stickyHeaders.map(v3).join(""),e[58]=n.rowModel.stickyHeaders,e[59]=Se):Se=e[59];const me=Se,ke=!r.timelineView;let V;e[60]!==Ee?(V=z=>{S(Ee.has(String(z.active.id)))},e[60]=Ee,e[61]=V):V=e[61];let J;e[62]===Symbol.for("react.memo_cache_sentinel")?(J=()=>S(!1),e[62]=J):J=e[62];let de;e[63]!==i||e[64]!==m||e[65]!==n.rowModel.folderAuthorityByOwner||e[66]!==n.rowModel.folderDropTargets||e[67]!==n.rowModel.rows||e[68]!==n.sectionsForRender||e[69]!==n.state||e[70]!==r.hasSessionSearchQuery||e[71]!==r.projectSortOrder?(de=z=>{if(S(!1),!z.over)return;const Q=z.active.data.current,ue=z.over.data.current;if(Q?.type==="session"&&Q.sessionId&&Q.ownerKey&&Q.archivedBucket!==!0&&ue?.type==="folder"&&ue.folderId&&ue.scopeKey&&ue.ownerKey===Q.ownerKey){const Me=n.rowModel.folderDropTargets.find(je=>je.folderId===ue.folderId&&je.scopeKey===ue.scopeKey&&je.ownerKey===Q.ownerKey),q=n.rowModel.folderAuthorityByOwner.get(Q.ownerKey);if(!Me?.enabled||q?.complete!==!0)return;const Ne=ss.getState();for(const je of q.scopeKeys)je!==ue.scopeKey&&Ne.removeSessionFromFolder(je,Q.sessionId);m(ue.scopeKey,ue.folderId,Q.sessionId);return}if(r.hasSessionSearchQuery||n.state.editingId!==null||z.active.id===z.over.id)return;const le=String(z.active.id),W=String(z.over.id),E=n.sectionsForRender.map(w3),K=E.indexOf(le),te=E.indexOf(W);if(K>=0&&te>=0&&r.projectSortOrder==="manual"){i.reorderProjects(K,te);return}const oe=n.rowModel.rows.find(Me=>Me.kind==="group-header"&&Me.groupKey===le),he=n.rowModel.rows.find(Me=>Me.kind==="group-header"&&Me.groupKey===W);if(!oe||!he||oe.projectId!==he.projectId||!oe.projectId)return;const ie=oe.projectId,Fe=n.sectionsForRender.find(Me=>Me.project.id===ie);if(!Fe)return;const _e=Fe.groups.findIndex(Me=>Me.id===oe.group.id),Ae=Fe.groups.findIndex(Me=>Me.id===he.group.id);_e<0||Ae<0||i.setGroupOrderByProject(Me=>new Map(Me).set(ie,sf(Fe.groups,_e,Ae).map(y3)))},e[63]=i,e[64]=m,e[65]=n.rowModel.folderAuthorityByOwner,e[66]=n.rowModel.folderDropTargets,e[67]=n.rowModel.rows,e[68]=n.sectionsForRender,e[69]=n.state,e[70]=r.hasSessionSearchQuery,e[71]=r.projectSortOrder,e[72]=de):de=e[72];let we;e[73]!==P||e[74]!==n.rowModel||e[75]!==A||e[76]!==ce||e[77]!==g?(we=s.jsx(Wk,{model:n.rowModel,scrollElement:g,pinnedRowIndexes:A,renderRow:ce,onFirstVisibleIndexChange:P}),e[73]=P,e[74]=n.rowModel,e[75]=A,e[76]=ce,e[77]=g,e[78]=we):we=e[78];let G;e[79]!==ge||e[80]!==we?(G=s.jsx(nl,{items:ge,strategy:nf,children:we}),e[79]=ge,e[80]=we,e[81]=G):G=e[81];let Ce;e[82]!==I||e[83]!==V||e[84]!==de||e[85]!==G?(Ce=s.jsx(mi,{sensors:I,collisionDetection:hi,onDragStart:V,onDragCancel:J,onDragEnd:de,children:G}),e[82]=I,e[83]=V,e[84]=de,e[85]=G,e[86]=Ce):Ce=e[86];let Te;e[87]!==ke||e[88]!==Ce?(Te=s.jsx(On,{ref:O,useScrollShadow:!0,hideTopScrollShadow:ke,scrollShadowSize:40,outerClassName:"flex-1 min-h-0",className:"oc-sidebar-scroller pb-1 pl-2.5 pr-2 [overflow-anchor:none]",children:Ce}),e[87]=ke,e[88]=Ce,e[89]=Te):Te=e[89];let pe;e[90]!==b||e[91]!==Te||e[92]!==r.stickyZoneHeaders||e[93]!==me?(pe=s.jsx(e3,{enabled:r.stickyZoneHeaders,suspended:b,layoutKey:me,scrollRef:C,children:Te}),e[90]=b,e[91]=Te,e[92]=r.stickyZoneHeaders,e[93]=me,e[94]=pe):pe=e[94];let ne;e[95]!==u||e[96]!==p?(ne=()=>{p&&(u(p.scopeKey,p.folderId),y(null))},e[95]=u,e[96]=p,e[97]=ne):ne=e[97];let xe;e[98]!==p||e[99]!==ne?(xe=s.jsx(dm,{value:p,setValue:y,onConfirm:ne}),e[98]=p,e[99]=ne,e[100]=xe):xe=e[100];let U;return e[101]!==pe||e[102]!==xe?(U=s.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[pe,xe]}),e[101]=pe,e[102]=xe,e[103]=U):U=e[103],U}function y3(t){return t.id}function w3(t){return t.project.id}function v3(t){const{kind:e,id:n,rowIndex:r}=t;return`${e}:${n}:${r}`}function S3(t){return t.project.id}function j3(t){return t.kind==="project-header"?[t.section.project.id]:t.kind==="group-header"?[t.groupKey]:[]}function k3(){}function C3(t){return t.showDeletionDialog}function N3(t){return t.addSessionToFolder}function A3(t){return t.deleteFolder}function P3(t){return t.renameFolder}function D3(t){return t.toggleFolderCollapse}const I3=c.memo(b3),Ra=new Map,md=(t,e)=>{for(const n of t){const r=xt(n??null);r&&!Ra.has(r)&&Ra.set(r,e)}},hd=t=>{const e=xt(t??null);return e?Ra.get(e)??0:0},_r=t=>!!t.time?.archived,T3=t=>{const{t:e}=kt(),n=c.useRef(t.gitBranches);n.current=t.gitBranches;const r=c.useCallback(a=>[a.label,a.branch??"",a.description??"",a.directory??""].join(" ").toLowerCase(),[]),i=c.useCallback(a=>{const d=xt(a.directory??null)??"";return`${(a.title||e("sessions.sidebar.session.untitled")).trim()} ${d}`.toLowerCase()},[e]),o=c.useCallback((a,d)=>{if(!d)return a;const u=d.trim().toLowerCase(),m=u.startsWith("ses_");return a.flatMap(f=>{if(m&&_r(f.session))return[];if(m?f.session.id.toLowerCase()===u:Wo([i(f.session)],d))return[f];const y=o(f.children,d);return y.length===0?[]:[{...f,children:y}]})},[i]),l=c.useCallback((a,d,u,m,f)=>{const p=xt(d??null),y=$u(a),x=new Map(y.map(L=>[L.id,L])),k=new Map;y.forEach(L=>{const A=L.parentID;if(!A)return;const D=x.get(A);if(!D||_r(D)!==_r(L))return;const P=k.get(A)??[];P.push(L),k.set(A,P)});const w=Xg(u,p),h=L=>{const A=xt(L.directory??null),D=t.worktreeMetadata.get(L.id)??null;if(D)return D;if(A){const P=w.get(A)??null;if(P&&A!==p)return P}return null},g=new Set,j=L=>{g.add(L.id);const A=k.get(L.id)??[],D=[];for(const P of A)g.has(P.id)||D.push(j(P));return{session:L,children:D,worktree:h(L)}},b=y.filter(L=>{const A=L.parentID;if(!A)return!0;const D=x.get(A);return D?_r(D)!==_r(L):!0}),S=[],C=L=>{g.has(L.id)||S.push(j(L))};b.forEach(C),y.forEach(C);const v=new Map,M="__archived__",R=L=>{if(L.time?.archived)return M;if(t.isVSCode)return p??"__project_root__";const A=t.sessionOwners?.get(L.id)?.scopeDirectory;if(A){if(A===p)return p??"__project_root__";if(w.has(A))return A}const P=xt(t.worktreeMetadata.get(L.id)?.path??null)??Ps(L);return P&&P!==p&&w.has(P)?P:p??"__project_root__"};S.forEach(L=>{const A=R(L.session);v.has(A)||v.set(A,[]),v.get(A)?.push(L)});const I=p??"__project_root__",B=[{id:"root",label:f&&m&&m!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:m}):e("sessions.sidebar.grouping.projectRoot"),branch:m??null,description:p?Zr(p,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:p,folderScopeKey:p,sessions:v.get(I)??[]}],O=new Map;u.forEach(L=>{const A=xt(L.path)??L.path,D=v.get(A)??[],P=D.length>0,Z=D.reduce((X,se)=>{const ce=Jg(se.session,t.sessionOrderRanks);return Number.isFinite(ce)?Math.max(X,ce):X},0);O.set(A,{hasActiveSession:P,lastUpdatedAt:Z})});const T=(L,A)=>{const D=(L.label||L.branch||L.name||L.path||"").toLowerCase(),P=(A.label||A.branch||A.name||A.path||"").toLowerCase();return D.localeCompare(P)},$=t.worktreeSortOrder!=="recent"?[...u].sort(T):[...u].sort((L,A)=>{const D=xt(L.path)??L.path,P=xt(A.path)??A.path,Z=O.get(D)??{hasActiveSession:!1,lastUpdatedAt:0},X=O.get(P)??{hasActiveSession:!1,lastUpdatedAt:0};if(Z.hasActiveSession!==X.hasActiveSession)return Z.hasActiveSession?-1:1;if(Z.hasActiveSession&&X.hasActiveSession)return X.lastUpdatedAt-Z.lastUpdatedAt;const se=hd(L.path),ce=hd(A.path);return se!==ce?ce-se:T(L,A)});(t.isVSCode?[]:$).forEach(L=>{const A=xt(L.path)??L.path,D=n.current.get(A)?.trim()||null,P=L.branch?.trim()||null,X=!!(D&&P&&L.label&&Kl(L.label)===Kl(P))?D:L.label||L.name||cr(A,t.homeDirectory)||A;B.push({id:`worktree:${A}`,label:X,branch:D||P,description:Zr(A,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:L,directory:A,folderScopeKey:A,sessions:v.get(A)??[]})});const Y=v.get(M)??[];return Y.length>0&&B.push({id:"archived",label:e("sessions.sidebar.grouping.archived"),branch:null,description:e("sessions.sidebar.grouping.archivedDescription"),isMain:!1,isArchivedBucket:!0,worktree:null,directory:null,folderScopeKey:!t.isVSCode&&p?Lu(p):null,sessions:Y}),B},[t.homeDirectory,t.worktreeMetadata,t.sessionOrderRanks,t.isVSCode,t.worktreeSortOrder,t.sessionOwners,e]);return{buildGroupSearchText:r,buildSessionSearchText:i,filterSessionNodesForSearch:o,buildGroupedSessions:l}},E3=t=>{const e=et.c(60),{selectedCount:n,scopeKey:r,scopeFolders:i,archivedBucket:o,onMoveToFolder:l,onCreateFolderAndMove:a,onRemoveFromFolder:d,canRemoveFromFolder:u,onRestore:m,onArchive:f,onDelete:p,onDone:y}=t,{t:x}=kt(),k=n>0,w=k&&!!r&&!o;let h;e[0]!==n||e[1]!==x?(h=x("sessions.sidebar.bulkActions.selectedCount",{count:n}),e[0]=n,e[1]=x,e[2]=h):h=e[2];let g;e[3]!==h?(g=s.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:h}),e[3]=h,e[4]=g):g=e[4];let j;e[5]!==w||e[6]!==u||e[7]!==a||e[8]!==l||e[9]!==d||e[10]!==i||e[11]!==x?(j=w?s.jsxs($s,{children:[s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx(_s,{asChild:!0,children:s.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40","aria-label":x("sessions.sidebar.bulkActions.moveToFolder"),children:s.jsx(F,{name:"folder",className:"h-4 w-4"})})})}),s.jsx(St,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:x("sessions.sidebar.bulkActions.moveToFolder")})})]}),s.jsxs(Ls,{align:"end",className:"min-w-[180px]",children:[i.length===0?s.jsx(Ht,{disabled:!0,className:"text-muted-foreground",children:x("sessions.sidebar.folders.none")}):i.map(X=>s.jsx(Ht,{onClick:()=>l(X.id),children:s.jsx("span",{className:"flex-1 truncate",children:X.name})},X.id)),s.jsx(As,{}),s.jsxs(Ht,{onClick:a,children:[s.jsx(F,{name:"add",className:"mr-1 h-4 w-4"}),x("sessions.sidebar.folders.newFolderEllipsis")]}),u?s.jsxs(Ht,{onClick:d,className:"text-destructive focus:text-destructive",children:[s.jsx(F,{name:"close",className:"mr-1 h-4 w-4"}),x("sessions.sidebar.folders.removeFromFolder")]}):null]})]}):null,e[5]=w,e[6]=u,e[7]=a,e[8]=l,e[9]=d,e[10]=i,e[11]=x,e[12]=j):j=e[12];let b;e[13]!==o||e[14]!==k||e[15]!==m||e[16]!==x?(b=o?s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:m,disabled:!k,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40","aria-label":x("sessions.sidebar.bulkActions.restore"),children:s.jsx(F,{name:"inbox-unarchive",className:"h-4 w-4"})})}),s.jsx(St,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:x("sessions.sidebar.bulkActions.restore")})})]}):null,e[13]=o,e[14]=k,e[15]=m,e[16]=x,e[17]=b):b=e[17];let S;e[18]!==o||e[19]!==k||e[20]!==f||e[21]!==x?(S=o?null:s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,disabled:!k,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40","aria-label":x("sessions.sidebar.bulkActions.archive"),children:s.jsx(F,{name:"archive",className:"h-4 w-4"})})}),s.jsx(St,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:x("sessions.sidebar.bulkActions.archive")})})]}),e[18]=o,e[19]=k,e[20]=f,e[21]=x,e[22]=S):S=e[22];const C=!k;let v;e[23]===Symbol.for("react.memo_cache_sentinel")?(v=Re("inline-flex h-7 w-7 items-center justify-center rounded-md text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50 disabled:pointer-events-none disabled:opacity-40"),e[23]=v):v=e[23];let M;e[24]!==x?(M=x("sessions.sidebar.bulkActions.delete"),e[24]=x,e[25]=M):M=e[25];let R;e[26]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx(F,{name:"delete-bin",className:"h-4 w-4"}),e[26]=R):R=e[26];let I;e[27]!==p||e[28]!==C||e[29]!==M?(I=s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:p,disabled:C,className:v,"aria-label":M,children:R})}),e[27]=p,e[28]=C,e[29]=M,e[30]=I):I=e[30];let B;e[31]!==x?(B=x("sessions.sidebar.bulkActions.delete"),e[31]=x,e[32]=B):B=e[32];let O;e[33]!==B?(O=s.jsx(St,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:B})}),e[33]=B,e[34]=O):O=e[34];let T;e[35]!==I||e[36]!==O?(T=s.jsxs(wt,{children:[I,O]}),e[35]=I,e[36]=O,e[37]=T):T=e[37];let $;e[38]!==x?($=x("sessions.sidebar.header.actions.exitSelection"),e[38]=x,e[39]=$):$=e[39];let _;e[40]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx(F,{name:"close",className:"h-4 w-4"}),e[40]=_):_=e[40];let Y;e[41]!==y||e[42]!==$?(Y=s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:y,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40","aria-label":$,children:_})}),e[41]=y,e[42]=$,e[43]=Y):Y=e[43];let L;e[44]!==x?(L=x("sessions.sidebar.header.actions.exitSelection"),e[44]=x,e[45]=L):L=e[45];let A;e[46]!==L?(A=s.jsx(St,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:L})}),e[46]=L,e[47]=A):A=e[47];let D;e[48]!==Y||e[49]!==A?(D=s.jsxs(wt,{children:[Y,A]}),e[48]=Y,e[49]=A,e[50]=D):D=e[50];let P;e[51]!==T||e[52]!==D||e[53]!==j||e[54]!==b||e[55]!==S?(P=s.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[j,b,S,T,D]}),e[51]=T,e[52]=D,e[53]=j,e[54]=b,e[55]=S,e[56]=P):P=e[56];let Z;return e[57]!==g||e[58]!==P?(Z=s.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-2.5 py-1.5",children:[g,P]}),e[57]=g,e[58]=P,e[59]=Z):Z=e[59],Z},pd=new Map,R3=(t,e)=>{if(!t)return[];const n=e(t);return n.length>0?n.map(r=>r.scopeKey):[t]},M3=(t,e)=>{const n=t.sessionIds.filter(o=>e.has(o));if(n.length===0)return{ready:!1,value:null};const r=t.archivedBucket||tm(new Set(n),e),i={sessionIds:n,sessionCount:n.length,archivedBucket:r};return{ready:n.length===t.sessionIds.length&&r===t.archivedBucket,value:i}},O3=t=>{const e=et.c(89),{t:n}=kt();let r;e[0]!==n?(r=le=>{const W=Zg(le);return W?{description:ou(W,n)}:void 0},e[0]=n,e[1]=r):r=e[1];const i=r,{isInlineEditing:o,showDeletionDialog:l,foldersMap:a,getFolderScopesForProject:d,addSessionsToFolder:u,removeSessionsFromFolders:m,createFolderAndStartRename:f,archiveSessions:p,unarchiveSessions:y,deleteSessions:x,bulkDeleteConfirm:k,setBulkDeleteConfirm:w}=t,h=hs(B3),g=hs(F3),j=g>0,b=hs(_3),S=hs(L3),C=em(),v=$3,M=z3;let R;e[2]!==j||e[3]!==C||e[4]!==b?(R=j&&tm(b,C?.getSessionsById()??pd),e[2]=j,e[3]=C,e[4]=b,e[5]=R):R=e[5];const I=R;let B;e:{if(S){B=S;break e}B=null}const O=B;let T;e[6]!==O||e[7]!==d?(T=R3(O,d),e[6]=O,e[7]=d,e[8]=T):T=e[8];const $=T;let _;if(e[9]!==a||e[10]!==$){let le;e[12]!==a?(le=W=>a[W]??[],e[12]=a,e[13]=le):le=e[13],_=$.flatMap(le),e[9]=a,e[10]=$,e[11]=_}else _=e[11];const Y=_;let L;e[14]!==a||e[15]!==$?(L=le=>{for(const W of $)if((a[W]??[]).some(E=>E.id===le))return W;return null},e[14]=a,e[15]=$,e[16]=L):L=e[16];const A=L;let D;e:{if(!j){D=!1;break e}for(const le of $)for(const W of a[le]??[])for(const E of W.sessionIds)if(b.has(E)){D=!0;break e}D=!1}const P=D;let Z;e[17]!==u||e[18]!==m||e[19]!==b||e[20]!==$?(Z=(le,W)=>{const E=Array.from(b);for(const K of $)K!==le&&m(K,E);u(le,W,E)},e[17]=u,e[18]=m,e[19]=b,e[20]=$,e[21]=Z):Z=e[21];const X=Z;let se;e[22]!==j||e[23]!==X||e[24]!==A?(se=le=>{if(!j)return;const W=A(le);W&&X(W,le)},e[22]=j,e[23]=X,e[24]=A,e[25]=se):se=e[25];const ce=se;let re;e[26]!==f||e[27]!==j||e[28]!==X||e[29]!==$?(re=()=>{const le=$[0];if(!le||!j)return;const W=f(le);W&&X(le,W.id)},e[26]=f,e[27]=j,e[28]=X,e[29]=$,e[30]=re):re=e[30];const ge=re;let ae;e[31]!==j||e[32]!==m||e[33]!==b||e[34]!==$?(ae=()=>{if(!j)return;const le=Array.from(b);for(const W of $)m(W,le)},e[31]=j,e[32]=m,e[33]=b,e[34]=$,e[35]=ae):ae=e[35];const Ee=ae;let Se;e[36]!==p||e[37]!==x||e[38]!==i||e[39]!==n?(Se=async(le,W)=>{if(le.length!==0)if(W){const{deletedIds:E,failedIds:K}=await x(le);E.length>0&&ze.success(E.length===1?n("sessions.sidebar.bulkActions.deletedSingle",{count:E.length}):n("sessions.sidebar.bulkActions.deletedPlural",{count:E.length})),K.length>0&&ze.error(K.length===1?n("sessions.sidebar.bulkActions.failedDeleteSingle",{count:K.length}):n("sessions.sidebar.bulkActions.failedDeletePlural",{count:K.length}),i(K)),hs.getState().removeMany(E)}else{const{archivedIds:E,failedIds:K}=await p(le);E.length>0&&ze.success(E.length===1?n("sessions.sidebar.bulkActions.archivedSingle",{count:E.length}):n("sessions.sidebar.bulkActions.archivedPlural",{count:E.length})),K.length>0&&ze.error(K.length===1?n("sessions.sidebar.bulkActions.failedArchiveSingle",{count:K.length}):n("sessions.sidebar.bulkActions.failedArchivePlural",{count:K.length}),i(K)),hs.getState().removeMany(E)}},e[36]=p,e[37]=x,e[38]=i,e[39]=n,e[40]=Se):Se=e[40];const me=Se;let ke;e[41]!==me||e[42]!==j||e[43]!==b||e[44]!==w||e[45]!==l?(ke=le=>{if(!j)return;const W=Array.from(b);if(!l){me(W,le);return}w({sessionIds:W,sessionCount:W.length,archivedBucket:le})},e[41]=me,e[42]=j,e[43]=b,e[44]=w,e[45]=l,e[46]=ke):ke=e[46];const V=ke;let J;e[47]!==I||e[48]!==V?(J=()=>V(I),e[47]=I,e[48]=V,e[49]=J):J=e[49];const de=J;let we;e[50]!==V?(we=()=>V(!1),e[50]=V,e[51]=we):we=e[51];const G=we;let Ce;e[52]!==V?(Ce=()=>V(!0),e[52]=V,e[53]=Ce):Ce=e[53];const Te=Ce;let pe;e[54]!==I||e[55]!==i||e[56]!==j||e[57]!==b||e[58]!==n||e[59]!==y?(pe=async()=>{if(!j||!I)return;const le=Array.from(b),{restoredIds:W,failedIds:E}=await y(le);W.length>0&&ze.success(W.length===1?n("sessions.sidebar.bulkActions.restoredSingle",{count:W.length}):n("sessions.sidebar.bulkActions.restoredPlural",{count:W.length})),E.length>0&&ze.error(E.length===1?n("sessions.sidebar.bulkActions.failedRestoreSingle",{count:E.length}):n("sessions.sidebar.bulkActions.failedRestorePlural",{count:E.length}),i(E)),hs.getState().removeMany(W)},e[54]=I,e[55]=i,e[56]=j,e[57]=b,e[58]=n,e[59]=y,e[60]=pe):pe=e[60];const ne=pe;let xe;e[61]!==k||e[62]!==me||e[63]!==C||e[64]!==w?(xe=async()=>{if(!k)return;const le=C?.getSessionsById()??pd,W=M3(k,le);if(!W.ready){w(W.value);return}w(null),await me(W.value.sessionIds,W.value.archivedBucket)},e[61]=k,e[62]=me,e[63]=C,e[64]=w,e[65]=xe):xe=e[65];const U=xe;let z,Q;e[66]!==k||e[67]!==de||e[68]!==o||e[69]!==C||e[70]!==h?(z=()=>{if(!h)return;const le=/Macintosh|Mac OS X/.test(navigator.userAgent||""),W=E=>{if(k||o)return;const K=E.target instanceof HTMLElement?E.target:null;if(K&&(K.tagName==="INPUT"||K.tagName==="TEXTAREA"||K.isContentEditable))return;const te=le?E.metaKey:E.ctrlKey;if(E.key==="Escape"){E.preventDefault(),hs.getState().disable();return}if(te&&E.key==="Backspace"){E.preventDefault(),de();return}if(te&&(E.key==="a"||E.key==="A")){const oe=A2(C?.getEntries()??[],C?.getDescendantIds()??[],hs.getState().scopeKey);if(!oe)return;E.preventDefault(),hs.getState().replaceAll(oe.ids,oe.scopeKey)}};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},Q=[k,de,o,C,h],e[66]=k,e[67]=de,e[68]=o,e[69]=C,e[70]=h,e[71]=z,e[72]=Q):(z=e[71],Q=e[72]),c.useEffect(z,Q);let ue;return e[73]!==P||e[74]!==Y||e[75]!==I||e[76]!==U||e[77]!==O||e[78]!==G||e[79]!==ge||e[80]!==de||e[81]!==Te||e[82]!==ce||e[83]!==Ee||e[84]!==ne||e[85]!==j||e[86]!==g||e[87]!==h?(ue={selectionModeEnabled:h,hasSelection:j,selectedIdsSize:g,bulkScopeIsArchived:I,derivedSelectionScope:O,bulkScopeFolders:Y,bulkCanRemoveFromFolder:P,handleToggleSelectionMode:v,handleExitSelectionMode:M,handleBulkMoveToFolder:ce,handleBulkCreateFolderAndMove:ge,handleBulkRemoveFromFolder:Ee,handleBulkDelete:de,handleBulkArchive:G,handleBulkHardDelete:Te,handleBulkRestore:ne,confirmBulkDelete:U},e[73]=P,e[74]=Y,e[75]=I,e[76]=U,e[77]=O,e[78]=G,e[79]=ge,e[80]=de,e[81]=Te,e[82]=ce,e[83]=Ee,e[84]=ne,e[85]=j,e[86]=g,e[87]=h,e[88]=ue):ue=e[88],ue};function B3(t){return t.enabled}function F3(t){return t.selectedIds.size}function _3(t){return t.selectedIds}function L3(t){return t.scopeKey}function $3(){hs.getState().toggleMode()}function z3(){hs.getState().disable()}function W3(t){const e=et.c(37),{getFolderScopesForProject:n,isInlineEditing:r,startFolderRename:i}=t,[o,l]=c.useState(null),a=Pe(X3),d=Pe(Q3),u=ss(Y3),m=ss(q3),f=ss(G3),p=ss(H3),y=nt(U3),x=nt(V3),k=nt(K3);let w;e[0]!==m||e[1]!==i?(w=C=>{const v=m(C,"New folder");return i(C,v),v},e[0]=m,e[1]=i,e[2]=w):w=e[2];let h;e[3]!==f||e[4]!==y||e[5]!==o||e[6]!==k||e[7]!==u||e[8]!==n||e[9]!==r||e[10]!==p||e[11]!==a||e[12]!==w||e[13]!==x?(h={isInlineEditing:r,showDeletionDialog:a,foldersMap:u,getFolderScopesForProject:n,addSessionsToFolder:f,removeSessionsFromFolders:p,createFolderAndStartRename:w,archiveSessions:y,unarchiveSessions:x,deleteSessions:k,bulkDeleteConfirm:o,setBulkDeleteConfirm:l},e[3]=f,e[4]=y,e[5]=o,e[6]=k,e[7]=u,e[8]=n,e[9]=r,e[10]=p,e[11]=a,e[12]=w,e[13]=x,e[14]=h):h=e[14];const g=O3(h);let j;e[15]!==g.bulkCanRemoveFromFolder||e[16]!==g.bulkScopeFolders||e[17]!==g.bulkScopeIsArchived||e[18]!==g.derivedSelectionScope||e[19]!==g.handleBulkArchive||e[20]!==g.handleBulkCreateFolderAndMove||e[21]!==g.handleBulkHardDelete||e[22]!==g.handleBulkMoveToFolder||e[23]!==g.handleBulkRemoveFromFolder||e[24]!==g.handleBulkRestore||e[25]!==g.handleExitSelectionMode||e[26]!==g.selectedIdsSize||e[27]!==g.selectionModeEnabled?(j=g.selectionModeEnabled?s.jsx(E3,{selectedCount:g.selectedIdsSize,scopeKey:g.derivedSelectionScope,scopeFolders:g.bulkScopeFolders,archivedBucket:g.bulkScopeIsArchived,onMoveToFolder:g.handleBulkMoveToFolder,onCreateFolderAndMove:g.handleBulkCreateFolderAndMove,onRemoveFromFolder:g.handleBulkRemoveFromFolder,canRemoveFromFolder:g.bulkCanRemoveFromFolder,onRestore:g.handleBulkRestore,onArchive:g.handleBulkArchive,onDelete:g.handleBulkHardDelete,onDone:g.handleExitSelectionMode}):null,e[15]=g.bulkCanRemoveFromFolder,e[16]=g.bulkScopeFolders,e[17]=g.bulkScopeIsArchived,e[18]=g.derivedSelectionScope,e[19]=g.handleBulkArchive,e[20]=g.handleBulkCreateFolderAndMove,e[21]=g.handleBulkHardDelete,e[22]=g.handleBulkMoveToFolder,e[23]=g.handleBulkRemoveFromFolder,e[24]=g.handleBulkRestore,e[25]=g.handleExitSelectionMode,e[26]=g.selectedIdsSize,e[27]=g.selectionModeEnabled,e[28]=j):j=e[28];let b;e[29]!==g.confirmBulkDelete||e[30]!==o||e[31]!==d||e[32]!==a?(b=s.jsx(Dk,{value:o,setValue:l,showDeletionDialog:a,setShowDeletionDialog:d,onConfirm:g.confirmBulkDelete}),e[29]=g.confirmBulkDelete,e[30]=o,e[31]=d,e[32]=a,e[33]=b):b=e[33];let S;return e[34]!==j||e[35]!==b?(S=s.jsxs(s.Fragment,{children:[j,b]}),e[34]=j,e[35]=b,e[36]=S):S=e[36],S}function K3(t){return t.deleteSessions}function V3(t){return t.unarchiveSessions}function U3(t){return t.archiveSessions}function H3(t){return t.removeSessionsFromFolders}function G3(t){return t.addSessionsToFolder}function q3(t){return t.createFolder}function Y3(t){return t.foldersMap}function Q3(t){return t.setShowDeletionDialog}function X3(t){return t.showDeletionDialog}const mm="oc.sessions.expandedParents.v3",J3=rl(ur()),Z3=()=>{try{const t=globalThis.localStorage.getItem(mm);if(t===null)return new Set;const e=J3.safeParse(JSON.parse(t));return e.success?new Set(e.data):new Set}catch{return new Set}},e4=()=>{const[t,e]=c.useState(Z3),n=c.useRef(t);n.current=t;const r=c.useCallback(i=>{const o=ex(n.current,i);n.current=o,e(o);try{globalThis.localStorage.setItem(mm,JSON.stringify([...o]))}catch{}},[]);return{expandedParents:t,toggleParent:r}},t4=t=>{const e=et.c(22),{childStores:n,sections:r,chatGroup:i,canGrantAccess:o}=t,l=js(s4),a=js(n4);let d;e[0]!==i||e[1]!==r?(d=[...r.flatMap(r4),...i?[{key:"activity:chats",group:i}]:[]].map(a4),e[0]=i,e[1]=r,e[2]=d):d=e[2];const u=d;let m;e[3]!==u?(m=new Set(u.flatMap(l4)),e[3]=u,e[4]=m):m=e[4];let f;e[5]!==m?(f=[...m],e[5]=m,e[6]=f):f=e[6];const p=f;let y;e[7]!==n||e[8]!==p.length?(y=j=>p.length>0?n.subscribeBootstrap(j):c4,e[7]=n,e[8]=p.length,e[9]=y):y=e[9];let x;e[10]!==n||e[11]!==p?(x=()=>p.map(j=>`${j}\0${n.getBootstrapState(j)??""}\0${n.getBootstrapFailure(j)??""}\0${n.getInitializationState(j)??""}\0${n.getInitializationFailure(j)??""}`).join(""),e[10]=n,e[11]=p,e[12]=x):x=e[12];const k=c.useSyncExternalStore(y,x,d4);let w;if(e[13]!==o||e[14]!==n||e[15]!==l||e[16]!==u||e[17]!==a){w=new Map;for(const{key:j,archived:b,directories:S}of u){const C=S.find(v=>n.getBootstrapState(v)==="failed"||n.getInitializationState(v)==="failed");if(C){const v=n.getBootstrapState(C)==="failed",M=v?n.getBootstrapFailure(C):n.getInitializationFailure(C);w.set(j,{state:M==="os-permission"?"permission-denied":v?"load-failed":"initialization-failed",directory:C,canGrantAccess:M==="os-permission"&&o})}else{const v=a||!b&&S.length>0&&S.every(M=>n.getBootstrapState(M)==="complete");w.set(j,{state:v?"ready":l==="error"?"load-failed":"loading",directory:v?S[0]??null:null,canGrantAccess:!1})}}e[13]=o,e[14]=n,e[15]=l,e[16]=u,e[17]=a,e[18]=w}else w=e[18];const h=w;let g;return e[19]!==k||e[20]!==h?(g={groupStatusByKey:h,bootstrapSnapshot:k},e[19]=k,e[20]=h,e[21]=g):g=e[21],g};function s4(t){return t.status}function n4(t){return t.hasLoaded}function r4(t){return t.groups.map(e=>({key:`${t.project.id}:${e.id}`,group:e}))}function o4(t){return xt(t.directory)}function i4(t){return!!t}function a4(t){const{key:e,group:n}=t;return{key:e,archived:n.isArchivedBucket===!0,directories:eo(n).map(o4).filter(i4)}}function l4(t){return t.directories}function c4(){}function d4(){return""}const u4=5*6e4,f4=[],m4=[],h4=t=>!t.parentID,p4=t=>{const e=et.c(312),{topology:n,view:r,actions:i}=t;let o,l,a,d,u;e[0]!==i?({alwaysShowActions:o,notifyOnSubtasks:l,projectViewActions:a,rowActions:d,...u}=i,e[0]=i,e[1]=o,e[2]=l,e[3]=a,e[4]=d,e[5]=u):(o=e[1],l=e[2],a=e[3],d=e[4],u=e[5]);const m=ss(x4),f=ss(b4),p=ss(y4),y=ss(w4),x=r.projectView,{getOrderedGroups:k,setGroupOrderByProject:w,toggleGroup:h,toggleProject:g}=a;let j;e[6]!==n.isVSCode||e[7]!==n.knownDirectories?(j={knownDirectories:n.knownDirectories,isVSCode:n.isVSCode,isVisible:!0},e[6]=n.isVSCode,e[7]=n.knownDirectories,e[8]=j):j=e[8];const b=Hh(j),S=tx(v4);let C;e[9]!==S||e[10]!==b.archivedSessions||e[11]!==b.sessions||e[12]!==n.availableWorktreesByProject||e[13]!==n.isVSCode||e[14]!==n.projects?(C=Gh(b.sessions,n.projects,n.availableWorktreesByProject,n.isVSCode,b.archivedSessions,S),e[9]=S,e[10]=b.archivedSessions,e[11]=b.sessions,e[12]=n.availableWorktreesByProject,e[13]=n.isVSCode,e[14]=n.projects,e[15]=C):C=e[15];const v=C;let M;e[16]===Symbol.for("react.memo_cache_sentinel")?(M=new Map,e[16]=M):M=e[16];const[R,I]=c.useState(M);let B;e[17]===Symbol.for("react.memo_cache_sentinel")?(B=new Set,e[17]=B):B=e[17];const[O,T]=c.useState(B);let $;e[18]===Symbol.for("react.memo_cache_sentinel")?($=new Map,e[18]=$):$=e[18];const[_,Y]=c.useState($);let L;e[19]===Symbol.for("react.memo_cache_sentinel")?(L=(gt,It,Mt)=>{const Vt=Mt===void 0?7:Mt;I(Yt=>new Map(Yt).set(gt,It+Vt))},e[19]=L):L=e[19];const A=L;let D;e[20]===Symbol.for("react.memo_cache_sentinel")?(D=gt=>{I(It=>{if(!It.has(gt))return It;const Mt=new Map(It);return Mt.delete(gt),Mt})},e[20]=D):D=e[20];const P=D,Z=ys(S4),X=ys(j4),se=ys(k4),ce=ys(C4);let re;e[21]!==n.isVSCode?(re=!n.isVSCode&&!dh(),e[21]=n.isVSCode,e[22]=re):re=e[22];const ae=re&&X==="single",Ee=r.sidebarViewMode==="timeline"&&!n.isVSCode,Se=Z&&!ae&&!Ee;let me;e[23]!==b.pinnedSessionIds||e[24]!==b.rootSessions||e[25]!==b.sessionOrderRanks||e[26]!==Se||e[27]!==n.isVSCode?(me={enabled:Se,isVSCode:n.isVSCode,pinnedSessionIds:b.pinnedSessionIds,sessionOrderRanks:b.sessionOrderRanks,sessions:b.rootSessions},e[23]=b.pinnedSessionIds,e[24]=b.rootSessions,e[25]=b.sessionOrderRanks,e[26]=Se,e[27]=n.isVSCode,e[28]=me):me=e[28];const ke=qh(me),[V,J]=c.useState(null),[de,we]=c.useState(null),[G,Ce]=c.useState(""),[Te,pe]=c.useState(null),[ne,xe]=c.useState(null),[U,z]=c.useState(null);let Q;e[29]===Symbol.for("react.memo_cache_sentinel")?(Q=(gt,It)=>{z({scopeKey:gt,folderId:It.id,draft:It.name})},e[29]=Q):Q=e[29];const ue=Q;let le;e[30]===Symbol.for("react.memo_cache_sentinel")?(le=gt=>{z(It=>It?{...It,draft:gt}:null)},e[30]=le):le=e[30];const W=le;let E;e[31]===Symbol.for("react.memo_cache_sentinel")?(E=()=>z(null),e[31]=E):E=e[31];const K=E,{expandedParents:te,toggleParent:oe}=e4(),he=nt(N4);let ie;e[32]!==he?(ie=(gt,It)=>{gt!==nt.getState().currentSessionId&&he(gt,It)},e[32]=he,e[33]=ie):ie=e[33];const Fe=ie,_e=Uu(),Ae=ys(A4);let Me;e[34]!==b.pinnedSessionIds||e[35]!==b.sessionOrderRanks||e[36]!==v.bySessionId||e[37]!==n.gitBranches||e[38]!==n.isVSCode||e[39]!==n.worktreeMetadata||e[40]!==r.homeDirectory||e[41]!==Ae?(Me={homeDirectory:r.homeDirectory,worktreeMetadata:n.worktreeMetadata,pinnedSessionIds:b.pinnedSessionIds,sessionOrderRanks:b.sessionOrderRanks,gitBranches:n.gitBranches,isVSCode:n.isVSCode,worktreeSortOrder:Ae,sessionOwners:v.bySessionId},e[34]=b.pinnedSessionIds,e[35]=b.sessionOrderRanks,e[36]=v.bySessionId,e[37]=n.gitBranches,e[38]=n.isVSCode,e[39]=n.worktreeMetadata,e[40]=r.homeDirectory,e[41]=Ae,e[42]=Me):Me=e[42];const{buildGroupedSessions:q,filterSessionNodesForSearch:Ne,buildGroupSearchText:je}=T3(Me);let We;e[43]!==v?(We={ownership:v},e[43]=v,e[44]=We):We=e[44];const{getSessionsForProject:tt,getArchivedSessionsForProject:it}=Zj(We);let rt;e:{if(n.isVSCode){rt=null;break e}let gt;e[45]!==b.chatSessions||e[46]!==r.homeDirectory?(gt=sx(r.homeDirectory)??b.chatSessions.map(P4).find(Boolean)??null,e[45]=b.chatSessions,e[46]=r.homeDirectory,e[47]=gt):gt=e[47];const It=gt;if(!It){rt=null;break e}let Mt;if(e[48]!==It||e[49]!==b.chatSessions){const cs=[It,...b.chatSessions.map(D4).filter(Boolean)];let ms;e[51]!==cs?(ms=new Set(cs),e[51]=cs,e[52]=ms):ms=e[52],Mt=Array.from(ms).filter(I4).map(T4),e[48]=It,e[49]=b.chatSessions,e[50]=Mt}else Mt=e[50];const Vt=Mt;let Yt;if(e[53]!==b.chatSessions||e[54]!==b.childrenMap){let cs;e[56]!==b.childrenMap?(cs=ms=>uo(b.childrenMap,ms),e[56]=b.childrenMap,e[57]=cs):cs=e[57],Yt=b.chatSessions.filter(E4).map(cs),e[53]=b.chatSessions,e[54]=b.childrenMap,e[55]=Yt}else Yt=e[55];let qt;e[58]!==It||e[59]!==Vt||e[60]!==Yt?(qt={id:"managed-chats",label:"",branch:null,description:null,isMain:!0,worktree:null,directory:It,folderScopeKey:It,folderScopes:Vt,draftTarget:"chat",sessions:Yt},e[58]=It,e[59]=Vt,e[60]=Yt,e[61]=qt):qt=e[61],rt=qt}const ot=rt;let ft;e[62]!==ot?(ft=ot?[ot]:f4,e[62]=ot,e[63]=ft):ft=e[63];const st=ft;let Ct;e[64]!==je||e[65]!==q||e[66]!==Ne||e[67]!==m||e[68]!==it||e[69]!==tt||e[70]!==st||e[71]!==n.availableWorktreesByProject||e[72]!==n.gitBranches||e[73]!==n.lastRepoStatus||e[74]!==n.projectRepoStatus||e[75]!==n.projectRootBranches||e[76]!==n.projects||e[77]!==r.hasSessionSearchQuery||e[78]!==r.normalizedSessionSearchQuery?(Ct={normalizedProjects:n.projects,getSessionsForProject:tt,getArchivedSessionsForProject:it,availableWorktreesByProject:n.availableWorktreesByProject,projectRepoStatus:n.projectRepoStatus,projectRootBranches:n.projectRootBranches,gitBranches:n.gitBranches,lastRepoStatus:n.lastRepoStatus,buildGroupedSessions:q,hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,filterSessionNodesForSearch:Ne,buildGroupSearchText:je,foldersMap:m,standaloneGroups:st},e[64]=je,e[65]=q,e[66]=Ne,e[67]=m,e[68]=it,e[69]=tt,e[70]=st,e[71]=n.availableWorktreesByProject,e[72]=n.gitBranches,e[73]=n.lastRepoStatus,e[74]=n.projectRepoStatus,e[75]=n.projectRootBranches,e[76]=n.projects,e[77]=r.hasSessionSearchQuery,e[78]=r.normalizedSessionSearchQuery,e[79]=Ct):Ct=e[79];const{projectSections:ht,groupSearchDataByGroup:be,sectionsForRender:Je,flatSectionsForRender:dt}=s2(Ct),Ke=r.onSearchMatchCountChange;let mt,ee;e[80]!==Ke?(mt=()=>()=>Ke(0),ee=[Ke],e[80]=Ke,e[81]=mt,e[82]=ee):(mt=e[81],ee=e[82]),c.useEffect(mt,ee);const fe=li(),Ie=r.useGroupedSections?Je:dt;let $e;e[83]!==Ie||e[84]!==r.showInlineArchived?($e=r.showInlineArchived?Ie:Ie.map(O4),e[83]=Ie,e[84]=r.showInlineArchived,e[85]=$e):$e=e[85];const H=$e;let Be;e[86]!==dt?(Be=gt=>dt.find(Mt=>Mt.project.id===gt)?.groups.find(B4)?.folderScopes??[],e[86]=dt,e[87]=Be):Be=e[87];const Ye=Be;let qe;e[88]!==y||e[89]!==b.hasAuthoritativeGlobalSessions||e[90]!==p||e[91]!==m||e[92]!==v||e[93]!==n.projects||e[94]!==r.isSessionsLoading||e[95]!==r.isWorktreeTopologyLoading||e[96]!==r.unresolvedWorktreeProjectPaths?(qe={enabled:!0,normalizedProjects:n.projects,ownership:v,isSessionsLoading:r.isSessionsLoading,hasAuthoritativeGlobalSessions:b.hasAuthoritativeGlobalSessions,isWorktreeTopologyLoading:r.isWorktreeTopologyLoading,unresolvedWorktreeProjectPaths:r.unresolvedWorktreeProjectPaths,foldersMap:m,createFolder:p,addSessionToFolder:y},e[88]=y,e[89]=b.hasAuthoritativeGlobalSessions,e[90]=p,e[91]=m,e[92]=v,e[93]=n.projects,e[94]=r.isSessionsLoading,e[95]=r.isWorktreeTopologyLoading,e[96]=r.unresolvedWorktreeProjectPaths,e[97]=qe):qe=e[97],Hj(qe);const{github:Xe}=kn(),jt=Rn(F4),Ve=Rn(_4),pt=Vs(L4),Rt=Vs($4),De=Vs(z4);let yt;e[98]===Symbol.for("react.memo_cache_sentinel")?(yt=new Set,e[98]=yt):yt=e[98];const Pt=c.useRef(yt);let Ue;e[99]!==pt||e[100]!==Xe||e[101]!==Ve||e[102]!==jt||e[103]!==ht||e[104]!==x.collapsedProjects||e[105]!==De||e[106]!==Rt||e[107]!==n.gitBranches?(Ue=()=>{if(!Xe||!Ve||!jt?.connected)return;const gt=new Map,It=Date.now();ht.forEach(Mt=>{x.collapsedProjects.has(Mt.project.id)||Mt.groups.forEach(Vt=>{if(Vt.isArchivedBucket||Vt.isMain)return;const Yt=xt(Vt.directory??null),qt=Vt.branch?.trim()||n.gitBranches.get(Yt||"")?.trim();if(!Yt||!qt)return;const cs=si(Yt,qt),ms=Vs.getState().entries[cs],qn=ms?.status?.pr?.state==="closed"||ms?.status?.pr?.state==="merged",ao=`${Yt}::${qt}`,vi=Math.max(ms?.lastRefreshAt??0,ms?.lastDiscoveryPollAt??0),lo=!!(ms?.isInitialStatusResolved&&(!ms.status?.pr||qn)&&(!Pt.current.has(ao)||It-vi>=u4));(!ms||!ms.isInitialStatusResolved||lo)&&(lo&&Pt.current.add(ao),gt.set(cs,{directory:Yt,branch:qt}))})}),gt.forEach((Mt,Vt)=>{pt(Vt),Rt(Vt,{...Mt,remoteName:null,canShow:!0,github:Xe,githubAuthChecked:Ve,githubConnected:jt.connected})}),gt.size&&De([...gt.values()],{silent:!0,markInitialResolved:!0})},e[99]=pt,e[100]=Xe,e[101]=Ve,e[102]=jt,e[103]=ht,e[104]=x.collapsedProjects,e[105]=De,e[106]=Rt,e[107]=n.gitBranches,e[108]=Ue):Ue=e[108];const He=jt?.connected;let ve;e[109]!==pt||e[110]!==Xe||e[111]!==Ve||e[112]!==ht||e[113]!==x.collapsedProjects||e[114]!==De||e[115]!==Rt||e[116]!==He||e[117]!==n.gitBranches?(ve=[pt,Xe,Ve,He,ht,x.collapsedProjects,De,Rt,n.gitBranches],e[109]=pt,e[110]=Xe,e[111]=Ve,e[112]=ht,e[113]=x.collapsedProjects,e[114]=De,e[115]=Rt,e[116]=He,e[117]=n.gitBranches,e[118]=ve):ve=e[118],c.useEffect(Ue,ve);let Qe;e[119]!==b.orderedSessions?(Qe=new Map(b.orderedSessions.map(W4)),e[119]=b.orderedSessions,e[120]=Qe):Qe=e[120];const Ge=Qe;let Ze;e[121]!==k||e[122]!==H||e[123]!==Ae?(Ze=Ae!=="manual"?H:H.map(gt=>{const It=k(gt.project.id,gt.groups);return It===gt.groups?gt:{...gt,groups:It}}),e[121]=k,e[122]=H,e[123]=Ae,e[124]=Ze):Ze=e[124];const lt=Ze;let Bt;if(e[125]!==b.childrenMap||e[126]!==v.bySessionId||e[127]!==ke||e[128]!==n.availableWorktreesByProject||e[129]!==n.gitBranches||e[130]!==n.projects||e[131]!==r.hasSessionSearchQuery||e[132]!==r.homeDirectory||e[133]!==r.normalizedSessionSearchQuery){let gt;e[135]!==b.childrenMap?(gt=qt=>[qt.id,uo(b.childrenMap,qt)],e[135]=b.childrenMap,e[136]=gt):gt=e[136];const It=new Map(ke.map(gt)),Mt=[...It.values()],Vt=[];for(;Mt.length>0;){const qt=Mt.pop();if(!qt)break;Vt.push(qt.session),Mt.push(...qt.children)}const Yt=Tl({sessions:Vt,projects:n.projects,ownerBySessionId:v.bySessionId,availableWorktreesByProject:n.availableWorktreesByProject,gitBranches:n.gitBranches,homeDirectory:r.homeDirectory,hideBranchMatchingProjectLabel:!0});Bt=Yh({sessions:ke,getSessionLocation:qt=>Yt.get(qt)??null,getSessionNode:qt=>It.get(qt.id)??uo(b.childrenMap,qt),query:r.hasSessionSearchQuery?r.normalizedSessionSearchQuery:""}),e[125]=b.childrenMap,e[126]=v.bySessionId,e[127]=ke,e[128]=n.availableWorktreesByProject,e[129]=n.gitBranches,e[130]=n.projects,e[131]=r.hasSessionSearchQuery,e[132]=r.homeDirectory,e[133]=r.normalizedSessionSearchQuery,e[134]=Bt}else Bt=e[134];const $t=Bt;let Wt;e:{if(!Ee){Wt=m4;break e}let gt;e[137]!==b.rootSessions?(gt=new Set(b.rootSessions.map(K4)),e[137]=b.rootSessions,e[138]=gt):gt=e[138];const It=gt;let Mt;if(e[139]!==b.childrenMap||e[140]!==b.orderedSessions||e[141]!==v.bySessionId||e[142]!==It||e[143]!==n.availableWorktreesByProject||e[144]!==n.gitBranches||e[145]!==n.projectRootBranches||e[146]!==n.projects||e[147]!==r.hasSessionSearchQuery||e[148]!==r.homeDirectory||e[149]!==r.normalizedSessionSearchQuery){let Vt;e[151]!==It?(Vt=cs=>It.has(cs.id)&&!cs.time?.archived,e[151]=It,e[152]=Vt):Vt=e[152];const Yt=b.orderedSessions.filter(Vt),qt=Tl({sessions:Yt,projects:n.projects,ownerBySessionId:v.bySessionId,availableWorktreesByProject:n.availableWorktreesByProject,gitBranches:n.gitBranches,homeDirectory:r.homeDirectory,rootBranchByProjectId:n.projectRootBranches,hideBranchMatchingProjectLabel:!1});Mt=Qh({sessions:Yt,getSessionLocation:cs=>qt.get(cs)??null,getSessionNode:cs=>({...uo(b.childrenMap,cs),children:[],worktree:qt.get(cs.id)?.worktree??null}),query:r.hasSessionSearchQuery?r.normalizedSessionSearchQuery:""}),e[139]=b.childrenMap,e[140]=b.orderedSessions,e[141]=v.bySessionId,e[142]=It,e[143]=n.availableWorktreesByProject,e[144]=n.gitBranches,e[145]=n.projectRootBranches,e[146]=n.projects,e[147]=r.hasSessionSearchQuery,e[148]=r.homeDirectory,e[149]=r.normalizedSessionSearchQuery,e[150]=Mt}else Mt=e[150];Wt=Mt}const Xt=Wt;let Ft;e[153]===Symbol.for("react.memo_cache_sentinel")?(Ft=qd(),e[153]=Ft):Ft=e[153];let Jt;e[154]!==ot||e[155]!==fe||e[156]!==lt?(Jt={childStores:fe,sections:lt,chatGroup:ot,canGrantAccess:Ft},e[154]=ot,e[155]=fe,e[156]=lt,e[157]=Jt):Jt=e[157];const{groupStatusByKey:Lt,bootstrapSnapshot:is}=t4(Jt);let _t;e[158]!==ht||e[159]!==se||e[160]!==ae||e[161]!==r.activeProjectId?(_t=null,ae&&(ht.some(gt=>gt.project.id===se)?_t=se:ht.some(gt=>gt.project.id===r.activeProjectId)?_t=r.activeProjectId:_t=ht[0]?.project.id??null),e[158]=ht,e[159]=se,e[160]=ae,e[161]=r.activeProjectId,e[162]=_t):_t=e[162];const zt=ae&&!r.useGroupedSections?20:void 0,Nt=Ee?u.openProjectEditDialog:void 0;let At;e[163]!==i.startSessionWorktreeMenuLoad||e[164]!==o||e[165]!==b.pinnedSessionIds||e[166]!==ne||e[167]!==G||e[168]!==V||e[169]!==de||e[170]!==te||e[171]!==U||e[172]!==be||e[173]!==l||e[174]!==x.collapsedGroups||e[175]!==d.allowReselect||e[176]!==d.onSessionSelected||e[177]!==d.resetSessionSearch||e[178]!==Ge||e[179]!==zt||e[180]!==Nt||e[181]!==oe||e[182]!==r.activeProjectId||e[183]!==r.hasSessionSearchQuery||e[184]!==r.hideDirectoryControls||e[185]!==r.mobileVariant||e[186]!==r.normalizedSessionSearchQuery?(At={hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,groupSearchDataByGroup:be,collapsedGroups:x.collapsedGroups,hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:o,activeProjectId:r.activeProjectId,notifyOnSubtasks:l,pinnedSessionIds:b.pinnedSessionIds,sessionOrderIndex:Ge,expandedParents:te,editingId:V,editingRowKey:de,editTitle:G,sessionBatchSize:zt,setEditingId:J,setEditingRowKey:we,setEditTitle:Ce,toggleParent:oe,allowReselect:d.allowReselect,onSessionSelected:d.onSessionSelected,resetSessionSearch:d.resetSessionSearch,deleteSessionConfirm:ne,setDeleteSessionConfirm:xe,startFolderRename:ue,startSessionWorktreeMenuLoad:i.startSessionWorktreeMenuLoad,onEditProject:Nt,folderRename:U,setFolderRenameDraft:W,clearFolderRename:K},e[163]=i.startSessionWorktreeMenuLoad,e[164]=o,e[165]=b.pinnedSessionIds,e[166]=ne,e[167]=G,e[168]=V,e[169]=de,e[170]=te,e[171]=U,e[172]=be,e[173]=l,e[174]=x.collapsedGroups,e[175]=d.allowReselect,e[176]=d.onSessionSelected,e[177]=d.resetSessionSearch,e[178]=Ge,e[179]=zt,e[180]=Nt,e[181]=oe,e[182]=r.activeProjectId,e[183]=r.hasSessionSearchQuery,e[184]=r.hideDirectoryControls,e[185]=r.mobileVariant,e[186]=r.normalizedSessionSearchQuery,e[187]=At):At=e[187];const us=At;let xs;e[188]!==u.openNewSessionDraft||e[189]!==u.setActiveProjectIdOnly||e[190]!==u.setSessionSwitcherOpen||e[191]!==h?(xs={showMoreGroupSessions:A,resetGroupSessionLimit:P,setActiveProjectIdOnly:u.setActiveProjectIdOnly,setSessionSwitcherOpen:u.setSessionSwitcherOpen,openNewSessionDraft:u.openNewSessionDraft,onToggleCollapsedGroup:h},e[188]=u.openNewSessionDraft,e[189]=u.setActiveProjectIdOnly,e[190]=u.setSessionSwitcherOpen,e[191]=h,e[192]=xs):xs=e[192];const qs=xs;let Zt;if(e[193]!==ot||e[194]!==fe||e[195]!==b.hasAuthoritativeGlobalSessions||e[196]!==lt){Zt=new Map;for(const gt of lt)for(const It of gt.groups){const Mt=nr(gt.project.id,It.directory);if(!Mt)continue;const Vt=eo(It),Yt=Zt.get(Mt),qt=[...new Set([...Yt?.scopeKeys??[],...Vt.map(V4)])],cs=b.hasAuthoritativeGlobalSessions&&Vt.every(ms=>{const qn=xt(ms.directory);return!qn||fe.getBootstrapState(qn)==="complete"});Zt.set(Mt,{scopeKeys:qt,complete:(Yt?.complete??!0)&&cs})}if(ot){let gt;e[198]!==ot.directory?(gt=nr(null,ot.directory),e[198]=ot.directory,e[199]=gt):gt=e[199];const It=gt;if(It){let Mt;e[200]!==ot?(Mt=eo(ot).map(U4),e[200]=ot,e[201]=Mt):Mt=e[201];let Vt;e[202]!==b.hasAuthoritativeGlobalSessions||e[203]!==Mt?(Vt={scopeKeys:Mt,complete:b.hasAuthoritativeGlobalSessions},e[202]=b.hasAuthoritativeGlobalSessions,e[203]=Mt,e[204]=Vt):Vt=e[204],Zt.set(It,Vt)}}e[193]=ot,e[194]=fe,e[195]=b.hasAuthoritativeGlobalSessions,e[196]=lt,e[197]=Zt}else Zt=e[197];const nn=Zt;let Cn;e[205]!==_||e[206]!==R?(Cn=new Map([...R,..._]),e[205]=_,e[206]=R,e[207]=Cn):Cn=e[207];const rn=Cn,hn=r.hasSessionSearchQuery?"search":"normal",on=Ee?"timeline":"projects",Ts=Z&&!ae&&!Ee,zs=ae&&!Ee,Ws=ae&&!r.useGroupedSections?20:void 0;let an;e[208]!==ot||e[209]!==O||e[210]!==f||e[211]!==b.pinnedSessionIds||e[212]!==te||e[213]!==nn||e[214]!==m||e[215]!==be||e[216]!==Lt||e[217]!==lt||e[218]!==ht||e[219]!==x.collapsedGroups||e[220]!==x.collapsedProjects||e[221]!==$t||e[222]!==_t||e[223]!==Ge||e[224]!==hn||e[225]!==on||e[226]!==Ts||e[227]!==zs||e[228]!==Ws||e[229]!==Xt||e[230]!==r.activeProjectId||e[231]!==r.hideDirectoryControls||e[232]!==r.normalizedSessionSearchQuery||e[233]!==r.showOnlyMainWorkspace||e[234]!==rn?(an=Zk({mode:hn,viewMode:on,sections:lt,authoritativeSections:ht,chatGroup:ot,recentSections:$t,timelineItems:Xt,showRecentSection:Ts,foldersMap:m,groupSearchDataByGroup:be,normalizedQuery:r.normalizedSessionSearchQuery,collapsedProjects:x.collapsedProjects,collapsedGroups:x.collapsedGroups,collapsedFolders:f,collapsedActivities:O,expandedParents:te,visibleCountByContainer:rn,pinnedSessionIds:b.pinnedSessionIds,sessionOrderIndex:Ge,groupStatusByKey:Lt,folderAuthorityByOwner:nn,activeProjectId:r.activeProjectId,singleProjectMode:zs,singleProjectId:_t,showOnlyMainWorkspace:r.showOnlyMainWorkspace,hideDirectoryControls:r.hideDirectoryControls,sessionBatchSize:Ws}),e[208]=ot,e[209]=O,e[210]=f,e[211]=b.pinnedSessionIds,e[212]=te,e[213]=nn,e[214]=m,e[215]=be,e[216]=Lt,e[217]=lt,e[218]=ht,e[219]=x.collapsedGroups,e[220]=x.collapsedProjects,e[221]=$t,e[222]=_t,e[223]=Ge,e[224]=hn,e[225]=on,e[226]=Ts,e[227]=zs,e[228]=Ws,e[229]=Xt,e[230]=r.activeProjectId,e[231]=r.hideDirectoryControls,e[232]=r.normalizedSessionSearchQuery,e[233]=r.showOnlyMainWorkspace,e[234]=rn,e[235]=an):an=e[235];const as=an;let ps,Ys;e[236]!==Ke||e[237]!==as.searchMatchCount?(ps=()=>{Ke(as.searchMatchCount)},Ys=[Ke,as.searchMatchCount],e[236]=Ke,e[237]=as.searchMatchCount,e[238]=ps,e[239]=Ys):(ps=e[238],Ys=e[239]),c.useEffect(ps,Ys);let fs;e[240]!==O||e[241]!==V||e[242]!==Te||e[243]!==_||e[244]!==R?(fs={editingId:V,openSidebarMenuKey:Te,setOpenSidebarMenuKey:pe,visibleSessionCountByGroup:R,collapsedActivityKeys:O,setCollapsedActivityKeys:T,visibleActivityCountByKey:_,setVisibleActivityCountByKey:Y},e[240]=O,e[241]=V,e[242]=Te,e[243]=_,e[244]=R,e[245]=fs):fs=e[245];let ln;e[246]!==us||e[247]!==lt||e[248]!==ht||e[249]!==as||e[250]!==ae||e[251]!==fs||e[252]!==n.projectRepoStatus||e[253]!==r.emptyState||e[254]!==r.searchEmptyState?(ln={rowModel:as,sectionsForRender:lt,projectSections:ht,singleProjectMode:ae,emptyState:r.emptyState,searchEmptyState:r.searchEmptyState,projectRepoStatus:n.projectRepoStatus,state:fs,groupProps:us},e[246]=us,e[247]=lt,e[248]=ht,e[249]=as,e[250]=ae,e[251]=fs,e[252]=n.projectRepoStatus,e[253]=r.emptyState,e[254]=r.searchEmptyState,e[255]=ln):ln=e[255];const pn=ln;let gn;e[256]!==o||e[257]!==Ee||e[258]!==r.hasSessionSearchQuery||e[259]!==r.hideDirectoryControls||e[260]!==r.homeDirectory||e[261]!==r.mobileVariant||e[262]!==r.projectSortOrder||e[263]!==r.stickyZoneHeaders||e[264]!==Ae?(gn={homeDirectory:r.homeDirectory,hasSessionSearchQuery:r.hasSessionSearchQuery,hideDirectoryControls:r.hideDirectoryControls,stickyZoneHeaders:r.stickyZoneHeaders,mobileVariant:r.mobileVariant,alwaysShowActions:o,projectSortOrder:r.projectSortOrder,worktreeSortOrder:Ae,timelineView:Ee},e[256]=o,e[257]=Ee,e[258]=r.hasSessionSearchQuery,e[259]=r.hideDirectoryControls,e[260]=r.homeDirectory,e[261]=r.mobileVariant,e[262]=r.projectSortOrder,e[263]=r.stickyZoneHeaders,e[264]=Ae,e[265]=gn):gn=e[265];const xn=gn;let bn;e[266]!==qs||e[267]!==u.openNewSessionDraft||e[268]!==u.openNewWorktreeDialog||e[269]!==u.openProjectEditDialog||e[270]!==u.openWorktreesPage||e[271]!==u.removeProject||e[272]!==u.renderProjectStatusIndicator||e[273]!==u.reorderProjects||e[274]!==u.setActiveProjectIdOnly||e[275]!==u.setSessionSwitcherOpen||e[276]!==w||e[277]!==ce||e[278]!==g?(bn={group:qs,toggleProject:g,setActiveProjectIdOnly:u.setActiveProjectIdOnly,setSessionSwitcherOpen:u.setSessionSwitcherOpen,openNewSessionDraft:u.openNewSessionDraft,openNewWorktreeDialog:u.openNewWorktreeDialog,openWorktreesPage:u.openWorktreesPage,openProjectEditDialog:u.openProjectEditDialog,removeProject:u.removeProject,reorderProjects:u.reorderProjects,setGroupOrderByProject:w,renderProjectStatusIndicator:u.renderProjectStatusIndicator,setSingleProjectId:ce},e[266]=qs,e[267]=u.openNewSessionDraft,e[268]=u.openNewWorktreeDialog,e[269]=u.openProjectEditDialog,e[270]=u.openWorktreesPage,e[271]=u.removeProject,e[272]=u.renderProjectStatusIndicator,e[273]=u.reorderProjects,e[274]=u.setActiveProjectIdOnly,e[275]=u.setSessionSwitcherOpen,e[276]=w,e[277]=ce,e[278]=g,e[279]=bn):bn=e[279];const N=bn;let ye;e[280]===Symbol.for("react.memo_cache_sentinel")?(ye=s.jsx(Wj,{}),e[280]=ye):ye=e[280];let Le;e[281]!==i.initialActiveSessionByProject||e[282]!==i.openNewSessionDraft||e[283]!==i.persistActiveSessionByProject||e[284]!==i.setSessionSwitcherOpen||e[285]!==v.bySessionId||e[286]!==ht||e[287]!==Fe||e[288]!==r.activeProjectId||e[289]!==r.mobileVariant?(Le=s.jsx(Qj,{projectSections:ht,activeProjectId:r.activeProjectId,initialActiveSessionByProject:i.initialActiveSessionByProject,persistActiveSessionByProject:i.persistActiveSessionByProject,mobileVariant:r.mobileVariant,openNewSessionDraft:i.openNewSessionDraft,setSessionSwitcherOpen:i.setSessionSwitcherOpen,sessionOwnerBySessionId:v.bySessionId,handleSessionSelect:Fe}),e[281]=i.initialActiveSessionByProject,e[282]=i.openNewSessionDraft,e[283]=i.persistActiveSessionByProject,e[284]=i.setSessionSwitcherOpen,e[285]=v.bySessionId,e[286]=ht,e[287]=Fe,e[288]=r.activeProjectId,e[289]=r.mobileVariant,e[290]=Le):Le=e[290];let at;e[291]!==b.orderedSessions||e[292]!==_e||e[293]!==ke?(at=s.jsx(l2,{sortedSessions:b.orderedSessions,recentSessions:ke,prefetchSession:_e}),e[291]=b.orderedSessions,e[292]=_e,e[293]=ke,e[294]=at):at=e[294];const Tt=V!==null;let Dt;e[295]!==Ye||e[296]!==Tt?(Dt=s.jsx(W3,{getFolderScopesForProject:Ye,isInlineEditing:Tt,startFolderRename:ue}),e[295]=Ye,e[296]=Tt,e[297]=Dt):Dt=e[297];let bt;e[298]!==N||e[299]!==pn||e[300]!==xn?(bt=s.jsx(I3,{model:pn,view:xn,actions:N}),e[298]=N,e[299]=pn,e[300]=xn,e[301]=bt):bt=e[301];let Kt;e[302]!==as.selectionDescendantIds||e[303]!==as.selectionEntries||e[304]!==as.sessionById||e[305]!==Dt||e[306]!==bt?(Kt=s.jsxs(N2,{entries:as.selectionEntries,descendantIds:as.selectionDescendantIds,sessionsById:as.sessionById,children:[Dt,bt]}),e[302]=as.selectionDescendantIds,e[303]=as.selectionEntries,e[304]=as.sessionById,e[305]=Dt,e[306]=bt,e[307]=Kt):Kt=e[307];let ls;return e[308]!==Le||e[309]!==at||e[310]!==Kt?(ls=s.jsxs(s.Fragment,{children:[ye,Le,at,Kt]}),e[308]=Le,e[309]=at,e[310]=Kt,e[311]=ls):ls=e[311],ls},g4=t=>{const e=et.c(2);let n;return e[0]!==t?(n=t.view.isVisible?s.jsx(p4,{...t}):null,e[0]=t,e[1]=n):n=e[1],n};function x4(t){return t.foldersMap}function b4(t){return t.collapsedFolderIds}function y4(t){return t.createFolder}function w4(t){return t.addSessionToFolder}function v4(t){return t.projects}function S4(t){return t.showRecentSection}function j4(t){return t.projectDisplayMode}function k4(t){return t.singleProjectId}function C4(t){return t.setSingleProjectId}function N4(t){return t.setCurrentSession}function A4(t){return t.worktreeSortOrder}function P4(t){return Ja(t.directory)}function D4(t){return xt(t.directory??null)}function I4(t){return!!t}function T4(t){return{scopeKey:t,directory:t}}function E4(t){return!t.time?.archived&&h4(t)}function R4(t){return t.isArchivedBucket}function M4(t){return!t.isArchivedBucket}function O4(t){return t.groups.some(R4)?{...t,groups:t.groups.filter(M4)}:t}function B4(t){return!t.isArchivedBucket}function F4(t){return t.status}function _4(t){return t.hasChecked}function L4(t){return t.ensureEntry}function $4(t){return t.setParams}function z4(t){return t.refreshTargets}function W4(t,e){return[t.id,e]}function K4(t){return t.id}function V4(t){return t.scopeKey}function U4(t){return t.scopeKey}const hm=(t,e,n)=>{const r=new Set;for(const i of t){const o=xt(i.path);o&&r.add(o)}if(n?.includeWorktrees===!1)return r;for(const i of e.values())for(const o of i){const l=xt(o.path);l&&r.add(l)}return r},gd="oc.sessions.activeSessionByProject",H4=[],G4=df(ur(),ur().min(1).catch("")),q4=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:n,allowReselect:r=!1,hideDirectoryControls:i=!1,showOnlyMainWorkspace:o=!1})=>{qi("react.session_sidebar_render"),Rs("ui.session_sidebar.render"),Rs(`ui.session_sidebar.render.${e?"mobile":"desktop"}`),Rs(`ui.session_sidebar.render.${t?"visible":"hidden"}`);const{t:l}=kt(),[a,d]=c.useState(!1),[u,m]=c.useState(""),f=c.useCallback(()=>{m(""),d(!1)},[]),[p,y]=c.useState(0),x=c.useRef(null),k=c.useRef(null),[w,h]=c.useState(null),g=c.useMemo(()=>$o(),[]),[j,b]=c.useState(new Map),S=Pe(De=>De.isNewWorktreeDialogOpen),C=Pe(De=>De.setNewWorktreeDialogOpen),[v,M]=c.useState(!1),R=c.useMemo(()=>{try{const De=g.getItem(gd);if(!De)return new Map;const yt=G4.safeParse(JSON.parse(De));if(!yt.success)return new Map;const Pt=new Map;return Object.entries(yt.data).forEach(([Ue,He])=>{He&&Pt.set(Ue,He)}),Pt}catch{return new Map}},[g]),I=c.useCallback(De=>{try{g.setItem(gd,JSON.stringify(Object.fromEntries(De.entries())))}catch{}},[g]),[B,O]=c.useState(new Map),T=os(De=>De.homeDirectory),$=Gt(De=>De.projects),_=Gt(De=>De.activeProjectId),Y=Gt(De=>De.removeProject),L=Gt(De=>De.setActiveProjectIdOnly),A=Gt(De=>De.updateProjectMeta),D=Gt(De=>De.reorderProjects),P=Pe(De=>De.setSettingsDialogOpen),Z=Pe(De=>De.toggleHelpDialog),X=Pe(De=>De.setAboutDialogOpen),se=Pe(De=>De.setSessionSwitcherOpen),ce=Pe(De=>De.setScheduledTasksDialogOpen),re=Pe(De=>De.setArchivePageOpen),ge=Pe(De=>De.setUsageStatsPageOpen),ae=Pe(De=>De.setWorktreesPageProjectId),Ee=Pe(De=>De.openMultiRunLauncher),Se=Pe(De=>De.notifyOnSubtasks),me=c.useMemo(()=>u.trim().toLowerCase(),[u]),ke=me.length>0;uj({enabled:t,isSessionSearchOpen:a,setIsSessionSearchOpen:d,sessionSearchInputRef:k,sessionSearchContainerRef:x});const V=Ou(t),J=c.useMemo(()=>Wn(),[]),de=nt(De=>De.setCurrentSession),we=nt(De=>De.worktreeMetadata),G=nt(De=>De.availableWorktreesByProject),Ce=nt(De=>De.openNewSessionDraft),Te=c.useMemo(()=>hm($,G,{includeWorktrees:!J}),[G,J,$]),pe=c.useCallback(De=>{Pe.getState().closeMainSurfaces(),Ce(De),J&&window.dispatchEvent(new CustomEvent("openchamber:navigate",{detail:{view:"chat"}}))},[J,Ce]),ne=Ur(dr(De=>({checkForUpdates:De.checkForUpdates,available:De.available,runtimeType:De.runtimeType,info:De.info,downloading:De.downloading,downloaded:De.downloaded,progress:De.progress,error:De.error,downloadUpdate:De.downloadUpdate,restartToUpdate:De.restartToUpdate}))),xe=Qt(),U=c.useMemo(()=>`${xe}|${$.map(De=>`${De.id}:${xt(De.path)??""}`).join("|")}`,[$,xe]),[z,Q]=c.useState(J?U:null),[ue,le]=c.useReducer(De=>De+1,0),W=!J&&z!==U,[E,K]=c.useState(new Set),te=c.useRef({runtimeKey:null,revision:0,worktreesByProject:new Map});c.useEffect(()=>{let De=!1;return(async()=>{const Pt=xe,Ue=Gt.getState().projects;if(nt.setState({worktreeDiscoveryByProject:new Map(Ue.map(Ft=>[xt(Ft.path)??Ft.path,"loading"]))}),Ue.length===0||J){De||(te.current={runtimeKey:null,revision:0,worktreesByProject:new Map},K(new Set),Q(U));return}const He=nt.getState().availableWorktreesByProject,ve=gl({rawWorktreesByProjectRef:te,publishedWorktreesByProject:He,runtimeKey:Pt}),Qe=ve.revision,Ge=new Map(ve.worktreesByProject),Ze=new Set,lt=3;let Bt=0;const $t=Array.from({length:lt},async()=>{for(;;){const Ft=Bt;if(Bt+=1,Ft>=Ue.length)return;const Jt=Ue[Ft],Lt=xt(Jt.path);if(Lt)try{const is=await oa(async()=>Mn.getState().directories.get(Lt)?.isGitRepo??await hu(Lt)?Hl({id:Jt.id,path:Lt}):null);if(is===null){Ge.delete(Lt);continue}if(De)return;is.length===0?Ge.delete(Lt):Ge.set(Lt,is)}catch{Ze.add(Lt)}}});if(await Promise.all($t),De||Qt()!==Pt)return;const Wt=new Set(Ue.map(Ft=>xt(Ft.path)).filter(Boolean));for(const Ft of Ge.keys())Wt.has(Ft)||Ge.delete(Ft);mk({rawWorktreesByProjectRef:te,runtimeKey:Pt,capturedRevision:Qe,nextRawWorktreesByProject:Ge,publishedWorktreesByProject:He,partitionWorktreesByRegisteredProject:Ul,projects:Ue,worktreeMapsEqual:Vl,recordWorktreesSeen:md,publishTopology:Ft=>{nt.setState(Ft)},requestRediscovery:()=>{le()},now:()=>Date.now()})&&(K(Ze),nt.setState({worktreeDiscoveryByProject:new Map(Ue.map(Ft=>{const Jt=xt(Ft.path)??Ft.path;return[Jt,Ze.has(Jt)?"error":"ready"]}))}),Q(U))})(),()=>{De=!0}},[J,U,xe,ue]);const oe=c.useMemo(()=>vn(),[]),{isTablet:he}=Vn(),ie=e||he,Fe=c.useMemo(()=>s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:l("sessions.sidebar.empty.noSessions.title")}),s.jsx("p",{className:"typography-meta mt-1",children:l("sessions.sidebar.empty.noSessions.description")})]}),[l]),_e=c.useMemo(()=>$.find(De=>De.id===w)??null,[$,w]),Ae=c.useCallback(De=>{w&&A(w,{label:De.label,icon:De.icon,color:De.color,iconBackground:De.iconBackground,defaultAgent:De.defaultAgent??null,defaultModel:De.defaultModel??null,defaultVariant:De.defaultVariant??null})},[w,A]),Me=c.useCallback(()=>{C(!0)},[C]),q=c.useCallback(()=>{const De=Ur.getState();if(De.available&&De.info){M(!0);return}ne.checkForUpdates().then(()=>{const{available:yt,error:Pt}=Ur.getState();if(Pt){ze.error(l("sessions.sidebar.updateCheck.errorTitle"),{description:Pt});return}if(!yt){ze.success(l("sessions.sidebar.updateCheck.latestVersion"));return}M(!0)})},[l,ne]),Ne=c.useCallback(()=>{e&&se(!1),P(!0)},[e,se,P]),je=ne.available&&(ne.runtimeType==="desktop"||ne.runtimeType==="web"),We=c.useCallback(()=>{mn.requestDirectoryDialog()},[]),tt=c.useMemo(()=>$.flatMap(De=>{const yt=xt(De.path);return yt?[{id:De.id,path:De.path,label:De.label,normalizedPath:yt,icon:De.icon??void 0,color:De.color??void 0,iconImage:De.iconImage??void 0,iconBackground:De.iconBackground??void 0,addedAt:De.addedAt,lastOpenedAt:De.lastOpenedAt,sidebarCollapsed:De.sidebarCollapsed}]:[]}),[$]),it=c.useMemo(()=>tt.map(De=>De.normalizedPath),[tt]),rt=nx(t?it:H4);yj({enabled:t,normalizedProjects:tt,gitRepoStatus:rt,setProjectRepoStatus:b,setProjectRootBranches:O});const ot=nt(De=>De.isLoading),ft=c.useRef(!1);_&&j.has(_)&&(ft.current=!!j.get(_));const st=ys(De=>De.showArchivedSessions),Ct=ys(De=>De.projectSortOrder),ht=ys(De=>De.sidebarViewMode),be=Gt(De=>De.manualProjectOrder),Je={isVisible:t,mobileVariant:e,onSessionSelected:n,allowReselect:r,hideDirectoryControls:i,showOnlyMainWorkspace:o,t:l,isTablet:he,projects:$,activeProjectId:_,manualProjectOrder:be,worktreeMetadata:we,availableWorktreesByProject:G,gitBranches:V,gitRepoStatus:rt,updateStore:ne,showArchivedSessions:st,projectSortOrder:Ct,projectRepoStatus:j,projectRootBranches:B,resolvedWorktreeTopologyKey:z,unresolvedWorktreeProjectPaths:E,isSessionSearchOpen:a,sessionSearchQuery:u,editingProjectDialogId:w,updateDialogOpen:v},dt=c.useRef(null),Ke=dt.current;if(Ke){let De=!1;for(const yt of Object.keys(Je))Object.is(Ke[yt],Je[yt])||(Rs(`ui.session_sidebar.source.${yt}`),De=!0);De||Rs("ui.session_sidebar.source.parent_or_context")}dt.current=Je;const mt=c.useMemo(()=>Xh(tt,Ct,be),[tt,Ct,be]),ee=pj({isVSCode:J,projects:mt}),fe=c.useMemo(()=>s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:l("sessions.sidebar.empty.noMatches.title")}),s.jsx("p",{className:"typography-meta mt-1",children:l("sessions.sidebar.empty.noMatches.description")})]}),[l]),Ie=J&&st,$e=!J,H=J?"projects":ht,Be=H==="projects",Xe=e?"inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md leading-none text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed":"inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md leading-none text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed",jt="h-4.5 w-4.5",Ve=c.useCallback(()=>{e&&se(!1),Ee()},[e,Ee,se]),pt=c.useMemo(()=>({projects:$,getCurrentProjects:()=>Gt.getState().projects,rawWorktreesByProjectRef:te,getPublishedWorktreesByProject:()=>nt.getState().availableWorktreesByProject,resolveProject:De=>Zi(De),listProjectWorktrees:Hl,partitionWorktreesByRegisteredProject:Ul,worktreeMapsEqual:Vl,recordWorktreesSeen:md,publishTopology:De=>{nt.setState(De)},getRuntimeKey:Qt,now:()=>Date.now()}),[$]),Rt=c.useCallback(De=>{const yt=cm(De,{projects:$,resolveProject:Zi});return fk(De,{...pt,projectRootBranch:yt?B.get(yt.id)??null:null})},[B,$,pt]);return c.useEffect(()=>{if(!J)return Hn(De=>{if(De.type==="session-created"){le();return}if(De.type==="worktree-changed")for(const yt of rx(De.directories)){const Pt=xt(yt.path),Ue=Qt(),He=ve=>{!Pt||Qt()!==Ue||nt.setState(Qe=>({worktreeDiscoveryByProject:new Map(Qe.worktreeDiscoveryByProject).set(Pt,ve)}))};He("loading"),am(yt,null,pt).then(()=>{!Pt||Qt()!==Ue||(He("ready"),K(ve=>{if(!ve.has(Pt))return ve;const Qe=new Set(ve);return Qe.delete(Pt),Qe}))}).catch(()=>{!Pt||Qt()!==Ue||(He("error"),K(ve=>new Set(ve).add(Pt)))})}})},[J,pt]),s.jsx(ca,{delay:400,closeDelay:0,timeout:300,children:s.jsxs("div",{ref:x,className:Re("relative flex h-full flex-col text-foreground overflow-x-hidden",e?"":"bg-transparent"),children:[s.jsx(Cj,{hideDirectoryControls:i,showProjectDisplayControls:!J,showRecentControls:!J,handleOpenDirectoryDialog:We,onOpenScheduled:()=>{e&&se(!1),ce(!0)},onOpenMultiRun:Ve,canOpenMultiRun:$.length>0,onOpenArchive:()=>{e&&se(!1),re(!0)},headerActionIconClass:jt,headerActionButtonClass:Xe,isSessionSearchOpen:a,setIsSessionSearchOpen:d,sessionSearchInputRef:k,sessionSearchQuery:u,setSessionSearchQuery:m,hasSessionSearchQuery:ke,searchMatchCount:p,collapseAllProjects:ee.actions.collapseAllProjects,expandAllProjects:ee.actions.expandAllProjects}),s.jsx(g4,{topology:{projects:mt,availableWorktreesByProject:G,knownDirectories:Te,isVSCode:J,worktreeMetadata:we,gitBranches:V,projectRepoStatus:j,projectRootBranches:B,lastRepoStatus:ft.current},view:{isVisible:t,hasSessionSearchQuery:ke,normalizedSessionSearchQuery:me,activeProjectId:_,showInlineArchived:Ie,useGroupedSections:$e,homeDirectory:T,mobileVariant:e,hideDirectoryControls:i,showOnlyMainWorkspace:o,isDesktopShellRuntime:oe,stickyZoneHeaders:Be,projectSortOrder:Ct,sidebarViewMode:H,emptyState:Fe,searchEmptyState:fe,isSessionsLoading:ot,isWorktreeTopologyLoading:W,unresolvedWorktreeProjectPaths:E,projectView:ee.state,onSearchMatchCountChange:y},actions:{rowActions:{allowReselect:r,onSessionSelected:n,resetSessionSearch:f},alwaysShowActions:ie,notifyOnSubtasks:Se,setActiveProjectIdOnly:L,setSessionSwitcherOpen:se,openNewSessionDraft:pe,openNewWorktreeDialog:Me,openWorktreesPage:De=>{e&&se(!1),ae(De)},openProjectEditDialog:h,removeProject:Y,reorderProjects:D,startSessionWorktreeMenuLoad:Rt,initialActiveSessionByProject:R,persistActiveSessionByProject:I,projectViewActions:ee.actions}}),s.jsx($j,{onOpenSettings:Ne,onOpenUsage:()=>ge(!0),onOpenShortcuts:Z,onOpenAbout:()=>X(!0),onOpenUpdate:q,showRuntimeButtons:!J,showUpdateButton:je}),s.jsx(Xd,{open:v,onOpenChange:M,info:ne.info,downloading:ne.downloading,downloaded:ne.downloaded,progress:ne.progress,error:ne.error,onDownload:ne.downloadUpdate,onRestart:ne.restartToUpdate,runtimeType:ne.runtimeType}),s.jsx(kj,{open:!!_e,onOpenChange:De=>{De||h(null)},project:_e,onSave:Ae}),s.jsx(Jh,{open:S,onOpenChange:C,onWorktreeCreated:(De,yt)=>{if(Pe.getState().closeMainSurfaces(),e&&se(!1),yt?.sessionId){de(yt.sessionId,De);return}Ce({directoryOverride:De,preserveDirectoryOverride:!0})}})]})})},Y4=c.memo(q4),An=t=>t?s.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,dn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Q4=()=>{const{t}=kt(),[e,n]=c.useState(!1),[r,i]=c.useState(!1),[o,l]=c.useState(null),[a,d]=c.useState([]),[u,m]=c.useState(!1),[f,p]=c.useState(!1),[y,x]=c.useState(!1),[k,w]=c.useState(!1),[h,g]=c.useState(new Set),j=nt(U=>U.getWorktreeMetadata),b=nt(U=>U.newSessionDraft),S=nt(U=>U.setNewSessionDraftTarget),C=nt(U=>U.setDraftBootstrapPendingDirectory),v=ox,M=nt(U=>U.deleteSessions),R=nt(U=>U.archiveSessions),I=Pe(U=>U.showDeletionDialog),B=Pe(U=>U.setShowDeletionDialog),O=os(U=>U.currentDirectory),T=os(U=>U.homeDirectory),$=os(U=>U.isHomeReady),_=Gt(U=>U.projects),Y=Gt(U=>U.activeProjectId),{isMobile:L,isTablet:A,hasTouchInput:D}=Vn(),P=L||A||D,Z=c.useMemo(()=>{const z=(Y?_.find(Q=>Q.id===Y)??null:null)?.path??O;return dn(z)},[Y,O,_]),X=c.useCallback(U=>{const Q=dn(U.projectDirectory)||Z;return{id:(_.find(le=>dn(le.path)===Q)??null)?.id??`path:${Q}`,path:Q}},[Z,_]),se=k&&h.size>0,ce=c.useMemo(()=>{const U=o?.worktree;return U&&typeof U.branch=="string"&&U.branch.trim().length>0?!0:a.length>0&&a.every(({metadata:z})=>typeof z.branch=="string"&&z.branch.trim().length>0)},[o?.worktree,a]),re=o?.mode==="worktree",ge=re,ae=y||!re||!ce,Ee=y||!re;c.useEffect(()=>{r||!$||_.length>0||(i(!0),n(!0))},[r,$,_.length]);const Se=c.useCallback(U=>{l({sessions:U.sessions,dateLabel:U.dateLabel,mode:U.mode??"session",worktree:U.worktree??null})},[]),me=c.useCallback(()=>{l(null),d([]),m(!1),p(!1),x(!1),w(!1),g(new Set)},[]),ke=c.useCallback(async U=>{if(U.sessions.length===0)return;if(U.sessions.length===1){const le=U.sessions[0];await v(le.id)?ze.success(t("sessions.sidebar.session.delete.success")):ze.error(t("sessions.sidebar.session.delete.error"));return}const z=U.sessions.map(le=>le.id),{deletedIds:Q,failedIds:ue}=await M(z);if(Q.length>0){const le=ue.length>0?ue.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:ue.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:ue.length}):U.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:U.dateLabel}):void 0;ze.success(Q.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:Q.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:Q.length}),{description:An(le)})}ue.length>0&&ze.error(ue.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:ue.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:ue.length}),{description:An(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[v,M,t]);c.useEffect(()=>mn.onDeleteRequest(U=>{if(!I&&(U.mode??"session")==="session"){ke(U);return}Se(U)}),[Se,I,ke]),c.useEffect(()=>mn.onDirectoryRequest(()=>{n(!0)}),[]),c.useEffect(()=>{if(!o){d([]),m(!1),p(!1),w(!1),g(new Set);return}const U=o.sessions.map(ue=>{const le=j(ue.id);return le?{session:ue,metadata:le}:null}).filter(ue=>!!ue);d(U),m(!1),w(!1),g(new Set);const z=new Map;if(o.worktree?.path&&z.set(dn(o.worktree.path),o.worktree),U.forEach(({metadata:ue})=>{ue.path&&z.set(dn(ue.path),ue)}),z.size===0){w(!0);return}let Q=!1;return(async()=>{const ue=new Map,le=new Set;await Promise.all(Array.from(z.entries()).map(async([W,E])=>{try{const K=await ix(E.path);ue.set(W,K),K?.isDirty&&le.add(W)}catch{E.status&&(ue.set(W,E.status),E.status.isDirty&&le.add(W))}})).catch(W=>{console.warn("Failed to inspect worktree status before deletion:",W)}),!Q&&(g(le),w(!0),l(W=>{if(!W?.worktree?.path)return W;const E=dn(W.worktree.path),K=ue.get(E);if(!K)return W;const te=W.worktree.status;return te?.isDirty===K.isDirty&&te?.ahead===K.ahead&&te?.behind===K.behind&&te?.upstream===K.upstream?W:{...W,worktree:{...W.worktree,status:K}}}),d(W=>W.map(E=>{const K=dn(E.metadata.path),te=ue.get(K);return te?{session:E.session,metadata:{...E.metadata,status:te}}:E})))})(),()=>{Q=!0}},[o,j]),c.useEffect(()=>{ce||m(!1)},[ce]);const V=c.useCallback(async(U,z,Q)=>{const ue=u&&ce,le=X(U),W=dn(U.path),E=dn(le.path);try{await pu(le,U,{deleteRemoteBranch:ue,deleteLocalBranch:z});const K=dn(b?.directoryOverride);return b?.open&&W&&K===W&&E&&(C(null),S({projectId:le.id,directoryOverride:E},{force:!0})),dn(O)===W&&E&&os.getState().setDirectory(E,{showOverlay:!1}),!0}catch(K){return ze.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:Ti(U)}),{id:Q,description:An(K instanceof Error?K.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[ce,O,u,X,b?.directoryOverride,b?.open,C,S,t]),J=c.useCallback((U,z,Q)=>{const ue=u&&ce,le=ze.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:Ti(U)}));(async()=>{try{if(z.length>0){const{failedIds:K}=await R(z);if(K.length>0){ze.error(K.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:K.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:K.length}),{id:le,description:An(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))});return}}if(!await V(U,Q,le))return;const E=t(ue?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");ze.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:Ti(U)}),{id:le,description:An(E)})}catch(W){ze.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:le,description:An(W instanceof Error?W.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}})()},[R,ce,u,V,t]),de=c.useCallback(async()=>{if(o){x(!0);try{const U=ge,z=U&&u,Q=U&&f;if(re&&o.worktree){J(o.worktree,o.sessions.map(ue=>ue.id),Q),me();return}if(o.sessions.length===1){const ue=o.sessions[0];if(!await v(ue.id)){ze.error(t("sessions.sidebar.session.delete.error")),x(!1);return}const W=!re&&U?t(z?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.attachedArchived"):void 0;ze.success(t("sessions.sidebar.session.delete.success"),{description:An(W),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const ue=o.sessions.map(K=>K.id);let le=[],W=[];const E=await M(ue);if(le=E.deletedIds,W=E.failedIds,le.length>0){const K=!re&&U?t(z?"sessions.sidebar.sessionDialogs.worktree.archivedAndRemoteRemoved":"sessions.sidebar.sessionDialogs.worktree.attachedArchivedPlural"):void 0,oe=[W.length>0?W.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:W.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:W.length}):o.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:o.dateLabel}):void 0,K].filter(Boolean).join(" ");ze.success(le.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:le.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:le.length}),{description:An(oe||void 0),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(W.length>0&&(ze.error(W.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:W.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:W.length}),{description:An(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),le.length===0)){x(!1);return}}me()}finally{x(!1)}}},[o,u,f,v,M,me,ge,re,J,t]),we=o?.worktree??a[0]?.metadata??null,G=o?o.mode==="worktree"?o.sessions.length===0?t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):o.sessions.length===1?t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:o.sessions.length}):t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:o.sessions.length}):o.sessions.length===1?o.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:o.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):o.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:o.sessions.length,dateLabel:o.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:o.sessions.length}):"",Ce=o?s.jsxs("div",{className:Re(re?"space-y-3":"space-y-2"),children:[o.sessions.length>0&&s.jsxs("div",{className:Re(re?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[re&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-meta font-medium text-foreground",children:o.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:o.sessions.length})]}),s.jsxs("ul",{className:Re(re?"mt-2 space-y-1":"space-y-0.5"),children:[o.sessions.slice(0,5).map(U=>s.jsxs("li",{className:Re(re?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground/80"),children:[s.jsx("span",{className:Re(!re&&"hidden"),children:"•"}),s.jsx("span",{className:"truncate",children:U.title||t("sessions.sidebar.session.untitled")})]},U.id)),o.sessions.length>5&&s.jsx("li",{className:Re(re?"px-2.5 py-1 text-xs text-muted-foreground/70":"typography-micro text-muted-foreground/70"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:o.sessions.length-5})})]})]}),re?s.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/30 p-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(F,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-meta font-medium text-foreground",children:t("sessions.sidebar.sessionDialogs.worktree.label")}),we?.label?s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:we.label}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:we?Zr(we.path,T):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),se&&s.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):s.jsx("div",{className:"rounded-xl border border-border/40 bg-sidebar/60 p-3",children:s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,Te=re?ce?s.jsxs("button",{type:"button",onClick:()=>{ae||m(U=>!U)},disabled:ae,className:Re("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",ae?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[u?s.jsx(F,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(F,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):s.jsx("span",{className:"text-xs text-muted-foreground/70",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,pe=re?s.jsxs("button",{type:"button",onClick:()=>{Ee||p(U=>!U)},disabled:Ee,className:Re("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",Ee?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[f?s.jsx(F,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(F,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,ne=re?s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[pe,Te]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ut,{variant:"ghost",onClick:me,disabled:y,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ut,{variant:"destructive",onClick:de,disabled:y,children:t(y?"sessions.sidebar.sessionDialogs.actions.deleting":"sessions.sidebar.sessionDialogs.actions.deleteWorktree")})]})]}):s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>B(!I),className:"inline-flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-pressed":!I,children:[I?s.jsx(F,{name:"checkbox-blank",className:"size-4"}):s.jsx(F,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ut,{variant:"ghost",onClick:me,disabled:y,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ut,{variant:"destructive",onClick:de,disabled:y,children:y?t("sessions.sidebar.sessionDialogs.actions.deleting"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),xe=re?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return s.jsxs(s.Fragment,{children:[P?s.jsx(ni,{open:!!o,onClose:()=>{y||me()},title:xe,footer:s.jsx("div",{className:"flex justify-end gap-2",children:ne}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[G&&s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:G}),Ce]})}):s.jsx(Ds,{open:!!o,onOpenChange:U=>{if(!U){if(y)return;me()}},children:s.jsxs(Is,{className:Re(re?"max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3":"max-w-[min(520px,100vw-2rem)] space-y-2 pb-2"),children:[s.jsxs(sn,{children:[s.jsxs(Hs,{className:Re(re&&"flex items-center gap-2"),children:[re&&s.jsx(F,{name:"delete-bin",className:"h-5 w-5"}),xe]}),G&&s.jsx(Gs,{children:G})]}),s.jsx("div",{className:Re(re&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:Ce}),s.jsx(Un,{className:"mt-2 gap-2 pt-1 pb-1",children:ne})]})}),s.jsx(Zh,{open:e,onOpenChange:n})]})};function pm(t){if(!t||!t.trim())return{valid:!1,error:"required"};try{return uf.CronExpressionParser.parse(t),{valid:!0}}catch(e){return{valid:!1,error:e instanceof Error?e.message:"Invalid cron expression"}}}function X4(t,e,n=4){try{const r=e?{tz:e,currentDate:new Date}:{currentDate:new Date},i=uf.CronExpressionParser.parse(t,r),o=[];for(let l=0;l<n;l+=1){const a=i.next();a&&o.push(a.toDate())}return o}catch{return[]}}const J4=[{expression:"*/5 * * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.every5min"},{expression:"0 * * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.everyHour"},{expression:"0 9 * * 1",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.monday9am"},{expression:"0 9,17 * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.9am5pm"},{expression:"0 0 1 * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.firstOfMonth"}],Z4={"Europe/Kiev":"Europe/Kyiv","Asia/Calcutta":"Asia/Kolkata","Asia/Saigon":"Asia/Ho_Chi_Minh","Asia/Rangoon":"Asia/Yangon","Asia/Katmandu":"Asia/Kathmandu","America/Godthab":"America/Nuuk","Atlantic/Faeroe":"Atlantic/Faroe","Pacific/Enderbury":"Pacific/Kanton"},rr=t=>Z4[t]??t,gm=[0,1,2,3,4,5,6],xd="flex h-6 w-6 cursor-pointer items-center justify-center text-foreground transition-none outline-none focus:outline-none flex-shrink-0",Ma=typeof Intl<"u"&&typeof Intl.supportedValuesOf=="function"?[...new Set(Intl.supportedValuesOf("timeZone").map(rr))]:["UTC","Europe/Kyiv","Europe/London","Europe/Berlin","America/New_York","America/Los_Angeles","Asia/Tokyo"],bd=()=>{const t=new Date,e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`},Bo=t=>{const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!e)return null;const n=Number(e[1]),r=Number(e[2]),i=Number(e[3]),o=new Date(n,r-1,i);return Number.isNaN(o.getTime())||o.getFullYear()!==n||o.getMonth()!==r-1||o.getDate()!==i?null:o},yd=t=>{const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`},e5=(t,e,n)=>{const r=Bo(t);return r?new Intl.DateTimeFormat(n,{month:"short",day:"numeric",year:"numeric"}).format(r):e},wd=(t,e)=>new Date(t.getFullYear(),t.getMonth()+e,1),t5=(t,e)=>{const n=t.getFullYear(),r=t.getMonth(),l=(new Date(n,r,1).getDay()-e+7)%7,a=new Date(n,r+1,0).getDate(),d=new Date(n,r,0).getDate(),u=[];for(let m=0;m<42;m+=1){const f=m-l+1;if(f<=0){const p=d+f;u.push({date:new Date(n,r-1,p),inCurrentMonth:!1});continue}if(f>a){u.push({date:new Date(n,r+1,f-a),inCurrentMonth:!1});continue}u.push({date:new Date(n,r,f),inCurrentMonth:!0})}return u},s5=t=>{const e=/^([01]\d|2[0-3]):([0-5]\d)$/.exec(t);if(!e)return{hour24:"00",hour12:"12",minute:"00",meridiem:"AM"};const n=Number(e[1]),r=e[2],i=n>=12?"PM":"AM",o=n%12===0?12:n%12;return{hour24:String(n).padStart(2,"0"),hour12:String(o).padStart(2,"0"),minute:r,meridiem:i}},Xn=(t,e,n)=>{const r=Number(t),i=Number(e),o=Number.isFinite(r)?Math.min(12,Math.max(1,r)):12,l=Number.isFinite(i)?Math.min(59,Math.max(0,i)):0;let a=o%12;return n==="PM"&&(a+=12),`${String(a).padStart(2,"0")}:${String(l).padStart(2,"0")}`},Tr=(t,e)=>{const{max:n,min:r=0,loop:i=!1}=e;let o=Number.parseInt(t,10);return Number.isFinite(o)?(i?(o>n&&(o=r),o<r&&(o=n)):(o>n&&(o=n),o<r&&(o=r)),String(o).padStart(2,"0")):"00"},vd=t=>/^(0[1-9]|1[0-2])$/.test(t)?t:Tr(t,{min:1,max:12}),Po=t=>/^[0-5][0-9]$/.test(t)?t:Tr(t,{max:59}),n5=(t,e)=>Tr(String(Number.parseInt(t,10)+e),{min:1,max:12,loop:!0}),Sd=(t,e)=>Tr(String(Number.parseInt(t,10)+e),{min:0,max:59,loop:!0}),r5=t=>{try{const e=Intl.Locale;if(typeof e!="function")return 1;const r=new e(t).weekInfo?.firstDay;return typeof r!="number"?1:r%7}catch{return 1}},o5=t=>{try{const e=new Intl.DateTimeFormat(t,{hour:"numeric"}).resolvedOptions();return typeof e.hour12=="boolean"?!e.hour12:e.hourCycle==="h23"||e.hourCycle==="h24"}catch{return!0}},i5=t=>{const e=new Intl.DateTimeFormat(t,{weekday:"short"}),n=new Date(2023,0,1);return gm.map(r=>e.format(new Date(n.getFullYear(),n.getMonth(),n.getDate()+r)))},a5=(t,e)=>[...t.slice(e),...t.slice(0,e)],Es=t=>{const e=et.c(6),{htmlFor:n,required:r,children:i}=t;let o;e[0]!==r?(o=r&&s.jsx("span",{className:"ml-0.5 text-destructive",children:"*"}),e[0]=r,e[1]=o):o=e[1];let l;return e[2]!==i||e[3]!==n||e[4]!==o?(l=s.jsx("div",{className:"flex items-center gap-1.5",children:s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[i,o]})}),e[2]=i,e[3]=n,e[4]=o,e[5]=l):l=e[5],l},jd=t=>{const e=et.c(84),{value:n,onChange:r,use24Hour:i,hourAriaLabel:o,minuteAriaLabel:l,periodAriaLabel:a,amLabel:d,pmLabel:u}=t;let m;e[0]!==n?(m=s5(n),e[0]=n,e[1]=m):m=e[1];const f=m,p=ct.useRef(null),y=ct.useRef(null),[x,k]=ct.useState(null),[w,h]=ct.useState(null),g=ct.useRef(null),j=ct.useRef(null);let b;e[2]===Symbol.for("react.memo_cache_sentinel")?(b=U=>{g.current=U,k(U)},e[2]=b):b=e[2];const S=b;let C;e[3]===Symbol.for("react.memo_cache_sentinel")?(C=U=>{j.current=U,h(U)},e[3]=C):C=e[3];const v=C,M=h5,R=p5,I=g5;let B;e[4]!==r||e[5]!==f.meridiem||e[6]!==f.minute||e[7]!==i?(B=U=>{const z=U.replace(/\D/g,"").slice(0,2);S(z),z.length===2&&(r(i?I(M(z),f.minute):Xn(vd(z),f.minute,f.meridiem)),S(null),y.current?.focus())},e[4]=r,e[5]=f.meridiem,e[6]=f.minute,e[7]=i,e[8]=B):B=e[8];const O=B;let T;e[9]!==r||e[10]!==f.meridiem||e[11]!==f.minute||e[12]!==i?(T=()=>{const U=g.current;if(U!==null&&(S(null),U.length!==0)){if(i){r(I(M(U.padStart(2,"0")),f.minute));return}r(Xn(vd(U.padStart(2,"0")),f.minute,f.meridiem))}},e[9]=r,e[10]=f.meridiem,e[11]=f.minute,e[12]=i,e[13]=T):T=e[13];const $=T;let _;e[14]!==r||e[15]!==f.hour12||e[16]!==f.hour24||e[17]!==f.meridiem||e[18]!==i?(_=U=>{const z=U.replace(/\D/g,"").slice(0,2);v(z),z.length===2&&(r(i?I(f.hour24,Po(z)):Xn(f.hour12,Po(z),f.meridiem)),v(null))},e[14]=r,e[15]=f.hour12,e[16]=f.hour24,e[17]=f.meridiem,e[18]=i,e[19]=_):_=e[19];const Y=_;let L;e[20]!==r||e[21]!==f.hour12||e[22]!==f.hour24||e[23]!==f.meridiem||e[24]!==i?(L=()=>{const U=j.current;U!==null&&(v(null),U.length!==0&&r(i?I(f.hour24,Po(U.padStart(2,"0"))):Xn(f.hour12,Po(U.padStart(2,"0")),f.meridiem)))},e[20]=r,e[21]=f.hour12,e[22]=f.hour24,e[23]=f.meridiem,e[24]=i,e[25]=L):L=e[25];const A=L;let D;e[26]!==r||e[27]!==f.hour12||e[28]!==f.hour24||e[29]!==f.meridiem||e[30]!==f.minute||e[31]!==i?(D=U=>r(i?I(R(f.hour24,U),f.minute):Xn(n5(f.hour12,U),f.minute,f.meridiem)),e[26]=r,e[27]=f.hour12,e[28]=f.hour24,e[29]=f.meridiem,e[30]=f.minute,e[31]=i,e[32]=D):D=e[32];const P=D;let Z;e[33]!==r||e[34]!==f.hour12||e[35]!==f.hour24||e[36]!==f.meridiem||e[37]!==f.minute||e[38]!==i?(Z=U=>r(i?I(f.hour24,Sd(f.minute,U)):Xn(f.hour12,Sd(f.minute,U),f.meridiem)),e[33]=r,e[34]=f.hour12,e[35]=f.hour24,e[36]=f.meridiem,e[37]=f.minute,e[38]=i,e[39]=Z):Z=e[39];const X=Z;let se;e[40]!==r||e[41]!==f.hour12||e[42]!==f.meridiem||e[43]!==f.minute?(se=U=>{U!==f.meridiem&&r(Xn(f.hour12,f.minute,U))},e[40]=r,e[41]=f.hour12,e[42]=f.meridiem,e[43]=f.minute,e[44]=se):se=e[44];const ce=se;let re;e[45]!==$||e[46]!==P?(re=U=>{if(U.key==="ArrowRight"){U.preventDefault(),$(),y.current?.focus();return}(U.key==="ArrowUp"||U.key==="ArrowDown")&&(U.preventDefault(),S(null),P(U.key==="ArrowUp"?1:-1))},e[45]=$,e[46]=P,e[47]=re):re=e[47];const ge=re;let ae;e[48]!==A||e[49]!==X?(ae=U=>{if(U.key==="ArrowLeft"&&(U.currentTarget.selectionStart??0)===0){U.preventDefault(),A(),p.current?.focus();return}(U.key==="ArrowUp"||U.key==="ArrowDown")&&(U.preventDefault(),v(null),X(U.key==="ArrowUp"?1:-1))},e[48]=A,e[49]=X,e[50]=ae):ae=e[50];const Ee=ae,Se=i?"px-2":"pl-2 pr-1";let me;e[51]!==Se?(me=Re("oc-surface-elevated inline-flex h-9 w-fit items-center gap-1 rounded-md border border-border bg-surface-elevated focus-within:ring-1 focus-within:ring-ring focus-within:border-ring",Se),e[51]=Se,e[52]=me):me=e[52];const ke=x??(i?f.hour24:f.hour12);let V;e[53]!==O?(V=U=>O(U.target.value),e[53]=O,e[54]=V):V=e[54];let J;e[55]===Symbol.for("react.memo_cache_sentinel")?(J=()=>S(""),e[55]=J):J=e[55];let de;e[56]!==$||e[57]!==o||e[58]!==ge||e[59]!==ke||e[60]!==V?(de=s.jsx("input",{ref:p,inputMode:"numeric",value:ke,onChange:V,onKeyDown:ge,onFocus:J,onBlur:$,maxLength:2,"aria-label":o,className:"h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover"}),e[56]=$,e[57]=o,e[58]=ge,e[59]=ke,e[60]=V,e[61]=de):de=e[61];let we;e[62]===Symbol.for("react.memo_cache_sentinel")?(we=s.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:":"}),e[62]=we):we=e[62];const G=w??f.minute;let Ce;e[63]!==Y?(Ce=U=>Y(U.target.value),e[63]=Y,e[64]=Ce):Ce=e[64];let Te;e[65]===Symbol.for("react.memo_cache_sentinel")?(Te=()=>v(""),e[65]=Te):Te=e[65];let pe;e[66]!==A||e[67]!==l||e[68]!==Ee||e[69]!==G||e[70]!==Ce?(pe=s.jsx("input",{ref:y,inputMode:"numeric",value:G,onChange:Ce,onKeyDown:Ee,onFocus:Te,onBlur:A,maxLength:2,"aria-label":l,className:"h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover"}),e[66]=A,e[67]=l,e[68]=Ee,e[69]=G,e[70]=Ce,e[71]=pe):pe=e[71];let ne;e[72]!==d||e[73]!==f.meridiem||e[74]!==a||e[75]!==u||e[76]!==ce||e[77]!==i?(ne=i?null:s.jsxs(Ms,{value:f.meridiem,onValueChange:U=>ce(U),children:[s.jsx(Os,{"aria-label":a,className:"ml-1 h-7 w-fit border-0 bg-transparent pl-2 pr-1 shadow-none hover:bg-interactive-hover focus:ring-0",children:s.jsx(Cs,{})}),s.jsxs(Bs,{children:[s.jsx(rs,{value:"AM",children:d}),s.jsx(rs,{value:"PM",children:u})]})]}),e[72]=d,e[73]=f.meridiem,e[74]=a,e[75]=u,e[76]=ce,e[77]=i,e[78]=ne):ne=e[78];let xe;return e[79]!==me||e[80]!==de||e[81]!==pe||e[82]!==ne?(xe=s.jsxs("div",{className:me,children:[de,we,pe,ne]}),e[79]=me,e[80]=de,e[81]=pe,e[82]=ne,e[83]=xe):xe=e[83],xe},kd=t=>new Date(t.getFullYear(),t.getMonth(),1),l5=()=>{const t=new Date;return new Date(t.getFullYear(),t.getMonth(),t.getDate())},Cd=(t,e)=>t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate(),c5=t=>{if(!t)return["09:00"];const n=(Array.isArray(t.schedule.times)?t.schedule.times:t.schedule.time?[t.schedule.time]:[]).filter(i=>typeof i=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(i)).map(i=>i.trim()),r=Array.from(new Set(n)).sort((i,o)=>i.localeCompare(o));return r.length>0?r:["09:00"]},Nd=(t,e)=>{const n=rr(Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC");return t?{id:t.id,name:t.name,enabled:t.enabled,schedule:{kind:t.schedule.kind==="cron"?"cron":t.schedule.kind==="once"?"once":t.schedule.kind==="weekly"?"weekly":"daily",times:c5(t),onceDate:typeof t.schedule.date=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t.schedule.date)?t.schedule.date:bd(),onceTime:typeof t.schedule.time=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(t.schedule.time)?t.schedule.time:"09:00",weekdays:Array.isArray(t.schedule.weekdays)?t.schedule.weekdays:[1],timezone:rr(t.schedule.timezone||n),cronExpression:t.schedule.kind==="cron"&&typeof t.schedule.cron=="string"?t.schedule.cron:""},execution:{prompt:t.execution.prompt,providerID:t.execution.providerID,modelID:t.execution.modelID,variant:t.execution.variant||"",agent:t.execution.agent||"",goalEnabled:t.execution.goalEnabled===!0,goalTokenBudget:typeof t.execution.goalTokenBudget=="number"&&t.execution.goalTokenBudget>0?t.execution.goalTokenBudget:null,permissionAutoAccept:t.execution.permissionAutoAccept===!0},state:t.state}:{name:"",enabled:!0,schedule:{kind:"daily",times:["09:00"],onceDate:bd(),onceTime:"09:00",weekdays:[1],timezone:n,cronExpression:""},execution:{prompt:"",providerID:e.providerID,modelID:e.modelID,variant:e.variant,agent:e.agent,goalEnabled:!1,goalTokenBudget:null,permissionAutoAccept:!1}}},d5=(t,e)=>{if(!t.name.trim())return e("sessions.scheduledTasks.editor.validation.taskNameRequired");if(!t.execution.prompt.trim())return e("sessions.scheduledTasks.editor.validation.promptRequired");if(!t.execution.providerID.trim()||!t.execution.modelID.trim())return e("sessions.scheduledTasks.editor.validation.modelRequired");if(t.schedule.kind==="once"){if(!/^\d{4}-\d{2}-\d{2}$/.test(t.schedule.onceDate))return e("sessions.scheduledTasks.editor.validation.dateFormat");if(!/^([01]\d|2[0-3]):([0-5]\d)$/.test(t.schedule.onceTime))return e("sessions.scheduledTasks.editor.validation.timeFormat")}else if(t.schedule.kind==="cron"){if(!t.schedule.cronExpression.trim())return e("sessions.scheduledTasks.editor.validation.cronRequired");if(!pm(t.schedule.cronExpression).valid)return e("sessions.scheduledTasks.editor.validation.cronInvalid")}else if(t.schedule.times.filter(r=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(r)).length===0)return e("sessions.scheduledTasks.editor.validation.atLeastOneTime");return t.schedule.kind==="weekly"&&t.schedule.weekdays.length===0?e("sessions.scheduledTasks.editor.validation.atLeastOneWeekday"):t.schedule.timezone.trim()?null:e("sessions.scheduledTasks.editor.validation.timezoneRequired")},u5=t=>{const e=t.filter(n=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(n));return Array.from(new Set(e)).sort((n,r)=>n.localeCompare(r))},f5=t=>{const e=et.c(64),{draft:n,setDraft:r,locale:i,t:o}=t,l=n.schedule.cronExpression;let a;e[0]!==l?(a=l.trim()?pm(l):null,e[0]=l,e[1]=a):a=e[1];const d=a;let u;e:{if(!d?.valid||!l.trim()){let D;e[2]===Symbol.for("react.memo_cache_sentinel")?(D=[],e[2]=D):D=e[2],u=D;break e}let A;e[3]!==l||e[4]!==n.schedule.timezone?(A=X4(l,n.schedule.timezone),e[3]=l,e[4]=n.schedule.timezone,e[5]=A):A=e[5],u=A}const m=u;let f;e[6]!==n.schedule.timezone||e[7]!==i?(f=A=>new Intl.DateTimeFormat(i,{timeZone:n.schedule.timezone,month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(A),e[6]=n.schedule.timezone,e[7]=i,e[8]=f):f=e[8];const p=f;let y;e[9]!==o?(y=o("sessions.scheduledTasks.editor.cronExpression.label"),e[9]=o,e[10]=y):y=e[10];let x;e[11]!==y?(x=s.jsx(Es,{htmlFor:"sched-cron",required:!0,children:y}),e[11]=y,e[12]=x):x=e[12];let k;e[13]!==r?(k=A=>r(D=>({...D,schedule:{...D.schedule,cronExpression:A.target.value}})),e[13]=r,e[14]=k):k=e[14];let w;e[15]!==o?(w=o("sessions.scheduledTasks.editor.cronExpression.placeholder"),e[15]=o,e[16]=w):w=e[16];let h;e[17]!==l||e[18]!==k||e[19]!==w?(h=s.jsx(In,{id:"sched-cron",value:l,onChange:k,placeholder:w,className:"w-full max-w-xs font-mono"}),e[17]=l,e[18]=k,e[19]=w,e[20]=h):h=e[20];let g;e[21]!==l||e[22]!==d||e[23]!==o?(g=d&&!d.valid&&l.trim()?s.jsx("span",{className:"typography-micro text-destructive",children:o("sessions.scheduledTasks.editor.validation.cronInvalid")}):null,e[21]=l,e[22]=d,e[23]=o,e[24]=g):g=e[24];let j;e[25]!==x||e[26]!==h||e[27]!==g?(j=s.jsxs("div",{className:"flex flex-col gap-1",children:[x,h,g]}),e[25]=x,e[26]=h,e[27]=g,e[28]=j):j=e[28];let b;e[29]!==p||e[30]!==m||e[31]!==o?(b=m.length>0?s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:o("sessions.scheduledTasks.editor.cronExpression.nextRuns")}),s.jsx("span",{className:"typography-micro text-foreground",children:m.map(p).join(", ")})]}):null,e[29]=p,e[30]=m,e[31]=o,e[32]=b):b=e[32];let S;e[33]!==o?(S=o("sessions.scheduledTasks.editor.cronExpression.examples"),e[33]=o,e[34]=S):S=e[34];let C;e[35]!==S?(C=s.jsx("span",{className:"typography-meta text-muted-foreground",children:S}),e[35]=S,e[36]=C):C=e[36];let v;e[37]!==r||e[38]!==o?(v=J4.map(A=>s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 typography-micro text-foreground hover:bg-interactive-hover",onClick:()=>r(D=>({...D,schedule:{...D.schedule,cronExpression:A.expression}})),children:[s.jsx("span",{className:"font-mono",children:A.expression}),s.jsx("span",{className:"text-muted-foreground",children:o(A.labelKey)})]},A.expression)),e[37]=r,e[38]=o,e[39]=v):v=e[39];let M;e[40]!==v?(M=s.jsx("div",{className:"flex flex-wrap gap-1.5",children:v}),e[40]=v,e[41]=M):M=e[41];let R;e[42]!==C||e[43]!==M?(R=s.jsxs("div",{className:"flex flex-col gap-1",children:[C,M]}),e[42]=C,e[43]=M,e[44]=R):R=e[44];let I;e[45]!==o?(I=o("sessions.scheduledTasks.editor.timezone.label"),e[45]=o,e[46]=I):I=e[46];let B;e[47]!==I?(B=s.jsx(Es,{children:I}),e[47]=I,e[48]=B):B=e[48];let O;e[49]!==r?(O=A=>{r(D=>({...D,schedule:{...D.schedule,timezone:A}}))},e[49]=r,e[50]=O):O=e[50];let T;e[51]===Symbol.for("react.memo_cache_sentinel")?(T=s.jsx(Os,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Cs,{})}),e[51]=T):T=e[51];let $;e[52]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx(Bs,{children:Ma.map(x5)}),e[52]=$):$=e[52];let _;e[53]!==n.schedule.timezone||e[54]!==O?(_=s.jsxs(Ms,{value:n.schedule.timezone,onValueChange:O,children:[T,$]}),e[53]=n.schedule.timezone,e[54]=O,e[55]=_):_=e[55];let Y;e[56]!==B||e[57]!==_?(Y=s.jsxs("div",{className:"flex flex-col gap-1",children:[B,_]}),e[56]=B,e[57]=_,e[58]=Y):Y=e[58];let L;return e[59]!==j||e[60]!==b||e[61]!==R||e[62]!==Y?(L=s.jsxs("div",{className:"flex flex-col gap-3",children:[j,b,R,Y]}),e[59]=j,e[60]=b,e[61]=R,e[62]=Y,e[63]=L):L=e[63],L};function m5(t){const{open:e,task:n,onOpenChange:r,onSave:i}=t,{t:o,locale:l}=kt(),a=Ut(q=>q.loadProviders),d=Ut(q=>q.loadAgents),u=Ut(q=>q.providers),m=Ut(q=>q.currentProviderId),f=Ut(q=>q.currentModelId),p=Ut(q=>q.currentVariant||""),y=Ut(q=>q.currentAgentName||""),x=Pe(q=>q.timeFormatPreference),k=Pe(q=>q.weekStartPreference),w=Pe(q=>q.isMobile),[h,g]=ct.useState(()=>Nd(n,{providerID:m,modelID:f,variant:p,agent:y})),[j,b]=ct.useState(!1),[S,C]=ct.useState(!1),[v,M]=ct.useState(!1),[R,I]=ct.useState(""),[B,O]=ct.useState(!1),[T,$]=ct.useState(""),[_,Y]=ct.useState(!1),[L,A]=ct.useState(""),[D,P]=ct.useState(()=>{const q=Bo(n?.schedule?.date||"")||new Date;return new Date(q.getFullYear(),q.getMonth(),1)}),Z=ct.useRef(null),X=ct.useRef(null),se=ct.useRef(null),ce=ct.useRef(null),re=ct.useRef(null),ge=ct.useMemo(()=>o5(l),[l]),ae=ct.useMemo(()=>r5(l),[l]),Ee=ct.useMemo(()=>x==="24h"?!0:x==="12h"?!1:ge,[x,ge]),Se=ct.useMemo(()=>k==="sunday"?0:k==="monday"?1:ae,[k,ae]),me=ct.useMemo(()=>{const q=i5(l);return a5(gm.map(Ne=>({value:Ne,label:q[Ne]||""})),Se)},[l,Se]);ct.useEffect(()=>{e&&(a({source:"scheduledTaskEditor"}),d({source:"scheduledTaskEditor"}))},[e,a,d]),ct.useEffect(()=>{if(!e)return;g(Nd(n,{providerID:m,modelID:f,variant:p,agent:y}));const q=Bo(n?.schedule?.date||"")||new Date;P(new Date(q.getFullYear(),q.getMonth(),1)),C(!1),O(!1),M(!1),$(""),I("")},[e,n,m,f,p,y]),ct.useEffect(()=>{if(!S)return;const q=Ne=>{Z.current&&!Z.current.contains(Ne.target)&&C(!1)};return document.addEventListener("mousedown",q),()=>{document.removeEventListener("mousedown",q)}},[S]);const ke=ct.useMemo(()=>{const Ne=u.find(je=>je.id===h.execution.providerID)?.models?.find(je=>je.id===h.execution.modelID);return tl(Ne?.variants)},[u,h.execution.providerID,h.execution.modelID]),V=ke.length>0,J=ct.useMemo(()=>!V||!h.execution.variant?"__default":ke.includes(h.execution.variant)?h.execution.variant:"__default",[h.execution.variant,V,ke]);ct.useEffect(()=>{V||!h.execution.variant||g(q=>({...q,execution:{...q.execution,variant:""}}))},[V,h.execution.variant]);const de=ct.useCallback((q,Ne)=>{g(je=>{const We=new Set(je.schedule.weekdays);return Ne?We.add(q):We.delete(q),{...je,schedule:{...je.schedule,weekdays:Array.from(We).sort((tt,it)=>tt-it)}}})},[]),we=ct.useCallback((q,Ne)=>{g(je=>{const We=je.schedule.times.slice();return We[q]=Ne,{...je,schedule:{...je.schedule,times:We}}})},[]),G=ct.useCallback(q=>{g(Ne=>{const je=Ne.schedule.times.filter((We,tt)=>tt!==q);return{...Ne,schedule:{...Ne.schedule,times:je.length>0?je:["09:00"]}}})},[]),Ce=ct.useCallback(()=>{g(q=>({...q,schedule:{...q.schedule,times:[...q.schedule.times,"12:00"]}}))},[]),Te=ct.useMemo(()=>l5(),[]),pe=ct.useMemo(()=>kd(Te),[Te]),ne=ct.useMemo(()=>{const q=Bo(h.schedule.onceDate);return q?Cd(q,Te)?o("sessions.scheduledTasks.editor.date.today"):new Intl.DateTimeFormat(l,{weekday:"short"}).format(q):null},[h.schedule.onceDate,l,o,Te]),xe=ct.useMemo(()=>kd(D).getTime()<=pe.getTime(),[D,pe]),U=ct.useMemo(()=>me.map(q=>q.label),[me]),z=ct.useCallback(q=>{g(Ne=>({...Ne,schedule:{...Ne.schedule,onceDate:q}}))},[]),Q=ct.useCallback((q,Ne)=>{if(q.startsWith("/")){const it=q.indexOf(" "),rt=q.indexOf(`
|
|
890
|
-
`),ot=Math.min(it===-1?q.length:it,rt===-1?q.length:rt);if(Ne<=ot&&it===-1){$(q.substring(1,ot)),O(!0),M(!1),Y(!1);return}}O(!1);const je=q.substring(0,Ne),We=je.lastIndexOf("#");if(We!==-1){const it=We>0?je[We-1]:null,rt=je.substring(We+1);if((!it||/\s/.test(it))&&!rt.includes(" ")&&!rt.includes(`
|
|
891
|
-
`)){A(rt),Y(!0),M(!1);return}}Y(!1);const tt=je.lastIndexOf("@");if(tt!==-1){const it=tt>0?je[tt-1]:null,rt=je.substring(tt+1);(!it||/\s/.test(it))&&!rt.includes(" ")&&!rt.includes(`
|
|
892
|
-
`)?(I(rt),M(!0)):M(!1);return}M(!1)},[]),ue=ct.useCallback(q=>{g(Ne=>({...Ne,execution:{...Ne.execution,prompt:q}}))},[]),le=ct.useCallback(q=>{const Ne=h.execution.prompt,We=X.current?.selectionStart??Ne.length,it=Ne.substring(0,We).lastIndexOf("@"),rt=q.relativePath&&q.relativePath.trim().length>0?q.relativePath.trim():q.path||q.name,ot=it!==-1?it:We,ft=`${Ne.substring(0,ot)}@${rt} ${Ne.substring(We)}`,st=ot+rt.length+2;ue(ft),M(!1),I(""),requestAnimationFrame(()=>{const Ct=X.current;Ct&&(Ct.selectionStart=st,Ct.selectionEnd=st,Ct.focus()),Q(ft,st)})},[h.execution.prompt,ue,Q]),W=ct.useCallback(q=>{const Ne=h.execution.prompt,We=X.current?.selectionStart??Ne.length,it=Ne.substring(0,We).lastIndexOf("@"),rt=it!==-1?it:We,ot=`${Ne.substring(0,rt)}@${q} ${Ne.substring(We)}`,ft=rt+q.length+2;ue(ot),M(!1),I(""),requestAnimationFrame(()=>{const st=X.current;st&&(st.selectionStart=ft,st.selectionEnd=ft,st.focus()),Q(ot,ft)})},[h.execution.prompt,ue,Q]),E=ct.useCallback(q=>{const Ne=`/${q.name} `;ue(Ne),O(!1),$(""),Y(!1),requestAnimationFrame(()=>{const je=X.current;je&&(je.focus(),je.selectionStart=je.value.length,je.selectionEnd=je.value.length),Q(Ne,Ne.length)})},[ue,Q]),K=ct.useCallback((q,Ne)=>{const je=h.execution.prompt,tt=X.current?.selectionStart??je.length,rt=je.substring(0,tt).lastIndexOf("#"),ot=rt!==-1?rt:tt,ft=`${je.substring(0,ot)}#${Ne} ${je.substring(tt)}`,st=ot+Ne.length+2;ue(ft),Y(!1),A(""),requestAnimationFrame(()=>{const Ct=X.current;Ct&&(Ct.selectionStart=st,Ct.selectionEnd=st,Ct.focus()),Q(ft,st)})},[h.execution.prompt,ue,Q]),te=ct.useCallback(q=>{if(B&&ce.current&&(q.key==="Enter"||q.key==="ArrowUp"||q.key==="ArrowDown"||q.key==="Escape"||q.key==="Tab")){q.preventDefault(),ce.current.handleKeyDown(q.key);return}v&&se.current&&(q.key==="Enter"||q.key==="ArrowUp"||q.key==="ArrowDown"||q.key==="Escape"||q.key==="Tab")&&(q.preventDefault(),se.current.handleKeyDown(q.key)),_&&re.current&&(q.key==="Enter"||q.key==="ArrowUp"||q.key==="ArrowDown"||q.key==="Escape"||q.key==="Tab")&&(q.preventDefault(),re.current.handleKeyDown(q.key))},[B,v,_]),oe=ct.useCallback(async()=>{const q=d5(h,o);if(q){ze.error(q);return}const Ne={...h.id?{id:h.id}:{},name:h.name.trim(),enabled:h.enabled,schedule:{kind:h.schedule.kind,timezone:h.schedule.timezone.trim(),...h.schedule.kind==="cron"?{cron:h.schedule.cronExpression.trim()}:h.schedule.kind==="once"?{date:h.schedule.onceDate,time:h.schedule.onceTime}:{times:u5(h.schedule.times),...h.schedule.kind==="weekly"?{weekdays:h.schedule.weekdays}:{}}},execution:{prompt:h.execution.prompt,providerID:h.execution.providerID,modelID:h.execution.modelID,...h.execution.variant.trim()?{variant:h.execution.variant.trim()}:{},...h.execution.agent.trim()?{agent:h.execution.agent.trim()}:{},...h.execution.permissionAutoAccept?{permissionAutoAccept:!0}:{},...h.execution.goalEnabled?{goalEnabled:!0}:{},...h.execution.goalEnabled&&h.execution.goalTokenBudget?{goalTokenBudget:h.execution.goalTokenBudget}:{}},...h.state?{state:h.state}:{}};b(!0);try{await i(Ne),r(!1)}catch(je){ze.error(je instanceof Error?je.message:o("sessions.scheduledTasks.editor.toast.saveFailed"))}finally{b(!1)}},[h,r,i,o]),he=ct.useId(),ie=ct.useCallback(()=>typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]'),[]),Fe=o(n?"sessions.scheduledTasks.editor.title.edit":"sessions.scheduledTasks.editor.title.new"),_e=o("sessions.scheduledTasks.editor.description"),Ae=s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Es,{htmlFor:"sched-name",required:!0,children:o("sessions.scheduledTasks.editor.taskName.label")}),s.jsx(In,{id:"sched-name",value:h.name,onChange:q=>g(Ne=>({...Ne,name:q.target.value})),placeholder:o("sessions.scheduledTasks.editor.taskName.placeholder"),maxLength:80,className:"w-full sm:max-w-[220px]"})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Es,{children:o("sessions.scheduledTasks.editor.scheduleType.label")}),s.jsxs(Ms,{value:h.schedule.kind,onValueChange:q=>{g(Ne=>({...Ne,schedule:{...Ne.schedule,kind:q,...q==="cron"&&!Ne.schedule.cronExpression?{cronExpression:"0 * * * *"}:{}}}))},children:[s.jsx(Os,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Cs,{children:q=>o(q==="daily"?"sessions.scheduledTasks.editor.scheduleType.daily":q==="weekly"?"sessions.scheduledTasks.editor.scheduleType.weekly":q==="cron"?"sessions.scheduledTasks.editor.scheduleType.cron":"sessions.scheduledTasks.editor.scheduleType.once")})}),s.jsxs(Bs,{children:[s.jsx(rs,{value:"daily",children:o("sessions.scheduledTasks.editor.scheduleType.daily")}),s.jsx(rs,{value:"weekly",children:o("sessions.scheduledTasks.editor.scheduleType.weekly")}),s.jsx(rs,{value:"once",children:o("sessions.scheduledTasks.editor.scheduleType.once")}),s.jsx(rs,{value:"cron",children:o("sessions.scheduledTasks.editor.scheduleType.cron")})]})]})]})]}),h.schedule.kind==="cron"?s.jsx(f5,{draft:h,setDraft:g,locale:l,t:o}):h.schedule.kind==="once"?s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",ref:Z,children:[s.jsx(Es,{children:o("sessions.scheduledTasks.editor.date.label")}),s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",className:Re(Wu({size:"default"}),"w-fit max-w-full"),onClick:()=>C(q=>!q),children:[s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(F,{name:"calendar",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:e5(h.schedule.onceDate,o("sessions.scheduledTasks.editor.date.placeholder"),l)})]}),s.jsx(F,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"})]}),S?s.jsxs("div",{className:"oc-surface-elevated absolute left-0 top-[calc(100%+6px)] z-50 w-[288px] rounded-xl border border-border bg-surface-elevated p-3 shadow-sm",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover disabled:cursor-not-allowed disabled:opacity-40",onClick:()=>P(q=>wd(q,-1)),"aria-label":o("sessions.scheduledTasks.editor.date.previousMonth"),disabled:xe,children:s.jsx(F,{name:"arrow-left-s",className:"h-4 w-4"})}),s.jsx("div",{className:"typography-ui-label text-foreground",children:new Intl.DateTimeFormat(l,{month:"long",year:"numeric"}).format(D)}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover",onClick:()=>P(q=>wd(q,1)),"aria-label":o("sessions.scheduledTasks.editor.date.nextMonth"),children:s.jsx(F,{name:"arrow-right-s",className:"h-4 w-4"})})]}),s.jsx("div",{className:"mb-1 grid grid-cols-7 gap-1 px-1",children:U.map((q,Ne)=>s.jsx("div",{className:"py-1 text-center typography-micro text-muted-foreground",children:q},`${q}-${Ne}`))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:t5(D,Se).map(({date:q,inCurrentMonth:Ne})=>{const je=yd(q),We=je===h.schedule.onceDate,tt=Cd(q,Te),it=q.getTime()<Te.getTime(),rt=We?"bg-interactive-selection text-interactive-selection-foreground":it?"text-muted-foreground/40":Ne?"text-foreground hover:bg-interactive-hover":"text-muted-foreground/60 hover:bg-interactive-hover";return s.jsx("button",{type:"button",onClick:()=>{it||(z(je),C(!1))},disabled:it,className:["h-8 rounded-md typography-ui-label",rt,tt&&!We?"ring-1 ring-inset ring-ring bg-interactive-selection text-interactive-selection-foreground":"",it?"cursor-not-allowed opacity-45":""].join(" "),children:q.getDate()},je)})}),s.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-border pt-2",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:ne||""}),s.jsx(ut,{type:"button",size:"xs",variant:"ghost",onClick:()=>{z(yd(Te)),P(new Date(Te.getFullYear(),Te.getMonth(),1))},children:o("sessions.scheduledTasks.editor.date.jumpToToday")})]})]}):null]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Es,{children:o("sessions.scheduledTasks.editor.time.label")}),s.jsx(jd,{value:h.schedule.onceTime,use24Hour:Ee,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:q=>g(Ne=>({...Ne,schedule:{...Ne.schedule,onceTime:q}}))}),s.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[s.jsx(Es,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Ms,{value:h.schedule.timezone,onValueChange:q=>{g(Ne=>({...Ne,schedule:{...Ne.schedule,timezone:q}}))},children:[s.jsx(Os,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Cs,{})}),s.jsx(Bs,{children:Ma.map(q=>s.jsx(rs,{value:q,children:q},q))})]})]})]})]}):s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[h.schedule.kind==="weekly"?s.jsxs("div",{className:"flex flex-col gap-1 sm:col-span-2",children:[s.jsx(Es,{children:o("sessions.scheduledTasks.editor.weekdays.label")}),s.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-2",children:me.map(q=>{const Ne=h.schedule.weekdays.includes(q.value);return s.jsxs("div",{className:["group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta",Ne?"text-foreground":"text-muted-foreground"].join(" "),children:[s.jsx(Sr,{checked:Ne,onChange:je=>de(q.value,je),ariaLabel:q.label}),s.jsx("button",{type:"button",onClick:()=>de(q.value,!Ne),className:"group-hover:text-foreground",children:q.label})]},q.value)})})]}):null,s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Es,{children:o("sessions.scheduledTasks.editor.times.label")}),s.jsx("div",{className:"flex flex-col gap-2",children:h.schedule.times.map((q,Ne)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(jd,{value:q,use24Hour:Ee,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:je=>we(Ne,je)}),h.schedule.times.length>1?s.jsx(ut,{type:"button",size:"icon",variant:"ghost",onClick:()=>G(Ne),"aria-label":o("sessions.scheduledTasks.editor.times.removeAria"),children:s.jsx(F,{name:"close",className:"h-4 w-4"})}):null]},Ne))}),s.jsx("div",{children:s.jsxs(ut,{type:"button",size:"sm",variant:"outline",onClick:Ce,children:[s.jsx(F,{name:"add",className:"mr-1 h-4 w-4"})," ",o("sessions.scheduledTasks.editor.times.add")]})})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Es,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Ms,{value:h.schedule.timezone,onValueChange:q=>{g(Ne=>({...Ne,schedule:{...Ne.schedule,timezone:q}}))},children:[s.jsx(Os,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Cs,{})}),s.jsx(Bs,{children:Ma.map(q=>s.jsx(rs,{value:q,children:q},q))})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Es,{required:!0,children:o("sessions.scheduledTasks.editor.model.label")}),s.jsx(ax,{providerId:h.execution.providerID,modelId:h.execution.modelID,onChange:(q,Ne)=>{g(je=>({...je,execution:{...je.execution,providerID:q,modelID:Ne,variant:""}}))}})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Es,{children:o("sessions.scheduledTasks.editor.thinkingLevel.label")}),s.jsxs(Ms,{value:J,disabled:!V,onValueChange:q=>{g(Ne=>({...Ne,execution:{...Ne.execution,variant:q==="__default"?"":q}}))},children:[s.jsx(Os,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Cs,{children:q=>q==="__default"?o("sessions.scheduledTasks.editor.thinkingLevel.default"):q})}),s.jsxs(Bs,{children:[s.jsx(rs,{value:"__default",children:o("sessions.scheduledTasks.editor.thinkingLevel.default")}),ke.map(q=>s.jsx(rs,{value:q,children:q},q))]})]})]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Es,{children:o("sessions.scheduledTasks.editor.agent.label")}),s.jsx(lx,{agentName:h.execution.agent,filter:q=>zu(q.mode),onChange:q=>g(Ne=>({...Ne,execution:{...Ne.execution,agent:q}}))})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Es,{htmlFor:"sched-prompt",required:!0,children:o("sessions.scheduledTasks.editor.prompt.label")}),s.jsxs("div",{className:"relative",children:[s.jsx(wr,{id:"sched-prompt",ref:X,value:h.execution.prompt,onChange:q=>{const Ne=q.target.value;ue(Ne);const je=q.target.selectionStart??Ne.length;Q(Ne,je)},onKeyDown:te,rows:8,placeholder:o("sessions.scheduledTasks.editor.prompt.placeholder"),className:"typography-meta min-h-[120px] max-h-[300px] resize-none overflow-y-auto"}),B?s.jsx(Yu,{ref:ce,searchQuery:T,onCommandSelect:E,onClose:()=>O(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,v?s.jsx(Qu,{ref:se,searchQuery:R,onFileSelect:le,onAgentSelect:W,onClose:()=>M(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,_?s.jsx(Xu,{ref:re,searchQuery:L,onSnippetSelect:K,onClose:()=>Y(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null]})]}),h.execution.goalEnabled?s.jsxs("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-2",children:[s.jsxs("label",{className:"inline-flex cursor-pointer items-center gap-2",children:[s.jsx(Sr,{checked:h.execution.goalTokenBudget!==null,onChange:q=>g(Ne=>({...Ne,execution:{...Ne.execution,goalTokenBudget:q?2e5:null}})),ariaLabel:o("sessions.scheduledTasks.editor.goal.budgetAria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.goal.budgetLabel")})]}),h.execution.goalTokenBudget!==null?s.jsx(cx,{value:h.execution.goalTokenBudget,onValueChange:q=>{typeof q=="number"&&Number.isFinite(q)&&q>0&&g(Ne=>({...Ne,execution:{...Ne.execution,goalTokenBudget:Math.floor(q)}}))},min:1e3,max:1e8,step:5e4}):null]}):null]}),Me=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("label",{className:"inline-flex items-center gap-2",children:[s.jsx(Sr,{checked:h.enabled,onChange:q=>g(Ne=>({...Ne,enabled:q})),ariaLabel:o("sessions.scheduledTasks.editor.enabled.aria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.enabled.label")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",className:Re(xd),onClick:()=>g(q=>({...q,execution:{...q.execution,permissionAutoAccept:!q.execution.permissionAutoAccept}})),"aria-pressed":h.execution.permissionAutoAccept,"aria-label":o("sessions.scheduledTasks.editor.permissionAutoAccept.aria"),children:h.execution.permissionAutoAccept?s.jsx(F,{name:"shield-check",className:"h-[18px] w-[18px]",style:{color:"var(--status-info)"},"aria-hidden":"true"}):s.jsx(F,{name:"shield-user",className:"h-[18px] w-[18px]","aria-hidden":"true"})})}),s.jsx(St,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.permissionAutoAccept.label")})]}),s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",className:Re(xd,h.execution.goalEnabled&&"text-[var(--status-info)]"),onClick:()=>g(q=>({...q,execution:{...q.execution,goalEnabled:!q.execution.goalEnabled}})),"aria-pressed":h.execution.goalEnabled,"aria-label":o("sessions.scheduledTasks.editor.goal.aria"),children:h.execution.goalEnabled?s.jsx(F,{name:"target-fill",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"}):s.jsx(F,{name:"target",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"})})}),s.jsx(St,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.goal.label")})]}),s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:j,children:o("sessions.scheduledTasks.editor.actions.cancel")}),s.jsx(ut,{type:"button",size:"sm",onClick:oe,disabled:j,children:o(j?"sessions.scheduledTasks.editor.actions.saving":"sessions.scheduledTasks.editor.actions.save")})]})]});return w?s.jsx(ni,{open:e,title:Fe,onClose:()=>r(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:q=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:Fe}),q]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:_e})]}),footer:Me,children:Ae}):s.jsx(Ds,{open:e,onOpenChange:q=>{!q&&ie()||r(q)},children:s.jsxs(Is,{"aria-describedby":he,className:"!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden",children:[s.jsx(Gs,{id:he,className:"sr-only",children:_e}),s.jsx("header",{className:"shrink-0 px-4 sm:px-6 pt-5 pb-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl",children:[s.jsx(Hs,{className:"typography-ui-label font-medium text-foreground",children:Fe}),s.jsx("p",{className:"typography-meta mt-0.5 text-muted-foreground",children:_e})]})}),s.jsx(Ga,{className:"flex-1 min-h-0 overflow-auto [scrollbar-gutter:stable_both-edges]",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 pb-5",children:Ae})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsx("div",{className:"mx-auto w-full max-w-2xl",children:Me})})]})})}function h5(t){return Tr(t,{min:0,max:23})}function p5(t,e){return Tr(String(Number.parseInt(t,10)+e),{min:0,max:23,loop:!0})}function g5(t,e){const n=Number(t),r=Number(e),i=Number.isFinite(n)?Math.min(23,Math.max(0,n)):0,o=Number.isFinite(r)?Math.min(59,Math.max(0,r)):0;return`${String(i).padStart(2,"0")}:${String(o).padStart(2,"0")}`}function x5(t){return s.jsx(rs,{value:t,children:t},t)}const b5=t=>{const n=(Array.isArray(t.schedule.times)?t.schedule.times:t.schedule.time?[t.schedule.time]:[]).filter(r=>typeof r=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(r));return Array.from(new Set(n)).sort((r,i)=>r.localeCompare(i))},y5=(t,e)=>{const n=b5(t).join(", ")||"--:--",r=i=>e(i===0?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sun":i===1?"sessions.scheduledTasks.dialog.schedule.weekdayShort.mon":i===2?"sessions.scheduledTasks.dialog.schedule.weekdayShort.tue":i===3?"sessions.scheduledTasks.dialog.schedule.weekdayShort.wed":i===4?"sessions.scheduledTasks.dialog.schedule.weekdayShort.thu":i===5?"sessions.scheduledTasks.dialog.schedule.weekdayShort.fri":i===6?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sat":"sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown");if(t.schedule.kind==="daily")return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.dailyWithTimezone",{time:n,timezone:rr(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.daily",{time:n});if(t.schedule.kind==="weekly"){const i=Array.isArray(t.schedule.weekdays)?t.schedule.weekdays.map(o=>r(o)).join(", "):"";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone",{days:i,time:n,timezone:rr(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.weekly",{days:i,time:n})}if(t.schedule.kind==="once"){const i=typeof t.schedule.date=="string"&&t.schedule.date.trim().length>0?t.schedule.date:e("sessions.scheduledTasks.dialog.schedule.unknownDate"),o=typeof t.schedule.time=="string"&&t.schedule.time.trim().length>0?t.schedule.time:"--:--";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.onceWithTimezone",{date:i,time:o,timezone:rr(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.once",{date:i,time:o})}return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.cronWithTimezone",{cron:t.schedule.cron||"",timezone:rr(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.cron",{cron:t.schedule.cron||""})},w5=(t,e)=>!t||!Number.isFinite(t)?"":dx(t,e),Ad=(t,e)=>{if(!t||!Number.isFinite(t))return"";const n=t-Date.now(),r=Math.abs(n),i=6e4,o=60*i,l=24*o,a=n>=0;if(r<i)return e(a?"sessions.scheduledTasks.dialog.relativeTime.inLessThanOneMinute":"sessions.scheduledTasks.dialog.relativeTime.justNow");if(r<o){const f=Math.round(r/i);return a?e("sessions.scheduledTasks.dialog.relativeTime.inMinutes",{count:f}):e("sessions.scheduledTasks.dialog.relativeTime.minutesAgo",{count:f})}if(r<l){const f=Math.floor(r/o),p=Math.round(r%o/i),y=p>0?`${f}h ${p}m`:`${f}h`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:y}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:y})}const d=Math.floor(r/l),u=Math.round(r%l/o),m=u>0?`${d}d ${u}h`:`${d}d`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:m}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:m})},v5={success:{tone:"success",Icon:"checkbox-circle"},error:{tone:"error",Icon:"error-warning"},running:{tone:"warning",Icon:"loader-4",spin:!0},idle:{tone:"muted",Icon:"pulse"}},S5=t=>({color:`var(--status-${t})`,backgroundColor:`var(--status-${t}-background)`,borderColor:`var(--status-${t}-border)`});function j5(){const{t}=kt(),e=Pe(A=>A.isScheduledTasksDialogOpen),n=Pe(A=>A.setScheduledTasksDialogOpen),r=Pe(A=>A.isMobile),i=Pe(A=>A.timeFormatPreference),o=Gt(A=>A.projects),l=Gt(A=>A.getActiveProject()),a=os(A=>A.homeDirectory),{currentTheme:d}=Kn(),[u,m]=ct.useState(""),[f,p]=ct.useState([]),[y,x]=ct.useState(!0),[k,w]=ct.useState(!1),[h,g]=ct.useState(null),[j,b]=ct.useState(null),S=ct.useMemo(()=>o.find(A=>A.id===u)||null,[o,u]),C=ct.useCallback(A=>{const D=A.label?.trim()||cr(A.path,a||void 0),P=A.icon?oi[A.icon]:null,Z=A.color?ii[A.color]:void 0,X=P?s.jsx(F,{name:P,className:"h-3.5 w-3.5 shrink-0",style:Z?{color:Z}:void 0}):s.jsx(F,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:Z?{color:Z}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[A.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:A.iconBackground?{backgroundColor:A.iconBackground}:void 0,children:s.jsx(ai,{project:{id:A.id,iconImage:A.iconImage??null},options:{themeVariant:d.metadata.variant,iconColor:d.colors.surface.foreground},className:"h-full w-full object-contain",fallback:X})}):X,s.jsx("span",{className:"truncate",children:D})]})},[a,d.metadata.variant,d.colors.surface.foreground]),v=ct.useCallback(async(A,D)=>{if(!A){p([]);return}D?.silent||x(!0);try{const P=await sb(A);P.sort((Z,X)=>{if(Z.enabled!==X.enabled)return Z.enabled?-1:1;const se=Z.name.localeCompare(X.name);return se!==0?se:(Z.state?.nextRunAt||Number.MAX_SAFE_INTEGER)-(X.state?.nextRunAt||Number.MAX_SAFE_INTEGER)}),p(P)}catch(P){ze.error(P instanceof Error?P.message:t("sessions.scheduledTasks.dialog.toast.loadFailed")),D?.silent||p([])}finally{D?.silent||x(!1)}},[t]);ct.useEffect(()=>{if(!e)return;const A=l?.id||o[0]?.id||"";m(A),A?v(A):(p([]),x(!1))},[e,l,o,v]),ct.useEffect(()=>{if(!e)return;let A=null;const D=Hn(P=>{P.type==="scheduled-task-ran"&&P.projectId===u&&(A&&clearTimeout(A),A=setTimeout(()=>{v(u,{silent:!0})},400))});return()=>{A&&clearTimeout(A),D()}},[e,u,v]);const M=ct.useCallback(async A=>{if(!u)throw new Error(t("sessions.scheduledTasks.dialog.error.chooseProjectFirst"));await sc(u,A),await v(u),ze.success(t("sessions.scheduledTasks.dialog.toast.saved"))},[u,v,t]),R=ct.useCallback(async(A,D)=>{if(u){b(A.id),p(P=>P.map(Z=>Z.id===A.id?{...Z,enabled:D}:Z));try{A.loopFile?await nb(u,A.id,D):await sc(u,{...A,enabled:D}),await v(u,{silent:!0})}catch(P){ze.error(P instanceof Error?P.message:t("sessions.scheduledTasks.dialog.toast.updateFailed")),await v(u,{silent:!0})}finally{b(null)}}},[u,v,t]),I=ct.useCallback(async A=>{if(!(!u||!window.confirm(A.loopFile?t("sessions.scheduledTasks.dialog.confirm.deleteLoopFile",{taskName:A.name}):t("sessions.scheduledTasks.dialog.confirm.deleteTask",{taskName:A.name})))){b(A.id);try{A.loopFile?await rb(u,A.id):await ob(u,A.id),await v(u,{silent:!0}),ze.success(t("sessions.scheduledTasks.dialog.toast.deleted"))}catch(P){ze.error(P instanceof Error?P.message:t("sessions.scheduledTasks.dialog.toast.deleteFailed"))}finally{b(null)}}},[u,v,t]),B=ct.useCallback(A=>{if(!A.loopFile){g(A),w(!0);return}S?.path&&(n(!1),yn.getState().setSelectedPath(S.path,A.loopFile,{allowOutsideRoot:!0}),Pe.getState().openContextFile(S.path,A.loopFile))},[S?.path,n]),O=ct.useCallback(async A=>{if(u){b(A.id);try{const{sessionId:D,persistError:P}=await ib(u,A.id);if(await Promise.all([v(u,{silent:!0}),ci()]),P?ze.warning(t("sessions.scheduledTasks.dialog.toast.startedPersistWarning")):ze.success(t("sessions.scheduledTasks.dialog.toast.started")),D){const Z=o.find(X=>X.id===u);nt.getState().setCurrentSession(D,Z?.path??null)}}catch(D){ze.error(D instanceof Error?D.message:t("sessions.scheduledTasks.dialog.toast.runFailed"))}finally{b(null)}}},[u,o,v,t]),T=s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.label")}),s.jsxs(Ms,{value:u||"__none",onValueChange:A=>{const D=A==="__none"?"":A;m(D),D?v(D):p([])},children:[s.jsx(Os,{size:"lg",className:r?"w-full":void 0,children:S?s.jsx(Cs,{children:C(S)}):s.jsx(Cs,{placeholder:t("sessions.scheduledTasks.dialog.project.placeholder")})}),s.jsxs(Bs,{children:[o.length===0?s.jsx(rs,{value:"__none",children:t("sessions.scheduledTasks.dialog.project.empty")}):null,o.map(A=>s.jsx(rs,{value:A.id,children:C(A)},A.id))]})]})]}),$=()=>{g(null),w(!0)},_=A=>{m(A),A?v(A):p([])},Y=s.jsx("div",{className:"min-h-[280px]",children:y?s.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx(F,{name:"loader-4",className:"h-4 w-4 animate-spin"})," ",t("sessions.scheduledTasks.dialog.loading")]}):f.length===0?s.jsx("div",{className:"rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground",children:t(u?"sessions.scheduledTasks.dialog.empty.noTasks":"sessions.scheduledTasks.dialog.empty.selectProject")}):s.jsx("div",{className:"space-y-2.5",children:f.map(A=>{const D=j===A.id,P=A.state?.lastStatus||"idle",Z=v5[P],X=t(P==="success"?"sessions.scheduledTasks.dialog.status.success":P==="error"?"sessions.scheduledTasks.dialog.status.error":P==="running"?"sessions.scheduledTasks.dialog.status.running":"sessions.scheduledTasks.dialog.status.idle"),se=A.state?.nextRunAt,ce=A.state?.lastRunAt;return s.jsxs("div",{className:Re("rounded-lg border border-border p-4 transition-opacity"),children:[s.jsxs("div",{className:Re("min-w-0",!A.enabled&&"opacity-60"),children:[s.jsx("div",{className:"typography-ui-header truncate font-semibold text-foreground",children:A.name}),s.jsx("div",{className:"typography-micro truncate text-muted-foreground",children:y5(A,t)}),A.loopFile?s.jsx("div",{className:"typography-micro truncate text-muted-foreground/70",title:A.loopFile,children:t("sessions.scheduledTasks.dialog.loopFile.note",{file:A.loopFile})}):null]}),s.jsxs("div",{className:Re("mt-3 flex flex-wrap items-center gap-x-5 gap-y-1 typography-micro text-muted-foreground",!A.enabled&&"opacity-60"),children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(F,{name:"timer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.nextRun.label")}),se?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-foreground",children:Ad(se,t)}),s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:w5(se,i)})]}):s.jsx("span",{children:"—"})]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(F,{name:"history",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.lastRun.label")}),P==="running"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:"var(--status-warning)"},children:[s.jsx(F,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),t("sessions.scheduledTasks.dialog.lastRun.runningNow")]}):ce?s.jsxs(s.Fragment,{children:[Z.tone!=="muted"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:`var(--status-${Z.tone})`},children:[s.jsx(F,{name:Z.Icon,className:"h-3.5 w-3.5"}),X]}):null,s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:Ad(ce,t)})]}):s.jsx("span",{children:t("sessions.scheduledTasks.dialog.lastRun.never")})]})]}),A.state?.lastError?s.jsxs("div",{className:Re("mt-3 flex items-start gap-2 rounded-md border p-2 typography-micro",!A.enabled&&"opacity-60"),style:S5("error"),children:[s.jsx(F,{name:"error-warning",className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"min-w-0 break-words",children:A.state.lastError})]}):null,s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("label",{className:Re("inline-flex cursor-pointer items-center gap-2 typography-micro font-medium",A.enabled?"text-foreground":"text-muted-foreground",D&&"cursor-not-allowed opacity-50"),children:[s.jsx(Sr,{checked:A.enabled,onChange:re=>{R(A,re)},ariaLabel:A.enabled?t("sessions.scheduledTasks.dialog.taskToggle.pauseAria",{taskName:A.name}):t("sessions.scheduledTasks.dialog.taskToggle.enableAria",{taskName:A.name}),disabled:D}),A.enabled?t("sessions.scheduledTasks.dialog.taskToggle.enabled"):t("sessions.scheduledTasks.dialog.taskToggle.paused")]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsxs(ut,{variant:"outline",size:"sm",onClick:()=>{O(A)},disabled:D,children:[s.jsx(F,{name:"play",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.runNow")]}),s.jsxs(ut,{variant:"outline",size:"sm",onClick:()=>B(A),disabled:D,"aria-label":t("sessions.scheduledTasks.dialog.actions.editAria",{taskName:A.name}),children:[s.jsx(F,{name:"edit-2",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.edit")]}),s.jsx(ut,{variant:"destructive",size:"sm",onClick:()=>{I(A)},disabled:D,"aria-label":t("sessions.scheduledTasks.dialog.actions.deleteAria",{taskName:A.name}),children:s.jsx(F,{name:"delete-bin",className:"h-4 w-4"})})]})]})]},A.id)})})}),L=s.jsxs("div",{className:"space-y-4",children:[T,Y]});return s.jsxs(s.Fragment,{children:[r?s.jsx(ni,{open:e,title:t("sessions.scheduledTasks.dialog.title"),onClose:()=>n(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:A=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:t("sessions.scheduledTasks.dialog.title")}),A]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("sessions.scheduledTasks.dialog.description")})]}),footer:s.jsxs(ut,{className:"w-full",onClick:$,disabled:!u,children:[s.jsx(F,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]}),children:L}):e?s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-surface-elevated",children:s.jsxs("div",{className:"flex min-h-0 flex-1",children:[s.jsx("div",{className:"flex w-60 flex-shrink-0 flex-col border-r border-border/50",children:s.jsx("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:o.length===0?s.jsx("div",{className:"px-2 py-2 typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.empty")}):o.map(A=>s.jsx("button",{type:"button",onClick:()=>_(A.id),className:Re("flex w-full min-w-0 items-center rounded-md px-2 py-1.5 text-left typography-ui-label focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",u===A.id?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:C(A)},A.id))})}),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("div",{className:"flex items-center px-6 pt-3",children:s.jsxs(ut,{size:"sm",onClick:$,disabled:!u,children:[s.jsx(F,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]})}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-4",children:s.jsx("div",{className:"mx-auto w-full max-w-3xl",children:Y})})]})]})}):null,s.jsx(m5,{open:k,task:h,onOpenChange:w,onSave:M})]})}const Fo=100;function k5(){const t=et.c(108),{t:e}=kt(),n=Pe(R5),r=Pe(E5),i=nt(T5),o=nt(I5),l=os(D5);let a;t[0]!==n?(a=se=>n?se.archivedSessions:[],t[0]=n,t[1]=a):a=t[1];const d=js(dr(a)),[u,m]=c.useState(""),[f,p]=c.useState(null),[y,x]=c.useState(Fo);let k;t[2]!==u?(k=u.trim().toLowerCase(),t[2]=u,t[3]=k):k=t[3];const w=k;let h;e:{if(!n){let ce;t[4]===Symbol.for("react.memo_cache_sentinel")?(ce=[],t[4]=ce):ce=t[4],h=ce;break e}let se;t[5]!==d?(se=[...d].sort(P5),t[5]=d,t[6]=se):se=t[6],h=se}const g=h;let j;if(t[7]!==l||t[8]!==g||t[9]!==e){const se=new Map;for(const ce of g){const re=xt(Ps(ce))??"",ge=se.get(re);if(ge){ge.sessions.push(ce);continue}se.set(re,{directory:re,label:re?cr(re,l)||re:e("sessions.archivePage.otherProjects"),sessions:[ce]})}j=[...se.values()].sort(A5),t[7]=l,t[8]=g,t[9]=e,t[10]=j}else j=t[10];const b=j;let S;e:{if(w){if(w.startsWith("ses_")){let re;if(t[11]!==w||t[12]!==g){let ge;t[14]!==w?(ge=ae=>ae.id.toLowerCase()===w,t[14]=w,t[15]=ge):ge=t[15],re=g.filter(ge),t[11]=w,t[12]=g,t[13]=re}else re=t[13];S=re;break e}let ce;t[16]!==w||t[17]!==g?(ce=ux(g,w,N5),t[16]=w,t[17]=g,t[18]=ce):ce=t[18],S=ce;break e}if(f===null){S=g;break e}let se;t[19]!==b||t[20]!==f?(se=b.find(ce=>ce.directory===f)?.sessions??[],t[19]=b,t[20]=f,t[21]=se):se=t[21],S=se}const C=S;let v,M,R,I,B,O,T,$,_,Y;if(t[22]!==d.length||t[23]!==b||t[24]!==C||t[25]!==l||t[26]!==w||t[27]!==n||t[28]!==u||t[29]!==f||t[30]!==i||t[31]!==r||t[32]!==e||t[33]!==o||t[34]!==y){B=Symbol.for("react.early_return_sentinel");e:{const se=C.slice(0,y);v=C.length-se.length;const ce=d.length;let re;t[45]===Symbol.for("react.memo_cache_sentinel")?(re=xe=>{p(xe),x(Fo)},t[45]=re):re=t[45];const ge=re;let ae;t[46]!==i||t[47]!==r?(ae=xe=>{const U=xt(Ps(xe));i(xe.id,U??void 0),r(!1)},t[46]=i,t[47]=r,t[48]=ae):ae=t[48];const Ee=ae;let Se;t[49]!==e||t[50]!==o?(Se=xe=>{o(xe.id).then(U=>{U?ze.success(e("sessions.sidebar.session.restore.success")):ze.error(e("sessions.sidebar.session.restore.error"))})},t[49]=e,t[50]=o,t[51]=Se):Se=t[51];const me=Se;if(!n){B=null;break e}let ke;t[52]!==e?(ke=(xe,U,z,Q,ue,le,W)=>s.jsxs("div",{className:"group/dir relative",children:[s.jsxs("button",{type:"button",onClick:ue,title:le,className:Re("flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left typography-ui-label transition-[padding] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",W?"group-hover/dir:pr-8 group-focus-within/dir:pr-8":"",Q?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:U}),s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground/70",children:z})]}),W?s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>mn.requestDelete({sessions:W,mode:"session"}),className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:text-destructive group-hover/dir:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.deleteProjectAria",{label:U}),children:s.jsx(F,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),s.jsx(St,{side:"bottom",sideOffset:4,children:e("sessions.archivePage.deleteProject")})]}):null]},xe),t[52]=e,t[53]=ke):ke=t[53];const V=ke;I="absolute inset-0 z-10 flex flex-col bg-background",M="flex min-h-0 flex-1";let J;if(t[54]!==V||t[55]!==f||t[56]!==e||t[57]!==ce){let xe;t[59]===Symbol.for("react.memo_cache_sentinel")?(xe=()=>ge(null),t[59]=xe):xe=t[59],J=V("__all__",e("sessions.archivePage.allDirectories"),ce,f===null,xe),t[54]=V,t[55]=f,t[56]=e,t[57]=ce,t[58]=J}else J=t[58];let de;if(t[60]!==b||t[61]!==V||t[62]!==f){let xe;t[64]!==V||t[65]!==f?(xe=U=>V(U.directory||"__none__",U.label,U.sessions.length,f===U.directory,()=>ge(U.directory),U.directory||void 0,U.sessions),t[64]=V,t[65]=f,t[66]=xe):xe=t[66],de=b.map(xe),t[60]=b,t[61]=V,t[62]=f,t[63]=de}else de=t[63];t[67]!==J||t[68]!==de?(R=s.jsx("div",{className:"flex w-64 flex-shrink-0 flex-col border-r border-border/50",children:s.jsxs("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:[J,de]})}),t[67]=J,t[68]=de,t[69]=R):R=t[69],_="flex min-w-0 flex-1 flex-col";let we;t[70]===Symbol.for("react.memo_cache_sentinel")?(we=xe=>{m(xe),x(Fo)},t[70]=we):we=t[70];let G;t[71]!==e?(G=e("sessions.archivePage.searchPlaceholder"),t[71]=e,t[72]=G):G=t[72];let Ce;t[73]!==e?(Ce=e("sessions.sidebar.header.search.clear"),t[73]=e,t[74]=Ce):Ce=t[74];let Te;t[75]!==u||t[76]!==G||t[77]!==Ce?(Te=s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(su,{value:u,onSearch:we,placeholder:G,clearLabel:Ce})}),t[75]=u,t[76]=G,t[77]=Ce,t[78]=Te):Te=t[78];let pe;t[79]!==C.length||t[80]!==e?(pe=C.length===1?e("sessions.archivePage.countSingle",{count:C.length}):e("sessions.archivePage.countPlural",{count:C.length}),t[79]=C.length,t[80]=e,t[81]=pe):pe=t[81];let ne;t[82]!==pe?(ne=s.jsx("span",{className:"flex h-8 flex-shrink-0 items-center self-start typography-micro text-muted-foreground",children:pe}),t[82]=pe,t[83]=ne):ne=t[83],t[84]!==Te||t[85]!==ne?(Y=s.jsxs("div",{className:"flex items-center gap-3 px-6 pt-3",children:[Te,ne]}),t[84]=Te,t[85]=ne,t[86]=Y):Y=t[86],$="min-h-0 flex-1 overflow-y-auto px-6 py-3",O="mx-auto w-full max-w-3xl space-y-0.5",T=se.length===0?s.jsx("div",{className:"py-10 text-center text-muted-foreground",children:s.jsx("p",{className:"typography-ui-label font-semibold",children:e(w?"sessions.archivePage.empty.noMatches":"sessions.archivePage.empty.noArchived")})}):se.map(xe=>{const U=xt(Ps(xe))??"",z=U?cr(U,l)||U:null;return s.jsxs("div",{className:"group relative flex cursor-pointer items-center gap-3 rounded-md py-1 pl-2 pr-2 transition-[padding] hover:bg-interactive-hover/40 hover:pr-14 focus-within:pr-14",onClick:()=>Ee(xe),role:"button",tabIndex:0,onKeyDown:Q=>{(Q.key==="Enter"||Q.key===" ")&&(Q.preventDefault(),Ee(xe))},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:xe.title||e("sessions.sidebar.session.untitled")}),w&&z?s.jsx("span",{className:"max-w-40 flex-shrink-0 truncate text-[0.72rem] text-muted-foreground/70",title:U,children:z}):null,s.jsx("span",{className:"flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:qu(xe.time?.archived??xe.time?.updated??xe.time?.created??Date.now())}),s.jsx("button",{type:"button",onClick:Q=>{Q.stopPropagation(),me(xe)},className:"absolute right-7 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-foreground group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.restoreSessionAria",{title:xe.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(F,{name:"inbox-unarchive",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:Q=>{Q.stopPropagation(),mn.requestDelete({sessions:[xe],mode:"session"})},className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-destructive group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.deleteSessionAria",{title:xe.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(F,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},xe.id)})}t[22]=d.length,t[23]=b,t[24]=C,t[25]=l,t[26]=w,t[27]=n,t[28]=u,t[29]=f,t[30]=i,t[31]=r,t[32]=e,t[33]=o,t[34]=y,t[35]=v,t[36]=M,t[37]=R,t[38]=I,t[39]=B,t[40]=O,t[41]=T,t[42]=$,t[43]=_,t[44]=Y}else v=t[35],M=t[36],R=t[37],I=t[38],B=t[39],O=t[40],T=t[41],$=t[42],_=t[43],Y=t[44];if(B!==Symbol.for("react.early_return_sentinel"))return B;let L;t[87]!==v||t[88]!==e?(L=v>0?s.jsx("button",{type:"button",onClick:()=>x(C5),className:"mt-1 flex items-center justify-start rounded-md px-2 py-1 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,t[87]=v,t[88]=e,t[89]=L):L=t[89];let A;t[90]!==L||t[91]!==O||t[92]!==T?(A=s.jsxs("div",{className:O,children:[T,L]}),t[90]=L,t[91]=O,t[92]=T,t[93]=A):A=t[93];let D;t[94]!==A||t[95]!==$?(D=s.jsx("div",{className:$,children:A}),t[94]=A,t[95]=$,t[96]=D):D=t[96];let P;t[97]!==D||t[98]!==_||t[99]!==Y?(P=s.jsxs("div",{className:_,children:[Y,D]}),t[97]=D,t[98]=_,t[99]=Y,t[100]=P):P=t[100];let Z;t[101]!==M||t[102]!==R||t[103]!==P?(Z=s.jsxs("div",{className:M,children:[R,P]}),t[101]=M,t[102]=R,t[103]=P,t[104]=Z):Z=t[104];let X;return t[105]!==I||t[106]!==Z?(X=s.jsx("div",{className:I,children:Z}),t[105]=I,t[106]=Z,t[107]=X):X=t[107],X}function C5(t){return t+Fo}function N5(t){return[t.title]}function A5(t,e){return e.sessions.length-t.sessions.length}function P5(t,e){return(e.time?.archived??0)-(t.time?.archived??0)}function D5(t){return t.homeDirectory}function I5(t){return t.unarchiveSession}function T5(t){return t.setCurrentSession}function E5(t){return t.setArchivePageOpen}function R5(t){return t.isArchivePageOpen}function M5(){const t=et.c(18),{t:e}=kt(),n=Pe(F5),r=Pe(B5),i=Gt(O5);let o;t[0]!==n?(o=y=>y.projects.find(x=>x.id===n)??null,t[0]=n,t[1]=o):o=t[1];const l=Gt(o);if(!n||!l)return null;let a;t[2]!==l.id||t[3]!==i||t[4]!==r?(a=()=>{i(l.id),r(!0)},t[2]=l.id,t[3]=i,t[4]=r,t[5]=a):a=t[5];let d;t[6]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(F,{name:"node-tree",className:"mr-1 h-3.5 w-3.5"}),t[6]=d):d=t[6];let u;t[7]!==e?(u=e("sessions.sidebar.project.actions.newWorktree"),t[7]=e,t[8]=u):u=t[8];let m;t[9]!==a||t[10]!==u?(m=s.jsx("div",{className:"flex items-center",children:s.jsxs(ut,{size:"sm",onClick:a,children:[d,u]})}),t[9]=a,t[10]=u,t[11]=m):m=t[11];let f;t[12]!==l.id||t[13]!==l.path?(f=s.jsx(ep,{projectRef:{id:l.id,path:l.path},sections:"list-only"}),t[12]=l.id,t[13]=l.path,t[14]=f):f=t[14];let p;return t[15]!==m||t[16]!==f?(p=s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:s.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:s.jsxs("div",{className:"mx-auto w-full max-w-4xl space-y-4",children:[m,f]})})}),t[15]=m,t[16]=f,t[17]=p):p=t[17],p}function O5(t){return t.setActiveProjectIdOnly}function B5(t){return t.setNewWorktreeDialogOpen}function F5(t){return t.worktreesPageProjectId}function xm(t){const e=et.c(30),{git:n}=kn(),r=Au(t),i=Pu(t),o=fx(t),l=mx(t),a=Mn(W5),d=Mn(z5);let u,m;e[0]!==t||e[1]!==d||e[2]!==n||e[3]!==i||e[4]!==o?(u=()=>{!t||!n||i!==null||o||d(t,n,{silent:!0})},m=[t,n,d,i,o],e[0]=t,e[1]=d,e[2]=n,e[3]=i,e[4]=o,e[5]=u,e[6]=m):(u=e[5],m=e[6]),c.useEffect(u,m);let f;e[7]!==r?.all||e[8]!==t||e[9]!==a||e[10]!==n||e[11]!==i?(f=()=>{!t||!n||i===!0&&(r?.all||a(t,n))},e[7]=r?.all,e[8]=t,e[9]=a,e[10]=n,e[11]=i,e[12]=f):f=e[12];const p=r?.all;let y;e[13]!==t||e[14]!==a||e[15]!==n||e[16]!==i||e[17]!==p?(y=[t,n,i,p,a],e[13]=t,e[14]=a,e[15]=n,e[16]=i,e[17]=p,e[18]=y):y=e[18],c.useEffect(f,y);const x=o||i===!0&&l;let k;e:{if(!r?.all){let v;e[19]===Symbol.for("react.memo_cache_sentinel")?(v=[],e[19]=v):v=e[19],k=v;break e}let C;e[20]!==r.all?(C=r.all.filter($5).sort(),e[20]=r.all,e[21]=C):C=e[21],k=C}const w=k;let h;e:{if(!r?.all){let v;e[22]===Symbol.for("react.memo_cache_sentinel")?(v=[],e[22]=v):v=e[22],h=v;break e}let C;e[23]!==r.all?(C=r.all.filter(L5).map(_5).sort(),e[23]=r.all,e[24]=C):C=e[24],h=C}const g=h;let j;e:{if(!t){j=null;break e}if(i!==null){j=i;break e}if(x){j=null;break e}j=r?.all?!0:null}const b=j;let S;return e[25]!==b||e[26]!==x||e[27]!==w||e[28]!==g?(S={localBranches:w,remoteBranches:g,isLoading:x,isGitRepository:b},e[25]=b,e[26]=x,e[27]=w,e[28]=g,e[29]=S):S=e[29],S}function _5(t){return t.replace(/^remotes\//,"")}function L5(t){return t.startsWith("remotes/")}function $5(t){return!t.startsWith("remotes/")}function z5(t){return t.fetchStatus}function W5(t){return t.fetchBranches}const K5=({directory:t,value:e,onChange:n,className:r,disabled:i,id:o})=>{const{t:l}=kt(),{localBranches:a,remoteBranches:d,isLoading:u,isGitRepository:m}=xm(t),f=c.useMemo(()=>[...a,...d.map(y=>`remotes/${y}`)],[a,d]);c.useEffect(()=>{if(i||u||f.length===0||e&&f.includes(e))return;const y=e;let x=!1;return(async()=>{try{const w=t?await Ha(t).catch(()=>null):null;if(x)return;const h=localStorage.getItem(El),{sourceBranch:g,shouldClearSavedSourceBranch:j}=tp({branches:f,savedSourceBranch:h,rootBranch:w});if(j&&localStorage.removeItem(El),x||y&&f.includes(y))return;g&&n(g)}catch{}})(),()=>{x=!0}},[f,t,i,u,n,e]);const p=i||!m||u;return s.jsxs("div",{children:[s.jsxs(Ms,{value:e,onValueChange:n,disabled:p,children:[s.jsx(Os,{id:o,size:"lg",className:Re("min-w-0 max-w-full *:data-[slot=select-value]:truncate",r??"w-fit"),children:s.jsx(Cs,{placeholder:l(u?"multiRun.branchSelector.status.loadingBranches":"multiRun.branchSelector.placeholder.selectSourceBranch")})}),s.jsx(Bs,{className:"max-h-[280px] max-w-[320px]",children:u?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.loadingBranches")}):a.length===0&&d.length===0?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.noBranchesFound")}):s.jsxs(s.Fragment,{children:[a.length>0&&s.jsxs(aa,{children:[s.jsx(Gl,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.localBranches")}),a.map(y=>s.jsx(rs,{value:y,className:"whitespace-normal break-all",children:y},y))]}),a.length>0&&d.length>0&&s.jsx(hx,{}),d.length>0&&s.jsxs(aa,{children:[s.jsx(Gl,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.remoteBranches")}),d.map(y=>s.jsx(rs,{value:`remotes/${y}`,className:"whitespace-normal break-all",children:y},`remotes/${y}`))]})]})})]}),m===!1&&s.jsx("p",{className:"typography-micro text-muted-foreground/70 mt-2",children:l("multiRun.branchSelector.status.notInGitRepository")})]})},V5=10*1024*1024,_o=t=>{const e=et.c(3),{children:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",tabIndex:-1,className:"inline-flex items-center justify-center text-muted-foreground/50 hover:text-muted-foreground transition-colors",children:s.jsx(F,{name:"information",className:"h-3.5 w-3.5"})})}),e[0]=r):r=e[0];let i;return e[1]!==n?(i=s.jsxs(wt,{children:[r,s.jsx(St,{side:"top",className:"max-w-[240px]",children:n})]}),e[1]=n,e[2]=i):i=e[2],i},sr=t=>{const e=et.c(9),{htmlFor:n,required:r,children:i,info:o}=t;let l;e[0]!==r?(l=r&&s.jsx("span",{className:"text-destructive ml-0.5",children:"*"}),e[0]=r,e[1]=l):l=e[1];let a;e[2]!==i||e[3]!==n||e[4]!==l?(a=s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[i,l]}),e[2]=i,e[3]=n,e[4]=l,e[5]=a):a=e[5];const d=o&&o;let u;return e[6]!==a||e[7]!==d?(u=s.jsxs("div",{className:"flex items-center gap-1.5",children:[a,d]}),e[6]=a,e[7]=d,e[8]=u):u=e[8],u},U5=({initialPrompt:t,onCreated:e,onCancel:n,isWindowed:r=!1})=>{const{t:i}=kt(),[o,l]=c.useState(""),[a,d]=c.useState(()=>[{id:Yr(),prompt:"",models:[]}]),[u,m]=c.useState(""),[f,p]=c.useState([]),[y,x]=c.useState(!1),[k,w]=c.useState([]),[h,g]=c.useState(!1),[j,b]=c.useState(!1),[S,C]=c.useState(!0),v=c.useRef(null),M=os(E=>E.currentDirectory??null),R=os(E=>E.homeDirectory??null),I=c.useMemo(()=>{if(typeof window>"u")return null;const E=window.__VSCODE_CONFIG__?.workspaceFolder;return typeof E=="string"&&E.trim().length>0?E.trim():null},[]),B=Gt(E=>E.activeProjectId),O=Gt(E=>E.setActiveProjectIdOnly),T=Gt(E=>E.projects),[$,_]=c.useState(()=>B??null);c.useEffect(()=>{if(B){_(B);return}!$&&T.length>0&&_(T[0].id)},[B,T,$]);const Y=c.useMemo(()=>$?T.find(E=>E.id===$)??null:null,[T,$]),L=Y?.path??M,A=c.useCallback(E=>{_(E),E!==B&&O(E)},[B,O]),{currentTheme:D}=Kn(),P=c.useCallback(E=>{const K=E.label?.trim()||cr(E.path,R),te=E.icon?oi[E.icon]:null,oe=E.color?ii[E.color]:void 0,he=te?s.jsx(F,{name:te,className:"h-3.5 w-3.5 shrink-0",style:oe?{color:oe}:void 0}):s.jsx(F,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:oe?{color:oe}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[E.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:E.iconBackground?{backgroundColor:E.iconBackground}:void 0,children:s.jsx(ai,{project:{id:E.id,iconImage:E.iconImage??null},options:{themeVariant:D.metadata.variant,iconColor:D.colors.surface.foreground},className:"h-full w-full object-contain",fallback:he})}):he,s.jsx("span",{className:"truncate",children:K})]})},[R,D.metadata.variant,D.colors.surface.foreground]),Z=c.useMemo(()=>{if(Y?.path)return{id:Y.id,path:Y.path};const E=M??I;return E?{id:`path:${E}`,path:E}:null},[Y,M,I]),[X]=c.useState(()=>typeof window<"u"?vn():!1),se=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),ce=gu(),re=c.useMemo(()=>{if(typeof window>"u")return null;const E=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof E=="number"&&Number.isFinite(E)&&E>0)return E;if(typeof navigator>"u")return null;const K=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!K)return null;const te=Number.parseInt(K[1],10),oe=Number.parseInt(K[2],10);return Number.isNaN(te)?null:te===10?oe:te},[]),ge=c.useMemo(()=>X&&se||ce?"pl-[88px]":"pl-3",[X,se,ce]),ae=c.useMemo(()=>!X||!se||re===null?"":re>=26?"h-12":re<=15?"h-14":"",[X,se,re]),Ee=c.useCallback(async E=>{E.target.closest("button, a, input, select, textarea")||E.button===0&&X&&await px()},[X]);c.useEffect(()=>{if(!n)return;const E=K=>{K.key==="Escape"&&(K.preventDefault(),K.stopPropagation(),n())};return window.addEventListener("keydown",E,!0),()=>window.removeEventListener("keydown",E,!0)},[n]);const[Se,me]=c.useState(""),{isLoading:ke,isGitRepository:V}=xm(L),J=c.useRef(!1),de=V===!0,we=de&&S;c.useEffect(()=>{if(V===!1){J.current=!0,C(!1);return}V===!0&&J.current&&(J.current=!1,C(!0))},[V]);const G=Di(E=>E.createMultiRun),Ce=Di(E=>E.error),Te=Di(E=>E.clearError);c.useEffect(()=>{typeof t=="string"&&t.trim().length>0&&d(E=>{const K=[...E];return K.length>0&&!K[0].prompt.trim()&&(K[0]={...K[0],prompt:t}),K})},[t]),c.useEffect(()=>{if(!Z)return;let E=!1;return b(!0),(async()=>{try{const K=await gx(Z);E||w(K)}catch{}finally{E||b(!1)}})(),()=>{E=!0}},[Z]);const pe=c.useCallback((E,K)=>{d(te=>te.map(oe=>oe.id===E?{...oe,...K}:oe))},[]),ne=c.useCallback(E=>{d(K=>K.filter(te=>te.id!==E))},[]),xe=c.useCallback(()=>{d(E=>[...E,{id:Yr(),prompt:"",models:[]}])},[]),U=async E=>{const K=E.target.files;if(!K)return;let te=0;for(let oe=0;oe<K.length;oe++){const he=K[oe];if(he.size>V5){ze.error(i("multirun.launcher.toast.fileTooLarge",{fileName:he.name}));continue}try{const ie=await new Promise((Fe,_e)=>{const Ae=new FileReader;Ae.onload=()=>Fe(Ae.result),Ae.onerror=_e,Ae.readAsDataURL(he)});p(Fe=>[...Fe,{id:Yr(),filename:he.name,mimeType:he.type||"application/octet-stream",size:he.size,dataUrl:ie}]),te++}catch(ie){console.error("File attach failed",ie),ze.error(i("multirun.launcher.toast.attachFailed",{fileName:he.name}))}}te>0&&ze.success(te===1?i("multirun.launcher.toast.attachedSingle",{count:te}):i("multirun.launcher.toast.attachedPlural",{count:te})),v.current&&(v.current.value="")},z=E=>{p(K=>K.filter(te=>te.id!==E))},Q=c.useMemo(()=>a.reduce((E,K)=>E+K.models.length,0),[a]),ue=async E=>{E.preventDefault();const K=a.filter(te=>te.prompt.trim()&&te.models.length>=1);if(K.length!==0&&!(Q<1)){x(!0),Te();try{$&&$!==B&&O($);const te=f.map(_e=>({mime:_e.mimeType,filename:_e.filename,url:_e.dataUrl})),oe=k.filter(_e=>_e.trim().length>0),he=K.map(_e=>({prompt:_e.prompt.trim(),models:_e.models.map(Ae=>({providerID:Ae.providerID,modelID:Ae.modelID,displayName:Ae.displayName,variant:Ae.variant}))})),ie={name:o.trim(),groups:he,agent:u||void 0,worktreeBaseBranch:we?Se:void 0,isolateRuns:we,files:te.length>0?te:void 0,setupCommands:oe.length>0?oe:void 0},Fe=await G(ie);Fe&&(Fe.failedCount>0&&ze.error(i("multirun.launcher.toast.partialFailure",{failed:Fe.failedCount})),Fe.firstSessionId&&nt.getState().setCurrentSession(Fe.firstSessionId),e?.())}finally{x(!1)}}},le=!!(o.trim()&&a.some(E=>E.prompt.trim()&&E.models.length>=1)&&Q>=1&&L&&!ke&&(V===!1||!we||Se)),W=k.filter(E=>E.trim()).length;return s.jsxs("form",{onSubmit:ue,className:"flex flex-col h-full bg-background",children:[r?null:s.jsxs("header",{onMouseDown:Ee,className:Re("relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none",ge,ae),style:{borderColor:"var(--interactive-border)"},children:[s.jsx("h1",{className:"typography-ui-label font-medium",children:i("multirun.launcher.title")}),n&&s.jsx("div",{className:"absolute right-0 flex items-center pr-3",children:s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":i("multirun.launcher.actions.closeEsc"),className:"inline-flex h-9 w-9 items-center justify-center p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring app-region-no-drag",children:s.jsx(F,{name:"close",className:"h-5 w-5"})})}),s.jsx(St,{children:s.jsx("p",{children:i("multirun.launcher.actions.closeEsc")})})]})})]}),s.jsx(Ga,{className:"flex-1 min-h-0 overflow-auto",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 py-5",children:s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(sr,{htmlFor:"multirun-project",required:!0,children:i("multirun.launcher.project.label")}),T.length>0?s.jsxs(Ms,{value:$??void 0,onValueChange:A,children:[s.jsx(Os,{id:"multirun-project",size:"lg",className:"w-fit max-w-full",children:Y?s.jsx(Cs,{children:P(Y)}):s.jsx(Cs,{placeholder:i("multirun.launcher.project.placeholder")})}),s.jsx(Bs,{fitContent:!0,children:T.map(E=>s.jsx(rs,{value:E.id,className:"max-w-[24rem]",children:P(E)},E.id))})]}):s.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:i("multirun.launcher.project.empty")})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(sr,{htmlFor:"group-name",required:!0,info:s.jsx(_o,{children:i("multirun.launcher.groupName.info")}),children:i("multirun.launcher.groupName.label")}),s.jsx(In,{id:"group-name",value:o,onChange:E=>l(E.target.value),placeholder:i("multirun.launcher.groupName.placeholder"),className:"typography-meta w-full",required:!0})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(sr,{htmlFor:"multirun-worktree-base-branch",info:s.jsx(_o,{children:i("multirun.launcher.baseBranch.info")}),children:i("multirun.launcher.baseBranch.label")}),s.jsx(K5,{directory:L,value:Se,onChange:me,disabled:!we,id:"multirun-worktree-base-branch"}),s.jsxs("label",{className:"mt-1.5 flex w-fit items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(Sr,{checked:S,onChange:C,disabled:!de,ariaLabel:i("multirun.launcher.isolateRuns.label")}),s.jsx("span",{children:i("multirun.launcher.isolateRuns.label")})]})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(sr,{htmlFor:"multirun-agent",info:s.jsx(_o,{children:i("multirun.launcher.agent.info")}),children:i("multirun.launcher.agent.label")}),s.jsx(om,{value:u,onChange:m,id:"multirun-agent"})]})]}),s.jsxs(ta,{open:h,onOpenChange:g,children:[s.jsxs(Nu,{className:"w-full flex items-center gap-2 py-1.5 px-2 -mx-2 rounded-lg hover:bg-[var(--interactive-hover)]/50 transition-colors group",children:[s.jsx(F,{name:"terminal",className:"h-3.5 w-3.5 text-muted-foreground/70"}),s.jsx("span",{className:"typography-meta font-medium text-muted-foreground group-hover:text-foreground transition-colors",children:i("multirun.launcher.setupCommands.label")}),W>0&&s.jsx("span",{className:"inline-flex items-center justify-center h-4 min-w-4 px-1 rounded-full typography-micro font-medium",style:{backgroundColor:"var(--primary-base)",color:"var(--primary-foreground)",fontSize:"0.625rem",lineHeight:1},children:W}),s.jsx(F,{name:"arrow-down-s",className:Re("h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto",h&&"rotate-180")})]}),s.jsx(sa,{children:s.jsx("div",{className:"pt-2 space-y-1.5",children:j?s.jsx("p",{className:"typography-meta text-muted-foreground/70 px-2",children:i("multirun.launcher.setupCommands.loading")}):s.jsxs(s.Fragment,{children:[k.map((E,K)=>s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(In,{value:E,onChange:te=>{const oe=[...k];oe[K]=te.target.value,w(oe)},placeholder:i("multirun.launcher.setupCommands.commandPlaceholder"),className:"h-8 flex-1 font-mono text-xs"}),s.jsx("button",{type:"button",onClick:()=>w(k.filter((te,oe)=>oe!==K)),className:"flex-shrink-0 flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":i("multirun.launcher.setupCommands.removeCommandAria"),children:s.jsx(F,{name:"close",className:"h-3.5 w-3.5"})})]},`${E}-${K}`)),s.jsxs("button",{type:"button",onClick:()=>w([...k,""]),className:"flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1",children:[s.jsx(F,{name:"add",className:"h-3 w-3"}),i("multirun.launcher.setupCommands.addCommand")]})]})})})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(sr,{htmlFor:"prompt",required:!0,children:i("multirun.launcher.attachments.label")}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx("input",{ref:v,type:"file",multiple:!0,className:"hidden",onChange:U,accept:"*/*"}),s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>v.current?.click(),className:"inline-flex items-center gap-1 h-6 px-2 rounded-md typography-micro text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(F,{name:"attachment-2",className:"h-3 w-3"}),i("multirun.launcher.attachments.attach")]})}),s.jsx(St,{children:i("multirun.launcher.attachments.tooltip")})]}),f.map(E=>s.jsxs("div",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md typography-micro border",style:{backgroundColor:"var(--surface-elevated)",borderColor:"var(--interactive-border)"},children:[E.mimeType.startsWith("image/")?s.jsx(F,{name:"file-image",className:"h-3 w-3 text-muted-foreground"}):s.jsx(F,{name:"file",className:"h-3 w-3 text-muted-foreground"}),s.jsx("span",{className:"truncate max-w-[100px]",title:E.filename,children:E.filename}),s.jsx("button",{type:"button",onClick:()=>z(E.id),className:"text-muted-foreground hover:text-destructive",children:s.jsx(F,{name:"close",className:"h-3 w-3"})})]},E.id))]})]}),a.map((E,K)=>s.jsx(H5,{group:E,groupIndex:K,canRemove:a.length>1,onUpdate:pe,onRemove:ne},E.id)),s.jsxs("button",{type:"button",onClick:xe,className:"flex items-center gap-1.5 py-2 px-3 -mx-3 rounded-lg typography-meta font-medium text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(F,{name:"add",className:"h-3.5 w-3.5"}),i("multirun.launcher.groups.addGroup")]}),Ce&&s.jsx("div",{className:"px-3 py-2 rounded-lg typography-meta",style:{backgroundColor:"var(--status-error-background)",color:"var(--status-error)",borderWidth:1,borderColor:"var(--status-error-border)"},children:Ce})]})})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl flex items-center justify-end gap-2",children:[!we&&V!==null?s.jsxs("div",{className:"mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(F,{name:"information",className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:i("multirun.launcher.project.gitRequired")})]}):null,!r&&n?s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:n,children:i("multirun.launcher.actions.cancel")}):null,s.jsx(ut,{type:"submit",size:"sm",disabled:!le||y,children:y?i("multirun.launcher.actions.creating"):s.jsx(s.Fragment,{children:i("multirun.launcher.actions.startWithRunCount",{count:Q})})})]})})]})},H5=t=>{const e=et.c(99),{group:n,groupIndex:r,canRemove:i,onUpdate:o,onRemove:l}=t,{t:a}=kt(),[d,u]=c.useState(!1),[m,f]=c.useState(""),[p,y]=c.useState(!1),[x,k]=c.useState(""),[w,h]=c.useState(!1),[g,j]=c.useState(""),b=c.useRef(null),S=c.useRef(null),C=c.useRef(null),v=c.useRef(null);let M;e[0]!==n.id||e[1]!==n.models||e[2]!==o?(M=oe=>{o(n.id,{models:[...n.models,oe]})},e[0]=n.id,e[1]=n.models,e[2]=o,e[3]=M):M=e[3];const R=M;let I;e[4]!==n.id||e[5]!==n.models||e[6]!==o?(I=oe=>{o(n.id,{models:n.models.filter((he,ie)=>ie!==oe)})},e[4]=n.id,e[5]=n.models,e[6]=o,e[7]=I):I=e[7];const B=I;let O;e[8]!==n.id||e[9]!==n.models||e[10]!==o?(O=(oe,he)=>{o(n.id,{models:n.models.map((ie,Fe)=>Fe===oe?he:ie)})},e[8]=n.id,e[9]=n.models,e[10]=o,e[11]=O):O=e[11];const T=O;let $;e[12]===Symbol.for("react.memo_cache_sentinel")?($=(oe,he)=>{if(oe.startsWith("/")){const Ae=oe.indexOf(" "),Me=oe.indexOf(`
|
|
893
|
-
`),q=Math.min(Ae===-1?oe.length:Ae,Me===-1?oe.length:Me);if(he<=q&&Ae===-1){k(oe.substring(1,q)),y(!0),u(!1),h(!1);return}}y(!1);const ie=oe.substring(0,he),Fe=ie.lastIndexOf("#");if(Fe!==-1){const Ae=Fe>0?ie[Fe-1]:null,Me=ie.substring(Fe+1);if((!Ae||/\s/.test(Ae))&&!Me.includes(" ")&&!Me.includes(`
|
|
894
|
-
`)){j(Me),h(!0),u(!1);return}}h(!1);const _e=ie.lastIndexOf("@");if(_e!==-1){const Ae=_e>0?ie[_e-1]:null,Me=ie.substring(_e+1);(!Ae||/\s/.test(Ae))&&!Me.includes(" ")&&!Me.includes(`
|
|
895
|
-
`)?(f(Me),u(!0)):u(!1);return}u(!1)},e[12]=$):$=e[12];const _=$;let Y;e[13]!==n.id||e[14]!==o?(Y=oe=>{o(n.id,{prompt:oe})},e[13]=n.id,e[14]=o,e[15]=Y):Y=e[15];const L=Y;let A;e[16]!==n.prompt||e[17]!==L?(A=oe=>{const he=n.prompt,Fe=b.current?.selectionStart??he.length,Ae=he.substring(0,Fe).lastIndexOf("@"),Me=oe.relativePath&&oe.relativePath.trim().length>0?oe.relativePath.trim():oe.path||oe.name,q=Ae!==-1?Ae:Fe,Ne=`${he.substring(0,q)}@${Me} ${he.substring(Fe)}`,je=q+Me.length+2;L(Ne),u(!1),f(""),requestAnimationFrame(()=>{const We=b.current;We&&(We.selectionStart=je,We.selectionEnd=je,We.focus()),_(Ne,je)})},e[16]=n.prompt,e[17]=L,e[18]=A):A=e[18];const D=A;let P;e[19]!==n.prompt||e[20]!==L?(P=oe=>{const he=n.prompt,Fe=b.current?.selectionStart??he.length,Ae=he.substring(0,Fe).lastIndexOf("@"),Me=Ae!==-1?Ae:Fe,q=`${he.substring(0,Me)}@${oe} ${he.substring(Fe)}`,Ne=Me+oe.length+2;L(q),u(!1),f(""),requestAnimationFrame(()=>{const je=b.current;je&&(je.selectionStart=Ne,je.selectionEnd=Ne,je.focus()),_(q,Ne)})},e[19]=n.prompt,e[20]=L,e[21]=P):P=e[21];const Z=P;let X;e[22]!==L?(X=oe=>{const he=`/${oe.name} `;L(he),y(!1),k(""),h(!1),requestAnimationFrame(()=>{const ie=b.current;ie&&(ie.focus(),ie.selectionStart=ie.value.length,ie.selectionEnd=ie.value.length),_(he,he.length)})},e[22]=L,e[23]=X):X=e[23];const se=X;let ce;e[24]!==n.prompt||e[25]!==L?(ce=(oe,he)=>{const ie=n.prompt,_e=b.current?.selectionStart??ie.length,Me=ie.substring(0,_e).lastIndexOf("#"),q=Me!==-1?Me:_e,Ne=`${ie.substring(0,q)}#${he} ${ie.substring(_e)}`,je=q+he.length+2;L(Ne),h(!1),j(""),requestAnimationFrame(()=>{const We=b.current;We&&(We.selectionStart=je,We.selectionEnd=je,We.focus()),_(Ne,je)})},e[24]=n.prompt,e[25]=L,e[26]=ce):ce=e[26];const re=ce;let ge;e[27]!==p||e[28]!==d||e[29]!==w?(ge=oe=>{if(p&&C.current&&(oe.key==="Enter"||oe.key==="ArrowUp"||oe.key==="ArrowDown"||oe.key==="Escape"||oe.key==="Tab")){oe.preventDefault(),C.current.handleKeyDown(oe.key);return}d&&S.current&&(oe.key==="Enter"||oe.key==="ArrowUp"||oe.key==="ArrowDown"||oe.key==="Escape"||oe.key==="Tab")&&(oe.preventDefault(),S.current.handleKeyDown(oe.key)),w&&v.current&&(oe.key==="Enter"||oe.key==="ArrowUp"||oe.key==="ArrowDown"||oe.key==="Escape"||oe.key==="Tab")&&(oe.preventDefault(),v.current.handleKeyDown(oe.key))},e[27]=p,e[28]=d,e[29]=w,e[30]=ge):ge=e[30];const ae=ge,Ee=r+1;let Se;e[31]!==a||e[32]!==Ee?(Se=a("multirun.launcher.groups.groupLabel",{index:Ee}),e[31]=a,e[32]=Ee,e[33]=Se):Se=e[33];let me;e[34]!==Se?(me=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:Se}),e[34]=Se,e[35]=me):me=e[35];let ke;e[36]!==i||e[37]!==n.id||e[38]!==l||e[39]!==a?(ke=i&&s.jsx("button",{type:"button",onClick:()=>l(n.id),className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10","aria-label":a("multirun.launcher.groups.removeGroup"),children:s.jsx(F,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=i,e[37]=n.id,e[38]=l,e[39]=a,e[40]=ke):ke=e[40];let V;e[41]!==me||e[42]!==ke?(V=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[me,ke]}),e[41]=me,e[42]=ke,e[43]=V):V=e[43];let J;e[44]!==a?(J=a("multirun.launcher.groups.prompt.label"),e[44]=a,e[45]=J):J=e[45];let de;e[46]!==J?(de=s.jsx(sr,{required:!0,children:J}),e[46]=J,e[47]=de):de=e[47];const we=n.prompt;let G;e[48]!==L?(G=oe=>{const he=oe.target.value;L(he);const ie=oe.target.selectionStart??he.length;_(he,ie)},e[48]=L,e[49]=G):G=e[49];let Ce;e[50]!==a?(Ce=a("multirun.launcher.groups.prompt.placeholder"),e[50]=a,e[51]=Ce):Ce=e[51];let Te;e[52]!==n.prompt||e[53]!==ae||e[54]!==G||e[55]!==Ce?(Te=s.jsx(wr,{ref:b,value:we,onChange:G,onKeyDown:ae,placeholder:Ce,className:"typography-meta min-h-[80px] max-h-[200px] resize-none overflow-y-auto field-sizing-content",required:!0}),e[52]=n.prompt,e[53]=ae,e[54]=G,e[55]=Ce,e[56]=Te):Te=e[56];let pe;e[57]!==x||e[58]!==se||e[59]!==p?(pe=p?s.jsx(Yu,{ref:C,searchQuery:x,onCommandSelect:se,onClose:()=>y(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=x,e[58]=se,e[59]=p,e[60]=pe):pe=e[60];let ne;e[61]!==Z||e[62]!==D||e[63]!==m||e[64]!==d?(ne=d?s.jsx(Qu,{ref:S,searchQuery:m,onFileSelect:D,onAgentSelect:Z,onClose:()=>u(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=Z,e[62]=D,e[63]=m,e[64]=d,e[65]=ne):ne=e[65];let xe;e[66]!==re||e[67]!==w||e[68]!==g?(xe=w?s.jsx(Xu,{ref:v,searchQuery:g,onSnippetSelect:re,onClose:()=>h(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=re,e[67]=w,e[68]=g,e[69]=xe):xe=e[69];let U;e[70]!==Te||e[71]!==pe||e[72]!==ne||e[73]!==xe?(U=s.jsxs("div",{className:"relative",children:[Te,pe,ne,xe]}),e[70]=Te,e[71]=pe,e[72]=ne,e[73]=xe,e[74]=U):U=e[74];let z;e[75]!==de||e[76]!==U?(z=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[de,U]}),e[75]=de,e[76]=U,e[77]=z):z=e[77];let Q;e[78]!==a?(Q=a("multirun.launcher.models.info"),e[78]=a,e[79]=Q):Q=e[79];let ue;e[80]!==Q?(ue=s.jsx(_o,{children:Q}),e[80]=Q,e[81]=ue):ue=e[81];let le;e[82]!==a?(le=a("multirun.launcher.models.label"),e[82]=a,e[83]=le):le=e[83];let W;e[84]!==ue||e[85]!==le?(W=s.jsx(sr,{required:!0,info:ue,children:le}),e[84]=ue,e[85]=le,e[86]=W):W=e[86];let E;e[87]!==n.models||e[88]!==R||e[89]!==B||e[90]!==T?(E=s.jsx(im,{selectedModels:n.models,onAdd:R,onRemove:B,onUpdate:T,minModels:1}),e[87]=n.models,e[88]=R,e[89]=B,e[90]=T,e[91]=E):E=e[91];let K;e[92]!==W||e[93]!==E?(K=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[W,E]}),e[92]=W,e[93]=E,e[94]=K):K=e[94];let te;return e[95]!==V||e[96]!==z||e[97]!==K?(te=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[V,z,K]}),e[95]=V,e[96]=z,e[97]=K,e[98]=te):te=e[98],te};function G5(t){const e=[],n=(r,i)=>{const o=xt(r);!o||e.some(l=>l.directory===o)||e.push({directory:o,priority:"selected",reason:i})};return n(t.currentDirectory,"current-directory"),n(t.currentSessionDirectory,"selected-session"),e}const q5=t=>{const e=new Map;for(const n of t){const r=Ps(n);r&&e.set(n.id,{directory:r,sessionId:n.id})}return e},Y5=(t,e)=>{if(!t)return[];const n=[];return t.forEach((r,i)=>{e.has(i)||n.push(r)}),n},Q5=t=>{const e=et.c(5),{enabled:n,hasAuthoritativeGlobalSessions:r,sessions:i}=t,o=n===void 0?!0:n,l=c.useRef(null);let a,d;e[0]!==o||e[1]!==r||e[2]!==i?(a=()=>{if(!o||!r)return;const u=Qt(),m=q5(i),f=l.current?.runtimeKey===u?l.current.identities:null;for(const p of Y5(f,m))xx({runtimeKey:u,...p});l.current={runtimeKey:u,identities:m}},d=[o,r,i],e[0]=o,e[1]=r,e[2]=i,e[3]=a,e[4]=d):(a=e[3],d=e[4]),c.useEffect(a,d)},X5=new Map,J5=t=>{const e=et.c(23),{isVSCode:n}=t,r=li(),i=Gt(Z5),o=os(eC),l=nt(tC);let a;e[0]!==n?(a=R=>n?X5:R.availableWorktreesByProject,e[0]=n,e[1]=a):a=e[1];const d=nt(a),u=!n;let m;e[2]!==d||e[3]!==i||e[4]!==u?(m=hm(i,d,{includeWorktrees:u}),e[2]=d,e[3]=i,e[4]=u,e[5]=m):m=e[5];const f=m,p=js(sC),y=js(nC),x=js(rC),k=`session-list-sync:${c.useId()}`;let w,h;e[6]!==k||e[7]!==r||e[8]!==o||e[9]!==l?(w=()=>(r.setBootstrapDemand(k,G5({currentDirectory:o,currentSessionDirectory:l})),()=>r.clearBootstrapDemand(k)),h=[k,r,o,l],e[6]=k,e[7]=r,e[8]=o,e[9]=l,e[10]=w,e[11]=h):(w=e[10],h=e[11]),c.useEffect(w,h);const g=c.useRef(null);let j,b;e[12]!==n||e[13]!==f?(j=()=>{const R=new Set(f),I=g.current;g.current=R;const B=I?[...R].filter(O=>!I.has(O)):n?[...R]:[];B.length&&Wa(B,Ko())},b=[n,f],e[12]=n,e[13]=f,e[14]=j,e[15]=b):(j=e[14],b=e[15]),c.useEffect(j,b);let S;e[16]===Symbol.for("react.memo_cache_sentinel")?(S=[],e[16]=S):S=e[16],c.useEffect(oC,S);let C;e[17]!==y||e[18]!==p?(C=[...p,...y],e[17]=y,e[18]=p,e[19]=C):C=e[19];const v=C;let M;e[20]!==v||e[21]!==x?(M={enabled:!0,hasAuthoritativeGlobalSessions:x,sessions:v},e[20]=v,e[21]=x,e[22]=M):M=e[22],Q5(M)};function Z5(t){return t.projects}function eC(t){return t.currentDirectory}function tC(t){return t.currentSessionDirectory}function sC(t){return t.activeSessions}function nC(t){return t.archivedSessions}function rC(t){return t.status==="ready"}function oC(){let t=null,e=!1;const n=new Set,r=Hn(i=>{if(i.type==="scheduled-task-ran")e=!0;else if(i.type==="session-created")n.add(i.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,n.clear(),ci(Ko());return}const o=[...n];n.clear(),o.length&&Wa(o,Ko())},500)});return()=>{t&&clearTimeout(t),r()}}const iC=Gn(()=>jn(()=>import("./SettingsWindow-D6oi-UmV.js"),__vite__mapDeps([146,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,147,84,85,86,148,132,133,134,135,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,149,150,151])).then(t=>({default:t.SettingsWindow}))),aC=()=>{const t=et.c(72);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],J5(e),sp();const n=Pe(lC),r=Pe(cC),i=Pe(dC),o=Pe(uC),[l,a]=c.useState(!1);let d,u;t[1]!==i?(d=()=>{i&&a(!0)},u=[i],t[1]=i,t[2]=d,t[3]=u):(d=t[2],u=t[3]),c.useEffect(d,u);const m=Pe(fC),f=Pe(mC),p=Pe(hC),y=Pe(pC),x=Pe(gC),k=Pe(xC),w=Pe(bC),h=Pe(yC),g=_u();let j;if(t[4]!==g||t[5]!==h){let U;t[7]!==h?(U=z=>z.id===h,t[7]=h,t[8]=U):U=t[8],j=g.find(U),t[4]=g,t[5]=h,t[6]=j}else j=t[6];const b=j;let S,C;t[9]!==b||t[10]!==h?(S=()=>{h&&!b&&Pe.getState().setOpenGuestPage(null)},C=[h,b],t[9]=b,t[10]=h,t[11]=S,t[12]=C):(S=t[11],C=t[12]),c.useEffect(S,C);let v;t[13]===Symbol.for("react.memo_cache_sentinel")?(v=[],t[13]=v):v=t[13],c.useEffect(vC,v);const M=y||x||k||!!w||m||!!b;let R;t[14]===Symbol.for("react.memo_cache_sentinel")?(R=[],t[14]=R):R=t[14],c.useEffect(jC,R);const{isMobile:I}=Vn();np();let B,O;t[15]!==I||t[16]!==r?(B=()=>{Pe.getState().isMobile!==I&&r(I)},O=[I,r],t[15]=I,t[16]=r,t[17]=B,t[18]=O):(B=t[17],O=t[18]),c.useEffect(B,O);let T,$,_,Y,L;t[19]===Symbol.for("react.memo_cache_sentinel")?(T=s.jsx(i0,{}),$=s.jsx(nj,{}),_=s.jsx(aj,{}),Y=s.jsx(Q4,{}),L=s.jsx(Ry,{}),t[19]=T,t[20]=$,t[21]=_,t[22]=Y,t[23]=L):(T=t[19],$=t[20],_=t[21],Y=t[22],L=t[23]);let A;t[24]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx(Ey,{}),t[24]=A):A=t[24];let D;t[25]!==n?(D=s.jsx(Y4,{isVisible:n}),t[25]=n,t[26]=D):D=t[26];let P;t[27]!==I||t[28]!==n||t[29]!==D?(P=s.jsx(Ty,{isOpen:n,isMobile:I,className:"border-border",topBar:A,children:D}),t[27]=I,t[28]=n,t[29]=D,t[30]=P):P=t[30];let Z;t[31]===Symbol.for("react.memo_cache_sentinel")?(Z=s.jsx(Dy,{}),t[31]=Z):Z=t[31];const X=M&&"invisible";let se;t[32]!==X?(se=Re("absolute inset-0",X),t[32]=X,t[33]=se):se=t[33];const ce=!i&&!M;let re;t[34]!==ce?(re=s.jsx(Ns,{children:s.jsx(iu,{active:ce})}),t[34]=ce,t[35]=re):re=t[35];let ge;t[36]!==se||t[37]!==re?(ge=s.jsx("div",{className:se,children:re}),t[36]=se,t[37]=re,t[38]=ge):ge=t[38];let ae;t[39]!==m||t[40]!==p||t[41]!==f?(ae=m&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Ns,{children:s.jsx(U5,{isWindowed:!0,initialPrompt:p,onCreated:()=>f(!1),onCancel:()=>f(!1)})})}),t[39]=m,t[40]=p,t[41]=f,t[42]=ae):ae=t[42];let Ee;t[43]===Symbol.for("react.memo_cache_sentinel")?(Ee=s.jsx(Ns,{children:s.jsx(j5,{})}),t[43]=Ee):Ee=t[43];let Se;t[44]===Symbol.for("react.memo_cache_sentinel")?(Se=s.jsx(Ns,{children:s.jsx(k5,{})}),t[44]=Se):Se=t[44];let me;t[45]!==k?(me=k&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Ns,{children:s.jsx(rp,{})})}),t[45]=k,t[46]=me):me=t[46];let ke;t[47]===Symbol.for("react.memo_cache_sentinel")?(ke=s.jsx(Ns,{children:s.jsx(M5,{})}),t[47]=ke):ke=t[47];let V;t[48]!==b?(V=b&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Ns,{children:s.jsx(kb,{mode:`plugin:${b.id}`,surface:"page",item:null,onDismiss:kC})})}),t[48]=b,t[49]=V):V=t[49];let J;t[50]!==ge||t[51]!==ae||t[52]!==me||t[53]!==V?(J=s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[ge,ae,Ee,Se,me,ke,V]}),t[50]=ge,t[51]=ae,t[52]=me,t[53]=V,t[54]=J):J=t[54];let de;t[55]===Symbol.for("react.memo_cache_sentinel")?(de=s.jsx(PS,{}),t[55]=de):de=t[55];let we;t[56]!==J?(we=s.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border bg-background","data-page-scroll-lock":"true",children:s.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children:s.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true","data-chat-area":"true",children:[J,de]})})}),t[56]=J,t[57]=we):we=t[57];let G;t[58]===Symbol.for("react.memo_cache_sentinel")?(G=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(Ns,{children:s.jsx(_S,{})})}),t[58]=G):G=t[58];let Ce;t[59]===Symbol.for("react.memo_cache_sentinel")?(Ce=s.jsx(Ns,{children:s.jsx(Xx,{})}),t[59]=Ce):Ce=t[59];let Te;t[60]!==we?(Te=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[Z,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[we,G,Ce]})]}),t[60]=we,t[61]=Te):Te=t[61];let pe;t[62]!==P||t[63]!==Te?(pe=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[P,Te]}),t[62]=P,t[63]=Te,t[64]=pe):pe=t[64];let ne;t[65]!==i||t[66]!==o||t[67]!==l?(ne=l?s.jsx(c.Suspense,{fallback:null,children:s.jsx(iC,{open:i,onOpenChange:o})}):null,t[65]=i,t[66]=o,t[67]=l,t[68]=ne):ne=t[68];let xe;return t[69]!==pe||t[70]!==ne?(xe=s.jsx(op,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[T,$,_,Y,L,pe,ne]})}),t[69]=pe,t[70]=ne,t[71]=xe):xe=t[71],xe};function lC(t){return t.isSidebarOpen}function cC(t){return t.setIsMobile}function dC(t){return t.isSettingsDialogOpen}function uC(t){return t.setSettingsDialogOpen}function fC(t){return t.isMultiRunLauncherOpen}function mC(t){return t.setMultiRunLauncherOpen}function hC(t){return t.multiRunLauncherPrefillPrompt}function pC(t){return t.isScheduledTasksDialogOpen}function gC(t){return t.isArchivePageOpen}function xC(t){return t.isUsageStatsPageOpen}function bC(t){return t.worktreesPageProjectId}function yC(t){return t.openGuestPageId}function wC(){return Pe.getState().setOpenGuestPage(null)}function vC(){return Dr(wC)}function SC(){return Pe.getState().closeMainSurfaces()}function jC(){const t=SC,e=nt.subscribe((n,r)=>{const i=!!n.currentSessionId&&n.currentSessionId!==r.currentSessionId,o=!!n.newSessionDraft?.open&&n.newSessionDraft!==r.newSessionDraft;(i||o)&&t()});return()=>{e()}}function kC(){return Pe.getState().setOpenGuestPage(null)}const bm=12,CC=[{id:"left",x:22,y:58,delay:0,radius:120,colorVar:"--status-success"},{id:"center",x:50,y:42,delay:120,radius:150,colorVar:"--primary-base"},{id:"right",x:78,y:55,delay:200,radius:130,colorVar:"--status-info"}],NC=t=>{const e=et.c(18),{isActive:n,burstKey:r,className:i,durationMs:o,bursts:l,onComplete:a}=t,d=r===void 0?0:r,u=o===void 0?900:o,m=l===void 0?CC:l,f=ct.useRef(!1);let p,y;e[0]!==n||e[1]!==a?(p=()=>{!n&&f.current&&a?.(),n&&(f.current=!0)},y=[n,a],e[0]=n,e[1]=a,e[2]=p,e[3]=y):(p=e[2],y=e[3]),ct.useEffect(p,y);let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x=Array.from({length:bm},AC),e[4]=x):x=e[4];const k=x;if(!n)return null;let w;e[5]!==i?(w=Re("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=w):w=e[6];let h;if(e[7]!==d||e[8]!==m||e[9]!==u){let j;e[11]!==d||e[12]!==u?(j=b=>{const S={"--burst-delay":`${b.delay}ms`,"--burst-x":`${b.x}%`,"--burst-y":`${b.y}%`,"--firework-color":`var(${b.colorVar})`,"--firework-duration":`${u}ms`};return s.jsx("div",{className:"firework-burst",style:S,children:k.map((C,v)=>{const M=C.x*b.radius,R=C.y*b.radius,I={"--translate-x":`${M}px`,"--translate-y":`${R}px`,"--particle-delay":`${C.delay}ms`,color:`var(${b.colorVar})`};return s.jsx("span",{className:"firework-particle",style:I},`${b.id}-${v}-${d}`)})},`${b.id}-${d}`)},e[11]=d,e[12]=u,e[13]=j):j=e[13],h=m.map(j),e[7]=d,e[8]=m,e[9]=u,e[10]=h}else h=e[10];let g;return e[14]!==d||e[15]!==w||e[16]!==h?(g=s.jsx("div",{className:w,"aria-hidden":"true","data-burst-key":d,children:h}),e[14]=d,e[15]=w,e[16]=h,e[17]=g):g=e[17],g};function AC(t,e){const n=Math.PI*2*e/bm;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const PC=t=>{const e=et.c(13);let n;e[0]!==t?(n={},e[0]=t,e[1]=n):n=e[1];const{durationMs:r}=n,i=r===void 0?3400:r;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o={isActive:!1,cycle:0},e[2]=o):o=e[2];const[l,a]=ct.useState(o),d=ct.useRef(null);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},e[3]=u):u=e[3];const m=u;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{m(),a(DC)},e[4]=f):f=e[4];const p=f;let y;e[5]!==i?(y=()=>{m(),a(IC),d.current=window.setTimeout(()=>{a(TC),d.current=null},i)},e[5]=i,e[6]=y):y=e[6];const x=y;let k,w;e[7]===Symbol.for("react.memo_cache_sentinel")?(k=()=>()=>m(),w=[m],e[7]=k,e[8]=w):(k=e[7],w=e[8]),ct.useEffect(k,w);let h;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==x?(h={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:x,dismissFireworks:p},e[9]=l.cycle,e[10]=l.isActive,e[11]=x,e[12]=h):h=e[12],h};function DC(t){return t.isActive?{...t,isActive:!1}:t}function IC(t){return{isActive:!0,cycle:t.cycle+1}}function TC(t){return t.isActive?{...t,isActive:!1}:t}const ym=c.createContext(void 0),EC=t=>{const e=et.c(10),{children:n}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=PC();let a;e[0]!==l||e[1]!==o?(a={triggerFireworks:o,dismissFireworks:l},e[0]=l,e[1]=o,e[2]=a):a=e[2];const d=a;let u;e[3]!==i||e[4]!==r?(u=s.jsx(NC,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=u):u=e[5];let m;return e[6]!==n||e[7]!==u||e[8]!==d?(m=s.jsxs(ym.Provider,{value:d,children:[n,u]}),e[6]=n,e[7]=u,e[8]=d,e[9]=m):m=e[9],m},IA=()=>{const t=c.useContext(ym);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},Oa="openchamber_requests_in_flight",wm=1e3,RC=300*1e3,ei=Math.ceil(RC/wm),MC=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Oa)==="1"}catch{return!1}},vm=()=>({enabled:!0,startedAt:Date.now(),inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],peakAgeMs:0,inFlightStarts:new Map,sampleCount:0,lastSampleAt:null,fetchWrapped:!1,originalFetch:null,sampleTimer:null});let OC=1;const BC=(t,e)=>{const n=window.__openchamberRequestsInFlight__;!n||!n.enabled||(n.inFlight+=1,n.totalStarted+=1,n.inFlight>n.peak&&(n.peak=n.inFlight),n.inFlightStarts.set(t,e))},FC=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},Sm=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),n=[];for(const r of t.inFlightStarts.values())n.push(Math.max(0,e-r));return n.sort((r,i)=>r-i),n},Ar=(t,e)=>{const n=t.length;if(n===0)return 0;if(n===1)return t[0];const r=e/100*(n-1),i=Math.floor(r),o=Math.ceil(r);return i===o?t[i]:t[i]+(t[o]-t[i])*(r-i)},_C=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t||t.fetchWrapped)return;const e=window.fetch.bind(window);t.originalFetch=e,t.fetchWrapped=!0;const n=async(r,i)=>{const o=OC++;BC(o,Date.now());try{return await e(r,i)}finally{FC(o)}};window.fetch=n},Pd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Lr=t=>{t.length>ei&&t.splice(0,t.length-ei)},LC=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=Sm(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(Ar(e,50)),t.p90Samples.push(Ar(e,90)),t.p99Samples.push(Ar(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Lr(t.samples),Lr(t.p50Samples),Lr(t.p90Samples),Lr(t.p99Samples),Lr(t.maxSamples),t.lastSampleAt=Date.now()},$C=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(LC,wm))},Dd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Id=t=>{if(!(typeof window>"u"))try{if(t){Dd(),Pd(),window.localStorage.setItem(Oa,"1"),window.__openchamberRequestsInFlight__=vm(),_C(),$C();return}window.localStorage.removeItem(Oa),Dd(),Pd(),delete window.__openchamberRequestsInFlight__}catch{}},zC=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=vm();t.startedAt=e.startedAt,t.inFlight=e.inFlight,t.peak=e.peak,t.totalStarted=e.totalStarted,t.totalSettled=e.totalSettled,t.samples=e.samples,t.p50Samples=e.p50Samples,t.p90Samples=e.p90Samples,t.p99Samples=e.p99Samples,t.maxSamples=e.maxSamples,t.peakAgeMs=e.peakAgeMs,t.inFlightStarts=e.inFlightStarts,t.sampleCount=e.sampleCount,t.lastSampleAt=e.lastSampleAt},Ba=()=>{if(typeof window>"u")return Td();const t=window.__openchamberRequestsInFlight__;if(!MC()||!t)return Td();const e=Sm(t);return{enabled:!0,startedAt:t.startedAt,durationMs:Math.max(0,Date.now()-t.startedAt),inFlight:t.inFlight,peak:t.peak,totalStarted:t.totalStarted,totalSettled:t.totalSettled,samples:t.samples.slice(),ageP50:Ar(e,50),ageP90:Ar(e,90),ageP99:Ar(e,99),ageMax:e.length>0?e[e.length-1]:0,peakAgeMs:t.peakAgeMs,p50Samples:t.p50Samples.slice(),p90Samples:t.p90Samples.slice(),p99Samples:t.p99Samples.slice(),maxSamples:t.maxSamples.slice(),sampleCount:t.sampleCount,lastSampleAt:t.lastSampleAt,windowSeconds:ei}},Td=()=>({enabled:!1,startedAt:null,durationMs:0,inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],ageP50:0,ageP90:0,ageP99:0,ageMax:0,peakAgeMs:0,p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],sampleCount:0,lastSampleAt:null,windowSeconds:ei});function WC(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const jm=t=>{if(t<1e3)return`${Math.round(t)}ms`;const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const n=Math.floor(e/60),r=Math.round(e%60);return`${n}m ${r}s`},Fa=t=>`${(t/1e3).toFixed(2)} s`,Ss=t=>{const e=et.c(8),{label:n,value:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=i):i=e[0];let o;e[1]!==n?(o=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:n}),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==r?(l=s.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==o||e[6]!==l?(a=s.jsxs("div",{className:"rounded-md p-2",style:i,children:[o,l]}),e[5]=o,e[6]=l,e[7]=a):a=e[7],a},Ed=t=>{const e=et.c(43),{title:n,snapshot:r,emptyLabel:i}=t,{t:o}=kt();let l;if(e[0]!==i||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==o||e[6]!==n){const a=r.entries.slice(0,12);let d;e[8]!==r.entries?(d=r.entries.reduce(UC,0),e[8]=r.entries,e[9]=d):d=e[9];const u=d;let m;e[10]!==n?(m=s.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:n}),e[10]=n,e[11]=m):m=e[11];let f;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==o?(f=r.startedAt?jm(r.durationMs):o("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=o,e[15]=f):f=e[15];let p;e[16]!==f?(p=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=p):p=e[17];let y;e[18]!==m||e[19]!==p?(y=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m,p]}),e[18]=m,e[19]=p,e[20]=y):y=e[20];let x;e[21]!==o?(x=o("memoryDebugPanel.metric.metrics"),e[21]=o,e[22]=x):x=e[22];let k;e[23]!==r.entries.length||e[24]!==x?(k=s.jsx(Ss,{label:x,value:r.entries.length}),e[23]=r.entries.length,e[24]=x,e[25]=k):k=e[25];let w;e[26]!==o?(w=o("memoryDebugPanel.metric.samples"),e[26]=o,e[27]=w):w=e[27];let h;e[28]!==w||e[29]!==u?(h=s.jsx(Ss,{label:w,value:u}),e[28]=w,e[29]=u,e[30]=h):h=e[30];let g;e[31]!==o?(g=o("memoryDebugPanel.metric.lastUpdate"),e[31]=o,e[32]=g):g=e[32];let j;e[33]!==r.lastUpdatedAt||e[34]!==o?(j=r.lastUpdatedAt?o("memoryDebugPanel.common.live"):o("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=o,e[35]=j):j=e[35];let b;e[36]!==g||e[37]!==j?(b=s.jsx(Ss,{label:g,value:j}),e[36]=g,e[37]=j,e[38]=b):b=e[38];let S;e[39]!==h||e[40]!==b||e[41]!==k?(S=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[k,h,b]}),e[39]=h,e[40]=b,e[41]=k,e[42]=S):S=e[42],l=s.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[y,S,a.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:i}):s.jsx(On,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:a.map(C=>s.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] p-2",style:{backgroundColor:"color-mix(in srgb, var(--surface-elevated) 88%, transparent)"},children:[s.jsx("div",{className:"typography-meta font-medium text-[var(--surface-foreground)] break-all",children:C.metric}),s.jsxs("div",{className:"mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:o("memoryDebugPanel.metric.countValue",{value:C.count})}),s.jsx("span",{children:o("memoryDebugPanel.metric.avgValue",{value:C.avg})}),s.jsx("span",{children:o("memoryDebugPanel.metric.maxValue",{value:C.max})}),s.jsx("span",{children:o("memoryDebugPanel.metric.totalValue",{value:C.total})})]})]},C.metric))})})]}),e[0]=i,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=o,e[6]=n,e[7]=l}else l=e[7];return l},Rd=t=>{const e=et.c(24),{series:n,peak:r,windowSeconds:i,ariaLabel:o,maxLabel:l}=t,a=i,d=n.reduce(HC,0),u=r>0?52/r:0;let m;e[0]!==d||e[1]!==a?(m=b=>a-d+b,e[0]=d,e[1]=a,e[2]=m):m=e[2];const f=m;let p;e[3]!==u?(p=b=>56-b*u,e[3]=u,e[4]=p):p=e[4];const y=p;let x;e[5]!==l?(x=s.jsx("span",{className:"pointer-events-none absolute left-0 top-0 typography-meta text-[var(--surface-muted-foreground)]",children:l}),e[5]=l,e[6]=x):x=e[6];const k=`0 0 ${a} 56`;let w;e[7]!==a?(w=s.jsx("line",{x1:0,y1:56,x2:a,y2:56,stroke:"var(--interactive-border)",strokeWidth:1,vectorEffect:"non-scaling-stroke"}),e[7]=a,e[8]=w):w=e[8];let h;if(e[9]!==n||e[10]!==f||e[11]!==y){let b;e[13]!==f||e[14]!==y?(b=(S,C)=>{const v=S.samples.length;if(v===0)return null;const M=S.samples.map((I,B)=>`${f(B)},${y(I).toFixed(2)}`),R=`M ${M.join(" L ")}`;return s.jsxs(c.Fragment,{children:[S.filled?s.jsx("path",{d:`M ${f(0)},56 L ${M.join(" L ")} L ${f(v-1)},56 Z`,fill:`color-mix(in srgb, ${S.color} 18%, transparent)`,stroke:"none"}):null,s.jsx("path",{d:R,fill:"none",stroke:S.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},C)},e[13]=f,e[14]=y,e[15]=b):b=e[15],h=n.map(b),e[9]=n,e[10]=f,e[11]=y,e[12]=h}else h=e[12];let g;e[16]!==o||e[17]!==k||e[18]!==w||e[19]!==h?(g=s.jsxs("svg",{viewBox:k,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":o,children:[w,h]}),e[16]=o,e[17]=k,e[18]=w,e[19]=h,e[20]=g):g=e[20];let j;return e[21]!==x||e[22]!==g?(j=s.jsxs("div",{className:"relative w-full",children:[x,g]}),e[21]=x,e[22]=g,e[23]=j):j=e[23],j},KC=t=>{const e=et.c(100),{onClose:n}=t,{t:r}=kt(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),d=nt(GC),u=Hu(qC),m=Tu(),f=bx(YC),p=Vs(QC),[y,x]=c.useState(XC),[k,w]=c.useState(JC),[h,g]=c.useState(ZC),j=[{label:"p50",current:h.ageP50,samples:h.p50Samples,color:"var(--status-success)"},{label:"p90",current:h.ageP90,samples:h.p90Samples,color:"var(--status-info)"},{label:"p99",current:h.ageP99,samples:h.p99Samples,color:"var(--status-warning)"},{label:"max",current:h.ageMax,samples:h.maxSamples,color:"var(--status-error)"}];let b;e[0]!==h.samples?(b=h.samples.reduce(eN,0),e[0]=h.samples,e[1]=b):b=e[1];const S=b,C=j.reduce(sN,0);let v;e[2]!==y.entries?(v=new Map,y.entries.forEach(je=>{v.set(je.metric,je.count)}),e[2]=y.entries,e[3]=v):v=e[3];let M;e[4]!==v?(M=v.get("ui.message_list.render")??0,e[4]=v,e[5]=M):M=e[5];let R;e[6]!==v?(R=v.get("ui.message_list.render.streaming")??0,e[6]=v,e[7]=R):R=e[7];let I;e[8]!==v?(I=v.get("ui.chat_message.render")??0,e[8]=v,e[9]=I):I=e[9];let B;e[10]!==v?(B=v.get("ui.chat_message.render.streaming")??0,e[10]=v,e[11]=B):B=e[11];let O;e[12]!==v?(O=v.get("ui.chat_message.render.static_during_stream")??0,e[12]=v,e[13]=O):O=e[13];let T;e[14]!==v?(T=v.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=v,e[15]=T):T=e[15];let $;e[16]!==M||e[17]!==R||e[18]!==I||e[19]!==B||e[20]!==O||e[21]!==T?($={messageListRender:M,messageListRenderStreaming:R,chatMessageRender:I,chatMessageRenderStreaming:B,chatMessageRenderStaticDuringStream:O,chatMessageRenderStaticOutsideActiveTurnDuringStream:T},e[16]=M,e[17]=R,e[18]=I,e[19]=B,e[20]=O,e[21]=T,e[22]=$):$=e[22];const _=$;let Y,L;e[23]===Symbol.for("react.memo_cache_sentinel")?(L=()=>{const je=()=>{x(Io()),w(To()),g(Ba())};je();const We=window.setInterval(je,500);return()=>window.clearInterval(We)},Y=[],e[23]=Y,e[24]=L):(Y=e[23],L=e[24]),c.useEffect(L,Y);let A,D;e[25]!==l?(A=()=>{if(l==="idle")return;const je=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(je)},D=[l],e[25]=l,e[26]=A,e[27]=D):(A=e[26],D=e[27]),c.useEffect(A,D);let P=0,Z=0,X=0;for(const je of Object.keys(f)){const We=f[je]??[];Z=Z+We.length;for(const tt of We)tt.role==="user"?X=X+1:tt.role==="assistant"&&(P=P+1)}let se;e[28]!==P||e[29]!==Z||e[30]!==X?(se={assistant:P,total:Z,user:X},e[28]=P,e[29]=Z,e[30]=X,e[31]=se):se=e[31];const ce=se;let re;if(e[32]!==d||e[33]!==f||e[34]!==u||e[35]!==m||e[36]!==r){let je;e[38]!==d||e[39]!==f||e[40]!==u||e[41]!==r?(je=We=>{const tt=f[We.id]??[];let it=0,rt=0;for(const ft of tt)ft.role==="user"?rt=rt+1:ft.role==="assistant"&&(it=it+1);const ot=u.get(We.id);return{id:We.id,title:We.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:it,messageCount:tt.length,userMessageCount:rt,isStreaming:ot?.isStreaming||!1,isZombie:ot?.isZombie||!1,backgroundCount:ot?.backgroundMessageCount||0,lastAccessed:ot?.lastAccessedAt||0,isCurrent:We.id===d}},e[38]=d,e[39]=f,e[40]=u,e[41]=r,e[42]=je):je=e[42],re=m.map(je).sort(nN),e[32]=d,e[33]=f,e[34]=u,e[35]=m,e[36]=r,e[37]=re}else re=e[37];const ge=re;let ae;e[43]!==f?(ae=Object.keys(f),e[43]=f,e[44]=ae):ae=e[44];const Ee=ae.length;let Se;e[45]===Symbol.for("react.memo_cache_sentinel")?(Se=async()=>{try{const je={generatedAt:new Date().toISOString(),ui:Io(),vscode:To()};await navigator.clipboard.writeText(JSON.stringify(je,null,2)),a("copied")}catch{a("error")}},e[45]=Se):Se=e[45];const me=Se,ke=wx,V="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let J;e[46]===Symbol.for("react.memo_cache_sentinel")?(J={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=J):J=e[46];let de;e[47]!==i?(de=WC(i),e[47]=i,e[48]=de):de=e[48];let we;e[49]!==de?(we=s.jsx(F,{name:de,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=de,e[50]=we):we=e[50];let G;e[51]!==r?(G=r("memoryDebugPanel.title"),e[51]=r,e[52]=G):G=e[52];let Ce;e[53]!==G?(Ce=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:G}),e[53]=G,e[54]=Ce):Ce=e[54];let Te;e[55]!==we||e[56]!==Ce?(Te=s.jsxs("div",{className:"flex items-center gap-2",children:[we,Ce]}),e[55]=we,e[56]=Ce,e[57]=Te):Te=e[57];let pe;e[58]!==i?(pe=i==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(ut,{size:"xs",variant:"ghost",onClick:me,children:s.jsx(F,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(ut,{size:"xs",variant:"ghost",onClick:()=>{uh(),x(Io()),w(To())},children:s.jsx(F,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=i,e[59]=pe):pe=e[59];let ne;e[60]!==i?(ne=i==="requests"?s.jsx(ut,{size:"xs",variant:"ghost",onClick:()=>{zC(),g(Ba())},children:s.jsx(F,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=i,e[61]=ne):ne=e[61];let xe;e[62]!==n?(xe=n?s.jsx(ut,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(F,{name:"close",className:"h-4 w-4"})}):null,e[62]=n,e[63]=xe):xe=e[63];let U;e[64]!==pe||e[65]!==ne||e[66]!==xe?(U=s.jsxs("div",{className:"flex items-center gap-1",children:[pe,ne,xe]}),e[64]=pe,e[65]=ne,e[66]=xe,e[67]=U):U=e[67];let z;e[68]!==Te||e[69]!==U?(z=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[Te,U]}),e[68]=Te,e[69]=U,e[70]=z):z=e[70];let Q;e[71]===Symbol.for("react.memo_cache_sentinel")?(Q={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=Q):Q=e[71];const ue=i==="memory"?"secondary":"ghost";let le;e[72]===Symbol.for("react.memo_cache_sentinel")?(le=()=>o("memory"),e[72]=le):le=e[72];let W;e[73]!==r?(W=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=W):W=e[74];let E;e[75]!==ue||e[76]!==W?(E=s.jsx(ut,{size:"sm",variant:ue,className:"flex-1",onClick:le,children:W}),e[75]=ue,e[76]=W,e[77]=E):E=e[77];const K=i==="streaming"?"secondary":"ghost";let te;e[78]===Symbol.for("react.memo_cache_sentinel")?(te=()=>o("streaming"),e[78]=te):te=e[78];let oe;e[79]!==r?(oe=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=oe):oe=e[80];let he;e[81]!==K||e[82]!==oe?(he=s.jsx(ut,{size:"sm",variant:K,className:"flex-1",onClick:te,children:oe}),e[81]=K,e[82]=oe,e[83]=he):he=e[83];const ie=i==="requests"?"secondary":"ghost";let Fe;e[84]===Symbol.for("react.memo_cache_sentinel")?(Fe=()=>o("requests"),e[84]=Fe):Fe=e[84];let _e;e[85]!==r?(_e=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=_e):_e=e[86];let Ae;e[87]!==ie||e[88]!==_e?(Ae=s.jsx(ut,{size:"sm",variant:ie,className:"flex-1",onClick:Fe,children:_e}),e[87]=ie,e[88]=_e,e[89]=Ae):Ae=e[89];let Me;e[90]!==E||e[91]!==he||e[92]!==Ae?(Me=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:Q,children:[E,he,Ae]}),e[90]=E,e[91]=he,e[92]=Ae,e[93]=Me):Me=e[93];const q=i==="memory"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(Ss,{label:r("memoryDebugPanel.metric.totalMessages"),value:ce.total}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${Ee} / ${ql.MAX_SESSIONS}`}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.userMessages"),value:ce.user}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.assistantMessages"),value:ce.assistant})]}),s.jsxs("div",{className:"typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2",children:[s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.viewportWindow")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.messagesValue",{count:yx()})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.zombieTimeout")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.minutesValue",{count:ql.ZOMBIE_TIMEOUT/1e3/60})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.githubTotalRequests")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:p})]})]}),s.jsxs("div",{className:"border-t border-[var(--interactive-border)] pt-2",children:[s.jsx("div",{className:"mb-1 typography-meta font-semibold text-[var(--surface-foreground)]",children:r("memoryDebugPanel.section.sessionsInMemory")}),s.jsx(On,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:ge.map(je=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:je.isCurrent?"color-mix(in srgb, var(--interactive-selection) 22%, transparent)":"color-mix(in srgb, var(--surface-muted) 35%, transparent)"},children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx("span",{className:"truncate text-[var(--surface-foreground)]",children:je.title}),je.isStreaming?s.jsx(F,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,je.isZombie?s.jsx("span",{className:"text-[var(--status-warning)]",children:"!"}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.roleMsgsValue",{assistant:je.assistantMessageCount,user:je.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:je.messageCount})}),je.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",je.backgroundCount]}):null]})]},je.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(wt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx(ut,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:m.map(rN),currentSessionId:d,cachedSessions:Object.keys(f),messageRoleCounts:ce,sessionMessageRoleCounts:ge.map(oN),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(St,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):i==="streaming"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r(l==="copied"?"memoryDebugPanel.streaming.copy.copied":l==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),s.jsx(ut,{size:"xs",variant:"outline",onClick:me,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(Ss,{label:r("memoryDebugPanel.metric.uiMetrics"),value:y.entries.length}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:k.entries.length}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.messageListRenders"),value:_.messageListRender}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:_.messageListRenderStreaming}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:_.chatMessageRender}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:_.chatMessageRenderStreaming}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:_.chatMessageRenderStaticDuringStream}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:_.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(Ed,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:y,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),k.entries.length>0?s.jsx(Ed,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:k,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(Ss,{label:r("memoryDebugPanel.requests.totalRequests"),value:`${h.totalSettled} / ${h.totalStarted}`}),s.jsx(Ss,{label:r("memoryDebugPanel.requests.tracking"),value:h.startedAt?jm(h.durationMs):r("memoryDebugPanel.common.idle")})]}),h.samples.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:r("memoryDebugPanel.requests.noSamples")}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.inFlight")}),s.jsxs("span",{children:[s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:h.inFlight}),s.jsxs("span",{className:"text-[var(--surface-muted-foreground)]",children:[" · ",r("memoryDebugPanel.requests.peak")," "]}),s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:h.peak})]})]}),s.jsx(Rd,{series:[{samples:h.samples,color:"var(--status-info)",filled:!0}],peak:S,windowSeconds:h.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:h.peak}),maxLabel:`${S}`}),s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.duration")}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:Fa(h.peakAgeMs)})]}),s.jsx(Rd,{series:j.map(iN),peak:C,windowSeconds:h.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:Fa(C)}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:j.map(aN)}),s.jsxs("div",{className:"flex items-center justify-between typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r("memoryDebugPanel.requests.windowHint",{seconds:h.windowSeconds})}),s.jsx("span",{children:r("memoryDebugPanel.requests.now")})]})]})]});let Ne;return e[94]!==ke||e[95]!==J||e[96]!==z||e[97]!==Me||e[98]!==q?(Ne=s.jsxs(ke,{className:V,style:J,children:[z,Me,q]}),e[94]=ke,e[95]=J,e[96]=z,e[97]=Me,e[98]=q,e[99]=Ne):Ne=e[99],Ne},VC=KC;function UC(t,e){return t+e.count}function HC(t,e){return Math.max(t,e.samples.length)}function GC(t){return t.currentSessionId}function qC(t){return t.sessionMemoryState}function YC(t){return t.message}function QC(t){return t.totalRequestCount}function XC(){return Io()}function JC(){return To()}function ZC(){return Ba()}function eN(t,e){return Math.max(t,e)}function tN(t,e){return Math.max(t,e)}function sN(t,e){return e.samples.reduce(tN,t)}function nN(t,e){return e.lastAccessed-t.lastAccessed}function rN(t){return{id:t.id,title:t.title}}function oN(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function iN(t){return{samples:t.samples,color:t.color}}function aN(t){return s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:t.color}}),s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:t.label}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:Fa(t.current)})]},t.label)}const lN=()=>{if(typeof document>"u")return"";const t=document.activeElement;if(t instanceof HTMLTextAreaElement)return t.value.slice(t.selectionStart??0,t.selectionEnd??0);if(t instanceof HTMLInputElement){const e=t.type?.toLowerCase()??"text";if(["text","search","url","tel","password"].includes(e))return t.value.slice(t.selectionStart??0,t.selectionEnd??0)}return t instanceof HTMLElement&&t.isContentEditable?t.ownerDocument.defaultView?.getSelection?.()?.toString()??"":""},cN=async()=>{const t=lN()||window.getSelection()?.toString()||"";if(!t.trim())return!1;try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(t),!0}catch{}return document.execCommand("copy")},Md="openchamber:menu-action",Hi="openchamber:check-for-updates",dN=t=>{const e=nt(h=>h.openNewSessionDraft),n=Pe(h=>h.toggleCommandPalette),r=Pe(h=>h.setCommandPaletteOpen),i=Pe(h=>h.toggleHelpDialog),o=Pe(h=>h.toggleSidebar),l=Pe(h=>h.setSessionSwitcherOpen),a=Pe(h=>h.setSettingsDialogOpen),d=Pe(h=>h.setAboutDialogOpen),u=Ur(h=>h.checkForUpdates),{setThemeMode:m}=Kn(),f=c.useRef(!1),p=c.useCallback(()=>{f.current||(f.current=!0,u().then(()=>{const{available:h,error:g}=Ur.getState();if(g){ze.error("Failed to check for updates",{description:g});return}h||ze.success("You are on the latest version")}).finally(()=>{f.current=!1}))},[u]),y=c.useCallback(()=>{mn.requestDirectoryDialog()},[]),x=c.useCallback(h=>{const g=vx();if(g.length===0)return;const j=nt.getState().currentSessionId,b=g.findIndex(v=>v.id===j);let S=h>0?0:g.length-1;b>=0&&(S=(b+h+g.length)%g.length);const C=g[S];C&&(l(!1),nt.getState().setCurrentSession(C.id))},[l]),k=c.useCallback(h=>{const{activeProjectId:g,projects:j,setActiveProject:b}=Gt.getState();if(j.length===0)return;const S=j.findIndex(M=>M.id===g);let C=h>0?0:j.length-1;S>=0&&(C=(S+h+j.length)%j.length);const v=j[C];v&&b(v.id)},[]),w=c.useCallback(h=>{switch(h){case"about":d(!0);break;case"settings":a(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const g=nt.getState(),j=os.getState().currentDirectory;e(g.currentSessionId&&j?{directoryOverride:j}:void 0)}break;case"new-worktree-session":l(!1),Bu();break;case"change-workspace":y();break;case"toggle-right-sidebar":{const g=os.getState().currentDirectory;if(!g)break;const j=Pe.getState(),b=er(g),S=j.contextPanelByDirectory[b];S?.isOpen?j.closeContextPanel(b):S?.activeTabId?j.setActiveContextPanelTab(b,S.activeTabId):j.openContextSurface(b,"git");break}case"open-right-sidebar-git":{const g=os.getState().currentDirectory;if(!g)break;Pe.getState().openContextSurface(er(g),"git");break}case"open-right-sidebar-files":{const g=os.getState().currentDirectory;if(!g)break;Pe.getState().openContextSurface(er(g),"file");break}case"toggle-terminal":{const g=os.getState().currentDirectory;if(!g)break;Pe.getState().openContextSurface(er(g),"terminal");break}case"toggle-terminal-expanded":{const g=os.getState().currentDirectory;if(!g)break;const j=er(g),b=Pe.getState(),S=b.contextPanelByDirectory[j];(S?.isOpen?S.tabs.find(v=>v.id===S.activeTabId)?.mode:null)!=="terminal"&&b.openContextSurface(j,"terminal"),b.toggleContextPanelExpanded(j);break}case"copy":{const g=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(g)||cN();break}case"theme-light":m("light");break;case"theme-dark":m("dark");break;case"theme-system":m("system");break;case"add-selection-to-chat":Sx();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":os.getState().goBack();break;case"go-forward":os.getState().goForward();break;case"previous-session":x(-1);break;case"next-session":x(1);break;case"previous-project":k(-1);break;case"next-project":k(1);break;case"help-dialog":i();break;case"download-logs":{Fu().catch(()=>{ze.error("Failed to collect OpenCode status")});break}}},[y,k,x,t,e,d,l,r,a,m,n,i,o]);c.useEffect(()=>{const h=j=>{const b=j.detail;b&&w(b)},g=()=>{p()};return window.addEventListener(Md,h),window.addEventListener(Hi,g),()=>{window.removeEventListener(Md,h),window.removeEventListener(Hi,g)}},[w,p]),c.useEffect(()=>{if(typeof window>"u")return;const g=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof g!="function")return;let j=null,b=null;return g("openchamber:menu-action",S=>{const C=S?.payload;typeof C=="string"&&w(C)}).then(S=>{j=S}).catch(()=>{}),g("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(Hi))}).then(S=>{b=S}).catch(()=>{}),()=>{(async()=>{try{const C=j?.();C instanceof Promise&&await C}catch{}try{const C=b?.();C instanceof Promise&&await C}catch{}})()}},[w])},uN="openchamber:tray-action",fN=5e3,mN=500,hN=20,Od=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Bd=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,km=t=>{const e=t.action.trim()||"Permission",n=t.resources.find(r=>r.trim());return n?`${e}: ${n}`:e},Cm=t=>t.title.trim()||"Question",pN=(t,e)=>sl(t,e,Jr.getState().ids,Qa.getState().rankById),gN=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},xN=(t,e,n,r,i)=>{if(!t)return"";const o=lu(n,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||gN(t),d=Eo(t);let u=d&&i.get(d)||"";if(!u){for(const[m,f]of Mn.getState().directories)if(Eo(m)===d){u=f.status?.current??"";break}}if(!u)for(const m of r.values()){const f=m.find(p=>Eo(p.path)===d);if(f?.branch){u=f.branch;break}}return u?`${a} · ${u}`:a},bN=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=yr.getState(),r=n==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const i=new Map(t.map(l=>[l.providerId,l])),o=[];for(const l of kx){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const d=[];for(const[m,f]of Object.entries(a.usage?.windows??{})){const p=r==="remaining"?f.remainingPercent:f.usedPercent;d.push({label:Nx(m),value:Cx(f.valueLabel,p)})}const u=!a.ok&&a.error?a.error:d.length===0?"No rate limits reported":null;o.push({provider:l.name,rows:d,status:u})}return{mode:r,groups:o}},yN=async()=>{try{if(ti())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=En();if(e&&jl(e,t))return"Local OpenChamber";const r=(await Wd()).hosts.find(i=>e?jl(e,fh(i)):!1);return r?.label?.trim()?Kd(r.label.trim()):"Instance"}catch{return""}},wN=()=>{const t=new Map,e=new Map,n=[],r=new Map;let i;try{i=da()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[o,l]of i.children.entries()){const a=l.getState();a.vcs?.branch&&e.set(Eo(o)??o,a.vcs.branch);for(const d of a.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(a.session_status??{})){const m=u?.type,f=m==="busy"?"busy":m==="retry"?"retry":"idle",p=t.get(d);(!p||p==="idle")&&t.set(d,f)}for(const[d,u]of Object.entries(a.permission??{}))for(const m of u??[]){if(!m?.id)continue;const f=m.sessionID||d;n.push({kind:"permission",id:m.id,sessionId:f,sessionTitle:"",label:km(m),directory:o})}for(const[d,u]of Object.entries(a.form??{}))for(const m of u??[]){if(!m?.id)continue;const f=m.sessionID||d;n.push({kind:"form",id:m.id,sessionId:f,sessionTitle:"",label:Cm(m),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},vN=(t,e)=>{const n=Za.getState().index.session,r=js.getState().activeSessions,i=new Map;for(const g of r)if(g?.id&&g.parentID){const j=i.get(g.parentID)??[];j.push(g.id),i.set(g.parentID,j)}const o=g=>{const j=[],b=[...i.get(g)??[]],S=new Set;for(;b.length;){const C=b.pop();S.has(C)||(S.add(C),j.push(C),b.push(...i.get(C)??[]))}return j},l=Pe.getState();let a=0;if(l.dockBadgeEnabled)for(const g of r){if(!g?.id||g.parentID)continue;let j=n.unseenCount[g.id]??0;j===0&&l.notifyOnSubtasks&&(j=o(g.id).reduce((b,S)=>b+(n.unseenCount[S]??0),0)),j>0&&(a+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:a};const d=wN(),u=new Map(d.titleById);for(const g of r)g?.id&&g.title&&u.set(g.id,g.title);const m=ri.getState().statusById,f=g=>{const j=d.statusById.get(g);return j&&j!=="idle"?j:m.get(g)?.status.type??j??"idle"},p=g=>{const j=g.map(b=>f(b));return j.includes("busy")?"busy":j.includes("retry")?"retry":"idle"},y=Gt.getState().projects,x=nt.getState().availableWorktreesByProject,k=r.filter(g=>g?.id&&!g.parentID).slice().sort(pN).slice(0,hN).map(g=>{const j=[g.id,...o(g.id)],b=Ps(g)??"";return{id:g.id,title:g.title||"Untitled session",status:p(j),branch:b?d.branchByDirectory.get(b)??"":"",unseen:j.reduce((S,C)=>S+(n.unseenCount[C]??0),0),hasError:j.some(S=>n.unseenHasError[S]??!1),directory:b,subtitle:xN(b,g,y,x,d.branchByDirectory)}}),w=d.approvals.map(g=>({...g,sessionTitle:u.get(g.sessionId)||""})),h=new Set(w.map(g=>g.id));for(const[g,j]of el.getState().bySession){const b=u.get(g)||"";for(const S of j.permissions)h.has(S.id)||(h.add(S.id),w.push({kind:"permission",id:S.id,sessionId:g,sessionTitle:b,label:km(S),directory:j.directory}));for(const S of j.forms)h.has(S.id)||(h.add(S.id),w.push({kind:"form",id:S.id,sessionId:g,sessionTitle:b,label:Cm(S),directory:j.directory}))}return{sessions:k,approvals:w,instanceName:t,usage:bN(),dockBadgeCount:a}},SN=()=>{c.useEffect(()=>{if(!Od()||!Qr())return;const t=Bd();let e=!1,n="",r=null,i="";const o=()=>{if(e)return;const v=vN(i,t),M=JSON.stringify(v);M!==n&&(n=M,zn("desktop_tray_update",v))},l=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,o()},mN))},a=Za.subscribe(()=>l()),d=js.subscribe(()=>l()),u=Pe.subscribe((v,M)=>{(v.dockBadgeEnabled!==M.dockBadgeEnabled||v.notifyOnSubtasks!==M.notifyOnSubtasks)&&l()}),m=()=>{e=!0,r!==null&&window.clearTimeout(r),a(),d(),u()};if(!t)return o(),m;yN().then(v=>{e||(i=v,o())});const f=new Map,p=()=>{if(e)return;let v;try{v=da()}catch{return}const M=new Set;for(const[R,I]of v.children.entries())M.add(R),f.has(R)||f.set(R,I.subscribe(()=>l()));for(const[R,I]of f)M.has(R)||(I(),f.delete(R))};let y=null;try{y=da().subscribeRegistry(()=>{p(),l()})}catch{}p();const x=Gt.subscribe(()=>l()),k=nt.subscribe(()=>l()),w=Mn.subscribe(()=>l()),h=ri.subscribe(()=>l()),g=el.subscribe(()=>l()),j=Qa.subscribe(()=>l()),b=Jr.subscribe(()=>l()),S=yr.subscribe(()=>l());yr.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:v,results:M}=yr.getState();v.length>0&&v.some(I=>!M.some(B=>B.providerId===I))&&yr.getState().fetchQuotas(v)});const C=window.setInterval(()=>{p(),o()},fN);return o(),()=>{m(),window.clearInterval(C),x(),k(),w(),h(),g(),j(),b(),S(),y?.();for(const v of f.values())v();f.clear()}},[]),c.useEffect(()=>{if(!Od()||!Bd()||!Qr())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{i.type==="respond-permission"&&jx(i.sessionId,i.id,i.response).catch(()=>{ze.error("Failed to respond to permission request")})};let r=null;return e(uN,i=>{const o=i?.payload;!o||typeof o!="object"||typeof o.type!="string"||n(o)}).then(i=>{r=i}).catch(()=>{}),()=>{try{const i=r?.();i instanceof Promise&&i.catch(()=>{})}catch{}}},[])},jN=30*6e4,kN=(t,e,n=jN)=>{const r=new Map;for(const[i,o]of Object.entries(t.sessions)){if(o.status!=="busy"&&o.status!=="retry"||t.serverTime-o.lastUpdateAt>n||e.isKnown(i))continue;const l=e.resolveDirectory(i);if(!l)continue;const a=r.get(l)??[];a.push({type:"session.status",properties:{sessionID:i,status:{type:"busy"}}}),r.set(l,a)}return r};let $r=null;const CN=()=>{if($r)return $r;const t=Qt();return $r=(async()=>{const e=await fn.getHostSessionStatusSnapshot();if(!e||Qt()!==t)return;const n=ri.getState(),r=js.getState().entityById,i=kN(e,{isKnown:l=>n.statusById.has(l)||n.observedById.has(l),resolveDirectory:l=>{const a=r.get(l);return a?Ps(a):null}});for(const[l,a]of i)Ax(l,a);const o=[];for(const[l,a]of Object.entries(e.pending??{})){const d=r.get(l),u=d?Ps(d):null;u&&o.push({sessionId:l,directory:u,permissions:a.permissions,forms:a.forms})}Px(o)})().finally(()=>{$r=null}),$r},NN=45e3,AN=[1e3,2e3,4e3],PN=(t,e,n=window.setTimeout.bind(window),r=window.clearTimeout.bind(window))=>{let i=!1,o,l=0,a=!1;const d=async u=>{const m=await u().catch(()=>!1);if(i)return;a||=m;const f=a?void 0:AN[l];f!==void 0&&(l+=1),o=n(()=>{o=void 0,d(e)},f??NN)};return d(t),()=>{i=!0,o!==void 0&&r(o)}},DN=t=>{const e=et.c(3);let n,r;e[0]!==t?(n=()=>{if(!t)return;const i=IN;let o=i();const l=Dr(()=>{o(),o=i()});return()=>{l(),o()}},r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),c.useEffect(n,r)};function IN(){const t=Qt();let e=!0;const n=async i=>(i?await Dx(Ko()):await ci(),!e||Qt()!==t?!1:(CN(),js.getState().status==="ready")),r=PN(()=>n(!0),()=>n(!1));return()=>{e=!1,r()}}const TN=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,EN=t=>{const e=et.c(3),n=t?.enabled??!0;let r,i;e[0]!==n?(r=()=>{if(!(!n||vn()||!La()||!globalThis.window))return Hn(RN)},i=[n],e[0]=n,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function RN(t){if(t.type!=="notification")return;const e=Pe.getState();if(!e.nativeNotificationsEnabled||e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&TN())return;zd()?.notifications?.notifyAgentCompletion(t.payload)}const MN=6e4,ON=t=>{const e=et.c(10),n=Pe(BN),r=Ix(FN),o=ip(t)?.path??null;let l,a;e[0]!==n||e[1]!==r||e[2]!==o?(l=()=>{n&&r(o,{maxAgeMs:MN})},a=[n,r,o],e[0]=n,e[1]=r,e[2]=o,e[3]=l,e[4]=a):(l=e[3],a=e[4]),c.useEffect(l,a);let d,u;e[5]!==n||e[6]!==r||e[7]!==o?(d=()=>{if(n)return Hn(m=>{m.type==="agent-memory-changed"&&r(o)})},u=[n,r,o],e[5]=n,e[6]=r,e[7]=o,e[8]=d,e[9]=u):(d=e[8],u=e[9]),c.useEffect(d,u)};function BN(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function FN(t){return t.load}const _N=()=>{const t=et.c(4),{t:e}=kt(),n=Pe(LN);let r,i;t[0]!==n||t[1]!==e?(r=()=>Hn(o=>{o.type==="browser-provider-reset"&&(n("builtin"),ze.info(e("settings.openchamber.tools.browserProvider.toast.reset",{name:o.guestName})))}),i=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i)};function LN(t){return t.setBrowserProvider}const Fd="pwa-install-toast-shown",_d="pwa-install-toast-dismissed",$N=()=>{const t=et.c(6),{browserTab:e}=ap(),{t:n}=kt(),r=c.useRef(n);let i,o;t[0]!==n?(i=()=>{r.current=n},o=[n],t[0]=n,t[1]=i,t[2]=o):(i=t[1],o=t[2]),c.useEffect(i,o);let l,a;t[3]!==e?(l=()=>{if(typeof window>"u"||!La()||!e)return;let d=null,u=null;const m=()=>{u!==null&&(ze.dismiss(u),u=null)},f=async()=>{if(!d)return;const x=d;d=null,m(),await x.prompt();const{outcome:k}=await x.userChoice;k==="accepted"&&ze.success(r.current("pwa.installPrompt.started"))},p=x=>{const k=x;if(typeof k.prompt!="function")return;k.preventDefault(),d=k;const w=$o(),h=mh();lp({dismissed:w.getItem(_d),sessionShown:h.getItem(Fd),hasActiveToast:u!==null})&&(h.setItem(Fd,"true"),u=ze.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{f()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{$o().setItem(_d,"true"),m()}}}))},y=()=>{d=null,m(),ze.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",p),window.addEventListener("appinstalled",y),()=>{m(),window.removeEventListener("beforeinstallprompt",p),window.removeEventListener("appinstalled",y)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},zN=({open:t,onOpenChange:e})=>{const{t:n}=kt(),r=!1,[i,o]=c.useState(null),[l,a]=c.useState(null),[d,u]=c.useState(!1),[m,f]=c.useState(!1),[p,y]=c.useState(null),[x,k]=c.useState(!1);c.useCallback(async()=>{},[p,d,r,n]),c.useEffect(()=>{if(!t)return;(async()=>{try{const g=await ws("/api/system/info");if(g.ok){const j=await g.json();if(typeof j.openchamberVersion=="string"&&j.openchamberVersion.trim()){o(j.openchamberVersion);return}}}catch{}o(await Tx())})()},[t]),c.useEffect(()=>{if(!t)return;let h=!1;return(async()=>{try{const j=await ws("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!j.ok)return;const b=await j.json().catch(()=>null),S=typeof b?.currentVersion=="string"?b.currentVersion.trim():"";!h&&S&&a(S)}catch{}})(),()=>{h=!0}},[t]),c.useEffect(()=>{{y(null),k(!1);return}},[t,r]);const w=i;return s.jsx(Ds,{open:t,onOpenChange:e,children:s.jsx(Is,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(Eu,{width:64,height:64}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"OpenChamber"}),s.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[w&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:w})}),l&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:l})})]})]}),r,s.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-4",children:[s.jsxs("a",{href:"https://github.com/openchamber/openchamber",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(F,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://discord.gg/ZYRSdnwwKA",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(F,{name:"discord-fill",className:"h-4 w-4"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:"https://x.com/openchamber_dev",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(F,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:n("aboutDialog.footerNote")})]})})})},_a="project-config-invalid",WN=()=>{const t=et.c(9),{t:e}=kt(),n=Ut(KN);let r;t[0]!==n?(r=p=>p.projectConfigErrors[n],t[0]=n,t[1]=r):r=t[1];const i=Ut(r),[o,l]=ct.useState(!1);let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const p=Ut.getState(),y=p.activeDirectoryKey;l(!0),Promise.all([p.loadProviders({directory:y,source:"projectConfigError:retry"}),p.loadAgents({directory:y,source:"projectConfigError:retry"})]).finally(()=>l(!1))},t[2]=a):a=t[2];const d=a;let u,m;t[3]!==i||t[4]!==o||t[5]!==e?(u=()=>{if(!i){ze.dismiss(_a);return}ze.error(e("projectConfigError.toast.title"),{id:_a,duration:1/0,description:s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx("span",{className:"break-all font-mono typography-meta",children:i.path??e("projectConfigError.toast.unknownFile")}),i.message&&s.jsx("span",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta",children:i.message}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(o?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick:p=>{p.preventDefault(),o||d()}}})},m=[i,o,d,e],t[3]=i,t[4]=o,t[5]=e,t[6]=u,t[7]=m):(u=t[6],m=t[7]),ct.useEffect(u,m);let f;return t[8]===Symbol.for("react.memo_cache_sentinel")?(f=[],t[8]=f):f=t[8],ct.useEffect(UN,f),null};function KN(t){return t.activeDirectoryKey}function VN(){ze.dismiss(_a)}function UN(){return VN}const HN="\x1B",GN=new RegExp(`${HN}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Do=ur().transform(t=>t.replace(GN,"").trim()).nullish(),qN=nc({isOpenCodeReady:rc().optional(),openCodeRunning:rc().optional(),lastOpenCodeError:Do,opencodeBinaryResolved:Do,lastOpenCodeLaunchDiagnostics:nc({sourceBinary:Do,binary:Do}).nullish()}),YN=async(t,e=ws)=>{const n=await e("/health",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!n.ok)throw new Error(`Startup diagnostics request failed (${n.status})`);const r=qN.parse(await n.json());return r.isOpenCodeReady===!0||r.isOpenCodeReady!==!1&&r.openCodeRunning!==!1?null:{error:r.lastOpenCodeError||null,binary:r.lastOpenCodeLaunchDiagnostics?.sourceBinary||r.opencodeBinaryResolved||r.lastOpenCodeLaunchDiagnostics?.binary||null}},QN=(t,e)=>{if(t)return"startup.initRecovery.openCodeUnavailable";switch(e?.step){case"serverUnreachable":return"startup.initRecovery.serverUnreachable";case"openCodeUnavailable":return"startup.initRecovery.openCodeUnavailable";case"loadAgents":return"startup.initRecovery.loadAgentsFailed";default:return"startup.initRecovery.unexpected"}},Ld=Gn(()=>jn(()=>import("./OnboardingScreen-CBx6cXPP.js"),__vite__mapDeps([152,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(t=>({default:t.OnboardingScreen}))),XN=()=>{const t=et.c(3),e=Pe(nA),n=Pe(rA);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(zN,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},JN=t=>{const e=et.c(33),{onRetry:n,isRetrying:r}=t,{t:i}=kt(),[o,l]=c.useState(null);let a,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const S=new AbortController,C=Qt(),v=setTimeout(()=>S.abort(),5e3);return YN(S.signal).then(M=>{!S.signal.aborted&&Qt()===C&&l(M)}).catch(oA).finally(()=>clearTimeout(v)),()=>{S.abort(),clearTimeout(v)}},d=[],e[0]=a,e[1]=d):(a=e[0],d=e[1]),c.useEffect(a,d);const u=Ut(iA),m=o?null:u?.message??null;let f;e[2]!==i?(f=i("startup.initRecovery.title"),e[2]=i,e[3]=f):f=e[3];let p;e[4]!==f?(p=s.jsx("h1",{className:"typography-title text-foreground",children:f}),e[4]=f,e[5]=p):p=e[5];let y;e[6]!==o||e[7]!==u||e[8]!==i?(y=i(QN(o,u)),e[6]=o,e[7]=u,e[8]=i,e[9]=y):y=e[9];let x;e[10]!==y?(x=s.jsx("p",{className:"typography-body text-muted-foreground",children:y}),e[10]=y,e[11]=x):x=e[11];let k;e[12]!==p||e[13]!==x?(k=s.jsxs("div",{className:"flex flex-col gap-2",children:[p,x]}),e[12]=p,e[13]=x,e[14]=k):k=e[14];let w;e[15]!==m||e[16]!==i?(w=m&&s.jsxs("dl",{className:"w-full min-w-0 text-left","aria-live":"polite",children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.lastError")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono typography-meta text-muted-foreground",children:m})]}),e[15]=m,e[16]=i,e[17]=w):w=e[17];let h;e[18]!==o||e[19]!==i?(h=o&&s.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-left","aria-live":"polite",children:[o.binary&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.binary")}),s.jsx("dd",{className:"break-all font-mono typography-meta",children:o.binary})]}),o.error&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.error")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta text-[var(--status-error)]",children:o.error})]})]}),e[18]=o,e[19]=i,e[20]=h):h=e[20];let g;e[21]!==r||e[22]!==i?(g=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[21]=r,e[22]=i,e[23]=g):g=e[23];let j;e[24]!==r||e[25]!==n||e[26]!==g?(j=s.jsx(ut,{type:"button",onClick:n,disabled:r,children:g}),e[24]=r,e[25]=n,e[26]=g,e[27]=j):j=e[27];let b;return e[28]!==j||e[29]!==k||e[30]!==w||e[31]!==h?(b=s.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:s.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[k,w,h,j]})}),e[28]=j,e[29]=k,e[30]=w,e[31]=h,e[32]=b):b=e[32],b},$d=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",ZN=()=>{if(typeof window>"u"||!jb())return null;const t=new URLSearchParams(window.location.search),e=t.get("sessionId"),n=typeof e=="string"?e.trim():"";if(!n)return null;const r=t.get("directory"),i=typeof r=="string"&&r.trim().length>0?r.trim():null;return{sessionId:n,directory:i,readOnly:t.get("readOnly")==="1"||t.get("readOnly")==="true",allowPromptingSubagentSessions:t.has("allowPromptingSubagentSessions")?t.get("allowPromptingSubagentSessions")==="1":void 0}},eA=t=>{const e=et.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=os(aA),l=nt(lA),a=nt(cA),d=Fx(),u=c.useRef(null);let m;e[0]!==n.directory?(m=$d(n.directory),e[0]=n.directory,e[1]=m):m=e[1];const f=m;let p;e[2]!==o?(p=$d(o),e[2]=o,e[3]=p):p=e[3];const y=p;let x,k;if(e[4]!==y||e[5]!==l||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==d?(x=()=>{if(r||f&&y!==f)return;const S=`${f}
|
|
896
|
-
${n.sessionId}`;u.current===S&&l||(u.current=S,a(n.sessionId,n.directory),d.ensureSessionRenderable(n.sessionId,!0))},k=[y,l,n.directory,n.sessionId,f,r,a,d],e[4]=y,e[5]=l,e[6]=n.directory,e[7]=n.sessionId,e[8]=f,e[9]=r,e[10]=a,e[11]=d,e[12]=x,e[13]=k):(x=e[12],k=e[13]),c.useEffect(x,k),f&&y!==f)return null;let w;e[14]!==i?(w=s.jsx(Ju,{embeddedBackgroundWorkEnabled:i}),e[14]=i,e[15]=w):w=e[15];let h;e[16]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx(au,{}),e[16]=h):h=e[16];let g;e[17]!==i||e[18]!==n.allowPromptingSubagentSessions||e[19]!==n.readOnly?(g=s.jsx(iu,{active:i,messagesEnabled:!0,readOnly:n.readOnly,initialAllowPromptingSubagentSessions:n.allowPromptingSubagentSessions}),e[17]=i,e[18]=n.allowPromptingSubagentSessions,e[19]=n.readOnly,e[20]=g):g=e[20];let j;e[21]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(Zu,{}),e[21]=j):j=e[21];let b;return e[22]!==w||e[23]!==g?(b=s.jsxs(s.Fragment,{children:[w,h,g,j]}),e[22]=w,e[23]=g,e[24]=b):b=e[24],b};function tA({apis:t}){c.useEffect(()=>{hh("App:mounted"),ph()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=Ut(V=>V.initializeApp),n=Ut(V=>V.isInitialized),r=Ut(V=>V.isConnected),i=Ut(V=>V.providers.length),o=Ut(V=>V.agents.length),l=Ut(V=>V.loadProviders),a=Ut(V=>V.loadAgents),d=nt(V=>V.error),u=nt(V=>V.clearError),m=os(V=>V.currentDirectory),f=os(V=>V.setDirectory),p=os(V=>V.isSwitchingDirectory),[y,x]=c.useState(!1),k=Rn(V=>V.refreshStatus),w=na(V=>V.refreshStatus),[h,g]=c.useState(()=>t.runtime.isVSCode),[j,b]=c.useState(!1),[S,C]=c.useState(!1),[v,M]=c.useState(0),[R,I]=c.useState(0),[B,O]=c.useState(!1),T=Pe(V=>V.wideChatLayoutEnabled),$=Pe(V=>V.mobileKeyboardMode),_=c.useMemo(()=>vn(),[]),Y=Va(V=>V.setPlanModeEnabled),[L,A]=c.useState(()=>kl()),[D,P]=c.useState(()=>{const V=Cl();return V!==null?Nl({isDesktopShell:!0,bootOutcome:V}):null}),Z=c.useRef(!1),X=c.useMemo(()=>ZN(),[]),se=!X||j;c.useEffect(()=>(Al(y),Id(y),()=>{Al(!1),Id(!1)}),[y]),c.useEffect(()=>{gh($)},[$]),c.useEffect(()=>{g(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>Dr(V=>{dp(V),I(J=>J+1),C(!1),M(J=>J+1)}),[]);const ce=Yl(V=>{const J=Qt();return Object.values(V.runsByOriginalSessionID).filter(de=>de.status==="running"&&de.runtimeKey===J).map(de=>`${de.originalSessionID}:${de.phase}:${de.lastForwardedMessageID??""}:${de.expectedAssistantParentID??""}`).sort().join("|")});c.useEffect(()=>{if(X)return;const V=Qt(),J=Object.values(Yl.getState().runsByOriginalSessionID).filter(de=>de.status==="running"&&de.runtimeKey===V);for(const de of J)Ex(de.originalSessionID)},[ce,X,R]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",T),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[T]),c.useEffect(()=>(Pl(t),()=>Pl(null)),[t]),c.useEffect(()=>{X||(k(t.github,{force:!0}),w(t.linear,{force:!0}))},[t.github,t.linear,X,r,k,w,R]),Rx();const re=L==="valid",ge=D?.screen==="main";c.useEffect(()=>{if(!xh({isDesktopShell:_,isInitialized:n,bootOutcomeKnown:re,bootViewIsMain:ge}))return;const V=setTimeout(()=>{const J=document.getElementById("initial-loading");J&&(J.classList.add("fade-out"),setTimeout(()=>{J.remove()},300))},150);return()=>clearTimeout(V)},[_,n,re,ge]),c.useEffect(()=>{if(!_||L!=="malformed")return;const V=document.getElementById("initial-loading");V&&(V.textContent="Desktop startup failed — please restart the app.")},[_,L]),c.useEffect(()=>{if(_)return;const V=setTimeout(()=>{const J=document.getElementById("initial-loading");J&&!n&&(J.classList.add("fade-out"),setTimeout(()=>{J.remove()},300))},5e3);return()=>clearTimeout(V)},[_,n]),c.useEffect(()=>{let V=!1;return(async()=>{const de=await ws("/health",{method:"GET"}).catch(()=>null);if(!de||!de.ok||V)return;const we=await de.json().catch(()=>null);if(!we||V)return;const G=we.planModeExperimentalEnabled;Y(G===!0||G===1||G==="1"||G==="true")})(),()=>{V=!0}},[Y]),c.useEffect(()=>{h||e()},[e,h]),c.useEffect(()=>{if(h||n)return;let V=!0,J,de=0;const we=10,G=1e3,Ce=async()=>{if(!V)return;if(de>=we){C(!0);return}const Te=Ut.getState();if(Te.isInitialized){C(!1);return}de+=1,await Te.initializeApp();const pe=Ut.getState();if(!V)return;if(pe.isInitialized){C(!1);return}if(de>=we){C(!0);return}const ne=Math.min(G*Math.pow(2,de-1),16e3);J=setTimeout(Ce,ne)};return J=setTimeout(Ce,G),()=>{V=!1,J&&clearTimeout(J)}},[v,n,h]),c.useEffect(()=>{n&&C(!1)},[n]),c.useEffect(()=>{if(!S)return;const V=document.getElementById("initial-loading");V&&(V.classList.add("fade-out"),setTimeout(()=>{V.remove()},300))},[S]),c.useEffect(()=>{if(h||!r||i>0&&o>0)return;let V=!0,J=0;const de=15,we=async()=>{const Ce=Ut.getState();if(!(Ce.providers.length>0&&Ce.agents.length>0))try{Ce.providers.length===0&&await l({source:"startupRecovery"}),Ut.getState().agents.length===0&&await a({source:"startupRecovery"})}catch{}};we();const G=setInterval(()=>{if(V){if(++J>=de){clearInterval(G);return}we()}},2e3);return()=>{V=!1,clearInterval(G)}},[r,h,a,l,i,o]),c.useEffect(()=>{p||h||r&&fn.setDirectory(m)},[m,p,r,h]),c.useEffect(()=>{if(!X||typeof window>"u")return;const V=we=>{b(we?.visible===!0)},J=we=>{if(we.origin!==window.location.origin||we.source!==window.parent)return;const G=we.data;G?.type===cf&&V(G.payload)},de=window;return de.__openchamberSetEmbeddedVisibility=V,window.addEventListener("message",J),Sb(),()=>{window.removeEventListener("message",J),de.__openchamberSetEmbeddedVisibility===V&&delete de.__openchamberSetEmbeddedVisibility}},[X]),c.useEffect(()=>{!X?.directory||h||m!==X.directory&&f(X.directory,{showOverlay:!1})},[m,X,h,f]),c.useEffect(()=>{if(!X||typeof window>"u")return;const V=J=>{J.storageArea===window.localStorage&&J.key==="ui-store"&&Pe.persist.rehydrate()};return window.addEventListener("storage",V),()=>{window.removeEventListener("storage",V)}},[X]),c.useEffect(()=>{if(typeof window>"u")return;const V=J=>{const de=J.detail,we=typeof de?.sessionId=="string"?de.sessionId.trim():"";if(!we)return;const G=typeof de?.directory=="string"&&de.directory.trim().length>0?de.directory.trim():null;nt.getState().setCurrentSession(we,G)};return window.addEventListener("openchamber:open-session",V),()=>window.removeEventListener("openchamber:open-session",V)},[]),c.useEffect(()=>{if(typeof window>"u")return;const V=()=>{zn("desktop_open_draft_mini_chat_window",{directory:"",projectId:null})};return window.addEventListener("openchamber:open-mini-chat",V),()=>window.removeEventListener("openchamber:open-mini-chat",V)},[]),c.useEffect(()=>{if(typeof window>"u")return;const V=()=>{const J=nt.getState().currentSessionId;J&&Ru(J)};return window.addEventListener("focus",V),()=>window.removeEventListener("focus",V)},[]),c.useEffect(()=>{if(typeof window>"u")return;const V=J=>{const de=J.detail,we=typeof de?.directory=="string"&&de.directory.trim().length>0?de.directory.trim():null,G=typeof de?.projectId=="string"&&de.projectId.trim().length>0?de.projectId.trim():null,Ce=!!(we||G);Pe.getState().setSessionSwitcherOpen(!1),nt.getState().openNewSessionDraft({target:Ce?"project":"chat",selectedProjectId:Ce?G:null,directoryOverride:Ce?we:null,preserveDirectoryOverride:!!we})};return window.addEventListener("openchamber:open-draft-session",V),()=>window.removeEventListener("openchamber:open-draft-session",V)},[]),c.useEffect(()=>{typeof window>"u"||!n||p||Z.current||(Z.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,p]),Mx({enabled:se}),EN({enabled:se}),ON(m||null),_N(),Ox(),$N(),Bx(),Jx(),up();const ae=c.useCallback(()=>{x(V=>!V)},[]);dN(ae),SN(),DN(!X),c.useEffect(()=>{if(X)return;const V=()=>x(J=>!J);return window.addEventListener("openchamber:memory-debug-toggle",V),()=>window.removeEventListener("openchamber:memory-debug-toggle",V)},[X]),c.useEffect(()=>{X||d&&setTimeout(()=>u(),5e3)},[u,X,d]),c.useEffect(()=>{if(!_||L!=="not-injected")return;let V=!1,J=0;const de=200,we=2e3,G=50,Ce=()=>{if(V)return;J++;const Te=kl();if(Te!=="not-injected"){if(V=!0,A(Te),Te==="valid"){const ne=Cl();ne&&P(Nl({isDesktopShell:!0,bootOutcome:ne}))}return}const pe=Math.min(de*Math.pow(1.1,J),we);if(J>=G){const ne=document.getElementById("initial-loading");ne&&!ne.textContent?.includes("taking longer")&&(ne.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(Ce,pe)};return window.setTimeout(Ce,de),()=>{V=!0}},[_,L]);const Ee=c.useCallback(async()=>{if(bh({isDesktopShell:vn(),isDesktopLocalOriginActive:ti()})){await yh();return}window.location.reload()},[]),Se=c.useCallback(async()=>{if(!B){C(!1),O(!0);try{await Ut.getState().initializeApp()}finally{O(!1)}Ut.getState().isInitialized||M(V=>V+1)}},[B]),me=V=>{if(V.screen==="recovery")return V.variant};if(_&&D&&D.screen!=="main"){if(D.screen==="chooser")return s.jsx(Ns,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Ld,{mode:"first-launch",localAvailable:D.localAvailable!==!1,onCliAvailable:Ee,onChooseRemote:()=>{}})})})});const V=me(D),J=D.screen==="recovery"&&"url"in D?D.url:void 0;return s.jsx(Ns,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Ld,{mode:"recovery",recoveryVariant:V,recoveryHostUrl:J,recoveryHostLabel:void 0,localAvailable:D.localAvailable!==!1,onCliAvailable:Ee})})})})}if(X)return s.jsx(Ns,{children:s.jsx(Ql,{sdk:fn.getSdkClient(),directory:m||"",children:s.jsx(Xl,{apis:t,children:s.jsx(ca,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:"h-full text-foreground bg-background",children:[s.jsx(eA,{embeddedSessionChat:X,isVSCodeRuntime:h,embeddedBackgroundWorkEnabled:se}),s.jsx(Jl,{}),s.jsx(Zl,{})]})})})},R)});if(S&&!n&&!h&&!X)return s.jsx(Ns,{children:s.jsx(JN,{onRetry:()=>{Se()},isRetrying:B},R)});const ke=!n&&!_;return s.jsx(Ns,{children:s.jsx(Ql,{sdk:fn.getSdkClient(),directory:m||"",children:s.jsx(Xl,{apis:t,children:s.jsx(EC,{children:s.jsx(ca,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:_?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[s.jsx(Ju,{embeddedBackgroundWorkEnabled:se}),s.jsx(au,{}),s.jsx(WN,{}),s.jsx(aC,{}),s.jsx(fp,{ready:n&&(!_||re&&ge)}),s.jsx(Zu,{}),s.jsx(Jl,{}),s.jsx(Zl,{}),!ke&&s.jsxs(s.Fragment,{children:[s.jsx(mp,{}),s.jsx(XN,{}),y&&s.jsx(VC,{onClose:()=>x(!1)})]})]})})})})},R)})}function sA(t){const e=et.c(2);let n;return e[0]!==t?(n=s.jsx(cp,{children:s.jsx(tA,{...t})}),e[0]=t,e[1]=n):n=e[1],n}function nA(t){return t.isAboutDialogOpen}function rA(t){return t.setAboutDialogOpen}function oA(){}function iA(t){return t.lastInitFailure}function aA(t){return t.currentDirectory}function lA(t){return t.currentSessionId}function cA(t){return t.setCurrentSession}const dA=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();_x();wh().then(()=>{Promise.all([vh(),Lx()]).catch(t=>{console.error("[main] settings init failed:",t)}),$x(),zx(),Wx()}).catch(t=>{console.error("[main] appearance init failed:",t)});const Nm=document.getElementById("root");if(!Nm)throw new Error("Root element not found");Kx();Gm.createRoot(Nm).render(s.jsx(ct.StrictMode,{children:s.jsx(Vx,{children:s.jsx(Ux,{children:s.jsx(Hx,{children:s.jsx(Gx,{children:s.jsx(sA,{apis:dA})})})})})}));const TA=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Xy as W,$y as a,IA as b,kf as g,TA as m,Qy as u,jf as v};
|